@svgrid/grid 3.0.4 → 3.0.5
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/README.md +4 -4
- package/dist/SvGrid.controller.svelte.d.ts +12 -2
- package/dist/SvGrid.controller.svelte.js +192 -8
- package/dist/SvGrid.css +73 -0
- package/dist/SvGrid.svelte +128 -3
- package/dist/SvGrid.types.d.ts +356 -3
- package/dist/build-api.js +11 -6
- package/dist/cdn/{GridMenus-BL7ZgQvU.js → GridMenus-CID62rlI.js} +11 -11
- package/dist/cdn/{GridMenus-7kbpnnBW.js → GridMenus-DLL-qZeu.js} +11 -11
- package/dist/cdn/server-block-cache-CGoWz-87.js +237 -0
- package/dist/cdn/{src-BKhZ6eXd.js → src-Bklofsad.js} +8818 -8798
- package/dist/cdn/{src-V1uu8iE9.js → src-jcFMkBnN.js} +4282 -4262
- package/dist/cdn/svgrid.js +27 -26
- package/dist/cdn/svgrid.svelte-external.js +27 -26
- package/dist/cdn/validate-C7Rn_Bns.js +76 -0
- package/dist/core.js +36 -13
- package/dist/editing.js +10 -0
- package/dist/gantt-view.svelte.d.ts +24 -0
- package/dist/gantt-view.svelte.js +13 -0
- package/dist/grid-icons.d.ts +2 -2
- package/dist/grid-icons.js +2 -2
- package/dist/grid-messages.d.ts +6 -0
- package/dist/grid-messages.js +5 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -3
- package/dist/row-model.d.ts +133 -0
- package/dist/row-model.js +16 -0
- package/dist/selection.d.ts +2 -1
- package/dist/selection.js +30 -2
- package/dist/server-block-cache.d.ts +214 -0
- package/dist/server-block-cache.js +531 -0
- package/dist/server-data-source.d.ts +240 -6
- package/dist/server-data-source.js +220 -20
- package/dist/server.d.ts +13 -0
- package/dist/server.js +13 -0
- package/dist/validate.d.ts +4 -0
- package/dist/validate.js +21 -3
- package/package.json +6 -1
- package/src/SvGrid.controller.svelte.ts +191 -8
- package/src/SvGrid.css +73 -0
- package/src/SvGrid.svelte +128 -3
- package/src/SvGrid.types.ts +376 -3
- package/src/build-api.ts +11 -4
- package/src/core.rowmodel-cache.test.ts +51 -0
- package/src/core.ts +33 -12
- package/src/editing.ts +8 -0
- package/src/gantt-stub.test.svelte +38 -0
- package/src/gantt-view.svelte.ts +35 -0
- package/src/grid-icons.ts +2 -2
- package/src/grid-messages.ts +12 -0
- package/src/icon-seam.test.ts +2 -4
- package/src/index.ts +36 -10
- package/src/row-model.ts +146 -0
- package/src/selection.test.ts +3 -0
- package/src/selection.ts +32 -2
- package/src/server-block-cache.test.ts +645 -0
- package/src/server-block-cache.ts +677 -0
- package/src/server-data-source.infinite.test.ts +343 -0
- package/src/server-data-source.ts +450 -27
- package/src/server.ts +47 -0
- package/src/svgrid.gantt-seam.test.ts +199 -0
- package/src/svgrid.row-model-prop.svelte.test.ts +352 -0
- package/src/svgrid.row-model-seam.svelte.test.ts +289 -0
- package/src/svgrid.upsell-license.test.ts +7 -4
- package/src/validate.test.ts +29 -0
- package/src/validate.ts +28 -3
- package/dist/SvGroupCell.svelte +0 -141
- package/dist/SvGroupCell.svelte.d.ts +0 -49
- package/dist/SvRowGroupPanel.svelte +0 -186
- package/dist/SvRowGroupPanel.svelte.d.ts +0 -25
- package/dist/cdn/validate-_CDJzgIo.js +0 -75
- package/dist/server-group-model.d.ts +0 -98
- package/dist/server-group-model.js +0 -263
- package/src/SvGroupCell.svelte +0 -141
- package/src/SvRowGroupPanel.svelte +0 -186
- package/src/server-group-model.test.ts +0 -294
- package/src/server-group-model.ts +0 -370
package/dist/SvGrid.types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from "svelte";
|
|
2
|
+
import type { GridRowModel } from "./row-model.js";
|
|
2
3
|
import type { CellEditorType, ColumnDef, RowData, SvGridApi, TableFeatures } from "./index.js";
|
|
3
4
|
import type { ConditionalFormat } from "./conditional-formatting.js";
|
|
4
5
|
import type { GroupDisplayType } from "./group-display.js";
|
|
@@ -1074,8 +1075,256 @@ export type SchedulerConfig<TFeatures extends TableFeatures = TableFeatures, TDa
|
|
|
1074
1075
|
searchable?: boolean;
|
|
1075
1076
|
searchPlaceholder?: string;
|
|
1076
1077
|
};
|
|
1078
|
+
/**
|
|
1079
|
+
* The Gantt axis presets: which unit is a tick and which is the coarser row
|
|
1080
|
+
* grouping them. `week` (day ticks under month majors) is the default.
|
|
1081
|
+
*/
|
|
1082
|
+
export type GanttZoom = "day" | "week" | "month" | "quarter" | "year";
|
|
1083
|
+
/**
|
|
1084
|
+
* The four classic dependency kinds. `FS` (finish-to-start) is the default:
|
|
1085
|
+
* the successor may not start before the predecessor finishes.
|
|
1086
|
+
*/
|
|
1087
|
+
export type GanttDependencyType = "FS" | "SS" | "FF" | "SF";
|
|
1088
|
+
/**
|
|
1089
|
+
* A link from a predecessor task (`from`) to a successor (`to`). Both are row
|
|
1090
|
+
* ids (the grid's `getRowId`). `lag` is in DAYS - negative for a lead, so
|
|
1091
|
+
* `{ type: 'FS', lag: -1 }` lets the successor start a day before the
|
|
1092
|
+
* predecessor finishes.
|
|
1093
|
+
*/
|
|
1094
|
+
export type GanttDependency = {
|
|
1095
|
+
id: string;
|
|
1096
|
+
from: string;
|
|
1097
|
+
to: string;
|
|
1098
|
+
type?: GanttDependencyType;
|
|
1099
|
+
lag?: number;
|
|
1100
|
+
};
|
|
1101
|
+
/** Fired when a task bar is dragged to new dates. {@link GanttConfig.onTaskMove}. */
|
|
1102
|
+
export type GanttTaskMoveEvent<TData extends RowData = RowData> = {
|
|
1103
|
+
row: TData;
|
|
1104
|
+
start: Date;
|
|
1105
|
+
end: Date;
|
|
1106
|
+
/**
|
|
1107
|
+
* The moved row's descendants, shifted by the same delta - present only when
|
|
1108
|
+
* a summary (parent) bar was dragged. Cascaded successors are NOT here; they
|
|
1109
|
+
* arrive through {@link GanttConfig.onDependenciesChange}.
|
|
1110
|
+
*/
|
|
1111
|
+
subtree?: Array<{
|
|
1112
|
+
row: TData;
|
|
1113
|
+
start: Date;
|
|
1114
|
+
end: Date;
|
|
1115
|
+
}>;
|
|
1116
|
+
};
|
|
1117
|
+
/** Fired when a task bar's edge is dragged. {@link GanttConfig.onTaskResize}. */
|
|
1118
|
+
export type GanttTaskResizeEvent<TData extends RowData = RowData> = {
|
|
1119
|
+
row: TData;
|
|
1120
|
+
start: Date;
|
|
1121
|
+
end: Date;
|
|
1122
|
+
/** Which edge the user dragged. */
|
|
1123
|
+
edge: "start" | "end";
|
|
1124
|
+
};
|
|
1125
|
+
/** Fired when a bar's progress grip is dragged. {@link GanttConfig.onProgressChange}. */
|
|
1126
|
+
export type GanttProgressChangeEvent<TData extends RowData = RowData> = {
|
|
1127
|
+
row: TData;
|
|
1128
|
+
/** 0-100, in whole percent. */
|
|
1129
|
+
progress: number;
|
|
1130
|
+
};
|
|
1131
|
+
/** Fired when the Gantt's detail drawer is saved. {@link GanttConfig.onTaskCommit}. */
|
|
1132
|
+
export type GanttTaskCommitEvent<TData extends RowData = RowData> = {
|
|
1133
|
+
row: TData;
|
|
1134
|
+
values: Partial<TData>;
|
|
1135
|
+
};
|
|
1136
|
+
/**
|
|
1137
|
+
* The Gantt's built-in task drawer. Same shape as the scheduler's - a field
|
|
1138
|
+
* list, a title and a width - so one drawer config type covers both views.
|
|
1139
|
+
*/
|
|
1140
|
+
export type GanttDrawerConfig<TData extends RowData = RowData> = SchedulerDrawerConfig<TData>;
|
|
1141
|
+
/**
|
|
1142
|
+
* Turns the grid into a Gantt chart. Set `gantt` and the grid renders its rows
|
|
1143
|
+
* as a task table beside a time chart: one bar per row positioned by start /
|
|
1144
|
+
* end, nested into a work-breakdown tree by `parentField`, with dependency
|
|
1145
|
+
* arrows between linked tasks.
|
|
1146
|
+
*
|
|
1147
|
+
* Like the Kanban board and the scheduler it is a pure *view of the grid*: it
|
|
1148
|
+
* renders the grid's filtered + sorted rows and writes back only through
|
|
1149
|
+
* callbacks, never mutating your data. Dragging a bar fires
|
|
1150
|
+
* {@link GanttConfig.onTaskMove} where you reassign the dates on your own rows.
|
|
1151
|
+
*
|
|
1152
|
+
* Dates are local calendar days and `end` is EXCLUSIVE, except that a date-only
|
|
1153
|
+
* string (`'2026-09-14'`, no time part) is read as the end OF that day - the
|
|
1154
|
+
* inclusive convention planning tools use. So
|
|
1155
|
+
* `{ start: '2026-09-14', end: '2026-09-16' }` draws a three-day bar.
|
|
1156
|
+
*/
|
|
1157
|
+
export type GanttConfig<TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData> = {
|
|
1158
|
+
/** Field holding each task's start (`Date` | epoch-ms | ISO string). Required. */
|
|
1159
|
+
startField: keyof TData & string;
|
|
1160
|
+
/** Field holding the end. Omit to use `durationField`, else the task is a milestone. */
|
|
1161
|
+
endField?: keyof TData & string;
|
|
1162
|
+
/** Field holding the length in WORKING days, used when `endField` is absent. */
|
|
1163
|
+
durationField?: keyof TData & string;
|
|
1164
|
+
/** Field for the task name. Defaults to the first column's field. */
|
|
1165
|
+
titleField?: keyof TData & string;
|
|
1166
|
+
/** Field holding percent complete (0-100). Drives the bar's inner fill. */
|
|
1167
|
+
progressField?: keyof TData & string;
|
|
1168
|
+
/**
|
|
1169
|
+
* Field holding each row's PARENT task id, nesting the flat rows into a
|
|
1170
|
+
* work-breakdown tree. Parents render a rolled-up summary bar and a collapse
|
|
1171
|
+
* chevron. Rows whose parent is missing become roots rather than vanishing.
|
|
1172
|
+
*
|
|
1173
|
+
* This is the Gantt's own tree - do NOT also set the grid's `treeData` prop.
|
|
1174
|
+
* `treeData` hides collapsed children from the view entirely, which would
|
|
1175
|
+
* drop them out of their phase's summary bar.
|
|
1176
|
+
*/
|
|
1177
|
+
parentField?: keyof TData & string;
|
|
1178
|
+
/**
|
|
1179
|
+
* Boolean field marking a task as a milestone (a diamond, no length). A task
|
|
1180
|
+
* whose end equals its start renders as one regardless.
|
|
1181
|
+
*/
|
|
1182
|
+
milestoneField?: keyof TData & string;
|
|
1183
|
+
/** Field holding a per-task accent color (any CSS color). Else `color`. */
|
|
1184
|
+
colorField?: keyof TData & string;
|
|
1185
|
+
/** Fallback accent color for every bar. */
|
|
1186
|
+
color?: string;
|
|
1187
|
+
/**
|
|
1188
|
+
* Predecessor -> successor links, drawn as arrows between bars. `from` / `to`
|
|
1189
|
+
* are row ids (your `getRowId`). See {@link GanttDependency}.
|
|
1190
|
+
*/
|
|
1191
|
+
dependencies?: ReadonlyArray<GanttDependency>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Per-row field holding that row's links (as `GanttDependency[]` or a plain
|
|
1194
|
+
* list of successor ids). An alternative to the flat `dependencies` array.
|
|
1195
|
+
*/
|
|
1196
|
+
dependencyField?: keyof TData & string;
|
|
1197
|
+
/**
|
|
1198
|
+
* Cascade successors forward on move / resize so every link stays legal,
|
|
1199
|
+
* preserving each task's duration. Defaults to `true` when any dependency is
|
|
1200
|
+
* present. Cascading never pulls a task earlier.
|
|
1201
|
+
*/
|
|
1202
|
+
autoReschedule?: boolean;
|
|
1203
|
+
/**
|
|
1204
|
+
* Schedule in working time (see `nonWorkingDays` / `holidays`): a moved
|
|
1205
|
+
* or cascaded task lands on a working day and keeps its WORKING length, so
|
|
1206
|
+
* a five-day task dragged over a weekend stays five days of work, and the
|
|
1207
|
+
* critical path measures slack in working days. `false` schedules in
|
|
1208
|
+
* calendar time. Default `true`.
|
|
1209
|
+
*/
|
|
1210
|
+
respectWorkingTime?: boolean;
|
|
1211
|
+
/** Fired with the cascaded shifts after a move / resize (never mutates rows). */
|
|
1212
|
+
onDependenciesChange?: (moves: Array<{
|
|
1213
|
+
id: string;
|
|
1214
|
+
start: Date;
|
|
1215
|
+
end: Date;
|
|
1216
|
+
}>) => void;
|
|
1217
|
+
/** Fired when the user draws a new link (drag from one bar's edge to another). */
|
|
1218
|
+
onDependencyAdd?: (dep: GanttDependency) => void;
|
|
1219
|
+
/** Fired when the user removes a link (arrow context menu). */
|
|
1220
|
+
onDependencyRemove?: (id: string) => void;
|
|
1221
|
+
/** The axis preset the chart opens on. Default `'week'`. */
|
|
1222
|
+
zoom?: GanttZoom;
|
|
1223
|
+
/**
|
|
1224
|
+
* The presets the toolbar's zoom stepper offers. Default all five; a single
|
|
1225
|
+
* entry hides the stepper.
|
|
1226
|
+
*/
|
|
1227
|
+
zoomLevels?: ReadonlyArray<GanttZoom>;
|
|
1228
|
+
/** Fired when the zoom preset changes (stepper or Ctrl+wheel). */
|
|
1229
|
+
onZoomChange?: (zoom: GanttZoom) => void;
|
|
1230
|
+
/** First day of the week, 0-6 (0 = Sunday). Default 0. */
|
|
1231
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
1232
|
+
/**
|
|
1233
|
+
* Weekday numbers (0 = Sun ... 6 = Sat) that are non-working: shaded in the
|
|
1234
|
+
* chart and skipped by duration + cascade arithmetic. Default `[0, 6]`.
|
|
1235
|
+
*/
|
|
1236
|
+
nonWorkingDays?: ReadonlyArray<number>;
|
|
1237
|
+
/** Specific dates that are non-working (holidays, closures). */
|
|
1238
|
+
holidays?: ReadonlyArray<Date | number | string>;
|
|
1239
|
+
/** Shade the non-working columns. Default `true`. */
|
|
1240
|
+
showNonWorking?: boolean;
|
|
1241
|
+
/** Draw the dashed "today" line across the chart. Default `true`. */
|
|
1242
|
+
todayLine?: boolean;
|
|
1243
|
+
/** Earliest date the axis shows and a drag may reach. */
|
|
1244
|
+
minDate?: Date | number | string;
|
|
1245
|
+
/** Latest date the axis shows and a drag may reach. */
|
|
1246
|
+
maxDate?: Date | number | string;
|
|
1247
|
+
/** Calendar days of slack around the first start / last end. Default 7. */
|
|
1248
|
+
rangePaddingDays?: number;
|
|
1249
|
+
/**
|
|
1250
|
+
* Column ids shown in the task table, in order. Defaults to every leaf
|
|
1251
|
+
* column. Two built-ins need no column definition: `'__duration'` (working
|
|
1252
|
+
* days) and `'__progress'` (a small bar).
|
|
1253
|
+
*/
|
|
1254
|
+
tableColumns?: ReadonlyArray<string>;
|
|
1255
|
+
/** Width (px) of the task table pane. Default 360; a splitter resizes it. */
|
|
1256
|
+
tableWidth?: number;
|
|
1257
|
+
/** Height (px) of one task row. Default 32. */
|
|
1258
|
+
rowHeight?: number;
|
|
1259
|
+
/** Parents draw a rolled-up summary bar spanning their children. Default `true`. */
|
|
1260
|
+
summaryBars?: boolean;
|
|
1261
|
+
/**
|
|
1262
|
+
* Where a bar's label sits: `'inside'` (default, falling back to the right
|
|
1263
|
+
* when the bar is too narrow), always `'right'`, or `'none'`.
|
|
1264
|
+
*/
|
|
1265
|
+
labelPosition?: "inside" | "right" | "none";
|
|
1266
|
+
/**
|
|
1267
|
+
* Controlled collapse: the ids of the parent rows whose children are hidden.
|
|
1268
|
+
* Omit to let the Gantt own its own collapse state.
|
|
1269
|
+
*/
|
|
1270
|
+
collapsed?: ReadonlyArray<string>;
|
|
1271
|
+
/** Fired when a chevron (or Expand / Collapse all) changes the collapsed set. */
|
|
1272
|
+
onCollapseChange?: (collapsed: string[]) => void;
|
|
1273
|
+
/**
|
|
1274
|
+
* Enable drag-to-move, edge resize, the progress grip and link drawing.
|
|
1275
|
+
* Without it the chart is read-only.
|
|
1276
|
+
*/
|
|
1277
|
+
editable?: boolean;
|
|
1278
|
+
/**
|
|
1279
|
+
* Enable undo / redo of move, resize and progress edits with `Ctrl/Cmd+Z` and
|
|
1280
|
+
* `Ctrl/Cmd+Shift+Z` (or `Ctrl+Y`). The callbacks re-fire with the reversed
|
|
1281
|
+
* values, so your data follows.
|
|
1282
|
+
*/
|
|
1283
|
+
history?: boolean;
|
|
1284
|
+
/** Fired when a bar is dragged to new dates. */
|
|
1285
|
+
onTaskMove?: (event: GanttTaskMoveEvent<TData>) => void;
|
|
1286
|
+
/** Fired when a bar's edge is dragged. */
|
|
1287
|
+
onTaskResize?: (event: GanttTaskResizeEvent<TData>) => void;
|
|
1288
|
+
/** Fired when the progress grip is dragged. */
|
|
1289
|
+
onProgressChange?: (event: GanttProgressChangeEvent<TData>) => void;
|
|
1290
|
+
/** Fired when empty chart space is double-clicked - create a task there. */
|
|
1291
|
+
onTaskAdd?: (start: Date, end: Date, parentId?: string) => void;
|
|
1292
|
+
/**
|
|
1293
|
+
* Fired from the bar's Delete action. Setting this shows Delete in the
|
|
1294
|
+
* drawer and the context menu. Remove the row from your data in the handler.
|
|
1295
|
+
*/
|
|
1296
|
+
onTaskDelete?: (row: TData) => void;
|
|
1297
|
+
/**
|
|
1298
|
+
* Custom body for a TASK bar. Receives the row. Omit for the built-in label.
|
|
1299
|
+
* A phase's summary bar is a thin spine with no room for a body, so it keeps
|
|
1300
|
+
* its plain label; a milestone has no body at all.
|
|
1301
|
+
*/
|
|
1302
|
+
task?: Snippet<[TData]>;
|
|
1303
|
+
/**
|
|
1304
|
+
* Hover tooltip for a bar. A `Snippet<[TData]>` for custom content, or `true`
|
|
1305
|
+
* for the built-in one (title, dates, duration, percent). Omit to disable.
|
|
1306
|
+
*/
|
|
1307
|
+
tooltip?: boolean | Snippet<[TData]>;
|
|
1308
|
+
/** Delay (ms) before the hover tooltip opens. Default 400. */
|
|
1309
|
+
tooltipDelay?: number;
|
|
1310
|
+
/** Built-in task drawer: `true` for all fields, or a config object. */
|
|
1311
|
+
drawer?: boolean | GanttDrawerConfig<TData>;
|
|
1312
|
+
/** Fired when the drawer is saved. */
|
|
1313
|
+
onTaskCommit?: (event: GanttTaskCommitEvent<TData>) => void;
|
|
1314
|
+
/** Right-click menu for a bar. Return items or `undefined` to suppress. */
|
|
1315
|
+
taskMenu?: (row: TData) => MenuItem[] | undefined;
|
|
1316
|
+
/** Show the search box (binds to the grid's global filter). Default `true`. */
|
|
1317
|
+
searchable?: boolean;
|
|
1318
|
+
searchPlaceholder?: string;
|
|
1319
|
+
};
|
|
1077
1320
|
export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData> = {
|
|
1078
|
-
|
|
1321
|
+
/**
|
|
1322
|
+
* The rows to render.
|
|
1323
|
+
*
|
|
1324
|
+
* Optional only because `rowModel` can supply them instead; a grid with
|
|
1325
|
+
* neither renders empty. When both are present `data` wins.
|
|
1326
|
+
*/
|
|
1327
|
+
data?: ReadonlyArray<TData>;
|
|
1079
1328
|
columns: Array<ColumnDef<TFeatures, TData>>;
|
|
1080
1329
|
/**
|
|
1081
1330
|
* Kanban board mode. When set, the grid renders its rows as cards in
|
|
@@ -1089,6 +1338,15 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
|
|
|
1089
1338
|
* {@link SchedulerConfig}.
|
|
1090
1339
|
*/
|
|
1091
1340
|
scheduler?: SchedulerConfig<TFeatures, TData>;
|
|
1341
|
+
/**
|
|
1342
|
+
* Gantt mode. When set, the grid renders its rows as a task table beside a
|
|
1343
|
+
* time chart: one bar per row by start / end, a work-breakdown tree from
|
|
1344
|
+
* `parentField`, and dependency arrows. See {@link GanttConfig}.
|
|
1345
|
+
*
|
|
1346
|
+
* A view of the grid like the board and scheduler; the renderer ships in
|
|
1347
|
+
* `@svgrid/enterprise` (call `enableGanttView()`).
|
|
1348
|
+
*/
|
|
1349
|
+
gantt?: GanttConfig<TFeatures, TData>;
|
|
1092
1350
|
/**
|
|
1093
1351
|
* Chart view. When set, the grid renders its FILTERED + SORTED rows as a chart
|
|
1094
1352
|
* instead of a table (search / filters / sort flow through). Unlike board and
|
|
@@ -2078,6 +2336,99 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
|
|
|
2078
2336
|
scrollHeight: number;
|
|
2079
2337
|
clientHeight: number;
|
|
2080
2338
|
}) => void;
|
|
2339
|
+
/**
|
|
2340
|
+
* Fires when the range of rows on screen changes, with the first and last
|
|
2341
|
+
* row INDEX (not pixels). Coalesced to one call per frame, so it is cheap
|
|
2342
|
+
* to wire to something that fetches.
|
|
2343
|
+
*
|
|
2344
|
+
* This is the hook a block-loading data source needs and
|
|
2345
|
+
* `onScrollBottomReached` cannot give it: "the user is looking at rows
|
|
2346
|
+
* 4,000-4,020" answers which block to fetch and which to keep, while
|
|
2347
|
+
* "they hit the bottom" only ever means "append more". Both are free; use
|
|
2348
|
+
* this one with `createServerDataSource({ mode: 'infinite' })`, or let
|
|
2349
|
+
* `rowModel` wire it for you.
|
|
2350
|
+
*
|
|
2351
|
+
* Reports `0, data.length - 1` when virtualization is off, since every row
|
|
2352
|
+
* really is rendered.
|
|
2353
|
+
*/
|
|
2354
|
+
onVisibleRangeChange?: (range: {
|
|
2355
|
+
startIndex: number;
|
|
2356
|
+
endIndex: number;
|
|
2357
|
+
}) => void;
|
|
2358
|
+
/**
|
|
2359
|
+
* Marks a row as one whose data has not arrived: `"loading"` draws a
|
|
2360
|
+
* shimmer in every cell, `"failed"` draws a full-width "could not load"
|
|
2361
|
+
* row with a Retry button, and `null` (the default for every row) renders
|
|
2362
|
+
* normally.
|
|
2363
|
+
*
|
|
2364
|
+
* Placeholder rows are inert - not selectable, not editable, and skipped
|
|
2365
|
+
* by cell navigation - because there is nothing there to act on yet.
|
|
2366
|
+
*
|
|
2367
|
+
* `createServerDataSource` in `infinite` mode fills the gaps with rows this
|
|
2368
|
+
* recognises, so the usual wiring is `rowPlaceholder={rowPlaceholderState}`
|
|
2369
|
+
* (or nothing at all, via `rowModel`).
|
|
2370
|
+
*/
|
|
2371
|
+
rowPlaceholder?: (row: TData, rowIndex: number) => "loading" | "failed" | null;
|
|
2372
|
+
/** Called by the Retry button on a `"failed"` placeholder row. */
|
|
2373
|
+
onRetryRow?: (row: TData, rowIndex: number) => void;
|
|
2374
|
+
/**
|
|
2375
|
+
* Hand selection over to an external model.
|
|
2376
|
+
*
|
|
2377
|
+
* The grid normally tracks selection as a record of the row ids it has
|
|
2378
|
+
* seen, which is right until the rows it has seen are a window onto a
|
|
2379
|
+
* million on a server: "select all" then means 20 ticked checkboxes rather
|
|
2380
|
+
* than a million, and the header checkbox cannot honestly say `all`. A
|
|
2381
|
+
* model that stores the RULE ("everything except these three") can answer
|
|
2382
|
+
* both, so when this is set the header checkbox, the row checkboxes and
|
|
2383
|
+
* `api.selectAllRows()` all route through it instead.
|
|
2384
|
+
*
|
|
2385
|
+
* `@svgrid/enterprise` ships one for the server-side row model; this is the
|
|
2386
|
+
* seam it plugs into.
|
|
2387
|
+
*/
|
|
2388
|
+
/**
|
|
2389
|
+
* Drive the grid from a row model instead of wiring a dozen props.
|
|
2390
|
+
*
|
|
2391
|
+
* `createServerDataSource` returns one, and so does the Enterprise
|
|
2392
|
+
* server-side row model, so server-backed grids become:
|
|
2393
|
+
*
|
|
2394
|
+
* ```svelte
|
|
2395
|
+
* <SvGrid rowModel={ctl} {columns} />
|
|
2396
|
+
* ```
|
|
2397
|
+
*
|
|
2398
|
+
* The model supplies `data`, `loading`, `getRowId`, the external sort
|
|
2399
|
+
* and filter wiring, the visible range, placeholder rows, group
|
|
2400
|
+
* accessors, selection and paging - each one only if it implements that
|
|
2401
|
+
* part. A prop written explicitly on the grid always wins, so you can
|
|
2402
|
+
* adopt it and still override one piece.
|
|
2403
|
+
*/
|
|
2404
|
+
rowModel?: GridRowModel<TData>;
|
|
2405
|
+
/**
|
|
2406
|
+
* Columns that REPLACE `columns` while set. The server-side row model
|
|
2407
|
+
* supplies them in pivot mode - one column per pivoted value, grouped
|
|
2408
|
+
* under a header per pivot key - and clears them when pivot mode ends,
|
|
2409
|
+
* so `columns` stays the app's own list. Rarely set by hand.
|
|
2410
|
+
*/
|
|
2411
|
+
pivotResultColumns?: Array<ColumnDef<TFeatures, TData>> | null;
|
|
2412
|
+
rowSelectionModel?: {
|
|
2413
|
+
isSelected: (rowId: string, row: TData) => boolean;
|
|
2414
|
+
/** Whether the header checkbox shows empty, indeterminate, or ticked. */
|
|
2415
|
+
headerState: () => "none" | "some" | "all";
|
|
2416
|
+
toggle: (rowId: string, row: TData, next: boolean) => void;
|
|
2417
|
+
/** The header checkbox: select or clear everything, loaded or not. */
|
|
2418
|
+
toggleAll: (next: boolean) => void;
|
|
2419
|
+
/**
|
|
2420
|
+
* How many rows the rule selects, counting the ones the grid never
|
|
2421
|
+
* loaded; `null` when it cannot say. The selection bar shows this
|
|
2422
|
+
* instead of counting ticked rows on screen.
|
|
2423
|
+
*/
|
|
2424
|
+
selectedCount?: () => number | null;
|
|
2425
|
+
/**
|
|
2426
|
+
* Apply one patch to every selected row, loaded or not. When present,
|
|
2427
|
+
* the bulk-edit drawer sends its edits here instead of writing the
|
|
2428
|
+
* loaded cells. Resolves with how many rows changed.
|
|
2429
|
+
*/
|
|
2430
|
+
bulkUpdate?: (patch: Record<string, unknown>) => Promise<number>;
|
|
2431
|
+
};
|
|
2081
2432
|
/**
|
|
2082
2433
|
* Marks a row as an expandable "detail row". When this returns true the
|
|
2083
2434
|
* grid renders that row as a SINGLE full-width cell (colspan across every
|
|
@@ -2101,8 +2452,10 @@ export type Props<TFeatures extends TableFeatures = TableFeatures, TData extends
|
|
|
2101
2452
|
* Server-side group / tree keyboard + accessibility, built into the grid. When
|
|
2102
2453
|
* set, the grid uses the treegrid role and marks matching rows with
|
|
2103
2454
|
* `aria-level` / `aria-expanded`, and ArrowRight / ArrowLeft expand / collapse
|
|
2104
|
-
* the focused group row (no app-level key handling). Pair with
|
|
2105
|
-
* + `SvGroupCell` for the visual
|
|
2455
|
+
* the focused group row (no app-level key handling). Pair with
|
|
2456
|
+
* `serverGroupRows` + `SvGroupCell` from `@svgrid/enterprise` for the visual
|
|
2457
|
+
* expander, or drive it from your own tree state. Every accessor receives the
|
|
2458
|
+
* row data.
|
|
2106
2459
|
*/
|
|
2107
2460
|
serverGroup?: {
|
|
2108
2461
|
/** Whether a row is an expandable group / branch. */
|
package/dist/build-api.js
CHANGED
|
@@ -691,11 +691,10 @@ export function createGridApi(ctx) {
|
|
|
691
691
|
});
|
|
692
692
|
},
|
|
693
693
|
selectAllRows() {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
ctx.grid.setRowSelection(() => next);
|
|
694
|
+
// One implementation of "select everything", shared with the header
|
|
695
|
+
// checkbox, so it knows about an external selection model and about
|
|
696
|
+
// rows whose data has not arrived.
|
|
697
|
+
ctx.setSelectAllRows(true);
|
|
699
698
|
},
|
|
700
699
|
toggleRowSelected(id) {
|
|
701
700
|
ctx.toggleRowSelectionById(id);
|
|
@@ -703,7 +702,13 @@ export function createGridApi(ctx) {
|
|
|
703
702
|
// ---- Pagination
|
|
704
703
|
getPageInfo() {
|
|
705
704
|
const { pageIndex, pageSize } = ctx.paginationState;
|
|
706
|
-
|
|
705
|
+
// Under external pagination the grid holds ONE page, so counting the
|
|
706
|
+
// rows in hand would report a 95-row table as a 20-row one. The
|
|
707
|
+
// consumer tells us the real total through rowCount, which is what
|
|
708
|
+
// the footer has always shown.
|
|
709
|
+
const total = ctx.externalPaginationEnabled
|
|
710
|
+
? (ctx.props.rowCount ?? ctx.allRowsBeforePagination.length)
|
|
711
|
+
: ctx.allRowsBeforePagination.length;
|
|
707
712
|
const pageCount = Math.max(1, Math.ceil(total / Math.max(1, pageSize)));
|
|
708
713
|
return { pageIndex, pageSize, pageCount, total };
|
|
709
714
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $a as e,
|
|
1
|
+
import { $a as e, Ln as t, Qa as n } from "./src-Bklofsad.js";
|
|
2
2
|
import { S as r, _ as i, j as a, k as o } from "./editor-registry-BhgE3S84.js";
|
|
3
3
|
import { r as s } from "./dismissable-DAHetSNk.js";
|
|
4
4
|
import * as c from "svelte/internal/client";
|
|
@@ -280,11 +280,11 @@ function _e(_e, M) {
|
|
|
280
280
|
t?.closest(".sv-listbox") || t?.tagName === "BUTTON" || (e.preventDefault(), c.get(q)());
|
|
281
281
|
}
|
|
282
282
|
let Ze = c.derived(() => P().columnMenuFacetOptions), Qe = c.derived(() => P().columnMenuSelectedFacets), $e = c.derived(() => P().setFacetSelection), et = c.derived(() => P().setFilterTokens), Z = c.derived(() => P().inSuggestOptions), tt = c.derived(() => P().openInSuggest), nt = c.derived(() => P().closeInSuggest), rt = c.derived(() => P().isAllFacetsChecked), it = c.derived(() => P().toggleAllFacets), at = 40;
|
|
283
|
-
function ot(
|
|
284
|
-
c.get(tt)(
|
|
283
|
+
function ot(t, n) {
|
|
284
|
+
c.get(tt)(t, n), P().inSuggestQuery = e(t.value);
|
|
285
285
|
}
|
|
286
|
-
function st(
|
|
287
|
-
P().inSuggestQuery =
|
|
286
|
+
function st(t, n) {
|
|
287
|
+
P().inSuggestQuery = e(t.value), P().inSuggestFor !== n && c.get(tt)(t, n);
|
|
288
288
|
}
|
|
289
289
|
function ct(e) {
|
|
290
290
|
return e.map((e) => ({
|
|
@@ -513,11 +513,11 @@ function _e(_e, M) {
|
|
|
513
513
|
c.get(V) && e(At);
|
|
514
514
|
});
|
|
515
515
|
var jt = c.sibling(kt, 2), Mt = (r) => {
|
|
516
|
-
let i = c.derived(() => c.get(Fe)), a = c.derived(() => new Set(
|
|
517
|
-
var o = fe(), s = c.child(o), l = (
|
|
516
|
+
let i = c.derived(() => c.get(Fe)), a = c.derived(() => new Set(n(c.get(Pe)[c.get(i)] ?? "")));
|
|
517
|
+
var o = fe(), s = c.child(o), l = (n) => {
|
|
518
518
|
{
|
|
519
519
|
let r = c.derived(() => c.get(Z).length > 40);
|
|
520
|
-
t(
|
|
520
|
+
t(n, {
|
|
521
521
|
block: !0,
|
|
522
522
|
checkbox: !0,
|
|
523
523
|
multiple: !0,
|
|
@@ -534,9 +534,9 @@ function _e(_e, M) {
|
|
|
534
534
|
get value() {
|
|
535
535
|
return c.get(a);
|
|
536
536
|
},
|
|
537
|
-
onChange: (
|
|
538
|
-
let
|
|
539
|
-
r &&
|
|
537
|
+
onChange: (t) => {
|
|
538
|
+
let n = new Set(t), r = e(c.get(Pe)[c.get(i)] ?? "");
|
|
539
|
+
r && n.delete(r), c.get(et)(c.get(i), [...n]), P().inSuggestQuery = "";
|
|
540
540
|
}
|
|
541
541
|
});
|
|
542
542
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $a as e,
|
|
1
|
+
import { $a as e, Ln as t, Qa as n } from "./src-jcFMkBnN.js";
|
|
2
2
|
import { D as r, E as i, F as a, G as o, H as s, I as c, L as l, N as u, Q as d, R as f, U as p, V as m, X as h, Y as g, Z as _, _ as v, at as y, b, d as x, et as S, f as C, ft as w, g as ee, h as T, it as E, j as D, k as O, lt as k, m as te, mt as ne, nt as A, o as re, pt as j, st as M, t as ie, tt as N, u as P, ut as ae, v as F, w as oe } from "./disclose-version-Dr7rEVv-.js";
|
|
3
3
|
import { S as se, _ as ce, j as le, k as ue } from "./editor-registry-BhgE3S84.js";
|
|
4
4
|
import { r as I } from "./dismissable-DAHetSNk.js";
|
|
@@ -279,11 +279,11 @@ function H(l, f) {
|
|
|
279
279
|
t?.closest(".sv-listbox") || t?.tagName === "BUTTON" || (e.preventDefault(), o(Q)());
|
|
280
280
|
}
|
|
281
281
|
let jt = M(() => H().columnMenuFacetOptions), Mt = M(() => H().columnMenuSelectedFacets), Nt = M(() => H().setFacetSelection), Pt = M(() => H().setFilterTokens), Ft = M(() => H().inSuggestOptions), It = M(() => H().openInSuggest), Lt = M(() => H().closeInSuggest), Rt = M(() => H().isAllFacetsChecked), zt = M(() => H().toggleAllFacets), Bt = 40;
|
|
282
|
-
function Vt(
|
|
283
|
-
o(It)(
|
|
282
|
+
function Vt(t, n) {
|
|
283
|
+
o(It)(t, n), H().inSuggestQuery = e(t.value);
|
|
284
284
|
}
|
|
285
|
-
function Ht(
|
|
286
|
-
H().inSuggestQuery =
|
|
285
|
+
function Ht(t, n) {
|
|
286
|
+
H().inSuggestQuery = e(t.value), H().inSuggestFor !== n && o(It)(t, n);
|
|
287
287
|
}
|
|
288
288
|
function Ut(e) {
|
|
289
289
|
return e.map((e) => ({
|
|
@@ -512,11 +512,11 @@ function H(l, f) {
|
|
|
512
512
|
o(Je) && e(pn);
|
|
513
513
|
});
|
|
514
514
|
var mn = A(fn, 2), hn = (r) => {
|
|
515
|
-
let i = M(() => o(ft)), c = M(() => new Set(
|
|
516
|
-
var l = Re(), u = S(l), d = (
|
|
515
|
+
let i = M(() => o(ft)), c = M(() => new Set(n(o(dt)[o(i)] ?? "")));
|
|
516
|
+
var l = Re(), u = S(l), d = (n) => {
|
|
517
517
|
{
|
|
518
518
|
let r = M(() => o(Ft).length > 40);
|
|
519
|
-
t(
|
|
519
|
+
t(n, {
|
|
520
520
|
block: !0,
|
|
521
521
|
checkbox: !0,
|
|
522
522
|
multiple: !0,
|
|
@@ -533,9 +533,9 @@ function H(l, f) {
|
|
|
533
533
|
get value() {
|
|
534
534
|
return o(c);
|
|
535
535
|
},
|
|
536
|
-
onChange: (
|
|
537
|
-
let
|
|
538
|
-
r &&
|
|
536
|
+
onChange: (t) => {
|
|
537
|
+
let n = new Set(t), r = e(o(dt)[o(i)] ?? "");
|
|
538
|
+
r && n.delete(r), o(Pt)(o(i), [...n]), H().inSuggestQuery = "";
|
|
539
539
|
}
|
|
540
540
|
});
|
|
541
541
|
}
|