@platforma-sdk/model 1.63.12 → 1.64.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/columns/column_collection_builder.cjs +105 -92
- package/dist/columns/column_collection_builder.cjs.map +1 -1
- package/dist/columns/column_collection_builder.d.ts +13 -12
- package/dist/columns/column_collection_builder.d.ts.map +1 -1
- package/dist/columns/column_collection_builder.js +107 -94
- package/dist/columns/column_collection_builder.js.map +1 -1
- package/dist/columns/column_selector.cjs +8 -80
- package/dist/columns/column_selector.cjs.map +1 -1
- package/dist/columns/column_selector.d.ts +6 -14
- package/dist/columns/column_selector.d.ts.map +1 -1
- package/dist/columns/column_selector.js +6 -77
- package/dist/columns/column_selector.js.map +1 -1
- package/dist/columns/column_snapshot.cjs +3 -3
- package/dist/columns/column_snapshot.cjs.map +1 -1
- package/dist/columns/column_snapshot.d.ts +3 -3
- package/dist/columns/column_snapshot.d.ts.map +1 -1
- package/dist/columns/column_snapshot.js +3 -3
- package/dist/columns/column_snapshot.js.map +1 -1
- package/dist/columns/column_snapshot_provider.cjs +1 -1
- package/dist/columns/column_snapshot_provider.cjs.map +1 -1
- package/dist/columns/column_snapshot_provider.d.ts +8 -8
- package/dist/columns/column_snapshot_provider.d.ts.map +1 -1
- package/dist/columns/column_snapshot_provider.js +1 -1
- package/dist/columns/column_snapshot_provider.js.map +1 -1
- package/dist/columns/ctx_column_sources.cjs.map +1 -1
- package/dist/columns/ctx_column_sources.d.ts +2 -1
- package/dist/columns/ctx_column_sources.d.ts.map +1 -1
- package/dist/columns/ctx_column_sources.js.map +1 -1
- package/dist/columns/expand_by_partition.cjs +106 -0
- package/dist/columns/expand_by_partition.cjs.map +1 -0
- package/dist/columns/expand_by_partition.d.ts +33 -0
- package/dist/columns/expand_by_partition.d.ts.map +1 -0
- package/dist/columns/expand_by_partition.js +105 -0
- package/dist/columns/expand_by_partition.js.map +1 -0
- package/dist/columns/index.cjs +1 -0
- package/dist/columns/index.d.ts +4 -3
- package/dist/columns/index.js +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV2.cjs +26 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV2.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV2.js +25 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV2.js.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV3.cjs +68 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV3.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV3.js +67 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV3.js.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs +20 -9
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.d.ts +4 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js +21 -10
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs +257 -175
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts +37 -21
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js +260 -175
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.cjs +64 -0
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.d.ts +17 -0
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.d.ts.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.js +63 -0
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.js.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/index.cjs +2 -1
- package/dist/components/PlDataTable/createPlDataTable/index.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/index.d.ts +2 -1
- package/dist/components/PlDataTable/createPlDataTable/index.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/index.js +2 -1
- package/dist/components/PlDataTable/createPlDataTable/index.js.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/utils.cjs +109 -0
- package/dist/components/PlDataTable/createPlDataTable/utils.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/utils.d.ts +19 -0
- package/dist/components/PlDataTable/createPlDataTable/utils.d.ts.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/utils.js +102 -0
- package/dist/components/PlDataTable/createPlDataTable/utils.js.map +1 -0
- package/dist/components/PlDataTable/index.cjs +3 -1
- package/dist/components/PlDataTable/index.d.ts +4 -2
- package/dist/components/PlDataTable/index.js +3 -1
- package/dist/components/PlDataTable/labels.cjs +25 -11
- package/dist/components/PlDataTable/labels.cjs.map +1 -1
- package/dist/components/PlDataTable/labels.js +25 -11
- package/dist/components/PlDataTable/labels.js.map +1 -1
- package/dist/components/PlDataTable/state-migration.cjs +4 -1
- package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
- package/dist/components/PlDataTable/state-migration.d.ts.map +1 -1
- package/dist/components/PlDataTable/state-migration.js +4 -1
- package/dist/components/PlDataTable/state-migration.js.map +1 -1
- package/dist/components/PlDataTable/typesV5.d.ts +5 -4
- package/dist/components/PlDataTable/typesV5.d.ts.map +1 -1
- package/dist/components/index.cjs +3 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +3 -1
- package/dist/index.cjs +13 -9
- package/dist/index.d.ts +8 -6
- package/dist/index.js +6 -4
- package/dist/labels/derive_distinct_labels.cjs +39 -27
- package/dist/labels/derive_distinct_labels.cjs.map +1 -1
- package/dist/labels/derive_distinct_labels.d.ts +15 -15
- package/dist/labels/derive_distinct_labels.d.ts.map +1 -1
- package/dist/labels/derive_distinct_labels.js +39 -27
- package/dist/labels/derive_distinct_labels.js.map +1 -1
- package/dist/labels/index.cjs +0 -1
- package/dist/labels/index.d.ts +1 -2
- package/dist/labels/index.js +0 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/render/api.cjs +10 -3
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +2 -2
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/api.js +10 -3
- package/dist/render/api.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.map +1 -1
- package/dist/render/util/column_collection.js +3 -3
- package/dist/render/util/column_collection.js.map +1 -1
- package/dist/render/util/label.cjs +2 -2
- package/dist/render/util/label.cjs.map +1 -1
- package/dist/render/util/label.js +2 -2
- package/dist/render/util/label.js.map +1 -1
- package/dist/render/util/pcolumn_data.cjs.map +1 -1
- package/dist/render/util/pcolumn_data.d.ts +2 -2
- package/dist/render/util/pcolumn_data.d.ts.map +1 -1
- package/dist/render/util/pcolumn_data.js.map +1 -1
- package/package.json +6 -6
- package/src/columns/column_collection_builder.test.ts +40 -27
- package/src/columns/column_collection_builder.ts +176 -131
- package/src/columns/column_selector.test.ts +17 -399
- package/src/columns/column_selector.ts +14 -127
- package/src/columns/column_snapshot.ts +5 -5
- package/src/columns/column_snapshot_provider.ts +11 -10
- package/src/columns/ctx_column_sources.ts +2 -2
- package/src/columns/expand_by_partition.test.ts +4 -4
- package/src/columns/expand_by_partition.ts +4 -3
- package/src/columns/index.ts +1 -0
- package/src/components/PlDataTable/createPlDataTable/createPTableDefV2.ts +42 -0
- package/src/components/PlDataTable/createPlDataTable/createPTableDefV3.ts +89 -0
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV2.ts +39 -11
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV3.ts +502 -313
- package/src/components/PlDataTable/createPlDataTable/discoverColumns.ts +122 -0
- package/src/components/PlDataTable/createPlDataTable/index.ts +4 -2
- package/src/components/PlDataTable/createPlDataTable/utils.test.ts +257 -0
- package/src/components/PlDataTable/createPlDataTable/utils.ts +160 -0
- package/src/components/PlDataTable/index.ts +13 -2
- package/src/components/PlDataTable/labels.ts +29 -18
- package/src/components/PlDataTable/state-migration.ts +3 -1
- package/src/components/PlDataTable/typesV5.ts +4 -4
- package/src/labels/derive_distinct_labels.test.ts +143 -45
- package/src/labels/derive_distinct_labels.ts +102 -49
- package/src/labels/index.ts +0 -1
- package/src/render/api.ts +15 -5
- package/src/render/util/column_collection.ts +4 -3
- package/src/render/util/label.ts +2 -2
- package/src/render/util/pcolumn_data.ts +5 -3
- package/dist/labels/write_labels_to_specs.cjs +0 -14
- package/dist/labels/write_labels_to_specs.cjs.map +0 -1
- package/dist/labels/write_labels_to_specs.d.ts +0 -7
- package/dist/labels/write_labels_to_specs.d.ts.map +0 -1
- package/dist/labels/write_labels_to_specs.js +0 -13
- package/dist/labels/write_labels_to_specs.js.map +0 -1
- package/src/labels/write_labels_to_specs.ts +0 -12
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require("../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_column_snapshot_provider = require("../../../columns/column_snapshot_provider.cjs");
|
|
3
|
+
const require_column_collection_builder = require("../../../columns/column_collection_builder.cjs");
|
|
4
|
+
const require_ctx_column_sources = require("../../../columns/ctx_column_sources.cjs");
|
|
5
|
+
require("../../../columns/index.cjs");
|
|
6
|
+
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
7
|
+
let _milaboratories_helpers = require("@milaboratories/helpers");
|
|
8
|
+
//#region src/components/PlDataTable/createPlDataTable/discoverColumns.ts
|
|
9
|
+
/** Discover columns from sources/anchors and normalize into a flat DiscoveredColumn list. */
|
|
10
|
+
function discoverTableColumnSnaphots(ctx, options) {
|
|
11
|
+
const resolvedOptions = {
|
|
12
|
+
...options,
|
|
13
|
+
anchors: resolveAnchors(ctx, options.anchors)
|
|
14
|
+
};
|
|
15
|
+
const providers = resolveProviders(ctx, resolvedOptions.sources);
|
|
16
|
+
if (providers.length === 0) return void 0;
|
|
17
|
+
const collection = new require_column_collection_builder.ColumnCollectionBuilder(ctx.services.pframeSpec ?? (0, _milaboratories_helpers.throwError)("PFrameSpec service is required for column discovery.")).addSources(providers).build(resolvedOptions);
|
|
18
|
+
if (collection === void 0) return void 0;
|
|
19
|
+
try {
|
|
20
|
+
const matched = collection.findColumns(resolvedOptions.columnsSelector ?? void 0);
|
|
21
|
+
const anchors = collection.getAnchors();
|
|
22
|
+
return mapToDiscoveredColumns(matched, Array.from(Array.from(anchors.values()).map((v) => v.columnId)));
|
|
23
|
+
} finally {
|
|
24
|
+
collection.dispose();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Resolve PlRef values in anchors to PColumnSpec via the result pool. */
|
|
28
|
+
function resolveAnchors(ctx, anchors) {
|
|
29
|
+
const result = {};
|
|
30
|
+
for (const [key, value] of Object.entries(anchors)) if ((0, _milaboratories_pl_model_common.isPlRef)(value)) result[key] = ctx.resultPool.getPColumnSpecByRef(value) ?? (0, _milaboratories_helpers.throwError)(`Anchor ${key} with ref ${JSON.stringify(value)} could not be resolved to a PColumnSpec`);
|
|
31
|
+
else result[key] = value;
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
/** Resolve column snapshot providers from explicit sources or context. */
|
|
35
|
+
function resolveProviders(ctx, sources) {
|
|
36
|
+
return sources !== void 0 ? sources.map(require_column_snapshot_provider.toColumnSnapshotProvider) : require_ctx_column_sources.collectCtxColumnSnapshotProviders(ctx);
|
|
37
|
+
}
|
|
38
|
+
/** Map matched columns into a flat DiscoveredColumn list with deduped IDs. */
|
|
39
|
+
function mapToDiscoveredColumns(matched, anchorColumnIds) {
|
|
40
|
+
const hitCounts = matched.reduce((acc, match) => acc.set(match.originalId, (acc.get(match.originalId) ?? 0) + 1), /* @__PURE__ */ new Map());
|
|
41
|
+
const hitIndices = /* @__PURE__ */ new Map();
|
|
42
|
+
return matched.map((match) => {
|
|
43
|
+
const snap = match.column;
|
|
44
|
+
let id = snap.id;
|
|
45
|
+
if ((hitCounts.get(match.originalId) ?? 0) > 1) {
|
|
46
|
+
const idx = hitIndices.get(match.originalId) ?? 0;
|
|
47
|
+
hitIndices.set(match.originalId, idx + 1);
|
|
48
|
+
id = `${snap.id}#q${idx}`;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
id,
|
|
52
|
+
originalId: match.originalId,
|
|
53
|
+
spec: snap.spec,
|
|
54
|
+
data: snap.data,
|
|
55
|
+
dataStatus: snap.dataStatus,
|
|
56
|
+
isPrimary: anchorColumnIds.some((anchor) => snap.id === anchor || match.originalId === anchor),
|
|
57
|
+
linkerPath: match.path
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
exports.discoverTableColumnSnaphots = discoverTableColumnSnaphots;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=discoverColumns.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoverColumns.cjs","names":["ColumnCollectionBuilder","toColumnSnapshotProvider","collectCtxColumnSnapshotProviders"],"sources":["../../../../src/components/PlDataTable/createPlDataTable/discoverColumns.ts"],"sourcesContent":["import type {\n PColumnSpec,\n PlRef,\n PObjectId,\n RequireServices,\n Services,\n SUniversalPColumnId,\n} from \"@milaboratories/pl-model-common\";\nimport { isPlRef } from \"@milaboratories/pl-model-common\";\nimport type { RenderCtxBase } from \"../../../render\";\nimport type { ColumnSource, ColumnMatch, RelaxedColumnSelector } from \"../../../columns\";\nimport { ColumnCollectionBuilder } from \"../../../columns\";\nimport { toColumnSnapshotProvider } from \"../../../columns/column_snapshot_provider\";\nimport { collectCtxColumnSnapshotProviders } from \"../../../columns/ctx_column_sources\";\nimport { throwError } from \"@milaboratories/helpers\";\nimport type { ColumnsSelectorConfig, TableColumnSnapshot } from \"./createPlDataTableV3\";\n\nexport type DiscoveredTableColumnOptions = {\n sources?: ColumnSource[];\n anchors: Record<string, PlRef | PObjectId | PColumnSpec | RelaxedColumnSelector>;\n columnsSelector: ColumnsSelectorConfig;\n};\n\n/** Discover columns from sources/anchors and normalize into a flat DiscoveredColumn list. */\nexport function discoverTableColumnSnaphots<\n A,\n U,\n S extends RequireServices<typeof Services.PFrameSpec>,\n>(\n ctx: RenderCtxBase<A, U, S>,\n options: DiscoveredTableColumnOptions,\n): TableColumnSnapshot<SUniversalPColumnId>[] | undefined {\n // Resolve PlRef anchors to PColumnSpec\n const resolvedOptions = { ...options, anchors: resolveAnchors(ctx, options.anchors) };\n\n // Resolve providers\n const providers = resolveProviders(ctx, resolvedOptions.sources);\n if (providers.length === 0) return undefined;\n\n // Build collection (anchored or plain)\n const pframeSpec =\n ctx.services.pframeSpec ?? throwError(\"PFrameSpec service is required for column discovery.\");\n const collection = new ColumnCollectionBuilder(pframeSpec)\n .addSources(providers)\n .build(resolvedOptions);\n if (collection === undefined) return undefined;\n\n try {\n const matched = collection.findColumns(resolvedOptions.columnsSelector ?? undefined);\n const anchors = collection.getAnchors();\n return mapToDiscoveredColumns(\n matched,\n Array.from(Array.from(anchors.values()).map((v) => v.columnId)),\n );\n } finally {\n collection.dispose();\n }\n}\n\n// --- Pure helper functions ---\n\n/** Resolve PlRef values in anchors to PColumnSpec via the result pool. */\nfunction resolveAnchors<A, U>(\n ctx: RenderCtxBase<A, U>,\n anchors: Record<string, PlRef | PObjectId | PColumnSpec | RelaxedColumnSelector>,\n): Record<string, PObjectId | PColumnSpec | RelaxedColumnSelector> {\n const result: Record<string, PObjectId | PColumnSpec | RelaxedColumnSelector> = {};\n for (const [key, value] of Object.entries(anchors)) {\n if (isPlRef(value)) {\n result[key] =\n ctx.resultPool.getPColumnSpecByRef(value) ??\n throwError(\n `Anchor ${key} with ref ${JSON.stringify(value)} could not be resolved to a PColumnSpec`,\n );\n } else {\n result[key] = value;\n }\n }\n return result;\n}\n\n/** Resolve column snapshot providers from explicit sources or context. */\nfunction resolveProviders<A, U>(ctx: RenderCtxBase<A, U>, sources: undefined | ColumnSource[]) {\n return sources !== undefined\n ? sources.map(toColumnSnapshotProvider)\n : collectCtxColumnSnapshotProviders(ctx);\n}\n\n/** Map matched columns into a flat DiscoveredColumn list with deduped IDs. */\nfunction mapToDiscoveredColumns(\n matched: readonly ColumnMatch[],\n anchorColumnIds: readonly PObjectId[],\n): TableColumnSnapshot<SUniversalPColumnId>[] {\n const hitCounts = matched.reduce(\n (acc, match) => acc.set(match.originalId, (acc.get(match.originalId) ?? 0) + 1),\n new Map<PObjectId, number>(),\n );\n\n const hitIndices = new Map<PObjectId, number>();\n return matched.map((match) => {\n const snap = match.column;\n\n let id = snap.id;\n if ((hitCounts.get(match.originalId) ?? 0) > 1) {\n const idx = hitIndices.get(match.originalId) ?? 0;\n hitIndices.set(match.originalId, idx + 1);\n id = `${snap.id}#q${idx}` as SUniversalPColumnId;\n }\n\n return {\n id,\n originalId: match.originalId,\n spec: snap.spec,\n data: snap.data,\n dataStatus: snap.dataStatus,\n isPrimary: anchorColumnIds.some(\n (anchor) => snap.id === anchor || match.originalId === anchor,\n ),\n linkerPath: match.path,\n };\n });\n}\n"],"mappings":";;;;;;;;;AAwBA,SAAgB,4BAKd,KACA,SACwD;CAExD,MAAM,kBAAkB;EAAE,GAAG;EAAS,SAAS,eAAe,KAAK,QAAQ,QAAQ;EAAE;CAGrF,MAAM,YAAY,iBAAiB,KAAK,gBAAgB,QAAQ;AAChE,KAAI,UAAU,WAAW,EAAG,QAAO,KAAA;CAKnC,MAAM,aAAa,IAAIA,kCAAAA,wBADrB,IAAI,SAAS,eAAA,GAAA,wBAAA,YAAyB,uDAAuD,CACrC,CACvD,WAAW,UAAU,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ClB,MAAM,KAAK;GACX,MAAM,KAAK;GACX,YAAY,KAAK;GACjB,WAAW,gBAAgB,MACxB,WAAW,KAAK,OAAO,UAAU,MAAM,eAAe,OACxD;GACD,YAAY,MAAM;GACnB;GACD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RenderCtxBase } from "../../../render/api.js";
|
|
2
|
+
import { ColumnSource } from "../../../columns/column_snapshot_provider.js";
|
|
3
|
+
import { RelaxedColumnSelector } from "../../../columns/column_selector.js";
|
|
4
|
+
import { ColumnsSelectorConfig, TableColumnSnapshot } from "./createPlDataTableV3.js";
|
|
5
|
+
import { PColumnSpec, PObjectId, PlRef, RequireServices, SUniversalPColumnId, Services } from "@milaboratories/pl-model-common";
|
|
6
|
+
|
|
7
|
+
//#region src/components/PlDataTable/createPlDataTable/discoverColumns.d.ts
|
|
8
|
+
type DiscoveredTableColumnOptions = {
|
|
9
|
+
sources?: ColumnSource[];
|
|
10
|
+
anchors: Record<string, PlRef | PObjectId | PColumnSpec | RelaxedColumnSelector>;
|
|
11
|
+
columnsSelector: ColumnsSelectorConfig;
|
|
12
|
+
};
|
|
13
|
+
/** Discover columns from sources/anchors and normalize into a flat DiscoveredColumn list. */
|
|
14
|
+
declare function discoverTableColumnSnaphots<A, U, S extends RequireServices<typeof Services.PFrameSpec>>(ctx: RenderCtxBase<A, U, S>, options: DiscoveredTableColumnOptions): TableColumnSnapshot<SUniversalPColumnId>[] | undefined;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { DiscoveredTableColumnOptions, discoverTableColumnSnaphots };
|
|
17
|
+
//# sourceMappingURL=discoverColumns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoverColumns.d.ts","names":[],"sources":["../../../../src/components/PlDataTable/createPlDataTable/discoverColumns.ts"],"mappings":";;;;;;;KAiBY,4BAAA;EACV,OAAA,GAAU,YAAA;EACV,OAAA,EAAS,MAAA,SAAe,KAAA,GAAQ,SAAA,GAAY,WAAA,GAAc,qBAAA;EAC1D,eAAA,EAAiB,qBAAA;AAAA;AAHnB;AAAA,iBAOgB,2BAAA,iBAGJ,eAAA,QAAuB,QAAA,CAAS,UAAA,EAAA,CAE1C,GAAA,EAAK,aAAA,CAAc,CAAA,EAAG,CAAA,EAAG,CAAA,GACzB,OAAA,EAAS,4BAAA,GACR,mBAAA,CAAoB,mBAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { toColumnSnapshotProvider } from "../../../columns/column_snapshot_provider.js";
|
|
2
|
+
import { ColumnCollectionBuilder } from "../../../columns/column_collection_builder.js";
|
|
3
|
+
import { collectCtxColumnSnapshotProviders } from "../../../columns/ctx_column_sources.js";
|
|
4
|
+
import "../../../columns/index.js";
|
|
5
|
+
import { isPlRef } from "@milaboratories/pl-model-common";
|
|
6
|
+
import { throwError } from "@milaboratories/helpers";
|
|
7
|
+
//#region src/components/PlDataTable/createPlDataTable/discoverColumns.ts
|
|
8
|
+
/** Discover columns from sources/anchors and normalize into a flat DiscoveredColumn list. */
|
|
9
|
+
function discoverTableColumnSnaphots(ctx, options) {
|
|
10
|
+
const resolvedOptions = {
|
|
11
|
+
...options,
|
|
12
|
+
anchors: resolveAnchors$1(ctx, options.anchors)
|
|
13
|
+
};
|
|
14
|
+
const providers = resolveProviders(ctx, resolvedOptions.sources);
|
|
15
|
+
if (providers.length === 0) return void 0;
|
|
16
|
+
const collection = new ColumnCollectionBuilder(ctx.services.pframeSpec ?? throwError("PFrameSpec service is required for column discovery.")).addSources(providers).build(resolvedOptions);
|
|
17
|
+
if (collection === void 0) return void 0;
|
|
18
|
+
try {
|
|
19
|
+
const matched = collection.findColumns(resolvedOptions.columnsSelector ?? void 0);
|
|
20
|
+
const anchors = collection.getAnchors();
|
|
21
|
+
return mapToDiscoveredColumns(matched, Array.from(Array.from(anchors.values()).map((v) => v.columnId)));
|
|
22
|
+
} finally {
|
|
23
|
+
collection.dispose();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Resolve PlRef values in anchors to PColumnSpec via the result pool. */
|
|
27
|
+
function resolveAnchors$1(ctx, anchors) {
|
|
28
|
+
const result = {};
|
|
29
|
+
for (const [key, value] of Object.entries(anchors)) if (isPlRef(value)) result[key] = ctx.resultPool.getPColumnSpecByRef(value) ?? throwError(`Anchor ${key} with ref ${JSON.stringify(value)} could not be resolved to a PColumnSpec`);
|
|
30
|
+
else result[key] = value;
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
/** Resolve column snapshot providers from explicit sources or context. */
|
|
34
|
+
function resolveProviders(ctx, sources) {
|
|
35
|
+
return sources !== void 0 ? sources.map(toColumnSnapshotProvider) : collectCtxColumnSnapshotProviders(ctx);
|
|
36
|
+
}
|
|
37
|
+
/** Map matched columns into a flat DiscoveredColumn list with deduped IDs. */
|
|
38
|
+
function mapToDiscoveredColumns(matched, anchorColumnIds) {
|
|
39
|
+
const hitCounts = matched.reduce((acc, match) => acc.set(match.originalId, (acc.get(match.originalId) ?? 0) + 1), /* @__PURE__ */ new Map());
|
|
40
|
+
const hitIndices = /* @__PURE__ */ new Map();
|
|
41
|
+
return matched.map((match) => {
|
|
42
|
+
const snap = match.column;
|
|
43
|
+
let id = snap.id;
|
|
44
|
+
if ((hitCounts.get(match.originalId) ?? 0) > 1) {
|
|
45
|
+
const idx = hitIndices.get(match.originalId) ?? 0;
|
|
46
|
+
hitIndices.set(match.originalId, idx + 1);
|
|
47
|
+
id = `${snap.id}#q${idx}`;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
id,
|
|
51
|
+
originalId: match.originalId,
|
|
52
|
+
spec: snap.spec,
|
|
53
|
+
data: snap.data,
|
|
54
|
+
dataStatus: snap.dataStatus,
|
|
55
|
+
isPrimary: anchorColumnIds.some((anchor) => snap.id === anchor || match.originalId === anchor),
|
|
56
|
+
linkerPath: match.path
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { discoverTableColumnSnaphots };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=discoverColumns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discoverColumns.js","names":["resolveAnchors"],"sources":["../../../../src/components/PlDataTable/createPlDataTable/discoverColumns.ts"],"sourcesContent":["import type {\n PColumnSpec,\n PlRef,\n PObjectId,\n RequireServices,\n Services,\n SUniversalPColumnId,\n} from \"@milaboratories/pl-model-common\";\nimport { isPlRef } from \"@milaboratories/pl-model-common\";\nimport type { RenderCtxBase } from \"../../../render\";\nimport type { ColumnSource, ColumnMatch, RelaxedColumnSelector } from \"../../../columns\";\nimport { ColumnCollectionBuilder } from \"../../../columns\";\nimport { toColumnSnapshotProvider } from \"../../../columns/column_snapshot_provider\";\nimport { collectCtxColumnSnapshotProviders } from \"../../../columns/ctx_column_sources\";\nimport { throwError } from \"@milaboratories/helpers\";\nimport type { ColumnsSelectorConfig, TableColumnSnapshot } from \"./createPlDataTableV3\";\n\nexport type DiscoveredTableColumnOptions = {\n sources?: ColumnSource[];\n anchors: Record<string, PlRef | PObjectId | PColumnSpec | RelaxedColumnSelector>;\n columnsSelector: ColumnsSelectorConfig;\n};\n\n/** Discover columns from sources/anchors and normalize into a flat DiscoveredColumn list. */\nexport function discoverTableColumnSnaphots<\n A,\n U,\n S extends RequireServices<typeof Services.PFrameSpec>,\n>(\n ctx: RenderCtxBase<A, U, S>,\n options: DiscoveredTableColumnOptions,\n): TableColumnSnapshot<SUniversalPColumnId>[] | undefined {\n // Resolve PlRef anchors to PColumnSpec\n const resolvedOptions = { ...options, anchors: resolveAnchors(ctx, options.anchors) };\n\n // Resolve providers\n const providers = resolveProviders(ctx, resolvedOptions.sources);\n if (providers.length === 0) return undefined;\n\n // Build collection (anchored or plain)\n const pframeSpec =\n ctx.services.pframeSpec ?? throwError(\"PFrameSpec service is required for column discovery.\");\n const collection = new ColumnCollectionBuilder(pframeSpec)\n .addSources(providers)\n .build(resolvedOptions);\n if (collection === undefined) return undefined;\n\n try {\n const matched = collection.findColumns(resolvedOptions.columnsSelector ?? undefined);\n const anchors = collection.getAnchors();\n return mapToDiscoveredColumns(\n matched,\n Array.from(Array.from(anchors.values()).map((v) => v.columnId)),\n );\n } finally {\n collection.dispose();\n }\n}\n\n// --- Pure helper functions ---\n\n/** Resolve PlRef values in anchors to PColumnSpec via the result pool. */\nfunction resolveAnchors<A, U>(\n ctx: RenderCtxBase<A, U>,\n anchors: Record<string, PlRef | PObjectId | PColumnSpec | RelaxedColumnSelector>,\n): Record<string, PObjectId | PColumnSpec | RelaxedColumnSelector> {\n const result: Record<string, PObjectId | PColumnSpec | RelaxedColumnSelector> = {};\n for (const [key, value] of Object.entries(anchors)) {\n if (isPlRef(value)) {\n result[key] =\n ctx.resultPool.getPColumnSpecByRef(value) ??\n throwError(\n `Anchor ${key} with ref ${JSON.stringify(value)} could not be resolved to a PColumnSpec`,\n );\n } else {\n result[key] = value;\n }\n }\n return result;\n}\n\n/** Resolve column snapshot providers from explicit sources or context. */\nfunction resolveProviders<A, U>(ctx: RenderCtxBase<A, U>, sources: undefined | ColumnSource[]) {\n return sources !== undefined\n ? sources.map(toColumnSnapshotProvider)\n : collectCtxColumnSnapshotProviders(ctx);\n}\n\n/** Map matched columns into a flat DiscoveredColumn list with deduped IDs. */\nfunction mapToDiscoveredColumns(\n matched: readonly ColumnMatch[],\n anchorColumnIds: readonly PObjectId[],\n): TableColumnSnapshot<SUniversalPColumnId>[] {\n const hitCounts = matched.reduce(\n (acc, match) => acc.set(match.originalId, (acc.get(match.originalId) ?? 0) + 1),\n new Map<PObjectId, number>(),\n );\n\n const hitIndices = new Map<PObjectId, number>();\n return matched.map((match) => {\n const snap = match.column;\n\n let id = snap.id;\n if ((hitCounts.get(match.originalId) ?? 0) > 1) {\n const idx = hitIndices.get(match.originalId) ?? 0;\n hitIndices.set(match.originalId, idx + 1);\n id = `${snap.id}#q${idx}` as SUniversalPColumnId;\n }\n\n return {\n id,\n originalId: match.originalId,\n spec: snap.spec,\n data: snap.data,\n dataStatus: snap.dataStatus,\n isPrimary: anchorColumnIds.some(\n (anchor) => snap.id === anchor || match.originalId === anchor,\n ),\n linkerPath: match.path,\n };\n });\n}\n"],"mappings":";;;;;;;;AAwBA,SAAgB,4BAKd,KACA,SACwD;CAExD,MAAM,kBAAkB;EAAE,GAAG;EAAS,SAASA,iBAAe,KAAK,QAAQ,QAAQ;EAAE;CAGrF,MAAM,YAAY,iBAAiB,KAAK,gBAAgB,QAAQ;AAChE,KAAI,UAAU,WAAW,EAAG,QAAO,KAAA;CAKnC,MAAM,aAAa,IAAI,wBADrB,IAAI,SAAS,cAAc,WAAW,uDAAuD,CACrC,CACvD,WAAW,UAAU,CACrB,MAAM,gBAAgB;AACzB,KAAI,eAAe,KAAA,EAAW,QAAO,KAAA;AAErC,KAAI;EACF,MAAM,UAAU,WAAW,YAAY,gBAAgB,mBAAmB,KAAA,EAAU;EACpF,MAAM,UAAU,WAAW,YAAY;AACvC,SAAO,uBACL,SACA,MAAM,KAAK,MAAM,KAAK,QAAQ,QAAQ,CAAC,CAAC,KAAK,MAAM,EAAE,SAAS,CAAC,CAChE;WACO;AACR,aAAW,SAAS;;;;AAOxB,SAASA,iBACP,KACA,SACiE;CACjE,MAAM,SAA0E,EAAE;AAClF,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,CAChD,KAAI,QAAQ,MAAM,CAChB,QAAO,OACL,IAAI,WAAW,oBAAoB,MAAM,IACzC,WACE,UAAU,IAAI,YAAY,KAAK,UAAU,MAAM,CAAC,yCACjD;KAEH,QAAO,OAAO;AAGlB,QAAO;;;AAIT,SAAS,iBAAuB,KAA0B,SAAqC;AAC7F,QAAO,YAAY,KAAA,IACf,QAAQ,IAAI,yBAAyB,GACrC,kCAAkC,IAAI;;;AAI5C,SAAS,uBACP,SACA,iBAC4C;CAC5C,MAAM,YAAY,QAAQ,QACvB,KAAK,UAAU,IAAI,IAAI,MAAM,aAAa,IAAI,IAAI,MAAM,WAAW,IAAI,KAAK,EAAE,kBAC/E,IAAI,KAAwB,CAC7B;CAED,MAAM,6BAAa,IAAI,KAAwB;AAC/C,QAAO,QAAQ,KAAK,UAAU;EAC5B,MAAM,OAAO,MAAM;EAEnB,IAAI,KAAK,KAAK;AACd,OAAK,UAAU,IAAI,MAAM,WAAW,IAAI,KAAK,GAAG;GAC9C,MAAM,MAAM,WAAW,IAAI,MAAM,WAAW,IAAI;AAChD,cAAW,IAAI,MAAM,YAAY,MAAM,EAAE;AACzC,QAAK,GAAG,KAAK,GAAG,IAAI;;AAGtB,SAAO;GACL;GACA,YAAY,MAAM;GAClB,MAAM,KAAK;GACX,MAAM,KAAK;GACX,YAAY,KAAK;GACjB,WAAW,gBAAgB,MACxB,WAAW,KAAK,OAAO,UAAU,MAAM,eAAe,OACxD;GACD,YAAY,MAAM;GACnB;GACD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const require_createPlDataTableV3 = require("./createPlDataTableV3.cjs");
|
|
2
1
|
const require_createPlDataTableV2 = require("./createPlDataTableV2.cjs");
|
|
2
|
+
require("./discoverColumns.cjs");
|
|
3
|
+
const require_createPlDataTableV3 = require("./createPlDataTableV3.cjs");
|
|
3
4
|
//#region src/components/PlDataTable/createPlDataTable/index.ts
|
|
4
5
|
function createPlDataTable(ctx, options) {
|
|
5
6
|
if (options.version === "v2") return require_createPlDataTableV2.createPlDataTableV2(ctx, options.columns, options.tableState, options.options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["createPlDataTableV2","createPlDataTableV3"],"sources":["../../../../src/components/PlDataTable/createPlDataTable/index.ts"],"sourcesContent":["import { Services, type RequireServices } from \"@milaboratories/pl-model-common\";\nimport type { RenderCtxBase } from \"../../../render\";\nimport type { PlDataTableModel } from \"../typesV5\";\nimport { createPlDataTableOptionsV2, createPlDataTableV2 } from \"./createPlDataTableV2\";\nimport { createPlDataTableV3 } from \"./createPlDataTableV3\";\nimport type { createPlDataTableOptionsV3 } from \"./createPlDataTableV3\";\n\nexport function createPlDataTable<A, U
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["createPlDataTableV2","createPlDataTableV3"],"sources":["../../../../src/components/PlDataTable/createPlDataTable/index.ts"],"sourcesContent":["import { Services, type RequireServices } from \"@milaboratories/pl-model-common\";\nimport type { RenderCtxBase } from \"../../../render\";\nimport type { PlDataTableModel } from \"../typesV5\";\nimport { createPlDataTableOptionsV2, createPlDataTableV2 } from \"./createPlDataTableV2\";\nimport { createPlDataTableV3 } from \"./createPlDataTableV3\";\nimport type { createPlDataTableOptionsV3 } from \"./createPlDataTableV3\";\n\nexport function createPlDataTable<A, U, S extends RequireServices<typeof Services.PFrameSpec>>(\n ctx: RenderCtxBase<A, U, S>,\n options: { version: \"v2\" } & createPlDataTableOptionsV2,\n): ReturnType<typeof createPlDataTableV2>;\nexport function createPlDataTable<A, U, S extends RequireServices<typeof Services.PFrameSpec>>(\n ctx: RenderCtxBase<A, U, S>,\n options: { version?: \"v3\" } & createPlDataTableOptionsV3,\n): ReturnType<typeof createPlDataTableV3>;\nexport function createPlDataTable<A, U, S extends RequireServices<typeof Services.PFrameSpec>>(\n ctx: RenderCtxBase<A, U, S>,\n options:\n | ({ version: \"v2\" } & createPlDataTableOptionsV2)\n | ({ version?: \"v3\" } & createPlDataTableOptionsV3),\n): PlDataTableModel | undefined {\n if (options.version === \"v2\") {\n return createPlDataTableV2(ctx, options.columns, options.tableState, options.options);\n } else {\n // default version is last (v3 at the moment)\n return createPlDataTableV3(ctx, options);\n }\n}\n\nexport { discoverTableColumnSnaphots } from \"./discoverColumns\";\n"],"mappings":";;;;AAeA,SAAgB,kBACd,KACA,SAG8B;AAC9B,KAAI,QAAQ,YAAY,KACtB,QAAOA,4BAAAA,oBAAoB,KAAK,QAAQ,SAAS,QAAQ,YAAY,QAAQ,QAAQ;KAGrF,QAAOC,4BAAAA,oBAAoB,KAAK,QAAQ"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { RenderCtxBase } from "../../../render/api.js";
|
|
2
2
|
import { createPlDataTableOptionsV2, createPlDataTableV2 } from "./createPlDataTableV2.js";
|
|
3
|
+
import { discoverTableColumnSnaphots } from "./discoverColumns.js";
|
|
3
4
|
import { createPlDataTableOptionsV3, createPlDataTableV3 } from "./createPlDataTableV3.js";
|
|
4
5
|
import { RequireServices, Services } from "@milaboratories/pl-model-common";
|
|
5
6
|
|
|
6
7
|
//#region src/components/PlDataTable/createPlDataTable/index.d.ts
|
|
7
|
-
declare function createPlDataTable<A, U
|
|
8
|
+
declare function createPlDataTable<A, U, S extends RequireServices<typeof Services.PFrameSpec>>(ctx: RenderCtxBase<A, U, S>, options: {
|
|
8
9
|
version: "v2";
|
|
9
10
|
} & createPlDataTableOptionsV2): ReturnType<typeof createPlDataTableV2>;
|
|
10
11
|
declare function createPlDataTable<A, U, S extends RequireServices<typeof Services.PFrameSpec>>(ctx: RenderCtxBase<A, U, S>, options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/components/PlDataTable/createPlDataTable/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/components/PlDataTable/createPlDataTable/index.ts"],"mappings":";;;;;;;iBAOgB,iBAAA,iBAAkC,eAAA,QAAuB,QAAA,CAAS,UAAA,EAAA,CAChF,GAAA,EAAK,aAAA,CAAc,CAAA,EAAG,CAAA,EAAG,CAAA,GACzB,OAAA;EAAW,OAAA;AAAA,IAAkB,0BAAA,GAC5B,UAAA,QAAkB,mBAAA;AAAA,iBACL,iBAAA,iBAAkC,eAAA,QAAuB,QAAA,CAAS,UAAA,EAAA,CAChF,GAAA,EAAK,aAAA,CAAc,CAAA,EAAG,CAAA,EAAG,CAAA,GACzB,OAAA;EAAW,OAAA;AAAA,IAAmB,0BAAA,GAC7B,UAAA,QAAkB,mBAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { createPlDataTableV3 } from "./createPlDataTableV3.js";
|
|
2
1
|
import { createPlDataTableV2 } from "./createPlDataTableV2.js";
|
|
2
|
+
import "./discoverColumns.js";
|
|
3
|
+
import { createPlDataTableV3 } from "./createPlDataTableV3.js";
|
|
3
4
|
//#region src/components/PlDataTable/createPlDataTable/index.ts
|
|
4
5
|
function createPlDataTable(ctx, options) {
|
|
5
6
|
if (options.version === "v2") return createPlDataTableV2(ctx, options.columns, options.tableState, options.options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/PlDataTable/createPlDataTable/index.ts"],"sourcesContent":["import { Services, type RequireServices } from \"@milaboratories/pl-model-common\";\nimport type { RenderCtxBase } from \"../../../render\";\nimport type { PlDataTableModel } from \"../typesV5\";\nimport { createPlDataTableOptionsV2, createPlDataTableV2 } from \"./createPlDataTableV2\";\nimport { createPlDataTableV3 } from \"./createPlDataTableV3\";\nimport type { createPlDataTableOptionsV3 } from \"./createPlDataTableV3\";\n\nexport function createPlDataTable<A, U
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/PlDataTable/createPlDataTable/index.ts"],"sourcesContent":["import { Services, type RequireServices } from \"@milaboratories/pl-model-common\";\nimport type { RenderCtxBase } from \"../../../render\";\nimport type { PlDataTableModel } from \"../typesV5\";\nimport { createPlDataTableOptionsV2, createPlDataTableV2 } from \"./createPlDataTableV2\";\nimport { createPlDataTableV3 } from \"./createPlDataTableV3\";\nimport type { createPlDataTableOptionsV3 } from \"./createPlDataTableV3\";\n\nexport function createPlDataTable<A, U, S extends RequireServices<typeof Services.PFrameSpec>>(\n ctx: RenderCtxBase<A, U, S>,\n options: { version: \"v2\" } & createPlDataTableOptionsV2,\n): ReturnType<typeof createPlDataTableV2>;\nexport function createPlDataTable<A, U, S extends RequireServices<typeof Services.PFrameSpec>>(\n ctx: RenderCtxBase<A, U, S>,\n options: { version?: \"v3\" } & createPlDataTableOptionsV3,\n): ReturnType<typeof createPlDataTableV3>;\nexport function createPlDataTable<A, U, S extends RequireServices<typeof Services.PFrameSpec>>(\n ctx: RenderCtxBase<A, U, S>,\n options:\n | ({ version: \"v2\" } & createPlDataTableOptionsV2)\n | ({ version?: \"v3\" } & createPlDataTableOptionsV3),\n): PlDataTableModel | undefined {\n if (options.version === \"v2\") {\n return createPlDataTableV2(ctx, options.columns, options.tableState, options.options);\n } else {\n // default version is last (v3 at the moment)\n return createPlDataTableV3(ctx, options);\n }\n}\n\nexport { discoverTableColumnSnaphots } from \"./discoverColumns\";\n"],"mappings":";;;;AAeA,SAAgB,kBACd,KACA,SAG8B;AAC9B,KAAI,QAAQ,YAAY,KACtB,QAAO,oBAAoB,KAAK,QAAQ,SAAS,QAAQ,YAAY,QAAQ,QAAQ;KAGrF,QAAO,oBAAoB,KAAK,QAAQ"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
require("../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_derive_distinct_labels = require("../../../labels/derive_distinct_labels.cjs");
|
|
3
|
+
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
4
|
+
let es_toolkit = require("es-toolkit");
|
|
5
|
+
//#region src/components/PlDataTable/createPlDataTable/utils.ts
|
|
6
|
+
/** Check if column should be omitted from the table */
|
|
7
|
+
function isColumnHidden(spec) {
|
|
8
|
+
return (0, _milaboratories_pl_model_common.readAnnotation)(spec, _milaboratories_pl_model_common.Annotation.Table.Visibility) === "hidden";
|
|
9
|
+
}
|
|
10
|
+
/** Check if column is hidden by default */
|
|
11
|
+
function isColumnOptional(spec) {
|
|
12
|
+
return (0, _milaboratories_pl_model_common.readAnnotation)(spec, _milaboratories_pl_model_common.Annotation.Table.Visibility) === "optional";
|
|
13
|
+
}
|
|
14
|
+
/** Get effective visibility for a column, considering display config rules first, then annotations. */
|
|
15
|
+
function getEffectiveVisibility(spec, displayConfig) {
|
|
16
|
+
if (displayConfig?.visibility) {
|
|
17
|
+
for (const rule of displayConfig.visibility) if (rule.match(spec)) return rule.visibility;
|
|
18
|
+
}
|
|
19
|
+
if (isColumnHidden(spec)) return "hidden";
|
|
20
|
+
if (isColumnOptional(spec)) return "optional";
|
|
21
|
+
}
|
|
22
|
+
/** Get ordering priority for a column. Display config rules first, then annotation fallback. */
|
|
23
|
+
function getOrderPriority(spec, displayConfig) {
|
|
24
|
+
if (displayConfig?.ordering) {
|
|
25
|
+
for (const rule of displayConfig.ordering) if (rule.match(spec)) return rule.priority;
|
|
26
|
+
}
|
|
27
|
+
return (0, _milaboratories_pl_model_common.readAnnotationJson)(spec, _milaboratories_pl_model_common.Annotation.Table.OrderPriority);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Writes derived labels into column and axis annotations.
|
|
31
|
+
* Returns new column objects with modified specs — original columns are not mutated.
|
|
32
|
+
*
|
|
33
|
+
* For each column: writes derived label into Annotation.Label (if present in derivedLabels).
|
|
34
|
+
* For each axis in column specs: writes derived axis label into AxisSpec annotations.
|
|
35
|
+
*/
|
|
36
|
+
function withLabelAnnotations(derivedLabels, columns) {
|
|
37
|
+
if (derivedLabels === void 0) return columns;
|
|
38
|
+
return columns.map((col) => {
|
|
39
|
+
const colLabel = derivedLabels[col.id];
|
|
40
|
+
return {
|
|
41
|
+
...col,
|
|
42
|
+
spec: {
|
|
43
|
+
...col.spec,
|
|
44
|
+
...(0, es_toolkit.isNil)(colLabel) ? {} : { annotations: {
|
|
45
|
+
...col.spec.annotations,
|
|
46
|
+
[_milaboratories_pl_model_common.Annotation.Label]: colLabel
|
|
47
|
+
} },
|
|
48
|
+
axesSpec: col.spec.axesSpec.map((axis) => {
|
|
49
|
+
const label = derivedLabels[(0, _milaboratories_pl_model_common.canonicalizeAxisId)(axis)];
|
|
50
|
+
return (0, es_toolkit.isNil)(label) ? axis : {
|
|
51
|
+
...axis,
|
|
52
|
+
annotations: {
|
|
53
|
+
...axis.annotations,
|
|
54
|
+
[_milaboratories_pl_model_common.Annotation.Label]: label
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Writes effective display properties (OrderPriority, Visibility) from ColumnDisplayOptions
|
|
64
|
+
* into column annotations. Returns new column objects — originals are not mutated.
|
|
65
|
+
*/
|
|
66
|
+
function withTableVisualAnnotations(displayOptions, columns) {
|
|
67
|
+
if (displayOptions === void 0) return columns;
|
|
68
|
+
return columns.map((col) => {
|
|
69
|
+
const annotations = { ...col.spec.annotations };
|
|
70
|
+
const visibility = getEffectiveVisibility(col.spec, displayOptions);
|
|
71
|
+
if (!(0, es_toolkit.isNil)(visibility)) annotations[_milaboratories_pl_model_common.Annotation.Table.Visibility] = visibility;
|
|
72
|
+
const orderPriority = getOrderPriority(col.spec, displayOptions);
|
|
73
|
+
if (!(0, es_toolkit.isNil)(orderPriority)) annotations[_milaboratories_pl_model_common.Annotation.Table.OrderPriority] = String(orderPriority);
|
|
74
|
+
return {
|
|
75
|
+
...col,
|
|
76
|
+
spec: {
|
|
77
|
+
...col.spec,
|
|
78
|
+
annotations
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/** Derive labels for all table elements: columns via deriveDistinctLabels, axes from label columns. */
|
|
84
|
+
function deriveAllLabels(options) {
|
|
85
|
+
const { columns, labelColumns, deriveLabelsOptions } = options;
|
|
86
|
+
const axisLabels = deriveAxisLabels(columns, labelColumns);
|
|
87
|
+
const columnLabels = require_derive_distinct_labels.deriveDistinctLabels(columns, deriveLabelsOptions).reduce((acc, label, index) => (acc[columns[index].id] = label, acc), {});
|
|
88
|
+
return {
|
|
89
|
+
...axisLabels,
|
|
90
|
+
...columnLabels
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Derive axis labels from matching label columns, falling back to axis spec annotations. */
|
|
94
|
+
function deriveAxisLabels(columns, labelColumns) {
|
|
95
|
+
const axisSpecMap = new Map(columns.flatMap((c) => c.spec.axesSpec).map((a) => [(0, _milaboratories_pl_model_common.canonicalizeJson)((0, _milaboratories_pl_model_common.getAxisId)(a)), a]));
|
|
96
|
+
const result = {};
|
|
97
|
+
for (const axisKey of axisSpecMap.keys()) result[axisKey] = (0, _milaboratories_pl_model_common.readAnnotation)(labelColumns.find((lc) => (0, _milaboratories_pl_model_common.canonicalizeJson)((0, _milaboratories_pl_model_common.getAxisId)(lc.spec.axesSpec[0])) === axisKey)?.spec ?? axisSpecMap.get(axisKey) ?? {}, _milaboratories_pl_model_common.Annotation.Label)?.trim() ?? "Unlabeled";
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
exports.deriveAllLabels = deriveAllLabels;
|
|
102
|
+
exports.getEffectiveVisibility = getEffectiveVisibility;
|
|
103
|
+
exports.getOrderPriority = getOrderPriority;
|
|
104
|
+
exports.isColumnHidden = isColumnHidden;
|
|
105
|
+
exports.isColumnOptional = isColumnOptional;
|
|
106
|
+
exports.withLabelAnnotations = withLabelAnnotations;
|
|
107
|
+
exports.withTableVisualAnnotations = withTableVisualAnnotations;
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["Annotation","deriveDistinctLabels"],"sources":["../../../../src/components/PlDataTable/createPlDataTable/utils.ts"],"sourcesContent":["import {\n type PColumn,\n type PColumnSpec,\n type PObjectId,\n Annotation,\n canonicalizeAxisId,\n canonicalizeJson,\n getAxisId,\n readAnnotation,\n readAnnotationJson,\n} from \"@milaboratories/pl-model-common\";\nimport {\n deriveDistinctLabels,\n type DeriveLabelsOptions,\n} from \"../../../labels/derive_distinct_labels\";\nimport type { ColumnsDisplayOptions } from \"./createPlDataTableV3\";\nimport { isNil } from \"es-toolkit\";\n\n/** Check if column should be omitted from the table */\nexport function isColumnHidden(spec: { annotations?: Annotation }): boolean {\n return readAnnotation(spec, Annotation.Table.Visibility) === \"hidden\";\n}\n\n/** Check if column is hidden by default */\nexport function isColumnOptional(spec: { annotations?: Annotation }): boolean {\n return readAnnotation(spec, Annotation.Table.Visibility) === \"optional\";\n}\n\n/** Get effective visibility for a column, considering display config rules first, then annotations. */\nexport function getEffectiveVisibility(\n spec: PColumnSpec,\n displayConfig?: ColumnsDisplayOptions,\n): undefined | \"default\" | \"optional\" | \"hidden\" {\n if (displayConfig?.visibility) {\n for (const rule of displayConfig.visibility) {\n if (rule.match(spec)) {\n return rule.visibility;\n }\n }\n }\n if (isColumnHidden(spec)) return \"hidden\";\n if (isColumnOptional(spec)) return \"optional\";\n return undefined;\n}\n\n/** Get ordering priority for a column. Display config rules first, then annotation fallback. */\nexport function getOrderPriority(\n spec: PColumnSpec,\n displayConfig?: ColumnsDisplayOptions,\n): undefined | number {\n if (displayConfig?.ordering) {\n for (const rule of displayConfig.ordering) {\n if (rule.match(spec)) {\n return rule.priority;\n }\n }\n }\n return readAnnotationJson(spec, Annotation.Table.OrderPriority);\n}\n\n/**\n * Writes derived labels into column and axis annotations.\n * Returns new column objects with modified specs — original columns are not mutated.\n *\n * For each column: writes derived label into Annotation.Label (if present in derivedLabels).\n * For each axis in column specs: writes derived axis label into AxisSpec annotations.\n */\nexport function withLabelAnnotations<Data>(\n derivedLabels: undefined | Record<string, string>,\n columns: PColumn<Data>[],\n): PColumn<Data>[] {\n if (derivedLabels === undefined) return columns;\n return columns.map((col) => {\n const colLabel = derivedLabels[col.id];\n return {\n ...col,\n spec: {\n ...col.spec,\n ...(isNil(colLabel)\n ? {}\n : { annotations: { ...col.spec.annotations, [Annotation.Label]: colLabel } }),\n axesSpec: col.spec.axesSpec.map((axis) => {\n const label = derivedLabels[canonicalizeAxisId(axis)];\n return isNil(label)\n ? axis\n : { ...axis, annotations: { ...axis.annotations, [Annotation.Label]: label } };\n }),\n },\n };\n });\n}\n\n/**\n * Writes effective display properties (OrderPriority, Visibility) from ColumnDisplayOptions\n * into column annotations. Returns new column objects — originals are not mutated.\n */\nexport function withTableVisualAnnotations<Data>(\n displayOptions: undefined | ColumnsDisplayOptions,\n columns: PColumn<Data>[],\n): PColumn<Data>[] {\n if (displayOptions === undefined) return columns;\n return columns.map((col) => {\n const annotations = { ...col.spec.annotations };\n\n const visibility = getEffectiveVisibility(col.spec, displayOptions);\n if (!isNil(visibility)) annotations[Annotation.Table.Visibility] = visibility;\n\n const orderPriority = getOrderPriority(col.spec, displayOptions);\n if (!isNil(orderPriority)) annotations[Annotation.Table.OrderPriority] = String(orderPriority);\n\n return {\n ...col,\n spec: {\n ...col.spec,\n annotations: annotations,\n },\n };\n });\n}\n\n/** Column shape required by label derivation. */\nexport type LabelableColumn = {\n readonly id: PObjectId;\n readonly spec: PColumnSpec;\n readonly linkerPath?: { spec: PColumnSpec }[];\n};\n\n/** Derive labels for all table elements: columns via deriveDistinctLabels, axes from label columns. */\nexport function deriveAllLabels(options: {\n columns: LabelableColumn[];\n labelColumns: { readonly spec: PColumnSpec }[];\n deriveLabelsOptions?: DeriveLabelsOptions;\n}): Record<string, string> {\n const { columns, labelColumns, deriveLabelsOptions } = options;\n const axisLabels = deriveAxisLabels(columns, labelColumns);\n const columnLabels = deriveDistinctLabels(columns, deriveLabelsOptions).reduce(\n (acc, label, index) => ((acc[columns[index].id] = label), acc),\n {} as Record<string, string>,\n );\n return { ...axisLabels, ...columnLabels };\n}\n\n/** Derive axis labels from matching label columns, falling back to axis spec annotations. */\nfunction deriveAxisLabels(\n columns: { readonly spec: PColumnSpec }[],\n labelColumns: { readonly spec: PColumnSpec }[],\n): Record<string, string> {\n const axisSpecMap = new Map(\n columns.flatMap((c) => c.spec.axesSpec).map((a) => [canonicalizeJson(getAxisId(a)), a]),\n );\n const result: Record<string, string> = {};\n for (const axisKey of axisSpecMap.keys()) {\n const labelCol = labelColumns.find(\n (lc) => canonicalizeJson(getAxisId(lc.spec.axesSpec[0])) === axisKey,\n );\n const source = labelCol?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,CAAC,KAAK,QAC9D,EACwB,QAAQ,YAAY,IAAI,QAAQ,IACd,EAAE,EAAED,gCAAAA,WAAW,MAAM,EAAE,MAAM,IAAI;AAE9E,QAAO"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ColumnsDisplayOptions } from "./createPlDataTableV3.js";
|
|
2
|
+
import { Annotation, PColumn, PColumnSpec, PObjectId } from "@milaboratories/pl-model-common";
|
|
3
|
+
|
|
4
|
+
//#region src/components/PlDataTable/createPlDataTable/utils.d.ts
|
|
5
|
+
/** Check if column should be omitted from the table */
|
|
6
|
+
declare function isColumnHidden(spec: {
|
|
7
|
+
annotations?: Annotation;
|
|
8
|
+
}): boolean;
|
|
9
|
+
/** Check if column is hidden by default */
|
|
10
|
+
declare function isColumnOptional(spec: {
|
|
11
|
+
annotations?: Annotation;
|
|
12
|
+
}): boolean;
|
|
13
|
+
/** Get effective visibility for a column, considering display config rules first, then annotations. */
|
|
14
|
+
declare function getEffectiveVisibility(spec: PColumnSpec, displayConfig?: ColumnsDisplayOptions): undefined | "default" | "optional" | "hidden";
|
|
15
|
+
/** Get ordering priority for a column. Display config rules first, then annotation fallback. */
|
|
16
|
+
declare function getOrderPriority(spec: PColumnSpec, displayConfig?: ColumnsDisplayOptions): undefined | number;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { getEffectiveVisibility, getOrderPriority, isColumnHidden, isColumnOptional };
|
|
19
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","names":[],"sources":["../../../../src/components/PlDataTable/createPlDataTable/utils.ts"],"mappings":";;;;;iBAmBgB,cAAA,CAAe,IAAA;EAAQ,WAAA,GAAc,UAAA;AAAA;;iBAKrC,gBAAA,CAAiB,IAAA;EAAQ,WAAA,GAAc,UAAA;AAAA;;iBAKvC,sBAAA,CACd,IAAA,EAAM,WAAA,EACN,aAAA,GAAgB,qBAAA;;iBAeF,gBAAA,CACd,IAAA,EAAM,WAAA,EACN,aAAA,GAAgB,qBAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { deriveDistinctLabels } from "../../../labels/derive_distinct_labels.js";
|
|
2
|
+
import { Annotation, canonicalizeAxisId, canonicalizeJson, getAxisId, readAnnotation, readAnnotationJson } from "@milaboratories/pl-model-common";
|
|
3
|
+
import { isNil } from "es-toolkit";
|
|
4
|
+
//#region src/components/PlDataTable/createPlDataTable/utils.ts
|
|
5
|
+
/** Check if column should be omitted from the table */
|
|
6
|
+
function isColumnHidden(spec) {
|
|
7
|
+
return readAnnotation(spec, Annotation.Table.Visibility) === "hidden";
|
|
8
|
+
}
|
|
9
|
+
/** Check if column is hidden by default */
|
|
10
|
+
function isColumnOptional(spec) {
|
|
11
|
+
return readAnnotation(spec, Annotation.Table.Visibility) === "optional";
|
|
12
|
+
}
|
|
13
|
+
/** Get effective visibility for a column, considering display config rules first, then annotations. */
|
|
14
|
+
function getEffectiveVisibility(spec, displayConfig) {
|
|
15
|
+
if (displayConfig?.visibility) {
|
|
16
|
+
for (const rule of displayConfig.visibility) if (rule.match(spec)) return rule.visibility;
|
|
17
|
+
}
|
|
18
|
+
if (isColumnHidden(spec)) return "hidden";
|
|
19
|
+
if (isColumnOptional(spec)) return "optional";
|
|
20
|
+
}
|
|
21
|
+
/** Get ordering priority for a column. Display config rules first, then annotation fallback. */
|
|
22
|
+
function getOrderPriority(spec, displayConfig) {
|
|
23
|
+
if (displayConfig?.ordering) {
|
|
24
|
+
for (const rule of displayConfig.ordering) if (rule.match(spec)) return rule.priority;
|
|
25
|
+
}
|
|
26
|
+
return readAnnotationJson(spec, Annotation.Table.OrderPriority);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Writes derived labels into column and axis annotations.
|
|
30
|
+
* Returns new column objects with modified specs — original columns are not mutated.
|
|
31
|
+
*
|
|
32
|
+
* For each column: writes derived label into Annotation.Label (if present in derivedLabels).
|
|
33
|
+
* For each axis in column specs: writes derived axis label into AxisSpec annotations.
|
|
34
|
+
*/
|
|
35
|
+
function withLabelAnnotations(derivedLabels, columns) {
|
|
36
|
+
if (derivedLabels === void 0) return columns;
|
|
37
|
+
return columns.map((col) => {
|
|
38
|
+
const colLabel = derivedLabels[col.id];
|
|
39
|
+
return {
|
|
40
|
+
...col,
|
|
41
|
+
spec: {
|
|
42
|
+
...col.spec,
|
|
43
|
+
...isNil(colLabel) ? {} : { annotations: {
|
|
44
|
+
...col.spec.annotations,
|
|
45
|
+
[Annotation.Label]: colLabel
|
|
46
|
+
} },
|
|
47
|
+
axesSpec: col.spec.axesSpec.map((axis) => {
|
|
48
|
+
const label = derivedLabels[canonicalizeAxisId(axis)];
|
|
49
|
+
return isNil(label) ? axis : {
|
|
50
|
+
...axis,
|
|
51
|
+
annotations: {
|
|
52
|
+
...axis.annotations,
|
|
53
|
+
[Annotation.Label]: label
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Writes effective display properties (OrderPriority, Visibility) from ColumnDisplayOptions
|
|
63
|
+
* into column annotations. Returns new column objects — originals are not mutated.
|
|
64
|
+
*/
|
|
65
|
+
function withTableVisualAnnotations(displayOptions, columns) {
|
|
66
|
+
if (displayOptions === void 0) return columns;
|
|
67
|
+
return columns.map((col) => {
|
|
68
|
+
const annotations = { ...col.spec.annotations };
|
|
69
|
+
const visibility = getEffectiveVisibility(col.spec, displayOptions);
|
|
70
|
+
if (!isNil(visibility)) annotations[Annotation.Table.Visibility] = visibility;
|
|
71
|
+
const orderPriority = getOrderPriority(col.spec, displayOptions);
|
|
72
|
+
if (!isNil(orderPriority)) annotations[Annotation.Table.OrderPriority] = String(orderPriority);
|
|
73
|
+
return {
|
|
74
|
+
...col,
|
|
75
|
+
spec: {
|
|
76
|
+
...col.spec,
|
|
77
|
+
annotations
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/** Derive labels for all table elements: columns via deriveDistinctLabels, axes from label columns. */
|
|
83
|
+
function deriveAllLabels(options) {
|
|
84
|
+
const { columns, labelColumns, deriveLabelsOptions } = options;
|
|
85
|
+
const axisLabels = deriveAxisLabels(columns, labelColumns);
|
|
86
|
+
const columnLabels = deriveDistinctLabels(columns, deriveLabelsOptions).reduce((acc, label, index) => (acc[columns[index].id] = label, acc), {});
|
|
87
|
+
return {
|
|
88
|
+
...axisLabels,
|
|
89
|
+
...columnLabels
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Derive axis labels from matching label columns, falling back to axis spec annotations. */
|
|
93
|
+
function deriveAxisLabels(columns, labelColumns) {
|
|
94
|
+
const axisSpecMap = new Map(columns.flatMap((c) => c.spec.axesSpec).map((a) => [canonicalizeJson(getAxisId(a)), a]));
|
|
95
|
+
const result = {};
|
|
96
|
+
for (const axisKey of axisSpecMap.keys()) result[axisKey] = readAnnotation(labelColumns.find((lc) => canonicalizeJson(getAxisId(lc.spec.axesSpec[0])) === axisKey)?.spec ?? axisSpecMap.get(axisKey) ?? {}, Annotation.Label)?.trim() ?? "Unlabeled";
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { deriveAllLabels, getEffectiveVisibility, getOrderPriority, isColumnHidden, isColumnOptional, withLabelAnnotations, withTableVisualAnnotations };
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../../src/components/PlDataTable/createPlDataTable/utils.ts"],"sourcesContent":["import {\n type PColumn,\n type PColumnSpec,\n type PObjectId,\n Annotation,\n canonicalizeAxisId,\n canonicalizeJson,\n getAxisId,\n readAnnotation,\n readAnnotationJson,\n} from \"@milaboratories/pl-model-common\";\nimport {\n deriveDistinctLabels,\n type DeriveLabelsOptions,\n} from \"../../../labels/derive_distinct_labels\";\nimport type { ColumnsDisplayOptions } from \"./createPlDataTableV3\";\nimport { isNil } from \"es-toolkit\";\n\n/** Check if column should be omitted from the table */\nexport function isColumnHidden(spec: { annotations?: Annotation }): boolean {\n return readAnnotation(spec, Annotation.Table.Visibility) === \"hidden\";\n}\n\n/** Check if column is hidden by default */\nexport function isColumnOptional(spec: { annotations?: Annotation }): boolean {\n return readAnnotation(spec, Annotation.Table.Visibility) === \"optional\";\n}\n\n/** Get effective visibility for a column, considering display config rules first, then annotations. */\nexport function getEffectiveVisibility(\n spec: PColumnSpec,\n displayConfig?: ColumnsDisplayOptions,\n): undefined | \"default\" | \"optional\" | \"hidden\" {\n if (displayConfig?.visibility) {\n for (const rule of displayConfig.visibility) {\n if (rule.match(spec)) {\n return rule.visibility;\n }\n }\n }\n if (isColumnHidden(spec)) return \"hidden\";\n if (isColumnOptional(spec)) return \"optional\";\n return undefined;\n}\n\n/** Get ordering priority for a column. Display config rules first, then annotation fallback. */\nexport function getOrderPriority(\n spec: PColumnSpec,\n displayConfig?: ColumnsDisplayOptions,\n): undefined | number {\n if (displayConfig?.ordering) {\n for (const rule of displayConfig.ordering) {\n if (rule.match(spec)) {\n return rule.priority;\n }\n }\n }\n return readAnnotationJson(spec, Annotation.Table.OrderPriority);\n}\n\n/**\n * Writes derived labels into column and axis annotations.\n * Returns new column objects with modified specs — original columns are not mutated.\n *\n * For each column: writes derived label into Annotation.Label (if present in derivedLabels).\n * For each axis in column specs: writes derived axis label into AxisSpec annotations.\n */\nexport function withLabelAnnotations<Data>(\n derivedLabels: undefined | Record<string, string>,\n columns: PColumn<Data>[],\n): PColumn<Data>[] {\n if (derivedLabels === undefined) return columns;\n return columns.map((col) => {\n const colLabel = derivedLabels[col.id];\n return {\n ...col,\n spec: {\n ...col.spec,\n ...(isNil(colLabel)\n ? {}\n : { annotations: { ...col.spec.annotations, [Annotation.Label]: colLabel } }),\n axesSpec: col.spec.axesSpec.map((axis) => {\n const label = derivedLabels[canonicalizeAxisId(axis)];\n return isNil(label)\n ? axis\n : { ...axis, annotations: { ...axis.annotations, [Annotation.Label]: label } };\n }),\n },\n };\n });\n}\n\n/**\n * Writes effective display properties (OrderPriority, Visibility) from ColumnDisplayOptions\n * into column annotations. Returns new column objects — originals are not mutated.\n */\nexport function withTableVisualAnnotations<Data>(\n displayOptions: undefined | ColumnsDisplayOptions,\n columns: PColumn<Data>[],\n): PColumn<Data>[] {\n if (displayOptions === undefined) return columns;\n return columns.map((col) => {\n const annotations = { ...col.spec.annotations };\n\n const visibility = getEffectiveVisibility(col.spec, displayOptions);\n if (!isNil(visibility)) annotations[Annotation.Table.Visibility] = visibility;\n\n const orderPriority = getOrderPriority(col.spec, displayOptions);\n if (!isNil(orderPriority)) annotations[Annotation.Table.OrderPriority] = String(orderPriority);\n\n return {\n ...col,\n spec: {\n ...col.spec,\n annotations: annotations,\n },\n };\n });\n}\n\n/** Column shape required by label derivation. */\nexport type LabelableColumn = {\n readonly id: PObjectId;\n readonly spec: PColumnSpec;\n readonly linkerPath?: { spec: PColumnSpec }[];\n};\n\n/** Derive labels for all table elements: columns via deriveDistinctLabels, axes from label columns. */\nexport function deriveAllLabels(options: {\n columns: LabelableColumn[];\n labelColumns: { readonly spec: PColumnSpec }[];\n deriveLabelsOptions?: DeriveLabelsOptions;\n}): Record<string, string> {\n const { columns, labelColumns, deriveLabelsOptions } = options;\n const axisLabels = deriveAxisLabels(columns, labelColumns);\n const columnLabels = deriveDistinctLabels(columns, deriveLabelsOptions).reduce(\n (acc, label, index) => ((acc[columns[index].id] = label), acc),\n {} as Record<string, string>,\n );\n return { ...axisLabels, ...columnLabels };\n}\n\n/** Derive axis labels from matching label columns, falling back to axis spec annotations. */\nfunction deriveAxisLabels(\n columns: { readonly spec: PColumnSpec }[],\n labelColumns: { readonly spec: PColumnSpec }[],\n): Record<string, string> {\n const axisSpecMap = new Map(\n columns.flatMap((c) => c.spec.axesSpec).map((a) => [canonicalizeJson(getAxisId(a)), a]),\n );\n const result: Record<string, string> = {};\n for (const axisKey of axisSpecMap.keys()) {\n const labelCol = labelColumns.find(\n (lc) => canonicalizeJson(getAxisId(lc.spec.axesSpec[0])) === axisKey,\n );\n const source = labelCol?.spec ?? axisSpecMap.get(axisKey);\n result[axisKey] = readAnnotation(source ?? {}, Annotation.Label)?.trim() ?? \"Unlabeled\";\n }\n return result;\n}\n"],"mappings":";;;;;AAmBA,SAAgB,eAAe,MAA6C;AAC1E,QAAO,eAAe,MAAM,WAAW,MAAM,WAAW,KAAK;;;AAI/D,SAAgB,iBAAiB,MAA6C;AAC5E,QAAO,eAAe,MAAM,WAAW,MAAM,WAAW,KAAK;;;AAI/D,SAAgB,uBACd,MACA,eAC+C;AAC/C,KAAI,eAAe;OACZ,MAAM,QAAQ,cAAc,WAC/B,KAAI,KAAK,MAAM,KAAK,CAClB,QAAO,KAAK;;AAIlB,KAAI,eAAe,KAAK,CAAE,QAAO;AACjC,KAAI,iBAAiB,KAAK,CAAE,QAAO;;;AAKrC,SAAgB,iBACd,MACA,eACoB;AACpB,KAAI,eAAe;OACZ,MAAM,QAAQ,cAAc,SAC/B,KAAI,KAAK,MAAM,KAAK,CAClB,QAAO,KAAK;;AAIlB,QAAO,mBAAmB,MAAM,WAAW,MAAM,cAAc;;;;;;;;;AAUjE,SAAgB,qBACd,eACA,SACiB;AACjB,KAAI,kBAAkB,KAAA,EAAW,QAAO;AACxC,QAAO,QAAQ,KAAK,QAAQ;EAC1B,MAAM,WAAW,cAAc,IAAI;AACnC,SAAO;GACL,GAAG;GACH,MAAM;IACJ,GAAG,IAAI;IACP,GAAI,MAAM,SAAS,GACf,EAAE,GACF,EAAE,aAAa;KAAE,GAAG,IAAI,KAAK;MAAc,WAAW,QAAQ;KAAU,EAAE;IAC9E,UAAU,IAAI,KAAK,SAAS,KAAK,SAAS;KACxC,MAAM,QAAQ,cAAc,mBAAmB,KAAK;AACpD,YAAO,MAAM,MAAM,GACf,OACA;MAAE,GAAG;MAAM,aAAa;OAAE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
@@ -1,5 +1,7 @@
|
|
|
1
1
|
require("./state-migration.cjs");
|
|
2
2
|
require("./createPlDataTableSheet.cjs");
|
|
3
|
-
require("./createPlDataTable/
|
|
3
|
+
require("./createPlDataTable/utils.cjs");
|
|
4
4
|
require("./createPlDataTable/createPlDataTableV2.cjs");
|
|
5
|
+
require("./createPlDataTable/discoverColumns.cjs");
|
|
6
|
+
require("./createPlDataTable/createPlDataTableV3.cjs");
|
|
5
7
|
require("./createPlDataTable/index.cjs");
|
|
@@ -2,5 +2,7 @@ import { PTableParamsV2, PlDataTableFilters, PlDataTableFiltersWithMeta, PlDataT
|
|
|
2
2
|
import { PlDataTableStateV2, createDefaultPTableParams, createPlDataTableStateV2, upgradePlDataTableStateV2 } from "./state-migration.js";
|
|
3
3
|
import { createPlDataTableSheet } from "./createPlDataTableSheet.js";
|
|
4
4
|
import { createPlDataTableV2 } from "./createPlDataTable/createPlDataTableV2.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { discoverTableColumnSnaphots } from "./createPlDataTable/discoverColumns.js";
|
|
6
|
+
import { ColumnMatcher, ColumnOrderRule, ColumnVisibilityRule, ColumnsDisplayOptions, ColumnsSelectorConfig, createPlDataTableOptionsV3, createPlDataTableV3 } from "./createPlDataTable/createPlDataTableV3.js";
|
|
7
|
+
import { createPlDataTable } from "./createPlDataTable/index.js";
|
|
8
|
+
import { getEffectiveVisibility, getOrderPriority, isColumnHidden, isColumnOptional } from "./createPlDataTable/utils.js";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import "./state-migration.js";
|
|
2
2
|
import "./createPlDataTableSheet.js";
|
|
3
|
-
import "./createPlDataTable/
|
|
3
|
+
import "./createPlDataTable/utils.js";
|
|
4
4
|
import "./createPlDataTable/createPlDataTableV2.js";
|
|
5
|
+
import "./createPlDataTable/discoverColumns.js";
|
|
6
|
+
import "./createPlDataTable/createPlDataTableV3.js";
|
|
5
7
|
import "./createPlDataTable/index.js";
|
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
const
|
|
3
|
-
require("../../
|
|
2
|
+
const require_column_collection_builder = require("../../columns/column_collection_builder.cjs");
|
|
3
|
+
const require_ctx_column_sources = require("../../columns/ctx_column_sources.cjs");
|
|
4
|
+
require("../../columns/index.cjs");
|
|
4
5
|
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
6
|
+
let _milaboratories_helpers = require("@milaboratories/helpers");
|
|
5
7
|
//#region src/components/PlDataTable/labels.ts
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Get all label columns visible in the current render context
|
|
10
|
+
* (result pool + block outputs + prerun).
|
|
11
|
+
*/
|
|
12
|
+
function getAllLabelColumns(ctx) {
|
|
13
|
+
const collection = new require_column_collection_builder.ColumnCollectionBuilder(ctx.services.pframeSpec ?? (0, _milaboratories_helpers.throwError)("PFrameSpec service is required for label discovery.")).addSources(require_ctx_column_sources.collectCtxColumnSnapshotProviders(ctx)).build({ allowPartialColumnList: true });
|
|
14
|
+
try {
|
|
15
|
+
return collection.findColumns({ include: {
|
|
16
|
+
name: _milaboratories_pl_model_common.PColumnName.Label,
|
|
17
|
+
axes: []
|
|
18
|
+
} }).reduce((acc, hit) => {
|
|
19
|
+
const data = hit.data?.get();
|
|
20
|
+
return data === void 0 ? acc : [...acc, {
|
|
21
|
+
id: hit.id,
|
|
22
|
+
spec: hit.spec,
|
|
23
|
+
data
|
|
24
|
+
}];
|
|
25
|
+
}, []);
|
|
26
|
+
} finally {
|
|
27
|
+
collection.dispose();
|
|
28
|
+
}
|
|
15
29
|
}
|
|
16
30
|
/** Get label columns matching the provided columns from the result pool */
|
|
17
31
|
function getMatchingLabelColumns(columns, allLabelColumns) {
|