@skyux/indicators 5.3.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/bundles/skyux-indicators.umd.js +115 -114
- package/documentation.json +303 -30
- package/esm2015/index.js +38 -0
- package/esm2015/index.js.map +1 -0
- package/esm2015/{modules → lib/modules}/alert/alert.component.js +4 -4
- package/esm2015/lib/modules/alert/alert.component.js.map +1 -0
- package/esm2015/lib/modules/alert/alert.module.js +38 -0
- package/esm2015/lib/modules/alert/alert.module.js.map +1 -0
- package/esm2015/lib/modules/chevron/chevron.component.js +66 -0
- package/esm2015/lib/modules/chevron/chevron.component.js.map +1 -0
- package/esm2015/lib/modules/chevron/chevron.module.js +38 -0
- package/esm2015/lib/modules/chevron/chevron.module.js.map +1 -0
- package/esm2015/{modules → lib/modules}/expansion-indicator/expansion-indicator.component.js +4 -4
- package/esm2015/lib/modules/expansion-indicator/expansion-indicator.component.js.map +1 -0
- package/esm2015/lib/modules/expansion-indicator/expansion-indicator.module.js +19 -0
- package/esm2015/lib/modules/expansion-indicator/expansion-indicator.module.js.map +1 -0
- package/esm2015/{modules → lib/modules}/help-inline/help-inline.component.js +4 -4
- package/esm2015/lib/modules/help-inline/help-inline.component.js.map +1 -0
- package/esm2015/lib/modules/help-inline/help-inline.module.js +38 -0
- package/esm2015/lib/modules/help-inline/help-inline.module.js.map +1 -0
- package/esm2015/lib/modules/icon/icon-class-list.pipe.js +38 -0
- package/esm2015/lib/modules/icon/icon-class-list.pipe.js.map +1 -0
- package/esm2015/lib/modules/icon/icon-resolver.service.js +42 -0
- package/esm2015/lib/modules/icon/icon-resolver.service.js.map +1 -0
- package/esm2015/lib/modules/icon/icon-stack-item.js +2 -0
- package/esm2015/lib/modules/icon/icon-stack-item.js.map +1 -0
- package/esm2015/lib/modules/icon/icon-stack.component.js +23 -0
- package/esm2015/lib/modules/icon/icon-stack.component.js.map +1 -0
- package/esm2015/lib/modules/icon/icon.component.js +37 -0
- package/esm2015/lib/modules/icon/icon.component.js.map +1 -0
- package/esm2015/lib/modules/icon/icon.module.js +21 -0
- package/esm2015/lib/modules/icon/icon.module.js.map +1 -0
- package/esm2015/lib/modules/icon/types/icon-type.js +2 -0
- package/esm2015/lib/modules/icon/types/icon-type.js.map +1 -0
- package/esm2015/lib/modules/icon/types/icon-variant-type.js +2 -0
- package/esm2015/lib/modules/icon/types/icon-variant-type.js.map +1 -0
- package/esm2015/lib/modules/key-info/key-info-label.component.js +18 -0
- package/esm2015/lib/modules/key-info/key-info-label.component.js.map +1 -0
- package/esm2015/lib/modules/key-info/key-info-value.component.js +18 -0
- package/esm2015/lib/modules/key-info/key-info-value.component.js.map +1 -0
- package/esm2015/lib/modules/key-info/key-info.component.js +26 -0
- package/esm2015/lib/modules/key-info/key-info.component.js.map +1 -0
- package/esm2015/lib/modules/key-info/key-info.module.js +32 -0
- package/esm2015/lib/modules/key-info/key-info.module.js.map +1 -0
- package/esm2015/lib/modules/label/label-type.js +2 -0
- package/esm2015/lib/modules/label/label-type.js.map +1 -0
- package/esm2015/{modules → lib/modules}/label/label.component.js +4 -4
- package/esm2015/lib/modules/label/label.component.js.map +1 -0
- package/esm2015/lib/modules/label/label.module.js +19 -0
- package/esm2015/lib/modules/label/label.module.js.map +1 -0
- package/esm2015/lib/modules/shared/indicator-description-type.js +2 -0
- package/esm2015/lib/modules/shared/indicator-description-type.js.map +1 -0
- package/esm2015/lib/modules/shared/indicator-icon-type.js +2 -0
- package/esm2015/lib/modules/shared/indicator-icon-type.js.map +1 -0
- package/esm2015/lib/modules/shared/indicator-icon-utility.js +41 -0
- package/esm2015/lib/modules/shared/indicator-icon-utility.js.map +1 -0
- package/esm2015/lib/modules/shared/indicator-icon.js +2 -0
- package/esm2015/lib/modules/shared/indicator-icon.js.map +1 -0
- package/esm2015/lib/modules/shared/sky-indicators-resources.module.js +61 -0
- package/esm2015/lib/modules/shared/sky-indicators-resources.module.js.map +1 -0
- package/esm2015/lib/modules/status-indicator/status-indicator.component.js +99 -0
- package/esm2015/lib/modules/status-indicator/status-indicator.component.js.map +1 -0
- package/esm2015/lib/modules/status-indicator/status-indicator.module.js +34 -0
- package/esm2015/lib/modules/status-indicator/status-indicator.module.js.map +1 -0
- package/esm2015/lib/modules/text-highlight/text-highlight.directive.js +154 -0
- package/esm2015/lib/modules/text-highlight/text-highlight.directive.js.map +1 -0
- package/esm2015/lib/modules/text-highlight/text-highlight.module.js +18 -0
- package/esm2015/lib/modules/text-highlight/text-highlight.module.js.map +1 -0
- package/esm2015/{modules → lib/modules}/tokens/token.component.js +6 -5
- package/esm2015/lib/modules/tokens/token.component.js.map +1 -0
- package/esm2015/lib/modules/tokens/tokens.component.js +304 -0
- package/esm2015/lib/modules/tokens/tokens.component.js.map +1 -0
- package/esm2015/lib/modules/tokens/tokens.module.js +35 -0
- package/esm2015/lib/modules/tokens/tokens.module.js.map +1 -0
- package/esm2015/lib/modules/tokens/types/token-selected-event-args.js +2 -0
- package/esm2015/lib/modules/tokens/types/token-selected-event-args.js.map +1 -0
- package/esm2015/lib/modules/tokens/types/token.js +2 -0
- package/esm2015/lib/modules/tokens/types/token.js.map +1 -0
- package/esm2015/lib/modules/tokens/types/tokens-message-type.js +24 -0
- package/esm2015/lib/modules/tokens/types/tokens-message-type.js.map +1 -0
- package/esm2015/lib/modules/tokens/types/tokens-message.js +2 -0
- package/esm2015/lib/modules/tokens/types/tokens-message.js.map +1 -0
- package/esm2015/lib/modules/wait/wait-adapter.service.js +201 -0
- package/esm2015/lib/modules/wait/wait-adapter.service.js.map +1 -0
- package/esm2015/lib/modules/wait/wait-page-adapter.service.js +25 -0
- package/esm2015/lib/modules/wait/wait-page-adapter.service.js.map +1 -0
- package/esm2015/lib/modules/wait/wait-page.component.js +23 -0
- package/esm2015/lib/modules/wait/wait-page.component.js.map +1 -0
- package/esm2015/lib/modules/wait/wait.component.js +94 -0
- package/esm2015/lib/modules/wait/wait.component.js.map +1 -0
- package/esm2015/lib/modules/wait/wait.module.js +22 -0
- package/esm2015/lib/modules/wait/wait.module.js.map +1 -0
- package/esm2015/lib/modules/wait/wait.service.js +164 -0
- package/esm2015/lib/modules/wait/wait.service.js.map +1 -0
- package/esm2015/skyux-indicators.js +2 -2
- package/esm2015/skyux-indicators.js.map +1 -0
- package/esm2015/testing/alert-fixture.js +1 -1
- package/esm2015/testing/alert-fixture.js.map +1 -0
- package/esm2015/testing/label-fixture.js +1 -1
- package/esm2015/testing/label-fixture.js.map +1 -0
- package/esm2015/testing/public-api.js +1 -1
- package/esm2015/testing/public-api.js.map +1 -0
- package/esm2015/testing/skyux-indicators-testing.js +1 -1
- package/esm2015/testing/skyux-indicators-testing.js.map +1 -0
- package/esm2015/testing/wait-fixture.js +1 -1
- package/esm2015/testing/wait-fixture.js.map +1 -0
- package/fesm2015/skyux-indicators-testing.js.map +1 -1
- package/fesm2015/skyux-indicators.js +115 -114
- package/fesm2015/skyux-indicators.js.map +1 -1
- package/index.d.ts +35 -0
- package/{modules → lib/modules}/alert/alert.component.d.ts +0 -0
- package/{modules → lib/modules}/alert/alert.module.d.ts +0 -0
- package/{modules → lib/modules}/chevron/chevron.component.d.ts +0 -0
- package/{modules → lib/modules}/chevron/chevron.module.d.ts +0 -0
- package/{modules → lib/modules}/expansion-indicator/expansion-indicator.component.d.ts +0 -0
- package/{modules → lib/modules}/expansion-indicator/expansion-indicator.module.d.ts +0 -0
- package/{modules → lib/modules}/help-inline/help-inline.component.d.ts +0 -0
- package/{modules → lib/modules}/help-inline/help-inline.module.d.ts +0 -0
- package/{modules → lib/modules}/icon/icon-class-list.pipe.d.ts +0 -0
- package/{modules → lib/modules}/icon/icon-resolver.service.d.ts +0 -0
- package/{modules → lib/modules}/icon/icon-stack-item.d.ts +0 -0
- package/{modules → lib/modules}/icon/icon-stack.component.d.ts +0 -0
- package/{modules → lib/modules}/icon/icon.component.d.ts +4 -3
- package/{modules → lib/modules}/icon/icon.module.d.ts +0 -0
- package/{modules → lib/modules}/icon/types/icon-type.d.ts +0 -0
- package/{modules → lib/modules}/icon/types/icon-variant-type.d.ts +0 -0
- package/{modules → lib/modules}/key-info/key-info-label.component.d.ts +0 -0
- package/{modules → lib/modules}/key-info/key-info-value.component.d.ts +0 -0
- package/{modules → lib/modules}/key-info/key-info.component.d.ts +0 -0
- package/{modules → lib/modules}/key-info/key-info.module.d.ts +0 -0
- package/{modules → lib/modules}/label/label-type.d.ts +0 -0
- package/{modules → lib/modules}/label/label.component.d.ts +0 -0
- package/{modules → lib/modules}/label/label.module.d.ts +0 -0
- package/{modules → lib/modules}/shared/indicator-description-type.d.ts +0 -0
- package/{modules → lib/modules}/shared/indicator-icon-type.d.ts +0 -0
- package/{modules → lib/modules}/shared/indicator-icon-utility.d.ts +0 -0
- package/{modules → lib/modules}/shared/indicator-icon.d.ts +0 -0
- package/{modules → lib/modules}/shared/sky-indicators-resources.module.d.ts +0 -0
- package/{modules → lib/modules}/status-indicator/status-indicator.component.d.ts +0 -0
- package/{modules → lib/modules}/status-indicator/status-indicator.module.d.ts +0 -0
- package/{modules → lib/modules}/text-highlight/text-highlight.directive.d.ts +0 -0
- package/{modules → lib/modules}/text-highlight/text-highlight.module.d.ts +0 -0
- package/{modules → lib/modules}/tokens/token.component.d.ts +0 -0
- package/{modules → lib/modules}/tokens/tokens.component.d.ts +1 -1
- package/{modules → lib/modules}/tokens/tokens.module.d.ts +0 -0
- package/{modules → lib/modules}/tokens/types/token-selected-event-args.d.ts +0 -0
- package/{modules → lib/modules}/tokens/types/token.d.ts +0 -0
- package/{modules → lib/modules}/tokens/types/tokens-message-type.d.ts +0 -0
- package/{modules → lib/modules}/tokens/types/tokens-message.d.ts +0 -0
- package/{modules → lib/modules}/wait/wait-adapter.service.d.ts +0 -0
- package/{modules → lib/modules}/wait/wait-page-adapter.service.d.ts +0 -0
- package/{modules → lib/modules}/wait/wait-page.component.d.ts +0 -0
- package/{modules → lib/modules}/wait/wait.component.d.ts +0 -0
- package/{modules → lib/modules}/wait/wait.module.d.ts +0 -0
- package/{modules → lib/modules}/wait/wait.service.d.ts +0 -0
- package/package.json +20 -6
- package/skyux-indicators.d.ts +1 -1
- package/LICENSE +0 -21
- package/esm2015/modules/alert/alert.module.js +0 -38
- package/esm2015/modules/chevron/chevron.component.js +0 -66
- package/esm2015/modules/chevron/chevron.module.js +0 -38
- package/esm2015/modules/expansion-indicator/expansion-indicator.module.js +0 -19
- package/esm2015/modules/help-inline/help-inline.module.js +0 -38
- package/esm2015/modules/icon/icon-class-list.pipe.js +0 -37
- package/esm2015/modules/icon/icon-resolver.service.js +0 -41
- package/esm2015/modules/icon/icon-stack-item.js +0 -2
- package/esm2015/modules/icon/icon-stack.component.js +0 -23
- package/esm2015/modules/icon/icon.component.js +0 -36
- package/esm2015/modules/icon/icon.module.js +0 -21
- package/esm2015/modules/icon/types/icon-type.js +0 -2
- package/esm2015/modules/icon/types/icon-variant-type.js +0 -2
- package/esm2015/modules/key-info/key-info-label.component.js +0 -18
- package/esm2015/modules/key-info/key-info-value.component.js +0 -18
- package/esm2015/modules/key-info/key-info.component.js +0 -26
- package/esm2015/modules/key-info/key-info.module.js +0 -32
- package/esm2015/modules/label/label-type.js +0 -2
- package/esm2015/modules/label/label.module.js +0 -19
- package/esm2015/modules/shared/indicator-description-type.js +0 -2
- package/esm2015/modules/shared/indicator-icon-type.js +0 -2
- package/esm2015/modules/shared/indicator-icon-utility.js +0 -41
- package/esm2015/modules/shared/indicator-icon.js +0 -2
- package/esm2015/modules/shared/sky-indicators-resources.module.js +0 -61
- package/esm2015/modules/status-indicator/status-indicator.component.js +0 -98
- package/esm2015/modules/status-indicator/status-indicator.module.js +0 -34
- package/esm2015/modules/text-highlight/text-highlight.directive.js +0 -153
- package/esm2015/modules/text-highlight/text-highlight.module.js +0 -18
- package/esm2015/modules/tokens/tokens.component.js +0 -304
- package/esm2015/modules/tokens/tokens.module.js +0 -35
- package/esm2015/modules/tokens/types/token-selected-event-args.js +0 -2
- package/esm2015/modules/tokens/types/token.js +0 -2
- package/esm2015/modules/tokens/types/tokens-message-type.js +0 -24
- package/esm2015/modules/tokens/types/tokens-message.js +0 -2
- package/esm2015/modules/wait/wait-adapter.service.js +0 -201
- package/esm2015/modules/wait/wait-page-adapter.service.js +0 -25
- package/esm2015/modules/wait/wait-page.component.js +0 -23
- package/esm2015/modules/wait/wait.component.js +0 -93
- package/esm2015/modules/wait/wait.module.js +0 -22
- package/esm2015/modules/wait/wait.service.js +0 -162
- package/esm2015/public-api.js +0 -38
- package/public-api.d.ts +0 -35
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { SkyI18nModule } from '@skyux/i18n';
|
|
4
|
+
import { SkyIndicatorsResourcesModule } from '../shared/sky-indicators-resources.module';
|
|
5
|
+
import { SkyIconModule } from '../icon/icon.module';
|
|
6
|
+
import { SkyStatusIndicatorComponent } from './status-indicator.component';
|
|
7
|
+
import * as i0 from "@angular/core";
|
|
8
|
+
export class SkyStatusIndicatorModule {
|
|
9
|
+
}
|
|
10
|
+
SkyStatusIndicatorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyStatusIndicatorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
11
|
+
SkyStatusIndicatorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyStatusIndicatorModule, declarations: [SkyStatusIndicatorComponent], imports: [CommonModule,
|
|
12
|
+
SkyI18nModule,
|
|
13
|
+
SkyIconModule,
|
|
14
|
+
SkyIndicatorsResourcesModule], exports: [SkyStatusIndicatorComponent] });
|
|
15
|
+
SkyStatusIndicatorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyStatusIndicatorModule, imports: [[
|
|
16
|
+
CommonModule,
|
|
17
|
+
SkyI18nModule,
|
|
18
|
+
SkyIconModule,
|
|
19
|
+
SkyIndicatorsResourcesModule,
|
|
20
|
+
]] });
|
|
21
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyStatusIndicatorModule, decorators: [{
|
|
22
|
+
type: NgModule,
|
|
23
|
+
args: [{
|
|
24
|
+
declarations: [SkyStatusIndicatorComponent],
|
|
25
|
+
imports: [
|
|
26
|
+
CommonModule,
|
|
27
|
+
SkyI18nModule,
|
|
28
|
+
SkyIconModule,
|
|
29
|
+
SkyIndicatorsResourcesModule,
|
|
30
|
+
],
|
|
31
|
+
exports: [SkyStatusIndicatorComponent],
|
|
32
|
+
}]
|
|
33
|
+
}] });
|
|
34
|
+
//# sourceMappingURL=status-indicator.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-indicator.module.js","sourceRoot":"","sources":["../../../../../../../../libs/components/indicators/src/lib/modules/status-indicator/status-indicator.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AAEzF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;;AAY3E,MAAM,OAAO,wBAAwB;;sHAAxB,wBAAwB;uHAAxB,wBAAwB,iBATpB,2BAA2B,aAExC,YAAY;QACZ,aAAa;QACb,aAAa;QACb,4BAA4B,aAEpB,2BAA2B;uHAE1B,wBAAwB,YAR1B;YACP,YAAY;YACZ,aAAa;YACb,aAAa;YACb,4BAA4B;SAC7B;4FAGU,wBAAwB;kBAVpC,QAAQ;mBAAC;oBACR,YAAY,EAAE,CAAC,2BAA2B,CAAC;oBAC3C,OAAO,EAAE;wBACP,YAAY;wBACZ,aAAa;wBACb,aAAa;wBACb,4BAA4B;qBAC7B;oBACD,OAAO,EAAE,CAAC,2BAA2B,CAAC;iBACvC","sourcesContent":["import { NgModule } from '@angular/core';\n\nimport { CommonModule } from '@angular/common';\n\nimport { SkyI18nModule } from '@skyux/i18n';\n\nimport { SkyIndicatorsResourcesModule } from '../shared/sky-indicators-resources.module';\n\nimport { SkyIconModule } from '../icon/icon.module';\n\nimport { SkyStatusIndicatorComponent } from './status-indicator.component';\n\n@NgModule({\n declarations: [SkyStatusIndicatorComponent],\n imports: [\n CommonModule,\n SkyI18nModule,\n SkyIconModule,\n SkyIndicatorsResourcesModule,\n ],\n exports: [SkyStatusIndicatorComponent],\n})\nexport class SkyStatusIndicatorModule {}\n"]}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { Directive, ElementRef, Input, } from '@angular/core';
|
|
2
|
+
import { MutationObserverService } from '@skyux/core';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import * as i1 from "@skyux/core";
|
|
5
|
+
const className = 'sky-highlight-mark';
|
|
6
|
+
// Need to add the following to classes which contain static methods.
|
|
7
|
+
// See: https://github.com/ng-packagr/ng-packagr/issues/641
|
|
8
|
+
// @dynamic
|
|
9
|
+
/**
|
|
10
|
+
* Highlights all matching text within DOM elements that it is placed on.
|
|
11
|
+
* The directive is only valid for elements that contain content, so you
|
|
12
|
+
* cannot place it on `ng-template`, `ng-content`, or `ng-container` tags.
|
|
13
|
+
*/
|
|
14
|
+
export class SkyTextHighlightDirective {
|
|
15
|
+
constructor(el, observerService) {
|
|
16
|
+
this.el = el;
|
|
17
|
+
this.observerService = observerService;
|
|
18
|
+
this.existingHighlight = false;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Specifies the text to highlight.
|
|
22
|
+
*/
|
|
23
|
+
set skyHighlight(value) {
|
|
24
|
+
value = value || [];
|
|
25
|
+
this._skyHighlight = [];
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
this._skyHighlight = value.filter((item) => !!item);
|
|
28
|
+
// Reorder strings by their length in descending order to avoid missing matches
|
|
29
|
+
// that contain substrings of other matches.
|
|
30
|
+
this._skyHighlight.sort(function (a, b) {
|
|
31
|
+
return b.length - a.length;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this._skyHighlight = [value];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
ngOnChanges(changes) {
|
|
39
|
+
if (changes.skyHighlight && !changes.skyHighlight.firstChange) {
|
|
40
|
+
this.highlight();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
ngAfterViewInit() {
|
|
44
|
+
const self = this;
|
|
45
|
+
this.observer = this.observerService.create((mutations) => {
|
|
46
|
+
self.highlight();
|
|
47
|
+
});
|
|
48
|
+
this.observeDom();
|
|
49
|
+
if (this._skyHighlight && this._skyHighlight.length > 0) {
|
|
50
|
+
this.highlight();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
ngOnDestroy() {
|
|
54
|
+
/* istanbul ignore else */
|
|
55
|
+
if (this.observer) {
|
|
56
|
+
this.observer.disconnect();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
readyForHighlight(searchText) {
|
|
60
|
+
return searchText && searchText.length > 0 && this.el.nativeElement;
|
|
61
|
+
}
|
|
62
|
+
highlight() {
|
|
63
|
+
/* istanbul ignore else */
|
|
64
|
+
if (this.observer) {
|
|
65
|
+
this.observer.disconnect();
|
|
66
|
+
}
|
|
67
|
+
const searchText = this._skyHighlight;
|
|
68
|
+
if (this.existingHighlight) {
|
|
69
|
+
SkyTextHighlightDirective.removeHighlight(this.el);
|
|
70
|
+
}
|
|
71
|
+
/* istanbul ignore else */
|
|
72
|
+
if (this.readyForHighlight(searchText)) {
|
|
73
|
+
const node = this.el.nativeElement;
|
|
74
|
+
// mark all matched text in the DOM
|
|
75
|
+
SkyTextHighlightDirective.markTextNodes(node, searchText);
|
|
76
|
+
this.existingHighlight = true;
|
|
77
|
+
}
|
|
78
|
+
this.observeDom();
|
|
79
|
+
}
|
|
80
|
+
observeDom() {
|
|
81
|
+
/* istanbul ignore else */
|
|
82
|
+
if (this.observer) {
|
|
83
|
+
const config = {
|
|
84
|
+
attributes: false,
|
|
85
|
+
childList: true,
|
|
86
|
+
characterData: true,
|
|
87
|
+
};
|
|
88
|
+
this.observer.observe(this.el.nativeElement, config);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
static cleanRegex(regex) {
|
|
92
|
+
return regex.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
93
|
+
}
|
|
94
|
+
static markNode(node, searchTerms) {
|
|
95
|
+
/* istanbul ignore else */
|
|
96
|
+
if (searchTerms) {
|
|
97
|
+
const text = node.nodeValue;
|
|
98
|
+
for (let i = 0; i < searchTerms.length; i++) {
|
|
99
|
+
searchTerms[i] = this.cleanRegex(searchTerms[i]);
|
|
100
|
+
}
|
|
101
|
+
const searchRegex = new RegExp(searchTerms.join('|'), 'gi');
|
|
102
|
+
const match = searchRegex.exec(text);
|
|
103
|
+
if (match) {
|
|
104
|
+
// Split apart text node with mark tags in the middle on the search term.
|
|
105
|
+
const matchIndex = match.index;
|
|
106
|
+
const middle = node.splitText(matchIndex);
|
|
107
|
+
middle.splitText(searchRegex.lastIndex - matchIndex);
|
|
108
|
+
const middleClone = middle.cloneNode(true);
|
|
109
|
+
const markNode = document.createElement('mark');
|
|
110
|
+
markNode.className = className;
|
|
111
|
+
markNode.appendChild(middleClone);
|
|
112
|
+
middle.parentNode.replaceChild(markNode, middle);
|
|
113
|
+
return 1;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
static markTextNodes(node, searchTerms) {
|
|
119
|
+
if (node.nodeType === 3) {
|
|
120
|
+
return SkyTextHighlightDirective.markNode(node, searchTerms);
|
|
121
|
+
}
|
|
122
|
+
else if (node.nodeType === 1 && node.childNodes) {
|
|
123
|
+
for (let i = 0; i < node.childNodes.length; i++) {
|
|
124
|
+
const childNode = node.childNodes[i];
|
|
125
|
+
i += SkyTextHighlightDirective.markTextNodes(childNode, searchTerms);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
static removeHighlight(el) {
|
|
131
|
+
const matchedElements = el.nativeElement.querySelectorAll(`mark.${className}`);
|
|
132
|
+
/* istanbul ignore else */
|
|
133
|
+
/* sanity check */
|
|
134
|
+
if (matchedElements) {
|
|
135
|
+
for (let i = 0; i < matchedElements.length; i++) {
|
|
136
|
+
const node = matchedElements[i];
|
|
137
|
+
const parentNode = node.parentNode;
|
|
138
|
+
parentNode.replaceChild(node.firstChild, node);
|
|
139
|
+
parentNode.normalize();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
SkyTextHighlightDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextHighlightDirective, deps: [{ token: i0.ElementRef }, { token: i1.MutationObserverService }], target: i0.ɵɵFactoryTarget.Directive });
|
|
145
|
+
SkyTextHighlightDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyTextHighlightDirective, selector: "[skyHighlight]", inputs: { skyHighlight: "skyHighlight" }, usesOnChanges: true, ngImport: i0 });
|
|
146
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextHighlightDirective, decorators: [{
|
|
147
|
+
type: Directive,
|
|
148
|
+
args: [{
|
|
149
|
+
selector: '[skyHighlight]',
|
|
150
|
+
}]
|
|
151
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.MutationObserverService }]; }, propDecorators: { skyHighlight: [{
|
|
152
|
+
type: Input
|
|
153
|
+
}] } });
|
|
154
|
+
//# sourceMappingURL=text-highlight.directive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-highlight.directive.js","sourceRoot":"","sources":["../../../../../../../../libs/components/indicators/src/lib/modules/text-highlight/text-highlight.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,UAAU,EACV,KAAK,GAIN,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;;;AAEtD,MAAM,SAAS,GAAG,oBAAoB,CAAC;AAEvC,qEAAqE;AACrE,2DAA2D;AAC3D,WAAW;AACX;;;;GAIG;AAIH,MAAM,OAAO,yBAAyB;IA6BpC,YACU,EAAc,EACd,eAAwC;QADxC,OAAE,GAAF,EAAE,CAAY;QACd,oBAAe,GAAf,eAAe,CAAyB;QAR1C,sBAAiB,GAAG,KAAK,CAAC;IAS/B,CAAC;IA7BJ;;OAEG;IACH,IACW,YAAY,CAAC,KAAwB;QAC9C,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC;QACpB,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QAExB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACxB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACpD,+EAA+E;YAC/E,4CAA4C;YAC5C,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBACpC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;YAC7B,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,aAAa,GAAG,CAAC,KAAe,CAAC,CAAC;SACxC;IACH,CAAC;IAaM,WAAW,CAAC,OAAsB;QACvC,IAAI,OAAO,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,YAAY,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AC,CAAC,CAAC;gBAChC,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;gBAEnC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;gBAC/C,UAAU,CAAC,SAAS,EAAE,CAAC;aACxB;SACF;IACH,CAAC;;uHArKU,yBAAyB;2GAAzB,yBAAyB;4FAAzB,yBAAyB;kBAHrC,SAAS;mBAAC;oBACT,QAAQ,EAAE,gBAAgB;iBAC3B;uIAQY,YAAY;sBADtB,KAAK","sourcesContent":["import {\n AfterViewInit,\n Directive,\n ElementRef,\n Input,\n OnChanges,\n OnDestroy,\n SimpleChanges,\n} from '@angular/core';\n\nimport { MutationObserverService } from '@skyux/core';\n\nconst className = 'sky-highlight-mark';\n\n// Need to add the following to classes which contain static methods.\n// See: https://github.com/ng-packagr/ng-packagr/issues/641\n// @dynamic\n/**\n * Highlights all matching text within DOM elements that it is placed on.\n * The directive is only valid for elements that contain content, so you\n * cannot place it on `ng-template`, `ng-content`, or `ng-container` tags.\n */\n@Directive({\n selector: '[skyHighlight]',\n})\nexport class SkyTextHighlightDirective\n implements OnChanges, AfterViewInit, OnDestroy\n{\n /**\n * Specifies the text to highlight.\n */\n @Input()\n public set skyHighlight(value: string | string[]) {\n value = value || [];\n this._skyHighlight = [];\n\n if (Array.isArray(value)) {\n this._skyHighlight = value.filter((item) => !!item);\n // Reorder strings by their length in descending order to avoid missing matches\n // that contain substrings of other matches.\n this._skyHighlight.sort(function (a, b) {\n return b.length - a.length;\n });\n } else {\n this._skyHighlight = [value as string];\n }\n }\n\n private existingHighlight = false;\n\n private observer: MutationObserver;\n\n private _skyHighlight: string[];\n\n constructor(\n private el: ElementRef,\n private observerService: MutationObserverService\n ) {}\n\n public ngOnChanges(changes: SimpleChanges): void {\n if (changes.skyHighlight && !changes.skyHighlight.firstChange) {\n this.highlight();\n }\n }\n\n public ngAfterViewInit(): void {\n const self = this;\n this.observer = this.observerService.create(\n (mutations: MutationRecord[]) => {\n self.highlight();\n }\n );\n\n this.observeDom();\n if (this._skyHighlight && this._skyHighlight.length > 0) {\n this.highlight();\n }\n }\n\n public ngOnDestroy(): void {\n /* istanbul ignore else */\n if (this.observer) {\n this.observer.disconnect();\n }\n }\n\n private readyForHighlight(searchText: string[]): boolean {\n return searchText && searchText.length > 0 && this.el.nativeElement;\n }\n\n private highlight(): void {\n /* istanbul ignore else */\n if (this.observer) {\n this.observer.disconnect();\n }\n\n const searchText = this._skyHighlight;\n\n if (this.existingHighlight) {\n SkyTextHighlightDirective.removeHighlight(this.el);\n }\n\n /* istanbul ignore else */\n if (this.readyForHighlight(searchText)) {\n const node: HTMLElement = this.el.nativeElement;\n\n // mark all matched text in the DOM\n SkyTextHighlightDirective.markTextNodes(node, searchText);\n this.existingHighlight = true;\n }\n\n this.observeDom();\n }\n\n private observeDom(): void {\n /* istanbul ignore else */\n if (this.observer) {\n const config = {\n attributes: false,\n childList: true,\n characterData: true,\n };\n this.observer.observe(this.el.nativeElement, config);\n }\n }\n\n private static cleanRegex(regex: string): string {\n return regex.replace(/[-\\/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n }\n\n private static markNode(node: any, searchTerms: string[]): number {\n /* istanbul ignore else */\n if (searchTerms) {\n const text = node.nodeValue;\n for (let i = 0; i < searchTerms.length; i++) {\n searchTerms[i] = this.cleanRegex(searchTerms[i]);\n }\n const searchRegex = new RegExp(searchTerms.join('|'), 'gi');\n const match = searchRegex.exec(text);\n if (match) {\n // Split apart text node with mark tags in the middle on the search term.\n const matchIndex = match.index;\n\n const middle = node.splitText(matchIndex);\n middle.splitText(searchRegex.lastIndex - matchIndex);\n const middleClone = middle.cloneNode(true);\n\n const markNode = document.createElement('mark');\n markNode.className = className;\n markNode.appendChild(middleClone);\n middle.parentNode.replaceChild(markNode, middle);\n\n return 1;\n }\n }\n return 0;\n }\n\n private static markTextNodes(\n node: HTMLElement,\n searchTerms: string[]\n ): number {\n if (node.nodeType === 3) {\n return SkyTextHighlightDirective.markNode(node, searchTerms);\n } else if (node.nodeType === 1 && node.childNodes) {\n for (let i = 0; i < node.childNodes.length; i++) {\n const childNode = node.childNodes[i] as HTMLElement;\n i += SkyTextHighlightDirective.markTextNodes(childNode, searchTerms);\n }\n }\n\n return 0;\n }\n\n private static removeHighlight(el: ElementRef): void {\n const matchedElements = el.nativeElement.querySelectorAll(\n `mark.${className}`\n ) as NodeList;\n\n /* istanbul ignore else */\n /* sanity check */\n if (matchedElements) {\n for (let i = 0; i < matchedElements.length; i++) {\n const node = matchedElements[i];\n const parentNode = node.parentNode;\n\n parentNode.replaceChild(node.firstChild, node);\n parentNode.normalize();\n }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { MutationObserverService } from '@skyux/core';
|
|
3
|
+
import { SkyTextHighlightDirective } from './text-highlight.directive';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export class SkyTextHighlightModule {
|
|
6
|
+
}
|
|
7
|
+
SkyTextHighlightModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextHighlightModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
8
|
+
SkyTextHighlightModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextHighlightModule, declarations: [SkyTextHighlightDirective], exports: [SkyTextHighlightDirective] });
|
|
9
|
+
SkyTextHighlightModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextHighlightModule, providers: [MutationObserverService] });
|
|
10
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextHighlightModule, decorators: [{
|
|
11
|
+
type: NgModule,
|
|
12
|
+
args: [{
|
|
13
|
+
declarations: [SkyTextHighlightDirective],
|
|
14
|
+
exports: [SkyTextHighlightDirective],
|
|
15
|
+
providers: [MutationObserverService],
|
|
16
|
+
}]
|
|
17
|
+
}] });
|
|
18
|
+
//# sourceMappingURL=text-highlight.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-highlight.module.js","sourceRoot":"","sources":["../../../../../../../../libs/components/indicators/src/lib/modules/text-highlight/text-highlight.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;;AAOvE,MAAM,OAAO,sBAAsB;;oHAAtB,sBAAsB;qHAAtB,sBAAsB,iBAJlB,yBAAyB,aAC9B,yBAAyB;qHAGxB,sBAAsB,aAFtB,CAAC,uBAAuB,CAAC;4FAEzB,sBAAsB;kBALlC,QAAQ;mBAAC;oBACR,YAAY,EAAE,CAAC,yBAAyB,CAAC;oBACzC,OAAO,EAAE,CAAC,yBAAyB,CAAC;oBACpC,SAAS,EAAE,CAAC,uBAAuB,CAAC;iBACrC","sourcesContent":["import { NgModule } from '@angular/core';\n\nimport { MutationObserverService } from '@skyux/core';\n\nimport { SkyTextHighlightDirective } from './text-highlight.directive';\n\n@NgModule({\n declarations: [SkyTextHighlightDirective],\n exports: [SkyTextHighlightDirective],\n providers: [MutationObserverService],\n})\nexport class SkyTextHighlightModule {}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, } from '@angular/core';
|
|
1
|
+
import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, Output, } from '@angular/core';
|
|
2
|
+
import { SkyLibResourcesService } from '@skyux/i18n';
|
|
2
3
|
import * as i0 from "@angular/core";
|
|
3
4
|
import * as i1 from "@skyux/i18n";
|
|
4
5
|
import * as i2 from "../icon/icon.component";
|
|
@@ -85,9 +86,9 @@ export class SkyTokenComponent {
|
|
|
85
86
|
return this.resourcesService.getStringForLocale({ locale: 'en-US' }, key);
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
|
-
SkyTokenComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
89
|
-
SkyTokenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.
|
|
90
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
89
|
+
SkyTokenComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTokenComponent, deps: [{ token: i0.ElementRef }, { token: i1.SkyLibResourcesService }], target: i0.ɵɵFactoryTarget.Component });
|
|
90
|
+
SkyTokenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SkyTokenComponent, selector: "sky-token", inputs: { disabled: "disabled", ariaLabel: "ariaLabel", dismissible: "dismissible", focusable: "focusable" }, outputs: { dismiss: "dismiss", tokenFocus: "tokenFocus" }, ngImport: i0, template: "<div\n class=\"sky-token sky-btn sky-btn-default\"\n role=\"button\"\n [attr.aria-disabled]=\"disabled\"\n [attr.tabindex]=\"tabIndex\"\n [ngClass]=\"{\n 'sky-btn-disabled': disabled,\n 'sky-token-dismissable': dismissible,\n 'sky-token-active': tokenActive && !closeActive\n }\"\n (document:mouseup)=\"setTokenActive(false)\"\n (focus)=\"tokenFocus.emit()\"\n (mousedown)=\"setTokenActive(true)\"\n>\n <ng-content></ng-content>\n <button\n *ngIf=\"dismissible\"\n class=\"sky-btn sky-token-btn-close\"\n type=\"button\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.tabindex]=\"tabIndex\"\n [attr.title]=\"ariaLabel\"\n [disabled]=\"disabled\"\n [ngClass]=\"{\n 'sky-token-btn-close-active': closeActive\n }\"\n (click)=\"dismissToken($event)\"\n (document:mouseup)=\"setCloseActive(false)\"\n (mousedown)=\"setCloseActive(true)\"\n >\n <sky-icon class=\"sky-token-btn-close-icon-default\" icon=\"times\"></sky-icon>\n <sky-icon\n class=\"sky-token-btn-close-icon-modern\"\n icon=\"close\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </button>\n</div>\n", styles: [".sky-token{background-color:#c1e8fb;border:1px solid #00b4f1;overflow:hidden;padding:2px 8px;display:inline-block;-webkit-user-select:none;user-select:none}.sky-token:hover,.sky-token:focus{background-color:#91d6f8;border-color:#008ebe;cursor:pointer}.sky-token:focus{box-shadow:0 0 8px #00b4f199;border:1px solid #00b4f1;outline:none}.sky-btn-disabled{cursor:default;-webkit-user-select:none;user-select:none}.sky-token-btn-close{background:transparent;padding:0;border:0;margin-left:2px;opacity:.9}.sky-token-btn-close:hover,.sky-token-btn-close:focus{opacity:1}.sky-token-btn-close-icon-modern{display:none}:host-context(.sky-theme-modern) .sky-token{align-items:center;display:inline-flex;padding:1px 5px;font-size:14px}:host-context(.sky-theme-modern) .sky-token.sky-btn-disabled{color:#212327}:host-context(.sky-theme-modern) .sky-token:not(.sky-btn-disabled){border:none;box-shadow:inset 0 0 0 1px #81d4f7}:host-context(.sky-theme-modern) .sky-token.sky-token-dismissable{padding-right:1px}:host-context(.sky-theme-modern) .sky-token:hover:not(:active){border:none;box-shadow:inset 0 0 0 1px #1870b8}:host-context(.sky-theme-modern) .sky-token.sky-token-active{border:none;box-shadow:inset 0 0 0 2px #1870b8}:host-context(.sky-theme-modern) .sky-token:focus:not(:active){border:none;box-shadow:inset 0 0 0 2px #1870b8,0 1px 3px #0000004d}:host-context(.sky-theme-modern) .sky-token:focus,:host-context(.sky-theme-modern) .sky-token:hover{background-color:#c1e8fb}:host-context(.sky-theme-modern) .sky-token-btn-close{align-items:center;border-radius:5px;display:flex;height:20px;margin-left:5px;width:20px}:host-context(.sky-theme-modern) .sky-token-btn-close:hover{border:none;box-shadow:inset 0 0 0 1px transparent}:host-context(.sky-theme-modern) .sky-token-btn-close.sky-token-btn-close-active{border:none;box-shadow:inset 0 0 0 2px #1870b8}:host-context(.sky-theme-modern) .sky-token-btn-close:focus{outline:none}:host-context(.sky-theme-modern) .sky-token-btn-close:focus:not(:active){border:none;box-shadow:inset 0 0 0 2px #1870b8,0 1px 3px #0000004d}:host-context(.sky-theme-modern) .sky-token-btn-close-icon-default{display:none}:host-context(.sky-theme-modern) .sky-token-btn-close-icon-modern{display:inline-block;width:100%}.sky-theme-modern .sky-token{align-items:center;display:inline-flex;padding:1px 5px;font-size:14px}.sky-theme-modern .sky-token.sky-btn-disabled{color:#212327}.sky-theme-modern .sky-token:not(.sky-btn-disabled){border:none;box-shadow:inset 0 0 0 1px #81d4f7}.sky-theme-modern .sky-token.sky-token-dismissable{padding-right:1px}.sky-theme-modern .sky-token:hover:not(:active){border:none;box-shadow:inset 0 0 0 1px #1870b8}.sky-theme-modern .sky-token.sky-token-active{border:none;box-shadow:inset 0 0 0 2px #1870b8}.sky-theme-modern .sky-token:focus:not(:active){border:none;box-shadow:inset 0 0 0 2px #1870b8,0 1px 3px #0000004d}.sky-theme-modern .sky-token:focus,.sky-theme-modern .sky-token:hover{background-color:#c1e8fb}.sky-theme-modern .sky-token-btn-close{align-items:center;border-radius:5px;display:flex;height:20px;margin-left:5px;width:20px}.sky-theme-modern .sky-token-btn-close:hover{border:none;box-shadow:inset 0 0 0 1px transparent}.sky-theme-modern .sky-token-btn-close.sky-token-btn-close-active{border:none;box-shadow:inset 0 0 0 2px #1870b8}.sky-theme-modern .sky-token-btn-close:focus{outline:none}.sky-theme-modern .sky-token-btn-close:focus:not(:active){border:none;box-shadow:inset 0 0 0 2px #1870b8,0 1px 3px #0000004d}.sky-theme-modern .sky-token-btn-close-icon-default{display:none}.sky-theme-modern .sky-token-btn-close-icon-modern{display:inline-block;width:100%}:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-token{background-color:#c1e8fb}:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-token,:host-context(.sky-theme-modern.sky-theme-mode-dark) .sky-token-btn-close{color:#212327}.sky-theme-modern.sky-theme-mode-dark .sky-token{background-color:#c1e8fb}.sky-theme-modern.sky-theme-mode-dark .sky-token,.sky-theme-modern.sky-theme-mode-dark .sky-token-btn-close{color:#212327}\n"], components: [{ type: i2.SkyIconComponent, selector: "sky-icon", inputs: ["icon", "iconType", "size", "fixedWidth", "variant"] }], directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
91
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTokenComponent, decorators: [{
|
|
91
92
|
type: Component,
|
|
92
93
|
args: [{
|
|
93
94
|
selector: 'sky-token',
|
|
@@ -108,4 +109,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
|
108
109
|
}], tokenFocus: [{
|
|
109
110
|
type: Output
|
|
110
111
|
}] } });
|
|
111
|
-
//# sourceMappingURL=
|
|
112
|
+
//# sourceMappingURL=token.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.component.js","sourceRoot":"","sources":["../../../../../../../../libs/components/indicators/src/lib/modules/tokens/token.component.ts","../../../../../../../../libs/components/indicators/src/lib/modules/tokens/token.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,UAAU,EACV,YAAY,EACZ,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;;;;;AAQrD,MAAM,OAAO,iBAAiB;IA8F5B,YACU,UAAsB,EACtB,gBAAwC;QADxC,eAAU,GAAV,UAAU,CAAY;QACtB,qBAAgB,GAAhB,gBAAgB,CAAwB;Q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C;IACpE,CAAC;IAEM,cAAc,CAAC,WAAoB;QACxC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEM,cAAc,CAAC,WAAoB;QACxC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEO,SAAS,CAAC,GAAW;QAC3B,6EAA6E;QAC7E,OAAO,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;IAC5E,CAAC;;+GAvHU,iBAAiB;mGAAjB,iBAAiB,0NCjB9B,mnCAuCA;4FDtBa,iBAAiB;kBAN7B,SAAS;mBAAC;oBACT,QAAQ,EAAE,WAAW;oBACrB,WAAW,EAAE,wBAAwB;oBACrC,SAAS,EAAE,CAAC,wBAAwB,CAAC;oBACrC,eAAe,EAAE,uBAAuB,CAAC,MAAM;iBAChD;sIASY,QAAQ;sBADlB,KAAK;gBAeK,SAAS;sBADnB,KAAK;gBAiBK,WAAW;sBADrB,KAAK;gBAeK,SAAS;sBADnB,KAAK;gBAaC,OAAO;sBADb,MAAM;gBAOA,UAAU;sBADhB,MAAM","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n EventEmitter,\n Input,\n Output,\n} from '@angular/core';\n\nimport { SkyLibResourcesService } from '@skyux/i18n';\n\n@Component({\n selector: 'sky-token',\n templateUrl: './token.component.html',\n styleUrls: ['./token.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class SkyTokenComponent {\n /**\n * Indicates whether to disable the token to prevent users from selecting it, dismissing it,\n * or navigating to it with the arrow keys. When the token is disabled,\n * users can still place focus on it using the `Tab` key.\n * @default true\n */\n @Input()\n public set disabled(value: boolean) {\n this._disabled = value;\n }\n\n public get disabled(): boolean {\n return !!this._disabled;\n }\n\n /**\n * Specifies an ARIA label for the token's close button. This sets the button's `aria-label`\n * [to support accessibility](https://developer.blackbaud.com/skyux/learn/accessibility).\n * @default \"Remove item\"\n */\n @Input()\n public set ariaLabel(value: string) {\n this._ariaLabel = value;\n }\n\n public get ariaLabel(): string {\n return (\n this._ariaLabel || this.getString('skyux_tokens_dismiss_button_title')\n );\n }\n\n /**\n * Indicates whether users can remove the token from the list by selecting the close button\n * or pressing the `Backspace` key.\n * @default true\n */\n @Input()\n public set dismissible(value: boolean) {\n this._dismissible = value;\n }\n\n public get dismissible(): boolean {\n return this._dismissible !== false;\n }\n\n /**\n * Indicates whether users can press the `Tab` key to place focus on the token. This does not\n * affect the ability to select the token, dismiss it, or navigate to it with the arrow keys.\n * @default true\n */\n @Input()\n public set focusable(value: boolean) {\n this._focusable = value;\n }\n\n public get focusable(): boolean {\n return this._focusable !== false;\n }\n\n /**\n * Fires when users click the close button or press the `Backspace` key to dismiss the token.\n */\n @Output()\n public dismiss = new EventEmitter<void>();\n\n /**\n * Fires when users place focus on the token by navigating to it with the `Tab` key.\n */\n @Output()\n public tokenFocus = new EventEmitter<void>();\n\n /**\n * @internal\n */\n public get tabIndex(): number | boolean {\n return this.focusable ? 0 : -1;\n }\n\n /**\n * @internal\n */\n public tokenActive: boolean;\n\n /**\n * @internal\n */\n public closeActive: boolean;\n\n private _ariaLabel: string;\n private _disabled: boolean;\n private _dismissible: boolean;\n private _focusable: boolean;\n\n constructor(\n private elementRef: ElementRef,\n private resourcesService: SkyLibResourcesService\n ) {}\n\n public dismissToken(event: Event): void {\n event.stopPropagation();\n this.dismiss.emit();\n }\n\n public focusElement(): void {\n this.elementRef.nativeElement.querySelector('.sky-token').focus();\n }\n\n public setTokenActive(tokenActive: boolean): void {\n this.tokenActive = tokenActive;\n }\n\n public setCloseActive(closeActive: boolean): void {\n this.closeActive = closeActive;\n }\n\n private getString(key: string): string {\n // TODO: Need to implement the async `getString` method in a breaking change.\n return this.resourcesService.getStringForLocale({ locale: 'en-US' }, key);\n }\n}\n","<div\n class=\"sky-token sky-btn sky-btn-default\"\n role=\"button\"\n [attr.aria-disabled]=\"disabled\"\n [attr.tabindex]=\"tabIndex\"\n [ngClass]=\"{\n 'sky-btn-disabled': disabled,\n 'sky-token-dismissable': dismissible,\n 'sky-token-active': tokenActive && !closeActive\n }\"\n (document:mouseup)=\"setTokenActive(false)\"\n (focus)=\"tokenFocus.emit()\"\n (mousedown)=\"setTokenActive(true)\"\n>\n <ng-content></ng-content>\n <button\n *ngIf=\"dismissible\"\n class=\"sky-btn sky-token-btn-close\"\n type=\"button\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.tabindex]=\"tabIndex\"\n [attr.title]=\"ariaLabel\"\n [disabled]=\"disabled\"\n [ngClass]=\"{\n 'sky-token-btn-close-active': closeActive\n }\"\n (click)=\"dismissToken($event)\"\n (document:mouseup)=\"setCloseActive(false)\"\n (mousedown)=\"setCloseActive(true)\"\n >\n <sky-icon class=\"sky-token-btn-close-icon-default\" icon=\"times\"></sky-icon>\n <sky-icon\n class=\"sky-token-btn-close-icon-modern\"\n icon=\"close\"\n iconType=\"skyux\"\n >\n </sky-icon>\n </button>\n</div>\n"]}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { animate, style, transition, trigger } from '@angular/animations';
|
|
2
|
+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, Output, QueryList, ViewChildren, } from '@angular/core';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
import { takeUntil } from 'rxjs/operators';
|
|
5
|
+
import { SkyTokensMessageType } from './types/tokens-message-type';
|
|
6
|
+
import { SkyTokenComponent } from './token.component';
|
|
7
|
+
import * as i0 from "@angular/core";
|
|
8
|
+
import * as i1 from "./token.component";
|
|
9
|
+
import * as i2 from "@angular/common";
|
|
10
|
+
export class SkyTokensComponent {
|
|
11
|
+
constructor(changeDetector) {
|
|
12
|
+
this.changeDetector = changeDetector;
|
|
13
|
+
/**
|
|
14
|
+
* Fires when users navigate through the tokens list with the `Tab` key
|
|
15
|
+
* and attempt to move past the final token in the list.
|
|
16
|
+
*/
|
|
17
|
+
this.focusIndexOverRange = new EventEmitter();
|
|
18
|
+
/**
|
|
19
|
+
* Fires when usersnavigate through the tokens list with the `Tab` key
|
|
20
|
+
* and attempt to move before the first token in the list.
|
|
21
|
+
*/
|
|
22
|
+
this.focusIndexUnderRange = new EventEmitter();
|
|
23
|
+
/**
|
|
24
|
+
* Fires when users select a token in the list. This event emits the selected token.
|
|
25
|
+
*/
|
|
26
|
+
this.tokenSelected = new EventEmitter();
|
|
27
|
+
/**
|
|
28
|
+
* Fires when the tokens in the list change.
|
|
29
|
+
* This event emits an array of the tokens in the updated list.
|
|
30
|
+
*/
|
|
31
|
+
this.tokensChange = new EventEmitter();
|
|
32
|
+
this.ngUnsubscribe = new Subject();
|
|
33
|
+
// Angular calls the trackBy function without applying the component instance's scope.
|
|
34
|
+
// Use a fat-arrow function so the current component instance's trackWith property can
|
|
35
|
+
// be referenced.
|
|
36
|
+
this.trackTokenFn = (_index, item) => {
|
|
37
|
+
if (this.trackWith) {
|
|
38
|
+
return item.value[this.trackWith];
|
|
39
|
+
}
|
|
40
|
+
return item;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Indicates whether to disable the tokens list to prevent users from selecting tokens,
|
|
45
|
+
* dismissing tokens, or navigating through the list with the arrow keys. When the tokens list
|
|
46
|
+
* is disabled, users can still place focus on items in the list using the `Tab` key.
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
set disabled(value) {
|
|
50
|
+
this._disabled = value;
|
|
51
|
+
}
|
|
52
|
+
get disabled() {
|
|
53
|
+
return !!this._disabled;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Indicates whether users can remove tokens from the list by selecting their close buttons
|
|
57
|
+
* or pressing the `Backspace` key.
|
|
58
|
+
* @default true
|
|
59
|
+
*/
|
|
60
|
+
set dismissible(value) {
|
|
61
|
+
this._dismissible = value;
|
|
62
|
+
}
|
|
63
|
+
get dismissible() {
|
|
64
|
+
return this._dismissible !== false;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Specifies the token property to display for each item in the tokens list.
|
|
68
|
+
* @default "name"
|
|
69
|
+
*/
|
|
70
|
+
set displayWith(value) {
|
|
71
|
+
this._displayWith = value;
|
|
72
|
+
}
|
|
73
|
+
get displayWith() {
|
|
74
|
+
return this._displayWith || 'name';
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Indicates whether users can focus on items in the list using the `Tab` key.
|
|
78
|
+
* This does not affect the ability of users to select tokens, dismiss tokens,
|
|
79
|
+
* or navigate through the list with the arrow keys.
|
|
80
|
+
* @default true
|
|
81
|
+
*/
|
|
82
|
+
set focusable(value) {
|
|
83
|
+
this._focusable = value;
|
|
84
|
+
}
|
|
85
|
+
get focusable() {
|
|
86
|
+
return this._focusable !== false;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Specifies an array of tokens to include in the list.
|
|
90
|
+
*/
|
|
91
|
+
set tokens(value) {
|
|
92
|
+
this._tokens = value;
|
|
93
|
+
this.tokensChange.emit(this._tokens);
|
|
94
|
+
}
|
|
95
|
+
get tokens() {
|
|
96
|
+
return this._tokens || [];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Specifies an observable of `SkyTokensMessage` that can place focus on a
|
|
100
|
+
* particular token or remove the active token from the list.
|
|
101
|
+
*/
|
|
102
|
+
set messageStream(value) {
|
|
103
|
+
this._messageStream = value;
|
|
104
|
+
this.initMessageStream();
|
|
105
|
+
}
|
|
106
|
+
get messageStream() {
|
|
107
|
+
return this._messageStream;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
get activeIndex() {
|
|
113
|
+
return this._activeIndex || 0;
|
|
114
|
+
}
|
|
115
|
+
set activeIndex(value) {
|
|
116
|
+
if (value >= this.tokens.length) {
|
|
117
|
+
value = this.tokens.length - 1;
|
|
118
|
+
this.focusIndexOverRange.emit();
|
|
119
|
+
}
|
|
120
|
+
if (value < 0) {
|
|
121
|
+
value = 0;
|
|
122
|
+
this.focusIndexUnderRange.emit();
|
|
123
|
+
}
|
|
124
|
+
this._activeIndex = value;
|
|
125
|
+
}
|
|
126
|
+
ngOnDestroy() {
|
|
127
|
+
this.ngUnsubscribe.next();
|
|
128
|
+
this.ngUnsubscribe.complete();
|
|
129
|
+
}
|
|
130
|
+
onTokenClick(token) {
|
|
131
|
+
if (this.disabled) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
this.notifyTokenSelected(token);
|
|
135
|
+
}
|
|
136
|
+
onTokenKeyDown(event) {
|
|
137
|
+
if (!this.disabled) {
|
|
138
|
+
/* tslint:disable-next-line:switch-default */
|
|
139
|
+
switch (event.key) {
|
|
140
|
+
case 'Left':
|
|
141
|
+
case 'ArrowLeft':
|
|
142
|
+
this.messageStream.next({
|
|
143
|
+
type: SkyTokensMessageType.FocusPreviousToken,
|
|
144
|
+
});
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
break;
|
|
147
|
+
case 'Right':
|
|
148
|
+
case 'ArrowRight':
|
|
149
|
+
this.messageStream.next({
|
|
150
|
+
type: SkyTokensMessageType.FocusNextToken,
|
|
151
|
+
});
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
selectToken(token) {
|
|
158
|
+
if (!this.disabled) {
|
|
159
|
+
this.notifyTokenSelected(token);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
removeToken(token) {
|
|
163
|
+
this.tokens = this.tokens.filter((t) => t !== token);
|
|
164
|
+
this.changeDetector.detectChanges();
|
|
165
|
+
}
|
|
166
|
+
focusPreviousToken() {
|
|
167
|
+
this.activeIndex--;
|
|
168
|
+
this.focusActiveToken();
|
|
169
|
+
}
|
|
170
|
+
focusNextToken() {
|
|
171
|
+
this.activeIndex++;
|
|
172
|
+
this.focusActiveToken();
|
|
173
|
+
}
|
|
174
|
+
focusLastToken() {
|
|
175
|
+
this.activeIndex = this.tokenComponents.length - 1;
|
|
176
|
+
this.focusActiveToken();
|
|
177
|
+
}
|
|
178
|
+
focusActiveToken() {
|
|
179
|
+
const tokenComponent = this.tokenComponents.find((_comp, i) => {
|
|
180
|
+
return this.activeIndex === i;
|
|
181
|
+
});
|
|
182
|
+
if (tokenComponent) {
|
|
183
|
+
tokenComponent.focusElement();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
removeActiveToken() {
|
|
187
|
+
const token = this.tokens[this.activeIndex];
|
|
188
|
+
if (token) {
|
|
189
|
+
this.removeToken(token);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
initMessageStream() {
|
|
193
|
+
if (this.messageStreamSub) {
|
|
194
|
+
this.messageStreamSub.unsubscribe();
|
|
195
|
+
}
|
|
196
|
+
if (this.messageStream) {
|
|
197
|
+
this.messageStreamSub = this.messageStream
|
|
198
|
+
.pipe(takeUntil(this.ngUnsubscribe))
|
|
199
|
+
.subscribe((message) => {
|
|
200
|
+
/* tslint:disable-next-line:switch-default */
|
|
201
|
+
switch (message.type) {
|
|
202
|
+
case SkyTokensMessageType.FocusLastToken:
|
|
203
|
+
this.focusLastToken();
|
|
204
|
+
break;
|
|
205
|
+
case SkyTokensMessageType.FocusActiveToken:
|
|
206
|
+
this.focusActiveToken();
|
|
207
|
+
break;
|
|
208
|
+
case SkyTokensMessageType.FocusPreviousToken:
|
|
209
|
+
this.focusPreviousToken();
|
|
210
|
+
break;
|
|
211
|
+
case SkyTokensMessageType.FocusNextToken:
|
|
212
|
+
this.focusNextToken();
|
|
213
|
+
break;
|
|
214
|
+
case SkyTokensMessageType.RemoveActiveToken:
|
|
215
|
+
this.removeActiveToken();
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
notifyTokenSelected(token) {
|
|
222
|
+
this.tokenSelected.emit({
|
|
223
|
+
token,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
SkyTokensComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTokensComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
228
|
+
SkyTokensComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SkyTokensComponent, selector: "sky-tokens", inputs: { disabled: "disabled", dismissible: "dismissible", displayWith: "displayWith", trackWith: "trackWith", focusable: "focusable", tokens: "tokens", messageStream: "messageStream" }, outputs: { focusIndexOverRange: "focusIndexOverRange", focusIndexUnderRange: "focusIndexUnderRange", tokenSelected: "tokenSelected", tokensChange: "tokensChange" }, viewQueries: [{ propertyName: "tokenComponents", predicate: SkyTokenComponent, descendants: true }], ngImport: i0, template: "<div\n *ngIf=\"tokens\"\n class=\"sky-tokens\"\n [@blockAnimationOnLoad]\n [attr.role]=\"tokens && tokens.length ? 'list' : null\"\n>\n <sky-token\n *ngFor=\"let token of tokens; let i = index; trackBy: trackTokenFn\"\n role=\"listitem\"\n [@.disabled]=\"!trackWith\"\n [@dismiss]\n [disabled]=\"disabled\"\n [dismissible]=\"dismissible\"\n [focusable]=\"focusable\"\n (dismiss)=\"removeToken(token)\"\n (click)=\"onTokenClick(token)\"\n (keydown)=\"onTokenKeyDown($event)\"\n (keyup.enter)=\"selectToken(token); $event.preventDefault()\"\n (tokenFocus)=\"activeIndex = i\"\n >\n {{ token.value[displayWith] }}\n </sky-token>\n <div class=\"sky-tokens-content\">\n <ng-content></ng-content>\n </div>\n</div>\n", styles: ["@charset \"UTF-8\";.sky-tokens{display:flex;flex-wrap:wrap;align-items:baseline;margin:-2px}.sky-tokens .sky-tokens-content,.sky-tokens ::ng-deep sky-token{flex:0 0 auto;display:inline-flex;padding:2px}.sky-tokens .sky-tokens-content{flex-grow:1;flex-basis:0px}.sky-tokens .sky-tokens-content:before{content:\"\\200b\"}\n"], components: [{ type: i1.SkyTokenComponent, selector: "sky-token", inputs: ["disabled", "ariaLabel", "dismissible", "focusable"], outputs: ["dismiss", "tokenFocus"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], animations: [
|
|
229
|
+
trigger('blockAnimationOnLoad', [transition(':enter', [])]),
|
|
230
|
+
trigger('dismiss', [
|
|
231
|
+
transition(':enter', [
|
|
232
|
+
style({
|
|
233
|
+
opacity: 0,
|
|
234
|
+
width: 0,
|
|
235
|
+
}),
|
|
236
|
+
animate('150ms ease-in', style({
|
|
237
|
+
opacity: 1,
|
|
238
|
+
width: '*',
|
|
239
|
+
})),
|
|
240
|
+
]),
|
|
241
|
+
transition(':leave', [
|
|
242
|
+
animate('150ms ease-in', style({
|
|
243
|
+
opacity: 0,
|
|
244
|
+
width: 0,
|
|
245
|
+
})),
|
|
246
|
+
]),
|
|
247
|
+
]),
|
|
248
|
+
], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
249
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTokensComponent, decorators: [{
|
|
250
|
+
type: Component,
|
|
251
|
+
args: [{
|
|
252
|
+
selector: 'sky-tokens',
|
|
253
|
+
templateUrl: './tokens.component.html',
|
|
254
|
+
styleUrls: ['./tokens.component.scss'],
|
|
255
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
256
|
+
animations: [
|
|
257
|
+
trigger('blockAnimationOnLoad', [transition(':enter', [])]),
|
|
258
|
+
trigger('dismiss', [
|
|
259
|
+
transition(':enter', [
|
|
260
|
+
style({
|
|
261
|
+
opacity: 0,
|
|
262
|
+
width: 0,
|
|
263
|
+
}),
|
|
264
|
+
animate('150ms ease-in', style({
|
|
265
|
+
opacity: 1,
|
|
266
|
+
width: '*',
|
|
267
|
+
})),
|
|
268
|
+
]),
|
|
269
|
+
transition(':leave', [
|
|
270
|
+
animate('150ms ease-in', style({
|
|
271
|
+
opacity: 0,
|
|
272
|
+
width: 0,
|
|
273
|
+
})),
|
|
274
|
+
]),
|
|
275
|
+
]),
|
|
276
|
+
],
|
|
277
|
+
}]
|
|
278
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { disabled: [{
|
|
279
|
+
type: Input
|
|
280
|
+
}], dismissible: [{
|
|
281
|
+
type: Input
|
|
282
|
+
}], displayWith: [{
|
|
283
|
+
type: Input
|
|
284
|
+
}], trackWith: [{
|
|
285
|
+
type: Input
|
|
286
|
+
}], focusable: [{
|
|
287
|
+
type: Input
|
|
288
|
+
}], tokens: [{
|
|
289
|
+
type: Input
|
|
290
|
+
}], messageStream: [{
|
|
291
|
+
type: Input
|
|
292
|
+
}], focusIndexOverRange: [{
|
|
293
|
+
type: Output
|
|
294
|
+
}], focusIndexUnderRange: [{
|
|
295
|
+
type: Output
|
|
296
|
+
}], tokenSelected: [{
|
|
297
|
+
type: Output
|
|
298
|
+
}], tokensChange: [{
|
|
299
|
+
type: Output
|
|
300
|
+
}], tokenComponents: [{
|
|
301
|
+
type: ViewChildren,
|
|
302
|
+
args: [SkyTokenComponent]
|
|
303
|
+
}] } });
|
|
304
|
+
//# sourceMappingURL=tokens.component.js.map
|