@react-fabric/searchbar 1.0.0-beta.8 → 1.0.0-beta.9
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.
|
@@ -15,6 +15,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
15
15
|
var FilterSchema = new utilities.yup.ObjectSchema({
|
|
16
16
|
id: utilities.yup.string().required(),
|
|
17
17
|
field: utilities.yup.string().required(),
|
|
18
|
+
type: utilities.yup.string().required().oneOf(Object.values(index.FIELD_TYPE)),
|
|
18
19
|
operator: utilities.yup.string().required().oneOf(Object.values(index.OPERATOR)),
|
|
19
20
|
negate: utilities.yup["boolean"](),
|
|
20
21
|
label: utilities.yup.string(),
|
|
@@ -62,6 +63,7 @@ var FilterForm = function FilterForm(_ref) {
|
|
|
62
63
|
(_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setValues({
|
|
63
64
|
id: utilities.shortHash(),
|
|
64
65
|
field: "",
|
|
66
|
+
type: index.FIELD_TYPE.NONE,
|
|
65
67
|
operator: index.OPERATOR.EXISTS
|
|
66
68
|
});
|
|
67
69
|
}, [filter]);
|
|
@@ -185,6 +187,7 @@ var FilterForm = function FilterForm(_ref) {
|
|
|
185
187
|
var filter = {
|
|
186
188
|
id: model.id,
|
|
187
189
|
field: model.field,
|
|
190
|
+
type: model.type,
|
|
188
191
|
negate: model.negate,
|
|
189
192
|
operator: model.operator,
|
|
190
193
|
value: model.value,
|
|
@@ -213,7 +216,11 @@ var FilterForm = function FilterForm(_ref) {
|
|
|
213
216
|
options: fields,
|
|
214
217
|
labelProperty: "label",
|
|
215
218
|
valueProperty: "field",
|
|
216
|
-
groupProperty: "type"
|
|
219
|
+
groupProperty: "type",
|
|
220
|
+
onSelect: function onSelect(field) {
|
|
221
|
+
var _formRef$current10;
|
|
222
|
+
return (_formRef$current10 = formRef.current) === null || _formRef$current10 === void 0 ? void 0 : _formRef$current10.setValue("type", field.type);
|
|
223
|
+
}
|
|
217
224
|
})
|
|
218
225
|
})
|
|
219
226
|
}), /*#__PURE__*/jsxRuntime.jsxs(core.Col, {
|
|
@@ -8,13 +8,14 @@ import { Field, Controller, Switch, Select, Input, Number, Form } from '@react-f
|
|
|
8
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
|
-
import { OPERATOR, TypeOperators
|
|
11
|
+
import { FIELD_TYPE, OPERATOR, TypeOperators } from '../types/index.js';
|
|
12
12
|
import { useFilterContext } from './Context.js';
|
|
13
13
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
14
14
|
|
|
15
15
|
var FilterSchema = new yup.ObjectSchema({
|
|
16
16
|
id: yup.string().required(),
|
|
17
17
|
field: yup.string().required(),
|
|
18
|
+
type: yup.string().required().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(),
|
|
@@ -62,6 +63,7 @@ var FilterForm = function FilterForm(_ref) {
|
|
|
62
63
|
(_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setValues({
|
|
63
64
|
id: shortHash(),
|
|
64
65
|
field: "",
|
|
66
|
+
type: FIELD_TYPE.NONE,
|
|
65
67
|
operator: OPERATOR.EXISTS
|
|
66
68
|
});
|
|
67
69
|
}, [filter]);
|
|
@@ -185,6 +187,7 @@ var FilterForm = function FilterForm(_ref) {
|
|
|
185
187
|
var filter = {
|
|
186
188
|
id: model.id,
|
|
187
189
|
field: model.field,
|
|
190
|
+
type: model.type,
|
|
188
191
|
negate: model.negate,
|
|
189
192
|
operator: model.operator,
|
|
190
193
|
value: model.value,
|
|
@@ -213,7 +216,11 @@ var FilterForm = function FilterForm(_ref) {
|
|
|
213
216
|
options: fields,
|
|
214
217
|
labelProperty: "label",
|
|
215
218
|
valueProperty: "field",
|
|
216
|
-
groupProperty: "type"
|
|
219
|
+
groupProperty: "type",
|
|
220
|
+
onSelect: function onSelect(field) {
|
|
221
|
+
var _formRef$current10;
|
|
222
|
+
return (_formRef$current10 = formRef.current) === null || _formRef$current10 === void 0 ? void 0 : _formRef$current10.setValue("type", field.type);
|
|
223
|
+
}
|
|
217
224
|
})
|
|
218
225
|
})
|
|
219
226
|
}), /*#__PURE__*/jsxs(Col, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/searchbar",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.9",
|
|
4
4
|
"description": "RUF: Searchbar with filters package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@floating-ui/react": "0.26.24",
|
|
37
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
38
|
-
"@react-fabric/date": "^1.0.0-beta.
|
|
39
|
-
"@react-fabric/form": "^1.0.0-beta.
|
|
40
|
-
"@react-fabric/monaco": "^1.0.0-beta.
|
|
41
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
37
|
+
"@react-fabric/core": "^1.0.0-beta.9",
|
|
38
|
+
"@react-fabric/date": "^1.0.0-beta.9",
|
|
39
|
+
"@react-fabric/form": "^1.0.0-beta.9",
|
|
40
|
+
"@react-fabric/monaco": "^1.0.0-beta.9",
|
|
41
|
+
"@react-fabric/utilities": "^1.0.0-beta.9",
|
|
42
42
|
"classnames": "^2.5.1",
|
|
43
43
|
"react-hook-form": "^7.52.1"
|
|
44
44
|
},
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"node": ">=18.12.0",
|
|
53
53
|
"npm": ">=8.19.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "3dde23444bcebf68c30198af5c2fef55572da38f"
|
|
56
56
|
}
|
|
@@ -48,6 +48,7 @@ import { useFilterContext } from "./Context";
|
|
|
48
48
|
const FilterSchema = new yup.ObjectSchema({
|
|
49
49
|
id: yup.string().required(),
|
|
50
50
|
field: yup.string().required(),
|
|
51
|
+
type: yup.string().required().oneOf(Object.values(FIELD_TYPE)),
|
|
51
52
|
operator: yup.string().required().oneOf(Object.values(OPERATOR)),
|
|
52
53
|
negate: yup.boolean(),
|
|
53
54
|
label: yup.string(),
|
|
@@ -93,6 +94,7 @@ export const FilterForm = ({
|
|
|
93
94
|
formRef.current?.setValues({
|
|
94
95
|
id: shortHash(),
|
|
95
96
|
field: "",
|
|
97
|
+
type: FIELD_TYPE.NONE,
|
|
96
98
|
operator: OPERATOR.EXISTS,
|
|
97
99
|
});
|
|
98
100
|
}, [filter]);
|
|
@@ -209,6 +211,7 @@ export const FilterForm = ({
|
|
|
209
211
|
const filter: FilterObject = {
|
|
210
212
|
id: model.id,
|
|
211
213
|
field: model.field,
|
|
214
|
+
type: model.type,
|
|
212
215
|
negate: model.negate,
|
|
213
216
|
operator: model.operator,
|
|
214
217
|
value: model.value as AnyObject,
|
|
@@ -240,6 +243,9 @@ export const FilterForm = ({
|
|
|
240
243
|
labelProperty="label"
|
|
241
244
|
valueProperty="field"
|
|
242
245
|
groupProperty="type"
|
|
246
|
+
onSelect={(field) =>
|
|
247
|
+
formRef.current?.setValue("type", field.type)
|
|
248
|
+
}
|
|
243
249
|
/>
|
|
244
250
|
</Controller>
|
|
245
251
|
</Col>
|