payload 1.2.0 → 1.2.2
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 +161 -16
- package/components/fields/Array.ts +1 -2
- package/components/fields/Blocks.ts +1 -2
- package/components/fields/Cell.ts +1 -1
- package/components/fields/Checkbox.ts +1 -2
- package/components/fields/Code.ts +1 -2
- package/components/fields/DateTime.ts +1 -2
- package/components/fields/Email.ts +1 -2
- package/components/fields/Group.ts +1 -2
- package/components/fields/Number.ts +1 -2
- package/components/fields/Password.ts +1 -2
- package/components/fields/RadioGroup/RadioInput.ts +1 -2
- package/components/fields/RadioGroup/index.ts +1 -2
- package/components/fields/Relationship.ts +1 -2
- package/components/fields/RichText.ts +1 -2
- package/components/fields/Row.ts +1 -2
- package/components/fields/Select.ts +1 -2
- package/components/fields/Text.ts +1 -2
- package/components/fields/Textarea.ts +1 -2
- package/components/fields/Upload.ts +1 -2
- package/components/views/Cell.ts +1 -2
- package/components/views/Edit.ts +1 -2
- package/components/views/List.ts +1 -2
- package/dist/admin/components/elements/ReactSelect/index.js +4 -4
- package/dist/admin/components/elements/ReactSelect/types.d.ts +11 -10
- package/dist/admin/components/elements/Status/index.js +1 -1
- package/dist/admin/components/elements/VersionsCount/index.js +1 -1
- package/dist/admin/components/elements/WhereBuilder/Condition/Text/index.js +5 -1
- package/dist/admin/components/forms/Form/context.d.ts +15 -0
- package/dist/admin/components/forms/Form/context.js +16 -1
- package/dist/admin/components/forms/field-types/Blocks/SectionTitle/index.scss +3 -2
- package/dist/admin/components/forms/field-types/Blocks/index.js +1 -1
- package/dist/admin/components/forms/field-types/Code/Code.js +3 -4
- package/dist/admin/components/forms/field-types/Code/index.scss +177 -78
- package/dist/admin/components/forms/field-types/Relationship/AddNew/index.js +0 -1
- package/dist/admin/components/forms/field-types/Relationship/GetFilterOptions/index.d.ts +11 -0
- package/dist/admin/components/forms/field-types/Relationship/GetFilterOptions/index.js +37 -0
- package/dist/admin/components/forms/field-types/Relationship/findOptionsByValue.d.ts +8 -0
- package/dist/admin/components/forms/field-types/Relationship/findOptionsByValue.js +29 -0
- package/dist/admin/components/forms/field-types/Relationship/index.js +89 -139
- package/dist/admin/components/forms/field-types/Relationship/optionsReducer.d.ts +2 -2
- package/dist/admin/components/forms/field-types/Relationship/optionsReducer.js +2 -29
- package/dist/admin/components/forms/field-types/Relationship/types.d.ts +14 -2
- package/dist/admin/components/forms/field-types/RichText/elements/link/Element.js +3 -3
- package/dist/admin/components/forms/field-types/RichText/elements/link/index.scss +2 -1
- package/dist/admin/components/forms/field-types/RichText/elements/upload/Button/index.js +1 -1
- package/dist/admin/components/forms/field-types/Row/index.js +1 -1
- package/dist/admin/components/forms/field-types/Select/Input.d.ts +2 -2
- package/dist/admin/components/forms/field-types/Select/Input.js +13 -3
- package/dist/admin/components/forms/field-types/Textarea/Input.js +1 -1
- package/dist/admin/components/forms/field-types/Textarea/index.scss +3 -6
- package/dist/admin/components/forms/useField/index.d.ts +5 -0
- package/dist/admin/components/forms/useField/index.js +5 -0
- package/dist/admin/components/utilities/I18n/index.js +1 -1
- package/dist/admin/components/views/Account/index.js +6 -1
- package/dist/admin/components/views/Global/index.scss +31 -24
- package/dist/admin/components/views/Login/index.js +1 -1
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +1 -1
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Nested/index.js +15 -9
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +5 -2
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts +5 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Select/index.js +34 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Select/index.scss +10 -0
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/Text/index.js +3 -2
- package/dist/admin/components/views/Version/RenderFieldsToDiff/fields/index.js +3 -2
- package/dist/admin/components/views/Versions/index.js +1 -1
- package/dist/admin/components/views/collections/Edit/Default.js +2 -0
- package/dist/admin/components/views/collections/Edit/SetStepNav.d.ts +7 -0
- package/dist/admin/components/views/collections/Edit/SetStepNav.js +31 -0
- package/dist/admin/components/views/collections/Edit/index.js +2 -36
- package/dist/admin/components/views/collections/Edit/index.scss +19 -4
- package/dist/admin/hooks/usePayloadAPI.js +3 -1
- package/dist/collections/buildSchema.js +5 -1
- package/dist/collections/config/types.d.ts +16 -3
- package/dist/collections/operations/find.js +11 -6
- package/dist/collections/operations/findVersions.js +4 -5
- package/dist/collections/operations/update.js +8 -9
- package/dist/collections/requestHandlers/find.js +4 -3
- package/dist/collections/requestHandlers/update.js +3 -3
- package/dist/config/schema.js +2 -2
- package/dist/config/types.d.ts +269 -6
- package/dist/config/types.js +1 -1
- package/dist/email/build.js +2 -2
- package/dist/express/types.d.ts +26 -2
- package/dist/fields/config/sanitize.spec.js +5 -5
- package/dist/fields/config/types.d.ts +3 -3
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js +73 -21
- package/dist/fields/hooks/beforeChange/promise.js +7 -1
- package/dist/globals/operations/findVersions.js +4 -5
- package/dist/globals/operations/update.js +4 -4
- package/dist/globals/requestHandlers/update.js +3 -3
- package/dist/graphql/schema/fieldToWhereInputSchemaMap.js +7 -7
- package/dist/graphql/schema/operators.d.ts +1 -0
- package/dist/graphql/schema/operators.js +2 -1
- package/dist/mongoose/types.d.ts +3 -3
- package/dist/translations/de.json +100 -100
- package/dist/translations/en.json +3 -1
- package/dist/translations/es.json +1 -1
- package/dist/translations/fr.json +1 -1
- package/dist/translations/index.d.ts +5 -0
- package/dist/translations/it.json +19 -16
- package/dist/translations/my.json +1 -1
- package/dist/translations/nl.json +1 -1
- package/dist/translations/pl.json +1 -1
- package/dist/translations/pt.json +1 -1
- package/dist/translations/ru.json +1 -1
- package/dist/translations/sv.json +1 -1
- package/dist/translations/vi.json +1 -1
- package/dist/utilities/isNumber.d.ts +1 -0
- package/dist/utilities/isNumber.js +8 -0
- package/dist/versions/drafts/saveCollectionDraft.js +4 -3
- package/dist/versions/drafts/saveGlobalDraft.js +4 -3
- package/dist/versions/ensurePublishedCollectionVersion.js +2 -1
- package/dist/versions/ensurePublishedGlobalVersion.js +2 -1
- package/dist/versions/getLatestCollectionVersion.d.ts +10 -0
- package/dist/versions/getLatestCollectionVersion.js +27 -0
- package/dist/versions/getLatestGlobalVersion.d.ts +10 -0
- package/dist/versions/getLatestGlobalVersion.js +27 -0
- package/docs/admin/components.mdx +1 -5
- package/docs/authentication/config.mdx +1 -1
- package/docs/configuration/globals.mdx +12 -12
- package/docs/configuration/i18n.mdx +1 -1
- package/docs/fields/array.mdx +14 -14
- package/docs/fields/blocks.mdx +1 -1
- package/docs/fields/checkbox.mdx +2 -2
- package/docs/fields/code.mdx +1 -1
- package/docs/fields/date.mdx +1 -1
- package/docs/fields/email.mdx +1 -1
- package/docs/fields/number.mdx +1 -1
- package/docs/fields/radio.mdx +1 -1
- package/docs/fields/relationship.mdx +1 -1
- package/docs/fields/rich-text.mdx +1 -1
- package/docs/fields/select.mdx +2 -2
- package/docs/fields/text.mdx +2 -2
- package/docs/fields/textarea.mdx +1 -1
- package/docs/fields/upload.mdx +51 -17
- package/docs/production/preventing-abuse.mdx +6 -6
- package/package.json +3 -2
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
@import '../../../../scss/styles.scss';
|
|
2
2
|
|
|
3
|
-
.field
|
|
3
|
+
.code-field {
|
|
4
4
|
position: relative;
|
|
5
5
|
margin-bottom: $baseline;
|
|
6
6
|
|
|
7
|
+
&__input {
|
|
8
|
+
@include formInput();
|
|
9
|
+
height: unset;
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
&.error {
|
|
8
13
|
textarea {
|
|
9
14
|
border: 1px solid var(--theme-error-500) !important;
|
|
@@ -47,110 +52,204 @@ pre[class*="language-"] {
|
|
|
47
52
|
border-radius: 0.3em;
|
|
48
53
|
}
|
|
49
54
|
|
|
50
|
-
:not(pre)>code[class*="language-"],
|
|
51
|
-
pre[class*="language-"] {
|
|
52
|
-
background: var(--theme-base-100);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
55
|
/* Inline code */
|
|
56
56
|
:not(pre)>code[class*="language-"] {
|
|
57
57
|
padding: 0.1em;
|
|
58
58
|
border-radius: 0.3em;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
.token.comment,
|
|
62
|
-
.token.prolog,
|
|
63
|
-
.token.doctype,
|
|
64
|
-
.token.cdata {
|
|
65
|
-
color: #7c7c7c;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.token.punctuation {
|
|
69
|
-
color: #c5c8c6;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
61
|
.namespace {
|
|
73
62
|
opacity: 0.7;
|
|
74
63
|
}
|
|
75
64
|
|
|
76
|
-
.token.
|
|
77
|
-
.token.
|
|
78
|
-
|
|
79
|
-
color: #96cbfe;
|
|
65
|
+
.token.important,
|
|
66
|
+
.token.bold {
|
|
67
|
+
font-weight: bold;
|
|
80
68
|
}
|
|
81
69
|
|
|
82
|
-
.token.
|
|
83
|
-
|
|
84
|
-
text-decoration: underline;
|
|
70
|
+
.token.italic {
|
|
71
|
+
font-style: italic;
|
|
85
72
|
}
|
|
86
73
|
|
|
87
|
-
|
|
88
|
-
.token.constant {
|
|
89
|
-
color: #99cc99;
|
|
90
|
-
}
|
|
74
|
+
// DARK
|
|
91
75
|
|
|
92
|
-
|
|
93
|
-
.token.deleted {
|
|
94
|
-
color: #f92672;
|
|
95
|
-
}
|
|
76
|
+
html[data-theme=dark] {
|
|
96
77
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
78
|
+
:not(pre)>code[class*="language-"],
|
|
79
|
+
pre[class*="language-"] {
|
|
80
|
+
background: var(--theme-base-100);
|
|
81
|
+
}
|
|
100
82
|
|
|
101
|
-
.token.
|
|
102
|
-
.token.
|
|
103
|
-
.token.
|
|
104
|
-
.token.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
color: #a8ff60;
|
|
108
|
-
}
|
|
83
|
+
.token.comment,
|
|
84
|
+
.token.prolog,
|
|
85
|
+
.token.doctype,
|
|
86
|
+
.token.cdata {
|
|
87
|
+
color: #7c7c7c;
|
|
88
|
+
}
|
|
109
89
|
|
|
110
|
-
.token.
|
|
111
|
-
|
|
112
|
-
}
|
|
90
|
+
.token.punctuation {
|
|
91
|
+
color: #c5c8c6;
|
|
92
|
+
}
|
|
113
93
|
|
|
114
|
-
.token.
|
|
115
|
-
|
|
116
|
-
|
|
94
|
+
.token.property,
|
|
95
|
+
.token.keyword,
|
|
96
|
+
.token.tag {
|
|
97
|
+
color: #96cbfe;
|
|
98
|
+
}
|
|
117
99
|
|
|
118
|
-
.token.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
100
|
+
.token.class-name {
|
|
101
|
+
color: #ffffb6;
|
|
102
|
+
text-decoration: underline;
|
|
103
|
+
}
|
|
122
104
|
|
|
123
|
-
.token.
|
|
124
|
-
|
|
125
|
-
|
|
105
|
+
.token.boolean,
|
|
106
|
+
.token.constant {
|
|
107
|
+
color: #99cc99;
|
|
108
|
+
}
|
|
126
109
|
|
|
127
|
-
.
|
|
128
|
-
.
|
|
129
|
-
|
|
130
|
-
}
|
|
110
|
+
.token.symbol,
|
|
111
|
+
.token.deleted {
|
|
112
|
+
color: #f92672;
|
|
113
|
+
}
|
|
131
114
|
|
|
132
|
-
.token.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
115
|
+
.token.number {
|
|
116
|
+
color: #ff73fd;
|
|
117
|
+
}
|
|
136
118
|
|
|
137
|
-
.token.
|
|
138
|
-
|
|
139
|
-
|
|
119
|
+
.token.selector,
|
|
120
|
+
.token.attr-name,
|
|
121
|
+
.token.string,
|
|
122
|
+
.token.char,
|
|
123
|
+
.token.builtin,
|
|
124
|
+
.token.inserted {
|
|
125
|
+
color: #a8ff60;
|
|
126
|
+
}
|
|
140
127
|
|
|
141
|
-
.token.
|
|
142
|
-
|
|
143
|
-
}
|
|
128
|
+
.token.variable {
|
|
129
|
+
color: #c6c5fe;
|
|
130
|
+
}
|
|
144
131
|
|
|
145
|
-
.token.
|
|
146
|
-
|
|
147
|
-
}
|
|
132
|
+
.token.operator {
|
|
133
|
+
color: #ededed;
|
|
134
|
+
}
|
|
148
135
|
|
|
149
|
-
.token.
|
|
150
|
-
|
|
151
|
-
|
|
136
|
+
.token.entity {
|
|
137
|
+
color: #ffffb6;
|
|
138
|
+
cursor: help;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.token.url {
|
|
142
|
+
color: #96cbfe;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.language-css .token.string,
|
|
146
|
+
.style .token.string {
|
|
147
|
+
color: #87c38a;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.token.atrule,
|
|
151
|
+
.token.attr-value {
|
|
152
|
+
color: #f9ee98;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.token.function {
|
|
156
|
+
color: #dad085;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.token.regex {
|
|
160
|
+
color: #e9c062;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.token.important {
|
|
164
|
+
color: #fd971f;
|
|
165
|
+
}
|
|
152
166
|
}
|
|
153
167
|
|
|
154
|
-
|
|
155
|
-
|
|
168
|
+
// LIGHT
|
|
169
|
+
|
|
170
|
+
html[data-theme=light] {
|
|
171
|
+
|
|
172
|
+
.token.comment,
|
|
173
|
+
.token.prolog,
|
|
174
|
+
.token.doctype,
|
|
175
|
+
.token.cdata {
|
|
176
|
+
color: #666666;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.token.punctuation {
|
|
180
|
+
color: #797979;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.token.property,
|
|
184
|
+
.token.keyword,
|
|
185
|
+
.token.tag {
|
|
186
|
+
color: #0167c5;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.token.class-name {
|
|
190
|
+
color: #b2ac00;
|
|
191
|
+
text-decoration: underline;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.token.boolean,
|
|
195
|
+
.token.constant {
|
|
196
|
+
color: #008600;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.token.symbol,
|
|
200
|
+
.token.deleted {
|
|
201
|
+
color: #ab003f;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.token.number {
|
|
205
|
+
color: #970195;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.token.selector,
|
|
209
|
+
.token.attr-name,
|
|
210
|
+
.token.string,
|
|
211
|
+
.token.char,
|
|
212
|
+
.token.builtin,
|
|
213
|
+
.token.inserted {
|
|
214
|
+
color: #418c03;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.token.variable {
|
|
218
|
+
color: #4643e3;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.token.operator {
|
|
222
|
+
color: #3c3c3c;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.token.entity {
|
|
226
|
+
color: #b2ac00;
|
|
227
|
+
cursor: help;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.token.url {
|
|
231
|
+
color: #0084ff;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.language-css .token.string,
|
|
235
|
+
.style .token.string {
|
|
236
|
+
color: #386b3a;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.token.atrule,
|
|
240
|
+
.token.attr-value {
|
|
241
|
+
color: #b5a108;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.token.function {
|
|
245
|
+
color: #8c1aea;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.token.regex {
|
|
249
|
+
color: #e5a205;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.token.important {
|
|
253
|
+
color: #ac0900;
|
|
254
|
+
}
|
|
156
255
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FilterOptions } from '../../../../../../fields/config/types';
|
|
2
|
+
import { FilterOptionsResult } from '../types';
|
|
3
|
+
declare type Args = {
|
|
4
|
+
filterOptions: FilterOptions;
|
|
5
|
+
filterOptionsResult: FilterOptionsResult;
|
|
6
|
+
setFilterOptionsResult: (optionFilters: FilterOptionsResult) => void;
|
|
7
|
+
relationTo: string | string[];
|
|
8
|
+
path: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const GetFilterOptions: ({ filterOptions, filterOptionsResult, setFilterOptionsResult, relationTo, path, }: Args) => null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import equal from 'deep-equal';
|
|
3
|
+
import { useAuth } from '../../../../utilities/Auth';
|
|
4
|
+
import { useDocumentInfo } from '../../../../utilities/DocumentInfo';
|
|
5
|
+
import { useAllFormFields } from '../../../Form/context';
|
|
6
|
+
import { getFilterOptionsQuery } from '../../getFilterOptionsQuery';
|
|
7
|
+
import reduceFieldsToValues from '../../../Form/reduceFieldsToValues';
|
|
8
|
+
import getSiblingData from '../../../Form/getSiblingData';
|
|
9
|
+
export const GetFilterOptions = ({ filterOptions, filterOptionsResult, setFilterOptionsResult, relationTo, path, }) => {
|
|
10
|
+
const [fields] = useAllFormFields();
|
|
11
|
+
const { id } = useDocumentInfo();
|
|
12
|
+
const { user } = useAuth();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const data = reduceFieldsToValues(fields);
|
|
15
|
+
const siblingData = getSiblingData(fields, path);
|
|
16
|
+
const newFilterOptionsResult = getFilterOptionsQuery(filterOptions, {
|
|
17
|
+
id,
|
|
18
|
+
data,
|
|
19
|
+
relationTo,
|
|
20
|
+
siblingData,
|
|
21
|
+
user,
|
|
22
|
+
});
|
|
23
|
+
if (!equal(newFilterOptionsResult, filterOptionsResult)) {
|
|
24
|
+
setFilterOptionsResult(newFilterOptionsResult);
|
|
25
|
+
}
|
|
26
|
+
}, [
|
|
27
|
+
fields,
|
|
28
|
+
filterOptions,
|
|
29
|
+
id,
|
|
30
|
+
relationTo,
|
|
31
|
+
user,
|
|
32
|
+
path,
|
|
33
|
+
filterOptionsResult,
|
|
34
|
+
setFilterOptionsResult,
|
|
35
|
+
]);
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Option } from '../../../elements/ReactSelect/types';
|
|
2
|
+
import { OptionGroup, Value } from './types';
|
|
3
|
+
declare type Args = {
|
|
4
|
+
value: Value | Value[];
|
|
5
|
+
options: OptionGroup[];
|
|
6
|
+
};
|
|
7
|
+
export declare const findOptionsByValue: ({ value, options }: Args) => Option | Option[];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const findOptionsByValue = ({ value, options }) => {
|
|
2
|
+
if (value) {
|
|
3
|
+
if (Array.isArray(value)) {
|
|
4
|
+
return value.map((val) => {
|
|
5
|
+
let matchedOption;
|
|
6
|
+
options.forEach((optGroup) => {
|
|
7
|
+
matchedOption = optGroup.options.find((option) => {
|
|
8
|
+
if (typeof val === 'object') {
|
|
9
|
+
return option.value === val.value && option.relationTo === val.relationTo;
|
|
10
|
+
}
|
|
11
|
+
return val === option.value;
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
return matchedOption;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
let matchedOption;
|
|
18
|
+
options.forEach((optGroup) => {
|
|
19
|
+
matchedOption = optGroup.options.find((option) => {
|
|
20
|
+
if (typeof value === 'object') {
|
|
21
|
+
return option.value === value.value && option.relationTo === value.relationTo;
|
|
22
|
+
}
|
|
23
|
+
return value === option.value;
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
return matchedOption;
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
};
|