@kikiloaw/simple-table 1.0.5 → 1.0.6

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.
package/README.md CHANGED
@@ -475,7 +475,7 @@ SimpleTable supports three data modes:
475
475
  label: 'Name', // Required: Column header text
476
476
  sortable: true, // Optional: Enable sorting
477
477
  width: '200px', // Optional: Fixed column width
478
- fixed: true, // Optional: Sticky column (useful for actions)
478
+ fixed: true, // Optional: Sticky column (left for first, right for last, others left). **Requires `width` to be set.**
479
479
  class: 'text-center' // Optional: Additional CSS classes
480
480
  }
481
481
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kikiloaw/simple-table",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A lightweight, dependency-light DataTable component for Vue 3 with Tailwind CSS",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -653,15 +653,13 @@ function getCellClass(col: any, index: number, totalCols: number, rowIndex: numb
653
653
 
654
654
  if (col.fixed) {
655
655
  // Sticky logic
656
- const isLast = index === totalCols - 1
657
-
658
- let stickyClass = ''
659
- if (isLast) {
660
- // Right sticky: Stronger shadow to the left, and a left border
661
- stickyClass = ' sticky right-0 z-10 shadow-[-4px_0_8px_-2px_rgba(0,0,0,0.1)] border-l border-border/50'
656
+ let stickyClass = ' whitespace-nowrap' // Prevent content wrapping in sticky columns
657
+ if (index === totalCols - 1) {
658
+ // Last Column -> Right Sticky
659
+ stickyClass = ' sticky right-0 z-10 shadow-[-4px_0_8px_-2px_rgba(0,0,0,0.1)] border-l border-stone-300'
662
660
  } else {
663
- // Left sticky: Stronger shadow to the right, and a right border
664
- stickyClass = ' sticky left-0 z-10 shadow-[4px_0_8px_-2px_rgba(0,0,0,0.1)] border-r border-border/50'
661
+ // All other fixed columns -> Left Sticky
662
+ stickyClass = ' sticky left-0 z-10 shadow-[4px_0_8px_-2px_rgba(0,0,0,0.1)] border-r border-stone-300'
665
663
  }
666
664
 
667
665
  // Determine background
@@ -670,8 +668,8 @@ function getCellClass(col: any, index: number, totalCols: number, rowIndex: numb
670
668
 
671
669
  if (rowIndex !== -1) {
672
670
  // Body Row
673
- const isEven = rowIndex % 2 === 0
674
- bgClass = isEven ? props.evenRowColor : props.oddRowColor
671
+ const isOdd = rowIndex % 2 === 0
672
+ bgClass = isOdd ? props.oddRowColor : props.evenRowColor
675
673
 
676
674
  // Should also match hover
677
675
  // If the row has a hover class (like hover:bg-muted), the sticky cell needs group-hover:bg-muted to match.
@@ -702,6 +700,10 @@ function getCellStyle(col: any) {
702
700
  if (col.width) {
703
701
  return { width: col.width, minWidth: col.width, maxWidth: col.width }
704
702
  }
703
+ // Smart default: If fixed but no width, force a safe width (e.g. 100px) to ensure background covers content
704
+ if (col.fixed) {
705
+ return { width: '100px', minWidth: '100px' }
706
+ }
705
707
  return {}
706
708
  }
707
709
 
@@ -753,7 +755,7 @@ function getCellStyle(col: any) {
753
755
  <!-- Table -->
754
756
  <div class="border bg-background overflow-x-auto relative">
755
757
  <!-- We add min-w-full to Table to ensure it stretches -->
756
- <Table class="min-w-full table-fixed">
758
+ <Table class="min-w-full table-auto">
757
759
  <TableHeader>
758
760
  <TableRow :style="{ height: densityConfig.cellHeight }">
759
761
  <TableHead
@@ -16,7 +16,7 @@ const delegatedProps = computed(() => {
16
16
  <template>
17
17
  <div class="relative w-full overflow-auto">
18
18
  <table
19
- :class="cn('w-full caption-bottom text-sm', props.class)"
19
+ :class="cn('w-full caption-bottom text-sm border-separate border-spacing-0', props.class)"
20
20
  v-bind="delegatedProps"
21
21
  >
22
22
  <slot />
@@ -25,7 +25,7 @@ const cellStyle = computed(() => {
25
25
 
26
26
  <template>
27
27
  <td
28
- :class="cn(props.padding || 'p-2', 'align-middle [&:has([role=checkbox])]:pr-0', props.class)"
28
+ :class="cn(props.padding || 'p-2', 'border-b border-stone-300 align-middle [&:has([role=checkbox])]:pr-0', props.class)"
29
29
  :style="cellStyle"
30
30
  v-bind="delegatedProps"
31
31
  >
@@ -21,7 +21,7 @@ const delegatedProps = computed(() => {
21
21
  cn(
22
22
  props.height || 'h-[38px]',
23
23
  props.padding || 'px-2',
24
- 'text-left align-middle font-bold text-muted-foreground [&:has([role=checkbox])]:pr-0',
24
+ 'border-b border-stone-300 text-left align-middle font-bold text-muted-foreground [&:has([role=checkbox])]:pr-0',
25
25
  props.class,
26
26
  )
27
27
  "
@@ -17,7 +17,7 @@ const delegatedProps = computed(() => {
17
17
  <tr
18
18
  :class="
19
19
  cn(
20
- 'border-b border-stone-300 transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted',
20
+ 'transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted',
21
21
  props.class,
22
22
  )
23
23
  "