tinacms 2.2.7 → 2.2.9

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/client.js CHANGED
@@ -26,7 +26,7 @@
26
26
  return;
27
27
  }
28
28
  try {
29
- if (this.cacheDir && window === void 0 && typeof require !== "undefined") {
29
+ if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
30
30
  const { NodeCache: NodeCache2 } = await Promise.resolve().then(() => nodeCache);
31
31
  this.cache = await NodeCache2(this.cacheDir);
32
32
  }
package/dist/client.mjs CHANGED
@@ -23,7 +23,7 @@ class TinaClient {
23
23
  return;
24
24
  }
25
25
  try {
26
- if (this.cacheDir && window === void 0 && typeof require !== "undefined") {
26
+ if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
27
27
  const { NodeCache } = await import("./node-cache-7fa2452c.mjs");
28
28
  this.cache = await NodeCache(this.cacheDir);
29
29
  }
package/dist/index.js CHANGED
@@ -4549,19 +4549,32 @@ var __publicField = (obj, key, value) => {
4549
4549
  }
4550
4550
  )));
4551
4551
  PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
4552
- const useGetOptionSets = (cms, collections) => {
4552
+ const filterQueryBuilder = (fieldFilterConfig, collection) => {
4553
+ return {
4554
+ [collection]: Object.entries(fieldFilterConfig).reduce(
4555
+ (acc, [key, value]) => {
4556
+ acc[key] = { in: value };
4557
+ return acc;
4558
+ },
4559
+ {}
4560
+ )
4561
+ };
4562
+ };
4563
+ const useGetOptionSets = (cms, collections, collectionFilter) => {
4553
4564
  const [optionSets, setOptionSets] = React__namespace.useState([]);
4554
4565
  const [loading, setLoading] = React__namespace.useState(true);
4555
4566
  React__namespace.useEffect(() => {
4556
4567
  const fetchOptionSets = async () => {
4568
+ const filters = typeof collectionFilter === "function" ? collectionFilter() : collectionFilter;
4557
4569
  const optionSets2 = await Promise.all(
4558
4570
  collections.map(async (collection) => {
4559
4571
  try {
4572
+ const filter = (filters == null ? void 0 : filters[collection]) ? filterQueryBuilder(filters[collection], collection) : {};
4560
4573
  const response = await cms.api.tina.request(
4561
4574
  `#graphql
4562
- query ($collection: String!){
4575
+ query ($collection: String!, $filter: DocumentFilter) {
4563
4576
  collection(collection: $collection) {
4564
- documents(first: -1) {
4577
+ documents(first: -1, filter: $filter) {
4565
4578
  edges {
4566
4579
  node {
4567
4580
  ...on Node {
@@ -4580,13 +4593,22 @@ var __publicField = (obj, key, value) => {
4580
4593
  }
4581
4594
  }
4582
4595
  `,
4583
- { variables: { collection } }
4596
+ {
4597
+ variables: {
4598
+ collection,
4599
+ filter
4600
+ }
4601
+ }
4584
4602
  );
4585
4603
  return {
4586
4604
  collection,
4587
4605
  edges: response.collection.documents.edges
4588
4606
  };
4589
4607
  } catch (e) {
4608
+ console.error(
4609
+ "Exception thrown while building and running GraphQL query: ",
4610
+ e
4611
+ );
4590
4612
  return {
4591
4613
  collection,
4592
4614
  edges: []
@@ -4620,7 +4642,11 @@ var __publicField = (obj, key, value) => {
4620
4642
  const [open2, setOpen] = React__namespace.useState(false);
4621
4643
  const [value, setValue] = React__namespace.useState(input.value);
4622
4644
  const [displayText, setDisplayText] = React__namespace.useState(null);
4623
- const { optionSets, loading } = useGetOptionSets(cms, field.collections);
4645
+ const { optionSets, loading } = useGetOptionSets(
4646
+ cms,
4647
+ field.collections,
4648
+ field.collectionFilter
4649
+ );
4624
4650
  const [filteredOptionsList, setFilteredOptionsList] = React__namespace.useState(optionSets);
4625
4651
  React__namespace.useEffect(() => {
4626
4652
  setDisplayText(getFilename(optionSets, value));
@@ -9257,7 +9283,7 @@ var __publicField = (obj, key, value) => {
9257
9283
  leaveFrom: "opacity-100",
9258
9284
  leaveTo: "opacity-0 -translate-x-1/2"
9259
9285
  },
9260
- cms.state.formLists.map((formList) => /* @__PURE__ */ React__namespace.createElement("div", { key: formList.id, className: "pt-16" }, /* @__PURE__ */ React__namespace.createElement(
9286
+ cms.state.formLists.map((formList, index) => /* @__PURE__ */ React__namespace.createElement("div", { key: `${formList.id}-${index}`, className: "pt-16" }, /* @__PURE__ */ React__namespace.createElement(
9261
9287
  FormList,
9262
9288
  {
9263
9289
  isEditing: props.isEditing,
@@ -9674,7 +9700,7 @@ var __publicField = (obj, key, value) => {
9674
9700
  "Event Log"
9675
9701
  ));
9676
9702
  };
9677
- const version = "2.2.6";
9703
+ const version = "2.2.9";
9678
9704
  const Nav = ({
9679
9705
  isLocalMode,
9680
9706
  className = "",
package/dist/index.mjs CHANGED
@@ -4572,19 +4572,32 @@ const PopoverContent = React.forwardRef(({ className, align = "center", sideOffs
4572
4572
  }
4573
4573
  )));
4574
4574
  PopoverContent.displayName = PopoverPrimitive.Content.displayName;
4575
- const useGetOptionSets = (cms, collections) => {
4575
+ const filterQueryBuilder = (fieldFilterConfig, collection) => {
4576
+ return {
4577
+ [collection]: Object.entries(fieldFilterConfig).reduce(
4578
+ (acc, [key, value]) => {
4579
+ acc[key] = { in: value };
4580
+ return acc;
4581
+ },
4582
+ {}
4583
+ )
4584
+ };
4585
+ };
4586
+ const useGetOptionSets = (cms, collections, collectionFilter) => {
4576
4587
  const [optionSets, setOptionSets] = React.useState([]);
4577
4588
  const [loading, setLoading] = React.useState(true);
4578
4589
  React.useEffect(() => {
4579
4590
  const fetchOptionSets = async () => {
4591
+ const filters = typeof collectionFilter === "function" ? collectionFilter() : collectionFilter;
4580
4592
  const optionSets2 = await Promise.all(
4581
4593
  collections.map(async (collection) => {
4582
4594
  try {
4595
+ const filter = (filters == null ? void 0 : filters[collection]) ? filterQueryBuilder(filters[collection], collection) : {};
4583
4596
  const response = await cms.api.tina.request(
4584
4597
  `#graphql
4585
- query ($collection: String!){
4598
+ query ($collection: String!, $filter: DocumentFilter) {
4586
4599
  collection(collection: $collection) {
4587
- documents(first: -1) {
4600
+ documents(first: -1, filter: $filter) {
4588
4601
  edges {
4589
4602
  node {
4590
4603
  ...on Node {
@@ -4603,13 +4616,22 @@ const useGetOptionSets = (cms, collections) => {
4603
4616
  }
4604
4617
  }
4605
4618
  `,
4606
- { variables: { collection } }
4619
+ {
4620
+ variables: {
4621
+ collection,
4622
+ filter
4623
+ }
4624
+ }
4607
4625
  );
4608
4626
  return {
4609
4627
  collection,
4610
4628
  edges: response.collection.documents.edges
4611
4629
  };
4612
4630
  } catch (e) {
4631
+ console.error(
4632
+ "Exception thrown while building and running GraphQL query: ",
4633
+ e
4634
+ );
4613
4635
  return {
4614
4636
  collection,
4615
4637
  edges: []
@@ -4643,7 +4665,11 @@ const ComboboxDemo = ({
4643
4665
  const [open2, setOpen] = React.useState(false);
4644
4666
  const [value, setValue] = React.useState(input.value);
4645
4667
  const [displayText, setDisplayText] = React.useState(null);
4646
- const { optionSets, loading } = useGetOptionSets(cms, field.collections);
4668
+ const { optionSets, loading } = useGetOptionSets(
4669
+ cms,
4670
+ field.collections,
4671
+ field.collectionFilter
4672
+ );
4647
4673
  const [filteredOptionsList, setFilteredOptionsList] = React.useState(optionSets);
4648
4674
  React.useEffect(() => {
4649
4675
  setDisplayText(getFilename(optionSets, value));
@@ -9280,7 +9306,7 @@ const FormLists = (props) => {
9280
9306
  leaveFrom: "opacity-100",
9281
9307
  leaveTo: "opacity-0 -translate-x-1/2"
9282
9308
  },
9283
- cms.state.formLists.map((formList) => /* @__PURE__ */ React.createElement("div", { key: formList.id, className: "pt-16" }, /* @__PURE__ */ React.createElement(
9309
+ cms.state.formLists.map((formList, index) => /* @__PURE__ */ React.createElement("div", { key: `${formList.id}-${index}`, className: "pt-16" }, /* @__PURE__ */ React.createElement(
9284
9310
  FormList,
9285
9311
  {
9286
9312
  isEditing: props.isEditing,
@@ -9697,7 +9723,7 @@ const SyncStatus = ({ cms, setEventsOpen }) => {
9697
9723
  "Event Log"
9698
9724
  ));
9699
9725
  };
9700
- const version = "2.2.6";
9726
+ const version = "2.2.9";
9701
9727
  const Nav = ({
9702
9728
  isLocalMode,
9703
9729
  className = "",
@@ -1,30 +1,3 @@
1
1
  import * as React from 'react';
2
- type Option = {
3
- value: string;
4
- label: string;
5
- };
6
- type ReferenceFieldOptions = {
7
- optionComponent?: OptionComponent;
8
- experimental___filter?: (list: Array<any>, searchQuery: string) => Array<any>;
9
- };
10
- type OptionComponent = (props: unknown, _sys: InternalSys) => React.ReactElement | string;
11
- export interface InternalSys {
12
- filename: string;
13
- path: string;
14
- }
15
- export interface ReferenceFieldProps extends ReferenceFieldOptions {
16
- label?: string;
17
- name: string;
18
- component: string;
19
- collections: string[];
20
- options: (Option | string)[];
21
- }
22
- export interface ReferenceProps {
23
- name: string;
24
- input: any;
25
- field: ReferenceFieldProps;
26
- disabled?: boolean;
27
- options?: (Option | string)[];
28
- }
2
+ import { ReferenceProps } from './model/reference-props';
29
3
  export declare const Reference: React.FC<ReferenceProps>;
30
- export {};
@@ -1,3 +1,4 @@
1
+ import { CollectionFilters } from '../utils/fetch-options-query-builder';
1
2
  export type Option = {
2
3
  value: string;
3
4
  label: string;
@@ -10,6 +11,7 @@ export interface InternalSys {
10
11
  type ReferenceFieldOptions = {
11
12
  optionComponent?: OptionComponent;
12
13
  experimental___filter?: (list: Array<any>, searchQuery: string) => Array<any>;
14
+ collectionFilter?: CollectionFilters;
13
15
  };
14
16
  export interface ReferenceFieldProps extends ReferenceFieldOptions {
15
17
  label?: string;
@@ -0,0 +1,5 @@
1
+ export type FilterValue = string[] | string;
2
+ export type CollectionFilters = Record<string, FilterValue> | (() => Record<string, FilterValue>);
3
+ export declare const filterQueryBuilder: (fieldFilterConfig: FilterValue, collection: string) => {
4
+ [x: string]: Record<string, Record<string, FilterValue>>;
5
+ };
@@ -1,8 +1,8 @@
1
- export declare const ReferenceField: (props: import("./wrap-field-with-meta").InputFieldType<import("../components/reference").ReferenceProps, {}>) => import("react").JSX.Element;
1
+ export declare const ReferenceField: (props: import("./wrap-field-with-meta").InputFieldType<import("../components/reference/model/reference-props").ReferenceProps, {}>) => import("react").JSX.Element;
2
2
  export declare const ReferenceFieldPlugin: {
3
3
  name: string;
4
4
  type: string;
5
- Component: (props: import("./wrap-field-with-meta").InputFieldType<import("../components/reference").ReferenceProps, {}>) => import("react").JSX.Element;
5
+ Component: (props: import("./wrap-field-with-meta").InputFieldType<import("../components/reference/model/reference-props").ReferenceProps, {}>) => import("react").JSX.Element;
6
6
  parse: (value?: string) => string;
7
7
  validate(value: any, values: any, meta: any, field: any): string;
8
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "2.2.7",
3
+ "version": "2.2.9",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "exports": {
@@ -60,12 +60,12 @@
60
60
  "typings": "dist/index.d.ts",
61
61
  "license": "Apache-2.0",
62
62
  "dependencies": {
63
- "@ariakit/react": "^0.4.7",
64
- "@floating-ui/dom": "^1.6.9",
65
- "@floating-ui/react-dom": "^2.1.1",
63
+ "@ariakit/react": "^0.4.11",
64
+ "@floating-ui/dom": "^1.6.11",
65
+ "@floating-ui/react-dom": "^2.1.2",
66
66
  "@graphql-inspector/core": "^6.1.0",
67
67
  "@headlessui/react": "2.1.8",
68
- "@heroicons/react": "^1.0.4",
68
+ "@heroicons/react": "^1.0.6",
69
69
  "@monaco-editor/react": "4.4.5",
70
70
  "@radix-ui/react-checkbox": "^1.1.1",
71
71
  "@radix-ui/react-dialog": "^1.1.1",
@@ -77,18 +77,18 @@
77
77
  "@radix-ui/react-tooltip": "^1.1.2",
78
78
  "@react-hook/window-size": "^3.1.1",
79
79
  "@udecode/cn": "^33.0.0",
80
- "@udecode/plate": "^36.3.6",
81
- "@udecode/plate-autoformat": "^36.0.0",
80
+ "@udecode/plate": "^36.5.9",
81
+ "@udecode/plate-autoformat": "^36.5.6",
82
82
  "@udecode/plate-block-quote": "^36.0.0",
83
- "@udecode/plate-code-block": "^36.0.0",
83
+ "@udecode/plate-code-block": "^36.5.6",
84
84
  "@udecode/plate-combobox": "^36.0.0",
85
- "@udecode/plate-common": "^36.3.4",
86
- "@udecode/plate-floating": "^36.3.2",
85
+ "@udecode/plate-common": "^36.5.9",
86
+ "@udecode/plate-floating": "^36.3.8",
87
87
  "@udecode/plate-heading": "^36.0.12",
88
88
  "@udecode/plate-indent": "^36.0.0",
89
- "@udecode/plate-indent-list": "^36.3.3",
90
- "@udecode/plate-link": "^36.3.2",
91
- "@udecode/plate-list": "^36.0.0",
89
+ "@udecode/plate-indent-list": "^36.5.2",
90
+ "@udecode/plate-link": "^36.5.9",
91
+ "@udecode/plate-list": "^36.5.2",
92
92
  "@udecode/plate-paragraph": "^36.0.0",
93
93
  "@udecode/plate-slash-command": "^36.0.0",
94
94
  "class-variance-authority": "^0.7.0",
@@ -109,42 +109,42 @@
109
109
  "lucide-react": "^0.424.0",
110
110
  "moment": "2.29.4",
111
111
  "monaco-editor": "0.31.0",
112
- "prism-react-renderer": "^2.3.1",
112
+ "prism-react-renderer": "^2.4.0",
113
113
  "prop-types": "15.7.2",
114
114
  "react-beautiful-dnd": "^13.1.1",
115
115
  "react-color": "^2.19.3",
116
116
  "react-datetime": "^3.2.0",
117
117
  "react-dropzone": "14.2.3",
118
118
  "react-final-form": "^6.5.9",
119
- "react-icons": "^5.2.1",
119
+ "react-icons": "^5.3.0",
120
120
  "react-onclickoutside": "^6.13.1",
121
121
  "react-router-dom": "6.3.0",
122
122
  "slate": "^0.103.0",
123
123
  "slate-history": "^0.100.0",
124
124
  "slate-hyperscript": "^0.100.0",
125
125
  "slate-react": "^0.107.1",
126
- "tailwind-merge": "^2.4.0",
126
+ "tailwind-merge": "^2.5.2",
127
127
  "webfontloader": "1.6.28",
128
128
  "yup": "^1.4.0",
129
129
  "zod": "^3.23.8",
130
- "@tinacms/mdx": "1.4.3",
131
- "@tinacms/schema-tools": "1.6.3",
132
- "@tinacms/search": "1.0.30"
130
+ "@tinacms/mdx": "1.4.5",
131
+ "@tinacms/search": "1.0.32",
132
+ "@tinacms/schema-tools": "1.6.5"
133
133
  },
134
134
  "devDependencies": {
135
- "@graphql-tools/utils": "^10.3.3",
135
+ "@graphql-tools/utils": "^10.5.4",
136
136
  "@testing-library/dom": "^10.4.0",
137
- "@testing-library/jest-dom": "^6.4.8",
138
- "@testing-library/react": "^16.0.0",
137
+ "@testing-library/jest-dom": "^6.5.0",
138
+ "@testing-library/react": "^16.0.1",
139
139
  "@testing-library/user-event": "^14.5.2",
140
140
  "@types/atob": "^2.1.4",
141
141
  "@types/codemirror": "^5.60.15",
142
142
  "@types/color-string": "^1.5.5",
143
143
  "@types/lodash.debounce": "^4.0.9",
144
144
  "@types/lodash.get": "^4.4.9",
145
- "@types/node": "^22.7.3",
146
- "@types/prop-types": "^15.7.12",
147
- "@types/react": "^18.3.3",
145
+ "@types/node": "^22.7.4",
146
+ "@types/prop-types": "^15.7.13",
147
+ "@types/react": "^18.3.10",
148
148
  "@types/react-beautiful-dnd": "^13.1.8",
149
149
  "@types/react-color": "^3.0.12",
150
150
  "@types/react-dom": "^18.3.0",
@@ -158,11 +158,11 @@
158
158
  "react-dom": "^18.3.1",
159
159
  "react-is": "^18.3.1",
160
160
  "tsc-alias": "^1.8.10",
161
- "tslib": "^2.6.3",
161
+ "tslib": "^2.7.0",
162
162
  "typescript": "^5.6.2",
163
- "vite": "^5.3.5",
164
- "vitest": "^2.0.5",
165
- "@tinacms/scripts": "1.2.2"
163
+ "vite": "^5.4.8",
164
+ "vitest": "^2.1.1",
165
+ "@tinacms/scripts": "1.2.3"
166
166
  },
167
167
  "peerDependencies": {
168
168
  "react": ">=16.14.0",