ngx-color 7.0.2 → 7.3.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 (350) hide show
  1. package/alpha/alpha-picker.component.d.ts +8 -0
  2. package/alpha/ngx-color-alpha.d.ts +2 -1
  3. package/alpha/package.json +6 -10
  4. package/alpha/public_api.d.ts +1 -0
  5. package/alpha.component.d.ts +9 -0
  6. package/block/block-swatches.component.d.ts +13 -8
  7. package/block/block.component.d.ts +9 -0
  8. package/block/ngx-color-block.d.ts +2 -2
  9. package/block/package.json +6 -10
  10. package/block/public_api.d.ts +2 -0
  11. package/checkboard.component.d.ts +7 -0
  12. package/chrome/chrome-fields.component.d.ts +3 -0
  13. package/chrome/chrome.component.d.ts +9 -0
  14. package/chrome/ngx-color-chrome.d.ts +2 -2
  15. package/chrome/package.json +6 -10
  16. package/chrome/public_api.d.ts +2 -0
  17. package/circle/circle-swatch.component.d.ts +3 -0
  18. package/circle/circle.component.d.ts +9 -0
  19. package/circle/ngx-color-circle.d.ts +2 -2
  20. package/circle/package.json +9 -10
  21. package/circle/public_api.d.ts +2 -0
  22. package/color-wrap.component.d.ts +27 -2
  23. package/compact/compact-color.component.d.ts +3 -0
  24. package/compact/compact-fields.component.d.ts +3 -0
  25. package/compact/compact.component.d.ts +10 -0
  26. package/compact/ngx-color-compact.d.ts +2 -3
  27. package/compact/package.json +6 -10
  28. package/compact/public_api.d.ts +3 -0
  29. package/coordinates.directive.d.ts +6 -0
  30. package/editable-input.component.d.ts +7 -0
  31. package/esm2020/alpha/alpha-picker.component.mjs +116 -0
  32. package/esm2020/alpha/ngx-color-alpha.mjs +5 -0
  33. package/esm2020/alpha/public_api.mjs +2 -0
  34. package/esm2020/alpha.component.mjs +186 -0
  35. package/esm2020/block/block-swatches.component.mjs +74 -0
  36. package/esm2020/block/block.component.mjs +199 -0
  37. package/esm2020/block/ngx-color-block.mjs +5 -0
  38. package/esm2020/block/public_api.mjs +3 -0
  39. package/esm2020/checkboard.component.mjs +66 -0
  40. package/esm2020/chrome/chrome-fields.component.mjs +356 -0
  41. package/esm2020/chrome/chrome.component.mjs +249 -0
  42. package/esm2020/chrome/ngx-color-chrome.mjs +5 -0
  43. package/esm2020/chrome/public_api.mjs +3 -0
  44. package/esm2020/circle/circle-swatch.component.mjs +85 -0
  45. package/esm2020/circle/circle.component.mjs +148 -0
  46. package/esm2020/circle/ngx-color-circle.mjs +5 -0
  47. package/esm2020/circle/public_api.mjs +3 -0
  48. package/esm2020/color-wrap.component.mjs +163 -0
  49. package/esm2020/compact/compact-color.component.mjs +91 -0
  50. package/esm2020/compact/compact-fields.component.mjs +186 -0
  51. package/esm2020/compact/compact.component.mjs +177 -0
  52. package/esm2020/compact/ngx-color-compact.mjs +5 -0
  53. package/esm2020/compact/public_api.mjs +4 -0
  54. package/esm2020/coordinates.directive.mjs +104 -0
  55. package/esm2020/editable-input.component.mjs +217 -0
  56. package/esm2020/github/github-swatch.component.mjs +67 -0
  57. package/esm2020/github/github.component.mjs +179 -0
  58. package/esm2020/github/ngx-color-github.mjs +5 -0
  59. package/esm2020/github/public_api.mjs +3 -0
  60. package/esm2020/helpers/checkboard.mjs +33 -0
  61. package/esm2020/helpers/color.interfaces.mjs +2 -0
  62. package/esm2020/helpers/color.mjs +60 -0
  63. package/esm2020/hue/hue-picker.component.mjs +113 -0
  64. package/esm2020/hue/ngx-color-hue.mjs +5 -0
  65. package/esm2020/hue/public_api.mjs +2 -0
  66. package/esm2020/hue.component.mjs +165 -0
  67. package/esm2020/material/material.component.mjs +211 -0
  68. package/esm2020/material/ngx-color-material.mjs +5 -0
  69. package/esm2020/material/public_api.mjs +2 -0
  70. package/esm2020/ngx-color.mjs +5 -0
  71. package/esm2020/photoshop/ngx-color-photoshop.mjs +5 -0
  72. package/esm2020/photoshop/photoshop-button.component.mjs +63 -0
  73. package/esm2020/photoshop/photoshop-fields.component.mjs +241 -0
  74. package/esm2020/photoshop/photoshop-previews.component.mjs +68 -0
  75. package/esm2020/photoshop/photoshop.component.mjs +258 -0
  76. package/esm2020/photoshop/public_api.mjs +5 -0
  77. package/esm2020/public_api.mjs +14 -0
  78. package/esm2020/raised.component.mjs +89 -0
  79. package/esm2020/saturation.component.mjs +136 -0
  80. package/esm2020/shade/ngx-color-shade.mjs +5 -0
  81. package/esm2020/shade/public_api.mjs +2 -0
  82. package/esm2020/shade/shade-picker.component.mjs +105 -0
  83. package/esm2020/shade.component.mjs +165 -0
  84. package/esm2020/sketch/ngx-color-sketch.mjs +5 -0
  85. package/esm2020/sketch/public_api.mjs +4 -0
  86. package/esm2020/sketch/sketch-fields.component.mjs +243 -0
  87. package/esm2020/sketch/sketch-preset-colors.component.mjs +98 -0
  88. package/esm2020/sketch/sketch.component.mjs +283 -0
  89. package/esm2020/slider/ngx-color-slider.mjs +5 -0
  90. package/esm2020/slider/public_api.mjs +4 -0
  91. package/esm2020/slider/slider-swatch.component.mjs +80 -0
  92. package/esm2020/slider/slider-swatches.component.mjs +135 -0
  93. package/esm2020/slider/slider.component.mjs +116 -0
  94. package/esm2020/swatch.component.mjs +125 -0
  95. package/esm2020/swatches/ngx-color-swatches.mjs +5 -0
  96. package/esm2020/swatches/public_api.mjs +4 -0
  97. package/esm2020/swatches/swatches-color.component.mjs +123 -0
  98. package/esm2020/swatches/swatches-group.component.mjs +64 -0
  99. package/esm2020/swatches/swatches.component.mjs +258 -0
  100. package/esm2020/twitter/ngx-color-twitter.mjs +5 -0
  101. package/esm2020/twitter/public_api.mjs +2 -0
  102. package/esm2020/twitter/twitter.component.mjs +255 -0
  103. package/fesm2015/ngx-color-alpha.mjs +123 -0
  104. package/fesm2015/ngx-color-alpha.mjs.map +1 -0
  105. package/fesm2015/ngx-color-block.mjs +275 -0
  106. package/fesm2015/ngx-color-block.mjs.map +1 -0
  107. package/fesm2015/ngx-color-chrome.mjs +606 -0
  108. package/fesm2015/ngx-color-chrome.mjs.map +1 -0
  109. package/fesm2015/ngx-color-circle.mjs +237 -0
  110. package/fesm2015/ngx-color-circle.mjs.map +1 -0
  111. package/fesm2015/ngx-color-compact.mjs +451 -0
  112. package/fesm2015/ngx-color-compact.mjs.map +1 -0
  113. package/fesm2015/ngx-color-github.mjs +250 -0
  114. package/fesm2015/ngx-color-github.mjs.map +1 -0
  115. package/fesm2015/ngx-color-hue.mjs +120 -0
  116. package/fesm2015/ngx-color-hue.mjs.map +1 -0
  117. package/fesm2015/ngx-color-material.mjs +218 -0
  118. package/fesm2015/ngx-color-material.mjs.map +1 -0
  119. package/fesm2015/ngx-color-photoshop.mjs +626 -0
  120. package/fesm2015/ngx-color-photoshop.mjs.map +1 -0
  121. package/fesm2015/ngx-color-shade.mjs +112 -0
  122. package/fesm2015/ngx-color-shade.mjs.map +1 -0
  123. package/fesm2015/ngx-color-sketch.mjs +620 -0
  124. package/fesm2015/ngx-color-sketch.mjs.map +1 -0
  125. package/fesm2015/ngx-color-slider.mjs +331 -0
  126. package/fesm2015/ngx-color-slider.mjs.map +1 -0
  127. package/fesm2015/ngx-color-swatches.mjs +441 -0
  128. package/fesm2015/ngx-color-swatches.mjs.map +1 -0
  129. package/fesm2015/ngx-color-twitter.mjs +262 -0
  130. package/fesm2015/ngx-color-twitter.mjs.map +1 -0
  131. package/fesm2015/ngx-color.mjs +1461 -0
  132. package/fesm2015/ngx-color.mjs.map +1 -0
  133. package/fesm2020/ngx-color-alpha.mjs +123 -0
  134. package/fesm2020/ngx-color-alpha.mjs.map +1 -0
  135. package/fesm2020/ngx-color-block.mjs +275 -0
  136. package/fesm2020/ngx-color-block.mjs.map +1 -0
  137. package/fesm2020/ngx-color-chrome.mjs +606 -0
  138. package/fesm2020/ngx-color-chrome.mjs.map +1 -0
  139. package/fesm2020/ngx-color-circle.mjs +237 -0
  140. package/fesm2020/ngx-color-circle.mjs.map +1 -0
  141. package/fesm2020/ngx-color-compact.mjs +451 -0
  142. package/fesm2020/ngx-color-compact.mjs.map +1 -0
  143. package/fesm2020/ngx-color-github.mjs +250 -0
  144. package/fesm2020/ngx-color-github.mjs.map +1 -0
  145. package/fesm2020/ngx-color-hue.mjs +120 -0
  146. package/fesm2020/ngx-color-hue.mjs.map +1 -0
  147. package/fesm2020/ngx-color-material.mjs +218 -0
  148. package/fesm2020/ngx-color-material.mjs.map +1 -0
  149. package/fesm2020/ngx-color-photoshop.mjs +626 -0
  150. package/fesm2020/ngx-color-photoshop.mjs.map +1 -0
  151. package/fesm2020/ngx-color-shade.mjs +112 -0
  152. package/fesm2020/ngx-color-shade.mjs.map +1 -0
  153. package/fesm2020/ngx-color-sketch.mjs +620 -0
  154. package/fesm2020/ngx-color-sketch.mjs.map +1 -0
  155. package/fesm2020/ngx-color-slider.mjs +331 -0
  156. package/fesm2020/ngx-color-slider.mjs.map +1 -0
  157. package/fesm2020/ngx-color-swatches.mjs +441 -0
  158. package/fesm2020/ngx-color-swatches.mjs.map +1 -0
  159. package/fesm2020/ngx-color-twitter.mjs +262 -0
  160. package/fesm2020/ngx-color-twitter.mjs.map +1 -0
  161. package/fesm2020/ngx-color.mjs +1466 -0
  162. package/fesm2020/ngx-color.mjs.map +1 -0
  163. package/github/github-swatch.component.d.ts +3 -0
  164. package/github/github.component.d.ts +9 -0
  165. package/github/ngx-color-github.d.ts +2 -2
  166. package/github/package.json +6 -10
  167. package/github/public_api.d.ts +2 -0
  168. package/hue/hue-picker.component.d.ts +8 -0
  169. package/hue/ngx-color-hue.d.ts +2 -1
  170. package/hue/package.json +6 -10
  171. package/hue/public_api.d.ts +1 -0
  172. package/hue.component.d.ts +8 -0
  173. package/material/material.component.d.ts +8 -0
  174. package/material/ngx-color-material.d.ts +2 -1
  175. package/material/package.json +6 -10
  176. package/material/public_api.d.ts +1 -0
  177. package/ngx-color.d.ts +1 -0
  178. package/package.json +137 -14
  179. package/photoshop/ngx-color-photoshop.d.ts +2 -4
  180. package/photoshop/package.json +6 -10
  181. package/photoshop/photoshop-button.component.d.ts +3 -0
  182. package/photoshop/photoshop-fields.component.d.ts +3 -0
  183. package/photoshop/photoshop-previews.component.d.ts +3 -0
  184. package/photoshop/photoshop.component.d.ts +11 -0
  185. package/photoshop/public_api.d.ts +4 -0
  186. package/raised.component.d.ts +7 -0
  187. package/saturation.component.d.ts +8 -0
  188. package/shade/ngx-color-shade.d.ts +2 -1
  189. package/shade/package.json +6 -10
  190. package/shade/public_api.d.ts +1 -0
  191. package/shade/shade-picker.component.d.ts +8 -0
  192. package/shade.component.d.ts +8 -0
  193. package/sketch/ngx-color-sketch.d.ts +2 -3
  194. package/sketch/package.json +6 -10
  195. package/sketch/public_api.d.ts +3 -0
  196. package/sketch/sketch-fields.component.d.ts +3 -0
  197. package/sketch/sketch-preset-colors.component.d.ts +3 -0
  198. package/sketch/sketch.component.d.ts +10 -0
  199. package/slider/ngx-color-slider.d.ts +2 -3
  200. package/slider/package.json +6 -10
  201. package/slider/public_api.d.ts +3 -0
  202. package/slider/slider-swatch.component.d.ts +3 -0
  203. package/slider/slider-swatches.component.d.ts +3 -0
  204. package/slider/slider.component.d.ts +10 -0
  205. package/swatch.component.d.ts +8 -0
  206. package/swatches/ngx-color-swatches.d.ts +2 -3
  207. package/swatches/package.json +9 -10
  208. package/swatches/public_api.d.ts +3 -0
  209. package/swatches/swatches-color.component.d.ts +3 -0
  210. package/swatches/swatches-group.component.d.ts +3 -0
  211. package/swatches/swatches.component.d.ts +10 -0
  212. package/twitter/ngx-color-twitter.d.ts +2 -1
  213. package/twitter/package.json +6 -10
  214. package/twitter/public_api.d.ts +1 -0
  215. package/twitter/twitter.component.d.ts +8 -0
  216. package/LICENSE +0 -21
  217. package/README.md +0 -280
  218. package/alpha/bundles/ngx-color-alpha.umd.js +0 -387
  219. package/alpha/bundles/ngx-color-alpha.umd.js.map +0 -1
  220. package/alpha/esm2015/alpha-picker.component.js +0 -72
  221. package/alpha/esm2015/ngx-color-alpha.js +0 -5
  222. package/alpha/fesm2015/ngx-color-alpha.js +0 -79
  223. package/alpha/fesm2015/ngx-color-alpha.js.map +0 -1
  224. package/alpha/ngx-color-alpha.metadata.json +0 -1
  225. package/block/bundles/ngx-color-block.umd.js +0 -455
  226. package/block/bundles/ngx-color-block.umd.js.map +0 -1
  227. package/block/esm2015/block-swatches.component.js +0 -58
  228. package/block/esm2015/block.component.js +0 -139
  229. package/block/esm2015/ngx-color-block.js +0 -6
  230. package/block/fesm2015/ngx-color-block.js +0 -202
  231. package/block/fesm2015/ngx-color-block.js.map +0 -1
  232. package/block/ngx-color-block.metadata.json +0 -1
  233. package/bundles/ngx-color.umd.js +0 -953
  234. package/bundles/ngx-color.umd.js.map +0 -1
  235. package/chrome/bundles/ngx-color-chrome.umd.js +0 -526
  236. package/chrome/bundles/ngx-color-chrome.umd.js.map +0 -1
  237. package/chrome/esm2015/chrome-fields.component.js +0 -255
  238. package/chrome/esm2015/chrome.component.js +0 -161
  239. package/chrome/esm2015/ngx-color-chrome.js +0 -6
  240. package/chrome/fesm2015/ngx-color-chrome.js +0 -420
  241. package/chrome/fesm2015/ngx-color-chrome.js.map +0 -1
  242. package/chrome/ngx-color-chrome.metadata.json +0 -1
  243. package/circle/bundles/ngx-color-circle.umd.js +0 -452
  244. package/circle/bundles/ngx-color-circle.umd.js.map +0 -1
  245. package/circle/esm2015/circle-swatch.component.js +0 -63
  246. package/circle/esm2015/circle.component.js +0 -97
  247. package/circle/esm2015/ngx-color-circle.js +0 -6
  248. package/circle/fesm2015/ngx-color-circle.js +0 -165
  249. package/circle/fesm2015/ngx-color-circle.js.map +0 -1
  250. package/circle/ngx-color-circle.metadata.json +0 -1
  251. package/compact/bundles/ngx-color-compact.umd.js +0 -562
  252. package/compact/bundles/ngx-color-compact.umd.js.map +0 -1
  253. package/compact/esm2015/compact-color.component.js +0 -70
  254. package/compact/esm2015/compact-fields.component.js +0 -142
  255. package/compact/esm2015/compact.component.js +0 -123
  256. package/compact/esm2015/ngx-color-compact.js +0 -7
  257. package/compact/fesm2015/ngx-color-compact.js +0 -336
  258. package/compact/fesm2015/ngx-color-compact.js.map +0 -1
  259. package/compact/ngx-color-compact.metadata.json +0 -1
  260. package/esm2015/alpha.component.js +0 -156
  261. package/esm2015/checkboard.component.js +0 -52
  262. package/esm2015/color-wrap.component.js +0 -82
  263. package/esm2015/coordinates.directive.js +0 -85
  264. package/esm2015/editable-input.component.js +0 -183
  265. package/esm2015/helpers/checkboard.js +0 -33
  266. package/esm2015/helpers/color.interfaces.js +0 -2
  267. package/esm2015/helpers/color.js +0 -60
  268. package/esm2015/hue.component.js +0 -140
  269. package/esm2015/ngx-color.js +0 -5
  270. package/esm2015/public_api.js +0 -14
  271. package/esm2015/raised.component.js +0 -73
  272. package/esm2015/saturation.component.js +0 -111
  273. package/esm2015/shade.component.js +0 -127
  274. package/esm2015/swatch.component.js +0 -85
  275. package/fesm2015/ngx-color.js +0 -1166
  276. package/fesm2015/ngx-color.js.map +0 -1
  277. package/github/bundles/ngx-color-github.umd.js +0 -430
  278. package/github/bundles/ngx-color-github.umd.js.map +0 -1
  279. package/github/esm2015/github-swatch.component.js +0 -48
  280. package/github/esm2015/github.component.js +0 -134
  281. package/github/esm2015/ngx-color-github.js +0 -6
  282. package/github/fesm2015/ngx-color-github.js +0 -187
  283. package/github/fesm2015/ngx-color-github.js.map +0 -1
  284. package/github/ngx-color-github.metadata.json +0 -1
  285. package/hue/bundles/ngx-color-hue.umd.js +0 -390
  286. package/hue/bundles/ngx-color-hue.umd.js.map +0 -1
  287. package/hue/esm2015/hue-picker.component.js +0 -70
  288. package/hue/esm2015/ngx-color-hue.js +0 -5
  289. package/hue/fesm2015/ngx-color-hue.js +0 -77
  290. package/hue/fesm2015/ngx-color-hue.js.map +0 -1
  291. package/hue/ngx-color-hue.metadata.json +0 -1
  292. package/material/bundles/ngx-color-material.umd.js +0 -438
  293. package/material/bundles/ngx-color-material.umd.js.map +0 -1
  294. package/material/esm2015/material.component.js +0 -149
  295. package/material/esm2015/ngx-color-material.js +0 -5
  296. package/material/fesm2015/ngx-color-material.js +0 -156
  297. package/material/fesm2015/ngx-color-material.js.map +0 -1
  298. package/material/ngx-color-material.metadata.json +0 -1
  299. package/ngx-color.metadata.json +0 -1
  300. package/photoshop/bundles/ngx-color-photoshop.umd.js +0 -554
  301. package/photoshop/bundles/ngx-color-photoshop.umd.js.map +0 -1
  302. package/photoshop/esm2015/ngx-color-photoshop.js +0 -8
  303. package/photoshop/esm2015/photoshop-button.component.js +0 -50
  304. package/photoshop/esm2015/photoshop-fields.component.js +0 -180
  305. package/photoshop/esm2015/photoshop-previews.component.js +0 -53
  306. package/photoshop/esm2015/photoshop.component.js +0 -169
  307. package/photoshop/fesm2015/ngx-color-photoshop.js +0 -452
  308. package/photoshop/fesm2015/ngx-color-photoshop.js.map +0 -1
  309. package/photoshop/ngx-color-photoshop.metadata.json +0 -1
  310. package/shade/bundles/ngx-color-shade.umd.js +0 -382
  311. package/shade/bundles/ngx-color-shade.umd.js.map +0 -1
  312. package/shade/esm2015/ngx-color-shade.js +0 -5
  313. package/shade/esm2015/shade-picker.component.js +0 -63
  314. package/shade/fesm2015/ngx-color-shade.js +0 -70
  315. package/shade/fesm2015/ngx-color-shade.js.map +0 -1
  316. package/shade/ngx-color-shade.metadata.json +0 -1
  317. package/sketch/bundles/ngx-color-sketch.umd.js +0 -568
  318. package/sketch/bundles/ngx-color-sketch.umd.js.map +0 -1
  319. package/sketch/esm2015/ngx-color-sketch.js +0 -7
  320. package/sketch/esm2015/sketch-fields.component.js +0 -181
  321. package/sketch/esm2015/sketch-preset-colors.component.js +0 -76
  322. package/sketch/esm2015/sketch.component.js +0 -191
  323. package/sketch/fesm2015/ngx-color-sketch.js +0 -450
  324. package/sketch/fesm2015/ngx-color-sketch.js.map +0 -1
  325. package/sketch/ngx-color-sketch.metadata.json +0 -1
  326. package/slider/bundles/ngx-color-slider.umd.js +0 -453
  327. package/slider/bundles/ngx-color-slider.umd.js.map +0 -1
  328. package/slider/esm2015/ngx-color-slider.js +0 -7
  329. package/slider/esm2015/slider-swatch.component.js +0 -65
  330. package/slider/esm2015/slider-swatches.component.js +0 -84
  331. package/slider/esm2015/slider.component.js +0 -69
  332. package/slider/fesm2015/ngx-color-slider.js +0 -221
  333. package/slider/fesm2015/ngx-color-slider.js.map +0 -1
  334. package/slider/ngx-color-slider.metadata.json +0 -1
  335. package/swatches/bundles/ngx-color-swatches.umd.js +0 -595
  336. package/swatches/bundles/ngx-color-swatches.umd.js.map +0 -1
  337. package/swatches/esm2015/ngx-color-swatches.js +0 -7
  338. package/swatches/esm2015/swatches-color.component.js +0 -90
  339. package/swatches/esm2015/swatches-group.component.js +0 -42
  340. package/swatches/esm2015/swatches.component.js +0 -205
  341. package/swatches/fesm2015/ngx-color-swatches.js +0 -339
  342. package/swatches/fesm2015/ngx-color-swatches.js.map +0 -1
  343. package/swatches/ngx-color-swatches.metadata.json +0 -1
  344. package/twitter/bundles/ngx-color-twitter.umd.js +0 -416
  345. package/twitter/bundles/ngx-color-twitter.umd.js.map +0 -1
  346. package/twitter/esm2015/ngx-color-twitter.js +0 -5
  347. package/twitter/esm2015/twitter.component.js +0 -195
  348. package/twitter/fesm2015/ngx-color-twitter.js +0 -202
  349. package/twitter/fesm2015/ngx-color-twitter.js.map +0 -1
  350. package/twitter/ngx-color-twitter.metadata.json +0 -1
@@ -1,1166 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { Component, ChangeDetectionStrategy, Input, NgModule, Directive, ElementRef, Output, HostListener, EventEmitter } from '@angular/core';
3
- import { Subject, fromEvent } from 'rxjs';
4
- import { distinctUntilChanged, debounceTime } from 'rxjs/operators';
5
- import { TinyColor } from '@ctrl/tinycolor';
6
-
7
- const checkboardCache = {};
8
- function render(c1, c2, size) {
9
- if (typeof document === 'undefined') {
10
- return null;
11
- }
12
- const canvas = document.createElement('canvas');
13
- canvas.width = size * 2;
14
- canvas.height = size * 2;
15
- const ctx = canvas.getContext('2d');
16
- if (!ctx) {
17
- return null;
18
- } // If no context can be found, return early.
19
- ctx.fillStyle = c1;
20
- ctx.fillRect(0, 0, canvas.width, canvas.height);
21
- ctx.fillStyle = c2;
22
- ctx.fillRect(0, 0, size, size);
23
- ctx.translate(size, size);
24
- ctx.fillRect(0, 0, size, size);
25
- return canvas.toDataURL();
26
- }
27
- function getCheckerboard(c1, c2, size) {
28
- const key = `${c1}-${c2}-${size}`;
29
- if (checkboardCache[key]) {
30
- return checkboardCache[key];
31
- }
32
- const checkboard = render(c1, c2, size);
33
- if (!checkboard) {
34
- return null;
35
- }
36
- checkboardCache[key] = checkboard;
37
- return checkboard;
38
- }
39
-
40
- class CheckboardComponent {
41
- constructor() {
42
- this.white = 'transparent';
43
- this.size = 8;
44
- this.grey = 'rgba(0,0,0,.08)';
45
- }
46
- ngOnInit() {
47
- const background = getCheckerboard(this.white, this.grey, this.size);
48
- this.gridStyles = {
49
- borderRadius: this.borderRadius,
50
- boxShadow: this.boxShadow,
51
- background: `url(${background}) center left`,
52
- };
53
- }
54
- }
55
- CheckboardComponent.decorators = [
56
- { type: Component, args: [{
57
- selector: 'color-checkboard',
58
- template: `<div class="grid" [ngStyle]="gridStyles"></div>`,
59
- preserveWhitespaces: false,
60
- changeDetection: ChangeDetectionStrategy.OnPush,
61
- styles: [`
62
- .grid {
63
- top: 0px;
64
- right: 0px;
65
- bottom: 0px;
66
- left: 0px;
67
- position: absolute;
68
- }
69
- `]
70
- },] }
71
- ];
72
- CheckboardComponent.propDecorators = {
73
- white: [{ type: Input }],
74
- size: [{ type: Input }],
75
- grey: [{ type: Input }],
76
- boxShadow: [{ type: Input }],
77
- borderRadius: [{ type: Input }]
78
- };
79
- class CheckboardModule {
80
- }
81
- CheckboardModule.decorators = [
82
- { type: NgModule, args: [{
83
- declarations: [CheckboardComponent],
84
- exports: [CheckboardComponent],
85
- imports: [CommonModule],
86
- },] }
87
- ];
88
-
89
- class CoordinatesDirective {
90
- constructor(el) {
91
- this.el = el;
92
- this.coordinatesChange = new Subject();
93
- this.mousechange = new Subject();
94
- this.mouseListening = false;
95
- }
96
- mousemove($event, x, y, isTouch = false) {
97
- if (this.mouseListening) {
98
- $event.preventDefault();
99
- this.mousechange.next({ $event, x, y, isTouch });
100
- }
101
- }
102
- mouseup() {
103
- this.mouseListening = false;
104
- }
105
- mousedown($event, x, y, isTouch = false) {
106
- $event.preventDefault();
107
- this.mouseListening = true;
108
- this.mousechange.next({ $event, x, y, isTouch });
109
- }
110
- ngOnInit() {
111
- this.sub = this.mousechange
112
- .pipe(
113
- // limit times it is updated for the same area
114
- distinctUntilChanged((p, q) => p.x === q.x && p.y === q.y))
115
- .subscribe(n => this.handleChange(n.x, n.y, n.$event, n.isTouch));
116
- }
117
- ngOnDestroy() {
118
- this.sub.unsubscribe();
119
- }
120
- handleChange(x, y, $event, isTouch) {
121
- const containerWidth = this.el.nativeElement.clientWidth;
122
- const containerHeight = this.el.nativeElement.clientHeight;
123
- const left = x -
124
- (this.el.nativeElement.getBoundingClientRect().left + window.pageXOffset);
125
- let top = y - this.el.nativeElement.getBoundingClientRect().top;
126
- if (!isTouch) {
127
- top = top - window.pageYOffset;
128
- }
129
- this.coordinatesChange.next({
130
- x,
131
- y,
132
- top,
133
- left,
134
- containerWidth,
135
- containerHeight,
136
- $event,
137
- });
138
- }
139
- }
140
- CoordinatesDirective.decorators = [
141
- { type: Directive, args: [{ selector: '[ngx-color-coordinates]' },] }
142
- ];
143
- CoordinatesDirective.ctorParameters = () => [
144
- { type: ElementRef }
145
- ];
146
- CoordinatesDirective.propDecorators = {
147
- coordinatesChange: [{ type: Output }],
148
- mousemove: [{ type: HostListener, args: ['window:mousemove', ['$event', '$event.pageX', '$event.pageY'],] }, { type: HostListener, args: ['window:touchmove', [
149
- '$event',
150
- '$event.touches[0].clientX',
151
- '$event.touches[0].clientY',
152
- 'true',
153
- ],] }],
154
- mouseup: [{ type: HostListener, args: ['window:mouseup',] }, { type: HostListener, args: ['window:touchend',] }],
155
- mousedown: [{ type: HostListener, args: ['mousedown', ['$event', '$event.pageX', '$event.pageY'],] }, { type: HostListener, args: ['touchstart', [
156
- '$event',
157
- '$event.touches[0].clientX',
158
- '$event.touches[0].clientY',
159
- 'true',
160
- ],] }]
161
- };
162
- class CoordinatesModule {
163
- }
164
- CoordinatesModule.decorators = [
165
- { type: NgModule, args: [{
166
- declarations: [CoordinatesDirective],
167
- exports: [CoordinatesDirective],
168
- },] }
169
- ];
170
-
171
- class AlphaComponent {
172
- constructor() {
173
- this.direction = 'horizontal';
174
- this.onChange = new EventEmitter();
175
- }
176
- ngOnChanges() {
177
- if (this.direction === 'vertical') {
178
- this.pointerLeft = 0;
179
- this.pointerTop = this.rgb.a * 100;
180
- this.gradient = {
181
- background: `linear-gradient(to bottom, rgba(${this.rgb.r},${this.rgb.g},${this.rgb.b}, 0) 0%,
182
- rgba(${this.rgb.r},${this.rgb.g},${this.rgb.b}, 1) 100%)`,
183
- };
184
- }
185
- else {
186
- this.gradient = {
187
- background: `linear-gradient(to right, rgba(${this.rgb.r},${this.rgb.g},${this.rgb.b}, 0) 0%,
188
- rgba(${this.rgb.r},${this.rgb.g},${this.rgb.b}, 1) 100%)`,
189
- };
190
- this.pointerLeft = this.rgb.a * 100;
191
- }
192
- }
193
- handleChange({ top, left, containerHeight, containerWidth, $event }) {
194
- let data;
195
- if (this.direction === 'vertical') {
196
- let a;
197
- if (top < 0) {
198
- a = 0;
199
- }
200
- else if (top > containerHeight) {
201
- a = 1;
202
- }
203
- else {
204
- a = Math.round(top * 100 / containerHeight) / 100;
205
- }
206
- if (this.hsl.a !== a) {
207
- data = {
208
- h: this.hsl.h,
209
- s: this.hsl.s,
210
- l: this.hsl.l,
211
- a,
212
- source: 'rgb',
213
- };
214
- }
215
- }
216
- else {
217
- let a;
218
- if (left < 0) {
219
- a = 0;
220
- }
221
- else if (left > containerWidth) {
222
- a = 1;
223
- }
224
- else {
225
- a = Math.round(left * 100 / containerWidth) / 100;
226
- }
227
- if (this.hsl.a !== a) {
228
- data = {
229
- h: this.hsl.h,
230
- s: this.hsl.s,
231
- l: this.hsl.l,
232
- a,
233
- source: 'rgb',
234
- };
235
- }
236
- }
237
- if (!data) {
238
- return;
239
- }
240
- this.onChange.emit({ data, $event });
241
- }
242
- }
243
- AlphaComponent.decorators = [
244
- { type: Component, args: [{
245
- selector: 'color-alpha',
246
- template: `
247
- <div class="alpha" [style.border-radius]="radius">
248
- <div class="alpha-checkboard">
249
- <color-checkboard></color-checkboard>
250
- </div>
251
- <div class="alpha-gradient" [ngStyle]="gradient" [style.box-shadow]="shadow" [style.border-radius]="radius"></div>
252
- <div ngx-color-coordinates (coordinatesChange)="handleChange($event)" class="alpha-container color-alpha-{{direction}}">
253
- <div class="alpha-pointer" [style.left.%]="pointerLeft" [style.top.%]="pointerTop">
254
- <div class="alpha-slider" [ngStyle]="pointer"></div>
255
- </div>
256
- </div>
257
- </div>
258
- `,
259
- changeDetection: ChangeDetectionStrategy.OnPush,
260
- preserveWhitespaces: false,
261
- styles: [`
262
- .alpha {
263
- position: absolute;
264
- top: 0;
265
- bottom: 0;
266
- left: 0;
267
- right: 0;
268
- }
269
- .alpha-checkboard {
270
- position: absolute;
271
- top: 0;
272
- bottom: 0;
273
- left: 0;
274
- right: 0;
275
- overflow: hidden;
276
- }
277
- .alpha-gradient {
278
- position: absolute;
279
- top: 0;
280
- bottom: 0;
281
- left: 0;
282
- right: 0;
283
- }
284
- .alpha-container {
285
- position: relative;
286
- height: 100%;
287
- margin: 0 3px;
288
- }
289
- .alpha-pointer {
290
- position: absolute;
291
- }
292
- .alpha-slider {
293
- width: 4px;
294
- border-radius: 1px;
295
- height: 8px;
296
- box-shadow: 0 0 2px rgba(0, 0, 0, .6);
297
- background: #fff;
298
- margin-top: 1px;
299
- transform: translateX(-2px);
300
- }
301
- `]
302
- },] }
303
- ];
304
- AlphaComponent.propDecorators = {
305
- hsl: [{ type: Input }],
306
- rgb: [{ type: Input }],
307
- pointer: [{ type: Input }],
308
- shadow: [{ type: Input }],
309
- radius: [{ type: Input }],
310
- direction: [{ type: Input }],
311
- onChange: [{ type: Output }]
312
- };
313
- class AlphaModule {
314
- }
315
- AlphaModule.decorators = [
316
- { type: NgModule, args: [{
317
- declarations: [AlphaComponent],
318
- exports: [AlphaComponent],
319
- imports: [CommonModule, CheckboardModule, CoordinatesModule],
320
- },] }
321
- ];
322
-
323
- function simpleCheckForValidColor(data) {
324
- const keysToCheck = ['r', 'g', 'b', 'a', 'h', 's', 'l', 'v'];
325
- let checked = 0;
326
- let passed = 0;
327
- keysToCheck.forEach(letter => {
328
- if (!data[letter]) {
329
- return;
330
- }
331
- checked += 1;
332
- if (!isNaN(data[letter])) {
333
- passed += 1;
334
- }
335
- if (letter === 's' || letter === 'l') {
336
- const percentPatt = /^\d+%$/;
337
- if (percentPatt.test(data[letter])) {
338
- passed += 1;
339
- }
340
- }
341
- });
342
- return checked === passed ? data : false;
343
- }
344
- function toState(data, oldHue, disableAlpha) {
345
- const color = data.hex ? new TinyColor(data.hex) : new TinyColor(data);
346
- if (disableAlpha) {
347
- color.setAlpha(1);
348
- }
349
- const hsl = color.toHsl();
350
- const hsv = color.toHsv();
351
- const rgb = color.toRgb();
352
- const hex = color.toHex();
353
- if (hsl.s === 0) {
354
- hsl.h = oldHue || 0;
355
- hsv.h = oldHue || 0;
356
- }
357
- const transparent = hex === '000000' && rgb.a === 0;
358
- return {
359
- hsl,
360
- hex: transparent ? 'transparent' : color.toHexString(),
361
- rgb,
362
- hsv,
363
- oldHue: data.h || oldHue || hsl.h,
364
- source: data.source,
365
- };
366
- }
367
- function isValidHex(hex) {
368
- return new TinyColor(hex).isValid;
369
- }
370
- function getContrastingColor(data) {
371
- if (!data) {
372
- return '#fff';
373
- }
374
- const col = toState(data);
375
- if (col.hex === 'transparent') {
376
- return 'rgba(0,0,0,0.4)';
377
- }
378
- const yiq = (col.rgb.r * 299 + col.rgb.g * 587 + col.rgb.b * 114) / 1000;
379
- return yiq >= 128 ? '#000' : '#fff';
380
- }
381
-
382
- class ColorWrap {
383
- constructor() {
384
- this.color = {
385
- h: 250,
386
- s: 0.5,
387
- l: 0.2,
388
- a: 1,
389
- };
390
- this.onChange = new EventEmitter();
391
- this.onChangeComplete = new EventEmitter();
392
- this.onSwatchHover = new EventEmitter();
393
- }
394
- ngOnInit() {
395
- this.changes = this.onChange
396
- .pipe(debounceTime(100))
397
- .subscribe(x => this.onChangeComplete.emit(x));
398
- this.setState(toState(this.color, 0));
399
- this.currentColor = this.hex;
400
- }
401
- ngOnChanges() {
402
- this.setState(toState(this.color, this.oldHue));
403
- }
404
- ngOnDestroy() {
405
- this.changes.unsubscribe();
406
- }
407
- setState(data) {
408
- this.oldHue = data.oldHue;
409
- this.hsl = data.hsl;
410
- this.hsv = data.hsv;
411
- this.rgb = data.rgb;
412
- this.hex = data.hex;
413
- this.source = data.source;
414
- this.afterValidChange();
415
- }
416
- handleChange(data, $event) {
417
- const isValidColor = simpleCheckForValidColor(data);
418
- if (isValidColor) {
419
- const color = toState(data, data.h || this.oldHue, this.disableAlpha);
420
- this.setState(color);
421
- this.onChange.emit({ color, $event });
422
- this.afterValidChange();
423
- }
424
- }
425
- /** hook for components after a complete change */
426
- afterValidChange() { }
427
- handleSwatchHover(data, $event) {
428
- const isValidColor = simpleCheckForValidColor(data);
429
- if (isValidColor) {
430
- const color = toState(data, data.h || this.oldHue);
431
- this.setState(color);
432
- this.onSwatchHover.emit({ color, $event });
433
- }
434
- }
435
- }
436
- ColorWrap.decorators = [
437
- { type: Component, args: [{
438
- // create seletor base for test override property
439
- selector: 'color-wrap',
440
- template: ``
441
- },] }
442
- ];
443
- ColorWrap.propDecorators = {
444
- className: [{ type: Input }],
445
- color: [{ type: Input }],
446
- onChange: [{ type: Output }],
447
- onChangeComplete: [{ type: Output }],
448
- onSwatchHover: [{ type: Output }]
449
- };
450
- class ColorWrapModule {
451
- }
452
- ColorWrapModule.decorators = [
453
- { type: NgModule, args: [{
454
- declarations: [ColorWrap],
455
- exports: [ColorWrap],
456
- imports: [CommonModule],
457
- },] }
458
- ];
459
-
460
- let nextUniqueId = 0;
461
- class EditableInputComponent {
462
- constructor() {
463
- this.placeholder = '';
464
- this.onChange = new EventEmitter();
465
- this.focus = false;
466
- this.uniqueId = `editableInput-${++nextUniqueId}`;
467
- }
468
- ngOnInit() {
469
- this.wrapStyle = this.style && this.style.wrap ? this.style.wrap : {};
470
- this.inputStyle = this.style && this.style.input ? this.style.input : {};
471
- this.labelStyle = this.style && this.style.label ? this.style.label : {};
472
- if (this.dragLabel) {
473
- this.labelStyle.cursor = 'ew-resize';
474
- }
475
- }
476
- handleFocus($event) {
477
- this.focus = true;
478
- }
479
- handleFocusOut($event) {
480
- this.focus = false;
481
- this.currentValue = this.blurValue;
482
- }
483
- handleKeydown($event) {
484
- // In case `e.target.value` is a percentage remove the `%` character
485
- // and update accordingly with a percentage
486
- // https://github.com/casesandberg/react-color/issues/383
487
- const stringValue = String($event.target.value);
488
- const isPercentage = stringValue.indexOf('%') > -1;
489
- const num = Number(stringValue.replace(/%/g, ''));
490
- if (isNaN(num)) {
491
- return;
492
- }
493
- const amount = this.arrowOffset || 1;
494
- // Up
495
- if ($event.keyCode === 38) {
496
- if (this.label) {
497
- this.onChange.emit({
498
- data: { [this.label]: num + amount },
499
- $event,
500
- });
501
- }
502
- else {
503
- this.onChange.emit({ data: num + amount, $event });
504
- }
505
- if (isPercentage) {
506
- this.currentValue = `${num + amount}%`;
507
- }
508
- else {
509
- this.currentValue = num + amount;
510
- }
511
- }
512
- // Down
513
- if ($event.keyCode === 40) {
514
- if (this.label) {
515
- this.onChange.emit({
516
- data: { [this.label]: num - amount },
517
- $event,
518
- });
519
- }
520
- else {
521
- this.onChange.emit({ data: num - amount, $event });
522
- }
523
- if (isPercentage) {
524
- this.currentValue = `${num - amount}%`;
525
- }
526
- else {
527
- this.currentValue = num - amount;
528
- }
529
- }
530
- }
531
- handleKeyup($event) {
532
- if ($event.keyCode === 40 || $event.keyCode === 38) {
533
- return;
534
- }
535
- if (`${this.currentValue}` === $event.target.value) {
536
- return;
537
- }
538
- if (this.label) {
539
- this.onChange.emit({
540
- data: { [this.label]: $event.target.value },
541
- $event,
542
- });
543
- }
544
- else {
545
- this.onChange.emit({ data: $event.target.value, $event });
546
- }
547
- }
548
- ngOnChanges() {
549
- if (!this.focus) {
550
- this.currentValue = String(this.value).toUpperCase();
551
- this.blurValue = String(this.value).toUpperCase();
552
- }
553
- else {
554
- this.blurValue = String(this.value).toUpperCase();
555
- }
556
- }
557
- ngOnDestroy() {
558
- this.unsubscribe();
559
- }
560
- subscribe() {
561
- this.mousemove = fromEvent(document, 'mousemove').subscribe((ev) => this.handleDrag(ev));
562
- this.mouseup = fromEvent(document, 'mouseup').subscribe(() => this.unsubscribe());
563
- }
564
- unsubscribe() {
565
- if (this.mousemove) {
566
- this.mousemove.unsubscribe();
567
- }
568
- if (this.mouseup) {
569
- this.mouseup.unsubscribe();
570
- }
571
- }
572
- handleMousedown($event) {
573
- if (this.dragLabel) {
574
- $event.preventDefault();
575
- this.handleDrag($event);
576
- this.subscribe();
577
- }
578
- }
579
- handleDrag($event) {
580
- if (this.dragLabel) {
581
- const newValue = Math.round(this.value + $event.movementX);
582
- if (newValue >= 0 && newValue <= this.dragMax) {
583
- this.onChange.emit({ data: { [this.label]: newValue }, $event });
584
- }
585
- }
586
- }
587
- }
588
- EditableInputComponent.decorators = [
589
- { type: Component, args: [{
590
- selector: 'color-editable-input',
591
- template: `
592
- <div class="wrap" [ngStyle]="wrapStyle">
593
- <input
594
- [ngStyle]="inputStyle"
595
- spellCheck="false"
596
- [value]="currentValue"
597
- [placeholder]="placeholder"
598
- (keydown)="handleKeydown($event)"
599
- (keyup)="handleKeyup($event)"
600
- (focus)="handleFocus($event)"
601
- (focusout)="handleFocusOut($event)"
602
- [attr.aria-labelledby]="uniqueId"
603
- />
604
- <span [id]="uniqueId" *ngIf="label" [ngStyle]="labelStyle" (mousedown)="handleMousedown($event)">
605
- {{ label }}
606
- </span>
607
- </div>
608
- `,
609
- changeDetection: ChangeDetectionStrategy.OnPush,
610
- styles: [`
611
- :host {
612
- display: flex;
613
- }
614
- .wrap {
615
- position: relative;
616
- }
617
- `]
618
- },] }
619
- ];
620
- EditableInputComponent.propDecorators = {
621
- style: [{ type: Input }],
622
- label: [{ type: Input }],
623
- value: [{ type: Input }],
624
- arrowOffset: [{ type: Input }],
625
- dragLabel: [{ type: Input }],
626
- dragMax: [{ type: Input }],
627
- placeholder: [{ type: Input }],
628
- onChange: [{ type: Output }]
629
- };
630
- class EditableInputModule {
631
- }
632
- EditableInputModule.decorators = [
633
- { type: NgModule, args: [{
634
- declarations: [EditableInputComponent],
635
- exports: [EditableInputComponent],
636
- imports: [CommonModule],
637
- },] }
638
- ];
639
-
640
- class HueComponent {
641
- constructor() {
642
- this.hidePointer = false;
643
- this.direction = 'horizontal';
644
- this.onChange = new EventEmitter();
645
- this.left = '0px';
646
- this.top = '';
647
- }
648
- ngOnChanges() {
649
- if (this.direction === 'horizontal') {
650
- this.left = `${this.hsl.h * 100 / 360}%`;
651
- }
652
- else {
653
- this.top = `${-(this.hsl.h * 100 / 360) + 100}%`;
654
- }
655
- }
656
- handleChange({ top, left, containerHeight, containerWidth, $event }) {
657
- let data;
658
- if (this.direction === 'vertical') {
659
- let h;
660
- if (top < 0) {
661
- h = 359;
662
- }
663
- else if (top > containerHeight) {
664
- h = 0;
665
- }
666
- else {
667
- const percent = -(top * 100 / containerHeight) + 100;
668
- h = 360 * percent / 100;
669
- }
670
- if (this.hsl.h !== h) {
671
- data = {
672
- h,
673
- s: this.hsl.s,
674
- l: this.hsl.l,
675
- a: this.hsl.a,
676
- source: 'rgb',
677
- };
678
- }
679
- }
680
- else {
681
- let h;
682
- if (left < 0) {
683
- h = 0;
684
- }
685
- else if (left > containerWidth) {
686
- h = 359;
687
- }
688
- else {
689
- const percent = left * 100 / containerWidth;
690
- h = 360 * percent / 100;
691
- }
692
- if (this.hsl.h !== h) {
693
- data = {
694
- h,
695
- s: this.hsl.s,
696
- l: this.hsl.l,
697
- a: this.hsl.a,
698
- source: 'rgb',
699
- };
700
- }
701
- }
702
- if (!data) {
703
- return;
704
- }
705
- this.onChange.emit({ data, $event });
706
- }
707
- }
708
- HueComponent.decorators = [
709
- { type: Component, args: [{
710
- selector: 'color-hue',
711
- template: `
712
- <div class="color-hue color-hue-{{direction}}" [style.border-radius.px]="radius" [style.box-shadow]="shadow">
713
- <div ngx-color-coordinates (coordinatesChange)="handleChange($event)" class="color-hue-container">
714
- <div class="color-hue-pointer" [style.left]="left" [style.top]="top" *ngIf="!hidePointer">
715
- <div class="color-hue-slider" [ngStyle]="pointer"></div>
716
- </div>
717
- </div>
718
- </div>
719
- `,
720
- preserveWhitespaces: false,
721
- changeDetection: ChangeDetectionStrategy.OnPush,
722
- styles: [`
723
- .color-hue {
724
- position: absolute;
725
- top: 0;
726
- bottom: 0;
727
- left: 0;
728
- right: 0;
729
- }
730
- .color-hue-container {
731
- margin: 0 2px;
732
- position: relative;
733
- height: 100%;
734
- }
735
- .color-hue-pointer {
736
- position: absolute;
737
- }
738
- .color-hue-slider {
739
- margin-top: 1px;
740
- width: 4px;
741
- border-radius: 1px;
742
- height: 8px;
743
- box-shadow: 0 0 2px rgba(0, 0, 0, .6);
744
- background: #fff;
745
- transform: translateX(-2px);
746
- }
747
- .color-hue-horizontal {
748
- background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0
749
- 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
750
- }
751
- .color-hue-vertical {
752
- background: linear-gradient(to top, #f00 0%, #ff0 17%, #0f0 33%,
753
- #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
754
- }
755
- `]
756
- },] }
757
- ];
758
- HueComponent.propDecorators = {
759
- hsl: [{ type: Input }],
760
- pointer: [{ type: Input }],
761
- radius: [{ type: Input }],
762
- shadow: [{ type: Input }],
763
- hidePointer: [{ type: Input }],
764
- direction: [{ type: Input }],
765
- onChange: [{ type: Output }]
766
- };
767
- class HueModule {
768
- }
769
- HueModule.decorators = [
770
- { type: NgModule, args: [{
771
- declarations: [HueComponent],
772
- exports: [HueComponent],
773
- imports: [CommonModule, CoordinatesModule],
774
- },] }
775
- ];
776
-
777
- class RaisedComponent {
778
- constructor() {
779
- this.zDepth = 1;
780
- this.radius = 1;
781
- this.background = '#fff';
782
- }
783
- }
784
- RaisedComponent.decorators = [
785
- { type: Component, args: [{
786
- selector: 'color-raised',
787
- template: `
788
- <div class="raised-wrap">
789
- <div class="raised-bg zDepth-{{zDepth}}" [style.background]="background"></div>
790
- <div class="raised-content">
791
- <ng-content></ng-content>
792
- </div>
793
- </div>
794
- `,
795
- preserveWhitespaces: false,
796
- changeDetection: ChangeDetectionStrategy.OnPush,
797
- styles: [`
798
- .raised-wrap {
799
- position: relative;
800
- display: inline-block;
801
- }
802
- .raised-bg {
803
- position: absolute;
804
- top: 0px;
805
- right: 0px;
806
- bottom: 0px;
807
- left: 0px;
808
- }
809
- .raised-content {
810
- position: relative;
811
- }
812
- .zDepth-0 {
813
- box-shadow: none;
814
- }
815
- .zDepth-1 {
816
- box-shadow: 0 2px 10px rgba(0,0,0,.12), 0 2px 5px rgba(0,0,0,.16);
817
- }
818
- .zDepth-2 {
819
- box-shadow: 0 6px 20px rgba(0,0,0,.19), 0 8px 17px rgba(0,0,0,.2);
820
- }
821
- .zDepth-3 {
822
- box-shadow: 0 17px 50px rgba(0,0,0,.19), 0 12px 15px rgba(0,0,0,.24);
823
- }
824
- .zDepth-4 {
825
- box-shadow: 0 25px 55px rgba(0,0,0,.21), 0 16px 28px rgba(0,0,0,.22);
826
- }
827
- .zDepth-5 {
828
- box-shadow: 0 40px 77px rgba(0,0,0,.22), 0 27px 24px rgba(0,0,0,.2);
829
- }
830
- `]
831
- },] }
832
- ];
833
- RaisedComponent.propDecorators = {
834
- zDepth: [{ type: Input }],
835
- radius: [{ type: Input }],
836
- background: [{ type: Input }]
837
- };
838
- class RaisedModule {
839
- }
840
- RaisedModule.decorators = [
841
- { type: NgModule, args: [{
842
- declarations: [RaisedComponent],
843
- exports: [RaisedComponent],
844
- imports: [CommonModule],
845
- },] }
846
- ];
847
-
848
- class SaturationComponent {
849
- constructor() {
850
- this.onChange = new EventEmitter();
851
- }
852
- ngOnChanges() {
853
- this.background = `hsl(${this.hsl.h}, 100%, 50%)`;
854
- this.pointerTop = -(this.hsv.v * 100) + 1 + 100 + '%';
855
- this.pointerLeft = this.hsv.s * 100 + '%';
856
- }
857
- handleChange({ top, left, containerHeight, containerWidth, $event }) {
858
- if (left < 0) {
859
- left = 0;
860
- }
861
- else if (left > containerWidth) {
862
- left = containerWidth;
863
- }
864
- else if (top < 0) {
865
- top = 0;
866
- }
867
- else if (top > containerHeight) {
868
- top = containerHeight;
869
- }
870
- const saturation = left / containerWidth;
871
- let bright = -(top / containerHeight) + 1;
872
- bright = bright > 0 ? bright : 0;
873
- bright = bright > 1 ? 1 : bright;
874
- const data = {
875
- h: this.hsl.h,
876
- s: saturation,
877
- v: bright,
878
- a: this.hsl.a,
879
- source: 'hsva',
880
- };
881
- this.onChange.emit({ data, $event });
882
- }
883
- }
884
- SaturationComponent.decorators = [
885
- { type: Component, args: [{
886
- selector: 'color-saturation',
887
- template: `
888
- <div class="color-saturation" ngx-color-coordinates (coordinatesChange)="handleChange($event)" [style.background]="background">
889
- <div class="saturation-white">
890
- <div class="saturation-black"></div>
891
- <div class="saturation-pointer" [ngStyle]="pointer" [style.top]="pointerTop" [style.left]="pointerLeft">
892
- <div class="saturation-circle" [ngStyle]="circle"></div>
893
- </div>
894
- </div>
895
- </div>
896
- `,
897
- preserveWhitespaces: false,
898
- changeDetection: ChangeDetectionStrategy.OnPush,
899
- styles: [`
900
- .saturation-white {
901
- background: linear-gradient(to right, #fff, rgba(255,255,255,0));
902
- position: absolute;
903
- top: 0;
904
- bottom: 0;
905
- left: 0;
906
- right: 0;
907
- }
908
- .saturation-black {
909
- background: linear-gradient(to top, #000, rgba(0,0,0,0));
910
- position: absolute;
911
- top: 0;
912
- bottom: 0;
913
- left: 0;
914
- right: 0;
915
- }
916
- .color-saturation {
917
- position: absolute;
918
- top: 0;
919
- bottom: 0;
920
- left: 0;
921
- right: 0;
922
- }
923
- .saturation-pointer {
924
- position: absolute;
925
- cursor: default;
926
- }
927
- .saturation-circle {
928
- width: 4px;
929
- height: 4px;
930
- box-shadow: 0 0 0 1.5px #fff, inset 0 0 1px 1px rgba(0,0,0,.3), 0 0 1px 2px rgba(0,0,0,.4);
931
- border-radius: 50%;
932
- cursor: hand;
933
- transform: translate(-2px, -4px);
934
- }
935
- `]
936
- },] }
937
- ];
938
- SaturationComponent.propDecorators = {
939
- hsl: [{ type: Input }],
940
- hsv: [{ type: Input }],
941
- radius: [{ type: Input }],
942
- pointer: [{ type: Input }],
943
- circle: [{ type: Input }],
944
- onChange: [{ type: Output }]
945
- };
946
- class SaturationModule {
947
- }
948
- SaturationModule.decorators = [
949
- { type: NgModule, args: [{
950
- declarations: [SaturationComponent],
951
- exports: [SaturationComponent],
952
- imports: [CommonModule, CoordinatesModule],
953
- },] }
954
- ];
955
-
956
- class SwatchComponent {
957
- constructor() {
958
- this.style = {};
959
- this.focusStyle = {};
960
- this.onClick = new EventEmitter();
961
- this.onHover = new EventEmitter();
962
- this.divStyles = {};
963
- this.focusStyles = {};
964
- this.inFocus = false;
965
- }
966
- ngOnInit() {
967
- this.divStyles = Object.assign({ background: this.color }, this.style);
968
- }
969
- currentStyles() {
970
- this.focusStyles = Object.assign(Object.assign({}, this.divStyles), this.focusStyle);
971
- return this.focus || this.inFocus ? this.focusStyles : this.divStyles;
972
- }
973
- handleFocusOut() {
974
- this.inFocus = false;
975
- }
976
- handleFocus() {
977
- this.inFocus = true;
978
- }
979
- handleHover(hex, $event) {
980
- this.onHover.emit({ hex, $event });
981
- }
982
- handleClick(hex, $event) {
983
- this.onClick.emit({ hex, $event });
984
- }
985
- }
986
- SwatchComponent.decorators = [
987
- { type: Component, args: [{
988
- selector: 'color-swatch',
989
- template: `
990
- <div
991
- class="swatch"
992
- [ngStyle]="currentStyles()"
993
- [attr.title]="color"
994
- (click)="handleClick(color, $event)"
995
- (keydown.enter)="handleClick(color, $event)"
996
- (focus)="handleFocus()"
997
- (blur)="handleFocusOut()"
998
- (mouseover)="handleHover(color, $event)"
999
- tabindex="0"
1000
- >
1001
- <ng-content></ng-content>
1002
- <color-checkboard
1003
- *ngIf="color === 'transparent'"
1004
- boxShadow="inset 0 0 0 1px rgba(0,0,0,0.1)"
1005
- ></color-checkboard>
1006
- </div>
1007
- `,
1008
- changeDetection: ChangeDetectionStrategy.OnPush,
1009
- styles: [`
1010
- .swatch {
1011
- outline: none;
1012
- height: 100%;
1013
- width: 100%;
1014
- cursor: pointer;
1015
- position: relative;
1016
- }
1017
- `]
1018
- },] }
1019
- ];
1020
- SwatchComponent.propDecorators = {
1021
- color: [{ type: Input }],
1022
- style: [{ type: Input }],
1023
- focusStyle: [{ type: Input }],
1024
- focus: [{ type: Input }],
1025
- onClick: [{ type: Output }],
1026
- onHover: [{ type: Output }]
1027
- };
1028
- class SwatchModule {
1029
- }
1030
- SwatchModule.decorators = [
1031
- { type: NgModule, args: [{
1032
- declarations: [SwatchComponent],
1033
- exports: [SwatchComponent],
1034
- imports: [CommonModule, CheckboardModule],
1035
- },] }
1036
- ];
1037
-
1038
- class ShadeComponent {
1039
- constructor() {
1040
- this.onChange = new EventEmitter();
1041
- }
1042
- ngOnChanges() {
1043
- this.gradient = {
1044
- background: `linear-gradient(to right,
1045
- hsl(${this.hsl.h}, 90%, 55%),
1046
- #000)`,
1047
- };
1048
- const hsv = new TinyColor(this.hsl).toHsv();
1049
- this.pointerLeft = 100 - (hsv.v * 100);
1050
- }
1051
- handleChange({ left, containerWidth, $event }) {
1052
- let data;
1053
- let v;
1054
- if (left < 0) {
1055
- v = 0;
1056
- }
1057
- else if (left > containerWidth) {
1058
- v = 1;
1059
- }
1060
- else {
1061
- v = Math.round((left * 100) / containerWidth) / 100;
1062
- }
1063
- const hsv = new TinyColor(this.hsl).toHsv();
1064
- if (hsv.v !== v) {
1065
- data = {
1066
- h: this.hsl.h,
1067
- s: 100,
1068
- v: 1 - v,
1069
- l: this.hsl.l,
1070
- a: this.hsl.a,
1071
- source: 'rgb',
1072
- };
1073
- }
1074
- if (!data) {
1075
- return;
1076
- }
1077
- this.onChange.emit({ data, $event });
1078
- }
1079
- }
1080
- ShadeComponent.decorators = [
1081
- { type: Component, args: [{
1082
- selector: 'color-shade',
1083
- template: `
1084
- <div class="shade" [style.border-radius]="radius">
1085
- <div
1086
- class="shade-gradient"
1087
- [ngStyle]="gradient"
1088
- [style.box-shadow]="shadow"
1089
- [style.border-radius]="radius"
1090
- ></div>
1091
- <div
1092
- ngx-color-coordinates
1093
- (coordinatesChange)="handleChange($event)"
1094
- class="shade-container"
1095
- >
1096
- <div
1097
- class="shade-pointer"
1098
- [style.left.%]="pointerLeft"
1099
- [style.top.%]="pointerTop"
1100
- >
1101
- <div class="shade-slider" [ngStyle]="pointer"></div>
1102
- </div>
1103
- </div>
1104
- </div>
1105
- `,
1106
- changeDetection: ChangeDetectionStrategy.OnPush,
1107
- preserveWhitespaces: false,
1108
- styles: [`
1109
- .shade {
1110
- position: absolute;
1111
- top: 0;
1112
- bottom: 0;
1113
- left: 0;
1114
- right: 0;
1115
- }
1116
- .shade-gradient {
1117
- position: absolute;
1118
- top: 0;
1119
- bottom: 0;
1120
- left: 0;
1121
- right: 0;
1122
- }
1123
- .shade-container {
1124
- position: relative;
1125
- height: 100%;
1126
- margin: 0 3px;
1127
- }
1128
- .shade-pointer {
1129
- position: absolute;
1130
- }
1131
- .shade-slider {
1132
- width: 4px;
1133
- border-radius: 1px;
1134
- height: 8px;
1135
- box-shadow: 0 0 2px rgba(0, 0, 0, .6);
1136
- background: #fff;
1137
- margin-top: 1px;
1138
- transform: translateX(-2px);
1139
- }
1140
- `]
1141
- },] }
1142
- ];
1143
- ShadeComponent.propDecorators = {
1144
- hsl: [{ type: Input }],
1145
- rgb: [{ type: Input }],
1146
- pointer: [{ type: Input }],
1147
- shadow: [{ type: Input }],
1148
- radius: [{ type: Input }],
1149
- onChange: [{ type: Output }]
1150
- };
1151
- class ShadeModule {
1152
- }
1153
- ShadeModule.decorators = [
1154
- { type: NgModule, args: [{
1155
- declarations: [ShadeComponent],
1156
- exports: [ShadeComponent],
1157
- imports: [CommonModule, CoordinatesModule],
1158
- },] }
1159
- ];
1160
-
1161
- /**
1162
- * Generated bundle index. Do not edit.
1163
- */
1164
-
1165
- export { AlphaComponent, AlphaModule, CheckboardComponent, CheckboardModule, ColorWrap, ColorWrapModule, CoordinatesDirective, CoordinatesModule, EditableInputComponent, EditableInputModule, HueComponent, HueModule, RaisedComponent, RaisedModule, SaturationComponent, SaturationModule, ShadeComponent, ShadeModule, SwatchComponent, SwatchModule, getCheckerboard, getContrastingColor, isValidHex, render, simpleCheckForValidColor, toState };
1166
- //# sourceMappingURL=ngx-color.js.map