vxe-pc-ui 3.16.21 → 3.16.22
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/es/color-picker/index.js +14 -0
- package/es/color-picker/src/color-picker.js +40 -28
- package/es/color-picker/src/util.js +252 -36
- package/es/date-picker/src/date-picker.js +2 -1
- package/es/date-range-picker/src/date-range-picker.js +2 -1
- package/es/icon/style.css +1 -1
- package/es/select/src/select.js +2 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/color-picker/index.js +14 -0
- package/lib/color-picker/index.min.js +1 -1
- package/lib/color-picker/src/color-picker.js +38 -27
- package/lib/color-picker/src/color-picker.min.js +1 -1
- package/lib/color-picker/src/util.js +266 -46
- package/lib/color-picker/src/util.min.js +1 -1
- package/lib/date-picker/src/date-picker.js +2 -1
- package/lib/date-picker/src/date-picker.min.js +1 -1
- package/lib/date-range-picker/src/date-range-picker.js +2 -1
- package/lib/date-range-picker/src/date-range-picker.min.js +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.umd.js +318 -77
- package/lib/index.umd.min.js +1 -1
- package/lib/select/src/select.js +2 -1
- package/lib/select/src/select.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +1 -1
- package/packages/color-picker/index.ts +15 -0
- package/packages/color-picker/src/color-picker.ts +41 -29
- package/packages/color-picker/src/util.ts +267 -42
- package/packages/date-picker/src/date-picker.ts +4 -2
- package/packages/date-range-picker/src/date-range-picker.ts +4 -2
- package/packages/select/src/select.ts +4 -2
- package/types/components/color-picker.d.ts +93 -0
- package/types/components/grid.d.ts +6 -0
- package/types/components/table.d.ts +2 -2
- package/types/ui/index.d.ts +2 -0
- /package/es/icon/{iconfont.1784868314197.ttf → iconfont.1784893277784.ttf} +0 -0
- /package/es/icon/{iconfont.1784868314197.woff → iconfont.1784893277784.woff} +0 -0
- /package/es/icon/{iconfont.1784868314197.woff2 → iconfont.1784893277784.woff2} +0 -0
- /package/es/{iconfont.1784868314197.ttf → iconfont.1784893277784.ttf} +0 -0
- /package/es/{iconfont.1784868314197.woff → iconfont.1784893277784.woff} +0 -0
- /package/es/{iconfont.1784868314197.woff2 → iconfont.1784893277784.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1784868314197.ttf → iconfont.1784893277784.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1784868314197.woff → iconfont.1784893277784.woff} +0 -0
- /package/lib/icon/style/{iconfont.1784868314197.woff2 → iconfont.1784893277784.woff2} +0 -0
- /package/lib/{iconfont.1784868314197.ttf → iconfont.1784893277784.ttf} +0 -0
- /package/lib/{iconfont.1784868314197.woff → iconfont.1784893277784.woff} +0 -0
- /package/lib/{iconfont.1784868314197.woff2 → iconfont.1784893277784.woff2} +0 -0
package/es/color-picker/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { VxeUI } from '@vxe-ui/core';
|
|
2
2
|
import VxeColorPickerComponent from './src/color-picker';
|
|
3
3
|
import { dynamicApp } from '../dynamics';
|
|
4
|
+
import { parseColor, hasRgb, hasHex, toRgb, toHex, toHsl, toHsv, toRgbString, toHexString, lighten, darken } from './src/util';
|
|
4
5
|
export const VxeColorPicker = Object.assign({}, VxeColorPickerComponent, {
|
|
5
6
|
install(app) {
|
|
6
7
|
app.component(VxeColorPickerComponent.name, VxeColorPickerComponent);
|
|
@@ -8,5 +9,18 @@ export const VxeColorPicker = Object.assign({}, VxeColorPickerComponent, {
|
|
|
8
9
|
});
|
|
9
10
|
dynamicApp.use(VxeColorPicker);
|
|
10
11
|
VxeUI.component(VxeColorPickerComponent);
|
|
12
|
+
VxeUI.color = {
|
|
13
|
+
parseColor,
|
|
14
|
+
hasRgb,
|
|
15
|
+
hasHex,
|
|
16
|
+
toRgb,
|
|
17
|
+
toRgbString,
|
|
18
|
+
toHex,
|
|
19
|
+
toHexString,
|
|
20
|
+
toHsl,
|
|
21
|
+
toHsv,
|
|
22
|
+
lighten,
|
|
23
|
+
darken
|
|
24
|
+
};
|
|
11
25
|
export const ColorPicker = VxeColorPicker;
|
|
12
26
|
export default VxeColorPicker;
|
|
@@ -3,7 +3,7 @@ import XEUtils from 'xe-utils';
|
|
|
3
3
|
import { VxeUI, getIcon, getConfig, getI18n, globalEvents, createEvent, globalMixins, renderEmptyElement } from '../../ui';
|
|
4
4
|
import { getEventTargetNode, getPopupContainer, toCssUnit, updatePanelPlacement } from '../../ui/src/dom';
|
|
5
5
|
import { getLastZIndex, nextZIndex } from '../../ui/src/utils';
|
|
6
|
-
import {
|
|
6
|
+
import { parseValColor, updateColorAlpha, hexToHsv, rgbToHsv, rgbToHexVal, hexToRgb, hsvToRgb, toValRgb } from './util';
|
|
7
7
|
import VxeButtonComponent from '../../button';
|
|
8
8
|
import VxeInputComponent from '../../input';
|
|
9
9
|
import VxeNumberInputComponent from '../../number-input';
|
|
@@ -162,6 +162,7 @@ export default {
|
|
|
162
162
|
const $xeTable = $xeColorPicker.$xeTable;
|
|
163
163
|
const $xeModal = $xeColorPicker.$xeModal;
|
|
164
164
|
const $xeDrawer = $xeColorPicker.$xeDrawer;
|
|
165
|
+
const $xeCard = $xeColorPicker.$xeCard;
|
|
165
166
|
const $xeForm = $xeColorPicker.$xeForm;
|
|
166
167
|
const { transfer } = props;
|
|
167
168
|
if (transfer === null) {
|
|
@@ -169,7 +170,7 @@ export default {
|
|
|
169
170
|
if (XEUtils.isBoolean(globalTransfer)) {
|
|
170
171
|
return globalTransfer;
|
|
171
172
|
}
|
|
172
|
-
if ($xeTable || $xeModal || $xeDrawer || $xeForm) {
|
|
173
|
+
if ($xeTable || $xeModal || $xeDrawer || $xeCard || $xeForm) {
|
|
173
174
|
return true;
|
|
174
175
|
}
|
|
175
176
|
}
|
|
@@ -257,32 +258,43 @@ export default {
|
|
|
257
258
|
const isRgb = $xeColorPicker.computeIsRgb;
|
|
258
259
|
const hueSliderEl = $xeColorPicker.$refs.refHueSliderElem;
|
|
259
260
|
const alphaSliderEl = $xeColorPicker.$refs.refAlphaSliderElem;
|
|
260
|
-
const colorRest =
|
|
261
|
-
reactData.hexValue =
|
|
262
|
-
reactData.rValue =
|
|
263
|
-
reactData.gValue =
|
|
264
|
-
reactData.bValue =
|
|
265
|
-
reactData.aValue =
|
|
266
|
-
if (colorRest
|
|
267
|
-
if (
|
|
268
|
-
|
|
269
|
-
const rgbRest = hexToRgb(colorRest.hex);
|
|
270
|
-
if (rgbRest) {
|
|
271
|
-
reactData.rValue = rgbRest.r;
|
|
272
|
-
reactData.gValue = rgbRest.g;
|
|
273
|
-
reactData.bValue = rgbRest.b;
|
|
274
|
-
reactData.aValue = rgbRest.a;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
261
|
+
const colorRest = parseValColor(selectColor);
|
|
262
|
+
reactData.hexValue = '';
|
|
263
|
+
reactData.rValue = 0;
|
|
264
|
+
reactData.gValue = 0;
|
|
265
|
+
reactData.bValue = 0;
|
|
266
|
+
reactData.aValue = 1;
|
|
267
|
+
if (colorRest) {
|
|
268
|
+
if (colorRest.type === 'hex') {
|
|
269
|
+
reactData.hexValue = colorRest.hex;
|
|
277
270
|
}
|
|
278
271
|
else {
|
|
279
|
-
|
|
280
|
-
|
|
272
|
+
reactData.rValue = colorRest.r;
|
|
273
|
+
reactData.gValue = colorRest.g;
|
|
274
|
+
reactData.bValue = colorRest.b;
|
|
275
|
+
reactData.aValue = colorRest.a;
|
|
276
|
+
}
|
|
277
|
+
if (colorRest.value) {
|
|
278
|
+
if (isRgb) {
|
|
279
|
+
if (colorRest.type === 'hex') {
|
|
280
|
+
const rgbRest = hexToRgb(colorRest.hex);
|
|
281
|
+
if (rgbRest) {
|
|
282
|
+
reactData.rValue = rgbRest.r;
|
|
283
|
+
reactData.gValue = rgbRest.g;
|
|
284
|
+
reactData.bValue = rgbRest.b;
|
|
285
|
+
reactData.aValue = rgbRest.a;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
if (colorRest.type !== 'hex') {
|
|
291
|
+
reactData.hexValue = rgbToHexVal(colorRest.r, colorRest.g, colorRest.b, colorRest.a);
|
|
292
|
+
}
|
|
281
293
|
}
|
|
282
294
|
}
|
|
283
295
|
}
|
|
284
296
|
if (isAniVisible) {
|
|
285
|
-
const hsvRest = colorRest.type === 'hex' ? hexToHsv(colorRest.hex) : rgbToHsv(colorRest);
|
|
297
|
+
const hsvRest = colorRest ? (colorRest.type === 'hex' ? hexToHsv(colorRest.hex) : rgbToHsv(colorRest)) : null;
|
|
286
298
|
const colorPanelEl = $xeColorPicker.$refs.refColorPanelElem;
|
|
287
299
|
if (hsvRest) {
|
|
288
300
|
if (colorPanelEl) {
|
|
@@ -295,7 +307,7 @@ export default {
|
|
|
295
307
|
}
|
|
296
308
|
}
|
|
297
309
|
if (alphaSliderEl) {
|
|
298
|
-
$xeColorPicker.handleAlphaColor(alphaSliderEl.clientWidth *
|
|
310
|
+
$xeColorPicker.handleAlphaColor(alphaSliderEl.clientWidth * reactData.aValue);
|
|
299
311
|
}
|
|
300
312
|
}
|
|
301
313
|
},
|
|
@@ -502,7 +514,7 @@ export default {
|
|
|
502
514
|
gNum = itemNum - offsetNum;
|
|
503
515
|
break;
|
|
504
516
|
}
|
|
505
|
-
reactData.panelColor =
|
|
517
|
+
reactData.panelColor = toValRgb(rNum, gNum, bNum);
|
|
506
518
|
hueSliderBtnEl.style.left = toCssUnit(offsetLeft);
|
|
507
519
|
}
|
|
508
520
|
},
|
|
@@ -580,7 +592,7 @@ export default {
|
|
|
580
592
|
const $xeColorPicker = this;
|
|
581
593
|
const reactData = $xeColorPicker.reactData;
|
|
582
594
|
const { rValue, gValue, bValue, aValue } = reactData;
|
|
583
|
-
reactData.selectColor =
|
|
595
|
+
reactData.selectColor = toValRgb(rValue, gValue, bValue, aValue);
|
|
584
596
|
$xeColorPicker.updateModelColor();
|
|
585
597
|
},
|
|
586
598
|
handleInputAlphaEvent() {
|
|
@@ -641,12 +653,12 @@ export default {
|
|
|
641
653
|
const colorPanelRect = colorPanelEl.getBoundingClientRect();
|
|
642
654
|
const offsetTop = Math.min(clientHeight, Math.max(0, clientY - colorPanelRect.y));
|
|
643
655
|
const offsetLeft = Math.min(clientWidth, Math.max(0, clientX - colorPanelRect.x));
|
|
644
|
-
const colorRest =
|
|
656
|
+
const colorRest = parseValColor(panelColor);
|
|
645
657
|
if (colorRest) {
|
|
646
658
|
const hsvRest = colorRest.type === 'hex' ? hexToHsv(colorRest.hex) : rgbToHsv(colorRest);
|
|
647
659
|
if (hsvRest) {
|
|
648
660
|
const ragRest = hsvToRgb(hsvRest.h, offsetLeft / clientWidth, (1 - offsetTop / clientHeight));
|
|
649
|
-
reactData.selectColor =
|
|
661
|
+
reactData.selectColor = toValRgb(ragRest.r, ragRest.g, ragRest.b, showAlpha ? aValue : null);
|
|
650
662
|
$xeColorPicker.handlePanelColor(offsetLeft, offsetTop);
|
|
651
663
|
}
|
|
652
664
|
}
|
|
@@ -1031,7 +1043,7 @@ export default {
|
|
|
1031
1043
|
reactData.hexValue = val;
|
|
1032
1044
|
},
|
|
1033
1045
|
change() {
|
|
1034
|
-
const colorRest =
|
|
1046
|
+
const colorRest = parseValColor(reactData.hexValue);
|
|
1035
1047
|
if (colorRest) {
|
|
1036
1048
|
if (colorRest.value) {
|
|
1037
1049
|
reactData.selectColor = colorRest.value;
|
|
@@ -8,13 +8,142 @@ const hexAlphaNumMaps = {};
|
|
|
8
8
|
});
|
|
9
9
|
const rgbRE = /^rgb(a?)\((\d{1,3})[,\s]+(\d{1,3})[,\s]+(\d{1,3})([,//\s]+([0-9.]{1,4})(%?))?\)$/;
|
|
10
10
|
export function hasRgb(value) {
|
|
11
|
-
return value && rgbRE.test(value);
|
|
11
|
+
return !!(value && rgbRE.test(value));
|
|
12
12
|
}
|
|
13
13
|
const hexRE = /^(#?)([0-9A-Fa-f]{6})([0-9A-Fa-f]{2})?$/;
|
|
14
14
|
export function hasHex(value) {
|
|
15
|
-
return value && hexRE.test(value);
|
|
15
|
+
return !!(value && hexRE.test(value));
|
|
16
16
|
}
|
|
17
|
-
export function
|
|
17
|
+
export function toRgb(value) {
|
|
18
|
+
if (value) {
|
|
19
|
+
if (hexRE.test(value)) {
|
|
20
|
+
return hexToRgb(value);
|
|
21
|
+
}
|
|
22
|
+
return parseRgbVal(value);
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
export function toRgbString(value) {
|
|
27
|
+
const rgbRest = toRgb(value);
|
|
28
|
+
if (rgbRest) {
|
|
29
|
+
return rgbRest.label;
|
|
30
|
+
}
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
export function toHex(value) {
|
|
34
|
+
if (value) {
|
|
35
|
+
if (rgbRE.test(value)) {
|
|
36
|
+
return rgbValToHex(value);
|
|
37
|
+
}
|
|
38
|
+
return parseHexVal(value);
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
export function toHexString(value) {
|
|
43
|
+
const hexRest = toHex(value);
|
|
44
|
+
if (hexRest) {
|
|
45
|
+
return hexRest.label;
|
|
46
|
+
}
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
export function toHsl(value) {
|
|
50
|
+
const rgbRest = toRgb(value);
|
|
51
|
+
if (rgbRest) {
|
|
52
|
+
const hslRest = rgbToHsl(rgbRest);
|
|
53
|
+
if (hslRest) {
|
|
54
|
+
const rest = Object.assign({ value, type: 'hsl' }, hslRest);
|
|
55
|
+
return rest;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
export function toHsv(value) {
|
|
61
|
+
const rgbRest = toRgb(value);
|
|
62
|
+
if (rgbRest) {
|
|
63
|
+
const hslRest = rgbToHsv(rgbRest);
|
|
64
|
+
if (hslRest) {
|
|
65
|
+
const rest = Object.assign({ value, type: 'hsv' }, hslRest);
|
|
66
|
+
return rest;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
export function parseColor(val, format) {
|
|
72
|
+
if (val) {
|
|
73
|
+
if (format === 'hex') {
|
|
74
|
+
return toHex(val);
|
|
75
|
+
}
|
|
76
|
+
if (format === 'hsl') {
|
|
77
|
+
return toHsl(val);
|
|
78
|
+
}
|
|
79
|
+
if (format === 'hsv') {
|
|
80
|
+
return toHsv(val);
|
|
81
|
+
}
|
|
82
|
+
return toRgb(val);
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
function handleNumClamp(val) {
|
|
87
|
+
return Math.min(1, Math.max(0, val));
|
|
88
|
+
}
|
|
89
|
+
function createLightenDarken(isAdd) {
|
|
90
|
+
return function (val, ratio) {
|
|
91
|
+
const colorRest = parseColor(val);
|
|
92
|
+
const hslRest = toHsl(val);
|
|
93
|
+
if (colorRest && hslRest) {
|
|
94
|
+
ratio = ratio === 0 ? 0 : ratio || 10;
|
|
95
|
+
hslRest.l += (isAdd ? ratio : -ratio) / 100;
|
|
96
|
+
hslRest.l = handleNumClamp(hslRest.l);
|
|
97
|
+
const rgbRest = hslToRgb(hslRest);
|
|
98
|
+
if (rgbRest) {
|
|
99
|
+
if ((colorRest === null || colorRest === void 0 ? void 0 : colorRest.type) === 'hex') {
|
|
100
|
+
return rgbToHexVal(rgbRest.r, rgbRest.g, rgbRest.b, hslRest.a);
|
|
101
|
+
}
|
|
102
|
+
return toValRgb(rgbRest.r, rgbRest.g, rgbRest.b, hslRest.a);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return val;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export const lighten = createLightenDarken(1);
|
|
109
|
+
export const darken = createLightenDarken(0);
|
|
110
|
+
function parseHexVal(value) {
|
|
111
|
+
if (value) {
|
|
112
|
+
const hexRest = value.match(hexRE);
|
|
113
|
+
if (hexRest) {
|
|
114
|
+
const rest = {
|
|
115
|
+
value,
|
|
116
|
+
label: value,
|
|
117
|
+
type: 'hex',
|
|
118
|
+
hex: value,
|
|
119
|
+
hexV: hexRest[2],
|
|
120
|
+
hexA: hexRest[3] || '',
|
|
121
|
+
a: (hexRest[3] ? hexAlphaKeyMaps[hexRest[3].toUpperCase()] : 1) || 1
|
|
122
|
+
};
|
|
123
|
+
return rest;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
function parseRgbVal(value) {
|
|
129
|
+
if (value) {
|
|
130
|
+
const rgbRest = value.match(rgbRE);
|
|
131
|
+
if (rgbRest) {
|
|
132
|
+
const rest = {
|
|
133
|
+
value,
|
|
134
|
+
label: value,
|
|
135
|
+
type: (rgbRest[6] ? 'rgba' : 'rgb'),
|
|
136
|
+
r: parseInt(rgbRest[2]),
|
|
137
|
+
g: parseInt(rgbRest[3]),
|
|
138
|
+
b: parseInt(rgbRest[4]),
|
|
139
|
+
a: rgbRest[7] ? parseInt(rgbRest[6]) / 100 : (rgbRest[6] ? parseFloat(rgbRest[6]) : 1)
|
|
140
|
+
};
|
|
141
|
+
return rest;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
export function parseValColor(value) {
|
|
18
147
|
const rest = {
|
|
19
148
|
value: '',
|
|
20
149
|
type: '',
|
|
@@ -27,49 +156,44 @@ export function parseColor(value) {
|
|
|
27
156
|
a: 1
|
|
28
157
|
};
|
|
29
158
|
if (value) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
rest.value = value;
|
|
33
|
-
rest.type = 'hex';
|
|
34
|
-
rest.hex = value;
|
|
35
|
-
rest.hexV = hexRest[2];
|
|
36
|
-
rest.hexA = hexRest[3] || '';
|
|
37
|
-
rest.a = (hexRest[3] ? hexAlphaKeyMaps[hexRest[3].toUpperCase()] : 1) || 1;
|
|
159
|
+
if (hexRE.test(value)) {
|
|
160
|
+
return Object.assign(rest, parseHexVal(value));
|
|
38
161
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
rest.value = value;
|
|
42
|
-
rest.type = rgbRest[6] ? 'rgba' : 'rgb';
|
|
43
|
-
rest.r = parseInt(rgbRest[2]);
|
|
44
|
-
rest.g = parseInt(rgbRest[3]);
|
|
45
|
-
rest.b = parseInt(rgbRest[4]);
|
|
46
|
-
rest.a = rgbRest[7] ? parseInt(rgbRest[6]) / 100 : (rgbRest[6] ? parseFloat(rgbRest[6]) : 1);
|
|
162
|
+
else if (rgbRE.test(value)) {
|
|
163
|
+
return Object.assign(rest, parseRgbVal(value));
|
|
47
164
|
}
|
|
48
165
|
}
|
|
49
166
|
return rest;
|
|
50
167
|
}
|
|
51
168
|
export function updateColorAlpha(value, alpha = 1) {
|
|
52
|
-
const colorRest =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return
|
|
169
|
+
const colorRest = parseValColor(value);
|
|
170
|
+
if (colorRest) {
|
|
171
|
+
const { type } = colorRest;
|
|
172
|
+
if (type === 'hex') {
|
|
173
|
+
return `#${colorRest.hexV}${alpha === 1 ? '' : (hexAlphaNumMaps[alpha] || '')}`;
|
|
174
|
+
}
|
|
175
|
+
return toValRgb(colorRest.r, colorRest.g, colorRest.b, alpha);
|
|
59
176
|
}
|
|
60
177
|
return '';
|
|
61
178
|
}
|
|
62
|
-
export function
|
|
63
|
-
if (XEUtils.eqNull(a)) {
|
|
179
|
+
export function toValRgb(r, g, b, a) {
|
|
180
|
+
if (XEUtils.eqNull(a) || a === 1) {
|
|
64
181
|
return `rgb(${r},${g},${b})`;
|
|
65
182
|
}
|
|
66
183
|
return `rgba(${r},${g},${b},${a})`;
|
|
67
184
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
185
|
+
function rgbValToHex(value) {
|
|
186
|
+
const rgbRest = parseRgbVal(value);
|
|
187
|
+
if (rgbRest) {
|
|
188
|
+
const hexVal = rgbToHexVal(rgbRest.r, rgbRest.g, rgbRest.b, rgbRest.a);
|
|
189
|
+
if (hexVal) {
|
|
190
|
+
return parseHexVal(hexVal);
|
|
191
|
+
}
|
|
71
192
|
}
|
|
72
|
-
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
export function rgbToHexVal(r, g, b, a) {
|
|
196
|
+
a = XEUtils.isNumber(a) ? a : 1;
|
|
73
197
|
const hexR = r.toString(16).padStart(2, '0');
|
|
74
198
|
const hexG = g.toString(16).padStart(2, '0');
|
|
75
199
|
const hexB = b.toString(16).padStart(2, '0');
|
|
@@ -120,6 +244,91 @@ export function rgbToHsv(rgbRest) {
|
|
|
120
244
|
v: XEUtils.round(val, 2)
|
|
121
245
|
};
|
|
122
246
|
}
|
|
247
|
+
function rgbToHsl(rgbRest) {
|
|
248
|
+
if (!rgbRest) {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
const { r, g, b, a } = rgbRest;
|
|
252
|
+
const rNorm = r / 255;
|
|
253
|
+
const gNorm = g / 255;
|
|
254
|
+
const bNorm = b / 255;
|
|
255
|
+
const max = Math.max(rNorm, gNorm, bNorm);
|
|
256
|
+
const min = Math.min(rNorm, gNorm, bNorm);
|
|
257
|
+
const delta = max - min;
|
|
258
|
+
let h = 0;
|
|
259
|
+
let s = 0;
|
|
260
|
+
const l = (max + min) / 2;
|
|
261
|
+
if (delta !== 0) {
|
|
262
|
+
s = l > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
|
263
|
+
if (max === rNorm) {
|
|
264
|
+
h = ((gNorm - bNorm) / delta) % 6;
|
|
265
|
+
}
|
|
266
|
+
else if (max === gNorm) {
|
|
267
|
+
h = (bNorm - rNorm) / delta + 2;
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
h = (rNorm - gNorm) / delta + 4;
|
|
271
|
+
}
|
|
272
|
+
h *= 60;
|
|
273
|
+
if (h < 0) {
|
|
274
|
+
h += 360;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
h,
|
|
279
|
+
s,
|
|
280
|
+
l,
|
|
281
|
+
a: XEUtils.isNumber(a) ? a : 1
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
function hslToRgb(slRest) {
|
|
285
|
+
if (!slRest) {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
let { h, s, l } = slRest;
|
|
289
|
+
const sNorm = s;
|
|
290
|
+
const lNorm = l;
|
|
291
|
+
h = ((h % 360) + 360) % 360;
|
|
292
|
+
const c = (1 - Math.abs(2 * lNorm - 1)) * sNorm;
|
|
293
|
+
const x = c * (1 - Math.abs((h / 60) % 2 - 1));
|
|
294
|
+
const m = lNorm - c / 2;
|
|
295
|
+
let r, g, b;
|
|
296
|
+
if (h >= 0 && h < 60) {
|
|
297
|
+
r = c;
|
|
298
|
+
g = x;
|
|
299
|
+
b = 0;
|
|
300
|
+
}
|
|
301
|
+
else if (h >= 60 && h < 120) {
|
|
302
|
+
r = x;
|
|
303
|
+
g = c;
|
|
304
|
+
b = 0;
|
|
305
|
+
}
|
|
306
|
+
else if (h >= 120 && h < 180) {
|
|
307
|
+
r = 0;
|
|
308
|
+
g = c;
|
|
309
|
+
b = x;
|
|
310
|
+
}
|
|
311
|
+
else if (h >= 180 && h < 240) {
|
|
312
|
+
r = 0;
|
|
313
|
+
g = x;
|
|
314
|
+
b = c;
|
|
315
|
+
}
|
|
316
|
+
else if (h >= 240 && h < 300) {
|
|
317
|
+
r = x;
|
|
318
|
+
g = 0;
|
|
319
|
+
b = c;
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
r = c;
|
|
323
|
+
g = 0;
|
|
324
|
+
b = x;
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
r: Math.round((r + m) * 255),
|
|
328
|
+
g: Math.round((g + m) * 255),
|
|
329
|
+
b: Math.round((b + m) * 255)
|
|
330
|
+
};
|
|
331
|
+
}
|
|
123
332
|
export function hsvToRgb(h, s, v) {
|
|
124
333
|
let r = 0;
|
|
125
334
|
let g = 0;
|
|
@@ -178,11 +387,18 @@ export function hexToRgb(str) {
|
|
|
178
387
|
if (str) {
|
|
179
388
|
const rests = str.match(/^(#?)([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})?$/);
|
|
180
389
|
if (rests) {
|
|
390
|
+
const r = parseInt(rests[2], 16);
|
|
391
|
+
const g = parseInt(rests[3], 16);
|
|
392
|
+
const b = parseInt(rests[4], 16);
|
|
393
|
+
const a = (rests[5] ? hexAlphaKeyMaps[rests[5].toUpperCase()] : 1) || 1;
|
|
181
394
|
return {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
395
|
+
value: str,
|
|
396
|
+
label: toValRgb(r, g, b, rests[5] ? a : null),
|
|
397
|
+
type: (rests[5] ? 'rgba' : 'rgb'),
|
|
398
|
+
r,
|
|
399
|
+
g,
|
|
400
|
+
b,
|
|
401
|
+
a
|
|
186
402
|
};
|
|
187
403
|
}
|
|
188
404
|
}
|
|
@@ -186,6 +186,7 @@ export default {
|
|
|
186
186
|
const $xeTable = $xeDatePicker.$xeTable;
|
|
187
187
|
const $xeModal = $xeDatePicker.$xeModal;
|
|
188
188
|
const $xeDrawer = $xeDatePicker.$xeDrawer;
|
|
189
|
+
const $xeCard = $xeDatePicker.$xeCard;
|
|
189
190
|
const $xeForm = $xeDatePicker.$xeForm;
|
|
190
191
|
const { transfer } = props;
|
|
191
192
|
const popupOpts = $xeDatePicker.computePopupOpts;
|
|
@@ -197,7 +198,7 @@ export default {
|
|
|
197
198
|
if (XEUtils.isBoolean(globalTransfer)) {
|
|
198
199
|
return globalTransfer;
|
|
199
200
|
}
|
|
200
|
-
if ($xeTable || $xeModal || $xeDrawer || $xeForm) {
|
|
201
|
+
if ($xeTable || $xeModal || $xeDrawer || $xeCard || $xeForm) {
|
|
201
202
|
return true;
|
|
202
203
|
}
|
|
203
204
|
}
|
|
@@ -181,6 +181,7 @@ export default {
|
|
|
181
181
|
const $xeTable = $xeDateRangePicker.$xeTable;
|
|
182
182
|
const $xeModal = $xeDateRangePicker.$xeModal;
|
|
183
183
|
const $xeDrawer = $xeDateRangePicker.$xeDrawer;
|
|
184
|
+
const $xeCard = $xeDateRangePicker.$xeCard;
|
|
184
185
|
const $xeForm = $xeDateRangePicker.$xeForm;
|
|
185
186
|
const { transfer } = props;
|
|
186
187
|
const popupOpts = $xeDateRangePicker.computePopupOpts;
|
|
@@ -192,7 +193,7 @@ export default {
|
|
|
192
193
|
if (XEUtils.isBoolean(globalTransfer)) {
|
|
193
194
|
return globalTransfer;
|
|
194
195
|
}
|
|
195
|
-
if ($xeTable || $xeModal || $xeDrawer || $xeForm) {
|
|
196
|
+
if ($xeTable || $xeModal || $xeDrawer || $xeCard || $xeForm) {
|
|
196
197
|
return true;
|
|
197
198
|
}
|
|
198
199
|
}
|