@ptsecurity/mosaic 13.9.1 → 13.9.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/_theming.scss +50 -28
- package/_visual.scss +45 -28
- package/core/formatters/date/formatter.d.ts +6 -2
- package/design-tokens/legacy-2017/tokens/components/form-field.json5 +2 -2
- package/design-tokens/legacy-2017/tokens/components/popover.json5 +1 -0
- package/design-tokens/legacy-2017/tokens/components/radio.json5 +1 -0
- package/design-tokens/legacy-2017/tokens/properties/typography.json5 +42 -33
- package/design-tokens/legacy-2017/tokens.d.ts +44 -35
- package/design-tokens/pt-2022/tokens/components/form-field.json5 +2 -2
- package/design-tokens/pt-2022/tokens/components/link.json5 +2 -2
- package/design-tokens/pt-2022/tokens/components/popover.json5 +7 -6
- package/design-tokens/pt-2022/tokens/properties/typography.json5 +33 -24
- package/design-tokens/pt-2022/tokens.d.ts +36 -28
- package/esm2020/button/button.component.mjs +2 -2
- package/esm2020/core/formatters/date/formatter.mjs +7 -3
- package/esm2020/design-tokens/legacy-2017/tokens.mjs +45 -36
- package/esm2020/design-tokens/pt-2022/tokens.mjs +37 -29
- package/esm2020/list/list-selection.component.mjs +227 -217
- package/esm2020/popover/popover-confirm.component.mjs +3 -3
- package/esm2020/popover/popover.component.mjs +3 -3
- package/esm2020/toast/toast.component.mjs +13 -10
- package/esm2020/tree/tree-option.component.mjs +5 -1
- package/esm2020/tree/tree-selection.component.mjs +7 -1
- package/fesm2015/ptsecurity-mosaic-button.mjs +2 -2
- package/fesm2015/ptsecurity-mosaic-button.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-core.mjs +6 -2
- package/fesm2015/ptsecurity-mosaic-core.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-design-tokens.mjs +90 -64
- package/fesm2015/ptsecurity-mosaic-design-tokens.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-list.mjs +235 -225
- package/fesm2015/ptsecurity-mosaic-list.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-popover.mjs +4 -4
- package/fesm2015/ptsecurity-mosaic-popover.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-toast.mjs +13 -8
- package/fesm2015/ptsecurity-mosaic-toast.mjs.map +1 -1
- package/fesm2015/ptsecurity-mosaic-tree.mjs +10 -0
- package/fesm2015/ptsecurity-mosaic-tree.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-button.mjs +2 -2
- package/fesm2020/ptsecurity-mosaic-button.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-core.mjs +6 -2
- package/fesm2020/ptsecurity-mosaic-core.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-design-tokens.mjs +90 -64
- package/fesm2020/ptsecurity-mosaic-design-tokens.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-list.mjs +230 -220
- package/fesm2020/ptsecurity-mosaic-list.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-popover.mjs +4 -4
- package/fesm2020/ptsecurity-mosaic-popover.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-toast.mjs +11 -8
- package/fesm2020/ptsecurity-mosaic-toast.mjs.map +1 -1
- package/fesm2020/ptsecurity-mosaic-tree.mjs +10 -0
- package/fesm2020/ptsecurity-mosaic-tree.mjs.map +1 -1
- package/list/list-selection.component.d.ts +53 -52
- package/package.json +4 -4
- package/prebuilt-themes/dark-theme.css +1 -1
- package/prebuilt-themes/default-theme.css +1 -1
- package/tree/tree-option.component.d.ts +1 -0
@@ -1,233 +1,21 @@
|
|
1
1
|
import { A11yModule } from '@angular/cdk/a11y';
|
2
|
-
import * as
|
2
|
+
import * as i3 from '@angular/common';
|
3
3
|
import { CommonModule } from '@angular/common';
|
4
4
|
import * as i0 from '@angular/core';
|
5
|
-
import { forwardRef,
|
6
|
-
import * as
|
7
|
-
import {
|
5
|
+
import { forwardRef, EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Attribute, Optional, ContentChildren, Output, Input, Inject, ContentChild, ViewChild, NgModule } from '@angular/core';
|
6
|
+
import * as i2 from '@ptsecurity/mosaic/core';
|
7
|
+
import { mixinTabIndex, mixinDisabled, MultipleMode, toBoolean, MC_OPTION_ACTION_PARENT, McOptionActionComponent, McLineSetter, McLine, McPseudoCheckboxModule, McLineModule, McOptionModule } from '@ptsecurity/mosaic/core';
|
8
8
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
9
9
|
import { SelectionModel } from '@angular/cdk/collections';
|
10
10
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
11
11
|
import { FocusKeyManager } from '@ptsecurity/cdk/a11y';
|
12
|
-
import {
|
12
|
+
import { SPACE, ENTER, LEFT_ARROW, RIGHT_ARROW, isVerticalMovement, isSelectAll, isCopy, TAB, DOWN_ARROW, UP_ARROW, HOME, END, PAGE_UP, PAGE_DOWN, hasModifierKey } from '@ptsecurity/cdk/keycodes';
|
13
13
|
import { McDropdownTrigger } from '@ptsecurity/mosaic/dropdown';
|
14
14
|
import { McTooltipTrigger } from '@ptsecurity/mosaic/tooltip';
|
15
15
|
import { Subject, merge } from 'rxjs';
|
16
|
-
import {
|
17
|
-
import * as
|
16
|
+
import { takeUntil, startWith, take } from 'rxjs/operators';
|
17
|
+
import * as i1 from '@angular/cdk/clipboard';
|
18
18
|
|
19
|
-
/**
|
20
|
-
* Component for list-options of selection-list. Each list-option can automatically
|
21
|
-
* generate a checkbox and can put current item into the selectionModel of selection-list
|
22
|
-
* if the current item is selected.
|
23
|
-
*/
|
24
|
-
class McListOption {
|
25
|
-
constructor(elementRef, changeDetector, ngZone, listSelection, group) {
|
26
|
-
this.elementRef = elementRef;
|
27
|
-
this.changeDetector = changeDetector;
|
28
|
-
this.ngZone = ngZone;
|
29
|
-
this.listSelection = listSelection;
|
30
|
-
this.group = group;
|
31
|
-
this.hasFocus = false;
|
32
|
-
this.onFocus = new Subject();
|
33
|
-
this.onBlur = new Subject();
|
34
|
-
/**
|
35
|
-
* This is set to true after the first OnChanges cycle so we don't clear the value of `selected`
|
36
|
-
* in the first cycle.
|
37
|
-
*/
|
38
|
-
this.inputsInitialized = false;
|
39
|
-
this._disabled = false;
|
40
|
-
this._selected = false;
|
41
|
-
}
|
42
|
-
get value() { return this._value; }
|
43
|
-
set value(newValue) {
|
44
|
-
if (this.selected && newValue !== this.value && this.inputsInitialized) {
|
45
|
-
this.selected = false;
|
46
|
-
}
|
47
|
-
this._value = newValue;
|
48
|
-
}
|
49
|
-
get disabled() {
|
50
|
-
const listSelectionDisabled = this.listSelection && this.listSelection.disabled;
|
51
|
-
const groupDisabled = this.group && this.group.disabled;
|
52
|
-
return listSelectionDisabled || groupDisabled || this._disabled;
|
53
|
-
}
|
54
|
-
set disabled(value) {
|
55
|
-
const newValue = toBoolean(value);
|
56
|
-
if (newValue !== this._disabled) {
|
57
|
-
this._disabled = newValue;
|
58
|
-
this.changeDetector.markForCheck();
|
59
|
-
}
|
60
|
-
}
|
61
|
-
get showCheckbox() {
|
62
|
-
return this._showCheckbox !== undefined ? this._showCheckbox : this.listSelection.showCheckbox;
|
63
|
-
}
|
64
|
-
set showCheckbox(value) {
|
65
|
-
this._showCheckbox = coerceBooleanProperty(value);
|
66
|
-
}
|
67
|
-
get selected() {
|
68
|
-
var _a;
|
69
|
-
return ((_a = this.listSelection.selectionModel) === null || _a === void 0 ? void 0 : _a.isSelected(this)) || false;
|
70
|
-
}
|
71
|
-
set selected(value) {
|
72
|
-
const isSelected = toBoolean(value);
|
73
|
-
if (isSelected !== this._selected) {
|
74
|
-
this.setSelected(isSelected);
|
75
|
-
}
|
76
|
-
}
|
77
|
-
get tabIndex() {
|
78
|
-
return this.disabled ? null : -1;
|
79
|
-
}
|
80
|
-
ngOnInit() {
|
81
|
-
const list = this.listSelection;
|
82
|
-
if (list._value && list._value.some((value) => list.compareWith(value, this._value))) {
|
83
|
-
this.setSelected(true);
|
84
|
-
}
|
85
|
-
const wasSelected = this._selected;
|
86
|
-
// List options that are selected at initialization can't be reported properly to the form
|
87
|
-
// control. This is because it takes some time until the selection-list knows about all
|
88
|
-
// available options. Also it can happen that the ControlValueAccessor has an initial value
|
89
|
-
// that should be used instead. Deferring the value change report to the next tick ensures
|
90
|
-
// that the form control value is not being overwritten.
|
91
|
-
Promise.resolve().then(() => {
|
92
|
-
if (this._selected || wasSelected) {
|
93
|
-
this.selected = true;
|
94
|
-
this.changeDetector.markForCheck();
|
95
|
-
}
|
96
|
-
});
|
97
|
-
this.inputsInitialized = true;
|
98
|
-
}
|
99
|
-
ngOnDestroy() {
|
100
|
-
if (this.selected) {
|
101
|
-
// We have to delay this until the next tick in order
|
102
|
-
// to avoid changed after checked errors.
|
103
|
-
Promise.resolve().then(() => this.selected = false);
|
104
|
-
}
|
105
|
-
this.listSelection.removeOptionFromList(this);
|
106
|
-
}
|
107
|
-
toggle() {
|
108
|
-
this.selected = !this.selected;
|
109
|
-
}
|
110
|
-
getLabel() {
|
111
|
-
return this.text ? this.text.nativeElement.textContent : '';
|
112
|
-
}
|
113
|
-
setSelected(selected) {
|
114
|
-
if (this._selected === selected || !this.listSelection.selectionModel) {
|
115
|
-
return;
|
116
|
-
}
|
117
|
-
this._selected = selected;
|
118
|
-
if (selected) {
|
119
|
-
this.listSelection.selectionModel.select(this);
|
120
|
-
}
|
121
|
-
else {
|
122
|
-
this.listSelection.selectionModel.deselect(this);
|
123
|
-
}
|
124
|
-
this.changeDetector.markForCheck();
|
125
|
-
}
|
126
|
-
getHeight() {
|
127
|
-
const clientRects = this.elementRef.nativeElement.getClientRects();
|
128
|
-
return clientRects.length ? clientRects[0].height : 0;
|
129
|
-
}
|
130
|
-
handleClick($event) {
|
131
|
-
if (this.disabled) {
|
132
|
-
return;
|
133
|
-
}
|
134
|
-
this.listSelection.setSelectedOptionsByClick(this, hasModifierKey($event, 'shiftKey'), hasModifierKey($event, 'ctrlKey'));
|
135
|
-
}
|
136
|
-
onKeydown($event) {
|
137
|
-
if (!this.actionButton) {
|
138
|
-
return;
|
139
|
-
}
|
140
|
-
if ($event.keyCode === TAB && !$event.shiftKey && !this.actionButton.hasFocus) {
|
141
|
-
this.actionButton.focus();
|
142
|
-
$event.preventDefault();
|
143
|
-
}
|
144
|
-
}
|
145
|
-
focus() {
|
146
|
-
var _a;
|
147
|
-
if (this.disabled || this.hasFocus || ((_a = this.actionButton) === null || _a === void 0 ? void 0 : _a.hasFocus)) {
|
148
|
-
return;
|
149
|
-
}
|
150
|
-
this.elementRef.nativeElement.focus();
|
151
|
-
this.onFocus.next({ option: this });
|
152
|
-
Promise.resolve().then(() => {
|
153
|
-
this.hasFocus = true;
|
154
|
-
this.changeDetector.markForCheck();
|
155
|
-
});
|
156
|
-
}
|
157
|
-
blur() {
|
158
|
-
// When animations are enabled, Angular may end up removing the option from the DOM a little
|
159
|
-
// earlier than usual, causing it to be blurred and throwing off the logic in the list
|
160
|
-
// that moves focus not the next item. To work around the issue, we defer marking the option
|
161
|
-
// as not focused until the next time the zone stabilizes.
|
162
|
-
this.ngZone.onStable
|
163
|
-
.asObservable()
|
164
|
-
.pipe(take(1))
|
165
|
-
.subscribe(() => {
|
166
|
-
this.ngZone.run(() => {
|
167
|
-
var _a;
|
168
|
-
this.hasFocus = false;
|
169
|
-
if ((_a = this.actionButton) === null || _a === void 0 ? void 0 : _a.hasFocus) {
|
170
|
-
return;
|
171
|
-
}
|
172
|
-
this.onBlur.next({ option: this });
|
173
|
-
});
|
174
|
-
});
|
175
|
-
}
|
176
|
-
getHostElement() {
|
177
|
-
return this.elementRef.nativeElement;
|
178
|
-
}
|
179
|
-
}
|
180
|
-
/** @nocollapse */ /** @nocollapse */ McListOption.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: McListOption, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: forwardRef(() => McListSelection) }, { token: i1.McOptgroup, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
181
|
-
/** @nocollapse */ /** @nocollapse */ McListOption.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: McListOption, selector: "mc-list-option", inputs: { checkboxPosition: "checkboxPosition", value: "value", disabled: "disabled", showCheckbox: "showCheckbox", selected: "selected" }, host: { listeners: { "focusin": "focus()", "blur": "blur()", "click": "handleClick($event)", "keydown": "onKeydown($event)" }, properties: { "class.mc-selected": "selected", "class.mc-disabled": "disabled", "class.mc-focused": "hasFocus", "class.mc-action-button-focused": "actionButton?.active", "attr.tabindex": "tabIndex", "attr.disabled": "disabled || null" }, classAttribute: "mc-list-option" }, providers: [
|
182
|
-
{ provide: MC_OPTION_ACTION_PARENT, useExisting: McListOption }
|
183
|
-
], queries: [{ propertyName: "actionButton", first: true, predicate: McOptionActionComponent, descendants: true }, { propertyName: "tooltipTrigger", first: true, predicate: McTooltipTrigger, descendants: true }, { propertyName: "dropdownTrigger", first: true, predicate: McDropdownTrigger, descendants: true }], viewQueries: [{ propertyName: "text", first: true, predicate: ["text"], descendants: true }], exportAs: ["mcListOption"], ngImport: i0, template: "<mc-pseudo-checkbox\n *ngIf=\"showCheckbox\"\n [state]=\"selected ? 'checked' : 'unchecked'\"\n [disabled]=\"disabled\">\n</mc-pseudo-checkbox>\n\n<ng-content select=\"[mc-icon]\"></ng-content>\n\n<div class=\"mc-list-text\" #text>\n <ng-content></ng-content>\n</div>\n\n<ng-content select=\"mc-option-action\"></ng-content>\n", components: [{ type: i1.McPseudoCheckbox, selector: "mc-pseudo-checkbox", inputs: ["color", "state", "disabled"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
184
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: McListOption, decorators: [{
|
185
|
-
type: Component,
|
186
|
-
args: [{ exportAs: 'mcListOption', selector: 'mc-list-option', host: {
|
187
|
-
class: 'mc-list-option',
|
188
|
-
'[class.mc-selected]': 'selected',
|
189
|
-
'[class.mc-disabled]': 'disabled',
|
190
|
-
'[class.mc-focused]': 'hasFocus',
|
191
|
-
'[class.mc-action-button-focused]': 'actionButton?.active',
|
192
|
-
'[attr.tabindex]': 'tabIndex',
|
193
|
-
'[attr.disabled]': 'disabled || null',
|
194
|
-
'(focusin)': 'focus()',
|
195
|
-
'(blur)': 'blur()',
|
196
|
-
'(click)': 'handleClick($event)',
|
197
|
-
'(keydown)': 'onKeydown($event)'
|
198
|
-
}, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
199
|
-
{ provide: MC_OPTION_ACTION_PARENT, useExisting: McListOption }
|
200
|
-
], template: "<mc-pseudo-checkbox\n *ngIf=\"showCheckbox\"\n [state]=\"selected ? 'checked' : 'unchecked'\"\n [disabled]=\"disabled\">\n</mc-pseudo-checkbox>\n\n<ng-content select=\"[mc-icon]\"></ng-content>\n\n<div class=\"mc-list-text\" #text>\n <ng-content></ng-content>\n</div>\n\n<ng-content select=\"mc-option-action\"></ng-content>\n" }]
|
201
|
-
}], ctorParameters: function () {
|
202
|
-
return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: McListSelection, decorators: [{
|
203
|
-
type: Inject,
|
204
|
-
args: [forwardRef(() => McListSelection)]
|
205
|
-
}] }, { type: i1.McOptgroup, decorators: [{
|
206
|
-
type: Optional
|
207
|
-
}] }];
|
208
|
-
}, propDecorators: { actionButton: [{
|
209
|
-
type: ContentChild,
|
210
|
-
args: [McOptionActionComponent]
|
211
|
-
}], tooltipTrigger: [{
|
212
|
-
type: ContentChild,
|
213
|
-
args: [McTooltipTrigger]
|
214
|
-
}], dropdownTrigger: [{
|
215
|
-
type: ContentChild,
|
216
|
-
args: [McDropdownTrigger]
|
217
|
-
}], text: [{
|
218
|
-
type: ViewChild,
|
219
|
-
args: ['text', { static: false }]
|
220
|
-
}], checkboxPosition: [{
|
221
|
-
type: Input
|
222
|
-
}], value: [{
|
223
|
-
type: Input
|
224
|
-
}], disabled: [{
|
225
|
-
type: Input
|
226
|
-
}], showCheckbox: [{
|
227
|
-
type: Input
|
228
|
-
}], selected: [{
|
229
|
-
type: Input
|
230
|
-
}] } });
|
231
19
|
const MC_SELECTION_LIST_VALUE_ACCESSOR = {
|
232
20
|
provide: NG_VALUE_ACCESSOR,
|
233
21
|
useExisting: forwardRef(() => McListSelection),
|
@@ -639,16 +427,22 @@ class McListSelection extends McListSelectionMixinBase {
|
|
639
427
|
this.onSelectAll.emit(new McListSelectAllEvent(this, optionsToSelect));
|
640
428
|
}
|
641
429
|
copyActiveOption() {
|
430
|
+
if (!this.keyManager.activeItem) {
|
431
|
+
return;
|
432
|
+
}
|
433
|
+
const option = this.keyManager.activeItem;
|
434
|
+
option.preventBlur = true;
|
642
435
|
if (this.onCopy.observers.length) {
|
643
|
-
this.onCopy.emit(new McListCopyEvent(this,
|
436
|
+
this.onCopy.emit(new McListCopyEvent(this, option));
|
644
437
|
}
|
645
438
|
else {
|
646
439
|
this.onCopyDefaultHandler();
|
647
440
|
}
|
441
|
+
option.preventBlur = false;
|
648
442
|
}
|
649
443
|
}
|
650
|
-
/** @nocollapse */ /** @nocollapse */ McListSelection.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: McListSelection, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: 'multiple', attribute: true }, { token:
|
651
|
-
/** @nocollapse */ /** @nocollapse */ McListSelection.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: McListSelection, selector: "mc-list-selection", inputs: { disabled: "disabled", autoSelect: "autoSelect", noUnselectLast: "noUnselectLast", horizontal: "horizontal", tabIndex: "tabIndex", compareWith: "compareWith" }, outputs: { onSelectAll: "onSelectAll", onCopy: "onCopy", selectionChange: "selectionChange" }, host: { listeners: { "keydown": "onKeyDown($event)", "window:resize": "updateScrollSize()" }, properties: { "attr.tabindex": "-1", "attr.disabled": "disabled || null" }, classAttribute: "mc-list-selection" }, providers: [MC_SELECTION_LIST_VALUE_ACCESSOR], queries: [{ propertyName: "options", predicate: McListOption, descendants: true }], exportAs: ["mcListSelection"], usesInheritance: true, ngImport: i0, template: `
|
444
|
+
/** @nocollapse */ /** @nocollapse */ McListSelection.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: McListSelection, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: 'multiple', attribute: true }, { token: i1.Clipboard, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
445
|
+
/** @nocollapse */ /** @nocollapse */ McListSelection.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: McListSelection, selector: "mc-list-selection", inputs: { disabled: "disabled", autoSelect: "autoSelect", noUnselectLast: "noUnselectLast", horizontal: "horizontal", tabIndex: "tabIndex", compareWith: "compareWith" }, outputs: { onSelectAll: "onSelectAll", onCopy: "onCopy", selectionChange: "selectionChange" }, host: { listeners: { "keydown": "onKeyDown($event)", "window:resize": "updateScrollSize()" }, properties: { "attr.tabindex": "-1", "attr.disabled": "disabled || null" }, classAttribute: "mc-list-selection" }, providers: [MC_SELECTION_LIST_VALUE_ACCESSOR], queries: [{ propertyName: "options", predicate: i0.forwardRef(function () { return McListOption; }), descendants: true }], exportAs: ["mcListSelection"], usesInheritance: true, ngImport: i0, template: `
|
652
446
|
<div [attr.tabindex]="tabIndex"
|
653
447
|
(focus)="focus()"
|
654
448
|
(blur)="blur()">
|
@@ -669,15 +463,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
669
463
|
'(window:resize)': 'updateScrollSize()'
|
670
464
|
}, providers: [MC_SELECTION_LIST_VALUE_ACCESSOR], preserveWhitespaces: false, styles: [".mc-divider{display:block;margin:0}.mc-divider.mc-divider_horizontal{border-top-width:var(--mc-divider-size-width, 1px);border-top-style:solid}.mc-divider.mc-divider_vertical{height:100%;border-right-width:var(--mc-divider-size-width, 1px);border-right-style:solid}.mc-divider.mc-divider_inset{margin-left:var(--mc-divider-size-inset-margin, 80px)}[dir=rtl] .mc-divider.mc-divider_inset{margin-left:auto;margin-right:var(--mc-divider-size-inset-margin, 80px)}.mc-no-select{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}.mc-list,.mc-list-selection{display:block;outline:none}.mc-list-item,.mc-list-option{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;position:relative;display:flex;align-items:center;box-sizing:border-box;height:var(--mc-list-size-item-height, 32px);border:2px solid transparent;padding-left:var(--mc-list-size-horizontal-padding, 12px)}.mc-list-item .mc-list-text,.mc-list-option .mc-list-text{display:flex;flex-direction:column;width:100%;box-sizing:border-box;overflow:hidden;padding-right:var(--mc-list-size-horizontal-padding, 12px)}.mc-list-item .mc-list-text>*,.mc-list-option .mc-list-text>*{margin:0;padding:0;font-weight:400;font-size:inherit}.mc-list-item .mc-list-text:empty,.mc-list-option .mc-list-text:empty{display:none}.mc-list-item .mc-divider,.mc-list-option .mc-divider{position:absolute;bottom:0;left:0;width:100%;margin:0}[dir=rtl] .mc-list-item .mc-divider,[dir=rtl] .mc-list-option .mc-divider{margin-left:auto;margin-right:0}.mc-list-item .mc-divider.mc-divider_inset,.mc-list-option .mc-divider.mc-divider_inset{position:absolute}.mc-list-item.mc-progress:after,.mc-list-option.mc-progress:after{top:-2px;right:-2px;bottom:-2px;left:-2px}.mc-list-item .mc-pseudo-checkbox,.mc-list-item .mc-icon,.mc-list-option .mc-pseudo-checkbox,.mc-list-option .mc-icon{margin-right:var(--mc-list-size-icon-right-margin, 8px)}.mc-list-item .mc-option-action,.mc-list-option .mc-option-action{display:none}.mc-list-item:not([disabled]):hover .mc-option-action,.mc-list-item:not([disabled]).mc-focused .mc-option-action,.mc-list-item:not([disabled]).mc-action-button-focused .mc-option-action,.mc-list-option:not([disabled]):hover .mc-option-action,.mc-list-option:not([disabled]).mc-focused .mc-option-action,.mc-list-option:not([disabled]).mc-action-button-focused .mc-option-action{display:flex}.mc-list-option:not([disabled]):not(.mc-disabled){cursor:pointer}\n"] }]
|
671
465
|
}], ctorParameters: function () {
|
672
|
-
return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type:
|
466
|
+
return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i2.MultipleMode, decorators: [{
|
673
467
|
type: Attribute,
|
674
468
|
args: ['multiple']
|
675
|
-
}] }, { type:
|
469
|
+
}] }, { type: i1.Clipboard, decorators: [{
|
676
470
|
type: Optional
|
677
471
|
}] }];
|
678
472
|
}, propDecorators: { options: [{
|
679
473
|
type: ContentChildren,
|
680
|
-
args: [McListOption, { descendants: true }]
|
474
|
+
args: [forwardRef(() => McListOption), { descendants: true }]
|
681
475
|
}], onSelectAll: [{
|
682
476
|
type: Output
|
683
477
|
}], onCopy: [{
|
@@ -695,6 +489,222 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
695
489
|
}], compareWith: [{
|
696
490
|
type: Input
|
697
491
|
}] } });
|
492
|
+
/**
|
493
|
+
* Component for list-options of selection-list. Each list-option can automatically
|
494
|
+
* generate a checkbox and can put current item into the selectionModel of selection-list
|
495
|
+
* if the current item is selected.
|
496
|
+
*/
|
497
|
+
class McListOption {
|
498
|
+
constructor(elementRef, changeDetector, ngZone, listSelection, group) {
|
499
|
+
this.elementRef = elementRef;
|
500
|
+
this.changeDetector = changeDetector;
|
501
|
+
this.ngZone = ngZone;
|
502
|
+
this.listSelection = listSelection;
|
503
|
+
this.group = group;
|
504
|
+
this.hasFocus = false;
|
505
|
+
this.preventBlur = false;
|
506
|
+
this.onFocus = new Subject();
|
507
|
+
this.onBlur = new Subject();
|
508
|
+
/**
|
509
|
+
* This is set to true after the first OnChanges cycle so we don't clear the value of `selected`
|
510
|
+
* in the first cycle.
|
511
|
+
*/
|
512
|
+
this.inputsInitialized = false;
|
513
|
+
this._disabled = false;
|
514
|
+
this._selected = false;
|
515
|
+
}
|
516
|
+
get value() { return this._value; }
|
517
|
+
set value(newValue) {
|
518
|
+
if (this.selected && newValue !== this.value && this.inputsInitialized) {
|
519
|
+
this.selected = false;
|
520
|
+
}
|
521
|
+
this._value = newValue;
|
522
|
+
}
|
523
|
+
get disabled() {
|
524
|
+
const listSelectionDisabled = this.listSelection && this.listSelection.disabled;
|
525
|
+
const groupDisabled = this.group && this.group.disabled;
|
526
|
+
return listSelectionDisabled || groupDisabled || this._disabled;
|
527
|
+
}
|
528
|
+
set disabled(value) {
|
529
|
+
const newValue = toBoolean(value);
|
530
|
+
if (newValue !== this._disabled) {
|
531
|
+
this._disabled = newValue;
|
532
|
+
this.changeDetector.markForCheck();
|
533
|
+
}
|
534
|
+
}
|
535
|
+
get showCheckbox() {
|
536
|
+
return this._showCheckbox !== undefined ? this._showCheckbox : this.listSelection.showCheckbox;
|
537
|
+
}
|
538
|
+
set showCheckbox(value) {
|
539
|
+
this._showCheckbox = coerceBooleanProperty(value);
|
540
|
+
}
|
541
|
+
get selected() {
|
542
|
+
var _a;
|
543
|
+
return ((_a = this.listSelection.selectionModel) === null || _a === void 0 ? void 0 : _a.isSelected(this)) || false;
|
544
|
+
}
|
545
|
+
set selected(value) {
|
546
|
+
const isSelected = toBoolean(value);
|
547
|
+
if (isSelected !== this._selected) {
|
548
|
+
this.setSelected(isSelected);
|
549
|
+
}
|
550
|
+
}
|
551
|
+
get tabIndex() {
|
552
|
+
return this.disabled ? null : -1;
|
553
|
+
}
|
554
|
+
ngOnInit() {
|
555
|
+
const list = this.listSelection;
|
556
|
+
if (list._value && list._value.some((value) => list.compareWith(value, this._value))) {
|
557
|
+
this.setSelected(true);
|
558
|
+
}
|
559
|
+
const wasSelected = this._selected;
|
560
|
+
// List options that are selected at initialization can't be reported properly to the form
|
561
|
+
// control. This is because it takes some time until the selection-list knows about all
|
562
|
+
// available options. Also it can happen that the ControlValueAccessor has an initial value
|
563
|
+
// that should be used instead. Deferring the value change report to the next tick ensures
|
564
|
+
// that the form control value is not being overwritten.
|
565
|
+
Promise.resolve().then(() => {
|
566
|
+
if (this._selected || wasSelected) {
|
567
|
+
this.selected = true;
|
568
|
+
this.changeDetector.markForCheck();
|
569
|
+
}
|
570
|
+
});
|
571
|
+
this.inputsInitialized = true;
|
572
|
+
}
|
573
|
+
ngOnDestroy() {
|
574
|
+
if (this.selected) {
|
575
|
+
// We have to delay this until the next tick in order
|
576
|
+
// to avoid changed after checked errors.
|
577
|
+
Promise.resolve().then(() => this.selected = false);
|
578
|
+
}
|
579
|
+
this.listSelection.removeOptionFromList(this);
|
580
|
+
}
|
581
|
+
toggle() {
|
582
|
+
this.selected = !this.selected;
|
583
|
+
}
|
584
|
+
getLabel() {
|
585
|
+
return this.text ? this.text.nativeElement.textContent : '';
|
586
|
+
}
|
587
|
+
setSelected(selected) {
|
588
|
+
if (this._selected === selected || !this.listSelection.selectionModel) {
|
589
|
+
return;
|
590
|
+
}
|
591
|
+
this._selected = selected;
|
592
|
+
if (selected) {
|
593
|
+
this.listSelection.selectionModel.select(this);
|
594
|
+
}
|
595
|
+
else {
|
596
|
+
this.listSelection.selectionModel.deselect(this);
|
597
|
+
}
|
598
|
+
this.changeDetector.markForCheck();
|
599
|
+
}
|
600
|
+
getHeight() {
|
601
|
+
const clientRects = this.elementRef.nativeElement.getClientRects();
|
602
|
+
return clientRects.length ? clientRects[0].height : 0;
|
603
|
+
}
|
604
|
+
handleClick($event) {
|
605
|
+
if (this.disabled) {
|
606
|
+
return;
|
607
|
+
}
|
608
|
+
this.listSelection.setSelectedOptionsByClick(this, hasModifierKey($event, 'shiftKey'), hasModifierKey($event, 'ctrlKey'));
|
609
|
+
}
|
610
|
+
onKeydown($event) {
|
611
|
+
if (!this.actionButton) {
|
612
|
+
return;
|
613
|
+
}
|
614
|
+
if ($event.keyCode === TAB && !$event.shiftKey && !this.actionButton.hasFocus) {
|
615
|
+
this.actionButton.focus();
|
616
|
+
$event.preventDefault();
|
617
|
+
}
|
618
|
+
}
|
619
|
+
focus() {
|
620
|
+
var _a;
|
621
|
+
if (this.disabled || this.hasFocus || ((_a = this.actionButton) === null || _a === void 0 ? void 0 : _a.hasFocus)) {
|
622
|
+
return;
|
623
|
+
}
|
624
|
+
this.elementRef.nativeElement.focus();
|
625
|
+
this.onFocus.next({ option: this });
|
626
|
+
Promise.resolve().then(() => {
|
627
|
+
this.hasFocus = true;
|
628
|
+
this.changeDetector.markForCheck();
|
629
|
+
});
|
630
|
+
}
|
631
|
+
blur() {
|
632
|
+
if (this.preventBlur) {
|
633
|
+
return;
|
634
|
+
}
|
635
|
+
// When animations are enabled, Angular may end up removing the option from the DOM a little
|
636
|
+
// earlier than usual, causing it to be blurred and throwing off the logic in the list
|
637
|
+
// that moves focus not the next item. To work around the issue, we defer marking the option
|
638
|
+
// as not focused until the next time the zone stabilizes.
|
639
|
+
this.ngZone.onStable
|
640
|
+
.asObservable()
|
641
|
+
.pipe(take(1))
|
642
|
+
.subscribe(() => {
|
643
|
+
this.ngZone.run(() => {
|
644
|
+
var _a;
|
645
|
+
this.hasFocus = false;
|
646
|
+
if ((_a = this.actionButton) === null || _a === void 0 ? void 0 : _a.hasFocus) {
|
647
|
+
return;
|
648
|
+
}
|
649
|
+
this.onBlur.next({ option: this });
|
650
|
+
});
|
651
|
+
});
|
652
|
+
}
|
653
|
+
getHostElement() {
|
654
|
+
return this.elementRef.nativeElement;
|
655
|
+
}
|
656
|
+
}
|
657
|
+
/** @nocollapse */ /** @nocollapse */ McListOption.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: McListOption, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: forwardRef(() => McListSelection) }, { token: i2.McOptgroup, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
658
|
+
/** @nocollapse */ /** @nocollapse */ McListOption.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: McListOption, selector: "mc-list-option", inputs: { checkboxPosition: "checkboxPosition", value: "value", disabled: "disabled", showCheckbox: "showCheckbox", selected: "selected" }, host: { listeners: { "focusin": "focus()", "blur": "blur()", "click": "handleClick($event)", "keydown": "onKeydown($event)" }, properties: { "class.mc-selected": "selected", "class.mc-disabled": "disabled", "class.mc-focused": "hasFocus", "class.mc-action-button-focused": "actionButton?.active", "attr.tabindex": "tabIndex", "attr.disabled": "disabled || null" }, classAttribute: "mc-list-option" }, providers: [
|
659
|
+
{ provide: MC_OPTION_ACTION_PARENT, useExisting: McListOption }
|
660
|
+
], queries: [{ propertyName: "actionButton", first: true, predicate: McOptionActionComponent, descendants: true }, { propertyName: "tooltipTrigger", first: true, predicate: McTooltipTrigger, descendants: true }, { propertyName: "dropdownTrigger", first: true, predicate: McDropdownTrigger, descendants: true }], viewQueries: [{ propertyName: "text", first: true, predicate: ["text"], descendants: true }], exportAs: ["mcListOption"], ngImport: i0, template: "<mc-pseudo-checkbox\n *ngIf=\"showCheckbox\"\n [state]=\"selected ? 'checked' : 'unchecked'\"\n [disabled]=\"disabled\">\n</mc-pseudo-checkbox>\n\n<ng-content select=\"[mc-icon]\"></ng-content>\n\n<div class=\"mc-list-text\" #text>\n <ng-content></ng-content>\n</div>\n\n<ng-content select=\"mc-option-action\"></ng-content>\n", components: [{ type: i2.McPseudoCheckbox, selector: "mc-pseudo-checkbox", inputs: ["color", "state", "disabled"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
661
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: McListOption, decorators: [{
|
662
|
+
type: Component,
|
663
|
+
args: [{ exportAs: 'mcListOption', selector: 'mc-list-option', host: {
|
664
|
+
class: 'mc-list-option',
|
665
|
+
'[class.mc-selected]': 'selected',
|
666
|
+
'[class.mc-disabled]': 'disabled',
|
667
|
+
'[class.mc-focused]': 'hasFocus',
|
668
|
+
'[class.mc-action-button-focused]': 'actionButton?.active',
|
669
|
+
'[attr.tabindex]': 'tabIndex',
|
670
|
+
'[attr.disabled]': 'disabled || null',
|
671
|
+
'(focusin)': 'focus()',
|
672
|
+
'(blur)': 'blur()',
|
673
|
+
'(click)': 'handleClick($event)',
|
674
|
+
'(keydown)': 'onKeydown($event)'
|
675
|
+
}, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
676
|
+
{ provide: MC_OPTION_ACTION_PARENT, useExisting: McListOption }
|
677
|
+
], template: "<mc-pseudo-checkbox\n *ngIf=\"showCheckbox\"\n [state]=\"selected ? 'checked' : 'unchecked'\"\n [disabled]=\"disabled\">\n</mc-pseudo-checkbox>\n\n<ng-content select=\"[mc-icon]\"></ng-content>\n\n<div class=\"mc-list-text\" #text>\n <ng-content></ng-content>\n</div>\n\n<ng-content select=\"mc-option-action\"></ng-content>\n" }]
|
678
|
+
}], ctorParameters: function () {
|
679
|
+
return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: McListSelection, decorators: [{
|
680
|
+
type: Inject,
|
681
|
+
args: [forwardRef(() => McListSelection)]
|
682
|
+
}] }, { type: i2.McOptgroup, decorators: [{
|
683
|
+
type: Optional
|
684
|
+
}] }];
|
685
|
+
}, propDecorators: { actionButton: [{
|
686
|
+
type: ContentChild,
|
687
|
+
args: [McOptionActionComponent]
|
688
|
+
}], tooltipTrigger: [{
|
689
|
+
type: ContentChild,
|
690
|
+
args: [McTooltipTrigger]
|
691
|
+
}], dropdownTrigger: [{
|
692
|
+
type: ContentChild,
|
693
|
+
args: [McDropdownTrigger]
|
694
|
+
}], text: [{
|
695
|
+
type: ViewChild,
|
696
|
+
args: ['text', { static: false }]
|
697
|
+
}], checkboxPosition: [{
|
698
|
+
type: Input
|
699
|
+
}], value: [{
|
700
|
+
type: Input
|
701
|
+
}], disabled: [{
|
702
|
+
type: Input
|
703
|
+
}], showCheckbox: [{
|
704
|
+
type: Input
|
705
|
+
}], selected: [{
|
706
|
+
type: Input
|
707
|
+
}] } });
|
698
708
|
|
699
709
|
// todo пока не делаем, перенесено из материала, но у нас в доках таких простых списков нет.
|
700
710
|
class McList {
|