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