@nocobase/plugin-gantt 2.1.0-beta.37 → 2.1.0-beta.38
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/client-v2.d.ts +2 -0
- package/client-v2.js +3 -0
- package/dist/client/index.js +1 -1
- package/dist/client-v2/143.1a8cf1cd5ce17b64.js +10 -0
- package/dist/client-v2/416.b7bb09162520e448.js +10 -0
- package/dist/client-v2/617.de3dc437887f3f07.js +10 -0
- package/dist/client-v2/872.e640aca77c79d895.js +10 -0
- package/dist/client-v2/index.d.ts +10 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/locale.d.ts +78 -0
- package/dist/client-v2/models/GanttBlockModel.d.ts +98 -0
- package/dist/client-v2/models/GanttBlockModel.helpers.d.ts +31 -0
- package/dist/client-v2/models/GanttBlockModel.settings.d.ts +9 -0
- package/dist/client-v2/models/actions/GanttActionModels.d.ts +33 -0
- package/dist/client-v2/models/actions/GanttPopupModels.d.ts +26 -0
- package/dist/client-v2/models/components/GanttBlock.d.ts +13 -0
- package/dist/client-v2/models/components/GanttBlock.helpers.d.ts +22 -0
- package/dist/client-v2/models/components/GanttBlock.styles.d.ts +22 -0
- package/dist/client-v2/models/components/GanttBlock.tree.d.ts +46 -0
- package/dist/client-v2/models/components/getLabelFormatValue.d.ts +11 -0
- package/dist/client-v2/models/index.d.ts +11 -0
- package/dist/client-v2/plugin.d.ts +13 -0
- package/dist/externalVersion.js +7 -6
- package/dist/locale/de-DE.json +2 -0
- package/dist/locale/en-US.json +25 -1
- package/dist/locale/es-ES.json +2 -0
- package/dist/locale/fr-FR.json +2 -0
- package/dist/locale/hu-HU.json +2 -0
- package/dist/locale/id-ID.json +2 -0
- package/dist/locale/it-IT.json +2 -0
- package/dist/locale/ja-JP.json +2 -0
- package/dist/locale/ko-KR.json +2 -0
- package/dist/locale/nl-NL.json +2 -0
- package/dist/locale/pt-BR.json +2 -0
- package/dist/locale/ru-RU.json +2 -0
- package/dist/locale/tr-TR.json +2 -0
- package/dist/locale/uk-UA.json +2 -0
- package/dist/locale/vi-VN.json +2 -0
- package/dist/locale/zh-CN.json +25 -1
- package/dist/locale/zh-TW.json +4 -0
- package/dist/node_modules/@ctrl/tinycolor/LICENSE +7 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/bundles/tinycolor.umd.min.js +2 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/conversion.d.ts +61 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/conversion.js +250 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/css-color-names.d.ts +4 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/css-color-names.js +157 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/format-input.d.ts +37 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/format-input.js +189 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/from-ratio.d.ts +14 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/from-ratio.js +30 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/index.d.ts +207 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/index.js +512 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/interfaces.d.ts +46 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/interfaces.js +2 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/module/conversion.js +235 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/module/css-color-names.js +154 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/module/format-input.js +183 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/module/from-ratio.js +25 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/module/index.js +508 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/module/interfaces.js +1 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/module/public_api.js +12 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/module/random.js +278 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/module/readability.js +80 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/module/to-ms-filter.js +16 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/module/umd_api.js +20 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/module/util.js +82 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/public_api.d.ts +11 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/public_api.js +1 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/random.d.ts +24 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/random.js +282 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/readability.d.ts +46 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/readability.js +86 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/to-ms-filter.d.ts +5 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/to-ms-filter.js +20 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/umd_api.d.ts +23 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/umd_api.js +22 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/util.d.ts +36 -0
- package/dist/node_modules/@ctrl/tinycolor/dist/util.js +92 -0
- package/dist/node_modules/@ctrl/tinycolor/package.json +1 -0
- package/dist/shared/components/calendar/calendar.d.ts +22 -0
- package/dist/shared/components/calendar/calendar.js +417 -0
- package/dist/shared/components/calendar/style.d.ts +14 -0
- package/dist/shared/components/calendar/style.js +79 -0
- package/dist/shared/components/calendar/top-part-of-calendar.d.ts +19 -0
- package/dist/shared/components/calendar/top-part-of-calendar.js +57 -0
- package/dist/shared/components/gantt/style.d.ts +14 -0
- package/dist/shared/components/gantt/style.js +74 -0
- package/dist/shared/components/gantt/task-gantt-content.d.ts +35 -0
- package/dist/shared/components/gantt/task-gantt-content.js +337 -0
- package/dist/shared/components/gantt/task-gantt.d.ts +24 -0
- package/dist/shared/components/gantt/task-gantt.js +128 -0
- package/dist/shared/components/grid/grid-body.d.ts +21 -0
- package/dist/shared/components/grid/grid-body.js +114 -0
- package/dist/shared/components/grid/grid.d.ts +12 -0
- package/dist/shared/components/grid/grid.js +50 -0
- package/dist/shared/components/grid/style.d.ts +14 -0
- package/dist/shared/components/grid/style.js +54 -0
- package/dist/shared/components/other/arrow.d.ts +20 -0
- package/dist/shared/components/other/arrow.js +90 -0
- package/dist/shared/components/other/horizontal-scroll.d.ts +16 -0
- package/dist/shared/components/other/horizontal-scroll.js +64 -0
- package/dist/shared/components/other/style.d.ts +16 -0
- package/dist/shared/components/other/style.js +125 -0
- package/dist/shared/components/other/tooltip.d.ts +36 -0
- package/dist/shared/components/other/tooltip.js +137 -0
- package/dist/shared/components/other/vertical-scroll.d.ts +17 -0
- package/dist/shared/components/other/vertical-scroll.js +74 -0
- package/dist/shared/components/task-item/bar/bar-date-handle.d.ts +19 -0
- package/dist/shared/components/task-item/bar/bar-date-handle.js +62 -0
- package/dist/shared/components/task-item/bar/bar-display.d.ts +29 -0
- package/dist/shared/components/task-item/bar/bar-display.js +98 -0
- package/dist/shared/components/task-item/bar/bar-progress-handle.d.ts +15 -0
- package/dist/shared/components/task-item/bar/bar-progress-handle.js +49 -0
- package/dist/shared/components/task-item/bar/bar-small.d.ts +11 -0
- package/dist/shared/components/task-item/bar/bar-small.js +85 -0
- package/dist/shared/components/task-item/bar/bar.d.ts +11 -0
- package/dist/shared/components/task-item/bar/bar.js +113 -0
- package/dist/shared/components/task-item/bar/style.d.ts +10 -0
- package/dist/shared/components/task-item/bar/style.js +58 -0
- package/dist/shared/components/task-item/milestone/milestone.d.ts +11 -0
- package/dist/shared/components/task-item/milestone/milestone.js +72 -0
- package/dist/shared/components/task-item/milestone/style.d.ts +10 -0
- package/dist/shared/components/task-item/milestone/style.js +45 -0
- package/dist/shared/components/task-item/project/project.d.ts +11 -0
- package/dist/shared/components/task-item/project/project.js +77 -0
- package/dist/shared/components/task-item/project/style.d.ts +11 -0
- package/dist/shared/components/task-item/project/style.js +51 -0
- package/dist/shared/components/task-item/style.d.ts +12 -0
- package/dist/shared/components/task-item/style.js +74 -0
- package/dist/shared/components/task-item/task-item.d.ts +23 -0
- package/dist/shared/components/task-item/task-item.js +132 -0
- package/dist/shared/helpers/bar-helper.d.ts +22 -0
- package/dist/shared/helpers/bar-helper.js +415 -0
- package/dist/shared/helpers/date-helper.d.ts +27 -0
- package/dist/shared/helpers/date-helper.js +231 -0
- package/dist/shared/helpers/other-helper.d.ts +17 -0
- package/dist/shared/helpers/other-helper.js +97 -0
- package/dist/shared/types/bar-task.d.ts +30 -0
- package/dist/shared/types/bar-task.js +24 -0
- package/dist/shared/types/date-setup.d.ts +13 -0
- package/dist/shared/types/date-setup.js +24 -0
- package/dist/shared/types/gantt-task-actions.d.ts +16 -0
- package/dist/shared/types/gantt-task-actions.js +24 -0
- package/dist/shared/types/public-types.d.ts +145 -0
- package/dist/shared/types/public-types.js +46 -0
- package/package.json +2 -2
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidCSSUnit = exports.stringInputToObject = exports.inputToRGB = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
|
|
5
|
+
var conversion_js_1 = require("./conversion.js");
|
|
6
|
+
var css_color_names_js_1 = require("./css-color-names.js");
|
|
7
|
+
var util_js_1 = require("./util.js");
|
|
8
|
+
/**
|
|
9
|
+
* Given a string or object, convert that input to RGB
|
|
10
|
+
*
|
|
11
|
+
* Possible string inputs:
|
|
12
|
+
* ```
|
|
13
|
+
* "red"
|
|
14
|
+
* "#f00" or "f00"
|
|
15
|
+
* "#ff0000" or "ff0000"
|
|
16
|
+
* "#ff000000" or "ff000000"
|
|
17
|
+
* "rgb 255 0 0" or "rgb (255, 0, 0)"
|
|
18
|
+
* "rgb 1.0 0 0" or "rgb (1, 0, 0)"
|
|
19
|
+
* "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
|
|
20
|
+
* "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
|
|
21
|
+
* "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
|
|
22
|
+
* "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
|
|
23
|
+
* "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function inputToRGB(color) {
|
|
27
|
+
var rgb = { r: 0, g: 0, b: 0 };
|
|
28
|
+
var a = 1;
|
|
29
|
+
var s = null;
|
|
30
|
+
var v = null;
|
|
31
|
+
var l = null;
|
|
32
|
+
var ok = false;
|
|
33
|
+
var format = false;
|
|
34
|
+
if (typeof color === 'string') {
|
|
35
|
+
color = stringInputToObject(color);
|
|
36
|
+
}
|
|
37
|
+
if (typeof color === 'object') {
|
|
38
|
+
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
|
|
39
|
+
rgb = (0, conversion_js_1.rgbToRgb)(color.r, color.g, color.b);
|
|
40
|
+
ok = true;
|
|
41
|
+
format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb';
|
|
42
|
+
}
|
|
43
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
|
|
44
|
+
s = (0, util_js_1.convertToPercentage)(color.s);
|
|
45
|
+
v = (0, util_js_1.convertToPercentage)(color.v);
|
|
46
|
+
rgb = (0, conversion_js_1.hsvToRgb)(color.h, s, v);
|
|
47
|
+
ok = true;
|
|
48
|
+
format = 'hsv';
|
|
49
|
+
}
|
|
50
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
|
|
51
|
+
s = (0, util_js_1.convertToPercentage)(color.s);
|
|
52
|
+
l = (0, util_js_1.convertToPercentage)(color.l);
|
|
53
|
+
rgb = (0, conversion_js_1.hslToRgb)(color.h, s, l);
|
|
54
|
+
ok = true;
|
|
55
|
+
format = 'hsl';
|
|
56
|
+
}
|
|
57
|
+
if (Object.prototype.hasOwnProperty.call(color, 'a')) {
|
|
58
|
+
a = color.a;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
a = (0, util_js_1.boundAlpha)(a);
|
|
62
|
+
return {
|
|
63
|
+
ok: ok,
|
|
64
|
+
format: color.format || format,
|
|
65
|
+
r: Math.min(255, Math.max(rgb.r, 0)),
|
|
66
|
+
g: Math.min(255, Math.max(rgb.g, 0)),
|
|
67
|
+
b: Math.min(255, Math.max(rgb.b, 0)),
|
|
68
|
+
a: a,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
exports.inputToRGB = inputToRGB;
|
|
72
|
+
// <http://www.w3.org/TR/css3-values/#integers>
|
|
73
|
+
var CSS_INTEGER = '[-\\+]?\\d+%?';
|
|
74
|
+
// <http://www.w3.org/TR/css3-values/#number-value>
|
|
75
|
+
var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
|
|
76
|
+
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
|
|
77
|
+
var CSS_UNIT = "(?:".concat(CSS_NUMBER, ")|(?:").concat(CSS_INTEGER, ")");
|
|
78
|
+
// Actual matching.
|
|
79
|
+
// Parentheses and commas are optional, but not required.
|
|
80
|
+
// Whitespace can take the place of commas or opening paren
|
|
81
|
+
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
|
|
82
|
+
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
|
|
83
|
+
var matchers = {
|
|
84
|
+
CSS_UNIT: new RegExp(CSS_UNIT),
|
|
85
|
+
rgb: new RegExp('rgb' + PERMISSIVE_MATCH3),
|
|
86
|
+
rgba: new RegExp('rgba' + PERMISSIVE_MATCH4),
|
|
87
|
+
hsl: new RegExp('hsl' + PERMISSIVE_MATCH3),
|
|
88
|
+
hsla: new RegExp('hsla' + PERMISSIVE_MATCH4),
|
|
89
|
+
hsv: new RegExp('hsv' + PERMISSIVE_MATCH3),
|
|
90
|
+
hsva: new RegExp('hsva' + PERMISSIVE_MATCH4),
|
|
91
|
+
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
92
|
+
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
93
|
+
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
94
|
+
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Permissive string parsing. Take in a number of formats, and output an object
|
|
98
|
+
* based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
|
|
99
|
+
*/
|
|
100
|
+
function stringInputToObject(color) {
|
|
101
|
+
color = color.trim().toLowerCase();
|
|
102
|
+
if (color.length === 0) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
var named = false;
|
|
106
|
+
if (css_color_names_js_1.names[color]) {
|
|
107
|
+
color = css_color_names_js_1.names[color];
|
|
108
|
+
named = true;
|
|
109
|
+
}
|
|
110
|
+
else if (color === 'transparent') {
|
|
111
|
+
return { r: 0, g: 0, b: 0, a: 0, format: 'name' };
|
|
112
|
+
}
|
|
113
|
+
// Try to match string input using regular expressions.
|
|
114
|
+
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
|
|
115
|
+
// Just return an object and let the conversion functions handle that.
|
|
116
|
+
// This way the result will be the same whether the tinycolor is initialized with string or object.
|
|
117
|
+
var match = matchers.rgb.exec(color);
|
|
118
|
+
if (match) {
|
|
119
|
+
return { r: match[1], g: match[2], b: match[3] };
|
|
120
|
+
}
|
|
121
|
+
match = matchers.rgba.exec(color);
|
|
122
|
+
if (match) {
|
|
123
|
+
return { r: match[1], g: match[2], b: match[3], a: match[4] };
|
|
124
|
+
}
|
|
125
|
+
match = matchers.hsl.exec(color);
|
|
126
|
+
if (match) {
|
|
127
|
+
return { h: match[1], s: match[2], l: match[3] };
|
|
128
|
+
}
|
|
129
|
+
match = matchers.hsla.exec(color);
|
|
130
|
+
if (match) {
|
|
131
|
+
return { h: match[1], s: match[2], l: match[3], a: match[4] };
|
|
132
|
+
}
|
|
133
|
+
match = matchers.hsv.exec(color);
|
|
134
|
+
if (match) {
|
|
135
|
+
return { h: match[1], s: match[2], v: match[3] };
|
|
136
|
+
}
|
|
137
|
+
match = matchers.hsva.exec(color);
|
|
138
|
+
if (match) {
|
|
139
|
+
return { h: match[1], s: match[2], v: match[3], a: match[4] };
|
|
140
|
+
}
|
|
141
|
+
match = matchers.hex8.exec(color);
|
|
142
|
+
if (match) {
|
|
143
|
+
return {
|
|
144
|
+
r: (0, conversion_js_1.parseIntFromHex)(match[1]),
|
|
145
|
+
g: (0, conversion_js_1.parseIntFromHex)(match[2]),
|
|
146
|
+
b: (0, conversion_js_1.parseIntFromHex)(match[3]),
|
|
147
|
+
a: (0, conversion_js_1.convertHexToDecimal)(match[4]),
|
|
148
|
+
format: named ? 'name' : 'hex8',
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
match = matchers.hex6.exec(color);
|
|
152
|
+
if (match) {
|
|
153
|
+
return {
|
|
154
|
+
r: (0, conversion_js_1.parseIntFromHex)(match[1]),
|
|
155
|
+
g: (0, conversion_js_1.parseIntFromHex)(match[2]),
|
|
156
|
+
b: (0, conversion_js_1.parseIntFromHex)(match[3]),
|
|
157
|
+
format: named ? 'name' : 'hex',
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
match = matchers.hex4.exec(color);
|
|
161
|
+
if (match) {
|
|
162
|
+
return {
|
|
163
|
+
r: (0, conversion_js_1.parseIntFromHex)(match[1] + match[1]),
|
|
164
|
+
g: (0, conversion_js_1.parseIntFromHex)(match[2] + match[2]),
|
|
165
|
+
b: (0, conversion_js_1.parseIntFromHex)(match[3] + match[3]),
|
|
166
|
+
a: (0, conversion_js_1.convertHexToDecimal)(match[4] + match[4]),
|
|
167
|
+
format: named ? 'name' : 'hex8',
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
match = matchers.hex3.exec(color);
|
|
171
|
+
if (match) {
|
|
172
|
+
return {
|
|
173
|
+
r: (0, conversion_js_1.parseIntFromHex)(match[1] + match[1]),
|
|
174
|
+
g: (0, conversion_js_1.parseIntFromHex)(match[2] + match[2]),
|
|
175
|
+
b: (0, conversion_js_1.parseIntFromHex)(match[3] + match[3]),
|
|
176
|
+
format: named ? 'name' : 'hex',
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
exports.stringInputToObject = stringInputToObject;
|
|
182
|
+
/**
|
|
183
|
+
* Check to see if it looks like a CSS unit
|
|
184
|
+
* (see `matchers` above for definition).
|
|
185
|
+
*/
|
|
186
|
+
function isValidCSSUnit(color) {
|
|
187
|
+
return Boolean(matchers.CSS_UNIT.exec(String(color)));
|
|
188
|
+
}
|
|
189
|
+
exports.isValidCSSUnit = isValidCSSUnit;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TinyColor } from './index.js';
|
|
2
|
+
export interface RatioInput {
|
|
3
|
+
r: number | string;
|
|
4
|
+
g: number | string;
|
|
5
|
+
b: number | string;
|
|
6
|
+
a?: number | string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* If input is an object, force 1 into "1.0" to handle ratios properly
|
|
10
|
+
* String input requires "1.0" as input, so 1 will be treated as 1
|
|
11
|
+
*/
|
|
12
|
+
export declare function fromRatio(ratio: RatioInput, opts?: any): TinyColor;
|
|
13
|
+
/** old random function */
|
|
14
|
+
export declare function legacyRandom(): TinyColor;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.legacyRandom = exports.fromRatio = void 0;
|
|
4
|
+
var index_js_1 = require("./index.js");
|
|
5
|
+
var util_js_1 = require("./util.js");
|
|
6
|
+
/**
|
|
7
|
+
* If input is an object, force 1 into "1.0" to handle ratios properly
|
|
8
|
+
* String input requires "1.0" as input, so 1 will be treated as 1
|
|
9
|
+
*/
|
|
10
|
+
function fromRatio(ratio, opts) {
|
|
11
|
+
var newColor = {
|
|
12
|
+
r: (0, util_js_1.convertToPercentage)(ratio.r),
|
|
13
|
+
g: (0, util_js_1.convertToPercentage)(ratio.g),
|
|
14
|
+
b: (0, util_js_1.convertToPercentage)(ratio.b),
|
|
15
|
+
};
|
|
16
|
+
if (ratio.a !== undefined) {
|
|
17
|
+
newColor.a = Number(ratio.a);
|
|
18
|
+
}
|
|
19
|
+
return new index_js_1.TinyColor(newColor, opts);
|
|
20
|
+
}
|
|
21
|
+
exports.fromRatio = fromRatio;
|
|
22
|
+
/** old random function */
|
|
23
|
+
function legacyRandom() {
|
|
24
|
+
return new index_js_1.TinyColor({
|
|
25
|
+
r: Math.random(),
|
|
26
|
+
g: Math.random(),
|
|
27
|
+
b: Math.random(),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.legacyRandom = legacyRandom;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { HSL, HSLA, HSV, HSVA, Numberify, RGB, RGBA } from './interfaces.js';
|
|
2
|
+
export interface TinyColorOptions {
|
|
3
|
+
format: string;
|
|
4
|
+
gradientType: string;
|
|
5
|
+
}
|
|
6
|
+
export type ColorInput = string | number | RGB | RGBA | HSL | HSLA | HSV | HSVA | TinyColor;
|
|
7
|
+
export type ColorFormats = 'rgb' | 'prgb' | 'hex' | 'hex3' | 'hex4' | 'hex6' | 'hex8' | 'name' | 'hsl' | 'hsv';
|
|
8
|
+
export declare class TinyColor {
|
|
9
|
+
/** red */
|
|
10
|
+
r: number;
|
|
11
|
+
/** green */
|
|
12
|
+
g: number;
|
|
13
|
+
/** blue */
|
|
14
|
+
b: number;
|
|
15
|
+
/** alpha */
|
|
16
|
+
a: number;
|
|
17
|
+
/** the format used to create the tinycolor instance */
|
|
18
|
+
format: ColorFormats;
|
|
19
|
+
/** input passed into the constructer used to create the tinycolor instance */
|
|
20
|
+
originalInput: ColorInput;
|
|
21
|
+
/** the color was successfully parsed */
|
|
22
|
+
isValid: boolean;
|
|
23
|
+
gradientType?: string;
|
|
24
|
+
/** rounded alpha */
|
|
25
|
+
roundA: number;
|
|
26
|
+
constructor(color?: ColorInput, opts?: Partial<TinyColorOptions>);
|
|
27
|
+
isDark(): boolean;
|
|
28
|
+
isLight(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the perceived brightness of the color, from 0-255.
|
|
31
|
+
*/
|
|
32
|
+
getBrightness(): number;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the perceived luminance of a color, from 0-1.
|
|
35
|
+
*/
|
|
36
|
+
getLuminance(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the alpha value of a color, from 0-1.
|
|
39
|
+
*/
|
|
40
|
+
getAlpha(): number;
|
|
41
|
+
/**
|
|
42
|
+
* Sets the alpha value on the current color.
|
|
43
|
+
*
|
|
44
|
+
* @param alpha - The new alpha value. The accepted range is 0-1.
|
|
45
|
+
*/
|
|
46
|
+
setAlpha(alpha?: string | number): this;
|
|
47
|
+
/**
|
|
48
|
+
* Returns whether the color is monochrome.
|
|
49
|
+
*/
|
|
50
|
+
isMonochrome(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the object as a HSVA object.
|
|
53
|
+
*/
|
|
54
|
+
toHsv(): Numberify<HSVA>;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the hsva values interpolated into a string with the following format:
|
|
57
|
+
* "hsva(xxx, xxx, xxx, xx)".
|
|
58
|
+
*/
|
|
59
|
+
toHsvString(): string;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the object as a HSLA object.
|
|
62
|
+
*/
|
|
63
|
+
toHsl(): Numberify<HSLA>;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the hsla values interpolated into a string with the following format:
|
|
66
|
+
* "hsla(xxx, xxx, xxx, xx)".
|
|
67
|
+
*/
|
|
68
|
+
toHslString(): string;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the hex value of the color.
|
|
71
|
+
* @param allow3Char will shorten hex value to 3 char if possible
|
|
72
|
+
*/
|
|
73
|
+
toHex(allow3Char?: boolean): string;
|
|
74
|
+
/**
|
|
75
|
+
* Returns the hex value of the color -with a # prefixed.
|
|
76
|
+
* @param allow3Char will shorten hex value to 3 char if possible
|
|
77
|
+
*/
|
|
78
|
+
toHexString(allow3Char?: boolean): string;
|
|
79
|
+
/**
|
|
80
|
+
* Returns the hex 8 value of the color.
|
|
81
|
+
* @param allow4Char will shorten hex value to 4 char if possible
|
|
82
|
+
*/
|
|
83
|
+
toHex8(allow4Char?: boolean): string;
|
|
84
|
+
/**
|
|
85
|
+
* Returns the hex 8 value of the color -with a # prefixed.
|
|
86
|
+
* @param allow4Char will shorten hex value to 4 char if possible
|
|
87
|
+
*/
|
|
88
|
+
toHex8String(allow4Char?: boolean): string;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the shorter hex value of the color depends on its alpha -with a # prefixed.
|
|
91
|
+
* @param allowShortChar will shorten hex value to 3 or 4 char if possible
|
|
92
|
+
*/
|
|
93
|
+
toHexShortString(allowShortChar?: boolean): string;
|
|
94
|
+
/**
|
|
95
|
+
* Returns the object as a RGBA object.
|
|
96
|
+
*/
|
|
97
|
+
toRgb(): Numberify<RGBA>;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the RGBA values interpolated into a string with the following format:
|
|
100
|
+
* "RGBA(xxx, xxx, xxx, xx)".
|
|
101
|
+
*/
|
|
102
|
+
toRgbString(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Returns the object as a RGBA object.
|
|
105
|
+
*/
|
|
106
|
+
toPercentageRgb(): RGBA;
|
|
107
|
+
/**
|
|
108
|
+
* Returns the RGBA relative values interpolated into a string
|
|
109
|
+
*/
|
|
110
|
+
toPercentageRgbString(): string;
|
|
111
|
+
/**
|
|
112
|
+
* The 'real' name of the color -if there is one.
|
|
113
|
+
*/
|
|
114
|
+
toName(): string | false;
|
|
115
|
+
/**
|
|
116
|
+
* String representation of the color.
|
|
117
|
+
*
|
|
118
|
+
* @param format - The format to be used when displaying the string representation.
|
|
119
|
+
*/
|
|
120
|
+
toString<T extends 'name'>(format: T): boolean | string;
|
|
121
|
+
toString<T extends ColorFormats>(format?: T): string;
|
|
122
|
+
toNumber(): number;
|
|
123
|
+
clone(): TinyColor;
|
|
124
|
+
/**
|
|
125
|
+
* Lighten the color a given amount. Providing 100 will always return white.
|
|
126
|
+
* @param amount - valid between 1-100
|
|
127
|
+
*/
|
|
128
|
+
lighten(amount?: number): TinyColor;
|
|
129
|
+
/**
|
|
130
|
+
* Brighten the color a given amount, from 0 to 100.
|
|
131
|
+
* @param amount - valid between 1-100
|
|
132
|
+
*/
|
|
133
|
+
brighten(amount?: number): TinyColor;
|
|
134
|
+
/**
|
|
135
|
+
* Darken the color a given amount, from 0 to 100.
|
|
136
|
+
* Providing 100 will always return black.
|
|
137
|
+
* @param amount - valid between 1-100
|
|
138
|
+
*/
|
|
139
|
+
darken(amount?: number): TinyColor;
|
|
140
|
+
/**
|
|
141
|
+
* Mix the color with pure white, from 0 to 100.
|
|
142
|
+
* Providing 0 will do nothing, providing 100 will always return white.
|
|
143
|
+
* @param amount - valid between 1-100
|
|
144
|
+
*/
|
|
145
|
+
tint(amount?: number): TinyColor;
|
|
146
|
+
/**
|
|
147
|
+
* Mix the color with pure black, from 0 to 100.
|
|
148
|
+
* Providing 0 will do nothing, providing 100 will always return black.
|
|
149
|
+
* @param amount - valid between 1-100
|
|
150
|
+
*/
|
|
151
|
+
shade(amount?: number): TinyColor;
|
|
152
|
+
/**
|
|
153
|
+
* Desaturate the color a given amount, from 0 to 100.
|
|
154
|
+
* Providing 100 will is the same as calling greyscale
|
|
155
|
+
* @param amount - valid between 1-100
|
|
156
|
+
*/
|
|
157
|
+
desaturate(amount?: number): TinyColor;
|
|
158
|
+
/**
|
|
159
|
+
* Saturate the color a given amount, from 0 to 100.
|
|
160
|
+
* @param amount - valid between 1-100
|
|
161
|
+
*/
|
|
162
|
+
saturate(amount?: number): TinyColor;
|
|
163
|
+
/**
|
|
164
|
+
* Completely desaturates a color into greyscale.
|
|
165
|
+
* Same as calling `desaturate(100)`
|
|
166
|
+
*/
|
|
167
|
+
greyscale(): TinyColor;
|
|
168
|
+
/**
|
|
169
|
+
* Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
|
|
170
|
+
* Values outside of this range will be wrapped into this range.
|
|
171
|
+
*/
|
|
172
|
+
spin(amount: number): TinyColor;
|
|
173
|
+
/**
|
|
174
|
+
* Mix the current color a given amount with another color, from 0 to 100.
|
|
175
|
+
* 0 means no mixing (return current color).
|
|
176
|
+
*/
|
|
177
|
+
mix(color: ColorInput, amount?: number): TinyColor;
|
|
178
|
+
analogous(results?: number, slices?: number): TinyColor[];
|
|
179
|
+
/**
|
|
180
|
+
* taken from https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js
|
|
181
|
+
*/
|
|
182
|
+
complement(): TinyColor;
|
|
183
|
+
monochromatic(results?: number): TinyColor[];
|
|
184
|
+
splitcomplement(): TinyColor[];
|
|
185
|
+
/**
|
|
186
|
+
* Compute how the color would appear on a background
|
|
187
|
+
*/
|
|
188
|
+
onBackground(background: ColorInput): TinyColor;
|
|
189
|
+
/**
|
|
190
|
+
* Alias for `polyad(3)`
|
|
191
|
+
*/
|
|
192
|
+
triad(): TinyColor[];
|
|
193
|
+
/**
|
|
194
|
+
* Alias for `polyad(4)`
|
|
195
|
+
*/
|
|
196
|
+
tetrad(): TinyColor[];
|
|
197
|
+
/**
|
|
198
|
+
* Get polyad colors, like (for 1, 2, 3, 4, 5, 6, 7, 8, etc...)
|
|
199
|
+
* monad, dyad, triad, tetrad, pentad, hexad, heptad, octad, etc...
|
|
200
|
+
*/
|
|
201
|
+
polyad(n: number): TinyColor[];
|
|
202
|
+
/**
|
|
203
|
+
* compare color vs current color
|
|
204
|
+
*/
|
|
205
|
+
equals(color?: ColorInput): boolean;
|
|
206
|
+
}
|
|
207
|
+
export declare function tinycolor(color?: ColorInput, opts?: Partial<TinyColorOptions>): TinyColor;
|