@pretable/core 0.0.5 → 0.0.6
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/index.cjs +27 -3
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.mjs +27 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -587,6 +587,29 @@ function matchesFilters(row, resolvedFilters) {
|
|
|
587
587
|
return true;
|
|
588
588
|
}
|
|
589
589
|
|
|
590
|
+
// ../grid-core/dist/group-expansion.js
|
|
591
|
+
var DEFAULT_GROUP_EXPANSION_OVERRIDE_LIMIT = 1e4;
|
|
592
|
+
function resolveGroupExpansionOverrideLimit(configured) {
|
|
593
|
+
if (configured === void 0)
|
|
594
|
+
return DEFAULT_GROUP_EXPANSION_OVERRIDE_LIMIT;
|
|
595
|
+
if (configured === Number.POSITIVE_INFINITY)
|
|
596
|
+
return configured;
|
|
597
|
+
if (!Number.isFinite(configured)) {
|
|
598
|
+
return DEFAULT_GROUP_EXPANSION_OVERRIDE_LIMIT;
|
|
599
|
+
}
|
|
600
|
+
return Math.max(1, Math.floor(configured));
|
|
601
|
+
}
|
|
602
|
+
function addGroupExpansionOverride(current, groupId, limit) {
|
|
603
|
+
const next = new Set(current);
|
|
604
|
+
next.delete(groupId);
|
|
605
|
+
next.add(groupId);
|
|
606
|
+
while (next.size > limit) {
|
|
607
|
+
const oldest = next.values().next().value;
|
|
608
|
+
next.delete(oldest);
|
|
609
|
+
}
|
|
610
|
+
return next;
|
|
611
|
+
}
|
|
612
|
+
|
|
590
613
|
// ../grid-core/dist/create-grid-core.js
|
|
591
614
|
var ROW_SELECT_COLUMN_ID = "__pretable_row_select__";
|
|
592
615
|
function isDataRow(entry) {
|
|
@@ -677,6 +700,7 @@ function createGridCore(inputOptions) {
|
|
|
677
700
|
let filters = {};
|
|
678
701
|
let rowGroups = sanitizeRowGroups(options.columns.filter((column) => column.rowGroup === true).map((c) => c.id), options.columns);
|
|
679
702
|
let groupExpansionOverrides = /* @__PURE__ */ new Set();
|
|
703
|
+
const groupExpansionOverrideLimit = resolveGroupExpansionOverrideLimit(options.groupExpansionOverrideLimit);
|
|
680
704
|
let groupsDefaultExpanded = options.groupsDefaultExpanded ?? true;
|
|
681
705
|
let previousAggregates = /* @__PURE__ */ new Map();
|
|
682
706
|
let selection = { ranges: [], anchor: null };
|
|
@@ -1357,13 +1381,13 @@ function createGridCore(inputOptions) {
|
|
|
1357
1381
|
if (isGroupExpanded(groupId) === expanded) {
|
|
1358
1382
|
return;
|
|
1359
1383
|
}
|
|
1360
|
-
const next = new Set(groupExpansionOverrides);
|
|
1361
1384
|
if (expanded === groupsDefaultExpanded) {
|
|
1385
|
+
const next = new Set(groupExpansionOverrides);
|
|
1362
1386
|
next.delete(groupId);
|
|
1387
|
+
groupExpansionOverrides = next;
|
|
1363
1388
|
} else {
|
|
1364
|
-
|
|
1389
|
+
groupExpansionOverrides = addGroupExpansionOverride(groupExpansionOverrides, groupId, groupExpansionOverrideLimit);
|
|
1365
1390
|
}
|
|
1366
|
-
groupExpansionOverrides = next;
|
|
1367
1391
|
emit();
|
|
1368
1392
|
},
|
|
1369
1393
|
expandAll() {
|
package/dist/index.d.cts
CHANGED
|
@@ -102,6 +102,15 @@ interface PretableColumn<TRow extends PretableRow = PretableRow> {
|
|
|
102
102
|
format?: (input: PretableFormatInput<TRow>) => string;
|
|
103
103
|
minWidthPx?: number;
|
|
104
104
|
maxWidthPx?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Share of the width the fixed columns leave over, so the row ends exactly at
|
|
107
|
+
* the viewport edge instead of underfilling or overflowing it. Weights are
|
|
108
|
+
* relative: two columns at `flex: 1` split the remainder evenly, `1` and `3`
|
|
109
|
+
* split it a quarter to three quarters. `minWidthPx`/`maxWidthPx` still
|
|
110
|
+
* apply, and a column that has been resized (which sets `widthPx`) stops
|
|
111
|
+
* flexing — an explicit width outranks a computed one.
|
|
112
|
+
*/
|
|
113
|
+
flex?: number;
|
|
105
114
|
resizable?: boolean;
|
|
106
115
|
reorderable?: boolean;
|
|
107
116
|
/** Group rows by this column by default; levels follow column order. */
|
|
@@ -144,6 +153,25 @@ interface PretableGridOptions<TRow extends PretableRow = PretableRow> {
|
|
|
144
153
|
* Default `true`. Groups appearing mid-stream inherit it with no bookkeeping.
|
|
145
154
|
*/
|
|
146
155
|
groupsDefaultExpanded?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* How many per-group expand/collapse decisions the grid remembers. Default
|
|
158
|
+
* `10_000`. Past the limit the least-recently-decided group is forgotten and
|
|
159
|
+
* reverts to `groupsDefaultExpanded`.
|
|
160
|
+
*
|
|
161
|
+
* **Why a limit exists.** Expansion state is keyed by a path-derived group id
|
|
162
|
+
* rather than owned by a node, which is what lets a group survive emptying and
|
|
163
|
+
* returning mid-stream. The price is that ids for groups which never return
|
|
164
|
+
* would otherwise accumulate forever under a stream whose grouping keys churn.
|
|
165
|
+
*
|
|
166
|
+
* Values below 1 clamp to 1; a non-finite value other than `Infinity` falls
|
|
167
|
+
* back to the default. Pass `Infinity` to opt out of the cap entirely and
|
|
168
|
+
* accept unbounded growth.
|
|
169
|
+
*
|
|
170
|
+
* `expandAll()` / `collapseAll()` are unaffected — they flip the default and
|
|
171
|
+
* clear the set, so "collapse everything" costs one entry-free operation no
|
|
172
|
+
* matter how many groups exist.
|
|
173
|
+
*/
|
|
174
|
+
groupExpansionOverrideLimit?: number;
|
|
147
175
|
}
|
|
148
176
|
/**
|
|
149
177
|
* One entry in the ordered sort list; index in the list = priority.
|
package/dist/index.d.ts
CHANGED
|
@@ -102,6 +102,15 @@ interface PretableColumn<TRow extends PretableRow = PretableRow> {
|
|
|
102
102
|
format?: (input: PretableFormatInput<TRow>) => string;
|
|
103
103
|
minWidthPx?: number;
|
|
104
104
|
maxWidthPx?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Share of the width the fixed columns leave over, so the row ends exactly at
|
|
107
|
+
* the viewport edge instead of underfilling or overflowing it. Weights are
|
|
108
|
+
* relative: two columns at `flex: 1` split the remainder evenly, `1` and `3`
|
|
109
|
+
* split it a quarter to three quarters. `minWidthPx`/`maxWidthPx` still
|
|
110
|
+
* apply, and a column that has been resized (which sets `widthPx`) stops
|
|
111
|
+
* flexing — an explicit width outranks a computed one.
|
|
112
|
+
*/
|
|
113
|
+
flex?: number;
|
|
105
114
|
resizable?: boolean;
|
|
106
115
|
reorderable?: boolean;
|
|
107
116
|
/** Group rows by this column by default; levels follow column order. */
|
|
@@ -144,6 +153,25 @@ interface PretableGridOptions<TRow extends PretableRow = PretableRow> {
|
|
|
144
153
|
* Default `true`. Groups appearing mid-stream inherit it with no bookkeeping.
|
|
145
154
|
*/
|
|
146
155
|
groupsDefaultExpanded?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* How many per-group expand/collapse decisions the grid remembers. Default
|
|
158
|
+
* `10_000`. Past the limit the least-recently-decided group is forgotten and
|
|
159
|
+
* reverts to `groupsDefaultExpanded`.
|
|
160
|
+
*
|
|
161
|
+
* **Why a limit exists.** Expansion state is keyed by a path-derived group id
|
|
162
|
+
* rather than owned by a node, which is what lets a group survive emptying and
|
|
163
|
+
* returning mid-stream. The price is that ids for groups which never return
|
|
164
|
+
* would otherwise accumulate forever under a stream whose grouping keys churn.
|
|
165
|
+
*
|
|
166
|
+
* Values below 1 clamp to 1; a non-finite value other than `Infinity` falls
|
|
167
|
+
* back to the default. Pass `Infinity` to opt out of the cap entirely and
|
|
168
|
+
* accept unbounded growth.
|
|
169
|
+
*
|
|
170
|
+
* `expandAll()` / `collapseAll()` are unaffected — they flip the default and
|
|
171
|
+
* clear the set, so "collapse everything" costs one entry-free operation no
|
|
172
|
+
* matter how many groups exist.
|
|
173
|
+
*/
|
|
174
|
+
groupExpansionOverrideLimit?: number;
|
|
147
175
|
}
|
|
148
176
|
/**
|
|
149
177
|
* One entry in the ordered sort list; index in the list = priority.
|
package/dist/index.mjs
CHANGED
|
@@ -585,6 +585,29 @@ function matchesFilters(row, resolvedFilters) {
|
|
|
585
585
|
return true;
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
+
// ../grid-core/dist/group-expansion.js
|
|
589
|
+
var DEFAULT_GROUP_EXPANSION_OVERRIDE_LIMIT = 1e4;
|
|
590
|
+
function resolveGroupExpansionOverrideLimit(configured) {
|
|
591
|
+
if (configured === void 0)
|
|
592
|
+
return DEFAULT_GROUP_EXPANSION_OVERRIDE_LIMIT;
|
|
593
|
+
if (configured === Number.POSITIVE_INFINITY)
|
|
594
|
+
return configured;
|
|
595
|
+
if (!Number.isFinite(configured)) {
|
|
596
|
+
return DEFAULT_GROUP_EXPANSION_OVERRIDE_LIMIT;
|
|
597
|
+
}
|
|
598
|
+
return Math.max(1, Math.floor(configured));
|
|
599
|
+
}
|
|
600
|
+
function addGroupExpansionOverride(current, groupId, limit) {
|
|
601
|
+
const next = new Set(current);
|
|
602
|
+
next.delete(groupId);
|
|
603
|
+
next.add(groupId);
|
|
604
|
+
while (next.size > limit) {
|
|
605
|
+
const oldest = next.values().next().value;
|
|
606
|
+
next.delete(oldest);
|
|
607
|
+
}
|
|
608
|
+
return next;
|
|
609
|
+
}
|
|
610
|
+
|
|
588
611
|
// ../grid-core/dist/create-grid-core.js
|
|
589
612
|
var ROW_SELECT_COLUMN_ID = "__pretable_row_select__";
|
|
590
613
|
function isDataRow(entry) {
|
|
@@ -675,6 +698,7 @@ function createGridCore(inputOptions) {
|
|
|
675
698
|
let filters = {};
|
|
676
699
|
let rowGroups = sanitizeRowGroups(options.columns.filter((column) => column.rowGroup === true).map((c) => c.id), options.columns);
|
|
677
700
|
let groupExpansionOverrides = /* @__PURE__ */ new Set();
|
|
701
|
+
const groupExpansionOverrideLimit = resolveGroupExpansionOverrideLimit(options.groupExpansionOverrideLimit);
|
|
678
702
|
let groupsDefaultExpanded = options.groupsDefaultExpanded ?? true;
|
|
679
703
|
let previousAggregates = /* @__PURE__ */ new Map();
|
|
680
704
|
let selection = { ranges: [], anchor: null };
|
|
@@ -1355,13 +1379,13 @@ function createGridCore(inputOptions) {
|
|
|
1355
1379
|
if (isGroupExpanded(groupId) === expanded) {
|
|
1356
1380
|
return;
|
|
1357
1381
|
}
|
|
1358
|
-
const next = new Set(groupExpansionOverrides);
|
|
1359
1382
|
if (expanded === groupsDefaultExpanded) {
|
|
1383
|
+
const next = new Set(groupExpansionOverrides);
|
|
1360
1384
|
next.delete(groupId);
|
|
1385
|
+
groupExpansionOverrides = next;
|
|
1361
1386
|
} else {
|
|
1362
|
-
|
|
1387
|
+
groupExpansionOverrides = addGroupExpansionOverride(groupExpansionOverrides, groupId, groupExpansionOverrideLimit);
|
|
1363
1388
|
}
|
|
1364
|
-
groupExpansionOverrides = next;
|
|
1365
1389
|
emit();
|
|
1366
1390
|
},
|
|
1367
1391
|
expandAll() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pretable/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Framework-agnostic grid state primitives for Pretable.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -43,6 +43,6 @@
|
|
|
43
43
|
"lint": "eslint src --ext .ts",
|
|
44
44
|
"lint:packaging": "publint --strict && attw --pack",
|
|
45
45
|
"test": "pnpm --filter @pretable-internal/grid-core build && vitest run",
|
|
46
|
-
"typecheck": "pnpm --filter @pretable-internal/grid-core build && tsc -p tsconfig.json --noEmit"
|
|
46
|
+
"typecheck": "pnpm --filter @pretable-internal/grid-core build && tsc -p tsconfig.typecheck.json --noEmit"
|
|
47
47
|
}
|
|
48
48
|
}
|