@stonecrop/atable 0.2.53 → 0.2.55

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": "@stonecrop/atable",
3
- "version": "0.2.53",
3
+ "version": "0.2.55",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": {
@@ -37,8 +37,8 @@
37
37
  "@vueuse/components": "^10.11.0",
38
38
  "@vueuse/core": "^11.1.0",
39
39
  "vue": "^3.5.6",
40
- "@stonecrop/themes": "0.2.53",
41
- "@stonecrop/utilities": "0.2.53"
40
+ "@stonecrop/themes": "0.2.55",
41
+ "@stonecrop/utilities": "0.2.55"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@microsoft/api-documenter": "^7.25.3",
@@ -75,7 +75,7 @@ const cellStyle = computed((): CSSProperties => {
75
75
  return {
76
76
  textAlign,
77
77
  width: cellWidth,
78
- backgroundColor: !cellModified.value ? 'inherit' : 'var(--cell-modified-color)',
78
+ backgroundColor: !cellModified.value ? 'inherit' : 'var(--sc-cell-modified)',
79
79
  fontWeight: !cellModified.value ? 'inherit' : 'bold',
80
80
  paddingLeft: getIndent(colIndex, tableData.display[rowIndex]?.indent),
81
81
  }
@@ -83,23 +83,27 @@ const cellStyle = computed((): CSSProperties => {
83
83
 
84
84
  const displayValue = computed(() => {
85
85
  const cellData = tableData.cellData<any>(colIndex, rowIndex)
86
+ return getFormattedValue(cellData)
87
+ })
88
+
89
+ const getFormattedValue = (value: any) => {
86
90
  const format = column.format
87
91
 
88
92
  if (!format) {
89
- return cellData
93
+ return value
90
94
  }
91
95
 
92
96
  if (typeof format === 'function') {
93
- return format(cellData, { table, row, column })
97
+ return format(value, { table, row, column })
94
98
  } else if (typeof format === 'string') {
95
99
  // parse format function from string
96
100
  // eslint-disable-next-line @typescript-eslint/no-implied-eval
97
101
  const formatFn: (value: any, context?: CellContext) => string = Function(`"use strict";return (${format})`)()
98
- return formatFn(cellData, { table, row, column })
102
+ return formatFn(value, { table, row, column })
99
103
  }
100
104
 
101
- return cellData
102
- })
105
+ return value
106
+ }
103
107
 
104
108
  const showModal = () => {
105
109
  if (column.mask) {
@@ -172,7 +176,11 @@ const onFocus = () => {
172
176
  const updateCellData = () => {
173
177
  if (cellRef.value) {
174
178
  // only apply changes if the cell value has changed after being mounted
175
- cellModified.value = cellRef.value.textContent !== originalData
179
+ if (column.format) {
180
+ cellModified.value = cellRef.value.textContent !== getFormattedValue(originalData)
181
+ } else {
182
+ cellModified.value = cellRef.value.textContent !== originalData
183
+ }
176
184
 
177
185
  if (cellRef.value.textContent !== currentData.value) {
178
186
  currentData.value = cellRef.value.textContent