@stonecrop/atable 0.4.8 → 0.4.10

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.4.8",
3
+ "version": "0.4.10",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": {
@@ -38,8 +38,8 @@
38
38
  "@vueuse/core": "^12.7.0",
39
39
  "pinia": "^3.0.1",
40
40
  "vue": "^3.5.13",
41
- "@stonecrop/themes": "0.4.8",
42
- "@stonecrop/utilities": "0.4.8"
41
+ "@stonecrop/themes": "0.4.10",
42
+ "@stonecrop/utilities": "0.4.10"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@microsoft/api-documenter": "^7.26.10",
@@ -48,8 +48,6 @@ const {
48
48
  pinned?: boolean
49
49
  }>()
50
50
 
51
- const emit = defineEmits<{ cellInput: [colIndex: number, rowIndex: number, newValue: string, oldValue: string] }>()
52
-
53
51
  const cellRef = useTemplateRef<HTMLTableCellElement>('cell')
54
52
 
55
53
  // keep a shallow copy of the original cell value for comparison
@@ -165,7 +163,6 @@ const updateCellData = (payload: Event) => {
165
163
  return
166
164
  }
167
165
 
168
- emit('cellInput', colIndex, rowIndex, target.textContent!, currentData.value)
169
166
  currentData.value = target.textContent!
170
167
 
171
168
  // only apply changes if the cell value has changed after being mounted
@@ -25,8 +25,7 @@
25
25
  textAlign: col?.align || 'center',
26
26
  minWidth: col?.width || '40ch',
27
27
  width: store.config.fullWidth ? 'auto' : null,
28
- }"
29
- @cellInput="emitInput" />
28
+ }" />
30
29
  </ARow>
31
30
  </slot>
32
31
  </tbody>
@@ -76,7 +75,7 @@ const {
76
75
 
77
76
  const emit = defineEmits<{
78
77
  'update:modelValue': [value: TableRow[]]
79
- cellUpdate: [colIndex: number, rowIndex: number, newCellValue: any, prevCellValue: any]
78
+ cellUpdate: [{ colIndex: number; rowIndex: number; newValue: any; oldValue: any }]
80
79
  }>()
81
80
 
82
81
  const tableRef = useTemplateRef<HTMLTableElement>('table')
@@ -84,12 +83,12 @@ const rowsValue = modelValue ? modelValue : rows
84
83
  const store = createTableStore({ columns, rows: rowsValue, id, config })
85
84
 
86
85
  store.$onAction(({ name, store, args, after }) => {
87
- if (name === 'setCellData') {
88
- const [colIndex, rowIndex, newCellValue] = args
89
- const prevCellValue = store.getCellData(colIndex, rowIndex)
86
+ if (name === 'setCellData' || name === 'setCellText') {
87
+ const [colIndex, rowIndex, newValue] = args
88
+ const oldValue = store.getCellData(colIndex, rowIndex)
90
89
 
91
90
  after(() => {
92
- emit('cellUpdate', colIndex, rowIndex, newCellValue, prevCellValue)
91
+ emit('cellUpdate', { colIndex, rowIndex, newValue, oldValue })
93
92
  })
94
93
  }
95
94
  })
@@ -113,10 +112,6 @@ onMounted(() => {
113
112
  }
114
113
  })
115
114
 
116
- const emitInput = (colIndex: number, rowIndex: number, newCellValue: any, prevCellValue: any) => {
117
- emit('cellUpdate', colIndex, rowIndex, newCellValue, prevCellValue)
118
- }
119
-
120
115
  const assignStickyCellWidths = () => {
121
116
  const table = tableRef.value
122
117