@platforma-sdk/model 1.64.0 → 1.65.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/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs +7 -8
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js +7 -8
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs +17 -16
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js +17 -16
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js.map +1 -1
- package/dist/components/PlDataTable/index.d.ts +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 +21 -14
- package/dist/components/PlDataTable/typesV5.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/package.json +6 -6
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV2.ts +12 -8
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV3.ts +22 -24
- package/src/components/PlDataTable/index.ts +2 -0
- package/src/components/PlDataTable/state-migration.ts +3 -0
- package/src/components/PlDataTable/typesV5.ts +21 -8
|
@@ -125,15 +125,24 @@ export function createPlDataTableV3<A, U, S extends RequireServices<typeof Servi
|
|
|
125
125
|
options.columnsDisplayOptions,
|
|
126
126
|
);
|
|
127
127
|
|
|
128
|
+
const primaryColumnIds = new Set<PObjectId>(
|
|
129
|
+
discovered.filter((dc) => dc.isPrimary).map((dc) => dc.id),
|
|
130
|
+
);
|
|
131
|
+
const primaryColumns = annotated.direct.filter((c) => primaryColumnIds.has(c.id));
|
|
132
|
+
const secondaryColumns = annotated.direct.filter((c) => !primaryColumnIds.has(c.id));
|
|
133
|
+
|
|
134
|
+
if (primaryColumns.length === 0) return undefined;
|
|
135
|
+
|
|
128
136
|
const columnIsAvailable = createColumnValidationById([
|
|
129
137
|
...annotated.direct,
|
|
130
138
|
...annotated.linked.flatMap((lc) => [...(annotated.linkers.get(lc.id) ?? []), lc]),
|
|
131
139
|
...annotated.labels,
|
|
132
140
|
]);
|
|
133
141
|
|
|
134
|
-
const
|
|
142
|
+
const remapedDefaultFilters = remapFilterColumnIds(options.filters, discovered);
|
|
143
|
+
const filters = concatFilters(
|
|
135
144
|
state.pTableParams.filters,
|
|
136
|
-
|
|
145
|
+
state.pTableParams.defaultFilters ?? remapedDefaultFilters,
|
|
137
146
|
);
|
|
138
147
|
validateFilters(filters, columnIsAvailable);
|
|
139
148
|
|
|
@@ -143,14 +152,6 @@ export function createPlDataTableV3<A, U, S extends RequireServices<typeof Servi
|
|
|
143
152
|
);
|
|
144
153
|
validateSorting(sorting, columnIsAvailable);
|
|
145
154
|
|
|
146
|
-
const primaryColumnIds = new Set<PObjectId>(
|
|
147
|
-
discovered.filter((dc) => dc.isPrimary).map((dc) => dc.id),
|
|
148
|
-
);
|
|
149
|
-
const primaryColumns = annotated.direct.filter((c) => primaryColumnIds.has(c.id));
|
|
150
|
-
const secondaryColumns = annotated.direct.filter((c) => !primaryColumnIds.has(c.id));
|
|
151
|
-
|
|
152
|
-
if (primaryColumns.length === 0) return undefined;
|
|
153
|
-
|
|
154
155
|
const fullDef = createPTableDefV3({
|
|
155
156
|
primaryJoinType,
|
|
156
157
|
primaryColumns,
|
|
@@ -170,10 +171,8 @@ export function createPlDataTableV3<A, U, S extends RequireServices<typeof Servi
|
|
|
170
171
|
...annotated.labels,
|
|
171
172
|
...uniqueBy([...annotated.linkers.values()].flat(), (c) => c.id),
|
|
172
173
|
]);
|
|
173
|
-
if (!fullHandle || !pframeHandle) return undefined;
|
|
174
174
|
|
|
175
175
|
const hiddenSpecs = state.pTableParams.hiddenColIds;
|
|
176
|
-
|
|
177
176
|
const hiddenColumnIds = computeHiddenColumns(
|
|
178
177
|
[...annotated.direct, ...annotated.linked],
|
|
179
178
|
sorting,
|
|
@@ -202,13 +201,13 @@ export function createPlDataTableV3<A, U, S extends RequireServices<typeof Servi
|
|
|
202
201
|
sorting,
|
|
203
202
|
});
|
|
204
203
|
const visibleHandle = ctx.createPTableV2(visibleDef);
|
|
205
|
-
if (!visibleHandle) return undefined;
|
|
206
204
|
|
|
207
205
|
return {
|
|
208
206
|
sourceId: state.pTableParams.sourceId,
|
|
209
207
|
fullTableHandle: fullHandle,
|
|
210
208
|
fullPframeHandle: pframeHandle,
|
|
211
209
|
visibleTableHandle: visibleHandle,
|
|
210
|
+
defaultFilters: remapedDefaultFilters,
|
|
212
211
|
} satisfies PlDataTableModel;
|
|
213
212
|
}
|
|
214
213
|
|
|
@@ -321,17 +320,6 @@ function createColumnValidationById(fullColumns: TableColumn[]) {
|
|
|
321
320
|
};
|
|
322
321
|
}
|
|
323
322
|
|
|
324
|
-
/** Merge filters from table state and options into a single filter spec. */
|
|
325
|
-
function mergeFilters(
|
|
326
|
-
stateFilters: PlDataTableFilters | null,
|
|
327
|
-
optionsFilters: PlDataTableFilters | null | undefined,
|
|
328
|
-
): Nil | PlDataTableFilters {
|
|
329
|
-
const normalized = optionsFilters ?? null;
|
|
330
|
-
return stateFilters !== null && normalized !== null
|
|
331
|
-
? { type: "and", filters: [stateFilters, normalized] }
|
|
332
|
-
: (stateFilters ?? normalized);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
323
|
/** Validate that all column references in filters exist in the table. */
|
|
336
324
|
function validateFilters(
|
|
337
325
|
filters: Nil | PlDataTableFilters,
|
|
@@ -347,6 +335,16 @@ function validateFilters(
|
|
|
347
335
|
}
|
|
348
336
|
}
|
|
349
337
|
|
|
338
|
+
/** Merge two filter trees into one AND-combined tree. Returns the non-nil one if the other is nil. */
|
|
339
|
+
function concatFilters(
|
|
340
|
+
a: Nil | PlDataTableFilters,
|
|
341
|
+
b: Nil | PlDataTableFilters,
|
|
342
|
+
): Nil | PlDataTableFilters {
|
|
343
|
+
if (isNil(a)) return b;
|
|
344
|
+
if (isNil(b)) return a;
|
|
345
|
+
return { ...a, filters: [...a.filters, ...b.filters] };
|
|
346
|
+
}
|
|
347
|
+
|
|
350
348
|
/** Pick user sorting from state if non-empty, otherwise fall back to options default. */
|
|
351
349
|
function resolveSorting(
|
|
352
350
|
userSorting: PTableSorting[],
|
|
@@ -173,6 +173,7 @@ function migrateV4toV5(
|
|
|
173
173
|
gridState: entry.gridState,
|
|
174
174
|
sheetsState: entry.sheetsState,
|
|
175
175
|
filtersState,
|
|
176
|
+
defaultFiltersState: null,
|
|
176
177
|
};
|
|
177
178
|
});
|
|
178
179
|
|
|
@@ -192,6 +193,7 @@ function migrateV4toV5(
|
|
|
192
193
|
state.pTableParams.hiddenColIds?.map((id) => ({ type: "column" as const, id })) ??
|
|
193
194
|
null,
|
|
194
195
|
filters: distillFilterSpec(currentCache.filtersState),
|
|
196
|
+
defaultFilters: null,
|
|
195
197
|
sorting: state.pTableParams.sorting,
|
|
196
198
|
}
|
|
197
199
|
: createDefaultPTableParams(),
|
|
@@ -274,6 +276,7 @@ export function createDefaultPTableParams(): PTableParamsV2 {
|
|
|
274
276
|
sourceId: null,
|
|
275
277
|
hiddenColIds: null,
|
|
276
278
|
filters: null,
|
|
279
|
+
defaultFilters: null,
|
|
277
280
|
sorting: [],
|
|
278
281
|
};
|
|
279
282
|
}
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
PFrameHandle,
|
|
13
13
|
} from "@milaboratories/pl-model-common";
|
|
14
14
|
import type { FilterSpecLeaf } from "../../filters";
|
|
15
|
+
import { Nil } from "@milaboratories/helpers";
|
|
15
16
|
|
|
16
17
|
export type PlTableColumnId = {
|
|
17
18
|
/** Original column spec */
|
|
@@ -62,11 +63,17 @@ export type PlDataTableSheetState = {
|
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
/** Tree-based filter state compatible with PlAdvancedFilter's RootFilter */
|
|
66
|
+
export type PlDataTableFilterMeta = {
|
|
67
|
+
id: number;
|
|
68
|
+
source?: "table-filter" | "table-search";
|
|
69
|
+
isExpanded?: boolean;
|
|
70
|
+
isSuppressed?: boolean;
|
|
71
|
+
};
|
|
65
72
|
export type PlDataTableFilterSpecLeaf = FilterSpecLeaf<CanonicalizedJson<PTableColumnId>>;
|
|
66
73
|
export type PlDataTableFilters = RootFilterSpec<PlDataTableFilterSpecLeaf>;
|
|
67
74
|
export type PlDataTableFiltersWithMeta = RootFilterSpec<
|
|
68
75
|
PlDataTableFilterSpecLeaf,
|
|
69
|
-
|
|
76
|
+
PlDataTableFilterMeta
|
|
70
77
|
>;
|
|
71
78
|
|
|
72
79
|
export type PlDataTableStateV2CacheEntry = {
|
|
@@ -76,8 +83,10 @@ export type PlDataTableStateV2CacheEntry = {
|
|
|
76
83
|
gridState: PlDataTableGridStateCore;
|
|
77
84
|
/** Sheets state */
|
|
78
85
|
sheetsState: PlDataTableSheetState[];
|
|
79
|
-
/**
|
|
86
|
+
/** User filters state (tree-based, compatible with PlAdvancedFilter) */
|
|
80
87
|
filtersState: null | PlDataTableFiltersWithMeta;
|
|
88
|
+
/** Default filters state from model (snapshot of defaults) */
|
|
89
|
+
defaultFiltersState: null | PlDataTableFiltersWithMeta;
|
|
81
90
|
/** Fast search string */
|
|
82
91
|
searchString?: string;
|
|
83
92
|
};
|
|
@@ -86,14 +95,16 @@ export type PTableParamsV2 =
|
|
|
86
95
|
| {
|
|
87
96
|
sourceId: null;
|
|
88
97
|
hiddenColIds: null;
|
|
89
|
-
filters: null;
|
|
90
98
|
sorting: [];
|
|
99
|
+
filters: null;
|
|
100
|
+
defaultFilters: null;
|
|
91
101
|
}
|
|
92
102
|
| {
|
|
93
103
|
sourceId: string;
|
|
94
104
|
hiddenColIds: null | PTableColumnId[];
|
|
95
|
-
filters: null | PlDataTableFilters;
|
|
96
105
|
sorting: PTableSorting[];
|
|
106
|
+
filters: null | PlDataTableFilters;
|
|
107
|
+
defaultFilters: null | PlDataTableFilters;
|
|
97
108
|
};
|
|
98
109
|
|
|
99
110
|
export type PlDataTableStateV2Normalized = {
|
|
@@ -108,13 +119,15 @@ export type PlDataTableStateV2Normalized = {
|
|
|
108
119
|
/** PlAgDataTable model */
|
|
109
120
|
export type PlDataTableModel = {
|
|
110
121
|
/** DataSource identifier for state management */
|
|
111
|
-
sourceId:
|
|
122
|
+
sourceId: null | string;
|
|
112
123
|
/** p-table including all columns, used to show the full specification of the table */
|
|
113
|
-
fullTableHandle
|
|
124
|
+
fullTableHandle?: PTableHandle;
|
|
114
125
|
/** p-frame handle */
|
|
115
|
-
fullPframeHandle
|
|
126
|
+
fullPframeHandle?: PFrameHandle;
|
|
116
127
|
/** p-table including only visible columns, used to get the data */
|
|
117
|
-
visibleTableHandle
|
|
128
|
+
visibleTableHandle?: PTableHandle;
|
|
129
|
+
/** Default filters from model options, surfaced for UI display */
|
|
130
|
+
defaultFilters?: Nil | PlDataTableFilters;
|
|
118
131
|
};
|
|
119
132
|
|
|
120
133
|
export type CreatePlDataTableOps = {
|