ngx-transforms 0.0.1
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/LICENSE +21 -0
- package/README.md +114 -0
- package/fesm2022/ngx-transforms.mjs +1245 -0
- package/fesm2022/ngx-transforms.mjs.map +1 -0
- package/package.json +53 -0
- package/types/ngx-transforms.d.ts +658 -0
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { PipeTransform, Provider } from '@angular/core';
|
|
3
|
+
import { AsciiConfig, TextToAsciiOptions } from 'ts-ascii-engine';
|
|
4
|
+
export { CharsetPreset } from 'ts-ascii-engine';
|
|
5
|
+
import { SafeHtml, SafeResourceUrl } from '@angular/platform-browser';
|
|
6
|
+
import * as QRCode from 'qrcode';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Configuration options for ASCII art generation
|
|
10
|
+
*/
|
|
11
|
+
interface AsciiArtOptions extends Partial<AsciiConfig> {
|
|
12
|
+
/**
|
|
13
|
+
* Text rendering options (only used when converting text to ASCII)
|
|
14
|
+
*/
|
|
15
|
+
textOptions?: TextToAsciiOptions;
|
|
16
|
+
/**
|
|
17
|
+
* Return format: 'html' returns formatted HTML, 'text' returns plain text
|
|
18
|
+
* @default 'html'
|
|
19
|
+
*/
|
|
20
|
+
format?: 'html' | 'text';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* AsciiArtPipe: Converts text into ASCII art using ts-ascii-engine.
|
|
24
|
+
*
|
|
25
|
+
* This pipe leverages the high-performance ts-ascii-engine library to convert
|
|
26
|
+
* text into visually appealing ASCII art with various customization options.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} value - The text to convert to ASCII art.
|
|
29
|
+
* @param {AsciiArtOptions} [options] - Configuration options for ASCII generation.
|
|
30
|
+
*
|
|
31
|
+
* @returns {string} - The ASCII art as HTML or plain text based on format option.
|
|
32
|
+
*
|
|
33
|
+
* @security
|
|
34
|
+
* The pipe returns HTML by default. When using with [innerHTML], Angular's
|
|
35
|
+
* DomSanitizer automatically sanitizes the output. For additional safety,
|
|
36
|
+
* you can explicitly sanitize:
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { DomSanitizer } from '@angular/platform-browser';
|
|
39
|
+
* this.safeHtml = this.sanitizer.sanitize(SecurityContext.HTML, asciiOutput);
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @performance
|
|
43
|
+
* - The AsciiGenerator instance is reused across transformations for optimal performance
|
|
44
|
+
* - Use smaller charset and width values for faster rendering
|
|
45
|
+
* - Consider format: 'text' for simple use cases (faster than HTML formatting)
|
|
46
|
+
* - The library is optimized with typed arrays and minimal garbage collection
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // Basic usage with default options
|
|
50
|
+
* {{ 'HELLO' | asciiArt }}
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // Custom charset and width
|
|
54
|
+
* {{ 'CODE' | asciiArt:{ charset: CharsetPreset.BLOCK, width: 60 } }}
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // Plain text output
|
|
58
|
+
* {{ 'ASCII' | asciiArt:{ format: 'text' } }}
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Advanced text rendering with custom font
|
|
62
|
+
* {{ 'WELCOME' | asciiArt:{
|
|
63
|
+
* charset: CharsetPreset.STANDARD,
|
|
64
|
+
* width: 80,
|
|
65
|
+
* textOptions: {
|
|
66
|
+
* font: 'Arial',
|
|
67
|
+
* fontSize: 72,
|
|
68
|
+
* fontWeight: 'bold'
|
|
69
|
+
* }
|
|
70
|
+
* }}}
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // With inverted colors
|
|
74
|
+
* {{ 'DARK' | asciiArt:{ inverted: true, charset: CharsetPreset.MINIMAL } }}
|
|
75
|
+
*
|
|
76
|
+
* @author Mofiro Jean
|
|
77
|
+
*/
|
|
78
|
+
declare class AsciiArtPipe implements PipeTransform {
|
|
79
|
+
private generator;
|
|
80
|
+
constructor();
|
|
81
|
+
transform(value: string, options?: AsciiArtOptions): string;
|
|
82
|
+
/**
|
|
83
|
+
* Escapes HTML special characters to prevent XSS
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
private escapeHtml;
|
|
87
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AsciiArtPipe, never>;
|
|
88
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<AsciiArtPipe, "asciiArt", true>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* BarcodeElementType: Defines the type of element to render the barcode.
|
|
93
|
+
*
|
|
94
|
+
* @typedef {'svg' | 'img' | 'canvas'} BarcodeElementType
|
|
95
|
+
*/
|
|
96
|
+
type BarcodeElementType = 'svg' | 'img' | 'canvas';
|
|
97
|
+
/**
|
|
98
|
+
* BarcodeFormat: Defines supported barcode formats.
|
|
99
|
+
*
|
|
100
|
+
* @typedef {'CODE128' | 'EAN13' | 'CODE39'} BarcodeFormat
|
|
101
|
+
*/
|
|
102
|
+
type BarcodeFormat = 'CODE128' | 'EAN13' | 'CODE39';
|
|
103
|
+
/**
|
|
104
|
+
* BarcodeOptions: Configuration options for barcode generation.
|
|
105
|
+
*
|
|
106
|
+
* @interface BarcodeOptions
|
|
107
|
+
* @property {BarcodeElementType} [elementType='svg'] - Output type (svg, img, canvas).
|
|
108
|
+
* @property {BarcodeFormat} [format='CODE128'] - Barcode format.
|
|
109
|
+
* @property {number} [width=2] - Bar width in pixels.
|
|
110
|
+
* @property {number} [height=100] - Barcode height in pixels.
|
|
111
|
+
* @property {string} [lineColor='#000000'] - Color of bars.
|
|
112
|
+
* @property {boolean} [displayValue=true] - Show value below barcode.
|
|
113
|
+
*/
|
|
114
|
+
interface BarcodeOptions {
|
|
115
|
+
elementType?: BarcodeElementType;
|
|
116
|
+
format?: BarcodeFormat;
|
|
117
|
+
width?: number;
|
|
118
|
+
height?: number;
|
|
119
|
+
lineColor?: string;
|
|
120
|
+
displayValue?: boolean;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* BarcodePipe: Generates a barcode from a string value.
|
|
124
|
+
*
|
|
125
|
+
* @param {string} value - The value to encode (e.g., '123456789').
|
|
126
|
+
* @param {BarcodeOptions} [options={}] - Configuration options.
|
|
127
|
+
*
|
|
128
|
+
* @returns {Promise<SafeHtml | SafeResourceUrl>} - SVG markup or image data URL.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* <div [innerHTML]="'123456789' | barcode:{elementType:'svg',format:'CODE128'} | async"></div>
|
|
132
|
+
* <img [src]="'123456789' | barcode:{elementType:'img'} | async" />
|
|
133
|
+
*
|
|
134
|
+
* @author Mofiro Jean
|
|
135
|
+
*/
|
|
136
|
+
declare class BarcodePipe implements PipeTransform {
|
|
137
|
+
private sanitizer;
|
|
138
|
+
transform(value: string, options?: BarcodeOptions): Promise<SafeHtml | SafeResourceUrl | ''>;
|
|
139
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<BarcodePipe, never>;
|
|
140
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<BarcodePipe, "barcode", true>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* CamelCasePipe: Converts text to camelCase (e.g., "hello world" → "helloWorld").
|
|
145
|
+
*
|
|
146
|
+
* @param {string} value - The input string to transform.
|
|
147
|
+
* @returns {string} The string in camelCase, or an empty string if input is invalid.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```html
|
|
151
|
+
* {{ 'hello world' | camelCase }} <!-- Outputs: helloWorld -->
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @author Mofiro Jean
|
|
155
|
+
*/
|
|
156
|
+
declare class CamelCasePipe implements PipeTransform {
|
|
157
|
+
transform(value: string): string;
|
|
158
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CamelCasePipe, never>;
|
|
159
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<CamelCasePipe, "camelCase", true>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* ColorTargetType: Defines the target color format for conversion.
|
|
164
|
+
*
|
|
165
|
+
* @typedef {'hex' | 'rgb' | 'rgba'} ColorTargetType
|
|
166
|
+
*
|
|
167
|
+
* @description
|
|
168
|
+
* Specifies the output format for color conversion:
|
|
169
|
+
* - 'hex': Hexadecimal format (#RRGGBB or #RRGGBBAA)
|
|
170
|
+
* - 'rgb': RGB format rgb(r, g, b)
|
|
171
|
+
* - 'rgba': RGBA format rgba(r, g, b, a)
|
|
172
|
+
*/
|
|
173
|
+
type ColorTargetType = 'hex' | 'rgb' | 'rgba';
|
|
174
|
+
/**
|
|
175
|
+
* ColorConvertPipe: Converts colors between HEX, RGB, and RGBA formats.
|
|
176
|
+
*
|
|
177
|
+
* @description
|
|
178
|
+
* A versatile color conversion pipe that supports multiple input formats
|
|
179
|
+
* and can convert to hex, rgb, or rgba output formats.
|
|
180
|
+
*
|
|
181
|
+
* **Supported Input Formats:**
|
|
182
|
+
* - 3-digit HEX: #RGB (e.g., #F00)
|
|
183
|
+
* - 4-digit HEX with alpha: #RGBA (e.g., #F00F)
|
|
184
|
+
* - 6-digit HEX: #RRGGBB (e.g., #FF0000)
|
|
185
|
+
* - 8-digit HEX with alpha: #RRGGBBAA (e.g., #FF0000FF)
|
|
186
|
+
* - RGB: rgb(r, g, b) with flexible whitespace
|
|
187
|
+
* - RGBA: rgba(r, g, b, a) with flexible whitespace
|
|
188
|
+
*
|
|
189
|
+
* **Output Formats:**
|
|
190
|
+
* - 'hex': Returns #RRGGBB or #RRGGBBAA (if alpha < 1)
|
|
191
|
+
* - 'rgb': Returns rgb(r, g, b) - alpha is discarded
|
|
192
|
+
* - 'rgba': Returns rgba(r, g, b, a)
|
|
193
|
+
*
|
|
194
|
+
* @param {string} value - The input color string
|
|
195
|
+
* @param {ColorTargetType} target - The desired output format
|
|
196
|
+
* @returns {string} The converted color string, or original value if invalid
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* // Basic conversions
|
|
200
|
+
* {{ '#FF0000' | colorConvert:'rgb' }} // rgb(255, 0, 0)
|
|
201
|
+
* {{ 'rgb(0, 255, 0)' | colorConvert:'hex' }} // #00FF00
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* // Short hex support
|
|
205
|
+
* {{ '#F00' | colorConvert:'rgb' }} // rgb(255, 0, 0)
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* // Alpha channel support
|
|
209
|
+
* {{ '#FF000080' | colorConvert:'rgba' }} // rgba(255, 0, 0, 0.5)
|
|
210
|
+
* {{ 'rgba(255, 0, 0, 0.5)' | colorConvert:'hex' }} // #FF000080
|
|
211
|
+
*
|
|
212
|
+
* @author Mofiro Jean
|
|
213
|
+
*/
|
|
214
|
+
declare class ColorConvertPipe implements PipeTransform {
|
|
215
|
+
transform(value: string, target: ColorTargetType): string;
|
|
216
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ColorConvertPipe, never>;
|
|
217
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ColorConvertPipe, "colorConvert", true>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
declare class CountPipe implements PipeTransform {
|
|
221
|
+
transform(value: any): number;
|
|
222
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CountPipe, never>;
|
|
223
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<CountPipe, "count", true>;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* CreditCardMaskPipe: Masks all but the last four digits of a string, optionally controlled by a boolean flag.
|
|
228
|
+
* By default, masking is applied.
|
|
229
|
+
*
|
|
230
|
+
* @param {string} value - The input string to mask (e.g., credit card number).
|
|
231
|
+
* @param {boolean} shouldMask - (Optional) Determines if masking should be applied. Defaults to true.
|
|
232
|
+
* @returns {string} - The masked string or the original value if `shouldMask` is false or the value is too short.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* {{ '1234567890123456' | creditCardMask }} // Outputs: **** **** **** 3456
|
|
236
|
+
* {{ '1234-5678-9012-3456' | creditCardMask }} // Outputs: **** **** **** 3456
|
|
237
|
+
* {{ '1234567890123456' | creditCardMask: true }} // Outputs: **** **** **** 3456
|
|
238
|
+
* {{ '1234567890123456' | creditCardMask: false }} // Outputs: 1234567890123456
|
|
239
|
+
*
|
|
240
|
+
* @author Mofiro Jean
|
|
241
|
+
*/
|
|
242
|
+
declare class CreditCardMaskPipe implements PipeTransform {
|
|
243
|
+
transform(value: string | null | undefined, shouldMask?: boolean): string | null | undefined;
|
|
244
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CreditCardMaskPipe, never>;
|
|
245
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<CreditCardMaskPipe, "creditCardMask", true>;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* DeviceType: Defines the type of element to render the QR code.
|
|
250
|
+
*
|
|
251
|
+
* @typedef {'mobile' | 'tablet' | 'desktop' | 'unknown'} DeviceType
|
|
252
|
+
*
|
|
253
|
+
* @description
|
|
254
|
+
* This type specifies the type of device in which the program is currently running on.
|
|
255
|
+
* - 'mobile': Indicates that the device is mobile.
|
|
256
|
+
* - 'tablet': Indicates that the device is a tablet.
|
|
257
|
+
* - 'desktop': Indicates that the device is a desktop.
|
|
258
|
+
* - 'unknown': Indicates an invalid or empty input.
|
|
259
|
+
*/
|
|
260
|
+
type DeviceType = 'mobile' | 'tablet' | 'desktop' | 'unknown';
|
|
261
|
+
/**
|
|
262
|
+
* DeviceTypePipe: Detects the device type based on the user agent string.
|
|
263
|
+
*
|
|
264
|
+
* @param {string} value - The user agent string (defaults to navigator.userAgent).
|
|
265
|
+
*
|
|
266
|
+
* @returns {'mobile' | 'tablet' | 'desktop' | 'unknown'} - The detected device type.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* {{ '' | device }} // Outputs: 'mobile' (on a mobile device)
|
|
270
|
+
* <div *ngIf="'' | device === 'desktop'">Desktop-only content</div>
|
|
271
|
+
*/
|
|
272
|
+
declare class DeviceTypePipe implements PipeTransform {
|
|
273
|
+
transform(value?: string): DeviceType;
|
|
274
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DeviceTypePipe, never>;
|
|
275
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<DeviceTypePipe, "device", true>;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* EmailMaskPipe: Masks the local part of an email address, revealing only the first and last characters.
|
|
280
|
+
*
|
|
281
|
+
* This Angular pipe transforms an email address string by replacing the characters between the first and last characters of the local part (before the '@') with "***".
|
|
282
|
+
* If the local part is 2 characters or less, it masks all characters except the first.
|
|
283
|
+
*
|
|
284
|
+
* @param {string} value - The email address string to be masked.
|
|
285
|
+
* @returns {string} - The masked email address, or the original value if it's not a valid email or falsy.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* {{ 'test@example.com' | emailMask }} // Returns 't***t@example.com'
|
|
289
|
+
* {{ 'te@example.com' | emailMask }} // Returns 't***@example.com'
|
|
290
|
+
* {{ 't@example.com' | emailMask }} // Returns 't***@example.com'
|
|
291
|
+
* {{ 'example.com' | emailMask }} // Returns 'example.com'
|
|
292
|
+
* {{ null | emailMask }} // Returns ''
|
|
293
|
+
* {{ undefined | emailMask }} // Returns ''
|
|
294
|
+
*
|
|
295
|
+
* @author Mofiro Jean
|
|
296
|
+
*/
|
|
297
|
+
declare class EmailMaskPipe implements PipeTransform {
|
|
298
|
+
transform(value: string): string;
|
|
299
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<EmailMaskPipe, never>;
|
|
300
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<EmailMaskPipe, "emailMask", true>;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* GravatarPipe: Generates Gravatar URLs from email addresses.
|
|
305
|
+
*
|
|
306
|
+
* @param {string} value - The email address.
|
|
307
|
+
* @param {number} [size=80] - The avatar size in pixels.
|
|
308
|
+
*
|
|
309
|
+
* @returns {string} - The Gravatar URL.
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* <img [src]="'user@example.com' | gravatar:100" />
|
|
313
|
+
*
|
|
314
|
+
* @author Mofiro Jean
|
|
315
|
+
*/
|
|
316
|
+
declare class GravatarPipe implements PipeTransform {
|
|
317
|
+
transform(value: string, size?: number): string;
|
|
318
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GravatarPipe, never>;
|
|
319
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<GravatarPipe, "gravatar", true>;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* HighlightPipe: Highlights occurrences of a search term within a string.
|
|
324
|
+
*
|
|
325
|
+
* This Angular pipe transforms a string input by wrapping all occurrences of a specified
|
|
326
|
+
* search term with a `<span>` element that has the class "highlight".
|
|
327
|
+
* It uses the Angular `DomSanitizer` to bypass security and render the highlighted HTML.
|
|
328
|
+
*
|
|
329
|
+
* @param {string} value - The input string in which to highlight the search term.
|
|
330
|
+
* @param {string} searchTerm - The string to search for and highlight.
|
|
331
|
+
* @returns {SafeHtml} - The input string with the search term highlighted, or an empty string if input or searchTerm are falsy.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* {{ 'This is a test string' | highlight: 'test' }} // Returns 'This is a <span class="highlight">test</span> string'
|
|
335
|
+
* {{ 'This is a test TEST string' | highlight: 'test' }} // Returns 'This is a <span class="highlight">test</span> <span class="highlight">TEST</span> string'
|
|
336
|
+
* {{ 'This is a test string' | highlight: '' }} // Returns 'This is a test string'
|
|
337
|
+
* {{ null | highlight: 'test' }} // Returns ''
|
|
338
|
+
* {{ undefined | highlight: 'test' }} // Returns ''
|
|
339
|
+
*
|
|
340
|
+
* @author Mofiro Jean
|
|
341
|
+
*/
|
|
342
|
+
declare class HighlightPipe implements PipeTransform {
|
|
343
|
+
private sanitizer;
|
|
344
|
+
transform(value: string, searchTerm: string): SafeHtml;
|
|
345
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HighlightPipe, never>;
|
|
346
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<HighlightPipe, "highlight", true>;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Converts special HTML characters in a string to their corresponding HTML entities.
|
|
351
|
+
* This prevents the browser from interpreting the input as HTML, rendering it as plain text.
|
|
352
|
+
*
|
|
353
|
+
* @param {string} value - The input string containing HTML to escape.
|
|
354
|
+
* @returns {string} The string with special HTML characters escaped, or an empty string if input is invalid.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```html
|
|
358
|
+
* {{ '<p>Hello</p>' | htmlEscape }} <!-- Outputs: <p>Hello</p> -->
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
declare class HtmlEscapePipe implements PipeTransform {
|
|
362
|
+
transform(value: string): string;
|
|
363
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HtmlEscapePipe, never>;
|
|
364
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<HtmlEscapePipe, "htmlEscape", true>;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Sanitizes HTML input to remove unsafe elements while allowing safe HTML to be rendered.
|
|
369
|
+
* Uses Angular's DomSanitizer to mark the output as trusted for use in [innerHTML].
|
|
370
|
+
*
|
|
371
|
+
* @param {string} value - The input string containing HTML to sanitize.
|
|
372
|
+
* @returns {SafeHtml} The sanitized HTML marked as safe, or an empty string if input is invalid.
|
|
373
|
+
*
|
|
374
|
+
* @remarks
|
|
375
|
+
* WARNING: Use with caution. Only apply to trusted input to avoid XSS risks.
|
|
376
|
+
* Ensure input is pre-validated or sourced from a secure origin (e.g., a controlled rich-text editor).
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```html
|
|
380
|
+
* <div [innerHTML]="'<p>Hello</p><script>alert(1)</script>' | htmlSanitize"></div>
|
|
381
|
+
* <!-- Renders: <p>Hello</p> (script tag removed) -->
|
|
382
|
+
* ```
|
|
383
|
+
*/
|
|
384
|
+
declare class HtmlSanitizePipe implements PipeTransform {
|
|
385
|
+
private sanitizer;
|
|
386
|
+
transform(value: string): SafeHtml;
|
|
387
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HtmlSanitizePipe, never>;
|
|
388
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<HtmlSanitizePipe, "htmlSanitize", true>;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* InitialsPipe: Extracts initials from a name.
|
|
393
|
+
*
|
|
394
|
+
* @param {string} value - The full name.
|
|
395
|
+
*
|
|
396
|
+
* @returns {string} - The initials (e.g., 'John Doe' → 'JD').
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* {{ 'John Doe' | initials }} // Outputs: JD
|
|
400
|
+
* {{ 'Mary Jane Watson' | initials }} // Outputs: MJW
|
|
401
|
+
*
|
|
402
|
+
* @author Mofiro Jean
|
|
403
|
+
*/
|
|
404
|
+
declare class InitialsPipe implements PipeTransform {
|
|
405
|
+
transform(value: string): string;
|
|
406
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<InitialsPipe, never>;
|
|
407
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<InitialsPipe, "initials", true>;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* IpAddressMaskPipe: Masks the last two octets of an IPv4 address.
|
|
412
|
+
*
|
|
413
|
+
* @param {string} value - The IPv4 address (e.g., 192.168.1.1).
|
|
414
|
+
* @param {boolean} shouldMask - (Optional) Determines if masking should be applied. Defaults to true..
|
|
415
|
+
*
|
|
416
|
+
* @returns {string} - The masked IP address (e.g., 192.168.*.*).
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* {{ '192.168.1.1' | ipAddressMask }} // Outputs: 192.168.*.*
|
|
420
|
+
* {{ '10.0.0.255' | ipAddressMask }} // Outputs: 10.0.*.*
|
|
421
|
+
*
|
|
422
|
+
* @author Mofiro Jean
|
|
423
|
+
*/
|
|
424
|
+
declare class IpAddressMaskPipe implements PipeTransform {
|
|
425
|
+
transform(value: string, shouldMask?: boolean): string;
|
|
426
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<IpAddressMaskPipe, never>;
|
|
427
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<IpAddressMaskPipe, "ipAddressMask", true>;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* JsonPrettyPipe: Formats JSON data with indentation and syntax highlighting.
|
|
432
|
+
*
|
|
433
|
+
* @param {string | object} value - The JSON string or object to format.
|
|
434
|
+
* @param {number} [spaces=2] - Number of spaces for indentation.
|
|
435
|
+
*
|
|
436
|
+
* @returns {SafeHtml} - Formatted HTML with color-coded JSON.
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* {{ '{"name": "John", "age": 30}' | jsonPretty }} // Outputs: Colorful, indented JSON
|
|
440
|
+
* <pre [innerHTML]="data | jsonPretty:4"></pre> // 4-space indentation
|
|
441
|
+
*
|
|
442
|
+
* @author Mofiro Jean
|
|
443
|
+
*/
|
|
444
|
+
declare class JsonPrettyPipe implements PipeTransform {
|
|
445
|
+
private sanitizer;
|
|
446
|
+
transform(value: string | object, spaces?: number, highlightProperty?: string | null): SafeHtml;
|
|
447
|
+
private highlightJson;
|
|
448
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<JsonPrettyPipe, never>;
|
|
449
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<JsonPrettyPipe, "jsonPretty", true>;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* KebabCasePipe: Converts text to kebab-case (e.g., "hello world" → "hello-world").
|
|
454
|
+
*
|
|
455
|
+
* @param {string} value - The input string to transform.
|
|
456
|
+
* @returns {string} The string in kebab-case, or an empty string if input is invalid.
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```html
|
|
460
|
+
* {{ 'hello world' | kebabCase }} <!-- Outputs: hello-world -->
|
|
461
|
+
* ```
|
|
462
|
+
*
|
|
463
|
+
* @author Mofiro Jean
|
|
464
|
+
*/
|
|
465
|
+
declare class KebabCasePipe implements PipeTransform {
|
|
466
|
+
transform(value: string): string;
|
|
467
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<KebabCasePipe, never>;
|
|
468
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<KebabCasePipe, "kebabCase", true>;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* MorseCodePipe: Converts text to Morse code.
|
|
473
|
+
*
|
|
474
|
+
* @param {string} value - The text to convert to Morse code.
|
|
475
|
+
*
|
|
476
|
+
* @returns {string} - The Morse code representation (e.g., 'SOS' → '... --- ...').
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* {{ 'SOS' | morseCode }} // Outputs: '... --- ...'
|
|
480
|
+
* {{ 'HELP' | morseCode }} // Outputs: '.... . .-.. .--.'
|
|
481
|
+
* <p>{{ userInput | morseCode }}</p>
|
|
482
|
+
*
|
|
483
|
+
* @author Mofiro Jean
|
|
484
|
+
*/
|
|
485
|
+
declare class MorseCodePipe implements PipeTransform {
|
|
486
|
+
private readonly morseCodeMap;
|
|
487
|
+
transform(value: string): string;
|
|
488
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MorseCodePipe, never>;
|
|
489
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<MorseCodePipe, "morseCode", true>;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* QrCodePipe: Generates a QR code from a string.
|
|
494
|
+
*
|
|
495
|
+
* @param {string} value - The string to encode.
|
|
496
|
+
* @param {QRCode.QRCodeToDataURLOptions} [options] - The QR code options.
|
|
497
|
+
*
|
|
498
|
+
* @returns {Promise<string>} - A promise that resolves with the QR code data URL.
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* <img [src]="'Hello, World!' | qrCode | async" />
|
|
502
|
+
*
|
|
503
|
+
* @author Mofiro Jean
|
|
504
|
+
*/
|
|
505
|
+
declare class QrCodePipe implements PipeTransform {
|
|
506
|
+
transform(value: string, options?: QRCode.QRCodeToDataURLOptions): Promise<string>;
|
|
507
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<QrCodePipe, never>;
|
|
508
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<QrCodePipe, "qrCode", true>;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* ReplacePipe: A custom Angular pipe that either highlights or replaces text based on a pattern.
|
|
513
|
+
*
|
|
514
|
+
* - If `isReplace` is `false`, it highlights occurrences of the pattern (if `highlightClass` is provided).
|
|
515
|
+
* - If `isReplace` is `true`, it replaces occurrences of the pattern with the replacement string, optionally highlighting the replacement.
|
|
516
|
+
*
|
|
517
|
+
* @param {string} value - The input string to transform.
|
|
518
|
+
* @param {string | RegExp} pattern - The pattern to match (string or RegExp). If an empty string, the value is returned as-is.
|
|
519
|
+
* @param {string} replacement - The string to replace matches with.
|
|
520
|
+
* @param {string} [highlightClass] - Optional CSS class for highlighting matched or replaced text (e.g., 'highlight').
|
|
521
|
+
* @param {boolean} [isReplace=true] - Whether to perform replacement (true) or only highlight matches (false).
|
|
522
|
+
*
|
|
523
|
+
* @returns {string | SafeHtml} - Returns the transformed string or SafeHtml with highlights.
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* {{ 'Hello World' | replace:'World':'Universe' }}
|
|
527
|
+
* // Output: Hello Universe
|
|
528
|
+
*
|
|
529
|
+
* {{ 'test123' | replace:/\d+/g:'X':'highlight' }}
|
|
530
|
+
* // Output: test<span class="highlight">X</span>
|
|
531
|
+
*
|
|
532
|
+
* {{ 'Angular is great' | replace:'great':'awesome':'highlight':true }}
|
|
533
|
+
* // Output: Angular is <span class="highlight">awesome</span>
|
|
534
|
+
*
|
|
535
|
+
* {{ 'Angular is great' | replace:'great':'awesome':'highlight':false }}
|
|
536
|
+
* // Output: Angular is <span class="highlight">great</span>
|
|
537
|
+
*
|
|
538
|
+
* <div [innerHTML]="'Angular is great' | replace:'great':'awesome':'highlight':false"></div>
|
|
539
|
+
* // Renders: Angular is <span class="highlight">great</span>
|
|
540
|
+
*
|
|
541
|
+
* @author Mofiro Jean
|
|
542
|
+
*/
|
|
543
|
+
declare class ReplacePipe implements PipeTransform {
|
|
544
|
+
private sanitizer;
|
|
545
|
+
transform(value: string, pattern: string | RegExp, replacement: string, highlightClass?: string, isReplace?: boolean): string | SafeHtml;
|
|
546
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ReplacePipe, never>;
|
|
547
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ReplacePipe, "replace", true>;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* ReversePipe: Reverses the characters in a string.
|
|
552
|
+
*
|
|
553
|
+
* @param {string} value - The string to reverse.
|
|
554
|
+
*
|
|
555
|
+
* @returns {string} - The reversed string (e.g., 'hello' → 'olleh').
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
* {{ 'hello' | reverse }} // Outputs: 'olleh'
|
|
559
|
+
* {{ '12345' | reverse }} // Outputs: '54321'
|
|
560
|
+
* <p>{{ userInput | reverse }}</p>
|
|
561
|
+
*
|
|
562
|
+
* @author Mofiro Jean
|
|
563
|
+
*/
|
|
564
|
+
declare class ReversePipe implements PipeTransform {
|
|
565
|
+
transform(value: string): string;
|
|
566
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ReversePipe, never>;
|
|
567
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ReversePipe, "reverse", true>;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* SnakeCasePipe: Converts text to snake_case (e.g., "hello world" → "hello_world").
|
|
572
|
+
*
|
|
573
|
+
* @param {string} value - The input string to transform.
|
|
574
|
+
* @returns {string} The string in snake_case, or an empty string if input is invalid.
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* ```html
|
|
578
|
+
* {{ 'hello world' | snakeCase }} <!-- Outputs: hello_world -->
|
|
579
|
+
* ```
|
|
580
|
+
*
|
|
581
|
+
* @author Mofiro Jean
|
|
582
|
+
*/
|
|
583
|
+
declare class SnakeCasePipe implements PipeTransform {
|
|
584
|
+
transform(value: string): string;
|
|
585
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SnakeCasePipe, never>;
|
|
586
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<SnakeCasePipe, "snakeCase", true>;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* TextToSpeechPipe: Converts text to speech using the Web Speech API.
|
|
591
|
+
*
|
|
592
|
+
* @param {string} value - The text to convert to speech.
|
|
593
|
+
* @param {string} [lang='en-US'] - The language (local) for speech synthesis.
|
|
594
|
+
*
|
|
595
|
+
* @returns {void} - Triggers speech synthesis (no return value).
|
|
596
|
+
*
|
|
597
|
+
* @example
|
|
598
|
+
* <div>{{ Hello World' | textToSpeech }}</div>
|
|
599
|
+
* <div>{{ 'Bonjour' | textToSpeech:'fr-FR' }}h</div>
|
|
600
|
+
*
|
|
601
|
+
* @author Mofiro Jean
|
|
602
|
+
*/
|
|
603
|
+
declare class TextToSpeechPipe implements PipeTransform {
|
|
604
|
+
transform(value: string, lang?: string): void;
|
|
605
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TextToSpeechPipe, never>;
|
|
606
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<TextToSpeechPipe, "textToSpeech", true>;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* TitleCasePipe: Capitalizes the first letter of each word in a string.
|
|
611
|
+
*
|
|
612
|
+
* @param {string} value - The input string to transform.
|
|
613
|
+
* @returns {string} The string with each word capitalized, or an empty string if input is invalid.
|
|
614
|
+
*
|
|
615
|
+
* @example
|
|
616
|
+
* ```html
|
|
617
|
+
* {{ 'hello world' | titleCase }} <!-- Outputs: Hello World -->
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
620
|
+
declare class TitleCasePipe implements PipeTransform {
|
|
621
|
+
transform(value: string): string;
|
|
622
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TitleCasePipe, never>;
|
|
623
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<TitleCasePipe, "titleCase", true>;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* TruncatePipe: Truncates a string to a specified maximum length, optionally preserving words.
|
|
628
|
+
*
|
|
629
|
+
* This Angular pipe transforms a string input by truncating it to the given `maxLength`.
|
|
630
|
+
* It provides options to customize the ellipsis and preserve word boundaries.
|
|
631
|
+
*
|
|
632
|
+
* @param {string} value - The input string to be truncated.
|
|
633
|
+
* @param {number} [maxLength=10] - The maximum length of the truncated string. Defaults to 10.
|
|
634
|
+
* @param {string} [ellipsis='...'] - The string to append to the truncated portion. Defaults to '...'.
|
|
635
|
+
* @param {boolean} [preserveWords=false] - If true, truncates at the last space before `maxLength` to avoid cutting words. Defaults to false.
|
|
636
|
+
* @returns {string} - The truncated string. Returns an empty string if the input is null, undefined, or not a string.
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* {{ 'This is a long sentence' | truncate }} // Returns 'This is a...'
|
|
640
|
+
* {{ 'This is a long sentence' | truncate: 20 }} // Returns 'This is a long sente...'
|
|
641
|
+
* {{ 'This is a long sentence' | truncate: 15: ' [more]' }} // Returns 'This is a long [more]'
|
|
642
|
+
* {{ 'This is a long sentence' | truncate: 15: '...' : true }} // Returns 'This is a...'
|
|
643
|
+
* {{ 'This is a long sentence' | truncate: 20: '...' : true }} // Returns 'This is a long...'
|
|
644
|
+
* {{ null | truncate }} // Returns ''
|
|
645
|
+
* {{ undefined | truncate }} // Returns ''
|
|
646
|
+
*
|
|
647
|
+
* @author Mofiro Jean
|
|
648
|
+
*/
|
|
649
|
+
declare class TruncatePipe implements PipeTransform {
|
|
650
|
+
transform(value: string, maxLength?: number, ellipsis?: string, preserveWords?: boolean): string;
|
|
651
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TruncatePipe, never>;
|
|
652
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<TruncatePipe, "truncate", true>;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
declare const ALL_PIPES: Provider[];
|
|
656
|
+
|
|
657
|
+
export { ALL_PIPES, AsciiArtPipe, BarcodePipe, CamelCasePipe, ColorConvertPipe, CountPipe, CreditCardMaskPipe, DeviceTypePipe, EmailMaskPipe, GravatarPipe, HighlightPipe, HtmlEscapePipe, HtmlSanitizePipe, InitialsPipe, IpAddressMaskPipe, JsonPrettyPipe, KebabCasePipe, MorseCodePipe, QrCodePipe, ReplacePipe, ReversePipe, SnakeCasePipe, TextToSpeechPipe, TitleCasePipe, TruncatePipe };
|
|
658
|
+
export type { AsciiArtOptions, BarcodeElementType, BarcodeFormat, BarcodeOptions, ColorTargetType, DeviceType };
|