tinacms 0.64.2 → 0.65.3
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/api.d.ts +36 -0
- package/dist/admin/components/GetCollection.d.ts +1 -28
- package/dist/admin/components/GetCollections.d.ts +1 -4
- package/dist/admin/components/GetDocument.d.ts +2 -15
- package/dist/admin/components/GetDocumentFields.d.ts +0 -7
- package/dist/admin/plugins/route-mapping.d.ts +3 -15
- package/dist/admin/types.d.ts +72 -0
- package/dist/edit-state.d.ts +8 -0
- package/dist/edit-state.es.js +32 -3
- package/dist/edit-state.js +30 -0
- package/dist/hooks/use-graphql-forms.d.ts +2 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +361 -259
- package/dist/index.js +361 -257
- package/dist/rich-text.d.ts +1 -1
- package/dist/style.css +45 -53
- package/dist/tina-cms.d.ts +54 -13
- package/package.json +7 -5
- package/dist/admin/hooks/useEmbedTailwind.d.ts +0 -14
package/dist/index.es.js
CHANGED
|
@@ -37,7 +37,7 @@ import gql$1 from "graphql-tag";
|
|
|
37
37
|
import React, { useState, useCallback, useEffect, Fragment } from "react";
|
|
38
38
|
import styled from "styled-components";
|
|
39
39
|
import * as yup from "yup";
|
|
40
|
-
import { setEditing, useEditState } from "@tinacms/sharedctx";
|
|
40
|
+
import { setEditing, TinaDataContext, useEditState } from "@tinacms/sharedctx";
|
|
41
41
|
import { getIn, setIn } from "final-form";
|
|
42
42
|
import UrlPattern from "url-pattern";
|
|
43
43
|
import { NavLink, useLocation, useParams, Link, useNavigate, BrowserRouter, Routes, Route } from "react-router-dom";
|
|
@@ -655,7 +655,7 @@ const AsyncButton = ({ name, primary, action }) => {
|
|
|
655
655
|
}
|
|
656
656
|
}, [action, setSubmitting]);
|
|
657
657
|
return /* @__PURE__ */ React.createElement(Button, {
|
|
658
|
-
primary,
|
|
658
|
+
variant: primary ? "primary" : "secondary",
|
|
659
659
|
onClick,
|
|
660
660
|
busy: submitting,
|
|
661
661
|
disabled: submitting
|
|
@@ -843,99 +843,11 @@ const TinaCloudProvider = (props) => {
|
|
|
843
843
|
}))));
|
|
844
844
|
};
|
|
845
845
|
const TinaCloudAuthWall = TinaCloudProvider;
|
|
846
|
-
var DefaultContext = {
|
|
847
|
-
color: void 0,
|
|
848
|
-
size: void 0,
|
|
849
|
-
className: void 0,
|
|
850
|
-
style: void 0,
|
|
851
|
-
attr: void 0
|
|
852
|
-
};
|
|
853
|
-
var IconContext = React.createContext && React.createContext(DefaultContext);
|
|
854
|
-
var __assign = function() {
|
|
855
|
-
__assign = Object.assign || function(t) {
|
|
856
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
857
|
-
s = arguments[i];
|
|
858
|
-
for (var p in s)
|
|
859
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
860
|
-
t[p] = s[p];
|
|
861
|
-
}
|
|
862
|
-
return t;
|
|
863
|
-
};
|
|
864
|
-
return __assign.apply(this, arguments);
|
|
865
|
-
};
|
|
866
|
-
var __rest = function(s, e) {
|
|
867
|
-
var t = {};
|
|
868
|
-
for (var p in s)
|
|
869
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
870
|
-
t[p] = s[p];
|
|
871
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
872
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
873
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
874
|
-
t[p[i]] = s[p[i]];
|
|
875
|
-
}
|
|
876
|
-
return t;
|
|
877
|
-
};
|
|
878
|
-
function Tree2Element(tree) {
|
|
879
|
-
return tree && tree.map(function(node, i) {
|
|
880
|
-
return React.createElement(node.tag, __assign({
|
|
881
|
-
key: i
|
|
882
|
-
}, node.attr), Tree2Element(node.child));
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
function GenIcon(data) {
|
|
886
|
-
return function(props) {
|
|
887
|
-
return React.createElement(IconBase, __assign({
|
|
888
|
-
attr: __assign({}, data.attr)
|
|
889
|
-
}, props), Tree2Element(data.child));
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
function IconBase(props) {
|
|
893
|
-
var elem = function(conf) {
|
|
894
|
-
var attr = props.attr, size = props.size, title = props.title, svgProps = __rest(props, ["attr", "size", "title"]);
|
|
895
|
-
var computedSize = size || conf.size || "1em";
|
|
896
|
-
var className;
|
|
897
|
-
if (conf.className)
|
|
898
|
-
className = conf.className;
|
|
899
|
-
if (props.className)
|
|
900
|
-
className = (className ? className + " " : "") + props.className;
|
|
901
|
-
return React.createElement("svg", __assign({
|
|
902
|
-
stroke: "currentColor",
|
|
903
|
-
fill: "currentColor",
|
|
904
|
-
strokeWidth: "0"
|
|
905
|
-
}, conf.attr, attr, svgProps, {
|
|
906
|
-
className,
|
|
907
|
-
style: __assign(__assign({
|
|
908
|
-
color: props.color || conf.color
|
|
909
|
-
}, conf.style), props.style),
|
|
910
|
-
height: computedSize,
|
|
911
|
-
width: computedSize,
|
|
912
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
913
|
-
}), title && React.createElement("title", null, title), props.children);
|
|
914
|
-
};
|
|
915
|
-
return IconContext !== void 0 ? React.createElement(IconContext.Consumer, null, function(conf) {
|
|
916
|
-
return elem(conf);
|
|
917
|
-
}) : elem(DefaultContext);
|
|
918
|
-
}
|
|
919
|
-
function BiEdit(props) {
|
|
920
|
-
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);
|
|
921
|
-
}
|
|
922
|
-
function BiExit(props) {
|
|
923
|
-
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);
|
|
924
|
-
}
|
|
925
|
-
function BiLinkExternal(props) {
|
|
926
|
-
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);
|
|
927
|
-
}
|
|
928
|
-
function BiLogIn(props) {
|
|
929
|
-
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);
|
|
930
|
-
}
|
|
931
|
-
function BiLogOut(props) {
|
|
932
|
-
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M16 13v-2H7V8l-5 4 5 4v-3z" } }, { "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);
|
|
933
|
-
}
|
|
934
846
|
function useGraphqlForms({
|
|
935
|
-
query,
|
|
936
847
|
variables,
|
|
937
848
|
onSubmit,
|
|
938
|
-
formify: formify2 = null
|
|
849
|
+
formify: formify2 = null,
|
|
850
|
+
query
|
|
939
851
|
}) {
|
|
940
852
|
const cms = useCMS();
|
|
941
853
|
const [formValues, setFormValues] = React.useState({});
|
|
@@ -985,7 +897,6 @@ function useGraphqlForms({
|
|
|
985
897
|
React.useEffect(() => {
|
|
986
898
|
updateData();
|
|
987
899
|
}, [JSON.stringify(formValues)]);
|
|
988
|
-
const queryString = print(query(gql$1));
|
|
989
900
|
React.useEffect(() => {
|
|
990
901
|
if (pendingReset) {
|
|
991
902
|
setData(__spreadProps(__spreadValues({}, data), { [pendingReset]: initialData[pendingReset] }));
|
|
@@ -993,9 +904,15 @@ function useGraphqlForms({
|
|
|
993
904
|
}
|
|
994
905
|
}, [pendingReset]);
|
|
995
906
|
React.useEffect(() => {
|
|
907
|
+
if (!query) {
|
|
908
|
+
setIsLoading(false);
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
996
911
|
const formIds = [];
|
|
997
912
|
setIsLoading(true);
|
|
998
|
-
cms.api.tina.requestWithForm(
|
|
913
|
+
cms.api.tina.requestWithForm((gql2) => gql2(query), {
|
|
914
|
+
variables
|
|
915
|
+
}).then((payload) => {
|
|
999
916
|
cms.plugins.remove(new FormMetaPlugin({ name: "tina-admin-link" }));
|
|
1000
917
|
setData(payload);
|
|
1001
918
|
setInitialData(payload);
|
|
@@ -1013,18 +930,6 @@ function useGraphqlForms({
|
|
|
1013
930
|
values: yup2.object().required(),
|
|
1014
931
|
form: yup2.object().required()
|
|
1015
932
|
}), `Unable to build form shape for fields at ${queryName}`);
|
|
1016
|
-
if (cms.flags.get("tina-admin")) {
|
|
1017
|
-
const TinaAdminLink = new FormMetaPlugin({
|
|
1018
|
-
name: "tina-admin-link",
|
|
1019
|
-
Component: () => /* @__PURE__ */ React.createElement("a", {
|
|
1020
|
-
href: `/admin/collections/${result._internalSys.collection.name}/${result._internalSys.filename}`,
|
|
1021
|
-
className: "flex items-center px-5 py-2 border-t border-b shadow border-gray-100 uppercase text-xs font-medium bg-white hover:bg-gray-50 hover:text-blue-500 transition-colors duration-100 ease-out"
|
|
1022
|
-
}, /* @__PURE__ */ React.createElement(BiLinkExternal, {
|
|
1023
|
-
className: "h-4 w-auto opacity-80 mr-2"
|
|
1024
|
-
}), " Edit in Tina Admin")
|
|
1025
|
-
});
|
|
1026
|
-
cms.plugins.add(TinaAdminLink);
|
|
1027
|
-
}
|
|
1028
933
|
const formConfig = {
|
|
1029
934
|
id: queryName,
|
|
1030
935
|
label: result.form.label,
|
|
@@ -1146,7 +1051,7 @@ function useGraphqlForms({
|
|
|
1146
1051
|
}
|
|
1147
1052
|
});
|
|
1148
1053
|
};
|
|
1149
|
-
}, [
|
|
1054
|
+
}, [query, JSON.stringify(variables), currentBranch]);
|
|
1150
1055
|
return [data, isLoading];
|
|
1151
1056
|
}
|
|
1152
1057
|
const transformDocumentIntoMutationRequestPayload = (document, instructions) => {
|
|
@@ -2015,10 +1920,6 @@ Document
|
|
|
2015
1920
|
z-index: 50 !important;
|
|
2016
1921
|
}
|
|
2017
1922
|
|
|
2018
|
-
.tina-tailwind .mr-2 {
|
|
2019
|
-
margin-right: 8px !important;
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
1923
|
.tina-tailwind .-ml-1 {
|
|
2023
1924
|
margin-left: -4px !important;
|
|
2024
1925
|
}
|
|
@@ -2035,6 +1936,10 @@ Document
|
|
|
2035
1936
|
margin-bottom: 12px !important;
|
|
2036
1937
|
}
|
|
2037
1938
|
|
|
1939
|
+
.tina-tailwind .mr-2 {
|
|
1940
|
+
margin-right: 8px !important;
|
|
1941
|
+
}
|
|
1942
|
+
|
|
2038
1943
|
.tina-tailwind .ml-1 {
|
|
2039
1944
|
margin-left: 4px !important;
|
|
2040
1945
|
}
|
|
@@ -2079,10 +1984,6 @@ Document
|
|
|
2079
1984
|
height: 100vh !important;
|
|
2080
1985
|
}
|
|
2081
1986
|
|
|
2082
|
-
.tina-tailwind .h-4 {
|
|
2083
|
-
height: 16px !important;
|
|
2084
|
-
}
|
|
2085
|
-
|
|
2086
1987
|
.tina-tailwind .h-auto {
|
|
2087
1988
|
height: auto !important;
|
|
2088
1989
|
}
|
|
@@ -2095,10 +1996,6 @@ Document
|
|
|
2095
1996
|
height: 20px !important;
|
|
2096
1997
|
}
|
|
2097
1998
|
|
|
2098
|
-
.tina-tailwind .w-auto {
|
|
2099
|
-
width: auto !important;
|
|
2100
|
-
}
|
|
2101
|
-
|
|
2102
1999
|
.tina-tailwind .w-full {
|
|
2103
2000
|
width: 100% !important;
|
|
2104
2001
|
}
|
|
@@ -2119,6 +2016,10 @@ Document
|
|
|
2119
2016
|
width: 24px !important;
|
|
2120
2017
|
}
|
|
2121
2018
|
|
|
2019
|
+
.tina-tailwind .w-auto {
|
|
2020
|
+
width: auto !important;
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2122
2023
|
.tina-tailwind .w-56 {
|
|
2123
2024
|
width: 224px !important;
|
|
2124
2025
|
}
|
|
@@ -2286,10 +2187,6 @@ Document
|
|
|
2286
2187
|
border-width: 1px !important;
|
|
2287
2188
|
}
|
|
2288
2189
|
|
|
2289
|
-
.tina-tailwind .border-t {
|
|
2290
|
-
border-top-width: 1px !important;
|
|
2291
|
-
}
|
|
2292
|
-
|
|
2293
2190
|
.tina-tailwind .border-b {
|
|
2294
2191
|
border-bottom-width: 1px !important;
|
|
2295
2192
|
}
|
|
@@ -2298,11 +2195,6 @@ Document
|
|
|
2298
2195
|
border-right-width: 1px !important;
|
|
2299
2196
|
}
|
|
2300
2197
|
|
|
2301
|
-
.tina-tailwind .border-gray-100 {
|
|
2302
|
-
--tw-border-opacity: 1 !important;
|
|
2303
|
-
border-color: rgba(237, 236, 243, var(--tw-border-opacity)) !important;
|
|
2304
|
-
}
|
|
2305
|
-
|
|
2306
2198
|
.tina-tailwind .border-gray-200 {
|
|
2307
2199
|
--tw-border-opacity: 1 !important;
|
|
2308
2200
|
border-color: rgba(225, 221, 236, var(--tw-border-opacity)) !important;
|
|
@@ -2348,16 +2240,6 @@ Document
|
|
|
2348
2240
|
--tw-gradient-to: #F6F6F9 !important;
|
|
2349
2241
|
}
|
|
2350
2242
|
|
|
2351
|
-
.tina-tailwind .px-5 {
|
|
2352
|
-
padding-left: 20px !important;
|
|
2353
|
-
padding-right: 20px !important;
|
|
2354
|
-
}
|
|
2355
|
-
|
|
2356
|
-
.tina-tailwind .py-2 {
|
|
2357
|
-
padding-top: 8px !important;
|
|
2358
|
-
padding-bottom: 8px !important;
|
|
2359
|
-
}
|
|
2360
|
-
|
|
2361
2243
|
.tina-tailwind .px-4 {
|
|
2362
2244
|
padding-left: 16px !important;
|
|
2363
2245
|
padding-right: 16px !important;
|
|
@@ -2368,6 +2250,11 @@ Document
|
|
|
2368
2250
|
padding-bottom: 24px !important;
|
|
2369
2251
|
}
|
|
2370
2252
|
|
|
2253
|
+
.tina-tailwind .px-5 {
|
|
2254
|
+
padding-left: 20px !important;
|
|
2255
|
+
padding-right: 20px !important;
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2371
2258
|
.tina-tailwind .py-4 {
|
|
2372
2259
|
padding-top: 16px !important;
|
|
2373
2260
|
padding-bottom: 16px !important;
|
|
@@ -2383,6 +2270,11 @@ Document
|
|
|
2383
2270
|
padding-bottom: 4px !important;
|
|
2384
2271
|
}
|
|
2385
2272
|
|
|
2273
|
+
.tina-tailwind .py-2 {
|
|
2274
|
+
padding-top: 8px !important;
|
|
2275
|
+
padding-bottom: 8px !important;
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2386
2278
|
.tina-tailwind .py-7 {
|
|
2387
2279
|
padding-top: 28px !important;
|
|
2388
2280
|
padding-bottom: 28px !important;
|
|
@@ -2438,11 +2330,6 @@ Document
|
|
|
2438
2330
|
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !important;
|
|
2439
2331
|
}
|
|
2440
2332
|
|
|
2441
|
-
.tina-tailwind .text-xs {
|
|
2442
|
-
font-size: 13px !important;
|
|
2443
|
-
line-height: 1.33 !important;
|
|
2444
|
-
}
|
|
2445
|
-
|
|
2446
2333
|
.tina-tailwind .text-2xl {
|
|
2447
2334
|
font-size: 24px !important;
|
|
2448
2335
|
line-height: 1.33 !important;
|
|
@@ -2463,24 +2350,34 @@ Document
|
|
|
2463
2350
|
line-height: 1.43 !important;
|
|
2464
2351
|
}
|
|
2465
2352
|
|
|
2353
|
+
.tina-tailwind .text-md {
|
|
2354
|
+
font-size: 16px !important;
|
|
2355
|
+
line-height: 1.5 !important;
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2466
2358
|
.tina-tailwind .text-3xl {
|
|
2467
2359
|
font-size: 30px !important;
|
|
2468
2360
|
line-height: 1.2 !important;
|
|
2469
2361
|
}
|
|
2470
2362
|
|
|
2363
|
+
.tina-tailwind .text-xs {
|
|
2364
|
+
font-size: 13px !important;
|
|
2365
|
+
line-height: 1.33 !important;
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2471
2368
|
.tina-tailwind .text-4xl {
|
|
2472
2369
|
font-size: 36px !important;
|
|
2473
2370
|
line-height: 1.1 !important;
|
|
2474
2371
|
}
|
|
2475
2372
|
|
|
2476
|
-
.tina-tailwind .font-medium {
|
|
2477
|
-
font-weight: 500 !important;
|
|
2478
|
-
}
|
|
2479
|
-
|
|
2480
2373
|
.tina-tailwind .font-bold {
|
|
2481
2374
|
font-weight: 700 !important;
|
|
2482
2375
|
}
|
|
2483
2376
|
|
|
2377
|
+
.tina-tailwind .font-medium {
|
|
2378
|
+
font-weight: 500 !important;
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2484
2381
|
.tina-tailwind .uppercase {
|
|
2485
2382
|
text-transform: uppercase !important;
|
|
2486
2383
|
}
|
|
@@ -2578,11 +2475,6 @@ Document
|
|
|
2578
2475
|
opacity: .7 !important;
|
|
2579
2476
|
}
|
|
2580
2477
|
|
|
2581
|
-
.tina-tailwind .shadow {
|
|
2582
|
-
--tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) !important;
|
|
2583
|
-
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
|
|
2584
|
-
}
|
|
2585
|
-
|
|
2586
2478
|
.tina-tailwind .shadow-lg {
|
|
2587
2479
|
--tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
|
|
2588
2480
|
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
|
|
@@ -2593,6 +2485,11 @@ Document
|
|
|
2593
2485
|
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
|
|
2594
2486
|
}
|
|
2595
2487
|
|
|
2488
|
+
.tina-tailwind .shadow {
|
|
2489
|
+
--tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) !important;
|
|
2490
|
+
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2596
2493
|
.tina-tailwind .ring-1 {
|
|
2597
2494
|
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color) !important;
|
|
2598
2495
|
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color) !important;
|
|
@@ -2636,10 +2533,6 @@ Document
|
|
|
2636
2533
|
transition-duration: 150ms !important;
|
|
2637
2534
|
}
|
|
2638
2535
|
|
|
2639
|
-
.tina-tailwind .duration-100 {
|
|
2640
|
-
transition-duration: 100ms !important;
|
|
2641
|
-
}
|
|
2642
|
-
|
|
2643
2536
|
.tina-tailwind .duration-150 {
|
|
2644
2537
|
transition-duration: 150ms !important;
|
|
2645
2538
|
}
|
|
@@ -2652,6 +2545,10 @@ Document
|
|
|
2652
2545
|
transition-duration: 75ms !important;
|
|
2653
2546
|
}
|
|
2654
2547
|
|
|
2548
|
+
.tina-tailwind .duration-100 {
|
|
2549
|
+
transition-duration: 100ms !important;
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2655
2552
|
.tina-tailwind .ease-out {
|
|
2656
2553
|
transition-timing-function: cubic-bezier(0, 0, 0.2, 1) !important;
|
|
2657
2554
|
}
|
|
@@ -2675,14 +2572,14 @@ Document
|
|
|
2675
2572
|
background-color: rgba(246, 246, 249, var(--tw-bg-opacity)) !important;
|
|
2676
2573
|
}
|
|
2677
2574
|
|
|
2678
|
-
.hover\\:text-blue-
|
|
2575
|
+
.hover\\:text-blue-600:hover {
|
|
2679
2576
|
--tw-text-opacity: 1 !important;
|
|
2680
|
-
color: rgba(
|
|
2577
|
+
color: rgba(5, 116, 228, var(--tw-text-opacity)) !important;
|
|
2681
2578
|
}
|
|
2682
2579
|
|
|
2683
|
-
.hover\\:text-blue-
|
|
2580
|
+
.hover\\:text-blue-500:hover {
|
|
2684
2581
|
--tw-text-opacity: 1 !important;
|
|
2685
|
-
color: rgba(
|
|
2582
|
+
color: rgba(0, 132, 255, var(--tw-text-opacity)) !important;
|
|
2686
2583
|
}
|
|
2687
2584
|
|
|
2688
2585
|
.hover\\:opacity-100:hover {
|
|
@@ -2720,6 +2617,35 @@ Document
|
|
|
2720
2617
|
}
|
|
2721
2618
|
}
|
|
2722
2619
|
`;
|
|
2620
|
+
function useTina({
|
|
2621
|
+
query,
|
|
2622
|
+
variables,
|
|
2623
|
+
data
|
|
2624
|
+
}) {
|
|
2625
|
+
const {
|
|
2626
|
+
setRequest,
|
|
2627
|
+
state,
|
|
2628
|
+
isDummyContainer,
|
|
2629
|
+
isLoading: contextLoading
|
|
2630
|
+
} = React.useContext(TinaDataContext);
|
|
2631
|
+
const [waitForContextRerender, setWaitForContextRerender] = useState(!isDummyContainer);
|
|
2632
|
+
const isLoading = contextLoading || waitForContextRerender;
|
|
2633
|
+
React.useEffect(() => {
|
|
2634
|
+
setRequest({ query, variables });
|
|
2635
|
+
}, [JSON.stringify(variables), query]);
|
|
2636
|
+
useEffect(() => {
|
|
2637
|
+
if (!isDummyContainer) {
|
|
2638
|
+
setTimeout(() => setWaitForContextRerender(false), 0);
|
|
2639
|
+
}
|
|
2640
|
+
return () => {
|
|
2641
|
+
setRequest(void 0);
|
|
2642
|
+
};
|
|
2643
|
+
}, [isDummyContainer]);
|
|
2644
|
+
return {
|
|
2645
|
+
data: isDummyContainer || isLoading ? data : state.payload,
|
|
2646
|
+
isLoading
|
|
2647
|
+
};
|
|
2648
|
+
}
|
|
2723
2649
|
const errorButtonStyles = {
|
|
2724
2650
|
background: "#eb6337",
|
|
2725
2651
|
padding: "12px 18px",
|
|
@@ -2732,22 +2658,6 @@ const errorButtonStyles = {
|
|
|
2732
2658
|
color: "white",
|
|
2733
2659
|
margin: "1rem 0"
|
|
2734
2660
|
};
|
|
2735
|
-
const SetupHooks = (props) => {
|
|
2736
|
-
const cms = useCMS();
|
|
2737
|
-
const [payload, isLoading] = useGraphqlForms({
|
|
2738
|
-
query: (gql2) => gql2(props.query),
|
|
2739
|
-
variables: props.variables || {},
|
|
2740
|
-
formify: (args) => {
|
|
2741
|
-
if (props.formifyCallback) {
|
|
2742
|
-
return props.formifyCallback(args, cms);
|
|
2743
|
-
} else {
|
|
2744
|
-
return args.createForm(args.formConfig);
|
|
2745
|
-
}
|
|
2746
|
-
}
|
|
2747
|
-
});
|
|
2748
|
-
useDocumentCreatorPlugin(props.documentCreatorCallback);
|
|
2749
|
-
return /* @__PURE__ */ React.createElement(ErrorBoundary, null, isLoading ? /* @__PURE__ */ React.createElement(Loader, null, props.children(props)) : props.children(__spreadProps(__spreadValues({}, props), { data: payload })));
|
|
2750
|
-
};
|
|
2751
2661
|
class ErrorBoundary extends React.Component {
|
|
2752
2662
|
constructor(props) {
|
|
2753
2663
|
super(props);
|
|
@@ -2822,19 +2732,14 @@ const parseURL = (url) => {
|
|
|
2822
2732
|
};
|
|
2823
2733
|
const TinaCMSProvider2 = (_c) => {
|
|
2824
2734
|
var _d = _c, {
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
tinaioConfig
|
|
2735
|
+
query,
|
|
2736
|
+
documentCreatorCallback,
|
|
2737
|
+
formifyCallback
|
|
2829
2738
|
} = _d, props = __objRest(_d, [
|
|
2830
|
-
"
|
|
2831
|
-
"
|
|
2832
|
-
"
|
|
2833
|
-
"tinaioConfig"
|
|
2739
|
+
"query",
|
|
2740
|
+
"documentCreatorCallback",
|
|
2741
|
+
"formifyCallback"
|
|
2834
2742
|
]);
|
|
2835
|
-
if (typeof props.query === "string") {
|
|
2836
|
-
props.query;
|
|
2837
|
-
}
|
|
2838
2743
|
const validOldSetup = new Boolean(props == null ? void 0 : props.isLocalClient) || new Boolean(props == null ? void 0 : props.clientId) && new Boolean(props == null ? void 0 : props.branch);
|
|
2839
2744
|
if (!props.apiURL && !validOldSetup) {
|
|
2840
2745
|
throw new Error(`apiURL is a required field`);
|
|
@@ -2844,18 +2749,88 @@ const TinaCMSProvider2 = (_c) => {
|
|
|
2844
2749
|
clientId: props.clientId,
|
|
2845
2750
|
isLocalClient: props.isLocalClient
|
|
2846
2751
|
};
|
|
2847
|
-
return /* @__PURE__ */ React.createElement(TinaCloudProvider, {
|
|
2752
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(TinaCloudProvider, {
|
|
2848
2753
|
branch,
|
|
2849
2754
|
clientId,
|
|
2850
|
-
tinaioConfig,
|
|
2755
|
+
tinaioConfig: props.tinaioConfig,
|
|
2851
2756
|
isLocalClient,
|
|
2852
|
-
cmsCallback,
|
|
2853
|
-
mediaStore
|
|
2854
|
-
}, /* @__PURE__ */ React.createElement("style", null, styles),
|
|
2855
|
-
|
|
2856
|
-
},
|
|
2857
|
-
|
|
2858
|
-
}
|
|
2757
|
+
cmsCallback: props.cmsCallback,
|
|
2758
|
+
mediaStore: props.mediaStore
|
|
2759
|
+
}, /* @__PURE__ */ React.createElement("style", null, styles), /* @__PURE__ */ React.createElement(ErrorBoundary, null, /* @__PURE__ */ React.createElement(DocumentCreator, {
|
|
2760
|
+
documentCreatorCallback
|
|
2761
|
+
}), /* @__PURE__ */ React.createElement(TinaDataProvider, {
|
|
2762
|
+
formifyCallback
|
|
2763
|
+
}, typeof props.children == "function" ? /* @__PURE__ */ React.createElement(TinaQuery, __spreadProps(__spreadValues({}, props), {
|
|
2764
|
+
variables: props.variables,
|
|
2765
|
+
data: props.data,
|
|
2766
|
+
query,
|
|
2767
|
+
formifyCallback,
|
|
2768
|
+
children: props.children
|
|
2769
|
+
})) : props.children))));
|
|
2770
|
+
};
|
|
2771
|
+
const DocumentCreator = ({
|
|
2772
|
+
documentCreatorCallback
|
|
2773
|
+
}) => {
|
|
2774
|
+
useDocumentCreatorPlugin(documentCreatorCallback);
|
|
2775
|
+
return null;
|
|
2776
|
+
};
|
|
2777
|
+
const TinaQuery = (props) => {
|
|
2778
|
+
return /* @__PURE__ */ React.createElement(TinaQueryInner, __spreadValues({
|
|
2779
|
+
key: `rootQuery-${props.query}`
|
|
2780
|
+
}, props));
|
|
2781
|
+
};
|
|
2782
|
+
const TinaQueryInner = (_e) => {
|
|
2783
|
+
var _f = _e, { children } = _f, props = __objRest(_f, ["children"]);
|
|
2784
|
+
const { data: liveData, isLoading } = useTina({
|
|
2785
|
+
query: props.query,
|
|
2786
|
+
variables: props.variables,
|
|
2787
|
+
data: props.data
|
|
2788
|
+
});
|
|
2789
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(isLoading ? props : __spreadProps(__spreadValues({}, props), { data: liveData })));
|
|
2790
|
+
};
|
|
2791
|
+
const TinaDataProvider = ({
|
|
2792
|
+
children,
|
|
2793
|
+
formifyCallback
|
|
2794
|
+
}) => {
|
|
2795
|
+
const [request, setRequest] = useState();
|
|
2796
|
+
const [state, setState] = React.useState({
|
|
2797
|
+
payload: void 0,
|
|
2798
|
+
isLoading: true
|
|
2799
|
+
});
|
|
2800
|
+
return /* @__PURE__ */ React.createElement(TinaDataContext.Provider, {
|
|
2801
|
+
value: {
|
|
2802
|
+
setRequest,
|
|
2803
|
+
isLoading: state.isLoading,
|
|
2804
|
+
state: { payload: state.payload }
|
|
2805
|
+
}
|
|
2806
|
+
}, /* @__PURE__ */ React.createElement(FormRegistrar, {
|
|
2807
|
+
key: request == null ? void 0 : request.query,
|
|
2808
|
+
request,
|
|
2809
|
+
formifyCallback,
|
|
2810
|
+
onPayloadStateChange: setState
|
|
2811
|
+
}), children);
|
|
2812
|
+
};
|
|
2813
|
+
const FormRegistrar = ({
|
|
2814
|
+
request,
|
|
2815
|
+
formifyCallback,
|
|
2816
|
+
onPayloadStateChange
|
|
2817
|
+
}) => {
|
|
2818
|
+
const cms = useCMS();
|
|
2819
|
+
const [payload, isLoading] = useGraphqlForms({
|
|
2820
|
+
query: request == null ? void 0 : request.query,
|
|
2821
|
+
variables: request == null ? void 0 : request.variables,
|
|
2822
|
+
formify: (args) => {
|
|
2823
|
+
if (formifyCallback) {
|
|
2824
|
+
return formifyCallback(args, cms);
|
|
2825
|
+
} else {
|
|
2826
|
+
return args.createForm(args.formConfig);
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
});
|
|
2830
|
+
React.useEffect(() => {
|
|
2831
|
+
onPayloadStateChange({ payload, isLoading });
|
|
2832
|
+
}, [JSON.stringify(payload), isLoading]);
|
|
2833
|
+
return isLoading ? /* @__PURE__ */ React.createElement(Loader, null, /* @__PURE__ */ React.createElement(React.Fragment, null)) : null;
|
|
2859
2834
|
};
|
|
2860
2835
|
const Loader = (props) => {
|
|
2861
2836
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
@@ -3016,17 +2991,195 @@ const Layout = ({ children }) => {
|
|
|
3016
2991
|
}
|
|
3017
2992
|
}, children));
|
|
3018
2993
|
};
|
|
2994
|
+
var DefaultContext = {
|
|
2995
|
+
color: void 0,
|
|
2996
|
+
size: void 0,
|
|
2997
|
+
className: void 0,
|
|
2998
|
+
style: void 0,
|
|
2999
|
+
attr: void 0
|
|
3000
|
+
};
|
|
3001
|
+
var IconContext = React.createContext && React.createContext(DefaultContext);
|
|
3002
|
+
var __assign = function() {
|
|
3003
|
+
__assign = Object.assign || function(t) {
|
|
3004
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
3005
|
+
s = arguments[i];
|
|
3006
|
+
for (var p in s)
|
|
3007
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
3008
|
+
t[p] = s[p];
|
|
3009
|
+
}
|
|
3010
|
+
return t;
|
|
3011
|
+
};
|
|
3012
|
+
return __assign.apply(this, arguments);
|
|
3013
|
+
};
|
|
3014
|
+
var __rest = function(s, e) {
|
|
3015
|
+
var t = {};
|
|
3016
|
+
for (var p in s)
|
|
3017
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
3018
|
+
t[p] = s[p];
|
|
3019
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
3020
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
3021
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
3022
|
+
t[p[i]] = s[p[i]];
|
|
3023
|
+
}
|
|
3024
|
+
return t;
|
|
3025
|
+
};
|
|
3026
|
+
function Tree2Element(tree) {
|
|
3027
|
+
return tree && tree.map(function(node, i) {
|
|
3028
|
+
return React.createElement(node.tag, __assign({
|
|
3029
|
+
key: i
|
|
3030
|
+
}, node.attr), Tree2Element(node.child));
|
|
3031
|
+
});
|
|
3032
|
+
}
|
|
3033
|
+
function GenIcon(data) {
|
|
3034
|
+
return function(props) {
|
|
3035
|
+
return React.createElement(IconBase, __assign({
|
|
3036
|
+
attr: __assign({}, data.attr)
|
|
3037
|
+
}, props), Tree2Element(data.child));
|
|
3038
|
+
};
|
|
3039
|
+
}
|
|
3040
|
+
function IconBase(props) {
|
|
3041
|
+
var elem = function(conf) {
|
|
3042
|
+
var attr = props.attr, size = props.size, title = props.title, svgProps = __rest(props, ["attr", "size", "title"]);
|
|
3043
|
+
var computedSize = size || conf.size || "1em";
|
|
3044
|
+
var className;
|
|
3045
|
+
if (conf.className)
|
|
3046
|
+
className = conf.className;
|
|
3047
|
+
if (props.className)
|
|
3048
|
+
className = (className ? className + " " : "") + props.className;
|
|
3049
|
+
return React.createElement("svg", __assign({
|
|
3050
|
+
stroke: "currentColor",
|
|
3051
|
+
fill: "currentColor",
|
|
3052
|
+
strokeWidth: "0"
|
|
3053
|
+
}, conf.attr, attr, svgProps, {
|
|
3054
|
+
className,
|
|
3055
|
+
style: __assign(__assign({
|
|
3056
|
+
color: props.color || conf.color
|
|
3057
|
+
}, conf.style), props.style),
|
|
3058
|
+
height: computedSize,
|
|
3059
|
+
width: computedSize,
|
|
3060
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
3061
|
+
}), title && React.createElement("title", null, title), props.children);
|
|
3062
|
+
};
|
|
3063
|
+
return IconContext !== void 0 ? React.createElement(IconContext.Consumer, null, function(conf) {
|
|
3064
|
+
return elem(conf);
|
|
3065
|
+
}) : elem(DefaultContext);
|
|
3066
|
+
}
|
|
3067
|
+
function BiEdit(props) {
|
|
3068
|
+
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);
|
|
3069
|
+
}
|
|
3070
|
+
function BiExit(props) {
|
|
3071
|
+
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);
|
|
3072
|
+
}
|
|
3073
|
+
function BiLinkExternal(props) {
|
|
3074
|
+
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);
|
|
3075
|
+
}
|
|
3076
|
+
function BiLogIn(props) {
|
|
3077
|
+
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);
|
|
3078
|
+
}
|
|
3079
|
+
function BiLogOut(props) {
|
|
3080
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M16 13v-2H7V8l-5 4 5 4v-3z" } }, { "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);
|
|
3081
|
+
}
|
|
3019
3082
|
function ImFilesEmpty(props) {
|
|
3020
3083
|
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);
|
|
3021
3084
|
}
|
|
3022
3085
|
function VscOpenPreview(props) {
|
|
3023
3086
|
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);
|
|
3024
3087
|
}
|
|
3088
|
+
class TinaAdminApi {
|
|
3089
|
+
constructor(TinaApi) {
|
|
3090
|
+
this.api = TinaApi;
|
|
3091
|
+
}
|
|
3092
|
+
async fetchCollections() {
|
|
3093
|
+
const response = await this.api.request(`query{ getCollections { label, name } }`, { variables: {} });
|
|
3094
|
+
return response;
|
|
3095
|
+
}
|
|
3096
|
+
async fetchCollection(collectionName, includeDocuments) {
|
|
3097
|
+
const response = await this.api.request(`
|
|
3098
|
+
query($collection: String!, $includeDocuments: Boolean!){
|
|
3099
|
+
getCollection(collection: $collection){
|
|
3100
|
+
name
|
|
3101
|
+
label
|
|
3102
|
+
format
|
|
3103
|
+
templates
|
|
3104
|
+
documents @include(if: $includeDocuments) {
|
|
3105
|
+
totalCount
|
|
3106
|
+
edges {
|
|
3107
|
+
node {
|
|
3108
|
+
... on Document {
|
|
3109
|
+
sys {
|
|
3110
|
+
template
|
|
3111
|
+
breadcrumbs
|
|
3112
|
+
path
|
|
3113
|
+
basename
|
|
3114
|
+
relativePath
|
|
3115
|
+
filename
|
|
3116
|
+
extension
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
}`, { variables: { collection: collectionName, includeDocuments } });
|
|
3124
|
+
return response;
|
|
3125
|
+
}
|
|
3126
|
+
async fetchDocument(collectionName, relativePath) {
|
|
3127
|
+
const response = await this.api.request(`
|
|
3128
|
+
query($collection: String!, $relativePath: String!) {
|
|
3129
|
+
getDocument(collection:$collection, relativePath:$relativePath) {
|
|
3130
|
+
... on Document {
|
|
3131
|
+
form
|
|
3132
|
+
values
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
}`, { variables: { collection: collectionName, relativePath } });
|
|
3136
|
+
return response;
|
|
3137
|
+
}
|
|
3138
|
+
async fetchDocumentFields() {
|
|
3139
|
+
const response = await this.api.request(`query { getDocumentFields }`, { variables: {} });
|
|
3140
|
+
return response;
|
|
3141
|
+
}
|
|
3142
|
+
async createDocument(collectionName, relativePath, params) {
|
|
3143
|
+
const response = await this.api.request(`#graphql
|
|
3144
|
+
mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
3145
|
+
createDocument(
|
|
3146
|
+
collection: $collection,
|
|
3147
|
+
relativePath: $relativePath,
|
|
3148
|
+
params: $params
|
|
3149
|
+
){__typename}
|
|
3150
|
+
}`, {
|
|
3151
|
+
variables: {
|
|
3152
|
+
collection: collectionName,
|
|
3153
|
+
relativePath,
|
|
3154
|
+
params
|
|
3155
|
+
}
|
|
3156
|
+
});
|
|
3157
|
+
return response;
|
|
3158
|
+
}
|
|
3159
|
+
async updateDocument(collectionName, relativePath, params) {
|
|
3160
|
+
const response = await this.api.request(`#graphql
|
|
3161
|
+
mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
3162
|
+
updateDocument(
|
|
3163
|
+
collection: $collection,
|
|
3164
|
+
relativePath: $relativePath,
|
|
3165
|
+
params: $params
|
|
3166
|
+
){__typename}
|
|
3167
|
+
}`, {
|
|
3168
|
+
variables: {
|
|
3169
|
+
collection: collectionName,
|
|
3170
|
+
relativePath,
|
|
3171
|
+
params
|
|
3172
|
+
}
|
|
3173
|
+
});
|
|
3174
|
+
return response;
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3025
3177
|
const useGetCollections = (cms) => {
|
|
3178
|
+
const api = new TinaAdminApi(cms.api.tina);
|
|
3026
3179
|
const [collections, setCollections] = useState([]);
|
|
3027
3180
|
useEffect(() => {
|
|
3028
3181
|
const fetchCollections = async () => {
|
|
3029
|
-
const response = await
|
|
3182
|
+
const response = await api.fetchCollections();
|
|
3030
3183
|
setCollections(response.getCollections);
|
|
3031
3184
|
};
|
|
3032
3185
|
fetchCollections();
|
|
@@ -3210,36 +3363,11 @@ const DashboardPage = () => {
|
|
|
3210
3363
|
}, "This is your dashboard for editing or creating content. Select a collection on the left to begin."))));
|
|
3211
3364
|
};
|
|
3212
3365
|
const useGetCollection = (cms, collectionName, includeDocuments = true) => {
|
|
3366
|
+
const api = new TinaAdminApi(cms.api.tina);
|
|
3213
3367
|
const [collection, setCollection] = useState(void 0);
|
|
3214
3368
|
useEffect(() => {
|
|
3215
3369
|
const fetchCollection = async () => {
|
|
3216
|
-
const response = await
|
|
3217
|
-
query($collection: String!, $includeDocuments: Boolean!){
|
|
3218
|
-
getCollection(collection: $collection){
|
|
3219
|
-
name
|
|
3220
|
-
label
|
|
3221
|
-
format
|
|
3222
|
-
templates
|
|
3223
|
-
documents @include(if: $includeDocuments) {
|
|
3224
|
-
totalCount
|
|
3225
|
-
edges {
|
|
3226
|
-
node {
|
|
3227
|
-
... on Document {
|
|
3228
|
-
sys {
|
|
3229
|
-
template
|
|
3230
|
-
breadcrumbs
|
|
3231
|
-
path
|
|
3232
|
-
basename
|
|
3233
|
-
relativePath
|
|
3234
|
-
filename
|
|
3235
|
-
extension
|
|
3236
|
-
}
|
|
3237
|
-
}
|
|
3238
|
-
}
|
|
3239
|
-
}
|
|
3240
|
-
}
|
|
3241
|
-
}
|
|
3242
|
-
}`, { variables: { collection: collectionName, includeDocuments } });
|
|
3370
|
+
const response = await api.fetchCollection(collectionName, includeDocuments);
|
|
3243
3371
|
setCollection(response.getCollection);
|
|
3244
3372
|
};
|
|
3245
3373
|
fetchCollection();
|
|
@@ -3368,6 +3496,7 @@ const CollectionListPage = () => {
|
|
|
3368
3496
|
});
|
|
3369
3497
|
};
|
|
3370
3498
|
const useGetDocumentFields = (cms, collectionName, templateName) => {
|
|
3499
|
+
const api = new TinaAdminApi(cms.api.tina);
|
|
3371
3500
|
const [info, setInfo] = useState({
|
|
3372
3501
|
collection: void 0,
|
|
3373
3502
|
template: void 0,
|
|
@@ -3376,7 +3505,7 @@ const useGetDocumentFields = (cms, collectionName, templateName) => {
|
|
|
3376
3505
|
});
|
|
3377
3506
|
useEffect(() => {
|
|
3378
3507
|
const fetchDocumentFields = async () => {
|
|
3379
|
-
const response = await
|
|
3508
|
+
const response = await api.fetchDocumentFields();
|
|
3380
3509
|
const documentFields = response.getDocumentFields;
|
|
3381
3510
|
const collection = documentFields[collectionName].collection;
|
|
3382
3511
|
const mutationInfo = documentFields[collectionName].mutationInfo;
|
|
@@ -3412,6 +3541,7 @@ const GetDocumentFields = ({
|
|
|
3412
3541
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, children({ collection, template, fields, mutationInfo }));
|
|
3413
3542
|
};
|
|
3414
3543
|
const createDocument = async (cms, collection, template, mutationInfo, values) => {
|
|
3544
|
+
const api = new TinaAdminApi(cms.api.tina);
|
|
3415
3545
|
const _a = values, { relativePath } = _a, leftover = __objRest(_a, ["relativePath"]);
|
|
3416
3546
|
const { includeCollection, includeTemplate } = mutationInfo;
|
|
3417
3547
|
const params = transformDocumentIntoMutationRequestPayload(__spreadValues(__spreadValues({
|
|
@@ -3420,17 +3550,7 @@ const createDocument = async (cms, collection, template, mutationInfo, values) =
|
|
|
3420
3550
|
includeCollection,
|
|
3421
3551
|
includeTemplate
|
|
3422
3552
|
});
|
|
3423
|
-
await
|
|
3424
|
-
createDocument(
|
|
3425
|
-
collection: $collection,
|
|
3426
|
-
relativePath: $relativePath,
|
|
3427
|
-
}`, {
|
|
3428
|
-
variables: {
|
|
3429
|
-
collection: collection.name,
|
|
3430
|
-
relativePath,
|
|
3431
|
-
params
|
|
3432
|
-
}
|
|
3433
|
-
});
|
|
3553
|
+
await api.createDocument(collection.name, relativePath, params);
|
|
3434
3554
|
};
|
|
3435
3555
|
const CollectionCreatePage = () => {
|
|
3436
3556
|
const { collectionName, templateName } = useParams();
|
|
@@ -3470,18 +3590,11 @@ const CollectionCreatePage = () => {
|
|
|
3470
3590
|
}));
|
|
3471
3591
|
};
|
|
3472
3592
|
const useGetDocument = (cms, collectionName, relativePath) => {
|
|
3593
|
+
const api = new TinaAdminApi(cms.api.tina);
|
|
3473
3594
|
const [document, setDocument] = useState(void 0);
|
|
3474
3595
|
useEffect(() => {
|
|
3475
3596
|
const fetchDocument = async () => {
|
|
3476
|
-
const response = await
|
|
3477
|
-
query($collection: String!, $relativePath: String!) {
|
|
3478
|
-
getDocument(collection:$collection, relativePath:$relativePath) {
|
|
3479
|
-
... on Document {
|
|
3480
|
-
form
|
|
3481
|
-
values
|
|
3482
|
-
}
|
|
3483
|
-
}
|
|
3484
|
-
}`, { variables: { collection: collectionName, relativePath } });
|
|
3597
|
+
const response = await api.fetchDocument(collectionName, relativePath);
|
|
3485
3598
|
setDocument(response.getDocument);
|
|
3486
3599
|
};
|
|
3487
3600
|
fetchDocument();
|
|
@@ -3501,24 +3614,13 @@ const GetDocument = ({
|
|
|
3501
3614
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(document));
|
|
3502
3615
|
};
|
|
3503
3616
|
const updateDocument = async (cms, relativePath, collection, mutationInfo, values) => {
|
|
3617
|
+
const api = new TinaAdminApi(cms.api.tina);
|
|
3504
3618
|
const { includeCollection, includeTemplate } = mutationInfo;
|
|
3505
3619
|
const params = transformDocumentIntoMutationRequestPayload(values, {
|
|
3506
3620
|
includeCollection,
|
|
3507
3621
|
includeTemplate
|
|
3508
3622
|
});
|
|
3509
|
-
await
|
|
3510
|
-
updateDocument(
|
|
3511
|
-
collection: $collection,
|
|
3512
|
-
relativePath: $relativePath,
|
|
3513
|
-
params: $params
|
|
3514
|
-
){__typename}
|
|
3515
|
-
}`, {
|
|
3516
|
-
variables: {
|
|
3517
|
-
collection: collection.name,
|
|
3518
|
-
relativePath,
|
|
3519
|
-
params
|
|
3520
|
-
}
|
|
3521
|
-
});
|
|
3623
|
+
await api.updateDocument(collection.name, relativePath, params);
|
|
3522
3624
|
};
|
|
3523
3625
|
const CollectionUpdatePage = () => {
|
|
3524
3626
|
const { collectionName, filename } = useParams();
|
|
@@ -3614,4 +3716,4 @@ class RouteMappingPlugin {
|
|
|
3614
3716
|
this.mapper = mapper;
|
|
3615
3717
|
}
|
|
3616
3718
|
}
|
|
3617
|
-
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 };
|
|
3719
|
+
export { AuthWallInner, Client, DEFAULT_LOCAL_TINA_GQL_SERVER_URL, LocalClient, RouteMappingPlugin, TinaAdmin, TinaAdminApi, TinaCMSProvider2, TinaCloudAuthWall, TinaCloudProvider, TinaDataProvider, assertShape, createClient, TinaCMSProvider2 as default, getStaticPropsForTina, gql, safeAssertShape, staticRequest, useDocumentCreatorPlugin, useGraphqlForms, useTinaAuthRedirect };
|