@citizenplane/pimp 16.2.1 → 16.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citizenplane/pimp",
3
- "version": "16.2.1",
3
+ "version": "16.2.2",
4
4
  "scripts": {
5
5
  "dev": "storybook dev -p 8081",
6
6
  "build-storybook": "storybook build --output-dir ./docs",
@@ -20,6 +20,7 @@
20
20
  v-for="column in visibleColumns"
21
21
  :key="column.id"
22
22
  class="cpTable__column"
23
+ :class="getColumnClasses(column.id)"
23
24
  :style="getColumnStyle(column)"
24
25
  >
25
26
  <slot :column="column" name="column">
@@ -49,12 +50,11 @@
49
50
  >
50
51
  <slot name="row" :row="rowData">
51
52
  <td
52
- v-for="(cellValue, cellKey, cellIndex) in rowData"
53
+ v-for="(cellValue, cellKey) in rowData"
53
54
  :key="`${cellKey}_${rowIndex}`"
54
55
  class="cpTable__cell"
55
56
  :class="getCellClasses(cellKey)"
56
57
  :colspan="getColspan(cellKey)"
57
- :style="getCellStyle(cellKey, cellIndex)"
58
58
  >
59
59
  <slot :cell="cellValue" :name="cellKey">
60
60
  <span v-if="isFullWidthRow(rowData)">{{ cellValue }}</span>
@@ -136,6 +136,7 @@ import CpTableEmptyState from '@/components/CpTableEmptyState.vue'
136
136
  import { camelize, decamelize } from '@/helpers/string'
137
137
 
138
138
  import { PAGINATION_FORMATS, RESERVED_KEYS, VISIBLE_ROWS_MAX } from '@/constants'
139
+ import { capitalizeFirstLetter } from '@/helpers'
139
140
 
140
141
  interface Emits {
141
142
  (evt: 'onRowClick', data: Record<string, unknown>): void
@@ -544,6 +545,8 @@ const resetScrollPosition = () => {
544
545
  }
545
546
  }
546
547
 
548
+ const getColumnClasses = (columnId: string) => `cpTable__column--is${capitalizeFirstLetter(columnId)}`
549
+
547
550
  const getColumnStyle = (column: CpTableColumnObject) => {
548
551
  let width: string | undefined
549
552
 
@@ -555,17 +558,7 @@ const getColumnStyle = (column: CpTableColumnObject) => {
555
558
  width = `${column.width}px`
556
559
  }
557
560
 
558
- return {
559
- width,
560
- textAlign: column.textAlign,
561
- }
562
- }
563
-
564
- const getCellStyle = (cellKey: RESERVED_KEYS, cellIndex: number) => {
565
- if (isFullWidthCell(cellKey)) return null
566
- return {
567
- textAlign: visibleColumns.value[cellIndex]?.textAlign,
568
- }
561
+ return { width }
569
562
  }
570
563
 
571
564
  const getRowClasses = (rowData: Record<string, unknown>, rowIndex: number) => {
@@ -4,7 +4,6 @@ export interface CpTableColumnObject {
4
4
  isHidden?: boolean
5
5
  isProtected?: boolean
6
6
  name: string
7
- textAlign?: 'left' | 'center' | 'right'
8
7
  width?: number
9
8
  }
10
9