compote-ui 0.43.7 → 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);
@@ -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);
@@ -140,98 +144,102 @@
140
144
  {hasGrowColumn}
141
145
  />
142
146
  <tbody>
143
- {#each rowModel.rows as row (row.id)}
144
- {@const rowSelected = getReactiveTableState(table).rowSelection[row.id] === true}
145
- <tr
146
- class={cn(
147
- 'group/row',
148
- '[--row-bg:var(--compote-surface-1)]',
149
- 'hover:bg-well/60 hover:[--row-bg:color-mix(in_srgb,var(--compote-well)_60%,var(--compote-surface-1))]',
150
- rowSelected &&
151
- 'bg-well/60 [--row-bg:color-mix(in_srgb,var(--compote-well)_60%,var(--compote-surface-1))]'
152
- )}
153
- onclick={(event) => onRowClick?.({ row: row.original, event })}
154
- ondblclick={(event) => onRowDoubleClick?.({ row: row.original, event })}
155
- >
156
- {#if isRowSelectionEnabled}
157
- <td
158
- class="border-b border-surface-2 bg-(--row-bg) px-3 py-2 text-center align-middle group-last/row:border-b-0"
159
- style="position: sticky; left: 0; z-index: 1"
160
- >
161
- <input
162
- type="checkbox"
163
- aria-label="Select row"
164
- class="table-checkbox mx-auto block size-4"
165
- checked={rowSelected}
166
- disabled={!row.getCanSelect()}
167
- onchange={(e) => row.toggleSelected(e.currentTarget.checked)}
168
- />
169
- </td>
170
- {/if}
171
- {#each getReactiveCells(row, getReactiveTableState(table).columnVisibility) as cell (cell.id)}
172
- {@const columnDef = getColumnMeta(cell.column.columnDef)}
173
- <td
174
- class={cn(
175
- 'truncate border-b border-b-surface-2 px-3 py-2 group-last/row:border-b-0',
176
- alignClass(columnDef?.align),
177
- cell.column.getIsPinned() && 'bg-(--row-bg)'
178
- )}
179
- style={getPinningStyle(cell.column, table, false, isRowSelectionEnabled)}
180
- >
181
- {#if columnDef?.type === 'boolean'}
182
- {@const value = getBooleanCellValue(cell.getValue())}
183
- {#if value === true}
184
- <span
185
- class="inline-flex size-5 items-center justify-center text-success"
186
- role="img"
187
- aria-label="Yes"
188
- >
189
- <PhCheck class="size-4" />
190
- </span>
191
- {:else if value === false}
192
- <span
193
- class="inline-flex size-5 items-center justify-center text-danger"
194
- role="img"
195
- aria-label="No"
196
- >
197
- <PhX class="size-4" />
198
- </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}
199
223
  {:else}
200
- -
224
+ <FlexRender content={cell.column.columnDef.cell} context={cell.getContext()} />
201
225
  {/if}
202
- {:else if columnDef?.type === 'url'}
203
- {@const value = getUrlCellValue(cell.getValue())}
204
- {#if value}
205
- <button
206
- type="button"
207
- class={cn(
208
- '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',
209
- justifyClass(columnDef.align)
210
- )}
211
- onclick={() => openUrlCell(value)}
212
- >
213
- <PhArrowSquareOut class="size-3.5 shrink-0" />
214
- </button>
215
- {:else}
216
- -
217
- {/if}
218
- {:else}
219
- <FlexRender content={cell.column.columnDef.cell} context={cell.getContext()} />
220
- {/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}
221
239
  </td>
222
- {/each}
223
- {#if !hasGrowColumn}
224
- <td aria-hidden="true" class="border-b border-surface-2 p-0 group-last/row:border-b-0"
225
- ></td>
226
- {/if}
227
- </tr>
228
- {:else}
229
- <tr>
230
- <td class="px-3 py-10 text-center text-sm text-ink-dim" colspan={renderedColumnCount}>
231
- {emptyMessage}
232
- </td>
233
- </tr>
234
- {/each}
240
+ </tr>
241
+ {/each}
242
+ {/key}
235
243
  </tbody>
236
244
  </table>
237
245
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "compote-ui",
3
- "version": "0.43.7",
3
+ "version": "0.43.8",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev --open",