tinacms 0.57.4 → 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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # tinacms
2
2
 
3
+ ## 0.58.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d1ed404ba: Add support for auto-generated SDK for type-safe data fetching
8
+
9
+ ### Patch Changes
10
+
11
+ - 138ceb8c4: Clean up dependencies
12
+ - 0417e3750: Adds RouteMapperPlugin and FormMetaPlugin
13
+ - Updated dependencies [138ceb8c4]
14
+ - Updated dependencies [0417e3750]
15
+ - Updated dependencies [d9f37ea7e]
16
+ - @tinacms/toolkit@0.55.3
17
+
3
18
  ## 0.57.4
4
19
 
5
20
  ### Patch Changes
@@ -0,0 +1,32 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ import { Plugin } from '@tinacms/toolkit';
14
+ import { Collection } from '../components/GetCollection';
15
+ interface Document {
16
+ sys: {
17
+ template: string;
18
+ breadcrumbs: string[];
19
+ path: string;
20
+ basename: string;
21
+ relativePath: string;
22
+ filename: string;
23
+ extension: string;
24
+ };
25
+ }
26
+ export declare class RouteMappingPlugin implements Plugin {
27
+ __type: string;
28
+ name: string;
29
+ mapper: (collection: Collection, document: Document) => string | undefined;
30
+ constructor(mapper: (collection: Collection, document: Document) => string | undefined);
31
+ }
32
+ export {};
package/dist/index.d.ts CHANGED
@@ -18,5 +18,6 @@ export { useGraphqlForms } from './hooks/use-graphql-forms';
18
18
  export { useDocumentCreatorPlugin } from './hooks/use-content-creator';
19
19
  export * from '@tinacms/toolkit';
20
20
  export { TinaAdmin } from './admin';
21
+ export { RouteMappingPlugin } from './admin/plugins/route-mapping';
21
22
  import { TinaCMSProvider2 } from './tina-cms';
22
23
  export default TinaCMSProvider2;
package/dist/index.es.js CHANGED
@@ -32,7 +32,7 @@ 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, FullscreenFormBuilder } from "@tinacms/toolkit";
35
+ import { EventBus, StyleReset, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, TinaCMS, BranchSwitcherPlugin, TinaProvider, useCMS, FormMetaPlugin, Form, GlobalFormPlugin, FullscreenFormBuilder } from "@tinacms/toolkit";
36
36
  export * from "@tinacms/toolkit";
37
37
  import React, { useState, useCallback, useEffect, Fragment } from "react";
38
38
  import styled from "styled-components";
@@ -800,6 +800,91 @@ const TinaCloudProvider = (props) => {
800
800
  })));
801
801
  };
802
802
  const TinaCloudAuthWall = TinaCloudProvider;
803
+ var DefaultContext = {
804
+ color: void 0,
805
+ size: void 0,
806
+ className: void 0,
807
+ style: void 0,
808
+ attr: void 0
809
+ };
810
+ var IconContext = React.createContext && React.createContext(DefaultContext);
811
+ var __assign = function() {
812
+ __assign = Object.assign || function(t) {
813
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
814
+ s = arguments[i];
815
+ for (var p in s)
816
+ if (Object.prototype.hasOwnProperty.call(s, p))
817
+ t[p] = s[p];
818
+ }
819
+ return t;
820
+ };
821
+ return __assign.apply(this, arguments);
822
+ };
823
+ var __rest = function(s, e) {
824
+ var t = {};
825
+ for (var p in s)
826
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
827
+ t[p] = s[p];
828
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
829
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
830
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
831
+ t[p[i]] = s[p[i]];
832
+ }
833
+ return t;
834
+ };
835
+ function Tree2Element(tree) {
836
+ return tree && tree.map(function(node, i) {
837
+ return React.createElement(node.tag, __assign({
838
+ key: i
839
+ }, node.attr), Tree2Element(node.child));
840
+ });
841
+ }
842
+ function GenIcon(data) {
843
+ return function(props) {
844
+ return React.createElement(IconBase, __assign({
845
+ attr: __assign({}, data.attr)
846
+ }, props), Tree2Element(data.child));
847
+ };
848
+ }
849
+ function IconBase(props) {
850
+ var elem = function(conf) {
851
+ var attr = props.attr, size = props.size, title = props.title, svgProps = __rest(props, ["attr", "size", "title"]);
852
+ var computedSize = size || conf.size || "1em";
853
+ var className;
854
+ if (conf.className)
855
+ className = conf.className;
856
+ if (props.className)
857
+ className = (className ? className + " " : "") + props.className;
858
+ return React.createElement("svg", __assign({
859
+ stroke: "currentColor",
860
+ fill: "currentColor",
861
+ strokeWidth: "0"
862
+ }, conf.attr, attr, svgProps, {
863
+ className,
864
+ style: __assign(__assign({
865
+ color: props.color || conf.color
866
+ }, conf.style), props.style),
867
+ height: computedSize,
868
+ width: computedSize,
869
+ xmlns: "http://www.w3.org/2000/svg"
870
+ }), title && React.createElement("title", null, title), props.children);
871
+ };
872
+ return IconContext !== void 0 ? React.createElement(IconContext.Consumer, null, function(conf) {
873
+ return elem(conf);
874
+ }) : elem(DefaultContext);
875
+ }
876
+ function BiEdit(props) {
877
+ 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);
878
+ }
879
+ function BiExit(props) {
880
+ 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);
881
+ }
882
+ function BiLinkExternal(props) {
883
+ 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);
884
+ }
885
+ function BiLogIn(props) {
886
+ 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);
887
+ }
803
888
  function useGraphqlForms({
804
889
  query,
805
890
  variables,
@@ -864,6 +949,7 @@ function useGraphqlForms({
864
949
  const formIds = [];
865
950
  setIsLoading(true);
866
951
  cms.api.tina.requestWithForm(query, { variables }).then((payload) => {
952
+ cms.plugins.remove(new FormMetaPlugin({ name: "tina-admin-link" }));
867
953
  setData(payload);
868
954
  setInitialData(payload);
869
955
  setIsLoading(false);
@@ -880,6 +966,32 @@ function useGraphqlForms({
880
966
  values: yup2.object().required(),
881
967
  form: yup2.object().required()
882
968
  }), `Unable to build form shape for fields at ${queryName}`);
969
+ if (cms.flags.get("tina-admin")) {
970
+ const TinaAdminLink = new FormMetaPlugin({
971
+ name: "tina-admin-link",
972
+ Component: () => /* @__PURE__ */ React.createElement("a", {
973
+ href: `/admin/collections/${result._internalSys.collection.name}/${result._internalSys.filename}`,
974
+ style: {
975
+ display: "flex",
976
+ alignItems: "center",
977
+ padding: "10px 20px",
978
+ borderTop: "1px solid var(--tina-color-grey-2)",
979
+ textTransform: "uppercase",
980
+ fontSize: "11px",
981
+ fontWeight: 500,
982
+ background: "var(--tina-color-grey-0)"
983
+ }
984
+ }, /* @__PURE__ */ React.createElement(BiLinkExternal, {
985
+ style: {
986
+ height: "1.25em",
987
+ width: "auto",
988
+ opacity: "0.8",
989
+ marginRight: "8px"
990
+ }
991
+ }), " ", "Edit in Tina Admin")
992
+ });
993
+ cms.plugins.add(TinaAdminLink);
994
+ }
883
995
  const formConfig = {
884
996
  id: queryName,
885
997
  label: result.form.label,
@@ -1469,81 +1581,12 @@ This will work when developing locally but NOT when deployed to production.
1469
1581
  }
1470
1582
  return client.request(query, { variables });
1471
1583
  };
1472
- function gql(strings) {
1473
- return strings[0];
1474
- }
1475
- var DefaultContext = {
1476
- color: void 0,
1477
- size: void 0,
1478
- className: void 0,
1479
- style: void 0,
1480
- attr: void 0
1481
- };
1482
- var IconContext = React.createContext && React.createContext(DefaultContext);
1483
- var __assign = function() {
1484
- __assign = Object.assign || function(t) {
1485
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1486
- s = arguments[i];
1487
- for (var p in s)
1488
- if (Object.prototype.hasOwnProperty.call(s, p))
1489
- t[p] = s[p];
1490
- }
1491
- return t;
1492
- };
1493
- return __assign.apply(this, arguments);
1494
- };
1495
- var __rest = function(s, e) {
1496
- var t = {};
1497
- for (var p in s)
1498
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1499
- t[p] = s[p];
1500
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
1501
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1502
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1503
- t[p[i]] = s[p[i]];
1504
- }
1505
- return t;
1506
- };
1507
- function Tree2Element(tree) {
1508
- return tree && tree.map(function(node, i) {
1509
- return React.createElement(node.tag, __assign({
1510
- key: i
1511
- }, node.attr), Tree2Element(node.child));
1584
+ function gql(strings, ...args) {
1585
+ let str = "";
1586
+ strings.forEach((string, i) => {
1587
+ str += string + (args[i] || "");
1512
1588
  });
1513
- }
1514
- function GenIcon(data) {
1515
- return function(props) {
1516
- return React.createElement(IconBase, __assign({
1517
- attr: __assign({}, data.attr)
1518
- }, props), Tree2Element(data.child));
1519
- };
1520
- }
1521
- function IconBase(props) {
1522
- var elem = function(conf) {
1523
- var attr = props.attr, size = props.size, title = props.title, svgProps = __rest(props, ["attr", "size", "title"]);
1524
- var computedSize = size || conf.size || "1em";
1525
- var className;
1526
- if (conf.className)
1527
- className = conf.className;
1528
- if (props.className)
1529
- className = (className ? className + " " : "") + props.className;
1530
- return React.createElement("svg", __assign({
1531
- stroke: "currentColor",
1532
- fill: "currentColor",
1533
- strokeWidth: "0"
1534
- }, conf.attr, attr, svgProps, {
1535
- className,
1536
- style: __assign(__assign({
1537
- color: props.color || conf.color
1538
- }, conf.style), props.style),
1539
- height: computedSize,
1540
- width: computedSize,
1541
- xmlns: "http://www.w3.org/2000/svg"
1542
- }), title && React.createElement("title", null, title), props.children);
1543
- };
1544
- return IconContext !== void 0 ? React.createElement(IconContext.Consumer, null, function(conf) {
1545
- return elem(conf);
1546
- }) : elem(DefaultContext);
1589
+ return str;
1547
1590
  }
1548
1591
  function ImFilesEmpty(props) {
1549
1592
  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);
@@ -1590,15 +1633,6 @@ const GetCollections = ({ cms, children }) => {
1590
1633
  return null;
1591
1634
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collections));
1592
1635
  };
1593
- function BiEdit(props) {
1594
- 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);
1595
- }
1596
- function BiExit(props) {
1597
- 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);
1598
- }
1599
- function BiLogIn(props) {
1600
- 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);
1601
- }
1602
1636
  function MdOutlineArrowBack(props) {
1603
1637
  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);
1604
1638
  }
@@ -1751,60 +1785,73 @@ const TemplateMenu = ({ templates }) => {
1751
1785
  const CollectionListPage = () => {
1752
1786
  const location2 = useLocation();
1753
1787
  const { collectionName } = useParams();
1754
- return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => /* @__PURE__ */ React.createElement(GetCollection, {
1755
- cms,
1756
- collectionName,
1757
- includeDocuments: true
1758
- }, (collection) => {
1759
- const totalCount = collection.documents.totalCount;
1760
- const documents = collection.documents.edges;
1761
- return /* @__PURE__ */ React.createElement("div", {
1762
- className: "px-6 py-14 h-screen overflow-y-auto flex justify-center"
1763
- }, /* @__PURE__ */ React.createElement("div", {
1764
- className: "max-w-screen-md w-full"
1765
- }, /* @__PURE__ */ React.createElement("div", {
1766
- className: "w-full flex justify-between items-end"
1767
- }, /* @__PURE__ */ React.createElement("h3", {
1768
- className: "text-3xl"
1769
- }, collection.label), !collection.templates && /* @__PURE__ */ React.createElement(Link, {
1770
- to: `${location2.pathname}/new`,
1771
- 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",
1772
- style: { background: "#0084FF" }
1773
- }, "Create New"), collection.templates && /* @__PURE__ */ React.createElement(TemplateMenu, {
1774
- templates: collection.templates
1775
- })), totalCount > 0 && /* @__PURE__ */ React.createElement("div", {
1776
- className: "mt-8 shadow overflow-hidden border-b border-gray-200 sm:rounded-lg"
1777
- }, /* @__PURE__ */ React.createElement("table", {
1778
- className: "min-w-full"
1779
- }, /* @__PURE__ */ React.createElement("tbody", {
1780
- className: "bg-white divide-y divide-gray-150"
1781
- }, documents.map((document2) => /* @__PURE__ */ React.createElement("tr", {
1782
- key: document2.node.sys.relativePath
1783
- }, /* @__PURE__ */ React.createElement("td", {
1784
- className: "px-6 py-2 whitespace-nowrap"
1785
- }, /* @__PURE__ */ React.createElement(Link, {
1786
- to: `${location2.pathname}/${document2.node.sys.filename}`,
1787
- className: "text-blue-600 hover:text-blue-400 flex items-center gap-3"
1788
- }, /* @__PURE__ */ React.createElement(BiEdit, {
1789
- className: "inline-block h-6 w-auto opacity-70"
1790
- }), " ", /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", {
1791
- className: "block text-xs text-gray-400 mb-1 uppercase"
1792
- }, "Filename"), /* @__PURE__ */ React.createElement("span", {
1793
- className: "h-5 leading-5 block whitespace-nowrap"
1794
- }, document2.node.sys.filename)))), /* @__PURE__ */ React.createElement("td", {
1795
- className: "px-6 py-4 whitespace-nowrap"
1796
- }, /* @__PURE__ */ React.createElement("span", {
1797
- className: "block text-xs text-gray-400 mb-1 uppercase"
1798
- }, "Extension"), /* @__PURE__ */ React.createElement("span", {
1799
- className: "h-5 leading-5 block text-sm font-medium text-gray-900"
1800
- }, document2.node.sys.extension)), /* @__PURE__ */ React.createElement("td", {
1801
- className: "px-6 py-4 whitespace-nowrap"
1802
- }, /* @__PURE__ */ React.createElement("span", {
1803
- className: "block text-xs text-gray-400 mb-1 uppercase"
1804
- }, "Template"), /* @__PURE__ */ React.createElement("span", {
1805
- className: "h-5 leading-5 block text-sm font-medium text-gray-900"
1806
- }, document2.node.sys.template)))))))));
1807
- }));
1788
+ return /* @__PURE__ */ React.createElement(GetCMS, null, (cms) => {
1789
+ const plugins = cms.plugins.all("tina-admin");
1790
+ const routeMapping = plugins.find(({ name }) => name === "route-mapping");
1791
+ return /* @__PURE__ */ React.createElement(GetCollection, {
1792
+ cms,
1793
+ collectionName,
1794
+ includeDocuments: true
1795
+ }, (collection) => {
1796
+ const totalCount = collection.documents.totalCount;
1797
+ const documents = collection.documents.edges;
1798
+ return /* @__PURE__ */ React.createElement("div", {
1799
+ className: "px-6 py-14 h-screen overflow-y-auto flex justify-center"
1800
+ }, /* @__PURE__ */ React.createElement("div", {
1801
+ className: "max-w-screen-md w-full"
1802
+ }, /* @__PURE__ */ React.createElement("div", {
1803
+ className: "w-full flex justify-between items-end"
1804
+ }, /* @__PURE__ */ React.createElement("h3", {
1805
+ className: "text-3xl"
1806
+ }, collection.label), !collection.templates && /* @__PURE__ */ React.createElement(Link, {
1807
+ to: `${location2.pathname}/new`,
1808
+ 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",
1809
+ style: { background: "#0084FF" }
1810
+ }, "Create New"), collection.templates && /* @__PURE__ */ React.createElement(TemplateMenu, {
1811
+ templates: collection.templates
1812
+ })), totalCount > 0 && /* @__PURE__ */ React.createElement("div", {
1813
+ className: "mt-8 shadow overflow-hidden border-b border-gray-200 sm:rounded-lg"
1814
+ }, /* @__PURE__ */ React.createElement("table", {
1815
+ className: "min-w-full"
1816
+ }, /* @__PURE__ */ React.createElement("tbody", {
1817
+ className: "bg-white divide-y divide-gray-150"
1818
+ }, documents.map((document2) => {
1819
+ const livesiteRoute = routeMapping ? routeMapping.mapper(collection, document2.node) : void 0;
1820
+ return /* @__PURE__ */ React.createElement("tr", {
1821
+ key: document2.node.sys.relativePath
1822
+ }, /* @__PURE__ */ React.createElement("td", {
1823
+ className: "px-5 py-3 whitespace-nowrap"
1824
+ }, /* @__PURE__ */ React.createElement("span", {
1825
+ className: "block text-xs mb-0.5 text-gray-400 uppercase"
1826
+ }, "Filename"), /* @__PURE__ */ React.createElement(Link, {
1827
+ to: `${location2.pathname}/${document2.node.sys.filename}`,
1828
+ className: "h-5 leading-5 block"
1829
+ }, /* @__PURE__ */ React.createElement("span", {
1830
+ className: "leading-5 font-medium text-base overflow-ellipsis overflow-hidden whitespace-nowrap text-gray-700"
1831
+ }, document2.node.sys.filename), /* @__PURE__ */ React.createElement("span", {
1832
+ className: "leading-5 text-base font-medium text-gray-300"
1833
+ }, document2.node.sys.extension))), /* @__PURE__ */ React.createElement("td", {
1834
+ className: "px-5 py-3 whitespace-nowrap"
1835
+ }, /* @__PURE__ */ React.createElement("span", {
1836
+ className: "block text-xs mb-0.5 text-gray-400 uppercase"
1837
+ }, "Template"), /* @__PURE__ */ React.createElement("span", {
1838
+ className: "h-5 block leading-5 font-regular text-base overflow-ellipsis overflow-hidden whitespace-nowrap text-gray-500"
1839
+ }, document2.node.sys.template)), /* @__PURE__ */ React.createElement("td", {
1840
+ className: "px-5 py-3 whitespace-nowrap flex gap-3 items-center justify-end"
1841
+ }, livesiteRoute && /* @__PURE__ */ React.createElement("a", {
1842
+ href: livesiteRoute,
1843
+ 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"
1844
+ }, /* @__PURE__ */ React.createElement(BiLinkExternal, {
1845
+ className: "inline-block h-5 w-auto opacity-70"
1846
+ }), " ", "View"), /* @__PURE__ */ React.createElement(Link, {
1847
+ to: `${location2.pathname}/${document2.node.sys.filename}`,
1848
+ 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"
1849
+ }, /* @__PURE__ */ React.createElement(BiEdit, {
1850
+ className: "inline-block h-5 w-auto opacity-70"
1851
+ }), " ", "Edit")));
1852
+ }))))));
1853
+ });
1854
+ });
1808
1855
  };
1809
1856
  const useGetDocumentFields = (cms, collectionName, templateName) => {
1810
1857
  const [info, setInfo] = useState({
@@ -2106,4 +2153,11 @@ const TinaAdmin = () => {
2106
2153
  path: `/admin`
2107
2154
  }, /* @__PURE__ */ React.createElement(DashboardPage, null)))))))));
2108
2155
  };
2109
- 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 };
2156
+ class RouteMappingPlugin {
2157
+ constructor(mapper) {
2158
+ this.__type = "tina-admin";
2159
+ this.name = "route-mapping";
2160
+ this.mapper = mapper;
2161
+ }
2162
+ }
2163
+ export { AuthWallInner, Client, DEFAULT_LOCAL_TINA_GQL_SERVER_URL, LocalClient, RouteMappingPlugin, TinaAdmin, TinaCMSProvider2, TinaCloudAuthWall, TinaCloudProvider, assertShape, createClient, TinaCMSProvider2 as default, getStaticPropsForTina, gql, safeAssertShape, staticRequest, useDocumentCreatorPlugin, useGraphqlForms, useTinaAuthRedirect };
package/dist/index.js CHANGED
@@ -821,6 +821,91 @@ mutation addPendingDocumentMutation(
821
821
  })));
822
822
  };
823
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
+ }
824
909
  function useGraphqlForms({
825
910
  query,
826
911
  variables,
@@ -885,6 +970,7 @@ mutation addPendingDocumentMutation(
885
970
  const formIds = [];
886
971
  setIsLoading(true);
887
972
  cms.api.tina.requestWithForm(query, { variables }).then((payload) => {
973
+ cms.plugins.remove(new toolkit.FormMetaPlugin({ name: "tina-admin-link" }));
888
974
  setData(payload);
889
975
  setInitialData(payload);
890
976
  setIsLoading(false);
@@ -901,6 +987,32 @@ mutation addPendingDocumentMutation(
901
987
  values: yup2.object().required(),
902
988
  form: yup2.object().required()
903
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
+ }
904
1016
  const formConfig = {
905
1017
  id: queryName,
906
1018
  label: result.form.label,
@@ -1490,81 +1602,12 @@ This will work when developing locally but NOT when deployed to production.
1490
1602
  }
1491
1603
  return client.request(query, { variables });
1492
1604
  };
1493
- function gql(strings) {
1494
- return strings[0];
1495
- }
1496
- var DefaultContext = {
1497
- color: void 0,
1498
- size: void 0,
1499
- className: void 0,
1500
- style: void 0,
1501
- attr: void 0
1502
- };
1503
- var IconContext = React__default["default"].createContext && React__default["default"].createContext(DefaultContext);
1504
- var __assign = function() {
1505
- __assign = Object.assign || function(t) {
1506
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1507
- s = arguments[i];
1508
- for (var p in s)
1509
- if (Object.prototype.hasOwnProperty.call(s, p))
1510
- t[p] = s[p];
1511
- }
1512
- return t;
1513
- };
1514
- return __assign.apply(this, arguments);
1515
- };
1516
- var __rest = function(s, e) {
1517
- var t = {};
1518
- for (var p in s)
1519
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1520
- t[p] = s[p];
1521
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
1522
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1523
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1524
- t[p[i]] = s[p[i]];
1525
- }
1526
- return t;
1527
- };
1528
- function Tree2Element(tree) {
1529
- return tree && tree.map(function(node, i) {
1530
- return React__default["default"].createElement(node.tag, __assign({
1531
- key: i
1532
- }, node.attr), Tree2Element(node.child));
1605
+ function gql(strings, ...args) {
1606
+ let str = "";
1607
+ strings.forEach((string, i) => {
1608
+ str += string + (args[i] || "");
1533
1609
  });
1534
- }
1535
- function GenIcon(data) {
1536
- return function(props) {
1537
- return React__default["default"].createElement(IconBase, __assign({
1538
- attr: __assign({}, data.attr)
1539
- }, props), Tree2Element(data.child));
1540
- };
1541
- }
1542
- function IconBase(props) {
1543
- var elem = function(conf) {
1544
- var attr = props.attr, size = props.size, title = props.title, svgProps = __rest(props, ["attr", "size", "title"]);
1545
- var computedSize = size || conf.size || "1em";
1546
- var className;
1547
- if (conf.className)
1548
- className = conf.className;
1549
- if (props.className)
1550
- className = (className ? className + " " : "") + props.className;
1551
- return React__default["default"].createElement("svg", __assign({
1552
- stroke: "currentColor",
1553
- fill: "currentColor",
1554
- strokeWidth: "0"
1555
- }, conf.attr, attr, svgProps, {
1556
- className,
1557
- style: __assign(__assign({
1558
- color: props.color || conf.color
1559
- }, conf.style), props.style),
1560
- height: computedSize,
1561
- width: computedSize,
1562
- xmlns: "http://www.w3.org/2000/svg"
1563
- }), title && React__default["default"].createElement("title", null, title), props.children);
1564
- };
1565
- return IconContext !== void 0 ? React__default["default"].createElement(IconContext.Consumer, null, function(conf) {
1566
- return elem(conf);
1567
- }) : elem(DefaultContext);
1610
+ return str;
1568
1611
  }
1569
1612
  function ImFilesEmpty(props) {
1570
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);
@@ -1611,15 +1654,6 @@ This will work when developing locally but NOT when deployed to production.
1611
1654
  return null;
1612
1655
  return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collections));
1613
1656
  };
1614
- function BiEdit(props) {
1615
- 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);
1616
- }
1617
- function BiExit(props) {
1618
- 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);
1619
- }
1620
- function BiLogIn(props) {
1621
- 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);
1622
- }
1623
1657
  function MdOutlineArrowBack(props) {
1624
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);
1625
1659
  }
@@ -1772,60 +1806,73 @@ This will work when developing locally but NOT when deployed to production.
1772
1806
  const CollectionListPage = () => {
1773
1807
  const location2 = reactRouterDom.useLocation();
1774
1808
  const { collectionName } = reactRouterDom.useParams();
1775
- return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetCollection, {
1776
- cms,
1777
- collectionName,
1778
- includeDocuments: true
1779
- }, (collection) => {
1780
- const totalCount = collection.documents.totalCount;
1781
- const documents = collection.documents.edges;
1782
- return /* @__PURE__ */ React__default["default"].createElement("div", {
1783
- className: "px-6 py-14 h-screen overflow-y-auto flex justify-center"
1784
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
1785
- className: "max-w-screen-md w-full"
1786
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
1787
- className: "w-full flex justify-between items-end"
1788
- }, /* @__PURE__ */ React__default["default"].createElement("h3", {
1789
- className: "text-3xl"
1790
- }, collection.label), !collection.templates && /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
1791
- to: `${location2.pathname}/new`,
1792
- 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",
1793
- style: { background: "#0084FF" }
1794
- }, "Create New"), collection.templates && /* @__PURE__ */ React__default["default"].createElement(TemplateMenu, {
1795
- templates: collection.templates
1796
- })), totalCount > 0 && /* @__PURE__ */ React__default["default"].createElement("div", {
1797
- className: "mt-8 shadow overflow-hidden border-b border-gray-200 sm:rounded-lg"
1798
- }, /* @__PURE__ */ React__default["default"].createElement("table", {
1799
- className: "min-w-full"
1800
- }, /* @__PURE__ */ React__default["default"].createElement("tbody", {
1801
- className: "bg-white divide-y divide-gray-150"
1802
- }, documents.map((document2) => /* @__PURE__ */ React__default["default"].createElement("tr", {
1803
- key: document2.node.sys.relativePath
1804
- }, /* @__PURE__ */ React__default["default"].createElement("td", {
1805
- className: "px-6 py-2 whitespace-nowrap"
1806
- }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
1807
- to: `${location2.pathname}/${document2.node.sys.filename}`,
1808
- className: "text-blue-600 hover:text-blue-400 flex items-center gap-3"
1809
- }, /* @__PURE__ */ React__default["default"].createElement(BiEdit, {
1810
- className: "inline-block h-6 w-auto opacity-70"
1811
- }), " ", /* @__PURE__ */ React__default["default"].createElement("span", null, /* @__PURE__ */ React__default["default"].createElement("span", {
1812
- className: "block text-xs text-gray-400 mb-1 uppercase"
1813
- }, "Filename"), /* @__PURE__ */ React__default["default"].createElement("span", {
1814
- className: "h-5 leading-5 block whitespace-nowrap"
1815
- }, document2.node.sys.filename)))), /* @__PURE__ */ React__default["default"].createElement("td", {
1816
- className: "px-6 py-4 whitespace-nowrap"
1817
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
1818
- className: "block text-xs text-gray-400 mb-1 uppercase"
1819
- }, "Extension"), /* @__PURE__ */ React__default["default"].createElement("span", {
1820
- className: "h-5 leading-5 block text-sm font-medium text-gray-900"
1821
- }, document2.node.sys.extension)), /* @__PURE__ */ React__default["default"].createElement("td", {
1822
- className: "px-6 py-4 whitespace-nowrap"
1823
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
1824
- className: "block text-xs text-gray-400 mb-1 uppercase"
1825
- }, "Template"), /* @__PURE__ */ React__default["default"].createElement("span", {
1826
- className: "h-5 leading-5 block text-sm font-medium text-gray-900"
1827
- }, document2.node.sys.template)))))))));
1828
- }));
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
+ });
1829
1876
  };
1830
1877
  const useGetDocumentFields = (cms, collectionName, templateName) => {
1831
1878
  const [info, setInfo] = React.useState({
@@ -2127,10 +2174,18 @@ This will work when developing locally but NOT when deployed to production.
2127
2174
  path: `/admin`
2128
2175
  }, /* @__PURE__ */ React__default["default"].createElement(DashboardPage, null)))))))));
2129
2176
  };
2177
+ class RouteMappingPlugin {
2178
+ constructor(mapper) {
2179
+ this.__type = "tina-admin";
2180
+ this.name = "route-mapping";
2181
+ this.mapper = mapper;
2182
+ }
2183
+ }
2130
2184
  exports2.AuthWallInner = AuthWallInner;
2131
2185
  exports2.Client = Client;
2132
2186
  exports2.DEFAULT_LOCAL_TINA_GQL_SERVER_URL = DEFAULT_LOCAL_TINA_GQL_SERVER_URL;
2133
2187
  exports2.LocalClient = LocalClient;
2188
+ exports2.RouteMappingPlugin = RouteMappingPlugin;
2134
2189
  exports2.TinaAdmin = TinaAdmin;
2135
2190
  exports2.TinaCMSProvider2 = TinaCMSProvider2;
2136
2191
  exports2.TinaCloudAuthWall = TinaCloudAuthWall;
@@ -66,4 +66,4 @@ export declare const staticRequest: ({ query, variables, }: {
66
66
  * to know the temlpate string is a GraphQL
67
67
  * query or muation
68
68
  */
69
- export declare function gql(strings: TemplateStringsArray): string;
69
+ export declare function gql(strings: TemplateStringsArray, ...args: string[]): string;
@@ -0,0 +1,29 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ export declare class TinaGQLClient {
14
+ private _usedFrags;
15
+ private _frags;
16
+ private _selections;
17
+ private get _queryAST();
18
+ private get _DocumentAST();
19
+ get query(): string;
20
+ /**
21
+ * getAuthorDocument
22
+ */
23
+ getAuthorDocument(args: {
24
+ relativePath: string;
25
+ }): this;
26
+ gePostsDocument(args: {
27
+ relativePath: string;
28
+ }): this;
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "0.57.4",
3
+ "version": "0.58.0",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist"
@@ -16,8 +16,7 @@
16
16
  "license": "Apache-2.0",
17
17
  "scripts": {
18
18
  "types": "yarn tsc",
19
- "build": "yarn tsup src/index.ts src/edit-state.tsx --format cjs --dts",
20
- "watch": "yarn tsup src/index.ts src/edit-state.tsx --watch --format cjs --dts"
19
+ "build": "echo \"Run `yarn build` from the root of the repository instead\""
21
20
  },
22
21
  "dependencies": {
23
22
  "@graphql-codegen/core": "^1.15.4",
@@ -25,7 +24,7 @@
25
24
  "@graphql-codegen/typescript-operations": "^1.15.4",
26
25
  "@headlessui/react": "^1.4.1",
27
26
  "@heroicons/react": "^1.0.4",
28
- "@tinacms/toolkit": "0.55.2",
27
+ "@tinacms/toolkit": "0.55.3",
29
28
  "@xstate/react": "^1.1.0",
30
29
  "codemirror": "^5.55.0",
31
30
  "cors": "^2.8.5",
@@ -44,26 +43,24 @@
44
43
  "prop-types": "15.7.2",
45
44
  "react-icons": "^4.3.1",
46
45
  "react-router-dom": "^5.3.0",
47
- "ts-jest": "^26.5.3",
48
46
  "xstate": "^4.15.1",
49
47
  "yup": "^0.32.0"
50
48
  },
51
49
  "devDependencies": {
52
- "@tinacms/scripts": "0.50.3",
50
+ "@tinacms/scripts": "0.50.4",
53
51
  "@types/lodash": "^4.14.169",
54
52
  "@types/node": "^14.0.13",
55
53
  "@types/react": "^16.9.38",
56
54
  "@types/yup": "^0.29.10",
57
55
  "next": "9.4.2",
58
56
  "react": "16.14.0",
59
- "react-dom": "16.13.1",
57
+ "react-dom": "16.14.0",
60
58
  "styled-components": "^5.2.0",
61
- "tsup": "4.12.5",
62
59
  "typescript": "^4.3.5"
63
60
  },
64
61
  "peerDependencies": {
65
62
  "react": ">=16.14.0",
66
- "react-dom": ">=16.8",
63
+ "react-dom": ">=16.14.0",
67
64
  "react-is": "^16.13.1 || <18.0.0",
68
65
  "styled-components": "*"
69
66
  },