@payloadcms/ui 4.0.0-canary.2 → 4.0.0-internal.011fd46

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 (194) hide show
  1. package/dist/css/colors.css +3 -0
  2. package/dist/css/design-tokens.css +5 -0
  3. package/dist/css/elevations.css +4 -0
  4. package/dist/elements/AppHeader/index.d.ts +3 -2
  5. package/dist/elements/AppHeader/index.d.ts.map +1 -1
  6. package/dist/elements/AppHeader/index.js +2 -2
  7. package/dist/elements/AppHeader/index.js.map +1 -1
  8. package/dist/elements/ColumnSelection/Popup.d.ts +12 -0
  9. package/dist/elements/ColumnSelection/Popup.d.ts.map +1 -0
  10. package/dist/elements/{ColumnSelector/index.js → ColumnSelection/Popup.js} +23 -12
  11. package/dist/elements/ColumnSelection/Popup.js.map +1 -0
  12. package/dist/elements/ColumnSelection/index.d.ts +10 -0
  13. package/dist/elements/ColumnSelection/index.d.ts.map +1 -0
  14. package/dist/elements/{ColumnsButton → ColumnSelection}/index.js +23 -17
  15. package/dist/elements/ColumnSelection/index.js.map +1 -0
  16. package/dist/elements/DocumentControls/index.css +7 -1
  17. package/dist/elements/DocumentControls/index.d.ts.map +1 -1
  18. package/dist/elements/DocumentControls/index.js +2 -2
  19. package/dist/elements/DocumentControls/index.js.map +1 -1
  20. package/dist/elements/DocumentDrawer/DrawerHeader/index.d.ts.map +1 -1
  21. package/dist/elements/DocumentDrawer/DrawerHeader/index.js +5 -3
  22. package/dist/elements/DocumentDrawer/DrawerHeader/index.js.map +1 -1
  23. package/dist/elements/GroupBy/Popup.d.ts +21 -0
  24. package/dist/elements/GroupBy/Popup.d.ts.map +1 -0
  25. package/dist/elements/GroupBy/Popup.js +269 -0
  26. package/dist/elements/GroupBy/Popup.js.map +1 -0
  27. package/dist/elements/GroupBy/index.d.ts +12 -0
  28. package/dist/elements/GroupBy/index.d.ts.map +1 -0
  29. package/dist/elements/GroupBy/index.js +91 -0
  30. package/dist/elements/GroupBy/index.js.map +1 -0
  31. package/dist/elements/ListColumnSelectionButton/index.d.ts +11 -0
  32. package/dist/elements/ListColumnSelectionButton/index.d.ts.map +1 -0
  33. package/dist/elements/ListColumnSelectionButton/index.js +37 -0
  34. package/dist/elements/ListColumnSelectionButton/index.js.map +1 -0
  35. package/dist/elements/ListControls/index.d.ts.map +1 -1
  36. package/dist/elements/ListControls/index.js +7 -7
  37. package/dist/elements/ListControls/index.js.map +1 -1
  38. package/dist/elements/ListGroupByButton/index.d.ts +12 -0
  39. package/dist/elements/ListGroupByButton/index.d.ts.map +1 -0
  40. package/dist/elements/ListGroupByButton/index.js +55 -0
  41. package/dist/elements/ListGroupByButton/index.js.map +1 -0
  42. package/dist/elements/ListWhereBuilder/index.d.ts +16 -0
  43. package/dist/elements/ListWhereBuilder/index.d.ts.map +1 -0
  44. package/dist/elements/ListWhereBuilder/index.js +62 -0
  45. package/dist/elements/ListWhereBuilder/index.js.map +1 -0
  46. package/dist/elements/Popup/PopupButtonList/index.css +5 -0
  47. package/dist/elements/Popup/PopupGroupLabel/index.css +8 -5
  48. package/dist/elements/Popup/index.d.ts.map +1 -1
  49. package/dist/elements/Popup/index.js +42 -11
  50. package/dist/elements/Popup/index.js.map +1 -1
  51. package/dist/elements/PublishMany/DrawerContent.d.ts +2 -1
  52. package/dist/elements/PublishMany/DrawerContent.d.ts.map +1 -1
  53. package/dist/elements/PublishMany/DrawerContent.js.map +1 -1
  54. package/dist/elements/PublishMany/index.d.ts +2 -6
  55. package/dist/elements/PublishMany/index.d.ts.map +1 -1
  56. package/dist/elements/PublishMany/index.js +0 -38
  57. package/dist/elements/PublishMany/index.js.map +1 -1
  58. package/dist/elements/QueryPresets/cells/ColumnsCell/{index.scss → index.css} +1 -3
  59. package/dist/elements/QueryPresets/cells/ColumnsCell/index.d.ts +1 -1
  60. package/dist/elements/QueryPresets/cells/ColumnsCell/index.d.ts.map +1 -1
  61. package/dist/elements/QueryPresets/cells/ColumnsCell/index.js +1 -1
  62. package/dist/elements/QueryPresets/cells/ColumnsCell/index.js.map +1 -1
  63. package/dist/elements/QueryPresets/fields/ColumnsField/index.d.ts +1 -1
  64. package/dist/elements/QueryPresets/fields/ColumnsField/index.d.ts.map +1 -1
  65. package/dist/elements/QueryPresets/fields/ColumnsField/index.js +77 -48
  66. package/dist/elements/QueryPresets/fields/ColumnsField/index.js.map +1 -1
  67. package/dist/elements/QueryPresets/fields/GroupByField/index.d.ts +1 -1
  68. package/dist/elements/QueryPresets/fields/GroupByField/index.d.ts.map +1 -1
  69. package/dist/elements/QueryPresets/fields/GroupByField/index.js +12 -21
  70. package/dist/elements/QueryPresets/fields/GroupByField/index.js.map +1 -1
  71. package/dist/elements/QueryPresets/fields/Heading/index.css +52 -0
  72. package/dist/elements/QueryPresets/fields/Heading/index.d.ts +7 -0
  73. package/dist/elements/QueryPresets/fields/Heading/index.d.ts.map +1 -0
  74. package/dist/elements/QueryPresets/fields/Heading/index.js +31 -0
  75. package/dist/elements/QueryPresets/fields/Heading/index.js.map +1 -0
  76. package/dist/elements/QueryPresets/fields/WhereField/index.d.ts +1 -1
  77. package/dist/elements/QueryPresets/fields/WhereField/index.d.ts.map +1 -1
  78. package/dist/elements/QueryPresets/fields/WhereField/index.js +24 -23
  79. package/dist/elements/QueryPresets/fields/WhereField/index.js.map +1 -1
  80. package/dist/elements/QueryPresets/fields/fields.css +23 -0
  81. package/dist/elements/ReactSelect/getCaptureMenuScroll.d.ts +5 -0
  82. package/dist/elements/ReactSelect/getCaptureMenuScroll.d.ts.map +1 -0
  83. package/dist/elements/ReactSelect/getCaptureMenuScroll.js +10 -0
  84. package/dist/elements/ReactSelect/getCaptureMenuScroll.js.map +1 -0
  85. package/dist/elements/ReactSelect/getMenuListStyles.d.ts +6 -0
  86. package/dist/elements/ReactSelect/getMenuListStyles.d.ts.map +1 -0
  87. package/dist/elements/ReactSelect/getMenuListStyles.js +7 -0
  88. package/dist/elements/ReactSelect/getMenuListStyles.js.map +1 -0
  89. package/dist/elements/ReactSelect/index.css +0 -1
  90. package/dist/elements/ReactSelect/index.d.ts.map +1 -1
  91. package/dist/elements/ReactSelect/index.js +168 -148
  92. package/dist/elements/ReactSelect/index.js.map +1 -1
  93. package/dist/elements/ReactSelect/types.d.ts +1 -0
  94. package/dist/elements/ReactSelect/types.d.ts.map +1 -1
  95. package/dist/elements/ReactSelect/types.js.map +1 -1
  96. package/dist/elements/RelationshipTable/index.js +2 -2
  97. package/dist/elements/RelationshipTable/index.js.map +1 -1
  98. package/dist/elements/SortColumn/index.css +1 -1
  99. package/dist/elements/Table/index.css +24 -2
  100. package/dist/elements/Toasts/fieldErrors.d.ts +1 -0
  101. package/dist/elements/Toasts/fieldErrors.d.ts.map +1 -1
  102. package/dist/elements/Toasts/fieldErrors.js +25 -9
  103. package/dist/elements/Toasts/fieldErrors.js.map +1 -1
  104. package/dist/elements/Toasts/index.css +5 -0
  105. package/dist/elements/UnpublishMany/DrawerContent.d.ts +2 -1
  106. package/dist/elements/UnpublishMany/DrawerContent.d.ts.map +1 -1
  107. package/dist/elements/UnpublishMany/DrawerContent.js.map +1 -1
  108. package/dist/elements/UnpublishMany/index.d.ts +2 -4
  109. package/dist/elements/UnpublishMany/index.d.ts.map +1 -1
  110. package/dist/elements/UnpublishMany/index.js +0 -38
  111. package/dist/elements/UnpublishMany/index.js.map +1 -1
  112. package/dist/elements/UserMenu/LanguageMenu/index.js +1 -1
  113. package/dist/elements/UserMenu/LanguageMenu/index.js.map +1 -1
  114. package/dist/elements/UserMenu/SettingsMenu/index.d.ts +6 -2
  115. package/dist/elements/UserMenu/SettingsMenu/index.d.ts.map +1 -1
  116. package/dist/elements/UserMenu/SettingsMenu/index.js +15 -10
  117. package/dist/elements/UserMenu/SettingsMenu/index.js.map +1 -1
  118. package/dist/elements/UserMenu/ThemeMenu/index.js +1 -1
  119. package/dist/elements/UserMenu/ThemeMenu/index.js.map +1 -1
  120. package/dist/elements/UserMenu/index.d.ts +2 -1
  121. package/dist/elements/UserMenu/index.d.ts.map +1 -1
  122. package/dist/elements/UserMenu/index.js +8 -5
  123. package/dist/elements/UserMenu/index.js.map +1 -1
  124. package/dist/elements/WhereBuilder/Condition/index.d.ts +1 -0
  125. package/dist/elements/WhereBuilder/Condition/index.d.ts.map +1 -1
  126. package/dist/elements/WhereBuilder/Condition/index.js +17 -2
  127. package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
  128. package/dist/elements/WhereBuilder/index.d.ts +4 -3
  129. package/dist/elements/WhereBuilder/index.d.ts.map +1 -1
  130. package/dist/elements/WhereBuilder/index.js +71 -62
  131. package/dist/elements/WhereBuilder/index.js.map +1 -1
  132. package/dist/elements/WhereBuilder/types.d.ts +6 -5
  133. package/dist/elements/WhereBuilder/types.d.ts.map +1 -1
  134. package/dist/elements/WhereBuilder/types.js.map +1 -1
  135. package/dist/exports/client/index.d.ts +2 -0
  136. package/dist/exports/client/index.d.ts.map +1 -1
  137. package/dist/exports/client/index.js +26 -26
  138. package/dist/exports/client/index.js.map +4 -4
  139. package/dist/fields/RadioGroup/index.css +6 -0
  140. package/dist/icons/Check/index.css +1 -2
  141. package/dist/icons/Check/index.js +1 -1
  142. package/dist/icons/Check/index.js.map +1 -1
  143. package/dist/icons/Warning/index.css +1 -7
  144. package/dist/icons/Warning/index.d.ts +1 -1
  145. package/dist/icons/Warning/index.d.ts.map +1 -1
  146. package/dist/icons/Warning/index.js +11 -16
  147. package/dist/icons/Warning/index.js.map +1 -1
  148. package/dist/providers/ToastContainer/index.css +208 -0
  149. package/dist/providers/ToastContainer/index.d.ts +1 -0
  150. package/dist/providers/ToastContainer/index.d.ts.map +1 -1
  151. package/dist/providers/ToastContainer/index.js +19 -6
  152. package/dist/providers/ToastContainer/index.js.map +1 -1
  153. package/dist/scss/app.scss +7 -2
  154. package/dist/styles.css +1 -1
  155. package/dist/templates/Default/index.d.ts.map +1 -1
  156. package/dist/templates/Default/index.js +51 -9
  157. package/dist/templates/Default/index.js.map +1 -1
  158. package/dist/utilities/reduceFieldsToOptions.js +1 -1
  159. package/dist/utilities/reduceFieldsToOptions.js.map +1 -1
  160. package/dist/views/HierarchyList/DocumentListSelection/index.js +4 -4
  161. package/dist/views/HierarchyList/DocumentListSelection/index.js.map +1 -1
  162. package/dist/views/List/ListSelection/index.js +4 -4
  163. package/dist/views/List/ListSelection/index.js.map +1 -1
  164. package/dist/views/List/index.client.d.ts.map +1 -1
  165. package/dist/views/List/index.client.js +3 -3
  166. package/dist/views/List/index.client.js.map +1 -1
  167. package/dist/views/List/renderListViewSlots.d.ts.map +1 -1
  168. package/dist/views/List/renderListViewSlots.js +9 -6
  169. package/dist/views/List/renderListViewSlots.js.map +1 -1
  170. package/dist/views/Logout/LogoutClient.js +1 -1
  171. package/dist/views/Logout/LogoutClient.js.map +1 -1
  172. package/dist/views/Versions/index.css +0 -4
  173. package/package.json +5 -5
  174. package/dist/elements/ColumnSelector/index.d.ts +0 -9
  175. package/dist/elements/ColumnSelector/index.d.ts.map +0 -1
  176. package/dist/elements/ColumnSelector/index.js.map +0 -1
  177. package/dist/elements/ColumnsButton/index.d.ts +0 -7
  178. package/dist/elements/ColumnsButton/index.d.ts.map +0 -1
  179. package/dist/elements/ColumnsButton/index.js.map +0 -1
  180. package/dist/elements/GroupByBuilder/index.d.ts +0 -12
  181. package/dist/elements/GroupByBuilder/index.d.ts.map +0 -1
  182. package/dist/elements/GroupByBuilder/index.js +0 -164
  183. package/dist/elements/GroupByBuilder/index.js.map +0 -1
  184. package/dist/elements/GroupByBuilder/index.scss +0 -39
  185. package/dist/elements/GroupByControl/index.d.ts +0 -9
  186. package/dist/elements/GroupByControl/index.d.ts.map +0 -1
  187. package/dist/elements/GroupByControl/index.js +0 -254
  188. package/dist/elements/GroupByControl/index.js.map +0 -1
  189. package/dist/elements/QueryPresets/fields/ColumnsField/index.scss +0 -17
  190. package/dist/elements/QueryPresets/fields/GroupByField/index.scss +0 -17
  191. package/dist/elements/QueryPresets/fields/WhereField/index.scss +0 -23
  192. package/dist/scss/toasts.scss +0 -146
  193. /package/dist/elements/{ColumnSelector/index.css → ColumnSelection/Popup.css} +0 -0
  194. /package/dist/elements/{GroupByControl/index.css → GroupBy/Popup.css} +0 -0
@@ -1,16 +1,19 @@
1
1
  'use client';
2
2
 
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
- import React, { useId, useMemo } from 'react';
4
+ import { fieldIsHiddenOrDisabled, fieldIsID, flattenTopLevelFields } from 'payload/shared';
5
+ import React, { useMemo } from 'react';
5
6
  import { FieldLabel } from '../../../../fields/FieldLabel/index.js';
6
7
  import { useField } from '../../../../forms/useField/index.js';
7
8
  import { useAuth } from '../../../../providers/Auth/index.js';
8
9
  import { useConfig } from '../../../../providers/Config/index.js';
10
+ import { filterFieldsWithPermissions } from '../../../../providers/TableColumns/buildColumnState/filterFieldsWithPermissions.js';
11
+ import { isColumnActive } from '../../../../providers/TableColumns/buildColumnState/isColumnActive.js';
12
+ import { sortFieldMap } from '../../../../providers/TableColumns/buildColumnState/sortFieldMap.js';
9
13
  import { useTranslation } from '../../../../providers/Translation/index.js';
10
14
  import { getColumns } from '../../../../utilities/getColumns.js';
11
- import { reduceFieldsToOptions } from '../../../../utilities/reduceFieldsToOptions.js';
12
- import { PillSelector } from '../../../PillSelector/index.js';
13
- import './index.scss';
15
+ import { ColumnSelectionButton } from '../../../ColumnSelection/index.js';
16
+ import '../fields.css';
14
17
  export const QueryPresetsColumnField = ({
15
18
  field: {
16
19
  label,
@@ -36,11 +39,10 @@ export const QueryPresetsColumnField = ({
36
39
  const {
37
40
  permissions
38
41
  } = useAuth();
39
- const uuid = useId();
40
42
  const collectionConfig = useMemo(() => relatedCollection ? getEntityConfig({
41
43
  collectionSlug: relatedCollection
42
44
  }) : null, [relatedCollection, getEntityConfig]);
43
- const columns = useMemo(() => {
45
+ const columnPreferences = useMemo(() => {
44
46
  if (!relatedCollection || !collectionConfig) {
45
47
  return [];
46
48
  }
@@ -53,40 +55,74 @@ export const QueryPresetsColumnField = ({
53
55
  permissions
54
56
  });
55
57
  }, [config, collectionConfig, relatedCollection, value, i18n, permissions]);
56
- const reducedFields = useMemo(() => {
58
+ // Build the full column set from every field (active and inactive), mirroring the
59
+ // list view's `buildColumnState`, so columns absent from the saved preferences still
60
+ // appear in the selector. No cells are rendered here.
61
+ const columns = useMemo(() => {
57
62
  if (!collectionConfig?.fields) {
58
63
  return [];
59
64
  }
60
- return reduceFieldsToOptions({
61
- fieldPermissions: permissions?.collections?.[relatedCollection]?.fields ?? true,
62
- fields: collectionConfig.fields,
63
- i18n
65
+ const fieldPermissions = permissions?.collections?.[relatedCollection]?.fields ?? true;
66
+ let sortedFieldMap = flattenTopLevelFields(filterFieldsWithPermissions({
67
+ fieldPermissions,
68
+ fields: collectionConfig.fields
69
+ }), {
70
+ i18n,
71
+ keepPresentationalFields: true,
72
+ moveSubFieldsToTop: true
64
73
  });
65
- }, [collectionConfig, i18n, permissions, relatedCollection]);
66
- const accessorToLabel = useMemo(() => {
67
- const map = {};
68
- for (const f of reducedFields) {
69
- map[String(f.fieldPath)] = f.label;
74
+ // Place the `id` field first, then the `useAsTitle` field, matching the list view.
75
+ const idFieldIndex = sortedFieldMap.findIndex(field => fieldIsID(field));
76
+ if (idFieldIndex > -1) {
77
+ sortedFieldMap.unshift(sortedFieldMap.splice(idFieldIndex, 1)[0]);
70
78
  }
71
- return map;
72
- }, [reducedFields]);
73
- const pills = useMemo(() => columns.map((col, i) => ({
74
- name: col.accessor,
75
- key: `${relatedCollection}-${col.accessor}-${i}-${uuid}`,
76
- Label: accessorToLabel[col.accessor] ?? col.accessor,
77
- selected: col.active
78
- })), [accessorToLabel, columns, relatedCollection, uuid]);
79
- const currentColumns = value ?? columns;
80
- const handleClick = React.useCallback(({
81
- pill
82
- }) => {
83
- const newColumns = currentColumns.map(col_0 => col_0.accessor === pill.name ? {
84
- ...col_0,
85
- active: !col_0.active
86
- } : col_0);
87
- setValue(newColumns.length ? newColumns : undefined);
88
- }, [currentColumns, setValue]);
89
- if (!relatedCollection) {
79
+ const useAsTitle = collectionConfig.admin?.useAsTitle;
80
+ const useAsTitleFieldIndex = useAsTitle ? sortedFieldMap.findIndex(field_0 => 'name' in field_0 && field_0.name === useAsTitle) : -1;
81
+ if (useAsTitleFieldIndex > -1) {
82
+ sortedFieldMap.unshift(sortedFieldMap.splice(useAsTitleFieldIndex, 1)[0]);
83
+ }
84
+ sortedFieldMap = sortFieldMap(sortedFieldMap, columnPreferences);
85
+ const activeColumnsIndices = [];
86
+ return sortedFieldMap.reduce((acc, field_1, colIndex) => {
87
+ if (fieldIsHiddenOrDisabled(field_1) && !fieldIsID(field_1)) {
88
+ return acc;
89
+ }
90
+ // Groups render as their flattened subfields, not as a selectable column.
91
+ if (field_1.type === 'group') {
92
+ return acc;
93
+ }
94
+ const accessor = 'accessor' in field_1 ? field_1.accessor : 'name' in field_1 ? field_1.name : undefined;
95
+ if (!accessor) {
96
+ return acc;
97
+ }
98
+ const columnPref = columnPreferences.find(pref => pref.accessor === accessor);
99
+ const active = isColumnActive({
100
+ accessor,
101
+ activeColumnsIndices,
102
+ column: columnPref,
103
+ columns: columnPreferences
104
+ });
105
+ if (active) {
106
+ activeColumnsIndices.push(colIndex);
107
+ }
108
+ acc.push({
109
+ accessor,
110
+ active,
111
+ field: field_1,
112
+ Heading: null,
113
+ renderedCells: []
114
+ });
115
+ return acc;
116
+ }, []);
117
+ }, [collectionConfig, columnPreferences, i18n, permissions, relatedCollection]);
118
+ const handleChange = React.useCallback(newColumns => {
119
+ const preferences = newColumns.map(col => ({
120
+ accessor: col.accessor,
121
+ active: col.active
122
+ }));
123
+ setValue(preferences.length ? preferences : undefined);
124
+ }, [setValue]);
125
+ if (!relatedCollection || !collectionConfig) {
90
126
  return /*#__PURE__*/_jsxs("div", {
91
127
  className: "field-type query-preset-columns-field",
92
128
  children: [/*#__PURE__*/_jsx(FieldLabel, {
@@ -100,20 +136,13 @@ export const QueryPresetsColumnField = ({
100
136
  })]
101
137
  });
102
138
  }
103
- return /*#__PURE__*/_jsxs("div", {
139
+ return /*#__PURE__*/_jsx("div", {
104
140
  className: "field-type query-preset-columns-field",
105
- children: [/*#__PURE__*/_jsx(FieldLabel, {
106
- as: "h3",
107
- label: label,
108
- path: path,
109
- required: required
110
- }), pills.length > 0 ? /*#__PURE__*/_jsx(PillSelector, {
111
- onClick: handleClick,
112
- pills: pills
113
- }) : /*#__PURE__*/_jsx("p", {
114
- className: "query-preset-columns-field__hint",
115
- children: "No columns available for this collection."
116
- })]
141
+ children: /*#__PURE__*/_jsx(ColumnSelectionButton, {
142
+ collectionSlug: relatedCollection,
143
+ columns: columns,
144
+ onChange: handleChange
145
+ })
117
146
  });
118
147
  };
119
148
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","useId","useMemo","FieldLabel","useField","useAuth","useConfig","useTranslation","getColumns","reduceFieldsToOptions","PillSelector","QueryPresetsColumnField","field","label","required","path","setValue","value","relatedCollectionField","relatedCollection","config","getEntityConfig","i18n","permissions","uuid","collectionConfig","collectionSlug","columns","clientConfig","reducedFields","fields","fieldPermissions","collections","accessorToLabel","map","f","String","fieldPath","pills","col","i","name","accessor","key","Label","selected","active","currentColumns","handleClick","useCallback","pill","newColumns","length","undefined","_jsxs","className","_jsx","as","onClick"],"sources":["../../../../../src/elements/QueryPresets/fields/ColumnsField/index.tsx"],"sourcesContent":["'use client'\nimport type { ColumnPreference, JSONFieldClientComponent } from 'payload'\n\nimport React, { useId, useMemo } from 'react'\n\nimport { FieldLabel } from '../../../../fields/FieldLabel/index.js'\nimport { useField } from '../../../../forms/useField/index.js'\nimport { useAuth } from '../../../../providers/Auth/index.js'\nimport { useConfig } from '../../../../providers/Config/index.js'\nimport { useTranslation } from '../../../../providers/Translation/index.js'\nimport { getColumns } from '../../../../utilities/getColumns.js'\nimport { reduceFieldsToOptions } from '../../../../utilities/reduceFieldsToOptions.js'\nimport { PillSelector, type SelectablePill } from '../../../PillSelector/index.js'\nimport './index.scss'\n\nexport const QueryPresetsColumnField: JSONFieldClientComponent = ({\n field: { label, required },\n}) => {\n const { path, setValue, value } = useField<ColumnPreference[]>()\n const relatedCollectionField = useField({ path: 'relatedCollection' })\n const relatedCollection = relatedCollectionField.value as string | undefined\n const { config, getEntityConfig } = useConfig()\n const { i18n } = useTranslation()\n const { permissions } = useAuth()\n const uuid = useId()\n\n const collectionConfig = useMemo(\n () => (relatedCollection ? getEntityConfig({ collectionSlug: relatedCollection }) : null),\n [relatedCollection, getEntityConfig],\n )\n\n const columns = useMemo(() => {\n if (!relatedCollection || !collectionConfig) {\n return []\n }\n return getColumns({\n clientConfig: config,\n collectionConfig,\n collectionSlug: relatedCollection,\n columns: value ?? [],\n i18n,\n permissions,\n })\n }, [config, collectionConfig, relatedCollection, value, i18n, permissions])\n\n const reducedFields = useMemo(() => {\n if (!collectionConfig?.fields) {\n return []\n }\n return reduceFieldsToOptions({\n fieldPermissions: permissions?.collections?.[relatedCollection]?.fields ?? true,\n fields: collectionConfig.fields,\n i18n,\n })\n }, [collectionConfig, i18n, permissions, relatedCollection])\n\n const accessorToLabel = useMemo(() => {\n const map: Record<string, React.ReactNode> = {}\n for (const f of reducedFields) {\n map[String(f.fieldPath)] = f.label\n }\n return map\n }, [reducedFields])\n\n const pills: SelectablePill[] = useMemo(\n () =>\n columns.map((col, i) => ({\n name: col.accessor,\n key: `${relatedCollection}-${col.accessor}-${i}-${uuid}`,\n Label: accessorToLabel[col.accessor] ?? col.accessor,\n selected: col.active,\n })),\n [accessorToLabel, columns, relatedCollection, uuid],\n )\n\n const currentColumns = value ?? columns\n\n const handleClick = React.useCallback(\n ({ pill }: { pill: SelectablePill }) => {\n const newColumns = currentColumns.map((col) =>\n col.accessor === pill.name ? { ...col, active: !col.active } : col,\n )\n setValue(newColumns.length ? newColumns : undefined)\n },\n [currentColumns, setValue],\n )\n\n if (!relatedCollection) {\n return (\n <div className=\"field-type query-preset-columns-field\">\n <FieldLabel as=\"h3\" label={label} path={path} required={required} />\n <p className=\"query-preset-columns-field__hint\">\n Select the related collection to configure columns.\n </p>\n </div>\n )\n }\n\n return (\n <div className=\"field-type query-preset-columns-field\">\n <FieldLabel as=\"h3\" label={label} path={path} required={required} />\n {pills.length > 0 ? (\n <PillSelector onClick={handleClick} pills={pills} />\n ) : (\n <p className=\"query-preset-columns-field__hint\">\n No columns available for this collection.\n </p>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,OAAOA,KAAA,IAASC,KAAK,EAAEC,OAAO,QAAQ;AAEtC,SAASC,UAAU,QAAQ;AAC3B,SAASC,QAAQ,QAAQ;AACzB,SAASC,OAAO,QAAQ;AACxB,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,YAAY,QAA6B;AAClD,OAAO;AAEP,OAAO,MAAMC,uBAAA,GAAoDA,CAAC;EAChEC,KAAA,EAAO;IAAEC,KAAK;IAAEC;EAAQ;AAAE,CAC3B;EACC,MAAM;IAAEC,IAAI;IAAEC,QAAQ;IAAEC;EAAK,CAAE,GAAGb,QAAA;EAClC,MAAMc,sBAAA,GAAyBd,QAAA,CAAS;IAAEW,IAAA,EAAM;EAAoB;EACpE,MAAMI,iBAAA,GAAoBD,sBAAA,CAAuBD,KAAK;EACtD,MAAM;IAAEG,MAAM;IAAEC;EAAe,CAAE,GAAGf,SAAA;EACpC,MAAM;IAAEgB;EAAI,CAAE,GAAGf,cAAA;EACjB,MAAM;IAAEgB;EAAW,CAAE,GAAGlB,OAAA;EACxB,MAAMmB,IAAA,GAAOvB,KAAA;EAEb,MAAMwB,gBAAA,GAAmBvB,OAAA,CACvB,MAAOiB,iBAAA,GAAoBE,eAAA,CAAgB;IAAEK,cAAA,EAAgBP;EAAkB,KAAK,MACpF,CAACA,iBAAA,EAAmBE,eAAA,CAAgB;EAGtC,MAAMM,OAAA,GAAUzB,OAAA,CAAQ;IACtB,IAAI,CAAC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enOrDisabled","fieldIsID","flattenTopLevelFields","React","useMemo","FieldLabel","useField","useAuth","useConfig","filterFieldsWithPermissions","isColumnActive","sortFieldMap","useTranslation","getColumns","ColumnSelectionButton","QueryPresetsColumnField","field","label","required","path","setValue","value","relatedCollectionField","relatedCollection","config","getEntityConfig","i18n","permissions","collectionConfig","collectionSlug","columnPreferences","clientConfig","columns","fields","fieldPermissions","collections","sortedFieldMap","keepPresentationalFields","moveSubFieldsToTop","idFieldIndex","findIndex","unshift","splice","useAsTitle","admin","useAsTitleFieldIndex","name","activeColumnsIndices","reduce","acc","colIndex","type","accessor","undefined","columnPref","find","pref","active","column","push","Heading","renderedCells","handleChange","useCallback","newColumns","preferences","map","col","length","_jsxs","className","_jsx","as","onChange"],"sources":["../../../../../src/elements/QueryPresets/fields/ColumnsField/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientField, Column, ColumnPreference, JSONFieldClientComponent } from 'payload'\n\nimport { fieldIsHiddenOrDisabled, fieldIsID, flattenTopLevelFields } from 'payload/shared'\nimport React, { useMemo } from 'react'\n\nimport { FieldLabel } from '../../../../fields/FieldLabel/index.js'\nimport { useField } from '../../../../forms/useField/index.js'\nimport { useAuth } from '../../../../providers/Auth/index.js'\nimport { useConfig } from '../../../../providers/Config/index.js'\nimport { filterFieldsWithPermissions } from '../../../../providers/TableColumns/buildColumnState/filterFieldsWithPermissions.js'\nimport { isColumnActive } from '../../../../providers/TableColumns/buildColumnState/isColumnActive.js'\nimport { sortFieldMap } from '../../../../providers/TableColumns/buildColumnState/sortFieldMap.js'\nimport { useTranslation } from '../../../../providers/Translation/index.js'\nimport { getColumns } from '../../../../utilities/getColumns.js'\nimport { ColumnSelectionButton } from '../../../ColumnSelection/index.js'\nimport '../fields.css'\n\nexport const QueryPresetsColumnField: JSONFieldClientComponent = ({\n field: { label, required },\n}) => {\n const { path, setValue, value } = useField<ColumnPreference[]>()\n const relatedCollectionField = useField({ path: 'relatedCollection' })\n const relatedCollection = relatedCollectionField.value as string | undefined\n const { config, getEntityConfig } = useConfig()\n const { i18n } = useTranslation()\n const { permissions } = useAuth()\n\n const collectionConfig = useMemo(\n () => (relatedCollection ? getEntityConfig({ collectionSlug: relatedCollection }) : null),\n [relatedCollection, getEntityConfig],\n )\n\n const columnPreferences = useMemo(() => {\n if (!relatedCollection || !collectionConfig) {\n return []\n }\n return getColumns({\n clientConfig: config,\n collectionConfig,\n collectionSlug: relatedCollection,\n columns: value ?? [],\n i18n,\n permissions,\n })\n }, [config, collectionConfig, relatedCollection, value, i18n, permissions])\n\n // Build the full column set from every field (active and inactive), mirroring the\n // list view's `buildColumnState`, so columns absent from the saved preferences still\n // appear in the selector. No cells are rendered here.\n const columns: Column[] = useMemo(() => {\n if (!collectionConfig?.fields) {\n return []\n }\n\n const fieldPermissions = permissions?.collections?.[relatedCollection]?.fields ?? true\n\n let sortedFieldMap = flattenTopLevelFields(\n filterFieldsWithPermissions({ fieldPermissions, fields: collectionConfig.fields }),\n {\n i18n,\n keepPresentationalFields: true,\n moveSubFieldsToTop: true,\n },\n ) as ClientField[]\n\n // Place the `id` field first, then the `useAsTitle` field, matching the list view.\n const idFieldIndex = sortedFieldMap.findIndex((field) => fieldIsID(field))\n if (idFieldIndex > -1) {\n sortedFieldMap.unshift(sortedFieldMap.splice(idFieldIndex, 1)[0])\n }\n\n const useAsTitle = collectionConfig.admin?.useAsTitle\n const useAsTitleFieldIndex = useAsTitle\n ? sortedFieldMap.findIndex((field) => 'name' in field && field.name === useAsTitle)\n : -1\n if (useAsTitleFieldIndex > -1) {\n sortedFieldMap.unshift(sortedFieldMap.splice(useAsTitleFieldIndex, 1)[0])\n }\n\n sortedFieldMap = sortFieldMap(sortedFieldMap, columnPreferences)\n\n const activeColumnsIndices: number[] = []\n\n return sortedFieldMap.reduce<Column[]>((acc, field, colIndex) => {\n if (fieldIsHiddenOrDisabled(field) && !fieldIsID(field)) {\n return acc\n }\n\n // Groups render as their flattened subfields, not as a selectable column.\n if (field.type === 'group') {\n return acc\n }\n\n const accessor =\n 'accessor' in field\n ? (field as { accessor: string }).accessor\n : 'name' in field\n ? field.name\n : undefined\n\n if (!accessor) {\n return acc\n }\n\n const columnPref = columnPreferences.find((pref) => pref.accessor === accessor)\n const active = isColumnActive({\n accessor,\n activeColumnsIndices,\n column: columnPref,\n columns: columnPreferences,\n })\n\n if (active) {\n activeColumnsIndices.push(colIndex)\n }\n\n acc.push({\n accessor,\n active,\n field,\n Heading: null,\n renderedCells: [],\n })\n\n return acc\n }, [])\n }, [collectionConfig, columnPreferences, i18n, permissions, relatedCollection])\n\n const handleChange = React.useCallback(\n (newColumns: Column[]) => {\n const preferences: ColumnPreference[] = newColumns.map((col) => ({\n accessor: col.accessor,\n active: col.active,\n }))\n setValue(preferences.length ? preferences : undefined)\n },\n [setValue],\n )\n\n if (!relatedCollection || !collectionConfig) {\n return (\n <div className=\"field-type query-preset-columns-field\">\n <FieldLabel as=\"h3\" label={label} path={path} required={required} />\n <p className=\"query-preset-columns-field__hint\">\n Select the related collection to configure columns.\n </p>\n </div>\n )\n }\n\n return (\n <div className=\"field-type query-preset-columns-field\">\n <ColumnSelectionButton\n collectionSlug={relatedCollection}\n columns={columns}\n onChange={handleChange}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,uBAAuB,EAAEC,SAAS,EAAEC,qBAAqB,QAAQ;AAC1E,OAAOC,KAAA,IAASC,OAAO,QAAQ;AAE/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,QAAQ,QAAQ;AACzB,SAASC,OAAO,QAAQ;AACxB,SAASC,SAAS,QAAQ;AAC1B,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,OAAO;AAEP,OAAO,MAAMC,uBAAA,GAAoDA,CAAC;EAChEC,KAAA,EAAO;IAAEC,KAAK;IAA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AAIlB","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  import type { TextFieldClientComponent } from 'payload';
2
- import './index.scss';
2
+ import '../fields.css';
3
3
  export declare const QueryPresetsGroupByField: TextFieldClientComponent;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/QueryPresets/fields/GroupByField/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAQvD,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,wBAAwB,EAAE,wBAuCtC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/QueryPresets/fields/GroupByField/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAQvD,OAAO,eAAe,CAAA;AAEtB,eAAO,MAAM,wBAAwB,EAAE,wBAkCtC,CAAA"}
@@ -5,8 +5,8 @@ import React, { useMemo } from 'react';
5
5
  import { FieldLabel } from '../../../../fields/FieldLabel/index.js';
6
6
  import { useField } from '../../../../forms/useField/index.js';
7
7
  import { useConfig } from '../../../../providers/Config/index.js';
8
- import { GroupByBuilder } from '../../../GroupByBuilder/index.js';
9
- import './index.scss';
8
+ import { GroupByButton } from '../../../GroupBy/index.js';
9
+ import '../fields.css';
10
10
  export const QueryPresetsGroupByField = ({
11
11
  field: {
12
12
  label,
@@ -23,16 +23,12 @@ export const QueryPresetsGroupByField = ({
23
23
  });
24
24
  const relatedCollection = relatedCollectionField.value;
25
25
  const {
26
- config
26
+ getEntityConfig
27
27
  } = useConfig();
28
- const collectionConfig = useMemo(() => {
29
- if (!relatedCollection) {
30
- return null;
31
- }
32
- return config.collections?.find(col => col.slug === relatedCollection);
33
- }, [relatedCollection, config.collections]);
34
- const fields = collectionConfig?.fields ?? [];
35
- if (!relatedCollection) {
28
+ const collectionConfig = useMemo(() => relatedCollection ? getEntityConfig({
29
+ collectionSlug: relatedCollection
30
+ }) : null, [relatedCollection, getEntityConfig]);
31
+ if (!relatedCollection || !collectionConfig) {
36
32
  return /*#__PURE__*/_jsxs("div", {
37
33
  className: "field-type query-preset-group-by-field",
38
34
  children: [/*#__PURE__*/_jsx(FieldLabel, {
@@ -46,19 +42,14 @@ export const QueryPresetsGroupByField = ({
46
42
  })]
47
43
  });
48
44
  }
49
- return /*#__PURE__*/_jsxs("div", {
45
+ return /*#__PURE__*/_jsx("div", {
50
46
  className: "field-type query-preset-group-by-field",
51
- children: [/*#__PURE__*/_jsx(FieldLabel, {
52
- as: "h3",
53
- label: label,
54
- path: path,
55
- required: required
56
- }), /*#__PURE__*/_jsx(GroupByBuilder, {
47
+ children: /*#__PURE__*/_jsx(GroupByButton, {
57
48
  collectionSlug: relatedCollection,
58
- fields: fields,
49
+ fields: collectionConfig.fields,
59
50
  onChange: groupBy => setValue(groupBy || null),
60
- value: value ?? undefined
61
- })]
51
+ value: value ?? ''
52
+ })
62
53
  });
63
54
  };
64
55
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","useMemo","FieldLabel","useField","useConfig","GroupByBuilder","QueryPresetsGroupByField","field","label","required","path","setValue","value","relatedCollectionField","relatedCollection","config","collectionConfig","collections","find","col","slug","fields","_jsxs","className","_jsx","as","collectionSlug","onChange","groupBy","undefined"],"sources":["../../../../../src/elements/QueryPresets/fields/GroupByField/index.tsx"],"sourcesContent":["'use client'\nimport type { TextFieldClientComponent } from 'payload'\n\nimport React, { useMemo } from 'react'\n\nimport { FieldLabel } from '../../../../fields/FieldLabel/index.js'\nimport { useField } from '../../../../forms/useField/index.js'\nimport { useConfig } from '../../../../providers/Config/index.js'\nimport { GroupByBuilder } from '../../../GroupByBuilder/index.js'\nimport './index.scss'\n\nexport const QueryPresetsGroupByField: TextFieldClientComponent = ({\n field: { label, required },\n}) => {\n const { path, setValue, value } = useField<string>()\n const relatedCollectionField = useField({ path: 'relatedCollection' })\n const relatedCollection = relatedCollectionField.value as string | undefined\n const { config } = useConfig()\n\n const collectionConfig = useMemo(() => {\n if (!relatedCollection) {\n return null\n }\n return config.collections?.find((col) => col.slug === relatedCollection)\n }, [relatedCollection, config.collections])\n\n const fields = collectionConfig?.fields ?? []\n\n if (!relatedCollection) {\n return (\n <div className=\"field-type query-preset-group-by-field\">\n <FieldLabel as=\"h3\" label={label} path={path} required={required} />\n <p className=\"query-preset-group-by-field__hint\">\n Select the related collection to configure group by.\n </p>\n </div>\n )\n }\n\n return (\n <div className=\"field-type query-preset-group-by-field\">\n <FieldLabel as=\"h3\" label={label} path={path} required={required} />\n <GroupByBuilder\n collectionSlug={relatedCollection}\n fields={fields}\n onChange={(groupBy) => setValue(groupBy || null)}\n value={value ?? undefined}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,OAAOA,KAAA,IAASC,OAAO,QAAQ;AAE/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,QAAQ,QAAQ;AACzB,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAEP,OAAO,MAAMC,wBAAA,GAAqDA,CAAC;EACjEC,KAAA,EAAO;IAAEC,KAAK;IAAEC;EAAQ;AAAE,CAC3B;EACC,MAAM;IAAEC,IAAI;IAAEC,QAAQ;IAAEC;EAAK,CAAE,GAAGT,QAAA;EAClC,MAAMU,sBAAA,GAAyBV,QAAA,CAAS;IAAEO,IAAA,EAAM;EAAoB;EACpE,MAAMI,iBAAA,GAAoBD,sBAAA,CAAuBD,KAAK;EACtD,MAAM;IAAEG;EAAM,CAAE,GAAGX,SAAA;EAEnB,MAAMY,gBAAA,GAAmBf,OAAA,CAAQ;IAC/B,IAAI,CAACa,iBAAA,EAAmB;MACtB,OAAO;IACT;IACA,OAAOC,MAAA,CAAOE,WAAW,EAAEC,IAAA,CAAMC,GAAA,IAAQA,GAAA,CAAIC,IAAI,KAAKN,iBAAA;EACxD,GAAG,CAACA,iBAAA,EAAmBC,MAAA,CAAOE,WAAW,CAAC;EAE1C,MAAMI,MAAA,GAASL,gBAAA,EAAkBK,MAAA,IAAU,EAAE;EAE7C,IAAI,CAACP,iBAAA,EAAmB;IACtB,oBACEQ,KAAA,CAAC;MAAIC,SAAA,EAAU;8BACbC,IAAA,CAACtB,UAAA;QAAWuB,EAAA,EAAG;QAAKjB,KAAA,EAAOA,KAAA;QAAOE,IAAA,EAAMA,IAAA;QAAMD,QAAA,EAAUA;uBACxDe,IAAA,CAAC;QAAED,SAAA,EAAU;kBAAoC;;;EAKvD;EAEA,oBACED,KAAA,CAAC;IAAIC,SAAA,EAAU;4BACbC,IAAA,CAACtB,UAAA;MAAWuB,EAAA,EAAG;MAAKjB,KAAA,EAAOA,KAAA;MAAOE,IAAA,EAAMA,IAAA;MAAMD,QAAA,EAAUA;qBACxDe,IAAA,CAACnB,cAAA;MACCqB,cAAA,EAAgBZ,iBAAA;MAChBO,MAAA,EAAQA,MAAA;MACRM,QAAA,EAAWC,OAAA,IAAYjB,QAAA,CAASiB,OAAA,IAAW;MAC3ChB,KAAA,EAAOA,KAAA,IAASiB;;;AAIxB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["React","useMemo","FieldLabel","useField","useConfig","GroupByButton","QueryPresetsGroupByField","field","label","required","path","setValue","value","relatedCollectionField","relatedCollection","getEntityConfig","collectionConfig","collectionSlug","_jsxs","className","_jsx","as","fields","onChange","groupBy"],"sources":["../../../../../src/elements/QueryPresets/fields/GroupByField/index.tsx"],"sourcesContent":["'use client'\nimport type { TextFieldClientComponent } from 'payload'\n\nimport React, { useMemo } from 'react'\n\nimport { FieldLabel } from '../../../../fields/FieldLabel/index.js'\nimport { useField } from '../../../../forms/useField/index.js'\nimport { useConfig } from '../../../../providers/Config/index.js'\nimport { GroupByButton } from '../../../GroupBy/index.js'\nimport '../fields.css'\n\nexport const QueryPresetsGroupByField: TextFieldClientComponent = ({\n field: { label, required },\n}) => {\n const { path, setValue, value } = useField<string>()\n const relatedCollectionField = useField({ path: 'relatedCollection' })\n const relatedCollection = relatedCollectionField.value as string | undefined\n const { getEntityConfig } = useConfig()\n\n const collectionConfig = useMemo(\n () => (relatedCollection ? getEntityConfig({ collectionSlug: relatedCollection }) : null),\n [relatedCollection, getEntityConfig],\n )\n\n if (!relatedCollection || !collectionConfig) {\n return (\n <div className=\"field-type query-preset-group-by-field\">\n <FieldLabel as=\"h3\" label={label} path={path} required={required} />\n <p className=\"query-preset-group-by-field__hint\">\n Select the related collection to configure group by.\n </p>\n </div>\n )\n }\n\n return (\n <div className=\"field-type query-preset-group-by-field\">\n <GroupByButton\n collectionSlug={relatedCollection}\n fields={collectionConfig.fields}\n onChange={(groupBy) => setValue(groupBy || null)}\n value={value ?? ''}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,OAAOA,KAAA,IAASC,OAAO,QAAQ;AAE/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,QAAQ,QAAQ;AACzB,SAASC,SAAS,QAAQ;AAC1B,SAASC,aAAa,QAAQ;AAC9B,OAAO;AAEP,OAAO,MAAMC,wBAAA,GAAqDA,CAAC;EACjEC,KAAA,EAAO;IAAEC,KAAK;IAAEC;EAAQ;AAAE,CAC3B;EACC,MAAM;IAAEC,IAAI;IAAEC,QAAQ;IAAEC;EAAK,CAAE,GAAGT,QAAA;EAClC,MAAMU,sBAAA,GAAyBV,QAAA,CAAS;IAAEO,IAAA,EAAM;EAAoB;EACpE,MAAMI,iBAAA,GAAoBD,sBAAA,CAAuBD,KAAK;EACtD,MAAM;IAAEG;EAAe,CAAE,GAAGX,SAAA;EAE5B,MAAMY,gBAAA,GAAmBf,OAAA,CACvB,MAAOa,iBAAA,GAAoBC,eAAA,CAAgB;IAAEE,cAAA,EAAgBH;EAAkB,KAAK,MACpF,CAACA,iBAAA,EAAmBC,eAAA,CAAgB;EAGtC,IAAI,CAACD,iBAAA,IAAqB,CAACE,gBAAA,EAAkB;IAC3C,oBACEE,KAAA,CAAC;MAAIC,SAAA,EAAU;8BACbC,IAAA,CAAClB,UAAA;QAAWmB,EAAA,EAAG;QAAKb,KAAA,EAAOA,KAAA;QAAOE,IAAA,EAAMA,IAAA;QAAMD,QAAA,EAAUA;uBACxDW,IAAA,CAAC;QAAED,SAAA,EAAU;kBAAoC;;;EAKvD;EAEA,oBACEC,IAAA,CAAC;IAAID,SAAA,EAAU;cACb,aAAAC,IAAA,CAACf,aAAA;MACCY,cAAA,EAAgBH,iBAAA;MAChBQ,MAAA,EAAQN,gBAAA,CAAiBM,MAAM;MAC/BC,QAAA,EAAWC,OAAA,IAAYb,QAAA,CAASa,OAAA,IAAW;MAC3CZ,KAAA,EAAOA,KAAA,IAAS;;;AAIxB","ignoreList":[]}
@@ -0,0 +1,52 @@
1
+ @layer payload-default {
2
+ .query-preset-heading {
3
+ margin: var(--spacer-4) 0 var(--spacer-2-5);
4
+ color: var(--color-text);
5
+ font-family: var(--text-heading-medium-font-family);
6
+ font-size: var(--text-heading-medium-font-size);
7
+ font-weight: var(--text-heading-medium-font-weight);
8
+ line-height: var(--text-heading-medium-line-height);
9
+ }
10
+
11
+ .field-type.row.query-preset-controls-row {
12
+ /* Match the standalone headings' top spacing so sections stay aligned. */
13
+ margin-top: var(--spacer-4);
14
+
15
+ .row__fields {
16
+ align-items: center;
17
+ column-gap: var(--spacer-2);
18
+ flex-wrap: nowrap;
19
+
20
+ /* Size controls to their content and drop Row's inline margins so the last
21
+ one aligns with the right edge. Matches Row's `:has` selector to win on
22
+ mobile, where Row's media-query reset has too little specificity. */
23
+ &:has(> *:nth-child(2)) {
24
+ margin-inline: 0;
25
+
26
+ > * {
27
+ flex: 0 0 auto;
28
+ margin-inline: 0;
29
+ /* Clamp against Row's mobile `width: 100% !important`. */
30
+ max-width: fit-content;
31
+ }
32
+ }
33
+
34
+ /* Stay in a row on mobile, where Row otherwise stacks into a column. */
35
+ @media (max-width: 1024px) {
36
+ flex-direction: row;
37
+ }
38
+ }
39
+
40
+ /* The heading absorbs the free space to push the controls to the right edge;
41
+ the row owns the top spacing, so collapse the heading's own block margins. */
42
+ .row__fields:has(> *:nth-child(2)) > .query-preset-heading {
43
+ margin-block: 0;
44
+ margin-inline-end: auto;
45
+ }
46
+ }
47
+
48
+ /* The Access heading provides the separation, so hide the group's top border. */
49
+ .query-preset-access-group.group-field--top-level::before {
50
+ display: none;
51
+ }
52
+ }
@@ -0,0 +1,7 @@
1
+ import type { ClientTranslationKeys } from '@payloadcms/translations';
2
+ import React from 'react';
3
+ import './index.css';
4
+ export declare const QueryPresetsHeading: React.FC<{
5
+ i18nKey?: ClientTranslationKeys;
6
+ }>;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/QueryPresets/fields/Heading/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAErE,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,aAAa,CAAA;AAEpB,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,OAAO,CAAC,EAAE,qBAAqB,CAAA;CAAE,CAM7E,CAAA"}
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import React from 'react';
6
+ import { useTranslation } from '../../../../providers/Translation/index.js';
7
+ import './index.css';
8
+ export const QueryPresetsHeading = t0 => {
9
+ const $ = _c(3);
10
+ const {
11
+ i18nKey: t1
12
+ } = t0;
13
+ const i18nKey = t1 === undefined ? "general:presets" : t1;
14
+ const {
15
+ t
16
+ } = useTranslation();
17
+ let t2;
18
+ if ($[0] !== i18nKey || $[1] !== t) {
19
+ t2 = _jsx("h3", {
20
+ className: "query-preset-heading",
21
+ children: t(i18nKey)
22
+ });
23
+ $[0] = i18nKey;
24
+ $[1] = t;
25
+ $[2] = t2;
26
+ } else {
27
+ t2 = $[2];
28
+ }
29
+ return t2;
30
+ };
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["c","_c","React","useTranslation","QueryPresetsHeading","t0","$","i18nKey","t1","undefined","t","t2","_jsx","className","children"],"sources":["../../../../../src/elements/QueryPresets/fields/Heading/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientTranslationKeys } from '@payloadcms/translations'\n\nimport React from 'react'\n\nimport { useTranslation } from '../../../../providers/Translation/index.js'\nimport './index.css'\n\nexport const QueryPresetsHeading: React.FC<{ i18nKey?: ClientTranslationKeys }> = ({\n i18nKey = 'general:presets',\n}) => {\n const { t } = useTranslation()\n\n return <h3 className=\"query-preset-heading\">{t(i18nKey)}</h3>\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,OAAOC,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAEP,OAAO,MAAMC,mBAAA,GAAqEC,EAAA;EAAA,MAAAC,CAAA,GAAAL,EAAA;EAAC;IAAAM,OAAA,EAAAC;EAAA,IAAAH,EAElF;EADC,MAAAE,OAAA,GAAAC,EAA2B,KAAAC,SAAA,GAAjB,iBAAiB,GAA3BD,EAA2B;EAE3B;IAAAE;EAAA,IAAcP,cAAA;EAAA,IAAAQ,EAAA;EAAA,IAAAL,CAAA,QAAAC,OAAA,IAAAD,CAAA,QAAAI,CAAA;IAEPC,EAAA,GAAAC,IAAA,CAAC;MAAAC,SAAA,EAAa;MAAAC,QAAA,EAAwBJ,CAAA,CAAEH,OAAA;IAAA,C;;;;;;;SAAxCI,E;CACT","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  import type { JSONFieldClientComponent } from 'payload';
2
- import './index.scss';
2
+ import '../fields.css';
3
3
  export declare const QueryPresetsWhereField: JSONFieldClientComponent;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/QueryPresets/fields/WhereField/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAS,MAAM,SAAS,CAAA;AAO9D,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,sBAAsB,EAAE,wBA4BpC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/QueryPresets/fields/WhereField/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAS,MAAM,SAAS,CAAA;AAQ9D,OAAO,eAAe,CAAA;AAEtB,eAAO,MAAM,sBAAsB,EAAE,wBA+BpC,CAAA"}
@@ -5,10 +5,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
5
  import React from 'react';
6
6
  import { FieldLabel } from '../../../../fields/FieldLabel/index.js';
7
7
  import { useField } from '../../../../forms/useField/index.js';
8
+ import { useConfig } from '../../../../providers/Config/index.js';
8
9
  import { WhereBuilder } from '../../../WhereBuilder/index.js';
9
- import './index.scss';
10
+ import '../fields.css';
10
11
  export const QueryPresetsWhereField = t0 => {
11
- const $ = _c(14);
12
+ const $ = _c(12);
12
13
  const {
13
14
  field: t1
14
15
  } = t0;
@@ -32,6 +33,9 @@ export const QueryPresetsWhereField = t0 => {
32
33
  }
33
34
  const relatedCollectionField = useField(t2);
34
35
  const relatedCollection = relatedCollectionField.value;
36
+ const {
37
+ getEntityConfig
38
+ } = useConfig();
35
39
  if (!relatedCollection) {
36
40
  let t3;
37
41
  if ($[1] !== label || $[2] !== path || $[3] !== required) {
@@ -57,37 +61,34 @@ export const QueryPresetsWhereField = t0 => {
57
61
  return t3;
58
62
  }
59
63
  let t3;
60
- if ($[5] !== label || $[6] !== path || $[7] !== relatedCollection || $[8] !== required || $[9] !== setValue || $[10] !== value) {
64
+ if ($[5] !== getEntityConfig || $[6] !== relatedCollection || $[7] !== setValue || $[8] !== value) {
65
+ const collectionConfig = getEntityConfig({
66
+ collectionSlug: relatedCollection
67
+ });
61
68
  let t4;
62
- if ($[12] !== setValue) {
69
+ if ($[10] !== setValue) {
63
70
  t4 = where => setValue(where);
64
- $[12] = setValue;
65
- $[13] = t4;
71
+ $[10] = setValue;
72
+ $[11] = t4;
66
73
  } else {
67
- t4 = $[13];
74
+ t4 = $[11];
68
75
  }
69
- t3 = _jsxs("div", {
76
+ t3 = _jsx("div", {
70
77
  className: "field-type query-preset-where-field",
71
- children: [_jsx(FieldLabel, {
72
- as: "h3",
73
- label,
74
- path,
75
- required
76
- }), _jsx(WhereBuilder, {
78
+ children: _jsx(WhereBuilder, {
77
79
  collectionSlug: relatedCollection,
80
+ fields: collectionConfig?.fields ?? [],
78
81
  onChange: t4,
79
82
  value: value ?? undefined
80
- })]
83
+ })
81
84
  });
82
- $[5] = label;
83
- $[6] = path;
84
- $[7] = relatedCollection;
85
- $[8] = required;
86
- $[9] = setValue;
87
- $[10] = value;
88
- $[11] = t3;
85
+ $[5] = getEntityConfig;
86
+ $[6] = relatedCollection;
87
+ $[7] = setValue;
88
+ $[8] = value;
89
+ $[9] = t3;
89
90
  } else {
90
- t3 = $[11];
91
+ t3 = $[9];
91
92
  }
92
93
  return t3;
93
94
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","React","FieldLabel","useField","WhereBuilder","QueryPresetsWhereField","t0","$","field","t1","label","required","path","setValue","value","t2","Symbol","for","relatedCollectionField","relatedCollection","t3","_jsxs","className","children","_jsx","as","t4","where","collectionSlug","onChange","undefined"],"sources":["../../../../../src/elements/QueryPresets/fields/WhereField/index.tsx"],"sourcesContent":["'use client'\nimport type { JSONFieldClientComponent, Where } from 'payload'\n\nimport React from 'react'\n\nimport { FieldLabel } from '../../../../fields/FieldLabel/index.js'\nimport { useField } from '../../../../forms/useField/index.js'\nimport { WhereBuilder } from '../../../WhereBuilder/index.js'\nimport './index.scss'\n\nexport const QueryPresetsWhereField: JSONFieldClientComponent = ({\n field: { label, required },\n}) => {\n const { path, setValue, value } = useField<Where>()\n const relatedCollectionField = useField({ path: 'relatedCollection' })\n const relatedCollection = relatedCollectionField.value as string | undefined\n\n if (!relatedCollection) {\n return (\n <div className=\"field-type query-preset-where-field\">\n <FieldLabel as=\"h3\" label={label} path={path} required={required} />\n <p className=\"query-preset-where-field__hint\">\n Select the related collection to configure filters.\n </p>\n </div>\n )\n }\n\n return (\n <div className=\"field-type query-preset-where-field\">\n <FieldLabel as=\"h3\" label={label} path={path} required={required} />\n <WhereBuilder\n collectionSlug={relatedCollection}\n onChange={(where) => setValue(where)}\n value={value ?? undefined}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,OAAOC,KAAA,MAAW;AAElB,SAASC,UAAU,QAAQ;AAC3B,SAASC,QAAQ,QAAQ;AACzB,SAASC,YAAY,QAAQ;AAC7B,OAAO;AAEP,OAAO,MAAMC,sBAAA,GAAmDC,EAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EAAC;IAAAQ,KAAA,EAAAC;EAAA,IAAAH,EAEhE;EADQ;IAAAI,KAAA;IAAAC;EAAA,IAAAF,EAAmB;EAE1B;IAAAG,IAAA;IAAAC,QAAA;IAAAC;EAAA,IAAkCX,QAAA;EAAA,IAAAY,EAAA;EAAA,IAAAR,CAAA,QAAAS,MAAA,CAAAC,GAAA;IACMF,EAAA;MAAAH,IAAA,EAAQ;IAAA;IAAoBL,CAAA,MAAAQ,EAAA;EAAA;IAAAA,EAAA,GAAAR,CAAA;EAAA;EAApE,MAAAW,sBAAA,GAA+Bf,QAAA,CAASY,EAA4B;EACpE,MAAAI,iBAAA,GAA0BD,sBAAA,CAAAJ,KAAA;EAA4B,KAEjDK,iBAAA;IAAA,IAAAC,EAAA;IAAA,IAAAb,CAAA,QAAAG,KAAA,IAAAH,CAAA,QAAAK,IAAA,IAAAL,CAAA,QAAAI,QAAA;MAEDS,EAAA,GAAAC,KAAA,CAAC;QAAAC,SAAA,EAAc;QAAAC,QAAA,GACbC,IAAA,CAAAtB,UAAA;UAAAuB,EAAA,EAAe;UAAAf,KAAA;UAAAE,IAAA;UAAAD;QAAA,C,GACfa,IAAA,CAAC;UAAAF,SAAA,EAAY;UAAAC,QAAA,EAAiC;QAAA,C;;;;;;;;;WAFhDH,E;;;;;;MAcYM,EAAA,GAAAC,KAAA,IAAWd,QAAA,CAASc,KAAA;MAAApB,CAAA,OAAAM,QAAA;MAAAN,CAAA,OAAAmB,EAAA;IAAA;MAAAA,EAAA,GAAAnB,CAAA;IAAA;IAJlCa,EAAA,GAAAC,KAAA,CAAC;MAAAC,SAAA,EAAc;MAAAC,QAAA,GACbC,IAAA,CAAAtB,UAAA;QAAAuB,EAAA,EAAe;QAAAf,KAAA;QAAAE,IAAA;QAAAD;MAAA,C,GACfa,IAAA,CAAApB,YAAA;QAAAwB,cAAA,EACkBT,iBAAA;QAAAU,QAAA,EACNH,EAAoB;QAAAZ,KAAA,EACvBA,KAAA,IAAAgB;MAAS,C;;;;;;;;;;;;SALpBV,E;CASJ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","React","FieldLabel","useField","useConfig","WhereBuilder","QueryPresetsWhereField","t0","$","field","t1","label","required","path","setValue","value","t2","Symbol","for","relatedCollectionField","relatedCollection","getEntityConfig","t3","_jsxs","className","children","_jsx","as","collectionConfig","collectionSlug","t4","where","fields","onChange","undefined"],"sources":["../../../../../src/elements/QueryPresets/fields/WhereField/index.tsx"],"sourcesContent":["'use client'\nimport type { JSONFieldClientComponent, Where } from 'payload'\n\nimport React from 'react'\n\nimport { FieldLabel } from '../../../../fields/FieldLabel/index.js'\nimport { useField } from '../../../../forms/useField/index.js'\nimport { useConfig } from '../../../../providers/Config/index.js'\nimport { WhereBuilder } from '../../../WhereBuilder/index.js'\nimport '../fields.css'\n\nexport const QueryPresetsWhereField: JSONFieldClientComponent = ({\n field: { label, required },\n}) => {\n const { path, setValue, value } = useField<Where>()\n const relatedCollectionField = useField({ path: 'relatedCollection' })\n const relatedCollection = relatedCollectionField.value as string | undefined\n const { getEntityConfig } = useConfig()\n\n if (!relatedCollection) {\n return (\n <div className=\"field-type query-preset-where-field\">\n <FieldLabel as=\"h3\" label={label} path={path} required={required} />\n <p className=\"query-preset-where-field__hint\">\n Select the related collection to configure filters.\n </p>\n </div>\n )\n }\n\n const collectionConfig = getEntityConfig({ collectionSlug: relatedCollection })\n\n return (\n <div className=\"field-type query-preset-where-field\">\n <WhereBuilder\n collectionSlug={relatedCollection}\n fields={collectionConfig?.fields ?? []}\n onChange={(where) => setValue(where)}\n value={value ?? undefined}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,OAAOC,KAAA,MAAW;AAElB,SAASC,UAAU,QAAQ;AAC3B,SAASC,QAAQ,QAAQ;AACzB,SAASC,SAAS,QAAQ;AAC1B,SAASC,YAAY,QAAQ;AAC7B,OAAO;AAEP,OAAO,MAAMC,sBAAA,GAAmDC,EAAA;EAAA,MAAAC,CAAA,GAAAR,EAAA;EAAC;IAAAS,KAAA,EAAAC;EAAA,IAAAH,EAEhE;EADQ;IAAAI,KAAA;IAAAC;EAAA,IAAAF,EAAmB;EAE1B;IAAAG,IAAA;IAAAC,QAAA;IAAAC;EAAA,IAAkCZ,QAAA;EAAA,IAAAa,EAAA;EAAA,IAAAR,CAAA,QAAAS,MAAA,CAAAC,GAAA;IACMF,EAAA;MAAAH,IAAA,EAAQ;IAAA;IAAoBL,CAAA,MAAAQ,EAAA;EAAA;IAAAA,EAAA,GAAAR,CAAA;EAAA;EAApE,MAAAW,sBAAA,GAA+BhB,QAAA,CAASa,EAA4B;EACpE,MAAAI,iBAAA,GAA0BD,sBAAA,CAAAJ,KAAA;EAC1B;IAAAM;EAAA,IAA4BjB,SAAA;EAAA,KAEvBgB,iBAAA;IAAA,IAAAE,EAAA;IAAA,IAAAd,CAAA,QAAAG,KAAA,IAAAH,CAAA,QAAAK,IAAA,IAAAL,CAAA,QAAAI,QAAA;MAEDU,EAAA,GAAAC,KAAA,CAAC;QAAAC,SAAA,EAAc;QAAAC,QAAA,GACbC,IAAA,CAAAxB,UAAA;UAAAyB,EAAA,EAAe;UAAAhB,KAAA;UAAAE,IAAA;UAAAD;QAAA,C,GACfc,IAAA,CAAC;UAAAF,SAAA,EAAY;UAAAC,QAAA,EAAiC;QAAA,C;;;;;;;;;WAFhDH,E;;;;IASJ,MAAAM,gBAAA,GAAyBP,eAAA;MAAAQ,cAAA,EAAkCT;IAAA,CAAkB;IAAA,IAAAU,EAAA;IAAA,IAAAtB,CAAA,SAAAM,QAAA;MAO7DgB,EAAA,GAAAC,KAAA,IAAWjB,QAAA,CAASiB,KAAA;MAAAvB,CAAA,OAAAM,QAAA;MAAAN,CAAA,OAAAsB,EAAA;IAAA;MAAAA,EAAA,GAAAtB,CAAA;IAAA;IAJlCc,EAAA,GAAAI,IAAA,CAAC;MAAAF,SAAA,EAAc;MAAAC,QAAA,EACbC,IAAA,CAAArB,YAAA;QAAAwB,cAAA,EACkBT,iBAAA;QAAAY,MAAA,EACRJ,gBAAA,EAAAI,MAAA,MAA8B;QAAAC,QAAA,EAC5BH,EAAoB;QAAAf,KAAA,EACvBA,KAAA,IAAAmB;MAAS,C;;;;;;;;;;SALpBZ,E;CASJ","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ @layer payload-default {
2
+ .query-preset-columns-field,
3
+ .query-preset-group-by-field,
4
+ .query-preset-where-field {
5
+ .field-label {
6
+ margin-bottom: var(--spacer-2);
7
+ }
8
+ }
9
+
10
+ .query-preset-columns-field__hint,
11
+ .query-preset-group-by-field__hint,
12
+ .query-preset-where-field__hint {
13
+ margin: 0;
14
+ color: var(--color-text-secondary);
15
+ }
16
+
17
+ /* The builder sits inline within the form here, so drop the list-panel chrome
18
+ (border + gutter padding) it carries in the list view. */
19
+ .query-preset-where-field .where-builder {
20
+ padding: 0;
21
+ border-bottom: none;
22
+ }
23
+ }
@@ -0,0 +1,5 @@
1
+ export declare const getCaptureMenuScroll: ({ captureMenuScroll, menuPortalTarget: _menuPortalTarget, }: {
2
+ captureMenuScroll?: boolean;
3
+ menuPortalTarget?: HTMLElement | null;
4
+ }) => boolean;
5
+ //# sourceMappingURL=getCaptureMenuScroll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCaptureMenuScroll.d.ts","sourceRoot":"","sources":["../../../src/elements/ReactSelect/getCaptureMenuScroll.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,GAAI,6DAGlC;IACD,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,gBAAgB,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;CACtC,KAAG,OAMH,CAAA"}
@@ -0,0 +1,10 @@
1
+ export const getCaptureMenuScroll = ({
2
+ captureMenuScroll,
3
+ menuPortalTarget: _menuPortalTarget
4
+ }) => {
5
+ if (typeof captureMenuScroll === 'boolean') {
6
+ return captureMenuScroll;
7
+ }
8
+ return true;
9
+ };
10
+ //# sourceMappingURL=getCaptureMenuScroll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCaptureMenuScroll.js","names":["getCaptureMenuScroll","captureMenuScroll","menuPortalTarget","_menuPortalTarget"],"sources":["../../../src/elements/ReactSelect/getCaptureMenuScroll.ts"],"sourcesContent":["export const getCaptureMenuScroll = ({\n captureMenuScroll,\n menuPortalTarget: _menuPortalTarget,\n}: {\n captureMenuScroll?: boolean\n menuPortalTarget?: HTMLElement | null\n}): boolean => {\n if (typeof captureMenuScroll === 'boolean') {\n return captureMenuScroll\n }\n\n return true\n}\n"],"mappings":"AAAA,OAAO,MAAMA,oBAAA,GAAuBA,CAAC;EACnCC,iBAAiB;EACjBC,gBAAA,EAAkBC;AAAiB,CAIpC;EACC,IAAI,OAAOF,iBAAA,KAAsB,WAAW;IAC1C,OAAOA,iBAAA;EACT;EAEA,OAAO;AACT","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { GroupBase, StylesConfig } from 'react-select';
2
+ import type { Option } from './types.js';
3
+ type MenuListStyles = NonNullable<StylesConfig<Option, boolean, GroupBase<Option>>['menuList']>;
4
+ export declare const getMenuListStyles: (externalStyles?: StylesConfig<Option, boolean, GroupBase<Option>>) => MenuListStyles;
5
+ export {};
6
+ //# sourceMappingURL=getMenuListStyles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMenuListStyles.d.ts","sourceRoot":"","sources":["../../../src/elements/ReactSelect/getMenuListStyles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExC,KAAK,cAAc,GAAG,WAAW,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;AAE/F,eAAO,MAAM,iBAAiB,GAC5B,iBAAiB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,KAChE,cAQF,CAAA"}
@@ -0,0 +1,7 @@
1
+ export const getMenuListStyles = externalStyles => {
2
+ return (rsStyles, state) => ({
3
+ ...rsStyles,
4
+ ...externalStyles?.menuList?.(rsStyles, state)
5
+ });
6
+ };
7
+ //# sourceMappingURL=getMenuListStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMenuListStyles.js","names":["getMenuListStyles","externalStyles","rsStyles","state","menuList"],"sources":["../../../src/elements/ReactSelect/getMenuListStyles.ts"],"sourcesContent":["import type { CSSObjectWithLabel, GroupBase, StylesConfig } from 'react-select'\n\nimport type { Option } from './types.js'\n\ntype MenuListStyles = NonNullable<StylesConfig<Option, boolean, GroupBase<Option>>['menuList']>\n\nexport const getMenuListStyles = (\n externalStyles?: StylesConfig<Option, boolean, GroupBase<Option>>,\n): MenuListStyles => {\n return (\n rsStyles: CSSObjectWithLabel,\n state: Parameters<NonNullable<StylesConfig<Option>['menuList']>>[1],\n ) => ({\n ...rsStyles,\n ...externalStyles?.menuList?.(rsStyles, state),\n })\n}\n"],"mappings":"AAMA,OAAO,MAAMA,iBAAA,GACXC,cAAA;EAEA,OAAO,CACLC,QAAA,EACAC,KAAA,MACI;IACJ,GAAGD,QAAQ;IACX,GAAGD,cAAA,EAAgBG,QAAA,GAAWF,QAAA,EAAUC,KAAA;EAC1C;AACF","ignoreList":[]}
@@ -103,7 +103,6 @@
103
103
  }
104
104
 
105
105
  .rs__menu-list {
106
- max-height: calc(var(--spacer-6) * 5);
107
106
  overflow-y: auto;
108
107
  }
109
108
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/ReactSelect/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAA2B,MAAM,OAAO,CAAA;AAI/C,OAAO,KAAK,EAAU,uBAAuB,EAAE,MAAM,YAAY,CAAA;AACjE,YAAY,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAgBxC,OAAO,aAAa,CAAA;AAgTpB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAQzD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/ReactSelect/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAQN,MAAM,OAAO,CAAA;AAId,OAAO,KAAK,EAAU,uBAAuB,EAAE,MAAM,YAAY,CAAA;AACjE,YAAY,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAkBxC,OAAO,aAAa,CAAA;AA4VpB,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAQzD,CAAA"}