tinacms 2.7.3 → 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("@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", "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", "@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, get, moment, dateFns, plateLink, ToolbarPrimitive, TooltipPrimitive, plateParagraph, plateBlockQuote, plateFloating, windowSize, graphql, gql, schemaTools, core, yup, 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) => {
@@ -9608,7 +9608,7 @@ flowchart TD
9608
9608
  return this.add("error", message, timeout);
9609
9609
  }
9610
9610
  };
9611
- const NoFormsPlaceholder = () => /* @__PURE__ */ React__namespace.createElement(
9611
+ const SidebarLoadingPlaceholder = () => /* @__PURE__ */ React__namespace.createElement(
9612
9612
  "div",
9613
9613
  {
9614
9614
  className: "relative flex flex-col items-center justify-center text-center p-5 pb-16 w-full h-full overflow-y-auto",
@@ -9621,25 +9621,8 @@ flowchart TD
9621
9621
  animationDuration: "150ms"
9622
9622
  }
9623
9623
  },
9624
- /* @__PURE__ */ React__namespace.createElement(Emoji$1, { className: "pb-5" }, "🔎"),
9625
- /* @__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."),
9626
- /* @__PURE__ */ React__namespace.createElement("p", { className: "block" }, /* @__PURE__ */ React__namespace.createElement(
9627
- Button$1,
9628
- {
9629
- href: "https://tina.io/docs/tinacms-context/",
9630
- target: "_blank",
9631
- as: "a"
9632
- },
9633
- /* @__PURE__ */ React__namespace.createElement(Emoji$1, { className: "mr-1.5" }, "📖"),
9634
- " Contextual Editing"
9635
- ))
9636
- );
9637
- const Emoji$1 = ({ className = "", ...props }) => /* @__PURE__ */ React__namespace.createElement(
9638
- "span",
9639
- {
9640
- className: `text-[24px] leading-none inline-block ${className}`,
9641
- ...props
9642
- }
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)" })
9643
9626
  );
9644
9627
  class SidebarState {
9645
9628
  constructor(events, options = {}) {
@@ -9654,7 +9637,7 @@ flowchart TD
9654
9637
  };
9655
9638
  this.position = options.position || "displace";
9656
9639
  this.renderNav = options.renderNav || true;
9657
- this.placeholder = options.placeholder || NoFormsPlaceholder;
9640
+ this.loadingPlaceholder = options.placeholder || SidebarLoadingPlaceholder;
9658
9641
  if ((_a = options.buttons) == null ? void 0 : _a.save) {
9659
9642
  this.buttons.save = options.buttons.save;
9660
9643
  }
@@ -9728,238 +9711,6 @@ flowchart TD
9728
9711
  children
9729
9712
  )));
9730
9713
  };
9731
- const Item = ({
9732
- item,
9733
- depth,
9734
- setActiveFormId
9735
- }) => {
9736
- const cms = useCMS();
9737
- const depths = ["pl-6", "pl-10", "pl-14"];
9738
- const form = React__namespace.useMemo(
9739
- () => cms.state.forms.find(({ tinaForm }) => item.formId === tinaForm.id),
9740
- [item.formId]
9741
- );
9742
- return /* @__PURE__ */ React__namespace.createElement(
9743
- "button",
9744
- {
9745
- type: "button",
9746
- key: item.path,
9747
- onClick: () => setActiveFormId(item.formId),
9748
- 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`
9749
- },
9750
- /* @__PURE__ */ React__namespace.createElement(BiEdit, { className: "opacity-70 w-5 h-auto text-blue-500 flex-none" }),
9751
- /* @__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))
9752
- );
9753
- };
9754
- const FormListItem = ({
9755
- item,
9756
- depth,
9757
- setActiveFormId
9758
- }) => {
9759
- var _a;
9760
- 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) => {
9761
- if (subItem.type === "document") {
9762
- return /* @__PURE__ */ React__namespace.createElement("li", { key: subItem.formId }, /* @__PURE__ */ React__namespace.createElement(
9763
- Item,
9764
- {
9765
- setActiveFormId,
9766
- depth: depth + 1,
9767
- item: subItem
9768
- }
9769
- ));
9770
- }
9771
- })));
9772
- };
9773
- const FormLists = (props) => {
9774
- const cms = useCMS();
9775
- return /* @__PURE__ */ React__namespace.createElement(
9776
- react.Transition,
9777
- {
9778
- appear: true,
9779
- show: true,
9780
- as: "div",
9781
- enter: "transition-all ease-out duration-150",
9782
- enterFrom: "opacity-0 -translate-x-1/2",
9783
- enterTo: "opacity-100",
9784
- leave: "transition-all ease-out duration-150",
9785
- leaveFrom: "opacity-100",
9786
- leaveTo: "opacity-0 -translate-x-1/2"
9787
- },
9788
- cms.state.formLists.map((formList, index) => /* @__PURE__ */ React__namespace.createElement("div", { key: `${formList.id}-${index}`, className: "pt-16" }, /* @__PURE__ */ React__namespace.createElement(
9789
- FormList,
9790
- {
9791
- isEditing: props.isEditing,
9792
- setActiveFormId: (id) => {
9793
- cms.dispatch({ type: "forms:set-active-form-id", value: id });
9794
- },
9795
- formList
9796
- }
9797
- )))
9798
- );
9799
- };
9800
- const FormList = (props) => {
9801
- const cms = useCMS();
9802
- const listItems = React__namespace.useMemo(() => {
9803
- var _a;
9804
- const orderedListItems = [];
9805
- const globalItems = [];
9806
- const topItems = [];
9807
- props.formList.items.forEach((item) => {
9808
- if (item.type === "document") {
9809
- const form = cms.state.forms.find(
9810
- ({ tinaForm }) => tinaForm.id === item.formId
9811
- );
9812
- if (form.tinaForm.global) {
9813
- globalItems.push(item);
9814
- } else {
9815
- orderedListItems.push(item);
9816
- }
9817
- } else {
9818
- orderedListItems.push(item);
9819
- }
9820
- });
9821
- if (((_a = orderedListItems[0]) == null ? void 0 : _a.type) === "document") {
9822
- topItems.push({ type: "list", label: "Documents" });
9823
- }
9824
- let extra = [];
9825
- if (globalItems.length) {
9826
- extra = [{ type: "list", label: "Global Documents" }, ...globalItems];
9827
- }
9828
- return [...topItems, ...orderedListItems, ...extra];
9829
- }, [JSON.stringify(props.formList.items)]);
9830
- return /* @__PURE__ */ React__namespace.createElement("ul", null, /* @__PURE__ */ React__namespace.createElement("li", { className: "divide-y divide-gray-200" }, listItems.map((item, index) => {
9831
- if (item.type === "list") {
9832
- return /* @__PURE__ */ React__namespace.createElement(
9833
- "div",
9834
- {
9835
- key: item.label,
9836
- className: `relative group text-left w-full bg-white shadow-sm
9837
- 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"}`
9838
- },
9839
- /* @__PURE__ */ React__namespace.createElement(
9840
- "span",
9841
- {
9842
- className: "text-sm tracking-wide font-bold text-gray-700 uppercase"
9843
- },
9844
- item.label
9845
- )
9846
- );
9847
- }
9848
- return /* @__PURE__ */ React__namespace.createElement(
9849
- FormListItem,
9850
- {
9851
- setActiveFormId: (id) => props.setActiveFormId(id),
9852
- key: item.formId,
9853
- item,
9854
- depth: 0
9855
- }
9856
- );
9857
- })));
9858
- };
9859
- const FormsView = ({
9860
- children
9861
- }) => {
9862
- const cms = useCMS$1();
9863
- const { setFormIsPristine } = React__namespace.useContext(SidebarContext);
9864
- const isMultiform = cms.state.forms.length > 1;
9865
- const activeForm = cms.state.forms.find(
9866
- ({ tinaForm }) => tinaForm.id === cms.state.activeFormId
9867
- );
9868
- const isEditing = !!activeForm;
9869
- if (!cms.state.formLists.length) {
9870
- return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, " ", children, " ");
9871
- }
9872
- if (isMultiform && !activeForm) {
9873
- return /* @__PURE__ */ React__namespace.createElement(FormLists, { isEditing });
9874
- }
9875
- const formMetas = cms.plugins.all("form:meta");
9876
- 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 })));
9877
- };
9878
- const FormWrapper$1 = ({ isEditing, children }) => {
9879
- return /* @__PURE__ */ React__namespace.createElement(
9880
- "div",
9881
- {
9882
- className: "flex-1 flex flex-col flex-nowrap overflow-hidden h-full w-full relative bg-white",
9883
- style: isEditing ? {
9884
- transform: "none",
9885
- animationName: "fly-in-left",
9886
- animationDuration: "150ms",
9887
- animationDelay: "0",
9888
- animationIterationCount: 1,
9889
- animationTimingFunction: "ease-out"
9890
- } : {
9891
- transform: "translate3d(100%, 0, 0)"
9892
- }
9893
- },
9894
- children
9895
- );
9896
- };
9897
- const MultiformFormHeader = ({
9898
- activeForm
9899
- }) => {
9900
- const cms = useCMS$1();
9901
- const { formIsPristine } = React__namespace.useContext(SidebarContext);
9902
- return /* @__PURE__ */ React__namespace.createElement(
9903
- "div",
9904
- {
9905
- className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
9906
- },
9907
- /* @__PURE__ */ React__namespace.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React__namespace.createElement(
9908
- "button",
9909
- {
9910
- type: "button",
9911
- className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
9912
- onClick: () => {
9913
- const state = activeForm.tinaForm.finalForm.getState();
9914
- if (state.invalid === true) {
9915
- cms.alerts.error("Cannot navigate away from an invalid form.");
9916
- } else {
9917
- cms.dispatch({ type: "forms:set-active-form-id", value: null });
9918
- }
9919
- }
9920
- },
9921
- /* @__PURE__ */ React__namespace.createElement(BiDotsVertical, { className: "h-auto w-5 inline-block opacity-70" })
9922
- ), /* @__PURE__ */ React__namespace.createElement(
9923
- "button",
9924
- {
9925
- type: "button",
9926
- className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
9927
- onClick: () => {
9928
- const collectionName = cms.api.tina.schema.getCollectionByFullPath(
9929
- cms.state.activeFormId
9930
- ).name;
9931
- window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
9932
- }
9933
- },
9934
- /* @__PURE__ */ React__namespace.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
9935
- ), /* @__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 }))
9936
- );
9937
- };
9938
- const FormHeader = ({ activeForm }) => {
9939
- const { formIsPristine } = React__namespace.useContext(SidebarContext);
9940
- const cms = useCMS$1();
9941
- const shortFormLabel = activeForm.tinaForm.label ? activeForm.tinaForm.label.replace(/^.*[\\\/]/, "") : false;
9942
- return /* @__PURE__ */ React__namespace.createElement(
9943
- "div",
9944
- {
9945
- className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
9946
- },
9947
- /* @__PURE__ */ React__namespace.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React__namespace.createElement(
9948
- "button",
9949
- {
9950
- type: "button",
9951
- className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
9952
- onClick: () => {
9953
- const collectionName = cms.api.tina.schema.getCollectionByFullPath(
9954
- cms.state.activeFormId
9955
- ).name;
9956
- window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
9957
- }
9958
- },
9959
- /* @__PURE__ */ React__namespace.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
9960
- ), 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 }))
9961
- );
9962
- };
9963
9714
  function ImFilesEmpty(props) {
9964
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);
9965
9716
  }
@@ -10202,7 +9953,7 @@ flowchart TD
10202
9953
  "Event Log"
10203
9954
  ));
10204
9955
  };
10205
- const version = "2.7.3";
9956
+ const version = "2.7.4";
10206
9957
  const Nav = ({
10207
9958
  isLocalMode,
10208
9959
  className = "",
@@ -10247,201 +9998,488 @@ flowchart TD
10247
9998
  acc[category].push(screen);
10248
9999
  return acc;
10249
10000
  },
10250
- { Site: [] }
10001
+ { Site: [] }
10002
+ );
10003
+ return /* @__PURE__ */ React__namespace.createElement(
10004
+ "div",
10005
+ {
10006
+ className: `relative z-30 flex flex-col bg-white border-r border-gray-200 w-96 h-full ${className}`,
10007
+ style: { maxWidth: `${sidebarWidth}px` },
10008
+ ...props
10009
+ },
10010
+ /* @__PURE__ */ React__namespace.createElement("div", { className: "border-b border-gray-200" }, /* @__PURE__ */ React__namespace.createElement(react.Menu, { as: "div", className: "relative block" }, ({ open: open2 }) => /* @__PURE__ */ React__namespace.createElement("div", null, /* @__PURE__ */ React__namespace.createElement(
10011
+ react.MenuButton,
10012
+ {
10013
+ className: `group w-full px-6 py-3 gap-2 flex justify-between items-center transition-colors duration-150 ease-out ${open2 ? "bg-gray-50" : "bg-transparent"}`
10014
+ },
10015
+ /* @__PURE__ */ React__namespace.createElement("span", { className: "text-left inline-flex items-center text-xl tracking-wide text-gray-800 flex-1 gap-1 opacity-80 group-hover:opacity-100 transition-opacity duration-150 ease-out" }, /* @__PURE__ */ React__namespace.createElement(
10016
+ "svg",
10017
+ {
10018
+ viewBox: "0 0 32 32",
10019
+ fill: "#EC4815",
10020
+ xmlns: "http://www.w3.org/2000/svg",
10021
+ className: "w-10 h-auto -ml-1"
10022
+ },
10023
+ /* @__PURE__ */ React__namespace.createElement("path", { d: "M18.6466 14.5553C19.9018 13.5141 20.458 7.36086 21.0014 5.14903C21.5447 2.9372 23.7919 3.04938 23.7919 3.04938C23.7919 3.04938 23.2085 4.06764 23.4464 4.82751C23.6844 5.58738 25.3145 6.26662 25.3145 6.26662L24.9629 7.19622C24.9629 7.19622 24.2288 7.10204 23.7919 7.9785C23.355 8.85496 24.3392 17.4442 24.3392 17.4442C24.3392 17.4442 21.4469 22.7275 21.4469 24.9206C21.4469 27.1136 22.4819 28.9515 22.4819 28.9515H21.0296C21.0296 28.9515 18.899 26.4086 18.462 25.1378C18.0251 23.8669 18.1998 22.596 18.1998 22.596C18.1998 22.596 15.8839 22.4646 13.8303 22.596C11.7767 22.7275 10.4072 24.498 10.16 25.4884C9.91287 26.4787 9.81048 28.9515 9.81048 28.9515H8.66211C7.96315 26.7882 7.40803 26.0129 7.70918 24.9206C8.54334 21.8949 8.37949 20.1788 8.18635 19.4145C7.99321 18.6501 6.68552 17.983 6.68552 17.983C7.32609 16.6741 7.97996 16.0452 10.7926 15.9796C13.6052 15.914 17.3915 15.5965 18.6466 14.5553Z" }),
10024
+ /* @__PURE__ */ React__namespace.createElement("path", { d: "M11.1268 24.7939C11.1268 24.7939 11.4236 27.5481 13.0001 28.9516H14.3511C13.0001 27.4166 12.8527 23.4155 12.8527 23.4155C12.1656 23.6399 11.3045 24.3846 11.1268 24.7939Z" })
10025
+ ), /* @__PURE__ */ React__namespace.createElement("span", null, "Tina")),
10026
+ /* @__PURE__ */ React__namespace.createElement(SyncErrorWidget, { cms }),
10027
+ /* @__PURE__ */ React__namespace.createElement(
10028
+ FiMoreVertical,
10029
+ {
10030
+ className: `flex-0 w-6 h-full inline-block group-hover:opacity-80 transition-all duration-300 ease-in-out transform ${open2 ? "opacity-100 text-blue-400" : "text-gray-400 opacity-50 hover:opacity-70"}`
10031
+ }
10032
+ )
10033
+ ), /* @__PURE__ */ React__namespace.createElement("div", { className: "transform translate-y-full absolute bottom-3 right-5 z-50" }, /* @__PURE__ */ React__namespace.createElement(
10034
+ react.Transition,
10035
+ {
10036
+ enter: "transition duration-150 ease-out",
10037
+ enterFrom: "transform opacity-0 -translate-y-2",
10038
+ enterTo: "transform opacity-100 translate-y-0",
10039
+ leave: "transition duration-75 ease-in",
10040
+ leaveFrom: "transform opacity-100 translate-y-0",
10041
+ leaveTo: "transform opacity-0 -translate-y-2"
10042
+ },
10043
+ /* @__PURE__ */ React__namespace.createElement(react.MenuItems, { className: "bg-white border border-gray-150 rounded-lg shadow-lg flex flex-col items-stretch overflow-hidden" }, /* @__PURE__ */ React__namespace.createElement(react.MenuItem, null, /* @__PURE__ */ React__namespace.createElement(
10044
+ "button",
10045
+ {
10046
+ className: `text-lg px-4 py-2 first:pt-3 last:pb-3 tracking-wide whitespace-nowrap flex items-center opacity-80 text-gray-600 hover:text-blue-400 hover:bg-gray-50 hover:opacity-100`,
10047
+ onClick: async () => {
10048
+ var _a, _b, _c, _d, _e, _f, _g, _h;
10049
+ updateBodyDisplacement({
10050
+ displayState: "closed",
10051
+ sidebarWidth: null,
10052
+ resizingSidebar: false
10053
+ });
10054
+ try {
10055
+ if ((_c = (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.authProvider) == null ? void 0 : _c.logout) {
10056
+ await ((_d = cms.api.tina) == null ? void 0 : _d.authProvider.logout());
10057
+ if ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.onLogout) {
10058
+ await ((_h = (_g = cms == null ? void 0 : cms.api) == null ? void 0 : _g.tina) == null ? void 0 : _h.onLogout());
10059
+ await new Promise(
10060
+ (resolve) => setTimeout(resolve, 500)
10061
+ );
10062
+ }
10063
+ window.location.href = new URL(
10064
+ window.location.href
10065
+ ).pathname;
10066
+ }
10067
+ } catch (e) {
10068
+ cms.alerts.error(`Error logging out: ${e}`);
10069
+ console.error("Unexpected error calling logout");
10070
+ console.error(e);
10071
+ }
10072
+ }
10073
+ },
10074
+ /* @__PURE__ */ React__namespace.createElement(BiExit, { className: "w-6 h-auto mr-2 text-blue-400" }),
10075
+ " Log Out"
10076
+ )), /* @__PURE__ */ React__namespace.createElement(react.MenuItem, null, /* @__PURE__ */ React__namespace.createElement(
10077
+ WrappedSyncStatus,
10078
+ {
10079
+ cms,
10080
+ setEventsOpen
10081
+ }
10082
+ )))
10083
+ ))))),
10084
+ eventsOpen && /* @__PURE__ */ React__namespace.createElement(SyncStatusModal, { cms, closeEventsModal }),
10085
+ children,
10086
+ /* @__PURE__ */ React__namespace.createElement("div", { className: "flex flex-col px-6 flex-1 overflow-auto" }, showCollections && /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("h4", { className: "flex space-x-1 justify-items-start uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, /* @__PURE__ */ React__namespace.createElement("span", null, "Collections"), isLocalMode && /* @__PURE__ */ React__namespace.createElement("span", { className: "flex items-center" }, /* @__PURE__ */ React__namespace.createElement(
10087
+ "a",
10088
+ {
10089
+ href: "https://tina.io/docs/schema/#defining-collections",
10090
+ target: "_blank"
10091
+ },
10092
+ /* @__PURE__ */ React__namespace.createElement(FiInfo, null)
10093
+ ))), /* @__PURE__ */ React__namespace.createElement(
10094
+ CollectionsList,
10095
+ {
10096
+ RenderNavCollection,
10097
+ collections: contentCollections
10098
+ }
10099
+ )), (screenCategories.Site.length > 0 || contentCreators.length) > 0 && /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, "Site"), /* @__PURE__ */ React__namespace.createElement("ul", { className: "flex flex-col gap-4" }, screenCategories.Site.map((view) => {
10100
+ return /* @__PURE__ */ React__namespace.createElement("li", { key: `nav-site-${view.name}` }, /* @__PURE__ */ React__namespace.createElement(RenderNavSite, { view }));
10101
+ }), contentCreators.map((plugin, idx) => {
10102
+ return /* @__PURE__ */ React__namespace.createElement(CreateContentNavItem, { key: `plugin-${idx}`, plugin });
10103
+ }), authCollection && /* @__PURE__ */ React__namespace.createElement(
10104
+ CollectionsList,
10105
+ {
10106
+ RenderNavCollection: AuthRenderNavCollection,
10107
+ collections: [authCollection]
10108
+ }
10109
+ ))), Object.entries(screenCategories).map(([category, screens2]) => {
10110
+ if (category !== "Site") {
10111
+ return /* @__PURE__ */ React__namespace.createElement("div", { key: category }, /* @__PURE__ */ React__namespace.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, category), /* @__PURE__ */ React__namespace.createElement("ul", { className: "flex flex-col gap-4" }, screens2.map((view) => {
10112
+ return /* @__PURE__ */ React__namespace.createElement("li", { key: `nav-site-${view.name}` }, /* @__PURE__ */ React__namespace.createElement(RenderNavSite, { view }));
10113
+ })));
10114
+ }
10115
+ }), !!(cloudConfigs == null ? void 0 : cloudConfigs.length) && /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, "Cloud"), /* @__PURE__ */ React__namespace.createElement("ul", { className: "flex flex-col gap-4" }, cloudConfigs.map((config) => {
10116
+ return /* @__PURE__ */ React__namespace.createElement("li", { key: `nav-site-${config.name}` }, /* @__PURE__ */ React__namespace.createElement(RenderNavCloud, { config }));
10117
+ }))), /* @__PURE__ */ React__namespace.createElement("div", { className: "grow" }), /* @__PURE__ */ React__namespace.createElement("span", { className: "font-sans font-light text-xs mb-3 mt-8 text-gray-500" }, "v", version))
10118
+ );
10119
+ };
10120
+ const CollectionsList = ({
10121
+ collections,
10122
+ RenderNavCollection
10123
+ }) => {
10124
+ if (collections.length === 0) {
10125
+ return /* @__PURE__ */ React__namespace.createElement("div", null, "No collections found");
10126
+ }
10127
+ return /* @__PURE__ */ React__namespace.createElement("ul", { className: "flex flex-col gap-4" }, collections.map((collection) => {
10128
+ return /* @__PURE__ */ React__namespace.createElement("li", { key: `nav-collection-${collection.name}` }, /* @__PURE__ */ React__namespace.createElement(RenderNavCollection, { collection }));
10129
+ }));
10130
+ };
10131
+ const CreateContentNavItem = ({ plugin }) => {
10132
+ const [open2, setOpen] = React__namespace.useState(false);
10133
+ return /* @__PURE__ */ React__namespace.createElement("li", { key: plugin.name }, /* @__PURE__ */ React__namespace.createElement(
10134
+ "button",
10135
+ {
10136
+ className: "text-base tracking-wide text-gray-500 hover:text-blue-600 flex items-center opacity-90 hover:opacity-100",
10137
+ onClick: () => {
10138
+ setOpen(true);
10139
+ }
10140
+ },
10141
+ /* @__PURE__ */ React__namespace.createElement(VscNewFile, { className: "mr-3 h-6 opacity-80 w-auto" }),
10142
+ " ",
10143
+ plugin.name
10144
+ ), open2 && /* @__PURE__ */ React__namespace.createElement(FormModal, { plugin, close: () => setOpen(false) }));
10145
+ };
10146
+ const ResizeHandle = () => {
10147
+ const {
10148
+ resizingSidebar,
10149
+ setResizingSidebar,
10150
+ fullscreen,
10151
+ setSidebarWidth,
10152
+ displayState
10153
+ } = React__namespace.useContext(SidebarContext);
10154
+ React__namespace.useEffect(() => {
10155
+ const handleMouseUp = () => setResizingSidebar(false);
10156
+ window.addEventListener("mouseup", handleMouseUp);
10157
+ return () => {
10158
+ window.removeEventListener("mouseup", handleMouseUp);
10159
+ };
10160
+ }, []);
10161
+ React__namespace.useEffect(() => {
10162
+ const handleMouseMove = (e) => {
10163
+ setSidebarWidth((sidebarWidth) => {
10164
+ const newWidth = sidebarWidth + e.movementX;
10165
+ const maxWidth = window.innerWidth - 8;
10166
+ if (newWidth < minSidebarWidth) {
10167
+ return minSidebarWidth;
10168
+ } else if (newWidth > maxWidth) {
10169
+ return maxWidth;
10170
+ } else {
10171
+ return newWidth;
10172
+ }
10173
+ });
10174
+ };
10175
+ if (resizingSidebar) {
10176
+ window.addEventListener("mousemove", handleMouseMove);
10177
+ document.body.classList.add("select-none");
10178
+ }
10179
+ return () => {
10180
+ window.removeEventListener("mousemove", handleMouseMove);
10181
+ document.body.classList.remove("select-none");
10182
+ };
10183
+ }, [resizingSidebar]);
10184
+ const handleresizingSidebar = () => setResizingSidebar(true);
10185
+ if (fullscreen) {
10186
+ return null;
10187
+ }
10188
+ return /* @__PURE__ */ React__namespace.createElement(
10189
+ "div",
10190
+ {
10191
+ onMouseDown: handleresizingSidebar,
10192
+ className: `z-100 absolute top-1/2 right-px w-2 h-32 bg-white rounded-r-md border border-gray-150 shadow-sm hover:shadow-md origin-left transition-all duration-150 ease-out transform translate-x-full -translate-y-1/2 group hover:bg-gray-50 ${displayState !== "closed" ? `opacity-100` : `opacity-0`} ${resizingSidebar ? `scale-110` : `scale-90 hover:scale-100`}`,
10193
+ style: { cursor: "grab" }
10194
+ },
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" })
10196
+ );
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
10251
10417
  );
10418
+ };
10419
+ const MultiformFormHeader = ({
10420
+ activeForm
10421
+ }) => {
10422
+ const cms = useCMS$1();
10423
+ const { formIsPristine } = React__namespace.useContext(SidebarContext);
10252
10424
  return /* @__PURE__ */ React__namespace.createElement(
10253
10425
  "div",
10254
10426
  {
10255
- className: `relative z-30 flex flex-col bg-white border-r border-gray-200 w-96 h-full ${className}`,
10256
- style: { maxWidth: `${sidebarWidth}px` },
10257
- ...props
10427
+ className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
10258
10428
  },
10259
- /* @__PURE__ */ React__namespace.createElement("div", { className: "border-b border-gray-200" }, /* @__PURE__ */ React__namespace.createElement(react.Menu, { as: "div", className: "relative block" }, ({ open: open2 }) => /* @__PURE__ */ React__namespace.createElement("div", null, /* @__PURE__ */ React__namespace.createElement(
10260
- react.MenuButton,
10261
- {
10262
- className: `group w-full px-6 py-3 gap-2 flex justify-between items-center transition-colors duration-150 ease-out ${open2 ? "bg-gray-50" : "bg-transparent"}`
10263
- },
10264
- /* @__PURE__ */ React__namespace.createElement("span", { className: "text-left inline-flex items-center text-xl tracking-wide text-gray-800 flex-1 gap-1 opacity-80 group-hover:opacity-100 transition-opacity duration-150 ease-out" }, /* @__PURE__ */ React__namespace.createElement(
10265
- "svg",
10266
- {
10267
- viewBox: "0 0 32 32",
10268
- fill: "#EC4815",
10269
- xmlns: "http://www.w3.org/2000/svg",
10270
- className: "w-10 h-auto -ml-1"
10271
- },
10272
- /* @__PURE__ */ React__namespace.createElement("path", { d: "M18.6466 14.5553C19.9018 13.5141 20.458 7.36086 21.0014 5.14903C21.5447 2.9372 23.7919 3.04938 23.7919 3.04938C23.7919 3.04938 23.2085 4.06764 23.4464 4.82751C23.6844 5.58738 25.3145 6.26662 25.3145 6.26662L24.9629 7.19622C24.9629 7.19622 24.2288 7.10204 23.7919 7.9785C23.355 8.85496 24.3392 17.4442 24.3392 17.4442C24.3392 17.4442 21.4469 22.7275 21.4469 24.9206C21.4469 27.1136 22.4819 28.9515 22.4819 28.9515H21.0296C21.0296 28.9515 18.899 26.4086 18.462 25.1378C18.0251 23.8669 18.1998 22.596 18.1998 22.596C18.1998 22.596 15.8839 22.4646 13.8303 22.596C11.7767 22.7275 10.4072 24.498 10.16 25.4884C9.91287 26.4787 9.81048 28.9515 9.81048 28.9515H8.66211C7.96315 26.7882 7.40803 26.0129 7.70918 24.9206C8.54334 21.8949 8.37949 20.1788 8.18635 19.4145C7.99321 18.6501 6.68552 17.983 6.68552 17.983C7.32609 16.6741 7.97996 16.0452 10.7926 15.9796C13.6052 15.914 17.3915 15.5965 18.6466 14.5553Z" }),
10273
- /* @__PURE__ */ React__namespace.createElement("path", { d: "M11.1268 24.7939C11.1268 24.7939 11.4236 27.5481 13.0001 28.9516H14.3511C13.0001 27.4166 12.8527 23.4155 12.8527 23.4155C12.1656 23.6399 11.3045 24.3846 11.1268 24.7939Z" })
10274
- ), /* @__PURE__ */ React__namespace.createElement("span", null, "Tina")),
10275
- /* @__PURE__ */ React__namespace.createElement(SyncErrorWidget, { cms }),
10276
- /* @__PURE__ */ React__namespace.createElement(
10277
- FiMoreVertical,
10278
- {
10279
- className: `flex-0 w-6 h-full inline-block group-hover:opacity-80 transition-all duration-300 ease-in-out transform ${open2 ? "opacity-100 text-blue-400" : "text-gray-400 opacity-50 hover:opacity-70"}`
10280
- }
10281
- )
10282
- ), /* @__PURE__ */ React__namespace.createElement("div", { className: "transform translate-y-full absolute bottom-3 right-5 z-50" }, /* @__PURE__ */ React__namespace.createElement(
10283
- react.Transition,
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",
10284
10431
  {
10285
- enter: "transition duration-150 ease-out",
10286
- enterFrom: "transform opacity-0 -translate-y-2",
10287
- enterTo: "transform opacity-100 translate-y-0",
10288
- leave: "transition duration-75 ease-in",
10289
- leaveFrom: "transform opacity-100 translate-y-0",
10290
- leaveTo: "transform opacity-0 -translate-y-2"
10291
- },
10292
- /* @__PURE__ */ React__namespace.createElement(react.MenuItems, { className: "bg-white border border-gray-150 rounded-lg shadow-lg flex flex-col items-stretch overflow-hidden" }, /* @__PURE__ */ React__namespace.createElement(react.MenuItem, null, /* @__PURE__ */ React__namespace.createElement(
10293
- "button",
10294
- {
10295
- className: `text-lg px-4 py-2 first:pt-3 last:pb-3 tracking-wide whitespace-nowrap flex items-center opacity-80 text-gray-600 hover:text-blue-400 hover:bg-gray-50 hover:opacity-100`,
10296
- onClick: async () => {
10297
- var _a, _b, _c, _d, _e, _f, _g, _h;
10298
- updateBodyDisplacement({
10299
- displayState: "closed",
10300
- sidebarWidth: null,
10301
- resizingSidebar: false
10302
- });
10303
- try {
10304
- if ((_c = (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.authProvider) == null ? void 0 : _c.logout) {
10305
- await ((_d = cms.api.tina) == null ? void 0 : _d.authProvider.logout());
10306
- if ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.onLogout) {
10307
- await ((_h = (_g = cms == null ? void 0 : cms.api) == null ? void 0 : _g.tina) == null ? void 0 : _h.onLogout());
10308
- await new Promise(
10309
- (resolve) => setTimeout(resolve, 500)
10310
- );
10311
- }
10312
- window.location.href = new URL(
10313
- window.location.href
10314
- ).pathname;
10315
- }
10316
- } catch (e) {
10317
- cms.alerts.error(`Error logging out: ${e}`);
10318
- console.error("Unexpected error calling logout");
10319
- console.error(e);
10320
- }
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 });
10321
10440
  }
10322
- },
10323
- /* @__PURE__ */ React__namespace.createElement(BiExit, { className: "w-6 h-auto mr-2 text-blue-400" }),
10324
- " Log Out"
10325
- )), /* @__PURE__ */ React__namespace.createElement(react.MenuItem, null, /* @__PURE__ */ React__namespace.createElement(
10326
- WrappedSyncStatus,
10327
- {
10328
- cms,
10329
- setEventsOpen
10330
10441
  }
10331
- )))
10332
- ))))),
10333
- eventsOpen && /* @__PURE__ */ React__namespace.createElement(SyncStatusModal, { cms, closeEventsModal }),
10334
- children,
10335
- /* @__PURE__ */ React__namespace.createElement("div", { className: "flex flex-col px-6 flex-1 overflow-auto" }, showCollections && /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("h4", { className: "flex space-x-1 justify-items-start uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, /* @__PURE__ */ React__namespace.createElement("span", null, "Collections"), isLocalMode && /* @__PURE__ */ React__namespace.createElement("span", { className: "flex items-center" }, /* @__PURE__ */ React__namespace.createElement(
10336
- "a",
10337
- {
10338
- href: "https://tina.io/docs/schema/#defining-collections",
10339
- target: "_blank"
10340
10442
  },
10341
- /* @__PURE__ */ React__namespace.createElement(FiInfo, null)
10342
- ))), /* @__PURE__ */ React__namespace.createElement(
10343
- CollectionsList,
10344
- {
10345
- RenderNavCollection,
10346
- collections: contentCollections
10347
- }
10348
- )), (screenCategories.Site.length > 0 || contentCreators.length) > 0 && /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, "Site"), /* @__PURE__ */ React__namespace.createElement("ul", { className: "flex flex-col gap-4" }, screenCategories.Site.map((view) => {
10349
- return /* @__PURE__ */ React__namespace.createElement("li", { key: `nav-site-${view.name}` }, /* @__PURE__ */ React__namespace.createElement(RenderNavSite, { view }));
10350
- }), contentCreators.map((plugin, idx) => {
10351
- return /* @__PURE__ */ React__namespace.createElement(CreateContentNavItem, { key: `plugin-${idx}`, plugin });
10352
- }), authCollection && /* @__PURE__ */ React__namespace.createElement(
10353
- CollectionsList,
10443
+ /* @__PURE__ */ React__namespace.createElement(BiDotsVertical, { className: "h-auto w-5 inline-block opacity-70" })
10444
+ ), /* @__PURE__ */ React__namespace.createElement(
10445
+ "button",
10354
10446
  {
10355
- RenderNavCollection: AuthRenderNavCollection,
10356
- collections: [authCollection]
10357
- }
10358
- ))), Object.entries(screenCategories).map(([category, screens2]) => {
10359
- if (category !== "Site") {
10360
- return /* @__PURE__ */ React__namespace.createElement("div", { key: category }, /* @__PURE__ */ React__namespace.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, category), /* @__PURE__ */ React__namespace.createElement("ul", { className: "flex flex-col gap-4" }, screens2.map((view) => {
10361
- return /* @__PURE__ */ React__namespace.createElement("li", { key: `nav-site-${view.name}` }, /* @__PURE__ */ React__namespace.createElement(RenderNavSite, { view }));
10362
- })));
10363
- }
10364
- }), !!(cloudConfigs == null ? void 0 : cloudConfigs.length) && /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("h4", { className: "uppercase font-sans font-bold text-sm mb-3 mt-8 text-gray-700" }, "Cloud"), /* @__PURE__ */ React__namespace.createElement("ul", { className: "flex flex-col gap-4" }, cloudConfigs.map((config) => {
10365
- return /* @__PURE__ */ React__namespace.createElement("li", { key: `nav-site-${config.name}` }, /* @__PURE__ */ React__namespace.createElement(RenderNavCloud, { config }));
10366
- }))), /* @__PURE__ */ React__namespace.createElement("div", { className: "grow" }), /* @__PURE__ */ React__namespace.createElement("span", { className: "font-sans font-light text-xs mb-3 mt-8 text-gray-500" }, "v", version))
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 }))
10367
10458
  );
10368
10459
  };
10369
- const CollectionsList = ({
10370
- collections,
10371
- RenderNavCollection
10372
- }) => {
10373
- if (collections.length === 0) {
10374
- return /* @__PURE__ */ React__namespace.createElement("div", null, "No collections found");
10375
- }
10376
- return /* @__PURE__ */ React__namespace.createElement("ul", { className: "flex flex-col gap-4" }, collections.map((collection) => {
10377
- return /* @__PURE__ */ React__namespace.createElement("li", { key: `nav-collection-${collection.name}` }, /* @__PURE__ */ React__namespace.createElement(RenderNavCollection, { collection }));
10378
- }));
10379
- };
10380
- const CreateContentNavItem = ({ plugin }) => {
10381
- const [open2, setOpen] = React__namespace.useState(false);
10382
- return /* @__PURE__ */ React__namespace.createElement("li", { key: plugin.name }, /* @__PURE__ */ React__namespace.createElement(
10383
- "button",
10384
- {
10385
- className: "text-base tracking-wide text-gray-500 hover:text-blue-600 flex items-center opacity-90 hover:opacity-100",
10386
- onClick: () => {
10387
- setOpen(true);
10388
- }
10389
- },
10390
- /* @__PURE__ */ React__namespace.createElement(VscNewFile, { className: "mr-3 h-6 opacity-80 w-auto" }),
10391
- " ",
10392
- plugin.name
10393
- ), open2 && /* @__PURE__ */ React__namespace.createElement(FormModal, { plugin, close: () => setOpen(false) }));
10394
- };
10395
- const ResizeHandle = () => {
10396
- const {
10397
- resizingSidebar,
10398
- setResizingSidebar,
10399
- fullscreen,
10400
- setSidebarWidth,
10401
- displayState
10402
- } = React__namespace.useContext(SidebarContext);
10403
- React__namespace.useEffect(() => {
10404
- const handleMouseUp = () => setResizingSidebar(false);
10405
- window.addEventListener("mouseup", handleMouseUp);
10406
- return () => {
10407
- window.removeEventListener("mouseup", handleMouseUp);
10408
- };
10409
- }, []);
10410
- React__namespace.useEffect(() => {
10411
- const handleMouseMove = (e) => {
10412
- setSidebarWidth((sidebarWidth) => {
10413
- const newWidth = sidebarWidth + e.movementX;
10414
- const maxWidth = window.innerWidth - 8;
10415
- if (newWidth < minSidebarWidth) {
10416
- return minSidebarWidth;
10417
- } else if (newWidth > maxWidth) {
10418
- return maxWidth;
10419
- } else {
10420
- return newWidth;
10421
- }
10422
- });
10423
- };
10424
- if (resizingSidebar) {
10425
- window.addEventListener("mousemove", handleMouseMove);
10426
- document.body.classList.add("select-none");
10427
- }
10428
- return () => {
10429
- window.removeEventListener("mousemove", handleMouseMove);
10430
- document.body.classList.remove("select-none");
10431
- };
10432
- }, [resizingSidebar]);
10433
- const handleresizingSidebar = () => setResizingSidebar(true);
10434
- if (fullscreen) {
10435
- return null;
10436
- }
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;
10437
10464
  return /* @__PURE__ */ React__namespace.createElement(
10438
10465
  "div",
10439
10466
  {
10440
- onMouseDown: handleresizingSidebar,
10441
- className: `z-100 absolute top-1/2 right-px w-2 h-32 bg-white rounded-r-md border border-gray-150 shadow-sm hover:shadow-md origin-left transition-all duration-150 ease-out transform translate-x-full -translate-y-1/2 group hover:bg-gray-50 ${displayState !== "closed" ? `opacity-100` : `opacity-0`} ${resizingSidebar ? `scale-110` : `scale-90 hover:scale-100`}`,
10442
- style: { cursor: "grab" }
10467
+ className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
10443
10468
  },
10444
- /* @__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" })
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 }))
10445
10483
  );
10446
10484
  };
10447
10485
  const SidebarContext = React__namespace.createContext(null);
@@ -10662,7 +10700,7 @@ flowchart TD
10662
10700
  isLocalMode: (_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.isLocalMode,
10663
10701
  branchingEnabled
10664
10702
  }
10665
- ), /* @__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(
10666
10704
  ScreenPluginModal,
10667
10705
  {
10668
10706
  screen: activeScreen,
@@ -12026,6 +12064,7 @@ flowchart TD
12026
12064
  forms: [],
12027
12065
  formLists: [],
12028
12066
  editingMode: "basic",
12067
+ isLoadingContent: false,
12029
12068
  quickEditSupported: false,
12030
12069
  sidebarDisplayState: ((_a = cms == null ? void 0 : cms.sidebar) == null ? void 0 : _a.defaultState) || "open"
12031
12070
  };
@@ -12085,7 +12124,12 @@ flowchart TD
12085
12124
  }
12086
12125
  });
12087
12126
  }
12088
- return { ...state, activeFormId, formLists: nextFormLists };
12127
+ return {
12128
+ ...state,
12129
+ activeFormId,
12130
+ formLists: nextFormLists,
12131
+ isLoadingContent: false
12132
+ };
12089
12133
  }
12090
12134
  case "form-lists:remove": {
12091
12135
  const nextFormLists = state.formLists.filter(
@@ -12154,6 +12198,9 @@ flowchart TD
12154
12198
  }
12155
12199
  return { ...state, sidebarDisplayState: action.value };
12156
12200
  }
12201
+ case "sidebar:set-loading-state": {
12202
+ return { ...state, isLoadingContent: action.value };
12203
+ }
12157
12204
  default:
12158
12205
  throw new Error(`Unhandled action ${action.type}`);
12159
12206
  }
@@ -12839,7 +12886,6 @@ flowchart TD
12839
12886
  }) => {
12840
12887
  const cms = useCMS$1();
12841
12888
  const tinaApi = cms.api.tina;
12842
- tinaApi.branch;
12843
12889
  const [disabled, setDisabled] = React__namespace.useState(false);
12844
12890
  const [newBranchName, setNewBranchName] = React__namespace.useState("");
12845
12891
  const [error, setError] = React__namespace.useState("");
@@ -12865,10 +12911,10 @@ flowchart TD
12865
12911
  const newUrl = window.location.href.replace(hash, newHash);
12866
12912
  window.location.href = newUrl;
12867
12913
  };
12868
- 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(
12869
12915
  PrefixedTextField,
12870
12916
  {
12871
- placeholder: "Branch Name",
12917
+ placeholder: "e.g. {{PAGE-NAME}}-updates",
12872
12918
  value: newBranchName,
12873
12919
  onChange: (e) => {
12874
12920
  setError("");
@@ -32618,6 +32664,35 @@ This will work when developing locally but NOT when deployed to production.
32618
32664
  }) => {
32619
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"));
32620
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
+ };
32621
32696
  const useGetCollection = (cms, collectionName, includeDocuments = true, folder, after = "", sortKey, filterArgs) => {
32622
32697
  const api = new TinaAdminApi(cms);
32623
32698
  const schema = cms.api.tina.schema;
@@ -32629,10 +32704,9 @@ This will work when developing locally but NOT when deployed to production.
32629
32704
  React.useEffect(() => {
32630
32705
  let cancelled = false;
32631
32706
  const fetchCollection = async () => {
32632
- var _a;
32633
32707
  if (await api.isAuthenticated() && !folder.loading && !cancelled) {
32634
32708
  const { name, order } = JSON.parse(sortKey || "{}");
32635
- 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;
32636
32710
  try {
32637
32711
  const collection2 = await api.fetchCollection(
32638
32712
  collectionName,