-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da68c8d
commit 74c0320
Showing
14 changed files
with
362 additions
and
383 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
packages/devextreme-vue/src/core/__mocks__/templates-discovering.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
/* eslint-disable no-undef */ | ||
export const discover = jest.fn(() => ({})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,58 @@ | ||
/* eslint-disable import/named */ | ||
import { PatchFlags } from '@vue/shared'; | ||
import { VNode } from 'vue'; | ||
import Configuration from './configuration'; | ||
import { IConfigurable, IConfigurationComponent } from './configuration-component'; | ||
import { configurationChildren, getComponentInfo, getNormalizedProps } from './vue-helper'; | ||
|
||
function pullAllChildren(directChildren: VNode[], allChildren: VNode[], config: Configuration): void { | ||
if(!directChildren || directChildren.length === 0) { return; } | ||
if (!directChildren || directChildren.length === 0) { return; } | ||
|
||
pullConfigComponents(directChildren, allChildren, config); | ||
pullConfigComponents(directChildren, allChildren, config); | ||
} | ||
|
||
export function isFragment(node: any): boolean { | ||
const { patchFlag } = node; | ||
return patchFlag === PatchFlags.KEYED_FRAGMENT | ||
const { patchFlag } = node; | ||
return patchFlag === PatchFlags.KEYED_FRAGMENT | ||
|| patchFlag === PatchFlags.UNKEYED_FRAGMENT | ||
|| patchFlag === PatchFlags.STABLE_FRAGMENT | ||
|| patchFlag === PatchFlags.BAIL; | ||
} | ||
|
||
export function pullConfigComponents(children: VNode[], nodes: VNode[], ownerConfig: Configuration): void { | ||
children.forEach((node) => { | ||
if(isFragment(node) && Array.isArray(node.children)) { | ||
pullConfigComponents(node.children as any as VNode[], nodes, ownerConfig); | ||
} | ||
if(!isFragment(node)) { | ||
nodes.push(node); | ||
} | ||
if(!node) { return; } | ||
|
||
const componentInfo = getComponentInfo(node) as any as IConfigurationComponent; | ||
if(!componentInfo || !componentInfo.$_optionName) { return; } | ||
|
||
const componentChildren = configurationChildren(node); | ||
const initialValues = { | ||
...componentInfo.$_predefinedProps, | ||
...getNormalizedProps(node.props || {}), | ||
}; | ||
|
||
const config = ownerConfig.createNested( | ||
componentInfo.$_optionName, | ||
initialValues, | ||
componentInfo.$_isCollectionItem, | ||
componentInfo.$_expectedChildren, | ||
); | ||
|
||
(node as any as IConfigurable).$_config = config; | ||
(node as any as IConfigurable).$_innerChanges = {}; | ||
|
||
if(componentChildren) { | ||
pullConfigComponents(componentChildren, nodes, config); | ||
} | ||
}); | ||
children.forEach((node) => { | ||
if (isFragment(node) && Array.isArray(node.children)) { | ||
pullConfigComponents(node.children as any as VNode[], nodes, ownerConfig); | ||
} | ||
if (!isFragment(node)) { | ||
nodes.push(node); | ||
} | ||
if (!node) { return; } | ||
|
||
const componentInfo = getComponentInfo(node) as any as IConfigurationComponent; | ||
if (!componentInfo || !componentInfo.$_optionName) { return; } | ||
|
||
const componentChildren = configurationChildren(node); | ||
const initialValues = { | ||
...componentInfo.$_predefinedProps, | ||
...getNormalizedProps(node.props || {}), | ||
}; | ||
|
||
const config = ownerConfig.createNested( | ||
componentInfo.$_optionName, | ||
initialValues, | ||
componentInfo.$_isCollectionItem, | ||
componentInfo.$_expectedChildren, | ||
); | ||
|
||
(node as any as IConfigurable).$_config = config; | ||
(node as any as IConfigurable).$_innerChanges = {}; | ||
|
||
if (componentChildren) { | ||
pullConfigComponents(componentChildren, nodes, config); | ||
} | ||
}); | ||
} | ||
|
||
export { | ||
pullAllChildren, | ||
pullAllChildren, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.