@xh/hoist 75.0.0-SNAPSHOT.1752765224740 → 75.0.0-SNAPSHOT.1752777363110
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 +9 -4
- package/build/types/cmp/grouping/GroupingChooserModel.d.ts +20 -12
- package/cmp/grouping/GroupingChooserModel.ts +53 -19
- package/desktop/cmp/grouping/GroupingChooser.ts +6 -16
- package/mobile/cmp/grouping/GroupingChooser.ts +4 -13
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## 75.0-SNAPSHOT - Unreleased
|
|
4
4
|
|
|
5
|
+
### 🎁 New Features
|
|
6
|
+
|
|
7
|
+
* Added new `GroupingChooserModel.sortDimensions` config - can be set to false to respect the order
|
|
8
|
+
in which dimensions are provided to the model.
|
|
9
|
+
|
|
5
10
|
### 🐞 Bug Fixes
|
|
6
11
|
|
|
7
12
|
* DashCanvas: ensure `allowAdd=false` is not enforced if loadingState
|
|
@@ -10,7 +15,7 @@
|
|
|
10
15
|
within the canvas, not the next parent container up that has `position: relative;`.
|
|
11
16
|
|
|
12
17
|
* `useContextModel` is now reactive to a change of an (observable) resolved model when it is set.
|
|
13
|
-
Previously this value was cached on first render.
|
|
18
|
+
Previously this value was cached on first render.
|
|
14
19
|
|
|
15
20
|
* Fixes to framework components that bind to grids (e.g. `ColChooserButton`, `ColAutosizeButton`,
|
|
16
21
|
`GridFindField`) to rebind to a new observable GridModel available via context.
|
|
@@ -26,9 +31,9 @@ Previously this value was cached on first render.
|
|
|
26
31
|
### 🎁 New Features
|
|
27
32
|
|
|
28
33
|
* Further refinements to the `GroupingChooser` desktop UI.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
* Added new props `favoritesSide` and `favoritesTitle`.
|
|
35
|
+
* Deprecated `popoverTitle` prop - use `editorTitle` instead.
|
|
36
|
+
* Moved "Save as Favorite" button to a new compact toolbar within the popover.
|
|
32
37
|
|
|
33
38
|
### 🐞 Bug Fixes
|
|
34
39
|
|
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
import { HoistModel, PersistOptions } from '@xh/hoist/core';
|
|
1
|
+
import { HoistModel, PersistOptions, SelectOption } from '@xh/hoist/core';
|
|
2
2
|
export interface GroupingChooserConfig {
|
|
3
|
+
/** True to accept an empty list as a valid value. */
|
|
4
|
+
allowEmpty?: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* False (default) waits for the user to dismiss the popover before updating the
|
|
7
|
+
* external/observable value.
|
|
8
|
+
*/
|
|
9
|
+
commitOnChange?: boolean;
|
|
3
10
|
/**
|
|
4
11
|
* Dimensions available for selection. When using GroupingChooser to create Cube queries,
|
|
5
12
|
* it is recommended to pass the `dimensions` from the related cube (or a subset thereof).
|
|
6
13
|
* Note that {@link CubeField} meets the `DimensionSpec` interface.
|
|
7
14
|
*/
|
|
8
15
|
dimensions?: (DimensionSpec | string)[];
|
|
9
|
-
/** Initial value as an array of dimension names, or a function to produce such an array. */
|
|
10
|
-
initialValue?: string[] | (() => string[]);
|
|
11
16
|
/**
|
|
12
17
|
* Initial favorites as an array of dim name arrays, or a function to produce such an array.
|
|
13
18
|
* Ignored if `persistWith.persistFavorites: false`.
|
|
14
19
|
*/
|
|
15
20
|
initialFavorites?: string[][] | (() => string[][]);
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/** True to accept an empty list as a valid value. */
|
|
19
|
-
allowEmpty?: boolean;
|
|
21
|
+
/** Initial value as an array of dimension names, or a function to produce such an array. */
|
|
22
|
+
initialValue?: string[] | (() => string[]);
|
|
20
23
|
/** Maximum number of dimensions allowed in a single grouping. */
|
|
21
24
|
maxDepth?: number;
|
|
25
|
+
/** Options governing persistence. */
|
|
26
|
+
persistWith?: GroupingChooserPersistOptions;
|
|
22
27
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
28
|
+
* True (default) to auto-sort dimensions by label. Set to false to show them in the order
|
|
29
|
+
* provided in the `dimensions` config.
|
|
25
30
|
*/
|
|
26
|
-
|
|
31
|
+
sortDimensions?: boolean;
|
|
27
32
|
}
|
|
28
33
|
/**
|
|
29
34
|
* Metadata for dimensions that are available for selection via a GroupingChooser control.
|
|
@@ -45,9 +50,10 @@ export declare class GroupingChooserModel extends HoistModel {
|
|
|
45
50
|
value: string[];
|
|
46
51
|
favorites: string[][];
|
|
47
52
|
allowEmpty: boolean;
|
|
48
|
-
maxDepth: number;
|
|
49
53
|
commitOnChange: boolean;
|
|
54
|
+
maxDepth: number;
|
|
50
55
|
persistFavorites: boolean;
|
|
56
|
+
sortDimensions: boolean;
|
|
51
57
|
pendingValue: string[];
|
|
52
58
|
editorIsOpen: boolean;
|
|
53
59
|
popoverRef: import("react").RefObject<HTMLElement> & import("react").RefCallback<HTMLElement>;
|
|
@@ -58,11 +64,13 @@ export declare class GroupingChooserModel extends HoistModel {
|
|
|
58
64
|
get isValid(): boolean;
|
|
59
65
|
get isAddEnabled(): boolean;
|
|
60
66
|
get isAddFavoriteEnabled(): boolean;
|
|
61
|
-
constructor({
|
|
67
|
+
constructor({ allowEmpty, commitOnChange, dimensions, initialFavorites, initialValue, maxDepth, persistWith, sortDimensions }: GroupingChooserConfig);
|
|
62
68
|
setDimensions(dimensions: Array<DimensionSpec | string>): void;
|
|
63
69
|
setValue(value: string[]): void;
|
|
64
70
|
toggleEditor(): void;
|
|
65
71
|
closeEditor(): void;
|
|
72
|
+
/** Transform dimension names into SelectOptions, with displayName and optional sort. */
|
|
73
|
+
getDimSelectOpts(dims?: string[]): SelectOption[];
|
|
66
74
|
addPendingDim(dimName: string): void;
|
|
67
75
|
replacePendingDimAtIdx(dimName: string, idx: number): void;
|
|
68
76
|
removePendingDimAtIdx(idx: number): void;
|
|
@@ -5,14 +5,39 @@
|
|
|
5
5
|
* Copyright © 2025 Extremely Heavy Industries Inc.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
HoistModel,
|
|
10
|
+
PersistableState,
|
|
11
|
+
PersistenceProvider,
|
|
12
|
+
PersistOptions,
|
|
13
|
+
SelectOption
|
|
14
|
+
} from '@xh/hoist/core';
|
|
9
15
|
import {genDisplayName} from '@xh/hoist/data';
|
|
10
16
|
import {action, computed, makeObservable, observable} from '@xh/hoist/mobx';
|
|
11
17
|
import {executeIfFunction, throwIf} from '@xh/hoist/utils/js';
|
|
12
18
|
import {createObservableRef} from '@xh/hoist/utils/react';
|
|
13
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
compact,
|
|
21
|
+
difference,
|
|
22
|
+
isArray,
|
|
23
|
+
isEmpty,
|
|
24
|
+
isEqual,
|
|
25
|
+
isObject,
|
|
26
|
+
isString,
|
|
27
|
+
keys,
|
|
28
|
+
sortBy
|
|
29
|
+
} from 'lodash';
|
|
14
30
|
|
|
15
31
|
export interface GroupingChooserConfig {
|
|
32
|
+
/** True to accept an empty list as a valid value. */
|
|
33
|
+
allowEmpty?: boolean;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* False (default) waits for the user to dismiss the popover before updating the
|
|
37
|
+
* external/observable value.
|
|
38
|
+
*/
|
|
39
|
+
commitOnChange?: boolean;
|
|
40
|
+
|
|
16
41
|
/**
|
|
17
42
|
* Dimensions available for selection. When using GroupingChooser to create Cube queries,
|
|
18
43
|
* it is recommended to pass the `dimensions` from the related cube (or a subset thereof).
|
|
@@ -20,29 +45,26 @@ export interface GroupingChooserConfig {
|
|
|
20
45
|
*/
|
|
21
46
|
dimensions?: (DimensionSpec | string)[];
|
|
22
47
|
|
|
23
|
-
/** Initial value as an array of dimension names, or a function to produce such an array. */
|
|
24
|
-
initialValue?: string[] | (() => string[]);
|
|
25
|
-
|
|
26
48
|
/**
|
|
27
49
|
* Initial favorites as an array of dim name arrays, or a function to produce such an array.
|
|
28
50
|
* Ignored if `persistWith.persistFavorites: false`.
|
|
29
51
|
*/
|
|
30
52
|
initialFavorites?: string[][] | (() => string[][]);
|
|
31
53
|
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/** True to accept an empty list as a valid value. */
|
|
36
|
-
allowEmpty?: boolean;
|
|
54
|
+
/** Initial value as an array of dimension names, or a function to produce such an array. */
|
|
55
|
+
initialValue?: string[] | (() => string[]);
|
|
37
56
|
|
|
38
57
|
/** Maximum number of dimensions allowed in a single grouping. */
|
|
39
58
|
maxDepth?: number;
|
|
40
59
|
|
|
60
|
+
/** Options governing persistence. */
|
|
61
|
+
persistWith?: GroupingChooserPersistOptions;
|
|
62
|
+
|
|
41
63
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
64
|
+
* True (default) to auto-sort dimensions by label. Set to false to show them in the order
|
|
65
|
+
* provided in the `dimensions` config.
|
|
44
66
|
*/
|
|
45
|
-
|
|
67
|
+
sortDimensions?: boolean;
|
|
46
68
|
}
|
|
47
69
|
|
|
48
70
|
/**
|
|
@@ -70,9 +92,10 @@ export class GroupingChooserModel extends HoistModel {
|
|
|
70
92
|
@observable.ref favorites: string[][] = [];
|
|
71
93
|
|
|
72
94
|
allowEmpty: boolean;
|
|
73
|
-
maxDepth: number;
|
|
74
95
|
commitOnChange: boolean;
|
|
96
|
+
maxDepth: number;
|
|
75
97
|
persistFavorites: boolean = false;
|
|
98
|
+
sortDimensions: boolean;
|
|
76
99
|
|
|
77
100
|
// Implementation fields for Control
|
|
78
101
|
@observable.ref pendingValue: string[] = [];
|
|
@@ -117,20 +140,22 @@ export class GroupingChooserModel extends HoistModel {
|
|
|
117
140
|
}
|
|
118
141
|
|
|
119
142
|
constructor({
|
|
143
|
+
allowEmpty = false,
|
|
144
|
+
commitOnChange = false,
|
|
120
145
|
dimensions,
|
|
121
|
-
initialValue = [],
|
|
122
146
|
initialFavorites = [],
|
|
123
|
-
|
|
124
|
-
allowEmpty = false,
|
|
147
|
+
initialValue = [],
|
|
125
148
|
maxDepth = null,
|
|
126
|
-
|
|
149
|
+
persistWith = null,
|
|
150
|
+
sortDimensions = true
|
|
127
151
|
}: GroupingChooserConfig) {
|
|
128
152
|
super();
|
|
129
153
|
makeObservable(this);
|
|
130
154
|
|
|
131
155
|
this.allowEmpty = allowEmpty;
|
|
132
|
-
this.maxDepth = maxDepth;
|
|
133
156
|
this.commitOnChange = commitOnChange;
|
|
157
|
+
this.maxDepth = maxDepth;
|
|
158
|
+
this.sortDimensions = sortDimensions;
|
|
134
159
|
|
|
135
160
|
this.setDimensions(dimensions);
|
|
136
161
|
|
|
@@ -187,6 +212,15 @@ export class GroupingChooserModel extends HoistModel {
|
|
|
187
212
|
this.editorIsOpen = false;
|
|
188
213
|
}
|
|
189
214
|
|
|
215
|
+
/** Transform dimension names into SelectOptions, with displayName and optional sort. */
|
|
216
|
+
getDimSelectOpts(dims: string[] = this.availableDims): SelectOption[] {
|
|
217
|
+
const ret = compact(dims).map(dimName => ({
|
|
218
|
+
value: dimName,
|
|
219
|
+
label: this.getDimDisplayName(dimName)
|
|
220
|
+
}));
|
|
221
|
+
return this.sortDimensions ? sortBy(ret, 'label') : ret;
|
|
222
|
+
}
|
|
223
|
+
|
|
190
224
|
//-------------------------
|
|
191
225
|
// Value handling
|
|
192
226
|
//-------------------------
|
|
@@ -29,7 +29,7 @@ import {dragDropContext, draggable, droppable} from '@xh/hoist/kit/react-beautif
|
|
|
29
29
|
import {apiDeprecated, elemWithin, getTestId} from '@xh/hoist/utils/js';
|
|
30
30
|
import {splitLayoutProps} from '@xh/hoist/utils/react';
|
|
31
31
|
import classNames from 'classnames';
|
|
32
|
-
import {
|
|
32
|
+
import {isEmpty, isNil, isUndefined} from 'lodash';
|
|
33
33
|
import './GroupingChooser.scss';
|
|
34
34
|
import {ReactNode} from 'react';
|
|
35
35
|
|
|
@@ -264,7 +264,7 @@ const dimensionList = hoistCmp.factory<GroupingChooserModel>({
|
|
|
264
264
|
const dimensionRow = hoistCmp.factory<GroupingChooserModel>({
|
|
265
265
|
render({model, dimension, idx}) {
|
|
266
266
|
// The options for this select include its current value
|
|
267
|
-
const options =
|
|
267
|
+
const options = model.getDimSelectOpts([...model.availableDims, dimension]);
|
|
268
268
|
|
|
269
269
|
return draggable({
|
|
270
270
|
key: dimension,
|
|
@@ -346,7 +346,8 @@ const dimensionRow = hoistCmp.factory<GroupingChooserModel>({
|
|
|
346
346
|
const addDimensionControl = hoistCmp.factory<GroupingChooserModel>({
|
|
347
347
|
render({model}) {
|
|
348
348
|
if (!model.isAddEnabled) return null;
|
|
349
|
-
|
|
349
|
+
|
|
350
|
+
const options = model.getDimSelectOpts();
|
|
350
351
|
return div({
|
|
351
352
|
className: 'xh-grouping-chooser__add-control',
|
|
352
353
|
items: [
|
|
@@ -372,9 +373,8 @@ const addDimensionControl = hoistCmp.factory<GroupingChooserModel>({
|
|
|
372
373
|
});
|
|
373
374
|
|
|
374
375
|
/**
|
|
375
|
-
* Extract integer values from CSS transform string.
|
|
376
|
-
*
|
|
377
|
-
* e.g. `translate3d(250px, 150px, 0px)` is equivalent to [250, 150, 0]
|
|
376
|
+
* Extract integer values from CSS transform string. Works for both `translate` and `translate3d`.
|
|
377
|
+
* e.g. `translate3d(250px, 150px, 0px) -> [250, 150, 0]`
|
|
378
378
|
*/
|
|
379
379
|
function parseTransform(transformStr: string): number[] {
|
|
380
380
|
return transformStr
|
|
@@ -383,16 +383,6 @@ function parseTransform(transformStr: string): number[] {
|
|
|
383
383
|
?.map(it => parseInt(it));
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
-
/**
|
|
387
|
-
* Convert a list of dim names into select options
|
|
388
|
-
*/
|
|
389
|
-
function getDimOptions(dims, model) {
|
|
390
|
-
const ret = compact(dims).map(dimName => {
|
|
391
|
-
return {value: dimName, label: model.getDimDisplayName(dimName)};
|
|
392
|
-
});
|
|
393
|
-
return sortBy(ret, 'label');
|
|
394
|
-
}
|
|
395
|
-
|
|
396
386
|
//------------------
|
|
397
387
|
// Favorites
|
|
398
388
|
//------------------
|
|
@@ -15,7 +15,7 @@ import '@xh/hoist/mobile/register';
|
|
|
15
15
|
import {dialogPanel, panel} from '@xh/hoist/mobile/cmp/panel';
|
|
16
16
|
import {splitLayoutProps} from '@xh/hoist/utils/react';
|
|
17
17
|
import classNames from 'classnames';
|
|
18
|
-
import {
|
|
18
|
+
import {isEmpty} from 'lodash';
|
|
19
19
|
|
|
20
20
|
import './GroupingChooser.scss';
|
|
21
21
|
|
|
@@ -134,7 +134,7 @@ const dimensionList = hoistCmp.factory<GroupingChooserModel>({
|
|
|
134
134
|
const dimensionRow = hoistCmp.factory<GroupingChooserModel>({
|
|
135
135
|
render({model, dimension, idx}) {
|
|
136
136
|
// The options for this select include its current value
|
|
137
|
-
const options =
|
|
137
|
+
const options = model.getDimSelectOpts([...model.availableDims, dimension]);
|
|
138
138
|
|
|
139
139
|
return draggable({
|
|
140
140
|
key: dimension,
|
|
@@ -182,7 +182,8 @@ const dimensionRow = hoistCmp.factory<GroupingChooserModel>({
|
|
|
182
182
|
const addDimensionControl = hoistCmp.factory<GroupingChooserModel>({
|
|
183
183
|
render({model}) {
|
|
184
184
|
if (!model.isAddEnabled) return null;
|
|
185
|
-
|
|
185
|
+
|
|
186
|
+
const options = model.getDimSelectOpts();
|
|
186
187
|
return div({
|
|
187
188
|
className: 'xh-grouping-chooser__add-control',
|
|
188
189
|
items: [
|
|
@@ -203,16 +204,6 @@ const addDimensionControl = hoistCmp.factory<GroupingChooserModel>({
|
|
|
203
204
|
}
|
|
204
205
|
});
|
|
205
206
|
|
|
206
|
-
/**
|
|
207
|
-
* Convert a list of dim names into select options
|
|
208
|
-
*/
|
|
209
|
-
function getDimOptions(dims, model) {
|
|
210
|
-
const ret = compact(dims).map(dimName => {
|
|
211
|
-
return {value: dimName, label: model.getDimDisplayName(dimName)};
|
|
212
|
-
});
|
|
213
|
-
return sortBy(ret, 'label');
|
|
214
|
-
}
|
|
215
|
-
|
|
216
207
|
//------------------
|
|
217
208
|
// Favorites
|
|
218
209
|
//------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "75.0.0-SNAPSHOT.
|
|
3
|
+
"version": "75.0.0-SNAPSHOT.1752777363110",
|
|
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",
|