@stonecrop/atable 0.3.2 → 0.3.4

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.
@@ -75,6 +75,7 @@ export const createTableStore = (initData: {
75
75
  const table = ref(initData.table || createTableObject())
76
76
  const display = ref(createDisplayObject(initData.display))
77
77
  const modal = ref(initData.modal || { visible: false })
78
+ const updates = ref<Record<string, string>>({})
78
79
 
79
80
  // getters
80
81
  const hasPinnedColumns = computed(() => columns.value.some(col => col.pinned))
@@ -100,6 +101,15 @@ export const createTableStore = (initData: {
100
101
  rows.value[rowIndex][col.name] = value
101
102
  }
102
103
 
104
+ const setCellText = (colIndex: number, rowIndex: number, value: string) => {
105
+ const index = `${colIndex}:${rowIndex}`
106
+
107
+ if (table.value[index] !== value) {
108
+ display.value[rowIndex].rowModified = true
109
+ updates.value[index] = value
110
+ }
111
+ }
112
+
103
113
  const getHeaderCellStyle = (column: TableColumn): CSSProperties => ({
104
114
  minWidth: column.width || '40ch',
105
115
  textAlign: column.align || 'center',
@@ -185,11 +195,12 @@ export const createTableStore = (initData: {
185
195
  return {
186
196
  // state
187
197
  columns,
188
- rows,
189
198
  config,
190
- table,
191
199
  display,
192
200
  modal,
201
+ rows,
202
+ table,
203
+ updates,
193
204
 
194
205
  // getters
195
206
  hasPinnedColumns,
@@ -206,6 +217,7 @@ export const createTableStore = (initData: {
206
217
  getRowExpandSymbol,
207
218
  isRowVisible,
208
219
  setCellData,
220
+ setCellText,
209
221
  toggleRowExpand,
210
222
  }
211
223
  })
@@ -1,3 +1,5 @@
1
+ import { createTableStore } from '../stores/table'
2
+
1
3
  /**
2
4
  * Table column definition.
3
5
  * @public
@@ -93,13 +95,25 @@ export type TableRow = {
93
95
  export type TableModal = {
94
96
  colIndex?: number
95
97
  event?: string
98
+ height?: number
96
99
  left?: number
97
100
  parent?: HTMLElement
98
101
  rowIndex?: number
99
102
  top?: number
100
103
  visible?: boolean
101
- width?: string
104
+ width?: number
102
105
 
103
106
  component?: string
104
107
  componentProps?: Record<string, any>
105
108
  }
109
+
110
+ /**
111
+ * Table modal props definition.
112
+ * @public
113
+ */
114
+ export type TableModalProps = {
115
+ [key: string]: any
116
+ colIndex: number
117
+ rowIndex: number
118
+ store: ReturnType<typeof createTableStore>
119
+ }