amazing-tree 1.2.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 [Maxkang]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,25 +1,28 @@
1
1
  # AmazingTree (Vue 3)
2
2
 
3
- > :warning:该组件因设计需求,是非受控组件,组件的拖拽功能会修改树形数据 `props.data`
4
- > 使用需谨慎
5
-
6
3
  一个高性能、可拖拽、可选择的虚拟滚动树组件,支持泛型类型自动推导,适合在大型数据集下渲染与交互。
7
4
 
5
+ > :warning:该组件因设计需求,是非受控组件,组件的拖拽功能会修改树形数据 `props.data`,使用需谨慎
6
+
8
7
  **特性**
9
8
 
10
- - 虚拟滚动渲染,平滑滚动与自动测量行高
9
+ - 虚拟滚动渲染,平滑滚动与自动测量行高(20w节点无压力)
11
10
  - 可选中(复选框),支持父子联动或严格模式
11
+ - 可筛选,可快速定位节点
12
12
  - 拖拽换位与嵌套,提供前置、后置、内部三种放置方式
13
- - 泛型组件:从 `data` 推导节点业务类型 `T`,事件与插槽类型随之推导
13
+ - 支持自定义内容(节点插槽和空数据占位插槽)
14
+ - 支持自定义拖拽/释放禁用逻辑
14
15
  - 轻量依赖,仅依赖 `vue`
15
16
 
16
17
  **安装**
17
18
 
18
- - 待发布到 npm 后:`npm i amazing-tree`
19
- - 当前仓库本地打包:`npm run build:lib`,产物在 `dist/`
19
+ - `npm i amazing-tree`
20
20
 
21
21
  **使用**
22
22
 
23
+ > 导入组件 `import { AmazingTree } from 'amazing-tree'`
24
+ > 导入样式:`import 'amazing-tree/style.css'`
25
+
23
26
  - 基本示例
24
27
 
25
28
  ```vue
@@ -30,6 +33,12 @@ import 'amazing-tree/style.css'
30
33
 
31
34
  type NodeItem = { uuid: string; name: string; children?: NodeItem[]; [k: string]: unknown }
32
35
  const data = ref<NodeItem[]>([])
36
+ const filterName = ref('')
37
+ const filterNodeMethod = (q: unknown, node: NodeItem) => {
38
+ const s = String(q || '')
39
+ if (!s) return true
40
+ return node.name.includes(s)
41
+ }
33
42
 
34
43
  function onDrop(drag: NodeItem, target: NodeItem, type: 'prev' | 'next' | 'inner') {
35
44
  console.log(drag, target, type)
@@ -40,80 +49,66 @@ function onDrop(drag: NodeItem, target: NodeItem, type: 'prev' | 'next' | 'inner
40
49
  <AmazingTree
41
50
  :data="data"
42
51
  :props="{ value: 'uuid', label: 'name', children: 'children' }"
52
+ :filter-node-method="filterNodeMethod"
43
53
  :show-checkbox="true"
44
54
  :check-strictly="false"
45
55
  :default-checked-keys="['id-1', 'id-2']"
46
56
  @node-drop="onDrop"
47
57
  />
58
+ <input v-model="filterName" placeholder="输入名称筛选" />
59
+ <button @click="$refs.tree?.filter(filterName)">筛选</button>
48
60
  </template>
49
61
  ```
50
62
 
51
- > 使用时请显式导入样式:`import 'amazing-tree/style.css'`
52
-
53
63
  **Props**
54
64
 
55
- - `data: T[]` 树数据源
56
- - `props?: { value: string; label: string; children: string }` 字段映射,默认 `{ value:'value', label:'label', children:'children' }`
57
- - `allowDrag?: (node: T) => boolean` 是否允许拖拽某节点
58
- - `allowDrop?: (drag: T, drop: T, type: 'prev'|'next'|'inner') => boolean` 是否允许目标位置
59
- - `height?: number | string` 容器高度,默认 `100%`
60
- - `highlightColor?: string` 选中行高亮色,默认 `#1e71ff`
61
- - `backgroundColor?: string` 背景色,默认 `#1d1d24`
62
- - `textColor?: string` 文本色,默认 `#c8d3de`
63
- - `hoverColor?: string` 悬浮色,默认 `#5d90e5`
64
- - `currentNodeKey?: Key` 当前行的 `value`
65
- - `defaultExpandedKeys?: Key[]` 默认展开的节点 `value` 列表
66
- - `defaultExpandAll?: boolean` 是否默认全部展开
67
- - `draggable?: boolean` 是否允许拖拽,默认 `false`
68
- - `emptyText?: string` 空状态文案,默认 `暂无数据`
69
- - `showCheckbox?: boolean` 是否显示复选框,默认 `false`
70
- - `checkStrictly?: boolean` 选择严格模式,父子不联动,默认 `false`
71
- - `defaultCheckedKeys?: Key[]` 默认勾选的 `value` 列表,默认 `[]`
72
- - `disabledChecked?: (node: T) => boolean` 是否禁用当前节点复选框,默认 `false`
65
+ | 属性名 | 说明 | 类型 | 默认值 | 是否可选 |
66
+ | --------------------- | --------------------------- | -------------------------------------------------------------- | ------------------------------------------------------- | -------- |
67
+ | `data` | 树数据源 | `T[]` | — | 否 |
68
+ | `props` | 字段映射 | `{ value: string; label: string; children: string }` | `{ value:'value', label:'label', children:'children' }` | 是 |
69
+ | `allowDrag` | 是否允许拖拽某节点 | `(node: T) => boolean` | — | 是 |
70
+ | `allowDrop` | 是否允许目标位置 | `(drag: T, drop: T, type: 'prev'\|'next'\|'inner') => boolean` | — | 是 |
71
+ | `height` | 容器高度 | `number \| string` | `'100%'` | 是 |
72
+ | `highlightColor` | 选中行高亮色 | `string` | `'#1e71ff'` | 是 |
73
+ | `backgroundColor` | 背景色 | `string` | `'#1d1d24'` | 是 |
74
+ | `textColor` | 文本色 | `string` | `'#c8d3de'` | 是 |
75
+ | `hoverColor` | 悬浮色 | `string` | `'#5d90e5'` | 是 |
76
+ | `currentNodeKey` | 当前行的 `value` | `Key` | — | 是 |
77
+ | `defaultExpandedKeys` | 默认展开的节点 `value` 列表 | `Key[]` | — | 是 |
78
+ | `defaultExpandAll` | 是否默认全部展开 | `boolean` | — | 是 |
79
+ | `draggable` | 是否允许拖拽 | `boolean` | `false` | 是 |
80
+ | `emptyText` | 空状态文案 | `string` | `'暂无数据'` | 是 |
81
+ | `showCheckbox` | 是否显示复选框 | `boolean` | `false` | 是 |
82
+ | `checkStrictly` | 选择严格模式,父子不联动 | `boolean` | `false` | 是 |
83
+ | `defaultCheckedKeys` | 默认勾选的 `value` 列表 | `Key[]` | `[]` | 是 |
84
+ | `disabledChecked` | 是否禁用当前节点复选框 | `(node: T) => boolean` | — | 是 |
85
+ | `filterNodeMethod` | 过滤方法(返回 false 隐藏) | `(value: unknown, node: T) => boolean` | — | 是 |
73
86
 
74
87
  **Events**
75
88
 
76
- - `node-click(node: T, ev: MouseEvent)` 点击行
77
- - `node-contextmenu(node: T, ev: MouseEvent)` 右键菜单
78
- - `node-drop(drag: T, target: T, type: 'prev'|'next'|'inner')` 拖拽放置
79
- - `current-change(node: T)` 当前行变化(配合 `currentNodeKey`)
80
- - `check-change(node: T, checked: boolean)` 勾选框点击时触发;禁用状态不触发
89
+ | 事件名 | 说明 | 回调参数 |
90
+ | ------------------ | ----------------------------------- | --------------------------------------------------------- |
91
+ | `node-click` | 点击行 | `(node: T, ev: MouseEvent)` |
92
+ | `node-contextmenu` | 右键菜单 | `(node: T, ev: MouseEvent)` |
93
+ | `node-drop` | 拖拽放置 | `(drag: T, target: T, type: 'prev' \| 'next' \| 'inner')` |
94
+ | `current-change` | 当前行变化(配合 `currentNodeKey`) | `(node: T)` |
95
+ | `check-change` | 勾选框点击时触发;禁用状态不触发 | `(node: T, checked: boolean)` |
81
96
 
82
97
  **Slots**
83
98
 
84
- - `default`:`{ node: T; data: T; level: number; expanded: boolean; isLeaf: boolean }`
85
- - `empty`:空状态自定义
86
-
87
- **Expose API**
88
-
89
- - `getCurrentKey(): Key | null` 获取当前行 `value`
90
- - `setCurrentKey(id: Key | null): void` 设置当前行并滚动可见
91
- - `scrollTo(id: Key | null): void` 滚动到指定行(自动展开祖先)
92
- - `getCheckedKeys(): Key[]` 获取当前勾选集合
93
- - `setCheckedKeys(keys: Key[]): void` 批量设置勾选(应用联动/严格逻辑)
94
- - `setChecked(id: Key, checked: boolean): void` 设置单个节点勾选状态
95
-
96
- **类型与泛型**
97
-
98
- - 组件声明为泛型:`generic="T extends Record<string, unknown>"`
99
- - `T` 会从 `data: T[]` 自动推导,事件与插槽参数均按 `T` 类型约束
100
- - 在模板中若需要强类型事件回调,可在脚本中声明具体 `T`(例如 `NodeItem`)并书写对应函数签名
101
-
102
- **样式**
103
-
104
- - 复选框遵循暗色主题风格,支持禁用态 `cursor:not-allowed`,可通过 CSS 变量定制:
105
- - `--vtree-primary` 主色(默认 `#409eff`)
106
- - `--vtree-checkbox-*` 系列变量控制背景、边框、禁用与勾选颜色
107
-
108
- **构建与发布**
109
-
110
- - 开发:`npm run dev`
111
- - 类型检查:`npm run type-check`
112
- - 构建应用:`npm run build`
113
- - 构建库:`npm run build:lib`(生成 `dist/amazing-tree.es.js`、`amazing-tree.cjs.js`、`amazing-tree.umd.js`)
114
- - 发布到 npm:在确认 `package.json` 中 `name`、`version`、`files`、`exports` 配置正确后执行 `npm publish`
115
-
116
- **注意事项**
117
-
118
- - 库构建将 `vue` 作为外部依赖,使用方需自行安装 `vue@^3.5`
119
- - 若需要声明文件(`.d.ts`),可引入 `vite-plugin-dts` 或单独生成并随包发布
99
+ | 插槽名 | 插槽参数 |
100
+ | --------- | ------------------------------------------------------------------------- |
101
+ | `default` | `{ node: T; data: T; level: number; expanded: boolean; isLeaf: boolean }` |
102
+ | `empty` | —(空状态自定义) |
103
+
104
+ **Exposes**
105
+
106
+ | 方法名 | 说明 | 返回类型 |
107
+ | ---------------- | --------------------------------- | ------------------------------------- |
108
+ | `getCurrentKey` | 获取当前行 `value` | `Key \| null` |
109
+ | `setCurrentKey` | 设置当前行并滚动可见 | `(id: Key \| null) => void` |
110
+ | `scrollTo` | 滚动到指定行(自动展开祖先) | `(id: Key \| null) => void` |
111
+ | `getCheckedKeys` | 获取当前勾选集合 | `Key[]` |
112
+ | `setCheckedKeys` | 批量设置勾选(应用联动/严格逻辑) | `(keys: Key[]) => void` |
113
+ | `setChecked` | 设置单个节点勾选状态 | `(id: Key, checked: boolean) => void` |
114
+ | `filter` | 触发过滤,参数作为回调第 1 个参数 | `(value: unknown) => void` |
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),Me=["onMousedown","onClick","onContextmenu"],Ae=["onClick"],Ke=["checked","indeterminate","disabled","onClick"],Ie={class:"amazing-tree-label"},Le={key:1,class:"amazing-tree-empty"},Ne={class:"amazing-tree-empty-inner"},H=28,Re=t.defineComponent({__name:"AmazingTree",props:{data:{},props:{default:()=>({value:"value",label:"label",children:"children"})},allowDrag:{},allowDrop:{},height:{default:void 0},highlightColor:{default:"#1e71ff"},backgroundColor:{default:"#1d1d24"},textColor:{default:"#c8d3de"},hoverColor:{default:"#5d90e5"},currentNodeKey:{},defaultExpandedKeys:{},defaultExpandAll:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},emptyText:{default:"暂无数据"},showCheckbox:{type:Boolean,default:!1},checkStrictly:{type:Boolean,default:!1},defaultCheckedKeys:{default:()=>[]},disabledChecked:{}},emits:["node-click","node-contextmenu","node-drop","current-change","check-change"],setup(m,{expose:j,emit:Y}){const a=m,M=Y,de=t.computed(()=>a.props.value||"value"),ve=t.computed(()=>a.props.label||"label"),_=t.computed(()=>a.props.children||"children"),fe=t.computed(()=>Array.isArray(a.data)?a.data.length===0:!0),y=t.ref(new Set),h=t.ref(new Set),p=t.ref(new Set);function ee(e){return y.value.has(e)}function he(e){y.value.has(e)?y.value.delete(e):y.value.add(e),i.value=C(a.data||[]),t.nextTick(()=>{B(),k()})}function w(e){return e[de.value]}function z(e){const n=e[_.value];return Array.isArray(n)?n:[]}function me(e){return h.value.has(e)}function pe(e){return p.value.has(e)}function G(e,n){if(n?h.value.add(e):h.value.delete(e),p.value.delete(e),!a.checkStrictly){const l=Z(e,a.data||[]);if(l){const o=[l];for(;o.length;){const r=o.pop(),c=w(r);n?h.value.add(c):h.value.delete(c),p.value.delete(c);const f=z(r);for(const s of f)o.push(s)}const u=q(e,a.data||[])||[];for(const r of u){const c=w(r),f=z(r);let s=!0,d=!1;for(const x of f){const $=w(x),re=h.value.has($),ie=p.value.has($);(re||ie)&&(d=!0),(!re||ie)&&(s=!1)}f.length===0?(h.value.has(c),p.value.delete(c)):s?(h.value.add(c),p.value.delete(c)):d?(h.value.delete(c),p.value.add(c)):(h.value.delete(c),p.value.delete(c))}}}}function te(e){h.value=new Set,p.value=new Set;for(const n of e||[])G(n,!0)}function ge(e,n){const l=n.target;a.disabledChecked&&a.disabledChecked(e.node)||(M("check-change",e.node,!!l.checked),G(e.id,!!l.checked))}function C(e){const n=[];function l(o,u,r){for(let c=0;c<o.length;c++){const f=o[c],s=w(f),d=z(f),x=d.length===0;n.push({id:s,node:f,parent:u,level:r,index:c,isLeaf:x}),!x&&y.value.has(s)&&l(d,f,r+1)}}return l(e,null,0),n}const v=t.ref(null),E=t.ref(0),R=t.ref(0),i=t.ref([]),A=t.reactive(new Map),g=t.computed(()=>{let e=0;const n=[];for(const l of i.value){const o=A.get(l.id)||H;e+=o,n.push(e)}return n}),ne=t.computed(()=>{const e=g.value;return e.length?e[e.length-1]:0});function le(e){let n=0,l=g.value.length-1,o=0;for(;n<=l;){const u=n+l>>1;g.value[u]!==void 0&&g.value[u]>=e?(o=u,l=u-1):n=u+1}return o}const K=t.ref(0),b=t.ref(0),I=t.ref(0),J=t.ref(0);function k(){if(R.value=v.value?.clientHeight||0,g.value.length===0||i.value.length===0){K.value=0,b.value=0,I.value=0,J.value=0;return}const e=le(E.value);K.value=Math.max(0,e-3);const n=i.value[K.value],l=n?A.get(n.id)||H:0,u=(g.value[K.value]??0)-l;I.value=Math.max(0,u);let r=K.value;const c=E.value+R.value+3*H;for(;r<i.value.length&&(g.value[r]??0)<c;)r++;b.value=Math.min(i.value.length,r+1);const s=(g.value[b.value-1]??0)-I.value;if(s<R.value&&b.value<i.value.length){let d=b.value,x=s;for(;x<R.value&&d<i.value.length;)d++,x=(g.value[d-1]??0)-I.value;b.value=d}J.value=Math.max(0,ne.value-I.value-((g.value[b.value-1]??0)-I.value))}t.watch([E,()=>a.data,y],()=>{i.value=C(a.data||[]),t.nextTick(B),k()}),t.onMounted(()=>{i.value=C(a.data||[]),t.nextTick(B),k(),a.defaultCheckedKeys&&a.defaultCheckedKeys.length&&te(a.defaultCheckedKeys),v.value&&(V=new ResizeObserver(()=>{R.value=v.value?.clientHeight||0,k()}),V.observe(v.value))});let V=null;t.onUnmounted(()=>{V&&(V.disconnect(),V=null)});const O=t.reactive(new Map);function ke(e,n){n?O.set(e,n):O.delete(e)}function B(){let e=!1;for(const n of i.value.slice(K.value,b.value)){const l=O.get(n.id);if(l){const o=l.offsetHeight;(!A.has(n.id)||A.get(n.id)!==o)&&(A.set(n.id,o),e=!0)}}e&&k()}function xe(){E.value=v.value?.scrollTop||0,k()}const S=t.ref(!1),Q=t.ref(null),D=t.ref(null),T=t.ref(null),X=t.ref(0),L=t.ref(null),F=t.ref(0);let N=null;function P(){N!=null&&(cancelAnimationFrame(N),N=null)}function ae(){if(!S.value||F.value===0){P();return}const e=v.value;if(!e){P();return}const n=e.scrollHeight-e.clientHeight,l=12;e.scrollTop=Math.max(0,Math.min(n,e.scrollTop+F.value*l)),E.value=e.scrollTop,k(),N=requestAnimationFrame(ae)}function ye(){F.value!==0&&N==null&&(N=requestAnimationFrame(ae)),F.value===0&&P()}function W(e){if(e==null)return null;for(const n of i.value)if(n.id===e)return n;return null}function we(e){const n=v.value.getBoundingClientRect(),l=e-n.top+E.value;return le(l)}function Ce(e,n){!a.draggable||n.button!==0||!(!a.allowDrag||a.allowDrag(e.node))||(S.value=!0,Q.value=e.id,X.value=n.clientY,n.preventDefault(),window.addEventListener("mousemove",oe),window.addEventListener("mouseup",ce))}function oe(e){if(!S.value)return;X.value=e.clientY;const n=we(e.clientY),l=i.value[Math.min(Math.max(n,0),i.value.length-1)];if(D.value=l?.id??null,!l){T.value=null;return}const o=g.value[n]??0,u=A.get(l.id)??H,r=o-u,c=v.value.getBoundingClientRect(),s=(e.clientY-c.top+E.value-r)/u;let d="inner";s<.25?d="prev":s>.75&&(d="next");const x=W(Q.value),$=a.allowDrop?!!(x&&a.allowDrop(x.node,l.node,d)):!0;T.value=$?d:null,F.value=e.clientY>c.bottom?1:e.clientY<c.top?-1:0,ye()}function q(e,n,l=[]){for(const o of n){if(w(o)===e)return l;const u=z(o);if(u.length){const r=q(e,u,[...l,o]);if(r)return r}}return null}function Z(e,n){if(e==null)return null;for(const l of n){if(w(l)===e)return l;const o=z(l),u=Z(e,o);if(u)return u}return null}function U(e){const n=[];for(const l of e){n.push(w(l));const o=z(l);o.length&&n.push(...U(o))}return n}function be(e){const n=e.parent;if(n)z(n).splice(e.index,1);else{const l=a.data.findIndex(o=>w(o)===e.id);l>=0&&a.data.splice(l,1)}}function Se(e,n,l){if(l==="inner"){Array.isArray(n.node[_.value])||(n.node[_.value]=[]),n.node[_.value].push(e),y.value.add(n.id);return}const o=n.parent;if(o){const u=z(o),r=n.index+(l==="next"?1:0);u.splice(r,0,e)}else{const u=n.index+(l==="next"?1:0);a.data.splice(u,0,e)}}function ce(){if(window.removeEventListener("mousemove",oe),window.removeEventListener("mouseup",ce),P(),!S.value)return;const e=W(Q.value),n=W(D.value),l=T.value;if(S.value=!1,T.value=null,D.value=null,!e||!n||!l||a.allowDrop&&!a.allowDrop(e.node,n.node,l)||e.id===n.id)return;const o=l==="inner"?n.node:n.parent||null;if(o){const f=q(w(o),a.data||[])||[];for(const s of f)if(w(s)===e.id)return}const u=e.node;be(e);const r=C(a.data||[]);i.value=r;const c=W(n.id)||n;Se(u,c,l),i.value=C(a.data||[]),t.nextTick(()=>{B(),k()}),M("node-drop",u,c.node,l)}function Te(e,n){L.value=e.id,M("node-click",e.node,n)}function ze(e,n){M("node-contextmenu",e.node,n)}t.watchEffect(()=>{t.nextTick(B)}),t.watch(()=>a.currentNodeKey,e=>{L.value=e??null},{immediate:!0}),t.watch(()=>a.defaultExpandedKeys,e=>{y.value=new Set(e||[]),i.value=C(a.data||[]),t.nextTick(()=>{B(),k()})},{immediate:!0}),t.watch(()=>a.defaultExpandAll,e=>{e&&(y.value=new Set(U(a.data||[])),i.value=C(a.data||[]),t.nextTick(()=>{B(),k()}))},{immediate:!0}),t.watch(()=>a.data,()=>{a.defaultExpandAll&&(y.value=new Set(U(a.data||[])),i.value=C(a.data||[]),t.nextTick(()=>{B(),k()}));const e=new Set(U(a.data||[]));h.value=new Set([...h.value].filter(n=>e.has(n))),p.value=new Set([...p.value].filter(n=>e.has(n)))});function Ee(e){const n=q(e,a.data||[])||[];for(const l of n)y.value.add(w(l));i.value=C(a.data||[])}function ue(e){e!=null&&(Ee(e),t.nextTick(()=>{const n=i.value.findIndex(c=>c.id===e);if(n<0||!v.value)return;const l=A.get(e)||H,o=(g.value[n]??0)-l,u=v.value.clientHeight,r=Math.max(0,o-Math.max(0,(u-l)/2));v.value.scrollTop=r,E.value=r,k(),t.nextTick(()=>{const c=O.get(e);if(!c||!v.value)return;const f=c.offsetLeft,s=c.offsetWidth,d=v.value.clientWidth,x=Math.max(0,f+Math.max(0,s/2)-Math.max(0,d/2));v.value.scrollLeft=x})}))}function Be(e){L.value=e??null,ue(L.value)}return j({getCurrentKey:()=>L.value,setCurrentKey:Be,scrollTo:ue,getCheckedKeys:()=>Array.from(h.value),setCheckedKeys:te,setChecked:(e,n)=>G(e,n)}),t.watch(L,e=>{const n=Z(e,a.data||[]);n&&M("current-change",n)}),(e,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"containerRef",ref:v,class:t.normalizeClass(["amazing-tree",{"is-dragging":S.value}]),style:t.normalizeStyle({height:typeof m.height=="number"?m.height+"px":m.height||"100%","--vtree-bg":m.backgroundColor,"--vtree-text":m.textColor,"--vtree-hover":m.hoverColor}),onScroll:xe},[fe.value?(t.openBlock(),t.createElementBlock("div",Le,[t.renderSlot(e.$slots,"empty",{},()=>[t.createElementVNode("div",Ne,t.toDisplayString(m.emptyText),1)],!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("div",{style:t.normalizeStyle({height:ne.value+"px",position:"relative",minWidth:"100%",width:"max-content"})},[t.createElementVNode("div",{style:t.normalizeStyle({height:I.value+"px"})},null,4),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.value.slice(K.value,b.value),l=>(t.openBlock(),t.createElementBlock("div",{key:l.id,class:"amazing-tree-row-wrapper"},[t.createElementVNode("div",{class:t.normalizeClass(["amazing-tree-row",{"is-target-inner":S.value&&D.value===l.id&&T.value==="inner","is-active":L.value===l.id}]),style:t.normalizeStyle({paddingLeft:l.level*16+"px","--active-color":m.highlightColor}),onMousedown:o=>Ce(l,o),onClick:o=>Te(l,o),onContextmenu:t.withModifiers(o=>ze(l,o),["prevent"]),ref_for:!0,ref:o=>ke(l.id,o)},[t.createElementVNode("span",{class:t.normalizeClass(["amazing-tree-caret-box",{"is-leaf":l.isLeaf}]),onClick:t.withModifiers(o=>!l.isLeaf&&he(l.id),["stop"])},[l.isLeaf?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["amazing-tree-caret",{expanded:ee(l.id)}])},null,2))],10,Ae),m.showCheckbox?(t.openBlock(),t.createElementBlock("input",{key:0,class:"amazing-tree-checkbox",type:"checkbox",checked:me(l.id),indeterminate:pe(l.id),disabled:a.disabledChecked?a.disabledChecked(l.node):!1,onClick:t.withModifiers(o=>ge(l,o),["stop"])},null,8,Ke)):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"default",{node:l.node,data:l.node,level:l.level,expanded:ee(l.id),isLeaf:l.isLeaf},()=>[t.createElementVNode("span",Ie,t.toDisplayString(l.node[ve.value]),1)],!0)],46,Me),S.value&&D.value===l.id&&(T.value==="prev"||T.value==="next")?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["amazing-tree-drop-line",{"is-prev":T.value==="prev","is-next":T.value==="next"}])},null,2)):t.createCommentVNode("",!0)]))),128)),t.createElementVNode("div",{style:t.normalizeStyle({height:J.value+"px"})},null,4)],4),S.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"amazing-tree-ghost",style:t.normalizeStyle({top:X.value+"px"})},null,4)):t.createCommentVNode("",!0)],64))],38))}}),Ve=(m,j)=>{const Y=m.__vccOpts||m;for(const[a,M]of j)Y[a]=M;return Y},se=Ve(Re,[["__scopeId","data-v-f93b9531"]]);exports.AmazingTree=se;exports.default=se;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),Ae=["onMousedown","onClick","onContextmenu"],Ke=["onClick"],Ne=["checked","indeterminate","disabled","onClick"],Ie={class:"amazing-tree-label"},Le={key:1,class:"amazing-tree-empty"},Re={class:"amazing-tree-empty-inner"},_=28,Ve=t.defineComponent({__name:"AmazingTree",props:{data:{},props:{default:()=>({value:"value",label:"label",children:"children"})},allowDrag:{},allowDrop:{},height:{default:void 0},highlightColor:{default:"#1e71ff"},backgroundColor:{default:"#1d1d24"},textColor:{default:"#c8d3de"},hoverColor:{default:"#5d90e5"},currentNodeKey:{},defaultExpandedKeys:{},defaultExpandAll:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},emptyText:{default:"暂无数据"},showCheckbox:{type:Boolean,default:!1},checkStrictly:{type:Boolean,default:!1},defaultCheckedKeys:{default:()=>[]},disabledChecked:{},filterNodeMethod:{}},emits:["node-click","node-contextmenu","node-drop","current-change","check-change"],setup(p,{expose:j,emit:O}){const a=p,B=O,fe=t.computed(()=>a.props.value||"value"),ve=t.computed(()=>a.props.label||"label"),P=t.computed(()=>a.props.children||"children"),he=t.computed(()=>Array.isArray(a.data)?a.data.length===0:!0),k=t.ref(new Set),m=t.ref(new Set),x=t.ref(new Set),Q=t.ref(null);function te(e){return k.value.has(e)}function me(e){k.value.has(e)?k.value.delete(e):k.value.add(e),i.value=C(a.data||[]),t.nextTick(()=>{T(),g()})}function y(e){return e[fe.value]}function b(e){const l=e[P.value];return Array.isArray(l)?l:[]}function pe(e){return m.value.has(e)}function ge(e){return x.value.has(e)}function G(e,l){if(l?m.value.add(e):m.value.delete(e),x.value.delete(e),!a.checkStrictly){const n=ee(e,a.data||[]);if(n){const o=[n];for(;o.length;){const r=o.pop(),c=y(r);l?m.value.add(c):m.value.delete(c),x.value.delete(c);const f=b(r);for(const d of f)o.push(d)}const u=$(e,a.data||[])||[];for(const r of u){const c=y(r),f=b(r);let d=!0,s=!1;for(const h of f){const R=y(h),ie=m.value.has(R),se=x.value.has(R);(ie||se)&&(s=!0),(!ie||se)&&(d=!1)}f.length===0?(m.value.has(c),x.value.delete(c)):d?(m.value.add(c),x.value.delete(c)):s?(m.value.delete(c),x.value.add(c)):(m.value.delete(c),x.value.delete(c))}}}}function le(e){m.value=new Set,x.value=new Set;for(const l of e||[])G(l,!0)}function ke(e,l){const n=l.target;a.disabledChecked&&a.disabledChecked(e.node)||(B("check-change",e.node,!!n.checked),G(e.id,!!n.checked))}function C(e){const l=[];function n(o,u,r){for(let c=0;c<o.length;c++){const f=o[c],d=y(f),s=b(f),h=s.length===0;l.push({id:d,node:f,parent:u,level:r,index:c,isLeaf:h}),!h&&k.value.has(d)&&n(s,f,r+1)}}if(n(e,null,0),a.filterNodeMethod&&Q.value!=null){let o=function(c){const f=y(c),d=b(c);let s=!1;for(const R of d)s=o(R)||s;const h=!!a.filterNodeMethod(Q.value,c);return h&&u.add(f),s&&r.add(f),h||s};const u=new Set,r=new Set;for(const c of e)o(c);return l.filter(c=>u.has(c.id)||r.has(c.id))}return l}const v=t.ref(null),M=t.ref(0),V=t.ref(0),i=t.ref([]),A=t.reactive(new Map),w=t.computed(()=>{let e=0;const l=[];for(const n of i.value){const o=A.get(n.id)||_;e+=o,l.push(e)}return l}),ne=t.computed(()=>{const e=w.value;return e.length?e[e.length-1]:0});function ae(e){let l=0,n=w.value.length-1,o=0;for(;l<=n;){const u=l+n>>1;w.value[u]!==void 0&&w.value[u]>=e?(o=u,n=u-1):l=u+1}return o}const K=t.ref(0),S=t.ref(0),N=t.ref(0),J=t.ref(0);function g(){if(V.value=v.value?.clientHeight||0,w.value.length===0||i.value.length===0){K.value=0,S.value=0,N.value=0,J.value=0;return}const e=ae(M.value);K.value=Math.max(0,e-3);const l=i.value[K.value],n=l?A.get(l.id)||_:0,u=(w.value[K.value]??0)-n;N.value=Math.max(0,u);let r=K.value;const c=M.value+V.value+3*_;for(;r<i.value.length&&(w.value[r]??0)<c;)r++;S.value=Math.min(i.value.length,r+1);const d=(w.value[S.value-1]??0)-N.value;if(d<V.value&&S.value<i.value.length){let s=S.value,h=d;for(;h<V.value&&s<i.value.length;)s++,h=(w.value[s-1]??0)-N.value;S.value=s}J.value=Math.max(0,ne.value-N.value-((w.value[S.value-1]??0)-N.value))}t.watch([M,()=>a.data,k],()=>{i.value=C(a.data||[]),t.nextTick(T),g()}),t.onMounted(()=>{i.value=C(a.data||[]),t.nextTick(T),g(),a.defaultCheckedKeys&&a.defaultCheckedKeys.length&&le(a.defaultCheckedKeys),v.value&&(D=new ResizeObserver(()=>{V.value=v.value?.clientHeight||0,g()}),D.observe(v.value))});let D=null;t.onUnmounted(()=>{D&&(D.disconnect(),D=null)});const W=t.reactive(new Map);function xe(e,l){l?W.set(e,l):W.delete(e)}function T(){let e=!1;for(const l of i.value.slice(K.value,S.value)){const n=W.get(l.id);if(n){const o=n.offsetHeight;(!A.has(l.id)||A.get(l.id)!==o)&&(A.set(l.id,o),e=!0)}}e&&g()}function ye(){M.value=v.value?.scrollTop||0,g()}const z=t.ref(!1),X=t.ref(null),H=t.ref(null),E=t.ref(null),Z=t.ref(0),I=t.ref(null),F=t.ref(0);let L=null;function q(){L!=null&&(cancelAnimationFrame(L),L=null)}function oe(){if(!z.value||F.value===0){q();return}const e=v.value;if(!e){q();return}const l=e.scrollHeight-e.clientHeight,n=12;e.scrollTop=Math.max(0,Math.min(l,e.scrollTop+F.value*n)),M.value=e.scrollTop,g(),L=requestAnimationFrame(oe)}function we(){F.value!==0&&L==null&&(L=requestAnimationFrame(oe)),F.value===0&&q()}function U(e){if(e==null)return null;for(const l of i.value)if(l.id===e)return l;return null}function Ce(e){const l=v.value.getBoundingClientRect(),n=e-l.top+M.value;return ae(n)}function be(e,l){!a.draggable||l.button!==0||!(!a.allowDrag||a.allowDrag(e.node))||(z.value=!0,X.value=e.id,Z.value=l.clientY,l.preventDefault(),window.addEventListener("mousemove",ce),window.addEventListener("mouseup",ue))}function ce(e){if(!z.value)return;Z.value=e.clientY;const l=Ce(e.clientY),n=i.value[Math.min(Math.max(l,0),i.value.length-1)];if(H.value=n?.id??null,!n){E.value=null;return}const o=w.value[l]??0,u=A.get(n.id)??_,r=o-u,c=v.value.getBoundingClientRect(),d=(e.clientY-c.top+M.value-r)/u;let s="inner";d<.25?s="prev":d>.75&&(s="next");const h=U(X.value),R=a.allowDrop?!!(h&&a.allowDrop(h.node,n.node,s)):!0;E.value=R?s:null,F.value=e.clientY>c.bottom?1:e.clientY<c.top?-1:0,we()}function $(e,l,n=[]){for(const o of l){if(y(o)===e)return n;const u=b(o);if(u.length){const r=$(e,u,[...n,o]);if(r)return r}}return null}function ee(e,l){if(e==null)return null;for(const n of l){if(y(n)===e)return n;const o=b(n),u=ee(e,o);if(u)return u}return null}function Y(e){const l=[];for(const n of e){l.push(y(n));const o=b(n);o.length&&l.push(...Y(o))}return l}function Se(e){const l=e.parent;if(l)b(l).splice(e.index,1);else{const n=a.data.findIndex(o=>y(o)===e.id);n>=0&&a.data.splice(n,1)}}function Te(e,l,n){if(n==="inner"){Array.isArray(l.node[P.value])||(l.node[P.value]=[]),l.node[P.value].push(e),k.value.add(l.id);return}const o=l.parent;if(o){const u=b(o),r=l.index+(n==="next"?1:0);u.splice(r,0,e)}else{const u=l.index+(n==="next"?1:0);a.data.splice(u,0,e)}}function ue(){if(window.removeEventListener("mousemove",ce),window.removeEventListener("mouseup",ue),q(),!z.value)return;const e=U(X.value),l=U(H.value),n=E.value;if(z.value=!1,E.value=null,H.value=null,!e||!l||!n||a.allowDrop&&!a.allowDrop(e.node,l.node,n)||e.id===l.id)return;const o=n==="inner"?l.node:l.parent||null;if(o){const f=$(y(o),a.data||[])||[];for(const d of f)if(y(d)===e.id)return}const u=e.node;Se(e);const r=C(a.data||[]);i.value=r;const c=U(l.id)||l;Te(u,c,n),i.value=C(a.data||[]),t.nextTick(()=>{T(),g()}),B("node-drop",u,c.node,n)}function ze(e,l){I.value=e.id,B("node-click",e.node,l)}function Ee(e,l){B("node-contextmenu",e.node,l)}t.watchEffect(()=>{t.nextTick(T)}),t.watch(()=>a.currentNodeKey,e=>{I.value=e??null},{immediate:!0}),t.watch(()=>a.defaultExpandedKeys,e=>{k.value=new Set(e||[]),i.value=C(a.data||[]),t.nextTick(()=>{T(),g()})},{immediate:!0}),t.watch(()=>a.defaultExpandAll,e=>{e&&(k.value=new Set(Y(a.data||[])),i.value=C(a.data||[]),t.nextTick(()=>{T(),g()}))},{immediate:!0}),t.watch(()=>a.data,()=>{a.defaultExpandAll&&(k.value=new Set(Y(a.data||[]))),i.value=C(a.data||[]),t.nextTick(()=>{T(),g()});const e=new Set(Y(a.data||[]));m.value=new Set([...m.value].filter(l=>e.has(l))),x.value=new Set([...x.value].filter(l=>e.has(l)))},{deep:!0});function Me(e){const l=$(e,a.data||[])||[];for(const n of l)k.value.add(y(n));i.value=C(a.data||[])}function re(e){e!=null&&(Me(e),t.nextTick(()=>{const l=i.value.findIndex(c=>c.id===e);if(l<0||!v.value)return;const n=A.get(e)||_,o=(w.value[l]??0)-n,u=v.value.clientHeight,r=Math.max(0,o-Math.max(0,(u-n)/2));v.value.scrollTop=r,M.value=r,g(),t.nextTick(()=>{const c=W.get(e);if(!c||!v.value)return;const f=c.offsetLeft,d=c.offsetWidth,s=v.value.clientWidth,h=Math.max(0,f+Math.max(0,d/2)-Math.max(0,s/2));v.value.scrollLeft=h})}))}function Be(e){I.value=e??null,re(I.value)}return j({getCurrentKey:()=>I.value,setCurrentKey:Be,scrollTo:re,getCheckedKeys:()=>Array.from(m.value),setCheckedKeys:le,setChecked:(e,l)=>G(e,l),filter:e=>{Q.value=e,k.value=new Set(Y(a.data||[])),i.value=C(a.data||[]),t.nextTick(()=>{T(),g()})}}),t.watch(I,e=>{const l=ee(e,a.data||[]);l&&B("current-change",l)}),(e,l)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"containerRef",ref:v,class:t.normalizeClass(["amazing-tree",{"is-dragging":z.value}]),style:t.normalizeStyle({height:typeof p.height=="number"?p.height+"px":p.height||"100%","--vtree-bg":p.backgroundColor,"--vtree-text":p.textColor,"--vtree-hover":p.hoverColor}),onScroll:ye},[he.value?(t.openBlock(),t.createElementBlock("div",Le,[t.renderSlot(e.$slots,"empty",{},()=>[t.createElementVNode("div",Re,t.toDisplayString(p.emptyText),1)],!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("div",{style:t.normalizeStyle({height:ne.value+"px",position:"relative",minWidth:"100%",width:"max-content"})},[t.createElementVNode("div",{style:t.normalizeStyle({height:N.value+"px"})},null,4),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.value.slice(K.value,S.value),n=>(t.openBlock(),t.createElementBlock("div",{key:n.id,class:"amazing-tree-row-wrapper"},[t.createElementVNode("div",{class:t.normalizeClass(["amazing-tree-row",{"is-target-inner":z.value&&H.value===n.id&&E.value==="inner","is-active":I.value===n.id}]),style:t.normalizeStyle({paddingLeft:n.level*16+"px","--active-color":p.highlightColor}),onMousedown:o=>be(n,o),onClick:o=>ze(n,o),onContextmenu:t.withModifiers(o=>Ee(n,o),["prevent"]),ref_for:!0,ref:o=>xe(n.id,o)},[t.createElementVNode("span",{class:t.normalizeClass(["amazing-tree-caret-box",{"is-leaf":n.isLeaf}]),onClick:t.withModifiers(o=>!n.isLeaf&&me(n.id),["stop"])},[n.isLeaf?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["amazing-tree-caret",{expanded:te(n.id)}])},null,2))],10,Ke),p.showCheckbox?(t.openBlock(),t.createElementBlock("input",{key:0,class:"amazing-tree-checkbox",type:"checkbox",checked:pe(n.id),indeterminate:ge(n.id),disabled:a.disabledChecked?a.disabledChecked(n.node):!1,onClick:t.withModifiers(o=>ke(n,o),["stop"])},null,8,Ne)):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"default",{node:n.node,data:n.node,level:n.level,expanded:te(n.id),isLeaf:n.isLeaf},()=>[t.createElementVNode("span",Ie,t.toDisplayString(n.node[ve.value]),1)],!0)],46,Ae),z.value&&H.value===n.id&&(E.value==="prev"||E.value==="next")?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["amazing-tree-drop-line",{"is-prev":E.value==="prev","is-next":E.value==="next"}])},null,2)):t.createCommentVNode("",!0)]))),128)),t.createElementVNode("div",{style:t.normalizeStyle({height:J.value+"px"})},null,4)],4),z.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"amazing-tree-ghost",style:t.normalizeStyle({top:Z.value+"px"})},null,4)):t.createCommentVNode("",!0)],64))],38))}}),De=(p,j)=>{const O=p.__vccOpts||p;for(const[a,B]of j)O[a]=B;return O},de=De(Ve,[["__scopeId","data-v-e0a4c022"]]);exports.AmazingTree=de;exports.default=de;
@@ -1 +1 @@
1
- .amazing-tree[data-v-f93b9531]{width:100%;overflow:auto;position:relative;background:var(--vtree-bg);color:var(--vtree-text);scrollbar-width:thin;scrollbar-color:rgba(144,147,153,.3) transparent;cursor:pointer;--vtree-primary: #409eff;--vtree-checkbox-bg: #1d1d24;--vtree-checkbox-border: #4c4d4f;--vtree-checkbox-hover-border: #8d8e91;--vtree-checkbox-disabled-bg: #2c2f33;--vtree-checkbox-disabled-border: #5c5f63;--vtree-checkbox-check: #ffffff;--vtree-checkbox-check-disabled: #cfd3dc}.amazing-tree.is-dragging[data-v-f93b9531],.amazing-tree.is-dragging[data-v-f93b9531] *{-webkit-user-select:none;user-select:none}.amazing-tree[data-v-f93b9531] *{cursor:pointer}.amazing-tree input[type=checkbox][data-v-f93b9531]:disabled{cursor:not-allowed}.amazing-tree .amazing-tree-checkbox[data-v-f93b9531]{-webkit-appearance:none;appearance:none;position:relative;width:14px;height:14px;border:1px solid var(--vtree-checkbox-border);background:var(--vtree-checkbox-bg);border-radius:2px;outline:none;transition:border-color .12s ease,background-color .12s ease,box-shadow .12s ease;vertical-align:middle;margin-right:6px}.amazing-tree .amazing-tree-checkbox[data-v-f93b9531]:not(:disabled):hover{border-color:var(--vtree-checkbox-hover-border)}.amazing-tree .amazing-tree-checkbox[data-v-f93b9531]:focus-visible{box-shadow:0 0 0 2px #409eff33}.amazing-tree .amazing-tree-checkbox[data-v-f93b9531]:checked{background:var(--vtree-primary);border-color:var(--vtree-primary)}.amazing-tree .amazing-tree-checkbox[data-v-f93b9531]:checked:after{content:"";position:absolute;left:3px;top:0;width:4px;height:8px;border:2px solid var(--vtree-checkbox-check);border-top:0;border-left:0;transform:rotate(45deg)}.amazing-tree .amazing-tree-checkbox[data-v-f93b9531]:indeterminate{background:var(--vtree-primary);border-color:var(--vtree-primary)}.amazing-tree .amazing-tree-checkbox[data-v-f93b9531]:indeterminate:after{content:"";position:absolute;left:2px;top:5px;width:10px;height:2px;background:var(--vtree-checkbox-check);border-radius:1px}.amazing-tree .amazing-tree-checkbox[data-v-f93b9531]:disabled{background:var(--vtree-checkbox-disabled-bg);border-color:var(--vtree-checkbox-disabled-border)}.amazing-tree .amazing-tree-checkbox[data-v-f93b9531]:disabled:checked:after{border-color:var(--vtree-checkbox-check-disabled)}.amazing-tree .amazing-tree-checkbox[data-v-f93b9531]:disabled:indeterminate:after{background:var(--vtree-checkbox-check-disabled)}.amazing-tree .amazing-tree-row-wrapper[data-v-f93b9531]{position:relative}.amazing-tree .amazing-tree-row-wrapper .amazing-tree-drop-line[data-v-f93b9531]{position:absolute;left:0;right:0;height:0;border-top:2px solid #409eff}.amazing-tree .amazing-tree-row-wrapper .amazing-tree-drop-line.is-prev[data-v-f93b9531]{top:0}.amazing-tree .amazing-tree-row-wrapper .amazing-tree-drop-line.is-next[data-v-f93b9531]{bottom:0}.amazing-tree .amazing-tree-row[data-v-f93b9531]{display:flex;align-items:center;gap:4px;box-sizing:border-box;min-height:24px;padding:0 8px;white-space:nowrap}.amazing-tree .amazing-tree-row[data-v-f93b9531]:hover{background:var(--vtree-hover)}.amazing-tree .amazing-tree-row.is-active[data-v-f93b9531],.amazing-tree .amazing-tree-row.is-active[data-v-f93b9531]:hover{background:var(--active-color)}.amazing-tree .amazing-tree-row.is-target-inner[data-v-f93b9531]{outline:2px dashed #409eff}.amazing-tree .amazing-tree-row .amazing-tree-caret-box[data-v-f93b9531]{display:inline-flex;align-items:center;justify-content:center;height:100%;aspect-ratio:1/1;min-width:16px;margin-right:4px;cursor:pointer}.amazing-tree .amazing-tree-row .amazing-tree-caret-box.is-leaf[data-v-f93b9531]{pointer-events:none}.amazing-tree .amazing-tree-row .amazing-tree-caret[data-v-f93b9531]{display:block;width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:6px solid #909399;transform:rotate(-90deg);transition:transform .1s linear}.amazing-tree .amazing-tree-row .amazing-tree-caret.expanded[data-v-f93b9531]{transform:rotate(0)}.amazing-tree .amazing-tree-row .amazing-tree-label[data-v-f93b9531]{color:inherit}.amazing-tree .amazing-tree-ghost[data-v-f93b9531]{position:fixed;left:16px;width:120px;height:24px;background:#409eff33;border:1px solid #409eff;pointer-events:none}.amazing-tree .amazing-tree-empty[data-v-f93b9531]{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.amazing-tree .amazing-tree-empty[data-v-f93b9531]>*{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.amazing-tree .amazing-tree-empty .amazing-tree-empty-inner[data-v-f93b9531]{color:var(--vtree-text)}[data-v-f93b9531] .amazing-tree::-webkit-scrollbar{width:8px;height:8px}[data-v-f93b9531] .amazing-tree::-webkit-scrollbar-track{background:transparent}[data-v-f93b9531] .amazing-tree::-webkit-scrollbar-thumb{background-color:#9093994d;border-radius:4px}[data-v-f93b9531] .amazing-tree::-webkit-scrollbar-thumb:hover{background-color:#90939980}
1
+ .amazing-tree[data-v-e0a4c022]{width:100%;overflow:auto;position:relative;background:var(--vtree-bg);color:var(--vtree-text);scrollbar-width:thin;scrollbar-color:rgba(144,147,153,.3) transparent;cursor:pointer;--vtree-primary: #409eff;--vtree-checkbox-bg: #1d1d24;--vtree-checkbox-border: #4c4d4f;--vtree-checkbox-hover-border: #8d8e91;--vtree-checkbox-disabled-bg: #2c2f33;--vtree-checkbox-disabled-border: #5c5f63;--vtree-checkbox-check: #ffffff;--vtree-checkbox-check-disabled: #cfd3dc}.amazing-tree.is-dragging[data-v-e0a4c022],.amazing-tree.is-dragging[data-v-e0a4c022] *{-webkit-user-select:none;user-select:none}.amazing-tree[data-v-e0a4c022] *{cursor:pointer}.amazing-tree input[type=checkbox][data-v-e0a4c022]:disabled{cursor:not-allowed}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]{-webkit-appearance:none;appearance:none;position:relative;width:14px;height:14px;border:1px solid var(--vtree-checkbox-border);background:var(--vtree-checkbox-bg);border-radius:2px;outline:none;transition:border-color .12s ease,background-color .12s ease,box-shadow .12s ease;vertical-align:middle;margin-right:6px}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:not(:disabled):hover{border-color:var(--vtree-checkbox-hover-border)}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:focus-visible{box-shadow:0 0 0 2px #409eff33}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:checked{background:var(--vtree-primary);border-color:var(--vtree-primary)}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:checked:after{content:"";position:absolute;left:3px;top:0;width:4px;height:8px;border:2px solid var(--vtree-checkbox-check);border-top:0;border-left:0;transform:rotate(45deg)}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:indeterminate{background:var(--vtree-primary);border-color:var(--vtree-primary)}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:indeterminate:after{content:"";position:absolute;left:2px;top:5px;width:10px;height:2px;background:var(--vtree-checkbox-check);border-radius:1px}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:disabled{background:var(--vtree-checkbox-disabled-bg);border-color:var(--vtree-checkbox-disabled-border)}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:disabled:checked:after{border-color:var(--vtree-checkbox-check-disabled)}.amazing-tree .amazing-tree-checkbox[data-v-e0a4c022]:disabled:indeterminate:after{background:var(--vtree-checkbox-check-disabled)}.amazing-tree .amazing-tree-row-wrapper[data-v-e0a4c022]{position:relative}.amazing-tree .amazing-tree-row-wrapper .amazing-tree-drop-line[data-v-e0a4c022]{position:absolute;left:0;right:0;height:0;border-top:2px solid #409eff}.amazing-tree .amazing-tree-row-wrapper .amazing-tree-drop-line.is-prev[data-v-e0a4c022]{top:0}.amazing-tree .amazing-tree-row-wrapper .amazing-tree-drop-line.is-next[data-v-e0a4c022]{bottom:0}.amazing-tree .amazing-tree-row[data-v-e0a4c022]{display:flex;align-items:center;gap:4px;box-sizing:border-box;min-height:24px;padding:0 8px;white-space:nowrap}.amazing-tree .amazing-tree-row[data-v-e0a4c022]:hover{background:var(--vtree-hover)}.amazing-tree .amazing-tree-row.is-active[data-v-e0a4c022],.amazing-tree .amazing-tree-row.is-active[data-v-e0a4c022]:hover{background:var(--active-color)}.amazing-tree .amazing-tree-row.is-target-inner[data-v-e0a4c022]{outline:2px dashed #409eff}.amazing-tree .amazing-tree-row .amazing-tree-caret-box[data-v-e0a4c022]{display:inline-flex;align-items:center;justify-content:center;height:100%;aspect-ratio:1/1;min-width:16px;margin-right:4px;cursor:pointer}.amazing-tree .amazing-tree-row .amazing-tree-caret-box.is-leaf[data-v-e0a4c022]{pointer-events:none}.amazing-tree .amazing-tree-row .amazing-tree-caret[data-v-e0a4c022]{display:block;width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:6px solid #909399;transform:rotate(-90deg);transition:transform .1s linear}.amazing-tree .amazing-tree-row .amazing-tree-caret.expanded[data-v-e0a4c022]{transform:rotate(0)}.amazing-tree .amazing-tree-row .amazing-tree-label[data-v-e0a4c022]{color:inherit}.amazing-tree .amazing-tree-ghost[data-v-e0a4c022]{position:fixed;left:16px;width:120px;height:24px;background:#409eff33;border:1px solid #409eff;pointer-events:none}.amazing-tree .amazing-tree-empty[data-v-e0a4c022]{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.amazing-tree .amazing-tree-empty[data-v-e0a4c022]>*{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.amazing-tree .amazing-tree-empty .amazing-tree-empty-inner[data-v-e0a4c022]{color:var(--vtree-text)}[data-v-e0a4c022] .amazing-tree::-webkit-scrollbar{width:8px;height:8px}[data-v-e0a4c022] .amazing-tree::-webkit-scrollbar-track{background:transparent}[data-v-e0a4c022] .amazing-tree::-webkit-scrollbar-thumb{background-color:#9093994d;border-radius:4px}[data-v-e0a4c022] .amazing-tree::-webkit-scrollbar-thumb:hover{background-color:#90939980}
@@ -1,8 +1,8 @@
1
- import { defineComponent as Oe, computed as N, ref as s, reactive as we, watch as _, nextTick as C, onMounted as Pe, onUnmounted as Ve, watchEffect as Ue, createElementBlock as z, openBlock as T, normalizeStyle as W, normalizeClass as $, Fragment as ke, createElementVNode as Y, createCommentVNode as ne, renderList as $e, withModifiers as se, renderSlot as Ce, toDisplayString as be } from "vue";
2
- const qe = ["onMousedown", "onClick", "onContextmenu"], je = ["onClick"], Ge = ["checked", "indeterminate", "disabled", "onClick"], Je = { class: "amazing-tree-label" }, Qe = {
1
+ import { defineComponent as Pe, computed as _, ref as d, reactive as ke, watch as W, nextTick as C, onMounted as Ve, onUnmounted as Ue, watchEffect as $e, createElementBlock as K, openBlock as E, normalizeStyle as O, normalizeClass as Q, Fragment as Ce, createElementVNode as Y, createCommentVNode as ne, renderList as qe, withModifiers as re, renderSlot as be, toDisplayString as Se } from "vue";
2
+ const Qe = ["onMousedown", "onClick", "onContextmenu"], je = ["onClick"], Ge = ["checked", "indeterminate", "disabled", "onClick"], Je = { class: "amazing-tree-label" }, Xe = {
3
3
  key: 1,
4
4
  class: "amazing-tree-empty"
5
- }, Xe = { class: "amazing-tree-empty-inner" }, q = 28, Ze = /* @__PURE__ */ Oe({
5
+ }, Ze = { class: "amazing-tree-empty-inner" }, j = 28, et = /* @__PURE__ */ Pe({
6
6
  __name: "AmazingTree",
7
7
  props: {
8
8
  data: {},
@@ -22,417 +22,436 @@ const qe = ["onMousedown", "onClick", "onContextmenu"], je = ["onClick"], Ge = [
22
22
  showCheckbox: { type: Boolean, default: !1 },
23
23
  checkStrictly: { type: Boolean, default: !1 },
24
24
  defaultCheckedKeys: { default: () => [] },
25
- disabledChecked: {}
25
+ disabledChecked: {},
26
+ filterNodeMethod: {}
26
27
  },
27
28
  emits: ["node-click", "node-contextmenu", "node-drop", "current-change", "check-change"],
28
- setup(g, { expose: le, emit: j }) {
29
- const l = g, L = j, Se = N(() => l.props.value || "value"), Me = N(() => l.props.label || "label"), G = N(() => l.props.children || "children"), Ae = N(() => Array.isArray(l.data) ? l.data.length === 0 : !0), w = s(/* @__PURE__ */ new Set()), h = s(/* @__PURE__ */ new Set()), p = s(/* @__PURE__ */ new Set());
30
- function re(e) {
31
- return w.value.has(e);
32
- }
33
- function ze(e) {
34
- w.value.has(e) ? w.value.delete(e) : w.value.add(e), i.value = b(l.data || []), C(() => {
35
- I(), x();
29
+ setup(g, { expose: le, emit: G }) {
30
+ const l = g, L = G, Me = _(() => l.props.value || "value"), Ae = _(() => l.props.label || "label"), J = _(() => l.props.children || "children"), ze = _(() => Array.isArray(l.data) ? l.data.length === 0 : !0), x = d(/* @__PURE__ */ new Set()), p = d(/* @__PURE__ */ new Set()), y = d(/* @__PURE__ */ new Set()), ae = d(null);
31
+ function de(e) {
32
+ return x.value.has(e);
33
+ }
34
+ function Te(e) {
35
+ x.value.has(e) ? x.value.delete(e) : x.value.add(e), i.value = b(l.data || []), C(() => {
36
+ A(), m();
36
37
  });
37
38
  }
38
- function k(e) {
39
- return e[Se.value];
39
+ function w(e) {
40
+ return e[Me.value];
40
41
  }
41
- function K(e) {
42
- const t = e[G.value];
42
+ function S(e) {
43
+ const t = e[J.value];
43
44
  return Array.isArray(t) ? t : [];
44
45
  }
45
- function Te(e) {
46
- return h.value.has(e);
47
- }
48
46
  function Ke(e) {
49
47
  return p.value.has(e);
50
48
  }
51
- function ae(e, t) {
52
- if (t ? h.value.add(e) : h.value.delete(e), p.value.delete(e), !l.checkStrictly) {
53
- const n = ie(e, l.data || []);
49
+ function Ee(e) {
50
+ return y.value.has(e);
51
+ }
52
+ function oe(e, t) {
53
+ if (t ? p.value.add(e) : p.value.delete(e), y.value.delete(e), !l.checkStrictly) {
54
+ const n = se(e, l.data || []);
54
55
  if (n) {
55
56
  const a = [n];
56
57
  for (; a.length; ) {
57
- const c = a.pop(), o = k(c);
58
- t ? h.value.add(o) : h.value.delete(o), p.value.delete(o);
59
- const f = K(c);
60
- for (const r of f) a.push(r);
58
+ const c = a.pop(), o = w(c);
59
+ t ? p.value.add(o) : p.value.delete(o), y.value.delete(o);
60
+ const v = S(c);
61
+ for (const r of v) a.push(r);
61
62
  }
62
- const u = Z(e, l.data || []) || [];
63
+ const u = te(e, l.data || []) || [];
63
64
  for (const c of u) {
64
- const o = k(c), f = K(c);
65
- let r = !0, d = !1;
66
- for (const y of f) {
67
- const te = k(y), xe = h.value.has(te), ye = p.value.has(te);
68
- (xe || ye) && (d = !0), (!xe || ye) && (r = !1);
65
+ const o = w(c), v = S(c);
66
+ let r = !0, s = !1;
67
+ for (const h of v) {
68
+ const N = w(h), ye = p.value.has(N), we = y.value.has(N);
69
+ (ye || we) && (s = !0), (!ye || we) && (r = !1);
69
70
  }
70
- f.length === 0 ? (h.value.has(o), p.value.delete(o)) : r ? (h.value.add(o), p.value.delete(o)) : d ? (h.value.delete(o), p.value.add(o)) : (h.value.delete(o), p.value.delete(o));
71
+ v.length === 0 ? (p.value.has(o), y.value.delete(o)) : r ? (p.value.add(o), y.value.delete(o)) : s ? (p.value.delete(o), y.value.add(o)) : (p.value.delete(o), y.value.delete(o));
71
72
  }
72
73
  }
73
74
  }
74
75
  }
75
- function de(e) {
76
- h.value = /* @__PURE__ */ new Set(), p.value = /* @__PURE__ */ new Set();
77
- for (const t of e || []) ae(t, !0);
76
+ function ve(e) {
77
+ p.value = /* @__PURE__ */ new Set(), y.value = /* @__PURE__ */ new Set();
78
+ for (const t of e || []) oe(t, !0);
78
79
  }
79
- function Ee(e, t) {
80
+ function Ie(e, t) {
80
81
  const n = t.target;
81
- l.disabledChecked && l.disabledChecked(e.node) || (L("check-change", e.node, !!n.checked), ae(e.id, !!n.checked));
82
+ l.disabledChecked && l.disabledChecked(e.node) || (L("check-change", e.node, !!n.checked), oe(e.id, !!n.checked));
82
83
  }
83
84
  function b(e) {
84
85
  const t = [];
85
86
  function n(a, u, c) {
86
87
  for (let o = 0; o < a.length; o++) {
87
- const f = a[o], r = k(f), d = K(f), y = d.length === 0;
88
- t.push({ id: r, node: f, parent: u, level: c, index: o, isLeaf: y }), !y && w.value.has(r) && n(d, f, c + 1);
88
+ const v = a[o], r = w(v), s = S(v), h = s.length === 0;
89
+ t.push({ id: r, node: v, parent: u, level: c, index: o, isLeaf: h }), !h && x.value.has(r) && n(s, v, c + 1);
89
90
  }
90
91
  }
91
- return n(e, null, 0), t;
92
+ if (n(e, null, 0), l.filterNodeMethod && ae.value != null) {
93
+ let a = function(o) {
94
+ const v = w(o), r = S(o);
95
+ let s = !1;
96
+ for (const N of r) s = a(N) || s;
97
+ const h = !!l.filterNodeMethod(ae.value, o);
98
+ return h && u.add(v), s && c.add(v), h || s;
99
+ };
100
+ const u = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set();
101
+ for (const o of e) a(o);
102
+ return t.filter((o) => u.has(o.id) || c.has(o.id));
103
+ }
104
+ return t;
92
105
  }
93
- const v = s(null), E = s(0), O = s(0), i = s([]), R = we(/* @__PURE__ */ new Map()), m = N(() => {
106
+ const f = d(null), I = d(0), P = d(0), i = d([]), R = ke(/* @__PURE__ */ new Map()), k = _(() => {
94
107
  let e = 0;
95
108
  const t = [];
96
109
  for (const n of i.value) {
97
- const a = R.get(n.id) || q;
110
+ const a = R.get(n.id) || j;
98
111
  e += a, t.push(e);
99
112
  }
100
113
  return t;
101
- }), ve = N(() => {
102
- const e = m.value;
114
+ }), fe = _(() => {
115
+ const e = k.value;
103
116
  return e.length ? e[e.length - 1] : 0;
104
117
  });
105
- function fe(e) {
106
- let t = 0, n = m.value.length - 1, a = 0;
118
+ function he(e) {
119
+ let t = 0, n = k.value.length - 1, a = 0;
107
120
  for (; t <= n; ) {
108
121
  const u = t + n >> 1;
109
- m.value[u] !== void 0 && m.value[u] >= e ? (a = u, n = u - 1) : t = u + 1;
122
+ k.value[u] !== void 0 && k.value[u] >= e ? (a = u, n = u - 1) : t = u + 1;
110
123
  }
111
124
  return a;
112
125
  }
113
- const B = s(0), S = s(0), D = s(0), oe = s(0);
114
- function x() {
115
- if (O.value = v.value?.clientHeight || 0, m.value.length === 0 || i.value.length === 0) {
116
- B.value = 0, S.value = 0, D.value = 0, oe.value = 0;
126
+ const B = d(0), M = d(0), H = d(0), ue = d(0);
127
+ function m() {
128
+ if (P.value = f.value?.clientHeight || 0, k.value.length === 0 || i.value.length === 0) {
129
+ B.value = 0, M.value = 0, H.value = 0, ue.value = 0;
117
130
  return;
118
131
  }
119
- const e = fe(E.value);
132
+ const e = he(I.value);
120
133
  B.value = Math.max(0, e - 3);
121
- const t = i.value[B.value], n = t ? R.get(t.id) || q : 0, u = (m.value[B.value] ?? 0) - n;
122
- D.value = Math.max(0, u);
134
+ const t = i.value[B.value], n = t ? R.get(t.id) || j : 0, u = (k.value[B.value] ?? 0) - n;
135
+ H.value = Math.max(0, u);
123
136
  let c = B.value;
124
- const o = E.value + O.value + 3 * q;
125
- for (; c < i.value.length && (m.value[c] ?? 0) < o; ) c++;
126
- S.value = Math.min(i.value.length, c + 1);
127
- const r = (m.value[S.value - 1] ?? 0) - D.value;
128
- if (r < O.value && S.value < i.value.length) {
129
- let d = S.value, y = r;
130
- for (; y < O.value && d < i.value.length; )
131
- d++, y = (m.value[d - 1] ?? 0) - D.value;
132
- S.value = d;
137
+ const o = I.value + P.value + 3 * j;
138
+ for (; c < i.value.length && (k.value[c] ?? 0) < o; ) c++;
139
+ M.value = Math.min(i.value.length, c + 1);
140
+ const r = (k.value[M.value - 1] ?? 0) - H.value;
141
+ if (r < P.value && M.value < i.value.length) {
142
+ let s = M.value, h = r;
143
+ for (; h < P.value && s < i.value.length; )
144
+ s++, h = (k.value[s - 1] ?? 0) - H.value;
145
+ M.value = s;
133
146
  }
134
- oe.value = Math.max(0, ve.value - D.value - ((m.value[S.value - 1] ?? 0) - D.value));
135
- }
136
- _([E, () => l.data, w], () => {
137
- i.value = b(l.data || []), C(I), x();
138
- }), Pe(() => {
139
- i.value = b(l.data || []), C(I), x(), l.defaultCheckedKeys && l.defaultCheckedKeys.length && de(l.defaultCheckedKeys), v.value && (P = new ResizeObserver(() => {
140
- O.value = v.value?.clientHeight || 0, x();
141
- }), P.observe(v.value));
147
+ ue.value = Math.max(0, fe.value - H.value - ((k.value[M.value - 1] ?? 0) - H.value));
148
+ }
149
+ W([I, () => l.data, x], () => {
150
+ i.value = b(l.data || []), C(A), m();
151
+ }), Ve(() => {
152
+ i.value = b(l.data || []), C(A), m(), l.defaultCheckedKeys && l.defaultCheckedKeys.length && ve(l.defaultCheckedKeys), f.value && (V = new ResizeObserver(() => {
153
+ P.value = f.value?.clientHeight || 0, m();
154
+ }), V.observe(f.value));
142
155
  });
143
- let P = null;
144
- Ve(() => {
145
- P && (P.disconnect(), P = null);
156
+ let V = null;
157
+ Ue(() => {
158
+ V && (V.disconnect(), V = null);
146
159
  });
147
- const J = we(/* @__PURE__ */ new Map());
148
- function Ie(e, t) {
149
- t ? J.set(e, t) : J.delete(e);
160
+ const X = ke(/* @__PURE__ */ new Map());
161
+ function Le(e, t) {
162
+ t ? X.set(e, t) : X.delete(e);
150
163
  }
151
- function I() {
164
+ function A() {
152
165
  let e = !1;
153
- for (const t of i.value.slice(B.value, S.value)) {
154
- const n = J.get(t.id);
166
+ for (const t of i.value.slice(B.value, M.value)) {
167
+ const n = X.get(t.id);
155
168
  if (n) {
156
169
  const a = n.offsetHeight;
157
170
  (!R.has(t.id) || R.get(t.id) !== a) && (R.set(t.id, a), e = !0);
158
171
  }
159
172
  }
160
- e && x();
173
+ e && m();
161
174
  }
162
- function Le() {
163
- E.value = v.value?.scrollTop || 0, x();
175
+ function Re() {
176
+ I.value = f.value?.scrollTop || 0, m();
164
177
  }
165
- const M = s(!1), ue = s(null), V = s(null), A = s(null), ce = s(0), H = s(null), U = s(0);
178
+ const z = d(!1), ce = d(null), U = d(null), T = d(null), ie = d(0), D = d(null), $ = d(0);
166
179
  let F = null;
167
- function Q() {
180
+ function Z() {
168
181
  F != null && (cancelAnimationFrame(F), F = null);
169
182
  }
170
- function he() {
171
- if (!M.value || U.value === 0) {
172
- Q();
183
+ function pe() {
184
+ if (!z.value || $.value === 0) {
185
+ Z();
173
186
  return;
174
187
  }
175
- const e = v.value;
188
+ const e = f.value;
176
189
  if (!e) {
177
- Q();
190
+ Z();
178
191
  return;
179
192
  }
180
193
  const t = e.scrollHeight - e.clientHeight, n = 12;
181
- e.scrollTop = Math.max(0, Math.min(t, e.scrollTop + U.value * n)), E.value = e.scrollTop, x(), F = requestAnimationFrame(he);
194
+ e.scrollTop = Math.max(0, Math.min(t, e.scrollTop + $.value * n)), I.value = e.scrollTop, m(), F = requestAnimationFrame(pe);
182
195
  }
183
- function Re() {
184
- U.value !== 0 && F == null && (F = requestAnimationFrame(he)), U.value === 0 && Q();
196
+ function Be() {
197
+ $.value !== 0 && F == null && (F = requestAnimationFrame(pe)), $.value === 0 && Z();
185
198
  }
186
- function X(e) {
199
+ function ee(e) {
187
200
  if (e == null) return null;
188
201
  for (const t of i.value) if (t.id === e) return t;
189
202
  return null;
190
203
  }
191
- function Be(e) {
192
- const t = v.value.getBoundingClientRect(), n = e - t.top + E.value;
193
- return fe(n);
204
+ function He(e) {
205
+ const t = f.value.getBoundingClientRect(), n = e - t.top + I.value;
206
+ return he(n);
194
207
  }
195
208
  function De(e, t) {
196
- !l.draggable || t.button !== 0 || !(!l.allowDrag || l.allowDrag(e.node)) || (M.value = !0, ue.value = e.id, ce.value = t.clientY, t.preventDefault(), window.addEventListener("mousemove", ge), window.addEventListener("mouseup", pe));
209
+ !l.draggable || t.button !== 0 || !(!l.allowDrag || l.allowDrag(e.node)) || (z.value = !0, ce.value = e.id, ie.value = t.clientY, t.preventDefault(), window.addEventListener("mousemove", ge), window.addEventListener("mouseup", me));
197
210
  }
198
211
  function ge(e) {
199
- if (!M.value) return;
200
- ce.value = e.clientY;
201
- const t = Be(e.clientY), n = i.value[Math.min(Math.max(t, 0), i.value.length - 1)];
202
- if (V.value = n?.id ?? null, !n) {
203
- A.value = null;
212
+ if (!z.value) return;
213
+ ie.value = e.clientY;
214
+ const t = He(e.clientY), n = i.value[Math.min(Math.max(t, 0), i.value.length - 1)];
215
+ if (U.value = n?.id ?? null, !n) {
216
+ T.value = null;
204
217
  return;
205
218
  }
206
- const a = m.value[t] ?? 0, u = R.get(n.id) ?? q, c = a - u, o = v.value.getBoundingClientRect(), r = (e.clientY - o.top + E.value - c) / u;
207
- let d = "inner";
208
- r < 0.25 ? d = "prev" : r > 0.75 && (d = "next");
209
- const y = X(ue.value), te = l.allowDrop ? !!(y && l.allowDrop(y.node, n.node, d)) : !0;
210
- A.value = te ? d : null, U.value = e.clientY > o.bottom ? 1 : e.clientY < o.top ? -1 : 0, Re();
219
+ const a = k.value[t] ?? 0, u = R.get(n.id) ?? j, c = a - u, o = f.value.getBoundingClientRect(), r = (e.clientY - o.top + I.value - c) / u;
220
+ let s = "inner";
221
+ r < 0.25 ? s = "prev" : r > 0.75 && (s = "next");
222
+ const h = ee(ce.value), N = l.allowDrop ? !!(h && l.allowDrop(h.node, n.node, s)) : !0;
223
+ T.value = N ? s : null, $.value = e.clientY > o.bottom ? 1 : e.clientY < o.top ? -1 : 0, Be();
211
224
  }
212
- function Z(e, t, n = []) {
225
+ function te(e, t, n = []) {
213
226
  for (const a of t) {
214
- if (k(a) === e) return n;
215
- const u = K(a);
227
+ if (w(a) === e) return n;
228
+ const u = S(a);
216
229
  if (u.length) {
217
- const c = Z(e, u, [...n, a]);
230
+ const c = te(e, u, [...n, a]);
218
231
  if (c) return c;
219
232
  }
220
233
  }
221
234
  return null;
222
235
  }
223
- function ie(e, t) {
236
+ function se(e, t) {
224
237
  if (e == null) return null;
225
238
  for (const n of t) {
226
- if (k(n) === e) return n;
227
- const a = K(n), u = ie(e, a);
239
+ if (w(n) === e) return n;
240
+ const a = S(n), u = se(e, a);
228
241
  if (u) return u;
229
242
  }
230
243
  return null;
231
244
  }
232
- function ee(e) {
245
+ function q(e) {
233
246
  const t = [];
234
247
  for (const n of e) {
235
- t.push(k(n));
236
- const a = K(n);
237
- a.length && t.push(...ee(a));
248
+ t.push(w(n));
249
+ const a = S(n);
250
+ a.length && t.push(...q(a));
238
251
  }
239
252
  return t;
240
253
  }
241
- function He(e) {
254
+ function Ye(e) {
242
255
  const t = e.parent;
243
256
  if (t)
244
- K(t).splice(e.index, 1);
257
+ S(t).splice(e.index, 1);
245
258
  else {
246
- const n = l.data.findIndex((a) => k(a) === e.id);
259
+ const n = l.data.findIndex((a) => w(a) === e.id);
247
260
  n >= 0 && l.data.splice(n, 1);
248
261
  }
249
262
  }
250
- function Ye(e, t, n) {
263
+ function Fe(e, t, n) {
251
264
  if (n === "inner") {
252
- Array.isArray(t.node[G.value]) || (t.node[G.value] = []), t.node[G.value].push(e), w.value.add(t.id);
265
+ Array.isArray(t.node[J.value]) || (t.node[J.value] = []), t.node[J.value].push(e), x.value.add(t.id);
253
266
  return;
254
267
  }
255
268
  const a = t.parent;
256
269
  if (a) {
257
- const u = K(a), c = t.index + (n === "next" ? 1 : 0);
270
+ const u = S(a), c = t.index + (n === "next" ? 1 : 0);
258
271
  u.splice(c, 0, e);
259
272
  } else {
260
273
  const u = t.index + (n === "next" ? 1 : 0);
261
274
  l.data.splice(u, 0, e);
262
275
  }
263
276
  }
264
- function pe() {
265
- if (window.removeEventListener("mousemove", ge), window.removeEventListener("mouseup", pe), Q(), !M.value) return;
266
- const e = X(ue.value), t = X(V.value), n = A.value;
267
- if (M.value = !1, A.value = null, V.value = null, !e || !t || !n || l.allowDrop && !l.allowDrop(e.node, t.node, n) || e.id === t.id) return;
277
+ function me() {
278
+ if (window.removeEventListener("mousemove", ge), window.removeEventListener("mouseup", me), Z(), !z.value) return;
279
+ const e = ee(ce.value), t = ee(U.value), n = T.value;
280
+ if (z.value = !1, T.value = null, U.value = null, !e || !t || !n || l.allowDrop && !l.allowDrop(e.node, t.node, n) || e.id === t.id) return;
268
281
  const a = n === "inner" ? t.node : t.parent || null;
269
282
  if (a) {
270
- const f = Z(k(a), l.data || []) || [];
271
- for (const r of f) if (k(r) === e.id) return;
283
+ const v = te(w(a), l.data || []) || [];
284
+ for (const r of v) if (w(r) === e.id) return;
272
285
  }
273
286
  const u = e.node;
274
- He(e);
287
+ Ye(e);
275
288
  const c = b(l.data || []);
276
289
  i.value = c;
277
- const o = X(t.id) || t;
278
- Ye(u, o, n), i.value = b(l.data || []), C(() => {
279
- I(), x();
290
+ const o = ee(t.id) || t;
291
+ Fe(u, o, n), i.value = b(l.data || []), C(() => {
292
+ A(), m();
280
293
  }), L("node-drop", u, o.node, n);
281
294
  }
282
- function Fe(e, t) {
283
- H.value = e.id, L("node-click", e.node, t);
284
- }
285
295
  function Ne(e, t) {
296
+ D.value = e.id, L("node-click", e.node, t);
297
+ }
298
+ function _e(e, t) {
286
299
  L("node-contextmenu", e.node, t);
287
300
  }
288
- Ue(() => {
289
- C(I);
290
- }), _(
301
+ $e(() => {
302
+ C(A);
303
+ }), W(
291
304
  () => l.currentNodeKey,
292
305
  (e) => {
293
- H.value = e ?? null;
306
+ D.value = e ?? null;
294
307
  },
295
308
  { immediate: !0 }
296
- ), _(
309
+ ), W(
297
310
  () => l.defaultExpandedKeys,
298
311
  (e) => {
299
- w.value = new Set(e || []), i.value = b(l.data || []), C(() => {
300
- I(), x();
312
+ x.value = new Set(e || []), i.value = b(l.data || []), C(() => {
313
+ A(), m();
301
314
  });
302
315
  },
303
316
  { immediate: !0 }
304
- ), _(
317
+ ), W(
305
318
  () => l.defaultExpandAll,
306
319
  (e) => {
307
- e && (w.value = new Set(ee(l.data || [])), i.value = b(l.data || []), C(() => {
308
- I(), x();
320
+ e && (x.value = new Set(q(l.data || [])), i.value = b(l.data || []), C(() => {
321
+ A(), m();
309
322
  }));
310
323
  },
311
324
  { immediate: !0 }
312
- ), _(
325
+ ), W(
313
326
  () => l.data,
314
327
  () => {
315
- l.defaultExpandAll && (w.value = new Set(ee(l.data || [])), i.value = b(l.data || []), C(() => {
316
- I(), x();
317
- }));
318
- const e = new Set(ee(l.data || []));
319
- h.value = new Set([...h.value].filter((t) => e.has(t))), p.value = new Set([...p.value].filter((t) => e.has(t)));
320
- }
328
+ l.defaultExpandAll && (x.value = new Set(q(l.data || []))), i.value = b(l.data || []), C(() => {
329
+ A(), m();
330
+ });
331
+ const e = new Set(q(l.data || []));
332
+ p.value = new Set([...p.value].filter((t) => e.has(t))), y.value = new Set([...y.value].filter((t) => e.has(t)));
333
+ },
334
+ { deep: !0 }
321
335
  );
322
- function _e(e) {
323
- const t = Z(e, l.data || []) || [];
324
- for (const n of t) w.value.add(k(n));
336
+ function We(e) {
337
+ const t = te(e, l.data || []) || [];
338
+ for (const n of t) x.value.add(w(n));
325
339
  i.value = b(l.data || []);
326
340
  }
327
- function me(e) {
328
- e != null && (_e(e), C(() => {
341
+ function xe(e) {
342
+ e != null && (We(e), C(() => {
329
343
  const t = i.value.findIndex((o) => o.id === e);
330
- if (t < 0 || !v.value) return;
331
- const n = R.get(e) || q, a = (m.value[t] ?? 0) - n, u = v.value.clientHeight, c = Math.max(0, a - Math.max(0, (u - n) / 2));
332
- v.value.scrollTop = c, E.value = c, x(), C(() => {
333
- const o = J.get(e);
334
- if (!o || !v.value) return;
335
- const f = o.offsetLeft, r = o.offsetWidth, d = v.value.clientWidth, y = Math.max(0, f + Math.max(0, r / 2) - Math.max(0, d / 2));
336
- v.value.scrollLeft = y;
344
+ if (t < 0 || !f.value) return;
345
+ const n = R.get(e) || j, a = (k.value[t] ?? 0) - n, u = f.value.clientHeight, c = Math.max(0, a - Math.max(0, (u - n) / 2));
346
+ f.value.scrollTop = c, I.value = c, m(), C(() => {
347
+ const o = X.get(e);
348
+ if (!o || !f.value) return;
349
+ const v = o.offsetLeft, r = o.offsetWidth, s = f.value.clientWidth, h = Math.max(0, v + Math.max(0, r / 2) - Math.max(0, s / 2));
350
+ f.value.scrollLeft = h;
337
351
  });
338
352
  }));
339
353
  }
340
- function We(e) {
341
- H.value = e ?? null, me(H.value);
354
+ function Oe(e) {
355
+ D.value = e ?? null, xe(D.value);
342
356
  }
343
357
  return le({
344
- getCurrentKey: () => H.value,
345
- setCurrentKey: We,
346
- scrollTo: me,
347
- getCheckedKeys: () => Array.from(h.value),
348
- setCheckedKeys: de,
349
- setChecked: (e, t) => ae(e, t)
350
- }), _(H, (e) => {
351
- const t = ie(e, l.data || []);
358
+ getCurrentKey: () => D.value,
359
+ setCurrentKey: Oe,
360
+ scrollTo: xe,
361
+ getCheckedKeys: () => Array.from(p.value),
362
+ setCheckedKeys: ve,
363
+ setChecked: (e, t) => oe(e, t),
364
+ filter: (e) => {
365
+ ae.value = e, x.value = new Set(q(l.data || [])), i.value = b(l.data || []), C(() => {
366
+ A(), m();
367
+ });
368
+ }
369
+ }), W(D, (e) => {
370
+ const t = se(e, l.data || []);
352
371
  t && L("current-change", t);
353
- }), (e, t) => (T(), z("div", {
372
+ }), (e, t) => (E(), K("div", {
354
373
  ref_key: "containerRef",
355
- ref: v,
356
- class: $(["amazing-tree", { "is-dragging": M.value }]),
357
- style: W({ height: typeof g.height == "number" ? g.height + "px" : g.height || "100%", "--vtree-bg": g.backgroundColor, "--vtree-text": g.textColor, "--vtree-hover": g.hoverColor }),
358
- onScroll: Le
374
+ ref: f,
375
+ class: Q(["amazing-tree", { "is-dragging": z.value }]),
376
+ style: O({ height: typeof g.height == "number" ? g.height + "px" : g.height || "100%", "--vtree-bg": g.backgroundColor, "--vtree-text": g.textColor, "--vtree-hover": g.hoverColor }),
377
+ onScroll: Re
359
378
  }, [
360
- Ae.value ? (T(), z("div", Qe, [
361
- Ce(e.$slots, "empty", {}, () => [
362
- Y("div", Xe, be(g.emptyText), 1)
379
+ ze.value ? (E(), K("div", Xe, [
380
+ be(e.$slots, "empty", {}, () => [
381
+ Y("div", Ze, Se(g.emptyText), 1)
363
382
  ], !0)
364
- ])) : (T(), z(ke, { key: 0 }, [
383
+ ])) : (E(), K(Ce, { key: 0 }, [
365
384
  Y("div", {
366
- style: W({ height: ve.value + "px", position: "relative", minWidth: "100%", width: "max-content" })
385
+ style: O({ height: fe.value + "px", position: "relative", minWidth: "100%", width: "max-content" })
367
386
  }, [
368
387
  Y("div", {
369
- style: W({ height: D.value + "px" })
388
+ style: O({ height: H.value + "px" })
370
389
  }, null, 4),
371
- (T(!0), z(ke, null, $e(i.value.slice(B.value, S.value), (n) => (T(), z("div", {
390
+ (E(!0), K(Ce, null, qe(i.value.slice(B.value, M.value), (n) => (E(), K("div", {
372
391
  key: n.id,
373
392
  class: "amazing-tree-row-wrapper"
374
393
  }, [
375
394
  Y("div", {
376
- class: $(["amazing-tree-row", { "is-target-inner": M.value && V.value === n.id && A.value === "inner", "is-active": H.value === n.id }]),
377
- style: W({ paddingLeft: n.level * 16 + "px", "--active-color": g.highlightColor }),
395
+ class: Q(["amazing-tree-row", { "is-target-inner": z.value && U.value === n.id && T.value === "inner", "is-active": D.value === n.id }]),
396
+ style: O({ paddingLeft: n.level * 16 + "px", "--active-color": g.highlightColor }),
378
397
  onMousedown: (a) => De(n, a),
379
- onClick: (a) => Fe(n, a),
380
- onContextmenu: se((a) => Ne(n, a), ["prevent"]),
398
+ onClick: (a) => Ne(n, a),
399
+ onContextmenu: re((a) => _e(n, a), ["prevent"]),
381
400
  ref_for: !0,
382
- ref: (a) => Ie(n.id, a)
401
+ ref: (a) => Le(n.id, a)
383
402
  }, [
384
403
  Y("span", {
385
- class: $(["amazing-tree-caret-box", { "is-leaf": n.isLeaf }]),
386
- onClick: se((a) => !n.isLeaf && ze(n.id), ["stop"])
404
+ class: Q(["amazing-tree-caret-box", { "is-leaf": n.isLeaf }]),
405
+ onClick: re((a) => !n.isLeaf && Te(n.id), ["stop"])
387
406
  }, [
388
- n.isLeaf ? ne("", !0) : (T(), z("span", {
407
+ n.isLeaf ? ne("", !0) : (E(), K("span", {
389
408
  key: 0,
390
- class: $(["amazing-tree-caret", { expanded: re(n.id) }])
409
+ class: Q(["amazing-tree-caret", { expanded: de(n.id) }])
391
410
  }, null, 2))
392
411
  ], 10, je),
393
- g.showCheckbox ? (T(), z("input", {
412
+ g.showCheckbox ? (E(), K("input", {
394
413
  key: 0,
395
414
  class: "amazing-tree-checkbox",
396
415
  type: "checkbox",
397
- checked: Te(n.id),
398
- indeterminate: Ke(n.id),
416
+ checked: Ke(n.id),
417
+ indeterminate: Ee(n.id),
399
418
  disabled: l.disabledChecked ? l.disabledChecked(n.node) : !1,
400
- onClick: se((a) => Ee(n, a), ["stop"])
419
+ onClick: re((a) => Ie(n, a), ["stop"])
401
420
  }, null, 8, Ge)) : ne("", !0),
402
- Ce(e.$slots, "default", {
421
+ be(e.$slots, "default", {
403
422
  node: n.node,
404
423
  data: n.node,
405
424
  level: n.level,
406
- expanded: re(n.id),
425
+ expanded: de(n.id),
407
426
  isLeaf: n.isLeaf
408
427
  }, () => [
409
- Y("span", Je, be(n.node[Me.value]), 1)
428
+ Y("span", Je, Se(n.node[Ae.value]), 1)
410
429
  ], !0)
411
- ], 46, qe),
412
- M.value && V.value === n.id && (A.value === "prev" || A.value === "next") ? (T(), z("div", {
430
+ ], 46, Qe),
431
+ z.value && U.value === n.id && (T.value === "prev" || T.value === "next") ? (E(), K("div", {
413
432
  key: 0,
414
- class: $(["amazing-tree-drop-line", { "is-prev": A.value === "prev", "is-next": A.value === "next" }])
433
+ class: Q(["amazing-tree-drop-line", { "is-prev": T.value === "prev", "is-next": T.value === "next" }])
415
434
  }, null, 2)) : ne("", !0)
416
435
  ]))), 128)),
417
436
  Y("div", {
418
- style: W({ height: oe.value + "px" })
437
+ style: O({ height: ue.value + "px" })
419
438
  }, null, 4)
420
439
  ], 4),
421
- M.value ? (T(), z("div", {
440
+ z.value ? (E(), K("div", {
422
441
  key: 0,
423
442
  class: "amazing-tree-ghost",
424
- style: W({ top: ce.value + "px" })
443
+ style: O({ top: ie.value + "px" })
425
444
  }, null, 4)) : ne("", !0)
426
445
  ], 64))
427
446
  ], 38));
428
447
  }
429
- }), et = (g, le) => {
430
- const j = g.__vccOpts || g;
448
+ }), tt = (g, le) => {
449
+ const G = g.__vccOpts || g;
431
450
  for (const [l, L] of le)
432
- j[l] = L;
433
- return j;
434
- }, nt = /* @__PURE__ */ et(Ze, [["__scopeId", "data-v-f93b9531"]]);
451
+ G[l] = L;
452
+ return G;
453
+ }, lt = /* @__PURE__ */ tt(et, [["__scopeId", "data-v-e0a4c022"]]);
435
454
  export {
436
- nt as AmazingTree,
437
- nt as default
455
+ lt as AmazingTree,
456
+ lt as default
438
457
  };
@@ -1 +1 @@
1
- (function(z,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(z=typeof globalThis<"u"?globalThis:z||self,t(z.AmazingTree={},z.Vue))})(this,(function(z,t){"use strict";const fe=["onMousedown","onClick","onContextmenu"],he=["onClick"],ve=["checked","indeterminate","disabled","onClick"],me={class:"amazing-tree-label"},pe={key:1,class:"amazing-tree-empty"},ge={class:"amazing-tree-empty-inner"},V=28,te=((m,G)=>{const Y=m.__vccOpts||m;for(const[a,A]of G)Y[a]=A;return Y})(t.defineComponent({__name:"AmazingTree",props:{data:{},props:{default:()=>({value:"value",label:"label",children:"children"})},allowDrag:{},allowDrop:{},height:{default:void 0},highlightColor:{default:"#1e71ff"},backgroundColor:{default:"#1d1d24"},textColor:{default:"#c8d3de"},hoverColor:{default:"#5d90e5"},currentNodeKey:{},defaultExpandedKeys:{},defaultExpandAll:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},emptyText:{default:"暂无数据"},showCheckbox:{type:Boolean,default:!1},checkStrictly:{type:Boolean,default:!1},defaultCheckedKeys:{default:()=>[]},disabledChecked:{}},emits:["node-click","node-contextmenu","node-drop","current-change","check-change"],setup(m,{expose:G,emit:Y}){const a=m,A=Y,ke=t.computed(()=>a.props.value||"value"),xe=t.computed(()=>a.props.label||"label"),O=t.computed(()=>a.props.children||"children"),ye=t.computed(()=>Array.isArray(a.data)?a.data.length===0:!0),y=t.ref(new Set),v=t.ref(new Set),p=t.ref(new Set);function ne(e){return y.value.has(e)}function we(e){y.value.has(e)?y.value.delete(e):y.value.add(e),s.value=C(a.data||[]),t.nextTick(()=>{M(),k()})}function w(e){return e[ke.value]}function E(e){const n=e[O.value];return Array.isArray(n)?n:[]}function Ce(e){return v.value.has(e)}function be(e){return p.value.has(e)}function J(e,n){if(n?v.value.add(e):v.value.delete(e),p.value.delete(e),!a.checkStrictly){const l=ee(e,a.data||[]);if(l){const o=[l];for(;o.length;){const r=o.pop(),c=w(r);n?v.value.add(c):v.value.delete(c),p.value.delete(c);const h=E(r);for(const d of h)o.push(d)}const i=U(e,a.data||[])||[];for(const r of i){const c=w(r),h=E(r);let d=!0,u=!1;for(const x of h){const j=w(x),de=v.value.has(j),ue=p.value.has(j);(de||ue)&&(u=!0),(!de||ue)&&(d=!1)}h.length===0?(v.value.has(c),p.value.delete(c)):d?(v.value.add(c),p.value.delete(c)):u?(v.value.delete(c),p.value.add(c)):(v.value.delete(c),p.value.delete(c))}}}}function le(e){v.value=new Set,p.value=new Set;for(const n of e||[])J(n,!0)}function Se(e,n){const l=n.target;a.disabledChecked&&a.disabledChecked(e.node)||(A("check-change",e.node,!!l.checked),J(e.id,!!l.checked))}function C(e){const n=[];function l(o,i,r){for(let c=0;c<o.length;c++){const h=o[c],d=w(h),u=E(h),x=u.length===0;n.push({id:d,node:h,parent:i,level:r,index:c,isLeaf:x}),!x&&y.value.has(d)&&l(u,h,r+1)}}return l(e,null,0),n}const f=t.ref(null),B=t.ref(0),D=t.ref(0),s=t.ref([]),K=t.reactive(new Map),g=t.computed(()=>{let e=0;const n=[];for(const l of s.value){const o=K.get(l.id)||V;e+=o,n.push(e)}return n}),ae=t.computed(()=>{const e=g.value;return e.length?e[e.length-1]:0});function oe(e){let n=0,l=g.value.length-1,o=0;for(;n<=l;){const i=n+l>>1;g.value[i]!==void 0&&g.value[i]>=e?(o=i,l=i-1):n=i+1}return o}const I=t.ref(0),b=t.ref(0),L=t.ref(0),Q=t.ref(0);function k(){if(D.value=f.value?.clientHeight||0,g.value.length===0||s.value.length===0){I.value=0,b.value=0,L.value=0,Q.value=0;return}const e=oe(B.value);I.value=Math.max(0,e-3);const n=s.value[I.value],l=n?K.get(n.id)||V:0,i=(g.value[I.value]??0)-l;L.value=Math.max(0,i);let r=I.value;const c=B.value+D.value+3*V;for(;r<s.value.length&&(g.value[r]??0)<c;)r++;b.value=Math.min(s.value.length,r+1);const d=(g.value[b.value-1]??0)-L.value;if(d<D.value&&b.value<s.value.length){let u=b.value,x=d;for(;x<D.value&&u<s.value.length;)u++,x=(g.value[u-1]??0)-L.value;b.value=u}Q.value=Math.max(0,ae.value-L.value-((g.value[b.value-1]??0)-L.value))}t.watch([B,()=>a.data,y],()=>{s.value=C(a.data||[]),t.nextTick(M),k()}),t.onMounted(()=>{s.value=C(a.data||[]),t.nextTick(M),k(),a.defaultCheckedKeys&&a.defaultCheckedKeys.length&&le(a.defaultCheckedKeys),f.value&&(_=new ResizeObserver(()=>{D.value=f.value?.clientHeight||0,k()}),_.observe(f.value))});let _=null;t.onUnmounted(()=>{_&&(_.disconnect(),_=null)});const P=t.reactive(new Map);function Te(e,n){n?P.set(e,n):P.delete(e)}function M(){let e=!1;for(const n of s.value.slice(I.value,b.value)){const l=P.get(n.id);if(l){const o=l.offsetHeight;(!K.has(n.id)||K.get(n.id)!==o)&&(K.set(n.id,o),e=!0)}}e&&k()}function ze(){B.value=f.value?.scrollTop||0,k()}const S=t.ref(!1),X=t.ref(null),F=t.ref(null),T=t.ref(null),Z=t.ref(0),N=t.ref(null),H=t.ref(0);let R=null;function W(){R!=null&&(cancelAnimationFrame(R),R=null)}function ce(){if(!S.value||H.value===0){W();return}const e=f.value;if(!e){W();return}const n=e.scrollHeight-e.clientHeight,l=12;e.scrollTop=Math.max(0,Math.min(n,e.scrollTop+H.value*l)),B.value=e.scrollTop,k(),R=requestAnimationFrame(ce)}function Ee(){H.value!==0&&R==null&&(R=requestAnimationFrame(ce)),H.value===0&&W()}function q(e){if(e==null)return null;for(const n of s.value)if(n.id===e)return n;return null}function Be(e){const n=f.value.getBoundingClientRect(),l=e-n.top+B.value;return oe(l)}function Me(e,n){!a.draggable||n.button!==0||!(!a.allowDrag||a.allowDrag(e.node))||(S.value=!0,X.value=e.id,Z.value=n.clientY,n.preventDefault(),window.addEventListener("mousemove",ie),window.addEventListener("mouseup",re))}function ie(e){if(!S.value)return;Z.value=e.clientY;const n=Be(e.clientY),l=s.value[Math.min(Math.max(n,0),s.value.length-1)];if(F.value=l?.id??null,!l){T.value=null;return}const o=g.value[n]??0,i=K.get(l.id)??V,r=o-i,c=f.value.getBoundingClientRect(),d=(e.clientY-c.top+B.value-r)/i;let u="inner";d<.25?u="prev":d>.75&&(u="next");const x=q(X.value),j=a.allowDrop?!!(x&&a.allowDrop(x.node,l.node,u)):!0;T.value=j?u:null,H.value=e.clientY>c.bottom?1:e.clientY<c.top?-1:0,Ee()}function U(e,n,l=[]){for(const o of n){if(w(o)===e)return l;const i=E(o);if(i.length){const r=U(e,i,[...l,o]);if(r)return r}}return null}function ee(e,n){if(e==null)return null;for(const l of n){if(w(l)===e)return l;const o=E(l),i=ee(e,o);if(i)return i}return null}function $(e){const n=[];for(const l of e){n.push(w(l));const o=E(l);o.length&&n.push(...$(o))}return n}function Ae(e){const n=e.parent;if(n)E(n).splice(e.index,1);else{const l=a.data.findIndex(o=>w(o)===e.id);l>=0&&a.data.splice(l,1)}}function Ke(e,n,l){if(l==="inner"){Array.isArray(n.node[O.value])||(n.node[O.value]=[]),n.node[O.value].push(e),y.value.add(n.id);return}const o=n.parent;if(o){const i=E(o),r=n.index+(l==="next"?1:0);i.splice(r,0,e)}else{const i=n.index+(l==="next"?1:0);a.data.splice(i,0,e)}}function re(){if(window.removeEventListener("mousemove",ie),window.removeEventListener("mouseup",re),W(),!S.value)return;const e=q(X.value),n=q(F.value),l=T.value;if(S.value=!1,T.value=null,F.value=null,!e||!n||!l||a.allowDrop&&!a.allowDrop(e.node,n.node,l)||e.id===n.id)return;const o=l==="inner"?n.node:n.parent||null;if(o){const h=U(w(o),a.data||[])||[];for(const d of h)if(w(d)===e.id)return}const i=e.node;Ae(e);const r=C(a.data||[]);s.value=r;const c=q(n.id)||n;Ke(i,c,l),s.value=C(a.data||[]),t.nextTick(()=>{M(),k()}),A("node-drop",i,c.node,l)}function Ie(e,n){N.value=e.id,A("node-click",e.node,n)}function Le(e,n){A("node-contextmenu",e.node,n)}t.watchEffect(()=>{t.nextTick(M)}),t.watch(()=>a.currentNodeKey,e=>{N.value=e??null},{immediate:!0}),t.watch(()=>a.defaultExpandedKeys,e=>{y.value=new Set(e||[]),s.value=C(a.data||[]),t.nextTick(()=>{M(),k()})},{immediate:!0}),t.watch(()=>a.defaultExpandAll,e=>{e&&(y.value=new Set($(a.data||[])),s.value=C(a.data||[]),t.nextTick(()=>{M(),k()}))},{immediate:!0}),t.watch(()=>a.data,()=>{a.defaultExpandAll&&(y.value=new Set($(a.data||[])),s.value=C(a.data||[]),t.nextTick(()=>{M(),k()}));const e=new Set($(a.data||[]));v.value=new Set([...v.value].filter(n=>e.has(n))),p.value=new Set([...p.value].filter(n=>e.has(n)))});function Ne(e){const n=U(e,a.data||[])||[];for(const l of n)y.value.add(w(l));s.value=C(a.data||[])}function se(e){e!=null&&(Ne(e),t.nextTick(()=>{const n=s.value.findIndex(c=>c.id===e);if(n<0||!f.value)return;const l=K.get(e)||V,o=(g.value[n]??0)-l,i=f.value.clientHeight,r=Math.max(0,o-Math.max(0,(i-l)/2));f.value.scrollTop=r,B.value=r,k(),t.nextTick(()=>{const c=P.get(e);if(!c||!f.value)return;const h=c.offsetLeft,d=c.offsetWidth,u=f.value.clientWidth,x=Math.max(0,h+Math.max(0,d/2)-Math.max(0,u/2));f.value.scrollLeft=x})}))}function Re(e){N.value=e??null,se(N.value)}return G({getCurrentKey:()=>N.value,setCurrentKey:Re,scrollTo:se,getCheckedKeys:()=>Array.from(v.value),setCheckedKeys:le,setChecked:(e,n)=>J(e,n)}),t.watch(N,e=>{const n=ee(e,a.data||[]);n&&A("current-change",n)}),(e,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"containerRef",ref:f,class:t.normalizeClass(["amazing-tree",{"is-dragging":S.value}]),style:t.normalizeStyle({height:typeof m.height=="number"?m.height+"px":m.height||"100%","--vtree-bg":m.backgroundColor,"--vtree-text":m.textColor,"--vtree-hover":m.hoverColor}),onScroll:ze},[ye.value?(t.openBlock(),t.createElementBlock("div",pe,[t.renderSlot(e.$slots,"empty",{},()=>[t.createElementVNode("div",ge,t.toDisplayString(m.emptyText),1)],!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("div",{style:t.normalizeStyle({height:ae.value+"px",position:"relative",minWidth:"100%",width:"max-content"})},[t.createElementVNode("div",{style:t.normalizeStyle({height:L.value+"px"})},null,4),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.value.slice(I.value,b.value),l=>(t.openBlock(),t.createElementBlock("div",{key:l.id,class:"amazing-tree-row-wrapper"},[t.createElementVNode("div",{class:t.normalizeClass(["amazing-tree-row",{"is-target-inner":S.value&&F.value===l.id&&T.value==="inner","is-active":N.value===l.id}]),style:t.normalizeStyle({paddingLeft:l.level*16+"px","--active-color":m.highlightColor}),onMousedown:o=>Me(l,o),onClick:o=>Ie(l,o),onContextmenu:t.withModifiers(o=>Le(l,o),["prevent"]),ref_for:!0,ref:o=>Te(l.id,o)},[t.createElementVNode("span",{class:t.normalizeClass(["amazing-tree-caret-box",{"is-leaf":l.isLeaf}]),onClick:t.withModifiers(o=>!l.isLeaf&&we(l.id),["stop"])},[l.isLeaf?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["amazing-tree-caret",{expanded:ne(l.id)}])},null,2))],10,he),m.showCheckbox?(t.openBlock(),t.createElementBlock("input",{key:0,class:"amazing-tree-checkbox",type:"checkbox",checked:Ce(l.id),indeterminate:be(l.id),disabled:a.disabledChecked?a.disabledChecked(l.node):!1,onClick:t.withModifiers(o=>Se(l,o),["stop"])},null,8,ve)):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"default",{node:l.node,data:l.node,level:l.level,expanded:ne(l.id),isLeaf:l.isLeaf},()=>[t.createElementVNode("span",me,t.toDisplayString(l.node[xe.value]),1)],!0)],46,fe),S.value&&F.value===l.id&&(T.value==="prev"||T.value==="next")?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["amazing-tree-drop-line",{"is-prev":T.value==="prev","is-next":T.value==="next"}])},null,2)):t.createCommentVNode("",!0)]))),128)),t.createElementVNode("div",{style:t.normalizeStyle({height:Q.value+"px"})},null,4)],4),S.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"amazing-tree-ghost",style:t.normalizeStyle({top:Z.value+"px"})},null,4)):t.createCommentVNode("",!0)],64))],38))}}),[["__scopeId","data-v-f93b9531"]]);z.AmazingTree=te,z.default=te,Object.defineProperties(z,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(M,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(M=typeof globalThis<"u"?globalThis:M||self,t(M.AmazingTree={},M.Vue))})(this,(function(M,t){"use strict";const he=["onMousedown","onClick","onContextmenu"],ve=["onClick"],me=["checked","indeterminate","disabled","onClick"],pe={class:"amazing-tree-label"},ge={key:1,class:"amazing-tree-empty"},ke={class:"amazing-tree-empty-inner"},D=28,ne=((p,Q)=>{const P=p.__vccOpts||p;for(const[a,A]of Q)P[a]=A;return P})(t.defineComponent({__name:"AmazingTree",props:{data:{},props:{default:()=>({value:"value",label:"label",children:"children"})},allowDrag:{},allowDrop:{},height:{default:void 0},highlightColor:{default:"#1e71ff"},backgroundColor:{default:"#1d1d24"},textColor:{default:"#c8d3de"},hoverColor:{default:"#5d90e5"},currentNodeKey:{},defaultExpandedKeys:{},defaultExpandAll:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},emptyText:{default:"暂无数据"},showCheckbox:{type:Boolean,default:!1},checkStrictly:{type:Boolean,default:!1},defaultCheckedKeys:{default:()=>[]},disabledChecked:{},filterNodeMethod:{}},emits:["node-click","node-contextmenu","node-drop","current-change","check-change"],setup(p,{expose:Q,emit:P}){const a=p,A=P,xe=t.computed(()=>a.props.value||"value"),ye=t.computed(()=>a.props.label||"label"),W=t.computed(()=>a.props.children||"children"),we=t.computed(()=>Array.isArray(a.data)?a.data.length===0:!0),k=t.ref(new Set),m=t.ref(new Set),x=t.ref(new Set),G=t.ref(null);function le(e){return k.value.has(e)}function Ce(e){k.value.has(e)?k.value.delete(e):k.value.add(e),s.value=C(a.data||[]),t.nextTick(()=>{T(),g()})}function y(e){return e[xe.value]}function b(e){const n=e[W.value];return Array.isArray(n)?n:[]}function be(e){return m.value.has(e)}function Se(e){return x.value.has(e)}function J(e,n){if(n?m.value.add(e):m.value.delete(e),x.value.delete(e),!a.checkStrictly){const l=te(e,a.data||[]);if(l){const o=[l];for(;o.length;){const r=o.pop(),c=y(r);n?m.value.add(c):m.value.delete(c),x.value.delete(c);const f=b(r);for(const u of f)o.push(u)}const i=j(e,a.data||[])||[];for(const r of i){const c=y(r),f=b(r);let u=!0,d=!1;for(const v of f){const V=y(v),ue=m.value.has(V),fe=x.value.has(V);(ue||fe)&&(d=!0),(!ue||fe)&&(u=!1)}f.length===0?(m.value.has(c),x.value.delete(c)):u?(m.value.add(c),x.value.delete(c)):d?(m.value.delete(c),x.value.add(c)):(m.value.delete(c),x.value.delete(c))}}}}function ae(e){m.value=new Set,x.value=new Set;for(const n of e||[])J(n,!0)}function Te(e,n){const l=n.target;a.disabledChecked&&a.disabledChecked(e.node)||(A("check-change",e.node,!!l.checked),J(e.id,!!l.checked))}function C(e){const n=[];function l(o,i,r){for(let c=0;c<o.length;c++){const f=o[c],u=y(f),d=b(f),v=d.length===0;n.push({id:u,node:f,parent:i,level:r,index:c,isLeaf:v}),!v&&k.value.has(u)&&l(d,f,r+1)}}if(l(e,null,0),a.filterNodeMethod&&G.value!=null){let o=function(c){const f=y(c),u=b(c);let d=!1;for(const V of u)d=o(V)||d;const v=!!a.filterNodeMethod(G.value,c);return v&&i.add(f),d&&r.add(f),v||d};const i=new Set,r=new Set;for(const c of e)o(c);return n.filter(c=>i.has(c.id)||r.has(c.id))}return n}const h=t.ref(null),B=t.ref(0),H=t.ref(0),s=t.ref([]),K=t.reactive(new Map),w=t.computed(()=>{let e=0;const n=[];for(const l of s.value){const o=K.get(l.id)||D;e+=o,n.push(e)}return n}),oe=t.computed(()=>{const e=w.value;return e.length?e[e.length-1]:0});function ce(e){let n=0,l=w.value.length-1,o=0;for(;n<=l;){const i=n+l>>1;w.value[i]!==void 0&&w.value[i]>=e?(o=i,l=i-1):n=i+1}return o}const N=t.ref(0),S=t.ref(0),I=t.ref(0),X=t.ref(0);function g(){if(H.value=h.value?.clientHeight||0,w.value.length===0||s.value.length===0){N.value=0,S.value=0,I.value=0,X.value=0;return}const e=ce(B.value);N.value=Math.max(0,e-3);const n=s.value[N.value],l=n?K.get(n.id)||D:0,i=(w.value[N.value]??0)-l;I.value=Math.max(0,i);let r=N.value;const c=B.value+H.value+3*D;for(;r<s.value.length&&(w.value[r]??0)<c;)r++;S.value=Math.min(s.value.length,r+1);const u=(w.value[S.value-1]??0)-I.value;if(u<H.value&&S.value<s.value.length){let d=S.value,v=u;for(;v<H.value&&d<s.value.length;)d++,v=(w.value[d-1]??0)-I.value;S.value=d}X.value=Math.max(0,oe.value-I.value-((w.value[S.value-1]??0)-I.value))}t.watch([B,()=>a.data,k],()=>{s.value=C(a.data||[]),t.nextTick(T),g()}),t.onMounted(()=>{s.value=C(a.data||[]),t.nextTick(T),g(),a.defaultCheckedKeys&&a.defaultCheckedKeys.length&&ae(a.defaultCheckedKeys),h.value&&(_=new ResizeObserver(()=>{H.value=h.value?.clientHeight||0,g()}),_.observe(h.value))});let _=null;t.onUnmounted(()=>{_&&(_.disconnect(),_=null)});const q=t.reactive(new Map);function ze(e,n){n?q.set(e,n):q.delete(e)}function T(){let e=!1;for(const n of s.value.slice(N.value,S.value)){const l=q.get(n.id);if(l){const o=l.offsetHeight;(!K.has(n.id)||K.get(n.id)!==o)&&(K.set(n.id,o),e=!0)}}e&&g()}function Ee(){B.value=h.value?.scrollTop||0,g()}const z=t.ref(!1),Z=t.ref(null),F=t.ref(null),E=t.ref(null),ee=t.ref(0),L=t.ref(null),Y=t.ref(0);let R=null;function U(){R!=null&&(cancelAnimationFrame(R),R=null)}function ie(){if(!z.value||Y.value===0){U();return}const e=h.value;if(!e){U();return}const n=e.scrollHeight-e.clientHeight,l=12;e.scrollTop=Math.max(0,Math.min(n,e.scrollTop+Y.value*l)),B.value=e.scrollTop,g(),R=requestAnimationFrame(ie)}function Me(){Y.value!==0&&R==null&&(R=requestAnimationFrame(ie)),Y.value===0&&U()}function $(e){if(e==null)return null;for(const n of s.value)if(n.id===e)return n;return null}function Be(e){const n=h.value.getBoundingClientRect(),l=e-n.top+B.value;return ce(l)}function Ae(e,n){!a.draggable||n.button!==0||!(!a.allowDrag||a.allowDrag(e.node))||(z.value=!0,Z.value=e.id,ee.value=n.clientY,n.preventDefault(),window.addEventListener("mousemove",re),window.addEventListener("mouseup",se))}function re(e){if(!z.value)return;ee.value=e.clientY;const n=Be(e.clientY),l=s.value[Math.min(Math.max(n,0),s.value.length-1)];if(F.value=l?.id??null,!l){E.value=null;return}const o=w.value[n]??0,i=K.get(l.id)??D,r=o-i,c=h.value.getBoundingClientRect(),u=(e.clientY-c.top+B.value-r)/i;let d="inner";u<.25?d="prev":u>.75&&(d="next");const v=$(Z.value),V=a.allowDrop?!!(v&&a.allowDrop(v.node,l.node,d)):!0;E.value=V?d:null,Y.value=e.clientY>c.bottom?1:e.clientY<c.top?-1:0,Me()}function j(e,n,l=[]){for(const o of n){if(y(o)===e)return l;const i=b(o);if(i.length){const r=j(e,i,[...l,o]);if(r)return r}}return null}function te(e,n){if(e==null)return null;for(const l of n){if(y(l)===e)return l;const o=b(l),i=te(e,o);if(i)return i}return null}function O(e){const n=[];for(const l of e){n.push(y(l));const o=b(l);o.length&&n.push(...O(o))}return n}function Ke(e){const n=e.parent;if(n)b(n).splice(e.index,1);else{const l=a.data.findIndex(o=>y(o)===e.id);l>=0&&a.data.splice(l,1)}}function Ne(e,n,l){if(l==="inner"){Array.isArray(n.node[W.value])||(n.node[W.value]=[]),n.node[W.value].push(e),k.value.add(n.id);return}const o=n.parent;if(o){const i=b(o),r=n.index+(l==="next"?1:0);i.splice(r,0,e)}else{const i=n.index+(l==="next"?1:0);a.data.splice(i,0,e)}}function se(){if(window.removeEventListener("mousemove",re),window.removeEventListener("mouseup",se),U(),!z.value)return;const e=$(Z.value),n=$(F.value),l=E.value;if(z.value=!1,E.value=null,F.value=null,!e||!n||!l||a.allowDrop&&!a.allowDrop(e.node,n.node,l)||e.id===n.id)return;const o=l==="inner"?n.node:n.parent||null;if(o){const f=j(y(o),a.data||[])||[];for(const u of f)if(y(u)===e.id)return}const i=e.node;Ke(e);const r=C(a.data||[]);s.value=r;const c=$(n.id)||n;Ne(i,c,l),s.value=C(a.data||[]),t.nextTick(()=>{T(),g()}),A("node-drop",i,c.node,l)}function Ie(e,n){L.value=e.id,A("node-click",e.node,n)}function Le(e,n){A("node-contextmenu",e.node,n)}t.watchEffect(()=>{t.nextTick(T)}),t.watch(()=>a.currentNodeKey,e=>{L.value=e??null},{immediate:!0}),t.watch(()=>a.defaultExpandedKeys,e=>{k.value=new Set(e||[]),s.value=C(a.data||[]),t.nextTick(()=>{T(),g()})},{immediate:!0}),t.watch(()=>a.defaultExpandAll,e=>{e&&(k.value=new Set(O(a.data||[])),s.value=C(a.data||[]),t.nextTick(()=>{T(),g()}))},{immediate:!0}),t.watch(()=>a.data,()=>{a.defaultExpandAll&&(k.value=new Set(O(a.data||[]))),s.value=C(a.data||[]),t.nextTick(()=>{T(),g()});const e=new Set(O(a.data||[]));m.value=new Set([...m.value].filter(n=>e.has(n))),x.value=new Set([...x.value].filter(n=>e.has(n)))},{deep:!0});function Re(e){const n=j(e,a.data||[])||[];for(const l of n)k.value.add(y(l));s.value=C(a.data||[])}function de(e){e!=null&&(Re(e),t.nextTick(()=>{const n=s.value.findIndex(c=>c.id===e);if(n<0||!h.value)return;const l=K.get(e)||D,o=(w.value[n]??0)-l,i=h.value.clientHeight,r=Math.max(0,o-Math.max(0,(i-l)/2));h.value.scrollTop=r,B.value=r,g(),t.nextTick(()=>{const c=q.get(e);if(!c||!h.value)return;const f=c.offsetLeft,u=c.offsetWidth,d=h.value.clientWidth,v=Math.max(0,f+Math.max(0,u/2)-Math.max(0,d/2));h.value.scrollLeft=v})}))}function Ve(e){L.value=e??null,de(L.value)}return Q({getCurrentKey:()=>L.value,setCurrentKey:Ve,scrollTo:de,getCheckedKeys:()=>Array.from(m.value),setCheckedKeys:ae,setChecked:(e,n)=>J(e,n),filter:e=>{G.value=e,k.value=new Set(O(a.data||[])),s.value=C(a.data||[]),t.nextTick(()=>{T(),g()})}}),t.watch(L,e=>{const n=te(e,a.data||[]);n&&A("current-change",n)}),(e,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"containerRef",ref:h,class:t.normalizeClass(["amazing-tree",{"is-dragging":z.value}]),style:t.normalizeStyle({height:typeof p.height=="number"?p.height+"px":p.height||"100%","--vtree-bg":p.backgroundColor,"--vtree-text":p.textColor,"--vtree-hover":p.hoverColor}),onScroll:Ee},[we.value?(t.openBlock(),t.createElementBlock("div",ge,[t.renderSlot(e.$slots,"empty",{},()=>[t.createElementVNode("div",ke,t.toDisplayString(p.emptyText),1)],!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("div",{style:t.normalizeStyle({height:oe.value+"px",position:"relative",minWidth:"100%",width:"max-content"})},[t.createElementVNode("div",{style:t.normalizeStyle({height:I.value+"px"})},null,4),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.value.slice(N.value,S.value),l=>(t.openBlock(),t.createElementBlock("div",{key:l.id,class:"amazing-tree-row-wrapper"},[t.createElementVNode("div",{class:t.normalizeClass(["amazing-tree-row",{"is-target-inner":z.value&&F.value===l.id&&E.value==="inner","is-active":L.value===l.id}]),style:t.normalizeStyle({paddingLeft:l.level*16+"px","--active-color":p.highlightColor}),onMousedown:o=>Ae(l,o),onClick:o=>Ie(l,o),onContextmenu:t.withModifiers(o=>Le(l,o),["prevent"]),ref_for:!0,ref:o=>ze(l.id,o)},[t.createElementVNode("span",{class:t.normalizeClass(["amazing-tree-caret-box",{"is-leaf":l.isLeaf}]),onClick:t.withModifiers(o=>!l.isLeaf&&Ce(l.id),["stop"])},[l.isLeaf?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["amazing-tree-caret",{expanded:le(l.id)}])},null,2))],10,ve),p.showCheckbox?(t.openBlock(),t.createElementBlock("input",{key:0,class:"amazing-tree-checkbox",type:"checkbox",checked:be(l.id),indeterminate:Se(l.id),disabled:a.disabledChecked?a.disabledChecked(l.node):!1,onClick:t.withModifiers(o=>Te(l,o),["stop"])},null,8,me)):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"default",{node:l.node,data:l.node,level:l.level,expanded:le(l.id),isLeaf:l.isLeaf},()=>[t.createElementVNode("span",pe,t.toDisplayString(l.node[ye.value]),1)],!0)],46,he),z.value&&F.value===l.id&&(E.value==="prev"||E.value==="next")?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["amazing-tree-drop-line",{"is-prev":E.value==="prev","is-next":E.value==="next"}])},null,2)):t.createCommentVNode("",!0)]))),128)),t.createElementVNode("div",{style:t.normalizeStyle({height:X.value+"px"})},null,4)],4),z.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"amazing-tree-ghost",style:t.normalizeStyle({top:ee.value+"px"})},null,4)):t.createCommentVNode("",!0)],64))],38))}}),[["__scopeId","data-v-e0a4c022"]]);M.AmazingTree=ne,M.default=ne,Object.defineProperties(M,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amazing-tree",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -54,6 +54,6 @@
54
54
  "sideEffects": [
55
55
  "dist/*.css"
56
56
  ],
57
- "author": "maxkang",
57
+ "author": "Maxkang",
58
58
  "style": "./dist/amazing-tree.css"
59
59
  }