@platforma-sdk/model 1.30.26 → 1.30.37
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/components/PlDataTable.d.ts +12 -5
- package/dist/components/PlDataTable.d.ts.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.d.ts +13 -0
- package/dist/components/PlMultiSequenceAlignment.d.ts.map +1 -0
- package/dist/components/PlSelectionModel.d.ts +18 -0
- package/dist/components/PlSelectionModel.d.ts.map +1 -0
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +475 -437
- package/dist/index.mjs.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/PlDataTable.ts +32 -11
- package/src/components/PlMultiSequenceAlignment.ts +71 -0
- package/src/components/PlSelectionModel.ts +27 -0
- package/src/components/index.ts +3 -1
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PlatformaSDKVersion = "1.30.
|
|
1
|
+
export declare const PlatformaSDKVersion = "1.30.37";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -16,16 +16,30 @@ import type {
|
|
|
16
16
|
PTableRecordFilter,
|
|
17
17
|
PTableRecordSingleValueFilterV2,
|
|
18
18
|
PTableSorting,
|
|
19
|
+
PTableValue,
|
|
19
20
|
} from '@milaboratories/pl-model-common';
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
import {
|
|
22
|
+
canonicalizeJson,
|
|
23
|
+
getAxisId,
|
|
24
|
+
getColumnIdAndSpec,
|
|
25
|
+
matchAxisId,
|
|
26
|
+
parseJson,
|
|
27
|
+
} from '@milaboratories/pl-model-common';
|
|
28
|
+
import type {
|
|
29
|
+
AxisLabelProvider,
|
|
30
|
+
ColumnProvider,
|
|
31
|
+
RenderCtx,
|
|
32
|
+
} from '../render';
|
|
33
|
+
import {
|
|
34
|
+
PColumnCollection,
|
|
35
|
+
TreeNodeAccessor,
|
|
36
|
+
} from '../render';
|
|
23
37
|
|
|
24
38
|
/** Canonicalized PTableColumnSpec JSON string */
|
|
25
39
|
export type PTableColumnSpecJson = CanonicalizedJson<PTableColumnSpec>;
|
|
26
40
|
|
|
27
41
|
/** Encode `PTableColumnId` as canonicalized JSON string */
|
|
28
|
-
export function
|
|
42
|
+
export function stringifyPTableColumnSpec(spec: PTableColumnSpec): PTableColumnSpecJson {
|
|
29
43
|
const type = spec.type;
|
|
30
44
|
switch (type) {
|
|
31
45
|
case 'axis':
|
|
@@ -38,11 +52,6 @@ export function stringifyPTableColumnId(spec: PTableColumnSpec): PTableColumnSpe
|
|
|
38
52
|
}
|
|
39
53
|
}
|
|
40
54
|
|
|
41
|
-
/** Parse `PTableColumnId` from JSON string */
|
|
42
|
-
export function parsePTableColumnId(str: PTableColumnSpecJson): PTableColumnSpec {
|
|
43
|
-
return JSON.parse(str) as PTableColumnSpec;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
55
|
/** Data table state */
|
|
47
56
|
export type PlDataTableGridState = {
|
|
48
57
|
// TODO request stable key from the driver
|
|
@@ -568,6 +577,17 @@ export type PlDataTableModel = {
|
|
|
568
577
|
tableHandle: PTableHandle;
|
|
569
578
|
};
|
|
570
579
|
|
|
580
|
+
/**
|
|
581
|
+
* @deprecated Used only in PlAgDataTable v1 that is no longer maintained.
|
|
582
|
+
* Please migrate to v2.
|
|
583
|
+
*/
|
|
584
|
+
export type PTableRowKey = PTableValue[];
|
|
585
|
+
|
|
586
|
+
/** Check if column should be omitted from the table */
|
|
587
|
+
export function isColumnHidden(spec: { annotations?: Record<string, string> }): boolean {
|
|
588
|
+
return spec.annotations?.['pl7.app/table/visibility'] === 'hidden';
|
|
589
|
+
}
|
|
590
|
+
|
|
571
591
|
/** Check if column is hidden by default */
|
|
572
592
|
export function isColumnOptional(spec: { annotations?: Record<string, string> }): boolean {
|
|
573
593
|
return spec.annotations?.['pl7.app/table/visibility'] === 'optional';
|
|
@@ -583,7 +603,7 @@ export function isColumnOptional(spec: { annotations?: Record<string, string> })
|
|
|
583
603
|
*/
|
|
584
604
|
export function createPlDataTableV2<A, U>(
|
|
585
605
|
ctx: RenderCtx<A, U>,
|
|
586
|
-
|
|
606
|
+
inputColumns: PColumn<TreeNodeAccessor | PColumnValues | DataInfo<TreeNodeAccessor>>[],
|
|
587
607
|
mainColumnPredicate: (spec: PColumnSpec) => boolean,
|
|
588
608
|
tableState: PlDataTableState | undefined,
|
|
589
609
|
ops?: CreatePlDataTableOps,
|
|
@@ -592,6 +612,7 @@ export function createPlDataTableV2<A, U>(
|
|
|
592
612
|
const filters: PTableRecordSingleValueFilterV2[]
|
|
593
613
|
= [...(ops?.filters ?? []), ...(tableState?.pTableParams?.filters ?? [])];
|
|
594
614
|
const sorting: PTableSorting[] = tableState?.pTableParams?.sorting ?? [];
|
|
615
|
+
const columns = inputColumns.filter((c) => !isColumnHidden(c.spec));
|
|
595
616
|
|
|
596
617
|
const mainColumn = columns.find((c) => mainColumnPredicate(c.spec));
|
|
597
618
|
if (!mainColumn) return undefined;
|
|
@@ -604,7 +625,7 @@ export function createPlDataTableV2<A, U>(
|
|
|
604
625
|
if (coreJoinType === 'inner') return [];
|
|
605
626
|
|
|
606
627
|
const hiddenColIds = tableState?.gridState.columnVisibility?.hiddenColIds
|
|
607
|
-
?.map(
|
|
628
|
+
?.map(parseJson)
|
|
608
629
|
.filter((c) => c.type === 'column')
|
|
609
630
|
.map((c) => c.id);
|
|
610
631
|
if (hiddenColIds) return hiddenColIds;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CanonicalizedJson,
|
|
3
|
+
PColumn,
|
|
4
|
+
PColumnIdAndSpec,
|
|
5
|
+
PColumnKey,
|
|
6
|
+
PColumnValues,
|
|
7
|
+
PColumnValuesEntry,
|
|
8
|
+
PObjectId,
|
|
9
|
+
PTableColumnId,
|
|
10
|
+
} from '@milaboratories/pl-model-common';
|
|
11
|
+
import {
|
|
12
|
+
canonicalizeJson,
|
|
13
|
+
isPTableAbsent,
|
|
14
|
+
} from '@milaboratories/pl-model-common';
|
|
15
|
+
import type { PlSelectionModel } from './PlSelectionModel';
|
|
16
|
+
|
|
17
|
+
/** Canonicalized PTableColumnId JSON string */
|
|
18
|
+
export type PTableColumnIdJson = CanonicalizedJson<PTableColumnId>;
|
|
19
|
+
|
|
20
|
+
/** Encode `PTableColumnId` as canonicalized JSON string */
|
|
21
|
+
export function stringifyPTableColumnId(
|
|
22
|
+
id: PTableColumnId,
|
|
23
|
+
): PTableColumnIdJson {
|
|
24
|
+
const type = id.type;
|
|
25
|
+
switch (type) {
|
|
26
|
+
case 'axis':
|
|
27
|
+
return canonicalizeJson(id);
|
|
28
|
+
case 'column':
|
|
29
|
+
return canonicalizeJson(id);
|
|
30
|
+
default:
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
32
|
+
throw Error(`unsupported column type: ${type satisfies never}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type PColumnPredicate = (column: PColumnIdAndSpec) => boolean;
|
|
37
|
+
|
|
38
|
+
export type PlMultiSequenceAlignmentModel = {
|
|
39
|
+
sequenceColumnIds?: PObjectId[];
|
|
40
|
+
labelColumnIds?: PTableColumnIdJson[];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export function createRowSelectionColumn(
|
|
44
|
+
columnId: PObjectId,
|
|
45
|
+
rowSelectionModel: PlSelectionModel | undefined,
|
|
46
|
+
label?: string,
|
|
47
|
+
domain?: Record<string, string>,
|
|
48
|
+
): PColumn<PColumnValues> | undefined {
|
|
49
|
+
if (!rowSelectionModel || rowSelectionModel.axesSpec.length === 0) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
id: columnId,
|
|
55
|
+
spec: {
|
|
56
|
+
kind: 'PColumn',
|
|
57
|
+
valueType: 'Int',
|
|
58
|
+
name: 'pl7.app/table/row-selection',
|
|
59
|
+
axesSpec: rowSelectionModel.axesSpec,
|
|
60
|
+
...(domain && { domain }),
|
|
61
|
+
annotations: {
|
|
62
|
+
'pl7.app/label': label ?? 'Selected rows',
|
|
63
|
+
'pl7.app/discreteValues': '[1]',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
data: rowSelectionModel
|
|
67
|
+
.selectedKeys
|
|
68
|
+
.filter((r): r is PColumnKey => !r.some((v) => isPTableAbsent(v)))
|
|
69
|
+
.map((r) => ({ key: r, val: 1 } satisfies PColumnValuesEntry)),
|
|
70
|
+
} satisfies PColumn<PColumnValues>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AxesSpec, PTableAbsent, PTableValue } from '@milaboratories/pl-model-common';
|
|
2
|
+
import { PTableNA } from '@milaboratories/pl-model-common';
|
|
3
|
+
|
|
4
|
+
/** Key is a set of all axes values, which means it is unique across rows */
|
|
5
|
+
export type PTableKey = AxisValue[];
|
|
6
|
+
|
|
7
|
+
/** Readable axis value */
|
|
8
|
+
export type AxisValue = string | number | PTableAbsent;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Information on selected rows.
|
|
12
|
+
* for selectedKeys = [[axis1Value, axis2Value, axis3Value], ...]
|
|
13
|
+
* axesSpec would be [axis1Spec, axis2Spec, axis3Spec]
|
|
14
|
+
*/
|
|
15
|
+
export type PlSelectionModel = {
|
|
16
|
+
/** Specs for {@link AxisValue}'s in {@link PTableKey} */
|
|
17
|
+
axesSpec: AxesSpec;
|
|
18
|
+
/** Row keys (arrays of axes values) of selected rows */
|
|
19
|
+
selectedKeys: PTableKey[];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function mapPTableValueToAxisKey(value: PTableValue): AxisValue {
|
|
23
|
+
if (value === PTableNA) {
|
|
24
|
+
throw new Error('Axis value can never be N/A');
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|