ngx-tethys 19.1.0-next.5 → 19.1.0-next.7
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 +25 -0
- package/color-picker/coordinates.directive.d.ts +1 -2
- package/date-picker/abstract-picker.component.d.ts +50 -52
- package/date-picker/abstract-picker.directive.d.ts +15 -40
- package/date-picker/base-picker.component.d.ts +12 -40
- package/date-picker/date-picker.config.d.ts +1 -0
- package/date-picker/lib/calendar/calendar-footer.component.d.ts +24 -19
- package/date-picker/lib/calendar/calendar-header.component.d.ts +15 -15
- package/date-picker/lib/calendar/calendar-table.component.d.ts +15 -16
- package/date-picker/lib/date/date-table-cell.component.d.ts +2 -3
- package/date-picker/lib/date/date-table.component.d.ts +2 -3
- package/date-picker/lib/date-carousel/date-carousel.component.d.ts +2 -3
- package/date-picker/lib/decade/decade-header.component.d.ts +2 -5
- package/date-picker/lib/decade/decade-table.component.d.ts +3 -5
- package/date-picker/lib/month/month-table.component.d.ts +1 -2
- package/date-picker/lib/popups/date-popup.component.d.ts +33 -34
- package/date-picker/lib/popups/inner-popup.component.d.ts +22 -29
- package/date-picker/lib/quarter/quarter-table.component.d.ts +1 -4
- package/date-picker/lib/year/year-header.component.d.ts +2 -4
- package/date-picker/lib/year/year-table.component.d.ts +2 -4
- package/date-picker/month-picker.component.d.ts +2 -2
- package/date-picker/picker.component.d.ts +31 -36
- package/date-picker/picker.pipes.d.ts +4 -5
- package/date-picker/picker.util.d.ts +5 -5
- package/date-picker/picker.validators.d.ts +4 -8
- package/date-picker/quarter-picker.component.d.ts +2 -3
- package/date-picker/week-picker.component.d.ts +0 -1
- package/date-picker/year-picker.component.d.ts +2 -3
- package/dropdown/dropdown-menu.component.d.ts +1 -1
- package/dropdown/dropdown.directive.d.ts +4 -3
- package/fesm2022/ngx-tethys-autocomplete.mjs +4 -4
- package/fesm2022/ngx-tethys-autocomplete.mjs.map +1 -1
- package/fesm2022/ngx-tethys-checkbox.mjs +2 -2
- package/fesm2022/ngx-tethys-checkbox.mjs.map +1 -1
- package/fesm2022/ngx-tethys-color-picker.mjs +4 -6
- package/fesm2022/ngx-tethys-color-picker.mjs.map +1 -1
- package/fesm2022/ngx-tethys-copy.mjs +2 -2
- package/fesm2022/ngx-tethys-copy.mjs.map +1 -1
- package/fesm2022/ngx-tethys-date-picker.mjs +841 -1068
- package/fesm2022/ngx-tethys-date-picker.mjs.map +1 -1
- package/fesm2022/ngx-tethys-dropdown.mjs +9 -11
- package/fesm2022/ngx-tethys-dropdown.mjs.map +1 -1
- package/fesm2022/ngx-tethys-flexible-text.mjs +4 -5
- package/fesm2022/ngx-tethys-flexible-text.mjs.map +1 -1
- package/fesm2022/ngx-tethys-i18n.mjs +11 -6
- package/fesm2022/ngx-tethys-i18n.mjs.map +1 -1
- package/fesm2022/ngx-tethys-image.mjs +5 -7
- package/fesm2022/ngx-tethys-image.mjs.map +1 -1
- package/fesm2022/ngx-tethys-layout.mjs +291 -334
- package/fesm2022/ngx-tethys-layout.mjs.map +1 -1
- package/fesm2022/ngx-tethys-list.mjs +147 -166
- package/fesm2022/ngx-tethys-list.mjs.map +1 -1
- package/fesm2022/ngx-tethys-message.mjs +1 -2
- package/fesm2022/ngx-tethys-message.mjs.map +1 -1
- package/fesm2022/ngx-tethys-radio.mjs +4 -4
- package/fesm2022/ngx-tethys-radio.mjs.map +1 -1
- package/fesm2022/ngx-tethys-select.mjs +164 -228
- package/fesm2022/ngx-tethys-select.mjs.map +1 -1
- package/fesm2022/ngx-tethys-shared.mjs +386 -569
- package/fesm2022/ngx-tethys-shared.mjs.map +1 -1
- package/fesm2022/ngx-tethys-skeleton.mjs +1 -2
- package/fesm2022/ngx-tethys-skeleton.mjs.map +1 -1
- package/fesm2022/ngx-tethys-table.mjs +1 -2
- package/fesm2022/ngx-tethys-table.mjs.map +1 -1
- package/fesm2022/ngx-tethys-tooltip.mjs +109 -93
- package/fesm2022/ngx-tethys-tooltip.mjs.map +1 -1
- package/fesm2022/ngx-tethys-tree-select.mjs +215 -281
- package/fesm2022/ngx-tethys-tree-select.mjs.map +1 -1
- package/fesm2022/ngx-tethys.mjs +1 -1
- package/fesm2022/ngx-tethys.mjs.map +1 -1
- package/i18n/i18n.d.ts +2 -1
- package/i18n/locales/de-de.d.ts +2 -1
- package/i18n/locales/en-us.d.ts +2 -1
- package/i18n/locales/ja-jp.d.ts +2 -1
- package/i18n/locales/zh-hans.d.ts +2 -1
- package/i18n/locales/zh-hant.d.ts +2 -1
- package/image/preview/image-preview.component.d.ts +2 -2
- package/layout/header.component.d.ts +15 -19
- package/layout/layout.component.d.ts +3 -2
- package/layout/sidebar-header.component.d.ts +7 -8
- package/layout/sidebar.component.d.ts +32 -62
- package/list/selection/selection-list.d.ts +33 -46
- package/package.json +1 -1
- package/schematics/version.d.ts +1 -1
- package/schematics/version.js +1 -1
- package/select/custom-select/custom-select.component.d.ts +33 -56
- package/select/native-select/native-select.component.d.ts +7 -13
- package/shared/base-form-check.component.d.ts +6 -8
- package/shared/directives/string-or-template-outlet.directive.d.ts +5 -6
- package/shared/directives/thy-autofocus.directive.d.ts +4 -6
- package/shared/directives/thy-contextmenu.directive.d.ts +2 -2
- package/shared/directives/thy-ctrl-enter.directive.d.ts +2 -2
- package/shared/directives/thy-enter.directive.d.ts +2 -2
- package/shared/directives/thy-scroll.directive.d.ts +5 -8
- package/shared/directives/thy-show.d.ts +5 -6
- package/shared/directives/thy-stop-propagation.directive.d.ts +4 -4
- package/shared/directives/view-outlet.directive.d.ts +6 -7
- package/shared/ng-transclude.directive.d.ts +2 -3
- package/shared/option/group/option-group.component.d.ts +5 -9
- package/shared/option/list-option/list-option.component.d.ts +9 -13
- package/shared/option/option.component.d.ts +10 -17
- package/shared/option/option.token.d.ts +4 -3
- package/shared/option/options-container.component.d.ts +1 -1
- package/shared/select/select-control/select-control.component.d.ts +27 -47
- package/table/table-column.component.d.ts +15 -5
- package/tooltip/tooltip.directive.d.ts +20 -22
- package/tree-select/tree-select.component.d.ts +53 -70
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, Component, inject, Renderer2, ElementRef, NgZone, ChangeDetectorRef,
|
|
2
|
+
import { input, Component, inject, Renderer2, ElementRef, NgZone, ChangeDetectorRef, computed, output, effect, forwardRef, ContentChildren, ChangeDetectionStrategy, contentChild, NgModule } from '@angular/core';
|
|
3
3
|
import { NgTemplateOutlet, CommonModule } from '@angular/common';
|
|
4
4
|
import { coerceBooleanProperty, dom, helpers, keycodes } from 'ngx-tethys/util';
|
|
5
5
|
import { ScrollToService } from 'ngx-tethys/core';
|
|
6
6
|
import { ThyListOption, THY_LIST_OPTION_PARENT_COMPONENT, ThyOptionModule } from 'ngx-tethys/shared';
|
|
7
|
-
import { Subscription } from 'rxjs';
|
|
8
|
-
import { startWith } from 'rxjs/operators';
|
|
9
7
|
import { useHostRenderer } from '@tethys/cdk/dom';
|
|
10
8
|
import { ActiveDescendantKeyManager } from '@angular/cdk/a11y';
|
|
11
9
|
import { SelectionModel } from '@angular/cdk/collections';
|
|
12
10
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
11
|
+
import { startWith } from 'rxjs/operators';
|
|
13
12
|
import { ThyAvatar, ThyAvatarModule } from 'ngx-tethys/avatar';
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -71,177 +70,190 @@ class ThySelectionList {
|
|
|
71
70
|
this.elementRef = inject(ElementRef);
|
|
72
71
|
this.ngZone = inject(NgZone);
|
|
73
72
|
this.changeDetectorRef = inject(ChangeDetectorRef);
|
|
74
|
-
this._selectionChangesUnsubscribe$ = Subscription.EMPTY;
|
|
75
73
|
this.hostRenderer = useHostRenderer();
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
this.multiple = true;
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
/**
|
|
75
|
+
* 改变 grid item 的选择模式,使其支持多选
|
|
76
|
+
*/
|
|
77
|
+
this.multiple = input(true, { alias: 'thyMultiple', transform: coerceBooleanProperty });
|
|
78
|
+
/**
|
|
79
|
+
* 绑定键盘事件的容器
|
|
80
|
+
* @type HTMLElement | ElementRef | string
|
|
81
|
+
* @default thy-selection-list 组件绑定的元素
|
|
82
|
+
*/
|
|
83
|
+
this.thyBindKeyEventContainer = input();
|
|
84
|
+
/**
|
|
85
|
+
* 出现滚动条的容器
|
|
86
|
+
* @type HTMLElement | ElementRef | string
|
|
87
|
+
* @default thy-selection-list 组件绑定的元素
|
|
88
|
+
*/
|
|
89
|
+
this.thyScrollContainer = input();
|
|
90
|
+
/**
|
|
91
|
+
* 键盘事件触发 Before 调用,如果返回 false 则停止继续执行
|
|
92
|
+
*/
|
|
93
|
+
this.thyBeforeKeydown = input();
|
|
94
|
+
/**
|
|
95
|
+
* Option Value 唯一的 Key,用于存储哪些选择被选中的唯一值,只有 Option 的 thyValue 是对象的时才可以传入该选项
|
|
96
|
+
*/
|
|
97
|
+
this.thyUniqueKey = input();
|
|
98
|
+
/**
|
|
99
|
+
* 比较2个选项的 Value 是否相同
|
|
100
|
+
*/
|
|
101
|
+
this.thyCompareWith = input();
|
|
102
|
+
/**
|
|
103
|
+
* grid item 的展示样式
|
|
104
|
+
* @type list | grid
|
|
105
|
+
*/
|
|
106
|
+
this.layout = input('list', { alias: 'thyLayout' });
|
|
107
|
+
this.isLayoutGrid = computed(() => this.layout() === 'grid');
|
|
108
|
+
/**
|
|
109
|
+
* 是否自动激活第一项
|
|
110
|
+
*/
|
|
111
|
+
this.thyAutoActiveFirstItem = input(false, { transform: coerceBooleanProperty });
|
|
112
|
+
/**
|
|
113
|
+
* 改变 grid item 的大小,支持默认以及 sm 两种大小
|
|
114
|
+
* @type sm | md | lg
|
|
115
|
+
*/
|
|
116
|
+
this.thySize = input();
|
|
117
|
+
/**
|
|
118
|
+
* 是否按下空格切换聚焦选项
|
|
119
|
+
*/
|
|
120
|
+
this.thySpaceKeyEnabled = input(true, { transform: coerceBooleanProperty });
|
|
82
121
|
/**
|
|
83
122
|
* 每当选项的选定状态发生更改时,都会触发更改事件
|
|
84
|
-
* @type EventEmitter<ThySelectionListChange>
|
|
85
123
|
*/
|
|
86
|
-
this.thySelectionChange =
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const previousValue = this.multiple;
|
|
96
|
-
this.multiple = value;
|
|
97
|
-
if (previousValue !== this.multiple) {
|
|
98
|
-
this._instanceSelectionModel();
|
|
99
|
-
}
|
|
124
|
+
this.thySelectionChange = output();
|
|
125
|
+
this.onTouched = () => { };
|
|
126
|
+
this.onChange = (_) => { };
|
|
127
|
+
effect(() => {
|
|
128
|
+
this.setListSize();
|
|
129
|
+
});
|
|
130
|
+
effect(() => {
|
|
131
|
+
this.instanceSelectionModel();
|
|
132
|
+
});
|
|
100
133
|
}
|
|
101
|
-
|
|
102
|
-
* grid item 的展示样式
|
|
103
|
-
* @type list | grid
|
|
104
|
-
* @default list
|
|
105
|
-
*/
|
|
106
|
-
set thyLayout(value) {
|
|
107
|
-
this.layout = value;
|
|
108
|
-
this.isLayoutGrid = value === 'grid';
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* 是否自动激活第一项
|
|
112
|
-
*/
|
|
113
|
-
set thyAutoActiveFirstItem(value) {
|
|
114
|
-
this.autoActiveFirstItem = value;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* 改变 grid item 的大小,支持默认以及 sm 两种大小
|
|
118
|
-
* @type sm | md | lg
|
|
119
|
-
*/
|
|
120
|
-
set thySize(value) {
|
|
121
|
-
this._setListSize(value);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* 是否按下空格切换聚焦选项
|
|
125
|
-
*/
|
|
126
|
-
set thySpaceKeyEnabled(value) {
|
|
127
|
-
this.spaceEnabled = value;
|
|
128
|
-
}
|
|
129
|
-
_emitChangeEvent(option, event) {
|
|
134
|
+
emitChangeEvent(option, event) {
|
|
130
135
|
this.thySelectionChange.emit({
|
|
131
136
|
source: this,
|
|
132
|
-
value: option.thyValue,
|
|
137
|
+
value: option.thyValue(),
|
|
133
138
|
option: option,
|
|
134
139
|
event: event,
|
|
135
140
|
selected: this.isSelected(option)
|
|
136
141
|
});
|
|
137
142
|
}
|
|
138
|
-
|
|
143
|
+
emitModelValueChange() {
|
|
144
|
+
const uniqueKey = this.thyUniqueKey();
|
|
139
145
|
if (this.options) {
|
|
140
146
|
let selectedValues = this.selectionModel.selected;
|
|
141
|
-
if (
|
|
147
|
+
if (uniqueKey) {
|
|
142
148
|
selectedValues = selectedValues.map(selectedValue => {
|
|
143
149
|
const selectedOption = this.options.find(option => {
|
|
144
|
-
return option.thyValue[
|
|
150
|
+
return option.thyValue()[uniqueKey] === selectedValue;
|
|
145
151
|
});
|
|
146
152
|
if (selectedOption) {
|
|
147
|
-
return selectedOption.thyValue;
|
|
153
|
+
return selectedOption.thyValue();
|
|
148
154
|
}
|
|
149
155
|
else {
|
|
150
|
-
return this.
|
|
151
|
-
return value[
|
|
156
|
+
return this.modelValues.find(value => {
|
|
157
|
+
return value[uniqueKey] === selectedValue;
|
|
152
158
|
});
|
|
153
159
|
}
|
|
154
160
|
});
|
|
155
161
|
}
|
|
156
|
-
this.
|
|
162
|
+
this.modelValues = selectedValues;
|
|
157
163
|
let changeValue = selectedValues;
|
|
158
|
-
if (!this.multiple && selectedValues && selectedValues.length > 0) {
|
|
164
|
+
if (!this.multiple() && selectedValues && selectedValues.length > 0) {
|
|
159
165
|
changeValue = selectedValues[0];
|
|
160
166
|
}
|
|
161
|
-
this.
|
|
167
|
+
this.onChange(changeValue);
|
|
162
168
|
}
|
|
163
169
|
}
|
|
164
|
-
|
|
165
|
-
if (this.
|
|
170
|
+
toggleFocusedOption(event) {
|
|
171
|
+
if (this.keyManager.activeItem) {
|
|
166
172
|
this.ngZone.run(() => {
|
|
167
|
-
this.toggleOption(this.
|
|
173
|
+
this.toggleOption(this.keyManager.activeItem, event);
|
|
168
174
|
});
|
|
169
175
|
}
|
|
170
176
|
}
|
|
171
|
-
|
|
172
|
-
this.
|
|
177
|
+
initializeFocusKeyManager() {
|
|
178
|
+
this.keyManager = new ActiveDescendantKeyManager(this.options)
|
|
173
179
|
.withWrap()
|
|
174
180
|
// .withTypeAhead()
|
|
175
181
|
// Allow disabled items to be focusable. For accessibility reasons, there must be a way for
|
|
176
182
|
// screenreader users, that allows reading the different options of the list.
|
|
177
183
|
.skipPredicate(() => false);
|
|
178
184
|
}
|
|
179
|
-
|
|
180
|
-
this.selectionModel = new SelectionModel(this.multiple);
|
|
185
|
+
instanceSelectionModel() {
|
|
186
|
+
this.selectionModel = new SelectionModel(this.multiple());
|
|
181
187
|
}
|
|
182
|
-
|
|
188
|
+
getElementBySelector(element) {
|
|
183
189
|
return dom.getHTMLElementBySelector(element, this.elementRef);
|
|
184
190
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
191
|
+
compareValue(value1, value2) {
|
|
192
|
+
const thyUniqueKey = this.thyUniqueKey();
|
|
193
|
+
const thyCompareWith = this.thyCompareWith();
|
|
194
|
+
if (thyCompareWith) {
|
|
195
|
+
const compareFn = thyCompareWith;
|
|
188
196
|
return compareFn(value1, value2);
|
|
189
197
|
}
|
|
190
|
-
else if (
|
|
191
|
-
return value1 && value1[
|
|
198
|
+
else if (thyUniqueKey) {
|
|
199
|
+
return value1 && value1[thyUniqueKey] === value2 && value2[thyUniqueKey];
|
|
192
200
|
}
|
|
193
201
|
else {
|
|
194
202
|
return value1 === value2;
|
|
195
203
|
}
|
|
196
204
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
205
|
+
getOptionSelectionValue(option) {
|
|
206
|
+
const thyValue = option.thyValue();
|
|
207
|
+
if (thyValue) {
|
|
208
|
+
const thyUniqueKey = this.thyUniqueKey();
|
|
209
|
+
return thyUniqueKey ? thyValue[thyUniqueKey] : thyValue;
|
|
200
210
|
}
|
|
201
211
|
else {
|
|
202
212
|
return option;
|
|
203
213
|
}
|
|
204
214
|
}
|
|
205
|
-
|
|
215
|
+
setSelectionByValues(values) {
|
|
206
216
|
this.selectionModel.clear();
|
|
207
217
|
values.forEach(value => {
|
|
208
|
-
|
|
209
|
-
|
|
218
|
+
const thyUniqueKey = this.thyUniqueKey();
|
|
219
|
+
if (thyUniqueKey) {
|
|
220
|
+
this.selectionModel.select(value[thyUniqueKey]);
|
|
210
221
|
}
|
|
211
222
|
else {
|
|
212
223
|
this.selectionModel.select(value);
|
|
213
224
|
}
|
|
214
225
|
});
|
|
215
226
|
}
|
|
216
|
-
|
|
227
|
+
setAllOptionsSelected(toIsSelected) {
|
|
217
228
|
// Keep track of whether anything changed, because we only want to
|
|
218
229
|
// emit the changed event when something actually changed.
|
|
219
230
|
let hasChanged = false;
|
|
220
231
|
this.options.forEach(option => {
|
|
221
|
-
const fromIsSelected = this.selectionModel.isSelected(option.thyValue);
|
|
232
|
+
const fromIsSelected = this.selectionModel.isSelected(option.thyValue());
|
|
222
233
|
if (fromIsSelected !== toIsSelected) {
|
|
223
234
|
hasChanged = true;
|
|
224
|
-
this.selectionModel.toggle(option.thyValue);
|
|
235
|
+
this.selectionModel.toggle(option.thyValue());
|
|
225
236
|
}
|
|
226
237
|
});
|
|
227
238
|
if (hasChanged) {
|
|
228
|
-
this.
|
|
239
|
+
this.emitModelValueChange();
|
|
229
240
|
}
|
|
230
241
|
}
|
|
231
|
-
|
|
242
|
+
getOptionByValue(value) {
|
|
232
243
|
return this.options.find(option => {
|
|
233
|
-
return this.
|
|
244
|
+
return this.compareValue(option.thyValue(), value);
|
|
234
245
|
});
|
|
235
246
|
}
|
|
236
|
-
|
|
237
|
-
if (this.
|
|
238
|
-
return this.
|
|
247
|
+
getActiveOption() {
|
|
248
|
+
if (this.keyManager.activeItem) {
|
|
249
|
+
return this.getOptionByValue(this.keyManager.activeItem.thyValue());
|
|
239
250
|
}
|
|
240
251
|
else {
|
|
241
252
|
return null;
|
|
242
253
|
}
|
|
243
254
|
}
|
|
244
|
-
|
|
255
|
+
setListSize() {
|
|
256
|
+
const size = this.thySize();
|
|
245
257
|
for (const key in listSizesMap) {
|
|
246
258
|
if (listSizesMap.hasOwnProperty(key)) {
|
|
247
259
|
this.hostRenderer.removeClass(listSizesMap[key]);
|
|
@@ -252,55 +264,57 @@ class ThySelectionList {
|
|
|
252
264
|
}
|
|
253
265
|
}
|
|
254
266
|
ngOnInit() {
|
|
255
|
-
const bindKeyEventElement = this.
|
|
267
|
+
const bindKeyEventElement = this.getElementBySelector(this.thyBindKeyEventContainer());
|
|
256
268
|
this.ngZone.runOutsideAngular(() => {
|
|
257
|
-
this.
|
|
269
|
+
this.bindKeyEventUnsubscribe = this.renderer.listen(bindKeyEventElement, 'keydown', this.onKeydown.bind(this));
|
|
258
270
|
});
|
|
259
|
-
this.
|
|
271
|
+
this.instanceSelectionModel();
|
|
260
272
|
}
|
|
261
273
|
writeValue(value) {
|
|
262
274
|
if ((typeof ngDevMode === 'undefined' || ngDevMode) && value) {
|
|
263
|
-
|
|
275
|
+
const multiple = this.multiple();
|
|
276
|
+
if (multiple && !helpers.isArray(value)) {
|
|
264
277
|
throw new Error(`The multiple selection ngModel must be an array.`);
|
|
265
278
|
}
|
|
266
|
-
if (!
|
|
279
|
+
if (!multiple && helpers.isArray(value)) {
|
|
267
280
|
throw new Error(`The single selection ngModel should not be an array.`);
|
|
268
281
|
}
|
|
269
282
|
}
|
|
270
283
|
const values = helpers.isArray(value) ? value : value ? [value] : [];
|
|
271
|
-
this.
|
|
284
|
+
this.modelValues = values;
|
|
272
285
|
if (this.options) {
|
|
273
|
-
this.
|
|
286
|
+
this.setSelectionByValues(values);
|
|
274
287
|
}
|
|
275
288
|
this.changeDetectorRef.markForCheck();
|
|
276
289
|
}
|
|
277
290
|
registerOnChange(fn) {
|
|
278
|
-
this.
|
|
291
|
+
this.onChange = fn;
|
|
279
292
|
}
|
|
280
293
|
registerOnTouched(fn) {
|
|
281
|
-
this.
|
|
294
|
+
this.onTouched = fn;
|
|
282
295
|
}
|
|
283
296
|
setDisabledState(isDisabled) {
|
|
284
297
|
this.disabled = isDisabled;
|
|
285
298
|
}
|
|
286
299
|
onKeydown(event) {
|
|
287
|
-
|
|
300
|
+
const thyBeforeKeydown = this.thyBeforeKeydown();
|
|
301
|
+
if (thyBeforeKeydown) {
|
|
288
302
|
// stop key down event
|
|
289
|
-
const isContinue =
|
|
303
|
+
const isContinue = thyBeforeKeydown(event);
|
|
290
304
|
if (!isContinue) {
|
|
291
305
|
return;
|
|
292
306
|
}
|
|
293
307
|
}
|
|
294
308
|
const keyCode = event.keyCode || event.which;
|
|
295
|
-
const manager = this.
|
|
309
|
+
const manager = this.keyManager;
|
|
296
310
|
const previousFocusIndex = manager.activeItemIndex;
|
|
297
311
|
switch (keyCode) {
|
|
298
312
|
case keycodes.SPACE:
|
|
299
313
|
case keycodes.ENTER:
|
|
300
|
-
if (keyCode === keycodes.SPACE && !this.
|
|
314
|
+
if (keyCode === keycodes.SPACE && !this.thySpaceKeyEnabled()) {
|
|
301
315
|
return;
|
|
302
316
|
}
|
|
303
|
-
this.
|
|
317
|
+
this.toggleFocusedOption(event);
|
|
304
318
|
// Always prevent space from scrolling the page since the list has focus
|
|
305
319
|
event.preventDefault();
|
|
306
320
|
break;
|
|
@@ -310,64 +324,63 @@ class ThySelectionList {
|
|
|
310
324
|
if ((keyCode === keycodes.UP_ARROW || keyCode === keycodes.DOWN_ARROW) &&
|
|
311
325
|
event.shiftKey &&
|
|
312
326
|
manager.activeItemIndex !== previousFocusIndex) {
|
|
313
|
-
this.
|
|
327
|
+
this.toggleFocusedOption(event);
|
|
314
328
|
}
|
|
315
329
|
}
|
|
316
330
|
toggleOption(option, event) {
|
|
317
|
-
if (option && !option.
|
|
318
|
-
this.selectionModel.toggle(this.
|
|
331
|
+
if (option && !option.thyDisabled()) {
|
|
332
|
+
this.selectionModel.toggle(this.getOptionSelectionValue(option));
|
|
319
333
|
// Emit a change event because the focused option changed its state through user
|
|
320
334
|
// interaction.
|
|
321
|
-
this.
|
|
322
|
-
this.
|
|
335
|
+
this.emitModelValueChange();
|
|
336
|
+
this.emitChangeEvent(option, event);
|
|
323
337
|
}
|
|
324
338
|
}
|
|
325
339
|
setActiveOption(option) {
|
|
326
|
-
this.
|
|
340
|
+
this.keyManager.updateActiveItem(option); // .updateActiveItemIndex(this._getOptionIndex(option));
|
|
327
341
|
}
|
|
328
342
|
scrollIntoView(option) {
|
|
329
|
-
const scrollContainerElement = dom.getHTMLElementBySelector(this.thyScrollContainer, this.elementRef);
|
|
343
|
+
const scrollContainerElement = dom.getHTMLElementBySelector(this.thyScrollContainer(), this.elementRef);
|
|
330
344
|
ScrollToService.scrollToElement(option.element.nativeElement, scrollContainerElement);
|
|
331
345
|
}
|
|
332
346
|
isSelected(option) {
|
|
333
|
-
return this.selectionModel.isSelected(this.
|
|
347
|
+
return this.selectionModel.isSelected(this.getOptionSelectionValue(option));
|
|
334
348
|
}
|
|
335
349
|
clearActiveItem() {
|
|
336
|
-
if (this.
|
|
337
|
-
this.
|
|
350
|
+
if (this.keyManager.activeItem) {
|
|
351
|
+
this.keyManager.setActiveItem(-1);
|
|
338
352
|
}
|
|
339
353
|
}
|
|
340
354
|
determineClearActiveItem() {
|
|
341
|
-
if (!this.
|
|
355
|
+
if (!this.getActiveOption()) {
|
|
342
356
|
this.clearActiveItem();
|
|
343
357
|
}
|
|
344
358
|
}
|
|
345
359
|
/** Selects all of the options. */
|
|
346
360
|
selectAll() {
|
|
347
|
-
this.
|
|
361
|
+
this.setAllOptionsSelected(true);
|
|
348
362
|
}
|
|
349
363
|
/** Deselects all of the options. */
|
|
350
364
|
deselectAll() {
|
|
351
|
-
this.
|
|
365
|
+
this.setAllOptionsSelected(false);
|
|
352
366
|
}
|
|
353
367
|
ngAfterContentInit() {
|
|
354
|
-
this.
|
|
368
|
+
this.initializeFocusKeyManager();
|
|
355
369
|
this.options.changes.pipe(startWith(true)).subscribe(() => {
|
|
356
|
-
if (this.
|
|
357
|
-
if (!this.
|
|
358
|
-
this.
|
|
370
|
+
if (this.thyAutoActiveFirstItem()) {
|
|
371
|
+
if (!this.keyManager.activeItem || this.options.toArray().indexOf(this.keyManager.activeItem) < 0) {
|
|
372
|
+
this.keyManager.setFirstItemActive();
|
|
359
373
|
}
|
|
360
374
|
}
|
|
361
375
|
});
|
|
362
376
|
}
|
|
363
377
|
ngOnDestroy() {
|
|
364
|
-
this.
|
|
365
|
-
|
|
366
|
-
this._bindKeyEventUnsubscribe();
|
|
378
|
+
if (this.bindKeyEventUnsubscribe) {
|
|
379
|
+
this.bindKeyEventUnsubscribe();
|
|
367
380
|
}
|
|
368
381
|
}
|
|
369
382
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: ThySelectionList, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
370
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
383
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.8", type: ThySelectionList, isStandalone: true, selector: "thy-selection-list,[thy-selection-list]", inputs: { multiple: { classPropertyName: "multiple", publicName: "thyMultiple", isSignal: true, isRequired: false, transformFunction: null }, thyBindKeyEventContainer: { classPropertyName: "thyBindKeyEventContainer", publicName: "thyBindKeyEventContainer", isSignal: true, isRequired: false, transformFunction: null }, thyScrollContainer: { classPropertyName: "thyScrollContainer", publicName: "thyScrollContainer", isSignal: true, isRequired: false, transformFunction: null }, thyBeforeKeydown: { classPropertyName: "thyBeforeKeydown", publicName: "thyBeforeKeydown", isSignal: true, isRequired: false, transformFunction: null }, thyUniqueKey: { classPropertyName: "thyUniqueKey", publicName: "thyUniqueKey", isSignal: true, isRequired: false, transformFunction: null }, thyCompareWith: { classPropertyName: "thyCompareWith", publicName: "thyCompareWith", isSignal: true, isRequired: false, transformFunction: null }, layout: { classPropertyName: "layout", publicName: "thyLayout", isSignal: true, isRequired: false, transformFunction: null }, thyAutoActiveFirstItem: { classPropertyName: "thyAutoActiveFirstItem", publicName: "thyAutoActiveFirstItem", isSignal: true, isRequired: false, transformFunction: null }, thySize: { classPropertyName: "thySize", publicName: "thySize", isSignal: true, isRequired: false, transformFunction: null }, thySpaceKeyEnabled: { classPropertyName: "thySpaceKeyEnabled", publicName: "thySpaceKeyEnabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { thySelectionChange: "thySelectionChange" }, host: { properties: { "class.thy-multiple-selection-list": "multiple()", "class.thy-grid-list": "isLayoutGrid()" }, classAttribute: "thy-list thy-selection-list" }, providers: [
|
|
371
384
|
{
|
|
372
385
|
provide: THY_LIST_OPTION_PARENT_COMPONENT,
|
|
373
386
|
useExisting: ThySelectionList
|
|
@@ -395,48 +408,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
395
408
|
multi: true
|
|
396
409
|
}
|
|
397
410
|
],
|
|
411
|
+
host: {
|
|
412
|
+
class: 'thy-list thy-selection-list',
|
|
413
|
+
'[class.thy-multiple-selection-list]': 'multiple()',
|
|
414
|
+
'[class.thy-grid-list]': 'isLayoutGrid()'
|
|
415
|
+
},
|
|
398
416
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
399
417
|
}]
|
|
400
|
-
}], propDecorators: {
|
|
401
|
-
type: HostBinding,
|
|
402
|
-
args: [`class.thy-list`]
|
|
403
|
-
}], _isSelectionList: [{
|
|
404
|
-
type: HostBinding,
|
|
405
|
-
args: [`class.thy-selection-list`]
|
|
406
|
-
}], multiple: [{
|
|
407
|
-
type: HostBinding,
|
|
408
|
-
args: [`class.thy-multiple-selection-list`]
|
|
409
|
-
}], isLayoutGrid: [{
|
|
410
|
-
type: HostBinding,
|
|
411
|
-
args: [`class.thy-grid-list`]
|
|
412
|
-
}], options: [{
|
|
418
|
+
}], ctorParameters: () => [], propDecorators: { options: [{
|
|
413
419
|
type: ContentChildren,
|
|
414
420
|
args: [ThyListOption, { descendants: true }]
|
|
415
|
-
}], thyMultiple: [{
|
|
416
|
-
type: Input,
|
|
417
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
418
|
-
}], thyBindKeyEventContainer: [{
|
|
419
|
-
type: Input
|
|
420
|
-
}], thyScrollContainer: [{
|
|
421
|
-
type: Input
|
|
422
|
-
}], thyBeforeKeydown: [{
|
|
423
|
-
type: Input
|
|
424
|
-
}], thyUniqueKey: [{
|
|
425
|
-
type: Input
|
|
426
|
-
}], thyCompareWith: [{
|
|
427
|
-
type: Input
|
|
428
|
-
}], thyLayout: [{
|
|
429
|
-
type: Input
|
|
430
|
-
}], thyAutoActiveFirstItem: [{
|
|
431
|
-
type: Input,
|
|
432
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
433
|
-
}], thySize: [{
|
|
434
|
-
type: Input
|
|
435
|
-
}], thySpaceKeyEnabled: [{
|
|
436
|
-
type: Input,
|
|
437
|
-
args: [{ transform: coerceBooleanProperty }]
|
|
438
|
-
}], thySelectionChange: [{
|
|
439
|
-
type: Output
|
|
440
421
|
}] } });
|
|
441
422
|
|
|
442
423
|
/**
|