payload 1.0.34 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/.eslintrc.js +1 -0
  2. package/components/elements.ts +1 -1
  3. package/components/index.js +2 -2
  4. package/dist/admin/components/elements/DeleteDocument/index.js +6 -6
  5. package/dist/admin/components/elements/DuplicateDocument/index.js +4 -4
  6. package/dist/admin/components/elements/GenerateConfirmation/index.js +7 -5
  7. package/dist/admin/components/elements/ListControls/index.js +3 -2
  8. package/dist/admin/components/elements/Nav/index.js +43 -24
  9. package/dist/admin/components/elements/Nav/index.scss +22 -26
  10. package/dist/admin/components/elements/NavGroup/index.d.ts +8 -0
  11. package/dist/admin/components/elements/NavGroup/index.js +52 -0
  12. package/dist/admin/components/elements/NavGroup/index.scss +53 -0
  13. package/dist/admin/components/elements/Popup/index.js +14 -13
  14. package/dist/admin/components/elements/SearchFilter/index.js +45 -16
  15. package/dist/admin/components/elements/SearchFilter/types.d.ts +2 -0
  16. package/dist/admin/components/elements/Status/index.js +14 -9
  17. package/dist/admin/components/elements/WhereBuilder/index.js +14 -1
  18. package/dist/admin/components/forms/Error/index.scss +2 -1
  19. package/dist/admin/components/forms/Form/buildStateFromSchema/addFieldStatePromise.js +3 -3
  20. package/dist/admin/components/forms/Label/index.scss +3 -1
  21. package/dist/admin/components/forms/field-types/Array/index.js +14 -9
  22. package/dist/admin/components/forms/field-types/Blocks/index.js +12 -7
  23. package/dist/admin/components/forms/field-types/Collapsible/index.js +7 -7
  24. package/dist/admin/components/forms/field-types/RichText/RichText.d.ts +2 -2
  25. package/dist/admin/components/forms/field-types/RichText/RichText.js +3 -6
  26. package/dist/admin/components/forms/field-types/RichText/elements/indent/index.js +0 -3
  27. package/dist/admin/components/forms/field-types/RichText/elements/index.d.ts +6 -3
  28. package/dist/admin/components/forms/field-types/RichText/elements/link/Button.d.ts +4 -0
  29. package/dist/admin/components/forms/field-types/RichText/elements/link/Button.js +105 -0
  30. package/dist/admin/components/forms/field-types/RichText/elements/link/Element.d.ts +9 -0
  31. package/dist/admin/components/forms/field-types/RichText/elements/link/Element.js +120 -0
  32. package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/baseFields.d.ts +3 -0
  33. package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/baseFields.js +56 -0
  34. package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/index.d.ts +4 -0
  35. package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/index.js +22 -0
  36. package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/index.scss +29 -0
  37. package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/types.d.ts +9 -0
  38. package/dist/admin/components/forms/field-types/RichText/elements/link/Modal/types.js +1 -0
  39. package/dist/admin/components/forms/field-types/RichText/elements/link/index.d.ts +6 -5
  40. package/dist/admin/components/forms/field-types/RichText/elements/link/index.js +4 -67
  41. package/dist/admin/components/forms/field-types/RichText/elements/link/index.scss +36 -63
  42. package/dist/admin/components/forms/field-types/RichText/elements/link/shared.d.ts +1 -0
  43. package/dist/admin/components/forms/field-types/RichText/elements/link/shared.js +1 -0
  44. package/dist/admin/components/forms/field-types/RichText/elements/link/utilities.d.ts +1 -1
  45. package/dist/admin/components/forms/field-types/RichText/elements/link/utilities.js +13 -23
  46. package/dist/admin/components/forms/field-types/RichText/elements/relationship/Button/index.js +6 -10
  47. package/dist/admin/components/forms/field-types/RichText/elements/toggle.js +0 -3
  48. package/dist/admin/components/forms/field-types/RichText/elements/upload/Button/index.js +8 -12
  49. package/dist/admin/components/forms/field-types/RichText/elements/upload/Element/EditModal/index.js +2 -3
  50. package/dist/admin/components/forms/field-types/RichText/elements/upload/Element/index.js +6 -6
  51. package/dist/admin/components/forms/field-types/RichText/types.d.ts +0 -4
  52. package/dist/admin/components/forms/field-types/Tabs/index.js +4 -4
  53. package/dist/admin/components/forms/field-types/Text/Input.d.ts +2 -0
  54. package/dist/admin/components/forms/field-types/Text/Input.js +2 -3
  55. package/dist/admin/components/forms/field-types/Text/index.js +2 -2
  56. package/dist/admin/components/forms/field-types/Text/types.d.ts +3 -0
  57. package/dist/admin/components/forms/field-types/Upload/Add/index.js +4 -4
  58. package/dist/admin/components/forms/field-types/Upload/Input.js +3 -3
  59. package/dist/admin/components/forms/field-types/Upload/SelectExisting/index.js +6 -6
  60. package/dist/admin/components/forms/field-types/rowReducer.d.ts +1 -0
  61. package/dist/admin/components/forms/field-types/rowReducer.js +2 -2
  62. package/dist/admin/components/graphics/Account/Gravatar.d.ts +3 -0
  63. package/dist/admin/components/graphics/Account/Gravatar.js +15 -0
  64. package/dist/admin/components/graphics/Account/index.d.ts +2 -2
  65. package/dist/admin/components/graphics/Account/index.js +24 -1
  66. package/dist/admin/components/modals/StayLoggedIn/index.js +4 -3
  67. package/dist/admin/components/utilities/Auth/index.js +1 -1
  68. package/dist/admin/components/views/Account/index.js +1 -1
  69. package/dist/admin/components/views/Dashboard/Default.js +44 -12
  70. package/dist/admin/components/views/Dashboard/index.scss +1 -1
  71. package/dist/admin/components/views/Version/Restore/index.js +3 -3
  72. package/dist/admin/components/views/collections/List/RelationshipProvider/index.js +1 -1
  73. package/dist/admin/components/views/collections/List/getInitialColumns.js +2 -2
  74. package/dist/admin/hooks/useThrottledEffect.js +15 -10
  75. package/dist/admin/index.js +1 -1
  76. package/dist/admin/scss/vars.scss +2 -2
  77. package/dist/admin/utilities/groupNavItems.d.ts +19 -0
  78. package/dist/admin/utilities/groupNavItems.js +36 -0
  79. package/dist/auth/types.d.ts +1 -1
  80. package/dist/bin/generateTypes.js +20 -4
  81. package/dist/collections/config/schema.js +18 -2
  82. package/dist/collections/config/types.d.ts +9 -0
  83. package/dist/collections/operations/create.js +3 -1
  84. package/dist/collections/operations/local/create.d.ts +2 -2
  85. package/dist/collections/operations/local/create.js +3 -3
  86. package/dist/collections/operations/local/update.js +2 -2
  87. package/dist/collections/operations/restoreVersion.js +11 -1
  88. package/dist/collections/operations/update.js +3 -1
  89. package/dist/config/defaults.js +2 -1
  90. package/dist/config/schema.js +3 -1
  91. package/dist/config/types.d.ts +1 -0
  92. package/dist/fields/config/schema.js +14 -6
  93. package/dist/fields/config/types.d.ts +45 -9
  94. package/dist/fields/config/types.js +10 -2
  95. package/dist/fields/hooks/afterChange/index.d.ts +2 -1
  96. package/dist/fields/hooks/afterChange/index.js +4 -2
  97. package/dist/fields/hooks/afterChange/promise.d.ts +5 -3
  98. package/dist/fields/hooks/afterChange/promise.js +49 -18
  99. package/dist/fields/hooks/afterChange/traverseFields.d.ts +5 -3
  100. package/dist/fields/hooks/afterChange/traverseFields.js +4 -2
  101. package/dist/fields/hooks/afterRead/promise.d.ts +2 -2
  102. package/dist/fields/hooks/afterRead/promise.js +50 -22
  103. package/dist/fields/hooks/afterRead/traverseFields.d.ts +2 -2
  104. package/dist/fields/hooks/beforeChange/promise.d.ts +2 -2
  105. package/dist/fields/hooks/beforeChange/promise.js +51 -20
  106. package/dist/fields/hooks/beforeChange/traverseFields.d.ts +2 -2
  107. package/dist/fields/hooks/beforeValidate/promise.d.ts +2 -2
  108. package/dist/fields/hooks/beforeValidate/promise.js +35 -15
  109. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +2 -2
  110. package/dist/fields/richText/recurseNestedFields.js +3 -3
  111. package/dist/fields/richText/{relationshipPromise.d.ts → richTextRelationshipPromise.d.ts} +0 -0
  112. package/dist/fields/richText/richTextRelationshipPromise.js +104 -0
  113. package/dist/globals/config/schema.js +2 -1
  114. package/dist/globals/config/types.d.ts +2 -0
  115. package/dist/globals/operations/restoreVersion.js +10 -1
  116. package/dist/globals/operations/update.js +4 -1
  117. package/dist/graphql/schema/buildMutationInputType.js +27 -13
  118. package/dist/graphql/schema/buildObjectType.js +18 -3
  119. package/dist/graphql/schema/withNullableType.d.ts +2 -2
  120. package/dist/graphql/schema/withNullableType.js +1 -1
  121. package/dist/mongoose/buildQuery.js +4 -2
  122. package/dist/mongoose/buildSchema.js +25 -14
  123. package/dist/types/index.d.ts +1 -1
  124. package/dist/uploads/getBaseFields.js +3 -3
  125. package/dist/uploads/getFileByPath.d.ts +1 -1
  126. package/dist/uploads/getFileByPath.js +5 -5
  127. package/dist/uploads/getSafeFilename.js +3 -4
  128. package/dist/uploads/imageResizer.d.ts +1 -9
  129. package/dist/uploads/imageResizer.js +18 -18
  130. package/dist/uploads/types.d.ts +18 -3
  131. package/dist/uploads/uploadFile.js +29 -8
  132. package/dist/utilities/flattenTopLevelFields.js +2 -2
  133. package/dist/utilities/groupOrTabHasRequiredSubfield.d.ts +2 -0
  134. package/dist/utilities/groupOrTabHasRequiredSubfield.js +17 -0
  135. package/dist/utilities/logger.js +2 -3
  136. package/dist/utilities/wordBoundariesRegex.js +2 -2
  137. package/docs/admin/overview.mdx +2 -1
  138. package/docs/configuration/collections.mdx +14 -1
  139. package/docs/fields/array.mdx +10 -1
  140. package/docs/fields/blocks.mdx +9 -1
  141. package/docs/fields/collapsible.mdx +13 -5
  142. package/docs/fields/rich-text.mdx +7 -0
  143. package/docs/fields/tabs.mdx +4 -2
  144. package/docs/hooks/collections.mdx +3 -2
  145. package/docs/hooks/fields.mdx +11 -9
  146. package/docs/hooks/globals.mdx +1 -0
  147. package/docs/upload/overview.mdx +5 -3
  148. package/package.json +4 -4
  149. package/CHANGELOG.md +0 -1870
  150. package/dist/fields/richText/relationshipPromise.js +0 -71
@@ -0,0 +1,53 @@
1
+ @import '../../../scss/styles.scss';
2
+
3
+ .nav-group {
4
+ width: 100%;
5
+ margin-bottom: base(.5);
6
+
7
+ &__toggle {
8
+ cursor: pointer;
9
+ color: var(--theme-elevation-400);
10
+ background: transparent;
11
+ padding-left: 0;
12
+ border: 0;
13
+ margin-top: base(.25);
14
+ width: 100%;
15
+ text-align: left;
16
+ display: flex;
17
+ align-items: flex-start;
18
+ padding-right: base(.5);
19
+
20
+ svg {
21
+ flex-shrink: 0;
22
+ margin-top: base(-.2);
23
+ }
24
+
25
+ &:hover {
26
+ color: var(--theme-elevation-1000);
27
+
28
+ .stroke {
29
+ stroke: var(--theme-elevation-1000);
30
+ }
31
+ }
32
+ }
33
+
34
+ &__indicator {
35
+ margin-left: auto;
36
+
37
+ .stroke {
38
+ stroke: var(--theme-elevation-200);
39
+ }
40
+ }
41
+
42
+ &--collapsed {
43
+ .collapsible__toggle {
44
+ border-bottom-right-radius: $style-radius-s;
45
+ border-bottom-left-radius: $style-radius-s;
46
+ }
47
+
48
+ .nav-group__indicator {
49
+ transform: rotate(.5turn);
50
+ }
51
+ }
52
+
53
+ }
@@ -1,28 +1,30 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { useWindowInfo } from '@faceless-ui/window-info';
3
- import { useScrollInfo } from '@faceless-ui/scroll-info';
4
- import useThrottledEffect from '../../../hooks/useThrottledEffect';
5
3
  import PopupButton from './PopupButton';
6
4
  import './index.scss';
5
+ import useIntersect from '../../../hooks/useIntersect';
7
6
  const baseClass = 'popup';
8
7
  const Popup = (props) => {
9
8
  const { className, buttonClassName, render, size = 'small', color = 'light', button, buttonType = 'default', children, showOnHover = false, horizontalAlign: horizontalAlignFromProps = 'left', verticalAlign: verticalAlignFromProps = 'top', initActive = false, onToggleOpen, padding, forceOpen, boundingRef, } = props;
9
+ const { width: windowWidth, height: windowHeight } = useWindowInfo();
10
+ const [intersectionRef, intersectionEntry] = useIntersect({
11
+ threshold: 1,
12
+ rootMargin: '-100px 0px 0px 0px',
13
+ root: (boundingRef === null || boundingRef === void 0 ? void 0 : boundingRef.current) || null,
14
+ });
10
15
  const buttonRef = useRef(null);
11
16
  const contentRef = useRef(null);
12
- const [mounted, setMounted] = useState(false);
13
17
  const [active, setActive] = useState(initActive);
14
18
  const [verticalAlign, setVerticalAlign] = useState(verticalAlignFromProps);
15
19
  const [horizontalAlign, setHorizontalAlign] = useState(horizontalAlignFromProps);
16
- const { y: scrollY } = useScrollInfo();
17
- const { height: windowHeight, width: windowWidth } = useWindowInfo();
18
20
  const handleClickOutside = useCallback((e) => {
19
21
  if (contentRef.current.contains(e.target)) {
20
22
  return;
21
23
  }
22
24
  setActive(false);
23
- }, []);
24
- useThrottledEffect(() => {
25
- if (contentRef.current && buttonRef.current) {
25
+ }, [contentRef]);
26
+ useEffect(() => {
27
+ if (contentRef.current) {
26
28
  const { left: contentLeftPos, right: contentRightPos, top: contentTopPos, bottom: contentBottomPos, } = contentRef.current.getBoundingClientRect();
27
29
  let boundingTopPos = 100;
28
30
  let boundingRightPos = windowWidth;
@@ -45,12 +47,11 @@ const Popup = (props) => {
45
47
  if (contentTopPos < boundingTopPos && contentBottomPos < boundingBottomPos) {
46
48
  setVerticalAlign('bottom');
47
49
  }
48
- else if (contentBottomPos > boundingBottomPos && contentTopPos < boundingTopPos) {
50
+ else if (contentBottomPos > boundingBottomPos && contentTopPos > boundingTopPos) {
49
51
  setVerticalAlign('top');
50
52
  }
51
- setMounted(true);
52
53
  }
53
- }, 500, [scrollY, windowHeight, windowWidth]);
54
+ }, [boundingRef, intersectionEntry, windowHeight, windowWidth]);
54
55
  useEffect(() => {
55
56
  if (typeof onToggleOpen === 'function')
56
57
  onToggleOpen(active);
@@ -74,7 +75,7 @@ const Popup = (props) => {
74
75
  `${baseClass}--color-${color}`,
75
76
  `${baseClass}--v-align-${verticalAlign}`,
76
77
  `${baseClass}--h-align-${horizontalAlign}`,
77
- (active && mounted) && `${baseClass}--active`,
78
+ (active) && `${baseClass}--active`,
78
79
  ].filter(Boolean).join(' ');
79
80
  return (React.createElement("div", { className: classes },
80
81
  React.createElement("div", { ref: buttonRef, className: `${baseClass}__wrapper` }, showOnHover
@@ -82,7 +83,7 @@ const Popup = (props) => {
82
83
  React.createElement(PopupButton, { ...{ className: buttonClassName, buttonType, button, setActive, active } })))
83
84
  : (React.createElement(PopupButton, { ...{ className: buttonClassName, buttonType, button, setActive, active } }))),
84
85
  React.createElement("div", { className: `${baseClass}__content`, ref: contentRef },
85
- React.createElement("div", { className: `${baseClass}__wrap` },
86
+ React.createElement("div", { className: `${baseClass}__wrap`, ref: intersectionRef },
86
87
  React.createElement("div", { className: `${baseClass}__scroll`, style: {
87
88
  padding,
88
89
  } },
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
2
  import { useHistory } from 'react-router-dom';
3
3
  import queryString from 'qs';
4
4
  import Search from '../../icons/Search';
@@ -7,26 +7,44 @@ import { useSearchParams } from '../../utilities/SearchParams';
7
7
  import './index.scss';
8
8
  const baseClass = 'search-filter';
9
9
  const SearchFilter = (props) => {
10
- const { fieldName = 'id', fieldLabel = 'ID', modifySearchQuery = true, handleChange, } = props;
10
+ const { fieldName = 'id', fieldLabel = 'ID', modifySearchQuery = true, listSearchableFields, handleChange, } = props;
11
11
  const params = useSearchParams();
12
12
  const history = useHistory();
13
- const [search, setSearch] = useState(() => { var _a, _b; return ((_b = (_a = params === null || params === void 0 ? void 0 : params.where) === null || _a === void 0 ? void 0 : _a[fieldName]) === null || _b === void 0 ? void 0 : _b.like) || ''; });
13
+ const [search, setSearch] = useState('');
14
+ const [previousSearch, setPreviousSearch] = useState('');
15
+ const placeholder = useRef(`Search by ${fieldLabel}`);
14
16
  const debouncedSearch = useDebounce(search, 300);
15
17
  useEffect(() => {
16
- var _a, _b, _c, _d, _e;
17
- if (debouncedSearch !== ((_b = (_a = params === null || params === void 0 ? void 0 : params.where) === null || _a === void 0 ? void 0 : _a[fieldName]) === null || _b === void 0 ? void 0 : _b.like)) {
18
- const newWhere = {
19
- ...(typeof (params === null || params === void 0 ? void 0 : params.where) === 'object' ? params.where : {}),
20
- [fieldName]: {
21
- like: debouncedSearch,
22
- },
23
- };
24
- if (!debouncedSearch) {
25
- delete newWhere[fieldName];
18
+ const newWhere = { ...typeof (params === null || params === void 0 ? void 0 : params.where) === 'object' ? params.where : {} };
19
+ const fieldNamesToSearch = [fieldName, ...(listSearchableFields || []).map(({ name }) => name)];
20
+ fieldNamesToSearch.forEach((fieldNameToSearch) => {
21
+ const hasOrQuery = Array.isArray(newWhere.or);
22
+ const existingFieldSearchIndex = hasOrQuery ? newWhere.or.findIndex((condition) => {
23
+ var _a;
24
+ return (_a = condition === null || condition === void 0 ? void 0 : condition[fieldNameToSearch]) === null || _a === void 0 ? void 0 : _a.like;
25
+ }) : -1;
26
+ if (debouncedSearch) {
27
+ if (!hasOrQuery)
28
+ newWhere.or = [];
29
+ if (existingFieldSearchIndex > -1) {
30
+ newWhere.or[existingFieldSearchIndex][fieldNameToSearch].like = debouncedSearch;
31
+ }
32
+ else {
33
+ newWhere.or.push({
34
+ [fieldNameToSearch]: {
35
+ like: debouncedSearch,
36
+ },
37
+ });
38
+ }
26
39
  }
40
+ else if (existingFieldSearchIndex > -1) {
41
+ newWhere.or.splice(existingFieldSearchIndex, 1);
42
+ }
43
+ });
44
+ if (debouncedSearch !== previousSearch) {
27
45
  if (handleChange)
28
46
  handleChange(newWhere);
29
- if (modifySearchQuery && ((_d = (_c = params === null || params === void 0 ? void 0 : params.where) === null || _c === void 0 ? void 0 : _c[fieldName]) === null || _d === void 0 ? void 0 : _d.like) !== ((_e = newWhere === null || newWhere === void 0 ? void 0 : newWhere[fieldName]) === null || _e === void 0 ? void 0 : _e.like)) {
47
+ if (modifySearchQuery) {
30
48
  history.replace({
31
49
  search: queryString.stringify({
32
50
  ...params,
@@ -34,11 +52,22 @@ const SearchFilter = (props) => {
34
52
  where: newWhere,
35
53
  }),
36
54
  });
55
+ setPreviousSearch(debouncedSearch);
37
56
  }
38
57
  }
39
- }, [debouncedSearch, history, fieldName, params, handleChange, modifySearchQuery]);
58
+ }, [debouncedSearch, previousSearch, history, fieldName, params, handleChange, modifySearchQuery, listSearchableFields]);
59
+ useEffect(() => {
60
+ if ((listSearchableFields === null || listSearchableFields === void 0 ? void 0 : listSearchableFields.length) > 0) {
61
+ placeholder.current = listSearchableFields.reduce((prev, curr, i) => {
62
+ if (i === listSearchableFields.length - 1) {
63
+ return `${prev} or ${curr.label || curr.name}`;
64
+ }
65
+ return `${prev}, ${curr.label || curr.name}`;
66
+ }, placeholder.current);
67
+ }
68
+ }, [listSearchableFields]);
40
69
  return (React.createElement("div", { className: baseClass },
41
- React.createElement("input", { className: `${baseClass}__input`, placeholder: `Search by ${fieldLabel}`, type: "text", value: search || '', onChange: (e) => setSearch(e.target.value) }),
70
+ React.createElement("input", { className: `${baseClass}__input`, placeholder: placeholder.current, type: "text", value: search || '', onChange: (e) => setSearch(e.target.value) }),
42
71
  React.createElement(Search, null)));
43
72
  };
44
73
  export default SearchFilter;
@@ -1,7 +1,9 @@
1
+ import { FieldAffectingData } from '../../../../fields/config/types';
1
2
  import { Where } from '../../../../types';
2
3
  export declare type Props = {
3
4
  fieldName?: string;
4
5
  fieldLabel?: string;
5
6
  modifySearchQuery?: boolean;
7
+ listSearchableFields?: FieldAffectingData[];
6
8
  handleChange?: (where: Where) => void;
7
9
  };
@@ -10,16 +10,16 @@ import { useForm } from '../../forms/Form/context';
10
10
  import { useLocale } from '../../utilities/Locale';
11
11
  import './index.scss';
12
12
  const baseClass = 'status';
13
- const unPublishModalSlug = 'confirm-un-publish';
14
- const revertModalSlug = 'confirm-revert';
15
13
  const Status = () => {
16
14
  var _a, _b;
17
15
  const { publishedDoc, unpublishedVersions, collection, global, id, getVersions } = useDocumentInfo();
18
- const { toggle, closeAll: closeAllModals } = useModal();
16
+ const { toggleModal } = useModal();
19
17
  const { serverURL, routes: { api } } = useConfig();
20
18
  const [processing, setProcessing] = useState(false);
21
19
  const { reset: resetForm } = useForm();
22
20
  const locale = useLocale();
21
+ const unPublishModalSlug = `confirm-un-publish-${id}`;
22
+ const revertModalSlug = `confirm-revert-${id}`;
23
23
  let statusToRender;
24
24
  if (((_a = unpublishedVersions === null || unpublishedVersions === void 0 ? void 0 : unpublishedVersions.docs) === null || _a === void 0 ? void 0 : _a.length) > 0 && publishedDoc) {
25
25
  statusToRender = 'Changed';
@@ -77,29 +77,34 @@ const Status = () => {
77
77
  toast.error('There was a problem while un-publishing this document.');
78
78
  }
79
79
  setProcessing(false);
80
- closeAllModals();
81
- }, [closeAllModals, collection, global, serverURL, api, resetForm, id, locale, getVersions, publishedDoc]);
80
+ if (action === 'revert') {
81
+ toggleModal(revertModalSlug);
82
+ }
83
+ if (action === 'unpublish') {
84
+ toggleModal(unPublishModalSlug);
85
+ }
86
+ }, [collection, global, publishedDoc, serverURL, api, id, locale, resetForm, getVersions, toggleModal, revertModalSlug, unPublishModalSlug]);
82
87
  if (statusToRender) {
83
88
  return (React.createElement("div", { className: baseClass },
84
89
  React.createElement("div", { className: `${baseClass}__value-wrap` },
85
90
  React.createElement("span", { className: `${baseClass}__value` }, statusToRender),
86
91
  statusToRender === 'Published' && (React.createElement(React.Fragment, null,
87
92
  "\u00A0\u2014\u00A0",
88
- React.createElement(Button, { onClick: () => toggle(unPublishModalSlug), className: `${baseClass}__action`, buttonStyle: "none" }, "Unpublish"),
93
+ React.createElement(Button, { onClick: () => toggleModal(unPublishModalSlug), className: `${baseClass}__action`, buttonStyle: "none" }, "Unpublish"),
89
94
  React.createElement(Modal, { slug: unPublishModalSlug, className: `${baseClass}__modal` },
90
95
  React.createElement(MinimalTemplate, { className: `${baseClass}__modal-template` },
91
96
  React.createElement("h1", null, "Confirm unpublish"),
92
97
  React.createElement("p", null, "You are about to unpublish this document. Are you sure?"),
93
- React.createElement(Button, { buttonStyle: "secondary", type: "button", onClick: processing ? undefined : () => toggle(unPublishModalSlug) }, "Cancel"),
98
+ React.createElement(Button, { buttonStyle: "secondary", type: "button", onClick: processing ? undefined : () => toggleModal(unPublishModalSlug) }, "Cancel"),
94
99
  React.createElement(Button, { onClick: processing ? undefined : () => performAction('unpublish') }, processing ? 'Unpublishing...' : 'Confirm'))))),
95
100
  statusToRender === 'Changed' && (React.createElement(React.Fragment, null,
96
101
  "\u00A0\u2014\u00A0",
97
- React.createElement(Button, { onClick: () => toggle(revertModalSlug), className: `${baseClass}__action`, buttonStyle: "none" }, "Revert to published"),
102
+ React.createElement(Button, { onClick: () => toggleModal(revertModalSlug), className: `${baseClass}__action`, buttonStyle: "none" }, "Revert to published"),
98
103
  React.createElement(Modal, { slug: revertModalSlug, className: `${baseClass}__modal` },
99
104
  React.createElement(MinimalTemplate, { className: `${baseClass}__modal-template` },
100
105
  React.createElement("h1", null, "Confirm revert to saved"),
101
106
  React.createElement("p", null, "You are about to revert this document's changes to its published state. Are you sure?"),
102
- React.createElement(Button, { buttonStyle: "secondary", type: "button", onClick: processing ? undefined : () => toggle(revertModalSlug) }, "Cancel"),
107
+ React.createElement(Button, { buttonStyle: "secondary", type: "button", onClick: processing ? undefined : () => toggleModal(revertModalSlug) }, "Cancel"),
103
108
  React.createElement(Button, { onClick: processing ? undefined : () => performAction('revert') }, processing ? 'Reverting...' : 'Confirm'))))))));
104
109
  }
105
110
  return null;
@@ -41,9 +41,22 @@ const WhereBuilder = (props) => {
41
41
  const [reducedFields] = useState(() => reduceFields(collection.fields));
42
42
  useThrottledEffect(() => {
43
43
  const currentParams = queryString.parse(history.location.search, { ignoreQueryPrefix: true, depth: 10 });
44
+ const paramsToKeep = typeof (currentParams === null || currentParams === void 0 ? void 0 : currentParams.where) === 'object' && 'or' in currentParams.where ? currentParams.where.or.reduce((keptParams, param) => {
45
+ const newParam = { ...param };
46
+ if (param.and) {
47
+ delete newParam.and;
48
+ }
49
+ return [
50
+ ...keptParams,
51
+ newParam,
52
+ ];
53
+ }, []) : [];
44
54
  const newWhereQuery = {
45
55
  ...typeof (currentParams === null || currentParams === void 0 ? void 0 : currentParams.where) === 'object' ? currentParams.where : {},
46
- or: conditions,
56
+ or: [
57
+ ...conditions,
58
+ ...paramsToKeep,
59
+ ],
47
60
  };
48
61
  if (handleChange)
49
62
  handleChange(newWhereQuery);
@@ -1,6 +1,7 @@
1
1
  @import '../../../scss/styles';
2
2
 
3
3
  .field-error.tooltip {
4
+ font-family: var(--font-body);
4
5
  top: 0;
5
6
  bottom: auto;
6
7
  left: auto;
@@ -11,4 +12,4 @@
11
12
  span {
12
13
  border-top-color: var(--theme-error-500);
13
14
  }
14
- }
15
+ }
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-param-reassign */
2
2
  import ObjectID from 'bson-objectid';
3
- import { fieldAffectsData, fieldHasSubFields } from '../../../../../fields/config/types';
3
+ import { fieldAffectsData, fieldHasSubFields, tabHasName, } from '../../../../../fields/config/types';
4
4
  import getValueWithDefault from '../../../../../fields/getDefaultValue';
5
5
  import { iterateFields } from './iterateFields';
6
6
  export const addFieldStatePromise = async ({ field, locale, user, state, path, passesCondition, fullData, data, fieldPromises, id, operation, }) => {
@@ -162,9 +162,9 @@ export const addFieldStatePromise = async ({ field, locale, user, state, path, p
162
162
  iterateFields({
163
163
  state,
164
164
  fields: tab.fields,
165
- data,
165
+ data: tabHasName(tab) ? data === null || data === void 0 ? void 0 : data[tab.name] : data,
166
166
  parentPassesCondition: passesCondition,
167
- path,
167
+ path: tabHasName(tab) ? `${path}${tab.name}.` : path,
168
168
  user,
169
169
  fieldPromises,
170
170
  fullData,
@@ -1,13 +1,15 @@
1
1
  @import '../../../scss/styles.scss';
2
2
 
3
3
  label.field-label {
4
+ @extend %body;
4
5
  display: flex;
5
6
  padding-bottom: base(.25);
6
7
  color: var(--theme-elevation-800);
8
+ font-family: var(--font-body);
7
9
 
8
10
  .required {
9
11
  color: var(--theme-error-500);
10
12
  margin-left: base(.25);
11
13
  margin-right: auto;
12
14
  }
13
- }
15
+ }
@@ -25,7 +25,7 @@ import './index.scss';
25
25
  const baseClass = 'array-field';
26
26
  const ArrayFieldType = (props) => {
27
27
  var _a, _b;
28
- const { name, path: pathFromProps, fields, fieldTypes, validate = array, required, maxRows, minRows, permissions, admin: { readOnly, description, condition, className, }, } = props;
28
+ const { name, path: pathFromProps, fields, fieldTypes, validate = array, required, maxRows, minRows, permissions, admin: { readOnly, description, condition, initCollapsed, className, }, } = props;
29
29
  const path = pathFromProps || name;
30
30
  // Handle labeling for Arrays, Global Arrays, and Blocks
31
31
  const getLabels = (p) => {
@@ -95,9 +95,14 @@ const ArrayFieldType = (props) => {
95
95
  var _a, _b, _c;
96
96
  dispatchRows({ type: 'SET_COLLAPSE', id: rowID, collapsed });
97
97
  if (preferencesKey) {
98
- const preferencesToSet = await getPreference(preferencesKey) || { fields: {} };
99
- let newCollapsedState = ((_b = (_a = preferencesToSet === null || preferencesToSet === void 0 ? void 0 : preferencesToSet.fields) === null || _a === void 0 ? void 0 : _a[path]) === null || _b === void 0 ? void 0 : _b.collapsed.filter((filterID) => (rows.find((row) => row.id === filterID))))
100
- || [];
98
+ const preferencesToSet = (await getPreference(preferencesKey)) || { fields: {} };
99
+ let newCollapsedState = (_b = (_a = preferencesToSet === null || preferencesToSet === void 0 ? void 0 : preferencesToSet.fields) === null || _a === void 0 ? void 0 : _a[path]) === null || _b === void 0 ? void 0 : _b.collapsed;
100
+ if (initCollapsed && typeof newCollapsedState === 'undefined') {
101
+ newCollapsedState = rows.map((row) => row.id);
102
+ }
103
+ else if (typeof newCollapsedState === 'undefined') {
104
+ newCollapsedState = [];
105
+ }
101
106
  if (!collapsed) {
102
107
  newCollapsedState = newCollapsedState.filter((existingID) => existingID !== rowID);
103
108
  }
@@ -107,7 +112,7 @@ const ArrayFieldType = (props) => {
107
112
  setPreference(preferencesKey, {
108
113
  ...preferencesToSet,
109
114
  fields: {
110
- ...(preferencesToSet === null || preferencesToSet === void 0 ? void 0 : preferencesToSet.fields) || {},
115
+ ...((preferencesToSet === null || preferencesToSet === void 0 ? void 0 : preferencesToSet.fields) || {}),
111
116
  [path]: {
112
117
  ...(_c = preferencesToSet === null || preferencesToSet === void 0 ? void 0 : preferencesToSet.fields) === null || _c === void 0 ? void 0 : _c[path],
113
118
  collapsed: newCollapsedState,
@@ -115,7 +120,7 @@ const ArrayFieldType = (props) => {
115
120
  },
116
121
  });
117
122
  }
118
- }, [preferencesKey, path, setPreference, rows, getPreference]);
123
+ }, [preferencesKey, getPreference, path, setPreference, initCollapsed, rows]);
119
124
  const toggleCollapseAll = useCallback(async (collapse) => {
120
125
  var _a;
121
126
  dispatchRows({ type: 'SET_ALL_COLLAPSED', collapse });
@@ -137,11 +142,11 @@ const ArrayFieldType = (props) => {
137
142
  const initializeRowState = async () => {
138
143
  var _a, _b;
139
144
  const data = formContext.getDataByPath(path);
140
- const preferences = await getPreference(preferencesKey) || { fields: {} };
141
- dispatchRows({ type: 'SET_ALL', data: data || [], collapsedState: (_b = (_a = preferences === null || preferences === void 0 ? void 0 : preferences.fields) === null || _a === void 0 ? void 0 : _a[path]) === null || _b === void 0 ? void 0 : _b.collapsed });
145
+ const preferences = (await getPreference(preferencesKey)) || { fields: {} };
146
+ dispatchRows({ type: 'SET_ALL', data: data || [], collapsedState: (_b = (_a = preferences === null || preferences === void 0 ? void 0 : preferences.fields) === null || _a === void 0 ? void 0 : _a[path]) === null || _b === void 0 ? void 0 : _b.collapsed, initCollapsed });
142
147
  };
143
148
  initializeRowState();
144
- }, [formContext, path, getPreference, preferencesKey]);
149
+ }, [formContext, path, getPreference, preferencesKey, initCollapsed]);
145
150
  useEffect(() => {
146
151
  setValue((rows === null || rows === void 0 ? void 0 : rows.length) || 0, true);
147
152
  if ((rows === null || rows === void 0 ? void 0 : rows.length) === 0) {
@@ -32,7 +32,7 @@ const labelDefaults = {
32
32
  plural: 'Blocks',
33
33
  };
34
34
  const Index = (props) => {
35
- const { label, name, path: pathFromProps, blocks, labels = labelDefaults, fieldTypes, maxRows, minRows, required, validate = blocksValidator, permissions, admin: { readOnly, description, condition, className, }, } = props;
35
+ const { label, name, path: pathFromProps, blocks, labels = labelDefaults, fieldTypes, maxRows, minRows, required, validate = blocksValidator, permissions, admin: { readOnly, description, condition, initCollapsed, className, }, } = props;
36
36
  const path = pathFromProps || name;
37
37
  const { preferencesKey } = useDocumentInfo();
38
38
  const { getPreference } = usePreferences();
@@ -99,8 +99,13 @@ const Index = (props) => {
99
99
  dispatchRows({ type: 'SET_COLLAPSE', id: rowID, collapsed });
100
100
  if (preferencesKey) {
101
101
  const preferencesToSet = await getPreference(preferencesKey) || { fields: {} };
102
- let newCollapsedState = ((_b = (_a = preferencesToSet === null || preferencesToSet === void 0 ? void 0 : preferencesToSet.fields) === null || _a === void 0 ? void 0 : _a[path]) === null || _b === void 0 ? void 0 : _b.collapsed.filter((filterID) => (rows.find((row) => row.id === filterID))))
103
- || [];
102
+ let newCollapsedState = (_b = (_a = preferencesToSet === null || preferencesToSet === void 0 ? void 0 : preferencesToSet.fields) === null || _a === void 0 ? void 0 : _a[path]) === null || _b === void 0 ? void 0 : _b.collapsed;
103
+ if (initCollapsed && typeof newCollapsedState === 'undefined') {
104
+ newCollapsedState = rows.map((row) => row.id);
105
+ }
106
+ else if (typeof newCollapsedState === 'undefined') {
107
+ newCollapsedState = [];
108
+ }
104
109
  if (!collapsed) {
105
110
  newCollapsedState = newCollapsedState.filter((existingID) => existingID !== rowID);
106
111
  }
@@ -118,7 +123,7 @@ const Index = (props) => {
118
123
  },
119
124
  });
120
125
  }
121
- }, [preferencesKey, getPreference, path, setPreference, rows]);
126
+ }, [preferencesKey, getPreference, path, setPreference, initCollapsed, rows]);
122
127
  const toggleCollapseAll = useCallback(async (collapse) => {
123
128
  var _a;
124
129
  dispatchRows({ type: 'SET_ALL_COLLAPSED', collapse });
@@ -141,11 +146,11 @@ const Index = (props) => {
141
146
  const initializeRowState = async () => {
142
147
  var _a, _b;
143
148
  const data = formContext.getDataByPath(path);
144
- const preferences = await getPreference(preferencesKey) || { fields: {} };
145
- dispatchRows({ type: 'SET_ALL', data: data || [], collapsedState: (_b = (_a = preferences === null || preferences === void 0 ? void 0 : preferences.fields) === null || _a === void 0 ? void 0 : _a[path]) === null || _b === void 0 ? void 0 : _b.collapsed });
149
+ const preferences = (await getPreference(preferencesKey)) || { fields: {} };
150
+ dispatchRows({ type: 'SET_ALL', data: data || [], collapsedState: (_b = (_a = preferences === null || preferences === void 0 ? void 0 : preferences.fields) === null || _a === void 0 ? void 0 : _a[path]) === null || _b === void 0 ? void 0 : _b.collapsed, initCollapsed });
146
151
  };
147
152
  initializeRowState();
148
- }, [formContext, path, getPreference, preferencesKey]);
153
+ }, [formContext, path, getPreference, preferencesKey, initCollapsed]);
149
154
  useEffect(() => {
150
155
  setValue((rows === null || rows === void 0 ? void 0 : rows.length) || 0, true);
151
156
  if ((rows === null || rows === void 0 ? void 0 : rows.length) === 0) {
@@ -10,10 +10,10 @@ import { getFieldPath } from '../getFieldPath';
10
10
  import './index.scss';
11
11
  const baseClass = 'collapsible-field';
12
12
  const CollapsibleField = (props) => {
13
- const { label, fields, fieldTypes, path, permissions, admin: { readOnly, className, description, }, } = props;
13
+ const { label, fields, fieldTypes, path, permissions, admin: { readOnly, className, initCollapsed, description, }, } = props;
14
14
  const { getPreference, setPreference } = usePreferences();
15
15
  const { preferencesKey } = useDocumentInfo();
16
- const [initCollapsed, setInitCollapsed] = useState();
16
+ const [collapsedOnMount, setCollapsedOnMount] = useState();
17
17
  const [fieldPreferencesKey] = useState(() => `collapsible-${toKebabCase(label)}`);
18
18
  const onToggle = useCallback(async (newCollapsedState) => {
19
19
  var _a;
@@ -31,16 +31,16 @@ const CollapsibleField = (props) => {
31
31
  }, [preferencesKey, fieldPreferencesKey, getPreference, setPreference]);
32
32
  useEffect(() => {
33
33
  const fetchInitialState = async () => {
34
- var _a, _b;
34
+ var _a, _b, _c;
35
35
  const preferences = await getPreference(preferencesKey);
36
- setInitCollapsed(Boolean((_b = (_a = preferences === null || preferences === void 0 ? void 0 : preferences.fields) === null || _a === void 0 ? void 0 : _a[fieldPreferencesKey]) === null || _b === void 0 ? void 0 : _b.collapsed));
36
+ setCollapsedOnMount(Boolean((_c = (_b = (_a = preferences === null || preferences === void 0 ? void 0 : preferences.fields) === null || _a === void 0 ? void 0 : _a[fieldPreferencesKey]) === null || _b === void 0 ? void 0 : _b.collapsed) !== null && _c !== void 0 ? _c : initCollapsed));
37
37
  };
38
38
  fetchInitialState();
39
- }, [getPreference, preferencesKey, fieldPreferencesKey]);
40
- if (typeof initCollapsed !== 'boolean')
39
+ }, [getPreference, preferencesKey, fieldPreferencesKey, initCollapsed]);
40
+ if (typeof collapsedOnMount !== 'boolean')
41
41
  return null;
42
42
  return (React.createElement(React.Fragment, null,
43
- React.createElement(Collapsible, { initCollapsed: initCollapsed, className: [
43
+ React.createElement(Collapsible, { initCollapsed: collapsedOnMount, className: [
44
44
  'field-type',
45
45
  baseClass,
46
46
  className,
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { BaseEditor } from 'slate';
3
3
  import { ReactEditor } from 'slate-react';
4
4
  import { HistoryEditor } from 'slate-history';
5
- import { Props, BlurSelectionEditor } from './types';
5
+ import { Props } from './types';
6
6
  import './index.scss';
7
7
  declare type CustomText = {
8
8
  text: string;
@@ -14,7 +14,7 @@ declare type CustomElement = {
14
14
  };
15
15
  declare module 'slate' {
16
16
  interface CustomTypes {
17
- Editor: BaseEditor & ReactEditor & HistoryEditor & BlurSelectionEditor;
17
+ Editor: BaseEditor & ReactEditor & HistoryEditor;
18
18
  Element: CustomElement;
19
19
  Text: CustomText;
20
20
  }
@@ -74,9 +74,6 @@ const RichText = (props) => {
74
74
  CreatedEditor = enablePlugins(CreatedEditor, leaves);
75
75
  return CreatedEditor;
76
76
  }, [elements, leaves]);
77
- const onBlur = useCallback(() => {
78
- editor.blurSelection = editor.selection;
79
- }, [editor]);
80
77
  useEffect(() => {
81
78
  if (!loaded) {
82
79
  const mergedElements = mergeCustomFunctions(elements, elementTypes);
@@ -128,7 +125,7 @@ const RichText = (props) => {
128
125
  const elementType = enabledElements[elementName];
129
126
  const Button = elementType === null || elementType === void 0 ? void 0 : elementType.Button;
130
127
  if (Button) {
131
- return (React.createElement(Button, { key: i, path: path }));
128
+ return (React.createElement(Button, { fieldProps: props, key: i, path: path }));
132
129
  }
133
130
  return null;
134
131
  }),
@@ -141,12 +138,12 @@ const RichText = (props) => {
141
138
  const leafType = enabledLeaves[leafName];
142
139
  const Button = leafType === null || leafType === void 0 ? void 0 : leafType.Button;
143
140
  if (Button) {
144
- return (React.createElement(Button, { key: i, path: path }));
141
+ return (React.createElement(Button, { fieldProps: props, key: i, path: path }));
145
142
  }
146
143
  return null;
147
144
  }))),
148
145
  React.createElement("div", { className: `${baseClass}__editor`, ref: editorRef },
149
- React.createElement(Editable, { id: `field-${path.replace(/\./gi, '__')}`, className: `${baseClass}__input`, renderElement: renderElement, renderLeaf: renderLeaf, placeholder: placeholder, spellCheck: true, readOnly: readOnly, onBlur: onBlur, onKeyDown: (event) => {
146
+ React.createElement(Editable, { id: `field-${path.replace(/\./gi, '__')}`, className: `${baseClass}__input`, renderElement: renderElement, renderLeaf: renderLeaf, placeholder: placeholder, spellCheck: true, readOnly: readOnly, onKeyDown: (event) => {
150
147
  if (event.key === 'Enter') {
151
148
  if (event.shiftKey) {
152
149
  event.preventDefault();
@@ -13,9 +13,6 @@ const indent = {
13
13
  const editor = useSlate();
14
14
  const handleIndent = useCallback((e, dir) => {
15
15
  e.preventDefault();
16
- if (editor.blurSelection) {
17
- Transforms.select(editor, editor.blurSelection);
18
- }
19
16
  if (dir === 'left') {
20
17
  Transforms.unwrapNodes(editor, {
21
18
  match: (n) => Element.isElement(n) && [indentType, ...listTypes].includes(n.type),
@@ -43,14 +43,17 @@ declare const elements: {
43
43
  }) => JSX.Element;
44
44
  };
45
45
  link: {
46
- Button: () => JSX.Element;
47
- Element: ({ attributes, children, element, editorRef }: {
46
+ Button: ({ fieldProps }: {
47
+ fieldProps: any;
48
+ }) => JSX.Element;
49
+ Element: ({ attributes, children, element, editorRef, fieldProps }: {
48
50
  attributes: any;
49
51
  children: any;
50
52
  element: any;
51
53
  editorRef: any;
54
+ fieldProps: any;
52
55
  }) => JSX.Element;
53
- plugins: ((incomingEditor: import("slate").BaseEditor & import("slate-react").ReactEditor & import("slate-history").HistoryEditor & import("../types").BlurSelectionEditor) => import("slate").BaseEditor & import("slate-react").ReactEditor & import("slate-history").HistoryEditor & import("../types").BlurSelectionEditor)[];
56
+ plugins: ((incomingEditor: import("slate").BaseEditor & import("slate-react").ReactEditor & import("slate-history").HistoryEditor) => import("slate").BaseEditor & import("slate-react").ReactEditor & import("slate-history").HistoryEditor)[];
54
57
  };
55
58
  ol: {
56
59
  Button: () => JSX.Element;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export declare const LinkButton: ({ fieldProps }: {
3
+ fieldProps: any;
4
+ }) => JSX.Element;