tinacms 0.0.0-e1b6d05-20251114052813 → 0.0.0-e2db315-20251216223244

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.
Files changed (65) hide show
  1. package/dist/admin/api.d.ts +1 -1
  2. package/dist/cache/node-cache.d.ts +6 -2
  3. package/dist/client.js +240 -181
  4. package/dist/index.js +118150 -117527
  5. package/dist/internalClient/index.d.ts +1 -1
  6. package/dist/react.js +210 -213
  7. package/dist/rich-text/index.js +234 -237
  8. package/dist/rich-text/prism.js +16 -18
  9. package/dist/rich-text/static.js +229 -232
  10. package/dist/toolkit/components/ui/button.d.ts +11 -0
  11. package/dist/toolkit/components/ui/calendar.d.ts +8 -0
  12. package/dist/toolkit/components/ui/date-time-picker.d.ts +111 -0
  13. package/dist/toolkit/components/ui/input.d.ts +3 -0
  14. package/dist/toolkit/components/ui/popover.d.ts +7 -0
  15. package/dist/toolkit/components/ui/select.d.ts +13 -0
  16. package/dist/toolkit/fields/components/color-picker/block-widget.d.ts +3 -0
  17. package/dist/toolkit/fields/components/color-picker/color-input.d.ts +35 -0
  18. package/dist/toolkit/fields/components/color-picker/color-picker.d.ts +6 -2
  19. package/dist/toolkit/fields/components/color-picker/color-utils.d.ts +37 -0
  20. package/dist/toolkit/fields/components/color-picker/sketch-widget.d.ts +3 -0
  21. package/dist/toolkit/fields/components/select.d.ts +1 -1
  22. package/dist/toolkit/fields/plugins/button-toggle-field-plugin.d.ts +2 -2
  23. package/dist/toolkit/fields/plugins/checkbox-group-field-plugin.d.ts +2 -2
  24. package/dist/toolkit/fields/plugins/color-field-plugin.d.ts +1 -0
  25. package/dist/toolkit/fields/plugins/date-field-plugin.d.ts +0 -2
  26. package/dist/toolkit/fields/plugins/dnd-kit-wrapper.d.ts +49 -0
  27. package/dist/toolkit/fields/plugins/group-list-field-plugin.d.ts +2 -1
  28. package/dist/toolkit/fields/plugins/list-field-plugin.d.ts +2 -0
  29. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/editor.d.ts +2 -2
  30. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/blockquote-element.d.ts +1 -1
  31. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/button.d.ts +2 -2
  32. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/code-block-element.d.ts +1 -1
  33. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-line-element.d.ts +1 -1
  34. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/command.d.ts +7 -7
  35. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/list-element.d.ts +2 -2
  36. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/paragraph-element.d.ts +1 -1
  37. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/slash-input-element.d.ts +1 -1
  38. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-cell-element.d.ts +2 -2
  39. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-element.d.ts +1 -1
  40. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-row-element.d.ts +1 -1
  41. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-hook.d.ts +1 -1
  42. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +18 -18
  43. package/dist/toolkit/fields/plugins/radio-group-field-plugin.d.ts +2 -2
  44. package/dist/toolkit/fields/plugins/select-field-plugin.d.ts +2 -2
  45. package/dist/toolkit/fields/plugins/toggle-field-plugin.d.ts +2 -2
  46. package/dist/toolkit/index.d.ts +1 -1
  47. package/dist/toolkit/react-sidebar/components/NavMenuTrigger.d.ts +11 -0
  48. package/dist/toolkit/react-sidebar/components/badge.d.ts +2 -1
  49. package/dist/toolkit/react-sidebar/components/nav-components.d.ts +11 -0
  50. package/dist/toolkit/react-sidebar/components/nav-context.d.ts +15 -0
  51. package/dist/toolkit/react-sidebar/components/nav.d.ts +3 -3
  52. package/dist/toolkit/react-sidebar/components/sidebar-body.d.ts +26 -1
  53. package/dist/toolkit/react-sidebar/index.d.ts +3 -0
  54. package/dist/unifiedClient/index.d.ts +1 -1
  55. package/dist/utils/index.d.ts +1 -0
  56. package/package.json +33 -70
  57. package/dist/client.mjs +0 -132
  58. package/dist/index.mjs +0 -122905
  59. package/dist/node-cache-5e8db9f0.mjs +0 -63
  60. package/dist/react.mjs +0 -254
  61. package/dist/rich-text/index.mjs +0 -256
  62. package/dist/rich-text/prism.mjs +0 -16
  63. package/dist/rich-text/static.mjs +0 -243
  64. package/dist/toolkit/react-datetime/DateTime.d.ts +0 -135
  65. /package/dist/admin/components/{Sidebar.d.ts → AdminNav.d.ts} +0 -0
@@ -2,7 +2,7 @@ import { BranchData, EventBus } from '@tinacms/toolkit';
2
2
  import { DocumentNode, GraphQLSchema } from 'graphql';
3
3
  import { TokenObject } from '../auth/authenticate';
4
4
  import { AuthProvider, Schema, TinaSchema } from '@tinacms/schema-tools';
5
- import { SearchClient } from '@tinacms/search/dist/index-client';
5
+ import { SearchClient } from '@tinacms/search/index-client';
6
6
  import gql from 'graphql-tag';
7
7
  import { TinaCloudProject } from './types';
8
8
  export * from './authProvider';
package/dist/react.js CHANGED
@@ -1,73 +1,70 @@
1
- (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP));
3
- })(this, function(exports2, React) {
4
- "use strict";
5
- function useTina(props) {
6
- const stringifiedQuery = JSON.stringify({
7
- query: props.query,
8
- variables: props.variables
1
+ import React from "react";
2
+ function useTina(props) {
3
+ const stringifiedQuery = JSON.stringify({
4
+ query: props.query,
5
+ variables: props.variables
6
+ });
7
+ const id = React.useMemo(
8
+ () => hashFromQuery(stringifiedQuery),
9
+ [stringifiedQuery]
10
+ );
11
+ const processedData = React.useMemo(() => {
12
+ if (props.data) {
13
+ const dataCopy = JSON.parse(JSON.stringify(props.data));
14
+ return addMetadata(id, dataCopy, []);
15
+ }
16
+ }, [props.data, id]);
17
+ const [data, setData] = React.useState(processedData);
18
+ const [isClient, setIsClient] = React.useState(false);
19
+ const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);
20
+ const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);
21
+ React.useEffect(() => {
22
+ setIsClient(true);
23
+ setData(processedData);
24
+ parent.postMessage({
25
+ type: "url-changed"
9
26
  });
10
- const id = React.useMemo(
11
- () => hashFromQuery(stringifiedQuery),
12
- [stringifiedQuery]
13
- );
14
- const processedData = React.useMemo(() => {
15
- if (props.data) {
16
- const dataCopy = JSON.parse(JSON.stringify(props.data));
17
- return addMetadata(id, dataCopy, []);
18
- }
19
- }, [props.data, id]);
20
- const [data, setData] = React.useState(processedData);
21
- const [isClient, setIsClient] = React.useState(false);
22
- const [quickEditEnabled, setQuickEditEnabled] = React.useState(false);
23
- const [isInTinaIframe, setIsInTinaIframe] = React.useState(false);
24
- React.useEffect(() => {
25
- setIsClient(true);
26
- setData(processedData);
27
- parent.postMessage({
28
- type: "url-changed"
29
- });
30
- }, [id, processedData]);
31
- React.useEffect(() => {
32
- if (quickEditEnabled) {
33
- let mouseDownHandler = function(e) {
34
- const attributeNames = e.target.getAttributeNames();
35
- const tinaAttribute = attributeNames.find(
36
- (name) => name.startsWith("data-tina-field")
27
+ }, [id, processedData]);
28
+ React.useEffect(() => {
29
+ if (quickEditEnabled) {
30
+ let mouseDownHandler = function(e) {
31
+ const attributeNames = e.target.getAttributeNames();
32
+ const tinaAttribute = attributeNames.find(
33
+ (name) => name.startsWith("data-tina-field")
34
+ );
35
+ let fieldName;
36
+ if (tinaAttribute) {
37
+ e.preventDefault();
38
+ e.stopPropagation();
39
+ fieldName = e.target.getAttribute(tinaAttribute);
40
+ } else {
41
+ const ancestor = e.target.closest(
42
+ "[data-tina-field], [data-tina-field-overlay]"
37
43
  );
38
- let fieldName;
39
- if (tinaAttribute) {
40
- e.preventDefault();
41
- e.stopPropagation();
42
- fieldName = e.target.getAttribute(tinaAttribute);
43
- } else {
44
- const ancestor = e.target.closest(
45
- "[data-tina-field], [data-tina-field-overlay]"
44
+ if (ancestor) {
45
+ const attributeNames2 = ancestor.getAttributeNames();
46
+ const tinaAttribute2 = attributeNames2.find(
47
+ (name) => name.startsWith("data-tina-field")
46
48
  );
47
- if (ancestor) {
48
- const attributeNames2 = ancestor.getAttributeNames();
49
- const tinaAttribute2 = attributeNames2.find(
50
- (name) => name.startsWith("data-tina-field")
51
- );
52
- if (tinaAttribute2) {
53
- e.preventDefault();
54
- e.stopPropagation();
55
- fieldName = ancestor.getAttribute(tinaAttribute2);
56
- }
49
+ if (tinaAttribute2) {
50
+ e.preventDefault();
51
+ e.stopPropagation();
52
+ fieldName = ancestor.getAttribute(tinaAttribute2);
57
53
  }
58
54
  }
59
- if (fieldName) {
60
- if (isInTinaIframe) {
61
- parent.postMessage(
62
- { type: "field:selected", fieldName },
63
- window.location.origin
64
- );
65
- }
55
+ }
56
+ if (fieldName) {
57
+ if (isInTinaIframe) {
58
+ parent.postMessage(
59
+ { type: "field:selected", fieldName },
60
+ window.location.origin
61
+ );
66
62
  }
67
- };
68
- const style = document.createElement("style");
69
- style.type = "text/css";
70
- style.textContent = `
63
+ }
64
+ };
65
+ const style = document.createElement("style");
66
+ style.type = "text/css";
67
+ style.textContent = `
71
68
  [data-tina-field] {
72
69
  outline: 2px dashed rgba(34,150,254,0.5);
73
70
  transition: box-shadow ease-out 150ms;
@@ -98,160 +95,160 @@
98
95
  opacity: 1;
99
96
  }
100
97
  `;
101
- document.head.appendChild(style);
102
- document.body.classList.add("__tina-quick-editing-enabled");
103
- document.addEventListener("click", mouseDownHandler, true);
104
- return () => {
105
- document.removeEventListener("click", mouseDownHandler, true);
106
- document.body.classList.remove("__tina-quick-editing-enabled");
107
- style.remove();
108
- };
109
- }
110
- }, [quickEditEnabled, isInTinaIframe]);
111
- React.useEffect(() => {
112
- if (props == null ? void 0 : props.experimental___selectFormByFormId) {
113
- parent.postMessage({
114
- type: "user-select-form",
115
- formId: props.experimental___selectFormByFormId()
116
- });
117
- }
118
- }, [id]);
119
- React.useEffect(() => {
120
- const { experimental___selectFormByFormId, ...rest } = props;
121
- parent.postMessage({ type: "open", ...rest, id }, window.location.origin);
122
- const handleMessage = (event) => {
123
- if (event.data.type === "quickEditEnabled") {
124
- setQuickEditEnabled(event.data.value);
125
- }
126
- if (event.data.id === id && event.data.type === "updateData") {
127
- const rawData = event.data.data;
128
- const newlyProcessedData = addMetadata(
129
- id,
130
- JSON.parse(JSON.stringify(rawData)),
131
- []
132
- );
133
- setData(newlyProcessedData);
134
- setIsInTinaIframe(true);
135
- const anyTinaField = document.querySelector("[data-tina-field]");
136
- if (anyTinaField) {
137
- parent.postMessage(
138
- { type: "quick-edit", value: true },
139
- window.location.origin
140
- );
141
- } else {
142
- parent.postMessage(
143
- { type: "quick-edit", value: false },
144
- window.location.origin
145
- );
146
- }
147
- }
148
- };
149
- window.addEventListener("message", handleMessage);
98
+ document.head.appendChild(style);
99
+ document.body.classList.add("__tina-quick-editing-enabled");
100
+ document.addEventListener("click", mouseDownHandler, true);
150
101
  return () => {
151
- window.removeEventListener("message", handleMessage);
152
- parent.postMessage({ type: "close", id }, window.location.origin);
102
+ document.removeEventListener("click", mouseDownHandler, true);
103
+ document.body.classList.remove("__tina-quick-editing-enabled");
104
+ style.remove();
153
105
  };
154
- }, [id, setQuickEditEnabled]);
155
- return { data, isClient };
156
- }
157
- function useEditState() {
158
- const [edit, setEdit] = React.useState(false);
159
- React.useEffect(() => {
160
- if (typeof window !== "undefined") {
161
- parent.postMessage({ type: "isEditMode" }, window.location.origin);
162
- window.addEventListener("message", (event) => {
163
- var _a;
164
- if (((_a = event.data) == null ? void 0 : _a.type) === "tina:editMode") {
165
- setEdit(true);
166
- }
167
- });
168
- }
169
- }, []);
170
- return { edit };
171
- }
172
- const tinaField = (object, property, index) => {
173
- const contentSource = object == null ? void 0 : object._content_source;
174
- if (!contentSource) {
175
- return "";
176
- }
177
- const { queryId, path } = contentSource;
178
- if (!property) {
179
- return `${queryId}---${path.join(".")}`;
180
- }
181
- const fullPath = typeof index === "number" ? [...path, property, index] : [...path, property];
182
- return `${queryId}---${fullPath.join(".")}`;
183
- };
184
- const addMetadata = (id, obj, path = []) => {
185
- if (obj === null) {
186
- return obj;
187
- }
188
- if (isScalarOrUndefined(obj)) {
189
- return obj;
190
- }
191
- if (obj instanceof String) {
192
- return obj.valueOf();
193
106
  }
194
- if (Array.isArray(obj)) {
195
- return obj.map(
196
- (item, index) => addMetadata(id, item, [...path, index])
197
- );
107
+ }, [quickEditEnabled, isInTinaIframe]);
108
+ React.useEffect(() => {
109
+ if (props == null ? void 0 : props.experimental___selectFormByFormId) {
110
+ parent.postMessage({
111
+ type: "user-select-form",
112
+ formId: props.experimental___selectFormByFormId()
113
+ });
198
114
  }
199
- const transformedObj = {};
200
- for (const [key, value] of Object.entries(obj)) {
201
- const currentPath = [...path, key];
202
- if ([
203
- "__typename",
204
- "_sys",
205
- "_internalSys",
206
- "_values",
207
- "_internalValues",
208
- "_content_source",
209
- "_tina_metadata"
210
- ].includes(key)) {
211
- transformedObj[key] = value;
212
- } else {
213
- transformedObj[key] = addMetadata(id, value, currentPath);
115
+ }, [id]);
116
+ React.useEffect(() => {
117
+ const { experimental___selectFormByFormId, ...rest } = props;
118
+ parent.postMessage({ type: "open", ...rest, id }, window.location.origin);
119
+ const handleMessage = (event) => {
120
+ if (event.data.type === "quickEditEnabled") {
121
+ setQuickEditEnabled(event.data.value);
214
122
  }
123
+ if (event.data.id === id && event.data.type === "updateData") {
124
+ const rawData = event.data.data;
125
+ const newlyProcessedData = addMetadata(
126
+ id,
127
+ JSON.parse(JSON.stringify(rawData)),
128
+ []
129
+ );
130
+ setData(newlyProcessedData);
131
+ setIsInTinaIframe(true);
132
+ const anyTinaField = document.querySelector("[data-tina-field]");
133
+ if (anyTinaField) {
134
+ parent.postMessage(
135
+ { type: "quick-edit", value: true },
136
+ window.location.origin
137
+ );
138
+ } else {
139
+ parent.postMessage(
140
+ { type: "quick-edit", value: false },
141
+ window.location.origin
142
+ );
143
+ }
144
+ }
145
+ };
146
+ window.addEventListener("message", handleMessage);
147
+ return () => {
148
+ window.removeEventListener("message", handleMessage);
149
+ parent.postMessage({ type: "close", id }, window.location.origin);
150
+ };
151
+ }, [id, setQuickEditEnabled]);
152
+ return { data, isClient };
153
+ }
154
+ function useEditState() {
155
+ const [edit, setEdit] = React.useState(false);
156
+ React.useEffect(() => {
157
+ if (typeof window !== "undefined") {
158
+ parent.postMessage({ type: "isEditMode" }, window.location.origin);
159
+ window.addEventListener("message", (event) => {
160
+ var _a;
161
+ if (((_a = event.data) == null ? void 0 : _a.type) === "tina:editMode") {
162
+ setEdit(true);
163
+ }
164
+ });
215
165
  }
216
- if (transformedObj && typeof transformedObj === "object" && "type" in transformedObj && transformedObj.type === "root") {
217
- return transformedObj;
218
- }
219
- return { ...transformedObj, _content_source: { queryId: id, path } };
220
- };
221
- function isScalarOrUndefined(value) {
222
- const type = typeof value;
223
- if (type === "string")
224
- return true;
225
- if (type === "number")
226
- return true;
227
- if (type === "boolean")
228
- return true;
229
- if (type === "undefined")
230
- return true;
231
- if (value == null)
232
- return true;
233
- if (value instanceof String)
234
- return true;
235
- if (value instanceof Number)
236
- return true;
237
- if (value instanceof Boolean)
238
- return true;
239
- return false;
166
+ }, []);
167
+ return { edit };
168
+ }
169
+ const tinaField = (object, property, index) => {
170
+ const contentSource = object == null ? void 0 : object._content_source;
171
+ if (!contentSource) {
172
+ return "";
173
+ }
174
+ const { queryId, path } = contentSource;
175
+ if (!property) {
176
+ return `${queryId}---${path.join(".")}`;
177
+ }
178
+ const fullPath = typeof index === "number" ? [...path, property, index] : [...path, property];
179
+ return `${queryId}---${fullPath.join(".")}`;
180
+ };
181
+ const addMetadata = (id, obj, path = []) => {
182
+ if (obj === null) {
183
+ return obj;
184
+ }
185
+ if (isScalarOrUndefined(obj)) {
186
+ return obj;
240
187
  }
241
- const hashFromQuery = (input) => {
242
- let hash = 0;
243
- for (let i = 0; i < input.length; i++) {
244
- const char = input.charCodeAt(i);
245
- hash = (hash << 5) - hash + char & 4294967295;
188
+ if (obj instanceof String) {
189
+ return obj.valueOf();
190
+ }
191
+ if (Array.isArray(obj)) {
192
+ return obj.map(
193
+ (item, index) => addMetadata(id, item, [...path, index])
194
+ );
195
+ }
196
+ const transformedObj = {};
197
+ for (const [key, value] of Object.entries(obj)) {
198
+ const currentPath = [...path, key];
199
+ if ([
200
+ "__typename",
201
+ "_sys",
202
+ "_internalSys",
203
+ "_values",
204
+ "_internalValues",
205
+ "_content_source",
206
+ "_tina_metadata"
207
+ ].includes(key)) {
208
+ transformedObj[key] = value;
209
+ } else {
210
+ transformedObj[key] = addMetadata(id, value, currentPath);
246
211
  }
247
- const nonNegativeHash = Math.abs(hash);
248
- const alphanumericHash = nonNegativeHash.toString(36);
249
- return alphanumericHash;
250
- };
251
- exports2.addMetadata = addMetadata;
252
- exports2.hashFromQuery = hashFromQuery;
253
- exports2.tinaField = tinaField;
254
- exports2.useEditState = useEditState;
255
- exports2.useTina = useTina;
256
- Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
257
- });
212
+ }
213
+ if (transformedObj && typeof transformedObj === "object" && "type" in transformedObj && transformedObj.type === "root") {
214
+ return transformedObj;
215
+ }
216
+ return { ...transformedObj, _content_source: { queryId: id, path } };
217
+ };
218
+ function isScalarOrUndefined(value) {
219
+ const type = typeof value;
220
+ if (type === "string")
221
+ return true;
222
+ if (type === "number")
223
+ return true;
224
+ if (type === "boolean")
225
+ return true;
226
+ if (type === "undefined")
227
+ return true;
228
+ if (value == null)
229
+ return true;
230
+ if (value instanceof String)
231
+ return true;
232
+ if (value instanceof Number)
233
+ return true;
234
+ if (value instanceof Boolean)
235
+ return true;
236
+ return false;
237
+ }
238
+ const hashFromQuery = (input) => {
239
+ let hash = 0;
240
+ for (let i = 0; i < input.length; i++) {
241
+ const char = input.charCodeAt(i);
242
+ hash = (hash << 5) - hash + char & 4294967295;
243
+ }
244
+ const nonNegativeHash = Math.abs(hash);
245
+ const alphanumericHash = nonNegativeHash.toString(36);
246
+ return alphanumericHash;
247
+ };
248
+ export {
249
+ addMetadata,
250
+ hashFromQuery,
251
+ tinaField,
252
+ useEditState,
253
+ useTina
254
+ };