@platforma-sdk/model 1.59.3 → 1.60.0
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/block_storage.cjs.map +1 -1
- package/dist/block_storage.d.ts +1 -11
- package/dist/block_storage.js.map +1 -1
- package/dist/block_storage_callbacks.cjs.map +1 -1
- package/dist/block_storage_callbacks.js.map +1 -1
- package/dist/columns/column_collection_builder.cjs +215 -0
- package/dist/columns/column_collection_builder.cjs.map +1 -0
- package/dist/columns/column_collection_builder.d.ts +112 -0
- package/dist/columns/column_collection_builder.js +214 -0
- package/dist/columns/column_collection_builder.js.map +1 -0
- package/dist/columns/column_selector.cjs +122 -0
- package/dist/columns/column_selector.cjs.map +1 -0
- package/dist/columns/column_selector.d.ts +41 -0
- package/dist/columns/column_selector.js +118 -0
- package/dist/columns/column_selector.js.map +1 -0
- package/dist/columns/column_snapshot.cjs +20 -0
- package/dist/columns/column_snapshot.cjs.map +1 -0
- package/dist/columns/column_snapshot.d.ts +39 -0
- package/dist/columns/column_snapshot.js +18 -0
- package/dist/columns/column_snapshot.js.map +1 -0
- package/dist/columns/column_snapshot_provider.cjs +112 -0
- package/dist/columns/column_snapshot_provider.cjs.map +1 -0
- package/dist/columns/column_snapshot_provider.d.ts +73 -0
- package/dist/columns/column_snapshot_provider.js +107 -0
- package/dist/columns/column_snapshot_provider.js.map +1 -0
- package/dist/columns/ctx_column_sources.cjs +84 -0
- package/dist/columns/ctx_column_sources.cjs.map +1 -0
- package/dist/columns/ctx_column_sources.d.ts +33 -0
- package/dist/columns/ctx_column_sources.js +82 -0
- package/dist/columns/ctx_column_sources.js.map +1 -0
- package/dist/columns/index.cjs +5 -0
- package/dist/columns/index.d.ts +5 -0
- package/dist/columns/index.js +5 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs +111 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.d.ts +25 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js +110 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js.map +1 -0
- package/dist/components/PlDataTable/{table.cjs → createPlDataTable/createPlDataTableV3.cjs} +54 -54
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts +39 -0
- package/dist/components/PlDataTable/{table.js → createPlDataTable/createPlDataTableV3.js} +53 -53
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/index.cjs +12 -0
- package/dist/components/PlDataTable/createPlDataTable/index.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/index.d.ts +15 -0
- package/dist/components/PlDataTable/createPlDataTable/index.js +12 -0
- package/dist/components/PlDataTable/createPlDataTable/index.js.map +1 -0
- package/dist/components/PlDataTable/createPlDataTableSheet.cjs +18 -0
- package/dist/components/PlDataTable/createPlDataTableSheet.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTableSheet.d.ts +11 -0
- package/dist/components/PlDataTable/createPlDataTableSheet.js +17 -0
- package/dist/components/PlDataTable/createPlDataTableSheet.js.map +1 -0
- package/dist/components/PlDataTable/index.cjs +4 -1
- package/dist/components/PlDataTable/index.d.ts +5 -2
- package/dist/components/PlDataTable/index.js +4 -1
- package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
- package/dist/components/PlDataTable/state-migration.d.ts +2 -2
- package/dist/components/PlDataTable/state-migration.js.map +1 -1
- package/dist/components/PlDataTable/{v4.d.ts → typesV4.d.ts} +2 -2
- package/dist/components/PlDataTable/{v5.d.ts → typesV5.d.ts} +2 -2
- package/dist/components/index.cjs +4 -1
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.js +4 -1
- package/dist/index.cjs +44 -16
- package/dist/index.d.ts +17 -5
- package/dist/index.js +15 -3
- package/dist/labels/derive_distinct_labels.cjs +156 -0
- package/dist/labels/derive_distinct_labels.cjs.map +1 -0
- package/dist/labels/derive_distinct_labels.d.ts +29 -0
- package/dist/labels/derive_distinct_labels.js +155 -0
- package/dist/labels/derive_distinct_labels.js.map +1 -0
- package/dist/labels/index.cjs +2 -0
- package/dist/labels/index.d.ts +2 -0
- package/dist/labels/index.js +2 -0
- package/dist/labels/write_labels_to_specs.cjs +15 -0
- package/dist/labels/write_labels_to_specs.cjs.map +1 -0
- package/dist/labels/write_labels_to_specs.d.ts +9 -0
- package/dist/labels/write_labels_to_specs.js +14 -0
- package/dist/labels/write_labels_to_specs.js.map +1 -0
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/render/api.cjs +11 -2
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +9 -5
- package/dist/render/api.js +12 -3
- package/dist/render/api.js.map +1 -1
- package/dist/render/index.d.ts +2 -1
- package/dist/render/index.js +1 -1
- package/dist/render/internal.cjs.map +1 -1
- package/dist/render/internal.d.ts +5 -2
- package/dist/render/internal.js.map +1 -1
- package/dist/render/util/column_collection.cjs +3 -3
- package/dist/render/util/column_collection.cjs.map +1 -1
- package/dist/render/util/column_collection.d.ts +3 -2
- package/dist/render/util/column_collection.js +4 -4
- package/dist/render/util/column_collection.js.map +1 -1
- package/dist/render/util/index.d.ts +2 -1
- package/dist/render/util/index.js +1 -1
- package/dist/render/util/label.cjs +7 -134
- package/dist/render/util/label.cjs.map +1 -1
- package/dist/render/util/label.d.ts +5 -50
- package/dist/render/util/label.js +8 -132
- package/dist/render/util/label.js.map +1 -1
- package/dist/render/util/split_selectors.d.ts +2 -2
- package/package.json +9 -7
- package/src/block_storage.ts +0 -11
- package/src/block_storage_callbacks.ts +1 -1
- package/src/columns/column_collection_builder.test.ts +427 -0
- package/src/columns/column_collection_builder.ts +455 -0
- package/src/columns/column_selector.test.ts +472 -0
- package/src/columns/column_selector.ts +212 -0
- package/src/columns/column_snapshot.ts +55 -0
- package/src/columns/column_snapshot_provider.ts +177 -0
- package/src/columns/ctx_column_sources.ts +107 -0
- package/src/columns/expand_by_partition.test.ts +289 -0
- package/src/columns/expand_by_partition.ts +187 -0
- package/src/columns/index.ts +5 -0
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV2.ts +193 -0
- package/src/components/PlDataTable/{table.ts → createPlDataTable/createPlDataTableV3.ts} +134 -70
- package/src/components/PlDataTable/createPlDataTable/index.ts +27 -0
- package/src/components/PlDataTable/createPlDataTableSheet.ts +20 -0
- package/src/components/PlDataTable/index.ts +6 -4
- package/src/components/PlDataTable/state-migration.ts +2 -2
- package/src/index.ts +2 -1
- package/src/labels/derive_distinct_labels.test.ts +461 -0
- package/src/labels/derive_distinct_labels.ts +289 -0
- package/src/labels/index.ts +2 -0
- package/src/labels/write_labels_to_specs.ts +12 -0
- package/src/render/api.ts +25 -3
- package/src/render/internal.ts +20 -1
- package/src/render/util/column_collection.ts +9 -6
- package/src/render/util/label.test.ts +1 -1
- package/src/render/util/label.ts +19 -235
- package/src/render/util/split_selectors.ts +3 -3
- package/dist/components/PlDataTable/table.cjs.map +0 -1
- package/dist/components/PlDataTable/table.d.ts +0 -30
- package/dist/components/PlDataTable/table.js.map +0 -1
- /package/src/components/PlDataTable/{v4.ts → typesV4.ts} +0 -0
- /package/src/components/PlDataTable/{v5.ts → typesV5.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AxisId,
|
|
3
|
-
|
|
3
|
+
CanonicalizedJson,
|
|
4
4
|
DataInfo,
|
|
5
5
|
PColumn,
|
|
6
6
|
PColumnIdAndSpec,
|
|
@@ -15,7 +15,9 @@ import type {
|
|
|
15
15
|
SingleAxisSelector,
|
|
16
16
|
SpecQueryExpression,
|
|
17
17
|
SpecQueryJoinEntry,
|
|
18
|
-
|
|
18
|
+
PColumnSpec,
|
|
19
|
+
PlRef,
|
|
20
|
+
MultiColumnSelector,
|
|
19
21
|
} from "@milaboratories/pl-model-common";
|
|
20
22
|
import {
|
|
21
23
|
Annotation,
|
|
@@ -24,25 +26,28 @@ import {
|
|
|
24
26
|
getColumnIdAndSpec,
|
|
25
27
|
isLinkerColumn,
|
|
26
28
|
readAnnotation,
|
|
27
|
-
uniqueBy,
|
|
28
29
|
isBooleanExpression,
|
|
29
30
|
parseJson,
|
|
31
|
+
uniqueBy,
|
|
30
32
|
} from "@milaboratories/pl-model-common";
|
|
31
|
-
import { filterSpecToSpecQueryExpr } from "
|
|
32
|
-
import
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import type { CreatePlDataTableOps, PlDataTableFilters, PlDataTableModel } from "./v5";
|
|
37
|
-
import { upgradePlDataTableStateV2 } from "./state-migration";
|
|
38
|
-
import type { PlDataTableStateV2 } from "./state-migration";
|
|
39
|
-
import type { PlDataTableSheet } from "./v5";
|
|
40
|
-
import { getAllLabelColumns, getMatchingLabelColumns } from "./labels";
|
|
41
|
-
import { collectFilterSpecColumns } from "../../filters/traverse";
|
|
33
|
+
import { filterSpecToSpecQueryExpr } from "../../../filters";
|
|
34
|
+
import { collectFilterSpecColumns } from "../../../filters/traverse";
|
|
35
|
+
import type { RenderCtxBase, TreeNodeAccessor, PColumnDataUniversal } from "../../../render";
|
|
36
|
+
import { allPColumnsReady } from "../../../render";
|
|
37
|
+
import { isFunction, isNil } from "es-toolkit";
|
|
42
38
|
import { isEmpty } from "es-toolkit/compat";
|
|
39
|
+
import { distillFilterSpec } from "../../../filters/distill";
|
|
40
|
+
import type { PlDataTableFilters, PlDataTableModel } from "../typesV5";
|
|
41
|
+
import { upgradePlDataTableStateV2 } from "../state-migration";
|
|
42
|
+
import type { PlDataTableStateV2 } from "../state-migration";
|
|
43
|
+
import type { ColumnSource, MatchingMode } from "../../../columns";
|
|
44
|
+
import { ColumnCollectionBuilder } from "../../../columns";
|
|
45
|
+
import { isColumnSnapshotProvider } from "../../../columns/column_snapshot_provider";
|
|
46
|
+
import { collectCtxColumnSnapshotProviders } from "../../../columns/ctx_column_sources";
|
|
47
|
+
import { getAllLabelColumns, getMatchingLabelColumns } from "../labels";
|
|
43
48
|
|
|
44
49
|
/** Convert a PTableColumnId to a SpecQueryExpression reference. */
|
|
45
|
-
function columnIdToExpr(col: PTableColumnId): SpecQueryExpression {
|
|
50
|
+
export function columnIdToExpr(col: PTableColumnId): SpecQueryExpression {
|
|
46
51
|
if (col.type === "axis") {
|
|
47
52
|
return { type: "axisRef", value: col.id as SingleAxisSelector };
|
|
48
53
|
}
|
|
@@ -50,11 +55,11 @@ function columnIdToExpr(col: PTableColumnId): SpecQueryExpression {
|
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
/** Wrap a SpecQuery as a SpecQueryJoinEntry with empty qualifications. */
|
|
53
|
-
function joinEntry<C>(input: SpecQuery<C>): SpecQueryJoinEntry<C> {
|
|
58
|
+
export function joinEntry<C>(input: SpecQuery<C>): SpecQueryJoinEntry<C> {
|
|
54
59
|
return { entry: input, qualifications: [] };
|
|
55
60
|
}
|
|
56
61
|
|
|
57
|
-
function createPTableDef(params: {
|
|
62
|
+
export function createPTableDef(params: {
|
|
58
63
|
columns: PColumn<PColumnDataUniversal>[];
|
|
59
64
|
labelColumns: PColumn<PColumnDataUniversal>[];
|
|
60
65
|
coreJoinType: "inner" | "full";
|
|
@@ -133,45 +138,107 @@ export function isColumnOptional(spec: { annotations?: Annotation }): boolean {
|
|
|
133
138
|
return readAnnotation(spec, Annotation.Table.Visibility) === "optional";
|
|
134
139
|
}
|
|
135
140
|
|
|
136
|
-
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
/** Structured source config — selectors/anchors instead of raw ColumnSource. */
|
|
142
|
+
type ColumnsSelectorConfig = {
|
|
143
|
+
include?: MultiColumnSelector | MultiColumnSelector[];
|
|
144
|
+
exclude?: MultiColumnSelector | MultiColumnSelector[];
|
|
145
|
+
anchors?: Record<string, PlRef | PObjectId | PColumnSpec>;
|
|
146
|
+
mode?: MatchingMode;
|
|
147
|
+
maxHops?: number;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export type createPlDataTableOptionsV3 = {
|
|
151
|
+
source?: ColumnSource | ColumnSource[];
|
|
152
|
+
columns: ColumnsSelectorConfig;
|
|
153
|
+
|
|
154
|
+
// Existing from V2
|
|
155
|
+
filters?: PlDataTableFilters;
|
|
156
|
+
sorting?: PTableSorting[];
|
|
157
|
+
coreJoinType?: "inner" | "full";
|
|
158
|
+
coreColumnPredicate?: (spec: PColumnIdAndSpec) => boolean;
|
|
159
|
+
|
|
160
|
+
state?: PlDataTableStateV2;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// interface ColumnDisplayConfig {
|
|
164
|
+
// /** Column ordering rules. Higher priority = further left. First matching rule wins. */
|
|
165
|
+
// ordering?: ColumnOrderRule[];
|
|
166
|
+
// /** Column visibility rules. First matching rule wins. Unmatched columns use default visibility. */
|
|
167
|
+
// visibility?: ColumnVisibilityRule[];
|
|
168
|
+
// }
|
|
169
|
+
|
|
170
|
+
// interface ColumnOrderRule {
|
|
171
|
+
// match: ColumnMatcher;
|
|
172
|
+
// /** Higher number = further left in table */
|
|
173
|
+
// priority: number;
|
|
174
|
+
// }
|
|
175
|
+
|
|
176
|
+
// interface ColumnVisibilityRule {
|
|
177
|
+
// match: ColumnMatcher;
|
|
178
|
+
// visibility: "default" | "optional" | "hidden";
|
|
179
|
+
// }
|
|
180
|
+
|
|
181
|
+
// type ColumnMatcher =
|
|
182
|
+
// | ((spec: PColumnSpec) => boolean)
|
|
183
|
+
// | { name: string | string[] }
|
|
184
|
+
// | { annotation: Record<string, string> }
|
|
185
|
+
// | { ids: Set<string> };
|
|
186
|
+
|
|
187
|
+
export function createPlDataTableV3<A, U>(
|
|
145
188
|
ctx: RenderCtxBase<A, U>,
|
|
146
|
-
|
|
147
|
-
tableState: PlDataTableStateV2 | undefined,
|
|
148
|
-
ops?: CreatePlDataTableOps,
|
|
189
|
+
options: createPlDataTableOptionsV3,
|
|
149
190
|
): PlDataTableModel | undefined {
|
|
150
|
-
|
|
191
|
+
const providers = options.source
|
|
192
|
+
? normalizeSourceList(options.source).filter(isColumnSnapshotProvider)
|
|
193
|
+
: collectCtxColumnSnapshotProviders(ctx);
|
|
194
|
+
|
|
195
|
+
if (providers.length === 0) return undefined;
|
|
196
|
+
|
|
197
|
+
// Step 1: Build collection from sources
|
|
198
|
+
const builder = new ColumnCollectionBuilder(ctx).addSources(providers);
|
|
199
|
+
const anchors = options.columns.anchors;
|
|
200
|
+
const collection = isNil(anchors) ? builder.build() : builder.build({ anchors });
|
|
201
|
+
|
|
202
|
+
if (!collection) return undefined;
|
|
203
|
+
|
|
204
|
+
// Step 2: Get data columns, excluding annotation-hidden ones
|
|
205
|
+
const findOptions = options.columns
|
|
206
|
+
? {
|
|
207
|
+
include: options.columns.include,
|
|
208
|
+
exclude: options.columns.exclude,
|
|
209
|
+
mode: options.columns.mode,
|
|
210
|
+
maxHops: options.columns.maxHops,
|
|
211
|
+
}
|
|
212
|
+
: undefined;
|
|
213
|
+
const findResult = collection.findColumns(findOptions);
|
|
214
|
+
const snapshots = findResult.map((v) => ("column" in v ? v.column : v));
|
|
215
|
+
const dataSnapshots = snapshots.filter((s) => !isColumnHidden(s.spec));
|
|
216
|
+
if (dataSnapshots.length === 0) return undefined;
|
|
217
|
+
|
|
218
|
+
// Convert snapshots to PColumn<PColumnDataUniversal>[]
|
|
219
|
+
const columns: PColumn<PColumnDataUniversal>[] = [];
|
|
220
|
+
for (const snap of dataSnapshots) {
|
|
221
|
+
if (!snap.data) return undefined;
|
|
222
|
+
const data = snap.data.get();
|
|
223
|
+
if (data === undefined) return undefined;
|
|
224
|
+
columns.push({ id: snap.id, spec: snap.spec, data });
|
|
225
|
+
}
|
|
151
226
|
|
|
152
|
-
|
|
227
|
+
// Step 3: Normalize table state
|
|
228
|
+
const tableStateNormalized = upgradePlDataTableStateV2(options.state);
|
|
153
229
|
|
|
230
|
+
// Step 4: Get label columns from result pool and match to data columns
|
|
154
231
|
const allLabelColumns = getAllLabelColumns(ctx.resultPool);
|
|
155
232
|
if (!allLabelColumns) return undefined;
|
|
156
233
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
...v.value,
|
|
162
|
-
spec: {
|
|
163
|
-
...v.value.spec,
|
|
164
|
-
annotations: {
|
|
165
|
-
...v.value.spec.annotations,
|
|
166
|
-
[Annotation.Label]: v.label,
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
},
|
|
234
|
+
const fullLabelColumns = getMatchingLabelColumns(
|
|
235
|
+
columns.map(getColumnIdAndSpec),
|
|
236
|
+
allLabelColumns,
|
|
171
237
|
);
|
|
172
238
|
|
|
173
239
|
const fullColumns = [...columns, ...fullLabelColumns];
|
|
174
240
|
|
|
241
|
+
// Step 5: Build column ID set for filter/sorting validation
|
|
175
242
|
const fullColumnsAxes = uniqueBy(
|
|
176
243
|
fullColumns.flatMap((c) => c.spec.axesSpec.map((a) => getAxisId(a))),
|
|
177
244
|
(a) => canonicalizeJson<AxisId>(a),
|
|
@@ -184,9 +251,9 @@ export function createPlDataTableV2<A, U>(
|
|
|
184
251
|
const isValidColumnId = (id: string): boolean =>
|
|
185
252
|
fullColumnsIdsSet.has(id as CanonicalizedJson<PTableColumnId>);
|
|
186
253
|
|
|
187
|
-
//
|
|
254
|
+
// Step 6: Filtering validation
|
|
188
255
|
const stateFilters = tableStateNormalized.pTableParams.filters;
|
|
189
|
-
const opsFilters =
|
|
256
|
+
const opsFilters = options?.filters ?? null;
|
|
190
257
|
const filters: null | PlDataTableFilters =
|
|
191
258
|
stateFilters != null && opsFilters != null
|
|
192
259
|
? { type: "and", filters: [stateFilters, opsFilters] }
|
|
@@ -198,9 +265,9 @@ export function createPlDataTableV2<A, U>(
|
|
|
198
265
|
`Invalid filter column ${firstInvalidFilterColumn}: column reference does not match the table columns`,
|
|
199
266
|
);
|
|
200
267
|
|
|
201
|
-
//
|
|
268
|
+
// Step 7: Sorting validation
|
|
202
269
|
const userSorting = tableStateNormalized.pTableParams.sorting;
|
|
203
|
-
const sorting = (isEmpty(userSorting) ?
|
|
270
|
+
const sorting = (isEmpty(userSorting) ? options?.sorting : userSorting) ?? [];
|
|
204
271
|
const firstInvalidSortingColumn = sorting.find(
|
|
205
272
|
(s) => !isValidColumnId(canonicalizeJson<PTableColumnId>(s.column)),
|
|
206
273
|
);
|
|
@@ -209,23 +276,25 @@ export function createPlDataTableV2<A, U>(
|
|
|
209
276
|
`Invalid sorting column ${JSON.stringify(firstInvalidSortingColumn.column)}: column reference does not match the table columns`,
|
|
210
277
|
);
|
|
211
278
|
|
|
212
|
-
|
|
279
|
+
// Step 8: Build full table definition and handles
|
|
280
|
+
const coreJoinType = options?.coreJoinType ?? "full";
|
|
213
281
|
const fullDef = createPTableDef({
|
|
214
282
|
columns,
|
|
215
283
|
labelColumns: fullLabelColumns,
|
|
216
284
|
coreJoinType,
|
|
217
285
|
filters,
|
|
218
286
|
sorting,
|
|
219
|
-
coreColumnPredicate:
|
|
287
|
+
coreColumnPredicate: options?.coreColumnPredicate,
|
|
220
288
|
});
|
|
221
289
|
|
|
222
290
|
const fullHandle = ctx.createPTableV2(fullDef);
|
|
223
291
|
const pframeHandle = ctx.createPFrame(fullColumns);
|
|
224
292
|
if (!fullHandle || !pframeHandle) return undefined;
|
|
225
293
|
|
|
294
|
+
// Step 9: Determine hidden columns
|
|
226
295
|
const hiddenColumns = new Set<PObjectId>(
|
|
227
296
|
((): PObjectId[] => {
|
|
228
|
-
// Inner join works as a filter
|
|
297
|
+
// Inner join works as a filter — all columns must be present
|
|
229
298
|
if (coreJoinType === "inner") return [];
|
|
230
299
|
|
|
231
300
|
const hiddenColIds = tableStateNormalized.pTableParams.hiddenColIds;
|
|
@@ -238,8 +307,8 @@ export function createPlDataTableV2<A, U>(
|
|
|
238
307
|
// Preserve linker columns
|
|
239
308
|
columns.filter((c) => isLinkerColumn(c.spec)).forEach((c) => hiddenColumns.delete(c.id));
|
|
240
309
|
|
|
241
|
-
// Preserve core columns as they change the shape of join
|
|
242
|
-
const coreColumnPredicate =
|
|
310
|
+
// Preserve core columns as they change the shape of join
|
|
311
|
+
const coreColumnPredicate = options?.coreColumnPredicate;
|
|
243
312
|
if (coreColumnPredicate) {
|
|
244
313
|
const coreColumns = columns.flatMap((c) =>
|
|
245
314
|
coreColumnPredicate(getColumnIdAndSpec(c)) ? [c.id] : [],
|
|
@@ -263,13 +332,13 @@ export function createPlDataTableV2<A, U>(
|
|
|
263
332
|
.forEach((c) => hiddenColumns.delete(c));
|
|
264
333
|
}
|
|
265
334
|
|
|
335
|
+
// Step 10: Build visible table definition
|
|
266
336
|
const visibleColumns = columns.filter((c) => !hiddenColumns.has(c.id));
|
|
267
337
|
const visibleLabelColumns = getMatchingLabelColumns(
|
|
268
338
|
visibleColumns.map(getColumnIdAndSpec),
|
|
269
339
|
allLabelColumns,
|
|
270
340
|
);
|
|
271
341
|
|
|
272
|
-
// if at least one column is not yet computed, we can't show the table
|
|
273
342
|
if (!allPColumnsReady([...visibleColumns, ...visibleLabelColumns])) return undefined;
|
|
274
343
|
|
|
275
344
|
const visibleDef = createPTableDef({
|
|
@@ -292,19 +361,14 @@ export function createPlDataTableV2<A, U>(
|
|
|
292
361
|
} satisfies PlDataTableModel;
|
|
293
362
|
}
|
|
294
363
|
|
|
295
|
-
/**
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
)
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
value: v,
|
|
306
|
-
label: labels?.[v] ?? v.toString(),
|
|
307
|
-
})),
|
|
308
|
-
defaultValue: values[0],
|
|
309
|
-
};
|
|
364
|
+
/** Normalize raw ColumnSource | ColumnSource[] into a flat list of sources. */
|
|
365
|
+
function normalizeSourceList(source: ColumnSource | ColumnSource[]): ColumnSource[] {
|
|
366
|
+
if (
|
|
367
|
+
Array.isArray(source) &&
|
|
368
|
+
source.length > 0 &&
|
|
369
|
+
(Array.isArray(source[0]) || isColumnSnapshotProvider(source[0]))
|
|
370
|
+
) {
|
|
371
|
+
return source as ColumnSource[];
|
|
372
|
+
}
|
|
373
|
+
return [source as ColumnSource];
|
|
310
374
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RenderCtxBase } from "../../../render";
|
|
2
|
+
import type { PlDataTableModel } from "../typesV5";
|
|
3
|
+
import { createPlDataTableOptionsV2, createPlDataTableV2 } from "./createPlDataTableV2";
|
|
4
|
+
import { createPlDataTableV3 } from "./createPlDataTableV3";
|
|
5
|
+
import type { createPlDataTableOptionsV3 } from "./createPlDataTableV3";
|
|
6
|
+
|
|
7
|
+
export function createPlDataTable<A, U>(
|
|
8
|
+
ctx: RenderCtxBase<A, U>,
|
|
9
|
+
options: { version: "v2" } & createPlDataTableOptionsV2,
|
|
10
|
+
): ReturnType<typeof createPlDataTableV2>;
|
|
11
|
+
export function createPlDataTable<A, U>(
|
|
12
|
+
ctx: RenderCtxBase<A, U>,
|
|
13
|
+
options: { version?: "v3" } & createPlDataTableOptionsV3,
|
|
14
|
+
): ReturnType<typeof createPlDataTableV3>;
|
|
15
|
+
export function createPlDataTable<A, U>(
|
|
16
|
+
ctx: RenderCtxBase<A, U>,
|
|
17
|
+
options:
|
|
18
|
+
| ({ version: "v2" } & createPlDataTableOptionsV2)
|
|
19
|
+
| ({ version?: "v3" } & createPlDataTableOptionsV3),
|
|
20
|
+
): PlDataTableModel | undefined {
|
|
21
|
+
if (options.version === "v2") {
|
|
22
|
+
return createPlDataTableV2(ctx, options.columns, options.tableState, options.options);
|
|
23
|
+
} else {
|
|
24
|
+
// default version is last (v3 at the moment)
|
|
25
|
+
return createPlDataTableV3(ctx, options);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AxisSpec } from "@milaboratories/pl-model-common";
|
|
2
|
+
import type { RenderCtxBase } from "../../render";
|
|
3
|
+
import type { PlDataTableSheet } from "./typesV5";
|
|
4
|
+
|
|
5
|
+
/** Create sheet entries for PlDataTable */
|
|
6
|
+
export function createPlDataTableSheet<A, U>(
|
|
7
|
+
ctx: RenderCtxBase<A, U>,
|
|
8
|
+
axis: AxisSpec,
|
|
9
|
+
values: (string | number)[],
|
|
10
|
+
): PlDataTableSheet {
|
|
11
|
+
const labels = ctx.resultPool.findLabels(axis);
|
|
12
|
+
return {
|
|
13
|
+
axis,
|
|
14
|
+
options: values.map((v) => ({
|
|
15
|
+
value: v,
|
|
16
|
+
label: labels?.[v] ?? v.toString(),
|
|
17
|
+
})),
|
|
18
|
+
defaultValue: values[0],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -12,7 +12,7 @@ export type {
|
|
|
12
12
|
PlDataTableModel,
|
|
13
13
|
PlDataTableFilters,
|
|
14
14
|
PlDataTableFiltersWithMeta,
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./typesV5";
|
|
16
16
|
|
|
17
17
|
export type { PlDataTableStateV2 } from "./state-migration";
|
|
18
18
|
export {
|
|
@@ -21,9 +21,11 @@ export {
|
|
|
21
21
|
createPlDataTableStateV2,
|
|
22
22
|
} from "./state-migration";
|
|
23
23
|
|
|
24
|
+
export { createPlDataTableSheet } from "./createPlDataTableSheet";
|
|
25
|
+
export { createPlDataTable } from "./createPlDataTable";
|
|
26
|
+
export { createPlDataTableV2 } from "./createPlDataTable/createPlDataTableV2";
|
|
24
27
|
export {
|
|
25
28
|
isColumnHidden,
|
|
26
29
|
isColumnOptional,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} from "./table";
|
|
30
|
+
createPlDataTableV3,
|
|
31
|
+
} from "./createPlDataTable/createPlDataTableV3";
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
} from "@milaboratories/pl-model-common";
|
|
10
10
|
import { canonicalizeJson } from "@milaboratories/pl-model-common";
|
|
11
11
|
import { distillFilterSpec } from "../../filters";
|
|
12
|
-
import type { PlDataTableFilterState, PlTableFilter } from "./
|
|
12
|
+
import type { PlDataTableFilterState, PlTableFilter } from "./typesV4";
|
|
13
13
|
import type {
|
|
14
14
|
PlDataTableFiltersWithMeta,
|
|
15
15
|
PlDataTableGridStateCore,
|
|
@@ -17,7 +17,7 @@ import type {
|
|
|
17
17
|
PlDataTableStateV2CacheEntry,
|
|
18
18
|
PlDataTableStateV2Normalized,
|
|
19
19
|
PTableParamsV2,
|
|
20
|
-
} from "./
|
|
20
|
+
} from "./typesV5";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* PlDataTableV2 persisted state
|
package/src/index.ts
CHANGED
|
@@ -14,7 +14,6 @@ export {
|
|
|
14
14
|
deriveDataFromStorage,
|
|
15
15
|
type MutateStoragePayload,
|
|
16
16
|
updateStorageData,
|
|
17
|
-
type StorageDebugView,
|
|
18
17
|
type MigrationSuccess,
|
|
19
18
|
type MigrationFailure,
|
|
20
19
|
type MigrationResult,
|
|
@@ -42,6 +41,8 @@ export * from "./bconfig";
|
|
|
42
41
|
export * from "./components";
|
|
43
42
|
export * from "./config";
|
|
44
43
|
export * from "./pframe";
|
|
44
|
+
export * from "./labels";
|
|
45
|
+
export * from "./columns";
|
|
45
46
|
export * from "./platforma";
|
|
46
47
|
export * from "./ref_util";
|
|
47
48
|
export * from "./render";
|