-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(comp: tree-select): add tree-select comp
- Loading branch information
1 parent
d5c2f81
commit 3fd3196
Showing
66 changed files
with
2,960 additions
and
15 deletions.
There are no files selected for viewing
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
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
18 changes: 18 additions & 0 deletions
18
packages/components/tree-select/__tests__/__snapshots__/treeSelect.spec.ts.snap
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`TreeSelect render work 1`] = ` | ||
"<div class=\\"ix-tree-select ix-tree-select-single ix-tree-select-with-suffix ix-tree-select-md\\"> | ||
<!----><label class=\\"ix-tree-select-selector\\"> | ||
<!----> | ||
<div class=\\"ix-tree-select-selector-input\\"><input class=\\"ix-tree-select-selector-input-inner\\" style=\\"opacity: 0;\\" autocomplete=\\"off\\"> | ||
<!----> | ||
</div> | ||
<div class=\\"ix-tree-select-selector-placeholder\\"> | ||
<!----> | ||
</div> | ||
<div class=\\"ix-tree-select-selector-suffix\\"><i class=\\"ix-icon ix-icon-down\\" role=\\"img\\" aria-label=\\"down\\"></i></div> | ||
<!----> | ||
</label> | ||
</div> | ||
<!---->" | ||
`; |
15 changes: 15 additions & 0 deletions
15
packages/components/tree-select/__tests__/treeSelect.spec.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { MountingOptions, mount } from '@vue/test-utils' | ||
|
||
import { renderWork } from '@tests' | ||
|
||
import TreeSelect from '../src/TreeSelect' | ||
import { TreeSelectProps } from '../src/types' | ||
|
||
describe('TreeSelect', () => { | ||
const TreeSelectMount = (options?: MountingOptions<Partial<TreeSelectProps>>) => | ||
mount(TreeSelect, { ...(options as MountingOptions<TreeSelectProps>) }) | ||
|
||
renderWork<TreeSelectProps>(TreeSelect, { | ||
props: {}, | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: | ||
zh: 异步加载 | ||
en: Asynchronously load | ||
order: 7 | ||
--- | ||
|
||
## zh | ||
|
||
点击展开节点,动态加载数据。 | ||
|
||
## en | ||
|
||
To load data asynchronously when click to expand a treeNode. |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<template> | ||
<IxTreeSelect placeholder="异步加载" :dataSource="treeData" :loadChildren="loadChildren" :onLoaded="onLoaded" /> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { VKey } from '@idux/cdk/utils' | ||
import type { TreeSelectNode } from '@idux/components/tree-select' | ||
const treeData: TreeSelectNode[] = [ | ||
{ | ||
label: 'Parent 0', | ||
key: '0', | ||
}, | ||
{ | ||
label: 'Parent 1', | ||
key: '1', | ||
}, | ||
{ | ||
label: 'Tree Node ', | ||
key: '2', | ||
isLeaf: true, | ||
}, | ||
] | ||
const loadChildren = (node: TreeSelectNode) => { | ||
return new Promise<TreeSelectNode[]>(resolve => { | ||
setTimeout(() => { | ||
const parentKey = node.key as string | ||
const children = [ | ||
{ | ||
label: `Child ${parentKey}-0 `, | ||
key: `${parentKey}-0`, | ||
}, | ||
{ | ||
label: `Child ${parentKey}-1 `, | ||
key: `${parentKey}-1`, | ||
}, | ||
] | ||
resolve(children) | ||
}, 1000) | ||
}) | ||
} | ||
const onLoaded = (loadedKeys: VKey[], node: TreeSelectNode) => { | ||
console.log('onLoaded', loadedKeys, node) | ||
} | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: | ||
zh: 基本使用 | ||
en: Basic usage | ||
order: 0 | ||
--- | ||
|
||
## zh | ||
|
||
最简单的用法。 | ||
|
||
## en | ||
|
||
The simplest usage. |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<template> | ||
<IxTreeSelect | ||
v-model:value="value" | ||
v-model:expandedKeys="expandedKeys" | ||
placeholder="单选" | ||
checkable | ||
:dataSource="treeData" | ||
:onExpand="onExpand" | ||
:onSelect="onSelect" | ||
/> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { TreeSelectNode } from '@idux/components/tree-select' | ||
import { ref } from 'vue' | ||
const treeData = [ | ||
{ | ||
label: 'Node 0', | ||
key: '0', | ||
children: [ | ||
{ | ||
label: 'Node 0-0', | ||
key: '0-0', | ||
children: [ | ||
{ | ||
label: 'Node 0-0-0', | ||
key: '0-0-0', | ||
}, | ||
{ | ||
label: 'Node 0-0-1', | ||
key: '0-0-1', | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'Node 0-1', | ||
key: '0-1', | ||
children: [ | ||
{ label: 'Node 0-1-0', key: '0-1-0' }, | ||
{ label: 'Node 0-1-1', key: '0-1-1' }, | ||
], | ||
}, | ||
], | ||
}, | ||
] | ||
const value = ref('0-0') | ||
const expandedKeys = ref(['0']) | ||
const onExpand = (expanded: boolean, node: TreeSelectNode) => console.log('expanded', expanded, node) | ||
const onSelect = (selected: boolean, node: TreeSelectNode) => console.log('select', selected, node) | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: | ||
zh: 级联 | ||
en: Cascade | ||
order: 3 | ||
--- | ||
|
||
## zh | ||
|
||
仅当`multiple`和`checkable`同时为`true`时才生效 | ||
## en | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<IxTreeSelect | ||
v-model:value="value" | ||
placeholder="级联" | ||
cascade | ||
checkable | ||
multiple | ||
defaultExpandAll | ||
:dataSource="treeData" | ||
/> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
const treeData = [ | ||
{ | ||
label: 'Node 0', | ||
key: '0', | ||
children: [ | ||
{ | ||
label: 'Node 0-0', | ||
key: '0-0', | ||
children: [ | ||
{ | ||
label: 'Node 0-0-0', | ||
key: '0-0-0', | ||
}, | ||
{ | ||
label: 'Node 0-0-1', | ||
key: '0-0-1', | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'Node 0-1', | ||
key: '0-1', | ||
children: [ | ||
{ label: 'Node 0-1-0', key: '0-1-0' }, | ||
{ label: 'Node 0-1-1', key: '0-1-1' }, | ||
], | ||
}, | ||
], | ||
}, | ||
] | ||
const value = ref(['0-0']) | ||
</script> |
Oops, something went wrong.