@react-fabric/searchbar 1.0.0-beta.6 → 1.0.0-beta.61

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 +17 -13
  2. package/dist/cjs/filterbar/FilterForm.js +144 -38
  3. package/dist/cjs/filterbar/FilterMenu.js +19 -7
  4. package/dist/cjs/filterbar/FilterTag.js +18 -10
  5. package/dist/cjs/filterbar/FilterView.js +6 -2
  6. package/dist/cjs/filterbar/QueryForm.js +11 -8
  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 +60 -7
  10. package/dist/cjs/types/index.js +12 -4
  11. package/dist/esm/filterbar/FilterBar.js +18 -14
  12. package/dist/esm/filterbar/FilterForm.js +145 -39
  13. package/dist/esm/filterbar/FilterMenu.js +20 -8
  14. package/dist/esm/filterbar/FilterTag.js +19 -11
  15. package/dist/esm/filterbar/FilterView.js +6 -2
  16. package/dist/esm/filterbar/QueryForm.js +11 -8
  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 +61 -8
  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 +17 -14
  29. package/src/filterbar/Context.tsx +4 -1
  30. package/src/filterbar/FilterBar.tsx +56 -15
  31. package/src/filterbar/FilterForm.tsx +113 -27
  32. package/src/filterbar/FilterMenu.tsx +34 -7
  33. package/src/filterbar/FilterTag.tsx +29 -11
  34. package/src/filterbar/FilterView.tsx +5 -2
  35. package/src/filterbar/QueryForm.tsx +7 -6
  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 +58 -5
  40. package/src/types/index.ts +57 -34
@@ -4,12 +4,12 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
4
  var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
5
5
  var core = require('@react-fabric/core');
6
6
  var utilities = require('@react-fabric/utilities');
7
+ var classNames = require('classnames');
7
8
  var react = require('react');
8
9
  var reactI18next = require('react-i18next');
10
+ var Context = require('./Context.js');
9
11
  var FilterEdit = require('./FilterEdit.js');
10
12
  var FilterTag = require('./FilterTag.js');
11
- var classNames = require('classnames');
12
- var Context = require('./Context.js');
13
13
  var jsxRuntime = require('react/jsx-runtime');
14
14
 
15
15
  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; }
@@ -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", {
@@ -85,7 +88,7 @@ var FilterBar = function FilterBar(_ref) {
85
88
  showArrow: true,
86
89
  disabled: utilities.isEmpty(filters),
87
90
  children: [/*#__PURE__*/jsxRuntime.jsx(core.Icon, {
88
- icon: core.CoreIcons.config,
91
+ icon: "icon-[mdi--cog-outline]",
89
92
  className: classNames(utilities.isEmpty(filters) && "pointer-events-none opacity-30"),
90
93
  color: !utilities.isEmpty(filters) ? "primary" : undefined
91
94
  }), /*#__PURE__*/jsxRuntime.jsxs(core.Menu, {
@@ -98,7 +101,7 @@ var FilterBar = function FilterBar(_ref) {
98
101
  id: "disableAll",
99
102
  label: t("label.disableAll")
100
103
  }), /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
101
- icon: core.CoreIcons.invertDisable,
104
+ icon: "icon-[mdi--checkbox-intermediate-variant]",
102
105
  id: "toggleDisable",
103
106
  label: t("label.toggleDisable")
104
107
  }), /*#__PURE__*/jsxRuntime.jsx(core.Divider, {}), menuItems.someExcluded && /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
@@ -109,12 +112,12 @@ var FilterBar = function FilterBar(_ref) {
109
112
  label: t("label.excludeAll")
110
113
  }), /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
111
114
  id: "invertAll",
112
- icon: core.CoreIcons.invertExclude,
115
+ icon: "icon-[mdi--set-left]",
113
116
  label: t("label.invertAll")
114
117
  }), /*#__PURE__*/jsxRuntime.jsx(core.Divider, {}), /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
115
118
  id: "removeAll",
116
119
  color: "danger",
117
- icon: core.CoreIcons.remove,
120
+ icon: "icon-[mdi--minus-circle-outline]",
118
121
  label: t("label.removeAll"),
119
122
  disabled: !menuItems.canRemoveAll
120
123
  })]
@@ -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() {
@@ -135,8 +139,8 @@ var FilterBar = function FilterBar(_ref) {
135
139
  showArrow: true,
136
140
  children: [/*#__PURE__*/jsxRuntime.jsx(core.Chip, {
137
141
  size: "sm",
138
- className: "!outline-dashed !outline-tint-400",
139
- icon: core.CoreIcons.insert,
142
+ className: "outline-dashed! outline-tint-400!",
143
+ icon: "icon-[mdi--plus-circle-outline]",
140
144
  children: t("label.add")
141
145
  }), /*#__PURE__*/jsxRuntime.jsx(FilterEdit.FilterEdit, {
142
146
  onChange: handleChange
@@ -3,6 +3,7 @@
3
3
  var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
4
4
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
5
5
  var react = require('@floating-ui/react');
6
+ var yup = require('@hookform/resolvers/yup');
6
7
  var core = require('@react-fabric/core');
7
8
  var form = require('@react-fabric/form');
8
9
  var utilities = require('@react-fabric/utilities');
@@ -15,8 +16,9 @@ var jsxRuntime = require('react/jsx-runtime');
15
16
  var FilterSchema = new utilities.yup.ObjectSchema({
16
17
  id: utilities.yup.string().required(),
17
18
  field: utilities.yup.string().required(),
19
+ // type: yup.string().oneOf(Object.values(FIELD_TYPE)),
18
20
  operator: utilities.yup.string().required().oneOf(Object.values(index.OPERATOR)),
19
- negate: utilities.yup["boolean"](),
21
+ negate: utilities.yup["boolean"]().optional(),
20
22
  label: utilities.yup.string(),
21
23
  value: utilities.yup.mixed().when("operator", {
22
24
  is: index.OPERATOR.EXISTS,
@@ -27,7 +29,7 @@ var FilterSchema = new utilities.yup.ObjectSchema({
27
29
  return schema.required();
28
30
  }
29
31
  }).when("operator", {
30
- is: index.OPERATOR.IN,
32
+ is: index.OPERATOR.ANY,
31
33
  then: function then(schema) {
32
34
  return schema.test({
33
35
  name: "array-check",
@@ -38,6 +40,42 @@ var FilterSchema = new utilities.yup.ObjectSchema({
38
40
  }
39
41
  });
40
42
  }
43
+ }).when("operator", {
44
+ is: index.OPERATOR.ALL,
45
+ then: function then(schema) {
46
+ return schema.test({
47
+ name: "array-check",
48
+ message: "${path} is a required field",
49
+ test: function test() {
50
+ var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
51
+ return (val === null || val === void 0 ? void 0 : val.length) > 0;
52
+ }
53
+ });
54
+ }
55
+ }).when("operator", {
56
+ is: index.OPERATOR.BETWEEN,
57
+ then: function then(schema) {
58
+ return schema.test({
59
+ name: "array-check",
60
+ message: "${path} is a required field",
61
+ test: function test() {
62
+ var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
63
+ return (val === null || val === void 0 ? void 0 : val.length) > 0 && val[0] && val[1];
64
+ }
65
+ });
66
+ }
67
+ }).when("operator", {
68
+ is: index.OPERATOR.BETWEEN,
69
+ then: function then(schema) {
70
+ return schema.test({
71
+ name: "array-check",
72
+ message: "${path} min max",
73
+ test: function test() {
74
+ var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
75
+ return (val === null || val === void 0 ? void 0 : val.length) > 0 && val[0] < val[1];
76
+ }
77
+ });
78
+ }
41
79
  })
42
80
  });
43
81
  var FilterForm = function FilterForm(_ref) {
@@ -57,13 +95,17 @@ var FilterForm = function FilterForm(_ref) {
57
95
  values = _useState2[0],
58
96
  setValues = _useState2[1];
59
97
  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
- });
98
+ if (filter && "field" in filter && filter.field) {
99
+ var _formRef$current;
100
+ (_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.setValues(filter);
101
+ } else {
102
+ var _formRef$current2;
103
+ (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setValues({
104
+ id: utilities.shortHash(),
105
+ field: "",
106
+ operator: index.OPERATOR.EXISTS
107
+ });
108
+ }
67
109
  }, [filter]);
68
110
  react$1.useEffect(function () {
69
111
  setTimeout(function () {
@@ -89,7 +131,7 @@ var FilterForm = function FilterForm(_ref) {
89
131
  (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 || _formRef$current4.setValue("value", undefined);
90
132
  }
91
133
  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) {
134
+ if ([index.OPERATOR.ALL, index.OPERATOR.ANY].includes(values === null || values === void 0 ? void 0 : values.operator)) {
93
135
  var _formRef$current5;
94
136
  !utilities.isArray(values.value) && ((_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 ? void 0 : _formRef$current5.setValue("value", []));
95
137
  } else {
@@ -97,7 +139,7 @@ var FilterForm = function FilterForm(_ref) {
97
139
  utilities.isArray(values.value) && ((_formRef$current6 = formRef.current) === null || _formRef$current6 === void 0 ? void 0 : _formRef$current6.setValue("value", undefined));
98
140
  }
99
141
  }
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) {
142
+ 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
143
  if ((values === null || values === void 0 ? void 0 : values.operator) === index.OPERATOR.BETWEEN) {
102
144
  var _formRef$current7;
103
145
  !utilities.isArray(values.value) && ((_formRef$current7 = formRef.current) === null || _formRef$current7 === void 0 ? void 0 : _formRef$current7.setValue("value", []));
@@ -106,7 +148,7 @@ var FilterForm = function FilterForm(_ref) {
106
148
  utilities.isArray(values.value) && ((_formRef$current8 = formRef.current) === null || _formRef$current8 === void 0 ? void 0 : _formRef$current8.setValue("value", undefined));
107
149
  }
108
150
  }
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) {
151
+ 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
152
  var _formRef$current9;
111
153
  (_formRef$current9 = formRef.current) === null || _formRef$current9 === void 0 || _formRef$current9.setValue("value", false);
112
154
  }
@@ -123,7 +165,8 @@ var FilterForm = function FilterForm(_ref) {
123
165
  });
124
166
  }
125
167
  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) {
168
+ var _field$values2;
169
+ if ([index.OPERATOR.ALL, index.OPERATOR.ANY].includes(values === null || values === void 0 ? void 0 : values.operator)) {
127
170
  var _field$values;
128
171
  return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
129
172
  name: "value",
@@ -137,6 +180,19 @@ var FilterForm = function FilterForm(_ref) {
137
180
  onQuery: field.onSearch
138
181
  })
139
182
  });
183
+ } else if (!!field.onSearch || (_field$values2 = field.values) !== null && _field$values2 !== void 0 && _field$values2.length) {
184
+ var _field$values3;
185
+ return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
186
+ name: "value",
187
+ children: /*#__PURE__*/jsxRuntime.jsx(form.Select, {
188
+ searchable: true,
189
+ allowCreate: true,
190
+ allowClear: true,
191
+ options: (_field$values3 = field.values) !== null && _field$values3 !== void 0 ? _field$values3 : [],
192
+ label: t("label.value"),
193
+ onQuery: field.onSearch
194
+ })
195
+ });
140
196
  } else {
141
197
  return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
142
198
  name: "value",
@@ -147,27 +203,40 @@ var FilterForm = function FilterForm(_ref) {
147
203
  });
148
204
  }
149
205
  }
206
+ if (field.type === index.FIELD_TYPE.TEXT) {
207
+ return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
208
+ name: "value",
209
+ children: /*#__PURE__*/jsxRuntime.jsx(form.Textarea, {
210
+ rows: 3,
211
+ label: t("label.value"),
212
+ allowClear: true
213
+ })
214
+ });
215
+ }
150
216
  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
217
  var step = field.type === index.FIELD_TYPE.DECIMAL ? 0.1 : 1;
152
218
  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
- })]
219
+ return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
220
+ name: "value",
221
+ children: /*#__PURE__*/jsxRuntime.jsxs(form.Field, {
222
+ label: t("label.value"),
223
+ children: [/*#__PURE__*/jsxRuntime.jsx(form.Controller, {
224
+ name: "value[0]",
225
+ children: /*#__PURE__*/jsxRuntime.jsx(form.Number, {
226
+ step: step,
227
+ allowClear: true
228
+ })
229
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
230
+ className: "p-2 text-muted",
231
+ children: "\u2277"
232
+ }), /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
233
+ name: "value[1]",
234
+ children: /*#__PURE__*/jsxRuntime.jsx(form.Number, {
235
+ step: step,
236
+ allowClear: true
237
+ })
238
+ })]
239
+ })
171
240
  });
172
241
  } else {
173
242
  return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
@@ -180,6 +249,41 @@ var FilterForm = function FilterForm(_ref) {
180
249
  });
181
250
  }
182
251
  }
252
+ 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) {
253
+ var type = field.type === index.FIELD_TYPE.DATETIME ? "datetime" : "date";
254
+ if ((values === null || values === void 0 ? void 0 : values.operator) === index.OPERATOR.BETWEEN) {
255
+ return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
256
+ name: "value",
257
+ children: /*#__PURE__*/jsxRuntime.jsxs(form.Field, {
258
+ label: t("label.value"),
259
+ children: [/*#__PURE__*/jsxRuntime.jsx(form.Controller, {
260
+ name: "value[0]",
261
+ children: /*#__PURE__*/jsxRuntime.jsx(form.DateInput, {
262
+ type: type,
263
+ allowClear: true
264
+ })
265
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
266
+ className: "p-2 text-muted",
267
+ children: "\u2277"
268
+ }), /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
269
+ name: "value[1]",
270
+ children: /*#__PURE__*/jsxRuntime.jsx(form.DateInput, {
271
+ type: type,
272
+ allowClear: true
273
+ })
274
+ })]
275
+ })
276
+ });
277
+ } else {
278
+ return /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
279
+ name: "value",
280
+ children: /*#__PURE__*/jsxRuntime.jsx(form.DateInput, {
281
+ type: type,
282
+ allowClear: true
283
+ })
284
+ });
285
+ }
286
+ }
183
287
  }, [field, values === null || values === void 0 ? void 0 : values.operator]);
184
288
  var handleSubmit = react$1.useCallback(function (model) {
185
289
  var filter = {
@@ -188,19 +292,20 @@ var FilterForm = function FilterForm(_ref) {
188
292
  negate: model.negate,
189
293
  operator: model.operator,
190
294
  value: model.value,
191
- label: model.label
295
+ label: model.label,
296
+ type: field === null || field === void 0 ? void 0 : field.type
192
297
  };
193
298
  onChange === null || onChange === void 0 || onChange(filter);
194
299
  tree === null || tree === void 0 || tree.events.emit("close");
195
- }, [onChange]);
300
+ }, [field, onChange]);
196
301
  return /*#__PURE__*/jsxRuntime.jsx(form.Form, {
197
302
  formRef: formRef,
198
- schema: FilterSchema,
303
+ resolver: yup.yupResolver(FilterSchema),
199
304
  defaultValues: values,
200
305
  onChange: setValues,
201
306
  onSubmit: handleSubmit,
202
307
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
203
- className: "w-[32rem]",
308
+ className: "w-lg",
204
309
  children: [/*#__PURE__*/jsxRuntime.jsxs(core.Row, {
205
310
  children: [/*#__PURE__*/jsxRuntime.jsx(core.Col, {
206
311
  flex: "fill",
@@ -208,6 +313,7 @@ var FilterForm = function FilterForm(_ref) {
208
313
  name: "field",
209
314
  children: /*#__PURE__*/jsxRuntime.jsx(form.Select, {
210
315
  required: true,
316
+ searchable: true,
211
317
  ref: inputRef,
212
318
  label: t("label.field"),
213
319
  options: fields,
@@ -217,7 +323,7 @@ var FilterForm = function FilterForm(_ref) {
217
323
  })
218
324
  })
219
325
  }), /*#__PURE__*/jsxRuntime.jsxs(core.Col, {
220
- flex: "auto",
326
+ flex: "content",
221
327
  className: "text-center",
222
328
  children: [/*#__PURE__*/jsxRuntime.jsx("label", {
223
329
  className: "block py-0.5 text-sm",
@@ -229,7 +335,7 @@ var FilterForm = function FilterForm(_ref) {
229
335
  })
230
336
  })]
231
337
  }), /*#__PURE__*/jsxRuntime.jsx(core.Col, {
232
- flex: "auto",
338
+ flex: "content",
233
339
  className: "basis-28",
234
340
  children: /*#__PURE__*/jsxRuntime.jsx(form.Controller, {
235
341
  name: "operator",
@@ -253,7 +359,7 @@ var FilterForm = function FilterForm(_ref) {
253
359
  })
254
360
  })
255
361
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
256
- className: "flex pt-4 justify-end gap-1",
362
+ className: "flex mt-4 justify-end gap-1 sticky bottom-1 bg-base",
257
363
  children: [onRemove && /*#__PURE__*/jsxRuntime.jsx("div", {
258
364
  className: "flex-1",
259
365
  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,28 +35,36 @@ 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, {
35
- icon: core.CoreIcons.edit,
38
+ children: [editable && filter.canEdit !== false ? /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
39
+ icon: "icon-[mdi--lead-pencil]",
36
40
  label: t("label.edit"),
37
41
  "data-dropdown-dismiss": "false",
38
42
  onClick: function onClick() {
39
43
  setView("edit");
40
44
  }
41
45
  }) : /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
42
- icon: core.CoreIcons.eye,
46
+ icon: "icon-[mdi--eye]",
43
47
  label: t("label.view"),
44
48
  "data-dropdown-dismiss": "false",
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), {}, {
@@ -68,7 +80,7 @@ var FilterMenu = function FilterMenu(_ref) {
68
80
  }
69
81
  }), !filter.required && /*#__PURE__*/jsxRuntime.jsx(core.Divider, {}), !filter.required && /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
70
82
  color: "danger",
71
- icon: core.CoreIcons.remove,
83
+ icon: "icon-[mdi--minus-circle-outline]",
72
84
  label: t("label.remove"),
73
85
  onClick: function onClick() {
74
86
  return onRemove();
@@ -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,27 +53,29 @@ 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;
59
- return filter.disabled ? core.CoreIcons.checkboxOff : core.CoreIcons.checkboxOn;
60
+ return filter.disabled ? "icon-[mdi--checkbox-blank-outline]" : "icon-[mdi--checkbox-marked]";
60
61
  }, [filter]);
61
62
  return /*#__PURE__*/jsxRuntime.jsxs(core.Dropdown, {
62
63
  showArrow: true,
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
- icon: icon,
69
- iconColor: color,
69
+ icon: icon && {
70
+ icon: icon,
71
+ color: color
72
+ },
70
73
  onIconClick: function onIconClick(e) {
71
74
  return [onChange(_objectSpread(_objectSpread({}, filter), {}, {
72
75
  disabled: !filter.disabled
73
76
  })), e.stopPropagation()];
74
77
  },
75
- "data-testid": "filter-tag",
78
+ "data-ref": "filterTag",
76
79
  "data-test-value": filter.id,
77
80
  stopPropagation: true,
78
81
  onRemove: filter.required ? undefined : function () {
@@ -81,12 +84,17 @@ var FilterTag = function FilterTag(_ref) {
81
84
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
82
85
  className: classNames("flex gap-1 items-center", filter.disabled && "line-through opacity-65"),
83
86
  children: [filter.pinned && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
84
- icon: (_filter$icon = filter.icon) !== null && _filter$icon !== void 0 ? _filter$icon : core.CoreIcons.pin
85
- }), label]
87
+ className: "flex-content",
88
+ icon: (_filter$icon = filter.icon) !== null && _filter$icon !== void 0 ? _filter$icon : "icon-[mdi--pin]"
89
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
90
+ className: "truncate flex gap-x-0.5 flex-nowrap",
91
+ children: label
92
+ })]
86
93
  })
87
94
  }), /*#__PURE__*/jsxRuntime.jsx(FilterMenu.FilterMenu, {
88
95
  filter: filter,
89
96
  fields: fields,
97
+ editable: editable,
90
98
  onChange: onChange,
91
99
  onRemove: onRemove
92
100
  })]
@@ -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"
@@ -72,7 +76,7 @@ var FilterView = function FilterView(_ref) {
72
76
  text: view
73
77
  })
74
78
  }), /*#__PURE__*/jsxRuntime.jsx("pre", {
75
- className: "overflow-auto bg-base outline text-sm p-2 max-h-[24rem] max-w-[48rem] min-w-[24rem]",
79
+ className: "overflow-auto bg-base outline text-sm p-2 max-h-96 max-w-3xl min-w-[24rem]",
76
80
  children: view
77
81
  }), !filter.required && /*#__PURE__*/jsxRuntime.jsx(core.Button, {
78
82
  size: "sm",