@payloadcms/ui 3.62.0-canary.2 → 3.62.0-canary.4
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/WhereBuilder/Condition/Date/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Date/index.js +20 -11
- package/dist/elements/WhereBuilder/Condition/Date/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Number/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Number/index.js +19 -13
- package/dist/elements/WhereBuilder/Condition/Number/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js +3 -0
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/elements/WhereBuilder/field-types.d.ts +12 -2
- package/dist/elements/WhereBuilder/field-types.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/field-types.js +30 -12
- 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 +22 -23
- package/dist/elements/WhereBuilder/index.js.map +1 -1
- package/dist/elements/WhereBuilder/types.d.ts +2 -1
- package/dist/elements/WhereBuilder/types.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/types.js.map +1 -1
- package/dist/exports/client/index.js +12 -12
- package/dist/exports/client/index.js.map +3 -3
- package/dist/utilities/reduceFieldsToOptions.d.ts.map +1 -1
- package/dist/utilities/reduceFieldsToOptions.js +9 -5
- package/dist/utilities/reduceFieldsToOptions.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/WhereBuilder/Condition/Date/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/WhereBuilder/Condition/Date/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,eAAe,IAAI,KAAK,EAAE,MAAM,YAAY,CAAA;AAO1D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAetC,CAAA"}
|
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
4
5
|
import React from 'react';
|
|
6
|
+
import { useTranslation } from '../../../../providers/Translation/index.js';
|
|
5
7
|
import { DatePickerField } from '../../../DatePicker/index.js';
|
|
6
8
|
const baseClass = 'condition-value-date';
|
|
7
|
-
export const DateFilter =
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
export const DateFilter = t0 => {
|
|
10
|
+
const {
|
|
11
|
+
disabled,
|
|
12
|
+
field: t1,
|
|
13
|
+
onChange,
|
|
14
|
+
value
|
|
15
|
+
} = t0;
|
|
16
|
+
const {
|
|
10
17
|
admin
|
|
11
|
-
}
|
|
12
|
-
onChange,
|
|
13
|
-
value
|
|
14
|
-
}) => {
|
|
18
|
+
} = t1;
|
|
15
19
|
const {
|
|
16
20
|
date
|
|
17
21
|
} = admin || {};
|
|
18
|
-
|
|
22
|
+
const {
|
|
23
|
+
i18n,
|
|
24
|
+
t
|
|
25
|
+
} = useTranslation();
|
|
26
|
+
return _jsx("div", {
|
|
19
27
|
className: baseClass,
|
|
20
|
-
children:
|
|
28
|
+
children: _jsx(DatePickerField, {
|
|
21
29
|
...date,
|
|
22
|
-
onChange
|
|
30
|
+
onChange,
|
|
31
|
+
placeholder: getTranslation(admin.placeholder, i18n) || t("general:enterAValue"),
|
|
23
32
|
readOnly: disabled,
|
|
24
|
-
value
|
|
33
|
+
value
|
|
25
34
|
})
|
|
26
35
|
});
|
|
27
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","DatePickerField","baseClass","DateFilter","disabled","field","
|
|
1
|
+
{"version":3,"file":"index.js","names":["getTranslation","React","useTranslation","DatePickerField","baseClass","DateFilter","t0","disabled","field","t1","onChange","value","admin","date","i18n","t","_jsx","className","children","placeholder","readOnly"],"sources":["../../../../../src/elements/WhereBuilder/Condition/Date/index.tsx"],"sourcesContent":["'use client'\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport type { DateFilterProps as Props } from './types.js'\n\nimport { useTranslation } from '../../../../providers/Translation/index.js'\nimport { DatePickerField } from '../../../DatePicker/index.js'\n\nconst baseClass = 'condition-value-date'\n\nexport const DateFilter: React.FC<Props> = ({ disabled, field: { admin }, onChange, value }) => {\n const { date } = admin || {}\n const { i18n, t } = useTranslation()\n\n return (\n <div className={baseClass}>\n <DatePickerField\n {...date}\n onChange={onChange}\n placeholder={getTranslation(admin.placeholder, i18n) || t('general:enterAValue')}\n readOnly={disabled}\n value={value as Date}\n />\n </div>\n )\n}\n"],"mappings":"AAAA;;;AACA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAIlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAEhC,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,UAAA,GAA8BC,EAAA;EAAC;IAAAC,QAAA;IAAAC,KAAA,EAAAC,EAAA;IAAAC,QAAA;IAAAC;EAAA,IAAAL,EAA+C;EAA5B;IAAAM;EAAA,IAAAH,EAAS;EACtE;IAAAI;EAAA,IAAiBD,KAAA,MAAU;EAC3B;IAAAE,IAAA;IAAAC;EAAA,IAAoBb,cAAA;EAAA,OAGlBc,IAAA,CAAC;IAAAC,SAAA,EAAAb,SAAA;IAAAc,QAAA,EACCF,IAAA,CAAAb,eAAA;MAAA,GACMU,IAAI;MAAAH,QAAA;MAAAS,WAAA,EAEKnB,cAAA,CAAeY,KAAA,CAAAO,WAAA,EAAmBL,IAAA,KAASC,CAAA,CAAE;MAAAK,QAAA,EAChDb,QAAA;MAAAI;IAAA,C;;CAKlB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/WhereBuilder/Condition/Number/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/elements/WhereBuilder/Condition/Number/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,iBAAiB,IAAI,KAAK,EAAE,MAAM,YAAY,CAAA;AAI5D,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA+ExC,CAAA"}
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
import { useTranslation } from '../../../../providers/Translation/index.js';
|
|
7
8
|
import { ReactSelect } from '../../../ReactSelect/index.js';
|
|
8
9
|
import './index.scss';
|
|
9
10
|
const baseClass = 'condition-value-number';
|
|
10
11
|
export const NumberFilter = props => {
|
|
11
|
-
const $ = _c(
|
|
12
|
+
const $ = _c(20);
|
|
12
13
|
const {
|
|
13
14
|
disabled,
|
|
14
15
|
field: t0,
|
|
@@ -17,9 +18,11 @@ export const NumberFilter = props => {
|
|
|
17
18
|
value
|
|
18
19
|
} = props;
|
|
19
20
|
const {
|
|
21
|
+
admin,
|
|
20
22
|
hasMany
|
|
21
23
|
} = t0;
|
|
22
24
|
const {
|
|
25
|
+
i18n,
|
|
23
26
|
t
|
|
24
27
|
} = useTranslation();
|
|
25
28
|
let t1;
|
|
@@ -84,7 +87,8 @@ export const NumberFilter = props => {
|
|
|
84
87
|
}
|
|
85
88
|
React.useEffect(t4, t5);
|
|
86
89
|
let t6;
|
|
87
|
-
if ($[10] !==
|
|
90
|
+
if ($[10] !== admin?.placeholder || $[11] !== disabled || $[12] !== i18n || $[13] !== isMulti || $[14] !== onChange || $[15] !== onSelect || $[16] !== t || $[17] !== value || $[18] !== valueToRender) {
|
|
91
|
+
const placeholder = getTranslation(admin?.placeholder, i18n) || t("general:enterAValue");
|
|
88
92
|
t6 = isMulti ? _jsx(ReactSelect, {
|
|
89
93
|
disabled,
|
|
90
94
|
isClearable: true,
|
|
@@ -94,26 +98,28 @@ export const NumberFilter = props => {
|
|
|
94
98
|
numberOnly: true,
|
|
95
99
|
onChange: onSelect,
|
|
96
100
|
options: [],
|
|
97
|
-
placeholder
|
|
101
|
+
placeholder,
|
|
98
102
|
value: valueToRender || []
|
|
99
103
|
}) : _jsx("input", {
|
|
100
104
|
className: baseClass,
|
|
101
105
|
disabled,
|
|
102
106
|
onChange: e => onChange(e.target.value),
|
|
103
|
-
placeholder
|
|
107
|
+
placeholder,
|
|
104
108
|
type: "number",
|
|
105
109
|
value
|
|
106
110
|
});
|
|
107
|
-
$[10] =
|
|
108
|
-
$[11] =
|
|
109
|
-
$[12] =
|
|
110
|
-
$[13] =
|
|
111
|
-
$[14] =
|
|
112
|
-
$[15] =
|
|
113
|
-
$[16] =
|
|
114
|
-
$[17] =
|
|
111
|
+
$[10] = admin?.placeholder;
|
|
112
|
+
$[11] = disabled;
|
|
113
|
+
$[12] = i18n;
|
|
114
|
+
$[13] = isMulti;
|
|
115
|
+
$[14] = onChange;
|
|
116
|
+
$[15] = onSelect;
|
|
117
|
+
$[16] = t;
|
|
118
|
+
$[17] = value;
|
|
119
|
+
$[18] = valueToRender;
|
|
120
|
+
$[19] = t6;
|
|
115
121
|
} else {
|
|
116
|
-
t6 = $[
|
|
122
|
+
t6 = $[19];
|
|
117
123
|
}
|
|
118
124
|
return t6;
|
|
119
125
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","React","useTranslation","ReactSelect","baseClass","NumberFilter","props","$","disabled","field","t0","onChange","operator","value","hasMany","t","t1","includes","isMulti","t2","Symbol","for","valueToRender","setValueToRender","useState","t3","selectedOption","newValue","Array","isArray","map","_temp","onSelect","t4","t5","_temp2","useEffect","t6","_jsx","isClearable","isCreatable","isSortable","numberOnly","options","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","getTranslation","React","useTranslation","ReactSelect","baseClass","NumberFilter","props","$","disabled","field","t0","onChange","operator","value","admin","hasMany","i18n","t","t1","includes","isMulti","t2","Symbol","for","valueToRender","setValueToRender","useState","t3","selectedOption","newValue","Array","isArray","map","_temp","onSelect","t4","t5","_temp2","useEffect","t6","placeholder","_jsx","isClearable","isCreatable","isSortable","numberOnly","options","className","e","target","type","option","Number","val","index","id","label","toString"],"sources":["../../../../../src/elements/WhereBuilder/Condition/Number/index.tsx"],"sourcesContent":["'use client'\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport type { NumberFilterProps as Props } from './types.js'\n\nimport { useTranslation } from '../../../../providers/Translation/index.js'\nimport { ReactSelect } from '../../../ReactSelect/index.js'\nimport './index.scss'\n\nconst baseClass = 'condition-value-number'\n\nexport const NumberFilter: React.FC<Props> = (props) => {\n const {\n disabled,\n field: { admin, hasMany },\n onChange,\n operator,\n value,\n } = props\n\n const { i18n, t } = useTranslation()\n\n const isMulti = ['in', 'not_in'].includes(operator) || hasMany\n\n const [valueToRender, setValueToRender] = React.useState<\n { id: string; label: string; value: { value: number } }[]\n >([])\n\n const onSelect = React.useCallback(\n (selectedOption) => {\n let newValue\n if (!selectedOption) {\n newValue = []\n } else if (isMulti) {\n if (Array.isArray(selectedOption)) {\n newValue = selectedOption.map((option) => Number(option.value?.value || option.value))\n } else {\n newValue = [Number(selectedOption.value?.value || selectedOption.value)]\n }\n }\n\n onChange(newValue)\n },\n [isMulti, onChange],\n )\n\n React.useEffect(() => {\n if (Array.isArray(value)) {\n setValueToRender(\n value.map((val, index) => {\n return {\n id: `${val}${index}`, // append index to avoid duplicate keys but allow duplicate numbers\n label: `${val}`,\n value: {\n toString: () => `${val}${index}`,\n value: (val as any)?.value || val,\n },\n }\n }),\n )\n } else {\n setValueToRender([])\n }\n }, [value])\n\n const placeholder = getTranslation(admin?.placeholder, i18n) || t('general:enterAValue')\n\n return isMulti ? (\n <ReactSelect\n disabled={disabled}\n isClearable\n isCreatable\n isMulti={isMulti}\n isSortable\n numberOnly\n onChange={onSelect}\n options={[]}\n placeholder={placeholder}\n value={valueToRender || []}\n />\n ) : (\n <input\n className={baseClass}\n disabled={disabled}\n onChange={(e) => onChange(e.target.value)}\n placeholder={placeholder}\n type=\"number\"\n value={value as number}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAIlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,WAAW,QAAQ;AAC5B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,YAAA,GAAgCC,KAAA;EAAA,MAAAC,CAAA,GAAAR,EAAA;EAC3C;IAAAS,QAAA;IAAAC,KAAA,EAAAC,EAAA;IAAAC,QAAA;IAAAC,QAAA;IAAAC;EAAA,IAMIP,KAAA;EAJK;IAAAQ,KAAA;IAAAC;EAAA,IAAAL,EAAkB;EAM3B;IAAAM,IAAA;IAAAC;EAAA,IAAoBf,cAAA;EAAA,IAAAgB,EAAA;EAAA,IAAAX,CAAA,QAAAQ,OAAA,IAAAR,CAAA,QAAAK,QAAA;IAEJM,EAAA,IAAC,MAAM,UAAAC,QAAA,CAAmBP,QAAA,KAAaG,OAAA;IAAAR,CAAA,MAAAQ,OAAA;IAAAR,CAAA,MAAAK,QAAA;IAAAL,CAAA,MAAAW,EAAA;EAAA;IAAAA,EAAA,GAAAX,CAAA;EAAA;EAAvD,MAAAa,OAAA,GAAgBF,EAAuC;E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AAAxC,KAAA;MAAA4C,QAAA,EAAAA,CAAA,KAEG,GAAGJ,GAAA,GAAMC,KAAA,EAAO;MAAAzC,KAAA,EACzBwC,GAAC,EAAAxC,KAAA,IAAsBwC;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,EACf,KAAK,EACN,MAAM,aAAa,CAAA;AAEpB,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAA;IAC7C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,aAAa,EAAE,YAAY,EAAE,CAAA;IACtC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,SAAS,CAAA;IACxC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CACtB,CAAA;AAED,OAAO,KAAK,EAAE,QAAQ,EAA2B,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAWvF,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,EACf,KAAK,EACN,MAAM,aAAa,CAAA;AAEpB,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAA;IAC7C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,aAAa,EAAE,YAAY,EAAE,CAAA;IACtC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,SAAS,CAAA;IACxC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CACtB,CAAA;AAED,OAAO,KAAK,EAAE,QAAQ,EAA2B,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAWvF,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAoLrC,CAAA"}
|
|
@@ -47,6 +47,7 @@ export const Condition = props => {
|
|
|
47
47
|
const updateValue = useEffectEvent(async debouncedValue_0 => {
|
|
48
48
|
if (operator) {
|
|
49
49
|
await updateCondition({
|
|
50
|
+
type: 'value',
|
|
50
51
|
andIndex,
|
|
51
52
|
field: reducedField,
|
|
52
53
|
operator,
|
|
@@ -62,6 +63,7 @@ export const Condition = props => {
|
|
|
62
63
|
const handleFieldChange = useCallback(async field_0 => {
|
|
63
64
|
setInternalValue(undefined);
|
|
64
65
|
await updateCondition({
|
|
66
|
+
type: 'field',
|
|
65
67
|
andIndex,
|
|
66
68
|
field: reducedFields.find(option => option.value === field_0.value),
|
|
67
69
|
operator,
|
|
@@ -79,6 +81,7 @@ export const Condition = props => {
|
|
|
79
81
|
setInternalValue(undefined);
|
|
80
82
|
}
|
|
81
83
|
await updateCondition({
|
|
84
|
+
type: 'operator',
|
|
82
85
|
andIndex,
|
|
83
86
|
field: reducedField,
|
|
84
87
|
operator: operator_0.value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","useDebounce","useEffectEvent","useTranslation","Button","ReactSelect","DefaultFilter","getOperatorValueTypes","baseClass","Condition","props","addCondition","andIndex","fieldPath","filterOptions","operator","orIndex","reducedFields","removeCondition","RenderedFilter","updateCondition","value","t","reducedField","find","field","internalValue","setInternalValue","debouncedValue","booleanSelect","includes","type","valueOptions","label","options","updateValue","disabled","admin","disableListFilter","handleFieldChange","undefined","option","handleOperatorChange","operatorValueTypes","validOperatorValue","isValidValue","_jsx","className","_jsxs","filterOption","inputValue","data","plainTextLabel","toLowerCase","isClearable","onChange","filter","operators","o","internalField","buttonStyle","icon","iconStyle","onClick","round","relation"],"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type {\n AddCondition,\n ReducedField,\n RemoveCondition,\n UpdateCondition,\n Value,\n} from '../types.js'\n\nexport type Props = {\n readonly addCondition: AddCondition\n readonly andIndex: number\n readonly fieldPath: string\n readonly filterOptions: ResolvedFilterOptions\n readonly operator: Operator\n readonly orIndex: number\n readonly reducedFields: ReducedField[]\n readonly removeCondition: RemoveCondition\n readonly RenderedFilter: React.ReactNode\n readonly updateCondition: UpdateCondition\n readonly value: Value\n}\n\nimport type { Operator, Option as PayloadOption, ResolvedFilterOptions } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { useDebounce } from '../../../hooks/useDebounce.js'\nimport { useEffectEvent } from '../../../hooks/useEffectEvent.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport { DefaultFilter } from './DefaultFilter/index.js'\nimport { getOperatorValueTypes } from './validOperators.js'\nimport './index.scss'\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldPath,\n filterOptions,\n operator,\n orIndex,\n reducedFields,\n removeCondition,\n RenderedFilter,\n updateCondition,\n value,\n } = props\n\n const { t } = useTranslation()\n\n const reducedField = reducedFields.find((field) => field.value === fieldPath)\n\n const [internalValue, setInternalValue] = useState<Value>(value)\n\n const debouncedValue = useDebounce(internalValue, 300)\n\n const booleanSelect = ['exists'].includes(operator) || reducedField?.field?.type === 'checkbox'\n\n let valueOptions: PayloadOption[] = []\n\n if (booleanSelect) {\n valueOptions = [\n { label: t('general:true'), value: 'true' },\n { label: t('general:false'), value: 'false' },\n ]\n } else if (reducedField?.field && 'options' in reducedField.field) {\n valueOptions = reducedField.field.options\n }\n\n const updateValue = useEffectEvent(async (debouncedValue) => {\n if (operator) {\n await updateCondition({\n andIndex,\n field: reducedField,\n operator,\n orIndex,\n value: debouncedValue === null ? '' : debouncedValue,\n })\n }\n })\n\n useEffect(() => {\n void updateValue(debouncedValue)\n }, [debouncedValue])\n\n const disabled =\n (!reducedField?.value && typeof reducedField?.value !== 'number') ||\n reducedField?.field?.admin?.disableListFilter\n\n const handleFieldChange = useCallback(\n async (field: Option<string>) => {\n setInternalValue(undefined)\n await updateCondition({\n andIndex,\n field: reducedFields.find((option) => option.value === field.value),\n operator,\n orIndex,\n value: undefined,\n })\n },\n [andIndex, operator, orIndex, reducedFields, updateCondition],\n )\n\n const handleOperatorChange = useCallback(\n async (operator: Option<Operator>) => {\n const operatorValueTypes = getOperatorValueTypes(reducedField.field.type)\n const validOperatorValue = operatorValueTypes[operator.value] || 'any'\n const isValidValue =\n validOperatorValue === 'any' ||\n typeof value === validOperatorValue ||\n (validOperatorValue === 'boolean' && (value === 'true' || value === 'false'))\n\n if (!isValidValue) {\n // if the current value is not valid for the new operator\n // reset the value before passing it to updateCondition\n setInternalValue(undefined)\n }\n\n await updateCondition({\n andIndex,\n field: reducedField,\n operator: operator.value,\n orIndex,\n value: isValidValue ? value : undefined,\n })\n },\n [andIndex, reducedField, orIndex, updateCondition, value],\n )\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__inputs`}>\n <div className={`${baseClass}__field`}>\n <ReactSelect\n disabled={disabled}\n filterOption={(option, inputValue) =>\n ((option?.data?.plainTextLabel as string) || option.label)\n .toLowerCase()\n .includes(inputValue.toLowerCase())\n }\n isClearable={false}\n onChange={handleFieldChange}\n options={reducedFields.filter((field) => !field.field.admin.disableListFilter)}\n value={\n reducedField || {\n value: reducedField?.value,\n }\n }\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={handleOperatorChange}\n options={reducedField?.operators}\n value={reducedField?.operators.find((o) => operator === o.value) || null}\n />\n </div>\n <div className={`${baseClass}__value`}>\n {RenderedFilter || (\n <DefaultFilter\n booleanSelect={booleanSelect}\n disabled={\n !operator || !reducedField || reducedField?.field?.admin?.disableListFilter\n }\n filterOptions={filterOptions}\n internalField={reducedField}\n onChange={setInternalValue}\n operator={operator}\n options={valueOptions}\n value={internalValue ?? ''}\n />\n )}\n </div>\n </div>\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-remove`}\n icon=\"x\"\n iconStyle=\"with-border\"\n onClick={() =>\n removeCondition({\n andIndex,\n orIndex,\n })\n }\n round\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-add`}\n icon=\"plus\"\n iconStyle=\"with-border\"\n onClick={() =>\n addCondition({\n andIndex: andIndex + 1,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex,\n relation: 'and',\n })\n }\n round\n />\n </div>\n </div>\n </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["React","useCallback","useEffect","useState","useDebounce","useEffectEvent","useTranslation","Button","ReactSelect","DefaultFilter","getOperatorValueTypes","baseClass","Condition","props","addCondition","andIndex","fieldPath","filterOptions","operator","orIndex","reducedFields","removeCondition","RenderedFilter","updateCondition","value","t","reducedField","find","field","internalValue","setInternalValue","debouncedValue","booleanSelect","includes","type","valueOptions","label","options","updateValue","disabled","admin","disableListFilter","handleFieldChange","undefined","option","handleOperatorChange","operatorValueTypes","validOperatorValue","isValidValue","_jsx","className","_jsxs","filterOption","inputValue","data","plainTextLabel","toLowerCase","isClearable","onChange","filter","operators","o","internalField","buttonStyle","icon","iconStyle","onClick","round","relation"],"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type {\n AddCondition,\n ReducedField,\n RemoveCondition,\n UpdateCondition,\n Value,\n} from '../types.js'\n\nexport type Props = {\n readonly addCondition: AddCondition\n readonly andIndex: number\n readonly fieldPath: string\n readonly filterOptions: ResolvedFilterOptions\n readonly operator: Operator\n readonly orIndex: number\n readonly reducedFields: ReducedField[]\n readonly removeCondition: RemoveCondition\n readonly RenderedFilter: React.ReactNode\n readonly updateCondition: UpdateCondition\n readonly value: Value\n}\n\nimport type { Operator, Option as PayloadOption, ResolvedFilterOptions } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { useDebounce } from '../../../hooks/useDebounce.js'\nimport { useEffectEvent } from '../../../hooks/useEffectEvent.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport { DefaultFilter } from './DefaultFilter/index.js'\nimport { getOperatorValueTypes } from './validOperators.js'\nimport './index.scss'\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldPath,\n filterOptions,\n operator,\n orIndex,\n reducedFields,\n removeCondition,\n RenderedFilter,\n updateCondition,\n value,\n } = props\n\n const { t } = useTranslation()\n\n const reducedField = reducedFields.find((field) => field.value === fieldPath)\n\n const [internalValue, setInternalValue] = useState<Value>(value)\n\n const debouncedValue = useDebounce(internalValue, 300)\n\n const booleanSelect = ['exists'].includes(operator) || reducedField?.field?.type === 'checkbox'\n\n let valueOptions: PayloadOption[] = []\n\n if (booleanSelect) {\n valueOptions = [\n { label: t('general:true'), value: 'true' },\n { label: t('general:false'), value: 'false' },\n ]\n } else if (reducedField?.field && 'options' in reducedField.field) {\n valueOptions = reducedField.field.options\n }\n\n const updateValue = useEffectEvent(async (debouncedValue) => {\n if (operator) {\n await updateCondition({\n type: 'value',\n andIndex,\n field: reducedField,\n operator,\n orIndex,\n value: debouncedValue === null ? '' : debouncedValue,\n })\n }\n })\n\n useEffect(() => {\n void updateValue(debouncedValue)\n }, [debouncedValue])\n\n const disabled =\n (!reducedField?.value && typeof reducedField?.value !== 'number') ||\n reducedField?.field?.admin?.disableListFilter\n\n const handleFieldChange = useCallback(\n async (field: Option<string>) => {\n setInternalValue(undefined)\n await updateCondition({\n type: 'field',\n andIndex,\n field: reducedFields.find((option) => option.value === field.value),\n operator,\n orIndex,\n value: undefined,\n })\n },\n [andIndex, operator, orIndex, reducedFields, updateCondition],\n )\n\n const handleOperatorChange = useCallback(\n async (operator: Option<Operator>) => {\n const operatorValueTypes = getOperatorValueTypes(reducedField.field.type)\n const validOperatorValue = operatorValueTypes[operator.value] || 'any'\n const isValidValue =\n validOperatorValue === 'any' ||\n typeof value === validOperatorValue ||\n (validOperatorValue === 'boolean' && (value === 'true' || value === 'false'))\n\n if (!isValidValue) {\n // if the current value is not valid for the new operator\n // reset the value before passing it to updateCondition\n setInternalValue(undefined)\n }\n\n await updateCondition({\n type: 'operator',\n andIndex,\n field: reducedField,\n operator: operator.value,\n orIndex,\n value: isValidValue ? value : undefined,\n })\n },\n [andIndex, reducedField, orIndex, updateCondition, value],\n )\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__inputs`}>\n <div className={`${baseClass}__field`}>\n <ReactSelect\n disabled={disabled}\n filterOption={(option, inputValue) =>\n ((option?.data?.plainTextLabel as string) || option.label)\n .toLowerCase()\n .includes(inputValue.toLowerCase())\n }\n isClearable={false}\n onChange={handleFieldChange}\n options={reducedFields.filter((field) => !field.field.admin.disableListFilter)}\n value={\n reducedField || {\n value: reducedField?.value,\n }\n }\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={handleOperatorChange}\n options={reducedField?.operators}\n value={reducedField?.operators.find((o) => operator === o.value) || null}\n />\n </div>\n <div className={`${baseClass}__value`}>\n {RenderedFilter || (\n <DefaultFilter\n booleanSelect={booleanSelect}\n disabled={\n !operator || !reducedField || reducedField?.field?.admin?.disableListFilter\n }\n filterOptions={filterOptions}\n internalField={reducedField}\n onChange={setInternalValue}\n operator={operator}\n options={valueOptions}\n value={internalValue ?? ''}\n />\n )}\n </div>\n </div>\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-remove`}\n icon=\"x\"\n iconStyle=\"with-border\"\n onClick={() =>\n removeCondition({\n andIndex,\n orIndex,\n })\n }\n round\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-add`}\n icon=\"plus\"\n iconStyle=\"with-border\"\n onClick={() =>\n addCondition({\n andIndex: andIndex + 1,\n field: reducedFields.find((field) => !field.field.admin?.disableListFilter),\n orIndex,\n relation: 'and',\n })\n }\n round\n />\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AA4BxD,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,WAAW,QAAQ;AAC5B,SAASC,aA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,SAAkB;oBAClCW,cAAA,iBACC2B,IAAA,CAACxC,aAAA;YACCuB,aAAA,EAAeA,aAAA;YACfO,QAAA,EACE,CAACrB,QAAA,IAAY,CAACQ,YAAA,IAAgBA,YAAA,EAAcE,KAAA,EAAOY,KAAA,EAAOC,iBAAA;YAE5DxB,aAAA,EAAeA,aAAA;YACf6C,aAAA,EAAepC,YAAA;YACfgC,QAAA,EAAU5B,gBAAA;YACVZ,QAAA,EAAUA,QAAA;YACVmB,OAAA,EAASF,YAAA;YACTX,KAAA,EAAOK,aAAA,IAAiB;;;uBAKhCsB,KAAA,CAAC;QAAID,SAAA,EAAW,GAAGvC,SAAA,WAAoB;gCACrCsC,IAAA,CAAC1C,MAAA;UACCwD,WAAA,EAAY;UACZb,SAAA,EAAW,GAAGvC,SAAA,kBAA2B;UACzCqD,IAAA,EAAK;UACLC,SAAA,EAAU;UACVC,OAAA,EAASA,CAAA,KACP7C,eAAA,CAAgB;YACdN,QAAA;YACAI;UACF;UAEFgD,KAAK;yBAEPlB,IAAA,CAAC1C,MAAA;UACCwD,WAAA,EAAY;UACZb,SAAA,EAAW,GAAGvC,SAAA,eAAwB;UACtCqD,IAAA,EAAK;UACLC,SAAA,EAAU;UACVC,OAAA,EAASA,CAAA,KACPpD,YAAA,CAAa;YACXC,QAAA,EAAUA,QAAA,GAAW;YACrBa,KAAA,EAAOR,aAAA,CAAcO,IAAI,CAAEC,OAAA,IAAU,CAACA,OAAA,CAAMA,KAAK,CAACY,KAAK,EAAEC,iBAAA;YACzDtB,OAAA;YACAiD,QAAA,EAAU;UACZ;UAEFD,KAAK;;;;;AAMjB","ignoreList":[]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { ClientField } from 'payload';
|
|
1
2
|
export declare const arrayOperators: {
|
|
2
3
|
label: string;
|
|
3
4
|
value: string;
|
|
4
5
|
}[];
|
|
5
|
-
declare const fieldTypeConditions: {
|
|
6
|
+
export declare const fieldTypeConditions: {
|
|
6
7
|
[key: string]: {
|
|
7
8
|
component: string;
|
|
8
9
|
operators: {
|
|
@@ -11,5 +12,14 @@ declare const fieldTypeConditions: {
|
|
|
11
12
|
}[];
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
|
-
export
|
|
15
|
+
export declare const getValidFieldOperators: ({ field, operator, }: {
|
|
16
|
+
field: ClientField;
|
|
17
|
+
operator?: string;
|
|
18
|
+
}) => {
|
|
19
|
+
validOperator: string;
|
|
20
|
+
validOperators: {
|
|
21
|
+
label: string;
|
|
22
|
+
value: string;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
15
25
|
//# sourceMappingURL=field-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-types.d.ts","sourceRoot":"","sources":["../../../src/elements/WhereBuilder/field-types.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"field-types.d.ts","sourceRoot":"","sources":["../../../src/elements/WhereBuilder/field-types.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAa1C,eAAO,MAAM,cAAc;;;GAS1B,CAAA;AA8DD,eAAO,MAAM,mBAAmB,EAAE;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,SAAS,EAAE,MAAM,CAAA;QACjB,SAAS,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAC9C,CAAA;CA0DF,CAAA;AAED,eAAO,MAAM,sBAAsB,yBAGhC;IACD,KAAK,EAAE,WAAW,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,KAAG;IACF,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE;QACd,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CAwBJ,CAAA"}
|
|
@@ -13,11 +13,12 @@ export const arrayOperators = [{
|
|
|
13
13
|
}, {
|
|
14
14
|
label: 'isNotIn',
|
|
15
15
|
value: 'not_in'
|
|
16
|
-
}
|
|
16
|
+
}];
|
|
17
|
+
const exists = {
|
|
17
18
|
label: 'exists',
|
|
18
19
|
value: 'exists'
|
|
19
|
-
}
|
|
20
|
-
const base = [...equalsOperators, ...arrayOperators];
|
|
20
|
+
};
|
|
21
|
+
const base = [...equalsOperators, ...arrayOperators, exists];
|
|
21
22
|
const numeric = [...base, {
|
|
22
23
|
label: 'isGreaterThan',
|
|
23
24
|
value: 'greater_than'
|
|
@@ -32,9 +33,6 @@ const numeric = [...base, {
|
|
|
32
33
|
value: 'greater_than_equal'
|
|
33
34
|
}];
|
|
34
35
|
const geo = [...equalsOperators, {
|
|
35
|
-
label: 'exists',
|
|
36
|
-
value: 'exists'
|
|
37
|
-
}, {
|
|
38
36
|
label: 'near',
|
|
39
37
|
value: 'near'
|
|
40
38
|
}];
|
|
@@ -58,10 +56,10 @@ const contains = {
|
|
|
58
56
|
label: 'contains',
|
|
59
57
|
value: 'contains'
|
|
60
58
|
};
|
|
61
|
-
const fieldTypeConditions = {
|
|
59
|
+
export const fieldTypeConditions = {
|
|
62
60
|
checkbox: {
|
|
63
61
|
component: 'Text',
|
|
64
|
-
operators: equalsOperators
|
|
62
|
+
operators: [...equalsOperators, exists]
|
|
65
63
|
},
|
|
66
64
|
code: {
|
|
67
65
|
component: 'Text',
|
|
@@ -69,7 +67,7 @@ const fieldTypeConditions = {
|
|
|
69
67
|
},
|
|
70
68
|
date: {
|
|
71
69
|
component: 'Date',
|
|
72
|
-
operators: [...
|
|
70
|
+
operators: [...numeric, exists]
|
|
73
71
|
},
|
|
74
72
|
email: {
|
|
75
73
|
component: 'Text',
|
|
@@ -81,11 +79,11 @@ const fieldTypeConditions = {
|
|
|
81
79
|
},
|
|
82
80
|
number: {
|
|
83
81
|
component: 'Number',
|
|
84
|
-
operators: [...
|
|
82
|
+
operators: [...numeric, exists]
|
|
85
83
|
},
|
|
86
84
|
point: {
|
|
87
85
|
component: 'Point',
|
|
88
|
-
operators: [...geo, within, intersects]
|
|
86
|
+
operators: [...geo, exists, within, intersects]
|
|
89
87
|
},
|
|
90
88
|
radio: {
|
|
91
89
|
component: 'Select',
|
|
@@ -116,5 +114,25 @@ const fieldTypeConditions = {
|
|
|
116
114
|
operators: [...base]
|
|
117
115
|
}
|
|
118
116
|
};
|
|
119
|
-
export
|
|
117
|
+
export const getValidFieldOperators = ({
|
|
118
|
+
field,
|
|
119
|
+
operator
|
|
120
|
+
}) => {
|
|
121
|
+
let validOperators = [];
|
|
122
|
+
if (field.type === 'relationship' && Array.isArray(field.relationTo)) {
|
|
123
|
+
if ('hasMany' in field && field.hasMany) {
|
|
124
|
+
validOperators = [...equalsOperators, exists];
|
|
125
|
+
} else {
|
|
126
|
+
validOperators = [...base];
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
validOperators = [...fieldTypeConditions[field.type].operators];
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
validOperator: operator && validOperators.find(({
|
|
133
|
+
value
|
|
134
|
+
}) => value === operator) ? operator : validOperators[0].value,
|
|
135
|
+
validOperators
|
|
136
|
+
};
|
|
137
|
+
};
|
|
120
138
|
//# sourceMappingURL=field-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-types.js","names":["equalsOperators","label","value","arrayOperators","base","numeric","geo","within","intersects","like","notLike","contains","fieldTypeConditions","checkbox","component","operators","code","date","email","json","number","point","radio","relationship","richText","select","text","textarea","upload"],"sources":["../../../src/elements/WhereBuilder/field-types.tsx"],"sourcesContent":["'use client'\nconst equalsOperators = [\n {\n label: 'equals',\n value: 'equals',\n },\n {\n label: 'isNotEqualTo',\n value: 'not_equals',\n },\n]\n\nexport const arrayOperators = [\n {\n label: 'isIn',\n value: 'in',\n },\n {\n label: 'isNotIn',\n value: 'not_in',\n },\n
|
|
1
|
+
{"version":3,"file":"field-types.js","names":["equalsOperators","label","value","arrayOperators","exists","base","numeric","geo","within","intersects","like","notLike","contains","fieldTypeConditions","checkbox","component","operators","code","date","email","json","number","point","radio","relationship","richText","select","text","textarea","upload","getValidFieldOperators","field","operator","validOperators","type","Array","isArray","relationTo","hasMany","validOperator","find"],"sources":["../../../src/elements/WhereBuilder/field-types.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientField } from 'payload'\n\nconst equalsOperators = [\n {\n label: 'equals',\n value: 'equals',\n },\n {\n label: 'isNotEqualTo',\n value: 'not_equals',\n },\n]\n\nexport const arrayOperators = [\n {\n label: 'isIn',\n value: 'in',\n },\n {\n label: 'isNotIn',\n value: 'not_in',\n },\n]\n\nconst exists = {\n label: 'exists',\n value: 'exists',\n}\n\nconst base = [...equalsOperators, ...arrayOperators, exists]\n\nconst numeric = [\n ...base,\n {\n label: 'isGreaterThan',\n value: 'greater_than',\n },\n {\n label: 'isLessThan',\n value: 'less_than',\n },\n {\n label: 'isLessThanOrEqualTo',\n value: 'less_than_equal',\n },\n {\n label: 'isGreaterThanOrEqualTo',\n value: 'greater_than_equal',\n },\n]\n\nconst geo = [\n ...equalsOperators,\n {\n label: 'near',\n value: 'near',\n },\n]\n\nconst within = {\n label: 'within',\n value: 'within',\n}\n\nconst intersects = {\n label: 'intersects',\n value: 'intersects',\n}\n\nconst like = {\n label: 'isLike',\n value: 'like',\n}\n\nconst notLike = {\n label: 'isNotLike',\n value: 'not_like',\n}\n\nconst contains = {\n label: 'contains',\n value: 'contains',\n}\n\nexport const fieldTypeConditions: {\n [key: string]: {\n component: string\n operators: { label: string; value: string }[]\n }\n} = {\n checkbox: {\n component: 'Text',\n operators: [...equalsOperators, exists],\n },\n code: {\n component: 'Text',\n operators: [...base, like, notLike, contains],\n },\n date: {\n component: 'Date',\n operators: [...numeric, exists],\n },\n email: {\n component: 'Text',\n operators: [...base, contains],\n },\n json: {\n component: 'Text',\n operators: [...base, like, contains, notLike, within, intersects],\n },\n number: {\n component: 'Number',\n operators: [...numeric, exists],\n },\n point: {\n component: 'Point',\n operators: [...geo, exists, within, intersects],\n },\n radio: {\n component: 'Select',\n operators: [...base],\n },\n relationship: {\n component: 'Relationship',\n operators: [...base],\n },\n richText: {\n component: 'Text',\n operators: [...base, like, notLike, contains],\n },\n select: {\n component: 'Select',\n operators: [...base],\n },\n text: {\n component: 'Text',\n operators: [...base, like, notLike, contains],\n },\n textarea: {\n component: 'Text',\n operators: [...base, like, notLike, contains],\n },\n upload: {\n component: 'Text',\n operators: [...base],\n },\n}\n\nexport const getValidFieldOperators = ({\n field,\n operator,\n}: {\n field: ClientField\n operator?: string\n}): {\n validOperator: string\n validOperators: {\n label: string\n value: string\n }[]\n} => {\n let validOperators: {\n label: string\n value: string\n }[] = []\n\n if (field.type === 'relationship' && Array.isArray(field.relationTo)) {\n if ('hasMany' in field && field.hasMany) {\n validOperators = [...equalsOperators, exists]\n } else {\n validOperators = [...base]\n }\n } else {\n validOperators = [...fieldTypeConditions[field.type].operators]\n }\n\n return {\n validOperator:\n operator && validOperators.find(({ value }) => value === operator)\n ? operator\n : validOperators[0].value,\n validOperators,\n }\n}\n"],"mappings":"AAAA;;AAIA,MAAMA,eAAA,GAAkB,CACtB;EACEC,KAAA,EAAO;EACPC,KAAA,EAAO;AACT,GACA;EACED,KAAA,EAAO;EACPC,KAAA,EAAO;AACT,EACD;AAED,OAAO,MAAMC,cAAA,GAAiB,CAC5B;EACEF,KAAA,EAAO;EACPC,KAAA,EAAO;AACT,GACA;EACED,KAAA,EAAO;EACPC,KAAA,EAAO;AACT,EACD;AAED,MAAME,MAAA,GAAS;EACbH,KAAA,EAAO;EACPC,KAAA,EAAO;AACT;AAEA,MAAMG,IAAA,GAAO,C,GAAIL,eAAA,E,GAAoBG,cAAA,EAAgBC,MAAA,CAAO;AAE5D,MAAME,OAAA,GAAU,C,GACXD,IAAA,EACH;EACEJ,KAAA,EAAO;EACPC,KAAA,EAAO;AACT,GACA;EACED,KAAA,EAAO;EACPC,KAAA,EAAO;AACT,GACA;EACED,KAAA,EAAO;EACPC,KAA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AAC,CAAC;MAAEtC;IAAK,CAAE,KAAKA,KAAA,KAAU8B,QAAA,IACrDA,QAAA,GACAC,cAAc,CAAC,EAAE,CAAC/B,KAAK;IAC7B+B;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/WhereBuilder/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAkD,iBAAiB,EAAE,MAAM,YAAY,CAAA;AASnG,OAAO,cAAc,CAAA;AAIrB,OAAO,EAAE,iBAAiB,EAAE,CAAA;AAE5B;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/WhereBuilder/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAkD,iBAAiB,EAAE,MAAM,YAAY,CAAA;AASnG,OAAO,cAAc,CAAA;AAIrB,OAAO,EAAE,iBAAiB,EAAE,CAAA;AAE5B;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAyMpD,CAAA"}
|
|
@@ -10,7 +10,7 @@ import { useTranslation } from '../../providers/Translation/index.js';
|
|
|
10
10
|
import { reduceFieldsToOptions } from '../../utilities/reduceFieldsToOptions.js';
|
|
11
11
|
import { Button } from '../Button/index.js';
|
|
12
12
|
import { Condition } from './Condition/index.js';
|
|
13
|
-
import
|
|
13
|
+
import { fieldTypeConditions, getValidFieldOperators } from './field-types.js';
|
|
14
14
|
import './index.scss';
|
|
15
15
|
const baseClass = 'where-builder';
|
|
16
16
|
/**
|
|
@@ -65,7 +65,7 @@ export const WhereBuilder = props => {
|
|
|
65
65
|
relation
|
|
66
66
|
}) => {
|
|
67
67
|
const newConditions = [...conditions];
|
|
68
|
-
const defaultOperator =
|
|
68
|
+
const defaultOperator = fieldTypeConditions[field.field.type].operators[0].value;
|
|
69
69
|
if (relation === 'and') {
|
|
70
70
|
newConditions[orIndex].and.splice(andIndex, 0, {
|
|
71
71
|
[String(field.value)]: {
|
|
@@ -90,27 +90,26 @@ export const WhereBuilder = props => {
|
|
|
90
90
|
field: field_0,
|
|
91
91
|
operator: incomingOperator,
|
|
92
92
|
orIndex: orIndex_0,
|
|
93
|
-
value
|
|
93
|
+
value
|
|
94
94
|
}) => {
|
|
95
95
|
const existingCondition = conditions[orIndex_0].and[andIndex_0];
|
|
96
|
-
const defaults = fieldTypes[field_0.field.type];
|
|
97
|
-
const operator = incomingOperator || defaults.operators[0].value;
|
|
98
96
|
if (typeof existingCondition === 'object' && field_0.value) {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
97
|
+
const {
|
|
98
|
+
validOperator
|
|
99
|
+
} = getValidFieldOperators({
|
|
100
|
+
field: field_0.field,
|
|
101
|
+
operator: incomingOperator
|
|
102
|
+
});
|
|
103
|
+
const newRowCondition = {
|
|
104
|
+
[String(field_0.value)]: {
|
|
105
|
+
[validOperator]: value
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const newConditions_0 = [...conditions];
|
|
109
|
+
newConditions_0[orIndex_0].and[andIndex_0] = newRowCondition;
|
|
110
|
+
await handleWhereChange({
|
|
111
|
+
or: newConditions_0
|
|
112
|
+
});
|
|
114
113
|
}
|
|
115
114
|
}, [conditions, handleWhereChange]);
|
|
116
115
|
const removeCondition = React.useCallback(async ({
|
|
@@ -147,8 +146,8 @@ export const WhereBuilder = props => {
|
|
|
147
146
|
children: Array.isArray(or?.and) && or.and.map((_, andIndex_2) => {
|
|
148
147
|
const condition = conditions[orIndex_2].and[andIndex_2];
|
|
149
148
|
const fieldPath = Object.keys(condition)[0];
|
|
150
|
-
const
|
|
151
|
-
const value_0 = condition?.[fieldPath]?.[
|
|
149
|
+
const operator = Object.keys(condition?.[fieldPath] || {})?.[0] || undefined;
|
|
150
|
+
const value_0 = condition?.[fieldPath]?.[operator] || undefined;
|
|
152
151
|
return /*#__PURE__*/_jsxs("li", {
|
|
153
152
|
children: [andIndex_2 !== 0 && /*#__PURE__*/_jsx("div", {
|
|
154
153
|
className: `${baseClass}__label`,
|
|
@@ -158,7 +157,7 @@ export const WhereBuilder = props => {
|
|
|
158
157
|
andIndex: andIndex_2,
|
|
159
158
|
fieldPath: fieldPath,
|
|
160
159
|
filterOptions: resolvedFilterOptions?.get(fieldPath),
|
|
161
|
-
operator:
|
|
160
|
+
operator: operator,
|
|
162
161
|
orIndex: orIndex_2,
|
|
163
162
|
reducedFields: reducedFields,
|
|
164
163
|
removeCondition: removeCondition,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getTranslation","transformWhereQuery","validateWhereQuery","React","useMemo","useAuth","useListQuery","useTranslation","reduceFieldsToOptions","Button","Condition","fieldTypes","baseClass","WhereBuilder","props","collectionPluralLabel","collectionSlug","fields","renderedFilters","resolvedFilterOptions","i18n","t","permissions","fieldPermissions","collections","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","String","undefined","push","updateCondition","operator","incomingOperator","valueArg","existingCondition","defaults","valueChanged","operatorChanged","Object","keys","newRowCondition","removeCondition","length","_jsxs","className","Fragment","_jsx","label","map","compoundOrKey","Array","isArray","_","condition","fieldPath","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 { transformWhereQuery, validateWhereQuery } from 'payload/shared'\nimport React, { useMemo } from 'react'\n\nimport type { AddCondition, RemoveCondition, UpdateCondition, WhereBuilderProps } from './types.js'\n\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useListQuery } from '../../providers/ListQuery/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { reduceFieldsToOptions } from '../../utilities/reduceFieldsToOptions.js'\nimport { Button } from '../Button/index.js'\nimport { Condition } from './Condition/index.js'\nimport fieldTypes from './field-types.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, collectionSlug, fields, renderedFilters, resolvedFilterOptions } =\n props\n const { i18n, t } = useTranslation()\n const { permissions } = useAuth()\n\n const fieldPermissions = permissions?.collections?.[collectionSlug]?.fields\n\n const reducedFields = useMemo(\n () =>\n reduceFieldsToOptions({\n fieldPermissions,\n fields,\n i18n,\n }),\n [fieldPermissions, fields, i18n],\n )\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 [String(field.value)]: {\n [defaultOperator]: undefined,\n },\n })\n } else {\n newConditions.push({\n and: [\n {\n [String(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 existingCondition = conditions[orIndex].and[andIndex]\n\n const defaults = fieldTypes[field.field.type]\n const operator = incomingOperator || defaults.operators[0].value\n\n if (typeof existingCondition === 'object' && field.value) {\n const value = valueArg ?? existingCondition?.[operator]\n\n const valueChanged = value !== existingCondition?.[String(field.value)]?.[String(operator)]\n\n const operatorChanged =\n operator !== Object.keys(existingCondition?.[String(field.value)] || {})?.[0]\n\n if (valueChanged || operatorChanged) {\n const newRowCondition = {\n [String(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 },\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 <p className={`${baseClass}__label`}>\n {t('general:filterWhere', { label: getTranslation(collectionPluralLabel, i18n) })}\n </p>\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 fieldPath = Object.keys(condition)[0]\n\n const operator =\n (Object.keys(condition?.[fieldPath] || {})?.[0] as Operator) || undefined\n\n const value = condition?.[fieldPath]?.[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 fieldPath={fieldPath}\n filterOptions={resolvedFilterOptions?.get(fieldPath)}\n operator={operator}\n orIndex={orIndex}\n reducedFields={reducedFields}\n removeCondition={removeCondition}\n RenderedFilter={renderedFilters?.get(fieldPath)}\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.find((field) => !field.field.admin?.disableListFilter),\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,SAASC,mBAAmB,EAAEC,kBAAkB,QAAQ;AACxD,OAAOC,KAAA,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8BACxCyD,IAAA,CAAC;QAAIF,SAAA,EAAW,GAAGvD,SAAA,SAAkB;kBAAGS,CAAA,CAAE;uBAC1CgD,IAAA,CAAC5D,MAAA;QACCwE,WAAA,EAAY;QACZd,SAAA,EAAW,GAAGvD,SAAA,oBAA6B;QAC3CsE,IAAA,EAAK;QACLC,YAAA,EAAa;QACbC,SAAA,EAAU;QACVC,OAAA,EAAS,MAAAA,CAAA;UACP,IAAI5D,aAAA,CAAcwC,MAAM,GAAG,GAAG;YAC5B,MAAM5B,YAAA,CAAa;cACjBE,QAAA,EAAU;cACVC,KAAA,EAAOf,aAAA,CAAc6D,IAAI,CAAE9C,OAAA,IAAU,CAACA,OAAA,CAAMA,KAAK,CAAC+C,KAAK,EAAEC,iBAAA;cACzD/C,OAAA,EAASb,UAAA,CAAWqC,MAAM;cAC1BvB,QAAA,EAAU;YACZ;UACF;QACF;kBAECrB,CAAA,CAAE;;;;AAMf","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["getTranslation","transformWhereQuery","validateWhereQuery","React","useMemo","useAuth","useListQuery","useTranslation","reduceFieldsToOptions","Button","Condition","fieldTypeConditions","getValidFieldOperators","baseClass","WhereBuilder","props","collectionPluralLabel","collectionSlug","fields","renderedFilters","resolvedFilterOptions","i18n","t","permissions","fieldPermissions","collections","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","String","undefined","push","updateCondition","operator","incomingOperator","existingCondition","validOperator","newRowCondition","removeCondition","length","_jsxs","className","Fragment","_jsx","label","map","compoundOrKey","Array","isArray","_","condition","fieldPath","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 { transformWhereQuery, validateWhereQuery } from 'payload/shared'\nimport React, { useMemo } from 'react'\n\nimport type { AddCondition, RemoveCondition, UpdateCondition, WhereBuilderProps } from './types.js'\n\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useListQuery } from '../../providers/ListQuery/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { reduceFieldsToOptions } from '../../utilities/reduceFieldsToOptions.js'\nimport { Button } from '../Button/index.js'\nimport { Condition } from './Condition/index.js'\nimport { fieldTypeConditions, getValidFieldOperators } from './field-types.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, collectionSlug, fields, renderedFilters, resolvedFilterOptions } =\n props\n const { i18n, t } = useTranslation()\n const { permissions } = useAuth()\n\n const fieldPermissions = permissions?.collections?.[collectionSlug]?.fields\n\n const reducedFields = useMemo(\n () =>\n reduceFieldsToOptions({\n fieldPermissions,\n fields,\n i18n,\n }),\n [fieldPermissions, fields, i18n],\n )\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 = fieldTypeConditions[field.field.type].operators[0].value\n\n if (relation === 'and') {\n newConditions[orIndex].and.splice(andIndex, 0, {\n [String(field.value)]: {\n [defaultOperator]: undefined,\n },\n })\n } else {\n newConditions.push({\n and: [\n {\n [String(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 }) => {\n const existingCondition = conditions[orIndex].and[andIndex]\n\n if (typeof existingCondition === 'object' && field.value) {\n const { validOperator } = getValidFieldOperators({\n field: field.field,\n operator: incomingOperator,\n })\n const newRowCondition = {\n [String(field.value)]: { [validOperator]: value },\n }\n\n const newConditions = [...conditions]\n newConditions[orIndex].and[andIndex] = newRowCondition\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 <p className={`${baseClass}__label`}>\n {t('general:filterWhere', { label: getTranslation(collectionPluralLabel, i18n) })}\n </p>\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 fieldPath = Object.keys(condition)[0]\n\n const operator =\n (Object.keys(condition?.[fieldPath] || {})?.[0] as Operator) || undefined\n\n const value = condition?.[fieldPath]?.[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 fieldPath={fieldPath}\n filterOptions={resolvedFilterOptions?.get(fieldPath)}\n operator={operator}\n orIndex={orIndex}\n reducedFields={reducedFields}\n removeCondition={removeCondition}\n RenderedFilter={renderedFilters?.get(fieldPath)}\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.find((field) => !field.field.admin?.disableListFilter),\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,SAASC,mBAAmB,EAAEC,kBAAkB,QAAQ;AACxD,OAAOC,KAAA,IAASC,OAAO,QAAQ;AAI/B,SAASC,OAAO,QAAQ;AACxB,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,MAAM,QAAQ;AACvB,SAASC,SAAS,QAAQ;AAC1B,SAASC,mBAAm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