@acorex/core 18.4.3 → 18.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/date-time/index.d.ts +2 -2
- package/esm2022/config/lib/configs.mjs +1 -1
- package/esm2022/date-time/index.mjs +3 -3
- package/esm2022/date-time/lib/dateTime.config.mjs +1 -1
- package/esm2022/date-time/lib/datetime.pipe.mjs +1 -1
- package/esm2022/date-time/lib/formatters/datetime-formatter.mjs +1 -1
- package/esm2022/date-time/lib/georgian.calendar.mjs +4 -9
- package/esm2022/date-time/lib/holidays.loader.mjs +1 -1
- package/esm2022/date-time/lib/jalali.calendar.mjs +10 -33
- package/esm2022/file/index.mjs +3 -3
- package/esm2022/file/lib/file-download-ref.class.mjs +1 -1
- package/esm2022/file/lib/file-upload-ref.class.mjs +1 -1
- package/esm2022/format/index.mjs +2 -2
- package/esm2022/format/lib/format.module.mjs +2 -2
- package/esm2022/format/lib/format.pipe.mjs +4 -8
- package/esm2022/image/lib/image.service.mjs +1 -1
- package/esm2022/pipes/lib/safe/safe.pipe.mjs +2 -2
- package/esm2022/platform/lib/platform.service.mjs +11 -3
- package/esm2022/storage/cookie-storage.service.mjs +5 -11
- package/esm2022/translation/index.mjs +3 -3
- package/esm2022/translation/lib/translation-scope.resolver.mjs +2 -2
- package/esm2022/translation/lib/translation.config.mjs +1 -1
- package/esm2022/translation/lib/translation.loader.mjs +1 -1
- package/esm2022/translation/lib/translation.module.mjs +4 -4
- package/esm2022/translation/lib/translator.directive.mjs +2 -2
- package/esm2022/translation/lib/translator.pipe.mjs +2 -2
- package/esm2022/utils/lib/auto-unsubscribe.mjs +1 -1
- package/esm2022/utils/lib/color-util.mjs +2 -4
- package/esm2022/utils/lib/drawing-util.mjs +4 -10
- package/esm2022/utils/lib/html-util.mjs +7 -3
- package/esm2022/utils/lib/string-util.mjs +1 -1
- package/esm2022/validation/lib/rules/between-rule.mjs +2 -2
- package/esm2022/validation/lib/rules/equal-rule.mjs +2 -2
- package/esm2022/validation/lib/rules/greater-than.mjs +3 -7
- package/esm2022/validation/lib/rules/length-rule.mjs +2 -5
- package/esm2022/validation/lib/rules/less-than-rule.mjs +3 -7
- package/esm2022/validation/lib/rules/maxlength-rule.mjs +3 -6
- package/esm2022/validation/lib/rules/minlength-rule.mjs +3 -6
- package/esm2022/validation/lib/rules/regex-rule.mjs +5 -8
- package/esm2022/validation/lib/rules/required-rule.mjs +6 -4
- package/esm2022/validation/lib/validation.config.mjs +1 -1
- package/esm2022/validation/lib/validation.module.mjs +10 -10
- package/esm2022/validation/lib/validation.service.mjs +3 -3
- package/esm2022/validation/lib/validation.types.mjs +1 -1
- package/fesm2022/acorex-core-config.mjs.map +1 -1
- package/fesm2022/acorex-core-date-time.mjs +87 -115
- package/fesm2022/acorex-core-date-time.mjs.map +1 -1
- package/fesm2022/acorex-core-file.mjs +42 -42
- package/fesm2022/acorex-core-file.mjs.map +1 -1
- package/fesm2022/acorex-core-format.mjs +2 -6
- package/fesm2022/acorex-core-format.mjs.map +1 -1
- package/fesm2022/acorex-core-image.mjs.map +1 -1
- package/fesm2022/acorex-core-pipes.mjs.map +1 -1
- package/fesm2022/acorex-core-platform.mjs +10 -2
- package/fesm2022/acorex-core-platform.mjs.map +1 -1
- package/fesm2022/acorex-core-storage.mjs +4 -10
- package/fesm2022/acorex-core-storage.mjs.map +1 -1
- package/fesm2022/acorex-core-translation.mjs +27 -27
- package/fesm2022/acorex-core-translation.mjs.map +1 -1
- package/fesm2022/acorex-core-utils.mjs +10 -14
- package/fesm2022/acorex-core-utils.mjs.map +1 -1
- package/fesm2022/acorex-core-validation.mjs +11 -29
- package/fesm2022/acorex-core-validation.mjs.map +1 -1
- package/file/index.d.ts +2 -2
- package/format/index.d.ts +1 -1
- package/format/lib/format.pipe.d.ts +1 -1
- package/package.json +13 -13
- package/platform/lib/platform.service.d.ts +5 -1
- package/translation/index.d.ts +2 -2
- package/translation/lib/translation.loader.d.ts +1 -1
- package/translation/lib/translator.pipe.d.ts +1 -1
- package/validation/lib/validation.service.d.ts +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"acorex-core-storage.mjs","sources":["../../../../libs/core/storage/src/cookie-storage.service.ts","../../../../libs/core/storage/src/local-storage.service.ts","../../../../libs/core/storage/src/session-storage.service.ts","../../../../libs/core/storage/src/acorex-core-storage.ts"],"sourcesContent":["import { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { Inject, Injectable, PLATFORM_ID } from '@angular/core';\nimport { AXCookieOptions, AXSameSite } from './storage.interface';\n\n@Injectable()\nexport class AXCookieStorageService {\n private readonly documentIsAccessible: boolean;\n\n constructor(\n @Inject(DOCUMENT) private document: Document,\n // Get the `PLATFORM_ID` so we can check if we're in a browser.\n @Inject(PLATFORM_ID) private platformId\n ) {\n this.documentIsAccessible = isPlatformBrowser(this.platformId);\n }\n\n /**\n * Get cookie Regular Expression\n *\n * @param name Cookie name\n * @returns property RegExp\n *\n */\n private static getCookieRegExp(name: string): RegExp {\n const escapedName: string = name.replace(/([[\\]{}()|=;+?,.*^$])/gi, '\\\\$1');\n\n return new RegExp(\n '(?:^' + escapedName + '|;\\\\s*' + escapedName + ')=(.*?)(?:;|$)',\n 'g'\n );\n }\n\n /**\n * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI).\n *\n * @param encodedURIComponent A value representing an encoded URI component.\n *\n * @returns The unencoded version of an encoded component of a Uniform Resource Identifier (URI).\n *\n */\n private static safeDecodeURIComponent(encodedURIComponent: string): string {\n try {\n return decodeURIComponent(encodedURIComponent);\n } catch {\n // probably it is not uri encoded. return as is\n return encodedURIComponent;\n }\n }\n\n /**\n * Return `true` if {@link Document} is accessible, otherwise return `false`\n *\n * @param name Cookie name\n * @returns boolean - whether cookie with specified name exists\n *\n */\n check(name: string): boolean {\n if (!this.documentIsAccessible) {\n return false;\n }\n name = encodeURIComponent(name);\n const regExp: RegExp = AXCookieStorageService.getCookieRegExp(name);\n return regExp.test(this.document.cookie);\n }\n\n /**\n * Get cookies by name\n *\n * @param name Cookie name\n * @returns property value\n *\n */\n get(name: string): string {\n if (this.documentIsAccessible && this.check(name)) {\n name = encodeURIComponent(name);\n\n const regExp: RegExp = AXCookieStorageService.getCookieRegExp(name);\n const result: RegExpExecArray = regExp.exec(this.document.cookie);\n\n return result[1]\n ? AXCookieStorageService.safeDecodeURIComponent(result[1])\n : '';\n } else {\n return '';\n }\n }\n\n /**\n * Get all cookies in JSON format\n *\n * @returns all the cookies in json\n *\n */\n getAll(): { [key: string]: string } {\n if (!this.documentIsAccessible) {\n return {};\n }\n\n const cookies: { [key: string]: string } = {};\n const document: any = this.document;\n\n if (document.cookie && document.cookie !== '') {\n document.cookie.split(';').forEach((currentCookie) => {\n const [cookieName, cookieValue] = currentCookie.split('=');\n cookies[\n AXCookieStorageService.safeDecodeURIComponent(\n cookieName.replace(/^ /, '')\n )\n ] = AXCookieStorageService.safeDecodeURIComponent(cookieValue);\n });\n }\n\n return cookies;\n }\n\n /**\n * Set cookie based on provided information\n *\n * @param name Cookie name\n * @param value Cookie value\n * @param expires Number of days until the cookies expires or an actual `Date`\n * @param path Cookie path\n * @param domain Cookie domain\n * @param secure Secure flag\n * @param sameSite OWASP samesite token `Lax`, `None`, or `Strict`. Defaults to `Lax`\n *\n */\n set(\n name: string,\n value: string,\n expires?: AXCookieOptions['expires'],\n path?: AXCookieOptions['path'],\n domain?: AXCookieOptions['domain'],\n secure?: AXCookieOptions['secure'],\n sameSite?: AXSameSite\n ): void;\n\n /**\n * Set cookie based on provided information\n *\n * Cookie's parameters:\n * <pre>\n * expires Number of days until the cookies expires or an actual `Date`\n * path Cookie path\n * domain Cookie domain\n * secure Secure flag\n * sameSite OWASP samesite token `Lax`, `None`, or `Strict`. Defaults to `Lax`\n * </pre>\n *\n * @param name Cookie name\n * @param value Cookie value\n * @param options Body with cookie's params\n *\n */\n set(name: string, value: string, options?: AXCookieOptions): void;\n\n set(\n name: string,\n value: string,\n expiresOrOptions?: AXCookieOptions['expires'] | AXCookieOptions,\n path?: AXCookieOptions['path'],\n domain?: AXCookieOptions['domain'],\n secure?: AXCookieOptions['secure'],\n sameSite?: AXSameSite\n ): void {\n if (!this.documentIsAccessible) {\n return;\n }\n\n if (\n typeof expiresOrOptions === 'number' ||\n expiresOrOptions instanceof Date ||\n path ||\n domain ||\n secure ||\n sameSite\n ) {\n const optionsBody = {\n expires: expiresOrOptions as AXCookieOptions['expires'],\n path,\n domain,\n secure,\n sameSite: sameSite ? sameSite : 'Lax',\n };\n\n this.set(name, value, optionsBody);\n return;\n }\n\n let cookieString: string =\n encodeURIComponent(name) + '=' + encodeURIComponent(value) + ';';\n\n const options = expiresOrOptions ? expiresOrOptions : {};\n\n if (options.expires) {\n if (typeof options.expires === 'number') {\n const dateExpires: Date = new Date(\n new Date().getTime() + options.expires * 1000 * 60 * 60 * 24\n );\n\n cookieString += 'expires=' + dateExpires.toUTCString() + ';';\n } else {\n cookieString += 'expires=' + options.expires.toUTCString() + ';';\n }\n }\n\n if (options.path) {\n cookieString += 'path=' + options.path + ';';\n }\n\n if (options.domain) {\n cookieString += 'domain=' + options.domain + ';';\n }\n\n if (options.secure === false && options.sameSite === 'None') {\n options.secure = true;\n console.warn(\n `[ngx-cookie-service] Cookie ${name} was forced with secure flag because sameSite=None.` +\n `More details : https://github.com/stevermeister/ngx-cookie-service/issues/86#issuecomment-597720130`\n );\n }\n if (options.secure) {\n cookieString += 'secure;';\n }\n\n if (!options.sameSite) {\n options.sameSite = 'Lax';\n }\n\n cookieString += 'sameSite=' + options.sameSite + ';';\n\n this.document.cookie = cookieString;\n }\n\n /**\n * Delete cookie by name\n *\n * @param name Cookie name\n * @param path Cookie path\n * @param domain Cookie domain\n * @param secure Cookie secure flag\n * @param sameSite Cookie sameSite flag - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite\n *\n */\n delete(\n name: string,\n path?: AXCookieOptions['path'],\n domain?: AXCookieOptions['domain'],\n secure?: AXCookieOptions['secure'],\n sameSite: AXSameSite = 'Lax'\n ): void {\n if (!this.documentIsAccessible) {\n return;\n }\n const expiresDate = new Date('Thu, 01 Jan 1970 00:00:01 GMT');\n this.set(name, '', {\n expires: expiresDate,\n path,\n domain,\n secure,\n sameSite,\n });\n }\n\n /**\n * Delete all cookies\n *\n * @param path Cookie path\n * @param domain Cookie domain\n * @param secure Is the Cookie secure\n * @param sameSite Is the cookie same site\n *\n */\n deleteAll(\n path?: AXCookieOptions['path'],\n domain?: AXCookieOptions['domain'],\n secure?: AXCookieOptions['secure'],\n sameSite: AXSameSite = 'Lax'\n ): void {\n if (!this.documentIsAccessible) {\n return;\n }\n\n const cookies = this.getAll();\n\n for (const cookieName in cookies) {\n // eslint-disable-next-line no-prototype-builtins\n if (cookies.hasOwnProperty(cookieName)) {\n this.delete(cookieName, path, domain, secure, sameSite);\n }\n }\n }\n}\n","import { isBrowser } from '@acorex/core/platform';\nimport { Inject, Injectable, InjectionToken } from '@angular/core';\nimport CryptoJS from 'crypto-es';\nimport { AXStorage } from './storage.interface';\n\nexport const AX_LOCALSTORAGE_SECRET_KEY: InjectionToken<string> = new InjectionToken('AX_LOCALSTORAGE_SECRET_KEY');\n\n@Injectable()\nexport class AXLocalStorageService implements AXStorage {\n constructor(@Inject(AX_LOCALSTORAGE_SECRET_KEY) private secret_key: string) {}\n\n get<T = unknown>(key: string): T {\n if (isBrowser()) {\n const value = localStorage.getItem(key);\n return value ? JSON.parse(value) : null;\n } else {\n return null;\n }\n }\n\n set<T = unknown>(key: string, value: T): void {\n if (isBrowser()) {\n return localStorage.setItem(key, JSON.stringify(value));\n }\n }\n\n clear(): void {\n if (isBrowser()) {\n return localStorage.clear();\n }\n }\n\n removeItem(key: string) {\n if (isBrowser()) {\n return localStorage.removeItem(key);\n }\n }\n\n setWithEncryption<T = unknown>(key: string, value: T) {\n if (isBrowser()) {\n const encrypted = CryptoJS.AES.encrypt(JSON.stringify(value), this.secret_key).toString();\n return localStorage.setItem(key, encrypted);\n }\n }\n\n getWithEncription<T = unknown>(key: string): T {\n if (isBrowser()) {\n const encrypted = localStorage.getItem(key) || '';\n const decrypted = CryptoJS.AES.decrypt(encrypted, this.secret_key).toString(CryptoJS.enc.Utf8);\n return encrypted ? JSON.parse(decrypted) : {};\n } else {\n return null;\n }\n }\n}\n","import { isBrowser } from '@acorex/core/platform';\nimport { Injectable } from '@angular/core';\nimport { AXStorage } from './storage.interface';\n\n@Injectable()\nexport class AXSessionStorageService implements AXStorage {\n get<T = unknown>(key: string): T {\n if (isBrowser()) {\n const value = sessionStorage.getItem(key);\n return value ? JSON.parse(value) : null;\n } else {\n return null;\n }\n }\n\n set<T = unknown>(key: string, value: T): void {\n if (isBrowser()) {\n return sessionStorage.setItem(key, JSON.stringify(value));\n }\n }\n\n clear(): void {\n if (isBrowser()) {\n return sessionStorage.clear();\n }\n }\n\n removeItem(key: string) {\n if (isBrowser()) {\n return sessionStorage.removeItem(key);\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MAKa,sBAAsB,CAAA;AAGjC,IAAA,WAAA,CAC4B,QAAkB;;IAEf,UAAU,EAAA;QAFb,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;QAEf,IAAU,CAAA,UAAA,GAAV,UAAU,CAAA;QAEvC,IAAI,CAAC,oBAAoB,GAAG,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KAChE;AAED;;;;;;AAMG;IACK,OAAO,eAAe,CAAC,IAAY,EAAA;QACzC,MAAM,WAAW,GAAW,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;AAE5E,QAAA,OAAO,IAAI,MAAM,CACf,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,gBAAgB,EAChE,GAAG,CACJ,CAAC;KACH;AAED;;;;;;;AAOG;IACK,OAAO,sBAAsB,CAAC,mBAA2B,EAAA;AAC/D,QAAA,IAAI;AACF,YAAA,OAAO,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;SACh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A;QACH,IAAI,SAAS,EAAE,EAAE;AACf,YAAA,OAAO,cAAc,CAAC,KAAK,EAAE,CAAC;SAC/B;KACF;AAED,IAAA,UAAU,CAAC,GAAW,EAAA;QACpB,IAAI,SAAS,EAAE,EAAE;AACf,YAAA,OAAO,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SACvC;KACF;8GA1BU,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA,EAAA;kHAAvB,uBAAuB,EAAA,CAAA,CAAA,EAAA;;2FAAvB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBADnC,UAAU;;;ACJX;;AAEG;;;;"}
|
1
|
+
{"version":3,"file":"acorex-core-storage.mjs","sources":["../../../../libs/core/storage/src/cookie-storage.service.ts","../../../../libs/core/storage/src/local-storage.service.ts","../../../../libs/core/storage/src/session-storage.service.ts","../../../../libs/core/storage/src/acorex-core-storage.ts"],"sourcesContent":["import { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { Inject, Injectable, PLATFORM_ID } from '@angular/core';\nimport { AXCookieOptions, AXSameSite } from './storage.interface';\n\n@Injectable()\nexport class AXCookieStorageService {\n private readonly documentIsAccessible: boolean;\n\n constructor(\n @Inject(DOCUMENT) private document: Document,\n // Get the `PLATFORM_ID` so we can check if we're in a browser.\n @Inject(PLATFORM_ID) private platformId,\n ) {\n this.documentIsAccessible = isPlatformBrowser(this.platformId);\n }\n\n /**\n * Get cookie Regular Expression\n *\n * @param name Cookie name\n * @returns property RegExp\n *\n */\n private static getCookieRegExp(name: string): RegExp {\n const escapedName: string = name.replace(/([[\\]{}()|=;+?,.*^$])/gi, '\\\\$1');\n\n return new RegExp('(?:^' + escapedName + '|;\\\\s*' + escapedName + ')=(.*?)(?:;|$)', 'g');\n }\n\n /**\n * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI).\n *\n * @param encodedURIComponent A value representing an encoded URI component.\n *\n * @returns The unencoded version of an encoded component of a Uniform Resource Identifier (URI).\n *\n */\n private static safeDecodeURIComponent(encodedURIComponent: string): string {\n try {\n return decodeURIComponent(encodedURIComponent);\n } catch {\n // probably it is not uri encoded. return as is\n return encodedURIComponent;\n }\n }\n\n /**\n * Return `true` if {@link Document} is accessible, otherwise return `false`\n *\n * @param name Cookie name\n * @returns boolean - whether cookie with specified name exists\n *\n */\n check(name: string): boolean {\n if (!this.documentIsAccessible) {\n return false;\n }\n name = encodeURIComponent(name);\n const regExp: RegExp = AXCookieStorageService.getCookieRegExp(name);\n return regExp.test(this.document.cookie);\n }\n\n /**\n * Get cookies by name\n *\n * @param name Cookie name\n * @returns property value\n *\n */\n get(name: string): string {\n if (this.documentIsAccessible && this.check(name)) {\n name = encodeURIComponent(name);\n\n const regExp: RegExp = AXCookieStorageService.getCookieRegExp(name);\n const result: RegExpExecArray = regExp.exec(this.document.cookie);\n\n return result[1] ? AXCookieStorageService.safeDecodeURIComponent(result[1]) : '';\n } else {\n return '';\n }\n }\n\n /**\n * Get all cookies in JSON format\n *\n * @returns all the cookies in json\n *\n */\n getAll(): { [key: string]: string } {\n if (!this.documentIsAccessible) {\n return {};\n }\n\n const cookies: { [key: string]: string } = {};\n const document: any = this.document;\n\n if (document.cookie && document.cookie !== '') {\n document.cookie.split(';').forEach((currentCookie) => {\n const [cookieName, cookieValue] = currentCookie.split('=');\n cookies[AXCookieStorageService.safeDecodeURIComponent(cookieName.replace(/^ /, ''))] =\n AXCookieStorageService.safeDecodeURIComponent(cookieValue);\n });\n }\n\n return cookies;\n }\n\n /**\n * Set cookie based on provided information\n *\n * @param name Cookie name\n * @param value Cookie value\n * @param expires Number of days until the cookies expires or an actual `Date`\n * @param path Cookie path\n * @param domain Cookie domain\n * @param secure Secure flag\n * @param sameSite OWASP samesite token `Lax`, `None`, or `Strict`. Defaults to `Lax`\n *\n */\n set(\n name: string,\n value: string,\n expires?: AXCookieOptions['expires'],\n path?: AXCookieOptions['path'],\n domain?: AXCookieOptions['domain'],\n secure?: AXCookieOptions['secure'],\n sameSite?: AXSameSite,\n ): void;\n\n /**\n * Set cookie based on provided information\n *\n * Cookie's parameters:\n * <pre>\n * expires Number of days until the cookies expires or an actual `Date`\n * path Cookie path\n * domain Cookie domain\n * secure Secure flag\n * sameSite OWASP samesite token `Lax`, `None`, or `Strict`. Defaults to `Lax`\n * </pre>\n *\n * @param name Cookie name\n * @param value Cookie value\n * @param options Body with cookie's params\n *\n */\n set(name: string, value: string, options?: AXCookieOptions): void;\n\n set(\n name: string,\n value: string,\n expiresOrOptions?: AXCookieOptions['expires'] | AXCookieOptions,\n path?: AXCookieOptions['path'],\n domain?: AXCookieOptions['domain'],\n secure?: AXCookieOptions['secure'],\n sameSite?: AXSameSite,\n ): void {\n if (!this.documentIsAccessible) {\n return;\n }\n\n if (typeof expiresOrOptions === 'number' || expiresOrOptions instanceof Date || path || domain || secure || sameSite) {\n const optionsBody = {\n expires: expiresOrOptions as AXCookieOptions['expires'],\n path,\n domain,\n secure,\n sameSite: sameSite ? sameSite : 'Lax',\n };\n\n this.set(name, value, optionsBody);\n return;\n }\n\n let cookieString: string = encodeURIComponent(name) + '=' + encodeURIComponent(value) + ';';\n\n const options = expiresOrOptions ? expiresOrOptions : {};\n\n if (options.expires) {\n if (typeof options.expires === 'number') {\n const dateExpires: Date = new Date(new Date().getTime() + options.expires * 1000 * 60 * 60 * 24);\n\n cookieString += 'expires=' + dateExpires.toUTCString() + ';';\n } else {\n cookieString += 'expires=' + options.expires.toUTCString() + ';';\n }\n }\n\n if (options.path) {\n cookieString += 'path=' + options.path + ';';\n }\n\n if (options.domain) {\n cookieString += 'domain=' + options.domain + ';';\n }\n\n if (options.secure === false && options.sameSite === 'None') {\n options.secure = true;\n console.warn(\n `[ngx-cookie-service] Cookie ${name} was forced with secure flag because sameSite=None.` +\n `More details : https://github.com/stevermeister/ngx-cookie-service/issues/86#issuecomment-597720130`,\n );\n }\n if (options.secure) {\n cookieString += 'secure;';\n }\n\n if (!options.sameSite) {\n options.sameSite = 'Lax';\n }\n\n cookieString += 'sameSite=' + options.sameSite + ';';\n\n this.document.cookie = cookieString;\n }\n\n /**\n * Delete cookie by name\n *\n * @param name Cookie name\n * @param path Cookie path\n * @param domain Cookie domain\n * @param secure Cookie secure flag\n * @param sameSite Cookie sameSite flag - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite\n *\n */\n delete(\n name: string,\n path?: AXCookieOptions['path'],\n domain?: AXCookieOptions['domain'],\n secure?: AXCookieOptions['secure'],\n sameSite: AXSameSite = 'Lax',\n ): void {\n if (!this.documentIsAccessible) {\n return;\n }\n const expiresDate = new Date('Thu, 01 Jan 1970 00:00:01 GMT');\n this.set(name, '', {\n expires: expiresDate,\n path,\n domain,\n secure,\n sameSite,\n });\n }\n\n /**\n * Delete all cookies\n *\n * @param path Cookie path\n * @param domain Cookie domain\n * @param secure Is the Cookie secure\n * @param sameSite Is the cookie same site\n *\n */\n deleteAll(\n path?: AXCookieOptions['path'],\n domain?: AXCookieOptions['domain'],\n secure?: AXCookieOptions['secure'],\n sameSite: AXSameSite = 'Lax',\n ): void {\n if (!this.documentIsAccessible) {\n return;\n }\n\n const cookies = this.getAll();\n\n for (const cookieName in cookies) {\n // eslint-disable-next-line no-prototype-builtins\n if (cookies.hasOwnProperty(cookieName)) {\n this.delete(cookieName, path, domain, secure, sameSite);\n }\n }\n }\n}\n","import { isBrowser } from '@acorex/core/platform';\nimport { Inject, Injectable, InjectionToken } from '@angular/core';\nimport CryptoJS from 'crypto-es';\nimport { AXStorage } from './storage.interface';\n\nexport const AX_LOCALSTORAGE_SECRET_KEY: InjectionToken<string> = new InjectionToken('AX_LOCALSTORAGE_SECRET_KEY');\n\n@Injectable()\nexport class AXLocalStorageService implements AXStorage {\n constructor(@Inject(AX_LOCALSTORAGE_SECRET_KEY) private secret_key: string) {}\n\n get<T = unknown>(key: string): T {\n if (isBrowser()) {\n const value = localStorage.getItem(key);\n return value ? JSON.parse(value) : null;\n } else {\n return null;\n }\n }\n\n set<T = unknown>(key: string, value: T): void {\n if (isBrowser()) {\n return localStorage.setItem(key, JSON.stringify(value));\n }\n }\n\n clear(): void {\n if (isBrowser()) {\n return localStorage.clear();\n }\n }\n\n removeItem(key: string) {\n if (isBrowser()) {\n return localStorage.removeItem(key);\n }\n }\n\n setWithEncryption<T = unknown>(key: string, value: T) {\n if (isBrowser()) {\n const encrypted = CryptoJS.AES.encrypt(JSON.stringify(value), this.secret_key).toString();\n return localStorage.setItem(key, encrypted);\n }\n }\n\n getWithEncription<T = unknown>(key: string): T {\n if (isBrowser()) {\n const encrypted = localStorage.getItem(key) || '';\n const decrypted = CryptoJS.AES.decrypt(encrypted, this.secret_key).toString(CryptoJS.enc.Utf8);\n return encrypted ? JSON.parse(decrypted) : {};\n } else {\n return null;\n }\n }\n}\n","import { isBrowser } from '@acorex/core/platform';\nimport { Injectable } from '@angular/core';\nimport { AXStorage } from './storage.interface';\n\n@Injectable()\nexport class AXSessionStorageService implements AXStorage {\n get<T = unknown>(key: string): T {\n if (isBrowser()) {\n const value = sessionStorage.getItem(key);\n return value ? JSON.parse(value) : null;\n } else {\n return null;\n }\n }\n\n set<T = unknown>(key: string, value: T): void {\n if (isBrowser()) {\n return sessionStorage.setItem(key, JSON.stringify(value));\n }\n }\n\n clear(): void {\n if (isBrowser()) {\n return sessionStorage.clear();\n }\n }\n\n removeItem(key: string) {\n if (isBrowser()) {\n return sessionStorage.removeItem(key);\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MAKa,sBAAsB,CAAA;AAGjC,IAAA,WAAA,CAC4B,QAAkB;;IAEf,UAAU,EAAA;QAFb,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;QAEf,IAAU,CAAA,UAAA,GAAV,UAAU,CAAA;QAEvC,IAAI,CAAC,oBAAoB,GAAG,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,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AAS,EAAE,EAAE;YACf,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAC1C,YAAA,OAAO,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;SACzC;aAAM;AACL,YAAA,OAAO,IAAI,CAAC;SACb;KACF;IAED,GAAG,CAAc,GAAW,EAAE,KAAQ,EAAA;QACpC,IAAI,SAAS,EAAE,EAAE;AACf,YAAA,OAAO,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;SAC3D;KACF;IAED,KAAK,GAAA;QACH,IAAI,SAAS,EAAE,EAAE;AACf,YAAA,OAAO,cAAc,CAAC,KAAK,EAAE,CAAC;SAC/B;KACF;AAED,IAAA,UAAU,CAAC,GAAW,EAAA;QACpB,IAAI,SAAS,EAAE,EAAE;AACf,YAAA,OAAO,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SACvC;KACF;8GA1BU,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA,EAAA;kHAAvB,uBAAuB,EAAA,CAAA,CAAA,EAAA;;2FAAvB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBADnC,UAAU;;;ACJX;;AAEG;;;;"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
|
-
import { InjectionToken, inject, Injectable,
|
3
|
-
import { of, BehaviorSubject, forkJoin, tap, catchError, finalize, shareReplay, map, switchMap, startWith, firstValueFrom, take, lastValueFrom } from 'rxjs';
|
2
|
+
import { InjectionToken, inject, Injectable, Directive, Pipe, APP_INITIALIZER, NgModule } from '@angular/core';
|
4
3
|
import { AXEventService, AXEventTypes } from '@acorex/core/events';
|
5
4
|
import { set, get } from 'lodash-es';
|
5
|
+
import { of, BehaviorSubject, forkJoin, tap, catchError, finalize, shareReplay, map, switchMap, startWith, firstValueFrom, take, lastValueFrom } from 'rxjs';
|
6
6
|
|
7
7
|
const AX_TRANSLATION_CONFIG = new InjectionToken('AX_TRANSLATION_CONFIG', {
|
8
8
|
providedIn: 'root',
|
@@ -216,23 +216,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImpor
|
|
216
216
|
args: [{ providedIn: 'root' }]
|
217
217
|
}], ctorParameters: () => [] });
|
218
218
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
}
|
227
|
-
return this.service.translate(key, options);
|
228
|
-
}
|
229
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXTranslatorPipe, deps: [{ token: AXTranslationService }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
230
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.0.2", ngImport: i0, type: AXTranslatorPipe, name: "translate" }); }
|
231
|
-
}
|
232
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXTranslatorPipe, decorators: [{
|
233
|
-
type: Pipe,
|
234
|
-
args: [{ name: 'translate', pure: true }]
|
235
|
-
}], ctorParameters: () => [{ type: AXTranslationService }] });
|
219
|
+
const loadTranslationScope = (route, state) => {
|
220
|
+
const translatorService = inject(AXTranslationService);
|
221
|
+
const config = inject(AX_TRANSLATION_CONFIG);
|
222
|
+
const scopeValue = route.data[config.scopeResolverKey];
|
223
|
+
const scopes = Array.isArray(scopeValue) ? scopeValue : [scopeValue];
|
224
|
+
return translatorService.loadLanguagesAndScopes([translatorService.getActiveLang()], scopes);
|
225
|
+
};
|
236
226
|
|
237
227
|
class AXTranslatorDirective {
|
238
228
|
constructor(templateRef, viewContainer, translationService) {
|
@@ -258,6 +248,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImpor
|
|
258
248
|
}]
|
259
249
|
}], ctorParameters: () => [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: AXTranslationService }] });
|
260
250
|
|
251
|
+
class AXTranslatorPipe {
|
252
|
+
constructor(service) {
|
253
|
+
this.service = service;
|
254
|
+
}
|
255
|
+
transform(key, options) {
|
256
|
+
if (!key) {
|
257
|
+
return of(''); // Return an empty observable if the key is not provided
|
258
|
+
}
|
259
|
+
return this.service.translate(key, options);
|
260
|
+
}
|
261
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXTranslatorPipe, deps: [{ token: AXTranslationService }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
262
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "18.0.2", ngImport: i0, type: AXTranslatorPipe, name: "translate" }); }
|
263
|
+
}
|
264
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AXTranslatorPipe, decorators: [{
|
265
|
+
type: Pipe,
|
266
|
+
args: [{ name: 'translate', pure: true }]
|
267
|
+
}], ctorParameters: () => [{ type: AXTranslationService }] });
|
268
|
+
|
261
269
|
function initializeApp(translatorService, config) {
|
262
270
|
return () => {
|
263
271
|
return translatorService.loadLanguagesAndScopes(config.preloadLangs ?? [config.defaultLang], config.preloadScopes ?? [config.defaultScope]);
|
@@ -292,14 +300,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImpor
|
|
292
300
|
}]
|
293
301
|
}] });
|
294
302
|
|
295
|
-
const loadTranslationScope = (route, state) => {
|
296
|
-
const translatorService = inject(AXTranslationService);
|
297
|
-
const config = inject(AX_TRANSLATION_CONFIG);
|
298
|
-
const scopeValue = route.data[config.scopeResolverKey];
|
299
|
-
const scopes = Array.isArray(scopeValue) ? scopeValue : [scopeValue];
|
300
|
-
return translatorService.loadLanguagesAndScopes([translatorService.getActiveLang()], scopes);
|
301
|
-
};
|
302
|
-
|
303
303
|
/**
|
304
304
|
* Generated bundle index. Do not edit.
|
305
305
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"acorex-core-translation.mjs","sources":["../../../../libs/core/translation/src/lib/translation.config.ts","../../../../libs/core/translation/src/lib/translation.loader.ts","../../../../libs/core/translation/src/lib/translation.service.ts","../../../../libs/core/translation/src/lib/translator.pipe.ts","../../../../libs/core/translation/src/lib/translator.directive.ts","../../../../libs/core/translation/src/lib/translation.module.ts","../../../../libs/core/translation/src/lib/translation-scope.resolver.ts","../../../../libs/core/translation/src/acorex-core-translation.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { AXTranslateLang, AXTranslateScope } from './translation.types';\n\nexport interface AXTranslationConfig {\n defaultLang: AXTranslateLang;\n defaultScope: AXTranslateScope;\n preloadLangs?: AXTranslateLang[];\n preloadScopes?: AXTranslateLang[];\n availableLangs?: AXTranslateLang[];\n scopeResolverKey: string;\n}\n\nexport const AX_TRANSLATION_CONFIG = new InjectionToken<AXTranslationConfig>(\n 'AX_TRANSLATION_CONFIG',\n {\n providedIn: 'root',\n factory: () => {\n return AXTranslationDefaultConfig;\n },\n }\n);\n\nexport const AXTranslationDefaultConfig: AXTranslationConfig = {\n defaultLang: 'en',\n defaultScope: 'common',\n scopeResolverKey: 'scope',\n};\n\nexport type AXPartialTranslationConfig = Partial<AXTranslationConfig>;\n\nexport function translationConfig(\n config: AXPartialTranslationConfig = {}\n): AXTranslationConfig {\n const result = {\n ...AXTranslationDefaultConfig,\n ...config,\n };\n return result;\n}\n","import { InjectionToken } from '@angular/core';\nimport {\n AXTranslateLang,\n AXTranslateScope,\n AXTranslation,\n} from './translation.types';\nimport { Observable, of } from 'rxjs';\n\nexport interface AXTranslationLoaderOptions {\n lang: AXTranslateLang;\n scope?: AXTranslateScope;\n}\n\nexport interface AXTranslationLoader {\n getTranslation(\n options: AXTranslationLoaderOptions\n ): Observable<AXTranslation>;\n}\n\nexport class AXTranslationLoaderDefault implements AXTranslationLoader {\n getTranslation(\n options: AXTranslationLoaderOptions\n ): Observable<AXTranslation> {\n return of({});\n }\n}\n\nexport const AX_TRANSLATION_LOADER = new InjectionToken<AXTranslationLoader>(\n 'AX_TRANSLATION_LOADER',\n {\n providedIn: 'root',\n factory: () => {\n return new AXTranslationLoaderDefault();\n },\n }\n);\n","import { AXEventService, AXEventTypes } from '@acorex/core/events';\nimport { Injectable, inject } from '@angular/core';\nimport { get as lodashGet, set as lodashSet } from 'lodash-es';\nimport {\n BehaviorSubject,\n Observable,\n catchError,\n finalize,\n firstValueFrom,\n forkJoin,\n lastValueFrom,\n map,\n of,\n shareReplay,\n startWith,\n switchMap,\n take,\n tap,\n} from 'rxjs';\nimport { AX_TRANSLATION_CONFIG } from './translation.config';\nimport { AX_TRANSLATION_LOADER } from './translation.loader';\nimport { AXTranslateHashMap, AXTranslateOptions, AXTranslateParams } from './translation.types';\n\nlet service: AXTranslationService;\n\nexport function translateSync(key: string, options?: AXTranslateOptions): string {\n return service.translateSync(key, options);\n}\n\n@Injectable({ providedIn: 'root' })\nexport class AXTranslationService {\n private loader = inject(AX_TRANSLATION_LOADER);\n private config = inject(AX_TRANSLATION_CONFIG);\n\n private eventService = inject(AXEventService);\n\n private translationCache: AXTranslateHashMap<AXTranslateHashMap<string>> = {};\n private ongoingRequests: Map<string, Observable<any>> = new Map();\n\n private activeLang: BehaviorSubject<string> = new BehaviorSubject<string>(this.getDefaultLang());\n langChanges$: Observable<string> = this.activeLang.asObservable();\n\n private lastActiveLang: string | null = null;\n\n /**\n * @ignore\n */\n constructor() {\n service = this;\n }\n\n public loadLanguagesAndScopes(languages: string[], scopes: string[]): Observable<unknown> {\n const requests = languages.flatMap((lang) =>\n scopes.map((scope) => {\n // Check if translations are already cached\n if (this.translationCache[lang]?.[scope]) {\n return of(this.translationCache[lang][scope]);\n }\n\n // Use the new method to handle ongoing requests and loading\n return this.getOrLoadTranslations(lang, scope);\n }),\n );\n\n return forkJoin(requests);\n }\n\n private getOrLoadTranslations(lang: string, scope: string): Observable<AXTranslateHashMap<string>> {\n const requestKey = `${lang}_${scope}`;\n\n // Return existing observable if the request is already in progress\n if (this.ongoingRequests.has(requestKey)) {\n return this.ongoingRequests.get(requestKey);\n }\n\n // Load translations if not in cache or ongoing requests\n const translationObservable = this.loader.getTranslation({ lang, scope }).pipe(\n tap((translations) => this.cacheTranslations(lang, scope, translations)),\n catchError((error) => {\n console.error(`Error loading translations for lang: ${lang}, scope: ${scope}`, error);\n return of(null);\n }),\n finalize(() => {\n this.eventService.emitEvent({\n type: AXEventTypes.AXLanguageLoaded,\n payload: lang,\n });\n this.ongoingRequests.delete(requestKey);\n }),\n shareReplay(1),\n );\n\n this.ongoingRequests.set(requestKey, translationObservable);\n return translationObservable;\n }\n\n private cacheTranslations(lang: string, scope: string, translations: AXTranslateHashMap<string>): void {\n lodashSet(this.translationCache, `${lang}.${scope}`, translations);\n }\n\n public getDefaultLang(): string {\n return this.config.defaultLang;\n }\n\n public getActiveLang(): string {\n return this.activeLang.getValue();\n }\n\n public setActiveLang(lang: string): void {\n if (lang != this.getActiveLang()) {\n this.lastActiveLang = this.getActiveLang(); // Update last active language\n this.activeLang.next(lang);\n this.eventService.emitEvent({\n type: AXEventTypes.AXLanguageChanged,\n payload: lang,\n });\n }\n }\n\n public isLangAvailable(lang: string, scope: string = null): boolean {\n return !this.translationCache[lang] && (!scope || !this.translationCache[lang][scope]);\n }\n\n private load(key: string, options: AXTranslateOptions = {}): Observable<string> {\n const { lang = this.getActiveLang(), scope = this.config.defaultScope } = options;\n\n // Function to fetch translation\n const fetchTranslation = (language: string): Observable<string> => {\n // Check if translations are available in the cache\n if (this.translationCache[language]?.[scope]) {\n return of(this.getTranslation(key, language, scope, options.params));\n }\n\n // Use the new method to handle ongoing requests and loading\n return this.getOrLoadTranslations(language, scope).pipe(\n map(() => {\n const translation = this.translationCache[language]?.[scope]?.[key] || key;\n return this.getTranslation(translation, language, scope, options.params);\n }),\n switchMap((translatedText) => {\n if (translatedText === key && language !== this.getDefaultLang()) {\n // If the translation is not found and the language is not default,\n // try fetching from the default language\n return fetchTranslation(this.getDefaultLang());\n }\n return of(translatedText);\n }),\n );\n };\n\n // First, try to fetch the translation for the requested language\n const translationForRequestedLang = fetchTranslation(lang);\n\n // If lastActiveLang is available and different from the requested language, use it as a fallback\n if (this.lastActiveLang && this.lastActiveLang !== lang) {\n const translationForLastActiveLang = this.getTranslation(key, this.lastActiveLang, scope, options.params);\n return translationForRequestedLang.pipe(startWith(translationForLastActiveLang));\n }\n\n return translationForRequestedLang;\n }\n\n private getTranslation(key: string, lang: string, scope: string, params?: AXTranslateParams): string {\n let translation: string = (lodashGet(this.translationCache, `${lang}.${scope}.${key}`) || key) as string;\n\n // Replace params like {{ name }}\n if (params) {\n Object.keys(params).forEach((paramKey) => {\n const paramValue = params[paramKey] as string;\n if (typeof translation !== 'string') {\n console.error(`${key} is not string`, { key, lang, scope, params, translation });\n } else {\n translation = translation.replace(new RegExp(`{{\\\\s*${paramKey}\\\\s*}}`, 'g'), paramValue);\n }\n });\n }\n\n if (typeof translation !== 'string') {\n console.error(`${key} is not string`, { key, lang, scope, params, translation });\n } else {\n // Replace translations like {{ t('key') }}\n const translationPattern = /{{\\s*t\\('([^']+)'\\)\\s*}}/g;\n translation = translation.replace(translationPattern, (match, innerKey) => {\n return this.getTranslation(innerKey, lang, scope, params);\n });\n }\n\n return translation;\n }\n\n public translate(key: string, options?: AXTranslateOptions): Observable<string> {\n if (options?.lang) {\n return this.load(key, options);\n }\n return this.langChanges$.pipe(\n startWith(this.getActiveLang()),\n switchMap((lang) => {\n return this.load(key, { ...options, lang: lang });\n }),\n );\n }\n\n public async translateAsync(key: string, options?: AXTranslateOptions): Promise<string> {\n const { lang = this.getActiveLang(), scope = this.config.defaultScope } = options || {};\n let translation = lodashGet(this.translationCache, `${lang}.${scope}.${key}`);\n\n if (!translation) {\n // If the translation is not in the cache, load it\n await firstValueFrom(this.load(key, { lang, scope }).pipe(take(1)));\n translation = lodashGet(this.translationCache, `${lang}.${scope}.${key}`);\n }\n\n // If still not available, try the last active language or default language\n if (!translation && this.lastActiveLang) {\n translation = lodashGet(this.translationCache, `${this.lastActiveLang}.${scope}.${key}`);\n }\n if (!translation) {\n translation = lodashGet(this.translationCache, `${this.getDefaultLang()}.${scope}.${key}`);\n }\n\n // Perform parameter replacement\n return this.getTranslation((translation || key) as any, lang, scope, options?.params);\n }\n\n public translateSync(key: string, options?: AXTranslateOptions): string {\n const { lang = this.getActiveLang(), scope = this.config.defaultScope } = options || {};\n\n // Check if the translation for the active language is available\n let translation = lodashGet(this.translationCache, `${lang}.${scope}.${key}`);\n\n //\n const loadLang = () => lastValueFrom(this.getOrLoadTranslations(lang, scope));\n // If not available, check lastActiveLang\n if (!translation && this.lastActiveLang) {\n loadLang();\n translation = lodashGet(this.translationCache, `${this.lastActiveLang}.${scope}.${key}`);\n }\n\n // If still not available, use the default language\n if (!translation) {\n loadLang();\n translation = lodashGet(this.translationCache, `${this.getDefaultLang()}.${scope}.${key}`);\n }\n\n // Perform parameter replacement\n return this.getTranslation((translation || key) as any, lang, scope, options?.params);\n }\n}\n","import { Pipe, PipeTransform } from '@angular/core';\nimport { AXTranslationService } from './translation.service';\nimport { Observable, of } from 'rxjs';\nimport { AXTranslateOptions } from './translation.types';\n\n@Pipe({ name: 'translate', pure: true }) // The pipe can now be pure\nexport class AXTranslatorPipe implements PipeTransform {\n constructor(private service: AXTranslationService) {}\n\n transform(key: string, options?: AXTranslateOptions): Observable<string> {\n if (!key) {\n return of(''); // Return an empty observable if the key is not provided\n }\n return this.service.translate(key, options);\n }\n}\n","import {\n Directive,\n OnInit,\n TemplateRef,\n ViewContainerRef,\n} from '@angular/core';\nimport { AXTranslationService } from './translation.service';\nimport { AXTranslateOptions } from './translation.types';\n\n@Directive({\n selector: '[translate]',\n})\nexport class AXTranslatorDirective implements OnInit {\n constructor(\n private templateRef: TemplateRef<any>,\n private viewContainer: ViewContainerRef,\n private translationService: AXTranslationService\n ) {}\n\n ngOnInit() {\n this.viewContainer.clear();\n this.viewContainer.createEmbeddedView(this.templateRef, {\n $implicit: (key: string, options?: AXTranslateOptions) => {\n return this.translationService.translate(key, options);\n },\n });\n }\n}\n","import { APP_INITIALIZER, NgModule } from '@angular/core';\nimport { AXTranslatorPipe } from './translator.pipe';\nimport { AXTranslatorDirective } from './translator.directive';\nimport { AXTranslationService } from './translation.service';\nimport { Observable } from 'rxjs';\nimport {\n AXTranslationConfig,\n AX_TRANSLATION_CONFIG,\n} from './translation.config';\n\nfunction initializeApp(\n translatorService: AXTranslationService,\n config: AXTranslationConfig\n) {\n return (): Observable<any> => {\n return translatorService.loadLanguagesAndScopes(\n config.preloadLangs ?? [config.defaultLang],\n config.preloadScopes ?? [config.defaultScope]\n );\n };\n}\n\n@NgModule({\n imports: [],\n exports: [AXTranslatorPipe, AXTranslatorDirective],\n declarations: [AXTranslatorPipe, AXTranslatorDirective],\n providers: [\n {\n provide: APP_INITIALIZER,\n useFactory: initializeApp,\n deps: [AXTranslationService, AX_TRANSLATION_CONFIG],\n multi: true,\n },\n ],\n})\nexport class AXTranslationModule {}\n","import { inject } from '@angular/core';\nimport { AXTranslationService } from './translation.service';\nimport { ResolveFn } from '@angular/router';\nimport { AX_TRANSLATION_CONFIG } from './translation.config';\n\nexport const loadTranslationScope: ResolveFn<unknown> = (route, state) => {\n const translatorService = inject(AXTranslationService);\n const config = inject(AX_TRANSLATION_CONFIG);\n const scopeValue = route.data[config.scopeResolverKey];\n const scopes = Array.isArray(scopeValue) ? scopeValue : [scopeValue];\n return translatorService.loadLanguagesAndScopes(\n [translatorService.getActiveLang()],\n scopes\n );\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["lodashSet","lodashGet","i1.AXTranslationService"],"mappings":";;;;;;MAYa,qBAAqB,GAAG,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AM,CAAC,gBAAgB,CAAC,CAAC;AACvD,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,UAAU,CAAC,CAAC;AACrE,IAAA,OAAO,iBAAiB,CAAC,sBAAsB,CAC7C,CAAC,iBAAiB,CAAC,aAAa,EAAE,CAAC,EACnC,MAAM,CACP,CAAC;AACJ;;ACdA;;AAEG;;;;"}
|
1
|
+
{"version":3,"file":"acorex-core-translation.mjs","sources":["../../../../libs/core/translation/src/lib/translation.config.ts","../../../../libs/core/translation/src/lib/translation.loader.ts","../../../../libs/core/translation/src/lib/translation.service.ts","../../../../libs/core/translation/src/lib/translation-scope.resolver.ts","../../../../libs/core/translation/src/lib/translator.directive.ts","../../../../libs/core/translation/src/lib/translator.pipe.ts","../../../../libs/core/translation/src/lib/translation.module.ts","../../../../libs/core/translation/src/acorex-core-translation.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { AXTranslateLang, AXTranslateScope } from './translation.types';\n\nexport interface AXTranslationConfig {\n defaultLang: AXTranslateLang;\n defaultScope: AXTranslateScope;\n preloadLangs?: AXTranslateLang[];\n preloadScopes?: AXTranslateLang[];\n availableLangs?: AXTranslateLang[];\n scopeResolverKey: string;\n}\n\nexport const AX_TRANSLATION_CONFIG = new InjectionToken<AXTranslationConfig>('AX_TRANSLATION_CONFIG', {\n providedIn: 'root',\n factory: () => {\n return AXTranslationDefaultConfig;\n },\n});\n\nexport const AXTranslationDefaultConfig: AXTranslationConfig = {\n defaultLang: 'en',\n defaultScope: 'common',\n scopeResolverKey: 'scope',\n};\n\nexport type AXPartialTranslationConfig = Partial<AXTranslationConfig>;\n\nexport function translationConfig(config: AXPartialTranslationConfig = {}): AXTranslationConfig {\n const result = {\n ...AXTranslationDefaultConfig,\n ...config,\n };\n return result;\n}\n","import { InjectionToken } from '@angular/core';\nimport { Observable, of } from 'rxjs';\nimport { AXTranslateLang, AXTranslateScope, AXTranslation } from './translation.types';\n\nexport interface AXTranslationLoaderOptions {\n lang: AXTranslateLang;\n scope?: AXTranslateScope;\n}\n\nexport interface AXTranslationLoader {\n getTranslation(options: AXTranslationLoaderOptions): Observable<AXTranslation>;\n}\n\nexport class AXTranslationLoaderDefault implements AXTranslationLoader {\n getTranslation(options: AXTranslationLoaderOptions): Observable<AXTranslation> {\n return of({});\n }\n}\n\nexport const AX_TRANSLATION_LOADER = new InjectionToken<AXTranslationLoader>('AX_TRANSLATION_LOADER', {\n providedIn: 'root',\n factory: () => {\n return new AXTranslationLoaderDefault();\n },\n});\n","import { AXEventService, AXEventTypes } from '@acorex/core/events';\nimport { Injectable, inject } from '@angular/core';\nimport { get as lodashGet, set as lodashSet } from 'lodash-es';\nimport {\n BehaviorSubject,\n Observable,\n catchError,\n finalize,\n firstValueFrom,\n forkJoin,\n lastValueFrom,\n map,\n of,\n shareReplay,\n startWith,\n switchMap,\n take,\n tap,\n} from 'rxjs';\nimport { AX_TRANSLATION_CONFIG } from './translation.config';\nimport { AX_TRANSLATION_LOADER } from './translation.loader';\nimport { AXTranslateHashMap, AXTranslateOptions, AXTranslateParams } from './translation.types';\n\nlet service: AXTranslationService;\n\nexport function translateSync(key: string, options?: AXTranslateOptions): string {\n return service.translateSync(key, options);\n}\n\n@Injectable({ providedIn: 'root' })\nexport class AXTranslationService {\n private loader = inject(AX_TRANSLATION_LOADER);\n private config = inject(AX_TRANSLATION_CONFIG);\n\n private eventService = inject(AXEventService);\n\n private translationCache: AXTranslateHashMap<AXTranslateHashMap<string>> = {};\n private ongoingRequests: Map<string, Observable<any>> = new Map();\n\n private activeLang: BehaviorSubject<string> = new BehaviorSubject<string>(this.getDefaultLang());\n langChanges$: Observable<string> = this.activeLang.asObservable();\n\n private lastActiveLang: string | null = null;\n\n /**\n * @ignore\n */\n constructor() {\n service = this;\n }\n\n public loadLanguagesAndScopes(languages: string[], scopes: string[]): Observable<unknown> {\n const requests = languages.flatMap((lang) =>\n scopes.map((scope) => {\n // Check if translations are already cached\n if (this.translationCache[lang]?.[scope]) {\n return of(this.translationCache[lang][scope]);\n }\n\n // Use the new method to handle ongoing requests and loading\n return this.getOrLoadTranslations(lang, scope);\n }),\n );\n\n return forkJoin(requests);\n }\n\n private getOrLoadTranslations(lang: string, scope: string): Observable<AXTranslateHashMap<string>> {\n const requestKey = `${lang}_${scope}`;\n\n // Return existing observable if the request is already in progress\n if (this.ongoingRequests.has(requestKey)) {\n return this.ongoingRequests.get(requestKey);\n }\n\n // Load translations if not in cache or ongoing requests\n const translationObservable = this.loader.getTranslation({ lang, scope }).pipe(\n tap((translations) => this.cacheTranslations(lang, scope, translations)),\n catchError((error) => {\n console.error(`Error loading translations for lang: ${lang}, scope: ${scope}`, error);\n return of(null);\n }),\n finalize(() => {\n this.eventService.emitEvent({\n type: AXEventTypes.AXLanguageLoaded,\n payload: lang,\n });\n this.ongoingRequests.delete(requestKey);\n }),\n shareReplay(1),\n );\n\n this.ongoingRequests.set(requestKey, translationObservable);\n return translationObservable;\n }\n\n private cacheTranslations(lang: string, scope: string, translations: AXTranslateHashMap<string>): void {\n lodashSet(this.translationCache, `${lang}.${scope}`, translations);\n }\n\n public getDefaultLang(): string {\n return this.config.defaultLang;\n }\n\n public getActiveLang(): string {\n return this.activeLang.getValue();\n }\n\n public setActiveLang(lang: string): void {\n if (lang != this.getActiveLang()) {\n this.lastActiveLang = this.getActiveLang(); // Update last active language\n this.activeLang.next(lang);\n this.eventService.emitEvent({\n type: AXEventTypes.AXLanguageChanged,\n payload: lang,\n });\n }\n }\n\n public isLangAvailable(lang: string, scope: string = null): boolean {\n return !this.translationCache[lang] && (!scope || !this.translationCache[lang][scope]);\n }\n\n private load(key: string, options: AXTranslateOptions = {}): Observable<string> {\n const { lang = this.getActiveLang(), scope = this.config.defaultScope } = options;\n\n // Function to fetch translation\n const fetchTranslation = (language: string): Observable<string> => {\n // Check if translations are available in the cache\n if (this.translationCache[language]?.[scope]) {\n return of(this.getTranslation(key, language, scope, options.params));\n }\n\n // Use the new method to handle ongoing requests and loading\n return this.getOrLoadTranslations(language, scope).pipe(\n map(() => {\n const translation = this.translationCache[language]?.[scope]?.[key] || key;\n return this.getTranslation(translation, language, scope, options.params);\n }),\n switchMap((translatedText) => {\n if (translatedText === key && language !== this.getDefaultLang()) {\n // If the translation is not found and the language is not default,\n // try fetching from the default language\n return fetchTranslation(this.getDefaultLang());\n }\n return of(translatedText);\n }),\n );\n };\n\n // First, try to fetch the translation for the requested language\n const translationForRequestedLang = fetchTranslation(lang);\n\n // If lastActiveLang is available and different from the requested language, use it as a fallback\n if (this.lastActiveLang && this.lastActiveLang !== lang) {\n const translationForLastActiveLang = this.getTranslation(key, this.lastActiveLang, scope, options.params);\n return translationForRequestedLang.pipe(startWith(translationForLastActiveLang));\n }\n\n return translationForRequestedLang;\n }\n\n private getTranslation(key: string, lang: string, scope: string, params?: AXTranslateParams): string {\n let translation: string = (lodashGet(this.translationCache, `${lang}.${scope}.${key}`) || key) as string;\n\n // Replace params like {{ name }}\n if (params) {\n Object.keys(params).forEach((paramKey) => {\n const paramValue = params[paramKey] as string;\n if (typeof translation !== 'string') {\n console.error(`${key} is not string`, { key, lang, scope, params, translation });\n } else {\n translation = translation.replace(new RegExp(`{{\\\\s*${paramKey}\\\\s*}}`, 'g'), paramValue);\n }\n });\n }\n\n if (typeof translation !== 'string') {\n console.error(`${key} is not string`, { key, lang, scope, params, translation });\n } else {\n // Replace translations like {{ t('key') }}\n const translationPattern = /{{\\s*t\\('([^']+)'\\)\\s*}}/g;\n translation = translation.replace(translationPattern, (match, innerKey) => {\n return this.getTranslation(innerKey, lang, scope, params);\n });\n }\n\n return translation;\n }\n\n public translate(key: string, options?: AXTranslateOptions): Observable<string> {\n if (options?.lang) {\n return this.load(key, options);\n }\n return this.langChanges$.pipe(\n startWith(this.getActiveLang()),\n switchMap((lang) => {\n return this.load(key, { ...options, lang: lang });\n }),\n );\n }\n\n public async translateAsync(key: string, options?: AXTranslateOptions): Promise<string> {\n const { lang = this.getActiveLang(), scope = this.config.defaultScope } = options || {};\n let translation = lodashGet(this.translationCache, `${lang}.${scope}.${key}`);\n\n if (!translation) {\n // If the translation is not in the cache, load it\n await firstValueFrom(this.load(key, { lang, scope }).pipe(take(1)));\n translation = lodashGet(this.translationCache, `${lang}.${scope}.${key}`);\n }\n\n // If still not available, try the last active language or default language\n if (!translation && this.lastActiveLang) {\n translation = lodashGet(this.translationCache, `${this.lastActiveLang}.${scope}.${key}`);\n }\n if (!translation) {\n translation = lodashGet(this.translationCache, `${this.getDefaultLang()}.${scope}.${key}`);\n }\n\n // Perform parameter replacement\n return this.getTranslation((translation || key) as any, lang, scope, options?.params);\n }\n\n public translateSync(key: string, options?: AXTranslateOptions): string {\n const { lang = this.getActiveLang(), scope = this.config.defaultScope } = options || {};\n\n // Check if the translation for the active language is available\n let translation = lodashGet(this.translationCache, `${lang}.${scope}.${key}`);\n\n //\n const loadLang = () => lastValueFrom(this.getOrLoadTranslations(lang, scope));\n // If not available, check lastActiveLang\n if (!translation && this.lastActiveLang) {\n loadLang();\n translation = lodashGet(this.translationCache, `${this.lastActiveLang}.${scope}.${key}`);\n }\n\n // If still not available, use the default language\n if (!translation) {\n loadLang();\n translation = lodashGet(this.translationCache, `${this.getDefaultLang()}.${scope}.${key}`);\n }\n\n // Perform parameter replacement\n return this.getTranslation((translation || key) as any, lang, scope, options?.params);\n }\n}\n","import { inject } from '@angular/core';\nimport { ResolveFn } from '@angular/router';\nimport { AX_TRANSLATION_CONFIG } from './translation.config';\nimport { AXTranslationService } from './translation.service';\n\nexport const loadTranslationScope: ResolveFn<unknown> = (route, state) => {\n const translatorService = inject(AXTranslationService);\n const config = inject(AX_TRANSLATION_CONFIG);\n const scopeValue = route.data[config.scopeResolverKey];\n const scopes = Array.isArray(scopeValue) ? scopeValue : [scopeValue];\n return translatorService.loadLanguagesAndScopes([translatorService.getActiveLang()], scopes);\n};\n","import { Directive, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';\nimport { AXTranslationService } from './translation.service';\nimport { AXTranslateOptions } from './translation.types';\n\n@Directive({\n selector: '[translate]',\n})\nexport class AXTranslatorDirective implements OnInit {\n constructor(\n private templateRef: TemplateRef<any>,\n private viewContainer: ViewContainerRef,\n private translationService: AXTranslationService,\n ) {}\n\n ngOnInit() {\n this.viewContainer.clear();\n this.viewContainer.createEmbeddedView(this.templateRef, {\n $implicit: (key: string, options?: AXTranslateOptions) => {\n return this.translationService.translate(key, options);\n },\n });\n }\n}\n","import { Pipe, PipeTransform } from '@angular/core';\nimport { Observable, of } from 'rxjs';\nimport { AXTranslationService } from './translation.service';\nimport { AXTranslateOptions } from './translation.types';\n\n@Pipe({ name: 'translate', pure: true }) // The pipe can now be pure\nexport class AXTranslatorPipe implements PipeTransform {\n constructor(private service: AXTranslationService) {}\n\n transform(key: string, options?: AXTranslateOptions): Observable<string> {\n if (!key) {\n return of(''); // Return an empty observable if the key is not provided\n }\n return this.service.translate(key, options);\n }\n}\n","import { APP_INITIALIZER, NgModule } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { AXTranslationConfig, AX_TRANSLATION_CONFIG } from './translation.config';\nimport { AXTranslationService } from './translation.service';\nimport { AXTranslatorDirective } from './translator.directive';\nimport { AXTranslatorPipe } from './translator.pipe';\n\nfunction initializeApp(translatorService: AXTranslationService, config: AXTranslationConfig) {\n return (): Observable<any> => {\n return translatorService.loadLanguagesAndScopes(\n config.preloadLangs ?? [config.defaultLang],\n config.preloadScopes ?? [config.defaultScope],\n );\n };\n}\n\n@NgModule({\n imports: [],\n exports: [AXTranslatorPipe, AXTranslatorDirective],\n declarations: [AXTranslatorPipe, AXTranslatorDirective],\n providers: [\n {\n provide: APP_INITIALIZER,\n useFactory: initializeApp,\n deps: [AXTranslationService, AX_TRANSLATION_CONFIG],\n multi: true,\n },\n ],\n})\nexport class AXTranslationModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["lodashSet","lodashGet","i1.AXTranslationService"],"mappings":";;;;;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,EAAE,CAAC,gBAAgB,EAAE,qBAAqB,CAAC;AACvD,oBAAA,SAAS,EAAE;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,eAAe;AACxB,4BAAA,UAAU,EAAE,aAAa;AACzB,4BAAA,IAAI,EAAE,CAAC,oBAAoB,EAAE,qBAAqB,CAAC;AACnD,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;AACF,qBAAA;AACF,iBAAA,CAAA;;;AC5BD;;AAEG;;;;"}
|
@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
|
|
3
3
|
import { Subject, takeUntil } from 'rxjs';
|
4
4
|
import tinycolor from 'tinycolor2';
|
5
5
|
import tinygradient from 'tinygradient-es';
|
6
|
+
import { isBrowser } from '@acorex/core/platform';
|
6
7
|
|
7
8
|
function AXAutoUnsubscriber() {
|
8
9
|
return function (constructor) {
|
@@ -131,9 +132,7 @@ class AXColorUtil {
|
|
131
132
|
X * 0.051713 - Y * 0.121364 + Z * 1.01153,
|
132
133
|
];
|
133
134
|
// Apply reverse gamma correction.
|
134
|
-
rgb = rgb.map((x) => x <= 0.0031308
|
135
|
-
? 12.92 * x
|
136
|
-
: (1.0 + 0.055) * Math.pow(x, 1.0 / 2.4) - 0.055);
|
135
|
+
rgb = rgb.map((x) => (x <= 0.0031308 ? 12.92 * x : (1.0 + 0.055) * Math.pow(x, 1.0 / 2.4) - 0.055));
|
137
136
|
// Bring all negative components to zero.
|
138
137
|
rgb = rgb.map((x) => Math.max(0, x));
|
139
138
|
// If one component is greater than 1, weight components by that value.
|
@@ -151,10 +150,7 @@ class AXDrawingUtil {
|
|
151
150
|
static collision(a, b) {
|
152
151
|
const ac = a.getBoundingClientRect();
|
153
152
|
const bc = b.getBoundingClientRect();
|
154
|
-
if (ac.left < bc.left + bc.width &&
|
155
|
-
ac.left + ac.width > bc.left &&
|
156
|
-
ac.top < bc.top + bc.height &&
|
157
|
-
ac.top + ac.height > bc.top) {
|
153
|
+
if (ac.left < bc.left + bc.width && ac.left + ac.width > bc.left && ac.top < bc.top + bc.height && ac.top + ac.height > bc.top) {
|
158
154
|
return true;
|
159
155
|
}
|
160
156
|
else {
|
@@ -171,13 +167,10 @@ class AXDrawingUtil {
|
|
171
167
|
});
|
172
168
|
}
|
173
169
|
static isInRecPoint(pos, rec) {
|
174
|
-
return
|
175
|
-
pos.x <= rec.left + rec.width &&
|
176
|
-
pos.y >= rec.top &&
|
177
|
-
pos.y <= rec.top + rec.height);
|
170
|
+
return pos.x >= rec.left && pos.x <= rec.left + rec.width && pos.y >= rec.top && pos.y <= rec.top + rec.height;
|
178
171
|
}
|
179
172
|
static convertRemToPixels(rem) {
|
180
|
-
return
|
173
|
+
return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
181
174
|
}
|
182
175
|
}
|
183
176
|
|
@@ -205,8 +198,11 @@ class AXHtmlUtil {
|
|
205
198
|
return element.matches(':focus-within') || element.matches(':focus');
|
206
199
|
}
|
207
200
|
static isRtl(element) {
|
208
|
-
|
209
|
-
|
201
|
+
if (isBrowser()) {
|
202
|
+
const rtl = element.classList.contains('ax-rtl') || window.getComputedStyle(element, null).getPropertyValue('direction') === 'rtl';
|
203
|
+
return rtl;
|
204
|
+
}
|
205
|
+
return false;
|
210
206
|
}
|
211
207
|
}
|
212
208
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"acorex-core-utils.mjs","sources":["../../../../libs/core/utils/src/lib/auto-unsubscribe.ts","../../../../libs/core/utils/src/lib/color-util.ts","../../../../libs/core/utils/src/lib/drawing-util.ts","../../../../libs/core/utils/src/lib/html-util.ts","../../../../libs/core/utils/src/lib/string-util.ts","../../../../libs/core/utils/src/acorex-core-utils.ts"],"sourcesContent":["import { Injectable, OnDestroy } from '@angular/core';\nimport { Observable, Subject, takeUntil } from 'rxjs';\n\nexport function AXAutoUnsubscriber() {\n return function (constructor) {\n const orig = constructor.prototype.ngOnDestroy;\n constructor.prototype.ngOnDestroy = function () {\n for (const prop in this) {\n const property = this[prop];\n if (typeof property.subscribe === 'function') {\n property.unsubscribe();\n }\n }\n orig.apply();\n };\n };\n}\n\n@Injectable()\nexport class AXUnsubscriber implements OnDestroy {\n private readonly _destroy$ = new Subject<void>();\n\n public readonly takeUntilDestroy = <T>(\n origin: Observable<T> | Subject<T>\n ): Observable<T> | Subject<T> => origin.pipe(takeUntil(this._destroy$));\n\n public unsubscribe(): void {\n this._destroy$.next();\n this._destroy$.complete();\n }\n\n public ngOnDestroy(): void {\n this.unsubscribe();\n }\n}\n","export type AXColorMode = 'rgba' | 'hex' | 'hsla' | 'hsva' | null;\n\nimport tinycolor, { ColorInput } from 'tinycolor2';\nimport tinygradient, { Instance } from 'tinygradient-es';\n\nexport type AXColorFormat = ColorInput;\n\nexport class AXColorUtil {\n static to(color: AXColorFormat, mode: AXColorMode): AXColorFormat {\n const _color = tinycolor(color);\n switch (mode) {\n case 'rgba':\n return _color.toRgb();\n case 'hsla':\n return _color.toHsl();\n case 'hsva':\n return _color.toHsv();\n default:\n return _color.toHex();\n }\n }\n\n static toString(color: AXColorFormat, mode: AXColorMode = null): string {\n const _color = tinycolor(color);\n switch (mode) {\n case 'rgba':\n return _color.toRgbString();\n case 'hsla':\n return _color.toHslString();\n case 'hsva':\n return _color.toHsvString();\n\n case 'hex': {\n const rgba = _color.toRgb();\n return rgba.a != 1 ? _color.toHex8String() : _color.toHexString();\n }\n default: {\n if (typeof color == 'string') {\n if (color.toLowerCase().startsWith('#'))\n return this.toString(color, 'hex');\n else return this.toString(color, 'rgba');\n } else {\n return this.toString(color, 'rgba');\n }\n }\n }\n }\n\n static isValid(color: AXColorFormat): boolean {\n const _color = tinycolor(color);\n return _color.isValid();\n }\n\n static mix(\n baseColor: AXColorFormat,\n hex: AXColorFormat,\n percentage: number\n ): string {\n return tinycolor.mix(baseColor, hex, percentage).toString('rgb');\n }\n\n static multiply(color1: AXColorFormat, color2: AXColorFormat): string {\n const rgb1 = tinycolor(color1).toRgb();\n const rgb2 = tinycolor(color2).toRgb();\n rgb1.b = Math.floor((rgb1.b * rgb2.b) / 255);\n rgb1.g = Math.floor((rgb1.g * rgb2.g) / 255);\n rgb1.r = Math.floor((rgb1.r * rgb2.r) / 255);\n return tinycolor('rgb ' + rgb1.r + ' ' + rgb1.g + ' ' + rgb1.b).toString(\n 'rgb'\n );\n }\n\n static contrastToWhite(color: AXColorFormat): number {\n return tinycolor.readability('#fff', color);\n }\n\n static lighten(hex: AXColorFormat, percentage?: number) {\n return tinycolor(hex).lighten(percentage);\n }\n\n static darken(hex: AXColorFormat, percentage?: number) {\n return tinycolor(hex).darken(percentage);\n }\n\n static brighten(hex: AXColorFormat, percentage?: number) {\n return tinycolor(hex).brighten(percentage);\n }\n\n static saturate(hex: AXColorFormat, percentage?: number) {\n return tinycolor(hex).saturate(percentage);\n }\n\n static desaturate(hex: AXColorFormat) {\n return tinycolor(hex).getLuminance();\n }\n\n static equal(color1: AXColorFormat, color2: AXColorFormat): boolean {\n return tinycolor.equals(color1, color2);\n }\n\n static gradient(\n values: unknown[] | { color: unknown; pos: number }[]\n ): Instance {\n return tinygradient([...values]);\n }\n\n static getLuminance(hex: AXColorFormat) {\n return tinycolor(hex).getLuminance();\n }\n\n static xyToRgb(vX, vY): string {\n vY = vY || 0.00000000001;\n const Y = 1;\n const X = (Y / vY) * vX;\n const Z = (Y / vY) * (1 - vX - vY);\n\n // Convert to RGB using Wide RGB D65 conversion.\n let rgb = [\n X * 1.656492 - Y * 0.354851 - Z * 0.255038,\n -X * 0.707196 + Y * 1.655397 + Z * 0.036152,\n X * 0.051713 - Y * 0.121364 + Z * 1.01153,\n ];\n\n // Apply reverse gamma correction.\n rgb = rgb.map((x) =>\n x <= 0.0031308\n ? 12.92 * x\n : (1.0 + 0.055) * Math.pow(x, 1.0 / 2.4) - 0.055\n );\n\n // Bring all negative components to zero.\n rgb = rgb.map((x) => Math.max(0, x));\n\n // If one component is greater than 1, weight components by that value.\n const max = Math.max(...rgb);\n if (max > 1) {\n rgb = rgb.map((x) => x / max);\n }\n\n rgb = rgb.map((x) => Math.round(x * 255));\n\n return 'rgb(' + rgb.join(',') + ')';\n }\n}\n","export interface AXPoint {\n x: number;\n y: number;\n}\n\nexport interface AXBoundingClientRect {\n left?: number;\n top?: number;\n width?: number;\n height?: number;\n bottom?: number;\n right?: number;\n}\n// @dynamic\nexport class AXDrawingUtil {\n static collision(a: HTMLElement, b: HTMLElement): boolean {\n const ac = a.getBoundingClientRect();\n const bc = b.getBoundingClientRect();\n\n if (\n ac.left < bc.left + bc.width &&\n ac.left + ac.width > bc.left &&\n ac.top < bc.top + bc.height &&\n ac.top + ac.height > bc.top\n ) {\n return true;\n } else {\n return false;\n }\n }\n\n static isInElementBound(pos: AXPoint, element: HTMLElement): boolean {\n const elBound = element.getBoundingClientRect();\n return AXDrawingUtil.isInRecPoint(pos, {\n left: elBound.x,\n width: elBound.width,\n top: elBound.y,\n height: elBound.height,\n });\n }\n\n static isInRecPoint(pos: AXPoint, rec: AXBoundingClientRect | any): boolean {\n return (\n pos.x >= rec.left &&\n pos.x <= rec.left + rec.width &&\n pos.y >= rec.top &&\n pos.y <= rec.top + rec.height\n );\n }\n\n static convertRemToPixels(rem: number): number {\n return (\n rem * parseFloat(getComputedStyle(document.documentElement).fontSize)\n );\n }\n}\n","// @dynamic\nexport class AXHtmlUtil {\n static focusElement(element: HTMLElement): HTMLElement {\n const list = ['button', 'input', '[href]', 'select', 'textarea', '[tabindex]'].map((c) => c + ':not([tabindex=\"-1\"])');\n const focusable = element.querySelector<HTMLElement>(list.join(', '));\n if (focusable) {\n focusable.focus();\n return focusable;\n }\n return null;\n }\n static blurElement(element: HTMLElement): HTMLElement {\n const list = ['button', 'input', '[href]', 'select', 'textarea', '[tabindex]'].map((c) => c + ':not([tabindex=\"-1\"])');\n const focusable = element.querySelector<HTMLElement>(list.join(', '));\n if (focusable) {\n focusable.blur();\n return focusable;\n }\n return null;\n }\n\n static hasFocus(element: HTMLElement) {\n return element.matches(':focus-within') || element.matches(':focus');\n }\n\n static isRtl(element: HTMLElement) {\n const rtl = element.classList.contains('ax-rtl') || window.getComputedStyle(element, null).getPropertyValue('direction') === 'rtl';\n return rtl;\n }\n}\n","// @dynamic\nexport class AXStringUtil {\n static getWordBoundsAtPosition(\n str: string,\n position: number\n ): { start: number; end: number } {\n const isSpace = (c) => /[^a-zA-Z0-9]+/i.test(c);\n let start = position - 1;\n\n while (start >= 0 && !isSpace(str[start])) {\n start -= 1;\n }\n start = Math.max(0, start + 1);\n const leftSideString: any = str.slice(start).match(/[a-zA-Z0-9]+/i);\n start += leftSideString.index;\n let end = start + leftSideString[0].length;\n return {\n start,\n end,\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;SAGgB,kBAAkB,GAAA;AAChC,IAAA,OAAO,UAAU,WAAW,EAAA;AAC1B,QAAA,MAAM,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC;AAC/C,QAAA,WAAW,CAAC,SAAS,CAAC,WAAW,GAAG,YAAA;AAClC,YAAA,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;AACvB,gBAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,gBAAA,IAAI,OAAO,QAAQ,CAAC,SAAS,KAAK,UAAU,EAAE;oBAC5C,QAAQ,CAAC,WAAW,EAAE,CAAC;iBACxB;aACF;YACD,IAAI,CAAC,KAAK,EAAE,CAAC;AACf,SAAC,CAAC;AACJ,KAAC,CAAC;AACJ,CAAC;MAGY,cAAc,CAAA;AAD3B,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,SAAS,GAAG,IAAI,OAAO,EAAQ,CAAC;AAEjC,QAAA,IAAA,CAAA,gBAAgB,GAAG,CACjC,MAAkC,KACH,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;AAUzE,KAAA;IARQ,WAAW,GAAA;AAChB,QAA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C;AACpE,QAAA,KAAK,IAAI,cAAc,CAAC,KAAK,CAAC;QAC9B,IAAI,GAAG,GAAG,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC3C,OAAO;YACL,KAAK;YACL,GAAG;SACJ,CAAC;KACH;AACF;;ACrBD;;AAEG;;;;"}
|
1
|
+
{"version":3,"file":"acorex-core-utils.mjs","sources":["../../../../libs/core/utils/src/lib/auto-unsubscribe.ts","../../../../libs/core/utils/src/lib/color-util.ts","../../../../libs/core/utils/src/lib/drawing-util.ts","../../../../libs/core/utils/src/lib/html-util.ts","../../../../libs/core/utils/src/lib/string-util.ts","../../../../libs/core/utils/src/acorex-core-utils.ts"],"sourcesContent":["import { Injectable, OnDestroy } from '@angular/core';\nimport { Observable, Subject, takeUntil } from 'rxjs';\n\nexport function AXAutoUnsubscriber() {\n return function (constructor) {\n const orig = constructor.prototype.ngOnDestroy;\n constructor.prototype.ngOnDestroy = function () {\n for (const prop in this) {\n const property = this[prop];\n if (typeof property.subscribe === 'function') {\n property.unsubscribe();\n }\n }\n orig.apply();\n };\n };\n}\n\n@Injectable()\nexport class AXUnsubscriber implements OnDestroy {\n private readonly _destroy$ = new Subject<void>();\n\n public readonly takeUntilDestroy = <T>(origin: Observable<T> | Subject<T>): Observable<T> | Subject<T> =>\n origin.pipe(takeUntil(this._destroy$));\n\n public unsubscribe(): void {\n this._destroy$.next();\n this._destroy$.complete();\n }\n\n public ngOnDestroy(): void {\n this.unsubscribe();\n }\n}\n","export type AXColorMode = 'rgba' | 'hex' | 'hsla' | 'hsva' | null;\n\nimport tinycolor, { ColorInput } from 'tinycolor2';\nimport tinygradient, { Instance } from 'tinygradient-es';\n\nexport type AXColorFormat = ColorInput;\n\nexport class AXColorUtil {\n static to(color: AXColorFormat, mode: AXColorMode): AXColorFormat {\n const _color = tinycolor(color);\n switch (mode) {\n case 'rgba':\n return _color.toRgb();\n case 'hsla':\n return _color.toHsl();\n case 'hsva':\n return _color.toHsv();\n default:\n return _color.toHex();\n }\n }\n\n static toString(color: AXColorFormat, mode: AXColorMode = null): string {\n const _color = tinycolor(color);\n switch (mode) {\n case 'rgba':\n return _color.toRgbString();\n case 'hsla':\n return _color.toHslString();\n case 'hsva':\n return _color.toHsvString();\n\n case 'hex': {\n const rgba = _color.toRgb();\n return rgba.a != 1 ? _color.toHex8String() : _color.toHexString();\n }\n default: {\n if (typeof color == 'string') {\n if (color.toLowerCase().startsWith('#')) return this.toString(color, 'hex');\n else return this.toString(color, 'rgba');\n } else {\n return this.toString(color, 'rgba');\n }\n }\n }\n }\n\n static isValid(color: AXColorFormat): boolean {\n const _color = tinycolor(color);\n return _color.isValid();\n }\n\n static mix(baseColor: AXColorFormat, hex: AXColorFormat, percentage: number): string {\n return tinycolor.mix(baseColor, hex, percentage).toString('rgb');\n }\n\n static multiply(color1: AXColorFormat, color2: AXColorFormat): string {\n const rgb1 = tinycolor(color1).toRgb();\n const rgb2 = tinycolor(color2).toRgb();\n rgb1.b = Math.floor((rgb1.b * rgb2.b) / 255);\n rgb1.g = Math.floor((rgb1.g * rgb2.g) / 255);\n rgb1.r = Math.floor((rgb1.r * rgb2.r) / 255);\n return tinycolor('rgb ' + rgb1.r + ' ' + rgb1.g + ' ' + rgb1.b).toString('rgb');\n }\n\n static contrastToWhite(color: AXColorFormat): number {\n return tinycolor.readability('#fff', color);\n }\n\n static lighten(hex: AXColorFormat, percentage?: number) {\n return tinycolor(hex).lighten(percentage);\n }\n\n static darken(hex: AXColorFormat, percentage?: number) {\n return tinycolor(hex).darken(percentage);\n }\n\n static brighten(hex: AXColorFormat, percentage?: number) {\n return tinycolor(hex).brighten(percentage);\n }\n\n static saturate(hex: AXColorFormat, percentage?: number) {\n return tinycolor(hex).saturate(percentage);\n }\n\n static desaturate(hex: AXColorFormat) {\n return tinycolor(hex).getLuminance();\n }\n\n static equal(color1: AXColorFormat, color2: AXColorFormat): boolean {\n return tinycolor.equals(color1, color2);\n }\n\n static gradient(values: unknown[] | { color: unknown; pos: number }[]): Instance {\n return tinygradient([...values]);\n }\n\n static getLuminance(hex: AXColorFormat) {\n return tinycolor(hex).getLuminance();\n }\n\n static xyToRgb(vX, vY): string {\n vY = vY || 0.00000000001;\n const Y = 1;\n const X = (Y / vY) * vX;\n const Z = (Y / vY) * (1 - vX - vY);\n\n // Convert to RGB using Wide RGB D65 conversion.\n let rgb = [\n X * 1.656492 - Y * 0.354851 - Z * 0.255038,\n -X * 0.707196 + Y * 1.655397 + Z * 0.036152,\n X * 0.051713 - Y * 0.121364 + Z * 1.01153,\n ];\n\n // Apply reverse gamma correction.\n rgb = rgb.map((x) => (x <= 0.0031308 ? 12.92 * x : (1.0 + 0.055) * Math.pow(x, 1.0 / 2.4) - 0.055));\n\n // Bring all negative components to zero.\n rgb = rgb.map((x) => Math.max(0, x));\n\n // If one component is greater than 1, weight components by that value.\n const max = Math.max(...rgb);\n if (max > 1) {\n rgb = rgb.map((x) => x / max);\n }\n\n rgb = rgb.map((x) => Math.round(x * 255));\n\n return 'rgb(' + rgb.join(',') + ')';\n }\n}\n","export interface AXPoint {\n x: number;\n y: number;\n}\n\nexport interface AXBoundingClientRect {\n left?: number;\n top?: number;\n width?: number;\n height?: number;\n bottom?: number;\n right?: number;\n}\n// @dynamic\nexport class AXDrawingUtil {\n static collision(a: HTMLElement, b: HTMLElement): boolean {\n const ac = a.getBoundingClientRect();\n const bc = b.getBoundingClientRect();\n\n if (ac.left < bc.left + bc.width && ac.left + ac.width > bc.left && ac.top < bc.top + bc.height && ac.top + ac.height > bc.top) {\n return true;\n } else {\n return false;\n }\n }\n\n static isInElementBound(pos: AXPoint, element: HTMLElement): boolean {\n const elBound = element.getBoundingClientRect();\n return AXDrawingUtil.isInRecPoint(pos, {\n left: elBound.x,\n width: elBound.width,\n top: elBound.y,\n height: elBound.height,\n });\n }\n\n static isInRecPoint(pos: AXPoint, rec: AXBoundingClientRect | any): boolean {\n return pos.x >= rec.left && pos.x <= rec.left + rec.width && pos.y >= rec.top && pos.y <= rec.top + rec.height;\n }\n\n static convertRemToPixels(rem: number): number {\n return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);\n }\n}\n","import { isBrowser } from '@acorex/core/platform';\n\n// @dynamic\nexport class AXHtmlUtil {\n static focusElement(element: HTMLElement): HTMLElement {\n const list = ['button', 'input', '[href]', 'select', 'textarea', '[tabindex]'].map((c) => c + ':not([tabindex=\"-1\"])');\n const focusable = element.querySelector<HTMLElement>(list.join(', '));\n if (focusable) {\n focusable.focus();\n return focusable;\n }\n return null;\n }\n static blurElement(element: HTMLElement): HTMLElement {\n const list = ['button', 'input', '[href]', 'select', 'textarea', '[tabindex]'].map((c) => c + ':not([tabindex=\"-1\"])');\n const focusable = element.querySelector<HTMLElement>(list.join(', '));\n if (focusable) {\n focusable.blur();\n return focusable;\n }\n return null;\n }\n\n static hasFocus(element: HTMLElement) {\n return element.matches(':focus-within') || element.matches(':focus');\n }\n\n static isRtl(element: HTMLElement) {\n if (isBrowser()) {\n const rtl = element.classList.contains('ax-rtl') || window.getComputedStyle(element, null).getPropertyValue('direction') === 'rtl';\n return rtl;\n }\n return false;\n }\n}\n","// @dynamic\nexport class AXStringUtil {\n static getWordBoundsAtPosition(str: string, position: number): { start: number; end: number } {\n const isSpace = (c) => /[^a-zA-Z0-9]+/i.test(c);\n let start = position - 1;\n\n while (start >= 0 && !isSpace(str[start])) {\n start -= 1;\n }\n start = Math.max(0, start + 1);\n const leftSideString: any = str.slice(start).match(/[a-zA-Z0-9]+/i);\n start += leftSideString.index;\n let end = start + leftSideString[0].length;\n return {\n start,\n end,\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;SAGgB,kBAAkB,GAAA;AAChC,IAAA,OAAO,UAAU,WAAW,EAAA;AAC1B,QAAA,MAAM,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC;AAC/C,QAAA,WAAW,CAAC,SAAS,CAAC,WAAW,GAAG,Y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AAgB,CAAC,WAAW,CAAC,KAAK,KAAK,CAAC;AACnI,YAAA,OAAO,GAAG,CAAC;SACZ;AACD,QAAA,OAAO,KAAK,CAAC;KACd;AACF;;AClCD;MACa,YAAY,CAAA;AACvB,IAAA,OAAO,uBAAuB,CAAC,GAAW,EAAE,QAAgB,EAAA;AAC1D,QAAA,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAChD,QAAA,IAAI,KAAK,GAAG,QAAQ,GAAG,CAAC,CAAC;AAEzB,QAAA,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;YACzC,KAAK,IAAI,CAAC,CAAC;SACZ;QACD,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;AAC/B,QAAA,MAAM,cAAc,GAAQ,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AACpE,QAAA,KAAK,IAAI,cAAc,CAAC,KAAK,CAAC;QAC9B,IAAI,GAAG,GAAG,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC3C,OAAO;YACL,KAAK;YACL,GAAG;SACJ,CAAC;KACH;AACF;;AClBD;;AAEG;;;;"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
2
|
import { Injectable, inject, InjectionToken, Injector, NgModule, Inject } from '@angular/core';
|
3
|
-
import { isString, isEmpty, isNull, isUndefined, isNumber, isArray, find, isEqual, merge } from 'lodash-es';
|
4
3
|
import * as i1 from '@acorex/core/translation';
|
5
4
|
import { AXTranslationService } from '@acorex/core/translation';
|
5
|
+
import { isString, isEmpty, isNull, isUndefined, isNumber, isArray, find, isEqual, merge } from 'lodash-es';
|
6
6
|
|
7
7
|
class AXCallbackValidationRule {
|
8
8
|
get name() {
|
@@ -47,9 +47,7 @@ class AXRegexValidationRule {
|
|
47
47
|
}
|
48
48
|
async validate(value, options) {
|
49
49
|
// Convert string pattern to RegExp if necessary
|
50
|
-
const regexPattern = typeof options.pattern === 'string'
|
51
|
-
? new RegExp(options.pattern)
|
52
|
-
: options.pattern;
|
50
|
+
const regexPattern = typeof options.pattern === 'string' ? new RegExp(options.pattern) : options.pattern;
|
53
51
|
if (!value || (isString(value) && isEmpty(value.trim()))) {
|
54
52
|
return {
|
55
53
|
rule: this.name,
|
@@ -67,8 +65,7 @@ class AXRegexValidationRule {
|
|
67
65
|
};
|
68
66
|
}
|
69
67
|
const isValid = regexPattern.test(value);
|
70
|
-
const translatedMessage = await this.traslationService.translateAsync(options?.message ??
|
71
|
-
`The value does not match the pattern ${regexPattern}.`, { params: { title: options?.['title'] } });
|
68
|
+
const translatedMessage = await this.traslationService.translateAsync(options?.message ?? `The value does not match the pattern ${regexPattern}.`, { params: { title: options?.['title'] } });
|
72
69
|
return {
|
73
70
|
rule: this.name,
|
74
71
|
result: isValid,
|
@@ -99,7 +96,9 @@ class AXRequiredValidationRule {
|
|
99
96
|
];
|
100
97
|
const failedRule = find(rules, (rule) => rule.test(value));
|
101
98
|
const isValid = !failedRule;
|
102
|
-
const translatedMessage = await this.traslationService.translateAsync('validation.messages.required', {
|
99
|
+
const translatedMessage = await this.traslationService.translateAsync('validation.messages.required', {
|
100
|
+
params: { title: options?.['title'] },
|
101
|
+
});
|
103
102
|
const message = failedRule ? options?.message ?? translatedMessage : null;
|
104
103
|
return {
|
105
104
|
rule: this.name,
|
@@ -125,10 +124,7 @@ class AXLengthValidationRule {
|
|
125
124
|
return {
|
126
125
|
rule: this.name,
|
127
126
|
result: isValid,
|
128
|
-
message: isValid
|
129
|
-
? null
|
130
|
-
: options?.message ??
|
131
|
-
`The value must be between ${options.min} and ${options.max} chars`,
|
127
|
+
message: isValid ? null : options?.message ?? `The value must be between ${options.min} and ${options.max} chars`,
|
132
128
|
value: value,
|
133
129
|
};
|
134
130
|
}
|
@@ -149,10 +145,7 @@ class AXMaxLengthValidationRule {
|
|
149
145
|
return {
|
150
146
|
rule: this.name,
|
151
147
|
result: isValid,
|
152
|
-
message: isValid
|
153
|
-
? ''
|
154
|
-
: options?.message ??
|
155
|
-
`The value must not exceed ${options.value} characters.`,
|
148
|
+
message: isValid ? '' : options?.message ?? `The value must not exceed ${options.value} characters.`,
|
156
149
|
value: value,
|
157
150
|
};
|
158
151
|
}
|
@@ -172,10 +165,7 @@ class AXMinLengthValidationRule {
|
|
172
165
|
return {
|
173
166
|
rule: this.name,
|
174
167
|
result: isValid,
|
175
|
-
message: isValid
|
176
|
-
? ''
|
177
|
-
: options?.message ??
|
178
|
-
`The value must be at least ${options.value} characters long.`,
|
168
|
+
message: isValid ? '' : options?.message ?? `The value must be at least ${options.value} characters long.`,
|
179
169
|
value: value,
|
180
170
|
};
|
181
171
|
}
|
@@ -243,11 +233,7 @@ class AXGreaterThanValidationRule {
|
|
243
233
|
return 'greaterThan';
|
244
234
|
}
|
245
235
|
async validate(value, options) {
|
246
|
-
const isValid = isNull(value) || isUndefined(value)
|
247
|
-
? true
|
248
|
-
: options.inclusive
|
249
|
-
? value >= options.value
|
250
|
-
: value > options.value;
|
236
|
+
const isValid = isNull(value) || isUndefined(value) ? true : options.inclusive ? value >= options.value : value > options.value;
|
251
237
|
const baseMessage = `The value must be ${options.inclusive ? 'greater than or equal to' : 'greater than'} ${options.value}.`;
|
252
238
|
return {
|
253
239
|
rule: this.name,
|
@@ -269,11 +255,7 @@ class AXLessThanValidationRule {
|
|
269
255
|
return 'lessThan';
|
270
256
|
}
|
271
257
|
async validate(value, options) {
|
272
|
-
const isValid = isNull(value) || isUndefined(value)
|
273
|
-
? true
|
274
|
-
: options.inclusive
|
275
|
-
? value <= options.value
|
276
|
-
: value < options.value;
|
258
|
+
const isValid = isNull(value) || isUndefined(value) ? true : options.inclusive ? value <= options.value : value < options.value;
|
277
259
|
const baseMessage = `The value must be ${options.inclusive ? 'less than or equal to' : 'less than'} ${options.value}.`;
|
278
260
|
return {
|
279
261
|
rule: this.name,
|