@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.
Files changed (146) hide show
  1. package/client-v2.d.ts +2 -0
  2. package/client-v2.js +3 -0
  3. package/dist/client/index.js +1 -1
  4. package/dist/client-v2/143.1a8cf1cd5ce17b64.js +10 -0
  5. package/dist/client-v2/416.b7bb09162520e448.js +10 -0
  6. package/dist/client-v2/617.de3dc437887f3f07.js +10 -0
  7. package/dist/client-v2/872.e640aca77c79d895.js +10 -0
  8. package/dist/client-v2/index.d.ts +10 -0
  9. package/dist/client-v2/index.js +10 -0
  10. package/dist/client-v2/locale.d.ts +78 -0
  11. package/dist/client-v2/models/GanttBlockModel.d.ts +98 -0
  12. package/dist/client-v2/models/GanttBlockModel.helpers.d.ts +31 -0
  13. package/dist/client-v2/models/GanttBlockModel.settings.d.ts +9 -0
  14. package/dist/client-v2/models/actions/GanttActionModels.d.ts +33 -0
  15. package/dist/client-v2/models/actions/GanttPopupModels.d.ts +26 -0
  16. package/dist/client-v2/models/components/GanttBlock.d.ts +13 -0
  17. package/dist/client-v2/models/components/GanttBlock.helpers.d.ts +22 -0
  18. package/dist/client-v2/models/components/GanttBlock.styles.d.ts +22 -0
  19. package/dist/client-v2/models/components/GanttBlock.tree.d.ts +46 -0
  20. package/dist/client-v2/models/components/getLabelFormatValue.d.ts +11 -0
  21. package/dist/client-v2/models/index.d.ts +11 -0
  22. package/dist/client-v2/plugin.d.ts +13 -0
  23. package/dist/externalVersion.js +7 -6
  24. package/dist/locale/de-DE.json +2 -0
  25. package/dist/locale/en-US.json +25 -1
  26. package/dist/locale/es-ES.json +2 -0
  27. package/dist/locale/fr-FR.json +2 -0
  28. package/dist/locale/hu-HU.json +2 -0
  29. package/dist/locale/id-ID.json +2 -0
  30. package/dist/locale/it-IT.json +2 -0
  31. package/dist/locale/ja-JP.json +2 -0
  32. package/dist/locale/ko-KR.json +2 -0
  33. package/dist/locale/nl-NL.json +2 -0
  34. package/dist/locale/pt-BR.json +2 -0
  35. package/dist/locale/ru-RU.json +2 -0
  36. package/dist/locale/tr-TR.json +2 -0
  37. package/dist/locale/uk-UA.json +2 -0
  38. package/dist/locale/vi-VN.json +2 -0
  39. package/dist/locale/zh-CN.json +25 -1
  40. package/dist/locale/zh-TW.json +4 -0
  41. package/dist/node_modules/@ctrl/tinycolor/LICENSE +7 -0
  42. package/dist/node_modules/@ctrl/tinycolor/dist/bundles/tinycolor.umd.min.js +2 -0
  43. package/dist/node_modules/@ctrl/tinycolor/dist/conversion.d.ts +61 -0
  44. package/dist/node_modules/@ctrl/tinycolor/dist/conversion.js +250 -0
  45. package/dist/node_modules/@ctrl/tinycolor/dist/css-color-names.d.ts +4 -0
  46. package/dist/node_modules/@ctrl/tinycolor/dist/css-color-names.js +157 -0
  47. package/dist/node_modules/@ctrl/tinycolor/dist/format-input.d.ts +37 -0
  48. package/dist/node_modules/@ctrl/tinycolor/dist/format-input.js +189 -0
  49. package/dist/node_modules/@ctrl/tinycolor/dist/from-ratio.d.ts +14 -0
  50. package/dist/node_modules/@ctrl/tinycolor/dist/from-ratio.js +30 -0
  51. package/dist/node_modules/@ctrl/tinycolor/dist/index.d.ts +207 -0
  52. package/dist/node_modules/@ctrl/tinycolor/dist/index.js +512 -0
  53. package/dist/node_modules/@ctrl/tinycolor/dist/interfaces.d.ts +46 -0
  54. package/dist/node_modules/@ctrl/tinycolor/dist/interfaces.js +2 -0
  55. package/dist/node_modules/@ctrl/tinycolor/dist/module/conversion.js +235 -0
  56. package/dist/node_modules/@ctrl/tinycolor/dist/module/css-color-names.js +154 -0
  57. package/dist/node_modules/@ctrl/tinycolor/dist/module/format-input.js +183 -0
  58. package/dist/node_modules/@ctrl/tinycolor/dist/module/from-ratio.js +25 -0
  59. package/dist/node_modules/@ctrl/tinycolor/dist/module/index.js +508 -0
  60. package/dist/node_modules/@ctrl/tinycolor/dist/module/interfaces.js +1 -0
  61. package/dist/node_modules/@ctrl/tinycolor/dist/module/public_api.js +12 -0
  62. package/dist/node_modules/@ctrl/tinycolor/dist/module/random.js +278 -0
  63. package/dist/node_modules/@ctrl/tinycolor/dist/module/readability.js +80 -0
  64. package/dist/node_modules/@ctrl/tinycolor/dist/module/to-ms-filter.js +16 -0
  65. package/dist/node_modules/@ctrl/tinycolor/dist/module/umd_api.js +20 -0
  66. package/dist/node_modules/@ctrl/tinycolor/dist/module/util.js +82 -0
  67. package/dist/node_modules/@ctrl/tinycolor/dist/public_api.d.ts +11 -0
  68. package/dist/node_modules/@ctrl/tinycolor/dist/public_api.js +1 -0
  69. package/dist/node_modules/@ctrl/tinycolor/dist/random.d.ts +24 -0
  70. package/dist/node_modules/@ctrl/tinycolor/dist/random.js +282 -0
  71. package/dist/node_modules/@ctrl/tinycolor/dist/readability.d.ts +46 -0
  72. package/dist/node_modules/@ctrl/tinycolor/dist/readability.js +86 -0
  73. package/dist/node_modules/@ctrl/tinycolor/dist/to-ms-filter.d.ts +5 -0
  74. package/dist/node_modules/@ctrl/tinycolor/dist/to-ms-filter.js +20 -0
  75. package/dist/node_modules/@ctrl/tinycolor/dist/umd_api.d.ts +23 -0
  76. package/dist/node_modules/@ctrl/tinycolor/dist/umd_api.js +22 -0
  77. package/dist/node_modules/@ctrl/tinycolor/dist/util.d.ts +36 -0
  78. package/dist/node_modules/@ctrl/tinycolor/dist/util.js +92 -0
  79. package/dist/node_modules/@ctrl/tinycolor/package.json +1 -0
  80. package/dist/shared/components/calendar/calendar.d.ts +22 -0
  81. package/dist/shared/components/calendar/calendar.js +417 -0
  82. package/dist/shared/components/calendar/style.d.ts +14 -0
  83. package/dist/shared/components/calendar/style.js +79 -0
  84. package/dist/shared/components/calendar/top-part-of-calendar.d.ts +19 -0
  85. package/dist/shared/components/calendar/top-part-of-calendar.js +57 -0
  86. package/dist/shared/components/gantt/style.d.ts +14 -0
  87. package/dist/shared/components/gantt/style.js +74 -0
  88. package/dist/shared/components/gantt/task-gantt-content.d.ts +35 -0
  89. package/dist/shared/components/gantt/task-gantt-content.js +337 -0
  90. package/dist/shared/components/gantt/task-gantt.d.ts +24 -0
  91. package/dist/shared/components/gantt/task-gantt.js +128 -0
  92. package/dist/shared/components/grid/grid-body.d.ts +21 -0
  93. package/dist/shared/components/grid/grid-body.js +114 -0
  94. package/dist/shared/components/grid/grid.d.ts +12 -0
  95. package/dist/shared/components/grid/grid.js +50 -0
  96. package/dist/shared/components/grid/style.d.ts +14 -0
  97. package/dist/shared/components/grid/style.js +54 -0
  98. package/dist/shared/components/other/arrow.d.ts +20 -0
  99. package/dist/shared/components/other/arrow.js +90 -0
  100. package/dist/shared/components/other/horizontal-scroll.d.ts +16 -0
  101. package/dist/shared/components/other/horizontal-scroll.js +64 -0
  102. package/dist/shared/components/other/style.d.ts +16 -0
  103. package/dist/shared/components/other/style.js +125 -0
  104. package/dist/shared/components/other/tooltip.d.ts +36 -0
  105. package/dist/shared/components/other/tooltip.js +137 -0
  106. package/dist/shared/components/other/vertical-scroll.d.ts +17 -0
  107. package/dist/shared/components/other/vertical-scroll.js +74 -0
  108. package/dist/shared/components/task-item/bar/bar-date-handle.d.ts +19 -0
  109. package/dist/shared/components/task-item/bar/bar-date-handle.js +62 -0
  110. package/dist/shared/components/task-item/bar/bar-display.d.ts +29 -0
  111. package/dist/shared/components/task-item/bar/bar-display.js +98 -0
  112. package/dist/shared/components/task-item/bar/bar-progress-handle.d.ts +15 -0
  113. package/dist/shared/components/task-item/bar/bar-progress-handle.js +49 -0
  114. package/dist/shared/components/task-item/bar/bar-small.d.ts +11 -0
  115. package/dist/shared/components/task-item/bar/bar-small.js +85 -0
  116. package/dist/shared/components/task-item/bar/bar.d.ts +11 -0
  117. package/dist/shared/components/task-item/bar/bar.js +113 -0
  118. package/dist/shared/components/task-item/bar/style.d.ts +10 -0
  119. package/dist/shared/components/task-item/bar/style.js +58 -0
  120. package/dist/shared/components/task-item/milestone/milestone.d.ts +11 -0
  121. package/dist/shared/components/task-item/milestone/milestone.js +72 -0
  122. package/dist/shared/components/task-item/milestone/style.d.ts +10 -0
  123. package/dist/shared/components/task-item/milestone/style.js +45 -0
  124. package/dist/shared/components/task-item/project/project.d.ts +11 -0
  125. package/dist/shared/components/task-item/project/project.js +77 -0
  126. package/dist/shared/components/task-item/project/style.d.ts +11 -0
  127. package/dist/shared/components/task-item/project/style.js +51 -0
  128. package/dist/shared/components/task-item/style.d.ts +12 -0
  129. package/dist/shared/components/task-item/style.js +74 -0
  130. package/dist/shared/components/task-item/task-item.d.ts +23 -0
  131. package/dist/shared/components/task-item/task-item.js +132 -0
  132. package/dist/shared/helpers/bar-helper.d.ts +22 -0
  133. package/dist/shared/helpers/bar-helper.js +415 -0
  134. package/dist/shared/helpers/date-helper.d.ts +27 -0
  135. package/dist/shared/helpers/date-helper.js +231 -0
  136. package/dist/shared/helpers/other-helper.d.ts +17 -0
  137. package/dist/shared/helpers/other-helper.js +97 -0
  138. package/dist/shared/types/bar-task.d.ts +30 -0
  139. package/dist/shared/types/bar-task.js +24 -0
  140. package/dist/shared/types/date-setup.d.ts +13 -0
  141. package/dist/shared/types/date-setup.js +24 -0
  142. package/dist/shared/types/gantt-task-actions.d.ts +16 -0
  143. package/dist/shared/types/gantt-task-actions.js +24 -0
  144. package/dist/shared/types/public-types.d.ts +145 -0
  145. package/dist/shared/types/public-types.js +46 -0
  146. package/package.json +2 -2
@@ -0,0 +1,512 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tinycolor = exports.TinyColor = void 0;
4
+ var conversion_js_1 = require("./conversion.js");
5
+ var css_color_names_js_1 = require("./css-color-names.js");
6
+ var format_input_1 = require("./format-input");
7
+ var util_js_1 = require("./util.js");
8
+ var TinyColor = /** @class */ (function () {
9
+ function TinyColor(color, opts) {
10
+ if (color === void 0) { color = ''; }
11
+ if (opts === void 0) { opts = {}; }
12
+ var _a;
13
+ // If input is already a tinycolor, return itself
14
+ if (color instanceof TinyColor) {
15
+ // eslint-disable-next-line no-constructor-return
16
+ return color;
17
+ }
18
+ if (typeof color === 'number') {
19
+ color = (0, conversion_js_1.numberInputToObject)(color);
20
+ }
21
+ this.originalInput = color;
22
+ var rgb = (0, format_input_1.inputToRGB)(color);
23
+ this.originalInput = color;
24
+ this.r = rgb.r;
25
+ this.g = rgb.g;
26
+ this.b = rgb.b;
27
+ this.a = rgb.a;
28
+ this.roundA = Math.round(100 * this.a) / 100;
29
+ this.format = (_a = opts.format) !== null && _a !== void 0 ? _a : rgb.format;
30
+ this.gradientType = opts.gradientType;
31
+ // Don't let the range of [0,255] come back in [0,1].
32
+ // Potentially lose a little bit of precision here, but will fix issues where
33
+ // .5 gets interpreted as half of the total, instead of half of 1
34
+ // If it was supposed to be 128, this was already taken care of by `inputToRgb`
35
+ if (this.r < 1) {
36
+ this.r = Math.round(this.r);
37
+ }
38
+ if (this.g < 1) {
39
+ this.g = Math.round(this.g);
40
+ }
41
+ if (this.b < 1) {
42
+ this.b = Math.round(this.b);
43
+ }
44
+ this.isValid = rgb.ok;
45
+ }
46
+ TinyColor.prototype.isDark = function () {
47
+ return this.getBrightness() < 128;
48
+ };
49
+ TinyColor.prototype.isLight = function () {
50
+ return !this.isDark();
51
+ };
52
+ /**
53
+ * Returns the perceived brightness of the color, from 0-255.
54
+ */
55
+ TinyColor.prototype.getBrightness = function () {
56
+ // http://www.w3.org/TR/AERT#color-contrast
57
+ var rgb = this.toRgb();
58
+ return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
59
+ };
60
+ /**
61
+ * Returns the perceived luminance of a color, from 0-1.
62
+ */
63
+ TinyColor.prototype.getLuminance = function () {
64
+ // http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
65
+ var rgb = this.toRgb();
66
+ var R;
67
+ var G;
68
+ var B;
69
+ var RsRGB = rgb.r / 255;
70
+ var GsRGB = rgb.g / 255;
71
+ var BsRGB = rgb.b / 255;
72
+ if (RsRGB <= 0.03928) {
73
+ R = RsRGB / 12.92;
74
+ }
75
+ else {
76
+ // eslint-disable-next-line prefer-exponentiation-operator
77
+ R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
78
+ }
79
+ if (GsRGB <= 0.03928) {
80
+ G = GsRGB / 12.92;
81
+ }
82
+ else {
83
+ // eslint-disable-next-line prefer-exponentiation-operator
84
+ G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
85
+ }
86
+ if (BsRGB <= 0.03928) {
87
+ B = BsRGB / 12.92;
88
+ }
89
+ else {
90
+ // eslint-disable-next-line prefer-exponentiation-operator
91
+ B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
92
+ }
93
+ return 0.2126 * R + 0.7152 * G + 0.0722 * B;
94
+ };
95
+ /**
96
+ * Returns the alpha value of a color, from 0-1.
97
+ */
98
+ TinyColor.prototype.getAlpha = function () {
99
+ return this.a;
100
+ };
101
+ /**
102
+ * Sets the alpha value on the current color.
103
+ *
104
+ * @param alpha - The new alpha value. The accepted range is 0-1.
105
+ */
106
+ TinyColor.prototype.setAlpha = function (alpha) {
107
+ this.a = (0, util_js_1.boundAlpha)(alpha);
108
+ this.roundA = Math.round(100 * this.a) / 100;
109
+ return this;
110
+ };
111
+ /**
112
+ * Returns whether the color is monochrome.
113
+ */
114
+ TinyColor.prototype.isMonochrome = function () {
115
+ var s = this.toHsl().s;
116
+ return s === 0;
117
+ };
118
+ /**
119
+ * Returns the object as a HSVA object.
120
+ */
121
+ TinyColor.prototype.toHsv = function () {
122
+ var hsv = (0, conversion_js_1.rgbToHsv)(this.r, this.g, this.b);
123
+ return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this.a };
124
+ };
125
+ /**
126
+ * Returns the hsva values interpolated into a string with the following format:
127
+ * "hsva(xxx, xxx, xxx, xx)".
128
+ */
129
+ TinyColor.prototype.toHsvString = function () {
130
+ var hsv = (0, conversion_js_1.rgbToHsv)(this.r, this.g, this.b);
131
+ var h = Math.round(hsv.h * 360);
132
+ var s = Math.round(hsv.s * 100);
133
+ var v = Math.round(hsv.v * 100);
134
+ return this.a === 1 ? "hsv(".concat(h, ", ").concat(s, "%, ").concat(v, "%)") : "hsva(".concat(h, ", ").concat(s, "%, ").concat(v, "%, ").concat(this.roundA, ")");
135
+ };
136
+ /**
137
+ * Returns the object as a HSLA object.
138
+ */
139
+ TinyColor.prototype.toHsl = function () {
140
+ var hsl = (0, conversion_js_1.rgbToHsl)(this.r, this.g, this.b);
141
+ return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this.a };
142
+ };
143
+ /**
144
+ * Returns the hsla values interpolated into a string with the following format:
145
+ * "hsla(xxx, xxx, xxx, xx)".
146
+ */
147
+ TinyColor.prototype.toHslString = function () {
148
+ var hsl = (0, conversion_js_1.rgbToHsl)(this.r, this.g, this.b);
149
+ var h = Math.round(hsl.h * 360);
150
+ var s = Math.round(hsl.s * 100);
151
+ var l = Math.round(hsl.l * 100);
152
+ return this.a === 1 ? "hsl(".concat(h, ", ").concat(s, "%, ").concat(l, "%)") : "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(this.roundA, ")");
153
+ };
154
+ /**
155
+ * Returns the hex value of the color.
156
+ * @param allow3Char will shorten hex value to 3 char if possible
157
+ */
158
+ TinyColor.prototype.toHex = function (allow3Char) {
159
+ if (allow3Char === void 0) { allow3Char = false; }
160
+ return (0, conversion_js_1.rgbToHex)(this.r, this.g, this.b, allow3Char);
161
+ };
162
+ /**
163
+ * Returns the hex value of the color -with a # prefixed.
164
+ * @param allow3Char will shorten hex value to 3 char if possible
165
+ */
166
+ TinyColor.prototype.toHexString = function (allow3Char) {
167
+ if (allow3Char === void 0) { allow3Char = false; }
168
+ return '#' + this.toHex(allow3Char);
169
+ };
170
+ /**
171
+ * Returns the hex 8 value of the color.
172
+ * @param allow4Char will shorten hex value to 4 char if possible
173
+ */
174
+ TinyColor.prototype.toHex8 = function (allow4Char) {
175
+ if (allow4Char === void 0) { allow4Char = false; }
176
+ return (0, conversion_js_1.rgbaToHex)(this.r, this.g, this.b, this.a, allow4Char);
177
+ };
178
+ /**
179
+ * Returns the hex 8 value of the color -with a # prefixed.
180
+ * @param allow4Char will shorten hex value to 4 char if possible
181
+ */
182
+ TinyColor.prototype.toHex8String = function (allow4Char) {
183
+ if (allow4Char === void 0) { allow4Char = false; }
184
+ return '#' + this.toHex8(allow4Char);
185
+ };
186
+ /**
187
+ * Returns the shorter hex value of the color depends on its alpha -with a # prefixed.
188
+ * @param allowShortChar will shorten hex value to 3 or 4 char if possible
189
+ */
190
+ TinyColor.prototype.toHexShortString = function (allowShortChar) {
191
+ if (allowShortChar === void 0) { allowShortChar = false; }
192
+ return this.a === 1 ? this.toHexString(allowShortChar) : this.toHex8String(allowShortChar);
193
+ };
194
+ /**
195
+ * Returns the object as a RGBA object.
196
+ */
197
+ TinyColor.prototype.toRgb = function () {
198
+ return {
199
+ r: Math.round(this.r),
200
+ g: Math.round(this.g),
201
+ b: Math.round(this.b),
202
+ a: this.a,
203
+ };
204
+ };
205
+ /**
206
+ * Returns the RGBA values interpolated into a string with the following format:
207
+ * "RGBA(xxx, xxx, xxx, xx)".
208
+ */
209
+ TinyColor.prototype.toRgbString = function () {
210
+ var r = Math.round(this.r);
211
+ var g = Math.round(this.g);
212
+ var b = Math.round(this.b);
213
+ return this.a === 1 ? "rgb(".concat(r, ", ").concat(g, ", ").concat(b, ")") : "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(this.roundA, ")");
214
+ };
215
+ /**
216
+ * Returns the object as a RGBA object.
217
+ */
218
+ TinyColor.prototype.toPercentageRgb = function () {
219
+ var fmt = function (x) { return "".concat(Math.round((0, util_js_1.bound01)(x, 255) * 100), "%"); };
220
+ return {
221
+ r: fmt(this.r),
222
+ g: fmt(this.g),
223
+ b: fmt(this.b),
224
+ a: this.a,
225
+ };
226
+ };
227
+ /**
228
+ * Returns the RGBA relative values interpolated into a string
229
+ */
230
+ TinyColor.prototype.toPercentageRgbString = function () {
231
+ var rnd = function (x) { return Math.round((0, util_js_1.bound01)(x, 255) * 100); };
232
+ return this.a === 1
233
+ ? "rgb(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%)")
234
+ : "rgba(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%, ").concat(this.roundA, ")");
235
+ };
236
+ /**
237
+ * The 'real' name of the color -if there is one.
238
+ */
239
+ TinyColor.prototype.toName = function () {
240
+ if (this.a === 0) {
241
+ return 'transparent';
242
+ }
243
+ if (this.a < 1) {
244
+ return false;
245
+ }
246
+ var hex = '#' + (0, conversion_js_1.rgbToHex)(this.r, this.g, this.b, false);
247
+ for (var _i = 0, _a = Object.entries(css_color_names_js_1.names); _i < _a.length; _i++) {
248
+ var _b = _a[_i], key = _b[0], value = _b[1];
249
+ if (hex === value) {
250
+ return key;
251
+ }
252
+ }
253
+ return false;
254
+ };
255
+ TinyColor.prototype.toString = function (format) {
256
+ var formatSet = Boolean(format);
257
+ format = format !== null && format !== void 0 ? format : this.format;
258
+ var formattedString = false;
259
+ var hasAlpha = this.a < 1 && this.a >= 0;
260
+ var needsAlphaFormat = !formatSet && hasAlpha && (format.startsWith('hex') || format === 'name');
261
+ if (needsAlphaFormat) {
262
+ // Special case for "transparent", all other non-alpha formats
263
+ // will return rgba when there is transparency.
264
+ if (format === 'name' && this.a === 0) {
265
+ return this.toName();
266
+ }
267
+ return this.toRgbString();
268
+ }
269
+ if (format === 'rgb') {
270
+ formattedString = this.toRgbString();
271
+ }
272
+ if (format === 'prgb') {
273
+ formattedString = this.toPercentageRgbString();
274
+ }
275
+ if (format === 'hex' || format === 'hex6') {
276
+ formattedString = this.toHexString();
277
+ }
278
+ if (format === 'hex3') {
279
+ formattedString = this.toHexString(true);
280
+ }
281
+ if (format === 'hex4') {
282
+ formattedString = this.toHex8String(true);
283
+ }
284
+ if (format === 'hex8') {
285
+ formattedString = this.toHex8String();
286
+ }
287
+ if (format === 'name') {
288
+ formattedString = this.toName();
289
+ }
290
+ if (format === 'hsl') {
291
+ formattedString = this.toHslString();
292
+ }
293
+ if (format === 'hsv') {
294
+ formattedString = this.toHsvString();
295
+ }
296
+ return formattedString || this.toHexString();
297
+ };
298
+ TinyColor.prototype.toNumber = function () {
299
+ return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
300
+ };
301
+ TinyColor.prototype.clone = function () {
302
+ return new TinyColor(this.toString());
303
+ };
304
+ /**
305
+ * Lighten the color a given amount. Providing 100 will always return white.
306
+ * @param amount - valid between 1-100
307
+ */
308
+ TinyColor.prototype.lighten = function (amount) {
309
+ if (amount === void 0) { amount = 10; }
310
+ var hsl = this.toHsl();
311
+ hsl.l += amount / 100;
312
+ hsl.l = (0, util_js_1.clamp01)(hsl.l);
313
+ return new TinyColor(hsl);
314
+ };
315
+ /**
316
+ * Brighten the color a given amount, from 0 to 100.
317
+ * @param amount - valid between 1-100
318
+ */
319
+ TinyColor.prototype.brighten = function (amount) {
320
+ if (amount === void 0) { amount = 10; }
321
+ var rgb = this.toRgb();
322
+ rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
323
+ rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
324
+ rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
325
+ return new TinyColor(rgb);
326
+ };
327
+ /**
328
+ * Darken the color a given amount, from 0 to 100.
329
+ * Providing 100 will always return black.
330
+ * @param amount - valid between 1-100
331
+ */
332
+ TinyColor.prototype.darken = function (amount) {
333
+ if (amount === void 0) { amount = 10; }
334
+ var hsl = this.toHsl();
335
+ hsl.l -= amount / 100;
336
+ hsl.l = (0, util_js_1.clamp01)(hsl.l);
337
+ return new TinyColor(hsl);
338
+ };
339
+ /**
340
+ * Mix the color with pure white, from 0 to 100.
341
+ * Providing 0 will do nothing, providing 100 will always return white.
342
+ * @param amount - valid between 1-100
343
+ */
344
+ TinyColor.prototype.tint = function (amount) {
345
+ if (amount === void 0) { amount = 10; }
346
+ return this.mix('white', amount);
347
+ };
348
+ /**
349
+ * Mix the color with pure black, from 0 to 100.
350
+ * Providing 0 will do nothing, providing 100 will always return black.
351
+ * @param amount - valid between 1-100
352
+ */
353
+ TinyColor.prototype.shade = function (amount) {
354
+ if (amount === void 0) { amount = 10; }
355
+ return this.mix('black', amount);
356
+ };
357
+ /**
358
+ * Desaturate the color a given amount, from 0 to 100.
359
+ * Providing 100 will is the same as calling greyscale
360
+ * @param amount - valid between 1-100
361
+ */
362
+ TinyColor.prototype.desaturate = function (amount) {
363
+ if (amount === void 0) { amount = 10; }
364
+ var hsl = this.toHsl();
365
+ hsl.s -= amount / 100;
366
+ hsl.s = (0, util_js_1.clamp01)(hsl.s);
367
+ return new TinyColor(hsl);
368
+ };
369
+ /**
370
+ * Saturate the color a given amount, from 0 to 100.
371
+ * @param amount - valid between 1-100
372
+ */
373
+ TinyColor.prototype.saturate = function (amount) {
374
+ if (amount === void 0) { amount = 10; }
375
+ var hsl = this.toHsl();
376
+ hsl.s += amount / 100;
377
+ hsl.s = (0, util_js_1.clamp01)(hsl.s);
378
+ return new TinyColor(hsl);
379
+ };
380
+ /**
381
+ * Completely desaturates a color into greyscale.
382
+ * Same as calling `desaturate(100)`
383
+ */
384
+ TinyColor.prototype.greyscale = function () {
385
+ return this.desaturate(100);
386
+ };
387
+ /**
388
+ * Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
389
+ * Values outside of this range will be wrapped into this range.
390
+ */
391
+ TinyColor.prototype.spin = function (amount) {
392
+ var hsl = this.toHsl();
393
+ var hue = (hsl.h + amount) % 360;
394
+ hsl.h = hue < 0 ? 360 + hue : hue;
395
+ return new TinyColor(hsl);
396
+ };
397
+ /**
398
+ * Mix the current color a given amount with another color, from 0 to 100.
399
+ * 0 means no mixing (return current color).
400
+ */
401
+ TinyColor.prototype.mix = function (color, amount) {
402
+ if (amount === void 0) { amount = 50; }
403
+ var rgb1 = this.toRgb();
404
+ var rgb2 = new TinyColor(color).toRgb();
405
+ var p = amount / 100;
406
+ var rgba = {
407
+ r: (rgb2.r - rgb1.r) * p + rgb1.r,
408
+ g: (rgb2.g - rgb1.g) * p + rgb1.g,
409
+ b: (rgb2.b - rgb1.b) * p + rgb1.b,
410
+ a: (rgb2.a - rgb1.a) * p + rgb1.a,
411
+ };
412
+ return new TinyColor(rgba);
413
+ };
414
+ TinyColor.prototype.analogous = function (results, slices) {
415
+ if (results === void 0) { results = 6; }
416
+ if (slices === void 0) { slices = 30; }
417
+ var hsl = this.toHsl();
418
+ var part = 360 / slices;
419
+ var ret = [this];
420
+ for (hsl.h = (hsl.h - ((part * results) >> 1) + 720) % 360; --results;) {
421
+ hsl.h = (hsl.h + part) % 360;
422
+ ret.push(new TinyColor(hsl));
423
+ }
424
+ return ret;
425
+ };
426
+ /**
427
+ * taken from https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js
428
+ */
429
+ TinyColor.prototype.complement = function () {
430
+ var hsl = this.toHsl();
431
+ hsl.h = (hsl.h + 180) % 360;
432
+ return new TinyColor(hsl);
433
+ };
434
+ TinyColor.prototype.monochromatic = function (results) {
435
+ if (results === void 0) { results = 6; }
436
+ var hsv = this.toHsv();
437
+ var h = hsv.h;
438
+ var s = hsv.s;
439
+ var v = hsv.v;
440
+ var res = [];
441
+ var modification = 1 / results;
442
+ while (results--) {
443
+ res.push(new TinyColor({ h: h, s: s, v: v }));
444
+ v = (v + modification) % 1;
445
+ }
446
+ return res;
447
+ };
448
+ TinyColor.prototype.splitcomplement = function () {
449
+ var hsl = this.toHsl();
450
+ var h = hsl.h;
451
+ return [
452
+ this,
453
+ new TinyColor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }),
454
+ new TinyColor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l }),
455
+ ];
456
+ };
457
+ /**
458
+ * Compute how the color would appear on a background
459
+ */
460
+ TinyColor.prototype.onBackground = function (background) {
461
+ var fg = this.toRgb();
462
+ var bg = new TinyColor(background).toRgb();
463
+ var alpha = fg.a + bg.a * (1 - fg.a);
464
+ return new TinyColor({
465
+ r: (fg.r * fg.a + bg.r * bg.a * (1 - fg.a)) / alpha,
466
+ g: (fg.g * fg.a + bg.g * bg.a * (1 - fg.a)) / alpha,
467
+ b: (fg.b * fg.a + bg.b * bg.a * (1 - fg.a)) / alpha,
468
+ a: alpha,
469
+ });
470
+ };
471
+ /**
472
+ * Alias for `polyad(3)`
473
+ */
474
+ TinyColor.prototype.triad = function () {
475
+ return this.polyad(3);
476
+ };
477
+ /**
478
+ * Alias for `polyad(4)`
479
+ */
480
+ TinyColor.prototype.tetrad = function () {
481
+ return this.polyad(4);
482
+ };
483
+ /**
484
+ * Get polyad colors, like (for 1, 2, 3, 4, 5, 6, 7, 8, etc...)
485
+ * monad, dyad, triad, tetrad, pentad, hexad, heptad, octad, etc...
486
+ */
487
+ TinyColor.prototype.polyad = function (n) {
488
+ var hsl = this.toHsl();
489
+ var h = hsl.h;
490
+ var result = [this];
491
+ var increment = 360 / n;
492
+ for (var i = 1; i < n; i++) {
493
+ result.push(new TinyColor({ h: (h + i * increment) % 360, s: hsl.s, l: hsl.l }));
494
+ }
495
+ return result;
496
+ };
497
+ /**
498
+ * compare color vs current color
499
+ */
500
+ TinyColor.prototype.equals = function (color) {
501
+ return this.toRgbString() === new TinyColor(color).toRgbString();
502
+ };
503
+ return TinyColor;
504
+ }());
505
+ exports.TinyColor = TinyColor;
506
+ // kept for backwards compatability with v1
507
+ function tinycolor(color, opts) {
508
+ if (color === void 0) { color = ''; }
509
+ if (opts === void 0) { opts = {}; }
510
+ return new TinyColor(color, opts);
511
+ }
512
+ exports.tinycolor = tinycolor;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * convert all properties in an interface to a number
3
+ */
4
+ export type Numberify<T> = {
5
+ [P in keyof T]: number;
6
+ };
7
+ /**
8
+ * A representation of additive color mixing.
9
+ * Projection of primary color lights on a white screen shows secondary
10
+ * colors where two overlap; the combination of all three of red, green,
11
+ * and blue in equal intensities makes white.
12
+ */
13
+ export interface RGB {
14
+ r: number | string;
15
+ g: number | string;
16
+ b: number | string;
17
+ }
18
+ export interface RGBA extends RGB {
19
+ a: number;
20
+ }
21
+ /**
22
+ * The HSL model describes colors in terms of hue, saturation,
23
+ * and lightness (also called luminance).
24
+ * @link https://en.wikibooks.org/wiki/Color_Models:_RGB,_HSV,_HSL#HSL
25
+ */
26
+ export interface HSL {
27
+ h: number | string;
28
+ s: number | string;
29
+ l: number | string;
30
+ }
31
+ export interface HSLA extends HSL {
32
+ a: number;
33
+ }
34
+ /**
35
+ * The HSV, or HSB, model describes colors in terms of
36
+ * hue, saturation, and value (brightness).
37
+ * @link https://en.wikibooks.org/wiki/Color_Models:_RGB,_HSV,_HSL#HSV
38
+ */
39
+ export interface HSV {
40
+ h: number | string;
41
+ s: number | string;
42
+ v: number | string;
43
+ }
44
+ export interface HSVA extends HSV {
45
+ a: number;
46
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });