@xh/hoist 73.0.0-SNAPSHOT.1738248972394 → 73.0.0-SNAPSHOT.1738687222195
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 +2 -0
- package/build/types/core/persist/PersistenceProvider.d.ts +4 -0
- package/cmp/filter/FilterChooserModel.ts +6 -2
- package/cmp/grid/impl/InitPersist.ts +9 -3
- package/cmp/grouping/GroupingChooserModel.ts +6 -2
- package/cmp/zoneGrid/impl/InitPersist.ts +9 -3
- package/core/HoistBase.ts +1 -2
- package/core/HoistBaseDecorators.ts +4 -1
- package/core/persist/PersistenceProvider.ts +31 -0
- package/data/cube/row/BaseRow.ts +3 -2
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
### 🐞 Bug Fixes
|
|
16
16
|
|
|
17
17
|
* Fixed Role grid losing view state on refresh.
|
|
18
|
+
* Fixed bug when merging `PersistOptions` with conflicting implicit provider types.
|
|
19
|
+
* Fixed bug where explicit `persistGrouping` options were not being respected by `GridModel`.
|
|
18
20
|
|
|
19
21
|
## v72.0.0 - 2025-01-27
|
|
20
22
|
|
|
@@ -41,6 +41,10 @@ export declare abstract class PersistenceProvider<S = any> {
|
|
|
41
41
|
* target without thrashing.
|
|
42
42
|
*/
|
|
43
43
|
static create<S>(cfg: PersistenceProviderConfig<S>): PersistenceProvider<S>;
|
|
44
|
+
/**
|
|
45
|
+
* Merge PersistOptions, respecting provider types, with later options overriding earlier ones.
|
|
46
|
+
*/
|
|
47
|
+
static mergePersistOptions(defaults: PersistOptions, ...overrides: PersistOptions[]): PersistOptions;
|
|
44
48
|
/** Read persisted state at this provider's path. */
|
|
45
49
|
read(): PersistableState<S>;
|
|
46
50
|
/** Persist JSON-serializable state to this provider's path. */
|
|
@@ -415,7 +415,9 @@ export class FilterChooserModel extends HoistModel {
|
|
|
415
415
|
}: FilterChooserPersistOptions) {
|
|
416
416
|
if (persistValue) {
|
|
417
417
|
const status = {initialized: false},
|
|
418
|
-
persistWith = isObject(persistValue)
|
|
418
|
+
persistWith = isObject(persistValue)
|
|
419
|
+
? PersistenceProvider.mergePersistOptions(rootPersistWith, persistValue)
|
|
420
|
+
: rootPersistWith;
|
|
419
421
|
PersistenceProvider.create({
|
|
420
422
|
persistOptions: {
|
|
421
423
|
path: `${path}.value`,
|
|
@@ -432,7 +434,9 @@ export class FilterChooserModel extends HoistModel {
|
|
|
432
434
|
}
|
|
433
435
|
|
|
434
436
|
if (persistFavorites) {
|
|
435
|
-
const persistWith = isObject(persistFavorites)
|
|
437
|
+
const persistWith = isObject(persistFavorites)
|
|
438
|
+
? PersistenceProvider.mergePersistOptions(rootPersistWith, persistFavorites)
|
|
439
|
+
: rootPersistWith,
|
|
436
440
|
provider = PersistenceProvider.create({
|
|
437
441
|
persistOptions: {
|
|
438
442
|
path: `${path}.favorites`,
|
|
@@ -24,7 +24,9 @@ export function initPersist(
|
|
|
24
24
|
}: GridModelPersistOptions
|
|
25
25
|
) {
|
|
26
26
|
if (persistColumns) {
|
|
27
|
-
const persistWith = isObject(persistColumns)
|
|
27
|
+
const persistWith = isObject(persistColumns)
|
|
28
|
+
? PersistenceProvider.mergePersistOptions(rootPersistWith, persistColumns)
|
|
29
|
+
: rootPersistWith;
|
|
28
30
|
PersistenceProvider.create({
|
|
29
31
|
persistOptions: {
|
|
30
32
|
path: `${path}.columns`,
|
|
@@ -39,7 +41,9 @@ export function initPersist(
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
if (persistSort) {
|
|
42
|
-
const persistWith = isObject(persistSort)
|
|
44
|
+
const persistWith = isObject(persistSort)
|
|
45
|
+
? PersistenceProvider.mergePersistOptions(rootPersistWith, persistSort)
|
|
46
|
+
: rootPersistWith;
|
|
43
47
|
PersistenceProvider.create({
|
|
44
48
|
persistOptions: {
|
|
45
49
|
path: `${path}.sortBy`,
|
|
@@ -55,7 +59,9 @@ export function initPersist(
|
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
if (persistGrouping) {
|
|
58
|
-
const persistWith = isObject(
|
|
62
|
+
const persistWith = isObject(persistGrouping)
|
|
63
|
+
? PersistenceProvider.mergePersistOptions(rootPersistWith, persistGrouping)
|
|
64
|
+
: rootPersistWith;
|
|
59
65
|
PersistenceProvider.create({
|
|
60
66
|
persistOptions: {
|
|
61
67
|
path: `${path}.groupBy`,
|
|
@@ -293,7 +293,9 @@ export class GroupingChooserModel extends HoistModel {
|
|
|
293
293
|
...rootPersistWith
|
|
294
294
|
}: GroupingChooserPersistOptions) {
|
|
295
295
|
if (persistValue) {
|
|
296
|
-
const persistWith = isObject(persistValue)
|
|
296
|
+
const persistWith = isObject(persistValue)
|
|
297
|
+
? PersistenceProvider.mergePersistOptions(rootPersistWith, persistValue)
|
|
298
|
+
: rootPersistWith;
|
|
297
299
|
PersistenceProvider.create({
|
|
298
300
|
persistOptions: {
|
|
299
301
|
path: `${path}.value`,
|
|
@@ -308,7 +310,9 @@ export class GroupingChooserModel extends HoistModel {
|
|
|
308
310
|
}
|
|
309
311
|
|
|
310
312
|
if (persistFavorites) {
|
|
311
|
-
const persistWith = isObject(persistFavorites)
|
|
313
|
+
const persistWith = isObject(persistFavorites)
|
|
314
|
+
? PersistenceProvider.mergePersistOptions(rootPersistWith, persistFavorites)
|
|
315
|
+
: rootPersistWith,
|
|
312
316
|
provider = PersistenceProvider.create({
|
|
313
317
|
persistOptions: {
|
|
314
318
|
path: `${path}.favorites`,
|
|
@@ -24,7 +24,9 @@ export function initPersist(
|
|
|
24
24
|
}: ZoneGridModelPersistOptions
|
|
25
25
|
) {
|
|
26
26
|
if (persistMappings) {
|
|
27
|
-
const persistWith = isObject(persistMappings)
|
|
27
|
+
const persistWith = isObject(persistMappings)
|
|
28
|
+
? PersistenceProvider.mergePersistOptions(rootPersistWith, persistMappings)
|
|
29
|
+
: rootPersistWith;
|
|
28
30
|
PersistenceProvider.create({
|
|
29
31
|
persistOptions: {
|
|
30
32
|
path: `${path}.mappings`,
|
|
@@ -39,7 +41,9 @@ export function initPersist(
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
if (persistGrouping) {
|
|
42
|
-
const persistWith = isObject(persistGrouping)
|
|
44
|
+
const persistWith = isObject(persistGrouping)
|
|
45
|
+
? PersistenceProvider.mergePersistOptions(rootPersistWith, persistGrouping)
|
|
46
|
+
: rootPersistWith;
|
|
43
47
|
PersistenceProvider.create({
|
|
44
48
|
persistOptions: {
|
|
45
49
|
path: `${path}.groupBy`,
|
|
@@ -54,7 +58,9 @@ export function initPersist(
|
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
if (persistSort) {
|
|
57
|
-
const persistWith = isObject(persistSort)
|
|
61
|
+
const persistWith = isObject(persistSort)
|
|
62
|
+
? PersistenceProvider.mergePersistOptions(rootPersistWith, persistSort)
|
|
63
|
+
: rootPersistWith;
|
|
58
64
|
PersistenceProvider.create({
|
|
59
65
|
persistOptions: {
|
|
60
66
|
path: `${path}.sortBy`,
|
package/core/HoistBase.ts
CHANGED
|
@@ -261,8 +261,7 @@ export abstract class HoistBase {
|
|
|
261
261
|
PersistenceProvider.create({
|
|
262
262
|
persistOptions: {
|
|
263
263
|
path: property,
|
|
264
|
-
...this.persistWith,
|
|
265
|
-
...options
|
|
264
|
+
...PersistenceProvider.mergePersistOptions(this.persistWith, options)
|
|
266
265
|
},
|
|
267
266
|
owner: this,
|
|
268
267
|
target: {
|
|
@@ -81,7 +81,10 @@ function createPersistDescriptor(
|
|
|
81
81
|
// codeValue undefined if no initial in-code value provided, otherwise call to get initial value.
|
|
82
82
|
ret = codeValue?.call(this);
|
|
83
83
|
|
|
84
|
-
const persistOptions = {
|
|
84
|
+
const persistOptions = {
|
|
85
|
+
path: property,
|
|
86
|
+
...PersistenceProvider.mergePersistOptions(this.persistWith, options)
|
|
87
|
+
};
|
|
85
88
|
PersistenceProvider.create({
|
|
86
89
|
persistOptions,
|
|
87
90
|
owner: this,
|
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
import {logDebug, logError, throwIf} from '@xh/hoist/utils/js';
|
|
9
9
|
import {
|
|
10
10
|
cloneDeep,
|
|
11
|
+
compact,
|
|
11
12
|
debounce as lodashDebounce,
|
|
12
13
|
get,
|
|
13
14
|
isEmpty,
|
|
14
15
|
isNumber,
|
|
15
16
|
isString,
|
|
16
17
|
isUndefined,
|
|
18
|
+
omit,
|
|
17
19
|
set,
|
|
18
20
|
toPath
|
|
19
21
|
} from 'lodash';
|
|
@@ -91,6 +93,35 @@ export abstract class PersistenceProvider<S = any> {
|
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Merge PersistOptions, respecting provider types, with later options overriding earlier ones.
|
|
98
|
+
*/
|
|
99
|
+
static mergePersistOptions(
|
|
100
|
+
defaults: PersistOptions,
|
|
101
|
+
...overrides: PersistOptions[]
|
|
102
|
+
): PersistOptions {
|
|
103
|
+
const TYPE_RELATED_KEYS = [
|
|
104
|
+
'type',
|
|
105
|
+
'prefKey',
|
|
106
|
+
'localStorageKey',
|
|
107
|
+
'sessionStorageKey',
|
|
108
|
+
'dashViewModel',
|
|
109
|
+
'viewManagerModel',
|
|
110
|
+
'getData',
|
|
111
|
+
'setData'
|
|
112
|
+
];
|
|
113
|
+
return compact(overrides).reduce(
|
|
114
|
+
(ret, override) =>
|
|
115
|
+
TYPE_RELATED_KEYS.some(key => override[key])
|
|
116
|
+
? {
|
|
117
|
+
...omit(ret, ...TYPE_RELATED_KEYS),
|
|
118
|
+
...override
|
|
119
|
+
}
|
|
120
|
+
: {...ret, ...override},
|
|
121
|
+
defaults
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
94
125
|
/** Read persisted state at this provider's path. */
|
|
95
126
|
read(): PersistableState<S> {
|
|
96
127
|
const state = get(this.readRaw(), this.path);
|
package/data/cube/row/BaseRow.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import {PlainObject, Some} from '@xh/hoist/core';
|
|
9
9
|
import {BucketSpec} from '@xh/hoist/data/cube/BucketSpec';
|
|
10
|
-
import {isEmpty, reduce} from 'lodash';
|
|
10
|
+
import {compact, isEmpty, reduce} from 'lodash';
|
|
11
11
|
import {View} from '../View';
|
|
12
12
|
import {RowUpdate} from './RowUpdate';
|
|
13
13
|
|
|
@@ -97,7 +97,8 @@ export abstract class BaseRow {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// Recurse
|
|
100
|
-
|
|
100
|
+
const ret = compact(children.flatMap(it => it.getVisibleDatas()));
|
|
101
|
+
return !isEmpty(ret) ? ret : null;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
private isRedundantChild(parent: any, child: any) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "73.0.0-SNAPSHOT.
|
|
3
|
+
"version": "73.0.0-SNAPSHOT.1738687222195",
|
|
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",
|