@react-fabric/searchbar 1.0.0-beta.51 → 1.0.0-beta.53

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.
@@ -1,71 +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",
42
- EQ: "=",
50
+ LIKE: "Like",
43
51
  LT: "<",
44
- GT: ">",
45
52
  LTE: "≤",
46
- GTE: "≥",
47
- INCLUDES: "Includes",
48
53
  STARTS: "Starts with",
49
- ENDS: "Ends with",
50
- WITHIN: "Within",
51
- BETWEEN: "Between"
54
+ WITHIN: "Within"
52
55
  };
53
56
  var placeholder = "Search term...";
54
57
  var type = {
55
- STRING: "String",
56
- NUMBER: "Number",
57
- DECIMAL: "Decimal",
58
58
  BOOLEAN: "Bool",
59
59
  DATE: "Date",
60
60
  DATETIME: "Date Time",
61
- GEO: "GeoJSON"
61
+ DECIMAL: "Decimal",
62
+ GEO: "GeoJSON",
63
+ NUMBER: "Number",
64
+ STRING: "String"
62
65
  };
63
66
  var validate = {
67
+ compare: "Compare field required",
64
68
  field: "Field required",
69
+ label: "Label required",
65
70
  operator: "Operator required",
66
- value: "Value required",
67
- compare: "Compare field required",
68
- label: "Label required"
71
+ value: "Value required"
69
72
  };
70
73
  var en = {
71
74
  label: label,
@@ -15,6 +15,40 @@ import { jsxs, jsx } from 'react/jsx-runtime';
15
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,
@@ -41,13 +41,14 @@ var FIELD_TYPE = /*#__PURE__*/function (FIELD_TYPE) {
41
41
  var OPERATOR = /*#__PURE__*/function (OPERATOR) {
42
42
  OPERATOR["EXISTS"] = "EXISTS";
43
43
  OPERATOR["IS"] = "IS";
44
- OPERATOR["IN"] = "IN";
44
+ OPERATOR["ALL"] = "ALL";
45
+ OPERATOR["ANY"] = "ANY";
45
46
  OPERATOR["EQ"] = "EQ";
46
47
  OPERATOR["LT"] = "LT";
47
48
  OPERATOR["GT"] = "GT";
48
49
  OPERATOR["LTE"] = "LTE";
49
50
  OPERATOR["GTE"] = "GTE";
50
- OPERATOR["INCLUDES"] = "INCLUDES";
51
+ OPERATOR["LIKE"] = "LIKE";
51
52
  OPERATOR["STARTS"] = "STARTS";
52
53
  OPERATOR["ENDS"] = "ENDS";
53
54
  OPERATOR["WITHIN"] = "WITHIN";
@@ -58,7 +59,7 @@ var OPERATOR = /*#__PURE__*/function (OPERATOR) {
58
59
  /**
59
60
  * @internal
60
61
  */
61
- var TypeOperators = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FIELD_TYPE.ID, [OPERATOR.IS, OPERATOR.IN]), FIELD_TYPE.STRING, [OPERATOR.EXISTS, OPERATOR.IS, OPERATOR.IN]), FIELD_TYPE.TEXT, [OPERATOR.EXISTS, OPERATOR.INCLUDES, 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]);
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]);
62
63
 
63
64
  /**
64
65
  * @internal
@@ -66,7 +67,7 @@ var TypeOperators = _defineProperty(_defineProperty(_defineProperty(_definePrope
66
67
  * 1 many values
67
68
  * 2 two values
68
69
  */
69
- (_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.EQ, 0), OPERATOR.LT, 0), _defineProperty(_defineProperty(_defineProperty(_OperatorValueType, OPERATOR.GT, 0), 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));
70
71
 
71
72
  /**
72
73
  * @internal
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type FilterBarProps } from "../types";
3
2
  export declare const FilterContext: import("react").Context<Pick<FilterBarProps, "querySchema" | "queryLanguage" | "defaultQuery" | "fields">>;
4
3
  export declare const useFilterContext: () => Pick<FilterBarProps, "querySchema" | "queryLanguage" | "defaultQuery" | "fields">;
@@ -1,2 +1,28 @@
1
1
  import { type FilterBarProps } from "../types";
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
+ */
2
28
  export declare const FilterBar: ({ filters, allowAdd, fields, editable, querySchema, queryLanguage, defaultQuery, includedColor, excludedColor, onFilterChanged, }: FilterBarProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,36 @@
1
1
  import { type FilterBarProps, type SearchBarProps } from "../types";
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
+ */
2
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;
@@ -14,13 +14,14 @@ export declare enum FIELD_TYPE {
14
14
  export declare enum OPERATOR {
15
15
  EXISTS = "EXISTS",
16
16
  IS = "IS",
17
- IN = "IN",
17
+ ALL = "ALL",
18
+ ANY = "ANY",
18
19
  EQ = "EQ",
19
20
  LT = "LT",
20
21
  GT = "GT",
21
22
  LTE = "LTE",
22
23
  GTE = "GTE",
23
- INCLUDES = "INCLUDES",
24
+ LIKE = "LIKE",
24
25
  STARTS = "STARTS",
25
26
  ENDS = "ENDS",
26
27
  WITHIN = "WITHIN",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/searchbar",
3
- "version": "1.0.0-beta.51",
3
+ "version": "1.0.0-beta.53",
4
4
  "description": "RUF: Searchbar with filters package",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
@@ -34,10 +34,10 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@floating-ui/react": "^0.27.9",
37
- "@react-fabric/core": "^1.0.0-beta.51",
38
- "@react-fabric/form": "^1.0.0-beta.51",
39
- "@react-fabric/monaco": "^1.0.0-beta.51",
40
- "@react-fabric/utilities": "^1.0.0-beta.50",
37
+ "@react-fabric/core": "^1.0.0-beta.53",
38
+ "@react-fabric/form": "^1.0.0-beta.53",
39
+ "@react-fabric/monaco": "^1.0.0-beta.53",
40
+ "@react-fabric/utilities": "^1.0.0-beta.52",
41
41
  "classnames": "^2.5.1",
42
42
  "react-hook-form": "^7.56.4"
43
43
  },
@@ -48,11 +48,11 @@
48
48
  "react-i18next": "^15.5.2"
49
49
  },
50
50
  "devDependencies": {
51
- "@react-fabric/superdate": "^1.0.0-beta.51"
51
+ "@react-fabric/superdate": "^1.0.0-beta.53"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=18.12.0",
55
55
  "npm": ">=8.19.0"
56
56
  },
57
- "gitHead": "a1b04de4663045f82992bff2aef8db26608eac74"
57
+ "gitHead": "1042327831f9c908912c552d5c2704b765a6f9c2"
58
58
  }
@@ -39,6 +39,32 @@ import { FilterTag } from "./FilterTag";
39
39
  import classNames from "classnames";
40
40
  import { FilterContext } from "./Context";
41
41
 
42
+ /**
43
+ * FilterBar component allows users to manage a list of filters.
44
+ * It provides options to add, remove, and modify filters,
45
+ * as well as to enable or disable all filters at once.
46
+ * It also supports toggling between included and excluded filters.
47
+ *
48
+ * @param {FilterBarProps} props - The properties for the FilterBar component.
49
+ * @returns {JSX.Element} The rendered FilterBar component.
50
+ *
51
+ * @example
52
+ * ```jsx
53
+ * <FilterBar
54
+ * filters={filters}
55
+ * allowAdd={true}
56
+ * fields={fields}
57
+ * editable={true}
58
+ * querySchema={querySchema}
59
+ * queryLanguage="lucene"
60
+ * defaultQuery="*"
61
+ * includedColor="green"
62
+ * excludedColor="red"
63
+ * onFilterChanged={(newFilters) => console.log(newFilters)}
64
+ * />
65
+ * ```
66
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/searchbar-searchbar--search-bar} for more details on the properties.
67
+ */
42
68
  export const FilterBar = ({
43
69
  filters = [],
44
70
  allowAdd,
@@ -62,7 +62,16 @@ const FilterSchema = new yup.ObjectSchema({
62
62
  otherwise: (schema) => schema.required(),
63
63
  })
64
64
  .when("operator", {
65
- is: OPERATOR.IN,
65
+ is: OPERATOR.ANY,
66
+ then: (schema) =>
67
+ schema.test({
68
+ name: "array-check",
69
+ message: `\${path} is a required field`,
70
+ test: (val: AnyObject = []) => val?.length > 0,
71
+ }),
72
+ })
73
+ .when("operator", {
74
+ is: OPERATOR.ALL,
66
75
  then: (schema) =>
67
76
  schema.test({
68
77
  name: "array-check",
@@ -142,7 +151,7 @@ export const FilterForm = ({
142
151
  formRef.current?.setValue("value", undefined);
143
152
  }
144
153
  if (field?.type === FIELD_TYPE.STRING) {
145
- if (values?.operator === OPERATOR.IN) {
154
+ if ([OPERATOR.ALL, OPERATOR.ANY].includes(values?.operator)) {
146
155
  !isArray(values.value) && formRef.current?.setValue("value", []);
147
156
  } else {
148
157
  isArray(values.value) && formRef.current?.setValue("value", undefined);
@@ -180,7 +189,7 @@ export const FilterForm = ({
180
189
  );
181
190
  }
182
191
  if (field?.type === FIELD_TYPE.STRING || field?.type === FIELD_TYPE.ID) {
183
- if (values?.operator === OPERATOR.IN) {
192
+ if ([OPERATOR.ALL, OPERATOR.ANY].includes(values?.operator)) {
184
193
  return (
185
194
  <Controller name="value">
186
195
  <Select
@@ -24,10 +24,15 @@
24
24
  import { CoreIcons, Divider, Menu, MenuItem } from "@react-fabric/core";
25
25
  import { useState } from "react";
26
26
  import { useTranslation } from "react-i18next";
27
- import { type FilterField, type FilterObject } from "../types";
27
+ import { OPERATOR, type FilterField, type FilterObject } from "../types";
28
28
  import { FilterEdit } from "./FilterEdit";
29
29
  import { FilterView } from "./FilterView";
30
30
 
31
+ const MATCH_ALL =
32
+ "M9,5C10.04,5 11.06,5.24 12,5.68C12.94,5.24 13.96,5 15,5A7,7 0 0,1 22,12A7,7 0 0,1 15,19C13.96,19 12.94,18.76 12,18.32C11.06,18.76 10.04,19 9,19A7,7 0 0,1 2,12A7,7 0 0,1 9,5M8.5,12C8.5,13.87 9.29,15.56 10.56,16.75L11.56,16.29C10.31,15.29 9.5,13.74 9.5,12C9.5,10.26 10.31,8.71 11.56,7.71L10.56,7.25C9.29,8.44 8.5,10.13 8.5,12M15.5,12C15.5,10.13 14.71,8.44 13.44,7.25L12.44,7.71C13.69,8.71 14.5,10.26 14.5,12C14.5,13.74 13.69,15.29 12.44,16.29L13.44,16.75C14.71,15.56 15.5,13.87 15.5,12Z";
33
+ const MATCH_ANY =
34
+ "M9,5A7,7 0 0,0 2,12A7,7 0 0,0 9,19C10.04,19 11.06,18.76 12,18.32C12.94,18.76 13.96,19 15,19A7,7 0 0,0 22,12A7,7 0 0,0 15,5C13.96,5 12.94,5.24 12,5.68C11.06,5.24 10.04,5 9,5M9,7C9.34,7 9.67,7.03 10,7.1C8.72,8.41 8,10.17 8,12C8,13.83 8.72,15.59 10,16.89C9.67,16.96 9.34,17 9,17A5,5 0 0,1 4,12A5,5 0 0,1 9,7M15,7A5,5 0 0,1 20,12A5,5 0 0,1 15,17C14.66,17 14.33,16.97 14,16.9C15.28,15.59 16,13.83 16,12C16,10.17 15.28,8.41 14,7.11C14.33,7.04 14.66,7 15,7Z";
35
+
31
36
  export const FilterMenu = ({
32
37
  filter,
33
38
  fields,
@@ -70,6 +75,26 @@ export const FilterMenu = ({
70
75
  />
71
76
  )}
72
77
  <Divider />
78
+ {filter.operator &&
79
+ [OPERATOR.ALL, OPERATOR.ANY].includes(filter.operator) && (
80
+ <MenuItem
81
+ label={t(
82
+ filter.operator === OPERATOR.ALL
83
+ ? "label.matchAny"
84
+ : "label.matchAll",
85
+ )}
86
+ icon={t(filter.operator === OPERATOR.ALL ? MATCH_ANY : MATCH_ALL)}
87
+ onClick={() =>
88
+ onChange({
89
+ ...filter,
90
+ operator:
91
+ filter.operator === OPERATOR.ALL
92
+ ? OPERATOR.ANY
93
+ : OPERATOR.ALL,
94
+ })
95
+ }
96
+ />
97
+ )}
73
98
  {filter.canPin !== false && (
74
99
  <MenuItem
75
100
  label={t(filter.pinned ? "label.unpin" : "label.pin")}
@@ -26,7 +26,7 @@ import { isNil } from "@react-fabric/utilities";
26
26
  import classNames from "classnames";
27
27
  import { Fragment, useMemo } from "react";
28
28
  import { useTranslation } from "react-i18next";
29
- import { type FilterBarProps, type FilterObject } from "../types";
29
+ import { OPERATOR, type FilterBarProps, type FilterObject } from "../types";
30
30
  import { FilterMenu } from "./FilterMenu";
31
31
 
32
32
  export const FilterTag = ({
@@ -47,9 +47,12 @@ export const FilterView = ({
47
47
  value = `[${filter.value?.join(" - ")}]`;
48
48
  }
49
49
 
50
- if (filter.operator === OPERATOR.IN && isArray(filter.value)) {
50
+ if (filter.operator === OPERATOR.ANY && isArray(filter.value)) {
51
51
  value = `[${filter.value?.join(", ")}]`;
52
52
  }
53
+ if (filter.operator === OPERATOR.ALL && isArray(filter.value)) {
54
+ value = `(${filter.value?.join(", ")})`;
55
+ }
53
56
 
54
57
  return (
55
58
  <Fragment>
package/src/i18n/ar.json CHANGED
@@ -1,68 +1,71 @@
1
1
  {
2
2
  "label": {
3
- "filters": "المرشحات",
3
+ "add": "إضافة عامل تصفية",
4
4
  "all_filters": "جميع المرشحات",
5
+ "apply": "يتقدم",
6
+ "basicFilter": "الفلتر الأساسي",
7
+ "cancel": "يلغي",
8
+ "customQuery": "استعلام مخصص",
9
+ "delete": "يمسح",
10
+ "disable": "إبطال",
11
+ "disableAll": "تعطيل الكل",
12
+ "edit": "يحرر",
13
+ "enable": "يُمكَِن",
14
+ "enableAll": "تمكين الكل",
15
+ "exclude": "استبعاد",
16
+ "excludeAll": "استبعاد الكل",
5
17
  "field": "مجال",
6
- "operator": "المشغل",
7
- "value": "قيمة",
18
+ "filters": "المرشحات",
19
+ "forAdvanced": "للمستخدمين المتقدمين فقط!",
20
+ "include": "يشمل",
21
+ "includeAll": "تضمين الكل",
22
+ "invertAll": "عكس التضمين/الاستبعاد",
8
23
  "label": "ملصق",
24
+ "operator": "المشغل",
9
25
  "optional": "خياري",
10
- "add": "إضافة عامل تصفية",
11
- "edit": "يحرر",
12
- "view": "منظر",
13
26
  "pin": "مثبت",
14
- "unpin": "غير مثبت",
15
- "includeAll": "تضمين الكل",
16
- "excludeAll": "استبعاد الكل",
17
- "invertAll": "عكس التضمين/الاستبعاد",
27
+ "query": "استفسار",
28
+ "refresh": "ينعش",
29
+ "remove": "يزيل",
18
30
  "removeAll": "إزالة الكل",
19
- "enableAll": "تمكين الكل",
20
- "disableAll": "تعطيل الكل",
21
31
  "toggleDisable": "عكس تعطيل/تمكين",
22
- "remove": "يزيل",
23
- "enable": "يُمكَِن",
24
- "disable": "إبطال",
25
- "exclude": "استبعاد",
26
- "include": "يشمل",
27
- "refresh": "ينعش",
32
+ "unpin": "غير مثبت",
28
33
  "update": "تحديث",
29
- "query": "استفسار",
30
- "apply": "يتقدم",
31
- "cancel": "يلغي",
32
- "delete": "يمسح",
33
- "basicFilter": "الفلتر الأساسي",
34
- "customQuery": "استعلام مخصص",
35
- "forAdvanced": "للمستخدمين المتقدمين فقط!"
34
+ "value": "قيمة",
35
+ "view": "منظر",
36
+ "matchAll": "تطابق كل شيء",
37
+ "matchAny": "تطابق أي"
36
38
  },
37
39
  "operator": {
40
+ "ALL": "كل",
41
+ "ANY": "أي من",
42
+ "BETWEEN": "بين هذا وذاك",
43
+ "ENDS": "ينتهي مع",
38
44
  "EXISTS": "موجود",
45
+ "GT": ">",
46
+ "GTE": "≥",
39
47
  "IS": "يكون",
40
- "IN": "في",
48
+ "LIKE": "يحب",
41
49
  "LT": "<",
42
- "GT": ">",
43
50
  "LTE": "≤",
44
- "GTE": "≥",
45
- "INCLUDES": "يشمل",
46
51
  "STARTS": "ابدا ب",
47
- "ENDS": "ينتهي مع",
48
- "WITHIN": "في غضون",
49
- "BETWEEN": "بين هذا وذاك"
52
+ "WITHIN": "في غضون"
50
53
  },
51
54
  "placeholder": "مصطلح البحث...",
52
55
  "type": {
53
- "STRING": "سلسلة",
54
- "NUMBER": "كثافة العمليات",
55
- "DECIMAL": "يطفو",
56
56
  "BOOLEAN": "رقم",
57
57
  "DATE": "منطقي",
58
58
  "DATETIME": "تاريخ",
59
- "GEO": "GeoJSON"
59
+ "DECIMAL": "يطفو",
60
+ "GEO": "GeoJSON",
61
+ "NUMBER": "كثافة العمليات",
62
+ "STRING": "سلسلة"
60
63
  },
61
64
  "validate": {
65
+ "compare": "مقارنة الحقل المطلوب",
62
66
  "field": "حقل مطلوب",
67
+ "label": "التصنيف مطلوب",
63
68
  "operator": "عامل مطلوب",
64
- "value": "القيمة المطلوبة",
65
- "compare": "مقارنة الحقل المطلوب",
66
- "label": "التصنيف مطلوب"
69
+ "value": "القيمة المطلوبة"
67
70
  }
68
71
  }