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.js
CHANGED
|
@@ -675,7 +675,7 @@ mutation addPendingDocumentMutation(
|
|
|
675
675
|
}
|
|
676
676
|
}, [action, setSubmitting]);
|
|
677
677
|
return /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
|
|
678
|
-
primary,
|
|
678
|
+
variant: primary ? "primary" : "secondary",
|
|
679
679
|
onClick,
|
|
680
680
|
busy: submitting,
|
|
681
681
|
disabled: submitting
|
|
@@ -863,99 +863,11 @@ mutation addPendingDocumentMutation(
|
|
|
863
863
|
}))));
|
|
864
864
|
};
|
|
865
865
|
const TinaCloudAuthWall = TinaCloudProvider;
|
|
866
|
-
var DefaultContext = {
|
|
867
|
-
color: void 0,
|
|
868
|
-
size: void 0,
|
|
869
|
-
className: void 0,
|
|
870
|
-
style: void 0,
|
|
871
|
-
attr: void 0
|
|
872
|
-
};
|
|
873
|
-
var IconContext = React__default["default"].createContext && React__default["default"].createContext(DefaultContext);
|
|
874
|
-
var __assign = function() {
|
|
875
|
-
__assign = Object.assign || function(t) {
|
|
876
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
877
|
-
s = arguments[i];
|
|
878
|
-
for (var p in s)
|
|
879
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
880
|
-
t[p] = s[p];
|
|
881
|
-
}
|
|
882
|
-
return t;
|
|
883
|
-
};
|
|
884
|
-
return __assign.apply(this, arguments);
|
|
885
|
-
};
|
|
886
|
-
var __rest = function(s, e) {
|
|
887
|
-
var t = {};
|
|
888
|
-
for (var p in s)
|
|
889
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
890
|
-
t[p] = s[p];
|
|
891
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
892
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
893
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
894
|
-
t[p[i]] = s[p[i]];
|
|
895
|
-
}
|
|
896
|
-
return t;
|
|
897
|
-
};
|
|
898
|
-
function Tree2Element(tree) {
|
|
899
|
-
return tree && tree.map(function(node, i) {
|
|
900
|
-
return React__default["default"].createElement(node.tag, __assign({
|
|
901
|
-
key: i
|
|
902
|
-
}, node.attr), Tree2Element(node.child));
|
|
903
|
-
});
|
|
904
|
-
}
|
|
905
|
-
function GenIcon(data) {
|
|
906
|
-
return function(props) {
|
|
907
|
-
return React__default["default"].createElement(IconBase, __assign({
|
|
908
|
-
attr: __assign({}, data.attr)
|
|
909
|
-
}, props), Tree2Element(data.child));
|
|
910
|
-
};
|
|
911
|
-
}
|
|
912
|
-
function IconBase(props) {
|
|
913
|
-
var elem = function(conf) {
|
|
914
|
-
var attr = props.attr, size = props.size, title = props.title, svgProps = __rest(props, ["attr", "size", "title"]);
|
|
915
|
-
var computedSize = size || conf.size || "1em";
|
|
916
|
-
var className;
|
|
917
|
-
if (conf.className)
|
|
918
|
-
className = conf.className;
|
|
919
|
-
if (props.className)
|
|
920
|
-
className = (className ? className + " " : "") + props.className;
|
|
921
|
-
return React__default["default"].createElement("svg", __assign({
|
|
922
|
-
stroke: "currentColor",
|
|
923
|
-
fill: "currentColor",
|
|
924
|
-
strokeWidth: "0"
|
|
925
|
-
}, conf.attr, attr, svgProps, {
|
|
926
|
-
className,
|
|
927
|
-
style: __assign(__assign({
|
|
928
|
-
color: props.color || conf.color
|
|
929
|
-
}, conf.style), props.style),
|
|
930
|
-
height: computedSize,
|
|
931
|
-
width: computedSize,
|
|
932
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
933
|
-
}), title && React__default["default"].createElement("title", null, title), props.children);
|
|
934
|
-
};
|
|
935
|
-
return IconContext !== void 0 ? React__default["default"].createElement(IconContext.Consumer, null, function(conf) {
|
|
936
|
-
return elem(conf);
|
|
937
|
-
}) : elem(DefaultContext);
|
|
938
|
-
}
|
|
939
|
-
function BiEdit(props) {
|
|
940
|
-
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);
|
|
941
|
-
}
|
|
942
|
-
function BiExit(props) {
|
|
943
|
-
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);
|
|
944
|
-
}
|
|
945
|
-
function BiLinkExternal(props) {
|
|
946
|
-
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);
|
|
947
|
-
}
|
|
948
|
-
function BiLogIn(props) {
|
|
949
|
-
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);
|
|
950
|
-
}
|
|
951
|
-
function BiLogOut(props) {
|
|
952
|
-
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);
|
|
953
|
-
}
|
|
954
866
|
function useGraphqlForms({
|
|
955
|
-
query,
|
|
956
867
|
variables,
|
|
957
868
|
onSubmit,
|
|
958
|
-
formify: formify2 = null
|
|
869
|
+
formify: formify2 = null,
|
|
870
|
+
query
|
|
959
871
|
}) {
|
|
960
872
|
const cms = toolkit.useCMS();
|
|
961
873
|
const [formValues, setFormValues] = React__default["default"].useState({});
|
|
@@ -1005,7 +917,6 @@ mutation addPendingDocumentMutation(
|
|
|
1005
917
|
React__default["default"].useEffect(() => {
|
|
1006
918
|
updateData();
|
|
1007
919
|
}, [JSON.stringify(formValues)]);
|
|
1008
|
-
const queryString = graphql.print(query(gql__default["default"]));
|
|
1009
920
|
React__default["default"].useEffect(() => {
|
|
1010
921
|
if (pendingReset) {
|
|
1011
922
|
setData(__spreadProps(__spreadValues({}, data), { [pendingReset]: initialData[pendingReset] }));
|
|
@@ -1013,9 +924,15 @@ mutation addPendingDocumentMutation(
|
|
|
1013
924
|
}
|
|
1014
925
|
}, [pendingReset]);
|
|
1015
926
|
React__default["default"].useEffect(() => {
|
|
927
|
+
if (!query) {
|
|
928
|
+
setIsLoading(false);
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
1016
931
|
const formIds = [];
|
|
1017
932
|
setIsLoading(true);
|
|
1018
|
-
cms.api.tina.requestWithForm(
|
|
933
|
+
cms.api.tina.requestWithForm((gql2) => gql2(query), {
|
|
934
|
+
variables
|
|
935
|
+
}).then((payload) => {
|
|
1019
936
|
cms.plugins.remove(new toolkit.FormMetaPlugin({ name: "tina-admin-link" }));
|
|
1020
937
|
setData(payload);
|
|
1021
938
|
setInitialData(payload);
|
|
@@ -1033,18 +950,6 @@ mutation addPendingDocumentMutation(
|
|
|
1033
950
|
values: yup2.object().required(),
|
|
1034
951
|
form: yup2.object().required()
|
|
1035
952
|
}), `Unable to build form shape for fields at ${queryName}`);
|
|
1036
|
-
if (cms.flags.get("tina-admin")) {
|
|
1037
|
-
const TinaAdminLink = new toolkit.FormMetaPlugin({
|
|
1038
|
-
name: "tina-admin-link",
|
|
1039
|
-
Component: () => /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
1040
|
-
href: `/admin/collections/${result._internalSys.collection.name}/${result._internalSys.filename}`,
|
|
1041
|
-
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"
|
|
1042
|
-
}, /* @__PURE__ */ React__default["default"].createElement(BiLinkExternal, {
|
|
1043
|
-
className: "h-4 w-auto opacity-80 mr-2"
|
|
1044
|
-
}), " Edit in Tina Admin")
|
|
1045
|
-
});
|
|
1046
|
-
cms.plugins.add(TinaAdminLink);
|
|
1047
|
-
}
|
|
1048
953
|
const formConfig = {
|
|
1049
954
|
id: queryName,
|
|
1050
955
|
label: result.form.label,
|
|
@@ -1166,7 +1071,7 @@ mutation addPendingDocumentMutation(
|
|
|
1166
1071
|
}
|
|
1167
1072
|
});
|
|
1168
1073
|
};
|
|
1169
|
-
}, [
|
|
1074
|
+
}, [query, JSON.stringify(variables), currentBranch]);
|
|
1170
1075
|
return [data, isLoading];
|
|
1171
1076
|
}
|
|
1172
1077
|
const transformDocumentIntoMutationRequestPayload = (document, instructions) => {
|
|
@@ -2035,10 +1940,6 @@ Document
|
|
|
2035
1940
|
z-index: 50 !important;
|
|
2036
1941
|
}
|
|
2037
1942
|
|
|
2038
|
-
.tina-tailwind .mr-2 {
|
|
2039
|
-
margin-right: 8px !important;
|
|
2040
|
-
}
|
|
2041
|
-
|
|
2042
1943
|
.tina-tailwind .-ml-1 {
|
|
2043
1944
|
margin-left: -4px !important;
|
|
2044
1945
|
}
|
|
@@ -2055,6 +1956,10 @@ Document
|
|
|
2055
1956
|
margin-bottom: 12px !important;
|
|
2056
1957
|
}
|
|
2057
1958
|
|
|
1959
|
+
.tina-tailwind .mr-2 {
|
|
1960
|
+
margin-right: 8px !important;
|
|
1961
|
+
}
|
|
1962
|
+
|
|
2058
1963
|
.tina-tailwind .ml-1 {
|
|
2059
1964
|
margin-left: 4px !important;
|
|
2060
1965
|
}
|
|
@@ -2099,10 +2004,6 @@ Document
|
|
|
2099
2004
|
height: 100vh !important;
|
|
2100
2005
|
}
|
|
2101
2006
|
|
|
2102
|
-
.tina-tailwind .h-4 {
|
|
2103
|
-
height: 16px !important;
|
|
2104
|
-
}
|
|
2105
|
-
|
|
2106
2007
|
.tina-tailwind .h-auto {
|
|
2107
2008
|
height: auto !important;
|
|
2108
2009
|
}
|
|
@@ -2115,10 +2016,6 @@ Document
|
|
|
2115
2016
|
height: 20px !important;
|
|
2116
2017
|
}
|
|
2117
2018
|
|
|
2118
|
-
.tina-tailwind .w-auto {
|
|
2119
|
-
width: auto !important;
|
|
2120
|
-
}
|
|
2121
|
-
|
|
2122
2019
|
.tina-tailwind .w-full {
|
|
2123
2020
|
width: 100% !important;
|
|
2124
2021
|
}
|
|
@@ -2139,6 +2036,10 @@ Document
|
|
|
2139
2036
|
width: 24px !important;
|
|
2140
2037
|
}
|
|
2141
2038
|
|
|
2039
|
+
.tina-tailwind .w-auto {
|
|
2040
|
+
width: auto !important;
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2142
2043
|
.tina-tailwind .w-56 {
|
|
2143
2044
|
width: 224px !important;
|
|
2144
2045
|
}
|
|
@@ -2306,10 +2207,6 @@ Document
|
|
|
2306
2207
|
border-width: 1px !important;
|
|
2307
2208
|
}
|
|
2308
2209
|
|
|
2309
|
-
.tina-tailwind .border-t {
|
|
2310
|
-
border-top-width: 1px !important;
|
|
2311
|
-
}
|
|
2312
|
-
|
|
2313
2210
|
.tina-tailwind .border-b {
|
|
2314
2211
|
border-bottom-width: 1px !important;
|
|
2315
2212
|
}
|
|
@@ -2318,11 +2215,6 @@ Document
|
|
|
2318
2215
|
border-right-width: 1px !important;
|
|
2319
2216
|
}
|
|
2320
2217
|
|
|
2321
|
-
.tina-tailwind .border-gray-100 {
|
|
2322
|
-
--tw-border-opacity: 1 !important;
|
|
2323
|
-
border-color: rgba(237, 236, 243, var(--tw-border-opacity)) !important;
|
|
2324
|
-
}
|
|
2325
|
-
|
|
2326
2218
|
.tina-tailwind .border-gray-200 {
|
|
2327
2219
|
--tw-border-opacity: 1 !important;
|
|
2328
2220
|
border-color: rgba(225, 221, 236, var(--tw-border-opacity)) !important;
|
|
@@ -2368,16 +2260,6 @@ Document
|
|
|
2368
2260
|
--tw-gradient-to: #F6F6F9 !important;
|
|
2369
2261
|
}
|
|
2370
2262
|
|
|
2371
|
-
.tina-tailwind .px-5 {
|
|
2372
|
-
padding-left: 20px !important;
|
|
2373
|
-
padding-right: 20px !important;
|
|
2374
|
-
}
|
|
2375
|
-
|
|
2376
|
-
.tina-tailwind .py-2 {
|
|
2377
|
-
padding-top: 8px !important;
|
|
2378
|
-
padding-bottom: 8px !important;
|
|
2379
|
-
}
|
|
2380
|
-
|
|
2381
2263
|
.tina-tailwind .px-4 {
|
|
2382
2264
|
padding-left: 16px !important;
|
|
2383
2265
|
padding-right: 16px !important;
|
|
@@ -2388,6 +2270,11 @@ Document
|
|
|
2388
2270
|
padding-bottom: 24px !important;
|
|
2389
2271
|
}
|
|
2390
2272
|
|
|
2273
|
+
.tina-tailwind .px-5 {
|
|
2274
|
+
padding-left: 20px !important;
|
|
2275
|
+
padding-right: 20px !important;
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2391
2278
|
.tina-tailwind .py-4 {
|
|
2392
2279
|
padding-top: 16px !important;
|
|
2393
2280
|
padding-bottom: 16px !important;
|
|
@@ -2403,6 +2290,11 @@ Document
|
|
|
2403
2290
|
padding-bottom: 4px !important;
|
|
2404
2291
|
}
|
|
2405
2292
|
|
|
2293
|
+
.tina-tailwind .py-2 {
|
|
2294
|
+
padding-top: 8px !important;
|
|
2295
|
+
padding-bottom: 8px !important;
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2406
2298
|
.tina-tailwind .py-7 {
|
|
2407
2299
|
padding-top: 28px !important;
|
|
2408
2300
|
padding-bottom: 28px !important;
|
|
@@ -2458,11 +2350,6 @@ Document
|
|
|
2458
2350
|
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;
|
|
2459
2351
|
}
|
|
2460
2352
|
|
|
2461
|
-
.tina-tailwind .text-xs {
|
|
2462
|
-
font-size: 13px !important;
|
|
2463
|
-
line-height: 1.33 !important;
|
|
2464
|
-
}
|
|
2465
|
-
|
|
2466
2353
|
.tina-tailwind .text-2xl {
|
|
2467
2354
|
font-size: 24px !important;
|
|
2468
2355
|
line-height: 1.33 !important;
|
|
@@ -2483,24 +2370,34 @@ Document
|
|
|
2483
2370
|
line-height: 1.43 !important;
|
|
2484
2371
|
}
|
|
2485
2372
|
|
|
2373
|
+
.tina-tailwind .text-md {
|
|
2374
|
+
font-size: 16px !important;
|
|
2375
|
+
line-height: 1.5 !important;
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2486
2378
|
.tina-tailwind .text-3xl {
|
|
2487
2379
|
font-size: 30px !important;
|
|
2488
2380
|
line-height: 1.2 !important;
|
|
2489
2381
|
}
|
|
2490
2382
|
|
|
2383
|
+
.tina-tailwind .text-xs {
|
|
2384
|
+
font-size: 13px !important;
|
|
2385
|
+
line-height: 1.33 !important;
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2491
2388
|
.tina-tailwind .text-4xl {
|
|
2492
2389
|
font-size: 36px !important;
|
|
2493
2390
|
line-height: 1.1 !important;
|
|
2494
2391
|
}
|
|
2495
2392
|
|
|
2496
|
-
.tina-tailwind .font-medium {
|
|
2497
|
-
font-weight: 500 !important;
|
|
2498
|
-
}
|
|
2499
|
-
|
|
2500
2393
|
.tina-tailwind .font-bold {
|
|
2501
2394
|
font-weight: 700 !important;
|
|
2502
2395
|
}
|
|
2503
2396
|
|
|
2397
|
+
.tina-tailwind .font-medium {
|
|
2398
|
+
font-weight: 500 !important;
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2504
2401
|
.tina-tailwind .uppercase {
|
|
2505
2402
|
text-transform: uppercase !important;
|
|
2506
2403
|
}
|
|
@@ -2598,11 +2495,6 @@ Document
|
|
|
2598
2495
|
opacity: .7 !important;
|
|
2599
2496
|
}
|
|
2600
2497
|
|
|
2601
|
-
.tina-tailwind .shadow {
|
|
2602
|
-
--tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) !important;
|
|
2603
|
-
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
|
|
2604
|
-
}
|
|
2605
|
-
|
|
2606
2498
|
.tina-tailwind .shadow-lg {
|
|
2607
2499
|
--tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
|
|
2608
2500
|
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
|
|
@@ -2613,6 +2505,11 @@ Document
|
|
|
2613
2505
|
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
|
|
2614
2506
|
}
|
|
2615
2507
|
|
|
2508
|
+
.tina-tailwind .shadow {
|
|
2509
|
+
--tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) !important;
|
|
2510
|
+
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2616
2513
|
.tina-tailwind .ring-1 {
|
|
2617
2514
|
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color) !important;
|
|
2618
2515
|
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color) !important;
|
|
@@ -2656,10 +2553,6 @@ Document
|
|
|
2656
2553
|
transition-duration: 150ms !important;
|
|
2657
2554
|
}
|
|
2658
2555
|
|
|
2659
|
-
.tina-tailwind .duration-100 {
|
|
2660
|
-
transition-duration: 100ms !important;
|
|
2661
|
-
}
|
|
2662
|
-
|
|
2663
2556
|
.tina-tailwind .duration-150 {
|
|
2664
2557
|
transition-duration: 150ms !important;
|
|
2665
2558
|
}
|
|
@@ -2672,6 +2565,10 @@ Document
|
|
|
2672
2565
|
transition-duration: 75ms !important;
|
|
2673
2566
|
}
|
|
2674
2567
|
|
|
2568
|
+
.tina-tailwind .duration-100 {
|
|
2569
|
+
transition-duration: 100ms !important;
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2675
2572
|
.tina-tailwind .ease-out {
|
|
2676
2573
|
transition-timing-function: cubic-bezier(0, 0, 0.2, 1) !important;
|
|
2677
2574
|
}
|
|
@@ -2695,14 +2592,14 @@ Document
|
|
|
2695
2592
|
background-color: rgba(246, 246, 249, var(--tw-bg-opacity)) !important;
|
|
2696
2593
|
}
|
|
2697
2594
|
|
|
2698
|
-
.hover\\:text-blue-
|
|
2595
|
+
.hover\\:text-blue-600:hover {
|
|
2699
2596
|
--tw-text-opacity: 1 !important;
|
|
2700
|
-
color: rgba(
|
|
2597
|
+
color: rgba(5, 116, 228, var(--tw-text-opacity)) !important;
|
|
2701
2598
|
}
|
|
2702
2599
|
|
|
2703
|
-
.hover\\:text-blue-
|
|
2600
|
+
.hover\\:text-blue-500:hover {
|
|
2704
2601
|
--tw-text-opacity: 1 !important;
|
|
2705
|
-
color: rgba(
|
|
2602
|
+
color: rgba(0, 132, 255, var(--tw-text-opacity)) !important;
|
|
2706
2603
|
}
|
|
2707
2604
|
|
|
2708
2605
|
.hover\\:opacity-100:hover {
|
|
@@ -2740,6 +2637,35 @@ Document
|
|
|
2740
2637
|
}
|
|
2741
2638
|
}
|
|
2742
2639
|
`;
|
|
2640
|
+
function useTina({
|
|
2641
|
+
query,
|
|
2642
|
+
variables,
|
|
2643
|
+
data
|
|
2644
|
+
}) {
|
|
2645
|
+
const {
|
|
2646
|
+
setRequest,
|
|
2647
|
+
state,
|
|
2648
|
+
isDummyContainer,
|
|
2649
|
+
isLoading: contextLoading
|
|
2650
|
+
} = React__default["default"].useContext(sharedctx.TinaDataContext);
|
|
2651
|
+
const [waitForContextRerender, setWaitForContextRerender] = React.useState(!isDummyContainer);
|
|
2652
|
+
const isLoading = contextLoading || waitForContextRerender;
|
|
2653
|
+
React__default["default"].useEffect(() => {
|
|
2654
|
+
setRequest({ query, variables });
|
|
2655
|
+
}, [JSON.stringify(variables), query]);
|
|
2656
|
+
React.useEffect(() => {
|
|
2657
|
+
if (!isDummyContainer) {
|
|
2658
|
+
setTimeout(() => setWaitForContextRerender(false), 0);
|
|
2659
|
+
}
|
|
2660
|
+
return () => {
|
|
2661
|
+
setRequest(void 0);
|
|
2662
|
+
};
|
|
2663
|
+
}, [isDummyContainer]);
|
|
2664
|
+
return {
|
|
2665
|
+
data: isDummyContainer || isLoading ? data : state.payload,
|
|
2666
|
+
isLoading
|
|
2667
|
+
};
|
|
2668
|
+
}
|
|
2743
2669
|
const errorButtonStyles = {
|
|
2744
2670
|
background: "#eb6337",
|
|
2745
2671
|
padding: "12px 18px",
|
|
@@ -2752,22 +2678,6 @@ Document
|
|
|
2752
2678
|
color: "white",
|
|
2753
2679
|
margin: "1rem 0"
|
|
2754
2680
|
};
|
|
2755
|
-
const SetupHooks = (props) => {
|
|
2756
|
-
const cms = toolkit.useCMS();
|
|
2757
|
-
const [payload, isLoading] = useGraphqlForms({
|
|
2758
|
-
query: (gql2) => gql2(props.query),
|
|
2759
|
-
variables: props.variables || {},
|
|
2760
|
-
formify: (args) => {
|
|
2761
|
-
if (props.formifyCallback) {
|
|
2762
|
-
return props.formifyCallback(args, cms);
|
|
2763
|
-
} else {
|
|
2764
|
-
return args.createForm(args.formConfig);
|
|
2765
|
-
}
|
|
2766
|
-
}
|
|
2767
|
-
});
|
|
2768
|
-
useDocumentCreatorPlugin(props.documentCreatorCallback);
|
|
2769
|
-
return /* @__PURE__ */ React__default["default"].createElement(ErrorBoundary, null, isLoading ? /* @__PURE__ */ React__default["default"].createElement(Loader, null, props.children(props)) : props.children(__spreadProps(__spreadValues({}, props), { data: payload })));
|
|
2770
|
-
};
|
|
2771
2681
|
class ErrorBoundary extends React__default["default"].Component {
|
|
2772
2682
|
constructor(props) {
|
|
2773
2683
|
super(props);
|
|
@@ -2842,19 +2752,14 @@ Document
|
|
|
2842
2752
|
};
|
|
2843
2753
|
const TinaCMSProvider2 = (_c) => {
|
|
2844
2754
|
var _d = _c, {
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
tinaioConfig
|
|
2755
|
+
query,
|
|
2756
|
+
documentCreatorCallback,
|
|
2757
|
+
formifyCallback
|
|
2849
2758
|
} = _d, props = __objRest(_d, [
|
|
2850
|
-
"
|
|
2851
|
-
"
|
|
2852
|
-
"
|
|
2853
|
-
"tinaioConfig"
|
|
2759
|
+
"query",
|
|
2760
|
+
"documentCreatorCallback",
|
|
2761
|
+
"formifyCallback"
|
|
2854
2762
|
]);
|
|
2855
|
-
if (typeof props.query === "string") {
|
|
2856
|
-
props.query;
|
|
2857
|
-
}
|
|
2858
2763
|
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);
|
|
2859
2764
|
if (!props.apiURL && !validOldSetup) {
|
|
2860
2765
|
throw new Error(`apiURL is a required field`);
|
|
@@ -2864,18 +2769,88 @@ Document
|
|
|
2864
2769
|
clientId: props.clientId,
|
|
2865
2770
|
isLocalClient: props.isLocalClient
|
|
2866
2771
|
};
|
|
2867
|
-
return /* @__PURE__ */ React__default["default"].createElement(TinaCloudProvider, {
|
|
2772
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement(TinaCloudProvider, {
|
|
2868
2773
|
branch,
|
|
2869
2774
|
clientId,
|
|
2870
|
-
tinaioConfig,
|
|
2775
|
+
tinaioConfig: props.tinaioConfig,
|
|
2871
2776
|
isLocalClient,
|
|
2872
|
-
cmsCallback,
|
|
2873
|
-
mediaStore
|
|
2874
|
-
}, /* @__PURE__ */ React__default["default"].createElement("style", null, styles),
|
|
2875
|
-
|
|
2876
|
-
},
|
|
2877
|
-
|
|
2878
|
-
}
|
|
2777
|
+
cmsCallback: props.cmsCallback,
|
|
2778
|
+
mediaStore: props.mediaStore
|
|
2779
|
+
}, /* @__PURE__ */ React__default["default"].createElement("style", null, styles), /* @__PURE__ */ React__default["default"].createElement(ErrorBoundary, null, /* @__PURE__ */ React__default["default"].createElement(DocumentCreator, {
|
|
2780
|
+
documentCreatorCallback
|
|
2781
|
+
}), /* @__PURE__ */ React__default["default"].createElement(TinaDataProvider, {
|
|
2782
|
+
formifyCallback
|
|
2783
|
+
}, typeof props.children == "function" ? /* @__PURE__ */ React__default["default"].createElement(TinaQuery, __spreadProps(__spreadValues({}, props), {
|
|
2784
|
+
variables: props.variables,
|
|
2785
|
+
data: props.data,
|
|
2786
|
+
query,
|
|
2787
|
+
formifyCallback,
|
|
2788
|
+
children: props.children
|
|
2789
|
+
})) : props.children))));
|
|
2790
|
+
};
|
|
2791
|
+
const DocumentCreator = ({
|
|
2792
|
+
documentCreatorCallback
|
|
2793
|
+
}) => {
|
|
2794
|
+
useDocumentCreatorPlugin(documentCreatorCallback);
|
|
2795
|
+
return null;
|
|
2796
|
+
};
|
|
2797
|
+
const TinaQuery = (props) => {
|
|
2798
|
+
return /* @__PURE__ */ React__default["default"].createElement(TinaQueryInner, __spreadValues({
|
|
2799
|
+
key: `rootQuery-${props.query}`
|
|
2800
|
+
}, props));
|
|
2801
|
+
};
|
|
2802
|
+
const TinaQueryInner = (_e) => {
|
|
2803
|
+
var _f = _e, { children } = _f, props = __objRest(_f, ["children"]);
|
|
2804
|
+
const { data: liveData, isLoading } = useTina({
|
|
2805
|
+
query: props.query,
|
|
2806
|
+
variables: props.variables,
|
|
2807
|
+
data: props.data
|
|
2808
|
+
});
|
|
2809
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(isLoading ? props : __spreadProps(__spreadValues({}, props), { data: liveData })));
|
|
2810
|
+
};
|
|
2811
|
+
const TinaDataProvider = ({
|
|
2812
|
+
children,
|
|
2813
|
+
formifyCallback
|
|
2814
|
+
}) => {
|
|
2815
|
+
const [request, setRequest] = React.useState();
|
|
2816
|
+
const [state, setState] = React__default["default"].useState({
|
|
2817
|
+
payload: void 0,
|
|
2818
|
+
isLoading: true
|
|
2819
|
+
});
|
|
2820
|
+
return /* @__PURE__ */ React__default["default"].createElement(sharedctx.TinaDataContext.Provider, {
|
|
2821
|
+
value: {
|
|
2822
|
+
setRequest,
|
|
2823
|
+
isLoading: state.isLoading,
|
|
2824
|
+
state: { payload: state.payload }
|
|
2825
|
+
}
|
|
2826
|
+
}, /* @__PURE__ */ React__default["default"].createElement(FormRegistrar, {
|
|
2827
|
+
key: request == null ? void 0 : request.query,
|
|
2828
|
+
request,
|
|
2829
|
+
formifyCallback,
|
|
2830
|
+
onPayloadStateChange: setState
|
|
2831
|
+
}), children);
|
|
2832
|
+
};
|
|
2833
|
+
const FormRegistrar = ({
|
|
2834
|
+
request,
|
|
2835
|
+
formifyCallback,
|
|
2836
|
+
onPayloadStateChange
|
|
2837
|
+
}) => {
|
|
2838
|
+
const cms = toolkit.useCMS();
|
|
2839
|
+
const [payload, isLoading] = useGraphqlForms({
|
|
2840
|
+
query: request == null ? void 0 : request.query,
|
|
2841
|
+
variables: request == null ? void 0 : request.variables,
|
|
2842
|
+
formify: (args) => {
|
|
2843
|
+
if (formifyCallback) {
|
|
2844
|
+
return formifyCallback(args, cms);
|
|
2845
|
+
} else {
|
|
2846
|
+
return args.createForm(args.formConfig);
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
});
|
|
2850
|
+
React__default["default"].useEffect(() => {
|
|
2851
|
+
onPayloadStateChange({ payload, isLoading });
|
|
2852
|
+
}, [JSON.stringify(payload), isLoading]);
|
|
2853
|
+
return isLoading ? /* @__PURE__ */ React__default["default"].createElement(Loader, null, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null)) : null;
|
|
2879
2854
|
};
|
|
2880
2855
|
const Loader = (props) => {
|
|
2881
2856
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
@@ -3036,17 +3011,195 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3036
3011
|
}
|
|
3037
3012
|
}, children));
|
|
3038
3013
|
};
|
|
3014
|
+
var DefaultContext = {
|
|
3015
|
+
color: void 0,
|
|
3016
|
+
size: void 0,
|
|
3017
|
+
className: void 0,
|
|
3018
|
+
style: void 0,
|
|
3019
|
+
attr: void 0
|
|
3020
|
+
};
|
|
3021
|
+
var IconContext = React__default["default"].createContext && React__default["default"].createContext(DefaultContext);
|
|
3022
|
+
var __assign = function() {
|
|
3023
|
+
__assign = Object.assign || function(t) {
|
|
3024
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
3025
|
+
s = arguments[i];
|
|
3026
|
+
for (var p in s)
|
|
3027
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
3028
|
+
t[p] = s[p];
|
|
3029
|
+
}
|
|
3030
|
+
return t;
|
|
3031
|
+
};
|
|
3032
|
+
return __assign.apply(this, arguments);
|
|
3033
|
+
};
|
|
3034
|
+
var __rest = function(s, e) {
|
|
3035
|
+
var t = {};
|
|
3036
|
+
for (var p in s)
|
|
3037
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
3038
|
+
t[p] = s[p];
|
|
3039
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
3040
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
3041
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
3042
|
+
t[p[i]] = s[p[i]];
|
|
3043
|
+
}
|
|
3044
|
+
return t;
|
|
3045
|
+
};
|
|
3046
|
+
function Tree2Element(tree) {
|
|
3047
|
+
return tree && tree.map(function(node, i) {
|
|
3048
|
+
return React__default["default"].createElement(node.tag, __assign({
|
|
3049
|
+
key: i
|
|
3050
|
+
}, node.attr), Tree2Element(node.child));
|
|
3051
|
+
});
|
|
3052
|
+
}
|
|
3053
|
+
function GenIcon(data) {
|
|
3054
|
+
return function(props) {
|
|
3055
|
+
return React__default["default"].createElement(IconBase, __assign({
|
|
3056
|
+
attr: __assign({}, data.attr)
|
|
3057
|
+
}, props), Tree2Element(data.child));
|
|
3058
|
+
};
|
|
3059
|
+
}
|
|
3060
|
+
function IconBase(props) {
|
|
3061
|
+
var elem = function(conf) {
|
|
3062
|
+
var attr = props.attr, size = props.size, title = props.title, svgProps = __rest(props, ["attr", "size", "title"]);
|
|
3063
|
+
var computedSize = size || conf.size || "1em";
|
|
3064
|
+
var className;
|
|
3065
|
+
if (conf.className)
|
|
3066
|
+
className = conf.className;
|
|
3067
|
+
if (props.className)
|
|
3068
|
+
className = (className ? className + " " : "") + props.className;
|
|
3069
|
+
return React__default["default"].createElement("svg", __assign({
|
|
3070
|
+
stroke: "currentColor",
|
|
3071
|
+
fill: "currentColor",
|
|
3072
|
+
strokeWidth: "0"
|
|
3073
|
+
}, conf.attr, attr, svgProps, {
|
|
3074
|
+
className,
|
|
3075
|
+
style: __assign(__assign({
|
|
3076
|
+
color: props.color || conf.color
|
|
3077
|
+
}, conf.style), props.style),
|
|
3078
|
+
height: computedSize,
|
|
3079
|
+
width: computedSize,
|
|
3080
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
3081
|
+
}), title && React__default["default"].createElement("title", null, title), props.children);
|
|
3082
|
+
};
|
|
3083
|
+
return IconContext !== void 0 ? React__default["default"].createElement(IconContext.Consumer, null, function(conf) {
|
|
3084
|
+
return elem(conf);
|
|
3085
|
+
}) : elem(DefaultContext);
|
|
3086
|
+
}
|
|
3087
|
+
function BiEdit(props) {
|
|
3088
|
+
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);
|
|
3089
|
+
}
|
|
3090
|
+
function BiExit(props) {
|
|
3091
|
+
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);
|
|
3092
|
+
}
|
|
3093
|
+
function BiLinkExternal(props) {
|
|
3094
|
+
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);
|
|
3095
|
+
}
|
|
3096
|
+
function BiLogIn(props) {
|
|
3097
|
+
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);
|
|
3098
|
+
}
|
|
3099
|
+
function BiLogOut(props) {
|
|
3100
|
+
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);
|
|
3101
|
+
}
|
|
3039
3102
|
function ImFilesEmpty(props) {
|
|
3040
3103
|
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);
|
|
3041
3104
|
}
|
|
3042
3105
|
function VscOpenPreview(props) {
|
|
3043
3106
|
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);
|
|
3044
3107
|
}
|
|
3108
|
+
class TinaAdminApi {
|
|
3109
|
+
constructor(TinaApi) {
|
|
3110
|
+
this.api = TinaApi;
|
|
3111
|
+
}
|
|
3112
|
+
async fetchCollections() {
|
|
3113
|
+
const response = await this.api.request(`query{ getCollections { label, name } }`, { variables: {} });
|
|
3114
|
+
return response;
|
|
3115
|
+
}
|
|
3116
|
+
async fetchCollection(collectionName, includeDocuments) {
|
|
3117
|
+
const response = await this.api.request(`
|
|
3118
|
+
query($collection: String!, $includeDocuments: Boolean!){
|
|
3119
|
+
getCollection(collection: $collection){
|
|
3120
|
+
name
|
|
3121
|
+
label
|
|
3122
|
+
format
|
|
3123
|
+
templates
|
|
3124
|
+
documents @include(if: $includeDocuments) {
|
|
3125
|
+
totalCount
|
|
3126
|
+
edges {
|
|
3127
|
+
node {
|
|
3128
|
+
... on Document {
|
|
3129
|
+
sys {
|
|
3130
|
+
template
|
|
3131
|
+
breadcrumbs
|
|
3132
|
+
path
|
|
3133
|
+
basename
|
|
3134
|
+
relativePath
|
|
3135
|
+
filename
|
|
3136
|
+
extension
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
}`, { variables: { collection: collectionName, includeDocuments } });
|
|
3144
|
+
return response;
|
|
3145
|
+
}
|
|
3146
|
+
async fetchDocument(collectionName, relativePath) {
|
|
3147
|
+
const response = await this.api.request(`
|
|
3148
|
+
query($collection: String!, $relativePath: String!) {
|
|
3149
|
+
getDocument(collection:$collection, relativePath:$relativePath) {
|
|
3150
|
+
... on Document {
|
|
3151
|
+
form
|
|
3152
|
+
values
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
}`, { variables: { collection: collectionName, relativePath } });
|
|
3156
|
+
return response;
|
|
3157
|
+
}
|
|
3158
|
+
async fetchDocumentFields() {
|
|
3159
|
+
const response = await this.api.request(`query { getDocumentFields }`, { variables: {} });
|
|
3160
|
+
return response;
|
|
3161
|
+
}
|
|
3162
|
+
async createDocument(collectionName, relativePath, params) {
|
|
3163
|
+
const response = await this.api.request(`#graphql
|
|
3164
|
+
mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
3165
|
+
createDocument(
|
|
3166
|
+
collection: $collection,
|
|
3167
|
+
relativePath: $relativePath,
|
|
3168
|
+
params: $params
|
|
3169
|
+
){__typename}
|
|
3170
|
+
}`, {
|
|
3171
|
+
variables: {
|
|
3172
|
+
collection: collectionName,
|
|
3173
|
+
relativePath,
|
|
3174
|
+
params
|
|
3175
|
+
}
|
|
3176
|
+
});
|
|
3177
|
+
return response;
|
|
3178
|
+
}
|
|
3179
|
+
async updateDocument(collectionName, relativePath, params) {
|
|
3180
|
+
const response = await this.api.request(`#graphql
|
|
3181
|
+
mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
3182
|
+
updateDocument(
|
|
3183
|
+
collection: $collection,
|
|
3184
|
+
relativePath: $relativePath,
|
|
3185
|
+
params: $params
|
|
3186
|
+
){__typename}
|
|
3187
|
+
}`, {
|
|
3188
|
+
variables: {
|
|
3189
|
+
collection: collectionName,
|
|
3190
|
+
relativePath,
|
|
3191
|
+
params
|
|
3192
|
+
}
|
|
3193
|
+
});
|
|
3194
|
+
return response;
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3045
3197
|
const useGetCollections = (cms) => {
|
|
3198
|
+
const api = new TinaAdminApi(cms.api.tina);
|
|
3046
3199
|
const [collections, setCollections] = React.useState([]);
|
|
3047
3200
|
React.useEffect(() => {
|
|
3048
3201
|
const fetchCollections = async () => {
|
|
3049
|
-
const response = await
|
|
3202
|
+
const response = await api.fetchCollections();
|
|
3050
3203
|
setCollections(response.getCollections);
|
|
3051
3204
|
};
|
|
3052
3205
|
fetchCollections();
|
|
@@ -3230,36 +3383,11 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3230
3383
|
}, "This is your dashboard for editing or creating content. Select a collection on the left to begin."))));
|
|
3231
3384
|
};
|
|
3232
3385
|
const useGetCollection = (cms, collectionName, includeDocuments = true) => {
|
|
3386
|
+
const api = new TinaAdminApi(cms.api.tina);
|
|
3233
3387
|
const [collection, setCollection] = React.useState(void 0);
|
|
3234
3388
|
React.useEffect(() => {
|
|
3235
3389
|
const fetchCollection = async () => {
|
|
3236
|
-
const response = await
|
|
3237
|
-
query($collection: String!, $includeDocuments: Boolean!){
|
|
3238
|
-
getCollection(collection: $collection){
|
|
3239
|
-
name
|
|
3240
|
-
label
|
|
3241
|
-
format
|
|
3242
|
-
templates
|
|
3243
|
-
documents @include(if: $includeDocuments) {
|
|
3244
|
-
totalCount
|
|
3245
|
-
edges {
|
|
3246
|
-
node {
|
|
3247
|
-
... on Document {
|
|
3248
|
-
sys {
|
|
3249
|
-
template
|
|
3250
|
-
breadcrumbs
|
|
3251
|
-
path
|
|
3252
|
-
basename
|
|
3253
|
-
relativePath
|
|
3254
|
-
filename
|
|
3255
|
-
extension
|
|
3256
|
-
}
|
|
3257
|
-
}
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
}
|
|
3261
|
-
}
|
|
3262
|
-
}`, { variables: { collection: collectionName, includeDocuments } });
|
|
3390
|
+
const response = await api.fetchCollection(collectionName, includeDocuments);
|
|
3263
3391
|
setCollection(response.getCollection);
|
|
3264
3392
|
};
|
|
3265
3393
|
fetchCollection();
|
|
@@ -3388,6 +3516,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3388
3516
|
});
|
|
3389
3517
|
};
|
|
3390
3518
|
const useGetDocumentFields = (cms, collectionName, templateName) => {
|
|
3519
|
+
const api = new TinaAdminApi(cms.api.tina);
|
|
3391
3520
|
const [info, setInfo] = React.useState({
|
|
3392
3521
|
collection: void 0,
|
|
3393
3522
|
template: void 0,
|
|
@@ -3396,7 +3525,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3396
3525
|
});
|
|
3397
3526
|
React.useEffect(() => {
|
|
3398
3527
|
const fetchDocumentFields = async () => {
|
|
3399
|
-
const response = await
|
|
3528
|
+
const response = await api.fetchDocumentFields();
|
|
3400
3529
|
const documentFields = response.getDocumentFields;
|
|
3401
3530
|
const collection = documentFields[collectionName].collection;
|
|
3402
3531
|
const mutationInfo = documentFields[collectionName].mutationInfo;
|
|
@@ -3432,6 +3561,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3432
3561
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children({ collection, template, fields, mutationInfo }));
|
|
3433
3562
|
};
|
|
3434
3563
|
const createDocument = async (cms, collection, template, mutationInfo, values) => {
|
|
3564
|
+
const api = new TinaAdminApi(cms.api.tina);
|
|
3435
3565
|
const _a = values, { relativePath } = _a, leftover = __objRest(_a, ["relativePath"]);
|
|
3436
3566
|
const { includeCollection, includeTemplate } = mutationInfo;
|
|
3437
3567
|
const params = transformDocumentIntoMutationRequestPayload(__spreadValues(__spreadValues({
|
|
@@ -3440,17 +3570,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3440
3570
|
includeCollection,
|
|
3441
3571
|
includeTemplate
|
|
3442
3572
|
});
|
|
3443
|
-
await
|
|
3444
|
-
createDocument(
|
|
3445
|
-
collection: $collection,
|
|
3446
|
-
relativePath: $relativePath,
|
|
3447
|
-
}`, {
|
|
3448
|
-
variables: {
|
|
3449
|
-
collection: collection.name,
|
|
3450
|
-
relativePath,
|
|
3451
|
-
params
|
|
3452
|
-
}
|
|
3453
|
-
});
|
|
3573
|
+
await api.createDocument(collection.name, relativePath, params);
|
|
3454
3574
|
};
|
|
3455
3575
|
const CollectionCreatePage = () => {
|
|
3456
3576
|
const { collectionName, templateName } = reactRouterDom.useParams();
|
|
@@ -3490,18 +3610,11 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3490
3610
|
}));
|
|
3491
3611
|
};
|
|
3492
3612
|
const useGetDocument = (cms, collectionName, relativePath) => {
|
|
3613
|
+
const api = new TinaAdminApi(cms.api.tina);
|
|
3493
3614
|
const [document, setDocument] = React.useState(void 0);
|
|
3494
3615
|
React.useEffect(() => {
|
|
3495
3616
|
const fetchDocument = async () => {
|
|
3496
|
-
const response = await
|
|
3497
|
-
query($collection: String!, $relativePath: String!) {
|
|
3498
|
-
getDocument(collection:$collection, relativePath:$relativePath) {
|
|
3499
|
-
... on Document {
|
|
3500
|
-
form
|
|
3501
|
-
values
|
|
3502
|
-
}
|
|
3503
|
-
}
|
|
3504
|
-
}`, { variables: { collection: collectionName, relativePath } });
|
|
3617
|
+
const response = await api.fetchDocument(collectionName, relativePath);
|
|
3505
3618
|
setDocument(response.getDocument);
|
|
3506
3619
|
};
|
|
3507
3620
|
fetchDocument();
|
|
@@ -3521,24 +3634,13 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3521
3634
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(document));
|
|
3522
3635
|
};
|
|
3523
3636
|
const updateDocument = async (cms, relativePath, collection, mutationInfo, values) => {
|
|
3637
|
+
const api = new TinaAdminApi(cms.api.tina);
|
|
3524
3638
|
const { includeCollection, includeTemplate } = mutationInfo;
|
|
3525
3639
|
const params = transformDocumentIntoMutationRequestPayload(values, {
|
|
3526
3640
|
includeCollection,
|
|
3527
3641
|
includeTemplate
|
|
3528
3642
|
});
|
|
3529
|
-
await
|
|
3530
|
-
updateDocument(
|
|
3531
|
-
collection: $collection,
|
|
3532
|
-
relativePath: $relativePath,
|
|
3533
|
-
params: $params
|
|
3534
|
-
){__typename}
|
|
3535
|
-
}`, {
|
|
3536
|
-
variables: {
|
|
3537
|
-
collection: collection.name,
|
|
3538
|
-
relativePath,
|
|
3539
|
-
params
|
|
3540
|
-
}
|
|
3541
|
-
});
|
|
3643
|
+
await api.updateDocument(collection.name, relativePath, params);
|
|
3542
3644
|
};
|
|
3543
3645
|
const CollectionUpdatePage = () => {
|
|
3544
3646
|
const { collectionName, filename } = reactRouterDom.useParams();
|
|
@@ -3640,9 +3742,11 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3640
3742
|
exports2.LocalClient = LocalClient;
|
|
3641
3743
|
exports2.RouteMappingPlugin = RouteMappingPlugin;
|
|
3642
3744
|
exports2.TinaAdmin = TinaAdmin;
|
|
3745
|
+
exports2.TinaAdminApi = TinaAdminApi;
|
|
3643
3746
|
exports2.TinaCMSProvider2 = TinaCMSProvider2;
|
|
3644
3747
|
exports2.TinaCloudAuthWall = TinaCloudAuthWall;
|
|
3645
3748
|
exports2.TinaCloudProvider = TinaCloudProvider;
|
|
3749
|
+
exports2.TinaDataProvider = TinaDataProvider;
|
|
3646
3750
|
exports2.assertShape = assertShape;
|
|
3647
3751
|
exports2.createClient = createClient;
|
|
3648
3752
|
exports2["default"] = TinaCMSProvider2;
|