payload 1.0.27 → 1.0.30

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 (100) hide show
  1. package/CHANGELOG.md +36 -4
  2. package/dist/admin/components/elements/Status/index.js +1 -1
  3. package/dist/admin/components/elements/ViewDescription/types.d.ts +1 -1
  4. package/dist/admin/components/elements/WhereBuilder/index.js +3 -1
  5. package/dist/admin/components/forms/field-types/Array/index.d.ts +3 -2
  6. package/dist/admin/components/forms/field-types/Array/index.js +201 -6
  7. package/dist/admin/components/forms/field-types/Blocks/index.d.ts +3 -2
  8. package/dist/admin/components/forms/field-types/Blocks/index.js +213 -6
  9. package/dist/admin/components/forms/field-types/Collapsible/index.js +2 -2
  10. package/dist/admin/components/forms/field-types/Row/index.js +2 -2
  11. package/dist/admin/components/forms/field-types/Tabs/index.js +2 -2
  12. package/dist/admin/components/forms/field-types/getFieldPath.d.ts +2 -0
  13. package/dist/admin/components/forms/field-types/getFieldPath.js +6 -0
  14. package/dist/admin/components/forms/field-types/index.d.ts +23 -23
  15. package/dist/admin/components/utilities/RenderCustomComponent/types.d.ts +2 -2
  16. package/dist/admin/components/views/collections/List/Cell/field-types/Relationship/index.js +1 -1
  17. package/dist/auth/operations/local/forgotPassword.js +3 -6
  18. package/dist/auth/operations/local/login.js +6 -9
  19. package/dist/auth/operations/local/resetPassword.js +4 -7
  20. package/dist/auth/operations/local/unlock.js +4 -7
  21. package/dist/collections/buildSchema.js +2 -1
  22. package/dist/collections/config/types.d.ts +2 -2
  23. package/dist/collections/dataloader.js +16 -8
  24. package/dist/collections/operations/local/create.d.ts +2 -2
  25. package/dist/collections/operations/local/create.js +11 -13
  26. package/dist/collections/operations/local/find.js +6 -10
  27. package/dist/collections/operations/local/findByID.js +6 -10
  28. package/dist/collections/operations/local/findVersionByID.js +6 -9
  29. package/dist/config/types.d.ts +13 -13
  30. package/dist/fields/config/sanitize.js +3 -3
  31. package/dist/fields/config/schema.js +3 -3
  32. package/dist/fields/config/types.d.ts +9 -9
  33. package/dist/fields/validations.js +43 -1
  34. package/dist/globals/config/types.d.ts +1 -1
  35. package/dist/mongoose/buildSchema.d.ts +1 -0
  36. package/dist/mongoose/buildSchema.js +3 -3
  37. package/dist/utilities/getIDType.d.ts +2 -0
  38. package/dist/utilities/getIDType.js +11 -0
  39. package/dist/utilities/isValidID.d.ts +1 -0
  40. package/dist/utilities/isValidID.js +16 -0
  41. package/docs/access-control/collections.mdx +21 -12
  42. package/docs/access-control/fields.mdx +5 -3
  43. package/docs/access-control/globals.mdx +8 -4
  44. package/docs/access-control/overview.mdx +1 -1
  45. package/docs/admin/components.mdx +29 -25
  46. package/docs/admin/customizing-css.mdx +2 -2
  47. package/docs/admin/overview.mdx +2 -2
  48. package/docs/admin/webpack.mdx +8 -7
  49. package/docs/authentication/config.mdx +14 -9
  50. package/docs/authentication/operations.mdx +22 -22
  51. package/docs/authentication/overview.mdx +8 -6
  52. package/docs/authentication/using-middleware.mdx +1 -1
  53. package/docs/configuration/collections.mdx +11 -7
  54. package/docs/configuration/globals.mdx +9 -5
  55. package/docs/configuration/localization.mdx +33 -31
  56. package/docs/configuration/overview.mdx +4 -7
  57. package/docs/email/overview.mdx +11 -7
  58. package/docs/fields/array.mdx +6 -5
  59. package/docs/fields/blocks.mdx +6 -4
  60. package/docs/fields/checkbox.mdx +6 -5
  61. package/docs/fields/code.mdx +6 -5
  62. package/docs/fields/collapsible.mdx +6 -5
  63. package/docs/fields/date.mdx +6 -5
  64. package/docs/fields/email.mdx +6 -5
  65. package/docs/fields/group.mdx +6 -5
  66. package/docs/fields/number.mdx +6 -5
  67. package/docs/fields/overview.mdx +40 -38
  68. package/docs/fields/point.mdx +6 -4
  69. package/docs/fields/radio.mdx +5 -3
  70. package/docs/fields/relationship.mdx +21 -21
  71. package/docs/fields/rich-text.mdx +9 -7
  72. package/docs/fields/row.mdx +5 -3
  73. package/docs/fields/select.mdx +4 -3
  74. package/docs/fields/tabs.mdx +5 -3
  75. package/docs/fields/text.mdx +5 -3
  76. package/docs/fields/textarea.mdx +5 -3
  77. package/docs/fields/ui.mdx +5 -3
  78. package/docs/fields/upload.mdx +5 -3
  79. package/docs/getting-started/concepts.mdx +1 -1
  80. package/docs/graphql/extending.mdx +1 -1
  81. package/docs/graphql/overview.mdx +8 -4
  82. package/docs/hooks/collections.mdx +62 -36
  83. package/docs/hooks/fields.mdx +5 -3
  84. package/docs/hooks/globals.mdx +25 -17
  85. package/docs/local-api/overview.mdx +27 -4
  86. package/docs/plugins/overview.mdx +3 -4
  87. package/docs/production/deployment.mdx +1 -1
  88. package/docs/queries/overview.mdx +4 -2
  89. package/docs/queries/pagination.mdx +1 -1
  90. package/docs/rest-api/overview.mdx +4 -2
  91. package/docs/upload/overview.mdx +35 -29
  92. package/docs/versions/autosave.mdx +4 -2
  93. package/docs/versions/drafts.mdx +8 -4
  94. package/docs/versions/overview.mdx +1 -1
  95. package/package.json +1 -1
  96. package/types.d.ts +21 -0
  97. package/dist/admin/components/forms/field-types/Array/Array.d.ts +0 -5
  98. package/dist/admin/components/forms/field-types/Array/Array.js +0 -201
  99. package/dist/admin/components/forms/field-types/Blocks/Blocks.d.ts +0 -5
  100. package/dist/admin/components/forms/field-types/Blocks/Blocks.js +0 -213
@@ -83,11 +83,10 @@ After all plugins are executed, the full config with all plugins will be sanitiz
83
83
 
84
84
  Here is an example for how to automatically add a `lastModifiedBy` field to all Payload collections using a Plugin written in TypeScript.
85
85
 
86
- ```js
87
- import { Config } from 'payload/config';
88
- import { CollectionConfig } from 'payload/dist/collections/config/types';
86
+ ```ts
87
+ import { Config, Plugin } from 'payload/config';
89
88
 
90
- const addLastModified = (incomingConfig: Config): Config => {
89
+ const addLastModified: Plugin = (incomingConfig: Config): Config => {
91
90
  // Find all incoming auth-enabled collections
92
91
  // so we can create a lastModifiedBy relationship field
93
92
  // to all auth collections
@@ -37,7 +37,7 @@ Because _**you**_ are in complete control of who can do what with your data, you
37
37
  Before running in Production, you need to have built a production-ready copy of the Payload Admin panel. To do this, Payload provides the `build` NPM script. You can use it by adding a `script` to your `package.json` file like this:
38
38
 
39
39
  `package.json`:
40
- ```js
40
+ ```json
41
41
  {
42
42
  "name": "project-name-here",
43
43
  "scripts": {
@@ -16,8 +16,10 @@ Payload provides an extremely granular querying language through all APIs. Each
16
16
 
17
17
  For example, say you have a collection as follows:
18
18
 
19
- ```js
20
- const Post = {
19
+ ```ts
20
+ import { CollectionConfig } from 'payload/types';
21
+
22
+ const Post: CollectionConfig = {
21
23
  slug: 'posts',
22
24
  fields: [
23
25
  {
@@ -24,7 +24,7 @@ All collection `find` queries are paginated automatically. Responses are returne
24
24
  | nextPage | `number` of next page, `null` if it doesn't exist |
25
25
 
26
26
  **Example response:**
27
- ```js
27
+ ```json
28
28
  {
29
29
  // Document Array // highlight-line
30
30
  "docs": [
@@ -89,9 +89,11 @@ Each endpoint object needs to have:
89
89
 
90
90
  Example:
91
91
 
92
- ```js
92
+ ```ts
93
+ import { CollectionConfig } from 'payload/types';
94
+
93
95
  // a collection of 'orders' with an additional route for tracking details, reachable at /api/orders/:id/tracking
94
- const Orders = {
96
+ const Orders: CollectionConfig = {
95
97
  slug: 'orders',
96
98
  fields: [ /* ... */ ],
97
99
  // highlight-start
@@ -55,38 +55,40 @@ _An asterisk denotes that a property above is required._
55
55
 
56
56
  **Example Upload collection:**
57
57
 
58
- ```js
59
- const Media = {
60
- slug: "media",
58
+ ```ts
59
+ import { CollectionConfig } from 'payload/types';
60
+
61
+ const Media: CollectionConfig = {
62
+ slug: 'media',
61
63
  upload: {
62
- staticURL: "/media",
63
- staticDir: "media",
64
+ staticURL: '/media',
65
+ staticDir: 'media',
64
66
  imageSizes: [
65
67
  {
66
- name: "thumbnail",
68
+ name: 'thumbnail',
67
69
  width: 400,
68
70
  height: 300,
69
- crop: "centre",
71
+ crop: 'centre',
70
72
  },
71
73
  {
72
- name: "card",
74
+ name: 'card',
73
75
  width: 768,
74
76
  height: 1024,
75
- crop: "centre",
77
+ crop: 'centre',
76
78
  },
77
79
  {
78
- name: "tablet",
80
+ name: 'tablet',
79
81
  width: 1024,
80
82
  // By specifying `null` or leaving a height undefined,
81
83
  // the image will be sized to a certain width,
82
84
  // but it will retain its original aspect ratio
83
85
  // and calculate a height automatically.
84
86
  height: null,
85
- crop: "centre",
87
+ crop: 'centre',
86
88
  },
87
89
  ],
88
- adminThumbnail: "thumbnail",
89
- mimeTypes: ["image/*"],
90
+ adminThumbnail: 'thumbnail',
91
+ mimeTypes: ['image/*'],
90
92
  },
91
93
  };
92
94
  ```
@@ -97,17 +99,17 @@ Payload relies on the [`express-fileupload`](https://www.npmjs.com/package/expre
97
99
 
98
100
  A common example of what you might want to customize within Payload-wide Upload options would be to increase the allowed `fileSize` of uploads sent to Payload:
99
101
 
100
- ```js
101
- import { buildConfig } from "payload/config";
102
+ ```ts
103
+ import { buildConfig } from 'payload/config';
102
104
 
103
105
  export default buildConfig({
104
106
  collections: [
105
107
  {
106
- slug: "media",
108
+ slug: 'media',
107
109
  fields: [
108
110
  {
109
- name: "alt",
110
- type: "text",
111
+ name: 'alt',
112
+ type: 'text',
111
113
  },
112
114
  ],
113
115
  upload: true,
@@ -158,12 +160,14 @@ You can specify how Payload retrieves admin thumbnails for your upload-enabled C
158
160
 
159
161
  **Example custom Admin thumbnail:**
160
162
 
161
- ```js
162
- const Media = {
163
- slug: "media",
163
+ ```ts
164
+ import { CollectionConfig } from 'payload/types';
165
+
166
+ const Media: CollectionConfig = {
167
+ slug: 'media',
164
168
  upload: {
165
- staticURL: "/media",
166
- staticDir: "media",
169
+ staticURL: '/media',
170
+ staticDir: 'media',
167
171
  imageSizes: [
168
172
  // ... image sizes here
169
173
  ],
@@ -191,13 +195,15 @@ Some example values are: `image/*`, `audio/*`, `video/*`, `image/png`, `applicat
191
195
 
192
196
  **Example mimeTypes usage:**
193
197
 
194
- ```js
195
- const Media = {
196
- slug: "media",
198
+ ```ts
199
+ import { CollectionConfig } from 'payload/types';
200
+
201
+ const Media: CollectionConfig = {
202
+ slug: 'media',
197
203
  upload: {
198
- staticURL: "/media",
199
- staticDir: "media",
200
- mimeTypes: ["image/*", "application/pdf"], // highlight-line
204
+ staticURL: '/media',
205
+ staticDir: 'media',
206
+ mimeTypes: ['image/*', 'application/pdf'], // highlight-line
201
207
  },
202
208
  };
203
209
  ```
@@ -25,8 +25,10 @@ Collections and Globals both support the same options for configuring autosave.
25
25
 
26
26
  **Example config with versions, drafts, and autosave enabled:**
27
27
 
28
- ```js
29
- const Pages = {
28
+ ```ts
29
+ import { CollectionConfig } from 'payload/types';
30
+
31
+ const Pages: CollectionConfig = {
30
32
  slug: 'pages',
31
33
  access: {
32
34
  read: ({ req }) => {
@@ -81,8 +81,10 @@ You can use the `read` [Access Control](/docs/access-control/collections#read) m
81
81
 
82
82
  Here is an example that utilizes the `_status` field to require a user to be logged in to retrieve drafts:
83
83
 
84
- ```js
85
- const Pages = {
84
+ ```ts
85
+ import { CollectionConfig } from 'payload/types';
86
+
87
+ const Pages: CollectionConfig = {
86
88
  slug: 'pages',
87
89
  access: {
88
90
  read: ({ req }) => {
@@ -114,8 +116,10 @@ const Pages = {
114
116
 
115
117
  Here is an example for how to write an access control function that grants access to both documents where `_status` is equal to "published" and where `_status` does not exist:
116
118
 
117
- ```js
118
- const Pages = {
119
+ ```ts
120
+ import { CollectionConfig } from 'payload/types';
121
+
122
+ const Pages: CollectionConfig = {
119
123
  slug: 'pages',
120
124
  access: {
121
125
  read: ({ req }) => {
@@ -77,7 +77,7 @@ _slug_versions
77
77
 
78
78
  Each document in this new `versions` collection will store a set of meta properties about the version as well as a _full_ copy of the document. For example, a version's data might look like this for a Collection document:
79
79
 
80
- ```js
80
+ ```json
81
81
  {
82
82
  "_id": "61cf752c19cdf1b1af7b61f1", // a unique ID of this version
83
83
  "parent": "61ce1354091d5b3ffc20ea6e", // the ID of the parent document
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "1.0.27",
3
+ "version": "1.0.30",
4
4
  "description": "Node, React and MongoDB Headless CMS and Application Framework",
5
5
  "license": "MIT",
6
6
  "author": {
package/types.d.ts CHANGED
@@ -34,4 +34,25 @@ export {
34
34
  RichTextCustomElement,
35
35
  RichTextCustomLeaf,
36
36
  Block,
37
+ TextField,
38
+ NumberField,
39
+ EmailField,
40
+ TextareaField,
41
+ CheckboxField,
42
+ DateField,
43
+ BlockField,
44
+ GroupField,
45
+ RadioField,
46
+ RelationshipField,
47
+ ArrayField,
48
+ RichTextField,
49
+ SelectField,
50
+ UploadField,
51
+ CodeField,
52
+ PointField,
53
+ RowField,
54
+ CollapsibleField,
55
+ TabsField,
56
+ UIField,
57
+ Validate,
37
58
  } from './dist/fields/config/types';
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import { Props } from './types';
3
- import './index.scss';
4
- declare const _default: React.FC<Props>;
5
- export default _default;
@@ -1,201 +0,0 @@
1
- import React, { useCallback, useEffect, useReducer, useState } from 'react';
2
- import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
3
- import { useAuth } from '../../../utilities/Auth';
4
- import withCondition from '../../withCondition';
5
- import Button from '../../../elements/Button';
6
- import reducer from '../rowReducer';
7
- import { useForm } from '../../Form/context';
8
- import buildStateFromSchema from '../../Form/buildStateFromSchema';
9
- import useField from '../../useField';
10
- import { useLocale } from '../../../utilities/Locale';
11
- import Error from '../../Error';
12
- import { array } from '../../../../../fields/validations';
13
- import Banner from '../../../elements/Banner';
14
- import FieldDescription from '../../FieldDescription';
15
- import { useDocumentInfo } from '../../../utilities/DocumentInfo';
16
- import { useOperation } from '../../../utilities/OperationProvider';
17
- import { Collapsible } from '../../../elements/Collapsible';
18
- import RenderFields from '../../RenderFields';
19
- import { fieldAffectsData } from '../../../../../fields/config/types';
20
- import { usePreferences } from '../../../utilities/Preferences';
21
- import { ArrayAction } from '../../../elements/ArrayAction';
22
- import { scrollToID } from '../../../../utilities/scrollToID';
23
- import HiddenInput from '../HiddenInput';
24
- import './index.scss';
25
- const baseClass = 'array-field';
26
- const ArrayFieldType = (props) => {
27
- var _a, _b;
28
- const { name, path: pathFromProps, fields, fieldTypes, validate = array, required, maxRows, minRows, permissions, admin: { readOnly, description, condition, className, }, } = props;
29
- const path = pathFromProps || name;
30
- // Handle labeling for Arrays, Global Arrays, and Blocks
31
- const getLabels = (p) => {
32
- if (p === null || p === void 0 ? void 0 : p.labels)
33
- return p.labels;
34
- if (p === null || p === void 0 ? void 0 : p.label)
35
- return { singular: p.label, plural: undefined };
36
- return { singular: 'Row', plural: 'Rows' };
37
- };
38
- const labels = getLabels(props);
39
- // eslint-disable-next-line react/destructuring-assignment
40
- const label = (_a = props === null || props === void 0 ? void 0 : props.label) !== null && _a !== void 0 ? _a : (_b = props === null || props === void 0 ? void 0 : props.labels) === null || _b === void 0 ? void 0 : _b.singular;
41
- const { preferencesKey } = useDocumentInfo();
42
- const { getPreference } = usePreferences();
43
- const { setPreference } = usePreferences();
44
- const [rows, dispatchRows] = useReducer(reducer, undefined);
45
- const formContext = useForm();
46
- const { user } = useAuth();
47
- const { id } = useDocumentInfo();
48
- const locale = useLocale();
49
- const operation = useOperation();
50
- const { dispatchFields } = formContext;
51
- const memoizedValidate = useCallback((value, options) => {
52
- return validate(value, { ...options, minRows, maxRows, required });
53
- }, [maxRows, minRows, required, validate]);
54
- const [disableFormData, setDisableFormData] = useState(false);
55
- const { showError, errorMessage, value, setValue, } = useField({
56
- path,
57
- validate: memoizedValidate,
58
- disableFormData,
59
- condition,
60
- });
61
- const addRow = useCallback(async (rowIndex) => {
62
- const subFieldState = await buildStateFromSchema({ fieldSchema: fields, operation, id, user, locale });
63
- dispatchFields({ type: 'ADD_ROW', rowIndex, subFieldState, path });
64
- dispatchRows({ type: 'ADD', rowIndex });
65
- setValue(value + 1);
66
- setTimeout(() => {
67
- scrollToID(`${path}-row-${rowIndex + 1}`);
68
- }, 0);
69
- }, [dispatchRows, dispatchFields, fields, path, setValue, value, operation, id, user, locale]);
70
- const duplicateRow = useCallback(async (rowIndex) => {
71
- dispatchFields({ type: 'DUPLICATE_ROW', rowIndex, path });
72
- dispatchRows({ type: 'ADD', rowIndex });
73
- setValue(value + 1);
74
- setTimeout(() => {
75
- scrollToID(`${path}-row-${rowIndex + 1}`);
76
- }, 0);
77
- }, [dispatchRows, dispatchFields, path, setValue, value]);
78
- const removeRow = useCallback((rowIndex) => {
79
- dispatchRows({ type: 'REMOVE', rowIndex });
80
- dispatchFields({ type: 'REMOVE_ROW', rowIndex, path });
81
- setValue(value - 1);
82
- }, [dispatchRows, dispatchFields, path, value, setValue]);
83
- const moveRow = useCallback((moveFromIndex, moveToIndex) => {
84
- dispatchRows({ type: 'MOVE', moveFromIndex, moveToIndex });
85
- dispatchFields({ type: 'MOVE_ROW', moveFromIndex, moveToIndex, path });
86
- }, [dispatchRows, dispatchFields, path]);
87
- const onDragEnd = useCallback((result) => {
88
- if (!result.destination)
89
- return;
90
- const sourceIndex = result.source.index;
91
- const destinationIndex = result.destination.index;
92
- moveRow(sourceIndex, destinationIndex);
93
- }, [moveRow]);
94
- const setCollapse = useCallback(async (rowID, collapsed) => {
95
- var _a, _b, _c;
96
- dispatchRows({ type: 'SET_COLLAPSE', id: rowID, collapsed });
97
- if (preferencesKey) {
98
- const preferencesToSet = await getPreference(preferencesKey) || { fields: {} };
99
- let newCollapsedState = ((_b = (_a = preferencesToSet === null || preferencesToSet === void 0 ? void 0 : preferencesToSet.fields) === null || _a === void 0 ? void 0 : _a[path]) === null || _b === void 0 ? void 0 : _b.collapsed.filter((filterID) => (rows.find((row) => row.id === filterID))))
100
- || [];
101
- if (!collapsed) {
102
- newCollapsedState = newCollapsedState.filter((existingID) => existingID !== rowID);
103
- }
104
- else {
105
- newCollapsedState.push(rowID);
106
- }
107
- setPreference(preferencesKey, {
108
- ...preferencesToSet,
109
- fields: {
110
- ...(preferencesToSet === null || preferencesToSet === void 0 ? void 0 : preferencesToSet.fields) || {},
111
- [path]: {
112
- ...(_c = preferencesToSet === null || preferencesToSet === void 0 ? void 0 : preferencesToSet.fields) === null || _c === void 0 ? void 0 : _c[path],
113
- collapsed: newCollapsedState,
114
- },
115
- },
116
- });
117
- }
118
- }, [preferencesKey, path, setPreference, rows, getPreference]);
119
- const toggleCollapseAll = useCallback(async (collapse) => {
120
- var _a;
121
- dispatchRows({ type: 'SET_ALL_COLLAPSED', collapse });
122
- if (preferencesKey) {
123
- const preferencesToSet = await getPreference(preferencesKey) || { fields: {} };
124
- setPreference(preferencesKey, {
125
- ...preferencesToSet,
126
- fields: {
127
- ...(preferencesToSet === null || preferencesToSet === void 0 ? void 0 : preferencesToSet.fields) || {},
128
- [path]: {
129
- ...(_a = preferencesToSet === null || preferencesToSet === void 0 ? void 0 : preferencesToSet.fields) === null || _a === void 0 ? void 0 : _a[path],
130
- collapsed: collapse ? rows.map(({ id: rowID }) => rowID) : [],
131
- },
132
- },
133
- });
134
- }
135
- }, [path, getPreference, preferencesKey, rows, setPreference]);
136
- useEffect(() => {
137
- const initializeRowState = async () => {
138
- var _a, _b;
139
- const data = formContext.getDataByPath(path);
140
- const preferences = await getPreference(preferencesKey) || { fields: {} };
141
- dispatchRows({ type: 'SET_ALL', data: data || [], collapsedState: (_b = (_a = preferences === null || preferences === void 0 ? void 0 : preferences.fields) === null || _a === void 0 ? void 0 : _a[path]) === null || _b === void 0 ? void 0 : _b.collapsed });
142
- };
143
- initializeRowState();
144
- }, [formContext, path, getPreference, preferencesKey]);
145
- useEffect(() => {
146
- setValue((rows === null || rows === void 0 ? void 0 : rows.length) || 0, true);
147
- if ((rows === null || rows === void 0 ? void 0 : rows.length) === 0) {
148
- setDisableFormData(false);
149
- }
150
- else {
151
- setDisableFormData(true);
152
- }
153
- }, [rows, setValue]);
154
- const hasMaxRows = maxRows && (rows === null || rows === void 0 ? void 0 : rows.length) >= maxRows;
155
- const classes = [
156
- 'field-type',
157
- baseClass,
158
- className,
159
- ].filter(Boolean).join(' ');
160
- if (!rows)
161
- return null;
162
- return (React.createElement(DragDropContext, { onDragEnd: onDragEnd },
163
- React.createElement("div", { id: `field-${path.replace(/\./gi, '__')}`, className: classes },
164
- React.createElement("div", { className: `${baseClass}__error-wrap` },
165
- React.createElement(Error, { showError: showError, message: errorMessage })),
166
- React.createElement("header", { className: `${baseClass}__header` },
167
- React.createElement("div", { className: `${baseClass}__header-wrap` },
168
- React.createElement("h3", null, label),
169
- React.createElement("ul", { className: `${baseClass}__header-actions` },
170
- React.createElement("li", null,
171
- React.createElement("button", { type: "button", onClick: () => toggleCollapseAll(true), className: `${baseClass}__header-action` }, "Collapse All")),
172
- React.createElement("li", null,
173
- React.createElement("button", { type: "button", onClick: () => toggleCollapseAll(false), className: `${baseClass}__header-action` }, "Show All")))),
174
- React.createElement(FieldDescription, { value: value, description: description })),
175
- React.createElement(Droppable, { droppableId: "array-drop" }, (provided) => (React.createElement("div", { ref: provided.innerRef, ...provided.droppableProps },
176
- rows.length > 0 && rows.map((row, i) => {
177
- const rowNumber = i + 1;
178
- return (React.createElement(Draggable, { key: row.id, draggableId: row.id, index: i, isDragDisabled: readOnly }, (providedDrag) => (React.createElement("div", { id: `${path}-row-${i}`, ref: providedDrag.innerRef, ...providedDrag.draggableProps },
179
- React.createElement(Collapsible, { collapsed: row.collapsed, onToggle: (collapsed) => setCollapse(row.id, collapsed), className: `${baseClass}__row`, key: row.id, dragHandleProps: providedDrag.dragHandleProps, header: `${labels.singular} ${rowNumber >= 10 ? rowNumber : `0${rowNumber}`}`, actions: !readOnly ? (React.createElement(ArrayAction, { rowCount: rows.length, duplicateRow: duplicateRow, addRow: addRow, moveRow: moveRow, removeRow: removeRow, index: i })) : undefined },
180
- React.createElement(HiddenInput, { name: `${path}.${i}.id`, value: row.id }),
181
- React.createElement(RenderFields, { className: `${baseClass}__fields`, forceRender: true, readOnly: readOnly, fieldTypes: fieldTypes, permissions: permissions === null || permissions === void 0 ? void 0 : permissions.fields, fieldSchema: fields.map((field) => ({
182
- ...field,
183
- path: `${path}.${i}${fieldAffectsData(field) ? `.${field.name}` : ''}`,
184
- })) }))))));
185
- }),
186
- (rows.length < minRows || (required && rows.length === 0)) && (React.createElement(Banner, { type: "error" },
187
- "This field requires at least",
188
- ' ',
189
- minRows
190
- ? `${minRows} ${labels.plural}`
191
- : `1 ${labels.singular}`)),
192
- (rows.length === 0 && readOnly) && (React.createElement(Banner, null,
193
- "This field has no",
194
- ' ',
195
- labels.plural,
196
- ".")),
197
- provided.placeholder))),
198
- (!readOnly && !hasMaxRows) && (React.createElement("div", { className: `${baseClass}__add-button-wrap` },
199
- React.createElement(Button, { onClick: () => addRow(value), buttonStyle: "icon-label", icon: "plus", iconStyle: "with-border", iconPosition: "left" }, `Add ${labels.singular}`))))));
200
- };
201
- export default withCondition(ArrayFieldType);
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import { Props } from './types';
3
- import './index.scss';
4
- declare const _default: React.FC<Props>;
5
- export default _default;