tinacms 0.56.0 → 0.57.0
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 +34 -0
- package/dist/admin/components/GetCMS.d.ts +16 -0
- package/dist/admin/components/GetCollection.d.ts +42 -0
- package/dist/admin/components/GetCollections.d.ts +23 -0
- package/dist/admin/components/GetDocument.d.ts +35 -0
- package/dist/admin/components/GetDocumentFields.d.ts +34 -0
- package/dist/admin/components/Layout.d.ts +16 -0
- package/dist/admin/hooks/useEmbedTailwind.d.ts +14 -0
- package/dist/admin/index.d.ts +13 -0
- package/dist/admin/pages/CollectionCreatePage.d.ts +14 -0
- package/dist/admin/pages/CollectionListPage.d.ts +14 -0
- package/dist/admin/pages/CollectionUpdatePage.d.ts +14 -0
- package/dist/admin/pages/DashboardPage.d.ts +14 -0
- package/dist/admin/pages/LoginPage.d.ts +14 -0
- package/dist/hooks/use-graphql-forms.d.ts +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +638 -22
- package/dist/index.js +637 -22
- package/dist/rich-text.d.ts +118 -0
- package/dist/rich-text.es.js +192 -0
- package/dist/rich-text.js +202 -0
- package/package.json +11 -6
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")) : typeof define === "function" && define.amd ? define(["exports", "graphql", "lodash.set", "graphql-tag", "@tinacms/toolkit", "react", "styled-components", "yup", "final-form"], 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));
|
|
34
|
-
})(this, function(exports2, graphql, set, gql$1, toolkit, React, styled, yup, finalForm) {
|
|
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) {
|
|
35
35
|
"use strict";
|
|
36
36
|
function _interopDefaultLegacy(e) {
|
|
37
37
|
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
@@ -799,7 +799,9 @@ mutation addPendingDocumentMutation(
|
|
|
799
799
|
}
|
|
800
800
|
return () => {
|
|
801
801
|
if (!branchingEnabled) {
|
|
802
|
-
|
|
802
|
+
if (branchSwitcher) {
|
|
803
|
+
cms.plugins.remove(branchSwitcher);
|
|
804
|
+
}
|
|
803
805
|
}
|
|
804
806
|
};
|
|
805
807
|
}, [branchingEnabled, props.branch]);
|
|
@@ -826,6 +828,7 @@ mutation addPendingDocumentMutation(
|
|
|
826
828
|
const [pendingReset, setPendingReset] = React__default["default"].useState(null);
|
|
827
829
|
const [isLoading, setIsLoading] = React__default["default"].useState(true);
|
|
828
830
|
const [newUpdate, setNewUpdate] = React__default["default"].useState(null);
|
|
831
|
+
React__default["default"].useState([]);
|
|
829
832
|
const updateData = async () => {
|
|
830
833
|
var _a;
|
|
831
834
|
if (newUpdate) {
|
|
@@ -1002,8 +1005,8 @@ mutation addPendingDocumentMutation(
|
|
|
1002
1005
|
}, [queryString, JSON.stringify(variables)]);
|
|
1003
1006
|
return [data, isLoading];
|
|
1004
1007
|
}
|
|
1005
|
-
const transformDocumentIntoMutationRequestPayload = (
|
|
1006
|
-
const _a =
|
|
1008
|
+
const transformDocumentIntoMutationRequestPayload = (document2, instructions) => {
|
|
1009
|
+
const _a = document2, { _collection, __typename, _template } = _a, rest = __objRest(_a, ["_collection", "__typename", "_template"]);
|
|
1007
1010
|
const params = transformParams(rest);
|
|
1008
1011
|
const paramsWithTemplate = instructions.includeTemplate ? { [_template]: params } : params;
|
|
1009
1012
|
return instructions.includeCollection ? { [_collection]: paramsWithTemplate } : paramsWithTemplate;
|
|
@@ -1021,11 +1024,18 @@ mutation addPendingDocumentMutation(
|
|
|
1021
1024
|
const nested = transformParams(rest);
|
|
1022
1025
|
return { [_template]: nested };
|
|
1023
1026
|
} catch (e) {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1027
|
+
if (e.message === "Failed to assertShape - _template is a required field") {
|
|
1028
|
+
const accum = {};
|
|
1029
|
+
Object.entries(data).map(([keyName, value]) => {
|
|
1030
|
+
accum[keyName] = transformParams(value);
|
|
1031
|
+
});
|
|
1032
|
+
return accum;
|
|
1033
|
+
} else {
|
|
1034
|
+
if (!data) {
|
|
1035
|
+
return [];
|
|
1036
|
+
}
|
|
1037
|
+
throw e;
|
|
1038
|
+
}
|
|
1029
1039
|
}
|
|
1030
1040
|
};
|
|
1031
1041
|
const getFieldUpdate = (newUpdate, activeForm, formValues) => {
|
|
@@ -1198,9 +1208,9 @@ mutation addPendingDocumentMutation(
|
|
|
1198
1208
|
}
|
|
1199
1209
|
return true;
|
|
1200
1210
|
}
|
|
1201
|
-
const isValid = /^[_a-zA-Z][_a-zA-Z0-9]*$/.test(value);
|
|
1211
|
+
const isValid = /^[_a-zA-Z][-,_a-zA-Z0-9]*$/.test(value);
|
|
1202
1212
|
if (value && !isValid) {
|
|
1203
|
-
return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, or _";
|
|
1213
|
+
return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, - or _";
|
|
1204
1214
|
}
|
|
1205
1215
|
}
|
|
1206
1216
|
}
|
|
@@ -1333,72 +1343,99 @@ mutation addPendingDocumentMutation(
|
|
|
1333
1343
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1334
1344
|
style: {
|
|
1335
1345
|
position: "fixed",
|
|
1336
|
-
background: "
|
|
1346
|
+
background: "rgba(0, 0, 0, 0.5)",
|
|
1337
1347
|
inset: 0,
|
|
1338
1348
|
zIndex: 200,
|
|
1339
1349
|
opacity: "0.8",
|
|
1340
1350
|
display: "flex",
|
|
1341
1351
|
alignItems: "center",
|
|
1342
|
-
justifyContent: "center"
|
|
1352
|
+
justifyContent: "center",
|
|
1353
|
+
padding: "40px"
|
|
1343
1354
|
}
|
|
1344
1355
|
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1345
1356
|
style: {
|
|
1357
|
+
background: "#f6f6f9",
|
|
1358
|
+
boxShadow: "0px 2px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.1)",
|
|
1359
|
+
borderRadius: "5px",
|
|
1360
|
+
padding: "40px 32px",
|
|
1361
|
+
width: "460px",
|
|
1362
|
+
maxWidth: "90%",
|
|
1346
1363
|
display: "flex",
|
|
1347
1364
|
alignItems: "center",
|
|
1348
1365
|
justifyContent: "center",
|
|
1349
1366
|
flexDirection: "column"
|
|
1350
1367
|
}
|
|
1351
1368
|
}, /* @__PURE__ */ React__default["default"].createElement("svg", {
|
|
1352
|
-
style: {
|
|
1369
|
+
style: {
|
|
1370
|
+
width: "64px",
|
|
1371
|
+
color: "#2296fe",
|
|
1372
|
+
marginTop: "-8px",
|
|
1373
|
+
marginBottom: "16px"
|
|
1374
|
+
},
|
|
1353
1375
|
version: "1.1",
|
|
1354
1376
|
id: "L5",
|
|
1355
1377
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1356
1378
|
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
1357
1379
|
x: "0px",
|
|
1358
1380
|
y: "0px",
|
|
1359
|
-
viewBox: "0 0 100
|
|
1381
|
+
viewBox: "0 0 100 64",
|
|
1360
1382
|
enableBackground: "new 0 0 0 0",
|
|
1361
1383
|
xmlSpace: "preserve"
|
|
1362
1384
|
}, /* @__PURE__ */ React__default["default"].createElement("circle", {
|
|
1363
1385
|
fill: "currentColor",
|
|
1364
1386
|
stroke: "none",
|
|
1365
1387
|
cx: 6,
|
|
1366
|
-
cy:
|
|
1388
|
+
cy: 32,
|
|
1367
1389
|
r: 6
|
|
1368
1390
|
}, /* @__PURE__ */ React__default["default"].createElement("animateTransform", {
|
|
1369
1391
|
attributeName: "transform",
|
|
1370
1392
|
dur: "1s",
|
|
1371
1393
|
type: "translate",
|
|
1372
1394
|
values: "0 15 ; 0 -15; 0 15",
|
|
1395
|
+
calcMode: "spline",
|
|
1396
|
+
keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
|
|
1373
1397
|
repeatCount: "indefinite",
|
|
1374
1398
|
begin: "0.1"
|
|
1375
1399
|
})), /* @__PURE__ */ React__default["default"].createElement("circle", {
|
|
1376
1400
|
fill: "currentColor",
|
|
1377
1401
|
stroke: "none",
|
|
1378
1402
|
cx: 30,
|
|
1379
|
-
cy:
|
|
1403
|
+
cy: 32,
|
|
1380
1404
|
r: 6
|
|
1381
1405
|
}, /* @__PURE__ */ React__default["default"].createElement("animateTransform", {
|
|
1382
1406
|
attributeName: "transform",
|
|
1383
1407
|
dur: "1s",
|
|
1384
1408
|
type: "translate",
|
|
1385
|
-
values: "0
|
|
1409
|
+
values: "0 15 ; 0 -10; 0 15",
|
|
1410
|
+
calcMode: "spline",
|
|
1411
|
+
keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
|
|
1386
1412
|
repeatCount: "indefinite",
|
|
1387
1413
|
begin: "0.2"
|
|
1388
1414
|
})), /* @__PURE__ */ React__default["default"].createElement("circle", {
|
|
1389
1415
|
fill: "currentColor",
|
|
1390
1416
|
stroke: "none",
|
|
1391
1417
|
cx: 54,
|
|
1392
|
-
cy:
|
|
1418
|
+
cy: 32,
|
|
1393
1419
|
r: 6
|
|
1394
1420
|
}, /* @__PURE__ */ React__default["default"].createElement("animateTransform", {
|
|
1395
1421
|
attributeName: "transform",
|
|
1396
1422
|
dur: "1s",
|
|
1397
1423
|
type: "translate",
|
|
1398
|
-
values: "0
|
|
1424
|
+
values: "0 15 ; 0 -5; 0 15",
|
|
1425
|
+
calcMode: "spline",
|
|
1426
|
+
keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
|
|
1399
1427
|
repeatCount: "indefinite",
|
|
1400
1428
|
begin: "0.3"
|
|
1401
|
-
}))), /* @__PURE__ */ React__default["default"].createElement("p",
|
|
1429
|
+
}))), /* @__PURE__ */ React__default["default"].createElement("p", {
|
|
1430
|
+
style: {
|
|
1431
|
+
fontSize: "18px",
|
|
1432
|
+
color: "#252336",
|
|
1433
|
+
textAlign: "center",
|
|
1434
|
+
lineHeight: "1.3",
|
|
1435
|
+
fontFamily: "'Inter', sans-serif",
|
|
1436
|
+
fontWeight: "normal"
|
|
1437
|
+
}
|
|
1438
|
+
}, "Please wait, Tina is loading data..."))), props.children);
|
|
1402
1439
|
};
|
|
1403
1440
|
const getStaticPropsForTina = async ({
|
|
1404
1441
|
query,
|
|
@@ -1441,10 +1478,588 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1441
1478
|
function gql(strings) {
|
|
1442
1479
|
return strings[0];
|
|
1443
1480
|
}
|
|
1481
|
+
var DefaultContext = {
|
|
1482
|
+
color: void 0,
|
|
1483
|
+
size: void 0,
|
|
1484
|
+
className: void 0,
|
|
1485
|
+
style: void 0,
|
|
1486
|
+
attr: void 0
|
|
1487
|
+
};
|
|
1488
|
+
var IconContext = React__default["default"].createContext && React__default["default"].createContext(DefaultContext);
|
|
1489
|
+
var __assign = function() {
|
|
1490
|
+
__assign = Object.assign || function(t) {
|
|
1491
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1492
|
+
s = arguments[i];
|
|
1493
|
+
for (var p in s)
|
|
1494
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1495
|
+
t[p] = s[p];
|
|
1496
|
+
}
|
|
1497
|
+
return t;
|
|
1498
|
+
};
|
|
1499
|
+
return __assign.apply(this, arguments);
|
|
1500
|
+
};
|
|
1501
|
+
var __rest = function(s, e) {
|
|
1502
|
+
var t = {};
|
|
1503
|
+
for (var p in s)
|
|
1504
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1505
|
+
t[p] = s[p];
|
|
1506
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1507
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1508
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1509
|
+
t[p[i]] = s[p[i]];
|
|
1510
|
+
}
|
|
1511
|
+
return t;
|
|
1512
|
+
};
|
|
1513
|
+
function Tree2Element(tree) {
|
|
1514
|
+
return tree && tree.map(function(node, i) {
|
|
1515
|
+
return React__default["default"].createElement(node.tag, __assign({
|
|
1516
|
+
key: i
|
|
1517
|
+
}, node.attr), Tree2Element(node.child));
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1520
|
+
function GenIcon(data) {
|
|
1521
|
+
return function(props) {
|
|
1522
|
+
return React__default["default"].createElement(IconBase, __assign({
|
|
1523
|
+
attr: __assign({}, data.attr)
|
|
1524
|
+
}, props), Tree2Element(data.child));
|
|
1525
|
+
};
|
|
1526
|
+
}
|
|
1527
|
+
function IconBase(props) {
|
|
1528
|
+
var elem = function(conf) {
|
|
1529
|
+
var attr = props.attr, size = props.size, title = props.title, svgProps = __rest(props, ["attr", "size", "title"]);
|
|
1530
|
+
var computedSize = size || conf.size || "1em";
|
|
1531
|
+
var className;
|
|
1532
|
+
if (conf.className)
|
|
1533
|
+
className = conf.className;
|
|
1534
|
+
if (props.className)
|
|
1535
|
+
className = (className ? className + " " : "") + props.className;
|
|
1536
|
+
return React__default["default"].createElement("svg", __assign({
|
|
1537
|
+
stroke: "currentColor",
|
|
1538
|
+
fill: "currentColor",
|
|
1539
|
+
strokeWidth: "0"
|
|
1540
|
+
}, conf.attr, attr, svgProps, {
|
|
1541
|
+
className,
|
|
1542
|
+
style: __assign(__assign({
|
|
1543
|
+
color: props.color || conf.color
|
|
1544
|
+
}, conf.style), props.style),
|
|
1545
|
+
height: computedSize,
|
|
1546
|
+
width: computedSize,
|
|
1547
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1548
|
+
}), title && React__default["default"].createElement("title", null, title), props.children);
|
|
1549
|
+
};
|
|
1550
|
+
return IconContext !== void 0 ? React__default["default"].createElement(IconContext.Consumer, null, function(conf) {
|
|
1551
|
+
return elem(conf);
|
|
1552
|
+
}) : elem(DefaultContext);
|
|
1553
|
+
}
|
|
1554
|
+
function ImFilesEmpty(props) {
|
|
1555
|
+
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);
|
|
1556
|
+
}
|
|
1557
|
+
function VscOpenPreview(props) {
|
|
1558
|
+
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);
|
|
1559
|
+
}
|
|
1560
|
+
const Layout = ({ children }) => {
|
|
1561
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1562
|
+
style: {
|
|
1563
|
+
position: "fixed",
|
|
1564
|
+
top: 0,
|
|
1565
|
+
left: 0,
|
|
1566
|
+
width: "100%",
|
|
1567
|
+
height: "100%",
|
|
1568
|
+
overflow: "auto",
|
|
1569
|
+
background: "#F6F6F9",
|
|
1570
|
+
zIndex: 9999
|
|
1571
|
+
}
|
|
1572
|
+
}, children);
|
|
1573
|
+
};
|
|
1574
|
+
const GetCMS = ({ children }) => {
|
|
1575
|
+
try {
|
|
1576
|
+
const cms = toolkit.useCMS();
|
|
1577
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(cms));
|
|
1578
|
+
} catch (e) {
|
|
1579
|
+
return null;
|
|
1580
|
+
}
|
|
1581
|
+
};
|
|
1582
|
+
const useGetCollections = (cms) => {
|
|
1583
|
+
const [collections, setCollections] = React.useState([]);
|
|
1584
|
+
React.useEffect(() => {
|
|
1585
|
+
const fetchCollections = async () => {
|
|
1586
|
+
const response = await cms.api.tina.request(`query{ getCollections { label, name } }`, {});
|
|
1587
|
+
setCollections(response.getCollections);
|
|
1588
|
+
};
|
|
1589
|
+
fetchCollections();
|
|
1590
|
+
}, [cms]);
|
|
1591
|
+
return collections;
|
|
1592
|
+
};
|
|
1593
|
+
const GetCollections = ({ cms, children }) => {
|
|
1594
|
+
const collections = useGetCollections(cms);
|
|
1595
|
+
if (!collections)
|
|
1596
|
+
return null;
|
|
1597
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collections));
|
|
1598
|
+
};
|
|
1599
|
+
function BiEdit(props) {
|
|
1600
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "m7 17.013 4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z" } }, { "tag": "path", "attr": { "d": "M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z" } }] })(props);
|
|
1601
|
+
}
|
|
1602
|
+
function BiExit(props) {
|
|
1603
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M19.002 3h-14c-1.103 0-2 .897-2 2v4h2V5h14v14h-14v-4h-2v4c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2V5c0-1.103-.898-2-2-2z" } }, { "tag": "path", "attr": { "d": "m11 16 5-4-5-4v3.001H3v2h8z" } }] })(props);
|
|
1604
|
+
}
|
|
1605
|
+
function BiLogIn(props) {
|
|
1606
|
+
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);
|
|
1607
|
+
}
|
|
1608
|
+
function MdOutlineArrowBack(props) {
|
|
1609
|
+
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);
|
|
1610
|
+
}
|
|
1611
|
+
const login = () => {
|
|
1612
|
+
setEditing(true);
|
|
1613
|
+
window.location.reload();
|
|
1614
|
+
};
|
|
1615
|
+
const LoginPage = () => {
|
|
1616
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1617
|
+
className: "h-screen w-full bg-gradient-to-b from-blue-900 to-gray-900 flex items-center justify-center px-4 py-6"
|
|
1618
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1619
|
+
className: "bg-white rounded-lg overflow-hidden shadow-lg w-full max-w-md"
|
|
1620
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1621
|
+
className: "px-5 py-4 border-b border-gray-150"
|
|
1622
|
+
}, /* @__PURE__ */ React__default["default"].createElement("h2", {
|
|
1623
|
+
className: "text-2xl tracking-wide text-gray-700 flex items-center gap-0.5"
|
|
1624
|
+
}, /* @__PURE__ */ React__default["default"].createElement("svg", {
|
|
1625
|
+
viewBox: "0 0 32 32",
|
|
1626
|
+
fill: "#EC4815",
|
|
1627
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1628
|
+
className: "w-10 h-auto"
|
|
1629
|
+
}, /* @__PURE__ */ React__default["default"].createElement("path", {
|
|
1630
|
+
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"
|
|
1631
|
+
}), /* @__PURE__ */ React__default["default"].createElement("path", {
|
|
1632
|
+
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"
|
|
1633
|
+
})), /* @__PURE__ */ React__default["default"].createElement("span", null, "Tina Admin"))), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1634
|
+
className: "px-5 py-4 "
|
|
1635
|
+
}, /* @__PURE__ */ React__default["default"].createElement("p", {
|
|
1636
|
+
className: "text-base font-sans leading-normal"
|
|
1637
|
+
}, "Please log in to Tina Cloud to access your admin dashboard.")), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1638
|
+
className: "px-5 py-4 flex gap-4 w-full justify-between"
|
|
1639
|
+
}, /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
1640
|
+
href: "/",
|
|
1641
|
+
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"
|
|
1642
|
+
}, /* @__PURE__ */ React__default["default"].createElement(MdOutlineArrowBack, {
|
|
1643
|
+
className: "w-6 h-auto mr-1.5 opacity-80"
|
|
1644
|
+
}), " Back to site"), /* @__PURE__ */ React__default["default"].createElement("button", {
|
|
1645
|
+
type: "submit",
|
|
1646
|
+
onClick: () => login(),
|
|
1647
|
+
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",
|
|
1648
|
+
style: { background: "#0084FF" }
|
|
1649
|
+
}, /* @__PURE__ */ React__default["default"].createElement(BiLogIn, {
|
|
1650
|
+
className: "w-6 h-auto mr-1.5 opacity-80"
|
|
1651
|
+
}), " Log in"))));
|
|
1652
|
+
};
|
|
1653
|
+
const DashboardPage = () => {
|
|
1654
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1655
|
+
className: "h-screen overflow-y-auto flex flex-col justify-start items-stretch"
|
|
1656
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1657
|
+
className: "flex-0 px-6 pt-16 pb-10 w-full flex justify-center bg-white border-b border-gray-150"
|
|
1658
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1659
|
+
className: "max-w-screen-md w-full"
|
|
1660
|
+
}, /* @__PURE__ */ React__default["default"].createElement("h3", {
|
|
1661
|
+
className: "text-4xl"
|
|
1662
|
+
}, "Welcome to Tina CMS."))), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1663
|
+
className: "w-full px-6 py-10 flex justify-center"
|
|
1664
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1665
|
+
className: "max-w-screen-md w-full"
|
|
1666
|
+
}, /* @__PURE__ */ React__default["default"].createElement("p", {
|
|
1667
|
+
className: "text-gray-700 text-lg"
|
|
1668
|
+
}, "This is your dashboard for editing or creating content. Select a collection on the left to begin."))));
|
|
1669
|
+
};
|
|
1670
|
+
const useGetCollection = (cms, collectionName, includeDocuments = true) => {
|
|
1671
|
+
const [collection, setCollection] = React.useState(void 0);
|
|
1672
|
+
React.useEffect(() => {
|
|
1673
|
+
const fetchCollection = async () => {
|
|
1674
|
+
const response = await cms.api.tina.request(`
|
|
1675
|
+
query($collection: String!, $includeDocuments: Boolean!){
|
|
1676
|
+
getCollection(collection: $collection){
|
|
1677
|
+
name
|
|
1678
|
+
label
|
|
1679
|
+
format
|
|
1680
|
+
documents @include(if: $includeDocuments) {
|
|
1681
|
+
totalCount
|
|
1682
|
+
edges {
|
|
1683
|
+
node {
|
|
1684
|
+
... on Document {
|
|
1685
|
+
sys {
|
|
1686
|
+
breadcrumbs
|
|
1687
|
+
path
|
|
1688
|
+
basename
|
|
1689
|
+
relativePath
|
|
1690
|
+
filename
|
|
1691
|
+
extension
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
}`, { variables: { collection: collectionName, includeDocuments } });
|
|
1699
|
+
setCollection(response.getCollection);
|
|
1700
|
+
};
|
|
1701
|
+
fetchCollection();
|
|
1702
|
+
}, [cms, collectionName]);
|
|
1703
|
+
return collection;
|
|
1704
|
+
};
|
|
1705
|
+
const GetCollection = ({
|
|
1706
|
+
cms,
|
|
1707
|
+
collectionName,
|
|
1708
|
+
includeDocuments = true,
|
|
1709
|
+
children
|
|
1710
|
+
}) => {
|
|
1711
|
+
const collection = useGetCollection(cms, collectionName, includeDocuments);
|
|
1712
|
+
if (!collection) {
|
|
1713
|
+
return null;
|
|
1714
|
+
}
|
|
1715
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collection));
|
|
1716
|
+
};
|
|
1717
|
+
const CollectionListPage = () => {
|
|
1718
|
+
const location = reactRouterDom.useLocation();
|
|
1719
|
+
const { collectionName } = reactRouterDom.useParams();
|
|
1720
|
+
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetCollection, {
|
|
1721
|
+
cms,
|
|
1722
|
+
collectionName,
|
|
1723
|
+
includeDocuments: true
|
|
1724
|
+
}, (collection) => {
|
|
1725
|
+
const totalCount = collection.documents.totalCount;
|
|
1726
|
+
const documents = collection.documents.edges;
|
|
1727
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1728
|
+
className: "px-6 py-14 h-screen overflow-y-auto flex justify-center"
|
|
1729
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1730
|
+
className: "max-w-screen-md w-full"
|
|
1731
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1732
|
+
className: "w-full flex justify-between items-end"
|
|
1733
|
+
}, /* @__PURE__ */ React__default["default"].createElement("h3", {
|
|
1734
|
+
className: "text-3xl"
|
|
1735
|
+
}, collection.label), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1736
|
+
to: `${location.pathname}/new`,
|
|
1737
|
+
className: "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",
|
|
1738
|
+
style: { background: "#0084FF" }
|
|
1739
|
+
}, "Create New")), totalCount > 0 && /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1740
|
+
className: "mt-8 shadow overflow-hidden border-b border-gray-200 sm:rounded-lg"
|
|
1741
|
+
}, /* @__PURE__ */ React__default["default"].createElement("table", {
|
|
1742
|
+
className: "min-w-full"
|
|
1743
|
+
}, /* @__PURE__ */ React__default["default"].createElement("tbody", {
|
|
1744
|
+
className: "bg-white divide-y divide-gray-150"
|
|
1745
|
+
}, documents.map((document2) => /* @__PURE__ */ React__default["default"].createElement("tr", {
|
|
1746
|
+
key: document2.node.sys.relativePath
|
|
1747
|
+
}, /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
1748
|
+
className: "px-6 py-2 whitespace-nowrap"
|
|
1749
|
+
}, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1750
|
+
to: `${location.pathname}/${document2.node.sys.filename}`,
|
|
1751
|
+
className: "text-blue-600 hover:text-blue-400 flex items-center gap-3"
|
|
1752
|
+
}, /* @__PURE__ */ React__default["default"].createElement(BiEdit, {
|
|
1753
|
+
className: "inline-block h-6 w-auto opacity-70"
|
|
1754
|
+
}), " ", /* @__PURE__ */ React__default["default"].createElement("span", null, /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1755
|
+
className: "block text-xs text-gray-400 mb-1 uppercase"
|
|
1756
|
+
}, "Filename"), /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1757
|
+
className: "h-5 leading-5 block whitespace-nowrap"
|
|
1758
|
+
}, document2.node.sys.filename)))), /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
1759
|
+
className: "px-6 py-4 whitespace-nowrap"
|
|
1760
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1761
|
+
className: "block text-xs text-gray-400 mb-1 uppercase"
|
|
1762
|
+
}, "Extension"), /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1763
|
+
className: "h-5 leading-5 block text-sm font-medium text-gray-900"
|
|
1764
|
+
}, document2.node.sys.extension)))))))));
|
|
1765
|
+
}));
|
|
1766
|
+
};
|
|
1767
|
+
const useGetDocumentFields = (cms, collectionName) => {
|
|
1768
|
+
const [info, setInfo] = React.useState({
|
|
1769
|
+
collection: void 0,
|
|
1770
|
+
fields: void 0,
|
|
1771
|
+
mutationInfo: void 0
|
|
1772
|
+
});
|
|
1773
|
+
React.useEffect(() => {
|
|
1774
|
+
const fetchDocumentFields = async () => {
|
|
1775
|
+
const response = await cms.api.tina.request(`query { getDocumentFields }`, {});
|
|
1776
|
+
const documentFields = response.getDocumentFields;
|
|
1777
|
+
const collection = documentFields[collectionName].collection;
|
|
1778
|
+
const fields = documentFields[collectionName].fields;
|
|
1779
|
+
const mutationInfo = documentFields[collectionName].mutationInfo;
|
|
1780
|
+
setInfo({
|
|
1781
|
+
collection,
|
|
1782
|
+
fields,
|
|
1783
|
+
mutationInfo
|
|
1784
|
+
});
|
|
1785
|
+
};
|
|
1786
|
+
fetchDocumentFields();
|
|
1787
|
+
}, [cms, collectionName]);
|
|
1788
|
+
return info;
|
|
1789
|
+
};
|
|
1790
|
+
const GetDocumentFields = ({
|
|
1791
|
+
cms,
|
|
1792
|
+
collectionName,
|
|
1793
|
+
children
|
|
1794
|
+
}) => {
|
|
1795
|
+
const { collection, fields, mutationInfo } = useGetDocumentFields(cms, collectionName);
|
|
1796
|
+
if (!collection || !fields || !mutationInfo) {
|
|
1797
|
+
return null;
|
|
1798
|
+
}
|
|
1799
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collection, fields, mutationInfo));
|
|
1800
|
+
};
|
|
1801
|
+
const createDocument = async (cms, collection, mutationInfo, values) => {
|
|
1802
|
+
const _a = values, { relativePath } = _a, leftover = __objRest(_a, ["relativePath"]);
|
|
1803
|
+
const { includeCollection, includeTemplate } = mutationInfo;
|
|
1804
|
+
const params = transformDocumentIntoMutationRequestPayload(__spreadValues({
|
|
1805
|
+
_collection: collection.name
|
|
1806
|
+
}, leftover), {
|
|
1807
|
+
includeCollection,
|
|
1808
|
+
includeTemplate
|
|
1809
|
+
});
|
|
1810
|
+
await cms.api.tina.request(`mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
1811
|
+
createDocument(
|
|
1812
|
+
collection: $collection,
|
|
1813
|
+
relativePath: $relativePath,
|
|
1814
|
+
params: $params
|
|
1815
|
+
){__typename}
|
|
1816
|
+
}`, {
|
|
1817
|
+
variables: {
|
|
1818
|
+
collection: collection.name,
|
|
1819
|
+
relativePath,
|
|
1820
|
+
params
|
|
1821
|
+
}
|
|
1822
|
+
});
|
|
1823
|
+
};
|
|
1824
|
+
const CollectionCreatePage = () => {
|
|
1825
|
+
const { collectionName } = reactRouterDom.useParams();
|
|
1826
|
+
const history = reactRouterDom.useHistory();
|
|
1827
|
+
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetDocumentFields, {
|
|
1828
|
+
cms,
|
|
1829
|
+
collectionName
|
|
1830
|
+
}, (collection, fields, mutationInfo) => {
|
|
1831
|
+
const form = new toolkit.Form({
|
|
1832
|
+
id: "create-form",
|
|
1833
|
+
label: "form",
|
|
1834
|
+
fields: [
|
|
1835
|
+
{
|
|
1836
|
+
name: "relativePath",
|
|
1837
|
+
label: "Relative Path",
|
|
1838
|
+
component: "text",
|
|
1839
|
+
required: true,
|
|
1840
|
+
defaultValue: `${collection.name}${Date.now()}.${collection.format}`
|
|
1841
|
+
},
|
|
1842
|
+
...fields
|
|
1843
|
+
],
|
|
1844
|
+
onSubmit: async (values) => {
|
|
1845
|
+
await createDocument(cms, collection, mutationInfo, values);
|
|
1846
|
+
history.push(`/admin/collections/${collection.name}`);
|
|
1847
|
+
}
|
|
1848
|
+
});
|
|
1849
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1850
|
+
className: "w-full h-screen"
|
|
1851
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1852
|
+
className: "flex flex-col items-center w-full flex-1"
|
|
1853
|
+
}, /* @__PURE__ */ React__default["default"].createElement(toolkit.FullscreenFormBuilder, {
|
|
1854
|
+
label: collection.label + " - Create New",
|
|
1855
|
+
form
|
|
1856
|
+
})));
|
|
1857
|
+
}));
|
|
1858
|
+
};
|
|
1859
|
+
const useGetDocument = (cms, collectionName, relativePath) => {
|
|
1860
|
+
const [document2, setDocument] = React.useState(void 0);
|
|
1861
|
+
React.useEffect(() => {
|
|
1862
|
+
const fetchDocument = async () => {
|
|
1863
|
+
const response = await cms.api.tina.request(`
|
|
1864
|
+
query($collection: String!, $relativePath: String!) {
|
|
1865
|
+
getDocument(collection:$collection, relativePath:$relativePath) {
|
|
1866
|
+
... on Document {
|
|
1867
|
+
form
|
|
1868
|
+
values
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
}`, { variables: { collection: collectionName, relativePath } });
|
|
1872
|
+
setDocument(response.getDocument);
|
|
1873
|
+
};
|
|
1874
|
+
fetchDocument();
|
|
1875
|
+
}, [cms, collectionName, relativePath]);
|
|
1876
|
+
return document2;
|
|
1877
|
+
};
|
|
1878
|
+
const GetDocument = ({
|
|
1879
|
+
cms,
|
|
1880
|
+
collectionName,
|
|
1881
|
+
relativePath,
|
|
1882
|
+
children
|
|
1883
|
+
}) => {
|
|
1884
|
+
const document2 = useGetDocument(cms, collectionName, relativePath);
|
|
1885
|
+
if (!document2) {
|
|
1886
|
+
return null;
|
|
1887
|
+
}
|
|
1888
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(document2));
|
|
1889
|
+
};
|
|
1890
|
+
const updateDocument = async (cms, collection, document2, relativePath, values) => {
|
|
1891
|
+
const { includeCollection, includeTemplate } = document2.form.mutationInfo;
|
|
1892
|
+
const params = transformDocumentIntoMutationRequestPayload(values, {
|
|
1893
|
+
includeCollection,
|
|
1894
|
+
includeTemplate
|
|
1895
|
+
});
|
|
1896
|
+
await cms.api.tina.request(`mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
1897
|
+
updateDocument(
|
|
1898
|
+
collection: $collection,
|
|
1899
|
+
relativePath: $relativePath,
|
|
1900
|
+
params: $params
|
|
1901
|
+
){__typename}
|
|
1902
|
+
}`, {
|
|
1903
|
+
variables: {
|
|
1904
|
+
collection: collection.name,
|
|
1905
|
+
relativePath,
|
|
1906
|
+
params
|
|
1907
|
+
}
|
|
1908
|
+
});
|
|
1909
|
+
};
|
|
1910
|
+
const CollectionUpdatePage = () => {
|
|
1911
|
+
const { collectionName, filename } = reactRouterDom.useParams();
|
|
1912
|
+
const history = reactRouterDom.useHistory();
|
|
1913
|
+
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetCollection, {
|
|
1914
|
+
cms,
|
|
1915
|
+
collectionName,
|
|
1916
|
+
includeDocuments: false
|
|
1917
|
+
}, (collection) => {
|
|
1918
|
+
const relativePath = `${filename}.${collection.format}`;
|
|
1919
|
+
return /* @__PURE__ */ React__default["default"].createElement(GetDocument, {
|
|
1920
|
+
cms,
|
|
1921
|
+
collectionName: collection.name,
|
|
1922
|
+
relativePath
|
|
1923
|
+
}, (document2) => {
|
|
1924
|
+
const form = new toolkit.Form({
|
|
1925
|
+
id: "update-form",
|
|
1926
|
+
label: "form",
|
|
1927
|
+
fields: document2.form.fields,
|
|
1928
|
+
initialValues: document2.values,
|
|
1929
|
+
onSubmit: async (values) => {
|
|
1930
|
+
await updateDocument(cms, collection, document2, relativePath, values);
|
|
1931
|
+
history.push(`/admin/collections/${collection.name}`);
|
|
1932
|
+
}
|
|
1933
|
+
});
|
|
1934
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1935
|
+
className: "w-full h-screen"
|
|
1936
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1937
|
+
className: "flex flex-col items-center w-full flex-1"
|
|
1938
|
+
}, /* @__PURE__ */ React__default["default"].createElement(toolkit.FullscreenFormBuilder, {
|
|
1939
|
+
label: collection.label + ` - ` + filename,
|
|
1940
|
+
form
|
|
1941
|
+
})));
|
|
1942
|
+
});
|
|
1943
|
+
}));
|
|
1944
|
+
};
|
|
1945
|
+
const useEmbedTailwind = () => {
|
|
1946
|
+
React.useEffect(() => {
|
|
1947
|
+
const isSSR2 = typeof window === "undefined";
|
|
1948
|
+
if (!isSSR2) {
|
|
1949
|
+
const head = document.head;
|
|
1950
|
+
const link = document.createElement("link");
|
|
1951
|
+
link.id = "tina-admin-stylesheet";
|
|
1952
|
+
link.type = "text/css";
|
|
1953
|
+
link.rel = "stylesheet";
|
|
1954
|
+
link.href = "https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css";
|
|
1955
|
+
head.appendChild(link);
|
|
1956
|
+
}
|
|
1957
|
+
}, []);
|
|
1958
|
+
};
|
|
1959
|
+
const logout = () => {
|
|
1960
|
+
setEditing(false);
|
|
1961
|
+
window.location.reload();
|
|
1962
|
+
};
|
|
1963
|
+
const TinaAdmin = () => {
|
|
1964
|
+
useEmbedTailwind();
|
|
1965
|
+
const isSSR2 = typeof window === "undefined";
|
|
1966
|
+
if (isSSR2) {
|
|
1967
|
+
return null;
|
|
1968
|
+
}
|
|
1969
|
+
const isEdit = isEditing();
|
|
1970
|
+
if (!isEdit) {
|
|
1971
|
+
return /* @__PURE__ */ React__default["default"].createElement(Layout, null, /* @__PURE__ */ React__default["default"].createElement(LoginPage, null));
|
|
1972
|
+
}
|
|
1973
|
+
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetCollections, {
|
|
1974
|
+
cms
|
|
1975
|
+
}, (collections) => /* @__PURE__ */ React__default["default"].createElement(Layout, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.BrowserRouter, null, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1976
|
+
className: "flex items-stretch h-screen overflow-hidden"
|
|
1977
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1978
|
+
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"
|
|
1979
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1980
|
+
className: "border-b border-gray-200"
|
|
1981
|
+
}, /* @__PURE__ */ React__default["default"].createElement(react.Menu, {
|
|
1982
|
+
as: "div",
|
|
1983
|
+
className: "relative block"
|
|
1984
|
+
}, ({ open }) => /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Button, {
|
|
1985
|
+
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`}`
|
|
1986
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1987
|
+
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"
|
|
1988
|
+
}, /* @__PURE__ */ React__default["default"].createElement("svg", {
|
|
1989
|
+
viewBox: "0 0 32 32",
|
|
1990
|
+
fill: "#EC4815",
|
|
1991
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1992
|
+
className: "w-10 h-auto -ml-1"
|
|
1993
|
+
}, /* @__PURE__ */ React__default["default"].createElement("path", {
|
|
1994
|
+
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"
|
|
1995
|
+
}), /* @__PURE__ */ React__default["default"].createElement("path", {
|
|
1996
|
+
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"
|
|
1997
|
+
})), /* @__PURE__ */ React__default["default"].createElement("span", null, "Tina Admin")), /* @__PURE__ */ React__default["default"].createElement("svg", {
|
|
1998
|
+
width: "20",
|
|
1999
|
+
height: "20",
|
|
2000
|
+
viewBox: "0 0 20 20",
|
|
2001
|
+
fill: "none",
|
|
2002
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2003
|
+
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`}`
|
|
2004
|
+
}, /* @__PURE__ */ React__default["default"].createElement("g", {
|
|
2005
|
+
opacity: "0.3"
|
|
2006
|
+
}, /* @__PURE__ */ React__default["default"].createElement("path", {
|
|
2007
|
+
d: "M7.91675 13.8086L9.16675 15.0586L14.2253 10L9.16675 4.9414L7.91675 6.1914L11.7253 10L7.91675 13.8086Z",
|
|
2008
|
+
fill: "currentColor"
|
|
2009
|
+
})))), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
2010
|
+
className: "transform translate-y-full absolute bottom-3 right-5 w-2/3 z-50"
|
|
2011
|
+
}, /* @__PURE__ */ React__default["default"].createElement(react.Transition, {
|
|
2012
|
+
enter: "transition duration-150 ease-out",
|
|
2013
|
+
enterFrom: "transform opacity-0 -translate-y-2",
|
|
2014
|
+
enterTo: "transform opacity-100 translate-y-0",
|
|
2015
|
+
leave: "transition duration-75 ease-in",
|
|
2016
|
+
leaveFrom: "transform opacity-100 translate-y-0",
|
|
2017
|
+
leaveTo: "transform opacity-0 -translate-y-2"
|
|
2018
|
+
}, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Items, {
|
|
2019
|
+
className: "w-full py-1 bg-white border border-gray-150 rounded-lg shadow-lg"
|
|
2020
|
+
}, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Item, null, ({ active }) => /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
2021
|
+
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"}`,
|
|
2022
|
+
href: "/"
|
|
2023
|
+
}, /* @__PURE__ */ React__default["default"].createElement(VscOpenPreview, {
|
|
2024
|
+
className: "w-6 h-auto mr-1.5 text-blue-400"
|
|
2025
|
+
}), " ", "View Website")), /* @__PURE__ */ React__default["default"].createElement(react.Menu.Item, null, ({ active }) => /* @__PURE__ */ React__default["default"].createElement("button", {
|
|
2026
|
+
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"}`,
|
|
2027
|
+
onClick: () => logout()
|
|
2028
|
+
}, /* @__PURE__ */ React__default["default"].createElement(BiExit, {
|
|
2029
|
+
className: "w-6 h-auto mr-1.5 text-blue-400"
|
|
2030
|
+
}), " ", "Log out")))))))), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
2031
|
+
className: "px-6 py-7 flex-1"
|
|
2032
|
+
}, /* @__PURE__ */ React__default["default"].createElement("h4", {
|
|
2033
|
+
className: "uppercase font-bold text-sm mb-3"
|
|
2034
|
+
}, "Collections"), /* @__PURE__ */ React__default["default"].createElement("ul", {
|
|
2035
|
+
className: "flex flex-col gap-4"
|
|
2036
|
+
}, collections.map((collection) => {
|
|
2037
|
+
return /* @__PURE__ */ React__default["default"].createElement("li", {
|
|
2038
|
+
key: `${collection.name}-link`
|
|
2039
|
+
}, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.NavLink, {
|
|
2040
|
+
className: `text-lg tracking-wide hover:text-blue-600 flex items-center opacity-90 hover:opacity-100`,
|
|
2041
|
+
activeClassName: "text-blue-600",
|
|
2042
|
+
to: `/admin/collections/${collection.name}`
|
|
2043
|
+
}, /* @__PURE__ */ React__default["default"].createElement(ImFilesEmpty, {
|
|
2044
|
+
className: "mr-2 h-6 opacity-80 w-auto"
|
|
2045
|
+
}), " ", collection.label));
|
|
2046
|
+
})))), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
2047
|
+
className: "flex-1"
|
|
2048
|
+
}, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Switch, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2049
|
+
path: `/admin/collections/:collectionName/new`
|
|
2050
|
+
}, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2051
|
+
path: `/admin/collections/:collectionName/:filename`
|
|
2052
|
+
}, /* @__PURE__ */ React__default["default"].createElement(CollectionUpdatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2053
|
+
path: `/admin/collections/:collectionName`
|
|
2054
|
+
}, /* @__PURE__ */ React__default["default"].createElement(CollectionListPage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2055
|
+
path: `/admin`
|
|
2056
|
+
}, /* @__PURE__ */ React__default["default"].createElement(DashboardPage, null)))))))));
|
|
2057
|
+
};
|
|
1444
2058
|
exports2.AuthWallInner = AuthWallInner;
|
|
1445
2059
|
exports2.Client = Client;
|
|
1446
2060
|
exports2.DEFAULT_LOCAL_TINA_GQL_SERVER_URL = DEFAULT_LOCAL_TINA_GQL_SERVER_URL;
|
|
1447
2061
|
exports2.LocalClient = LocalClient;
|
|
2062
|
+
exports2.TinaAdmin = TinaAdmin;
|
|
1448
2063
|
exports2.TinaCMSProvider2 = TinaCMSProvider2;
|
|
1449
2064
|
exports2.TinaCloudAuthWall = TinaCloudAuthWall;
|
|
1450
2065
|
exports2.TinaCloudProvider = TinaCloudProvider;
|