ngx-tethys 19.1.0-next.0 → 19.1.0-next.2
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/CHANGELOG.md +36 -0
- package/README.md +0 -1
- package/action/action.component.d.ts +7 -8
- package/affix/affix.component.d.ts +3 -4
- package/arrow-switcher/arrow-switcher.component.d.ts +5 -1
- package/button/button-group.component.d.ts +5 -12
- package/button/button-icon.component.d.ts +14 -28
- package/button/button.component.d.ts +17 -27
- package/date-picker/styles/calendar.scss +1 -1
- package/date-picker/styles/range-picker.scss +1 -0
- package/date-picker/styles/week-picker.scss +1 -0
- package/dropdown/dropdown-active.directive.d.ts +4 -5
- package/dropdown/dropdown-menu-item.directive.d.ts +7 -15
- package/dropdown/dropdown-menu.component.d.ts +6 -13
- package/dropdown/dropdown-submenu.component.d.ts +2 -4
- package/dropdown/dropdown.directive.d.ts +14 -25
- package/fesm2022/ngx-tethys-action.mjs +15 -16
- package/fesm2022/ngx-tethys-action.mjs.map +1 -1
- package/fesm2022/ngx-tethys-affix.mjs +14 -18
- package/fesm2022/ngx-tethys-affix.mjs.map +1 -1
- package/fesm2022/ngx-tethys-arrow-switcher.mjs +15 -3
- package/fesm2022/ngx-tethys-arrow-switcher.mjs.map +1 -1
- package/fesm2022/ngx-tethys-button.mjs +225 -322
- package/fesm2022/ngx-tethys-button.mjs.map +1 -1
- package/fesm2022/ngx-tethys-carousel.mjs +1 -0
- package/fesm2022/ngx-tethys-carousel.mjs.map +1 -1
- package/fesm2022/ngx-tethys-collapse.mjs +2 -2
- package/fesm2022/ngx-tethys-collapse.mjs.map +1 -1
- package/fesm2022/ngx-tethys-date-picker.mjs +6 -6
- package/fesm2022/ngx-tethys-date-picker.mjs.map +1 -1
- package/fesm2022/ngx-tethys-dropdown.mjs +155 -203
- package/fesm2022/ngx-tethys-dropdown.mjs.map +1 -1
- package/fesm2022/ngx-tethys-flexible-text.mjs +67 -86
- package/fesm2022/ngx-tethys-flexible-text.mjs.map +1 -1
- package/fesm2022/ngx-tethys-grid.mjs +10 -15
- package/fesm2022/ngx-tethys-grid.mjs.map +1 -1
- package/fesm2022/ngx-tethys-icon.mjs +44 -59
- package/fesm2022/ngx-tethys-icon.mjs.map +1 -1
- package/fesm2022/ngx-tethys-image.mjs +40 -36
- package/fesm2022/ngx-tethys-image.mjs.map +1 -1
- package/fesm2022/ngx-tethys-input-number.mjs.map +1 -1
- package/fesm2022/ngx-tethys-progress.mjs +7 -11
- package/fesm2022/ngx-tethys-progress.mjs.map +1 -1
- package/fesm2022/ngx-tethys-property.mjs +8 -19
- package/fesm2022/ngx-tethys-property.mjs.map +1 -1
- package/fesm2022/ngx-tethys-radio.mjs +42 -54
- package/fesm2022/ngx-tethys-radio.mjs.map +1 -1
- package/fesm2022/ngx-tethys-rate.mjs +115 -157
- package/fesm2022/ngx-tethys-rate.mjs.map +1 -1
- package/fesm2022/ngx-tethys-resizable.mjs +111 -157
- package/fesm2022/ngx-tethys-resizable.mjs.map +1 -1
- package/fesm2022/ngx-tethys-segment.mjs +84 -103
- package/fesm2022/ngx-tethys-segment.mjs.map +1 -1
- package/fesm2022/ngx-tethys-shared.mjs +2 -1
- package/fesm2022/ngx-tethys-shared.mjs.map +1 -1
- package/fesm2022/ngx-tethys-slide.mjs +37 -56
- package/fesm2022/ngx-tethys-slide.mjs.map +1 -1
- package/fesm2022/ngx-tethys-slider.mjs.map +1 -1
- package/fesm2022/ngx-tethys-space.mjs +2 -8
- package/fesm2022/ngx-tethys-space.mjs.map +1 -1
- package/fesm2022/ngx-tethys-strength.mjs +52 -66
- package/fesm2022/ngx-tethys-strength.mjs.map +1 -1
- package/fesm2022/ngx-tethys-transfer.mjs +98 -119
- package/fesm2022/ngx-tethys-transfer.mjs.map +1 -1
- package/fesm2022/ngx-tethys-tree-select.mjs +2 -4
- package/fesm2022/ngx-tethys-tree-select.mjs.map +1 -1
- package/fesm2022/ngx-tethys-tree.mjs +281 -401
- package/fesm2022/ngx-tethys-tree.mjs.map +1 -1
- package/fesm2022/ngx-tethys-upload.mjs +2 -2
- package/fesm2022/ngx-tethys-upload.mjs.map +1 -1
- package/fesm2022/ngx-tethys-vote.mjs +53 -99
- package/fesm2022/ngx-tethys-vote.mjs.map +1 -1
- package/fesm2022/ngx-tethys.mjs +1 -1
- package/fesm2022/ngx-tethys.mjs.map +1 -1
- package/flexible-text/flexible-text.component.d.ts +9 -15
- package/grid/flex.d.ts +1 -3
- package/grid/thy-row.directive.d.ts +1 -4
- package/icon/icon.component.d.ts +10 -18
- package/image/image.directive.d.ts +10 -13
- package/image/image.token.d.ts +5 -5
- package/input-number/input-number.component.d.ts +1 -1
- package/package.json +1 -1
- package/progress/progress-circle.component.d.ts +3 -5
- package/progress/progress.component.d.ts +2 -4
- package/property/properties.component.d.ts +0 -2
- package/property/property-item.component.d.ts +3 -10
- package/radio/group/radio-group.component.d.ts +5 -9
- package/rate/rate-item.component.d.ts +8 -11
- package/rate/rate.component.d.ts +18 -29
- package/resizable/resizable.directive.d.ts +18 -31
- package/resizable/resize-handle.component.d.ts +6 -7
- package/resizable/resize-handles.component.d.ts +5 -9
- package/schematics/version.d.ts +1 -1
- package/schematics/version.js +1 -1
- package/segment/segment-item.component.d.ts +9 -15
- package/segment/segment.component.d.ts +11 -15
- package/segment/segment.token.d.ts +4 -3
- package/slide/slide-body/slide-body-section.component.d.ts +2 -6
- package/slide/slide-header/slide-header.component.d.ts +6 -9
- package/space/space.component.d.ts +5 -11
- package/strength/strength.component.d.ts +8 -13
- package/transfer/transfer-list.component.d.ts +15 -15
- package/transfer/transfer.component.d.ts +20 -23
- package/tree/tree-abstract.d.ts +5 -5
- package/tree/tree-node.component.d.ts +24 -37
- package/tree/tree.class.d.ts +4 -4
- package/tree/tree.component.d.ts +47 -75
- package/tree/tree.service.d.ts +3 -4
- package/tree-select/tree-select.component.d.ts +2 -2
- package/vote/vote.component.d.ts +13 -33
|
@@ -8,14 +8,15 @@ import { ThySharedModule, ThyOptionModule } from 'ngx-tethys/shared';
|
|
|
8
8
|
import { CdkVirtualScrollViewport, CdkFixedSizeVirtualScroll, CdkVirtualForOf, ScrollingModule } from '@angular/cdk/scrolling';
|
|
9
9
|
import { NgClass, NgStyle, NgTemplateOutlet, DOCUMENT, CommonModule } from '@angular/common';
|
|
10
10
|
import * as i0 from '@angular/core';
|
|
11
|
-
import { InjectionToken, Injectable, inject,
|
|
11
|
+
import { InjectionToken, signal, Injectable, inject, input, output, contentChild, viewChild, numberAttribute, computed, ViewEncapsulation, Component, Pipe, DestroyRef, model, viewChildren, effect, afterNextRender, forwardRef, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
|
12
12
|
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
|
|
13
|
-
import { BehaviorSubject, Subject } from 'rxjs';
|
|
14
13
|
import { isArray, helpers, isFunction, coerceArray, coerceBooleanProperty } from 'ngx-tethys/util';
|
|
14
|
+
import { Subject } from 'rxjs';
|
|
15
15
|
import { useHostRenderer } from '@tethys/cdk/dom';
|
|
16
16
|
import { SelectionModel } from '@angular/cdk/collections';
|
|
17
17
|
import { CdkDrag, CdkDropList, DragDropModule } from '@angular/cdk/drag-drop';
|
|
18
|
-
import {
|
|
18
|
+
import { filter } from 'rxjs/operators';
|
|
19
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
19
20
|
|
|
20
21
|
const THY_TREE_ABSTRACT_TOKEN = new InjectionToken('thy-tree-abstract-token');
|
|
21
22
|
|
|
@@ -142,8 +143,7 @@ function checkStateResolve(node) {
|
|
|
142
143
|
*/
|
|
143
144
|
class ThyTreeService {
|
|
144
145
|
constructor() {
|
|
145
|
-
this.
|
|
146
|
-
this.flattenTreeNodes = [];
|
|
146
|
+
this.flattenTreeNodes = signal([]);
|
|
147
147
|
this.originTreeNodes = [];
|
|
148
148
|
this.treeNodes = [];
|
|
149
149
|
this.checkStateResolve = checkStateResolve;
|
|
@@ -158,9 +158,7 @@ class ThyTreeService {
|
|
|
158
158
|
this.treeNodes = (rootNodes || []).map(node => new ThyTreeNode(node, null, this));
|
|
159
159
|
}
|
|
160
160
|
syncFlattenTreeNodes() {
|
|
161
|
-
this.flattenTreeNodes
|
|
162
|
-
this.flattenNodes$.next(this.flattenTreeNodes);
|
|
163
|
-
return this.flattenTreeNodes;
|
|
161
|
+
this.flattenTreeNodes.set(this.getParallelTreeNodes(this.treeNodes, false));
|
|
164
162
|
}
|
|
165
163
|
getParallelTreeNodes(rootTrees = this.treeNodes, flattenAllNodes = true) {
|
|
166
164
|
const flattenTreeData = [];
|
|
@@ -314,195 +312,169 @@ class ThyTreeNodeComponent {
|
|
|
314
312
|
constructor() {
|
|
315
313
|
this.root = inject(THY_TREE_ABSTRACT_TOKEN);
|
|
316
314
|
this.thyTreeService = inject(ThyTreeService);
|
|
315
|
+
/**
|
|
316
|
+
* node 节点展现所需的数据
|
|
317
|
+
*/
|
|
318
|
+
this.node = input(null);
|
|
317
319
|
/**
|
|
318
320
|
* 设置 TreeNode 是否支持异步加载
|
|
319
321
|
*/
|
|
320
|
-
this.thyAsync = false;
|
|
322
|
+
this.thyAsync = input(false, { transform: coerceBooleanProperty });
|
|
321
323
|
/**
|
|
322
324
|
* 设置 TreeNode 是否支持多选节点
|
|
323
325
|
*/
|
|
324
|
-
this.thyMultiple = false;
|
|
326
|
+
this.thyMultiple = input(false, { transform: coerceBooleanProperty });
|
|
325
327
|
/**
|
|
326
328
|
* 设置 TreeNode 是否支持拖拽排序
|
|
327
329
|
*/
|
|
328
|
-
this.thyDraggable = false;
|
|
330
|
+
this.thyDraggable = input(false, { transform: coerceBooleanProperty });
|
|
329
331
|
/**
|
|
330
332
|
* 设置 TreeNode 是否支持 Checkbox 选择
|
|
331
333
|
*/
|
|
332
|
-
this.thyCheckable = false;
|
|
334
|
+
this.thyCheckable = input(false, { transform: coerceBooleanProperty });
|
|
335
|
+
/**
|
|
336
|
+
* 点击节点的行为,`default` 为选中当前节点,`selectCheckbox` 为选中节点的 Checkbox, `thyCheckable` 为 true 时生效。
|
|
337
|
+
* @default default
|
|
338
|
+
*/
|
|
339
|
+
this.thyClickBehavior = input(undefined);
|
|
340
|
+
/**
|
|
341
|
+
* 设置节点名称是否支持超出截取
|
|
342
|
+
* @default false
|
|
343
|
+
*/
|
|
344
|
+
this.thyTitleTruncate = input(false, { transform: coerceBooleanProperty });
|
|
345
|
+
/**
|
|
346
|
+
* 设置 TreeNode 的渲染模板
|
|
347
|
+
*/
|
|
348
|
+
this.templateRef = input();
|
|
349
|
+
/**
|
|
350
|
+
* 设置子的空数据渲染模板
|
|
351
|
+
*/
|
|
352
|
+
this.emptyChildrenTemplateRef = input();
|
|
333
353
|
/**
|
|
334
354
|
* 设置 node 点击事件
|
|
335
355
|
*/
|
|
336
|
-
this.thyOnClick =
|
|
356
|
+
this.thyOnClick = output();
|
|
337
357
|
/**
|
|
338
358
|
* 双击 node 事件
|
|
339
359
|
*/
|
|
340
|
-
this.thyDblClick =
|
|
360
|
+
this.thyDblClick = output();
|
|
341
361
|
/**
|
|
342
362
|
* 点击展开触发事件
|
|
343
363
|
*/
|
|
344
|
-
this.thyOnExpandChange =
|
|
364
|
+
this.thyOnExpandChange = output();
|
|
345
365
|
/**
|
|
346
366
|
* 设置 check 选择事件
|
|
347
367
|
*/
|
|
348
|
-
this.thyOnCheckboxChange =
|
|
349
|
-
|
|
368
|
+
this.thyOnCheckboxChange = output();
|
|
369
|
+
/**
|
|
370
|
+
* 设置 childrenTree 的渲染模板
|
|
371
|
+
*/
|
|
372
|
+
this.childrenTreeTemplateRef = contentChild('childrenTree');
|
|
373
|
+
/** The native `<div class="thy-tree-node-wrapper thy-sortable-item"></div>` element. */
|
|
374
|
+
this.treeNodeWrapper = viewChild('treeNodeWrapper');
|
|
350
375
|
/**
|
|
351
376
|
* 开启虚拟滚动时,单行节点的高度,当`thySize`为`default`时,该参数才生效
|
|
352
377
|
*/
|
|
353
|
-
this.thyItemSize = 44;
|
|
378
|
+
this.thyItemSize = input(44, { transform: numberAttribute });
|
|
354
379
|
/**
|
|
355
380
|
* 设置节点缩进距离,缩进距离 = thyIndent * node.level
|
|
356
381
|
*/
|
|
357
|
-
this.thyIndent = 25;
|
|
358
|
-
this.
|
|
382
|
+
this.thyIndent = input(25, { transform: numberAttribute });
|
|
383
|
+
this.nodeIcon = computed(() => {
|
|
384
|
+
return this.node().origin.icon;
|
|
385
|
+
});
|
|
386
|
+
this.nodeIconStyle = computed(() => {
|
|
387
|
+
return this.node().origin.iconStyle;
|
|
388
|
+
});
|
|
389
|
+
this.itemClass = computed(() => {
|
|
390
|
+
return this.node()?.itemClass?.join(' ');
|
|
391
|
+
});
|
|
359
392
|
this.checkState = ThyTreeNodeCheckState;
|
|
360
393
|
}
|
|
361
|
-
get nodeIcon() {
|
|
362
|
-
return this.node.origin.icon;
|
|
363
|
-
}
|
|
364
|
-
get nodeIconStyle() {
|
|
365
|
-
return this.node.origin.iconStyle;
|
|
366
|
-
}
|
|
367
394
|
clickNode(event) {
|
|
368
|
-
|
|
395
|
+
const node = this.node();
|
|
396
|
+
if (node.isDisabled) {
|
|
369
397
|
this.expandNode(event);
|
|
370
398
|
}
|
|
371
399
|
else {
|
|
372
|
-
if (this.thyCheckable && this.thyClickBehavior === 'selectCheckbox') {
|
|
400
|
+
if (this.thyCheckable() && this.thyClickBehavior() === 'selectCheckbox') {
|
|
373
401
|
this.clickNodeCheck(event);
|
|
374
402
|
}
|
|
375
403
|
else {
|
|
376
|
-
if (this.root.thyMultiple) {
|
|
377
|
-
this.root.toggleTreeNode(
|
|
404
|
+
if (this.root.thyMultiple()) {
|
|
405
|
+
this.root.toggleTreeNode(node);
|
|
378
406
|
}
|
|
379
407
|
else {
|
|
380
|
-
this.root.selectTreeNode(
|
|
408
|
+
this.root.selectTreeNode(node);
|
|
381
409
|
}
|
|
382
410
|
}
|
|
383
411
|
}
|
|
384
412
|
this.thyOnClick.emit({
|
|
385
413
|
eventName: 'click',
|
|
386
414
|
event: event,
|
|
387
|
-
node:
|
|
415
|
+
node: node
|
|
388
416
|
});
|
|
389
417
|
}
|
|
390
418
|
dbClickNode(event) {
|
|
391
419
|
this.thyDblClick.emit({
|
|
392
420
|
eventName: 'dbclick',
|
|
393
421
|
event: event,
|
|
394
|
-
node: this.node
|
|
422
|
+
node: this.node()
|
|
395
423
|
});
|
|
396
424
|
}
|
|
397
425
|
clickNodeCheck(event) {
|
|
398
426
|
event.stopPropagation();
|
|
399
|
-
|
|
400
|
-
|
|
427
|
+
const node = this.node();
|
|
428
|
+
if (node.isChecked === ThyTreeNodeCheckState.unchecked) {
|
|
429
|
+
node.setChecked(true);
|
|
401
430
|
}
|
|
402
|
-
else if (
|
|
403
|
-
|
|
431
|
+
else if (node.isChecked === ThyTreeNodeCheckState.checked) {
|
|
432
|
+
node.setChecked(false);
|
|
404
433
|
}
|
|
405
|
-
else if (
|
|
406
|
-
if (
|
|
407
|
-
const activeChildren =
|
|
434
|
+
else if (node.isChecked === ThyTreeNodeCheckState.indeterminate) {
|
|
435
|
+
if (node.children?.length) {
|
|
436
|
+
const activeChildren = node.children.filter(item => !item.isDisabled);
|
|
408
437
|
const isAllActiveChildrenChecked = activeChildren.every(item => item.isChecked);
|
|
409
|
-
|
|
438
|
+
node.setChecked(!isAllActiveChildrenChecked);
|
|
410
439
|
}
|
|
411
440
|
else {
|
|
412
|
-
|
|
441
|
+
node.setChecked(true);
|
|
413
442
|
}
|
|
414
443
|
}
|
|
415
444
|
this.thyOnCheckboxChange.emit({
|
|
416
445
|
eventName: 'checkboxChange',
|
|
417
446
|
event: event,
|
|
418
|
-
node:
|
|
447
|
+
node: node
|
|
419
448
|
});
|
|
420
449
|
}
|
|
421
450
|
expandNode(event) {
|
|
422
451
|
event.stopPropagation();
|
|
423
|
-
this.node
|
|
424
|
-
|
|
452
|
+
const node = this.node();
|
|
453
|
+
this.node().setExpanded(!node.isExpanded);
|
|
454
|
+
if (this.root.thyShowExpand()) {
|
|
425
455
|
this.thyOnExpandChange.emit({
|
|
426
456
|
eventName: 'expand',
|
|
427
457
|
event: event,
|
|
428
|
-
node:
|
|
458
|
+
node: node
|
|
429
459
|
});
|
|
430
|
-
if (this.thyAsync &&
|
|
431
|
-
|
|
460
|
+
if (this.thyAsync() && node.children.length === 0) {
|
|
461
|
+
node.setLoading(true);
|
|
432
462
|
}
|
|
433
463
|
}
|
|
434
464
|
}
|
|
435
465
|
isShowExpand(node) {
|
|
436
466
|
return this.root.isShowExpand(node);
|
|
437
467
|
}
|
|
438
|
-
ngOnInit() {
|
|
439
|
-
this.itemClass = this.node?.itemClass?.join(' ');
|
|
440
|
-
}
|
|
441
|
-
ngOnChanges(changes) {
|
|
442
|
-
if (changes.node && !changes.node.isFirstChange()) {
|
|
443
|
-
this.itemClass = changes?.node?.currentValue.itemClass?.join(' ');
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
ngOnDestroy() {
|
|
447
|
-
this.destroy$.next();
|
|
448
|
-
this.destroy$.complete();
|
|
449
|
-
}
|
|
450
468
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyTreeNodeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
451
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.8", type: ThyTreeNodeComponent, isStandalone: true, selector: "thy-tree-node", inputs: { node: "node", thyAsync:
|
|
469
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.8", type: ThyTreeNodeComponent, isStandalone: true, selector: "thy-tree-node", inputs: { node: { classPropertyName: "node", publicName: "node", isSignal: true, isRequired: false, transformFunction: null }, thyAsync: { classPropertyName: "thyAsync", publicName: "thyAsync", isSignal: true, isRequired: false, transformFunction: null }, thyMultiple: { classPropertyName: "thyMultiple", publicName: "thyMultiple", isSignal: true, isRequired: false, transformFunction: null }, thyDraggable: { classPropertyName: "thyDraggable", publicName: "thyDraggable", isSignal: true, isRequired: false, transformFunction: null }, thyCheckable: { classPropertyName: "thyCheckable", publicName: "thyCheckable", isSignal: true, isRequired: false, transformFunction: null }, thyClickBehavior: { classPropertyName: "thyClickBehavior", publicName: "thyClickBehavior", isSignal: true, isRequired: false, transformFunction: null }, thyTitleTruncate: { classPropertyName: "thyTitleTruncate", publicName: "thyTitleTruncate", isSignal: true, isRequired: false, transformFunction: null }, templateRef: { classPropertyName: "templateRef", publicName: "templateRef", isSignal: true, isRequired: false, transformFunction: null }, emptyChildrenTemplateRef: { classPropertyName: "emptyChildrenTemplateRef", publicName: "emptyChildrenTemplateRef", isSignal: true, isRequired: false, transformFunction: null }, thyItemSize: { classPropertyName: "thyItemSize", publicName: "thyItemSize", isSignal: true, isRequired: false, transformFunction: null }, thyIndent: { classPropertyName: "thyIndent", publicName: "thyIndent", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { thyOnClick: "thyOnClick", thyDblClick: "thyDblClick", thyOnExpandChange: "thyOnExpandChange", thyOnCheckboxChange: "thyOnCheckboxChange" }, host: { properties: { "class.thy-tree-node": "true", "class": "itemClass()" } }, queries: [{ propertyName: "childrenTreeTemplateRef", first: true, predicate: ["childrenTree"], descendants: true, isSignal: true }], viewQueries: [{ propertyName: "treeNodeWrapper", first: true, predicate: ["treeNodeWrapper"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n #treeNodeWrapper\n class=\"thy-tree-node-wrapper\"\n [class.active]=\"root.isSelected(node())\"\n [class.disabled]=\"node().isDisabled\"\n [class.expand]=\"node().children.length\"\n [style.height]=\"thyItemSize() + 'px'\"\n (click)=\"clickNode($event)\"\n >\n <span class=\"thy-tree-index\" [style.width.px]=\"node().level * thyIndent()\"></span>\n <span class=\"thy-tree-drag-icon\">\n <thy-icon thyIconName=\"drag\"></thy-icon>\n </span>\n <span class=\"thy-tree-expand\" (click)=\"expandNode($event)\">\n @if (isShowExpand(node())) {\n @if ((node().children && node().children.length > 0) || thyAsync() || emptyChildrenTemplateRef()) {\n @if (root.icons()?.expand && root.icons()?.collapse) {\n <thy-icon\n class=\"thy-tree-expand-icon\"\n [thyIconName]=\"node().isExpanded ? root.icons().expand : root.icons().collapse\"\n ></thy-icon>\n } @else {\n <thy-icon class=\"thy-tree-expand-icon\" [class.collapse]=\"!node().isExpanded\" thyIconName=\"caret-right-down\"></thy-icon>\n }\n }\n }\n </span>\n\n <span class=\"thy-tree-node-content\" (dblclick)=\"dbClickNode($event)\">\n @if (thyCheckable()) {\n <input\n type=\"checkbox\"\n class=\"thy-tree-node-check\"\n [class.form-check-indeterminate]=\"node().isChecked === checkState.indeterminate\"\n [class.form-unchecked]=\"node().isChecked === checkState.unchecked\"\n [checked]=\"node().isChecked === checkState.checked\"\n [disabled]=\"node().isDisabled\"\n (click)=\"clickNodeCheck($event)\"\n />\n }\n @if (!templateRef()) {\n @if (nodeIcon()) {\n <span class=\"thy-tree-node-icon\"> <i [ngClass]=\"nodeIcon()\" [ngStyle]=\"nodeIconStyle()\"></i></span>\n }\n <span [title]=\"node().title\" class=\"thy-tree-node-title\" [class.truncate]=\"thyTitleTruncate()\"> {{ node().title }}</span>\n }\n @if (templateRef()) {\n <ng-template\n [ngTemplateOutlet]=\"templateRef()\"\n [ngTemplateOutletContext]=\"{ $implicit: node(), node: node(), origin: node()?.origin }\"\n ></ng-template>\n }\n </span>\n</div>\n@if (thyAsync()) {\n @if (node().isLoading) {\n <thy-loading [thyDone]=\"!node().isLoading\"></thy-loading>\n }\n}\n", dependencies: [{ kind: "component", type: ThyIcon, selector: "thy-icon, [thy-icon]", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: ThyLoading, selector: "thy-loading", inputs: ["thyDone", "thyTip", "thyIsMask"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
452
470
|
}
|
|
453
471
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyTreeNodeComponent, decorators: [{
|
|
454
472
|
type: Component,
|
|
455
|
-
args: [{ selector: 'thy-tree-node', encapsulation: ViewEncapsulation.None, imports: [ThyIcon, NgClass, NgStyle, NgTemplateOutlet, ThyLoading],
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}],
|
|
459
|
-
|
|
460
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
461
|
-
}], thyMultiple: [{
|
|
462
|
-
type: Input,
|
|
463
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
464
|
-
}], thyDraggable: [{
|
|
465
|
-
type: Input,
|
|
466
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
467
|
-
}], thyCheckable: [{
|
|
468
|
-
type: Input,
|
|
469
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
470
|
-
}], thyClickBehavior: [{
|
|
471
|
-
type: Input
|
|
472
|
-
}], thyTitleTruncate: [{
|
|
473
|
-
type: Input,
|
|
474
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
475
|
-
}], templateRef: [{
|
|
476
|
-
type: Input
|
|
477
|
-
}], emptyChildrenTemplateRef: [{
|
|
478
|
-
type: Input
|
|
479
|
-
}], thyOnClick: [{
|
|
480
|
-
type: Output
|
|
481
|
-
}], thyDblClick: [{
|
|
482
|
-
type: Output
|
|
483
|
-
}], thyOnExpandChange: [{
|
|
484
|
-
type: Output
|
|
485
|
-
}], thyOnCheckboxChange: [{
|
|
486
|
-
type: Output
|
|
487
|
-
}], childrenTreeTemplateRef: [{
|
|
488
|
-
type: ContentChild,
|
|
489
|
-
args: ['childrenTree']
|
|
490
|
-
}], treeNodeWrapper: [{
|
|
491
|
-
type: ViewChild,
|
|
492
|
-
args: ['treeNodeWrapper', { static: true }]
|
|
493
|
-
}], thyTreeNodeClass: [{
|
|
494
|
-
type: HostBinding,
|
|
495
|
-
args: ['class.thy-tree-node']
|
|
496
|
-
}], itemClass: [{
|
|
497
|
-
type: HostBinding,
|
|
498
|
-
args: ['class']
|
|
499
|
-
}], thyItemSize: [{
|
|
500
|
-
type: Input,
|
|
501
|
-
args: [{ transform: numberAttribute }]
|
|
502
|
-
}], thyIndent: [{
|
|
503
|
-
type: Input,
|
|
504
|
-
args: [{ transform: numberAttribute }]
|
|
505
|
-
}] } });
|
|
473
|
+
args: [{ selector: 'thy-tree-node', encapsulation: ViewEncapsulation.None, imports: [ThyIcon, NgClass, NgStyle, NgTemplateOutlet, ThyLoading], host: {
|
|
474
|
+
'[class.thy-tree-node]': 'true',
|
|
475
|
+
'[class]': 'itemClass()'
|
|
476
|
+
}, template: "<div\n #treeNodeWrapper\n class=\"thy-tree-node-wrapper\"\n [class.active]=\"root.isSelected(node())\"\n [class.disabled]=\"node().isDisabled\"\n [class.expand]=\"node().children.length\"\n [style.height]=\"thyItemSize() + 'px'\"\n (click)=\"clickNode($event)\"\n >\n <span class=\"thy-tree-index\" [style.width.px]=\"node().level * thyIndent()\"></span>\n <span class=\"thy-tree-drag-icon\">\n <thy-icon thyIconName=\"drag\"></thy-icon>\n </span>\n <span class=\"thy-tree-expand\" (click)=\"expandNode($event)\">\n @if (isShowExpand(node())) {\n @if ((node().children && node().children.length > 0) || thyAsync() || emptyChildrenTemplateRef()) {\n @if (root.icons()?.expand && root.icons()?.collapse) {\n <thy-icon\n class=\"thy-tree-expand-icon\"\n [thyIconName]=\"node().isExpanded ? root.icons().expand : root.icons().collapse\"\n ></thy-icon>\n } @else {\n <thy-icon class=\"thy-tree-expand-icon\" [class.collapse]=\"!node().isExpanded\" thyIconName=\"caret-right-down\"></thy-icon>\n }\n }\n }\n </span>\n\n <span class=\"thy-tree-node-content\" (dblclick)=\"dbClickNode($event)\">\n @if (thyCheckable()) {\n <input\n type=\"checkbox\"\n class=\"thy-tree-node-check\"\n [class.form-check-indeterminate]=\"node().isChecked === checkState.indeterminate\"\n [class.form-unchecked]=\"node().isChecked === checkState.unchecked\"\n [checked]=\"node().isChecked === checkState.checked\"\n [disabled]=\"node().isDisabled\"\n (click)=\"clickNodeCheck($event)\"\n />\n }\n @if (!templateRef()) {\n @if (nodeIcon()) {\n <span class=\"thy-tree-node-icon\"> <i [ngClass]=\"nodeIcon()\" [ngStyle]=\"nodeIconStyle()\"></i></span>\n }\n <span [title]=\"node().title\" class=\"thy-tree-node-title\" [class.truncate]=\"thyTitleTruncate()\"> {{ node().title }}</span>\n }\n @if (templateRef()) {\n <ng-template\n [ngTemplateOutlet]=\"templateRef()\"\n [ngTemplateOutletContext]=\"{ $implicit: node(), node: node(), origin: node()?.origin }\"\n ></ng-template>\n }\n </span>\n</div>\n@if (thyAsync()) {\n @if (node().isLoading) {\n <thy-loading [thyDone]=\"!node().isLoading\"></thy-loading>\n }\n}\n" }]
|
|
477
|
+
}] });
|
|
506
478
|
|
|
507
479
|
/**
|
|
508
480
|
* @private
|
|
@@ -540,187 +512,199 @@ const treeItemSizeMap = {
|
|
|
540
512
|
* @name thy-tree
|
|
541
513
|
*/
|
|
542
514
|
class ThyTree {
|
|
515
|
+
get treeNodes() {
|
|
516
|
+
return this.thyTreeService.treeNodes;
|
|
517
|
+
}
|
|
543
518
|
constructor() {
|
|
544
519
|
this.thyTreeService = inject(ThyTreeService);
|
|
545
|
-
this.cdr = inject(ChangeDetectorRef);
|
|
546
520
|
this.document = inject(DOCUMENT);
|
|
547
|
-
this.
|
|
521
|
+
this.destroyRef = inject(DestroyRef);
|
|
548
522
|
this.hostRenderer = useHostRenderer();
|
|
549
523
|
this._onTouched = () => { };
|
|
550
524
|
this._onChange = (_) => { };
|
|
551
|
-
this.destroy$ = new Subject();
|
|
552
525
|
// 缓存 Element 和 DragRef 的关系,方便在 Item 拖动时查找
|
|
553
526
|
this.nodeDragsMap = new Map();
|
|
554
527
|
this.nodeDragMoved = new Subject();
|
|
555
528
|
this.dropEnterPredicate = context => {
|
|
556
529
|
return (this.isShowExpand(context.target) || (!this.isShowExpand(context.target) && context.dropPosition !== ThyTreeDropPosition.in));
|
|
557
530
|
};
|
|
558
|
-
this.flattenTreeNodes =
|
|
531
|
+
this.flattenTreeNodes = computed(() => this.thyTreeService.flattenTreeNodes());
|
|
532
|
+
/**
|
|
533
|
+
* 虚拟化滚动的视口
|
|
534
|
+
*/
|
|
535
|
+
this.viewport = viewChild('viewport');
|
|
536
|
+
/**
|
|
537
|
+
* TreeNode 展现所需的数据
|
|
538
|
+
* @type ThyTreeNodeData[]
|
|
539
|
+
*/
|
|
540
|
+
this.thyNodes = model(undefined);
|
|
559
541
|
/**
|
|
560
542
|
* 设置 TreeNode 是否支持展开
|
|
561
543
|
* @type boolean | Function
|
|
562
544
|
*/
|
|
563
|
-
this.thyShowExpand = true;
|
|
545
|
+
this.thyShowExpand = input(true);
|
|
564
546
|
/**
|
|
565
547
|
* 设置是否支持多选节点
|
|
566
548
|
*/
|
|
567
|
-
this.thyMultiple = false;
|
|
549
|
+
this.thyMultiple = input(false, { transform: coerceBooleanProperty });
|
|
550
|
+
/**
|
|
551
|
+
* 设置 TreeNode 是否支持拖拽排序
|
|
552
|
+
* @default false
|
|
553
|
+
*/
|
|
554
|
+
this.thyDraggable = input(false, { transform: coerceBooleanProperty });
|
|
555
|
+
/**
|
|
556
|
+
* 设置 TreeNode 是否支持 Checkbox 选择
|
|
557
|
+
* @default false
|
|
558
|
+
*/
|
|
559
|
+
this.thyCheckable = input(false, { transform: coerceBooleanProperty });
|
|
568
560
|
/**
|
|
569
561
|
* 点击节点的行为,`default` 为选中当前节点,`selectCheckbox` 为选中节点的 Checkbox, `thyCheckable` 为 true 时生效。
|
|
570
562
|
*/
|
|
571
|
-
this.thyClickBehavior = 'default';
|
|
563
|
+
this.thyClickBehavior = input('default');
|
|
564
|
+
/**
|
|
565
|
+
* 设置 check 状态的计算策略
|
|
566
|
+
*/
|
|
567
|
+
this.thyCheckStateResolve = input();
|
|
572
568
|
/**
|
|
573
569
|
* 设置 TreeNode 是否支持异步加载
|
|
574
570
|
*/
|
|
575
|
-
this.thyAsync = false;
|
|
576
|
-
|
|
571
|
+
this.thyAsync = input(false, { transform: coerceBooleanProperty });
|
|
572
|
+
/**
|
|
573
|
+
* 设置不同展示类型的 Tree,`default` 为小箭头展示, `especial` 为 加减号图标展示
|
|
574
|
+
* @type ThyTreeType
|
|
575
|
+
* @default default
|
|
576
|
+
*/
|
|
577
|
+
this.thyType = input('default');
|
|
577
578
|
/**
|
|
578
579
|
* 设置不同 Tree 展开折叠的图标,`expand` 为展开状态的图标,`collapse` 为折叠状态的图标
|
|
579
580
|
* @type { expand: string, collapse: string }
|
|
580
581
|
*/
|
|
581
|
-
this.thyIcons = {};
|
|
582
|
-
|
|
582
|
+
this.thyIcons = input({});
|
|
583
|
+
/**
|
|
584
|
+
* 支持 `sm` | `default` 两种大小,默认值为 `default`
|
|
585
|
+
* @type ThyTreeSize
|
|
586
|
+
* @default default
|
|
587
|
+
*/
|
|
588
|
+
this.thySize = input('default');
|
|
583
589
|
/**
|
|
584
590
|
* 设置是否开启虚拟滚动
|
|
585
591
|
*/
|
|
586
|
-
this.thyVirtualScroll = false;
|
|
587
|
-
|
|
592
|
+
this.thyVirtualScroll = input(false, { transform: coerceBooleanProperty });
|
|
593
|
+
/**
|
|
594
|
+
* 开启虚拟滚动时,单行节点的高度,当`thySize`为`default`时,该参数才生效
|
|
595
|
+
* @default 44
|
|
596
|
+
*/
|
|
597
|
+
this.thyItemSize = input(44, {
|
|
598
|
+
transform: value => {
|
|
599
|
+
if (value && this.thySize() !== 'default') {
|
|
600
|
+
throw new Error('setting thySize and thyItemSize at the same time is not allowed');
|
|
601
|
+
}
|
|
602
|
+
return numberAttribute(value);
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
this.icons = computed(() => {
|
|
606
|
+
if (this.thyType() === 'especial') {
|
|
607
|
+
return { expand: 'minus-square', collapse: 'plus-square' };
|
|
608
|
+
}
|
|
609
|
+
return this.thyIcons();
|
|
610
|
+
});
|
|
611
|
+
this.itemSize = computed(() => {
|
|
612
|
+
const itemSize = this.thyItemSize();
|
|
613
|
+
const size = this.thySize();
|
|
614
|
+
if (size === 'default') {
|
|
615
|
+
return itemSize || treeItemSizeMap.default;
|
|
616
|
+
}
|
|
617
|
+
else if (size) {
|
|
618
|
+
return treeItemSizeMap[size] || treeItemSizeMap.default;
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
return treeItemSizeMap.default;
|
|
622
|
+
}
|
|
623
|
+
});
|
|
588
624
|
/**
|
|
589
625
|
* 设置节点名称是否支持超出截取
|
|
590
626
|
* @type boolean
|
|
591
627
|
*/
|
|
592
|
-
this.thyTitleTruncate = true;
|
|
628
|
+
this.thyTitleTruncate = input(true, { transform: coerceBooleanProperty });
|
|
629
|
+
/**
|
|
630
|
+
* 已选中的 node 节点集合
|
|
631
|
+
* @default []
|
|
632
|
+
*/
|
|
633
|
+
this.thySelectedKeys = input(undefined);
|
|
634
|
+
/**
|
|
635
|
+
* 展开指定的树节点
|
|
636
|
+
*/
|
|
637
|
+
this.thyExpandedKeys = input(undefined);
|
|
593
638
|
/**
|
|
594
639
|
* 是否展开所有树节点
|
|
595
640
|
*/
|
|
596
|
-
this.thyExpandAll = false;
|
|
641
|
+
this.thyExpandAll = input(false, { transform: coerceBooleanProperty });
|
|
597
642
|
/**
|
|
598
643
|
* 设置缩进距离,缩进距离 = thyIndent * node.level
|
|
599
644
|
* @type number
|
|
600
645
|
*/
|
|
601
|
-
this.thyIndent = 25;
|
|
646
|
+
this.thyIndent = input(25, { transform: numberAttribute });
|
|
647
|
+
/**
|
|
648
|
+
* 拖拽之前的回调,函数返回 false 则阻止拖拽
|
|
649
|
+
*/
|
|
650
|
+
this.thyBeforeDragStart = input(undefined);
|
|
651
|
+
/**
|
|
652
|
+
* 拖放到元素时回调,函数返回 false 则阻止拖放到当前元素
|
|
653
|
+
*/
|
|
654
|
+
this.thyBeforeDragDrop = input(undefined);
|
|
602
655
|
/**
|
|
603
656
|
* 设置子 TreeNode 点击事件
|
|
604
657
|
*/
|
|
605
|
-
this.thyOnClick =
|
|
658
|
+
this.thyOnClick = output();
|
|
606
659
|
/**
|
|
607
660
|
* 设置 check 选择事件
|
|
608
661
|
*/
|
|
609
|
-
this.thyOnCheckboxChange =
|
|
662
|
+
this.thyOnCheckboxChange = output();
|
|
610
663
|
/**
|
|
611
664
|
* 设置点击展开触发事件
|
|
612
665
|
*/
|
|
613
|
-
this.thyOnExpandChange =
|
|
666
|
+
this.thyOnExpandChange = output();
|
|
614
667
|
/**
|
|
615
668
|
* 设置 TreeNode 拖拽事件
|
|
616
669
|
*/
|
|
617
|
-
this.thyOnDragDrop =
|
|
670
|
+
this.thyOnDragDrop = output();
|
|
618
671
|
/**
|
|
619
672
|
* 双击 TreeNode 事件
|
|
620
673
|
*/
|
|
621
|
-
this.thyDblClick =
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
}
|
|
638
|
-
/**
|
|
639
|
-
* 设置 check 状态的计算策略
|
|
640
|
-
*/
|
|
641
|
-
set thyCheckStateResolve(resolve) {
|
|
642
|
-
if (resolve) {
|
|
643
|
-
this.thyTreeService.setCheckStateResolve(resolve);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
/**
|
|
647
|
-
* 设置不同展示类型的 Tree,`default` 为小箭头展示, `especial` 为 加减号图标展示
|
|
648
|
-
* @type ThyTreeType
|
|
649
|
-
* @default default
|
|
650
|
-
*/
|
|
651
|
-
set thyType(type) {
|
|
652
|
-
this._thyType = type;
|
|
653
|
-
if (type === 'especial') {
|
|
654
|
-
this.thyIcons = { expand: 'minus-square', collapse: 'plus-square' };
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
get thyType() {
|
|
658
|
-
return this._thyType;
|
|
659
|
-
}
|
|
660
|
-
/**
|
|
661
|
-
* 支持 `sm` | `default` 两种大小,默认值为 `default`
|
|
662
|
-
* @type ThyTreeSize
|
|
663
|
-
* @default default
|
|
664
|
-
*/
|
|
665
|
-
set thySize(size) {
|
|
666
|
-
this._thySize = size;
|
|
667
|
-
if (this._thySize) {
|
|
668
|
-
this._thyItemSize = treeItemSizeMap[this._thySize];
|
|
669
|
-
}
|
|
670
|
-
else {
|
|
671
|
-
this._thyItemSize = treeItemSizeMap.default;
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
get thySize() {
|
|
675
|
-
return this._thySize;
|
|
676
|
-
}
|
|
677
|
-
/**
|
|
678
|
-
* 开启虚拟滚动时,单行节点的高度,当`thySize`为`default`时,该参数才生效
|
|
679
|
-
* @default 44
|
|
680
|
-
*/
|
|
681
|
-
set thyItemSize(itemSize) {
|
|
682
|
-
if (this.thySize !== 'default') {
|
|
683
|
-
throw new Error('setting thySize and thyItemSize at the same time is not allowed');
|
|
684
|
-
}
|
|
685
|
-
this._thyItemSize = itemSize;
|
|
686
|
-
}
|
|
687
|
-
get thyItemSize() {
|
|
688
|
-
return this._thyItemSize;
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* 设置 TreeNode 的渲染模板
|
|
692
|
-
*/
|
|
693
|
-
set templateRef(template) {
|
|
694
|
-
if (template) {
|
|
695
|
-
this._templateRef = template;
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
get templateRef() {
|
|
699
|
-
return this._templateRef;
|
|
700
|
-
}
|
|
701
|
-
set emptyChildrenTemplateRef(template) {
|
|
702
|
-
if (template) {
|
|
703
|
-
this._emptyChildrenTemplateRef = template;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
get emptyChildrenTemplateRef() {
|
|
707
|
-
return this._emptyChildrenTemplateRef;
|
|
708
|
-
}
|
|
709
|
-
ngOnInit() {
|
|
710
|
-
this._initThyNodes();
|
|
711
|
-
this._setTreeType();
|
|
712
|
-
this._setTreeSize();
|
|
713
|
-
this._instanceSelectionModel();
|
|
714
|
-
this._selectTreeNodes(this.thySelectedKeys);
|
|
715
|
-
this.thyTreeService.flattenNodes$.subscribe(flattenTreeNodes => {
|
|
716
|
-
this.flattenTreeNodes = flattenTreeNodes;
|
|
717
|
-
this.cdr.markForCheck();
|
|
674
|
+
this.thyDblClick = output();
|
|
675
|
+
/**
|
|
676
|
+
* 设置 TreeNode 的渲染模板
|
|
677
|
+
*/
|
|
678
|
+
this.templateRef = contentChild('treeNodeTemplate');
|
|
679
|
+
/**
|
|
680
|
+
* 设置子的空数据渲染模板
|
|
681
|
+
*/
|
|
682
|
+
this.emptyChildrenTemplate = contentChild('emptyChildrenTemplate');
|
|
683
|
+
this.dragging = signal(false);
|
|
684
|
+
this.cdkDrags = viewChildren(CdkDrag);
|
|
685
|
+
effect(() => {
|
|
686
|
+
const resolve = this.thyCheckStateResolve();
|
|
687
|
+
if (resolve) {
|
|
688
|
+
this.thyTreeService.setCheckStateResolve(resolve);
|
|
689
|
+
}
|
|
718
690
|
});
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
.
|
|
691
|
+
effect(() => {
|
|
692
|
+
this.initThyNodes();
|
|
693
|
+
});
|
|
694
|
+
effect(() => {
|
|
695
|
+
this.setTreeSize();
|
|
696
|
+
});
|
|
697
|
+
effect(() => {
|
|
698
|
+
this.setTreeType();
|
|
699
|
+
});
|
|
700
|
+
effect(() => {
|
|
701
|
+
this.instanceSelectionModel();
|
|
702
|
+
});
|
|
703
|
+
effect(() => {
|
|
704
|
+
this.selectTreeNodes(this.thySelectedKeys());
|
|
705
|
+
});
|
|
706
|
+
effect(() => {
|
|
707
|
+
const drags = this.cdkDrags();
|
|
724
708
|
this.nodeDragsMap.clear();
|
|
725
709
|
drags.forEach(drag => {
|
|
726
710
|
if (drag.data) {
|
|
@@ -729,36 +713,17 @@ class ThyTree {
|
|
|
729
713
|
}
|
|
730
714
|
});
|
|
731
715
|
});
|
|
732
|
-
|
|
733
|
-
.
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
716
|
+
afterNextRender(() => {
|
|
717
|
+
this.nodeDragMoved
|
|
718
|
+
.pipe(
|
|
719
|
+
// auditTime(30),
|
|
720
|
+
// auditTime 可能会导致拖动结束后仍然执行 moved ,所以通过判断 dragging 状态来过滤无效 moved
|
|
721
|
+
filter((event) => event.source._dragRef.isDragging()), takeUntilDestroyed(this.destroyRef))
|
|
722
|
+
.subscribe(event => {
|
|
723
|
+
this.onDragMoved(event);
|
|
724
|
+
});
|
|
739
725
|
});
|
|
740
726
|
}
|
|
741
|
-
ngOnChanges(changes) {
|
|
742
|
-
if (changes.thyNodes && !changes.thyNodes.isFirstChange()) {
|
|
743
|
-
this._initThyNodes();
|
|
744
|
-
}
|
|
745
|
-
if (changes.thyType && !changes.thyType.isFirstChange()) {
|
|
746
|
-
this._setTreeType();
|
|
747
|
-
}
|
|
748
|
-
if (changes.thyMultiple && !changes.thyMultiple.isFirstChange()) {
|
|
749
|
-
this._instanceSelectionModel();
|
|
750
|
-
}
|
|
751
|
-
if (changes.thySelectedKeys && !changes.thySelectedKeys.isFirstChange()) {
|
|
752
|
-
this._selectedKeys = changes.thySelectedKeys.currentValue;
|
|
753
|
-
this._selectTreeNodes(changes.thySelectedKeys.currentValue);
|
|
754
|
-
}
|
|
755
|
-
if (changes.thyExpandedKeys && !changes.thyExpandedKeys.isFirstChange()) {
|
|
756
|
-
this._handleExpandedKeys();
|
|
757
|
-
}
|
|
758
|
-
if (changes.thyExpandAll && !changes.thyExpandAll.isFirstChange()) {
|
|
759
|
-
this._handleExpandedKeys();
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
727
|
eventTriggerChanged(event) {
|
|
763
728
|
switch (event.eventName) {
|
|
764
729
|
case 'expand':
|
|
@@ -769,36 +734,40 @@ class ThyTree {
|
|
|
769
734
|
break;
|
|
770
735
|
}
|
|
771
736
|
}
|
|
772
|
-
|
|
773
|
-
this.
|
|
774
|
-
this.
|
|
775
|
-
this.thyTreeService.initializeTreeNodes(this.thyNodes);
|
|
776
|
-
this.
|
|
777
|
-
this.
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
737
|
+
initThyNodes() {
|
|
738
|
+
this.expandedKeys = this.getExpandedNodes().map(node => node.key);
|
|
739
|
+
this.selectedKeys = this.getSelectedNodes().map(node => node.key);
|
|
740
|
+
this.thyTreeService.initializeTreeNodes(this.thyNodes());
|
|
741
|
+
this.selectTreeNodes(this.selectedKeys);
|
|
742
|
+
this.handleExpandedKeys();
|
|
743
|
+
}
|
|
744
|
+
handleExpandedKeys() {
|
|
745
|
+
if (this.thyExpandAll()) {
|
|
746
|
+
this.thyTreeService.expandTreeNodes(true);
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
this.expandedKeys = helpers.concatArray((this.thyExpandedKeys() || []).filter(key => !this.expandedKeys.includes(key)), this.expandedKeys);
|
|
750
|
+
this.thyTreeService.expandTreeNodes(this.expandedKeys);
|
|
783
751
|
}
|
|
784
|
-
this.thyTreeService.expandTreeNodes(this.thyExpandAll || this._expandedKeys);
|
|
785
752
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
753
|
+
setTreeType() {
|
|
754
|
+
const type = this.thyType();
|
|
755
|
+
if (type && treeTypeClassMap[type]) {
|
|
756
|
+
treeTypeClassMap[type].forEach(className => {
|
|
789
757
|
this.hostRenderer.addClass(className);
|
|
790
758
|
});
|
|
791
759
|
}
|
|
792
760
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
761
|
+
setTreeSize() {
|
|
762
|
+
const size = this.thySize();
|
|
763
|
+
if (size) {
|
|
764
|
+
this.hostRenderer.addClass(`thy-tree-${size}`);
|
|
796
765
|
}
|
|
797
766
|
}
|
|
798
|
-
|
|
799
|
-
this.
|
|
767
|
+
instanceSelectionModel() {
|
|
768
|
+
this.selectionModel = new SelectionModel(this.thyMultiple());
|
|
800
769
|
}
|
|
801
|
-
|
|
770
|
+
selectTreeNodes(keys) {
|
|
802
771
|
(keys || []).forEach(key => {
|
|
803
772
|
const node = this.thyTreeService.getTreeNode(key);
|
|
804
773
|
if (node) {
|
|
@@ -807,28 +776,28 @@ class ThyTree {
|
|
|
807
776
|
});
|
|
808
777
|
}
|
|
809
778
|
isSelected(node) {
|
|
810
|
-
return this.
|
|
779
|
+
return this.selectionModel.isSelected(node);
|
|
811
780
|
}
|
|
812
781
|
toggleTreeNode(node) {
|
|
813
782
|
if (node && !node.isDisabled) {
|
|
814
|
-
this.
|
|
783
|
+
this.selectionModel.toggle(node);
|
|
815
784
|
}
|
|
816
785
|
}
|
|
817
786
|
trackByFn(index, item) {
|
|
818
787
|
return item.key || index;
|
|
819
788
|
}
|
|
820
789
|
isShowExpand(node) {
|
|
821
|
-
|
|
822
|
-
|
|
790
|
+
const thyShowExpand = this.thyShowExpand();
|
|
791
|
+
if (helpers.isFunction(thyShowExpand)) {
|
|
792
|
+
return thyShowExpand(node);
|
|
823
793
|
}
|
|
824
794
|
else {
|
|
825
|
-
return
|
|
795
|
+
return thyShowExpand;
|
|
826
796
|
}
|
|
827
797
|
}
|
|
828
798
|
writeValue(value) {
|
|
829
799
|
if (value) {
|
|
830
|
-
this.thyNodes
|
|
831
|
-
this._initThyNodes();
|
|
800
|
+
this.thyNodes.set(value);
|
|
832
801
|
}
|
|
833
802
|
}
|
|
834
803
|
registerOnChange(fn) {
|
|
@@ -838,7 +807,7 @@ class ThyTree {
|
|
|
838
807
|
this._onTouched = fn;
|
|
839
808
|
}
|
|
840
809
|
onDragStarted(event) {
|
|
841
|
-
this.dragging
|
|
810
|
+
this.dragging.set(true);
|
|
842
811
|
this.startDragNodeClone = Object.assign({}, event.source.data);
|
|
843
812
|
if (event.source.data.isExpanded) {
|
|
844
813
|
event.source.data.setExpanded(false);
|
|
@@ -886,7 +855,7 @@ class ThyTree {
|
|
|
886
855
|
}
|
|
887
856
|
}
|
|
888
857
|
onDragEnded(event) {
|
|
889
|
-
this.dragging
|
|
858
|
+
this.dragging.set(false);
|
|
890
859
|
// 拖拽结束后恢复原始的展开状态
|
|
891
860
|
event.source.data.setExpanded(this.startDragNodeClone.isExpanded);
|
|
892
861
|
setTimeout(() => {
|
|
@@ -903,7 +872,7 @@ class ThyTree {
|
|
|
903
872
|
}
|
|
904
873
|
const sourceNode = this.startDragNodeClone;
|
|
905
874
|
const sourceNodeParent = sourceNode.parentNode;
|
|
906
|
-
const targetDragRef = this.cdkDrags.find(item => item.data?.key === this.nodeDropTarget.key);
|
|
875
|
+
const targetDragRef = this.cdkDrags().find(item => item.data?.key === this.nodeDropTarget.key);
|
|
907
876
|
const targetNode = targetDragRef?.data;
|
|
908
877
|
const targetNodeParent = targetNode.parentNode;
|
|
909
878
|
const beforeDragDropContext = {
|
|
@@ -913,7 +882,8 @@ class ThyTree {
|
|
|
913
882
|
containerItems: targetNodeParent?.children,
|
|
914
883
|
position: this.nodeDropTarget.position
|
|
915
884
|
};
|
|
916
|
-
|
|
885
|
+
const thyBeforeDragDrop = this.thyBeforeDragDrop();
|
|
886
|
+
if (thyBeforeDragDrop && !thyBeforeDragDrop(beforeDragDropContext)) {
|
|
917
887
|
this.cleanupDragArtifacts();
|
|
918
888
|
return;
|
|
919
889
|
}
|
|
@@ -986,21 +956,18 @@ class ThyTree {
|
|
|
986
956
|
// region Public Functions
|
|
987
957
|
selectTreeNode(node) {
|
|
988
958
|
if (node && !node.isDisabled) {
|
|
989
|
-
this.
|
|
959
|
+
this.selectionModel.select(node);
|
|
990
960
|
this.thyTreeService.syncFlattenTreeNodes();
|
|
991
961
|
}
|
|
992
962
|
}
|
|
993
|
-
getRootNodes() {
|
|
994
|
-
return this.treeNodes;
|
|
995
|
-
}
|
|
996
963
|
getTreeNode(key) {
|
|
997
964
|
return this.thyTreeService.getTreeNode(key);
|
|
998
965
|
}
|
|
999
966
|
getSelectedNode() {
|
|
1000
|
-
return this.
|
|
967
|
+
return this.selectionModel ? this.selectionModel.selected[0] : null;
|
|
1001
968
|
}
|
|
1002
969
|
getSelectedNodes() {
|
|
1003
|
-
return this.
|
|
970
|
+
return this.selectionModel ? this.selectionModel.selected : [];
|
|
1004
971
|
}
|
|
1005
972
|
getExpandedNodes() {
|
|
1006
973
|
return this.thyTreeService.getExpandedNodes();
|
|
@@ -1014,26 +981,21 @@ class ThyTree {
|
|
|
1014
981
|
}
|
|
1015
982
|
deleteTreeNode(node) {
|
|
1016
983
|
if (this.isSelected(node)) {
|
|
1017
|
-
this.
|
|
984
|
+
this.selectionModel.toggle(node);
|
|
1018
985
|
}
|
|
1019
986
|
this.thyTreeService.deleteTreeNode(node);
|
|
1020
987
|
this.thyTreeService.syncFlattenTreeNodes();
|
|
1021
988
|
}
|
|
1022
989
|
expandAllNodes() {
|
|
1023
|
-
const nodes = this.
|
|
990
|
+
const nodes = this.treeNodes;
|
|
1024
991
|
nodes.forEach(n => n.setExpanded(true, true));
|
|
1025
992
|
}
|
|
1026
993
|
collapsedAllNodes() {
|
|
1027
|
-
const nodes = this.
|
|
994
|
+
const nodes = this.treeNodes;
|
|
1028
995
|
nodes.forEach(n => n.setExpanded(false, true));
|
|
1029
996
|
}
|
|
1030
|
-
// endregion
|
|
1031
|
-
ngOnDestroy() {
|
|
1032
|
-
this.destroy$.next();
|
|
1033
|
-
this.destroy$.complete();
|
|
1034
|
-
}
|
|
1035
997
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyTree, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1036
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.8", type: ThyTree, isStandalone: true, selector: "thy-tree", inputs: { thyNodes: "thyNodes", thyShowExpand: "thyShowExpand", thyMultiple:
|
|
998
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.8", type: ThyTree, isStandalone: true, selector: "thy-tree", inputs: { thyNodes: { classPropertyName: "thyNodes", publicName: "thyNodes", isSignal: true, isRequired: false, transformFunction: null }, thyShowExpand: { classPropertyName: "thyShowExpand", publicName: "thyShowExpand", isSignal: true, isRequired: false, transformFunction: null }, thyMultiple: { classPropertyName: "thyMultiple", publicName: "thyMultiple", isSignal: true, isRequired: false, transformFunction: null }, thyDraggable: { classPropertyName: "thyDraggable", publicName: "thyDraggable", isSignal: true, isRequired: false, transformFunction: null }, thyCheckable: { classPropertyName: "thyCheckable", publicName: "thyCheckable", isSignal: true, isRequired: false, transformFunction: null }, thyClickBehavior: { classPropertyName: "thyClickBehavior", publicName: "thyClickBehavior", isSignal: true, isRequired: false, transformFunction: null }, thyCheckStateResolve: { classPropertyName: "thyCheckStateResolve", publicName: "thyCheckStateResolve", isSignal: true, isRequired: false, transformFunction: null }, thyAsync: { classPropertyName: "thyAsync", publicName: "thyAsync", isSignal: true, isRequired: false, transformFunction: null }, thyType: { classPropertyName: "thyType", publicName: "thyType", isSignal: true, isRequired: false, transformFunction: null }, thyIcons: { classPropertyName: "thyIcons", publicName: "thyIcons", isSignal: true, isRequired: false, transformFunction: null }, thySize: { classPropertyName: "thySize", publicName: "thySize", isSignal: true, isRequired: false, transformFunction: null }, thyVirtualScroll: { classPropertyName: "thyVirtualScroll", publicName: "thyVirtualScroll", isSignal: true, isRequired: false, transformFunction: null }, thyItemSize: { classPropertyName: "thyItemSize", publicName: "thyItemSize", isSignal: true, isRequired: false, transformFunction: null }, thyTitleTruncate: { classPropertyName: "thyTitleTruncate", publicName: "thyTitleTruncate", isSignal: true, isRequired: false, transformFunction: null }, thySelectedKeys: { classPropertyName: "thySelectedKeys", publicName: "thySelectedKeys", isSignal: true, isRequired: false, transformFunction: null }, thyExpandedKeys: { classPropertyName: "thyExpandedKeys", publicName: "thyExpandedKeys", isSignal: true, isRequired: false, transformFunction: null }, thyExpandAll: { classPropertyName: "thyExpandAll", publicName: "thyExpandAll", isSignal: true, isRequired: false, transformFunction: null }, thyIndent: { classPropertyName: "thyIndent", publicName: "thyIndent", isSignal: true, isRequired: false, transformFunction: null }, thyBeforeDragStart: { classPropertyName: "thyBeforeDragStart", publicName: "thyBeforeDragStart", isSignal: true, isRequired: false, transformFunction: null }, thyBeforeDragDrop: { classPropertyName: "thyBeforeDragDrop", publicName: "thyBeforeDragDrop", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { thyNodes: "thyNodesChange", thyOnClick: "thyOnClick", thyOnCheckboxChange: "thyOnCheckboxChange", thyOnExpandChange: "thyOnExpandChange", thyOnDragDrop: "thyOnDragDrop", thyDblClick: "thyDblClick" }, host: { properties: { "class.thy-multiple-selection-list": "thyMultiple()", "class.thy-virtual-scrolling-tree": "thyVirtualScroll()", "class.thy-tree-draggable": "thyDraggable()", "class.thy-tree-dragging": "dragging()" }, classAttribute: "thy-tree" }, providers: [
|
|
1037
999
|
{
|
|
1038
1000
|
provide: NG_VALUE_ACCESSOR,
|
|
1039
1001
|
useExisting: forwardRef(() => ThyTree),
|
|
@@ -1044,11 +1006,17 @@ class ThyTree {
|
|
|
1044
1006
|
useExisting: forwardRef(() => ThyTree)
|
|
1045
1007
|
},
|
|
1046
1008
|
ThyTreeService
|
|
1047
|
-
], queries: [{ propertyName: "templateRef", first: true, predicate: ["treeNodeTemplate"], descendants: true,
|
|
1009
|
+
], queries: [{ propertyName: "templateRef", first: true, predicate: ["treeNodeTemplate"], descendants: true, isSignal: true }, { propertyName: "emptyChildrenTemplate", first: true, predicate: ["emptyChildrenTemplate"], descendants: true, isSignal: true }], viewQueries: [{ propertyName: "viewport", first: true, predicate: ["viewport"], descendants: true, isSignal: true }, { propertyName: "cdkDrags", predicate: CdkDrag, descendants: true, isSignal: true }], ngImport: i0, template: "@let flattenTreeNodesValue = flattenTreeNodes();\n@let draggable = thyDraggable();\n@let async = thyAsync();\n@let checkable = thyCheckable();\n@let multiple = thyMultiple();\n@let titleTruncate = thyTitleTruncate();\n@let indent = thyIndent();\n@let clickBehavior = thyClickBehavior();\n\n@if (thyVirtualScroll()) {\n <cdk-virtual-scroll-viewport\n #viewport\n [itemSize]=\"itemSize()\"\n [style.height]=\"'100%'\"\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"flattenTreeNodesValue\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\"\n >\n <div class=\"virtual-trees-container\">\n <thy-tree-node\n *cdkVirtualFor=\"let node of flattenTreeNodesValue; trackBy: trackByFn; let i = index\"\n cdkDrag\n [cdkDragData]=\"node\"\n [cdkDragDisabled]=\"!draggable || !(node | treeNodeDraggable : thyBeforeDragStart())\"\n (cdkDragStarted)=\"onDragStarted($event)\"\n (cdkDragEnded)=\"onDragEnded($event)\"\n (cdkDragMoved)=\"emitDragMoved($event)\"\n [node]=\"node\"\n [templateRef]=\"templateRef()\"\n [emptyChildrenTemplateRef]=\"emptyChildrenTemplate()\"\n [thyAsync]=\"async\"\n [thyDraggable]=\"draggable\"\n [thyCheckable]=\"checkable\"\n [thyMultiple]=\"multiple\"\n [thyClickBehavior]=\"clickBehavior\"\n [thyTitleTruncate]=\"titleTruncate\"\n [thyItemSize]=\"itemSize()\"\n [thyIndent]=\"indent\"\n (thyOnClick)=\"thyOnClick.emit($event)\"\n (thyDblClick)=\"thyDblClick.emit($event)\"\n (thyOnExpandChange)=\"eventTriggerChanged($event)\"\n (thyOnCheckboxChange)=\"eventTriggerChanged($event)\">\n </thy-tree-node>\n </div>\n </cdk-virtual-scroll-viewport>\n}\n\n@if (!thyVirtualScroll()) {\n <div\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"flattenTreeNodesValue\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\">\n @for (node of flattenTreeNodesValue; track trackByFn(i, node); let i = $index) {\n <thy-tree-node\n cdkDrag\n [cdkDragData]=\"node\"\n [cdkDragDisabled]=\"!draggable || !(node | treeNodeDraggable : thyBeforeDragStart())\"\n (cdkDragStarted)=\"onDragStarted($event)\"\n (cdkDragEnded)=\"onDragEnded($event)\"\n (cdkDragMoved)=\"emitDragMoved($event)\"\n [node]=\"node\"\n [templateRef]=\"templateRef()\"\n [emptyChildrenTemplateRef]=\"emptyChildrenTemplate()\"\n [thyAsync]=\"async\"\n [thyDraggable]=\"draggable\"\n [thyCheckable]=\"checkable\"\n [thyMultiple]=\"multiple\"\n [thyTitleTruncate]=\"titleTruncate\"\n [thyItemSize]=\"itemSize()\"\n [thyClickBehavior]=\"clickBehavior\"\n [thyIndent]=\"indent\"\n (thyOnClick)=\"thyOnClick.emit($event)\"\n (thyDblClick)=\"thyDblClick.emit($event)\"\n (thyOnExpandChange)=\"eventTriggerChanged($event)\"\n (thyOnCheckboxChange)=\"thyOnCheckboxChange.emit($event)\">\n </thy-tree-node>\n }\n </div>\n}\n", dependencies: [{ kind: "directive", type: CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "component", type: CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "directive", type: CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }, { kind: "component", type: ThyTreeNodeComponent, selector: "thy-tree-node", inputs: ["node", "thyAsync", "thyMultiple", "thyDraggable", "thyCheckable", "thyClickBehavior", "thyTitleTruncate", "templateRef", "emptyChildrenTemplateRef", "thyItemSize", "thyIndent"], outputs: ["thyOnClick", "thyDblClick", "thyOnExpandChange", "thyOnCheckboxChange"] }, { kind: "pipe", type: ThyTreeNodeDraggablePipe, name: "treeNodeDraggable" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
1048
1010
|
}
|
|
1049
1011
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyTree, decorators: [{
|
|
1050
1012
|
type: Component,
|
|
1051
|
-
args: [{ selector: 'thy-tree', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1013
|
+
args: [{ selector: 'thy-tree', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
1014
|
+
class: 'thy-tree',
|
|
1015
|
+
'[class.thy-multiple-selection-list]': 'thyMultiple()',
|
|
1016
|
+
'[class.thy-virtual-scrolling-tree]': 'thyVirtualScroll()',
|
|
1017
|
+
'[class.thy-tree-draggable]': 'thyDraggable()',
|
|
1018
|
+
'[class.thy-tree-dragging]': 'dragging()'
|
|
1019
|
+
}, providers: [
|
|
1052
1020
|
{
|
|
1053
1021
|
provide: NG_VALUE_ACCESSOR,
|
|
1054
1022
|
useExisting: forwardRef(() => ThyTree),
|
|
@@ -1067,96 +1035,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
1067
1035
|
CdkVirtualForOf,
|
|
1068
1036
|
ThyTreeNodeComponent,
|
|
1069
1037
|
ThyTreeNodeDraggablePipe
|
|
1070
|
-
], template: "@if (thyVirtualScroll) {\n <cdk-virtual-scroll-viewport\n #viewport\n [itemSize]=\"
|
|
1071
|
-
}],
|
|
1072
|
-
type: Output
|
|
1073
|
-
}, {
|
|
1074
|
-
type: ViewChild,
|
|
1075
|
-
args: ['viewport', { static: false }]
|
|
1076
|
-
}], thyNodes: [{
|
|
1077
|
-
type: Input
|
|
1078
|
-
}], thyShowExpand: [{
|
|
1079
|
-
type: Input
|
|
1080
|
-
}], thyMultiple: [{
|
|
1081
|
-
type: HostBinding,
|
|
1082
|
-
args: [`class.thy-multiple-selection-list`]
|
|
1083
|
-
}, {
|
|
1084
|
-
type: Input,
|
|
1085
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
1086
|
-
}], thyDraggable: [{
|
|
1087
|
-
type: HostBinding,
|
|
1088
|
-
args: ['class.thy-tree-draggable']
|
|
1089
|
-
}, {
|
|
1090
|
-
type: Input,
|
|
1091
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
1092
|
-
}], thyCheckable: [{
|
|
1093
|
-
type: Input,
|
|
1094
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
1095
|
-
}], thyClickBehavior: [{
|
|
1096
|
-
type: Input
|
|
1097
|
-
}], thyCheckStateResolve: [{
|
|
1098
|
-
type: Input
|
|
1099
|
-
}], thyAsync: [{
|
|
1100
|
-
type: Input,
|
|
1101
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
1102
|
-
}], thyType: [{
|
|
1103
|
-
type: Input
|
|
1104
|
-
}], thyIcons: [{
|
|
1105
|
-
type: Input
|
|
1106
|
-
}], thySize: [{
|
|
1107
|
-
type: Input
|
|
1108
|
-
}], thyVirtualScroll: [{
|
|
1109
|
-
type: HostBinding,
|
|
1110
|
-
args: ['class.thy-virtual-scrolling-tree']
|
|
1111
|
-
}, {
|
|
1112
|
-
type: Input,
|
|
1113
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
1114
|
-
}], thyItemSize: [{
|
|
1115
|
-
type: Input,
|
|
1116
|
-
args: [{ transform: numberAttribute }]
|
|
1117
|
-
}], thyTitleTruncate: [{
|
|
1118
|
-
type: Input,
|
|
1119
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
1120
|
-
}], thySelectedKeys: [{
|
|
1121
|
-
type: Input
|
|
1122
|
-
}], thyExpandedKeys: [{
|
|
1123
|
-
type: Input
|
|
1124
|
-
}], thyExpandAll: [{
|
|
1125
|
-
type: Input,
|
|
1126
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
1127
|
-
}], thyIndent: [{
|
|
1128
|
-
type: Input,
|
|
1129
|
-
args: [{ transform: numberAttribute }]
|
|
1130
|
-
}], thyBeforeDragStart: [{
|
|
1131
|
-
type: Input
|
|
1132
|
-
}], thyBeforeDragDrop: [{
|
|
1133
|
-
type: Input
|
|
1134
|
-
}], thyOnClick: [{
|
|
1135
|
-
type: Output
|
|
1136
|
-
}], thyOnCheckboxChange: [{
|
|
1137
|
-
type: Output
|
|
1138
|
-
}], thyOnExpandChange: [{
|
|
1139
|
-
type: Output
|
|
1140
|
-
}], thyOnDragDrop: [{
|
|
1141
|
-
type: Output
|
|
1142
|
-
}], thyDblClick: [{
|
|
1143
|
-
type: Output
|
|
1144
|
-
}], templateRef: [{
|
|
1145
|
-
type: ContentChild,
|
|
1146
|
-
args: ['treeNodeTemplate', { static: true }]
|
|
1147
|
-
}], emptyChildrenTemplate: [{
|
|
1148
|
-
type: ContentChild,
|
|
1149
|
-
args: ['emptyChildrenTemplate', { static: true }]
|
|
1150
|
-
}], thyTreeClass: [{
|
|
1151
|
-
type: HostBinding,
|
|
1152
|
-
args: ['class.thy-tree']
|
|
1153
|
-
}], dragging: [{
|
|
1154
|
-
type: HostBinding,
|
|
1155
|
-
args: ['class.thy-tree-dragging']
|
|
1156
|
-
}], cdkDrags: [{
|
|
1157
|
-
type: ViewChildren,
|
|
1158
|
-
args: [CdkDrag]
|
|
1159
|
-
}] } });
|
|
1038
|
+
], template: "@let flattenTreeNodesValue = flattenTreeNodes();\n@let draggable = thyDraggable();\n@let async = thyAsync();\n@let checkable = thyCheckable();\n@let multiple = thyMultiple();\n@let titleTruncate = thyTitleTruncate();\n@let indent = thyIndent();\n@let clickBehavior = thyClickBehavior();\n\n@if (thyVirtualScroll()) {\n <cdk-virtual-scroll-viewport\n #viewport\n [itemSize]=\"itemSize()\"\n [style.height]=\"'100%'\"\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"flattenTreeNodesValue\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\"\n >\n <div class=\"virtual-trees-container\">\n <thy-tree-node\n *cdkVirtualFor=\"let node of flattenTreeNodesValue; trackBy: trackByFn; let i = index\"\n cdkDrag\n [cdkDragData]=\"node\"\n [cdkDragDisabled]=\"!draggable || !(node | treeNodeDraggable : thyBeforeDragStart())\"\n (cdkDragStarted)=\"onDragStarted($event)\"\n (cdkDragEnded)=\"onDragEnded($event)\"\n (cdkDragMoved)=\"emitDragMoved($event)\"\n [node]=\"node\"\n [templateRef]=\"templateRef()\"\n [emptyChildrenTemplateRef]=\"emptyChildrenTemplate()\"\n [thyAsync]=\"async\"\n [thyDraggable]=\"draggable\"\n [thyCheckable]=\"checkable\"\n [thyMultiple]=\"multiple\"\n [thyClickBehavior]=\"clickBehavior\"\n [thyTitleTruncate]=\"titleTruncate\"\n [thyItemSize]=\"itemSize()\"\n [thyIndent]=\"indent\"\n (thyOnClick)=\"thyOnClick.emit($event)\"\n (thyDblClick)=\"thyDblClick.emit($event)\"\n (thyOnExpandChange)=\"eventTriggerChanged($event)\"\n (thyOnCheckboxChange)=\"eventTriggerChanged($event)\">\n </thy-tree-node>\n </div>\n </cdk-virtual-scroll-viewport>\n}\n\n@if (!thyVirtualScroll()) {\n <div\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"flattenTreeNodesValue\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\">\n @for (node of flattenTreeNodesValue; track trackByFn(i, node); let i = $index) {\n <thy-tree-node\n cdkDrag\n [cdkDragData]=\"node\"\n [cdkDragDisabled]=\"!draggable || !(node | treeNodeDraggable : thyBeforeDragStart())\"\n (cdkDragStarted)=\"onDragStarted($event)\"\n (cdkDragEnded)=\"onDragEnded($event)\"\n (cdkDragMoved)=\"emitDragMoved($event)\"\n [node]=\"node\"\n [templateRef]=\"templateRef()\"\n [emptyChildrenTemplateRef]=\"emptyChildrenTemplate()\"\n [thyAsync]=\"async\"\n [thyDraggable]=\"draggable\"\n [thyCheckable]=\"checkable\"\n [thyMultiple]=\"multiple\"\n [thyTitleTruncate]=\"titleTruncate\"\n [thyItemSize]=\"itemSize()\"\n [thyClickBehavior]=\"clickBehavior\"\n [thyIndent]=\"indent\"\n (thyOnClick)=\"thyOnClick.emit($event)\"\n (thyDblClick)=\"thyDblClick.emit($event)\"\n (thyOnExpandChange)=\"eventTriggerChanged($event)\"\n (thyOnCheckboxChange)=\"thyOnCheckboxChange.emit($event)\">\n </thy-tree-node>\n }\n </div>\n}\n" }]
|
|
1039
|
+
}], ctorParameters: () => [] });
|
|
1160
1040
|
|
|
1161
1041
|
class ThyTreeModule {
|
|
1162
1042
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThyTreeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|