@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
@@ -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 = useMemo(function () {
27
28
  var _filter$value;
28
29
  if (filter.label) return /*#__PURE__*/jsxs(Fragment, {
29
- children: [filter.negate && /*#__PURE__*/jsx("span", {
30
+ children: [filter.field && filter.negate && /*#__PURE__*/jsx("span", {
30
31
  className: "font-semibold",
31
32
  children: "NOT"
32
33
  }), /*#__PURE__*/jsx("span", {
@@ -34,7 +35,7 @@ var FilterTag = function FilterTag(_ref) {
34
35
  })]
35
36
  });
36
37
  return /*#__PURE__*/jsxs(Fragment, {
37
- children: [filter.negate && /*#__PURE__*/jsx("span", {
38
+ children: [filter.field && filter.negate && /*#__PURE__*/jsx("span", {
38
39
  className: "font-semibold",
39
40
  children: "NOT"
40
41
  }), /*#__PURE__*/jsx("span", {
@@ -52,7 +53,7 @@ var FilterTag = function FilterTag(_ref) {
52
53
  }, [filter]);
53
54
  var color = 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 = useMemo(function () {
58
59
  if (filter.canDisable === false) return undefined;
@@ -63,7 +64,7 @@ var FilterTag = function FilterTag(_ref) {
63
64
  children: [/*#__PURE__*/jsx(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__*/jsxs("div", {
80
83
  className: classNames("flex gap-1 items-center", filter.disabled && "line-through opacity-65"),
81
84
  children: [filter.pinned && /*#__PURE__*/jsx(Icon, {
85
+ className: "flex-content",
82
86
  icon: (_filter$icon = filter.icon) !== null && _filter$icon !== void 0 ? _filter$icon : CoreIcons.pin
83
87
  }), label]
84
88
  })
85
89
  }), /*#__PURE__*/jsx(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 === OPERATOR.IN && isArray(filter.value)) {
48
+ if (filter.operator === OPERATOR.ANY && 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 === OPERATOR.ALL && 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__*/jsxs(Fragment, {
53
57
  children: [filter.negate && /*#__PURE__*/jsx("b", {
54
58
  children: "NOT\xA0"
@@ -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({
@@ -37,7 +37,8 @@ var QueryForm = function QueryForm(_ref) {
37
37
  var _useFilterContext = 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 = useRef(null);
42
43
  var filterValue = 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__*/jsxs("div", {
93
95
  className: "my-2",
94
96
  children: [/*#__PURE__*/jsx("label", {
@@ -100,6 +102,7 @@ var QueryForm = function QueryForm(_ref) {
100
102
  gridTemplate: '"content" 1fr/1fr'
101
103
  },
102
104
  children: /*#__PURE__*/jsx(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__*/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__*/jsx("div", {
114
117
  className: "flex-1",
115
118
  children: /*#__PURE__*/jsx(Button, {
@@ -1,70 +1,73 @@
1
1
  'use client';
2
2
 
3
3
  var label = {
4
- filters: "المرشحات",
4
+ add: "إضافة عامل تصفية",
5
5
  all_filters: "جميع المرشحات",
6
+ apply: "يتقدم",
7
+ basicFilter: "الفلتر الأساسي",
8
+ cancel: "يلغي",
9
+ customQuery: "استعلام مخصص",
10
+ "delete": "يمسح",
11
+ disable: "إبطال",
12
+ disableAll: "تعطيل الكل",
13
+ edit: "يحرر",
14
+ enable: "يُمكَِن",
15
+ enableAll: "تمكين الكل",
16
+ exclude: "استبعاد",
17
+ excludeAll: "استبعاد الكل",
6
18
  field: "مجال",
7
- operator: "المشغل",
8
- value: "قيمة",
19
+ filters: "المرشحات",
20
+ forAdvanced: "للمستخدمين المتقدمين فقط!",
21
+ include: "يشمل",
22
+ includeAll: "تضمين الكل",
23
+ invertAll: "عكس التضمين/الاستبعاد",
9
24
  label: "ملصق",
25
+ operator: "المشغل",
10
26
  optional: "خياري",
11
- add: "إضافة عامل تصفية",
12
- edit: "يحرر",
13
- view: "منظر",
14
27
  pin: "مثبت",
15
- unpin: "غير مثبت",
16
- includeAll: "تضمين الكل",
17
- excludeAll: "استبعاد الكل",
18
- invertAll: "عكس التضمين/الاستبعاد",
28
+ query: "استفسار",
29
+ refresh: "ينعش",
30
+ remove: "يزيل",
19
31
  removeAll: "إزالة الكل",
20
- enableAll: "تمكين الكل",
21
- disableAll: "تعطيل الكل",
22
32
  toggleDisable: "عكس تعطيل/تمكين",
23
- remove: "يزيل",
24
- enable: "يُمكَِن",
25
- disable: "إبطال",
26
- exclude: "استبعاد",
27
- include: "يشمل",
28
- refresh: "ينعش",
33
+ unpin: "غير مثبت",
29
34
  update: "تحديث",
30
- query: "استفسار",
31
- apply: "يتقدم",
32
- cancel: "يلغي",
33
- "delete": "يمسح",
34
- basicFilter: "الفلتر الأساسي",
35
- customQuery: "استعلام مخصص",
36
- forAdvanced: "للمستخدمين المتقدمين فقط!"
35
+ value: "قيمة",
36
+ view: "منظر",
37
+ matchAll: "تطابق كل شيء",
38
+ matchAny: "تطابق أي"
37
39
  };
38
40
  var operator = {
41
+ ALL: "كل",
42
+ ANY: "أي من",
43
+ BETWEEN: "بين هذا وذاك",
44
+ ENDS: "ينتهي مع",
39
45
  EXISTS: "موجود",
46
+ GT: ">",
47
+ GTE: "≥",
40
48
  IS: "يكون",
41
- IN: "في",
49
+ LIKE: "يحب",
42
50
  LT: "<",
43
- GT: ">",
44
51
  LTE: "≤",
45
- GTE: "≥",
46
- INCLUDES: "يشمل",
47
52
  STARTS: "ابدا ب",
48
- ENDS: "ينتهي مع",
49
- WITHIN: "في غضون",
50
- BETWEEN: "بين هذا وذاك"
53
+ WITHIN: "في غضون"
51
54
  };
52
55
  var placeholder = "مصطلح البحث...";
53
56
  var type = {
54
- STRING: "سلسلة",
55
- NUMBER: "كثافة العمليات",
56
- DECIMAL: "يطفو",
57
57
  BOOLEAN: "رقم",
58
58
  DATE: "منطقي",
59
59
  DATETIME: "تاريخ",
60
- GEO: "GeoJSON"
60
+ DECIMAL: "يطفو",
61
+ GEO: "GeoJSON",
62
+ NUMBER: "كثافة العمليات",
63
+ STRING: "سلسلة"
61
64
  };
62
65
  var validate = {
66
+ compare: "مقارنة الحقل المطلوب",
63
67
  field: "حقل مطلوب",
68
+ label: "التصنيف مطلوب",
64
69
  operator: "عامل مطلوب",
65
- value: "القيمة المطلوبة",
66
- compare: "مقارنة الحقل المطلوب",
67
- label: "التصنيف مطلوب"
70
+ value: "القيمة المطلوبة"
68
71
  };
69
72
  var ar = {
70
73
  label: label,
@@ -1,70 +1,74 @@
1
1
  'use client';
2
2
 
3
3
  var label = {
4
- filters: "Filters",
4
+ add: "Add Filter",
5
5
  all_filters: "All Filters",
6
+ apply: "Apply",
7
+ basicFilter: "Basic Filter",
8
+ cancel: "Cancel",
9
+ customQuery: "Custom Query",
10
+ "delete": "Delete",
11
+ disable: "Disable",
12
+ disableAll: "Disable All",
13
+ edit: "Edit",
14
+ enable: "Enable",
15
+ enableAll: "Enable All",
16
+ exclude: "Exclude",
17
+ excludeAll: "Exclude All",
6
18
  field: "Field",
7
- operator: "Operator",
8
- value: "Value",
19
+ filters: "Filters",
20
+ forAdvanced: "For advanced users only!",
21
+ include: "Include",
22
+ includeAll: "Include All",
23
+ invertAll: "Invert Include/Exclude",
9
24
  label: "Label",
25
+ matchAll: "Match All",
26
+ matchAny: "Match Any",
27
+ operator: "Operator",
10
28
  optional: "Optional",
11
- add: "Add Filter",
12
- edit: "Edit",
13
- view: "View",
14
29
  pin: "Pinned",
15
- unpin: "Unpinned",
16
- includeAll: "Include All",
17
- excludeAll: "Exclude All",
18
- invertAll: "Invert Include/Exclude",
30
+ query: "Query",
31
+ refresh: "Refresh",
32
+ remove: "Remove",
19
33
  removeAll: "Remove All",
20
- enableAll: "Enable All",
21
- disableAll: "Disable All",
22
34
  toggleDisable: "Invert Disable/Enable",
23
- remove: "Remove",
24
- enable: "Enable",
25
- disable: "Disable",
26
- exclude: "Exclude",
27
- include: "Include",
28
- refresh: "Refresh",
35
+ unpin: "Unpinned",
29
36
  update: "Update",
30
- query: "Query",
31
- apply: "Apply",
32
- cancel: "Cancel",
33
- "delete": "Delete",
34
- basicFilter: "Basic Filter",
35
- customQuery: "Custom Query",
36
- forAdvanced: "For advanced users only!"
37
+ value: "Value",
38
+ view: "View"
37
39
  };
38
40
  var operator = {
41
+ ALL: "All of",
42
+ ANY: "Any of",
43
+ BETWEEN: "Between",
44
+ ENDS: "Ends with",
45
+ EQ: "=",
39
46
  EXISTS: "Exists",
47
+ GT: ">",
48
+ GTE: "≥",
40
49
  IS: "Is",
41
- IN: "In",
50
+ LIKE: "Like",
42
51
  LT: "<",
43
- GT: ">",
44
52
  LTE: "≤",
45
- GTE: "≥",
46
- INCLUDES: "Includes",
47
53
  STARTS: "Starts with",
48
- ENDS: "Ends with",
49
- WITHIN: "Within",
50
- BETWEEN: "Between"
54
+ WITHIN: "Within"
51
55
  };
52
56
  var placeholder = "Search term...";
53
57
  var type = {
54
- STRING: "String",
55
- NUMBER: "Number",
56
- DECIMAL: "Decimal",
57
58
  BOOLEAN: "Bool",
58
59
  DATE: "Date",
59
60
  DATETIME: "Date Time",
60
- GEO: "GeoJSON"
61
+ DECIMAL: "Decimal",
62
+ GEO: "GeoJSON",
63
+ NUMBER: "Number",
64
+ STRING: "String"
61
65
  };
62
66
  var validate = {
67
+ compare: "Compare field required",
63
68
  field: "Field required",
69
+ label: "Label required",
64
70
  operator: "Operator required",
65
- value: "Value required",
66
- compare: "Compare field required",
67
- label: "Label required"
71
+ value: "Value required"
68
72
  };
69
73
  var en = {
70
74
  label: label,
@@ -7,14 +7,48 @@ 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", "children", "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", "ref", "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
+ /**
19
+ * This component provides a search input with autocomplete functionality,
20
+ * a button to trigger search, and an optional filter bar.
21
+ * It supports history of search queries, multiple selection, and custom decorations.
22
+ * It can be collapsed to hide filters and has options for customization.
23
+ *
24
+ * @param {SearchBarProps} props - The properties for the SearchBar component.
25
+ * @returns {JSX.Element} The rendered SearchBar component.
26
+ *
27
+ * @example
28
+ * ```jsx
29
+ * <SearchBar
30
+ * historyKey="myApp:searchHistory"
31
+ * historyCount={10}
32
+ * defaultQueryList={["example", "test"]}
33
+ * prepend={<span>Prepend</span>}
34
+ * append={<span>Append</span>}
35
+ * decorateEnd={<span>End Decoration</span>}
36
+ * decorateStart={<span>Start Decoration</span>}
37
+ * hideFilters={false}
38
+ * defaultCollapsed={false}
39
+ * disabled={false}
40
+ * onCollapsed={(collapsed) => console.log("Collapsed:", collapsed)}
41
+ * onQuery={(query) => console.log("Query:", query)}
42
+ * onSearch={({ query, filters }) => console.log("Search:", query, filters)}
43
+ * query={""}
44
+ * ref={searchInputRef}
45
+ * multiple={false}
46
+ * filters={[{ name: "filter1", value: "value1" }]}
47
+ * />
48
+ * ```
49
+ *
50
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/searchbar-searchbar--search-bar} for more details on the properties.
51
+ */
18
52
  var SearchBar = function SearchBar(_ref) {
19
53
  var _ref$historyKey = _ref.historyKey,
20
54
  historyKey = _ref$historyKey === void 0 ? "ruf:search" : _ref$historyKey,
@@ -31,9 +65,10 @@ var SearchBar = function SearchBar(_ref) {
31
65
  defaultCollapsed = _ref$defaultCollapsed === void 0 ? false : _ref$defaultCollapsed;
32
66
  _ref.disabled;
33
67
  _ref.onCollapsed;
34
- var onQuery = _ref.onQuery,
35
- onSearch = _ref.onSearch,
68
+ _ref.onQuery;
69
+ var onSearch = _ref.onSearch,
36
70
  query = _ref.query,
71
+ ref = _ref.ref,
37
72
  multiple = _ref.multiple,
38
73
  _ref$filters = _ref.filters,
39
74
  filters = _ref$filters === void 0 ? EMPTY_ARRAY : _ref$filters,
@@ -52,12 +87,23 @@ var SearchBar = function SearchBar(_ref) {
52
87
  return multiple ? EMPTY_ARRAY : "";
53
88
  }, [multiple]);
54
89
  var fireSearch = useDebounce(function (query, filters) {
90
+ dispatch({
91
+ type: "dirty",
92
+ dirty: false
93
+ });
55
94
  onSearch === null || onSearch === void 0 || onSearch({
56
95
  query: query,
57
96
  filters: filters
58
97
  });
59
98
  }, []);
60
99
  var _useReducer = useReducer(function (state, action) {
100
+ if (action.type === "reset") {
101
+ return _objectSpread(_objectSpread({}, state), {}, {
102
+ dirty: false,
103
+ query: action.query,
104
+ filters: action.filters
105
+ });
106
+ }
61
107
  if (action.type === "dirty") {
62
108
  return _objectSpread(_objectSpread({}, state), {}, {
63
109
  dirty: action.dirty
@@ -88,6 +134,13 @@ var SearchBar = function SearchBar(_ref) {
88
134
  _useReducer2 = _slicedToArray(_useReducer, 2),
89
135
  state = _useReducer2[0],
90
136
  dispatch = _useReducer2[1];
137
+ useEffect(function () {
138
+ dispatch({
139
+ type: "reset",
140
+ filters: filters,
141
+ query: query
142
+ });
143
+ }, [filters, query]);
91
144
  var updateHistory = function updateHistory(value) {
92
145
  var historyEntry = isArray(value) ? value : [value];
93
146
  setHistory(dedupe([].concat(_toConsumableArray(historyEntry), _toConsumableArray(history))).slice(0, historyCount));
@@ -119,6 +172,7 @@ var SearchBar = function SearchBar(_ref) {
119
172
  }), prepend, /*#__PURE__*/jsx(AutoComplete, {
120
173
  allowClear: true,
121
174
  expandOnEdit: true,
175
+ ref: ref,
122
176
  multiple: multiple,
123
177
  history: history,
124
178
  value: state.query,
@@ -131,7 +185,7 @@ var SearchBar = function SearchBar(_ref) {
131
185
  });
132
186
  },
133
187
  onSelect: updateHistory,
134
- onQuery: onQuery,
188
+ "data-ref": "searchbarInput",
135
189
  onEnterPressed: function onEnterPressed() {
136
190
  return fireSearch(state.query, state.filters);
137
191
  }
@@ -29,21 +29,26 @@ var _OperatorValueType;
29
29
  var FIELD_TYPE = /*#__PURE__*/function (FIELD_TYPE) {
30
30
  FIELD_TYPE["ID"] = "ID";
31
31
  FIELD_TYPE["STRING"] = "STRING";
32
+ FIELD_TYPE["TEXT"] = "TEXT";
32
33
  FIELD_TYPE["NUMBER"] = "NUMBER";
33
34
  FIELD_TYPE["DECIMAL"] = "DECIMAL";
34
35
  FIELD_TYPE["BOOLEAN"] = "BOOLEAN";
36
+ FIELD_TYPE["DATE"] = "DATE";
37
+ FIELD_TYPE["DATETIME"] = "DATETIME";
35
38
  FIELD_TYPE["NONE"] = "NONE";
36
39
  return FIELD_TYPE;
37
40
  }({});
38
41
  var OPERATOR = /*#__PURE__*/function (OPERATOR) {
39
42
  OPERATOR["EXISTS"] = "EXISTS";
40
43
  OPERATOR["IS"] = "IS";
41
- OPERATOR["IN"] = "IN";
44
+ OPERATOR["ALL"] = "ALL";
45
+ OPERATOR["ANY"] = "ANY";
46
+ OPERATOR["EQ"] = "EQ";
42
47
  OPERATOR["LT"] = "LT";
43
48
  OPERATOR["GT"] = "GT";
44
49
  OPERATOR["LTE"] = "LTE";
45
50
  OPERATOR["GTE"] = "GTE";
46
- OPERATOR["INCLUDES"] = "INCLUDES";
51
+ OPERATOR["LIKE"] = "LIKE";
47
52
  OPERATOR["STARTS"] = "STARTS";
48
53
  OPERATOR["ENDS"] = "ENDS";
49
54
  OPERATOR["WITHIN"] = "WITHIN";
@@ -54,12 +59,15 @@ var OPERATOR = /*#__PURE__*/function (OPERATOR) {
54
59
  /**
55
60
  * @internal
56
61
  */
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]);
62
+ var TypeOperators = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FIELD_TYPE.ID, [OPERATOR.IS, OPERATOR.ANY]), FIELD_TYPE.STRING, [OPERATOR.EXISTS, OPERATOR.IS, OPERATOR.ANY, OPERATOR.ALL]), FIELD_TYPE.TEXT, [OPERATOR.EXISTS, OPERATOR.LIKE, OPERATOR.STARTS, OPERATOR.ENDS]), FIELD_TYPE.NUMBER, [OPERATOR.EXISTS, OPERATOR.EQ, OPERATOR.BETWEEN, OPERATOR.LT, OPERATOR.GT, OPERATOR.LTE, OPERATOR.GTE]), FIELD_TYPE.DECIMAL, [OPERATOR.EXISTS, OPERATOR.EQ, OPERATOR.BETWEEN, OPERATOR.LT, OPERATOR.GT, OPERATOR.LTE, OPERATOR.GTE]), FIELD_TYPE.BOOLEAN, [OPERATOR.EXISTS, OPERATOR.EQ]), FIELD_TYPE.DATE, [OPERATOR.EXISTS, OPERATOR.EQ, OPERATOR.BETWEEN, OPERATOR.LT, OPERATOR.GT, OPERATOR.LTE, OPERATOR.GTE]), FIELD_TYPE.DATETIME, [OPERATOR.EXISTS, OPERATOR.EQ, OPERATOR.BETWEEN, OPERATOR.LT, OPERATOR.GT, OPERATOR.LTE, OPERATOR.GTE]), FIELD_TYPE.NONE, [OPERATOR.EXISTS]);
58
63
 
59
64
  /**
60
65
  * @internal
66
+ * 0 single value
67
+ * 1 many values
68
+ * 2 two values
61
69
  */
62
- (_OperatorValueType = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_OperatorValueType, OPERATOR.EXISTS, 0), OPERATOR.IS, 0), OPERATOR.IN, 1), OPERATOR.BETWEEN, 2), OPERATOR.WITHIN, 0), OPERATOR.STARTS, 0), OPERATOR.ENDS, 0), OPERATOR.INCLUDES, 0), OPERATOR.LT, 0), OPERATOR.GT, 0), _defineProperty(_defineProperty(_OperatorValueType, OPERATOR.LTE, 0), OPERATOR.GTE, 0));
70
+ (_OperatorValueType = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_OperatorValueType, OPERATOR.EXISTS, 0), OPERATOR.IS, 0), OPERATOR.ANY, 1), OPERATOR.ALL, 1), OPERATOR.BETWEEN, 2), OPERATOR.WITHIN, 0), OPERATOR.STARTS, 0), OPERATOR.ENDS, 0), OPERATOR.LIKE, 0), OPERATOR.EQ, 0), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_OperatorValueType, OPERATOR.LT, 0), OPERATOR.GT, 0), OPERATOR.LTE, 0), OPERATOR.GTE, 0));
63
71
 
64
72
  /**
65
73
  * @internal
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type FilterBarProps } from "../types";
3
- export declare const FilterContext: import("react").Context<Pick<FilterBarProps, "querySchema" | "defaultQuery" | "fields">>;
4
- export declare const useFilterContext: () => Pick<FilterBarProps, "querySchema" | "defaultQuery" | "fields">;
2
+ export declare const FilterContext: import("react").Context<Pick<FilterBarProps, "querySchema" | "queryLanguage" | "defaultQuery" | "fields">>;
3
+ export declare const useFilterContext: () => Pick<FilterBarProps, "querySchema" | "queryLanguage" | "defaultQuery" | "fields">;
@@ -1,2 +1,28 @@
1
1
  import { type FilterBarProps } from "../types";
2
- export declare const FilterBar: ({ filters, allowAdd, fields, querySchema, defaultQuery, includedColor, excludedColor, onFilterChanged, }: FilterBarProps) => import("react/jsx-runtime").JSX.Element;
2
+ /**
3
+ * FilterBar component allows users to manage a list of filters.
4
+ * It provides options to add, remove, and modify filters,
5
+ * as well as to enable or disable all filters at once.
6
+ * It also supports toggling between included and excluded filters.
7
+ *
8
+ * @param {FilterBarProps} props - The properties for the FilterBar component.
9
+ * @returns {JSX.Element} The rendered FilterBar component.
10
+ *
11
+ * @example
12
+ * ```jsx
13
+ * <FilterBar
14
+ * filters={filters}
15
+ * allowAdd={true}
16
+ * fields={fields}
17
+ * editable={true}
18
+ * querySchema={querySchema}
19
+ * queryLanguage="lucene"
20
+ * defaultQuery="*"
21
+ * includedColor="green"
22
+ * excludedColor="red"
23
+ * onFilterChanged={(newFilters) => console.log(newFilters)}
24
+ * />
25
+ * ```
26
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/searchbar-searchbar--search-bar} for more details on the properties.
27
+ */
28
+ export declare const FilterBar: ({ filters, allowAdd, fields, editable, querySchema, queryLanguage, defaultQuery, includedColor, excludedColor, onFilterChanged, }: FilterBarProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,7 @@
1
1
  import { type FilterField, type FilterObject } from "../types";
2
- export declare const FilterMenu: ({ filter, fields, onChange, onRemove, }: {
2
+ export declare const FilterMenu: ({ filter, fields, editable, onChange, onRemove, }: {
3
3
  fields?: FilterField[];
4
+ editable?: boolean;
4
5
  filter: FilterObject;
5
6
  onRemove: () => void;
6
7
  onChange: (filter: FilterObject) => void;
@@ -1,6 +1,7 @@
1
1
  import { type FilterBarProps, type FilterObject } from "../types";
2
- export declare const FilterTag: ({ filter, fields, includedColor, excludedColor, onChange, onRemove, }: {
2
+ export declare const FilterTag: ({ filter, fields, editable, includedColor, excludedColor, onChange, onRemove, }: {
3
3
  filter: FilterObject;
4
+ editable?: boolean;
4
5
  onRemove: () => void;
5
6
  onChange: (filter: FilterObject) => void;
6
7
  } & Pick<FilterBarProps, "fields" | "includedColor" | "excludedColor">) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
1
  import "./i18n";
2
2
  export { FilterBar } from "./filterbar/FilterBar";
3
3
  export { SearchBar } from "./searchbar/SearchBar";
4
- export { FIELD_TYPE, OPERATOR, type FilterObject } from "./types";
4
+ export { FIELD_TYPE, OPERATOR, type FilterObject, type SearchObject, } from "./types";
@@ -1,2 +1,36 @@
1
1
  import { type FilterBarProps, type SearchBarProps } from "../types";
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;
2
+ /**
3
+ * This component provides a search input with autocomplete functionality,
4
+ * a button to trigger search, and an optional filter bar.
5
+ * It supports history of search queries, multiple selection, and custom decorations.
6
+ * It can be collapsed to hide filters and has options for customization.
7
+ *
8
+ * @param {SearchBarProps} props - The properties for the SearchBar component.
9
+ * @returns {JSX.Element} The rendered SearchBar component.
10
+ *
11
+ * @example
12
+ * ```jsx
13
+ * <SearchBar
14
+ * historyKey="myApp:searchHistory"
15
+ * historyCount={10}
16
+ * defaultQueryList={["example", "test"]}
17
+ * prepend={<span>Prepend</span>}
18
+ * append={<span>Append</span>}
19
+ * decorateEnd={<span>End Decoration</span>}
20
+ * decorateStart={<span>Start Decoration</span>}
21
+ * hideFilters={false}
22
+ * defaultCollapsed={false}
23
+ * disabled={false}
24
+ * onCollapsed={(collapsed) => console.log("Collapsed:", collapsed)}
25
+ * onQuery={(query) => console.log("Query:", query)}
26
+ * onSearch={({ query, filters }) => console.log("Search:", query, filters)}
27
+ * query={""}
28
+ * ref={searchInputRef}
29
+ * multiple={false}
30
+ * filters={[{ name: "filter1", value: "value1" }]}
31
+ * />
32
+ * ```
33
+ *
34
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/searchbar-searchbar--search-bar} for more details on the properties.
35
+ */
36
+ export declare const SearchBar: ({ historyKey, historyCount, defaultQueryList, prepend, append, decorateEnd, decorateStart, children, hideFilters, defaultCollapsed, disabled, onCollapsed, onQuery, onSearch, query, ref, multiple, filters, ...filterProps }: SearchBarProps & Omit<FilterBarProps, "onFilterChanged">) => import("react/jsx-runtime").JSX.Element;