@react-fabric/searchbar 1.0.0-beta.4 → 1.0.0-beta.41

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.
@@ -5,7 +5,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
5
  import { useFloatingTree } from '@floating-ui/react';
6
6
  import { Row, Col, Button } from '@react-fabric/core';
7
7
  import { Field, Controller, Switch, Select, Input, Number, Form } from '@react-fabric/form';
8
- import { yup, shortHash } from '@react-fabric/utilities';
8
+ import { yup, shortHash, isArray } from '@react-fabric/utilities';
9
9
  import { useRef, useState, useEffect, useMemo, useCallback } from 'react';
10
10
  import { useTranslation } from 'react-i18next';
11
11
  import { OPERATOR, TypeOperators, FIELD_TYPE } from '../types/index.js';
@@ -15,6 +15,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
15
15
  var FilterSchema = new yup.ObjectSchema({
16
16
  id: yup.string().required(),
17
17
  field: yup.string().required(),
18
+ // type: yup.string().oneOf(Object.values(FIELD_TYPE)),
18
19
  operator: yup.string().required().oneOf(Object.values(OPERATOR)),
19
20
  negate: yup["boolean"](),
20
21
  label: yup.string(),
@@ -57,12 +58,17 @@ var FilterForm = function FilterForm(_ref) {
57
58
  values = _useState2[0],
58
59
  setValues = _useState2[1];
59
60
  useEffect(function () {
60
- if (filter && "field" in filter && filter.field) return setValues(filter);
61
- setValues({
62
- id: shortHash(),
63
- field: "",
64
- operator: OPERATOR.EXISTS
65
- });
61
+ if (filter && "field" in filter && filter.field) {
62
+ var _formRef$current;
63
+ (_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.setValues(filter);
64
+ } else {
65
+ var _formRef$current2;
66
+ (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setValues({
67
+ id: shortHash(),
68
+ field: "",
69
+ operator: OPERATOR.EXISTS
70
+ });
71
+ }
66
72
  }, [filter]);
67
73
  useEffect(function () {
68
74
  setTimeout(function () {
@@ -77,22 +83,38 @@ var FilterForm = function FilterForm(_ref) {
77
83
  });
78
84
  }, [values]);
79
85
  var operators = useMemo(function () {
80
- var _formRef$current;
86
+ var _formRef$current3;
81
87
  if (field == null) return [OPERATOR.EXISTS];
82
- (_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.setValue("operator", TypeOperators[field.type][0]);
88
+ (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 || _formRef$current3.setValue("operator", TypeOperators[field.type][0]);
83
89
  return _toConsumableArray(TypeOperators[field.type]);
84
90
  }, [field]);
85
- useEffect(function () {
91
+ var valueInput = useMemo(function () {
86
92
  if ((values === null || values === void 0 ? void 0 : values.operator) === OPERATOR.EXISTS && (values === null || values === void 0 ? void 0 : values.value) !== undefined) {
87
- var _formRef$current2;
88
- (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setValue("value", undefined);
93
+ var _formRef$current4;
94
+ (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 || _formRef$current4.setValue("value", undefined);
95
+ }
96
+ if ((field === null || field === void 0 ? void 0 : field.type) === FIELD_TYPE.STRING) {
97
+ if ((values === null || values === void 0 ? void 0 : values.operator) === OPERATOR.IN) {
98
+ var _formRef$current5;
99
+ !isArray(values.value) && ((_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 ? void 0 : _formRef$current5.setValue("value", []));
100
+ } else {
101
+ var _formRef$current6;
102
+ isArray(values.value) && ((_formRef$current6 = formRef.current) === null || _formRef$current6 === void 0 ? void 0 : _formRef$current6.setValue("value", undefined));
103
+ }
104
+ }
105
+ if ((field === null || field === void 0 ? void 0 : field.type) === FIELD_TYPE.NUMBER || (field === null || field === void 0 ? void 0 : field.type) === FIELD_TYPE.DECIMAL) {
106
+ if ((values === null || values === void 0 ? void 0 : values.operator) === OPERATOR.BETWEEN) {
107
+ var _formRef$current7;
108
+ !isArray(values.value) && ((_formRef$current7 = formRef.current) === null || _formRef$current7 === void 0 ? void 0 : _formRef$current7.setValue("value", []));
109
+ } else {
110
+ var _formRef$current8;
111
+ isArray(values.value) && ((_formRef$current8 = formRef.current) === null || _formRef$current8 === void 0 ? void 0 : _formRef$current8.setValue("value", undefined));
112
+ }
89
113
  }
90
114
  if ((field === null || field === void 0 ? void 0 : field.type) === FIELD_TYPE.BOOLEAN && (values === null || values === void 0 ? void 0 : values.operator) === OPERATOR.IS && (values === null || values === void 0 ? void 0 : values.value) === undefined) {
91
- var _formRef$current3;
92
- (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 || _formRef$current3.setValue("value", false);
115
+ var _formRef$current9;
116
+ (_formRef$current9 = formRef.current) === null || _formRef$current9 === void 0 || _formRef$current9.setValue("value", false);
93
117
  }
94
- }, [values, field]);
95
- var valueInput = useMemo(function () {
96
118
  if (field == null || !(values !== null && values !== void 0 && values.operator)) return null;
97
119
  if ((values === null || values === void 0 ? void 0 : values.operator) === OPERATOR.EXISTS) return null;
98
120
  if ((field === null || field === void 0 ? void 0 : field.type) === FIELD_TYPE.BOOLEAN) {
@@ -112,6 +134,7 @@ var FilterForm = function FilterForm(_ref) {
112
134
  name: "value",
113
135
  children: /*#__PURE__*/jsx(Select, {
114
136
  multiple: true,
137
+ searchable: true,
115
138
  allowCreate: true,
116
139
  allowClear: true,
117
140
  options: (_field$values = field.values) !== null && _field$values !== void 0 ? _field$values : [],
@@ -142,7 +165,7 @@ var FilterForm = function FilterForm(_ref) {
142
165
  })
143
166
  }), /*#__PURE__*/jsx("span", {
144
167
  className: "p-2 text-muted",
145
- children: "<>"
168
+ children: "\u2277"
146
169
  }), /*#__PURE__*/jsx(Controller, {
147
170
  name: "value[1]",
148
171
  children: /*#__PURE__*/jsx(Number, {
@@ -175,87 +198,91 @@ var FilterForm = function FilterForm(_ref) {
175
198
  onChange === null || onChange === void 0 || onChange(filter);
176
199
  tree === null || tree === void 0 || tree.events.emit("close");
177
200
  }, [onChange]);
178
- return /*#__PURE__*/jsxs(Form, {
201
+ return /*#__PURE__*/jsx(Form, {
179
202
  formRef: formRef,
180
203
  schema: FilterSchema,
181
204
  defaultValues: values,
182
205
  onChange: setValues,
183
206
  onSubmit: handleSubmit,
184
- children: [/*#__PURE__*/jsxs(Row, {
185
- children: [/*#__PURE__*/jsx(Col, {
186
- flex: "fill",
187
- children: /*#__PURE__*/jsx(Controller, {
188
- name: "field",
189
- children: /*#__PURE__*/jsx(Select, {
190
- required: true,
191
- ref: inputRef,
192
- label: t("label.field"),
193
- options: fields,
194
- labelProperty: "label",
195
- valueProperty: "field",
196
- groupProperty: "type"
207
+ children: /*#__PURE__*/jsxs("div", {
208
+ className: "w-[32rem]",
209
+ children: [/*#__PURE__*/jsxs(Row, {
210
+ children: [/*#__PURE__*/jsx(Col, {
211
+ flex: "fill",
212
+ children: /*#__PURE__*/jsx(Controller, {
213
+ name: "field",
214
+ children: /*#__PURE__*/jsx(Select, {
215
+ required: true,
216
+ searchable: true,
217
+ ref: inputRef,
218
+ label: t("label.field"),
219
+ options: fields,
220
+ labelProperty: "label",
221
+ valueProperty: "field",
222
+ groupProperty: "type"
223
+ })
197
224
  })
198
- })
199
- }), /*#__PURE__*/jsxs(Col, {
200
- flex: "auto",
201
- className: "text-center",
202
- children: [/*#__PURE__*/jsx("label", {
203
- className: "block py-0.5 text-sm",
204
- children: t("label.exclude")
205
- }), /*#__PURE__*/jsx(Controller, {
206
- name: "negate",
207
- children: /*#__PURE__*/jsx(Switch, {
208
- color: "danger"
225
+ }), /*#__PURE__*/jsxs(Col, {
226
+ flex: "auto",
227
+ className: "text-center",
228
+ children: [/*#__PURE__*/jsx("label", {
229
+ className: "block py-0.5 text-sm",
230
+ children: t("label.exclude")
231
+ }), /*#__PURE__*/jsx(Controller, {
232
+ name: "negate",
233
+ children: /*#__PURE__*/jsx(Switch, {
234
+ color: "danger"
235
+ })
236
+ })]
237
+ }), /*#__PURE__*/jsx(Col, {
238
+ flex: "auto",
239
+ className: "basis-28",
240
+ children: /*#__PURE__*/jsx(Controller, {
241
+ name: "operator",
242
+ children: /*#__PURE__*/jsx(Select, {
243
+ label: t("label.operator"),
244
+ options: operators,
245
+ renderer: function renderer(v) {
246
+ return t("operator.".concat(v));
247
+ }
248
+ })
209
249
  })
210
250
  })]
211
- }), /*#__PURE__*/jsx(Col, {
212
- flex: "auto",
213
- className: "basis-28",
214
- children: /*#__PURE__*/jsx(Controller, {
215
- name: "operator",
216
- children: /*#__PURE__*/jsx(Select, {
217
- label: t("label.operator"),
218
- options: operators,
219
- renderer: function renderer(v) {
220
- return t("operator.".concat(v));
221
- }
251
+ }), /*#__PURE__*/jsx("br", {}), valueInput, /*#__PURE__*/jsx("br", {}), /*#__PURE__*/jsx(Controller, {
252
+ name: "label",
253
+ children: /*#__PURE__*/jsx(Input, {
254
+ label: t("label.label"),
255
+ placeholder: t("label.label"),
256
+ decorateEnd: !(filter !== null && filter !== void 0 && filter.label) && /*#__PURE__*/jsx("span", {
257
+ className: "text-sm opacity-65 pe-4",
258
+ children: "Optional"
222
259
  })
223
260
  })
224
- })]
225
- }), /*#__PURE__*/jsx("br", {}), valueInput, /*#__PURE__*/jsx("br", {}), /*#__PURE__*/jsx(Controller, {
226
- name: "label",
227
- children: /*#__PURE__*/jsx(Input, {
228
- label: t("label.label"),
229
- placeholder: t("label.label"),
230
- decorateEnd: !(filter !== null && filter !== void 0 && filter.label) && /*#__PURE__*/jsx("span", {
231
- className: "text-sm opacity-65 pe-4",
232
- children: "Optional"
233
- })
234
- })
235
- }), /*#__PURE__*/jsxs("div", {
236
- className: "flex pt-4 justify-end gap-1",
237
- children: [onRemove && /*#__PURE__*/jsx("div", {
238
- className: "flex-1",
239
- children: /*#__PURE__*/jsx(Button, {
261
+ }), /*#__PURE__*/jsxs("div", {
262
+ className: "flex mt-4 justify-end gap-1 sticky bottom-1 bg-base",
263
+ children: [onRemove && /*#__PURE__*/jsx("div", {
264
+ className: "flex-1",
265
+ children: /*#__PURE__*/jsx(Button, {
266
+ "data-dropdown-dismiss": "true",
267
+ variant: "link",
268
+ size: "sm",
269
+ color: "danger",
270
+ onClick: onRemove,
271
+ children: t("label.remove")
272
+ })
273
+ }), /*#__PURE__*/jsx(Button, {
240
274
  "data-dropdown-dismiss": "true",
241
275
  variant: "link",
242
276
  size: "sm",
243
- color: "danger",
244
- onClick: onRemove,
245
- children: t("label.remove")
246
- })
247
- }), /*#__PURE__*/jsx(Button, {
248
- "data-dropdown-dismiss": "true",
249
- variant: "link",
250
- size: "sm",
251
- children: t("label.cancel")
252
- }), /*#__PURE__*/jsx(Button, {
253
- type: "submit",
254
- variant: "solid",
255
- size: "sm",
256
- children: t("label.apply")
277
+ children: t("label.cancel")
278
+ }), /*#__PURE__*/jsx(Button, {
279
+ type: "submit",
280
+ variant: "solid",
281
+ size: "sm",
282
+ children: t("label.apply")
283
+ })]
257
284
  })]
258
- })]
285
+ })
259
286
  });
260
287
  };
261
288
 
@@ -51,7 +51,8 @@ var FilterTag = function FilterTag(_ref) {
51
51
  });
52
52
  }, [filter]);
53
53
  var color = useMemo(function () {
54
- return filter.negate ? excludedColor : includedColor;
54
+ var _filter$color;
55
+ return (_filter$color = filter.color) !== null && _filter$color !== void 0 ? _filter$color : filter.negate ? excludedColor : includedColor;
55
56
  }, [filter, includedColor, excludedColor]);
56
57
  var icon = useMemo(function () {
57
58
  if (filter.canDisable === false) return undefined;
@@ -71,13 +72,16 @@ var FilterTag = function FilterTag(_ref) {
71
72
  disabled: !filter.disabled
72
73
  })), e.stopPropagation()];
73
74
  },
75
+ "data-ref": "filterTag",
76
+ "data-test-value": filter.id,
74
77
  stopPropagation: true,
75
78
  onRemove: filter.required ? undefined : function () {
76
79
  return onRemove();
77
80
  },
78
81
  children: /*#__PURE__*/jsxs("div", {
79
- className: classNames("flex gap-1", filter.disabled && "line-through opacity-65"),
82
+ className: classNames("flex gap-1 items-center", filter.disabled && "line-through opacity-65"),
80
83
  children: [filter.pinned && /*#__PURE__*/jsx(Icon, {
84
+ className: "flex-content",
81
85
  icon: (_filter$icon = filter.icon) !== null && _filter$icon !== void 0 ? _filter$icon : CoreIcons.pin
82
86
  }), label]
83
87
  })
@@ -13,7 +13,7 @@ import { useTranslation } from 'react-i18next';
13
13
  import { useFilterContext } from './Context.js';
14
14
  import { jsxs, jsx } from '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 yup.ObjectSchema({
@@ -87,16 +87,21 @@ var QueryForm = function QueryForm(_ref) {
87
87
  children: function children(_ref2) {
88
88
  _ref2.checked;
89
89
  _ref2.error;
90
- var invalid = _ref2.invalid,
91
- field = _objectWithoutProperties(_ref2, _excluded);
90
+ var invalid = _ref2.invalid;
91
+ _ref2.ref;
92
+ var field = _objectWithoutProperties(_ref2, _excluded);
92
93
  return /*#__PURE__*/jsxs("div", {
93
94
  className: "my-2",
94
95
  children: [/*#__PURE__*/jsx("label", {
95
96
  className: classNames("block px-2", invalid && "text-danger-600"),
96
97
  children: t("label.query")
97
98
  }), /*#__PURE__*/jsx("div", {
98
- className: "h-[380px] w-[600px] grid outline",
99
+ className: "h-[24rem] w-[36rem] grid outline place-content-start",
100
+ style: {
101
+ gridTemplate: '"content" 1fr/1fr'
102
+ },
99
103
  children: /*#__PURE__*/jsx(CodeEditor, _objectSpread(_objectSpread({
104
+ language: "json",
100
105
  minimal: true,
101
106
  required: true
102
107
  }, field), {}, {
@@ -106,7 +111,7 @@ var QueryForm = function QueryForm(_ref) {
106
111
  });
107
112
  }
108
113
  }), /*#__PURE__*/jsxs("div", {
109
- className: "flex justify-end gap-1",
114
+ className: "flex mt-4 justify-end gap-1 sticky bottom-1 bg-base",
110
115
  children: [onRemove && /*#__PURE__*/jsx("div", {
111
116
  className: "flex-1",
112
117
  children: /*#__PURE__*/jsx(Button, {
package/dist/esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  import './i18n/index.js';
4
+ export { FilterBar } from './filterbar/FilterBar.js';
4
5
  export { SearchBar } from './searchbar/SearchBar.js';
5
6
  export { FIELD_TYPE, OPERATOR } from './types/index.js';
@@ -7,12 +7,12 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
7
7
  import { useLocalStorage, useDebounce, Button } from '@react-fabric/core';
8
8
  import { Field, AutoComplete } from '@react-fabric/form';
9
9
  import { EMPTY_ARRAY, isArray, dedupe } from '@react-fabric/utilities';
10
- import { useState, useMemo, useReducer } from 'react';
10
+ import { useState, useMemo, useReducer, useEffect } from 'react';
11
11
  import { useTranslation } from 'react-i18next';
12
12
  import { FilterBar } from '../filterbar/FilterBar.js';
13
13
  import { jsxs, jsx } from 'react/jsx-runtime';
14
14
 
15
- var _excluded = ["historyKey", "historyCount", "defaultQueryList", "prepend", "append", "decorateEnd", "decorateStart", "actions", "hideFilters", "defaultCollapsed", "disabled", "onCollapsed", "onQuery", "onSearch", "query", "multiple", "filters"];
15
+ var _excluded = ["historyKey", "historyCount", "defaultQueryList", "prepend", "append", "decorateEnd", "decorateStart", "children", "hideFilters", "defaultCollapsed", "disabled", "onCollapsed", "onQuery", "onSearch", "query", "multiple", "filters"];
16
16
  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; }
17
17
  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; }
18
18
  var SearchBar = function SearchBar(_ref) {
@@ -25,14 +25,14 @@ var SearchBar = function SearchBar(_ref) {
25
25
  append = _ref.append,
26
26
  decorateEnd = _ref.decorateEnd,
27
27
  decorateStart = _ref.decorateStart,
28
- actions = _ref.actions,
28
+ children = _ref.children,
29
29
  hideFilters = _ref.hideFilters,
30
30
  _ref$defaultCollapsed = _ref.defaultCollapsed,
31
31
  defaultCollapsed = _ref$defaultCollapsed === void 0 ? false : _ref$defaultCollapsed;
32
32
  _ref.disabled;
33
33
  _ref.onCollapsed;
34
- var onQuery = _ref.onQuery,
35
- onSearch = _ref.onSearch,
34
+ _ref.onQuery;
35
+ var onSearch = _ref.onSearch,
36
36
  query = _ref.query,
37
37
  multiple = _ref.multiple,
38
38
  _ref$filters = _ref.filters,
@@ -52,12 +52,23 @@ var SearchBar = function SearchBar(_ref) {
52
52
  return multiple ? EMPTY_ARRAY : "";
53
53
  }, [multiple]);
54
54
  var fireSearch = useDebounce(function (query, filters) {
55
+ dispatch({
56
+ type: "dirty",
57
+ dirty: false
58
+ });
55
59
  onSearch === null || onSearch === void 0 || onSearch({
56
60
  query: query,
57
61
  filters: filters
58
62
  });
59
63
  }, []);
60
64
  var _useReducer = useReducer(function (state, action) {
65
+ if (action.type === "reset") {
66
+ return _objectSpread(_objectSpread({}, state), {}, {
67
+ dirty: false,
68
+ query: action.query,
69
+ filters: action.filters
70
+ });
71
+ }
61
72
  if (action.type === "dirty") {
62
73
  return _objectSpread(_objectSpread({}, state), {}, {
63
74
  dirty: action.dirty
@@ -88,6 +99,13 @@ var SearchBar = function SearchBar(_ref) {
88
99
  _useReducer2 = _slicedToArray(_useReducer, 2),
89
100
  state = _useReducer2[0],
90
101
  dispatch = _useReducer2[1];
102
+ useEffect(function () {
103
+ dispatch({
104
+ type: "reset",
105
+ filters: filters,
106
+ query: query
107
+ });
108
+ }, [filters, query]);
91
109
  var updateHistory = function updateHistory(value) {
92
110
  var historyEntry = isArray(value) ? value : [value];
93
111
  setHistory(dedupe([].concat(_toConsumableArray(historyEntry), _toConsumableArray(history))).slice(0, historyCount));
@@ -131,7 +149,7 @@ var SearchBar = function SearchBar(_ref) {
131
149
  });
132
150
  },
133
151
  onSelect: updateHistory,
134
- onQuery: onQuery,
152
+ "data-ref": "searchbarInput",
135
153
  onEnterPressed: function onEnterPressed() {
136
154
  return fireSearch(state.query, state.filters);
137
155
  }
@@ -143,7 +161,7 @@ var SearchBar = function SearchBar(_ref) {
143
161
  },
144
162
  children: t(state.dirty ? "label.update" : "label.refresh")
145
163
  })]
146
- }), actions]
164
+ }), children]
147
165
  }), !hideFilters && !collapsed && /*#__PURE__*/jsx(FilterBar, _objectSpread(_objectSpread({}, filterProps), {}, {
148
166
  filters: state.filters,
149
167
  onFilterChanged: handleFilterChange
@@ -54,7 +54,7 @@ var OPERATOR = /*#__PURE__*/function (OPERATOR) {
54
54
  /**
55
55
  * @internal
56
56
  */
57
- var TypeOperators = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FIELD_TYPE.ID, [OPERATOR.IS]), FIELD_TYPE.STRING, [OPERATOR.EXISTS, OPERATOR.IS, OPERATOR.IN, OPERATOR.INCLUDES, OPERATOR.STARTS, OPERATOR.ENDS]), FIELD_TYPE.NUMBER, [OPERATOR.EXISTS, OPERATOR.IS, OPERATOR.BETWEEN, OPERATOR.LT, OPERATOR.GT, OPERATOR.LTE, OPERATOR.GTE]), FIELD_TYPE.DECIMAL, [OPERATOR.EXISTS, OPERATOR.IS, OPERATOR.BETWEEN, OPERATOR.LT, OPERATOR.GT, OPERATOR.LTE, OPERATOR.GTE]), FIELD_TYPE.BOOLEAN, [OPERATOR.EXISTS, OPERATOR.IS]), FIELD_TYPE.NONE, [OPERATOR.EXISTS]);
57
+ var TypeOperators = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FIELD_TYPE.ID, [OPERATOR.IS, OPERATOR.IN]), FIELD_TYPE.STRING, [OPERATOR.EXISTS, OPERATOR.IS, OPERATOR.IN, OPERATOR.INCLUDES, OPERATOR.STARTS, OPERATOR.ENDS]), FIELD_TYPE.NUMBER, [OPERATOR.EXISTS, OPERATOR.IS, OPERATOR.BETWEEN, OPERATOR.LT, OPERATOR.GT, OPERATOR.LTE, OPERATOR.GTE]), FIELD_TYPE.DECIMAL, [OPERATOR.EXISTS, OPERATOR.IS, OPERATOR.BETWEEN, OPERATOR.LT, OPERATOR.GT, OPERATOR.LTE, OPERATOR.GTE]), FIELD_TYPE.BOOLEAN, [OPERATOR.EXISTS, OPERATOR.IS]), FIELD_TYPE.NONE, [OPERATOR.EXISTS]);
58
58
 
59
59
  /**
60
60
  * @internal
@@ -1,3 +1,4 @@
1
1
  import "./i18n";
2
+ export { FilterBar } from "./filterbar/FilterBar";
2
3
  export { SearchBar } from "./searchbar/SearchBar";
3
- export { FIELD_TYPE, OPERATOR, type FilterObject, type SearchObject, } from "./types";
4
+ export { FIELD_TYPE, OPERATOR, type FilterObject } from "./types";
@@ -1,2 +1,2 @@
1
1
  import { type FilterBarProps, type SearchBarProps } from "../types";
2
- export declare const SearchBar: ({ historyKey, historyCount, defaultQueryList, prepend, append, decorateEnd, decorateStart, actions, hideFilters, defaultCollapsed, disabled, onCollapsed, onQuery, onSearch, query, multiple, filters, ...filterProps }: SearchBarProps & Omit<FilterBarProps, "onFilterChanged">) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const SearchBar: ({ historyKey, historyCount, defaultQueryList, prepend, append, decorateEnd, decorateStart, children, hideFilters, defaultCollapsed, disabled, onCollapsed, onQuery, onSearch, query, multiple, filters, ...filterProps }: SearchBarProps & Omit<FilterBarProps, "onFilterChanged">) => import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,4 @@
1
+ import { type ChildrenProp } from "@react-fabric/core/dist/types/types";
1
2
  import { type ReactElement } from "react";
2
3
  export declare enum FIELD_TYPE {
3
4
  ID = "ID",
@@ -42,6 +43,7 @@ interface BaseFilter {
42
43
  icon?: string;
43
44
  label?: string;
44
45
  group?: string;
46
+ color?: string;
45
47
  value?: FilterValue;
46
48
  pinned?: boolean;
47
49
  negate?: boolean;
@@ -54,19 +56,17 @@ interface BaseFilter {
54
56
  }
55
57
  export type FilterObject = BaseFilter & ({
56
58
  field: string;
57
- type?: FIELD_TYPE;
58
59
  operator: OPERATOR;
59
60
  value?: FilterValue;
60
61
  query?: never;
61
62
  } | {
62
63
  field?: never;
63
- type?: never;
64
64
  operator?: never;
65
65
  label: string;
66
66
  query: string;
67
67
  });
68
- export interface SearchObject {
69
- query?: string | string[];
68
+ export interface SearchObject<T = string> {
69
+ query?: T;
70
70
  filters: FilterObject[];
71
71
  }
72
72
  export type FieldValue = string | {
@@ -82,7 +82,7 @@ export interface FilterField {
82
82
  defaultOperator?: OPERATOR;
83
83
  onSearch?: (q: string) => Promise<FieldValue[]> | FieldValue[];
84
84
  }
85
- interface BaseSearchBarProps {
85
+ interface BaseSearchBarProps extends Partial<ChildrenProp> {
86
86
  /**
87
87
  * Query string
88
88
  */
@@ -109,10 +109,6 @@ interface BaseSearchBarProps {
109
109
  * Add-on after search input
110
110
  */
111
111
  append?: ReactElement;
112
- /**
113
- * Additional actions menu
114
- */
115
- actions?: ReactElement;
116
112
  /**
117
113
  * Hide filter bar
118
114
  */
@@ -139,11 +135,6 @@ interface BaseSearchBarProps {
139
135
  * @param collapsed
140
136
  */
141
137
  onCollapsed?: (collapsed: boolean) => void;
142
- /**
143
- * On search event
144
- * @param queryObject
145
- */
146
- onSearch?: (queryObject: SearchObject) => void;
147
138
  /**
148
139
  * On query string change event
149
140
  * @param query
@@ -153,9 +144,19 @@ interface BaseSearchBarProps {
153
144
  export type SearchBarProps = BaseSearchBarProps & ({
154
145
  multiple: true;
155
146
  query?: string[];
147
+ /**
148
+ * On search event
149
+ * @param queryObject
150
+ */
151
+ onSearch?: (queryObject: SearchObject<string[]>) => void;
156
152
  } | {
157
153
  multiple?: never | false;
158
154
  query?: string;
155
+ /**
156
+ * On search event
157
+ * @param queryObject
158
+ */
159
+ onSearch?: (queryObject: SearchObject) => void;
159
160
  });
160
161
  export interface FilterBarProps {
161
162
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/searchbar",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.0-beta.41",
4
4
  "description": "RUF: Searchbar with filters package",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
@@ -33,24 +33,26 @@
33
33
  "watch": "npm-run-all -p watch:rollup watch:dts"
34
34
  },
35
35
  "dependencies": {
36
- "@floating-ui/react": "0.26.24",
37
- "@react-fabric/core": "^1.0.0-beta.4",
38
- "@react-fabric/date": "^1.0.0-beta.4",
39
- "@react-fabric/form": "^1.0.0-beta.4",
40
- "@react-fabric/monaco": "^1.0.0-beta.4",
41
- "@react-fabric/utilities": "^1.0.0-beta.4",
36
+ "@floating-ui/react": "^0.26.24",
37
+ "@react-fabric/core": "^1.0.0-beta.41",
38
+ "@react-fabric/form": "^1.0.0-beta.41",
39
+ "@react-fabric/monaco": "^1.0.0-beta.41",
40
+ "@react-fabric/utilities": "^1.0.0-beta.41",
42
41
  "classnames": "^2.5.1",
43
42
  "react-hook-form": "^7.52.1"
44
43
  },
45
44
  "peerDependencies": {
46
45
  "i18next": "^23.15.1",
47
- "react": ">=18.0.0 <20.0.0",
48
- "react-dom": ">=18.0.0 <20.0.0",
46
+ "react": "^19.0.0",
47
+ "react-dom": "^19.0.0",
49
48
  "react-i18next": "^15.0.2"
50
49
  },
50
+ "devDependencies": {
51
+ "@react-fabric/superdate": "^1.0.0-beta.41"
52
+ },
51
53
  "engines": {
52
54
  "node": ">=18.12.0",
53
55
  "npm": ">=8.19.0"
54
56
  },
55
- "gitHead": "47b0aede19252a3a3ef8df75c08a21caabde8100"
57
+ "gitHead": "bc737416d3c6a217a6b8c47291c3975a22722d80"
56
58
  }