backup
This commit is contained in:
parent
7a0f7da119
commit
6526305284
|
@ -50,17 +50,17 @@ export const createApp = (componentLibraries, appDefinition, user, uiFunctions)
|
||||||
if(isFunction(event)) event(context);
|
if(isFunction(event)) event(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialiseChildrenParams = (hydrate, parentContext) => ({
|
const initialiseChildrenParams = (hydrate, parentContext, childIndex) => ({
|
||||||
bb, coreApi, store, parentContext,
|
bb, coreApi, store, parentContext,
|
||||||
componentLibraries, appDefinition,
|
componentLibraries, appDefinition,
|
||||||
hydrate, uiFunctions
|
hydrate, uiFunctions, childIndex
|
||||||
});
|
});
|
||||||
|
|
||||||
const bb = (componentProps, componentContext, parent) => ({
|
const bb = (componentProps, componentContext, childIndex) => ({
|
||||||
hydrateChildren: _initialiseChildren(initialiseChildrenParams(true, componentContext)),
|
hydrateChildren: _initialiseChildren(initialiseChildrenParams(true, componentContext, childIndex)),
|
||||||
appendChildren: _initialiseChildren(initialiseChildrenParams(false, componentContext)),
|
appendChildren: _initialiseChildren(initialiseChildrenParams(false, componentContext, childIndex)),
|
||||||
insertChildren: (props, htmlElement, anchor) =>
|
insertChildren: (props, htmlElement, anchor) =>
|
||||||
_initialiseChildren(initialiseChildrenParams(false, componentContext))
|
_initialiseChildren(initialiseChildrenParams(false, componentContext, childIndex))
|
||||||
(props, htmlElement, anchor),
|
(props, htmlElement, anchor),
|
||||||
context: componentContext,
|
context: componentContext,
|
||||||
props: componentProps,
|
props: componentProps,
|
||||||
|
|
|
@ -35,7 +35,7 @@ export const loadBudibase = async ({
|
||||||
props = appDefinition.props;
|
props = appDefinition.props;
|
||||||
}
|
}
|
||||||
|
|
||||||
const _app = createApp(
|
const app = createApp(
|
||||||
componentLibraries,
|
componentLibraries,
|
||||||
appDefinition,
|
appDefinition,
|
||||||
user,
|
user,
|
||||||
|
|
|
@ -12,7 +12,7 @@ export const _initialiseChildren = (initialiseOpts) =>
|
||||||
(childrenProps, htmlElement, anchor=null) => {
|
(childrenProps, htmlElement, anchor=null) => {
|
||||||
|
|
||||||
const { uiFunctions, bb, coreApi,
|
const { uiFunctions, bb, coreApi,
|
||||||
store, componentLibraries,
|
store, componentLibraries, childIndex,
|
||||||
appDefinition, parentContext, hydrate } = initialiseOpts;
|
appDefinition, parentContext, hydrate } = initialiseOpts;
|
||||||
|
|
||||||
const childComponents = [];
|
const childComponents = [];
|
||||||
|
@ -23,6 +23,7 @@ export const _initialiseChildren = (initialiseOpts) =>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let childIndex = 0;
|
||||||
for(let childProps of childrenProps) {
|
for(let childProps of childrenProps) {
|
||||||
|
|
||||||
const {componentName, libName} = splitName(childProps._component);
|
const {componentName, libName} = splitName(childProps._component);
|
||||||
|
@ -36,14 +37,19 @@ export const _initialiseChildren = (initialiseOpts) =>
|
||||||
|
|
||||||
const componentConstructor = componentLibraries[libName][componentName];
|
const componentConstructor = componentLibraries[libName][componentName];
|
||||||
|
|
||||||
const {component, context} = renderComponent({
|
const {component, context, lastChildIndex} = renderComponent({
|
||||||
componentConstructor,uiFunctions,
|
componentConstructor,uiFunctions,
|
||||||
htmlElement, anchor,
|
htmlElement, anchor, childIndex,
|
||||||
parentContext, initialProps, bb});
|
parentContext, initialProps, bb});
|
||||||
|
|
||||||
|
childIndex = lastChildIndex;
|
||||||
bind(component);
|
|
||||||
childComponents.push({component, context});
|
const unsubscribe = bind(component);
|
||||||
|
childComponents.push({
|
||||||
|
component,
|
||||||
|
context,
|
||||||
|
unsubscribe
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return childComponents;
|
return childComponents;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
export const renderComponent = ({
|
export const renderComponent = ({
|
||||||
componentConstructor, uiFunctions,
|
componentConstructor, uiFunctions,
|
||||||
htmlElement, anchor, parentContext,
|
htmlElement, anchor, parentContext,
|
||||||
initialProps, bb}) => {
|
initialProps, bb, childIndex}) => {
|
||||||
|
|
||||||
const func = initialProps._id
|
const func = initialProps._id
|
||||||
? uiFunctions[componentProps._id]
|
? uiFunctions[componentProps._id]
|
||||||
|
@ -27,6 +27,8 @@ export const renderComponent = ({
|
||||||
hydrate:false,
|
hydrate:false,
|
||||||
anchor
|
anchor
|
||||||
});
|
});
|
||||||
|
|
||||||
|
childIndex += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(func) {
|
if(func) {
|
||||||
|
@ -37,6 +39,7 @@ export const renderComponent = ({
|
||||||
|
|
||||||
return ({
|
return ({
|
||||||
context: componentContext,
|
context: componentContext,
|
||||||
|
lastChildIndex: childIndex,
|
||||||
component
|
component
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue