@payloadcms/ui 3.12.1-canary.b1b1cbf → 3.13.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.
- package/dist/elements/Autosave/index.d.ts.map +1 -1
- package/dist/elements/Autosave/index.js +1 -2
- package/dist/elements/Autosave/index.js.map +1 -1
- package/dist/elements/ColumnSelector/index.d.ts.map +1 -1
- package/dist/elements/ColumnSelector/index.js +41 -90
- package/dist/elements/ColumnSelector/index.js.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/elements/DocumentDrawer/DrawerContent.js +4 -1
- package/dist/elements/DocumentDrawer/DrawerContent.js.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.d.ts.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.js +1 -12
- package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.d.ts +1 -1
- package/dist/elements/WhereBuilder/Condition/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js +261 -101
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/elements/WhereBuilder/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/index.js +13 -10
- package/dist/elements/WhereBuilder/index.js.map +1 -1
- package/dist/elements/WhereBuilder/reduceClientFields.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/reduceClientFields.js +1 -0
- package/dist/elements/WhereBuilder/reduceClientFields.js.map +1 -1
- package/dist/exports/client/index.js +9 -9
- package/dist/exports/client/index.js.map +3 -3
- package/dist/providers/DocumentInfo/types.d.ts +0 -6
- package/dist/providers/DocumentInfo/types.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/types.js.map +1 -1
- package/dist/providers/ServerFunctions/index.d.ts +2 -1
- package/dist/providers/ServerFunctions/index.d.ts.map +1 -1
- package/dist/providers/ServerFunctions/index.js.map +1 -1
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.d.ts.map +1 -1
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js +5 -3
- package/dist/utilities/buildClientFieldSchemaMap/traverseFields.js.map +1 -1
- package/dist/utilities/renderTable.d.ts.map +1 -1
- package/dist/utilities/renderTable.js +35 -11
- package/dist/utilities/renderTable.js.map +1 -1
- package/dist/views/Edit/Auth/index.js +38 -35
- package/dist/views/Edit/Auth/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
import React, { useEffect,
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
5
6
|
import { useDebounce } from '../../../hooks/useDebounce.js';
|
|
6
7
|
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
7
8
|
import { Button } from '../../Button/index.js';
|
|
@@ -10,127 +11,286 @@ import { DefaultFilter } from './DefaultFilter/index.js';
|
|
|
10
11
|
import './index.scss';
|
|
11
12
|
const baseClass = 'condition';
|
|
12
13
|
export const Condition = props => {
|
|
14
|
+
const $ = _c(65);
|
|
13
15
|
const {
|
|
14
16
|
addCondition,
|
|
15
17
|
andIndex,
|
|
16
18
|
fieldName,
|
|
17
|
-
fields,
|
|
18
19
|
initialValue,
|
|
19
20
|
operator,
|
|
21
|
+
options,
|
|
20
22
|
orIndex,
|
|
21
23
|
removeCondition,
|
|
22
24
|
RenderedFilter,
|
|
23
25
|
updateCondition
|
|
24
26
|
} = props;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
let t0;
|
|
28
|
+
if ($[0] !== fieldName || $[1] !== options) {
|
|
29
|
+
t0 = () => options.find(field => fieldName === field.value);
|
|
30
|
+
$[0] = fieldName;
|
|
31
|
+
$[1] = options;
|
|
32
|
+
$[2] = t0;
|
|
33
|
+
} else {
|
|
34
|
+
t0 = $[2];
|
|
35
|
+
}
|
|
36
|
+
const [fieldOption, setFieldOption] = useState(t0);
|
|
31
37
|
const {
|
|
32
38
|
t
|
|
33
39
|
} = useTranslation();
|
|
34
40
|
const [internalOperatorOption, setInternalOperatorOption] = useState(operator);
|
|
35
41
|
const [internalQueryValue, setInternalQueryValue] = useState(initialValue);
|
|
36
42
|
const debouncedValue = useDebounce(internalQueryValue, 300);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
let t1;
|
|
44
|
+
if ($[3] !== andIndex || $[4] !== debouncedValue || $[5] !== fieldOption || $[6] !== internalOperatorOption || $[7] !== orIndex || $[8] !== updateCondition) {
|
|
45
|
+
t1 = () => {
|
|
46
|
+
if ((fieldOption?.value || typeof fieldOption?.value === "number") && internalOperatorOption && ![null, undefined].includes(debouncedValue)) {
|
|
47
|
+
updateCondition({
|
|
48
|
+
andIndex,
|
|
49
|
+
fieldName: fieldOption.value,
|
|
50
|
+
operator: internalOperatorOption,
|
|
51
|
+
orIndex,
|
|
52
|
+
value: debouncedValue
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
$[3] = andIndex;
|
|
57
|
+
$[4] = debouncedValue;
|
|
58
|
+
$[5] = fieldOption;
|
|
59
|
+
$[6] = internalOperatorOption;
|
|
60
|
+
$[7] = orIndex;
|
|
61
|
+
$[8] = updateCondition;
|
|
62
|
+
$[9] = t1;
|
|
63
|
+
} else {
|
|
64
|
+
t1 = $[9];
|
|
65
|
+
}
|
|
66
|
+
const t2 = fieldOption?.value;
|
|
67
|
+
let t3;
|
|
68
|
+
if ($[10] !== andIndex || $[11] !== debouncedValue || $[12] !== internalOperatorOption || $[13] !== operator || $[14] !== orIndex || $[15] !== t2 || $[16] !== updateCondition) {
|
|
69
|
+
t3 = [debouncedValue, andIndex, t2, internalOperatorOption, orIndex, updateCondition, operator];
|
|
70
|
+
$[10] = andIndex;
|
|
71
|
+
$[11] = debouncedValue;
|
|
72
|
+
$[12] = internalOperatorOption;
|
|
73
|
+
$[13] = operator;
|
|
74
|
+
$[14] = orIndex;
|
|
75
|
+
$[15] = t2;
|
|
76
|
+
$[16] = updateCondition;
|
|
77
|
+
$[17] = t3;
|
|
78
|
+
} else {
|
|
79
|
+
t3 = $[17];
|
|
80
|
+
}
|
|
81
|
+
useEffect(t1, t3);
|
|
82
|
+
let t4;
|
|
83
|
+
if ($[18] !== fieldOption?.field?.type || $[19] !== internalOperatorOption) {
|
|
84
|
+
t4 = ["exists"].includes(internalOperatorOption) || fieldOption?.field?.type === "checkbox";
|
|
85
|
+
$[18] = fieldOption?.field?.type;
|
|
86
|
+
$[19] = internalOperatorOption;
|
|
87
|
+
$[20] = t4;
|
|
88
|
+
} else {
|
|
89
|
+
t4 = $[20];
|
|
90
|
+
}
|
|
91
|
+
const booleanSelect = t4;
|
|
92
|
+
let valueOptions;
|
|
93
|
+
if (booleanSelect) {
|
|
94
|
+
let t5;
|
|
95
|
+
if ($[21] !== t) {
|
|
96
|
+
t5 = t("general:true");
|
|
97
|
+
$[21] = t;
|
|
98
|
+
$[22] = t5;
|
|
99
|
+
} else {
|
|
100
|
+
t5 = $[22];
|
|
101
|
+
}
|
|
102
|
+
let t6;
|
|
103
|
+
if ($[23] !== t5) {
|
|
104
|
+
t6 = {
|
|
105
|
+
label: t5,
|
|
106
|
+
value: "true"
|
|
107
|
+
};
|
|
108
|
+
$[23] = t5;
|
|
109
|
+
$[24] = t6;
|
|
110
|
+
} else {
|
|
111
|
+
t6 = $[24];
|
|
112
|
+
}
|
|
113
|
+
let t7;
|
|
114
|
+
if ($[25] !== t) {
|
|
115
|
+
t7 = t("general:false");
|
|
116
|
+
$[25] = t;
|
|
117
|
+
$[26] = t7;
|
|
118
|
+
} else {
|
|
119
|
+
t7 = $[26];
|
|
120
|
+
}
|
|
121
|
+
let t8;
|
|
122
|
+
if ($[27] !== t7) {
|
|
123
|
+
t8 = {
|
|
124
|
+
label: t7,
|
|
125
|
+
value: "false"
|
|
126
|
+
};
|
|
127
|
+
$[27] = t7;
|
|
128
|
+
$[28] = t8;
|
|
129
|
+
} else {
|
|
130
|
+
t8 = $[28];
|
|
131
|
+
}
|
|
132
|
+
let t9;
|
|
133
|
+
if ($[29] !== t6 || $[30] !== t8) {
|
|
134
|
+
t9 = [t6, t8];
|
|
135
|
+
$[29] = t6;
|
|
136
|
+
$[30] = t8;
|
|
137
|
+
$[31] = t9;
|
|
138
|
+
} else {
|
|
139
|
+
t9 = $[31];
|
|
140
|
+
}
|
|
141
|
+
valueOptions = t9;
|
|
142
|
+
} else {
|
|
143
|
+
if (fieldOption?.field && "options" in fieldOption.field) {
|
|
144
|
+
valueOptions = fieldOption.field.options;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const disabled = !fieldOption?.value && typeof fieldOption?.value !== "number" || fieldOption?.field?.admin?.disableListFilter;
|
|
148
|
+
let t5;
|
|
149
|
+
if ($[32] !== options) {
|
|
150
|
+
t5 = field_0 => {
|
|
151
|
+
setFieldOption(options.find(f => f.value === field_0.value));
|
|
152
|
+
setInternalOperatorOption(undefined);
|
|
153
|
+
setInternalQueryValue(undefined);
|
|
154
|
+
};
|
|
155
|
+
$[32] = options;
|
|
156
|
+
$[33] = t5;
|
|
157
|
+
} else {
|
|
158
|
+
t5 = $[33];
|
|
159
|
+
}
|
|
160
|
+
let t6;
|
|
161
|
+
if ($[34] !== RenderedFilter || $[35] !== addCondition || $[36] !== andIndex || $[37] !== booleanSelect || $[38] !== disabled || $[39] !== fieldOption || $[40] !== internalOperatorOption || $[41] !== internalQueryValue || $[42] !== options || $[43] !== orIndex || $[44] !== removeCondition || $[45] !== t5 || $[46] !== valueOptions) {
|
|
162
|
+
let t7;
|
|
163
|
+
if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
|
|
164
|
+
t7 = operator_0 => {
|
|
165
|
+
setInternalOperatorOption(operator_0.value);
|
|
166
|
+
};
|
|
167
|
+
$[48] = t7;
|
|
168
|
+
} else {
|
|
169
|
+
t7 = $[48];
|
|
170
|
+
}
|
|
171
|
+
let t8;
|
|
172
|
+
if ($[49] !== RenderedFilter || $[50] !== booleanSelect || $[51] !== fieldOption || $[52] !== internalOperatorOption || $[53] !== internalQueryValue || $[54] !== valueOptions) {
|
|
173
|
+
t8 = RenderedFilter || _jsx(DefaultFilter, {
|
|
174
|
+
booleanSelect,
|
|
175
|
+
disabled: !internalOperatorOption || !fieldOption || fieldOption?.field?.admin?.disableListFilter,
|
|
176
|
+
internalField: fieldOption,
|
|
177
|
+
onChange: setInternalQueryValue,
|
|
43
178
|
operator: internalOperatorOption,
|
|
179
|
+
options: valueOptions,
|
|
180
|
+
value: internalQueryValue ?? ""
|
|
181
|
+
});
|
|
182
|
+
$[49] = RenderedFilter;
|
|
183
|
+
$[50] = booleanSelect;
|
|
184
|
+
$[51] = fieldOption;
|
|
185
|
+
$[52] = internalOperatorOption;
|
|
186
|
+
$[53] = internalQueryValue;
|
|
187
|
+
$[54] = valueOptions;
|
|
188
|
+
$[55] = t8;
|
|
189
|
+
} else {
|
|
190
|
+
t8 = $[55];
|
|
191
|
+
}
|
|
192
|
+
let t9;
|
|
193
|
+
if ($[56] !== andIndex || $[57] !== orIndex || $[58] !== removeCondition) {
|
|
194
|
+
t9 = () => removeCondition({
|
|
195
|
+
andIndex,
|
|
196
|
+
orIndex
|
|
197
|
+
});
|
|
198
|
+
$[56] = andIndex;
|
|
199
|
+
$[57] = orIndex;
|
|
200
|
+
$[58] = removeCondition;
|
|
201
|
+
$[59] = t9;
|
|
202
|
+
} else {
|
|
203
|
+
t9 = $[59];
|
|
204
|
+
}
|
|
205
|
+
let t10;
|
|
206
|
+
if ($[60] !== addCondition || $[61] !== andIndex || $[62] !== options || $[63] !== orIndex) {
|
|
207
|
+
t10 = () => addCondition({
|
|
208
|
+
andIndex: andIndex + 1,
|
|
209
|
+
fieldName: options.find(_temp2).value,
|
|
44
210
|
orIndex,
|
|
45
|
-
|
|
211
|
+
relation: "and"
|
|
46
212
|
});
|
|
213
|
+
$[60] = addCondition;
|
|
214
|
+
$[61] = andIndex;
|
|
215
|
+
$[62] = options;
|
|
216
|
+
$[63] = orIndex;
|
|
217
|
+
$[64] = t10;
|
|
218
|
+
} else {
|
|
219
|
+
t10 = $[64];
|
|
47
220
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
})
|
|
95
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
96
|
-
className: `${baseClass}__value`,
|
|
97
|
-
children: RenderedFilter || /*#__PURE__*/_jsx(DefaultFilter, {
|
|
98
|
-
booleanSelect: booleanSelect,
|
|
99
|
-
disabled: !internalOperatorOption || internalField?.field?.admin?.disableListFilter,
|
|
100
|
-
internalField: internalField,
|
|
101
|
-
onChange: setInternalQueryValue,
|
|
102
|
-
operator: internalOperatorOption,
|
|
103
|
-
options: valueOptions,
|
|
104
|
-
value: internalQueryValue ?? ''
|
|
105
|
-
})
|
|
106
|
-
})]
|
|
107
|
-
}), /*#__PURE__*/_jsxs("div", {
|
|
108
|
-
className: `${baseClass}__actions`,
|
|
109
|
-
children: [/*#__PURE__*/_jsx(Button, {
|
|
110
|
-
buttonStyle: "icon-label",
|
|
111
|
-
className: `${baseClass}__actions-remove`,
|
|
112
|
-
icon: "x",
|
|
113
|
-
iconStyle: "with-border",
|
|
114
|
-
onClick: () => removeCondition({
|
|
115
|
-
andIndex,
|
|
116
|
-
orIndex
|
|
117
|
-
}),
|
|
118
|
-
round: true
|
|
119
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
120
|
-
buttonStyle: "icon-label",
|
|
121
|
-
className: `${baseClass}__actions-add`,
|
|
122
|
-
icon: "plus",
|
|
123
|
-
iconStyle: "with-border",
|
|
124
|
-
onClick: () => addCondition({
|
|
125
|
-
andIndex: andIndex + 1,
|
|
126
|
-
fieldName: fields[0].value,
|
|
127
|
-
orIndex,
|
|
128
|
-
relation: 'and'
|
|
129
|
-
}),
|
|
130
|
-
round: true
|
|
221
|
+
t6 = _jsx("div", {
|
|
222
|
+
className: baseClass,
|
|
223
|
+
children: _jsxs("div", {
|
|
224
|
+
className: `${baseClass}__wrap`,
|
|
225
|
+
children: [_jsxs("div", {
|
|
226
|
+
className: `${baseClass}__inputs`,
|
|
227
|
+
children: [_jsx("div", {
|
|
228
|
+
className: `${baseClass}__field`,
|
|
229
|
+
children: _jsx(ReactSelect, {
|
|
230
|
+
disabled,
|
|
231
|
+
isClearable: false,
|
|
232
|
+
onChange: t5,
|
|
233
|
+
options: options.filter(_temp),
|
|
234
|
+
value: options.find(field_2 => fieldOption?.value === field_2.value) || {
|
|
235
|
+
value: fieldOption?.value
|
|
236
|
+
}
|
|
237
|
+
})
|
|
238
|
+
}), _jsx("div", {
|
|
239
|
+
className: `${baseClass}__operator`,
|
|
240
|
+
children: _jsx(ReactSelect, {
|
|
241
|
+
disabled,
|
|
242
|
+
isClearable: false,
|
|
243
|
+
onChange: t7,
|
|
244
|
+
options: fieldOption?.operators,
|
|
245
|
+
value: fieldOption?.operators.find(operator_1 => internalOperatorOption === operator_1.value) || null
|
|
246
|
+
})
|
|
247
|
+
}), _jsx("div", {
|
|
248
|
+
className: `${baseClass}__value`,
|
|
249
|
+
children: t8
|
|
250
|
+
})]
|
|
251
|
+
}), _jsxs("div", {
|
|
252
|
+
className: `${baseClass}__actions`,
|
|
253
|
+
children: [_jsx(Button, {
|
|
254
|
+
buttonStyle: "icon-label",
|
|
255
|
+
className: `${baseClass}__actions-remove`,
|
|
256
|
+
icon: "x",
|
|
257
|
+
iconStyle: "with-border",
|
|
258
|
+
onClick: t9,
|
|
259
|
+
round: true
|
|
260
|
+
}), _jsx(Button, {
|
|
261
|
+
buttonStyle: "icon-label",
|
|
262
|
+
className: `${baseClass}__actions-add`,
|
|
263
|
+
icon: "plus",
|
|
264
|
+
iconStyle: "with-border",
|
|
265
|
+
onClick: t10,
|
|
266
|
+
round: true
|
|
267
|
+
})]
|
|
131
268
|
})]
|
|
132
|
-
})
|
|
133
|
-
})
|
|
134
|
-
|
|
269
|
+
})
|
|
270
|
+
});
|
|
271
|
+
$[34] = RenderedFilter;
|
|
272
|
+
$[35] = addCondition;
|
|
273
|
+
$[36] = andIndex;
|
|
274
|
+
$[37] = booleanSelect;
|
|
275
|
+
$[38] = disabled;
|
|
276
|
+
$[39] = fieldOption;
|
|
277
|
+
$[40] = internalOperatorOption;
|
|
278
|
+
$[41] = internalQueryValue;
|
|
279
|
+
$[42] = options;
|
|
280
|
+
$[43] = orIndex;
|
|
281
|
+
$[44] = removeCondition;
|
|
282
|
+
$[45] = t5;
|
|
283
|
+
$[46] = valueOptions;
|
|
284
|
+
$[47] = t6;
|
|
285
|
+
} else {
|
|
286
|
+
t6 = $[47];
|
|
287
|
+
}
|
|
288
|
+
return t6;
|
|
135
289
|
};
|
|
290
|
+
function _temp(field_1) {
|
|
291
|
+
return !field_1.field.admin.disableListFilter;
|
|
292
|
+
}
|
|
293
|
+
function _temp2(field_3) {
|
|
294
|
+
return !field_3.field.admin?.disableListFilter;
|
|
295
|
+
}
|
|
136
296
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useEffect","useMemo","useState","useDebounce","useTranslation","Button","ReactSelect","DefaultFilter","baseClass","Condition","props","addCondition","andIndex","fieldName","fields","initialValue","operator","orIndex","removeCondition","RenderedFilter","updateCondition","options","filter","field","admin","disableListFilter","internalField","setInternalField","find","value","t","internalOperatorOption","setInternalOperatorOption","internalQueryValue","setInternalQueryValue","debouncedValue","undefined","includes","booleanSelect","type","valueOptions","label","disabled","_jsx","className","_jsxs","isClearable","onChange","f","operators","buttonStyle","icon","iconStyle","onClick","round","relation"],"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useEffect, useMemo, useState } from 'react'\n\nimport type { FieldCondition } from '../types.js'\n\nexport type Props = {\n readonly addCondition: ({\n andIndex,\n fieldName,\n orIndex,\n relation,\n }: {\n andIndex: number\n fieldName: string\n orIndex: number\n relation: 'and' | 'or'\n }) => void\n readonly andIndex: number\n readonly fieldName: string\n readonly fields: FieldCondition[]\n readonly initialValue: string\n readonly operator: Operator\n readonly orIndex: number\n readonly removeCondition: ({ andIndex, orIndex }: { andIndex: number; orIndex: number }) => void\n readonly RenderedFilter: React.ReactNode\n readonly updateCondition: ({\n andIndex,\n fieldName,\n operator,\n orIndex,\n value,\n }: {\n andIndex: number\n fieldName: string\n operator: string\n orIndex: number\n value: string\n }) => void\n}\n\nimport type { Operator } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { useDebounce } from '../../../hooks/useDebounce.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 './index.scss'\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldName,\n fields,\n initialValue,\n operator,\n orIndex,\n removeCondition,\n RenderedFilter,\n updateCondition,\n } = props\n\n const options = useMemo(() => {\n return fields.filter(({ field }) => !field.admin.disableListFilter)\n }, [fields])\n\n const [internalField, setInternalField] = useState<FieldCondition>(() =>\n fields.find((field) => fieldName === field.value),\n )\n\n const { t } = useTranslation()\n const [internalOperatorOption, setInternalOperatorOption] = useState<Operator>(operator)\n const [internalQueryValue, setInternalQueryValue] = useState<string>(initialValue)\n\n const debouncedValue = useDebounce(internalQueryValue, 300)\n\n useEffect(() => {\n // This is to trigger changes when the debounced value changes\n if (\n (internalField?.value || typeof internalField?.value === 'number') &&\n internalOperatorOption &&\n ![null, undefined].includes(debouncedValue)\n ) {\n updateCondition({\n andIndex,\n fieldName: internalField.value,\n operator: internalOperatorOption,\n orIndex,\n value: debouncedValue,\n })\n }\n }, [\n debouncedValue,\n andIndex,\n internalField?.value,\n internalOperatorOption,\n orIndex,\n updateCondition,\n operator,\n ])\n\n const booleanSelect =\n ['exists'].includes(internalOperatorOption) || internalField?.field?.type === 'checkbox'\n\n let valueOptions\n\n if (booleanSelect) {\n valueOptions = [\n { label: t('general:true'), value: 'true' },\n { label: t('general:false'), value: 'false' },\n ]\n } else if (internalField?.field && 'options' in internalField.field) {\n valueOptions = internalField.field.options\n }\n\n const disabled =\n (!internalField?.value && typeof internalField?.value !== 'number') ||\n internalField?.field?.admin?.disableListFilter\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 isClearable={false}\n onChange={(field: Option) => {\n setInternalField(fields.find((f) => f.value === field.value))\n setInternalOperatorOption(undefined)\n setInternalQueryValue(undefined)\n }}\n options={options}\n value={\n fields.find((field) => internalField?.value === field.value) || {\n value: internalField?.value,\n }\n }\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={(operator: Option<Operator>) => {\n setInternalOperatorOption(operator.value)\n }}\n options={internalField?.operators}\n value={\n internalField?.operators.find(\n (operator) => internalOperatorOption === operator.value,\n ) || null\n }\n />\n </div>\n <div className={`${baseClass}__value`}>\n {RenderedFilter || (\n <DefaultFilter\n booleanSelect={booleanSelect}\n disabled={!internalOperatorOption || internalField?.field?.admin?.disableListFilter}\n internalField={internalField}\n onChange={setInternalQueryValue}\n operator={internalOperatorOption}\n options={valueOptions}\n value={internalQueryValue ?? ''}\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 fieldName: fields[0].value,\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,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AA2CpD,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,WAAW,QAAQ;AAC5B,SAASC,aAAa,QAAQ;AAC9B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,SAAA,GAA8BC,KAAA;EACzC,MAAM;IACJC,YAAY;IACZC,QAAQ;IACRC,SAAS;IACTC,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,OAAO;IACPC,eAAe;IACfC,cAAc;IACdC;EAAe,CAChB,GAAGV,KAAA;EAEJ,MAAMW,OAAA,GAAUpB,OAAA,CAAQ;IACtB,OAAOa,MAAA,CAAOQ,MAAM,CAAC,CAAC;MAAEC;IAAK,CAAE,KAAK,CAACA,KAAA,CAAMC,KAAK,CAACC,iBA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EACEH,aAAA,EAAeuB,SAAA,CAAUrB,IAAA,CACtBZ,UAAA,IAAae,sBAAA,KAA2Bf,UAAA,CAASa,KAAK,KACpD;;yBAIXc,IAAA,CAAC;UAAIC,SAAA,EAAW,GAAGpC,SAAA,SAAkB;oBAClCW,cAAA,iBACCwB,IAAA,CAACpC,aAAA;YACC+B,aAAA,EAAeA,aAAA;YACfI,QAAA,EAAU,CAACX,sBAAA,IAA0BL,aAAA,EAAeH,KAAA,EAAOC,KAAA,EAAOC,iBAAA;YAClEC,aAAA,EAAeA,aAAA;YACfqB,QAAA,EAAUb,qBAAA;YACVlB,QAAA,EAAUe,sBAAA;YACVV,OAAA,EAASmB,YAAA;YACTX,KAAA,EAAOI,kBAAA,IAAsB;;;uBAKrCY,KAAA,CAAC;QAAID,SAAA,EAAW,GAAGpC,SAAA,WAAoB;gCACrCmC,IAAA,CAACtC,MAAA;UACC6C,WAAA,EAAY;UACZN,SAAA,EAAW,GAAGpC,SAAA,kBAA2B;UACzC2C,IAAA,EAAK;UACLC,SAAA,EAAU;UACVC,OAAA,EAASA,CAAA,KACPnC,eAAA,CAAgB;YACdN,QAAA;YACAK;UACF;UAEFqC,KAAK;yBAEPX,IAAA,CAACtC,MAAA;UACC6C,WAAA,EAAY;UACZN,SAAA,EAAW,GAAGpC,SAAA,eAAwB;UACtC2C,IAAA,EAAK;UACLC,SAAA,EAAU;UACVC,OAAA,EAASA,CAAA,KACP1C,YAAA,CAAa;YACXC,QAAA,EAAUA,QAAA,GAAW;YACrBC,SAAA,EAAWC,MAAM,CAAC,EAAE,CAACe,KAAK;YAC1BZ,OAAA;YACAsC,QAAA,EAAU;UACZ;UAEFD,KAAK;;;;;AAMjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","useEffect","useState","useDebounce","useTranslation","Button","ReactSelect","DefaultFilter","baseClass","Condition","props","$","addCondition","andIndex","fieldName","initialValue","operator","options","orIndex","removeCondition","RenderedFilter","updateCondition","t0","find","field","value","fieldOption","setFieldOption","t","internalOperatorOption","setInternalOperatorOption","internalQueryValue","setInternalQueryValue","debouncedValue","t1","undefined","includes","t2","t3","t4","type","booleanSelect","valueOptions","t5","t6","label","t7","t8","t9","disabled","admin","disableListFilter","field_0","f","Symbol","for","operator_0","_jsx","internalField","onChange","t10","_temp2","relation","className","children","_jsxs","isClearable","filter","_temp","field_2","operators","operator_1","buttonStyle","icon","iconStyle","onClick","round","field_1","field_3"],"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useEffect, useState } from 'react'\n\nimport type { FieldCondition } from '../types.js'\n\nexport type Props = {\n readonly addCondition: ({\n andIndex,\n fieldName,\n orIndex,\n relation,\n }: {\n andIndex: number\n fieldName: string\n orIndex: number\n relation: 'and' | 'or'\n }) => void\n readonly andIndex: number\n readonly fieldName: string\n readonly initialValue: string\n readonly operator: Operator\n readonly options: FieldCondition[]\n readonly orIndex: number\n readonly removeCondition: ({ andIndex, orIndex }: { andIndex: number; orIndex: number }) => void\n readonly RenderedFilter: React.ReactNode\n readonly updateCondition: ({\n andIndex,\n fieldName,\n operator,\n orIndex,\n value,\n }: {\n andIndex: number\n fieldName: string\n operator: string\n orIndex: number\n value: string\n }) => void\n}\n\nimport type { Operator } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { useDebounce } from '../../../hooks/useDebounce.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 './index.scss'\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldName,\n initialValue,\n operator,\n options,\n orIndex,\n removeCondition,\n RenderedFilter,\n updateCondition,\n } = props\n\n const [fieldOption, setFieldOption] = useState<FieldCondition>(() =>\n options.find((field) => fieldName === field.value),\n )\n\n const { t } = useTranslation()\n const [internalOperatorOption, setInternalOperatorOption] = useState<Operator>(operator)\n const [internalQueryValue, setInternalQueryValue] = useState<string>(initialValue)\n\n const debouncedValue = useDebounce(internalQueryValue, 300)\n\n useEffect(() => {\n // This is to trigger changes when the debounced value changes\n if (\n (fieldOption?.value || typeof fieldOption?.value === 'number') &&\n internalOperatorOption &&\n ![null, undefined].includes(debouncedValue)\n ) {\n updateCondition({\n andIndex,\n fieldName: fieldOption.value,\n operator: internalOperatorOption,\n orIndex,\n value: debouncedValue,\n })\n }\n }, [\n debouncedValue,\n andIndex,\n fieldOption?.value,\n internalOperatorOption,\n orIndex,\n updateCondition,\n operator,\n ])\n\n const booleanSelect =\n ['exists'].includes(internalOperatorOption) || fieldOption?.field?.type === 'checkbox'\n\n let valueOptions\n\n if (booleanSelect) {\n valueOptions = [\n { label: t('general:true'), value: 'true' },\n { label: t('general:false'), value: 'false' },\n ]\n } else if (fieldOption?.field && 'options' in fieldOption.field) {\n valueOptions = fieldOption.field.options\n }\n\n const disabled =\n (!fieldOption?.value && typeof fieldOption?.value !== 'number') ||\n fieldOption?.field?.admin?.disableListFilter\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 isClearable={false}\n onChange={(field: Option) => {\n setFieldOption(options.find((f) => f.value === field.value))\n setInternalOperatorOption(undefined)\n setInternalQueryValue(undefined)\n }}\n options={options.filter((field) => !field.field.admin.disableListFilter)}\n value={\n options.find((field) => fieldOption?.value === field.value) || {\n value: fieldOption?.value,\n }\n }\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={(operator: Option<Operator>) => {\n setInternalOperatorOption(operator.value)\n }}\n options={fieldOption?.operators}\n value={\n fieldOption?.operators.find(\n (operator) => internalOperatorOption === operator.value,\n ) || null\n }\n />\n </div>\n <div className={`${baseClass}__value`}>\n {RenderedFilter || (\n <DefaultFilter\n booleanSelect={booleanSelect}\n disabled={\n !internalOperatorOption ||\n !fieldOption ||\n fieldOption?.field?.admin?.disableListFilter\n }\n internalField={fieldOption}\n onChange={setInternalQueryValue}\n operator={internalOperatorOption}\n options={valueOptions}\n value={internalQueryValue ?? ''}\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 fieldName: options.find((field) => !field.field.admin?.disableListFilter).value,\n orIndex,\n relation: 'and',\n })\n }\n round\n />\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,OAAOC,KAAA,IAASC,SAAS,EAAEC,QAAQ,QAAQ;AA2C3C,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,WAAW,QAAQ;AAC5B,SAASC,aAAa,QAAQ;AAC9B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,SAAA,GAA6BC,KAAA;EAAA,MAAAC,CAAA,GAAAZ,EAAA;EACxC;IAAAa,YAAA;IAAAC,QAAA;IAAAC,SAAA;IAAAC,YAAA;IAAAC,QAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,eAAA;IAAAC,cAAA;IAAAC;EAAA,IAWIX,KAAA;EAAA,IAAAY,EAAA;EAAA,IAAAX,CAAA,QAAAG,SAAA,IAAAH,CAAA,QAAAM,OAAA;IAE2DK,EAAA,GAAAA,CAAA,KAC7DL,OAAA,CAAAM,IAAA,CAAAC,KAAA,IAAwBV,SAAA,KAAc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AS,OAAA;EAAA,QAgFQrD,OAAA,CAAAA,KAAA,CAAA0B,KAAA,CAAAC,iBAAA;AAAA;AAhFR,SAAAU,OAAAiB,OAAA;EAAA,QA+IUtD,OAAA,CAAAA,KAAA,CAAA0B,KAAA,EAAAC,iBAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/WhereBuilder/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/elements/WhereBuilder/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AASnD,OAAO,cAAc,CAAA;AAIrB,OAAO,EAAE,iBAAiB,EAAE,CAAA;AAE5B;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA+NpD,CAAA"}
|
|
@@ -8,10 +8,10 @@ import { useListQuery } from '../../providers/ListQuery/index.js';
|
|
|
8
8
|
import { useTranslation } from '../../providers/Translation/index.js';
|
|
9
9
|
import { Button } from '../Button/index.js';
|
|
10
10
|
import { Condition } from './Condition/index.js';
|
|
11
|
-
import './index.scss';
|
|
12
11
|
import { reduceClientFields } from './reduceClientFields.js';
|
|
13
12
|
import { transformWhereQuery } from './transformWhereQuery.js';
|
|
14
13
|
import validateWhereQuery from './validateWhereQuery.js';
|
|
14
|
+
import './index.scss';
|
|
15
15
|
const baseClass = 'where-builder';
|
|
16
16
|
/**
|
|
17
17
|
* The WhereBuilder component is used to render the filter controls for a collection's list view.
|
|
@@ -40,12 +40,12 @@ export const WhereBuilder = props => {
|
|
|
40
40
|
} else {
|
|
41
41
|
t0 = $[2];
|
|
42
42
|
}
|
|
43
|
-
const [
|
|
43
|
+
const [options, setOptions] = useState(t0);
|
|
44
44
|
let t1;
|
|
45
45
|
let t2;
|
|
46
46
|
if ($[3] !== fields || $[4] !== i18n) {
|
|
47
47
|
t1 = () => {
|
|
48
|
-
|
|
48
|
+
setOptions(reduceClientFields({
|
|
49
49
|
fields,
|
|
50
50
|
i18n
|
|
51
51
|
}));
|
|
@@ -197,7 +197,7 @@ export const WhereBuilder = props => {
|
|
|
197
197
|
}
|
|
198
198
|
React.useEffect(t7, t8);
|
|
199
199
|
let t9;
|
|
200
|
-
if ($[20] !== addCondition || $[21] !== collectionPluralLabel || $[22] !== conditions || $[23] !== i18n || $[24] !==
|
|
200
|
+
if ($[20] !== addCondition || $[21] !== collectionPluralLabel || $[22] !== conditions || $[23] !== i18n || $[24] !== options || $[25] !== removeCondition || $[26] !== renderedFilters || $[27] !== t || $[28] !== updateCondition) {
|
|
201
201
|
t9 = _jsxs("div", {
|
|
202
202
|
className: baseClass,
|
|
203
203
|
children: [conditions.length > 0 && _jsxs(React.Fragment, {
|
|
@@ -219,7 +219,7 @@ export const WhereBuilder = props => {
|
|
|
219
219
|
children: Array.isArray(or?.and) && or.and.map((_, andIndex_2) => {
|
|
220
220
|
const initialFieldName = Object.keys(conditions[orIndex_2].and[andIndex_2])[0];
|
|
221
221
|
const initialOperator = Object.keys(conditions[orIndex_2].and[andIndex_2]?.[initialFieldName] || {})?.[0] || undefined;
|
|
222
|
-
const initialValue = conditions[orIndex_2].and[andIndex_2]?.[initialFieldName]?.[initialOperator] ||
|
|
222
|
+
const initialValue = conditions[orIndex_2].and[andIndex_2]?.[initialFieldName]?.[initialOperator] || undefined;
|
|
223
223
|
return _jsxs("li", {
|
|
224
224
|
children: [andIndex_2 !== 0 && _jsx("div", {
|
|
225
225
|
className: `${baseClass}__label`,
|
|
@@ -228,9 +228,9 @@ export const WhereBuilder = props => {
|
|
|
228
228
|
addCondition,
|
|
229
229
|
andIndex: andIndex_2,
|
|
230
230
|
fieldName: initialFieldName,
|
|
231
|
-
fields: reducedFields,
|
|
232
231
|
initialValue,
|
|
233
232
|
operator: initialOperator,
|
|
233
|
+
options,
|
|
234
234
|
orIndex: orIndex_2,
|
|
235
235
|
removeCondition,
|
|
236
236
|
RenderedFilter: renderedFilters?.get(initialFieldName),
|
|
@@ -250,7 +250,7 @@ export const WhereBuilder = props => {
|
|
|
250
250
|
onClick: () => {
|
|
251
251
|
addCondition({
|
|
252
252
|
andIndex: 0,
|
|
253
|
-
fieldName:
|
|
253
|
+
fieldName: options[0].value,
|
|
254
254
|
orIndex: conditions.length,
|
|
255
255
|
relation: "or"
|
|
256
256
|
});
|
|
@@ -269,10 +269,10 @@ export const WhereBuilder = props => {
|
|
|
269
269
|
iconPosition: "left",
|
|
270
270
|
iconStyle: "with-border",
|
|
271
271
|
onClick: () => {
|
|
272
|
-
if (
|
|
272
|
+
if (options.length > 0) {
|
|
273
273
|
addCondition({
|
|
274
274
|
andIndex: 0,
|
|
275
|
-
fieldName:
|
|
275
|
+
fieldName: options.find(_temp).value,
|
|
276
276
|
orIndex: conditions.length,
|
|
277
277
|
relation: "or"
|
|
278
278
|
});
|
|
@@ -286,7 +286,7 @@ export const WhereBuilder = props => {
|
|
|
286
286
|
$[21] = collectionPluralLabel;
|
|
287
287
|
$[22] = conditions;
|
|
288
288
|
$[23] = i18n;
|
|
289
|
-
$[24] =
|
|
289
|
+
$[24] = options;
|
|
290
290
|
$[25] = removeCondition;
|
|
291
291
|
$[26] = renderedFilters;
|
|
292
292
|
$[27] = t;
|
|
@@ -297,4 +297,7 @@ export const WhereBuilder = props => {
|
|
|
297
297
|
}
|
|
298
298
|
return t9;
|
|
299
299
|
};
|
|
300
|
+
function _temp(field) {
|
|
301
|
+
return !field.field.admin?.disableListFilter;
|
|
302
|
+
}
|
|
300
303
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","getTranslation","React","useEffect","useState","useListQuery","useTranslation","Button","Condition","reduceClientFields","transformWhereQuery","validateWhereQuery","baseClass","WhereBuilder","props","$","collectionPluralLabel","fields","renderedFilters","i18n","t","t0","reducedFields","setReducedColumns","t1","t2","handleWhereChange","query","shouldUpdateQuery","setShouldUpdateQuery","t3","where","whereFromSearch","or","transformedWhere","console","warn","JSON","stringify","conditions","setConditions","t4","t5","andIndex","fieldName","orIndex","relation","newConditions","and","splice","push","addCondition","t6","andIndex_0","fieldName_0","operator","orIndex_0","value","valueArg","existingRowCondition","newRowCondition","newConditions_0","undefined","includes","updateCondition","t7","andIndex_1","orIndex_1","newConditions_1","length","removeCondition","t8","handleChange","t9","_jsxs","className","children","Fragment","_jsx","label","map","orIndex_2","compoundOrKey","Array","isArray","_","andIndex_2","initialFieldName","Object","keys","initialOperator","initialValue","RenderedFilter","get","buttonStyle","icon","iconPosition","iconStyle","onClick"],"sources":["../../../src/elements/WhereBuilder/index.tsx"],"sourcesContent":["'use client'\nimport type { Operator } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useEffect, useState } from 'react'\n\nimport type { 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 './index.scss'\nimport { reduceClientFields } from './reduceClientFields.js'\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 } = props\n const { i18n, t } = useTranslation()\n\n const [reducedFields, setReducedColumns] = useState(() => reduceClientFields({ fields, i18n }))\n\n useEffect(() => {\n setReducedColumns(reduceClientFields({ fields, i18n }))\n }, [fields, i18n])\n\n const { handleWhereChange, query } = useListQuery()\n const [shouldUpdateQuery, setShouldUpdateQuery] = React.useState(false)\n\n // This handles initializing the where conditions from the search query (URL). That way, if you pass in\n // query params to the URL, the where conditions will be initialized from those and displayed in the UI.\n // Example: /admin/collections/posts?where[or][0][and][0][text][equals]=example%20post\n /*\n stored conditions look like this:\n [\n _or_ & _and_ queries have the same shape:\n {\n and: [{\n category: {\n equals: 'category-a'\n }\n }]\n },\n\n {\n and:[{\n category: {\n equals: 'category-b'\n },\n text: {\n not_equals: 'oranges'\n },\n }]\n }\n ]\n */\n\n const [conditions, setConditions] = React.useState(() => {\n const whereFromSearch = query.where\n\n if (whereFromSearch) {\n if (validateWhereQuery(whereFromSearch)) {\n return whereFromSearch.or\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 = React.useCallback(\n ({ andIndex, fieldName, orIndex, relation }) => {\n const newConditions = [...conditions]\n if (relation === 'and') {\n newConditions[orIndex].and.splice(andIndex, 0, { [fieldName]: {} })\n } else {\n newConditions.push({\n and: [\n {\n [fieldName]: {},\n },\n ],\n })\n }\n setConditions(newConditions)\n },\n [conditions],\n )\n\n const updateCondition = React.useCallback(\n ({ andIndex, fieldName, operator, orIndex, value: valueArg }) => {\n const existingRowCondition = conditions[orIndex].and[andIndex]\n if (typeof existingRowCondition === 'object' && fieldName && operator) {\n const value = valueArg ?? (operator ? existingRowCondition[operator] : '')\n const newRowCondition = {\n [fieldName]: operator ? { [operator]: value } : {},\n }\n\n if (JSON.stringify(existingRowCondition) !== JSON.stringify(newRowCondition)) {\n const newConditions = [...conditions]\n newConditions[orIndex].and[andIndex] = newRowCondition\n setConditions(newConditions)\n if (![null, undefined].includes(value)) {\n // only update query when field/operator/value are filled out\n setShouldUpdateQuery(true)\n }\n }\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 if (newConditions[orIndex].and.length === 0) {\n newConditions.splice(orIndex, 1)\n }\n setConditions(newConditions)\n setShouldUpdateQuery(true)\n },\n [conditions],\n )\n\n React.useEffect(() => {\n if (shouldUpdateQuery) {\n async function handleChange() {\n await handleWhereChange({ or: conditions })\n setShouldUpdateQuery(false)\n }\n void handleChange()\n }\n }, [conditions, handleWhereChange, shouldUpdateQuery])\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 initialFieldName = Object.keys(conditions[orIndex].and[andIndex])[0]\n const initialOperator =\n (Object.keys(\n conditions[orIndex].and[andIndex]?.[initialFieldName] || {},\n )?.[0] as Operator) || undefined\n const initialValue =\n conditions[orIndex].and[andIndex]?.[initialFieldName]?.[\n initialOperator\n ] || ''\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={initialFieldName}\n fields={reducedFields}\n initialValue={initialValue}\n operator={initialOperator}\n orIndex={orIndex}\n removeCondition={removeCondition}\n RenderedFilter={renderedFilters?.get(initialFieldName)}\n updateCondition={updateCondition}\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 fieldName: reducedFields[0].value,\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 fieldName: reducedFields[0].value,\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;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,SAAS,EAAEC,QAAQ,QAAQ;AAI3C,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,SAAS,QAAQ;AAC1B,OAAO;AACP,SAASC,kBAAkB,QAAQ;AACnC,SAASC,mBAAmB,QAAQ;AACpC,OAAOC,kBAAA,MAAwB;AAE/B,MAAMC,SAAA,GAAY;AAIlB;;;;AAIA,OAAO,MAAMC,YAAA,GAA4CC,KAAA;EAAA,MAAAC,CAAA,GAAAf,EAAA;EACvD;IAAAgB,qBAAA;IAAAC,MAAA;IAAAC;EAAA,IAA2DJ,KAAA;EAC3D;IAAAK,IAAA;IAAAC;EAAA,IAAoBd,cAAA;EAAA,IAAAe,EAAA;EAAA,IAAAN,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAI,IAAA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8B,QAAA,EAIHxD,CAAA,CAAE;QAAA,C;;;;;;;;;;;;;;;;SA1FXqD,E;CAgGJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","getTranslation","React","useEffect","useState","useListQuery","useTranslation","Button","Condition","reduceClientFields","transformWhereQuery","validateWhereQuery","baseClass","WhereBuilder","props","$","collectionPluralLabel","fields","renderedFilters","i18n","t","t0","options","setOptions","t1","t2","handleWhereChange","query","shouldUpdateQuery","setShouldUpdateQuery","t3","where","whereFromSearch","or","transformedWhere","console","warn","JSON","stringify","conditions","setConditions","t4","t5","andIndex","fieldName","orIndex","relation","newConditions","and","splice","push","addCondition","t6","andIndex_0","fieldName_0","operator","orIndex_0","value","valueArg","existingRowCondition","newRowCondition","newConditions_0","undefined","includes","updateCondition","t7","andIndex_1","orIndex_1","newConditions_1","length","removeCondition","t8","handleChange","t9","_jsxs","className","children","Fragment","_jsx","label","map","orIndex_2","compoundOrKey","Array","isArray","_","andIndex_2","initialFieldName","Object","keys","initialOperator","initialValue","RenderedFilter","get","buttonStyle","icon","iconPosition","iconStyle","onClick","find","_temp","field","admin","disableListFilter"],"sources":["../../../src/elements/WhereBuilder/index.tsx"],"sourcesContent":["'use client'\nimport type { Operator } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useEffect, useState } from 'react'\n\nimport type { 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 { reduceClientFields } from './reduceClientFields.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 } = props\n const { i18n, t } = useTranslation()\n\n const [options, setOptions] = useState(() => reduceClientFields({ fields, i18n }))\n\n useEffect(() => {\n setOptions(reduceClientFields({ fields, i18n }))\n }, [fields, i18n])\n\n const { handleWhereChange, query } = useListQuery()\n const [shouldUpdateQuery, setShouldUpdateQuery] = React.useState(false)\n\n // This handles initializing the where conditions from the search query (URL). That way, if you pass in\n // query params to the URL, the where conditions will be initialized from those and displayed in the UI.\n // Example: /admin/collections/posts?where[or][0][and][0][text][equals]=example%20post\n /*\n stored conditions look like this:\n [\n _or_ & _and_ queries have the same shape:\n {\n and: [{\n category: {\n equals: 'category-a'\n }\n }]\n },\n\n {\n and:[{\n category: {\n equals: 'category-b'\n },\n text: {\n not_equals: 'oranges'\n },\n }]\n }\n ]\n */\n\n const [conditions, setConditions] = React.useState(() => {\n const whereFromSearch = query.where\n\n if (whereFromSearch) {\n if (validateWhereQuery(whereFromSearch)) {\n return whereFromSearch.or\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 = React.useCallback(\n ({ andIndex, fieldName, orIndex, relation }) => {\n const newConditions = [...conditions]\n if (relation === 'and') {\n newConditions[orIndex].and.splice(andIndex, 0, { [fieldName]: {} })\n } else {\n newConditions.push({\n and: [\n {\n [fieldName]: {},\n },\n ],\n })\n }\n setConditions(newConditions)\n },\n [conditions],\n )\n\n const updateCondition = React.useCallback(\n ({ andIndex, fieldName, operator, orIndex, value: valueArg }) => {\n const existingRowCondition = conditions[orIndex].and[andIndex]\n if (typeof existingRowCondition === 'object' && fieldName && operator) {\n const value = valueArg ?? (operator ? existingRowCondition[operator] : '')\n const newRowCondition = {\n [fieldName]: operator ? { [operator]: value } : {},\n }\n\n if (JSON.stringify(existingRowCondition) !== JSON.stringify(newRowCondition)) {\n const newConditions = [...conditions]\n newConditions[orIndex].and[andIndex] = newRowCondition\n setConditions(newConditions)\n if (![null, undefined].includes(value)) {\n // only update query when field/operator/value are filled out\n setShouldUpdateQuery(true)\n }\n }\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 if (newConditions[orIndex].and.length === 0) {\n newConditions.splice(orIndex, 1)\n }\n setConditions(newConditions)\n setShouldUpdateQuery(true)\n },\n [conditions],\n )\n\n React.useEffect(() => {\n if (shouldUpdateQuery) {\n async function handleChange() {\n await handleWhereChange({ or: conditions })\n setShouldUpdateQuery(false)\n }\n void handleChange()\n }\n }, [conditions, handleWhereChange, shouldUpdateQuery])\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 initialFieldName = Object.keys(conditions[orIndex].and[andIndex])[0]\n const initialOperator =\n (Object.keys(\n conditions[orIndex].and[andIndex]?.[initialFieldName] || {},\n )?.[0] as Operator) || undefined\n const initialValue =\n conditions[orIndex].and[andIndex]?.[initialFieldName]?.[\n initialOperator\n ] || 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={initialFieldName}\n initialValue={initialValue}\n operator={initialOperator}\n options={options}\n orIndex={orIndex}\n removeCondition={removeCondition}\n RenderedFilter={renderedFilters?.get(initialFieldName)}\n updateCondition={updateCondition}\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 fieldName: options[0].value,\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 (options.length > 0) {\n addCondition({\n andIndex: 0,\n fieldName: options.find((field) => !field.field.admin?.disableListFilter).value,\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;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,SAAS,EAAEC,QAAQ,QAAQ;AAI3C,SAASC,YAAY,QAAQ;AAC7B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,SAAS,QAAQ;AAC1B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,mBAAmB,QAAQ;AACpC,OAAOC,kBAAA,MAAwB;AAC/B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAIlB;;;;AAIA,OAAO,MAAMC,YAAA,GAA4CC,KAAA;EAAA,MAAAC,CAAA,GAAAf,EAAA;EACvD;IAAAgB,qBAAA;IAAAC,MAAA;IAAAC;EAAA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