tinacms 1.5.12 → 1.5.14

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.
@@ -1,14 +1,12 @@
1
1
  import { useEditState as useEditState$1, EditProvider, TinaDataContext } from "@tinacms/sharedctx";
2
- export { isEditing, setEditing } from "@tinacms/sharedctx";
2
+ import { isEditing, setEditing } from "@tinacms/sharedctx";
3
3
  import React, { useState, useEffect } from "react";
4
4
  const useEditState = useEditState$1;
5
5
  const TinaEditProvider = ({
6
6
  showEditButton,
7
7
  ...props
8
8
  }) => {
9
- return /* @__PURE__ */ React.createElement(EditProvider, null, showEditButton && /* @__PURE__ */ React.createElement(ToggleButton, null), /* @__PURE__ */ React.createElement(TinaEditProviderInner, {
10
- ...props
11
- }));
9
+ return /* @__PURE__ */ React.createElement(EditProvider, null, showEditButton && /* @__PURE__ */ React.createElement(ToggleButton, null), /* @__PURE__ */ React.createElement(TinaEditProviderInner, { ...props }));
12
10
  };
13
11
  function useTina({
14
12
  query,
@@ -28,7 +26,9 @@ function useTina({
28
26
  isDummyContainer,
29
27
  isLoading: contextLoading
30
28
  } = React.useContext(TinaDataContext);
31
- const [waitForContextRerender, setWaitForContextRerender] = useState(!isDummyContainer);
29
+ const [waitForContextRerender, setWaitForContextRerender] = useState(
30
+ !isDummyContainer
31
+ );
32
32
  const isLoading = contextLoading || waitForContextRerender;
33
33
  React.useEffect(() => {
34
34
  setRequest({ query, variables });
@@ -57,23 +57,31 @@ const ToggleButton = () => {
57
57
  }
58
58
  }
59
59
  }, [setIsOnAdmin]);
60
- return edit || isOnAdmin ? null : /* @__PURE__ */ React.createElement("div", {
61
- style: { position: "fixed", bottom: "56px", left: "0px", zIndex: 200 }
62
- }, /* @__PURE__ */ React.createElement("a", {
63
- href: "/admin",
64
- style: {
65
- borderRadius: "0 50px 50px 0",
66
- fontSize: "16px",
67
- fontFamily: "Inter, 'Helvetica Neue', 'Arial Nova', Helvetica, Arial, sans-serif",
68
- fontWeight: "bold",
69
- textDecoration: "none",
70
- background: "rgb(34, 150, 254)",
71
- boxShadow: "0px 1px 3px rgb(0 0 0 / 10%), 0px 2px 6px rgb(0 0 0 / 20%)",
72
- color: "white",
73
- padding: "14px 20px",
74
- border: "none"
75
- }
76
- }, "Edit with Tina"));
60
+ return edit || isOnAdmin ? null : /* @__PURE__ */ React.createElement(
61
+ "div",
62
+ {
63
+ style: { position: "fixed", bottom: "56px", left: "0px", zIndex: 200 }
64
+ },
65
+ /* @__PURE__ */ React.createElement(
66
+ "a",
67
+ {
68
+ href: "/admin",
69
+ style: {
70
+ borderRadius: "0 50px 50px 0",
71
+ fontSize: "16px",
72
+ fontFamily: "Inter, 'Helvetica Neue', 'Arial Nova', Helvetica, Arial, sans-serif",
73
+ fontWeight: "bold",
74
+ textDecoration: "none",
75
+ background: "rgb(34, 150, 254)",
76
+ boxShadow: "0px 1px 3px rgb(0 0 0 / 10%), 0px 2px 6px rgb(0 0 0 / 20%)",
77
+ color: "white",
78
+ padding: "14px 20px",
79
+ border: "none"
80
+ }
81
+ },
82
+ "Edit with Tina"
83
+ )
84
+ );
77
85
  };
78
86
  const TinaEditProviderInner = ({ children, editMode }) => {
79
87
  const { edit } = useEditState();
@@ -86,4 +94,10 @@ const TinaEditProviderInner = ({ children, editMode }) => {
86
94
  }
87
95
  return children;
88
96
  };
89
- export { TinaEditProvider, useEditState, useTina };
97
+ export {
98
+ TinaEditProvider,
99
+ isEditing,
100
+ setEditing,
101
+ useEditState,
102
+ useTina
103
+ };
@@ -2,25 +2,19 @@
2
2
  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));
3
3
  })(this, function(exports2, sharedctx, React) {
4
4
  "use strict";
5
- function _interopDefaultLegacy(e) {
6
- return e && typeof e === "object" && "default" in e ? e : { "default": e };
7
- }
8
- var React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
9
5
  const useEditState = sharedctx.useEditState;
10
6
  const TinaEditProvider = ({
11
7
  showEditButton,
12
8
  ...props
13
9
  }) => {
14
- return /* @__PURE__ */ React__default["default"].createElement(sharedctx.EditProvider, null, showEditButton && /* @__PURE__ */ React__default["default"].createElement(ToggleButton, null), /* @__PURE__ */ React__default["default"].createElement(TinaEditProviderInner, {
15
- ...props
16
- }));
10
+ return /* @__PURE__ */ React.createElement(sharedctx.EditProvider, null, showEditButton && /* @__PURE__ */ React.createElement(ToggleButton, null), /* @__PURE__ */ React.createElement(TinaEditProviderInner, { ...props }));
17
11
  };
18
12
  function useTina({
19
13
  query,
20
14
  variables,
21
15
  data
22
16
  }) {
23
- React__default["default"].useEffect(() => {
17
+ React.useEffect(() => {
24
18
  console.warn(`
25
19
  "useTina" from 'tinacms/dist/edit-state' is now deprecated
26
20
  * Use "import { useTina } from 'tinacms/dist/react" instead.
@@ -32,10 +26,12 @@
32
26
  state,
33
27
  isDummyContainer,
34
28
  isLoading: contextLoading
35
- } = React__default["default"].useContext(sharedctx.TinaDataContext);
36
- const [waitForContextRerender, setWaitForContextRerender] = React.useState(!isDummyContainer);
29
+ } = React.useContext(sharedctx.TinaDataContext);
30
+ const [waitForContextRerender, setWaitForContextRerender] = React.useState(
31
+ !isDummyContainer
32
+ );
37
33
  const isLoading = contextLoading || waitForContextRerender;
38
- React__default["default"].useEffect(() => {
34
+ React.useEffect(() => {
39
35
  setRequest({ query, variables });
40
36
  }, [JSON.stringify(variables), query]);
41
37
  React.useEffect(() => {
@@ -53,8 +49,8 @@
53
49
  }
54
50
  const ToggleButton = () => {
55
51
  const { edit } = useEditState();
56
- const [isOnAdmin, setIsOnAdmin] = React__default["default"].useState(false);
57
- React__default["default"].useEffect(() => {
52
+ const [isOnAdmin, setIsOnAdmin] = React.useState(false);
53
+ React.useEffect(() => {
58
54
  var _a;
59
55
  if (window) {
60
56
  if ((_a = window.location) == null ? void 0 : _a.pathname.startsWith("/admin")) {
@@ -62,28 +58,36 @@
62
58
  }
63
59
  }
64
60
  }, [setIsOnAdmin]);
65
- return edit || isOnAdmin ? null : /* @__PURE__ */ React__default["default"].createElement("div", {
66
- style: { position: "fixed", bottom: "56px", left: "0px", zIndex: 200 }
67
- }, /* @__PURE__ */ React__default["default"].createElement("a", {
68
- href: "/admin",
69
- style: {
70
- borderRadius: "0 50px 50px 0",
71
- fontSize: "16px",
72
- fontFamily: "Inter, 'Helvetica Neue', 'Arial Nova', Helvetica, Arial, sans-serif",
73
- fontWeight: "bold",
74
- textDecoration: "none",
75
- background: "rgb(34, 150, 254)",
76
- boxShadow: "0px 1px 3px rgb(0 0 0 / 10%), 0px 2px 6px rgb(0 0 0 / 20%)",
77
- color: "white",
78
- padding: "14px 20px",
79
- border: "none"
80
- }
81
- }, "Edit with Tina"));
61
+ return edit || isOnAdmin ? null : /* @__PURE__ */ React.createElement(
62
+ "div",
63
+ {
64
+ style: { position: "fixed", bottom: "56px", left: "0px", zIndex: 200 }
65
+ },
66
+ /* @__PURE__ */ React.createElement(
67
+ "a",
68
+ {
69
+ href: "/admin",
70
+ style: {
71
+ borderRadius: "0 50px 50px 0",
72
+ fontSize: "16px",
73
+ fontFamily: "Inter, 'Helvetica Neue', 'Arial Nova', Helvetica, Arial, sans-serif",
74
+ fontWeight: "bold",
75
+ textDecoration: "none",
76
+ background: "rgb(34, 150, 254)",
77
+ boxShadow: "0px 1px 3px rgb(0 0 0 / 10%), 0px 2px 6px rgb(0 0 0 / 20%)",
78
+ color: "white",
79
+ padding: "14px 20px",
80
+ border: "none"
81
+ }
82
+ },
83
+ "Edit with Tina"
84
+ )
85
+ );
82
86
  };
83
87
  const TinaEditProviderInner = ({ children, editMode }) => {
84
88
  const { edit } = useEditState();
85
- const [isBrowser, setIsBrowser] = React__default["default"].useState(false);
86
- React__default["default"].useEffect(() => {
89
+ const [isBrowser, setIsBrowser] = React.useState(false);
90
+ React.useEffect(() => {
87
91
  setIsBrowser(true);
88
92
  }, []);
89
93
  if (edit && isBrowser) {
@@ -93,18 +97,14 @@
93
97
  };
94
98
  Object.defineProperty(exports2, "isEditing", {
95
99
  enumerable: true,
96
- get: function() {
97
- return sharedctx.isEditing;
98
- }
100
+ get: () => sharedctx.isEditing
99
101
  });
100
102
  Object.defineProperty(exports2, "setEditing", {
101
103
  enumerable: true,
102
- get: function() {
103
- return sharedctx.setEditing;
104
- }
104
+ get: () => sharedctx.setEditing
105
105
  });
106
106
  exports2.TinaEditProvider = TinaEditProvider;
107
107
  exports2.useEditState = useEditState;
108
108
  exports2.useTina = useTina;
109
- Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
109
+ Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
110
110
  });