@kopexa/filter 0.0.54 → 0.0.55
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/dist/chunk-HACVUP5P.mjs +52 -0
- package/dist/{chunk-E5CPSJZD.mjs → chunk-QRWKEHAH.mjs} +5 -2
- package/dist/{chunk-PUBY2ZP3.mjs → chunk-TCLE7EEK.mjs} +1 -1
- package/dist/{chunk-KCA4SBT7.mjs → chunk-VII35ERE.mjs} +5 -2
- package/dist/filter-bar-internal.mjs +2 -2
- package/dist/filter-bar-types.d.mts +11 -1
- package/dist/filter-bar-types.d.ts +11 -1
- package/dist/filter-bar-types.js +24 -2
- package/dist/filter-bar-types.mjs +7 -3
- package/dist/filter-bar.d.mts +1 -2
- package/dist/filter-bar.d.ts +1 -2
- package/dist/filter-bar.js +19 -1
- package/dist/filter-bar.mjs +3 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -2
- package/dist/index.mjs +9 -4
- package/dist/search-filter-bar.js +19 -1
- package/dist/search-filter-bar.mjs +3 -3
- package/package.json +19 -19
- package/dist/chunk-ON2UFJ3Y.mjs +0 -32
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/filter-bar-types.ts
|
|
4
|
+
var DEFAULT_FILTER_BAR_OPERATORS = {
|
|
5
|
+
select: ["equals", "not_equals", "is_empty", "is_not_empty"],
|
|
6
|
+
multiselect: ["equals", "not_equals", "is_empty", "is_not_empty"],
|
|
7
|
+
text: [
|
|
8
|
+
"equals",
|
|
9
|
+
"not_equals",
|
|
10
|
+
"contains",
|
|
11
|
+
"not_contains",
|
|
12
|
+
"starts_with",
|
|
13
|
+
"ends_with",
|
|
14
|
+
"is_empty",
|
|
15
|
+
"is_not_empty"
|
|
16
|
+
],
|
|
17
|
+
number: [
|
|
18
|
+
"equals",
|
|
19
|
+
"not_equals",
|
|
20
|
+
"gt",
|
|
21
|
+
"lt",
|
|
22
|
+
"gte",
|
|
23
|
+
"lte",
|
|
24
|
+
"is_empty",
|
|
25
|
+
"is_not_empty"
|
|
26
|
+
],
|
|
27
|
+
custom: ["equals", "not_equals"]
|
|
28
|
+
};
|
|
29
|
+
function isBooleanSelectField(field) {
|
|
30
|
+
if (field.type !== "select" || !field.options) return false;
|
|
31
|
+
if (field.options.length !== 2) return false;
|
|
32
|
+
const values = field.options.map((o) => o.value).sort();
|
|
33
|
+
return values[0] === "false" && values[1] === "true";
|
|
34
|
+
}
|
|
35
|
+
function getFilterDefaultValue(field) {
|
|
36
|
+
if (field.defaultValue !== void 0) {
|
|
37
|
+
return field.defaultValue;
|
|
38
|
+
}
|
|
39
|
+
if (field.type === "multiselect") {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
if (isBooleanSelectField(field)) {
|
|
43
|
+
return "true";
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
DEFAULT_FILTER_BAR_OPERATORS,
|
|
50
|
+
isBooleanSelectField,
|
|
51
|
+
getFilterDefaultValue
|
|
52
|
+
};
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
AddFilterDropdown,
|
|
4
4
|
FilterPill
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TCLE7EEK.mjs";
|
|
6
6
|
import {
|
|
7
7
|
filterBarMessages
|
|
8
8
|
} from "./chunk-I7WCYMXD.mjs";
|
|
9
|
+
import {
|
|
10
|
+
getFilterDefaultValue
|
|
11
|
+
} from "./chunk-HACVUP5P.mjs";
|
|
9
12
|
|
|
10
13
|
// src/search-filter-bar.tsx
|
|
11
14
|
import { useSafeIntl } from "@kopexa/i18n";
|
|
@@ -104,7 +107,7 @@ function SearchFilterBar(props) {
|
|
|
104
107
|
id: `${instanceId}-${fieldId}-${Date.now()}`,
|
|
105
108
|
fieldId,
|
|
106
109
|
operator: (_a = field.defaultOperator) != null ? _a : "equals",
|
|
107
|
-
value: field
|
|
110
|
+
value: getFilterDefaultValue(field)
|
|
108
111
|
};
|
|
109
112
|
setFilters([...filters, newFilter]);
|
|
110
113
|
setSessionFilterId(newFilter.id);
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
AddFilterDropdown,
|
|
4
4
|
FilterPill
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TCLE7EEK.mjs";
|
|
6
6
|
import {
|
|
7
7
|
filterBarMessages
|
|
8
8
|
} from "./chunk-I7WCYMXD.mjs";
|
|
9
|
+
import {
|
|
10
|
+
getFilterDefaultValue
|
|
11
|
+
} from "./chunk-HACVUP5P.mjs";
|
|
9
12
|
|
|
10
13
|
// src/filter-bar.tsx
|
|
11
14
|
import { useSafeIntl } from "@kopexa/i18n";
|
|
@@ -88,7 +91,7 @@ function FilterBar(props) {
|
|
|
88
91
|
id: `${instanceId}-${fieldId}-${Date.now()}`,
|
|
89
92
|
fieldId,
|
|
90
93
|
operator: (_a = field.defaultOperator) != null ? _a : "equals",
|
|
91
|
-
value: field
|
|
94
|
+
value: getFilterDefaultValue(field)
|
|
92
95
|
};
|
|
93
96
|
setValue([...value, newFilter]);
|
|
94
97
|
setSessionFilterId(newFilter.id);
|
|
@@ -46,6 +46,8 @@ interface FilterBarFieldConfig {
|
|
|
46
46
|
operators?: FilterBarOperator[];
|
|
47
47
|
/** Default operator */
|
|
48
48
|
defaultOperator?: FilterBarOperator;
|
|
49
|
+
/** Default value when filter is added. For boolean selects (true/false options), defaults to "true" automatically. */
|
|
50
|
+
defaultValue?: FilterBarInputValue;
|
|
49
51
|
/** Placeholder text */
|
|
50
52
|
placeholder?: string;
|
|
51
53
|
/** Whether the field is disabled */
|
|
@@ -92,6 +94,14 @@ interface FilterBarValue {
|
|
|
92
94
|
* Default operators by field type
|
|
93
95
|
*/
|
|
94
96
|
declare const DEFAULT_FILTER_BAR_OPERATORS: Record<FilterBarFieldType, FilterBarOperator[]>;
|
|
97
|
+
/**
|
|
98
|
+
* Check if a field is a boolean select (has exactly "true" and "false" options)
|
|
99
|
+
*/
|
|
100
|
+
declare function isBooleanSelectField(field: FilterBarFieldConfig): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Get the default value for a filter field when it is added
|
|
103
|
+
*/
|
|
104
|
+
declare function getFilterDefaultValue(field: FilterBarFieldConfig): FilterBarInputValue;
|
|
95
105
|
/**
|
|
96
106
|
* I18n configuration for FilterBar
|
|
97
107
|
*/
|
|
@@ -109,4 +119,4 @@ interface FilterBarI18nConfig {
|
|
|
109
119
|
};
|
|
110
120
|
}
|
|
111
121
|
|
|
112
|
-
export { DEFAULT_FILTER_BAR_OPERATORS, type FilterBarCustomRendererProps, type FilterBarFieldConfig, type FilterBarFieldType, type FilterBarI18nConfig, type FilterBarInputValue, type FilterBarOperator, type FilterBarOption, type FilterBarValidation, type FilterBarValue };
|
|
122
|
+
export { DEFAULT_FILTER_BAR_OPERATORS, type FilterBarCustomRendererProps, type FilterBarFieldConfig, type FilterBarFieldType, type FilterBarI18nConfig, type FilterBarInputValue, type FilterBarOperator, type FilterBarOption, type FilterBarValidation, type FilterBarValue, getFilterDefaultValue, isBooleanSelectField };
|
|
@@ -46,6 +46,8 @@ interface FilterBarFieldConfig {
|
|
|
46
46
|
operators?: FilterBarOperator[];
|
|
47
47
|
/** Default operator */
|
|
48
48
|
defaultOperator?: FilterBarOperator;
|
|
49
|
+
/** Default value when filter is added. For boolean selects (true/false options), defaults to "true" automatically. */
|
|
50
|
+
defaultValue?: FilterBarInputValue;
|
|
49
51
|
/** Placeholder text */
|
|
50
52
|
placeholder?: string;
|
|
51
53
|
/** Whether the field is disabled */
|
|
@@ -92,6 +94,14 @@ interface FilterBarValue {
|
|
|
92
94
|
* Default operators by field type
|
|
93
95
|
*/
|
|
94
96
|
declare const DEFAULT_FILTER_BAR_OPERATORS: Record<FilterBarFieldType, FilterBarOperator[]>;
|
|
97
|
+
/**
|
|
98
|
+
* Check if a field is a boolean select (has exactly "true" and "false" options)
|
|
99
|
+
*/
|
|
100
|
+
declare function isBooleanSelectField(field: FilterBarFieldConfig): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Get the default value for a filter field when it is added
|
|
103
|
+
*/
|
|
104
|
+
declare function getFilterDefaultValue(field: FilterBarFieldConfig): FilterBarInputValue;
|
|
95
105
|
/**
|
|
96
106
|
* I18n configuration for FilterBar
|
|
97
107
|
*/
|
|
@@ -109,4 +119,4 @@ interface FilterBarI18nConfig {
|
|
|
109
119
|
};
|
|
110
120
|
}
|
|
111
121
|
|
|
112
|
-
export { DEFAULT_FILTER_BAR_OPERATORS, type FilterBarCustomRendererProps, type FilterBarFieldConfig, type FilterBarFieldType, type FilterBarI18nConfig, type FilterBarInputValue, type FilterBarOperator, type FilterBarOption, type FilterBarValidation, type FilterBarValue };
|
|
122
|
+
export { DEFAULT_FILTER_BAR_OPERATORS, type FilterBarCustomRendererProps, type FilterBarFieldConfig, type FilterBarFieldType, type FilterBarI18nConfig, type FilterBarInputValue, type FilterBarOperator, type FilterBarOption, type FilterBarValidation, type FilterBarValue, getFilterDefaultValue, isBooleanSelectField };
|
package/dist/filter-bar-types.js
CHANGED
|
@@ -22,7 +22,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
// src/filter-bar-types.ts
|
|
23
23
|
var filter_bar_types_exports = {};
|
|
24
24
|
__export(filter_bar_types_exports, {
|
|
25
|
-
DEFAULT_FILTER_BAR_OPERATORS: () => DEFAULT_FILTER_BAR_OPERATORS
|
|
25
|
+
DEFAULT_FILTER_BAR_OPERATORS: () => DEFAULT_FILTER_BAR_OPERATORS,
|
|
26
|
+
getFilterDefaultValue: () => getFilterDefaultValue,
|
|
27
|
+
isBooleanSelectField: () => isBooleanSelectField
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(filter_bar_types_exports);
|
|
28
30
|
var DEFAULT_FILTER_BAR_OPERATORS = {
|
|
@@ -50,7 +52,27 @@ var DEFAULT_FILTER_BAR_OPERATORS = {
|
|
|
50
52
|
],
|
|
51
53
|
custom: ["equals", "not_equals"]
|
|
52
54
|
};
|
|
55
|
+
function isBooleanSelectField(field) {
|
|
56
|
+
if (field.type !== "select" || !field.options) return false;
|
|
57
|
+
if (field.options.length !== 2) return false;
|
|
58
|
+
const values = field.options.map((o) => o.value).sort();
|
|
59
|
+
return values[0] === "false" && values[1] === "true";
|
|
60
|
+
}
|
|
61
|
+
function getFilterDefaultValue(field) {
|
|
62
|
+
if (field.defaultValue !== void 0) {
|
|
63
|
+
return field.defaultValue;
|
|
64
|
+
}
|
|
65
|
+
if (field.type === "multiselect") {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
if (isBooleanSelectField(field)) {
|
|
69
|
+
return "true";
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
53
73
|
// Annotate the CommonJS export names for ESM import in node:
|
|
54
74
|
0 && (module.exports = {
|
|
55
|
-
DEFAULT_FILTER_BAR_OPERATORS
|
|
75
|
+
DEFAULT_FILTER_BAR_OPERATORS,
|
|
76
|
+
getFilterDefaultValue,
|
|
77
|
+
isBooleanSelectField
|
|
56
78
|
});
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
3
|
import {
|
|
4
|
-
DEFAULT_FILTER_BAR_OPERATORS
|
|
5
|
-
|
|
4
|
+
DEFAULT_FILTER_BAR_OPERATORS,
|
|
5
|
+
getFilterDefaultValue,
|
|
6
|
+
isBooleanSelectField
|
|
7
|
+
} from "./chunk-HACVUP5P.mjs";
|
|
6
8
|
export {
|
|
7
|
-
DEFAULT_FILTER_BAR_OPERATORS
|
|
9
|
+
DEFAULT_FILTER_BAR_OPERATORS,
|
|
10
|
+
getFilterDefaultValue,
|
|
11
|
+
isBooleanSelectField
|
|
8
12
|
};
|
package/dist/filter-bar.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { FilterBarFieldConfig, FilterBarValue, FilterBarI18nConfig } from './filter-bar-types.mjs';
|
|
3
|
-
export { FilterBarCustomRendererProps, FilterBarFieldType, FilterBarInputValue, FilterBarOperator, FilterBarOption, FilterBarValidation } from './filter-bar-types.mjs';
|
|
4
3
|
import 'react';
|
|
5
4
|
|
|
6
5
|
interface FilterBarProps {
|
|
@@ -26,4 +25,4 @@ declare namespace FilterBar {
|
|
|
26
25
|
var displayName: string;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
export { FilterBar,
|
|
28
|
+
export { FilterBar, type FilterBarProps };
|
package/dist/filter-bar.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { FilterBarFieldConfig, FilterBarValue, FilterBarI18nConfig } from './filter-bar-types.js';
|
|
3
|
-
export { FilterBarCustomRendererProps, FilterBarFieldType, FilterBarInputValue, FilterBarOperator, FilterBarOption, FilterBarValidation } from './filter-bar-types.js';
|
|
4
3
|
import 'react';
|
|
5
4
|
|
|
6
5
|
interface FilterBarProps {
|
|
@@ -26,4 +25,4 @@ declare namespace FilterBar {
|
|
|
26
25
|
var displayName: string;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
export { FilterBar,
|
|
28
|
+
export { FilterBar, type FilterBarProps };
|
package/dist/filter-bar.js
CHANGED
|
@@ -67,6 +67,24 @@ var DEFAULT_FILTER_BAR_OPERATORS = {
|
|
|
67
67
|
],
|
|
68
68
|
custom: ["equals", "not_equals"]
|
|
69
69
|
};
|
|
70
|
+
function isBooleanSelectField(field) {
|
|
71
|
+
if (field.type !== "select" || !field.options) return false;
|
|
72
|
+
if (field.options.length !== 2) return false;
|
|
73
|
+
const values = field.options.map((o) => o.value).sort();
|
|
74
|
+
return values[0] === "false" && values[1] === "true";
|
|
75
|
+
}
|
|
76
|
+
function getFilterDefaultValue(field) {
|
|
77
|
+
if (field.defaultValue !== void 0) {
|
|
78
|
+
return field.defaultValue;
|
|
79
|
+
}
|
|
80
|
+
if (field.type === "multiselect") {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
if (isBooleanSelectField(field)) {
|
|
84
|
+
return "true";
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
70
88
|
|
|
71
89
|
// src/filter-bar-internal.tsx
|
|
72
90
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -852,7 +870,7 @@ function FilterBar(props) {
|
|
|
852
870
|
id: `${instanceId}-${fieldId}-${Date.now()}`,
|
|
853
871
|
fieldId,
|
|
854
872
|
operator: (_a = field.defaultOperator) != null ? _a : "equals",
|
|
855
|
-
value: field
|
|
873
|
+
value: getFilterDefaultValue(field)
|
|
856
874
|
};
|
|
857
875
|
setValue([...value, newFilter]);
|
|
858
876
|
setSessionFilterId(newFilter.id);
|
package/dist/filter-bar.mjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import {
|
|
4
4
|
FilterBar
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-VII35ERE.mjs";
|
|
6
|
+
import "./chunk-TCLE7EEK.mjs";
|
|
7
7
|
import "./chunk-I7WCYMXD.mjs";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-HACVUP5P.mjs";
|
|
9
9
|
export {
|
|
10
10
|
FilterBar
|
|
11
11
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -6,10 +6,10 @@ export { FilterTrigger, FilterTriggerProps } from './filter-trigger.mjs';
|
|
|
6
6
|
export { FilterEditorRenderProps, FilterFieldConfig, FilterFieldType, FilterOperator, FilterOption, FilterValue, FilterValueRenderProps } from './filter-types.mjs';
|
|
7
7
|
export { FilterValueEditor } from './filter-value-editor.mjs';
|
|
8
8
|
export { FilterBar, FilterBarProps } from './filter-bar.mjs';
|
|
9
|
+
export { FilterBarCustomRendererProps, FilterBarFieldConfig, FilterBarFieldType, FilterBarI18nConfig, FilterBarInputValue, FilterBarOperator, FilterBarOption, FilterBarValidation, FilterBarValue, getFilterDefaultValue, isBooleanSelectField } from './filter-bar-types.mjs';
|
|
9
10
|
export { SearchFilterBar, SearchFilterBarProps } from './search-filter-bar.mjs';
|
|
10
11
|
export { filterBarMessages } from './filter-bar-messages.mjs';
|
|
11
12
|
export { messages as filterMessages } from './messages.mjs';
|
|
12
|
-
export { FilterBarCustomRendererProps, FilterBarFieldConfig, FilterBarFieldType, FilterBarI18nConfig, FilterBarInputValue, FilterBarOperator, FilterBarOption, FilterBarValidation, FilterBarValue } from './filter-bar-types.mjs';
|
|
13
13
|
import 'react/jsx-runtime';
|
|
14
14
|
import '@kopexa/theme';
|
|
15
15
|
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ export { FilterTrigger, FilterTriggerProps } from './filter-trigger.js';
|
|
|
6
6
|
export { FilterEditorRenderProps, FilterFieldConfig, FilterFieldType, FilterOperator, FilterOption, FilterValue, FilterValueRenderProps } from './filter-types.js';
|
|
7
7
|
export { FilterValueEditor } from './filter-value-editor.js';
|
|
8
8
|
export { FilterBar, FilterBarProps } from './filter-bar.js';
|
|
9
|
+
export { FilterBarCustomRendererProps, FilterBarFieldConfig, FilterBarFieldType, FilterBarI18nConfig, FilterBarInputValue, FilterBarOperator, FilterBarOption, FilterBarValidation, FilterBarValue, getFilterDefaultValue, isBooleanSelectField } from './filter-bar-types.js';
|
|
9
10
|
export { SearchFilterBar, SearchFilterBarProps } from './search-filter-bar.js';
|
|
10
11
|
export { filterBarMessages } from './filter-bar-messages.js';
|
|
11
12
|
export { messages as filterMessages } from './messages.js';
|
|
12
|
-
export { FilterBarCustomRendererProps, FilterBarFieldConfig, FilterBarFieldType, FilterBarI18nConfig, FilterBarInputValue, FilterBarOperator, FilterBarOption, FilterBarValidation, FilterBarValue } from './filter-bar-types.js';
|
|
13
13
|
import 'react/jsx-runtime';
|
|
14
14
|
import '@kopexa/theme';
|
|
15
15
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,8 @@ __export(index_exports, {
|
|
|
43
43
|
SearchFilterBar: () => SearchFilterBar,
|
|
44
44
|
filterBarMessages: () => filterBarMessages,
|
|
45
45
|
filterMessages: () => messages,
|
|
46
|
+
getFilterDefaultValue: () => getFilterDefaultValue,
|
|
47
|
+
isBooleanSelectField: () => isBooleanSelectField,
|
|
46
48
|
useFilterContext: () => useFilterContext
|
|
47
49
|
});
|
|
48
50
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -1177,6 +1179,24 @@ var DEFAULT_FILTER_BAR_OPERATORS = {
|
|
|
1177
1179
|
],
|
|
1178
1180
|
custom: ["equals", "not_equals"]
|
|
1179
1181
|
};
|
|
1182
|
+
function isBooleanSelectField(field) {
|
|
1183
|
+
if (field.type !== "select" || !field.options) return false;
|
|
1184
|
+
if (field.options.length !== 2) return false;
|
|
1185
|
+
const values = field.options.map((o) => o.value).sort();
|
|
1186
|
+
return values[0] === "false" && values[1] === "true";
|
|
1187
|
+
}
|
|
1188
|
+
function getFilterDefaultValue(field) {
|
|
1189
|
+
if (field.defaultValue !== void 0) {
|
|
1190
|
+
return field.defaultValue;
|
|
1191
|
+
}
|
|
1192
|
+
if (field.type === "multiselect") {
|
|
1193
|
+
return [];
|
|
1194
|
+
}
|
|
1195
|
+
if (isBooleanSelectField(field)) {
|
|
1196
|
+
return "true";
|
|
1197
|
+
}
|
|
1198
|
+
return null;
|
|
1199
|
+
}
|
|
1180
1200
|
|
|
1181
1201
|
// src/filter-bar-internal.tsx
|
|
1182
1202
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
@@ -1962,7 +1982,7 @@ function FilterBar(props) {
|
|
|
1962
1982
|
id: `${instanceId}-${fieldId}-${Date.now()}`,
|
|
1963
1983
|
fieldId,
|
|
1964
1984
|
operator: (_a = field.defaultOperator) != null ? _a : "equals",
|
|
1965
|
-
value: field
|
|
1985
|
+
value: getFilterDefaultValue(field)
|
|
1966
1986
|
};
|
|
1967
1987
|
setValue([...value, newFilter]);
|
|
1968
1988
|
setSessionFilterId(newFilter.id);
|
|
@@ -2144,7 +2164,7 @@ function SearchFilterBar(props) {
|
|
|
2144
2164
|
id: `${instanceId}-${fieldId}-${Date.now()}`,
|
|
2145
2165
|
fieldId,
|
|
2146
2166
|
operator: (_a = field.defaultOperator) != null ? _a : "equals",
|
|
2147
|
-
value: field
|
|
2167
|
+
value: getFilterDefaultValue(field)
|
|
2148
2168
|
};
|
|
2149
2169
|
setFilters([...filters, newFilter]);
|
|
2150
2170
|
setSessionFilterId(newFilter.id);
|
|
@@ -2291,5 +2311,7 @@ SearchFilterBar.displayName = "SearchFilterBar";
|
|
|
2291
2311
|
SearchFilterBar,
|
|
2292
2312
|
filterBarMessages,
|
|
2293
2313
|
filterMessages,
|
|
2314
|
+
getFilterDefaultValue,
|
|
2315
|
+
isBooleanSelectField,
|
|
2294
2316
|
useFilterContext
|
|
2295
2317
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-LWDVRMCI.mjs";
|
|
8
8
|
import {
|
|
9
9
|
SearchFilterBar
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-QRWKEHAH.mjs";
|
|
11
11
|
import {
|
|
12
12
|
FilterActive
|
|
13
13
|
} from "./chunk-KBVTXOFI.mjs";
|
|
@@ -17,12 +17,15 @@ import {
|
|
|
17
17
|
import "./chunk-PHESMHTT.mjs";
|
|
18
18
|
import {
|
|
19
19
|
FilterBar
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-VII35ERE.mjs";
|
|
21
|
+
import "./chunk-TCLE7EEK.mjs";
|
|
22
22
|
import {
|
|
23
23
|
filterBarMessages
|
|
24
24
|
} from "./chunk-I7WCYMXD.mjs";
|
|
25
|
-
import
|
|
25
|
+
import {
|
|
26
|
+
getFilterDefaultValue,
|
|
27
|
+
isBooleanSelectField
|
|
28
|
+
} from "./chunk-HACVUP5P.mjs";
|
|
26
29
|
import "./chunk-3WNAREG6.mjs";
|
|
27
30
|
import {
|
|
28
31
|
FilterGroup,
|
|
@@ -49,5 +52,7 @@ export {
|
|
|
49
52
|
SearchFilterBar,
|
|
50
53
|
filterBarMessages,
|
|
51
54
|
messages as filterMessages,
|
|
55
|
+
getFilterDefaultValue,
|
|
56
|
+
isBooleanSelectField,
|
|
52
57
|
useFilterContext
|
|
53
58
|
};
|
|
@@ -70,6 +70,24 @@ var DEFAULT_FILTER_BAR_OPERATORS = {
|
|
|
70
70
|
],
|
|
71
71
|
custom: ["equals", "not_equals"]
|
|
72
72
|
};
|
|
73
|
+
function isBooleanSelectField(field) {
|
|
74
|
+
if (field.type !== "select" || !field.options) return false;
|
|
75
|
+
if (field.options.length !== 2) return false;
|
|
76
|
+
const values = field.options.map((o) => o.value).sort();
|
|
77
|
+
return values[0] === "false" && values[1] === "true";
|
|
78
|
+
}
|
|
79
|
+
function getFilterDefaultValue(field) {
|
|
80
|
+
if (field.defaultValue !== void 0) {
|
|
81
|
+
return field.defaultValue;
|
|
82
|
+
}
|
|
83
|
+
if (field.type === "multiselect") {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
if (isBooleanSelectField(field)) {
|
|
87
|
+
return "true";
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
73
91
|
|
|
74
92
|
// src/filter-bar-internal.tsx
|
|
75
93
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -868,7 +886,7 @@ function SearchFilterBar(props) {
|
|
|
868
886
|
id: `${instanceId}-${fieldId}-${Date.now()}`,
|
|
869
887
|
fieldId,
|
|
870
888
|
operator: (_a = field.defaultOperator) != null ? _a : "equals",
|
|
871
|
-
value: field
|
|
889
|
+
value: getFilterDefaultValue(field)
|
|
872
890
|
};
|
|
873
891
|
setFilters([...filters, newFilter]);
|
|
874
892
|
setSessionFilterId(newFilter.id);
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import {
|
|
4
4
|
SearchFilterBar
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-QRWKEHAH.mjs";
|
|
6
|
+
import "./chunk-TCLE7EEK.mjs";
|
|
7
7
|
import "./chunk-I7WCYMXD.mjs";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-HACVUP5P.mjs";
|
|
9
9
|
export {
|
|
10
10
|
SearchFilterBar
|
|
11
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kopexa/filter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.55",
|
|
4
4
|
"description": "A filter component for building complex filtering interfaces",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"filter",
|
|
@@ -30,26 +30,26 @@
|
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": ">=19.0.0-rc.0",
|
|
32
32
|
"react-dom": ">=19.0.0-rc.0",
|
|
33
|
-
"@kopexa/theme": "17.26.
|
|
33
|
+
"@kopexa/theme": "17.26.2"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@kopexa/react-utils": "17.1.
|
|
37
|
-
"@kopexa/use-debounced-callback": "17.0.
|
|
38
|
-
"@kopexa/
|
|
39
|
-
"@kopexa/
|
|
40
|
-
"@kopexa/
|
|
41
|
-
"@kopexa/i18n": "17.11.
|
|
42
|
-
"@kopexa/
|
|
43
|
-
"@kopexa/
|
|
44
|
-
"@kopexa/
|
|
45
|
-
"@kopexa/
|
|
46
|
-
"@kopexa/
|
|
47
|
-
"@kopexa/
|
|
48
|
-
"@kopexa/
|
|
49
|
-
"@kopexa/
|
|
50
|
-
"@kopexa/
|
|
51
|
-
"@kopexa/command": "17.0.
|
|
52
|
-
"@kopexa/spinner": "17.0.
|
|
36
|
+
"@kopexa/react-utils": "17.1.7",
|
|
37
|
+
"@kopexa/use-debounced-callback": "17.0.65",
|
|
38
|
+
"@kopexa/icons": "17.7.30",
|
|
39
|
+
"@kopexa/shared-utils": "17.0.65",
|
|
40
|
+
"@kopexa/use-controllable-state": "17.0.65",
|
|
41
|
+
"@kopexa/i18n": "17.11.1",
|
|
42
|
+
"@kopexa/button": "17.0.65",
|
|
43
|
+
"@kopexa/select": "17.2.30",
|
|
44
|
+
"@kopexa/input": "17.0.65",
|
|
45
|
+
"@kopexa/combobox": "17.3.30",
|
|
46
|
+
"@kopexa/calendar": "17.0.65",
|
|
47
|
+
"@kopexa/dropdown-menu": "17.0.65",
|
|
48
|
+
"@kopexa/checkbox": "17.0.65",
|
|
49
|
+
"@kopexa/popover": "17.2.30",
|
|
50
|
+
"@kopexa/switch": "17.2.30",
|
|
51
|
+
"@kopexa/command": "17.0.65",
|
|
52
|
+
"@kopexa/spinner": "17.0.65"
|
|
53
53
|
},
|
|
54
54
|
"clean-package": "../../../clean-package.config.json",
|
|
55
55
|
"module": "dist/index.mjs",
|
package/dist/chunk-ON2UFJ3Y.mjs
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
// src/filter-bar-types.ts
|
|
4
|
-
var DEFAULT_FILTER_BAR_OPERATORS = {
|
|
5
|
-
select: ["equals", "not_equals", "is_empty", "is_not_empty"],
|
|
6
|
-
multiselect: ["equals", "not_equals", "is_empty", "is_not_empty"],
|
|
7
|
-
text: [
|
|
8
|
-
"equals",
|
|
9
|
-
"not_equals",
|
|
10
|
-
"contains",
|
|
11
|
-
"not_contains",
|
|
12
|
-
"starts_with",
|
|
13
|
-
"ends_with",
|
|
14
|
-
"is_empty",
|
|
15
|
-
"is_not_empty"
|
|
16
|
-
],
|
|
17
|
-
number: [
|
|
18
|
-
"equals",
|
|
19
|
-
"not_equals",
|
|
20
|
-
"gt",
|
|
21
|
-
"lt",
|
|
22
|
-
"gte",
|
|
23
|
-
"lte",
|
|
24
|
-
"is_empty",
|
|
25
|
-
"is_not_empty"
|
|
26
|
-
],
|
|
27
|
-
custom: ["equals", "not_equals"]
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export {
|
|
31
|
-
DEFAULT_FILTER_BAR_OPERATORS
|
|
32
|
-
};
|