tinacms 0.68.14 → 0.69.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/dist/index.js CHANGED
@@ -1193,7 +1193,8 @@
1193
1193
  return formifyInlineFragmentNode({
1194
1194
  inlineFragmentNode: selectionNode,
1195
1195
  parentType: type,
1196
- path
1196
+ path,
1197
+ showInSidebar: true
1197
1198
  });
1198
1199
  }
1199
1200
  case "Field": {
@@ -1263,7 +1264,8 @@
1263
1264
  return formifyInlineFragmentNode({
1264
1265
  inlineFragmentNode: selectionNode,
1265
1266
  parentType: field.type,
1266
- path: fieldPath
1267
+ path: fieldPath,
1268
+ showInSidebar: false
1267
1269
  });
1268
1270
  }
1269
1271
  default:
@@ -1277,7 +1279,8 @@
1277
1279
  const formifyInlineFragmentNode = ({
1278
1280
  inlineFragmentNode,
1279
1281
  parentType,
1280
- path
1282
+ path,
1283
+ showInSidebar
1281
1284
  }) => {
1282
1285
  const type = getSelectedUnionType(parentType, inlineFragmentNode);
1283
1286
  if (!type) {
@@ -1288,7 +1291,7 @@
1288
1291
  inlineFragmentNode,
1289
1292
  type,
1290
1293
  path,
1291
- showInSidebar: false
1294
+ showInSidebar
1292
1295
  });
1293
1296
  }
1294
1297
  return {
@@ -2501,10 +2504,10 @@ mutation addPendingDocumentMutation(
2501
2504
  }
2502
2505
  }`, { variables: { collection, relativePath } });
2503
2506
  }
2504
- async fetchCollection(collectionName, includeDocuments, after) {
2507
+ async fetchCollection(collectionName, includeDocuments, after, sortKey, order) {
2505
2508
  if (includeDocuments === true) {
2506
- const sort = this.schema.getIsTitleFieldName(collectionName);
2507
- const response = await this.api.request(`#graphql
2509
+ const sort = sortKey || this.schema.getIsTitleFieldName(collectionName);
2510
+ const response = order === "asc" ? await this.api.request(`#graphql
2508
2511
  query($collection: String!, $includeDocuments: Boolean!, $sort: String, $limit: Float, $after: String){
2509
2512
  collection(collection: $collection){
2510
2513
  name
@@ -2537,6 +2540,47 @@ mutation addPendingDocumentMutation(
2537
2540
  }
2538
2541
  }
2539
2542
  }
2543
+ }`, {
2544
+ variables: {
2545
+ collection: collectionName,
2546
+ includeDocuments,
2547
+ sort,
2548
+ limit: 10,
2549
+ after
2550
+ }
2551
+ }) : await this.api.request(`#graphql
2552
+ query($collection: String!, $includeDocuments: Boolean!, $sort: String, $limit: Float, $after: String){
2553
+ collection(collection: $collection){
2554
+ name
2555
+ label
2556
+ format
2557
+ templates
2558
+ documents(sort: $sort, before: $after, last: $limit) @include(if: $includeDocuments) {
2559
+ totalCount
2560
+ pageInfo {
2561
+ hasPreviousPage
2562
+ hasNextPage
2563
+ startCursor
2564
+ endCursor
2565
+ }
2566
+ edges {
2567
+ node {
2568
+ ... on Document {
2569
+ _sys {
2570
+ title
2571
+ template
2572
+ breadcrumbs
2573
+ path
2574
+ basename
2575
+ relativePath
2576
+ filename
2577
+ extension
2578
+ }
2579
+ }
2580
+ }
2581
+ }
2582
+ }
2583
+ }
2540
2584
  }`, {
2541
2585
  variables: {
2542
2586
  collection: collectionName,
@@ -3298,6 +3342,9 @@ mutation addPendingDocumentMutation(
3298
3342
  .tina-tailwind .gap-4 {
3299
3343
  gap: 16px;
3300
3344
  }
3345
+ .tina-tailwind .gap-2 {
3346
+ gap: 8px;
3347
+ }
3301
3348
  .tina-tailwind .gap-3 {
3302
3349
  gap: 12px;
3303
3350
  }
@@ -3316,6 +3363,9 @@ mutation addPendingDocumentMutation(
3316
3363
  .tina-tailwind .overflow-y-auto {
3317
3364
  overflow-y: auto;
3318
3365
  }
3366
+ .tina-tailwind .whitespace-normal {
3367
+ white-space: normal;
3368
+ }
3319
3369
  .tina-tailwind .whitespace-nowrap {
3320
3370
  white-space: nowrap;
3321
3371
  }
@@ -3437,8 +3487,8 @@ mutation addPendingDocumentMutation(
3437
3487
  .tina-tailwind .pb-4 {
3438
3488
  padding-bottom: 16px;
3439
3489
  }
3440
- .tina-tailwind .pt-18 {
3441
- padding-top: 72px;
3490
+ .tina-tailwind .pt-16 {
3491
+ padding-top: 64px;
3442
3492
  }
3443
3493
  .tina-tailwind .pt-3 {
3444
3494
  padding-top: 12px;
@@ -3482,6 +3532,9 @@ mutation addPendingDocumentMutation(
3482
3532
  .tina-tailwind .font-medium {
3483
3533
  font-weight: 500;
3484
3534
  }
3535
+ .tina-tailwind .font-semibold {
3536
+ font-weight: 600;
3537
+ }
3485
3538
  .tina-tailwind .uppercase {
3486
3539
  text-transform: uppercase;
3487
3540
  }
@@ -3984,16 +4037,18 @@ mutation addPendingDocumentMutation(
3984
4037
  ...props
3985
4038
  }) => {
3986
4039
  var _a;
3987
- 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);
3988
- const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
3989
- if (!apiURL && !validOldSetup) {
3990
- throw new Error(`Must provide apiUrl or a client to the TinaWrapper component`);
4040
+ if (props == null ? void 0 : props.apiURL) {
4041
+ console.warn("The apiURL prop is deprecated. Please see https://tina.io/blog/tina-v-0.68.14 for information on how to upgrade to the new API");
3991
4042
  }
4043
+ const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
3992
4044
  const { branch, clientId, isLocalClient } = apiURL ? parseURL(apiURL) : {
3993
4045
  branch: props.branch,
3994
4046
  clientId: props.clientId,
3995
- isLocalClient: props.isLocalClient
4047
+ isLocalClient: props == null ? void 0 : props.isLocalClient
3996
4048
  };
4049
+ if (typeof isLocalClient === "undefined" || !isLocalClient && (!branch || !clientId)) {
4050
+ throw new Error("Invalid setup. See https://tina.io/docs/tina-cloud/connecting-site/ for more information.");
4051
+ }
3997
4052
  if (!schema) {
3998
4053
  throw new Error("`schema` is required to be passed as a property to `TinaProvider`. You can learn more about this change here: https://github.com/tinacms/tinacms/pull/2823");
3999
4054
  }
@@ -4576,7 +4631,7 @@ This will work when developing locally but NOT when deployed to production.
4576
4631
  isLocalMode,
4577
4632
  children
4578
4633
  }) => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, isLocalMode && /* @__PURE__ */ React__default["default"].createElement(toolkit.LocalWarning, null), /* @__PURE__ */ React__default["default"].createElement("div", {
4579
- className: "bg-white pb-4 pt-18 border-b border-gray-200 px-12"
4634
+ className: "bg-white pb-4 pt-16 border-b border-gray-200 px-12"
4580
4635
  }, /* @__PURE__ */ React__default["default"].createElement("div", {
4581
4636
  className: "w-full mx-auto max-w-screen-xl"
4582
4637
  }, /* @__PURE__ */ React__default["default"].createElement("div", {
@@ -4703,8 +4758,10 @@ This will work when developing locally but NOT when deployed to production.
4703
4758
  fontWeight: "normal"
4704
4759
  }
4705
4760
  }, "Please wait, Tina is loading data..."))));
4706
- const useGetCollection = (cms, collectionName, includeDocuments = true, after = "") => {
4761
+ const useGetCollection = (cms, collectionName, includeDocuments = true, after = "", sortKey) => {
4707
4762
  const api = new TinaAdminApi(cms);
4763
+ const schema = cms.api.tina.schema;
4764
+ const collectionExtra = schema.getCollection(collectionName);
4708
4765
  const [collection, setCollection] = React.useState(void 0);
4709
4766
  const [loading, setLoading] = React.useState(true);
4710
4767
  const [error, setError] = React.useState(void 0);
@@ -4712,8 +4769,10 @@ This will work when developing locally but NOT when deployed to production.
4712
4769
  React.useEffect(() => {
4713
4770
  const fetchCollection = async () => {
4714
4771
  if (await api.isAuthenticated()) {
4772
+ const { name, order } = JSON.parse(sortKey || "{}");
4773
+ const validSortKey = collectionExtra.fields.map((x) => x.name).includes(name) ? name : void 0;
4715
4774
  try {
4716
- const collection2 = await api.fetchCollection(collectionName, includeDocuments, after);
4775
+ const collection2 = await api.fetchCollection(collectionName, includeDocuments, after, validSortKey, order);
4717
4776
  setCollection(collection2);
4718
4777
  } catch (error2) {
4719
4778
  cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`, 30 * 1e3);
@@ -4726,26 +4785,29 @@ This will work when developing locally but NOT when deployed to production.
4726
4785
  };
4727
4786
  setLoading(true);
4728
4787
  fetchCollection();
4729
- }, [cms, collectionName, resetState, after]);
4788
+ }, [cms, collectionName, resetState, after, sortKey]);
4730
4789
  const reFetchCollection = () => setResetSate((x) => x + 1);
4731
- return { collection, loading, error, reFetchCollection };
4790
+ return { collection, loading, error, reFetchCollection, collectionExtra };
4732
4791
  };
4733
4792
  const GetCollection = ({
4734
4793
  cms,
4735
4794
  collectionName,
4736
4795
  includeDocuments = true,
4737
4796
  startCursor,
4797
+ sortKey,
4738
4798
  children
4739
4799
  }) => {
4740
- const { collection, loading, error, reFetchCollection } = useGetCollection(cms, collectionName, includeDocuments, startCursor || "");
4800
+ const { collection, loading, error, reFetchCollection, collectionExtra } = useGetCollection(cms, collectionName, includeDocuments, startCursor || "", sortKey) || {};
4741
4801
  if (error) {
4742
4802
  return null;
4743
4803
  }
4744
4804
  if (loading) {
4745
4805
  return /* @__PURE__ */ React__default["default"].createElement(LoadingPage, null);
4746
4806
  }
4747
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collection, loading, reFetchCollection));
4807
+ return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collection, loading, reFetchCollection, collectionExtra));
4748
4808
  };
4809
+ const LOCAL_STORAGE_KEY = "tinacms.admin.collection.list.page";
4810
+ const isSSR = typeof window === "undefined";
4749
4811
  const TemplateMenu = ({ templates }) => {
4750
4812
  return /* @__PURE__ */ React__default["default"].createElement(react.Menu, {
4751
4813
  as: "div",
@@ -4794,8 +4856,17 @@ This will work when developing locally but NOT when deployed to production.
4794
4856
  });
4795
4857
  const [endCursor, setEndCursor] = React.useState("");
4796
4858
  const [prevCursors, setPrevCursors] = React.useState([]);
4859
+ const [sortKey, setSortKey] = React.useState(isSSR ? "" : window.localStorage.getItem(`${LOCAL_STORAGE_KEY}.${collectionName}`) || JSON.stringify({
4860
+ order: "asc",
4861
+ name: ""
4862
+ }));
4863
+ const [sortOrder, setSortOrder] = React.useState("asc");
4797
4864
  const loc = reactRouterDom.useLocation();
4798
4865
  React.useEffect(() => {
4866
+ setSortKey(window.localStorage.getItem(`${LOCAL_STORAGE_KEY}.${collectionName}`) || JSON.stringify({
4867
+ order: "asc",
4868
+ name: ""
4869
+ }));
4799
4870
  setEndCursor("");
4800
4871
  setPrevCursors([]);
4801
4872
  }, [loc]);
@@ -4804,13 +4875,15 @@ This will work when developing locally but NOT when deployed to production.
4804
4875
  cms,
4805
4876
  collectionName,
4806
4877
  includeDocuments: true,
4807
- startCursor: endCursor
4808
- }, (collection, _loading, reFetchCollection) => {
4878
+ startCursor: endCursor,
4879
+ sortKey
4880
+ }, (collection, _loading, reFetchCollection, collectionExtra) => {
4809
4881
  var _a, _b;
4810
4882
  const totalCount = collection.documents.totalCount;
4811
4883
  const documents = collection.documents.edges;
4812
4884
  const admin = cms.api.admin;
4813
4885
  const pageInfo = collection.documents.pageInfo;
4886
+ const fields = collectionExtra.fields.filter((x) => ["string", "number", "datetime"].includes(x.type));
4814
4887
  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, {
4815
4888
  filename: vars.relativePath,
4816
4889
  deleteFunc: async () => {
@@ -4827,9 +4900,56 @@ This will work when developing locally but NOT when deployed to production.
4827
4900
  close: () => setOpen(false)
4828
4901
  }), /* @__PURE__ */ React__default["default"].createElement(PageHeader, {
4829
4902
  isLocalMode: (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
4830
- }, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("h3", {
4903
+ }, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("div", {
4904
+ className: "flex flex-col gap-4"
4905
+ }, /* @__PURE__ */ React__default["default"].createElement("h3", {
4831
4906
  className: "font-sans text-2xl text-gray-700"
4832
- }, collection.label ? collection.label : collection.name), !collection.templates && /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
4907
+ }, collection.label ? collection.label : collection.name), fields.length > 0 && /* @__PURE__ */ React__default["default"].createElement("div", {
4908
+ className: "flex gap-2 items-center"
4909
+ }, /* @__PURE__ */ React__default["default"].createElement("label", {
4910
+ htmlFor: "sort",
4911
+ className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal"
4912
+ }, "Sort by"), /* @__PURE__ */ React__default["default"].createElement(toolkit.Select, {
4913
+ name: "sort",
4914
+ options: [
4915
+ {
4916
+ label: "Default",
4917
+ value: JSON.stringify({
4918
+ order: "asc",
4919
+ name: ""
4920
+ })
4921
+ },
4922
+ ...fields.map((x) => [
4923
+ {
4924
+ label: x.label + " (Ascending)",
4925
+ value: JSON.stringify({
4926
+ name: x.name,
4927
+ order: "asc"
4928
+ })
4929
+ },
4930
+ {
4931
+ label: x.label + " (Descending)",
4932
+ value: JSON.stringify({
4933
+ name: x.name,
4934
+ order: "desc"
4935
+ })
4936
+ }
4937
+ ]).flat()
4938
+ ],
4939
+ input: {
4940
+ id: "sort",
4941
+ name: "sort",
4942
+ value: sortKey,
4943
+ onChange: (e) => {
4944
+ const val = JSON.parse(e.target.value);
4945
+ setEndCursor("");
4946
+ setPrevCursors([]);
4947
+ window == null ? void 0 : window.localStorage.setItem(`${LOCAL_STORAGE_KEY}.${collectionName}`, e.target.value);
4948
+ setSortKey(e.target.value);
4949
+ setSortOrder(val.order);
4950
+ }
4951
+ }
4952
+ }))), !collection.templates && /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
4833
4953
  to: `new`,
4834
4954
  className: "icon-parent inline-flex items-center font-medium focus:outline-none focus:ring-2 focus:shadow-outline text-center rounded-full justify-center transition-all duration-150 ease-out shadow text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 text-sm h-10 px-6"
4835
4955
  }, "Create New", " ", /* @__PURE__ */ React__default["default"].createElement(BiPlus, {
@@ -4917,7 +5037,7 @@ This will work when developing locally but NOT when deployed to production.
4917
5037
  className: "pt-3"
4918
5038
  }, /* @__PURE__ */ React__default["default"].createElement(toolkit.CursorPaginator, {
4919
5039
  variant: "white",
4920
- hasNext: pageInfo == null ? void 0 : pageInfo.hasNextPage,
5040
+ hasNext: sortOrder === "asc" ? pageInfo == null ? void 0 : pageInfo.hasNextPage : pageInfo.hasPreviousPage,
4921
5041
  navigateNext: () => {
4922
5042
  const newState = [...prevCursors, endCursor];
4923
5043
  setPrevCursors(newState);
@@ -5255,9 +5375,9 @@ This will work when developing locally but NOT when deployed to production.
5255
5375
  return null;
5256
5376
  };
5257
5377
  const TinaAdmin = () => {
5258
- const isSSR = typeof window === "undefined";
5378
+ const isSSR2 = typeof window === "undefined";
5259
5379
  const { edit } = sharedctx.useEditState();
5260
- if (isSSR) {
5380
+ if (isSSR2) {
5261
5381
  return null;
5262
5382
  }
5263
5383
  if (!edit) {
@@ -74,6 +74,12 @@ declare type BaseComponents = {
74
74
  maybe_mdx?: {
75
75
  children: JSX.Element;
76
76
  };
77
+ html?: {
78
+ value: string;
79
+ };
80
+ html_inline?: {
81
+ value: string;
82
+ };
77
83
  component_missing?: {
78
84
  name: string;
79
85
  };
@@ -0,0 +1,221 @@
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, {
15
+ components,
16
+ key: index,
17
+ child
18
+ });
19
+ }));
20
+ };
21
+ const Leaf = (props) => {
22
+ if (props.bold) {
23
+ const { bold, ...rest } = props;
24
+ if (props.components.bold) {
25
+ const Component = props.components.bold;
26
+ return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
27
+ ...rest
28
+ }));
29
+ }
30
+ return /* @__PURE__ */ React.createElement("strong", null, /* @__PURE__ */ React.createElement(Leaf, {
31
+ ...rest
32
+ }));
33
+ }
34
+ if (props.italic) {
35
+ const { italic, ...rest } = props;
36
+ if (props.components.italic) {
37
+ const Component = props.components.italic;
38
+ return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
39
+ ...rest
40
+ }));
41
+ }
42
+ return /* @__PURE__ */ React.createElement("em", null, /* @__PURE__ */ React.createElement(Leaf, {
43
+ ...rest
44
+ }));
45
+ }
46
+ if (props.underline) {
47
+ const { underline, ...rest } = props;
48
+ if (props.components.underline) {
49
+ const Component = props.components.underline;
50
+ return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
51
+ ...rest
52
+ }));
53
+ }
54
+ return /* @__PURE__ */ React.createElement("u", null, /* @__PURE__ */ React.createElement(Leaf, {
55
+ ...rest
56
+ }));
57
+ }
58
+ if (props.strikethrough) {
59
+ const { strikethrough, ...rest } = props;
60
+ if (props.components.strikethrough) {
61
+ const Component = props.components.strikethrough;
62
+ return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
63
+ ...rest
64
+ }));
65
+ }
66
+ return /* @__PURE__ */ React.createElement("s", null, /* @__PURE__ */ React.createElement(Leaf, {
67
+ ...rest
68
+ }));
69
+ }
70
+ if (props.code) {
71
+ const { code, ...rest } = props;
72
+ if (props.components.code) {
73
+ const Component = props.components.code;
74
+ return /* @__PURE__ */ React.createElement(Component, null, /* @__PURE__ */ React.createElement(Leaf, {
75
+ ...rest
76
+ }));
77
+ }
78
+ return /* @__PURE__ */ React.createElement("code", null, /* @__PURE__ */ React.createElement(Leaf, {
79
+ ...rest
80
+ }));
81
+ }
82
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, props.text);
83
+ };
84
+ const MemoNode = (props) => {
85
+ const MNode = React.useMemo(() => /* @__PURE__ */ React.createElement(Node, {
86
+ ...props
87
+ }), [JSON.stringify(props)]);
88
+ return MNode;
89
+ };
90
+ const Node = ({ components, child }) => {
91
+ const { children, ...props } = child;
92
+ switch (child.type) {
93
+ case "h1":
94
+ case "h2":
95
+ case "h3":
96
+ case "h4":
97
+ case "h5":
98
+ case "h6":
99
+ case "p":
100
+ case "blockquote":
101
+ case "ol":
102
+ case "ul":
103
+ case "li":
104
+ if (components[child.type]) {
105
+ const Component2 = components[child.type];
106
+ return /* @__PURE__ */ React.createElement(Component2, {
107
+ ...props
108
+ }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
109
+ components,
110
+ content: children
111
+ }));
112
+ }
113
+ return React.createElement(child.type, {
114
+ children: /* @__PURE__ */ React.createElement(TinaMarkdown, {
115
+ components,
116
+ content: children
117
+ })
118
+ });
119
+ case "lic":
120
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(TinaMarkdown, {
121
+ components,
122
+ content: child.children
123
+ }));
124
+ case "img":
125
+ if (components[child.type]) {
126
+ const Component2 = components[child.type];
127
+ return /* @__PURE__ */ React.createElement(Component2, {
128
+ ...props
129
+ });
130
+ }
131
+ return /* @__PURE__ */ React.createElement("img", {
132
+ src: child.url,
133
+ alt: child.caption
134
+ });
135
+ case "a":
136
+ if (components[child.type]) {
137
+ const Component2 = components[child.type];
138
+ return /* @__PURE__ */ React.createElement(Component2, {
139
+ ...props
140
+ }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
141
+ components,
142
+ content: children
143
+ }));
144
+ }
145
+ return /* @__PURE__ */ React.createElement("a", {
146
+ href: child.url
147
+ }, /* @__PURE__ */ React.createElement(TinaMarkdown, {
148
+ components,
149
+ content: children
150
+ }));
151
+ case "code_block":
152
+ const value = child.value;
153
+ if (components[child.type]) {
154
+ const Component2 = components[child.type];
155
+ return /* @__PURE__ */ React.createElement(Component2, {
156
+ ...props
157
+ }, value);
158
+ }
159
+ return /* @__PURE__ */ React.createElement("pre", null, /* @__PURE__ */ React.createElement("code", null, value));
160
+ case "hr":
161
+ if (components[child.type]) {
162
+ const Component2 = components[child.type];
163
+ return /* @__PURE__ */ React.createElement(Component2, {
164
+ ...props
165
+ });
166
+ }
167
+ return /* @__PURE__ */ React.createElement("hr", null);
168
+ case "break":
169
+ if (components[child.type]) {
170
+ const Component2 = components[child.type];
171
+ return /* @__PURE__ */ React.createElement(Component2, {
172
+ ...props
173
+ });
174
+ }
175
+ return /* @__PURE__ */ React.createElement("br", null);
176
+ case "text":
177
+ return /* @__PURE__ */ React.createElement(Leaf, {
178
+ components,
179
+ ...child
180
+ });
181
+ case "mdxJsxTextElement":
182
+ case "mdxJsxFlowElement":
183
+ const Component = components[child.name];
184
+ if (Component) {
185
+ const props2 = child.props ? child.props : {};
186
+ return /* @__PURE__ */ React.createElement(Component, {
187
+ ...props2
188
+ });
189
+ } else {
190
+ const ComponentMissing = components["component_missing"];
191
+ if (ComponentMissing) {
192
+ return /* @__PURE__ */ React.createElement(ComponentMissing, {
193
+ name: child.name
194
+ });
195
+ } else {
196
+ return /* @__PURE__ */ React.createElement("span", null, `No component provided for ${child.name}`);
197
+ }
198
+ }
199
+ case "maybe_mdx":
200
+ return null;
201
+ case "html":
202
+ case "html_inline":
203
+ if (components[child.type]) {
204
+ const Component2 = components[child.type];
205
+ return /* @__PURE__ */ React.createElement(Component2, {
206
+ ...props
207
+ });
208
+ }
209
+ return child.value;
210
+ case "invalid_markdown":
211
+ return /* @__PURE__ */ React.createElement("pre", null, child.value);
212
+ default:
213
+ if (typeof child.text === "string") {
214
+ return /* @__PURE__ */ React.createElement(Leaf, {
215
+ components,
216
+ ...child
217
+ });
218
+ }
219
+ }
220
+ };
221
+ export { TinaMarkdown };