payload 0.12.5-beta.0 → 0.12.9-beta.0
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/CHANGELOG.md +20 -4
- package/dist/admin/components/elements/ReactSelect/index.js +2 -2
- package/dist/admin/components/elements/ReactSelect/types.d.ts +1 -0
- package/dist/admin/components/elements/WhereBuilder/Condition/Relationship/index.d.ts +5 -0
- package/dist/admin/components/elements/WhereBuilder/Condition/Relationship/index.js +202 -0
- package/dist/admin/components/elements/WhereBuilder/Condition/Relationship/index.scss +11 -0
- package/dist/admin/components/elements/WhereBuilder/Condition/Relationship/optionsReducer.d.ts +3 -0
- package/dist/admin/components/elements/WhereBuilder/Condition/Relationship/optionsReducer.js +76 -0
- package/dist/admin/components/elements/WhereBuilder/Condition/Relationship/types.d.ts +29 -0
- package/dist/admin/components/elements/WhereBuilder/Condition/Relationship/types.js +1 -0
- package/dist/admin/components/elements/WhereBuilder/Condition/index.js +3 -0
- package/dist/admin/components/elements/WhereBuilder/field-types.js +1 -1
- package/dist/admin/components/forms/FieldDescription/types.d.ts +1 -2
- package/dist/admin/components/forms/FieldDescription/types.js +11 -3
- package/dist/admin/components/forms/field-types/Array/types.d.ts +2 -1
- package/dist/admin/components/forms/field-types/Blocks/types.d.ts +2 -1
- package/dist/admin/components/forms/field-types/Password/types.d.ts +2 -1
- package/dist/admin/components/forms/field-types/RichText/elements/link/index.scss +5 -0
- package/dist/bin/generateTypes.d.ts +1 -0
- package/dist/bin/generateTypes.js +332 -0
- package/dist/bin/index.js +6 -1
- package/dist/collections/operations/find.js +15 -8
- package/dist/collections/operations/update.js +2 -2
- package/dist/config/build.js +3 -2
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.js +4 -1
- package/dist/config/schema.js +4 -1
- package/dist/config/types.d.ts +3 -0
- package/dist/fields/config/types.d.ts +1 -1
- package/dist/fields/config/types.js +1 -1
- package/dist/globals/operations/update.js +2 -2
- package/dist/mongoose/buildQuery.js +13 -9
- package/dist/mongoose/buildSchema.js +6 -1
- package/dist/mongoose/sanitizeFormattedValue.js +18 -22
- package/dist/uploads/isImage.js +2 -2
- package/docs/fields/select.mdx +1 -1
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,28 +1,44 @@
|
|
|
1
|
-
## [0.12.
|
|
1
|
+
## [0.12.9-beta.0](https://github.com/payloadcms/payload/compare/v0.12.3...v0.12.9-beta.0) (2021-11-24)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
6
|
* [#351](https://github.com/payloadcms/payload/issues/351) ([94c2b8d](https://github.com/payloadcms/payload/commit/94c2b8d80b046c067057d4ad089ed6a2edd656cf))
|
|
7
7
|
* bug with relationship cell when no doc is available ([40b33d9](https://github.com/payloadcms/payload/commit/40b33d9f5e99285cb0de148dbe059259817fcad8))
|
|
8
|
+
* ensures 'like' query param remains functional in all cases ([20d4e72](https://github.com/payloadcms/payload/commit/20d4e72a951dfcbf1cc301d0938e5095932436b9))
|
|
9
|
+
* ensures buildQuery works with fields as well as simultaneous or / and ([72fc413](https://github.com/payloadcms/payload/commit/72fc413764c6c42ba64a45f01d99b68ad3bd46c4))
|
|
8
10
|
* ensures relationship field search can return more than 10 options ([57c0346](https://github.com/payloadcms/payload/commit/57c0346a00286a3df695ea46e5c2630494183b5b))
|
|
11
|
+
* ensures richtext links retain proper formatting ([abf61d0](https://github.com/payloadcms/payload/commit/abf61d0734c09fd0fc5c5b827cb0631e11701f71))
|
|
9
12
|
* ensures tquerying by relationship subpaths works ([37b21b0](https://github.com/payloadcms/payload/commit/37b21b07628e892e85c2cf979d9e2c8af0d291f7))
|
|
13
|
+
* issue with querying by id and using comma-separated values ([d9e1b5e](https://github.com/payloadcms/payload/commit/d9e1b5ede33616893f9ba6990eeccf5410b75ae1))
|
|
14
|
+
* updates field description type to include react nodes ([291c193](https://github.com/payloadcms/payload/commit/291c193ad4a9ec8ce9310cc63c714eba10eca102))
|
|
10
15
|
|
|
11
16
|
|
|
12
17
|
### Features
|
|
13
18
|
|
|
19
|
+
* add id fields to generated types ([21a810c](https://github.com/payloadcms/payload/commit/21a810c38c16e6907069d9076abf55718e439497))
|
|
20
|
+
* adds field types to type generation ([6dd1b0e](https://github.com/payloadcms/payload/commit/6dd1b0e0339490bf9e500f03f47ed59381644d85))
|
|
21
|
+
* adds relationship filter field ([463c4e6](https://github.com/payloadcms/payload/commit/463c4e60de8e647fca6268b826d826f9c6e45412))
|
|
22
|
+
* azure cosmos compatibility ([6fd5ac2](https://github.com/payloadcms/payload/commit/6fd5ac2c082a5a5e6f510d781b2a2e12b7b62cb9))
|
|
23
|
+
* baseline type generation ([5a965d2](https://github.com/payloadcms/payload/commit/5a965d2263d1b246149c5220d039a6d97953d5e8))
|
|
24
|
+
* ensures update hooks have access to full original docs even in spite of access control ([b2c5b7e](https://github.com/payloadcms/payload/commit/b2c5b7e5752e829c7a53c054decceb43ec33065e))
|
|
25
|
+
* finishes typing all fields ([ed5a5eb](https://github.com/payloadcms/payload/commit/ed5a5ebe7e16d20577556ab233032a52bef6d2cb))
|
|
26
|
+
* generates further field types ([2ca76ba](https://github.com/payloadcms/payload/commit/2ca76ba8ce6c61ee7b0a01a557b6f013ca483d6d))
|
|
14
27
|
* improves querying logic ([4c85747](https://github.com/payloadcms/payload/commit/4c8574784995b1cb1f939648f4d2158286089b3d))
|
|
15
28
|
|
|
16
|
-
## [0.12.
|
|
29
|
+
## [0.12.8-beta.0](https://github.com/payloadcms/payload/compare/v0.12.3...v0.12.8-beta.0) (2021-11-10)
|
|
17
30
|
|
|
18
31
|
|
|
19
32
|
### Bug Fixes
|
|
20
33
|
|
|
21
|
-
*
|
|
22
|
-
|
|
34
|
+
* [#351](https://github.com/payloadcms/payload/issues/351) ([94c2b8d](https://github.com/payloadcms/payload/commit/94c2b8d80b046c067057d4ad089ed6a2edd656cf))
|
|
35
|
+
* bug with relationship cell when no doc is available ([40b33d9](https://github.com/payloadcms/payload/commit/40b33d9f5e99285cb0de148dbe059259817fcad8))
|
|
36
|
+
* ensures richtext links retain proper formatting ([abf61d0](https://github.com/payloadcms/payload/commit/abf61d0734c09fd0fc5c5b827cb0631e11701f71))
|
|
23
37
|
|
|
24
38
|
### Features
|
|
25
39
|
|
|
40
|
+
* adds relationship filter field ([463c4e6](https://github.com/payloadcms/payload/commit/463c4e60de8e647fca6268b826d826f9c6e45412))
|
|
41
|
+
* ensures update hooks have access to full original docs even in spite of access control ([b2c5b7e](https://github.com/payloadcms/payload/commit/b2c5b7e5752e829c7a53c054decceb43ec33065e))
|
|
26
42
|
* improves querying logic ([4c85747](https://github.com/payloadcms/payload/commit/4c8574784995b1cb1f939648f4d2158286089b3d))
|
|
27
43
|
|
|
28
44
|
## [0.12.3](https://github.com/payloadcms/payload/compare/v0.12.2...v0.12.3) (2021-10-23)
|
|
@@ -3,12 +3,12 @@ import Select from 'react-select';
|
|
|
3
3
|
import Chevron from '../../icons/Chevron';
|
|
4
4
|
import './index.scss';
|
|
5
5
|
const ReactSelect = (props) => {
|
|
6
|
-
const { className, showError = false, options, onChange, value, disabled = false, } = props;
|
|
6
|
+
const { className, showError = false, options, onChange, value, disabled = false, placeholder, } = props;
|
|
7
7
|
const classes = [
|
|
8
8
|
className,
|
|
9
9
|
'react-select',
|
|
10
10
|
showError && 'react-select--error',
|
|
11
11
|
].filter(Boolean).join(' ');
|
|
12
|
-
return (React.createElement(Select, { ...props, value: value, onChange: onChange, disabled: disabled ? 'disabled' : undefined, components: { DropdownIndicator: Chevron }, className: classes, classNamePrefix: "rs", options: options }));
|
|
12
|
+
return (React.createElement(Select, { placeholder: placeholder, ...props, value: value, onChange: onChange, disabled: disabled ? 'disabled' : undefined, components: { DropdownIndicator: Chevron }, className: classes, classNamePrefix: "rs", options: options }));
|
|
13
13
|
};
|
|
14
14
|
export default ReactSelect;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import React, { useReducer, useState, useCallback, useEffect } from 'react';
|
|
2
|
+
import { useConfig } from '@payloadcms/config-provider';
|
|
3
|
+
import optionsReducer from './optionsReducer';
|
|
4
|
+
import useDebounce from '../../../../../hooks/useDebounce';
|
|
5
|
+
import ReactSelect from '../../../ReactSelect';
|
|
6
|
+
import './index.scss';
|
|
7
|
+
const baseClass = 'condition-value-relationship';
|
|
8
|
+
const maxResultsPerRequest = 10;
|
|
9
|
+
const RelationshipField = (props) => {
|
|
10
|
+
const { onChange, value, relationTo, hasMany } = props;
|
|
11
|
+
const { serverURL, routes: { api, }, collections, } = useConfig();
|
|
12
|
+
const hasMultipleRelations = Array.isArray(relationTo);
|
|
13
|
+
const [options, dispatchOptions] = useReducer(optionsReducer, []);
|
|
14
|
+
const [lastFullyLoadedRelation, setLastFullyLoadedRelation] = useState(-1);
|
|
15
|
+
const [lastLoadedPage, setLastLoadedPage] = useState(1);
|
|
16
|
+
const [search, setSearch] = useState('');
|
|
17
|
+
const [errorLoading, setErrorLoading] = useState('');
|
|
18
|
+
const [hasLoadedFirstOptions, setHasLoadedFirstOptions] = useState(false);
|
|
19
|
+
const debouncedSearch = useDebounce(search, 300);
|
|
20
|
+
const addOptions = useCallback((data, relation) => {
|
|
21
|
+
const collection = collections.find((coll) => coll.slug === relation);
|
|
22
|
+
dispatchOptions({ type: 'ADD', data, relation, hasMultipleRelations, collection });
|
|
23
|
+
}, [collections, hasMultipleRelations]);
|
|
24
|
+
const getResults = useCallback(async ({ lastFullyLoadedRelation: lastFullyLoadedRelationArg, lastLoadedPage: lastLoadedPageArg, search: searchArg, }) => {
|
|
25
|
+
let lastLoadedPageToUse = typeof lastLoadedPageArg !== 'undefined' ? lastLoadedPageArg : 1;
|
|
26
|
+
const lastFullyLoadedRelationToUse = typeof lastFullyLoadedRelationArg !== 'undefined' ? lastFullyLoadedRelationArg : -1;
|
|
27
|
+
const relations = Array.isArray(relationTo) ? relationTo : [relationTo];
|
|
28
|
+
const relationsToFetch = lastFullyLoadedRelationToUse === -1 ? relations : relations.slice(lastFullyLoadedRelationToUse + 1);
|
|
29
|
+
let resultsFetched = 0;
|
|
30
|
+
if (!errorLoading) {
|
|
31
|
+
relationsToFetch.reduce(async (priorRelation, relation) => {
|
|
32
|
+
var _a;
|
|
33
|
+
await priorRelation;
|
|
34
|
+
if (resultsFetched < 10) {
|
|
35
|
+
const collection = collections.find((coll) => coll.slug === relation);
|
|
36
|
+
const fieldToSearch = ((_a = collection === null || collection === void 0 ? void 0 : collection.admin) === null || _a === void 0 ? void 0 : _a.useAsTitle) || 'id';
|
|
37
|
+
const searchParam = searchArg ? `&where[${fieldToSearch}][like]=${searchArg}` : '';
|
|
38
|
+
const response = await fetch(`${serverURL}${api}/${relation}?limit=${maxResultsPerRequest}&page=${lastLoadedPageToUse}&depth=0${searchParam}`);
|
|
39
|
+
if (response.ok) {
|
|
40
|
+
const data = await response.json();
|
|
41
|
+
if (data.docs.length > 0) {
|
|
42
|
+
resultsFetched += data.docs.length;
|
|
43
|
+
addOptions(data, relation);
|
|
44
|
+
setLastLoadedPage(data.page);
|
|
45
|
+
if (!data.nextPage) {
|
|
46
|
+
setLastFullyLoadedRelation(relations.indexOf(relation));
|
|
47
|
+
// If there are more relations to search, need to reset lastLoadedPage to 1
|
|
48
|
+
// both locally within function and state
|
|
49
|
+
if (relations.indexOf(relation) + 1 < relations.length) {
|
|
50
|
+
lastLoadedPageToUse = 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
setErrorLoading('An error has occurred.');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, Promise.resolve());
|
|
60
|
+
}
|
|
61
|
+
}, [addOptions, api, collections, serverURL, errorLoading, relationTo]);
|
|
62
|
+
const findOptionsByValue = useCallback(() => {
|
|
63
|
+
if (value) {
|
|
64
|
+
if (hasMany) {
|
|
65
|
+
if (Array.isArray(value)) {
|
|
66
|
+
return value.map((val) => {
|
|
67
|
+
if (hasMultipleRelations) {
|
|
68
|
+
let matchedOption;
|
|
69
|
+
options.forEach((opt) => {
|
|
70
|
+
if (opt.options) {
|
|
71
|
+
opt.options.some((subOpt) => {
|
|
72
|
+
if ((subOpt === null || subOpt === void 0 ? void 0 : subOpt.value) === val.value) {
|
|
73
|
+
matchedOption = subOpt;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return matchedOption;
|
|
81
|
+
}
|
|
82
|
+
return options.find((opt) => opt.value === val);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
if (hasMultipleRelations) {
|
|
88
|
+
let matchedOption;
|
|
89
|
+
const valueWithRelation = value;
|
|
90
|
+
options.forEach((opt) => {
|
|
91
|
+
if (opt === null || opt === void 0 ? void 0 : opt.options) {
|
|
92
|
+
opt.options.some((subOpt) => {
|
|
93
|
+
if ((subOpt === null || subOpt === void 0 ? void 0 : subOpt.value) === valueWithRelation.value) {
|
|
94
|
+
matchedOption = subOpt;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return matchedOption;
|
|
102
|
+
}
|
|
103
|
+
return options.find((opt) => opt.value === value);
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
}, [hasMany, hasMultipleRelations, value, options]);
|
|
107
|
+
const handleInputChange = useCallback((newSearch) => {
|
|
108
|
+
if (search !== newSearch) {
|
|
109
|
+
setSearch(newSearch);
|
|
110
|
+
}
|
|
111
|
+
}, [search]);
|
|
112
|
+
const addOptionByID = useCallback(async (id, relation) => {
|
|
113
|
+
if (!errorLoading && id !== 'null') {
|
|
114
|
+
const response = await fetch(`${serverURL}${api}/${relation}/${id}?depth=0`);
|
|
115
|
+
if (response.ok) {
|
|
116
|
+
const data = await response.json();
|
|
117
|
+
addOptions({ docs: [data] }, relation);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
console.error(`There was a problem loading the document with ID of ${id}.`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}, [addOptions, api, errorLoading, serverURL]);
|
|
124
|
+
// ///////////////////////////
|
|
125
|
+
// Get results when search input changes
|
|
126
|
+
// ///////////////////////////
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
dispatchOptions({
|
|
129
|
+
type: 'CLEAR',
|
|
130
|
+
required: true,
|
|
131
|
+
});
|
|
132
|
+
setHasLoadedFirstOptions(true);
|
|
133
|
+
setLastLoadedPage(1);
|
|
134
|
+
setLastFullyLoadedRelation(-1);
|
|
135
|
+
getResults({ search: debouncedSearch });
|
|
136
|
+
}, [getResults, debouncedSearch, relationTo]);
|
|
137
|
+
// ///////////////////////////
|
|
138
|
+
// Format options once first options have been retrieved
|
|
139
|
+
// ///////////////////////////
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (value && hasLoadedFirstOptions) {
|
|
142
|
+
if (hasMany) {
|
|
143
|
+
const matchedOptions = findOptionsByValue();
|
|
144
|
+
(matchedOptions || []).forEach((option, i) => {
|
|
145
|
+
if (!option) {
|
|
146
|
+
if (hasMultipleRelations) {
|
|
147
|
+
addOptionByID(value[i].value, value[i].relationTo);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
addOptionByID(value[i], relationTo);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const matchedOption = findOptionsByValue();
|
|
157
|
+
if (!matchedOption) {
|
|
158
|
+
if (hasMultipleRelations) {
|
|
159
|
+
const valueWithRelation = value;
|
|
160
|
+
addOptionByID(valueWithRelation.value, valueWithRelation.relationTo);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
addOptionByID(value, relationTo);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}, [addOptionByID, findOptionsByValue, hasMany, hasMultipleRelations, relationTo, value, hasLoadedFirstOptions]);
|
|
169
|
+
const classes = [
|
|
170
|
+
'field-type',
|
|
171
|
+
baseClass,
|
|
172
|
+
errorLoading && 'error-loading',
|
|
173
|
+
].filter(Boolean).join(' ');
|
|
174
|
+
const valueToRender = (findOptionsByValue() || value);
|
|
175
|
+
return (React.createElement("div", { className: classes },
|
|
176
|
+
!errorLoading && (React.createElement(ReactSelect, { placeholder: "Select a value", onInputChange: handleInputChange, onChange: (selected) => {
|
|
177
|
+
if (hasMany) {
|
|
178
|
+
onChange(selected ? selected.map((option) => {
|
|
179
|
+
if (hasMultipleRelations) {
|
|
180
|
+
return {
|
|
181
|
+
relationTo: option.relationTo,
|
|
182
|
+
value: option.value,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return option.value;
|
|
186
|
+
}) : null);
|
|
187
|
+
}
|
|
188
|
+
else if (hasMultipleRelations) {
|
|
189
|
+
onChange({
|
|
190
|
+
relationTo: selected.relationTo,
|
|
191
|
+
value: selected.value,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
onChange(selected.value);
|
|
196
|
+
}
|
|
197
|
+
}, onMenuScrollToBottom: () => {
|
|
198
|
+
getResults({ lastFullyLoadedRelation, lastLoadedPage: lastLoadedPage + 1 });
|
|
199
|
+
}, value: valueToRender, options: options, isMulti: hasMany })),
|
|
200
|
+
errorLoading && (React.createElement("div", { className: `${baseClass}__error-loading` }, errorLoading))));
|
|
201
|
+
};
|
|
202
|
+
export default RelationshipField;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const reduceToIDs = (options) => options.reduce((ids, option) => {
|
|
2
|
+
if (option.options) {
|
|
3
|
+
return [
|
|
4
|
+
...ids,
|
|
5
|
+
...reduceToIDs(option.options),
|
|
6
|
+
];
|
|
7
|
+
}
|
|
8
|
+
return [
|
|
9
|
+
...ids,
|
|
10
|
+
option.id,
|
|
11
|
+
];
|
|
12
|
+
}, []);
|
|
13
|
+
const optionsReducer = (state, action) => {
|
|
14
|
+
switch (action.type) {
|
|
15
|
+
case 'CLEAR': {
|
|
16
|
+
return action.required ? [] : [{ value: 'null', label: 'None' }];
|
|
17
|
+
}
|
|
18
|
+
case 'ADD': {
|
|
19
|
+
const { hasMultipleRelations, collection, relation, data } = action;
|
|
20
|
+
const labelKey = collection.admin.useAsTitle || 'id';
|
|
21
|
+
const loadedIDs = reduceToIDs(state);
|
|
22
|
+
if (!hasMultipleRelations) {
|
|
23
|
+
return [
|
|
24
|
+
...state,
|
|
25
|
+
...data.docs.reduce((docs, doc) => {
|
|
26
|
+
if (loadedIDs.indexOf(doc.id) === -1) {
|
|
27
|
+
loadedIDs.push(doc.id);
|
|
28
|
+
return [
|
|
29
|
+
...docs,
|
|
30
|
+
{
|
|
31
|
+
label: doc[labelKey],
|
|
32
|
+
value: doc.id,
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
return docs;
|
|
37
|
+
}, []),
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
const newOptions = [...state];
|
|
41
|
+
const optionsToAddTo = newOptions.find((optionGroup) => optionGroup.label === collection.labels.plural);
|
|
42
|
+
const newSubOptions = data.docs.reduce((docs, doc) => {
|
|
43
|
+
if (loadedIDs.indexOf(doc.id) === -1) {
|
|
44
|
+
loadedIDs.push(doc.id);
|
|
45
|
+
return [
|
|
46
|
+
...docs,
|
|
47
|
+
{
|
|
48
|
+
label: doc[labelKey],
|
|
49
|
+
relationTo: relation,
|
|
50
|
+
value: doc.id,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
return docs;
|
|
55
|
+
}, []);
|
|
56
|
+
if (optionsToAddTo) {
|
|
57
|
+
optionsToAddTo.options = [
|
|
58
|
+
...optionsToAddTo.options,
|
|
59
|
+
...newSubOptions,
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
newOptions.push({
|
|
64
|
+
label: collection.labels.plural,
|
|
65
|
+
options: newSubOptions,
|
|
66
|
+
value: undefined,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return newOptions;
|
|
70
|
+
}
|
|
71
|
+
default: {
|
|
72
|
+
return state;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
export default optionsReducer;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RelationshipField } from '../../../../../../fields/config/types';
|
|
2
|
+
import { PaginatedDocs, SanitizedCollectionConfig } from '../../../../../../collections/config/types';
|
|
3
|
+
export declare type Props = {
|
|
4
|
+
onChange: (val: unknown) => void;
|
|
5
|
+
value: unknown;
|
|
6
|
+
} & RelationshipField;
|
|
7
|
+
export declare type Option = {
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
relationTo?: string;
|
|
11
|
+
options?: Option[];
|
|
12
|
+
};
|
|
13
|
+
declare type CLEAR = {
|
|
14
|
+
type: 'CLEAR';
|
|
15
|
+
required: boolean;
|
|
16
|
+
};
|
|
17
|
+
declare type ADD = {
|
|
18
|
+
type: 'ADD';
|
|
19
|
+
data: PaginatedDocs;
|
|
20
|
+
relation: string;
|
|
21
|
+
hasMultipleRelations: boolean;
|
|
22
|
+
collection: SanitizedCollectionConfig;
|
|
23
|
+
};
|
|
24
|
+
export declare type Action = CLEAR | ADD;
|
|
25
|
+
export declare type ValueWithRelation = {
|
|
26
|
+
relationTo: string;
|
|
27
|
+
value: string;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,12 +5,14 @@ import Button from '../../Button';
|
|
|
5
5
|
import Date from './Date';
|
|
6
6
|
import Number from './Number';
|
|
7
7
|
import Text from './Text';
|
|
8
|
+
import Relationship from './Relationship';
|
|
8
9
|
import useDebounce from '../../../../hooks/useDebounce';
|
|
9
10
|
import './index.scss';
|
|
10
11
|
const valueFields = {
|
|
11
12
|
Date,
|
|
12
13
|
Number,
|
|
13
14
|
Text,
|
|
15
|
+
Relationship,
|
|
14
16
|
};
|
|
15
17
|
const baseClass = 'condition';
|
|
16
18
|
const Condition = (props) => {
|
|
@@ -60,6 +62,7 @@ const Condition = (props) => {
|
|
|
60
62
|
React.createElement("div", { className: `${baseClass}__value` },
|
|
61
63
|
React.createElement(RenderCustomComponent, { CustomComponent: (_c = (_b = (_a = activeField === null || activeField === void 0 ? void 0 : activeField.props) === null || _a === void 0 ? void 0 : _a.admin) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c.Filter, DefaultComponent: ValueComponent, componentProps: {
|
|
62
64
|
...activeField === null || activeField === void 0 ? void 0 : activeField.props,
|
|
65
|
+
operator: operatorValue,
|
|
63
66
|
value: internalValue,
|
|
64
67
|
onChange: setInternalValue,
|
|
65
68
|
} }))),
|
|
@@ -3,10 +3,9 @@ export declare type DescriptionFunction = (value: unknown) => string;
|
|
|
3
3
|
export declare type DescriptionComponent = React.ComponentType<{
|
|
4
4
|
value: unknown;
|
|
5
5
|
}>;
|
|
6
|
-
declare type Description = string | DescriptionFunction | DescriptionComponent;
|
|
6
|
+
export declare type Description = string | DescriptionFunction | DescriptionComponent;
|
|
7
7
|
export declare type Props = {
|
|
8
8
|
description?: Description;
|
|
9
9
|
value: unknown;
|
|
10
10
|
};
|
|
11
11
|
export declare function isComponent(description: Description): description is DescriptionComponent;
|
|
12
|
-
export {};
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isComponent = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function isComponent(description) {
|
|
9
|
+
return react_1.default.isValidElement(description);
|
|
4
10
|
}
|
|
11
|
+
exports.isComponent = isComponent;
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvYWRtaW4vY29tcG9uZW50cy9mb3Jtcy9GaWVsZERlc2NyaXB0aW9uL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLGtEQUEwQjtBQWExQixTQUFnQixXQUFXLENBQUMsV0FBd0I7SUFDbEQsT0FBTyxlQUFLLENBQUMsY0FBYyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQzNDLENBQUM7QUFGRCxrQ0FFQyJ9
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Data } from '../../Form/types';
|
|
2
|
-
import { ArrayField, Labels, Field
|
|
2
|
+
import { ArrayField, Labels, Field } from '../../../../../fields/config/types';
|
|
3
3
|
import { FieldTypes } from '..';
|
|
4
4
|
import { FieldPermissions } from '../../../../../auth/types';
|
|
5
|
+
import { Description } from '../../FieldDescription/types';
|
|
5
6
|
export declare type Props = Omit<ArrayField, 'type'> & {
|
|
6
7
|
path?: string;
|
|
7
8
|
fieldTypes: FieldTypes;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Data } from '../../Form/types';
|
|
2
|
-
import { BlockField, Labels, Block
|
|
2
|
+
import { BlockField, Labels, Block } from '../../../../../fields/config/types';
|
|
3
3
|
import { FieldTypes } from '..';
|
|
4
4
|
import { FieldPermissions } from '../../../../../auth/types';
|
|
5
|
+
import { Description } from '../../FieldDescription/types';
|
|
5
6
|
export declare type Props = Omit<BlockField, 'type'> & {
|
|
6
7
|
path?: string;
|
|
7
8
|
fieldTypes: FieldTypes;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Validate } from '../../../../../fields/config/types';
|
|
3
|
+
import { Description } from '../../FieldDescription/types';
|
|
3
4
|
export declare type Props = {
|
|
4
5
|
autoComplete?: string;
|
|
5
6
|
path?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateTypes(): void;
|