tinacms 0.69.4 → 0.69.5
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/dist/hooks/use-graphql-forms.d.ts +4 -1
- package/dist/index.es.js +30 -10
- package/dist/index.js +30 -10
- package/dist/internalClient/index.d.ts +10 -0
- package/package.json +3 -3
|
@@ -33,7 +33,10 @@ export declare const transformDocumentIntoMutationRequestPayload: (document: {
|
|
|
33
33
|
includeCollection?: boolean;
|
|
34
34
|
includeTemplate?: boolean;
|
|
35
35
|
}) => any;
|
|
36
|
-
export declare const generateFormCreators: (cms: TinaCMS, showInSidebar?: boolean
|
|
36
|
+
export declare const generateFormCreators: (cms: TinaCMS, showInSidebar?: boolean, global?: boolean | {
|
|
37
|
+
icon?: any;
|
|
38
|
+
layout: 'fullscreen' | 'popup';
|
|
39
|
+
}) => {
|
|
37
40
|
createForm: (formConfig: any) => Form<any, import("@tinacms/toolkit").AnyField>;
|
|
38
41
|
createGlobalForm: GlobalFormCreator;
|
|
39
42
|
};
|
package/dist/index.es.js
CHANGED
|
@@ -436,11 +436,16 @@ const transformParams = (data) => {
|
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
438
|
};
|
|
439
|
-
const generateFormCreators = (cms, showInSidebar) => {
|
|
439
|
+
const generateFormCreators = (cms, showInSidebar, global) => {
|
|
440
440
|
const createForm = (formConfig) => {
|
|
441
441
|
const form = new Form(formConfig);
|
|
442
442
|
if (showInSidebar) {
|
|
443
|
-
|
|
443
|
+
if (global) {
|
|
444
|
+
const options = typeof global === "boolean" ? [null, "fullscreen"] : [global.icon, global.layout];
|
|
445
|
+
cms.plugins.add(new GlobalFormPlugin(form, ...options));
|
|
446
|
+
} else {
|
|
447
|
+
cms.forms.add(form);
|
|
448
|
+
}
|
|
444
449
|
}
|
|
445
450
|
return form;
|
|
446
451
|
};
|
|
@@ -520,7 +525,11 @@ const getPathToChange = (documentBlueprint, formNode, event) => {
|
|
|
520
525
|
return accum.join(".");
|
|
521
526
|
};
|
|
522
527
|
const buildForm = (doc, cms, formify2, showInSidebar = false, onSubmit) => {
|
|
523
|
-
|
|
528
|
+
var _a;
|
|
529
|
+
const id = doc._internalSys.path;
|
|
530
|
+
const enrichedSchema = cms.api.tina.schema;
|
|
531
|
+
const collection = enrichedSchema.getCollection(doc._internalSys.collection.name);
|
|
532
|
+
const { createForm, createGlobalForm } = generateFormCreators(cms, showInSidebar, (_a = collection.ui) == null ? void 0 : _a.global);
|
|
524
533
|
const SKIPPED = "SKIPPED";
|
|
525
534
|
let form;
|
|
526
535
|
let skipped;
|
|
@@ -529,9 +538,6 @@ const buildForm = (doc, cms, formify2, showInSidebar = false, onSubmit) => {
|
|
|
529
538
|
};
|
|
530
539
|
if (skipped)
|
|
531
540
|
return;
|
|
532
|
-
const id = doc._internalSys.path;
|
|
533
|
-
const enrichedSchema = cms.api.tina.schema;
|
|
534
|
-
const collection = enrichedSchema.getCollection(doc._internalSys.collection.name);
|
|
535
541
|
const template = enrichedSchema.getTemplateForData({
|
|
536
542
|
collection,
|
|
537
543
|
data: doc._values
|
|
@@ -2288,6 +2294,15 @@ mutation addPendingDocumentMutation(
|
|
|
2288
2294
|
const jsonRes = await res.json();
|
|
2289
2295
|
return jsonRes;
|
|
2290
2296
|
}
|
|
2297
|
+
async fetchEvents(limit, cursor) {
|
|
2298
|
+
if (this.isLocalMode) {
|
|
2299
|
+
return {
|
|
2300
|
+
events: []
|
|
2301
|
+
};
|
|
2302
|
+
} else {
|
|
2303
|
+
return (await this.fetchWithToken(`${this.contentApiBase}/events/${this.clientId}/${this.branch}?limit=${limit || 1}${cursor ? `&cursor=${cursor}` : ""}`, { method: "GET" })).json();
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2291
2306
|
parseJwt(token) {
|
|
2292
2307
|
const base64Url = token.split(".")[1];
|
|
2293
2308
|
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
@@ -4820,10 +4835,14 @@ const TemplateMenu = ({ templates }) => {
|
|
|
4820
4835
|
className: `w-full text-md px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`
|
|
4821
4836
|
}, template.label))))))));
|
|
4822
4837
|
};
|
|
4823
|
-
const handleNavigate = (navigate, cms, collection, document) => {
|
|
4838
|
+
const handleNavigate = (navigate, cms, collection, collectionDefinition, document) => {
|
|
4839
|
+
var _a, _b;
|
|
4824
4840
|
const plugins = cms.plugins.all("tina-admin");
|
|
4825
4841
|
const routeMapping = plugins.find(({ name }) => name === "route-mapping");
|
|
4826
|
-
const routeOverride =
|
|
4842
|
+
const routeOverride = ((_a = collectionDefinition.ui) == null ? void 0 : _a.router) ? (_b = collectionDefinition.ui) == null ? void 0 : _b.router({
|
|
4843
|
+
document,
|
|
4844
|
+
collection: collectionDefinition
|
|
4845
|
+
}) : routeMapping ? routeMapping.mapper(collection, document) : void 0;
|
|
4827
4846
|
if (routeOverride) {
|
|
4828
4847
|
window.location.href = routeOverride;
|
|
4829
4848
|
return null;
|
|
@@ -4868,7 +4887,8 @@ const CollectionListPage = () => {
|
|
|
4868
4887
|
const documents = collection.documents.edges;
|
|
4869
4888
|
const admin = cms.api.admin;
|
|
4870
4889
|
const pageInfo = collection.documents.pageInfo;
|
|
4871
|
-
const fields = (_a = collectionExtra.fields) == null ? void 0 : _a.filter((x) => ["string", "number", "datetime"].includes(x.type));
|
|
4890
|
+
const fields = (_a = collectionExtra.fields) == null ? void 0 : _a.filter((x) => ["string", "number", "datetime", "boolean"].includes(x.type));
|
|
4891
|
+
const collectionDefinition = cms.api.tina.schema.getCollection(collection.name);
|
|
4872
4892
|
return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, open && /* @__PURE__ */ React.createElement(DeleteModal, {
|
|
4873
4893
|
filename: vars.relativePath,
|
|
4874
4894
|
deleteFunc: async () => {
|
|
@@ -4959,7 +4979,7 @@ const CollectionListPage = () => {
|
|
|
4959
4979
|
}, /* @__PURE__ */ React.createElement("a", {
|
|
4960
4980
|
className: "text-blue-600 hover:text-blue-400 flex items-center gap-3 cursor-pointer",
|
|
4961
4981
|
onClick: () => {
|
|
4962
|
-
handleNavigate(navigate, cms, collection, document.node);
|
|
4982
|
+
handleNavigate(navigate, cms, collection, collectionDefinition, document.node);
|
|
4963
4983
|
}
|
|
4964
4984
|
}, /* @__PURE__ */ React.createElement(BiEdit, {
|
|
4965
4985
|
className: "inline-block h-6 w-auto opacity-70"
|
package/dist/index.js
CHANGED
|
@@ -454,11 +454,16 @@
|
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
456
|
};
|
|
457
|
-
const generateFormCreators = (cms, showInSidebar) => {
|
|
457
|
+
const generateFormCreators = (cms, showInSidebar, global) => {
|
|
458
458
|
const createForm = (formConfig) => {
|
|
459
459
|
const form = new toolkit.Form(formConfig);
|
|
460
460
|
if (showInSidebar) {
|
|
461
|
-
|
|
461
|
+
if (global) {
|
|
462
|
+
const options = typeof global === "boolean" ? [null, "fullscreen"] : [global.icon, global.layout];
|
|
463
|
+
cms.plugins.add(new toolkit.GlobalFormPlugin(form, ...options));
|
|
464
|
+
} else {
|
|
465
|
+
cms.forms.add(form);
|
|
466
|
+
}
|
|
462
467
|
}
|
|
463
468
|
return form;
|
|
464
469
|
};
|
|
@@ -538,7 +543,11 @@
|
|
|
538
543
|
return accum.join(".");
|
|
539
544
|
};
|
|
540
545
|
const buildForm = (doc, cms, formify2, showInSidebar = false, onSubmit) => {
|
|
541
|
-
|
|
546
|
+
var _a;
|
|
547
|
+
const id = doc._internalSys.path;
|
|
548
|
+
const enrichedSchema = cms.api.tina.schema;
|
|
549
|
+
const collection = enrichedSchema.getCollection(doc._internalSys.collection.name);
|
|
550
|
+
const { createForm, createGlobalForm } = generateFormCreators(cms, showInSidebar, (_a = collection.ui) == null ? void 0 : _a.global);
|
|
542
551
|
const SKIPPED = "SKIPPED";
|
|
543
552
|
let form;
|
|
544
553
|
let skipped;
|
|
@@ -547,9 +556,6 @@
|
|
|
547
556
|
};
|
|
548
557
|
if (skipped)
|
|
549
558
|
return;
|
|
550
|
-
const id = doc._internalSys.path;
|
|
551
|
-
const enrichedSchema = cms.api.tina.schema;
|
|
552
|
-
const collection = enrichedSchema.getCollection(doc._internalSys.collection.name);
|
|
553
559
|
const template = enrichedSchema.getTemplateForData({
|
|
554
560
|
collection,
|
|
555
561
|
data: doc._values
|
|
@@ -2306,6 +2312,15 @@ mutation addPendingDocumentMutation(
|
|
|
2306
2312
|
const jsonRes = await res.json();
|
|
2307
2313
|
return jsonRes;
|
|
2308
2314
|
}
|
|
2315
|
+
async fetchEvents(limit, cursor) {
|
|
2316
|
+
if (this.isLocalMode) {
|
|
2317
|
+
return {
|
|
2318
|
+
events: []
|
|
2319
|
+
};
|
|
2320
|
+
} else {
|
|
2321
|
+
return (await this.fetchWithToken(`${this.contentApiBase}/events/${this.clientId}/${this.branch}?limit=${limit || 1}${cursor ? `&cursor=${cursor}` : ""}`, { method: "GET" })).json();
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2309
2324
|
parseJwt(token) {
|
|
2310
2325
|
const base64Url = token.split(".")[1];
|
|
2311
2326
|
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
@@ -4838,10 +4853,14 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4838
4853
|
className: `w-full text-md px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`
|
|
4839
4854
|
}, template.label))))))));
|
|
4840
4855
|
};
|
|
4841
|
-
const handleNavigate = (navigate, cms, collection, document) => {
|
|
4856
|
+
const handleNavigate = (navigate, cms, collection, collectionDefinition, document) => {
|
|
4857
|
+
var _a, _b;
|
|
4842
4858
|
const plugins = cms.plugins.all("tina-admin");
|
|
4843
4859
|
const routeMapping = plugins.find(({ name }) => name === "route-mapping");
|
|
4844
|
-
const routeOverride =
|
|
4860
|
+
const routeOverride = ((_a = collectionDefinition.ui) == null ? void 0 : _a.router) ? (_b = collectionDefinition.ui) == null ? void 0 : _b.router({
|
|
4861
|
+
document,
|
|
4862
|
+
collection: collectionDefinition
|
|
4863
|
+
}) : routeMapping ? routeMapping.mapper(collection, document) : void 0;
|
|
4845
4864
|
if (routeOverride) {
|
|
4846
4865
|
window.location.href = routeOverride;
|
|
4847
4866
|
return null;
|
|
@@ -4886,7 +4905,8 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4886
4905
|
const documents = collection.documents.edges;
|
|
4887
4906
|
const admin = cms.api.admin;
|
|
4888
4907
|
const pageInfo = collection.documents.pageInfo;
|
|
4889
|
-
const fields = (_a = collectionExtra.fields) == null ? void 0 : _a.filter((x) => ["string", "number", "datetime"].includes(x.type));
|
|
4908
|
+
const fields = (_a = collectionExtra.fields) == null ? void 0 : _a.filter((x) => ["string", "number", "datetime", "boolean"].includes(x.type));
|
|
4909
|
+
const collectionDefinition = cms.api.tina.schema.getCollection(collection.name);
|
|
4890
4910
|
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, {
|
|
4891
4911
|
filename: vars.relativePath,
|
|
4892
4912
|
deleteFunc: async () => {
|
|
@@ -4977,7 +4997,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4977
4997
|
}, /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
4978
4998
|
className: "text-blue-600 hover:text-blue-400 flex items-center gap-3 cursor-pointer",
|
|
4979
4999
|
onClick: () => {
|
|
4980
|
-
handleNavigate(navigate, cms, collection, document.node);
|
|
5000
|
+
handleNavigate(navigate, cms, collection, collectionDefinition, document.node);
|
|
4981
5001
|
}
|
|
4982
5002
|
}, /* @__PURE__ */ React__default["default"].createElement(BiEdit, {
|
|
4983
5003
|
className: "inline-block h-6 w-auto opacity-70"
|
|
@@ -93,6 +93,16 @@ export declare class Client {
|
|
|
93
93
|
}): Promise<{
|
|
94
94
|
assetsSyncing: string[];
|
|
95
95
|
}>;
|
|
96
|
+
fetchEvents(limit?: number, cursor?: string): Promise<{
|
|
97
|
+
events: {
|
|
98
|
+
message: string;
|
|
99
|
+
timestamp: number;
|
|
100
|
+
id: string;
|
|
101
|
+
isError: boolean;
|
|
102
|
+
isGlobal: boolean;
|
|
103
|
+
}[];
|
|
104
|
+
cursor?: string;
|
|
105
|
+
}>;
|
|
96
106
|
parseJwt(token: any): any;
|
|
97
107
|
getRefreshedToken(tokens: string): Promise<TokenObject>;
|
|
98
108
|
isAuthorized(): Promise<boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinacms",
|
|
3
|
-
"version": "0.69.
|
|
3
|
+
"version": "0.69.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "./dist/index.es.js",
|
|
6
6
|
"exports": {
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"@headlessui/react": "^1.5.0",
|
|
49
49
|
"@heroicons/react": "^1.0.4",
|
|
50
50
|
"@react-hook/window-size": "^3.0.7",
|
|
51
|
-
"@tinacms/schema-tools": "0.1.
|
|
51
|
+
"@tinacms/schema-tools": "0.1.1",
|
|
52
52
|
"@tinacms/sharedctx": "0.1.2",
|
|
53
|
-
"@tinacms/toolkit": "0.57.
|
|
53
|
+
"@tinacms/toolkit": "0.57.3",
|
|
54
54
|
"crypto-js": "^4.0.0",
|
|
55
55
|
"fetch-ponyfill": "^7.1.0",
|
|
56
56
|
"final-form": "4.20.1",
|