@payloadcms/ui 3.23.0-canary.fa36283 → 3.24.0-canary.10637cd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/ListControls/index.d.ts +2 -1
- package/dist/elements/ListControls/index.d.ts.map +1 -1
- package/dist/elements/ListControls/index.js +6 -4
- package/dist/elements/ListControls/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Blocks/index.d.ts.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/Blocks/index.js +12 -4
- package/dist/elements/Table/DefaultCell/fields/Blocks/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/index.js.map +1 -1
- package/dist/elements/ViewDescription/index.d.ts +0 -1
- package/dist/elements/ViewDescription/index.d.ts.map +1 -1
- package/dist/elements/ViewDescription/index.js +1 -2
- package/dist/elements/ViewDescription/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/DefaultFilter/index.d.ts +4 -3
- package/dist/elements/WhereBuilder/Condition/DefaultFilter/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/DefaultFilter/index.js +3 -0
- package/dist/elements/WhereBuilder/Condition/DefaultFilter/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/index.js +63 -43
- package/dist/elements/WhereBuilder/Condition/Relationship/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/types.d.ts +2 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/types.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Relationship/types.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Select/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Select/index.js +2 -0
- package/dist/elements/WhereBuilder/Condition/Select/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Select/types.d.ts +1 -0
- package/dist/elements/WhereBuilder/Condition/Select/types.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Select/types.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.d.ts +7 -17
- package/dist/elements/WhereBuilder/Condition/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js +116 -276
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/types.d.ts +2 -2
- package/dist/elements/WhereBuilder/Condition/types.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/types.js.map +1 -1
- package/dist/elements/WhereBuilder/field-types.d.ts +1 -92
- package/dist/elements/WhereBuilder/field-types.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/field-types.js.map +1 -1
- package/dist/elements/WhereBuilder/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/index.js +171 -260
- package/dist/elements/WhereBuilder/index.js.map +1 -1
- package/dist/elements/WhereBuilder/{reduceClientFields.d.ts → reduceFields.d.ts} +5 -4
- package/dist/elements/WhereBuilder/reduceFields.d.ts.map +1 -0
- package/dist/elements/WhereBuilder/{reduceClientFields.js → reduceFields.js} +8 -8
- package/dist/elements/WhereBuilder/reduceFields.js.map +1 -0
- package/dist/elements/WhereBuilder/types.d.ts +17 -3
- package/dist/elements/WhereBuilder/types.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/types.js.map +1 -1
- package/dist/elements/WhereBuilder/validateWhereQuery.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/validateWhereQuery.js.map +1 -1
- package/dist/exports/client/{CodeEditor-BMYVMDNZ.js → CodeEditor-G3Y4UHC4.js} +2 -2
- package/dist/exports/client/chunk-4L367VSB.js +26 -0
- package/dist/exports/client/{chunk-CQQHQHCB.js.map → chunk-4L367VSB.js.map} +3 -3
- package/dist/exports/client/index.js +11 -11
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/rsc/index.d.ts +1 -0
- package/dist/exports/rsc/index.d.ts.map +1 -1
- package/dist/exports/rsc/index.js +1 -0
- package/dist/exports/rsc/index.js.map +1 -1
- package/dist/fields/Blocks/BlockRow.d.ts +1 -1
- package/dist/fields/Blocks/BlockRow.d.ts.map +1 -1
- package/dist/fields/Blocks/BlockRow.js.map +1 -1
- package/dist/fields/Blocks/BlocksDrawer/index.d.ts +1 -1
- package/dist/fields/Blocks/BlocksDrawer/index.d.ts.map +1 -1
- package/dist/fields/Blocks/BlocksDrawer/index.js +31 -23
- package/dist/fields/Blocks/BlocksDrawer/index.js.map +1 -1
- package/dist/fields/Blocks/RowActions.d.ts +1 -1
- package/dist/fields/Blocks/RowActions.d.ts.map +1 -1
- package/dist/fields/Blocks/RowActions.js.map +1 -1
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +6 -4
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Join/index.d.ts.map +1 -1
- package/dist/fields/Join/index.js +9 -2
- package/dist/fields/Join/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +4 -3
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.js +1 -1
- package/dist/forms/fieldSchemasToFormState/calculateDefaultValues/promise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +2 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/providers/Config/index.d.ts +2 -2
- package/dist/providers/Config/index.d.ts.map +1 -1
- package/dist/providers/Config/index.js +17 -2
- package/dist/providers/Config/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.d.ts.map +1 -1
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js +3 -1
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/traverseFields.js +4 -1
- package/dist/utilities/buildFieldSchemaMap/traverseFields.js.map +1 -1
- package/dist/utilities/copyDataFromLocale.d.ts.map +1 -1
- package/dist/utilities/copyDataFromLocale.js +13 -15
- package/dist/utilities/copyDataFromLocale.js.map +1 -1
- package/dist/utilities/getClientConfig.js.map +1 -1
- package/dist/utilities/renderTable.d.ts.map +1 -1
- package/dist/utilities/renderTable.js +37 -0
- package/dist/utilities/renderTable.js.map +1 -1
- package/dist/utilities/resolveFilterOptions.d.ts +5 -0
- package/dist/utilities/resolveFilterOptions.d.ts.map +1 -0
- package/dist/{forms/fieldSchemasToFormState/getFilterOptionsQuery.js → utilities/resolveFilterOptions.js} +2 -2
- package/dist/utilities/resolveFilterOptions.js.map +1 -0
- package/dist/views/List/index.d.ts +2 -1
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +3 -1
- package/dist/views/List/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/elements/ViewDescription/index.scss +0 -7
- package/dist/elements/WhereBuilder/reduceClientFields.d.ts.map +0 -1
- package/dist/elements/WhereBuilder/reduceClientFields.js.map +0 -1
- package/dist/exports/client/chunk-CQQHQHCB.js +0 -26
- package/dist/forms/fieldSchemasToFormState/getFilterOptionsQuery.d.ts +0 -7
- package/dist/forms/fieldSchemasToFormState/getFilterOptionsQuery.d.ts.map +0 -1
- package/dist/forms/fieldSchemasToFormState/getFilterOptionsQuery.js.map +0 -1
- /package/dist/exports/client/{CodeEditor-BMYVMDNZ.js.map → CodeEditor-G3Y4UHC4.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClientCollectionConfig, Where } from 'payload';
|
|
1
|
+
import type { ClientCollectionConfig, ResolvedFilterOptions, Where } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import './index.scss';
|
|
4
4
|
export type ListControlsProps = {
|
|
@@ -13,6 +13,7 @@ export type ListControlsProps = {
|
|
|
13
13
|
readonly handleSortChange?: (sort: string) => void;
|
|
14
14
|
readonly handleWhereChange?: (where: Where) => void;
|
|
15
15
|
readonly renderedFilters?: Map<string, React.ReactNode>;
|
|
16
|
+
readonly resolvedFilterOptions?: Map<string, ResolvedFilterOptions>;
|
|
16
17
|
};
|
|
17
18
|
/**
|
|
18
19
|
* The ListControls component is used to render the controls (search, filter, where)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/ListControls/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/ListControls/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAInF,OAAO,KAAgD,MAAM,OAAO,CAAA;AAkBpE,OAAO,cAAc,CAAA;AAIrB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAA;IAC1C,QAAQ,CAAC,gBAAgB,EAAE,sBAAsB,CAAA;IACjD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IACpC,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAA;IAClC,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAA;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACtD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAClD,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IACnD,QAAQ,CAAC,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;IACvD,QAAQ,CAAC,qBAAqB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAA;CACpE,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA8LpD,CAAA"}
|
|
@@ -19,8 +19,8 @@ import { SearchFilter } from '../SearchFilter/index.js';
|
|
|
19
19
|
import { UnpublishMany } from '../UnpublishMany/index.js';
|
|
20
20
|
import { WhereBuilder } from '../WhereBuilder/index.js';
|
|
21
21
|
import validateWhereQuery from '../WhereBuilder/validateWhereQuery.js';
|
|
22
|
-
import './index.scss';
|
|
23
22
|
import { getTextFieldsToBeSearched } from './getTextFieldsToBeSearched.js';
|
|
23
|
+
import './index.scss';
|
|
24
24
|
const baseClass = 'list-controls';
|
|
25
25
|
/**
|
|
26
26
|
* The ListControls component is used to render the controls (search, filter, where)
|
|
@@ -36,7 +36,8 @@ export const ListControls = props => {
|
|
|
36
36
|
disableBulkEdit,
|
|
37
37
|
enableColumns = true,
|
|
38
38
|
enableSort = false,
|
|
39
|
-
renderedFilters
|
|
39
|
+
renderedFilters,
|
|
40
|
+
resolvedFilterOptions
|
|
40
41
|
} = props;
|
|
41
42
|
const {
|
|
42
43
|
handleSearchChange,
|
|
@@ -161,8 +162,9 @@ export const ListControls = props => {
|
|
|
161
162
|
collectionPluralLabel: collectionConfig?.labels?.plural,
|
|
162
163
|
collectionSlug: collectionConfig.slug,
|
|
163
164
|
fields: collectionConfig?.fields,
|
|
164
|
-
renderedFilters: renderedFilters
|
|
165
|
-
|
|
165
|
+
renderedFilters: renderedFilters,
|
|
166
|
+
resolvedFilterOptions: resolvedFilterOptions
|
|
167
|
+
})
|
|
166
168
|
}), enableSort && /*#__PURE__*/_jsx(AnimateHeight, {
|
|
167
169
|
className: `${baseClass}__sort`,
|
|
168
170
|
height: visibleDrawer === 'sort' ? 'auto' : 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useWindowInfo","getTranslation","React","Fragment","useEffect","useRef","useState","useUseTitleField","ChevronIcon","SearchIcon","useListQuery","useTranslation","AnimateHeight","ColumnSelector","DeleteMany","EditMany","Pill","PublishMany","SearchFilter","UnpublishMany","WhereBuilder","validateWhereQuery","getTextFieldsToBeSearched","baseClass","ListControls","props","beforeActions","collectionConfig","collectionSlug","disableBulkDelete","disableBulkEdit","enableColumns","enableSort","renderedFilters","handleSearchChange","query","titleField","i18n","t","breakpoints","s","smallBreak","searchLabel","label","name","listSearchableFields","admin","fields","searchLabelTranslated","hasWhereParam","Boolean","where","shouldInitializeWhereOpened","visibleDrawer","setVisibleDrawer","undefined","current","length","reduce","placeholderText","field","i","_jsxs","className","_jsx","fieldName","handleChange","search","initialParams","collection","icon","direction","onClick","pillStyle","height","id","slug","collectionPluralLabel","labels","plural","String"],"sources":["../../../src/elements/ListControls/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig, Where } from 'payload'\n\nimport { useWindowInfo } from '@faceless-ui/window-info'\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { Fragment, useEffect, useRef, useState } from 'react'\n\nimport { useUseTitleField } from '../../hooks/useUseAsTitle.js'\nimport { ChevronIcon } from '../../icons/Chevron/index.js'\nimport { SearchIcon } from '../../icons/Search/index.js'\nimport { useListQuery } from '../../providers/ListQuery/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { AnimateHeight } from '../AnimateHeight/index.js'\nimport { ColumnSelector } from '../ColumnSelector/index.js'\nimport { DeleteMany } from '../DeleteMany/index.js'\nimport { EditMany } from '../EditMany/index.js'\nimport { Pill } from '../Pill/index.js'\nimport { PublishMany } from '../PublishMany/index.js'\nimport { SearchFilter } from '../SearchFilter/index.js'\nimport { UnpublishMany } from '../UnpublishMany/index.js'\nimport { WhereBuilder } from '../WhereBuilder/index.js'\nimport validateWhereQuery from '../WhereBuilder/validateWhereQuery.js'\nimport './index.scss'\nimport { getTextFieldsToBeSearched } from './getTextFieldsToBeSearched.js'\n\nconst baseClass = 'list-controls'\n\nexport type ListControlsProps = {\n readonly beforeActions?: React.ReactNode[]\n readonly collectionConfig: ClientCollectionConfig\n readonly collectionSlug: string\n readonly disableBulkDelete?: boolean\n readonly disableBulkEdit?: boolean\n readonly enableColumns?: boolean\n readonly enableSort?: boolean\n readonly handleSearchChange?: (search: string) => void\n readonly handleSortChange?: (sort: string) => void\n readonly handleWhereChange?: (where: Where) => void\n readonly renderedFilters?: Map<string, React.ReactNode>\n}\n\n/**\n * The ListControls component is used to render the controls (search, filter, where)\n * for a collection's list view. You can find those directly above the table which lists\n * the collection's documents.\n */\nexport const ListControls: React.FC<ListControlsProps> = (props) => {\n const {\n beforeActions,\n collectionConfig,\n collectionSlug,\n disableBulkDelete,\n disableBulkEdit,\n enableColumns = true,\n enableSort = false,\n renderedFilters,\n } = props\n\n const { handleSearchChange, query } = useListQuery()\n const titleField = useUseTitleField(collectionConfig)\n const { i18n, t } = useTranslation()\n const {\n breakpoints: { s: smallBreak },\n } = useWindowInfo()\n\n const searchLabel =\n (titleField &&\n getTranslation(\n 'label' in titleField && typeof titleField.label === 'string'\n ? titleField.label\n : 'name' in titleField\n ? titleField.name\n : null,\n i18n,\n )) ??\n 'ID'\n\n const listSearchableFields = getTextFieldsToBeSearched(\n collectionConfig.admin.listSearchableFields,\n collectionConfig.fields,\n )\n\n const searchLabelTranslated = useRef(\n t('general:searchBy', { label: getTranslation(searchLabel, i18n) }),\n )\n\n const hasWhereParam = useRef(Boolean(query?.where))\n\n const shouldInitializeWhereOpened = validateWhereQuery(query?.where)\n const [visibleDrawer, setVisibleDrawer] = useState<'columns' | 'sort' | 'where'>(\n shouldInitializeWhereOpened ? 'where' : undefined,\n )\n\n useEffect(() => {\n if (hasWhereParam.current && !query?.where) {\n hasWhereParam.current = false\n } else if (query?.where) {\n hasWhereParam.current = true\n }\n }, [setVisibleDrawer, query?.where])\n\n useEffect(() => {\n if (listSearchableFields?.length > 0) {\n searchLabelTranslated.current = listSearchableFields.reduce(\n (placeholderText: string, field, i: number) => {\n const label =\n 'label' in field && field.label ? field.label : 'name' in field ? field.name : null\n\n if (i === 0) {\n return `${t('general:searchBy', {\n label: getTranslation(label, i18n),\n })}`\n }\n\n if (i === listSearchableFields.length - 1) {\n return `${placeholderText} ${t('general:or')} ${getTranslation(label, i18n)}`\n }\n\n return `${placeholderText}, ${getTranslation(label, i18n)}`\n },\n '',\n )\n } else {\n searchLabelTranslated.current = t('general:searchBy', {\n label: getTranslation(searchLabel, i18n),\n })\n }\n }, [t, listSearchableFields, i18n, searchLabel])\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <SearchIcon />\n <SearchFilter\n fieldName={titleField && 'name' in titleField ? titleField?.name : null}\n handleChange={(search) => {\n return void handleSearchChange(search)\n }}\n // @ts-expect-error @todo: fix types\n initialParams={query}\n key={collectionSlug}\n label={searchLabelTranslated.current}\n />\n <div className={`${baseClass}__buttons`}>\n <div className={`${baseClass}__buttons-wrap`}>\n {!smallBreak && (\n <React.Fragment>\n {beforeActions && beforeActions}\n {!disableBulkEdit && (\n <Fragment>\n <EditMany collection={collectionConfig} />\n <PublishMany collection={collectionConfig} />\n <UnpublishMany collection={collectionConfig} />\n </Fragment>\n )}\n {!disableBulkDelete && <DeleteMany collection={collectionConfig} />}\n </React.Fragment>\n )}\n {enableColumns && (\n <Pill\n aria-controls={`${baseClass}-columns`}\n aria-expanded={visibleDrawer === 'columns'}\n className={`${baseClass}__toggle-columns`}\n icon={<ChevronIcon direction={visibleDrawer === 'columns' ? 'up' : 'down'} />}\n onClick={() =>\n setVisibleDrawer(visibleDrawer !== 'columns' ? 'columns' : undefined)\n }\n pillStyle=\"light\"\n >\n {t('general:columns')}\n </Pill>\n )}\n <Pill\n aria-controls={`${baseClass}-where`}\n aria-expanded={visibleDrawer === 'where'}\n className={`${baseClass}__toggle-where`}\n icon={<ChevronIcon direction={visibleDrawer === 'where' ? 'up' : 'down'} />}\n onClick={() => setVisibleDrawer(visibleDrawer !== 'where' ? 'where' : undefined)}\n pillStyle=\"light\"\n >\n {t('general:filters')}\n </Pill>\n {enableSort && (\n <Pill\n aria-controls={`${baseClass}-sort`}\n aria-expanded={visibleDrawer === 'sort'}\n className={`${baseClass}__toggle-sort`}\n icon={<ChevronIcon />}\n onClick={() => setVisibleDrawer(visibleDrawer !== 'sort' ? 'sort' : undefined)}\n pillStyle=\"light\"\n >\n {t('general:sort')}\n </Pill>\n )}\n </div>\n </div>\n </div>\n {enableColumns && (\n <AnimateHeight\n className={`${baseClass}__columns`}\n height={visibleDrawer === 'columns' ? 'auto' : 0}\n id={`${baseClass}-columns`}\n >\n <ColumnSelector collectionSlug={collectionConfig.slug} />\n </AnimateHeight>\n )}\n <AnimateHeight\n className={`${baseClass}__where`}\n height={visibleDrawer === 'where' ? 'auto' : 0}\n id={`${baseClass}-where`}\n >\n <WhereBuilder\n collectionPluralLabel={collectionConfig?.labels?.plural}\n collectionSlug={collectionConfig.slug}\n fields={collectionConfig?.fields}\n key={String(hasWhereParam.current && !query?.where)}\n renderedFilters={renderedFilters}\n />\n </AnimateHeight>\n {enableSort && (\n <AnimateHeight\n className={`${baseClass}__sort`}\n height={visibleDrawer === 'sort' ? 'auto' : 0}\n id={`${baseClass}-sort`}\n >\n <p>Sort Complex</p>\n {/* <SortComplex\n collection={collection}\n handleChange={handleSortChange}\n modifySearchQuery={modifySearchQuery}\n /> */}\n </AnimateHeight>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ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AAGxC,SAAA,WAAoB;MAClCmD,MAAA,EAAQrB,aAAA,KAAkB,YAAY,SAAS;MAC/CsB,EAAA,EAAI,GAAGpD,SAAA,UAAmB;gBAE1B,aAAAyC,IAAA,CAACnD,cAAA;QAAee,cAAA,EAAgBD,gBAAA,CAAiBiD;;qBAGrDZ,IAAA,CAACpD,aAAA;MACCmD,SAAA,EAAW,GAAGxC,SAAA,SAAkB;MAChCmD,MAAA,EAAQrB,aAAA,KAAkB,UAAU,SAAS;MAC7CsB,EAAA,EAAI,GAAGpD,SAAA,QAAiB;gBAExB,aAAAyC,IAAA,CAAC5C,YAAA;QACCyD,qBAAA,EAAuBlD,gBAAA,EAAkBmD,MAAA,EAAQC,MAAA;QACjDnD,cAAA,EAAgBD,gBAAA,CAAiBiD,IAAI;QACrC7B,MAAA,EAAQpB,gBAAA,EAAkBoB,MAAA;QAE1Bd,eAAA,EAAiBA;SADZ+C,MAAA,CAAO/B,aAAA,CAAcO,OAAO,IAAI,CAACrB,KAAA,EAAOgB,KAAA;QAIhDnB,UAAA,iBACCgC,IAAA,CAACpD,aAAA;MACCmD,SAAA,EAAW,GAAGxC,SAAA,QAAiB;MAC/BmD,MAAA,EAAQrB,aAAA,KAAkB,SAAS,SAAS;MAC5CsB,EAAA,EAAI,GAAGpD,SAAA,OAAgB;gBAEvB,aAAAyC,IAAA,CAAC;kBAAE;;;;AAUb","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useWindowInfo","getTranslation","React","Fragment","useEffect","useRef","useState","useUseTitleField","ChevronIcon","SearchIcon","useListQuery","useTranslation","AnimateHeight","ColumnSelector","DeleteMany","EditMany","Pill","PublishMany","SearchFilter","UnpublishMany","WhereBuilder","validateWhereQuery","getTextFieldsToBeSearched","baseClass","ListControls","props","beforeActions","collectionConfig","collectionSlug","disableBulkDelete","disableBulkEdit","enableColumns","enableSort","renderedFilters","resolvedFilterOptions","handleSearchChange","query","titleField","i18n","t","breakpoints","s","smallBreak","searchLabel","label","name","listSearchableFields","admin","fields","searchLabelTranslated","hasWhereParam","Boolean","where","shouldInitializeWhereOpened","visibleDrawer","setVisibleDrawer","undefined","current","length","reduce","placeholderText","field","i","_jsxs","className","_jsx","fieldName","handleChange","search","initialParams","collection","icon","direction","onClick","pillStyle","height","id","slug","collectionPluralLabel","labels","plural"],"sources":["../../../src/elements/ListControls/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig, ResolvedFilterOptions, Where } from 'payload'\n\nimport { useWindowInfo } from '@faceless-ui/window-info'\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { Fragment, useEffect, useRef, useState } from 'react'\n\nimport { useUseTitleField } from '../../hooks/useUseAsTitle.js'\nimport { ChevronIcon } from '../../icons/Chevron/index.js'\nimport { SearchIcon } from '../../icons/Search/index.js'\nimport { useListQuery } from '../../providers/ListQuery/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { AnimateHeight } from '../AnimateHeight/index.js'\nimport { ColumnSelector } from '../ColumnSelector/index.js'\nimport { DeleteMany } from '../DeleteMany/index.js'\nimport { EditMany } from '../EditMany/index.js'\nimport { Pill } from '../Pill/index.js'\nimport { PublishMany } from '../PublishMany/index.js'\nimport { SearchFilter } from '../SearchFilter/index.js'\nimport { UnpublishMany } from '../UnpublishMany/index.js'\nimport { WhereBuilder } from '../WhereBuilder/index.js'\nimport validateWhereQuery from '../WhereBuilder/validateWhereQuery.js'\nimport { getTextFieldsToBeSearched } from './getTextFieldsToBeSearched.js'\nimport './index.scss'\n\nconst baseClass = 'list-controls'\n\nexport type ListControlsProps = {\n readonly beforeActions?: React.ReactNode[]\n readonly collectionConfig: ClientCollectionConfig\n readonly collectionSlug: string\n readonly disableBulkDelete?: boolean\n readonly disableBulkEdit?: boolean\n readonly enableColumns?: boolean\n readonly enableSort?: boolean\n readonly handleSearchChange?: (search: string) => void\n readonly handleSortChange?: (sort: string) => void\n readonly handleWhereChange?: (where: Where) => void\n readonly renderedFilters?: Map<string, React.ReactNode>\n readonly resolvedFilterOptions?: Map<string, ResolvedFilterOptions>\n}\n\n/**\n * The ListControls component is used to render the controls (search, filter, where)\n * for a collection's list view. You can find those directly above the table which lists\n * the collection's documents.\n */\nexport const ListControls: React.FC<ListControlsProps> = (props) => {\n const {\n beforeActions,\n collectionConfig,\n collectionSlug,\n disableBulkDelete,\n disableBulkEdit,\n enableColumns = true,\n enableSort = false,\n renderedFilters,\n resolvedFilterOptions,\n } = props\n\n const { handleSearchChange, query } = useListQuery()\n const titleField = useUseTitleField(collectionConfig)\n const { i18n, t } = useTranslation()\n const {\n breakpoints: { s: smallBreak },\n } = useWindowInfo()\n\n const searchLabel =\n (titleField &&\n getTranslation(\n 'label' in titleField && typeof titleField.label === 'string'\n ? titleField.label\n : 'name' in titleField\n ? titleField.name\n : null,\n i18n,\n )) ??\n 'ID'\n\n const listSearchableFields = getTextFieldsToBeSearched(\n collectionConfig.admin.listSearchableFields,\n collectionConfig.fields,\n )\n\n const searchLabelTranslated = useRef(\n t('general:searchBy', { label: getTranslation(searchLabel, i18n) }),\n )\n\n const hasWhereParam = useRef(Boolean(query?.where))\n\n const shouldInitializeWhereOpened = validateWhereQuery(query?.where)\n const [visibleDrawer, setVisibleDrawer] = useState<'columns' | 'sort' | 'where'>(\n shouldInitializeWhereOpened ? 'where' : undefined,\n )\n\n useEffect(() => {\n if (hasWhereParam.current && !query?.where) {\n hasWhereParam.current = false\n } else if (query?.where) {\n hasWhereParam.current = true\n }\n }, [setVisibleDrawer, query?.where])\n\n useEffect(() => {\n if (listSearchableFields?.length > 0) {\n searchLabelTranslated.current = listSearchableFields.reduce(\n (placeholderText: string, field, i: number) => {\n const label =\n 'label' in field && field.label ? field.label : 'name' in field ? field.name : null\n\n if (i === 0) {\n return `${t('general:searchBy', {\n label: getTranslation(label, i18n),\n })}`\n }\n\n if (i === listSearchableFields.length - 1) {\n return `${placeholderText} ${t('general:or')} ${getTranslation(label, i18n)}`\n }\n\n return `${placeholderText}, ${getTranslation(label, i18n)}`\n },\n '',\n )\n } else {\n searchLabelTranslated.current = t('general:searchBy', {\n label: getTranslation(searchLabel, i18n),\n })\n }\n }, [t, listSearchableFields, i18n, searchLabel])\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <SearchIcon />\n <SearchFilter\n fieldName={titleField && 'name' in titleField ? titleField?.name : null}\n handleChange={(search) => {\n return void handleSearchChange(search)\n }}\n // @ts-expect-error @todo: fix types\n initialParams={query}\n key={collectionSlug}\n label={searchLabelTranslated.current}\n />\n <div className={`${baseClass}__buttons`}>\n <div className={`${baseClass}__buttons-wrap`}>\n {!smallBreak && (\n <React.Fragment>\n {beforeActions && beforeActions}\n {!disableBulkEdit && (\n <Fragment>\n <EditMany collection={collectionConfig} />\n <PublishMany collection={collectionConfig} />\n <UnpublishMany collection={collectionConfig} />\n </Fragment>\n )}\n {!disableBulkDelete && <DeleteMany collection={collectionConfig} />}\n </React.Fragment>\n )}\n {enableColumns && (\n <Pill\n aria-controls={`${baseClass}-columns`}\n aria-expanded={visibleDrawer === 'columns'}\n className={`${baseClass}__toggle-columns`}\n icon={<ChevronIcon direction={visibleDrawer === 'columns' ? 'up' : 'down'} />}\n onClick={() =>\n setVisibleDrawer(visibleDrawer !== 'columns' ? 'columns' : undefined)\n }\n pillStyle=\"light\"\n >\n {t('general:columns')}\n </Pill>\n )}\n <Pill\n aria-controls={`${baseClass}-where`}\n aria-expanded={visibleDrawer === 'where'}\n className={`${baseClass}__toggle-where`}\n icon={<ChevronIcon direction={visibleDrawer === 'where' ? 'up' : 'down'} />}\n onClick={() => setVisibleDrawer(visibleDrawer !== 'where' ? 'where' : undefined)}\n pillStyle=\"light\"\n >\n {t('general:filters')}\n </Pill>\n {enableSort && (\n <Pill\n aria-controls={`${baseClass}-sort`}\n aria-expanded={visibleDrawer === 'sort'}\n className={`${baseClass}__toggle-sort`}\n icon={<ChevronIcon />}\n onClick={() => setVisibleDrawer(visibleDrawer !== 'sort' ? 'sort' : undefined)}\n pillStyle=\"light\"\n >\n {t('general:sort')}\n </Pill>\n )}\n </div>\n </div>\n </div>\n {enableColumns && (\n <AnimateHeight\n className={`${baseClass}__columns`}\n height={visibleDrawer === 'columns' ? 'auto' : 0}\n id={`${baseClass}-columns`}\n >\n <ColumnSelector collectionSlug={collectionConfig.slug} />\n </AnimateHeight>\n )}\n <AnimateHeight\n className={`${baseClass}__where`}\n height={visibleDrawer === 'where' ? 'auto' : 0}\n id={`${baseClass}-where`}\n >\n <WhereBuilder\n collectionPluralLabel={collectionConfig?.labels?.plural}\n collectionSlug={collectionConfig.slug}\n fields={collectionConfig?.fields}\n renderedFilters={renderedFilters}\n resolvedFilterOptions={resolvedFilterOptions}\n />\n </AnimateHeight>\n {enableSort && (\n <AnimateHeight\n className={`${baseClass}__sort`}\n height={visibleDrawer === 'sort' ? 'auto' : 0}\n id={`${baseClass}-sort`}\n >\n <p>Sort Complex</p>\n {/* <SortComplex\n collection={collection}\n handleChange={handleSortChange}\n modifySearchQuery={modifySearchQuery}\n /> */}\n </AnimateHeight>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,QAAQ,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAE7D,SAASC,gBAAgB,QAAQ;AACjC,SAASC,WAAW,QAAQ;AAC5B,SAASC,UAAU,QAAQ;AAC3B,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,QAAQ,QAAQ;AACzB,SAASC,IAAI,QAAQ;AACrB,SAASC,WAAW,QAAQ;AAC5B,SAASC,YAAY,QAAQ;AAC7B,SAASC,aAAa,QAAQ;AAC9B,SAASC,YAAY,QAAQ;AAC7B,OAAOC,kBAAA,MAAwB;AAC/B,SAASC,yBAAy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AI;QACrC7B,MAAA,EAAQrB,gBAAA,EAAkBqB,MAAA;QAC1Bf,eAAA,EAAiBA,eAAA;QACjBC,qBAAA,EAAuBA;;QAG1BF,UAAA,iBACCiC,IAAA,CAACrD,aAAA;MACCoD,SAAA,EAAW,GAAGzC,SAAA,QAAiB;MAC/BoD,MAAA,EAAQrB,aAAA,KAAkB,SAAS,SAAS;MAC5CsB,EAAA,EAAI,GAAGrD,SAAA,OAAgB;gBAEvB,aAAA0C,IAAA,CAAC;kBAAE;;;;AAUb","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/elements/Table/DefaultCell/fields/Blocks/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAG3E,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/elements/Table/DefaultCell/fields/Blocks/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAG3E,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,MAAM,WAAW,eAAgB,SAAQ,yBAAyB,CAAC,iBAAiB,CAAC;CAAG;AAExF,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA2ChD,CAAA"}
|
|
@@ -4,6 +4,7 @@ import { c as _c } from "react/compiler-runtime";
|
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
import { getTranslation } from '@payloadcms/translations';
|
|
6
6
|
import React from 'react';
|
|
7
|
+
import { useConfig } from '../../../../../providers/Config/index.js';
|
|
7
8
|
import { useTranslation } from '../../../../../providers/Translation/index.js';
|
|
8
9
|
export const BlocksCell = t0 => {
|
|
9
10
|
const $ = _c(2);
|
|
@@ -12,17 +13,24 @@ export const BlocksCell = t0 => {
|
|
|
12
13
|
field: t1
|
|
13
14
|
} = t0;
|
|
14
15
|
const {
|
|
16
|
+
blockReferences,
|
|
15
17
|
blocks,
|
|
16
18
|
labels
|
|
17
19
|
} = t1;
|
|
18
20
|
const {
|
|
19
21
|
i18n
|
|
20
22
|
} = useTranslation();
|
|
23
|
+
const {
|
|
24
|
+
config
|
|
25
|
+
} = useConfig();
|
|
21
26
|
const selectedBlocks = Array.isArray(cellData) ? cellData.map(_temp) : [];
|
|
22
|
-
const translatedBlockLabels = blocks?.map(b =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
const translatedBlockLabels = (blockReferences ?? blocks)?.map(b => {
|
|
28
|
+
const block = typeof b === "string" ? config.blocksMap[b] : b;
|
|
29
|
+
return {
|
|
30
|
+
slug: block.slug,
|
|
31
|
+
label: getTranslation(block.labels.singular, i18n)
|
|
32
|
+
};
|
|
33
|
+
});
|
|
26
34
|
let label = `0 ${getTranslation(labels?.plural, i18n)}`;
|
|
27
35
|
const formatBlockList = blocks_0 => blocks_0.map(b_0 => {
|
|
28
36
|
const filtered = translatedBlockLabels.filter(f => f.slug === b_0)?.[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","getTranslation","React","useTranslation","BlocksCell","t0","$","cellData","field","t1","blocks","labels","i18n","selectedBlocks","Array","isArray","map","_temp","translatedBlockLabels","b","slug","label","singular","plural","formatBlockList","blocks_0","b_0","filtered","filter","f","join","length","more","t","count","items","slice","t2","_jsx","children","blockType"],"sources":["../../../../../../src/elements/Table/DefaultCell/fields/Blocks/index.tsx"],"sourcesContent":["'use client'\nimport type { BlocksFieldClient, DefaultCellComponentProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport { useTranslation } from '../../../../../providers/Translation/index.js'\n\nexport interface BlocksCellProps extends DefaultCellComponentProps<BlocksFieldClient> {}\n\nexport const BlocksCell: React.FC<BlocksCellProps> = ({
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","getTranslation","React","useConfig","useTranslation","BlocksCell","t0","$","cellData","field","t1","blockReferences","blocks","labels","i18n","config","selectedBlocks","Array","isArray","map","_temp","translatedBlockLabels","b","block","blocksMap","slug","label","singular","plural","formatBlockList","blocks_0","b_0","filtered","filter","f","join","length","more","t","count","items","slice","t2","_jsx","children","blockType"],"sources":["../../../../../../src/elements/Table/DefaultCell/fields/Blocks/index.tsx"],"sourcesContent":["'use client'\nimport type { BlocksFieldClient, DefaultCellComponentProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport { useConfig } from '../../../../../providers/Config/index.js'\nimport { useTranslation } from '../../../../../providers/Translation/index.js'\n\nexport interface BlocksCellProps extends DefaultCellComponentProps<BlocksFieldClient> {}\n\nexport const BlocksCell: React.FC<BlocksCellProps> = ({\n cellData,\n field: { blockReferences, blocks, labels },\n}) => {\n const { i18n } = useTranslation()\n const { config } = useConfig()\n\n const selectedBlocks = Array.isArray(cellData) ? cellData.map(({ blockType }) => blockType) : []\n\n const translatedBlockLabels = (blockReferences ?? blocks)?.map((b) => {\n const block = typeof b === 'string' ? config.blocksMap[b] : b\n return {\n slug: block.slug,\n label: getTranslation(block.labels.singular, i18n),\n }\n })\n\n let label = `0 ${getTranslation(labels?.plural, i18n)}`\n\n const formatBlockList = (blocks) =>\n blocks\n .map((b) => {\n const filtered = translatedBlockLabels.filter((f) => f.slug === b)?.[0]\n return filtered?.label\n })\n .join(', ')\n\n const itemsToShow = 5\n\n if (selectedBlocks.length > itemsToShow) {\n const more = selectedBlocks.length - itemsToShow\n label = `${selectedBlocks.length} ${getTranslation(labels?.plural, i18n)} - ${i18n.t(\n 'fields:itemsAndMore',\n { count: more, items: formatBlockList(selectedBlocks.slice(0, itemsToShow)) },\n )}`\n } else if (selectedBlocks.length > 0) {\n label = `${selectedBlocks.length} ${getTranslation(\n selectedBlocks.length === 1 ? lab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S,IAAA,CACM;EAAA,IAINnB,cAAA,CAAAoB,MAAA,IAAwB;IAC1B,MAAAC,IAAA,GAAarB,cAAA,CAAAoB,MAAA,IAAwB;IACrCV,KAAA,CAAAA,CAAA,CAAQA,GAAGV,cAAA,CAAAoB,MAAA,IAAyBnC,cAAA,CAAeY,MAAA,EAAAe,MAAA,EAAgBd,IAAA,OAAWA,IAAA,CAAAwB,CAAA,CAC5E;MAAAC,KAAA,EACSF,IAAA;MAAAG,KAAA,EAAaX,eAAA,CAAgBb,cAAA,CAAAyB,KAAA,KAAwB;IAAA,CAAc,GAC3E;EAHH;IAAA,IAISzB,cAAA,CAAAoB,MAAA,IAAwB;MACjCV,KAAA,CAAAA,CAAA,CAAQA,GAAGV,cAAA,CAAAoB,MAAA,IAAyBnC,cAAA,CAClCe,cAAA,CAAAoB,MAAA,MAA0B,GAAIvB,MAAA,EAAAc,QAAA,GAAmBd,MAAA,EAAAe,MAAQ,EACzDd,IAAA,OACKe,eAAA,CAAgBb,cAAA,GAAiB;IAHxC;EAAA;EAAA,IAAA0B,EAAA;EAAA,IAAAnC,CAAA,QAAAmB,KAAA;IAMKgB,EAAA,GAAAC,IAAA,CAAC;MAAAC,QAAA,EAAMlB;IAAA,C;;;;;;SAAPgB,E;CACT;AA3CqD,SAAAtB,MAAAd,EAAA;EAOY;IAAAuC;EAAA,IAAAvC,EAAa;EAAA,OAAKuC,SAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","getTranslation","LinkImport","fieldAffectsData","fieldIsID","React","useConfig","useTranslation","formatAdminURL","CodeCell","cellComponents","Link","default","DefaultCell","props","$","cellData","className","classNameFromProps","collectionSlug","field","t0","link","onClick","onClickFromProps","rowData","admin","i18n","config","t1","getEntityConfig","routes","t2","adminRoute","t3","t4","Symbol","for","collectionConfig","classNameFromConfigContext","undefined","WrapElement","wrapElementProps","prefetch","href","slug","path","encodeURIComponent","id","type","_jsx","children","nowrap","DefaultCellComponent","CellComponent","upload","name","FileCellComponent","File","_jsxs","t","label","JSON","stringify"],"sources":["../../../../src/elements/Table/DefaultCell/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig, DefaultCellComponentProps, UploadFieldClient } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport LinkImport from 'next/link.js'\nimport { fieldAffectsData, fieldIsID } from 'payload/shared'\nimport React from 'react' // TODO: abstract this out to support all routers\n\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { formatAdminURL } from '../../../utilities/formatAdminURL.js'\nimport { CodeCell } from './fields/Code/index.js'\nimport { cellComponents } from './fields/index.js'\nconst Link = (LinkImport.default || LinkImport) as unknown as typeof LinkImport.default\n\nexport const DefaultCell: React.FC<DefaultCellComponentProps> = (props) => {\n const {\n cellData,\n className: classNameFromProps,\n collectionSlug,\n field,\n field: { admin },\n link,\n onClick: onClickFromProps,\n rowData,\n } = props\n\n const { i18n } = useTranslation()\n\n const {\n config: {\n routes: { admin: adminRoute },\n },\n getEntityConfig,\n } = useConfig()\n\n const collectionConfig = getEntityConfig({ collectionSlug })
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","getTranslation","LinkImport","fieldAffectsData","fieldIsID","React","useConfig","useTranslation","formatAdminURL","CodeCell","cellComponents","Link","default","DefaultCell","props","$","cellData","className","classNameFromProps","collectionSlug","field","t0","link","onClick","onClickFromProps","rowData","admin","i18n","config","t1","getEntityConfig","routes","t2","adminRoute","t3","t4","Symbol","for","collectionConfig","classNameFromConfigContext","undefined","WrapElement","wrapElementProps","prefetch","href","slug","path","encodeURIComponent","id","type","_jsx","children","nowrap","DefaultCellComponent","CellComponent","upload","name","FileCellComponent","File","_jsxs","t","label","JSON","stringify"],"sources":["../../../../src/elements/Table/DefaultCell/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig, DefaultCellComponentProps, UploadFieldClient } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport LinkImport from 'next/link.js'\nimport { fieldAffectsData, fieldIsID } from 'payload/shared'\nimport React from 'react' // TODO: abstract this out to support all routers\n\nimport { useConfig } from '../../../providers/Config/index.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { formatAdminURL } from '../../../utilities/formatAdminURL.js'\nimport { CodeCell } from './fields/Code/index.js'\nimport { cellComponents } from './fields/index.js'\nconst Link = (LinkImport.default || LinkImport) as unknown as typeof LinkImport.default\n\nexport const DefaultCell: React.FC<DefaultCellComponentProps> = (props) => {\n const {\n cellData,\n className: classNameFromProps,\n collectionSlug,\n field,\n field: { admin },\n link,\n onClick: onClickFromProps,\n rowData,\n } = props\n\n const { i18n } = useTranslation()\n\n const {\n config: {\n routes: { admin: adminRoute },\n },\n getEntityConfig,\n } = useConfig()\n\n const collectionConfig = getEntityConfig({ collectionSlug })\n\n const classNameFromConfigContext = admin && 'className' in admin ? admin.className : undefined\n\n const className =\n classNameFromProps ||\n (field.admin && 'className' in field.admin ? field.admin.className : null) ||\n classNameFromConfigContext\n\n const onClick = onClickFromProps\n\n let WrapElement: React.ComponentType<any> | string = 'span'\n\n const wrapElementProps: {\n className?: string\n href?: string\n onClick?: () => void\n prefetch?: false\n type?: 'button'\n } = {\n className,\n }\n\n if (link) {\n wrapElementProps.prefetch = false\n WrapElement = Link\n wrapElementProps.href = collectionConfig?.slug\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${collectionConfig?.slug}/${encodeURIComponent(rowData.id)}`,\n })\n : ''\n }\n\n if (typeof onClick === 'function') {\n WrapElement = 'button'\n wrapElementProps.type = 'button'\n wrapElementProps.onClick = () => {\n onClick({\n cellData,\n collectionSlug: collectionConfig?.slug,\n rowData,\n })\n }\n }\n\n if (fieldIsID(field)) {\n return (\n <WrapElement {...wrapElementProps}>\n <CodeCell\n cellData={`ID: ${cellData}`}\n collectionConfig={collectionConfig}\n collectionSlug={collectionSlug}\n field={{\n ...field,\n type: 'code',\n }}\n nowrap\n rowData={rowData}\n />\n </WrapElement>\n )\n }\n\n const DefaultCellComponent: React.FC<DefaultCellComponentProps> =\n typeof cellData !== 'undefined' && cellComponents[field.type]\n\n let CellComponent: React.ReactNode = null\n\n if (DefaultCellComponent) {\n CellComponent = <DefaultCellComponent cellData={cellData} rowData={rowData} {...props} />\n } else if (!DefaultCellComponent) {\n // DefaultCellComponent does not exist for certain field types like `text`\n if (\n collectionConfig?.upload &&\n fieldAffectsData(field) &&\n field.name === 'filename' &&\n field.type === 'text'\n ) {\n const FileCellComponent = cellComponents.File\n\n CellComponent = (\n <FileCellComponent\n cellData={cellData}\n rowData={rowData}\n {...(props as DefaultCellComponentProps<UploadFieldClient>)}\n collectionConfig={collectionConfig}\n field={field}\n />\n )\n } else {\n return (\n <WrapElement {...wrapElementProps}>\n {(cellData === '' || typeof cellData === 'undefined' || cellData === null) &&\n i18n.t('general:noLabel', {\n label: getTranslation(('label' in field ? field.label : null) || 'data', i18n),\n })}\n {typeof cellData === 'string' && cellData}\n {typeof cellData === 'number' && cellData}\n {typeof cellData === 'object' && cellData !== null && JSON.stringify(cellData)}\n </WrapElement>\n )\n }\n }\n\n return <WrapElement {...wrapElementProps}>{CellComponent}</WrapElement>\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,cAAc,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,gBAAgB,EAAEC,SAAS,QAAQ;AAC5C,OAAOC,KAAA,MAAW,QAAO,CAAC;AAE1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,QAAQ;AAC/B,MAAMC,IAAA,GAAQT,UAAA,CAAWU,OAAO,IAAIV,UAAA;AAEpC,OAAO,MAAMW,WAAA,GAAmDC,KAAA;EAAA,MAAAC,CAAA,GAAAf,EAAA;EAC9D;IAAAgB,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A;YAEAJ,aAAA,CAAAA,CAAA,CACEA,KAACG,iBAAA;cAAAzC,QAAA;cAAAS,OAAA;cAAA,GAGMX,KAAK;cAAAwB,gBAAA;cAAAlB;YAAA,C;UAJd;YAWEe,EAAA,GAAAwB,KAAA,CAAClB,WAAA;cAAA,GAAgBC,gBAAgB;cAAAS,QAAA,GAC7B,CAAAnC,QAAA,KAAa,MAAM,OAAOA,QAAA,KAAa,eAAeA,QAAA,SAAgB,KACtEW,IAAA,CAAAiC,CAAA,CAAO;gBAAAC,KAAA,EACE5D,cAAA,CAAe,CAAC,WAAWmB,KAAA,GAAQA,KAAA,CAAAyC,KAAA,OAAiB,KAAM,QAAQlC,IAAA;cAAA,CAC3E,GACD,OAAOX,QAAA,KAAa,YAAYA,QAAA,EAChC,OAAOA,QAAA,KAAa,YAAYA,QAAA,EAChC,OAAOA,QAAA,KAAa,YAAYA,QAAA,SAAa,IAAQ8C,IAAA,CAAAC,SAAA,CAAe/C,QAAA;YAAA,C;;;;;MAMtEkB,EAAA,GAAAgB,IAAA,CAACT,WAAA;QAAA,GAAgBC,gBAAgB;QAAAS,QAAA,EAAGG;MAAA,C;;;;;;;;;;;;;;;;;;;;;;;SAApCpB,E;CACT","ignoreList":[]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { DescriptionFunction, StaticDescription } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import './index.scss';
|
|
4
3
|
export type ViewDescriptionComponent = React.ComponentType<any>;
|
|
5
4
|
type Description = DescriptionFunction | StaticDescription | string | ViewDescriptionComponent;
|
|
6
5
|
export type ViewDescriptionProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/ViewDescription/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAGrE,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/ViewDescription/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAGrE,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;AAE/D,KAAK,WAAW,GAAG,mBAAmB,GAAG,iBAAiB,GAAG,MAAM,GAAG,wBAAwB,CAAA;AAE9F,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAA;CACzC,CAAA;AAED,wBAAgB,WAAW,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,IAAI,wBAAwB,CAE7F;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAS1D,CAAA"}
|
|
@@ -5,7 +5,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
import { getTranslation } from '@payloadcms/translations';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { useTranslation } from '../../providers/Translation/index.js';
|
|
8
|
-
import './index.scss';
|
|
9
8
|
export function isComponent(description) {
|
|
10
9
|
return /*#__PURE__*/React.isValidElement(description);
|
|
11
10
|
}
|
|
@@ -21,7 +20,7 @@ export const ViewDescription = props => {
|
|
|
21
20
|
let t0;
|
|
22
21
|
if ($[0] !== description || $[1] !== i18n) {
|
|
23
22
|
t0 = _jsx("div", {
|
|
24
|
-
className: "view-description",
|
|
23
|
+
className: "custom-view-description",
|
|
25
24
|
children: getTranslation(description, i18n)
|
|
26
25
|
});
|
|
27
26
|
$[0] = description;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","getTranslation","React","useTranslation","isComponent","description","isValidElement","ViewDescription","props","$","i18n","t0","_jsx","className","children"],"sources":["../../../src/elements/ViewDescription/index.tsx"],"sourcesContent":["'use client'\nimport type { DescriptionFunction, StaticDescription } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport { useTranslation } from '../../providers/Translation/index.js'\
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","getTranslation","React","useTranslation","isComponent","description","isValidElement","ViewDescription","props","$","i18n","t0","_jsx","className","children"],"sources":["../../../src/elements/ViewDescription/index.tsx"],"sourcesContent":["'use client'\nimport type { DescriptionFunction, StaticDescription } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport { useTranslation } from '../../providers/Translation/index.js'\n\nexport type ViewDescriptionComponent = React.ComponentType<any>\n\ntype Description = DescriptionFunction | StaticDescription | string | ViewDescriptionComponent\n\nexport type ViewDescriptionProps = {\n readonly description?: StaticDescription\n}\n\nexport function isComponent(description: Description): description is ViewDescriptionComponent {\n return React.isValidElement(description)\n}\n\nexport const ViewDescription: React.FC<ViewDescriptionProps> = (props) => {\n const { i18n } = useTranslation()\n const { description } = props\n\n if (description) {\n return <div className=\"custom-view-description\">{getTranslation(description, i18n)}</div>\n }\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAElB,SAASC,cAAc,QAAQ;AAU/B,OAAO,SAASC,YAAYC,WAAwB;EAClD,oBAAOH,KAAA,CAAMI,cAAc,CAACD,WAAA;AAC9B;AAEA,OAAO,MAAME,eAAA,GAAkDC,KAAA;EAAA,MAAAC,CAAA,GAAAT,EAAA;EAC7D;IAAAU;EAAA,IAAiBP,cAAA;EACjB;IAAAE;EAAA,IAAwBG,KAAA;EAAA,IAEpBH,WAAA;IAAA,IAAAM,EAAA;IAAA,IAAAF,CAAA,QAAAJ,WAAA,IAAAI,CAAA,QAAAC,IAAA;MACKC,EAAA,GAAAC,IAAA,CAAC;QAAAC,SAAA,EAAc;QAAAC,QAAA,EAA2Bb,cAAA,CAAeI,WAAA,EAAaK,IAAA;MAAA,C;;;;;;;WAAtEC,E;;;CAIX","ignoreList":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { Operator, Option } from 'payload';
|
|
1
|
+
import type { Operator, Option, ResolvedFilterOptions } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ReducedField } from '../../types.js';
|
|
4
4
|
type Props = {
|
|
5
5
|
booleanSelect: boolean;
|
|
6
6
|
disabled: boolean;
|
|
7
|
-
|
|
7
|
+
filterOptions: ResolvedFilterOptions;
|
|
8
|
+
internalField: ReducedField;
|
|
8
9
|
onChange: React.Dispatch<React.SetStateAction<string>>;
|
|
9
10
|
operator: Operator;
|
|
10
11
|
options: Option[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/WhereBuilder/Condition/DefaultFilter/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/WhereBuilder/Condition/DefaultFilter/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,MAAM,EACN,qBAAqB,EAGtB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAQlD,KAAK,KAAK,GAAG;IACX,aAAa,EAAE,OAAO,CAAA;IACtB,QAAQ,EAAE,OAAO,CAAA;IACjB,aAAa,EAAE,qBAAqB,CAAA;IACpC,aAAa,EAAE,YAAY,CAAA;IAC3B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;IACtD,QAAQ,EAAE,QAAQ,CAAA;IAClB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA0EzC,CAAA"}
|
|
@@ -8,6 +8,7 @@ import { Text } from '../Text/index.js';
|
|
|
8
8
|
export const DefaultFilter = ({
|
|
9
9
|
booleanSelect,
|
|
10
10
|
disabled,
|
|
11
|
+
filterOptions,
|
|
11
12
|
internalField,
|
|
12
13
|
onChange,
|
|
13
14
|
operator,
|
|
@@ -18,6 +19,7 @@ export const DefaultFilter = ({
|
|
|
18
19
|
return /*#__PURE__*/_jsx(Select, {
|
|
19
20
|
disabled: disabled,
|
|
20
21
|
field: internalField.field,
|
|
22
|
+
isClearable: !booleanSelect,
|
|
21
23
|
onChange: onChange,
|
|
22
24
|
operator: operator,
|
|
23
25
|
options: options,
|
|
@@ -50,6 +52,7 @@ export const DefaultFilter = ({
|
|
|
50
52
|
return /*#__PURE__*/_jsx(RelationshipFilter, {
|
|
51
53
|
disabled: disabled,
|
|
52
54
|
field: internalField.field,
|
|
55
|
+
filterOptions: filterOptions,
|
|
53
56
|
onChange: onChange,
|
|
54
57
|
operator: operator,
|
|
55
58
|
value: value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","DateFilter","NumberFilter","RelationshipFilter","Select","Text","DefaultFilter","booleanSelect","disabled","internalField","onChange","operator","options","value","includes","field","type","_jsx"],"sources":["../../../../../src/elements/WhereBuilder/Condition/DefaultFilter/index.tsx"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","DateFilter","NumberFilter","RelationshipFilter","Select","Text","DefaultFilter","booleanSelect","disabled","filterOptions","internalField","onChange","operator","options","value","includes","field","type","_jsx","isClearable"],"sources":["../../../../../src/elements/WhereBuilder/Condition/DefaultFilter/index.tsx"],"sourcesContent":["import type {\n Operator,\n Option,\n ResolvedFilterOptions,\n SelectFieldClient,\n TextFieldClient,\n} from 'payload'\n\nimport React from 'react'\n\nimport type { ReducedField } from '../../types.js'\n\nimport { DateFilter } from '../Date/index.js'\nimport { NumberFilter } from '../Number/index.js'\nimport { RelationshipFilter } from '../Relationship/index.js'\nimport { Select } from '../Select/index.js'\nimport { Text } from '../Text/index.js'\n\ntype Props = {\n booleanSelect: boolean\n disabled: boolean\n filterOptions: ResolvedFilterOptions\n internalField: ReducedField\n onChange: React.Dispatch<React.SetStateAction<string>>\n operator: Operator\n options: Option[]\n value: string\n}\n\nexport const DefaultFilter: React.FC<Props> = ({\n booleanSelect,\n disabled,\n filterOptions,\n internalField,\n onChange,\n operator,\n options,\n value,\n}) => {\n if (booleanSelect || ['radio', 'select'].includes(internalField?.field?.type)) {\n return (\n <Select\n disabled={disabled}\n field={internalField.field as SelectFieldClient}\n isClearable={!booleanSelect}\n onChange={onChange}\n operator={operator}\n options={options}\n value={value}\n />\n )\n }\n\n switch (internalField?.field?.type) {\n case 'date': {\n return (\n <DateFilter\n disabled={disabled}\n field={internalField.field}\n onChange={onChange}\n operator={operator}\n value={value}\n />\n )\n }\n\n case 'number': {\n return (\n <NumberFilter\n disabled={disabled}\n field={internalField.field}\n onChange={onChange}\n operator={operator}\n value={value}\n />\n )\n }\n\n case 'relationship': {\n return (\n <RelationshipFilter\n disabled={disabled}\n field={internalField.field}\n filterOptions={filterOptions}\n onChange={onChange}\n operator={operator}\n value={value}\n />\n )\n }\n\n default: {\n return (\n <Text\n disabled={disabled}\n field={internalField?.field as TextFieldClient}\n onChange={onChange}\n operator={operator}\n value={value}\n />\n )\n }\n }\n}\n"],"mappings":";AAQA,OAAOA,KAAA,MAAW;AAIlB,SAASC,UAAU,QAAQ;AAC3B,SAASC,YAAY,QAAQ;AAC7B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,MAAM,QAAQ;AACvB,SAASC,IAAI,QAAQ;AAarB,OAAO,MAAMC,aAAA,GAAiCA,CAAC;EAC7CC,aAAa;EACbC,QAAQ;EACRC,aAAa;EACbC,aAAa;EAC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F","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/WhereBuilder/Condition/Relationship/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAuD,MAAM,OAAO,CAAA;AAG3E,OAAO,KAAK,EAAE,KAAK,EAAqB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/WhereBuilder/Condition/Relationship/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAuD,MAAM,OAAO,CAAA;AAG3E,OAAO,KAAK,EAAE,KAAK,EAAqB,MAAM,YAAY,CAAA;AAQ1D,OAAO,cAAc,CAAA;AAMrB,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA6Y9C,CAAA"}
|
|
@@ -4,11 +4,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
import * as qs from 'qs-esm';
|
|
5
5
|
import React, { useCallback, useEffect, useReducer, useState } from 'react';
|
|
6
6
|
import { useDebounce } from '../../../../hooks/useDebounce.js';
|
|
7
|
+
import { useEffectEvent } from '../../../../hooks/useEffectEvent.js';
|
|
7
8
|
import { useConfig } from '../../../../providers/Config/index.js';
|
|
8
9
|
import { useTranslation } from '../../../../providers/Translation/index.js';
|
|
9
10
|
import { ReactSelect } from '../../../ReactSelect/index.js';
|
|
10
|
-
import './index.scss';
|
|
11
11
|
import optionsReducer from './optionsReducer.js';
|
|
12
|
+
import './index.scss';
|
|
12
13
|
const baseClass = 'condition-value-relationship';
|
|
13
14
|
const maxResultsPerRequest = 10;
|
|
14
15
|
export const RelationshipFilter = props => {
|
|
@@ -21,6 +22,7 @@ export const RelationshipFilter = props => {
|
|
|
21
22
|
hasMany,
|
|
22
23
|
relationTo
|
|
23
24
|
},
|
|
25
|
+
filterOptions,
|
|
24
26
|
onChange,
|
|
25
27
|
value
|
|
26
28
|
} = props;
|
|
@@ -36,23 +38,18 @@ export const RelationshipFilter = props => {
|
|
|
36
38
|
const hasMultipleRelations = Array.isArray(relationTo);
|
|
37
39
|
const [options, dispatchOptions] = useReducer(optionsReducer, []);
|
|
38
40
|
const [search, setSearch] = useState('');
|
|
41
|
+
const debouncedSearch = useDebounce(search, 300);
|
|
39
42
|
const [errorLoading, setErrorLoading] = useState('');
|
|
40
43
|
const [hasLoadedFirstOptions, setHasLoadedFirstOptions] = useState(false);
|
|
41
|
-
const debouncedSearch = useDebounce(search, 300);
|
|
42
44
|
const {
|
|
43
45
|
i18n,
|
|
44
46
|
t
|
|
45
47
|
} = useTranslation();
|
|
46
48
|
const relationSlugs = hasMultipleRelations ? relationTo : [relationTo];
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
return map;
|
|
53
|
-
};
|
|
54
|
-
const nextPageByRelationshipRef = React.useRef(initialRelationMap());
|
|
55
|
-
const partiallyLoadedRelationshipSlugs = React.useRef(relationSlugs);
|
|
49
|
+
const loadedRelationships = React.useRef(new Map(relationSlugs.map(relation => [relation, {
|
|
50
|
+
hasLoadedAll: false,
|
|
51
|
+
nextPage: 1
|
|
52
|
+
}])));
|
|
56
53
|
const addOptions = useCallback((data, relation_0) => {
|
|
57
54
|
const collection = getEntityConfig({
|
|
58
55
|
collectionSlug: relation_0
|
|
@@ -66,28 +63,31 @@ export const RelationshipFilter = props => {
|
|
|
66
63
|
relation: relation_0
|
|
67
64
|
});
|
|
68
65
|
}, [hasMultipleRelations, i18n, getEntityConfig]);
|
|
69
|
-
const
|
|
66
|
+
const loadOptions = useEffectEvent(async ({
|
|
70
67
|
abortController,
|
|
71
68
|
relationSlug
|
|
72
69
|
}) => {
|
|
73
|
-
|
|
70
|
+
const loadedRelationship = loadedRelationships.current.get(relationSlug);
|
|
71
|
+
if (relationSlug && !loadedRelationship.hasLoadedAll) {
|
|
74
72
|
const collection_0 = getEntityConfig({
|
|
75
73
|
collectionSlug: relationSlug
|
|
76
74
|
});
|
|
77
75
|
const fieldToSearch = collection_0?.admin?.useAsTitle || 'id';
|
|
78
|
-
const pageIndex = nextPageByRelationshipRef.current.get(relationSlug);
|
|
79
76
|
const where = {
|
|
80
77
|
and: []
|
|
81
78
|
};
|
|
82
79
|
const query = {
|
|
83
80
|
depth: 0,
|
|
84
81
|
limit: maxResultsPerRequest,
|
|
85
|
-
page:
|
|
82
|
+
page: loadedRelationship.nextPage,
|
|
86
83
|
select: {
|
|
87
84
|
[fieldToSearch]: true
|
|
88
85
|
},
|
|
89
86
|
where
|
|
90
87
|
};
|
|
88
|
+
if (filterOptions && filterOptions?.[relationSlug]) {
|
|
89
|
+
query.where.and.push(filterOptions[relationSlug]);
|
|
90
|
+
}
|
|
91
91
|
if (debouncedSearch) {
|
|
92
92
|
query.where.and.push({
|
|
93
93
|
[fieldToSearch]: {
|
|
@@ -110,9 +110,15 @@ export const RelationshipFilter = props => {
|
|
|
110
110
|
if (data_0.docs.length > 0) {
|
|
111
111
|
addOptions(data_0, relationSlug);
|
|
112
112
|
if (data_0.nextPage) {
|
|
113
|
-
|
|
113
|
+
loadedRelationships.current.set(relationSlug, {
|
|
114
|
+
hasLoadedAll: false,
|
|
115
|
+
nextPage: data_0.nextPage
|
|
116
|
+
});
|
|
114
117
|
} else {
|
|
115
|
-
|
|
118
|
+
loadedRelationships.current.set(relationSlug, {
|
|
119
|
+
hasLoadedAll: true,
|
|
120
|
+
nextPage: null
|
|
121
|
+
});
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
124
|
} else {
|
|
@@ -120,21 +126,23 @@ export const RelationshipFilter = props => {
|
|
|
120
126
|
}
|
|
121
127
|
} catch (e) {
|
|
122
128
|
if (!abortController.signal.aborted) {
|
|
123
|
-
console.error(e)
|
|
129
|
+
console.error(e) // eslint-disable-line no-console
|
|
130
|
+
;
|
|
124
131
|
}
|
|
125
132
|
}
|
|
126
133
|
}
|
|
127
134
|
setHasLoadedFirstOptions(true);
|
|
128
|
-
}
|
|
129
|
-
const
|
|
130
|
-
|
|
135
|
+
});
|
|
136
|
+
const handleScrollToBottom = React.useCallback(() => {
|
|
137
|
+
const relationshipToLoad = loadedRelationships.current.entries().next().value;
|
|
138
|
+
if (relationshipToLoad[0] && !relationshipToLoad[1].hasLoadedAll) {
|
|
131
139
|
const abortController_0 = new AbortController();
|
|
132
|
-
void
|
|
140
|
+
void loadOptions({
|
|
133
141
|
abortController: abortController_0,
|
|
134
|
-
relationSlug:
|
|
142
|
+
relationSlug: relationshipToLoad[0]
|
|
135
143
|
});
|
|
136
144
|
}
|
|
137
|
-
}, [
|
|
145
|
+
}, []);
|
|
138
146
|
const findOptionsByValue = useCallback(() => {
|
|
139
147
|
if (value) {
|
|
140
148
|
if (hasMany) {
|
|
@@ -180,22 +188,24 @@ export const RelationshipFilter = props => {
|
|
|
180
188
|
}
|
|
181
189
|
return undefined;
|
|
182
190
|
}, [hasMany, hasMultipleRelations, value, options]);
|
|
183
|
-
const handleInputChange = input => {
|
|
191
|
+
const handleInputChange = useCallback(input => {
|
|
184
192
|
if (input !== search) {
|
|
185
193
|
dispatchOptions({
|
|
186
194
|
type: 'CLEAR',
|
|
187
195
|
i18n,
|
|
188
196
|
required: false
|
|
189
197
|
});
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
198
|
+
const relationSlugs_0 = Array.isArray(relationTo) ? relationTo : [relationTo];
|
|
199
|
+
loadedRelationships.current = new Map(relationSlugs_0.map(relation_1 => [relation_1, {
|
|
200
|
+
hasLoadedAll: false,
|
|
201
|
+
nextPage: 1
|
|
202
|
+
}]));
|
|
193
203
|
setSearch(input);
|
|
194
204
|
}
|
|
195
|
-
};
|
|
196
|
-
const addOptionByID = useCallback(async (id,
|
|
197
|
-
if (!errorLoading && id !== 'null' && id &&
|
|
198
|
-
const response_0 = await fetch(`${serverURL}${api}/${
|
|
205
|
+
}, [i18n, relationTo, search]);
|
|
206
|
+
const addOptionByID = useCallback(async (id, relation_2) => {
|
|
207
|
+
if (!errorLoading && id !== 'null' && id && relation_2) {
|
|
208
|
+
const response_0 = await fetch(`${serverURL}${api}/${relation_2}/${id}?depth=0`, {
|
|
199
209
|
credentials: 'include',
|
|
200
210
|
headers: {
|
|
201
211
|
'Accept-Language': i18n.language
|
|
@@ -205,7 +215,7 @@ export const RelationshipFilter = props => {
|
|
|
205
215
|
const data_1 = await response_0.json();
|
|
206
216
|
addOptions({
|
|
207
217
|
docs: [data_1]
|
|
208
|
-
},
|
|
218
|
+
}, relation_2);
|
|
209
219
|
} else {
|
|
210
220
|
// eslint-disable-next-line no-console
|
|
211
221
|
console.error(t('error:loadingDocument', {
|
|
@@ -215,18 +225,29 @@ export const RelationshipFilter = props => {
|
|
|
215
225
|
}
|
|
216
226
|
}, [i18n, addOptions, api, errorLoading, serverURL, t]);
|
|
217
227
|
/**
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
228
|
+
* When `relationTo` changes externally, reset the options and reload them from scratch
|
|
229
|
+
* The `loadOptions` dependency is a useEffectEvent which has no dependencies of its own
|
|
230
|
+
* This means we can safely depend on it without it triggering this effect to run
|
|
231
|
+
* This is useful because this effect should _only_ run when `relationTo` changes
|
|
221
232
|
*/
|
|
222
233
|
useEffect(() => {
|
|
223
234
|
const relations = Array.isArray(relationTo) ? relationTo : [relationTo];
|
|
235
|
+
loadedRelationships.current = new Map(relations.map(relation_3 => [relation_3, {
|
|
236
|
+
hasLoadedAll: false,
|
|
237
|
+
nextPage: 1
|
|
238
|
+
}]));
|
|
239
|
+
dispatchOptions({
|
|
240
|
+
type: 'CLEAR',
|
|
241
|
+
i18n,
|
|
242
|
+
required: false
|
|
243
|
+
});
|
|
244
|
+
setHasLoadedFirstOptions(false);
|
|
224
245
|
const abortControllers = [];
|
|
225
|
-
relations.forEach(
|
|
246
|
+
relations.forEach(relation_4 => {
|
|
226
247
|
const abortController_1 = new AbortController();
|
|
227
|
-
void
|
|
248
|
+
void loadOptions({
|
|
228
249
|
abortController: abortController_1,
|
|
229
|
-
relationSlug:
|
|
250
|
+
relationSlug: relation_4
|
|
230
251
|
});
|
|
231
252
|
abortControllers.push(abortController_1);
|
|
232
253
|
});
|
|
@@ -241,10 +262,9 @@ export const RelationshipFilter = props => {
|
|
|
241
262
|
}
|
|
242
263
|
});
|
|
243
264
|
};
|
|
244
|
-
}, [i18n,
|
|
265
|
+
}, [i18n, relationTo, debouncedSearch]);
|
|
245
266
|
/**
|
|
246
|
-
* Load any options that were not
|
|
247
|
-
* in the first 10 of each relation fetch
|
|
267
|
+
* Load any other options that might exist in the value that were not loaded already
|
|
248
268
|
*/
|
|
249
269
|
useEffect(() => {
|
|
250
270
|
if (value && hasLoadedFirstOptions) {
|
|
@@ -305,7 +325,7 @@ export const RelationshipFilter = props => {
|
|
|
305
325
|
}
|
|
306
326
|
},
|
|
307
327
|
onInputChange: handleInputChange,
|
|
308
|
-
onMenuScrollToBottom:
|
|
328
|
+
onMenuScrollToBottom: handleScrollToBottom,
|
|
309
329
|
options: options,
|
|
310
330
|
placeholder: t('general:selectValue'),
|
|
311
331
|
value: valueToRender
|