payload 1.2.1 → 1.2.3

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.
Files changed (109) hide show
  1. package/CHANGELOG.md +47 -2
  2. package/components/fields/Array.ts +1 -2
  3. package/components/fields/Blocks.ts +1 -2
  4. package/components/fields/Cell.ts +1 -1
  5. package/components/fields/Checkbox.ts +1 -2
  6. package/components/fields/Code.ts +1 -2
  7. package/components/fields/DateTime.ts +1 -2
  8. package/components/fields/Email.ts +1 -2
  9. package/components/fields/Group.ts +1 -2
  10. package/components/fields/Number.ts +1 -2
  11. package/components/fields/Password.ts +1 -2
  12. package/components/fields/RadioGroup/RadioInput.ts +1 -2
  13. package/components/fields/RadioGroup/index.ts +1 -2
  14. package/components/fields/Relationship.ts +1 -2
  15. package/components/fields/RichText.ts +1 -2
  16. package/components/fields/Row.ts +1 -2
  17. package/components/fields/Select.ts +1 -2
  18. package/components/fields/Text.ts +1 -2
  19. package/components/fields/Textarea.ts +1 -2
  20. package/components/fields/Upload.ts +1 -2
  21. package/components/views/Cell.ts +1 -2
  22. package/components/views/Edit.ts +1 -2
  23. package/components/views/List.ts +1 -2
  24. package/dist/admin/components/elements/ReactSelect/index.js +3 -3
  25. package/dist/admin/components/elements/ReactSelect/types.d.ts +11 -10
  26. package/dist/admin/components/elements/Status/index.js +1 -1
  27. package/dist/admin/components/forms/Form/context.d.ts +15 -0
  28. package/dist/admin/components/forms/Form/context.js +16 -1
  29. package/dist/admin/components/forms/field-types/Blocks/SectionTitle/index.scss +3 -2
  30. package/dist/admin/components/forms/field-types/Blocks/index.js +1 -1
  31. package/dist/admin/components/forms/field-types/Code/Code.js +3 -4
  32. package/dist/admin/components/forms/field-types/Code/index.scss +177 -78
  33. package/dist/admin/components/forms/field-types/Relationship/AddNew/index.js +0 -1
  34. package/dist/admin/components/forms/field-types/Relationship/GetFilterOptions/index.d.ts +11 -0
  35. package/dist/admin/components/forms/field-types/Relationship/GetFilterOptions/index.js +37 -0
  36. package/dist/admin/components/forms/field-types/Relationship/findOptionsByValue.d.ts +8 -0
  37. package/dist/admin/components/forms/field-types/Relationship/findOptionsByValue.js +29 -0
  38. package/dist/admin/components/forms/field-types/Relationship/index.js +89 -139
  39. package/dist/admin/components/forms/field-types/Relationship/optionsReducer.d.ts +2 -2
  40. package/dist/admin/components/forms/field-types/Relationship/optionsReducer.js +2 -29
  41. package/dist/admin/components/forms/field-types/Relationship/types.d.ts +14 -2
  42. package/dist/admin/components/forms/field-types/RichText/elements/link/Element.js +3 -3
  43. package/dist/admin/components/forms/field-types/RichText/elements/link/index.scss +2 -1
  44. package/dist/admin/components/forms/field-types/RichText/elements/upload/Button/index.js +1 -1
  45. package/dist/admin/components/forms/field-types/Row/index.js +1 -1
  46. package/dist/admin/components/forms/field-types/Select/Input.d.ts +2 -2
  47. package/dist/admin/components/forms/useField/index.d.ts +5 -0
  48. package/dist/admin/components/forms/useField/index.js +5 -0
  49. package/dist/admin/components/utilities/I18n/index.js +1 -1
  50. package/dist/admin/components/views/Account/Default.js +1 -1
  51. package/dist/admin/components/views/Global/index.scss +31 -24
  52. package/dist/admin/components/views/collections/Edit/Auth/index.js +1 -1
  53. package/dist/admin/components/views/collections/Edit/index.scss +19 -4
  54. package/dist/collections/buildSchema.js +5 -1
  55. package/dist/collections/config/types.d.ts +16 -3
  56. package/dist/collections/operations/find.js +11 -6
  57. package/dist/collections/operations/findVersions.js +4 -5
  58. package/dist/collections/operations/update.js +13 -11
  59. package/dist/collections/requestHandlers/find.js +4 -3
  60. package/dist/config/schema.js +2 -2
  61. package/dist/config/types.d.ts +269 -6
  62. package/dist/config/types.js +1 -1
  63. package/dist/email/build.js +2 -2
  64. package/dist/express/types.d.ts +26 -2
  65. package/dist/fields/config/sanitize.spec.js +5 -5
  66. package/dist/fields/config/types.d.ts +3 -3
  67. package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js +73 -21
  68. package/dist/globals/operations/findVersions.js +4 -5
  69. package/dist/globals/operations/update.js +4 -4
  70. package/dist/graphql/schema/fieldToWhereInputSchemaMap.js +7 -7
  71. package/dist/graphql/schema/operators.d.ts +1 -0
  72. package/dist/graphql/schema/operators.js +2 -1
  73. package/dist/mongoose/types.d.ts +3 -3
  74. package/dist/translations/de.json +100 -100
  75. package/dist/translations/en.json +1 -1
  76. package/dist/translations/es.json +1 -1
  77. package/dist/translations/fr.json +1 -1
  78. package/dist/translations/it.json +1 -1
  79. package/dist/translations/my.json +1 -1
  80. package/dist/translations/nl.json +1 -1
  81. package/dist/translations/pl.json +1 -1
  82. package/dist/translations/pt.json +1 -1
  83. package/dist/translations/ru.json +1 -1
  84. package/dist/translations/sv.json +1 -1
  85. package/dist/translations/vi.json +1 -1
  86. package/dist/utilities/isNumber.d.ts +1 -0
  87. package/dist/utilities/isNumber.js +8 -0
  88. package/dist/versions/getLatestCollectionVersion.d.ts +11 -0
  89. package/dist/versions/getLatestCollectionVersion.js +27 -0
  90. package/dist/versions/getLatestGlobalVersion.d.ts +10 -0
  91. package/dist/versions/getLatestGlobalVersion.js +27 -0
  92. package/docs/admin/components.mdx +1 -5
  93. package/docs/configuration/globals.mdx +12 -12
  94. package/docs/fields/array.mdx +14 -14
  95. package/docs/fields/blocks.mdx +1 -1
  96. package/docs/fields/checkbox.mdx +2 -2
  97. package/docs/fields/code.mdx +1 -1
  98. package/docs/fields/date.mdx +1 -1
  99. package/docs/fields/email.mdx +1 -1
  100. package/docs/fields/number.mdx +1 -1
  101. package/docs/fields/radio.mdx +1 -1
  102. package/docs/fields/relationship.mdx +1 -1
  103. package/docs/fields/rich-text.mdx +1 -1
  104. package/docs/fields/select.mdx +2 -2
  105. package/docs/fields/text.mdx +2 -2
  106. package/docs/fields/textarea.mdx +1 -1
  107. package/docs/fields/upload.mdx +51 -17
  108. package/docs/production/preventing-abuse.mdx +6 -6
  109. package/package.json +3 -2
@@ -1,9 +1,14 @@
1
1
  @import '../../../../scss/styles.scss';
2
2
 
3
- .field-type.code {
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.property,
77
- .token.keyword,
78
- .token.tag {
79
- color: #96cbfe;
65
+ .token.important,
66
+ .token.bold {
67
+ font-weight: bold;
80
68
  }
81
69
 
82
- .token.class-name {
83
- color: #ffffb6;
84
- text-decoration: underline;
70
+ .token.italic {
71
+ font-style: italic;
85
72
  }
86
73
 
87
- .token.boolean,
88
- .token.constant {
89
- color: #99cc99;
90
- }
74
+ // DARK
91
75
 
92
- .token.symbol,
93
- .token.deleted {
94
- color: #f92672;
95
- }
76
+ html[data-theme=dark] {
96
77
 
97
- .token.number {
98
- color: #ff73fd;
99
- }
78
+ :not(pre)>code[class*="language-"],
79
+ pre[class*="language-"] {
80
+ background: var(--theme-base-100);
81
+ }
100
82
 
101
- .token.selector,
102
- .token.attr-name,
103
- .token.string,
104
- .token.char,
105
- .token.builtin,
106
- .token.inserted {
107
- color: #a8ff60;
108
- }
83
+ .token.comment,
84
+ .token.prolog,
85
+ .token.doctype,
86
+ .token.cdata {
87
+ color: #7c7c7c;
88
+ }
109
89
 
110
- .token.variable {
111
- color: #c6c5fe;
112
- }
90
+ .token.punctuation {
91
+ color: #c5c8c6;
92
+ }
113
93
 
114
- .token.operator {
115
- color: #ededed;
116
- }
94
+ .token.property,
95
+ .token.keyword,
96
+ .token.tag {
97
+ color: #96cbfe;
98
+ }
117
99
 
118
- .token.entity {
119
- color: #ffffb6;
120
- cursor: help;
121
- }
100
+ .token.class-name {
101
+ color: #ffffb6;
102
+ text-decoration: underline;
103
+ }
122
104
 
123
- .token.url {
124
- color: #96cbfe;
125
- }
105
+ .token.boolean,
106
+ .token.constant {
107
+ color: #99cc99;
108
+ }
126
109
 
127
- .language-css .token.string,
128
- .style .token.string {
129
- color: #87c38a;
130
- }
110
+ .token.symbol,
111
+ .token.deleted {
112
+ color: #f92672;
113
+ }
131
114
 
132
- .token.atrule,
133
- .token.attr-value {
134
- color: #f9ee98;
135
- }
115
+ .token.number {
116
+ color: #ff73fd;
117
+ }
136
118
 
137
- .token.function {
138
- color: #dad085;
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.regex {
142
- color: #e9c062;
143
- }
128
+ .token.variable {
129
+ color: #c6c5fe;
130
+ }
144
131
 
145
- .token.important {
146
- color: #fd971f;
147
- }
132
+ .token.operator {
133
+ color: #ededed;
134
+ }
148
135
 
149
- .token.important,
150
- .token.bold {
151
- font-weight: bold;
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
- .token.italic {
155
- font-style: italic;
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
  }
@@ -32,7 +32,6 @@ export const AddNewRelation = ({ path, hasMany, relationTo, value, setValue, dis
32
32
  } : json.doc.id;
33
33
  dispatchOptions({
34
34
  type: 'ADD',
35
- hasMultipleRelations: Array.isArray(relationTo),
36
35
  collection: modalCollection,
37
36
  docs: [
38
37
  json.doc,
@@ -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
+ };