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
|
-
|
|
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);
|
|
@@ -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
|
-
|
|
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);
|
|
@@ -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
|
-
{#
|
|
124
|
-
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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>
|