added _bb.get/setContext to clientApi - for MD components
This commit is contained in:
parent
dce21f7fbe
commit
f0dbfa15bf
|
@ -3,6 +3,7 @@ import { setState, setStateFromBinding } from "./setState"
|
|||
import { trimSlash } from "../common/trimSlash"
|
||||
import { isBound } from "./parseBinding"
|
||||
import { attachChildren } from "../render/attachChildren"
|
||||
import { getContext, setContext } from "./getSetContext"
|
||||
|
||||
export const bbFactory = ({
|
||||
store,
|
||||
|
@ -60,6 +61,8 @@ export const bbFactory = ({
|
|||
setState: (path, value) => setState(store, path, value),
|
||||
getStateOrValue: (prop, currentContext) =>
|
||||
getStateOrValue(getCurrentState(), prop, currentContext),
|
||||
getContext: getContext(treeNode),
|
||||
setContext: setContext(treeNode),
|
||||
store: store,
|
||||
relativeUrl,
|
||||
api,
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
export const setContext = treeNode => (key, value) =>
|
||||
(treeNode.context[key] = value)
|
||||
|
||||
export const getContext = treeNode => key => {
|
||||
if (treeNode.context && treeNode.context[key] !== undefined)
|
||||
return treeNode.context[key]
|
||||
|
||||
if (!treeNode.context.$parent) return
|
||||
|
||||
return getContext(treeNode.parentNode)(key)
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
export let onLoad
|
||||
|
||||
const cb = new ClassBuilder("data-table")
|
||||
_bb.setContext("BBMD:data-table:cb", cb)
|
||||
|
||||
let datatable = null
|
||||
let instance = null
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
<script>
|
||||
import { getContext } from "svelte"
|
||||
import ClassBuilder from "../ClassBuilder.js"
|
||||
|
||||
export let _bb
|
||||
|
||||
const cb = new ClassBuilder("data-table")
|
||||
const cb = _bb.getContext("BBMD:data-table:cb")
|
||||
|
||||
let tbody
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
<script>
|
||||
import { getContext } from "svelte"
|
||||
import ClassBuilder from "../ClassBuilder.js"
|
||||
|
||||
export let isHeader = false
|
||||
export let numeric = false
|
||||
export let _bb
|
||||
|
||||
const cb = new ClassBuilder("data-table")
|
||||
const cb = _bb.getContext("BBMD:data-table:cb")
|
||||
|
||||
let elementName = isHeader ? "header-cell" : "cell"
|
||||
let modifiers = { numeric }
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<script>
|
||||
|
||||
import ClassBuilder from "../ClassBuilder.js"
|
||||
|
||||
export let _bb
|
||||
|
||||
const cb = new ClassBuilder("data-table")
|
||||
const cb = _bb.getContext("BBMD:data-table:cb")
|
||||
|
||||
let thead
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<script>
|
||||
import { getContext } from "svelte";
|
||||
import ClassBuilder from "../ClassBuilder.js"
|
||||
|
||||
export let onSelect = () => {};
|
||||
export let isHeader = false;
|
||||
|
@ -10,7 +9,7 @@
|
|||
let row = null;
|
||||
let selected = false;
|
||||
|
||||
const cb = new ClassBuilder("data-table")
|
||||
const cb = _bb.getContext("BBMD:data-table:cb")
|
||||
|
||||
let elementName = isHeader ? "header-row" : "row";
|
||||
let modifiers = {};
|
||||
|
|
Loading…
Reference in New Issue