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