@acorex/core 5.3.4 → 5.6.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/config/configs.mjs +1 -1
- package/esm2020/lib/hotkeys/hotkeys.service.mjs +1 -1
- package/esm2020/lib/translation/translator.mjs +4 -3
- package/esm2020/lib/translation/translator.pipe.mjs +3 -3
- package/esm2020/lib/utils/color-util.mjs +61 -18
- package/fesm2015/acorex-core.mjs +65 -22
- package/fesm2015/acorex-core.mjs.map +1 -1
- package/fesm2020/acorex-core.mjs +65 -21
- 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 +11 -12
- 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';
|
|
@@ -94,24 +95,59 @@ class AXStringUtil {
|
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
class AXColorUtil {
|
|
97
|
-
static
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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.toRgb();
|
|
107
|
+
case 'hsla':
|
|
108
|
+
return _color.toHsl();
|
|
109
|
+
case 'hsva':
|
|
110
|
+
return _color.toHsv();
|
|
111
|
+
default:
|
|
112
|
+
return _color.toHex();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
;
|
|
116
|
+
static toString(color, mode) {
|
|
117
|
+
const _color = tinycolor(color);
|
|
118
|
+
switch (mode) {
|
|
119
|
+
case 'rgba':
|
|
120
|
+
return _color.toRgbString();
|
|
121
|
+
case 'hsla':
|
|
122
|
+
return _color.toHslString();
|
|
123
|
+
case 'hsva':
|
|
124
|
+
return _color.toHsvString();
|
|
125
|
+
default:
|
|
126
|
+
return _color.toHexString();
|
|
127
|
+
}
|
|
102
128
|
}
|
|
103
129
|
;
|
|
104
|
-
static
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
130
|
+
static mix(baseColor, hex, percentage) {
|
|
131
|
+
return tinycolor.mix(baseColor, hex, percentage);
|
|
132
|
+
}
|
|
133
|
+
static multiply(rgb1, rgb2) {
|
|
134
|
+
rgb1.b = Math.floor(rgb1.b * rgb2.b / 255);
|
|
135
|
+
rgb1.g = Math.floor(rgb1.g * rgb2.g / 255);
|
|
136
|
+
rgb1.r = Math.floor(rgb1.r * rgb2.r / 255);
|
|
137
|
+
return tinycolor('rgb ' + rgb1.r + ' ' + rgb1.g + ' ' + rgb1.b);
|
|
138
|
+
}
|
|
139
|
+
static toHexSting(color) {
|
|
140
|
+
const _color = tinycolor(color);
|
|
141
|
+
return _color.toHexString();
|
|
142
|
+
}
|
|
143
|
+
;
|
|
144
|
+
static toRGBString(color) {
|
|
145
|
+
const _color = tinycolor(color);
|
|
146
|
+
return _color.toRgbString();
|
|
111
147
|
}
|
|
112
148
|
;
|
|
113
149
|
static illuminance(hexColor) {
|
|
114
|
-
let rgbColor = AXColorUtil.
|
|
150
|
+
let rgbColor = AXColorUtil.toRGBString(hexColor);
|
|
115
151
|
if (!rgbColor)
|
|
116
152
|
return -1;
|
|
117
153
|
let r = rgbColor.r, g = rgbColor.g, b = rgbColor.b;
|
|
@@ -124,12 +160,19 @@ class AXColorUtil {
|
|
|
124
160
|
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
|
|
125
161
|
}
|
|
126
162
|
;
|
|
127
|
-
static contrastToWhite(
|
|
128
|
-
let whiteIlluminance = 1;
|
|
129
|
-
let illuminance = AXColorUtil.illuminance(hexColor);
|
|
130
|
-
return whiteIlluminance / illuminance;
|
|
163
|
+
static contrastToWhite(color) {
|
|
164
|
+
// let whiteIlluminance = 1;
|
|
165
|
+
// let illuminance = AXColorUtil.illuminance(hexColor);
|
|
166
|
+
// return whiteIlluminance / illuminance;
|
|
167
|
+
return tinycolor.readability("#fff", color);
|
|
131
168
|
}
|
|
132
169
|
;
|
|
170
|
+
static lighten(hex, percentage) {
|
|
171
|
+
return tinycolor(hex).lighten(percentage);
|
|
172
|
+
}
|
|
173
|
+
static darken(hex, percentage) {
|
|
174
|
+
return tinycolor(hex).darken(percentage);
|
|
175
|
+
}
|
|
133
176
|
}
|
|
134
177
|
|
|
135
178
|
class AXSafePipe {
|
|
@@ -1171,8 +1214,9 @@ class AXTranslator {
|
|
|
1171
1214
|
static use(lang) {
|
|
1172
1215
|
AXTranslator.lang = lang;
|
|
1173
1216
|
}
|
|
1174
|
-
static get(key,
|
|
1175
|
-
lang =
|
|
1217
|
+
static get(key, arg1, arg2) {
|
|
1218
|
+
const lang = arg1 && typeof arg1 == 'string' ? arg1 : AXTranslator.lang;
|
|
1219
|
+
const params = arg1 && typeof arg1 == 'object' ? arg1 : arg2;
|
|
1176
1220
|
let result = _.get(AXTranslator[`__data__${lang}`], key, key);
|
|
1177
1221
|
const vars = typeof (result) == 'string' ? result?.match(this._varsRegx) : [];
|
|
1178
1222
|
if (vars?.length) {
|
|
@@ -1195,8 +1239,8 @@ AXTranslator._varsRegx = /((\$\{[a-zA-Z_0-9\.]+\})+)/gm;
|
|
|
1195
1239
|
AXTranslator._varNameRegx = /[a-zA-Z_0-9\.]+/gm;
|
|
1196
1240
|
|
|
1197
1241
|
class AXTranslatorPipe {
|
|
1198
|
-
transform(value,
|
|
1199
|
-
return AXTranslator.get(value,
|
|
1242
|
+
transform(value, arg1, arg2) {
|
|
1243
|
+
return AXTranslator.get(value, arg1, arg2);
|
|
1200
1244
|
}
|
|
1201
1245
|
}
|
|
1202
1246
|
AXTranslatorPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: AXTranslatorPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|