@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,214 @@
|
|
|
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
|
+
// If search is empty just return current content
|
|
31
|
+
if (highlightText === '') {
|
|
32
|
+
return stringToBeChecked;
|
|
33
|
+
}
|
|
34
|
+
// Split search string into words
|
|
35
|
+
const splittedValue = highlightText.split(' ');
|
|
36
|
+
if (!splittedValue || splittedValue.length === 0) {
|
|
37
|
+
return stringToBeChecked;
|
|
38
|
+
}
|
|
39
|
+
const splittedStringToBeChecked = stringToBeChecked
|
|
40
|
+
? stringToBeChecked.split(' ')
|
|
41
|
+
: [];
|
|
42
|
+
const searchPhrases = splittedValue.filter(phrase => phrase.length > 0);
|
|
43
|
+
const markedWords = [];
|
|
44
|
+
// Go through search phrases and validate each string
|
|
45
|
+
const newContent = splittedStringToBeChecked
|
|
46
|
+
.map((wordToBeChecked) => {
|
|
47
|
+
const searchMarkRawResult = searchPhrases
|
|
48
|
+
.map(phrase => {
|
|
49
|
+
const safeString = escapeRegex(phrase);
|
|
50
|
+
const searchRegEx = new RegExp(safeString, 'i');
|
|
51
|
+
const testResult = searchRegEx.test(wordToBeChecked);
|
|
52
|
+
if (!testResult) {
|
|
53
|
+
return wordToBeChecked;
|
|
54
|
+
}
|
|
55
|
+
// Prevent text duplication when user enters same word multiple times
|
|
56
|
+
const wordIsAlreadyMarked = markedWords.some(alreadyMarkedWord => alreadyMarkedWord === wordToBeChecked);
|
|
57
|
+
if (wordIsAlreadyMarked) {
|
|
58
|
+
return wordToBeChecked;
|
|
59
|
+
}
|
|
60
|
+
markedWords.push(wordToBeChecked);
|
|
61
|
+
// Prepare content to be replaced with mark text
|
|
62
|
+
const markedContent = wordToBeChecked.replace(searchRegEx, (match) => {
|
|
63
|
+
return `<mark class='bg-primary text-white p-0 ${additionalClasses ?? ''}'>${match}</mark>`;
|
|
64
|
+
});
|
|
65
|
+
return markedContent;
|
|
66
|
+
})
|
|
67
|
+
.reduce((accumulator, currentItem) => {
|
|
68
|
+
const itemAlreadyExists = accumulator.some(item => item === currentItem);
|
|
69
|
+
if (!itemAlreadyExists) {
|
|
70
|
+
accumulator.push(currentItem);
|
|
71
|
+
}
|
|
72
|
+
return accumulator;
|
|
73
|
+
}, []);
|
|
74
|
+
/**
|
|
75
|
+
* At this point we have correctly marker content, however there can be
|
|
76
|
+
* duplicate words in the array. E.g. we have text First Client and user
|
|
77
|
+
* types Client First. This will give us two array. First one would be:
|
|
78
|
+
* ['First', '<mark class='highlighted-text '>First</mark>']
|
|
79
|
+
* Second one would be:
|
|
80
|
+
* ['<mark class='highlighted-text '>Client</mark>', 'Client']
|
|
81
|
+
* We have to filter out those plain values that are marked
|
|
82
|
+
*/
|
|
83
|
+
const sanitizedMarkedContent = searchMarkRawResult.filter(markedContentItem => {
|
|
84
|
+
const wordIsAlsoMarked = markedWords.some(word => word === markedContentItem);
|
|
85
|
+
if (wordIsAlsoMarked) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
});
|
|
90
|
+
return sanitizedMarkedContent;
|
|
91
|
+
})
|
|
92
|
+
.join(' ');
|
|
93
|
+
/**
|
|
94
|
+
* We want to sanitize this before pushing to DOM.
|
|
95
|
+
* Just to be on the safe side. Fallback to existing value if
|
|
96
|
+
* sanitize returns null
|
|
97
|
+
*/
|
|
98
|
+
const sanitizedContent = sanitizer.sanitize(SecurityContext.HTML, newContent) ?? existingHtmlContent;
|
|
99
|
+
return sanitizedContent;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
class HighlightTextDirective {
|
|
103
|
+
constructor(_elementRef, _sanitizer) {
|
|
104
|
+
this._elementRef = _elementRef;
|
|
105
|
+
this._sanitizer = _sanitizer;
|
|
106
|
+
/**
|
|
107
|
+
* INPUTS
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* CSS classes to be appended to the marked text
|
|
111
|
+
*/
|
|
112
|
+
this.additionalClasses = '';
|
|
113
|
+
/**
|
|
114
|
+
* Search term that should be found
|
|
115
|
+
*/
|
|
116
|
+
this._search = '';
|
|
117
|
+
/**
|
|
118
|
+
* For now make this case insensitive. We might change this to
|
|
119
|
+
* input latter if needed
|
|
120
|
+
*/
|
|
121
|
+
this.caseSensitive = false;
|
|
122
|
+
}
|
|
123
|
+
get highlightText() {
|
|
124
|
+
return this._search;
|
|
125
|
+
}
|
|
126
|
+
set highlightText(value) {
|
|
127
|
+
this._search = value;
|
|
128
|
+
// Now process the search value
|
|
129
|
+
this.markSearchedText(value);
|
|
130
|
+
}
|
|
131
|
+
markSearchedText(highlightText) {
|
|
132
|
+
// Make sure that native element is present
|
|
133
|
+
if (this._elementRef?.nativeElement) {
|
|
134
|
+
const currentHtmlContent = this._elementRef.nativeElement
|
|
135
|
+
.innerHTML;
|
|
136
|
+
const text = this._elementRef.nativeElement.textContent ?? '';
|
|
137
|
+
const highlightedText = highlightSearchedText(highlightText, text, currentHtmlContent, this._sanitizer, this.additionalClasses);
|
|
138
|
+
this.content = highlightedText;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
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 });
|
|
143
|
+
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 });
|
|
144
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: HighlightTextDirective, decorators: [{
|
|
145
|
+
type: Directive,
|
|
146
|
+
args: [{
|
|
147
|
+
selector: '[highlightText]'
|
|
148
|
+
}]
|
|
149
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.DomSanitizer }]; }, propDecorators: { additionalClasses: [{
|
|
150
|
+
type: Input
|
|
151
|
+
}], highlightText: [{
|
|
152
|
+
type: Input
|
|
153
|
+
}], content: [{
|
|
154
|
+
type: HostBinding,
|
|
155
|
+
args: ['innerHtml']
|
|
156
|
+
}] } });
|
|
157
|
+
|
|
158
|
+
class HighlightTextPipe {
|
|
159
|
+
constructor(_elementRef, _sanitizer) {
|
|
160
|
+
this._elementRef = _elementRef;
|
|
161
|
+
this._sanitizer = _sanitizer;
|
|
162
|
+
}
|
|
163
|
+
transform(highlightText, stringToBeChecked, additionalClasses) {
|
|
164
|
+
// Make sure that native element is present
|
|
165
|
+
if (this._elementRef?.nativeElement) {
|
|
166
|
+
const currentHtmlContent = this._elementRef.nativeElement
|
|
167
|
+
.innerHTML;
|
|
168
|
+
const highlightedText = highlightSearchedText(highlightText, stringToBeChecked, currentHtmlContent, this._sanitizer, additionalClasses);
|
|
169
|
+
return highlightedText;
|
|
170
|
+
}
|
|
171
|
+
return stringToBeChecked;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
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 });
|
|
175
|
+
HighlightTextPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: HighlightTextPipe, name: "highlightText" });
|
|
176
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: HighlightTextPipe, decorators: [{
|
|
177
|
+
type: Pipe,
|
|
178
|
+
args: [{
|
|
179
|
+
name: 'highlightText'
|
|
180
|
+
}]
|
|
181
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.DomSanitizer }]; } });
|
|
182
|
+
|
|
183
|
+
class SdsHighlightTextModule {
|
|
184
|
+
}
|
|
185
|
+
SdsHighlightTextModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsHighlightTextModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
186
|
+
SdsHighlightTextModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsHighlightTextModule, declarations: [HighlightTextDirective,
|
|
187
|
+
HighlightTextPipe], imports: [CommonModule], exports: [HighlightTextDirective,
|
|
188
|
+
HighlightTextPipe] });
|
|
189
|
+
SdsHighlightTextModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsHighlightTextModule, imports: [[
|
|
190
|
+
CommonModule
|
|
191
|
+
]] });
|
|
192
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsHighlightTextModule, decorators: [{
|
|
193
|
+
type: NgModule,
|
|
194
|
+
args: [{
|
|
195
|
+
declarations: [
|
|
196
|
+
HighlightTextDirective,
|
|
197
|
+
HighlightTextPipe
|
|
198
|
+
],
|
|
199
|
+
exports: [
|
|
200
|
+
HighlightTextDirective,
|
|
201
|
+
HighlightTextPipe
|
|
202
|
+
],
|
|
203
|
+
imports: [
|
|
204
|
+
CommonModule
|
|
205
|
+
]
|
|
206
|
+
}]
|
|
207
|
+
}] });
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Generated bundle index. Do not edit.
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
export { HighlightTextDirective, HighlightTextPipe, SdsHighlightTextModule };
|
|
214
|
+
//# 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;IAEF,MAAM,WAAW,GAAa,EAAE,CAAC;;IAGjC,MAAM,UAAU,GAAG,yBAAyB;AACzC,SAAA,GAAG,CAAC,CAAC,eAAuB,KAAI;QAC/B,MAAM,mBAAmB,GAAG,aAAa;aACtC,GAAG,CAAC,MAAM,IAAG;AACZ,YAAA,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AAA,sBAAsB,EAJxB,OAAA,EAAA,CAAA;YACP,YAAY;AACb,SAAA,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;AACF,iBAAA,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,m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A;AACD,oBAAA,OAAO,EAAE;wBACL,mBAAmB;AACtB,qBAAA;AACJ,iBAAA,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,12 +15,15 @@ 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
|
};
|
|
@@ -29,13 +32,16 @@ class SdsModalComponent {
|
|
|
29
32
|
open() {
|
|
30
33
|
if (this._modal != undefined) {
|
|
31
34
|
this._modal.nativeElement.style.display = 'block';
|
|
32
|
-
this.
|
|
35
|
+
this.isOpen = true;
|
|
36
|
+
if (this.autoFocusCloseButton)
|
|
37
|
+
this._closeButton?.nativeElement.focus();
|
|
33
38
|
this.modalOpen.emit();
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
close() {
|
|
37
42
|
if (this._modal != undefined) {
|
|
38
43
|
this._modal.nativeElement.style.display = 'none';
|
|
44
|
+
this.isOpen = false;
|
|
39
45
|
this.modalClose.emit();
|
|
40
46
|
}
|
|
41
47
|
}
|
|
@@ -49,15 +55,16 @@ class SdsModalComponent {
|
|
|
49
55
|
this._modal != undefined &&
|
|
50
56
|
this._modal.nativeElement.style.display === 'block') {
|
|
51
57
|
// console.log(`${this.constructor.name} got event: ${event.code}`);
|
|
58
|
+
this.closeEscapeKeypress.emit();
|
|
52
59
|
this.close();
|
|
53
60
|
}
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
63
|
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"] }] });
|
|
64
|
+
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
65
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsModalComponent, decorators: [{
|
|
59
66
|
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"] }]
|
|
67
|
+
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
68
|
}], ctorParameters: function () { return []; }, propDecorators: { headerContent: [{
|
|
62
69
|
type: ContentChild,
|
|
63
70
|
args: ['header']
|
|
@@ -73,6 +80,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
73
80
|
type: Input
|
|
74
81
|
}], showCloseButton: [{
|
|
75
82
|
type: Input
|
|
83
|
+
}], autoFocusCloseButton: [{
|
|
84
|
+
type: Input
|
|
76
85
|
}], translations: [{
|
|
77
86
|
type: Input
|
|
78
87
|
}], isScrollable: [{
|
|
@@ -85,9 +94,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
85
94
|
type: Output
|
|
86
95
|
}], closeClick: [{
|
|
87
96
|
type: Output
|
|
97
|
+
}], closeEscapeKeypress: [{
|
|
98
|
+
type: Output
|
|
88
99
|
}], _modal: [{
|
|
89
100
|
type: ViewChild,
|
|
90
101
|
args: ['modal', { static: false }]
|
|
102
|
+
}], _closeButton: [{
|
|
103
|
+
type: ViewChild,
|
|
104
|
+
args: ['closeButton', { static: false }]
|
|
91
105
|
}] } });
|
|
92
106
|
|
|
93
107
|
class SdsDialogComponent {
|
|
@@ -101,23 +115,38 @@ class SdsDialogComponent {
|
|
|
101
115
|
this.secondaryButtonText = 'Cancel';
|
|
102
116
|
this.secondaryButtonClass = 'btn-secondary';
|
|
103
117
|
this.secondaryButtonType = 'button';
|
|
118
|
+
this.closeOnEscape = true;
|
|
104
119
|
this.showHeader = true;
|
|
105
120
|
this.showCloseButton = true;
|
|
106
121
|
this.showPrimaryButton = true;
|
|
107
122
|
this.showSecondaryButton = true;
|
|
123
|
+
this.autofocusElement = 'primary';
|
|
108
124
|
this.dialogOpen = new EventEmitter();
|
|
109
125
|
this.dialogClose = new EventEmitter();
|
|
126
|
+
this.isOpen = false;
|
|
127
|
+
}
|
|
128
|
+
ngOnInit() {
|
|
129
|
+
if (this.autofocusElement == 'primary' && !this.showPrimaryButton) {
|
|
130
|
+
this.autofocusElement = 'secondary';
|
|
131
|
+
}
|
|
132
|
+
if (this.autofocusElement == 'secondary' && !this.showSecondaryButton) {
|
|
133
|
+
this.autofocusElement = 'close';
|
|
134
|
+
}
|
|
135
|
+
if (this.autofocusElement == 'close' && !this.showCloseButton) {
|
|
136
|
+
this.autofocusElement = 'content';
|
|
137
|
+
}
|
|
110
138
|
}
|
|
111
|
-
ngOnInit() { }
|
|
112
139
|
open(callback, data) {
|
|
113
140
|
this._callback = callback;
|
|
114
141
|
this._callbackData = data;
|
|
115
142
|
if (this._modal != undefined) {
|
|
143
|
+
this.isOpen = true;
|
|
116
144
|
this._modal.open();
|
|
117
145
|
}
|
|
118
146
|
}
|
|
119
147
|
close() {
|
|
120
148
|
if (this._modal != undefined) {
|
|
149
|
+
this.isOpen = false;
|
|
121
150
|
this._modal.close();
|
|
122
151
|
}
|
|
123
152
|
}
|
|
@@ -138,18 +167,36 @@ class SdsDialogComponent {
|
|
|
138
167
|
this._callback('close', this._callbackData);
|
|
139
168
|
}
|
|
140
169
|
}
|
|
170
|
+
onCloseEscapeKeypress() {
|
|
171
|
+
if (this._callback) {
|
|
172
|
+
this._callback('close', this._callbackData);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
141
175
|
onModalClose() {
|
|
142
176
|
this.dialogClose.emit();
|
|
143
177
|
}
|
|
144
178
|
onModalOpen() {
|
|
145
179
|
this.dialogOpen.emit();
|
|
180
|
+
switch (this.autofocusElement) {
|
|
181
|
+
case 'primary':
|
|
182
|
+
this._primaryButton?.nativeElement.focus();
|
|
183
|
+
break;
|
|
184
|
+
case 'secondary':
|
|
185
|
+
this._secondaryButton?.nativeElement.focus();
|
|
186
|
+
break;
|
|
187
|
+
case 'content':
|
|
188
|
+
this._content?.nativeElement.focus();
|
|
189
|
+
break;
|
|
190
|
+
default:
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
146
193
|
}
|
|
147
194
|
}
|
|
148
195
|
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
|
|
196
|
+
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
197
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: SdsDialogComponent, decorators: [{
|
|
151
198
|
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
|
|
199
|
+
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
200
|
}], ctorParameters: function () { return []; }, propDecorators: { title: [{
|
|
154
201
|
type: Input
|
|
155
202
|
}], closeText: [{
|
|
@@ -168,6 +215,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
168
215
|
type: Input
|
|
169
216
|
}], secondaryButtonType: [{
|
|
170
217
|
type: Input
|
|
218
|
+
}], closeOnEscape: [{
|
|
219
|
+
type: Input
|
|
171
220
|
}], showHeader: [{
|
|
172
221
|
type: Input
|
|
173
222
|
}], showCloseButton: [{
|
|
@@ -176,6 +225,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
176
225
|
type: Input
|
|
177
226
|
}], showSecondaryButton: [{
|
|
178
227
|
type: Input
|
|
228
|
+
}], autofocusElement: [{
|
|
229
|
+
type: Input
|
|
230
|
+
}], modalDialogId: [{
|
|
231
|
+
type: Input
|
|
179
232
|
}], dialogOpen: [{
|
|
180
233
|
type: Output
|
|
181
234
|
}], dialogClose: [{
|
|
@@ -183,6 +236,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
183
236
|
}], _modal: [{
|
|
184
237
|
type: ViewChild,
|
|
185
238
|
args: ['modal', { static: true }]
|
|
239
|
+
}], _content: [{
|
|
240
|
+
type: ViewChild,
|
|
241
|
+
args: ['content', { read: ElementRef, static: true }]
|
|
242
|
+
}], _primaryButton: [{
|
|
243
|
+
type: ViewChild,
|
|
244
|
+
args: ['primaryButton', { read: ElementRef, static: false }]
|
|
245
|
+
}], _secondaryButton: [{
|
|
246
|
+
type: ViewChild,
|
|
247
|
+
args: ['secondaryButton', { read: ElementRef, static: false }]
|
|
186
248
|
}] } });
|
|
187
249
|
|
|
188
250
|
const components = [
|