ngx-lift 0.4.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.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -0
  3. package/esm2022/lib/const.mjs +5 -0
  4. package/esm2022/lib/models/async-state.model.mjs +2 -0
  5. package/esm2022/lib/models/index.mjs +2 -0
  6. package/esm2022/lib/operators/combine-latest-eager.operator.mjs +48 -0
  7. package/esm2022/lib/operators/create-async-state.operator.mjs +52 -0
  8. package/esm2022/lib/operators/distinct-on-change.operator.mjs +80 -0
  9. package/esm2022/lib/operators/index.mjs +8 -0
  10. package/esm2022/lib/operators/logger.operator.mjs +21 -0
  11. package/esm2022/lib/operators/poll.operator.mjs +32 -0
  12. package/esm2022/lib/operators/start-with-tap.operator.mjs +15 -0
  13. package/esm2022/lib/operators/switch-map-with-async-state.operator.mjs +33 -0
  14. package/esm2022/lib/pipes/array-join.pipe.mjs +21 -0
  15. package/esm2022/lib/pipes/byte-converter.pipe.mjs +159 -0
  16. package/esm2022/lib/pipes/index.mjs +5 -0
  17. package/esm2022/lib/pipes/is-https.pipe.mjs +18 -0
  18. package/esm2022/lib/pipes/mask.pipe.mjs +36 -0
  19. package/esm2022/lib/utils/form.util.mjs +56 -0
  20. package/esm2022/lib/utils/index.mjs +5 -0
  21. package/esm2022/lib/utils/is-empty.util.mjs +17 -0
  22. package/esm2022/lib/utils/is-equal.util.mjs +24 -0
  23. package/esm2022/lib/utils/pick-by.util.mjs +16 -0
  24. package/esm2022/lib/validators/index.mjs +3 -0
  25. package/esm2022/lib/validators/unique.validator.mjs +64 -0
  26. package/esm2022/lib/validators/url.validator.mjs +14 -0
  27. package/esm2022/ngx-lift.mjs +5 -0
  28. package/esm2022/public-api.mjs +10 -0
  29. package/fesm2022/ngx-lift.mjs +707 -0
  30. package/fesm2022/ngx-lift.mjs.map +1 -0
  31. package/index.d.ts +5 -0
  32. package/lib/const.d.ts +3 -0
  33. package/lib/models/async-state.model.d.ts +22 -0
  34. package/lib/models/index.d.ts +1 -0
  35. package/lib/operators/combine-latest-eager.operator.d.ts +7 -0
  36. package/lib/operators/create-async-state.operator.d.ts +49 -0
  37. package/lib/operators/distinct-on-change.operator.d.ts +55 -0
  38. package/lib/operators/index.d.ts +7 -0
  39. package/lib/operators/logger.operator.d.ts +11 -0
  40. package/lib/operators/poll.operator.d.ts +18 -0
  41. package/lib/operators/start-with-tap.operator.d.ts +10 -0
  42. package/lib/operators/switch-map-with-async-state.operator.d.ts +31 -0
  43. package/lib/pipes/array-join.pipe.d.ts +7 -0
  44. package/lib/pipes/byte-converter.pipe.d.ts +39 -0
  45. package/lib/pipes/index.d.ts +4 -0
  46. package/lib/pipes/is-https.pipe.d.ts +7 -0
  47. package/lib/pipes/mask.pipe.d.ts +19 -0
  48. package/lib/utils/form.util.d.ts +18 -0
  49. package/lib/utils/index.d.ts +4 -0
  50. package/lib/utils/is-empty.util.d.ts +6 -0
  51. package/lib/utils/is-equal.util.d.ts +7 -0
  52. package/lib/utils/pick-by.util.d.ts +7 -0
  53. package/lib/validators/index.d.ts +2 -0
  54. package/lib/validators/unique.validator.d.ts +18 -0
  55. package/lib/validators/url.validator.d.ts +3 -0
  56. package/package.json +28 -0
  57. package/public-api.d.ts +5 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngx-lift.mjs","sources":["../../../projects/ngx-lift/src/lib/operators/combine-latest-eager.operator.ts","../../../projects/ngx-lift/src/lib/operators/create-async-state.operator.ts","../../../projects/ngx-lift/src/lib/operators/distinct-on-change.operator.ts","../../../projects/ngx-lift/src/lib/operators/logger.operator.ts","../../../projects/ngx-lift/src/lib/operators/poll.operator.ts","../../../projects/ngx-lift/src/lib/operators/start-with-tap.operator.ts","../../../projects/ngx-lift/src/lib/operators/switch-map-with-async-state.operator.ts","../../../projects/ngx-lift/src/lib/pipes/array-join.pipe.ts","../../../projects/ngx-lift/src/lib/pipes/byte-converter.pipe.ts","../../../projects/ngx-lift/src/lib/const.ts","../../../projects/ngx-lift/src/lib/pipes/is-https.pipe.ts","../../../projects/ngx-lift/src/lib/pipes/mask.pipe.ts","../../../projects/ngx-lift/src/lib/utils/form.util.ts","../../../projects/ngx-lift/src/lib/utils/is-empty.util.ts","../../../projects/ngx-lift/src/lib/utils/is-equal.util.ts","../../../projects/ngx-lift/src/lib/utils/pick-by.util.ts","../../../projects/ngx-lift/src/lib/validators/unique.validator.ts","../../../projects/ngx-lift/src/lib/validators/url.validator.ts","../../../projects/ngx-lift/src/public-api.ts","../../../projects/ngx-lift/src/ngx-lift.ts"],"sourcesContent":["import {combineLatest, Observable, startWith, Subject} from 'rxjs';\n\nexport function combineLatestEager<T extends Observable<unknown>[]>(\n sources: T,\n startWithNullForAll?: boolean,\n): Observable<{[K in keyof T]: T[K] extends Observable<infer U> ? U | null : never}>;\n\nexport function combineLatestEager<T extends Record<string, Observable<unknown>>>(\n sources: T,\n startWithNullForAll?: boolean,\n): Observable<{[K in keyof T]: T[K] extends Observable<infer U> ? U | null : never}>;\n\n/**\n * Combines multiple observables into a single observable emitting an array or dictionary\n * of the latest values from each source observable.\n * Adds startWith(null) for each Subject in combineLatest when the second parameter startWithNullForAll is false.\n * When startWithNullForAll is true, each observable will startWith null.\n *\n * @template T - The type of the data in the observables.\n *\n * @param {Array<Observable<T>> | Record<string, Observable<T>>} sources -\n * An array of observables or a dictionary of observables to be combined.\n *\n * @param {boolean} [startWithNullForAll=false] -\n * Determines whether to start each observable with a `null` value.\n *\n * @returns {Observable<Array<T | null> | Record<string, T | null>>} -\n * An observable emitting an array or dictionary of the latest values from each source observable.\n *\n * @throws {Error} -\n * Throws an error if the provided argument is not an array of observables or a dictionary of observables.\n */\nexport function combineLatestEager<T>(\n sources: Array<Observable<T>> | Record<string, Observable<T>>,\n startWithNullForAll = false,\n): Observable<Array<T | null> | Record<string, T | null>> {\n function observableMapper<T>(observable: Observable<T>) {\n if (startWithNullForAll) {\n return observable.pipe(startWith(null));\n } else {\n // Check if observable is a Subject, if true, apply startWith(null)\n return observable instanceof Subject ? observable.pipe(startWith(null)) : observable;\n }\n }\n\n if (Array.isArray(sources)) {\n // If sources is an array of observables\n return combineLatest(sources.map(observableMapper));\n } else if (typeof sources === 'object' && sources !== null) {\n // If sources is a dictionary of observables\n const observables: Record<string, Observable<T | null>> = {};\n\n for (const [key, value] of Object.entries(sources)) {\n observables[key] = observableMapper(value);\n }\n\n return combineLatest(observables);\n } else {\n throw new Error(\n `Invalid argument type. Please provide an array of observables or a dictionary of observables. Received: ${typeof sources}`,\n );\n }\n}\n","import {HttpErrorResponse} from '@angular/common/http';\nimport {catchError, map, Observable, of, pipe, startWith, tap, TapObserver, UnaryFunction} from 'rxjs';\n\nimport {AsyncState} from '../models/async-state.model';\n\n/**\n * createAsyncState transforms an Observable of type T into an Observable of AsyncState<T>.\n * AsyncState<T> represents the loading, error, and data states for asynchronous operations.\n *\n * @template T - The type of the data in the observable.\n * @template E - The type of the error that can occur.\n *\n * @param {Partial<Observer<T>> | ((value: T) => void)} [observerOrNextForOrigin] -\n * An optional parameter that can be a partial TapObserver<T> or a function to handle the next value or error in the original Observable.\n *\n * @returns {UnaryFunction<Observable<T>, Observable<AsyncState<T, E>>>} -\n * A function that transforms an observable stream into an asynchronous state.\n *\n * @example\n * Usage 1: Simple request\n * data$ = this.shopService.products$.pipe(\n * createAsyncState({\n * next: res => console.log('Side effect if success: ' + res),\n * error: error => console.error('Side effect if error: ' + error.message)\n * })\n * );\n *\n * Usage 2: Dependent requests\n * data$ = firstCall$.pipe(\n * switchMap(() => this.shopService.products$),\n * createAsyncState()\n * );\n *\n * Another implementation thought when refreshing the data: instead of startWith, `merge of` emit as the trigger\n *\n * subject.pipe(\n * switchMap(() => merge(\n * of({ loading: true, error: null, data: null }),\n * this.service.apiCall().pipe(\n * map(data => ({ loading: false, error: null, data })),\n * tap({\n * next: res => callback?.(res.data),\n * error: err => errorCallback?.(err),\n * }),\n * catchError(error => of({ loading: false, error, data: null })),\n * ),\n * ))\n * )\n *\n */\nexport function createAsyncState<T, E = HttpErrorResponse>(\n observerOrNextForOrigin?: Partial<TapObserver<T>> | ((value: T) => void),\n): UnaryFunction<Observable<T>, Observable<AsyncState<T, E>>> {\n return pipe(\n tap(observerOrNextForOrigin),\n map((data) => ({loading: false, error: null, data})),\n startWith({loading: true, error: null, data: null}),\n // retry(1), // if you want to add retry\n catchError((error: E) => of({loading: false, error, data: null})),\n );\n}\n","import {Observable, OperatorFunction, Subscriber, TeardownLogic} from 'rxjs';\n\n/**\n * Creates an operator function for RxJS Observables that filters out consecutive\n * values that are considered equal according to a provided comparator function,\n * and invokes a callback when a distinct value is encountered.\n *\n * @template T - The type of elements emitted by the observable.\n * @param {(previousValue: T, currentValue: T) => void} onChangeCallback\n * A callback function that will be invoked when a distinct value is encountered.\n * It receives the previous distinct value and the current value.\n * @param {(previousValue: T, currentValue: T) => boolean} [comparator]\n * A function that determines if two values are considered equal.\n * Defaults to a function that performs strict equality (===) comparison.\n * @returns {OperatorFunction<T, T>} - The RxJS operator function.\n *\n * @example\n * Example 1:\n * const source$ = new Observable<number>((observer) => {\n * observer.next(1);\n * observer.next(2);\n * observer.next(2);\n * observer.next(3);\n * observer.next(3);\n * observer.next(4);\n * observer.next(5);\n * observer.complete();\n * });\n *\n * const distinctOnChange$ = source$.pipe(\n * distinctOnChange(\n * (prev, curr) => console.log(`Value changed from ${prev} to: ${curr}`),\n * (prev, curr) => prev === curr,\n * ),\n * );\n * distinctOnChange$.subscribe((res) => console.log(res));\n *\n *\n * Example 2:\n * distinctOnChange<RDEValue<OseInstance>[]>(\n * () => {\n * this.store.dispatch(\n * addToast({\n * toast: {\n * type: ToastType.SUCCESS,\n * title: this.l10nService.getMessage('STATUS_CHANGE'),\n * description: this.l10nService.getMessage('STATUS_CHANGE_DESC'),\n * },\n * }),\n * );\n * },\n * (prev, current) =>\n * prev.every((prevInstance, index) => instanceComparator(prevInstance.entity, current[index].entity)),\n * );\n */\nexport function distinctOnChange<T>(\n onChangeCallback: (previousValue: T, currentValue: T) => void,\n comparator: (previousValue: T, currentValue: T) => boolean = (prev, curr) => prev === curr,\n): OperatorFunction<T, T> {\n return (source: Observable<T>) =>\n new Observable<T>((subscriber: Subscriber<T>): TeardownLogic => {\n let hasFirstValue = false;\n let previousValue: T;\n\n const subscription = source.subscribe({\n next: (currentValue: T) => {\n if (hasFirstValue) {\n if (!comparator(previousValue, currentValue)) {\n onChangeCallback(previousValue, currentValue);\n previousValue = currentValue;\n subscriber.next(currentValue);\n }\n } else {\n previousValue = currentValue;\n hasFirstValue = true;\n subscriber.next(currentValue);\n }\n },\n error: (err: unknown) => subscriber.error(err),\n complete: () => subscriber.complete(),\n });\n\n return () => subscription.unsubscribe();\n });\n}\n","import {OperatorFunction, pipe, tap} from 'rxjs';\n\n// Define a type for different logger functions\ntype LoggerType = 'count' | 'debug' | 'dir' | 'log' | 'table';\n\n// Define a more permissive type for console functions\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ConsoleFunction = (...args: any[]) => void;\n\n// Map each LoggerType to its corresponding console function\nconst loggerFunctions: Record<LoggerType, ConsoleFunction> = {\n count: console.count.bind(console),\n debug: console.debug.bind(console),\n dir: console.dir.bind(console),\n log: console.log.bind(console),\n table: console.table.bind(console),\n};\n\n/**\n * Logger operator for RxJS observables.\n *\n * @param loggerType The type of logger to be used: 'count', 'debug', 'dir', 'log', 'table'.\n * Defaults to 'log' if not provided or if an unknown type is specified.\n * @returns An RxJS operator function that logs values using the specified console function.\n */\nexport const logger = <T>(loggerType: LoggerType = 'log'): OperatorFunction<T, T> =>\n pipe(\n tap((value: T) => {\n const logFunction = loggerFunctions[loggerType] || console.log.bind(console);\n logFunction(value);\n }),\n );\n","import {catchError, EMPTY, exhaustMap, map, merge, Observable, of, share, startWith, timer} from 'rxjs';\n\nimport {AsyncState} from '../models';\n\n/**\n * Polls the API at a specified interval, handling the triggering of requests and building parameters.\n *\n * @param {Object} options - The options object containing interval, apiCall, paramsBuilder, and trigger\n * @param {number} options.interval - The interval at which to poll the API\n * @param {(params: Record<string, unknown>) => Observable<Data>} options.apiCall - The function to call the API\n * @param {(input: Input | null) => Record<string, unknown>} [options.paramsBuilder] - The function to build parameters based on input\n * @param {Observable<Input>} [options.trigger] - The trigger observable for initiating requests\n * @return {Observable<AsyncState<Data>>} An observable emitting the async state of the API data\n */\nexport function poll<Data, Input>(options: {\n interval: number;\n apiCall: (params: Record<string, unknown>) => Observable<Data>;\n paramsBuilder?: (input: Input | null) => Record<string, unknown>;\n trigger?: Observable<Input>;\n}): Observable<AsyncState<Data>> {\n let latestInput: Input | null = null;\n\n return merge(options.trigger || EMPTY, timer(0, options.interval)).pipe(\n exhaustMap((input) => {\n let params: Record<string, unknown> = {};\n\n const triggeredByObservable = typeof input !== 'number';\n if (triggeredByObservable) {\n latestInput = input;\n }\n if (options.paramsBuilder) {\n params = options.paramsBuilder(latestInput);\n }\n\n const isFirstRequest = input === 0;\n const shouldShowLoading = triggeredByObservable || isFirstRequest;\n\n let observable = options.apiCall(params).pipe(\n map((data) => ({loading: false, error: null, data})),\n catchError((error) => of({loading: false, error, data: null})),\n );\n\n if (shouldShowLoading) {\n observable = observable.pipe(startWith({loading: true, error: null, data: null}));\n }\n\n return observable;\n }),\n share(),\n );\n}\n","import {Observable} from 'rxjs';\n\n/**\n * Operator that taps into a callback before the source Observable starts emitting values.\n *\n * This operator is useful for triggering a side effect before the main Observable starts emitting.\n *\n * @param callback A function to be executed before the source Observable emits its first value.\n * @returns An RxJS operator function that taps into the callback and then switchMaps to the source Observable.\n */\nexport function startWithTap<T>(callback: () => void) {\n return (source: Observable<T>) => {\n callback();\n return source;\n };\n}\n","import {HttpErrorResponse} from '@angular/common/http';\nimport {Observable, OperatorFunction, switchMap} from 'rxjs';\n\nimport {AsyncState} from '../models';\nimport {createAsyncState} from './create-async-state.operator';\n\n/**\n * Custom RxJS operator that uses switchMap to handle asynchronous operations and\n * transforms the emitted values into an AsyncState object.\n *\n * @template T - The type of data emitted by the observable returned by the project.\n * @template K - The type of value emitted by the source observable.\n * @template E - The type of error that can be encountered during the asynchronous operation.\n *\n * @param {function(K): Observable<T>} project - A function that takes a value emitted by the source\n * observable and returns an observable representing an asynchronous operation.\n *\n * @returns {OperatorFunction<K, AsyncState<T, E>>} - An RxJS operator that transforms the source observable into\n * an observable of AsyncState objects.\n *\n * @example\n * // Usage of the switchMapWithAsyncState operator\n * const source$ = new BehaviorSubject<number>(1);\n *\n * const asyncOperation = (value: number) => {\n * return of(value * 2).pipe(delay(1000));\n * };\n *\n * const result$ = source$.pipe(switchMapWithAsyncState(asyncOperation));\n * result$.subscribe((state) => {\n * console.log(state); // Outputs AsyncState objects with loading, data, and error properties.\n * });\n */\nexport function switchMapWithAsyncState<T, K, E = HttpErrorResponse>(\n project: (value: K, index: number) => Observable<T>,\n): OperatorFunction<K, AsyncState<T, E>> {\n return (source: Observable<K>) =>\n source.pipe(switchMap((value, index) => project(value, index).pipe(createAsyncState<T, E>())));\n}\n","import {Pipe, PipeTransform} from '@angular/core';\n\n@Pipe({\n name: 'arrayJoin',\n standalone: true,\n})\nexport class ArrayJoinPipe implements PipeTransform {\n transform(value: unknown, separator: string = ',') {\n if (Array.isArray(value)) {\n return value.join(separator);\n }\n\n // For non-array cases or unexpected types, return the value as is\n return value;\n }\n}\n","import {Inject, LOCALE_ID, Pipe, PipeTransform} from '@angular/core';\n\n/**\n * import { LOCALE_ID, NgModule } from '@angular/core';\n * import { BrowserModule } from '@angular/platform-browser';\n * import { AppComponent } from './app.component';\n * import { registerLocaleData } from '@angular/common';\n *\n * import localeEn from '@angular/common/locales/en';\n * import localeFr from '@angular/common/locales/fr';\n *\n * // Register locales\n * registerLocaleData(localeEn);\n * registerLocaleData(localeFr);\n *\n * @NgModule({\n * declarations: [AppComponent],\n * imports: [BrowserModule],\n * providers: [\n * {\n * provide: LOCALE_ID,\n * useFactory: () => {\n * // Use the browser's language or a default language\n * return navigator.language || 'en';\n * },\n * },\n * ],\n * bootstrap: [AppComponent],\n * })\n * export class AppModule {}\n */\n\n@Pipe({\n name: 'byteConverter',\n standalone: true,\n})\nexport class ByteConverterPipe implements PipeTransform {\n constructor(@Inject(LOCALE_ID) private locale: string) {}\n\n // If using navigator.language directly in the pipe, this approach directly uses the browser's language at the moment the ByteConverterPipe is constructed. If the user changes the language while using the application, it won't be automatically reflected. If dynamic language changes are a requirement, using the LOCALE_ID provider as demonstrated in the AppModule is a more Angular-centric approach.\n // private locale: string;\n // constructor() {\n // // Use navigator.language as the default locale\n // this.locale = navigator.language || 'en';\n // }\n\n transform(value: number): string {\n if (value === null || value === undefined || isNaN(value)) {\n return '-';\n }\n\n const units = ['BYTE', 'KB', 'MB', 'GB', 'TB'];\n let unitIndex = 0;\n\n while (value >= 1024 && unitIndex < units.length - 1) {\n value /= 1024;\n unitIndex++;\n }\n\n const translationObject = translations[this.locale] || translations['en'];\n const key = units[unitIndex];\n\n return this.formatNumber(value) + ' ' + translationObject[key];\n }\n\n private formatNumber(value: number): string {\n return new Intl.NumberFormat(this.locale, {maximumFractionDigits: 2}).format(value);\n }\n}\n\nconst translations: Record<string, Record<string, string>> = {\n en: {\n BYTE: 'B',\n KB: 'KB',\n MB: 'MB',\n GB: 'GB',\n TB: 'TB',\n },\n 'en-US': {\n // You can provide specific variations for en-US if needed\n BYTE: 'B',\n KB: 'KB',\n MB: 'MB',\n GB: 'GB',\n TB: 'TB',\n },\n de: {\n BYTE: 'B',\n KB: 'KB',\n MB: 'MB',\n GB: 'GB',\n TB: 'TB',\n },\n es: {\n BYTE: 'B',\n KB: 'KB',\n MB: 'MB',\n GB: 'GB',\n TB: 'TB',\n },\n fr: {\n BYTE: 'o',\n KB: 'Ko',\n MB: 'Mo',\n GB: 'Go',\n TB: 'To',\n },\n it: {\n BYTE: 'B',\n KB: 'KB',\n MB: 'MB',\n GB: 'GB',\n TB: 'TB',\n },\n ja: {\n BYTE: 'B',\n KB: 'KB',\n MB: 'MB',\n GB: 'GB',\n TB: 'TB',\n },\n ko: {\n BYTE: 'B',\n KB: 'KB',\n MB: 'MB',\n GB: 'GB',\n TB: 'TB',\n },\n 'pt-BR': {\n BYTE: 'B',\n KB: 'KB',\n MB: 'MB',\n GB: 'GB',\n TB: 'TB',\n },\n 'zh-CN': {\n BYTE: '字节',\n KB: '千字节',\n MB: '兆字节',\n GB: '千兆字节',\n TB: '太字节',\n },\n 'zh-TW': {\n BYTE: '位元組',\n KB: '千位元組',\n MB: '兆位元組',\n GB: '千兆位元組',\n TB: '太位元組',\n },\n ru: {\n BYTE: 'Б',\n KB: 'КБ',\n MB: 'МБ',\n GB: 'ГБ',\n TB: 'ТБ',\n },\n};\n","// https://regex101.com/library/mX1xW0\nexport const emailPattern = /^([\\w-]+(?:\\.[\\w-]+)*)@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$/;\n\nexport const urlPattern =\n /^https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$/;\nexport const httpsPattern =\n /^https:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$/;\n","import {Pipe, PipeTransform} from '@angular/core';\n\nimport {httpsPattern} from '../const';\n\n@Pipe({\n name: 'isHttps',\n standalone: true,\n})\nexport class IsHttpsPipe implements PipeTransform {\n transform(value: string): boolean {\n return httpsPattern.test(value);\n }\n}\n","import {Pipe, PipeTransform} from '@angular/core';\n\nconst unmaskNumber = 6;\nconst maskChar = '*';\n\nexport interface MaskOptions {\n unmaskedPrefixLength?: number;\n unmaskedSuffixLength?: number;\n masked?: boolean;\n}\n\n@Pipe({\n name: 'mask',\n standalone: true,\n})\nexport class MaskPipe implements PipeTransform {\n /**\n * Transforms the input string by masking characters based on the provided options.\n *\n * @param {string} value - The input string to be masked.\n * @param {MaskOptions} [options={}] - Options for customizing the masking behavior.\n * @returns {string} - The masked string.\n */\n transform(value: string, options: MaskOptions = {}): string {\n const {unmaskedPrefixLength = unmaskNumber, unmaskedSuffixLength = unmaskNumber, masked = true} = options;\n\n if (\n value.length <= unmaskedPrefixLength + unmaskedSuffixLength ||\n unmaskedPrefixLength < 0 ||\n unmaskedSuffixLength < 0 ||\n !masked\n ) {\n return value;\n }\n\n return value\n .split('')\n .map((char, i) => (i < unmaskedPrefixLength || i > value.length - unmaskedSuffixLength - 1 ? char : maskChar))\n .join('');\n }\n}\n","import {AbstractControl, AsyncValidatorFn, ValidatorFn, Validators} from '@angular/forms';\nimport {of} from 'rxjs';\n\n/**\n * Provides a conditional validator that applies the specified validator functions only if the condition is met.\n *\n * @param condition A function that determines whether the validators should be applied.\n * @param trueValidatorFn The validator function or an array of validator functions to be applied when the condition is true.\n * @param falseValidatorFn Optional. The validator function or an array of validator functions to be applied when the condition is false.\n * @returns A validator function that can be used with Angular Reactive Forms.\n */\nexport function ifValidator(\n condition: (control: AbstractControl) => boolean,\n trueValidatorFn: ValidatorFn | ValidatorFn[],\n falseValidatorFn?: ValidatorFn | ValidatorFn[],\n): ValidatorFn {\n /**\n * @param control The AbstractControl to validate.\n * @returns Validation errors if the condition is met; otherwise, null.\n */\n return (control: AbstractControl): Validators | null => {\n if (!trueValidatorFn || !condition(control)) {\n return composeValidators(control, falseValidatorFn);\n }\n\n return composeValidators(control, trueValidatorFn);\n };\n}\n\n/**\n * Provides a conditional async validator that applies the specified async validator function only if the condition is met.\n *\n * @param condition A function that determines whether the async validator should be applied.\n * @param validatorFn The async validator function to be applied conditionally.\n * @returns An async validator function that can be used with Angular Reactive Forms.\n */\nexport function ifAsyncValidator(\n condition: (control: AbstractControl) => boolean,\n validatorFn: AsyncValidatorFn,\n): AsyncValidatorFn {\n /**\n * @param control The AbstractControl to validate asynchronously.\n * @returns An observable that emits validation errors if the condition is met; otherwise, emits null.\n */\n return (control: AbstractControl) => {\n if (!validatorFn || !condition(control)) {\n return of(null);\n }\n\n return validatorFn(control);\n };\n}\n\n/**\n * Composes and applies the provided validators to the given AbstractControl.\n *\n * @param control The AbstractControl to validate.\n * @param validatorFn The validator function or an array of validator functions to be applied.\n * @returns Validation errors if the validators are applicable; otherwise, null.\n */\nfunction composeValidators(\n control: AbstractControl,\n validatorFn: ValidatorFn | ValidatorFn[] | undefined,\n): Validators | null {\n if (!validatorFn) {\n return null;\n }\n\n const validatorFns = Array.isArray(validatorFn) ? validatorFn : [validatorFn];\n return Validators.compose(validatorFns)?.(control) || null;\n}\n","/**\n * Check if a value is empty.\n * @param {T | undefined | null} value - The value to check for emptiness.\n * @returns {boolean} - Returns true if the value is empty, otherwise false.\n */\nexport function isEmpty<T extends object | string | Array<unknown>>(value: T | undefined | null): value is null {\n if (value == null) return true;\n\n if (typeof value === 'string' || Array.isArray(value)) {\n return value.length === 0;\n }\n\n if (typeof value === 'object') {\n return Object.keys(value as Record<string, unknown>).length === 0;\n }\n\n return false;\n}\n","/**\n * Check if two values are deeply equal.\n * @param {T} value1 - The first value to compare.\n * @param {T} value2 - The second value to compare.\n * @returns {boolean} - Returns true if the values are deeply equal, otherwise false.\n */\nexport function isEqual<T>(value1: T, value2: T): boolean {\n if (value1 === value2) return true;\n\n if (typeof value1 !== 'object' || typeof value2 !== 'object' || value1 === null || value2 === null) {\n return false;\n }\n\n const keys1 = Object.keys(value1) as Array<keyof T>;\n const keys2 = Object.keys(value2) as Array<keyof T>;\n\n if (keys1.length !== keys2.length) return false;\n\n for (const key of keys1) {\n if (!keys2.includes(key) || !isEqual(value1[key], value2[key])) {\n return false;\n }\n }\n\n return true;\n}\n","/**\n * Create an object composed of object properties that satisfy a given condition.\n * @param {T} source - The object to pick properties from.\n * @param {(value: T[keyof T], key: string) => boolean} predicate - The function invoked per property.\n * @returns {Partial<T>} - Returns the new object.\n */\nexport function pickBy<T>(source: T, predicate: (value: T[keyof T], key: string) => boolean): Partial<T> {\n const result: Partial<T> = {};\n\n for (const key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key) && predicate(source[key], key)) {\n result[key] = source[key];\n }\n }\n\n return result;\n}\n","import {AbstractControl, FormArray, ValidationErrors, ValidatorFn} from '@angular/forms';\n\n/**\n * Validator for checking uniqueness across multiple fields in a FormArray or FormGroup.\n *\n * This validator can be applied to a FormArray or FormGroup containing the controls to be validated.\n * It ensures that each control's value is unique among all other controls within the array or group.\n */\nexport class UniqueValidator {\n /**\n * Validator function to be attached to a FormArray or FormGroup.\n *\n * This validator checks for uniqueness of each control's value within the array or group.\n *\n * @param keySelector A function to select the key control for comparison (default is the control itself).\n * @typeparam T The type of the control value.\n */\n static unique<T>(\n keySelector: (control: AbstractControl) => AbstractControl<T> = (control: AbstractControl<T>) => control,\n ): ValidatorFn {\n return (formArray: AbstractControl): ValidationErrors | null => {\n if (!(formArray instanceof FormArray)) {\n return null;\n }\n\n const targetControls = formArray.controls.map(keySelector);\n const valueControlMap = new Map<T, AbstractControl<T>>();\n const invalidControls: AbstractControl<T>[] = [];\n\n for (const control of targetControls) {\n const value = control.value;\n\n if (value == null || String(value) === '' || String(value) === 'NaN') {\n continue;\n }\n\n const controlInMap = valueControlMap.get(value);\n\n if (controlInMap) {\n if (!invalidControls.includes(controlInMap)) {\n invalidControls.push(controlInMap);\n }\n\n invalidControls.push(control);\n } else {\n valueControlMap.set(value, control);\n }\n }\n\n const notUniqueError = {notUnique: true};\n\n // set errors manually for target controls\n for (const control of targetControls) {\n const errors = control.errors;\n\n if (invalidControls.includes(control)) {\n // set not unique error for invalid controls\n control.setErrors(errors === null ? notUniqueError : {...errors, ...notUniqueError});\n } else {\n // remove not unique errors for valid controls\n if (errors === null) {\n control.setErrors(null);\n } else {\n delete errors['notUnique'];\n control.setErrors(Object.keys(errors).length > 0 ? errors : null);\n }\n }\n }\n\n return invalidControls.length > 0 ? notUniqueError : null;\n };\n }\n}\n","import {AbstractControl, ValidationErrors} from '@angular/forms';\n\nimport {httpsPattern, urlPattern} from '../const';\n\nexport function urlValidator(control: AbstractControl): ValidationErrors | null {\n if (!urlPattern.test(control.value)) {\n return {invalidUrl: true};\n }\n return null;\n}\n\nexport function httpsValidator(control: AbstractControl): ValidationErrors | null {\n if (!httpsPattern.test(control.value)) {\n return {invalidUrl: true};\n }\n return null;\n}\n","/*\n * Public API Surface of ngx-lift\n */\n\nexport * from './lib/models';\nexport * from './lib/operators';\nexport * from './lib/pipes';\nexport * from './lib/utils';\nexport * from './lib/validators';\n// export * from './lib/signals';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAYA;;;;;;;;;;;;;;;;;;;AAmBG;SACa,kBAAkB,CAChC,OAA6D,EAC7D,mBAAmB,GAAG,KAAK,EAAA;IAE3B,SAAS,gBAAgB,CAAI,UAAyB,EAAA;AACpD,QAAA,IAAI,mBAAmB,EAAE;YACvB,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AACzC,SAAA;AAAM,aAAA;;AAEL,YAAA,OAAO,UAAU,YAAY,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC;AACtF,SAAA;KACF;AAED,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;;QAE1B,OAAO,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACrD,KAAA;SAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE;;QAE1D,MAAM,WAAW,GAAyC,EAAE,CAAC;AAE7D,QAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAClD,WAAW,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;AAC5C,SAAA;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CAAC,CAAC;AACnE,qBAAA;AACF,iBAAA;AACF,aAAA;AAED,YAAA,OAAO,eAAe,CAAC,MAAM,GAAG,CAAC,GAAG,cAAc,GAAG,IAAI,CAAC;AAC5D,SAAC,CAAC;KACH;AACF;;ACpEK,SAAU,YAAY,CAAC,OAAwB,EAAA;IACnD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACnC,QAAA,OAAO,EAAC,UAAU,EAAE,IAAI,EAAC,CAAC;AAC3B,KAAA;AACD,IAAA,OAAO,IAAI,CAAC;AACd,CAAC;AAEK,SAAU,cAAc,CAAC,OAAwB,EAAA;IACrD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACrC,QAAA,OAAO,EAAC,UAAU,EAAE,IAAI,EAAC,CAAC;AAC3B,KAAA;AACD,IAAA,OAAO,IAAI,CAAC;AACd;;AChBA;;AAEG;AAOH;;ACTA;;AAEG;;;;"}
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ /// <amd-module name="ngx-lift" />
5
+ export * from './public-api';
package/lib/const.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare const emailPattern: RegExp;
2
+ export declare const urlPattern: RegExp;
3
+ export declare const httpsPattern: RegExp;
@@ -0,0 +1,22 @@
1
+ import { HttpErrorResponse } from '@angular/common/http';
2
+ /**
3
+ * Represents the state of an asynchronous operation, including loading, error, and data.
4
+ * @template T - The type of the data in the response.
5
+ * @template E - The type of the error response, defaulting to `HttpErrorResponse`.
6
+ */
7
+ export interface AsyncState<T, E = HttpErrorResponse> {
8
+ /**
9
+ * Indicates whether the asynchronous operation is in progress.
10
+ */
11
+ loading: boolean;
12
+ /**
13
+ * Represents any error that occurred during the asynchronous operation.
14
+ * Null if no error occurred.
15
+ */
16
+ error: E | null;
17
+ /**
18
+ * The data resulting from the asynchronous operation.
19
+ * Null if the operation has not completed successfully.
20
+ */
21
+ data: T | null;
22
+ }
@@ -0,0 +1 @@
1
+ export * from './async-state.model';
@@ -0,0 +1,7 @@
1
+ import { Observable } from 'rxjs';
2
+ export declare function combineLatestEager<T extends Observable<unknown>[]>(sources: T, startWithNullForAll?: boolean): Observable<{
3
+ [K in keyof T]: T[K] extends Observable<infer U> ? U | null : never;
4
+ }>;
5
+ export declare function combineLatestEager<T extends Record<string, Observable<unknown>>>(sources: T, startWithNullForAll?: boolean): Observable<{
6
+ [K in keyof T]: T[K] extends Observable<infer U> ? U | null : never;
7
+ }>;
@@ -0,0 +1,49 @@
1
+ import { HttpErrorResponse } from '@angular/common/http';
2
+ import { Observable, TapObserver, UnaryFunction } from 'rxjs';
3
+ import { AsyncState } from '../models/async-state.model';
4
+ /**
5
+ * createAsyncState transforms an Observable of type T into an Observable of AsyncState<T>.
6
+ * AsyncState<T> represents the loading, error, and data states for asynchronous operations.
7
+ *
8
+ * @template T - The type of the data in the observable.
9
+ * @template E - The type of the error that can occur.
10
+ *
11
+ * @param {Partial<Observer<T>> | ((value: T) => void)} [observerOrNextForOrigin] -
12
+ * An optional parameter that can be a partial TapObserver<T> or a function to handle the next value or error in the original Observable.
13
+ *
14
+ * @returns {UnaryFunction<Observable<T>, Observable<AsyncState<T, E>>>} -
15
+ * A function that transforms an observable stream into an asynchronous state.
16
+ *
17
+ * @example
18
+ * Usage 1: Simple request
19
+ * data$ = this.shopService.products$.pipe(
20
+ * createAsyncState({
21
+ * next: res => console.log('Side effect if success: ' + res),
22
+ * error: error => console.error('Side effect if error: ' + error.message)
23
+ * })
24
+ * );
25
+ *
26
+ * Usage 2: Dependent requests
27
+ * data$ = firstCall$.pipe(
28
+ * switchMap(() => this.shopService.products$),
29
+ * createAsyncState()
30
+ * );
31
+ *
32
+ * Another implementation thought when refreshing the data: instead of startWith, `merge of` emit as the trigger
33
+ *
34
+ * subject.pipe(
35
+ * switchMap(() => merge(
36
+ * of({ loading: true, error: null, data: null }),
37
+ * this.service.apiCall().pipe(
38
+ * map(data => ({ loading: false, error: null, data })),
39
+ * tap({
40
+ * next: res => callback?.(res.data),
41
+ * error: err => errorCallback?.(err),
42
+ * }),
43
+ * catchError(error => of({ loading: false, error, data: null })),
44
+ * ),
45
+ * ))
46
+ * )
47
+ *
48
+ */
49
+ export declare function createAsyncState<T, E = HttpErrorResponse>(observerOrNextForOrigin?: Partial<TapObserver<T>> | ((value: T) => void)): UnaryFunction<Observable<T>, Observable<AsyncState<T, E>>>;
@@ -0,0 +1,55 @@
1
+ import { OperatorFunction } from 'rxjs';
2
+ /**
3
+ * Creates an operator function for RxJS Observables that filters out consecutive
4
+ * values that are considered equal according to a provided comparator function,
5
+ * and invokes a callback when a distinct value is encountered.
6
+ *
7
+ * @template T - The type of elements emitted by the observable.
8
+ * @param {(previousValue: T, currentValue: T) => void} onChangeCallback
9
+ * A callback function that will be invoked when a distinct value is encountered.
10
+ * It receives the previous distinct value and the current value.
11
+ * @param {(previousValue: T, currentValue: T) => boolean} [comparator]
12
+ * A function that determines if two values are considered equal.
13
+ * Defaults to a function that performs strict equality (===) comparison.
14
+ * @returns {OperatorFunction<T, T>} - The RxJS operator function.
15
+ *
16
+ * @example
17
+ * Example 1:
18
+ * const source$ = new Observable<number>((observer) => {
19
+ * observer.next(1);
20
+ * observer.next(2);
21
+ * observer.next(2);
22
+ * observer.next(3);
23
+ * observer.next(3);
24
+ * observer.next(4);
25
+ * observer.next(5);
26
+ * observer.complete();
27
+ * });
28
+ *
29
+ * const distinctOnChange$ = source$.pipe(
30
+ * distinctOnChange(
31
+ * (prev, curr) => console.log(`Value changed from ${prev} to: ${curr}`),
32
+ * (prev, curr) => prev === curr,
33
+ * ),
34
+ * );
35
+ * distinctOnChange$.subscribe((res) => console.log(res));
36
+ *
37
+ *
38
+ * Example 2:
39
+ * distinctOnChange<RDEValue<OseInstance>[]>(
40
+ * () => {
41
+ * this.store.dispatch(
42
+ * addToast({
43
+ * toast: {
44
+ * type: ToastType.SUCCESS,
45
+ * title: this.l10nService.getMessage('STATUS_CHANGE'),
46
+ * description: this.l10nService.getMessage('STATUS_CHANGE_DESC'),
47
+ * },
48
+ * }),
49
+ * );
50
+ * },
51
+ * (prev, current) =>
52
+ * prev.every((prevInstance, index) => instanceComparator(prevInstance.entity, current[index].entity)),
53
+ * );
54
+ */
55
+ export declare function distinctOnChange<T>(onChangeCallback: (previousValue: T, currentValue: T) => void, comparator?: (previousValue: T, currentValue: T) => boolean): OperatorFunction<T, T>;
@@ -0,0 +1,7 @@
1
+ export * from './combine-latest-eager.operator';
2
+ export * from './create-async-state.operator';
3
+ export * from './distinct-on-change.operator';
4
+ export * from './logger.operator';
5
+ export * from './poll.operator';
6
+ export * from './start-with-tap.operator';
7
+ export * from './switch-map-with-async-state.operator';
@@ -0,0 +1,11 @@
1
+ import { OperatorFunction } from 'rxjs';
2
+ type LoggerType = 'count' | 'debug' | 'dir' | 'log' | 'table';
3
+ /**
4
+ * Logger operator for RxJS observables.
5
+ *
6
+ * @param loggerType The type of logger to be used: 'count', 'debug', 'dir', 'log', 'table'.
7
+ * Defaults to 'log' if not provided or if an unknown type is specified.
8
+ * @returns An RxJS operator function that logs values using the specified console function.
9
+ */
10
+ export declare const logger: <T>(loggerType?: LoggerType) => OperatorFunction<T, T>;
11
+ export {};
@@ -0,0 +1,18 @@
1
+ import { Observable } from 'rxjs';
2
+ import { AsyncState } from '../models';
3
+ /**
4
+ * Polls the API at a specified interval, handling the triggering of requests and building parameters.
5
+ *
6
+ * @param {Object} options - The options object containing interval, apiCall, paramsBuilder, and trigger
7
+ * @param {number} options.interval - The interval at which to poll the API
8
+ * @param {(params: Record<string, unknown>) => Observable<Data>} options.apiCall - The function to call the API
9
+ * @param {(input: Input | null) => Record<string, unknown>} [options.paramsBuilder] - The function to build parameters based on input
10
+ * @param {Observable<Input>} [options.trigger] - The trigger observable for initiating requests
11
+ * @return {Observable<AsyncState<Data>>} An observable emitting the async state of the API data
12
+ */
13
+ export declare function poll<Data, Input>(options: {
14
+ interval: number;
15
+ apiCall: (params: Record<string, unknown>) => Observable<Data>;
16
+ paramsBuilder?: (input: Input | null) => Record<string, unknown>;
17
+ trigger?: Observable<Input>;
18
+ }): Observable<AsyncState<Data>>;
@@ -0,0 +1,10 @@
1
+ import { Observable } from 'rxjs';
2
+ /**
3
+ * Operator that taps into a callback before the source Observable starts emitting values.
4
+ *
5
+ * This operator is useful for triggering a side effect before the main Observable starts emitting.
6
+ *
7
+ * @param callback A function to be executed before the source Observable emits its first value.
8
+ * @returns An RxJS operator function that taps into the callback and then switchMaps to the source Observable.
9
+ */
10
+ export declare function startWithTap<T>(callback: () => void): (source: Observable<T>) => Observable<T>;
@@ -0,0 +1,31 @@
1
+ import { HttpErrorResponse } from '@angular/common/http';
2
+ import { Observable, OperatorFunction } from 'rxjs';
3
+ import { AsyncState } from '../models';
4
+ /**
5
+ * Custom RxJS operator that uses switchMap to handle asynchronous operations and
6
+ * transforms the emitted values into an AsyncState object.
7
+ *
8
+ * @template T - The type of data emitted by the observable returned by the project.
9
+ * @template K - The type of value emitted by the source observable.
10
+ * @template E - The type of error that can be encountered during the asynchronous operation.
11
+ *
12
+ * @param {function(K): Observable<T>} project - A function that takes a value emitted by the source
13
+ * observable and returns an observable representing an asynchronous operation.
14
+ *
15
+ * @returns {OperatorFunction<K, AsyncState<T, E>>} - An RxJS operator that transforms the source observable into
16
+ * an observable of AsyncState objects.
17
+ *
18
+ * @example
19
+ * // Usage of the switchMapWithAsyncState operator
20
+ * const source$ = new BehaviorSubject<number>(1);
21
+ *
22
+ * const asyncOperation = (value: number) => {
23
+ * return of(value * 2).pipe(delay(1000));
24
+ * };
25
+ *
26
+ * const result$ = source$.pipe(switchMapWithAsyncState(asyncOperation));
27
+ * result$.subscribe((state) => {
28
+ * console.log(state); // Outputs AsyncState objects with loading, data, and error properties.
29
+ * });
30
+ */
31
+ export declare function switchMapWithAsyncState<T, K, E = HttpErrorResponse>(project: (value: K, index: number) => Observable<T>): OperatorFunction<K, AsyncState<T, E>>;
@@ -0,0 +1,7 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class ArrayJoinPipe implements PipeTransform {
4
+ transform(value: unknown, separator?: string): unknown;
5
+ static ɵfac: i0.ɵɵFactoryDeclaration<ArrayJoinPipe, never>;
6
+ static ɵpipe: i0.ɵɵPipeDeclaration<ArrayJoinPipe, "arrayJoin", true>;
7
+ }
@@ -0,0 +1,39 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * import { LOCALE_ID, NgModule } from '@angular/core';
5
+ * import { BrowserModule } from '@angular/platform-browser';
6
+ * import { AppComponent } from './app.component';
7
+ * import { registerLocaleData } from '@angular/common';
8
+ *
9
+ * import localeEn from '@angular/common/locales/en';
10
+ * import localeFr from '@angular/common/locales/fr';
11
+ *
12
+ * // Register locales
13
+ * registerLocaleData(localeEn);
14
+ * registerLocaleData(localeFr);
15
+ *
16
+ * @NgModule({
17
+ * declarations: [AppComponent],
18
+ * imports: [BrowserModule],
19
+ * providers: [
20
+ * {
21
+ * provide: LOCALE_ID,
22
+ * useFactory: () => {
23
+ * // Use the browser's language or a default language
24
+ * return navigator.language || 'en';
25
+ * },
26
+ * },
27
+ * ],
28
+ * bootstrap: [AppComponent],
29
+ * })
30
+ * export class AppModule {}
31
+ */
32
+ export declare class ByteConverterPipe implements PipeTransform {
33
+ private locale;
34
+ constructor(locale: string);
35
+ transform(value: number): string;
36
+ private formatNumber;
37
+ static ɵfac: i0.ɵɵFactoryDeclaration<ByteConverterPipe, never>;
38
+ static ɵpipe: i0.ɵɵPipeDeclaration<ByteConverterPipe, "byteConverter", true>;
39
+ }
@@ -0,0 +1,4 @@
1
+ export * from './array-join.pipe';
2
+ export * from './byte-converter.pipe';
3
+ export * from './is-https.pipe';
4
+ export * from './mask.pipe';
@@ -0,0 +1,7 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class IsHttpsPipe implements PipeTransform {
4
+ transform(value: string): boolean;
5
+ static ɵfac: i0.ɵɵFactoryDeclaration<IsHttpsPipe, never>;
6
+ static ɵpipe: i0.ɵɵPipeDeclaration<IsHttpsPipe, "isHttps", true>;
7
+ }
@@ -0,0 +1,19 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export interface MaskOptions {
4
+ unmaskedPrefixLength?: number;
5
+ unmaskedSuffixLength?: number;
6
+ masked?: boolean;
7
+ }
8
+ export declare class MaskPipe implements PipeTransform {
9
+ /**
10
+ * Transforms the input string by masking characters based on the provided options.
11
+ *
12
+ * @param {string} value - The input string to be masked.
13
+ * @param {MaskOptions} [options={}] - Options for customizing the masking behavior.
14
+ * @returns {string} - The masked string.
15
+ */
16
+ transform(value: string, options?: MaskOptions): string;
17
+ static ɵfac: i0.ɵɵFactoryDeclaration<MaskPipe, never>;
18
+ static ɵpipe: i0.ɵɵPipeDeclaration<MaskPipe, "mask", true>;
19
+ }
@@ -0,0 +1,18 @@
1
+ import { AbstractControl, AsyncValidatorFn, ValidatorFn } from '@angular/forms';
2
+ /**
3
+ * Provides a conditional validator that applies the specified validator functions only if the condition is met.
4
+ *
5
+ * @param condition A function that determines whether the validators should be applied.
6
+ * @param trueValidatorFn The validator function or an array of validator functions to be applied when the condition is true.
7
+ * @param falseValidatorFn Optional. The validator function or an array of validator functions to be applied when the condition is false.
8
+ * @returns A validator function that can be used with Angular Reactive Forms.
9
+ */
10
+ export declare function ifValidator(condition: (control: AbstractControl) => boolean, trueValidatorFn: ValidatorFn | ValidatorFn[], falseValidatorFn?: ValidatorFn | ValidatorFn[]): ValidatorFn;
11
+ /**
12
+ * Provides a conditional async validator that applies the specified async validator function only if the condition is met.
13
+ *
14
+ * @param condition A function that determines whether the async validator should be applied.
15
+ * @param validatorFn The async validator function to be applied conditionally.
16
+ * @returns An async validator function that can be used with Angular Reactive Forms.
17
+ */
18
+ export declare function ifAsyncValidator(condition: (control: AbstractControl) => boolean, validatorFn: AsyncValidatorFn): AsyncValidatorFn;
@@ -0,0 +1,4 @@
1
+ export * from './form.util';
2
+ export * from './is-empty.util';
3
+ export * from './is-equal.util';
4
+ export * from './pick-by.util';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Check if a value is empty.
3
+ * @param {T | undefined | null} value - The value to check for emptiness.
4
+ * @returns {boolean} - Returns true if the value is empty, otherwise false.
5
+ */
6
+ export declare function isEmpty<T extends object | string | Array<unknown>>(value: T | undefined | null): value is null;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Check if two values are deeply equal.
3
+ * @param {T} value1 - The first value to compare.
4
+ * @param {T} value2 - The second value to compare.
5
+ * @returns {boolean} - Returns true if the values are deeply equal, otherwise false.
6
+ */
7
+ export declare function isEqual<T>(value1: T, value2: T): boolean;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Create an object composed of object properties that satisfy a given condition.
3
+ * @param {T} source - The object to pick properties from.
4
+ * @param {(value: T[keyof T], key: string) => boolean} predicate - The function invoked per property.
5
+ * @returns {Partial<T>} - Returns the new object.
6
+ */
7
+ export declare function pickBy<T>(source: T, predicate: (value: T[keyof T], key: string) => boolean): Partial<T>;
@@ -0,0 +1,2 @@
1
+ export * from './unique.validator';
2
+ export * from './url.validator';
@@ -0,0 +1,18 @@
1
+ import { AbstractControl, ValidatorFn } from '@angular/forms';
2
+ /**
3
+ * Validator for checking uniqueness across multiple fields in a FormArray or FormGroup.
4
+ *
5
+ * This validator can be applied to a FormArray or FormGroup containing the controls to be validated.
6
+ * It ensures that each control's value is unique among all other controls within the array or group.
7
+ */
8
+ export declare class UniqueValidator {
9
+ /**
10
+ * Validator function to be attached to a FormArray or FormGroup.
11
+ *
12
+ * This validator checks for uniqueness of each control's value within the array or group.
13
+ *
14
+ * @param keySelector A function to select the key control for comparison (default is the control itself).
15
+ * @typeparam T The type of the control value.
16
+ */
17
+ static unique<T>(keySelector?: (control: AbstractControl) => AbstractControl<T>): ValidatorFn;
18
+ }
@@ -0,0 +1,3 @@
1
+ import { AbstractControl, ValidationErrors } from '@angular/forms';
2
+ export declare function urlValidator(control: AbstractControl): ValidationErrors | null;
3
+ export declare function httpsValidator(control: AbstractControl): ValidationErrors | null;
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "ngx-lift",
3
+ "version": "0.4.0",
4
+ "description": "A project has been crafted with the goal of enhancing and simplifying your Angular development experience.",
5
+ "author": "Guanghui Wang <guanghui-wang@foxmail.com>",
6
+ "peerDependencies": {
7
+ "@angular/common": ">=15.0.0",
8
+ "@angular/core": ">=15.0.0",
9
+ "rxjs": ">=7.8.0"
10
+ },
11
+ "dependencies": {
12
+ "tslib": "^2.3.0"
13
+ },
14
+ "sideEffects": false,
15
+ "module": "fesm2022/ngx-lift.mjs",
16
+ "typings": "index.d.ts",
17
+ "exports": {
18
+ "./package.json": {
19
+ "default": "./package.json"
20
+ },
21
+ ".": {
22
+ "types": "./index.d.ts",
23
+ "esm2022": "./esm2022/ngx-lift.mjs",
24
+ "esm": "./esm2022/ngx-lift.mjs",
25
+ "default": "./fesm2022/ngx-lift.mjs"
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,5 @@
1
+ export * from './lib/models';
2
+ export * from './lib/operators';
3
+ export * from './lib/pipes';
4
+ export * from './lib/utils';
5
+ export * from './lib/validators';