@spicainternational/ngx-sds-components 2.32.1 → 2.33.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/esm2020/public-api.mjs +3 -1
- package/esm2020/src/lib/date-picker/date-picker.component.mjs +8 -5
- package/esm2020/src/lib/highlight-text/directives/highlight-text.directive.mjs +60 -0
- package/esm2020/src/lib/highlight-text/directives/index.mjs +2 -0
- package/esm2020/src/lib/highlight-text/highlight-text.module.mjs +31 -0
- package/esm2020/src/lib/highlight-text/pipes/highlight-text.pipe.mjs +29 -0
- package/esm2020/src/lib/highlight-text/pipes/index.mjs +2 -0
- package/esm2020/src/lib/highlight-text/public-api.mjs +4 -0
- package/esm2020/src/lib/highlight-text/spicainternational-ngx-sds-components-src-lib-highlight-text.mjs +5 -0
- package/esm2020/src/lib/highlight-text/utils/highlight-text.utils.mjs +97 -0
- package/esm2020/src/lib/highlight-text/utils/index.mjs +2 -0
- package/esm2020/src/lib/message/message.component.mjs +41 -0
- package/esm2020/src/lib/message/message.module.mjs +30 -0
- package/esm2020/src/lib/message/public-api.mjs +3 -0
- package/esm2020/src/lib/message/spicainternational-ngx-sds-components-src-lib-message.mjs +5 -0
- package/esm2020/src/lib/modal/dialog/dialog.component.mjs +53 -5
- package/esm2020/src/lib/modal/modal.component.mjs +19 -5
- package/fesm2015/spicainternational-ngx-sds-components-src-lib-date-picker.mjs +7 -4
- package/fesm2015/spicainternational-ngx-sds-components-src-lib-date-picker.mjs.map +1 -1
- package/fesm2015/spicainternational-ngx-sds-components-src-lib-highlight-text.mjs +217 -0
- package/fesm2015/spicainternational-ngx-sds-components-src-lib-highlight-text.mjs.map +1 -0
- package/fesm2015/spicainternational-ngx-sds-components-src-lib-message.mjs +75 -0
- package/fesm2015/spicainternational-ngx-sds-components-src-lib-message.mjs.map +1 -0
- package/fesm2015/spicainternational-ngx-sds-components-src-lib-modal.mjs +71 -7
- package/fesm2015/spicainternational-ngx-sds-components-src-lib-modal.mjs.map +1 -1
- package/fesm2015/spicainternational-ngx-sds-components.mjs +2 -0
- package/fesm2015/spicainternational-ngx-sds-components.mjs.map +1 -1
- package/fesm2020/spicainternational-ngx-sds-components-src-lib-date-picker.mjs +7 -4
- package/fesm2020/spicainternational-ngx-sds-components-src-lib-date-picker.mjs.map +1 -1
- package/fesm2020/spicainternational-ngx-sds-components-src-lib-highlight-text.mjs +214 -0
- package/fesm2020/spicainternational-ngx-sds-components-src-lib-highlight-text.mjs.map +1 -0
- package/fesm2020/spicainternational-ngx-sds-components-src-lib-message.mjs +75 -0
- package/fesm2020/spicainternational-ngx-sds-components-src-lib-message.mjs.map +1 -0
- package/fesm2020/spicainternational-ngx-sds-components-src-lib-modal.mjs +69 -7
- package/fesm2020/spicainternational-ngx-sds-components-src-lib-modal.mjs.map +1 -1
- package/fesm2020/spicainternational-ngx-sds-components.mjs +2 -0
- package/fesm2020/spicainternational-ngx-sds-components.mjs.map +1 -1
- package/package.json +17 -1
- package/public-api.d.ts +2 -0
- package/src/lib/date-picker/date-picker.component.d.ts +2 -1
- package/src/lib/highlight-text/directives/highlight-text.directive.d.ts +33 -0
- package/src/lib/highlight-text/directives/index.d.ts +1 -0
- package/src/lib/highlight-text/highlight-text.module.d.ts +9 -0
- package/src/lib/highlight-text/package.json +10 -0
- package/src/lib/highlight-text/pipes/highlight-text.pipe.d.ts +11 -0
- package/src/lib/highlight-text/pipes/index.d.ts +1 -0
- package/src/lib/highlight-text/public-api.d.ts +3 -0
- package/src/lib/highlight-text/spicainternational-ngx-sds-components-src-lib-highlight-text.d.ts +5 -0
- package/src/lib/highlight-text/utils/highlight-text.utils.d.ts +23 -0
- package/src/lib/highlight-text/utils/index.d.ts +1 -0
- package/src/lib/message/message.component.d.ts +18 -0
- package/src/lib/message/message.module.d.ts +9 -0
- package/src/lib/message/package.json +10 -0
- package/src/lib/message/public-api.d.ts +2 -0
- package/src/lib/message/spicainternational-ngx-sds-components-src-lib-message.d.ts +5 -0
- package/src/lib/modal/dialog/dialog.component.d.ts +9 -1
- package/src/lib/modal/modal.component.d.ts +5 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { SecurityContext, Directive, Input, HostBinding, Pipe, NgModule } from '@angular/core';
|
|
3
|
+
import { CommonModule } from '@angular/common';
|
|
4
|
+
import * as i1 from '@angular/platform-browser';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @public @function escapeRegex
|
|
8
|
+
* @description
|
|
9
|
+
* Function responsible for substitution of chars that are a no-go for regex
|
|
10
|
+
* @param { string } phrase
|
|
11
|
+
* @returns { string }
|
|
12
|
+
*/
|
|
13
|
+
const escapeRegex = (phrase) => {
|
|
14
|
+
return phrase.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* @public @function highlightSearchedText
|
|
18
|
+
* @description
|
|
19
|
+
* Function responsible for returning html string
|
|
20
|
+
* with included marker that contains string that matches
|
|
21
|
+
* provided search phrase
|
|
22
|
+
* @param { string } highlightText
|
|
23
|
+
* @param { string } stringToBeChecked
|
|
24
|
+
* @param { string } existingHtmlContent
|
|
25
|
+
* @param { string } additionalClasses
|
|
26
|
+
* @param { string } sanitizer
|
|
27
|
+
* @returns { string }
|
|
28
|
+
*/
|
|
29
|
+
const highlightSearchedText = (highlightText, stringToBeChecked, existingHtmlContent, sanitizer, additionalClasses) => {
|
|
30
|
+
var _a;
|
|
31
|
+
// If search is empty just return current content
|
|
32
|
+
if (highlightText === '') {
|
|
33
|
+
return stringToBeChecked;
|
|
34
|
+
}
|
|
35
|
+
// Split search string into words
|
|
36
|
+
const splittedValue = highlightText.split(' ');
|
|
37
|
+
if (!splittedValue || splittedValue.length === 0) {
|
|
38
|
+
return stringToBeChecked;
|
|
39
|
+
}
|
|
40
|
+
const splittedStringToBeChecked = stringToBeChecked
|
|
41
|
+
? stringToBeChecked.split(' ')
|
|
42
|
+
: [];
|
|
43
|
+
const searchPhrases = splittedValue.filter(phrase => phrase.length > 0);
|
|
44
|
+
const markedWords = [];
|
|
45
|
+
// Go through search phrases and validate each string
|
|
46
|
+
const newContent = splittedStringToBeChecked
|
|
47
|
+
.map((wordToBeChecked) => {
|
|
48
|
+
const searchMarkRawResult = searchPhrases
|
|
49
|
+
.map(phrase => {
|
|
50
|
+
const safeString = escapeRegex(phrase);
|
|
51
|
+
const searchRegEx = new RegExp(safeString, 'i');
|
|
52
|
+
const testResult = searchRegEx.test(wordToBeChecked);
|
|
53
|
+
if (!testResult) {
|
|
54
|
+
return wordToBeChecked;
|
|
55
|
+
}
|
|
56
|
+
// Prevent text duplication when user enters same word multiple times
|
|
57
|
+
const wordIsAlreadyMarked = markedWords.some(alreadyMarkedWord => alreadyMarkedWord === wordToBeChecked);
|
|
58
|
+
if (wordIsAlreadyMarked) {
|
|
59
|
+
return wordToBeChecked;
|
|
60
|
+
}
|
|
61
|
+
markedWords.push(wordToBeChecked);
|
|
62
|
+
// Prepare content to be replaced with mark text
|
|
63
|
+
const markedContent = wordToBeChecked.replace(searchRegEx, (match) => {
|
|
64
|
+
return `<mark class='bg-primary text-white p-0 ${additionalClasses !== null && additionalClasses !== void 0 ? additionalClasses : ''}'>${match}</mark>`;
|
|
65
|
+
});
|
|
66
|
+
return markedContent;
|
|
67
|
+
})
|
|
68
|
+
.reduce((accumulator, currentItem) => {
|
|
69
|
+
const itemAlreadyExists = accumulator.some(item => item === currentItem);
|
|
70
|
+
if (!itemAlreadyExists) {
|
|
71
|
+
accumulator.push(currentItem);
|
|
72
|
+
}
|
|
73
|
+
return accumulator;
|
|
74
|
+
}, []);
|
|
75
|
+
/**
|
|
76
|
+
* At this point we have correctly marker content, however there can be
|
|
77
|
+
* duplicate words in the array. E.g. we have text First Client and user
|
|
78
|
+
* types Client First. This will give us two array. First one would be:
|
|
79
|
+
* ['First', '<mark class='highlighted-text '>First</mark>']
|
|
80
|
+
* Second one would be:
|
|
81
|
+
* ['<mark class='highlighted-text '>Client</mark>', 'Client']
|
|
82
|
+
* We have to filter out those plain values that are marked
|
|
83
|
+
*/
|
|
84
|
+
const sanitizedMarkedContent = searchMarkRawResult.filter(markedContentItem => {
|
|
85
|
+
const wordIsAlsoMarked = markedWords.some(word => word === markedContentItem);
|
|
86
|
+
if (wordIsAlsoMarked) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
});
|
|
91
|
+
return sanitizedMarkedContent;
|
|
92
|
+
})
|
|
93
|
+
.join(' ');
|
|
94
|
+
/**
|
|
95
|
+
* We want to sanitize this before pushing to DOM.
|
|
96
|
+
* Just to be on the safe side. Fallback to existing value if
|
|
97
|
+
* sanitize returns null
|
|
98
|
+
*/
|
|
99
|
+
const sanitizedContent = (_a = sanitizer.sanitize(SecurityContext.HTML, newContent)) !== null && _a !== void 0 ? _a : existingHtmlContent;
|
|
100
|
+
return sanitizedContent;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
class HighlightTextDirective {
|
|
104
|
+
constructor(_elementRef, _sanitizer) {
|
|
105
|
+
this._elementRef = _elementRef;
|
|
106
|
+
this._sanitizer = _sanitizer;
|
|
107
|
+
/**
|
|
108
|
+
* INPUTS
|
|
109
|
+
*/
|
|
110
|
+
/**
|
|
111
|
+
* CSS classes to be appended to the marked text
|
|
112
|
+
*/
|
|
113
|
+
this.additionalClasses = '';
|
|
114
|
+
/**
|
|
115
|
+
* Search term that should be found
|
|
116
|
+
*/
|
|
117
|
+
this._search = '';
|
|
118
|
+
/**
|
|
119
|
+
* For now make this case insensitive. We might change this to
|
|
120
|
+
* input latter if needed
|
|
121
|
+
*/
|
|
122
|
+
this.caseSensitive = false;
|
|
123
|
+
}
|
|
124
|
+
get highlightText() {
|
|
125
|
+
return this._search;
|
|
126
|
+
}
|
|
127
|
+
set highlightText(value) {
|
|
128
|
+
this._search = value;
|
|
129
|
+
// Now process the search value
|
|
130
|
+
this.markSearchedText(value);
|
|
131
|
+
}
|
|
132
|
+
markSearchedText(highlightText) {
|
|
133
|
+
var _a, _b;
|
|
134
|
+
// Make sure that native element is present
|
|
135
|
+
if ((_a = this._elementRef) === null || _a === void 0 ? void 0 : _a.nativeElement) {
|
|
136
|
+
const currentHtmlContent = this._elementRef.nativeElement
|
|
137
|
+
.innerHTML;
|
|
138
|
+
const text = (_b = this._elementRef.nativeElement.textContent) !== null && _b !== void 0 ? _b : '';
|
|
139
|
+
const highlightedText = highlightSearchedText(highlightText, text, currentHtmlContent, this._sanitizer, this.additionalClasses);
|
|
140
|
+
this.content = highlightedText;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
HighlightTextDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: HighlightTextDirective, deps: [{ token: i0.ElementRef }, { token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Directive });
|
|
145
|
+
HighlightTextDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.1", type: HighlightTextDirective, selector: "[highlightText]", inputs: { additionalClasses: "additionalClasses", highlightText: "highlightText" }, host: { properties: { "innerHtml": "this.content" } }, ngImport: i0 });
|
|
146
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: HighlightTextDirective, decorators: [{
|
|
147
|
+
type: Directive,
|
|
148
|
+
args: [{
|
|
149
|
+
selector: '[highlightText]'
|
|
150
|
+
}]
|
|
151
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.DomSanitizer }]; }, propDecorators: { additionalClasses: [{
|
|
152
|
+
type: Input
|
|
153
|
+
}], highlightText: [{
|
|
154
|
+
type: Input
|
|
155
|
+
}], content: [{
|
|
156
|
+
type: HostBinding,
|
|
157
|
+
args: ['innerHtml']
|
|
158
|
+
}] } });
|
|
159
|
+
|
|
160
|
+
class HighlightTextPipe {
|
|
161
|
+
constructor(_elementRef, _sanitizer) {
|
|
162
|
+
this._elementRef = _elementRef;
|
|
163
|
+
this._sanitizer = _sanitizer;
|
|
164
|
+
}
|
|
165
|
+
transform(highlightText, stringToBeChecked, additionalClasses) {
|
|
166
|
+
var _a;
|
|
167
|
+
// Make sure that native element is present
|
|
168
|
+
if ((_a = this._elementRef) === null || _a === void 0 ? void 0 : _a.nativeElement) {
|
|
169
|
+
const currentHtmlContent = this._elementRef.nativeElement
|
|
170
|
+
.innerHTML;
|
|
171
|
+
const highlightedText = highlightSearchedText(highlightText, stringToBeChecked, currentHtmlContent, this._sanitizer, additionalClasses);
|
|
172
|
+
return highlightedText;
|
|
173
|
+
}
|
|
174
|
+
return stringToBeChecked;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
HighlightTextPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: HighlightTextPipe, deps: [{ token: i0.ElementRef }, { token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
178
|
+
HighlightTextPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: HighlightTextPipe, name: "highlightText" });
|
|
179
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: HighlightTextPipe, decorators: [{
|
|
180
|
+
type: Pipe,
|
|
181
|
+
args: [{
|
|
182
|
+
name: 'highlightText'
|
|
183
|
+
}]
|
|
184
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.DomSanitizer }]; } });
|
|
185
|
+
|
|
186
|
+
class SdsHighlightTextModule {
|
|
187
|
+
}
|
|
188
|
+
SdsHighlightTextModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsHighlightTextModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
189
|
+
SdsHighlightTextModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsHighlightTextModule, declarations: [HighlightTextDirective,
|
|
190
|
+
HighlightTextPipe], imports: [CommonModule], exports: [HighlightTextDirective,
|
|
191
|
+
HighlightTextPipe] });
|
|
192
|
+
SdsHighlightTextModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsHighlightTextModule, imports: [[
|
|
193
|
+
CommonModule
|
|
194
|
+
]] });
|
|
195
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsHighlightTextModule, decorators: [{
|
|
196
|
+
type: NgModule,
|
|
197
|
+
args: [{
|
|
198
|
+
declarations: [
|
|
199
|
+
HighlightTextDirective,
|
|
200
|
+
HighlightTextPipe
|
|
201
|
+
],
|
|
202
|
+
exports: [
|
|
203
|
+
HighlightTextDirective,
|
|
204
|
+
HighlightTextPipe
|
|
205
|
+
],
|
|
206
|
+
imports: [
|
|
207
|
+
CommonModule
|
|
208
|
+
]
|
|
209
|
+
}]
|
|
210
|
+
}] });
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Generated bundle index. Do not edit.
|
|
214
|
+
*/
|
|
215
|
+
|
|
216
|
+
export { HighlightTextDirective, HighlightTextPipe, SdsHighlightTextModule };
|
|
217
|
+
//# sourceMappingURL=spicainternational-ngx-sds-components-src-lib-highlight-text.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spicainternational-ngx-sds-components-src-lib-highlight-text.mjs","sources":["../../../projects/ngx-sds-components/src/lib/highlight-text/utils/highlight-text.utils.ts","../../../projects/ngx-sds-components/src/lib/highlight-text/directives/highlight-text.directive.ts","../../../projects/ngx-sds-components/src/lib/highlight-text/pipes/highlight-text.pipe.ts","../../../projects/ngx-sds-components/src/lib/highlight-text/highlight-text.module.ts","../../../projects/ngx-sds-components/src/lib/highlight-text/spicainternational-ngx-sds-components-src-lib-highlight-text.ts"],"sourcesContent":["import { SecurityContext } from '@angular/core';\r\nimport { DomSanitizer } from '@angular/platform-browser';\r\n\r\n/**\r\n * @public @function escapeRegex\r\n * @description\r\n * Function responsible for substitution of chars that are a no-go for regex\r\n * @param { string } phrase\r\n * @returns { string }\r\n */\r\nexport const escapeRegex = (phrase: string): string => {\r\n return phrase.replace(/[-\\/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\r\n};\r\n\r\n/**\r\n * @public @function highlightSearchedText\r\n * @description\r\n * Function responsible for returning html string\r\n * with included marker that contains string that matches\r\n * provided search phrase\r\n * @param { string } highlightText\r\n * @param { string } stringToBeChecked\r\n * @param { string } existingHtmlContent\r\n * @param { string } additionalClasses\r\n * @param { string } sanitizer\r\n * @returns { string }\r\n */\r\nexport const highlightSearchedText = (\r\n highlightText: string,\r\n stringToBeChecked: string,\r\n existingHtmlContent: string,\r\n sanitizer: DomSanitizer,\r\n additionalClasses?: string\r\n ): string => {\r\n // If search is empty just return current content\r\n if (highlightText === '') {\r\n return stringToBeChecked;\r\n }\r\n\r\n // Split search string into words\r\n const splittedValue = highlightText.split(' ');\r\n\r\n if (!splittedValue || splittedValue.length === 0) {\r\n return stringToBeChecked;\r\n }\r\n\r\n const splittedStringToBeChecked: string[] = stringToBeChecked\r\n ? stringToBeChecked.split(' ')\r\n : [];\r\n\r\n const searchPhrases: string[] = splittedValue.filter(\r\n phrase => phrase.length > 0\r\n );\r\n\r\n const markedWords: string[] = [];\r\n\r\n // Go through search phrases and validate each string\r\n const newContent = splittedStringToBeChecked\r\n .map((wordToBeChecked: string) => {\r\n const searchMarkRawResult = searchPhrases\r\n .map(phrase => {\r\n const safeString = escapeRegex(phrase);\r\n\r\n const searchRegEx = new RegExp(safeString, 'i');\r\n\r\n const testResult: boolean = searchRegEx.test(wordToBeChecked);\r\n\r\n if (!testResult) {\r\n return wordToBeChecked;\r\n }\r\n\r\n // Prevent text duplication when user enters same word multiple times\r\n const wordIsAlreadyMarked = markedWords.some(alreadyMarkedWord => alreadyMarkedWord === wordToBeChecked)\r\n\r\n if (wordIsAlreadyMarked) {\r\n return wordToBeChecked;\r\n }\r\n\r\n markedWords.push(wordToBeChecked);\r\n\r\n // Prepare content to be replaced with mark text\r\n const markedContent = wordToBeChecked.replace(\r\n searchRegEx,\r\n (match: string) => {\r\n return `<mark class='bg-primary text-white p-0 ${\r\n additionalClasses ?? ''\r\n }'>${match}</mark>`;\r\n }\r\n );\r\n return markedContent;\r\n })\r\n .reduce((accumulator: string[], currentItem: string) => {\r\n const itemAlreadyExists = accumulator.some(\r\n item => item === currentItem\r\n );\r\n\r\n if (!itemAlreadyExists) {\r\n accumulator.push(currentItem);\r\n }\r\n\r\n return accumulator;\r\n }, []);\r\n\r\n /**\r\n * At this point we have correctly marker content, however there can be\r\n * duplicate words in the array. E.g. we have text First Client and user\r\n * types Client First. This will give us two array. First one would be:\r\n * ['First', '<mark class='highlighted-text '>First</mark>']\r\n * Second one would be:\r\n * ['<mark class='highlighted-text '>Client</mark>', 'Client']\r\n * We have to filter out those plain values that are marked\r\n */\r\n const sanitizedMarkedContent = searchMarkRawResult.filter(\r\n markedContentItem => {\r\n const wordIsAlsoMarked = markedWords.some(\r\n word => word === markedContentItem\r\n );\r\n\r\n if (wordIsAlsoMarked) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n );\r\n\r\n return sanitizedMarkedContent;\r\n })\r\n .join(' ');\r\n\r\n /**\r\n * We want to sanitize this before pushing to DOM.\r\n * Just to be on the safe side. Fallback to existing value if\r\n * sanitize returns null\r\n */\r\n const sanitizedContent =\r\n sanitizer.sanitize(SecurityContext.HTML, newContent) ?? existingHtmlContent;\r\n\r\n return sanitizedContent;\r\n};\r\n","import { Directive, ElementRef, HostBinding, Input } from '@angular/core';\r\nimport { DomSanitizer } from '@angular/platform-browser';\r\nimport { highlightSearchedText } from '../utils';\r\n\r\n@Directive({\r\n selector: '[highlightText]'\r\n})\r\nexport class HighlightTextDirective {\r\n/**\r\n * INPUTS\r\n */\r\n /**\r\n * CSS classes to be appended to the marked text\r\n */\r\n @Input() additionalClasses: string = '';\r\n\r\n /**\r\n * Search term that should be found\r\n */\r\n private _search: string = '';\r\n @Input()\r\n get highlightText(): string {\r\n return this._search;\r\n }\r\n set highlightText(value: string) {\r\n this._search = value;\r\n\r\n // Now process the search value\r\n this.markSearchedText(value);\r\n }\r\n\r\n /**\r\n * OTHER PROPS\r\n */\r\n @HostBinding('innerHtml')\r\n content!: string;\r\n\r\n /**\r\n * For now make this case insensitive. We might change this to\r\n * input latter if needed\r\n */\r\n protected caseSensitive: boolean = false;\r\n\r\n constructor(\r\n private readonly _elementRef: ElementRef,\r\n private readonly _sanitizer: DomSanitizer\r\n ) {}\r\n\r\n protected markSearchedText(highlightText: string): void {\r\n // Make sure that native element is present\r\n if (this._elementRef?.nativeElement) {\r\n const currentHtmlContent = (this._elementRef.nativeElement as HTMLElement)\r\n .innerHTML;\r\n\r\n const text =\r\n (this._elementRef.nativeElement as HTMLElement).textContent ?? '';\r\n\r\n const highlightedText = highlightSearchedText(\r\n highlightText,\r\n text,\r\n currentHtmlContent,\r\n this._sanitizer,\r\n this.additionalClasses\r\n );\r\n\r\n this.content = highlightedText;\r\n }\r\n }\r\n}\r\n","import { ElementRef, Pipe, PipeTransform } from '@angular/core';\r\nimport { DomSanitizer } from '@angular/platform-browser';\r\nimport { highlightSearchedText } from '../utils';\r\n\r\n@Pipe({\r\n name: 'highlightText'\r\n})\r\nexport class HighlightTextPipe implements PipeTransform {\r\n constructor(\r\n private readonly _elementRef: ElementRef,\r\n private readonly _sanitizer: DomSanitizer\r\n ) {}\r\n\r\n transform(\r\n highlightText: string,\r\n stringToBeChecked: string,\r\n additionalClasses?: string\r\n ): string {\r\n // Make sure that native element is present\r\n if (this._elementRef?.nativeElement) {\r\n const currentHtmlContent = (this._elementRef.nativeElement as HTMLElement)\r\n .innerHTML;\r\n\r\n const highlightedText = highlightSearchedText(\r\n highlightText,\r\n stringToBeChecked,\r\n currentHtmlContent,\r\n this._sanitizer,\r\n additionalClasses\r\n );\r\n\r\n return highlightedText;\r\n }\r\n\r\n return stringToBeChecked;\r\n }\r\n\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { HighlightTextDirective } from './directives';\r\nimport { HighlightTextPipe } from './pipes';\r\n\r\n\r\n\r\n@NgModule({\r\n declarations: [\r\n HighlightTextDirective,\r\n HighlightTextPipe\r\n ],\r\n exports: [\r\n HighlightTextDirective,\r\n HighlightTextPipe\r\n ],\r\n imports: [\r\n CommonModule\r\n ]\r\n})\r\nexport class SdsHighlightTextModule { }\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAGA;;;;;;AAMG;AACI,MAAM,WAAW,GAAG,CAAC,MAAc,KAAY;IAClD,OAAO,MAAM,CAAC,OAAO,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEF;;;;;;;;;;;;AAYG;AACI,MAAM,qBAAqB,GAAG,CACjC,aAAqB,EACrB,iBAAyB,EACzB,mBAA2B,EAC3B,SAAuB,EACvB,iBAA0B,KAChB;;;IAEV,IAAI,aAAa,KAAK,EAAE,EAAE;AACxB,QAAA,OAAO,iBAAiB,CAAC;AAC1B,KAAA;;IAGD,MAAM,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE/C,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;AAChD,QAAA,OAAO,iBAAiB,CAAC;AAC1B,KAAA;IAED,MAAM,yBAAyB,GAAa,iBAAiB;AAC3D,UAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC;UAC5B,EAAE,CAAC;AAEP,IAAA,MAAM,aAAa,GAAa,aAAa,CAAC,MAAM,CAClD,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAC5B,CAAC;IAE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AI,EAAE,eAAe;iBACtB,CAAA;;;MCcY,sBAAsB,CAAA;;mHAAtB,sBAAsB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAtB,sBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,sBAAsB,iBAX/B,sBAAsB;QACtB,iBAAiB,CAAA,EAAA,OAAA,EAAA,CAOjB,YAAY,CAAA,EAAA,OAAA,EAAA,CAJZ,sBAAsB;QACtB,iBAAiB,CAAA,EAAA,CAAA,CAAA;AAMR,sBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,sBAAsB,EAJxB,OAAA,EAAA,CAAA;YACP,YAAY;SACb,CAAA,EAAA,CAAA,CAAA;2FAEU,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAblC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE;wBACZ,sBAAsB;wBACtB,iBAAiB;AAClB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,sBAAsB;wBACtB,iBAAiB;AAClB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;iBACF,CAAA;;;ACnBD;;AAEG;;;;"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core';
|
|
3
|
+
import * as i2 from '@angular/common';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import * as i1 from '@fortawesome/angular-fontawesome';
|
|
6
|
+
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
|
7
|
+
|
|
8
|
+
class SdsMessageComponent {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.text = '';
|
|
11
|
+
this.showCloseButton = false;
|
|
12
|
+
this.close = new EventEmitter();
|
|
13
|
+
this.showLearnMoreLink = false;
|
|
14
|
+
this.learnMoreLinkText = 'Learn more';
|
|
15
|
+
this.learnMoreLinkUrl = '';
|
|
16
|
+
this.showMessage = true;
|
|
17
|
+
}
|
|
18
|
+
ngOnInit() { }
|
|
19
|
+
onCloseButtonClick() {
|
|
20
|
+
this.showMessage = false;
|
|
21
|
+
this.close.emit();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
SdsMessageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsMessageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
25
|
+
SdsMessageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: SdsMessageComponent, selector: "sds-message", inputs: { icon: "icon", text: "text", showCloseButton: "showCloseButton", showLearnMoreLink: "showLearnMoreLink", learnMoreLinkText: "learnMoreLinkText", learnMoreLinkUrl: "learnMoreLinkUrl" }, outputs: { close: "close" }, ngImport: i0, template: "<div \r\n *ngIf=\"showMessage\"\r\n class=\"px-3 py-2 bg-gray-300 d-flex rounded\"\r\n >\r\n\r\n <fa-icon \r\n *ngIf=\"icon\"\r\n [icon]=\"icon\"\r\n class=\"mr-2\"\r\n >\r\n </fa-icon>\r\n\r\n <div class=\"flex-grow-1\">\r\n <div class=\"\">\r\n <span>\r\n {{text}}\r\n </span>\r\n <span \r\n *ngIf=\"showLearnMoreLink\"\r\n >\r\n <a \r\n class=\"\"\r\n [href]=\"learnMoreLinkUrl\"\r\n target=\"_learnmore\"\r\n >\r\n {{learnMoreLinkText}}\r\n </a>\r\n </span>\r\n </div>\r\n </div>\r\n\r\n <div *ngIf=\"showCloseButton\">\r\n <button \r\n class=\"close rounded ml-2\" \r\n (click)=\"onCloseButtonClick()\"\r\n >\r\n <fa-icon \r\n [icon]=\"['far', 'times']\"\r\n size=\"xs\"\r\n >\r\n </fa-icon>\r\n </button>\r\n </div>\r\n\r\n</div>\r\n", styles: [""], components: [{ type: i1.FaIconComponent, selector: "fa-icon", inputs: ["icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "classes", "transform", "a11yRole"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
26
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsMessageComponent, decorators: [{
|
|
27
|
+
type: Component,
|
|
28
|
+
args: [{ selector: 'sds-message', template: "<div \r\n *ngIf=\"showMessage\"\r\n class=\"px-3 py-2 bg-gray-300 d-flex rounded\"\r\n >\r\n\r\n <fa-icon \r\n *ngIf=\"icon\"\r\n [icon]=\"icon\"\r\n class=\"mr-2\"\r\n >\r\n </fa-icon>\r\n\r\n <div class=\"flex-grow-1\">\r\n <div class=\"\">\r\n <span>\r\n {{text}}\r\n </span>\r\n <span \r\n *ngIf=\"showLearnMoreLink\"\r\n >\r\n <a \r\n class=\"\"\r\n [href]=\"learnMoreLinkUrl\"\r\n target=\"_learnmore\"\r\n >\r\n {{learnMoreLinkText}}\r\n </a>\r\n </span>\r\n </div>\r\n </div>\r\n\r\n <div *ngIf=\"showCloseButton\">\r\n <button \r\n class=\"close rounded ml-2\" \r\n (click)=\"onCloseButtonClick()\"\r\n >\r\n <fa-icon \r\n [icon]=\"['far', 'times']\"\r\n size=\"xs\"\r\n >\r\n </fa-icon>\r\n </button>\r\n </div>\r\n\r\n</div>\r\n", styles: [""] }]
|
|
29
|
+
}], ctorParameters: function () { return []; }, propDecorators: { icon: [{
|
|
30
|
+
type: Input
|
|
31
|
+
}], text: [{
|
|
32
|
+
type: Input
|
|
33
|
+
}], showCloseButton: [{
|
|
34
|
+
type: Input
|
|
35
|
+
}], close: [{
|
|
36
|
+
type: Output
|
|
37
|
+
}], showLearnMoreLink: [{
|
|
38
|
+
type: Input
|
|
39
|
+
}], learnMoreLinkText: [{
|
|
40
|
+
type: Input
|
|
41
|
+
}], learnMoreLinkUrl: [{
|
|
42
|
+
type: Input
|
|
43
|
+
}] } });
|
|
44
|
+
|
|
45
|
+
class SdsMessageModule {
|
|
46
|
+
}
|
|
47
|
+
SdsMessageModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsMessageModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
48
|
+
SdsMessageModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsMessageModule, declarations: [SdsMessageComponent], imports: [CommonModule,
|
|
49
|
+
FontAwesomeModule], exports: [SdsMessageComponent] });
|
|
50
|
+
SdsMessageModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsMessageModule, imports: [[
|
|
51
|
+
CommonModule,
|
|
52
|
+
FontAwesomeModule
|
|
53
|
+
]] });
|
|
54
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsMessageModule, decorators: [{
|
|
55
|
+
type: NgModule,
|
|
56
|
+
args: [{
|
|
57
|
+
declarations: [
|
|
58
|
+
SdsMessageComponent
|
|
59
|
+
],
|
|
60
|
+
imports: [
|
|
61
|
+
CommonModule,
|
|
62
|
+
FontAwesomeModule
|
|
63
|
+
],
|
|
64
|
+
exports: [
|
|
65
|
+
SdsMessageComponent
|
|
66
|
+
]
|
|
67
|
+
}]
|
|
68
|
+
}] });
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Generated bundle index. Do not edit.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
export { SdsMessageComponent, SdsMessageModule };
|
|
75
|
+
//# sourceMappingURL=spicainternational-ngx-sds-components-src-lib-message.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spicainternational-ngx-sds-components-src-lib-message.mjs","sources":["../../../projects/ngx-sds-components/src/lib/message/message.component.ts","../../../projects/ngx-sds-components/src/lib/message/message.component.html","../../../projects/ngx-sds-components/src/lib/message/message.module.ts","../../../projects/ngx-sds-components/src/lib/message/spicainternational-ngx-sds-components-src-lib-message.ts"],"sourcesContent":["import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';\r\nimport { IconProp } from '@fortawesome/fontawesome-svg-core';\r\n\r\n@Component({\r\n selector: 'sds-message',\r\n templateUrl: './message.component.html',\r\n styleUrls: ['./message.component.scss'],\r\n})\r\nexport class SdsMessageComponent implements OnInit {\r\n\r\n @Input() public icon?: IconProp;\r\n @Input() public text: string = '';\r\n @Input() public showCloseButton: boolean = false;\r\n\r\n @Output() public close: EventEmitter<void> = new EventEmitter();\r\n\r\n @Input() public showLearnMoreLink: boolean = false;\r\n @Input() public learnMoreLinkText: string = 'Learn more';\r\n @Input() public learnMoreLinkUrl: string = '';\r\n\r\n public showMessage: boolean = true;\r\n\r\n constructor() {}\r\n\r\n ngOnInit(): void {}\r\n\r\n public onCloseButtonClick(): void {\r\n this.showMessage = false;\r\n this.close.emit();\r\n }\r\n\r\n}\r\n","<div \r\n *ngIf=\"showMessage\"\r\n class=\"px-3 py-2 bg-gray-300 d-flex rounded\"\r\n >\r\n\r\n <fa-icon \r\n *ngIf=\"icon\"\r\n [icon]=\"icon\"\r\n class=\"mr-2\"\r\n >\r\n </fa-icon>\r\n\r\n <div class=\"flex-grow-1\">\r\n <div class=\"\">\r\n <span>\r\n {{text}}\r\n </span>\r\n <span \r\n *ngIf=\"showLearnMoreLink\"\r\n >\r\n <a \r\n class=\"\"\r\n [href]=\"learnMoreLinkUrl\"\r\n target=\"_learnmore\"\r\n >\r\n {{learnMoreLinkText}}\r\n </a>\r\n </span>\r\n </div>\r\n </div>\r\n\r\n <div *ngIf=\"showCloseButton\">\r\n <button \r\n class=\"close rounded ml-2\" \r\n (click)=\"onCloseButtonClick()\"\r\n >\r\n <fa-icon \r\n [icon]=\"['far', 'times']\"\r\n size=\"xs\"\r\n >\r\n </fa-icon>\r\n </button>\r\n </div>\r\n\r\n</div>\r\n","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { SdsMessageComponent } from './message.component';\r\nimport { FontAwesomeModule } from '@fortawesome/angular-fontawesome';\r\n\r\n@NgModule({\r\n declarations: [\r\n SdsMessageComponent\r\n ],\r\n imports: [\r\n CommonModule,\r\n FontAwesomeModule\r\n ],\r\n exports: [\r\n SdsMessageComponent\r\n ]\r\n})\r\nexport class SdsMessageModule {}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAQa,mBAAmB,CAAA;AAc5B,IAAA,WAAA,GAAA;AAXgB,QAAA,IAAI,CAAA,IAAA,GAAW,EAAE,CAAC;AAClB,QAAA,IAAe,CAAA,eAAA,GAAY,KAAK,CAAC;AAEhC,QAAA,IAAA,CAAA,KAAK,GAAuB,IAAI,YAAY,EAAE,CAAC;AAEhD,QAAA,IAAiB,CAAA,iBAAA,GAAY,KAAK,CAAC;AACnC,QAAA,IAAiB,CAAA,iBAAA,GAAW,YAAY,CAAC;AACzC,QAAA,IAAgB,CAAA,gBAAA,GAAW,EAAE,CAAC;AAEvC,QAAA,IAAW,CAAA,WAAA,GAAY,IAAI,CAAC;KAEnB;AAEhB,IAAA,QAAQ,MAAW;IAEZ,kBAAkB,GAAA;AACrB,QAAA,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;AACzB,QAAA,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;KACrB;;gHArBQ,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eA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A,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;8GAAhB,gBAAgB,EAAA,YAAA,EAAA,CAVrB,mBAAmB,CAAA,EAAA,OAAA,EAAA,CAGnB,YAAY;QACZ,iBAAiB,aAGjB,mBAAmB,CAAA,EAAA,CAAA,CAAA;AAGd,gBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,EARhB,OAAA,EAAA,CAAA;YACL,YAAY;YACZ,iBAAiB;SACpB,CAAA,EAAA,CAAA,CAAA;2FAKQ,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAZ5B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,YAAY,EAAE;wBACV,mBAAmB;AACtB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACL,YAAY;wBACZ,iBAAiB;AACpB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACL,mBAAmB;AACtB,qBAAA;iBACJ,CAAA;;;AChBD;;AAEG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { EventEmitter, Component, ContentChild, Input, Output, ViewChild, NgModule } from '@angular/core';
|
|
2
|
+
import { EventEmitter, Component, ContentChild, Input, Output, ViewChild, ElementRef, NgModule } from '@angular/core';
|
|
3
3
|
import * as i3 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import { faXmark } from '@fortawesome/pro-regular-svg-icons';
|
|
@@ -15,27 +15,34 @@ class SdsModalComponent {
|
|
|
15
15
|
this.showFooter = true;
|
|
16
16
|
this.size = 'md';
|
|
17
17
|
this.showCloseButton = true;
|
|
18
|
+
this.autoFocusCloseButton = false;
|
|
18
19
|
this.isScrollable = true;
|
|
19
20
|
this.closeOnEscape = false;
|
|
20
21
|
this.modalOpen = new EventEmitter();
|
|
21
22
|
this.modalClose = new EventEmitter();
|
|
22
23
|
this.closeClick = new EventEmitter();
|
|
24
|
+
this.closeEscapeKeypress = new EventEmitter();
|
|
23
25
|
this.closeIcon = faXmark;
|
|
26
|
+
this.isOpen = false;
|
|
24
27
|
this.translations = {
|
|
25
28
|
close: undefined
|
|
26
29
|
};
|
|
27
30
|
}
|
|
28
31
|
ngOnInit() { }
|
|
29
32
|
open() {
|
|
33
|
+
var _a;
|
|
30
34
|
if (this._modal != undefined) {
|
|
31
35
|
this._modal.nativeElement.style.display = 'block';
|
|
32
|
-
this.
|
|
36
|
+
this.isOpen = true;
|
|
37
|
+
if (this.autoFocusCloseButton)
|
|
38
|
+
(_a = this._closeButton) === null || _a === void 0 ? void 0 : _a.nativeElement.focus();
|
|
33
39
|
this.modalOpen.emit();
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
42
|
close() {
|
|
37
43
|
if (this._modal != undefined) {
|
|
38
44
|
this._modal.nativeElement.style.display = 'none';
|
|
45
|
+
this.isOpen = false;
|
|
39
46
|
this.modalClose.emit();
|
|
40
47
|
}
|
|
41
48
|
}
|
|
@@ -49,15 +56,16 @@ class SdsModalComponent {
|
|
|
49
56
|
this._modal != undefined &&
|
|
50
57
|
this._modal.nativeElement.style.display === 'block') {
|
|
51
58
|
// console.log(`${this.constructor.name} got event: ${event.code}`);
|
|
59
|
+
this.closeEscapeKeypress.emit();
|
|
52
60
|
this.close();
|
|
53
61
|
}
|
|
54
62
|
}
|
|
55
63
|
}
|
|
56
64
|
SdsModalComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsModalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
57
|
-
SdsModalComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: SdsModalComponent, selector: "sds-modal", inputs: { modalTitle: "modalTitle", showHeader: "showHeader", showFooter: "showFooter", size: "size", modalDialogId: "modalDialogId", showCloseButton: "showCloseButton", translations: "translations", isScrollable: "isScrollable", closeOnEscape: "closeOnEscape" }, outputs: { modalOpen: "modalOpen", modalClose: "modalClose", closeClick: "closeClick" }, queries: [{ propertyName: "headerContent", first: true, predicate: ["header"], descendants: true }], viewQueries: [{ propertyName: "_modal", first: true, predicate: ["modal"], descendants: true }], ngImport: i0, template: "<div #modal class=\"modal\" (keydown)=\"onKeydown($event)\" cdkTrapFocus [cdkTrapFocusAutoCapture]=\"true\">\r\n <div\r\n class=\"modal-dialog modal-dialog-centered\"\r\n [class.modal-dialog-scrollable] = \"isScrollable\"\r\n [id]=\"modalDialogId\"\r\n [ngClass]=\"'modal-' + size\"\r\n role=\"document\"\r\n >\r\n <div class=\"modal-content\">\r\n\r\n <div *ngIf=\"showHeader && headerContent\" class=\"modal-header\">\r\n <ng-content select='header'></ng-content>\r\n </div> \r\n\r\n <div *ngIf=\"showHeader && !headerContent\" class=\"modal-header\">\r\n <h5 class=\"modal-title\">{{modalTitle}}</h5>\r\n <button \r\n *ngIf=\"showCloseButton\"\r\n type=\"button\" \r\n class=\"close rounded\" \r\n [title]=\"translations.close ?? ''\"\r\n (click)=\"onCloseButtonClick()\">\r\n <fa-icon [icon]=\"closeIcon\"></fa-icon>\r\n </button>\r\n </div>\r\n\r\n <div class=\"modal-body\">\r\n <ng-content></ng-content>\r\n </div>\r\n\r\n <div *ngIf=\"showFooter\" class=\"modal-footer\">\r\n <ng-content select=\"footer\"></ng-content>\r\n </div> \r\n </div>\r\n </div>\r\n</div>", styles: [".modal{background:rgba(0,0,0,.5)}.modal .modal-header button.close:hover{background-color:#e9ecef}.modal.in{opacity:1}.modal.in .modal-dialog{transform:translate(0)}.modal-backdrop.fade{filter:alpha(opacity=0);opacity:0}.modal-backdrop.in{filter:alpha(opacity=50);opacity:.5}\n"], components: [{ type: i1.FaIconComponent, selector: "fa-icon", inputs: ["icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "classes", "transform", "a11yRole"] }], directives: [{ type: i2.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }, { type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
65
|
+
SdsModalComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: SdsModalComponent, selector: "sds-modal", inputs: { modalTitle: "modalTitle", showHeader: "showHeader", showFooter: "showFooter", size: "size", modalDialogId: "modalDialogId", showCloseButton: "showCloseButton", autoFocusCloseButton: "autoFocusCloseButton", translations: "translations", isScrollable: "isScrollable", closeOnEscape: "closeOnEscape" }, outputs: { modalOpen: "modalOpen", modalClose: "modalClose", closeClick: "closeClick", closeEscapeKeypress: "closeEscapeKeypress" }, queries: [{ propertyName: "headerContent", first: true, predicate: ["header"], descendants: true }], viewQueries: [{ propertyName: "_modal", first: true, predicate: ["modal"], descendants: true }, { propertyName: "_closeButton", first: true, predicate: ["closeButton"], descendants: true }], ngImport: i0, template: "<div #modal class=\"modal\" (keydown)=\"onKeydown($event)\" [cdkTrapFocus]=\"isOpen\" [cdkTrapFocusAutoCapture]=\"true\" >\r\n <div\r\n class=\"modal-dialog modal-dialog-centered\"\r\n [class.modal-dialog-scrollable] = \"isScrollable\"\r\n [attr.id]=\"modalDialogId\"\r\n [ngClass]=\"'modal-' + size\"\r\n role=\"document\"\r\n >\r\n <div class=\"modal-content\">\r\n\r\n <div *ngIf=\"showHeader && headerContent\" class=\"modal-header\">\r\n <ng-content select='header'></ng-content>\r\n </div> \r\n\r\n <div *ngIf=\"showHeader && !headerContent\" class=\"modal-header\">\r\n <h5 class=\"modal-title\">{{modalTitle}}</h5>\r\n <button \r\n #closeButton\r\n *ngIf=\"showCloseButton\"\r\n type=\"button\" \r\n class=\"close rounded\" \r\n [title]=\"translations.close ?? ''\"\r\n (click)=\"onCloseButtonClick()\">\r\n <fa-icon [icon]=\"closeIcon\"></fa-icon>\r\n </button>\r\n </div>\r\n\r\n <div class=\"modal-body\">\r\n <ng-content></ng-content>\r\n </div>\r\n\r\n <div *ngIf=\"showFooter\" class=\"modal-footer\">\r\n <ng-content select=\"footer\"></ng-content>\r\n </div> \r\n </div>\r\n </div>\r\n</div>", styles: [".modal{background:rgba(0,0,0,.5)}.modal .modal-header button.close:hover{background-color:#e9ecef}.modal.in{opacity:1}.modal.in .modal-dialog{transform:translate(0)}.modal-backdrop.fade{filter:alpha(opacity=0);opacity:0}.modal-backdrop.in{filter:alpha(opacity=50);opacity:.5}\n"], components: [{ type: i1.FaIconComponent, selector: "fa-icon", inputs: ["icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "classes", "transform", "a11yRole"] }], directives: [{ type: i2.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }, { type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
58
66
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsModalComponent, decorators: [{
|
|
59
67
|
type: Component,
|
|
60
|
-
args: [{ selector: 'sds-modal', template: "<div #modal class=\"modal\" (keydown)=\"onKeydown($event)\" cdkTrapFocus [cdkTrapFocusAutoCapture]=\"true\">\r\n <div\r\n class=\"modal-dialog modal-dialog-centered\"\r\n [class.modal-dialog-scrollable] = \"isScrollable\"\r\n [id]=\"modalDialogId\"\r\n [ngClass]=\"'modal-' + size\"\r\n role=\"document\"\r\n >\r\n <div class=\"modal-content\">\r\n\r\n <div *ngIf=\"showHeader && headerContent\" class=\"modal-header\">\r\n <ng-content select='header'></ng-content>\r\n </div> \r\n\r\n <div *ngIf=\"showHeader && !headerContent\" class=\"modal-header\">\r\n <h5 class=\"modal-title\">{{modalTitle}}</h5>\r\n <button \r\n *ngIf=\"showCloseButton\"\r\n type=\"button\" \r\n class=\"close rounded\" \r\n [title]=\"translations.close ?? ''\"\r\n (click)=\"onCloseButtonClick()\">\r\n <fa-icon [icon]=\"closeIcon\"></fa-icon>\r\n </button>\r\n </div>\r\n\r\n <div class=\"modal-body\">\r\n <ng-content></ng-content>\r\n </div>\r\n\r\n <div *ngIf=\"showFooter\" class=\"modal-footer\">\r\n <ng-content select=\"footer\"></ng-content>\r\n </div> \r\n </div>\r\n </div>\r\n</div>", styles: [".modal{background:rgba(0,0,0,.5)}.modal .modal-header button.close:hover{background-color:#e9ecef}.modal.in{opacity:1}.modal.in .modal-dialog{transform:translate(0)}.modal-backdrop.fade{filter:alpha(opacity=0);opacity:0}.modal-backdrop.in{filter:alpha(opacity=50);opacity:.5}\n"] }]
|
|
68
|
+
args: [{ selector: 'sds-modal', template: "<div #modal class=\"modal\" (keydown)=\"onKeydown($event)\" [cdkTrapFocus]=\"isOpen\" [cdkTrapFocusAutoCapture]=\"true\" >\r\n <div\r\n class=\"modal-dialog modal-dialog-centered\"\r\n [class.modal-dialog-scrollable] = \"isScrollable\"\r\n [attr.id]=\"modalDialogId\"\r\n [ngClass]=\"'modal-' + size\"\r\n role=\"document\"\r\n >\r\n <div class=\"modal-content\">\r\n\r\n <div *ngIf=\"showHeader && headerContent\" class=\"modal-header\">\r\n <ng-content select='header'></ng-content>\r\n </div> \r\n\r\n <div *ngIf=\"showHeader && !headerContent\" class=\"modal-header\">\r\n <h5 class=\"modal-title\">{{modalTitle}}</h5>\r\n <button \r\n #closeButton\r\n *ngIf=\"showCloseButton\"\r\n type=\"button\" \r\n class=\"close rounded\" \r\n [title]=\"translations.close ?? ''\"\r\n (click)=\"onCloseButtonClick()\">\r\n <fa-icon [icon]=\"closeIcon\"></fa-icon>\r\n </button>\r\n </div>\r\n\r\n <div class=\"modal-body\">\r\n <ng-content></ng-content>\r\n </div>\r\n\r\n <div *ngIf=\"showFooter\" class=\"modal-footer\">\r\n <ng-content select=\"footer\"></ng-content>\r\n </div> \r\n </div>\r\n </div>\r\n</div>", styles: [".modal{background:rgba(0,0,0,.5)}.modal .modal-header button.close:hover{background-color:#e9ecef}.modal.in{opacity:1}.modal.in .modal-dialog{transform:translate(0)}.modal-backdrop.fade{filter:alpha(opacity=0);opacity:0}.modal-backdrop.in{filter:alpha(opacity=50);opacity:.5}\n"] }]
|
|
61
69
|
}], ctorParameters: function () { return []; }, propDecorators: { headerContent: [{
|
|
62
70
|
type: ContentChild,
|
|
63
71
|
args: ['header']
|
|
@@ -73,6 +81,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
73
81
|
type: Input
|
|
74
82
|
}], showCloseButton: [{
|
|
75
83
|
type: Input
|
|
84
|
+
}], autoFocusCloseButton: [{
|
|
85
|
+
type: Input
|
|
76
86
|
}], translations: [{
|
|
77
87
|
type: Input
|
|
78
88
|
}], isScrollable: [{
|
|
@@ -85,9 +95,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
85
95
|
type: Output
|
|
86
96
|
}], closeClick: [{
|
|
87
97
|
type: Output
|
|
98
|
+
}], closeEscapeKeypress: [{
|
|
99
|
+
type: Output
|
|
88
100
|
}], _modal: [{
|
|
89
101
|
type: ViewChild,
|
|
90
102
|
args: ['modal', { static: false }]
|
|
103
|
+
}], _closeButton: [{
|
|
104
|
+
type: ViewChild,
|
|
105
|
+
args: ['closeButton', { static: false }]
|
|
91
106
|
}] } });
|
|
92
107
|
|
|
93
108
|
class SdsDialogComponent {
|
|
@@ -101,23 +116,38 @@ class SdsDialogComponent {
|
|
|
101
116
|
this.secondaryButtonText = 'Cancel';
|
|
102
117
|
this.secondaryButtonClass = 'btn-secondary';
|
|
103
118
|
this.secondaryButtonType = 'button';
|
|
119
|
+
this.closeOnEscape = true;
|
|
104
120
|
this.showHeader = true;
|
|
105
121
|
this.showCloseButton = true;
|
|
106
122
|
this.showPrimaryButton = true;
|
|
107
123
|
this.showSecondaryButton = true;
|
|
124
|
+
this.autofocusElement = 'primary';
|
|
108
125
|
this.dialogOpen = new EventEmitter();
|
|
109
126
|
this.dialogClose = new EventEmitter();
|
|
127
|
+
this.isOpen = false;
|
|
128
|
+
}
|
|
129
|
+
ngOnInit() {
|
|
130
|
+
if (this.autofocusElement == 'primary' && !this.showPrimaryButton) {
|
|
131
|
+
this.autofocusElement = 'secondary';
|
|
132
|
+
}
|
|
133
|
+
if (this.autofocusElement == 'secondary' && !this.showSecondaryButton) {
|
|
134
|
+
this.autofocusElement = 'close';
|
|
135
|
+
}
|
|
136
|
+
if (this.autofocusElement == 'close' && !this.showCloseButton) {
|
|
137
|
+
this.autofocusElement = 'content';
|
|
138
|
+
}
|
|
110
139
|
}
|
|
111
|
-
ngOnInit() { }
|
|
112
140
|
open(callback, data) {
|
|
113
141
|
this._callback = callback;
|
|
114
142
|
this._callbackData = data;
|
|
115
143
|
if (this._modal != undefined) {
|
|
144
|
+
this.isOpen = true;
|
|
116
145
|
this._modal.open();
|
|
117
146
|
}
|
|
118
147
|
}
|
|
119
148
|
close() {
|
|
120
149
|
if (this._modal != undefined) {
|
|
150
|
+
this.isOpen = false;
|
|
121
151
|
this._modal.close();
|
|
122
152
|
}
|
|
123
153
|
}
|
|
@@ -138,18 +168,37 @@ class SdsDialogComponent {
|
|
|
138
168
|
this._callback('close', this._callbackData);
|
|
139
169
|
}
|
|
140
170
|
}
|
|
171
|
+
onCloseEscapeKeypress() {
|
|
172
|
+
if (this._callback) {
|
|
173
|
+
this._callback('close', this._callbackData);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
141
176
|
onModalClose() {
|
|
142
177
|
this.dialogClose.emit();
|
|
143
178
|
}
|
|
144
179
|
onModalOpen() {
|
|
180
|
+
var _a, _b, _c;
|
|
145
181
|
this.dialogOpen.emit();
|
|
182
|
+
switch (this.autofocusElement) {
|
|
183
|
+
case 'primary':
|
|
184
|
+
(_a = this._primaryButton) === null || _a === void 0 ? void 0 : _a.nativeElement.focus();
|
|
185
|
+
break;
|
|
186
|
+
case 'secondary':
|
|
187
|
+
(_b = this._secondaryButton) === null || _b === void 0 ? void 0 : _b.nativeElement.focus();
|
|
188
|
+
break;
|
|
189
|
+
case 'content':
|
|
190
|
+
(_c = this._content) === null || _c === void 0 ? void 0 : _c.nativeElement.focus();
|
|
191
|
+
break;
|
|
192
|
+
default:
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
146
195
|
}
|
|
147
196
|
}
|
|
148
197
|
SdsDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
149
|
-
SdsDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: SdsDialogComponent, selector: "sds-dialog", inputs: { title: "title", closeText: "closeText", size: "size", primaryButtonText: "primaryButtonText", primaryButtonClass: "primaryButtonClass", primaryButtonType: "primaryButtonType", secondaryButtonText: "secondaryButtonText", secondaryButtonClass: "secondaryButtonClass", secondaryButtonType: "secondaryButtonType", showHeader: "showHeader", showCloseButton: "showCloseButton", showPrimaryButton: "showPrimaryButton", showSecondaryButton: "showSecondaryButton" }, outputs: { dialogOpen: "dialogOpen", dialogClose: "dialogClose" }, viewQueries: [{ propertyName: "_modal", first: true, predicate: ["modal"], descendants: true, static: true }], ngImport: i0, template: "<sds-modal\r\n #modal\r\n [modalTitle]=\"title\"\r\n [size]=\"size\"\r\n [showCloseButton]=\"showCloseButton\"\r\n [showHeader]=\"showHeader\"\r\n [translations]=\"{ close: closeText}\"\r\n (closeClick)=\"onCloseClick()\"\r\n (modalClose)=\"onModalClose()\"\r\n (modalOpen)=\"onModalOpen()\"\r\n>\r\n <div>\r\n <ng-content></ng-content>\r\n </div>\r\n
|
|
198
|
+
SdsDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.1", type: SdsDialogComponent, selector: "sds-dialog", inputs: { title: "title", closeText: "closeText", size: "size", primaryButtonText: "primaryButtonText", primaryButtonClass: "primaryButtonClass", primaryButtonType: "primaryButtonType", secondaryButtonText: "secondaryButtonText", secondaryButtonClass: "secondaryButtonClass", secondaryButtonType: "secondaryButtonType", closeOnEscape: "closeOnEscape", showHeader: "showHeader", showCloseButton: "showCloseButton", showPrimaryButton: "showPrimaryButton", showSecondaryButton: "showSecondaryButton", autofocusElement: "autofocusElement", modalDialogId: "modalDialogId" }, outputs: { dialogOpen: "dialogOpen", dialogClose: "dialogClose" }, viewQueries: [{ propertyName: "_modal", first: true, predicate: ["modal"], descendants: true, static: true }, { propertyName: "_content", first: true, predicate: ["content"], descendants: true, read: ElementRef, static: true }, { propertyName: "_primaryButton", first: true, predicate: ["primaryButton"], descendants: true, read: ElementRef }, { propertyName: "_secondaryButton", first: true, predicate: ["secondaryButton"], descendants: true, read: ElementRef }], ngImport: i0, template: "<sds-modal\r\n #modal\r\n [modalTitle]=\"title\"\r\n [size]=\"size\"\r\n [modalDialogId]=\"modalDialogId\"\r\n [showCloseButton]=\"showCloseButton\"\r\n [showHeader]=\"showHeader\"\r\n [translations]=\"{ close: closeText}\"\r\n [autoFocusCloseButton]=\"autofocusElement === 'close'\"\r\n [closeOnEscape]=\"closeOnEscape\"\r\n (closeClick)=\"onCloseClick()\"\r\n (closeEscapeKeypress)=\"onCloseEscapeKeypress()\"\r\n (modalClose)=\"onModalClose()\"\r\n (modalOpen)=\"onModalOpen()\"\r\n>\r\n\r\n <div #content [attr.tabindex]=\"autofocusElement === 'content' ? 0 : undefined\" >\r\n <ng-content></ng-content>\r\n </div>\r\n <ng-container #footer ngProjectAs='footer'>\r\n <button\r\n #secondaryButton\r\n *ngIf=\"showSecondaryButton\"\r\n class=\"btn\"\r\n [class]=\"secondaryButtonClass\"\r\n (click)=\"onSecondaryClick()\"\r\n >{{secondaryButtonText}}</button>\r\n <button\r\n #primaryButton\r\n *ngIf=\"showPrimaryButton\"\r\n class=\"btn\"\r\n [class]=\"primaryButtonClass\"\r\n (click)=\"onPrimaryClick()\"\r\n >{{primaryButtonText}}</button>\r\n </ng-container>\r\n</sds-modal>\r\n", styles: [""], components: [{ type: SdsModalComponent, selector: "sds-modal", inputs: ["modalTitle", "showHeader", "showFooter", "size", "modalDialogId", "showCloseButton", "autoFocusCloseButton", "translations", "isScrollable", "closeOnEscape"], outputs: ["modalOpen", "modalClose", "closeClick", "closeEscapeKeypress"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
150
199
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsDialogComponent, decorators: [{
|
|
151
200
|
type: Component,
|
|
152
|
-
args: [{ selector: 'sds-dialog', template: "<sds-modal\r\n #modal\r\n [modalTitle]=\"title\"\r\n [size]=\"size\"\r\n [showCloseButton]=\"showCloseButton\"\r\n [showHeader]=\"showHeader\"\r\n [translations]=\"{ close: closeText}\"\r\n (closeClick)=\"onCloseClick()\"\r\n (modalClose)=\"onModalClose()\"\r\n (modalOpen)=\"onModalOpen()\"\r\n>\r\n <div>\r\n <ng-content></ng-content>\r\n </div>\r\n
|
|
201
|
+
args: [{ selector: 'sds-dialog', template: "<sds-modal\r\n #modal\r\n [modalTitle]=\"title\"\r\n [size]=\"size\"\r\n [modalDialogId]=\"modalDialogId\"\r\n [showCloseButton]=\"showCloseButton\"\r\n [showHeader]=\"showHeader\"\r\n [translations]=\"{ close: closeText}\"\r\n [autoFocusCloseButton]=\"autofocusElement === 'close'\"\r\n [closeOnEscape]=\"closeOnEscape\"\r\n (closeClick)=\"onCloseClick()\"\r\n (closeEscapeKeypress)=\"onCloseEscapeKeypress()\"\r\n (modalClose)=\"onModalClose()\"\r\n (modalOpen)=\"onModalOpen()\"\r\n>\r\n\r\n <div #content [attr.tabindex]=\"autofocusElement === 'content' ? 0 : undefined\" >\r\n <ng-content></ng-content>\r\n </div>\r\n <ng-container #footer ngProjectAs='footer'>\r\n <button\r\n #secondaryButton\r\n *ngIf=\"showSecondaryButton\"\r\n class=\"btn\"\r\n [class]=\"secondaryButtonClass\"\r\n (click)=\"onSecondaryClick()\"\r\n >{{secondaryButtonText}}</button>\r\n <button\r\n #primaryButton\r\n *ngIf=\"showPrimaryButton\"\r\n class=\"btn\"\r\n [class]=\"primaryButtonClass\"\r\n (click)=\"onPrimaryClick()\"\r\n >{{primaryButtonText}}</button>\r\n </ng-container>\r\n</sds-modal>\r\n", styles: [""] }]
|
|
153
202
|
}], ctorParameters: function () { return []; }, propDecorators: { title: [{
|
|
154
203
|
type: Input
|
|
155
204
|
}], closeText: [{
|
|
@@ -168,6 +217,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
168
217
|
type: Input
|
|
169
218
|
}], secondaryButtonType: [{
|
|
170
219
|
type: Input
|
|
220
|
+
}], closeOnEscape: [{
|
|
221
|
+
type: Input
|
|
171
222
|
}], showHeader: [{
|
|
172
223
|
type: Input
|
|
173
224
|
}], showCloseButton: [{
|
|
@@ -176,6 +227,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
176
227
|
type: Input
|
|
177
228
|
}], showSecondaryButton: [{
|
|
178
229
|
type: Input
|
|
230
|
+
}], autofocusElement: [{
|
|
231
|
+
type: Input
|
|
232
|
+
}], modalDialogId: [{
|
|
233
|
+
type: Input
|
|
179
234
|
}], dialogOpen: [{
|
|
180
235
|
type: Output
|
|
181
236
|
}], dialogClose: [{
|
|
@@ -183,6 +238,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
183
238
|
}], _modal: [{
|
|
184
239
|
type: ViewChild,
|
|
185
240
|
args: ['modal', { static: true }]
|
|
241
|
+
}], _content: [{
|
|
242
|
+
type: ViewChild,
|
|
243
|
+
args: ['content', { read: ElementRef, static: true }]
|
|
244
|
+
}], _primaryButton: [{
|
|
245
|
+
type: ViewChild,
|
|
246
|
+
args: ['primaryButton', { read: ElementRef, static: false }]
|
|
247
|
+
}], _secondaryButton: [{
|
|
248
|
+
type: ViewChild,
|
|
249
|
+
args: ['secondaryButton', { read: ElementRef, static: false }]
|
|
186
250
|
}] } });
|
|
187
251
|
|
|
188
252
|
const components = [
|