@koalarx/ui 20.0.7 → 20.0.8
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.
|
@@ -58,26 +58,26 @@ function generateQuerySelector(elem) {
|
|
|
58
58
|
|
|
59
59
|
class HttpErrorFeedbackAlert {
|
|
60
60
|
snackbar = inject(Snackbar);
|
|
61
|
-
httpClientErrorsMiddleware = AppConfig.httpClientErrorsMiddleware;
|
|
62
|
-
translations = AppConfig.translation.feedbackRequestInterceptor;
|
|
63
61
|
tapError(error) {
|
|
62
|
+
const httpClientErrorsMiddleware = AppConfig.httpClientErrorsMiddleware;
|
|
63
|
+
const translations = AppConfig.translation.feedbackRequestInterceptor;
|
|
64
64
|
const statusCode = error.status.toString();
|
|
65
65
|
if (statusCode.charAt(0) === '4') {
|
|
66
66
|
console.warn(error);
|
|
67
|
-
this.snackbar.warning(
|
|
68
|
-
|
|
67
|
+
this.snackbar.warning(httpClientErrorsMiddleware?.handleError(error) ??
|
|
68
|
+
translations[statusCode]);
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
else if (statusCode.charAt(0) === '5') {
|
|
72
72
|
console.error(error);
|
|
73
|
-
this.snackbar.error(
|
|
74
|
-
|
|
73
|
+
this.snackbar.error(httpClientErrorsMiddleware?.handleError(error) ??
|
|
74
|
+
translations[statusCode]);
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
78
|
console.info(error);
|
|
79
|
-
this.snackbar.info(
|
|
80
|
-
|
|
79
|
+
this.snackbar.info(httpClientErrorsMiddleware?.handleError(error) ??
|
|
80
|
+
translations.unknowError);
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"koalarx-ui-shared-utils.mjs","sources":["../../projects/koala-ui/shared/utils/is-empty.ts","../../projects/koala-ui/shared/utils/generate-query-selector.ts","../../projects/koala-ui/shared/utils/http-error-feedback-alert.ts","../../projects/koala-ui/shared/utils/koalarx-ui-shared-utils.ts"],"sourcesContent":["export function isEmpty(value: any) {\n return value === null || value === undefined || value === ''\n}\n","export function generateQuerySelector(elem: HTMLElement): string {\n const { tagName, id, className, parentElement } = elem;\n\n let str = '';\n\n if (id !== '' && id.match(/^[a-z].*/)) {\n str += `#${id}`;\n return str;\n }\n\n str = tagName.toLowerCase();\n\n if (className) {\n str +=\n '.' +\n className\n .replace(/(^\\s)/gm, '')\n .replace(/(\\s{2,})/gm, ' ')\n .split(/\\s/)\n .filter((c) => !/[[,\\]]/.test(c))\n .join('.');\n }\n\n const needNthPart = (el: HTMLElement): boolean => {\n let sib = el.previousElementSibling;\n\n if (!el.className) {\n return true;\n }\n\n while (sib) {\n if (el.className !== sib.className) {\n return false;\n }\n\n sib = sib.previousElementSibling;\n }\n\n return false;\n };\n\n const getNthPart = (el: HTMLElement): string => {\n let childIndex = 1;\n\n let sib = el.previousElementSibling;\n while (sib) {\n childIndex++;\n sib = sib.previousElementSibling;\n }\n\n return `:nth-child(${childIndex})`;\n };\n\n if (needNthPart(elem)) {\n str += getNthPart(elem);\n }\n\n if (!parentElement) {\n return str;\n }\n\n return `${generateQuerySelector(parentElement)} > ${str}`;\n}\n","import { HttpErrorResponse } from '@angular/common/http';\r\nimport { inject, Injectable } from '@angular/core';\r\nimport { AppConfig } from '@koalarx/ui/core/config';\r\nimport { Snackbar } from '@koalarx/ui/shared/components/snackbar';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class HttpErrorFeedbackAlert {\r\n private readonly snackbar = inject(Snackbar);\r\n
|
|
1
|
+
{"version":3,"file":"koalarx-ui-shared-utils.mjs","sources":["../../projects/koala-ui/shared/utils/is-empty.ts","../../projects/koala-ui/shared/utils/generate-query-selector.ts","../../projects/koala-ui/shared/utils/http-error-feedback-alert.ts","../../projects/koala-ui/shared/utils/koalarx-ui-shared-utils.ts"],"sourcesContent":["export function isEmpty(value: any) {\n return value === null || value === undefined || value === ''\n}\n","export function generateQuerySelector(elem: HTMLElement): string {\n const { tagName, id, className, parentElement } = elem;\n\n let str = '';\n\n if (id !== '' && id.match(/^[a-z].*/)) {\n str += `#${id}`;\n return str;\n }\n\n str = tagName.toLowerCase();\n\n if (className) {\n str +=\n '.' +\n className\n .replace(/(^\\s)/gm, '')\n .replace(/(\\s{2,})/gm, ' ')\n .split(/\\s/)\n .filter((c) => !/[[,\\]]/.test(c))\n .join('.');\n }\n\n const needNthPart = (el: HTMLElement): boolean => {\n let sib = el.previousElementSibling;\n\n if (!el.className) {\n return true;\n }\n\n while (sib) {\n if (el.className !== sib.className) {\n return false;\n }\n\n sib = sib.previousElementSibling;\n }\n\n return false;\n };\n\n const getNthPart = (el: HTMLElement): string => {\n let childIndex = 1;\n\n let sib = el.previousElementSibling;\n while (sib) {\n childIndex++;\n sib = sib.previousElementSibling;\n }\n\n return `:nth-child(${childIndex})`;\n };\n\n if (needNthPart(elem)) {\n str += getNthPart(elem);\n }\n\n if (!parentElement) {\n return str;\n }\n\n return `${generateQuerySelector(parentElement)} > ${str}`;\n}\n","import { HttpErrorResponse } from '@angular/common/http';\r\nimport { inject, Injectable } from '@angular/core';\r\nimport { AppConfig } from '@koalarx/ui/core/config';\r\nimport { Snackbar } from '@koalarx/ui/shared/components/snackbar';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class HttpErrorFeedbackAlert {\r\n private readonly snackbar = inject(Snackbar);\r\n\r\n tapError(error: HttpErrorResponse) {\r\n const httpClientErrorsMiddleware = AppConfig.httpClientErrorsMiddleware;\r\n const translations = AppConfig.translation.feedbackRequestInterceptor;\r\n const statusCode = error.status.toString();\r\n\r\n if (statusCode.charAt(0) === '4') {\r\n console.warn(error);\r\n\r\n this.snackbar.warning(\r\n httpClientErrorsMiddleware?.handleError(error) ??\r\n (translations as any)[statusCode]\r\n );\r\n return;\r\n } else if (statusCode.charAt(0) === '5') {\r\n console.error(error);\r\n\r\n this.snackbar.error(\r\n httpClientErrorsMiddleware?.handleError(error) ??\r\n (translations as any)[statusCode]\r\n );\r\n return;\r\n } else {\r\n console.info(error);\r\n\r\n this.snackbar.info(\r\n httpClientErrorsMiddleware?.handleError(error) ??\r\n translations.unknowError\r\n );\r\n return;\r\n }\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAAM,SAAU,OAAO,CAAC,KAAU,EAAA;IAChC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE;AAC9D;;ACFM,SAAU,qBAAqB,CAAC,IAAiB,EAAA;IACrD,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,IAAI;IAEtD,IAAI,GAAG,GAAG,EAAE;IAEZ,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;AACrC,QAAA,GAAG,IAAI,CAAA,CAAA,EAAI,EAAE,CAAA,CAAE;AACf,QAAA,OAAO,GAAG;;AAGZ,IAAA,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE;IAE3B,IAAI,SAAS,EAAE;QACb,GAAG;YACD,GAAG;gBACH;AACG,qBAAA,OAAO,CAAC,SAAS,EAAE,EAAE;AACrB,qBAAA,OAAO,CAAC,YAAY,EAAE,GAAG;qBACzB,KAAK,CAAC,IAAI;AACV,qBAAA,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;qBAC/B,IAAI,CAAC,GAAG,CAAC;;AAGhB,IAAA,MAAM,WAAW,GAAG,CAAC,EAAe,KAAa;AAC/C,QAAA,IAAI,GAAG,GAAG,EAAE,CAAC,sBAAsB;AAEnC,QAAA,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE;AACjB,YAAA,OAAO,IAAI;;QAGb,OAAO,GAAG,EAAE;YACV,IAAI,EAAE,CAAC,SAAS,KAAK,GAAG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C,CAAC,CAAC,KAAK,GAAG,EAAE;AACvC,YAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;YAEpB,IAAI,CAAC,QAAQ,CAAC,KAAK,CACjB,0BAA0B,EAAE,WAAW,CAAC,KAAK,CAAC;AAC3C,gBAAA,YAAoB,CAAC,UAAU,CAAC,CACpC;YACD;;aACK;AACL,YAAA,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;YAEnB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAChB,0BAA0B,EAAE,WAAW,CAAC,KAAK,CAAC;gBAC5C,YAAY,CAAC,WAAW,CAC3B;YACD;;;uGA/BO,sBAAsB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAtB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,sBAAsB,cADT,MAAM,EAAA,CAAA;;2FACnB,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBADlC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACLlC;;AAEG;;;;"}
|
package/package.json
CHANGED
package/shared/utils/index.d.ts
CHANGED
|
@@ -7,8 +7,6 @@ declare function generateQuerySelector(elem: HTMLElement): string;
|
|
|
7
7
|
|
|
8
8
|
declare class HttpErrorFeedbackAlert {
|
|
9
9
|
private readonly snackbar;
|
|
10
|
-
private readonly httpClientErrorsMiddleware;
|
|
11
|
-
private readonly translations;
|
|
12
10
|
tapError(error: HttpErrorResponse): void;
|
|
13
11
|
static ɵfac: i0.ɵɵFactoryDeclaration<HttpErrorFeedbackAlert, never>;
|
|
14
12
|
static ɵprov: i0.ɵɵInjectableDeclaration<HttpErrorFeedbackAlert>;
|