@payloadcms/ui 3.26.0-canary.bbb3083 → 3.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/elements/AnimateHeight/index.scss +7 -5
  2. package/dist/elements/BulkUpload/FormsManager/index.d.ts.map +1 -1
  3. package/dist/elements/BulkUpload/FormsManager/index.js +37 -21
  4. package/dist/elements/BulkUpload/FormsManager/index.js.map +1 -1
  5. package/dist/elements/FieldSelect/index.js +1 -1
  6. package/dist/elements/FieldSelect/index.js.map +1 -1
  7. package/dist/elements/Localizer/index.d.ts.map +1 -1
  8. package/dist/elements/Localizer/index.js +36 -24
  9. package/dist/elements/Localizer/index.js.map +1 -1
  10. package/dist/elements/Nav/context.d.ts.map +1 -1
  11. package/dist/elements/Nav/context.js +8 -1
  12. package/dist/elements/Nav/context.js.map +1 -1
  13. package/dist/elements/PublishButton/index.js +1 -0
  14. package/dist/elements/PublishButton/index.js.map +1 -1
  15. package/dist/elements/RelationshipTable/index.d.ts +1 -1
  16. package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
  17. package/dist/elements/RelationshipTable/index.js +4 -11
  18. package/dist/elements/RelationshipTable/index.js.map +1 -1
  19. package/dist/elements/TableColumns/context.d.ts +4 -0
  20. package/dist/elements/TableColumns/context.d.ts.map +1 -0
  21. package/dist/elements/TableColumns/context.js +4 -0
  22. package/dist/elements/TableColumns/context.js.map +1 -0
  23. package/dist/elements/TableColumns/index.d.ts +3 -31
  24. package/dist/elements/TableColumns/index.d.ts.map +1 -1
  25. package/dist/elements/TableColumns/index.js +49 -164
  26. package/dist/elements/TableColumns/index.js.map +1 -1
  27. package/dist/elements/TableColumns/types.d.ts +52 -0
  28. package/dist/elements/TableColumns/types.d.ts.map +1 -0
  29. package/dist/elements/TableColumns/types.js +2 -0
  30. package/dist/elements/TableColumns/types.js.map +1 -0
  31. package/dist/elements/WhereBuilder/Condition/index.d.ts +2 -5
  32. package/dist/elements/WhereBuilder/Condition/index.d.ts.map +1 -1
  33. package/dist/elements/WhereBuilder/Condition/index.js +7 -7
  34. package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
  35. package/dist/elements/WhereBuilder/index.d.ts.map +1 -1
  36. package/dist/elements/WhereBuilder/index.js +22 -31
  37. package/dist/elements/WhereBuilder/index.js.map +1 -1
  38. package/dist/elements/WhereBuilder/types.d.ts +6 -2
  39. package/dist/elements/WhereBuilder/types.d.ts.map +1 -1
  40. package/dist/elements/WhereBuilder/types.js.map +1 -1
  41. package/dist/exports/client/index.js +11 -11
  42. package/dist/exports/client/index.js.map +4 -4
  43. package/dist/fields/Upload/HasMany/index.d.ts.map +1 -1
  44. package/dist/fields/Upload/HasMany/index.js +12 -4
  45. package/dist/fields/Upload/HasMany/index.js.map +1 -1
  46. package/dist/fields/Upload/HasOne/index.d.ts.map +1 -1
  47. package/dist/fields/Upload/HasOne/index.js +15 -5
  48. package/dist/fields/Upload/HasOne/index.js.map +1 -1
  49. package/dist/fields/Upload/RelationshipContent/index.d.ts +1 -0
  50. package/dist/fields/Upload/RelationshipContent/index.d.ts.map +1 -1
  51. package/dist/fields/Upload/RelationshipContent/index.js +13 -11
  52. package/dist/fields/Upload/RelationshipContent/index.js.map +1 -1
  53. package/dist/forms/Form/index.d.ts.map +1 -1
  54. package/dist/forms/Form/index.js +3 -1
  55. package/dist/forms/Form/index.js.map +1 -1
  56. package/dist/forms/Form/types.d.ts +4 -0
  57. package/dist/forms/Form/types.d.ts.map +1 -1
  58. package/dist/forms/Form/types.js.map +1 -1
  59. package/dist/providers/ListQuery/context.d.ts +4 -0
  60. package/dist/providers/ListQuery/context.d.ts.map +1 -0
  61. package/dist/providers/ListQuery/context.js +4 -0
  62. package/dist/providers/ListQuery/context.js.map +1 -0
  63. package/dist/providers/ListQuery/index.d.ts +2 -27
  64. package/dist/providers/ListQuery/index.d.ts.map +1 -1
  65. package/dist/providers/ListQuery/index.js +51 -37
  66. package/dist/providers/ListQuery/index.js.map +1 -1
  67. package/dist/providers/ListQuery/types.d.ts +33 -0
  68. package/dist/providers/ListQuery/types.d.ts.map +1 -0
  69. package/dist/providers/ListQuery/types.js +2 -0
  70. package/dist/providers/ListQuery/types.js.map +1 -0
  71. package/dist/providers/RouteTransition/ProgressBar/index.scss +19 -17
  72. package/dist/styles.css +1 -1
  73. package/dist/utilities/copyDataFromLocale.d.ts.map +1 -1
  74. package/dist/utilities/copyDataFromLocale.js +6 -2
  75. package/dist/utilities/copyDataFromLocale.js.map +1 -1
  76. package/dist/utilities/handleFormStateLocking.d.ts.map +1 -1
  77. package/dist/utilities/handleFormStateLocking.js +4 -2
  78. package/dist/utilities/handleFormStateLocking.js.map +1 -1
  79. package/dist/views/List/index.d.ts.map +1 -1
  80. package/dist/views/List/index.js +0 -7
  81. package/dist/views/List/index.js.map +1 -1
  82. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getTranslation","React","useMemo","useEffectEvent","useListQuery","useTranslation","Button","Condition","fieldTypes","reduceFields","transformWhereQuery","validateWhereQuery","baseClass","WhereBuilder","props","collectionPluralLabel","fields","renderedFilters","resolvedFilterOptions","i18n","t","reducedFields","handleWhereChange","query","shouldUpdateQuery","setShouldUpdateQuery","useState","conditions","setConditions","whereFromSearch","where","or","transformedWhere","console","warn","JSON","stringify","addCondition","useCallback","andIndex","field","orIndex","relation","newConditions","defaultOperator","type","operators","value","and","splice","undefined","push","updateCondition","operator","incomingOperator","valueArg","existingRowCondition","defaults","newRowCondition","removeCondition","length","handleChange","useEffect","_jsxs","className","Fragment","_jsx","label","map","compoundOrKey","Array","isArray","_","condition","fieldName","Object","keys","filterOptions","get","RenderedFilter","buttonStyle","icon","iconPosition","iconStyle","onClick","find","admin","disableListFilter"],"sources":["../../../src/elements/WhereBuilder/index.tsx"],"sourcesContent":["'use client'\nimport type { Operator, Where } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useMemo } from 'react'\n\nimport type { AddCondition, UpdateCondition, WhereBuilderProps } from './types.js'\n\nimport { useEffectEvent } from '../../hooks/useEffectEvent.js'\nimport { useListQuery } from '../../providers/ListQuery/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { Button } from '../Button/index.js'\nimport { Condition } from './Condition/index.js'\nimport fieldTypes from './field-types.js'\nimport { reduceFields } from './reduceFields.js'\nimport './index.scss'\nimport { transformWhereQuery } from './transformWhereQuery.js'\nimport validateWhereQuery from './validateWhereQuery.js'\n\nconst baseClass = 'where-builder'\n\nexport { WhereBuilderProps }\n\n/**\n * The WhereBuilder component is used to render the filter controls for a collection's list view.\n * It is part of the {@link ListControls} component which is used to render the controls (search, filter, where).\n */\nexport const WhereBuilder: React.FC<WhereBuilderProps> = (props) => {\n const { collectionPluralLabel, fields, renderedFilters, resolvedFilterOptions } = props\n const { i18n, t } = useTranslation()\n\n const reducedFields = useMemo(() => reduceFields({ fields, i18n }), [fields, i18n])\n\n const { handleWhereChange, query } = useListQuery()\n const [shouldUpdateQuery, setShouldUpdateQuery] = React.useState(false)\n\n const [conditions, setConditions] = React.useState<Where[]>(() => {\n const whereFromSearch = query.where\n\n if (whereFromSearch) {\n if (validateWhereQuery(whereFromSearch)) {\n return whereFromSearch.or\n }\n\n // Transform the where query to be in the right format. This will transform something simple like [text][equals]=example%20post to the right format\n const transformedWhere = transformWhereQuery(whereFromSearch)\n\n if (validateWhereQuery(transformedWhere)) {\n return transformedWhere.or\n }\n\n console.warn(`Invalid where query in URL: ${JSON.stringify(whereFromSearch)}`) // eslint-disable-line no-console\n }\n\n return []\n })\n\n const addCondition: AddCondition = React.useCallback(\n ({ andIndex, field, orIndex, relation }) => {\n const newConditions = [...conditions]\n\n const defaultOperator = fieldTypes[field.field.type].operators[0].value\n\n if (relation === 'and') {\n newConditions[orIndex].and.splice(andIndex, 0, {\n [field.value]: {\n [defaultOperator]: undefined,\n },\n })\n } else {\n newConditions.push({\n and: [\n {\n [field.value]: {\n [defaultOperator]: undefined,\n },\n },\n ],\n })\n }\n\n setConditions(newConditions)\n },\n [conditions],\n )\n\n const updateCondition: UpdateCondition = React.useCallback(\n ({ andIndex, field, operator: incomingOperator, orIndex, value: valueArg }) => {\n const existingRowCondition = conditions[orIndex].and[andIndex]\n\n const defaults = fieldTypes[field.field.type]\n const operator = incomingOperator || defaults.operators[0].value\n\n if (typeof existingRowCondition === 'object' && field.value) {\n const value = valueArg ?? existingRowCondition?.[operator]\n\n const newRowCondition = {\n [field.value]: { [operator]: value },\n }\n\n const newConditions = [...conditions]\n newConditions[orIndex].and[andIndex] = newRowCondition\n\n setConditions(newConditions)\n setShouldUpdateQuery(true)\n }\n },\n [conditions],\n )\n\n const removeCondition = React.useCallback(\n ({ andIndex, orIndex }) => {\n const newConditions = [...conditions]\n newConditions[orIndex].and.splice(andIndex, 1)\n\n if (newConditions[orIndex].and.length === 0) {\n newConditions.splice(orIndex, 1)\n }\n\n setConditions(newConditions)\n setShouldUpdateQuery(true)\n },\n [conditions],\n )\n\n const handleChange = useEffectEvent(async (conditions: Where[]) => {\n if (shouldUpdateQuery) {\n await handleWhereChange({ or: conditions })\n setShouldUpdateQuery(false)\n }\n })\n\n React.useEffect(() => {\n void handleChange(conditions)\n }, [conditions])\n\n return (\n <div className={baseClass}>\n {conditions.length > 0 && (\n <React.Fragment>\n <div className={`${baseClass}__label`}>\n {t('general:filterWhere', { label: getTranslation(collectionPluralLabel, i18n) })}\n </div>\n <ul className={`${baseClass}__or-filters`}>\n {conditions.map((or, orIndex) => {\n const compoundOrKey = `${orIndex}_${Array.isArray(or?.and) ? or.and.length : ''}`\n\n return (\n <li key={compoundOrKey}>\n {orIndex !== 0 && <div className={`${baseClass}__label`}>{t('general:or')}</div>}\n <ul className={`${baseClass}__and-filters`}>\n {Array.isArray(or?.and) &&\n or.and.map((_, andIndex) => {\n const condition = conditions[orIndex].and[andIndex]\n const fieldName = Object.keys(condition)[0]\n\n const operator =\n (Object.keys(condition?.[fieldName] || {})?.[0] as Operator) || undefined\n\n const value = condition?.[fieldName]?.[operator] || undefined\n\n return (\n <li key={andIndex}>\n {andIndex !== 0 && (\n <div className={`${baseClass}__label`}>{t('general:and')}</div>\n )}\n <Condition\n addCondition={addCondition}\n andIndex={andIndex}\n fieldName={fieldName}\n filterOptions={resolvedFilterOptions?.get(fieldName)}\n operator={operator}\n orIndex={orIndex}\n reducedFields={reducedFields}\n removeCondition={removeCondition}\n RenderedFilter={renderedFilters?.get(fieldName)}\n updateCondition={updateCondition}\n value={value}\n />\n </li>\n )\n })}\n </ul>\n </li>\n )\n })}\n </ul>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__add-or`}\n icon=\"plus\"\n iconPosition=\"left\"\n iconStyle=\"with-border\"\n onClick={() => {\n addCondition({\n andIndex: 0,\n field: reducedFields[0],\n orIndex: conditions.length,\n relation: 'or',\n })\n }}\n >\n {t('general:or')}\n </Button>\n </React.Fragment>\n )}\n {conditions.length === 0 && (\n <div className={`${baseClass}__no-filters`}>\n <div className={`${baseClass}__label`}>{t('general:noFiltersSet')}</div>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__add-first-filter`}\n icon=\"plus\"\n iconPosition=\"left\"\n iconStyle=\"with-border\"\n onClick={() => {\n if (reducedFields.length > 0) {\n addCondition({\n andIndex: 0,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex: conditions.length,\n relation: 'or',\n })\n }\n }}\n >\n {t('general:addFilter')}\n </Button>\n </div>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,OAAO,QAAQ;AAI/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,SAAS,QAAQ;AAC1B,OAAOC,UAAA,MAAgB;AACvB,SAASC,YAAY,QAAQ;AAC7B,OAAO;AACP,SAASC,mBAAmB,QAAQ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BAECtB,CAAA,CAAE;;;;AAMf","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["getTranslation","React","useMemo","useListQuery","useTranslation","Button","Condition","fieldTypes","reduceFields","transformWhereQuery","validateWhereQuery","baseClass","WhereBuilder","props","collectionPluralLabel","fields","renderedFilters","resolvedFilterOptions","i18n","t","reducedFields","handleWhereChange","query","conditions","whereFromSearch","where","or","transformedWhere","console","warn","JSON","stringify","addCondition","useCallback","andIndex","field","orIndex","relation","newConditions","defaultOperator","type","operators","value","and","splice","undefined","push","updateCondition","operator","incomingOperator","valueArg","existingRowCondition","defaults","newRowCondition","removeCondition","length","_jsxs","className","Fragment","_jsx","label","map","compoundOrKey","Array","isArray","_","condition","fieldName","Object","keys","filterOptions","get","RenderedFilter","buttonStyle","icon","iconPosition","iconStyle","onClick","find","admin","disableListFilter"],"sources":["../../../src/elements/WhereBuilder/index.tsx"],"sourcesContent":["'use client'\nimport type { Operator } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useMemo } from 'react'\n\nimport type { AddCondition, RemoveCondition, UpdateCondition, WhereBuilderProps } from './types.js'\n\nimport { useListQuery } from '../../providers/ListQuery/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { Button } from '../Button/index.js'\nimport { Condition } from './Condition/index.js'\nimport fieldTypes from './field-types.js'\nimport { reduceFields } from './reduceFields.js'\nimport { transformWhereQuery } from './transformWhereQuery.js'\nimport validateWhereQuery from './validateWhereQuery.js'\nimport './index.scss'\n\nconst baseClass = 'where-builder'\n\nexport { WhereBuilderProps }\n\n/**\n * The WhereBuilder component is used to render the filter controls for a collection's list view.\n * It is part of the {@link ListControls} component which is used to render the controls (search, filter, where).\n */\nexport const WhereBuilder: React.FC<WhereBuilderProps> = (props) => {\n const { collectionPluralLabel, fields, renderedFilters, resolvedFilterOptions } = props\n const { i18n, t } = useTranslation()\n\n const reducedFields = useMemo(() => reduceFields({ fields, i18n }), [fields, i18n])\n\n const { handleWhereChange, query } = useListQuery()\n\n const conditions = useMemo(() => {\n const whereFromSearch = query.where\n\n if (whereFromSearch) {\n if (validateWhereQuery(whereFromSearch)) {\n return whereFromSearch.or\n }\n\n // Transform the where query to be in the right format. This will transform something simple like [text][equals]=example%20post to the right format\n const transformedWhere = transformWhereQuery(whereFromSearch)\n\n if (validateWhereQuery(transformedWhere)) {\n return transformedWhere.or\n }\n\n console.warn(`Invalid where query in URL: ${JSON.stringify(whereFromSearch)}`) // eslint-disable-line no-console\n }\n\n return []\n }, [query.where])\n\n const addCondition: AddCondition = React.useCallback(\n async ({ andIndex, field, orIndex, relation }) => {\n const newConditions = [...conditions]\n\n const defaultOperator = fieldTypes[field.field.type].operators[0].value\n\n if (relation === 'and') {\n newConditions[orIndex].and.splice(andIndex, 0, {\n [field.value]: {\n [defaultOperator]: undefined,\n },\n })\n } else {\n newConditions.push({\n and: [\n {\n [field.value]: {\n [defaultOperator]: undefined,\n },\n },\n ],\n })\n }\n\n await handleWhereChange({ or: newConditions })\n },\n [conditions, handleWhereChange],\n )\n\n const updateCondition: UpdateCondition = React.useCallback(\n async ({ andIndex, field, operator: incomingOperator, orIndex, value: valueArg }) => {\n const existingRowCondition = conditions[orIndex].and[andIndex]\n\n const defaults = fieldTypes[field.field.type]\n const operator = incomingOperator || defaults.operators[0].value\n\n if (typeof existingRowCondition === 'object' && field.value) {\n const value = valueArg ?? existingRowCondition?.[operator]\n\n const newRowCondition = {\n [field.value]: { [operator]: value },\n }\n\n const newConditions = [...conditions]\n newConditions[orIndex].and[andIndex] = newRowCondition\n\n await handleWhereChange({ or: newConditions })\n }\n },\n [conditions, handleWhereChange],\n )\n\n const removeCondition: RemoveCondition = React.useCallback(\n async ({ andIndex, orIndex }) => {\n const newConditions = [...conditions]\n newConditions[orIndex].and.splice(andIndex, 1)\n\n if (newConditions[orIndex].and.length === 0) {\n newConditions.splice(orIndex, 1)\n }\n\n await handleWhereChange({ or: newConditions })\n },\n [conditions, handleWhereChange],\n )\n\n return (\n <div className={baseClass}>\n {conditions.length > 0 && (\n <React.Fragment>\n <div className={`${baseClass}__label`}>\n {t('general:filterWhere', { label: getTranslation(collectionPluralLabel, i18n) })}\n </div>\n <ul className={`${baseClass}__or-filters`}>\n {conditions.map((or, orIndex) => {\n const compoundOrKey = `${orIndex}_${Array.isArray(or?.and) ? or.and.length : ''}`\n\n return (\n <li key={compoundOrKey}>\n {orIndex !== 0 && <div className={`${baseClass}__label`}>{t('general:or')}</div>}\n <ul className={`${baseClass}__and-filters`}>\n {Array.isArray(or?.and) &&\n or.and.map((_, andIndex) => {\n const condition = conditions[orIndex].and[andIndex]\n const fieldName = Object.keys(condition)[0]\n\n const operator =\n (Object.keys(condition?.[fieldName] || {})?.[0] as Operator) || undefined\n\n const value = condition?.[fieldName]?.[operator] || undefined\n\n return (\n <li key={andIndex}>\n {andIndex !== 0 && (\n <div className={`${baseClass}__label`}>{t('general:and')}</div>\n )}\n <Condition\n addCondition={addCondition}\n andIndex={andIndex}\n fieldName={fieldName}\n filterOptions={resolvedFilterOptions?.get(fieldName)}\n operator={operator}\n orIndex={orIndex}\n reducedFields={reducedFields}\n removeCondition={removeCondition}\n RenderedFilter={renderedFilters?.get(fieldName)}\n updateCondition={updateCondition}\n value={value}\n />\n </li>\n )\n })}\n </ul>\n </li>\n )\n })}\n </ul>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__add-or`}\n icon=\"plus\"\n iconPosition=\"left\"\n iconStyle=\"with-border\"\n onClick={async () => {\n await addCondition({\n andIndex: 0,\n field: reducedFields[0],\n orIndex: conditions.length,\n relation: 'or',\n })\n }}\n >\n {t('general:or')}\n </Button>\n </React.Fragment>\n )}\n {conditions.length === 0 && (\n <div className={`${baseClass}__no-filters`}>\n <div className={`${baseClass}__label`}>{t('general:noFiltersSet')}</div>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__add-first-filter`}\n icon=\"plus\"\n iconPosition=\"left\"\n iconStyle=\"with-border\"\n onClick={async () => {\n if (reducedFields.length > 0) {\n await addCondition({\n andIndex: 0,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex: conditions.length,\n relation: 'or',\n })\n }\n }}\n >\n {t('general:addFilter')}\n </Button>\n </div>\n )}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,OAAO,QAAQ;AAI/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,SAAS,QAAQ;AAC1B,OAAOC,UAAA,MAAgB;AACvB,SAASC,YAAY,QAAQ;AAC7B,SAASC,mBAAmB,QAAQ;AACpC,OAAOC,kBAAA,MAAwB;AAC/B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAIlB;;;;AAIA,OAAO,MAAMC,YAAA,GAA6CC,KAAA;EACxD,MAAM;IAAEC,qBAAqB;IAAEC,MAAM;IAAEC,eAAe;IAAEC;EAAqB,CAAE,GAAGJ,KAAA;EAClF,MAAM;IAAEK,IAAI;IAAEC;EAAC,CAAE,GAAGf,cAAA;EAEpB,MAAMgB,aAAA,GAAgBlB,OAAA,CAAQ,MAAMM,YAAA,CAAa;IAAEO,MAAA;IAAQG;EAAK,IAAI,CAACH,MAAA,EAAQG,IAAA,CAAK;EAElF,MAAM;IAAEG,iBAAiB;IAAEC;EAAK,CAAE,GAAGnB,YAAA;EAErC,MAAMoB,UAAA,GAAarB,OAAA,CAAQ;IACzB,MAAMsB,eAAA,GAAkBF,KAAA,CAAMG,KAAK;IAEnC,IAAID,eAAA,EAAiB;MACnB,IAAId,kBAAA,CAAmBc,eAAA,GAAkB;QACvC,OAAOA,eAAA,CAAgBE,EAAE;MAC3B;MAEA;MACA,MAAMC,gBAAA,GAAmBlB,mBAAA,CAAoBe,eAAA;MAE7C,IAAId,kBAAA,CAAmBiB,gBAAA,GAAmB;QACxC,OAAOA,gBAAA,CAAiBD,EAAE;MAC5B;MAEAE,OAAA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,KAAA,EAAOf,aAAA,CAAc0D,IAAI,CAAE3C,OAAA,IAAU,CAACA,OAAA,CAAMA,KAAK,CAAC4C,KAAK,EAAEC,iBAAA;cACzD5C,OAAA,EAASb,UAAA,CAAWgC,MAAM;cAC1BlB,QAAA,EAAU;YACZ;UACF;QACF;kBAEClB,CAAA,CAAE;;;;AAMf","ignoreList":[]}
@@ -45,12 +45,16 @@ export type AddCondition = ({ andIndex, field, orIndex, relation, }: {
45
45
  field: ReducedField;
46
46
  orIndex: number;
47
47
  relation: 'and' | 'or';
48
- }) => void;
48
+ }) => Promise<void> | void;
49
49
  export type UpdateCondition = ({ andIndex, field, operator, orIndex, value, }: {
50
50
  andIndex: number;
51
51
  field: ReducedField;
52
52
  operator: string;
53
53
  orIndex: number;
54
54
  value: string;
55
- }) => void;
55
+ }) => Promise<void> | void;
56
+ export type RemoveCondition = ({ andIndex, orIndex, }: {
57
+ andIndex: number;
58
+ orIndex: number;
59
+ }) => Promise<void> | void;
56
60
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/elements/WhereBuilder/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EACR,qBAAqB,EACrB,yBAAyB,EACzB,KAAK,EACN,MAAM,SAAS,CAAA;AAEhB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,qBAAqB,EAAE,yBAAyB,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAA;IAC7E,QAAQ,CAAC,cAAc,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAA;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;IAC/B,QAAQ,CAAC,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;IACvD,QAAQ,CAAC,qBAAqB,CAAC,EAAE,GAAG,CAAC,MAAM,EA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AAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;AAE1B,MAAM,MAAM,eAAe,GAAG,CAAC,EAC7B,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/elements/WhereBuilder/types.ts"],"sourcesContent":["import type {\n ClientField,\n Operator,\n ResolvedFilterOptions,\n SanitizedCollectionConfig,\n Where,\n} from 'payload'\n\nexport type WhereBuilderProps = {\n readonly collectionPluralLabel: SanitizedCollectionConfig['labels']['plural']\n readonly collectionSlug: SanitizedCollectionConfig['slug']\n readonly fields?: ClientField[]\n readonly renderedFilters?: Map<string, React.ReactNode>\n readonly resolvedFilterOptions?: Map<string, ResolvedFilterOptions>\n}\n\nexport type ReducedField = {\n field: ClientField\n label: React.ReactNode\n operators: {\n label: string\n value: Operator\n }[]\n value: string\n}\n\nexport type Relation = 'and' | 'or'\n\nexport type ADD = {\n andIndex?: number\n field: string\n orIndex?: number\n relation?: Relation\n type: 'add'\n}\n\nexport type REMOVE = {\n andIndex: number\n orIndex: number\n type: 'remove'\n}\n\nexport type UPDATE = {\n andIndex: number\n field?: string\n operator?: string\n orIndex: number\n type: 'update'\n value?: unknown\n}\n\nexport type Action = ADD | REMOVE | UPDATE\n\nexport type State = {\n or: Where[]\n}\n\nexport type AddCondition = ({\n andIndex,\n field,\n orIndex,\n relation,\n}: {\n andIndex: number\n field: ReducedField\n orIndex: number\n relation: 'and' | 'or'\n}) => void\n\nexport type UpdateCondition = ({\n andIndex,\n field,\n operator,\n orIndex,\n value,\n}: {\n andIndex: number\n field: ReducedField\n operator: string\n orIndex: number\n value: string\n}) => void\n"],"mappings":"AAqEA","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/elements/WhereBuilder/types.ts"],"sourcesContent":["import type {\n ClientField,\n Operator,\n ResolvedFilterOptions,\n SanitizedCollectionConfig,\n Where,\n} from 'payload'\n\nexport type WhereBuilderProps = {\n readonly collectionPluralLabel: SanitizedCollectionConfig['labels']['plural']\n readonly collectionSlug: SanitizedCollectionConfig['slug']\n readonly fields?: ClientField[]\n readonly renderedFilters?: Map<string, React.ReactNode>\n readonly resolvedFilterOptions?: Map<string, ResolvedFilterOptions>\n}\n\nexport type ReducedField = {\n field: ClientField\n label: React.ReactNode\n operators: {\n label: string\n value: Operator\n }[]\n value: string\n}\n\nexport type Relation = 'and' | 'or'\n\nexport type ADD = {\n andIndex?: number\n field: string\n orIndex?: number\n relation?: Relation\n type: 'add'\n}\n\nexport type REMOVE = {\n andIndex: number\n orIndex: number\n type: 'remove'\n}\n\nexport type UPDATE = {\n andIndex: number\n field?: string\n operator?: string\n orIndex: number\n type: 'update'\n value?: unknown\n}\n\nexport type Action = ADD | REMOVE | UPDATE\n\nexport type State = {\n or: Where[]\n}\n\nexport type AddCondition = ({\n andIndex,\n field,\n orIndex,\n relation,\n}: {\n andIndex: number\n field: ReducedField\n orIndex: number\n relation: 'and' | 'or'\n}) => Promise<void> | void\n\nexport type UpdateCondition = ({\n andIndex,\n field,\n operator,\n orIndex,\n value,\n}: {\n andIndex: number\n field: ReducedField\n operator: string\n orIndex: number\n value: string\n}) => Promise<void> | void\n\nexport type RemoveCondition = ({\n andIndex,\n orIndex,\n}: {\n andIndex: number\n orIndex: number\n}) => Promise<void> | void\n"],"mappings":"AAmFA","ignoreList":[]}