@react-fabric/searchbar 1.0.0-beta.5 → 1.0.0-beta.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/cjs/filterbar/FilterBar.js +9 -5
  2. package/dist/cjs/filterbar/FilterForm.js +138 -33
  3. package/dist/cjs/filterbar/FilterMenu.js +16 -4
  4. package/dist/cjs/filterbar/FilterTag.js +9 -4
  5. package/dist/cjs/filterbar/FilterView.js +5 -1
  6. package/dist/cjs/filterbar/QueryForm.js +8 -5
  7. package/dist/cjs/i18n/ar.json.js +42 -39
  8. package/dist/cjs/i18n/en.json.js +43 -39
  9. package/dist/cjs/searchbar/SearchBar.js +58 -4
  10. package/dist/cjs/types/index.js +12 -4
  11. package/dist/esm/filterbar/FilterBar.js +9 -5
  12. package/dist/esm/filterbar/FilterForm.js +139 -34
  13. package/dist/esm/filterbar/FilterMenu.js +16 -4
  14. package/dist/esm/filterbar/FilterTag.js +9 -4
  15. package/dist/esm/filterbar/FilterView.js +5 -1
  16. package/dist/esm/filterbar/QueryForm.js +8 -5
  17. package/dist/esm/i18n/ar.json.js +42 -39
  18. package/dist/esm/i18n/en.json.js +43 -39
  19. package/dist/esm/searchbar/SearchBar.js +59 -5
  20. package/dist/esm/types/index.js +12 -4
  21. package/dist/types/filterbar/Context.d.ts +2 -3
  22. package/dist/types/filterbar/FilterBar.d.ts +27 -1
  23. package/dist/types/filterbar/FilterMenu.d.ts +2 -1
  24. package/dist/types/filterbar/FilterTag.d.ts +2 -1
  25. package/dist/types/index.d.ts +1 -1
  26. package/dist/types/searchbar/SearchBar.d.ts +35 -1
  27. package/dist/types/types/index.d.ts +19 -10
  28. package/package.json +15 -13
  29. package/src/filterbar/Context.tsx +4 -1
  30. package/src/filterbar/FilterBar.tsx +48 -6
  31. package/src/filterbar/FilterForm.tsx +107 -22
  32. package/src/filterbar/FilterMenu.tsx +30 -3
  33. package/src/filterbar/FilterTag.tsx +25 -6
  34. package/src/filterbar/FilterView.tsx +4 -1
  35. package/src/filterbar/QueryForm.tsx +10 -4
  36. package/src/i18n/ar.json +42 -39
  37. package/src/i18n/en.json +43 -39
  38. package/src/index.ts +6 -1
  39. package/src/searchbar/SearchBar.tsx +52 -2
  40. package/src/types/index.ts +57 -34
@@ -19,7 +19,9 @@ var FilterBar = function FilterBar(_ref) {
19
19
  filters = _ref$filters === void 0 ? [] : _ref$filters,
20
20
  allowAdd = _ref.allowAdd,
21
21
  fields = _ref.fields,
22
+ editable = _ref.editable,
22
23
  querySchema = _ref.querySchema,
24
+ queryLanguage = _ref.queryLanguage,
23
25
  defaultQuery = _ref.defaultQuery,
24
26
  includedColor = _ref.includedColor,
25
27
  excludedColor = _ref.excludedColor,
@@ -48,9 +50,9 @@ var FilterBar = function FilterBar(_ref) {
48
50
  if (type === "disableAll") filter.disabled = true;
49
51
  if (type === "enableAll") filter.disabled = false;
50
52
  if (type === "toggleDisable") filter.disabled = !filter.disabled;
51
- if (type === "excludeAll") filter.negate = true;
52
- if (type === "includeAll") filter.negate = false;
53
- if (type === "invertAll") filter.negate = !filter.negate;
53
+ if (type === "excludeAll" && filter.field) filter.negate = true;
54
+ if (type === "includeAll" && filter.field) filter.negate = false;
55
+ if (type === "invertAll" && filter.field) filter.negate = !filter.negate;
54
56
  return _objectSpread({}, filter);
55
57
  })));
56
58
  }
@@ -67,8 +69,8 @@ var FilterBar = function FilterBar(_ref) {
67
69
  filters.forEach(function (filter) {
68
70
  if (filter.disabled && filter.canDisable !== false && !key.someDisabled) key.someDisabled = true;
69
71
  if (!filter.disabled && filter.canDisable !== false && !key.someEnabled) key.someEnabled = true;
70
- if (filter.negate && filter.canInvert !== false && !key.someExcluded) key.someExcluded = true;
71
- if (!filter.negate && filter.canInvert !== false && !key.someIncluded) key.someIncluded = true;
72
+ if (filter.field && filter.negate && filter.canInvert !== false && !key.someExcluded) key.someExcluded = true;
73
+ if (filter.field && !filter.negate && filter.canInvert !== false && !key.someIncluded) key.someIncluded = true;
72
74
  if (!filter.required && !key.canRemoveAll) key.canRemoveAll = true;
73
75
  });
74
76
  return key;
@@ -77,6 +79,7 @@ var FilterBar = function FilterBar(_ref) {
77
79
  value: {
78
80
  defaultQuery: defaultQuery,
79
81
  querySchema: querySchema,
82
+ queryLanguage: queryLanguage,
80
83
  fields: fields
81
84
  },
82
85
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -122,6 +125,7 @@ var FilterBar = function FilterBar(_ref) {
122
125
  }), filters === null || filters === void 0 ? void 0 : filters.map(function (filter, idx) {
123
126
  return /*#__PURE__*/jsxRuntime.jsx(FilterTag.FilterTag, {
124
127
  filter: filter,
128
+ editable: editable,
125
129
  includedColor: includedColor,
126
130
  excludedColor: excludedColor,
127
131
  onRemove: function onRemove() {
@@ -15,6 +15,7 @@ var jsxRuntime = require('react/jsx-runtime');
15
15
  var FilterSchema = new utilities.yup.ObjectSchema({
16
16
  id: utilities.yup.string().required(),
17
17
  field: utilities.yup.string().required(),
18
+ // type: yup.string().oneOf(Object.values(FIELD_TYPE)),
18
19
  operator: utilities.yup.string().required().oneOf(Object.values(index.OPERATOR)),
19
20
  negate: utilities.yup["boolean"](),
20
21
  label: utilities.yup.string(),
@@ -27,7 +28,7 @@ var FilterSchema = new utilities.yup.ObjectSchema({
27
28
  return schema.required();
28
29
  }
29
30
  }).when("operator", {
30
- is: index.OPERATOR.IN,
31
+ is: index.OPERATOR.ANY,
31
32
  then: function then(schema) {
32
33
  return schema.test({
33
34
  name: "array-check",
@@ -38,6 +39,42 @@ var FilterSchema = new utilities.yup.ObjectSchema({
38
39
  }
39
40
  });
40
41
  }
42
+ }).when("operator", {
43
+ is: index.OPERATOR.ALL,
44
+ then: function then(schema) {
45
+ return schema.test({
46
+ name: "array-check",
47
+ message: "${path} is a required field",
48
+ test: function test() {
49
+ var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
50
+ return (val === null || val === void 0 ? void 0 : val.length) > 0;
51
+ }
52
+ });
53
+ }
54
+ }).when("operator", {
55
+ is: index.OPERATOR.BETWEEN,
56
+ then: function then(schema) {
57
+ return schema.test({
58
+ name: "array-check",
59
+ message: "${path} is a required field",
60
+ test: function test() {
61
+ var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
62
+ return (val === null || val === void 0 ? void 0 : val.length) > 0 && val[0] && val[1];
63
+ }
64
+ });
65
+ }
66
+ }).when("operator", {
67
+ is: index.OPERATOR.BETWEEN,
68
+ then: function then(schema) {
69
+ return schema.test({
70
+ name: "array-check",
71
+ message: "${path} min max",
72
+ test: function test() {
73
+ var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
74
+ return (val === null || val === void 0 ? void 0 : val.length) > 0 && val[0] < val[1];
75
+ }
76
+ });
77
+ }
41
78
  })
42
79
  });
43
80
  var FilterForm = function FilterForm(_ref) {
@@ -57,13 +94,17 @@ var FilterForm = function FilterForm(_ref) {
57
94
  values = _useState2[0],
58
95
  setValues = _useState2[1];
59
96
  react$1.useEffect(function () {
60
- var _formRef$current, _formRef$current2;
61
- if (filter && "field" in filter && filter.field) return (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.setValues(filter);
62
- (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setValues({
63
- id: utilities.shortHash(),
64
- field: "",
65
- operator: index.OPERATOR.EXISTS
66
- });
97
+ if (filter && "field" in filter && filter.field) {
98
+ var _formRef$current;
99
+ (_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.setValues(filter);
100
+ } else {
101
+ var _formRef$current2;
102
+ (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setValues({
103
+ id: utilities.shortHash(),
104
+ field: "",
105
+ operator: index.OPERATOR.EXISTS
106
+ });
107
+ }
67
108
  }, [filter]);
68
109
  react$1.useEffect(function () {
69
110
  setTimeout(function () {
@@ -89,7 +130,7 @@ var FilterForm = function FilterForm(_ref) {
89
130
  (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 || _formRef$current4.setValue("value", undefined);
90
131
  }
91
132
  if ((field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.STRING) {
92
- if ((values === null || values === void 0 ? void 0 : values.operator) === index.OPERATOR.IN) {
133
+ if ([index.OPERATOR.ALL, index.OPERATOR.ANY].includes(values === null || values === void 0 ? void 0 : values.operator)) {
93
134
  var _formRef$current5;
94
135
  !utilities.isArray(values.value) && ((_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 ? void 0 : _formRef$current5.setValue("value", []));
95
136
  } else {
@@ -97,7 +138,7 @@ var FilterForm = function FilterForm(_ref) {
97
138
  utilities.isArray(values.value) && ((_formRef$current6 = formRef.current) === null || _formRef$current6 === void 0 ? void 0 : _formRef$current6.setValue("value", undefined));
98
139
  }
99
140
  }
100
- if ((field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.NUMBER || (field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.DECIMAL) {
141
+ if ((field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.DATE || (field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.DATETIME || (field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.NUMBER || (field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.DECIMAL) {
101
142
  if ((values === null || values === void 0 ? void 0 : values.operator) === index.OPERATOR.BETWEEN) {
102
143
  var _formRef$current7;
103
144
  !utilities.isArray(values.value) && ((_formRef$current7 = formRef.current) === null || _formRef$current7 === void 0 ? void 0 : _formRef$current7.setValue("value", []));
@@ -106,7 +147,7 @@ var FilterForm = function FilterForm(_ref) {
106
147
  utilities.isArray(values.value) && ((_formRef$current8 = formRef.current) === null || _formRef$current8 === void 0 ? void 0 : _formRef$current8.setValue("value", undefined));
107
148
  }
108
149
  }
109
- if ((field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.BOOLEAN && (values === null || values === void 0 ? void 0 : values.operator) === index.OPERATOR.IS && (values === null || values === void 0 ? void 0 : values.value) === undefined) {
150
+ if ((field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.BOOLEAN && [index.OPERATOR.IS, index.OPERATOR.EQ].includes(values === null || values === void 0 ? void 0 : values.operator) && (values === null || values === void 0 ? void 0 : values.value) === undefined) {
110
151
  var _formRef$current9;
111
152
  (_formRef$current9 = formRef.current) === null || _formRef$current9 === void 0 || _formRef$current9.setValue("value", false);
112
153
  }
@@ -123,7 +164,8 @@ var FilterForm = function FilterForm(_ref) {
123
164
  });
124
165
  }
125
166
  if ((field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.STRING || (field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.ID) {
126
- if ((values === null || values === void 0 ? void 0 : values.operator) === index.OPERATOR.IN) {
167
+ var _field$values2;
168
+ if ([index.OPERATOR.ALL, index.OPERATOR.ANY].includes(values === null || values === void 0 ? void 0 : values.operator)) {
127
169
  var _field$values;
128
170
  return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
129
171
  name: "value",
@@ -137,6 +179,19 @@ var FilterForm = function FilterForm(_ref) {
137
179
  onQuery: field.onSearch
138
180
  })
139
181
  });
182
+ } else if (!!field.onSearch || (_field$values2 = field.values) !== null && _field$values2 !== void 0 && _field$values2.length) {
183
+ var _field$values3;
184
+ return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
185
+ name: "value",
186
+ children: /*#__PURE__*/jsxRuntime.jsx(form.Select, {
187
+ searchable: true,
188
+ allowCreate: true,
189
+ allowClear: true,
190
+ options: (_field$values3 = field.values) !== null && _field$values3 !== void 0 ? _field$values3 : [],
191
+ label: t("label.value"),
192
+ onQuery: field.onSearch
193
+ })
194
+ });
140
195
  } else {
141
196
  return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
142
197
  name: "value",
@@ -147,27 +202,40 @@ var FilterForm = function FilterForm(_ref) {
147
202
  });
148
203
  }
149
204
  }
205
+ if (field.type === index.FIELD_TYPE.TEXT) {
206
+ return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
207
+ name: "value",
208
+ children: /*#__PURE__*/jsxRuntime.jsx(form.Textarea, {
209
+ rows: 3,
210
+ label: t("label.value"),
211
+ allowClear: true
212
+ })
213
+ });
214
+ }
150
215
  if ((field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.DECIMAL || (field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.NUMBER) {
151
216
  var step = field.type === index.FIELD_TYPE.DECIMAL ? 0.1 : 1;
152
217
  if ((values === null || values === void 0 ? void 0 : values.operator) === index.OPERATOR.BETWEEN) {
153
- return /*#__PURE__*/jsxRuntime.jsxs(form.Field, {
154
- label: t("label.value"),
155
- children: [/*#__PURE__*/jsxRuntime.jsx(form.Controller, {
156
- name: "value[0]",
157
- children: /*#__PURE__*/jsxRuntime.jsx(form.Number, {
158
- step: step,
159
- allowClear: true
160
- })
161
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
162
- className: "p-2 text-muted",
163
- children: "\u2277"
164
- }), /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
165
- name: "value[1]",
166
- children: /*#__PURE__*/jsxRuntime.jsx(form.Number, {
167
- step: step,
168
- allowClear: true
169
- })
170
- })]
218
+ return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
219
+ name: "value",
220
+ children: /*#__PURE__*/jsxRuntime.jsxs(form.Field, {
221
+ label: t("label.value"),
222
+ children: [/*#__PURE__*/jsxRuntime.jsx(form.Controller, {
223
+ name: "value[0]",
224
+ children: /*#__PURE__*/jsxRuntime.jsx(form.Number, {
225
+ step: step,
226
+ allowClear: true
227
+ })
228
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
229
+ className: "p-2 text-muted",
230
+ children: "\u2277"
231
+ }), /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
232
+ name: "value[1]",
233
+ children: /*#__PURE__*/jsxRuntime.jsx(form.Number, {
234
+ step: step,
235
+ allowClear: true
236
+ })
237
+ })]
238
+ })
171
239
  });
172
240
  } else {
173
241
  return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
@@ -180,6 +248,41 @@ var FilterForm = function FilterForm(_ref) {
180
248
  });
181
249
  }
182
250
  }
251
+ if ((field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.DATE || (field === null || field === void 0 ? void 0 : field.type) === index.FIELD_TYPE.DATETIME) {
252
+ var type = field.type === index.FIELD_TYPE.DATETIME ? "datetime" : "date";
253
+ if ((values === null || values === void 0 ? void 0 : values.operator) === index.OPERATOR.BETWEEN) {
254
+ return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
255
+ name: "value",
256
+ children: /*#__PURE__*/jsxRuntime.jsxs(form.Field, {
257
+ label: t("label.value"),
258
+ children: [/*#__PURE__*/jsxRuntime.jsx(form.Controller, {
259
+ name: "value[0]",
260
+ children: /*#__PURE__*/jsxRuntime.jsx(form.DateInput, {
261
+ type: type,
262
+ allowClear: true
263
+ })
264
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
265
+ className: "p-2 text-muted",
266
+ children: "\u2277"
267
+ }), /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
268
+ name: "value[1]",
269
+ children: /*#__PURE__*/jsxRuntime.jsx(form.DateInput, {
270
+ type: type,
271
+ allowClear: true
272
+ })
273
+ })]
274
+ })
275
+ });
276
+ } else {
277
+ return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
278
+ name: "value",
279
+ children: /*#__PURE__*/jsxRuntime.jsx(form.DateInput, {
280
+ type: type,
281
+ allowClear: true
282
+ })
283
+ });
284
+ }
285
+ }
183
286
  }, [field, values === null || values === void 0 ? void 0 : values.operator]);
184
287
  var handleSubmit = react$1.useCallback(function (model) {
185
288
  var filter = {
@@ -188,11 +291,12 @@ var FilterForm = function FilterForm(_ref) {
188
291
  negate: model.negate,
189
292
  operator: model.operator,
190
293
  value: model.value,
191
- label: model.label
294
+ label: model.label,
295
+ type: field === null || field === void 0 ? void 0 : field.type
192
296
  };
193
297
  onChange === null || onChange === void 0 || onChange(filter);
194
298
  tree === null || tree === void 0 || tree.events.emit("close");
195
- }, [onChange]);
299
+ }, [field, onChange]);
196
300
  return /*#__PURE__*/jsxRuntime.jsx(form.Form, {
197
301
  formRef: formRef,
198
302
  schema: FilterSchema,
@@ -208,6 +312,7 @@ var FilterForm = function FilterForm(_ref) {
208
312
  name: "field",
209
313
  children: /*#__PURE__*/jsxRuntime.jsx(form.Select, {
210
314
  required: true,
315
+ searchable: true,
211
316
  ref: inputRef,
212
317
  label: t("label.field"),
213
318
  options: fields,
@@ -253,7 +358,7 @@ var FilterForm = function FilterForm(_ref) {
253
358
  })
254
359
  })
255
360
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
256
- className: "flex pt-4 justify-end gap-1",
361
+ className: "flex mt-4 justify-end gap-1 sticky bottom-1 bg-base",
257
362
  children: [onRemove && /*#__PURE__*/jsxRuntime.jsx("div", {
258
363
  className: "flex-1",
259
364
  children: /*#__PURE__*/jsxRuntime.jsx(core.Button, {
@@ -5,16 +5,20 @@ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
5
5
  var core = require('@react-fabric/core');
6
6
  var react = require('react');
7
7
  var reactI18next = require('react-i18next');
8
+ var index = require('../types/index.js');
8
9
  var FilterEdit = require('./FilterEdit.js');
9
10
  var FilterView = require('./FilterView.js');
10
11
  var jsxRuntime = require('react/jsx-runtime');
11
12
 
12
13
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
14
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ var MATCH_ALL = "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";
16
+ var MATCH_ANY = "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";
14
17
  var FilterMenu = function FilterMenu(_ref) {
15
18
  var filter = _ref.filter;
16
19
  _ref.fields;
17
- var onChange = _ref.onChange,
20
+ var editable = _ref.editable,
21
+ onChange = _ref.onChange,
18
22
  onRemove = _ref.onRemove;
19
23
  var _useTranslation = reactI18next.useTranslation("searchbar"),
20
24
  t = _useTranslation.t;
@@ -31,7 +35,7 @@ var FilterMenu = function FilterMenu(_ref) {
31
35
  onRemove: onRemove
32
36
  }) : /*#__PURE__*/jsxRuntime.jsxs(core.Menu, {
33
37
  className: "text-sm",
34
- children: [filter.canEdit !== false ? /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
38
+ children: [editable && filter.canEdit !== false ? /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
35
39
  icon: core.CoreIcons.edit,
36
40
  label: t("label.edit"),
37
41
  "data-dropdown-dismiss": "false",
@@ -45,14 +49,22 @@ var FilterMenu = function FilterMenu(_ref) {
45
49
  onClick: function onClick() {
46
50
  setView("view");
47
51
  }
48
- }), /*#__PURE__*/jsxRuntime.jsx(core.Divider, {}), filter.canPin !== false && /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
52
+ }), /*#__PURE__*/jsxRuntime.jsx(core.Divider, {}), filter.operator && [index.OPERATOR.ALL, index.OPERATOR.ANY].includes(filter.operator) && /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
53
+ label: t(filter.operator === index.OPERATOR.ALL ? "label.matchAny" : "label.matchAll"),
54
+ icon: t(filter.operator === index.OPERATOR.ALL ? MATCH_ANY : MATCH_ALL),
55
+ onClick: function onClick() {
56
+ return onChange(_objectSpread(_objectSpread({}, filter), {}, {
57
+ operator: filter.operator === index.OPERATOR.ALL ? index.OPERATOR.ANY : index.OPERATOR.ALL
58
+ }));
59
+ }
60
+ }), filter.canPin !== false && /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
49
61
  label: t(filter.pinned ? "label.unpin" : "label.pin"),
50
62
  onClick: function onClick() {
51
63
  return onChange(_objectSpread(_objectSpread({}, filter), {}, {
52
64
  pinned: !filter.pinned
53
65
  }));
54
66
  }
55
- }), filter.canInvert !== false && /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
67
+ }), filter.canInvert !== false && filter.field && /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
56
68
  label: t(filter.negate ? "label.include" : "label.exclude"),
57
69
  onClick: function onClick() {
58
70
  return onChange(_objectSpread(_objectSpread({}, filter), {}, {
@@ -15,6 +15,7 @@ var FilterTag = function FilterTag(_ref) {
15
15
  var _filter$icon;
16
16
  var filter = _ref.filter,
17
17
  fields = _ref.fields,
18
+ editable = _ref.editable,
18
19
  _ref$includedColor = _ref.includedColor,
19
20
  includedColor = _ref$includedColor === void 0 ? "primary-500" : _ref$includedColor,
20
21
  _ref$excludedColor = _ref.excludedColor,
@@ -26,7 +27,7 @@ var FilterTag = function FilterTag(_ref) {
26
27
  var label = react.useMemo(function () {
27
28
  var _filter$value;
28
29
  if (filter.label) return /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
29
- children: [filter.negate && /*#__PURE__*/jsxRuntime.jsx("span", {
30
+ children: [filter.field && filter.negate && /*#__PURE__*/jsxRuntime.jsx("span", {
30
31
  className: "font-semibold",
31
32
  children: "NOT"
32
33
  }), /*#__PURE__*/jsxRuntime.jsx("span", {
@@ -34,7 +35,7 @@ var FilterTag = function FilterTag(_ref) {
34
35
  })]
35
36
  });
36
37
  return /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
37
- children: [filter.negate && /*#__PURE__*/jsxRuntime.jsx("span", {
38
+ children: [filter.field && filter.negate && /*#__PURE__*/jsxRuntime.jsx("span", {
38
39
  className: "font-semibold",
39
40
  children: "NOT"
40
41
  }), /*#__PURE__*/jsxRuntime.jsx("span", {
@@ -52,7 +53,7 @@ var FilterTag = function FilterTag(_ref) {
52
53
  }, [filter]);
53
54
  var color = react.useMemo(function () {
54
55
  var _filter$color;
55
- return (_filter$color = filter.color) !== null && _filter$color !== void 0 ? _filter$color : filter.negate ? excludedColor : includedColor;
56
+ return (_filter$color = filter.color) !== null && _filter$color !== void 0 ? _filter$color : filter.field && filter.negate ? excludedColor : includedColor;
56
57
  }, [filter, includedColor, excludedColor]);
57
58
  var icon = react.useMemo(function () {
58
59
  if (filter.canDisable === false) return undefined;
@@ -63,7 +64,7 @@ var FilterTag = function FilterTag(_ref) {
63
64
  children: [/*#__PURE__*/jsxRuntime.jsx(core.Chip, {
64
65
  size: "sm",
65
66
  color: color,
66
- className: "outline outline-1 max-w-60",
67
+ className: classNames("outline max-w-60", filter.disabled && "opacity-65"),
67
68
  variant: filter.pinned ? "solid" : undefined,
68
69
  icon: icon,
69
70
  iconColor: color,
@@ -72,6 +73,8 @@ var FilterTag = function FilterTag(_ref) {
72
73
  disabled: !filter.disabled
73
74
  })), e.stopPropagation()];
74
75
  },
76
+ "data-ref": "filterTag",
77
+ "data-test-value": filter.id,
75
78
  stopPropagation: true,
76
79
  onRemove: filter.required ? undefined : function () {
77
80
  return onRemove();
@@ -79,12 +82,14 @@ var FilterTag = function FilterTag(_ref) {
79
82
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
80
83
  className: classNames("flex gap-1 items-center", filter.disabled && "line-through opacity-65"),
81
84
  children: [filter.pinned && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
85
+ className: "flex-content",
82
86
  icon: (_filter$icon = filter.icon) !== null && _filter$icon !== void 0 ? _filter$icon : core.CoreIcons.pin
83
87
  }), label]
84
88
  })
85
89
  }), /*#__PURE__*/jsxRuntime.jsx(FilterMenu.FilterMenu, {
86
90
  filter: filter,
87
91
  fields: fields,
92
+ editable: editable,
88
93
  onChange: onChange,
89
94
  onRemove: onRemove
90
95
  })]
@@ -45,10 +45,14 @@ var FilterView = function FilterView(_ref) {
45
45
  var _filter$value2;
46
46
  value = "[".concat((_filter$value2 = filter.value) === null || _filter$value2 === void 0 ? void 0 : _filter$value2.join(" - "), "]");
47
47
  }
48
- if (filter.operator === index.OPERATOR.IN && utilities.isArray(filter.value)) {
48
+ if (filter.operator === index.OPERATOR.ANY && utilities.isArray(filter.value)) {
49
49
  var _filter$value3;
50
50
  value = "[".concat((_filter$value3 = filter.value) === null || _filter$value3 === void 0 ? void 0 : _filter$value3.join(", "), "]");
51
51
  }
52
+ if (filter.operator === index.OPERATOR.ALL && utilities.isArray(filter.value)) {
53
+ var _filter$value4;
54
+ value = "(".concat((_filter$value4 = filter.value) === null || _filter$value4 === void 0 ? void 0 : _filter$value4.join(", "), ")");
55
+ }
52
56
  return /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
53
57
  children: [filter.negate && /*#__PURE__*/jsxRuntime.jsx("b", {
54
58
  children: "NOT\xA0"
@@ -13,7 +13,7 @@ var reactI18next = require('react-i18next');
13
13
  var Context = require('./Context.js');
14
14
  var jsxRuntime = require('react/jsx-runtime');
15
15
 
16
- var _excluded = ["checked", "error", "invalid"];
16
+ var _excluded = ["checked", "error", "invalid", "ref"];
17
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
18
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
19
  var QuerySchema = new utilities.yup.ObjectSchema({
@@ -37,7 +37,8 @@ var QueryForm = function QueryForm(_ref) {
37
37
  var _useFilterContext = Context.useFilterContext(),
38
38
  _useFilterContext$def = _useFilterContext.defaultQuery,
39
39
  defaultQuery = _useFilterContext$def === void 0 ? "" : _useFilterContext$def,
40
- querySchema = _useFilterContext.querySchema;
40
+ querySchema = _useFilterContext.querySchema,
41
+ queryLanguage = _useFilterContext.queryLanguage;
41
42
  var inputRef = react$1.useRef(null);
42
43
  var filterValue = react$1.useMemo(function () {
43
44
  var _filter$query;
@@ -87,8 +88,9 @@ var QueryForm = function QueryForm(_ref) {
87
88
  children: function children(_ref2) {
88
89
  _ref2.checked;
89
90
  _ref2.error;
90
- var invalid = _ref2.invalid,
91
- field = _objectWithoutProperties(_ref2, _excluded);
91
+ var invalid = _ref2.invalid;
92
+ _ref2.ref;
93
+ var field = _objectWithoutProperties(_ref2, _excluded);
92
94
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
93
95
  className: "my-2",
94
96
  children: [/*#__PURE__*/jsxRuntime.jsx("label", {
@@ -100,6 +102,7 @@ var QueryForm = function QueryForm(_ref) {
100
102
  gridTemplate: '"content" 1fr/1fr'
101
103
  },
102
104
  children: /*#__PURE__*/jsxRuntime.jsx(monaco.CodeEditor, _objectSpread(_objectSpread({
105
+ language: queryLanguage !== null && queryLanguage !== void 0 ? queryLanguage : "text",
103
106
  minimal: true,
104
107
  required: true
105
108
  }, field), {}, {
@@ -109,7 +112,7 @@ var QueryForm = function QueryForm(_ref) {
109
112
  });
110
113
  }
111
114
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
112
- className: "flex justify-end gap-1",
115
+ className: "flex mt-4 justify-end gap-1 sticky bottom-1 bg-base",
113
116
  children: [onRemove && /*#__PURE__*/jsxRuntime.jsx("div", {
114
117
  className: "flex-1",
115
118
  children: /*#__PURE__*/jsxRuntime.jsx(core.Button, {
@@ -3,70 +3,73 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var label = {
6
- filters: "المرشحات",
6
+ add: "إضافة عامل تصفية",
7
7
  all_filters: "جميع المرشحات",
8
+ apply: "يتقدم",
9
+ basicFilter: "الفلتر الأساسي",
10
+ cancel: "يلغي",
11
+ customQuery: "استعلام مخصص",
12
+ "delete": "يمسح",
13
+ disable: "إبطال",
14
+ disableAll: "تعطيل الكل",
15
+ edit: "يحرر",
16
+ enable: "يُمكَِن",
17
+ enableAll: "تمكين الكل",
18
+ exclude: "استبعاد",
19
+ excludeAll: "استبعاد الكل",
8
20
  field: "مجال",
9
- operator: "المشغل",
10
- value: "قيمة",
21
+ filters: "المرشحات",
22
+ forAdvanced: "للمستخدمين المتقدمين فقط!",
23
+ include: "يشمل",
24
+ includeAll: "تضمين الكل",
25
+ invertAll: "عكس التضمين/الاستبعاد",
11
26
  label: "ملصق",
27
+ operator: "المشغل",
12
28
  optional: "خياري",
13
- add: "إضافة عامل تصفية",
14
- edit: "يحرر",
15
- view: "منظر",
16
29
  pin: "مثبت",
17
- unpin: "غير مثبت",
18
- includeAll: "تضمين الكل",
19
- excludeAll: "استبعاد الكل",
20
- invertAll: "عكس التضمين/الاستبعاد",
30
+ query: "استفسار",
31
+ refresh: "ينعش",
32
+ remove: "يزيل",
21
33
  removeAll: "إزالة الكل",
22
- enableAll: "تمكين الكل",
23
- disableAll: "تعطيل الكل",
24
34
  toggleDisable: "عكس تعطيل/تمكين",
25
- remove: "يزيل",
26
- enable: "يُمكَِن",
27
- disable: "إبطال",
28
- exclude: "استبعاد",
29
- include: "يشمل",
30
- refresh: "ينعش",
35
+ unpin: "غير مثبت",
31
36
  update: "تحديث",
32
- query: "استفسار",
33
- apply: "يتقدم",
34
- cancel: "يلغي",
35
- "delete": "يمسح",
36
- basicFilter: "الفلتر الأساسي",
37
- customQuery: "استعلام مخصص",
38
- forAdvanced: "للمستخدمين المتقدمين فقط!"
37
+ value: "قيمة",
38
+ view: "منظر",
39
+ matchAll: "تطابق كل شيء",
40
+ matchAny: "تطابق أي"
39
41
  };
40
42
  var operator = {
43
+ ALL: "كل",
44
+ ANY: "أي من",
45
+ BETWEEN: "بين هذا وذاك",
46
+ ENDS: "ينتهي مع",
41
47
  EXISTS: "موجود",
48
+ GT: ">",
49
+ GTE: "≥",
42
50
  IS: "يكون",
43
- IN: "في",
51
+ LIKE: "يحب",
44
52
  LT: "<",
45
- GT: ">",
46
53
  LTE: "≤",
47
- GTE: "≥",
48
- INCLUDES: "يشمل",
49
54
  STARTS: "ابدا ب",
50
- ENDS: "ينتهي مع",
51
- WITHIN: "في غضون",
52
- BETWEEN: "بين هذا وذاك"
55
+ WITHIN: "في غضون"
53
56
  };
54
57
  var placeholder = "مصطلح البحث...";
55
58
  var type = {
56
- STRING: "سلسلة",
57
- NUMBER: "كثافة العمليات",
58
- DECIMAL: "يطفو",
59
59
  BOOLEAN: "رقم",
60
60
  DATE: "منطقي",
61
61
  DATETIME: "تاريخ",
62
- GEO: "GeoJSON"
62
+ DECIMAL: "يطفو",
63
+ GEO: "GeoJSON",
64
+ NUMBER: "كثافة العمليات",
65
+ STRING: "سلسلة"
63
66
  };
64
67
  var validate = {
68
+ compare: "مقارنة الحقل المطلوب",
65
69
  field: "حقل مطلوب",
70
+ label: "التصنيف مطلوب",
66
71
  operator: "عامل مطلوب",
67
- value: "القيمة المطلوبة",
68
- compare: "مقارنة الحقل المطلوب",
69
- label: "التصنيف مطلوب"
72
+ value: "القيمة المطلوبة"
70
73
  };
71
74
  var ar = {
72
75
  label: label,