compote-ui 0.43.6 → 0.43.8

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.
@@ -40,8 +40,12 @@
40
40
  });
41
41
  const headerGroups = $derived.by(() => {
42
42
  const { columnVisibility } = getReactiveTableState(table);
43
- void columnVisibility;
44
- return table.getHeaderGroups();
43
+ return table.getHeaderGroups().map((group) => ({
44
+ ...group,
45
+ headers: group.headers.filter(
46
+ (header) => header.colSpan > 0 && columnVisibility[header.column.id] !== false
47
+ )
48
+ }));
45
49
  });
46
50
  const isRowSelectionEnabled = $derived(Boolean(table.options.enableRowSelection));
47
51
  const isMultiRowSelectionEnabled = $derived(table.options.enableMultiRowSelection !== false);
@@ -55,6 +59,26 @@
55
59
  return getSelectedRowCount(table);
56
60
  });
57
61
  const isColumnResizing = $derived(tableState.columnSizingInfo.isResizingColumn !== false);
62
+
63
+ $effect(() => {
64
+ console.log('VIRTUAL DATA TABLE DEBUG', {
65
+ columnVisibility: { ...tableState.columnVisibility },
66
+ visibleLeafColumns: table.getVisibleLeafColumns().map((column) => column.id),
67
+ allLeafColumns: table.getAllLeafColumns().map((column) => ({
68
+ id: column.id,
69
+ isVisible: column.getIsVisible()
70
+ })),
71
+ headerGroups: table.getHeaderGroups().map((group) => ({
72
+ id: group.id,
73
+ headers: group.headers.map((header) => ({
74
+ id: header.id,
75
+ columnId: header.column.id,
76
+ colSpan: header.colSpan,
77
+ isPlaceholder: header.isPlaceholder
78
+ }))
79
+ }))
80
+ });
81
+ });
58
82
  </script>
59
83
 
60
84
  <div
@@ -49,8 +49,12 @@
49
49
  });
50
50
  const headerGroups = $derived.by(() => {
51
51
  const { columnVisibility } = getReactiveTableState(table);
52
- void columnVisibility;
53
- return table.getHeaderGroups();
52
+ return table.getHeaderGroups().map((group) => ({
53
+ ...group,
54
+ headers: group.headers.filter(
55
+ (header) => header.colSpan > 0 && columnVisibility[header.column.id] !== false
56
+ )
57
+ }));
54
58
  });
55
59
  const visibleLeafColumns = $derived.by(() => {
56
60
  const { columnVisibility } = getReactiveTableState(table);
@@ -74,6 +78,26 @@
74
78
  return getSelectedRowCount(table);
75
79
  });
76
80
  const isColumnResizing = $derived(tableState.columnSizingInfo.isResizingColumn !== false);
81
+
82
+ $effect(() => {
83
+ console.log('DATA TABLE DEBUG', {
84
+ columnVisibility: { ...tableState.columnVisibility },
85
+ visibleLeafColumns: table.getVisibleLeafColumns().map((column) => column.id),
86
+ allLeafColumns: table.getAllLeafColumns().map((column) => ({
87
+ id: column.id,
88
+ isVisible: column.getIsVisible()
89
+ })),
90
+ headerGroups: table.getHeaderGroups().map((group) => ({
91
+ id: group.id,
92
+ headers: group.headers.map((header) => ({
93
+ id: header.id,
94
+ columnId: header.column.id,
95
+ colSpan: header.colSpan,
96
+ isPlaceholder: header.isPlaceholder
97
+ }))
98
+ }))
99
+ });
100
+ });
77
101
  </script>
78
102
 
79
103
  <div
@@ -120,98 +144,102 @@
120
144
  {hasGrowColumn}
121
145
  />
122
146
  <tbody>
123
- {#each rowModel.rows as row (row.id)}
124
- {@const rowSelected = getReactiveTableState(table).rowSelection[row.id] === true}
125
- <tr
126
- class={cn(
127
- 'group/row',
128
- '[--row-bg:var(--compote-surface-1)]',
129
- 'hover:bg-well/60 hover:[--row-bg:color-mix(in_srgb,var(--compote-well)_60%,var(--compote-surface-1))]',
130
- rowSelected &&
131
- 'bg-well/60 [--row-bg:color-mix(in_srgb,var(--compote-well)_60%,var(--compote-surface-1))]'
132
- )}
133
- onclick={(event) => onRowClick?.({ row: row.original, event })}
134
- ondblclick={(event) => onRowDoubleClick?.({ row: row.original, event })}
135
- >
136
- {#if isRowSelectionEnabled}
137
- <td
138
- class="border-b border-surface-2 bg-(--row-bg) px-3 py-2 text-center align-middle group-last/row:border-b-0"
139
- style="position: sticky; left: 0; z-index: 1"
140
- >
141
- <input
142
- type="checkbox"
143
- aria-label="Select row"
144
- class="table-checkbox mx-auto block size-4"
145
- checked={rowSelected}
146
- disabled={!row.getCanSelect()}
147
- onchange={(e) => row.toggleSelected(e.currentTarget.checked)}
148
- />
149
- </td>
150
- {/if}
151
- {#each getReactiveCells(row, getReactiveTableState(table).columnVisibility) as cell (cell.id)}
152
- {@const columnDef = getColumnMeta(cell.column.columnDef)}
153
- <td
154
- class={cn(
155
- 'truncate border-b border-b-surface-2 px-3 py-2 group-last/row:border-b-0',
156
- alignClass(columnDef?.align),
157
- cell.column.getIsPinned() && 'bg-(--row-bg)'
158
- )}
159
- style={getPinningStyle(cell.column, table, false, isRowSelectionEnabled)}
160
- >
161
- {#if columnDef?.type === 'boolean'}
162
- {@const value = getBooleanCellValue(cell.getValue())}
163
- {#if value === true}
164
- <span
165
- class="inline-flex size-5 items-center justify-center text-success"
166
- role="img"
167
- aria-label="Yes"
168
- >
169
- <PhCheck class="size-4" />
170
- </span>
171
- {:else if value === false}
172
- <span
173
- class="inline-flex size-5 items-center justify-center text-danger"
174
- role="img"
175
- aria-label="No"
176
- >
177
- <PhX class="size-4" />
178
- </span>
147
+ {#key visibleLeafColumns.map((column) => column.id).join('|')}
148
+ {#each rowModel.rows as row (row.id)}
149
+ {@const rowSelected = getReactiveTableState(table).rowSelection[row.id] === true}
150
+ <tr
151
+ class={cn(
152
+ 'group/row',
153
+ '[--row-bg:var(--compote-surface-1)]',
154
+ 'hover:bg-well/60 hover:[--row-bg:color-mix(in_srgb,var(--compote-well)_60%,var(--compote-surface-1))]',
155
+ rowSelected &&
156
+ 'bg-well/60 [--row-bg:color-mix(in_srgb,var(--compote-well)_60%,var(--compote-surface-1))]'
157
+ )}
158
+ onclick={(event) => onRowClick?.({ row: row.original, event })}
159
+ ondblclick={(event) => onRowDoubleClick?.({ row: row.original, event })}
160
+ >
161
+ {#if isRowSelectionEnabled}
162
+ <td
163
+ class="border-b border-surface-2 bg-(--row-bg) px-3 py-2 text-center align-middle group-last/row:border-b-0"
164
+ style="position: sticky; left: 0; z-index: 1"
165
+ >
166
+ <input
167
+ type="checkbox"
168
+ aria-label="Select row"
169
+ class="table-checkbox mx-auto block size-4"
170
+ checked={rowSelected}
171
+ disabled={!row.getCanSelect()}
172
+ onchange={(e) => row.toggleSelected(e.currentTarget.checked)}
173
+ />
174
+ </td>
175
+ {/if}
176
+ {#each getReactiveCells(row, getReactiveTableState(table).columnVisibility) as cell (cell.id)}
177
+ {@const columnDef = getColumnMeta(cell.column.columnDef)}
178
+ <td
179
+ class={cn(
180
+ 'truncate border-b border-b-surface-2 px-3 py-2 group-last/row:border-b-0',
181
+ alignClass(columnDef?.align),
182
+ cell.column.getIsPinned() && 'bg-(--row-bg)'
183
+ )}
184
+ style={getPinningStyle(cell.column, table, false, isRowSelectionEnabled)}
185
+ >
186
+ {#if columnDef?.type === 'boolean'}
187
+ {@const value = getBooleanCellValue(cell.getValue())}
188
+ {#if value === true}
189
+ <span
190
+ class="inline-flex size-5 items-center justify-center text-success"
191
+ role="img"
192
+ aria-label="Yes"
193
+ >
194
+ <PhCheck class="size-4" />
195
+ </span>
196
+ {:else if value === false}
197
+ <span
198
+ class="inline-flex size-5 items-center justify-center text-danger"
199
+ role="img"
200
+ aria-label="No"
201
+ >
202
+ <PhX class="size-4" />
203
+ </span>
204
+ {:else}
205
+ -
206
+ {/if}
207
+ {:else if columnDef?.type === 'url'}
208
+ {@const value = getUrlCellValue(cell.getValue())}
209
+ {#if value}
210
+ <button
211
+ type="button"
212
+ class={cn(
213
+ 'inline-flex max-w-full appearance-none items-center gap-1.5 rounded-sm border-0 bg-transparent p-0 align-middle leading-5 font-medium text-ink underline decoration-border decoration-dotted underline-offset-4 outline-none hover:text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring',
214
+ justifyClass(columnDef.align)
215
+ )}
216
+ onclick={() => openUrlCell(value)}
217
+ >
218
+ <PhArrowSquareOut class="size-3.5 shrink-0" />
219
+ </button>
220
+ {:else}
221
+ -
222
+ {/if}
179
223
  {:else}
180
- -
224
+ <FlexRender content={cell.column.columnDef.cell} context={cell.getContext()} />
181
225
  {/if}
182
- {:else if columnDef?.type === 'url'}
183
- {@const value = getUrlCellValue(cell.getValue())}
184
- {#if value}
185
- <button
186
- type="button"
187
- class={cn(
188
- 'inline-flex max-w-full appearance-none items-center gap-1.5 rounded-sm border-0 bg-transparent p-0 align-middle leading-5 font-medium text-ink underline decoration-border decoration-dotted underline-offset-4 outline-none hover:text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring',
189
- justifyClass(columnDef.align)
190
- )}
191
- onclick={() => openUrlCell(value)}
192
- >
193
- <PhArrowSquareOut class="size-3.5 shrink-0" />
194
- </button>
195
- {:else}
196
- -
197
- {/if}
198
- {:else}
199
- <FlexRender content={cell.column.columnDef.cell} context={cell.getContext()} />
200
- {/if}
226
+ </td>
227
+ {/each}
228
+ {#if !hasGrowColumn}
229
+ <td
230
+ aria-hidden="true"
231
+ class="border-b border-surface-2 p-0 group-last/row:border-b-0"
232
+ ></td>
233
+ {/if}
234
+ </tr>
235
+ {:else}
236
+ <tr>
237
+ <td class="px-3 py-10 text-center text-sm text-ink-dim" colspan={renderedColumnCount}>
238
+ {emptyMessage}
201
239
  </td>
202
- {/each}
203
- {#if !hasGrowColumn}
204
- <td aria-hidden="true" class="border-b border-surface-2 p-0 group-last/row:border-b-0"
205
- ></td>
206
- {/if}
207
- </tr>
208
- {:else}
209
- <tr>
210
- <td class="px-3 py-10 text-center text-sm text-ink-dim" colspan={renderedColumnCount}>
211
- {emptyMessage}
212
- </td>
213
- </tr>
214
- {/each}
240
+ </tr>
241
+ {/each}
242
+ {/key}
215
243
  </tbody>
216
244
  </table>
217
245
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "compote-ui",
3
- "version": "0.43.6",
3
+ "version": "0.43.8",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev --open",