@xh/hoist 77.0.0-SNAPSHOT.1760466580390 → 77.0.0-SNAPSHOT.1760631134539
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/build/types/data/cube/Query.d.ts +1 -0
- package/data/cube/Query.ts +2 -0
- package/data/cube/View.ts +18 -12
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -97,6 +97,7 @@ export declare class Query {
|
|
|
97
97
|
readonly fields: CubeField[];
|
|
98
98
|
readonly dimensions: CubeField[];
|
|
99
99
|
readonly filter: Filter;
|
|
100
|
+
readonly hasFilter: boolean;
|
|
100
101
|
readonly includeRoot: boolean;
|
|
101
102
|
readonly includeLeaves: boolean;
|
|
102
103
|
readonly provideLeaves: boolean;
|
package/data/cube/Query.ts
CHANGED
|
@@ -127,6 +127,7 @@ export class Query {
|
|
|
127
127
|
readonly fields: CubeField[];
|
|
128
128
|
readonly dimensions: CubeField[];
|
|
129
129
|
readonly filter: Filter;
|
|
130
|
+
readonly hasFilter: boolean;
|
|
130
131
|
readonly includeRoot: boolean;
|
|
131
132
|
readonly includeLeaves: boolean;
|
|
132
133
|
readonly provideLeaves: boolean;
|
|
@@ -164,6 +165,7 @@ export class Query {
|
|
|
164
165
|
this.omitFn = omitFn;
|
|
165
166
|
|
|
166
167
|
this._testFn = this.filter?.getTestFn(this.cube.store) ?? null;
|
|
168
|
+
this.hasFilter = this._testFn != null;
|
|
167
169
|
}
|
|
168
170
|
|
|
169
171
|
clone(overrides: Partial<QueryConfig>) {
|
package/data/cube/View.ts
CHANGED
|
@@ -309,12 +309,12 @@ export class View extends HoistBase {
|
|
|
309
309
|
appliedDimensions: PlainObject,
|
|
310
310
|
leafMap: Map<StoreRecordId, LeafRow>
|
|
311
311
|
): BaseRow[] {
|
|
312
|
-
if (
|
|
312
|
+
if (!records?.length) return [];
|
|
313
313
|
|
|
314
314
|
const rootId = parentId + Cube.RECORD_ID_DELIMITER;
|
|
315
315
|
|
|
316
|
-
if (
|
|
317
|
-
return map(
|
|
316
|
+
if (!dimensions?.length) {
|
|
317
|
+
return records.map(r => {
|
|
318
318
|
const id = rootId + r.id,
|
|
319
319
|
leaf = this.cachedRow(id, null, () => new LeafRow(this, id, r));
|
|
320
320
|
leafMap.set(r.id, leaf);
|
|
@@ -355,16 +355,17 @@ export class View extends HoistBase {
|
|
|
355
355
|
parentId: string,
|
|
356
356
|
appliedDimensions: PlainObject
|
|
357
357
|
): BaseRow[] {
|
|
358
|
-
|
|
358
|
+
const {query} = this;
|
|
359
359
|
|
|
360
|
-
|
|
361
|
-
if (!
|
|
360
|
+
if (!query.bucketSpecFn) return rows;
|
|
361
|
+
if (!query.includeLeaves && rows[0]?.isLeaf) return rows;
|
|
362
362
|
|
|
363
|
-
|
|
363
|
+
const bucketSpec = query.bucketSpecFn(rows);
|
|
364
|
+
if (!bucketSpec) return rows;
|
|
364
365
|
|
|
365
366
|
const {name: bucketName, bucketFn} = bucketSpec,
|
|
366
|
-
buckets = {},
|
|
367
|
-
ret = [];
|
|
367
|
+
buckets: Record<string, BaseRow[]> = {},
|
|
368
|
+
ret: BaseRow[] = [];
|
|
368
369
|
|
|
369
370
|
// Determine which bucket to put this row into (if any)
|
|
370
371
|
rows.forEach(row => {
|
|
@@ -372,8 +373,8 @@ export class View extends HoistBase {
|
|
|
372
373
|
if (isNil(bucketVal)) {
|
|
373
374
|
ret.push(row);
|
|
374
375
|
} else {
|
|
375
|
-
|
|
376
|
-
|
|
376
|
+
const bucketRows = buckets[bucketVal] ??= [];
|
|
377
|
+
bucketRows.push(row);
|
|
377
378
|
}
|
|
378
379
|
});
|
|
379
380
|
|
|
@@ -454,8 +455,13 @@ export class View extends HoistBase {
|
|
|
454
455
|
|
|
455
456
|
private filterRecords() {
|
|
456
457
|
const {query, cube} = this,
|
|
458
|
+
{hasFilter} = query,
|
|
457
459
|
ret = new Map();
|
|
458
|
-
|
|
460
|
+
|
|
461
|
+
cube.store.records.forEach(r => {
|
|
462
|
+
if (!hasFilter || query.test(r)) ret.set(r.id, r);
|
|
463
|
+
});
|
|
464
|
+
|
|
459
465
|
this._recordMap = ret;
|
|
460
466
|
}
|
|
461
467
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "77.0.0-SNAPSHOT.
|
|
3
|
+
"version": "77.0.0-SNAPSHOT.1760631134539",
|
|
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",
|