tinacms 0.66.9 → 0.67.1
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 +81 -0
- package/dist/admin/api.d.ts +4 -0
- package/dist/admin/components/GetCollection.d.ts +1 -0
- package/dist/admin/components/GetCollections.d.ts +1 -1
- package/dist/client/index.d.ts +5 -1
- package/dist/hooks/formify/formify-utils.d.ts +89 -0
- package/dist/hooks/formify/reducer.d.ts +1 -0
- package/dist/hooks/formify/{test → spec}/runner.d.ts +1 -1
- package/dist/hooks/formify/{test → spec}/util.d.ts +0 -0
- package/dist/hooks/formify/types.d.ts +11 -4
- package/dist/hooks/formify/util.d.ts +61 -73
- package/dist/hooks/use-graphql-forms.d.ts +2 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.es.js +713 -506
- package/dist/index.js +710 -504
- package/dist/rich-text.d.ts +1 -0
- package/dist/rich-text.es.js +10 -0
- package/dist/rich-text.js +10 -0
- package/dist/style.css +11 -4
- package/dist/tina-cms.d.ts +5 -3
- package/dist/utils/index.d.ts +3 -1
- package/package.json +4 -3
- package/dist/types/SchemaTypes.d.ts +0 -258
- package/dist/types/index.d.ts +0 -18
package/dist/index.js
CHANGED
|
@@ -30,8 +30,8 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
32
|
(function(global, factory) {
|
|
33
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@tinacms/toolkit"), require("graphql"), require("lodash.set"), require("react"), require("final-form"), require("
|
|
34
|
-
})(this, function(exports2, toolkit, G, set, React, finalForm,
|
|
33
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@tinacms/toolkit"), require("graphql"), require("lodash.set"), require("react"), require("final-form"), require("@tinacms/schema-tools"), require("graphql-tag"), require("yup"), require("styled-components"), require("@tinacms/sharedctx"), require("url-pattern"), require("react-router-dom"), require("@headlessui/react")) : typeof define === "function" && define.amd ? define(["exports", "@tinacms/toolkit", "graphql", "lodash.set", "react", "final-form", "@tinacms/schema-tools", "graphql-tag", "yup", "styled-components", "@tinacms/sharedctx", "url-pattern", "react-router-dom", "@headlessui/react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
|
|
34
|
+
})(this, function(exports2, toolkit, G, set, React, finalForm, schemaTools, gql$1, yup, styled, sharedctx, UrlPattern, reactRouterDom, react) {
|
|
35
35
|
"use strict";
|
|
36
36
|
function _interopDefaultLegacy(e) {
|
|
37
37
|
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
@@ -59,8 +59,8 @@ var __objRest = (source, exclude) => {
|
|
|
59
59
|
var G__namespace = /* @__PURE__ */ _interopNamespace(G);
|
|
60
60
|
var set__default = /* @__PURE__ */ _interopDefaultLegacy(set);
|
|
61
61
|
var React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
|
|
62
|
-
var yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
|
63
62
|
var gql__default = /* @__PURE__ */ _interopDefaultLegacy(gql$1);
|
|
63
|
+
var yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
|
64
64
|
var styled__default = /* @__PURE__ */ _interopDefaultLegacy(styled);
|
|
65
65
|
var UrlPattern__default = /* @__PURE__ */ _interopDefaultLegacy(UrlPattern);
|
|
66
66
|
function popupWindow(url, title, window2, w, h) {
|
|
@@ -400,13 +400,15 @@ var __objRest = (source, exclude) => {
|
|
|
400
400
|
clientId,
|
|
401
401
|
isLocalClient = true,
|
|
402
402
|
branch,
|
|
403
|
-
tinaioConfig
|
|
403
|
+
tinaioConfig,
|
|
404
|
+
schema
|
|
404
405
|
}) => {
|
|
405
|
-
return isLocalClient ? new LocalClient() : new Client({
|
|
406
|
+
return isLocalClient ? new LocalClient({ schema }) : new Client({
|
|
406
407
|
clientId: clientId || "",
|
|
407
408
|
branch: branch || "main",
|
|
408
409
|
tokenStorage: "LOCAL_STORAGE",
|
|
409
|
-
tinaioConfig
|
|
410
|
+
tinaioConfig,
|
|
411
|
+
schema
|
|
410
412
|
});
|
|
411
413
|
};
|
|
412
414
|
function assertShape(value, yupSchema, errorMessage) {
|
|
@@ -434,9 +436,6 @@ var __objRest = (source, exclude) => {
|
|
|
434
436
|
eventList
|
|
435
437
|
}) {
|
|
436
438
|
const cms = toolkit.useCMS();
|
|
437
|
-
React__default["default"].useEffect(() => {
|
|
438
|
-
console.log("NOTE: using unstable formify");
|
|
439
|
-
}, []);
|
|
440
439
|
const state = useFormify({
|
|
441
440
|
query,
|
|
442
441
|
cms,
|
|
@@ -512,11 +511,12 @@ var __objRest = (source, exclude) => {
|
|
|
512
511
|
setIsLoading(false);
|
|
513
512
|
return;
|
|
514
513
|
}
|
|
514
|
+
const useUnstableFormify = (cms == null ? void 0 : cms.flags.get("use-unstable-formify")) === false ? false : true;
|
|
515
515
|
const formIds = [];
|
|
516
516
|
setIsLoading(true);
|
|
517
517
|
cms.api.tina.requestWithForm((gql2) => gql2(query), {
|
|
518
518
|
variables,
|
|
519
|
-
useUnstableFormify
|
|
519
|
+
useUnstableFormify
|
|
520
520
|
}).then((payload) => {
|
|
521
521
|
cms.plugins.remove(new toolkit.FormMetaPlugin({ name: "tina-admin-link" }));
|
|
522
522
|
setData(payload);
|
|
@@ -535,11 +535,10 @@ var __objRest = (source, exclude) => {
|
|
|
535
535
|
values: yup2.object().required(),
|
|
536
536
|
form: yup2.object().required()
|
|
537
537
|
}), `Unable to build form shape for fields at ${queryName}`);
|
|
538
|
-
|
|
538
|
+
let formConfig = {};
|
|
539
|
+
const formCommon = {
|
|
539
540
|
id: queryName,
|
|
540
|
-
label: result.form.label,
|
|
541
541
|
initialValues: result.values,
|
|
542
|
-
fields: result.form.fields,
|
|
543
542
|
reset: () => {
|
|
544
543
|
setPendingReset(queryName);
|
|
545
544
|
},
|
|
@@ -571,6 +570,29 @@ var __objRest = (source, exclude) => {
|
|
|
571
570
|
}
|
|
572
571
|
}
|
|
573
572
|
};
|
|
573
|
+
if (cms.api.tina.schema) {
|
|
574
|
+
const enrichedSchema = cms.api.tina.schema;
|
|
575
|
+
const collection = enrichedSchema.getCollection(result._internalSys.collection.name);
|
|
576
|
+
const template = enrichedSchema.getTemplateForData({
|
|
577
|
+
collection,
|
|
578
|
+
data: result.values
|
|
579
|
+
});
|
|
580
|
+
const formInfo = schemaTools.resolveForm({
|
|
581
|
+
collection,
|
|
582
|
+
basename: collection.name,
|
|
583
|
+
schema: enrichedSchema,
|
|
584
|
+
template
|
|
585
|
+
});
|
|
586
|
+
formConfig = __spreadValues({
|
|
587
|
+
label: formInfo.label,
|
|
588
|
+
fields: formInfo.fields
|
|
589
|
+
}, formCommon);
|
|
590
|
+
} else {
|
|
591
|
+
formConfig = __spreadValues({
|
|
592
|
+
label: result.form.label,
|
|
593
|
+
fields: result.form.fields
|
|
594
|
+
}, formCommon);
|
|
595
|
+
}
|
|
574
596
|
const { createForm, createGlobalForm } = generateFormCreators(cms);
|
|
575
597
|
const SKIPPED = "SKIPPED";
|
|
576
598
|
let form;
|
|
@@ -643,10 +665,8 @@ var __objRest = (source, exclude) => {
|
|
|
643
665
|
}, { values: true });
|
|
644
666
|
});
|
|
645
667
|
}).catch((e) => {
|
|
646
|
-
cms.alerts.error("There was a problem setting up forms for your query");
|
|
647
|
-
console.error("There was a problem setting up forms for your query");
|
|
648
|
-
console.error(e);
|
|
649
668
|
setIsLoading(false);
|
|
669
|
+
throw new Error(`There was a problem setting up forms for your query: ${e.message}`);
|
|
650
670
|
});
|
|
651
671
|
return () => {
|
|
652
672
|
formIds.forEach((name) => {
|
|
@@ -742,100 +762,7 @@ var __objRest = (source, exclude) => {
|
|
|
742
762
|
};
|
|
743
763
|
return { createForm, createGlobalForm };
|
|
744
764
|
};
|
|
745
|
-
const
|
|
746
|
-
if (G__namespace.isUnionType(type)) {
|
|
747
|
-
return type.getTypes().every((type2) => {
|
|
748
|
-
return type2.getInterfaces().find((intfc) => intfc.name === "Node");
|
|
749
|
-
});
|
|
750
|
-
} else if (G__namespace.isObjectType(type)) {
|
|
751
|
-
return !!type.getInterfaces().find((intfc) => intfc.name === "Node");
|
|
752
|
-
} else if (G__namespace.isInterfaceType(type)) {
|
|
753
|
-
if (type.name === "Node") {
|
|
754
|
-
return true;
|
|
755
|
-
}
|
|
756
|
-
} else {
|
|
757
|
-
return false;
|
|
758
|
-
}
|
|
759
|
-
};
|
|
760
|
-
const isConnectionField = (type) => {
|
|
761
|
-
if (G__namespace.isObjectType(type)) {
|
|
762
|
-
return !!type.getInterfaces().find((intfc) => intfc.name === "Connection");
|
|
763
|
-
} else {
|
|
764
|
-
throw new Error(`Expected GraphQLObjectType for isConnectionField check`);
|
|
765
|
-
}
|
|
766
|
-
};
|
|
767
|
-
const getObjectField = (object, selectionNode) => {
|
|
768
|
-
return object.getFields()[selectionNode.name.value];
|
|
769
|
-
};
|
|
770
|
-
const getSelectedUnionType = (unionType, selectionNode) => {
|
|
771
|
-
return unionType.getTypes().find((type) => type.name === selectionNode.typeCondition.name.value);
|
|
772
|
-
};
|
|
773
|
-
function isListType(type) {
|
|
774
|
-
if (G__namespace.isListType(type)) {
|
|
775
|
-
return true;
|
|
776
|
-
} else if (G__namespace.isNonNullType(type)) {
|
|
777
|
-
if (G__namespace.isListType(type.ofType)) {
|
|
778
|
-
return true;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
return false;
|
|
782
|
-
}
|
|
783
|
-
function ensureNodeField(field) {
|
|
784
|
-
if (!isNodeField(field)) {
|
|
785
|
-
throw new Error(`Expected field to implement Node interface`);
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
function ensureUnionType(type) {
|
|
789
|
-
if (!G__namespace.isUnionType(type)) {
|
|
790
|
-
throw new Error(`Expected type to be GraphQLUnionType`);
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
function ensureObjectType(type) {
|
|
794
|
-
if (!G__namespace.isObjectType(type)) {
|
|
795
|
-
console.log(type);
|
|
796
|
-
throw new Error(`Expected type to be GraphQLObjectType`);
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
function ensureOperationDefinition(type) {
|
|
800
|
-
if (type.kind !== "OperationDefinition") {
|
|
801
|
-
throw new Error(`Expected top-level definition to be an OperationDefinition node, ensure your query has been optimized before calling formify`);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
function getNameAndAlias(fieldNode, list, isNode) {
|
|
805
|
-
return {
|
|
806
|
-
name: fieldNode.name.value,
|
|
807
|
-
alias: fieldNode.alias ? fieldNode.alias.value : fieldNode.name.value,
|
|
808
|
-
list: !!list,
|
|
809
|
-
isNode: !!isNode
|
|
810
|
-
};
|
|
811
|
-
}
|
|
812
|
-
const node = G__namespace.parse(`
|
|
813
|
-
query Sample {
|
|
814
|
-
_internalSys: sys {
|
|
815
|
-
path
|
|
816
|
-
collection {
|
|
817
|
-
name
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
form
|
|
821
|
-
values
|
|
822
|
-
}`);
|
|
823
|
-
const metaFields = node.definitions[0].selectionSet.selections;
|
|
824
|
-
const getRelativeBlueprint = (path) => {
|
|
825
|
-
let indexOfLastNode = 0;
|
|
826
|
-
path.forEach((item, i) => {
|
|
827
|
-
if (item.isNode) {
|
|
828
|
-
if (i === path.length - 1)
|
|
829
|
-
;
|
|
830
|
-
else {
|
|
831
|
-
indexOfLastNode = i;
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
});
|
|
835
|
-
const documentBlueprintPath = path.slice(0, indexOfLastNode + 1);
|
|
836
|
-
return getBlueprintNamePath({ path: documentBlueprintPath });
|
|
837
|
-
};
|
|
838
|
-
const getIn2 = (state, path) => {
|
|
765
|
+
const getValueForBlueprint = (state, path) => {
|
|
839
766
|
const pathArray = path.split(".");
|
|
840
767
|
let latest = state;
|
|
841
768
|
pathArray.every((item, index) => {
|
|
@@ -845,7 +772,7 @@ var __objRest = (source, exclude) => {
|
|
|
845
772
|
const next = [];
|
|
846
773
|
if (Array.isArray(latest)) {
|
|
847
774
|
latest.forEach((latest2, index2) => {
|
|
848
|
-
const res =
|
|
775
|
+
const res = getValueForBlueprint(latest2, restOfItems.join("."));
|
|
849
776
|
next.push(res);
|
|
850
777
|
});
|
|
851
778
|
} else {
|
|
@@ -912,9 +839,8 @@ var __objRest = (source, exclude) => {
|
|
|
912
839
|
if (skipped)
|
|
913
840
|
return;
|
|
914
841
|
const id = doc._internalSys.path;
|
|
915
|
-
const
|
|
916
|
-
id
|
|
917
|
-
}, doc.form), {
|
|
842
|
+
const formCommon = {
|
|
843
|
+
id,
|
|
918
844
|
label: doc.form.label,
|
|
919
845
|
initialValues: doc.values,
|
|
920
846
|
onSubmit: async (payload) => {
|
|
@@ -944,7 +870,31 @@ var __objRest = (source, exclude) => {
|
|
|
944
870
|
cms.alerts.error("There was a problem saving your document");
|
|
945
871
|
}
|
|
946
872
|
}
|
|
947
|
-
}
|
|
873
|
+
};
|
|
874
|
+
let formConfig = {};
|
|
875
|
+
if (cms.api.tina.schema) {
|
|
876
|
+
const enrichedSchema = cms.api.tina.schema;
|
|
877
|
+
const collection = enrichedSchema.getCollection(doc._internalSys.collection.name);
|
|
878
|
+
const template = enrichedSchema.getTemplateForData({
|
|
879
|
+
collection,
|
|
880
|
+
data: doc.values
|
|
881
|
+
});
|
|
882
|
+
const formInfo = schemaTools.resolveForm({
|
|
883
|
+
collection,
|
|
884
|
+
basename: collection.name,
|
|
885
|
+
schema: enrichedSchema,
|
|
886
|
+
template
|
|
887
|
+
});
|
|
888
|
+
formConfig = __spreadValues({
|
|
889
|
+
label: formInfo.label,
|
|
890
|
+
fields: formInfo.fields
|
|
891
|
+
}, formCommon);
|
|
892
|
+
} else {
|
|
893
|
+
formConfig = __spreadValues({
|
|
894
|
+
label: doc.form.label,
|
|
895
|
+
fields: doc.form.fields
|
|
896
|
+
}, formCommon);
|
|
897
|
+
}
|
|
948
898
|
if (formify2) {
|
|
949
899
|
form = formify2({
|
|
950
900
|
formConfig,
|
|
@@ -990,19 +940,6 @@ var __objRest = (source, exclude) => {
|
|
|
990
940
|
}
|
|
991
941
|
return accum;
|
|
992
942
|
};
|
|
993
|
-
const getBlueprintId = (path) => {
|
|
994
|
-
const namePath = [];
|
|
995
|
-
const aliasPath = [];
|
|
996
|
-
path.forEach((p) => {
|
|
997
|
-
namePath.push(p.name);
|
|
998
|
-
aliasPath.push(p.alias);
|
|
999
|
-
if (p.list) {
|
|
1000
|
-
namePath.push("[]");
|
|
1001
|
-
aliasPath.push("[]");
|
|
1002
|
-
}
|
|
1003
|
-
});
|
|
1004
|
-
return namePath.join(".");
|
|
1005
|
-
};
|
|
1006
943
|
const getFormNodesStartingWith = (string, state) => {
|
|
1007
944
|
return state.formNodes.filter((subFormNode) => {
|
|
1008
945
|
return subFormNode.documentBlueprintId.startsWith(string);
|
|
@@ -1018,44 +955,6 @@ var __objRest = (source, exclude) => {
|
|
|
1018
955
|
const existing = finalForm.getIn(state.data, pathToChange);
|
|
1019
956
|
return { pathToChange, formNodes, eventLocation, existing };
|
|
1020
957
|
};
|
|
1021
|
-
const matchLocation = (eventLocation, formNode) => {
|
|
1022
|
-
return eventLocation.every((item, index) => item === formNode.location[index]);
|
|
1023
|
-
};
|
|
1024
|
-
const bumpLocation = (location) => {
|
|
1025
|
-
return location.map((item, index) => {
|
|
1026
|
-
if (index === location.length - 1) {
|
|
1027
|
-
return item + 1;
|
|
1028
|
-
}
|
|
1029
|
-
return item;
|
|
1030
|
-
});
|
|
1031
|
-
};
|
|
1032
|
-
const maybeLowerLocation = (location, at) => {
|
|
1033
|
-
return location.map((item, index) => {
|
|
1034
|
-
if (index === location.length - 1) {
|
|
1035
|
-
return item < at ? item : item - 1;
|
|
1036
|
-
}
|
|
1037
|
-
return item;
|
|
1038
|
-
});
|
|
1039
|
-
};
|
|
1040
|
-
const matchesAt = (location, at) => {
|
|
1041
|
-
let matches = false;
|
|
1042
|
-
location.map((item, index) => {
|
|
1043
|
-
if (index === location.length - 1) {
|
|
1044
|
-
if (item === at) {
|
|
1045
|
-
matches = true;
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
});
|
|
1049
|
-
return matches;
|
|
1050
|
-
};
|
|
1051
|
-
const swapLocation = (location, mapping) => {
|
|
1052
|
-
return location.map((item, index) => {
|
|
1053
|
-
if (index === location.length - 1) {
|
|
1054
|
-
return mapping[item];
|
|
1055
|
-
}
|
|
1056
|
-
return item;
|
|
1057
|
-
});
|
|
1058
|
-
};
|
|
1059
958
|
const getBlueprintAliasPath = (blueprint) => {
|
|
1060
959
|
const namePath = [];
|
|
1061
960
|
const aliasPath = [];
|
|
@@ -1071,22 +970,56 @@ var __objRest = (source, exclude) => {
|
|
|
1071
970
|
};
|
|
1072
971
|
const getBlueprintFieldsForEvent = (blueprint, event) => {
|
|
1073
972
|
return blueprint.fields.filter((fbp) => {
|
|
1074
|
-
|
|
973
|
+
if (getBlueprintNamePath(fbp) === getEventPath(event, blueprint)) {
|
|
974
|
+
return true;
|
|
975
|
+
}
|
|
976
|
+
}).filter((fbp) => {
|
|
977
|
+
return filterFieldBlueprintsByParentTypename(fbp, event.field.data.tinaField.parentTypename);
|
|
1075
978
|
});
|
|
1076
979
|
};
|
|
1077
|
-
const
|
|
980
|
+
const filterFieldBlueprintsByParentTypename = (fbp, typename) => {
|
|
981
|
+
let lastDisambiguator;
|
|
982
|
+
fbp.path.forEach((path) => {
|
|
983
|
+
if (path.parentTypename) {
|
|
984
|
+
lastDisambiguator = path.parentTypename;
|
|
985
|
+
}
|
|
986
|
+
});
|
|
987
|
+
if (lastDisambiguator) {
|
|
988
|
+
return typename === lastDisambiguator;
|
|
989
|
+
} else {
|
|
990
|
+
return true;
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
const getBlueprintNamePath = (blueprint, disambiguator) => {
|
|
1078
994
|
const namePath = [];
|
|
1079
|
-
const aliasPath = [];
|
|
1080
995
|
blueprint.path.forEach((p) => {
|
|
996
|
+
if (disambiguator) {
|
|
997
|
+
if (p.parentTypename) {
|
|
998
|
+
namePath.push(p.parentTypename);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1081
1001
|
namePath.push(p.name);
|
|
1082
|
-
aliasPath.push(p.alias);
|
|
1083
1002
|
if (p.list) {
|
|
1084
1003
|
namePath.push("[]");
|
|
1085
|
-
aliasPath.push("[]");
|
|
1086
1004
|
}
|
|
1087
1005
|
});
|
|
1088
1006
|
return namePath.join(".");
|
|
1089
1007
|
};
|
|
1008
|
+
const getEventPath = (event, blueprint) => {
|
|
1009
|
+
const stringArray = event.field.name.split(".");
|
|
1010
|
+
const eventPath = stringArray.map((item) => {
|
|
1011
|
+
if (isNaN(Number(item))) {
|
|
1012
|
+
return item;
|
|
1013
|
+
}
|
|
1014
|
+
return `[]`;
|
|
1015
|
+
}).join(".");
|
|
1016
|
+
const items = [blueprint.id, DATA_NODE_NAME$1, eventPath];
|
|
1017
|
+
const isList = event.field.data.tinaField.list;
|
|
1018
|
+
if (isList && !eventPath.endsWith("[]")) {
|
|
1019
|
+
items.push(`[]`);
|
|
1020
|
+
}
|
|
1021
|
+
return items.join(".");
|
|
1022
|
+
};
|
|
1090
1023
|
const stripIndices = (string) => {
|
|
1091
1024
|
const accum = [];
|
|
1092
1025
|
const stringArray = string.split(".");
|
|
@@ -1108,20 +1041,21 @@ var __objRest = (source, exclude) => {
|
|
|
1108
1041
|
return "[]";
|
|
1109
1042
|
}).join(".");
|
|
1110
1043
|
};
|
|
1044
|
+
const getMatchName = ({ field, prefix, blueprint }) => {
|
|
1045
|
+
const fieldName = field.list ? `${field.name}.[]` : field.name;
|
|
1046
|
+
const blueprintName = getBlueprintNamePath(blueprint);
|
|
1047
|
+
const extra = [];
|
|
1048
|
+
if (prefix) {
|
|
1049
|
+
extra.push(prefix);
|
|
1050
|
+
}
|
|
1051
|
+
const matchName = [blueprintName, DATA_NODE_NAME$1, ...extra, fieldName].join(".");
|
|
1052
|
+
return { matchName, fieldName };
|
|
1053
|
+
};
|
|
1111
1054
|
const getFormNodesFromEvent = (state, event) => {
|
|
1112
1055
|
const formNodes = state.formNodes.filter((formNode) => formNode.documentFormId === event.formId);
|
|
1113
1056
|
return formNodes;
|
|
1114
1057
|
};
|
|
1115
1058
|
const DATA_NODE_NAME$1 = "data";
|
|
1116
|
-
const getEventPath = (event, blueprint) => {
|
|
1117
|
-
const eventPath = replaceRealNum(event.field.name);
|
|
1118
|
-
const items = [blueprint.id, DATA_NODE_NAME$1, eventPath];
|
|
1119
|
-
const isList = event.field.data.tinaField.list;
|
|
1120
|
-
if (isList && !eventPath.endsWith("[]")) {
|
|
1121
|
-
items.push("[]");
|
|
1122
|
-
}
|
|
1123
|
-
return items.join(".");
|
|
1124
|
-
};
|
|
1125
1059
|
const printEvent = (event) => {
|
|
1126
1060
|
var _a, _b;
|
|
1127
1061
|
return {
|
|
@@ -1190,17 +1124,43 @@ var __objRest = (source, exclude) => {
|
|
|
1190
1124
|
}
|
|
1191
1125
|
return newOrderObject;
|
|
1192
1126
|
};
|
|
1193
|
-
const
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1127
|
+
const matchLocation = (eventLocation, formNode) => {
|
|
1128
|
+
return eventLocation.every((item, index) => item === formNode.location[index]);
|
|
1129
|
+
};
|
|
1130
|
+
const bumpLocation = (location) => {
|
|
1131
|
+
return location.map((item, index) => {
|
|
1132
|
+
if (index === location.length - 1) {
|
|
1133
|
+
return item + 1;
|
|
1134
|
+
}
|
|
1135
|
+
return item;
|
|
1136
|
+
});
|
|
1137
|
+
};
|
|
1138
|
+
const maybeLowerLocation = (location, at) => {
|
|
1139
|
+
return location.map((item, index) => {
|
|
1140
|
+
if (index === location.length - 1) {
|
|
1141
|
+
return item < at ? item : item - 1;
|
|
1142
|
+
}
|
|
1143
|
+
return item;
|
|
1144
|
+
});
|
|
1145
|
+
};
|
|
1146
|
+
const matchesAt = (location, at) => {
|
|
1147
|
+
let matches = false;
|
|
1148
|
+
location.map((item, index) => {
|
|
1149
|
+
if (index === location.length - 1) {
|
|
1150
|
+
if (item === at) {
|
|
1151
|
+
matches = true;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1155
|
+
return matches;
|
|
1156
|
+
};
|
|
1157
|
+
const swapLocation = (location, mapping) => {
|
|
1158
|
+
return location.map((item, index) => {
|
|
1159
|
+
if (index === location.length - 1) {
|
|
1160
|
+
return mapping[item];
|
|
1161
|
+
}
|
|
1162
|
+
return item;
|
|
1202
1163
|
});
|
|
1203
|
-
return pathsToChange;
|
|
1204
1164
|
};
|
|
1205
1165
|
const getSubFields = (changeSet) => {
|
|
1206
1166
|
var _a;
|
|
@@ -1211,6 +1171,133 @@ var __objRest = (source, exclude) => {
|
|
|
1211
1171
|
}
|
|
1212
1172
|
return { fields, __typename };
|
|
1213
1173
|
};
|
|
1174
|
+
const isFormifiableDocument = (t) => {
|
|
1175
|
+
const type = G__namespace.getNamedType(t);
|
|
1176
|
+
if (G__namespace.isUnionType(type)) {
|
|
1177
|
+
return type.getTypes().every((type2) => {
|
|
1178
|
+
return type2.getInterfaces().find((intfc) => intfc.name === "Node");
|
|
1179
|
+
});
|
|
1180
|
+
} else if (G__namespace.isObjectType(type)) {
|
|
1181
|
+
return !!type.getInterfaces().find((intfc) => intfc.name === "Node");
|
|
1182
|
+
} else {
|
|
1183
|
+
return false;
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1186
|
+
const isScalarType = (t) => {
|
|
1187
|
+
const namedType = G__namespace.getNamedType(t);
|
|
1188
|
+
return G__namespace.isScalarType(namedType);
|
|
1189
|
+
};
|
|
1190
|
+
const isConnectionField = (t) => {
|
|
1191
|
+
const type = G__namespace.getNamedType(t);
|
|
1192
|
+
if (G__namespace.isObjectType(type)) {
|
|
1193
|
+
return !!type.getInterfaces().find((intfc) => intfc.name === "Connection");
|
|
1194
|
+
} else {
|
|
1195
|
+
throw new Error(`Expected GraphQLObjectType for isConnectionField check`);
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
const getObjectField = (object, selectionNode) => {
|
|
1199
|
+
const namedType = G__namespace.getNamedType(object);
|
|
1200
|
+
ensureObjectOrInterfaceType(namedType);
|
|
1201
|
+
return namedType.getFields()[selectionNode.name.value];
|
|
1202
|
+
};
|
|
1203
|
+
const getSelectedUnionType = (unionType, selectionNode) => {
|
|
1204
|
+
const namedType = G__namespace.getNamedType(unionType);
|
|
1205
|
+
if (!G__namespace.isUnionType(namedType)) {
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
const types = namedType.getTypes();
|
|
1209
|
+
const typeCondition = selectionNode.typeCondition.name.value;
|
|
1210
|
+
let intfc;
|
|
1211
|
+
types.forEach((type) => {
|
|
1212
|
+
intfc = type.getInterfaces().find((intfc2) => intfc2.name === typeCondition);
|
|
1213
|
+
});
|
|
1214
|
+
if (intfc) {
|
|
1215
|
+
return intfc;
|
|
1216
|
+
}
|
|
1217
|
+
return namedType.getTypes().find((type) => type.name === typeCondition);
|
|
1218
|
+
};
|
|
1219
|
+
function isListType(type) {
|
|
1220
|
+
if (G__namespace.isListType(type)) {
|
|
1221
|
+
return true;
|
|
1222
|
+
} else if (G__namespace.isNonNullType(type)) {
|
|
1223
|
+
if (G__namespace.isListType(type.ofType)) {
|
|
1224
|
+
return true;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
return false;
|
|
1228
|
+
}
|
|
1229
|
+
function ensureObjectOrInterfaceType(type) {
|
|
1230
|
+
if (G__namespace.isInterfaceType(type) || G__namespace.isObjectType(type))
|
|
1231
|
+
;
|
|
1232
|
+
else {
|
|
1233
|
+
console.log("Expected type to be GraphQLObjectType or GraphQLInterfaceType", type);
|
|
1234
|
+
throw new Error(`Expected type to be GraphQLObjectType or GraphQLInterfaceType`);
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
function ensureOperationDefinition(type) {
|
|
1238
|
+
if (type.kind !== "OperationDefinition") {
|
|
1239
|
+
throw new Error(`Expected top-level definition to be an OperationDefinition node, ensure your query has been optimized before calling formify`);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
function buildPath({
|
|
1243
|
+
fieldNode,
|
|
1244
|
+
type,
|
|
1245
|
+
parentTypename,
|
|
1246
|
+
path
|
|
1247
|
+
}) {
|
|
1248
|
+
const p = path || [];
|
|
1249
|
+
const list = isListType(type);
|
|
1250
|
+
const isNode = isFormifiableDocument(type);
|
|
1251
|
+
return [
|
|
1252
|
+
...p,
|
|
1253
|
+
{
|
|
1254
|
+
name: fieldNode.name.value,
|
|
1255
|
+
alias: fieldNode.alias ? fieldNode.alias.value : fieldNode.name.value,
|
|
1256
|
+
parentTypename,
|
|
1257
|
+
list: !!list,
|
|
1258
|
+
isNode: !!isNode
|
|
1259
|
+
}
|
|
1260
|
+
];
|
|
1261
|
+
}
|
|
1262
|
+
const node = G__namespace.parse(`
|
|
1263
|
+
query Sample {
|
|
1264
|
+
_internalSys: sys {
|
|
1265
|
+
path
|
|
1266
|
+
collection {
|
|
1267
|
+
name
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
form
|
|
1271
|
+
values
|
|
1272
|
+
}`);
|
|
1273
|
+
const metaFields = node.definitions[0].selectionSet.selections;
|
|
1274
|
+
const getRelativeBlueprint = (path) => {
|
|
1275
|
+
let indexOfLastNode = 0;
|
|
1276
|
+
path.forEach((item, i) => {
|
|
1277
|
+
if (item.isNode) {
|
|
1278
|
+
if (i === path.length - 1)
|
|
1279
|
+
;
|
|
1280
|
+
else {
|
|
1281
|
+
indexOfLastNode = i;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
const documentBlueprintPath = path.slice(0, indexOfLastNode + 1);
|
|
1286
|
+
return getBlueprintNamePath({ path: documentBlueprintPath });
|
|
1287
|
+
};
|
|
1288
|
+
const getBlueprintId = (path) => {
|
|
1289
|
+
const namePath = [];
|
|
1290
|
+
const aliasPath = [];
|
|
1291
|
+
path.forEach((p) => {
|
|
1292
|
+
namePath.push(p.name);
|
|
1293
|
+
aliasPath.push(p.alias);
|
|
1294
|
+
if (p.list) {
|
|
1295
|
+
namePath.push("[]");
|
|
1296
|
+
aliasPath.push("[]");
|
|
1297
|
+
}
|
|
1298
|
+
});
|
|
1299
|
+
return namePath.join(".");
|
|
1300
|
+
};
|
|
1214
1301
|
const NOOP = "This is either an error or is not yet supported";
|
|
1215
1302
|
const UNEXPECTED = "Formify encountered an unexpected error, please contact support";
|
|
1216
1303
|
const EDGES_NODE_NAME = "edges";
|
|
@@ -1243,11 +1330,10 @@ var __objRest = (source, exclude) => {
|
|
|
1243
1330
|
const optimizedQuery = await getOptimizedQuery(documentNodeWithName);
|
|
1244
1331
|
const typeInfo = new G__namespace.TypeInfo(schema);
|
|
1245
1332
|
const formifyConnection = ({
|
|
1246
|
-
|
|
1333
|
+
parentType,
|
|
1247
1334
|
selectionNode,
|
|
1248
1335
|
path
|
|
1249
1336
|
}) => {
|
|
1250
|
-
ensureObjectType(namedFieldType);
|
|
1251
1337
|
return __spreadProps(__spreadValues({}, selectionNode), {
|
|
1252
1338
|
selectionSet: {
|
|
1253
1339
|
kind: "SelectionSet",
|
|
@@ -1255,13 +1341,12 @@ var __objRest = (source, exclude) => {
|
|
|
1255
1341
|
switch (selectionNode2.kind) {
|
|
1256
1342
|
case "Field":
|
|
1257
1343
|
if (selectionNode2.name.value === EDGES_NODE_NAME) {
|
|
1258
|
-
const edgeField =
|
|
1259
|
-
const
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
];
|
|
1344
|
+
const edgeField = getObjectField(parentType, selectionNode2);
|
|
1345
|
+
const edgesPath = buildPath({
|
|
1346
|
+
fieldNode: selectionNode2,
|
|
1347
|
+
type: edgeField.type,
|
|
1348
|
+
path
|
|
1349
|
+
});
|
|
1265
1350
|
return __spreadProps(__spreadValues({}, selectionNode2), {
|
|
1266
1351
|
selectionSet: {
|
|
1267
1352
|
kind: "SelectionSet",
|
|
@@ -1269,15 +1354,15 @@ var __objRest = (source, exclude) => {
|
|
|
1269
1354
|
switch (subSelectionNode.kind) {
|
|
1270
1355
|
case "Field":
|
|
1271
1356
|
if (subSelectionNode.name.value === NODE_NAME) {
|
|
1272
|
-
const nodeField =
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
getNameAndAlias(subSelectionNode, false, true)
|
|
1276
|
-
];
|
|
1277
|
-
return formifyNode({
|
|
1278
|
-
fieldOrInlineFragmentNode: subSelectionNode,
|
|
1357
|
+
const nodeField = getObjectField(edgeField.type, subSelectionNode);
|
|
1358
|
+
return formifyFieldNodeDocument({
|
|
1359
|
+
fieldNode: subSelectionNode,
|
|
1279
1360
|
type: nodeField.type,
|
|
1280
|
-
path:
|
|
1361
|
+
path: buildPath({
|
|
1362
|
+
fieldNode: subSelectionNode,
|
|
1363
|
+
type: nodeField.type,
|
|
1364
|
+
path: edgesPath
|
|
1365
|
+
}),
|
|
1281
1366
|
showInSidebar: false
|
|
1282
1367
|
});
|
|
1283
1368
|
} else {
|
|
@@ -1298,28 +1383,48 @@ var __objRest = (source, exclude) => {
|
|
|
1298
1383
|
}
|
|
1299
1384
|
});
|
|
1300
1385
|
};
|
|
1301
|
-
function
|
|
1302
|
-
|
|
1386
|
+
function formifyInlineFragmentDocument({
|
|
1387
|
+
inlineFragmentNode,
|
|
1388
|
+
type,
|
|
1389
|
+
path,
|
|
1390
|
+
showInSidebar = false
|
|
1391
|
+
}) {
|
|
1392
|
+
return formifyDocument({
|
|
1393
|
+
selection: inlineFragmentNode,
|
|
1394
|
+
type,
|
|
1395
|
+
path,
|
|
1396
|
+
showInSidebar
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
function formifyFieldNodeDocument({
|
|
1400
|
+
fieldNode,
|
|
1401
|
+
type,
|
|
1402
|
+
path,
|
|
1403
|
+
showInSidebar = false
|
|
1404
|
+
}) {
|
|
1405
|
+
return formifyDocument({ selection: fieldNode, type, path, showInSidebar });
|
|
1406
|
+
}
|
|
1407
|
+
function formifyDocument({
|
|
1408
|
+
selection,
|
|
1303
1409
|
type,
|
|
1304
1410
|
path,
|
|
1305
1411
|
showInSidebar = false
|
|
1306
1412
|
}) {
|
|
1307
1413
|
let extraFields = [];
|
|
1308
|
-
const namedType = G__namespace.getNamedType(type);
|
|
1309
1414
|
let hasDataJSONField = false;
|
|
1310
1415
|
let hasValuesField = false;
|
|
1311
1416
|
let shouldFormify = false;
|
|
1312
|
-
|
|
1313
|
-
if (
|
|
1314
|
-
if (
|
|
1417
|
+
selection.selectionSet.selections.forEach((selection2) => {
|
|
1418
|
+
if (selection2.kind === "Field") {
|
|
1419
|
+
if (selection2.name.value === "dataJSON") {
|
|
1315
1420
|
shouldFormify = true;
|
|
1316
1421
|
hasDataJSONField = true;
|
|
1317
1422
|
}
|
|
1318
|
-
if (
|
|
1423
|
+
if (selection2.name.value === "values") {
|
|
1319
1424
|
shouldFormify = true;
|
|
1320
1425
|
hasValuesField = true;
|
|
1321
1426
|
}
|
|
1322
|
-
if (
|
|
1427
|
+
if (selection2.name.value === "data") {
|
|
1323
1428
|
shouldFormify = true;
|
|
1324
1429
|
}
|
|
1325
1430
|
}
|
|
@@ -1328,7 +1433,7 @@ var __objRest = (source, exclude) => {
|
|
|
1328
1433
|
blueprints.push({
|
|
1329
1434
|
id: getBlueprintId(path),
|
|
1330
1435
|
path,
|
|
1331
|
-
selection
|
|
1436
|
+
selection,
|
|
1332
1437
|
fields: [],
|
|
1333
1438
|
showInSidebar,
|
|
1334
1439
|
hasDataJSONField,
|
|
@@ -1336,71 +1441,58 @@ var __objRest = (source, exclude) => {
|
|
|
1336
1441
|
});
|
|
1337
1442
|
extraFields = metaFields;
|
|
1338
1443
|
}
|
|
1339
|
-
|
|
1444
|
+
return __spreadProps(__spreadValues({}, selection), {
|
|
1340
1445
|
selectionSet: {
|
|
1341
1446
|
kind: "SelectionSet",
|
|
1342
1447
|
selections: [
|
|
1343
|
-
...
|
|
1448
|
+
...selection.selectionSet.selections.map((selectionNode) => {
|
|
1344
1449
|
switch (selectionNode.kind) {
|
|
1345
|
-
case "InlineFragment":
|
|
1450
|
+
case "InlineFragment": {
|
|
1451
|
+
const namedType = G__namespace.getNamedType(type);
|
|
1346
1452
|
if (G__namespace.isInterfaceType(namedType)) {
|
|
1347
|
-
const
|
|
1348
|
-
return
|
|
1349
|
-
|
|
1350
|
-
type:
|
|
1453
|
+
const subType = schema.getImplementations(namedType).objects.find((item) => item.name === selectionNode.typeCondition.name.value);
|
|
1454
|
+
return formifyInlineFragmentDocument({
|
|
1455
|
+
inlineFragmentNode: selectionNode,
|
|
1456
|
+
type: subType,
|
|
1351
1457
|
path,
|
|
1352
|
-
showInSidebar:
|
|
1458
|
+
showInSidebar: true
|
|
1353
1459
|
});
|
|
1354
1460
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
type: subType,
|
|
1360
|
-
path,
|
|
1361
|
-
showInSidebar
|
|
1461
|
+
return formifyInlineFragmentNode({
|
|
1462
|
+
inlineFragmentNode: selectionNode,
|
|
1463
|
+
parentType: type,
|
|
1464
|
+
path
|
|
1362
1465
|
});
|
|
1363
|
-
|
|
1466
|
+
}
|
|
1467
|
+
case "Field": {
|
|
1364
1468
|
if (selectionNode.name.value === DATA_NODE_NAME) {
|
|
1365
|
-
const
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
...path2,
|
|
1390
|
-
getNameAndAlias(subSelectionNode, isListType(subSelectionField.type), isNodeField(subSelectionType))
|
|
1391
|
-
]
|
|
1392
|
-
});
|
|
1393
|
-
default:
|
|
1394
|
-
throw new FormifyError("UNEXPECTED", `selection ${subSelectionNode.kind}`);
|
|
1395
|
-
}
|
|
1396
|
-
})
|
|
1397
|
-
]
|
|
1398
|
-
}
|
|
1399
|
-
});
|
|
1400
|
-
}
|
|
1401
|
-
throw new FormifyError("UNEXPECTED");
|
|
1469
|
+
const field = getObjectField(type, selectionNode);
|
|
1470
|
+
return __spreadProps(__spreadValues({}, selectionNode), {
|
|
1471
|
+
selectionSet: {
|
|
1472
|
+
kind: "SelectionSet",
|
|
1473
|
+
selections: [
|
|
1474
|
+
...selectionNode.selectionSet.selections.map((subSelectionNode) => {
|
|
1475
|
+
switch (subSelectionNode.kind) {
|
|
1476
|
+
case "Field":
|
|
1477
|
+
return formifyFieldNode({
|
|
1478
|
+
fieldNode: subSelectionNode,
|
|
1479
|
+
parentType: field.type,
|
|
1480
|
+
path: buildPath({
|
|
1481
|
+
fieldNode: selectionNode,
|
|
1482
|
+
type: field.type,
|
|
1483
|
+
path
|
|
1484
|
+
})
|
|
1485
|
+
});
|
|
1486
|
+
default:
|
|
1487
|
+
throw new FormifyError("UNEXPECTED", `selection ${subSelectionNode.kind}`);
|
|
1488
|
+
}
|
|
1489
|
+
})
|
|
1490
|
+
]
|
|
1491
|
+
}
|
|
1492
|
+
});
|
|
1402
1493
|
}
|
|
1403
1494
|
return selectionNode;
|
|
1495
|
+
}
|
|
1404
1496
|
default:
|
|
1405
1497
|
throw new FormifyError("UNEXPECTED");
|
|
1406
1498
|
}
|
|
@@ -1409,32 +1501,35 @@ var __objRest = (source, exclude) => {
|
|
|
1409
1501
|
]
|
|
1410
1502
|
}
|
|
1411
1503
|
});
|
|
1412
|
-
return formifiedNode;
|
|
1413
1504
|
}
|
|
1414
|
-
const
|
|
1505
|
+
const formifyFieldNode = ({
|
|
1415
1506
|
fieldNode,
|
|
1416
1507
|
parentType,
|
|
1417
1508
|
path
|
|
1418
1509
|
}) => {
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1510
|
+
if (fieldNode.name.value === "__typename") {
|
|
1511
|
+
return fieldNode;
|
|
1512
|
+
}
|
|
1513
|
+
const field = getObjectField(parentType, fieldNode);
|
|
1422
1514
|
if (!field) {
|
|
1423
|
-
|
|
1424
|
-
return fieldNode;
|
|
1425
|
-
} else {
|
|
1426
|
-
throw new FormifyError("UNEXPECTED", `field with no associated type ${fieldNode.name.value}`);
|
|
1427
|
-
}
|
|
1515
|
+
return fieldNode;
|
|
1428
1516
|
}
|
|
1429
|
-
const namedType = G__namespace.getNamedType(field.type);
|
|
1430
|
-
const fieldBlueprint = {
|
|
1431
|
-
id: getBlueprintId([...path]),
|
|
1432
|
-
documentBlueprintId: getRelativeBlueprint(path),
|
|
1433
|
-
path: [...path]
|
|
1434
|
-
};
|
|
1435
1517
|
const blueprint = blueprints.find((blueprint2) => blueprint2.id === getRelativeBlueprint(path));
|
|
1436
|
-
blueprint
|
|
1437
|
-
|
|
1518
|
+
if (!blueprint) {
|
|
1519
|
+
return fieldNode;
|
|
1520
|
+
}
|
|
1521
|
+
const fieldPath = buildPath({
|
|
1522
|
+
fieldNode,
|
|
1523
|
+
type: field.type,
|
|
1524
|
+
parentTypename: G__namespace.getNamedType(parentType).name,
|
|
1525
|
+
path
|
|
1526
|
+
});
|
|
1527
|
+
blueprint.fields.push({
|
|
1528
|
+
id: getBlueprintId(fieldPath),
|
|
1529
|
+
documentBlueprintId: blueprint.id,
|
|
1530
|
+
path: fieldPath
|
|
1531
|
+
});
|
|
1532
|
+
if (isScalarType(field.type)) {
|
|
1438
1533
|
return fieldNode;
|
|
1439
1534
|
}
|
|
1440
1535
|
return __spreadProps(__spreadValues({}, fieldNode), {
|
|
@@ -1443,121 +1538,20 @@ var __objRest = (source, exclude) => {
|
|
|
1443
1538
|
selections: [
|
|
1444
1539
|
...fieldNode.selectionSet.selections.map((selectionNode) => {
|
|
1445
1540
|
switch (selectionNode.kind) {
|
|
1446
|
-
case "Field":
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
const subField = getObjectField(namedType, selectionNode);
|
|
1452
|
-
if (!subField) {
|
|
1453
|
-
return fieldNode;
|
|
1454
|
-
}
|
|
1455
|
-
if (G__namespace.isScalarType(G__namespace.getNamedType(subField.type))) {
|
|
1456
|
-
const newPath2 = [
|
|
1457
|
-
...path,
|
|
1458
|
-
getNameAndAlias(selectionNode, isListType(subField.type), false)
|
|
1459
|
-
];
|
|
1460
|
-
const fieldBlueprint3 = {
|
|
1461
|
-
id: getBlueprintId(newPath2),
|
|
1462
|
-
documentBlueprintId: getRelativeBlueprint(newPath2),
|
|
1463
|
-
path: newPath2
|
|
1464
|
-
};
|
|
1465
|
-
const blueprint3 = blueprints.find((blueprint4) => blueprint4.id === getRelativeBlueprint(path));
|
|
1466
|
-
blueprint3.fields.push(fieldBlueprint3);
|
|
1467
|
-
return selectionNode;
|
|
1468
|
-
}
|
|
1469
|
-
const subFieldType = subField.type;
|
|
1470
|
-
const namedSubFieldType = G__namespace.getNamedType(subFieldType);
|
|
1471
|
-
const newPath = [
|
|
1472
|
-
...path,
|
|
1473
|
-
getNameAndAlias(selectionNode, isListType(subFieldType), isNodeField(namedSubFieldType))
|
|
1474
|
-
];
|
|
1475
|
-
const fieldBlueprint2 = {
|
|
1476
|
-
id: getBlueprintId(newPath),
|
|
1477
|
-
documentBlueprintId: getRelativeBlueprint(newPath),
|
|
1478
|
-
path: newPath
|
|
1479
|
-
};
|
|
1480
|
-
const blueprint2 = blueprints.find((blueprint3) => blueprint3.id === getRelativeBlueprint(path));
|
|
1481
|
-
blueprint2.fields.push(fieldBlueprint2);
|
|
1482
|
-
return __spreadProps(__spreadValues({}, selectionNode), {
|
|
1483
|
-
selectionSet: {
|
|
1484
|
-
kind: "SelectionSet",
|
|
1485
|
-
selections: selectionNode.selectionSet.selections.map((subSelectionNode) => {
|
|
1486
|
-
switch (subSelectionNode.kind) {
|
|
1487
|
-
case "Field":
|
|
1488
|
-
if (subSelectionNode.name.value === "__typename") {
|
|
1489
|
-
return subSelectionNode;
|
|
1490
|
-
}
|
|
1491
|
-
ensureObjectType(namedSubFieldType);
|
|
1492
|
-
const subField1 = getObjectField(namedSubFieldType, subSelectionNode);
|
|
1493
|
-
const subType1 = subField1.type;
|
|
1494
|
-
const namedSubType2 = G__namespace.getNamedType(subType1);
|
|
1495
|
-
return formifyField({
|
|
1496
|
-
fieldNode: subSelectionNode,
|
|
1497
|
-
parentType: subFieldType,
|
|
1498
|
-
path: [
|
|
1499
|
-
...path,
|
|
1500
|
-
getNameAndAlias(subSelectionNode, isListType(subType1), isNodeField(namedSubType2))
|
|
1501
|
-
]
|
|
1502
|
-
});
|
|
1503
|
-
case "InlineFragment":
|
|
1504
|
-
const subNamedType = G__namespace.getNamedType(subField.type);
|
|
1505
|
-
ensureNodeField(subNamedType);
|
|
1506
|
-
ensureUnionType(subNamedType);
|
|
1507
|
-
const subType2 = getSelectedUnionType(subNamedType, subSelectionNode);
|
|
1508
|
-
const newPath2 = [
|
|
1509
|
-
...path,
|
|
1510
|
-
getNameAndAlias(selectionNode, isListType(subField.type), true)
|
|
1511
|
-
];
|
|
1512
|
-
return formifyNode({
|
|
1513
|
-
fieldOrInlineFragmentNode: subSelectionNode,
|
|
1514
|
-
type: subType2,
|
|
1515
|
-
path: newPath2,
|
|
1516
|
-
showInSidebar: false
|
|
1517
|
-
});
|
|
1518
|
-
default:
|
|
1519
|
-
throw new FormifyError("UNEXPECTED", `selection ${subSelectionNode.kind}`);
|
|
1520
|
-
}
|
|
1521
|
-
})
|
|
1522
|
-
}
|
|
1541
|
+
case "Field": {
|
|
1542
|
+
return formifyFieldNode({
|
|
1543
|
+
fieldNode: selectionNode,
|
|
1544
|
+
parentType: field.type,
|
|
1545
|
+
path: fieldPath
|
|
1523
1546
|
});
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
type: parentType2,
|
|
1531
|
-
path,
|
|
1532
|
-
showInSidebar: false
|
|
1533
|
-
});
|
|
1534
|
-
}
|
|
1535
|
-
const subType = getSelectedUnionType(namedType, selectionNode);
|
|
1536
|
-
const namedSubType = G__namespace.getNamedType(subType);
|
|
1537
|
-
return __spreadProps(__spreadValues({}, selectionNode), {
|
|
1538
|
-
selectionSet: {
|
|
1539
|
-
kind: "SelectionSet",
|
|
1540
|
-
selections: selectionNode.selectionSet.selections.map((subSelectionNode) => {
|
|
1541
|
-
switch (subSelectionNode.kind) {
|
|
1542
|
-
case "Field":
|
|
1543
|
-
ensureObjectType(namedSubType);
|
|
1544
|
-
const subField2 = getObjectField(namedSubType, subSelectionNode);
|
|
1545
|
-
const subType2 = subField2.type;
|
|
1546
|
-
const namedSubType2 = G__namespace.getNamedType(subType2);
|
|
1547
|
-
return formifyField({
|
|
1548
|
-
fieldNode: subSelectionNode,
|
|
1549
|
-
parentType: subType,
|
|
1550
|
-
path: [
|
|
1551
|
-
...path,
|
|
1552
|
-
getNameAndAlias(subSelectionNode, isListType(subType2), isNodeField(namedSubType2))
|
|
1553
|
-
]
|
|
1554
|
-
});
|
|
1555
|
-
default:
|
|
1556
|
-
throw new FormifyError("UNEXPECTED", `selection ${subSelectionNode.kind}`);
|
|
1557
|
-
}
|
|
1558
|
-
})
|
|
1559
|
-
}
|
|
1547
|
+
}
|
|
1548
|
+
case "InlineFragment": {
|
|
1549
|
+
return formifyInlineFragmentNode({
|
|
1550
|
+
inlineFragmentNode: selectionNode,
|
|
1551
|
+
parentType: field.type,
|
|
1552
|
+
path: fieldPath
|
|
1560
1553
|
});
|
|
1554
|
+
}
|
|
1561
1555
|
default:
|
|
1562
1556
|
throw new FormifyError("UNEXPECTED", `selection ${selectionNode.kind}`);
|
|
1563
1557
|
}
|
|
@@ -1566,43 +1560,77 @@ var __objRest = (source, exclude) => {
|
|
|
1566
1560
|
}
|
|
1567
1561
|
});
|
|
1568
1562
|
};
|
|
1563
|
+
const formifyInlineFragmentNode = ({
|
|
1564
|
+
inlineFragmentNode,
|
|
1565
|
+
parentType,
|
|
1566
|
+
path
|
|
1567
|
+
}) => {
|
|
1568
|
+
const type = getSelectedUnionType(parentType, inlineFragmentNode);
|
|
1569
|
+
if (!type) {
|
|
1570
|
+
return inlineFragmentNode;
|
|
1571
|
+
}
|
|
1572
|
+
if (isFormifiableDocument(type)) {
|
|
1573
|
+
return formifyInlineFragmentDocument({
|
|
1574
|
+
inlineFragmentNode,
|
|
1575
|
+
type,
|
|
1576
|
+
path,
|
|
1577
|
+
showInSidebar: false
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
return __spreadProps(__spreadValues({}, inlineFragmentNode), {
|
|
1581
|
+
selectionSet: {
|
|
1582
|
+
kind: "SelectionSet",
|
|
1583
|
+
selections: inlineFragmentNode.selectionSet.selections.map((selectionNode) => {
|
|
1584
|
+
switch (selectionNode.kind) {
|
|
1585
|
+
case "Field":
|
|
1586
|
+
return formifyFieldNode({
|
|
1587
|
+
fieldNode: selectionNode,
|
|
1588
|
+
parentType: type,
|
|
1589
|
+
path
|
|
1590
|
+
});
|
|
1591
|
+
default:
|
|
1592
|
+
throw new FormifyError("UNEXPECTED", `selection ${selectionNode.kind}`);
|
|
1593
|
+
}
|
|
1594
|
+
})
|
|
1595
|
+
}
|
|
1596
|
+
});
|
|
1597
|
+
};
|
|
1569
1598
|
const formifiedQuery = {
|
|
1570
1599
|
kind: "Document",
|
|
1571
1600
|
definitions: optimizedQuery.definitions.map((definition) => {
|
|
1572
1601
|
typeInfo.enter(definition);
|
|
1573
1602
|
ensureOperationDefinition(definition);
|
|
1574
|
-
const
|
|
1575
|
-
const namedType = G__namespace.getNamedType(type);
|
|
1576
|
-
ensureObjectType(namedType);
|
|
1603
|
+
const parentType = typeInfo.getType();
|
|
1577
1604
|
return __spreadProps(__spreadValues({}, definition), {
|
|
1578
1605
|
selectionSet: {
|
|
1579
1606
|
kind: "SelectionSet",
|
|
1580
1607
|
selections: definition.selectionSet.selections.map((selectionNode) => {
|
|
1581
1608
|
switch (selectionNode.kind) {
|
|
1582
1609
|
case "Field":
|
|
1583
|
-
const
|
|
1584
|
-
const
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
if (
|
|
1589
|
-
return
|
|
1590
|
-
|
|
1610
|
+
const field = getObjectField(parentType, selectionNode);
|
|
1611
|
+
const path = buildPath({
|
|
1612
|
+
fieldNode: selectionNode,
|
|
1613
|
+
type: field.type
|
|
1614
|
+
});
|
|
1615
|
+
if (isFormifiableDocument(field.type)) {
|
|
1616
|
+
return formifyFieldNodeDocument({
|
|
1617
|
+
fieldNode: selectionNode,
|
|
1591
1618
|
type: field.type,
|
|
1592
|
-
path
|
|
1619
|
+
path,
|
|
1593
1620
|
showInSidebar: true
|
|
1594
1621
|
});
|
|
1595
|
-
} else if (isConnectionField(
|
|
1622
|
+
} else if (isConnectionField(field.type)) {
|
|
1596
1623
|
return formifyConnection({
|
|
1597
|
-
|
|
1624
|
+
parentType: field.type,
|
|
1598
1625
|
selectionNode,
|
|
1599
|
-
path
|
|
1626
|
+
path
|
|
1600
1627
|
});
|
|
1601
1628
|
}
|
|
1602
1629
|
if (selectionNode.name.value === COLLECTION_FIELD_NAME || selectionNode.name.value === COLLECTIONS_FIELD_NAME) {
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1605
|
-
|
|
1630
|
+
const path2 = buildPath({
|
|
1631
|
+
fieldNode: selectionNode,
|
|
1632
|
+
type: field.type
|
|
1633
|
+
});
|
|
1606
1634
|
return __spreadProps(__spreadValues({}, selectionNode), {
|
|
1607
1635
|
selectionSet: {
|
|
1608
1636
|
kind: "SelectionSet",
|
|
@@ -1610,16 +1638,15 @@ var __objRest = (source, exclude) => {
|
|
|
1610
1638
|
switch (subSelectionNode.kind) {
|
|
1611
1639
|
case "Field":
|
|
1612
1640
|
if (subSelectionNode.name.value === COLLECTIONS_DOCUMENTS_NAME) {
|
|
1613
|
-
|
|
1614
|
-
const n = namedFieldType.getFields()[COLLECTIONS_DOCUMENTS_NAME];
|
|
1615
|
-
const docType = G__namespace.getNamedType(n.type);
|
|
1641
|
+
const subField = getObjectField(field.type, subSelectionNode);
|
|
1616
1642
|
return formifyConnection({
|
|
1617
|
-
|
|
1643
|
+
parentType: subField.type,
|
|
1618
1644
|
selectionNode: subSelectionNode,
|
|
1619
|
-
path:
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1645
|
+
path: buildPath({
|
|
1646
|
+
fieldNode: subSelectionNode,
|
|
1647
|
+
type: subField.type,
|
|
1648
|
+
path: path2
|
|
1649
|
+
})
|
|
1623
1650
|
});
|
|
1624
1651
|
}
|
|
1625
1652
|
return subSelectionNode;
|
|
@@ -1659,9 +1686,27 @@ var __objRest = (source, exclude) => {
|
|
|
1659
1686
|
this.name = "FormifyError";
|
|
1660
1687
|
}
|
|
1661
1688
|
}
|
|
1689
|
+
const defaultState = {
|
|
1690
|
+
status: "idle",
|
|
1691
|
+
schema: void 0,
|
|
1692
|
+
query: null,
|
|
1693
|
+
queryString: null,
|
|
1694
|
+
data: {},
|
|
1695
|
+
changeSets: [],
|
|
1696
|
+
count: 0,
|
|
1697
|
+
blueprints: [],
|
|
1698
|
+
formNodes: [],
|
|
1699
|
+
documentForms: []
|
|
1700
|
+
};
|
|
1662
1701
|
function reducer(state, action) {
|
|
1663
1702
|
var _a, _b, _c, _d;
|
|
1664
1703
|
switch (action.type) {
|
|
1704
|
+
case "start":
|
|
1705
|
+
return __spreadProps(__spreadValues(__spreadValues({}, state), defaultState), {
|
|
1706
|
+
query: action.value.query ? G__namespace.parse(action.value.query) : null,
|
|
1707
|
+
queryString: action.value.query,
|
|
1708
|
+
status: "initialized"
|
|
1709
|
+
});
|
|
1665
1710
|
case "addDocumentBlueprints":
|
|
1666
1711
|
return __spreadProps(__spreadValues({}, state), {
|
|
1667
1712
|
status: "formified",
|
|
@@ -1716,16 +1761,21 @@ var __objRest = (source, exclude) => {
|
|
|
1716
1761
|
}
|
|
1717
1762
|
if (event.mutationType.type === "change") {
|
|
1718
1763
|
if (!action.value.form) {
|
|
1719
|
-
|
|
1764
|
+
getBlueprintFieldsForEvent(blueprint, event).forEach((fieldBlueprint) => {
|
|
1765
|
+
const { pathToChange } = getFormNodesForField(fieldBlueprint, formNode, event, state);
|
|
1720
1766
|
changeSets.push(__spreadValues({
|
|
1721
1767
|
path: pathToChange
|
|
1722
|
-
}, buildChangeSet(event,
|
|
1768
|
+
}, buildChangeSet(event, formNode)));
|
|
1723
1769
|
});
|
|
1724
1770
|
}
|
|
1725
1771
|
} else if (event.mutationType.type === "referenceChange") {
|
|
1726
1772
|
getBlueprintFieldsForEvent(blueprint, event).forEach((fieldBlueprint) => {
|
|
1727
|
-
const {
|
|
1728
|
-
|
|
1773
|
+
const {
|
|
1774
|
+
pathToChange,
|
|
1775
|
+
formNodes: subFormNodes,
|
|
1776
|
+
eventLocation
|
|
1777
|
+
} = getFormNodesForField(fieldBlueprint, formNode, event, state);
|
|
1778
|
+
if (action.value.form && state.blueprints.find((blueprint2) => blueprint2.id === fieldBlueprint.id)) {
|
|
1729
1779
|
const newFormNode = {
|
|
1730
1780
|
documentBlueprintId: fieldBlueprint.id,
|
|
1731
1781
|
documentFormId: action.value.form.id,
|
|
@@ -1736,8 +1786,15 @@ var __objRest = (source, exclude) => {
|
|
|
1736
1786
|
path: pathToChange
|
|
1737
1787
|
}, buildChangeSet(event, newFormNode)));
|
|
1738
1788
|
}
|
|
1739
|
-
|
|
1789
|
+
subFormNodes.forEach((subFormNode) => {
|
|
1740
1790
|
if (matchLocation(eventLocation, subFormNode)) {
|
|
1791
|
+
if (!action.value.form) {
|
|
1792
|
+
changeSets.push(__spreadProps(__spreadValues({
|
|
1793
|
+
path: pathToChange
|
|
1794
|
+
}, buildChangeSet(event, subFormNode)), {
|
|
1795
|
+
value: null
|
|
1796
|
+
}));
|
|
1797
|
+
}
|
|
1741
1798
|
formNodesToReplace.push(subFormNode);
|
|
1742
1799
|
}
|
|
1743
1800
|
});
|
|
@@ -1890,7 +1947,7 @@ var __objRest = (source, exclude) => {
|
|
|
1890
1947
|
}) => {
|
|
1891
1948
|
const formIds = React__default["default"].useRef([]);
|
|
1892
1949
|
const [state, dispatch] = React__default["default"].useReducer(reducer, {
|
|
1893
|
-
status: "
|
|
1950
|
+
status: "idle",
|
|
1894
1951
|
schema: void 0,
|
|
1895
1952
|
query: query ? G__namespace.parse(query) : null,
|
|
1896
1953
|
queryString: query,
|
|
@@ -1901,6 +1958,17 @@ var __objRest = (source, exclude) => {
|
|
|
1901
1958
|
formNodes: [],
|
|
1902
1959
|
documentForms: []
|
|
1903
1960
|
});
|
|
1961
|
+
React__default["default"].useEffect(() => {
|
|
1962
|
+
if (query) {
|
|
1963
|
+
dispatch({ type: "start", value: { query } });
|
|
1964
|
+
formIds.current.forEach((formId) => {
|
|
1965
|
+
const form = cms.forms.find(formId);
|
|
1966
|
+
if (form) {
|
|
1967
|
+
cms.plugins.remove(form);
|
|
1968
|
+
}
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
}, [query, JSON.stringify(variables)]);
|
|
1904
1972
|
React__default["default"].useEffect(() => {
|
|
1905
1973
|
if (state.status === "initialized") {
|
|
1906
1974
|
cms.api.tina.request(query, { variables }).then((res) => {
|
|
@@ -1932,7 +2000,7 @@ var __objRest = (source, exclude) => {
|
|
|
1932
2000
|
variables
|
|
1933
2001
|
});
|
|
1934
2002
|
state.blueprints.map((blueprint) => {
|
|
1935
|
-
const responseAtBlueprint =
|
|
2003
|
+
const responseAtBlueprint = getValueForBlueprint(result, getBlueprintAliasPath(blueprint));
|
|
1936
2004
|
const location = [];
|
|
1937
2005
|
const findFormNodes = (res, location2) => {
|
|
1938
2006
|
if (Array.isArray(res)) {
|
|
@@ -1981,6 +2049,9 @@ var __objRest = (source, exclude) => {
|
|
|
1981
2049
|
React__default["default"].useEffect(() => {
|
|
1982
2050
|
if (state.status === "ready") {
|
|
1983
2051
|
cms.events.subscribe(`forms:reset`, (event) => {
|
|
2052
|
+
if (eventList) {
|
|
2053
|
+
eventList.push(printEvent(event));
|
|
2054
|
+
}
|
|
1984
2055
|
dispatch({ type: "formOnReset", value: { event } });
|
|
1985
2056
|
});
|
|
1986
2057
|
cms.events.subscribe(`forms:fields:onChange`, async (event) => {
|
|
@@ -2002,6 +2073,9 @@ var __objRest = (source, exclude) => {
|
|
|
2002
2073
|
values
|
|
2003
2074
|
_internalSys: sys {
|
|
2004
2075
|
path
|
|
2076
|
+
collection {
|
|
2077
|
+
name
|
|
2078
|
+
}
|
|
2005
2079
|
}
|
|
2006
2080
|
}
|
|
2007
2081
|
}
|
|
@@ -2032,7 +2106,8 @@ var __objRest = (source, exclude) => {
|
|
|
2032
2106
|
const form = cms.forms.find(changeSet.formId);
|
|
2033
2107
|
resolveSubFields({
|
|
2034
2108
|
formNode: changeSet.formNode,
|
|
2035
|
-
form
|
|
2109
|
+
form,
|
|
2110
|
+
loc: []
|
|
2036
2111
|
}).then((res) => {
|
|
2037
2112
|
dispatch({
|
|
2038
2113
|
type: "setIn",
|
|
@@ -2141,22 +2216,15 @@ var __objRest = (source, exclude) => {
|
|
|
2141
2216
|
const data = {};
|
|
2142
2217
|
await sequential(form.fields, async (field) => {
|
|
2143
2218
|
const value = form.values[field.name];
|
|
2144
|
-
const fieldName = field.list ? `${field.name}.[]` : field.name;
|
|
2145
2219
|
const blueprint = getFormNodeBlueprint(formNode, state);
|
|
2146
|
-
const
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
}
|
|
2151
|
-
const matchName = [
|
|
2152
|
-
blueprintName,
|
|
2153
|
-
DATA_NODE_NAME,
|
|
2154
|
-
...extra,
|
|
2155
|
-
fieldName
|
|
2156
|
-
].join(".");
|
|
2220
|
+
const { matchName, fieldName } = getMatchName({
|
|
2221
|
+
field,
|
|
2222
|
+
prefix,
|
|
2223
|
+
blueprint
|
|
2224
|
+
});
|
|
2157
2225
|
const fieldBlueprints = blueprint.fields.filter((fieldBlueprint) => {
|
|
2158
2226
|
return matchName === getBlueprintNamePath(fieldBlueprint);
|
|
2159
|
-
});
|
|
2227
|
+
}).filter((fbp) => filterFieldBlueprintsByParentTypename(fbp, field.parentTypename));
|
|
2160
2228
|
switch (field.type) {
|
|
2161
2229
|
case "object":
|
|
2162
2230
|
if (field.templates) {
|
|
@@ -2170,18 +2238,17 @@ var __objRest = (source, exclude) => {
|
|
|
2170
2238
|
if (!Array.isArray(value)) {
|
|
2171
2239
|
throw new Error(`Expected value for object list field to be an array`);
|
|
2172
2240
|
}
|
|
2173
|
-
|
|
2174
|
-
await sequential(value, async (item, index) => {
|
|
2241
|
+
data[keyName] = await sequential(value, async (item, index) => {
|
|
2175
2242
|
const template = field.templates[item._template];
|
|
2176
|
-
|
|
2243
|
+
return __spreadProps(__spreadValues({}, await resolveSubFields({
|
|
2177
2244
|
formNode,
|
|
2178
2245
|
form: { fields: template.fields, values: item },
|
|
2179
|
-
prefix: [prefix, fieldName].join("."),
|
|
2246
|
+
prefix: prefix ? [prefix, fieldName].join(".") : fieldName,
|
|
2180
2247
|
loc: [...loc, index]
|
|
2248
|
+
})), {
|
|
2249
|
+
__typename: field.typeMap[item._template]
|
|
2181
2250
|
});
|
|
2182
|
-
d.push(d2);
|
|
2183
2251
|
});
|
|
2184
|
-
data[keyName] = d;
|
|
2185
2252
|
});
|
|
2186
2253
|
} else {
|
|
2187
2254
|
throw new Error("blocks without list true is not yet supported");
|
|
@@ -2197,18 +2264,14 @@ var __objRest = (source, exclude) => {
|
|
|
2197
2264
|
if (!Array.isArray(value)) {
|
|
2198
2265
|
throw new Error(`Expected value for object list field to be an array`);
|
|
2199
2266
|
}
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
const d2 = await resolveSubFields({
|
|
2267
|
+
data[keyName] = await sequential(value, async (item, index) => {
|
|
2268
|
+
return resolveSubFields({
|
|
2203
2269
|
formNode,
|
|
2204
2270
|
form: { fields: field.fields, values: item },
|
|
2205
2271
|
prefix: [prefix, fieldName].join("."),
|
|
2206
2272
|
loc: [...loc, index]
|
|
2207
2273
|
});
|
|
2208
|
-
d.push(d2);
|
|
2209
|
-
return true;
|
|
2210
2274
|
});
|
|
2211
|
-
data[keyName] = d;
|
|
2212
2275
|
return true;
|
|
2213
2276
|
});
|
|
2214
2277
|
} else {
|
|
@@ -2218,13 +2281,12 @@ var __objRest = (source, exclude) => {
|
|
|
2218
2281
|
data[keyName] = null;
|
|
2219
2282
|
return true;
|
|
2220
2283
|
}
|
|
2221
|
-
|
|
2284
|
+
data[keyName] = await resolveSubFields({
|
|
2222
2285
|
formNode,
|
|
2223
2286
|
form: { fields: field.fields, values: value },
|
|
2224
2287
|
prefix: [prefix, fieldName].join("."),
|
|
2225
2288
|
loc
|
|
2226
2289
|
});
|
|
2227
|
-
data[keyName] = d;
|
|
2228
2290
|
return true;
|
|
2229
2291
|
});
|
|
2230
2292
|
}
|
|
@@ -2245,6 +2307,9 @@ var __objRest = (source, exclude) => {
|
|
|
2245
2307
|
values
|
|
2246
2308
|
_internalSys: sys {
|
|
2247
2309
|
path
|
|
2310
|
+
collection {
|
|
2311
|
+
name
|
|
2312
|
+
}
|
|
2248
2313
|
}
|
|
2249
2314
|
}
|
|
2250
2315
|
}
|
|
@@ -2279,12 +2344,13 @@ var __objRest = (source, exclude) => {
|
|
|
2279
2344
|
}
|
|
2280
2345
|
}
|
|
2281
2346
|
`, { variables: { id: value } });
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2347
|
+
data[keyName] = __spreadProps(__spreadValues({}, res.node), {
|
|
2348
|
+
data: await resolveSubFields({
|
|
2349
|
+
formNode: subDocumentFormNode,
|
|
2350
|
+
form: form2,
|
|
2351
|
+
loc: location
|
|
2352
|
+
})
|
|
2286
2353
|
});
|
|
2287
|
-
data[keyName] = __spreadProps(__spreadValues({}, res.node), { data: d });
|
|
2288
2354
|
});
|
|
2289
2355
|
break;
|
|
2290
2356
|
default:
|
|
@@ -2352,13 +2418,13 @@ mutation addPendingDocumentMutation(
|
|
|
2352
2418
|
return result;
|
|
2353
2419
|
};
|
|
2354
2420
|
this.getSchema = async () => {
|
|
2355
|
-
if (!this.
|
|
2421
|
+
if (!this.gqlSchema) {
|
|
2356
2422
|
const data = await this.request(G.getIntrospectionQuery(), {
|
|
2357
2423
|
variables: {}
|
|
2358
2424
|
});
|
|
2359
|
-
this.
|
|
2425
|
+
this.gqlSchema = G.buildClientSchema(data);
|
|
2360
2426
|
}
|
|
2361
|
-
return this.
|
|
2427
|
+
return this.gqlSchema;
|
|
2362
2428
|
};
|
|
2363
2429
|
this.getOptimizedQuery = async (documentNode) => {
|
|
2364
2430
|
const data = await this.request(`query GetOptimizedQuery($queryString: String!) {
|
|
@@ -2368,6 +2434,13 @@ mutation addPendingDocumentMutation(
|
|
|
2368
2434
|
});
|
|
2369
2435
|
return G.parse(data.getOptimizedQuery);
|
|
2370
2436
|
};
|
|
2437
|
+
if (options.schema) {
|
|
2438
|
+
const enrichedSchema = new schemaTools.TinaSchema(__spreadValues({
|
|
2439
|
+
version: { fullVersion: "", major: "", minor: "", patch: "" },
|
|
2440
|
+
meta: { flags: [] }
|
|
2441
|
+
}, schemaTools.addNamespaceToSchema(options.schema, [])));
|
|
2442
|
+
this.schema = enrichedSchema;
|
|
2443
|
+
}
|
|
2371
2444
|
this.options = options;
|
|
2372
2445
|
this.setBranch(options.branch);
|
|
2373
2446
|
this.events.subscribe("branch:change", ({ branchName }) => {
|
|
@@ -2577,11 +2650,11 @@ mutation addPendingDocumentMutation(
|
|
|
2577
2650
|
const DEFAULT_LOCAL_TINA_GQL_SERVER_URL = "http://localhost:4001/graphql";
|
|
2578
2651
|
class LocalClient extends Client {
|
|
2579
2652
|
constructor(props) {
|
|
2580
|
-
const clientProps = {
|
|
2653
|
+
const clientProps = __spreadProps(__spreadValues({}, props), {
|
|
2581
2654
|
clientId: "",
|
|
2582
2655
|
branch: "",
|
|
2583
2656
|
customContentApiUrl: props && props.customContentApiUrl ? props.customContentApiUrl : DEFAULT_LOCAL_TINA_GQL_SERVER_URL
|
|
2584
|
-
};
|
|
2657
|
+
});
|
|
2585
2658
|
super(clientProps);
|
|
2586
2659
|
}
|
|
2587
2660
|
async isAuthorized() {
|
|
@@ -2652,6 +2725,17 @@ mutation addPendingDocumentMutation(
|
|
|
2652
2725
|
}`, { variables: {} });
|
|
2653
2726
|
return response;
|
|
2654
2727
|
}
|
|
2728
|
+
async deleteDocument({
|
|
2729
|
+
collection,
|
|
2730
|
+
relativePath
|
|
2731
|
+
}) {
|
|
2732
|
+
await this.api.request(`#graphql
|
|
2733
|
+
mutation DeleteDocument($collection: String!, $relativePath: String! ){
|
|
2734
|
+
deleteDocument(collection: $collection, relativePath: $relativePath){
|
|
2735
|
+
__typename
|
|
2736
|
+
}
|
|
2737
|
+
}`, { variables: { collection, relativePath } });
|
|
2738
|
+
}
|
|
2655
2739
|
async fetchCollection(collectionName, includeDocuments) {
|
|
2656
2740
|
const response = await this.api.request(`#graphql
|
|
2657
2741
|
query($collection: String!, $includeDocuments: Boolean!){
|
|
@@ -2876,6 +2960,7 @@ mutation addPendingDocumentMutation(
|
|
|
2876
2960
|
}))));
|
|
2877
2961
|
};
|
|
2878
2962
|
const TinaCloudAuthWall = TinaCloudProvider;
|
|
2963
|
+
var styles = '*, ::before, ::after {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(0 132 255 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n}\n.tina-tailwind .static {\n position: static;\n}\n.tina-tailwind .fixed {\n position: fixed;\n}\n.tina-tailwind .absolute {\n position: absolute;\n}\n.tina-tailwind .relative {\n position: relative;\n}\n.tina-tailwind .left-0 {\n left: 0px;\n}\n.tina-tailwind .right-0 {\n right: 0px;\n}\n.tina-tailwind .mx-auto {\n margin-left: auto;\n margin-right: auto;\n}\n.tina-tailwind .mr-2 {\n margin-right: 8px;\n}\n.tina-tailwind .mb-2 {\n margin-bottom: 8px;\n}\n.tina-tailwind .mb-1 {\n margin-bottom: 4px;\n}\n.tina-tailwind .-mt-0\\.5 {\n margin-top: -2px;\n}\n.tina-tailwind .-mt-0 {\n margin-top: -0px;\n}\n.tina-tailwind .ml-1 {\n margin-left: 4px;\n}\n.tina-tailwind .mt-2 {\n margin-top: 8px;\n}\n.tina-tailwind .mr-1\\.5 {\n margin-right: 6px;\n}\n.tina-tailwind .mr-1 {\n margin-right: 4px;\n}\n.tina-tailwind .block {\n display: block;\n}\n.tina-tailwind .inline-block {\n display: inline-block;\n}\n.tina-tailwind .inline {\n display: inline;\n}\n.tina-tailwind .flex {\n display: flex;\n}\n.tina-tailwind .inline-flex {\n display: inline-flex;\n}\n.tina-tailwind .table {\n display: table;\n}\n.tina-tailwind .h-screen {\n height: 100vh;\n}\n.tina-tailwind .h-auto {\n height: auto;\n}\n.tina-tailwind .h-full {\n height: 100%;\n}\n.tina-tailwind .h-6 {\n height: 24px;\n}\n.tina-tailwind .h-10 {\n height: 40px;\n}\n.tina-tailwind .h-5 {\n height: 20px;\n}\n.tina-tailwind .h-12 {\n height: 48px;\n}\n.tina-tailwind .w-full {\n width: 100%;\n}\n.tina-tailwind .w-10 {\n width: 40px;\n}\n.tina-tailwind .w-auto {\n width: auto;\n}\n.tina-tailwind .w-5 {\n width: 20px;\n}\n.tina-tailwind .w-56 {\n width: 224px;\n}\n.tina-tailwind .w-0 {\n width: 0px;\n}\n.tina-tailwind .w-6 {\n width: 24px;\n}\n.tina-tailwind .max-w-lg {\n max-width: 32rem;\n}\n.tina-tailwind .max-w-screen-xl {\n max-width: 1280px;\n}\n.tina-tailwind .max-w-form {\n max-width: 900px;\n}\n.tina-tailwind .max-w-full {\n max-width: 100%;\n}\n.tina-tailwind .flex-1 {\n flex: 1 1 0%;\n}\n.tina-tailwind .flex-shrink-0 {\n flex-shrink: 0;\n}\n.tina-tailwind .flex-grow-0 {\n flex-grow: 0;\n}\n.tina-tailwind .table-auto {\n table-layout: auto;\n}\n.tina-tailwind .origin-top-right {\n transform-origin: top right;\n}\n.tina-tailwind .scale-95 {\n --tw-scale-x: .95;\n --tw-scale-y: .95;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.tina-tailwind .scale-100 {\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.tina-tailwind .transform {\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.tina-tailwind .cursor-pointer {\n cursor: pointer;\n}\n.tina-tailwind .flex-col {\n flex-direction: column;\n}\n.tina-tailwind .items-end {\n align-items: flex-end;\n}\n.tina-tailwind .items-center {\n align-items: center;\n}\n.tina-tailwind .items-stretch {\n align-items: stretch;\n}\n.tina-tailwind .justify-end {\n justify-content: flex-end;\n}\n.tina-tailwind .justify-center {\n justify-content: center;\n}\n.tina-tailwind .justify-between {\n justify-content: space-between;\n}\n.tina-tailwind .gap-0\\.5 {\n gap: 2px;\n}\n.tina-tailwind .gap-0 {\n gap: 0px;\n}\n.tina-tailwind .gap-4 {\n gap: 16px;\n}\n.tina-tailwind .gap-3 {\n gap: 12px;\n}\n.tina-tailwind .divide-y > :not([hidden]) ~ :not([hidden]) {\n --tw-divide-y-reverse: 0;\n border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));\n border-bottom-width: calc(1px * var(--tw-divide-y-reverse));\n}\n.tina-tailwind .divide-gray-150 > :not([hidden]) ~ :not([hidden]) {\n --tw-divide-opacity: 1;\n border-color: rgb(230 227 239 / var(--tw-divide-opacity));\n}\n.tina-tailwind .overflow-hidden {\n overflow: hidden;\n}\n.tina-tailwind .overflow-y-auto {\n overflow-y: auto;\n}\n.tina-tailwind .whitespace-nowrap {\n white-space: nowrap;\n}\n.tina-tailwind .rounded-lg {\n border-radius: 8px;\n}\n.tina-tailwind .rounded-full {\n border-radius: 9999px;\n}\n.tina-tailwind .rounded-md {\n border-radius: 6px;\n}\n.tina-tailwind .border {\n border-width: 1px;\n}\n.tina-tailwind .border-b {\n border-bottom-width: 1px;\n}\n.tina-tailwind .border-gray-150 {\n --tw-border-opacity: 1;\n border-color: rgb(230 227 239 / var(--tw-border-opacity));\n}\n.tina-tailwind .border-gray-200 {\n --tw-border-opacity: 1;\n border-color: rgb(225 221 236 / var(--tw-border-opacity));\n}\n.tina-tailwind .bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity));\n}\n.tina-tailwind .bg-gray-50 {\n --tw-bg-opacity: 1;\n background-color: rgb(246 246 249 / var(--tw-bg-opacity));\n}\n.tina-tailwind .bg-blue-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(0 132 255 / var(--tw-bg-opacity));\n}\n.tina-tailwind .bg-gradient-to-b {\n background-image: linear-gradient(to bottom, var(--tw-gradient-stops));\n}\n.tina-tailwind .from-blue-900 {\n --tw-gradient-from: #1D2C6C;\n --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgb(29 44 108 / 0));\n}\n.tina-tailwind .to-gray-900 {\n --tw-gradient-to: #252336;\n}\n.tina-tailwind .px-4 {\n padding-left: 16px;\n padding-right: 16px;\n}\n.tina-tailwind .py-6 {\n padding-top: 24px;\n padding-bottom: 24px;\n}\n.tina-tailwind .px-5 {\n padding-left: 20px;\n padding-right: 20px;\n}\n.tina-tailwind .py-4 {\n padding-top: 16px;\n padding-bottom: 16px;\n}\n.tina-tailwind .px-12 {\n padding-left: 48px;\n padding-right: 48px;\n}\n.tina-tailwind .py-10 {\n padding-top: 40px;\n padding-bottom: 40px;\n}\n.tina-tailwind .px-20 {\n padding-left: 80px;\n padding-right: 80px;\n}\n.tina-tailwind .px-6 {\n padding-left: 24px;\n padding-right: 24px;\n}\n.tina-tailwind .py-1 {\n padding-top: 4px;\n padding-bottom: 4px;\n}\n.tina-tailwind .py-2 {\n padding-top: 8px;\n padding-bottom: 8px;\n}\n.tina-tailwind .pt-4 {\n padding-top: 16px;\n}\n.tina-tailwind .pb-4 {\n padding-bottom: 16px;\n}\n.tina-tailwind .pt-18 {\n padding-top: 72px;\n}\n.tina-tailwind .text-left {\n text-align: left;\n}\n.tina-tailwind .text-center {\n text-align: center;\n}\n.tina-tailwind .font-sans {\n 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";\n}\n.tina-tailwind .text-2xl {\n font-size: 24px;\n line-height: 1.33;\n}\n.tina-tailwind .text-base {\n font-size: 16px;\n line-height: 1.5;\n}\n.tina-tailwind .text-sm {\n font-size: 14px;\n line-height: 1.43;\n}\n.tina-tailwind .text-xl {\n font-size: 20px;\n line-height: 1.4;\n}\n.tina-tailwind .text-md {\n font-size: 16px;\n line-height: 1.5;\n}\n.tina-tailwind .text-xs {\n font-size: 13px;\n line-height: 1.33;\n}\n.tina-tailwind .font-medium {\n font-weight: 500;\n}\n.tina-tailwind .uppercase {\n text-transform: uppercase;\n}\n.tina-tailwind .italic {\n font-style: italic;\n}\n.tina-tailwind .leading-normal {\n line-height: 1.5;\n}\n.tina-tailwind .leading-tight {\n line-height: 1.25;\n}\n.tina-tailwind .leading-5 {\n line-height: 20px;\n}\n.tina-tailwind .tracking-wide {\n letter-spacing: 0.025em;\n}\n.tina-tailwind .text-gray-600 {\n --tw-text-opacity: 1;\n color: rgb(86 81 101 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-gray-700 {\n --tw-text-opacity: 1;\n color: rgb(67 62 82 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-blue-600 {\n --tw-text-opacity: 1;\n color: rgb(5 116 228 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-gray-500 {\n --tw-text-opacity: 1;\n color: rgb(113 108 127 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-gray-400 {\n --tw-text-opacity: 1;\n color: rgb(145 140 158 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-current {\n color: currentColor;\n}\n.tina-tailwind .text-white {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-gray-800 {\n --tw-text-opacity: 1;\n color: rgb(54 49 69 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-gray-900 {\n --tw-text-opacity: 1;\n color: rgb(37 35 54 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-red-500 {\n --tw-text-opacity: 1;\n color: rgb(239 68 68 / var(--tw-text-opacity));\n}\n.tina-tailwind .underline {\n text-decoration-line: underline;\n}\n.tina-tailwind .opacity-100 {\n opacity: 1;\n}\n.tina-tailwind .opacity-90 {\n opacity: .9;\n}\n.tina-tailwind .opacity-80 {\n opacity: .8;\n}\n.tina-tailwind .opacity-50 {\n opacity: .5;\n}\n.tina-tailwind .opacity-70 {\n opacity: .7;\n}\n.tina-tailwind .opacity-0 {\n opacity: 0;\n}\n.tina-tailwind .shadow-lg {\n --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);\n --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.tina-tailwind .shadow-2xl {\n --tw-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n --tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.tina-tailwind .shadow {\n --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.tina-tailwind .ring-1 {\n --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);\n --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);\n box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);\n}\n.tina-tailwind .ring-black {\n --tw-ring-opacity: 1;\n --tw-ring-color: rgb(0 0 0 / var(--tw-ring-opacity));\n}\n.tina-tailwind .ring-opacity-5 {\n --tw-ring-opacity: .05;\n}\n.tina-tailwind .filter {\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n.tina-tailwind .transition-opacity {\n transition-property: opacity;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.tina-tailwind .transition-colors {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.tina-tailwind .transition-all {\n transition-property: all;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.tina-tailwind .transition {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.tina-tailwind .duration-300 {\n transition-duration: 300ms;\n}\n.tina-tailwind .duration-150 {\n transition-duration: 150ms;\n}\n.tina-tailwind .duration-100 {\n transition-duration: 100ms;\n}\n.tina-tailwind .duration-75 {\n transition-duration: 75ms;\n}\n.tina-tailwind .ease-out {\n transition-timing-function: cubic-bezier(0, 0, 0.2, 1);\n}\n.tina-tailwind .ease-in {\n transition-timing-function: cubic-bezier(0.4, 0, 1, 1);\n}\n.tina-tailwind .icon-parent svg {\n fill: currentColor;\n }\n\n.tina-tailwind {\n 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";\n font-size: 16px;\n line-height: 1.5;\n --tw-text-opacity: 1;\n color: rgb(86 81 101 / var(--tw-text-opacity));\n}\n\n.tina-tailwind .hover\\:bg-blue-600:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(5 116 228 / var(--tw-bg-opacity));\n}\n\n.tina-tailwind .hover\\:text-blue-600:hover {\n --tw-text-opacity: 1;\n color: rgb(5 116 228 / var(--tw-text-opacity));\n}\n\n.tina-tailwind .hover\\:text-blue-400:hover {\n --tw-text-opacity: 1;\n color: rgb(34 150 254 / var(--tw-text-opacity));\n}\n\n.tina-tailwind .hover\\:opacity-100:hover {\n opacity: 1;\n}\n\n.tina-tailwind .focus\\:text-blue-400:focus {\n --tw-text-opacity: 1;\n color: rgb(34 150 254 / var(--tw-text-opacity));\n}\n\n.tina-tailwind .focus\\:underline:focus {\n text-decoration-line: underline;\n}\n\n.tina-tailwind .focus\\:shadow-outline:focus {\n --tw-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);\n --tw-shadow-colored: 0 0 0 3px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n\n.tina-tailwind .focus\\:outline-none:focus {\n outline: 2px solid transparent;\n outline-offset: 2px;\n}\n\n.tina-tailwind .focus\\:ring-2:focus {\n --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);\n --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);\n box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);\n}\n\n.tina-tailwind .focus\\:ring-blue-500:focus {\n --tw-ring-opacity: 1;\n --tw-ring-color: rgb(0 132 255 / var(--tw-ring-opacity));\n}\n';
|
|
2879
2964
|
class ContentCreatorPlugin {
|
|
2880
2965
|
constructor(options) {
|
|
2881
2966
|
this.__type = "content-creator";
|
|
@@ -3038,7 +3123,6 @@ mutation addPendingDocumentMutation(
|
|
|
3038
3123
|
};
|
|
3039
3124
|
}, [plugin]);
|
|
3040
3125
|
};
|
|
3041
|
-
var styles = '*, ::before, ::after {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(0 132 255 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n}\n.tina-tailwind .static {\n position: static;\n}\n.tina-tailwind .fixed {\n position: fixed;\n}\n.tina-tailwind .absolute {\n position: absolute;\n}\n.tina-tailwind .relative {\n position: relative;\n}\n.tina-tailwind .left-0 {\n left: 0px;\n}\n.tina-tailwind .right-0 {\n right: 0px;\n}\n.tina-tailwind .mx-auto {\n margin-left: auto;\n margin-right: auto;\n}\n.tina-tailwind .mr-2 {\n margin-right: 8px;\n}\n.tina-tailwind .mb-2 {\n margin-bottom: 8px;\n}\n.tina-tailwind .mb-1 {\n margin-bottom: 4px;\n}\n.tina-tailwind .-mt-0\\.5 {\n margin-top: -2px;\n}\n.tina-tailwind .-mt-0 {\n margin-top: -0px;\n}\n.tina-tailwind .ml-1 {\n margin-left: 4px;\n}\n.tina-tailwind .mt-2 {\n margin-top: 8px;\n}\n.tina-tailwind .mr-1\\.5 {\n margin-right: 6px;\n}\n.tina-tailwind .mr-1 {\n margin-right: 4px;\n}\n.tina-tailwind .block {\n display: block;\n}\n.tina-tailwind .inline-block {\n display: inline-block;\n}\n.tina-tailwind .inline {\n display: inline;\n}\n.tina-tailwind .flex {\n display: flex;\n}\n.tina-tailwind .inline-flex {\n display: inline-flex;\n}\n.tina-tailwind .table {\n display: table;\n}\n.tina-tailwind .h-screen {\n height: 100vh;\n}\n.tina-tailwind .h-auto {\n height: auto;\n}\n.tina-tailwind .h-full {\n height: 100%;\n}\n.tina-tailwind .h-6 {\n height: 24px;\n}\n.tina-tailwind .h-10 {\n height: 40px;\n}\n.tina-tailwind .h-5 {\n height: 20px;\n}\n.tina-tailwind .h-12 {\n height: 48px;\n}\n.tina-tailwind .w-full {\n width: 100%;\n}\n.tina-tailwind .w-10 {\n width: 40px;\n}\n.tina-tailwind .w-auto {\n width: auto;\n}\n.tina-tailwind .w-5 {\n width: 20px;\n}\n.tina-tailwind .w-56 {\n width: 224px;\n}\n.tina-tailwind .w-6 {\n width: 24px;\n}\n.tina-tailwind .max-w-lg {\n max-width: 32rem;\n}\n.tina-tailwind .max-w-screen-xl {\n max-width: 1280px;\n}\n.tina-tailwind .max-w-form {\n max-width: 900px;\n}\n.tina-tailwind .max-w-full {\n max-width: 100%;\n}\n.tina-tailwind .flex-1 {\n flex: 1 1 0%;\n}\n.tina-tailwind .flex-shrink-0 {\n flex-shrink: 0;\n}\n.tina-tailwind .flex-grow-0 {\n flex-grow: 0;\n}\n.tina-tailwind .table-auto {\n table-layout: auto;\n}\n.tina-tailwind .origin-top-right {\n transform-origin: top right;\n}\n.tina-tailwind .scale-95 {\n --tw-scale-x: .95;\n --tw-scale-y: .95;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.tina-tailwind .scale-100 {\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.tina-tailwind .transform {\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.tina-tailwind .cursor-pointer {\n cursor: pointer;\n}\n.tina-tailwind .flex-col {\n flex-direction: column;\n}\n.tina-tailwind .items-end {\n align-items: flex-end;\n}\n.tina-tailwind .items-center {\n align-items: center;\n}\n.tina-tailwind .items-stretch {\n align-items: stretch;\n}\n.tina-tailwind .justify-end {\n justify-content: flex-end;\n}\n.tina-tailwind .justify-center {\n justify-content: center;\n}\n.tina-tailwind .justify-between {\n justify-content: space-between;\n}\n.tina-tailwind .gap-0\\.5 {\n gap: 2px;\n}\n.tina-tailwind .gap-0 {\n gap: 0px;\n}\n.tina-tailwind .gap-4 {\n gap: 16px;\n}\n.tina-tailwind .gap-3 {\n gap: 12px;\n}\n.tina-tailwind .divide-y > :not([hidden]) ~ :not([hidden]) {\n --tw-divide-y-reverse: 0;\n border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));\n border-bottom-width: calc(1px * var(--tw-divide-y-reverse));\n}\n.tina-tailwind .divide-gray-150 > :not([hidden]) ~ :not([hidden]) {\n --tw-divide-opacity: 1;\n border-color: rgb(230 227 239 / var(--tw-divide-opacity));\n}\n.tina-tailwind .overflow-hidden {\n overflow: hidden;\n}\n.tina-tailwind .overflow-y-auto {\n overflow-y: auto;\n}\n.tina-tailwind .whitespace-nowrap {\n white-space: nowrap;\n}\n.tina-tailwind .rounded-lg {\n border-radius: 8px;\n}\n.tina-tailwind .rounded-full {\n border-radius: 9999px;\n}\n.tina-tailwind .rounded-md {\n border-radius: 6px;\n}\n.tina-tailwind .border {\n border-width: 1px;\n}\n.tina-tailwind .border-b {\n border-bottom-width: 1px;\n}\n.tina-tailwind .border-gray-150 {\n --tw-border-opacity: 1;\n border-color: rgb(230 227 239 / var(--tw-border-opacity));\n}\n.tina-tailwind .border-gray-200 {\n --tw-border-opacity: 1;\n border-color: rgb(225 221 236 / var(--tw-border-opacity));\n}\n.tina-tailwind .bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity));\n}\n.tina-tailwind .bg-gray-50 {\n --tw-bg-opacity: 1;\n background-color: rgb(246 246 249 / var(--tw-bg-opacity));\n}\n.tina-tailwind .bg-blue-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(0 132 255 / var(--tw-bg-opacity));\n}\n.tina-tailwind .bg-gradient-to-b {\n background-image: linear-gradient(to bottom, var(--tw-gradient-stops));\n}\n.tina-tailwind .from-blue-900 {\n --tw-gradient-from: #1D2C6C;\n --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgb(29 44 108 / 0));\n}\n.tina-tailwind .to-gray-900 {\n --tw-gradient-to: #252336;\n}\n.tina-tailwind .px-4 {\n padding-left: 16px;\n padding-right: 16px;\n}\n.tina-tailwind .py-6 {\n padding-top: 24px;\n padding-bottom: 24px;\n}\n.tina-tailwind .px-5 {\n padding-left: 20px;\n padding-right: 20px;\n}\n.tina-tailwind .py-4 {\n padding-top: 16px;\n padding-bottom: 16px;\n}\n.tina-tailwind .px-12 {\n padding-left: 48px;\n padding-right: 48px;\n}\n.tina-tailwind .py-10 {\n padding-top: 40px;\n padding-bottom: 40px;\n}\n.tina-tailwind .px-20 {\n padding-left: 80px;\n padding-right: 80px;\n}\n.tina-tailwind .px-6 {\n padding-left: 24px;\n padding-right: 24px;\n}\n.tina-tailwind .py-1 {\n padding-top: 4px;\n padding-bottom: 4px;\n}\n.tina-tailwind .py-2 {\n padding-top: 8px;\n padding-bottom: 8px;\n}\n.tina-tailwind .pt-4 {\n padding-top: 16px;\n}\n.tina-tailwind .pb-4 {\n padding-bottom: 16px;\n}\n.tina-tailwind .pt-18 {\n padding-top: 72px;\n}\n.tina-tailwind .text-left {\n text-align: left;\n}\n.tina-tailwind .text-center {\n text-align: center;\n}\n.tina-tailwind .font-sans {\n 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";\n}\n.tina-tailwind .text-2xl {\n font-size: 24px;\n line-height: 1.33;\n}\n.tina-tailwind .text-base {\n font-size: 16px;\n line-height: 1.5;\n}\n.tina-tailwind .text-sm {\n font-size: 14px;\n line-height: 1.43;\n}\n.tina-tailwind .text-xl {\n font-size: 20px;\n line-height: 1.4;\n}\n.tina-tailwind .text-md {\n font-size: 16px;\n line-height: 1.5;\n}\n.tina-tailwind .text-xs {\n font-size: 13px;\n line-height: 1.33;\n}\n.tina-tailwind .font-medium {\n font-weight: 500;\n}\n.tina-tailwind .uppercase {\n text-transform: uppercase;\n}\n.tina-tailwind .italic {\n font-style: italic;\n}\n.tina-tailwind .leading-normal {\n line-height: 1.5;\n}\n.tina-tailwind .leading-tight {\n line-height: 1.25;\n}\n.tina-tailwind .leading-5 {\n line-height: 20px;\n}\n.tina-tailwind .tracking-wide {\n letter-spacing: 0.025em;\n}\n.tina-tailwind .text-gray-700 {\n --tw-text-opacity: 1;\n color: rgb(67 62 82 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-blue-600 {\n --tw-text-opacity: 1;\n color: rgb(5 116 228 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-gray-500 {\n --tw-text-opacity: 1;\n color: rgb(113 108 127 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-gray-400 {\n --tw-text-opacity: 1;\n color: rgb(145 140 158 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-current {\n color: currentColor;\n}\n.tina-tailwind .text-white {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-gray-600 {\n --tw-text-opacity: 1;\n color: rgb(86 81 101 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-gray-800 {\n --tw-text-opacity: 1;\n color: rgb(54 49 69 / var(--tw-text-opacity));\n}\n.tina-tailwind .text-gray-900 {\n --tw-text-opacity: 1;\n color: rgb(37 35 54 / var(--tw-text-opacity));\n}\n.tina-tailwind .underline {\n text-decoration-line: underline;\n}\n.tina-tailwind .opacity-100 {\n opacity: 1;\n}\n.tina-tailwind .opacity-90 {\n opacity: .9;\n}\n.tina-tailwind .opacity-80 {\n opacity: .8;\n}\n.tina-tailwind .opacity-50 {\n opacity: .5;\n}\n.tina-tailwind .opacity-70 {\n opacity: .7;\n}\n.tina-tailwind .opacity-0 {\n opacity: 0;\n}\n.tina-tailwind .shadow-lg {\n --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);\n --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.tina-tailwind .shadow-2xl {\n --tw-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n --tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.tina-tailwind .shadow {\n --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.tina-tailwind .ring-1 {\n --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);\n --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);\n box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);\n}\n.tina-tailwind .ring-black {\n --tw-ring-opacity: 1;\n --tw-ring-color: rgb(0 0 0 / var(--tw-ring-opacity));\n}\n.tina-tailwind .ring-opacity-5 {\n --tw-ring-opacity: .05;\n}\n.tina-tailwind .filter {\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n.tina-tailwind .transition-opacity {\n transition-property: opacity;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.tina-tailwind .transition-colors {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.tina-tailwind .transition-all {\n transition-property: all;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.tina-tailwind .transition {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.tina-tailwind .duration-300 {\n transition-duration: 300ms;\n}\n.tina-tailwind .duration-150 {\n transition-duration: 150ms;\n}\n.tina-tailwind .duration-100 {\n transition-duration: 100ms;\n}\n.tina-tailwind .duration-75 {\n transition-duration: 75ms;\n}\n.tina-tailwind .ease-out {\n transition-timing-function: cubic-bezier(0, 0, 0.2, 1);\n}\n.tina-tailwind .ease-in {\n transition-timing-function: cubic-bezier(0.4, 0, 1, 1);\n}\n.tina-tailwind .icon-parent svg {\n fill: currentColor;\n }\n\n.tina-tailwind {\n 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";\n font-size: 16px;\n line-height: 1.5;\n --tw-text-opacity: 1;\n color: rgb(86 81 101 / var(--tw-text-opacity));\n}\n\n.tina-tailwind .hover\\:bg-blue-600:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(5 116 228 / var(--tw-bg-opacity));\n}\n\n.tina-tailwind .hover\\:text-blue-600:hover {\n --tw-text-opacity: 1;\n color: rgb(5 116 228 / var(--tw-text-opacity));\n}\n\n.tina-tailwind .hover\\:text-blue-400:hover {\n --tw-text-opacity: 1;\n color: rgb(34 150 254 / var(--tw-text-opacity));\n}\n\n.tina-tailwind .hover\\:opacity-100:hover {\n opacity: 1;\n}\n\n.tina-tailwind .focus\\:text-blue-400:focus {\n --tw-text-opacity: 1;\n color: rgb(34 150 254 / var(--tw-text-opacity));\n}\n\n.tina-tailwind .focus\\:underline:focus {\n text-decoration-line: underline;\n}\n\n.tina-tailwind .focus\\:shadow-outline:focus {\n --tw-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);\n --tw-shadow-colored: 0 0 0 3px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n\n.tina-tailwind .focus\\:outline-none:focus {\n outline: 2px solid transparent;\n outline-offset: 2px;\n}\n\n.tina-tailwind .focus\\:ring-2:focus {\n --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);\n --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);\n box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);\n}\n\n.tina-tailwind .focus\\:ring-blue-500:focus {\n --tw-ring-opacity: 1;\n --tw-ring-color: rgb(0 132 255 / var(--tw-ring-opacity));\n}\n';
|
|
3042
3126
|
function useTina({
|
|
3043
3127
|
query,
|
|
3044
3128
|
variables,
|
|
@@ -3117,13 +3201,23 @@ mutation addPendingDocumentMutation(
|
|
|
3117
3201
|
style: { color: "#eb6337" }
|
|
3118
3202
|
}, "TinaCMS Render Error"), /* @__PURE__ */ React__default["default"].createElement("p", null, "Tina caught an error while updating the page:"), /* @__PURE__ */ React__default["default"].createElement("pre", {
|
|
3119
3203
|
style: { marginTop: "1rem", overflowX: "auto" }
|
|
3120
|
-
}, this.state.message), /* @__PURE__ */ React__default["default"].createElement("br", null), /* @__PURE__ */ React__default["default"].createElement("p", null, `If you've just updated the form, undo your most recent changes and click "refresh". If after a few refreshes, you're still encountering this error. There is a bigger issue with the site. Please reach out to your site admin.`), /* @__PURE__ */ React__default["default"].createElement("
|
|
3204
|
+
}, this.state.message), /* @__PURE__ */ React__default["default"].createElement("br", null), /* @__PURE__ */ React__default["default"].createElement("p", null, `If you've just updated the form, undo your most recent changes and click "refresh". If after a few refreshes, you're still encountering this error. There is a bigger issue with the site. Please reach out to your site admin.`), /* @__PURE__ */ React__default["default"].createElement("p", null, "See our", " ", /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
3205
|
+
className: "text-gray-600",
|
|
3206
|
+
style: { textDecoration: "underline" },
|
|
3207
|
+
href: "https://tina.io/docs/errors/faq/",
|
|
3208
|
+
target: "_blank"
|
|
3209
|
+
}, " ", "Error FAQ", " "), " ", "for more information."), /* @__PURE__ */ React__default["default"].createElement("button", {
|
|
3121
3210
|
style: errorButtonStyles,
|
|
3122
3211
|
onClick: () => {
|
|
3123
3212
|
this.setState({ pageRefresh: true });
|
|
3124
3213
|
setTimeout(() => this.setState({ hasError: false, pageRefresh: false }), 3e3);
|
|
3125
3214
|
}
|
|
3126
|
-
}, "Refresh"), hasBranchData && /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("p", null, `If you're using the branch switcher, you may currently be on a "stale" branch that has been deleted or whose content is not compatible with the latest version of the site's layout. Click the button below to switch back to the default branch for this deployment.`), /* @__PURE__ */ React__default["default"].createElement("
|
|
3215
|
+
}, "Refresh"), hasBranchData && /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("p", null, `If you're using the branch switcher, you may currently be on a "stale" branch that has been deleted or whose content is not compatible with the latest version of the site's layout. Click the button below to switch back to the default branch for this deployment.`), /* @__PURE__ */ React__default["default"].createElement("p", null, "See our", " ", /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
3216
|
+
className: "text-gray-600",
|
|
3217
|
+
style: { textDecoration: "underline" },
|
|
3218
|
+
href: "https://tina.io/docs/errors/faq/",
|
|
3219
|
+
target: "_blank"
|
|
3220
|
+
}, " ", "Error FAQ", " "), " ", "for more information."), /* @__PURE__ */ React__default["default"].createElement("button", {
|
|
3127
3221
|
style: errorButtonStyles,
|
|
3128
3222
|
onClick: () => {
|
|
3129
3223
|
window.localStorage.removeItem("tinacms-current-branch");
|
|
@@ -3156,11 +3250,13 @@ mutation addPendingDocumentMutation(
|
|
|
3156
3250
|
var _d = _c, {
|
|
3157
3251
|
query,
|
|
3158
3252
|
documentCreatorCallback,
|
|
3159
|
-
formifyCallback
|
|
3253
|
+
formifyCallback,
|
|
3254
|
+
schema
|
|
3160
3255
|
} = _d, props = __objRest(_d, [
|
|
3161
3256
|
"query",
|
|
3162
3257
|
"documentCreatorCallback",
|
|
3163
|
-
"formifyCallback"
|
|
3258
|
+
"formifyCallback",
|
|
3259
|
+
"schema"
|
|
3164
3260
|
]);
|
|
3165
3261
|
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);
|
|
3166
3262
|
if (!props.apiURL && !validOldSetup) {
|
|
@@ -3177,7 +3273,8 @@ mutation addPendingDocumentMutation(
|
|
|
3177
3273
|
tinaioConfig: props.tinaioConfig,
|
|
3178
3274
|
isLocalClient,
|
|
3179
3275
|
cmsCallback: props.cmsCallback,
|
|
3180
|
-
mediaStore: props.mediaStore
|
|
3276
|
+
mediaStore: props.mediaStore,
|
|
3277
|
+
schema
|
|
3181
3278
|
}, /* @__PURE__ */ React__default["default"].createElement("style", null, styles), /* @__PURE__ */ React__default["default"].createElement(ErrorBoundary, null, /* @__PURE__ */ React__default["default"].createElement(DocumentCreator, {
|
|
3182
3279
|
documentCreatorCallback
|
|
3183
3280
|
}), /* @__PURE__ */ React__default["default"].createElement(TinaDataProvider, {
|
|
@@ -3221,10 +3318,10 @@ mutation addPendingDocumentMutation(
|
|
|
3221
3318
|
});
|
|
3222
3319
|
const cms = toolkit.useCMS();
|
|
3223
3320
|
const useUnstableFormify = React__default["default"].useMemo(() => {
|
|
3224
|
-
if (cms == null ? void 0 : cms.flags.get("use-unstable-formify")) {
|
|
3225
|
-
return
|
|
3321
|
+
if ((cms == null ? void 0 : cms.flags.get("use-unstable-formify")) === false) {
|
|
3322
|
+
return false;
|
|
3226
3323
|
}
|
|
3227
|
-
return
|
|
3324
|
+
return true;
|
|
3228
3325
|
}, [cms == null ? void 0 : cms.flags]);
|
|
3229
3326
|
return /* @__PURE__ */ React__default["default"].createElement(sharedctx.TinaDataContext.Provider, {
|
|
3230
3327
|
value: {
|
|
@@ -3542,10 +3639,10 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3542
3639
|
const response = await api.fetchCollections();
|
|
3543
3640
|
setCollections(response.getCollections);
|
|
3544
3641
|
} catch (error2) {
|
|
3545
|
-
cms.alerts.error(`[${error2.name}] GetCollections failed: ${error2.message}`, 30 * 1e3);
|
|
3546
3642
|
console.error(error2);
|
|
3547
3643
|
setCollections([]);
|
|
3548
3644
|
setError(error2);
|
|
3645
|
+
throw new Error(`[${error2.name}] GetCollections failed: ${error2.message}`);
|
|
3549
3646
|
}
|
|
3550
3647
|
setLoading(false);
|
|
3551
3648
|
}
|
|
@@ -3610,6 +3707,9 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3610
3707
|
function BiPlus(props) {
|
|
3611
3708
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M19 11h-6V5h-2v6H5v2h6v6h2v-6h6z" } }] })(props);
|
|
3612
3709
|
}
|
|
3710
|
+
function BiTrash(props) {
|
|
3711
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M5 20a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8h2V6h-4V4a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v2H3v2h2zM9 4h6v2H9zM8 8h9v12H7V8z" } }, { "tag": "path", "attr": { "d": "M9 10h2v8H9zm4 0h2v8h-2z" } }] })(props);
|
|
3712
|
+
}
|
|
3613
3713
|
function MdOutlineArrowBack(props) {
|
|
3614
3714
|
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);
|
|
3615
3715
|
}
|
|
@@ -3835,6 +3935,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3835
3935
|
const [collection, setCollection] = React.useState(void 0);
|
|
3836
3936
|
const [loading, setLoading] = React.useState(true);
|
|
3837
3937
|
const [error, setError] = React.useState(void 0);
|
|
3938
|
+
const [resetState, setResetSate] = React.useState(0);
|
|
3838
3939
|
React.useEffect(() => {
|
|
3839
3940
|
const fetchCollection = async () => {
|
|
3840
3941
|
if (await api.isAuthenticated()) {
|
|
@@ -3852,8 +3953,9 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3852
3953
|
};
|
|
3853
3954
|
setLoading(true);
|
|
3854
3955
|
fetchCollection();
|
|
3855
|
-
}, [cms, collectionName]);
|
|
3856
|
-
|
|
3956
|
+
}, [cms, collectionName, resetState]);
|
|
3957
|
+
const reFetchCollection = () => setResetSate((x) => x + 1);
|
|
3958
|
+
return { collection, loading, error, reFetchCollection };
|
|
3857
3959
|
};
|
|
3858
3960
|
const GetCollection = ({
|
|
3859
3961
|
cms,
|
|
@@ -3861,14 +3963,14 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3861
3963
|
includeDocuments = true,
|
|
3862
3964
|
children
|
|
3863
3965
|
}) => {
|
|
3864
|
-
const { collection, loading, error } = useGetCollection(cms, collectionName, includeDocuments);
|
|
3966
|
+
const { collection, loading, error, reFetchCollection } = useGetCollection(cms, collectionName, includeDocuments);
|
|
3865
3967
|
if (error) {
|
|
3866
3968
|
return null;
|
|
3867
3969
|
}
|
|
3868
3970
|
if (loading) {
|
|
3869
3971
|
return /* @__PURE__ */ React__default["default"].createElement(LoadingPage, null);
|
|
3870
3972
|
}
|
|
3871
|
-
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collection, loading));
|
|
3973
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collection, loading, reFetchCollection));
|
|
3872
3974
|
};
|
|
3873
3975
|
const TemplateMenu = ({ templates }) => {
|
|
3874
3976
|
return /* @__PURE__ */ React__default["default"].createElement(react.Menu, {
|
|
@@ -3905,22 +4007,42 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3905
4007
|
window.location.href = routeOverride;
|
|
3906
4008
|
return null;
|
|
3907
4009
|
} else {
|
|
3908
|
-
navigate(document.sys.
|
|
4010
|
+
navigate(document.sys.breadcrumbs.join("/"));
|
|
3909
4011
|
}
|
|
3910
4012
|
};
|
|
3911
4013
|
const CollectionListPage = () => {
|
|
3912
4014
|
const navigate = reactRouterDom.useNavigate();
|
|
3913
4015
|
const { collectionName } = reactRouterDom.useParams();
|
|
4016
|
+
const [open, setOpen] = React__default["default"].useState(false);
|
|
4017
|
+
const [vars, setVars] = React__default["default"].useState({
|
|
4018
|
+
collection: collectionName,
|
|
4019
|
+
relativePath: ""
|
|
4020
|
+
});
|
|
3914
4021
|
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => {
|
|
3915
4022
|
return /* @__PURE__ */ React__default["default"].createElement(GetCollection, {
|
|
3916
4023
|
cms,
|
|
3917
4024
|
collectionName,
|
|
3918
4025
|
includeDocuments: true
|
|
3919
|
-
}, (collection) => {
|
|
4026
|
+
}, (collection, _loading, reFetchCollection) => {
|
|
3920
4027
|
var _a, _b;
|
|
3921
4028
|
const totalCount = collection.documents.totalCount;
|
|
3922
4029
|
const documents = collection.documents.edges;
|
|
3923
|
-
|
|
4030
|
+
const admin = cms.api.admin;
|
|
4031
|
+
return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, open && /* @__PURE__ */ React__default["default"].createElement(DeleteModal, {
|
|
4032
|
+
filename: vars.relativePath,
|
|
4033
|
+
deleteFunc: async () => {
|
|
4034
|
+
try {
|
|
4035
|
+
await admin.deleteDocument(vars);
|
|
4036
|
+
cms.alerts.info("Document was successfully deleted");
|
|
4037
|
+
reFetchCollection();
|
|
4038
|
+
} catch (error) {
|
|
4039
|
+
cms.alerts.warn("Document was not deleted, ask a developer for help or check the console for an error message");
|
|
4040
|
+
console.error(error);
|
|
4041
|
+
throw error;
|
|
4042
|
+
}
|
|
4043
|
+
},
|
|
4044
|
+
close: () => setOpen(false)
|
|
4045
|
+
}), /* @__PURE__ */ React__default["default"].createElement(PageHeader, {
|
|
3924
4046
|
isLocalMode: (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
|
|
3925
4047
|
}, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("h3", {
|
|
3926
4048
|
className: "text-2xl text-gray-700"
|
|
@@ -3938,8 +4060,9 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3938
4060
|
}, /* @__PURE__ */ React__default["default"].createElement("tbody", {
|
|
3939
4061
|
className: "divide-y divide-gray-150"
|
|
3940
4062
|
}, documents.map((document) => {
|
|
4063
|
+
const subfolders = document.node.sys.breadcrumbs.slice(0, -1).join("/");
|
|
3941
4064
|
return /* @__PURE__ */ React__default["default"].createElement("tr", {
|
|
3942
|
-
key: `document-${document.node.sys.
|
|
4065
|
+
key: `document-${document.node.sys.relativePath}`,
|
|
3943
4066
|
className: ""
|
|
3944
4067
|
}, /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
3945
4068
|
className: "px-6 py-2 whitespace-nowrap"
|
|
@@ -3954,7 +4077,9 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3954
4077
|
className: "block text-xs text-gray-400 mb-1 uppercase"
|
|
3955
4078
|
}, "Filename"), /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
3956
4079
|
className: "h-5 leading-5 block whitespace-nowrap"
|
|
3957
|
-
},
|
|
4080
|
+
}, subfolders && /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
4081
|
+
className: "text-xs text-gray-400"
|
|
4082
|
+
}, `${subfolders}/`), /* @__PURE__ */ React__default["default"].createElement("span", null, document.node.sys.filename))))), /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
3958
4083
|
className: "px-6 py-4 whitespace-nowrap"
|
|
3959
4084
|
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
3960
4085
|
className: "block text-xs text-gray-400 mb-1 uppercase"
|
|
@@ -3966,14 +4091,59 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
3966
4091
|
className: "block text-xs text-gray-400 mb-1 uppercase"
|
|
3967
4092
|
}, "Template"), /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
3968
4093
|
className: "h-5 leading-5 block text-sm font-medium text-gray-900"
|
|
3969
|
-
}, document.node.sys.template))
|
|
4094
|
+
}, document.node.sys.template)), /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
4095
|
+
className: "w-0"
|
|
4096
|
+
}, /* @__PURE__ */ React__default["default"].createElement(toolkit.OverflowMenu, {
|
|
4097
|
+
showEmbed: true,
|
|
4098
|
+
toolbarItems: [
|
|
4099
|
+
{
|
|
4100
|
+
name: "edit",
|
|
4101
|
+
label: "Edit in Admin",
|
|
4102
|
+
Icon: /* @__PURE__ */ React__default["default"].createElement(BiEdit, {
|
|
4103
|
+
size: "1.3rem"
|
|
4104
|
+
}),
|
|
4105
|
+
onMouseDown: () => {
|
|
4106
|
+
navigate(`${document.node.sys.filename}`, { replace: true });
|
|
4107
|
+
}
|
|
4108
|
+
},
|
|
4109
|
+
{
|
|
4110
|
+
name: "delete",
|
|
4111
|
+
label: "Delete",
|
|
4112
|
+
Icon: /* @__PURE__ */ React__default["default"].createElement(BiTrash, {
|
|
4113
|
+
size: "1.3rem",
|
|
4114
|
+
className: "text-red-500"
|
|
4115
|
+
}),
|
|
4116
|
+
onMouseDown: () => {
|
|
4117
|
+
setVars({
|
|
4118
|
+
collection: collectionName,
|
|
4119
|
+
relativePath: document.node.sys.filename + document.node.sys.extension
|
|
4120
|
+
});
|
|
4121
|
+
setOpen(true);
|
|
4122
|
+
}
|
|
4123
|
+
}
|
|
4124
|
+
]
|
|
4125
|
+
})));
|
|
3970
4126
|
})))))));
|
|
3971
4127
|
});
|
|
3972
4128
|
});
|
|
3973
4129
|
};
|
|
3974
|
-
|
|
3975
|
-
return
|
|
3976
|
-
|
|
4130
|
+
const DeleteModal = ({ close: close2, deleteFunc, filename }) => {
|
|
4131
|
+
return /* @__PURE__ */ React__default["default"].createElement(toolkit.Modal, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalPopup, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalHeader, {
|
|
4132
|
+
close: close2
|
|
4133
|
+
}, "Reset"), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalBody, {
|
|
4134
|
+
padded: true
|
|
4135
|
+
}, /* @__PURE__ */ React__default["default"].createElement("p", null, `Are you sure you want to delete ${filename}?`)), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalActions, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
|
|
4136
|
+
style: { flexGrow: 2 },
|
|
4137
|
+
onClick: close2
|
|
4138
|
+
}, "Cancel"), /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
|
|
4139
|
+
style: { flexGrow: 3 },
|
|
4140
|
+
variant: "danger",
|
|
4141
|
+
onClick: async () => {
|
|
4142
|
+
await deleteFunc();
|
|
4143
|
+
close2();
|
|
4144
|
+
}
|
|
4145
|
+
}, "Delete"))));
|
|
4146
|
+
};
|
|
3977
4147
|
const useGetDocumentFields = (cms, collectionName, templateName) => {
|
|
3978
4148
|
const api = new TinaAdminApi(cms);
|
|
3979
4149
|
const [info, setInfo] = React.useState({
|
|
@@ -4040,6 +4210,9 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4040
4210
|
}
|
|
4041
4211
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children({ collection, template, fields, mutationInfo, loading }));
|
|
4042
4212
|
};
|
|
4213
|
+
function HiChevronRight(props) {
|
|
4214
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z", "clipRule": "evenodd" } }] })(props);
|
|
4215
|
+
}
|
|
4043
4216
|
const createDocument = async (cms, collection, template, mutationInfo, values) => {
|
|
4044
4217
|
const api = new TinaAdminApi(cms);
|
|
4045
4218
|
const _a = values, { filename } = _a, leftover = __objRest(_a, ["filename"]);
|
|
@@ -4078,6 +4251,22 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4078
4251
|
var _a, _b;
|
|
4079
4252
|
const navigate = reactRouterDom.useNavigate();
|
|
4080
4253
|
const [formIsPristine, setFormIsPristine] = React.useState(true);
|
|
4254
|
+
const schema = cms.api.tina.schema;
|
|
4255
|
+
let schemaFields = fields;
|
|
4256
|
+
if (schema) {
|
|
4257
|
+
const schemaCollection = schema.getCollection(collection.name);
|
|
4258
|
+
const template2 = schema.getTemplateForData({
|
|
4259
|
+
collection: schemaCollection,
|
|
4260
|
+
data: {}
|
|
4261
|
+
});
|
|
4262
|
+
const formInfo = schemaTools.resolveForm({
|
|
4263
|
+
collection: schemaCollection,
|
|
4264
|
+
basename: schemaCollection.name,
|
|
4265
|
+
schema,
|
|
4266
|
+
template: template2
|
|
4267
|
+
});
|
|
4268
|
+
schemaFields = formInfo.fields;
|
|
4269
|
+
}
|
|
4081
4270
|
const form = React.useMemo(() => {
|
|
4082
4271
|
return new toolkit.Form({
|
|
4083
4272
|
id: "create-form",
|
|
@@ -4087,7 +4276,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4087
4276
|
name: "filename",
|
|
4088
4277
|
label: "Filename",
|
|
4089
4278
|
component: "text",
|
|
4090
|
-
description:
|
|
4279
|
+
description: /* @__PURE__ */ React__default["default"].createElement("span", null, "A unique filename for the content.", /* @__PURE__ */ React__default["default"].createElement("br", null), "Examples: ", /* @__PURE__ */ React__default["default"].createElement("code", null, "My_Document"), ", ", /* @__PURE__ */ React__default["default"].createElement("code", null, "My_Document.en"), ",", " ", /* @__PURE__ */ React__default["default"].createElement("code", null, "sub-folder/My_Document")),
|
|
4091
4280
|
placeholder: `My_Document`,
|
|
4092
4281
|
validate: (value, allValues, meta) => {
|
|
4093
4282
|
if (!value) {
|
|
@@ -4096,13 +4285,13 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4096
4285
|
}
|
|
4097
4286
|
return true;
|
|
4098
4287
|
}
|
|
4099
|
-
const isValid = /^[_a-zA-Z][
|
|
4288
|
+
const isValid = /^[_a-zA-Z][\.\-_\/a-zA-Z0-9]*$/.test(value);
|
|
4100
4289
|
if (value && !isValid) {
|
|
4101
|
-
return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, -, ., or
|
|
4290
|
+
return "Must begin with a-z, A-Z, or _ and contain only a-z, A-Z, 0-9, -, _, ., or /.";
|
|
4102
4291
|
}
|
|
4103
4292
|
}
|
|
4104
4293
|
},
|
|
4105
|
-
...
|
|
4294
|
+
...schemaFields
|
|
4106
4295
|
],
|
|
4107
4296
|
onSubmit: async (values) => {
|
|
4108
4297
|
try {
|
|
@@ -4110,8 +4299,8 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4110
4299
|
cms.alerts.success("Document created!");
|
|
4111
4300
|
navigate(`/collections/${collection.name}`);
|
|
4112
4301
|
} catch (error) {
|
|
4113
|
-
cms.alerts.error(`[${error.name}] CreateDocument failed: ${error.message}`, 30 * 1e3);
|
|
4114
4302
|
console.error(error);
|
|
4303
|
+
throw new Error(`[${error.name}] CreateDocument failed: ${error.message}`);
|
|
4115
4304
|
}
|
|
4116
4305
|
}
|
|
4117
4306
|
});
|
|
@@ -4195,7 +4384,8 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4195
4384
|
}
|
|
4196
4385
|
};
|
|
4197
4386
|
const CollectionUpdatePage = () => {
|
|
4198
|
-
const { collectionName
|
|
4387
|
+
const _a = reactRouterDom.useParams(), { collectionName } = _a, rest = __objRest(_a, ["collectionName"]);
|
|
4388
|
+
const { "*": filename } = rest;
|
|
4199
4389
|
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => /* @__PURE__ */ React__default["default"].createElement(GetDocumentFields, {
|
|
4200
4390
|
cms,
|
|
4201
4391
|
collectionName
|
|
@@ -4224,21 +4414,36 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4224
4414
|
mutationInfo
|
|
4225
4415
|
}) => {
|
|
4226
4416
|
var _a, _b;
|
|
4227
|
-
reactRouterDom.useNavigate();
|
|
4228
4417
|
const [formIsPristine, setFormIsPristine] = React.useState(true);
|
|
4418
|
+
const schema = cms.api.tina.schema;
|
|
4419
|
+
let schemaFields = document.form.fields;
|
|
4420
|
+
if (schema) {
|
|
4421
|
+
const schemaCollection = schema.getCollection(collection.name);
|
|
4422
|
+
const template = schema.getTemplateForData({
|
|
4423
|
+
collection: schemaCollection,
|
|
4424
|
+
data: document.value
|
|
4425
|
+
});
|
|
4426
|
+
const formInfo = schemaTools.resolveForm({
|
|
4427
|
+
collection: schemaCollection,
|
|
4428
|
+
basename: schemaCollection.name,
|
|
4429
|
+
schema,
|
|
4430
|
+
template
|
|
4431
|
+
});
|
|
4432
|
+
schemaFields = formInfo.fields;
|
|
4433
|
+
}
|
|
4229
4434
|
const form = React.useMemo(() => {
|
|
4230
4435
|
return new toolkit.Form({
|
|
4231
4436
|
id: "update-form",
|
|
4232
4437
|
label: "form",
|
|
4233
|
-
fields:
|
|
4438
|
+
fields: schemaFields,
|
|
4234
4439
|
initialValues: document.values,
|
|
4235
4440
|
onSubmit: async (values) => {
|
|
4236
4441
|
try {
|
|
4237
4442
|
await updateDocument(cms, relativePath, collection, mutationInfo, values);
|
|
4238
4443
|
cms.alerts.success("Document updated!");
|
|
4239
4444
|
} catch (error) {
|
|
4240
|
-
cms.alerts.error(`[${error.name}] UpdateDocument failed: ${error.message}`, 30 * 1e3);
|
|
4241
4445
|
console.error(error);
|
|
4446
|
+
throw new Error(`[${error.name}] UpdateDocument failed: ${error.message}`);
|
|
4242
4447
|
}
|
|
4243
4448
|
}
|
|
4244
4449
|
});
|
|
@@ -4314,7 +4519,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4314
4519
|
path: "collections/:collectionName/:templateName/new",
|
|
4315
4520
|
element: /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)
|
|
4316
4521
|
}), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
4317
|
-
path: "collections/:collectionName
|
|
4522
|
+
path: "collections/:collectionName/*",
|
|
4318
4523
|
element: /* @__PURE__ */ React__default["default"].createElement(CollectionUpdatePage, null)
|
|
4319
4524
|
}), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
4320
4525
|
path: "collections/:collectionName",
|
|
@@ -4345,6 +4550,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4345
4550
|
}
|
|
4346
4551
|
}
|
|
4347
4552
|
const defineSchema = (config) => {
|
|
4553
|
+
schemaTools.validateSchema({ config });
|
|
4348
4554
|
return config;
|
|
4349
4555
|
};
|
|
4350
4556
|
const defineConfig = (config) => {
|