@stonecrop/atable 0.3.1 → 0.3.3

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.
@@ -27,9 +27,9 @@ export declare const createTableStore: (initData: {
27
27
  pinned?: boolean;
28
28
  cellComponent?: string;
29
29
  cellComponentProps?: Record<string, any>;
30
- modalComponent?: string | ((context?: CellContext) => string);
30
+ modalComponent?: string | ((context: CellContext) => string);
31
31
  modalComponentExtraProps?: Record<string, any>;
32
- format?: string | ((value: any, context?: CellContext) => string);
32
+ format?: string | ((value: any, context: CellContext) => string);
33
33
  mask?: (value: any) => any;
34
34
  }[], TableColumn[] | {
35
35
  name: string;
@@ -41,9 +41,9 @@ export declare const createTableStore: (initData: {
41
41
  pinned?: boolean;
42
42
  cellComponent?: string;
43
43
  cellComponentProps?: Record<string, any>;
44
- modalComponent?: string | ((context?: CellContext) => string);
44
+ modalComponent?: string | ((context: CellContext) => string);
45
45
  modalComponentExtraProps?: Record<string, any>;
46
- format?: string | ((value: any, context?: CellContext) => string);
46
+ format?: string | ((value: any, context: CellContext) => string);
47
47
  mask?: (value: any) => any;
48
48
  }[]>;
49
49
  rows: import("vue").Ref<{
@@ -85,23 +85,25 @@ export declare const createTableStore: (initData: {
85
85
  modal: import("vue").Ref<{
86
86
  colIndex?: number;
87
87
  event?: string;
88
+ height?: number;
88
89
  left?: number;
89
90
  parent?: HTMLElement;
90
91
  rowIndex?: number;
91
92
  top?: number;
92
93
  visible?: boolean;
93
- width?: string;
94
+ width?: number;
94
95
  component?: string;
95
96
  componentProps?: Record<string, any>;
96
97
  }, TableModal | {
97
98
  colIndex?: number;
98
99
  event?: string;
100
+ height?: number;
99
101
  left?: number;
100
102
  parent?: HTMLElement;
101
103
  rowIndex?: number;
102
104
  top?: number;
103
105
  visible?: boolean;
104
- width?: string;
106
+ width?: number;
105
107
  component?: string;
106
108
  componentProps?: Record<string, any>;
107
109
  }>;
@@ -129,9 +131,9 @@ export declare const createTableStore: (initData: {
129
131
  pinned?: boolean;
130
132
  cellComponent?: string;
131
133
  cellComponentProps?: Record<string, any>;
132
- modalComponent?: string | ((context?: CellContext) => string);
134
+ modalComponent?: string | ((context: CellContext) => string);
133
135
  modalComponentExtraProps?: Record<string, any>;
134
- format?: string | ((value: any, context?: CellContext) => string);
136
+ format?: string | ((value: any, context: CellContext) => string);
135
137
  mask?: (value: any) => any;
136
138
  }[], TableColumn[] | {
137
139
  name: string;
@@ -143,9 +145,9 @@ export declare const createTableStore: (initData: {
143
145
  pinned?: boolean;
144
146
  cellComponent?: string;
145
147
  cellComponentProps?: Record<string, any>;
146
- modalComponent?: string | ((context?: CellContext) => string);
148
+ modalComponent?: string | ((context: CellContext) => string);
147
149
  modalComponentExtraProps?: Record<string, any>;
148
- format?: string | ((value: any, context?: CellContext) => string);
150
+ format?: string | ((value: any, context: CellContext) => string);
149
151
  mask?: (value: any) => any;
150
152
  }[]>;
151
153
  rows: import("vue").Ref<{
@@ -187,23 +189,25 @@ export declare const createTableStore: (initData: {
187
189
  modal: import("vue").Ref<{
188
190
  colIndex?: number;
189
191
  event?: string;
192
+ height?: number;
190
193
  left?: number;
191
194
  parent?: HTMLElement;
192
195
  rowIndex?: number;
193
196
  top?: number;
194
197
  visible?: boolean;
195
- width?: string;
198
+ width?: number;
196
199
  component?: string;
197
200
  componentProps?: Record<string, any>;
198
201
  }, TableModal | {
199
202
  colIndex?: number;
200
203
  event?: string;
204
+ height?: number;
201
205
  left?: number;
202
206
  parent?: HTMLElement;
203
207
  rowIndex?: number;
204
208
  top?: number;
205
209
  visible?: boolean;
206
- width?: string;
210
+ width?: number;
207
211
  component?: string;
208
212
  componentProps?: Record<string, any>;
209
213
  }>;
@@ -231,9 +235,9 @@ export declare const createTableStore: (initData: {
231
235
  pinned?: boolean;
232
236
  cellComponent?: string;
233
237
  cellComponentProps?: Record<string, any>;
234
- modalComponent?: string | ((context?: CellContext) => string);
238
+ modalComponent?: string | ((context: CellContext) => string);
235
239
  modalComponentExtraProps?: Record<string, any>;
236
- format?: string | ((value: any, context?: CellContext) => string);
240
+ format?: string | ((value: any, context: CellContext) => string);
237
241
  mask?: (value: any) => any;
238
242
  }[], TableColumn[] | {
239
243
  name: string;
@@ -245,9 +249,9 @@ export declare const createTableStore: (initData: {
245
249
  pinned?: boolean;
246
250
  cellComponent?: string;
247
251
  cellComponentProps?: Record<string, any>;
248
- modalComponent?: string | ((context?: CellContext) => string);
252
+ modalComponent?: string | ((context: CellContext) => string);
249
253
  modalComponentExtraProps?: Record<string, any>;
250
- format?: string | ((value: any, context?: CellContext) => string);
254
+ format?: string | ((value: any, context: CellContext) => string);
251
255
  mask?: (value: any) => any;
252
256
  }[]>;
253
257
  rows: import("vue").Ref<{
@@ -289,23 +293,25 @@ export declare const createTableStore: (initData: {
289
293
  modal: import("vue").Ref<{
290
294
  colIndex?: number;
291
295
  event?: string;
296
+ height?: number;
292
297
  left?: number;
293
298
  parent?: HTMLElement;
294
299
  rowIndex?: number;
295
300
  top?: number;
296
301
  visible?: boolean;
297
- width?: string;
302
+ width?: number;
298
303
  component?: string;
299
304
  componentProps?: Record<string, any>;
300
305
  }, TableModal | {
301
306
  colIndex?: number;
302
307
  event?: string;
308
+ height?: number;
303
309
  left?: number;
304
310
  parent?: HTMLElement;
305
311
  rowIndex?: number;
306
312
  top?: number;
307
313
  visible?: boolean;
308
- width?: string;
314
+ width?: number;
309
315
  component?: string;
310
316
  componentProps?: Record<string, any>;
311
317
  }>;
@@ -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,EAA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AS,GAAG;iCA3CrC,WAAW,KAAG,aAAa;0BA0ElC,MAAM,gBAAgB,MAAM;mCAhEnB,MAAM;6BAJZ,MAAM;4BAlBP,MAAM,YAAY,MAAM,SAAS,GAAG;gCAkChC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0Cd,UAAU;kBA7EhB,CAAC,kBAAkB,MAAM,YAAY,MAAM,KAAG,CAAC;oCAmD7B,MAAM,YAAY,MAAM;kCAK1B,MAAM,YAAY,MAAM,SAAS,GAAG;iCA3CrC,WAAW,KAAG,aAAa;0BA0ElC,MAAM,gBAAgB,MAAM;mCAhEnB,MAAM;6BAJZ,MAAM;4BAlBP,MAAM,YAAY,MAAM,SAAS,GAAG;gCAkChC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA0Cd,UAAU;kBA7EhB,CAAC,kBAAkB,MAAM,YAAY,MAAM,KAAG,CAAC;oCAmD7B,MAAM,YAAY,MAAM;kCAK1B,MAAM,YAAY,MAAM,SAAS,GAAG;iCA3CrC,WAAW,KAAG,aAAa;0BA0ElC,MAAM,gBAAgB,MAAM;mCAhEnB,MAAM;6BAJZ,MAAM;4BAlBP,MAAM,YAAY,MAAM,SAAS,GAAG;gCAkChC,MAAM;gMAyF1C,CAAA"}
@@ -12,9 +12,23 @@ export type TableColumn = {
12
12
  pinned?: boolean;
13
13
  cellComponent?: string;
14
14
  cellComponentProps?: Record<string, any>;
15
- modalComponent?: string | ((context?: CellContext) => string);
15
+ /**
16
+ * The component to use for the modal. If a function is provided, it will be called with the cell context.
17
+ * The following properties are available on the cell context:
18
+ * - `row` - the row object
19
+ * - `column` - the column object
20
+ * - `table` - the table object
21
+ *
22
+ * The function should return the name of the component to use for the modal.
23
+ *
24
+ * Additionally, the following properties will be automatically passed to the modal component:
25
+ * - `colIndex` - the column index of the current cell
26
+ * - `rowIndex` - the row index of the current cell
27
+ * - `store` - the table data store
28
+ */
29
+ modalComponent?: string | ((context: CellContext) => string);
16
30
  modalComponentExtraProps?: Record<string, any>;
17
- format?: string | ((value: any, context?: CellContext) => string);
31
+ format?: string | ((value: any, context: CellContext) => string);
18
32
  mask?: (value: any) => any;
19
33
  };
20
34
  /**
@@ -73,12 +87,13 @@ export type TableRow = {
73
87
  export type TableModal = {
74
88
  colIndex?: number;
75
89
  event?: string;
90
+ height?: number;
76
91
  left?: number;
77
92
  parent?: HTMLElement;
78
93
  rowIndex?: number;
79
94
  top?: number;
80
95
  visible?: boolean;
81
- width?: string;
96
+ width?: number;
82
97
  component?: string;
83
98
  componentProps?: Record<string, any>;
84
99
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IAEZ,KAAK,CAAC,EAAE,eAAe,CAAA;IACvB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACxC,cAAc,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,WAAW,KAAK,MAAM,CAAC,CAAA;IAC7D,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAE9C,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAA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ED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/atable",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
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.1",
42
- "@stonecrop/utilities": "0.3.1"
41
+ "@stonecrop/themes": "0.3.3",
42
+ "@stonecrop/utilities": "0.3.3"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@microsoft/api-documenter": "^7.26.2",
@@ -28,7 +28,7 @@
28
28
  <script setup lang="ts">
29
29
  import { KeypressHandlers, defaultKeypressHandlers, useKeyboardNav } from '@stonecrop/utilities'
30
30
  import { useElementBounding } from '@vueuse/core'
31
- import { computed, CSSProperties, ref, useTemplateRef } from 'vue'
31
+ import { computed, CSSProperties, ref, useTemplateRef, watch } from 'vue'
32
32
 
33
33
  import { createTableStore } from '../stores/table'
34
34
  import { isHtmlString } from '../utils'
@@ -49,11 +49,11 @@ const {
49
49
  }>()
50
50
 
51
51
  const cellRef = useTemplateRef<HTMLTableCellElement>('cell')
52
- const { bottom, left } = useElementBounding(cellRef)
52
+ const { width, height } = useElementBounding(cellRef)
53
53
 
54
54
  // keep a shallow copy of the original cell value for comparison
55
55
  const originalData = store.getCellData(colIndex, rowIndex)
56
- const displayValue = store.getCellDisplayValue(colIndex, rowIndex)
56
+ const displayValue = ref(store.getCellDisplayValue(colIndex, rowIndex))
57
57
  const currentData = ref('')
58
58
  const cellModified = ref(false)
59
59
 
@@ -63,9 +63,16 @@ 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
73
  const isHtmlValue = computed(() => {
67
74
  // TODO: check if display value is a native DOM element
68
- return typeof displayValue === 'string' ? isHtmlString(displayValue) : false
75
+ return typeof displayValue.value === 'string' ? isHtmlString(displayValue.value) : false
69
76
  })
70
77
 
71
78
  const cellStyle = computed((): CSSProperties => {
@@ -90,9 +97,10 @@ const showModal = () => {
90
97
  state.modal.colIndex = colIndex
91
98
  state.modal.rowIndex = rowIndex
92
99
  state.modal.parent = cellRef.value
93
- state.modal.top = bottom.value
94
- state.modal.left = left.value
95
- state.modal.width = cellWidth
100
+ state.modal.top = cellRef.value.offsetTop + cellRef.value.offsetHeight
101
+ state.modal.left = cellRef.value.offsetLeft
102
+ state.modal.width = width.value
103
+ state.modal.height = height.value
96
104
 
97
105
  if (typeof column.modalComponent === 'function') {
98
106
  state.modal.component = column.modalComponent({ table: state.table, row, column })
@@ -37,11 +37,7 @@
37
37
  :colIndex="store.modal.colIndex"
38
38
  :rowIndex="store.modal.rowIndex"
39
39
  :store="store"
40
- :style="{
41
- left: store.modal.left + 'px',
42
- top: store.modal.top + 'px',
43
- maxWidth: store.modal.width + 'px',
44
- }">
40
+ :container="tableRef">
45
41
  <template #default>
46
42
  <component
47
43
  :key="`${store.modal.rowIndex}:${store.modal.colIndex}`"
@@ -249,6 +245,7 @@ td.sticky-index {
249
245
  <style scoped>
250
246
  @import url('@stonecrop/themes/default.css');
251
247
  .atable {
248
+ position: relative;
252
249
  font-family: var(--sc-atable-font-family);
253
250
  -webkit-font-smoothing: antialiased;
254
251
  -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
  }
@@ -14,10 +14,24 @@ export type TableColumn = {
14
14
 
15
15
  cellComponent?: string
16
16
  cellComponentProps?: Record<string, any>
17
- modalComponent?: string | ((context?: CellContext) => string)
17
+ /**
18
+ * The component to use for the modal. If a function is provided, it will be called with the cell context.
19
+ * The following properties are available on the cell context:
20
+ * - `row` - the row object
21
+ * - `column` - the column object
22
+ * - `table` - the table object
23
+ *
24
+ * The function should return the name of the component to use for the modal.
25
+ *
26
+ * Additionally, the following properties will be automatically passed to the modal component:
27
+ * - `colIndex` - the column index of the current cell
28
+ * - `rowIndex` - the row index of the current cell
29
+ * - `store` - the table data store
30
+ */
31
+ modalComponent?: string | ((context: CellContext) => string)
18
32
  modalComponentExtraProps?: Record<string, any>
19
33
 
20
- format?: string | ((value: any, context?: CellContext) => string)
34
+ format?: string | ((value: any, context: CellContext) => string)
21
35
  mask?: (value: any) => any
22
36
  }
23
37
 
@@ -79,12 +93,13 @@ export type TableRow = {
79
93
  export type TableModal = {
80
94
  colIndex?: number
81
95
  event?: string
96
+ height?: number
82
97
  left?: number
83
98
  parent?: HTMLElement
84
99
  rowIndex?: number
85
100
  top?: number
86
101
  visible?: boolean
87
- width?: string
102
+ width?: number
88
103
 
89
104
  component?: string
90
105
  componentProps?: Record<string, any>