@nocobase/plugin-gantt 2.1.0-beta.38 → 2.1.0-beta.41
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/dist/client/index.js +1 -1
- package/dist/client-v2/793.629d4cd39664b681.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/client-v2/locale.d.ts +6 -0
- package/dist/client-v2/models/GanttBlockModel.d.ts +1 -1
- package/dist/client-v2/models/components/GanttBlock.helpers.d.ts +8 -0
- package/dist/client-v2/models/components/GanttBlock.styles.d.ts +2 -1
- package/dist/client-v2/models/components/GanttBlock.tree.d.ts +9 -6
- package/dist/{shared → client-v2/shared}/components/grid/style.d.ts +4 -3
- package/dist/{shared → client-v2/shared}/components/other/horizontal-scroll.d.ts +1 -1
- package/dist/externalVersion.js +6 -6
- package/dist/locale/en-US.json +4 -1
- package/dist/locale/zh-CN.json +4 -1
- package/package.json +2 -2
- package/dist/client-v2/143.1a8cf1cd5ce17b64.js +0 -10
- package/dist/node_modules/@ctrl/tinycolor/LICENSE +0 -7
- package/dist/node_modules/@ctrl/tinycolor/dist/bundles/tinycolor.umd.min.js +0 -2
- package/dist/node_modules/@ctrl/tinycolor/dist/conversion.d.ts +0 -61
- package/dist/node_modules/@ctrl/tinycolor/dist/conversion.js +0 -250
- package/dist/node_modules/@ctrl/tinycolor/dist/css-color-names.d.ts +0 -4
- package/dist/node_modules/@ctrl/tinycolor/dist/css-color-names.js +0 -157
- package/dist/node_modules/@ctrl/tinycolor/dist/format-input.d.ts +0 -37
- package/dist/node_modules/@ctrl/tinycolor/dist/format-input.js +0 -189
- package/dist/node_modules/@ctrl/tinycolor/dist/from-ratio.d.ts +0 -14
- package/dist/node_modules/@ctrl/tinycolor/dist/from-ratio.js +0 -30
- package/dist/node_modules/@ctrl/tinycolor/dist/index.d.ts +0 -207
- package/dist/node_modules/@ctrl/tinycolor/dist/index.js +0 -512
- package/dist/node_modules/@ctrl/tinycolor/dist/interfaces.d.ts +0 -46
- package/dist/node_modules/@ctrl/tinycolor/dist/interfaces.js +0 -2
- package/dist/node_modules/@ctrl/tinycolor/dist/module/conversion.js +0 -235
- package/dist/node_modules/@ctrl/tinycolor/dist/module/css-color-names.js +0 -154
- package/dist/node_modules/@ctrl/tinycolor/dist/module/format-input.js +0 -183
- package/dist/node_modules/@ctrl/tinycolor/dist/module/from-ratio.js +0 -25
- package/dist/node_modules/@ctrl/tinycolor/dist/module/index.js +0 -508
- package/dist/node_modules/@ctrl/tinycolor/dist/module/interfaces.js +0 -1
- package/dist/node_modules/@ctrl/tinycolor/dist/module/public_api.js +0 -12
- package/dist/node_modules/@ctrl/tinycolor/dist/module/random.js +0 -278
- package/dist/node_modules/@ctrl/tinycolor/dist/module/readability.js +0 -80
- package/dist/node_modules/@ctrl/tinycolor/dist/module/to-ms-filter.js +0 -16
- package/dist/node_modules/@ctrl/tinycolor/dist/module/umd_api.js +0 -20
- package/dist/node_modules/@ctrl/tinycolor/dist/module/util.js +0 -82
- package/dist/node_modules/@ctrl/tinycolor/dist/public_api.d.ts +0 -11
- package/dist/node_modules/@ctrl/tinycolor/dist/public_api.js +0 -1
- package/dist/node_modules/@ctrl/tinycolor/dist/random.d.ts +0 -24
- package/dist/node_modules/@ctrl/tinycolor/dist/random.js +0 -282
- package/dist/node_modules/@ctrl/tinycolor/dist/readability.d.ts +0 -46
- package/dist/node_modules/@ctrl/tinycolor/dist/readability.js +0 -86
- package/dist/node_modules/@ctrl/tinycolor/dist/to-ms-filter.d.ts +0 -5
- package/dist/node_modules/@ctrl/tinycolor/dist/to-ms-filter.js +0 -20
- package/dist/node_modules/@ctrl/tinycolor/dist/umd_api.d.ts +0 -23
- package/dist/node_modules/@ctrl/tinycolor/dist/umd_api.js +0 -22
- package/dist/node_modules/@ctrl/tinycolor/dist/util.d.ts +0 -36
- package/dist/node_modules/@ctrl/tinycolor/dist/util.js +0 -92
- package/dist/node_modules/@ctrl/tinycolor/package.json +0 -1
- package/dist/shared/components/calendar/calendar.js +0 -417
- package/dist/shared/components/calendar/style.js +0 -79
- package/dist/shared/components/calendar/top-part-of-calendar.js +0 -57
- package/dist/shared/components/gantt/style.js +0 -74
- package/dist/shared/components/gantt/task-gantt-content.js +0 -337
- package/dist/shared/components/gantt/task-gantt.js +0 -128
- package/dist/shared/components/grid/grid-body.js +0 -114
- package/dist/shared/components/grid/grid.js +0 -50
- package/dist/shared/components/grid/style.js +0 -54
- package/dist/shared/components/other/arrow.js +0 -90
- package/dist/shared/components/other/horizontal-scroll.js +0 -64
- package/dist/shared/components/other/style.js +0 -125
- package/dist/shared/components/other/tooltip.js +0 -137
- package/dist/shared/components/other/vertical-scroll.js +0 -74
- package/dist/shared/components/task-item/bar/bar-date-handle.js +0 -62
- package/dist/shared/components/task-item/bar/bar-display.js +0 -98
- package/dist/shared/components/task-item/bar/bar-progress-handle.js +0 -49
- package/dist/shared/components/task-item/bar/bar-small.js +0 -85
- package/dist/shared/components/task-item/bar/bar.js +0 -113
- package/dist/shared/components/task-item/bar/style.js +0 -58
- package/dist/shared/components/task-item/milestone/milestone.js +0 -72
- package/dist/shared/components/task-item/milestone/style.js +0 -45
- package/dist/shared/components/task-item/project/project.js +0 -77
- package/dist/shared/components/task-item/project/style.js +0 -51
- package/dist/shared/components/task-item/style.js +0 -74
- package/dist/shared/components/task-item/task-item.js +0 -132
- package/dist/shared/helpers/bar-helper.js +0 -415
- package/dist/shared/helpers/date-helper.js +0 -231
- package/dist/shared/helpers/other-helper.js +0 -97
- package/dist/shared/types/bar-task.js +0 -24
- package/dist/shared/types/date-setup.js +0 -24
- package/dist/shared/types/gantt-task-actions.js +0 -24
- package/dist/shared/types/public-types.js +0 -46
- /package/dist/{shared → client-v2/shared}/components/calendar/calendar.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/calendar/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/calendar/top-part-of-calendar.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/gantt/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/gantt/task-gantt-content.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/gantt/task-gantt.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/grid/grid-body.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/grid/grid.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/other/arrow.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/other/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/other/tooltip.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/other/vertical-scroll.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/bar/bar-date-handle.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/bar/bar-display.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/bar/bar-progress-handle.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/bar/bar-small.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/bar/bar.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/bar/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/milestone/milestone.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/milestone/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/project/project.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/project/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/style.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/components/task-item/task-item.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/helpers/bar-helper.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/helpers/date-helper.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/helpers/other-helper.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/types/bar-task.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/types/date-setup.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/types/gantt-task-actions.d.ts +0 -0
- /package/dist/{shared → client-v2/shared}/types/public-types.d.ts +0 -0
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { bound01, pad2 } from './util.js';
|
|
2
|
-
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
|
|
3
|
-
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
|
|
4
|
-
/**
|
|
5
|
-
* Handle bounds / percentage checking to conform to CSS color spec
|
|
6
|
-
* <http://www.w3.org/TR/css3-color/>
|
|
7
|
-
* *Assumes:* r, g, b in [0, 255] or [0, 1]
|
|
8
|
-
* *Returns:* { r, g, b } in [0, 255]
|
|
9
|
-
*/
|
|
10
|
-
export function rgbToRgb(r, g, b) {
|
|
11
|
-
return {
|
|
12
|
-
r: bound01(r, 255) * 255,
|
|
13
|
-
g: bound01(g, 255) * 255,
|
|
14
|
-
b: bound01(b, 255) * 255,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Converts an RGB color value to HSL.
|
|
19
|
-
* *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
|
|
20
|
-
* *Returns:* { h, s, l } in [0,1]
|
|
21
|
-
*/
|
|
22
|
-
export function rgbToHsl(r, g, b) {
|
|
23
|
-
r = bound01(r, 255);
|
|
24
|
-
g = bound01(g, 255);
|
|
25
|
-
b = bound01(b, 255);
|
|
26
|
-
var max = Math.max(r, g, b);
|
|
27
|
-
var min = Math.min(r, g, b);
|
|
28
|
-
var h = 0;
|
|
29
|
-
var s = 0;
|
|
30
|
-
var l = (max + min) / 2;
|
|
31
|
-
if (max === min) {
|
|
32
|
-
s = 0;
|
|
33
|
-
h = 0; // achromatic
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
var d = max - min;
|
|
37
|
-
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
38
|
-
switch (max) {
|
|
39
|
-
case r:
|
|
40
|
-
h = (g - b) / d + (g < b ? 6 : 0);
|
|
41
|
-
break;
|
|
42
|
-
case g:
|
|
43
|
-
h = (b - r) / d + 2;
|
|
44
|
-
break;
|
|
45
|
-
case b:
|
|
46
|
-
h = (r - g) / d + 4;
|
|
47
|
-
break;
|
|
48
|
-
default:
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
h /= 6;
|
|
52
|
-
}
|
|
53
|
-
return { h: h, s: s, l: l };
|
|
54
|
-
}
|
|
55
|
-
function hue2rgb(p, q, t) {
|
|
56
|
-
if (t < 0) {
|
|
57
|
-
t += 1;
|
|
58
|
-
}
|
|
59
|
-
if (t > 1) {
|
|
60
|
-
t -= 1;
|
|
61
|
-
}
|
|
62
|
-
if (t < 1 / 6) {
|
|
63
|
-
return p + (q - p) * (6 * t);
|
|
64
|
-
}
|
|
65
|
-
if (t < 1 / 2) {
|
|
66
|
-
return q;
|
|
67
|
-
}
|
|
68
|
-
if (t < 2 / 3) {
|
|
69
|
-
return p + (q - p) * (2 / 3 - t) * 6;
|
|
70
|
-
}
|
|
71
|
-
return p;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Converts an HSL color value to RGB.
|
|
75
|
-
*
|
|
76
|
-
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
|
|
77
|
-
* *Returns:* { r, g, b } in the set [0, 255]
|
|
78
|
-
*/
|
|
79
|
-
export function hslToRgb(h, s, l) {
|
|
80
|
-
var r;
|
|
81
|
-
var g;
|
|
82
|
-
var b;
|
|
83
|
-
h = bound01(h, 360);
|
|
84
|
-
s = bound01(s, 100);
|
|
85
|
-
l = bound01(l, 100);
|
|
86
|
-
if (s === 0) {
|
|
87
|
-
// achromatic
|
|
88
|
-
g = l;
|
|
89
|
-
b = l;
|
|
90
|
-
r = l;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
94
|
-
var p = 2 * l - q;
|
|
95
|
-
r = hue2rgb(p, q, h + 1 / 3);
|
|
96
|
-
g = hue2rgb(p, q, h);
|
|
97
|
-
b = hue2rgb(p, q, h - 1 / 3);
|
|
98
|
-
}
|
|
99
|
-
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Converts an RGB color value to HSV
|
|
103
|
-
*
|
|
104
|
-
* *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
|
|
105
|
-
* *Returns:* { h, s, v } in [0,1]
|
|
106
|
-
*/
|
|
107
|
-
export function rgbToHsv(r, g, b) {
|
|
108
|
-
r = bound01(r, 255);
|
|
109
|
-
g = bound01(g, 255);
|
|
110
|
-
b = bound01(b, 255);
|
|
111
|
-
var max = Math.max(r, g, b);
|
|
112
|
-
var min = Math.min(r, g, b);
|
|
113
|
-
var h = 0;
|
|
114
|
-
var v = max;
|
|
115
|
-
var d = max - min;
|
|
116
|
-
var s = max === 0 ? 0 : d / max;
|
|
117
|
-
if (max === min) {
|
|
118
|
-
h = 0; // achromatic
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
switch (max) {
|
|
122
|
-
case r:
|
|
123
|
-
h = (g - b) / d + (g < b ? 6 : 0);
|
|
124
|
-
break;
|
|
125
|
-
case g:
|
|
126
|
-
h = (b - r) / d + 2;
|
|
127
|
-
break;
|
|
128
|
-
case b:
|
|
129
|
-
h = (r - g) / d + 4;
|
|
130
|
-
break;
|
|
131
|
-
default:
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
h /= 6;
|
|
135
|
-
}
|
|
136
|
-
return { h: h, s: s, v: v };
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Converts an HSV color value to RGB.
|
|
140
|
-
*
|
|
141
|
-
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
|
|
142
|
-
* *Returns:* { r, g, b } in the set [0, 255]
|
|
143
|
-
*/
|
|
144
|
-
export function hsvToRgb(h, s, v) {
|
|
145
|
-
h = bound01(h, 360) * 6;
|
|
146
|
-
s = bound01(s, 100);
|
|
147
|
-
v = bound01(v, 100);
|
|
148
|
-
var i = Math.floor(h);
|
|
149
|
-
var f = h - i;
|
|
150
|
-
var p = v * (1 - s);
|
|
151
|
-
var q = v * (1 - f * s);
|
|
152
|
-
var t = v * (1 - (1 - f) * s);
|
|
153
|
-
var mod = i % 6;
|
|
154
|
-
var r = [v, q, p, p, t, v][mod];
|
|
155
|
-
var g = [t, v, v, q, p, p][mod];
|
|
156
|
-
var b = [p, p, t, v, v, q][mod];
|
|
157
|
-
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Converts an RGB color to hex
|
|
161
|
-
*
|
|
162
|
-
* Assumes r, g, and b are contained in the set [0, 255]
|
|
163
|
-
* Returns a 3 or 6 character hex
|
|
164
|
-
*/
|
|
165
|
-
export function rgbToHex(r, g, b, allow3Char) {
|
|
166
|
-
var hex = [
|
|
167
|
-
pad2(Math.round(r).toString(16)),
|
|
168
|
-
pad2(Math.round(g).toString(16)),
|
|
169
|
-
pad2(Math.round(b).toString(16)),
|
|
170
|
-
];
|
|
171
|
-
// Return a 3 character hex if possible
|
|
172
|
-
if (allow3Char &&
|
|
173
|
-
hex[0].startsWith(hex[0].charAt(1)) &&
|
|
174
|
-
hex[1].startsWith(hex[1].charAt(1)) &&
|
|
175
|
-
hex[2].startsWith(hex[2].charAt(1))) {
|
|
176
|
-
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
177
|
-
}
|
|
178
|
-
return hex.join('');
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Converts an RGBA color plus alpha transparency to hex
|
|
182
|
-
*
|
|
183
|
-
* Assumes r, g, b are contained in the set [0, 255] and
|
|
184
|
-
* a in [0, 1]. Returns a 4 or 8 character rgba hex
|
|
185
|
-
*/
|
|
186
|
-
// eslint-disable-next-line max-params
|
|
187
|
-
export function rgbaToHex(r, g, b, a, allow4Char) {
|
|
188
|
-
var hex = [
|
|
189
|
-
pad2(Math.round(r).toString(16)),
|
|
190
|
-
pad2(Math.round(g).toString(16)),
|
|
191
|
-
pad2(Math.round(b).toString(16)),
|
|
192
|
-
pad2(convertDecimalToHex(a)),
|
|
193
|
-
];
|
|
194
|
-
// Return a 4 character hex if possible
|
|
195
|
-
if (allow4Char &&
|
|
196
|
-
hex[0].startsWith(hex[0].charAt(1)) &&
|
|
197
|
-
hex[1].startsWith(hex[1].charAt(1)) &&
|
|
198
|
-
hex[2].startsWith(hex[2].charAt(1)) &&
|
|
199
|
-
hex[3].startsWith(hex[3].charAt(1))) {
|
|
200
|
-
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
|
|
201
|
-
}
|
|
202
|
-
return hex.join('');
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Converts an RGBA color to an ARGB Hex8 string
|
|
206
|
-
* Rarely used, but required for "toFilter()"
|
|
207
|
-
*/
|
|
208
|
-
export function rgbaToArgbHex(r, g, b, a) {
|
|
209
|
-
var hex = [
|
|
210
|
-
pad2(convertDecimalToHex(a)),
|
|
211
|
-
pad2(Math.round(r).toString(16)),
|
|
212
|
-
pad2(Math.round(g).toString(16)),
|
|
213
|
-
pad2(Math.round(b).toString(16)),
|
|
214
|
-
];
|
|
215
|
-
return hex.join('');
|
|
216
|
-
}
|
|
217
|
-
/** Converts a decimal to a hex value */
|
|
218
|
-
export function convertDecimalToHex(d) {
|
|
219
|
-
return Math.round(parseFloat(d) * 255).toString(16);
|
|
220
|
-
}
|
|
221
|
-
/** Converts a hex value to a decimal */
|
|
222
|
-
export function convertHexToDecimal(h) {
|
|
223
|
-
return parseIntFromHex(h) / 255;
|
|
224
|
-
}
|
|
225
|
-
/** Parse a base-16 hex value into a base-10 integer */
|
|
226
|
-
export function parseIntFromHex(val) {
|
|
227
|
-
return parseInt(val, 16);
|
|
228
|
-
}
|
|
229
|
-
export function numberInputToObject(color) {
|
|
230
|
-
return {
|
|
231
|
-
r: color >> 16,
|
|
232
|
-
g: (color & 0xff00) >> 8,
|
|
233
|
-
b: color & 0xff,
|
|
234
|
-
};
|
|
235
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json
|
|
2
|
-
/**
|
|
3
|
-
* @hidden
|
|
4
|
-
*/
|
|
5
|
-
export var names = {
|
|
6
|
-
aliceblue: '#f0f8ff',
|
|
7
|
-
antiquewhite: '#faebd7',
|
|
8
|
-
aqua: '#00ffff',
|
|
9
|
-
aquamarine: '#7fffd4',
|
|
10
|
-
azure: '#f0ffff',
|
|
11
|
-
beige: '#f5f5dc',
|
|
12
|
-
bisque: '#ffe4c4',
|
|
13
|
-
black: '#000000',
|
|
14
|
-
blanchedalmond: '#ffebcd',
|
|
15
|
-
blue: '#0000ff',
|
|
16
|
-
blueviolet: '#8a2be2',
|
|
17
|
-
brown: '#a52a2a',
|
|
18
|
-
burlywood: '#deb887',
|
|
19
|
-
cadetblue: '#5f9ea0',
|
|
20
|
-
chartreuse: '#7fff00',
|
|
21
|
-
chocolate: '#d2691e',
|
|
22
|
-
coral: '#ff7f50',
|
|
23
|
-
cornflowerblue: '#6495ed',
|
|
24
|
-
cornsilk: '#fff8dc',
|
|
25
|
-
crimson: '#dc143c',
|
|
26
|
-
cyan: '#00ffff',
|
|
27
|
-
darkblue: '#00008b',
|
|
28
|
-
darkcyan: '#008b8b',
|
|
29
|
-
darkgoldenrod: '#b8860b',
|
|
30
|
-
darkgray: '#a9a9a9',
|
|
31
|
-
darkgreen: '#006400',
|
|
32
|
-
darkgrey: '#a9a9a9',
|
|
33
|
-
darkkhaki: '#bdb76b',
|
|
34
|
-
darkmagenta: '#8b008b',
|
|
35
|
-
darkolivegreen: '#556b2f',
|
|
36
|
-
darkorange: '#ff8c00',
|
|
37
|
-
darkorchid: '#9932cc',
|
|
38
|
-
darkred: '#8b0000',
|
|
39
|
-
darksalmon: '#e9967a',
|
|
40
|
-
darkseagreen: '#8fbc8f',
|
|
41
|
-
darkslateblue: '#483d8b',
|
|
42
|
-
darkslategray: '#2f4f4f',
|
|
43
|
-
darkslategrey: '#2f4f4f',
|
|
44
|
-
darkturquoise: '#00ced1',
|
|
45
|
-
darkviolet: '#9400d3',
|
|
46
|
-
deeppink: '#ff1493',
|
|
47
|
-
deepskyblue: '#00bfff',
|
|
48
|
-
dimgray: '#696969',
|
|
49
|
-
dimgrey: '#696969',
|
|
50
|
-
dodgerblue: '#1e90ff',
|
|
51
|
-
firebrick: '#b22222',
|
|
52
|
-
floralwhite: '#fffaf0',
|
|
53
|
-
forestgreen: '#228b22',
|
|
54
|
-
fuchsia: '#ff00ff',
|
|
55
|
-
gainsboro: '#dcdcdc',
|
|
56
|
-
ghostwhite: '#f8f8ff',
|
|
57
|
-
goldenrod: '#daa520',
|
|
58
|
-
gold: '#ffd700',
|
|
59
|
-
gray: '#808080',
|
|
60
|
-
green: '#008000',
|
|
61
|
-
greenyellow: '#adff2f',
|
|
62
|
-
grey: '#808080',
|
|
63
|
-
honeydew: '#f0fff0',
|
|
64
|
-
hotpink: '#ff69b4',
|
|
65
|
-
indianred: '#cd5c5c',
|
|
66
|
-
indigo: '#4b0082',
|
|
67
|
-
ivory: '#fffff0',
|
|
68
|
-
khaki: '#f0e68c',
|
|
69
|
-
lavenderblush: '#fff0f5',
|
|
70
|
-
lavender: '#e6e6fa',
|
|
71
|
-
lawngreen: '#7cfc00',
|
|
72
|
-
lemonchiffon: '#fffacd',
|
|
73
|
-
lightblue: '#add8e6',
|
|
74
|
-
lightcoral: '#f08080',
|
|
75
|
-
lightcyan: '#e0ffff',
|
|
76
|
-
lightgoldenrodyellow: '#fafad2',
|
|
77
|
-
lightgray: '#d3d3d3',
|
|
78
|
-
lightgreen: '#90ee90',
|
|
79
|
-
lightgrey: '#d3d3d3',
|
|
80
|
-
lightpink: '#ffb6c1',
|
|
81
|
-
lightsalmon: '#ffa07a',
|
|
82
|
-
lightseagreen: '#20b2aa',
|
|
83
|
-
lightskyblue: '#87cefa',
|
|
84
|
-
lightslategray: '#778899',
|
|
85
|
-
lightslategrey: '#778899',
|
|
86
|
-
lightsteelblue: '#b0c4de',
|
|
87
|
-
lightyellow: '#ffffe0',
|
|
88
|
-
lime: '#00ff00',
|
|
89
|
-
limegreen: '#32cd32',
|
|
90
|
-
linen: '#faf0e6',
|
|
91
|
-
magenta: '#ff00ff',
|
|
92
|
-
maroon: '#800000',
|
|
93
|
-
mediumaquamarine: '#66cdaa',
|
|
94
|
-
mediumblue: '#0000cd',
|
|
95
|
-
mediumorchid: '#ba55d3',
|
|
96
|
-
mediumpurple: '#9370db',
|
|
97
|
-
mediumseagreen: '#3cb371',
|
|
98
|
-
mediumslateblue: '#7b68ee',
|
|
99
|
-
mediumspringgreen: '#00fa9a',
|
|
100
|
-
mediumturquoise: '#48d1cc',
|
|
101
|
-
mediumvioletred: '#c71585',
|
|
102
|
-
midnightblue: '#191970',
|
|
103
|
-
mintcream: '#f5fffa',
|
|
104
|
-
mistyrose: '#ffe4e1',
|
|
105
|
-
moccasin: '#ffe4b5',
|
|
106
|
-
navajowhite: '#ffdead',
|
|
107
|
-
navy: '#000080',
|
|
108
|
-
oldlace: '#fdf5e6',
|
|
109
|
-
olive: '#808000',
|
|
110
|
-
olivedrab: '#6b8e23',
|
|
111
|
-
orange: '#ffa500',
|
|
112
|
-
orangered: '#ff4500',
|
|
113
|
-
orchid: '#da70d6',
|
|
114
|
-
palegoldenrod: '#eee8aa',
|
|
115
|
-
palegreen: '#98fb98',
|
|
116
|
-
paleturquoise: '#afeeee',
|
|
117
|
-
palevioletred: '#db7093',
|
|
118
|
-
papayawhip: '#ffefd5',
|
|
119
|
-
peachpuff: '#ffdab9',
|
|
120
|
-
peru: '#cd853f',
|
|
121
|
-
pink: '#ffc0cb',
|
|
122
|
-
plum: '#dda0dd',
|
|
123
|
-
powderblue: '#b0e0e6',
|
|
124
|
-
purple: '#800080',
|
|
125
|
-
rebeccapurple: '#663399',
|
|
126
|
-
red: '#ff0000',
|
|
127
|
-
rosybrown: '#bc8f8f',
|
|
128
|
-
royalblue: '#4169e1',
|
|
129
|
-
saddlebrown: '#8b4513',
|
|
130
|
-
salmon: '#fa8072',
|
|
131
|
-
sandybrown: '#f4a460',
|
|
132
|
-
seagreen: '#2e8b57',
|
|
133
|
-
seashell: '#fff5ee',
|
|
134
|
-
sienna: '#a0522d',
|
|
135
|
-
silver: '#c0c0c0',
|
|
136
|
-
skyblue: '#87ceeb',
|
|
137
|
-
slateblue: '#6a5acd',
|
|
138
|
-
slategray: '#708090',
|
|
139
|
-
slategrey: '#708090',
|
|
140
|
-
snow: '#fffafa',
|
|
141
|
-
springgreen: '#00ff7f',
|
|
142
|
-
steelblue: '#4682b4',
|
|
143
|
-
tan: '#d2b48c',
|
|
144
|
-
teal: '#008080',
|
|
145
|
-
thistle: '#d8bfd8',
|
|
146
|
-
tomato: '#ff6347',
|
|
147
|
-
turquoise: '#40e0d0',
|
|
148
|
-
violet: '#ee82ee',
|
|
149
|
-
wheat: '#f5deb3',
|
|
150
|
-
white: '#ffffff',
|
|
151
|
-
whitesmoke: '#f5f5f5',
|
|
152
|
-
yellow: '#ffff00',
|
|
153
|
-
yellowgreen: '#9acd32',
|
|
154
|
-
};
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
|
|
2
|
-
import { convertHexToDecimal, hslToRgb, hsvToRgb, parseIntFromHex, rgbToRgb, } from './conversion.js';
|
|
3
|
-
import { names } from './css-color-names.js';
|
|
4
|
-
import { boundAlpha, convertToPercentage } from './util.js';
|
|
5
|
-
/**
|
|
6
|
-
* Given a string or object, convert that input to RGB
|
|
7
|
-
*
|
|
8
|
-
* Possible string inputs:
|
|
9
|
-
* ```
|
|
10
|
-
* "red"
|
|
11
|
-
* "#f00" or "f00"
|
|
12
|
-
* "#ff0000" or "ff0000"
|
|
13
|
-
* "#ff000000" or "ff000000"
|
|
14
|
-
* "rgb 255 0 0" or "rgb (255, 0, 0)"
|
|
15
|
-
* "rgb 1.0 0 0" or "rgb (1, 0, 0)"
|
|
16
|
-
* "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
|
|
17
|
-
* "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
|
|
18
|
-
* "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
|
|
19
|
-
* "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
|
|
20
|
-
* "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export function inputToRGB(color) {
|
|
24
|
-
var rgb = { r: 0, g: 0, b: 0 };
|
|
25
|
-
var a = 1;
|
|
26
|
-
var s = null;
|
|
27
|
-
var v = null;
|
|
28
|
-
var l = null;
|
|
29
|
-
var ok = false;
|
|
30
|
-
var format = false;
|
|
31
|
-
if (typeof color === 'string') {
|
|
32
|
-
color = stringInputToObject(color);
|
|
33
|
-
}
|
|
34
|
-
if (typeof color === 'object') {
|
|
35
|
-
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
|
|
36
|
-
rgb = rgbToRgb(color.r, color.g, color.b);
|
|
37
|
-
ok = true;
|
|
38
|
-
format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb';
|
|
39
|
-
}
|
|
40
|
-
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
|
|
41
|
-
s = convertToPercentage(color.s);
|
|
42
|
-
v = convertToPercentage(color.v);
|
|
43
|
-
rgb = hsvToRgb(color.h, s, v);
|
|
44
|
-
ok = true;
|
|
45
|
-
format = 'hsv';
|
|
46
|
-
}
|
|
47
|
-
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
|
|
48
|
-
s = convertToPercentage(color.s);
|
|
49
|
-
l = convertToPercentage(color.l);
|
|
50
|
-
rgb = hslToRgb(color.h, s, l);
|
|
51
|
-
ok = true;
|
|
52
|
-
format = 'hsl';
|
|
53
|
-
}
|
|
54
|
-
if (Object.prototype.hasOwnProperty.call(color, 'a')) {
|
|
55
|
-
a = color.a;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
a = boundAlpha(a);
|
|
59
|
-
return {
|
|
60
|
-
ok: ok,
|
|
61
|
-
format: color.format || format,
|
|
62
|
-
r: Math.min(255, Math.max(rgb.r, 0)),
|
|
63
|
-
g: Math.min(255, Math.max(rgb.g, 0)),
|
|
64
|
-
b: Math.min(255, Math.max(rgb.b, 0)),
|
|
65
|
-
a: a,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
// <http://www.w3.org/TR/css3-values/#integers>
|
|
69
|
-
var CSS_INTEGER = '[-\\+]?\\d+%?';
|
|
70
|
-
// <http://www.w3.org/TR/css3-values/#number-value>
|
|
71
|
-
var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
|
|
72
|
-
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
|
|
73
|
-
var CSS_UNIT = "(?:".concat(CSS_NUMBER, ")|(?:").concat(CSS_INTEGER, ")");
|
|
74
|
-
// Actual matching.
|
|
75
|
-
// Parentheses and commas are optional, but not required.
|
|
76
|
-
// Whitespace can take the place of commas or opening paren
|
|
77
|
-
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
|
|
78
|
-
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
|
|
79
|
-
var matchers = {
|
|
80
|
-
CSS_UNIT: new RegExp(CSS_UNIT),
|
|
81
|
-
rgb: new RegExp('rgb' + PERMISSIVE_MATCH3),
|
|
82
|
-
rgba: new RegExp('rgba' + PERMISSIVE_MATCH4),
|
|
83
|
-
hsl: new RegExp('hsl' + PERMISSIVE_MATCH3),
|
|
84
|
-
hsla: new RegExp('hsla' + PERMISSIVE_MATCH4),
|
|
85
|
-
hsv: new RegExp('hsv' + PERMISSIVE_MATCH3),
|
|
86
|
-
hsva: new RegExp('hsva' + PERMISSIVE_MATCH4),
|
|
87
|
-
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
88
|
-
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
89
|
-
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
90
|
-
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Permissive string parsing. Take in a number of formats, and output an object
|
|
94
|
-
* based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
|
|
95
|
-
*/
|
|
96
|
-
export function stringInputToObject(color) {
|
|
97
|
-
color = color.trim().toLowerCase();
|
|
98
|
-
if (color.length === 0) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
var named = false;
|
|
102
|
-
if (names[color]) {
|
|
103
|
-
color = names[color];
|
|
104
|
-
named = true;
|
|
105
|
-
}
|
|
106
|
-
else if (color === 'transparent') {
|
|
107
|
-
return { r: 0, g: 0, b: 0, a: 0, format: 'name' };
|
|
108
|
-
}
|
|
109
|
-
// Try to match string input using regular expressions.
|
|
110
|
-
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
|
|
111
|
-
// Just return an object and let the conversion functions handle that.
|
|
112
|
-
// This way the result will be the same whether the tinycolor is initialized with string or object.
|
|
113
|
-
var match = matchers.rgb.exec(color);
|
|
114
|
-
if (match) {
|
|
115
|
-
return { r: match[1], g: match[2], b: match[3] };
|
|
116
|
-
}
|
|
117
|
-
match = matchers.rgba.exec(color);
|
|
118
|
-
if (match) {
|
|
119
|
-
return { r: match[1], g: match[2], b: match[3], a: match[4] };
|
|
120
|
-
}
|
|
121
|
-
match = matchers.hsl.exec(color);
|
|
122
|
-
if (match) {
|
|
123
|
-
return { h: match[1], s: match[2], l: match[3] };
|
|
124
|
-
}
|
|
125
|
-
match = matchers.hsla.exec(color);
|
|
126
|
-
if (match) {
|
|
127
|
-
return { h: match[1], s: match[2], l: match[3], a: match[4] };
|
|
128
|
-
}
|
|
129
|
-
match = matchers.hsv.exec(color);
|
|
130
|
-
if (match) {
|
|
131
|
-
return { h: match[1], s: match[2], v: match[3] };
|
|
132
|
-
}
|
|
133
|
-
match = matchers.hsva.exec(color);
|
|
134
|
-
if (match) {
|
|
135
|
-
return { h: match[1], s: match[2], v: match[3], a: match[4] };
|
|
136
|
-
}
|
|
137
|
-
match = matchers.hex8.exec(color);
|
|
138
|
-
if (match) {
|
|
139
|
-
return {
|
|
140
|
-
r: parseIntFromHex(match[1]),
|
|
141
|
-
g: parseIntFromHex(match[2]),
|
|
142
|
-
b: parseIntFromHex(match[3]),
|
|
143
|
-
a: convertHexToDecimal(match[4]),
|
|
144
|
-
format: named ? 'name' : 'hex8',
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
match = matchers.hex6.exec(color);
|
|
148
|
-
if (match) {
|
|
149
|
-
return {
|
|
150
|
-
r: parseIntFromHex(match[1]),
|
|
151
|
-
g: parseIntFromHex(match[2]),
|
|
152
|
-
b: parseIntFromHex(match[3]),
|
|
153
|
-
format: named ? 'name' : 'hex',
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
match = matchers.hex4.exec(color);
|
|
157
|
-
if (match) {
|
|
158
|
-
return {
|
|
159
|
-
r: parseIntFromHex(match[1] + match[1]),
|
|
160
|
-
g: parseIntFromHex(match[2] + match[2]),
|
|
161
|
-
b: parseIntFromHex(match[3] + match[3]),
|
|
162
|
-
a: convertHexToDecimal(match[4] + match[4]),
|
|
163
|
-
format: named ? 'name' : 'hex8',
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
match = matchers.hex3.exec(color);
|
|
167
|
-
if (match) {
|
|
168
|
-
return {
|
|
169
|
-
r: parseIntFromHex(match[1] + match[1]),
|
|
170
|
-
g: parseIntFromHex(match[2] + match[2]),
|
|
171
|
-
b: parseIntFromHex(match[3] + match[3]),
|
|
172
|
-
format: named ? 'name' : 'hex',
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Check to see if it looks like a CSS unit
|
|
179
|
-
* (see `matchers` above for definition).
|
|
180
|
-
*/
|
|
181
|
-
export function isValidCSSUnit(color) {
|
|
182
|
-
return Boolean(matchers.CSS_UNIT.exec(String(color)));
|
|
183
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { TinyColor } from './index.js';
|
|
2
|
-
import { convertToPercentage } from './util.js';
|
|
3
|
-
/**
|
|
4
|
-
* If input is an object, force 1 into "1.0" to handle ratios properly
|
|
5
|
-
* String input requires "1.0" as input, so 1 will be treated as 1
|
|
6
|
-
*/
|
|
7
|
-
export function fromRatio(ratio, opts) {
|
|
8
|
-
var newColor = {
|
|
9
|
-
r: convertToPercentage(ratio.r),
|
|
10
|
-
g: convertToPercentage(ratio.g),
|
|
11
|
-
b: convertToPercentage(ratio.b),
|
|
12
|
-
};
|
|
13
|
-
if (ratio.a !== undefined) {
|
|
14
|
-
newColor.a = Number(ratio.a);
|
|
15
|
-
}
|
|
16
|
-
return new TinyColor(newColor, opts);
|
|
17
|
-
}
|
|
18
|
-
/** old random function */
|
|
19
|
-
export function legacyRandom() {
|
|
20
|
-
return new TinyColor({
|
|
21
|
-
r: Math.random(),
|
|
22
|
-
g: Math.random(),
|
|
23
|
-
b: Math.random(),
|
|
24
|
-
});
|
|
25
|
-
}
|