Compare commits

..

198 Commits

Author SHA1 Message Date
Dan Ribbens
fc1fac08c8 chore(release): v1.8.1 2023-05-10 18:25:54 -04:00
Dan Ribbens
1d03de333c Revert "Merge pull request #2572 from wesdimiceli/fix/provide-plugin-package-resolution"
This reverts commit 4f5b811383, reversing
changes made to 776cad427d.
2023-05-10 18:12:39 -04:00
Dan Ribbens
74f086a460 Merge branch 'master' of github.com:payloadcms/payload 2023-05-10 15:00:02 -04:00
Dan Ribbens
6e93e3e25d chore: release v1.8.0 2023-05-10 14:45:42 -04:00
Jessica Boezwinkle
d53d0cb439 chore: updates payload version on example repos 2023-05-10 15:56:57 +01:00
Paul
3f185cb18b feat: export additional graphql types (#2610)
* Add paginatedType to graphQL on collections types

* Refactor config query and mutation extension into a reusable type

* Export paginatedListType and payload's version of graphql

* Revert prettier's automatic changes

* Fix requested changes

* Add additional documentation for extending GraphQL

* Add information about the resolver's first argument
2023-05-10 08:53:46 -04:00
Paul
7963e7540f fix: add dotenv.config() to test/dev.ts (#2646) 2023-05-10 08:47:22 -04:00
Angelo Bartolome
85316879cd feat: allow users to manipulate images without needing to resize them (#2574)
* Refactor imageResizer.ts to allow for keeping original size in certain cases

* revert new property for keeping desired size

* add unit tests for maintained image size feature
2023-05-10 08:44:53 -04:00
Jacob Fletcher
69c4760f37 chore: migrates react-router-dom to v5.1 (#2637) 2023-05-09 10:35:37 -04:00
Dan Ribbens
7d04cf14fb feat: add Arabic translations (#2641) 2023-05-09 10:15:23 -04:00
Quentin Beauperin
9072096495 fix: softens columns and filters pill colors (#2642) 2023-05-08 17:59:41 -04:00
Elliot DeNolf
f6cfe15807 Merge pull request #2639 from payloadcms/chore/eslint-config
chore: migrate eslint config
2023-05-08 17:03:29 -04:00
Elliot DeNolf
e1bad04279 chore: lint fix 2023-05-08 16:49:13 -04:00
Elliot DeNolf
dda3341537 chore: upgrade rules to latest eslint-plugin-jest 2023-05-08 16:33:58 -04:00
Elliot DeNolf
6e27795756 chore: migrate @trbl/eslint-config inline 2023-05-08 16:33:19 -04:00
Dennis Snijder
54fac4a5d7 fix: Row groups in tabs vertical alignment (#2593)
* fix: removes top padding from group in row

---------

Co-authored-by: PatrikKozak <patrik@trbl.design>
2023-05-08 15:55:12 -04:00
Elliot Lintz
a9b5dffa00 feat: allow full URL in staticURL (#2562)
* feat: support full URL for upload.staticURL

* feat: Update documentation about upload.staticURL property

* feat: Add reproduction test for absolute staticURL
2023-05-08 13:17:16 -04:00
James Mikrut
4f5b811383 Merge pull request #2572 from wesdimiceli/fix/provide-plugin-package-resolution
fix: resolve process/browser package in webpack config
2023-05-08 12:52:55 -04:00
James Mikrut
776cad427d Merge pull request #2635 from payloadcms/fix/2611-nested-querying
fix: ensures nested querying works when querying across collections
2023-05-08 12:49:55 -04:00
Jarrod Flesch
d365ba5303 chore: fixes test 2023-05-08 12:24:24 -04:00
Jarrod Flesch
31c0ab7ab7 chore: strengthens int test 2023-05-08 12:22:08 -04:00
Jarrod Flesch
09974fa686 fix: ensures nested querying works when querying across collections 2023-05-08 12:20:06 -04:00
James Mikrut
03cbab6c08 Merge pull request #2548 from payloadcms/docs/upload-example
chore: adds export and fields to upload example
2023-05-08 11:51:44 -04:00
James Mikrut
bbe5bff389 Merge pull request #2625 from payloadcms/fix/#2608-custom-id-text-query
fix: query custom text id fields
2023-05-08 11:51:04 -04:00
James Mikrut
f857da964b Merge pull request #2632 from payloadcms/fix/graphql-type
fix: correct casing on graphql type
2023-05-08 11:50:42 -04:00
James Mikrut
d36916b400 Merge pull request #2631 from payloadcms/fix/uploading-webp
fix: webp upload formatting
2023-05-08 11:50:22 -04:00
James Mikrut
c0568f92e4 Merge pull request #2634 from payloadcms/fix/queryHiddenFields
Fix/query hidden fields
2023-05-08 11:49:22 -04:00
James Mikrut
b17891c170 Merge pull request #2633 from payloadcms/fix/upload-schema
fix: defaultValue missing from Upload field schema
2023-05-08 11:49:04 -04:00
James
164d6e93d0 Merge branch 'master' of github.com:payloadcms/payload 2023-05-08 10:27:04 -04:00
James
733ca324d2 chore: force aliases react to avoid invalid hook call 2023-05-08 10:26:57 -04:00
PatrikKozak
fb4f822d34 fix: removes queryHiddenFields from example Find operation 2023-05-08 09:56:32 -04:00
Jessica Boezwinkle
7b21eaf12d fix: defaultValue missing from Upload field schema 2023-05-08 14:55:51 +01:00
PatrikKozak
02a4e17e41 Merge branch 'master' of https://github.com/payloadcms/payload into fix/queryHiddenFields 2023-05-08 09:53:34 -04:00
PatrikKozak
5f30dbb1a5 fix: removes deprecated queryHiddenFIelds from local API docs 2023-05-08 09:53:27 -04:00
Jessica Boezwinkle
219f50b0bc fix: correct casing on graphql type 2023-05-08 14:45:42 +01:00
Jessica Boezwinkle
ccd6ca298e fix: webp upload formatting 2023-05-08 13:15:18 +01:00
Dan Ribbens
967f2ace0e fix: query custom text id fields 2023-05-06 21:25:41 -04:00
Dan Ribbens
2c36468431 chore(release): v1.7.5 2023-05-04 16:55:46 -04:00
Hristiyan Dodov
8dbf0a2bd8 fix: make incrementName match multiple digits (#2609) 2023-05-04 16:35:55 -04:00
Michel v. Varendorff
967899229f feat: collection admin.enableRichTextLink property (#2560) 2023-05-04 16:31:40 -04:00
Jarrod Flesch
1d58007606 feat: custom admin buttons (#2618)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2023-05-04 16:04:06 -04:00
Jarrod Flesch
56a1dee3d6 docs: fix ui field example code block config 2023-05-04 09:33:28 -04:00
Quentin Beauperin
28572a978e docs: add hideAPIURL to the collections and globals admin options (#2614)
* fix: add the missing `hideAPIURL` admin option in the collections docs

* fix: add the missing `hideAPIURL` admin option in the globals docs
2023-05-03 19:11:56 -04:00
Jarrod Flesch
acfb9bca45 Feat/custom admin buttons (#2613) 2023-05-03 17:21:38 -04:00
Jacob Fletcher
6f82cefdc5 chore: adds cloud messaging to example READMEs (#2612) 2023-05-03 11:14:11 -04:00
James
d0ea57120c chore(release): v1.7.4 2023-05-01 22:45:37 -04:00
Elliot DeNolf
277beb6587 chore: release-it verbose logging 2023-05-01 22:19:07 -04:00
Elliot DeNolf
802deaca03 fix: properly import SwcMinifyWebpackPlugin (#2600) 2023-05-01 22:00:56 -04:00
Dan Ribbens
3c6461f757 chore(release): v1.7.3 2023-05-01 17:27:29 -04:00
James Mikrut
a0bb13a412 fix: #2592, allows usage of hidden fields within access query constraints (#2599)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2023-05-01 17:15:14 -04:00
Elliot DeNolf
870838e756 feat: adjust stack trace for api error (#2598) 2023-05-01 16:50:48 -04:00
Jarrod Flesch
8f6f13dc93 fix: addds workaround for slate isBlock function issue (#2596) 2023-05-01 16:30:01 -04:00
Harrison-Blair
13179a9498 chore: misc documentation updates (#2589)
* chore: ensures example configs are being exported when necessary
* chore: adds note regarding updating of hidden fields

---------

Co-authored-by: Jessica Boezwinkle <jessica@trbl.design>
2023-05-01 16:28:13 -04:00
Dan Ribbens
0ba22c3aaf fix: query on id throws 500 (#2587) 2023-05-01 14:36:26 -04:00
Seied Ali Mirkarimi
311f77dd25 chore: translations fa.json (#2590)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2023-05-01 13:52:27 -04:00
Dan Ribbens
8382faa0af fix: bulk operations result type (#2588) 2023-05-01 13:46:17 -04:00
Dan Ribbens
9c5107e86d fix: timestamp queries (#2583) 2023-05-01 13:45:51 -04:00
Elliot DeNolf
14a6b40bcc chore: bump swc-minify-webpack-plugin (#2571) 2023-05-01 11:50:10 -04:00
Jarrod Flesch
07506ae4d9 Merge branch 'master' of https://github.com/payloadcms/payload 2023-04-28 10:17:45 -04:00
Jarrod Flesch
6abcca1215 chore: adds github-stars md file 2023-04-28 10:17:39 -04:00
Wes DiMiceli
02f27f3de6 fix: resolve process/browser package in webpack config 2023-04-27 12:38:49 -04:00
Paul
fbf3a2a1b4 feat: Add new translation for romanian language (#2556)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2023-04-26 17:18:09 -04:00
Seied Ali Mirkarimi
c80f68af94 feat: add persian translations (#2553)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2023-04-26 16:12:11 -04:00
Perry
85b3d579d3 feat: supports collection compound indexes (#2529)
Co-authored-by: Perry Li <yuanping.li@moblab.com>
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2023-04-26 11:11:01 -04:00
Michel v. Varendorff
bf6522898d feat: allow customizing the link fields (#2559) 2023-04-26 11:08:47 -04:00
Jarrod Flesch
ddb34c3d83 chore: recreates yarn lock file 2023-04-25 19:13:48 -04:00
James
010ea4305b chore(release): v1.7.2 2023-04-25 14:48:57 -04:00
James
c33b226660 chore: yarn 2023-04-25 14:41:26 -04:00
Martin Choutka
8670d387d6 Feat: blocks should only search on singular labels (#2479)
* Blocks now only search on singular labels

* Add types to getBlockLabel params

---------

Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
2023-04-25 11:40:50 -04:00
Jarrod Flesch
a684b8f8bf chore: bumps eslint and related dev deps (#2561) 2023-04-25 11:09:31 -04:00
Jessica Boezwinkle
8270d8a228 docs: typo on REST API page 2023-04-25 12:33:33 +01:00
James
48941dce07 chore: merge conflicts 2023-04-24 17:11:23 -04:00
Jacob Fletcher
d6aa06a8af Merge pull request #2551 from payloadcms/fix/doc-drawer-access
fix: document drawer access control
2023-04-24 16:56:17 -04:00
Jacob Fletcher
7a0511610e chore: prevents document drawer from making get request when creating new 2023-04-24 16:22:10 -04:00
Jacob Fletcher
451ffcd982 chore: adds testing coverage for document drawer access control 2023-04-24 15:32:45 -04:00
Jarrod Flesch
fb2fcf3f66 chore: reduce complexity of block modal state tracking 2023-04-24 15:24:45 -04:00
Jarrod Flesch
b97a0881f1 Merge branch 'master' of https://github.com/payloadcms/payload 2023-04-24 15:23:43 -04:00
James
f9b3486ed1 Merge branch 'master' of github.com:payloadcms/payload 2023-04-24 15:16:54 -04:00
James
8cc900e11f chore: merge conflicts 2023-04-24 15:16:46 -04:00
Jarrod Flesch
904c365b75 Fix/2535 upload field access (#2550) 2023-04-24 15:16:12 -04:00
Jessica Chowdhury
362a4ccece Merge pull request #2533 from mauricewegner/feat/rich-text-blockquote
feat: add rich-text blockquote toggle, change quote node type to blockquote
2023-04-24 19:19:28 +01:00
PatrikKozak
750c6c32fa Merge pull request #2499 from AlessioGr/fix-readonly-styles
fix: read-only styles for textArea and richtext
2023-04-24 14:05:59 -04:00
Jacob Fletcher
439caf815f fix: document drawer access control #2545 2023-04-24 13:44:13 -04:00
Steven Thompson
0406548fe6 feat(imageresizer): add trim options (#2073)
* freat(imageresizer): add trim options

* fix(imageresizer): check for trimOptions config key

* feat: add trimOptions to original file upload, add test config

* chore: adjust sharp file ref

---------

Co-authored-by: Steven Thompson <steven@teamtailor.com>
Co-authored-by: Elliot DeNolf <denolfe@gmail.com>
2023-04-24 13:09:04 -04:00
Jessica Boezwinkle
4fb8b0fa28 chore: updates richText docs 2023-04-24 17:58:49 +01:00
James Mikrut
a0fd26602e Merge pull request #2051 from R0bson/master
Fix read of undefined error when autosave enabled
2023-04-24 12:51:56 -04:00
James
6d8eafd072 Merge branch 'master' of github.com:payloadcms/payload into R0bson/master 2023-04-24 12:29:03 -04:00
James
286193b4ab chore: cleanup 2023-04-24 12:27:00 -04:00
Jarrod Flesch
1808a9b663 Merge branch 'master' of https://github.com/payloadcms/payload 2023-04-24 12:19:01 -04:00
PatrikKozak
0683dd22dd Merge pull request #2539 from DennisSnijder/fix/multivalue-draggable
Multi value Select draggable enhancement
2023-04-24 11:58:18 -04:00
Elliot Lintz
7fcde11fa0 fix: prevent floating point number in image sizes (#1935) 2023-04-24 11:19:26 -04:00
Elliot DeNolf
90dab3c445 fix: prevent sharp toFormat settings fallthrough by using clone (#2547) 2023-04-24 10:42:29 -04:00
Jessica Boezwinkle
e942a18e5a chore: adds export and fields to upload example 2023-04-24 15:32:52 +01:00
James Mikrut
d397fe9af7 Merge pull request #2531 from payloadcms/feat/expose-id-in-condition
feat: exposes id in conditional logic
2023-04-24 09:59:51 -04:00
James Mikrut
cf6f0bfb8b Merge pull request #2532 from payloadcms/fix/#2521
fix: #2521, graphql AND not working with drafts
2023-04-24 09:59:44 -04:00
James Mikrut
b628a19e35 Merge pull request #2542 from payloadcms/fix/localized-field-nonlocalized-project
fix: query localized fields without localization configured
2023-04-24 09:56:24 -04:00
Dan Ribbens
4592d981a7 chore: fields test user config regression 2023-04-21 23:31:43 -04:00
Dan Ribbens
f6db81e431 docs: add user to field conditional logic 2023-04-21 22:55:23 -04:00
Dan Ribbens
274edc74a7 feat: add user to field conditional logic 2023-04-21 22:50:47 -04:00
Dan Ribbens
12edb1cc4b fix: query localized fields without localization configured 2023-04-21 21:12:30 -04:00
Dennis Snijder
269b203ef8 Changed background for multi values on select boxes, added is-dragging property to the multi value select and applied a z-index while dragging 2023-04-21 20:23:13 +02:00
mauricewegner
ed230a42e0 feat: add rich-text blockquote element, change quote node type to blockquote 2023-04-20 21:52:05 +02:00
Elliot DeNolf
c251801b1a chore: proper url path for docker deployment 2023-04-20 13:38:22 -04:00
Elliot DeNolf
8c242450e5 docs: fix docker link from getting started page 2023-04-20 13:31:56 -04:00
James
e67ca20108 fix: #2521, graphql AND not working with drafts 2023-04-20 09:31:29 -05:00
James
c117b32147 feat: exposes id in conditional logic 2023-04-20 09:20:02 -05:00
Dan Ribbens
1c5737b68a chore: add graphql variable to collection-graphql test (#2525) 2023-04-19 09:48:31 -04:00
James
db7acb4edd chore(release): v1.7.1 2023-04-18 17:28:25 -04:00
James
72be80abc4 fix: graphql variables not being passed properly 2023-04-18 17:19:15 -04:00
Teun Mooij
023719d775 feat: configuration extension points
* added custom config extension points

* Added custom field to documentation

* fix deeprequired issue
2023-04-18 15:28:42 -04:00
James
431b04075f Merge branch 'master' of github.com:payloadcms/payload 2023-04-18 14:54:10 -04:00
James
5e02985206 fix: adds 'use client' for next 13 compatibility 2023-04-18 14:53:59 -04:00
Elliot DeNolf
b80478d4b4 chore: remove release script to prevent accidental releases 2023-04-18 09:26:41 -04:00
James
fc7fa8debd chore: changelog formatting 2023-04-17 21:53:04 -04:00
James
a4fd0df69c chore(release): v1.7.0 2023-04-17 21:47:24 -04:00
James
cb9ca3e4c9 chore: type fix 2023-04-17 21:40:56 -04:00
James
5a6447805f Merge branch 'master' of github.com:payloadcms/payload 2023-04-17 21:38:12 -04:00
James
52ae6f06a1 feat: exposes new replaceState form api 2023-04-17 21:38:06 -04:00
James Mikrut
799699894c Merge pull request #2518 from payloadcms/fix/#2494-excess-versions
fix: #2494, reduces versions caused by reverting to published with autosave: true
2023-04-17 20:24:58 -04:00
James
e0c0b2fdf6 fix: #2494, reduces versions caused by reverting to published with autosave: true 2023-04-17 20:23:56 -04:00
James Mikrut
506bf646ba Merge pull request #2515 from payloadcms/feat/abstract-query-engine
Feat/abstract query engine
2023-04-17 19:54:49 -04:00
James Mikrut
e6c94c4f36 Merge pull request #2511 from payloadcms/docs/user-token
docs: adds info on payload secret encryption
2023-04-17 19:40:39 -04:00
James
3f9bbe90bd fix: incorrect version defaults 2023-04-17 19:37:22 -04:00
Elliot DeNolf
042e58ea29 feat: support email configuration in payload config (#2485)
* feat: support email configuration in payload config

* feat: set email defaults if no email config

* chore: leftover line from testing

* feat: add warning if email configure in both init and config
2023-04-17 17:21:28 -04:00
James
7fa27686bb chore: clarity to secret key usage 2023-04-17 17:02:07 -04:00
James
e3e2d513df Merge branch 'docs/user-token' of github.com:payloadcms/payload into docs/user-token 2023-04-17 17:00:46 -04:00
James
086feafcb7 chore: cleans duplicative logic 2023-04-17 16:56:38 -04:00
Quentin Beauperin
f9b8e2dbc5 fix: hides preview button until document is saved #2476 (#2477)
Co-authored-by: Jacob Fletcher <jacobsfletch@gmail.com>
2023-04-17 16:55:17 -04:00
Jacob Fletcher
5eafbefa9f Merge pull request #2507 from payloadcms/fix/preview-null
feat: supports null preview url #2472
2023-04-17 16:54:41 -04:00
James
cfadaf781c chore: merge master 2023-04-17 16:50:46 -04:00
Jacob Fletcher
dab5481fc5 Merge pull request #2513 from payloadcms/fix/sidebar-spacing-2478
fix: sidebar spacing #2478
2023-04-17 16:46:37 -04:00
James
1a681dd97b chore: revises outdated tests 2023-04-17 16:46:08 -04:00
Jacob Fletcher
2074f63333 chore: corrects typo in queries overview documentation (#2475) 2023-04-17 16:45:03 -04:00
Dan Ribbens
959a5d78c7 chore: test coverage queries 2023-04-17 16:43:00 -04:00
James
995054d46b chore: adds tests to validate queries 2023-04-17 16:25:07 -04:00
James
d187b809d7 feat: refactors buildQuery to rely on fields instead of mongoose 2023-04-17 16:08:44 -04:00
Dan Ribbens
81d69d1b64 feat: add admin.hidden to collections and globals (#2487) 2023-04-17 15:21:42 -04:00
Elliot DeNolf
faef4d5f8e docs: export default typo 2023-04-17 14:12:33 -04:00
Dan Ribbens
cd548a6e2d feat: replace deprecated express-graphql dependency (#2484) 2023-04-17 13:48:14 -04:00
Jacob Fletcher
78316d4ddc chore: updates global versions test config 2023-04-17 13:43:31 -04:00
Jacob Fletcher
a45ab8bd76 fix: corrects sidebar spacing in collection and global edit views #2478 2023-04-17 13:39:16 -04:00
Jessica Boezwinkle
cd861c22b7 docs: adds info on payload secret encryption 2023-04-17 18:22:03 +01:00
Alessio Gravili
15442a9cc7 fix: use correct locale when querying relationships for list view (#2438)
* chore: use correct locale when querying relationship for list view

* chore: make sure the relationships are re-queried when the locale changes

* chore: cleans up localization test ts-types

---------

Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
2023-04-17 12:43:33 -04:00
Elliot DeNolf
3c04d43eae docs: add custom express middleware and logging example (#2509) 2023-04-17 11:52:09 -04:00
Jacob Fletcher
63e23bab89 chore: adds translations for error:previewing 2023-04-17 11:48:28 -04:00
Jacob Fletcher
e8a24fd2e5 feat: supports null preview url #2472 2023-04-17 11:41:00 -04:00
Elliot DeNolf
aee6ca05cc fix: proper height data for animated gifs (#2506) 2023-04-17 11:34:31 -04:00
Elliot Lintz
0f8051b577 fix: Clear blocks modal search input when closing the modal (#2501) 2023-04-17 11:26:36 -04:00
Alessio Gravili
9d489ed57f actually no, background saves a few bytes 2023-04-15 19:48:28 +02:00
Alessio Gravili
ae88bade03 background => background-color 2023-04-15 19:47:31 +02:00
Alessio Gravili
4be43527e8 disable shadow for read-only textArea field 2023-04-15 19:46:06 +02:00
Alessio Gravili
823d0228c9 fix: read-only styles 2023-04-15 19:37:28 +02:00
James
2d0441a72e chore: begins work to build queries from fields instead of mongoose schema 2023-04-14 15:52:38 -04:00
Jessica Chowdhury
6ceb791891 fix: excess padding on textarea (#2488) 2023-04-13 11:56:04 -04:00
Jarrod Flesch
cd9e0400ac Merge branch 'master' of https://github.com/payloadcms/payload 2023-04-13 08:36:52 -04:00
PatrikKozak
b9a5bb3b8e Merge pull request #2289 from payloadcms/feat/form-builder-example
Feat/form builder example
2023-04-12 11:33:16 -04:00
PatrikKozak
1387ba9ae0 chore: updates form-builder-example nextjs README 2023-04-12 10:39:58 -04:00
PatrikKozak
3dd70483c6 Merge branch 'master' of https://github.com/payloadcms/payload into feat/form-builder-example 2023-04-11 10:49:31 -04:00
James Mikrut
ec2933c49a Merge pull request #2455 from payloadcms/chore/date-docs
chore: updates date field docs
2023-04-11 10:38:57 -04:00
James Mikrut
7eec16ee61 Merge pull request #2448 from AlessioGr/patch-4
docs: explain lifecycle of validate & beforeValidate
2023-04-11 10:38:24 -04:00
James Mikrut
ff89b8f782 Merge pull request #2464 from infonomic/docs/localization-warning
Docs/localization warning
2023-04-11 10:36:58 -04:00
James Mikrut
588a7d0a5b Update overview.mdx 2023-04-11 09:44:01 -04:00
Jessica Chowdhury
19ce0d79ef fix: increase line height for global title (#2465) 2023-04-10 15:42:11 -04:00
Jarrod Flesch
7f2c3d1d0a fix: uses docPermissions to show/hide x button on media collection doc fileDetails - #2428 2023-04-10 15:40:46 -04:00
Jarrod Flesch
13cc669e2c fix: prevents rendering of version actions when a user does not have permission 2023-04-10 15:38:49 -04:00
PatrikKozak
4d515a0d5b chore: improves text-area error rendering 2023-04-10 15:23:37 -04:00
Jacob Fletcher
11a6ce6d3a fix: properly awaits email send to catch potential errors #2444 (#2470) 2023-04-10 13:50:27 -04:00
Jarrod Flesch
048dd89bbc Merge branch 'master' of https://github.com/payloadcms/payload 2023-04-10 13:42:35 -04:00
Jarrod Flesch
48625e0e34 chore: general cleanup on useDocumentInfo hook usage 2023-04-10 13:27:29 -04:00
Anthony Bouch
013c96f0db docs: fixed sentance error in warning 2023-04-10 13:37:27 +07:00
Anthony Bouch
5fa8f69e10 docs: localization warning for existing data 2023-04-10 13:34:52 +07:00
Jessica Boezwinkle
fb89793703 docs: typo in date field and double link in textarea field 2023-04-06 11:35:15 +01:00
PatrikKozak
67098f7a3e chore: updates date field docs 2023-04-05 21:19:26 -04:00
James
299ae4fce5 chore(release): v1.6.32 2023-04-05 13:29:37 -04:00
James Mikrut
09ba58a432 Merge pull request #2454 from payloadcms/feat/only-use-sharp-if-required
feat: only uses sharp if required
2023-04-05 13:24:54 -04:00
James
f9f6ec47d9 feat: only uses sharp if required 2023-04-05 12:59:51 -04:00
Alessio Gravili
b76c25c9e7 docs: explain lifecycle of validate & beforeValida
Caused confusion here: https://discord.com/channels/967097582721572934/1091785894136139808/1092821186959921193

The initial expectation is that beforeValidate runs before any validation happens. However, it seems that client-side validation happens first nonetheless.

Please do check if this is 100% correct before merging.
2023-04-04 17:21:54 +02:00
James
192dac38f8 chore(release): v1.6.31 2023-04-04 08:25:51 -04:00
James
3a6acf322b fix: ensures select hasMany does not get mutated on patch operations 2023-04-04 08:16:10 -04:00
James
a9cd23a883 feat: improves required type accuracy 2023-04-03 22:30:24 -04:00
James
b6dec7af1c chore(release): v1.6.30 2023-04-03 16:14:20 -04:00
James Mikrut
546b7dc20a Merge pull request #2443 from payloadcms/fix/#2442-delete-local-type
fix: incorrect type local api using delete with where
2023-04-03 16:09:19 -04:00
James Mikrut
7cab14353d Merge pull request #2445 from payloadcms/fix/before-change-mutation
fix: originalDoc being mutated in beforeChange field hooks
2023-04-03 16:09:02 -04:00
James
888bbf28e0 fix: originalDoc being mutated in beforeChange field hooks 2023-04-03 15:27:59 -04:00
Dan Ribbens
de5ceb2aca fix: incorrect type local api using delete with where 2023-04-03 12:14:27 -04:00
Dan Ribbens
95719a978c chore(release): v1.6.29 2023-03-31 14:11:22 -04:00
Alessio Gravili
dd16bcffd2 chore: export formatListDrawerSlug (#2422) 2023-03-31 14:00:40 -04:00
Dan Ribbens
02410a0be3 fix: update and delete local API return types (#2434) 2023-03-31 13:58:54 -04:00
James
14f2fbbce7 chore(release): v1.6.28 2023-03-28 11:26:30 -04:00
James
8eea0d6cf4 fix: potential memory leak with probe-image-size 2023-03-28 11:21:56 -04:00
Jarrod Flesch
c14db9f94d chore: bumps slate and slate-react 2023-03-20 12:55:51 -04:00
PatrikKozak
c0ab499a77 chore: adds max-width to confirmation message 2023-03-15 12:04:52 -04:00
PatrikKozak
abf74f1a90 Merge branch 'master' of https://github.com/payloadcms/payload into feat/form-builder-example 2023-03-15 11:58:48 -04:00
PatrikKozak
8e814b1edd chore: style refinements 2023-03-15 11:58:40 -04:00
PatrikKozak
b459277c72 feat: updates form-builder example READMEs 2023-03-10 12:03:00 -05:00
PatrikKozak
28ecb0c5eb feat: migrates form builder example nextjs to examples 2023-03-10 11:50:41 -05:00
PatrikKozak
1356b4db40 chore: migrates form builder example cms to examples 2023-03-10 10:55:31 -05:00
Robert
4c22b2a7d9 Fix read of undefined error when autosave enabled
Fixes ERROR (payload): TypeError: Cannot read properties of undefined (reading '<field.name>')
    at promise (...\payload\src\fields\hooks\afterChange\promise.ts:68:23)
    at ...\payload\src\fields\hooks\afterChange\traverseFields.ts:31:26
    at Array.forEach (<anonymous>)
    at traverseFields (...\payload\src\fields\hooks\afterChange\traverseFields.ts:30:10)
    at promise (...\payload\src\fields\hooks\afterChange\promise.ts:154:27)
    at ...\payload\src\fields\hooks\afterChange\traverseFields.ts:31:26
    at Array.forEach (<anonymous>)
    at traverseFields (...\payload\src\fields\hooks\afterChange\traverseFields.ts:30:10)
    at promise (...\payload\src\fields\hooks\afterChange\promise.ts:170:27)
    at ...\payload\src\fields\hooks\afterChange\traverseFields.ts:31:26
2023-02-09 22:26:26 +01:00
407 changed files with 25496 additions and 6008 deletions

View File

@@ -11,7 +11,7 @@ module.exports = {
'@typescript-eslint',
],
extends: [
'@trbl',
'./eslint-config',
],
settings: {
'import/resolver': {

View File

@@ -1,4 +1,5 @@
{
"verbose": true,
"git": {
"commitMessage": "chore(release): v${version}",
"requireCleanWorkingDir": true

View File

@@ -1,4 +1,5 @@
{
"verbose": true,
"git": {
"requireCleanWorkingDir": false,
"commit": false,

View File

@@ -1,303 +1,441 @@
## [1.8.1](https://github.com/payloadcms/payload/compare/v1.8.0...v1.8.1) (2023-05-10)
### Bug Fixes
* add dotenv.config() to test/dev.ts ([#2646](https://github.com/payloadcms/payload/issues/2646)) ([7963e75](https://github.com/payloadcms/payload/commit/7963e7540f4899c16a49b47cf5145f46ea0c71cf))
### Features
* allow users to manipulate images without needing to resize them ([#2574](https://github.com/payloadcms/payload/issues/2574)) ([8531687](https://github.com/payloadcms/payload/commit/85316879cd97933ed34588b0cee72798964de281))
* export additional graphql types ([#2610](https://github.com/payloadcms/payload/issues/2610)) ([3f185cb](https://github.com/payloadcms/payload/commit/3f185cb18b9677654b92921267ffef408388d0d1))
# [1.8.0](https://github.com/payloadcms/payload/compare/v1.7.5...v1.8.0) (2023-05-09)
### Bug Fixes
* correct casing on graphql type ([219f50b](https://github.com/payloadcms/payload/commit/219f50b0bc7a520655a5ae4f1d8b08fd04c8a3dd))
* defaultValue missing from Upload field schema ([7b21eaf](https://github.com/payloadcms/payload/commit/7b21eaf12da64778568b45e56fa8d39e81f11c29))
* ensures nested querying works when querying across collections ([09974fa](https://github.com/payloadcms/payload/commit/09974fa68677586c727943cc234311f87bf6da75))
* query custom text id fields ([967f2ac](https://github.com/payloadcms/payload/commit/967f2ace0ea1a65570f69e85920f2f55626efde0))
* removes deprecated queryHiddenFIelds from local API docs ([5f30dbb](https://github.com/payloadcms/payload/commit/5f30dbb1a5b7c7ab6752c114710f92c159319d3d))
* removes queryHiddenFields from example Find operation ([fb4f822](https://github.com/payloadcms/payload/commit/fb4f822d34d0235a537f96515073e2662680412f))
* resolve process/browser package in webpack config ([02f27f3](https://github.com/payloadcms/payload/commit/02f27f3de6fdaf5dd0023298fc671a8ae9a1b758))
* Row groups in tabs vertical alignment ([#2593](https://github.com/payloadcms/payload/issues/2593)) ([54fac4a](https://github.com/payloadcms/payload/commit/54fac4a5d793b534e25600d2f9470c449f40df1d))
* softens columns and filters pill colors ([#2642](https://github.com/payloadcms/payload/issues/2642)) ([9072096](https://github.com/payloadcms/payload/commit/90720964953d392d85982052b3a4843a5450681e))
* webp upload formatting ([ccd6ca2](https://github.com/payloadcms/payload/commit/ccd6ca298e69faf04709535df3fcb18eb3d40f1b))
### Features
* add Arabic translations ([#2641](https://github.com/payloadcms/payload/issues/2641)) ([7d04cf1](https://github.com/payloadcms/payload/commit/7d04cf14fb0587f2208745bb77ed4fd17e99c8d5))
* allow full URL in staticURL ([#2562](https://github.com/payloadcms/payload/issues/2562)) ([a9b5dff](https://github.com/payloadcms/payload/commit/a9b5dffa00623eb48302d51b88c3449920c10f46))
## [1.7.5](https://github.com/payloadcms/payload/compare/v1.7.4...v1.7.5) (2023-05-04)
### Bug Fixes
* make incrementName match multiple digits ([#2609](https://github.com/payloadcms/payload/issues/2609)) ([8dbf0a2](https://github.com/payloadcms/payload/commit/8dbf0a2bd88db1b361ce16bb730613de489f2ed2))
### Features
* collection admin.enableRichTextLink property ([#2560](https://github.com/payloadcms/payload/issues/2560)) ([9678992](https://github.com/payloadcms/payload/commit/967899229f458d06a3931d086bcc49299dc310b7))
* custom admin buttons ([#2618](https://github.com/payloadcms/payload/issues/2618)) ([1d58007](https://github.com/payloadcms/payload/commit/1d58007606fa7e34007f2a56a3ca653d2cd3404d))
## [1.7.4](https://github.com/payloadcms/payload/compare/v1.7.3...v1.7.4) (2023-05-02)
### Bug Fixes
* properly import SwcMinifyWebpackPlugin ([#2600](https://github.com/payloadcms/payload/issues/2600)) ([802deac](https://github.com/payloadcms/payload/commit/802deaca03f8506fa4a7adb8fc008205c2c4f013))
## [1.7.3](https://github.com/payloadcms/payload/compare/v1.7.2...v1.7.3) (2023-05-01)
### Bug Fixes
* [#2592](https://github.com/payloadcms/payload/issues/2592), allows usage of hidden fields within access query constraints ([#2599](https://github.com/payloadcms/payload/issues/2599)) ([a0bb13a](https://github.com/payloadcms/payload/commit/a0bb13a4123b51d770b364ddaee3dde1c5a3da53))
* addds workaround for slate isBlock function issue ([#2596](https://github.com/payloadcms/payload/issues/2596)) ([8f6f13d](https://github.com/payloadcms/payload/commit/8f6f13dc93f49f5ba5384a9168ced5baec85e1fb))
* bulk operations result type ([#2588](https://github.com/payloadcms/payload/issues/2588)) ([8382faa](https://github.com/payloadcms/payload/commit/8382faa0afc8118f4fb873c657a52c48abb2a6ad))
* query on id throws 500 ([#2587](https://github.com/payloadcms/payload/issues/2587)) ([0ba22c3](https://github.com/payloadcms/payload/commit/0ba22c3aafca67be78814357edc668ed11ec4a97))
* timestamp queries ([#2583](https://github.com/payloadcms/payload/issues/2583)) ([9c5107e](https://github.com/payloadcms/payload/commit/9c5107e86d70e36ac181c9d3ad51edacf9fc529a))
### Features
* Add new translation for romanian language ([#2556](https://github.com/payloadcms/payload/issues/2556)) ([fbf3a2a](https://github.com/payloadcms/payload/commit/fbf3a2a1b4633e704e467d9aec05f3ae0b900bae))
* add persian translations ([#2553](https://github.com/payloadcms/payload/issues/2553)) ([c80f68a](https://github.com/payloadcms/payload/commit/c80f68af943c730996c9cdad87cf84d4d06a5777))
* adjust stack trace for api error ([#2598](https://github.com/payloadcms/payload/issues/2598)) ([870838e](https://github.com/payloadcms/payload/commit/870838e7563b6767c53f4dc0288119087e3f9486))
* allow customizing the link fields ([#2559](https://github.com/payloadcms/payload/issues/2559)) ([bf65228](https://github.com/payloadcms/payload/commit/bf6522898db353e75db11525ea5a1b58243333d8))
* supports collection compound indexes ([#2529](https://github.com/payloadcms/payload/issues/2529)) ([85b3d57](https://github.com/payloadcms/payload/commit/85b3d579d3054aad2de793957cf6454332361327))
## [1.7.2](https://github.com/payloadcms/payload/compare/v1.7.1...v1.7.2) (2023-04-25)
### Bug Fixes
* [#2521](https://github.com/payloadcms/payload/issues/2521), graphql AND not working with drafts ([e67ca20](https://github.com/payloadcms/payload/commit/e67ca2010831c14938d3f639fcb5374ca62747ba))
* document drawer access control [#2545](https://github.com/payloadcms/payload/issues/2545) ([439caf8](https://github.com/payloadcms/payload/commit/439caf815fc99538f14b3a59835dcf49185759dc))
* prevent floating point number in image sizes ([#1935](https://github.com/payloadcms/payload/issues/1935)) ([7fcde11](https://github.com/payloadcms/payload/commit/7fcde11fa0b232537de606e44c0af68b122daed2))
* prevent sharp toFormat settings fallthrough by using clone ([#2547](https://github.com/payloadcms/payload/issues/2547)) ([90dab3c](https://github.com/payloadcms/payload/commit/90dab3c445d4bdbab0eff286a2b66861d04f2a93))
* query localized fields without localization configured ([12edb1c](https://github.com/payloadcms/payload/commit/12edb1cc4b2675d9b0948fb7f3439f61c6e2015d))
* read-only styles ([823d022](https://github.com/payloadcms/payload/commit/823d0228c949fe58a7e0f11f95354b240c3ea876))
### Features
* add rich-text blockquote element, change quote node type to blockquote ([ed230a4](https://github.com/payloadcms/payload/commit/ed230a42e0315dc2492b4a26e3bf8b5334e89380))
* add user to field conditional logic ([274edc7](https://github.com/payloadcms/payload/commit/274edc74a70202e8c771c5111507b585c3f69377))
* exposes id in conditional logic ([c117b32](https://github.com/payloadcms/payload/commit/c117b321474b8318c3a0ddf544e49568e461f0d8))
* **imageresizer:** add trim options ([#2073](https://github.com/payloadcms/payload/issues/2073)) ([0406548](https://github.com/payloadcms/payload/commit/0406548fe6127e091db9926ee42e59f9158eff5a))
## [1.7.1](https://github.com/payloadcms/payload/compare/v1.7.0...v1.7.1) (2023-04-18)
### Bug Fixes
* adds 'use client' for next 13 compatibility ([5e02985](https://github.com/payloadcms/payload/commit/5e029852060d6475eccada35ffbcdd0178d5e690))
* graphql variables not being passed properly ([72be80a](https://github.com/payloadcms/payload/commit/72be80abc4082013e052aef1152a5de749a6f3c4))
### Features
* configuration extension points ([023719d](https://github.com/payloadcms/payload/commit/023719d77554a70493d779ba94bf55058d4caf98))
## [1.7.0](https://github.com/payloadcms/payload/compare/v1.6.32...v1.7.0) (2023-04-17)
### Features
- feat: exposes new replaceState form api (52ae6f06a)
- feat: support email configuration in payload config (#2485) (042e58ea2)
- feat: refactors buildQuery to rely on fields instead of mongoose (d187b809d)
- feat: add admin.hidden to collections and globals (#2487) (81d69d1b6)
- feat: replace deprecated express-graphql dependency (#2484) (cd548a6e2)
- feat: supports null preview url #2472 (e8a24fd2e)
- feat: migrates form builder example nextjs to examples (28ecb0c5e)
### Bug Fixes
- fix: #2494, reduces versions caused by reverting to published with autosave: true (e0c0b2fdf)
- fix: incorrect version defaults (3f9bbe90b)
- fix: hides preview button until document is saved #2476 (#2477) (f9b8e2dbc)
- fix: corrects sidebar spacing in collection and global edit views #2478 (a45ab8bd7)
- fix: use correct locale when querying relationships for list view (#2438) (15442a9cc)
- fix: proper height data for animated gifs (#2506) (aee6ca05c)
- fix: Clear blocks modal search input when closing the modal (#2501) (0f8051b57)
- fix: excess padding on textarea (#2488) (6ceb79189)
- fix: increase line height for global title (#2465) (19ce0d79e)
- fix: uses docPermissions to show/hide x button on media collection doc fileDetails - #2428 (7f2c3d1d0)
- fix: prevents rendering of version actions when a user does not have permission (13cc669e2)
- fix: properly awaits email send to catch potential errors #2444 (#2470) (11a6ce6d3)
## [1.6.32](https://github.com/payloadcms/payload/compare/v1.6.31...v1.6.32) (2023-04-05)
### Features
- only uses sharp if required ([f9f6ec4](https://github.com/payloadcms/payload/commit/f9f6ec47d9a4f9ed94b7f7a4d50f13a8ee881ad0))
## [1.6.31](https://github.com/payloadcms/payload/compare/v1.6.30...v1.6.31) (2023-04-04)
### Bug Fixes
- ensures select hasMany does not get mutated on patch operations ([3a6acf3](https://github.com/payloadcms/payload/commit/3a6acf322b5546ca3cd1d4dcb093af6e3b6ed086))
### Features
- improves required type accuracy ([a9cd23a](https://github.com/payloadcms/payload/commit/a9cd23a883d89c8deb3c1b5386decd50516d69fd))
## [1.6.30](https://github.com/payloadcms/payload/compare/v1.6.29...v1.6.30) (2023-04-03)
### Bug Fixes
- incorrect type local api using delete with where ([de5ceb2](https://github.com/payloadcms/payload/commit/de5ceb2aca624f702ea39556ffe2f689701615c1))
- originalDoc being mutated in beforeChange field hooks ([888bbf2](https://github.com/payloadcms/payload/commit/888bbf28e0b793a2298e27a7e1df235d78b0a718))
## [1.6.29](https://github.com/payloadcms/payload/compare/v1.6.28...v1.6.29) (2023-03-31)
### Bug Fixes
- update and delete local API return types ([#2434](https://github.com/payloadcms/payload/issues/2434)) ([02410a0](https://github.com/payloadcms/payload/commit/02410a0be38004b90d19207071569294fd104a66))
## [1.6.28](https://github.com/payloadcms/payload/compare/v1.6.27...v1.6.28) (2023-03-28)
### Bug Fixes
- potential memory leak with `probe-image-size` ([8eea0d6](https://github.com/payloadcms/payload/commit/8eea0d6cf41dd6360d713f463ad1b48ba253a9e7))
## [1.6.27](https://github.com/payloadcms/payload/compare/v1.6.26...v1.6.27) (2023-03-27)
### Bug Fixes
* [#2355](https://github.com/payloadcms/payload/issues/2355), select field not fully visible on small screens in certain scenarios ([07eb8dd](https://github.com/payloadcms/payload/commit/07eb8dd7d252043c00b79d532736896134204c4c))
* [#2384](https://github.com/payloadcms/payload/issues/2384), preserves manually set verified from admin UI ([72a8b1e](https://github.com/payloadcms/payload/commit/72a8b1eebe6c3b45663a14fa7488772ad13f975d))
* hide fields with admin.hidden attribute ([ad25b09](https://github.com/payloadcms/payload/commit/ad25b096b6efa7e0cba647e82e29e36f7a95934a))
* make update typing a deep partial ([#2407](https://github.com/payloadcms/payload/issues/2407)) ([e8dc7d4](https://github.com/payloadcms/payload/commit/e8dc7d462e21d1021275a95fbf62094f290e37ce))
* restoring version did not correctly create new version from result ([6ca12b1](https://github.com/payloadcms/payload/commit/6ca12b1cc06554b04f3055df8f01d7eee1c09169))
* textarea field overlap in UI ([1c8cf24](https://github.com/payloadcms/payload/commit/1c8cf24ba623746c160007d7c09b3160f2aae8d3))
- [#2355](https://github.com/payloadcms/payload/issues/2355), select field not fully visible on small screens in certain scenarios ([07eb8dd](https://github.com/payloadcms/payload/commit/07eb8dd7d252043c00b79d532736896134204c4c))
- [#2384](https://github.com/payloadcms/payload/issues/2384), preserves manually set verified from admin UI ([72a8b1e](https://github.com/payloadcms/payload/commit/72a8b1eebe6c3b45663a14fa7488772ad13f975d))
- hide fields with admin.hidden attribute ([ad25b09](https://github.com/payloadcms/payload/commit/ad25b096b6efa7e0cba647e82e29e36f7a95934a))
- make update typing a deep partial ([#2407](https://github.com/payloadcms/payload/issues/2407)) ([e8dc7d4](https://github.com/payloadcms/payload/commit/e8dc7d462e21d1021275a95fbf62094f290e37ce))
- restoring version did not correctly create new version from result ([6ca12b1](https://github.com/payloadcms/payload/commit/6ca12b1cc06554b04f3055df8f01d7eee1c09169))
- textarea field overlap in UI ([1c8cf24](https://github.com/payloadcms/payload/commit/1c8cf24ba623746c160007d7c09b3160f2aae8d3))
## [1.6.25](https://github.com/payloadcms/payload/compare/v1.6.24...v1.6.25) (2023-03-24)
### Bug Fixes
* upload field select existing file ([#2392](https://github.com/payloadcms/payload/issues/2392)) ([38e917a](https://github.com/payloadcms/payload/commit/38e917a3dfa70ac3234915a6c8f7424eb22cb000))
- upload field select existing file ([#2392](https://github.com/payloadcms/payload/issues/2392)) ([38e917a](https://github.com/payloadcms/payload/commit/38e917a3dfa70ac3234915a6c8f7424eb22cb000))
## [1.6.24](https://github.com/payloadcms/payload/compare/v1.6.23...v1.6.24) (2023-03-23)
### Features
* bulk-operations ([#2346](https://github.com/payloadcms/payload/issues/2346)) ([0fedbab](https://github.com/payloadcms/payload/commit/0fedbabe9e975f375dc12447fcdab4119bc6a4c4))
- bulk-operations ([#2346](https://github.com/payloadcms/payload/issues/2346)) ([0fedbab](https://github.com/payloadcms/payload/commit/0fedbabe9e975f375dc12447fcdab4119bc6a4c4))
## [1.6.23](https://github.com/payloadcms/payload/compare/v1.6.22...v1.6.23) (2023-03-22)
### Bug Fixes
* [#2315](https://github.com/payloadcms/payload/issues/2315) - deleting files if overwriteExistingFiles is true ([4d578f1](https://github.com/payloadcms/payload/commit/4d578f1bfd05efab5cc8db95895eabb776b2d9d1))
* [#2363](https://github.com/payloadcms/payload/issues/2363) version tabs and select field comparisons ([#2364](https://github.com/payloadcms/payload/issues/2364)) ([21b8da7](https://github.com/payloadcms/payload/commit/21b8da7f415cdace9f7d5898c98f9c7a6bb39107))
* allows base64 thumbnails ([#2361](https://github.com/payloadcms/payload/issues/2361)) ([e09ebff](https://github.com/payloadcms/payload/commit/e09ebfffa0a7a7fdb3469f272de0e6930d97a336))
* DateField admin type ([#2256](https://github.com/payloadcms/payload/issues/2256)) ([fb2fd3e](https://github.com/payloadcms/payload/commit/fb2fd3e9b7e302d8069bfcb6f3cb698ac7abf0ca))
* fallback to default locale showing on non-localized fields ([#2316](https://github.com/payloadcms/payload/issues/2316)) ([e1a6e08](https://github.com/payloadcms/payload/commit/e1a6e08aa140cf21597d6009b811f7fdd2106f4f))
* Fix missing Spanish translations ([#2372](https://github.com/payloadcms/payload/issues/2372)) ([c0ff75c](https://github.com/payloadcms/payload/commit/c0ff75c1647a36219549e20fc081883f8cf1d7e4))
* relationship field useAsTitle [#2333](https://github.com/payloadcms/payload/issues/2333) ([#2350](https://github.com/payloadcms/payload/issues/2350)) ([10dd819](https://github.com/payloadcms/payload/commit/10dd819863ecac4a5cea2e13f820df2224ac57f4))
- [#2315](https://github.com/payloadcms/payload/issues/2315) - deleting files if overwriteExistingFiles is true ([4d578f1](https://github.com/payloadcms/payload/commit/4d578f1bfd05efab5cc8db95895eabb776b2d9d1))
- [#2363](https://github.com/payloadcms/payload/issues/2363) version tabs and select field comparisons ([#2364](https://github.com/payloadcms/payload/issues/2364)) ([21b8da7](https://github.com/payloadcms/payload/commit/21b8da7f415cdace9f7d5898c98f9c7a6bb39107))
- allows base64 thumbnails ([#2361](https://github.com/payloadcms/payload/issues/2361)) ([e09ebff](https://github.com/payloadcms/payload/commit/e09ebfffa0a7a7fdb3469f272de0e6930d97a336))
- DateField admin type ([#2256](https://github.com/payloadcms/payload/issues/2256)) ([fb2fd3e](https://github.com/payloadcms/payload/commit/fb2fd3e9b7e302d8069bfcb6f3cb698ac7abf0ca))
- fallback to default locale showing on non-localized fields ([#2316](https://github.com/payloadcms/payload/issues/2316)) ([e1a6e08](https://github.com/payloadcms/payload/commit/e1a6e08aa140cf21597d6009b811f7fdd2106f4f))
- Fix missing Spanish translations ([#2372](https://github.com/payloadcms/payload/issues/2372)) ([c0ff75c](https://github.com/payloadcms/payload/commit/c0ff75c1647a36219549e20fc081883f8cf1d7e4))
- relationship field useAsTitle [#2333](https://github.com/payloadcms/payload/issues/2333) ([#2350](https://github.com/payloadcms/payload/issues/2350)) ([10dd819](https://github.com/payloadcms/payload/commit/10dd819863ecac4a5cea2e13f820df2224ac57f4))
### Features
* adds title attribute to ThumbnailCard ([#2368](https://github.com/payloadcms/payload/issues/2368)) ([a8766d0](https://github.com/payloadcms/payload/commit/a8766d00a8365c8e6ffe507944fbe49aaa39d4bd))
* exposes defaultSort property for collection list view ([#2382](https://github.com/payloadcms/payload/issues/2382)) ([1f480c4](https://github.com/payloadcms/payload/commit/1f480c4cd5673a6fe08360183fe1c7c1d4e05de0))
- adds title attribute to ThumbnailCard ([#2368](https://github.com/payloadcms/payload/issues/2368)) ([a8766d0](https://github.com/payloadcms/payload/commit/a8766d00a8365c8e6ffe507944fbe49aaa39d4bd))
- exposes defaultSort property for collection list view ([#2382](https://github.com/payloadcms/payload/issues/2382)) ([1f480c4](https://github.com/payloadcms/payload/commit/1f480c4cd5673a6fe08360183fe1c7c1d4e05de0))
## [1.6.22](https://github.com/payloadcms/payload/compare/v1.6.21...v1.6.22) (2023-03-15)
## [1.6.21](https://github.com/payloadcms/payload/compare/v1.6.20...v1.6.21) (2023-03-15)
### Bug Fixes
* hidden fields being mutated on patch ([#2317](https://github.com/payloadcms/payload/issues/2317)) ([8d65ba1](https://github.com/payloadcms/payload/commit/8d65ba1efd8744042bbaf669c10b6837a6b972f8))
- hidden fields being mutated on patch ([#2317](https://github.com/payloadcms/payload/issues/2317)) ([8d65ba1](https://github.com/payloadcms/payload/commit/8d65ba1efd8744042bbaf669c10b6837a6b972f8))
## [1.6.20](https://github.com/payloadcms/payload/compare/v1.6.19...v1.6.20) (2023-03-13)
### Bug Fixes
* allow thumbnails in upload gallery to show useAsTitle value ([aae6d71](https://github.com/payloadcms/payload/commit/aae6d716e5608270ca142f2f4df214f9e271deb4))
* allows useListDrawer to work without collectionSlugs defined ([e1553c2](https://github.com/payloadcms/payload/commit/e1553c2fc88ac582744cd72d15c9e9ef3b8ec549))
* cancels existing fetches if new fetches are started ([ccc92fd](https://github.com/payloadcms/payload/commit/ccc92fdb7519e14ff1092f19ae4e7060fa413aab))
* check relationships indexed access for undefined ([959f017](https://github.com/payloadcms/payload/commit/959f01739c30450f3a6d052dd6083fdacf1527a4))
* ensures documentID exists in doc documentDrawers ([#2304](https://github.com/payloadcms/payload/issues/2304)) ([566c45b](https://github.com/payloadcms/payload/commit/566c45b0b436a9a3ea8eff27de2ea829dd6a2f0c))
* flattens title fields to allow seaching by title if title inside Row field ([75e776d](https://github.com/payloadcms/payload/commit/75e776ddb43b292eae6c1204589d9dc22deab50c))
* keep drop zone active when hovering inner elements ([#2295](https://github.com/payloadcms/payload/issues/2295)) ([39e303a](https://github.com/payloadcms/payload/commit/39e303add62d2dbd3e72d17e64e1ea5d940b0298))
* Prevent browser initial favicon request ([fd8ea88](https://github.com/payloadcms/payload/commit/fd8ea88488c80627346733e0595a2ef34c964a87))
* removes forced require on array, block, group ts ([657aa65](https://github.com/payloadcms/payload/commit/657aa65e993d13e9a294456b73adcd57f20d7c87))
* removes pagination type from top level admin config types ([bf9929e](https://github.com/payloadcms/payload/commit/bf9929e9a9919488f6de0e172909fa27719ecb04))
* renders presentational table columns ([4e1748f](https://github.com/payloadcms/payload/commit/4e1748fb8a3554586b377e60738130d03ec12f38))
* undefined point fields saving as empty object ([#2313](https://github.com/payloadcms/payload/issues/2313)) ([af16415](https://github.com/payloadcms/payload/commit/af164159fb52f4b0ef97e2fa34b881f97bc07310))
- allow thumbnails in upload gallery to show useAsTitle value ([aae6d71](https://github.com/payloadcms/payload/commit/aae6d716e5608270ca142f2f4df214f9e271deb4))
- allows useListDrawer to work without collectionSlugs defined ([e1553c2](https://github.com/payloadcms/payload/commit/e1553c2fc88ac582744cd72d15c9e9ef3b8ec549))
- cancels existing fetches if new fetches are started ([ccc92fd](https://github.com/payloadcms/payload/commit/ccc92fdb7519e14ff1092f19ae4e7060fa413aab))
- check relationships indexed access for undefined ([959f017](https://github.com/payloadcms/payload/commit/959f01739c30450f3a6d052dd6083fdacf1527a4))
- ensures documentID exists in doc documentDrawers ([#2304](https://github.com/payloadcms/payload/issues/2304)) ([566c45b](https://github.com/payloadcms/payload/commit/566c45b0b436a9a3ea8eff27de2ea829dd6a2f0c))
- flattens title fields to allow seaching by title if title inside Row field ([75e776d](https://github.com/payloadcms/payload/commit/75e776ddb43b292eae6c1204589d9dc22deab50c))
- keep drop zone active when hovering inner elements ([#2295](https://github.com/payloadcms/payload/issues/2295)) ([39e303a](https://github.com/payloadcms/payload/commit/39e303add62d2dbd3e72d17e64e1ea5d940b0298))
- Prevent browser initial favicon request ([fd8ea88](https://github.com/payloadcms/payload/commit/fd8ea88488c80627346733e0595a2ef34c964a87))
- removes forced require on array, block, group ts ([657aa65](https://github.com/payloadcms/payload/commit/657aa65e993d13e9a294456b73adcd57f20d7c87))
- removes pagination type from top level admin config types ([bf9929e](https://github.com/payloadcms/payload/commit/bf9929e9a9919488f6de0e172909fa27719ecb04))
- renders presentational table columns ([4e1748f](https://github.com/payloadcms/payload/commit/4e1748fb8a3554586b377e60738130d03ec12f38))
- undefined point fields saving as empty object ([#2313](https://github.com/payloadcms/payload/issues/2313)) ([af16415](https://github.com/payloadcms/payload/commit/af164159fb52f4b0ef97e2fa34b881f97bc07310))
### Features
* [#2280](https://github.com/payloadcms/payload/issues/2280) Improve UX of paginator ([#2293](https://github.com/payloadcms/payload/issues/2293)) ([1df3d14](https://github.com/payloadcms/payload/commit/1df3d149e06cc955a61c4371371b601c0d9aad2b))
* exposes useTheme hook ([abebde6](https://github.com/payloadcms/payload/commit/abebde6b120a9dddc9971325b616b9cb31bcba90))
* provide refresh permissions for auth context ([e9c796e](https://github.com/payloadcms/payload/commit/e9c796e42c1bb1e0ce72d057ee88dee624b94c24))
- [#2280](https://github.com/payloadcms/payload/issues/2280) Improve UX of paginator ([#2293](https://github.com/payloadcms/payload/issues/2293)) ([1df3d14](https://github.com/payloadcms/payload/commit/1df3d149e06cc955a61c4371371b601c0d9aad2b))
- exposes useTheme hook ([abebde6](https://github.com/payloadcms/payload/commit/abebde6b120a9dddc9971325b616b9cb31bcba90))
- provide refresh permissions for auth context ([e9c796e](https://github.com/payloadcms/payload/commit/e9c796e42c1bb1e0ce72d057ee88dee624b94c24))
## [1.6.19](https://github.com/payloadcms/payload/compare/v1.6.18...v1.6.19) (2023-03-09)
### Bug Fixes
* ensures nested fields save properly within link, upload rte ([057522c](https://github.com/payloadcms/payload/commit/057522c5bdade430c6e60f589a32f174739d400c))
- ensures nested fields save properly within link, upload rte ([057522c](https://github.com/payloadcms/payload/commit/057522c5bdade430c6e60f589a32f174739d400c))
## [1.6.18](https://github.com/payloadcms/payload/compare/v1.6.17...v1.6.18) (2023-03-09)
### Bug Fixes
* [#2272](https://github.com/payloadcms/payload/issues/2272), rich text within blocks causing crash on reorder ([7daddf8](https://github.com/payloadcms/payload/commit/7daddf864d71e83fa74bc76768d85d4c7fa93d9a))
* allows swc/register to transpile files above current workspace ([ef826c8](https://github.com/payloadcms/payload/commit/ef826c88ec40878bb36e960c2df2c68ec3c54ef6))
* renders row fields as table columns [#2257](https://github.com/payloadcms/payload/issues/2257) ([b10e842](https://github.com/payloadcms/payload/commit/b10e842e89a4e0839d0f391cfbafa916134c47c8))
* table column preferences sync ([a1ddd2e](https://github.com/payloadcms/payload/commit/a1ddd2e2e37a76471631a90938a9ceaba8f9a394))
- [#2272](https://github.com/payloadcms/payload/issues/2272), rich text within blocks causing crash on reorder ([7daddf8](https://github.com/payloadcms/payload/commit/7daddf864d71e83fa74bc76768d85d4c7fa93d9a))
- allows swc/register to transpile files above current workspace ([ef826c8](https://github.com/payloadcms/payload/commit/ef826c88ec40878bb36e960c2df2c68ec3c54ef6))
- renders row fields as table columns [#2257](https://github.com/payloadcms/payload/issues/2257) ([b10e842](https://github.com/payloadcms/payload/commit/b10e842e89a4e0839d0f391cfbafa916134c47c8))
- table column preferences sync ([a1ddd2e](https://github.com/payloadcms/payload/commit/a1ddd2e2e37a76471631a90938a9ceaba8f9a394))
## [1.6.17](https://github.com/payloadcms/payload/compare/v1.6.15...v1.6.17) (2023-03-06)
### Bug Fixes
* [#2150](https://github.com/payloadcms/payload/issues/2150), can now query on N number of levels deep ([ac54b11](https://github.com/payloadcms/payload/commit/ac54b11f9d2f9cfde15a4421d13ce26ffd6cdc63))
* [#2179](https://github.com/payloadcms/payload/issues/2179), async default values resetting form state ([a4de51a](https://github.com/payloadcms/payload/commit/a4de51adaaa9399fa9036e485eb2e7f350719638))
* allows empty objects to be retained in db ([0247e2d](https://github.com/payloadcms/payload/commit/0247e2d1068527213f007c71f6efa1aff4c21af6))
* clear relationship value ([#2188](https://github.com/payloadcms/payload/issues/2188)) ([387cec9](https://github.com/payloadcms/payload/commit/387cec983868d6c10c043248b45fc8c1657e4981))
* conditionally renders draggable pill ([#2224](https://github.com/payloadcms/payload/issues/2224)) ([812ab9f](https://github.com/payloadcms/payload/commit/812ab9f86824aca3689ddef8af759a84f59f2148))
* ensures sorting on drafts works in all cases ([c87fd2b](https://github.com/payloadcms/payload/commit/c87fd2b649e59afb6fe7998d04142f3ba246dcef))
* globals publish after draft ([44651e6](https://github.com/payloadcms/payload/commit/44651e6ecc354dbe17a08fccfafd686420d07158))
* minimize not set to false on all field type schemas ([ace032e](https://github.com/payloadcms/payload/commit/ace032ef897dc55131c6cf7cb80dc1a652940748))
* pass result of previous hook into next hook ([c661ac2](https://github.com/payloadcms/payload/commit/c661ac2e8a26251e77c558e00ed3c32741d2d385))
* properly resizes animated images ([#2181](https://github.com/payloadcms/payload/issues/2181)) ([8c4f890](https://github.com/payloadcms/payload/commit/8c4f890af0cbd1f2b3a2dd1980d26ba3e721f154))
* properly set req.payload on forgotPassword in local API ([#2194](https://github.com/payloadcms/payload/issues/2194)) ([5ac436e](https://github.com/payloadcms/payload/commit/5ac436e1843aacc81072992805bdbd1aed41d243))
* redirects example ([#2209](https://github.com/payloadcms/payload/issues/2209)) ([5aa203d](https://github.com/payloadcms/payload/commit/5aa203d020177eb25b7675d6ab30fc8721b9fe0c))
* removes duplicative fields from table columns [#2221](https://github.com/payloadcms/payload/issues/2221) ([#2226](https://github.com/payloadcms/payload/issues/2226)) ([474a3cb](https://github.com/payloadcms/payload/commit/474a3cbf7a90ab02d9e6c86ee018895576cbcab9))
* renders rte upload drawer [#2178](https://github.com/payloadcms/payload/issues/2178) ([523d9d4](https://github.com/payloadcms/payload/commit/523d9d495261b44fdb9c7922bfa9cdd8aaba85fb))
* skips field validation on submit if skipValidation is set to true ([cf17760](https://github.com/payloadcms/payload/commit/cf17760735d466a5817fc37bc3dc6f3ad8c52f7a))
* Validate typescript signature ([8d31ed6](https://github.com/payloadcms/payload/commit/8d31ed6d39d1a4d147e13de5b96073fab5563173))
* version comparison view errors on old select value ([#2163](https://github.com/payloadcms/payload/issues/2163)) ([a3cc3c3](https://github.com/payloadcms/payload/commit/a3cc3c342928e00564a662ba210635d78238fed8))
* versions table ([#2235](https://github.com/payloadcms/payload/issues/2235)) ([066f5f6](https://github.com/payloadcms/payload/commit/066f5f6d2cb48525896366166693af6c92d1814d))
* virtual fields example ([#2214](https://github.com/payloadcms/payload/issues/2214)) ([f6eb020](https://github.com/payloadcms/payload/commit/f6eb0202fec15a0ba0e6c357ecdb9ace62bd2ea9))
- [#2150](https://github.com/payloadcms/payload/issues/2150), can now query on N number of levels deep ([ac54b11](https://github.com/payloadcms/payload/commit/ac54b11f9d2f9cfde15a4421d13ce26ffd6cdc63))
- [#2179](https://github.com/payloadcms/payload/issues/2179), async default values resetting form state ([a4de51a](https://github.com/payloadcms/payload/commit/a4de51adaaa9399fa9036e485eb2e7f350719638))
- allows empty objects to be retained in db ([0247e2d](https://github.com/payloadcms/payload/commit/0247e2d1068527213f007c71f6efa1aff4c21af6))
- clear relationship value ([#2188](https://github.com/payloadcms/payload/issues/2188)) ([387cec9](https://github.com/payloadcms/payload/commit/387cec983868d6c10c043248b45fc8c1657e4981))
- conditionally renders draggable pill ([#2224](https://github.com/payloadcms/payload/issues/2224)) ([812ab9f](https://github.com/payloadcms/payload/commit/812ab9f86824aca3689ddef8af759a84f59f2148))
- ensures sorting on drafts works in all cases ([c87fd2b](https://github.com/payloadcms/payload/commit/c87fd2b649e59afb6fe7998d04142f3ba246dcef))
- globals publish after draft ([44651e6](https://github.com/payloadcms/payload/commit/44651e6ecc354dbe17a08fccfafd686420d07158))
- minimize not set to false on all field type schemas ([ace032e](https://github.com/payloadcms/payload/commit/ace032ef897dc55131c6cf7cb80dc1a652940748))
- pass result of previous hook into next hook ([c661ac2](https://github.com/payloadcms/payload/commit/c661ac2e8a26251e77c558e00ed3c32741d2d385))
- properly resizes animated images ([#2181](https://github.com/payloadcms/payload/issues/2181)) ([8c4f890](https://github.com/payloadcms/payload/commit/8c4f890af0cbd1f2b3a2dd1980d26ba3e721f154))
- properly set req.payload on forgotPassword in local API ([#2194](https://github.com/payloadcms/payload/issues/2194)) ([5ac436e](https://github.com/payloadcms/payload/commit/5ac436e1843aacc81072992805bdbd1aed41d243))
- redirects example ([#2209](https://github.com/payloadcms/payload/issues/2209)) ([5aa203d](https://github.com/payloadcms/payload/commit/5aa203d020177eb25b7675d6ab30fc8721b9fe0c))
- removes duplicative fields from table columns [#2221](https://github.com/payloadcms/payload/issues/2221) ([#2226](https://github.com/payloadcms/payload/issues/2226)) ([474a3cb](https://github.com/payloadcms/payload/commit/474a3cbf7a90ab02d9e6c86ee018895576cbcab9))
- renders rte upload drawer [#2178](https://github.com/payloadcms/payload/issues/2178) ([523d9d4](https://github.com/payloadcms/payload/commit/523d9d495261b44fdb9c7922bfa9cdd8aaba85fb))
- skips field validation on submit if skipValidation is set to true ([cf17760](https://github.com/payloadcms/payload/commit/cf17760735d466a5817fc37bc3dc6f3ad8c52f7a))
- Validate typescript signature ([8d31ed6](https://github.com/payloadcms/payload/commit/8d31ed6d39d1a4d147e13de5b96073fab5563173))
- version comparison view errors on old select value ([#2163](https://github.com/payloadcms/payload/issues/2163)) ([a3cc3c3](https://github.com/payloadcms/payload/commit/a3cc3c342928e00564a662ba210635d78238fed8))
- versions table ([#2235](https://github.com/payloadcms/payload/issues/2235)) ([066f5f6](https://github.com/payloadcms/payload/commit/066f5f6d2cb48525896366166693af6c92d1814d))
- virtual fields example ([#2214](https://github.com/payloadcms/payload/issues/2214)) ([f6eb020](https://github.com/payloadcms/payload/commit/f6eb0202fec15a0ba0e6c357ecdb9ace62bd2ea9))
### Features
* Add Hungarian Translations ([#2169](https://github.com/payloadcms/payload/issues/2169)) ([ebd16e8](https://github.com/payloadcms/payload/commit/ebd16e8fdf811ec19dd5231b01c91f201d00d3a3))
* adds min and max options to relationship with hasMany ([0f38a0d](https://github.com/payloadcms/payload/commit/0f38a0dcf6a4d993579ed3af55940f28b13f5d3d))
* drag-and-drop columns ([#2142](https://github.com/payloadcms/payload/issues/2142)) ([e2c65e3](https://github.com/payloadcms/payload/commit/e2c65e3fa519fc04c7d1552064980ffee145a3bc))
* improves ui performance with thousands of fields ([0779f8d](https://github.com/payloadcms/payload/commit/0779f8d73da4767e9918b04cc8795e52b2198f4c))
- Add Hungarian Translations ([#2169](https://github.com/payloadcms/payload/issues/2169)) ([ebd16e8](https://github.com/payloadcms/payload/commit/ebd16e8fdf811ec19dd5231b01c91f201d00d3a3))
- adds min and max options to relationship with hasMany ([0f38a0d](https://github.com/payloadcms/payload/commit/0f38a0dcf6a4d993579ed3af55940f28b13f5d3d))
- drag-and-drop columns ([#2142](https://github.com/payloadcms/payload/issues/2142)) ([e2c65e3](https://github.com/payloadcms/payload/commit/e2c65e3fa519fc04c7d1552064980ffee145a3bc))
- improves ui performance with thousands of fields ([0779f8d](https://github.com/payloadcms/payload/commit/0779f8d73da4767e9918b04cc8795e52b2198f4c))
## [1.6.16](https://github.com/payloadcms/payload/compare/v1.6.15...v1.6.16) (2023-02-28)
### Bug Fixes
* [#2150](https://github.com/payloadcms/payload/issues/2150), can now query on N number of levels deep ([ac54b11](https://github.com/payloadcms/payload/commit/ac54b11f9d2f9cfde15a4421d13ce26ffd6cdc63))
* [#2179](https://github.com/payloadcms/payload/issues/2179), async default values resetting form state ([a4de51a](https://github.com/payloadcms/payload/commit/a4de51adaaa9399fa9036e485eb2e7f350719638))
* allows empty objects to be retained in db ([0247e2d](https://github.com/payloadcms/payload/commit/0247e2d1068527213f007c71f6efa1aff4c21af6))
* clear relationship value ([#2188](https://github.com/payloadcms/payload/issues/2188)) ([387cec9](https://github.com/payloadcms/payload/commit/387cec983868d6c10c043248b45fc8c1657e4981))
* ensures sorting on drafts works in all cases ([c87fd2b](https://github.com/payloadcms/payload/commit/c87fd2b649e59afb6fe7998d04142f3ba246dcef))
* globals publish after draft ([44651e6](https://github.com/payloadcms/payload/commit/44651e6ecc354dbe17a08fccfafd686420d07158))
* properly resizes animated images ([#2181](https://github.com/payloadcms/payload/issues/2181)) ([8c4f890](https://github.com/payloadcms/payload/commit/8c4f890af0cbd1f2b3a2dd1980d26ba3e721f154))
* properly set req.payload on forgotPassword in local API ([#2194](https://github.com/payloadcms/payload/issues/2194)) ([5ac436e](https://github.com/payloadcms/payload/commit/5ac436e1843aacc81072992805bdbd1aed41d243))
* redirects example ([#2209](https://github.com/payloadcms/payload/issues/2209)) ([5aa203d](https://github.com/payloadcms/payload/commit/5aa203d020177eb25b7675d6ab30fc8721b9fe0c))
* renders rte upload drawer [#2178](https://github.com/payloadcms/payload/issues/2178) ([523d9d4](https://github.com/payloadcms/payload/commit/523d9d495261b44fdb9c7922bfa9cdd8aaba85fb))
* skips field validation on submit if skipValidation is set to true ([cf17760](https://github.com/payloadcms/payload/commit/cf17760735d466a5817fc37bc3dc6f3ad8c52f7a))
* version comparison view errors on old select value ([#2163](https://github.com/payloadcms/payload/issues/2163)) ([a3cc3c3](https://github.com/payloadcms/payload/commit/a3cc3c342928e00564a662ba210635d78238fed8))
- [#2150](https://github.com/payloadcms/payload/issues/2150), can now query on N number of levels deep ([ac54b11](https://github.com/payloadcms/payload/commit/ac54b11f9d2f9cfde15a4421d13ce26ffd6cdc63))
- [#2179](https://github.com/payloadcms/payload/issues/2179), async default values resetting form state ([a4de51a](https://github.com/payloadcms/payload/commit/a4de51adaaa9399fa9036e485eb2e7f350719638))
- allows empty objects to be retained in db ([0247e2d](https://github.com/payloadcms/payload/commit/0247e2d1068527213f007c71f6efa1aff4c21af6))
- clear relationship value ([#2188](https://github.com/payloadcms/payload/issues/2188)) ([387cec9](https://github.com/payloadcms/payload/commit/387cec983868d6c10c043248b45fc8c1657e4981))
- ensures sorting on drafts works in all cases ([c87fd2b](https://github.com/payloadcms/payload/commit/c87fd2b649e59afb6fe7998d04142f3ba246dcef))
- globals publish after draft ([44651e6](https://github.com/payloadcms/payload/commit/44651e6ecc354dbe17a08fccfafd686420d07158))
- properly resizes animated images ([#2181](https://github.com/payloadcms/payload/issues/2181)) ([8c4f890](https://github.com/payloadcms/payload/commit/8c4f890af0cbd1f2b3a2dd1980d26ba3e721f154))
- properly set req.payload on forgotPassword in local API ([#2194](https://github.com/payloadcms/payload/issues/2194)) ([5ac436e](https://github.com/payloadcms/payload/commit/5ac436e1843aacc81072992805bdbd1aed41d243))
- redirects example ([#2209](https://github.com/payloadcms/payload/issues/2209)) ([5aa203d](https://github.com/payloadcms/payload/commit/5aa203d020177eb25b7675d6ab30fc8721b9fe0c))
- renders rte upload drawer [#2178](https://github.com/payloadcms/payload/issues/2178) ([523d9d4](https://github.com/payloadcms/payload/commit/523d9d495261b44fdb9c7922bfa9cdd8aaba85fb))
- skips field validation on submit if skipValidation is set to true ([cf17760](https://github.com/payloadcms/payload/commit/cf17760735d466a5817fc37bc3dc6f3ad8c52f7a))
- version comparison view errors on old select value ([#2163](https://github.com/payloadcms/payload/issues/2163)) ([a3cc3c3](https://github.com/payloadcms/payload/commit/a3cc3c342928e00564a662ba210635d78238fed8))
### Features
* Add Hungarian Translations ([#2169](https://github.com/payloadcms/payload/issues/2169)) ([ebd16e8](https://github.com/payloadcms/payload/commit/ebd16e8fdf811ec19dd5231b01c91f201d00d3a3))
* drag-and-drop columns ([#2142](https://github.com/payloadcms/payload/issues/2142)) ([e2c65e3](https://github.com/payloadcms/payload/commit/e2c65e3fa519fc04c7d1552064980ffee145a3bc))
- Add Hungarian Translations ([#2169](https://github.com/payloadcms/payload/issues/2169)) ([ebd16e8](https://github.com/payloadcms/payload/commit/ebd16e8fdf811ec19dd5231b01c91f201d00d3a3))
- drag-and-drop columns ([#2142](https://github.com/payloadcms/payload/issues/2142)) ([e2c65e3](https://github.com/payloadcms/payload/commit/e2c65e3fa519fc04c7d1552064980ffee145a3bc))
## [1.6.15](https://github.com/payloadcms/payload/compare/v1.6.14...v1.6.15) (2023-02-21)
### Bug Fixes
* mongoose connection error with useFacet ([5888fb9](https://github.com/payloadcms/payload/commit/5888fb9b3f82f49686da27c216b40c38b5a5d6c2))
- mongoose connection error with useFacet ([5888fb9](https://github.com/payloadcms/payload/commit/5888fb9b3f82f49686da27c216b40c38b5a5d6c2))
## [1.6.14](https://github.com/payloadcms/payload/compare/v1.6.13...v1.6.14) (2023-02-21)
### Bug Fixes
* [#2091](https://github.com/payloadcms/payload/issues/2091) admin translations for filter operators ([#2143](https://github.com/payloadcms/payload/issues/2143)) ([8a8c392](https://github.com/payloadcms/payload/commit/8a8c3920950ece5995f81bff717b30a2baf8f219))
* [#2096](https://github.com/payloadcms/payload/issues/2096), allows custom ts paths with payload generate:types ([686a616](https://github.com/payloadcms/payload/commit/686a616b4cf06685fd22b075cf87ceafec455e40))
* [#2117](https://github.com/payloadcms/payload/issues/2117) collection pagination defaultLimit ([#2147](https://github.com/payloadcms/payload/issues/2147)) ([2a4db38](https://github.com/payloadcms/payload/commit/2a4db3896ead2b49c0a7ebc5da6b9825b223ca19))
* [#2131](https://github.com/payloadcms/payload/issues/2131), doesn't log in unverified user after resetting password ([3eb85b1](https://github.com/payloadcms/payload/commit/3eb85b1554ceb705c4a1436af4d9ba982e4cdbdf))
* [#2134](https://github.com/payloadcms/payload/issues/2134), allows links to be populated without having relationship or upload enabled ([32a0778](https://github.com/payloadcms/payload/commit/32a0778fc4311509699b14f9a3f145380ec56e25))
* [#2148](https://github.com/payloadcms/payload/issues/2148), adds queryHiddenFields property to find operation ([15b6bb3](https://github.com/payloadcms/payload/commit/15b6bb3d756697428775df5ece3c6092d0537d82))
* checks locale is valid for monaco code editor ([#2144](https://github.com/payloadcms/payload/issues/2144)) ([40224ed](https://github.com/payloadcms/payload/commit/40224ed1bcd886be8bf2f5b42a272db7615495c1))
* generate proper json field type according to rfc ([#2137](https://github.com/payloadcms/payload/issues/2137)) ([7e88698](https://github.com/payloadcms/payload/commit/7e8869858cfca70b2e996d984e065da75398076b))
* removes custom header and gutter from rte link drawer [#2120](https://github.com/payloadcms/payload/issues/2120) ([#2135](https://github.com/payloadcms/payload/issues/2135)) ([6a7663b](https://github.com/payloadcms/payload/commit/6a7663beb57f624ea52d95a8f26345dcd32d65bc))
* sizes property optional on upload ([#2066](https://github.com/payloadcms/payload/issues/2066)) ([79d047e](https://github.com/payloadcms/payload/commit/79d047e64fd40507abf9de2ced5dab7aeb2bb6fa))
* useFacet config option to disable $facet aggregation ([#2141](https://github.com/payloadcms/payload/issues/2141)) ([b4a2074](https://github.com/payloadcms/payload/commit/b4a20741b2d995e5e46875c2ae1f11ff5b319e6b))
- [#2091](https://github.com/payloadcms/payload/issues/2091) admin translations for filter operators ([#2143](https://github.com/payloadcms/payload/issues/2143)) ([8a8c392](https://github.com/payloadcms/payload/commit/8a8c3920950ece5995f81bff717b30a2baf8f219))
- [#2096](https://github.com/payloadcms/payload/issues/2096), allows custom ts paths with payload generate:types ([686a616](https://github.com/payloadcms/payload/commit/686a616b4cf06685fd22b075cf87ceafec455e40))
- [#2117](https://github.com/payloadcms/payload/issues/2117) collection pagination defaultLimit ([#2147](https://github.com/payloadcms/payload/issues/2147)) ([2a4db38](https://github.com/payloadcms/payload/commit/2a4db3896ead2b49c0a7ebc5da6b9825b223ca19))
- [#2131](https://github.com/payloadcms/payload/issues/2131), doesn't log in unverified user after resetting password ([3eb85b1](https://github.com/payloadcms/payload/commit/3eb85b1554ceb705c4a1436af4d9ba982e4cdbdf))
- [#2134](https://github.com/payloadcms/payload/issues/2134), allows links to be populated without having relationship or upload enabled ([32a0778](https://github.com/payloadcms/payload/commit/32a0778fc4311509699b14f9a3f145380ec56e25))
- [#2148](https://github.com/payloadcms/payload/issues/2148), adds queryHiddenFields property to find operation ([15b6bb3](https://github.com/payloadcms/payload/commit/15b6bb3d756697428775df5ece3c6092d0537d82))
- checks locale is valid for monaco code editor ([#2144](https://github.com/payloadcms/payload/issues/2144)) ([40224ed](https://github.com/payloadcms/payload/commit/40224ed1bcd886be8bf2f5b42a272db7615495c1))
- generate proper json field type according to rfc ([#2137](https://github.com/payloadcms/payload/issues/2137)) ([7e88698](https://github.com/payloadcms/payload/commit/7e8869858cfca70b2e996d984e065da75398076b))
- removes custom header and gutter from rte link drawer [#2120](https://github.com/payloadcms/payload/issues/2120) ([#2135](https://github.com/payloadcms/payload/issues/2135)) ([6a7663b](https://github.com/payloadcms/payload/commit/6a7663beb57f624ea52d95a8f26345dcd32d65bc))
- sizes property optional on upload ([#2066](https://github.com/payloadcms/payload/issues/2066)) ([79d047e](https://github.com/payloadcms/payload/commit/79d047e64fd40507abf9de2ced5dab7aeb2bb6fa))
- useFacet config option to disable $facet aggregation ([#2141](https://github.com/payloadcms/payload/issues/2141)) ([b4a2074](https://github.com/payloadcms/payload/commit/b4a20741b2d995e5e46875c2ae1f11ff5b319e6b))
## [1.6.13](https://github.com/payloadcms/payload/compare/v1.6.12...v1.6.13) (2023-02-18)
### Bug Fixes
* [#2125](https://github.com/payloadcms/payload/issues/2125), ensures createdAt and updatedAt are returned in update operations ([42ebf68](https://github.com/payloadcms/payload/commit/42ebf6893257256554a57e6b6684a726d11800b8))
- [#2125](https://github.com/payloadcms/payload/issues/2125), ensures createdAt and updatedAt are returned in update operations ([42ebf68](https://github.com/payloadcms/payload/commit/42ebf6893257256554a57e6b6684a726d11800b8))
## [1.6.12](https://github.com/payloadcms/payload/compare/v1.6.11...v1.6.12) (2023-02-17)
### Bug Fixes
* ensures only valid fields can be queried on ([1930bc2](https://github.com/payloadcms/payload/commit/1930bc260e721c5c7a10793b5d2a7809694089f3))
- ensures only valid fields can be queried on ([1930bc2](https://github.com/payloadcms/payload/commit/1930bc260e721c5c7a10793b5d2a7809694089f3))
### Features
* adds gql auth example ([#2115](https://github.com/payloadcms/payload/issues/2115)) ([fa32c27](https://github.com/payloadcms/payload/commit/fa32c2771637af11d7ef0fb21b2f1f3cceae1ead))
* auth example ([c076c77](https://github.com/payloadcms/payload/commit/c076c77db4a26cf514a040b1048de25b1141f0cb))
* separates admin root component from DOM render logic ([ff4d1f6](https://github.com/payloadcms/payload/commit/ff4d1f6ac26f5cac56b6c5b7b67b99f50067cb8d))
* virtual fields example ([#1990](https://github.com/payloadcms/payload/issues/1990)) ([2af0c04](https://github.com/payloadcms/payload/commit/2af0c04c8ae5892b317af240c1502bc21bb65253))
- adds gql auth example ([#2115](https://github.com/payloadcms/payload/issues/2115)) ([fa32c27](https://github.com/payloadcms/payload/commit/fa32c2771637af11d7ef0fb21b2f1f3cceae1ead))
- auth example ([c076c77](https://github.com/payloadcms/payload/commit/c076c77db4a26cf514a040b1048de25b1141f0cb))
- separates admin root component from DOM render logic ([ff4d1f6](https://github.com/payloadcms/payload/commit/ff4d1f6ac26f5cac56b6c5b7b67b99f50067cb8d))
- virtual fields example ([#1990](https://github.com/payloadcms/payload/issues/1990)) ([2af0c04](https://github.com/payloadcms/payload/commit/2af0c04c8ae5892b317af240c1502bc21bb65253))
## [1.6.11](https://github.com/payloadcms/payload/compare/v1.6.10...v1.6.11) (2023-02-15)
### Bug Fixes
* existing upload deletion [#2098](https://github.com/payloadcms/payload/issues/2098) ([#2101](https://github.com/payloadcms/payload/issues/2101)) ([060c380](https://github.com/payloadcms/payload/commit/060c3805e567fe450c4b9aa00fbdbb919427c625))
- existing upload deletion [#2098](https://github.com/payloadcms/payload/issues/2098) ([#2101](https://github.com/payloadcms/payload/issues/2101)) ([060c380](https://github.com/payloadcms/payload/commit/060c3805e567fe450c4b9aa00fbdbb919427c625))
### Features
* preview example ([#1950](https://github.com/payloadcms/payload/issues/1950)) ([0a87f10](https://github.com/payloadcms/payload/commit/0a87f106ecb5c95738109db5231d72abd281e7e1))
- preview example ([#1950](https://github.com/payloadcms/payload/issues/1950)) ([0a87f10](https://github.com/payloadcms/payload/commit/0a87f106ecb5c95738109db5231d72abd281e7e1))
## [1.6.10](https://github.com/payloadcms/payload/compare/v1.6.9...v1.6.10) (2023-02-14)
### Bug Fixes
* [#2077](https://github.com/payloadcms/payload/issues/2077) useAPIKey UI missing with disableLocalStrategy ([#2084](https://github.com/payloadcms/payload/issues/2084)) ([586b25a](https://github.com/payloadcms/payload/commit/586b25a54c6ec8bd134bce05c480cd429e47e252))
* Add missing Spanish translations and fix typos ([c4742e5](https://github.com/payloadcms/payload/commit/c4742e5c303ca4ba41c2fbb45a8e8474608418c1))
* document type in update request handler ([d5cd970](https://github.com/payloadcms/payload/commit/d5cd9709f717b08b930461079b147967d8d7a885))
* ensures versions createdAt matches the original doc ([8c7e37c](https://github.com/payloadcms/payload/commit/8c7e37c56aab2bb28de01cf7d4a91062cbde80de))
* globals not saving drafts unless published first ([#2082](https://github.com/payloadcms/payload/issues/2082)) ([4999fba](https://github.com/payloadcms/payload/commit/4999fbaee680e256ece7083fbe422f25e85de0d5))
* Use the user's AdminUI locale for the DatePicker ([#2046](https://github.com/payloadcms/payload/issues/2046)) ([#2057](https://github.com/payloadcms/payload/issues/2057)) ([b4a7e91](https://github.com/payloadcms/payload/commit/b4a7e912b2117cef3345adb8b514958345838030))
* validate type ([7bb0984](https://github.com/payloadcms/payload/commit/7bb0984a12a0d80d9ac2af82427ac7dbc985ffc5))
- [#2077](https://github.com/payloadcms/payload/issues/2077) useAPIKey UI missing with disableLocalStrategy ([#2084](https://github.com/payloadcms/payload/issues/2084)) ([586b25a](https://github.com/payloadcms/payload/commit/586b25a54c6ec8bd134bce05c480cd429e47e252))
- Add missing Spanish translations and fix typos ([c4742e5](https://github.com/payloadcms/payload/commit/c4742e5c303ca4ba41c2fbb45a8e8474608418c1))
- document type in update request handler ([d5cd970](https://github.com/payloadcms/payload/commit/d5cd9709f717b08b930461079b147967d8d7a885))
- ensures versions createdAt matches the original doc ([8c7e37c](https://github.com/payloadcms/payload/commit/8c7e37c56aab2bb28de01cf7d4a91062cbde80de))
- globals not saving drafts unless published first ([#2082](https://github.com/payloadcms/payload/issues/2082)) ([4999fba](https://github.com/payloadcms/payload/commit/4999fbaee680e256ece7083fbe422f25e85de0d5))
- Use the user's AdminUI locale for the DatePicker ([#2046](https://github.com/payloadcms/payload/issues/2046)) ([#2057](https://github.com/payloadcms/payload/issues/2057)) ([b4a7e91](https://github.com/payloadcms/payload/commit/b4a7e912b2117cef3345adb8b514958345838030))
- validate type ([7bb0984](https://github.com/payloadcms/payload/commit/7bb0984a12a0d80d9ac2af82427ac7dbc985ffc5))
### Features
* allows control over relationship add new button ([6096044](https://github.com/payloadcms/payload/commit/6096044fe058113ca47c7f7d833cb788d97df9a2))
* async plugins ([#2030](https://github.com/payloadcms/payload/issues/2030)) ([9f30553](https://github.com/payloadcms/payload/commit/9f3055381337f80229f220c1e6114b4ea56be969))
* export more errors ([3a2a41d](https://github.com/payloadcms/payload/commit/3a2a41d2b6ead4188b432d9e6780764a7c08b2dd))
- allows control over relationship add new button ([6096044](https://github.com/payloadcms/payload/commit/6096044fe058113ca47c7f7d833cb788d97df9a2))
- async plugins ([#2030](https://github.com/payloadcms/payload/issues/2030)) ([9f30553](https://github.com/payloadcms/payload/commit/9f3055381337f80229f220c1e6114b4ea56be969))
- export more errors ([3a2a41d](https://github.com/payloadcms/payload/commit/3a2a41d2b6ead4188b432d9e6780764a7c08b2dd))
## [1.6.9](https://github.com/payloadcms/payload/compare/v1.6.7...v1.6.9) (2023-02-10)
### Bug Fixes
* adds query constraint to ensureMaxVersions query ([30688bb](https://github.com/payloadcms/payload/commit/30688bbe4136285af181a5deae5e949b98bea0be))
* translation of "or" -> "ou" in french ([#2047](https://github.com/payloadcms/payload/issues/2047)) ([dddbec2](https://github.com/payloadcms/payload/commit/dddbec268255c41b7ea786bdddc02dfeb7d66fbd))
- adds query constraint to ensureMaxVersions query ([30688bb](https://github.com/payloadcms/payload/commit/30688bbe4136285af181a5deae5e949b98bea0be))
- translation of "or" -> "ou" in french ([#2047](https://github.com/payloadcms/payload/issues/2047)) ([dddbec2](https://github.com/payloadcms/payload/commit/dddbec268255c41b7ea786bdddc02dfeb7d66fbd))
### Features
* allows customization of the folder used to serve admin bundled files in production ([4d259a6](https://github.com/payloadcms/payload/commit/4d259a69f2c9beb1d84f703a08921469e6f1c34b))
- allows customization of the folder used to serve admin bundled files in production ([4d259a6](https://github.com/payloadcms/payload/commit/4d259a69f2c9beb1d84f703a08921469e6f1c34b))
## [1.6.7](https://github.com/payloadcms/payload/compare/v1.6.6...v1.6.7) (2023-02-08)
### Bug Fixes
* drawer state was not set when opened ([e6ac872](https://github.com/payloadcms/payload/commit/e6ac872b0d80470883836ef5aac0bdf4b62d6de9))
- drawer state was not set when opened ([e6ac872](https://github.com/payloadcms/payload/commit/e6ac872b0d80470883836ef5aac0bdf4b62d6de9))
## [1.6.6](https://github.com/payloadcms/payload/compare/v1.6.5...v1.6.6) (2023-02-07)
### Bug Fixes
* [#1887](https://github.com/payloadcms/payload/issues/1887), dataloader rich text population infinite loop ([ac2e174](https://github.com/payloadcms/payload/commit/ac2e174643419e5b01cfbbf53234b0145aeb5e4e))
* enables locales with date field ([aefb655](https://github.com/payloadcms/payload/commit/aefb655769e7998a44cef9f93a19e4aef24c50bb))
- [#1887](https://github.com/payloadcms/payload/issues/1887), dataloader rich text population infinite loop ([ac2e174](https://github.com/payloadcms/payload/commit/ac2e174643419e5b01cfbbf53234b0145aeb5e4e))
- enables locales with date field ([aefb655](https://github.com/payloadcms/payload/commit/aefb655769e7998a44cef9f93a19e4aef24c50bb))
## [1.6.5](https://github.com/payloadcms/payload/compare/v1.6.4...v1.6.5) (2023-02-07)
### Bug Fixes
* allows radio input to be tabbable ([b5880f2](https://github.com/payloadcms/payload/commit/b5880f26af8b97d47eca83a9fc7bd05b006cc54c))
* auth type leaking into type gen ([1f0a1c7](https://github.com/payloadcms/payload/commit/1f0a1c796ab4126a464949f3a1bc34c7360470a5))
* corrects keyboard accessibility for checkbox field ([65b8fd2](https://github.com/payloadcms/payload/commit/65b8fd27af05c25c3ddf86c34e1f181b8a605c27))
* ensures preview is enabled before rendering button ([e968f40](https://github.com/payloadcms/payload/commit/e968f4067c2427965c0f96845aff8eaca36d0df6))
* local API update typing ([#2010](https://github.com/payloadcms/payload/issues/2010)) ([4b0d4f4](https://github.com/payloadcms/payload/commit/4b0d4f4cd59940cace6b6b8cebf3d834d2b88dab)), closes [#2009](https://github.com/payloadcms/payload/issues/2009)
* max versions incorrectly sorting, causing incorrect versions to be held onto ([2e4f7ab](https://github.com/payloadcms/payload/commit/2e4f7ab35c23f25051a5000e7902df7f255ed607))
* named tabs not displaying data in versions view ([a41e295](https://github.com/payloadcms/payload/commit/a41e295e42fbf283733afd8b63bced9555cb1338))
* replaced media not rendering after document save ([827428d](https://github.com/payloadcms/payload/commit/827428d6b57a7abe858ca5ddaad5ba4ec9d3a270))
* webpack css-loader resolve urls ([ade4c01](https://github.com/payloadcms/payload/commit/ade4c011d348249e975a1510ae481018834a2ca2))
- allows radio input to be tabbable ([b5880f2](https://github.com/payloadcms/payload/commit/b5880f26af8b97d47eca83a9fc7bd05b006cc54c))
- auth type leaking into type gen ([1f0a1c7](https://github.com/payloadcms/payload/commit/1f0a1c796ab4126a464949f3a1bc34c7360470a5))
- corrects keyboard accessibility for checkbox field ([65b8fd2](https://github.com/payloadcms/payload/commit/65b8fd27af05c25c3ddf86c34e1f181b8a605c27))
- ensures preview is enabled before rendering button ([e968f40](https://github.com/payloadcms/payload/commit/e968f4067c2427965c0f96845aff8eaca36d0df6))
- local API update typing ([#2010](https://github.com/payloadcms/payload/issues/2010)) ([4b0d4f4](https://github.com/payloadcms/payload/commit/4b0d4f4cd59940cace6b6b8cebf3d834d2b88dab)), closes [#2009](https://github.com/payloadcms/payload/issues/2009)
- max versions incorrectly sorting, causing incorrect versions to be held onto ([2e4f7ab](https://github.com/payloadcms/payload/commit/2e4f7ab35c23f25051a5000e7902df7f255ed607))
- named tabs not displaying data in versions view ([a41e295](https://github.com/payloadcms/payload/commit/a41e295e42fbf283733afd8b63bced9555cb1338))
- replaced media not rendering after document save ([827428d](https://github.com/payloadcms/payload/commit/827428d6b57a7abe858ca5ddaad5ba4ec9d3a270))
- webpack css-loader resolve urls ([ade4c01](https://github.com/payloadcms/payload/commit/ade4c011d348249e975a1510ae481018834a2ca2))
### Features
* deletes old media upon re-upload [#1897](https://github.com/payloadcms/payload/issues/1897) ([02f9be2](https://github.com/payloadcms/payload/commit/02f9be2c4a15eed6bba07f504319a2213ea411df))
* enables document drawers from read-only fields ([#1989](https://github.com/payloadcms/payload/issues/1989)) ([0dbc4fa](https://github.com/payloadcms/payload/commit/0dbc4fa21334e1a17c5aa35d84d78973fb7f54ec))
- deletes old media upon re-upload [#1897](https://github.com/payloadcms/payload/issues/1897) ([02f9be2](https://github.com/payloadcms/payload/commit/02f9be2c4a15eed6bba07f504319a2213ea411df))
- enables document drawers from read-only fields ([#1989](https://github.com/payloadcms/payload/issues/1989)) ([0dbc4fa](https://github.com/payloadcms/payload/commit/0dbc4fa21334e1a17c5aa35d84d78973fb7f54ec))
## [1.6.4](https://github.com/payloadcms/payload/compare/v1.6.3...v1.6.4) (2023-02-03)
### Bug Fixes
* only hoists localized values if localization is enabled ([8c65f6a](https://github.com/payloadcms/payload/commit/8c65f6a93836d80fb22724454f5efb49e11763ad))
- only hoists localized values if localization is enabled ([8c65f6a](https://github.com/payloadcms/payload/commit/8c65f6a93836d80fb22724454f5efb49e11763ad))
### Features
* support large file uploads ([#1981](https://github.com/payloadcms/payload/issues/1981)) ([12ed655](https://github.com/payloadcms/payload/commit/12ed65588131c6db5252a1302a7dd82f0a10bd2e))
- support large file uploads ([#1981](https://github.com/payloadcms/payload/issues/1981)) ([12ed655](https://github.com/payloadcms/payload/commit/12ed65588131c6db5252a1302a7dd82f0a10bd2e))
## [1.6.3](https://github.com/payloadcms/payload/compare/v1.6.2...v1.6.3) (2023-02-01)
### Bug Fixes
* properly await graphql schema generation ([888b3a2](https://github.com/payloadcms/payload/commit/888b3a26727b32d19e39d1a8b672eb1881effad7))
- properly await graphql schema generation ([888b3a2](https://github.com/payloadcms/payload/commit/888b3a26727b32d19e39d1a8b672eb1881effad7))
## [1.6.2](https://github.com/payloadcms/payload/compare/v1.6.1...v1.6.2) (2023-02-01)

View File

@@ -30,7 +30,7 @@ If a Collection supports [`Authentication`](/docs/authentication/overview), the
```ts
import { CollectionConfig } from 'payload/types';
const Posts: CollectionConfig = {
export const Posts: CollectionConfig = {
slug: "posts",
// highlight-start
access: {
@@ -42,8 +42,6 @@ const Posts: CollectionConfig = {
},
// highlight-end
};
export default Categories;
```
### Create

View File

@@ -20,7 +20,7 @@ Field Access Control is specified with functions inside a field's config. All fi
```ts
import { CollectionConfig } from 'payload/types';
const Posts: CollectionConfig = {
export const Posts: CollectionConfig = {
slug: 'posts',
fields: [
{
@@ -67,6 +67,8 @@ Returns a boolean which allows or denies the ability to read a field's value. If
Returns a boolean which allows or denies the ability to update a field's value. If `false` is returned, any passed values will be discarded.
If `false` is returned and you attempt to update the field's value, the operation will **not** throw an error however the field will be omitted from the update operation and the value will remain unchanged.
**Available argument properties:**
| Option | Description |

View File

@@ -21,22 +21,22 @@ To swap in your own React component, first, consult the list of available compon
You can override a set of admin panel-wide components by providing a component to your base Payload config's `admin.components` property. The following options are available:
| Path | Description |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`Nav`** | Contains the sidebar and mobile Nav in its entirety. |
| **`logout.Button`** | A custom React component.
| **`BeforeDashboard`** | Array of components to inject into the built-in Dashboard, _before_ the default dashboard contents. |
| **`AfterDashboard`** | Array of components to inject into the built-in Dashboard, _after_ the default dashboard contents. [Demo](https://github.com/payloadcms/payload/tree/master/test/admin/components/AfterDashboard/index.tsx) |
| **`BeforeLogin`** | Array of components to inject into the built-in Login, _before_ the default login form. |
| **`AfterLogin`** | Array of components to inject into the built-in Login, _after_ the default login form. |
| **`BeforeNavLinks`** | Array of components to inject into the built-in Nav, _before_ the links themselves. |
| **`AfterNavLinks`** | Array of components to inject into the built-in Nav, _after_ the links. |
| **`views.Account`** | The Account view is used to show the currently logged in user's Account page. |
| **`views.Dashboard`** | The main landing page of the Admin panel. |
| **`graphics.Icon`** | Used as a graphic within the `Nav` component. Often represents a condensed version of a full logo. |
| **`graphics.Logo`** | The full logo to be used in contexts like the `Login` view. |
| **`routes`** | Define your own routes to add to the Payload Admin UI. [More](#custom-routes) |
| **`providers`** | Define your own provider components that will wrap the Payload Admin UI. [More](#custom-providers) |
| Path | Description |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`Nav`** | Contains the sidebar and mobile Nav in its entirety. |
| **`logout.Button`** | A custom React component. |
| **`BeforeDashboard`** | Array of components to inject into the built-in Dashboard, _before_ the default dashboard contents. |
| **`AfterDashboard`** | Array of components to inject into the built-in Dashboard, _after_ the default dashboard contents. [Demo](https://github.com/payloadcms/payload/tree/master/test/admin/components/AfterDashboard/index.tsx) |
| **`BeforeLogin`** | Array of components to inject into the built-in Login, _before_ the default login form. |
| **`AfterLogin`** | Array of components to inject into the built-in Login, _after_ the default login form. |
| **`BeforeNavLinks`** | Array of components to inject into the built-in Nav, _before_ the links themselves. |
| **`AfterNavLinks`** | Array of components to inject into the built-in Nav, _after_ the links. |
| **`views.Account`** | The Account view is used to show the currently logged in user's Account page. |
| **`views.Dashboard`** | The main landing page of the Admin panel. |
| **`graphics.Icon`** | Used as a graphic within the `Nav` component. Often represents a condensed version of a full logo. |
| **`graphics.Logo`** | The full logo to be used in contexts like the `Login` view. |
| **`routes`** | Define your own routes to add to the Payload Admin UI. [More](#custom-routes) |
| **`providers`** | Define your own provider components that will wrap the Payload Admin UI. [More](#custom-providers) |
#### Full example:
@@ -77,18 +77,76 @@ _For more examples regarding how to customize components, look at the following
You can override components on a Collection-by-Collection basis via each Collection's `admin` property.
| Path | Description |
| ---------------- | ------------------------------------------------------------------------------------------------ |
| **`views.Edit`** | Used while a document within this Collection is being edited. |
| **`views.List`** | The `List` view is used to render a paginated, filterable table of Documents in this Collection. |
| Path | Description |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| **`views.Edit`** | Used while a document within this Collection is being edited. |
| **`views.List`** | The `List` view is used to render a paginated, filterable table of Documents in this Collection. |
| **`edit.SaveButton`** | Replace the default `Save` button with a custom component. Drafts must be disabled |
| **`edit.SaveDraftButton`** | Replace the default `Save Draft` button with a custom component. Drafts must be enabled and autosave must be disabled. |
| **`edit.PublishButton`** | Replace the default `Publish` button with a custom component. Drafts must be enabled. |
| **`edit.PreviewButton`** | Replace the default `Preview` button with a custom component. |
#### Examples
```tsx
// Custom Buttons
import * as React from "react";
import {
CustomSaveButtonProps,
CustomSaveDraftButtonProps,
CustomPublishButtonProps,
CustomPreviewButtonProps,
} from "payload/types";
export const CustomSaveButton: CustomSaveButtonProps = ({
DefaultButton,
label,
}) => {
return <DefaultButton label={label} />;
};
export const CustomSaveDraftButton: CustomSaveDraftButtonProps = ({
DefaultButton,
disabled,
label,
saveDraft,
}) => {
return (
<DefaultButton label={label} disabled={disabled} saveDraft={saveDraft} />
);
};
export const CustomPublishButton: CustomPublishButtonProps = ({
DefaultButton,
disabled,
label,
publish,
}) => {
return <DefaultButton label={label} disabled={disabled} publish={publish} />;
};
export const CustomPreviewButton: CustomPreviewButtonProps = ({
DefaultButton,
disabled,
label,
preview,
}) => {
return <DefaultButton label={label} disabled={disabled} preview={preview} />;
};
```
### Globals
As with Collections, You can override components on a global-by-global basis via their `admin` property.
| Path | Description |
| ---------------- | --------------------------------------- |
| **`views.Edit`** | Used while this Global is being edited. |
| Path | Description |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| **`views.Edit`** | Used while this Global is being edited. |
| **`edit.SaveButton`** | Replace the default `Save` button with a custom component. Drafts must be disabled |
| **`edit.SaveDraftButton`** | Replace the default `Save Draft` button with a custom component. Drafts must be enabled and autosave must be disabled. |
| **`edit.PublishButton`** | Replace the default `Publish` button with a custom component. Drafts must be enabled. |
| **`edit.PreviewButton`** | Replace the default `Preview` button with a custom component. |
### Fields
@@ -163,7 +221,11 @@ const CustomTextField: React.FC<Props> = ({ path }) => {
<Banner type="success">
For more information regarding the hooks that are available to you while you
build custom components, including the <strong>useField</strong> hook, <a href="/docs/admin/hooks" style={{ color: "black" }}>click here</a>.
build custom components, including the <strong>useField</strong> hook,{" "}
<a href="/docs/admin/hooks" style={{ color: "black" }}>
click here
</a>
.
</Banner>
## Custom routes
@@ -232,19 +294,20 @@ To make use of Payload SCSS variables / mixins to use directly in your own compo
When developing custom components you can support multiple languages to be consistent with Payload's i18n support. The best way to do this is to add your translation resources to the [i18n configuration](https://payloadcms.com/docs/configuration/i18n) and import `useTranslation` from `react-i18next` in your components.
For example:
```tsx
import { useTranslation } from 'react-i18next';
import { useTranslation } from "react-i18next";
const CustomComponent: React.FC = () => {
// highlight-start
const { t, i18n } = useTranslation('namespace1');
const { t, i18n } = useTranslation("namespace1");
// highlight-end
return (
<ul>
<li>{ t('key', { variable: 'value' }) }</li>
<li>{ t('namespace2:key', { variable: 'value' }) }</li>
<li>{ i18n.language }</li>
<li>{t("key", { variable: "value" })}</li>
<li>{t("namespace2:key", { variable: "value" })}</li>
<li>{i18n.language}</li>
</ul>
);
};

View File

@@ -166,7 +166,6 @@ The `useDocumentInfo` hook provides lots of information about the document curre
|---------------------------|--------------------------------------------------------------------------------------------------------------------| |
| **`collection`** | If the doc is a collection, its collection config will be returned |
| **`global`** | If the doc is a global, its global config will be returned |
| **`type`** | The type of document being edited (collection or global) |
| **`id`** | If the doc is a collection, its ID will be returned |
| **`preferencesKey`** | The `preferences` key to use when interacting with document-level user preferences |
| **`versions`** | Versions of the current doc |

View File

@@ -56,7 +56,7 @@ You may rely on server-only packages such as the above to perform logic in acces
import { CollectionConfig } from 'payload/types';
import createStripeSubscription from './hooks/createStripeSubscription';
const Subscription: CollectionConfig = {
export const Subscription: CollectionConfig = {
slug: 'subscriptions',
hooks: {
beforeChange: [
@@ -71,8 +71,6 @@ const Subscription: CollectionConfig = {
}
]
};
export default Subscription;
```
The collection above features a `beforeChange` hook that creates a Stripe subscription whenever a Subscription document is created in Payload.

View File

@@ -82,7 +82,7 @@ Example:
```ts
import { CollectionConfig } from 'payload/types';
const Customers: CollectionConfig = {
export const Customers: CollectionConfig = {
slug: 'customers',
auth: {
forgotPassword: {
@@ -156,7 +156,7 @@ Example:
import { CollectionConfig } from 'payload/types';
const Customers: CollectionConfig = {
export const Customers: CollectionConfig = {
slug: 'customers',
auth: {
verify: {

View File

@@ -35,8 +35,8 @@ Simple example collection:
```ts
import { CollectionConfig } from 'payload/types';
const Admins: CollectionConfig = {
slug:
export const Admins: CollectionConfig = {
slug: 'admins',
// highlight-start
auth: {
tokenExpiration: 7200, // How many seconds to keep the user logged in

View File

@@ -16,6 +16,7 @@ It's often best practice to write your Collections in separate files and then im
|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **`slug`** * | Unique, URL-friendly string that will act as an identifier for this Collection. |
| **`fields`** * | Array of field types that will determine the structure and functionality of the data stored within this Collection. [Click here](/docs/fields/overview) for a full list of field types as well as how to configure them. |
| **`indexes`** * | Array of database indexes to create, including compound indexes that have multiple fields. |
| **`labels`** | Singular and plural labels for use in identifying this Collection throughout Payload. Auto-generated from slug if not defined. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-options). |
| **`hooks`** | Entry points to "tie in" to Collection actions at specific points. [More](/docs/hooks/overview#collection-hooks) |
@@ -27,8 +28,9 @@ It's often best practice to write your Collections in separate files and then im
| **`endpoints`** | Add custom routes to the REST API. [More](/docs/rest-api/overview#custom-endpoints) |
| **`graphQL`** | An object with `singularName` and `pluralName` strings used in schema generation. Auto-generated from slug if not defined. |
| **`typescript`** | An object with property `interface` as the text used in schema generation. Auto-generated from slug if not defined. |
| **`defaultSort`** | Pass a top-level field to sort by default in the collection List view. Prefix the name of the field with a minus symbol ("-") to sort in descending order. |
| **`pagination`** | Set pagination-specific options for this collection. [More](#pagination) |
| **`defaultSort`** | Pass a top-level field to sort by default in the collection List view. Prefix the name of the field with a minus symbol ("-") to sort in descending order. |
| **`pagination`** | Set pagination-specific options for this collection. [More](#pagination) |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -37,7 +39,7 @@ It's often best practice to write your Collections in separate files and then im
```ts
import { CollectionConfig } from 'payload/types';
const Orders: CollectionConfig = {
export const Orders: CollectionConfig = {
slug: 'orders',
fields: [
{
@@ -51,7 +53,7 @@ const Orders: CollectionConfig = {
relationTo: 'customers',
required: true,
}
]
],
};
```
@@ -63,18 +65,21 @@ You can find an assortment of [example collection configs](https://github.com/pa
You can customize the way that the Admin panel behaves on a collection-by-collection basis by defining the `admin` property on a collection's config.
| Option | Description |
| --------------------------- | -------------|
| `group` | Text used as a label for grouping collection links together in the navigation. |
| `hooks` | Admin-specific hooks for this collection. [More](#admin-hooks) |
| `useAsTitle` | Specify a top-level field to use for a document title throughout the Admin panel. If no field is defined, the ID of the document is used as the title. |
| `description` | Text or React component to display below the Collection label in the List view to give editors more information. |
| `defaultColumns` | Array of field names that correspond to which columns to show by default in this collection's List view. |
| `disableDuplicate ` | Disables the "Duplicate" button while editing documents within this collection. |
| Option | Description |
|------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `group` | Text used as a label for grouping collection links together in the navigation. |
| `hidden` | Set to true or a function, called with the current user, returning true to exclude this collection from navigation and admin routing. |
| `hooks` | Admin-specific hooks for this collection. [More](#admin-hooks) |
| `useAsTitle` | Specify a top-level field to use for a document title throughout the Admin panel. If no field is defined, the ID of the document is used as the title. |
| `description` | Text or React component to display below the Collection label in the List view to give editors more information. |
| `defaultColumns` | Array of field names that correspond to which columns to show by default in this collection's List view. |
| `disableDuplicate ` | Disables the "Duplicate" button while editing documents within this collection. |
| `hideAPIURL` | Hides the "API URL" meta field while editing documents within this collection. |
| `enableRichTextLink` | The [Rich Text](/docs/fields/rich-text) field features a `Link` element which allows for users to automatically reference related documents within their rich text. Set to `true` by default. |
| `enableRichTextRelationship` | The [Rich Text](/docs/fields/rich-text) field features a `Relationship` element which allows for users to automatically reference related documents within their rich text. Set to `true` by default. |
| `preview` | Function to generate preview URLS within the Admin panel that can point to your app. [More](#preview). |
| `components` | Swap in your own React components to be used within this collection. [More](/docs/admin/components#collections) |
| `listSearchableFields` | Specify which fields should be searched in the List search view. [More](#list-searchable-fields) |
| `preview` | Function to generate preview URLS within the Admin panel that can point to your app. [More](#preview). |
| `components` | Swap in your own React components to be used within this collection. [More](/docs/admin/components#collections) |
| `listSearchableFields` | Specify which fields should be searched in the List search view. [More](#list-searchable-fields) |
### Preview
@@ -92,7 +97,7 @@ If the function is specified, a Preview button will automatically appear in the
```ts
import { CollectionConfig } from 'payload/types';
const Posts: CollectionConfig = {
export const Posts: CollectionConfig = {
slug: 'posts',
fields: [
{

View File

@@ -8,6 +8,40 @@ keywords: config, configuration, documentation, Content Management System, cms,
Payload utilizes a few Express-specific middleware packages within its own routers. You can customize how they work by passing in configuration options to the main Payload config's `express` property.
### Custom Middleware
Payload allows you to pass in custom Express middleware to be used on all of the routes it opens. This is useful for adding logging or any other custom functionality to your endpoints.
There are 2 exposed properties. Each property is an array of middleware functions.
- `preMiddleware` - runs before any of the Payload middleware
- `postMiddleware` - runs after all of the Payload middleware
```ts
{
express: {
preMiddleware: [
(req, res, next) => {
// do something
next()
}
],
postMiddleware: [
(req, res, next) => {
// do something
next()
}
]
}
}
// Example logging middleware function
const requestLoggerMiddleware = (req, res, next) => {
req.payload.logger.info(`request: ${req.method} ${req.url}`)
next()
}
```
### JSON
`express.json()` is used to parse JSON body content into JavaScript objects accessible on the Express `req`. Payload allows you to customize all of the `json` method's options. Common examples of customization use-cases are increasing the max allowed JSON body size which defaults to `2MB`.

View File

@@ -25,6 +25,7 @@ As with Collection configs, it's often best practice to write your Globals in se
| **`endpoints`** | Add custom routes to the REST API. [More](/docs/rest-api/overview#custom-endpoints) |
| **`graphQL.name`** | Text used in schema generation. Auto-generated from slug if not defined. |
| **`typescript`** | An object with property `interface` as the text used in schema generation. Auto-generated from slug if not defined. |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
_\* An asterisk denotes that a property is required._
@@ -64,10 +65,12 @@ You can find an [example Global config](https://github.com/payloadcms/public-dem
You can customize the way that the Admin panel behaves on a Global-by-Global basis by defining the `admin` property on a Global's config.
| Option | Description |
| ------------ | ----------------------------------------------------------------------------------------------------------------------- |
| `components` | Swap in your own React components to be used within this Global. [More](/docs/admin/components#globals) |
| `preview` | Function to generate a preview URL within the Admin panel for this global that can point to your app. [More](#preview). |
| Option | Description |
|--------------|-----------------------------------------------------------------------------------------------------------------------------------|
| `hidden` | Set to true or a function, called with the current user, returning true to exclude this global from navigation and admin routing. |
| `components` | Swap in your own React components to be used within this Global. [More](/docs/admin/components#globals) |
| `preview` | Function to generate a preview URL within the Admin panel for this global that can point to your app. [More](#preview). |
| `hideAPIURL` | Hides the "API URL" meta field while editing documents within this collection. |
### Preview
@@ -85,7 +88,7 @@ If the function is specified, a Preview button will automatically appear in the
```ts
import { GlobalConfig } from "payload/types";
const MyGlobal: GlobalConfig = {
export const MyGlobal: GlobalConfig = {
slug: "my-global",
fields: [
{

View File

@@ -12,7 +12,9 @@ While Payload's built-in features come translated, you may want to also translat
Here is an example of a simple collection supporting both English and Spanish editors:
```ts
const Articles: CollectionConfig = {
import { CollectionConfig } from 'payload/types';
export const Articles: CollectionConfig = {
slug: 'articles',
labels: {
singular: {

View File

@@ -72,6 +72,15 @@ All field types with a `name` property support the `localized` property—even t
Enabling localization for field types that support nested fields will automatically create localized "sets" of all fields contained within the field. For example, if you have a page layout using a blocks field type, you have the choice of either localizing the full layout, by enabling localization on the top-level blocks field, or only certain fields within the layout.
</Banner>
<Banner type="warning">
<strong>Important:</strong>
<br />
When converting an existing field to or from `localized: true` the data
structure in the document will change for this field and so existing data for
this field will be lost. Before changing the localization setting on fields
with existing data, you may need to consider a field migration strategy.
</Banner>
### Retrieving localized docs
When retrieving documents, you can specify which locale you'd like to receive as well as which fallback locale should be used.

View File

@@ -43,6 +43,7 @@ Payload is a _config-based_, code-first CMS and application framework. The Paylo
| `hooks` | Tap into Payload-wide hooks. [More](/docs/hooks/overview) |
| `plugins` | An array of Payload plugins. [More](/docs/plugins/overview) |
| `endpoints` | An array of custom API endpoints added to the Payload router. [More](/docs/rest-api/overview#custom-endpoints) |
| `custom` | Extension point for adding custom data (e.g. for plugins) |
#### Simple example

View File

@@ -35,7 +35,8 @@ keywords: array, fields, config, configuration, documentation, Content Managemen
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this Array will be kept, so there is no need to specify each nested field as `localized`. |
| **`required`** | Require this field to have a value. |
| **`labels`** | Customize the row labels appearing in the Admin dashboard. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -55,7 +56,7 @@ In addition to the default [field admin config](/docs/fields/overview#admin-conf
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -37,6 +37,7 @@ keywords: blocks, fields, config, configuration, documentation, Content Manageme
| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
| **`labels`** | Customize the block row labels appearing in the Admin dashboard. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -101,7 +102,7 @@ const QuoteBlock: Block = {
]
};
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -26,6 +26,7 @@ keywords: checkbox, fields, config, configuration, documentation, Content Manage
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -35,7 +36,7 @@ keywords: checkbox, fields, config, configuration, documentation, Content Manage
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -32,6 +32,7 @@ This field uses the `monaco-react` editor syntax highlighting.
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
_\* An asterisk denotes that a property is required._
@@ -50,7 +51,7 @@ In addition to the default [field admin config](/docs/fields/overview#admin-conf
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -17,6 +17,7 @@ keywords: row, fields, config, configuration, documentation, Content Management
| **`label`** * | A label to render within the header of the collapsible component. This can be a string, function or react component. Function/components receive `({ data, path })` as args. |
| **`fields`** * | Array of field types to nest within this Collapsible. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -34,7 +35,7 @@ In addition to the default [field admin config](/docs/fields/overview#admin-conf
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -18,7 +18,7 @@ This field uses [`react-datepicker`](https://www.npmjs.com/package/react-datepic
| Option | Description |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
| **`index`** | Build a [MongoDB index](https://docs.mongodb.com/manual/indexes/) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
@@ -28,7 +28,8 @@ This field uses [`react-datepicker`](https://www.npmjs.com/package/react-datepic
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
_\* An asterisk denotes that a property is required._
@@ -36,19 +37,19 @@ _\* An asterisk denotes that a property is required._
In addition to the default [field admin config](/docs/fields/overview#admin-config), you can customize the following fields that will adjust how the component displays in the admin panel via the `date` property.
| Property | Option | Description |
| ---------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| **`placeholder`** | | Placeholder text for the field. |
| **`date`** | | Pass options to customize date field appearance. |
| | **`displayFormat`** | Format date to be shown in field **cell**. |
| | **`pickerAppearance`** \* | Determines the appearance of the datepicker: `dayAndTime` `timeOnly` `dayOnly` `monthOnly`. |
| | **`monthsToShow`** \* | Number of months to display max is 2. Defaults to 1. |
| | **`minDate`** \* | Min date value to allow. |
| | **`maxDate`** \* | Max date value to allow. |
| | **`minTime`** \* | Min time value to allow. |
| | **`maxTime`** \* | Max date value to allow. |
| | **`timeIntervals`** \* | Time intervals to display. Defaults to 30 minutes. |
| | **`timeFormat`** \* | Determines time format. Defaults to `'h:mm aa'`. |
| Property | Description |
| ------------------------------ | ------------------------------------------------------------------------------------------- |
| **`placeholder`** | Placeholder text for the field. |
| **`date`** | Pass options to customize date field appearance. |
| **`date.displayFormat`** | Format date to be shown in field **cell**. |
| **`date.pickerAppearance`** \* | Determines the appearance of the datepicker: `dayAndTime` `timeOnly` `dayOnly` `monthOnly`. |
| **`date.monthsToShow`** \* | Number of months to display max is 2. Defaults to 1. |
| **`date.minDate`** \* | Min date value to allow. |
| **`date.maxDate`** \* | Max date value to allow. |
| **`date.minTime`** \* | Min time value to allow. |
| **`date.maxTime`** \* | Max date value to allow. |
| **`date.timeIntervals`** \* | Time intervals to display. Defaults to 30 minutes. |
| **`date.timeFormat`** \* | Determines time format. Defaults to `'h:mm aa'`. |
_\* This property is passed directly to [react-datepicker](https://github.com/Hacker0x01/react-datepicker/blob/master/docs/datepicker.md). ._
@@ -60,48 +61,48 @@ These properties only affect how the date is displayed in the UI. The full date
`pickerAppearance` sets the appearance of the **react datepicker**, the options available are `dayAndTime`, `dayOnly`, `timeOnly`, and `monthOnly`. By default, the datepicker will display `dayOnly`.
When only `pickerAppearance`, an equivalent format will be rendered in the date field cell. To overwrite this format, set `displayFormat`.
When only `pickerAppearance` is set, an equivalent format will be rendered in the date field cell. To overwrite this format, set `displayFormat`.
### Example
`collections/ExampleCollection.ts`
```ts
import { CollectionConfig } from 'payload/types';
import { CollectionConfig } from "payload/types";
const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
export const ExampleCollection: CollectionConfig = {
slug: "example-collection",
fields: [
{
name: 'dateOnly',
type: 'date',
{
name: "dateOnly",
type: "date",
admin: {
date: {
pickerAppearance: 'dayOnly',
displayFormat: 'd MMM yyy',
pickerAppearance: "dayOnly",
displayFormat: "d MMM yyy",
},
},
},
{
name: 'timeOnly',
type: 'date',
name: "timeOnly",
type: "date",
admin: {
date: {
pickerAppearance: 'timeOnly',
displayFormat: 'h:mm:ss a',
pickerAppearance: "timeOnly",
displayFormat: "h:mm:ss a",
},
},
},
{
name: 'monthOnly',
type: 'date',
name: "monthOnly",
type: "date",
admin: {
date: {
pickerAppearance: 'monthOnly',
displayFormat: 'MMMM yyyy',
pickerAppearance: "monthOnly",
displayFormat: "MMMM yyyy",
},
},
},
]
],
};
```

View File

@@ -27,6 +27,7 @@ keywords: email, fields, config, configuration, documentation, Content Managemen
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -48,7 +49,7 @@ Set this property to a string that will be used for browser autocomplete.
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -25,6 +25,7 @@ keywords: group, fields, config, configuration, documentation, Content Managemen
| **`defaultValue`** | Provide an object of data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this Group will be kept, so there is no need to specify each nested field as `localized`. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -42,7 +43,7 @@ Set this property to `true` to hide this field's gutter within the admin panel.
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -30,6 +30,7 @@ This field uses the `monaco-react` editor syntax highlighting.
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
_\* An asterisk denotes that a property is required._
@@ -47,7 +48,7 @@ In addition to the default [field admin config](/docs/fields/overview#admin-conf
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -29,6 +29,7 @@ keywords: number, fields, config, configuration, documentation, Content Manageme
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -54,7 +55,7 @@ Set this property to a string that will be used for browser autocomplete.
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -19,7 +19,7 @@ The required `type` property on a field determines what values it can accept, ho
```ts
import { CollectionConfig } from 'payload/types';
const Page: CollectionConfig = {
export const Page: CollectionConfig = {
slug: 'pages',
fields: [
{
@@ -90,7 +90,7 @@ Example:
```ts
import { CollectionConfig } from 'payload/types';
const Orders: CollectionConfig = {
export const Orders: CollectionConfig = {
slug: 'orders',
fields: [
{
@@ -175,10 +175,11 @@ All Payload fields support the ability to swap in your own React components with
### Conditional logic
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:
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 three arguments:
- `data` - the entire document's data that is currently being edited
- `siblingData` - only the fields that are direct siblings to the field with the condition
- `{ user }` - the final argument is an object containing the currently authenticated user
The `condition` function should return a boolean that will control if the field should be displayed or not.
@@ -197,7 +198,7 @@ The `condition` function should return a boolean that will control if the field
type: 'text',
admin: {
// highlight-start
condition: (data, siblingData) => {
condition: (data, siblingData, { user }) => {
if (data.enableGreeting) {
return true;
} else {

View File

@@ -30,6 +30,7 @@ The data structure in the database matches the GeoJSON structure to represent po
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -39,7 +40,7 @@ The data structure in the database matches the GeoJSON structure to represent po
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -27,6 +27,7 @@ keywords: radio, fields, config, configuration, documentation, Content Managemen
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -49,7 +50,7 @@ The `layout` property allows for the radio group to be styled as a horizonally o
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{
@@ -72,5 +73,4 @@ const ExampleCollection: CollectionConfig = {
}
]
}
```

View File

@@ -20,13 +20,13 @@ keywords: relationship, fields, config, configuration, documentation, Content Ma
### Config
| Option | Description |
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
| **`relationTo`** \* | Provide one or many collection `slug`s to be able to assign relationships to. |
| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-relationship-options). |
| **`hasMany`** | Boolean when, if set to `true`, allows this field to have many relations instead of only one. |
| **`min`** | A number for the fewest allowed items during validation when a value is present. Used with `hasMany`. |
| **`max`** | A number for the most allowed items during validation when a value is present. Used with `hasMany`. |
| **`max`** | A number for the most allowed items during validation when a value is present. Used with `hasMany`. |
| **`maxDepth`** | Sets a number limit on iterations of related documents to populate when queried. [Depth](/docs/getting-started/concepts#depth) |
| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
@@ -40,6 +40,7 @@ keywords: relationship, fields, config, configuration, documentation, Content Ma
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
_\* An asterisk denotes that a property is required._
@@ -76,27 +77,34 @@ The `filterOptions` property can either be a `Where` query directly, or a functi
| `id` | The value of the collection `id`, will be `undefined` on create request |
| `user` | The currently authenticated user object |
**Example:**
### Example
```ts
const relationshipField = {
name: "purchase",
type: "relationship",
relationTo: ["products", "services"],
filterOptions: ({ relationTo, siblingData }) => {
// returns a Where query dynamically by the type of relationship
if (relationTo === "products") {
return {
stock: { greater_than: siblingData.quantity },
};
}
import { CollectionConfig } from "payload/types";
if (relationTo === "services") {
return {
isAvailable: { equals: true },
};
}
},
export const ExampleCollection: CollectionConfig = {
slug: "example-collection",
fields: [
{
name: "purchase",
type: "relationship",
relationTo: ["products", "services"],
filterOptions: ({ relationTo, siblingData }) => {
// returns a Where query dynamically by the type of relationship
if (relationTo === "products") {
return {
stock: { greater_than: siblingData.quantity },
};
}
if (relationTo === "services") {
return {
isAvailable: { equals: true },
};
}
},
},
],
};
```

View File

@@ -31,6 +31,7 @@ The Admin component is built on the powerful [`slatejs`](https://docs.slatejs.or
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -54,6 +55,7 @@ The default `elements` available in Payload are:
- `h4`
- `h5`
- `h6`
- `blockquote`
- `link`
- `ol`
- `ul`
@@ -81,6 +83,8 @@ Set this property to `true` to hide this field's gutter within the admin panel.
This allows [fields](/docs/fields/overview) to be saved as extra fields on a link inside the Rich Text Editor. When this is present, the fields will render inside a modal that can be opened by clicking the "edit" button on the link element.
`link.fields` may either be an array of fields (in which case all fields defined in it will be appended below the default fields) or a function that accepts the default fields as only argument and returns an array defining the entirety of fields to be used (thus providing a mechanism of overriding the default fields).
![RichText link fields](https://payloadcms.com/images/docs/fields/richText/rte-link-fields-modal.jpg)
*RichText link with custom fields*
@@ -104,7 +108,7 @@ Similar to the `relationship` element, the `upload` element is a user-friendly w
<Banner type="success">
<strong>Tip:</strong><br/>
Collections are automatically allowed to be selected within the Rich Text relationship and upload elements by default. If you want to disable a collection from being able to be referenced in Rich Text fields, set the collection admin option of <strong>enableRichTextRelationship</strong> to false.
Collections are automatically allowed to be selected within the Rich Text relationship and upload elements by default. If you want to disable a collection from being able to be referenced in Rich Text fields, set the collection admin options of <strong>enableRichTextLink</strong> and <strong>enableRichTextRelationship</strong> to false.
</Banner>
Relationship and Upload elements are populated dynamically into your Rich Text field' content. Within the REST and Local APIs, any present RichText `relationship` or `upload` elements will respect the `depth` option that you pass, and will be populated accordingly. In GraphQL, each `richText` field accepts an argument of `depth` for you to utilize.
@@ -137,7 +141,7 @@ Custom `Leaf` objects follow a similar pattern but require you to define the `Le
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{
@@ -153,6 +157,7 @@ const ExampleCollection: CollectionConfig = {
'h3',
'h4',
'link',
'blockquote',
{
name: 'cta',
Button: CustomCallToActionButton,
@@ -270,7 +275,7 @@ const serialize = (children) => children.map((node, i) => {
{serialize(node.children)}
</h6>
);
case 'quote':
case 'blockquote':
return (
<blockquote key={i}>
{serialize(node.children)}
@@ -366,5 +371,4 @@ import type {
RichTextCustomElement,
RichTextCustomLeaf,
} from 'payload/types';
```

View File

@@ -16,6 +16,7 @@ keywords: row, fields, config, configuration, documentation, Content Management
| ---------------- | ----------- |
| **`fields`** * | Array of field types to nest within this Row. |
| **`admin`** | Admin-specific configuration excluding `description`, `readOnly`, and `hidden`. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -25,7 +26,7 @@ keywords: row, fields, config, configuration, documentation, Content Management
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -30,6 +30,7 @@ keywords: select, multi-select, fields, config, configuration, documentation, Co
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
_\* An asterisk denotes that a property is required._
@@ -61,7 +62,7 @@ Set to `true` if you'd like this field to be sortable within the Admin UI using
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -19,6 +19,7 @@ keywords: tabs, fields, config, configuration, documentation, Content Management
| ---------------- | ----------- |
| **`tabs`** * | Array of tabs to render within this Tabs field. |
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
#### Tab-specific Config
@@ -39,7 +40,7 @@ Each tab has its own required `label` and `fields` array. You can also optionall
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -29,6 +29,7 @@ keywords: text, fields, config, configuration, documentation, Content Management
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -50,7 +51,7 @@ Set this property to a string that will be used for browser autocomplete.
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -25,10 +25,11 @@ keywords: textarea, fields, config, configuration, documentation, Content Manage
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) [More](/docs/fields/overview#default-values) |
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values)|
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -50,7 +51,7 @@ Set this property to a string that will be used for browser autocomplete.
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -6,8 +6,11 @@ desc: UI fields are purely presentational and allow developers to customize the
keywords: custom field, react component, fields, config, configuration, documentation, Content Management System, cms, headless, javascript, node, react, express
---
<Banner >
The UI (user interface) field gives you a ton of power to add your own React components directly into the Admin panel, nested directly within your other fields. It has absolutely no effect on the data of your documents. It is presentational-only.
<Banner>
The UI (user interface) field gives you a ton of power to add your own React
components directly into the Admin panel, nested directly within your other
fields. It has absolutely no effect on the data of your documents. It is
presentational-only.
</Banner>
This field is helpful if you need to build in custom functionality via React components within the Admin panel. Think of it as a way for you to "plug in" your own React components directly within your other fields, so you can provide your editors with new controls exactly where you want them to go.
@@ -23,34 +26,36 @@ With this field, you can also inject custom `Cell` components that appear as add
### Config
| Option | Description |
| ---------------------------- |-------------------------------------------------------------------------------------------------------------------|
| **`name`** * | A unique identifier for this field. |
| **`label`** | Human-readable label for this UI field. |
| Option | Description |
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| **`name`** \* | A unique identifier for this field. |
| **`label`** | Human-readable label for this UI field. |
| **`admin.components.Field`** | React component to be rendered for this field within the Edit view. [More](/docs/admin/components/#field-component) |
| **`admin.components.Cell`** | React component to be rendered as a Cell within collection List views. [More](/docs/admin/components/#field-component) |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
_\* An asterisk denotes that a property is required._
### Example
`collections/ExampleCollection.ts`
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
```ts
import { CollectionConfig } from "payload/types";
export const ExampleCollection: CollectionConfig = {
slug: "example-collection",
fields: [
{
type: 'ui', // required
name: "myCustomUIField", // required
type: "ui", // required
admin: {
components: {
Field: MyCustomUIField,
Cell: MyCustomUICell,
}
}
}
]
}
},
},
},
],
};
```

View File

@@ -41,6 +41,7 @@ keywords: upload, images media, fields, config, configuration, documentation, Co
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
@@ -50,7 +51,7 @@ keywords: upload, images media, fields, config, configuration, documentation, Co
```ts
import { CollectionConfig } from 'payload/types';
const ExampleCollection: CollectionConfig = {
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
fields: [
{

View File

@@ -106,6 +106,8 @@ Here is a list of all properties available to pass through `payload.init`:
**Required**. This is a secure string that will be used to authenticate with Payload. It can be random but should be at least 14 characters and be very difficult to guess. Often, it's smart to store this value in an `env` and set different values for each of your environments (local, stage, prod, etc). The `dotenv` package is very handy and works well alongside of Payload.
Payload uses this secret key to generate secure user tokens (JWT). Behind the scenes, we do not use your secret key to encrypt directly - instead, we first take the secret key and create an encrypted string using the SHA-256 hash function. Then, we reduce the encrypted string to its first 32 characters. This final value is what Payload uses for encryption.
##### `mongoURL`
**Required**. This is a fully qualified MongoDB connection string that points to your Mongo database. If you don't have Mongo installed locally, you can [follow these steps for Mac OSX](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/) and [these steps](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/) for Windows 10. If you want to use a local database and you know you have MongoDB installed locally, a typical connection string will look like this:
@@ -142,4 +144,4 @@ After it starts, you can go to `http://localhost:3000/admin` to create your firs
### Docker
Looking to deploy Payload with Docker? New projects with `create-payload-app` come with a Dockerfile and docker-compose.yml file ready to go. Examples of these files can be seen in our [Deployment docs](/docs/deployment#Docker).
Looking to deploy Payload with Docker? New projects with `create-payload-app` come with a Dockerfile and docker-compose.yml file ready to go. Examples of these files can be seen in our [Deployment docs](/docs/production/deployment#docker).

View File

@@ -67,3 +67,89 @@ export default buildConfig({
}
})
```
### Resolver function
In your resolver, make sure you set `depth: 0` if you're returning data directly from the local API so that GraphQL can correctly resolve queries to nested values such as relationship data.
Your function will receive four arguments you can make use of:
Example
```ts
async (obj, args, context, info) => { }
```
**`obj`** The previous object. Not very often used and usually discarded.
**`args`**
The available arguments from your query or mutation will be available to you here, these must be configured via the custom operation first.
**`context`**
An object containing the `req` and `res` objects that will provide you with the `payload`, `user` instances and more, like any other Payload API handler.
**`info`**
Contextual information about the currently running GraphQL operation. You can get schema information from this as well as contextual information about where this resolver function is being run.
### Types
We've exposed a few types and utilities to help you extend the API further. Payload uses the GraphQL.js package for which you can view the full list of available types in the [official documentation](https://graphql.org/graphql-js/type/).
**`GraphQL`**
You can directly import the GraphQL package used by Payload, most useful for typing. For queries, mutations and handlers make sure you use the `GraphQL` and `payload` instances provided via arguments.
**`buildPaginatedListType`**
This is a utility function that allows you to build a new GraphQL type for a paginated result similar to the Payload's generated schema.
It takes in two arguments, the first for the name of this new schema type and the second for the GraphQL type to be used in the docs parameter.
Example
```ts
export const getMyPosts = (GraphQL, payload) => {
return {
args: {},
resolve: Resolver,
// The name of your new type has to be unique
type: buildPaginatedListType('AuthorPosts', payload.collections['posts'].graphQL?.type),
}
}
```
**`payload.collections.slug.graphQL`**
If you want to extend more of the provided API then the `graphQL` object on your collection slug will contain additional types to help you re-use code for types, mutations and queries.
```ts
graphQL?: {
type: GraphQLObjectType
paginatedType: GraphQLObjectType
JWT: GraphQLObjectType
versionType: GraphQLObjectType
whereInputType: GraphQLInputObjectType
mutationInputType: GraphQLNonNull<any>
updateMutationInputType: GraphQLNonNull<any>
}
```
### Best practices
There are a few ways to structure your code, we recommend using a dedicated `graphql` directory so you can keep all of your logic in one place. You have total freedom of how you want to structure this but a common pattern is to group functions by type and with their resolver.
Example
```
src/graphql
---- queries/
index.ts
-- myCustomQuery/
index.ts
resolver.ts
---- mutations/
```

View File

@@ -32,7 +32,7 @@ Everything that can be done to a Collection via the REST or Local API can be don
```ts
import { CollectionConfig } from 'payload/types';
const PublicUser: CollectionConfig = {
export const PublicUser: CollectionConfig = {
slug: 'public-users',
auth: true, // Auth is enabled
fields: [

View File

@@ -34,7 +34,7 @@ All collection Hook properties accept arrays of synchronous or asynchronous func
```ts
import { CollectionConfig } from 'payload/types';
const ExampleHooks: CollectionConfig = {
export const ExampleHooks: CollectionConfig = {
slug: 'example-hooks',
fields: [
{ name: 'name', type: 'text'},
@@ -79,7 +79,13 @@ const beforeOperationHook: CollectionBeforeOperationHook = async ({
### beforeValidate
Runs before the `create` and `update` operations. This hook allows you to add or format data before the incoming data is validated.
Runs before the `create` and `update` operations. This hook allows you to add or format data before the incoming data is validated server-side.
Please do note that this does not run before the client-side validation. If you added a `validate` function, this would be the lifecycle:
1. `validate` runs on the client
2. if successful, `beforeValidate` runs on the server
3. `validate` runs on the server
```ts
import { CollectionBeforeOperationHook } from 'payload/types';

View File

@@ -66,18 +66,17 @@ const afterChangeHook: CollectionAfterChangeHook = async ({
You can specify more options within the Local API vs. REST or GraphQL due to the server-only context that they are executed in.
| Local Option | Description |
| ------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `collection` | Required for Collection operations. Specifies the Collection slug to operate against. |
| `data` | The data to use within the operation. Required for `create`, `update`. |
| `depth` | [Control auto-population](/docs/getting-started/concepts#depth) of nested relationship and upload fields. |
| `locale` | Specify [locale](/docs/configuration/localization) for any returned documents. |
| `fallbackLocale` | Specify a [fallback locale](/docs/configuration/localization) to use for any returned documents. |
| `overrideAccess` | Skip access control. By default, this property is set to true within all Local API operations. |
| `user` | If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks. |
| `showHiddenFields` | Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config. |
| `queryHiddenFields` | Allow querying by hidden fields. By default, hidden fields are not allowed to be queried on. |
| `pagination` | Set to false to return all documents and avoid querying for document counts. |
| Local Option | Description |
| ------------------ | -------------------------------------------------------------------------------------------------------------------- |
| `collection` | Required for Collection operations. Specifies the Collection slug to operate against. |
| `data` | The data to use within the operation. Required for `create`, `update`. |
| `depth` | [Control auto-population](/docs/getting-started/concepts#depth) of nested relationship and upload fields. |
| `locale` | Specify [locale](/docs/configuration/localization) for any returned documents. |
| `fallbackLocale` | Specify a [fallback locale](/docs/configuration/localization) to use for any returned documents. |
| `overrideAccess` | Skip access control. By default, this property is set to true within all Local API operations. |
| `user` | If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks. |
| `showHiddenFields` | Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config. |
| `pagination` | Set to false to return all documents and avoid querying for document counts. |
_There are more options available on an operation by operation basis outlined below._
@@ -142,7 +141,6 @@ const result = await payload.find({
user: dummyUser,
overrideAccess: false,
showHiddenFields: true,
queryHiddenFields: false,
});
```
@@ -205,7 +203,7 @@ const result = await payload.update({
collection: "posts", // required
where: {
// required
fieldName: { equals: 'value' },
fieldName: { equals: "value" },
},
data: {
// required
@@ -259,7 +257,7 @@ const result = await payload.delete({
collection: "posts", // required
where: {
// required
fieldName: { equals: 'value' },
fieldName: { equals: "value" },
},
depth: 0,
locale: "en",

View File

@@ -19,7 +19,7 @@ For example, say you have a collection as follows:
```ts
import { CollectionConfig } from 'payload/types';
const Post: CollectionConfig = {
export const Post: CollectionConfig = {
slug: 'posts',
fields: [
{
@@ -75,7 +75,7 @@ The above example demonstrates a simple query but you can get much more complex.
### And / Or Logic
In addition to defining simple queries, you can join multiple queries together using simple AND / OR logic. Let's take the above `Post` collection for example and write a more complex query usnig AND / OR:
In addition to defining simple queries, you can join multiple queries together using simple AND / OR logic. Let's take the above `Post` collection for example and write a more complex query using AND / OR:
```js
const query = {

View File

@@ -32,9 +32,9 @@ Note: Collection slugs must be formatted in kebab-case
| `GET` | `/api/{collection-slug}/:id` | Find a specific document by ID |
| `POST` | `/api/{collection-slug}` | Create a new document |
| `PATCH` | `/api/{collection-slug}` | Update all documents matching the `where` query |
| `PATCH` | `/api/{collection-slug}` | Update a document by ID |
| `PATCH` | `/api/{collection-slug}/:id` | Update a document by ID |
| `DELETE` | `/api/{collection-slug}` | Delete all documents matching the `where` query |
| `DELETE` | `/api/{collection-sldug}/:id` | Delete an existing document by ID |
| `DELETE` | `/api/{collection-slug}/:id` | Delete an existing document by ID |
##### Additional `find` query parameters
@@ -91,6 +91,7 @@ Each endpoint object needs to have:
| **`method`** | The lowercase HTTP verb to use: 'get', 'head', 'post', 'put', 'delete', 'connect' or 'options' |
| **`handler`** | A function or array of functions to be called with **req**, **res** and **next** arguments. [Express](https://expressjs.com/en/guide/routing.html#route-handlers) |
| **`root`** | When `true`, defines the endpoint on the root Express app, bypassing Payload handlers and the `routes.api` subpath. Note: this only applies to top-level endpoints of your Payload config, endpoints defined on `collections` or `globals` cannot be root. |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
Example:
@@ -98,7 +99,7 @@ Example:
import { CollectionConfig } from 'payload/types';
// a collection of 'orders' with an additional route for tracking details, reachable at /api/orders/:id/tracking
const Orders: CollectionConfig = {
export const Orders: CollectionConfig = {
slug: 'orders',
fields: [ /* ... */ ],
// highlight-start

View File

@@ -42,7 +42,7 @@ Every Payload Collection can opt-in to supporting Uploads by specifying the `upl
| Option | Description |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| **`staticURL`** \* | The base URL path to use to access your uploads. Example: `/media` |
| **`staticURL`** \* | The URL path to use to access your uploads. Relative path like `/media` will be served by payload. Full path like `https://example.com/media` needs to be served by another web server. |
| **`staticDir`** \* | The folder directory to use to store media in. Can be either an absolute path or relative to the directory that contains your config. |
| **`imageSizes`** | If specified, image uploads will be automatically resized in accordance to these image sizes. [More](#image-sizes) |
| **`formatOptions`** | An object with `format` and `options` that are used with the Sharp image library to format the upload file. [More](https://sharp.pixelplumbing.com/api-output#toformat) |
@@ -60,7 +60,7 @@ _An asterisk denotes that a property above is required._
```ts
import { CollectionConfig } from 'payload/types';
const Media: CollectionConfig = {
export const Media: CollectionConfig = {
slug: 'media',
upload: {
staticURL: '/media',
@@ -92,6 +92,12 @@ const Media: CollectionConfig = {
adminThumbnail: 'thumbnail',
mimeTypes: ['image/*'],
},
fields: [
{
name: 'alt',
type: 'text',
},
],
};
```
@@ -165,7 +171,7 @@ You can specify how Payload retrieves admin thumbnails for your upload-enabled C
```ts
import { CollectionConfig } from 'payload/types';
const Media: CollectionConfig = {
export const Media: CollectionConfig = {
slug: 'media',
upload: {
staticURL: '/media',
@@ -200,7 +206,7 @@ Some example values are: `image/*`, `audio/*`, `video/*`, `image/png`, `applicat
```ts
import { CollectionConfig } from 'payload/types';
const Media: CollectionConfig = {
export const Media: CollectionConfig = {
slug: 'media',
upload: {
staticURL: '/media',

View File

@@ -28,7 +28,7 @@ Collections and Globals both support the same options for configuring autosave.
```ts
import { CollectionConfig } from 'payload/types';
const Pages: CollectionConfig = {
export const Pages: CollectionConfig = {
slug: 'pages',
access: {
read: ({ req }) => {

View File

@@ -84,7 +84,7 @@ Here is an example that utilizes the `_status` field to require a user to be log
```ts
import { CollectionConfig } from 'payload/types';
const Pages: CollectionConfig = {
export const Pages: CollectionConfig = {
slug: 'pages',
access: {
read: ({ req }) => {
@@ -119,7 +119,7 @@ Here is an example for how to write an access control function that grants acces
```ts
import { CollectionConfig } from 'payload/types';
const Pages: CollectionConfig = {
export const Pages: CollectionConfig = {
slug: 'pages',
access: {
read: ({ req }) => {

View File

@@ -0,0 +1,17 @@
module.exports = {
plugins: [
'node',
],
env: {
node: true,
},
extends: [
'./rules/best-practices',
'./rules/errors',
'./rules/es6',
'./rules/imports',
'./rules/style',
'./rules/variables',
].map(require.resolve),
rules: {},
};

View File

@@ -0,0 +1,356 @@
module.exports = {
rules: {
// enforces getter/setter pairs in objects
'accessor-pairs': 'off',
// enforces return statements in callbacks of array's methods
// https://eslint.org/docs/rules/array-callback-return
'array-callback-return': ['error', { allowImplicit: true }],
// treat var statements as if they were block scoped
'block-scoped-var': 'error',
// specify the maximum cyclomatic complexity allowed in a program
complexity: ['off', 11],
// enforce that class methods use "this"
// https://eslint.org/docs/rules/class-methods-use-this
'class-methods-use-this': ['error', {
exceptMethods: [],
}],
// require return statements to either always or never specify values
'consistent-return': 'error',
// specify curly brace conventions for all control statements
curly: ['error', 'multi-line'], // multiline
// require default case in switch statements
'default-case': ['error', { commentPattern: '^no default$' }],
// https://eslint.org/docs/rules/default-param-last
// TODO: enable, semver-minor, when eslint v6.4 is required (which is a major)
'default-param-last': 'off',
// encourages use of dot notation whenever possible
'dot-notation': ['error', { allowKeywords: true }],
// enforces consistent newlines before or after dots
// https://eslint.org/docs/rules/dot-location
'dot-location': ['error', 'property'],
// require the use of === and !==
// https://eslint.org/docs/rules/eqeqeq
eqeqeq: ['error', 'always', { null: 'ignore' }],
// Require grouped accessor pairs in object literals and classes
// https://eslint.org/docs/rules/grouped-accessor-pairs
// TODO: enable in next major, altho the guide forbids getters/setters anyways
'grouped-accessor-pairs': 'off',
// make sure for-in loops have an if statement
'guard-for-in': 'error',
// enforce a maximum number of classes per file
// https://eslint.org/docs/rules/max-classes-per-file
'max-classes-per-file': ['error', 1],
// disallow the use of alert, confirm, and prompt
'no-alert': 'warn',
// disallow use of arguments.caller or arguments.callee
'no-caller': 'error',
// disallow lexical declarations in case/default clauses
// https://eslint.org/docs/rules/no-case-declarations.html
'no-case-declarations': 'error',
// Disallow returning value in constructor
// https://eslint.org/docs/rules/no-constructor-return
// TODO: enable, semver-major
'no-constructor-return': 'off',
// disallow division operators explicitly at beginning of regular expression
// https://eslint.org/docs/rules/no-div-regex
'no-div-regex': 'off',
// disallow else after a return in an if
// https://eslint.org/docs/rules/no-else-return
'no-else-return': ['error', { allowElseIf: false }],
// disallow empty functions, except for standalone funcs/arrows
// https://eslint.org/docs/rules/no-empty-function
'no-empty-function': ['error', {
allow: [
'arrowFunctions',
'functions',
'methods',
],
}],
// disallow empty destructuring patterns
// https://eslint.org/docs/rules/no-empty-pattern
'no-empty-pattern': 'error',
// disallow comparisons to null without a type-checking operator
'no-eq-null': 'off',
// disallow use of eval()
'no-eval': 'error',
// disallow adding to native types
'no-extend-native': 'error',
// disallow unnecessary function binding
'no-extra-bind': 'error',
// disallow Unnecessary Labels
// https://eslint.org/docs/rules/no-extra-label
'no-extra-label': 'error',
// disallow fallthrough of case statements
'no-fallthrough': 'error',
// disallow the use of leading or trailing decimal points in numeric literals
'no-floating-decimal': 'error',
// disallow reassignments of native objects or read-only globals
// https://eslint.org/docs/rules/no-global-assign
'no-global-assign': ['error', { exceptions: [] }],
// deprecated in favor of no-global-assign
'no-native-reassign': 'off',
// disallow implicit type conversions
// https://eslint.org/docs/rules/no-implicit-coercion
'no-implicit-coercion': ['off', {
boolean: false,
number: true,
string: true,
allow: [],
}],
// disallow var and named functions in global scope
// https://eslint.org/docs/rules/no-implicit-globals
'no-implicit-globals': 'off',
// disallow use of eval()-like methods
'no-implied-eval': 'error',
// disallow this keywords outside of classes or class-like objects
'no-invalid-this': 'off',
// disallow usage of __iterator__ property
'no-iterator': 'error',
// disallow use of labels for anything other then loops and switches
'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
// disallow unnecessary nested blocks
'no-lone-blocks': 'error',
// disallow creation of functions within loops
'no-loop-func': 'error',
// disallow magic numbers
// https://eslint.org/docs/rules/no-magic-numbers
'no-magic-numbers': ['off', {
ignore: [],
ignoreArrayIndexes: true,
enforceConst: true,
detectObjects: false,
}],
// disallow use of multiple spaces
'no-multi-spaces': ['error', {
ignoreEOLComments: false,
}],
// disallow use of multiline strings
'no-multi-str': 'error',
// disallow use of new operator when not part of the assignment or comparison
'no-new': 'error',
// disallow use of new operator for Function object
'no-new-func': 'error',
// disallows creating new instances of String, Number, and Boolean
'no-new-wrappers': 'error',
// disallow use of (old style) octal literals
'no-octal': 'error',
// disallow use of octal escape sequences in string literals, such as
// var foo = 'Copyright \251';
'no-octal-escape': 'error',
// disallow reassignment of function parameters
// disallow parameter object manipulation except for specific exclusions
// rule: https://eslint.org/docs/rules/no-param-reassign.html
'no-param-reassign': ['error', {
props: true,
ignorePropertyModificationsFor: [
'acc', // for reduce accumulators
'accumulator', // for reduce accumulators
'e', // for e.returnvalue
'ctx', // for Koa routing
'req', // for Express requests
'request', // for Express requests
'res', // for Express responses
'response', // for Express responses
'$scope', // for Angular 1 scopes
'staticContext', // for ReactRouter context
],
}],
// disallow usage of __proto__ property
'no-proto': 'error',
// disallow declaring the same variable more then once
'no-redeclare': 'error',
// disallow certain object properties
// https://eslint.org/docs/rules/no-restricted-properties
'no-restricted-properties': ['error',
{
object: 'arguments',
property: 'callee',
message: 'arguments.callee is deprecated',
}, {
object: 'global',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
}, {
object: 'self',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
}, {
object: 'window',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
}, {
object: 'global',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
}, {
object: 'self',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
}, {
object: 'window',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
}, {
property: '__defineGetter__',
message: 'Please use Object.defineProperty instead.',
}, {
property: '__defineSetter__',
message: 'Please use Object.defineProperty instead.',
}, {
object: 'Math',
property: 'pow',
message: 'Use the exponentiation operator (**) instead.',
}],
// disallow use of assignment in return statement
'no-return-assign': ['error', 'always'],
// disallow redundant `return await`
'no-return-await': 'error',
// disallow use of `javascript:` urls.
'no-script-url': 'error',
// disallow self assignment
// https://eslint.org/docs/rules/no-self-assign
'no-self-assign': ['error', {
props: true,
}],
// disallow comparisons where both sides are exactly the same
'no-self-compare': 'error',
// disallow use of comma operator
'no-sequences': 'error',
// restrict what can be thrown as an exception
'no-throw-literal': 'error',
// disallow unmodified conditions of loops
// https://eslint.org/docs/rules/no-unmodified-loop-condition
'no-unmodified-loop-condition': 'off',
// disallow usage of expressions in statement position
'no-unused-expressions': ['error', {
allowShortCircuit: false,
allowTernary: false,
allowTaggedTemplates: false,
}],
// disallow unused labels
// https://eslint.org/docs/rules/no-unused-labels
'no-unused-labels': 'error',
// disallow unnecessary .call() and .apply()
'no-useless-call': 'off',
// Disallow unnecessary catch clauses
// https://eslint.org/docs/rules/no-useless-catch
'no-useless-catch': 'error',
// disallow useless string concatenation
// https://eslint.org/docs/rules/no-useless-concat
'no-useless-concat': 'error',
// disallow unnecessary string escaping
// https://eslint.org/docs/rules/no-useless-escape
'no-useless-escape': 'error',
// disallow redundant return; keywords
// https://eslint.org/docs/rules/no-useless-return
'no-useless-return': 'error',
// disallow use of void operator
// https://eslint.org/docs/rules/no-void
'no-void': 'error',
// disallow usage of configurable warning terms in comments: e.g. todo
'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
// disallow use of the with statement
'no-with': 'error',
// require using Error objects as Promise rejection reasons
// https://eslint.org/docs/rules/prefer-promise-reject-errors
'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
// Suggest using named capture group in regular expression
// https://eslint.org/docs/rules/prefer-named-capture-group
'prefer-named-capture-group': 'off',
// https://eslint.org/docs/rules/prefer-regex-literals
// TODO; enable, semver-minor, once eslint v6.4 is required (which is a major)
'prefer-regex-literals': 'off',
// require use of the second argument for parseInt()
radix: 'error',
// require `await` in `async function` (note: this is a horrible rule that should never be used)
// https://eslint.org/docs/rules/require-await
'require-await': 'off',
// Enforce the use of u flag on RegExp
// https://eslint.org/docs/rules/require-unicode-regexp
'require-unicode-regexp': 'off',
// requires to declare all vars on top of their containing scope
'vars-on-top': 'error',
// require immediate function invocation to be wrapped in parentheses
// https://eslint.org/docs/rules/wrap-iife.html
'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }],
// require or disallow Yoda conditions
yoda: 'error',
},
};

View File

@@ -0,0 +1,154 @@
module.exports = {
rules: {
// Enforce “for” loop update clause moving the counter in the right direction
// https://eslint.org/docs/rules/for-direction
'for-direction': 'error',
// Enforces that a return statement is present in property getters
// https://eslint.org/docs/rules/getter-return
'getter-return': ['error', { allowImplicit: true }],
// disallow using an async function as a Promise executor
// https://eslint.org/docs/rules/no-async-promise-executor
'no-async-promise-executor': 'error',
// Disallow await inside of loops
// https://eslint.org/docs/rules/no-await-in-loop
'no-await-in-loop': 'error',
// Disallow comparisons to negative zero
// https://eslint.org/docs/rules/no-compare-neg-zero
'no-compare-neg-zero': 'error',
// disallow assignment in conditional expressions
'no-cond-assign': ['error', 'always'],
// disallow use of console
'no-console': ['warn', { allow: ['warn', 'error'] }],
// disallow use of constant expressions in conditions
'no-constant-condition': 'warn',
// disallow control characters in regular expressions
'no-control-regex': 'error',
// disallow use of debugger
'no-debugger': 'error',
// disallow duplicate arguments in functions
'no-dupe-args': 'error',
// Disallow duplicate conditions in if-else-if chains
// https://eslint.org/docs/rules/no-dupe-else-if
// TODO: enable, semver-major
'no-dupe-else-if': 'off',
// disallow duplicate keys when creating object literals
'no-dupe-keys': 'error',
// disallow a duplicate case label.
'no-duplicate-case': 'error',
// disallow empty statements
'no-empty': 'error',
// disallow the use of empty character classes in regular expressions
'no-empty-character-class': 'error',
// disallow assigning to the exception in a catch block
'no-ex-assign': 'error',
// disallow double-negation boolean casts in a boolean context
// https://eslint.org/docs/rules/no-extra-boolean-cast
'no-extra-boolean-cast': 'error',
// disallow unnecessary parentheses
// https://eslint.org/docs/rules/no-extra-parens
'no-extra-parens': ['off', 'all', {
conditionalAssign: true,
nestedBinaryExpressions: false,
returnAssign: false,
ignoreJSX: 'all', // delegate to eslint-plugin-react
enforceForArrowConditionals: false,
}],
// disallow unnecessary semicolons
'no-extra-semi': 'error',
// disallow overwriting functions written as function declarations
'no-func-assign': 'error',
// https://eslint.org/docs/rules/no-import-assign
// TODO: enable, semver-minor, once eslint v6.4 is required (which is a major)
'no-import-assign': 'off',
// disallow function or variable declarations in nested blocks
'no-inner-declarations': 'error',
// disallow invalid regular expression strings in the RegExp constructor
'no-invalid-regexp': 'error',
// disallow irregular whitespace outside of strings and comments
'no-irregular-whitespace': 'error',
// Disallow characters which are made with multiple code points in character class syntax
// https://eslint.org/docs/rules/no-misleading-character-class
'no-misleading-character-class': 'error',
// disallow the use of object properties of the global object (Math and JSON) as functions
'no-obj-calls': 'error',
// disallow use of Object.prototypes builtins directly
// https://eslint.org/docs/rules/no-prototype-builtins
'no-prototype-builtins': 'error',
// disallow multiple spaces in a regular expression literal
'no-regex-spaces': 'error',
// Disallow returning values from setters
// https://eslint.org/docs/rules/no-setter-return
// TODO: enable, semver-major (altho the guide forbids getters/setters already)
'no-setter-return': 'off',
// disallow sparse arrays
'no-sparse-arrays': 'error',
// Disallow template literal placeholder syntax in regular strings
// https://eslint.org/docs/rules/no-template-curly-in-string
'no-template-curly-in-string': 'error',
// Avoid code that looks like two expressions but is actually one
// https://eslint.org/docs/rules/no-unexpected-multiline
'no-unexpected-multiline': 'error',
// disallow unreachable statements after a return, throw, continue, or break statement
'no-unreachable': 'error',
// disallow return/throw/break/continue inside finally blocks
// https://eslint.org/docs/rules/no-unsafe-finally
'no-unsafe-finally': 'error',
// disallow negating the left operand of relational operators
// https://eslint.org/docs/rules/no-unsafe-negation
'no-unsafe-negation': 'error',
// disallow negation of the left operand of an in expression
// deprecated in favor of no-unsafe-negation
'no-negated-in-lhs': 'off',
// Disallow assignments that can lead to race conditions due to usage of await or yield
// https://eslint.org/docs/rules/require-atomic-updates
// TODO: enable, semver-major
'require-atomic-updates': 'off',
// disallow comparisons with the value NaN
'use-isnan': 'error',
// ensure JSDoc comments are valid
// https://eslint.org/docs/rules/valid-jsdoc
'valid-jsdoc': 'off',
// ensure that the results of typeof are compared against a valid string
// https://eslint.org/docs/rules/valid-typeof
'valid-typeof': ['error', { requireStringLiterals: true }],
},
};

View File

@@ -0,0 +1,176 @@
module.exports = {
env: {
es6: true,
},
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: {
generators: false,
objectLiteralDuplicateProperties: false,
},
},
rules: {
// enforces no braces where they can be omitted
// https://eslint.org/docs/rules/arrow-body-style
'arrow-body-style': ['error', 'as-needed', {
requireReturnForObjectLiteral: false,
}],
// require parens in arrow function arguments
// https://eslint.org/docs/rules/arrow-parens
'arrow-parens': ['error', 'always'],
// require space before/after arrow function's arrow
// https://eslint.org/docs/rules/arrow-spacing
'arrow-spacing': ['error', { before: true, after: true }],
// verify super() callings in constructors
'constructor-super': 'error',
// enforce the spacing around the * in generator functions
// https://eslint.org/docs/rules/generator-star-spacing
'generator-star-spacing': ['error', { before: false, after: true }],
// disallow modifying variables of class declarations
// https://eslint.org/docs/rules/no-class-assign
'no-class-assign': 'error',
// disallow arrow functions where they could be confused with comparisons
// https://eslint.org/docs/rules/no-confusing-arrow
'no-confusing-arrow': ['error', {
allowParens: true,
}],
// disallow modifying variables that are declared using const
'no-const-assign': 'error',
// disallow duplicate class members
// https://eslint.org/docs/rules/no-dupe-class-members
'no-dupe-class-members': 'error',
// disallow importing from the same path more than once
// https://eslint.org/docs/rules/no-duplicate-imports
// replaced by https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
'no-duplicate-imports': 'off',
// disallow symbol constructor
// https://eslint.org/docs/rules/no-new-symbol
'no-new-symbol': 'error',
// disallow specific imports
// https://eslint.org/docs/rules/no-restricted-imports
'no-restricted-imports': ['off', {
paths: [],
patterns: [],
}],
// disallow to use this/super before super() calling in constructors.
// https://eslint.org/docs/rules/no-this-before-super
'no-this-before-super': 'error',
// disallow useless computed property keys
// https://eslint.org/docs/rules/no-useless-computed-key
'no-useless-computed-key': 'error',
// disallow unnecessary constructor
// https://eslint.org/docs/rules/no-useless-constructor
'no-useless-constructor': 'error',
// disallow renaming import, export, and destructured assignments to the same name
// https://eslint.org/docs/rules/no-useless-rename
'no-useless-rename': ['error', {
ignoreDestructuring: false,
ignoreImport: false,
ignoreExport: false,
}],
// require let or const instead of var
'no-var': 'error',
// require method and property shorthand syntax for object literals
// https://eslint.org/docs/rules/object-shorthand
'object-shorthand': ['error', 'always', {
ignoreConstructors: false,
avoidQuotes: true,
}],
// suggest using arrow functions as callbacks
'prefer-arrow-callback': ['error', {
allowNamedFunctions: false,
allowUnboundThis: true,
}],
// suggest using of const declaration for variables that are never modified after declared
'prefer-const': ['error', {
destructuring: 'any',
ignoreReadBeforeAssign: true,
}],
// Prefer destructuring from arrays and objects
// https://eslint.org/docs/rules/prefer-destructuring
'prefer-destructuring': ['error',
{
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: true,
object: false,
},
}, {
enforceForRenamedProperties: false,
},
],
// disallow parseInt() in favor of binary, octal, and hexadecimal literals
// https://eslint.org/docs/rules/prefer-numeric-literals
'prefer-numeric-literals': 'error',
// suggest using Reflect methods where applicable
// https://eslint.org/docs/rules/prefer-reflect
'prefer-reflect': 'off',
// use rest parameters instead of arguments
// https://eslint.org/docs/rules/prefer-rest-params
'prefer-rest-params': 'error',
// suggest using the spread operator instead of .apply()
// https://eslint.org/docs/rules/prefer-spread
'prefer-spread': 'error',
// suggest using template literals instead of string concatenation
// https://eslint.org/docs/rules/prefer-template
'prefer-template': 'error',
// disallow generator functions that do not have yield
// https://eslint.org/docs/rules/require-yield
'require-yield': 'error',
// enforce spacing between object rest-spread
// https://eslint.org/docs/rules/rest-spread-spacing
'rest-spread-spacing': ['error', 'never'],
// import sorting
// https://eslint.org/docs/rules/sort-imports
'sort-imports': ['off', {
ignoreCase: false,
ignoreDeclarationSort: false,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
}],
// require a Symbol description
// https://eslint.org/docs/rules/symbol-description
'symbol-description': 'error',
// enforce usage of spacing in template strings
// https://eslint.org/docs/rules/template-curly-spacing
'template-curly-spacing': 'error',
// enforce spacing around the * in yield* expressions
// https://eslint.org/docs/rules/yield-star-spacing
'yield-star-spacing': ['error', 'after'],
},
};

View File

@@ -0,0 +1,234 @@
module.exports = {
env: {
es6: true,
},
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
},
plugins: [
'import',
],
settings: {
'import/resolver': {
node: {
extensions: ['.mjs', '.js', '.json'],
},
},
'import/extensions': [
'.js',
'.mjs',
'.jsx',
],
'import/core-modules': [],
'import/ignore': [
'node_modules',
'\\.(coffee|scss|css|less|hbs|svg|json)$',
],
},
rules: {
// Static analysis:
// ensure imports point to files/modules that can be resolved
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
'import/no-unresolved': ['error', { commonjs: true, caseSensitive: true }],
// ensure named imports coupled with named exports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it
'import/named': 'error',
// ensure default import coupled with default export
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
'import/default': 'off',
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md
'import/namespace': 'off',
// Helpful warnings:
// disallow invalid exports, e.g. multiple defaults
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md
'import/export': 'error',
// do not allow a default import name to match a named export
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
'import/no-named-as-default': 'error',
// warn on accessing default export property names that are also named exports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
'import/no-named-as-default-member': 'error',
// disallow use of jsdoc-marked-deprecated imports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
'import/no-deprecated': 'off',
// Forbid the use of extraneous packages
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
// paths are treated both as absolute paths, and relative to process.cwd()
'import/no-extraneous-dependencies': ['error'],
// Forbid mutable exports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
'import/no-mutable-exports': 'error',
// Module systems:
// disallow require()
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
'import/no-commonjs': 'off',
// disallow AMD require/define
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md
'import/no-amd': 'error',
// No Node.js builtin modules
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
// TODO: enable?
'import/no-nodejs-modules': 'off',
// Style guide:
// disallow non-import statements appearing before import statements
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md
'import/first': 'error',
// disallow non-import statements appearing before import statements
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md
// deprecated: use `import/first`
'import/imports-first': 'off',
// disallow duplicate imports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
'import/no-duplicates': 'error',
// disallow namespace imports
// TODO: enable?
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
'import/no-namespace': 'off',
// Ensure consistent use of file extension within the import path
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
'import/extensions': ['error', 'ignorePackages', {
js: 'never',
mjs: 'never',
jsx: 'never',
}],
// ensure absolute imports are above relative imports and that unassigned imports are ignored
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
// TODO: enforce a stricter convention in module import order?
'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }],
// Require a newline after the last import/require in a group
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
'import/newline-after-import': 'error',
// Require modules with a single export to use a default export
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
'import/prefer-default-export': 'error',
// Restrict which files can be imported in a given folder
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
'import/no-restricted-paths': 'off',
// Forbid modules to have too many dependencies
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md
'import/max-dependencies': ['off', { max: 10 }],
// Forbid import of modules using absolute paths
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md
'import/no-absolute-path': 'error',
// Forbid require() calls with expressions
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
'import/no-dynamic-require': 'error',
// prevent importing the submodules of other modules
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md
'import/no-internal-modules': ['off', {
allow: [],
}],
// Warn if a module could be mistakenly parsed as a script by a consumer
// leveraging Unambiguous JavaScript Grammar
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md
// this should not be enabled until this proposal has at least been *presented* to TC39.
// At the moment, it's not a thing.
'import/unambiguous': 'off',
// Forbid Webpack loader syntax in imports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
'import/no-webpack-loader-syntax': 'error',
// Prevent unassigned imports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md
// importing for side effects is perfectly acceptable, if you need side effects.
'import/no-unassigned-import': 'off',
// Prevent importing the default as if it were named
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md
'import/no-named-default': 'error',
// Reports if a module's default export is unnamed
// https://github.com/benmosher/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md
'import/no-anonymous-default-export': ['off', {
allowArray: false,
allowArrowFunction: false,
allowAnonymousClass: false,
allowAnonymousFunction: false,
allowLiteral: false,
allowObject: false,
}],
// This rule enforces that all exports are declared at the bottom of the file.
// https://github.com/benmosher/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md
// TODO: enable?
'import/exports-last': 'off',
// Reports when named exports are not grouped together in a single export declaration
// or when multiple assignments to CommonJS module.exports or exports object are present
// in a single file.
// https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md
'import/group-exports': 'off',
// forbid default exports. this is a terrible rule, do not use it.
// https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md
'import/no-default-export': 'off',
// Prohibit named exports. this is a terrible rule, do not use it.
// https://github.com/benmosher/eslint-plugin-import/blob/1ec80fa35fa1819e2d35a70e68fb6a149fb57c5e/docs/rules/no-named-export.md
'import/no-named-export': 'off',
// Forbid a module from importing itself
// https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md
'import/no-self-import': 'error',
// Forbid cyclical dependencies between modules
// https://github.com/benmosher/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md
'import/no-cycle': ['error', { maxDepth: Infinity }],
// Ensures that there are no useless path segments
// https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md
'import/no-useless-path-segments': ['error', { commonjs: true }],
// dynamic imports require a leading comment with a webpackChunkName
// https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md
'import/dynamic-import-chunkname': ['off', {
importFunctions: [],
webpackChunknameFormat: '[0-9a-zA-Z-_/.]+',
}],
// Use this rule to prevent imports to folders in relative parent paths.
// https://github.com/benmosher/eslint-plugin-import/blob/c34f14f67f077acd5a61b3da9c0b0de298d20059/docs/rules/no-relative-parent-imports.md
'import/no-relative-parent-imports': 'off',
// Reports modules without any exports, or with unused exports
// https://github.com/benmosher/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md
// TODO: enable, semver-major
'import/no-unused-modules': ['off', {
ignoreExports: [],
missingExports: true,
unusedExports: true,
}],
},
};

View File

@@ -0,0 +1,525 @@
module.exports = {
rules: {
// enforce line breaks after opening and before closing array brackets
// https://eslint.org/docs/rules/array-bracket-newline
// TODO: enable? semver-major
'array-bracket-newline': ['off', 'consistent'], // object option alternative: { multiline: true, minItems: 3 }
// enforce line breaks between array elements
// https://eslint.org/docs/rules/array-element-newline
// TODO: enable? semver-major
'array-element-newline': ['off', { multiline: true, minItems: 3 }],
// enforce spacing inside array brackets
'array-bracket-spacing': ['error', 'never'],
// enforce spacing inside single-line blocks
// https://eslint.org/docs/rules/block-spacing
'block-spacing': ['error', 'always'],
// enforce one true brace style
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
// require camel case names
camelcase: ['error', { properties: 'never', ignoreDestructuring: false }],
// enforce or disallow capitalization of the first letter of a comment
// https://eslint.org/docs/rules/capitalized-comments
'capitalized-comments': ['off', 'never', {
line: {
ignorePattern: '.*',
ignoreInlineComments: true,
ignoreConsecutiveComments: true,
},
block: {
ignorePattern: '.*',
ignoreInlineComments: true,
ignoreConsecutiveComments: true,
},
}],
// require trailing commas in multiline object literals
'comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline',
}],
// enforce spacing before and after comma
'comma-spacing': ['error', { before: false, after: true }],
// enforce one true comma style
'comma-style': ['error', 'last', {
exceptions: {
ArrayExpression: false,
ArrayPattern: false,
ArrowFunctionExpression: false,
CallExpression: false,
FunctionDeclaration: false,
FunctionExpression: false,
ImportDeclaration: false,
ObjectExpression: false,
ObjectPattern: false,
VariableDeclaration: false,
NewExpression: false,
},
}],
// disallow padding inside computed properties
'computed-property-spacing': ['error', 'never'],
// enforces consistent naming when capturing the current execution context
'consistent-this': 'off',
// enforce newline at the end of file, with no multiple empty lines
'eol-last': ['error', 'always'],
// https://eslint.org/docs/rules/function-call-argument-newline
// TODO: enable, semver-minor, once eslint v6.2 is required (which is a major)
'function-call-argument-newline': ['off', 'consistent'],
// enforce spacing between functions and their invocations
// https://eslint.org/docs/rules/func-call-spacing
'func-call-spacing': ['error', 'never'],
// requires function names to match the name of the variable or property to which they are
// assigned
// https://eslint.org/docs/rules/func-name-matching
'func-name-matching': ['off', 'always', {
includeCommonJSModuleExports: false,
considerPropertyDescriptor: true,
}],
// require function expressions to have a name
// https://eslint.org/docs/rules/func-names
'func-names': 'warn',
// enforces use of function declarations or expressions
// https://eslint.org/docs/rules/func-style
// TODO: enable
'func-style': ['off', 'expression'],
// enforce consistent line breaks inside function parentheses
// https://eslint.org/docs/rules/function-paren-newline
'function-paren-newline': ['error', 'consistent'],
// Blacklist certain identifiers to prevent them being used
// https://eslint.org/docs/rules/id-blacklist
'id-blacklist': 'off',
// this option enforces minimum and maximum identifier lengths
// (variable names, property names etc.)
'id-length': 'off',
// require identifiers to match the provided regular expression
'id-match': 'off',
// Enforce the location of arrow function bodies with implicit returns
// https://eslint.org/docs/rules/implicit-arrow-linebreak
'implicit-arrow-linebreak': ['error', 'beside'],
// this option sets a specific tab width for your code
// https://eslint.org/docs/rules/indent
indent: ['error', 2, {
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
// MemberExpression: null,
FunctionDeclaration: {
parameters: 1,
body: 1,
},
FunctionExpression: {
parameters: 1,
body: 1,
},
CallExpression: {
arguments: 1,
},
ArrayExpression: 1,
ObjectExpression: 1,
ImportDeclaration: 1,
flatTernaryExpressions: false,
// list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js
ignoredNodes: ['JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'],
ignoreComments: false,
}],
// specify whether double or single quotes should be used in JSX attributes
// https://eslint.org/docs/rules/jsx-quotes
'jsx-quotes': ['off', 'prefer-double'],
// enforces spacing between keys and values in object literal properties
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
// require a space before & after certain keywords
'keyword-spacing': ['error', {
before: true,
after: true,
overrides: {
return: { after: true },
throw: { after: true },
case: { after: true },
},
}],
// enforce position of line comments
// https://eslint.org/docs/rules/line-comment-position
// TODO: enable?
'line-comment-position': ['off', {
position: 'above',
ignorePattern: '',
applyDefaultPatterns: true,
}],
// disallow mixed 'LF' and 'CRLF' as linebreaks
// https://eslint.org/docs/rules/linebreak-style
'linebreak-style': ['error', 'unix'],
// require or disallow an empty line between class members
// https://eslint.org/docs/rules/lines-between-class-members
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: false }],
// enforces empty lines around comments
'lines-around-comment': 'off',
// require or disallow newlines around directives
// https://eslint.org/docs/rules/lines-around-directive
'lines-around-directive': ['error', {
before: 'always',
after: 'always',
}],
// specify the maximum depth that blocks can be nested
'max-depth': ['off', 4],
// specify the maximum length of a line in your program
// https://eslint.org/docs/rules/max-len
'max-len': ['off'],
// specify the max number of lines in a file
// https://eslint.org/docs/rules/max-lines
'max-lines': ['off', {
max: 300,
skipBlankLines: true,
skipComments: true,
}],
// enforce a maximum function length
// https://eslint.org/docs/rules/max-lines-per-function
'max-lines-per-function': ['off', {
max: 50,
skipBlankLines: true,
skipComments: true,
IIFEs: true,
}],
// specify the maximum depth callbacks can be nested
'max-nested-callbacks': 'off',
// limits the number of parameters that can be used in the function declaration.
'max-params': ['off', 3],
// specify the maximum number of statement allowed in a function
'max-statements': ['off', 10],
// restrict the number of statements per line
// https://eslint.org/docs/rules/max-statements-per-line
'max-statements-per-line': ['off', { max: 1 }],
// enforce a particular style for multiline comments
// https://eslint.org/docs/rules/multiline-comment-style
'multiline-comment-style': ['off', 'starred-block'],
// require multiline ternary
// https://eslint.org/docs/rules/multiline-ternary
// TODO: enable?
'multiline-ternary': ['off', 'never'],
// require a capital letter for constructors
'new-cap': ['error', {
newIsCap: true,
newIsCapExceptions: [],
capIsNew: false,
capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
}],
// disallow the omission of parentheses when invoking a constructor with no arguments
// https://eslint.org/docs/rules/new-parens
'new-parens': 'error',
// allow/disallow an empty newline after var statement
'newline-after-var': 'off',
// https://eslint.org/docs/rules/newline-before-return
'newline-before-return': 'off',
// enforces new line after each method call in the chain to make it
// more readable and easy to maintain
// https://eslint.org/docs/rules/newline-per-chained-call
'newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }],
// disallow use of the Array constructor
'no-array-constructor': 'error',
// disallow use of bitwise operators
// https://eslint.org/docs/rules/no-bitwise
'no-bitwise': 'error',
// disallow use of the continue statement
// https://eslint.org/docs/rules/no-continue
'no-continue': 'error',
// disallow comments inline after code
'no-inline-comments': 'off',
// disallow if as the only statement in an else block
// https://eslint.org/docs/rules/no-lonely-if
'no-lonely-if': 'error',
// disallow un-paren'd mixes of different operators
// https://eslint.org/docs/rules/no-mixed-operators
'no-mixed-operators': ['error', {
// the list of arthmetic groups disallows mixing `%` and `**`
// with other arithmetic operators.
groups: [
['%', '**'],
['%', '+'],
['%', '-'],
['%', '*'],
['%', '/'],
['/', '*'],
['&', '|', '<<', '>>', '>>>'],
['==', '!=', '===', '!=='],
['&&', '||'],
],
allowSamePrecedence: false,
}],
// disallow mixed spaces and tabs for indentation
'no-mixed-spaces-and-tabs': 'error',
// disallow use of chained assignment expressions
// https://eslint.org/docs/rules/no-multi-assign
'no-multi-assign': ['error'],
// disallow multiple empty lines, only one newline at the end, and no new lines at the beginning
// https://eslint.org/docs/rules/no-multiple-empty-lines
'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 1, maxEOF: 0 }],
// disallow negated conditions
// https://eslint.org/docs/rules/no-negated-condition
'no-negated-condition': 'off',
// disallow nested ternary expressions
'no-nested-ternary': 'error',
// disallow use of the Object constructor
'no-new-object': 'error',
// disallow use of unary operators, ++ and --
// https://eslint.org/docs/rules/no-plusplus
'no-plusplus': 'error',
// disallow certain syntax forms
// https://eslint.org/docs/rules/no-restricted-syntax
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'ForOfStatement',
message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
},
{
selector: 'LabeledStatement',
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
// disallow space between function identifier and application
'no-spaced-func': 'error',
// disallow tab characters entirely
'no-tabs': 'error',
// disallow the use of ternary operators
'no-ternary': 'off',
// disallow trailing whitespace at the end of lines
'no-trailing-spaces': ['error', {
skipBlankLines: false,
ignoreComments: false,
}],
// disallow dangling underscores in identifiers
// https://eslint.org/docs/rules/no-underscore-dangle
'no-underscore-dangle': ['error', {
allow: [],
allowAfterThis: false,
allowAfterSuper: false,
enforceInMethodNames: true,
}],
// disallow the use of Boolean literals in conditional expressions
// also, prefer `a || b` over `a ? a : b`
// https://eslint.org/docs/rules/no-unneeded-ternary
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
// disallow whitespace before properties
// https://eslint.org/docs/rules/no-whitespace-before-property
'no-whitespace-before-property': 'error',
// enforce the location of single-line statements
// https://eslint.org/docs/rules/nonblock-statement-body-position
'nonblock-statement-body-position': ['error', 'beside', { overrides: {} }],
// require padding inside curly braces
'object-curly-spacing': ['error', 'always'],
// enforce line breaks between braces
// https://eslint.org/docs/rules/object-curly-newline
'object-curly-newline': ['error', {
ObjectExpression: { multiline: true, consistent: true },
ObjectPattern: { multiline: true, consistent: true },
ImportDeclaration: { multiline: true, consistent: true },
ExportDeclaration: { multiline: true, consistent: true },
}],
// enforce "same line" or "multiple line" on object properties.
// https://eslint.org/docs/rules/object-property-newline
'object-property-newline': ['error', {
allowAllPropertiesOnSameLine: true,
}],
// allow just one var statement per function
'one-var': ['error', 'never'],
// require a newline around variable declaration
// https://eslint.org/docs/rules/one-var-declaration-per-line
'one-var-declaration-per-line': ['error', 'always'],
// require assignment operator shorthand where possible or prohibit it entirely
// https://eslint.org/docs/rules/operator-assignment
'operator-assignment': ['error', 'always'],
// Requires operator at the beginning of the line in multiline statements
// https://eslint.org/docs/rules/operator-linebreak
'operator-linebreak': ['error', 'before', { overrides: { '=': 'none' } }],
// disallow padding within blocks
'padded-blocks': ['error',
{
blocks: 'never',
classes: 'never',
switches: 'never',
},
{
allowSingleLineBlocks: true,
},
],
// Require or disallow padding lines between statements
// https://eslint.org/docs/rules/padding-line-between-statements
'padding-line-between-statements': 'off',
// Disallow the use of Math.pow in favor of the ** operator
// https://eslint.org/docs/rules/prefer-exponentiation-operator
// TODO: enable, semver-major when eslint 5 is dropped
'prefer-exponentiation-operator': 'off',
// Prefer use of an object spread over Object.assign
// https://eslint.org/docs/rules/prefer-object-spread
'prefer-object-spread': 'error',
// require quotes around object literal property names
// https://eslint.org/docs/rules/quote-props.html
'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }],
// specify whether double or single quotes should be used
quotes: ['error', 'single', { avoidEscape: true }],
// do not require jsdoc
// https://eslint.org/docs/rules/require-jsdoc
'require-jsdoc': 'off',
// require or disallow use of semicolons instead of ASI
semi: ['error', 'always'],
// enforce spacing before and after semicolons
'semi-spacing': ['error', { before: false, after: true }],
// Enforce location of semicolons
// https://eslint.org/docs/rules/semi-style
'semi-style': ['error', 'last'],
// requires object keys to be sorted
'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }],
// sort variables within the same declaration block
'sort-vars': 'off',
// require or disallow space before blocks
'space-before-blocks': 'error',
// require or disallow space before function opening parenthesis
// https://eslint.org/docs/rules/space-before-function-paren
'space-before-function-paren': ['error', {
anonymous: 'always',
named: 'never',
asyncArrow: 'always',
}],
// require or disallow spaces inside parentheses
'space-in-parens': ['error', 'never'],
// require spaces around operators
'space-infix-ops': 'error',
// Require or disallow spaces before/after unary operators
// https://eslint.org/docs/rules/space-unary-ops
'space-unary-ops': ['error', {
words: true,
nonwords: false,
overrides: {
},
}],
// require or disallow a space immediately following the // or /* in a comment
// https://eslint.org/docs/rules/spaced-comment
'spaced-comment': ['error', 'always', {
line: {
exceptions: ['-', '+'],
markers: ['=', '!'], // space here to support sprockets directives
},
block: {
exceptions: ['-', '+'],
markers: ['=', '!', ':', '::'], // space here to support sprockets directives and flow comment types
balanced: true,
},
}],
// Enforce spacing around colons of switch statements
// https://eslint.org/docs/rules/switch-colon-spacing
'switch-colon-spacing': ['error', { after: true, before: false }],
// Require or disallow spacing between template tags and their literals
// https://eslint.org/docs/rules/template-tag-spacing
'template-tag-spacing': ['error', 'never'],
// require or disallow the Unicode Byte Order Mark
// https://eslint.org/docs/rules/unicode-bom
'unicode-bom': ['error', 'never'],
// require regex literals to be wrapped in parentheses
'wrap-regex': 'off',
},
};

View File

@@ -0,0 +1,44 @@
const confusingBrowserGlobals = require('confusing-browser-globals');
module.exports = {
rules: {
// enforce or disallow variable initializations at definition
'init-declarations': 'off',
// disallow the catch clause parameter name being the same as a variable in the outer scope
'no-catch-shadow': 'off',
// disallow deletion of variables
'no-delete-var': 'error',
// disallow labels that share a name with a variable
// https://eslint.org/docs/rules/no-label-var
'no-label-var': 'error',
// disallow specific globals
'no-restricted-globals': ['error', 'isFinite', 'isNaN'].concat(confusingBrowserGlobals),
// disallow declaration of variables already declared in the outer scope
'no-shadow': 'error',
// disallow shadowing of names such as arguments
'no-shadow-restricted-names': 'error',
// disallow use of undeclared variables unless mentioned in a /*global */ block
'no-undef': 'error',
// disallow use of undefined when initializing variables
'no-undef-init': 'error',
// disallow use of undefined variable
// https://eslint.org/docs/rules/no-undefined
// TODO: enable?
'no-undefined': 'off',
// disallow declaration of variables that are not used in the code
'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
// disallow use of variables before they are defined
'no-use-before-define': ['error', { functions: true, classes: true, variables: true }],
},
};

View File

@@ -0,0 +1,14 @@
module.exports = {
env: {
jest: true,
},
plugins: [
'jest',
'jest-dom',
],
extends: [
'./rules/jest',
'./rules/jest-dom',
].map(require.resolve),
rules: {},
};

View File

@@ -0,0 +1,9 @@
module.exports = {
rules: {
'jest-dom/prefer-checked': 'error',
'jest-dom/prefer-enabled-disabled': 'error',
'jest-dom/prefer-focus': 'error',
'jest-dom/prefer-required': 'error',
'jest-dom/prefer-to-have-attribute': 'error',
},
};

View File

@@ -0,0 +1,37 @@
module.exports = {
rules: {
'jest/consistent-test-it': ['error', { fn: 'it' }],
'jest/expect-expect': 'error',
'jest/prefer-lowercase-title': ['error', { ignore: ['describe'] }],
'jest/no-alias-methods': 'error',
'jest/no-commented-out-tests': 'off',
'jest/no-disabled-tests': 'off',
'jest/no-duplicate-hooks': 'error',
'jest/no-export': 'error',
'jest/no-focused-tests': 'error',
'jest/no-hooks': 'off',
'jest/no-identical-title': 'error',
'jest/no-if': 'error',
'jest/no-jasmine-globals': 'error',
'jest/no-large-snapshots': 'error',
'jest/no-mocks-import': 'error',
'jest/no-standalone-expect': 'error',
'jest/no-done-callback': 'error',
'jest/no-test-prefixes': 'error',
'jest/no-test-return-statement': 'error',
'jest/prefer-called-with': 'error',
'jest/prefer-expect-assertions': 'off',
'jest/prefer-hooks-on-top': 'error',
'jest/prefer-spy-on': 'error',
'jest/prefer-strict-equal': 'error',
'jest/prefer-to-contain': 'error',
'jest/prefer-to-have-length': 'error',
'jest/prefer-todo': 'error',
'jest/require-top-level-describe': 'error',
'jest/require-to-throw-message': 'error',
'jest/valid-describe-callback': 'error',
'jest/valid-expect-in-promise': 'error',
'jest/valid-expect': 'error',
'jest/valid-title': 'error',
},
};

View File

@@ -0,0 +1,26 @@
module.exports = {
env: {
browser: true,
},
plugins: [
'jsx-a11y',
'react-hooks',
'react',
],
settings: {
react: {
version: 'detect',
},
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
extends: [
'./rules/react-a11y',
'./rules/react-hooks',
'./rules/react',
].map(require.resolve),
rules: {},
};

View File

@@ -0,0 +1,229 @@
module.exports = {
rules: {
// Enforce that anchors have content
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md
'jsx-a11y/anchor-has-content': ['error', { components: [] }],
// Require ARIA roles to be valid and non-abstract
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md
'jsx-a11y/aria-role': ['error', { ignoreNonDom: false }],
// Enforce all aria-* props are valid.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
'jsx-a11y/aria-props': 'error',
// Enforce ARIA state and property values are valid.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md
'jsx-a11y/aria-proptypes': 'error',
// Enforce that elements that do not support ARIA roles, states, and
// properties do not have those attributes.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
'jsx-a11y/aria-unsupported-elements': 'error',
// Enforce that all elements that require alternative text have meaningful information
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md
'jsx-a11y/alt-text': ['error', {
elements: ['img', 'object', 'area', 'input[type="image"]'],
img: [],
object: [],
area: [],
'input[type="image"]': [],
}],
// Prevent img alt text from containing redundant words like "image", "picture", or "photo"
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md
'jsx-a11y/img-redundant-alt': 'error',
// require that JSX labels use "htmlFor"
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
// deprecated: replaced by `label-has-associated-control` rule
'jsx-a11y/label-has-for': ['off', {
components: [],
required: {
every: ['nesting', 'id'],
},
allowChildren: false,
}],
// Enforce that a label tag has a text label and an associated control.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md
'jsx-a11y/label-has-associated-control': ['error', {
labelComponents: [],
labelAttributes: [],
controlComponents: [],
assert: 'both',
depth: 25,
}],
// Enforce that a control (an interactive element) has a text label.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/control-has-associated-label.md
'jsx-a11y/control-has-associated-label': ['error', {
labelAttributes: ['label'],
controlComponents: [],
ignoreElements: [
'audio',
'canvas',
'embed',
'input',
'textarea',
'tr',
'video',
],
ignoreRoles: [
'grid',
'listbox',
'menu',
'menubar',
'radiogroup',
'row',
'tablist',
'toolbar',
'tree',
'treegrid',
],
depth: 5,
}],
// require that mouseover/out come with focus/blur, for keyboard-only users
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md
'jsx-a11y/mouse-events-have-key-events': 'error',
// Prevent use of `accessKey`
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md
'jsx-a11y/no-access-key': 'error',
// require onBlur instead of onChange
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md
'jsx-a11y/no-onchange': 'off',
// Elements with an interactive role and interaction handlers must be focusable
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/interactive-supports-focus.md
'jsx-a11y/interactive-supports-focus': 'error',
// Enforce that elements with ARIA roles must have all required attributes
// for that role.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md
'jsx-a11y/role-has-required-aria-props': 'error',
// Enforce that elements with explicit or implicit roles defined contain
// only aria-* properties supported by that role.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md
'jsx-a11y/role-supports-aria-props': 'error',
// Enforce tabIndex value is not greater than zero.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md
'jsx-a11y/tabindex-no-positive': 'error',
// ensure <hX> tags have content and are not aria-hidden
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md
'jsx-a11y/heading-has-content': ['error', { components: [''] }],
// require HTML elements to have a "lang" prop
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md
'jsx-a11y/html-has-lang': 'error',
// require HTML element's lang prop to be valid
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md
'jsx-a11y/lang': 'error',
// prevent distracting elements, like <marquee> and <blink>
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md
'jsx-a11y/no-distracting-elements': ['error', {
elements: ['marquee', 'blink'],
}],
// only allow <th> to have the "scope" attr
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md
'jsx-a11y/scope': 'error',
// require onClick be accompanied by onKeyUp/onKeyDown/onKeyPress
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md
'jsx-a11y/click-events-have-key-events': 'error',
// Enforce that DOM elements without semantic behavior not have interaction handlers
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md
'jsx-a11y/no-static-element-interactions': ['error', {
handlers: [
'onClick',
'onMouseDown',
'onMouseUp',
'onKeyPress',
'onKeyDown',
'onKeyUp',
],
}],
// A non-interactive element does not support event handlers (mouse and key handlers)
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-interactions.md
'jsx-a11y/no-noninteractive-element-interactions': ['error', {
handlers: [
'onClick',
'onMouseDown',
'onMouseUp',
'onKeyPress',
'onKeyDown',
'onKeyUp',
],
}],
// ensure emoji are accessible
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md
'jsx-a11y/accessible-emoji': 'error',
// elements with aria-activedescendant must be tabbable
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md
'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
// ensure iframe elements have a unique title
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md
'jsx-a11y/iframe-has-title': 'error',
// prohibit autoFocus prop
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md
'jsx-a11y/no-autofocus': ['error', { ignoreNonDOM: true }],
// ensure HTML elements do not specify redundant ARIA roles
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md
'jsx-a11y/no-redundant-roles': 'error',
// media elements must have captions
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/media-has-caption.md
'jsx-a11y/media-has-caption': ['error', {
audio: [],
video: [],
track: [],
}],
// WAI-ARIA roles should not be used to convert an interactive element to non-interactive
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-interactive-element-to-noninteractive-role.md
'jsx-a11y/no-interactive-element-to-noninteractive-role': ['error', {
tr: ['none', 'presentation'],
}],
// WAI-ARIA roles should not be used to convert a non-interactive element to interactive
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-to-interactive-role.md
'jsx-a11y/no-noninteractive-element-to-interactive-role': ['error', {
ul: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
ol: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
li: ['menuitem', 'option', 'row', 'tab', 'treeitem'],
table: ['grid'],
td: ['gridcell'],
}],
// Tab key navigation should be limited to elements on the page that can be interacted with.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-tabindex.md
'jsx-a11y/no-noninteractive-tabindex': ['error', {
tags: [],
roles: ['tabpanel'],
}],
// ensure <a> tags are valid
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md
'jsx-a11y/anchor-is-valid': ['error', {
components: ['Link'],
specialLink: ['to'],
aspects: ['noHref', 'invalidHref', 'preferButton'],
}],
},
};

View File

@@ -0,0 +1,11 @@
module.exports = {
rules: {
// Enforce Rules of Hooks
// https://github.com/facebook/react/blob/c11015ff4f610ac2924d1fc6d569a17657a404fd/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
'react-hooks/rules-of-hooks': 'error',
// Verify the list of the dependencies for Hooks like useEffect and similar
// https://github.com/facebook/react/blob/1204c789776cb01fbaf3e9f032e7e2ba85a44137/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
'react-hooks/exhaustive-deps': 'error',
},
};

View File

@@ -0,0 +1,499 @@
module.exports = {
rules: {
// View link below for react rules documentation
// https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules
// Specify whether double or single quotes should be used in JSX attributes
// https://eslint.org/docs/rules/jsx-quotes
'jsx-quotes': ['error', 'prefer-double'],
'class-methods-use-this': ['error', {
exceptMethods: [
'render',
'getInitialState',
'getDefaultProps',
'getChildContext',
'componentWillMount',
'UNSAFE_componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'UNSAFE_componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'UNSAFE_componentWillUpdate',
'componentDidUpdate',
'componentWillUnmount',
'componentDidCatch',
'getSnapshotBeforeUpdate',
],
}],
// Prevent missing displayName in a React component definition
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md
'react/display-name': ['off', { ignoreTranspilerName: false }],
// Forbid certain propTypes (any, array, object)
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-prop-types.md
'react/forbid-prop-types': ['error', {
forbid: ['any', 'array', 'object'],
checkContextTypes: true,
checkChildContextTypes: true,
}],
// Forbid certain props on DOM Nodes
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-dom-props.md
'react/forbid-dom-props': ['off', { forbid: [] }],
// Enforce boolean attributes notation in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
'react/jsx-boolean-value': ['error', 'never', { always: [] }],
// Validate closing bracket location in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
'react/jsx-closing-bracket-location': ['error', 'line-aligned'],
// Validate closing tag location in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
'react/jsx-closing-tag-location': 'error',
// Enforce or disallow spaces inside of curly braces in JSX attributes
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }],
// Enforce event handler naming conventions in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
'react/jsx-handler-names': ['off', {
eventHandlerPrefix: 'handle',
eventHandlerPropPrefix: 'on',
}],
// Validate props indentation in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
'react/jsx-indent-props': ['error', 2],
// Validate JSX has key prop when in array or iterator
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
'react/jsx-key': 'off',
// Limit maximum of props on a single line in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
'react/jsx-max-props-per-line': ['error', { maximum: 1 }],
// Prevent usage of .bind() in JSX props
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
'react/jsx-no-bind': ['error', {
ignoreRefs: true,
allowArrowFunctions: true,
allowFunctions: false,
allowBind: false,
ignoreDOMComponents: true,
}],
// Prevent duplicate props in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
// Prevent usage of unwrapped JSX strings
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
'react/jsx-no-literals': ['off', { noStrings: true }],
// Disallow undeclared variables in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
'react/jsx-no-undef': 'error',
// Enforce PascalCase for user-defined JSX components
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
'react/jsx-pascal-case': ['error', {
allowAllCaps: true,
ignore: [],
}],
// Enforce propTypes declarations alphabetical sorting
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
'react/sort-prop-types': ['off', {
ignoreCase: true,
callbacksLast: false,
requiredFirst: false,
sortShapeProp: true,
}],
// Deprecated in favor of react/jsx-sort-props
'react/jsx-sort-prop-types': 'off',
// Enforce props alphabetical sorting
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
'react/jsx-sort-props': ['off', {
ignoreCase: true,
callbacksLast: false,
shorthandFirst: false,
shorthandLast: false,
noSortAlphabetically: false,
reservedFirst: true,
}],
// Enforce defaultProps declarations alphabetical sorting
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-sort-default-props.md
'react/jsx-sort-default-props': ['off', {
ignoreCase: true,
}],
// Prevent React to be incorrectly marked as unused
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
'react/jsx-uses-react': ['error'],
// Prevent variables used in JSX to be incorrectly marked as unused
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
'react/jsx-uses-vars': 'error',
// Prevent usage of dangerous JSX properties
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md
'react/no-danger': 'off',
// Prevent usage of deprecated methods
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
'react/no-deprecated': ['error'],
// Prevent usage of setState in componentDidMount
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
// this is necessary for server-rendering
'react/no-did-mount-set-state': 'off',
// Prevent usage of setState in componentDidUpdate
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
'react/no-did-update-set-state': 'off',
// Prevent usage of setState in componentWillUpdate
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md
'react/no-will-update-set-state': 'error',
// Prevent direct mutation of this.state
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
'react/no-direct-mutation-state': 'off',
// Prevent usage of isMounted
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
'react/no-is-mounted': 'error',
// Prevent multiple component definition per file
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
'react/no-multi-comp': 'off',
// Prevent usage of setState
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
'react/no-set-state': 'off',
// Prevent using string references
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
'react/no-string-refs': 'error',
// Prevent usage of unknown DOM property
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
'react/no-unknown-property': 'error',
// Require ES6 class declarations over React.createClass
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
'react/prefer-es6-class': ['error', 'always'],
// Require stateless functions when not using lifecycle methods, setState or ref
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
'react/prefer-stateless-function': ['error', { ignorePureComponents: true }],
// Prevent missing props validation in a React component definition
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
'react/prop-types': ['error', {
ignore: [],
customValidators: [],
skipUndeclared: false,
}],
// Prevent missing React when using JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
'react/react-in-jsx-scope': 'error',
// Require render() methods to return something
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
'react/require-render-return': 'error',
// Prevent extra closing tags for components without children
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
'react/self-closing-comp': 'error',
// Enforce component methods order
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/sort-comp.md
'react/sort-comp': ['error', {
order: [
'static-variables',
'static-methods',
'instance-variables',
'lifecycle',
'/^on.+$/',
'getters',
'setters',
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
'instance-methods',
'everything-else',
'rendering',
],
groups: {
lifecycle: [
'displayName',
'propTypes',
'contextTypes',
'childContextTypes',
'mixins',
'statics',
'defaultProps',
'constructor',
'getDefaultProps',
'getInitialState',
'state',
'getChildContext',
'getDerivedStateFromProps',
'componentWillMount',
'UNSAFE_componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'UNSAFE_componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'UNSAFE_componentWillUpdate',
'getSnapshotBeforeUpdate',
'componentDidUpdate',
'componentDidCatch',
'componentWillUnmount',
],
rendering: [
'/^render.+$/',
'render',
],
},
}],
// Prevent missing parentheses around multilines JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-wrap-multilines.md
'react/jsx-wrap-multilines': ['error', {
declaration: 'parens-new-line',
assignment: 'parens-new-line',
return: 'parens-new-line',
arrow: 'parens-new-line',
condition: 'parens-new-line',
logical: 'parens-new-line',
prop: 'parens-new-line',
}],
// Require that the first prop in a JSX element be on a new line when the element is multiline
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
// Enforce spacing around jsx equals signs
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
'react/jsx-equals-spacing': ['error', 'never'],
// Enforce JSX indentation
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md
'react/jsx-indent': ['error', 2],
// Disallow target="_blank" on links
// https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-no-target-blank.md
'react/jsx-no-target-blank': ['error', { enforceDynamicLinks: 'always' }],
// only .jsx files may have JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
// prevent accidental JS comments from being injected into JSX as text
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
'react/jsx-no-comment-textnodes': 'error',
// disallow using React.render/ReactDOM.render's return value
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
'react/no-render-return-value': 'error',
// require a shouldComponentUpdate method, or PureRenderMixin
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
'react/require-optimization': ['off', { allowDecorators: [] }],
// warn against using findDOMNode()
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
'react/no-find-dom-node': 'error',
// Forbid certain props on Components
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md
'react/forbid-component-props': ['off', { forbid: [] }],
// Forbid certain elements
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md
'react/forbid-elements': ['off', { forbid: [] }],
// Prevent problem with children and props.dangerouslySetInnerHTML
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md
'react/no-danger-with-children': 'error',
// Prevent unused propType definitions
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
'react/no-unused-prop-types': ['error', {
customValidators: [
],
skipShapeProps: true,
}],
// Require style prop value be an object or var
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
'react/style-prop-object': 'error',
// Prevent invalid characters from appearing in markup
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
'react/no-unescaped-entities': 'error',
// Prevent passing of children as props
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
'react/no-children-prop': 'error',
// Validate whitespace in and around the JSX opening and closing brackets
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-tag-spacing.md
'react/jsx-tag-spacing': ['error', {
closingSlash: 'never',
beforeSelfClosing: 'always',
afterOpening: 'never',
beforeClosing: 'never',
}],
// Enforce spaces before the closing bracket of self-closing JSX elements
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md
// Deprecated in favor of jsx-tag-spacing
'react/jsx-space-before-closing': ['off', 'always'],
// Prevent usage of Array index in keys
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
'react/no-array-index-key': 'off',
// Enforce a defaultProps definition for every prop that is not a required prop
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/require-default-props.md
'react/require-default-props': ['error', {
forbidDefaultForRequired: true,
}],
// Forbids using non-exported propTypes
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md
// this is intentionally set to "warn". it would be "error",
// but it's only critical if you're stripping propTypes in production.
'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }],
// Prevent void DOM elements from receiving children
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md
'react/void-dom-elements-no-children': 'error',
// Enforce all defaultProps have a corresponding non-required PropType
// https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/default-props-match-prop-types.md
'react/default-props-match-prop-types': ['error', { allowRequiredDefaults: false }],
// Prevent usage of shouldComponentUpdate when extending React.PureComponent
// https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/no-redundant-should-component-update.md
'react/no-redundant-should-component-update': 'error',
// Prevent unused state values
// https://github.com/yannickcr/eslint-plugin-react/pull/1103/
'react/no-unused-state': 'error',
// Enforces consistent naming for boolean props
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/boolean-prop-naming.md
'react/boolean-prop-naming': ['off', {
propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'],
rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+',
message: '',
}],
// Prevents common casing typos
// https://github.com/yannickcr/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/no-typos.md
'react/no-typos': 'error',
// Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }],
// One JSX Element Per Line
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-one-expression-per-line.md
'react/jsx-one-expression-per-line': ['error', { allow: 'single-child' }],
// Enforce consistent usage of destructuring assignment of props, state, and context
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/destructuring-assignment.md
'react/destructuring-assignment': ['error', 'always'],
// Prevent using this.state within a this.setState
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-access-state-in-setstate.md
'react/no-access-state-in-setstate': 'error',
// Prevent usage of button elements without an explicit type attribute
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/button-has-type.md
'react/button-has-type': ['error', {
button: true,
submit: true,
reset: false,
}],
// Ensures inline tags are not rendered without spaces between them
'react/jsx-child-element-spacing': 'off',
// Prevent this from being used in stateless functional components
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-this-in-sfc.md
'react/no-this-in-sfc': 'error',
// Validate JSX maximum depth
// https://github.com/yannickcr/eslint-plugin-react/blob/abe8381c0d6748047224c430ce47f02e40160ed0/docs/rules/jsx-max-depth.md
'react/jsx-max-depth': 'off',
// Disallow multiple spaces between inline JSX props
// https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-props-no-multi-spaces.md
'react/jsx-props-no-multi-spaces': 'error',
// Prevent usage of UNSAFE_ methods
// https://github.com/yannickcr/eslint-plugin-react/blob/157cc932be2cfaa56b3f5b45df6f6d4322a2f660/docs/rules/no-unsafe.md
'react/no-unsafe': 'off',
// Enforce shorthand or standard form for React fragments
// https://github.com/yannickcr/eslint-plugin-react/blob/bc976b837abeab1dffd90ac6168b746a83fc83cc/docs/rules/jsx-fragments.md
'react/jsx-fragments': ['error', 'element'],
// Enforce linebreaks in curly braces in JSX attributes and expressions.
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md
'react/jsx-curly-newline': ['error', {
multiline: 'consistent',
singleline: 'consistent',
}],
// Enforce state initialization style
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
// TODO: set to "never" once babel-preset-airbnb supports public class fields
'react/state-in-constructor': ['error', 'always'],
// Enforces where React component static properties should be positioned
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
// TODO: set to "static public field" once babel-preset-airbnb supports public class fields
'react/static-property-placement': ['error', 'property assignment'],
// Disallow JSX props spreading
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
'react/jsx-props-no-spreading': 'off',
// Enforce that props are read-only
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md
'react/prefer-read-only-props': 'off',
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.json'],
},
},
react: {
pragma: 'React',
version: 'detect',
},
propWrapperFunctions: [
'forbidExtraProps', // https://www.npmjs.com/package/airbnb-prop-types
'exact', // https://www.npmjs.com/package/prop-types-exact
'Object.freeze', // https://tc39.github.io/ecma262/#sec-object.freeze
],
},
};

8
eslint-config/index.js Normal file
View File

@@ -0,0 +1,8 @@
module.exports = {
extends: [
'./configs/base',
'./configs/jest',
'./configs/react',
].map(require.resolve),
rules: {},
};

View File

@@ -1,21 +1,24 @@
# Auth Example for Payload CMS
# Payload Auth Example
This example demonstrates how to implement [Authentication](https://payloadcms.com/docs/authentication/overview) in Payload CMS.
This example demonstrates how to implement [Payload Authentication](https://payloadcms.com/docs/authentication/overview).
There is a fully working Next.js app tailored specifically for this example which can be found [here](../nextjs). Follow the instructions there to get started. If you are setting up authentication for another front-end, please consider contributing to this repo with your own example!
There is a fully working Next.js app made explicitly for this example which can be found [here](../nextjs). Follow the instructions there to get started. If you are setting up authentication for another front-end, please consider contributing to this repo with your own example!
## Getting Started
## Quick Start
1. Clone this repo
2. `cd` into this directory and run `yarn` or `npm install`
3. `cp .env.example .env` to copy the example environment variables
4. `yarn dev` or `npm run dev` to start the server and seed the database
5. `open http://localhost:8000/admin` to access the admin panel
6. Login with email `dev@payloadcms.com` and password `test`
To spin up this example locally, follow these steps:
1. First clone the repo
1. Then `cd YOUR_PROJECT_REPO && cp .env.example .env`
1. Next `yarn && yarn dev`
1. Now `open http://localhost:8000/admin` to access the admin panel
1. Login with email `dev@payloadcms.com` and password `test`
That's it! Changes made in `./src` will be reflected in your app. See the [Development](#development) section for more details.
## How it works
An auth-enabled `users` collection is create which opens all [auth-related operations](https://payloadcms.com/docs/authentication/operations) needed to create a fully custom workflow on your front-end using the REST or GraphQL APIs, including:
The `users` collection exposes all [auth-related operations](https://payloadcms.com/docs/authentication/operations) needed to create a fully custom workflow on your front-end using the REST or GraphQL APIs, including:
- `Me`
- `Login`
@@ -28,7 +31,7 @@ An auth-enabled `users` collection is create which opens all [auth-related opera
The [`cors`](https://payloadcms.com/docs/production/preventing-abuse#cross-origin-resource-sharing-cors), [`csrf`](https://payloadcms.com/docs/production/preventing-abuse#cross-site-request-forgery-csrf), and [`cookies`](https://payloadcms.com/docs/authentication/config#options) settings are also configured to ensure that the admin panel and front-end can communicate with each other securely.
### Role-based Access Control
### Access Control
Basic role-based access control is setup to determine what users can and cannot do based on their roles, which are:
@@ -37,6 +40,28 @@ Basic role-based access control is setup to determine what users can and cannot
A `beforeChange` field hook called `protectRoles` is placed on this to automatically populate `roles` with the `user` role when a new user is created. It also protects roles from being changed by non-admins.
## Development
To spin up this example locally, follow the [Quick Start](#quick-start).
### Seed
On boot, a seed script is included to create a user with the role `admin`.
On boot, a seed script is included to create a user with email `dev@payloadcms.com`, password `test`, the role `admin`.
> NOTICE: seeding the database is destructive because it drops your current database to populate a fresh one from the seed template. Only run this command if you are starting a new project or can afford to lose your current data.
## Production
To run Payload in production, you need to build and serve the Admin panel. To do so, follow these steps:
1. First invoke the `payload build` script by running `yarn build` or `npm run build` in your project root. This creates a `./build` directory with a production-ready admin bundle.
1. Then run `yarn serve` or `npm run serve` to run Node in production and serve Payload from the `./build` directory.
### Deployment
The easiest way to deploy your project is to use [Payload Cloud](https://payloadcms.com/new/import), a one-click hosting solution to deploy production-ready instances of your Payload apps directly from your GitHub repo. You can also deploy your app manually, check out the [deployment documentation](https://payloadcms.com/docs/production/deployment) for full details.
## Questions
If you have any issues or questions, reach out to us on [Discord](https://discord.com/invite/r6sCXqVk3v) or start a [GitHub discussion](https://github.com/payloadcms/payload/discussions).

View File

@@ -19,15 +19,15 @@
"dependencies": {
"dotenv": "^8.2.0",
"express": "^4.17.1",
"payload": "^1.6.4"
"payload": "^1.7.5"
},
"devDependencies": {
"@payloadcms/eslint-config": "^0.0.1",
"@types/express": "^4.17.9",
"@types/node": "18.11.3",
"@types/react": "18.0.21",
"@types/express": "^4.17.9",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"@payloadcms/eslint-config": "^0.0.1",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"eslint": "^8.19.0",

View File

@@ -4,9 +4,9 @@ This is a [Next.js](https://nextjs.org/) app made explicitly for Payload's [Auth
## Getting Started
### Payload CMS
### Payload
First you'll need a running CMS. If you have not done so already, open up the `cms` folder alongside this example and follow the setup instructions. Take note of your server URL, you'll need this in the next step.
First you'll need a running Payload app. If you have not done so already, open up the `cms` folder alongside this example and follow the setup instructions. Take note of your server URL, you'll need this in the next step.
### Next.js App
@@ -22,14 +22,14 @@ Once running you will find a couple seeded pages on your local environment with
To learn more about PayloadCMS and Next.js, take a look at the following resources:
- [Payload CMS Documentation](https://payloadcms.com/docs) - learn about Payload CMS features and API.
- [Payload Documentation](https://payloadcms.com/docs) - learn about Payload features and API.
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Payload CMS GitHub repository](https://github.com/payloadcms/payload/) as well as [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
You can check out [the Payload GitHub repository](https://github.com/payloadcms/payload/) as well as [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Payload CMS deployment documentaton](https://payloadcms.com/docs/production/deployment) or the [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Check out our [Payload deployment documentation](https://payloadcms.com/docs/production/deployment) or the [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

View File

@@ -69,7 +69,7 @@ const serialize = (children: Children): React.ReactElement[] =>
return <h5 key={i}>{serialize(node.children)}</h5>
case 'h6':
return <h6 key={i}>{serialize(node.children)}</h6>
case 'quote':
case 'blockquote':
return <blockquote key={i}>{serialize(node.children)}</blockquote>
case 'ul':
return <ul key={i}>{serialize(node.children)}</ul>

View File

@@ -0,0 +1,4 @@
MONGODB_URI=mongodb://localhost/payload-example-form-builder
PAYLOAD_SECRET=ENTER-STRING-HERE
PAYLOAD_PUBLIC_SITE_URL=http://localhost:3000
PAYLOAD_PUBLIC_SERVER_URL=http://localhost:8000

View File

@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ['@payloadcms'],
}

5
examples/form-builder/cms/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
build
dist
node_modules
package-lock.json
.env

View File

@@ -0,0 +1 @@
legacy-peer-deps=true

View File

@@ -0,0 +1,8 @@
module.exports = {
printWidth: 100,
parser: "typescript",
semi: false,
singleQuote: true,
trailingComma: "all",
arrowParens: "avoid",
};

View File

@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Form Builder Example CMS",
"program": "${workspaceFolder}/src/server.ts",
"preLaunchTask": "npm: build:server",
"env": {
"PAYLOAD_CONFIG_PATH": "${workspaceFolder}/src/payload.config.ts"
},
// "outFiles": [
// "${workspaceFolder}/dist/**/*.js"
// ]
},
]
}

View File

@@ -0,0 +1,48 @@
# Payload Form Builder Example
This example demonstrates how to implement the official [Form Builder Plugin](https://github.com/payloadcms/plugin-form-builder) into Payload.
There is a fully working Next.js app made explicitly for this example which can be found [here](../nextjs). Follow the instructions there to get started. If you are setting up the form builder plugin for another front-end, please consider contributing to this repo with your own example
## Quick Start
To spin up this example locally, follow these steps:
1. Clone this repo
2. `cd` into this directory and run `yarn` or `npm install`
3. `cp .env.example .env` to copy the example environment variables
4. `yarn dev` or `npm run dev` to start the server and seed the database
5. `open http://localhost:8000/admin` to access the admin panel
6. Login with email `dev@payloadcms.com` and password `test`
That's it! Changes made in `./src` will be reflected in your app. See the [Development](#development) section for more details.
## How it works
The [Form Builder Plugin](https://github.com/payloadcms/plugin-form-builder) automatically adds the `forms` and `formSubmissions` collections to your config which your front-end can use to query forms and submit form data. You can embed forms into layout building blocks by referring a `forms` document in a relationship field.
See the official [Form Builder Plugin](https://github.com/payloadcms/plugin-form-builder) for full details.
## Development
To spin up this example locally, follow the [Quick Start](#quick-start).
### Seed
On boot, a seed script is included to create a user, a home page, and some basic forms.
## Production
To run Payload in production, you need to build and serve the Admin panel. To do so, follow these steps:
1. First invoke the `payload build` script by running `yarn build` or `npm run build` in your project root. This creates a `./build` directory with a production-ready admin bundle.
1. Then run `yarn serve` or `npm run serve` to run Node in production and serve Payload from the `./build` directory.
### Deployment
The easiest way to deploy your project is to use [Payload Cloud](https://payloadcms.com/new/import), a one-click hosting solution to deploy production-ready instances of your Payload apps directly from your GitHub repo. You can also deploy your app manually, check out the [deployment documentation](https://payloadcms.com/docs/production/deployment) for full details.
## Questions
If you have any issues or questions, reach out to us on [Discord](https://discord.com/invite/r6sCXqVk3v) or start a [GitHub discussion](https://github.com/payloadcms/payload/discussions).

View File

@@ -0,0 +1,4 @@
{
"ext": "ts",
"exec": "ts-node src/server.ts"
}

View File

@@ -0,0 +1,33 @@
{
"name": "form-builder-example-cms",
"description": "The CMS that utilizes Payload's form builder plugin.",
"version": "1.0.0",
"main": "dist/server.js",
"license": "MIT",
"scripts": {
"dev": "cross-env PAYLOAD_SEED=true PAYLOAD_DROP_DATABASE=true PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
"build:server": "tsc",
"build": "yarn copyfiles && yarn build:payload && yarn build:server",
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}\" dist/",
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types",
"generate:graphQLSchema": "PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema"
},
"dependencies": {
"@faceless-ui/modal": "^2.0.1",
"@payloadcms/plugin-form-builder": "^1.0.12",
"@payloadcms/plugin-seo": "^1.0.8",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"payload": "^1.7.5"
},
"devDependencies": {
"@types/express": "^4.17.9",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"nodemon": "^2.0.6",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
}
}

View File

@@ -0,0 +1,11 @@
import { Access } from 'payload/config';
export const publishedOnly: Access = ({ req: { user } }) => {
if (user) return true;
return {
_status: {
equals: 'published',
},
};
};

View File

@@ -0,0 +1,33 @@
import { Block } from 'payload/types';
import richText from '../../fields/richText';
export const FormBlock: Block = {
slug: 'formBlock',
labels: {
singular: 'Form Block',
plural: 'Form Blocks',
},
graphQL: {
singularName: 'FormBlock',
},
fields: [
{
name: 'form',
type: 'relationship',
relationTo: 'forms',
required: true,
},
{
name: 'enableIntro',
label: 'Enable Intro Content',
type: 'checkbox',
},
richText({
name: 'introContent',
label: 'Intro Content',
admin: {
condition: (_, { enableIntro }) => Boolean(enableIntro),
},
}),
],
};

View File

@@ -0,0 +1,44 @@
import { CollectionConfig } from 'payload/types';
import { publishedOnly } from '../access/publishedOnly';
import { FormBlock } from '../blocks/Form';
import { slugField } from '../fields/slug';
export const Pages: CollectionConfig = {
slug: 'pages',
admin: {
useAsTitle: 'title',
defaultColumns: ['title', 'slug', 'updatedAt'],
},
versions: {
drafts: true,
},
access: {
read: publishedOnly,
},
fields: [
{
name: 'title',
type: 'text',
required: true,
},
{
type: 'tabs',
tabs: [
{
label: 'Content',
fields: [
{
name: 'layout',
type: 'blocks',
required: true,
blocks: [
FormBlock,
],
},
],
},
],
},
slugField(),
],
};

View File

@@ -0,0 +1,12 @@
import { CollectionConfig } from 'payload/types';
export const Users: CollectionConfig = {
slug: 'users',
auth: true,
admin: {
useAsTitle: 'email',
},
fields: [
// Don't need any user fields here
],
};

View File

@@ -0,0 +1,151 @@
import { Field } from 'payload/types';
import deepMerge from '../utilities/deepMerge';
export const appearanceOptions = {
primary: {
label: 'Primary Button',
value: 'primary',
},
secondary: {
label: 'Secondary Button',
value: 'secondary',
},
default: {
label: 'Default',
value: 'default',
},
};
export type LinkAppearances = 'primary' | 'secondary' | 'default'
type LinkType = (
options?: {
appearances?: LinkAppearances[] | false
disableLabel?: boolean
overrides?: Record<string, unknown>
}
) => Field;
const link: LinkType = ({
appearances,
disableLabel = false,
overrides = {},
} = {}) => {
const linkResult: Field = {
name: 'link',
type: 'group',
admin: {
hideGutter: true,
},
fields: [
{
type: 'row',
fields: [
{
name: 'type',
type: 'radio',
options: [
{
label: 'Internal link',
value: 'reference',
},
{
label: 'Custom URL',
value: 'custom',
},
],
defaultValue: 'reference',
admin: {
layout: 'horizontal',
width: '50%',
},
},
{
name: 'newTab',
label: 'Open in new tab',
type: 'checkbox',
admin: {
width: '50%',
style: {
alignSelf: 'flex-end',
},
},
},
],
},
],
};
const linkTypes: Field[] = [
{
name: 'reference',
label: 'Document to link to',
type: 'relationship',
relationTo: ['pages'],
required: true,
maxDepth: 1,
admin: {
condition: (_, siblingData) => siblingData?.type === 'reference',
},
},
{
name: 'url',
label: 'Custom URL',
type: 'text',
required: true,
admin: {
condition: (_, siblingData) => siblingData?.type === 'custom',
},
},
];
if (!disableLabel) {
linkTypes[0].admin.width = '50%';
linkTypes[1].admin.width = '50%';
linkResult.fields.push({
type: 'row',
fields: [
...linkTypes,
{
name: 'label',
label: 'Label',
type: 'text',
required: true,
admin: {
width: '50%',
},
},
],
});
} else {
linkResult.fields = [...linkResult.fields, ...linkTypes];
}
if (appearances !== false) {
let appearanceOptionsToUse = [
appearanceOptions.default,
appearanceOptions.primary,
appearanceOptions.secondary,
];
if (appearances) {
appearanceOptionsToUse = appearances.map((appearance) => appearanceOptions[appearance]);
}
linkResult.fields.push({
name: 'appearance',
type: 'select',
defaultValue: 'default',
options: appearanceOptionsToUse,
admin: {
description: 'Choose how the link should be rendered.',
},
});
}
return deepMerge(linkResult, overrides);
};
export default link;

View File

@@ -0,0 +1,13 @@
import { RichTextElement } from 'payload/dist/fields/config/types';
const elements: RichTextElement[] = [
'blockquote',
'h2',
'h3',
'h4',
'h5',
'h6',
'link',
];
export default elements;

View File

@@ -0,0 +1,94 @@
import { RichTextElement, RichTextField, RichTextLeaf } from 'payload/dist/fields/config/types';
import deepMerge from '../../utilities/deepMerge';
import elements from './elements';
import leaves from './leaves';
import link from '../link';
type RichText = (
overrides?: Partial<RichTextField>,
additions?: {
elements?: RichTextElement[]
leaves?: RichTextLeaf[]
}
) => RichTextField
const richText: RichText = (
overrides,
additions = {
elements: [],
leaves: [],
},
) => deepMerge<RichTextField, Partial<RichTextField>>(
{
name: 'richText',
type: 'richText',
required: true,
admin: {
upload: {
collections: {
media: {
fields: [
{
type: 'richText',
name: 'caption',
label: 'Caption',
admin: {
elements: [
...elements,
],
leaves: [
...leaves,
],
},
},
{
type: 'radio',
name: 'alignment',
label: 'Alignment',
options: [
{
label: 'Left',
value: 'left',
},
{
label: 'Center',
value: 'center',
},
{
label: 'Right',
value: 'right',
},
],
},
{
name: 'enableLink',
type: 'checkbox',
label: 'Enable Link',
},
link({
appearances: false,
disableLabel: true,
overrides: {
admin: {
condition: (_, data) => Boolean(data?.enableLink),
},
},
}),
],
},
},
},
elements: [
...elements,
...additions.elements || [],
],
leaves: [
...leaves,
...additions.leaves || [],
],
},
},
overrides,
);
export default richText;

View File

@@ -0,0 +1,9 @@
import { RichTextLeaf } from 'payload/dist/fields/config/types';
const defaultLeaves: RichTextLeaf[] = [
'bold',
'italic',
'underline',
];
export default defaultLeaves;

View File

@@ -0,0 +1,23 @@
import { Field } from 'payload/types';
import formatSlug from '../utilities/formatSlug';
import deepMerge from '../utilities/deepMerge';
type Slug = (fieldToUse?: string, overrides?: Partial<Field>) => Field
export const slugField: Slug = (fieldToUse = 'title', overrides) => deepMerge<Field, Partial<Field>>(
{
name: 'slug',
label: 'Slug',
type: 'text',
index: true,
admin: {
position: 'sidebar',
},
hooks: {
beforeValidate: [
formatSlug(fieldToUse),
],
},
},
overrides,
);

View File

@@ -0,0 +1,21 @@
import { GlobalConfig } from 'payload/types';
import link from '../fields/link';
export const MainMenu: GlobalConfig = {
slug: 'main-menu',
access: {
read: () => true,
},
fields: [
{
name: 'navItems',
type: 'array',
maxRows: 6,
fields: [
link({
appearances: false,
}),
],
},
],
};

View File

@@ -0,0 +1,202 @@
/* tslint:disable */
/**
* This file was automatically generated by Payload CMS.
* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,
* and re-run `payload generate:types` to regenerate this file.
*/
export interface Config {}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "main-menu".
*/
export interface MainMenu {
id: string;
navItems: {
link: {
type?: 'reference' | 'custom';
newTab?: boolean;
reference: {
value: string | Page;
relationTo: 'pages';
};
url: string;
label: string;
};
id?: string;
}[];
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "pages".
*/
export interface Page {
id: string;
title: string;
layout: {
form: string | Form;
enableIntro?: boolean;
introContent: {
[k: string]: unknown;
}[];
id?: string;
blockName?: string;
blockType: 'formBlock';
}[];
slug?: string;
_status?: 'draft' | 'published';
createdAt: string;
updatedAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "forms".
*/
export interface Form {
id: string;
title: string;
fields: (
| {
name: string;
label?: string;
width?: number;
defaultValue?: string;
required?: boolean;
id?: string;
blockName?: string;
blockType: 'text';
}
| {
name: string;
label?: string;
width?: number;
defaultValue?: string;
required?: boolean;
id?: string;
blockName?: string;
blockType: 'textarea';
}
| {
name: string;
label?: string;
width?: number;
defaultValue?: string;
options: {
label: string;
value: string;
id?: string;
}[];
required?: boolean;
id?: string;
blockName?: string;
blockType: 'select';
}
| {
name: string;
label?: string;
width?: number;
required?: boolean;
id?: string;
blockName?: string;
blockType: 'email';
}
| {
name: string;
label?: string;
width?: number;
required?: boolean;
id?: string;
blockName?: string;
blockType: 'state';
}
| {
name: string;
label?: string;
width?: number;
required?: boolean;
id?: string;
blockName?: string;
blockType: 'country';
}
| {
name: string;
label?: string;
width?: number;
defaultValue?: number;
required?: boolean;
id?: string;
blockName?: string;
blockType: 'number';
}
| {
name: string;
label?: string;
width?: number;
required?: boolean;
defaultValue?: boolean;
id?: string;
blockName?: string;
blockType: 'checkbox';
}
| {
message?: {
[k: string]: unknown;
}[];
id?: string;
blockName?: string;
blockType: 'message';
}
)[];
submitButtonLabel?: string;
confirmationType?: 'message' | 'redirect';
confirmationMessage: {
[k: string]: unknown;
}[];
redirect: {
url: string;
};
emails: {
emailTo: string;
bcc?: string;
replyTo?: string;
replyToName?: string;
emailFrom?: string;
emailFromName?: string;
subject: string;
message?: {
[k: string]: unknown;
}[];
id?: string;
}[];
createdAt: string;
updatedAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "users".
*/
export interface User {
id: string;
email?: string;
resetPasswordToken?: string;
resetPasswordExpiration?: string;
loginAttempts?: number;
lockUntil?: string;
createdAt: string;
updatedAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "form-submissions".
*/
export interface FormSubmission {
id: string;
form: string | Form;
submissionData: {
field: string;
value: string;
id?: string;
}[];
createdAt: string;
updatedAt: string;
}

View File

@@ -0,0 +1,31 @@
import { buildConfig } from 'payload/config';
import path from 'path';
import FormBuilder from '@payloadcms/plugin-form-builder';
import { Users } from './collections/Users';
import { Pages } from './collections/Pages';
import { MainMenu } from './globals/MainMenu';
export default buildConfig({
collections: [
Pages,
Users,
],
globals: [
MainMenu,
],
cors: [
'http://localhost:3000',
process.env.PAYLOAD_PUBLIC_SITE_URL,
],
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
},
plugins: [
FormBuilder({
fields: {
payment: false,
},
}),
],
});

View File

@@ -0,0 +1,23 @@
export const advanced = {
title: 'Advanced',
layout: [
{
form: '{{ADVANCED_FORM_ID}}',
enableIntro: true,
introContent: [
{
children: [
{
text: 'Advanced form:',
},
],
type: 'h4',
},
],
id: '63adc92568224b995af9df14',
blockType: 'formBlock',
},
],
slug: 'advanced',
_status: 'published',
};

View File

@@ -0,0 +1,119 @@
export const advancedForm = {
id: '63c0835134d40cef85cc11a2',
title: 'Advanced Form',
fields: [
{
name: 'first-name',
label: 'First Name',
width: 50,
required: true,
id: '63c081b169853127a8895312',
blockName: 'first-name',
blockType: 'text',
},
{
name: 'last-name',
label: 'Last Name',
width: 50,
required: true,
id: '63c081c669853127a8895313',
blockName: 'last-name',
blockType: 'text',
},
{
name: 'email',
label: 'Email',
width: 100,
required: true,
id: '63c081e869853127a8895314',
blockName: 'email',
blockType: 'email',
},
{
name: 'street-address',
label: 'Street Address',
width: 100,
required: true,
id: '63c081fe69853127a8895315',
blockName: 'street-address',
blockType: 'text',
},
{
name: 'street-address-two',
label: 'Street Address Line 2',
width: 100,
id: '63c0823169853127a8895316',
blockName: 'street-address-two',
blockType: 'text',
},
{
name: 'city',
label: 'City',
width: 50,
required: true,
id: '63c0825a69853127a8895317',
blockName: 'city',
blockType: 'text',
},
{
name: 'state',
label: 'State',
width: 50,
required: true,
id: '63c0826569853127a8895318',
blockName: 'state',
blockType: 'state',
},
{
name: 'zip-code',
label: 'Postal / Zip Code',
width: 50,
required: true,
id: '63c082bb69853127a889531a',
blockName: 'zip-code',
blockType: 'number',
},
{
name: 'country',
label: 'Country',
width: 50,
required: true,
id: '63c0829269853127a8895319',
blockName: 'country',
blockType: 'country',
},
],
submitButtonLabel: 'Submit',
confirmationType: 'message',
confirmationMessage: [
{
children: [
{
text: 'Your shipping information submission was successful.',
},
],
type: 'h2',
},
],
emails: [
{
emailTo: '{{email}}',
emailFrom: 'dev@payloadcms.com',
emailFromName: 'Payload Team',
subject: "You've received a new message.",
message: [
{
children: [
{
text: 'Your example shipping information form submission was received successfully.',
},
],
},
],
id: '63c0831869853127a889531b',
},
],
createdAt: '2023-01-12T22:01:53.023Z',
updatedAt: '2023-01-12T22:01:53.023Z',
redirect: {},
};

View File

@@ -0,0 +1,103 @@
export const basicForm = {
id: '63c0651b132c8e2783f8dcae',
updatedAt: '2023-01-12T21:25:41.113Z',
createdAt: '2022-12-28T20:48:53.181Z',
title: 'Basic Form',
fields: [
{
name: 'first-name',
label: 'First name',
width: 50,
required: true,
id: '63adaaba5236fe69ca8973f8',
blockName: 'first-name',
blockType: 'text',
},
{
name: 'last-name',
label: 'Last name',
width: 50,
required: true,
id: '63bf4b1fd69cef4f34272f9a',
blockName: 'last-name',
blockType: 'text',
},
{
name: 'email',
label: 'Email',
width: 100,
required: true,
id: '63c0953adc1cd2c2f6c2d30b',
blockName: 'email',
blockType: 'email',
},
{
name: 'coolest-project',
label: "What's the coolest project you've built with Payload so far?",
width: 100,
required: false,
id: '63adab96b65c28c168442316',
blockName: 'coolest-project',
blockType: 'textarea',
},
{
message: [
{
children: [
{
text: 'Have a great rest of your day!',
},
],
},
{
children: [
{
text: '',
},
],
},
{
children: [
{
text: 'Sincerely, \n\nPayload Team.',
},
],
},
],
id: '63adb90db65c28c168442322',
blockName: 'farewell',
blockType: 'message',
},
],
submitButtonLabel: 'Submit',
confirmationType: 'message',
confirmationMessage: [
{
children: [
{
text: 'The basic form has been submitted successfully.',
},
],
type: 'h2',
},
],
emails: [
{
emailTo: '{{email}}',
emailFrom: 'dev@payloadcms.com',
emailFromName: 'Payload',
subject: "You've received a new message.",
message: [
{
children: [
{
text: 'Your basic form submission was successfully received.',
},
],
},
],
id: '63acab72433ea1822764c538',
},
],
redirect: {},
};

View File

@@ -0,0 +1,23 @@
export const contact = {
title: 'Contact',
layout: [
{
form: '{{CONTACT_FORM_ID}}',
enableIntro: true,
introContent: [
{
children: [
{
text: 'Example contact form:',
},
],
type: 'h4',
},
],
id: '63adc92568224b995af9df13',
blockType: 'formBlock',
},
],
slug: 'contact',
_status: 'published',
};

View File

@@ -0,0 +1,75 @@
export const contactForm = {
id: '63c07ffd4cb6b574b4977573',
title: 'Contact Form',
fields: [
{
name: 'full-name',
label: 'Full Name',
width: 100,
required: true,
id: '63c07f4e69853127a889530c',
blockName: 'full-name',
blockType: 'text',
},
{
name: 'email',
label: 'Email',
width: 50,
required: true,
id: '63c07f7069853127a889530d',
blockName: 'email',
blockType: 'email',
},
{
name: 'phone',
label: 'Phone',
width: 50,
required: false,
id: '63c07f8169853127a889530e',
blockName: 'phone',
blockType: 'number',
},
{
name: 'message',
label: 'Message',
width: 100,
required: true,
id: '63c07f9d69853127a8895310',
blockName: 'message',
blockType: 'textarea',
},
],
submitButtonLabel: 'Submit',
confirmationType: 'message',
confirmationMessage: [
{
children: [
{
text: 'The contact form has been submitted successfully.',
},
],
type: 'h2',
},
],
emails: [
{
emailTo: '{{email}}',
emailFrom: 'dev@payloadcms.com',
emailFromName: 'Payload Team',
subject: "You've received a new message.",
message: [
{
children: [
{
text: 'Your contact form submission was successfully received.',
},
],
},
],
id: '63c07fcb69853127a8895311',
},
],
createdAt: '2023-01-12T21:47:41.374Z',
updatedAt: '2023-01-12T21:47:41.374Z',
redirect: {},
};

View File

@@ -0,0 +1,23 @@
export const home = {
title: 'Home',
layout: [
{
form: '{{BASIC_FORM_ID}}',
enableIntro: true,
introContent: [
{
children: [
{
text: 'Example basic form:',
},
],
type: 'h4',
},
],
id: '63adc92568224b995af9df12',
blockType: 'formBlock',
},
],
slug: 'home',
_status: 'published',
};

View File

@@ -0,0 +1,121 @@
import { Payload } from 'payload';
import { home } from './home';
import { contact } from './contact';
import { advanced } from './advanced';
import { signUp } from './signUp';
import { basicForm } from './basicForm';
import { contactForm } from './contactForm';
import { advancedForm } from './advancedForm';
import { signUpForm } from './signUpForm';
export const seed = async (payload: Payload) => {
await payload.create({
collection: 'users',
data: {
email: 'dev@payloadcms.com',
password: 'test',
},
});
const basicFormJSON = JSON.parse(JSON.stringify(basicForm));
const { id: basicFormID } = await payload.create({
collection: 'forms',
data: basicFormJSON,
});
const contactFormJSON = JSON.parse(JSON.stringify(contactForm));
const { id: contactFormID } = await payload.create({
collection: 'forms',
data: contactFormJSON,
});
const advancedFormJSON = JSON.parse(JSON.stringify(advancedForm));
const { id: advancedFormID } = await payload.create({
collection: 'forms',
data: advancedFormJSON,
});
const signUpFormJSON = JSON.parse(JSON.stringify(signUpForm));
const { id: signUpFormID } = await payload.create({
collection: 'forms',
data: signUpFormJSON,
});
const homePageJSON = JSON.parse(
JSON.stringify(home).replace(/{{BASIC_FORM_ID}}/g, basicFormID),
);
const contactPageJSON = JSON.parse(
JSON.stringify(contact).replace(/{{CONTACT_FORM_ID}}/g, contactFormID),
);
const advancedPageJSON = JSON.parse(
JSON.stringify(advanced).replace(/{{ADVANCED_FORM_ID}}/g, advancedFormID),
);
const signupPageJSON = JSON.parse(
JSON.stringify(signUp).replace(/{{SIGNUP_FORM_ID}}/g, signUpFormID),
);
await payload.create({
collection: 'pages',
data: homePageJSON,
});
const { id: contactPageID } = await payload.create({
collection: 'pages',
data: contactPageJSON,
});
const { id: advancedPageID } = await payload.create({
collection: 'pages',
data: advancedPageJSON,
});
const { id: signupPageID } = await payload.create({
collection: 'pages',
data: signupPageJSON,
});
await payload.updateGlobal({
slug: 'main-menu',
data: {
navItems: [
{
link: {
type: 'reference',
reference: {
relationTo: 'pages',
value: contactPageID,
},
label: 'Contact Form',
},
},
{
link: {
type: 'reference',
reference: {
relationTo: 'pages',
value: advancedPageID,
},
label: 'Advanced Form',
},
},
{
link: {
type: 'reference',
reference: {
relationTo: 'pages',
value: signupPageID,
},
label: 'Signup Form',
},
},
],
},
});
};

View File

@@ -0,0 +1,23 @@
export const signUp = {
title: 'Sign Up',
layout: [
{
form: '{{SIGNUP_FORM_ID}}',
enableIntro: true,
introContent: [
{
children: [
{
text: 'Example sign-up form:',
},
],
type: 'h4',
},
],
id: '63adc92568224b995af9df15',
blockType: 'formBlock',
},
],
slug: 'sign-up',
_status: 'published',
};

View File

@@ -0,0 +1,87 @@
export const signUpForm = {
id: '63c086c36955e39c4208aa8f',
title: 'Sign Up Form',
fields: [
{
name: 'full-name',
label: 'Full Name',
width: 100,
required: true,
id: '63c085ae69853127a889531e',
blockName: 'full-name',
blockType: 'text',
},
{
name: 'email',
label: 'Email',
width: 100,
required: true,
id: '63c085df69853127a889531f',
blockName: 'email',
blockType: 'email',
},
{
name: 'password',
label: 'Password',
width: 100,
required: true,
id: '63c0861869853127a8895321',
blockName: 'password',
blockType: 'text',
},
{
message: [
{
children: [
{
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
},
],
},
],
id: '63c0865769853127a8895324',
blockType: 'message',
},
{
name: 'terms-and-conditions',
label: 'I agree to the terms and conditions',
required: true,
id: '63c086a469853127a8895325',
blockName: 'terms-and-conditions',
blockType: 'checkbox',
},
],
submitButtonLabel: 'Create Account',
confirmationType: 'message',
confirmationMessage: [
{
children: [
{
text: 'Your sign up submission was successful.',
},
],
type: 'h2',
},
],
emails: [
{
emailTo: '{{email}}',
emailFrom: 'dev@payloadcms.com',
emailFromName: 'Payload Team',
subject: "You've received a new message.",
message: [
{
children: [
{
text: 'Your sign up submissioin was received successfully.',
},
],
},
],
id: '63c0858f69853127a889531d',
},
],
createdAt: '2023-01-12T22:16:35.480Z',
updatedAt: '2023-01-12T22:16:35.480Z',
redirect: {},
};

View File

@@ -0,0 +1,40 @@
import path from 'path';
import express from 'express';
import payload from 'payload';
import { seed } from './seed';
// eslint-disable-next-line
require('dotenv').config({
path: path.resolve(__dirname, '../.env'),
});
const app = express();
app.get('/', (_, res) => {
res.redirect('/admin');
});
const start = async () => {
await payload.init({
secret: process.env.PAYLOAD_SECRET,
mongoURL: process.env.MONGODB_URI,
express: app,
email: {
fromName: 'Admin',
fromAddress: 'admin@example.com',
logMockCredentials: true,
},
onInit: () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
},
});
if (process.env.PAYLOAD_SEED === 'true') {
payload.logger.info('---- SEEDING DATABASE ----');
await seed(payload);
}
app.listen(8000);
};
start();

View File

@@ -0,0 +1,32 @@
/**
* Simple object check.
* @param item
* @returns {boolean}
*/
export function isObject(item: unknown): boolean {
return (item && typeof item === 'object' && !Array.isArray(item));
}
/**
* Deep merge two objects.
* @param target
* @param ...sources
*/
export default function deepMerge<T, R>(target: T, source: R): T {
const output = { ...target };
if (isObject(target) && isObject(source)) {
Object.keys(source).forEach((key) => {
if (isObject(source[key])) {
if (!(key in target)) {
Object.assign(output, { [key]: source[key] });
} else {
output[key] = deepMerge(target[key], source[key]);
}
} else {
Object.assign(output, { [key]: source[key] });
}
});
}
return output;
}

Some files were not shown because too many files have changed in this diff Show More