Type grid svelte file
This commit is contained in:
parent
d476a5c5cd
commit
51c7fe8c5b
|
@ -1,4 +1,4 @@
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { setContext, onMount } from "svelte"
|
import { setContext, onMount } from "svelte"
|
||||||
import { writable, derived } from "svelte/store"
|
import { writable, derived } from "svelte/store"
|
||||||
import { fade } from "svelte/transition"
|
import { fade } from "svelte/transition"
|
||||||
|
@ -53,17 +53,16 @@
|
||||||
const gridID = `grid-${Math.random().toString().slice(2)}`
|
const gridID = `grid-${Math.random().toString().slice(2)}`
|
||||||
|
|
||||||
// Store props in a store for reference in other stores
|
// Store props in a store for reference in other stores
|
||||||
const props = writable($$props)
|
const props: any = writable($$props)
|
||||||
|
|
||||||
// Build up context
|
// Build up context
|
||||||
let context = {
|
let context = attachStores({
|
||||||
API: API || createAPIClient(),
|
API: API || createAPIClient(),
|
||||||
Constants,
|
Constants,
|
||||||
gridID,
|
gridID,
|
||||||
props,
|
props,
|
||||||
}
|
...createEventManagers(),
|
||||||
context = { ...context, ...createEventManagers() }
|
})
|
||||||
context = attachStores(context)
|
|
||||||
|
|
||||||
// Reference some stores for local use
|
// Reference some stores for local use
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import * as NonPlus from "./datasources/nonPlus"
|
||||||
import * as Cache from "./cache"
|
import * as Cache from "./cache"
|
||||||
import * as Conditions from "./conditions"
|
import * as Conditions from "./conditions"
|
||||||
import { SortOrder, UIDatasource, UISearchFilter } from "@budibase/types"
|
import { SortOrder, UIDatasource, UISearchFilter } from "@budibase/types"
|
||||||
|
import * as Constants from "../lib/constants"
|
||||||
|
|
||||||
const DependencyOrderedStores = [
|
const DependencyOrderedStores = [
|
||||||
Sort,
|
Sort,
|
||||||
|
@ -73,6 +74,7 @@ export interface BaseStoreProps {
|
||||||
canEditColumns?: boolean
|
canEditColumns?: boolean
|
||||||
canExpandRows?: boolean
|
canExpandRows?: boolean
|
||||||
canSaveSchema?: boolean
|
canSaveSchema?: boolean
|
||||||
|
minHeight?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BaseStore {
|
export interface BaseStore {
|
||||||
|
@ -81,6 +83,7 @@ export interface BaseStore {
|
||||||
props: Writable<BaseStoreProps>
|
props: Writable<BaseStoreProps>
|
||||||
subscribe: any
|
subscribe: any
|
||||||
dispatch: (event: string, data: any) => any
|
dispatch: (event: string, data: any) => any
|
||||||
|
Constants: typeof Constants
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Store = BaseStore &
|
export type Store = BaseStore &
|
||||||
|
@ -107,7 +110,7 @@ export type Store = BaseStore &
|
||||||
Sort.Store &
|
Sort.Store &
|
||||||
Bounds.Store
|
Bounds.Store
|
||||||
|
|
||||||
export const attachStores = (context: Store): Store => {
|
export const attachStores = (context: BaseStore): Store => {
|
||||||
// Atomic store creation
|
// Atomic store creation
|
||||||
for (let store of DependencyOrderedStores) {
|
for (let store of DependencyOrderedStores) {
|
||||||
if ("createStores" in store) {
|
if ("createStores" in store) {
|
||||||
|
|
Loading…
Reference in New Issue