@innertia-solutions/nuxt-theme-spark 0.1.62 → 0.1.64

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.
@@ -1,9 +1,9 @@
1
1
  <script setup>
2
2
  import { useVueTable, getCoreRowModel } from '@tanstack/vue-table'
3
3
  import {
4
- IconArrowsSort,
5
- IconSortAscendingSmallBig,
6
- IconSortDescendingSmallBig,
4
+ IconSelector,
5
+ IconChevronUp,
6
+ IconChevronDown,
7
7
  IconReload,
8
8
  IconBolt,
9
9
  } from '@tabler/icons-vue'
@@ -304,6 +304,35 @@ let draggedHeaderId = null
304
304
  const dragOverHeaderId = ref(null)
305
305
  const resizeHoverId = ref(null)
306
306
 
307
+ // ─── Column auto-size on double click ─────────────────────────────────────────
308
+ const _canvas = typeof document !== 'undefined' ? document.createElement('canvas') : null
309
+ const _ctx = _canvas?.getContext('2d')
310
+
311
+ const measureText = (text, font) => {
312
+ if (!_ctx) return 0
313
+ _ctx.font = font
314
+ return _ctx.measureText(String(text ?? '')).width
315
+ }
316
+
317
+ const autoSizeColumn = (header) => {
318
+ const colId = header.column.id
319
+ const pad = 32 // px-4 on each side
320
+
321
+ // Measure header label
322
+ const label = header.column.columnDef.meta?.label ?? header.id
323
+ let max = measureText(label, '500 12px ui-sans-serif,system-ui,sans-serif') + pad + 20 // +20 for sort icon
324
+
325
+ // Measure all visible data cells
326
+ if (tableBodyRef.value) {
327
+ tableBodyRef.value.querySelectorAll(`td[data-col-id="${colId}"]`).forEach(td => {
328
+ const w = measureText(td.textContent?.trim(), '14px ui-sans-serif,system-ui,sans-serif') + pad
329
+ if (w > max) max = w
330
+ })
331
+ }
332
+
333
+ header.column.setSize(Math.ceil(max))
334
+ }
335
+
307
336
  const onHeaderDragStart = (colId) => { draggedHeaderId = colId }
308
337
  const onHeaderDragOver = (e, colId) => { e.preventDefault(); dragOverHeaderId.value = colId }
309
338
  const onHeaderDragLeave = () => { dragOverHeaderId.value = null }
@@ -491,9 +520,9 @@ defineExpose({
491
520
  <div class="px-4 py-3 flex items-center gap-x-1 text-xs font-medium text-slate-500 dark:text-slate-400 w-full">
492
521
  {{ header.column.columnDef.meta?.label ?? header.id }}
493
522
  <span v-if="header.column.getCanSort()">
494
- <IconArrowsSort v-if="!header.column.getIsSorted()" class="size-4 opacity-40" />
495
- <IconSortDescendingSmallBig v-else-if="header.column.getIsSorted() === 'desc'" class="size-5" />
496
- <IconSortAscendingSmallBig v-else class="size-5" />
523
+ <IconSelector v-if="!header.column.getIsSorted()" class="size-4 opacity-40" />
524
+ <IconChevronDown v-else-if="header.column.getIsSorted() === 'desc'" class="size-4" />
525
+ <IconChevronUp v-else class="size-4" />
497
526
  </span>
498
527
  </div>
499
528
  <!-- Resize handle -->
@@ -504,6 +533,7 @@ defineExpose({
504
533
  @mouseleave="resizeHoverId = null"
505
534
  @mousedown.stop="header.getResizeHandler()?.($event)"
506
535
  @touchstart.passive.stop="header.getResizeHandler()?.($event)"
536
+ @dblclick.stop="autoSizeColumn(header)"
507
537
  @dragstart.stop.prevent
508
538
  @click.stop
509
539
  >
@@ -605,6 +635,7 @@ defineExpose({
605
635
  <td
606
636
  v-for="cell in row.getVisibleCells()"
607
637
  :key="cell.id"
638
+ :data-col-id="cell.column.id"
608
639
  :class="[
609
640
  cell.column.id === 'select'
610
641
  ? 'text-center w-12'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innertia-solutions/nuxt-theme-spark",
3
- "version": "0.1.62",
3
+ "version": "0.1.64",
4
4
  "description": "Innertia Solutions — Spark theme: backoffice, landing and mobile components and layouts",
5
5
  "keywords": [
6
6
  "nuxt",