@para-ui/core 4.0.0-beta → 4.0.0-rc.1

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 (270) hide show
  1. package/AutoBox/index.d.ts +1 -1
  2. package/AutoBox/index.js +12 -12
  3. package/AutoTips/autoTipsMultiline/index.d.ts +1 -1
  4. package/AutoTips/index.d.ts +2 -2
  5. package/AutoTips/index.js +17 -17
  6. package/Badge/index.d.ts +23 -0
  7. package/Badge/index.js +54 -0
  8. package/Breadcrumbs/index.js +8 -8
  9. package/Button/SplitButton.d.ts +1 -1
  10. package/Button/index.d.ts +1 -1
  11. package/Button/index.js +4 -4
  12. package/Carousel/index.d.ts +6 -6
  13. package/Carousel/index.js +5 -5
  14. package/Cascader/Cascader.d.ts +10 -10
  15. package/Cascader/OptionList/Column.d.ts +3 -3
  16. package/Cascader/OptionList/index.d.ts +2 -2
  17. package/Cascader/index.d.ts +1 -1
  18. package/Cascader/index.js +5 -3
  19. package/Cascader/lang/en_US.d.ts +5 -0
  20. package/Cascader/lang/index.d.ts +11 -0
  21. package/Cascader/lang/zh_CN.d.ts +5 -0
  22. package/Cascader/utils/treeUtil.d.ts +1 -1
  23. package/Checkbox/index.d.ts +1 -1
  24. package/Checkbox/index.js +5 -5
  25. package/CheckboxGroup/index.d.ts +2 -2
  26. package/CheckboxGroup/index.js +3 -3
  27. package/Collapse/index.js +4 -4
  28. package/CollapseBox/index.js +12 -20
  29. package/CollapseLayout/index.js +20 -20
  30. package/ColorPicker/index.js +2 -2
  31. package/ComboSelect/index.js +53 -63
  32. package/ComboSelect/interface.d.ts +3 -3
  33. package/ComboSelect/utils.d.ts +5 -0
  34. package/Container/index.d.ts +3 -3
  35. package/Container/index.js +56 -56
  36. package/CopyText/index.d.ts +2 -2
  37. package/CopyText/index.js +2 -2
  38. package/DatePicker/generatePicker/index.d.ts +22 -22
  39. package/DatePicker/index.js +10 -8
  40. package/DatePicker/util.d.ts +1 -1
  41. package/Desktop/index.d.ts +1 -1
  42. package/Desktop/index.js +19 -14
  43. package/DragVerify/index.d.ts +1 -1
  44. package/DragVerify/index.js +15 -15
  45. package/Drawer/index.d.ts +2 -2
  46. package/Drawer/index.js +118 -17
  47. package/Drawer/interface.d.ts +10 -2
  48. package/Drawer/util.d.ts +6 -0
  49. package/Dropdown/index.d.ts +1 -1
  50. package/DynamicMultiBox/formItem.d.ts +1 -1
  51. package/DynamicMultiBox/index.d.ts +7 -2
  52. package/DynamicMultiBox/index.js +42 -39
  53. package/DynamicMultiBox/interface.d.ts +8 -8
  54. package/DynamicMultiBox/rowForm.d.ts +3 -1
  55. package/Empty/index.d.ts +1 -1
  56. package/Empty/index.js +2 -2
  57. package/Form/index.d.ts +12 -13
  58. package/Form/index.js +14 -12
  59. package/FormItem/compoments/defaultCompoments/index.d.ts +4 -4
  60. package/FormItem/compoments/formCheckboxGroup/index.d.ts +1 -1
  61. package/FormItem/compoments/formFile/index.d.ts +2 -2
  62. package/FormItem/compoments/formRadioGroup/index.d.ts +1 -1
  63. package/FormItem/compoments/formSelect/index.d.ts +7 -7
  64. package/FormItem/errorTips.d.ts +3 -3
  65. package/FormItem/index.d.ts +5 -5
  66. package/FormItem/index.js +7 -6
  67. package/FormItem/lang/en_US.d.ts +10 -0
  68. package/FormItem/lang/index.d.ts +21 -0
  69. package/FormItem/lang/zh_CN.d.ts +10 -0
  70. package/FormItem/validateFunction.d.ts +1 -1
  71. package/FunctionModal/dialog.d.ts +26 -26
  72. package/FunctionModal/index.d.ts +6 -6
  73. package/FunctionModal/index.js +9 -9
  74. package/FunctionModal/modalContext.d.ts +3 -3
  75. package/GlobalContext/componentsProps.d.ts +7 -7
  76. package/GlobalContext/index.d.ts +2 -2
  77. package/GlobalContext/index.js +1 -1
  78. package/GlobalContext/useFormatMessage.d.ts +1 -1
  79. package/Help/index.js +2 -2
  80. package/HelperText/index.js +1 -1
  81. package/InputLang/index.d.ts +2 -2
  82. package/InputLang/index.js +8 -8
  83. package/InputNumber/index.d.ts +2 -2
  84. package/InputNumber/index.js +4 -4
  85. package/Label/index.js +2 -2
  86. package/Loading/index.js +1 -1
  87. package/Menu/index.js +14 -14
  88. package/Menu/interface.d.ts +1 -1
  89. package/Message/index.js +12 -12
  90. package/Modal/Confirm/index.d.ts +3 -3
  91. package/Modal/index.d.ts +1 -1
  92. package/Modal/index.js +7 -7
  93. package/MultiBox/index.d.ts +2 -2
  94. package/MultiBox/index.js +11 -7
  95. package/Notification/index.js +2 -2
  96. package/OperateBtn/index.d.ts +2 -2
  97. package/OperateBtn/index.js +42 -37
  98. package/PageHeader/index.js +31 -31
  99. package/PageHeader/interface.d.ts +1 -1
  100. package/Pagination/index.d.ts +1 -1
  101. package/Pagination/index.js +17 -17
  102. package/ParauiProvider/index.js +1 -1
  103. package/PasswordRules/index.js +8 -8
  104. package/PopConfirm/index.js +4 -4
  105. package/Progress/Line.d.ts +10 -10
  106. package/Progress/Steps.d.ts +2 -2
  107. package/Progress/index.d.ts +12 -12
  108. package/Progress/index.js +40 -40
  109. package/Progress/utils.d.ts +4 -4
  110. package/Querying/index.d.ts +1 -1
  111. package/Querying/index.js +2 -2
  112. package/README.md +3 -0
  113. package/Radio/index.d.ts +1 -1
  114. package/Radio/index.js +5 -5
  115. package/RadioGroup/index.d.ts +2 -2
  116. package/RadioGroup/index.js +3 -3
  117. package/Search/index.js +2 -2
  118. package/Select/index.d.ts +3 -3
  119. package/Select/index.js +43 -43
  120. package/SelectInput/index.js +2 -2
  121. package/Selector/index.js +19 -19
  122. package/Selector/interface.d.ts +6 -6
  123. package/SelectorPicker/index.d.ts +4 -4
  124. package/SelectorPicker/index.js +12 -12
  125. package/SingleBox/index.d.ts +2 -2
  126. package/SingleBox/index.js +3 -3
  127. package/Slider/interface.d.ts +1 -1
  128. package/Status/index.d.ts +6 -4
  129. package/Status/index.js +21 -9
  130. package/Stepper/index.d.ts +5 -5
  131. package/Stepper/index.js +24 -24
  132. package/Styles/scrollbar.scss +66 -66
  133. package/Styles/theme.scss +62 -61
  134. package/Switch/index.d.ts +7 -7
  135. package/Switch/index.js +24 -6
  136. package/Switch/lang/en_US.d.ts +4 -0
  137. package/Switch/lang/index.d.ts +9 -0
  138. package/Switch/lang/zh_CN.d.ts +4 -0
  139. package/Table/index.js +36 -36
  140. package/Table/interface.d.ts +4 -4
  141. package/Table/tableBodyElement/index.d.ts +1 -1
  142. package/Table/tableBodyInterface.d.ts +2 -2
  143. package/Table/tableContainer/index.d.ts +1 -1
  144. package/Table/tableElement/index.d.ts +1 -1
  145. package/Table/tableHeadElement/index.d.ts +1 -1
  146. package/Table/tableHeadInterface.d.ts +1 -1
  147. package/Table/tablePaginationInterface.d.ts +6 -6
  148. package/Table/tdElement/index.d.ts +1 -1
  149. package/Table/thElement/index.d.ts +2 -2
  150. package/Table/trElement/index.d.ts +1 -1
  151. package/Table/util.d.ts +1 -1
  152. package/Tabs/index.d.ts +1 -1
  153. package/Tabs/index.js +26 -18
  154. package/Tag/TagGroup.d.ts +5 -5
  155. package/Tag/index.d.ts +7 -7
  156. package/Tag/index.js +33 -1207
  157. package/TextEditor/index.d.ts +2 -2
  158. package/TextEditor/index.js +45 -27
  159. package/TextEditor/lang/en_US.d.ts +4 -0
  160. package/TextEditor/lang/index.d.ts +9 -0
  161. package/TextEditor/lang/zh_CN.d.ts +4 -0
  162. package/TextField/index.d.ts +1 -1
  163. package/TextField/index.js +13 -13
  164. package/TimePicker/index.d.ts +1 -1
  165. package/TimePicker/index.js +2 -1
  166. package/Timeline/TimelineItem.d.ts +1 -1
  167. package/Timeline/index.d.ts +5 -5
  168. package/Timeline/index.js +14 -14
  169. package/Title/index.d.ts +6 -4
  170. package/Title/index.js +9 -5
  171. package/ToggleButton/ToggleButtonGroup.d.ts +1 -1
  172. package/ToggleButton/index.d.ts +5 -1
  173. package/ToggleButton/index.js +17 -10
  174. package/Tooltip/index.js +1 -1
  175. package/Transfer/box.d.ts +6 -6
  176. package/Transfer/index.js +27 -27
  177. package/Tree/OperateBar/index.d.ts +2 -2
  178. package/Tree/Tree.d.ts +2 -2
  179. package/Tree/index.js +4 -4
  180. package/Tree/interface.d.ts +8 -4
  181. package/Tree/utils/tools.d.ts +1 -1
  182. package/Upload/Dragger/index.d.ts +2 -2
  183. package/Upload/ErroTip/index.d.ts +1 -1
  184. package/Upload/index.d.ts +2 -2
  185. package/Upload/index.js +13 -13
  186. package/Upload/interface.d.ts +1 -1
  187. package/_verture/{index-5c77417d.js → index-0f315bca.js} +4 -4
  188. package/_verture/{index-e2881a53.js → index-19947788.js} +2 -2
  189. package/_verture/{index-d63bd287.js → index-232d890b.js} +1 -1
  190. package/_verture/{index-68db2bc3.js → index-92e406f4.js} +50 -26
  191. package/_verture/{index-7ec72724.js → index-bc461491.js} +45 -38
  192. package/_verture/{index-e6f85fd5.js → index-d251967e.js} +104 -47
  193. package/_verture/{modalContext-c12ca3e8.js → modalContext-9299acc9.js} +26 -26
  194. package/_verture/tinycolor-ece3542d.js +1180 -0
  195. package/_verture/{utils-f0e81540.js → utils-06d86594.js} +3 -6
  196. package/index.d.ts +2 -0
  197. package/index.js +14 -13
  198. package/locale/en-US.d.ts +19 -0
  199. package/locale/index.d.ts +38 -0
  200. package/locale/index.js +41 -3
  201. package/locale/zh-CN.d.ts +19 -0
  202. package/package.json +53 -8
  203. package/umd/AutoBox.js +2 -2
  204. package/umd/AutoTips.js +4 -4
  205. package/umd/Badge.js +1 -0
  206. package/umd/Breadcrumbs.js +2 -2
  207. package/umd/Button.js +2 -2
  208. package/umd/ButtonGroup.js +4 -4
  209. package/umd/Cascader.js +4 -4
  210. package/umd/Checkbox.js +5 -5
  211. package/umd/CheckboxGroup.js +5 -5
  212. package/umd/Collapse.js +1 -1
  213. package/umd/CollapseBox.js +1 -1
  214. package/umd/CollapseLayout.js +4 -4
  215. package/umd/ColorPicker.js +1 -1
  216. package/umd/ComboSelect.js +6 -6
  217. package/umd/CopyText.js +2 -2
  218. package/umd/DatePicker.js +2 -2
  219. package/umd/Desktop.js +2 -2
  220. package/umd/DragVerify.js +4 -4
  221. package/umd/Drawer.js +4 -4
  222. package/umd/DynamicMultiBox.js +4 -4
  223. package/umd/Form.js +4 -4
  224. package/umd/FormItem.js +4 -4
  225. package/umd/FunctionModal.js +2 -2
  226. package/umd/GlobalContext.js +1 -1
  227. package/umd/Help.js +2 -2
  228. package/umd/HelperText.js +1 -1
  229. package/umd/InputLang.js +4 -4
  230. package/umd/InputNumber.js +2 -2
  231. package/umd/Label.js +2 -2
  232. package/umd/Loading.js +1 -1
  233. package/umd/Menu.js +2 -2
  234. package/umd/Message.js +1 -1
  235. package/umd/Modal.js +2 -2
  236. package/umd/MultiBox.js +7 -7
  237. package/umd/Notification.js +2 -2
  238. package/umd/OperateBtn.js +2 -2
  239. package/umd/PageHeader.js +2 -2
  240. package/umd/Pagination.js +4 -4
  241. package/umd/ParauiProvider.js +1 -1
  242. package/umd/PasswordRules.js +3 -3
  243. package/umd/PopConfirm.js +2 -2
  244. package/umd/Popover.js +1 -1
  245. package/umd/Progress.js +1 -1
  246. package/umd/Radio.js +2 -2
  247. package/umd/RadioGroup.js +2 -2
  248. package/umd/Search.js +7 -7
  249. package/umd/Select.js +2 -2
  250. package/umd/SelectInput.js +2 -2
  251. package/umd/Selector.js +2 -2
  252. package/umd/SelectorPicker.js +2 -2
  253. package/umd/SingleBox.js +2 -2
  254. package/umd/Status.js +4 -4
  255. package/umd/Stepper.js +2 -2
  256. package/umd/Switch.js +5 -5
  257. package/umd/Table.js +6 -6
  258. package/umd/Tabs.js +4 -4
  259. package/umd/Tag.js +2 -2
  260. package/umd/TextEditor.js +3 -3
  261. package/umd/TextField.js +7 -7
  262. package/umd/TimePicker.js +2 -2
  263. package/umd/Title.js +2 -2
  264. package/umd/ToggleButton.js +4 -4
  265. package/umd/Tooltip.js +1 -1
  266. package/umd/Transfer.js +5 -5
  267. package/umd/Tree.js +7 -7
  268. package/umd/Upload.js +2 -2
  269. package/umd/locale.js +1 -1
  270. /package/_verture/{typeof-b240b062.js → typeof-c310ee4a.js} +0 -0
@@ -0,0 +1,1180 @@
1
+ // This file is autogenerated. It's used to publish ESM to npm.
2
+ function _typeof(obj) {
3
+ "@babel/helpers - typeof";
4
+
5
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
6
+ return typeof obj;
7
+ } : function (obj) {
8
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
9
+ }, _typeof(obj);
10
+ }
11
+
12
+ // https://github.com/bgrins/TinyColor
13
+ // Brian Grinstead, MIT License
14
+
15
+ var trimLeft = /^\s+/;
16
+ var trimRight = /\s+$/;
17
+ function tinycolor(color, opts) {
18
+ color = color ? color : "";
19
+ opts = opts || {};
20
+
21
+ // If input is already a tinycolor, return itself
22
+ if (color instanceof tinycolor) {
23
+ return color;
24
+ }
25
+ // If we are called as a function, call using new instead
26
+ if (!(this instanceof tinycolor)) {
27
+ return new tinycolor(color, opts);
28
+ }
29
+ var rgb = inputToRGB(color);
30
+ this._originalInput = color, this._r = rgb.r, this._g = rgb.g, this._b = rgb.b, this._a = rgb.a, this._roundA = Math.round(100 * this._a) / 100, this._format = opts.format || rgb.format;
31
+ this._gradientType = opts.gradientType;
32
+
33
+ // Don't let the range of [0,255] come back in [0,1].
34
+ // Potentially lose a little bit of precision here, but will fix issues where
35
+ // .5 gets interpreted as half of the total, instead of half of 1
36
+ // If it was supposed to be 128, this was already taken care of by `inputToRgb`
37
+ if (this._r < 1) this._r = Math.round(this._r);
38
+ if (this._g < 1) this._g = Math.round(this._g);
39
+ if (this._b < 1) this._b = Math.round(this._b);
40
+ this._ok = rgb.ok;
41
+ }
42
+ tinycolor.prototype = {
43
+ isDark: function isDark() {
44
+ return this.getBrightness() < 128;
45
+ },
46
+ isLight: function isLight() {
47
+ return !this.isDark();
48
+ },
49
+ isValid: function isValid() {
50
+ return this._ok;
51
+ },
52
+ getOriginalInput: function getOriginalInput() {
53
+ return this._originalInput;
54
+ },
55
+ getFormat: function getFormat() {
56
+ return this._format;
57
+ },
58
+ getAlpha: function getAlpha() {
59
+ return this._a;
60
+ },
61
+ getBrightness: function getBrightness() {
62
+ //http://www.w3.org/TR/AERT#color-contrast
63
+ var rgb = this.toRgb();
64
+ return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
65
+ },
66
+ getLuminance: function getLuminance() {
67
+ //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
68
+ var rgb = this.toRgb();
69
+ var RsRGB, GsRGB, BsRGB, R, G, B;
70
+ RsRGB = rgb.r / 255;
71
+ GsRGB = rgb.g / 255;
72
+ BsRGB = rgb.b / 255;
73
+ if (RsRGB <= 0.03928) R = RsRGB / 12.92;else R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
74
+ if (GsRGB <= 0.03928) G = GsRGB / 12.92;else G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
75
+ if (BsRGB <= 0.03928) B = BsRGB / 12.92;else B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
76
+ return 0.2126 * R + 0.7152 * G + 0.0722 * B;
77
+ },
78
+ setAlpha: function setAlpha(value) {
79
+ this._a = boundAlpha(value);
80
+ this._roundA = Math.round(100 * this._a) / 100;
81
+ return this;
82
+ },
83
+ toHsv: function toHsv() {
84
+ var hsv = rgbToHsv(this._r, this._g, this._b);
85
+ return {
86
+ h: hsv.h * 360,
87
+ s: hsv.s,
88
+ v: hsv.v,
89
+ a: this._a
90
+ };
91
+ },
92
+ toHsvString: function toHsvString() {
93
+ var hsv = rgbToHsv(this._r, this._g, this._b);
94
+ var h = Math.round(hsv.h * 360),
95
+ s = Math.round(hsv.s * 100),
96
+ v = Math.round(hsv.v * 100);
97
+ return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
98
+ },
99
+ toHsl: function toHsl() {
100
+ var hsl = rgbToHsl(this._r, this._g, this._b);
101
+ return {
102
+ h: hsl.h * 360,
103
+ s: hsl.s,
104
+ l: hsl.l,
105
+ a: this._a
106
+ };
107
+ },
108
+ toHslString: function toHslString() {
109
+ var hsl = rgbToHsl(this._r, this._g, this._b);
110
+ var h = Math.round(hsl.h * 360),
111
+ s = Math.round(hsl.s * 100),
112
+ l = Math.round(hsl.l * 100);
113
+ return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
114
+ },
115
+ toHex: function toHex(allow3Char) {
116
+ return rgbToHex(this._r, this._g, this._b, allow3Char);
117
+ },
118
+ toHexString: function toHexString(allow3Char) {
119
+ return "#" + this.toHex(allow3Char);
120
+ },
121
+ toHex8: function toHex8(allow4Char) {
122
+ return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
123
+ },
124
+ toHex8String: function toHex8String(allow4Char) {
125
+ return "#" + this.toHex8(allow4Char);
126
+ },
127
+ toRgb: function toRgb() {
128
+ return {
129
+ r: Math.round(this._r),
130
+ g: Math.round(this._g),
131
+ b: Math.round(this._b),
132
+ a: this._a
133
+ };
134
+ },
135
+ toRgbString: function toRgbString() {
136
+ return this._a == 1 ? "rgb(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ")" : "rgba(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ", " + this._roundA + ")";
137
+ },
138
+ toPercentageRgb: function toPercentageRgb() {
139
+ return {
140
+ r: Math.round(bound01(this._r, 255) * 100) + "%",
141
+ g: Math.round(bound01(this._g, 255) * 100) + "%",
142
+ b: Math.round(bound01(this._b, 255) * 100) + "%",
143
+ a: this._a
144
+ };
145
+ },
146
+ toPercentageRgbString: function toPercentageRgbString() {
147
+ return this._a == 1 ? "rgb(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
148
+ },
149
+ toName: function toName() {
150
+ if (this._a === 0) {
151
+ return "transparent";
152
+ }
153
+ if (this._a < 1) {
154
+ return false;
155
+ }
156
+ return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
157
+ },
158
+ toFilter: function toFilter(secondColor) {
159
+ var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
160
+ var secondHex8String = hex8String;
161
+ var gradientType = this._gradientType ? "GradientType = 1, " : "";
162
+ if (secondColor) {
163
+ var s = tinycolor(secondColor);
164
+ secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
165
+ }
166
+ return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")";
167
+ },
168
+ toString: function toString(format) {
169
+ var formatSet = !!format;
170
+ format = format || this._format;
171
+ var formattedString = false;
172
+ var hasAlpha = this._a < 1 && this._a >= 0;
173
+ var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
174
+ if (needsAlphaFormat) {
175
+ // Special case for "transparent", all other non-alpha formats
176
+ // will return rgba when there is transparency.
177
+ if (format === "name" && this._a === 0) {
178
+ return this.toName();
179
+ }
180
+ return this.toRgbString();
181
+ }
182
+ if (format === "rgb") {
183
+ formattedString = this.toRgbString();
184
+ }
185
+ if (format === "prgb") {
186
+ formattedString = this.toPercentageRgbString();
187
+ }
188
+ if (format === "hex" || format === "hex6") {
189
+ formattedString = this.toHexString();
190
+ }
191
+ if (format === "hex3") {
192
+ formattedString = this.toHexString(true);
193
+ }
194
+ if (format === "hex4") {
195
+ formattedString = this.toHex8String(true);
196
+ }
197
+ if (format === "hex8") {
198
+ formattedString = this.toHex8String();
199
+ }
200
+ if (format === "name") {
201
+ formattedString = this.toName();
202
+ }
203
+ if (format === "hsl") {
204
+ formattedString = this.toHslString();
205
+ }
206
+ if (format === "hsv") {
207
+ formattedString = this.toHsvString();
208
+ }
209
+ return formattedString || this.toHexString();
210
+ },
211
+ clone: function clone() {
212
+ return tinycolor(this.toString());
213
+ },
214
+ _applyModification: function _applyModification(fn, args) {
215
+ var color = fn.apply(null, [this].concat([].slice.call(args)));
216
+ this._r = color._r;
217
+ this._g = color._g;
218
+ this._b = color._b;
219
+ this.setAlpha(color._a);
220
+ return this;
221
+ },
222
+ lighten: function lighten() {
223
+ return this._applyModification(_lighten, arguments);
224
+ },
225
+ brighten: function brighten() {
226
+ return this._applyModification(_brighten, arguments);
227
+ },
228
+ darken: function darken() {
229
+ return this._applyModification(_darken, arguments);
230
+ },
231
+ desaturate: function desaturate() {
232
+ return this._applyModification(_desaturate, arguments);
233
+ },
234
+ saturate: function saturate() {
235
+ return this._applyModification(_saturate, arguments);
236
+ },
237
+ greyscale: function greyscale() {
238
+ return this._applyModification(_greyscale, arguments);
239
+ },
240
+ spin: function spin() {
241
+ return this._applyModification(_spin, arguments);
242
+ },
243
+ _applyCombination: function _applyCombination(fn, args) {
244
+ return fn.apply(null, [this].concat([].slice.call(args)));
245
+ },
246
+ analogous: function analogous() {
247
+ return this._applyCombination(_analogous, arguments);
248
+ },
249
+ complement: function complement() {
250
+ return this._applyCombination(_complement, arguments);
251
+ },
252
+ monochromatic: function monochromatic() {
253
+ return this._applyCombination(_monochromatic, arguments);
254
+ },
255
+ splitcomplement: function splitcomplement() {
256
+ return this._applyCombination(_splitcomplement, arguments);
257
+ },
258
+ // Disabled until https://github.com/bgrins/TinyColor/issues/254
259
+ // polyad: function (number) {
260
+ // return this._applyCombination(polyad, [number]);
261
+ // },
262
+ triad: function triad() {
263
+ return this._applyCombination(polyad, [3]);
264
+ },
265
+ tetrad: function tetrad() {
266
+ return this._applyCombination(polyad, [4]);
267
+ }
268
+ };
269
+
270
+ // If input is an object, force 1 into "1.0" to handle ratios properly
271
+ // String input requires "1.0" as input, so 1 will be treated as 1
272
+ tinycolor.fromRatio = function (color, opts) {
273
+ if (_typeof(color) == "object") {
274
+ var newColor = {};
275
+ for (var i in color) {
276
+ if (color.hasOwnProperty(i)) {
277
+ if (i === "a") {
278
+ newColor[i] = color[i];
279
+ } else {
280
+ newColor[i] = convertToPercentage(color[i]);
281
+ }
282
+ }
283
+ }
284
+ color = newColor;
285
+ }
286
+ return tinycolor(color, opts);
287
+ };
288
+
289
+ // Given a string or object, convert that input to RGB
290
+ // Possible string inputs:
291
+ //
292
+ // "red"
293
+ // "#f00" or "f00"
294
+ // "#ff0000" or "ff0000"
295
+ // "#ff000000" or "ff000000"
296
+ // "rgb 255 0 0" or "rgb (255, 0, 0)"
297
+ // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
298
+ // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
299
+ // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
300
+ // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
301
+ // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
302
+ // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
303
+ //
304
+ function inputToRGB(color) {
305
+ var rgb = {
306
+ r: 0,
307
+ g: 0,
308
+ b: 0
309
+ };
310
+ var a = 1;
311
+ var s = null;
312
+ var v = null;
313
+ var l = null;
314
+ var ok = false;
315
+ var format = false;
316
+ if (typeof color == "string") {
317
+ color = stringInputToObject(color);
318
+ }
319
+ if (_typeof(color) == "object") {
320
+ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
321
+ rgb = rgbToRgb(color.r, color.g, color.b);
322
+ ok = true;
323
+ format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
324
+ } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
325
+ s = convertToPercentage(color.s);
326
+ v = convertToPercentage(color.v);
327
+ rgb = hsvToRgb(color.h, s, v);
328
+ ok = true;
329
+ format = "hsv";
330
+ } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
331
+ s = convertToPercentage(color.s);
332
+ l = convertToPercentage(color.l);
333
+ rgb = hslToRgb(color.h, s, l);
334
+ ok = true;
335
+ format = "hsl";
336
+ }
337
+ if (color.hasOwnProperty("a")) {
338
+ a = color.a;
339
+ }
340
+ }
341
+ a = boundAlpha(a);
342
+ return {
343
+ ok: ok,
344
+ format: color.format || format,
345
+ r: Math.min(255, Math.max(rgb.r, 0)),
346
+ g: Math.min(255, Math.max(rgb.g, 0)),
347
+ b: Math.min(255, Math.max(rgb.b, 0)),
348
+ a: a
349
+ };
350
+ }
351
+
352
+ // Conversion Functions
353
+ // --------------------
354
+
355
+ // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
356
+ // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
357
+
358
+ // `rgbToRgb`
359
+ // Handle bounds / percentage checking to conform to CSS color spec
360
+ // <http://www.w3.org/TR/css3-color/>
361
+ // *Assumes:* r, g, b in [0, 255] or [0, 1]
362
+ // *Returns:* { r, g, b } in [0, 255]
363
+ function rgbToRgb(r, g, b) {
364
+ return {
365
+ r: bound01(r, 255) * 255,
366
+ g: bound01(g, 255) * 255,
367
+ b: bound01(b, 255) * 255
368
+ };
369
+ }
370
+
371
+ // `rgbToHsl`
372
+ // Converts an RGB color value to HSL.
373
+ // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
374
+ // *Returns:* { h, s, l } in [0,1]
375
+ function rgbToHsl(r, g, b) {
376
+ r = bound01(r, 255);
377
+ g = bound01(g, 255);
378
+ b = bound01(b, 255);
379
+ var max = Math.max(r, g, b),
380
+ min = Math.min(r, g, b);
381
+ var h,
382
+ s,
383
+ l = (max + min) / 2;
384
+ if (max == min) {
385
+ h = s = 0; // achromatic
386
+ } else {
387
+ var d = max - min;
388
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
389
+ switch (max) {
390
+ case r:
391
+ h = (g - b) / d + (g < b ? 6 : 0);
392
+ break;
393
+ case g:
394
+ h = (b - r) / d + 2;
395
+ break;
396
+ case b:
397
+ h = (r - g) / d + 4;
398
+ break;
399
+ }
400
+ h /= 6;
401
+ }
402
+ return {
403
+ h: h,
404
+ s: s,
405
+ l: l
406
+ };
407
+ }
408
+
409
+ // `hslToRgb`
410
+ // Converts an HSL color value to RGB.
411
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
412
+ // *Returns:* { r, g, b } in the set [0, 255]
413
+ function hslToRgb(h, s, l) {
414
+ var r, g, b;
415
+ h = bound01(h, 360);
416
+ s = bound01(s, 100);
417
+ l = bound01(l, 100);
418
+ function hue2rgb(p, q, t) {
419
+ if (t < 0) t += 1;
420
+ if (t > 1) t -= 1;
421
+ if (t < 1 / 6) return p + (q - p) * 6 * t;
422
+ if (t < 1 / 2) return q;
423
+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
424
+ return p;
425
+ }
426
+ if (s === 0) {
427
+ r = g = b = l; // achromatic
428
+ } else {
429
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
430
+ var p = 2 * l - q;
431
+ r = hue2rgb(p, q, h + 1 / 3);
432
+ g = hue2rgb(p, q, h);
433
+ b = hue2rgb(p, q, h - 1 / 3);
434
+ }
435
+ return {
436
+ r: r * 255,
437
+ g: g * 255,
438
+ b: b * 255
439
+ };
440
+ }
441
+
442
+ // `rgbToHsv`
443
+ // Converts an RGB color value to HSV
444
+ // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
445
+ // *Returns:* { h, s, v } in [0,1]
446
+ function rgbToHsv(r, g, b) {
447
+ r = bound01(r, 255);
448
+ g = bound01(g, 255);
449
+ b = bound01(b, 255);
450
+ var max = Math.max(r, g, b),
451
+ min = Math.min(r, g, b);
452
+ var h,
453
+ s,
454
+ v = max;
455
+ var d = max - min;
456
+ s = max === 0 ? 0 : d / max;
457
+ if (max == min) {
458
+ h = 0; // achromatic
459
+ } else {
460
+ switch (max) {
461
+ case r:
462
+ h = (g - b) / d + (g < b ? 6 : 0);
463
+ break;
464
+ case g:
465
+ h = (b - r) / d + 2;
466
+ break;
467
+ case b:
468
+ h = (r - g) / d + 4;
469
+ break;
470
+ }
471
+ h /= 6;
472
+ }
473
+ return {
474
+ h: h,
475
+ s: s,
476
+ v: v
477
+ };
478
+ }
479
+
480
+ // `hsvToRgb`
481
+ // Converts an HSV color value to RGB.
482
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
483
+ // *Returns:* { r, g, b } in the set [0, 255]
484
+ function hsvToRgb(h, s, v) {
485
+ h = bound01(h, 360) * 6;
486
+ s = bound01(s, 100);
487
+ v = bound01(v, 100);
488
+ var i = Math.floor(h),
489
+ f = h - i,
490
+ p = v * (1 - s),
491
+ q = v * (1 - f * s),
492
+ t = v * (1 - (1 - f) * s),
493
+ mod = i % 6,
494
+ r = [v, q, p, p, t, v][mod],
495
+ g = [t, v, v, q, p, p][mod],
496
+ b = [p, p, t, v, v, q][mod];
497
+ return {
498
+ r: r * 255,
499
+ g: g * 255,
500
+ b: b * 255
501
+ };
502
+ }
503
+
504
+ // `rgbToHex`
505
+ // Converts an RGB color to hex
506
+ // Assumes r, g, and b are contained in the set [0, 255]
507
+ // Returns a 3 or 6 character hex
508
+ function rgbToHex(r, g, b, allow3Char) {
509
+ var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
510
+
511
+ // Return a 3 character hex if possible
512
+ if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
513
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
514
+ }
515
+ return hex.join("");
516
+ }
517
+
518
+ // `rgbaToHex`
519
+ // Converts an RGBA color plus alpha transparency to hex
520
+ // Assumes r, g, b are contained in the set [0, 255] and
521
+ // a in [0, 1]. Returns a 4 or 8 character rgba hex
522
+ function rgbaToHex(r, g, b, a, allow4Char) {
523
+ var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))];
524
+
525
+ // Return a 4 character hex if possible
526
+ if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
527
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
528
+ }
529
+ return hex.join("");
530
+ }
531
+
532
+ // `rgbaToArgbHex`
533
+ // Converts an RGBA color to an ARGB Hex8 string
534
+ // Rarely used, but required for "toFilter()"
535
+ function rgbaToArgbHex(r, g, b, a) {
536
+ var hex = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
537
+ return hex.join("");
538
+ }
539
+
540
+ // `equals`
541
+ // Can be called with any tinycolor input
542
+ tinycolor.equals = function (color1, color2) {
543
+ if (!color1 || !color2) return false;
544
+ return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
545
+ };
546
+ tinycolor.random = function () {
547
+ return tinycolor.fromRatio({
548
+ r: Math.random(),
549
+ g: Math.random(),
550
+ b: Math.random()
551
+ });
552
+ };
553
+
554
+ // Modification Functions
555
+ // ----------------------
556
+ // Thanks to less.js for some of the basics here
557
+ // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
558
+
559
+ function _desaturate(color, amount) {
560
+ amount = amount === 0 ? 0 : amount || 10;
561
+ var hsl = tinycolor(color).toHsl();
562
+ hsl.s -= amount / 100;
563
+ hsl.s = clamp01(hsl.s);
564
+ return tinycolor(hsl);
565
+ }
566
+ function _saturate(color, amount) {
567
+ amount = amount === 0 ? 0 : amount || 10;
568
+ var hsl = tinycolor(color).toHsl();
569
+ hsl.s += amount / 100;
570
+ hsl.s = clamp01(hsl.s);
571
+ return tinycolor(hsl);
572
+ }
573
+ function _greyscale(color) {
574
+ return tinycolor(color).desaturate(100);
575
+ }
576
+ function _lighten(color, amount) {
577
+ amount = amount === 0 ? 0 : amount || 10;
578
+ var hsl = tinycolor(color).toHsl();
579
+ hsl.l += amount / 100;
580
+ hsl.l = clamp01(hsl.l);
581
+ return tinycolor(hsl);
582
+ }
583
+ function _brighten(color, amount) {
584
+ amount = amount === 0 ? 0 : amount || 10;
585
+ var rgb = tinycolor(color).toRgb();
586
+ rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
587
+ rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
588
+ rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
589
+ return tinycolor(rgb);
590
+ }
591
+ function _darken(color, amount) {
592
+ amount = amount === 0 ? 0 : amount || 10;
593
+ var hsl = tinycolor(color).toHsl();
594
+ hsl.l -= amount / 100;
595
+ hsl.l = clamp01(hsl.l);
596
+ return tinycolor(hsl);
597
+ }
598
+
599
+ // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
600
+ // Values outside of this range will be wrapped into this range.
601
+ function _spin(color, amount) {
602
+ var hsl = tinycolor(color).toHsl();
603
+ var hue = (hsl.h + amount) % 360;
604
+ hsl.h = hue < 0 ? 360 + hue : hue;
605
+ return tinycolor(hsl);
606
+ }
607
+
608
+ // Combination Functions
609
+ // ---------------------
610
+ // Thanks to jQuery xColor for some of the ideas behind these
611
+ // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
612
+
613
+ function _complement(color) {
614
+ var hsl = tinycolor(color).toHsl();
615
+ hsl.h = (hsl.h + 180) % 360;
616
+ return tinycolor(hsl);
617
+ }
618
+ function polyad(color, number) {
619
+ if (isNaN(number) || number <= 0) {
620
+ throw new Error("Argument to polyad must be a positive number");
621
+ }
622
+ var hsl = tinycolor(color).toHsl();
623
+ var result = [tinycolor(color)];
624
+ var step = 360 / number;
625
+ for (var i = 1; i < number; i++) {
626
+ result.push(tinycolor({
627
+ h: (hsl.h + i * step) % 360,
628
+ s: hsl.s,
629
+ l: hsl.l
630
+ }));
631
+ }
632
+ return result;
633
+ }
634
+ function _splitcomplement(color) {
635
+ var hsl = tinycolor(color).toHsl();
636
+ var h = hsl.h;
637
+ return [tinycolor(color), tinycolor({
638
+ h: (h + 72) % 360,
639
+ s: hsl.s,
640
+ l: hsl.l
641
+ }), tinycolor({
642
+ h: (h + 216) % 360,
643
+ s: hsl.s,
644
+ l: hsl.l
645
+ })];
646
+ }
647
+ function _analogous(color, results, slices) {
648
+ results = results || 6;
649
+ slices = slices || 30;
650
+ var hsl = tinycolor(color).toHsl();
651
+ var part = 360 / slices;
652
+ var ret = [tinycolor(color)];
653
+ for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results;) {
654
+ hsl.h = (hsl.h + part) % 360;
655
+ ret.push(tinycolor(hsl));
656
+ }
657
+ return ret;
658
+ }
659
+ function _monochromatic(color, results) {
660
+ results = results || 6;
661
+ var hsv = tinycolor(color).toHsv();
662
+ var h = hsv.h,
663
+ s = hsv.s,
664
+ v = hsv.v;
665
+ var ret = [];
666
+ var modification = 1 / results;
667
+ while (results--) {
668
+ ret.push(tinycolor({
669
+ h: h,
670
+ s: s,
671
+ v: v
672
+ }));
673
+ v = (v + modification) % 1;
674
+ }
675
+ return ret;
676
+ }
677
+
678
+ // Utility Functions
679
+ // ---------------------
680
+
681
+ tinycolor.mix = function (color1, color2, amount) {
682
+ amount = amount === 0 ? 0 : amount || 50;
683
+ var rgb1 = tinycolor(color1).toRgb();
684
+ var rgb2 = tinycolor(color2).toRgb();
685
+ var p = amount / 100;
686
+ var rgba = {
687
+ r: (rgb2.r - rgb1.r) * p + rgb1.r,
688
+ g: (rgb2.g - rgb1.g) * p + rgb1.g,
689
+ b: (rgb2.b - rgb1.b) * p + rgb1.b,
690
+ a: (rgb2.a - rgb1.a) * p + rgb1.a
691
+ };
692
+ return tinycolor(rgba);
693
+ };
694
+
695
+ // Readability Functions
696
+ // ---------------------
697
+ // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
698
+
699
+ // `contrast`
700
+ // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
701
+ tinycolor.readability = function (color1, color2) {
702
+ var c1 = tinycolor(color1);
703
+ var c2 = tinycolor(color2);
704
+ return (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) / (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05);
705
+ };
706
+
707
+ // `isReadable`
708
+ // Ensure that foreground and background color combinations meet WCAG2 guidelines.
709
+ // The third argument is an optional Object.
710
+ // the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
711
+ // the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
712
+ // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
713
+
714
+ // *Example*
715
+ // tinycolor.isReadable("#000", "#111") => false
716
+ // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
717
+ tinycolor.isReadable = function (color1, color2, wcag2) {
718
+ var readability = tinycolor.readability(color1, color2);
719
+ var wcag2Parms, out;
720
+ out = false;
721
+ wcag2Parms = validateWCAG2Parms(wcag2);
722
+ switch (wcag2Parms.level + wcag2Parms.size) {
723
+ case "AAsmall":
724
+ case "AAAlarge":
725
+ out = readability >= 4.5;
726
+ break;
727
+ case "AAlarge":
728
+ out = readability >= 3;
729
+ break;
730
+ case "AAAsmall":
731
+ out = readability >= 7;
732
+ break;
733
+ }
734
+ return out;
735
+ };
736
+
737
+ // `mostReadable`
738
+ // Given a base color and a list of possible foreground or background
739
+ // colors for that base, returns the most readable color.
740
+ // Optionally returns Black or White if the most readable color is unreadable.
741
+ // *Example*
742
+ // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
743
+ // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
744
+ // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
745
+ // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
746
+ tinycolor.mostReadable = function (baseColor, colorList, args) {
747
+ var bestColor = null;
748
+ var bestScore = 0;
749
+ var readability;
750
+ var includeFallbackColors, level, size;
751
+ args = args || {};
752
+ includeFallbackColors = args.includeFallbackColors;
753
+ level = args.level;
754
+ size = args.size;
755
+ for (var i = 0; i < colorList.length; i++) {
756
+ readability = tinycolor.readability(baseColor, colorList[i]);
757
+ if (readability > bestScore) {
758
+ bestScore = readability;
759
+ bestColor = tinycolor(colorList[i]);
760
+ }
761
+ }
762
+ if (tinycolor.isReadable(baseColor, bestColor, {
763
+ level: level,
764
+ size: size
765
+ }) || !includeFallbackColors) {
766
+ return bestColor;
767
+ } else {
768
+ args.includeFallbackColors = false;
769
+ return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
770
+ }
771
+ };
772
+
773
+ // Big List of Colors
774
+ // ------------------
775
+ // <https://www.w3.org/TR/css-color-4/#named-colors>
776
+ var names = tinycolor.names = {
777
+ aliceblue: "f0f8ff",
778
+ antiquewhite: "faebd7",
779
+ aqua: "0ff",
780
+ aquamarine: "7fffd4",
781
+ azure: "f0ffff",
782
+ beige: "f5f5dc",
783
+ bisque: "ffe4c4",
784
+ black: "000",
785
+ blanchedalmond: "ffebcd",
786
+ blue: "00f",
787
+ blueviolet: "8a2be2",
788
+ brown: "a52a2a",
789
+ burlywood: "deb887",
790
+ burntsienna: "ea7e5d",
791
+ cadetblue: "5f9ea0",
792
+ chartreuse: "7fff00",
793
+ chocolate: "d2691e",
794
+ coral: "ff7f50",
795
+ cornflowerblue: "6495ed",
796
+ cornsilk: "fff8dc",
797
+ crimson: "dc143c",
798
+ cyan: "0ff",
799
+ darkblue: "00008b",
800
+ darkcyan: "008b8b",
801
+ darkgoldenrod: "b8860b",
802
+ darkgray: "a9a9a9",
803
+ darkgreen: "006400",
804
+ darkgrey: "a9a9a9",
805
+ darkkhaki: "bdb76b",
806
+ darkmagenta: "8b008b",
807
+ darkolivegreen: "556b2f",
808
+ darkorange: "ff8c00",
809
+ darkorchid: "9932cc",
810
+ darkred: "8b0000",
811
+ darksalmon: "e9967a",
812
+ darkseagreen: "8fbc8f",
813
+ darkslateblue: "483d8b",
814
+ darkslategray: "2f4f4f",
815
+ darkslategrey: "2f4f4f",
816
+ darkturquoise: "00ced1",
817
+ darkviolet: "9400d3",
818
+ deeppink: "ff1493",
819
+ deepskyblue: "00bfff",
820
+ dimgray: "696969",
821
+ dimgrey: "696969",
822
+ dodgerblue: "1e90ff",
823
+ firebrick: "b22222",
824
+ floralwhite: "fffaf0",
825
+ forestgreen: "228b22",
826
+ fuchsia: "f0f",
827
+ gainsboro: "dcdcdc",
828
+ ghostwhite: "f8f8ff",
829
+ gold: "ffd700",
830
+ goldenrod: "daa520",
831
+ gray: "808080",
832
+ green: "008000",
833
+ greenyellow: "adff2f",
834
+ grey: "808080",
835
+ honeydew: "f0fff0",
836
+ hotpink: "ff69b4",
837
+ indianred: "cd5c5c",
838
+ indigo: "4b0082",
839
+ ivory: "fffff0",
840
+ khaki: "f0e68c",
841
+ lavender: "e6e6fa",
842
+ lavenderblush: "fff0f5",
843
+ lawngreen: "7cfc00",
844
+ lemonchiffon: "fffacd",
845
+ lightblue: "add8e6",
846
+ lightcoral: "f08080",
847
+ lightcyan: "e0ffff",
848
+ lightgoldenrodyellow: "fafad2",
849
+ lightgray: "d3d3d3",
850
+ lightgreen: "90ee90",
851
+ lightgrey: "d3d3d3",
852
+ lightpink: "ffb6c1",
853
+ lightsalmon: "ffa07a",
854
+ lightseagreen: "20b2aa",
855
+ lightskyblue: "87cefa",
856
+ lightslategray: "789",
857
+ lightslategrey: "789",
858
+ lightsteelblue: "b0c4de",
859
+ lightyellow: "ffffe0",
860
+ lime: "0f0",
861
+ limegreen: "32cd32",
862
+ linen: "faf0e6",
863
+ magenta: "f0f",
864
+ maroon: "800000",
865
+ mediumaquamarine: "66cdaa",
866
+ mediumblue: "0000cd",
867
+ mediumorchid: "ba55d3",
868
+ mediumpurple: "9370db",
869
+ mediumseagreen: "3cb371",
870
+ mediumslateblue: "7b68ee",
871
+ mediumspringgreen: "00fa9a",
872
+ mediumturquoise: "48d1cc",
873
+ mediumvioletred: "c71585",
874
+ midnightblue: "191970",
875
+ mintcream: "f5fffa",
876
+ mistyrose: "ffe4e1",
877
+ moccasin: "ffe4b5",
878
+ navajowhite: "ffdead",
879
+ navy: "000080",
880
+ oldlace: "fdf5e6",
881
+ olive: "808000",
882
+ olivedrab: "6b8e23",
883
+ orange: "ffa500",
884
+ orangered: "ff4500",
885
+ orchid: "da70d6",
886
+ palegoldenrod: "eee8aa",
887
+ palegreen: "98fb98",
888
+ paleturquoise: "afeeee",
889
+ palevioletred: "db7093",
890
+ papayawhip: "ffefd5",
891
+ peachpuff: "ffdab9",
892
+ peru: "cd853f",
893
+ pink: "ffc0cb",
894
+ plum: "dda0dd",
895
+ powderblue: "b0e0e6",
896
+ purple: "800080",
897
+ rebeccapurple: "663399",
898
+ red: "f00",
899
+ rosybrown: "bc8f8f",
900
+ royalblue: "4169e1",
901
+ saddlebrown: "8b4513",
902
+ salmon: "fa8072",
903
+ sandybrown: "f4a460",
904
+ seagreen: "2e8b57",
905
+ seashell: "fff5ee",
906
+ sienna: "a0522d",
907
+ silver: "c0c0c0",
908
+ skyblue: "87ceeb",
909
+ slateblue: "6a5acd",
910
+ slategray: "708090",
911
+ slategrey: "708090",
912
+ snow: "fffafa",
913
+ springgreen: "00ff7f",
914
+ steelblue: "4682b4",
915
+ tan: "d2b48c",
916
+ teal: "008080",
917
+ thistle: "d8bfd8",
918
+ tomato: "ff6347",
919
+ turquoise: "40e0d0",
920
+ violet: "ee82ee",
921
+ wheat: "f5deb3",
922
+ white: "fff",
923
+ whitesmoke: "f5f5f5",
924
+ yellow: "ff0",
925
+ yellowgreen: "9acd32"
926
+ };
927
+
928
+ // Make it easy to access colors via `hexNames[hex]`
929
+ var hexNames = tinycolor.hexNames = flip(names);
930
+
931
+ // Utilities
932
+ // ---------
933
+
934
+ // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
935
+ function flip(o) {
936
+ var flipped = {};
937
+ for (var i in o) {
938
+ if (o.hasOwnProperty(i)) {
939
+ flipped[o[i]] = i;
940
+ }
941
+ }
942
+ return flipped;
943
+ }
944
+
945
+ // Return a valid alpha value [0,1] with all invalid values being set to 1
946
+ function boundAlpha(a) {
947
+ a = parseFloat(a);
948
+ if (isNaN(a) || a < 0 || a > 1) {
949
+ a = 1;
950
+ }
951
+ return a;
952
+ }
953
+
954
+ // Take input from [0, n] and return it as [0, 1]
955
+ function bound01(n, max) {
956
+ if (isOnePointZero(n)) n = "100%";
957
+ var processPercent = isPercentage(n);
958
+ n = Math.min(max, Math.max(0, parseFloat(n)));
959
+
960
+ // Automatically convert percentage into number
961
+ if (processPercent) {
962
+ n = parseInt(n * max, 10) / 100;
963
+ }
964
+
965
+ // Handle floating point rounding errors
966
+ if (Math.abs(n - max) < 0.000001) {
967
+ return 1;
968
+ }
969
+
970
+ // Convert into [0, 1] range if it isn't already
971
+ return n % max / parseFloat(max);
972
+ }
973
+
974
+ // Force a number between 0 and 1
975
+ function clamp01(val) {
976
+ return Math.min(1, Math.max(0, val));
977
+ }
978
+
979
+ // Parse a base-16 hex value into a base-10 integer
980
+ function parseIntFromHex(val) {
981
+ return parseInt(val, 16);
982
+ }
983
+
984
+ // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
985
+ // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
986
+ function isOnePointZero(n) {
987
+ return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
988
+ }
989
+
990
+ // Check to see if string passed in is a percentage
991
+ function isPercentage(n) {
992
+ return typeof n === "string" && n.indexOf("%") != -1;
993
+ }
994
+
995
+ // Force a hex value to have 2 characters
996
+ function pad2(c) {
997
+ return c.length == 1 ? "0" + c : "" + c;
998
+ }
999
+
1000
+ // Replace a decimal with it's percentage value
1001
+ function convertToPercentage(n) {
1002
+ if (n <= 1) {
1003
+ n = n * 100 + "%";
1004
+ }
1005
+ return n;
1006
+ }
1007
+
1008
+ // Converts a decimal to a hex value
1009
+ function convertDecimalToHex(d) {
1010
+ return Math.round(parseFloat(d) * 255).toString(16);
1011
+ }
1012
+ // Converts a hex value to a decimal
1013
+ function convertHexToDecimal(h) {
1014
+ return parseIntFromHex(h) / 255;
1015
+ }
1016
+ var matchers = function () {
1017
+ // <http://www.w3.org/TR/css3-values/#integers>
1018
+ var CSS_INTEGER = "[-\\+]?\\d+%?";
1019
+
1020
+ // <http://www.w3.org/TR/css3-values/#number-value>
1021
+ var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
1022
+
1023
+ // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
1024
+ var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
1025
+
1026
+ // Actual matching.
1027
+ // Parentheses and commas are optional, but not required.
1028
+ // Whitespace can take the place of commas or opening paren
1029
+ var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
1030
+ var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
1031
+ return {
1032
+ CSS_UNIT: new RegExp(CSS_UNIT),
1033
+ rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
1034
+ rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
1035
+ hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
1036
+ hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
1037
+ hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
1038
+ hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
1039
+ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1040
+ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1041
+ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1042
+ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
1043
+ };
1044
+ }();
1045
+
1046
+ // `isValidCSSUnit`
1047
+ // Take in a single string / number and check to see if it looks like a CSS unit
1048
+ // (see `matchers` above for definition).
1049
+ function isValidCSSUnit(color) {
1050
+ return !!matchers.CSS_UNIT.exec(color);
1051
+ }
1052
+
1053
+ // `stringInputToObject`
1054
+ // Permissive string parsing. Take in a number of formats, and output an object
1055
+ // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
1056
+ function stringInputToObject(color) {
1057
+ color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
1058
+ var named = false;
1059
+ if (names[color]) {
1060
+ color = names[color];
1061
+ named = true;
1062
+ } else if (color == "transparent") {
1063
+ return {
1064
+ r: 0,
1065
+ g: 0,
1066
+ b: 0,
1067
+ a: 0,
1068
+ format: "name"
1069
+ };
1070
+ }
1071
+
1072
+ // Try to match string input using regular expressions.
1073
+ // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
1074
+ // Just return an object and let the conversion functions handle that.
1075
+ // This way the result will be the same whether the tinycolor is initialized with string or object.
1076
+ var match;
1077
+ if (match = matchers.rgb.exec(color)) {
1078
+ return {
1079
+ r: match[1],
1080
+ g: match[2],
1081
+ b: match[3]
1082
+ };
1083
+ }
1084
+ if (match = matchers.rgba.exec(color)) {
1085
+ return {
1086
+ r: match[1],
1087
+ g: match[2],
1088
+ b: match[3],
1089
+ a: match[4]
1090
+ };
1091
+ }
1092
+ if (match = matchers.hsl.exec(color)) {
1093
+ return {
1094
+ h: match[1],
1095
+ s: match[2],
1096
+ l: match[3]
1097
+ };
1098
+ }
1099
+ if (match = matchers.hsla.exec(color)) {
1100
+ return {
1101
+ h: match[1],
1102
+ s: match[2],
1103
+ l: match[3],
1104
+ a: match[4]
1105
+ };
1106
+ }
1107
+ if (match = matchers.hsv.exec(color)) {
1108
+ return {
1109
+ h: match[1],
1110
+ s: match[2],
1111
+ v: match[3]
1112
+ };
1113
+ }
1114
+ if (match = matchers.hsva.exec(color)) {
1115
+ return {
1116
+ h: match[1],
1117
+ s: match[2],
1118
+ v: match[3],
1119
+ a: match[4]
1120
+ };
1121
+ }
1122
+ if (match = matchers.hex8.exec(color)) {
1123
+ return {
1124
+ r: parseIntFromHex(match[1]),
1125
+ g: parseIntFromHex(match[2]),
1126
+ b: parseIntFromHex(match[3]),
1127
+ a: convertHexToDecimal(match[4]),
1128
+ format: named ? "name" : "hex8"
1129
+ };
1130
+ }
1131
+ if (match = matchers.hex6.exec(color)) {
1132
+ return {
1133
+ r: parseIntFromHex(match[1]),
1134
+ g: parseIntFromHex(match[2]),
1135
+ b: parseIntFromHex(match[3]),
1136
+ format: named ? "name" : "hex"
1137
+ };
1138
+ }
1139
+ if (match = matchers.hex4.exec(color)) {
1140
+ return {
1141
+ r: parseIntFromHex(match[1] + "" + match[1]),
1142
+ g: parseIntFromHex(match[2] + "" + match[2]),
1143
+ b: parseIntFromHex(match[3] + "" + match[3]),
1144
+ a: convertHexToDecimal(match[4] + "" + match[4]),
1145
+ format: named ? "name" : "hex8"
1146
+ };
1147
+ }
1148
+ if (match = matchers.hex3.exec(color)) {
1149
+ return {
1150
+ r: parseIntFromHex(match[1] + "" + match[1]),
1151
+ g: parseIntFromHex(match[2] + "" + match[2]),
1152
+ b: parseIntFromHex(match[3] + "" + match[3]),
1153
+ format: named ? "name" : "hex"
1154
+ };
1155
+ }
1156
+ return false;
1157
+ }
1158
+ function validateWCAG2Parms(parms) {
1159
+ // return valid WCAG2 parms for isReadable.
1160
+ // If input parms are invalid, return {"level":"AA", "size":"small"}
1161
+ var level, size;
1162
+ parms = parms || {
1163
+ level: "AA",
1164
+ size: "small"
1165
+ };
1166
+ level = (parms.level || "AA").toUpperCase();
1167
+ size = (parms.size || "small").toLowerCase();
1168
+ if (level !== "AA" && level !== "AAA") {
1169
+ level = "AA";
1170
+ }
1171
+ if (size !== "small" && size !== "large") {
1172
+ size = "small";
1173
+ }
1174
+ return {
1175
+ level: level,
1176
+ size: size
1177
+ };
1178
+ }
1179
+
1180
+ export { tinycolor as t };