@acorex/core 3.0.21 → 3.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/acorex-core.d.ts +4 -0
- package/acorex-core.metadata.json +1 -0
- package/bundles/acorex-core.umd.js +2539 -0
- package/bundles/acorex-core.umd.js.map +1 -0
- package/bundles/acorex-core.umd.min.js +17 -0
- package/bundles/acorex-core.umd.min.js.map +1 -0
- package/esm2015/acorex-core.js +5 -0
- package/esm2015/lib/classes/base-page.class.js +21 -0
- package/esm2015/lib/classes/color.class.js +49 -0
- package/esm2015/lib/classes/datetime.class.js +314 -0
- package/esm2015/lib/classes/menu.class.js +27 -0
- package/esm2015/lib/classes/navigator.class.js +1 -0
- package/esm2015/lib/classes/popup.class.js +1 -0
- package/esm2015/lib/classes/promise.class.js +19 -0
- package/esm2015/lib/classes/sectionlist.class.js +1 -0
- package/esm2015/lib/classes/select.class.js +3 -0
- package/esm2015/lib/core.module.js +24 -0
- package/esm2015/lib/error/error.class.js +1 -0
- package/esm2015/lib/error/error.module.js +16 -0
- package/esm2015/lib/error/error.service.js +25 -0
- package/esm2015/lib/events/keyboard.js +1 -0
- package/esm2015/lib/http/http-error.class.js +1 -0
- package/esm2015/lib/http/http-events.interceptor.js +3 -0
- package/esm2015/lib/http/http-request.class.js +1 -0
- package/esm2015/lib/http/http-result.class.js +21 -0
- package/esm2015/lib/http/http.module.js +29 -0
- package/esm2015/lib/http/http.service.js +149 -0
- package/{src → esm2015}/lib/locale/en.json +2 -2
- package/{src → esm2015}/lib/locale/fa.json +3 -3
- package/esm2015/lib/pipe/datetime.pipe.js +24 -0
- package/esm2015/lib/pipe/htmlToText.pipe.js +23 -0
- package/esm2015/lib/services/config.js +29 -0
- package/esm2015/lib/services/event.service.js +36 -0
- package/esm2015/lib/services/navigator.service.js +9 -0
- package/esm2015/lib/services/storage.service.js +15 -0
- package/esm2015/lib/translator/translator.js +26 -0
- package/esm2015/lib/translator/translator.module.js +23 -0
- package/esm2015/lib/translator/translator.pipe.js +23 -0
- package/esm2015/lib/translator/translator.service.js +21 -0
- package/esm2015/lib/utils/array/array-util.js +133 -0
- package/esm2015/lib/utils/html/html-util.js +192 -0
- package/esm2015/lib/utils/html/html.module.js +16 -0
- package/esm2015/lib/utils/math/math-util.js +6 -0
- package/esm2015/lib/utils/object/object-util.js +83 -0
- package/esm2015/lib/utils/render/on-demand-preload-strategy.service.js +21 -0
- package/esm2015/lib/utils/render/render.service.js +112 -0
- package/esm2015/lib/utils/render/rendering.module.js +26 -0
- package/esm2015/lib/utils/scroll/scroll.directive.js +66 -0
- package/esm2015/lib/utils/scroll/scroll.module.js +16 -0
- package/esm2015/lib/utils/separator/separator.module.js +16 -0
- package/esm2015/lib/utils/separator/separator.pipe.js +22 -0
- package/esm2015/public-api.js +36 -0
- package/esm5/acorex-core.js +5 -0
- package/esm5/lib/classes/base-page.class.js +23 -0
- package/esm5/lib/classes/color.class.js +54 -0
- package/esm5/lib/classes/datetime.class.js +390 -0
- package/esm5/lib/classes/menu.class.js +42 -0
- package/esm5/lib/classes/navigator.class.js +1 -0
- package/esm5/lib/classes/popup.class.js +1 -0
- package/esm5/lib/classes/promise.class.js +22 -0
- package/esm5/lib/classes/sectionlist.class.js +1 -0
- package/esm5/lib/classes/select.class.js +7 -0
- package/esm5/lib/core.module.js +27 -0
- package/esm5/lib/error/error.class.js +1 -0
- package/esm5/lib/error/error.module.js +19 -0
- package/esm5/lib/error/error.service.js +26 -0
- package/esm5/lib/events/keyboard.js +1 -0
- package/esm5/lib/http/http-error.class.js +1 -0
- package/esm5/lib/http/http-events.interceptor.js +3 -0
- package/esm5/lib/http/http-request.class.js +1 -0
- package/esm5/lib/http/http-result.class.js +24 -0
- package/esm5/lib/http/http.module.js +33 -0
- package/esm5/lib/http/http.service.js +157 -0
- package/esm5/lib/locale/en.json +249 -0
- package/esm5/lib/locale/fa.json +238 -0
- package/esm5/lib/pipe/datetime.pipe.js +26 -0
- package/esm5/lib/pipe/htmlToText.pipe.js +26 -0
- package/esm5/lib/services/config.js +37 -0
- package/esm5/lib/services/event.service.js +37 -0
- package/esm5/lib/services/navigator.service.js +12 -0
- package/esm5/lib/services/storage.service.js +18 -0
- package/esm5/lib/translator/translator.js +34 -0
- package/esm5/lib/translator/translator.module.js +24 -0
- package/esm5/lib/translator/translator.pipe.js +25 -0
- package/esm5/lib/translator/translator.service.js +24 -0
- package/esm5/lib/utils/array/array-util.js +147 -0
- package/esm5/lib/utils/html/html-util.js +224 -0
- package/esm5/lib/utils/html/html.module.js +19 -0
- package/esm5/lib/utils/math/math-util.js +10 -0
- package/esm5/lib/utils/object/object-util.js +88 -0
- package/esm5/lib/utils/render/on-demand-preload-strategy.service.js +22 -0
- package/esm5/lib/utils/render/render.service.js +117 -0
- package/esm5/lib/utils/render/rendering.module.js +29 -0
- package/esm5/lib/utils/scroll/scroll.directive.js +68 -0
- package/esm5/lib/utils/scroll/scroll.module.js +19 -0
- package/esm5/lib/utils/separator/separator.module.js +19 -0
- package/esm5/lib/utils/separator/separator.pipe.js +25 -0
- package/esm5/public-api.js +36 -0
- package/fesm2015/acorex-core.js +2057 -0
- package/fesm2015/acorex-core.js.map +1 -0
- package/fesm5/acorex-core.js +2274 -0
- package/fesm5/acorex-core.js.map +1 -0
- package/lib/classes/base-page.class.d.ts +10 -0
- package/lib/classes/color.class.d.ts +17 -0
- package/lib/classes/datetime.class.d.ts +63 -0
- package/lib/classes/menu.class.d.ts +34 -0
- package/{src/lib/classes/navigator.class.ts → lib/classes/navigator.class.d.ts} +1 -1
- package/{src/lib/classes/popup.class.ts → lib/classes/popup.class.d.ts} +0 -2
- package/lib/classes/promise.class.d.ts +7 -0
- package/{src/lib/classes/sectionlist.class.ts → lib/classes/sectionlist.class.d.ts} +0 -0
- package/lib/classes/select.class.d.ts +7 -0
- package/lib/core.module.d.ts +2 -0
- package/{src/lib/error/error.class.ts → lib/error/error.class.d.ts} +0 -0
- package/lib/error/error.module.d.ts +2 -0
- package/lib/error/error.service.d.ts +10 -0
- package/{src/lib/events/keyboard.ts → lib/events/keyboard.d.ts} +0 -3
- package/{src/lib/http/http-error.class.ts → lib/http/http-error.class.d.ts} +2 -2
- package/{src/lib/http/http-events.interceptor.ts → lib/http/http-events.interceptor.d.ts} +3 -7
- package/{src/lib/http/http-request.class.ts → lib/http/http-request.class.d.ts} +5 -5
- package/lib/http/http-result.class.d.ts +11 -0
- package/lib/http/http.module.d.ts +4 -0
- package/lib/http/http.service.d.ts +20 -0
- package/lib/pipe/datetime.pipe.d.ts +5 -0
- package/lib/pipe/htmlToText.pipe.d.ts +4 -0
- package/lib/services/config.d.ts +9 -0
- package/lib/services/event.service.d.ts +6 -0
- package/lib/services/navigator.service.d.ts +5 -0
- package/lib/services/storage.service.d.ts +4 -0
- package/lib/translator/translator.d.ts +9 -0
- package/lib/translator/translator.module.d.ts +3 -0
- package/lib/translator/translator.pipe.d.ts +5 -0
- package/lib/translator/translator.service.d.ts +5 -0
- package/lib/utils/array/array-util.d.ts +6 -0
- package/lib/utils/html/html-util.d.ts +62 -0
- package/lib/utils/html/html.module.d.ts +2 -0
- package/lib/utils/math/math-util.d.ts +3 -0
- package/lib/utils/object/object-util.d.ts +7 -0
- package/lib/utils/render/on-demand-preload-strategy.service.d.ts +7 -0
- package/lib/utils/render/render.service.d.ts +14 -0
- package/lib/utils/render/rendering.module.d.ts +4 -0
- package/lib/utils/scroll/scroll.directive.d.ts +13 -0
- package/lib/utils/scroll/scroll.module.d.ts +2 -0
- package/lib/utils/separator/separator.module.d.ts +2 -0
- package/lib/utils/separator/separator.pipe.d.ts +4 -0
- package/package.json +23 -13
- package/{src/public-api.ts → public-api.d.ts} +0 -9
- package/karma.conf.js +0 -32
- package/ng-package.json +0 -10
- package/src/lib/classes/base-page.class.ts +0 -27
- package/src/lib/classes/color.class.ts +0 -61
- package/src/lib/classes/datetime.class.ts +0 -374
- package/src/lib/classes/menu.class.ts +0 -37
- package/src/lib/classes/promise.class.ts +0 -25
- package/src/lib/classes/select.class.ts +0 -7
- package/src/lib/core.module.ts +0 -21
- package/src/lib/error/error.module.ts +0 -13
- package/src/lib/error/error.service.ts +0 -23
- package/src/lib/error/index.ts +0 -3
- package/src/lib/http/http-result.class.ts +0 -34
- package/src/lib/http/http.module.ts +0 -25
- package/src/lib/http/http.service.ts +0 -159
- package/src/lib/pipe/datetime.pipe.ts +0 -20
- package/src/lib/pipe/htmlToText.pipe.ts +0 -18
- package/src/lib/services/config.ts +0 -36
- package/src/lib/services/event.service.ts +0 -31
- package/src/lib/services/navigator.service.ts +0 -8
- package/src/lib/services/storage.service.ts +0 -11
- package/src/lib/translator/translator.module.ts +0 -19
- package/src/lib/translator/translator.pipe.ts +0 -22
- package/src/lib/translator/translator.service.ts +0 -19
- package/src/lib/translator/translator.ts +0 -31
- package/src/lib/utils/array/array-util.ts +0 -140
- package/src/lib/utils/html/html-util.ts +0 -264
- package/src/lib/utils/html/html.module.ts +0 -11
- package/src/lib/utils/math/math-util.ts +0 -5
- package/src/lib/utils/object/object-util.ts +0 -87
- package/src/lib/utils/render/on-demand-preload-strategy.service.ts +0 -26
- package/src/lib/utils/render/render.service.ts +0 -107
- package/src/lib/utils/render/rendering.module.ts +0 -25
- package/src/lib/utils/scroll/scroll.directive.ts +0 -35
- package/src/lib/utils/scroll/scroll.module.ts +0 -11
- package/src/lib/utils/separator/separator.module.ts +0 -11
- package/src/lib/utils/separator/separator.pipe.ts +0 -15
- package/src/test.ts +0 -26
- package/tsconfig.lib.json +0 -23
- package/tsconfig.lib.prod.json +0 -6
- package/tsconfig.spec.json +0 -18
- package/tslint.json +0 -17
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare type AXPlacement = 'top-start' | 'top-middle' | 'top-end' | 'center-start' | 'center-end' | 'bottom-start' | 'bottom-middle' | 'bottom-end';
|
|
2
|
+
export interface AXIPoint {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
export interface AXConnectedPosition {
|
|
7
|
+
originX: 'start' | 'center' | 'end';
|
|
8
|
+
originY: 'top' | 'center' | 'bottom';
|
|
9
|
+
overlayX: 'start' | 'center' | 'end';
|
|
10
|
+
overlayY: 'top' | 'center' | 'bottom';
|
|
11
|
+
weight?: number;
|
|
12
|
+
offsetX?: number;
|
|
13
|
+
offsetY?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class AXPoint implements AXIPoint {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
constructor(x: number, y: number);
|
|
19
|
+
}
|
|
20
|
+
export interface AXClientRecCtor {
|
|
21
|
+
left?: number;
|
|
22
|
+
top?: number;
|
|
23
|
+
width?: number;
|
|
24
|
+
height?: number;
|
|
25
|
+
bottom?: number;
|
|
26
|
+
right?: number;
|
|
27
|
+
}
|
|
28
|
+
export declare class AXClientRec implements AXClientRecCtor {
|
|
29
|
+
private _left;
|
|
30
|
+
get left(): number;
|
|
31
|
+
set left(v: number);
|
|
32
|
+
private _top;
|
|
33
|
+
get top(): number;
|
|
34
|
+
set top(v: number);
|
|
35
|
+
private _right;
|
|
36
|
+
get right(): number;
|
|
37
|
+
set right(v: number);
|
|
38
|
+
private _bottom;
|
|
39
|
+
get bottom(): number;
|
|
40
|
+
set bottom(v: number);
|
|
41
|
+
private _width;
|
|
42
|
+
get width(): number;
|
|
43
|
+
set width(v: number);
|
|
44
|
+
private _height;
|
|
45
|
+
get height(): number;
|
|
46
|
+
set height(v: number);
|
|
47
|
+
constructor(rec: AXClientRecCtor);
|
|
48
|
+
intersect(rec: AXClientRecCtor): boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare class AXHtmlUtil {
|
|
51
|
+
static getBoundingRectPoint(el: HTMLElement, placement: AXPlacement): AXPoint;
|
|
52
|
+
static isInRecPoint(pos: AXIPoint, rec: AXClientRecCtor): boolean;
|
|
53
|
+
static isInElementBound(pos: AXIPoint, element: HTMLElement): boolean;
|
|
54
|
+
static getDimensions(): {
|
|
55
|
+
width: number;
|
|
56
|
+
height: number;
|
|
57
|
+
};
|
|
58
|
+
static getOffsetRight(elem: HTMLElement): number;
|
|
59
|
+
static getUID(): string;
|
|
60
|
+
static getRelatedPosition(source: HTMLElement, placement: AXPlacement, target: HTMLElement, alignment: AXPlacement): AXIPoint;
|
|
61
|
+
static collision(a: HTMLElement, b: HTMLElement): boolean;
|
|
62
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class AXObjectUtil {
|
|
2
|
+
static deepJSONClone(obj: any): any;
|
|
3
|
+
static deepCopy(obj: any): any;
|
|
4
|
+
}
|
|
5
|
+
export declare function AXFetchProp(obj: any, prop: string): any;
|
|
6
|
+
export declare function getPropByPath(obj: any, path: any, defaultVal?: any): any;
|
|
7
|
+
export declare function setPropByPath(obj: any, path: any, value: any): any;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ApplicationRef, ComponentFactoryResolver, ComponentRef, Injector, Type } from '@angular/core';
|
|
2
|
+
import { Router, Route } from '@angular/router';
|
|
3
|
+
import { AXOnDemandPreloadService } from './on-demand-preload-strategy.service';
|
|
4
|
+
export declare class AXRenderService {
|
|
5
|
+
private appRef;
|
|
6
|
+
private router;
|
|
7
|
+
private componentFactoryResolver;
|
|
8
|
+
private modulePreloadService;
|
|
9
|
+
private injector;
|
|
10
|
+
constructor(appRef: ApplicationRef, router: Router, componentFactoryResolver: ComponentFactoryResolver, modulePreloadService: AXOnDemandPreloadService, injector: Injector);
|
|
11
|
+
appendComponent<T>(componentClass: Type<T>, options?: any, location?: Element): ComponentRef<any>;
|
|
12
|
+
findLoadedComponentByRoute(path: string, timeoutTime?: number): Promise<Route>;
|
|
13
|
+
private _findLoadedComponentByRoute;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ElementRef } from '@angular/core';
|
|
2
|
+
export declare class AXHorizontalScrollDirective {
|
|
3
|
+
private el;
|
|
4
|
+
constructor(el: ElementRef<HTMLElement>);
|
|
5
|
+
scrollValue: number;
|
|
6
|
+
onMouseWheel(e: any): void;
|
|
7
|
+
}
|
|
8
|
+
export declare class AXVerticalScrollDirective {
|
|
9
|
+
private el;
|
|
10
|
+
constructor(el: ElementRef<HTMLElement>);
|
|
11
|
+
scrollValue: number;
|
|
12
|
+
onMouseWheel(e: any): void;
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@acorex/core",
|
|
3
|
-
"version": "3.0.
|
|
4
|
-
"peerDependencies": {
|
|
5
|
-
"@angular/common": "^9.0.6",
|
|
6
|
-
"@angular/core": "^9.0.6",
|
|
7
|
-
"rxjs": "~6.5.4"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
}
|
|
13
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@acorex/core",
|
|
3
|
+
"version": "3.0.25",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^9.0.6",
|
|
6
|
+
"@angular/core": "^9.0.6",
|
|
7
|
+
"rxjs": "~6.5.4"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"jalali-moment": "3.3.3",
|
|
11
|
+
"tslib": "^1.10.0"
|
|
12
|
+
},
|
|
13
|
+
"main": "bundles/acorex-core.umd.js",
|
|
14
|
+
"module": "fesm5/acorex-core.js",
|
|
15
|
+
"es2015": "fesm2015/acorex-core.js",
|
|
16
|
+
"esm5": "esm5/acorex-core.js",
|
|
17
|
+
"esm2015": "esm2015/acorex-core.js",
|
|
18
|
+
"fesm5": "fesm5/acorex-core.js",
|
|
19
|
+
"fesm2015": "fesm2015/acorex-core.js",
|
|
20
|
+
"typings": "acorex-core.d.ts",
|
|
21
|
+
"metadata": "acorex-core.metadata.json",
|
|
22
|
+
"sideEffects": false
|
|
23
|
+
}
|
|
@@ -7,34 +7,26 @@ export * from './lib/classes/promise.class';
|
|
|
7
7
|
export * from './lib/classes/sectionlist.class';
|
|
8
8
|
export * from './lib/classes/select.class';
|
|
9
9
|
export * from './lib/classes/base-page.class';
|
|
10
|
-
|
|
11
10
|
export * from './lib/error/error.class';
|
|
12
11
|
export * from './lib/error/error.module';
|
|
13
12
|
export * from './lib/error/error.service';
|
|
14
|
-
|
|
15
13
|
export * from './lib/events/keyboard';
|
|
16
|
-
|
|
17
14
|
export * from './lib/http/http-error.class';
|
|
18
15
|
export * from './lib/http/http-events.interceptor';
|
|
19
16
|
export * from './lib/http/http-request.class';
|
|
20
17
|
export * from './lib/http/http-result.class';
|
|
21
18
|
export * from './lib/http/http.module';
|
|
22
19
|
export * from './lib/http/http.service';
|
|
23
|
-
|
|
24
20
|
export * from './lib/pipe/datetime.pipe';
|
|
25
21
|
export * from './lib/pipe/htmlToText.pipe';
|
|
26
|
-
|
|
27
22
|
export * from './lib/services/event.service';
|
|
28
23
|
export * from './lib/services/navigator.service';
|
|
29
24
|
export * from './lib/services/storage.service';
|
|
30
25
|
export * from './lib/services/config';
|
|
31
|
-
|
|
32
|
-
|
|
33
26
|
export * from './lib/translator/translator.service';
|
|
34
27
|
export * from './lib/translator/translator.pipe';
|
|
35
28
|
export * from './lib/translator/translator';
|
|
36
29
|
export * from './lib/translator/translator.module';
|
|
37
|
-
|
|
38
30
|
export * from './lib/utils/array/array-util';
|
|
39
31
|
export * from './lib/utils/html/html-util';
|
|
40
32
|
export * from './lib/utils/html/html.module';
|
|
@@ -48,4 +40,3 @@ export * from './lib/utils/scroll/scroll.module';
|
|
|
48
40
|
export * from './lib/utils/separator/separator.module';
|
|
49
41
|
export * from './lib/utils/separator/separator.pipe';
|
|
50
42
|
export * from './lib/core.module';
|
|
51
|
-
|
package/karma.conf.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Karma configuration file, see link for more information
|
|
2
|
-
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
|
3
|
-
|
|
4
|
-
module.exports = function (config) {
|
|
5
|
-
config.set({
|
|
6
|
-
basePath: '',
|
|
7
|
-
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
|
8
|
-
plugins: [
|
|
9
|
-
require('karma-jasmine'),
|
|
10
|
-
require('karma-chrome-launcher'),
|
|
11
|
-
require('karma-jasmine-html-reporter'),
|
|
12
|
-
require('karma-coverage-istanbul-reporter'),
|
|
13
|
-
require('@angular-devkit/build-angular/plugins/karma')
|
|
14
|
-
],
|
|
15
|
-
client: {
|
|
16
|
-
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|
17
|
-
},
|
|
18
|
-
coverageIstanbulReporter: {
|
|
19
|
-
dir: require('path').join(__dirname, '../../../coverage/acorex/core'),
|
|
20
|
-
reports: ['html', 'lcovonly', 'text-summary'],
|
|
21
|
-
fixWebpackSourcePaths: true
|
|
22
|
-
},
|
|
23
|
-
reporters: ['progress', 'kjhtml'],
|
|
24
|
-
port: 9876,
|
|
25
|
-
colors: true,
|
|
26
|
-
logLevel: config.LOG_INFO,
|
|
27
|
-
autoWatch: true,
|
|
28
|
-
browsers: ['Chrome'],
|
|
29
|
-
singleRun: false,
|
|
30
|
-
restartOnFileChange: true
|
|
31
|
-
});
|
|
32
|
-
};
|
package/ng-package.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated Use AXBasePageComponent from @acorex/components
|
|
5
|
-
*/
|
|
6
|
-
export abstract class AXBasePageComponent {
|
|
7
|
-
|
|
8
|
-
onClosed: EventEmitter<any> = new EventEmitter<any>();
|
|
9
|
-
|
|
10
|
-
close(data?: any) {
|
|
11
|
-
this.onClosed.emit({
|
|
12
|
-
component: this,
|
|
13
|
-
data: data
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
onClosing(e: any): void | Promise<void> {
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
ngOnDestroy() {
|
|
21
|
-
this.onClosed.unsubscribe();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export interface AXColor {
|
|
2
|
-
id?: string;
|
|
3
|
-
color?: string;
|
|
4
|
-
code: string;
|
|
5
|
-
selected?: boolean;
|
|
6
|
-
active?: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export class AXColorUtil {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
static hex2Rgb(hexColor: string) {
|
|
13
|
-
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hexColor);
|
|
14
|
-
return result ? {
|
|
15
|
-
r: parseInt(result[1], 16),
|
|
16
|
-
g: parseInt(result[2], 16),
|
|
17
|
-
b: parseInt(result[3], 16)
|
|
18
|
-
} : null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static rgb2Hex(r: number, g: number, b: number, a: number = 255): string {
|
|
22
|
-
let alpha;
|
|
23
|
-
let hex = (r | 1 << 8).toString(16).slice(1) +
|
|
24
|
-
(g | 1 << 8).toString(16).slice(1) +
|
|
25
|
-
(b | 1 << 8).toString(16).slice(1);
|
|
26
|
-
if (a !== 255) {
|
|
27
|
-
alpha = a;
|
|
28
|
-
} else {
|
|
29
|
-
alpha = 1;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
alpha = Math.round(alpha * 100) / 100;
|
|
33
|
-
alpha = Math.round(alpha * 255);
|
|
34
|
-
const hexAlpha = (alpha + 0x10000).toString(16).substr(-2).toUpperCase();
|
|
35
|
-
return '#' + hex + (alpha == 255 ? '' : hexAlpha);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
static illuminance(hexColor: string) {
|
|
39
|
-
const rgbColor = AXColorUtil.hex2Rgb(hexColor);
|
|
40
|
-
if (!rgbColor) {
|
|
41
|
-
return -1;
|
|
42
|
-
}
|
|
43
|
-
const r = rgbColor.r;
|
|
44
|
-
const g = rgbColor.g;
|
|
45
|
-
const b = rgbColor.b;
|
|
46
|
-
const a = [r, g, b].map(v => {
|
|
47
|
-
v /= 255;
|
|
48
|
-
return (v <= 0.03928) ?
|
|
49
|
-
v / 12.92 :
|
|
50
|
-
Math.pow(((v + 0.055) / 1.055), 2.4);
|
|
51
|
-
});
|
|
52
|
-
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
static contrastToWhite(hexColor: string) {
|
|
56
|
-
const whiteIlluminance = 1;
|
|
57
|
-
const illuminance = AXColorUtil.illuminance(hexColor);
|
|
58
|
-
return whiteIlluminance / illuminance;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
}
|