spark-grid-vue3 0.0.2 → 0.0.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.
- package/package.json +3 -2
- package/src/definition/types.d.ts +2 -0
- package/src/index.d.ts +1 -0
- package/src/utils/RadioButtonSelectedMapper.ts +17 -4
- package/src/main.ts +0 -10
package/package.json
CHANGED
|
@@ -65,6 +65,7 @@ export type Action = {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export type ComputedColumn = () => Column[]
|
|
68
|
+
export type UniqueKeyIdentifier = (row: Row) => string
|
|
68
69
|
|
|
69
70
|
export type SparkGridConfig = {
|
|
70
71
|
url?: string | function,
|
|
@@ -111,6 +112,7 @@ export type SparkGridConfig = {
|
|
|
111
112
|
onClickCell?: OnCellEvent,
|
|
112
113
|
onDoubleClickCell?: OnCellEvent,
|
|
113
114
|
onContextMenu?: OnContextMenu,
|
|
115
|
+
uniqueKeyIdentifier?: string | UniqueKeyIdentifier,
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
export type Row = {
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'definition/types'
|
|
@@ -3,15 +3,28 @@ import type {GridComponent, Row} from "../definition/types"
|
|
|
3
3
|
export class RadioButtonSelectedMapper {
|
|
4
4
|
static map(row: Row, grid: GridComponent) {
|
|
5
5
|
if (grid._selectedRadioRow) {
|
|
6
|
-
const uuidMatches = row._uuid == grid._selectedRadioRow._uuid
|
|
7
|
-
const idMatches = row.id == grid._selectedRadioRow.id
|
|
6
|
+
const uuidMatches: boolean = row._uuid == grid._selectedRadioRow._uuid
|
|
8
7
|
|
|
9
|
-
if (uuidMatches ||
|
|
8
|
+
if (uuidMatches || this._idMatches(row, grid)) {
|
|
10
9
|
row._isRadioChecked = true;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
return row;
|
|
16
14
|
}
|
|
15
|
+
|
|
16
|
+
static _idMatches(row: Row, grid: GridComponent): boolean {
|
|
17
|
+
if (!grid._selectedRadioRow) {
|
|
18
|
+
return false
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof grid.config.uniqueKeyIdentifier == 'string') {
|
|
22
|
+
const uniqueKey = grid.config.uniqueKeyIdentifier
|
|
23
|
+
return row[uniqueKey] == grid._selectedRadioRow[uniqueKey]
|
|
24
|
+
} else if (typeof grid.config.uniqueKeyIdentifier == 'function') {
|
|
25
|
+
return grid.config.uniqueKeyIdentifier(row) == grid.config.uniqueKeyIdentifier(grid._selectedRadioRow)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return row.id == grid._selectedRadioRow.id
|
|
29
|
+
}
|
|
17
30
|
}
|