@progress/kendo-angular-menu 21.4.1 → 22.0.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/data-binding/binding-directive-base.d.ts +1 -1
- package/fesm2022/progress-kendo-angular-menu.mjs +87 -87
- package/menu-base.d.ts +1 -1
- package/package.json +11 -19
- package/esm2022/constants.mjs +0 -8
- package/esm2022/context-menu/context-menu-event.mjs +0 -25
- package/esm2022/context-menu/context-menu-items.service.mjs +0 -27
- package/esm2022/context-menu/context-menu-popup-event.mjs +0 -29
- package/esm2022/context-menu/context-menu-select-event.mjs +0 -14
- package/esm2022/context-menu/context-menu-target-container.directive.mjs +0 -49
- package/esm2022/context-menu/context-menu-target.directive.mjs +0 -62
- package/esm2022/context-menu/context-menu-target.service.mjs +0 -27
- package/esm2022/context-menu/context-menu-template.directive.mjs +0 -39
- package/esm2022/context-menu/context-menu.component.mjs +0 -527
- package/esm2022/context-menu/context-menu.module.mjs +0 -69
- package/esm2022/context-menu/context-menu.service.mjs +0 -30
- package/esm2022/data-binding/binding-directive-base.mjs +0 -46
- package/esm2022/data-binding/flat-binding.directive.mjs +0 -139
- package/esm2022/data-binding/hierachy-binding.directive.mjs +0 -124
- package/esm2022/data-binding/utils.mjs +0 -31
- package/esm2022/directives.mjs +0 -48
- package/esm2022/dom-queries.mjs +0 -104
- package/esm2022/index.mjs +0 -29
- package/esm2022/menu-animation.interface.mjs +0 -5
- package/esm2022/menu-base.mjs +0 -103
- package/esm2022/menu-event.mjs +0 -22
- package/esm2022/menu-item.component.mjs +0 -149
- package/esm2022/menu-item.interface.mjs +0 -5
- package/esm2022/menu-select-event.mjs +0 -14
- package/esm2022/menu.component.mjs +0 -304
- package/esm2022/menu.module.mjs +0 -65
- package/esm2022/menus.module.mjs +0 -59
- package/esm2022/open-on-click-settings.mjs +0 -10
- package/esm2022/package-metadata.mjs +0 -16
- package/esm2022/preventable-event.mjs +0 -34
- package/esm2022/progress-kendo-angular-menu.mjs +0 -8
- package/esm2022/rendering/arrow.component.mjs +0 -70
- package/esm2022/rendering/link.directive.mjs +0 -69
- package/esm2022/rendering/list.component.mjs +0 -679
- package/esm2022/rendering/popup-settings.mjs +0 -74
- package/esm2022/services/actions.service.mjs +0 -192
- package/esm2022/services/hover.service.mjs +0 -127
- package/esm2022/services/items.service.mjs +0 -128
- package/esm2022/services/navigation.service.mjs +0 -268
- package/esm2022/size.mjs +0 -5
- package/esm2022/templates/item-content-template.directive.mjs +0 -53
- package/esm2022/templates/item-link-template.directive.mjs +0 -57
- package/esm2022/templates/item-template.directive.mjs +0 -54
- package/esm2022/utils.mjs +0 -52
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
const POPUP_ALIGN = {
|
|
6
|
-
vertical: 'top',
|
|
7
|
-
horizontal: 'left'
|
|
8
|
-
};
|
|
9
|
-
const POPUP_ALIGN_RTL = {
|
|
10
|
-
vertical: 'top',
|
|
11
|
-
horizontal: 'right'
|
|
12
|
-
};
|
|
13
|
-
const VERTICAL_COLLISION = {
|
|
14
|
-
vertical: 'flip',
|
|
15
|
-
horizontal: 'fit'
|
|
16
|
-
};
|
|
17
|
-
const HORIZONTAL_COLLISION = {
|
|
18
|
-
vertical: 'fit',
|
|
19
|
-
horizontal: 'flip'
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* @hidden
|
|
23
|
-
*/
|
|
24
|
-
export const DEFAULT_MARGIN = { horizontal: 0, vertical: 0 };
|
|
25
|
-
/**
|
|
26
|
-
* @hidden
|
|
27
|
-
*/
|
|
28
|
-
export const POPUP_SETTINGS_RTL = {
|
|
29
|
-
vertical: {
|
|
30
|
-
anchor: {
|
|
31
|
-
vertical: 'bottom',
|
|
32
|
-
horizontal: 'right'
|
|
33
|
-
},
|
|
34
|
-
popup: POPUP_ALIGN_RTL,
|
|
35
|
-
collision: VERTICAL_COLLISION,
|
|
36
|
-
animate: 'down',
|
|
37
|
-
popupClass: ['k-rtl', 'k-menu-popup']
|
|
38
|
-
},
|
|
39
|
-
horizontal: {
|
|
40
|
-
anchor: {
|
|
41
|
-
vertical: 'top',
|
|
42
|
-
horizontal: 'left'
|
|
43
|
-
},
|
|
44
|
-
popup: POPUP_ALIGN_RTL,
|
|
45
|
-
collision: HORIZONTAL_COLLISION,
|
|
46
|
-
animate: 'left',
|
|
47
|
-
popupClass: ['k-rtl', 'k-menu-popup']
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* @hidden
|
|
52
|
-
*/
|
|
53
|
-
export const POPUP_SETTINGS = {
|
|
54
|
-
vertical: {
|
|
55
|
-
anchor: {
|
|
56
|
-
vertical: 'bottom',
|
|
57
|
-
horizontal: 'left'
|
|
58
|
-
},
|
|
59
|
-
popup: POPUP_ALIGN,
|
|
60
|
-
collision: VERTICAL_COLLISION,
|
|
61
|
-
animate: 'down',
|
|
62
|
-
popupClass: ['k-menu-popup']
|
|
63
|
-
},
|
|
64
|
-
horizontal: {
|
|
65
|
-
anchor: {
|
|
66
|
-
vertical: 'top',
|
|
67
|
-
horizontal: 'right'
|
|
68
|
-
},
|
|
69
|
-
popup: POPUP_ALIGN,
|
|
70
|
-
collision: HORIZONTAL_COLLISION,
|
|
71
|
-
animate: 'right',
|
|
72
|
-
popupClass: ['k-menu-popup']
|
|
73
|
-
}
|
|
74
|
-
};
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { NgZone, Injectable } from '@angular/core';
|
|
6
|
-
import { ItemsService } from './items.service';
|
|
7
|
-
import { hasObservers, PreventableEvent } from '@progress/kendo-angular-common';
|
|
8
|
-
import * as i0 from "@angular/core";
|
|
9
|
-
import * as i1 from "./items.service";
|
|
10
|
-
const canPerformAction = (item, action) => !((action === 'open' && item.opened) || (action === 'close' && !item.opened));
|
|
11
|
-
/**
|
|
12
|
-
* Used to remove cyclic dependency error. Dublicates MenuEvent
|
|
13
|
-
* @hidden
|
|
14
|
-
*/
|
|
15
|
-
export class MenuStateEvent extends PreventableEvent {
|
|
16
|
-
/**
|
|
17
|
-
* The MenuComponent that triggered the event.
|
|
18
|
-
*/
|
|
19
|
-
sender;
|
|
20
|
-
/**
|
|
21
|
-
* The item data of the event.
|
|
22
|
-
*/
|
|
23
|
-
item;
|
|
24
|
-
/**
|
|
25
|
-
* The item index of the event.
|
|
26
|
-
*/
|
|
27
|
-
index;
|
|
28
|
-
constructor(args) {
|
|
29
|
-
super();
|
|
30
|
-
Object.assign(this, args);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @hidden
|
|
35
|
-
*/
|
|
36
|
-
export class ActionsService {
|
|
37
|
-
ngZone;
|
|
38
|
-
items;
|
|
39
|
-
owner;
|
|
40
|
-
actions = [];
|
|
41
|
-
constructor(ngZone, items) {
|
|
42
|
-
this.ngZone = ngZone;
|
|
43
|
-
this.items = items;
|
|
44
|
-
}
|
|
45
|
-
open(item, finished) {
|
|
46
|
-
if (item.disabled) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (item.hasContent && !item.opened) {
|
|
50
|
-
this.actions.push({
|
|
51
|
-
name: 'open',
|
|
52
|
-
requiresZone: item.hasContentTemplates(),
|
|
53
|
-
item,
|
|
54
|
-
finished
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
else if (finished) {
|
|
58
|
-
finished();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
close(item) {
|
|
62
|
-
this.closeChildren(item);
|
|
63
|
-
this.closeItem(item);
|
|
64
|
-
}
|
|
65
|
-
closeItem(item) {
|
|
66
|
-
if (item.opened) {
|
|
67
|
-
this.actions.push({
|
|
68
|
-
name: 'close',
|
|
69
|
-
item
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
closeToRoot(item) {
|
|
74
|
-
this.closeChildren(item);
|
|
75
|
-
let current = item;
|
|
76
|
-
do {
|
|
77
|
-
this.closeItem(current);
|
|
78
|
-
current = this.items.parent(current);
|
|
79
|
-
} while (current);
|
|
80
|
-
}
|
|
81
|
-
closeOthers(item) {
|
|
82
|
-
this.closeChildren(item);
|
|
83
|
-
let current = item;
|
|
84
|
-
while (current) {
|
|
85
|
-
const siblings = this.items.otherSiblings(current);
|
|
86
|
-
this.closeItems(siblings);
|
|
87
|
-
current = this.items.parent(current);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
closeAll() {
|
|
91
|
-
this.items.forEach((item) => {
|
|
92
|
-
if (item.opened && item.level === 0) {
|
|
93
|
-
this.close(item);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
select(item, domEvent, prevented, finished) {
|
|
98
|
-
this.actions.push({
|
|
99
|
-
name: 'select',
|
|
100
|
-
item,
|
|
101
|
-
prevented,
|
|
102
|
-
finished,
|
|
103
|
-
domEvent
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
emit(name, item, domEvent) {
|
|
107
|
-
const owner = this.owner;
|
|
108
|
-
const eventArgs = new MenuStateEvent({
|
|
109
|
-
sender: owner,
|
|
110
|
-
item: item.item,
|
|
111
|
-
index: item.index,
|
|
112
|
-
originalEvent: domEvent,
|
|
113
|
-
hasContent: item.hasContent
|
|
114
|
-
});
|
|
115
|
-
owner[name].emit(eventArgs);
|
|
116
|
-
if (owner.contextService) {
|
|
117
|
-
owner.contextService.emit(name, eventArgs);
|
|
118
|
-
}
|
|
119
|
-
return eventArgs.isDefaultPrevented();
|
|
120
|
-
}
|
|
121
|
-
get hasPending() {
|
|
122
|
-
return this.actions.length > 0;
|
|
123
|
-
}
|
|
124
|
-
execute(toExecute) {
|
|
125
|
-
if (!this.hasPending && !toExecute) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const actions = toExecute || this.clear();
|
|
129
|
-
if (!NgZone.isInAngularZone() && this.requiresZone(actions)) {
|
|
130
|
-
this.ngZone.run(() => {
|
|
131
|
-
this.executeActions(actions);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
this.executeActions(actions);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
clear() {
|
|
139
|
-
const actions = this.actions;
|
|
140
|
-
this.actions = [];
|
|
141
|
-
return actions;
|
|
142
|
-
}
|
|
143
|
-
executeActions(actions) {
|
|
144
|
-
for (let idx = 0; idx < actions.length; idx++) {
|
|
145
|
-
const { item, name, prevented, finished, domEvent } = actions[idx];
|
|
146
|
-
if (!canPerformAction(item, name)) {
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
if (!this.emit(name, item, domEvent)) {
|
|
150
|
-
if (item[name]) {
|
|
151
|
-
item[name]();
|
|
152
|
-
}
|
|
153
|
-
if (finished) {
|
|
154
|
-
finished();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
else if (prevented) {
|
|
158
|
-
prevented();
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
requiresZone(toExecute) {
|
|
163
|
-
const actions = toExecute || this.actions;
|
|
164
|
-
const owner = this.owner;
|
|
165
|
-
const contextService = owner.contextService;
|
|
166
|
-
for (let idx = 0; idx < actions.length; idx++) {
|
|
167
|
-
const action = actions[idx];
|
|
168
|
-
const name = action.name;
|
|
169
|
-
if (action.requiresZone || (name && (hasObservers(owner[name]) || (contextService && contextService.hasObservers(name))))) {
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
closeChildren(item) {
|
|
176
|
-
if (!item.opened) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
const children = this.items.children(item);
|
|
180
|
-
this.closeItems(children);
|
|
181
|
-
}
|
|
182
|
-
closeItems(items) {
|
|
183
|
-
for (let idx = 0; idx < items.length; idx++) {
|
|
184
|
-
this.close(items[idx]);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ActionsService, deps: [{ token: i0.NgZone }, { token: i1.ItemsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
188
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ActionsService });
|
|
189
|
-
}
|
|
190
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ActionsService, decorators: [{
|
|
191
|
-
type: Injectable
|
|
192
|
-
}], ctorParameters: () => [{ type: i0.NgZone }, { type: i1.ItemsService }] });
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { Injectable } from '@angular/core';
|
|
6
|
-
import { ItemsService } from './items.service';
|
|
7
|
-
import { ActionsService } from './actions.service';
|
|
8
|
-
import * as i0 from "@angular/core";
|
|
9
|
-
import * as i1 from "./actions.service";
|
|
10
|
-
import * as i2 from "./items.service";
|
|
11
|
-
const DISABLE_OPEN_ON_OVER_DELAY = 500;
|
|
12
|
-
/**
|
|
13
|
-
* @hidden
|
|
14
|
-
*/
|
|
15
|
-
export class HoverService {
|
|
16
|
-
actions;
|
|
17
|
-
items;
|
|
18
|
-
delay = 100;
|
|
19
|
-
get openOnOver() {
|
|
20
|
-
return this._openOnOver;
|
|
21
|
-
}
|
|
22
|
-
set openOnOver(value) {
|
|
23
|
-
this.cancelActions();
|
|
24
|
-
this._openOnOver = value;
|
|
25
|
-
}
|
|
26
|
-
_openOnOver = true;
|
|
27
|
-
hoveredIdx;
|
|
28
|
-
get hovered() {
|
|
29
|
-
return this.items.get(this.hoveredIdx);
|
|
30
|
-
}
|
|
31
|
-
set hovered(item) {
|
|
32
|
-
this.hoveredIdx = item ? item.index : null;
|
|
33
|
-
}
|
|
34
|
-
scheduled = [];
|
|
35
|
-
constructor(actions, items) {
|
|
36
|
-
this.actions = actions;
|
|
37
|
-
this.items = items;
|
|
38
|
-
}
|
|
39
|
-
ngOnDestroy() {
|
|
40
|
-
this.cancelActions();
|
|
41
|
-
}
|
|
42
|
-
over(item) {
|
|
43
|
-
this.cancelActions((action) => action.name === 'openOnOver');
|
|
44
|
-
if (!this.hovered || this.hovered !== item) {
|
|
45
|
-
this.actions.closeOthers(item);
|
|
46
|
-
this.hovered = item;
|
|
47
|
-
if ((item.level > 0 || this.openOnOver) && !item.disabled) {
|
|
48
|
-
this.actions.open(item);
|
|
49
|
-
this.cancelActions((action) => (action.name === 'close' && (item === action.item || this.items.hasParent(item, action.item))) ||
|
|
50
|
-
(action.name === 'open' && !this.items.hasParent(item, action.item)));
|
|
51
|
-
}
|
|
52
|
-
this.scheduleActions();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
leave(disableOpenOnOver) {
|
|
56
|
-
const hovered = this.hovered;
|
|
57
|
-
if (hovered) {
|
|
58
|
-
this.actions.closeToRoot(hovered);
|
|
59
|
-
this.cancelActions(action => action.name === 'open');
|
|
60
|
-
this.scheduleActions();
|
|
61
|
-
}
|
|
62
|
-
if (disableOpenOnOver && this._openOnOver) {
|
|
63
|
-
this.scheduleDisableOpenOnOver();
|
|
64
|
-
}
|
|
65
|
-
this.hovered = null;
|
|
66
|
-
}
|
|
67
|
-
closeCurrent() {
|
|
68
|
-
const hovered = this.hovered;
|
|
69
|
-
if (hovered) {
|
|
70
|
-
this.actions.closeToRoot(hovered);
|
|
71
|
-
this.hovered = null;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
scheduleActions() {
|
|
75
|
-
if (this.actions.hasPending) {
|
|
76
|
-
const item = {};
|
|
77
|
-
item.actions = this.actions.clear();
|
|
78
|
-
item.id = setTimeout(() => {
|
|
79
|
-
this.actions.execute(item.actions);
|
|
80
|
-
this.removeScheduled(item);
|
|
81
|
-
}, this.delay);
|
|
82
|
-
this.scheduled.push(item);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
scheduleDisableOpenOnOver() {
|
|
86
|
-
const item = {
|
|
87
|
-
actions: [{ name: 'openOnOver' }]
|
|
88
|
-
};
|
|
89
|
-
item.id = setTimeout(() => {
|
|
90
|
-
this._openOnOver = false;
|
|
91
|
-
this.removeScheduled(item);
|
|
92
|
-
}, Math.max(this.delay, DISABLE_OPEN_ON_OVER_DELAY));
|
|
93
|
-
this.scheduled.push(item);
|
|
94
|
-
}
|
|
95
|
-
removeScheduled(item) {
|
|
96
|
-
const scheduled = this.scheduled;
|
|
97
|
-
for (let idx = 0; idx < scheduled.length; idx++) {
|
|
98
|
-
if (scheduled[idx] === item) {
|
|
99
|
-
scheduled.splice(idx, 1);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
cancelActions(predicate) {
|
|
105
|
-
const scheduled = this.scheduled;
|
|
106
|
-
for (let idx = scheduled.length - 1; idx >= 0; idx--) {
|
|
107
|
-
const item = scheduled[idx];
|
|
108
|
-
const actions = item.actions;
|
|
109
|
-
if (predicate) {
|
|
110
|
-
for (let actionIdx = actions.length - 1; actionIdx >= 0; actionIdx--) {
|
|
111
|
-
if (predicate(actions[actionIdx])) {
|
|
112
|
-
actions.splice(actionIdx, 1);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (!predicate || actions.length === 0) {
|
|
117
|
-
clearTimeout(item.id);
|
|
118
|
-
scheduled.splice(idx, 1);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: HoverService, deps: [{ token: i1.ActionsService }, { token: i2.ItemsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
123
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: HoverService });
|
|
124
|
-
}
|
|
125
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: HoverService, decorators: [{
|
|
126
|
-
type: Injectable
|
|
127
|
-
}], ctorParameters: () => [{ type: i1.ActionsService }, { type: i2.ItemsService }] });
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { Injectable } from '@angular/core';
|
|
6
|
-
import * as i0 from "@angular/core";
|
|
7
|
-
const PARENT_REGEX = /_?\d+$/;
|
|
8
|
-
const SEPARATOR = '_';
|
|
9
|
-
let id = 0;
|
|
10
|
-
const itemIndexComparer = (a, b) => a.siblingIndex - b.siblingIndex;
|
|
11
|
-
const next = (idx, items, dir) => {
|
|
12
|
-
let current = items[idx + dir];
|
|
13
|
-
while (!current) {
|
|
14
|
-
if (idx < 0) {
|
|
15
|
-
idx = items.length - 1;
|
|
16
|
-
}
|
|
17
|
-
else if (idx >= items.length) {
|
|
18
|
-
idx = 0;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
idx += dir;
|
|
22
|
-
}
|
|
23
|
-
current = items[idx];
|
|
24
|
-
}
|
|
25
|
-
return current;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* @hidden
|
|
29
|
-
*/
|
|
30
|
-
export class ItemsService {
|
|
31
|
-
items = {};
|
|
32
|
-
lists = [];
|
|
33
|
-
idPrefix = `k-menu${id++}`;
|
|
34
|
-
get hasItems() {
|
|
35
|
-
return Object.keys(this.items).length > 0;
|
|
36
|
-
}
|
|
37
|
-
childId(index) {
|
|
38
|
-
return `${this.idPrefix}-child${index}`;
|
|
39
|
-
}
|
|
40
|
-
itemIndex(parentIndex, index) {
|
|
41
|
-
return (parentIndex ? parentIndex + SEPARATOR : '') + index;
|
|
42
|
-
}
|
|
43
|
-
get(index) {
|
|
44
|
-
return this.items[index];
|
|
45
|
-
}
|
|
46
|
-
add(item) {
|
|
47
|
-
this.items[item.index] = item;
|
|
48
|
-
}
|
|
49
|
-
remove(item) {
|
|
50
|
-
if (this.items[item.index] === item) {
|
|
51
|
-
delete this.items[item.index];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
addList(list) {
|
|
55
|
-
this.lists.push(list);
|
|
56
|
-
}
|
|
57
|
-
removeList(list) {
|
|
58
|
-
const index = this.lists.indexOf(list);
|
|
59
|
-
if (index >= 0) {
|
|
60
|
-
this.lists.splice(index, 1);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
containsList(element) {
|
|
64
|
-
return Boolean(this.lists.find(list => list.element.nativeElement === element));
|
|
65
|
-
}
|
|
66
|
-
siblings(item) {
|
|
67
|
-
const parentIndex = this.parentIndex(item.index);
|
|
68
|
-
return this.filter((index) => this.parentIndex(index) === parentIndex);
|
|
69
|
-
}
|
|
70
|
-
otherSiblings(item) {
|
|
71
|
-
const parentIndex = this.parentIndex(item.index);
|
|
72
|
-
return this.filter((index) => this.parentIndex(index) === parentIndex && index !== item.index);
|
|
73
|
-
}
|
|
74
|
-
children(item) {
|
|
75
|
-
return this.filter((index) => this.parentIndex(index) === item.index);
|
|
76
|
-
}
|
|
77
|
-
parent(item) {
|
|
78
|
-
return this.items[this.parentIndex(item.index)];
|
|
79
|
-
}
|
|
80
|
-
root(item) {
|
|
81
|
-
return this.items[this.indices(item.index)[0]];
|
|
82
|
-
}
|
|
83
|
-
indices(index) {
|
|
84
|
-
return index.split(SEPARATOR);
|
|
85
|
-
}
|
|
86
|
-
filter(predicate) {
|
|
87
|
-
const result = [];
|
|
88
|
-
const items = this.items;
|
|
89
|
-
for (const index in items) {
|
|
90
|
-
if (predicate(index, items[index])) {
|
|
91
|
-
result.push(items[index]);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return result.sort(itemIndexComparer);
|
|
95
|
-
}
|
|
96
|
-
previous(item) {
|
|
97
|
-
const siblings = this.siblings(item);
|
|
98
|
-
const itemIndex = siblings.indexOf(item);
|
|
99
|
-
return next(itemIndex, siblings, -1);
|
|
100
|
-
}
|
|
101
|
-
next(item) {
|
|
102
|
-
const siblings = this.siblings(item);
|
|
103
|
-
const itemIndex = siblings.indexOf(item);
|
|
104
|
-
return next(itemIndex, siblings, 1);
|
|
105
|
-
}
|
|
106
|
-
hasParent(item, parent) {
|
|
107
|
-
return item.index.startsWith(parent.index);
|
|
108
|
-
}
|
|
109
|
-
areSiblings(item1, item2) {
|
|
110
|
-
return item1 !== item2 && this.parent(item1) === this.parent(item2);
|
|
111
|
-
}
|
|
112
|
-
forEach(callback) {
|
|
113
|
-
const items = this.items;
|
|
114
|
-
for (const index in items) {
|
|
115
|
-
if (items.hasOwnProperty(index)) {
|
|
116
|
-
callback(items[index]);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
parentIndex(index) {
|
|
121
|
-
return index.replace(PARENT_REGEX, '');
|
|
122
|
-
}
|
|
123
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ItemsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
124
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ItemsService });
|
|
125
|
-
}
|
|
126
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ItemsService, decorators: [{
|
|
127
|
-
type: Injectable
|
|
128
|
-
}] });
|