@esri/solutions-components 0.3.5 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) hide show
  1. package/dist/cjs/buffer-tools_6.cjs.entry.js +26 -8
  2. package/dist/cjs/calcite-combobox_3.cjs.entry.js +2 -2
  3. package/dist/cjs/calcite-input-message_5.cjs.entry.js +6 -4
  4. package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +2 -2
  5. package/dist/cjs/{csvUtils-83af7ae1.js → csvUtils-34666909.js} +1 -1
  6. package/dist/cjs/{interfaces-772edf61.js → interfaces-17c631bf.js} +1 -1
  7. package/dist/cjs/layer-table.cjs.entry.js +3 -3
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/map-card.cjs.entry.js +1 -1
  10. package/dist/cjs/{mapViewUtils-55ac76cb.js → mapViewUtils-24d1d859.js} +1 -1
  11. package/dist/cjs/public-notification.cjs.entry.js +41 -7
  12. package/dist/cjs/solution-configuration.cjs.entry.js +2 -2
  13. package/dist/cjs/solution-contents_3.cjs.entry.js +2 -2
  14. package/dist/cjs/{solution-store-39726b81.js → solution-store-2dbab624.js} +1 -1
  15. package/dist/cjs/solutions-components.cjs.js +1 -1
  16. package/dist/collection/components/buffer-tools/buffer-tools.js +48 -0
  17. package/dist/collection/components/map-draw-tools/map-draw-tools.js +10 -4
  18. package/dist/collection/components/public-notification/public-notification.css +12 -12
  19. package/dist/collection/components/public-notification/public-notification.js +50 -4
  20. package/dist/collection/components/refine-selection/refine-selection.js +4 -2
  21. package/dist/collection/components/refine-selection-tools/refine-selection-tools.css +1 -0
  22. package/dist/collection/components/refine-selection-tools/refine-selection-tools.js +3 -1
  23. package/dist/collection/demos/new-public-notification.html +7 -6
  24. package/dist/collection/utils/interfaces.js +1 -1
  25. package/dist/collection/utils/interfaces.ts +7 -2
  26. package/dist/components/buffer-tools2.js +10 -0
  27. package/dist/components/interfaces3.js +1 -1
  28. package/dist/components/map-draw-tools2.js +10 -4
  29. package/dist/components/public-notification.js +40 -6
  30. package/dist/components/refine-selection-tools2.js +4 -2
  31. package/dist/components/refine-selection2.js +4 -2
  32. package/dist/esm/buffer-tools_6.entry.js +26 -8
  33. package/dist/esm/calcite-combobox_3.entry.js +2 -2
  34. package/dist/esm/calcite-input-message_5.entry.js +6 -4
  35. package/dist/esm/calcite-shell-panel_14.entry.js +2 -2
  36. package/dist/esm/{csvUtils-eb231cfb.js → csvUtils-ae3004b9.js} +1 -1
  37. package/dist/esm/{interfaces-3b23a5f9.js → interfaces-d0d83efa.js} +1 -1
  38. package/dist/esm/layer-table.entry.js +3 -3
  39. package/dist/esm/loader.js +1 -1
  40. package/dist/esm/map-card.entry.js +1 -1
  41. package/dist/esm/{mapViewUtils-e5d8a1e1.js → mapViewUtils-541e7a3c.js} +1 -1
  42. package/dist/esm/public-notification.entry.js +41 -7
  43. package/dist/esm/solution-configuration.entry.js +2 -2
  44. package/dist/esm/solution-contents_3.entry.js +2 -2
  45. package/dist/esm/{solution-store-c0bf9200.js → solution-store-41e15f1c.js} +1 -1
  46. package/dist/esm/solutions-components.js +1 -1
  47. package/dist/solutions-components/demos/new-public-notification.html +7 -6
  48. package/dist/solutions-components/p-05e64bd1.js +498 -2
  49. package/dist/solutions-components/p-08a95b33.entry.js +138 -0
  50. package/dist/solutions-components/p-0da5bbdf.entry.js +91 -0
  51. package/dist/solutions-components/p-0ef91144.entry.js +913 -0
  52. package/dist/solutions-components/p-0f523243.entry.js +1916 -0
  53. package/dist/solutions-components/p-11b9510e.entry.js +173 -0
  54. package/dist/solutions-components/p-1b875d94.entry.js +58 -0
  55. package/dist/solutions-components/p-1c567f3a.js +23 -16
  56. package/dist/solutions-components/p-1c883db9.entry.js +43 -0
  57. package/dist/solutions-components/p-1f225056.js +322 -0
  58. package/dist/solutions-components/p-1f499e67.entry.js +72 -0
  59. package/dist/solutions-components/p-20d3d758.entry.js +881 -0
  60. package/dist/solutions-components/p-2274ac9e.entry.js +160 -0
  61. package/dist/solutions-components/p-23ec5ac5.entry.js +93 -0
  62. package/dist/solutions-components/p-2447798c.entry.js +155 -0
  63. package/dist/solutions-components/p-2525e691.entry.js +432 -0
  64. package/dist/solutions-components/p-2561f5b5.js +4092 -0
  65. package/dist/solutions-components/p-29f887c0.entry.js +234 -0
  66. package/dist/solutions-components/p-2a0d8047.entry.js +345 -0
  67. package/dist/solutions-components/p-2c177e6a.entry.js +101 -0
  68. package/dist/solutions-components/p-2e9ed892.js +46 -1
  69. package/dist/solutions-components/p-316f56db.js +219 -2
  70. package/dist/solutions-components/p-327f3ebf.entry.js +98 -0
  71. package/dist/solutions-components/p-356f8b54.entry.js +138 -0
  72. package/dist/solutions-components/p-359c58de.entry.js +172 -0
  73. package/dist/solutions-components/p-37336c0d.entry.js +116 -0
  74. package/dist/solutions-components/p-374a5031.js +105 -2
  75. package/dist/solutions-components/p-39ea6ef4.entry.js +71 -0
  76. package/dist/solutions-components/p-3b010ce1.js +17 -1
  77. package/dist/solutions-components/p-4307dacd.js +194 -1
  78. package/dist/solutions-components/p-44da2507.js +405 -14
  79. package/dist/solutions-components/p-46bdffe8.entry.js +54 -0
  80. package/dist/solutions-components/p-4894bbeb.js +53 -2
  81. package/dist/solutions-components/p-4cd569f1.entry.js +1298 -0
  82. package/dist/solutions-components/p-4d4160f9.entry.js +121 -0
  83. package/dist/solutions-components/p-4e32bf8c.js +482 -1
  84. package/dist/solutions-components/p-4e9cbd32.entry.js +184 -0
  85. package/dist/solutions-components/p-508317b3.js +13 -2
  86. package/dist/solutions-components/p-54697d58.entry.js +198 -0
  87. package/dist/solutions-components/p-55c79103.entry.js +311 -0
  88. package/dist/solutions-components/p-57fd19c0.entry.js +706 -0
  89. package/dist/solutions-components/p-59b48fde.entry.js +443 -0
  90. package/dist/solutions-components/p-60e0e6a0.entry.js +214 -0
  91. package/dist/solutions-components/p-621d0534.entry.js +123 -0
  92. package/dist/solutions-components/p-63f6e8f1.js +14 -1
  93. package/dist/solutions-components/p-66aeec57.entry.js +61 -0
  94. package/dist/solutions-components/p-69834f46.entry.js +618 -0
  95. package/dist/solutions-components/p-6d9da8e5.entry.js +21530 -0
  96. package/dist/solutions-components/p-6e0da576.js +13 -1
  97. package/dist/solutions-components/p-6ec3f294.entry.js +106 -0
  98. package/dist/solutions-components/p-6fe17794.js +9 -1
  99. package/dist/solutions-components/p-7024cb16.entry.js +72 -0
  100. package/dist/solutions-components/p-70535506.entry.js +226 -0
  101. package/dist/solutions-components/p-708a63a8.js +12 -1
  102. package/dist/solutions-components/p-729708a3.js +14 -1
  103. package/dist/solutions-components/p-73e23995.js +6 -1
  104. package/dist/solutions-components/p-74b29d75.entry.js +231 -0
  105. package/dist/solutions-components/p-74b7ee25.entry.js +711 -0
  106. package/dist/solutions-components/p-77182c3a.js +3015 -1
  107. package/dist/solutions-components/p-78b3ef80.entry.js +456 -0
  108. package/dist/solutions-components/p-79709c19.js +60 -3
  109. package/dist/solutions-components/p-7a46ef97.js +181 -2
  110. package/dist/solutions-components/p-7be159e6.entry.js +175 -0
  111. package/dist/solutions-components/p-7d4451c2.entry.js +71 -0
  112. package/dist/solutions-components/p-7daea1df.js +41 -1
  113. package/dist/solutions-components/p-7e39e5ad.entry.js +102 -0
  114. package/dist/solutions-components/p-7fb45059.entry.js +43 -0
  115. package/dist/solutions-components/p-815533de.js +306 -3
  116. package/dist/solutions-components/p-816622ca.entry.js +248 -0
  117. package/dist/solutions-components/p-83166522.js +205 -2
  118. package/dist/solutions-components/p-83bd1991.entry.js +36 -0
  119. package/dist/solutions-components/p-856464d7.entry.js +572 -0
  120. package/dist/solutions-components/p-8c349bad.entry.js +347 -0
  121. package/dist/solutions-components/p-8dccb390.entry.js +1986 -0
  122. package/dist/solutions-components/p-904c185a.entry.js +228 -0
  123. package/dist/solutions-components/p-9092f8b3.entry.js +156 -0
  124. package/dist/solutions-components/p-9371145a.entry.js +477 -0
  125. package/dist/solutions-components/p-93d3119d.js +1948 -1
  126. package/dist/solutions-components/p-95ec8062.entry.js +173 -0
  127. package/dist/solutions-components/p-991ee695.js +109 -1
  128. package/dist/solutions-components/p-9a57dab7.entry.js +213 -0
  129. package/dist/solutions-components/p-9a9955db.js +41 -1
  130. package/dist/solutions-components/p-9c1ebc90.js +35 -16
  131. package/dist/solutions-components/p-9eba5c66.js +399 -3
  132. package/dist/solutions-components/p-a033a507.entry.js +252 -0
  133. package/dist/solutions-components/p-a3773415.entry.js +1132 -0
  134. package/dist/solutions-components/p-a44fe40f.entry.js +94 -0
  135. package/dist/solutions-components/p-a5b1ab03.js +33 -3
  136. package/dist/solutions-components/p-a5b2c13d.entry.js +723 -0
  137. package/dist/solutions-components/p-a6d729b7.entry.js +85 -0
  138. package/dist/solutions-components/p-a8005026.entry.js +565 -0
  139. package/dist/solutions-components/p-a80b3880.js +14 -1
  140. package/dist/solutions-components/p-a89198a3.entry.js +2620 -0
  141. package/dist/solutions-components/p-aa04bd1f.entry.js +95 -0
  142. package/dist/solutions-components/p-aa0a0922.entry.js +80 -0
  143. package/dist/solutions-components/p-ae1fd76b.js +11 -1
  144. package/dist/solutions-components/p-b2cf435e.entry.js +87 -0
  145. package/dist/solutions-components/p-b359dc78.js +41 -1
  146. package/dist/solutions-components/p-b57bc4eb.entry.js +71 -0
  147. package/dist/solutions-components/p-b75cc407.entry.js +145 -0
  148. package/dist/solutions-components/p-b911cb75.entry.js +71 -0
  149. package/dist/solutions-components/p-b965e177.entry.js +335 -0
  150. package/dist/solutions-components/p-b978636e.js +14 -1
  151. package/dist/solutions-components/p-ba10a5c8.entry.js +42 -0
  152. package/dist/solutions-components/p-bd67334c.js +122 -2
  153. package/dist/solutions-components/p-bde20dba.entry.js +212 -0
  154. package/dist/solutions-components/p-be0b5a94.entry.js +248 -0
  155. package/dist/solutions-components/p-c023e6a1.js +2028 -2
  156. package/dist/solutions-components/p-c27b0c2d.entry.js +150 -0
  157. package/dist/solutions-components/p-c579ed60.entry.js +447 -0
  158. package/dist/solutions-components/p-c92bc231.js +101 -2
  159. package/dist/solutions-components/p-cc815aca.js +839 -16
  160. package/dist/solutions-components/p-cc8beabb.entry.js +695 -0
  161. package/dist/solutions-components/p-cdc46c0c.js +1751 -2
  162. package/dist/solutions-components/p-d12e6992.entry.js +118 -0
  163. package/dist/solutions-components/p-d1dfed6b.entry.js +179 -0
  164. package/dist/solutions-components/p-d48a24e6.js +754 -2
  165. package/dist/solutions-components/p-d96ee3ef.entry.js +579 -0
  166. package/dist/solutions-components/p-dbc9a5a8.js +80 -0
  167. package/dist/solutions-components/p-dcdbe712.entry.js +278 -0
  168. package/dist/solutions-components/p-de39206f.entry.js +113 -0
  169. package/dist/solutions-components/p-de5416e8.js +28 -1
  170. package/dist/solutions-components/p-df420d54.entry.js +213 -0
  171. package/dist/solutions-components/p-e3138cf0.entry.js +20 -0
  172. package/dist/solutions-components/p-e4845fec.entry.js +152 -0
  173. package/dist/solutions-components/p-e611d8c8.js +28 -1
  174. package/dist/solutions-components/p-e947d3b0.js +5 -1
  175. package/dist/solutions-components/p-ea534300.js +41 -2
  176. package/dist/solutions-components/p-ec84ee85.entry.js +55 -0
  177. package/dist/solutions-components/p-ed36c637.entry.js +85 -0
  178. package/dist/solutions-components/p-f0add71c.js +74 -0
  179. package/dist/solutions-components/p-f42e014b.js +171 -2
  180. package/dist/solutions-components/p-fc02e7de.entry.js +308 -0
  181. package/dist/solutions-components/p-fc884dd6.js +28 -16
  182. package/dist/solutions-components/p-fcbfa59c.entry.js +181 -0
  183. package/dist/solutions-components/p-fdc5cf5f.entry.js +138 -0
  184. package/dist/solutions-components/solutions-components.esm.js +20 -1
  185. package/dist/solutions-components/utils/interfaces.ts +7 -2
  186. package/dist/types/components/buffer-tools/buffer-tools.d.ts +9 -1
  187. package/dist/types/components/public-notification/public-notification.d.ts +26 -0
  188. package/dist/types/components.d.ts +9 -1
  189. package/dist/types/preact.d.ts +3 -1
  190. package/dist/types/utils/interfaces.d.ts +4 -0
  191. package/package.json +1 -1
  192. package/dist/solutions-components/p-021432b8.entry.js +0 -12
  193. package/dist/solutions-components/p-03440b1e.entry.js +0 -11
  194. package/dist/solutions-components/p-0512635b.entry.js +0 -6
  195. package/dist/solutions-components/p-086ef115.entry.js +0 -29
  196. package/dist/solutions-components/p-0b4bf57f.entry.js +0 -6
  197. package/dist/solutions-components/p-0c088725.entry.js +0 -6
  198. package/dist/solutions-components/p-0f820c08.entry.js +0 -6
  199. package/dist/solutions-components/p-164780a0.entry.js +0 -6
  200. package/dist/solutions-components/p-179a68a0.entry.js +0 -6
  201. package/dist/solutions-components/p-184b5005.entry.js +0 -11
  202. package/dist/solutions-components/p-1d082fee.entry.js +0 -11
  203. package/dist/solutions-components/p-1e6c02a2.entry.js +0 -11
  204. package/dist/solutions-components/p-20a58e62.entry.js +0 -17
  205. package/dist/solutions-components/p-20b2458c.entry.js +0 -11
  206. package/dist/solutions-components/p-245d47c1.entry.js +0 -6
  207. package/dist/solutions-components/p-2cb057a9.entry.js +0 -11
  208. package/dist/solutions-components/p-2cc72806.entry.js +0 -23
  209. package/dist/solutions-components/p-2de1db9c.entry.js +0 -11
  210. package/dist/solutions-components/p-2e9c7055.entry.js +0 -11
  211. package/dist/solutions-components/p-2ed5e6c8.entry.js +0 -11
  212. package/dist/solutions-components/p-3109d940.entry.js +0 -6
  213. package/dist/solutions-components/p-31a8bcfa.entry.js +0 -6
  214. package/dist/solutions-components/p-3f88ba73.entry.js +0 -6
  215. package/dist/solutions-components/p-3fa9b3c8.js +0 -36
  216. package/dist/solutions-components/p-40c41709.entry.js +0 -6
  217. package/dist/solutions-components/p-40e963c7.entry.js +0 -11
  218. package/dist/solutions-components/p-40f480da.entry.js +0 -11
  219. package/dist/solutions-components/p-49d5d2d3.entry.js +0 -11
  220. package/dist/solutions-components/p-4f7049a4.entry.js +0 -11
  221. package/dist/solutions-components/p-506e4d78.entry.js +0 -6
  222. package/dist/solutions-components/p-576fdcab.entry.js +0 -6
  223. package/dist/solutions-components/p-5bd0cf34.entry.js +0 -23
  224. package/dist/solutions-components/p-65e177f1.entry.js +0 -6
  225. package/dist/solutions-components/p-67d710c2.entry.js +0 -6
  226. package/dist/solutions-components/p-7268b445.entry.js +0 -11
  227. package/dist/solutions-components/p-75ea4667.entry.js +0 -6
  228. package/dist/solutions-components/p-778c0a36.entry.js +0 -17
  229. package/dist/solutions-components/p-7a22509b.entry.js +0 -12
  230. package/dist/solutions-components/p-7bff51db.entry.js +0 -6
  231. package/dist/solutions-components/p-7d2d0d5d.entry.js +0 -6
  232. package/dist/solutions-components/p-7f0036f1.entry.js +0 -11
  233. package/dist/solutions-components/p-8060fb94.entry.js +0 -6
  234. package/dist/solutions-components/p-80a1b305.entry.js +0 -6
  235. package/dist/solutions-components/p-81eae877.entry.js +0 -12
  236. package/dist/solutions-components/p-84e86b8b.entry.js +0 -6
  237. package/dist/solutions-components/p-877dd0dc.entry.js +0 -18
  238. package/dist/solutions-components/p-9106950a.entry.js +0 -11
  239. package/dist/solutions-components/p-979804a4.entry.js +0 -11
  240. package/dist/solutions-components/p-9862baa8.entry.js +0 -11
  241. package/dist/solutions-components/p-9b5a9117.entry.js +0 -12
  242. package/dist/solutions-components/p-9deff0c2.entry.js +0 -6
  243. package/dist/solutions-components/p-9f400eeb.entry.js +0 -6
  244. package/dist/solutions-components/p-a0639ad1.entry.js +0 -11
  245. package/dist/solutions-components/p-a33c044e.entry.js +0 -6
  246. package/dist/solutions-components/p-a516c658.entry.js +0 -6
  247. package/dist/solutions-components/p-aa0ef36d.entry.js +0 -11
  248. package/dist/solutions-components/p-aaccbdf3.entry.js +0 -18
  249. package/dist/solutions-components/p-ab03a5c9.entry.js +0 -11
  250. package/dist/solutions-components/p-ad469b92.entry.js +0 -11
  251. package/dist/solutions-components/p-adc86ac3.entry.js +0 -6
  252. package/dist/solutions-components/p-addc1156.entry.js +0 -11
  253. package/dist/solutions-components/p-ae846934.entry.js +0 -11
  254. package/dist/solutions-components/p-b0572fc4.entry.js +0 -37
  255. package/dist/solutions-components/p-b4e476b7.js +0 -257
  256. package/dist/solutions-components/p-b668daf8.js +0 -21
  257. package/dist/solutions-components/p-b6e6eae1.entry.js +0 -6
  258. package/dist/solutions-components/p-bc317a7f.entry.js +0 -6
  259. package/dist/solutions-components/p-bd4d0773.entry.js +0 -6
  260. package/dist/solutions-components/p-be41429f.js +0 -21
  261. package/dist/solutions-components/p-bf6b6353.entry.js +0 -11
  262. package/dist/solutions-components/p-c2e3dfbb.entry.js +0 -11
  263. package/dist/solutions-components/p-c4afae53.entry.js +0 -12
  264. package/dist/solutions-components/p-c9da1c26.entry.js +0 -6
  265. package/dist/solutions-components/p-cbf8cd49.entry.js +0 -6
  266. package/dist/solutions-components/p-cc1a064a.entry.js +0 -11
  267. package/dist/solutions-components/p-d09a168c.entry.js +0 -6
  268. package/dist/solutions-components/p-d377f913.entry.js +0 -11
  269. package/dist/solutions-components/p-d4cefead.entry.js +0 -37
  270. package/dist/solutions-components/p-d7bc0baf.entry.js +0 -16
  271. package/dist/solutions-components/p-d8968487.entry.js +0 -11
  272. package/dist/solutions-components/p-e00a0b86.entry.js +0 -11
  273. package/dist/solutions-components/p-e9a7ed49.entry.js +0 -11
  274. package/dist/solutions-components/p-ec27e493.entry.js +0 -11
  275. package/dist/solutions-components/p-ed6404eb.entry.js +0 -6
  276. package/dist/solutions-components/p-ef21e195.entry.js +0 -23
  277. package/dist/solutions-components/p-f6068a2d.entry.js +0 -11
  278. package/dist/solutions-components/p-f6c4cff3.entry.js +0 -11
  279. package/dist/solutions-components/p-f847291f.entry.js +0 -6
  280. package/dist/solutions-components/p-f90fd262.entry.js +0 -11
  281. package/dist/solutions-components/p-fc973005.entry.js +0 -6
  282. package/dist/solutions-components/p-ff9fb6bc.entry.js +0 -11
@@ -0,0 +1,913 @@
1
+ /*!
2
+ * Copyright 2022 Esri
3
+ * Licensed under the Apache License, Version 2.0
4
+ * http://www.apache.org/licenses/LICENSE-2.0
5
+ */
6
+ import { r as registerInstance, c as createEvent, h, g as getElement } from './p-c023e6a1.js';
7
+ import { c as color } from './p-93d3119d.js';
8
+ import { D as DEFAULT_COLOR, T as TEXT, a as DIMENSIONS, H as HSV_LIMITS, C as CSS, b as DEFAULT_STORAGE_KEY_PREFIX, R as RGB_LIMITS } from './p-374a5031.js';
9
+ import { i as isPrimaryPointerButton, b as getElementDir, f as focusElement } from './p-83166522.js';
10
+ import { n as normalizeHex, C as CSSColorMode, p as parseMode, c as colorEqual } from './p-991ee695.js';
11
+ import { c as clamp } from './p-63f6e8f1.js';
12
+ import { u as updateHostInteraction } from './p-7daea1df.js';
13
+ import { i as isActivationKey } from './p-73e23995.js';
14
+ import { d as debounce, i as isObject } from './p-4e32bf8c.js';
15
+ import './p-3b010ce1.js';
16
+ import './p-729708a3.js';
17
+ import './p-a80b3880.js';
18
+
19
+ /** Error message constants. */
20
+ var FUNC_ERROR_TEXT = 'Expected a function';
21
+
22
+ /**
23
+ * Creates a throttled function that only invokes `func` at most once per
24
+ * every `wait` milliseconds. The throttled function comes with a `cancel`
25
+ * method to cancel delayed `func` invocations and a `flush` method to
26
+ * immediately invoke them. Provide `options` to indicate whether `func`
27
+ * should be invoked on the leading and/or trailing edge of the `wait`
28
+ * timeout. The `func` is invoked with the last arguments provided to the
29
+ * throttled function. Subsequent calls to the throttled function return the
30
+ * result of the last `func` invocation.
31
+ *
32
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
33
+ * invoked on the trailing edge of the timeout only if the throttled function
34
+ * is invoked more than once during the `wait` timeout.
35
+ *
36
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
37
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
38
+ *
39
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
40
+ * for details over the differences between `_.throttle` and `_.debounce`.
41
+ *
42
+ * @static
43
+ * @memberOf _
44
+ * @since 0.1.0
45
+ * @category Function
46
+ * @param {Function} func The function to throttle.
47
+ * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
48
+ * @param {Object} [options={}] The options object.
49
+ * @param {boolean} [options.leading=true]
50
+ * Specify invoking on the leading edge of the timeout.
51
+ * @param {boolean} [options.trailing=true]
52
+ * Specify invoking on the trailing edge of the timeout.
53
+ * @returns {Function} Returns the new throttled function.
54
+ * @example
55
+ *
56
+ * // Avoid excessively updating the position while scrolling.
57
+ * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
58
+ *
59
+ * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
60
+ * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
61
+ * jQuery(element).on('click', throttled);
62
+ *
63
+ * // Cancel the trailing throttled invocation.
64
+ * jQuery(window).on('popstate', throttled.cancel);
65
+ */
66
+ function throttle(func, wait, options) {
67
+ var leading = true,
68
+ trailing = true;
69
+
70
+ if (typeof func != 'function') {
71
+ throw new TypeError(FUNC_ERROR_TEXT);
72
+ }
73
+ if (isObject(options)) {
74
+ leading = 'leading' in options ? !!options.leading : leading;
75
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
76
+ }
77
+ return debounce(func, wait, {
78
+ 'leading': leading,
79
+ 'maxWait': wait,
80
+ 'trailing': trailing
81
+ });
82
+ }
83
+
84
+ const colorPickerCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host{display:inline-block;font-size:var(--calcite-font-size--2);line-height:1rem;font-weight:var(--calcite-font-weight-normal)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([scale=s]) .container{inline-size:160px}:host([scale=s]) .saved-colors{grid-template-columns:repeat(auto-fill, minmax(20px, 1fr))}:host([scale=s]) .channels{flex-direction:column}:host([scale=s]) .channel{inline-size:100%;-webkit-margin-after:4px;margin-block-end:4px}:host([scale=s]) .channel:last-child{-webkit-margin-after:0;margin-block-end:0}:host([scale=m]) .container{inline-size:272px}:host([scale=l]) .header{-webkit-padding-after:0px;padding-block-end:0px}:host([scale=l]){font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=l]) .container{inline-size:464px}:host([scale=l]) .color-field-and-slider{-webkit-margin-after:-20px;margin-block-end:-20px}:host([scale=l]) .section{padding-block:0 16px;padding-inline:16px}:host([scale=l]) .section:first-of-type{-webkit-padding-before:16px;padding-block-start:16px}:host([scale=l]) .saved-colors{grid-template-columns:repeat(auto-fill, minmax(28px, 1fr));grid-gap:12px;-webkit-padding-before:16px;padding-block-start:16px}:host([scale=l]) .control-section{flex-wrap:nowrap;align-items:baseline}:host([scale=l]) .control-section>:nth-child(2){-webkit-margin-start:12px;margin-inline-start:12px}:host([scale=l]) .color-hex-options{display:flex;flex-shrink:1;flex-direction:column;justify-content:space-around;min-block-size:98px;inline-size:160px}:host([scale=l]) .color-mode-container{flex-shrink:3}:host([appearance=minimal]) .container{border:none}.container{background-color:var(--calcite-ui-foreground-1);display:inline-block;border:1px solid var(--calcite-ui-border-1)}.color-field-and-slider-wrap{position:relative}.scope{pointer-events:none;position:absolute;font-size:var(--calcite-font-size--1);outline-color:transparent;outline-offset:14px}.scope:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:16px}.color-field-and-slider{-webkit-margin-after:-16px;margin-block-end:-16px;touch-action:none}.color-field-and-slider--interactive{cursor:pointer}.control-section{display:flex;flex-direction:row;flex-wrap:wrap}.section{padding-block:0 12px;padding-inline:12px}.section:first-of-type{-webkit-padding-before:12px;padding-block-start:12px}.color-hex-options,.section--split{flex-grow:1}.header{display:flex;align-items:center;justify-content:space-between;-webkit-padding-after:0.25rem;padding-block-end:0.25rem;color:var(--calcite-ui-text-1)}.header--hex,.color-mode-container{-webkit-padding-before:12px;padding-block-start:12px}.channels{display:flex;justify-content:space-between}.channel{inline-size:31%}.saved-colors{-webkit-padding-before:12px;padding-block-start:12px;display:grid;grid-template-columns:repeat(auto-fill, minmax(24px, 1fr));grid-gap:8px;inline-size:100%}.saved-colors-buttons{display:flex}.saved-color{outline-offset:0;outline-color:transparent;cursor:pointer}.saved-color:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}.saved-color:hover{transition:outline-color var(--calcite-internal-animation-timing-fast) ease-in-out;outline:2px solid var(--calcite-ui-border-2);outline-offset:2px}";
85
+
86
+ const throttleFor60FpsInMs = 16;
87
+ const defaultValue = normalizeHex(DEFAULT_COLOR.hex());
88
+ const defaultFormat = "auto";
89
+ const ColorPicker = class {
90
+ constructor(hostRef) {
91
+ registerInstance(this, hostRef);
92
+ this.calciteColorPickerChange = createEvent(this, "calciteColorPickerChange", 6);
93
+ this.calciteColorPickerInput = createEvent(this, "calciteColorPickerInput", 6);
94
+ //--------------------------------------------------------------------------
95
+ //
96
+ // Public properties
97
+ //
98
+ //--------------------------------------------------------------------------
99
+ /**
100
+ * When `false`, an empty color (`null`) will be allowed as a `value`. Otherwise, a color value is enforced on the component.
101
+ *
102
+ * When `true`, a color value is enforced, and clearing the input or blurring will restore the last valid `value`. When `false`, an empty color (`null`) will be allowed as a `value`.
103
+ */
104
+ this.allowEmpty = false;
105
+ /**
106
+ * Specifies the appearance style of the component -
107
+ *
108
+ * `"solid"` (containing border) or `"minimal"` (no containing border).
109
+ */
110
+ this.appearance = "solid";
111
+ /**
112
+ * Internal prop for advanced use-cases.
113
+ *
114
+ * @internal
115
+ */
116
+ this.color = DEFAULT_COLOR;
117
+ /**
118
+ * When `true`, interaction is prevented and the component is displayed with lower opacity.
119
+ */
120
+ this.disabled = false;
121
+ /**
122
+ * The format of `value`.
123
+ *
124
+ * When `"auto"`, the format will be inferred from `value` when set.
125
+ *
126
+ * @default "auto"
127
+ */
128
+ this.format = defaultFormat;
129
+ /** When `true`, hides the Hex input. */
130
+ this.hideHex = false;
131
+ /** When `true`, hides the RGB/HSV channel inputs. */
132
+ this.hideChannels = false;
133
+ /** When `true`, hides the saved colors section. */
134
+ this.hideSaved = false;
135
+ /**
136
+ * Accessible name for the RGB section's blue channel.
137
+ *
138
+ * @default "B"
139
+ */
140
+ this.intlB = TEXT.b;
141
+ /**
142
+ * Accessible name for the RGB section's blue channel description.
143
+ *
144
+ * @default "Blue"
145
+ */
146
+ this.intlBlue = TEXT.blue;
147
+ /**
148
+ * Accessible name for the delete color button.
149
+ *
150
+ * @default "Delete color"
151
+ */
152
+ this.intlDeleteColor = TEXT.deleteColor;
153
+ /**
154
+ * Accessible name for the RGB section's green channel.
155
+ *
156
+ * @default "G"
157
+ */
158
+ this.intlG = TEXT.g;
159
+ /**
160
+ * Accessible name for the RGB section's green channel description.
161
+ *
162
+ * @default "Green"
163
+ */
164
+ this.intlGreen = TEXT.green;
165
+ /**
166
+ * Accessible name for the HSV section's hue channel.
167
+ *
168
+ * @default "H"
169
+ */
170
+ this.intlH = TEXT.h;
171
+ /**
172
+ * Accessible name for the HSV mode.
173
+ *
174
+ * @default "HSV"
175
+ */
176
+ this.intlHsv = TEXT.hsv;
177
+ /**
178
+ * Accessible name for the Hex input.
179
+ *
180
+ * @default "Hex"
181
+ */
182
+ this.intlHex = TEXT.hex;
183
+ /**
184
+ * Accessible name for the HSV section's hue channel description.
185
+ *
186
+ * @default "Hue"
187
+ */
188
+ this.intlHue = TEXT.hue;
189
+ /**
190
+ * Accessible name for the Hex input when there is no color selected.
191
+ *
192
+ * @default "No color"
193
+ */
194
+ this.intlNoColor = TEXT.noColor;
195
+ /**
196
+ * Accessible name for the RGB section's red channel.
197
+ *
198
+ * @default "R"
199
+ */
200
+ this.intlR = TEXT.r;
201
+ /**
202
+ * Accessible name for the RGB section's red channel description.
203
+ *
204
+ * @default "Red"
205
+ */
206
+ this.intlRed = TEXT.red;
207
+ /**
208
+ * Accessible name for the RGB mode.
209
+ *
210
+ * @default "RGB"
211
+ */
212
+ this.intlRgb = TEXT.rgb;
213
+ /**
214
+ * Accessible name for the HSV section's saturation channel.
215
+ *
216
+ * @default "S"
217
+ */
218
+ this.intlS = TEXT.s;
219
+ /**
220
+ * Accessible name for the HSV section's saturation channel description.
221
+ *
222
+ * @default "Saturation"
223
+ */
224
+ this.intlSaturation = TEXT.saturation;
225
+ /**
226
+ * Accessible name for the save color button.
227
+ *
228
+ * @default "Save color"
229
+ */
230
+ this.intlSaveColor = TEXT.saveColor;
231
+ /**
232
+ * Accessible name for the saved colors section.
233
+ *
234
+ * @default "Saved"
235
+ */
236
+ this.intlSaved = TEXT.saved;
237
+ /**
238
+ * Accessible name for the HSV section's value channel.
239
+ *
240
+ * @default "V"
241
+ */
242
+ this.intlV = TEXT.v;
243
+ /**
244
+ * Accessible name for the HSV section's value channel description.
245
+ *
246
+ * @default "Value"
247
+ */
248
+ this.intlValue = TEXT.value;
249
+ /** Specifies the size of the component. */
250
+ this.scale = "m";
251
+ /**
252
+ * The component's value, where the value can be a CSS color string, or a RGB, HSL or HSV object.
253
+ *
254
+ * The type will be preserved as the color is updated.
255
+ *
256
+ * @default "#007ac2"
257
+ * @see [CSS Color](https://developer.mozilla.org/en-US/docs/Web/CSS/color)
258
+ * @see [ColorValue](https://github.com/Esri/calcite-components/blob/master/src/components/color-picker/interfaces.ts#L10)
259
+ */
260
+ this.value = defaultValue;
261
+ this.colorFieldAndSliderHovered = false;
262
+ this.hueThumbState = "idle";
263
+ this.internalColorUpdateContext = null;
264
+ this.mode = CSSColorMode.HEX;
265
+ this.shiftKeyChannelAdjustment = 0;
266
+ this.sliderThumbState = "idle";
267
+ this.colorFieldAndSliderInteractive = false;
268
+ this.channelMode = "rgb";
269
+ this.channels = this.toChannels(DEFAULT_COLOR);
270
+ this.dimensions = DIMENSIONS.m;
271
+ this.savedColors = [];
272
+ this.handleTabActivate = (event) => {
273
+ this.channelMode = event.currentTarget.getAttribute("data-color-mode");
274
+ this.updateChannelsFromColor(this.color);
275
+ };
276
+ this.handleColorFieldScopeKeyDown = (event) => {
277
+ const { key } = event;
278
+ const arrowKeyToXYOffset = {
279
+ ArrowUp: { x: 0, y: -10 },
280
+ ArrowRight: { x: 10, y: 0 },
281
+ ArrowDown: { x: 0, y: 10 },
282
+ ArrowLeft: { x: -10, y: 0 }
283
+ };
284
+ if (arrowKeyToXYOffset[key]) {
285
+ event.preventDefault();
286
+ this.scopeOrientation = key === "ArrowDown" || key === "ArrowUp" ? "vertical" : "horizontal";
287
+ this.captureColorFieldColor(this.colorFieldScopeLeft + arrowKeyToXYOffset[key].x || 0, this.colorFieldScopeTop + arrowKeyToXYOffset[key].y || 0, false);
288
+ }
289
+ };
290
+ this.handleHueScopeKeyDown = (event) => {
291
+ const modifier = event.shiftKey ? 10 : 1;
292
+ const { key } = event;
293
+ const arrowKeyToXOffset = {
294
+ ArrowUp: 1,
295
+ ArrowRight: 1,
296
+ ArrowDown: -1,
297
+ ArrowLeft: -1
298
+ };
299
+ if (arrowKeyToXOffset[key]) {
300
+ event.preventDefault();
301
+ const delta = arrowKeyToXOffset[key] * modifier;
302
+ const hue = this.baseColorFieldColor.hue();
303
+ const color = this.baseColorFieldColor.hue(hue + delta);
304
+ this.internalColorSet(color, false);
305
+ }
306
+ };
307
+ this.handleHexInputChange = (event) => {
308
+ event.stopPropagation();
309
+ const { allowEmpty, color: color$1 } = this;
310
+ const input = event.target;
311
+ const hex = input.value;
312
+ if (allowEmpty && !hex) {
313
+ this.internalColorSet(null);
314
+ return;
315
+ }
316
+ const normalizedHex = color$1 && normalizeHex(color$1.hex());
317
+ if (hex !== normalizedHex) {
318
+ this.internalColorSet(color(hex));
319
+ }
320
+ };
321
+ this.handleSavedColorSelect = (event) => {
322
+ const swatch = event.currentTarget;
323
+ this.internalColorSet(color(swatch.color));
324
+ };
325
+ this.handleChannelInput = (event) => {
326
+ const input = event.currentTarget;
327
+ const internalInput = event.detail.nativeEvent.target;
328
+ const channelIndex = Number(input.getAttribute("data-channel-index"));
329
+ const limit = this.channelMode === "rgb"
330
+ ? RGB_LIMITS[Object.keys(RGB_LIMITS)[channelIndex]]
331
+ : HSV_LIMITS[Object.keys(HSV_LIMITS)[channelIndex]];
332
+ let inputValue;
333
+ if (this.allowEmpty && !input.value) {
334
+ inputValue = "";
335
+ }
336
+ else {
337
+ const value = Number(input.value) + this.shiftKeyChannelAdjustment;
338
+ const clamped = clamp(value, 0, limit);
339
+ inputValue = clamped.toString();
340
+ }
341
+ input.value = inputValue;
342
+ internalInput.value = inputValue;
343
+ };
344
+ this.handleChannelChange = (event) => {
345
+ const input = event.currentTarget;
346
+ const channelIndex = Number(input.getAttribute("data-channel-index"));
347
+ const channels = [...this.channels];
348
+ const shouldClearChannels = this.allowEmpty && !input.value;
349
+ if (shouldClearChannels) {
350
+ this.channels = [null, null, null];
351
+ this.internalColorSet(null);
352
+ return;
353
+ }
354
+ channels[channelIndex] = Number(input.value);
355
+ this.updateColorFromChannels(channels);
356
+ };
357
+ this.handleSavedColorKeyDown = (event) => {
358
+ if (isActivationKey(event.key)) {
359
+ event.preventDefault();
360
+ this.handleSavedColorSelect(event);
361
+ }
362
+ };
363
+ this.handleColorFieldAndSliderPointerLeave = () => {
364
+ this.colorFieldAndSliderInteractive = false;
365
+ this.colorFieldAndSliderHovered = false;
366
+ if (this.sliderThumbState !== "drag" && this.hueThumbState !== "drag") {
367
+ this.hueThumbState = "idle";
368
+ this.sliderThumbState = "idle";
369
+ this.drawColorFieldAndSlider();
370
+ }
371
+ };
372
+ this.handleColorFieldAndSliderPointerDown = (event) => {
373
+ var _a, _b;
374
+ if (!isPrimaryPointerButton(event)) {
375
+ return;
376
+ }
377
+ const { offsetX, offsetY } = event;
378
+ const region = this.getCanvasRegion(offsetY);
379
+ if (region === "color-field") {
380
+ this.hueThumbState = "drag";
381
+ this.captureColorFieldColor(offsetX, offsetY);
382
+ (_a = this.colorFieldScopeNode) === null || _a === void 0 ? void 0 : _a.focus();
383
+ }
384
+ else if (region === "slider") {
385
+ this.sliderThumbState = "drag";
386
+ this.captureHueSliderColor(offsetX);
387
+ (_b = this.hueScopeNode) === null || _b === void 0 ? void 0 : _b.focus();
388
+ }
389
+ // prevent text selection outside of color field & slider area
390
+ event.preventDefault();
391
+ document.addEventListener("pointermove", this.globalPointerMoveHandler);
392
+ document.addEventListener("pointerup", this.globalPointerUpHandler, { once: true });
393
+ this.activeColorFieldAndSliderRect =
394
+ this.fieldAndSliderRenderingContext.canvas.getBoundingClientRect();
395
+ };
396
+ this.globalPointerUpHandler = (event) => {
397
+ if (!isPrimaryPointerButton(event)) {
398
+ return;
399
+ }
400
+ const previouslyDragging = this.sliderThumbState === "drag" || this.hueThumbState === "drag";
401
+ this.hueThumbState = "idle";
402
+ this.sliderThumbState = "idle";
403
+ this.activeColorFieldAndSliderRect = null;
404
+ this.drawColorFieldAndSlider();
405
+ if (previouslyDragging) {
406
+ this.calciteColorPickerChange.emit();
407
+ }
408
+ };
409
+ this.globalPointerMoveHandler = (event) => {
410
+ const { el, dimensions } = this;
411
+ const sliderThumbDragging = this.sliderThumbState === "drag";
412
+ const hueThumbDragging = this.hueThumbState === "drag";
413
+ if (!el.isConnected || (!sliderThumbDragging && !hueThumbDragging)) {
414
+ return;
415
+ }
416
+ let samplingX;
417
+ let samplingY;
418
+ const colorFieldAndSliderRect = this.activeColorFieldAndSliderRect;
419
+ const { clientX, clientY } = event;
420
+ if (this.colorFieldAndSliderHovered) {
421
+ samplingX = clientX - colorFieldAndSliderRect.x;
422
+ samplingY = clientY - colorFieldAndSliderRect.y;
423
+ }
424
+ else {
425
+ const colorFieldWidth = dimensions.colorField.width;
426
+ const colorFieldHeight = dimensions.colorField.height;
427
+ const hueSliderHeight = dimensions.slider.height;
428
+ if (clientX < colorFieldAndSliderRect.x + colorFieldWidth &&
429
+ clientX > colorFieldAndSliderRect.x) {
430
+ samplingX = clientX - colorFieldAndSliderRect.x;
431
+ }
432
+ else if (clientX < colorFieldAndSliderRect.x) {
433
+ samplingX = 0;
434
+ }
435
+ else {
436
+ samplingX = colorFieldWidth - 1;
437
+ }
438
+ if (clientY < colorFieldAndSliderRect.y + colorFieldHeight + hueSliderHeight &&
439
+ clientY > colorFieldAndSliderRect.y) {
440
+ samplingY = clientY - colorFieldAndSliderRect.y;
441
+ }
442
+ else if (clientY < colorFieldAndSliderRect.y) {
443
+ samplingY = 0;
444
+ }
445
+ else {
446
+ samplingY = colorFieldHeight + hueSliderHeight;
447
+ }
448
+ }
449
+ if (hueThumbDragging) {
450
+ this.captureColorFieldColor(samplingX, samplingY, false);
451
+ }
452
+ else {
453
+ this.captureHueSliderColor(samplingX);
454
+ }
455
+ };
456
+ this.handleColorFieldAndSliderPointerEnterOrMove = ({ offsetX, offsetY }) => {
457
+ const { dimensions: { colorField, slider, thumb } } = this;
458
+ this.colorFieldAndSliderInteractive = offsetY <= colorField.height + slider.height;
459
+ this.colorFieldAndSliderHovered = true;
460
+ const region = this.getCanvasRegion(offsetY);
461
+ if (region === "color-field") {
462
+ const prevHueThumbState = this.hueThumbState;
463
+ const color = this.baseColorFieldColor.hsv();
464
+ const centerX = Math.round(color.saturationv() / (HSV_LIMITS.s / colorField.width));
465
+ const centerY = Math.round(colorField.height - color.value() / (HSV_LIMITS.v / colorField.height));
466
+ const hoveringThumb = this.containsPoint(offsetX, offsetY, centerX, centerY, thumb.radius);
467
+ let transitionedBetweenHoverAndIdle = false;
468
+ if (prevHueThumbState === "idle" && hoveringThumb) {
469
+ this.hueThumbState = "hover";
470
+ transitionedBetweenHoverAndIdle = true;
471
+ }
472
+ else if (prevHueThumbState === "hover" && !hoveringThumb) {
473
+ this.hueThumbState = "idle";
474
+ transitionedBetweenHoverAndIdle = true;
475
+ }
476
+ if (this.hueThumbState !== "drag") {
477
+ if (transitionedBetweenHoverAndIdle) {
478
+ // refresh since we won't update color and thus no redraw
479
+ this.drawColorFieldAndSlider();
480
+ }
481
+ }
482
+ }
483
+ else if (region === "slider") {
484
+ const sliderThumbColor = this.baseColorFieldColor.hsv().saturationv(100).value(100);
485
+ const prevSliderThumbState = this.sliderThumbState;
486
+ const sliderThumbCenterX = Math.round(sliderThumbColor.hue() / (360 / slider.width));
487
+ const sliderThumbCenterY = Math.round((slider.height + this.getSliderCapSpacing()) / 2) + colorField.height;
488
+ const hoveringSliderThumb = this.containsPoint(offsetX, offsetY, sliderThumbCenterX, sliderThumbCenterY, thumb.radius);
489
+ let sliderThumbTransitionedBetweenHoverAndIdle = false;
490
+ if (prevSliderThumbState === "idle" && hoveringSliderThumb) {
491
+ this.sliderThumbState = "hover";
492
+ sliderThumbTransitionedBetweenHoverAndIdle = true;
493
+ }
494
+ else if (prevSliderThumbState === "hover" && !hoveringSliderThumb) {
495
+ this.sliderThumbState = "idle";
496
+ sliderThumbTransitionedBetweenHoverAndIdle = true;
497
+ }
498
+ if (this.sliderThumbState !== "drag") {
499
+ if (sliderThumbTransitionedBetweenHoverAndIdle) {
500
+ // refresh since we won't update color and thus no redraw
501
+ this.drawColorFieldAndSlider();
502
+ }
503
+ }
504
+ }
505
+ };
506
+ this.storeColorFieldScope = (node) => {
507
+ this.colorFieldScopeNode = node;
508
+ };
509
+ this.storeHueScope = (node) => {
510
+ this.hueScopeNode = node;
511
+ };
512
+ this.renderChannelsTabTitle = (channelMode) => {
513
+ const { channelMode: activeChannelMode, intlRgb, intlHsv } = this;
514
+ const active = channelMode === activeChannelMode;
515
+ const label = channelMode === "rgb" ? intlRgb : intlHsv;
516
+ return (h("calcite-tab-title", { active: active, class: CSS.colorMode, "data-color-mode": channelMode, key: channelMode, onCalciteTabsActivate: this.handleTabActivate }, label));
517
+ };
518
+ this.renderChannelsTab = (channelMode) => {
519
+ const { channelMode: activeChannelMode, channels, intlB, intlBlue, intlG, intlGreen, intlH, intlHue, intlR, intlRed, intlS, intlSaturation, intlV, intlValue } = this;
520
+ const active = channelMode === activeChannelMode;
521
+ const isRgb = channelMode === "rgb";
522
+ const channelLabels = isRgb ? [intlR, intlG, intlB] : [intlH, intlS, intlV];
523
+ const channelAriaLabels = isRgb
524
+ ? [intlRed, intlGreen, intlBlue]
525
+ : [intlHue, intlSaturation, intlValue];
526
+ const direction = getElementDir(this.el);
527
+ return (h("calcite-tab", { active: active, class: CSS.control, key: channelMode }, h("div", { class: CSS.channels, dir: "ltr" }, channels.map((channel, index) =>
528
+ /* the channel container is ltr, so we apply the host's direction */
529
+ this.renderChannel(channel, index, channelLabels[index], channelAriaLabels[index], direction)))));
530
+ };
531
+ this.renderChannel = (value, index, label, ariaLabel, direction) => (h("calcite-input", { class: CSS.channel, "data-channel-index": index, dir: direction, label: ariaLabel, numberButtonType: "none", numberingSystem: this.numberingSystem, onCalciteInputChange: this.handleChannelChange, onCalciteInputInput: this.handleChannelInput, onKeyDown: this.handleKeyDown, prefixText: label, scale: this.scale === "l" ? "m" : "s", type: "number", value: value === null || value === void 0 ? void 0 : value.toString() }));
532
+ this.deleteColor = () => {
533
+ const colorToDelete = this.color.hex();
534
+ const inStorage = this.savedColors.indexOf(colorToDelete) > -1;
535
+ if (!inStorage) {
536
+ return;
537
+ }
538
+ const savedColors = this.savedColors.filter((color) => color !== colorToDelete);
539
+ this.savedColors = savedColors;
540
+ const storageKey = `${DEFAULT_STORAGE_KEY_PREFIX}${this.storageId}`;
541
+ if (this.storageId) {
542
+ localStorage.setItem(storageKey, JSON.stringify(savedColors));
543
+ }
544
+ };
545
+ this.saveColor = () => {
546
+ const colorToSave = this.color.hex();
547
+ const alreadySaved = this.savedColors.indexOf(colorToSave) > -1;
548
+ if (alreadySaved) {
549
+ return;
550
+ }
551
+ const savedColors = [...this.savedColors, colorToSave];
552
+ this.savedColors = savedColors;
553
+ const storageKey = `${DEFAULT_STORAGE_KEY_PREFIX}${this.storageId}`;
554
+ if (this.storageId) {
555
+ localStorage.setItem(storageKey, JSON.stringify(savedColors));
556
+ }
557
+ };
558
+ this.drawColorFieldAndSlider = throttle(() => {
559
+ if (!this.fieldAndSliderRenderingContext) {
560
+ return;
561
+ }
562
+ this.drawColorField();
563
+ this.drawHueSlider();
564
+ }, throttleFor60FpsInMs);
565
+ this.captureColorFieldColor = (x, y, skipEqual = true) => {
566
+ const { dimensions: { colorField: { height, width } } } = this;
567
+ const saturation = Math.round((HSV_LIMITS.s / width) * x);
568
+ const value = Math.round((HSV_LIMITS.v / height) * (height - y));
569
+ this.internalColorSet(this.baseColorFieldColor.hsv().saturationv(saturation).value(value), skipEqual);
570
+ };
571
+ this.initColorFieldAndSlider = (canvas) => {
572
+ this.fieldAndSliderRenderingContext = canvas.getContext("2d");
573
+ this.updateCanvasSize(canvas);
574
+ };
575
+ }
576
+ handleColorChange(color, oldColor) {
577
+ this.drawColorFieldAndSlider();
578
+ this.updateChannelsFromColor(color);
579
+ this.previousColor = oldColor;
580
+ }
581
+ handleFormatChange(format) {
582
+ this.setMode(format);
583
+ this.internalColorSet(this.color, false, "internal");
584
+ }
585
+ handleScaleChange(scale = "m") {
586
+ var _a;
587
+ this.updateDimensions(scale);
588
+ this.updateCanvasSize((_a = this.fieldAndSliderRenderingContext) === null || _a === void 0 ? void 0 : _a.canvas);
589
+ }
590
+ handleValueChange(value, oldValue) {
591
+ const { allowEmpty, format } = this;
592
+ const checkMode = !allowEmpty || value;
593
+ let modeChanged = false;
594
+ if (checkMode) {
595
+ const nextMode = parseMode(value);
596
+ if (!nextMode || (format !== "auto" && nextMode !== format)) {
597
+ this.showIncompatibleColorWarning(value, format);
598
+ this.value = oldValue;
599
+ return;
600
+ }
601
+ modeChanged = this.mode !== nextMode;
602
+ this.setMode(nextMode);
603
+ }
604
+ const dragging = this.sliderThumbState === "drag" || this.hueThumbState === "drag";
605
+ if (this.internalColorUpdateContext === "initial") {
606
+ return;
607
+ }
608
+ if (this.internalColorUpdateContext === "user-interaction") {
609
+ this.calciteColorPickerInput.emit();
610
+ if (!dragging) {
611
+ this.calciteColorPickerChange.emit();
612
+ }
613
+ return;
614
+ }
615
+ const color$1 = allowEmpty && !value ? null : color(value);
616
+ const colorChanged = !colorEqual(color$1, this.color);
617
+ if (modeChanged || colorChanged) {
618
+ this.internalColorSet(color$1, true, "internal");
619
+ }
620
+ }
621
+ //--------------------------------------------------------------------------
622
+ //
623
+ // Internal State/Props
624
+ //
625
+ //--------------------------------------------------------------------------
626
+ get baseColorFieldColor() {
627
+ return this.color || this.previousColor || DEFAULT_COLOR;
628
+ }
629
+ // using @Listen as a workaround for VDOM listener not firing
630
+ handleChannelKeyUpOrDown(event) {
631
+ this.shiftKeyChannelAdjustment = 0;
632
+ const { key } = event;
633
+ if ((key !== "ArrowUp" && key !== "ArrowDown") ||
634
+ !event.composedPath().some((node) => { var _a; return (_a = node.classList) === null || _a === void 0 ? void 0 : _a.contains(CSS.channel); })) {
635
+ return;
636
+ }
637
+ const { shiftKey } = event;
638
+ event.preventDefault();
639
+ if (!this.color) {
640
+ this.internalColorSet(this.previousColor);
641
+ event.stopPropagation();
642
+ return;
643
+ }
644
+ // this gets applied to the input's up/down arrow increment/decrement
645
+ const complementaryBump = 9;
646
+ this.shiftKeyChannelAdjustment =
647
+ key === "ArrowUp" && shiftKey
648
+ ? complementaryBump
649
+ : key === "ArrowDown" && shiftKey
650
+ ? -complementaryBump
651
+ : 0;
652
+ }
653
+ //--------------------------------------------------------------------------
654
+ //
655
+ // Public Methods
656
+ //
657
+ //--------------------------------------------------------------------------
658
+ /** Sets focus on the component. */
659
+ async setFocus() {
660
+ return focusElement(this.colorFieldScopeNode);
661
+ }
662
+ //--------------------------------------------------------------------------
663
+ //
664
+ // Lifecycle
665
+ //
666
+ //--------------------------------------------------------------------------
667
+ componentWillLoad() {
668
+ const { allowEmpty, color: color$1, format, value } = this;
669
+ const willSetNoColor = allowEmpty && !value;
670
+ const parsedMode = parseMode(value);
671
+ const valueIsCompatible = willSetNoColor || (format === "auto" && parsedMode) || format === parsedMode;
672
+ const initialColor = willSetNoColor ? null : valueIsCompatible ? color(value) : color$1;
673
+ if (!valueIsCompatible) {
674
+ this.showIncompatibleColorWarning(value, format);
675
+ }
676
+ this.setMode(format);
677
+ this.internalColorSet(initialColor, false, "initial");
678
+ this.updateDimensions(this.scale);
679
+ const storageKey = `${DEFAULT_STORAGE_KEY_PREFIX}${this.storageId}`;
680
+ if (this.storageId && localStorage.getItem(storageKey)) {
681
+ this.savedColors = JSON.parse(localStorage.getItem(storageKey));
682
+ }
683
+ }
684
+ disconnectedCallback() {
685
+ document.removeEventListener("pointermove", this.globalPointerMoveHandler);
686
+ document.removeEventListener("pointerup", this.globalPointerUpHandler);
687
+ }
688
+ componentDidRender() {
689
+ updateHostInteraction(this);
690
+ }
691
+ //--------------------------------------------------------------------------
692
+ //
693
+ // Render Methods
694
+ //
695
+ //--------------------------------------------------------------------------
696
+ render() {
697
+ const { allowEmpty, color, intlDeleteColor, hideHex, hideChannels, hideSaved, intlHex, intlSaved, intlSaveColor, savedColors, scale } = this;
698
+ const selectedColorInHex = color ? color.hex() : null;
699
+ const hexInputScale = scale === "l" ? "m" : "s";
700
+ const { colorFieldAndSliderInteractive, colorFieldScopeTop, colorFieldScopeLeft, hueScopeLeft, hueScopeTop, scopeOrientation, dimensions: { colorField: { height: colorFieldHeight, width: colorFieldWidth }, slider: { height: sliderHeight } } } = this;
701
+ const hueTop = hueScopeTop !== null && hueScopeTop !== void 0 ? hueScopeTop : sliderHeight / 2 + colorFieldHeight;
702
+ const hueLeft = hueScopeLeft !== null && hueScopeLeft !== void 0 ? hueScopeLeft : (colorFieldWidth * DEFAULT_COLOR.hue()) / HSV_LIMITS.h;
703
+ const noColor = color === null;
704
+ const vertical = scopeOrientation === "vertical";
705
+ return (h("div", { class: CSS.container }, h("div", { class: CSS.colorFieldAndSliderWrap }, h("canvas", { class: {
706
+ [CSS.colorFieldAndSlider]: true,
707
+ [CSS.colorFieldAndSliderInteractive]: colorFieldAndSliderInteractive
708
+ }, onPointerDown: this.handleColorFieldAndSliderPointerDown, onPointerEnter: this.handleColorFieldAndSliderPointerEnterOrMove, onPointerLeave: this.handleColorFieldAndSliderPointerLeave, onPointerMove: this.handleColorFieldAndSliderPointerEnterOrMove, ref: this.initColorFieldAndSlider }), h("div", { "aria-label": vertical ? this.intlValue : this.intlSaturation, "aria-valuemax": vertical ? HSV_LIMITS.v : HSV_LIMITS.s, "aria-valuemin": "0", "aria-valuenow": (vertical ? color === null || color === void 0 ? void 0 : color.saturationv() : color === null || color === void 0 ? void 0 : color.value()) || "0", class: { [CSS.scope]: true, [CSS.colorFieldScope]: true }, onKeyDown: this.handleColorFieldScopeKeyDown, ref: this.storeColorFieldScope, role: "slider", style: { top: `${colorFieldScopeTop || 0}px`, left: `${colorFieldScopeLeft || 0}px` }, tabindex: "0" }), h("div", { "aria-label": this.intlHue, "aria-valuemax": HSV_LIMITS.h, "aria-valuemin": "0", "aria-valuenow": (color === null || color === void 0 ? void 0 : color.round().hue()) || DEFAULT_COLOR.round().hue(), class: { [CSS.scope]: true, [CSS.hueScope]: true }, onKeyDown: this.handleHueScopeKeyDown, ref: this.storeHueScope, role: "slider", style: { top: `${hueTop}px`, left: `${hueLeft}px` }, tabindex: "0" })), hideHex && hideChannels ? null : (h("div", { class: {
709
+ [CSS.controlSection]: true,
710
+ [CSS.section]: true
711
+ } }, hideHex ? null : (h("div", { class: CSS.hexOptions }, h("span", { class: {
712
+ [CSS.header]: true,
713
+ [CSS.headerHex]: true
714
+ } }, intlHex), h("calcite-color-picker-hex-input", { allowEmpty: allowEmpty, class: CSS.control, numberingSystem: this.numberingSystem, onCalciteColorPickerHexInputChange: this.handleHexInputChange, scale: hexInputScale, value: selectedColorInHex }))), hideChannels ? null : (h("calcite-tabs", { class: {
715
+ [CSS.colorModeContainer]: true,
716
+ [CSS.splitSection]: true
717
+ }, scale: hexInputScale }, h("calcite-tab-nav", { slot: "tab-nav" }, this.renderChannelsTabTitle("rgb"), this.renderChannelsTabTitle("hsv")), this.renderChannelsTab("rgb"), this.renderChannelsTab("hsv"))))), hideSaved ? null : (h("div", { class: { [CSS.savedColorsSection]: true, [CSS.section]: true } }, h("div", { class: CSS.header }, h("label", null, intlSaved), h("div", { class: CSS.savedColorsButtons }, h("calcite-button", { appearance: "transparent", class: CSS.deleteColor, color: "neutral", disabled: noColor, iconStart: "minus", label: intlDeleteColor, onClick: this.deleteColor, scale: hexInputScale, type: "button" }), h("calcite-button", { appearance: "transparent", class: CSS.saveColor, color: "neutral", disabled: noColor, iconStart: "plus", label: intlSaveColor, onClick: this.saveColor, scale: hexInputScale, type: "button" }))), savedColors.length > 0 ? (h("div", { class: CSS.savedColors }, [
718
+ ...savedColors.map((color) => (h("calcite-color-picker-swatch", { active: selectedColorInHex === color, class: CSS.savedColor, color: color, key: color, onClick: this.handleSavedColorSelect, onKeyDown: this.handleSavedColorKeyDown, scale: scale, tabIndex: 0 })))
719
+ ])) : null))));
720
+ }
721
+ // --------------------------------------------------------------------------
722
+ //
723
+ // Private Methods
724
+ //
725
+ //--------------------------------------------------------------------------
726
+ handleKeyDown(event) {
727
+ if (event.key === "Enter") {
728
+ event.preventDefault();
729
+ }
730
+ }
731
+ showIncompatibleColorWarning(value, format) {
732
+ console.warn(`ignoring color value (${value}) as it is not compatible with the current format (${format})`);
733
+ }
734
+ setMode(format) {
735
+ this.mode = format === "auto" ? this.mode : format;
736
+ }
737
+ captureHueSliderColor(x) {
738
+ const { dimensions: { slider: { width } } } = this;
739
+ const hue = (360 / width) * x;
740
+ this.internalColorSet(this.baseColorFieldColor.hue(hue), false);
741
+ }
742
+ getCanvasRegion(y) {
743
+ const { dimensions: { colorField: { height: colorFieldHeight }, slider: { height: sliderHeight } } } = this;
744
+ if (y <= colorFieldHeight) {
745
+ return "color-field";
746
+ }
747
+ if (y <= colorFieldHeight + sliderHeight) {
748
+ return "slider";
749
+ }
750
+ return "none";
751
+ }
752
+ internalColorSet(color, skipEqual = true, context = "user-interaction") {
753
+ if (skipEqual && colorEqual(color, this.color)) {
754
+ return;
755
+ }
756
+ this.internalColorUpdateContext = context;
757
+ this.color = color;
758
+ this.value = this.toValue(color);
759
+ this.internalColorUpdateContext = null;
760
+ }
761
+ toValue(color, format = this.mode) {
762
+ if (!color) {
763
+ return null;
764
+ }
765
+ const hexMode = "hex";
766
+ if (format.includes(hexMode)) {
767
+ return normalizeHex(color.round()[hexMode]());
768
+ }
769
+ if (format.includes("-css")) {
770
+ return color[format.replace("-css", "").replace("a", "")]().round().string();
771
+ }
772
+ const colorObject = color[format]().round().object();
773
+ if (format.endsWith("a")) {
774
+ // normalize alpha prop
775
+ colorObject.a = colorObject.alpha;
776
+ delete colorObject.alpha;
777
+ }
778
+ return colorObject;
779
+ }
780
+ getSliderCapSpacing() {
781
+ const { dimensions: { slider: { height }, thumb: { radius } } } = this;
782
+ return radius * 2 - height;
783
+ }
784
+ updateDimensions(scale = "m") {
785
+ this.dimensions = DIMENSIONS[scale];
786
+ }
787
+ drawColorField() {
788
+ const context = this.fieldAndSliderRenderingContext;
789
+ const { dimensions: { colorField: { height, width } } } = this;
790
+ context.fillStyle = this.baseColorFieldColor.hsv().saturationv(100).value(100).string();
791
+ context.fillRect(0, 0, width, height);
792
+ const whiteGradient = context.createLinearGradient(0, 0, width, 0);
793
+ whiteGradient.addColorStop(0, "rgba(255,255,255,1)");
794
+ whiteGradient.addColorStop(1, "rgba(255,255,255,0)");
795
+ context.fillStyle = whiteGradient;
796
+ context.fillRect(0, 0, width, height);
797
+ const blackGradient = context.createLinearGradient(0, 0, 0, height);
798
+ blackGradient.addColorStop(0, "rgba(0,0,0,0)");
799
+ blackGradient.addColorStop(1, "rgba(0,0,0,1)");
800
+ context.fillStyle = blackGradient;
801
+ context.fillRect(0, 0, width, height);
802
+ this.drawActiveColorFieldColor();
803
+ }
804
+ setCanvasContextSize(canvas, { height, width }) {
805
+ const devicePixelRatio = window.devicePixelRatio || 1;
806
+ canvas.width = width * devicePixelRatio;
807
+ canvas.height = height * devicePixelRatio;
808
+ canvas.style.height = `${height}px`;
809
+ canvas.style.width = `${width}px`;
810
+ const context = canvas.getContext("2d");
811
+ context.scale(devicePixelRatio, devicePixelRatio);
812
+ }
813
+ updateCanvasSize(canvas) {
814
+ if (!canvas) {
815
+ return;
816
+ }
817
+ this.setCanvasContextSize(canvas, {
818
+ width: this.dimensions.colorField.width,
819
+ height: this.dimensions.colorField.height +
820
+ this.dimensions.slider.height +
821
+ this.getSliderCapSpacing() * 2
822
+ });
823
+ this.drawColorFieldAndSlider();
824
+ }
825
+ containsPoint(testPointX, testPointY, boundsX, boundsY, boundsRadius) {
826
+ return (Math.pow(testPointX - boundsX, 2) + Math.pow(testPointY - boundsY, 2) <=
827
+ Math.pow(boundsRadius, 2));
828
+ }
829
+ drawActiveColorFieldColor() {
830
+ const { color } = this;
831
+ if (!color) {
832
+ return;
833
+ }
834
+ const hsvColor = color.hsv();
835
+ const { dimensions: { colorField: { height, width }, thumb: { radius } } } = this;
836
+ const x = hsvColor.saturationv() / (HSV_LIMITS.s / width);
837
+ const y = height - hsvColor.value() / (HSV_LIMITS.v / height);
838
+ requestAnimationFrame(() => {
839
+ this.colorFieldScopeLeft = x;
840
+ this.colorFieldScopeTop = y;
841
+ });
842
+ this.drawThumb(this.fieldAndSliderRenderingContext, radius, x, y, hsvColor, this.hueThumbState);
843
+ }
844
+ drawThumb(context, radius, x, y, color, state) {
845
+ const startAngle = 0;
846
+ const endAngle = 2 * Math.PI;
847
+ context.beginPath();
848
+ context.arc(x, y, radius, startAngle, endAngle);
849
+ context.shadowBlur = state === "hover" ? 32 : 16;
850
+ context.shadowColor = `rgba(0, 0, 0, ${state === "drag" ? 0.32 : 0.16})`;
851
+ context.fillStyle = "#fff";
852
+ context.fill();
853
+ context.beginPath();
854
+ context.arc(x, y, radius - 3, startAngle, endAngle);
855
+ context.shadowBlur = 0;
856
+ context.shadowColor = "transparent";
857
+ context.fillStyle = color.rgb().string();
858
+ context.fill();
859
+ }
860
+ drawActiveHueSliderColor() {
861
+ const { color } = this;
862
+ if (!color) {
863
+ return;
864
+ }
865
+ const hsvColor = color.hsv().saturationv(100).value(100);
866
+ const { dimensions: { colorField: { height: colorFieldHeight }, slider: { height, width }, thumb: { radius } } } = this;
867
+ const x = hsvColor.hue() / (360 / width);
868
+ const y = height / 2 + colorFieldHeight;
869
+ requestAnimationFrame(() => {
870
+ this.hueScopeLeft = x;
871
+ this.hueScopeTop = y;
872
+ });
873
+ this.drawThumb(this.fieldAndSliderRenderingContext, radius, x, y, hsvColor, this.sliderThumbState);
874
+ }
875
+ drawHueSlider() {
876
+ const context = this.fieldAndSliderRenderingContext;
877
+ const { dimensions: { colorField: { height: colorFieldHeight }, slider: { height, width } } } = this;
878
+ const gradient = context.createLinearGradient(0, 0, width, 0);
879
+ const hueSliderColorStopKeywords = ["red", "yellow", "lime", "cyan", "blue", "magenta", "red"];
880
+ const offset = 1 / (hueSliderColorStopKeywords.length - 1);
881
+ let currentOffset = 0;
882
+ hueSliderColorStopKeywords.forEach((keyword) => {
883
+ gradient.addColorStop(currentOffset, color(keyword).string());
884
+ currentOffset += offset;
885
+ });
886
+ context.fillStyle = gradient;
887
+ context.clearRect(0, colorFieldHeight, width, height + this.getSliderCapSpacing() * 2);
888
+ context.fillRect(0, colorFieldHeight, width, height);
889
+ this.drawActiveHueSliderColor();
890
+ }
891
+ updateColorFromChannels(channels) {
892
+ this.internalColorSet(color(channels, this.channelMode));
893
+ }
894
+ updateChannelsFromColor(color) {
895
+ this.channels = color ? this.toChannels(color) : [null, null, null];
896
+ }
897
+ toChannels(color) {
898
+ const { channelMode } = this;
899
+ return color[channelMode]()
900
+ .array()
901
+ .map((value) => Math.floor(value));
902
+ }
903
+ get el() { return getElement(this); }
904
+ static get watchers() { return {
905
+ "color": ["handleColorChange"],
906
+ "format": ["handleFormatChange"],
907
+ "scale": ["handleScaleChange"],
908
+ "value": ["handleValueChange"]
909
+ }; }
910
+ };
911
+ ColorPicker.style = colorPickerCss;
912
+
913
+ export { ColorPicker as calcite_color_picker };