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
|
-
|
|
44
|
-
|
|
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
|
-
|
|
53
|
-
|
|
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
|
-
{#
|
|
144
|
-
{
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
{
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
{
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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>
|