@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.
package/src/i18n/en.json CHANGED
@@ -1,69 +1,72 @@
1
1
  {
2
2
  "label": {
3
- "filters": "Filters",
3
+ "add": "Add Filter",
4
4
  "all_filters": "All Filters",
5
+ "apply": "Apply",
6
+ "basicFilter": "Basic Filter",
7
+ "cancel": "Cancel",
8
+ "customQuery": "Custom Query",
9
+ "delete": "Delete",
10
+ "disable": "Disable",
11
+ "disableAll": "Disable All",
12
+ "edit": "Edit",
13
+ "enable": "Enable",
14
+ "enableAll": "Enable All",
15
+ "exclude": "Exclude",
16
+ "excludeAll": "Exclude All",
5
17
  "field": "Field",
6
- "operator": "Operator",
7
- "value": "Value",
18
+ "filters": "Filters",
19
+ "forAdvanced": "For advanced users only!",
20
+ "include": "Include",
21
+ "includeAll": "Include All",
22
+ "invertAll": "Invert Include/Exclude",
8
23
  "label": "Label",
24
+ "matchAll": "Match All",
25
+ "matchAny": "Match Any",
26
+ "operator": "Operator",
9
27
  "optional": "Optional",
10
- "add": "Add Filter",
11
- "edit": "Edit",
12
- "view": "View",
13
28
  "pin": "Pinned",
14
- "unpin": "Unpinned",
15
- "includeAll": "Include All",
16
- "excludeAll": "Exclude All",
17
- "invertAll": "Invert Include/Exclude",
29
+ "query": "Query",
30
+ "refresh": "Refresh",
31
+ "remove": "Remove",
18
32
  "removeAll": "Remove All",
19
- "enableAll": "Enable All",
20
- "disableAll": "Disable All",
21
33
  "toggleDisable": "Invert Disable/Enable",
22
- "remove": "Remove",
23
- "enable": "Enable",
24
- "disable": "Disable",
25
- "exclude": "Exclude",
26
- "include": "Include",
27
- "refresh": "Refresh",
34
+ "unpin": "Unpinned",
28
35
  "update": "Update",
29
- "query": "Query",
30
- "apply": "Apply",
31
- "cancel": "Cancel",
32
- "delete": "Delete",
33
- "basicFilter": "Basic Filter",
34
- "customQuery": "Custom Query",
35
- "forAdvanced": "For advanced users only!"
36
+ "value": "Value",
37
+ "view": "View"
36
38
  },
37
39
  "operator": {
40
+ "ALL": "All of",
41
+ "ANY": "Any of",
42
+ "BETWEEN": "Between",
43
+ "ENDS": "Ends with",
44
+ "EQ": "=",
38
45
  "EXISTS": "Exists",
46
+ "GT": ">",
47
+ "GTE": "≥",
39
48
  "IS": "Is",
40
- "IN": "In",
41
- "EQ": "=",
49
+ "LIKE": "Like",
42
50
  "LT": "<",
43
- "GT": ">",
44
51
  "LTE": "≤",
45
- "GTE": "≥",
46
- "INCLUDES": "Includes",
47
52
  "STARTS": "Starts with",
48
- "ENDS": "Ends with",
49
- "WITHIN": "Within",
50
- "BETWEEN": "Between"
53
+ "WITHIN": "Within"
51
54
  },
52
55
  "placeholder": "Search term...",
53
56
  "type": {
54
- "STRING": "String",
55
- "NUMBER": "Number",
56
- "DECIMAL": "Decimal",
57
57
  "BOOLEAN": "Bool",
58
58
  "DATE": "Date",
59
59
  "DATETIME": "Date Time",
60
- "GEO": "GeoJSON"
60
+ "DECIMAL": "Decimal",
61
+ "GEO": "GeoJSON",
62
+ "NUMBER": "Number",
63
+ "STRING": "String"
61
64
  },
62
65
  "validate": {
66
+ "compare": "Compare field required",
63
67
  "field": "Field required",
68
+ "label": "Label required",
64
69
  "operator": "Operator required",
65
- "value": "Value required",
66
- "compare": "Compare field required",
67
- "label": "Label required"
70
+ "value": "Value required"
68
71
  }
69
72
  }
@@ -45,6 +45,40 @@ type SearchActions =
45
45
  | { type: "query"; query: string | string[] }
46
46
  | { type: "filter"; filters: FilterObject[] };
47
47
 
48
+ /**
49
+ * This component provides a search input with autocomplete functionality,
50
+ * a button to trigger search, and an optional filter bar.
51
+ * It supports history of search queries, multiple selection, and custom decorations.
52
+ * It can be collapsed to hide filters and has options for customization.
53
+ *
54
+ * @param {SearchBarProps} props - The properties for the SearchBar component.
55
+ * @returns {JSX.Element} The rendered SearchBar component.
56
+ *
57
+ * @example
58
+ * ```jsx
59
+ * <SearchBar
60
+ * historyKey="myApp:searchHistory"
61
+ * historyCount={10}
62
+ * defaultQueryList={["example", "test"]}
63
+ * prepend={<span>Prepend</span>}
64
+ * append={<span>Append</span>}
65
+ * decorateEnd={<span>End Decoration</span>}
66
+ * decorateStart={<span>Start Decoration</span>}
67
+ * hideFilters={false}
68
+ * defaultCollapsed={false}
69
+ * disabled={false}
70
+ * onCollapsed={(collapsed) => console.log("Collapsed:", collapsed)}
71
+ * onQuery={(query) => console.log("Query:", query)}
72
+ * onSearch={({ query, filters }) => console.log("Search:", query, filters)}
73
+ * query={""}
74
+ * ref={searchInputRef}
75
+ * multiple={false}
76
+ * filters={[{ name: "filter1", value: "value1" }]}
77
+ * />
78
+ * ```
79
+ *
80
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/searchbar-searchbar--search-bar} for more details on the properties.
81
+ */
48
82
  export const SearchBar = ({
49
83
  historyKey = "ruf:search",
50
84
  historyCount = 20,
@@ -43,13 +43,14 @@ export enum FIELD_TYPE {
43
43
  export enum OPERATOR {
44
44
  EXISTS = "EXISTS",
45
45
  IS = "IS",
46
- IN = "IN",
46
+ ALL = "ALL",
47
+ ANY = "ANY",
47
48
  EQ = "EQ",
48
49
  LT = "LT",
49
50
  GT = "GT",
50
51
  LTE = "LTE",
51
52
  GTE = "GTE",
52
- INCLUDES = "INCLUDES",
53
+ LIKE = "LIKE",
53
54
  STARTS = "STARTS",
54
55
  ENDS = "ENDS",
55
56
  WITHIN = "WITHIN",
@@ -60,11 +61,16 @@ export enum OPERATOR {
60
61
  * @internal
61
62
  */
62
63
  export const TypeOperators: { [key in FIELD_TYPE]: OPERATOR[] } = {
63
- [FIELD_TYPE.ID]: [OPERATOR.IS, OPERATOR.IN],
64
- [FIELD_TYPE.STRING]: [OPERATOR.EXISTS, OPERATOR.IS, OPERATOR.IN],
64
+ [FIELD_TYPE.ID]: [OPERATOR.IS, OPERATOR.ANY],
65
+ [FIELD_TYPE.STRING]: [
66
+ OPERATOR.EXISTS,
67
+ OPERATOR.IS,
68
+ OPERATOR.ANY,
69
+ OPERATOR.ALL,
70
+ ],
65
71
  [FIELD_TYPE.TEXT]: [
66
72
  OPERATOR.EXISTS,
67
- OPERATOR.INCLUDES,
73
+ OPERATOR.LIKE,
68
74
  OPERATOR.STARTS,
69
75
  OPERATOR.ENDS,
70
76
  ],
@@ -120,12 +126,13 @@ export const OperatorValueType: {
120
126
  } = {
121
127
  [OPERATOR.EXISTS]: 0,
122
128
  [OPERATOR.IS]: 0,
123
- [OPERATOR.IN]: 1,
129
+ [OPERATOR.ANY]: 1,
130
+ [OPERATOR.ALL]: 1,
124
131
  [OPERATOR.BETWEEN]: 2,
125
132
  [OPERATOR.WITHIN]: 0,
126
133
  [OPERATOR.STARTS]: 0,
127
134
  [OPERATOR.ENDS]: 0,
128
- [OPERATOR.INCLUDES]: 0,
135
+ [OPERATOR.LIKE]: 0,
129
136
  [OPERATOR.EQ]: 0,
130
137
  [OPERATOR.LT]: 0,
131
138
  [OPERATOR.GT]: 0,