@acorex/core 5.3.3 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/ax-preset.js +16 -0
- package/esm2020/lib/translation/translator.mjs +4 -3
- package/esm2020/lib/translation/translator.pipe.mjs +3 -3
- package/esm2020/lib/utils/color-util.mjs +53 -0
- package/esm2020/lib/utils/index.mjs +2 -1
- package/fesm2015/acorex-core.mjs +59 -5
- package/fesm2015/acorex-core.mjs.map +1 -1
- package/fesm2020/acorex-core.mjs +59 -5
- package/fesm2020/acorex-core.mjs.map +1 -1
- package/lib/translation/translator.d.ts +1 -1
- package/lib/translation/translator.pipe.d.ts +1 -1
- package/lib/utils/color-util.d.ts +9 -0
- package/lib/utils/index.d.ts +1 -0
- package/package.json +3 -2
package/fesm2020/acorex-core.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Pipe, NgModule, Injectable, Inject } from '@angular/core';
|
|
3
|
+
import tinycolor from 'tinycolor2';
|
|
3
4
|
import * as i1 from '@angular/platform-browser';
|
|
4
5
|
import _ from 'lodash';
|
|
5
6
|
import { Subject, fromEvent } from 'rxjs';
|
|
@@ -93,6 +94,58 @@ class AXStringUtil {
|
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
|
|
97
|
+
class AXColorUtil {
|
|
98
|
+
static testa(color) {
|
|
99
|
+
var _color = tinycolor(color);
|
|
100
|
+
console.log(_color);
|
|
101
|
+
}
|
|
102
|
+
static to(color, mode) {
|
|
103
|
+
const _color = tinycolor(color);
|
|
104
|
+
switch (mode) {
|
|
105
|
+
case 'rgba':
|
|
106
|
+
return _color.toRgbString();
|
|
107
|
+
case 'hsla':
|
|
108
|
+
return _color.toHslString();
|
|
109
|
+
case 'hsva':
|
|
110
|
+
return _color.toHsvString();
|
|
111
|
+
default:
|
|
112
|
+
return _color.toHexString();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
;
|
|
116
|
+
static toHex(color) {
|
|
117
|
+
const _color = tinycolor(color);
|
|
118
|
+
return _color.toHexString();
|
|
119
|
+
}
|
|
120
|
+
;
|
|
121
|
+
static toRGB(color) {
|
|
122
|
+
const _color = tinycolor(color);
|
|
123
|
+
return _color.toRgbString();
|
|
124
|
+
}
|
|
125
|
+
;
|
|
126
|
+
static illuminance(hexColor) {
|
|
127
|
+
let rgbColor = AXColorUtil.toRGB(hexColor);
|
|
128
|
+
if (!rgbColor)
|
|
129
|
+
return -1;
|
|
130
|
+
let r = rgbColor.r, g = rgbColor.g, b = rgbColor.b;
|
|
131
|
+
let a = [r, g, b].map(v => {
|
|
132
|
+
v /= 255;
|
|
133
|
+
return (v <= 0.03928) ?
|
|
134
|
+
v / 12.92 :
|
|
135
|
+
Math.pow(((v + 0.055) / 1.055), 2.4);
|
|
136
|
+
});
|
|
137
|
+
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
|
|
138
|
+
}
|
|
139
|
+
;
|
|
140
|
+
static contrastToWhite(color) {
|
|
141
|
+
// let whiteIlluminance = 1;
|
|
142
|
+
// let illuminance = AXColorUtil.illuminance(hexColor);
|
|
143
|
+
// return whiteIlluminance / illuminance;
|
|
144
|
+
return tinycolor.readability("#fff", color);
|
|
145
|
+
}
|
|
146
|
+
;
|
|
147
|
+
}
|
|
148
|
+
|
|
96
149
|
class AXSafePipe {
|
|
97
150
|
constructor(sanitizer) {
|
|
98
151
|
this.sanitizer = sanitizer;
|
|
@@ -1132,8 +1185,9 @@ class AXTranslator {
|
|
|
1132
1185
|
static use(lang) {
|
|
1133
1186
|
AXTranslator.lang = lang;
|
|
1134
1187
|
}
|
|
1135
|
-
static get(key,
|
|
1136
|
-
lang =
|
|
1188
|
+
static get(key, arg1, arg2) {
|
|
1189
|
+
const lang = arg1 && typeof arg1 == 'string' ? arg1 : AXTranslator.lang;
|
|
1190
|
+
const params = arg1 && typeof arg1 == 'object' ? arg1 : arg2;
|
|
1137
1191
|
let result = _.get(AXTranslator[`__data__${lang}`], key, key);
|
|
1138
1192
|
const vars = typeof (result) == 'string' ? result?.match(this._varsRegx) : [];
|
|
1139
1193
|
if (vars?.length) {
|
|
@@ -1156,8 +1210,8 @@ AXTranslator._varsRegx = /((\$\{[a-zA-Z_0-9\.]+\})+)/gm;
|
|
|
1156
1210
|
AXTranslator._varNameRegx = /[a-zA-Z_0-9\.]+/gm;
|
|
1157
1211
|
|
|
1158
1212
|
class AXTranslatorPipe {
|
|
1159
|
-
transform(value,
|
|
1160
|
-
return AXTranslator.get(value,
|
|
1213
|
+
transform(value, arg1, arg2) {
|
|
1214
|
+
return AXTranslator.get(value, arg1, arg2);
|
|
1161
1215
|
}
|
|
1162
1216
|
}
|
|
1163
1217
|
AXTranslatorPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: AXTranslatorPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
@@ -1325,5 +1379,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.9", ngImpor
|
|
|
1325
1379
|
* Generated bundle index. Do not edit.
|
|
1326
1380
|
*/
|
|
1327
1381
|
|
|
1328
|
-
export { AXCalendarMonth, AXConfig, AXCoreModule, AXDateTime, AXDateTimeModule, AXDateTimePipe, AXDateTimeRange, AXDrawingUtil, AXEventService, AXHotkeysService, AXObjectUtil, AXPlatform, AXPlatformEvent, AXSafePipe, AXStringUtil, AXTranslationModule, AXTranslator, AXTranslatorPipe, GeorgianCalendar, JalaliCalendar, testUserAgent };
|
|
1382
|
+
export { AXCalendarMonth, AXColorUtil, AXConfig, AXCoreModule, AXDateTime, AXDateTimeModule, AXDateTimePipe, AXDateTimeRange, AXDrawingUtil, AXEventService, AXHotkeysService, AXObjectUtil, AXPlatform, AXPlatformEvent, AXSafePipe, AXStringUtil, AXTranslationModule, AXTranslator, AXTranslatorPipe, GeorgianCalendar, JalaliCalendar, testUserAgent };
|
|
1329
1383
|
//# sourceMappingURL=acorex-core.mjs.map
|