@react-fabric/searchbar 1.0.0-beta.6 → 1.0.0-beta.60
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/cjs/filterbar/FilterBar.js +10 -6
- package/dist/cjs/filterbar/FilterForm.js +141 -36
- package/dist/cjs/filterbar/FilterMenu.js +16 -4
- package/dist/cjs/filterbar/FilterTag.js +16 -8
- package/dist/cjs/filterbar/FilterView.js +6 -2
- package/dist/cjs/filterbar/QueryForm.js +9 -7
- package/dist/cjs/i18n/ar.json.js +42 -39
- package/dist/cjs/i18n/en.json.js +43 -39
- package/dist/cjs/searchbar/SearchBar.js +60 -7
- package/dist/cjs/types/index.js +12 -4
- package/dist/esm/filterbar/FilterBar.js +10 -6
- package/dist/esm/filterbar/FilterForm.js +142 -37
- package/dist/esm/filterbar/FilterMenu.js +16 -4
- package/dist/esm/filterbar/FilterTag.js +16 -8
- package/dist/esm/filterbar/FilterView.js +6 -2
- package/dist/esm/filterbar/QueryForm.js +9 -7
- package/dist/esm/i18n/ar.json.js +42 -39
- package/dist/esm/i18n/en.json.js +43 -39
- package/dist/esm/searchbar/SearchBar.js +61 -8
- package/dist/esm/types/index.js +12 -4
- package/dist/types/filterbar/Context.d.ts +2 -3
- package/dist/types/filterbar/FilterBar.d.ts +27 -1
- package/dist/types/filterbar/FilterMenu.d.ts +2 -1
- package/dist/types/filterbar/FilterTag.d.ts +2 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/searchbar/SearchBar.d.ts +35 -1
- package/dist/types/types/index.d.ts +19 -10
- package/package.json +16 -14
- package/src/filterbar/Context.tsx +4 -1
- package/src/filterbar/FilterBar.tsx +49 -7
- package/src/filterbar/FilterForm.tsx +110 -25
- package/src/filterbar/FilterMenu.tsx +30 -3
- package/src/filterbar/FilterTag.tsx +25 -9
- package/src/filterbar/FilterView.tsx +5 -2
- package/src/filterbar/QueryForm.tsx +5 -5
- package/src/i18n/ar.json +42 -39
- package/src/i18n/en.json +43 -39
- package/src/index.ts +6 -1
- package/src/searchbar/SearchBar.tsx +58 -5
- package/src/types/index.ts +57 -34
|
@@ -25,12 +25,14 @@ import { useFloatingTree } from "@floating-ui/react";
|
|
|
25
25
|
import { Button, Col, Row } from "@react-fabric/core";
|
|
26
26
|
import {
|
|
27
27
|
Controller,
|
|
28
|
+
DateInput,
|
|
28
29
|
Field,
|
|
29
30
|
Form,
|
|
30
31
|
Input,
|
|
31
32
|
Number,
|
|
32
33
|
Select,
|
|
33
34
|
Switch,
|
|
35
|
+
Textarea,
|
|
34
36
|
type FormRef,
|
|
35
37
|
} from "@react-fabric/form";
|
|
36
38
|
import { isArray, shortHash, yup } from "@react-fabric/utilities";
|
|
@@ -48,6 +50,7 @@ import { useFilterContext } from "./Context";
|
|
|
48
50
|
const FilterSchema = new yup.ObjectSchema({
|
|
49
51
|
id: yup.string().required(),
|
|
50
52
|
field: yup.string().required(),
|
|
53
|
+
// type: yup.string().oneOf(Object.values(FIELD_TYPE)),
|
|
51
54
|
operator: yup.string().required().oneOf(Object.values(OPERATOR)),
|
|
52
55
|
negate: yup.boolean(),
|
|
53
56
|
label: yup.string(),
|
|
@@ -59,13 +62,40 @@ const FilterSchema = new yup.ObjectSchema({
|
|
|
59
62
|
otherwise: (schema) => schema.required(),
|
|
60
63
|
})
|
|
61
64
|
.when("operator", {
|
|
62
|
-
is: OPERATOR.
|
|
65
|
+
is: OPERATOR.ANY,
|
|
63
66
|
then: (schema) =>
|
|
64
67
|
schema.test({
|
|
65
68
|
name: "array-check",
|
|
66
69
|
message: `\${path} is a required field`,
|
|
67
70
|
test: (val: AnyObject = []) => val?.length > 0,
|
|
68
71
|
}),
|
|
72
|
+
})
|
|
73
|
+
.when("operator", {
|
|
74
|
+
is: OPERATOR.ALL,
|
|
75
|
+
then: (schema) =>
|
|
76
|
+
schema.test({
|
|
77
|
+
name: "array-check",
|
|
78
|
+
message: `\${path} is a required field`,
|
|
79
|
+
test: (val: AnyObject = []) => val?.length > 0,
|
|
80
|
+
}),
|
|
81
|
+
})
|
|
82
|
+
.when("operator", {
|
|
83
|
+
is: OPERATOR.BETWEEN,
|
|
84
|
+
then: (schema) =>
|
|
85
|
+
schema.test({
|
|
86
|
+
name: "array-check",
|
|
87
|
+
message: `\${path} is a required field`,
|
|
88
|
+
test: (val: AnyObject = []) => val?.length > 0 && val[0] && val[1],
|
|
89
|
+
}),
|
|
90
|
+
})
|
|
91
|
+
.when("operator", {
|
|
92
|
+
is: OPERATOR.BETWEEN,
|
|
93
|
+
then: (schema) =>
|
|
94
|
+
schema.test({
|
|
95
|
+
name: "array-check",
|
|
96
|
+
message: `\${path} min max`,
|
|
97
|
+
test: (val: AnyObject = []) => val?.length > 0 && val[0] < val[1],
|
|
98
|
+
}),
|
|
69
99
|
}),
|
|
70
100
|
});
|
|
71
101
|
|
|
@@ -88,13 +118,15 @@ export const FilterForm = ({
|
|
|
88
118
|
const [values, setValues] = useState<FilterSchemaType>(filter as AnyObject);
|
|
89
119
|
|
|
90
120
|
useEffect(() => {
|
|
91
|
-
if (filter && "field" in filter && filter.field)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
121
|
+
if (filter && "field" in filter && filter.field) {
|
|
122
|
+
formRef.current?.setValues(filter);
|
|
123
|
+
} else {
|
|
124
|
+
formRef.current?.setValues({
|
|
125
|
+
id: shortHash(),
|
|
126
|
+
field: "",
|
|
127
|
+
operator: OPERATOR.EXISTS,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
98
130
|
}, [filter]);
|
|
99
131
|
|
|
100
132
|
useEffect(() => {
|
|
@@ -119,13 +151,15 @@ export const FilterForm = ({
|
|
|
119
151
|
formRef.current?.setValue("value", undefined);
|
|
120
152
|
}
|
|
121
153
|
if (field?.type === FIELD_TYPE.STRING) {
|
|
122
|
-
if (values?.operator
|
|
154
|
+
if ([OPERATOR.ALL, OPERATOR.ANY].includes(values?.operator)) {
|
|
123
155
|
!isArray(values.value) && formRef.current?.setValue("value", []);
|
|
124
156
|
} else {
|
|
125
157
|
isArray(values.value) && formRef.current?.setValue("value", undefined);
|
|
126
158
|
}
|
|
127
159
|
}
|
|
128
160
|
if (
|
|
161
|
+
field?.type === FIELD_TYPE.DATE ||
|
|
162
|
+
field?.type === FIELD_TYPE.DATETIME ||
|
|
129
163
|
field?.type === FIELD_TYPE.NUMBER ||
|
|
130
164
|
field?.type === FIELD_TYPE.DECIMAL
|
|
131
165
|
) {
|
|
@@ -137,7 +171,7 @@ export const FilterForm = ({
|
|
|
137
171
|
}
|
|
138
172
|
if (
|
|
139
173
|
field?.type === FIELD_TYPE.BOOLEAN &&
|
|
140
|
-
values?.operator
|
|
174
|
+
[OPERATOR.IS, OPERATOR.EQ].includes(values?.operator) &&
|
|
141
175
|
values?.value === undefined
|
|
142
176
|
) {
|
|
143
177
|
formRef.current?.setValue("value", false);
|
|
@@ -155,7 +189,7 @@ export const FilterForm = ({
|
|
|
155
189
|
);
|
|
156
190
|
}
|
|
157
191
|
if (field?.type === FIELD_TYPE.STRING || field?.type === FIELD_TYPE.ID) {
|
|
158
|
-
if (values?.operator
|
|
192
|
+
if ([OPERATOR.ALL, OPERATOR.ANY].includes(values?.operator)) {
|
|
159
193
|
return (
|
|
160
194
|
<Controller name="value">
|
|
161
195
|
<Select
|
|
@@ -169,6 +203,19 @@ export const FilterForm = ({
|
|
|
169
203
|
/>
|
|
170
204
|
</Controller>
|
|
171
205
|
);
|
|
206
|
+
} else if (!!field.onSearch || field.values?.length) {
|
|
207
|
+
return (
|
|
208
|
+
<Controller name="value">
|
|
209
|
+
<Select
|
|
210
|
+
searchable
|
|
211
|
+
allowCreate
|
|
212
|
+
allowClear
|
|
213
|
+
options={field.values ?? []}
|
|
214
|
+
label={t("label.value")}
|
|
215
|
+
onQuery={field.onSearch}
|
|
216
|
+
/>
|
|
217
|
+
</Controller>
|
|
218
|
+
);
|
|
172
219
|
} else {
|
|
173
220
|
return (
|
|
174
221
|
<Controller name="value">
|
|
@@ -177,6 +224,13 @@ export const FilterForm = ({
|
|
|
177
224
|
);
|
|
178
225
|
}
|
|
179
226
|
}
|
|
227
|
+
if (field.type === FIELD_TYPE.TEXT) {
|
|
228
|
+
return (
|
|
229
|
+
<Controller name="value">
|
|
230
|
+
<Textarea rows={3} label={t("label.value")} allowClear />
|
|
231
|
+
</Controller>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
180
234
|
if (
|
|
181
235
|
field?.type === FIELD_TYPE.DECIMAL ||
|
|
182
236
|
field?.type === FIELD_TYPE.NUMBER
|
|
@@ -184,15 +238,17 @@ export const FilterForm = ({
|
|
|
184
238
|
const step = field.type === FIELD_TYPE.DECIMAL ? 0.1 : 1;
|
|
185
239
|
if (values?.operator === OPERATOR.BETWEEN) {
|
|
186
240
|
return (
|
|
187
|
-
<
|
|
188
|
-
<
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
241
|
+
<Controller name="value">
|
|
242
|
+
<Field label={t("label.value")}>
|
|
243
|
+
<Controller name="value[0]">
|
|
244
|
+
<Number step={step} allowClear />
|
|
245
|
+
</Controller>
|
|
246
|
+
<span className="p-2 text-muted">{`≷`}</span>
|
|
247
|
+
<Controller name="value[1]">
|
|
248
|
+
<Number step={step} allowClear />
|
|
249
|
+
</Controller>
|
|
250
|
+
</Field>
|
|
251
|
+
</Controller>
|
|
196
252
|
);
|
|
197
253
|
} else {
|
|
198
254
|
return (
|
|
@@ -202,6 +258,33 @@ export const FilterForm = ({
|
|
|
202
258
|
);
|
|
203
259
|
}
|
|
204
260
|
}
|
|
261
|
+
if (
|
|
262
|
+
field?.type === FIELD_TYPE.DATE ||
|
|
263
|
+
field?.type === FIELD_TYPE.DATETIME
|
|
264
|
+
) {
|
|
265
|
+
const type = field.type === FIELD_TYPE.DATETIME ? "datetime" : "date";
|
|
266
|
+
if (values?.operator === OPERATOR.BETWEEN) {
|
|
267
|
+
return (
|
|
268
|
+
<Controller name="value">
|
|
269
|
+
<Field label={t("label.value")}>
|
|
270
|
+
<Controller name="value[0]">
|
|
271
|
+
<DateInput type={type} allowClear />
|
|
272
|
+
</Controller>
|
|
273
|
+
<span className="p-2 text-muted">{`≷`}</span>
|
|
274
|
+
<Controller name="value[1]">
|
|
275
|
+
<DateInput type={type} allowClear />
|
|
276
|
+
</Controller>
|
|
277
|
+
</Field>
|
|
278
|
+
</Controller>
|
|
279
|
+
);
|
|
280
|
+
} else {
|
|
281
|
+
return (
|
|
282
|
+
<Controller name="value">
|
|
283
|
+
<DateInput type={type} allowClear />
|
|
284
|
+
</Controller>
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
205
288
|
}, [field, values?.operator]);
|
|
206
289
|
|
|
207
290
|
const handleSubmit = useCallback(
|
|
@@ -213,11 +296,12 @@ export const FilterForm = ({
|
|
|
213
296
|
operator: model.operator,
|
|
214
297
|
value: model.value as AnyObject,
|
|
215
298
|
label: model.label,
|
|
299
|
+
type: field?.type,
|
|
216
300
|
};
|
|
217
301
|
onChange?.(filter);
|
|
218
302
|
tree?.events.emit("close");
|
|
219
303
|
},
|
|
220
|
-
[onChange],
|
|
304
|
+
[field, onChange],
|
|
221
305
|
);
|
|
222
306
|
|
|
223
307
|
return (
|
|
@@ -228,12 +312,13 @@ export const FilterForm = ({
|
|
|
228
312
|
onChange={setValues}
|
|
229
313
|
onSubmit={handleSubmit}
|
|
230
314
|
>
|
|
231
|
-
<div className="w-
|
|
315
|
+
<div className="w-lg">
|
|
232
316
|
<Row>
|
|
233
317
|
<Col flex="fill">
|
|
234
318
|
<Controller name="field">
|
|
235
319
|
<Select<FilterField>
|
|
236
320
|
required
|
|
321
|
+
searchable
|
|
237
322
|
ref={inputRef}
|
|
238
323
|
label={t("label.field")}
|
|
239
324
|
options={fields}
|
|
@@ -243,13 +328,13 @@ export const FilterForm = ({
|
|
|
243
328
|
/>
|
|
244
329
|
</Controller>
|
|
245
330
|
</Col>
|
|
246
|
-
<Col flex="
|
|
331
|
+
<Col flex="content" className="text-center">
|
|
247
332
|
<label className="block py-0.5 text-sm">{t("label.exclude")}</label>
|
|
248
333
|
<Controller name="negate">
|
|
249
334
|
<Switch color="danger" />
|
|
250
335
|
</Controller>
|
|
251
336
|
</Col>
|
|
252
|
-
<Col flex="
|
|
337
|
+
<Col flex="content" className="basis-28">
|
|
253
338
|
<Controller name="operator">
|
|
254
339
|
<Select
|
|
255
340
|
label={t("label.operator")}
|
|
@@ -273,7 +358,7 @@ export const FilterForm = ({
|
|
|
273
358
|
}
|
|
274
359
|
/>
|
|
275
360
|
</Controller>
|
|
276
|
-
<div className="flex
|
|
361
|
+
<div className="flex mt-4 justify-end gap-1 sticky bottom-1 bg-base">
|
|
277
362
|
{onRemove && (
|
|
278
363
|
<div className="flex-1">
|
|
279
364
|
<Button
|
|
@@ -24,17 +24,24 @@
|
|
|
24
24
|
import { CoreIcons, Divider, Menu, MenuItem } from "@react-fabric/core";
|
|
25
25
|
import { useState } from "react";
|
|
26
26
|
import { useTranslation } from "react-i18next";
|
|
27
|
-
import { type FilterField, type FilterObject } from "../types";
|
|
27
|
+
import { OPERATOR, type FilterField, type FilterObject } from "../types";
|
|
28
28
|
import { FilterEdit } from "./FilterEdit";
|
|
29
29
|
import { FilterView } from "./FilterView";
|
|
30
30
|
|
|
31
|
+
const MATCH_ALL =
|
|
32
|
+
"M9,5C10.04,5 11.06,5.24 12,5.68C12.94,5.24 13.96,5 15,5A7,7 0 0,1 22,12A7,7 0 0,1 15,19C13.96,19 12.94,18.76 12,18.32C11.06,18.76 10.04,19 9,19A7,7 0 0,1 2,12A7,7 0 0,1 9,5M8.5,12C8.5,13.87 9.29,15.56 10.56,16.75L11.56,16.29C10.31,15.29 9.5,13.74 9.5,12C9.5,10.26 10.31,8.71 11.56,7.71L10.56,7.25C9.29,8.44 8.5,10.13 8.5,12M15.5,12C15.5,10.13 14.71,8.44 13.44,7.25L12.44,7.71C13.69,8.71 14.5,10.26 14.5,12C14.5,13.74 13.69,15.29 12.44,16.29L13.44,16.75C14.71,15.56 15.5,13.87 15.5,12Z";
|
|
33
|
+
const MATCH_ANY =
|
|
34
|
+
"M9,5A7,7 0 0,0 2,12A7,7 0 0,0 9,19C10.04,19 11.06,18.76 12,18.32C12.94,18.76 13.96,19 15,19A7,7 0 0,0 22,12A7,7 0 0,0 15,5C13.96,5 12.94,5.24 12,5.68C11.06,5.24 10.04,5 9,5M9,7C9.34,7 9.67,7.03 10,7.1C8.72,8.41 8,10.17 8,12C8,13.83 8.72,15.59 10,16.89C9.67,16.96 9.34,17 9,17A5,5 0 0,1 4,12A5,5 0 0,1 9,7M15,7A5,5 0 0,1 20,12A5,5 0 0,1 15,17C14.66,17 14.33,16.97 14,16.9C15.28,15.59 16,13.83 16,12C16,10.17 15.28,8.41 14,7.11C14.33,7.04 14.66,7 15,7Z";
|
|
35
|
+
|
|
31
36
|
export const FilterMenu = ({
|
|
32
37
|
filter,
|
|
33
38
|
fields,
|
|
39
|
+
editable,
|
|
34
40
|
onChange,
|
|
35
41
|
onRemove,
|
|
36
42
|
}: {
|
|
37
43
|
fields?: FilterField[];
|
|
44
|
+
editable?: boolean;
|
|
38
45
|
filter: FilterObject;
|
|
39
46
|
onRemove: () => void;
|
|
40
47
|
onChange: (filter: FilterObject) => void;
|
|
@@ -48,7 +55,7 @@ export const FilterMenu = ({
|
|
|
48
55
|
<FilterView filter={filter} onRemove={onRemove} />
|
|
49
56
|
) : (
|
|
50
57
|
<Menu className="text-sm">
|
|
51
|
-
{filter.canEdit !== false ? (
|
|
58
|
+
{editable && filter.canEdit !== false ? (
|
|
52
59
|
<MenuItem
|
|
53
60
|
icon={CoreIcons.edit}
|
|
54
61
|
label={t("label.edit")}
|
|
@@ -68,13 +75,33 @@ export const FilterMenu = ({
|
|
|
68
75
|
/>
|
|
69
76
|
)}
|
|
70
77
|
<Divider />
|
|
78
|
+
{filter.operator &&
|
|
79
|
+
[OPERATOR.ALL, OPERATOR.ANY].includes(filter.operator) && (
|
|
80
|
+
<MenuItem
|
|
81
|
+
label={t(
|
|
82
|
+
filter.operator === OPERATOR.ALL
|
|
83
|
+
? "label.matchAny"
|
|
84
|
+
: "label.matchAll",
|
|
85
|
+
)}
|
|
86
|
+
icon={t(filter.operator === OPERATOR.ALL ? MATCH_ANY : MATCH_ALL)}
|
|
87
|
+
onClick={() =>
|
|
88
|
+
onChange({
|
|
89
|
+
...filter,
|
|
90
|
+
operator:
|
|
91
|
+
filter.operator === OPERATOR.ALL
|
|
92
|
+
? OPERATOR.ANY
|
|
93
|
+
: OPERATOR.ALL,
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
/>
|
|
97
|
+
)}
|
|
71
98
|
{filter.canPin !== false && (
|
|
72
99
|
<MenuItem
|
|
73
100
|
label={t(filter.pinned ? "label.unpin" : "label.pin")}
|
|
74
101
|
onClick={() => onChange({ ...filter, pinned: !filter.pinned })}
|
|
75
102
|
/>
|
|
76
103
|
)}
|
|
77
|
-
{filter.canInvert !== false && (
|
|
104
|
+
{filter.canInvert !== false && filter.field && (
|
|
78
105
|
<MenuItem
|
|
79
106
|
label={t(filter.negate ? "label.include" : "label.exclude")}
|
|
80
107
|
onClick={() => onChange({ ...filter, negate: !filter.negate })}
|
|
@@ -32,12 +32,14 @@ import { FilterMenu } from "./FilterMenu";
|
|
|
32
32
|
export const FilterTag = ({
|
|
33
33
|
filter,
|
|
34
34
|
fields,
|
|
35
|
+
editable,
|
|
35
36
|
includedColor = "primary-500",
|
|
36
37
|
excludedColor = "danger-500",
|
|
37
38
|
onChange,
|
|
38
39
|
onRemove,
|
|
39
40
|
}: {
|
|
40
41
|
filter: FilterObject;
|
|
42
|
+
editable?: boolean;
|
|
41
43
|
onRemove: () => void;
|
|
42
44
|
onChange: (filter: FilterObject) => void;
|
|
43
45
|
} & Pick<FilterBarProps, "fields" | "includedColor" | "excludedColor">) => {
|
|
@@ -46,14 +48,18 @@ export const FilterTag = ({
|
|
|
46
48
|
if (filter.label)
|
|
47
49
|
return (
|
|
48
50
|
<Fragment>
|
|
49
|
-
{filter.negate &&
|
|
51
|
+
{filter.field && filter.negate && (
|
|
52
|
+
<span className="font-semibold">NOT</span>
|
|
53
|
+
)}
|
|
50
54
|
<span>{filter.label}</span>
|
|
51
55
|
</Fragment>
|
|
52
56
|
);
|
|
53
57
|
|
|
54
58
|
return (
|
|
55
59
|
<Fragment>
|
|
56
|
-
{filter.negate &&
|
|
60
|
+
{filter.field && filter.negate && (
|
|
61
|
+
<span className="font-semibold">NOT</span>
|
|
62
|
+
)}
|
|
57
63
|
<span>{filter.field}</span>
|
|
58
64
|
<span className="font-semibold">
|
|
59
65
|
{t(`operator.${filter.operator}`, { defaultValue: filter.operator })}
|
|
@@ -68,7 +74,9 @@ export const FilterTag = ({
|
|
|
68
74
|
}, [filter]);
|
|
69
75
|
|
|
70
76
|
const color = useMemo(
|
|
71
|
-
() =>
|
|
77
|
+
() =>
|
|
78
|
+
filter.color ??
|
|
79
|
+
(filter.field && filter.negate ? excludedColor : includedColor),
|
|
72
80
|
[filter, includedColor, excludedColor],
|
|
73
81
|
);
|
|
74
82
|
|
|
@@ -82,15 +90,17 @@ export const FilterTag = ({
|
|
|
82
90
|
<Chip
|
|
83
91
|
size="sm"
|
|
84
92
|
color={color}
|
|
85
|
-
className=
|
|
93
|
+
className={classNames(
|
|
94
|
+
"outline max-w-60",
|
|
95
|
+
filter.disabled && "opacity-65",
|
|
96
|
+
)}
|
|
86
97
|
variant={filter.pinned ? "solid" : undefined}
|
|
87
|
-
icon={icon}
|
|
88
|
-
iconColor={color}
|
|
98
|
+
icon={icon && { icon, color }}
|
|
89
99
|
onIconClick={(e) => [
|
|
90
100
|
onChange({ ...filter, disabled: !filter.disabled }),
|
|
91
101
|
e.stopPropagation(),
|
|
92
102
|
]}
|
|
93
|
-
data-
|
|
103
|
+
data-ref="filterTag"
|
|
94
104
|
data-test-value={filter.id}
|
|
95
105
|
stopPropagation
|
|
96
106
|
onRemove={filter.required ? undefined : () => onRemove()}
|
|
@@ -101,13 +111,19 @@ export const FilterTag = ({
|
|
|
101
111
|
filter.disabled && "line-through opacity-65",
|
|
102
112
|
)}
|
|
103
113
|
>
|
|
104
|
-
{filter.pinned &&
|
|
105
|
-
|
|
114
|
+
{filter.pinned && (
|
|
115
|
+
<Icon
|
|
116
|
+
className="flex-content"
|
|
117
|
+
icon={filter.icon ?? CoreIcons.pin}
|
|
118
|
+
/>
|
|
119
|
+
)}
|
|
120
|
+
<div className="truncate flex gap-x-0.5 flex-nowrap">{label}</div>
|
|
106
121
|
</div>
|
|
107
122
|
</Chip>
|
|
108
123
|
<FilterMenu
|
|
109
124
|
filter={filter}
|
|
110
125
|
fields={fields}
|
|
126
|
+
editable={editable}
|
|
111
127
|
onChange={onChange}
|
|
112
128
|
onRemove={onRemove}
|
|
113
129
|
/>
|
|
@@ -47,9 +47,12 @@ export const FilterView = ({
|
|
|
47
47
|
value = `[${filter.value?.join(" - ")}]`;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
if (filter.operator === OPERATOR.
|
|
50
|
+
if (filter.operator === OPERATOR.ANY && isArray(filter.value)) {
|
|
51
51
|
value = `[${filter.value?.join(", ")}]`;
|
|
52
52
|
}
|
|
53
|
+
if (filter.operator === OPERATOR.ALL && isArray(filter.value)) {
|
|
54
|
+
value = `(${filter.value?.join(", ")})`;
|
|
55
|
+
}
|
|
53
56
|
|
|
54
57
|
return (
|
|
55
58
|
<Fragment>
|
|
@@ -70,7 +73,7 @@ export const FilterView = ({
|
|
|
70
73
|
<Copy size="sm" text={view as AnyObject} />
|
|
71
74
|
</div>
|
|
72
75
|
)}
|
|
73
|
-
<pre className="overflow-auto bg-base outline text-sm p-2 max-h-
|
|
76
|
+
<pre className="overflow-auto bg-base outline text-sm p-2 max-h-96 max-w-3xl min-w-[24rem]">
|
|
74
77
|
{view}
|
|
75
78
|
</pre>
|
|
76
79
|
{!filter.required && (
|
|
@@ -60,7 +60,7 @@ export const QueryForm = ({
|
|
|
60
60
|
}) => {
|
|
61
61
|
const { t } = useTranslation("searchbar");
|
|
62
62
|
const tree = useFloatingTree();
|
|
63
|
-
const { defaultQuery = "", querySchema } = useFilterContext();
|
|
63
|
+
const { defaultQuery = "", querySchema, queryLanguage } = useFilterContext();
|
|
64
64
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
65
65
|
|
|
66
66
|
const filterValue = useMemo(() => {
|
|
@@ -112,7 +112,7 @@ export const QueryForm = ({
|
|
|
112
112
|
/>
|
|
113
113
|
</Controller>
|
|
114
114
|
<Controller name="query">
|
|
115
|
-
{({ checked, error, invalid, ...field }) => (
|
|
115
|
+
{({ checked, error, invalid, ref, ...field }) => (
|
|
116
116
|
<div className="my-2">
|
|
117
117
|
<label
|
|
118
118
|
className={classNames("block px-2", invalid && "text-danger-600")}
|
|
@@ -120,13 +120,13 @@ export const QueryForm = ({
|
|
|
120
120
|
{t("label.query")}
|
|
121
121
|
</label>
|
|
122
122
|
<div
|
|
123
|
-
className="h-
|
|
123
|
+
className="h-96 w-xl grid outline place-content-start"
|
|
124
124
|
style={{
|
|
125
125
|
gridTemplate: '"content" 1fr/1fr',
|
|
126
126
|
}}
|
|
127
127
|
>
|
|
128
128
|
<CodeEditor
|
|
129
|
-
language="
|
|
129
|
+
language={queryLanguage ?? "text"}
|
|
130
130
|
minimal
|
|
131
131
|
required
|
|
132
132
|
{...field}
|
|
@@ -136,7 +136,7 @@ export const QueryForm = ({
|
|
|
136
136
|
</div>
|
|
137
137
|
)}
|
|
138
138
|
</Controller>
|
|
139
|
-
<div className="flex justify-end gap-1">
|
|
139
|
+
<div className="flex mt-4 justify-end gap-1 sticky bottom-1 bg-base">
|
|
140
140
|
{onRemove && (
|
|
141
141
|
<div className="flex-1">
|
|
142
142
|
<Button
|
package/src/i18n/ar.json
CHANGED
|
@@ -1,68 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"label": {
|
|
3
|
-
"
|
|
3
|
+
"add": "إضافة عامل تصفية",
|
|
4
4
|
"all_filters": "جميع المرشحات",
|
|
5
|
+
"apply": "يتقدم",
|
|
6
|
+
"basicFilter": "الفلتر الأساسي",
|
|
7
|
+
"cancel": "يلغي",
|
|
8
|
+
"customQuery": "استعلام مخصص",
|
|
9
|
+
"delete": "يمسح",
|
|
10
|
+
"disable": "إبطال",
|
|
11
|
+
"disableAll": "تعطيل الكل",
|
|
12
|
+
"edit": "يحرر",
|
|
13
|
+
"enable": "يُمكَِن",
|
|
14
|
+
"enableAll": "تمكين الكل",
|
|
15
|
+
"exclude": "استبعاد",
|
|
16
|
+
"excludeAll": "استبعاد الكل",
|
|
5
17
|
"field": "مجال",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
18
|
+
"filters": "المرشحات",
|
|
19
|
+
"forAdvanced": "للمستخدمين المتقدمين فقط!",
|
|
20
|
+
"include": "يشمل",
|
|
21
|
+
"includeAll": "تضمين الكل",
|
|
22
|
+
"invertAll": "عكس التضمين/الاستبعاد",
|
|
8
23
|
"label": "ملصق",
|
|
24
|
+
"operator": "المشغل",
|
|
9
25
|
"optional": "خياري",
|
|
10
|
-
"add": "إضافة عامل تصفية",
|
|
11
|
-
"edit": "يحرر",
|
|
12
|
-
"view": "منظر",
|
|
13
26
|
"pin": "مثبت",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"invertAll": "عكس التضمين/الاستبعاد",
|
|
27
|
+
"query": "استفسار",
|
|
28
|
+
"refresh": "ينعش",
|
|
29
|
+
"remove": "يزيل",
|
|
18
30
|
"removeAll": "إزالة الكل",
|
|
19
|
-
"enableAll": "تمكين الكل",
|
|
20
|
-
"disableAll": "تعطيل الكل",
|
|
21
31
|
"toggleDisable": "عكس تعطيل/تمكين",
|
|
22
|
-
"
|
|
23
|
-
"enable": "يُمكَِن",
|
|
24
|
-
"disable": "إبطال",
|
|
25
|
-
"exclude": "استبعاد",
|
|
26
|
-
"include": "يشمل",
|
|
27
|
-
"refresh": "ينعش",
|
|
32
|
+
"unpin": "غير مثبت",
|
|
28
33
|
"update": "تحديث",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"basicFilter": "الفلتر الأساسي",
|
|
34
|
-
"customQuery": "استعلام مخصص",
|
|
35
|
-
"forAdvanced": "للمستخدمين المتقدمين فقط!"
|
|
34
|
+
"value": "قيمة",
|
|
35
|
+
"view": "منظر",
|
|
36
|
+
"matchAll": "تطابق كل شيء",
|
|
37
|
+
"matchAny": "تطابق أي"
|
|
36
38
|
},
|
|
37
39
|
"operator": {
|
|
40
|
+
"ALL": "كل",
|
|
41
|
+
"ANY": "أي من",
|
|
42
|
+
"BETWEEN": "بين هذا وذاك",
|
|
43
|
+
"ENDS": "ينتهي مع",
|
|
38
44
|
"EXISTS": "موجود",
|
|
45
|
+
"GT": ">",
|
|
46
|
+
"GTE": "≥",
|
|
39
47
|
"IS": "يكون",
|
|
40
|
-
"
|
|
48
|
+
"LIKE": "يحب",
|
|
41
49
|
"LT": "<",
|
|
42
|
-
"GT": ">",
|
|
43
50
|
"LTE": "≤",
|
|
44
|
-
"GTE": "≥",
|
|
45
|
-
"INCLUDES": "يشمل",
|
|
46
51
|
"STARTS": "ابدا ب",
|
|
47
|
-
"
|
|
48
|
-
"WITHIN": "في غضون",
|
|
49
|
-
"BETWEEN": "بين هذا وذاك"
|
|
52
|
+
"WITHIN": "في غضون"
|
|
50
53
|
},
|
|
51
54
|
"placeholder": "مصطلح البحث...",
|
|
52
55
|
"type": {
|
|
53
|
-
"STRING": "سلسلة",
|
|
54
|
-
"NUMBER": "كثافة العمليات",
|
|
55
|
-
"DECIMAL": "يطفو",
|
|
56
56
|
"BOOLEAN": "رقم",
|
|
57
57
|
"DATE": "منطقي",
|
|
58
58
|
"DATETIME": "تاريخ",
|
|
59
|
-
"
|
|
59
|
+
"DECIMAL": "يطفو",
|
|
60
|
+
"GEO": "GeoJSON",
|
|
61
|
+
"NUMBER": "كثافة العمليات",
|
|
62
|
+
"STRING": "سلسلة"
|
|
60
63
|
},
|
|
61
64
|
"validate": {
|
|
65
|
+
"compare": "مقارنة الحقل المطلوب",
|
|
62
66
|
"field": "حقل مطلوب",
|
|
67
|
+
"label": "التصنيف مطلوب",
|
|
63
68
|
"operator": "عامل مطلوب",
|
|
64
|
-
"value": "القيمة المطلوبة"
|
|
65
|
-
"compare": "مقارنة الحقل المطلوب",
|
|
66
|
-
"label": "التصنيف مطلوب"
|
|
69
|
+
"value": "القيمة المطلوبة"
|
|
67
70
|
}
|
|
68
71
|
}
|