Merge pull request #15240 from Budibase/typing/stores-grid-menu
Typing grid menu store
This commit is contained in:
commit
a759b465e1
|
@ -62,7 +62,8 @@ export type Store = BaseStore &
|
||||||
NonPlus.Store &
|
NonPlus.Store &
|
||||||
Datasource.Store &
|
Datasource.Store &
|
||||||
Validation.Store &
|
Validation.Store &
|
||||||
Users.Store & {
|
Users.Store &
|
||||||
|
Menu.Store & {
|
||||||
// TODO while typing the rest of stores
|
// TODO while typing the rest of stores
|
||||||
fetch: Writable<any>
|
fetch: Writable<any>
|
||||||
filter: Writable<any>
|
filter: Writable<any>
|
||||||
|
@ -80,6 +81,11 @@ export type Store = BaseStore &
|
||||||
schemaOverrides: Writable<any>
|
schemaOverrides: Writable<any>
|
||||||
focusedCellId: Writable<any>
|
focusedCellId: Writable<any>
|
||||||
previousFocusedRowId: Writable<string>
|
previousFocusedRowId: Writable<string>
|
||||||
|
gridID: string
|
||||||
|
selectedRows: Writable<any>
|
||||||
|
selectedRowCount: Writable<any>
|
||||||
|
selectedCellMap: Writable<any>
|
||||||
|
selectedCellCount: Writable<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const attachStores = (context: Store): Store => {
|
export const attachStores = (context: Store): Store => {
|
||||||
|
|
|
@ -1,8 +1,24 @@
|
||||||
import { writable, get } from "svelte/store"
|
import { writable, get, Writable } from "svelte/store"
|
||||||
|
|
||||||
|
import { Store as StoreContext } from "."
|
||||||
import { parseCellID } from "../lib/utils"
|
import { parseCellID } from "../lib/utils"
|
||||||
|
|
||||||
|
interface MenuStoreData {
|
||||||
|
left: number
|
||||||
|
top: number
|
||||||
|
visible: boolean
|
||||||
|
multiRowMode: boolean
|
||||||
|
multiCellMode: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MenuStore {
|
||||||
|
menu: Writable<MenuStoreData>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Store = MenuStore
|
||||||
|
|
||||||
export const createStores = () => {
|
export const createStores = () => {
|
||||||
const menu = writable({
|
const menu = writable<MenuStoreData>({
|
||||||
left: 0,
|
left: 0,
|
||||||
top: 0,
|
top: 0,
|
||||||
visible: false,
|
visible: false,
|
||||||
|
@ -14,7 +30,7 @@ export const createStores = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createActions = context => {
|
export const createActions = (context: StoreContext) => {
|
||||||
const {
|
const {
|
||||||
menu,
|
menu,
|
||||||
focusedCellId,
|
focusedCellId,
|
||||||
|
@ -25,7 +41,7 @@ export const createActions = context => {
|
||||||
selectedCellCount,
|
selectedCellCount,
|
||||||
} = context
|
} = context
|
||||||
|
|
||||||
const open = (cellId, e) => {
|
const open = (cellId: string, e: MouseEvent) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
|
||||||
|
@ -37,7 +53,7 @@ export const createActions = context => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute bounds of cell relative to outer data node
|
// Compute bounds of cell relative to outer data node
|
||||||
const targetBounds = e.target.getBoundingClientRect()
|
const targetBounds = (e.target as HTMLElement).getBoundingClientRect()
|
||||||
const dataBounds = dataNode.getBoundingClientRect()
|
const dataBounds = dataNode.getBoundingClientRect()
|
||||||
|
|
||||||
// Check if there are multiple rows selected, and if this is one of them
|
// Check if there are multiple rows selected, and if this is one of them
|
Loading…
Reference in New Issue