ngx-color 7.0.1 → 7.3.0

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