@nocobase/plugin-gantt 2.1.0-beta.36 → 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,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bounds = exports.random = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
|
|
5
|
+
// randomColor by David Merfield under the CC0 license
|
|
6
|
+
// https://github.com/davidmerfield/randomColor/
|
|
7
|
+
var index_js_1 = require("./index.js");
|
|
8
|
+
function random(options) {
|
|
9
|
+
if (options === void 0) { options = {}; }
|
|
10
|
+
// Check if we need to generate multiple colors
|
|
11
|
+
if (options.count !== undefined &&
|
|
12
|
+
options.count !== null) {
|
|
13
|
+
var totalColors = options.count;
|
|
14
|
+
var colors = [];
|
|
15
|
+
options.count = undefined;
|
|
16
|
+
while (totalColors > colors.length) {
|
|
17
|
+
// Since we're generating multiple colors,
|
|
18
|
+
// incremement the seed. Otherwise we'd just
|
|
19
|
+
// generate the same color each time...
|
|
20
|
+
options.count = null;
|
|
21
|
+
if (options.seed) {
|
|
22
|
+
options.seed += 1;
|
|
23
|
+
}
|
|
24
|
+
colors.push(random(options));
|
|
25
|
+
}
|
|
26
|
+
options.count = totalColors;
|
|
27
|
+
return colors;
|
|
28
|
+
}
|
|
29
|
+
// First we pick a hue (H)
|
|
30
|
+
var h = pickHue(options.hue, options.seed);
|
|
31
|
+
// Then use H to determine saturation (S)
|
|
32
|
+
var s = pickSaturation(h, options);
|
|
33
|
+
// Then use S and H to determine brightness (B).
|
|
34
|
+
var v = pickBrightness(h, s, options);
|
|
35
|
+
var res = { h: h, s: s, v: v };
|
|
36
|
+
if (options.alpha !== undefined) {
|
|
37
|
+
res.a = options.alpha;
|
|
38
|
+
}
|
|
39
|
+
// Then we return the HSB color in the desired format
|
|
40
|
+
return new index_js_1.TinyColor(res);
|
|
41
|
+
}
|
|
42
|
+
exports.random = random;
|
|
43
|
+
function pickHue(hue, seed) {
|
|
44
|
+
var hueRange = getHueRange(hue);
|
|
45
|
+
var res = randomWithin(hueRange, seed);
|
|
46
|
+
// Instead of storing red as two seperate ranges,
|
|
47
|
+
// we group them, using negative numbers
|
|
48
|
+
if (res < 0) {
|
|
49
|
+
res = 360 + res;
|
|
50
|
+
}
|
|
51
|
+
return res;
|
|
52
|
+
}
|
|
53
|
+
function pickSaturation(hue, options) {
|
|
54
|
+
if (options.hue === 'monochrome') {
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
if (options.luminosity === 'random') {
|
|
58
|
+
return randomWithin([0, 100], options.seed);
|
|
59
|
+
}
|
|
60
|
+
var saturationRange = getColorInfo(hue).saturationRange;
|
|
61
|
+
var sMin = saturationRange[0];
|
|
62
|
+
var sMax = saturationRange[1];
|
|
63
|
+
switch (options.luminosity) {
|
|
64
|
+
case 'bright':
|
|
65
|
+
sMin = 55;
|
|
66
|
+
break;
|
|
67
|
+
case 'dark':
|
|
68
|
+
sMin = sMax - 10;
|
|
69
|
+
break;
|
|
70
|
+
case 'light':
|
|
71
|
+
sMax = 55;
|
|
72
|
+
break;
|
|
73
|
+
default:
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
return randomWithin([sMin, sMax], options.seed);
|
|
77
|
+
}
|
|
78
|
+
function pickBrightness(H, S, options) {
|
|
79
|
+
var bMin = getMinimumBrightness(H, S);
|
|
80
|
+
var bMax = 100;
|
|
81
|
+
switch (options.luminosity) {
|
|
82
|
+
case 'dark':
|
|
83
|
+
bMax = bMin + 20;
|
|
84
|
+
break;
|
|
85
|
+
case 'light':
|
|
86
|
+
bMin = (bMax + bMin) / 2;
|
|
87
|
+
break;
|
|
88
|
+
case 'random':
|
|
89
|
+
bMin = 0;
|
|
90
|
+
bMax = 100;
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
return randomWithin([bMin, bMax], options.seed);
|
|
96
|
+
}
|
|
97
|
+
function getMinimumBrightness(H, S) {
|
|
98
|
+
var lowerBounds = getColorInfo(H).lowerBounds;
|
|
99
|
+
for (var i = 0; i < lowerBounds.length - 1; i++) {
|
|
100
|
+
var s1 = lowerBounds[i][0];
|
|
101
|
+
var v1 = lowerBounds[i][1];
|
|
102
|
+
var s2 = lowerBounds[i + 1][0];
|
|
103
|
+
var v2 = lowerBounds[i + 1][1];
|
|
104
|
+
if (S >= s1 && S <= s2) {
|
|
105
|
+
var m = (v2 - v1) / (s2 - s1);
|
|
106
|
+
var b = v1 - m * s1;
|
|
107
|
+
return m * S + b;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return 0;
|
|
111
|
+
}
|
|
112
|
+
function getHueRange(colorInput) {
|
|
113
|
+
var num = parseInt(colorInput, 10);
|
|
114
|
+
if (!Number.isNaN(num) && num < 360 && num > 0) {
|
|
115
|
+
return [num, num];
|
|
116
|
+
}
|
|
117
|
+
if (typeof colorInput === 'string') {
|
|
118
|
+
var namedColor = exports.bounds.find(function (n) { return n.name === colorInput; });
|
|
119
|
+
if (namedColor) {
|
|
120
|
+
var color = defineColor(namedColor);
|
|
121
|
+
if (color.hueRange) {
|
|
122
|
+
return color.hueRange;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
var parsed = new index_js_1.TinyColor(colorInput);
|
|
126
|
+
if (parsed.isValid) {
|
|
127
|
+
var hue = parsed.toHsv().h;
|
|
128
|
+
return [hue, hue];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return [0, 360];
|
|
132
|
+
}
|
|
133
|
+
function getColorInfo(hue) {
|
|
134
|
+
// Maps red colors to make picking hue easier
|
|
135
|
+
if (hue >= 334 && hue <= 360) {
|
|
136
|
+
hue -= 360;
|
|
137
|
+
}
|
|
138
|
+
for (var _i = 0, bounds_1 = exports.bounds; _i < bounds_1.length; _i++) {
|
|
139
|
+
var bound = bounds_1[_i];
|
|
140
|
+
var color = defineColor(bound);
|
|
141
|
+
if (color.hueRange && hue >= color.hueRange[0] && hue <= color.hueRange[1]) {
|
|
142
|
+
return color;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
throw Error('Color not found');
|
|
146
|
+
}
|
|
147
|
+
function randomWithin(range, seed) {
|
|
148
|
+
if (seed === undefined) {
|
|
149
|
+
return Math.floor(range[0] + Math.random() * (range[1] + 1 - range[0]));
|
|
150
|
+
}
|
|
151
|
+
// Seeded random algorithm from http://indiegamr.com/generate-repeatable-random-numbers-in-js/
|
|
152
|
+
var max = range[1] || 1;
|
|
153
|
+
var min = range[0] || 0;
|
|
154
|
+
seed = (seed * 9301 + 49297) % 233280;
|
|
155
|
+
var rnd = seed / 233280.0;
|
|
156
|
+
return Math.floor(min + rnd * (max - min));
|
|
157
|
+
}
|
|
158
|
+
function defineColor(bound) {
|
|
159
|
+
var sMin = bound.lowerBounds[0][0];
|
|
160
|
+
var sMax = bound.lowerBounds[bound.lowerBounds.length - 1][0];
|
|
161
|
+
var bMin = bound.lowerBounds[bound.lowerBounds.length - 1][1];
|
|
162
|
+
var bMax = bound.lowerBounds[0][1];
|
|
163
|
+
return {
|
|
164
|
+
name: bound.name,
|
|
165
|
+
hueRange: bound.hueRange,
|
|
166
|
+
lowerBounds: bound.lowerBounds,
|
|
167
|
+
saturationRange: [sMin, sMax],
|
|
168
|
+
brightnessRange: [bMin, bMax],
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* @hidden
|
|
173
|
+
*/
|
|
174
|
+
exports.bounds = [
|
|
175
|
+
{
|
|
176
|
+
name: 'monochrome',
|
|
177
|
+
hueRange: null,
|
|
178
|
+
lowerBounds: [
|
|
179
|
+
[0, 0],
|
|
180
|
+
[100, 0],
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: 'red',
|
|
185
|
+
hueRange: [-26, 18],
|
|
186
|
+
lowerBounds: [
|
|
187
|
+
[20, 100],
|
|
188
|
+
[30, 92],
|
|
189
|
+
[40, 89],
|
|
190
|
+
[50, 85],
|
|
191
|
+
[60, 78],
|
|
192
|
+
[70, 70],
|
|
193
|
+
[80, 60],
|
|
194
|
+
[90, 55],
|
|
195
|
+
[100, 50],
|
|
196
|
+
],
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: 'orange',
|
|
200
|
+
hueRange: [19, 46],
|
|
201
|
+
lowerBounds: [
|
|
202
|
+
[20, 100],
|
|
203
|
+
[30, 93],
|
|
204
|
+
[40, 88],
|
|
205
|
+
[50, 86],
|
|
206
|
+
[60, 85],
|
|
207
|
+
[70, 70],
|
|
208
|
+
[100, 70],
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: 'yellow',
|
|
213
|
+
hueRange: [47, 62],
|
|
214
|
+
lowerBounds: [
|
|
215
|
+
[25, 100],
|
|
216
|
+
[40, 94],
|
|
217
|
+
[50, 89],
|
|
218
|
+
[60, 86],
|
|
219
|
+
[70, 84],
|
|
220
|
+
[80, 82],
|
|
221
|
+
[90, 80],
|
|
222
|
+
[100, 75],
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: 'green',
|
|
227
|
+
hueRange: [63, 178],
|
|
228
|
+
lowerBounds: [
|
|
229
|
+
[30, 100],
|
|
230
|
+
[40, 90],
|
|
231
|
+
[50, 85],
|
|
232
|
+
[60, 81],
|
|
233
|
+
[70, 74],
|
|
234
|
+
[80, 64],
|
|
235
|
+
[90, 50],
|
|
236
|
+
[100, 40],
|
|
237
|
+
],
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: 'blue',
|
|
241
|
+
hueRange: [179, 257],
|
|
242
|
+
lowerBounds: [
|
|
243
|
+
[20, 100],
|
|
244
|
+
[30, 86],
|
|
245
|
+
[40, 80],
|
|
246
|
+
[50, 74],
|
|
247
|
+
[60, 60],
|
|
248
|
+
[70, 52],
|
|
249
|
+
[80, 44],
|
|
250
|
+
[90, 39],
|
|
251
|
+
[100, 35],
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: 'purple',
|
|
256
|
+
hueRange: [258, 282],
|
|
257
|
+
lowerBounds: [
|
|
258
|
+
[20, 100],
|
|
259
|
+
[30, 87],
|
|
260
|
+
[40, 79],
|
|
261
|
+
[50, 70],
|
|
262
|
+
[60, 65],
|
|
263
|
+
[70, 59],
|
|
264
|
+
[80, 52],
|
|
265
|
+
[90, 45],
|
|
266
|
+
[100, 42],
|
|
267
|
+
],
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
name: 'pink',
|
|
271
|
+
hueRange: [283, 334],
|
|
272
|
+
lowerBounds: [
|
|
273
|
+
[20, 100],
|
|
274
|
+
[30, 90],
|
|
275
|
+
[40, 86],
|
|
276
|
+
[60, 84],
|
|
277
|
+
[80, 80],
|
|
278
|
+
[90, 75],
|
|
279
|
+
[100, 73],
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ColorInput, TinyColor } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* AKA `contrast`
|
|
4
|
+
*
|
|
5
|
+
* Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
|
|
6
|
+
*/
|
|
7
|
+
export declare function readability(color1: ColorInput, color2: ColorInput): number;
|
|
8
|
+
export interface WCAG2Parms {
|
|
9
|
+
level?: 'AA' | 'AAA';
|
|
10
|
+
size?: 'large' | 'small';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Ensure that foreground and background color combinations meet WCAG2 guidelines.
|
|
14
|
+
* The third argument is an object.
|
|
15
|
+
* the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
|
|
16
|
+
* the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
|
|
17
|
+
* If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
|
|
18
|
+
*
|
|
19
|
+
* Example
|
|
20
|
+
* ```ts
|
|
21
|
+
* new TinyColor().isReadable('#000', '#111') => false
|
|
22
|
+
* new TinyColor().isReadable('#000', '#111', { level: 'AA', size: 'large' }) => false
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function isReadable(color1: ColorInput, color2: ColorInput, wcag2?: WCAG2Parms): boolean;
|
|
26
|
+
export interface WCAG2FallbackParms extends WCAG2Parms {
|
|
27
|
+
includeFallbackColors?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Given a base color and a list of possible foreground or background
|
|
31
|
+
* colors for that base, returns the most readable color.
|
|
32
|
+
* Optionally returns Black or White if the most readable color is unreadable.
|
|
33
|
+
*
|
|
34
|
+
* @param baseColor - the base color.
|
|
35
|
+
* @param colorList - array of colors to pick the most readable one from.
|
|
36
|
+
* @param args - and object with extra arguments
|
|
37
|
+
*
|
|
38
|
+
* Example
|
|
39
|
+
* ```ts
|
|
40
|
+
* new TinyColor().mostReadable('#123', ['#124", "#125'], { includeFallbackColors: false }).toHexString(); // "#112255"
|
|
41
|
+
* new TinyColor().mostReadable('#123', ['#124", "#125'],{ includeFallbackColors: true }).toHexString(); // "#ffffff"
|
|
42
|
+
* new TinyColor().mostReadable('#a8015a', ["#faf3f3"], { includeFallbackColors:true, level: 'AAA', size: 'large' }).toHexString(); // "#faf3f3"
|
|
43
|
+
* new TinyColor().mostReadable('#a8015a', ["#faf3f3"], { includeFallbackColors:true, level: 'AAA', size: 'small' }).toHexString(); // "#ffffff"
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function mostReadable(baseColor: ColorInput, colorList: ColorInput[], args?: WCAG2FallbackParms): TinyColor | null;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mostReadable = exports.isReadable = exports.readability = void 0;
|
|
4
|
+
var index_js_1 = require("./index.js");
|
|
5
|
+
// Readability Functions
|
|
6
|
+
// ---------------------
|
|
7
|
+
// <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
|
|
8
|
+
/**
|
|
9
|
+
* AKA `contrast`
|
|
10
|
+
*
|
|
11
|
+
* Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
|
|
12
|
+
*/
|
|
13
|
+
function readability(color1, color2) {
|
|
14
|
+
var c1 = new index_js_1.TinyColor(color1);
|
|
15
|
+
var c2 = new index_js_1.TinyColor(color2);
|
|
16
|
+
return ((Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) /
|
|
17
|
+
(Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05));
|
|
18
|
+
}
|
|
19
|
+
exports.readability = readability;
|
|
20
|
+
/**
|
|
21
|
+
* Ensure that foreground and background color combinations meet WCAG2 guidelines.
|
|
22
|
+
* The third argument is an object.
|
|
23
|
+
* the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
|
|
24
|
+
* the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
|
|
25
|
+
* If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
|
|
26
|
+
*
|
|
27
|
+
* Example
|
|
28
|
+
* ```ts
|
|
29
|
+
* new TinyColor().isReadable('#000', '#111') => false
|
|
30
|
+
* new TinyColor().isReadable('#000', '#111', { level: 'AA', size: 'large' }) => false
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
function isReadable(color1, color2, wcag2) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
if (wcag2 === void 0) { wcag2 = { level: 'AA', size: 'small' }; }
|
|
36
|
+
var readabilityLevel = readability(color1, color2);
|
|
37
|
+
switch (((_a = wcag2.level) !== null && _a !== void 0 ? _a : 'AA') + ((_b = wcag2.size) !== null && _b !== void 0 ? _b : 'small')) {
|
|
38
|
+
case 'AAsmall':
|
|
39
|
+
case 'AAAlarge':
|
|
40
|
+
return readabilityLevel >= 4.5;
|
|
41
|
+
case 'AAlarge':
|
|
42
|
+
return readabilityLevel >= 3;
|
|
43
|
+
case 'AAAsmall':
|
|
44
|
+
return readabilityLevel >= 7;
|
|
45
|
+
default:
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.isReadable = isReadable;
|
|
50
|
+
/**
|
|
51
|
+
* Given a base color and a list of possible foreground or background
|
|
52
|
+
* colors for that base, returns the most readable color.
|
|
53
|
+
* Optionally returns Black or White if the most readable color is unreadable.
|
|
54
|
+
*
|
|
55
|
+
* @param baseColor - the base color.
|
|
56
|
+
* @param colorList - array of colors to pick the most readable one from.
|
|
57
|
+
* @param args - and object with extra arguments
|
|
58
|
+
*
|
|
59
|
+
* Example
|
|
60
|
+
* ```ts
|
|
61
|
+
* new TinyColor().mostReadable('#123', ['#124", "#125'], { includeFallbackColors: false }).toHexString(); // "#112255"
|
|
62
|
+
* new TinyColor().mostReadable('#123', ['#124", "#125'],{ includeFallbackColors: true }).toHexString(); // "#ffffff"
|
|
63
|
+
* new TinyColor().mostReadable('#a8015a', ["#faf3f3"], { includeFallbackColors:true, level: 'AAA', size: 'large' }).toHexString(); // "#faf3f3"
|
|
64
|
+
* new TinyColor().mostReadable('#a8015a', ["#faf3f3"], { includeFallbackColors:true, level: 'AAA', size: 'small' }).toHexString(); // "#ffffff"
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
function mostReadable(baseColor, colorList, args) {
|
|
68
|
+
if (args === void 0) { args = { includeFallbackColors: false, level: 'AA', size: 'small' }; }
|
|
69
|
+
var bestColor = null;
|
|
70
|
+
var bestScore = 0;
|
|
71
|
+
var includeFallbackColors = args.includeFallbackColors, level = args.level, size = args.size;
|
|
72
|
+
for (var _i = 0, colorList_1 = colorList; _i < colorList_1.length; _i++) {
|
|
73
|
+
var color = colorList_1[_i];
|
|
74
|
+
var score = readability(baseColor, color);
|
|
75
|
+
if (score > bestScore) {
|
|
76
|
+
bestScore = score;
|
|
77
|
+
bestColor = new index_js_1.TinyColor(color);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (isReadable(baseColor, bestColor, { level: level, size: size }) || !includeFallbackColors) {
|
|
81
|
+
return bestColor;
|
|
82
|
+
}
|
|
83
|
+
args.includeFallbackColors = false;
|
|
84
|
+
return mostReadable(baseColor, ['#fff', '#000'], args);
|
|
85
|
+
}
|
|
86
|
+
exports.mostReadable = mostReadable;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toMsFilter = void 0;
|
|
4
|
+
var conversion_js_1 = require("./conversion.js");
|
|
5
|
+
var index_js_1 = require("./index.js");
|
|
6
|
+
/**
|
|
7
|
+
* Returns the color represented as a Microsoft filter for use in old versions of IE.
|
|
8
|
+
*/
|
|
9
|
+
function toMsFilter(firstColor, secondColor) {
|
|
10
|
+
var color = new index_js_1.TinyColor(firstColor);
|
|
11
|
+
var hex8String = '#' + (0, conversion_js_1.rgbaToArgbHex)(color.r, color.g, color.b, color.a);
|
|
12
|
+
var secondHex8String = hex8String;
|
|
13
|
+
var gradientType = color.gradientType ? 'GradientType = 1, ' : '';
|
|
14
|
+
if (secondColor) {
|
|
15
|
+
var s = new index_js_1.TinyColor(secondColor);
|
|
16
|
+
secondHex8String = '#' + (0, conversion_js_1.rgbaToArgbHex)(s.r, s.g, s.b, s.a);
|
|
17
|
+
}
|
|
18
|
+
return "progid:DXImageTransform.Microsoft.gradient(".concat(gradientType, "startColorstr=").concat(hex8String, ",endColorstr=").concat(secondHex8String, ")");
|
|
19
|
+
}
|
|
20
|
+
exports.toMsFilter = toMsFilter;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { names } from './css-color-names.js';
|
|
2
|
+
import { inputToRGB, isValidCSSUnit, stringInputToObject } from './format-input.js';
|
|
3
|
+
import { fromRatio, legacyRandom } from './from-ratio.js';
|
|
4
|
+
import { TinyColor } from './index.js';
|
|
5
|
+
import { random } from './random.js';
|
|
6
|
+
import { mostReadable, readability } from './readability.js';
|
|
7
|
+
import { toMsFilter } from './to-ms-filter.js';
|
|
8
|
+
export interface TinyColorUMD {
|
|
9
|
+
(): TinyColor;
|
|
10
|
+
TinyColor: typeof TinyColor;
|
|
11
|
+
readability: typeof readability;
|
|
12
|
+
random: typeof random;
|
|
13
|
+
names: typeof names;
|
|
14
|
+
fromRatio: typeof fromRatio;
|
|
15
|
+
legacyRandom: typeof legacyRandom;
|
|
16
|
+
toMsFilter: typeof toMsFilter;
|
|
17
|
+
inputToRGB: typeof inputToRGB;
|
|
18
|
+
stringInputToObject: typeof stringInputToObject;
|
|
19
|
+
isValidCSSUnit: typeof isValidCSSUnit;
|
|
20
|
+
mostReadable: typeof mostReadable;
|
|
21
|
+
}
|
|
22
|
+
declare const tinycolorumd: TinyColorUMD;
|
|
23
|
+
export default tinycolorumd;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var css_color_names_js_1 = require("./css-color-names.js");
|
|
4
|
+
var format_input_js_1 = require("./format-input.js");
|
|
5
|
+
var from_ratio_js_1 = require("./from-ratio.js");
|
|
6
|
+
var index_js_1 = require("./index.js");
|
|
7
|
+
var random_js_1 = require("./random.js");
|
|
8
|
+
var readability_js_1 = require("./readability.js");
|
|
9
|
+
var to_ms_filter_js_1 = require("./to-ms-filter.js");
|
|
10
|
+
var tinycolorumd = index_js_1.tinycolor;
|
|
11
|
+
tinycolorumd.TinyColor = index_js_1.TinyColor;
|
|
12
|
+
tinycolorumd.readability = readability_js_1.readability;
|
|
13
|
+
tinycolorumd.mostReadable = readability_js_1.mostReadable;
|
|
14
|
+
tinycolorumd.random = random_js_1.random;
|
|
15
|
+
tinycolorumd.names = css_color_names_js_1.names;
|
|
16
|
+
tinycolorumd.fromRatio = from_ratio_js_1.fromRatio;
|
|
17
|
+
tinycolorumd.legacyRandom = from_ratio_js_1.legacyRandom;
|
|
18
|
+
tinycolorumd.toMsFilter = to_ms_filter_js_1.toMsFilter;
|
|
19
|
+
tinycolorumd.inputToRGB = format_input_js_1.inputToRGB;
|
|
20
|
+
tinycolorumd.stringInputToObject = format_input_js_1.stringInputToObject;
|
|
21
|
+
tinycolorumd.isValidCSSUnit = format_input_js_1.isValidCSSUnit;
|
|
22
|
+
exports.default = tinycolorumd;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Take input from [0, n] and return it as [0, 1]
|
|
3
|
+
* @hidden
|
|
4
|
+
*/
|
|
5
|
+
export declare function bound01(n: any, max: number): number;
|
|
6
|
+
/**
|
|
7
|
+
* Force a number between 0 and 1
|
|
8
|
+
* @hidden
|
|
9
|
+
*/
|
|
10
|
+
export declare function clamp01(val: number): number;
|
|
11
|
+
/**
|
|
12
|
+
* Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
|
|
13
|
+
* <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
|
|
14
|
+
* @hidden
|
|
15
|
+
*/
|
|
16
|
+
export declare function isOnePointZero(n: string | number): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Check to see if string passed in is a percentage
|
|
19
|
+
* @hidden
|
|
20
|
+
*/
|
|
21
|
+
export declare function isPercentage(n: string | number): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Return a valid alpha value [0,1] with all invalid values being set to 1
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
export declare function boundAlpha(a?: number | string): number;
|
|
27
|
+
/**
|
|
28
|
+
* Replace a decimal with it's percentage value
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
31
|
+
export declare function convertToPercentage(n: number | string): number | string;
|
|
32
|
+
/**
|
|
33
|
+
* Force a hex value to have 2 characters
|
|
34
|
+
* @hidden
|
|
35
|
+
*/
|
|
36
|
+
export declare function pad2(c: string): string;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pad2 = exports.convertToPercentage = exports.boundAlpha = exports.isPercentage = exports.isOnePointZero = exports.clamp01 = exports.bound01 = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Take input from [0, n] and return it as [0, 1]
|
|
6
|
+
* @hidden
|
|
7
|
+
*/
|
|
8
|
+
function bound01(n, max) {
|
|
9
|
+
if (isOnePointZero(n)) {
|
|
10
|
+
n = '100%';
|
|
11
|
+
}
|
|
12
|
+
var isPercent = isPercentage(n);
|
|
13
|
+
n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
|
|
14
|
+
// Automatically convert percentage into number
|
|
15
|
+
if (isPercent) {
|
|
16
|
+
n = parseInt(String(n * max), 10) / 100;
|
|
17
|
+
}
|
|
18
|
+
// Handle floating point rounding errors
|
|
19
|
+
if (Math.abs(n - max) < 0.000001) {
|
|
20
|
+
return 1;
|
|
21
|
+
}
|
|
22
|
+
// Convert into [0, 1] range if it isn't already
|
|
23
|
+
if (max === 360) {
|
|
24
|
+
// If n is a hue given in degrees,
|
|
25
|
+
// wrap around out-of-range values into [0, 360] range
|
|
26
|
+
// then convert into [0, 1].
|
|
27
|
+
n = (n < 0 ? (n % max) + max : n % max) / parseFloat(String(max));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// If n not a hue given in degrees
|
|
31
|
+
// Convert into [0, 1] range if it isn't already.
|
|
32
|
+
n = (n % max) / parseFloat(String(max));
|
|
33
|
+
}
|
|
34
|
+
return n;
|
|
35
|
+
}
|
|
36
|
+
exports.bound01 = bound01;
|
|
37
|
+
/**
|
|
38
|
+
* Force a number between 0 and 1
|
|
39
|
+
* @hidden
|
|
40
|
+
*/
|
|
41
|
+
function clamp01(val) {
|
|
42
|
+
return Math.min(1, Math.max(0, val));
|
|
43
|
+
}
|
|
44
|
+
exports.clamp01 = clamp01;
|
|
45
|
+
/**
|
|
46
|
+
* Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
|
|
47
|
+
* <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
|
|
48
|
+
* @hidden
|
|
49
|
+
*/
|
|
50
|
+
function isOnePointZero(n) {
|
|
51
|
+
return typeof n === 'string' && n.indexOf('.') !== -1 && parseFloat(n) === 1;
|
|
52
|
+
}
|
|
53
|
+
exports.isOnePointZero = isOnePointZero;
|
|
54
|
+
/**
|
|
55
|
+
* Check to see if string passed in is a percentage
|
|
56
|
+
* @hidden
|
|
57
|
+
*/
|
|
58
|
+
function isPercentage(n) {
|
|
59
|
+
return typeof n === 'string' && n.indexOf('%') !== -1;
|
|
60
|
+
}
|
|
61
|
+
exports.isPercentage = isPercentage;
|
|
62
|
+
/**
|
|
63
|
+
* Return a valid alpha value [0,1] with all invalid values being set to 1
|
|
64
|
+
* @hidden
|
|
65
|
+
*/
|
|
66
|
+
function boundAlpha(a) {
|
|
67
|
+
a = parseFloat(a);
|
|
68
|
+
if (isNaN(a) || a < 0 || a > 1) {
|
|
69
|
+
a = 1;
|
|
70
|
+
}
|
|
71
|
+
return a;
|
|
72
|
+
}
|
|
73
|
+
exports.boundAlpha = boundAlpha;
|
|
74
|
+
/**
|
|
75
|
+
* Replace a decimal with it's percentage value
|
|
76
|
+
* @hidden
|
|
77
|
+
*/
|
|
78
|
+
function convertToPercentage(n) {
|
|
79
|
+
if (n <= 1) {
|
|
80
|
+
return "".concat(Number(n) * 100, "%");
|
|
81
|
+
}
|
|
82
|
+
return n;
|
|
83
|
+
}
|
|
84
|
+
exports.convertToPercentage = convertToPercentage;
|
|
85
|
+
/**
|
|
86
|
+
* Force a hex value to have 2 characters
|
|
87
|
+
* @hidden
|
|
88
|
+
*/
|
|
89
|
+
function pad2(c) {
|
|
90
|
+
return c.length === 1 ? '0' + c : String(c);
|
|
91
|
+
}
|
|
92
|
+
exports.pad2 = pad2;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@ctrl/tinycolor","version":"3.6.1","description":"Fast, small color manipulation and conversion for JavaScript","author":"Scott Cooper <scttcper@gmail.com>","publishConfig":{"access":"public"},"license":"MIT","homepage":"https://tinycolor.vercel.app","repository":"scttcper/tinycolor","keywords":["typescript","color","manipulation","tinycolor","hsa","rgb"],"main":"dist/public_api.js","module":"dist/module/public_api.js","typings":"dist/public_api.d.ts","files":["dist"],"sideEffects":false,"scripts":{"build:demo":"rollup -c rollup.demo.js","watch:demo":"rollup -c rollup.demo.js -w","lint":"eslint --ext .js,.ts, .","lint:fix":"eslint --fix --ext .js,.ts, .","prepare":"npm run build","build":"del-cli dist && tsc -p tsconfig.build.json && tsc -p tsconfig.module.json && ts-node build","build:docs":"typedoc --out demo/public/docs --hideGenerator --tsconfig tsconfig.build.json src/public_api.ts","test":"jest","test:ci":"jest --ci --runInBand --reporters=default --reporters=jest-junit --coverage","test:watch":"jest --watch"},"dependencies":{},"devDependencies":{"@babel/plugin-transform-modules-commonjs":"7.19.6","@babel/preset-typescript":"7.18.6","@ctrl/eslint-config":"3.5.6","@jest/globals":"29.3.1","@types/node":"18.11.11","del-cli":"5.0.0","jest":"29.3.1","jest-junit":"15.0.0","rollup":"2.70.1","rollup-plugin-livereload":"2.0.5","rollup-plugin-serve":"1.1.0","rollup-plugin-sourcemaps":"0.6.3","rollup-plugin-terser":"7.0.2","rollup-plugin-typescript2":"0.34.1","ts-node":"10.9.1","typedoc":"0.23.21","typescript":"4.9.3"},"jest":{"testEnvironment":"node","coverageProvider":"v8","moduleNameMapper":{"(.+)\\.js":"$1"}},"babel":{"presets":["@babel/preset-typescript"],"plugins":["@babel/plugin-transform-modules-commonjs"]},"release":{"branch":"master"},"engines":{"node":">=10"},"_lastModified":"2026-05-29T02:52:51.549Z"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { DateSetup } from '../../types/date-setup';
|
|
11
|
+
import { ViewMode } from '../../types/public-types';
|
|
12
|
+
export type CalendarProps = {
|
|
13
|
+
dateSetup: DateSetup;
|
|
14
|
+
locale: string;
|
|
15
|
+
viewMode: ViewMode;
|
|
16
|
+
rtl: boolean;
|
|
17
|
+
headerHeight: number;
|
|
18
|
+
columnWidth: number;
|
|
19
|
+
fontFamily: string;
|
|
20
|
+
fontSize: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const Calendar: React.FC<CalendarProps>;
|