tinacms 2.2.8 → 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 +1 -1
- package/dist/client.mjs +1 -1
- package/dist/index.js +32 -6
- package/dist/index.mjs +32 -6
- package/dist/toolkit/fields/components/reference/index.d.ts +1 -28
- package/dist/toolkit/fields/components/reference/model/reference-field-props.d.ts +2 -0
- package/dist/toolkit/fields/components/reference/utils/fetch-options-query-builder.d.ts +5 -0
- package/dist/toolkit/fields/plugins/reference-field-plugin.d.ts +2 -2
- package/package.json +4 -4
package/dist/client.js
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
try {
|
|
29
|
-
if (this.cacheDir && window ===
|
|
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 ===
|
|
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
|
|
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
|
-
{
|
|
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(
|
|
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));
|
|
@@ -9674,7 +9700,7 @@ var __publicField = (obj, key, value) => {
|
|
|
9674
9700
|
"Event Log"
|
|
9675
9701
|
));
|
|
9676
9702
|
};
|
|
9677
|
-
const version = "2.2.
|
|
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
|
|
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
|
-
{
|
|
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(
|
|
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));
|
|
@@ -9697,7 +9723,7 @@ const SyncStatus = ({ cms, setEventsOpen }) => {
|
|
|
9697
9723
|
"Event Log"
|
|
9698
9724
|
));
|
|
9699
9725
|
};
|
|
9700
|
-
const version = "2.2.
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "2.2.9",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -127,9 +127,9 @@
|
|
|
127
127
|
"webfontloader": "1.6.28",
|
|
128
128
|
"yup": "^1.4.0",
|
|
129
129
|
"zod": "^3.23.8",
|
|
130
|
-
"@tinacms/mdx": "1.4.
|
|
131
|
-
"@tinacms/
|
|
132
|
-
"@tinacms/
|
|
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
135
|
"@graphql-tools/utils": "^10.5.4",
|