Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: remove support for vue2 #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
ChuChencheng merged 13 commits into dev from refactor/vue3
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
87b8e5e
refactor: vue3
ChuChencheng Jun 10, 2024
8f6b7ab
test: use vitest
ChuChencheng Jun 12, 2024
56fe90f
fix: maximun call stack size exceeded when load over a certain number...
ChuChencheng Jun 15, 2024
c279a6c
feat: optimize setExpand and extract event target
ChuChencheng Jun 17, 2024
0ac3cd7
feat: support showLine #89
ChuChencheng Jun 19, 2024
f7983d9
feat: rename ctree to vtree
ChuChencheng Jun 20, 2024
990694c
feat: support expand animation
ChuChencheng Jun 23, 2024
bf9c886
chore: update vue and lock file
ChuChencheng Jun 23, 2024
bb49b32
feat: support node slot
ChuChencheng Jun 23, 2024
53c0791
feat: update new props and slots doc
ChuChencheng Jun 23, 2024
0d78200
doc: update docs
ChuChencheng Jun 23, 2024
0c8eb32
doc: update README
ChuChencheng Jun 23, 2024
4cc8a91
feat: add v-on to expand animation tree nodes
ChuChencheng Jun 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: rename ctree to vtree
  • Loading branch information
ChuChencheng committed Jun 23, 2024
commit f7983d94ecc9ef903cd16145c30bb1ff21158c9e
12 changes: 6 additions & 6 deletions examples/Mobile.vue
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,22 @@ function onResetBtnClick() {

<style lang="less" scoped>

:deep(.ctree-tree-node_selected) {
:deep(.vtree-tree-node_selected) {
background-color: #eef5ff;
border-radius: 4px;
.ctree-tree-node__title {
.vtree-tree-node__title {
background: none;
}
}
:deep(.ctree-tree-node__wrapper.ctree-tree-node__wrapper_is-leaf.ctree-tree-node_checked) {
:deep(.vtree-tree-node__wrapper.vtree-tree-node__wrapper_is-leaf.vtree-tree-node_checked) {
background-color: #eef5ff;
border-radius: 4px;
}
:deep(.ctree-tree-node__checkbox_wrapper) {
:deep(.vtree-tree-node__checkbox_wrapper) {
display: none;
}
:deep(.ctree-tree-node__wrapper_is-leaf) {
.ctree-tree-node__checkbox_wrapper {
:deep(.vtree-tree-node__wrapper_is-leaf) {
.vtree-tree-node__checkbox_wrapper {
display: flex;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/LoadingIcon.vue
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<svg viewBox="0 0 50 50">
<circle
class="ctree-loading-icon__circle"
class="vtree-loading-icon__circle"
cx="25"
cy="25"
r="20"
Expand Down
6 changes: 3 additions & 3 deletions src/components/Tree.vue
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- 可见节点区域,包括上下两片空白加渲染的节点 -->
<div :class="blockAreaCls">
<div :style="{ height: `${topSpaceHeight}px` }"></div>
<CTreeNode
<VTreeNode
v-for="node in renderNodes"
v-bind="treeNodeProps"
:key="node[keyField]"
Expand Down Expand Up @@ -211,7 +211,7 @@ import {
toRefs,
} from 'vue'
import TreeStore, { TreeNode } from '../store'
import CTreeNode from './TreeNode.vue'
import VTreeNode from './TreeNode.vue'
import LoadingIcon from './LoadingIcon.vue'
import {
ignoreEnum,
Expand Down Expand Up @@ -638,7 +638,7 @@ defineExpose({
})

defineOptions({
name: 'CTree',
name: 'VTree',
inheritAttrs: false,
})
</script>
16 changes: 8 additions & 8 deletions src/components/TreeDrop.vue
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</div>

<!-- 下拉框 -->
<transition name="ctree-dropdown">
<transition name="vtree-dropdown">
<div
ref="dropdownRef"
v-show="dropdownVisible"
Expand All @@ -29,7 +29,7 @@
height: `${dropHeight}px`
}"
>
<CTreeSearch
<VTreeSearch
ref="treeSearchRef"
v-bind="props"
v-model="treeSearchValue"
Expand All @@ -41,7 +41,7 @@
<template v-for="(_, slot) in $slots" v-slot:[slot]="scope">
<slot :name="slot" v-bind="scope"></slot>
</template>
</CTreeSearch>
</VTreeSearch>
</div>
</transition>
</div>
Expand Down Expand Up @@ -97,12 +97,12 @@ import {
watch,
nextTick,
} from 'vue'
import CTreeSearch, { DEFAULT_TREE_SEARCH_PROPS, TreeSearchProps } from './TreeSearch.vue'
import VTreeSearch, { DEFAULT_TREE_SEARCH_PROPS, TreeSearchProps } from './TreeSearch.vue'
import { TreeNode } from '../store'
import { TREE_SEARCH_API_METHODS, placementEnum } from '../constants'
import { TREE_DROP_EVENTS, TREE_SEARCH_EVENTS } from '../constants/events'
import { TreeNodeKeyType, TreeDropSlotProps, PlacementType } from '../types'
import { getCtreeMethods } from '../utils'
import { getVTreeMethods } from '../utils'
import { useTreeDropCls } from '../hooks/useTreeDropCls'

const props = withDefaults(defineProps<TreeDropProps>(), DEFAULT_TREE_DROP_PROPS)
Expand Down Expand Up @@ -143,7 +143,7 @@ const {

const referenceRef = ref()
const dropdownRef = ref()
const treeSearchRef = ref<InstanceType<typeof CTreeSearch> | null>(null)
const treeSearchRef = ref<InstanceType<typeof VTreeSearch> | null>(null)
const slotProps = reactive<TreeDropSlotProps>({
/** 多选选中的节点 */
checkedNodes: [] as TreeNode[],
Expand Down Expand Up @@ -391,11 +391,11 @@ watch(
//#endregion

defineExpose({
...getCtreeMethods(TREE_SEARCH_API_METHODS, treeSearchRef),
...getVTreeMethods(TREE_SEARCH_API_METHODS, treeSearchRef),
})

defineOptions({
name: 'CTreeDrop',
name: 'VTreeDrop',
inheritAttrs: false,
})
</script>
2 changes: 1 addition & 1 deletion src/components/TreeNode.vue
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,6 @@ function handleDrop(e: DragEvent): void {
}

defineOptions({
name: 'CTreeNode',
name: 'VTreeNode',
})
</script>
14 changes: 7 additions & 7 deletions src/components/TreeSearch.vue
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<!-- 树区域 -->
<div :class="treeWrapperCls">
<CTree
<VTree
ref="treeRef"
v-bind="props"
v-model="treeModelValue"
Expand All @@ -42,7 +42,7 @@
<template v-for="(_, slot) in $slots" :name="slot" v-slot="scope">
<slot :name="slot" v-bind="scope"></slot>
</template>
</CTree>
</VTree>
</div>

<!-- 底部信息 -->
Expand Down Expand Up @@ -108,10 +108,10 @@ import {
computed,
onMounted,
} from 'vue'
import CTree, { DEFAULT_TREE_PROPS, TreeProps } from './Tree.vue'
import VTree, { DEFAULT_TREE_PROPS, TreeProps } from './Tree.vue'
import { useTreeSearchCls } from '../hooks/useTreeSearchCls'
import { TreeNode } from '..'
import { getCtreeMethods } from '../utils'
import { getVTreeMethods } from '../utils'
import { TREE_API_METHODS } from '../constants'
import { TREE_EVENTS, TREE_SEARCH_EVENTS } from '../constants/events'

Expand Down Expand Up @@ -141,7 +141,7 @@ const isShowingChecked = ref(false)
const keyword = ref('')
const debounceTimer = ref<number | undefined>(undefined)
const checkedCount = ref(0)
const treeRef = ref<InstanceType<typeof CTree> | null>(null)
const treeRef = ref<InstanceType<typeof VTree> | null>(null)

const {
wrapperCls,
Expand Down Expand Up @@ -325,14 +325,14 @@ onMounted(() => {
})

defineExpose({
...getCtreeMethods(TREE_API_METHODS, treeRef),
...getVTreeMethods(TREE_API_METHODS, treeRef),
clearKeyword,
getKeyword,
search,
})

defineOptions({
name: 'CTreeSearch',
name: 'VTreeSearch',
inheritAttrs: false,
})
</script>
2 changes: 1 addition & 1 deletion src/hooks/useTreeCls.ts
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { computed } from "vue"

const prefixCls = 'ctree-tree'
const prefixCls = 'vtree-tree'

export { prefixCls as TREE_PREFIX_CLS }

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useTreeDropCls.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Ref, computed } from 'vue'
import { TREE_SEARCH_PREFIX_CLS as treeSearchPrefixCls } from './useTreeSearchCls'
import { TreeDropProps } from '../components/TreeDrop.vue'

const prefixCls = 'ctree-tree-drop'
const prefixCls = 'vtree-tree-drop'

export { prefixCls as TREE_DROP_PREFIX_CLS }

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useTreeNodeCls.ts
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Ref, computed } from "vue"
import { TreeNodeProps } from "../components/TreeNode.vue"

const prefixCls = 'ctree-tree-node'
const prefixCls = 'vtree-tree-node'

export { prefixCls as TREE_NODE_PREFIX_CLS }

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useTreeSearchCls.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Ref, computed } from 'vue'
import { TREE_NODE_PREFIX_CLS as treeNodePrefixCls } from './useTreeNodeCls'
import { TreeSearchProps } from '../components/TreeSearch.vue'

const prefixCls = 'ctree-tree-search'
const prefixCls = 'vtree-tree-search'

export { prefixCls as TREE_SEARCH_PREFIX_CLS }

Expand Down
2 changes: 1 addition & 1 deletion src/store/tree-store.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ export default class TreeStore extends TreeEventTarget {

/**
* 获取多选选中节点
* @param ignoreMode 忽略模式,可选择忽略父节点或子节点,默认值是 CTree 的 ignoreMode Prop
* @param ignoreMode 忽略模式,可选择忽略父节点或子节点,默认值是 VTree 的 ignoreMode Prop
*/
getCheckedNodes(ignoreMode = this.options.ignoreMode): TreeNode[] {
if (ignoreMode === ignoreEnum.children) {
Expand Down
8 changes: 4 additions & 4 deletions src/styles/loading-icon.less
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ctree-loading-icon-styles (@size: 30px, @color: @ctree-color-primary) {
#vtree-loading-icon-styles (@size: 30px, @color: @vtree-color-primary) {
display: inline-block;
width: @size;
height: @size;
animation: ctree-animation-spin 2s linear infinite;
animation: vtree-animation-spin 2s linear infinite;

.@{ctree-prefix}-loading-icon__circle {
.@{vtree-prefix}-loading-icon__circle {
stroke: @color;
stroke-linecap: round;
animation: ctree-animation-svg-circle-spin 1.5s ease-in-out infinite;
animation: vtree-animation-svg-circle-spin 1.5s ease-in-out infinite;
}
}
22 changes: 11 additions & 11 deletions src/styles/tree-drop.less
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ctree-tree-drop-styles () {
#vtree-tree-drop-styles () {
// prefix
@tree-drop-prefix: ~'@{ctree-prefix}-tree-drop';
@tree-search-prefix: ~'@{ctree-prefix}-tree-search';
@tree-dropdown-prefix: ~'@{ctree-prefix}-dropdown';
@tree-drop-prefix: ~'@{vtree-prefix}-tree-drop';
@tree-search-prefix: ~'@{vtree-prefix}-tree-search';
@tree-dropdown-prefix: ~'@{vtree-prefix}-dropdown';

// TreeDrop
.@{tree-drop-prefix} {
Expand Down Expand Up @@ -31,12 +31,12 @@
}

&-placeholder {
color: @ctree-color-input-placeholder;
color: @vtree-color-input-placeholder;
}

&_focus {
border-color: @ctree-color-input-border;
box-shadow: 0 0 0 2px fade(@ctree-color-primary, 20%);
border-color: @vtree-color-input-border;
box-shadow: 0 0 0 2px fade(@vtree-color-primary, 20%);
}
}

Expand All @@ -60,7 +60,7 @@
translateY(@translate);

.icon();
border: 3px solid @ctree-color-sub;
border: 3px solid @vtree-color-sub;
border-top: none;
border-left: none;
transform: rotate(45deg) @transform-rest;
Expand Down Expand Up @@ -91,7 +91,7 @@

.icon();
border-radius: 50%;
background-color: @ctree-color-sub;
background-color: @vtree-color-sub;
overflow: hidden;
transform: scale(@scale) rotate(45deg);
display: none;
Expand Down Expand Up @@ -130,7 +130,7 @@
.@{tree-search-prefix} {
// TreeSearch 搜索区域
&__search {
border-bottom: 1px solid @ctree-color-border;
border-bottom: 1px solid @vtree-color-border;
padding-bottom: 5px;
height: 38px;
}
Expand Down Expand Up @@ -158,4 +158,4 @@
}
}

#ctree-tree-drop-styles();
#vtree-tree-drop-styles();
28 changes: 14 additions & 14 deletions src/styles/tree-search.less
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ctree-tree-search-styles () {
#vtree-tree-search-styles () {
// prefix
@tree-search-prefix: ~'@{ctree-prefix}-tree-search';
@tree-search-prefix: ~'@{vtree-prefix}-tree-search';

// TreeSearch
.@{tree-search-prefix} {
Expand Down Expand Up @@ -50,39 +50,39 @@

// 搜索框
&__input {
color: @ctree-color-content;
color: @vtree-color-content;
box-sizing: border-box;
width: 100%;
height: 32px;
border: 1px solid @ctree-color-border;
border: 1px solid @vtree-color-border;
border-radius: 4px;
padding: 4px 7px;
outline: none;
transition: border 0.2s ease-in-out, box-shadow 0.2s ease-in-out;

&::placeholder {
color: @ctree-color-input-placeholder;
color: @vtree-color-input-placeholder;
}

@media(any-hover:hover) {
&:hover {
border-color: @ctree-color-input-border;
border-color: @vtree-color-input-border;
}
}

&:focus {
border-color: @ctree-color-input-border;
box-shadow: 0 0 0 2px fade(@ctree-color-primary, 20%);
border-color: @vtree-color-input-border;
box-shadow: 0 0 0 2px fade(@vtree-color-primary, 20%);
}

&_disabled {
cursor: not-allowed;
color: @ctree-color-input-disabled;
background-color: @ctree-color-input-background-disabled;
color: @vtree-color-input-disabled;
background-color: @vtree-color-input-background-disabled;

@media(any-hover:hover) {
&:hover {
border-color: @ctree-color-border;
border-color: @vtree-color-border;
}
}
}
Expand All @@ -100,12 +100,12 @@

@media(any-hover:hover) {
&:hover {
color: @ctree-color-light-primary;
color: @vtree-color-light-primary;
}
}

&_active {
color: @ctree-color-primary;
color: @vtree-color-primary;
}
}

Expand All @@ -123,4 +123,4 @@
}
}

#ctree-tree-search-styles();
#vtree-tree-search-styles();
Loading

AltStyle によって変換されたページ (->オリジナル) /