@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.
Files changed (77) hide show
  1. package/README.md +4 -4
  2. package/dist/SvGrid.controller.svelte.d.ts +12 -2
  3. package/dist/SvGrid.controller.svelte.js +192 -8
  4. package/dist/SvGrid.css +73 -0
  5. package/dist/SvGrid.svelte +128 -3
  6. package/dist/SvGrid.types.d.ts +356 -3
  7. package/dist/build-api.js +11 -6
  8. package/dist/cdn/{GridMenus-BL7ZgQvU.js → GridMenus-CID62rlI.js} +11 -11
  9. package/dist/cdn/{GridMenus-7kbpnnBW.js → GridMenus-DLL-qZeu.js} +11 -11
  10. package/dist/cdn/server-block-cache-CGoWz-87.js +237 -0
  11. package/dist/cdn/{src-BKhZ6eXd.js → src-Bklofsad.js} +8818 -8798
  12. package/dist/cdn/{src-V1uu8iE9.js → src-jcFMkBnN.js} +4282 -4262
  13. package/dist/cdn/svgrid.js +27 -26
  14. package/dist/cdn/svgrid.svelte-external.js +27 -26
  15. package/dist/cdn/validate-C7Rn_Bns.js +76 -0
  16. package/dist/core.js +36 -13
  17. package/dist/editing.js +10 -0
  18. package/dist/gantt-view.svelte.d.ts +24 -0
  19. package/dist/gantt-view.svelte.js +13 -0
  20. package/dist/grid-icons.d.ts +2 -2
  21. package/dist/grid-icons.js +2 -2
  22. package/dist/grid-messages.d.ts +6 -0
  23. package/dist/grid-messages.js +5 -0
  24. package/dist/index.d.ts +5 -4
  25. package/dist/index.js +3 -3
  26. package/dist/row-model.d.ts +133 -0
  27. package/dist/row-model.js +16 -0
  28. package/dist/selection.d.ts +2 -1
  29. package/dist/selection.js +30 -2
  30. package/dist/server-block-cache.d.ts +214 -0
  31. package/dist/server-block-cache.js +531 -0
  32. package/dist/server-data-source.d.ts +240 -6
  33. package/dist/server-data-source.js +220 -20
  34. package/dist/server.d.ts +13 -0
  35. package/dist/server.js +13 -0
  36. package/dist/validate.d.ts +4 -0
  37. package/dist/validate.js +21 -3
  38. package/package.json +6 -1
  39. package/src/SvGrid.controller.svelte.ts +191 -8
  40. package/src/SvGrid.css +73 -0
  41. package/src/SvGrid.svelte +128 -3
  42. package/src/SvGrid.types.ts +376 -3
  43. package/src/build-api.ts +11 -4
  44. package/src/core.rowmodel-cache.test.ts +51 -0
  45. package/src/core.ts +33 -12
  46. package/src/editing.ts +8 -0
  47. package/src/gantt-stub.test.svelte +38 -0
  48. package/src/gantt-view.svelte.ts +35 -0
  49. package/src/grid-icons.ts +2 -2
  50. package/src/grid-messages.ts +12 -0
  51. package/src/icon-seam.test.ts +2 -4
  52. package/src/index.ts +36 -10
  53. package/src/row-model.ts +146 -0
  54. package/src/selection.test.ts +3 -0
  55. package/src/selection.ts +32 -2
  56. package/src/server-block-cache.test.ts +645 -0
  57. package/src/server-block-cache.ts +677 -0
  58. package/src/server-data-source.infinite.test.ts +343 -0
  59. package/src/server-data-source.ts +450 -27
  60. package/src/server.ts +47 -0
  61. package/src/svgrid.gantt-seam.test.ts +199 -0
  62. package/src/svgrid.row-model-prop.svelte.test.ts +352 -0
  63. package/src/svgrid.row-model-seam.svelte.test.ts +289 -0
  64. package/src/svgrid.upsell-license.test.ts +7 -4
  65. package/src/validate.test.ts +29 -0
  66. package/src/validate.ts +28 -3
  67. package/dist/SvGroupCell.svelte +0 -141
  68. package/dist/SvGroupCell.svelte.d.ts +0 -49
  69. package/dist/SvRowGroupPanel.svelte +0 -186
  70. package/dist/SvRowGroupPanel.svelte.d.ts +0 -25
  71. package/dist/cdn/validate-_CDJzgIo.js +0 -75
  72. package/dist/server-group-model.d.ts +0 -98
  73. package/dist/server-group-model.js +0 -263
  74. package/src/SvGroupCell.svelte +0 -141
  75. package/src/SvRowGroupPanel.svelte +0 -186
  76. package/src/server-group-model.test.ts +0 -294
  77. package/src/server-group-model.ts +0 -370
@@ -0,0 +1,289 @@
1
+ /**
2
+ * The four seams a server-backed row model plugs into, all free:
3
+ *
4
+ * - `onVisibleRangeChange` - which rows are on screen, by index
5
+ * - `rowPlaceholder` / `onRetryRow` - rows whose data has not arrived
6
+ * - `rowSelectionModel` - selection the grid does not own
7
+ *
8
+ * They are deliberately generic: none of them mentions groups, blocks or a
9
+ * datasource, so the free infinite controller and the Enterprise row model
10
+ * plug into the same four holes, and an app with its own fetching can too.
11
+ */
12
+ import { describe, expect, it, vi } from 'vitest'
13
+ import { mount, unmount } from 'svelte'
14
+ import SvGrid from './SvGrid.svelte'
15
+ import {
16
+ createCoreRowModel,
17
+ rowSelectionFeature,
18
+ rowSortingFeature,
19
+ tableFeatures,
20
+ } from './index'
21
+ import type { ColumnDef, SvGridApi } from './index'
22
+
23
+ type Row = { id: number; name: string }
24
+ const features = tableFeatures({ rowSortingFeature, rowSelectionFeature })
25
+ const cols: ColumnDef<typeof features, Row>[] = [
26
+ { field: 'name', header: 'Name', width: 160 },
27
+ { field: 'id', header: 'Id', width: 80 },
28
+ ]
29
+
30
+ const tick = () => new Promise<void>((r) => setTimeout(r))
31
+ const rowsOf = (n: number): Row[] =>
32
+ Array.from({ length: n }, (_, i) => ({ id: i, name: `Row ${i}` }))
33
+
34
+ function mountGrid(extra: Record<string, unknown>, data: Row[] = rowsOf(5)) {
35
+ return new Promise<{
36
+ api: SvGridApi<typeof features, Row>
37
+ target: HTMLElement
38
+ destroy: () => void
39
+ }>((res, rej) => {
40
+ const target = document.createElement('div')
41
+ document.body.appendChild(target)
42
+ const app = mount(SvGrid, {
43
+ target,
44
+ props: {
45
+ data,
46
+ columns: cols,
47
+ features,
48
+ _rowModels: { coreRowModel: createCoreRowModel() },
49
+ getRowId: (r: Row) => String(r.id),
50
+ containerHeight: 200,
51
+ virtualization: false,
52
+ onApiReady(api: SvGridApi<typeof features, Row>) {
53
+ res({ api, target, destroy: () => { unmount(app); target.remove() } })
54
+ },
55
+ ...extra,
56
+ } as any,
57
+ })
58
+ queueMicrotask(() => {
59
+ if (!target.querySelector('[role="grid"]')) rej(new Error('no grid'))
60
+ })
61
+ })
62
+ }
63
+
64
+ describe('onVisibleRangeChange', () => {
65
+ it('reports the whole list when virtualization is off', async () => {
66
+ const seen: Array<{ startIndex: number; endIndex: number }> = []
67
+ const { destroy } = await mountGrid({ onVisibleRangeChange: (r: any) => seen.push(r) }, rowsOf(5))
68
+ await tick()
69
+
70
+ expect(seen.at(-1)).toEqual({ startIndex: 0, endIndex: 4 })
71
+ destroy()
72
+ })
73
+
74
+ it('reports row indices, not pixels, when virtualization is on', async () => {
75
+ const seen: Array<{ startIndex: number; endIndex: number }> = []
76
+ const { destroy } = await mountGrid(
77
+ {
78
+ onVisibleRangeChange: (r: any) => seen.push(r),
79
+ virtualization: true,
80
+ containerHeight: 200,
81
+ },
82
+ rowsOf(10_000),
83
+ )
84
+ await tick()
85
+
86
+ const last = seen.at(-1)!
87
+ expect(last.startIndex).toBe(0)
88
+ // A 200px viewport cannot be showing ten thousand rows, and the numbers
89
+ // are row indices - if these were the pixel offsets the old deriveds
90
+ // carry, endIndex would be in the hundreds.
91
+ expect(last.endIndex).toBeGreaterThan(0)
92
+ expect(last.endIndex).toBeLessThan(200)
93
+ destroy()
94
+ })
95
+
96
+ it('does not fire again while the range is unchanged', async () => {
97
+ const seen: Array<unknown> = []
98
+ const { api, destroy } = await mountGrid({ onVisibleRangeChange: (r: any) => seen.push(r) })
99
+ await tick()
100
+ const count = seen.length
101
+
102
+ // Something unrelated changes; the visible rows do not.
103
+ api.selectRows(['1'])
104
+ await tick()
105
+ expect(seen).toHaveLength(count)
106
+ destroy()
107
+ })
108
+ })
109
+
110
+ describe('rowPlaceholder', () => {
111
+ it('draws a skeleton cell per column for a loading row', async () => {
112
+ const { target, destroy } = await mountGrid({
113
+ rowPlaceholder: (row: Row) => (row.id === 2 ? 'loading' : null),
114
+ })
115
+ await tick()
116
+
117
+ const placeholder = target.querySelector('.sv-grid-placeholder-row')!
118
+ expect(placeholder).not.toBeNull()
119
+ expect(placeholder.getAttribute('aria-busy')).toBe('true')
120
+ // One shimmer per real column, so the table keeps its shape.
121
+ expect(placeholder.querySelectorAll('.sv-grid-placeholder-skeleton')).toHaveLength(cols.length)
122
+ // And the rows around it are untouched.
123
+ expect(target.querySelectorAll('.sv-grid-placeholder-row')).toHaveLength(1)
124
+ destroy()
125
+ })
126
+
127
+ it('draws one full-width message with a Retry button for a failed row', async () => {
128
+ const retried: Array<{ row: Row; index: number }> = []
129
+ const { target, destroy } = await mountGrid({
130
+ rowPlaceholder: (row: Row) => (row.id === 3 ? 'failed' : null),
131
+ onRetryRow: (row: Row, index: number) => retried.push({ row, index }),
132
+ })
133
+ await tick()
134
+
135
+ const failed = target.querySelector('.sv-grid-placeholder-failed')!
136
+ expect(failed).not.toBeNull()
137
+ expect(failed.textContent).toContain('Could not load')
138
+ expect(failed.querySelectorAll('.sv-grid-placeholder-skeleton')).toHaveLength(0)
139
+
140
+ const retry = failed.querySelector<HTMLButtonElement>('.sv-grid-placeholder-retry')!
141
+ retry.click()
142
+ expect(retried).toHaveLength(1)
143
+ expect(retried[0]!.row.id).toBe(3)
144
+ expect(retried[0]!.index).toBe(3)
145
+ destroy()
146
+ })
147
+
148
+ it('gives a run of failed rows one message, and a band under it', async () => {
149
+ // A failed block is claimed row by row; the message and Retry sit on
150
+ // the first row of the run, the rest are the same tint with nothing
151
+ // to read, so a hundred-row block is not a hundred red lines.
152
+ const { target, destroy } = await mountGrid(
153
+ {
154
+ rowPlaceholder: (row: Row) => (row.id >= 2 && row.id <= 4 ? 'failed' : null),
155
+ onRetryRow: () => {},
156
+ },
157
+ rowsOf(7),
158
+ )
159
+ await tick()
160
+ const failed = [...target.querySelectorAll('.sv-grid-placeholder-failed')]
161
+ expect(failed).toHaveLength(3)
162
+ expect(failed.map((r) => r.classList.contains('sv-grid-placeholder-failed-cont'))).toEqual([false, true, true])
163
+ expect(target.querySelectorAll('.sv-grid-placeholder-retry')).toHaveLength(1)
164
+ expect(failed[0]!.textContent).toContain('Could not load')
165
+ expect(failed[1]!.textContent!.trim()).toBe('')
166
+ // Every row of the run keeps its own slot: the scrollbar does not move.
167
+ expect(target.querySelectorAll('tbody .sv-grid-row').length).toBe(7)
168
+ destroy()
169
+ })
170
+
171
+ it('omits the Retry button when there is no handler to run', async () => {
172
+ const { target, destroy } = await mountGrid({
173
+ rowPlaceholder: (row: Row) => (row.id === 3 ? 'failed' : null),
174
+ })
175
+ await tick()
176
+ expect(target.querySelector('.sv-grid-placeholder-retry')).toBeNull()
177
+ destroy()
178
+ })
179
+
180
+ it('keeps placeholder rows out of select-all', async () => {
181
+ const { api, destroy } = await mountGrid({
182
+ showRowSelection: true,
183
+ rowPlaceholder: (row: Row) => (row.id >= 3 ? 'loading' : null),
184
+ })
185
+ await tick()
186
+
187
+ api.selectAllRows()
188
+ await tick()
189
+ // Selecting a row that has not loaded would leave an id that never
190
+ // resolves to anything.
191
+ expect(api.getSelectedRowIds().sort()).toEqual(['0', '1', '2'])
192
+ destroy()
193
+ })
194
+
195
+ it('changes nothing for a grid that does not use it', async () => {
196
+ const { target, destroy } = await mountGrid({})
197
+ await tick()
198
+ expect(target.querySelector('.sv-grid-placeholder-row')).toBeNull()
199
+ expect(target.querySelectorAll('.sv-grid-row').length).toBeGreaterThan(0)
200
+ destroy()
201
+ })
202
+ })
203
+
204
+ describe('rowSelectionModel', () => {
205
+ /**
206
+ * "Everything except these", the shape a server-side selection needs.
207
+ *
208
+ * Its state is a rune, so the header checkbox re-derives when the model
209
+ * changes. That is a requirement of the seam, not an accident of the test:
210
+ * the grid re-reads `headerState()` only when something reactive that it
211
+ * touched has changed.
212
+ */
213
+ function exceptModel(totalRows: number) {
214
+ const state = $state({ selectAll: false, toggled: new Set<string>() })
215
+ return {
216
+ state,
217
+ isSelected: (rowId: string) => state.selectAll !== state.toggled.has(rowId),
218
+ headerState: () => {
219
+ if (state.selectAll) return state.toggled.size === 0 ? 'all' : 'some'
220
+ return state.toggled.size === 0 ? 'none' : 'some'
221
+ },
222
+ toggle: (rowId: string) => {
223
+ const next = new Set(state.toggled)
224
+ if (next.has(rowId)) next.delete(rowId)
225
+ else next.add(rowId)
226
+ state.toggled = next
227
+ },
228
+ toggleAll: (next: boolean) => {
229
+ state.selectAll = next
230
+ state.toggled = new Set()
231
+ },
232
+ selectedCount: () => (state.selectAll ? totalRows - state.toggled.size : state.toggled.size),
233
+ }
234
+ }
235
+
236
+ it('answers the header checkbox instead of counting loaded rows', async () => {
237
+ const model = exceptModel(1_000_000)
238
+ const { target, destroy } = await mountGrid({ showRowSelection: true, rowSelectionModel: model })
239
+ await tick()
240
+
241
+ const header = target.querySelector('thead [role="checkbox"], thead input[type="checkbox"]')!
242
+ expect(header.getAttribute('aria-checked')).toBe('false')
243
+
244
+ model.toggleAll(true)
245
+ await vi.waitFor(() =>
246
+ expect(
247
+ target.querySelector('thead [role="checkbox"], thead input[type="checkbox"]')!
248
+ .getAttribute('aria-checked'),
249
+ ).toBe('true'),
250
+ )
251
+ // Five rows are loaded; a million are selected. The grid says "all"
252
+ // because the model said so, which is the whole point of the seam.
253
+ expect(model.selectedCount()).toBe(1_000_000)
254
+ destroy()
255
+ })
256
+
257
+ it('routes the header checkbox click to toggleAll, not to the loaded rows', async () => {
258
+ const model = exceptModel(1_000_000)
259
+ const { target, destroy } = await mountGrid({ showRowSelection: true, rowSelectionModel: model })
260
+ await tick()
261
+
262
+ const header = target.querySelector<HTMLElement>('thead [role="checkbox"], thead input[type="checkbox"]')!
263
+ header.click()
264
+ await tick()
265
+
266
+ expect(model.state.selectAll).toBe(true)
267
+ expect(model.selectedCount()).toBe(1_000_000)
268
+ destroy()
269
+ })
270
+
271
+ it('routes a row checkbox through the model', async () => {
272
+ const model = exceptModel(1_000_000)
273
+ const { api, destroy } = await mountGrid({ showRowSelection: true, rowSelectionModel: model })
274
+ await tick()
275
+
276
+ api.toggleRowSelected('2')
277
+ await tick()
278
+ expect(model.state.toggled.has('2')).toBe(true)
279
+ expect(model.isSelected('2')).toBe(true)
280
+
281
+ model.toggleAll(true)
282
+ await tick()
283
+ api.toggleRowSelected('2')
284
+ // Under select-all, toggling a row means "except this one".
285
+ expect(model.isSelected('2')).toBe(false)
286
+ expect(model.selectedCount()).toBe(999_999)
287
+ destroy()
288
+ })
289
+ })
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Every Enterprise gate carries the same licensing line.
3
3
  *
4
- * There are four of them - Kanban board, scheduler, pivot mode and the
5
- * selection bar - and they used to be four hand-written paragraphs. Four gates
6
- * worded four ways is how a product ends up explaining its own licensing
4
+ * There are five of them - Kanban board, scheduler, Gantt, pivot mode and the
5
+ * selection bar - and they used to be four hand-written paragraphs. Gates
6
+ * worded one way each is how a product ends up explaining its own licensing
7
7
  * inconsistently, so they now share one snippet. This is the test that keeps
8
- * them sharing it: a fifth Enterprise feature that hand-rolls its own note
8
+ * them sharing it: a sixth Enterprise feature that hand-rolls its own note
9
9
  * will show up here as a missing licensing line.
10
10
  *
11
11
  * None of the renderers are registered in this file, which is the point - it
@@ -17,6 +17,7 @@ import SvGrid from './SvGrid.svelte'
17
17
  import {
18
18
  createCoreRowModel,
19
19
  hasBoardView,
20
+ hasGanttView,
20
21
  hasSchedulerView,
21
22
  hasSelectionBarView,
22
23
  tableFeatures,
@@ -69,12 +70,14 @@ describe('Enterprise upsell notes', () => {
69
70
  // Otherwise every assertion below is checking the wrong branch.
70
71
  expect(hasBoardView()).toBe(false)
71
72
  expect(hasSchedulerView()).toBe(false)
73
+ expect(hasGanttView()).toBe(false)
72
74
  expect(hasSelectionBarView()).toBe(false)
73
75
  })
74
76
 
75
77
  const gates: Array<[string, Record<string, unknown>, ((api: SvGridApi<typeof features, Row>) => void)?]> = [
76
78
  ['Kanban board', { board: { groupBy: 'team' } }],
77
79
  ['scheduler', { scheduler: { startField: 'name' } }],
80
+ ['Gantt', { gantt: { startField: 'name' } }],
78
81
  ['selection bar', { showRowSelection: true, selectionBar: true }, (api) => api.selectRows(['1'])],
79
82
  // pivotViewOn = a pivot config AND pivot mode on; without the Pro engine
80
83
  // `pivotResult` stays null and the upsell renders in its place.
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { describe, expect, it } from 'vitest'
7
7
  import { validateGridConfig } from './validate'
8
+ import { createRowPlaceholder } from './server-block-cache'
8
9
 
9
10
  type Row = { name: string; amount: number }
10
11
  const data: Row[] = [
@@ -48,6 +49,15 @@ describe('unknown field', () => {
48
49
  expect(run({ columns: [{ id: 'actions', header: '' }] })).toEqual([])
49
50
  })
50
51
 
52
+ it('looks past placeholder rows, which a row model shows before its data lands', () => {
53
+ const loading = [createRowPlaceholder('loading', { index: 0 }), createRowPlaceholder('loading', { index: 1 })]
54
+ // Only placeholders: nothing to judge the columns by, so no warning.
55
+ expect(run({ data: loading })).toEqual([])
56
+ // Placeholders ahead of real rows: the real rows are the sample.
57
+ expect(run({ data: [...loading, ...data] })).toEqual([])
58
+ expect(run({ data: [...loading, ...data], columns: [{ field: 'naem' }] })).toHaveLength(1)
59
+ })
60
+
51
61
  it('looks through group columns', () => {
52
62
  const msgs = run({ columns: [{ header: 'Group', columns: [{ field: 'nope' }] }] })
53
63
  expect(msgs[0]).toContain('"nope" does not exist')
@@ -151,6 +161,25 @@ describe('treeData fields', () => {
151
161
  })
152
162
  })
153
163
 
164
+ describe('gantt versus treeData', () => {
165
+ it('flags both trees being configured at once', () => {
166
+ const msg = run({ gantt: { startField: 'name' }, treeData: { parentField: 'name' } }).find(
167
+ (m) => m.includes('`gantt` and `treeData`'),
168
+ )!
169
+ expect(msg).toBeDefined()
170
+ expect(msg).toContain('gantt.parentField')
171
+ expect(msg).toContain('summary bars will under-report')
172
+ })
173
+
174
+ it('is silent for a Gantt on its own', () => {
175
+ expect(run({ gantt: { startField: 'name' } })).toEqual([])
176
+ })
177
+
178
+ it('is silent for treeData on its own', () => {
179
+ expect(run({ treeData: { parentField: 'name' } })).toEqual([])
180
+ })
181
+ })
182
+
154
183
  describe('pinning versus column virtualization', () => {
155
184
  it('flags pinning while column virtualization is on by default', () => {
156
185
  const msg = run({ initialColumnPinning: { left: ['name'] } })[0]!
package/src/validate.ts CHANGED
@@ -20,6 +20,7 @@
20
20
  * changes, and must not scale with row count.
21
21
  */
22
22
  import type { ColumnDef, RowData, TableFeatures } from './core'
23
+ import { rowPlaceholderState } from './server-block-cache'
23
24
 
24
25
  /** How many rows to sample when deciding whether a `field` exists. */
25
26
  const FIELD_SAMPLE_ROWS = 10
@@ -37,6 +38,10 @@ export type ValidateInput<TFeatures extends TableFeatures, TData extends RowData
37
38
  pageSize?: number
38
39
  groupBy?: ReadonlyArray<string>
39
40
  treeData?: { parentField?: string; idField?: string; column?: string }
41
+ /** Gantt mode. Only its presence matters here - see rule 6b. */
42
+ gantt?: unknown
43
+ /** Server-side grouping: group rows carry their key and aggregates, not the leaf fields. */
44
+ serverGroup?: unknown
40
45
  initialColumnPinning?: { left?: ReadonlyArray<string>; right?: ReadonlyArray<string> }
41
46
  columnVirtualization?: boolean
42
47
  externalPagination?: boolean
@@ -69,9 +74,13 @@ export function validateGridConfig<
69
74
  // ---- 1. A `field` that does not exist on the data -------------------------
70
75
  // The single most expensive silent failure: the column renders, and every
71
76
  // cell in it is blank. Sampled across several rows so genuinely sparse data
72
- // (a key absent from row 0 but present later) does not trip it.
73
- const sample = (input.data ?? []).slice(0, FIELD_SAMPLE_ROWS)
74
- if (sample.length) {
77
+ // (a key absent from row 0 but present later) does not trip it. A row
78
+ // model shows placeholder rows before its first block lands; those carry
79
+ // no data keys at all and say nothing about the columns.
80
+ const sample = (input.data ?? []).filter((row) => !rowPlaceholderState(row)).slice(0, FIELD_SAMPLE_ROWS)
81
+ // Under server-side grouping the first rows are group rows, which carry
82
+ // a key and aggregates and none of the leaf fields; nothing to judge by.
83
+ if (sample.length && !input.serverGroup) {
75
84
  const known = new Set<string>()
76
85
  for (const row of sample) {
77
86
  if (row && typeof row === 'object') for (const k of Object.keys(row)) known.add(k)
@@ -189,6 +198,22 @@ export function validateGridConfig<
189
198
  }
190
199
  }
191
200
 
201
+ // ---- 6b. gantt + treeData: two trees over one set of rows -----------------
202
+ // The Gantt builds its own work-breakdown tree from `gantt.parentField`,
203
+ // because it needs every descendant - a collapsed phase still contributes to
204
+ // its summary bar. `treeData` hides collapsed children from the view before
205
+ // the renderer sees them, so the two together silently drop tasks out of
206
+ // their phase's rollup the moment anything is collapsed.
207
+ if (input.gantt && input.treeData) {
208
+ messages.push(
209
+ '[svgrid] `gantt` and `treeData` are both set. The Gantt builds its own ' +
210
+ 'work-breakdown tree from `gantt.parentField` and needs every ' +
211
+ 'descendant row, but `treeData` hides collapsed children from the view, ' +
212
+ 'so summary bars will under-report. Remove `treeData` and set ' +
213
+ '`gantt.parentField` instead.',
214
+ )
215
+ }
216
+
192
217
  // ---- 7. Pinning that column virtualization will hide ----------------------
193
218
  // Documented incompatibility: the virtualizer recycles column DOM nodes, so
194
219
  // sticky pinning cannot survive it. `columnVirtualization` defaults to ON,
@@ -1,141 +0,0 @@
1
- <!--
2
- Built-in group cell for the server-side group/tree model. Drop it into the
3
- grouping column and it draws the expander + indentation for group rows (and an
4
- indented leaf value) - no hand-written cell recipe. Pair with `serverGroupRows`
5
- to feed `<SvGrid data>`, and wire `onToggle` to the controller's `toggleGroup`.
6
-
7
- cell: (ctx) => renderComponent(SvGroupCell, {
8
- row: ctx.row.original, onToggle: ctl.toggleGroup, leafField: 'name',
9
- })
10
- -->
11
- <script lang="ts" generics="TData">
12
- import type { ServerDisplayRow } from './server-data-source'
13
- import type { GridIcons } from './grid-icons'
14
-
15
- type GroupGridRow = { __group?: ServerDisplayRow<TData> } & Record<string, unknown>
16
- type Props = {
17
- /** The grid row from `serverGroupRows` (carries the `__group` marker). */
18
- row: GroupGridRow
19
- /**
20
- * Expand / collapse a group, or load more children. Receives the grid row;
21
- * wire to `serverGroupNav(ctl).onToggle` (which drives clicks and keyboard).
22
- */
23
- onToggle: (row: GroupGridRow) => void
24
- /** Field to show for leaf rows in the group column (blank if omitted). */
25
- leafField?: string
26
- /** Pixels of indentation per level. Default 18. */
27
- indent?: number
28
- /**
29
- * Icon overrides, the same map `<SvGrid icons>` takes. Only
30
- * `chevron-right` is drawn here. You mount this component yourself, so it
31
- * cannot inherit the grid's icons - pass the same object to both to keep
32
- * the expander consistent with the rest of the chrome.
33
- */
34
- icons?: GridIcons
35
- }
36
-
37
- let { row, onToggle, leafField, indent = 18, icons }: Props = $props()
38
- const chevron = $derived(icons?.['chevron-right'])
39
- const meta = $derived(row.__group)
40
- </script>
41
-
42
- {#if meta && meta.kind === 'group'}
43
- <button
44
- type="button"
45
- class="sv-group-cell"
46
- style={`padding-inline-start: ${meta.level * indent}px`}
47
- aria-expanded={meta.expanded}
48
- aria-label={meta.expanded ? 'Collapse group' : 'Expand group'}
49
- onclick={() => onToggle(row)}
50
- >
51
- <!-- Same chevron the grid's own expanders and SvTree draw, so every
52
- expander in the library looks identical. -->
53
- <span class="sv-group-chev" class:open={meta.expanded} aria-hidden="true">
54
- {#if chevron}
55
- {@render chevron()}
56
- {:else}
57
- <svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor"
58
- stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="m9 18 6-6-6-6" /></svg>
59
- {/if}
60
- </span>
61
- <span class="sv-group-key">{meta.key}</span>
62
- {#if meta.loading}<span class="sv-group-load" aria-hidden="true">…</span>{/if}
63
- </button>
64
- {:else if meta && meta.kind === 'more'}
65
- <button
66
- type="button"
67
- class="sv-group-more"
68
- style={`padding-inline-start: ${meta.level * indent}px`}
69
- disabled={meta.loading}
70
- onclick={() => onToggle(row)}
71
- >
72
- {meta.loading ? 'Loading...' : `Load ${meta.remaining} more`}
73
- </button>
74
- {:else if meta && meta.kind === 'footer'}
75
- <span class="sv-group-footer" style={`padding-inline-start: ${meta.level * indent}px`}>Total</span>
76
- {:else if meta && meta.kind === 'skeleton'}
77
- <span class="sv-group-skeleton" style={`margin-inline-start: ${meta.level * indent}px`} aria-hidden="true"></span>
78
- {:else if meta}
79
- <span class="sv-group-leaf" style={`padding-inline-start: ${(meta.level + 1) * indent}px`}>
80
- {leafField ? (row[leafField] ?? '') : ''}
81
- </span>
82
- {/if}
83
-
84
- <style>
85
- .sv-group-cell {
86
- display: inline-flex;
87
- align-items: center;
88
- gap: 6px;
89
- background: none;
90
- border: 0;
91
- padding: 0;
92
- font: inherit;
93
- color: inherit;
94
- cursor: pointer;
95
- }
96
- .sv-group-chev {
97
- display: inline-flex;
98
- align-items: center;
99
- justify-content: center;
100
- width: 12px;
101
- height: 12px;
102
- transition: transform 0.15s;
103
- color: var(--sg-muted, #64748b);
104
- }
105
- /* An `icons` override renders inside this wrapper, and this style block is
106
- scoped, so its markup needs :global() to be reached. Sizing it here means
107
- a custom chevron lands in the same box as the built-in and rotates with
108
- the wrapper rather than needing to know the rule exists. */
109
- .sv-group-chev :global(svg),
110
- .sv-group-chev :global(img) {
111
- width: 100%;
112
- height: 100%;
113
- display: block;
114
- }
115
- .sv-group-chev.open { transform: rotate(90deg); }
116
- .sv-group-key { font-weight: 600; }
117
- .sv-group-load { color: var(--sg-muted, #64748b); font-size: 12px; }
118
- .sv-group-leaf { color: var(--sg-muted, #475569); }
119
- .sv-group-more {
120
- background: none;
121
- border: 0;
122
- padding: 0;
123
- font: inherit;
124
- font-size: 13px;
125
- color: var(--sg-accent, #2563eb);
126
- cursor: pointer;
127
- }
128
- .sv-group-more:disabled { color: var(--sg-muted, #64748b); cursor: default; }
129
- .sv-group-footer { font-weight: 600; color: var(--sg-muted, #64748b); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
130
- .sv-group-skeleton {
131
- display: inline-block;
132
- width: 60%;
133
- height: 10px;
134
- border-radius: 5px;
135
- background: linear-gradient(90deg, var(--sg-border, #e2e8f0) 25%, var(--sg-header-bg, #f1f5f9) 50%, var(--sg-border, #e2e8f0) 75%);
136
- background-size: 200% 100%;
137
- animation: sv-group-shimmer 1.2s infinite;
138
- }
139
- @keyframes sv-group-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
140
- @media (prefers-reduced-motion: reduce) { .sv-group-skeleton { animation: none; } }
141
- </style>
@@ -1,49 +0,0 @@
1
- import type { ServerDisplayRow } from './server-data-source.js';
2
- import type { GridIcons } from './grid-icons.js';
3
- declare function $$render<TData>(): {
4
- props: {
5
- /** The grid row from `serverGroupRows` (carries the `__group` marker). */
6
- row: {
7
- __group?: ServerDisplayRow<TData>;
8
- } & Record<string, unknown>;
9
- /**
10
- * Expand / collapse a group, or load more children. Receives the grid row;
11
- * wire to `serverGroupNav(ctl).onToggle` (which drives clicks and keyboard).
12
- */
13
- onToggle: (row: {
14
- __group?: ServerDisplayRow<TData>;
15
- } & Record<string, unknown>) => void;
16
- /** Field to show for leaf rows in the group column (blank if omitted). */
17
- leafField?: string;
18
- /** Pixels of indentation per level. Default 18. */
19
- indent?: number;
20
- /**
21
- * Icon overrides, the same map `<SvGrid icons>` takes. Only
22
- * `chevron-right` is drawn here. You mount this component yourself, so it
23
- * cannot inherit the grid's icons - pass the same object to both to keep
24
- * the expander consistent with the rest of the chrome.
25
- */
26
- icons?: GridIcons;
27
- };
28
- exports: {};
29
- bindings: "";
30
- slots: {};
31
- events: {};
32
- };
33
- declare class __sveltets_Render<TData> {
34
- props(): ReturnType<typeof $$render<TData>>['props'];
35
- events(): ReturnType<typeof $$render<TData>>['events'];
36
- slots(): ReturnType<typeof $$render<TData>>['slots'];
37
- bindings(): "";
38
- exports(): {};
39
- }
40
- interface $$IsomorphicComponent {
41
- new <TData>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TData>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TData>['props']>, ReturnType<__sveltets_Render<TData>['events']>, ReturnType<__sveltets_Render<TData>['slots']>> & {
42
- $$bindings?: ReturnType<__sveltets_Render<TData>['bindings']>;
43
- } & ReturnType<__sveltets_Render<TData>['exports']>;
44
- <TData>(internal: unknown, props: ReturnType<__sveltets_Render<TData>['props']> & {}): ReturnType<__sveltets_Render<TData>['exports']>;
45
- z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
46
- }
47
- declare const SvGroupCell: $$IsomorphicComponent;
48
- type SvGroupCell<TData> = InstanceType<typeof SvGroupCell<TData>>;
49
- export default SvGroupCell;