payload 0.11.1-beta.0 → 0.12.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 +19 -0
- package/components/forms.ts +2 -0
- package/dist/fields/accessPromise.js +2 -5
- package/docs/fields/overview.mdx +32 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [0.12.0](https://github.com/payloadcms/payload/compare/v0.11.0...v0.12.0) (2021-10-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bug where field hooks and access control couuld potentially compete ([c35009f](https://github.com/payloadcms/payload/commit/c35009f14c9403e63727d4d77af51a449a5f7b4b))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* builds UI field ([edb723a](https://github.com/payloadcms/payload/commit/edb723a4fb8b4c353a9073cc7ec5f5cfd026cbe0))
|
|
12
|
+
* exposes withCondition for re-use ([c02e8f1](https://github.com/payloadcms/payload/commit/c02e8f14c74a2ab9a53b0d8fd81f1083bede594e))
|
|
13
|
+
|
|
14
|
+
## [0.11.2-beta.0](https://github.com/payloadcms/payload/compare/v0.11.0...v0.11.2-beta.0) (2021-10-21)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* exposes withCondition for re-use ([c02e8f1](https://github.com/payloadcms/payload/commit/c02e8f14c74a2ab9a53b0d8fd81f1083bede594e))
|
|
19
|
+
|
|
1
20
|
## [0.11.1-beta.0](https://github.com/payloadcms/payload/compare/v0.11.0...v0.11.1-beta.0) (2021-10-20)
|
|
2
21
|
|
|
3
22
|
|
package/components/forms.ts
CHANGED
|
@@ -18,3 +18,5 @@ export { default as Submit } from '../dist/admin/components/forms/Submit';
|
|
|
18
18
|
export { default as Label } from '../dist/admin/components/forms/Label';
|
|
19
19
|
|
|
20
20
|
export { default as reduceFieldsToValues } from '../dist/admin/components/forms/Form/reduceFieldsToValues';
|
|
21
|
+
|
|
22
|
+
export { default as withCondition } from '../dist/admin/components/forms/withCondition';
|
|
@@ -18,10 +18,7 @@ const accessPromise = async ({ data, fullData, originalDoc, field, operation, ov
|
|
|
18
18
|
}
|
|
19
19
|
if (field.access && field.access[accessOperation]) {
|
|
20
20
|
const result = overrideAccess ? true : await field.access[accessOperation]({ req, id, siblingData: data, data: fullData });
|
|
21
|
-
if (!result
|
|
22
|
-
resultingData[field.name] = originalDoc[field.name];
|
|
23
|
-
}
|
|
24
|
-
else if (!result) {
|
|
21
|
+
if (!result) {
|
|
25
22
|
delete resultingData[field.name];
|
|
26
23
|
}
|
|
27
24
|
}
|
|
@@ -38,4 +35,4 @@ const accessPromise = async ({ data, fullData, originalDoc, field, operation, ov
|
|
|
38
35
|
}
|
|
39
36
|
};
|
|
40
37
|
exports.default = accessPromise;
|
|
41
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjZXNzUHJvbWlzZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9maWVsZHMvYWNjZXNzUHJvbWlzZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUVBLG9HQUE0RTtBQW9CNUUsTUFBTSxhQUFhLEdBQUcsS0FBSyxFQUFFLEVBQzNCLElBQUksRUFDSixRQUFRLEVBQ1IsV0FBVyxFQUNYLEtBQUssRUFDTCxTQUFTLEVBQ1QsY0FBYyxFQUNkLEdBQUcsRUFDSCxFQUFFLEVBQ0YsdUJBQXVCLEVBQ3ZCLEtBQUssRUFDTCxZQUFZLEVBQ1osSUFBSSxFQUNKLE9BQU8sR0FDRyxFQUFpQixFQUFFO0lBQzdCLE1BQU0sYUFBYSxHQUFHLElBQUksQ0FBQztJQUUzQixJQUFJLGVBQWUsQ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RUYsa0JBQWUsYUFBYSxDQUFDIn0=
|
package/docs/fields/overview.mdx
CHANGED
|
@@ -50,6 +50,7 @@ const Pages = {
|
|
|
50
50
|
- [Text](/docs/fields/text) - simple text input
|
|
51
51
|
- [Textarea](/docs/fields/textarea) - allows a bit larger of a text editor
|
|
52
52
|
- [Upload](/docs/fields/upload) - allows local file and image upload
|
|
53
|
+
- [UI](/docs/fields/ui) - inject your own custom components and do whatever you need
|
|
53
54
|
|
|
54
55
|
### Field-level hooks
|
|
55
56
|
|
|
@@ -117,6 +118,10 @@ In addition to each field's base configuration, you can define specific traits a
|
|
|
117
118
|
| `disabled` | If a field is `disabled`, it is completely omitted from the Admin panel. |
|
|
118
119
|
| `hidden` | Setting a field's `hidden` property on its `admin` config will transform it into a `hidden` input type. Its value will still submit with the Admin panel's requests, but the field itself will not be visible to editors. |
|
|
119
120
|
|
|
121
|
+
### Custom components
|
|
122
|
+
|
|
123
|
+
All Payload fields support the ability to swap in your own React components with ease. For more information, including examples, [click here](/docs/admin/components#fields).
|
|
124
|
+
|
|
120
125
|
### Conditional logic
|
|
121
126
|
|
|
122
127
|
You can show and hide fields based on what other fields are doing by utilizing conditional logic on a field by field basis. The `condition` property on a field's admin config accepts a function which takes two arguments:
|
|
@@ -155,9 +160,34 @@ The `condition` function should return a boolean that will control if the field
|
|
|
155
160
|
}
|
|
156
161
|
```
|
|
157
162
|
|
|
158
|
-
|
|
163
|
+
If you are building custom components, and you'd like for your custom components to support conditional logic as well, you can utilize Payload's `withCondition` higher-order function by importing it and using it as follows:
|
|
159
164
|
|
|
160
|
-
|
|
165
|
+
```js
|
|
166
|
+
import { withCondition } from 'payload/components/forms';
|
|
167
|
+
|
|
168
|
+
const CustomComponent = () => {
|
|
169
|
+
return (
|
|
170
|
+
<div>
|
|
171
|
+
<p>Hello, on my own, I won't respect my field's conditional logic.<p/>
|
|
172
|
+
<p>But, I will if I'm wrapped with the withCondition HOC as shown below!</p>
|
|
173
|
+
</div>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const CustomComponentWithCondition = withCondition(CustomComponent);
|
|
178
|
+
|
|
179
|
+
const customFieldWithCondition = {
|
|
180
|
+
name: 'myCustomField',
|
|
181
|
+
type: 'text',
|
|
182
|
+
admin: {
|
|
183
|
+
condition: (data) => Boolean(data.enableCustomField),
|
|
184
|
+
components: {
|
|
185
|
+
Field: CustomComponentWithCondition,
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
```
|
|
161
191
|
|
|
162
192
|
### Description
|
|
163
193
|
|