@xh/hoist 80.0.0-SNAPSHOT.1769000829579 → 80.0.0-SNAPSHOT.1769042130982
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/CHANGELOG.md +4 -0
- package/build/types/cmp/grid/GridModel.d.ts +1 -1
- package/build/types/cmp/grid/Types.d.ts +7 -3
- package/build/types/cmp/store/StoreFilterField.d.ts +3 -3
- package/build/types/cmp/store/impl/StoreFilterFieldImplModel.d.ts +9 -7
- package/build/types/data/filter/Types.d.ts +7 -0
- package/build/types/desktop/cmp/grid/find/GridFindField.d.ts +3 -2
- package/build/types/desktop/cmp/grid/find/impl/GridFindFieldImplModel.d.ts +5 -3
- package/build/types/desktop/cmp/grid/impl/colchooser/ColChooserModel.d.ts +6 -11
- package/build/types/desktop/cmp/leftrightchooser/LeftRightChooserFilter.d.ts +3 -2
- package/cmp/grid/GridModel.ts +1 -1
- package/cmp/grid/Types.ts +15 -4
- package/cmp/store/StoreFilterField.ts +3 -3
- package/cmp/store/impl/StoreFilterFieldImplModel.ts +32 -26
- package/data/filter/Types.ts +8 -0
- package/desktop/cmp/grid/find/GridFindField.ts +3 -2
- package/desktop/cmp/grid/find/impl/GridFindFieldImplModel.ts +41 -37
- package/desktop/cmp/grid/impl/colchooser/ColChooser.ts +2 -2
- package/desktop/cmp/grid/impl/colchooser/ColChooserModel.ts +9 -5
- package/desktop/cmp/leftrightchooser/LeftRightChooserFilter.ts +26 -11
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -32,14 +32,14 @@ export const colChooser = hoistCmp.factory<ColChooserProps>({
|
|
|
32
32
|
className: 'xh-col-chooser',
|
|
33
33
|
|
|
34
34
|
render({model, className}) {
|
|
35
|
-
const {commitOnChange, showRestoreDefaults, width, height} = model;
|
|
35
|
+
const {commitOnChange, showRestoreDefaults, width, height, filterMatchMode} = model;
|
|
36
36
|
|
|
37
37
|
return panel({
|
|
38
38
|
className,
|
|
39
39
|
items: [
|
|
40
40
|
leftRightChooser({width, height}),
|
|
41
41
|
toolbar(
|
|
42
|
-
leftRightChooserFilter(),
|
|
42
|
+
leftRightChooserFilter({matchMode: filterMatchMode}),
|
|
43
43
|
filler(),
|
|
44
44
|
button({
|
|
45
45
|
omit: !showRestoreDefaults,
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2026 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
-
import {GridModel} from '@xh/hoist/cmp/grid';
|
|
7
|
+
import {ColChooserConfig, GridModel} from '@xh/hoist/cmp/grid';
|
|
8
8
|
import {HoistModel, managed} from '@xh/hoist/core';
|
|
9
|
+
import type {FilterMatchMode} from '@xh/hoist/data';
|
|
9
10
|
import {LeftRightChooserModel} from '@xh/hoist/desktop/cmp/leftrightchooser';
|
|
10
11
|
import {action, makeObservable, observable} from '@xh/hoist/mobx';
|
|
11
12
|
import {sortBy} from 'lodash';
|
|
@@ -29,8 +30,9 @@ export class ColChooserModel extends HoistModel {
|
|
|
29
30
|
commitOnChange: boolean;
|
|
30
31
|
showRestoreDefaults: boolean;
|
|
31
32
|
autosizeOnCommit: boolean;
|
|
32
|
-
width: number;
|
|
33
|
-
height: number;
|
|
33
|
+
width: string | number;
|
|
34
|
+
height: string | number;
|
|
35
|
+
filterMatchMode: FilterMatchMode;
|
|
34
36
|
|
|
35
37
|
constructor({
|
|
36
38
|
gridModel,
|
|
@@ -38,8 +40,9 @@ export class ColChooserModel extends HoistModel {
|
|
|
38
40
|
showRestoreDefaults = true,
|
|
39
41
|
autosizeOnCommit = false,
|
|
40
42
|
width = !commitOnChange && showRestoreDefaults ? 600 : 520,
|
|
41
|
-
height = 300
|
|
42
|
-
|
|
43
|
+
height = 300,
|
|
44
|
+
filterMatchMode = 'startWord'
|
|
45
|
+
}: ColChooserConfig) {
|
|
43
46
|
super();
|
|
44
47
|
makeObservable(this);
|
|
45
48
|
|
|
@@ -49,6 +52,7 @@ export class ColChooserModel extends HoistModel {
|
|
|
49
52
|
this.autosizeOnCommit = autosizeOnCommit;
|
|
50
53
|
this.width = width;
|
|
51
54
|
this.height = height;
|
|
55
|
+
this.filterMatchMode = filterMatchMode;
|
|
52
56
|
|
|
53
57
|
this.lrModel = new LeftRightChooserModel({
|
|
54
58
|
leftTitle: 'Available Columns',
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Copyright © 2026 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
|
-
import {hoistCmp, HoistModel, HoistProps, lookup, useLocalModel, uses} from '@xh/hoist/core';
|
|
7
|
+
import {hoistCmp, HoistModel, HoistProps, lookup, useLocalModel, uses, XH} from '@xh/hoist/core';
|
|
8
|
+
import type {FilterMatchMode} from '@xh/hoist/data';
|
|
8
9
|
import {textInput} from '@xh/hoist/desktop/cmp/input';
|
|
9
10
|
import '@xh/hoist/desktop/register';
|
|
10
11
|
import {Icon} from '@xh/hoist/icon';
|
|
@@ -16,8 +17,8 @@ export interface LeftRightChooserFilterProps extends HoistProps<LeftRightChooser
|
|
|
16
17
|
/** Names of fields in chooser on which to filter. Defaults to ['text', 'group'] */
|
|
17
18
|
fields?: string[];
|
|
18
19
|
|
|
19
|
-
/**
|
|
20
|
-
|
|
20
|
+
/** Mode to use when filtering (default 'startWord'). */
|
|
21
|
+
matchMode?: FilterMatchMode;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -51,34 +52,48 @@ class LeftRightChooserFilterLocalModel extends HoistModel {
|
|
|
51
52
|
@bindable
|
|
52
53
|
value = null;
|
|
53
54
|
|
|
55
|
+
get matchMode(): FilterMatchMode {
|
|
56
|
+
return this.componentProps.matchMode ?? 'startWord';
|
|
57
|
+
}
|
|
58
|
+
|
|
54
59
|
constructor() {
|
|
55
60
|
super();
|
|
56
61
|
makeObservable(this);
|
|
57
62
|
this.addReaction({
|
|
58
|
-
track: () => this.value,
|
|
63
|
+
track: () => [this.value, this.matchMode],
|
|
59
64
|
run: () => this.runFilter()
|
|
60
65
|
});
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
private runFilter() {
|
|
64
|
-
const {fields = ['text', 'group']
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (!anyMatch) {
|
|
68
|
-
searchTerm = `(^|\\W)${searchTerm}`;
|
|
69
|
-
}
|
|
69
|
+
const {fields = ['text', 'group']} = this.componentProps,
|
|
70
|
+
searchTerm = this.value,
|
|
71
|
+
regex = this.getRegex(searchTerm);
|
|
70
72
|
|
|
71
73
|
const filter = raw => {
|
|
72
74
|
return fields.some(f => {
|
|
73
75
|
if (!searchTerm) return true;
|
|
74
76
|
const fieldVal = raw.data[f];
|
|
75
|
-
return fieldVal &&
|
|
77
|
+
return fieldVal && regex.test(fieldVal);
|
|
76
78
|
});
|
|
77
79
|
};
|
|
78
80
|
|
|
79
81
|
this.model.setDisplayFilter(filter);
|
|
80
82
|
}
|
|
81
83
|
|
|
84
|
+
private getRegex(searchTerm: string): RegExp {
|
|
85
|
+
searchTerm = escapeRegExp(searchTerm);
|
|
86
|
+
switch (this.matchMode) {
|
|
87
|
+
case 'any':
|
|
88
|
+
return new RegExp(searchTerm, 'i');
|
|
89
|
+
case 'start':
|
|
90
|
+
return new RegExp(`^${searchTerm}`, 'i');
|
|
91
|
+
case 'startWord':
|
|
92
|
+
return new RegExp(`(^|\\W)${searchTerm}`, 'i');
|
|
93
|
+
}
|
|
94
|
+
throw XH.exception('Unknown matchMode in StoreFilterField');
|
|
95
|
+
}
|
|
96
|
+
|
|
82
97
|
override destroy() {
|
|
83
98
|
// This unusual bit of code is extremely important -- the model we are linking to might
|
|
84
99
|
// survive the display of this component and should be restored. (This happens with GridColumnChooser)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "80.0.0-SNAPSHOT.
|
|
3
|
+
"version": "80.0.0-SNAPSHOT.1769042130982",
|
|
4
4
|
"description": "Hoist add-on for building and deploying React Applications.",
|
|
5
5
|
"repository": "github:xh/hoist-react",
|
|
6
6
|
"homepage": "https://xh.io",
|