@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.
@@ -6,7 +6,7 @@ import ATable from './components/ATable.vue';
6
6
  import ATableHeader from './components/ATableHeader.vue';
7
7
  import ATableModal from './components/ATableModal.vue';
8
8
  export { createTableStore } from './stores/table';
9
- export type { CellContext, TableColumn, TableConfig, TableDisplay, TableRow, TableModal } from './types';
9
+ export type { CellContext, TableColumn, TableConfig, TableDisplay, TableModal, TableModalProps, TableRow, } from './types';
10
10
  /**
11
11
  * Install all ATable components
12
12
  * @param app - Vue app instance
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,OAAO,KAAK,MAAM,wBAAwB,CAAA;AAC1C,OAAO,aAAa,MAAM,gCAAgC,CAAA;AAC1D,OAAO,IAAI,MAAM,uBAAuB,CAAA;AACxC,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,WAAW,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAExG;;;;GAIG;AACH,iBAAS,OAAO,CAAC,GAAG,EAAE,GAAG,QAOxB;AAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,OAAO,KAAK,MAAM,wBAAwB,CAAA;AAC1C,OAAO,aAAa,MAAM,gCAAgC,CAAA;AAC1D,OAAO,IAAI,MAAM,uBAAuB,CAAA;AACxC,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,WAAW,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,YAAY,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EACf,QAAQ,GACR,MAAM,SAAS,CAAA;AAEhB;;;;GAIG;AACH,iBAAS,OAAO,CAAC,GAAG,EAAE,GAAG,QAOxB;AAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,CAAA"}
@@ -46,15 +46,6 @@ export declare const createTableStore: (initData: {
46
46
  format?: string | ((value: any, context: CellContext) => string);
47
47
  mask?: (value: any) => any;
48
48
  }[]>;
49
- rows: import("vue").Ref<{
50
- [x: string]: any;
51
- indent?: number;
52
- parent?: number;
53
- }[], TableRow[] | {
54
- [x: string]: any;
55
- indent?: number;
56
- parent?: number;
57
- }[]>;
58
49
  config: import("vue").Ref<{
59
50
  view?: "uncounted" | "list" | "list-expansion" | "tree";
60
51
  fullWidth?: boolean;
@@ -62,7 +53,6 @@ export declare const createTableStore: (initData: {
62
53
  view?: "uncounted" | "list" | "list-expansion" | "tree";
63
54
  fullWidth?: boolean;
64
55
  }>;
65
- table: import("vue").Ref<{}, {}>;
66
56
  display: import("vue").Ref<{
67
57
  childrenOpen?: boolean;
68
58
  expanded?: boolean;
@@ -85,26 +75,39 @@ export declare const createTableStore: (initData: {
85
75
  modal: import("vue").Ref<{
86
76
  colIndex?: number;
87
77
  event?: string;
78
+ height?: number;
88
79
  left?: number;
89
80
  parent?: HTMLElement;
90
81
  rowIndex?: number;
91
82
  top?: number;
92
83
  visible?: boolean;
93
- width?: string;
84
+ width?: number;
94
85
  component?: string;
95
86
  componentProps?: Record<string, any>;
96
87
  }, TableModal | {
97
88
  colIndex?: number;
98
89
  event?: string;
90
+ height?: number;
99
91
  left?: number;
100
92
  parent?: HTMLElement;
101
93
  rowIndex?: number;
102
94
  top?: number;
103
95
  visible?: boolean;
104
- width?: string;
96
+ width?: number;
105
97
  component?: string;
106
98
  componentProps?: Record<string, any>;
107
99
  }>;
100
+ rows: import("vue").Ref<{
101
+ [x: string]: any;
102
+ indent?: number;
103
+ parent?: number;
104
+ }[], TableRow[] | {
105
+ [x: string]: any;
106
+ indent?: number;
107
+ parent?: number;
108
+ }[]>;
109
+ table: import("vue").Ref<{}, {}>;
110
+ updates: import("vue").Ref<Record<string, string>, Record<string, string>>;
108
111
  hasPinnedColumns: import("vue").ComputedRef<boolean>;
109
112
  numberedRowWidth: import("vue").ComputedRef<string>;
110
113
  zeroColumn: import("vue").ComputedRef<boolean>;
@@ -117,8 +120,9 @@ export declare const createTableStore: (initData: {
117
120
  getRowExpandSymbol: (rowIndex: number) => "" | "-" | "+";
118
121
  isRowVisible: (rowIndex: number) => boolean;
119
122
  setCellData: (colIndex: number, rowIndex: number, value: any) => void;
123
+ setCellText: (colIndex: number, rowIndex: number, value: string) => void;
120
124
  toggleRowExpand: (rowIndex: number) => void;
121
- }, "columns" | "rows" | "config" | "table" | "display" | "modal">, Pick<{
125
+ }, "columns" | "config" | "display" | "modal" | "rows" | "table" | "updates">, Pick<{
122
126
  columns: import("vue").Ref<{
123
127
  name: string;
124
128
  align?: CanvasTextAlign;
@@ -148,15 +152,6 @@ export declare const createTableStore: (initData: {
148
152
  format?: string | ((value: any, context: CellContext) => string);
149
153
  mask?: (value: any) => any;
150
154
  }[]>;
151
- rows: import("vue").Ref<{
152
- [x: string]: any;
153
- indent?: number;
154
- parent?: number;
155
- }[], TableRow[] | {
156
- [x: string]: any;
157
- indent?: number;
158
- parent?: number;
159
- }[]>;
160
155
  config: import("vue").Ref<{
161
156
  view?: "uncounted" | "list" | "list-expansion" | "tree";
162
157
  fullWidth?: boolean;
@@ -164,7 +159,6 @@ export declare const createTableStore: (initData: {
164
159
  view?: "uncounted" | "list" | "list-expansion" | "tree";
165
160
  fullWidth?: boolean;
166
161
  }>;
167
- table: import("vue").Ref<{}, {}>;
168
162
  display: import("vue").Ref<{
169
163
  childrenOpen?: boolean;
170
164
  expanded?: boolean;
@@ -187,26 +181,39 @@ export declare const createTableStore: (initData: {
187
181
  modal: import("vue").Ref<{
188
182
  colIndex?: number;
189
183
  event?: string;
184
+ height?: number;
190
185
  left?: number;
191
186
  parent?: HTMLElement;
192
187
  rowIndex?: number;
193
188
  top?: number;
194
189
  visible?: boolean;
195
- width?: string;
190
+ width?: number;
196
191
  component?: string;
197
192
  componentProps?: Record<string, any>;
198
193
  }, TableModal | {
199
194
  colIndex?: number;
200
195
  event?: string;
196
+ height?: number;
201
197
  left?: number;
202
198
  parent?: HTMLElement;
203
199
  rowIndex?: number;
204
200
  top?: number;
205
201
  visible?: boolean;
206
- width?: string;
202
+ width?: number;
207
203
  component?: string;
208
204
  componentProps?: Record<string, any>;
209
205
  }>;
206
+ rows: import("vue").Ref<{
207
+ [x: string]: any;
208
+ indent?: number;
209
+ parent?: number;
210
+ }[], TableRow[] | {
211
+ [x: string]: any;
212
+ indent?: number;
213
+ parent?: number;
214
+ }[]>;
215
+ table: import("vue").Ref<{}, {}>;
216
+ updates: import("vue").Ref<Record<string, string>, Record<string, string>>;
210
217
  hasPinnedColumns: import("vue").ComputedRef<boolean>;
211
218
  numberedRowWidth: import("vue").ComputedRef<string>;
212
219
  zeroColumn: import("vue").ComputedRef<boolean>;
@@ -219,6 +226,7 @@ export declare const createTableStore: (initData: {
219
226
  getRowExpandSymbol: (rowIndex: number) => "" | "-" | "+";
220
227
  isRowVisible: (rowIndex: number) => boolean;
221
228
  setCellData: (colIndex: number, rowIndex: number, value: any) => void;
229
+ setCellText: (colIndex: number, rowIndex: number, value: string) => void;
222
230
  toggleRowExpand: (rowIndex: number) => void;
223
231
  }, "hasPinnedColumns" | "numberedRowWidth" | "zeroColumn">, Pick<{
224
232
  columns: import("vue").Ref<{
@@ -250,15 +258,6 @@ export declare const createTableStore: (initData: {
250
258
  format?: string | ((value: any, context: CellContext) => string);
251
259
  mask?: (value: any) => any;
252
260
  }[]>;
253
- rows: import("vue").Ref<{
254
- [x: string]: any;
255
- indent?: number;
256
- parent?: number;
257
- }[], TableRow[] | {
258
- [x: string]: any;
259
- indent?: number;
260
- parent?: number;
261
- }[]>;
262
261
  config: import("vue").Ref<{
263
262
  view?: "uncounted" | "list" | "list-expansion" | "tree";
264
263
  fullWidth?: boolean;
@@ -266,7 +265,6 @@ export declare const createTableStore: (initData: {
266
265
  view?: "uncounted" | "list" | "list-expansion" | "tree";
267
266
  fullWidth?: boolean;
268
267
  }>;
269
- table: import("vue").Ref<{}, {}>;
270
268
  display: import("vue").Ref<{
271
269
  childrenOpen?: boolean;
272
270
  expanded?: boolean;
@@ -289,26 +287,39 @@ export declare const createTableStore: (initData: {
289
287
  modal: import("vue").Ref<{
290
288
  colIndex?: number;
291
289
  event?: string;
290
+ height?: number;
292
291
  left?: number;
293
292
  parent?: HTMLElement;
294
293
  rowIndex?: number;
295
294
  top?: number;
296
295
  visible?: boolean;
297
- width?: string;
296
+ width?: number;
298
297
  component?: string;
299
298
  componentProps?: Record<string, any>;
300
299
  }, TableModal | {
301
300
  colIndex?: number;
302
301
  event?: string;
302
+ height?: number;
303
303
  left?: number;
304
304
  parent?: HTMLElement;
305
305
  rowIndex?: number;
306
306
  top?: number;
307
307
  visible?: boolean;
308
- width?: string;
308
+ width?: number;
309
309
  component?: string;
310
310
  componentProps?: Record<string, any>;
311
311
  }>;
312
+ rows: import("vue").Ref<{
313
+ [x: string]: any;
314
+ indent?: number;
315
+ parent?: number;
316
+ }[], TableRow[] | {
317
+ [x: string]: any;
318
+ indent?: number;
319
+ parent?: number;
320
+ }[]>;
321
+ table: import("vue").Ref<{}, {}>;
322
+ updates: import("vue").Ref<Record<string, string>, Record<string, string>>;
312
323
  hasPinnedColumns: import("vue").ComputedRef<boolean>;
313
324
  numberedRowWidth: import("vue").ComputedRef<string>;
314
325
  zeroColumn: import("vue").ComputedRef<boolean>;
@@ -321,6 +332,7 @@ export declare const createTableStore: (initData: {
321
332
  getRowExpandSymbol: (rowIndex: number) => "" | "-" | "+";
322
333
  isRowVisible: (rowIndex: number) => boolean;
323
334
  setCellData: (colIndex: number, rowIndex: number, value: any) => void;
335
+ setCellText: (colIndex: number, rowIndex: number, value: string) => void;
324
336
  toggleRowExpand: (rowIndex: number) => void;
325
- }, "closeModal" | "getCellData" | "getCellDisplayValue" | "getFormattedValue" | "getHeaderCellStyle" | "getIndent" | "getRowExpandSymbol" | "isRowVisible" | "setCellData" | "toggleRowExpand">>;
337
+ }, "closeModal" | "getCellData" | "getCellDisplayValue" | "getFormattedValue" | "getHeaderCellStyle" | "getIndent" | "getRowExpandSymbol" | "isRowVisible" | "setCellData" | "setCellText" | "toggleRowExpand">>;
326
338
  //# sourceMappingURL=table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/stores/table.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,KAAK,CAAA;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEzG;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aAAc;IAC1C,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,IAAI,EAAE,QAAQ,EAAE,CAAA;IAChB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,KAAK,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;IAC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MAAM,KAAG,CAAC;oCA4D7B,MAAM,YAAY,MAAM;kCAK1B,MAAM,YAAY,MAAM,SAAS,GAAG;iCA3CrC,WAAW,KAAG,aAAa;0BA0ElC,MAAM,gBAAgB,MAAM;mCAhEnB,MAAM;6BAJZ,MAAM;4BA3BP,MAAM,YAAY,MAAM,SAAS,GAAG;4BAYpC,MAAM,YAAY,MAAM,SAAS,MAAM;gCA+BnC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0Cd,UAAU;kBAtFhB,CAAC,kBAAkB,MAAM,YAAY,MAAM,KAAG,CAAC;oCA4D7B,MAAM,YAAY,MAAM;kCAK1B,MAAM,YAAY,MAAM,SAAS,GAAG;iCA3CrC,WAAW,KAAG,aAAa;0BA0ElC,MAAM,gBAAgB,MAAM;mCAhEnB,MAAM;6BAJZ,MAAM;4BA3BP,MAAM,YAAY,MAAM,SAAS,GAAG;4BAYpC,MAAM,YAAY,MAAM,SAAS,MAAM;gCA+BnC,MAAM;gNA2F1C,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { createTableStore } from '../stores/table';
1
2
  /**
2
3
  * Table column definition.
3
4
  * @public
@@ -87,13 +88,24 @@ export type TableRow = {
87
88
  export type TableModal = {
88
89
  colIndex?: number;
89
90
  event?: string;
91
+ height?: number;
90
92
  left?: number;
91
93
  parent?: HTMLElement;
92
94
  rowIndex?: number;
93
95
  top?: number;
94
96
  visible?: boolean;
95
- width?: string;
97
+ width?: number;
96
98
  component?: string;
97
99
  componentProps?: Record<string, any>;
98
100
  };
101
+ /**
102
+ * Table modal props definition.
103
+ * @public
104
+ */
105
+ export type TableModalProps = {
106
+ [key: string]: any;
107
+ colIndex: number;
108
+ rowIndex: number;
109
+ store: ReturnType<typeof createTableStore>;
110
+ };
99
111
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file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A;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CACpC,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAA;CAC1C,CAAA"}
@@ -58,6 +58,7 @@ export const createTableStore = (initData) => {
58
58
  const table = ref(initData.table || createTableObject());
59
59
  const display = ref(createDisplayObject(initData.display));
60
60
  const modal = ref(initData.modal || { visible: false });
61
+ const updates = ref({});
61
62
  // getters
62
63
  const hasPinnedColumns = computed(() => columns.value.some(col => col.pinned));
63
64
  const numberedRowWidth = computed(() => {
@@ -76,6 +77,13 @@ export const createTableStore = (initData) => {
76
77
  table.value[index] = value;
77
78
  rows.value[rowIndex][col.name] = value;
78
79
  };
80
+ const setCellText = (colIndex, rowIndex, value) => {
81
+ const index = `${colIndex}:${rowIndex}`;
82
+ if (table.value[index] !== value) {
83
+ display.value[rowIndex].rowModified = true;
84
+ updates.value[index] = value;
85
+ }
86
+ };
79
87
  const getHeaderCellStyle = (column) => ({
80
88
  minWidth: column.width || '40ch',
81
89
  textAlign: column.align || 'center',
@@ -154,11 +162,12 @@ export const createTableStore = (initData) => {
154
162
  return {
155
163
  // state
156
164
  columns,
157
- rows,
158
165
  config,
159
- table,
160
166
  display,
161
167
  modal,
168
+ rows,
169
+ table,
170
+ updates,
162
171
  // getters
163
172
  hasPinnedColumns,
164
173
  numberedRowWidth,
@@ -173,6 +182,7 @@ export const createTableStore = (initData) => {
173
182
  getRowExpandSymbol,
174
183
  isRowVisible,
175
184
  setCellData,
185
+ setCellText,
176
186
  toggleRowExpand,
177
187
  };
178
188
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/atable",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": {
@@ -38,8 +38,8 @@
38
38
  "@vueuse/core": "^12.0.0",
39
39
  "pinia": "^2.3.0",
40
40
  "vue": "^3.5.11",
41
- "@stonecrop/themes": "0.3.2",
42
- "@stonecrop/utilities": "0.3.2"
41
+ "@stonecrop/themes": "0.3.4",
42
+ "@stonecrop/utilities": "0.3.4"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@microsoft/api-documenter": "^7.26.2",
@@ -10,7 +10,6 @@
10
10
  :style="cellStyle"
11
11
  @focus="onFocus"
12
12
  @paste="updateCellData"
13
- @blur="updateCellData"
14
13
  @input="updateCellData"
15
14
  @click="showModal"
16
15
  class="atable-cell"
@@ -28,7 +27,7 @@
28
27
  <script setup lang="ts">
29
28
  import { KeypressHandlers, defaultKeypressHandlers, useKeyboardNav } from '@stonecrop/utilities'
30
29
  import { useElementBounding } from '@vueuse/core'
31
- import { computed, CSSProperties, ref, useTemplateRef, watch } from 'vue'
30
+ import { computed, type CSSProperties, ref, useTemplateRef } from 'vue'
32
31
 
33
32
  import { createTableStore } from '../stores/table'
34
33
  import { isHtmlString } from '../utils'
@@ -48,12 +47,13 @@ const {
48
47
  pinned?: boolean
49
48
  }>()
50
49
 
50
+ const emit = defineEmits<{ cellInput: [colIndex: number, rowIndex: number, newValue: string, oldValue: string] }>()
51
+
51
52
  const cellRef = useTemplateRef<HTMLTableCellElement>('cell')
52
- const { bottom, left } = useElementBounding(cellRef)
53
+ const { width, height } = useElementBounding(cellRef)
53
54
 
54
55
  // keep a shallow copy of the original cell value for comparison
55
56
  const originalData = store.getCellData(colIndex, rowIndex)
56
- const displayValue = ref(store.getCellDisplayValue(colIndex, rowIndex))
57
57
  const currentData = ref('')
58
58
  const cellModified = ref(false)
59
59
 
@@ -63,13 +63,7 @@ const row = store.rows[rowIndex]
63
63
  const textAlign = column.align || 'center'
64
64
  const cellWidth = column.width || '40ch'
65
65
 
66
- watch(
67
- () => store.getCellData(colIndex, rowIndex),
68
- cellData => {
69
- displayValue.value = store.getFormattedValue(colIndex, rowIndex, cellData)
70
- }
71
- )
72
-
66
+ const displayValue = computed(() => store.getCellDisplayValue(colIndex, rowIndex))
73
67
  const isHtmlValue = computed(() => {
74
68
  // TODO: check if display value is a native DOM element
75
69
  return typeof displayValue.value === 'string' ? isHtmlString(displayValue.value) : false
@@ -97,9 +91,10 @@ const showModal = () => {
97
91
  state.modal.colIndex = colIndex
98
92
  state.modal.rowIndex = rowIndex
99
93
  state.modal.parent = cellRef.value
100
- state.modal.top = bottom.value
101
- state.modal.left = left.value
102
- state.modal.width = cellWidth
94
+ state.modal.top = cellRef.value.offsetTop + cellRef.value.offsetHeight
95
+ state.modal.left = cellRef.value.offsetLeft
96
+ state.modal.width = width.value
97
+ state.modal.height = height.value
103
98
 
104
99
  if (typeof column.modalComponent === 'function') {
105
100
  state.modal.component = column.modalComponent({ table: state.table, row, column })
@@ -155,23 +150,23 @@ const onFocus = () => {
155
150
  }
156
151
  }
157
152
 
158
- const updateCellData = () => {
159
- if (cellRef.value) {
160
- // only apply changes if the cell value has changed after being mounted
161
- if (column.format) {
162
- cellModified.value = cellRef.value.textContent !== store.getFormattedValue(colIndex, rowIndex, originalData)
163
- } else {
164
- cellModified.value = cellRef.value.textContent !== originalData
165
- }
153
+ const updateCellData = (payload: Event) => {
154
+ const target = payload.target as HTMLTableCellElement
155
+ if (target.textContent === currentData.value) {
156
+ return
157
+ }
166
158
 
167
- if (cellRef.value.textContent !== currentData.value) {
168
- currentData.value = cellRef.value.textContent
169
- cellRef.value.dispatchEvent(new Event('change'))
170
- if (!column.format) {
171
- // TODO: need to setup reverse format function
172
- store.setCellData(colIndex, rowIndex, currentData.value)
173
- }
174
- }
159
+ emit('cellInput', colIndex, rowIndex, target.textContent, currentData.value)
160
+ currentData.value = target.textContent
161
+
162
+ // only apply changes if the cell value has changed after being mounted
163
+ if (column.format) {
164
+ cellModified.value = target.textContent !== store.getFormattedValue(colIndex, rowIndex, originalData)
165
+ // TODO: need to setup reverse format function?
166
+ store.setCellText(colIndex, rowIndex, target.textContent)
167
+ } else {
168
+ cellModified.value = target.textContent !== originalData
169
+ store.setCellData(colIndex, rowIndex, target.textContent)
175
170
  }
176
171
  }
177
172
  </script>
@@ -25,7 +25,8 @@
25
25
  textAlign: col?.align || 'center',
26
26
  minWidth: col?.width || '40ch',
27
27
  width: store.config.fullWidth ? 'auto' : null,
28
- }" />
28
+ }"
29
+ @cellInput="emitInput" />
29
30
  </ARow>
30
31
  </slot>
31
32
  </tbody>
@@ -37,11 +38,7 @@
37
38
  :colIndex="store.modal.colIndex"
38
39
  :rowIndex="store.modal.rowIndex"
39
40
  :store="store"
40
- :style="{
41
- left: store.modal.left + 'px',
42
- top: store.modal.top + 'px',
43
- maxWidth: store.modal.width + 'px',
44
- }">
41
+ :container="tableRef">
45
42
  <template #default>
46
43
  <component
47
44
  :key="`${store.modal.rowIndex}:${store.modal.colIndex}`"
@@ -91,11 +88,14 @@ const tableRef = useTemplateRef<HTMLTableElement>('table')
91
88
  const rowsValue = modelValue ? modelValue : rows
92
89
  const store = createTableStore({ columns, rows: rowsValue, id, config })
93
90
 
94
- store.$onAction(({ name, store, args }) => {
91
+ store.$onAction(({ name, store, args, after }) => {
95
92
  if (name === 'setCellData') {
96
93
  const [colIndex, rowIndex, newCellValue] = args
97
94
  const prevCellValue = store.getCellData(colIndex, rowIndex)
98
- emit('cellUpdate', [colIndex, rowIndex, newCellValue, prevCellValue])
95
+
96
+ after(() => {
97
+ emit('cellUpdate', colIndex, rowIndex, newCellValue, prevCellValue)
98
+ })
99
99
  }
100
100
  })
101
101
 
@@ -118,6 +118,10 @@ onMounted(() => {
118
118
  }
119
119
  })
120
120
 
121
+ const emitInput = (colIndex: number, rowIndex: number, newCellValue: any, prevCellValue: any) => {
122
+ emit('cellUpdate', colIndex, rowIndex, newCellValue, prevCellValue)
123
+ }
124
+
121
125
  const assignStickyCellWidths = () => {
122
126
  const table = tableRef.value
123
127
 
@@ -152,54 +156,6 @@ const assignStickyCellWidths = () => {
152
156
  }
153
157
  }
154
158
 
155
- // const formatCell = (event?: KeyboardEvent, column?: TableColumn, cellData?: any) => {
156
- // let colIndex: number
157
- // const target = event?.target as HTMLTableCellElement
158
- // if (event) {
159
- // colIndex = target.cellIndex
160
- // } else if (column && cellData) {
161
- // colIndex = store.columns.indexOf(column)
162
- // }
163
-
164
- // if (!column && 'format' in store.columns[colIndex]) {
165
- // // TODO: (utils) create helper to extract format from string
166
- // const format = store.columns[colIndex].format
167
- // if (typeof format === 'function') {
168
- // return format(target.innerHTML)
169
- // } else if (typeof format === 'string') {
170
- // // parse format function from string
171
- // // eslint-disable-next-line @typescript-eslint/no-implied-eval
172
- // const formatFn: (args: any) => any = Function(`"use strict";return (${format})`)()
173
- // return formatFn(target.innerHTML)
174
- // } else {
175
- // return target.innerHTML
176
- // }
177
- // } else if (cellData && 'format' in column) {
178
- // const format = column.format
179
- // if (typeof format === 'function') {
180
- // return format(cellData)
181
- // } else if (typeof format === 'string') {
182
- // // parse format function from string
183
- // // eslint-disable-next-line @typescript-eslint/no-implied-eval
184
- // const formatFn: (args: any) => any = Function(`"use strict";return (${format})`)()
185
- // return formatFn(cellData)
186
- // } else {
187
- // return cellData
188
- // }
189
- // } else if (cellData && column.type.toLowerCase() in ['int', 'decimal', 'float', 'number', 'percent']) {
190
- // return cellData
191
- // // TODO: number formatting
192
- // } else {
193
- // return cellData
194
- // }
195
- // }
196
-
197
- // const moveCursorToEnd = (target: HTMLElement) => {
198
- // target.focus()
199
- // document.execCommand('selectAll', false, null)
200
- // document.getSelection().collapseToEnd()
201
- // }
202
-
203
159
  window.addEventListener('keydown', (event: KeyboardEvent) => {
204
160
  if (event.key === 'Escape') {
205
161
  if (store.modal.visible) {
@@ -249,6 +205,7 @@ td.sticky-index {
249
205
  <style scoped>
250
206
  @import url('@stonecrop/themes/default.css');
251
207
  .atable {
208
+ position: relative;
252
209
  font-family: var(--sc-atable-font-family);
253
210
  -webkit-font-smoothing: antialiased;
254
211
  -moz-osx-font-smoothing: grayscale;
@@ -1,26 +1,49 @@
1
1
  <template>
2
- <div class="amodal" tabindex="-1" @click="handleInput" @input="handleInput">
2
+ <div class="amodal" ref="amodal" tabindex="-1" @click="handleInput" @input="handleInput" :style="amodalStyles">
3
3
  <slot />
4
4
  </div>
5
5
  </template>
6
6
 
7
7
  <script setup lang="ts">
8
+ import { useElementBounding } from '@vueuse/core'
9
+ import { useTemplateRef, computed } from 'vue'
10
+
8
11
  import { createTableStore } from '../stores/table'
9
12
 
10
- /* const { colIndex, rowIndex, store } = */ defineProps<{
13
+ const { store, container } = defineProps<{
11
14
  colIndex?: number
12
15
  rowIndex?: number
13
16
  store?: ReturnType<typeof createTableStore>
17
+ container?: HTMLElement
14
18
  }>()
15
19
 
16
- // const cellBackgroundColor = computed(() => {
17
- // if (store.modal.parent) {
18
- // let computedstyle = window.getComputedStyle(store.modal.parent)
19
- // return 'blue'
20
- // } else {
21
- // return 'inherit'
22
- // }
23
- // })
20
+ const amodalRef = useTemplateRef('amodal')
21
+ const { width, height } = useElementBounding(amodalRef)
22
+
23
+ const amodalStyles = computed(() => {
24
+ // the modal usually will appear left align with and below the element it is associated with,
25
+ // but needs to detect and adjust its position if it would overflow the rightr or bottom edges
26
+
27
+ // get the dimensions of whatever container is holding this modal, e.g. Table, Window, div so the modal can detect edges
28
+ const containerWidth = container?.offsetWidth || 0
29
+ const containerHeight = container?.offsetHeight || 0
30
+
31
+ // if this modal would go outside the edge of its container, instead place it above the element (Y) or along the right side (X)
32
+ const modalLeft =
33
+ store.modal.left + width.value > containerWidth
34
+ ? store.modal.left - (width.value - store.modal.width)
35
+ : store.modal.left
36
+
37
+ const modalTop =
38
+ store.modal.top + height.value > containerHeight
39
+ ? store.modal.top - height.value - store.modal.height
40
+ : store.modal.top
41
+
42
+ return {
43
+ left: `${modalLeft}px`,
44
+ top: `${modalTop}px`,
45
+ }
46
+ })
24
47
 
25
48
  const handleInput = (event: Event) => {
26
49
  event.stopPropagation()
@@ -31,7 +54,7 @@ const handleInput = (event: Event) => {
31
54
  @import url('@stonecrop/themes/default.css');
32
55
 
33
56
  .amodal {
34
- position: fixed;
57
+ position: absolute;
35
58
  background-color: var(--sc-row-color-zebra-dark);
36
59
  z-index: 100;
37
60
  }
package/src/index.ts CHANGED
@@ -7,7 +7,15 @@ import ATable from './components/ATable.vue'
7
7
  import ATableHeader from './components/ATableHeader.vue'
8
8
  import ATableModal from './components/ATableModal.vue'
9
9
  export { createTableStore } from './stores/table'
10
- export type { CellContext, TableColumn, TableConfig, TableDisplay, TableRow, TableModal } from './types'
10
+ export type {
11
+ CellContext,
12
+ TableColumn,
13
+ TableConfig,
14
+ TableDisplay,
15
+ TableModal,
16
+ TableModalProps,
17
+ TableRow,
18
+ } from './types'
11
19
 
12
20
  /**
13
21
  * Install all ATable components