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
@@ -1,63 +0,0 @@
1
- const makeCacheDir = async (dir, fs, path, os) => {
2
- const pathParts = dir.split(path.sep).filter(Boolean);
3
- const cacheHash = pathParts[pathParts.length - 1];
4
- const rootUser = pathParts[0];
5
- let cacheDir = dir;
6
- if (!fs.existsSync(path.join(path.sep, rootUser))) {
7
- cacheDir = path.join(os.tmpdir(), cacheHash);
8
- }
9
- try {
10
- fs.mkdirSync(cacheDir, { recursive: true });
11
- } catch (error) {
12
- throw new Error(`Failed to create cache directory: ${error.message}`);
13
- }
14
- return cacheDir;
15
- };
16
- const NodeCache = async (dir) => {
17
- const fs = require("node:fs");
18
- const path = require("node:path");
19
- const os = require("node:os");
20
- const { createHash } = require("node:crypto");
21
- const cacheDir = await makeCacheDir(dir, fs, path, os);
22
- return {
23
- makeKey: (key) => {
24
- const input = key && key instanceof Object ? JSON.stringify(key) : key || "";
25
- return createHash("sha256").update(input).digest("hex");
26
- },
27
- get: async (key) => {
28
- let readValue;
29
- const cacheFilename = `${cacheDir}/${key}`;
30
- try {
31
- const data = await fs.promises.readFile(cacheFilename, "utf-8");
32
- readValue = JSON.parse(data);
33
- } catch (e) {
34
- if (e.code !== "ENOENT") {
35
- console.error(
36
- `Failed to read cache file to ${cacheFilename}: ${e.message}`
37
- );
38
- }
39
- }
40
- return readValue;
41
- },
42
- set: async (key, value) => {
43
- const cacheFilename = `${cacheDir}/${key}`;
44
- try {
45
- await fs.promises.writeFile(cacheFilename, JSON.stringify(value), {
46
- encoding: "utf-8",
47
- flag: "wx"
48
- // Don't overwrite existing caches
49
- });
50
- } catch (e) {
51
- if (e.code !== "EEXIST") {
52
- console.error(
53
- `Failed to write cache file to ${cacheFilename}: ${e.message}`
54
- );
55
- }
56
- }
57
- }
58
- };
59
- };
60
- export {
61
- NodeCache,
62
- makeCacheDir
63
- };
package/dist/react.mjs DELETED
@@ -1,254 +0,0 @@
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"
26
- });
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]"
43
- );
44
- if (ancestor) {
45
- const attributeNames2 = ancestor.getAttributeNames();
46
- const tinaAttribute2 = attributeNames2.find(
47
- (name) => name.startsWith("data-tina-field")
48
- );
49
- if (tinaAttribute2) {
50
- e.preventDefault();
51
- e.stopPropagation();
52
- fieldName = ancestor.getAttribute(tinaAttribute2);
53
- }
54
- }
55
- }
56
- if (fieldName) {
57
- if (isInTinaIframe) {
58
- parent.postMessage(
59
- { type: "field:selected", fieldName },
60
- window.location.origin
61
- );
62
- }
63
- }
64
- };
65
- const style = document.createElement("style");
66
- style.type = "text/css";
67
- style.textContent = `
68
- [data-tina-field] {
69
- outline: 2px dashed rgba(34,150,254,0.5);
70
- transition: box-shadow ease-out 150ms;
71
- }
72
- [data-tina-field]:hover {
73
- box-shadow: inset 100vi 100vh rgba(34,150,254,0.3);
74
- outline: 2px solid rgba(34,150,254,1);
75
- cursor: pointer;
76
- }
77
- [data-tina-field-overlay] {
78
- outline: 2px dashed rgba(34,150,254,0.5);
79
- position: relative;
80
- }
81
- [data-tina-field-overlay]:hover {
82
- cursor: pointer;
83
- outline: 2px solid rgba(34,150,254,1);
84
- }
85
- [data-tina-field-overlay]::after {
86
- content: '';
87
- position: absolute;
88
- inset: 0;
89
- z-index: 20;
90
- transition: opacity ease-out 150ms;
91
- background-color: rgba(34,150,254,0.3);
92
- opacity: 0;
93
- }
94
- [data-tina-field-overlay]:hover::after {
95
- opacity: 1;
96
- }
97
- `;
98
- document.head.appendChild(style);
99
- document.body.classList.add("__tina-quick-editing-enabled");
100
- document.addEventListener("click", mouseDownHandler, true);
101
- return () => {
102
- document.removeEventListener("click", mouseDownHandler, true);
103
- document.body.classList.remove("__tina-quick-editing-enabled");
104
- style.remove();
105
- };
106
- }
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
- });
114
- }
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);
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
- });
165
- }
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;
187
- }
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);
211
- }
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
- };
@@ -1,256 +0,0 @@
1
- import React from "react";
2
- const TinaMarkdown = ({
3
- content,
4
- components = {}
5
- }) => {
6
- if (!content) {
7
- return null;
8
- }
9
- const nodes = Array.isArray(content) ? content : content.children;
10
- if (!nodes) {
11
- return null;
12
- }
13
- return /* @__PURE__ */ React.createElement(React.Fragment, null, nodes.map((child, index) => {
14
- return /* @__PURE__ */ React.createElement(MemoNode, { components, key: index, child });
15
- }));
16
- };
17
- const Leaf = (props) => {
18
- if (props.bold) {
19
- const { bold, ...rest } = props;
20
- if (props.components.bold) {
21
- const Component = props.components.bold;
22
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
23
- }
24
- return /* @__PURE__ */ React.createElement("strong", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
25
- }
26
- if (props.italic) {
27
- const { italic, ...rest } = props;
28
- if (props.components.italic) {
29
- const Component = props.components.italic;
30
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
31
- }
32
- return /* @__PURE__ */ React.createElement("em", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
33
- }
34
- if (props.underline) {
35
- const { underline, ...rest } = props;
36
- if (props.components.underline) {
37
- const Component = props.components.underline;
38
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
39
- }
40
- return /* @__PURE__ */ React.createElement("u", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
41
- }
42
- if (props.strikethrough) {
43
- const { strikethrough, ...rest } = props;
44
- if (props.components.strikethrough) {
45
- const Component = props.components.strikethrough;
46
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
47
- }
48
- return /* @__PURE__ */ React.createElement("s", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
49
- }
50
- if (props.code) {
51
- const { code, ...rest } = props;
52
- if (props.components.code) {
53
- const Component = props.components.code;
54
- return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
55
- }
56
- return /* @__PURE__ */ React.createElement("code", null, /* @__PURE__ */ React.createElement(Leaf, { ...rest }));
57
- }
58
- if (props.components.text) {
59
- const Component = props.components.text;
60
- return /* @__PURE__ */ React.createElement(Component, null, props.text);
61
- }
62
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.text);
63
- };
64
- const MemoNode = (props) => {
65
- const MNode = React.useMemo(
66
- () => /* @__PURE__ */ React.createElement(Node, { ...props }),
67
- [JSON.stringify(props)]
68
- );
69
- return MNode;
70
- };
71
- const Node = ({ components, child }) => {
72
- var _a, _b, _c, _d, _e, _f, _g;
73
- const { children, ...props } = child;
74
- switch (child.type) {
75
- case "h1":
76
- case "h2":
77
- case "h3":
78
- case "h4":
79
- case "h5":
80
- case "h6":
81
- case "p":
82
- case "ol":
83
- case "ul":
84
- case "li":
85
- if (components[child.type]) {
86
- const Component2 = components[child.type];
87
- return /* @__PURE__ */ React.createElement(Component2, { ...props }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }));
88
- }
89
- return React.createElement(child.type, {
90
- children: /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children })
91
- });
92
- case "lic":
93
- if (components.lic) {
94
- const Component2 = components.lic;
95
- return /* @__PURE__ */ React.createElement(Component2, { ...props }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }));
96
- }
97
- return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: child.children }));
98
- case "blockquote":
99
- const BlockquoteComponent = components.blockquote || components.block_quote;
100
- if (BlockquoteComponent) {
101
- return /* @__PURE__ */ React.createElement(BlockquoteComponent, { ...props }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }));
102
- }
103
- return React.createElement("blockquote", {
104
- children: /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children })
105
- });
106
- case "img":
107
- if (components[child.type]) {
108
- const Component2 = components[child.type];
109
- return /* @__PURE__ */ React.createElement(Component2, { ...props });
110
- }
111
- return /* @__PURE__ */ React.createElement("img", { src: child.url, alt: child.alt });
112
- case "a":
113
- if (components[child.type]) {
114
- const Component2 = components[child.type];
115
- return (
116
- // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types
117
- /* @__PURE__ */ React.createElement(Component2, { ...props }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }))
118
- );
119
- }
120
- return (
121
- // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types
122
- /* @__PURE__ */ React.createElement("a", { href: child.url }, /* @__PURE__ */ React.createElement(TinaMarkdown, { components, content: children }))
123
- );
124
- case "code_block": {
125
- let codeString = "";
126
- if (Array.isArray(child.children)) {
127
- codeString = child.children.map(
128
- (line) => Array.isArray(line.children) ? line.children.map((t) => t.text).join("") : ""
129
- ).join("\n");
130
- } else if (typeof child.value === "string") {
131
- codeString = child.value;
132
- }
133
- if (components[child.type]) {
134
- const Component2 = components[child.type];
135
- return (
136
- // @ts-ignore FIXME: TinaMarkdownContent needs to be a union of all possible node types
137
- /* @__PURE__ */ React.createElement(Component2, { ...props, value: codeString })
138
- );
139
- }
140
- return /* @__PURE__ */ React.createElement("pre", null, /* @__PURE__ */ React.createElement("code", null, codeString));
141
- }
142
- case "hr":
143
- if (components[child.type]) {
144
- const Component2 = components[child.type];
145
- return /* @__PURE__ */ React.createElement(Component2, { ...props });
146
- }
147
- return /* @__PURE__ */ React.createElement("hr", null);
148
- case "break":
149
- if (components[child.type]) {
150
- const Component2 = components[child.type];
151
- return /* @__PURE__ */ React.createElement(Component2, { ...props });
152
- }
153
- return /* @__PURE__ */ React.createElement("br", null);
154
- case "text":
155
- return /* @__PURE__ */ React.createElement(Leaf, { components, ...child });
156
- case "mdxJsxTextElement":
157
- case "mdxJsxFlowElement":
158
- const Component = components[child.name];
159
- if (Component) {
160
- const props2 = child.props ? child.props : {};
161
- return /* @__PURE__ */ React.createElement(Component, { ...props2 });
162
- } else {
163
- if (child.name === "table") {
164
- const firstRowHeader = (_a = child.props) == null ? void 0 : _a.firstRowHeader;
165
- const rows2 = (firstRowHeader ? (_b = child.props) == null ? void 0 : _b.tableRows.filter((_, i) => i !== 0) : (_c = child.props) == null ? void 0 : _c.tableRows) || [];
166
- const header = (_e = (_d = child.props) == null ? void 0 : _d.tableRows) == null ? void 0 : _e.at(0);
167
- const TableComponent2 = components["table"] || ((props2) => /* @__PURE__ */ React.createElement("table", { ...props2 }));
168
- const TrComponent2 = components["tr"] || ((props2) => /* @__PURE__ */ React.createElement("tr", { ...props2 }));
169
- const ThComponent = components["th"] || ((props2) => /* @__PURE__ */ React.createElement("th", { style: { textAlign: (props2 == null ? void 0 : props2.align) || "auto" }, ...props2 }));
170
- const TdComponent2 = components["td"] || ((props2) => /* @__PURE__ */ React.createElement("td", { style: { textAlign: (props2 == null ? void 0 : props2.align) || "auto" }, ...props2 }));
171
- const align2 = ((_f = child.props) == null ? void 0 : _f.align) || [];
172
- return /* @__PURE__ */ React.createElement(TableComponent2, null, firstRowHeader && /* @__PURE__ */ React.createElement("thead", null, /* @__PURE__ */ React.createElement(TrComponent2, null, header.tableCells.map((c, i) => {
173
- return /* @__PURE__ */ React.createElement(
174
- TinaMarkdown,
175
- {
176
- key: i,
177
- components: {
178
- p: (props2) => /* @__PURE__ */ React.createElement(ThComponent, { align: align2[i], ...props2 })
179
- },
180
- content: c.value
181
- }
182
- );
183
- }))), /* @__PURE__ */ React.createElement("tbody", null, rows2.map((row, i) => {
184
- var _a2;
185
- return /* @__PURE__ */ React.createElement(TrComponent2, { key: i }, (_a2 = row == null ? void 0 : row.tableCells) == null ? void 0 : _a2.map((c, i2) => {
186
- return /* @__PURE__ */ React.createElement(
187
- TinaMarkdown,
188
- {
189
- key: i2,
190
- components: {
191
- p: (props2) => /* @__PURE__ */ React.createElement(TdComponent2, { align: align2[i2], ...props2 })
192
- },
193
- content: c.value
194
- }
195
- );
196
- }));
197
- })));
198
- }
199
- const ComponentMissing = components["component_missing"];
200
- if (ComponentMissing) {
201
- return /* @__PURE__ */ React.createElement(ComponentMissing, { name: child.name });
202
- } else {
203
- return /* @__PURE__ */ React.createElement("span", null, `No component provided for ${child.name}`);
204
- }
205
- }
206
- case "table":
207
- const rows = child.children || [];
208
- const TableComponent = components["table"] || ((props2) => /* @__PURE__ */ React.createElement("table", { style: { border: "1px solid #EDECF3" }, ...props2 }));
209
- const TrComponent = components["tr"] || ((props2) => /* @__PURE__ */ React.createElement("tr", { ...props2 }));
210
- const TdComponent = components["td"] || ((props2) => /* @__PURE__ */ React.createElement(
211
- "td",
212
- {
213
- style: {
214
- textAlign: (props2 == null ? void 0 : props2.align) || "auto",
215
- border: "1px solid #EDECF3",
216
- padding: "0.25rem"
217
- },
218
- ...props2
219
- }
220
- ));
221
- const align = ((_g = child.props) == null ? void 0 : _g.align) || [];
222
- return /* @__PURE__ */ React.createElement(TableComponent, null, /* @__PURE__ */ React.createElement("tbody", null, rows.map((row, i) => {
223
- var _a2;
224
- return /* @__PURE__ */ React.createElement(TrComponent, { key: i }, (_a2 = row.children) == null ? void 0 : _a2.map((cell, i2) => {
225
- return /* @__PURE__ */ React.createElement(
226
- TinaMarkdown,
227
- {
228
- key: i2,
229
- components: {
230
- p: (props2) => /* @__PURE__ */ React.createElement(TdComponent, { align: align[i2], ...props2 })
231
- },
232
- content: cell.children
233
- }
234
- );
235
- }));
236
- })));
237
- case "maybe_mdx":
238
- return null;
239
- case "html":
240
- case "html_inline":
241
- if (components[child.type]) {
242
- const Component2 = components[child.type];
243
- return /* @__PURE__ */ React.createElement(Component2, { ...props });
244
- }
245
- return child.value;
246
- case "invalid_markdown":
247
- return /* @__PURE__ */ React.createElement("pre", null, child.value);
248
- default:
249
- if (typeof child.text === "string") {
250
- return /* @__PURE__ */ React.createElement(Leaf, { components, ...child });
251
- }
252
- }
253
- };
254
- export {
255
- TinaMarkdown
256
- };
@@ -1,16 +0,0 @@
1
- import React from "react";
2
- import { Highlight, themes } from "prism-react-renderer";
3
- const Prism = (props) => {
4
- return /* @__PURE__ */ React.createElement(
5
- Highlight,
6
- {
7
- theme: themes[props.theme || "github"],
8
- code: props.value || "",
9
- language: props.lang || ""
10
- },
11
- ({ className, style, tokens, getLineProps, getTokenProps }) => /* @__PURE__ */ React.createElement("pre", { className, style }, tokens.map((line, i) => /* @__PURE__ */ React.createElement("div", { ...getLineProps({ line, key: i }) }, line.map((token, key) => /* @__PURE__ */ React.createElement("span", { ...getTokenProps({ token, key }) })))))
12
- );
13
- };
14
- export {
15
- Prism
16
- };