@rt-tools/core 0.0.6 → 0.2.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.
@@ -1,8 +1,181 @@
1
- import { Observable } from 'rxjs';
1
+ import { ConnectedPosition } from '@angular/cdk/overlay';
2
2
  import * as i0 from '@angular/core';
3
- import { InjectionToken, OnChanges, ElementRef, Renderer2, PipeTransform, Provider } from '@angular/core';
3
+ import { InputSignalWithTransform, InputSignal, OnInit, Signal, OnDestroy, OutputEmitterRef, PipeTransform, Provider, InjectionToken, OnChanges, ElementRef, Renderer2 } from '@angular/core';
4
+ import { BooleanInput } from '@angular/cdk/coercion';
5
+ import { Nullable } from '@rt-tools/utils';
6
+ import { SafeHtml } from '@angular/platform-browser';
7
+ import { Observable } from 'rxjs';
8
+ import { ValidatorFn, AbstractControl, ValidationErrors } from '@angular/forms';
9
+
10
+ declare const OVERLAY_POSITIONS: Readonly<ConnectedPosition[]>;
11
+
12
+ declare class RtIconOutlinedDirective {
13
+ isOutlined: InputSignalWithTransform<boolean, BooleanInput>;
14
+ get fontVariationSettings(): string;
15
+ static ɵfac: i0.ɵɵFactoryDeclaration<RtIconOutlinedDirective, never>;
16
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RtIconOutlinedDirective, "mat-icon[rtIconOutlined]", never, { "isOutlined": { "alias": "rtIconOutlined"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
17
+ }
18
+
19
+ declare class RtScrollToElementDirective {
20
+ #private;
21
+ rtScrollToElement: InputSignal<string | number>;
22
+ elements: InputSignalWithTransform<unknown[], unknown[]>;
23
+ constructor();
24
+ static ɵfac: i0.ɵɵFactoryDeclaration<RtScrollToElementDirective, never>;
25
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RtScrollToElementDirective, "[rtScrollToElement]", never, { "rtScrollToElement": { "alias": "rtScrollToElement"; "required": true; "isSignal": true; }; "elements": { "alias": "elements"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
26
+ }
27
+
28
+ declare class RtNavigationDirective {
29
+ #private;
30
+ link: InputSignal<Nullable<string>>;
31
+ onClick(event: MouseEvent): void;
32
+ static ɵfac: i0.ɵɵFactoryDeclaration<RtNavigationDirective, never>;
33
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RtNavigationDirective, "[rtNavigationDirective]", never, { "link": { "alias": "rtNavigationDirective"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
34
+ }
35
+
36
+ declare abstract class RtTabQueryParamDirective implements OnInit {
37
+ #private;
38
+ readonly currentTabIndex: Signal<number>;
39
+ ngOnInit(): void;
40
+ setQueryTab(index: number): void;
41
+ static ɵfac: i0.ɵɵFactoryDeclaration<RtTabQueryParamDirective, never>;
42
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RtTabQueryParamDirective, never, never, {}, {}, never, never, true, never>;
43
+ }
44
+
45
+ declare class RtScrollDirective implements OnInit, OnDestroy {
46
+ #private;
47
+ active: InputSignal<boolean>;
48
+ multiplier: InputSignal<number>;
49
+ readonly scrollAction: OutputEmitterRef<void>;
50
+ ngOnInit(): void;
51
+ ngOnDestroy(): void;
52
+ scroll: EventListener;
53
+ static ɵfac: i0.ɵɵFactoryDeclaration<RtScrollDirective, never>;
54
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RtScrollDirective, "[rtScrollDirective]", never, { "active": { "alias": "active"; "required": false; "isSignal": true; }; "multiplier": { "alias": "multiplier"; "required": false; "isSignal": true; }; }, { "scrollAction": "scrollAction"; }, never, never, true, never>;
55
+ }
56
+
57
+ declare class RtEscapeKeyDirective {
58
+ readonly escapeKeyAction: OutputEmitterRef<void>;
59
+ handleKeyboardEvent(event: KeyboardEvent): void;
60
+ static ɵfac: i0.ɵɵFactoryDeclaration<RtEscapeKeyDirective, never>;
61
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RtEscapeKeyDirective, "[rtEscapeKey]", never, {}, { "escapeKeyAction": "escapeKeyAction"; }, never, never, true, never>;
62
+ }
63
+
64
+ declare enum POSITION_ENUM {
65
+ LEFT = "left",
66
+ RIGHT = "right",
67
+ TOP = "top",
68
+ BOTTOM = "bottom",
69
+ START = "start",
70
+ END = "end",
71
+ CENTER = "center"
72
+ }
73
+
74
+ /**
75
+ * This function is a type guard that checks if a value is an instance of HTMLElement.
76
+ */
77
+ declare function isHTMLElement(element: any): element is HTMLElement;
78
+
79
+ declare class BreakStringPipe implements PipeTransform {
80
+ transform(value: Nullable<string>): string;
81
+ static ɵfac: i0.ɵɵFactoryDeclaration<BreakStringPipe, never>;
82
+ static ɵpipe: i0.ɵɵPipeDeclaration<BreakStringPipe, "breakString", true>;
83
+ }
84
+
85
+ declare class SanitizePipe implements PipeTransform {
86
+ #private;
87
+ transform(value: string): SafeHtml;
88
+ static ɵfac: i0.ɵɵFactoryDeclaration<SanitizePipe, never>;
89
+ static ɵpipe: i0.ɵɵPipeDeclaration<SanitizePipe, "sanitize", true>;
90
+ }
91
+
92
+ declare class EntityToStringPipe implements PipeTransform {
93
+ transform<T>(value: T): string;
94
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityToStringPipe, never>;
95
+ static ɵpipe: i0.ɵɵPipeDeclaration<EntityToStringPipe, "entityToString", true>;
96
+ }
97
+
98
+ declare class EmptyToDashPipe implements PipeTransform {
99
+ transform<T>(value: T | null | undefined): T | string;
100
+ static ɵfac: i0.ɵɵFactoryDeclaration<EmptyToDashPipe, never>;
101
+ static ɵpipe: i0.ɵɵPipeDeclaration<EmptyToDashPipe, "emptyToDash", true>;
102
+ }
103
+
104
+ /**
105
+ * @description Use to compare equality to any of items with provided value
106
+ * @example
107
+ *
108
+ * Direct usage
109
+ * ```ts
110
+ * equalPipe.transform(100, 1, 10, 100) // => true
111
+ * ```
112
+ *
113
+ * Template usage
114
+ *
115
+ * ```html
116
+ * <div *ngIf="100 | equal:1:10:100">Visible</div>
117
+ * ```
118
+ */
119
+ declare class EqualPipe implements PipeTransform {
120
+ transform(value: any, ...compares: any[]): boolean;
121
+ static ɵfac: i0.ɵɵFactoryDeclaration<EqualPipe, never>;
122
+ static ɵpipe: i0.ɵɵPipeDeclaration<EqualPipe, "equal", true>;
123
+ }
124
+
125
+ /**
126
+ * @description Use to access to the deep object state for comparison
127
+ * @example
128
+ * {a: {b: true}} | equalChain:'a':'b':true => true
129
+ */
130
+ declare class EqualChainPipe implements PipeTransform {
131
+ transform(obj: object, ...args: any[]): boolean;
132
+ static ɵfac: i0.ɵɵFactoryDeclaration<EqualChainPipe, never>;
133
+ static ɵpipe: i0.ɵɵPipeDeclaration<EqualChainPipe, "equalChain", true>;
134
+ }
135
+
136
+ /**
137
+ * @description Use to compare not equality to all items with provided value
138
+ * @example
139
+ *
140
+ * Direct usage
141
+ * ```ts
142
+ * notEqualPipe.transform(100, 1, 10, 100) // => false
143
+ * ```
144
+ *
145
+ * Template usage
146
+ *
147
+ * ```html
148
+ * <div *ngIf="100 | notEqual:1:10:100">Invisible</div>
149
+ * ```
150
+ */
151
+ declare class NotEqualPipe implements PipeTransform {
152
+ transform(value: any, ...compares: any[]): boolean;
153
+ static ɵfac: i0.ɵɵFactoryDeclaration<NotEqualPipe, never>;
154
+ static ɵpipe: i0.ɵɵPipeDeclaration<NotEqualPipe, "notEqual", true>;
155
+ }
156
+
157
+ /**
158
+ * @description Use to access to the deep object state for comparison
159
+ * @example
160
+ * {a: {b: true}} | equalChain:'a':'b':false => true
161
+ */
162
+ declare class NotEqualChainPipe implements PipeTransform {
163
+ transform(obj: object, ...args: any[]): boolean;
164
+ static ɵfac: i0.ɵɵFactoryDeclaration<NotEqualChainPipe, never>;
165
+ static ɵpipe: i0.ɵɵPipeDeclaration<NotEqualChainPipe, "notEqualChain", true>;
166
+ }
167
+
168
+ declare class TernaryPipe implements PipeTransform {
169
+ transform(value: any, option1: any, option2: any): any;
170
+ static ɵfac: i0.ɵɵFactoryDeclaration<TernaryPipe, never>;
171
+ static ɵpipe: i0.ɵɵPipeDeclaration<TernaryPipe, "ternary", true>;
172
+ }
4
173
 
5
- declare function isNil<T>(entity: T | null | undefined): entity is null | undefined;
174
+ declare class IsEmailPipe implements PipeTransform {
175
+ transform(value: any): boolean;
176
+ static ɵfac: i0.ɵɵFactoryDeclaration<IsEmailPipe, never>;
177
+ static ɵpipe: i0.ɵɵPipeDeclaration<IsEmailPipe, "isEmail", true>;
178
+ }
6
179
 
7
180
  interface MessageBusEvent<T = string> {
8
181
  readonly type: T;
@@ -27,14 +200,122 @@ declare class PlatformService {
27
200
  static ɵprov: i0.ɵɵInjectableDeclaration<PlatformService>;
28
201
  }
29
202
 
203
+ declare namespace OSTypes {
204
+ const WINDOWS: string;
205
+ const MAC_OS: string;
206
+ const LINUX: string;
207
+ const ANDROID: string;
208
+ const IOS: string;
209
+ const UNKNOWN: string;
210
+ }
211
+ declare class DeviceDetectorService {
212
+ #private;
213
+ userAgent: Nullable<string>;
214
+ constructor();
215
+ isMobile(): boolean;
216
+ isTablet(): boolean;
217
+ isDesktop(): boolean;
218
+ getOS(): string;
219
+ static ɵfac: i0.ɵɵFactoryDeclaration<DeviceDetectorService, never>;
220
+ static ɵprov: i0.ɵɵInjectableDeclaration<DeviceDetectorService>;
221
+ }
222
+
223
+ interface IBreakpoints {
224
+ xl: string;
225
+ lg: string;
226
+ md: string;
227
+ sm: string;
228
+ xs: string;
229
+ }
230
+
231
+ /**
232
+ * A service that manages responsive design breakpoints using Angular's `BreakpointObserver`.
233
+ * This service provides signals for different screen sizes and allows dynamic
234
+ * breakpoint management.
235
+ *
236
+ * @Injectable
237
+ */
238
+ declare class BreakpointService {
239
+ #private;
240
+ readonly isDesktop: Signal<Nullable<boolean>>;
241
+ readonly isSmallDesktop: Signal<Nullable<boolean>>;
242
+ readonly isMobile: Signal<Nullable<boolean>>;
243
+ readonly isTablet: Signal<Nullable<boolean>>;
244
+ readonly isSmallTablet: Signal<Nullable<boolean>>;
245
+ /**
246
+ * Allows setting custom breakpoints for different screen sizes.
247
+ *
248
+ * @param breakpoints - The custom breakpoints to apply.
249
+ */
250
+ setBreakpoints(breakpoints: IBreakpoints): void;
251
+ /**
252
+ * Helper function to decrement the pixel value by 1.
253
+ * Used to exclude the exact pixel value in media queries.
254
+ *
255
+ * @usageNotes
256
+ *
257
+ * This function is useful for setting correct media queries.
258
+ * E.g. for mobile devices: media query should be `(max-width: 599px)`,
259
+ * and from `(min-width: 600px)` it should be considered as a tablet.
260
+ *
261
+ * @param value - The pixel value to decrement.
262
+ * @returns The adjusted pixel value as a string.
263
+ */
264
+ decrementOnePixel(value: string): string;
265
+ static ɵfac: i0.ɵɵFactoryDeclaration<BreakpointService, never>;
266
+ static ɵprov: i0.ɵɵInjectableDeclaration<BreakpointService>;
267
+ }
268
+
269
+ declare class Breakpoints implements IBreakpoints {
270
+ readonly xl: string;
271
+ readonly lg: string;
272
+ readonly md: string;
273
+ readonly sm: string;
274
+ readonly xs: string;
275
+ }
276
+
277
+ declare function checkIsMatchingValues(sample: string): ValidatorFn;
278
+
279
+ declare function arraysNotEmptyValidator(control: AbstractControl): ValidationErrors | null;
280
+
281
+ /**
282
+ * @description Reactive-forms validator over the framework-free `isEmail` predicate.
283
+ *
284
+ * Reports `{ email: true }` on a malformed address. An empty control passes, matching `isEmail` —
285
+ * combine it with `Validators.required` where the field is mandatory.
286
+ */
287
+ declare function emailValidator(control: AbstractControl): ValidationErrors | null;
288
+
289
+ /**
290
+ * Returns a set of dependency injection providers for utility services.
291
+ *
292
+ * @usageNotes
293
+ *
294
+ * This function provides utility services that are commonly used across
295
+ * an Angular application. Specifically, it provides the `BreakpointService`
296
+ * for managing responsive design breakpoints and the `PlatformService` for
297
+ * detecting the platform on which the application is running (e.g., browser or server).
298
+ *
299
+ * ```typescript
300
+ * bootstrapApplication(RootComponent, {
301
+ * providers: [
302
+ * provideRtUtils()
303
+ * ]
304
+ * });
305
+ * ```
306
+ *
307
+ * @publicApi
308
+ */
309
+ declare function provideRtUtils(): Provider[];
310
+
30
311
  declare const WINDOW: InjectionToken<Window>;
31
312
 
313
+ declare const NAVIGATOR: InjectionToken<Navigator>;
314
+
32
315
  interface IDictionary<T> {
33
316
  [Key: string]: T;
34
317
  }
35
318
 
36
- type Nullable<T> = T | undefined | null;
37
-
38
319
  type Primitive = string | number | bigint | boolean | symbol | null | undefined;
39
320
 
40
321
  type IModsObject = Record<string, unknown>;
@@ -363,5 +644,5 @@ declare function provideRtIDBStorage(): Provider[];
363
644
  */
364
645
  declare const IDB_STORAGE_SERVICE_TOKEN: InjectionToken<IDBStorageService<any>>;
365
646
 
366
- export { BlockDirective, CUSTOM_STORAGE, ConcatClassesPipe, ElemDirective, IDBStorageService, IDB_STORAGE_SERVICE_TOKEN, IN_MEMORY_STORAGE, InMemoryStorageService, JsonConverter, LOCAL_STORAGE, MessageBus, ModDirective, PlatformService, SESSION_STORAGE, STORAGE_TYPES_ENUM, StorageService, WINDOW, iDBStorageFactory, inMemoryStorageFactory, isNil, localStorageFactory, provideRtIDBStorage, provideRtStorage, sessionStorageFactory };
367
- export type { IBemConfig, IDictionary, IIDBStorageServiceInterface, IModsObject, IStorageConfig, IStorageConverter, MessageBusEvent, Nullable, Primitive, StorageType };
647
+ export { BlockDirective, BreakStringPipe, BreakpointService, Breakpoints, CUSTOM_STORAGE, ConcatClassesPipe, DeviceDetectorService, ElemDirective, EmptyToDashPipe, EntityToStringPipe, EqualChainPipe, EqualPipe, IDBStorageService, IDB_STORAGE_SERVICE_TOKEN, IN_MEMORY_STORAGE, InMemoryStorageService, IsEmailPipe, JsonConverter, LOCAL_STORAGE, MessageBus, ModDirective, NAVIGATOR, NotEqualChainPipe, NotEqualPipe, OSTypes, OVERLAY_POSITIONS, POSITION_ENUM, PlatformService, RtEscapeKeyDirective, RtIconOutlinedDirective, RtNavigationDirective, RtScrollDirective, RtScrollToElementDirective, RtTabQueryParamDirective, SESSION_STORAGE, STORAGE_TYPES_ENUM, SanitizePipe, StorageService, TernaryPipe, WINDOW, arraysNotEmptyValidator, checkIsMatchingValues, emailValidator, iDBStorageFactory, inMemoryStorageFactory, isHTMLElement, localStorageFactory, provideRtIDBStorage, provideRtStorage, provideRtUtils, sessionStorageFactory };
648
+ export type { IBemConfig, IBreakpoints, IDictionary, IIDBStorageServiceInterface, IModsObject, IStorageConfig, IStorageConverter, MessageBusEvent, Primitive, StorageType };
Binary file