tinacms 2.7.3 → 2.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -43,6 +43,7 @@ import { twMerge } from "tailwind-merge";
43
43
  import { Command as Command$1 } from "cmdk";
44
44
  import { isHotkey } from "is-hotkey";
45
45
  import { Transforms, Element, Range, Path, Node, Editor as Editor$1 } from "slate";
46
+ import { useWindowWidth } from "@react-hook/window-size";
46
47
  import get from "lodash.get";
47
48
  import moment from "moment";
48
49
  import { formatDistanceToNow } from "date-fns";
@@ -52,14 +53,13 @@ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
52
53
  import { ELEMENT_PARAGRAPH as ELEMENT_PARAGRAPH$1 } from "@udecode/plate-paragraph";
53
54
  import { ELEMENT_BLOCKQUOTE as ELEMENT_BLOCKQUOTE$1 } from "@udecode/plate-block-quote";
54
55
  import { useFloatingToolbarState, offset, flip, useFloatingToolbar } from "@udecode/plate-floating";
55
- import { useWindowWidth } from "@react-hook/window-size";
56
56
  import { getIntrospectionQuery, buildClientSchema, print, parse as parse$3, buildSchema } from "graphql";
57
- import gql from "graphql-tag";
58
57
  import { TinaSchema, addNamespaceToSchema, parseURL, resolveForm, normalizePath, validateSchema } from "@tinacms/schema-tools";
59
58
  import { NAMER, resolveField } from "@tinacms/schema-tools";
59
+ import gql from "graphql-tag";
60
60
  import { diff } from "@graphql-inspector/core";
61
61
  import * as yup from "yup";
62
- import { NavLink, useNavigate, useLocation, useParams, Link, useSearchParams, HashRouter, Routes, Route } from "react-router-dom";
62
+ import { NavLink, useLocation, useNavigate, useParams, Link, useSearchParams, HashRouter, Routes, Route } from "react-router-dom";
63
63
  import { stringifyMDX } from "@tinacms/mdx";
64
64
  const ModalProvider = ({ children }) => {
65
65
  const [modalRootContainerRef, setModalRootContainerRef] = useState(
@@ -4430,36 +4430,6 @@ function MdOutlineArrowBackIos(props) {
4430
4430
  function MdOutlinePerson(props) {
4431
4431
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" }, "child": [] }, { "tag": "path", "attr": { "d": "M12 6c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2m0 10c2.7 0 5.8 1.29 6 2H6c.23-.72 3.31-2 6-2m0-12C9.79 4 8 5.79 8 8s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 10c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" }, "child": [] }] })(props);
4432
4432
  }
4433
- const BranchContext = React.createContext({
4434
- currentBranch: null,
4435
- setCurrentBranch: (branch) => {
4436
- console.warn("BranchContext not initialized");
4437
- }
4438
- });
4439
- const BranchDataProvider = ({
4440
- currentBranch,
4441
- setCurrentBranch,
4442
- children
4443
- }) => {
4444
- return /* @__PURE__ */ React.createElement(
4445
- BranchContext.Provider,
4446
- {
4447
- value: {
4448
- currentBranch,
4449
- setCurrentBranch
4450
- }
4451
- },
4452
- children
4453
- );
4454
- };
4455
- const useBranchData = () => {
4456
- const branchData = React.useContext(BranchContext);
4457
- const { dispatch } = useEvent("branch:change");
4458
- React.useEffect(() => {
4459
- dispatch({ branchName: branchData.currentBranch });
4460
- }, [branchData.currentBranch]);
4461
- return branchData;
4462
- };
4463
4433
  const textFieldClasses = "shadow-inner focus:shadow-outline focus:border-blue-500 focus:outline-none block text-base placeholder:text-gray-300 px-3 py-2 text-gray-600 w-full bg-white border border-gray-200 transition-all ease-out duration-150 focus:text-gray-900 rounded-md";
4464
4434
  const disabledClasses$1 = "opacity-50 pointer-events-none cursor-not-allowed";
4465
4435
  const BaseTextField = React.forwardRef(({ className, disabled, ...rest }, ref) => {
@@ -8063,9 +8033,6 @@ const PasswordFieldPlugin = {
8063
8033
  },
8064
8034
  parse: parse$2
8065
8035
  };
8066
- function GrCircleQuestion(props) {
8067
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "strokeWidth": "2", "d": "M12,22 C17.5228475,22 22,17.5228475 22,12 C22,6.4771525 17.5228475,2 12,2 C6.4771525,2 2,6.4771525 2,12 C2,17.5228475 6.4771525,22 12,22 Z M12,15 L12,14 C12,13 12,12.5 13,12 C14,11.5 15,11 15,9.5 C15,8.5 14,7 12,7 C10,7 9,8.26413718 9,10 M12,16 L12,18" }, "child": [] }] })(props);
8068
- }
8069
8036
  function AiFillWarning(props) {
8070
8037
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 1024 1024" }, "child": [{ "tag": "path", "attr": { "d": "M955.7 856l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zM480 416c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v184c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V416zm32 352a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z" }, "child": [] }] })(props);
8071
8038
  }
@@ -8084,6 +8051,39 @@ function FaSpinner(props) {
8084
8051
  function FaUnlock(props) {
8085
8052
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 448 512" }, "child": [{ "tag": "path", "attr": { "d": "M400 256H152V152.9c0-39.6 31.7-72.5 71.3-72.9 40-.4 72.7 32.1 72.7 72v16c0 13.3 10.7 24 24 24h32c13.3 0 24-10.7 24-24v-16C376 68 307.5-.3 223.5 0 139.5.3 72 69.5 72 153.5V256H48c-26.5 0-48 21.5-48 48v160c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V304c0-26.5-21.5-48-48-48z" }, "child": [] }] })(props);
8086
8053
  }
8054
+ function GrCircleQuestion(props) {
8055
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "strokeWidth": "2", "d": "M12,22 C17.5228475,22 22,17.5228475 22,12 C22,6.4771525 17.5228475,2 12,2 C6.4771525,2 2,6.4771525 2,12 C2,17.5228475 6.4771525,22 12,22 Z M12,15 L12,14 C12,13 12,12.5 13,12 C14,11.5 15,11 15,9.5 C15,8.5 14,7 12,7 C10,7 9,8.26413718 9,10 M12,16 L12,18" }, "child": [] }] })(props);
8056
+ }
8057
+ const BranchContext = React.createContext({
8058
+ currentBranch: null,
8059
+ setCurrentBranch: (branch) => {
8060
+ console.warn("BranchContext not initialized");
8061
+ }
8062
+ });
8063
+ const BranchDataProvider = ({
8064
+ currentBranch,
8065
+ setCurrentBranch,
8066
+ children
8067
+ }) => {
8068
+ return /* @__PURE__ */ React.createElement(
8069
+ BranchContext.Provider,
8070
+ {
8071
+ value: {
8072
+ currentBranch,
8073
+ setCurrentBranch
8074
+ }
8075
+ },
8076
+ children
8077
+ );
8078
+ };
8079
+ const useBranchData = () => {
8080
+ const branchData = React.useContext(BranchContext);
8081
+ const { dispatch } = useEvent("branch:change");
8082
+ React.useEffect(() => {
8083
+ dispatch({ branchName: branchData.currentBranch });
8084
+ }, [branchData.currentBranch]);
8085
+ return branchData;
8086
+ };
8087
8087
  function formatBranchName$1(str) {
8088
8088
  const pattern = /[^/\w-]+/g;
8089
8089
  const formattedStr = str.replace(pattern, "");
@@ -8182,7 +8182,7 @@ const BranchSwitcherLegacy = ({
8182
8182
  className: "transition-all duration-150 ease-out text-blue-600 hover:text-blue-400 hover:underline no-underline",
8183
8183
  href: "https://tina.io/docs/tina-cloud/"
8184
8184
  },
8185
- "Learn more about moving to production with Tina Cloud."
8185
+ "Learn more about moving to production with TinaCloud."
8186
8186
  )), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement(
8187
8187
  Button$1,
8188
8188
  {
@@ -8418,7 +8418,7 @@ const EditoralBranchSwitcher = ({
8418
8418
  className: "transition-all duration-150 ease-out text-blue-600 hover:text-blue-400 hover:underline no-underline",
8419
8419
  href: "https://tina.io/docs/tina-cloud/"
8420
8420
  },
8421
- "Learn more about moving to production with Tina Cloud."
8421
+ "Learn more about moving to production with TinaCloud."
8422
8422
  )), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement(
8423
8423
  Button$1,
8424
8424
  {
@@ -9450,7 +9450,7 @@ const E_BAD_ROUTE = new MediaListError({
9450
9450
  });
9451
9451
  new MediaListError({
9452
9452
  title: "An Error Occurred",
9453
- message: "Something went wrong accessing your media from Tina Cloud.",
9453
+ message: "Something went wrong accessing your media from TinaCloud.",
9454
9454
  docsLink: ""
9455
9455
  // TODO
9456
9456
  });
@@ -9635,7 +9635,7 @@ let Alerts$1 = class Alerts {
9635
9635
  return this.add("error", message, timeout);
9636
9636
  }
9637
9637
  };
9638
- const NoFormsPlaceholder = () => /* @__PURE__ */ React.createElement(
9638
+ const SidebarLoadingPlaceholder = () => /* @__PURE__ */ React.createElement(
9639
9639
  "div",
9640
9640
  {
9641
9641
  className: "relative flex flex-col items-center justify-center text-center p-5 pb-16 w-full h-full overflow-y-auto",
@@ -9648,25 +9648,8 @@ const NoFormsPlaceholder = () => /* @__PURE__ */ React.createElement(
9648
9648
  animationDuration: "150ms"
9649
9649
  }
9650
9650
  },
9651
- /* @__PURE__ */ React.createElement(Emoji$1, { className: "pb-5" }, "🔎"),
9652
- /* @__PURE__ */ React.createElement("p", { className: "block pb-5" }, "Looks like there's ", /* @__PURE__ */ React.createElement("br", null), "nothing to edit on ", /* @__PURE__ */ React.createElement("br", null), "this page."),
9653
- /* @__PURE__ */ React.createElement("p", { className: "block" }, /* @__PURE__ */ React.createElement(
9654
- Button$1,
9655
- {
9656
- href: "https://tina.io/docs/tinacms-context/",
9657
- target: "_blank",
9658
- as: "a"
9659
- },
9660
- /* @__PURE__ */ React.createElement(Emoji$1, { className: "mr-1.5" }, "📖"),
9661
- " Contextual Editing"
9662
- ))
9663
- );
9664
- const Emoji$1 = ({ className = "", ...props }) => /* @__PURE__ */ React.createElement(
9665
- "span",
9666
- {
9667
- className: `text-[24px] leading-none inline-block ${className}`,
9668
- ...props
9669
- }
9651
+ /* @__PURE__ */ React.createElement("p", { className: "block pb-5" }, "Please wait while TinaCMS", /* @__PURE__ */ React.createElement("br", null), "loads your content"),
9652
+ /* @__PURE__ */ React.createElement(LoadingDots, { color: "var(--tina-color-primary)" })
9670
9653
  );
9671
9654
  class SidebarState {
9672
9655
  constructor(events, options = {}) {
@@ -9681,7 +9664,7 @@ class SidebarState {
9681
9664
  };
9682
9665
  this.position = options.position || "displace";
9683
9666
  this.renderNav = options.renderNav || true;
9684
- this.placeholder = options.placeholder || NoFormsPlaceholder;
9667
+ this.loadingPlaceholder = options.placeholder || SidebarLoadingPlaceholder;
9685
9668
  if ((_a = options.buttons) == null ? void 0 : _a.save) {
9686
9669
  this.buttons.save = options.buttons.save;
9687
9670
  }
@@ -9755,238 +9738,6 @@ const ModalLayout = ({ children, name, close: close2, layout }) => {
9755
9738
  children
9756
9739
  )));
9757
9740
  };
9758
- const Item = ({
9759
- item,
9760
- depth,
9761
- setActiveFormId
9762
- }) => {
9763
- const cms = useCMS();
9764
- const depths = ["pl-6", "pl-10", "pl-14"];
9765
- const form = React.useMemo(
9766
- () => cms.state.forms.find(({ tinaForm }) => item.formId === tinaForm.id),
9767
- [item.formId]
9768
- );
9769
- return /* @__PURE__ */ React.createElement(
9770
- "button",
9771
- {
9772
- type: "button",
9773
- key: item.path,
9774
- onClick: () => setActiveFormId(item.formId),
9775
- 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`
9776
- },
9777
- /* @__PURE__ */ React.createElement(BiEdit, { className: "opacity-70 w-5 h-auto text-blue-500 flex-none" }),
9778
- /* @__PURE__ */ React.createElement("div", { className: "flex-1 flex flex-col gap-0.5 items-start" }, /* @__PURE__ */ React.createElement("div", { className: "group-hover:text-blue-500 font-sans text-xs font-semibold text-gray-700 whitespace-normal" }, form.tinaForm.label), /* @__PURE__ */ React.createElement("div", { className: "group-hover:text-blue-500 text-base truncate leading-tight text-gray-600" }, form.tinaForm.id))
9779
- );
9780
- };
9781
- const FormListItem = ({
9782
- item,
9783
- depth,
9784
- setActiveFormId
9785
- }) => {
9786
- var _a;
9787
- return /* @__PURE__ */ React.createElement("div", { className: "divide-y divide-gray-200" }, /* @__PURE__ */ React.createElement(Item, { setActiveFormId, item, depth }), item.subItems && /* @__PURE__ */ React.createElement("ul", { className: "divide-y divide-gray-200" }, (_a = item.subItems) == null ? void 0 : _a.map((subItem) => {
9788
- if (subItem.type === "document") {
9789
- return /* @__PURE__ */ React.createElement("li", { key: subItem.formId }, /* @__PURE__ */ React.createElement(
9790
- Item,
9791
- {
9792
- setActiveFormId,
9793
- depth: depth + 1,
9794
- item: subItem
9795
- }
9796
- ));
9797
- }
9798
- })));
9799
- };
9800
- const FormLists = (props) => {
9801
- const cms = useCMS();
9802
- return /* @__PURE__ */ React.createElement(
9803
- Transition,
9804
- {
9805
- appear: true,
9806
- show: true,
9807
- as: "div",
9808
- enter: "transition-all ease-out duration-150",
9809
- enterFrom: "opacity-0 -translate-x-1/2",
9810
- enterTo: "opacity-100",
9811
- leave: "transition-all ease-out duration-150",
9812
- leaveFrom: "opacity-100",
9813
- leaveTo: "opacity-0 -translate-x-1/2"
9814
- },
9815
- cms.state.formLists.map((formList, index) => /* @__PURE__ */ React.createElement("div", { key: `${formList.id}-${index}`, className: "pt-16" }, /* @__PURE__ */ React.createElement(
9816
- FormList,
9817
- {
9818
- isEditing: props.isEditing,
9819
- setActiveFormId: (id) => {
9820
- cms.dispatch({ type: "forms:set-active-form-id", value: id });
9821
- },
9822
- formList
9823
- }
9824
- )))
9825
- );
9826
- };
9827
- const FormList = (props) => {
9828
- const cms = useCMS();
9829
- const listItems = React.useMemo(() => {
9830
- var _a;
9831
- const orderedListItems = [];
9832
- const globalItems = [];
9833
- const topItems = [];
9834
- props.formList.items.forEach((item) => {
9835
- if (item.type === "document") {
9836
- const form = cms.state.forms.find(
9837
- ({ tinaForm }) => tinaForm.id === item.formId
9838
- );
9839
- if (form.tinaForm.global) {
9840
- globalItems.push(item);
9841
- } else {
9842
- orderedListItems.push(item);
9843
- }
9844
- } else {
9845
- orderedListItems.push(item);
9846
- }
9847
- });
9848
- if (((_a = orderedListItems[0]) == null ? void 0 : _a.type) === "document") {
9849
- topItems.push({ type: "list", label: "Documents" });
9850
- }
9851
- let extra = [];
9852
- if (globalItems.length) {
9853
- extra = [{ type: "list", label: "Global Documents" }, ...globalItems];
9854
- }
9855
- return [...topItems, ...orderedListItems, ...extra];
9856
- }, [JSON.stringify(props.formList.items)]);
9857
- return /* @__PURE__ */ React.createElement("ul", null, /* @__PURE__ */ React.createElement("li", { className: "divide-y divide-gray-200" }, listItems.map((item, index) => {
9858
- if (item.type === "list") {
9859
- return /* @__PURE__ */ React.createElement(
9860
- "div",
9861
- {
9862
- key: item.label,
9863
- className: `relative group text-left w-full bg-white shadow-sm
9864
- 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"}`
9865
- },
9866
- /* @__PURE__ */ React.createElement(
9867
- "span",
9868
- {
9869
- className: "text-sm tracking-wide font-bold text-gray-700 uppercase"
9870
- },
9871
- item.label
9872
- )
9873
- );
9874
- }
9875
- return /* @__PURE__ */ React.createElement(
9876
- FormListItem,
9877
- {
9878
- setActiveFormId: (id) => props.setActiveFormId(id),
9879
- key: item.formId,
9880
- item,
9881
- depth: 0
9882
- }
9883
- );
9884
- })));
9885
- };
9886
- const FormsView = ({
9887
- children
9888
- }) => {
9889
- const cms = useCMS$1();
9890
- const { setFormIsPristine } = React.useContext(SidebarContext);
9891
- const isMultiform = cms.state.forms.length > 1;
9892
- const activeForm = cms.state.forms.find(
9893
- ({ tinaForm }) => tinaForm.id === cms.state.activeFormId
9894
- );
9895
- const isEditing = !!activeForm;
9896
- if (!cms.state.formLists.length) {
9897
- return /* @__PURE__ */ React.createElement(React.Fragment, null, " ", children, " ");
9898
- }
9899
- if (isMultiform && !activeForm) {
9900
- return /* @__PURE__ */ React.createElement(FormLists, { isEditing });
9901
- }
9902
- const formMetas = cms.plugins.all("form:meta");
9903
- return /* @__PURE__ */ React.createElement(React.Fragment, null, activeForm && /* @__PURE__ */ React.createElement(FormWrapper$1, { isEditing, isMultiform }, isMultiform && /* @__PURE__ */ React.createElement(MultiformFormHeader, { activeForm }), !isMultiform && /* @__PURE__ */ React.createElement(FormHeader, { activeForm }), formMetas == null ? void 0 : formMetas.map((meta) => /* @__PURE__ */ React.createElement(React.Fragment, { key: meta.name }, /* @__PURE__ */ React.createElement(meta.Component, null))), /* @__PURE__ */ React.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine })));
9904
- };
9905
- const FormWrapper$1 = ({ isEditing, children }) => {
9906
- return /* @__PURE__ */ React.createElement(
9907
- "div",
9908
- {
9909
- className: "flex-1 flex flex-col flex-nowrap overflow-hidden h-full w-full relative bg-white",
9910
- style: isEditing ? {
9911
- transform: "none",
9912
- animationName: "fly-in-left",
9913
- animationDuration: "150ms",
9914
- animationDelay: "0",
9915
- animationIterationCount: 1,
9916
- animationTimingFunction: "ease-out"
9917
- } : {
9918
- transform: "translate3d(100%, 0, 0)"
9919
- }
9920
- },
9921
- children
9922
- );
9923
- };
9924
- const MultiformFormHeader = ({
9925
- activeForm
9926
- }) => {
9927
- const cms = useCMS$1();
9928
- const { formIsPristine } = React.useContext(SidebarContext);
9929
- return /* @__PURE__ */ React.createElement(
9930
- "div",
9931
- {
9932
- className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
9933
- },
9934
- /* @__PURE__ */ React.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React.createElement(
9935
- "button",
9936
- {
9937
- type: "button",
9938
- className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
9939
- onClick: () => {
9940
- const state = activeForm.tinaForm.finalForm.getState();
9941
- if (state.invalid === true) {
9942
- cms.alerts.error("Cannot navigate away from an invalid form.");
9943
- } else {
9944
- cms.dispatch({ type: "forms:set-active-form-id", value: null });
9945
- }
9946
- }
9947
- },
9948
- /* @__PURE__ */ React.createElement(BiDotsVertical, { className: "h-auto w-5 inline-block opacity-70" })
9949
- ), /* @__PURE__ */ React.createElement(
9950
- "button",
9951
- {
9952
- type: "button",
9953
- className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
9954
- onClick: () => {
9955
- const collectionName = cms.api.tina.schema.getCollectionByFullPath(
9956
- cms.state.activeFormId
9957
- ).name;
9958
- window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
9959
- }
9960
- },
9961
- /* @__PURE__ */ React.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
9962
- ), /* @__PURE__ */ React.createElement("span", { className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0" }, "/"), /* @__PURE__ */ React.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, activeForm.tinaForm.label || activeForm.tinaForm.id), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }))
9963
- );
9964
- };
9965
- const FormHeader = ({ activeForm }) => {
9966
- const { formIsPristine } = React.useContext(SidebarContext);
9967
- const cms = useCMS$1();
9968
- const shortFormLabel = activeForm.tinaForm.label ? activeForm.tinaForm.label.replace(/^.*[\\\/]/, "") : false;
9969
- return /* @__PURE__ */ React.createElement(
9970
- "div",
9971
- {
9972
- className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
9973
- },
9974
- /* @__PURE__ */ React.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React.createElement(
9975
- "button",
9976
- {
9977
- type: "button",
9978
- className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
9979
- onClick: () => {
9980
- const collectionName = cms.api.tina.schema.getCollectionByFullPath(
9981
- cms.state.activeFormId
9982
- ).name;
9983
- window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
9984
- }
9985
- },
9986
- /* @__PURE__ */ React.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
9987
- ), shortFormLabel && /* @__PURE__ */ React.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, shortFormLabel), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }))
9988
- );
9989
- };
9990
9741
  function ImFilesEmpty(props) {
9991
9742
  return GenIcon({ "tag": "svg", "attr": { "version": "1.1", "viewBox": "0 0 16 16" }, "child": [{ "tag": "path", "attr": { "d": "M14.341 5.579c-0.347-0.473-0.831-1.027-1.362-1.558s-1.085-1.015-1.558-1.362c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.689 0.561 1.25 1.25 1.25h9.5c0.689 0 1.25-0.561 1.25-1.25v-7.75c0-0.224-0.068-0.615-0.659-1.421zM12.271 4.729c0.48 0.48 0.856 0.912 1.134 1.271h-2.406v-2.405c0.359 0.278 0.792 0.654 1.271 1.134v0zM14 14.75c0 0.136-0.114 0.25-0.25 0.25h-9.5c-0.136 0-0.25-0.114-0.25-0.25v-11.5c0-0.135 0.114-0.25 0.25-0.25 0 0 5.749-0 5.75 0v3.5c0 0.276 0.224 0.5 0.5 0.5h3.5v7.75z" }, "child": [] }, { "tag": "path", "attr": { "d": "M9.421 0.659c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.604 0.43 1.109 1 1.225v-12.725c0-0.135 0.115-0.25 0.25-0.25h7.607c-0.151-0.124-0.297-0.238-0.437-0.341z" }, "child": [] }] })(props);
9992
9743
  }
@@ -10229,7 +9980,7 @@ const SyncStatus = ({ cms, setEventsOpen }) => {
10229
9980
  "Event Log"
10230
9981
  ));
10231
9982
  };
10232
- const version = "2.7.3";
9983
+ const version = "2.7.5";
10233
9984
  const Nav = ({
10234
9985
  isLocalMode,
10235
9986
  className = "",
@@ -10471,6 +10222,293 @@ const ResizeHandle = () => {
10471
10222
  /* @__PURE__ */ React.createElement("span", { className: "absolute top-1/2 left-1/2 h-4/6 w-px bg-gray-200 transform -translate-y-1/2 -translate-x-1/2 opacity-30 transition-opacity duration-150 ease-out group-hover:opacity-100" })
10472
10223
  );
10473
10224
  };
10225
+ const Item = ({
10226
+ item,
10227
+ depth,
10228
+ setActiveFormId
10229
+ }) => {
10230
+ const cms = useCMS();
10231
+ const depths = ["pl-6", "pl-10", "pl-14"];
10232
+ const form = React.useMemo(
10233
+ () => cms.state.forms.find(({ tinaForm }) => item.formId === tinaForm.id),
10234
+ [item.formId]
10235
+ );
10236
+ return /* @__PURE__ */ React.createElement(
10237
+ "button",
10238
+ {
10239
+ type: "button",
10240
+ key: item.path,
10241
+ onClick: () => setActiveFormId(item.formId),
10242
+ className: `${depths[depth] || "pl-12"} pr-6 py-3 w-full h-full bg-transparent border-none text-lg text-gray-700 group hover:bg-gray-50 transition-all ease-out duration-150 flex items-center justify-between gap-2`
10243
+ },
10244
+ /* @__PURE__ */ React.createElement(BiEdit, { className: "opacity-70 w-5 h-auto text-blue-500 flex-none" }),
10245
+ /* @__PURE__ */ React.createElement("div", { className: "flex-1 flex flex-col gap-0.5 items-start" }, /* @__PURE__ */ React.createElement("div", { className: "group-hover:text-blue-500 font-sans text-xs font-semibold text-gray-700 whitespace-normal" }, form.tinaForm.label), /* @__PURE__ */ React.createElement("div", { className: "group-hover:text-blue-500 text-base truncate leading-tight text-gray-600" }, form.tinaForm.id))
10246
+ );
10247
+ };
10248
+ const FormListItem = ({
10249
+ item,
10250
+ depth,
10251
+ setActiveFormId
10252
+ }) => {
10253
+ var _a;
10254
+ return /* @__PURE__ */ React.createElement("div", { className: "divide-y divide-gray-200" }, /* @__PURE__ */ React.createElement(Item, { setActiveFormId, item, depth }), item.subItems && /* @__PURE__ */ React.createElement("ul", { className: "divide-y divide-gray-200" }, (_a = item.subItems) == null ? void 0 : _a.map((subItem) => {
10255
+ if (subItem.type === "document") {
10256
+ return /* @__PURE__ */ React.createElement("li", { key: subItem.formId }, /* @__PURE__ */ React.createElement(
10257
+ Item,
10258
+ {
10259
+ setActiveFormId,
10260
+ depth: depth + 1,
10261
+ item: subItem
10262
+ }
10263
+ ));
10264
+ }
10265
+ })));
10266
+ };
10267
+ const FormLists = (props) => {
10268
+ const cms = useCMS();
10269
+ return /* @__PURE__ */ React.createElement(
10270
+ Transition,
10271
+ {
10272
+ appear: true,
10273
+ show: true,
10274
+ as: "div",
10275
+ enter: "transition-all ease-out duration-150",
10276
+ enterFrom: "opacity-0 -translate-x-1/2",
10277
+ enterTo: "opacity-100",
10278
+ leave: "transition-all ease-out duration-150",
10279
+ leaveFrom: "opacity-100",
10280
+ leaveTo: "opacity-0 -translate-x-1/2"
10281
+ },
10282
+ cms.state.formLists.map((formList, index) => /* @__PURE__ */ React.createElement("div", { key: `${formList.id}-${index}`, className: "pt-16" }, /* @__PURE__ */ React.createElement(
10283
+ FormList,
10284
+ {
10285
+ isEditing: props.isEditing,
10286
+ setActiveFormId: (id) => {
10287
+ cms.dispatch({ type: "forms:set-active-form-id", value: id });
10288
+ },
10289
+ formList
10290
+ }
10291
+ )))
10292
+ );
10293
+ };
10294
+ const FormList = (props) => {
10295
+ const cms = useCMS();
10296
+ const listItems = React.useMemo(() => {
10297
+ var _a;
10298
+ const orderedListItems = [];
10299
+ const globalItems = [];
10300
+ const topItems = [];
10301
+ props.formList.items.forEach((item) => {
10302
+ if (item.type === "document") {
10303
+ const form = cms.state.forms.find(
10304
+ ({ tinaForm }) => tinaForm.id === item.formId
10305
+ );
10306
+ if (form.tinaForm.global) {
10307
+ globalItems.push(item);
10308
+ } else {
10309
+ orderedListItems.push(item);
10310
+ }
10311
+ } else {
10312
+ orderedListItems.push(item);
10313
+ }
10314
+ });
10315
+ if (((_a = orderedListItems[0]) == null ? void 0 : _a.type) === "document") {
10316
+ topItems.push({ type: "list", label: "Documents" });
10317
+ }
10318
+ let extra = [];
10319
+ if (globalItems.length) {
10320
+ extra = [{ type: "list", label: "Global Documents" }, ...globalItems];
10321
+ }
10322
+ return [...topItems, ...orderedListItems, ...extra];
10323
+ }, [JSON.stringify(props.formList.items)]);
10324
+ return /* @__PURE__ */ React.createElement("ul", null, /* @__PURE__ */ React.createElement("li", { className: "divide-y divide-gray-200" }, listItems.map((item, index) => {
10325
+ if (item.type === "list") {
10326
+ return /* @__PURE__ */ React.createElement(
10327
+ "div",
10328
+ {
10329
+ key: item.label,
10330
+ className: `relative group text-left w-full bg-white shadow-sm
10331
+ border-gray-100 px-6 -mt-px pb-3 ${index > 0 ? "pt-6 bg-gradient-to-b from-gray-50 via-white to-white" : "pt-3"}`
10332
+ },
10333
+ /* @__PURE__ */ React.createElement(
10334
+ "span",
10335
+ {
10336
+ className: "text-sm tracking-wide font-bold text-gray-700 uppercase"
10337
+ },
10338
+ item.label
10339
+ )
10340
+ );
10341
+ }
10342
+ return /* @__PURE__ */ React.createElement(
10343
+ FormListItem,
10344
+ {
10345
+ setActiveFormId: (id) => props.setActiveFormId(id),
10346
+ key: item.formId,
10347
+ item,
10348
+ depth: 0
10349
+ }
10350
+ );
10351
+ })));
10352
+ };
10353
+ const SidebarNoFormsPlaceholder = () => /* @__PURE__ */ React.createElement(
10354
+ "div",
10355
+ {
10356
+ className: "relative flex flex-col items-center justify-center text-center p-5 pb-16 w-full h-full overflow-y-auto",
10357
+ style: {
10358
+ animationName: "fade-in",
10359
+ animationDelay: "300ms",
10360
+ animationTimingFunction: "ease-out",
10361
+ animationIterationCount: 1,
10362
+ animationFillMode: "both",
10363
+ animationDuration: "150ms"
10364
+ }
10365
+ },
10366
+ /* @__PURE__ */ React.createElement("p", { className: "block pb-5" }, "Looks like there's ", /* @__PURE__ */ React.createElement("br", null), "nothing to edit on ", /* @__PURE__ */ React.createElement("br", null), "this page."),
10367
+ /* @__PURE__ */ React.createElement("p", { className: "block pt-5" }, /* @__PURE__ */ React.createElement(
10368
+ Button$1,
10369
+ {
10370
+ href: "https://tina.io/docs/contextual-editing/overview",
10371
+ target: "_blank",
10372
+ as: "a"
10373
+ },
10374
+ /* @__PURE__ */ React.createElement(Emoji$1, { className: "mr-1.5" }, "📖"),
10375
+ " Contextual Editing Docs"
10376
+ ))
10377
+ );
10378
+ const Emoji$1 = ({ className = "", ...props }) => /* @__PURE__ */ React.createElement(
10379
+ "span",
10380
+ {
10381
+ className: `text-[24px] leading-none inline-block ${className}`,
10382
+ ...props
10383
+ }
10384
+ );
10385
+ const minimumTimeToShowLoadingIndicator = 1e3;
10386
+ const FormsView = ({ loadingPlaceholder } = {}) => {
10387
+ const cms = useCMS$1();
10388
+ const { setFormIsPristine } = React.useContext(SidebarContext);
10389
+ const [isShowingLoading, setIsShowingLoading] = React.useState(true);
10390
+ const [initialLoadComplete, setInitialLoadComplete] = React.useState(false);
10391
+ React.useEffect(() => {
10392
+ if (cms.state.isLoadingContent) {
10393
+ setIsShowingLoading(true);
10394
+ const timer = setTimeout(() => {
10395
+ if (!cms.state.isLoadingContent) {
10396
+ setIsShowingLoading(false);
10397
+ setInitialLoadComplete(true);
10398
+ }
10399
+ }, minimumTimeToShowLoadingIndicator);
10400
+ return () => clearTimeout(timer);
10401
+ } else {
10402
+ const timer = setTimeout(() => {
10403
+ setIsShowingLoading(false);
10404
+ setInitialLoadComplete(true);
10405
+ }, minimumTimeToShowLoadingIndicator);
10406
+ return () => clearTimeout(timer);
10407
+ }
10408
+ }, [cms.state.isLoadingContent]);
10409
+ if (isShowingLoading || !initialLoadComplete) {
10410
+ const LoadingPlaceholder = loadingPlaceholder || SidebarLoadingPlaceholder;
10411
+ return /* @__PURE__ */ React.createElement(LoadingPlaceholder, null);
10412
+ }
10413
+ if (!cms.state.formLists.length) {
10414
+ return /* @__PURE__ */ React.createElement(SidebarNoFormsPlaceholder, null);
10415
+ }
10416
+ const isMultiform = cms.state.forms.length > 1;
10417
+ const activeForm = cms.state.forms.find(
10418
+ ({ tinaForm }) => tinaForm.id === cms.state.activeFormId
10419
+ );
10420
+ const isEditing = !!activeForm;
10421
+ if (isMultiform && !activeForm) {
10422
+ return /* @__PURE__ */ React.createElement(FormLists, { isEditing });
10423
+ }
10424
+ const formMetas = cms.plugins.all("form:meta");
10425
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, activeForm && /* @__PURE__ */ React.createElement(FormWrapper$1, { isEditing, isMultiform }, isMultiform && /* @__PURE__ */ React.createElement(MultiformFormHeader, { activeForm }), !isMultiform && /* @__PURE__ */ React.createElement(FormHeader, { activeForm }), formMetas == null ? void 0 : formMetas.map((meta) => /* @__PURE__ */ React.createElement(React.Fragment, { key: meta.name }, /* @__PURE__ */ React.createElement(meta.Component, null))), /* @__PURE__ */ React.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine })));
10426
+ };
10427
+ const FormWrapper$1 = ({ isEditing, children }) => {
10428
+ return /* @__PURE__ */ React.createElement(
10429
+ "div",
10430
+ {
10431
+ className: "flex-1 flex flex-col flex-nowrap overflow-hidden h-full w-full relative bg-white",
10432
+ style: isEditing ? {
10433
+ transform: "none",
10434
+ animationName: "fly-in-left",
10435
+ animationDuration: "150ms",
10436
+ animationDelay: "0",
10437
+ animationIterationCount: 1,
10438
+ animationTimingFunction: "ease-out"
10439
+ } : {
10440
+ transform: "translate3d(100%, 0, 0)"
10441
+ }
10442
+ },
10443
+ children
10444
+ );
10445
+ };
10446
+ const MultiformFormHeader = ({
10447
+ activeForm
10448
+ }) => {
10449
+ const cms = useCMS$1();
10450
+ const { formIsPristine } = React.useContext(SidebarContext);
10451
+ return /* @__PURE__ */ React.createElement(
10452
+ "div",
10453
+ {
10454
+ className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
10455
+ },
10456
+ /* @__PURE__ */ React.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React.createElement(
10457
+ "button",
10458
+ {
10459
+ type: "button",
10460
+ className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
10461
+ onClick: () => {
10462
+ const state = activeForm.tinaForm.finalForm.getState();
10463
+ if (state.invalid === true) {
10464
+ cms.alerts.error("Cannot navigate away from an invalid form.");
10465
+ } else {
10466
+ cms.dispatch({ type: "forms:set-active-form-id", value: null });
10467
+ }
10468
+ }
10469
+ },
10470
+ /* @__PURE__ */ React.createElement(BiDotsVertical, { className: "h-auto w-5 inline-block opacity-70" })
10471
+ ), /* @__PURE__ */ React.createElement(
10472
+ "button",
10473
+ {
10474
+ type: "button",
10475
+ className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
10476
+ onClick: () => {
10477
+ const collectionName = cms.api.tina.schema.getCollectionByFullPath(
10478
+ cms.state.activeFormId
10479
+ ).name;
10480
+ window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
10481
+ }
10482
+ },
10483
+ /* @__PURE__ */ React.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
10484
+ ), /* @__PURE__ */ React.createElement("span", { className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0" }, "/"), /* @__PURE__ */ React.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, activeForm.tinaForm.label || activeForm.tinaForm.id), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }))
10485
+ );
10486
+ };
10487
+ const FormHeader = ({ activeForm }) => {
10488
+ const { formIsPristine } = React.useContext(SidebarContext);
10489
+ const cms = useCMS$1();
10490
+ const shortFormLabel = activeForm.tinaForm.label ? activeForm.tinaForm.label.replace(/^.*[\\\/]/, "") : false;
10491
+ return /* @__PURE__ */ React.createElement(
10492
+ "div",
10493
+ {
10494
+ className: "pt-18 pb-4 px-6 border-b border-gray-200 bg-gradient-to-t from-white to-gray-50"
10495
+ },
10496
+ /* @__PURE__ */ React.createElement("div", { className: "max-w-form mx-auto flex gap-2 justify-between items-center" }, /* @__PURE__ */ React.createElement(
10497
+ "button",
10498
+ {
10499
+ type: "button",
10500
+ className: "pointer-events-auto text-xs text-blue-400 hover:text-blue-500 hover:underline transition-all ease-out duration-150",
10501
+ onClick: () => {
10502
+ const collectionName = cms.api.tina.schema.getCollectionByFullPath(
10503
+ cms.state.activeFormId
10504
+ ).name;
10505
+ window.location.href = `${new URL(window.location.href).pathname}#/collections/${collectionName}/~`;
10506
+ }
10507
+ },
10508
+ /* @__PURE__ */ React.createElement(BiHomeAlt, { className: "h-auto w-5 inline-block opacity-70" })
10509
+ ), shortFormLabel && /* @__PURE__ */ React.createElement("span", { className: "block w-full text-sm leading-tight whitespace-nowrap truncate" }, shortFormLabel), /* @__PURE__ */ React.createElement(FormStatus, { pristine: formIsPristine }))
10510
+ );
10511
+ };
10474
10512
  const SidebarContext = React.createContext(null);
10475
10513
  const minPreviewWidth = 440;
10476
10514
  const minSidebarWidth = 360;
@@ -10689,7 +10727,7 @@ const Sidebar$1 = ({
10689
10727
  isLocalMode: (_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.isLocalMode,
10690
10728
  branchingEnabled
10691
10729
  }
10692
- ), /* @__PURE__ */ React.createElement(FormsView, null, /* @__PURE__ */ React.createElement(sidebar.placeholder, null)), activeScreen && /* @__PURE__ */ React.createElement(
10730
+ ), /* @__PURE__ */ React.createElement(FormsView, { loadingPlaceholder: sidebar.loadingPlaceholder }), activeScreen && /* @__PURE__ */ React.createElement(
10693
10731
  ScreenPluginModal,
10694
10732
  {
10695
10733
  screen: activeScreen,
@@ -11005,6 +11043,93 @@ function createPlaceholder(name, _pr) {
11005
11043
  );
11006
11044
  };
11007
11045
  }
11046
+ function dirname(path) {
11047
+ var _a, _b;
11048
+ const pattern = new RegExp("(?<prevDir>.*)/");
11049
+ return (_b = (_a = path.match(pattern)) == null ? void 0 : _a.groups) == null ? void 0 : _b.prevDir;
11050
+ }
11051
+ const BreadcrumbButton = ({ className = "", ...props }) => /* @__PURE__ */ React__default.createElement(
11052
+ "button",
11053
+ {
11054
+ className: "capitalize transition-colors duration-150 border-0 bg-transparent hover:text-blue-500 " + className,
11055
+ ...props
11056
+ }
11057
+ );
11058
+ function Breadcrumb$1({ directory = "", setDirectory }) {
11059
+ directory = directory.replace(/^\/|\/$/g, "");
11060
+ let prevDir = dirname(directory) || "";
11061
+ if (prevDir === ".") {
11062
+ prevDir = "";
11063
+ }
11064
+ return /* @__PURE__ */ React__default.createElement("div", { className: "w-full flex items-center text-[16px] text-gray-300" }, directory !== "" && /* @__PURE__ */ React__default.createElement(
11065
+ IconButton,
11066
+ {
11067
+ variant: "ghost",
11068
+ className: "mr-2",
11069
+ onClick: () => setDirectory(prevDir)
11070
+ },
11071
+ /* @__PURE__ */ React__default.createElement(
11072
+ LeftArrowIcon,
11073
+ {
11074
+ className: `w-7 h-auto fill-gray-300 hover:fill-gray-900 transition duration-150 ease-out`
11075
+ }
11076
+ )
11077
+ ), /* @__PURE__ */ React__default.createElement(
11078
+ BreadcrumbButton,
11079
+ {
11080
+ onClick: () => setDirectory(""),
11081
+ className: directory === "" ? "text-gray-500 font-bold" : "text-gray-300 font-medium after:pl-1.5 after:content-['/']"
11082
+ },
11083
+ "Media"
11084
+ ), directory && directory.split("/").map((part, index, parts) => {
11085
+ const currentDir = parts.slice(0, index + 1).join("/");
11086
+ return /* @__PURE__ */ React__default.createElement(
11087
+ BreadcrumbButton,
11088
+ {
11089
+ className: "pl-1.5 " + (index + 1 === parts.length ? "text-gray-500 font-bold" : "text-gray-300 font-medium after:pl-1.5 after:content-['/']"),
11090
+ key: currentDir,
11091
+ onClick: () => {
11092
+ setDirectory(currentDir);
11093
+ }
11094
+ },
11095
+ part
11096
+ );
11097
+ }));
11098
+ }
11099
+ const CopyField = ({ label, description, value }) => {
11100
+ const [copied, setCopied] = React__default.useState(false);
11101
+ const [fadeOut, setFadeOut] = React__default.useState(false);
11102
+ return /* @__PURE__ */ React__default.createElement("div", { className: "w-full" }, label && /* @__PURE__ */ React__default.createElement("label", { className: "w-full mb-1 block flex-1 text-sm font-bold leading-5 text-gray-700" }, label), /* @__PURE__ */ React__default.createElement(
11103
+ "span",
11104
+ {
11105
+ onClick: () => {
11106
+ if (copied === true)
11107
+ return;
11108
+ setCopied(true);
11109
+ setTimeout(() => {
11110
+ setFadeOut(true);
11111
+ }, 2500);
11112
+ setTimeout(() => {
11113
+ setCopied(false);
11114
+ setFadeOut(false);
11115
+ }, 3e3);
11116
+ navigator.clipboard.writeText(value);
11117
+ },
11118
+ className: `shadow-inner text-base leading-5 whitespace-normal break-all px-3 py-2 text-gray-600 w-full bg-gray-50 border border-gray-200 transition-all ease-out duration-150 rounded-md relative overflow-hidden appearance-none flex items-center w-full cursor-pointer hover:bg-white hover:text-blue-500 ${copied ? `pointer-events-none` : ``}`
11119
+ },
11120
+ /* @__PURE__ */ React__default.createElement(BiCopyAlt, { className: "relative text-blue-500 shrink-0 w-5 h-auto mr-1.5 -ml-0.5 z-20" }),
11121
+ " ",
11122
+ value,
11123
+ " ",
11124
+ copied && /* @__PURE__ */ React__default.createElement(
11125
+ "span",
11126
+ {
11127
+ className: `${fadeOut ? `opacity-0` : `opacity-100`} text-blue-500 transition-opacity duration-500 absolute right-0 w-full h-full px-3 py-2 bg-white bg-opacity-90 flex items-center justify-center text-center tracking-wide font-medium z-10`
11128
+ },
11129
+ /* @__PURE__ */ React__default.createElement("span", null, "Copied to clipboard!")
11130
+ )
11131
+ ), description && /* @__PURE__ */ React__default.createElement("p", { className: "mt-2 text-sm text-gray-500" }, description));
11132
+ };
11008
11133
  function ListMediaItem({ item, onClick, active }) {
11009
11134
  let FileIcon = BiFile;
11010
11135
  if (item.type === "dir") {
@@ -11080,59 +11205,6 @@ function GridMediaItem({ item, active, onClick }) {
11080
11205
  )
11081
11206
  );
11082
11207
  }
11083
- function dirname(path) {
11084
- var _a, _b;
11085
- const pattern = new RegExp("(?<prevDir>.*)/");
11086
- return (_b = (_a = path.match(pattern)) == null ? void 0 : _a.groups) == null ? void 0 : _b.prevDir;
11087
- }
11088
- const BreadcrumbButton = ({ className = "", ...props }) => /* @__PURE__ */ React__default.createElement(
11089
- "button",
11090
- {
11091
- className: "capitalize transition-colors duration-150 border-0 bg-transparent hover:text-blue-500 " + className,
11092
- ...props
11093
- }
11094
- );
11095
- function Breadcrumb$1({ directory = "", setDirectory }) {
11096
- directory = directory.replace(/^\/|\/$/g, "");
11097
- let prevDir = dirname(directory) || "";
11098
- if (prevDir === ".") {
11099
- prevDir = "";
11100
- }
11101
- return /* @__PURE__ */ React__default.createElement("div", { className: "w-full flex items-center text-[16px] text-gray-300" }, directory !== "" && /* @__PURE__ */ React__default.createElement(
11102
- IconButton,
11103
- {
11104
- variant: "ghost",
11105
- className: "mr-2",
11106
- onClick: () => setDirectory(prevDir)
11107
- },
11108
- /* @__PURE__ */ React__default.createElement(
11109
- LeftArrowIcon,
11110
- {
11111
- className: `w-7 h-auto fill-gray-300 hover:fill-gray-900 transition duration-150 ease-out`
11112
- }
11113
- )
11114
- ), /* @__PURE__ */ React__default.createElement(
11115
- BreadcrumbButton,
11116
- {
11117
- onClick: () => setDirectory(""),
11118
- className: directory === "" ? "text-gray-500 font-bold" : "text-gray-300 font-medium after:pl-1.5 after:content-['/']"
11119
- },
11120
- "Media"
11121
- ), directory && directory.split("/").map((part, index, parts) => {
11122
- const currentDir = parts.slice(0, index + 1).join("/");
11123
- return /* @__PURE__ */ React__default.createElement(
11124
- BreadcrumbButton,
11125
- {
11126
- className: "pl-1.5 " + (index + 1 === parts.length ? "text-gray-500 font-bold" : "text-gray-300 font-medium after:pl-1.5 after:content-['/']"),
11127
- key: currentDir,
11128
- onClick: () => {
11129
- setDirectory(currentDir);
11130
- }
11131
- },
11132
- part
11133
- );
11134
- }));
11135
- }
11136
11208
  const DeleteModal$1 = ({
11137
11209
  close: close2,
11138
11210
  deleteFunc,
@@ -11186,40 +11258,6 @@ const NewFolderModal = ({ onSubmit, close: close2 }) => {
11186
11258
  "Create New Folder"
11187
11259
  ))));
11188
11260
  };
11189
- const CopyField = ({ label, description, value }) => {
11190
- const [copied, setCopied] = React__default.useState(false);
11191
- const [fadeOut, setFadeOut] = React__default.useState(false);
11192
- return /* @__PURE__ */ React__default.createElement("div", { className: "w-full" }, label && /* @__PURE__ */ React__default.createElement("label", { className: "w-full mb-1 block flex-1 text-sm font-bold leading-5 text-gray-700" }, label), /* @__PURE__ */ React__default.createElement(
11193
- "span",
11194
- {
11195
- onClick: () => {
11196
- if (copied === true)
11197
- return;
11198
- setCopied(true);
11199
- setTimeout(() => {
11200
- setFadeOut(true);
11201
- }, 2500);
11202
- setTimeout(() => {
11203
- setCopied(false);
11204
- setFadeOut(false);
11205
- }, 3e3);
11206
- navigator.clipboard.writeText(value);
11207
- },
11208
- className: `shadow-inner text-base leading-5 whitespace-normal break-all px-3 py-2 text-gray-600 w-full bg-gray-50 border border-gray-200 transition-all ease-out duration-150 rounded-md relative overflow-hidden appearance-none flex items-center w-full cursor-pointer hover:bg-white hover:text-blue-500 ${copied ? `pointer-events-none` : ``}`
11209
- },
11210
- /* @__PURE__ */ React__default.createElement(BiCopyAlt, { className: "relative text-blue-500 shrink-0 w-5 h-auto mr-1.5 -ml-0.5 z-20" }),
11211
- " ",
11212
- value,
11213
- " ",
11214
- copied && /* @__PURE__ */ React__default.createElement(
11215
- "span",
11216
- {
11217
- className: `${fadeOut ? `opacity-0` : `opacity-100`} text-blue-500 transition-opacity duration-500 absolute right-0 w-full h-full px-3 py-2 bg-white bg-opacity-90 flex items-center justify-center text-center tracking-wide font-medium z-10`
11218
- },
11219
- /* @__PURE__ */ React__default.createElement("span", null, "Copied to clipboard!")
11220
- )
11221
- ), description && /* @__PURE__ */ React__default.createElement("p", { className: "mt-2 text-sm text-gray-500" }, description));
11222
- };
11223
11261
  const { useDropzone } = dropzone;
11224
11262
  const join = function(...parts) {
11225
11263
  const [first, last, slash] = [0, parts.length - 1, "/"];
@@ -11721,7 +11759,7 @@ const SyncStatusContainer = ({ children }) => {
11721
11759
  target: "_blank",
11722
11760
  href: `${cms.api.tina.appDashboardLink}/media`
11723
11761
  },
11724
- "Sync Your Media In Tina Cloud.",
11762
+ "Sync Your Media In TinaCloud.",
11725
11763
  /* @__PURE__ */ React__default.createElement(BiLinkExternal, { className: `w-5 h-auto flex-shrink-0` })
11726
11764
  )
11727
11765
  )))) : /* @__PURE__ */ React__default.createElement(SyncStatusContext.Provider, { value: { syncStatus } }, children);
@@ -12053,6 +12091,7 @@ const initialState = (cms) => {
12053
12091
  forms: [],
12054
12092
  formLists: [],
12055
12093
  editingMode: "basic",
12094
+ isLoadingContent: false,
12056
12095
  quickEditSupported: false,
12057
12096
  sidebarDisplayState: ((_a = cms == null ? void 0 : cms.sidebar) == null ? void 0 : _a.defaultState) || "open"
12058
12097
  };
@@ -12112,7 +12151,12 @@ function tinaReducer(state, action) {
12112
12151
  }
12113
12152
  });
12114
12153
  }
12115
- return { ...state, activeFormId, formLists: nextFormLists };
12154
+ return {
12155
+ ...state,
12156
+ activeFormId,
12157
+ formLists: nextFormLists,
12158
+ isLoadingContent: false
12159
+ };
12116
12160
  }
12117
12161
  case "form-lists:remove": {
12118
12162
  const nextFormLists = state.formLists.filter(
@@ -12181,6 +12225,9 @@ function tinaReducer(state, action) {
12181
12225
  }
12182
12226
  return { ...state, sidebarDisplayState: action.value };
12183
12227
  }
12228
+ case "sidebar:set-loading-state": {
12229
+ return { ...state, isLoadingContent: action.value };
12230
+ }
12184
12231
  default:
12185
12232
  throw new Error(`Unhandled action ${action.type}`);
12186
12233
  }
@@ -12866,7 +12913,6 @@ const CreateBranchModel = ({
12866
12913
  }) => {
12867
12914
  const cms = useCMS$1();
12868
12915
  const tinaApi = cms.api.tina;
12869
- tinaApi.branch;
12870
12916
  const [disabled, setDisabled] = React.useState(false);
12871
12917
  const [newBranchName, setNewBranchName] = React.useState("");
12872
12918
  const [error, setError] = React.useState("");
@@ -12892,10 +12938,10 @@ const CreateBranchModel = ({
12892
12938
  const newUrl = window.location.href.replace(hash, newHash);
12893
12939
  window.location.href = newUrl;
12894
12940
  };
12895
- return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, /* @__PURE__ */ React.createElement(BiGitBranch, { className: "w-6 h-auto mr-1 text-blue-500 opacity-70" }), " ", "Create Branch"), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", { className: "text-base text-gray-700 mb-2" }, "This branch is ", /* @__PURE__ */ React.createElement("strong", null, "protected"), ". Create a new branch to save your changes."), /* @__PURE__ */ React.createElement(
12941
+ return /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, { close: close2 }, /* @__PURE__ */ React.createElement(BiGitBranch, { className: "w-6 h-auto mr-1 text-blue-500 opacity-70" }), " ", "Create Branch"), /* @__PURE__ */ React.createElement(ModalBody, { padded: true }, /* @__PURE__ */ React.createElement("p", { className: "text-lg text-gray-700 font-bold mb-2" }, "This content is protected 🚧"), /* @__PURE__ */ React.createElement("p", { className: "text-sm text-gray-700 mb-4" }, "To make changes, you need to create a copy then get it approved and merged for it to go live."), /* @__PURE__ */ React.createElement(
12896
12942
  PrefixedTextField,
12897
12943
  {
12898
- placeholder: "Branch Name",
12944
+ placeholder: "e.g. {{PAGE-NAME}}-updates",
12899
12945
  value: newBranchName,
12900
12946
  onChange: (e) => {
12901
12947
  setError("");
@@ -30650,6 +30696,7 @@ mutation addPendingDocumentMutation(
30650
30696
  setBranch(branchName) {
30651
30697
  var _a, _b, _c, _d;
30652
30698
  const encodedBranch = encodeURIComponent(branchName);
30699
+ document.cookie = `x-branch=${encodedBranch}; path=/; max-age=3600`;
30653
30700
  this.branch = encodedBranch;
30654
30701
  this.assetsApiUrl = ((_a = this.options.tinaioConfig) == null ? void 0 : _a.assetsApiUrlOverride) || "https://assets.tinajs.io";
30655
30702
  this.frontendUrl = ((_b = this.options.tinaioConfig) == null ? void 0 : _b.frontendUrlOverride) || "https://app.tina.io";
@@ -30692,7 +30739,7 @@ mutation addPendingDocumentMutation(
30692
30739
  branch: ${this.branch}.`;
30693
30740
  if (this.branch !== "main") {
30694
30741
  errorMessage = `${errorMessage}
30695
- Note: This error can occur if the branch does not exist on GitHub or on Tina Cloud`;
30742
+ Note: This error can occur if the branch does not exist on GitHub or on TinaCloud`;
30696
30743
  }
30697
30744
  }
30698
30745
  throw new Error(errorMessage);
@@ -30828,7 +30875,7 @@ mutation addPendingDocumentMutation(
30828
30875
  unknownCount++;
30829
30876
  if (unknownCount > 5) {
30830
30877
  throw new Error(
30831
- "AsyncPoller: status unknown for too long, please check indexing progress the Tina Cloud dashboard"
30878
+ "AsyncPoller: status unknown for too long, please check indexing progress the TinaCloud dashboard"
30832
30879
  );
30833
30880
  }
30834
30881
  }
@@ -31539,7 +31586,7 @@ const AuthWallInner = ({
31539
31586
  });
31540
31587
  }
31541
31588
  };
31542
- let modalTitle = "Tina Cloud";
31589
+ let modalTitle = "TinaCloud";
31543
31590
  if (activeModal === "authenticate" && loginStrategy === "Redirect" && !isTinaCloud) {
31544
31591
  modalTitle = "Enter into edit mode";
31545
31592
  } else if (activeModal === "authenticate" && loginStrategy === "UsernamePassword") {
@@ -31555,7 +31602,7 @@ const AuthWallInner = ({
31555
31602
  ModalBuilder,
31556
31603
  {
31557
31604
  title: modalTitle,
31558
- message: isTinaCloud ? "Your site uses Tina Cloud to track changes. To make edits, you must log in." : "To save edits, enter into edit mode. On save, changes will saved to the local filesystem.",
31605
+ message: isTinaCloud ? "Your site uses TinaCloud to track changes. To make edits, you must log in." : "To save edits, enter into edit mode. On save, changes will saved to the local filesystem.",
31559
31606
  close,
31560
31607
  actions: [
31561
31608
  ...otherModalActions,
@@ -32278,6 +32325,14 @@ This will work when developing locally but NOT when deployed to production.
32278
32325
  }
32279
32326
  return client.request(query, { variables });
32280
32327
  };
32328
+ const GetCMS = ({ children }) => {
32329
+ try {
32330
+ const cms = useCMS$1();
32331
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children(cms));
32332
+ } catch (e) {
32333
+ return null;
32334
+ }
32335
+ };
32281
32336
  const Layout = ({ children }) => {
32282
32337
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
32283
32338
  "div",
@@ -32489,14 +32544,118 @@ const SidebarCloudLink = ({ config }) => {
32489
32544
  }
32490
32545
  return /* @__PURE__ */ React__default.createElement("span", { className: "text-base tracking-wide text-gray-500 hover:text-blue-600 flex items-center opacity-90 hover:opacity-100" }, /* @__PURE__ */ React__default.createElement(config.Icon, { className: "mr-2 h-6 opacity-80 w-auto" }), /* @__PURE__ */ React__default.createElement("a", { target: "_blank", href: config.link.href }, config.link.text));
32491
32546
  };
32492
- const GetCMS = ({ children }) => {
32493
- try {
32494
- const cms = useCMS$1();
32495
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children(cms));
32496
- } catch (e) {
32497
- return null;
32498
- }
32499
- };
32547
+ const LoadingPage = () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
32548
+ "div",
32549
+ {
32550
+ style: {
32551
+ position: "absolute",
32552
+ top: 0,
32553
+ left: 0,
32554
+ width: "100%",
32555
+ height: "100%",
32556
+ zIndex: 200,
32557
+ opacity: "0.8",
32558
+ display: "flex",
32559
+ alignItems: "start",
32560
+ justifyContent: "center",
32561
+ padding: "120px 40px 40px 40px"
32562
+ }
32563
+ },
32564
+ /* @__PURE__ */ React__default.createElement(
32565
+ "div",
32566
+ {
32567
+ style: {
32568
+ background: "#FFF",
32569
+ border: "1px solid #EDECF3",
32570
+ boxShadow: "0px 2px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.1)",
32571
+ borderRadius: "8px",
32572
+ padding: "32px 24px",
32573
+ width: "460px",
32574
+ maxWidth: "90%",
32575
+ display: "flex",
32576
+ alignItems: "center",
32577
+ justifyContent: "center",
32578
+ flexDirection: "column"
32579
+ }
32580
+ },
32581
+ /* @__PURE__ */ React__default.createElement(
32582
+ "svg",
32583
+ {
32584
+ style: {
32585
+ width: "64px",
32586
+ color: "#2296fe",
32587
+ marginTop: "-8px",
32588
+ marginBottom: "16px"
32589
+ },
32590
+ version: "1.1",
32591
+ id: "L5",
32592
+ xmlns: "http://www.w3.org/2000/svg",
32593
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
32594
+ x: "0px",
32595
+ y: "0px",
32596
+ viewBox: "0 0 100 64",
32597
+ enableBackground: "new 0 0 0 0",
32598
+ xmlSpace: "preserve"
32599
+ },
32600
+ /* @__PURE__ */ React__default.createElement("circle", { fill: "currentColor", stroke: "none", cx: 6, cy: 32, r: 6 }, /* @__PURE__ */ React__default.createElement(
32601
+ "animateTransform",
32602
+ {
32603
+ attributeName: "transform",
32604
+ dur: "1s",
32605
+ type: "translate",
32606
+ values: "0 15 ; 0 -15; 0 15",
32607
+ calcMode: "spline",
32608
+ keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
32609
+ repeatCount: "indefinite",
32610
+ begin: "0.1"
32611
+ }
32612
+ )),
32613
+ /* @__PURE__ */ React__default.createElement("circle", { fill: "currentColor", stroke: "none", cx: 30, cy: 32, r: 6 }, /* @__PURE__ */ React__default.createElement(
32614
+ "animateTransform",
32615
+ {
32616
+ attributeName: "transform",
32617
+ dur: "1s",
32618
+ type: "translate",
32619
+ values: "0 15 ; 0 -10; 0 15",
32620
+ calcMode: "spline",
32621
+ keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
32622
+ repeatCount: "indefinite",
32623
+ begin: "0.2"
32624
+ }
32625
+ )),
32626
+ /* @__PURE__ */ React__default.createElement("circle", { fill: "currentColor", stroke: "none", cx: 54, cy: 32, r: 6 }, /* @__PURE__ */ React__default.createElement(
32627
+ "animateTransform",
32628
+ {
32629
+ attributeName: "transform",
32630
+ dur: "1s",
32631
+ type: "translate",
32632
+ values: "0 15 ; 0 -5; 0 15",
32633
+ calcMode: "spline",
32634
+ keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
32635
+ repeatCount: "indefinite",
32636
+ begin: "0.3"
32637
+ }
32638
+ ))
32639
+ ),
32640
+ /* @__PURE__ */ React__default.createElement(
32641
+ "p",
32642
+ {
32643
+ style: {
32644
+ fontSize: "16px",
32645
+ color: "#716c7f",
32646
+ textAlign: "center",
32647
+ lineHeight: "1.3",
32648
+ fontFamily: "'Inter', sans-serif",
32649
+ fontWeight: "normal"
32650
+ }
32651
+ },
32652
+ "Please wait, Tina is loading data..."
32653
+ )
32654
+ )
32655
+ ));
32656
+ function RiHome2Line(props) {
32657
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M19 21H5C4.44772 21 4 20.5523 4 20V11L1 11L11.3273 1.6115C11.7087 1.26475 12.2913 1.26475 12.6727 1.6115L23 11L20 11V20C20 20.5523 19.5523 21 19 21ZM6 19H18V9.15745L12 3.7029L6 9.15745V19Z" }, "child": [] }] })(props);
32658
+ }
32500
32659
  const PageWrapper = ({ children }) => {
32501
32660
  var _a, _b;
32502
32661
  const cms = useCMS$1();
@@ -32521,321 +32680,6 @@ const PageHeader = ({
32521
32680
  };
32522
32681
  const PageBody = ({ children }) => /* @__PURE__ */ React__default.createElement("div", { className: "py-8 px-6 xl:px-12" }, children);
32523
32682
  const PageBodyNarrow = ({ children }) => /* @__PURE__ */ React__default.createElement("div", { className: "py-10 px-6 xl:px-12" }, /* @__PURE__ */ React__default.createElement("div", { className: "w-full mx-auto max-w-screen-xl" }, children));
32524
- const DashboardPage = () => {
32525
- return /* @__PURE__ */ React__default.createElement(GetCMS, null, (cms) => {
32526
- var _a, _b;
32527
- return /* @__PURE__ */ React__default.createElement(PageWrapper, null, /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(PageHeader, { isLocalMode: (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode }, /* @__PURE__ */ React__default.createElement("h3", { className: "text-2xl font-sans text-gray-700" }, "Welcome to Tina!")), /* @__PURE__ */ React__default.createElement(PageBodyNarrow, null, "This is your dashboard for editing or creating content. Select a collection on the left to begin.")));
32528
- });
32529
- };
32530
- function RiHome2Line(props) {
32531
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M19 21H5C4.44772 21 4 20.5523 4 20V11L1 11L11.3273 1.6115C11.7087 1.26475 12.2913 1.26475 12.6727 1.6115L23 11L20 11V20C20 20.5523 19.5523 21 19 21ZM6 19H18V9.15745L12 3.7029L6 9.15745V19Z" }, "child": [] }] })(props);
32532
- }
32533
- const LoadingPage = () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
32534
- "div",
32535
- {
32536
- style: {
32537
- position: "absolute",
32538
- top: 0,
32539
- left: 0,
32540
- width: "100%",
32541
- height: "100%",
32542
- zIndex: 200,
32543
- opacity: "0.8",
32544
- display: "flex",
32545
- alignItems: "start",
32546
- justifyContent: "center",
32547
- padding: "120px 40px 40px 40px"
32548
- }
32549
- },
32550
- /* @__PURE__ */ React__default.createElement(
32551
- "div",
32552
- {
32553
- style: {
32554
- background: "#FFF",
32555
- border: "1px solid #EDECF3",
32556
- boxShadow: "0px 2px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.1)",
32557
- borderRadius: "8px",
32558
- padding: "32px 24px",
32559
- width: "460px",
32560
- maxWidth: "90%",
32561
- display: "flex",
32562
- alignItems: "center",
32563
- justifyContent: "center",
32564
- flexDirection: "column"
32565
- }
32566
- },
32567
- /* @__PURE__ */ React__default.createElement(
32568
- "svg",
32569
- {
32570
- style: {
32571
- width: "64px",
32572
- color: "#2296fe",
32573
- marginTop: "-8px",
32574
- marginBottom: "16px"
32575
- },
32576
- version: "1.1",
32577
- id: "L5",
32578
- xmlns: "http://www.w3.org/2000/svg",
32579
- xmlnsXlink: "http://www.w3.org/1999/xlink",
32580
- x: "0px",
32581
- y: "0px",
32582
- viewBox: "0 0 100 64",
32583
- enableBackground: "new 0 0 0 0",
32584
- xmlSpace: "preserve"
32585
- },
32586
- /* @__PURE__ */ React__default.createElement("circle", { fill: "currentColor", stroke: "none", cx: 6, cy: 32, r: 6 }, /* @__PURE__ */ React__default.createElement(
32587
- "animateTransform",
32588
- {
32589
- attributeName: "transform",
32590
- dur: "1s",
32591
- type: "translate",
32592
- values: "0 15 ; 0 -15; 0 15",
32593
- calcMode: "spline",
32594
- keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
32595
- repeatCount: "indefinite",
32596
- begin: "0.1"
32597
- }
32598
- )),
32599
- /* @__PURE__ */ React__default.createElement("circle", { fill: "currentColor", stroke: "none", cx: 30, cy: 32, r: 6 }, /* @__PURE__ */ React__default.createElement(
32600
- "animateTransform",
32601
- {
32602
- attributeName: "transform",
32603
- dur: "1s",
32604
- type: "translate",
32605
- values: "0 15 ; 0 -10; 0 15",
32606
- calcMode: "spline",
32607
- keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
32608
- repeatCount: "indefinite",
32609
- begin: "0.2"
32610
- }
32611
- )),
32612
- /* @__PURE__ */ React__default.createElement("circle", { fill: "currentColor", stroke: "none", cx: 54, cy: 32, r: 6 }, /* @__PURE__ */ React__default.createElement(
32613
- "animateTransform",
32614
- {
32615
- attributeName: "transform",
32616
- dur: "1s",
32617
- type: "translate",
32618
- values: "0 15 ; 0 -5; 0 15",
32619
- calcMode: "spline",
32620
- keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
32621
- repeatCount: "indefinite",
32622
- begin: "0.3"
32623
- }
32624
- ))
32625
- ),
32626
- /* @__PURE__ */ React__default.createElement(
32627
- "p",
32628
- {
32629
- style: {
32630
- fontSize: "16px",
32631
- color: "#716c7f",
32632
- textAlign: "center",
32633
- lineHeight: "1.3",
32634
- fontFamily: "'Inter', sans-serif",
32635
- fontWeight: "normal"
32636
- }
32637
- },
32638
- "Please wait, Tina is loading data..."
32639
- )
32640
- )
32641
- ));
32642
- const FullscreenError = ({
32643
- title = "Error",
32644
- errorMessage = "It looks like something went wrong."
32645
- }) => {
32646
- return /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col justify-center items-center h-screen bg-gray-100" }, /* @__PURE__ */ React__default.createElement("div", { className: "text-red-500 text-4xl mb-6 flex items-center" }, /* @__PURE__ */ React__default.createElement(BiError, { className: "w-12 h-auto fill-current text-red-400 opacity-70 mr-1" }), " ", title), /* @__PURE__ */ React__default.createElement("p", { className: "text-gray-700 text-xl mb-8" }, errorMessage), /* @__PURE__ */ React__default.createElement(Button$1, { variant: "danger", onClick: () => window.location.reload() }, /* @__PURE__ */ React__default.createElement(BiSync, { className: "w-7 h-auto fill-current opacity-70 mr-1" }), " Reload"));
32647
- };
32648
- const useGetCollection = (cms, collectionName, includeDocuments = true, folder, after = "", sortKey, filterArgs) => {
32649
- const api = new TinaAdminApi(cms);
32650
- const schema = cms.api.tina.schema;
32651
- const collectionExtra = schema.getCollection(collectionName);
32652
- const [collection, setCollection] = useState(void 0);
32653
- const [loading, setLoading] = useState(true);
32654
- const [error, setError] = useState(void 0);
32655
- const [resetState, setResetSate] = useState(0);
32656
- useEffect(() => {
32657
- let cancelled = false;
32658
- const fetchCollection = async () => {
32659
- var _a;
32660
- if (await api.isAuthenticated() && !folder.loading && !cancelled) {
32661
- const { name, order } = JSON.parse(sortKey || "{}");
32662
- const validSortKey = ((_a = collectionExtra.fields) == null ? void 0 : _a.map((x) => x.name).includes(name)) ? name : void 0;
32663
- try {
32664
- const collection2 = await api.fetchCollection(
32665
- collectionName,
32666
- includeDocuments,
32667
- (filterArgs == null ? void 0 : filterArgs.filterField) ? "" : folder.fullyQualifiedName,
32668
- after,
32669
- validSortKey,
32670
- order,
32671
- filterArgs
32672
- );
32673
- setCollection(collection2);
32674
- } catch (error2) {
32675
- cms.alerts.error(
32676
- `[${error2.name}] GetCollection failed: ${error2.message}`
32677
- );
32678
- console.error(error2);
32679
- setCollection(void 0);
32680
- setError(error2);
32681
- }
32682
- setLoading(false);
32683
- }
32684
- };
32685
- if (cancelled)
32686
- return;
32687
- setLoading(true);
32688
- fetchCollection();
32689
- return () => {
32690
- cancelled = true;
32691
- };
32692
- }, [
32693
- cms,
32694
- collectionName,
32695
- folder.loading,
32696
- folder.fullyQualifiedName,
32697
- resetState,
32698
- after,
32699
- sortKey
32700
- ]);
32701
- const reFetchCollection = () => setResetSate((x) => x + 1);
32702
- return { collection, loading, error, reFetchCollection, collectionExtra };
32703
- };
32704
- const useSearchCollection = (cms, collectionName, includeDocuments = true, folder, after = "", search) => {
32705
- const api = new TinaAdminApi(cms);
32706
- const schema = cms.api.tina.schema;
32707
- const collectionExtra = schema.getCollection(collectionName);
32708
- const [collection, setCollection] = useState(void 0);
32709
- const [loading, setLoading] = useState(true);
32710
- const [error, setError] = useState(void 0);
32711
- const [resetState, setResetSate] = useState(0);
32712
- useEffect(() => {
32713
- let cancelled = false;
32714
- const searchCollection = async () => {
32715
- if (await api.isAuthenticated() && !folder.loading && !cancelled) {
32716
- try {
32717
- const response = await cms.api.search.query(
32718
- `${search} AND _collection:${collectionName}`,
32719
- {
32720
- limit: 15,
32721
- cursor: after
32722
- }
32723
- );
32724
- const docs = await Promise.allSettled(
32725
- response.results.map((result) => {
32726
- const [collection2, relativePath2] = result._id.split(":");
32727
- return api.fetchDocument(collection2, relativePath2, false);
32728
- })
32729
- );
32730
- const edges = docs.filter((p) => {
32731
- var _a;
32732
- return p.status === "fulfilled" && !!((_a = p.value) == null ? void 0 : _a.document);
32733
- }).map((result) => ({ node: result.value.document }));
32734
- const c = await api.fetchCollection(collectionName, false, "");
32735
- setCollection({
32736
- format: collection.format,
32737
- label: collection.label,
32738
- name: collectionName,
32739
- templates: collection.templates,
32740
- documents: {
32741
- pageInfo: {
32742
- hasNextPage: !!response.nextCursor,
32743
- hasPreviousPage: !!response.prevCursor,
32744
- startCursor: "",
32745
- endCursor: response.nextCursor || ""
32746
- },
32747
- edges
32748
- }
32749
- });
32750
- } catch (error2) {
32751
- cms.alerts.error(
32752
- `[${error2.name}] GetCollection failed: ${error2.message}`
32753
- );
32754
- console.error(error2);
32755
- setCollection(void 0);
32756
- setError(error2);
32757
- }
32758
- setLoading(false);
32759
- }
32760
- };
32761
- if (cancelled)
32762
- return;
32763
- setLoading(true);
32764
- searchCollection();
32765
- return () => {
32766
- cancelled = true;
32767
- };
32768
- }, [
32769
- cms,
32770
- collectionName,
32771
- folder.loading,
32772
- folder.fullyQualifiedName,
32773
- resetState,
32774
- after,
32775
- search
32776
- ]);
32777
- const reFetchCollection = () => setResetSate((x) => x + 1);
32778
- return { collection, loading, error, reFetchCollection, collectionExtra };
32779
- };
32780
- const GetCollection = ({
32781
- cms,
32782
- collectionName,
32783
- folder,
32784
- includeDocuments = true,
32785
- startCursor,
32786
- sortKey,
32787
- children,
32788
- filterArgs,
32789
- search
32790
- }) => {
32791
- const navigate = useNavigate();
32792
- const { collection, loading, error, reFetchCollection, collectionExtra } = search ? useSearchCollection(
32793
- cms,
32794
- collectionName,
32795
- includeDocuments,
32796
- folder,
32797
- startCursor || "",
32798
- search
32799
- ) : useGetCollection(
32800
- cms,
32801
- collectionName,
32802
- includeDocuments,
32803
- folder,
32804
- startCursor || "",
32805
- sortKey,
32806
- filterArgs
32807
- ) || {};
32808
- useEffect(() => {
32809
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
32810
- if (loading)
32811
- return;
32812
- const collectionDefinition = cms.api.tina.schema.getCollection(
32813
- collection.name
32814
- );
32815
- const allowCreate = ((_b = (_a = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _a.allowedActions) == null ? void 0 : _b.create) ?? true;
32816
- const allowDelete = ((_d = (_c = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _c.allowedActions) == null ? void 0 : _d.delete) ?? true;
32817
- const collectionResponse = collection;
32818
- if (!allowCreate && !allowDelete && // Check there is only one document
32819
- ((_f = (_e = collectionResponse.documents) == null ? void 0 : _e.edges) == null ? void 0 : _f.length) === 1 && // Check to make sure the file is not a folder
32820
- ((_i = (_h = (_g = collectionResponse.documents) == null ? void 0 : _g.edges[0]) == null ? void 0 : _h.node) == null ? void 0 : _i.__typename) !== "Folder") {
32821
- const doc = collectionResponse.documents.edges[0].node;
32822
- handleNavigate(
32823
- navigate,
32824
- cms,
32825
- collectionResponse,
32826
- collectionDefinition,
32827
- doc
32828
- );
32829
- }
32830
- }, [(collection == null ? void 0 : collection.name) || "", loading]);
32831
- if (error) {
32832
- return /* @__PURE__ */ React__default.createElement(FullscreenError, null);
32833
- }
32834
- if (loading) {
32835
- return /* @__PURE__ */ React__default.createElement(LoadingPage, null);
32836
- }
32837
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children(collection, loading, reFetchCollection, collectionExtra));
32838
- };
32839
32683
  const folderRegex = /^.*\/~\/*(.*)$/;
32840
32684
  const parentFolder = (folder) => {
32841
32685
  return {
@@ -33713,6 +33557,231 @@ const RenameModal = ({
33713
33557
  "Rename"
33714
33558
  ))));
33715
33559
  };
33560
+ const FullscreenError = ({
33561
+ title = "Error",
33562
+ errorMessage = "It looks like something went wrong."
33563
+ }) => {
33564
+ return /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col justify-center items-center h-screen bg-gray-100" }, /* @__PURE__ */ React__default.createElement("div", { className: "text-red-500 text-4xl mb-6 flex items-center" }, /* @__PURE__ */ React__default.createElement(BiError, { className: "w-12 h-auto fill-current text-red-400 opacity-70 mr-1" }), " ", title), /* @__PURE__ */ React__default.createElement("p", { className: "text-gray-700 text-xl mb-8" }, errorMessage), /* @__PURE__ */ React__default.createElement(Button$1, { variant: "danger", onClick: () => window.location.reload() }, /* @__PURE__ */ React__default.createElement(BiSync, { className: "w-7 h-auto fill-current opacity-70 mr-1" }), " Reload"));
33565
+ };
33566
+ const isValidSortKey = (sortKey, collection) => {
33567
+ if (collection.fields) {
33568
+ const sortKeys = collection.fields.map((x) => x.name);
33569
+ return sortKeys.includes(sortKey);
33570
+ } else if (collection.templates) {
33571
+ const collectionMap = {};
33572
+ const conflictedFields = /* @__PURE__ */ new Set();
33573
+ for (const template of collection.templates) {
33574
+ for (const field of template.fields) {
33575
+ if (collectionMap[field.name]) {
33576
+ if (collectionMap[field.name].type !== field.type) {
33577
+ conflictedFields.add(field.name);
33578
+ }
33579
+ } else {
33580
+ collectionMap[field.name] = field;
33581
+ }
33582
+ }
33583
+ }
33584
+ for (const key in conflictedFields) {
33585
+ delete collectionMap[key];
33586
+ }
33587
+ for (const key in collectionMap) {
33588
+ if (key === sortKey) {
33589
+ return true;
33590
+ }
33591
+ }
33592
+ return false;
33593
+ }
33594
+ };
33595
+ const useGetCollection = (cms, collectionName, includeDocuments = true, folder, after = "", sortKey, filterArgs) => {
33596
+ const api = new TinaAdminApi(cms);
33597
+ const schema = cms.api.tina.schema;
33598
+ const collectionExtra = schema.getCollection(collectionName);
33599
+ const [collection, setCollection] = useState(void 0);
33600
+ const [loading, setLoading] = useState(true);
33601
+ const [error, setError] = useState(void 0);
33602
+ const [resetState, setResetSate] = useState(0);
33603
+ useEffect(() => {
33604
+ let cancelled = false;
33605
+ const fetchCollection = async () => {
33606
+ if (await api.isAuthenticated() && !folder.loading && !cancelled) {
33607
+ const { name, order } = JSON.parse(sortKey || "{}");
33608
+ const validSortKey = isValidSortKey(name, collectionExtra) ? name : void 0;
33609
+ try {
33610
+ const collection2 = await api.fetchCollection(
33611
+ collectionName,
33612
+ includeDocuments,
33613
+ (filterArgs == null ? void 0 : filterArgs.filterField) ? "" : folder.fullyQualifiedName,
33614
+ after,
33615
+ validSortKey,
33616
+ order,
33617
+ filterArgs
33618
+ );
33619
+ setCollection(collection2);
33620
+ } catch (error2) {
33621
+ cms.alerts.error(
33622
+ `[${error2.name}] GetCollection failed: ${error2.message}`
33623
+ );
33624
+ console.error(error2);
33625
+ setCollection(void 0);
33626
+ setError(error2);
33627
+ }
33628
+ setLoading(false);
33629
+ }
33630
+ };
33631
+ if (cancelled)
33632
+ return;
33633
+ setLoading(true);
33634
+ fetchCollection();
33635
+ return () => {
33636
+ cancelled = true;
33637
+ };
33638
+ }, [
33639
+ cms,
33640
+ collectionName,
33641
+ folder.loading,
33642
+ folder.fullyQualifiedName,
33643
+ resetState,
33644
+ after,
33645
+ sortKey
33646
+ ]);
33647
+ const reFetchCollection = () => setResetSate((x) => x + 1);
33648
+ return { collection, loading, error, reFetchCollection, collectionExtra };
33649
+ };
33650
+ const useSearchCollection = (cms, collectionName, includeDocuments = true, folder, after = "", search) => {
33651
+ const api = new TinaAdminApi(cms);
33652
+ const schema = cms.api.tina.schema;
33653
+ const collectionExtra = schema.getCollection(collectionName);
33654
+ const [collection, setCollection] = useState(void 0);
33655
+ const [loading, setLoading] = useState(true);
33656
+ const [error, setError] = useState(void 0);
33657
+ const [resetState, setResetSate] = useState(0);
33658
+ useEffect(() => {
33659
+ let cancelled = false;
33660
+ const searchCollection = async () => {
33661
+ if (await api.isAuthenticated() && !folder.loading && !cancelled) {
33662
+ try {
33663
+ const response = await cms.api.search.query(
33664
+ `${search} AND _collection:${collectionName}`,
33665
+ {
33666
+ limit: 15,
33667
+ cursor: after
33668
+ }
33669
+ );
33670
+ const docs = await Promise.allSettled(
33671
+ response.results.map((result) => {
33672
+ const [collection2, relativePath2] = result._id.split(":");
33673
+ return api.fetchDocument(collection2, relativePath2, false);
33674
+ })
33675
+ );
33676
+ const edges = docs.filter((p) => {
33677
+ var _a;
33678
+ return p.status === "fulfilled" && !!((_a = p.value) == null ? void 0 : _a.document);
33679
+ }).map((result) => ({ node: result.value.document }));
33680
+ const c = await api.fetchCollection(collectionName, false, "");
33681
+ setCollection({
33682
+ format: collection.format,
33683
+ label: collection.label,
33684
+ name: collectionName,
33685
+ templates: collection.templates,
33686
+ documents: {
33687
+ pageInfo: {
33688
+ hasNextPage: !!response.nextCursor,
33689
+ hasPreviousPage: !!response.prevCursor,
33690
+ startCursor: "",
33691
+ endCursor: response.nextCursor || ""
33692
+ },
33693
+ edges
33694
+ }
33695
+ });
33696
+ } catch (error2) {
33697
+ cms.alerts.error(
33698
+ `[${error2.name}] GetCollection failed: ${error2.message}`
33699
+ );
33700
+ console.error(error2);
33701
+ setCollection(void 0);
33702
+ setError(error2);
33703
+ }
33704
+ setLoading(false);
33705
+ }
33706
+ };
33707
+ if (cancelled)
33708
+ return;
33709
+ setLoading(true);
33710
+ searchCollection();
33711
+ return () => {
33712
+ cancelled = true;
33713
+ };
33714
+ }, [
33715
+ cms,
33716
+ collectionName,
33717
+ folder.loading,
33718
+ folder.fullyQualifiedName,
33719
+ resetState,
33720
+ after,
33721
+ search
33722
+ ]);
33723
+ const reFetchCollection = () => setResetSate((x) => x + 1);
33724
+ return { collection, loading, error, reFetchCollection, collectionExtra };
33725
+ };
33726
+ const GetCollection = ({
33727
+ cms,
33728
+ collectionName,
33729
+ folder,
33730
+ includeDocuments = true,
33731
+ startCursor,
33732
+ sortKey,
33733
+ children,
33734
+ filterArgs,
33735
+ search
33736
+ }) => {
33737
+ const navigate = useNavigate();
33738
+ const { collection, loading, error, reFetchCollection, collectionExtra } = search ? useSearchCollection(
33739
+ cms,
33740
+ collectionName,
33741
+ includeDocuments,
33742
+ folder,
33743
+ startCursor || "",
33744
+ search
33745
+ ) : useGetCollection(
33746
+ cms,
33747
+ collectionName,
33748
+ includeDocuments,
33749
+ folder,
33750
+ startCursor || "",
33751
+ sortKey,
33752
+ filterArgs
33753
+ ) || {};
33754
+ useEffect(() => {
33755
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
33756
+ if (loading)
33757
+ return;
33758
+ const collectionDefinition = cms.api.tina.schema.getCollection(
33759
+ collection.name
33760
+ );
33761
+ const allowCreate = ((_b = (_a = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _a.allowedActions) == null ? void 0 : _b.create) ?? true;
33762
+ const allowDelete = ((_d = (_c = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _c.allowedActions) == null ? void 0 : _d.delete) ?? true;
33763
+ const collectionResponse = collection;
33764
+ if (!allowCreate && !allowDelete && // Check there is only one document
33765
+ ((_f = (_e = collectionResponse.documents) == null ? void 0 : _e.edges) == null ? void 0 : _f.length) === 1 && // Check to make sure the file is not a folder
33766
+ ((_i = (_h = (_g = collectionResponse.documents) == null ? void 0 : _g.edges[0]) == null ? void 0 : _h.node) == null ? void 0 : _i.__typename) !== "Folder") {
33767
+ const doc = collectionResponse.documents.edges[0].node;
33768
+ handleNavigate(
33769
+ navigate,
33770
+ cms,
33771
+ collectionResponse,
33772
+ collectionDefinition,
33773
+ doc
33774
+ );
33775
+ }
33776
+ }, [(collection == null ? void 0 : collection.name) || "", loading]);
33777
+ if (error) {
33778
+ return /* @__PURE__ */ React__default.createElement(FullscreenError, null);
33779
+ }
33780
+ if (loading) {
33781
+ return /* @__PURE__ */ React__default.createElement(LoadingPage, null);
33782
+ }
33783
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children(collection, loading, reFetchCollection, collectionExtra));
33784
+ };
33716
33785
  const ErrorDialog = (props) => {
33717
33786
  return /* @__PURE__ */ React__default.createElement(
33718
33787
  "div",
@@ -34256,6 +34325,12 @@ const RenderForm = ({
34256
34325
  ), /* @__PURE__ */ React__default.createElement("span", { className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0" }, "/"), /* @__PURE__ */ React__default.createElement("span", { className: "flex-1 w-full text-sm leading-tight whitespace-nowrap truncate" }, `${filename}.${collection.format}`), /* @__PURE__ */ React__default.createElement(FormStatus, { pristine: formIsPristine }))
34257
34326
  ), activeForm && /* @__PURE__ */ React__default.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine }));
34258
34327
  };
34328
+ const DashboardPage = () => {
34329
+ return /* @__PURE__ */ React__default.createElement(GetCMS, null, (cms) => {
34330
+ var _a, _b;
34331
+ return /* @__PURE__ */ React__default.createElement(PageWrapper, null, /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(PageHeader, { isLocalMode: (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode }, /* @__PURE__ */ React__default.createElement("h3", { className: "text-2xl font-sans text-gray-700" }, "Welcome to Tina!")), /* @__PURE__ */ React__default.createElement(PageBodyNarrow, null, "This is your dashboard for editing or creating content. Select a collection on the left to begin.")));
34332
+ });
34333
+ };
34259
34334
  const ScreenPage = () => {
34260
34335
  const { screenName } = useParams();
34261
34336
  return /* @__PURE__ */ React__default.createElement(GetCMS, null, (cms) => {
@@ -34338,7 +34413,7 @@ const IndexingPage = () => {
34338
34413
  } catch {
34339
34414
  cms.alerts.error("Branch indexing failed.");
34340
34415
  setErrorMessage(
34341
- 'Branch indexing failed, please check the Tina Cloud dashboard for more information. To try again chick "re-index" on the branch in the dashboard.'
34416
+ 'Branch indexing failed, please check the TinaCloud dashboard for more information. To try again chick "re-index" on the branch in the dashboard.'
34342
34417
  );
34343
34418
  setState("error");
34344
34419
  }
@@ -34506,7 +34581,7 @@ const CheckSchema = ({
34506
34581
  );
34507
34582
  }
34508
34583
  }).catch((e) => {
34509
- if (e.message.includes("has not been indexed by Tina Cloud")) {
34584
+ if (e.message.includes("has not been indexed by TinaCloud")) {
34510
34585
  setSchemaMissingError(true);
34511
34586
  } else {
34512
34587
  cms.alerts.error(`Unexpected error checking schema: ${e}`);