tinacms 0.57.1 → 0.58.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 +36 -0
- package/dist/admin/components/GetCollection.d.ts +7 -0
- package/dist/admin/components/GetDocumentFields.d.ts +6 -3
- package/dist/admin/plugins/route-mapping.d.ts +32 -0
- package/dist/auth/TinaCloudProvider.d.ts +1 -1
- package/dist/edit-state.es.js +3 -0
- package/dist/edit-state.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +289 -163
- package/dist/index.js +287 -160
- package/dist/tina-cms.d.ts +2 -2
- package/dist/utils/client.d.ts +29 -0
- package/package.json +6 -9
package/dist/index.js
CHANGED
|
@@ -767,8 +767,14 @@ mutation addPendingDocumentMutation(
|
|
|
767
767
|
cms.api.tina = createClient(props);
|
|
768
768
|
}
|
|
769
769
|
const setupMedia = async () => {
|
|
770
|
+
var _a;
|
|
770
771
|
if (props.mediaStore) {
|
|
771
|
-
|
|
772
|
+
if ((_a = props.mediaStore.prototype) == null ? void 0 : _a.persist) {
|
|
773
|
+
cms.media.store = new props.mediaStore(cms.api.tina);
|
|
774
|
+
} else {
|
|
775
|
+
const MediaClass = await props.mediaStore();
|
|
776
|
+
cms.media.store = new MediaClass(cms.api.tina);
|
|
777
|
+
}
|
|
772
778
|
}
|
|
773
779
|
};
|
|
774
780
|
const handleListBranches = async () => {
|
|
@@ -815,6 +821,91 @@ mutation addPendingDocumentMutation(
|
|
|
815
821
|
})));
|
|
816
822
|
};
|
|
817
823
|
const TinaCloudAuthWall = TinaCloudProvider;
|
|
824
|
+
var DefaultContext = {
|
|
825
|
+
color: void 0,
|
|
826
|
+
size: void 0,
|
|
827
|
+
className: void 0,
|
|
828
|
+
style: void 0,
|
|
829
|
+
attr: void 0
|
|
830
|
+
};
|
|
831
|
+
var IconContext = React__default["default"].createContext && React__default["default"].createContext(DefaultContext);
|
|
832
|
+
var __assign = function() {
|
|
833
|
+
__assign = Object.assign || function(t) {
|
|
834
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
835
|
+
s = arguments[i];
|
|
836
|
+
for (var p in s)
|
|
837
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
838
|
+
t[p] = s[p];
|
|
839
|
+
}
|
|
840
|
+
return t;
|
|
841
|
+
};
|
|
842
|
+
return __assign.apply(this, arguments);
|
|
843
|
+
};
|
|
844
|
+
var __rest = function(s, e) {
|
|
845
|
+
var t = {};
|
|
846
|
+
for (var p in s)
|
|
847
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
848
|
+
t[p] = s[p];
|
|
849
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
850
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
851
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
852
|
+
t[p[i]] = s[p[i]];
|
|
853
|
+
}
|
|
854
|
+
return t;
|
|
855
|
+
};
|
|
856
|
+
function Tree2Element(tree) {
|
|
857
|
+
return tree && tree.map(function(node, i) {
|
|
858
|
+
return React__default["default"].createElement(node.tag, __assign({
|
|
859
|
+
key: i
|
|
860
|
+
}, node.attr), Tree2Element(node.child));
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
function GenIcon(data) {
|
|
864
|
+
return function(props) {
|
|
865
|
+
return React__default["default"].createElement(IconBase, __assign({
|
|
866
|
+
attr: __assign({}, data.attr)
|
|
867
|
+
}, props), Tree2Element(data.child));
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
function IconBase(props) {
|
|
871
|
+
var elem = function(conf) {
|
|
872
|
+
var attr = props.attr, size = props.size, title = props.title, svgProps = __rest(props, ["attr", "size", "title"]);
|
|
873
|
+
var computedSize = size || conf.size || "1em";
|
|
874
|
+
var className;
|
|
875
|
+
if (conf.className)
|
|
876
|
+
className = conf.className;
|
|
877
|
+
if (props.className)
|
|
878
|
+
className = (className ? className + " " : "") + props.className;
|
|
879
|
+
return React__default["default"].createElement("svg", __assign({
|
|
880
|
+
stroke: "currentColor",
|
|
881
|
+
fill: "currentColor",
|
|
882
|
+
strokeWidth: "0"
|
|
883
|
+
}, conf.attr, attr, svgProps, {
|
|
884
|
+
className,
|
|
885
|
+
style: __assign(__assign({
|
|
886
|
+
color: props.color || conf.color
|
|
887
|
+
}, conf.style), props.style),
|
|
888
|
+
height: computedSize,
|
|
889
|
+
width: computedSize,
|
|
890
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
891
|
+
}), title && React__default["default"].createElement("title", null, title), props.children);
|
|
892
|
+
};
|
|
893
|
+
return IconContext !== void 0 ? React__default["default"].createElement(IconContext.Consumer, null, function(conf) {
|
|
894
|
+
return elem(conf);
|
|
895
|
+
}) : elem(DefaultContext);
|
|
896
|
+
}
|
|
897
|
+
function BiEdit(props) {
|
|
898
|
+
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);
|
|
899
|
+
}
|
|
900
|
+
function BiExit(props) {
|
|
901
|
+
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);
|
|
902
|
+
}
|
|
903
|
+
function BiLinkExternal(props) {
|
|
904
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "m13 3 3.293 3.293-7 7 1.414 1.414 7-7L21 11V3z" } }, { "tag": "path", "attr": { "d": "M19 19H5V5h7l-2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2v-5l-2-2v7z" } }] })(props);
|
|
905
|
+
}
|
|
906
|
+
function BiLogIn(props) {
|
|
907
|
+
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);
|
|
908
|
+
}
|
|
818
909
|
function useGraphqlForms({
|
|
819
910
|
query,
|
|
820
911
|
variables,
|
|
@@ -828,7 +919,6 @@ mutation addPendingDocumentMutation(
|
|
|
828
919
|
const [pendingReset, setPendingReset] = React__default["default"].useState(null);
|
|
829
920
|
const [isLoading, setIsLoading] = React__default["default"].useState(true);
|
|
830
921
|
const [newUpdate, setNewUpdate] = React__default["default"].useState(null);
|
|
831
|
-
React__default["default"].useState([]);
|
|
832
922
|
const updateData = async () => {
|
|
833
923
|
var _a;
|
|
834
924
|
if (newUpdate) {
|
|
@@ -877,12 +967,15 @@ mutation addPendingDocumentMutation(
|
|
|
877
967
|
}
|
|
878
968
|
}, [pendingReset]);
|
|
879
969
|
React__default["default"].useEffect(() => {
|
|
970
|
+
const formIds = [];
|
|
880
971
|
setIsLoading(true);
|
|
881
972
|
cms.api.tina.requestWithForm(query, { variables }).then((payload) => {
|
|
973
|
+
cms.plugins.remove(new toolkit.FormMetaPlugin({ name: "tina-admin-link" }));
|
|
882
974
|
setData(payload);
|
|
883
975
|
setInitialData(payload);
|
|
884
976
|
setIsLoading(false);
|
|
885
977
|
Object.entries(payload).map(([queryName, result]) => {
|
|
978
|
+
formIds.push(queryName);
|
|
886
979
|
const canBeFormified = safeAssertShape(result, (yup2) => yup2.object({
|
|
887
980
|
values: yup2.object().required(),
|
|
888
981
|
form: yup2.object().required()
|
|
@@ -894,6 +987,32 @@ mutation addPendingDocumentMutation(
|
|
|
894
987
|
values: yup2.object().required(),
|
|
895
988
|
form: yup2.object().required()
|
|
896
989
|
}), `Unable to build form shape for fields at ${queryName}`);
|
|
990
|
+
if (cms.flags.get("tina-admin")) {
|
|
991
|
+
const TinaAdminLink = new toolkit.FormMetaPlugin({
|
|
992
|
+
name: "tina-admin-link",
|
|
993
|
+
Component: () => /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
994
|
+
href: `/admin/collections/${result._internalSys.collection.name}/${result._internalSys.filename}`,
|
|
995
|
+
style: {
|
|
996
|
+
display: "flex",
|
|
997
|
+
alignItems: "center",
|
|
998
|
+
padding: "10px 20px",
|
|
999
|
+
borderTop: "1px solid var(--tina-color-grey-2)",
|
|
1000
|
+
textTransform: "uppercase",
|
|
1001
|
+
fontSize: "11px",
|
|
1002
|
+
fontWeight: 500,
|
|
1003
|
+
background: "var(--tina-color-grey-0)"
|
|
1004
|
+
}
|
|
1005
|
+
}, /* @__PURE__ */ React__default["default"].createElement(BiLinkExternal, {
|
|
1006
|
+
style: {
|
|
1007
|
+
height: "1.25em",
|
|
1008
|
+
width: "auto",
|
|
1009
|
+
opacity: "0.8",
|
|
1010
|
+
marginRight: "8px"
|
|
1011
|
+
}
|
|
1012
|
+
}), " ", "Edit in Tina Admin")
|
|
1013
|
+
});
|
|
1014
|
+
cms.plugins.add(TinaAdminLink);
|
|
1015
|
+
}
|
|
897
1016
|
const formConfig = {
|
|
898
1017
|
id: queryName,
|
|
899
1018
|
label: result.form.label,
|
|
@@ -1002,6 +1121,14 @@ mutation addPendingDocumentMutation(
|
|
|
1002
1121
|
console.error(e);
|
|
1003
1122
|
setIsLoading(false);
|
|
1004
1123
|
});
|
|
1124
|
+
return () => {
|
|
1125
|
+
formIds.forEach((name) => {
|
|
1126
|
+
const formPlugin = cms.forms.find(name);
|
|
1127
|
+
if (formPlugin) {
|
|
1128
|
+
cms.forms.remove(formPlugin);
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
};
|
|
1005
1132
|
}, [queryString, JSON.stringify(variables)]);
|
|
1006
1133
|
return [data, isLoading];
|
|
1007
1134
|
}
|
|
@@ -1475,81 +1602,12 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1475
1602
|
}
|
|
1476
1603
|
return client.request(query, { variables });
|
|
1477
1604
|
};
|
|
1478
|
-
function gql(strings) {
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
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));
|
|
1605
|
+
function gql(strings, ...args) {
|
|
1606
|
+
let str = "";
|
|
1607
|
+
strings.forEach((string, i) => {
|
|
1608
|
+
str += string + (args[i] || "");
|
|
1518
1609
|
});
|
|
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);
|
|
1610
|
+
return str;
|
|
1553
1611
|
}
|
|
1554
1612
|
function ImFilesEmpty(props) {
|
|
1555
1613
|
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);
|
|
@@ -1596,15 +1654,6 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1596
1654
|
return null;
|
|
1597
1655
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collections));
|
|
1598
1656
|
};
|
|
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
1657
|
function MdOutlineArrowBack(props) {
|
|
1609
1658
|
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
1659
|
}
|
|
@@ -1677,12 +1726,14 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1677
1726
|
name
|
|
1678
1727
|
label
|
|
1679
1728
|
format
|
|
1729
|
+
templates
|
|
1680
1730
|
documents @include(if: $includeDocuments) {
|
|
1681
1731
|
totalCount
|
|
1682
1732
|
edges {
|
|
1683
1733
|
node {
|
|
1684
1734
|
... on Document {
|
|
1685
1735
|
sys {
|
|
1736
|
+
template
|
|
1686
1737
|
breadcrumbs
|
|
1687
1738
|
path
|
|
1688
1739
|
basename
|
|
@@ -1714,59 +1765,119 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1714
1765
|
}
|
|
1715
1766
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collection));
|
|
1716
1767
|
};
|
|
1768
|
+
const TemplateMenu = ({ templates }) => {
|
|
1769
|
+
return /* @__PURE__ */ React__default["default"].createElement(react.Menu, {
|
|
1770
|
+
as: "div",
|
|
1771
|
+
className: "relative inline-block text-left"
|
|
1772
|
+
}, ({ open }) => /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Button, {
|
|
1773
|
+
className: "inline-flex items-center px-8 py-2.5 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",
|
|
1774
|
+
style: { background: "#0084FF" }
|
|
1775
|
+
}, "Create New", /* @__PURE__ */ React__default["default"].createElement("svg", {
|
|
1776
|
+
width: "20",
|
|
1777
|
+
height: "20",
|
|
1778
|
+
viewBox: "0 0 20 20",
|
|
1779
|
+
fill: "none",
|
|
1780
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1781
|
+
className: `ml-1 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`}`
|
|
1782
|
+
}, /* @__PURE__ */ React__default["default"].createElement("g", {
|
|
1783
|
+
opacity: "1.0"
|
|
1784
|
+
}, /* @__PURE__ */ React__default["default"].createElement("path", {
|
|
1785
|
+
d: "M7.91675 13.8086L9.16675 15.0586L14.2253 10L9.16675 4.9414L7.91675 6.1914L11.7253 10L7.91675 13.8086Z",
|
|
1786
|
+
fill: "currentColor"
|
|
1787
|
+
}))))), /* @__PURE__ */ React__default["default"].createElement(react.Transition, {
|
|
1788
|
+
as: React.Fragment,
|
|
1789
|
+
enter: "transition ease-out duration-100",
|
|
1790
|
+
enterFrom: "transform opacity-0 scale-95",
|
|
1791
|
+
enterTo: "transform opacity-100 scale-100",
|
|
1792
|
+
leave: "transition ease-in duration-75",
|
|
1793
|
+
leaveFrom: "transform opacity-100 scale-100",
|
|
1794
|
+
leaveTo: "transform opacity-0 scale-95"
|
|
1795
|
+
}, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Items, {
|
|
1796
|
+
className: "origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none"
|
|
1797
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1798
|
+
className: "py-1"
|
|
1799
|
+
}, templates.map((template) => /* @__PURE__ */ React__default["default"].createElement(react.Menu.Item, {
|
|
1800
|
+
key: `${template.label}-${template.name}`
|
|
1801
|
+
}, ({ active }) => /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1802
|
+
to: `${location.pathname}/${template.name}/new`,
|
|
1803
|
+
className: `w-full text-md px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`
|
|
1804
|
+
}, template.label))))))));
|
|
1805
|
+
};
|
|
1717
1806
|
const CollectionListPage = () => {
|
|
1718
|
-
const
|
|
1807
|
+
const location2 = reactRouterDom.useLocation();
|
|
1719
1808
|
const { collectionName } = reactRouterDom.useParams();
|
|
1720
|
-
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) =>
|
|
1721
|
-
cms
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1809
|
+
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => {
|
|
1810
|
+
const plugins = cms.plugins.all("tina-admin");
|
|
1811
|
+
const routeMapping = plugins.find(({ name }) => name === "route-mapping");
|
|
1812
|
+
return /* @__PURE__ */ React__default["default"].createElement(GetCollection, {
|
|
1813
|
+
cms,
|
|
1814
|
+
collectionName,
|
|
1815
|
+
includeDocuments: true
|
|
1816
|
+
}, (collection) => {
|
|
1817
|
+
const totalCount = collection.documents.totalCount;
|
|
1818
|
+
const documents = collection.documents.edges;
|
|
1819
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1820
|
+
className: "px-6 py-14 h-screen overflow-y-auto flex justify-center"
|
|
1821
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1822
|
+
className: "max-w-screen-md w-full"
|
|
1823
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1824
|
+
className: "w-full flex justify-between items-end"
|
|
1825
|
+
}, /* @__PURE__ */ React__default["default"].createElement("h3", {
|
|
1826
|
+
className: "text-3xl"
|
|
1827
|
+
}, collection.label), !collection.templates && /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1828
|
+
to: `${location2.pathname}/new`,
|
|
1829
|
+
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",
|
|
1830
|
+
style: { background: "#0084FF" }
|
|
1831
|
+
}, "Create New"), collection.templates && /* @__PURE__ */ React__default["default"].createElement(TemplateMenu, {
|
|
1832
|
+
templates: collection.templates
|
|
1833
|
+
})), totalCount > 0 && /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1834
|
+
className: "mt-8 shadow overflow-hidden border-b border-gray-200 sm:rounded-lg"
|
|
1835
|
+
}, /* @__PURE__ */ React__default["default"].createElement("table", {
|
|
1836
|
+
className: "min-w-full"
|
|
1837
|
+
}, /* @__PURE__ */ React__default["default"].createElement("tbody", {
|
|
1838
|
+
className: "bg-white divide-y divide-gray-150"
|
|
1839
|
+
}, documents.map((document2) => {
|
|
1840
|
+
const livesiteRoute = routeMapping ? routeMapping.mapper(collection, document2.node) : void 0;
|
|
1841
|
+
return /* @__PURE__ */ React__default["default"].createElement("tr", {
|
|
1842
|
+
key: document2.node.sys.relativePath
|
|
1843
|
+
}, /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
1844
|
+
className: "px-5 py-3 whitespace-nowrap"
|
|
1845
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1846
|
+
className: "block text-xs mb-0.5 text-gray-400 uppercase"
|
|
1847
|
+
}, "Filename"), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1848
|
+
to: `${location2.pathname}/${document2.node.sys.filename}`,
|
|
1849
|
+
className: "h-5 leading-5 block"
|
|
1850
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1851
|
+
className: "leading-5 font-medium text-base overflow-ellipsis overflow-hidden whitespace-nowrap text-gray-700"
|
|
1852
|
+
}, document2.node.sys.filename), /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1853
|
+
className: "leading-5 text-base font-medium text-gray-300"
|
|
1854
|
+
}, document2.node.sys.extension))), /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
1855
|
+
className: "px-5 py-3 whitespace-nowrap"
|
|
1856
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1857
|
+
className: "block text-xs mb-0.5 text-gray-400 uppercase"
|
|
1858
|
+
}, "Template"), /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1859
|
+
className: "h-5 block leading-5 font-regular text-base overflow-ellipsis overflow-hidden whitespace-nowrap text-gray-500"
|
|
1860
|
+
}, document2.node.sys.template)), /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
1861
|
+
className: "px-5 py-3 whitespace-nowrap flex gap-3 items-center justify-end"
|
|
1862
|
+
}, livesiteRoute && /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
1863
|
+
href: livesiteRoute,
|
|
1864
|
+
className: "flex gap-1.5 items-center px-4 py-1.5 rounded-full transition-all ease-out duration-150 text-gray-500 hover:text-blue-500"
|
|
1865
|
+
}, /* @__PURE__ */ React__default["default"].createElement(BiLinkExternal, {
|
|
1866
|
+
className: "inline-block h-5 w-auto opacity-70"
|
|
1867
|
+
}), " ", "View"), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1868
|
+
to: `${location2.pathname}/${document2.node.sys.filename}`,
|
|
1869
|
+
className: "flex gap-1.5 items-center px-4 py-1.5 rounded-full border border-gray-150 transition-all ease-out duration-150 text-gray-700 hover:bg-gray-50 hover:text-blue-500"
|
|
1870
|
+
}, /* @__PURE__ */ React__default["default"].createElement(BiEdit, {
|
|
1871
|
+
className: "inline-block h-5 w-auto opacity-70"
|
|
1872
|
+
}), " ", "Edit")));
|
|
1873
|
+
}))))));
|
|
1874
|
+
});
|
|
1875
|
+
});
|
|
1766
1876
|
};
|
|
1767
|
-
const useGetDocumentFields = (cms, collectionName) => {
|
|
1877
|
+
const useGetDocumentFields = (cms, collectionName, templateName) => {
|
|
1768
1878
|
const [info, setInfo] = React.useState({
|
|
1769
1879
|
collection: void 0,
|
|
1880
|
+
template: void 0,
|
|
1770
1881
|
fields: void 0,
|
|
1771
1882
|
mutationInfo: void 0
|
|
1772
1883
|
});
|
|
@@ -1775,10 +1886,18 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1775
1886
|
const response = await cms.api.tina.request(`query { getDocumentFields }`, {});
|
|
1776
1887
|
const documentFields = response.getDocumentFields;
|
|
1777
1888
|
const collection = documentFields[collectionName].collection;
|
|
1778
|
-
const fields = documentFields[collectionName].fields;
|
|
1779
1889
|
const mutationInfo = documentFields[collectionName].mutationInfo;
|
|
1890
|
+
let fields = void 0;
|
|
1891
|
+
let template = void 0;
|
|
1892
|
+
if (templateName && documentFields[collectionName].templates && documentFields[collectionName].templates[templateName]) {
|
|
1893
|
+
template = documentFields[collectionName].templates[templateName].template;
|
|
1894
|
+
fields = documentFields[collectionName].templates[templateName].fields;
|
|
1895
|
+
} else {
|
|
1896
|
+
fields = documentFields[collectionName].fields;
|
|
1897
|
+
}
|
|
1780
1898
|
setInfo({
|
|
1781
1899
|
collection,
|
|
1900
|
+
template,
|
|
1782
1901
|
fields,
|
|
1783
1902
|
mutationInfo
|
|
1784
1903
|
});
|
|
@@ -1790,44 +1909,44 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1790
1909
|
const GetDocumentFields = ({
|
|
1791
1910
|
cms,
|
|
1792
1911
|
collectionName,
|
|
1912
|
+
templateName,
|
|
1793
1913
|
children
|
|
1794
1914
|
}) => {
|
|
1795
|
-
const { collection, fields, mutationInfo } = useGetDocumentFields(cms, collectionName);
|
|
1796
|
-
if (!collection
|
|
1915
|
+
const { collection, template, fields, mutationInfo } = useGetDocumentFields(cms, collectionName, templateName);
|
|
1916
|
+
if (!collection) {
|
|
1797
1917
|
return null;
|
|
1798
1918
|
}
|
|
1799
|
-
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collection, fields, mutationInfo));
|
|
1919
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children({ collection, template, fields, mutationInfo }));
|
|
1800
1920
|
};
|
|
1801
|
-
const createDocument = async (cms, collection, mutationInfo, values) => {
|
|
1921
|
+
const createDocument = async (cms, collection, template, mutationInfo, values) => {
|
|
1802
1922
|
const _a = values, { relativePath } = _a, leftover = __objRest(_a, ["relativePath"]);
|
|
1803
1923
|
const { includeCollection, includeTemplate } = mutationInfo;
|
|
1804
|
-
const params = transformDocumentIntoMutationRequestPayload(__spreadValues({
|
|
1924
|
+
const params = transformDocumentIntoMutationRequestPayload(__spreadValues(__spreadValues({
|
|
1805
1925
|
_collection: collection.name
|
|
1806
|
-
}, leftover), {
|
|
1926
|
+
}, template && { _template: template.name }), leftover), {
|
|
1807
1927
|
includeCollection,
|
|
1808
1928
|
includeTemplate
|
|
1809
1929
|
});
|
|
1810
|
-
await cms.api.tina.request(`mutation($
|
|
1811
|
-
createDocument(
|
|
1812
|
-
collection: $collection,
|
|
1930
|
+
await cms.api.tina.request(`mutation($relativePath: String!, $params: DocumentMutation!) {
|
|
1931
|
+
createDocument(
|
|
1813
1932
|
relativePath: $relativePath,
|
|
1814
1933
|
params: $params
|
|
1815
1934
|
){__typename}
|
|
1816
1935
|
}`, {
|
|
1817
1936
|
variables: {
|
|
1818
|
-
collection: collection.name,
|
|
1819
1937
|
relativePath,
|
|
1820
1938
|
params
|
|
1821
1939
|
}
|
|
1822
1940
|
});
|
|
1823
1941
|
};
|
|
1824
1942
|
const CollectionCreatePage = () => {
|
|
1825
|
-
const { collectionName } = reactRouterDom.useParams();
|
|
1943
|
+
const { collectionName, templateName } = reactRouterDom.useParams();
|
|
1826
1944
|
const history = reactRouterDom.useHistory();
|
|
1827
1945
|
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetDocumentFields, {
|
|
1828
1946
|
cms,
|
|
1829
|
-
collectionName
|
|
1830
|
-
|
|
1947
|
+
collectionName,
|
|
1948
|
+
templateName
|
|
1949
|
+
}, ({ collection, template, fields, mutationInfo }) => {
|
|
1831
1950
|
const form = new toolkit.Form({
|
|
1832
1951
|
id: "create-form",
|
|
1833
1952
|
label: "form",
|
|
@@ -1842,16 +1961,17 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1842
1961
|
...fields
|
|
1843
1962
|
],
|
|
1844
1963
|
onSubmit: async (values) => {
|
|
1845
|
-
await createDocument(cms, collection, mutationInfo, values);
|
|
1964
|
+
await createDocument(cms, collection, template, mutationInfo, values);
|
|
1846
1965
|
history.push(`/admin/collections/${collection.name}`);
|
|
1847
1966
|
}
|
|
1848
1967
|
});
|
|
1968
|
+
const formLabel = template ? `${collection.label} - Create New ${template.label}` : `${collection.label} - Create New`;
|
|
1849
1969
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1850
1970
|
className: "w-full h-screen"
|
|
1851
1971
|
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1852
1972
|
className: "flex flex-col items-center w-full flex-1"
|
|
1853
1973
|
}, /* @__PURE__ */ React__default["default"].createElement(toolkit.FullscreenFormBuilder, {
|
|
1854
|
-
label:
|
|
1974
|
+
label: formLabel,
|
|
1855
1975
|
form
|
|
1856
1976
|
})));
|
|
1857
1977
|
}));
|
|
@@ -1887,21 +2007,19 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1887
2007
|
}
|
|
1888
2008
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(document2));
|
|
1889
2009
|
};
|
|
1890
|
-
const updateDocument = async (cms,
|
|
1891
|
-
const { includeCollection, includeTemplate } =
|
|
2010
|
+
const updateDocument = async (cms, relativePath, mutationInfo, values) => {
|
|
2011
|
+
const { includeCollection, includeTemplate } = mutationInfo;
|
|
1892
2012
|
const params = transformDocumentIntoMutationRequestPayload(values, {
|
|
1893
2013
|
includeCollection,
|
|
1894
2014
|
includeTemplate
|
|
1895
2015
|
});
|
|
1896
|
-
await cms.api.tina.request(`mutation($
|
|
1897
|
-
updateDocument(
|
|
1898
|
-
collection: $collection,
|
|
2016
|
+
await cms.api.tina.request(`mutation($relativePath: String!, $params: DocumentMutation!) {
|
|
2017
|
+
updateDocument(
|
|
1899
2018
|
relativePath: $relativePath,
|
|
1900
2019
|
params: $params
|
|
1901
2020
|
){__typename}
|
|
1902
2021
|
}`, {
|
|
1903
2022
|
variables: {
|
|
1904
|
-
collection: collection.name,
|
|
1905
2023
|
relativePath,
|
|
1906
2024
|
params
|
|
1907
2025
|
}
|
|
@@ -1910,11 +2028,10 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1910
2028
|
const CollectionUpdatePage = () => {
|
|
1911
2029
|
const { collectionName, filename } = reactRouterDom.useParams();
|
|
1912
2030
|
const history = reactRouterDom.useHistory();
|
|
1913
|
-
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(
|
|
2031
|
+
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetDocumentFields, {
|
|
1914
2032
|
cms,
|
|
1915
|
-
collectionName
|
|
1916
|
-
|
|
1917
|
-
}, (collection) => {
|
|
2033
|
+
collectionName
|
|
2034
|
+
}, ({ collection, mutationInfo }) => {
|
|
1918
2035
|
const relativePath = `${filename}.${collection.format}`;
|
|
1919
2036
|
return /* @__PURE__ */ React__default["default"].createElement(GetDocument, {
|
|
1920
2037
|
cms,
|
|
@@ -1927,7 +2044,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1927
2044
|
fields: document2.form.fields,
|
|
1928
2045
|
initialValues: document2.values,
|
|
1929
2046
|
onSubmit: async (values) => {
|
|
1930
|
-
await updateDocument(cms,
|
|
2047
|
+
await updateDocument(cms, relativePath, mutationInfo, values);
|
|
1931
2048
|
history.push(`/admin/collections/${collection.name}`);
|
|
1932
2049
|
}
|
|
1933
2050
|
});
|
|
@@ -2047,6 +2164,8 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2047
2164
|
className: "flex-1"
|
|
2048
2165
|
}, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Switch, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2049
2166
|
path: `/admin/collections/:collectionName/new`
|
|
2167
|
+
}, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2168
|
+
path: `/admin/collections/:collectionName/:templateName/new`
|
|
2050
2169
|
}, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2051
2170
|
path: `/admin/collections/:collectionName/:filename`
|
|
2052
2171
|
}, /* @__PURE__ */ React__default["default"].createElement(CollectionUpdatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
@@ -2055,10 +2174,18 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2055
2174
|
path: `/admin`
|
|
2056
2175
|
}, /* @__PURE__ */ React__default["default"].createElement(DashboardPage, null)))))))));
|
|
2057
2176
|
};
|
|
2177
|
+
class RouteMappingPlugin {
|
|
2178
|
+
constructor(mapper) {
|
|
2179
|
+
this.__type = "tina-admin";
|
|
2180
|
+
this.name = "route-mapping";
|
|
2181
|
+
this.mapper = mapper;
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2058
2184
|
exports2.AuthWallInner = AuthWallInner;
|
|
2059
2185
|
exports2.Client = Client;
|
|
2060
2186
|
exports2.DEFAULT_LOCAL_TINA_GQL_SERVER_URL = DEFAULT_LOCAL_TINA_GQL_SERVER_URL;
|
|
2061
2187
|
exports2.LocalClient = LocalClient;
|
|
2188
|
+
exports2.RouteMappingPlugin = RouteMappingPlugin;
|
|
2062
2189
|
exports2.TinaAdmin = TinaAdmin;
|
|
2063
2190
|
exports2.TinaCMSProvider2 = TinaCMSProvider2;
|
|
2064
2191
|
exports2.TinaCloudAuthWall = TinaCloudAuthWall;
|