@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,2 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).tinycolor=e()}(this,(function(){"use strict";var t={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",goldenrod:"#daa520",gold:"#ffd700",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavenderblush:"#fff0f5",lavender:"#e6e6fa",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function e(t,e){(function(t){return"string"==typeof t&&-1!==t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var r=function(t){return"string"==typeof t&&-1!==t.indexOf("%")}(t);return t=360===e?t:Math.min(e,Math.max(0,parseFloat(t))),r&&(t=parseInt(String(t*e),10)/100),Math.abs(t-e)<1e-6?1:t=360===e?(t<0?t%e+e:t%e)/parseFloat(String(e)):t%e/parseFloat(String(e))}function r(t){return Math.min(1,Math.max(0,t))}function n(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function a(t){return t<=1?"".concat(100*Number(t),"%"):t}function o(t){return 1===t.length?"0"+t:String(t)}function i(t,r,n){t=e(t,255),r=e(r,255),n=e(n,255);var a=Math.max(t,r,n),o=Math.min(t,r,n),i=0,s=0,h=(a+o)/2;if(a===o)s=0,i=0;else{var u=a-o;switch(s=h>.5?u/(2-a-o):u/(a+o),a){case t:i=(r-n)/u+(r<n?6:0);break;case r:i=(n-t)/u+2;break;case n:i=(t-r)/u+4}i/=6}return{h:i,s:s,l:h}}function s(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*r*(e-t):r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function h(t,r,n){t=e(t,255),r=e(r,255),n=e(n,255);var a=Math.max(t,r,n),o=Math.min(t,r,n),i=0,s=a,h=a-o,u=0===a?0:h/a;if(a===o)i=0;else{switch(a){case t:i=(r-n)/h+(r<n?6:0);break;case r:i=(n-t)/h+2;break;case n:i=(t-r)/h+4}i/=6}return{h:i,s:u,v:s}}function u(t,e,r,n){var a=[o(Math.round(t).toString(16)),o(Math.round(e).toString(16)),o(Math.round(r).toString(16))];return n&&a[0].startsWith(a[0].charAt(1))&&a[1].startsWith(a[1].charAt(1))&&a[2].startsWith(a[2].charAt(1))?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0):a.join("")}function f(t,e,r,n){return[o(c(n)),o(Math.round(t).toString(16)),o(Math.round(e).toString(16)),o(Math.round(r).toString(16))].join("")}function c(t){return Math.round(255*parseFloat(t)).toString(16)}function l(t){return d(t)/255}function d(t){return parseInt(t,16)}function g(t){var r,o,i,h={r:0,g:0,b:0},u=1,f=null,c=null,l=null,d=!1,g=!1;return"string"==typeof t&&(t=y(t)),"object"==typeof t&&(w(t.r)&&w(t.g)&&w(t.b)?(r=t.r,o=t.g,i=t.b,h={r:255*e(r,255),g:255*e(o,255),b:255*e(i,255)},d=!0,g="%"===String(t.r).substr(-1)?"prgb":"rgb"):w(t.h)&&w(t.s)&&w(t.v)?(f=a(t.s),c=a(t.v),h=function(t,r,n){t=6*e(t,360),r=e(r,100),n=e(n,100);var a=Math.floor(t),o=t-a,i=n*(1-r),s=n*(1-o*r),h=n*(1-(1-o)*r),u=a%6;return{r:255*[n,s,i,i,h,n][u],g:255*[h,n,n,s,i,i][u],b:255*[i,i,h,n,n,s][u]}}(t.h,f,c),d=!0,g="hsv"):w(t.h)&&w(t.s)&&w(t.l)&&(f=a(t.s),l=a(t.l),h=function(t,r,n){var a,o,i;if(t=e(t,360),r=e(r,100),n=e(n,100),0===r)o=n,i=n,a=n;else{var h=n<.5?n*(1+r):n+r-n*r,u=2*n-h;a=s(u,h,t+1/3),o=s(u,h,t),i=s(u,h,t-1/3)}return{r:255*a,g:255*o,b:255*i}}(t.h,f,l),d=!0,g="hsl"),Object.prototype.hasOwnProperty.call(t,"a")&&(u=t.a)),u=n(u),{ok:d,format:t.format||g,r:Math.min(255,Math.max(h.r,0)),g:Math.min(255,Math.max(h.g,0)),b:Math.min(255,Math.max(h.b,0)),a:u}}var b="(?:".concat("[-\\+]?\\d*\\.\\d+%?",")|(?:").concat("[-\\+]?\\d+%?",")"),p="[\\s|\\(]+(".concat(b,")[,|\\s]+(").concat(b,")[,|\\s]+(").concat(b,")\\s*\\)?"),v="[\\s|\\(]+(".concat(b,")[,|\\s]+(").concat(b,")[,|\\s]+(").concat(b,")[,|\\s]+(").concat(b,")\\s*\\)?"),m={CSS_UNIT:new RegExp(b),rgb:new RegExp("rgb"+p),rgba:new RegExp("rgba"+v),hsl:new RegExp("hsl"+p),hsla:new RegExp("hsla"+v),hsv:new RegExp("hsv"+p),hsva:new RegExp("hsva"+v),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/};function y(e){if(0===(e=e.trim().toLowerCase()).length)return!1;var r=!1;if(t[e])e=t[e],r=!0;else if("transparent"===e)return{r:0,g:0,b:0,a:0,format:"name"};var n=m.rgb.exec(e);return n?{r:n[1],g:n[2],b:n[3]}:(n=m.rgba.exec(e))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=m.hsl.exec(e))?{h:n[1],s:n[2],l:n[3]}:(n=m.hsla.exec(e))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=m.hsv.exec(e))?{h:n[1],s:n[2],v:n[3]}:(n=m.hsva.exec(e))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=m.hex8.exec(e))?{r:d(n[1]),g:d(n[2]),b:d(n[3]),a:l(n[4]),format:r?"name":"hex8"}:(n=m.hex6.exec(e))?{r:d(n[1]),g:d(n[2]),b:d(n[3]),format:r?"name":"hex"}:(n=m.hex4.exec(e))?{r:d(n[1]+n[1]),g:d(n[2]+n[2]),b:d(n[3]+n[3]),a:l(n[4]+n[4]),format:r?"name":"hex8"}:!!(n=m.hex3.exec(e))&&{r:d(n[1]+n[1]),g:d(n[2]+n[2]),b:d(n[3]+n[3]),format:r?"name":"hex"}}function w(t){return Boolean(m.CSS_UNIT.exec(String(t)))}var M=function(){function a(t,e){var r;if(void 0===t&&(t=""),void 0===e&&(e={}),t instanceof a)return t;"number"==typeof t&&(t=function(t){return{r:t>>16,g:(65280&t)>>8,b:255&t}}(t)),this.originalInput=t;var n=g(t);this.originalInput=t,this.r=n.r,this.g=n.g,this.b=n.b,this.a=n.a,this.roundA=Math.round(100*this.a)/100,this.format=null!==(r=e.format)&&void 0!==r?r:n.format,this.gradientType=e.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=n.ok}return a.prototype.isDark=function(){return this.getBrightness()<128},a.prototype.isLight=function(){return!this.isDark()},a.prototype.getBrightness=function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},a.prototype.getLuminance=function(){var t=this.toRgb(),e=t.r/255,r=t.g/255,n=t.b/255;return.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))},a.prototype.getAlpha=function(){return this.a},a.prototype.setAlpha=function(t){return this.a=n(t),this.roundA=Math.round(100*this.a)/100,this},a.prototype.isMonochrome=function(){return 0===this.toHsl().s},a.prototype.toHsv=function(){var t=h(this.r,this.g,this.b);return{h:360*t.h,s:t.s,v:t.v,a:this.a}},a.prototype.toHsvString=function(){var t=h(this.r,this.g,this.b),e=Math.round(360*t.h),r=Math.round(100*t.s),n=Math.round(100*t.v);return 1===this.a?"hsv(".concat(e,", ").concat(r,"%, ").concat(n,"%)"):"hsva(".concat(e,", ").concat(r,"%, ").concat(n,"%, ").concat(this.roundA,")")},a.prototype.toHsl=function(){var t=i(this.r,this.g,this.b);return{h:360*t.h,s:t.s,l:t.l,a:this.a}},a.prototype.toHslString=function(){var t=i(this.r,this.g,this.b),e=Math.round(360*t.h),r=Math.round(100*t.s),n=Math.round(100*t.l);return 1===this.a?"hsl(".concat(e,", ").concat(r,"%, ").concat(n,"%)"):"hsla(".concat(e,", ").concat(r,"%, ").concat(n,"%, ").concat(this.roundA,")")},a.prototype.toHex=function(t){return void 0===t&&(t=!1),u(this.r,this.g,this.b,t)},a.prototype.toHexString=function(t){return void 0===t&&(t=!1),"#"+this.toHex(t)},a.prototype.toHex8=function(t){return void 0===t&&(t=!1),function(t,e,r,n,a){var i=[o(Math.round(t).toString(16)),o(Math.round(e).toString(16)),o(Math.round(r).toString(16)),o(c(n))];return a&&i[0].startsWith(i[0].charAt(1))&&i[1].startsWith(i[1].charAt(1))&&i[2].startsWith(i[2].charAt(1))&&i[3].startsWith(i[3].charAt(1))?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0)+i[3].charAt(0):i.join("")}(this.r,this.g,this.b,this.a,t)},a.prototype.toHex8String=function(t){return void 0===t&&(t=!1),"#"+this.toHex8(t)},a.prototype.toHexShortString=function(t){return void 0===t&&(t=!1),1===this.a?this.toHexString(t):this.toHex8String(t)},a.prototype.toRgb=function(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}},a.prototype.toRgbString=function(){var t=Math.round(this.r),e=Math.round(this.g),r=Math.round(this.b);return 1===this.a?"rgb(".concat(t,", ").concat(e,", ").concat(r,")"):"rgba(".concat(t,", ").concat(e,", ").concat(r,", ").concat(this.roundA,")")},a.prototype.toPercentageRgb=function(){var t=function(t){return"".concat(Math.round(100*e(t,255)),"%")};return{r:t(this.r),g:t(this.g),b:t(this.b),a:this.a}},a.prototype.toPercentageRgbString=function(){var t=function(t){return Math.round(100*e(t,255))};return 1===this.a?"rgb(".concat(t(this.r),"%, ").concat(t(this.g),"%, ").concat(t(this.b),"%)"):"rgba(".concat(t(this.r),"%, ").concat(t(this.g),"%, ").concat(t(this.b),"%, ").concat(this.roundA,")")},a.prototype.toName=function(){if(0===this.a)return"transparent";if(this.a<1)return!1;for(var e="#"+u(this.r,this.g,this.b,!1),r=0,n=Object.entries(t);r<n.length;r++){var a=n[r],o=a[0];if(e===a[1])return o}return!1},a.prototype.toString=function(t){var e=Boolean(t);t=null!=t?t:this.format;var r=!1,n=this.a<1&&this.a>=0;return e||!n||!t.startsWith("hex")&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this.a?this.toName():this.toRgbString()},a.prototype.toNumber=function(){return(Math.round(this.r)<<16)+(Math.round(this.g)<<8)+Math.round(this.b)},a.prototype.clone=function(){return new a(this.toString())},a.prototype.lighten=function(t){void 0===t&&(t=10);var e=this.toHsl();return e.l+=t/100,e.l=r(e.l),new a(e)},a.prototype.brighten=function(t){void 0===t&&(t=10);var e=this.toRgb();return e.r=Math.max(0,Math.min(255,e.r-Math.round(-t/100*255))),e.g=Math.max(0,Math.min(255,e.g-Math.round(-t/100*255))),e.b=Math.max(0,Math.min(255,e.b-Math.round(-t/100*255))),new a(e)},a.prototype.darken=function(t){void 0===t&&(t=10);var e=this.toHsl();return e.l-=t/100,e.l=r(e.l),new a(e)},a.prototype.tint=function(t){return void 0===t&&(t=10),this.mix("white",t)},a.prototype.shade=function(t){return void 0===t&&(t=10),this.mix("black",t)},a.prototype.desaturate=function(t){void 0===t&&(t=10);var e=this.toHsl();return e.s-=t/100,e.s=r(e.s),new a(e)},a.prototype.saturate=function(t){void 0===t&&(t=10);var e=this.toHsl();return e.s+=t/100,e.s=r(e.s),new a(e)},a.prototype.greyscale=function(){return this.desaturate(100)},a.prototype.spin=function(t){var e=this.toHsl(),r=(e.h+t)%360;return e.h=r<0?360+r:r,new a(e)},a.prototype.mix=function(t,e){void 0===e&&(e=50);var r=this.toRgb(),n=new a(t).toRgb(),o=e/100;return new a({r:(n.r-r.r)*o+r.r,g:(n.g-r.g)*o+r.g,b:(n.b-r.b)*o+r.b,a:(n.a-r.a)*o+r.a})},a.prototype.analogous=function(t,e){void 0===t&&(t=6),void 0===e&&(e=30);var r=this.toHsl(),n=360/e,o=[this];for(r.h=(r.h-(n*t>>1)+720)%360;--t;)r.h=(r.h+n)%360,o.push(new a(r));return o},a.prototype.complement=function(){var t=this.toHsl();return t.h=(t.h+180)%360,new a(t)},a.prototype.monochromatic=function(t){void 0===t&&(t=6);for(var e=this.toHsv(),r=e.h,n=e.s,o=e.v,i=[],s=1/t;t--;)i.push(new a({h:r,s:n,v:o})),o=(o+s)%1;return i},a.prototype.splitcomplement=function(){var t=this.toHsl(),e=t.h;return[this,new a({h:(e+72)%360,s:t.s,l:t.l}),new a({h:(e+216)%360,s:t.s,l:t.l})]},a.prototype.onBackground=function(t){var e=this.toRgb(),r=new a(t).toRgb(),n=e.a+r.a*(1-e.a);return new a({r:(e.r*e.a+r.r*r.a*(1-e.a))/n,g:(e.g*e.a+r.g*r.a*(1-e.a))/n,b:(e.b*e.a+r.b*r.a*(1-e.a))/n,a:n})},a.prototype.triad=function(){return this.polyad(3)},a.prototype.tetrad=function(){return this.polyad(4)},a.prototype.polyad=function(t){for(var e=this.toHsl(),r=e.h,n=[this],o=360/t,i=1;i<t;i++)n.push(new a({h:(r+i*o)%360,s:e.s,l:e.l}));return n},a.prototype.equals=function(t){return this.toRgbString()===new a(t).toRgbString()},a}();function x(t){t>=334&&t<=360&&(t-=360);for(var e=0,r=S;e<r.length;e++){var n=A(r[e]);if(n.hueRange&&t>=n.hueRange[0]&&t<=n.hueRange[1])return n}throw Error("Color not found")}function k(t,e){if(void 0===e)return Math.floor(t[0]+Math.random()*(t[1]+1-t[0]));var r=t[1]||1,n=t[0]||0,a=(e=(9301*e+49297)%233280)/233280;return Math.floor(n+a*(r-n))}function A(t){var e=t.lowerBounds[0][0],r=t.lowerBounds[t.lowerBounds.length-1][0],n=t.lowerBounds[t.lowerBounds.length-1][1],a=t.lowerBounds[0][1];return{name:t.name,hueRange:t.hueRange,lowerBounds:t.lowerBounds,saturationRange:[e,r],brightnessRange:[n,a]}}var S=[{name:"monochrome",hueRange:null,lowerBounds:[[0,0],[100,0]]},{name:"red",hueRange:[-26,18],lowerBounds:[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]},{name:"orange",hueRange:[19,46],lowerBounds:[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]},{name:"yellow",hueRange:[47,62],lowerBounds:[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]},{name:"green",hueRange:[63,178],lowerBounds:[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]},{name:"blue",hueRange:[179,257],lowerBounds:[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]},{name:"purple",hueRange:[258,282],lowerBounds:[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]},{name:"pink",hueRange:[283,334],lowerBounds:[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]}];function R(t,e){var r=new M(t),n=new M(e);return(Math.max(r.getLuminance(),n.getLuminance())+.05)/(Math.min(r.getLuminance(),n.getLuminance())+.05)}var H=function(t,e){return void 0===t&&(t=""),void 0===e&&(e={}),new M(t,e)};return H.TinyColor=M,H.readability=R,H.mostReadable=function t(e,r,n){void 0===n&&(n={includeFallbackColors:!1,level:"AA",size:"small"});for(var a=null,o=0,i=n.includeFallbackColors,s=n.level,h=n.size,u=0,f=r;u<f.length;u++){var c=f[u],l=R(e,c);l>o&&(o=l,a=new M(c))}return function(t,e,r){var n,a;void 0===r&&(r={level:"AA",size:"small"});var o=R(t,e);switch((null!==(n=r.level)&&void 0!==n?n:"AA")+(null!==(a=r.size)&&void 0!==a?a:"small")){case"AAsmall":case"AAAlarge":return o>=4.5;case"AAlarge":return o>=3;case"AAAsmall":return o>=7;default:return!1}}(e,a,{level:s,size:h})||!i?a:(n.includeFallbackColors=!1,t(e,["#fff","#000"],n))},H.random=function t(e){if(void 0===e&&(e={}),void 0!==e.count&&null!==e.count){var r=e.count,n=[];for(e.count=void 0;r>n.length;)e.count=null,e.seed&&(e.seed+=1),n.push(t(e));return e.count=r,n}var a=function(t,e){var r=k(function(t){var e=parseInt(t,10);if(!Number.isNaN(e)&&e<360&&e>0)return[e,e];if("string"==typeof t){var r=S.find((function(e){return e.name===t}));if(r){var n=A(r);if(n.hueRange)return n.hueRange}var a=new M(t);if(a.isValid){var o=a.toHsv().h;return[o,o]}}return[0,360]}(t),e);r<0&&(r=360+r);return r}(e.hue,e.seed),o=function(t,e){if("monochrome"===e.hue)return 0;if("random"===e.luminosity)return k([0,100],e.seed);var r=x(t).saturationRange,n=r[0],a=r[1];switch(e.luminosity){case"bright":n=55;break;case"dark":n=a-10;break;case"light":a=55}return k([n,a],e.seed)}(a,e),i=function(t,e,r){var n=function(t,e){for(var r=x(t).lowerBounds,n=0;n<r.length-1;n++){var a=r[n][0],o=r[n][1],i=r[n+1][0],s=r[n+1][1];if(e>=a&&e<=i){var h=(s-o)/(i-a);return h*e+(o-h*a)}}return 0}(t,e),a=100;switch(r.luminosity){case"dark":a=n+20;break;case"light":n=(a+n)/2;break;case"random":n=0,a=100}return k([n,a],r.seed)}(a,o,e),s={h:a,s:o,v:i};return void 0!==e.alpha&&(s.a=e.alpha),new M(s)},H.names=t,H.fromRatio=function(t,e){var r={r:a(t.r),g:a(t.g),b:a(t.b)};return void 0!==t.a&&(r.a=Number(t.a)),new M(r,e)},H.legacyRandom=function(){return new M({r:Math.random(),g:Math.random(),b:Math.random()})},H.toMsFilter=function(t,e){var r=new M(t),n="#"+f(r.r,r.g,r.b,r.a),a=n,o=r.gradientType?"GradientType = 1, ":"";if(e){var i=new M(e);a="#"+f(i.r,i.g,i.b,i.a)}return"progid:DXImageTransform.Microsoft.gradient(".concat(o,"startColorstr=").concat(n,",endColorstr=").concat(a,")")},H.inputToRGB=g,H.stringInputToObject=y,H.isValidCSSUnit=w,H}));
|
|
2
|
+
//# sourceMappingURL=tinycolor.umd.min.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { HSL, HSV, Numberify, RGB } from './interfaces.js';
|
|
2
|
+
/**
|
|
3
|
+
* Handle bounds / percentage checking to conform to CSS color spec
|
|
4
|
+
* <http://www.w3.org/TR/css3-color/>
|
|
5
|
+
* *Assumes:* r, g, b in [0, 255] or [0, 1]
|
|
6
|
+
* *Returns:* { r, g, b } in [0, 255]
|
|
7
|
+
*/
|
|
8
|
+
export declare function rgbToRgb(r: number | string, g: number | string, b: number | string): Numberify<RGB>;
|
|
9
|
+
/**
|
|
10
|
+
* Converts an RGB color value to HSL.
|
|
11
|
+
* *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
|
|
12
|
+
* *Returns:* { h, s, l } in [0,1]
|
|
13
|
+
*/
|
|
14
|
+
export declare function rgbToHsl(r: number, g: number, b: number): Numberify<HSL>;
|
|
15
|
+
/**
|
|
16
|
+
* Converts an HSL color value to RGB.
|
|
17
|
+
*
|
|
18
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
|
|
19
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
20
|
+
*/
|
|
21
|
+
export declare function hslToRgb(h: number | string, s: number | string, l: number | string): Numberify<RGB>;
|
|
22
|
+
/**
|
|
23
|
+
* Converts an RGB color value to HSV
|
|
24
|
+
*
|
|
25
|
+
* *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
|
|
26
|
+
* *Returns:* { h, s, v } in [0,1]
|
|
27
|
+
*/
|
|
28
|
+
export declare function rgbToHsv(r: number, g: number, b: number): Numberify<HSV>;
|
|
29
|
+
/**
|
|
30
|
+
* Converts an HSV color value to RGB.
|
|
31
|
+
*
|
|
32
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
|
|
33
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
34
|
+
*/
|
|
35
|
+
export declare function hsvToRgb(h: number | string, s: number | string, v: number | string): Numberify<RGB>;
|
|
36
|
+
/**
|
|
37
|
+
* Converts an RGB color to hex
|
|
38
|
+
*
|
|
39
|
+
* Assumes r, g, and b are contained in the set [0, 255]
|
|
40
|
+
* Returns a 3 or 6 character hex
|
|
41
|
+
*/
|
|
42
|
+
export declare function rgbToHex(r: number, g: number, b: number, allow3Char: boolean): string;
|
|
43
|
+
/**
|
|
44
|
+
* Converts an RGBA color plus alpha transparency to hex
|
|
45
|
+
*
|
|
46
|
+
* Assumes r, g, b are contained in the set [0, 255] and
|
|
47
|
+
* a in [0, 1]. Returns a 4 or 8 character rgba hex
|
|
48
|
+
*/
|
|
49
|
+
export declare function rgbaToHex(r: number, g: number, b: number, a: number, allow4Char: boolean): string;
|
|
50
|
+
/**
|
|
51
|
+
* Converts an RGBA color to an ARGB Hex8 string
|
|
52
|
+
* Rarely used, but required for "toFilter()"
|
|
53
|
+
*/
|
|
54
|
+
export declare function rgbaToArgbHex(r: number, g: number, b: number, a: number): string;
|
|
55
|
+
/** Converts a decimal to a hex value */
|
|
56
|
+
export declare function convertDecimalToHex(d: string | number): string;
|
|
57
|
+
/** Converts a hex value to a decimal */
|
|
58
|
+
export declare function convertHexToDecimal(h: string): number;
|
|
59
|
+
/** Parse a base-16 hex value into a base-10 integer */
|
|
60
|
+
export declare function parseIntFromHex(val: string): number;
|
|
61
|
+
export declare function numberInputToObject(color: number): RGB;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.numberInputToObject = exports.parseIntFromHex = exports.convertHexToDecimal = exports.convertDecimalToHex = exports.rgbaToArgbHex = exports.rgbaToHex = exports.rgbToHex = exports.hsvToRgb = exports.rgbToHsv = exports.hslToRgb = exports.rgbToHsl = exports.rgbToRgb = void 0;
|
|
4
|
+
var util_js_1 = require("./util.js");
|
|
5
|
+
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
|
|
6
|
+
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
|
|
7
|
+
/**
|
|
8
|
+
* Handle bounds / percentage checking to conform to CSS color spec
|
|
9
|
+
* <http://www.w3.org/TR/css3-color/>
|
|
10
|
+
* *Assumes:* r, g, b in [0, 255] or [0, 1]
|
|
11
|
+
* *Returns:* { r, g, b } in [0, 255]
|
|
12
|
+
*/
|
|
13
|
+
function rgbToRgb(r, g, b) {
|
|
14
|
+
return {
|
|
15
|
+
r: (0, util_js_1.bound01)(r, 255) * 255,
|
|
16
|
+
g: (0, util_js_1.bound01)(g, 255) * 255,
|
|
17
|
+
b: (0, util_js_1.bound01)(b, 255) * 255,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.rgbToRgb = rgbToRgb;
|
|
21
|
+
/**
|
|
22
|
+
* Converts an RGB color value to HSL.
|
|
23
|
+
* *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
|
|
24
|
+
* *Returns:* { h, s, l } in [0,1]
|
|
25
|
+
*/
|
|
26
|
+
function rgbToHsl(r, g, b) {
|
|
27
|
+
r = (0, util_js_1.bound01)(r, 255);
|
|
28
|
+
g = (0, util_js_1.bound01)(g, 255);
|
|
29
|
+
b = (0, util_js_1.bound01)(b, 255);
|
|
30
|
+
var max = Math.max(r, g, b);
|
|
31
|
+
var min = Math.min(r, g, b);
|
|
32
|
+
var h = 0;
|
|
33
|
+
var s = 0;
|
|
34
|
+
var l = (max + min) / 2;
|
|
35
|
+
if (max === min) {
|
|
36
|
+
s = 0;
|
|
37
|
+
h = 0; // achromatic
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
var d = max - min;
|
|
41
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
42
|
+
switch (max) {
|
|
43
|
+
case r:
|
|
44
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
45
|
+
break;
|
|
46
|
+
case g:
|
|
47
|
+
h = (b - r) / d + 2;
|
|
48
|
+
break;
|
|
49
|
+
case b:
|
|
50
|
+
h = (r - g) / d + 4;
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
h /= 6;
|
|
56
|
+
}
|
|
57
|
+
return { h: h, s: s, l: l };
|
|
58
|
+
}
|
|
59
|
+
exports.rgbToHsl = rgbToHsl;
|
|
60
|
+
function hue2rgb(p, q, t) {
|
|
61
|
+
if (t < 0) {
|
|
62
|
+
t += 1;
|
|
63
|
+
}
|
|
64
|
+
if (t > 1) {
|
|
65
|
+
t -= 1;
|
|
66
|
+
}
|
|
67
|
+
if (t < 1 / 6) {
|
|
68
|
+
return p + (q - p) * (6 * t);
|
|
69
|
+
}
|
|
70
|
+
if (t < 1 / 2) {
|
|
71
|
+
return q;
|
|
72
|
+
}
|
|
73
|
+
if (t < 2 / 3) {
|
|
74
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
75
|
+
}
|
|
76
|
+
return p;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Converts an HSL color value to RGB.
|
|
80
|
+
*
|
|
81
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
|
|
82
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
83
|
+
*/
|
|
84
|
+
function hslToRgb(h, s, l) {
|
|
85
|
+
var r;
|
|
86
|
+
var g;
|
|
87
|
+
var b;
|
|
88
|
+
h = (0, util_js_1.bound01)(h, 360);
|
|
89
|
+
s = (0, util_js_1.bound01)(s, 100);
|
|
90
|
+
l = (0, util_js_1.bound01)(l, 100);
|
|
91
|
+
if (s === 0) {
|
|
92
|
+
// achromatic
|
|
93
|
+
g = l;
|
|
94
|
+
b = l;
|
|
95
|
+
r = l;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
99
|
+
var p = 2 * l - q;
|
|
100
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
101
|
+
g = hue2rgb(p, q, h);
|
|
102
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
103
|
+
}
|
|
104
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
105
|
+
}
|
|
106
|
+
exports.hslToRgb = hslToRgb;
|
|
107
|
+
/**
|
|
108
|
+
* Converts an RGB color value to HSV
|
|
109
|
+
*
|
|
110
|
+
* *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
|
|
111
|
+
* *Returns:* { h, s, v } in [0,1]
|
|
112
|
+
*/
|
|
113
|
+
function rgbToHsv(r, g, b) {
|
|
114
|
+
r = (0, util_js_1.bound01)(r, 255);
|
|
115
|
+
g = (0, util_js_1.bound01)(g, 255);
|
|
116
|
+
b = (0, util_js_1.bound01)(b, 255);
|
|
117
|
+
var max = Math.max(r, g, b);
|
|
118
|
+
var min = Math.min(r, g, b);
|
|
119
|
+
var h = 0;
|
|
120
|
+
var v = max;
|
|
121
|
+
var d = max - min;
|
|
122
|
+
var s = max === 0 ? 0 : d / max;
|
|
123
|
+
if (max === min) {
|
|
124
|
+
h = 0; // achromatic
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
switch (max) {
|
|
128
|
+
case r:
|
|
129
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
130
|
+
break;
|
|
131
|
+
case g:
|
|
132
|
+
h = (b - r) / d + 2;
|
|
133
|
+
break;
|
|
134
|
+
case b:
|
|
135
|
+
h = (r - g) / d + 4;
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
h /= 6;
|
|
141
|
+
}
|
|
142
|
+
return { h: h, s: s, v: v };
|
|
143
|
+
}
|
|
144
|
+
exports.rgbToHsv = rgbToHsv;
|
|
145
|
+
/**
|
|
146
|
+
* Converts an HSV color value to RGB.
|
|
147
|
+
*
|
|
148
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
|
|
149
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
150
|
+
*/
|
|
151
|
+
function hsvToRgb(h, s, v) {
|
|
152
|
+
h = (0, util_js_1.bound01)(h, 360) * 6;
|
|
153
|
+
s = (0, util_js_1.bound01)(s, 100);
|
|
154
|
+
v = (0, util_js_1.bound01)(v, 100);
|
|
155
|
+
var i = Math.floor(h);
|
|
156
|
+
var f = h - i;
|
|
157
|
+
var p = v * (1 - s);
|
|
158
|
+
var q = v * (1 - f * s);
|
|
159
|
+
var t = v * (1 - (1 - f) * s);
|
|
160
|
+
var mod = i % 6;
|
|
161
|
+
var r = [v, q, p, p, t, v][mod];
|
|
162
|
+
var g = [t, v, v, q, p, p][mod];
|
|
163
|
+
var b = [p, p, t, v, v, q][mod];
|
|
164
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
165
|
+
}
|
|
166
|
+
exports.hsvToRgb = hsvToRgb;
|
|
167
|
+
/**
|
|
168
|
+
* Converts an RGB color to hex
|
|
169
|
+
*
|
|
170
|
+
* Assumes r, g, and b are contained in the set [0, 255]
|
|
171
|
+
* Returns a 3 or 6 character hex
|
|
172
|
+
*/
|
|
173
|
+
function rgbToHex(r, g, b, allow3Char) {
|
|
174
|
+
var hex = [
|
|
175
|
+
(0, util_js_1.pad2)(Math.round(r).toString(16)),
|
|
176
|
+
(0, util_js_1.pad2)(Math.round(g).toString(16)),
|
|
177
|
+
(0, util_js_1.pad2)(Math.round(b).toString(16)),
|
|
178
|
+
];
|
|
179
|
+
// Return a 3 character hex if possible
|
|
180
|
+
if (allow3Char &&
|
|
181
|
+
hex[0].startsWith(hex[0].charAt(1)) &&
|
|
182
|
+
hex[1].startsWith(hex[1].charAt(1)) &&
|
|
183
|
+
hex[2].startsWith(hex[2].charAt(1))) {
|
|
184
|
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
185
|
+
}
|
|
186
|
+
return hex.join('');
|
|
187
|
+
}
|
|
188
|
+
exports.rgbToHex = rgbToHex;
|
|
189
|
+
/**
|
|
190
|
+
* Converts an RGBA color plus alpha transparency to hex
|
|
191
|
+
*
|
|
192
|
+
* Assumes r, g, b are contained in the set [0, 255] and
|
|
193
|
+
* a in [0, 1]. Returns a 4 or 8 character rgba hex
|
|
194
|
+
*/
|
|
195
|
+
// eslint-disable-next-line max-params
|
|
196
|
+
function rgbaToHex(r, g, b, a, allow4Char) {
|
|
197
|
+
var hex = [
|
|
198
|
+
(0, util_js_1.pad2)(Math.round(r).toString(16)),
|
|
199
|
+
(0, util_js_1.pad2)(Math.round(g).toString(16)),
|
|
200
|
+
(0, util_js_1.pad2)(Math.round(b).toString(16)),
|
|
201
|
+
(0, util_js_1.pad2)(convertDecimalToHex(a)),
|
|
202
|
+
];
|
|
203
|
+
// Return a 4 character hex if possible
|
|
204
|
+
if (allow4Char &&
|
|
205
|
+
hex[0].startsWith(hex[0].charAt(1)) &&
|
|
206
|
+
hex[1].startsWith(hex[1].charAt(1)) &&
|
|
207
|
+
hex[2].startsWith(hex[2].charAt(1)) &&
|
|
208
|
+
hex[3].startsWith(hex[3].charAt(1))) {
|
|
209
|
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
|
|
210
|
+
}
|
|
211
|
+
return hex.join('');
|
|
212
|
+
}
|
|
213
|
+
exports.rgbaToHex = rgbaToHex;
|
|
214
|
+
/**
|
|
215
|
+
* Converts an RGBA color to an ARGB Hex8 string
|
|
216
|
+
* Rarely used, but required for "toFilter()"
|
|
217
|
+
*/
|
|
218
|
+
function rgbaToArgbHex(r, g, b, a) {
|
|
219
|
+
var hex = [
|
|
220
|
+
(0, util_js_1.pad2)(convertDecimalToHex(a)),
|
|
221
|
+
(0, util_js_1.pad2)(Math.round(r).toString(16)),
|
|
222
|
+
(0, util_js_1.pad2)(Math.round(g).toString(16)),
|
|
223
|
+
(0, util_js_1.pad2)(Math.round(b).toString(16)),
|
|
224
|
+
];
|
|
225
|
+
return hex.join('');
|
|
226
|
+
}
|
|
227
|
+
exports.rgbaToArgbHex = rgbaToArgbHex;
|
|
228
|
+
/** Converts a decimal to a hex value */
|
|
229
|
+
function convertDecimalToHex(d) {
|
|
230
|
+
return Math.round(parseFloat(d) * 255).toString(16);
|
|
231
|
+
}
|
|
232
|
+
exports.convertDecimalToHex = convertDecimalToHex;
|
|
233
|
+
/** Converts a hex value to a decimal */
|
|
234
|
+
function convertHexToDecimal(h) {
|
|
235
|
+
return parseIntFromHex(h) / 255;
|
|
236
|
+
}
|
|
237
|
+
exports.convertHexToDecimal = convertHexToDecimal;
|
|
238
|
+
/** Parse a base-16 hex value into a base-10 integer */
|
|
239
|
+
function parseIntFromHex(val) {
|
|
240
|
+
return parseInt(val, 16);
|
|
241
|
+
}
|
|
242
|
+
exports.parseIntFromHex = parseIntFromHex;
|
|
243
|
+
function numberInputToObject(color) {
|
|
244
|
+
return {
|
|
245
|
+
r: color >> 16,
|
|
246
|
+
g: (color & 0xff00) >> 8,
|
|
247
|
+
b: color & 0xff,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
exports.numberInputToObject = numberInputToObject;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.names = void 0;
|
|
4
|
+
// https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
*/
|
|
8
|
+
exports.names = {
|
|
9
|
+
aliceblue: '#f0f8ff',
|
|
10
|
+
antiquewhite: '#faebd7',
|
|
11
|
+
aqua: '#00ffff',
|
|
12
|
+
aquamarine: '#7fffd4',
|
|
13
|
+
azure: '#f0ffff',
|
|
14
|
+
beige: '#f5f5dc',
|
|
15
|
+
bisque: '#ffe4c4',
|
|
16
|
+
black: '#000000',
|
|
17
|
+
blanchedalmond: '#ffebcd',
|
|
18
|
+
blue: '#0000ff',
|
|
19
|
+
blueviolet: '#8a2be2',
|
|
20
|
+
brown: '#a52a2a',
|
|
21
|
+
burlywood: '#deb887',
|
|
22
|
+
cadetblue: '#5f9ea0',
|
|
23
|
+
chartreuse: '#7fff00',
|
|
24
|
+
chocolate: '#d2691e',
|
|
25
|
+
coral: '#ff7f50',
|
|
26
|
+
cornflowerblue: '#6495ed',
|
|
27
|
+
cornsilk: '#fff8dc',
|
|
28
|
+
crimson: '#dc143c',
|
|
29
|
+
cyan: '#00ffff',
|
|
30
|
+
darkblue: '#00008b',
|
|
31
|
+
darkcyan: '#008b8b',
|
|
32
|
+
darkgoldenrod: '#b8860b',
|
|
33
|
+
darkgray: '#a9a9a9',
|
|
34
|
+
darkgreen: '#006400',
|
|
35
|
+
darkgrey: '#a9a9a9',
|
|
36
|
+
darkkhaki: '#bdb76b',
|
|
37
|
+
darkmagenta: '#8b008b',
|
|
38
|
+
darkolivegreen: '#556b2f',
|
|
39
|
+
darkorange: '#ff8c00',
|
|
40
|
+
darkorchid: '#9932cc',
|
|
41
|
+
darkred: '#8b0000',
|
|
42
|
+
darksalmon: '#e9967a',
|
|
43
|
+
darkseagreen: '#8fbc8f',
|
|
44
|
+
darkslateblue: '#483d8b',
|
|
45
|
+
darkslategray: '#2f4f4f',
|
|
46
|
+
darkslategrey: '#2f4f4f',
|
|
47
|
+
darkturquoise: '#00ced1',
|
|
48
|
+
darkviolet: '#9400d3',
|
|
49
|
+
deeppink: '#ff1493',
|
|
50
|
+
deepskyblue: '#00bfff',
|
|
51
|
+
dimgray: '#696969',
|
|
52
|
+
dimgrey: '#696969',
|
|
53
|
+
dodgerblue: '#1e90ff',
|
|
54
|
+
firebrick: '#b22222',
|
|
55
|
+
floralwhite: '#fffaf0',
|
|
56
|
+
forestgreen: '#228b22',
|
|
57
|
+
fuchsia: '#ff00ff',
|
|
58
|
+
gainsboro: '#dcdcdc',
|
|
59
|
+
ghostwhite: '#f8f8ff',
|
|
60
|
+
goldenrod: '#daa520',
|
|
61
|
+
gold: '#ffd700',
|
|
62
|
+
gray: '#808080',
|
|
63
|
+
green: '#008000',
|
|
64
|
+
greenyellow: '#adff2f',
|
|
65
|
+
grey: '#808080',
|
|
66
|
+
honeydew: '#f0fff0',
|
|
67
|
+
hotpink: '#ff69b4',
|
|
68
|
+
indianred: '#cd5c5c',
|
|
69
|
+
indigo: '#4b0082',
|
|
70
|
+
ivory: '#fffff0',
|
|
71
|
+
khaki: '#f0e68c',
|
|
72
|
+
lavenderblush: '#fff0f5',
|
|
73
|
+
lavender: '#e6e6fa',
|
|
74
|
+
lawngreen: '#7cfc00',
|
|
75
|
+
lemonchiffon: '#fffacd',
|
|
76
|
+
lightblue: '#add8e6',
|
|
77
|
+
lightcoral: '#f08080',
|
|
78
|
+
lightcyan: '#e0ffff',
|
|
79
|
+
lightgoldenrodyellow: '#fafad2',
|
|
80
|
+
lightgray: '#d3d3d3',
|
|
81
|
+
lightgreen: '#90ee90',
|
|
82
|
+
lightgrey: '#d3d3d3',
|
|
83
|
+
lightpink: '#ffb6c1',
|
|
84
|
+
lightsalmon: '#ffa07a',
|
|
85
|
+
lightseagreen: '#20b2aa',
|
|
86
|
+
lightskyblue: '#87cefa',
|
|
87
|
+
lightslategray: '#778899',
|
|
88
|
+
lightslategrey: '#778899',
|
|
89
|
+
lightsteelblue: '#b0c4de',
|
|
90
|
+
lightyellow: '#ffffe0',
|
|
91
|
+
lime: '#00ff00',
|
|
92
|
+
limegreen: '#32cd32',
|
|
93
|
+
linen: '#faf0e6',
|
|
94
|
+
magenta: '#ff00ff',
|
|
95
|
+
maroon: '#800000',
|
|
96
|
+
mediumaquamarine: '#66cdaa',
|
|
97
|
+
mediumblue: '#0000cd',
|
|
98
|
+
mediumorchid: '#ba55d3',
|
|
99
|
+
mediumpurple: '#9370db',
|
|
100
|
+
mediumseagreen: '#3cb371',
|
|
101
|
+
mediumslateblue: '#7b68ee',
|
|
102
|
+
mediumspringgreen: '#00fa9a',
|
|
103
|
+
mediumturquoise: '#48d1cc',
|
|
104
|
+
mediumvioletred: '#c71585',
|
|
105
|
+
midnightblue: '#191970',
|
|
106
|
+
mintcream: '#f5fffa',
|
|
107
|
+
mistyrose: '#ffe4e1',
|
|
108
|
+
moccasin: '#ffe4b5',
|
|
109
|
+
navajowhite: '#ffdead',
|
|
110
|
+
navy: '#000080',
|
|
111
|
+
oldlace: '#fdf5e6',
|
|
112
|
+
olive: '#808000',
|
|
113
|
+
olivedrab: '#6b8e23',
|
|
114
|
+
orange: '#ffa500',
|
|
115
|
+
orangered: '#ff4500',
|
|
116
|
+
orchid: '#da70d6',
|
|
117
|
+
palegoldenrod: '#eee8aa',
|
|
118
|
+
palegreen: '#98fb98',
|
|
119
|
+
paleturquoise: '#afeeee',
|
|
120
|
+
palevioletred: '#db7093',
|
|
121
|
+
papayawhip: '#ffefd5',
|
|
122
|
+
peachpuff: '#ffdab9',
|
|
123
|
+
peru: '#cd853f',
|
|
124
|
+
pink: '#ffc0cb',
|
|
125
|
+
plum: '#dda0dd',
|
|
126
|
+
powderblue: '#b0e0e6',
|
|
127
|
+
purple: '#800080',
|
|
128
|
+
rebeccapurple: '#663399',
|
|
129
|
+
red: '#ff0000',
|
|
130
|
+
rosybrown: '#bc8f8f',
|
|
131
|
+
royalblue: '#4169e1',
|
|
132
|
+
saddlebrown: '#8b4513',
|
|
133
|
+
salmon: '#fa8072',
|
|
134
|
+
sandybrown: '#f4a460',
|
|
135
|
+
seagreen: '#2e8b57',
|
|
136
|
+
seashell: '#fff5ee',
|
|
137
|
+
sienna: '#a0522d',
|
|
138
|
+
silver: '#c0c0c0',
|
|
139
|
+
skyblue: '#87ceeb',
|
|
140
|
+
slateblue: '#6a5acd',
|
|
141
|
+
slategray: '#708090',
|
|
142
|
+
slategrey: '#708090',
|
|
143
|
+
snow: '#fffafa',
|
|
144
|
+
springgreen: '#00ff7f',
|
|
145
|
+
steelblue: '#4682b4',
|
|
146
|
+
tan: '#d2b48c',
|
|
147
|
+
teal: '#008080',
|
|
148
|
+
thistle: '#d8bfd8',
|
|
149
|
+
tomato: '#ff6347',
|
|
150
|
+
turquoise: '#40e0d0',
|
|
151
|
+
violet: '#ee82ee',
|
|
152
|
+
wheat: '#f5deb3',
|
|
153
|
+
white: '#ffffff',
|
|
154
|
+
whitesmoke: '#f5f5f5',
|
|
155
|
+
yellow: '#ffff00',
|
|
156
|
+
yellowgreen: '#9acd32',
|
|
157
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { HSL, HSLA, HSV, HSVA, RGB, RGBA } from './interfaces.js';
|
|
2
|
+
/**
|
|
3
|
+
* Given a string or object, convert that input to RGB
|
|
4
|
+
*
|
|
5
|
+
* Possible string inputs:
|
|
6
|
+
* ```
|
|
7
|
+
* "red"
|
|
8
|
+
* "#f00" or "f00"
|
|
9
|
+
* "#ff0000" or "ff0000"
|
|
10
|
+
* "#ff000000" or "ff000000"
|
|
11
|
+
* "rgb 255 0 0" or "rgb (255, 0, 0)"
|
|
12
|
+
* "rgb 1.0 0 0" or "rgb (1, 0, 0)"
|
|
13
|
+
* "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
|
|
14
|
+
* "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
|
|
15
|
+
* "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
|
|
16
|
+
* "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
|
|
17
|
+
* "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function inputToRGB(color: string | RGB | RGBA | HSL | HSLA | HSV | HSVA | any): {
|
|
21
|
+
ok: boolean;
|
|
22
|
+
format: any;
|
|
23
|
+
r: number;
|
|
24
|
+
g: number;
|
|
25
|
+
b: number;
|
|
26
|
+
a: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Permissive string parsing. Take in a number of formats, and output an object
|
|
30
|
+
* based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
|
|
31
|
+
*/
|
|
32
|
+
export declare function stringInputToObject(color: string): any;
|
|
33
|
+
/**
|
|
34
|
+
* Check to see if it looks like a CSS unit
|
|
35
|
+
* (see `matchers` above for definition).
|
|
36
|
+
*/
|
|
37
|
+
export declare function isValidCSSUnit(color: string | number): boolean;
|