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.es.js
CHANGED
|
@@ -32,12 +32,14 @@ var __objRest = (source, exclude) => {
|
|
|
32
32
|
import { TypeInfo, visit, visitWithTypeInfo, getNamedType, GraphQLObjectType, isLeafType, GraphQLUnionType, isScalarType, getIntrospectionQuery, buildClientSchema, print } from "graphql";
|
|
33
33
|
import set from "lodash.set";
|
|
34
34
|
import gql$1 from "graphql-tag";
|
|
35
|
-
import { EventBus, StyleReset, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, TinaCMS, BranchSwitcherPlugin, TinaProvider, useCMS, Form, GlobalFormPlugin } from "@tinacms/toolkit";
|
|
35
|
+
import { EventBus, StyleReset, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, TinaCMS, BranchSwitcherPlugin, TinaProvider, useCMS, Form, GlobalFormPlugin, FullscreenFormBuilder } from "@tinacms/toolkit";
|
|
36
36
|
export * from "@tinacms/toolkit";
|
|
37
37
|
import React, { useState, useCallback, useEffect } from "react";
|
|
38
38
|
import styled from "styled-components";
|
|
39
39
|
import * as yup from "yup";
|
|
40
40
|
import { getIn, setIn } from "final-form";
|
|
41
|
+
import { useLocation, useParams, Link, useHistory, BrowserRouter, NavLink, Switch, Route } from "react-router-dom";
|
|
42
|
+
import { Menu, Transition } from "@headlessui/react";
|
|
41
43
|
function popupWindow(url, title, window2, w, h) {
|
|
42
44
|
const y = window2.top.outerHeight / 2 + window2.top.screenY - h / 2;
|
|
43
45
|
const x = window2.top.outerWidth / 2 + window2.top.screenX - w / 2;
|
|
@@ -776,7 +778,9 @@ const TinaCloudProvider = (props) => {
|
|
|
776
778
|
}
|
|
777
779
|
return () => {
|
|
778
780
|
if (!branchingEnabled) {
|
|
779
|
-
|
|
781
|
+
if (branchSwitcher) {
|
|
782
|
+
cms.plugins.remove(branchSwitcher);
|
|
783
|
+
}
|
|
780
784
|
}
|
|
781
785
|
};
|
|
782
786
|
}, [branchingEnabled, props.branch]);
|
|
@@ -803,6 +807,7 @@ function useGraphqlForms({
|
|
|
803
807
|
const [pendingReset, setPendingReset] = React.useState(null);
|
|
804
808
|
const [isLoading, setIsLoading] = React.useState(true);
|
|
805
809
|
const [newUpdate, setNewUpdate] = React.useState(null);
|
|
810
|
+
React.useState([]);
|
|
806
811
|
const updateData = async () => {
|
|
807
812
|
var _a;
|
|
808
813
|
if (newUpdate) {
|
|
@@ -979,8 +984,8 @@ function useGraphqlForms({
|
|
|
979
984
|
}, [queryString, JSON.stringify(variables)]);
|
|
980
985
|
return [data, isLoading];
|
|
981
986
|
}
|
|
982
|
-
const transformDocumentIntoMutationRequestPayload = (
|
|
983
|
-
const _a =
|
|
987
|
+
const transformDocumentIntoMutationRequestPayload = (document2, instructions) => {
|
|
988
|
+
const _a = document2, { _collection, __typename, _template } = _a, rest = __objRest(_a, ["_collection", "__typename", "_template"]);
|
|
984
989
|
const params = transformParams(rest);
|
|
985
990
|
const paramsWithTemplate = instructions.includeTemplate ? { [_template]: params } : params;
|
|
986
991
|
return instructions.includeCollection ? { [_collection]: paramsWithTemplate } : paramsWithTemplate;
|
|
@@ -998,11 +1003,18 @@ const transformParams = (data) => {
|
|
|
998
1003
|
const nested = transformParams(rest);
|
|
999
1004
|
return { [_template]: nested };
|
|
1000
1005
|
} catch (e) {
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
+
if (e.message === "Failed to assertShape - _template is a required field") {
|
|
1007
|
+
const accum = {};
|
|
1008
|
+
Object.entries(data).map(([keyName, value]) => {
|
|
1009
|
+
accum[keyName] = transformParams(value);
|
|
1010
|
+
});
|
|
1011
|
+
return accum;
|
|
1012
|
+
} else {
|
|
1013
|
+
if (!data) {
|
|
1014
|
+
return [];
|
|
1015
|
+
}
|
|
1016
|
+
throw e;
|
|
1017
|
+
}
|
|
1006
1018
|
}
|
|
1007
1019
|
};
|
|
1008
1020
|
const getFieldUpdate = (newUpdate, activeForm, formValues) => {
|
|
@@ -1175,9 +1187,9 @@ const useDocumentCreatorPlugin = (args) => {
|
|
|
1175
1187
|
}
|
|
1176
1188
|
return true;
|
|
1177
1189
|
}
|
|
1178
|
-
const isValid = /^[_a-zA-Z][_a-zA-Z0-9]*$/.test(value);
|
|
1190
|
+
const isValid = /^[_a-zA-Z][-,_a-zA-Z0-9]*$/.test(value);
|
|
1179
1191
|
if (value && !isValid) {
|
|
1180
|
-
return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, or _";
|
|
1192
|
+
return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, - or _";
|
|
1181
1193
|
}
|
|
1182
1194
|
}
|
|
1183
1195
|
}
|
|
@@ -1310,72 +1322,99 @@ const Loader = (props) => {
|
|
|
1310
1322
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
1311
1323
|
style: {
|
|
1312
1324
|
position: "fixed",
|
|
1313
|
-
background: "
|
|
1325
|
+
background: "rgba(0, 0, 0, 0.5)",
|
|
1314
1326
|
inset: 0,
|
|
1315
1327
|
zIndex: 200,
|
|
1316
1328
|
opacity: "0.8",
|
|
1317
1329
|
display: "flex",
|
|
1318
1330
|
alignItems: "center",
|
|
1319
|
-
justifyContent: "center"
|
|
1331
|
+
justifyContent: "center",
|
|
1332
|
+
padding: "40px"
|
|
1320
1333
|
}
|
|
1321
1334
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
1322
1335
|
style: {
|
|
1336
|
+
background: "#f6f6f9",
|
|
1337
|
+
boxShadow: "0px 2px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.1)",
|
|
1338
|
+
borderRadius: "5px",
|
|
1339
|
+
padding: "40px 32px",
|
|
1340
|
+
width: "460px",
|
|
1341
|
+
maxWidth: "90%",
|
|
1323
1342
|
display: "flex",
|
|
1324
1343
|
alignItems: "center",
|
|
1325
1344
|
justifyContent: "center",
|
|
1326
1345
|
flexDirection: "column"
|
|
1327
1346
|
}
|
|
1328
1347
|
}, /* @__PURE__ */ React.createElement("svg", {
|
|
1329
|
-
style: {
|
|
1348
|
+
style: {
|
|
1349
|
+
width: "64px",
|
|
1350
|
+
color: "#2296fe",
|
|
1351
|
+
marginTop: "-8px",
|
|
1352
|
+
marginBottom: "16px"
|
|
1353
|
+
},
|
|
1330
1354
|
version: "1.1",
|
|
1331
1355
|
id: "L5",
|
|
1332
1356
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1333
1357
|
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
1334
1358
|
x: "0px",
|
|
1335
1359
|
y: "0px",
|
|
1336
|
-
viewBox: "0 0 100
|
|
1360
|
+
viewBox: "0 0 100 64",
|
|
1337
1361
|
enableBackground: "new 0 0 0 0",
|
|
1338
1362
|
xmlSpace: "preserve"
|
|
1339
1363
|
}, /* @__PURE__ */ React.createElement("circle", {
|
|
1340
1364
|
fill: "currentColor",
|
|
1341
1365
|
stroke: "none",
|
|
1342
1366
|
cx: 6,
|
|
1343
|
-
cy:
|
|
1367
|
+
cy: 32,
|
|
1344
1368
|
r: 6
|
|
1345
1369
|
}, /* @__PURE__ */ React.createElement("animateTransform", {
|
|
1346
1370
|
attributeName: "transform",
|
|
1347
1371
|
dur: "1s",
|
|
1348
1372
|
type: "translate",
|
|
1349
1373
|
values: "0 15 ; 0 -15; 0 15",
|
|
1374
|
+
calcMode: "spline",
|
|
1375
|
+
keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
|
|
1350
1376
|
repeatCount: "indefinite",
|
|
1351
1377
|
begin: "0.1"
|
|
1352
1378
|
})), /* @__PURE__ */ React.createElement("circle", {
|
|
1353
1379
|
fill: "currentColor",
|
|
1354
1380
|
stroke: "none",
|
|
1355
1381
|
cx: 30,
|
|
1356
|
-
cy:
|
|
1382
|
+
cy: 32,
|
|
1357
1383
|
r: 6
|
|
1358
1384
|
}, /* @__PURE__ */ React.createElement("animateTransform", {
|
|
1359
1385
|
attributeName: "transform",
|
|
1360
1386
|
dur: "1s",
|
|
1361
1387
|
type: "translate",
|
|
1362
|
-
values: "0
|
|
1388
|
+
values: "0 15 ; 0 -10; 0 15",
|
|
1389
|
+
calcMode: "spline",
|
|
1390
|
+
keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
|
|
1363
1391
|
repeatCount: "indefinite",
|
|
1364
1392
|
begin: "0.2"
|
|
1365
1393
|
})), /* @__PURE__ */ React.createElement("circle", {
|
|
1366
1394
|
fill: "currentColor",
|
|
1367
1395
|
stroke: "none",
|
|
1368
1396
|
cx: 54,
|
|
1369
|
-
cy:
|
|
1397
|
+
cy: 32,
|
|
1370
1398
|
r: 6
|
|
1371
1399
|
}, /* @__PURE__ */ React.createElement("animateTransform", {
|
|
1372
1400
|
attributeName: "transform",
|
|
1373
1401
|
dur: "1s",
|
|
1374
1402
|
type: "translate",
|
|
1375
|
-
values: "0
|
|
1403
|
+
values: "0 15 ; 0 -5; 0 15",
|
|
1404
|
+
calcMode: "spline",
|
|
1405
|
+
keySplines: "0.8 0 0.4 1; 0.4 0 0.2 1",
|
|
1376
1406
|
repeatCount: "indefinite",
|
|
1377
1407
|
begin: "0.3"
|
|
1378
|
-
}))), /* @__PURE__ */ React.createElement("p",
|
|
1408
|
+
}))), /* @__PURE__ */ React.createElement("p", {
|
|
1409
|
+
style: {
|
|
1410
|
+
fontSize: "18px",
|
|
1411
|
+
color: "#252336",
|
|
1412
|
+
textAlign: "center",
|
|
1413
|
+
lineHeight: "1.3",
|
|
1414
|
+
fontFamily: "'Inter', sans-serif",
|
|
1415
|
+
fontWeight: "normal"
|
|
1416
|
+
}
|
|
1417
|
+
}, "Please wait, Tina is loading data..."))), props.children);
|
|
1379
1418
|
};
|
|
1380
1419
|
const getStaticPropsForTina = async ({
|
|
1381
1420
|
query,
|
|
@@ -1418,4 +1457,581 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1418
1457
|
function gql(strings) {
|
|
1419
1458
|
return strings[0];
|
|
1420
1459
|
}
|
|
1421
|
-
|
|
1460
|
+
var DefaultContext = {
|
|
1461
|
+
color: void 0,
|
|
1462
|
+
size: void 0,
|
|
1463
|
+
className: void 0,
|
|
1464
|
+
style: void 0,
|
|
1465
|
+
attr: void 0
|
|
1466
|
+
};
|
|
1467
|
+
var IconContext = React.createContext && React.createContext(DefaultContext);
|
|
1468
|
+
var __assign = function() {
|
|
1469
|
+
__assign = Object.assign || function(t) {
|
|
1470
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1471
|
+
s = arguments[i];
|
|
1472
|
+
for (var p in s)
|
|
1473
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1474
|
+
t[p] = s[p];
|
|
1475
|
+
}
|
|
1476
|
+
return t;
|
|
1477
|
+
};
|
|
1478
|
+
return __assign.apply(this, arguments);
|
|
1479
|
+
};
|
|
1480
|
+
var __rest = function(s, e) {
|
|
1481
|
+
var t = {};
|
|
1482
|
+
for (var p in s)
|
|
1483
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1484
|
+
t[p] = s[p];
|
|
1485
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1486
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1487
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1488
|
+
t[p[i]] = s[p[i]];
|
|
1489
|
+
}
|
|
1490
|
+
return t;
|
|
1491
|
+
};
|
|
1492
|
+
function Tree2Element(tree) {
|
|
1493
|
+
return tree && tree.map(function(node, i) {
|
|
1494
|
+
return React.createElement(node.tag, __assign({
|
|
1495
|
+
key: i
|
|
1496
|
+
}, node.attr), Tree2Element(node.child));
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
function GenIcon(data) {
|
|
1500
|
+
return function(props) {
|
|
1501
|
+
return React.createElement(IconBase, __assign({
|
|
1502
|
+
attr: __assign({}, data.attr)
|
|
1503
|
+
}, props), Tree2Element(data.child));
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
function IconBase(props) {
|
|
1507
|
+
var elem = function(conf) {
|
|
1508
|
+
var attr = props.attr, size = props.size, title = props.title, svgProps = __rest(props, ["attr", "size", "title"]);
|
|
1509
|
+
var computedSize = size || conf.size || "1em";
|
|
1510
|
+
var className;
|
|
1511
|
+
if (conf.className)
|
|
1512
|
+
className = conf.className;
|
|
1513
|
+
if (props.className)
|
|
1514
|
+
className = (className ? className + " " : "") + props.className;
|
|
1515
|
+
return React.createElement("svg", __assign({
|
|
1516
|
+
stroke: "currentColor",
|
|
1517
|
+
fill: "currentColor",
|
|
1518
|
+
strokeWidth: "0"
|
|
1519
|
+
}, conf.attr, attr, svgProps, {
|
|
1520
|
+
className,
|
|
1521
|
+
style: __assign(__assign({
|
|
1522
|
+
color: props.color || conf.color
|
|
1523
|
+
}, conf.style), props.style),
|
|
1524
|
+
height: computedSize,
|
|
1525
|
+
width: computedSize,
|
|
1526
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1527
|
+
}), title && React.createElement("title", null, title), props.children);
|
|
1528
|
+
};
|
|
1529
|
+
return IconContext !== void 0 ? React.createElement(IconContext.Consumer, null, function(conf) {
|
|
1530
|
+
return elem(conf);
|
|
1531
|
+
}) : elem(DefaultContext);
|
|
1532
|
+
}
|
|
1533
|
+
function ImFilesEmpty(props) {
|
|
1534
|
+
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);
|
|
1535
|
+
}
|
|
1536
|
+
function VscOpenPreview(props) {
|
|
1537
|
+
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);
|
|
1538
|
+
}
|
|
1539
|
+
const Layout = ({ children }) => {
|
|
1540
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1541
|
+
style: {
|
|
1542
|
+
position: "fixed",
|
|
1543
|
+
top: 0,
|
|
1544
|
+
left: 0,
|
|
1545
|
+
width: "100%",
|
|
1546
|
+
height: "100%",
|
|
1547
|
+
overflow: "auto",
|
|
1548
|
+
background: "#F6F6F9",
|
|
1549
|
+
zIndex: 9999
|
|
1550
|
+
}
|
|
1551
|
+
}, children);
|
|
1552
|
+
};
|
|
1553
|
+
const GetCMS = ({ children }) => {
|
|
1554
|
+
try {
|
|
1555
|
+
const cms = useCMS();
|
|
1556
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(cms));
|
|
1557
|
+
} catch (e) {
|
|
1558
|
+
return null;
|
|
1559
|
+
}
|
|
1560
|
+
};
|
|
1561
|
+
const useGetCollections = (cms) => {
|
|
1562
|
+
const [collections, setCollections] = useState([]);
|
|
1563
|
+
useEffect(() => {
|
|
1564
|
+
const fetchCollections = async () => {
|
|
1565
|
+
const response = await cms.api.tina.request(`query{ getCollections { label, name } }`, {});
|
|
1566
|
+
setCollections(response.getCollections);
|
|
1567
|
+
};
|
|
1568
|
+
fetchCollections();
|
|
1569
|
+
}, [cms]);
|
|
1570
|
+
return collections;
|
|
1571
|
+
};
|
|
1572
|
+
const GetCollections = ({ cms, children }) => {
|
|
1573
|
+
const collections = useGetCollections(cms);
|
|
1574
|
+
if (!collections)
|
|
1575
|
+
return null;
|
|
1576
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collections));
|
|
1577
|
+
};
|
|
1578
|
+
function BiEdit(props) {
|
|
1579
|
+
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);
|
|
1580
|
+
}
|
|
1581
|
+
function BiExit(props) {
|
|
1582
|
+
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);
|
|
1583
|
+
}
|
|
1584
|
+
function BiLogIn(props) {
|
|
1585
|
+
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);
|
|
1586
|
+
}
|
|
1587
|
+
function MdOutlineArrowBack(props) {
|
|
1588
|
+
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);
|
|
1589
|
+
}
|
|
1590
|
+
const login = () => {
|
|
1591
|
+
setEditing(true);
|
|
1592
|
+
window.location.reload();
|
|
1593
|
+
};
|
|
1594
|
+
const LoginPage = () => {
|
|
1595
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1596
|
+
className: "h-screen w-full bg-gradient-to-b from-blue-900 to-gray-900 flex items-center justify-center px-4 py-6"
|
|
1597
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1598
|
+
className: "bg-white rounded-lg overflow-hidden shadow-lg w-full max-w-md"
|
|
1599
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1600
|
+
className: "px-5 py-4 border-b border-gray-150"
|
|
1601
|
+
}, /* @__PURE__ */ React.createElement("h2", {
|
|
1602
|
+
className: "text-2xl tracking-wide text-gray-700 flex items-center gap-0.5"
|
|
1603
|
+
}, /* @__PURE__ */ React.createElement("svg", {
|
|
1604
|
+
viewBox: "0 0 32 32",
|
|
1605
|
+
fill: "#EC4815",
|
|
1606
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1607
|
+
className: "w-10 h-auto"
|
|
1608
|
+
}, /* @__PURE__ */ React.createElement("path", {
|
|
1609
|
+
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"
|
|
1610
|
+
}), /* @__PURE__ */ React.createElement("path", {
|
|
1611
|
+
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"
|
|
1612
|
+
})), /* @__PURE__ */ React.createElement("span", null, "Tina Admin"))), /* @__PURE__ */ React.createElement("div", {
|
|
1613
|
+
className: "px-5 py-4 "
|
|
1614
|
+
}, /* @__PURE__ */ React.createElement("p", {
|
|
1615
|
+
className: "text-base font-sans leading-normal"
|
|
1616
|
+
}, "Please log in to Tina Cloud to access your admin dashboard.")), /* @__PURE__ */ React.createElement("div", {
|
|
1617
|
+
className: "px-5 py-4 flex gap-4 w-full justify-between"
|
|
1618
|
+
}, /* @__PURE__ */ React.createElement("a", {
|
|
1619
|
+
href: "/",
|
|
1620
|
+
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"
|
|
1621
|
+
}, /* @__PURE__ */ React.createElement(MdOutlineArrowBack, {
|
|
1622
|
+
className: "w-6 h-auto mr-1.5 opacity-80"
|
|
1623
|
+
}), " Back to site"), /* @__PURE__ */ React.createElement("button", {
|
|
1624
|
+
type: "submit",
|
|
1625
|
+
onClick: () => login(),
|
|
1626
|
+
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",
|
|
1627
|
+
style: { background: "#0084FF" }
|
|
1628
|
+
}, /* @__PURE__ */ React.createElement(BiLogIn, {
|
|
1629
|
+
className: "w-6 h-auto mr-1.5 opacity-80"
|
|
1630
|
+
}), " Log in"))));
|
|
1631
|
+
};
|
|
1632
|
+
const DashboardPage = () => {
|
|
1633
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1634
|
+
className: "h-screen overflow-y-auto flex flex-col justify-start items-stretch"
|
|
1635
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1636
|
+
className: "flex-0 px-6 pt-16 pb-10 w-full flex justify-center bg-white border-b border-gray-150"
|
|
1637
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1638
|
+
className: "max-w-screen-md w-full"
|
|
1639
|
+
}, /* @__PURE__ */ React.createElement("h3", {
|
|
1640
|
+
className: "text-4xl"
|
|
1641
|
+
}, "Welcome to Tina CMS."))), /* @__PURE__ */ React.createElement("div", {
|
|
1642
|
+
className: "w-full px-6 py-10 flex justify-center"
|
|
1643
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1644
|
+
className: "max-w-screen-md w-full"
|
|
1645
|
+
}, /* @__PURE__ */ React.createElement("p", {
|
|
1646
|
+
className: "text-gray-700 text-lg"
|
|
1647
|
+
}, "This is your dashboard for editing or creating content. Select a collection on the left to begin."))));
|
|
1648
|
+
};
|
|
1649
|
+
const useGetCollection = (cms, collectionName, includeDocuments = true) => {
|
|
1650
|
+
const [collection, setCollection] = useState(void 0);
|
|
1651
|
+
useEffect(() => {
|
|
1652
|
+
const fetchCollection = async () => {
|
|
1653
|
+
const response = await cms.api.tina.request(`
|
|
1654
|
+
query($collection: String!, $includeDocuments: Boolean!){
|
|
1655
|
+
getCollection(collection: $collection){
|
|
1656
|
+
name
|
|
1657
|
+
label
|
|
1658
|
+
format
|
|
1659
|
+
documents @include(if: $includeDocuments) {
|
|
1660
|
+
totalCount
|
|
1661
|
+
edges {
|
|
1662
|
+
node {
|
|
1663
|
+
... on Document {
|
|
1664
|
+
sys {
|
|
1665
|
+
breadcrumbs
|
|
1666
|
+
path
|
|
1667
|
+
basename
|
|
1668
|
+
relativePath
|
|
1669
|
+
filename
|
|
1670
|
+
extension
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
}`, { variables: { collection: collectionName, includeDocuments } });
|
|
1678
|
+
setCollection(response.getCollection);
|
|
1679
|
+
};
|
|
1680
|
+
fetchCollection();
|
|
1681
|
+
}, [cms, collectionName]);
|
|
1682
|
+
return collection;
|
|
1683
|
+
};
|
|
1684
|
+
const GetCollection = ({
|
|
1685
|
+
cms,
|
|
1686
|
+
collectionName,
|
|
1687
|
+
includeDocuments = true,
|
|
1688
|
+
children
|
|
1689
|
+
}) => {
|
|
1690
|
+
const collection = useGetCollection(cms, collectionName, includeDocuments);
|
|
1691
|
+
if (!collection) {
|
|
1692
|
+
return null;
|
|
1693
|
+
}
|
|
1694
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collection));
|
|
1695
|
+
};
|
|
1696
|
+
const CollectionListPage = () => {
|
|
1697
|
+
const location = useLocation();
|
|
1698
|
+
const { collectionName } = useParams();
|
|
1699
|
+
return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(GetCollection, {
|
|
1700
|
+
cms,
|
|
1701
|
+
collectionName,
|
|
1702
|
+
includeDocuments: true
|
|
1703
|
+
}, (collection) => {
|
|
1704
|
+
const totalCount = collection.documents.totalCount;
|
|
1705
|
+
const documents = collection.documents.edges;
|
|
1706
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1707
|
+
className: "px-6 py-14 h-screen overflow-y-auto flex justify-center"
|
|
1708
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1709
|
+
className: "max-w-screen-md w-full"
|
|
1710
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1711
|
+
className: "w-full flex justify-between items-end"
|
|
1712
|
+
}, /* @__PURE__ */ React.createElement("h3", {
|
|
1713
|
+
className: "text-3xl"
|
|
1714
|
+
}, collection.label), /* @__PURE__ */ React.createElement(Link, {
|
|
1715
|
+
to: `${location.pathname}/new`,
|
|
1716
|
+
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",
|
|
1717
|
+
style: { background: "#0084FF" }
|
|
1718
|
+
}, "Create New")), totalCount > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
1719
|
+
className: "mt-8 shadow overflow-hidden border-b border-gray-200 sm:rounded-lg"
|
|
1720
|
+
}, /* @__PURE__ */ React.createElement("table", {
|
|
1721
|
+
className: "min-w-full"
|
|
1722
|
+
}, /* @__PURE__ */ React.createElement("tbody", {
|
|
1723
|
+
className: "bg-white divide-y divide-gray-150"
|
|
1724
|
+
}, documents.map((document2) => /* @__PURE__ */ React.createElement("tr", {
|
|
1725
|
+
key: document2.node.sys.relativePath
|
|
1726
|
+
}, /* @__PURE__ */ React.createElement("td", {
|
|
1727
|
+
className: "px-6 py-2 whitespace-nowrap"
|
|
1728
|
+
}, /* @__PURE__ */ React.createElement(Link, {
|
|
1729
|
+
to: `${location.pathname}/${document2.node.sys.filename}`,
|
|
1730
|
+
className: "text-blue-600 hover:text-blue-400 flex items-center gap-3"
|
|
1731
|
+
}, /* @__PURE__ */ React.createElement(BiEdit, {
|
|
1732
|
+
className: "inline-block h-6 w-auto opacity-70"
|
|
1733
|
+
}), " ", /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", {
|
|
1734
|
+
className: "block text-xs text-gray-400 mb-1 uppercase"
|
|
1735
|
+
}, "Filename"), /* @__PURE__ */ React.createElement("span", {
|
|
1736
|
+
className: "h-5 leading-5 block whitespace-nowrap"
|
|
1737
|
+
}, document2.node.sys.filename)))), /* @__PURE__ */ React.createElement("td", {
|
|
1738
|
+
className: "px-6 py-4 whitespace-nowrap"
|
|
1739
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1740
|
+
className: "block text-xs text-gray-400 mb-1 uppercase"
|
|
1741
|
+
}, "Extension"), /* @__PURE__ */ React.createElement("span", {
|
|
1742
|
+
className: "h-5 leading-5 block text-sm font-medium text-gray-900"
|
|
1743
|
+
}, document2.node.sys.extension)))))))));
|
|
1744
|
+
}));
|
|
1745
|
+
};
|
|
1746
|
+
const useGetDocumentFields = (cms, collectionName) => {
|
|
1747
|
+
const [info, setInfo] = useState({
|
|
1748
|
+
collection: void 0,
|
|
1749
|
+
fields: void 0,
|
|
1750
|
+
mutationInfo: void 0
|
|
1751
|
+
});
|
|
1752
|
+
useEffect(() => {
|
|
1753
|
+
const fetchDocumentFields = async () => {
|
|
1754
|
+
const response = await cms.api.tina.request(`query { getDocumentFields }`, {});
|
|
1755
|
+
const documentFields = response.getDocumentFields;
|
|
1756
|
+
const collection = documentFields[collectionName].collection;
|
|
1757
|
+
const fields = documentFields[collectionName].fields;
|
|
1758
|
+
const mutationInfo = documentFields[collectionName].mutationInfo;
|
|
1759
|
+
setInfo({
|
|
1760
|
+
collection,
|
|
1761
|
+
fields,
|
|
1762
|
+
mutationInfo
|
|
1763
|
+
});
|
|
1764
|
+
};
|
|
1765
|
+
fetchDocumentFields();
|
|
1766
|
+
}, [cms, collectionName]);
|
|
1767
|
+
return info;
|
|
1768
|
+
};
|
|
1769
|
+
const GetDocumentFields = ({
|
|
1770
|
+
cms,
|
|
1771
|
+
collectionName,
|
|
1772
|
+
children
|
|
1773
|
+
}) => {
|
|
1774
|
+
const { collection, fields, mutationInfo } = useGetDocumentFields(cms, collectionName);
|
|
1775
|
+
if (!collection || !fields || !mutationInfo) {
|
|
1776
|
+
return null;
|
|
1777
|
+
}
|
|
1778
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collection, fields, mutationInfo));
|
|
1779
|
+
};
|
|
1780
|
+
const createDocument = async (cms, collection, mutationInfo, values) => {
|
|
1781
|
+
const _a = values, { relativePath } = _a, leftover = __objRest(_a, ["relativePath"]);
|
|
1782
|
+
const { includeCollection, includeTemplate } = mutationInfo;
|
|
1783
|
+
const params = transformDocumentIntoMutationRequestPayload(__spreadValues({
|
|
1784
|
+
_collection: collection.name
|
|
1785
|
+
}, leftover), {
|
|
1786
|
+
includeCollection,
|
|
1787
|
+
includeTemplate
|
|
1788
|
+
});
|
|
1789
|
+
await cms.api.tina.request(`mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
1790
|
+
createDocument(
|
|
1791
|
+
collection: $collection,
|
|
1792
|
+
relativePath: $relativePath,
|
|
1793
|
+
params: $params
|
|
1794
|
+
){__typename}
|
|
1795
|
+
}`, {
|
|
1796
|
+
variables: {
|
|
1797
|
+
collection: collection.name,
|
|
1798
|
+
relativePath,
|
|
1799
|
+
params
|
|
1800
|
+
}
|
|
1801
|
+
});
|
|
1802
|
+
};
|
|
1803
|
+
const CollectionCreatePage = () => {
|
|
1804
|
+
const { collectionName } = useParams();
|
|
1805
|
+
const history = useHistory();
|
|
1806
|
+
return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(GetDocumentFields, {
|
|
1807
|
+
cms,
|
|
1808
|
+
collectionName
|
|
1809
|
+
}, (collection, fields, mutationInfo) => {
|
|
1810
|
+
const form = new Form({
|
|
1811
|
+
id: "create-form",
|
|
1812
|
+
label: "form",
|
|
1813
|
+
fields: [
|
|
1814
|
+
{
|
|
1815
|
+
name: "relativePath",
|
|
1816
|
+
label: "Relative Path",
|
|
1817
|
+
component: "text",
|
|
1818
|
+
required: true,
|
|
1819
|
+
defaultValue: `${collection.name}${Date.now()}.${collection.format}`
|
|
1820
|
+
},
|
|
1821
|
+
...fields
|
|
1822
|
+
],
|
|
1823
|
+
onSubmit: async (values) => {
|
|
1824
|
+
await createDocument(cms, collection, mutationInfo, values);
|
|
1825
|
+
history.push(`/admin/collections/${collection.name}`);
|
|
1826
|
+
}
|
|
1827
|
+
});
|
|
1828
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1829
|
+
className: "w-full h-screen"
|
|
1830
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1831
|
+
className: "flex flex-col items-center w-full flex-1"
|
|
1832
|
+
}, /* @__PURE__ */ React.createElement(FullscreenFormBuilder, {
|
|
1833
|
+
label: collection.label + " - Create New",
|
|
1834
|
+
form
|
|
1835
|
+
})));
|
|
1836
|
+
}));
|
|
1837
|
+
};
|
|
1838
|
+
const useGetDocument = (cms, collectionName, relativePath) => {
|
|
1839
|
+
const [document2, setDocument] = useState(void 0);
|
|
1840
|
+
useEffect(() => {
|
|
1841
|
+
const fetchDocument = async () => {
|
|
1842
|
+
const response = await cms.api.tina.request(`
|
|
1843
|
+
query($collection: String!, $relativePath: String!) {
|
|
1844
|
+
getDocument(collection:$collection, relativePath:$relativePath) {
|
|
1845
|
+
... on Document {
|
|
1846
|
+
form
|
|
1847
|
+
values
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
}`, { variables: { collection: collectionName, relativePath } });
|
|
1851
|
+
setDocument(response.getDocument);
|
|
1852
|
+
};
|
|
1853
|
+
fetchDocument();
|
|
1854
|
+
}, [cms, collectionName, relativePath]);
|
|
1855
|
+
return document2;
|
|
1856
|
+
};
|
|
1857
|
+
const GetDocument = ({
|
|
1858
|
+
cms,
|
|
1859
|
+
collectionName,
|
|
1860
|
+
relativePath,
|
|
1861
|
+
children
|
|
1862
|
+
}) => {
|
|
1863
|
+
const document2 = useGetDocument(cms, collectionName, relativePath);
|
|
1864
|
+
if (!document2) {
|
|
1865
|
+
return null;
|
|
1866
|
+
}
|
|
1867
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(document2));
|
|
1868
|
+
};
|
|
1869
|
+
const updateDocument = async (cms, collection, document2, relativePath, values) => {
|
|
1870
|
+
const { includeCollection, includeTemplate } = document2.form.mutationInfo;
|
|
1871
|
+
const params = transformDocumentIntoMutationRequestPayload(values, {
|
|
1872
|
+
includeCollection,
|
|
1873
|
+
includeTemplate
|
|
1874
|
+
});
|
|
1875
|
+
await cms.api.tina.request(`mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
1876
|
+
updateDocument(
|
|
1877
|
+
collection: $collection,
|
|
1878
|
+
relativePath: $relativePath,
|
|
1879
|
+
params: $params
|
|
1880
|
+
){__typename}
|
|
1881
|
+
}`, {
|
|
1882
|
+
variables: {
|
|
1883
|
+
collection: collection.name,
|
|
1884
|
+
relativePath,
|
|
1885
|
+
params
|
|
1886
|
+
}
|
|
1887
|
+
});
|
|
1888
|
+
};
|
|
1889
|
+
const CollectionUpdatePage = () => {
|
|
1890
|
+
const { collectionName, filename } = useParams();
|
|
1891
|
+
const history = useHistory();
|
|
1892
|
+
return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(GetCollection, {
|
|
1893
|
+
cms,
|
|
1894
|
+
collectionName,
|
|
1895
|
+
includeDocuments: false
|
|
1896
|
+
}, (collection) => {
|
|
1897
|
+
const relativePath = `${filename}.${collection.format}`;
|
|
1898
|
+
return /* @__PURE__ */ React.createElement(GetDocument, {
|
|
1899
|
+
cms,
|
|
1900
|
+
collectionName: collection.name,
|
|
1901
|
+
relativePath
|
|
1902
|
+
}, (document2) => {
|
|
1903
|
+
const form = new Form({
|
|
1904
|
+
id: "update-form",
|
|
1905
|
+
label: "form",
|
|
1906
|
+
fields: document2.form.fields,
|
|
1907
|
+
initialValues: document2.values,
|
|
1908
|
+
onSubmit: async (values) => {
|
|
1909
|
+
await updateDocument(cms, collection, document2, relativePath, values);
|
|
1910
|
+
history.push(`/admin/collections/${collection.name}`);
|
|
1911
|
+
}
|
|
1912
|
+
});
|
|
1913
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1914
|
+
className: "w-full h-screen"
|
|
1915
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1916
|
+
className: "flex flex-col items-center w-full flex-1"
|
|
1917
|
+
}, /* @__PURE__ */ React.createElement(FullscreenFormBuilder, {
|
|
1918
|
+
label: collection.label + ` - ` + filename,
|
|
1919
|
+
form
|
|
1920
|
+
})));
|
|
1921
|
+
});
|
|
1922
|
+
}));
|
|
1923
|
+
};
|
|
1924
|
+
const useEmbedTailwind = () => {
|
|
1925
|
+
useEffect(() => {
|
|
1926
|
+
const isSSR2 = typeof window === "undefined";
|
|
1927
|
+
if (!isSSR2) {
|
|
1928
|
+
const head = document.head;
|
|
1929
|
+
const link = document.createElement("link");
|
|
1930
|
+
link.id = "tina-admin-stylesheet";
|
|
1931
|
+
link.type = "text/css";
|
|
1932
|
+
link.rel = "stylesheet";
|
|
1933
|
+
link.href = "https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css";
|
|
1934
|
+
head.appendChild(link);
|
|
1935
|
+
}
|
|
1936
|
+
}, []);
|
|
1937
|
+
};
|
|
1938
|
+
const logout = () => {
|
|
1939
|
+
setEditing(false);
|
|
1940
|
+
window.location.reload();
|
|
1941
|
+
};
|
|
1942
|
+
const TinaAdmin = () => {
|
|
1943
|
+
useEmbedTailwind();
|
|
1944
|
+
const isSSR2 = typeof window === "undefined";
|
|
1945
|
+
if (isSSR2) {
|
|
1946
|
+
return null;
|
|
1947
|
+
}
|
|
1948
|
+
const isEdit = isEditing();
|
|
1949
|
+
if (!isEdit) {
|
|
1950
|
+
return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(LoginPage, null));
|
|
1951
|
+
}
|
|
1952
|
+
return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(GetCollections, {
|
|
1953
|
+
cms
|
|
1954
|
+
}, (collections) => /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(BrowserRouter, null, /* @__PURE__ */ React.createElement("div", {
|
|
1955
|
+
className: "flex items-stretch h-screen overflow-hidden"
|
|
1956
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1957
|
+
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"
|
|
1958
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1959
|
+
className: "border-b border-gray-200"
|
|
1960
|
+
}, /* @__PURE__ */ React.createElement(Menu, {
|
|
1961
|
+
as: "div",
|
|
1962
|
+
className: "relative block"
|
|
1963
|
+
}, ({ open }) => /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Menu.Button, {
|
|
1964
|
+
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`}`
|
|
1965
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
1966
|
+
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"
|
|
1967
|
+
}, /* @__PURE__ */ React.createElement("svg", {
|
|
1968
|
+
viewBox: "0 0 32 32",
|
|
1969
|
+
fill: "#EC4815",
|
|
1970
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1971
|
+
className: "w-10 h-auto -ml-1"
|
|
1972
|
+
}, /* @__PURE__ */ React.createElement("path", {
|
|
1973
|
+
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"
|
|
1974
|
+
}), /* @__PURE__ */ React.createElement("path", {
|
|
1975
|
+
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"
|
|
1976
|
+
})), /* @__PURE__ */ React.createElement("span", null, "Tina Admin")), /* @__PURE__ */ React.createElement("svg", {
|
|
1977
|
+
width: "20",
|
|
1978
|
+
height: "20",
|
|
1979
|
+
viewBox: "0 0 20 20",
|
|
1980
|
+
fill: "none",
|
|
1981
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1982
|
+
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`}`
|
|
1983
|
+
}, /* @__PURE__ */ React.createElement("g", {
|
|
1984
|
+
opacity: "0.3"
|
|
1985
|
+
}, /* @__PURE__ */ React.createElement("path", {
|
|
1986
|
+
d: "M7.91675 13.8086L9.16675 15.0586L14.2253 10L9.16675 4.9414L7.91675 6.1914L11.7253 10L7.91675 13.8086Z",
|
|
1987
|
+
fill: "currentColor"
|
|
1988
|
+
})))), /* @__PURE__ */ React.createElement("div", {
|
|
1989
|
+
className: "transform translate-y-full absolute bottom-3 right-5 w-2/3 z-50"
|
|
1990
|
+
}, /* @__PURE__ */ React.createElement(Transition, {
|
|
1991
|
+
enter: "transition duration-150 ease-out",
|
|
1992
|
+
enterFrom: "transform opacity-0 -translate-y-2",
|
|
1993
|
+
enterTo: "transform opacity-100 translate-y-0",
|
|
1994
|
+
leave: "transition duration-75 ease-in",
|
|
1995
|
+
leaveFrom: "transform opacity-100 translate-y-0",
|
|
1996
|
+
leaveTo: "transform opacity-0 -translate-y-2"
|
|
1997
|
+
}, /* @__PURE__ */ React.createElement(Menu.Items, {
|
|
1998
|
+
className: "w-full py-1 bg-white border border-gray-150 rounded-lg shadow-lg"
|
|
1999
|
+
}, /* @__PURE__ */ React.createElement(Menu.Item, null, ({ active }) => /* @__PURE__ */ React.createElement("a", {
|
|
2000
|
+
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"}`,
|
|
2001
|
+
href: "/"
|
|
2002
|
+
}, /* @__PURE__ */ React.createElement(VscOpenPreview, {
|
|
2003
|
+
className: "w-6 h-auto mr-1.5 text-blue-400"
|
|
2004
|
+
}), " ", "View Website")), /* @__PURE__ */ React.createElement(Menu.Item, null, ({ active }) => /* @__PURE__ */ React.createElement("button", {
|
|
2005
|
+
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"}`,
|
|
2006
|
+
onClick: () => logout()
|
|
2007
|
+
}, /* @__PURE__ */ React.createElement(BiExit, {
|
|
2008
|
+
className: "w-6 h-auto mr-1.5 text-blue-400"
|
|
2009
|
+
}), " ", "Log out")))))))), /* @__PURE__ */ React.createElement("div", {
|
|
2010
|
+
className: "px-6 py-7 flex-1"
|
|
2011
|
+
}, /* @__PURE__ */ React.createElement("h4", {
|
|
2012
|
+
className: "uppercase font-bold text-sm mb-3"
|
|
2013
|
+
}, "Collections"), /* @__PURE__ */ React.createElement("ul", {
|
|
2014
|
+
className: "flex flex-col gap-4"
|
|
2015
|
+
}, collections.map((collection) => {
|
|
2016
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
2017
|
+
key: `${collection.name}-link`
|
|
2018
|
+
}, /* @__PURE__ */ React.createElement(NavLink, {
|
|
2019
|
+
className: `text-lg tracking-wide hover:text-blue-600 flex items-center opacity-90 hover:opacity-100`,
|
|
2020
|
+
activeClassName: "text-blue-600",
|
|
2021
|
+
to: `/admin/collections/${collection.name}`
|
|
2022
|
+
}, /* @__PURE__ */ React.createElement(ImFilesEmpty, {
|
|
2023
|
+
className: "mr-2 h-6 opacity-80 w-auto"
|
|
2024
|
+
}), " ", collection.label));
|
|
2025
|
+
})))), /* @__PURE__ */ React.createElement("div", {
|
|
2026
|
+
className: "flex-1"
|
|
2027
|
+
}, /* @__PURE__ */ React.createElement(Switch, null, /* @__PURE__ */ React.createElement(Route, {
|
|
2028
|
+
path: `/admin/collections/:collectionName/new`
|
|
2029
|
+
}, /* @__PURE__ */ React.createElement(CollectionCreatePage, null)), /* @__PURE__ */ React.createElement(Route, {
|
|
2030
|
+
path: `/admin/collections/:collectionName/:filename`
|
|
2031
|
+
}, /* @__PURE__ */ React.createElement(CollectionUpdatePage, null)), /* @__PURE__ */ React.createElement(Route, {
|
|
2032
|
+
path: `/admin/collections/:collectionName`
|
|
2033
|
+
}, /* @__PURE__ */ React.createElement(CollectionListPage, null)), /* @__PURE__ */ React.createElement(Route, {
|
|
2034
|
+
path: `/admin`
|
|
2035
|
+
}, /* @__PURE__ */ React.createElement(DashboardPage, null)))))))));
|
|
2036
|
+
};
|
|
2037
|
+
export { AuthWallInner, Client, DEFAULT_LOCAL_TINA_GQL_SERVER_URL, LocalClient, TinaAdmin, TinaCMSProvider2, TinaCloudAuthWall, TinaCloudProvider, assertShape, createClient, TinaCMSProvider2 as default, getStaticPropsForTina, gql, safeAssertShape, staticRequest, useDocumentCreatorPlugin, useGraphqlForms, useTinaAuthRedirect };
|