2022-02-11 12:55:35 +01:00
|
|
|
import { writable } from "svelte/store"
|
|
|
|
|
|
|
|
const createRowSelectionStore = () => {
|
2022-02-22 16:18:08 +01:00
|
|
|
const store = writable({})
|
2022-02-11 12:55:35 +01:00
|
|
|
|
2022-02-22 16:18:08 +01:00
|
|
|
function updateSelection(componentId, selectedRows) {
|
2022-02-11 12:55:35 +01:00
|
|
|
store.update(state => {
|
2022-02-22 16:18:08 +01:00
|
|
|
state[componentId] = [...selectedRows]
|
2022-02-11 12:55:35 +01:00
|
|
|
return state
|
|
|
|
})
|
|
|
|
}
|
2022-02-22 16:18:08 +01:00
|
|
|
|
2022-02-11 12:55:35 +01:00
|
|
|
return {
|
|
|
|
subscribe: store.subscribe,
|
2022-02-22 16:18:08 +01:00
|
|
|
set: store.set,
|
2022-02-11 12:55:35 +01:00
|
|
|
actions: {
|
2022-02-22 16:18:08 +01:00
|
|
|
updateSelection,
|
2022-02-11 12:55:35 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const rowSelectionStore = createRowSelectionStore()
|