@kikiloaw/simple-table 1.0.4 → 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
@@ -459,9 +459,9 @@ SimpleTable supports three data modes:
459
459
  | Prop | Type | Default | Description |
460
460
  |------|------|---------|-------------|
461
461
  | `queryParams` | Object | `{}` | Additional parameters for every request |
462
- | `oddRowColor` | String | `'bg-background'` | Tailwind class for odd rows |
463
- | `evenRowColor` | String | `'bg-background'` | Tailwind class for even rows |
464
- | `hoverColor` | String | `'hover:bg-muted/50'` | Tailwind class for row hover |
462
+ | `oddRowColor` | String | `'bg-white'` | Tailwind class for odd rows |
463
+ | `evenRowColor` | String | `'bg-stone-100'` | Tailwind class for even rows |
464
+ | `hoverColor` | String | `'hover:bg-stone-200'` | Tailwind class for row hover |
465
465
 
466
466
  ---
467
467
 
@@ -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
  ```
@@ -1097,7 +1097,8 @@ const beforeRender = (rows) => {
1097
1097
  #### 3. Action Buttons
1098
1098
 
1099
1099
  ```vue
1100
- <SimpleTable :columns="columns" :data="data">
1100
+ <SimpleTable :columns="
1101
+ " :data="data">
1101
1102
  <template #cell-actions="{ row }">
1102
1103
  <div v-if="!row._isGroupHeader" class="flex gap-2">
1103
1104
  <Button variant="outline" size="sm" @click="edit(row)">Edit</Button>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kikiloaw/simple-table",
3
- "version": "1.0.4",
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",
@@ -62,9 +62,9 @@ const props = withDefaults(defineProps<Props>(), {
62
62
  perPage: 10,
63
63
  pageSizes: () => [10, 20, 30, 50, 100],
64
64
  rowHeight: 38,
65
- oddRowColor: 'bg-background',
66
- evenRowColor: 'bg-background',
67
- hoverColor: 'hover:bg-muted/50'
65
+ oddRowColor: 'bg-white',
66
+ evenRowColor: 'bg-stone-100',
67
+ hoverColor: 'hover:bg-stone-200'
68
68
  })
69
69
 
70
70
  // ...
@@ -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
 
@@ -720,7 +722,7 @@ function getCellStyle(col: any) {
720
722
  <select
721
723
  :value="currentPerPage"
722
724
  @change="(e: any) => handlePageSizeChange(e.target.value)"
723
- class="h-10 w-[80px] appearance-none rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer"
725
+ class="h-10 w-[80px] appearance-none border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer"
724
726
  >
725
727
  <option
726
728
  v-for="pageSize in normalizedPageSizes"
@@ -741,7 +743,7 @@ function getCellStyle(col: any) {
741
743
  v-model="searchQuery"
742
744
  type="text"
743
745
  placeholder="Search..."
744
- class="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 pl-8 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
746
+ class="flex h-10 w-full border border-input bg-background px-3 py-2 pl-8 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
745
747
  />
746
748
  </div>
747
749
  </div>
@@ -751,9 +753,9 @@ function getCellStyle(col: any) {
751
753
  </div>
752
754
 
753
755
  <!-- Table -->
754
- <div class="rounded-md border bg-background overflow-x-auto relative">
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-medium 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 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
  "