tinacms 0.59.0 → 0.59.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # tinacms
2
2
 
3
+ ## 0.59.1
4
+
5
+ ### Patch Changes
6
+
7
+ - ed9d48abc: Swaps starter's old admin for the new one
8
+ - f6876d30f: Alter empty sidebar message to be more specific to auto-generating logic
9
+ - Updated dependencies [f6876d30f]
10
+ - Updated dependencies [92268fc85]
11
+ - @tinacms/toolkit@0.56.1
12
+
3
13
  ## 0.59.0
4
14
 
5
15
  ### Minor Changes
@@ -0,0 +1,17 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ declare const AuthTemplate: ({ message, children, }: {
14
+ message?: string;
15
+ children: any;
16
+ }) => JSX.Element;
17
+ export default AuthTemplate;
@@ -0,0 +1,17 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ import type { TinaCMS } from '@tinacms/toolkit';
14
+ declare const Sidebar: ({ cms }: {
15
+ cms: TinaCMS;
16
+ }) => JSX.Element;
17
+ export default Sidebar;
@@ -0,0 +1,14 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ declare const LogoutPage: () => JSX.Element;
14
+ export default LogoutPage;
@@ -10,20 +10,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
+ import { isEditing, setEditing, useEditState } from '@tinacms/sharedctx';
13
14
  import React from 'react';
15
+ export { isEditing, setEditing, useEditState };
14
16
  export declare const TinaEditProvider: ({ showEditButton, ...props }: {
15
17
  showEditButton?: boolean;
16
18
  children: React.ReactNode;
17
19
  editMode: React.ReactNode;
18
20
  }) => JSX.Element;
19
- export declare const isEditing: () => boolean;
20
- export declare const setEditing: (isEditing: boolean) => void;
21
- export declare const EditContext: React.Context<{
22
- edit: boolean;
23
- setEdit: (edit: boolean) => void;
24
- }>;
25
- export declare const EditProvider: React.FC;
26
- export declare const useEditState: () => {
27
- edit: boolean;
28
- setEdit: (edit: boolean) => void;
29
- };
@@ -26,7 +26,9 @@ var __objRest = (source, exclude) => {
26
26
  }
27
27
  return target;
28
28
  };
29
- import React, { useState, useContext } from "react";
29
+ import { EditProvider, useEditState } from "@tinacms/sharedctx";
30
+ export { isEditing, setEditing, useEditState } from "@tinacms/sharedctx";
31
+ import React from "react";
30
32
  const TinaEditProvider = (_a) => {
31
33
  var _b = _a, {
32
34
  showEditButton
@@ -37,7 +39,16 @@ const TinaEditProvider = (_a) => {
37
39
  };
38
40
  const ToggleButton = () => {
39
41
  const { edit } = useEditState();
40
- return edit ? null : /* @__PURE__ */ React.createElement("div", {
42
+ const [isOnAdmin, setIsOnAdmin] = React.useState(false);
43
+ React.useEffect(() => {
44
+ var _a;
45
+ if (window) {
46
+ if ((_a = window.location) == null ? void 0 : _a.pathname.startsWith("/admin")) {
47
+ setIsOnAdmin(true);
48
+ }
49
+ }
50
+ }, [setIsOnAdmin]);
51
+ return edit || isOnAdmin ? null : /* @__PURE__ */ React.createElement("div", {
41
52
  style: { position: "fixed", bottom: "56px", left: "0px", zIndex: 200 }
42
53
  }, /* @__PURE__ */ React.createElement("a", {
43
54
  href: "/admin",
@@ -62,39 +73,4 @@ const TinaEditProviderInner = ({ children, editMode }) => {
62
73
  }
63
74
  return children;
64
75
  };
65
- const LOCALSTORAGEKEY = "tina.isEditing";
66
- const isSSR = typeof window === "undefined";
67
- const isEditing = () => {
68
- if (!isSSR) {
69
- const isEdit = window.localStorage.getItem(LOCALSTORAGEKEY);
70
- return isEdit && isEdit === "true";
71
- }
72
- return false;
73
- };
74
- const setEditing = (isEditing2) => {
75
- if (!isSSR) {
76
- window.localStorage.setItem(LOCALSTORAGEKEY, isEditing2 ? "true" : "false");
77
- }
78
- };
79
- const EditContext = React.createContext({
80
- edit: isEditing(),
81
- setEdit: void 0
82
- });
83
- const EditProvider = ({ children }) => {
84
- const [edit, setEditState] = useState(isEditing());
85
- const setEdit = (edit2) => {
86
- setEditState(edit2);
87
- setEditing(edit2);
88
- };
89
- return /* @__PURE__ */ React.createElement(EditContext.Provider, {
90
- value: { edit, setEdit }
91
- }, children);
92
- };
93
- const useEditState = () => {
94
- const { edit, setEdit } = useContext(EditContext);
95
- if (!setEdit) {
96
- throw new Error("No `TinaEditProvider` found");
97
- }
98
- return { edit, setEdit };
99
- };
100
- export { EditContext, EditProvider, TinaEditProvider, isEditing, setEditing, useEditState };
76
+ export { TinaEditProvider };
@@ -27,8 +27,8 @@ var __objRest = (source, exclude) => {
27
27
  return target;
28
28
  };
29
29
  (function(global, factory) {
30
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP));
31
- })(this, function(exports2, React) {
30
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@tinacms/sharedctx"), require("react")) : typeof define === "function" && define.amd ? define(["exports", "@tinacms/sharedctx", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP));
31
+ })(this, function(exports2, sharedctx, React) {
32
32
  "use strict";
33
33
  function _interopDefaultLegacy(e) {
34
34
  return e && typeof e === "object" && "default" in e ? e : { "default": e };
@@ -40,11 +40,20 @@ var __objRest = (source, exclude) => {
40
40
  } = _b, props = __objRest(_b, [
41
41
  "showEditButton"
42
42
  ]);
43
- return /* @__PURE__ */ React__default["default"].createElement(EditProvider, null, showEditButton && /* @__PURE__ */ React__default["default"].createElement(ToggleButton, null), /* @__PURE__ */ React__default["default"].createElement(TinaEditProviderInner, __spreadValues({}, props)));
43
+ return /* @__PURE__ */ React__default["default"].createElement(sharedctx.EditProvider, null, showEditButton && /* @__PURE__ */ React__default["default"].createElement(ToggleButton, null), /* @__PURE__ */ React__default["default"].createElement(TinaEditProviderInner, __spreadValues({}, props)));
44
44
  };
45
45
  const ToggleButton = () => {
46
- const { edit } = useEditState();
47
- return edit ? null : /* @__PURE__ */ React__default["default"].createElement("div", {
46
+ const { edit } = sharedctx.useEditState();
47
+ const [isOnAdmin, setIsOnAdmin] = React__default["default"].useState(false);
48
+ React__default["default"].useEffect(() => {
49
+ var _a;
50
+ if (window) {
51
+ if ((_a = window.location) == null ? void 0 : _a.pathname.startsWith("/admin")) {
52
+ setIsOnAdmin(true);
53
+ }
54
+ }
55
+ }, [setIsOnAdmin]);
56
+ return edit || isOnAdmin ? null : /* @__PURE__ */ React__default["default"].createElement("div", {
48
57
  style: { position: "fixed", bottom: "56px", left: "0px", zIndex: 200 }
49
58
  }, /* @__PURE__ */ React__default["default"].createElement("a", {
50
59
  href: "/admin",
@@ -63,53 +72,31 @@ var __objRest = (source, exclude) => {
63
72
  }, "Edit with Tina"));
64
73
  };
65
74
  const TinaEditProviderInner = ({ children, editMode }) => {
66
- const { edit } = useEditState();
75
+ const { edit } = sharedctx.useEditState();
67
76
  if (edit) {
68
77
  return editMode;
69
78
  }
70
79
  return children;
71
80
  };
72
- const LOCALSTORAGEKEY = "tina.isEditing";
73
- const isSSR = typeof window === "undefined";
74
- const isEditing = () => {
75
- if (!isSSR) {
76
- const isEdit = window.localStorage.getItem(LOCALSTORAGEKEY);
77
- return isEdit && isEdit === "true";
81
+ Object.defineProperty(exports2, "isEditing", {
82
+ enumerable: true,
83
+ get: function() {
84
+ return sharedctx.isEditing;
78
85
  }
79
- return false;
80
- };
81
- const setEditing = (isEditing2) => {
82
- if (!isSSR) {
83
- window.localStorage.setItem(LOCALSTORAGEKEY, isEditing2 ? "true" : "false");
86
+ });
87
+ Object.defineProperty(exports2, "setEditing", {
88
+ enumerable: true,
89
+ get: function() {
90
+ return sharedctx.setEditing;
84
91
  }
85
- };
86
- const EditContext = React__default["default"].createContext({
87
- edit: isEditing(),
88
- setEdit: void 0
89
92
  });
90
- const EditProvider = ({ children }) => {
91
- const [edit, setEditState] = React.useState(isEditing());
92
- const setEdit = (edit2) => {
93
- setEditState(edit2);
94
- setEditing(edit2);
95
- };
96
- return /* @__PURE__ */ React__default["default"].createElement(EditContext.Provider, {
97
- value: { edit, setEdit }
98
- }, children);
99
- };
100
- const useEditState = () => {
101
- const { edit, setEdit } = React.useContext(EditContext);
102
- if (!setEdit) {
103
- throw new Error("No `TinaEditProvider` found");
93
+ Object.defineProperty(exports2, "useEditState", {
94
+ enumerable: true,
95
+ get: function() {
96
+ return sharedctx.useEditState;
104
97
  }
105
- return { edit, setEdit };
106
- };
107
- exports2.EditContext = EditContext;
108
- exports2.EditProvider = EditProvider;
98
+ });
109
99
  exports2.TinaEditProvider = TinaEditProvider;
110
- exports2.isEditing = isEditing;
111
- exports2.setEditing = setEditing;
112
- exports2.useEditState = useEditState;
113
100
  Object.defineProperty(exports2, "__esModule", { value: true });
114
101
  exports2[Symbol.toStringTag] = "Module";
115
102
  });
package/dist/index.es.js CHANGED
@@ -37,8 +37,9 @@ export * from "@tinacms/toolkit";
37
37
  import React, { useState, useCallback, useEffect, Fragment } from "react";
38
38
  import styled from "styled-components";
39
39
  import * as yup from "yup";
40
+ import { setEditing, useEditState } from "@tinacms/sharedctx";
40
41
  import { getIn, setIn } from "final-form";
41
- import { useLocation, useParams, Link, useHistory, BrowserRouter, NavLink, Switch, Route } from "react-router-dom";
42
+ import { NavLink, useLocation, useParams, Link, useHistory, BrowserRouter, Switch, Route } from "react-router-dom";
42
43
  import { Menu, Transition } from "@headlessui/react";
43
44
  function popupWindow(url, title, window2, w, h) {
44
45
  const y = window2.top.outerHeight / 2 + window2.top.screenY - h / 2;
@@ -652,24 +653,6 @@ function safeAssertShape(value, yupSchema) {
652
653
  return false;
653
654
  }
654
655
  }
655
- const LOCALSTORAGEKEY = "tina.isEditing";
656
- const isSSR = typeof window === "undefined";
657
- const isEditing = () => {
658
- if (!isSSR) {
659
- const isEdit = window.localStorage.getItem(LOCALSTORAGEKEY);
660
- return isEdit && isEdit === "true";
661
- }
662
- return false;
663
- };
664
- const setEditing = (isEditing2) => {
665
- if (!isSSR) {
666
- window.localStorage.setItem(LOCALSTORAGEKEY, isEditing2 ? "true" : "false");
667
- }
668
- };
669
- React.createContext({
670
- edit: isEditing(),
671
- setEdit: void 0
672
- });
673
656
  function sleep(ms) {
674
657
  return new Promise((resolve) => setTimeout(resolve, ms));
675
658
  }
@@ -892,6 +875,9 @@ function BiLinkExternal(props) {
892
875
  function BiLogIn(props) {
893
876
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "m13 16 5-4-5-4v3H4v2h9z" } }, { "tag": "path", "attr": { "d": "M20 3h-9c-1.103 0-2 .897-2 2v4h2V5h9v14h-9v-4H9v4c0 1.103.897 2 2 2h9c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2z" } }] })(props);
894
877
  }
878
+ function BiLogOut(props) {
879
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M16 13v-2H7V8l-5 4 5 4v-3z" } }, { "tag": "path", "attr": { "d": "M20 3h-9c-1.103 0-2 .897-2 2v4h2V5h9v14h-9v-4H9v4c0 1.103.897 2 2 2h9c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2z" } }] })(props);
880
+ }
895
881
  function useGraphqlForms({
896
882
  query,
897
883
  variables,
@@ -1596,12 +1582,6 @@ function gql(strings, ...args) {
1596
1582
  });
1597
1583
  return str;
1598
1584
  }
1599
- function ImFilesEmpty(props) {
1600
- 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" } }, { "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" } }] })(props);
1601
- }
1602
- function VscOpenPreview(props) {
1603
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 16 16", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "clipRule": "evenodd", "d": "M3 1h11l1 1v5.3a3.21 3.21 0 0 0-1-.3V2H9v10.88L7.88 14H3l-1-1V2l1-1zm0 12h5V2H3v11zm10.379-4.998a2.53 2.53 0 0 0-1.19.348h-.03a2.51 2.51 0 0 0-.799 3.53L9 14.23l.71.71 2.35-2.36c.325.22.7.358 1.09.4a2.47 2.47 0 0 0 1.14-.13 2.51 2.51 0 0 0 1-.63 2.46 2.46 0 0 0 .58-1 2.63 2.63 0 0 0 .07-1.15 2.53 2.53 0 0 0-1.35-1.81 2.53 2.53 0 0 0-1.211-.258zm.24 3.992a1.5 1.5 0 0 1-.979-.244 1.55 1.55 0 0 1-.56-.68 1.49 1.49 0 0 1-.08-.86 1.49 1.49 0 0 1 1.18-1.18 1.49 1.49 0 0 1 .86.08c.276.117.512.311.68.56a1.5 1.5 0 0 1-1.1 2.324z" } }] })(props);
1604
- }
1605
1585
  const Layout = ({ children }) => {
1606
1586
  return /* @__PURE__ */ React.createElement("div", {
1607
1587
  style: {
@@ -1616,14 +1596,12 @@ const Layout = ({ children }) => {
1616
1596
  }
1617
1597
  }, children);
1618
1598
  };
1619
- const GetCMS = ({ children }) => {
1620
- try {
1621
- const cms = useCMS();
1622
- return /* @__PURE__ */ React.createElement(React.Fragment, null, children(cms));
1623
- } catch (e) {
1624
- return null;
1625
- }
1626
- };
1599
+ function ImFilesEmpty(props) {
1600
+ 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" } }, { "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" } }] })(props);
1601
+ }
1602
+ function VscOpenPreview(props) {
1603
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 16 16", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "clipRule": "evenodd", "d": "M3 1h11l1 1v5.3a3.21 3.21 0 0 0-1-.3V2H9v10.88L7.88 14H3l-1-1V2l1-1zm0 12h5V2H3v11zm10.379-4.998a2.53 2.53 0 0 0-1.19.348h-.03a2.51 2.51 0 0 0-.799 3.53L9 14.23l.71.71 2.35-2.36c.325.22.7.358 1.09.4a2.47 2.47 0 0 0 1.14-.13 2.51 2.51 0 0 0 1-.63 2.46 2.46 0 0 0 .58-1 2.63 2.63 0 0 0 .07-1.15 2.53 2.53 0 0 0-1.35-1.81 2.53 2.53 0 0 0-1.211-.258zm.24 3.992a1.5 1.5 0 0 1-.979-.244 1.55 1.55 0 0 1-.56-.68 1.49 1.49 0 0 1-.08-.86 1.49 1.49 0 0 1 1.18-1.18 1.49 1.49 0 0 1 .86.08c.276.117.512.311.68.56a1.5 1.5 0 0 1-1.1 2.324z" } }] })(props);
1604
+ }
1627
1605
  const useGetCollections = (cms) => {
1628
1606
  const [collections, setCollections] = useState([]);
1629
1607
  useEffect(() => {
@@ -1641,14 +1619,97 @@ const GetCollections = ({ cms, children }) => {
1641
1619
  return null;
1642
1620
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collections));
1643
1621
  };
1622
+ const Sidebar = ({ cms }) => {
1623
+ const { setEdit } = useEditState();
1624
+ const logout2 = () => setEdit(false);
1625
+ return /* @__PURE__ */ React.createElement(GetCollections, {
1626
+ cms
1627
+ }, (collections) => /* @__PURE__ */ React.createElement("div", {
1628
+ className: "flex flex-col w-80 lg:w-96 flex-shrink-0 bg-gradient-to-b from-white to-gray-50 border-r border-gray-200"
1629
+ }, /* @__PURE__ */ React.createElement("div", {
1630
+ className: "border-b border-gray-200"
1631
+ }, /* @__PURE__ */ React.createElement(Menu, {
1632
+ as: "div",
1633
+ className: "relative block"
1634
+ }, ({ open }) => /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Menu.Button, {
1635
+ className: `group w-full px-6 py-4 flex justify-between items-center transition-colors duration-150 ease-out ${open ? `bg-gray-50` : `bg-transparent`}`
1636
+ }, /* @__PURE__ */ React.createElement("span", {
1637
+ className: "text-left inline-flex items-center text-2xl tracking-wide text-gray-800 flex-1 gap-1 opacity-80 group-hover:opacity-100 transition-opacity duration-150 ease-out"
1638
+ }, /* @__PURE__ */ React.createElement("svg", {
1639
+ viewBox: "0 0 32 32",
1640
+ fill: "#EC4815",
1641
+ xmlns: "http://www.w3.org/2000/svg",
1642
+ className: "w-10 h-auto -ml-1"
1643
+ }, /* @__PURE__ */ React.createElement("path", {
1644
+ 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"
1645
+ }), /* @__PURE__ */ React.createElement("path", {
1646
+ 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"
1647
+ })), /* @__PURE__ */ React.createElement("span", null, "Tina Admin")), /* @__PURE__ */ React.createElement("svg", {
1648
+ width: "20",
1649
+ height: "20",
1650
+ viewBox: "0 0 20 20",
1651
+ fill: "none",
1652
+ xmlns: "http://www.w3.org/2000/svg",
1653
+ className: `flex-0 inline-block opacity-50 group-hover:opacity-80 transition-all duration-300 ease-in-out transform ${open ? `rotate-90 opacity-100` : `rotate-0`}`
1654
+ }, /* @__PURE__ */ React.createElement("g", {
1655
+ opacity: "0.3"
1656
+ }, /* @__PURE__ */ React.createElement("path", {
1657
+ d: "M7.91675 13.8086L9.16675 15.0586L14.2253 10L9.16675 4.9414L7.91675 6.1914L11.7253 10L7.91675 13.8086Z",
1658
+ fill: "currentColor"
1659
+ })))), /* @__PURE__ */ React.createElement("div", {
1660
+ className: "transform translate-y-full absolute bottom-3 right-5 w-2/3 z-50"
1661
+ }, /* @__PURE__ */ React.createElement(Transition, {
1662
+ enter: "transition duration-150 ease-out",
1663
+ enterFrom: "transform opacity-0 -translate-y-2",
1664
+ enterTo: "transform opacity-100 translate-y-0",
1665
+ leave: "transition duration-75 ease-in",
1666
+ leaveFrom: "transform opacity-100 translate-y-0",
1667
+ leaveTo: "transform opacity-0 -translate-y-2"
1668
+ }, /* @__PURE__ */ React.createElement(Menu.Items, {
1669
+ className: "w-full py-1 bg-white border border-gray-150 rounded-lg shadow-lg"
1670
+ }, /* @__PURE__ */ React.createElement(Menu.Item, null, ({ active }) => /* @__PURE__ */ React.createElement("a", {
1671
+ className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
1672
+ href: "/"
1673
+ }, /* @__PURE__ */ React.createElement(VscOpenPreview, {
1674
+ className: "w-6 h-auto mr-1.5 text-blue-400"
1675
+ }), " ", "View Website")), /* @__PURE__ */ React.createElement(Menu.Item, null, ({ active }) => /* @__PURE__ */ React.createElement("button", {
1676
+ className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
1677
+ onClick: () => logout2()
1678
+ }, /* @__PURE__ */ React.createElement(BiExit, {
1679
+ className: "w-6 h-auto mr-1.5 text-blue-400"
1680
+ }), " ", "Log out")))))))), /* @__PURE__ */ React.createElement("div", {
1681
+ className: "px-6 py-7 flex-1"
1682
+ }, /* @__PURE__ */ React.createElement("h4", {
1683
+ className: "uppercase font-bold text-sm mb-3"
1684
+ }, "Collections"), /* @__PURE__ */ React.createElement("ul", {
1685
+ className: "flex flex-col gap-4"
1686
+ }, collections.map((collection) => {
1687
+ return /* @__PURE__ */ React.createElement("li", {
1688
+ key: `${collection.name}-link`
1689
+ }, /* @__PURE__ */ React.createElement(NavLink, {
1690
+ className: `text-lg tracking-wide hover:text-blue-600 flex items-center opacity-90 hover:opacity-100`,
1691
+ activeClassName: "text-blue-600",
1692
+ to: `/admin/collections/${collection.name}`
1693
+ }, /* @__PURE__ */ React.createElement(ImFilesEmpty, {
1694
+ className: "mr-2 h-6 opacity-80 w-auto"
1695
+ }), " ", collection.label));
1696
+ })))));
1697
+ };
1698
+ const GetCMS = ({ children }) => {
1699
+ try {
1700
+ const cms = useCMS();
1701
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children(cms));
1702
+ } catch (e) {
1703
+ return null;
1704
+ }
1705
+ };
1644
1706
  function MdOutlineArrowBack(props) {
1645
1707
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" } }, { "tag": "path", "attr": { "d": "M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" } }] })(props);
1646
1708
  }
1647
- const login = () => {
1648
- setEditing(true);
1649
- window.location.reload();
1650
- };
1651
- const LoginPage = () => {
1709
+ const AuthTemplate = ({
1710
+ message,
1711
+ children
1712
+ }) => {
1652
1713
  return /* @__PURE__ */ React.createElement("div", {
1653
1714
  className: "h-screen w-full bg-gradient-to-b from-blue-900 to-gray-900 flex items-center justify-center px-4 py-6"
1654
1715
  }, /* @__PURE__ */ React.createElement("div", {
@@ -1666,12 +1727,19 @@ const LoginPage = () => {
1666
1727
  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"
1667
1728
  }), /* @__PURE__ */ React.createElement("path", {
1668
1729
  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"
1669
- })), /* @__PURE__ */ React.createElement("span", null, "Tina Admin"))), /* @__PURE__ */ React.createElement("div", {
1730
+ })), /* @__PURE__ */ React.createElement("span", null, "Tina Admin"))), message && /* @__PURE__ */ React.createElement("div", {
1670
1731
  className: "px-5 py-4 "
1671
1732
  }, /* @__PURE__ */ React.createElement("p", {
1672
1733
  className: "text-base font-sans leading-normal"
1673
- }, "Please log in to Tina Cloud to access your admin dashboard.")), /* @__PURE__ */ React.createElement("div", {
1734
+ }, message)), /* @__PURE__ */ React.createElement("div", {
1674
1735
  className: "px-5 py-4 flex gap-4 w-full justify-between"
1736
+ }, children)));
1737
+ };
1738
+ const LoginPage = () => {
1739
+ const { setEdit } = useEditState();
1740
+ const login = () => setEdit(true);
1741
+ return /* @__PURE__ */ React.createElement(AuthTemplate, {
1742
+ message: "Please log in to Tina Cloud to access your content."
1675
1743
  }, /* @__PURE__ */ React.createElement("a", {
1676
1744
  href: "/",
1677
1745
  className: "flex-1 text-center inline-flex justify-center items-center px-8 py-3 shadow-sm text-sm leading-4 font-medium rounded-full text-gray-600 border border-gray-150 hover:opacity-80 hover:bg-gray-50 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out"
@@ -1684,7 +1752,26 @@ const LoginPage = () => {
1684
1752
  style: { background: "#0084FF" }
1685
1753
  }, /* @__PURE__ */ React.createElement(BiLogIn, {
1686
1754
  className: "w-6 h-auto mr-1.5 opacity-80"
1687
- }), " Log in"))));
1755
+ }), " Log in"));
1756
+ };
1757
+ const logout = () => {
1758
+ setEditing(false);
1759
+ window.location.href = "/";
1760
+ };
1761
+ const LogoutPage = () => {
1762
+ return /* @__PURE__ */ React.createElement(AuthTemplate, null, /* @__PURE__ */ React.createElement("a", {
1763
+ href: "/",
1764
+ className: "flex-1 text-center inline-flex justify-center items-center px-8 py-3 shadow-sm text-sm leading-4 font-medium rounded-full text-gray-600 border border-gray-150 hover:opacity-80 hover:bg-gray-50 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out"
1765
+ }, /* @__PURE__ */ React.createElement(MdOutlineArrowBack, {
1766
+ className: "w-6 h-auto mr-1.5 opacity-80"
1767
+ }), " Back to site"), /* @__PURE__ */ React.createElement("button", {
1768
+ type: "submit",
1769
+ onClick: () => logout(),
1770
+ className: "flex-1 justify-center text-center inline-flex items-center px-8 py-3 shadow-sm border border-transparent text-sm leading-4 font-medium rounded-full text-white hover:opacity-80 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out",
1771
+ style: { background: "#0084FF" }
1772
+ }, /* @__PURE__ */ React.createElement(BiLogOut, {
1773
+ className: "w-6 h-auto mr-1.5 opacity-80"
1774
+ }), " Log out"));
1688
1775
  };
1689
1776
  const DashboardPage = () => {
1690
1777
  return /* @__PURE__ */ React.createElement("div", {
@@ -2052,8 +2139,8 @@ const CollectionUpdatePage = () => {
2052
2139
  };
2053
2140
  const useEmbedTailwind = () => {
2054
2141
  useEffect(() => {
2055
- const isSSR2 = typeof window === "undefined";
2056
- if (!isSSR2) {
2142
+ const isSSR = typeof window === "undefined";
2143
+ if (!isSSR) {
2057
2144
  const head = document.head;
2058
2145
  const link = document.createElement("link");
2059
2146
  link.id = "tina-admin-stylesheet";
@@ -2064,106 +2151,46 @@ const useEmbedTailwind = () => {
2064
2151
  }
2065
2152
  }, []);
2066
2153
  };
2067
- const logout = () => {
2068
- setEditing(false);
2069
- window.location.reload();
2070
- };
2071
2154
  const TinaAdmin = () => {
2072
2155
  useEmbedTailwind();
2073
- const isSSR2 = typeof window === "undefined";
2074
- if (isSSR2) {
2156
+ const isSSR = typeof window === "undefined";
2157
+ if (isSSR) {
2075
2158
  return null;
2076
2159
  }
2077
- const isEdit = isEditing();
2078
- if (!isEdit) {
2160
+ const { edit } = useEditState();
2161
+ if (!edit) {
2079
2162
  return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(LoginPage, null));
2080
2163
  }
2081
- return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(GetCollections, {
2082
- cms
2083
- }, (collections) => /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(BrowserRouter, null, /* @__PURE__ */ React.createElement("div", {
2084
- className: "flex items-stretch h-screen overflow-hidden"
2085
- }, /* @__PURE__ */ React.createElement("div", {
2086
- className: "flex flex-col w-80 lg:w-96 flex-shrink-0 bg-gradient-to-b from-white to-gray-50 border-r border-gray-200"
2087
- }, /* @__PURE__ */ React.createElement("div", {
2088
- className: "border-b border-gray-200"
2089
- }, /* @__PURE__ */ React.createElement(Menu, {
2090
- as: "div",
2091
- className: "relative block"
2092
- }, ({ open }) => /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Menu.Button, {
2093
- className: `group w-full px-6 py-4 flex justify-between items-center transition-colors duration-150 ease-out ${open ? `bg-gray-50` : `bg-transparent`}`
2094
- }, /* @__PURE__ */ React.createElement("span", {
2095
- className: "text-left inline-flex items-center text-2xl tracking-wide text-gray-800 flex-1 gap-1 opacity-80 group-hover:opacity-100 transition-opacity duration-150 ease-out"
2096
- }, /* @__PURE__ */ React.createElement("svg", {
2097
- viewBox: "0 0 32 32",
2098
- fill: "#EC4815",
2099
- xmlns: "http://www.w3.org/2000/svg",
2100
- className: "w-10 h-auto -ml-1"
2101
- }, /* @__PURE__ */ React.createElement("path", {
2102
- 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"
2103
- }), /* @__PURE__ */ React.createElement("path", {
2104
- 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"
2105
- })), /* @__PURE__ */ React.createElement("span", null, "Tina Admin")), /* @__PURE__ */ React.createElement("svg", {
2106
- width: "20",
2107
- height: "20",
2108
- viewBox: "0 0 20 20",
2109
- fill: "none",
2110
- xmlns: "http://www.w3.org/2000/svg",
2111
- className: `flex-0 inline-block opacity-50 group-hover:opacity-80 transition-all duration-300 ease-in-out transform ${open ? `rotate-90 opacity-100` : `rotate-0`}`
2112
- }, /* @__PURE__ */ React.createElement("g", {
2113
- opacity: "0.3"
2114
- }, /* @__PURE__ */ React.createElement("path", {
2115
- d: "M7.91675 13.8086L9.16675 15.0586L14.2253 10L9.16675 4.9414L7.91675 6.1914L11.7253 10L7.91675 13.8086Z",
2116
- fill: "currentColor"
2117
- })))), /* @__PURE__ */ React.createElement("div", {
2118
- className: "transform translate-y-full absolute bottom-3 right-5 w-2/3 z-50"
2119
- }, /* @__PURE__ */ React.createElement(Transition, {
2120
- enter: "transition duration-150 ease-out",
2121
- enterFrom: "transform opacity-0 -translate-y-2",
2122
- enterTo: "transform opacity-100 translate-y-0",
2123
- leave: "transition duration-75 ease-in",
2124
- leaveFrom: "transform opacity-100 translate-y-0",
2125
- leaveTo: "transform opacity-0 -translate-y-2"
2126
- }, /* @__PURE__ */ React.createElement(Menu.Items, {
2127
- className: "w-full py-1 bg-white border border-gray-150 rounded-lg shadow-lg"
2128
- }, /* @__PURE__ */ React.createElement(Menu.Item, null, ({ active }) => /* @__PURE__ */ React.createElement("a", {
2129
- className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
2130
- href: "/"
2131
- }, /* @__PURE__ */ React.createElement(VscOpenPreview, {
2132
- className: "w-6 h-auto mr-1.5 text-blue-400"
2133
- }), " ", "View Website")), /* @__PURE__ */ React.createElement(Menu.Item, null, ({ active }) => /* @__PURE__ */ React.createElement("button", {
2134
- className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
2135
- onClick: () => logout()
2136
- }, /* @__PURE__ */ React.createElement(BiExit, {
2137
- className: "w-6 h-auto mr-1.5 text-blue-400"
2138
- }), " ", "Log out")))))))), /* @__PURE__ */ React.createElement("div", {
2139
- className: "px-6 py-7 flex-1"
2140
- }, /* @__PURE__ */ React.createElement("h4", {
2141
- className: "uppercase font-bold text-sm mb-3"
2142
- }, "Collections"), /* @__PURE__ */ React.createElement("ul", {
2143
- className: "flex flex-col gap-4"
2144
- }, collections.map((collection) => {
2145
- return /* @__PURE__ */ React.createElement("li", {
2146
- key: `${collection.name}-link`
2147
- }, /* @__PURE__ */ React.createElement(NavLink, {
2148
- className: `text-lg tracking-wide hover:text-blue-600 flex items-center opacity-90 hover:opacity-100`,
2149
- activeClassName: "text-blue-600",
2150
- to: `/admin/collections/${collection.name}`
2151
- }, /* @__PURE__ */ React.createElement(ImFilesEmpty, {
2152
- className: "mr-2 h-6 opacity-80 w-auto"
2153
- }), " ", collection.label));
2154
- })))), /* @__PURE__ */ React.createElement("div", {
2155
- className: "flex-1"
2156
- }, /* @__PURE__ */ React.createElement(Switch, null, /* @__PURE__ */ React.createElement(Route, {
2157
- path: `/admin/collections/:collectionName/new`
2158
- }, /* @__PURE__ */ React.createElement(CollectionCreatePage, null)), /* @__PURE__ */ React.createElement(Route, {
2159
- path: `/admin/collections/:collectionName/:templateName/new`
2160
- }, /* @__PURE__ */ React.createElement(CollectionCreatePage, null)), /* @__PURE__ */ React.createElement(Route, {
2161
- path: `/admin/collections/:collectionName/:filename`
2162
- }, /* @__PURE__ */ React.createElement(CollectionUpdatePage, null)), /* @__PURE__ */ React.createElement(Route, {
2163
- path: `/admin/collections/:collectionName`
2164
- }, /* @__PURE__ */ React.createElement(CollectionListPage, null)), /* @__PURE__ */ React.createElement(Route, {
2165
- path: `/admin`
2166
- }, /* @__PURE__ */ React.createElement(DashboardPage, null)))))))));
2164
+ return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
2165
+ const isTinaAdminEnabled = cms.flags.get("tina-admin");
2166
+ if (isTinaAdminEnabled) {
2167
+ return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(BrowserRouter, null, /* @__PURE__ */ React.createElement("div", {
2168
+ className: "flex items-stretch h-screen overflow-hidden"
2169
+ }, /* @__PURE__ */ React.createElement(Sidebar, {
2170
+ cms
2171
+ }), /* @__PURE__ */ React.createElement("div", {
2172
+ className: "flex-1"
2173
+ }, /* @__PURE__ */ React.createElement(Switch, null, /* @__PURE__ */ React.createElement(Route, {
2174
+ path: `/admin/collections/:collectionName/new`
2175
+ }, /* @__PURE__ */ React.createElement(CollectionCreatePage, null)), /* @__PURE__ */ React.createElement(Route, {
2176
+ path: `/admin/collections/:collectionName/:templateName/new`
2177
+ }, /* @__PURE__ */ React.createElement(CollectionCreatePage, null)), /* @__PURE__ */ React.createElement(Route, {
2178
+ path: `/admin/collections/:collectionName/:filename`
2179
+ }, /* @__PURE__ */ React.createElement(CollectionUpdatePage, null)), /* @__PURE__ */ React.createElement(Route, {
2180
+ path: `/admin/collections/:collectionName`
2181
+ }, /* @__PURE__ */ React.createElement(CollectionListPage, null)), /* @__PURE__ */ React.createElement(Route, {
2182
+ path: `/admin`
2183
+ }, /* @__PURE__ */ React.createElement(DashboardPage, null)))))));
2184
+ } else {
2185
+ return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(BrowserRouter, null, /* @__PURE__ */ React.createElement(Switch, null, /* @__PURE__ */ React.createElement(Route, {
2186
+ path: [`/admin/logout`, `/admin/exit`, `/admin/exit-admin`]
2187
+ }, /* @__PURE__ */ React.createElement(LogoutPage, null)), /* @__PURE__ */ React.createElement(Route, {
2188
+ path: `/admin`
2189
+ }, () => {
2190
+ window.location.href = "/";
2191
+ }))));
2192
+ }
2193
+ });
2167
2194
  };
2168
2195
  class RouteMappingPlugin {
2169
2196
  constructor(mapper) {
package/dist/index.js CHANGED
@@ -30,8 +30,8 @@ var __objRest = (source, exclude) => {
30
30
  return target;
31
31
  };
32
32
  (function(global, factory) {
33
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("graphql"), require("lodash.set"), require("graphql-tag"), require("@tinacms/toolkit"), require("react"), require("styled-components"), require("yup"), require("final-form"), require("react-router-dom"), require("@headlessui/react")) : typeof define === "function" && define.amd ? define(["exports", "graphql", "lodash.set", "graphql-tag", "@tinacms/toolkit", "react", "styled-components", "yup", "final-form", "react-router-dom", "@headlessui/react"], 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));
34
- })(this, function(exports2, graphql, set, gql$1, toolkit, React, styled, yup, finalForm, reactRouterDom, react) {
33
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("graphql"), require("lodash.set"), require("graphql-tag"), require("@tinacms/toolkit"), require("react"), require("styled-components"), require("yup"), require("@tinacms/sharedctx"), require("final-form"), require("react-router-dom"), require("@headlessui/react")) : typeof define === "function" && define.amd ? define(["exports", "graphql", "lodash.set", "graphql-tag", "@tinacms/toolkit", "react", "styled-components", "yup", "@tinacms/sharedctx", "final-form", "react-router-dom", "@headlessui/react"], 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));
34
+ })(this, function(exports2, graphql, set, gql$1, toolkit, React, styled, yup, sharedctx, finalForm, reactRouterDom, react) {
35
35
  "use strict";
36
36
  function _interopDefaultLegacy(e) {
37
37
  return e && typeof e === "object" && "default" in e ? e : { "default": e };
@@ -673,24 +673,6 @@ mutation addPendingDocumentMutation(
673
673
  return false;
674
674
  }
675
675
  }
676
- const LOCALSTORAGEKEY = "tina.isEditing";
677
- const isSSR = typeof window === "undefined";
678
- const isEditing = () => {
679
- if (!isSSR) {
680
- const isEdit = window.localStorage.getItem(LOCALSTORAGEKEY);
681
- return isEdit && isEdit === "true";
682
- }
683
- return false;
684
- };
685
- const setEditing = (isEditing2) => {
686
- if (!isSSR) {
687
- window.localStorage.setItem(LOCALSTORAGEKEY, isEditing2 ? "true" : "false");
688
- }
689
- };
690
- React__default["default"].createContext({
691
- edit: isEditing(),
692
- setEdit: void 0
693
- });
694
676
  function sleep(ms) {
695
677
  return new Promise((resolve) => setTimeout(resolve, ms));
696
678
  }
@@ -736,7 +718,7 @@ mutation addPendingDocumentMutation(
736
718
  ...otherModalActions,
737
719
  {
738
720
  action: async () => {
739
- setEditing(false);
721
+ sharedctx.setEditing(false);
740
722
  window.location.reload();
741
723
  },
742
724
  name: "Close",
@@ -913,6 +895,9 @@ mutation addPendingDocumentMutation(
913
895
  function BiLogIn(props) {
914
896
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "m13 16 5-4-5-4v3H4v2h9z" } }, { "tag": "path", "attr": { "d": "M20 3h-9c-1.103 0-2 .897-2 2v4h2V5h9v14h-9v-4H9v4c0 1.103.897 2 2 2h9c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2z" } }] })(props);
915
897
  }
898
+ function BiLogOut(props) {
899
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M16 13v-2H7V8l-5 4 5 4v-3z" } }, { "tag": "path", "attr": { "d": "M20 3h-9c-1.103 0-2 .897-2 2v4h2V5h9v14h-9v-4H9v4c0 1.103.897 2 2 2h9c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2z" } }] })(props);
900
+ }
916
901
  function useGraphqlForms({
917
902
  query,
918
903
  variables,
@@ -1617,12 +1602,6 @@ This will work when developing locally but NOT when deployed to production.
1617
1602
  });
1618
1603
  return str;
1619
1604
  }
1620
- function ImFilesEmpty(props) {
1621
- 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" } }, { "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" } }] })(props);
1622
- }
1623
- function VscOpenPreview(props) {
1624
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 16 16", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "clipRule": "evenodd", "d": "M3 1h11l1 1v5.3a3.21 3.21 0 0 0-1-.3V2H9v10.88L7.88 14H3l-1-1V2l1-1zm0 12h5V2H3v11zm10.379-4.998a2.53 2.53 0 0 0-1.19.348h-.03a2.51 2.51 0 0 0-.799 3.53L9 14.23l.71.71 2.35-2.36c.325.22.7.358 1.09.4a2.47 2.47 0 0 0 1.14-.13 2.51 2.51 0 0 0 1-.63 2.46 2.46 0 0 0 .58-1 2.63 2.63 0 0 0 .07-1.15 2.53 2.53 0 0 0-1.35-1.81 2.53 2.53 0 0 0-1.211-.258zm.24 3.992a1.5 1.5 0 0 1-.979-.244 1.55 1.55 0 0 1-.56-.68 1.49 1.49 0 0 1-.08-.86 1.49 1.49 0 0 1 1.18-1.18 1.49 1.49 0 0 1 .86.08c.276.117.512.311.68.56a1.5 1.5 0 0 1-1.1 2.324z" } }] })(props);
1625
- }
1626
1605
  const Layout = ({ children }) => {
1627
1606
  return /* @__PURE__ */ React__default["default"].createElement("div", {
1628
1607
  style: {
@@ -1637,14 +1616,12 @@ This will work when developing locally but NOT when deployed to production.
1637
1616
  }
1638
1617
  }, children);
1639
1618
  };
1640
- const GetCMS = ({ children }) => {
1641
- try {
1642
- const cms = toolkit.useCMS();
1643
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(cms));
1644
- } catch (e) {
1645
- return null;
1646
- }
1647
- };
1619
+ function ImFilesEmpty(props) {
1620
+ 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" } }, { "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" } }] })(props);
1621
+ }
1622
+ function VscOpenPreview(props) {
1623
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 16 16", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "clipRule": "evenodd", "d": "M3 1h11l1 1v5.3a3.21 3.21 0 0 0-1-.3V2H9v10.88L7.88 14H3l-1-1V2l1-1zm0 12h5V2H3v11zm10.379-4.998a2.53 2.53 0 0 0-1.19.348h-.03a2.51 2.51 0 0 0-.799 3.53L9 14.23l.71.71 2.35-2.36c.325.22.7.358 1.09.4a2.47 2.47 0 0 0 1.14-.13 2.51 2.51 0 0 0 1-.63 2.46 2.46 0 0 0 .58-1 2.63 2.63 0 0 0 .07-1.15 2.53 2.53 0 0 0-1.35-1.81 2.53 2.53 0 0 0-1.211-.258zm.24 3.992a1.5 1.5 0 0 1-.979-.244 1.55 1.55 0 0 1-.56-.68 1.49 1.49 0 0 1-.08-.86 1.49 1.49 0 0 1 1.18-1.18 1.49 1.49 0 0 1 .86.08c.276.117.512.311.68.56a1.5 1.5 0 0 1-1.1 2.324z" } }] })(props);
1624
+ }
1648
1625
  const useGetCollections = (cms) => {
1649
1626
  const [collections, setCollections] = React.useState([]);
1650
1627
  React.useEffect(() => {
@@ -1662,14 +1639,97 @@ This will work when developing locally but NOT when deployed to production.
1662
1639
  return null;
1663
1640
  return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collections));
1664
1641
  };
1642
+ const Sidebar = ({ cms }) => {
1643
+ const { setEdit } = sharedctx.useEditState();
1644
+ const logout2 = () => setEdit(false);
1645
+ return /* @__PURE__ */ React__default["default"].createElement(GetCollections, {
1646
+ cms
1647
+ }, (collections) => /* @__PURE__ */ React__default["default"].createElement("div", {
1648
+ className: "flex flex-col w-80 lg:w-96 flex-shrink-0 bg-gradient-to-b from-white to-gray-50 border-r border-gray-200"
1649
+ }, /* @__PURE__ */ React__default["default"].createElement("div", {
1650
+ className: "border-b border-gray-200"
1651
+ }, /* @__PURE__ */ React__default["default"].createElement(react.Menu, {
1652
+ as: "div",
1653
+ className: "relative block"
1654
+ }, ({ open }) => /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Button, {
1655
+ className: `group w-full px-6 py-4 flex justify-between items-center transition-colors duration-150 ease-out ${open ? `bg-gray-50` : `bg-transparent`}`
1656
+ }, /* @__PURE__ */ React__default["default"].createElement("span", {
1657
+ className: "text-left inline-flex items-center text-2xl tracking-wide text-gray-800 flex-1 gap-1 opacity-80 group-hover:opacity-100 transition-opacity duration-150 ease-out"
1658
+ }, /* @__PURE__ */ React__default["default"].createElement("svg", {
1659
+ viewBox: "0 0 32 32",
1660
+ fill: "#EC4815",
1661
+ xmlns: "http://www.w3.org/2000/svg",
1662
+ className: "w-10 h-auto -ml-1"
1663
+ }, /* @__PURE__ */ React__default["default"].createElement("path", {
1664
+ 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"
1665
+ }), /* @__PURE__ */ React__default["default"].createElement("path", {
1666
+ 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"
1667
+ })), /* @__PURE__ */ React__default["default"].createElement("span", null, "Tina Admin")), /* @__PURE__ */ React__default["default"].createElement("svg", {
1668
+ width: "20",
1669
+ height: "20",
1670
+ viewBox: "0 0 20 20",
1671
+ fill: "none",
1672
+ xmlns: "http://www.w3.org/2000/svg",
1673
+ className: `flex-0 inline-block opacity-50 group-hover:opacity-80 transition-all duration-300 ease-in-out transform ${open ? `rotate-90 opacity-100` : `rotate-0`}`
1674
+ }, /* @__PURE__ */ React__default["default"].createElement("g", {
1675
+ opacity: "0.3"
1676
+ }, /* @__PURE__ */ React__default["default"].createElement("path", {
1677
+ d: "M7.91675 13.8086L9.16675 15.0586L14.2253 10L9.16675 4.9414L7.91675 6.1914L11.7253 10L7.91675 13.8086Z",
1678
+ fill: "currentColor"
1679
+ })))), /* @__PURE__ */ React__default["default"].createElement("div", {
1680
+ className: "transform translate-y-full absolute bottom-3 right-5 w-2/3 z-50"
1681
+ }, /* @__PURE__ */ React__default["default"].createElement(react.Transition, {
1682
+ enter: "transition duration-150 ease-out",
1683
+ enterFrom: "transform opacity-0 -translate-y-2",
1684
+ enterTo: "transform opacity-100 translate-y-0",
1685
+ leave: "transition duration-75 ease-in",
1686
+ leaveFrom: "transform opacity-100 translate-y-0",
1687
+ leaveTo: "transform opacity-0 -translate-y-2"
1688
+ }, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Items, {
1689
+ className: "w-full py-1 bg-white border border-gray-150 rounded-lg shadow-lg"
1690
+ }, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Item, null, ({ active }) => /* @__PURE__ */ React__default["default"].createElement("a", {
1691
+ className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
1692
+ href: "/"
1693
+ }, /* @__PURE__ */ React__default["default"].createElement(VscOpenPreview, {
1694
+ className: "w-6 h-auto mr-1.5 text-blue-400"
1695
+ }), " ", "View Website")), /* @__PURE__ */ React__default["default"].createElement(react.Menu.Item, null, ({ active }) => /* @__PURE__ */ React__default["default"].createElement("button", {
1696
+ className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
1697
+ onClick: () => logout2()
1698
+ }, /* @__PURE__ */ React__default["default"].createElement(BiExit, {
1699
+ className: "w-6 h-auto mr-1.5 text-blue-400"
1700
+ }), " ", "Log out")))))))), /* @__PURE__ */ React__default["default"].createElement("div", {
1701
+ className: "px-6 py-7 flex-1"
1702
+ }, /* @__PURE__ */ React__default["default"].createElement("h4", {
1703
+ className: "uppercase font-bold text-sm mb-3"
1704
+ }, "Collections"), /* @__PURE__ */ React__default["default"].createElement("ul", {
1705
+ className: "flex flex-col gap-4"
1706
+ }, collections.map((collection) => {
1707
+ return /* @__PURE__ */ React__default["default"].createElement("li", {
1708
+ key: `${collection.name}-link`
1709
+ }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.NavLink, {
1710
+ className: `text-lg tracking-wide hover:text-blue-600 flex items-center opacity-90 hover:opacity-100`,
1711
+ activeClassName: "text-blue-600",
1712
+ to: `/admin/collections/${collection.name}`
1713
+ }, /* @__PURE__ */ React__default["default"].createElement(ImFilesEmpty, {
1714
+ className: "mr-2 h-6 opacity-80 w-auto"
1715
+ }), " ", collection.label));
1716
+ })))));
1717
+ };
1718
+ const GetCMS = ({ children }) => {
1719
+ try {
1720
+ const cms = toolkit.useCMS();
1721
+ return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(cms));
1722
+ } catch (e) {
1723
+ return null;
1724
+ }
1725
+ };
1665
1726
  function MdOutlineArrowBack(props) {
1666
1727
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" } }, { "tag": "path", "attr": { "d": "M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" } }] })(props);
1667
1728
  }
1668
- const login = () => {
1669
- setEditing(true);
1670
- window.location.reload();
1671
- };
1672
- const LoginPage = () => {
1729
+ const AuthTemplate = ({
1730
+ message,
1731
+ children
1732
+ }) => {
1673
1733
  return /* @__PURE__ */ React__default["default"].createElement("div", {
1674
1734
  className: "h-screen w-full bg-gradient-to-b from-blue-900 to-gray-900 flex items-center justify-center px-4 py-6"
1675
1735
  }, /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -1687,12 +1747,19 @@ This will work when developing locally but NOT when deployed to production.
1687
1747
  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"
1688
1748
  }), /* @__PURE__ */ React__default["default"].createElement("path", {
1689
1749
  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"
1690
- })), /* @__PURE__ */ React__default["default"].createElement("span", null, "Tina Admin"))), /* @__PURE__ */ React__default["default"].createElement("div", {
1750
+ })), /* @__PURE__ */ React__default["default"].createElement("span", null, "Tina Admin"))), message && /* @__PURE__ */ React__default["default"].createElement("div", {
1691
1751
  className: "px-5 py-4 "
1692
1752
  }, /* @__PURE__ */ React__default["default"].createElement("p", {
1693
1753
  className: "text-base font-sans leading-normal"
1694
- }, "Please log in to Tina Cloud to access your admin dashboard.")), /* @__PURE__ */ React__default["default"].createElement("div", {
1754
+ }, message)), /* @__PURE__ */ React__default["default"].createElement("div", {
1695
1755
  className: "px-5 py-4 flex gap-4 w-full justify-between"
1756
+ }, children)));
1757
+ };
1758
+ const LoginPage = () => {
1759
+ const { setEdit } = sharedctx.useEditState();
1760
+ const login = () => setEdit(true);
1761
+ return /* @__PURE__ */ React__default["default"].createElement(AuthTemplate, {
1762
+ message: "Please log in to Tina Cloud to access your content."
1696
1763
  }, /* @__PURE__ */ React__default["default"].createElement("a", {
1697
1764
  href: "/",
1698
1765
  className: "flex-1 text-center inline-flex justify-center items-center px-8 py-3 shadow-sm text-sm leading-4 font-medium rounded-full text-gray-600 border border-gray-150 hover:opacity-80 hover:bg-gray-50 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out"
@@ -1705,7 +1772,26 @@ This will work when developing locally but NOT when deployed to production.
1705
1772
  style: { background: "#0084FF" }
1706
1773
  }, /* @__PURE__ */ React__default["default"].createElement(BiLogIn, {
1707
1774
  className: "w-6 h-auto mr-1.5 opacity-80"
1708
- }), " Log in"))));
1775
+ }), " Log in"));
1776
+ };
1777
+ const logout = () => {
1778
+ sharedctx.setEditing(false);
1779
+ window.location.href = "/";
1780
+ };
1781
+ const LogoutPage = () => {
1782
+ return /* @__PURE__ */ React__default["default"].createElement(AuthTemplate, null, /* @__PURE__ */ React__default["default"].createElement("a", {
1783
+ href: "/",
1784
+ className: "flex-1 text-center inline-flex justify-center items-center px-8 py-3 shadow-sm text-sm leading-4 font-medium rounded-full text-gray-600 border border-gray-150 hover:opacity-80 hover:bg-gray-50 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out"
1785
+ }, /* @__PURE__ */ React__default["default"].createElement(MdOutlineArrowBack, {
1786
+ className: "w-6 h-auto mr-1.5 opacity-80"
1787
+ }), " Back to site"), /* @__PURE__ */ React__default["default"].createElement("button", {
1788
+ type: "submit",
1789
+ onClick: () => logout(),
1790
+ className: "flex-1 justify-center text-center inline-flex items-center px-8 py-3 shadow-sm border border-transparent text-sm leading-4 font-medium rounded-full text-white hover:opacity-80 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out",
1791
+ style: { background: "#0084FF" }
1792
+ }, /* @__PURE__ */ React__default["default"].createElement(BiLogOut, {
1793
+ className: "w-6 h-auto mr-1.5 opacity-80"
1794
+ }), " Log out"));
1709
1795
  };
1710
1796
  const DashboardPage = () => {
1711
1797
  return /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -2073,8 +2159,8 @@ This will work when developing locally but NOT when deployed to production.
2073
2159
  };
2074
2160
  const useEmbedTailwind = () => {
2075
2161
  React.useEffect(() => {
2076
- const isSSR2 = typeof window === "undefined";
2077
- if (!isSSR2) {
2162
+ const isSSR = typeof window === "undefined";
2163
+ if (!isSSR) {
2078
2164
  const head = document.head;
2079
2165
  const link = document.createElement("link");
2080
2166
  link.id = "tina-admin-stylesheet";
@@ -2085,106 +2171,46 @@ This will work when developing locally but NOT when deployed to production.
2085
2171
  }
2086
2172
  }, []);
2087
2173
  };
2088
- const logout = () => {
2089
- setEditing(false);
2090
- window.location.reload();
2091
- };
2092
2174
  const TinaAdmin = () => {
2093
2175
  useEmbedTailwind();
2094
- const isSSR2 = typeof window === "undefined";
2095
- if (isSSR2) {
2176
+ const isSSR = typeof window === "undefined";
2177
+ if (isSSR) {
2096
2178
  return null;
2097
2179
  }
2098
- const isEdit = isEditing();
2099
- if (!isEdit) {
2180
+ const { edit } = sharedctx.useEditState();
2181
+ if (!edit) {
2100
2182
  return /* @__PURE__ */ React__default["default"].createElement(Layout, null, /* @__PURE__ */ React__default["default"].createElement(LoginPage, null));
2101
2183
  }
2102
- return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetCollections, {
2103
- cms
2104
- }, (collections) => /* @__PURE__ */ React__default["default"].createElement(Layout, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.BrowserRouter, null, /* @__PURE__ */ React__default["default"].createElement("div", {
2105
- className: "flex items-stretch h-screen overflow-hidden"
2106
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
2107
- className: "flex flex-col w-80 lg:w-96 flex-shrink-0 bg-gradient-to-b from-white to-gray-50 border-r border-gray-200"
2108
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
2109
- className: "border-b border-gray-200"
2110
- }, /* @__PURE__ */ React__default["default"].createElement(react.Menu, {
2111
- as: "div",
2112
- className: "relative block"
2113
- }, ({ open }) => /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Button, {
2114
- className: `group w-full px-6 py-4 flex justify-between items-center transition-colors duration-150 ease-out ${open ? `bg-gray-50` : `bg-transparent`}`
2115
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
2116
- className: "text-left inline-flex items-center text-2xl tracking-wide text-gray-800 flex-1 gap-1 opacity-80 group-hover:opacity-100 transition-opacity duration-150 ease-out"
2117
- }, /* @__PURE__ */ React__default["default"].createElement("svg", {
2118
- viewBox: "0 0 32 32",
2119
- fill: "#EC4815",
2120
- xmlns: "http://www.w3.org/2000/svg",
2121
- className: "w-10 h-auto -ml-1"
2122
- }, /* @__PURE__ */ React__default["default"].createElement("path", {
2123
- 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"
2124
- }), /* @__PURE__ */ React__default["default"].createElement("path", {
2125
- 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"
2126
- })), /* @__PURE__ */ React__default["default"].createElement("span", null, "Tina Admin")), /* @__PURE__ */ React__default["default"].createElement("svg", {
2127
- width: "20",
2128
- height: "20",
2129
- viewBox: "0 0 20 20",
2130
- fill: "none",
2131
- xmlns: "http://www.w3.org/2000/svg",
2132
- className: `flex-0 inline-block opacity-50 group-hover:opacity-80 transition-all duration-300 ease-in-out transform ${open ? `rotate-90 opacity-100` : `rotate-0`}`
2133
- }, /* @__PURE__ */ React__default["default"].createElement("g", {
2134
- opacity: "0.3"
2135
- }, /* @__PURE__ */ React__default["default"].createElement("path", {
2136
- d: "M7.91675 13.8086L9.16675 15.0586L14.2253 10L9.16675 4.9414L7.91675 6.1914L11.7253 10L7.91675 13.8086Z",
2137
- fill: "currentColor"
2138
- })))), /* @__PURE__ */ React__default["default"].createElement("div", {
2139
- className: "transform translate-y-full absolute bottom-3 right-5 w-2/3 z-50"
2140
- }, /* @__PURE__ */ React__default["default"].createElement(react.Transition, {
2141
- enter: "transition duration-150 ease-out",
2142
- enterFrom: "transform opacity-0 -translate-y-2",
2143
- enterTo: "transform opacity-100 translate-y-0",
2144
- leave: "transition duration-75 ease-in",
2145
- leaveFrom: "transform opacity-100 translate-y-0",
2146
- leaveTo: "transform opacity-0 -translate-y-2"
2147
- }, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Items, {
2148
- className: "w-full py-1 bg-white border border-gray-150 rounded-lg shadow-lg"
2149
- }, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Item, null, ({ active }) => /* @__PURE__ */ React__default["default"].createElement("a", {
2150
- className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
2151
- href: "/"
2152
- }, /* @__PURE__ */ React__default["default"].createElement(VscOpenPreview, {
2153
- className: "w-6 h-auto mr-1.5 text-blue-400"
2154
- }), " ", "View Website")), /* @__PURE__ */ React__default["default"].createElement(react.Menu.Item, null, ({ active }) => /* @__PURE__ */ React__default["default"].createElement("button", {
2155
- className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
2156
- onClick: () => logout()
2157
- }, /* @__PURE__ */ React__default["default"].createElement(BiExit, {
2158
- className: "w-6 h-auto mr-1.5 text-blue-400"
2159
- }), " ", "Log out")))))))), /* @__PURE__ */ React__default["default"].createElement("div", {
2160
- className: "px-6 py-7 flex-1"
2161
- }, /* @__PURE__ */ React__default["default"].createElement("h4", {
2162
- className: "uppercase font-bold text-sm mb-3"
2163
- }, "Collections"), /* @__PURE__ */ React__default["default"].createElement("ul", {
2164
- className: "flex flex-col gap-4"
2165
- }, collections.map((collection) => {
2166
- return /* @__PURE__ */ React__default["default"].createElement("li", {
2167
- key: `${collection.name}-link`
2168
- }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.NavLink, {
2169
- className: `text-lg tracking-wide hover:text-blue-600 flex items-center opacity-90 hover:opacity-100`,
2170
- activeClassName: "text-blue-600",
2171
- to: `/admin/collections/${collection.name}`
2172
- }, /* @__PURE__ */ React__default["default"].createElement(ImFilesEmpty, {
2173
- className: "mr-2 h-6 opacity-80 w-auto"
2174
- }), " ", collection.label));
2175
- })))), /* @__PURE__ */ React__default["default"].createElement("div", {
2176
- className: "flex-1"
2177
- }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Switch, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
2178
- path: `/admin/collections/:collectionName/new`
2179
- }, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
2180
- path: `/admin/collections/:collectionName/:templateName/new`
2181
- }, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
2182
- path: `/admin/collections/:collectionName/:filename`
2183
- }, /* @__PURE__ */ React__default["default"].createElement(CollectionUpdatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
2184
- path: `/admin/collections/:collectionName`
2185
- }, /* @__PURE__ */ React__default["default"].createElement(CollectionListPage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
2186
- path: `/admin`
2187
- }, /* @__PURE__ */ React__default["default"].createElement(DashboardPage, null)))))))));
2184
+ return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => {
2185
+ const isTinaAdminEnabled = cms.flags.get("tina-admin");
2186
+ if (isTinaAdminEnabled) {
2187
+ return /* @__PURE__ */ React__default["default"].createElement(Layout, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.BrowserRouter, null, /* @__PURE__ */ React__default["default"].createElement("div", {
2188
+ className: "flex items-stretch h-screen overflow-hidden"
2189
+ }, /* @__PURE__ */ React__default["default"].createElement(Sidebar, {
2190
+ cms
2191
+ }), /* @__PURE__ */ React__default["default"].createElement("div", {
2192
+ className: "flex-1"
2193
+ }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Switch, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
2194
+ path: `/admin/collections/:collectionName/new`
2195
+ }, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
2196
+ path: `/admin/collections/:collectionName/:templateName/new`
2197
+ }, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
2198
+ path: `/admin/collections/:collectionName/:filename`
2199
+ }, /* @__PURE__ */ React__default["default"].createElement(CollectionUpdatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
2200
+ path: `/admin/collections/:collectionName`
2201
+ }, /* @__PURE__ */ React__default["default"].createElement(CollectionListPage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
2202
+ path: `/admin`
2203
+ }, /* @__PURE__ */ React__default["default"].createElement(DashboardPage, null)))))));
2204
+ } else {
2205
+ return /* @__PURE__ */ React__default["default"].createElement(Layout, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.BrowserRouter, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Switch, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
2206
+ path: [`/admin/logout`, `/admin/exit`, `/admin/exit-admin`]
2207
+ }, /* @__PURE__ */ React__default["default"].createElement(LogoutPage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
2208
+ path: `/admin`
2209
+ }, () => {
2210
+ window.location.href = "/";
2211
+ }))));
2212
+ }
2213
+ });
2188
2214
  };
2189
2215
  class RouteMappingPlugin {
2190
2216
  constructor(mapper) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "0.59.0",
3
+ "version": "0.59.1",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist"
@@ -19,31 +19,17 @@
19
19
  "build": "echo \"Run `yarn build` from the root of the repository instead\""
20
20
  },
21
21
  "dependencies": {
22
- "@graphql-codegen/core": "^1.15.4",
23
- "@graphql-codegen/typescript": "^1.15.4",
24
- "@graphql-codegen/typescript-operations": "^1.15.4",
25
22
  "@headlessui/react": "^1.4.1",
26
23
  "@heroicons/react": "^1.0.4",
27
- "@tinacms/toolkit": "0.56.0",
28
- "@xstate/react": "^1.1.0",
29
- "codemirror": "^5.55.0",
30
- "cors": "^2.8.5",
24
+ "@tinacms/sharedctx": "0.0.1",
25
+ "@tinacms/toolkit": "0.56.1",
31
26
  "crypto-js": "^4.0.0",
32
27
  "final-form": "4.20.1",
33
- "final-form-arrays": "^3.0.2",
34
28
  "graphql": "^15.1.0",
35
29
  "graphql-tag": "^2.11.0",
36
- "isomorphic-unfetch": "^3.0.0",
37
- "lodash.get": "^4.4.2",
38
- "lodash.has": "^4.5.2",
39
- "lodash.merge": "^4.6.2",
40
30
  "lodash.set": "^4.3.2",
41
- "next": "9.4.2",
42
- "node-fetch": "^2.6.0",
43
- "prop-types": "15.7.2",
44
31
  "react-icons": "^4.3.1",
45
32
  "react-router-dom": "^5.3.0",
46
- "xstate": "^4.15.1",
47
33
  "yup": "^0.32.0"
48
34
  },
49
35
  "devDependencies": {