@vonage/vivid 5.2.0 → 5.4.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 (433) hide show
  1. package/accordion-item/definition.cjs +2 -1
  2. package/accordion-item/definition.js +3 -2
  3. package/alert/definition.cjs +1 -1
  4. package/alert/definition.js +2 -2
  5. package/alert/index.cjs +1 -1
  6. package/alert/index.js +1 -1
  7. package/audio-player/definition.cjs +4 -2
  8. package/audio-player/definition.js +4 -2
  9. package/audio-player/index.cjs +5 -3
  10. package/audio-player/index.js +5 -3
  11. package/badge/definition.js +1 -1
  12. package/badge/index.cjs +2 -2
  13. package/badge/index.js +4 -4
  14. package/banner/definition.js +1 -1
  15. package/banner/index.cjs +3 -3
  16. package/banner/index.js +6 -6
  17. package/breadcrumb-item/index.cjs +1 -1
  18. package/breadcrumb-item/index.js +1 -1
  19. package/bundled/affix.cjs +7 -7
  20. package/bundled/affix.js +5 -5
  21. package/bundled/anchored.cjs +1 -1
  22. package/bundled/anchored.js +6 -6
  23. package/bundled/attribute-binding-behaviour.cjs +1 -1
  24. package/bundled/attribute-binding-behaviour.js +15 -13
  25. package/bundled/base-color-picker.cjs +13 -0
  26. package/bundled/base-color-picker.js +194 -0
  27. package/bundled/button.cjs +1 -1
  28. package/bundled/button.js +2 -2
  29. package/bundled/calendar-picker.template.cjs +7 -7
  30. package/bundled/calendar-picker.template.js +118 -118
  31. package/bundled/char-count.cjs +1 -1
  32. package/bundled/char-count.js +1 -1
  33. package/bundled/children.cjs +1 -1
  34. package/bundled/children.js +28 -20
  35. package/bundled/definition.cjs +3 -3
  36. package/bundled/definition.js +38 -38
  37. package/bundled/definition10.cjs +72 -18
  38. package/bundled/definition10.js +351 -65
  39. package/bundled/definition11.cjs +19 -10
  40. package/bundled/definition11.js +217 -36
  41. package/bundled/definition12.cjs +10 -1
  42. package/bundled/definition12.js +38 -14
  43. package/bundled/definition13.cjs +1 -73
  44. package/bundled/definition13.js +15 -354
  45. package/bundled/definition15.cjs +1 -1
  46. package/bundled/definition15.js +1 -1
  47. package/bundled/definition16.cjs +2 -2
  48. package/bundled/definition16.js +8 -8
  49. package/bundled/definition17.cjs +7 -7
  50. package/bundled/definition17.js +17 -17
  51. package/bundled/definition19.cjs +23 -24
  52. package/bundled/definition19.js +151 -163
  53. package/bundled/definition2.cjs +9 -5
  54. package/bundled/definition2.js +21 -17
  55. package/bundled/definition22.cjs +9 -9
  56. package/bundled/definition22.js +31 -31
  57. package/bundled/definition3.cjs +1 -1
  58. package/bundled/definition3.js +1 -1
  59. package/bundled/definition6.cjs +3 -3
  60. package/bundled/definition6.js +28 -28
  61. package/bundled/definition7.cjs +1 -1
  62. package/bundled/definition7.js +6 -6
  63. package/bundled/definition8.cjs +2 -2
  64. package/bundled/definition8.js +4 -4
  65. package/bundled/definition9.cjs +5 -5
  66. package/bundled/definition9.js +394 -392
  67. package/bundled/delegates-aria.cjs +1 -1
  68. package/bundled/delegates-aria.js +59 -46
  69. package/bundled/form-associated.cjs +1 -1
  70. package/bundled/form-associated.js +3 -3
  71. package/bundled/host-semantics.cjs +1 -1
  72. package/bundled/host-semantics.js +48 -34
  73. package/bundled/listbox.cjs +1 -1
  74. package/bundled/listbox.js +82 -102
  75. package/bundled/localized.cjs +1 -1
  76. package/bundled/localized.js +51 -36
  77. package/bundled/mixins.cjs +18 -18
  78. package/bundled/mixins.js +99 -93
  79. package/bundled/normalize.cjs +1 -0
  80. package/bundled/normalize.js +7 -0
  81. package/bundled/picker-field.template.cjs +1 -1
  82. package/bundled/picker-field.template.js +4 -4
  83. package/bundled/ref.cjs +1 -1
  84. package/bundled/ref.js +8 -25
  85. package/bundled/repeat.cjs +1 -1
  86. package/bundled/repeat.js +459 -233
  87. package/bundled/slider.template.cjs +1 -1
  88. package/bundled/slider.template.js +2 -2
  89. package/bundled/slotted.cjs +1 -1
  90. package/bundled/slotted.js +62 -45
  91. package/bundled/time-selection-picker.template.cjs +1 -1
  92. package/bundled/time-selection-picker.template.js +5 -5
  93. package/bundled/vivid-element.cjs +5 -1
  94. package/bundled/vivid-element.js +2159 -1162
  95. package/bundled/when.cjs +1 -1
  96. package/bundled/when.js +8 -7
  97. package/calendar/definition.cjs +1 -1
  98. package/calendar/definition.js +2 -2
  99. package/calendar/index.cjs +1 -1
  100. package/calendar/index.js +15 -15
  101. package/calendar-event/index.cjs +1 -1
  102. package/calendar-event/index.js +1 -1
  103. package/card/definition.cjs +11 -3
  104. package/card/definition.js +11 -3
  105. package/card/index.cjs +19 -11
  106. package/card/index.js +35 -27
  107. package/color-picker/definition.cjs +1079 -0
  108. package/color-picker/definition.js +1073 -0
  109. package/color-picker/index.cjs +127 -0
  110. package/color-picker/index.js +726 -0
  111. package/combobox/definition.cjs +8 -28
  112. package/combobox/definition.js +10 -30
  113. package/combobox/index.cjs +7 -7
  114. package/combobox/index.js +60 -74
  115. package/contextual-help/index.cjs +1 -1
  116. package/contextual-help/index.js +1 -1
  117. package/custom-elements.json +1670 -163
  118. package/data-grid/definition.cjs +862 -27
  119. package/data-grid/definition.js +863 -28
  120. package/data-grid/index.cjs +25 -25
  121. package/data-grid/index.js +175 -168
  122. package/date-picker/definition.cjs +1 -1
  123. package/date-picker/definition.js +1 -1
  124. package/date-picker/index.cjs +1 -1
  125. package/date-picker/index.js +2 -2
  126. package/date-range-picker/definition.cjs +1 -1
  127. package/date-range-picker/definition.js +1 -1
  128. package/date-range-picker/index.cjs +1 -1
  129. package/date-range-picker/index.js +2 -2
  130. package/date-time-picker/definition.cjs +1 -1
  131. package/date-time-picker/definition.js +1 -1
  132. package/date-time-picker/index.cjs +1 -1
  133. package/date-time-picker/index.js +2 -2
  134. package/dial-pad/definition.cjs +4 -0
  135. package/dial-pad/definition.js +4 -0
  136. package/dial-pad/index.cjs +3 -3
  137. package/dial-pad/index.js +42 -39
  138. package/dialog/definition.cjs +6 -3
  139. package/dialog/definition.js +6 -3
  140. package/dialog/index.cjs +22 -19
  141. package/dialog/index.js +48 -45
  142. package/elevation/definition.cjs +1 -1
  143. package/elevation/definition.js +1 -1
  144. package/empty-state/definition.cjs +7 -2
  145. package/empty-state/definition.js +7 -2
  146. package/empty-state/index.cjs +10 -5
  147. package/empty-state/index.js +18 -13
  148. package/fab/definition.js +1 -1
  149. package/fab/index.cjs +2 -2
  150. package/fab/index.js +4 -4
  151. package/file-picker/definition.cjs +2 -2
  152. package/file-picker/definition.js +3 -3
  153. package/file-picker/index.cjs +1 -1
  154. package/file-picker/index.js +4 -4
  155. package/header/definition.cjs +1 -1
  156. package/header/definition.js +1 -1
  157. package/icon/definition.cjs +10 -6
  158. package/icon/definition.js +10 -6
  159. package/index.cjs +7 -4
  160. package/index.js +3 -3
  161. package/lib/accordion/accordion.d.ts +1 -1
  162. package/lib/accordion/definition.d.ts +1 -1
  163. package/lib/accordion-item/accordion-item.d.ts +2 -2
  164. package/lib/action-group/action-group.d.ts +2 -2
  165. package/lib/alert/alert.d.ts +4 -4
  166. package/lib/audio-player/audio-player.d.ts +3 -3
  167. package/lib/avatar/avatar.d.ts +2 -2
  168. package/lib/badge/badge.d.ts +2 -2
  169. package/lib/banner/banner.d.ts +6 -6
  170. package/lib/breadcrumb/breadcrumb.d.ts +2 -2
  171. package/lib/breadcrumb-item/breadcrumb-item.d.ts +2 -2
  172. package/lib/button/button.d.ts +6 -6
  173. package/lib/button/button.template.d.ts +2 -1
  174. package/lib/calendar/calendar.d.ts +1 -1
  175. package/lib/calendar-event/calendar-event.d.ts +2 -2
  176. package/lib/card/card.d.ts +2 -2
  177. package/lib/checkbox/checkbox.d.ts +12 -12
  178. package/lib/color-picker/color-picker.d.ts +2420 -0
  179. package/lib/color-picker/color-picker.template.d.ts +3 -0
  180. package/lib/color-picker/definition.d.ts +4 -0
  181. package/lib/color-picker/locale.d.ts +9 -0
  182. package/lib/combobox/combobox.d.ts +15 -14
  183. package/lib/combobox/combobox.options.d.ts +1 -1
  184. package/lib/components.d.ts +1 -0
  185. package/lib/data-grid/data-grid-cell.d.ts +4 -4
  186. package/lib/data-grid/data-grid-row.d.ts +3 -4
  187. package/lib/data-grid/data-grid.d.ts +1 -2
  188. package/lib/date-picker/date-picker.d.ts +54 -54
  189. package/lib/date-range-picker/date-range-picker.d.ts +28 -28
  190. package/lib/date-time-picker/date-time-picker.d.ts +56 -56
  191. package/lib/dial-pad/dial-pad.d.ts +3 -2
  192. package/lib/dialog/dialog.d.ts +4 -4
  193. package/lib/divider/divider.d.ts +3 -3
  194. package/lib/fab/fab.d.ts +2 -2
  195. package/lib/file-picker/file-picker.d.ts +14 -14
  196. package/lib/header/header.d.ts +2 -2
  197. package/lib/menu/menu.d.ts +4 -4
  198. package/lib/menu-item/menu-item-role.d.ts +1 -1
  199. package/lib/menu-item/menu-item.d.ts +4 -4
  200. package/lib/nav/nav.d.ts +2 -2
  201. package/lib/nav-disclosure/nav-disclosure.d.ts +4 -4
  202. package/lib/nav-item/nav-item.d.ts +4 -4
  203. package/lib/note/note.d.ts +2 -2
  204. package/lib/number-field/number-field.d.ts +18 -18
  205. package/lib/option/option.d.ts +4 -4
  206. package/lib/pagination/pagination.d.ts +2 -2
  207. package/lib/popup/popup.d.ts +1 -1
  208. package/lib/progress/progress.d.ts +2 -2
  209. package/lib/progress-ring/progress-ring.d.ts +2 -2
  210. package/lib/radio/radio.d.ts +6 -6
  211. package/lib/radio-group/radio-group.d.ts +2 -2
  212. package/lib/range-slider/range-slider.d.ts +6 -6
  213. package/lib/rich-text-editor/menubar/menubar.d.ts +2 -2
  214. package/lib/rich-text-editor/rich-text-editor.d.ts +2 -2
  215. package/lib/searchable-select/locale.d.ts +4 -0
  216. package/lib/searchable-select/option-tag.d.ts +2 -2
  217. package/lib/searchable-select/searchable-select.d.ts +21 -18
  218. package/lib/select/select.d.ts +19 -17
  219. package/lib/selectable-box/selectable-box.d.ts +2 -2
  220. package/lib/simple-color-picker/locale.d.ts +0 -1
  221. package/lib/simple-color-picker/simple-color-picker.d.ts +47 -821
  222. package/lib/slider/slider.d.ts +7 -7
  223. package/lib/split-button/split-button.d.ts +6 -6
  224. package/lib/switch/switch.d.ts +4 -4
  225. package/lib/tab/tab.d.ts +6 -6
  226. package/lib/tab-panel/tab-panel.d.ts +2 -2
  227. package/lib/tabs/tabs.d.ts +2 -2
  228. package/lib/tag/tag.d.ts +6 -6
  229. package/lib/tag-group/tag-group.d.ts +2 -2
  230. package/lib/tag-name-map.d.ts +2 -1
  231. package/lib/text-area/text-area.d.ts +17 -17
  232. package/lib/text-field/text-field.d.ts +19 -19
  233. package/lib/time-picker/time-picker.d.ts +28 -28
  234. package/lib/toggletip/toggletip.d.ts +4 -4
  235. package/lib/tooltip/tooltip.d.ts +2 -2
  236. package/lib/tree-item/tree-item.d.ts +4 -4
  237. package/lib/tree-view/tree-view.d.ts +2 -2
  238. package/lib/video-player/video-player.d.ts +2 -2
  239. package/locales/de-DE.cjs +17 -2
  240. package/locales/de-DE.js +17 -2
  241. package/locales/en-GB.cjs +17 -2
  242. package/locales/en-GB.js +17 -2
  243. package/locales/en-US.cjs +17 -2
  244. package/locales/en-US.js +17 -2
  245. package/locales/ja-JP.cjs +17 -2
  246. package/locales/ja-JP.js +17 -2
  247. package/locales/zh-CN.cjs +17 -2
  248. package/locales/zh-CN.js +17 -2
  249. package/menu/definition.cjs +6 -6
  250. package/menu/definition.js +7 -7
  251. package/nav-disclosure/definition.js +1 -1
  252. package/nav-item/definition.js +1 -1
  253. package/note/definition.js +1 -1
  254. package/note/index.cjs +2 -2
  255. package/note/index.js +4 -4
  256. package/number-field/definition.cjs +1 -1
  257. package/number-field/definition.js +3 -3
  258. package/number-field/index.cjs +5 -5
  259. package/number-field/index.js +21 -21
  260. package/option/definition.cjs +6 -77
  261. package/option/definition.js +3 -78
  262. package/option/index.cjs +1 -1
  263. package/option/index.js +1 -1
  264. package/package.json +34 -8
  265. package/pagination/definition.cjs +2 -1
  266. package/pagination/definition.js +2 -1
  267. package/pagination/index.cjs +12 -12
  268. package/pagination/index.js +59 -59
  269. package/popup/definition.cjs +2 -2
  270. package/popup/definition.js +2 -2
  271. package/progress/index.cjs +1 -1
  272. package/progress/index.js +1 -1
  273. package/radio/definition.cjs +9 -9
  274. package/radio/definition.js +10 -10
  275. package/radio-group/definition.cjs +2 -1
  276. package/radio-group/definition.js +2 -1
  277. package/radio-group/index.cjs +5 -5
  278. package/radio-group/index.js +80 -77
  279. package/range-slider/definition.cjs +1 -1
  280. package/range-slider/definition.js +1 -1
  281. package/range-slider/index.cjs +1 -1
  282. package/range-slider/index.js +1 -1
  283. package/rich-text-editor/definition.cjs +3 -4
  284. package/rich-text-editor/definition.js +3 -4
  285. package/rich-text-editor/index.cjs +27 -27
  286. package/rich-text-editor/index.js +1208 -1198
  287. package/searchable-select/definition.cjs +106 -14
  288. package/searchable-select/definition.js +107 -15
  289. package/searchable-select/index.cjs +81 -69
  290. package/searchable-select/index.js +362 -276
  291. package/select/definition.cjs +25 -42
  292. package/select/definition.js +26 -43
  293. package/selectable-box/definition.cjs +1 -1
  294. package/selectable-box/definition.js +1 -1
  295. package/selectable-box/index.cjs +3 -3
  296. package/selectable-box/index.js +20 -20
  297. package/shared/aria/aria-change-subscription.d.ts +0 -1
  298. package/shared/aria/aria-mixin.d.ts +3 -3
  299. package/shared/aria/delegate-aria-behavior.d.ts +5 -10
  300. package/shared/aria/delegates-aria.d.ts +3 -3
  301. package/shared/aria/host-semantics-behavior.d.ts +5 -8
  302. package/shared/aria/host-semantics.d.ts +3 -3
  303. package/shared/color-picker/base-color-picker.d.ts +436 -0
  304. package/shared/color-picker/index.d.ts +1 -0
  305. package/shared/color-picker/locale.d.ts +3 -0
  306. package/shared/color-picker/utils.d.ts +1 -0
  307. package/shared/deprecation/replaced-props.d.ts +317 -2
  308. package/shared/design-system/defineVividComponent.d.ts +2 -2
  309. package/shared/feedback/feedback-message.d.ts +2 -2
  310. package/shared/feedback/mixins.d.ts +4 -4
  311. package/shared/foundation/button/button.d.ts +4 -4
  312. package/shared/foundation/form-associated/form-associated.d.ts +4 -4
  313. package/shared/foundation/listbox/listbox.d.ts +4 -0
  314. package/shared/foundation/vivid-element/vivid-element.d.ts +335 -8
  315. package/shared/localization/Locale.d.ts +4 -0
  316. package/shared/patterns/affix.d.ts +4 -4
  317. package/shared/patterns/anchored.d.ts +4 -4
  318. package/shared/patterns/char-count/char-count.d.ts +2 -2
  319. package/shared/patterns/form-elements/form-element.d.ts +4 -4
  320. package/shared/patterns/form-elements/with-contextual-help.d.ts +6 -6
  321. package/shared/patterns/form-elements/with-error-text.d.ts +6 -6
  322. package/shared/patterns/form-elements/with-success-text.d.ts +2 -2
  323. package/shared/patterns/linkable.d.ts +2 -2
  324. package/shared/patterns/localized.d.ts +2 -2
  325. package/shared/patterns/trapped-focus.d.ts +2 -2
  326. package/shared/picker-field/mixins/calendar-picker.d.ts +14 -14
  327. package/shared/picker-field/mixins/calendar-picker.template.d.ts +14 -14
  328. package/shared/picker-field/mixins/inline-time-picker/inline-time-picker.d.ts +2 -2
  329. package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +28 -28
  330. package/shared/picker-field/mixins/single-date-picker.d.ts +40 -40
  331. package/shared/picker-field/mixins/single-value-picker.d.ts +12 -12
  332. package/shared/picker-field/mixins/time-selection-picker.d.ts +29 -29
  333. package/shared/picker-field/mixins/time-selection-picker.template.d.ts +28 -28
  334. package/shared/picker-field/picker-field.d.ts +14 -14
  335. package/shared/templating/attribute-binding-behaviour.d.ts +3 -4
  336. package/shared/templating/render-in-light-dom.d.ts +13 -12
  337. package/side-drawer/index.cjs +1 -1
  338. package/side-drawer/index.js +1 -1
  339. package/simple-color-picker/definition.cjs +29 -216
  340. package/simple-color-picker/definition.js +30 -217
  341. package/simple-color-picker/index.cjs +9 -21
  342. package/simple-color-picker/index.js +71 -185
  343. package/slider/definition.cjs +1 -1
  344. package/slider/definition.js +1 -1
  345. package/split-button/definition.js +1 -1
  346. package/styles/core/all.css +1 -1
  347. package/styles/core/theme.css +1 -1
  348. package/styles/core/typography.css +1 -1
  349. package/styles/tokens/theme-dark.css +4 -4
  350. package/styles/tokens/theme-light.css +4 -4
  351. package/styles/tokens/vivid-2-compat.css +1 -1
  352. package/switch/index.cjs +2 -2
  353. package/switch/index.js +4 -4
  354. package/tab/definition.js +1 -1
  355. package/tabs/definition.cjs +1 -1
  356. package/tabs/definition.js +2 -2
  357. package/tabs/index.cjs +2 -2
  358. package/tabs/index.js +16 -16
  359. package/tag/definition.js +1 -1
  360. package/tag/index.cjs +1 -1
  361. package/tag/index.js +1 -1
  362. package/text-area/index.cjs +3 -3
  363. package/text-area/index.js +8 -8
  364. package/text-field/definition.cjs +2 -2
  365. package/text-field/definition.js +4 -4
  366. package/text-field/index.cjs +1 -1
  367. package/text-field/index.js +1 -1
  368. package/time-picker/definition.cjs +1 -1
  369. package/time-picker/definition.js +1 -1
  370. package/time-picker/index.cjs +1 -1
  371. package/time-picker/index.js +2 -2
  372. package/toggletip/definition.cjs +2 -2
  373. package/toggletip/definition.js +3 -3
  374. package/tooltip/definition.cjs +1 -1
  375. package/tooltip/definition.js +1 -1
  376. package/tree-item/definition.cjs +1 -1
  377. package/tree-item/definition.js +1 -1
  378. package/tree-view/definition.cjs +2 -2
  379. package/tree-view/definition.js +3 -3
  380. package/tree-view/index.cjs +2 -2
  381. package/tree-view/index.js +6 -6
  382. package/unbundled/_commonjsHelpers.cjs +36 -0
  383. package/unbundled/_commonjsHelpers.js +32 -0
  384. package/unbundled/affix.cjs +1 -1
  385. package/unbundled/affix.js +2 -2
  386. package/unbundled/attribute-binding-behaviour.cjs +11 -10
  387. package/unbundled/attribute-binding-behaviour.js +11 -10
  388. package/unbundled/base-color-picker.cjs +278 -0
  389. package/unbundled/base-color-picker.js +275 -0
  390. package/unbundled/button.cjs +1 -1
  391. package/unbundled/button.js +2 -2
  392. package/unbundled/calendar-picker.template.cjs +4 -4
  393. package/unbundled/calendar-picker.template.js +5 -5
  394. package/unbundled/definition.js +1 -1
  395. package/unbundled/definition2.cjs +1 -1
  396. package/unbundled/definition2.js +3 -3
  397. package/unbundled/definition3.cjs +222 -140
  398. package/unbundled/definition3.js +220 -138
  399. package/unbundled/definition4.cjs +145 -235
  400. package/unbundled/definition4.js +143 -233
  401. package/unbundled/definition5.cjs +269 -27
  402. package/unbundled/definition5.js +267 -26
  403. package/unbundled/definition6.cjs +56 -0
  404. package/unbundled/definition6.js +52 -0
  405. package/unbundled/delegates-aria.cjs +67 -33
  406. package/unbundled/delegates-aria.js +69 -35
  407. package/unbundled/form-associated.cjs +2 -2
  408. package/unbundled/form-associated.js +3 -3
  409. package/unbundled/host-semantics.cjs +47 -22
  410. package/unbundled/host-semantics.js +48 -23
  411. package/unbundled/listbox.cjs +41 -63
  412. package/unbundled/listbox.js +39 -61
  413. package/unbundled/mixins.cjs +34 -27
  414. package/unbundled/mixins.js +35 -28
  415. package/unbundled/picker-field.template.cjs +3 -3
  416. package/unbundled/picker-field.template.js +4 -4
  417. package/unbundled/slider.template.cjs +1 -1
  418. package/unbundled/slider.template.js +1 -1
  419. package/unbundled/time-selection-picker.template.cjs +4 -4
  420. package/unbundled/time-selection-picker.template.js +5 -5
  421. package/unbundled/vivid-element.cjs +22 -15
  422. package/unbundled/vivid-element.js +23 -15
  423. package/video-player/definition.cjs +69047 -1
  424. package/video-player/definition.js +69047 -1
  425. package/video-player/index.cjs +36 -36
  426. package/video-player/index.js +1895 -1905
  427. package/visually-hidden/index.cjs +1 -1
  428. package/visually-hidden/index.js +1 -1
  429. package/vivid.api.json +719 -224
  430. package/bundled/option.cjs +0 -1
  431. package/bundled/option.js +0 -158
  432. package/unbundled/option.cjs +0 -217
  433. package/unbundled/option.js +0 -214
@@ -0,0 +1,1079 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const vividElement = require('../unbundled/vivid-element.cjs');
6
+ const popup_definition = require('../unbundled/definition5.cjs');
7
+ const icon_definition = require('../icon/definition.cjs');
8
+ const mixins = require('../unbundled/mixins.cjs');
9
+ const fastElement = require('@microsoft/fast-element');
10
+ const delegatesAria = require('../unbundled/delegates-aria.cjs');
11
+ const withContextualHelp = require('../unbundled/with-contextual-help.cjs');
12
+ const baseColorPicker = require('../unbundled/base-color-picker.cjs');
13
+ const withErrorText = require('../unbundled/with-error-text.cjs');
14
+ const withSuccessText = require('../unbundled/with-success-text.cjs');
15
+ const fastWebUtilities = require('@microsoft/fast-web-utilities');
16
+ const textField_definition = require('../text-field/definition.cjs');
17
+ const button_definition = require('../unbundled/definition.cjs');
18
+
19
+ const styles = ".palette{display:grid;grid-template-columns:repeat(var(--swatches-per-row, 7),var(--_color-swatch-size, 24px))}.swatch{position:relative;padding:0;border:none;border-radius:4px;background-color:var(--swatch-color);block-size:var(--_color-swatch-size, 24px);color:var(--vvd-color-canvas);cursor:pointer;inline-size:var(--_color-swatch-size, 24px)}.swatch.contrast{color:var(--vvd-color-canvas-text)}.swatch:focus-visible{outline:none;box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px));--focus-stroke-gap-color: transparent;--focus-inset: -3px}:host{display:inline-block}.base{display:inline-block;min-inline-size:var(--_color-picker-min-inline-size, 280px)}.control{inline-size:100%}.button{display:inline-flex;box-sizing:border-box;align-items:center;border:0 none;border-radius:4px;margin:0;background-color:var(--button-color, var(--vvd-color-canvas-text));block-size:calc(1px*(32 + 4*clamp(-1,var(--vvd-size-density, 0),2)));color:var(--vvd-color-canvas);inline-size:calc(1px*(32 + 4*clamp(-1,var(--vvd-size-density, 0),2)));padding-inline:calc(1px*(32 + 4*clamp(-1,var(--vvd-size-density, 0),2))/4);text-decoration:none;vertical-align:middle}.button.contrast{color:var(--vvd-color-canvas-text)}.button:not(.disabled){cursor:pointer}.button.disabled{background-color:var(--vvd-color-neutral-300);color:var(--vvd-color-neutral-500);cursor:not-allowed}.button:focus-visible{--focus-stroke-gap-color: transparent;box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px))}.button [data-vvd-component=icon]{font-size:calc(1px*(32 + 4*clamp(-1,var(--vvd-size-density, 0),2))/2);line-height:1}.dialog{display:flex;flex-direction:column;min-inline-size:var(--_color-picker-popup-min-inline-size, 264px)}.dialog .header{display:inline-flex;align-items:center;justify-content:space-between;padding-block:8px;padding-inline:16px}.dialog .header-title{font:var(--vvd-typography-base-extended-bold)}.dialog .body{display:flex;flex-direction:column;gap:16px;margin-block-end:16px;padding-inline:16px}.dialog .hex-input-wrapper{display:flex;align-items:stretch;gap:8px}.dialog .hex-input-wrapper [data-vvd-component=button]{flex:0 0 auto}.dialog .footer{padding:16px;border-top:1px solid var(--vvd-color-neutral-200)}.dialog .footer-title{display:block;margin-block-end:8px}.dialog .palette{gap:var(--_color-swatches-gap, 8px)}vvd-hex-input{min-width:0;flex:1 1 auto}vvd-hex-input::part(input){width:100%;height:100%;box-sizing:border-box;border:0 none;border-radius:8px;background-color:var(--vvd-color-canvas);box-shadow:inset 0 0 0 1px var(--vvd-color-neutral-500);font:var(--vvd-typography-base);outline:transparent;padding-inline:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2))*.4)}vvd-hex-input::part(input):focus-visible{box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px));--focus-stroke-gap-color: transparent}vvd-hex-picker{width:auto;height:auto;gap:16px;inline-size:100%}vvd-hex-picker::part(saturation){border-radius:8px;block-size:120px}vvd-hex-picker::part(hue){flex:0 0 8px;border-radius:8px}vvd-hex-picker::part(hue-pointer){width:10px;height:10px}vvd-hex-picker::part(saturation-pointer){width:18px;height:18px}::part(popup-base){inline-size:max-content;min-block-size:var(--_color-picker-popup-min-inline-size, 264px);min-inline-size:var(--_color-picker-popup-min-inline-size, 264px)}";
20
+
21
+ // Clamps a value between an upper and lower bound.
22
+ // We use ternary operators because it makes the minified code
23
+ // 2 times shorter then `Math.min(Math.max(a,b),c)`
24
+ const clamp = (number, min = 0, max = 1) => {
25
+ return number > max ? max : number < min ? min : number;
26
+ };
27
+ const round = (number, digits = 0, base = Math.pow(10, digits)) => {
28
+ return Math.round(base * number) / base;
29
+ };
30
+
31
+ const hexToHsva = (hex) => rgbaToHsva(hexToRgba(hex));
32
+ const hexToRgba = (hex) => {
33
+ if (hex[0] === '#')
34
+ hex = hex.substring(1);
35
+ if (hex.length < 6) {
36
+ return {
37
+ r: parseInt(hex[0] + hex[0], 16),
38
+ g: parseInt(hex[1] + hex[1], 16),
39
+ b: parseInt(hex[2] + hex[2], 16),
40
+ a: hex.length === 4 ? round(parseInt(hex[3] + hex[3], 16) / 255, 2) : 1
41
+ };
42
+ }
43
+ return {
44
+ r: parseInt(hex.substring(0, 2), 16),
45
+ g: parseInt(hex.substring(2, 4), 16),
46
+ b: parseInt(hex.substring(4, 6), 16),
47
+ a: hex.length === 8 ? round(parseInt(hex.substring(6, 8), 16) / 255, 2) : 1
48
+ };
49
+ };
50
+ const hsvaToHex = (hsva) => rgbaToHex(hsvaToRgba(hsva));
51
+ const hsvaToHsla = ({ h, s, v, a }) => {
52
+ const hh = ((200 - s) * v) / 100;
53
+ return {
54
+ h: round(h),
55
+ s: round(hh > 0 && hh < 200 ? ((s * v) / 100 / (hh <= 100 ? hh : 200 - hh)) * 100 : 0),
56
+ l: round(hh / 2),
57
+ a: round(a, 2)
58
+ };
59
+ };
60
+ const hsvaToHslString = (hsva) => {
61
+ const { h, s, l } = hsvaToHsla(hsva);
62
+ return `hsl(${h}, ${s}%, ${l}%)`;
63
+ };
64
+ const hsvaToRgba = ({ h, s, v, a }) => {
65
+ h = (h / 360) * 6;
66
+ s = s / 100;
67
+ v = v / 100;
68
+ const hh = Math.floor(h), b = v * (1 - s), c = v * (1 - (h - hh) * s), d = v * (1 - (1 - h + hh) * s), module = hh % 6;
69
+ return {
70
+ r: round([v, c, b, b, d, v][module] * 255),
71
+ g: round([d, v, v, c, b, b][module] * 255),
72
+ b: round([b, b, d, v, v, c][module] * 255),
73
+ a: round(a, 2)
74
+ };
75
+ };
76
+ const format = (number) => {
77
+ const hex = number.toString(16);
78
+ return hex.length < 2 ? '0' + hex : hex;
79
+ };
80
+ const rgbaToHex = ({ r, g, b, a }) => {
81
+ const alphaHex = a < 1 ? format(round(a * 255)) : '';
82
+ return '#' + format(r) + format(g) + format(b) + alphaHex;
83
+ };
84
+ const rgbaToHsva = ({ r, g, b, a }) => {
85
+ const max = Math.max(r, g, b);
86
+ const delta = max - Math.min(r, g, b);
87
+ // prettier-ignore
88
+ const hh = delta
89
+ ? max === r
90
+ ? (g - b) / delta
91
+ : max === g
92
+ ? 2 + (b - r) / delta
93
+ : 4 + (r - g) / delta
94
+ : 0;
95
+ return {
96
+ h: round(60 * (hh < 0 ? hh + 6 : hh)),
97
+ s: round(max ? (delta / max) * 100 : 0),
98
+ v: round((max / 255) * 100),
99
+ a
100
+ };
101
+ };
102
+
103
+ const equalColorObjects = (first, second) => {
104
+ if (first === second)
105
+ return true;
106
+ for (const prop in first) {
107
+ // The following allows for a type-safe calling of this function (first & second have to be HSL, HSV, or RGB)
108
+ // with type-unsafe iterating over object keys. TS does not allow this without an index (`[key: string]: number`)
109
+ // on an object to define how iteration is normally done. To ensure extra keys are not allowed on our types,
110
+ // we must cast our object to unknown (as RGB demands `r` be a key, while `Record<string, x>` does not care if
111
+ // there is or not), and then as a type TS can iterate over.
112
+ if (first[prop] !==
113
+ second[prop])
114
+ return false;
115
+ }
116
+ return true;
117
+ };
118
+ const equalHex = (first, second) => {
119
+ if (first.toLowerCase() === second.toLowerCase())
120
+ return true;
121
+ // To compare colors like `#FFF` and `ffffff` we convert them into RGB objects
122
+ return equalColorObjects(hexToRgba(first), hexToRgba(second));
123
+ };
124
+
125
+ const cache = {};
126
+ const tpl = (html) => {
127
+ let template = cache[html];
128
+ if (!template) {
129
+ template = document.createElement('template');
130
+ template.innerHTML = html;
131
+ cache[html] = template;
132
+ }
133
+ return template;
134
+ };
135
+ const fire = (target, type, detail) => {
136
+ target.dispatchEvent(new CustomEvent(type, {
137
+ bubbles: true,
138
+ detail
139
+ }));
140
+ };
141
+
142
+ let hasTouched = false;
143
+ // Check if an event was triggered by touch
144
+ const isTouch = (e) => 'touches' in e;
145
+ // Prevent mobile browsers from handling mouse events (conflicting with touch ones).
146
+ // If we detected a touch interaction before, we prefer reacting to touch events only.
147
+ const isValid = (event) => {
148
+ if (hasTouched && !isTouch(event))
149
+ return false;
150
+ if (!hasTouched)
151
+ hasTouched = isTouch(event);
152
+ return true;
153
+ };
154
+ const pointerMove = (target, event) => {
155
+ const pointer = isTouch(event) ? event.touches[0] : event;
156
+ const rect = target.el.getBoundingClientRect();
157
+ fire(target.el, 'move', target.getMove({
158
+ x: clamp((pointer.pageX - (rect.left + window.pageXOffset)) / rect.width),
159
+ y: clamp((pointer.pageY - (rect.top + window.pageYOffset)) / rect.height)
160
+ }));
161
+ };
162
+ const keyMove = (target, event) => {
163
+ // We use `keyCode` instead of `key` to reduce the size of the library.
164
+ const keyCode = event.keyCode;
165
+ // Ignore all keys except arrow ones, Page Up, Page Down, Home and End.
166
+ if (keyCode > 40 || (target.xy && keyCode < 37) || keyCode < 33)
167
+ return;
168
+ // Do not scroll page by keys when color picker element has focus.
169
+ event.preventDefault();
170
+ // Send relative offset to the parent component.
171
+ fire(target.el, 'move', target.getMove({
172
+ x: keyCode === 39 // Arrow Right
173
+ ? 0.01
174
+ : keyCode === 37 // Arrow Left
175
+ ? -0.01
176
+ : keyCode === 34 // Page Down
177
+ ? 0.05
178
+ : keyCode === 33 // Page Up
179
+ ? -0.05
180
+ : keyCode === 35 // End
181
+ ? 1
182
+ : keyCode === 36 // Home
183
+ ? -1
184
+ : 0,
185
+ y: keyCode === 40 // Arrow down
186
+ ? 0.01
187
+ : keyCode === 38 // Arrow Up
188
+ ? -0.01
189
+ : 0
190
+ }, true));
191
+ };
192
+ class Slider {
193
+ constructor(root, part, aria, xy) {
194
+ const template = tpl(`<div role="slider" tabindex="0" part="${part}" ${aria}><div part="${part}-pointer"></div></div>`);
195
+ root.appendChild(template.content.cloneNode(true));
196
+ const el = root.querySelector(`[part=${part}]`);
197
+ el.addEventListener('mousedown', this);
198
+ el.addEventListener('touchstart', this);
199
+ el.addEventListener('keydown', this);
200
+ this.el = el;
201
+ this.xy = xy;
202
+ this.nodes = [el.firstChild, el];
203
+ }
204
+ set dragging(state) {
205
+ const toggleEvent = state ? document.addEventListener : document.removeEventListener;
206
+ toggleEvent(hasTouched ? 'touchmove' : 'mousemove', this);
207
+ toggleEvent(hasTouched ? 'touchend' : 'mouseup', this);
208
+ }
209
+ handleEvent(event) {
210
+ switch (event.type) {
211
+ case 'mousedown':
212
+ case 'touchstart':
213
+ event.preventDefault();
214
+ // event.button is 0 in mousedown for left button activation
215
+ if (!isValid(event) || (!hasTouched && event.button != 0))
216
+ return;
217
+ this.el.focus();
218
+ pointerMove(this, event);
219
+ this.dragging = true;
220
+ break;
221
+ case 'mousemove':
222
+ case 'touchmove':
223
+ event.preventDefault();
224
+ pointerMove(this, event);
225
+ break;
226
+ case 'mouseup':
227
+ case 'touchend':
228
+ this.dragging = false;
229
+ break;
230
+ case 'keydown':
231
+ keyMove(this, event);
232
+ break;
233
+ }
234
+ }
235
+ style(styles) {
236
+ styles.forEach((style, i) => {
237
+ for (const p in style) {
238
+ this.nodes[i].style.setProperty(p, style[p]);
239
+ }
240
+ });
241
+ }
242
+ }
243
+
244
+ class Hue extends Slider {
245
+ constructor(root) {
246
+ super(root, 'hue', 'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"', false);
247
+ }
248
+ update({ h }) {
249
+ this.h = h;
250
+ this.style([
251
+ {
252
+ left: `${(h / 360) * 100}%`,
253
+ color: hsvaToHslString({ h, s: 100, v: 100, a: 1 })
254
+ }
255
+ ]);
256
+ this.el.setAttribute('aria-valuenow', `${round(h)}`);
257
+ }
258
+ getMove(offset, key) {
259
+ // Hue measured in degrees of the color circle ranging from 0 to 360
260
+ return { h: key ? clamp(this.h + offset.x * 360, 0, 360) : 360 * offset.x };
261
+ }
262
+ }
263
+
264
+ class Saturation extends Slider {
265
+ constructor(root) {
266
+ super(root, 'saturation', 'aria-label="Color"', true);
267
+ }
268
+ update(hsva) {
269
+ this.hsva = hsva;
270
+ this.style([
271
+ {
272
+ top: `${100 - hsva.v}%`,
273
+ left: `${hsva.s}%`,
274
+ color: hsvaToHslString(hsva)
275
+ },
276
+ {
277
+ 'background-color': hsvaToHslString({ h: hsva.h, s: 100, v: 100, a: 1 })
278
+ }
279
+ ]);
280
+ this.el.setAttribute('aria-valuetext', `Saturation ${round(hsva.s)}%, Brightness ${round(hsva.v)}%`);
281
+ }
282
+ getMove(offset, key) {
283
+ // Saturation and brightness always fit into [0, 100] range
284
+ return {
285
+ s: key ? clamp(this.hsva.s + offset.x * 100, 0, 100) : offset.x * 100,
286
+ v: key ? clamp(this.hsva.v - offset.y * 100, 0, 100) : Math.round(100 - offset.y * 100)
287
+ };
288
+ }
289
+ }
290
+
291
+ const css = `:host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}`;
292
+
293
+ const hueCss = `[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}`;
294
+
295
+ const saturationCss = `[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}`;
296
+
297
+ const $isSame = Symbol('same');
298
+ const $color$1 = Symbol('color');
299
+ const $hsva = Symbol('hsva');
300
+ const $update$1 = Symbol('update');
301
+ const $parts = Symbol('parts');
302
+ const $css = Symbol('css');
303
+ const $sliders = Symbol('sliders');
304
+ let ColorPicker$1 = class ColorPicker extends HTMLElement {
305
+ static get observedAttributes() {
306
+ return ['color'];
307
+ }
308
+ get [$css]() {
309
+ return [css, hueCss, saturationCss];
310
+ }
311
+ get [$sliders]() {
312
+ return [Saturation, Hue];
313
+ }
314
+ get color() {
315
+ return this[$color$1];
316
+ }
317
+ set color(newColor) {
318
+ if (!this[$isSame](newColor)) {
319
+ const newHsva = this.colorModel.toHsva(newColor);
320
+ this[$update$1](newHsva);
321
+ this[$color$1] = newColor;
322
+ }
323
+ }
324
+ constructor() {
325
+ super();
326
+ const template = tpl(`<style>${this[$css].join('')}</style>`);
327
+ const root = this.attachShadow({ mode: 'open' });
328
+ root.appendChild(template.content.cloneNode(true));
329
+ root.addEventListener('move', this);
330
+ this[$parts] = this[$sliders].map((slider) => new slider(root));
331
+ }
332
+ connectedCallback() {
333
+ // A user may set a property on an _instance_ of an element,
334
+ // before its prototype has been connected to this class.
335
+ // If so, we need to run it through the proper class setter.
336
+ if (this.hasOwnProperty('color')) {
337
+ const value = this.color;
338
+ delete this['color'];
339
+ this.color = value;
340
+ }
341
+ else if (!this.color) {
342
+ this.color = this.colorModel.defaultColor;
343
+ }
344
+ }
345
+ attributeChangedCallback(_attr, _oldVal, newVal) {
346
+ const color = this.colorModel.fromAttr(newVal);
347
+ if (!this[$isSame](color)) {
348
+ this.color = color;
349
+ }
350
+ }
351
+ handleEvent(event) {
352
+ // Merge the current HSV color object with updated params.
353
+ const oldHsva = this[$hsva];
354
+ const newHsva = { ...oldHsva, ...event.detail };
355
+ this[$update$1](newHsva);
356
+ let newColor;
357
+ if (!equalColorObjects(newHsva, oldHsva) &&
358
+ !this[$isSame]((newColor = this.colorModel.fromHsva(newHsva)))) {
359
+ this[$color$1] = newColor;
360
+ fire(this, 'color-changed', { value: newColor });
361
+ }
362
+ }
363
+ [$isSame](color) {
364
+ return this.color && this.colorModel.equal(color, this.color);
365
+ }
366
+ [$update$1](hsva) {
367
+ this[$hsva] = hsva;
368
+ this[$parts].forEach((part) => part.update(hsva));
369
+ }
370
+ };
371
+
372
+ const colorModel = {
373
+ defaultColor: '#000',
374
+ toHsva: hexToHsva,
375
+ fromHsva: ({ h, s, v }) => hsvaToHex({ h, s, v, a: 1 }),
376
+ equal: equalHex,
377
+ fromAttr: (color) => color
378
+ };
379
+ class HexBase extends ColorPicker$1 {
380
+ get colorModel() {
381
+ return colorModel;
382
+ }
383
+ }
384
+
385
+ /**
386
+ * A color picker custom element that uses HEX format.
387
+ *
388
+ * @element hex-color-picker
389
+ *
390
+ * @prop {string} color - Selected color in HEX format.
391
+ * @attr {string} color - Selected color in HEX format.
392
+ *
393
+ * @fires color-changed - Event fired when color property changes.
394
+ *
395
+ * @csspart hue - A hue selector container.
396
+ * @csspart saturation - A saturation selector container
397
+ * @csspart hue-pointer - A hue pointer element.
398
+ * @csspart saturation-pointer - A saturation pointer element.
399
+ */
400
+ class HexColorPicker extends HexBase {
401
+ }
402
+ customElements.define('hex-color-picker', HexColorPicker);
403
+
404
+ const matcher = /^#?([0-9A-F]{3,8})$/i;
405
+ const validHex = (value, alpha) => {
406
+ const match = matcher.exec(value);
407
+ const length = match ? match[1].length : 0;
408
+ return (length === 3 || // '#rgb' format
409
+ length === 6 || // '#rrggbb' format
410
+ (!!alpha && length === 4) || // '#rgba' format
411
+ (!!alpha && length === 8) // '#rrggbbaa' format
412
+ );
413
+ };
414
+
415
+ const template = tpl('<slot><input part="input" spellcheck="false"></slot>');
416
+ // Escapes all non-hexadecimal characters including "#"
417
+ const escape = (hex, alpha) => hex.replace(/([^0-9A-F]+)/gi, '').substring(0, alpha ? 8 : 6);
418
+ const $alpha = Symbol('alpha');
419
+ const $color = Symbol('color');
420
+ const $saved = Symbol('saved');
421
+ const $input = Symbol('input');
422
+ const $init = Symbol('init');
423
+ const $prefix = Symbol('prefix');
424
+ const $update = Symbol('update');
425
+ class HexInputBase extends HTMLElement {
426
+ static get observedAttributes() {
427
+ return ['alpha', 'color', 'prefixed'];
428
+ }
429
+ get color() {
430
+ return this[$color];
431
+ }
432
+ set color(hex) {
433
+ this[$color] = hex;
434
+ this[$update](hex);
435
+ }
436
+ get alpha() {
437
+ return this[$alpha];
438
+ }
439
+ set alpha(alpha) {
440
+ this[$alpha] = alpha;
441
+ this.toggleAttribute('alpha', alpha);
442
+ // When alpha set to false, update color
443
+ const color = this.color;
444
+ if (color && !validHex(color, alpha)) {
445
+ this.color = color.startsWith('#')
446
+ ? color.substring(0, color.length === 5 ? 4 : 7)
447
+ : color.substring(0, color.length === 4 ? 3 : 6);
448
+ }
449
+ }
450
+ get prefixed() {
451
+ return this[$prefix];
452
+ }
453
+ set prefixed(prefixed) {
454
+ this[$prefix] = prefixed;
455
+ this.toggleAttribute('prefixed', prefixed);
456
+ this[$update](this.color);
457
+ }
458
+ constructor() {
459
+ super();
460
+ const root = this.attachShadow({ mode: 'open' });
461
+ root.appendChild(template.content.cloneNode(true));
462
+ const slot = root.firstElementChild;
463
+ slot.addEventListener('slotchange', () => this[$init](root));
464
+ }
465
+ connectedCallback() {
466
+ this[$init](this.shadowRoot);
467
+ // A user may set a property on an _instance_ of an element,
468
+ // before its prototype has been connected to this class.
469
+ // If so, we need to run it through the proper class setter.
470
+ if (this.hasOwnProperty('alpha')) {
471
+ const value = this.alpha;
472
+ delete this['alpha'];
473
+ this.alpha = value;
474
+ }
475
+ else {
476
+ this.alpha = this.hasAttribute('alpha');
477
+ }
478
+ if (this.hasOwnProperty('prefixed')) {
479
+ const value = this.prefixed;
480
+ delete this['prefixed'];
481
+ this.prefixed = value;
482
+ }
483
+ else {
484
+ this.prefixed = this.hasAttribute('prefixed');
485
+ }
486
+ if (this.hasOwnProperty('color')) {
487
+ const value = this.color;
488
+ delete this['color'];
489
+ this.color = value;
490
+ }
491
+ else if (this.color == null) {
492
+ this.color = this.getAttribute('color') || '';
493
+ }
494
+ else if (this[$color]) {
495
+ this[$update](this[$color]);
496
+ }
497
+ }
498
+ handleEvent(event) {
499
+ const target = event.target;
500
+ const { value } = target;
501
+ switch (event.type) {
502
+ case 'input':
503
+ const hex = escape(value, this.alpha);
504
+ this[$saved] = this.color;
505
+ if (validHex(hex, this.alpha) || value === '') {
506
+ this.color = hex;
507
+ this.dispatchEvent(new CustomEvent('color-changed', {
508
+ bubbles: true,
509
+ detail: { value: hex ? '#' + hex : '' }
510
+ }));
511
+ }
512
+ break;
513
+ case 'blur':
514
+ if (value && !validHex(value, this.alpha)) {
515
+ this.color = this[$saved];
516
+ }
517
+ }
518
+ }
519
+ attributeChangedCallback(attr, _oldVal, newVal) {
520
+ if (attr === 'color' && this.color !== newVal) {
521
+ this.color = newVal;
522
+ }
523
+ const hasBooleanAttr = newVal != null;
524
+ if (attr === 'alpha') {
525
+ if (this.alpha !== hasBooleanAttr) {
526
+ this.alpha = hasBooleanAttr;
527
+ }
528
+ }
529
+ if (attr === 'prefixed') {
530
+ if (this.prefixed !== hasBooleanAttr) {
531
+ this.prefixed = hasBooleanAttr;
532
+ }
533
+ }
534
+ }
535
+ [$init](root) {
536
+ let input = this.querySelector('input');
537
+ if (!input) {
538
+ // remove all child node if no input found
539
+ let c;
540
+ while ((c = this.firstChild)) {
541
+ c.remove();
542
+ }
543
+ input = root.querySelector('input');
544
+ }
545
+ input.addEventListener('input', this);
546
+ input.addEventListener('blur', this);
547
+ this[$input] = input;
548
+ this[$update](this.color);
549
+ }
550
+ [$update](hex) {
551
+ if (this[$input]) {
552
+ this[$input].value =
553
+ hex == null || hex == '' ? '' : (this.prefixed ? '#' : '') + escape(hex, this.alpha);
554
+ }
555
+ }
556
+ }
557
+
558
+ /**
559
+ * A custom element for entering color in HEX format.
560
+ *
561
+ * @element hex-input
562
+ *
563
+ * @prop {string} color - Color in HEX format.
564
+ * @attr {string} color - Selected color in HEX format.
565
+ * @prop {boolean} alpha - When true, `#rgba` and `#rrggbbaa` color formats are allowed.
566
+ * @attr {boolean} alpha - Allows `#rgba` and `#rrggbbaa` color formats.
567
+ * @prop {boolean} prefixed - When true, `#` prefix is displayed in the input.
568
+ * @attr {boolean} prefixed - Enables `#` prefix displaying.
569
+ *
570
+ * @fires color-changed - Event fired when color is changed.
571
+ *
572
+ * @csspart input - A native input element.
573
+ */
574
+ class HexInput extends HexInputBase {
575
+ }
576
+ customElements.define('hex-input', HexInput);
577
+
578
+ var __defProp = Object.defineProperty;
579
+ var __decorateClass = (decorators, target, key, kind) => {
580
+ var result = void 0 ;
581
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
582
+ if (decorator = decorators[i])
583
+ result = (decorator(target, key, result) ) || result;
584
+ if (result) __defProp(target, key, result);
585
+ return result;
586
+ };
587
+ const VC_HEX_PICKER_TAG = "vvd-hex-picker";
588
+ const VC_HEX_INPUT_TAG = "vvd-hex-input";
589
+ class VvdHexPicker extends HexColorPicker {
590
+ static {
591
+ this.displayName = "VvdHexPicker";
592
+ }
593
+ }
594
+ class VvdHexInput extends HexInput {
595
+ static {
596
+ this.displayName = "VvdHexInput";
597
+ }
598
+ }
599
+ if (!customElements.get(VC_HEX_PICKER_TAG)) {
600
+ customElements.define(VC_HEX_PICKER_TAG, VvdHexPicker);
601
+ }
602
+ if (!customElements.get(VC_HEX_INPUT_TAG)) {
603
+ customElements.define(VC_HEX_INPUT_TAG, VvdHexInput);
604
+ }
605
+ const vcPickerTag = VC_HEX_PICKER_TAG;
606
+ const vcInputTag = VC_HEX_INPUT_TAG;
607
+ class ColorPicker extends withContextualHelp.WithContextualHelp(
608
+ mixins.WithFeedback(
609
+ withErrorText.WithErrorText(withSuccessText.WithSuccessText(delegatesAria.DelegatesAria(baseColorPicker.BaseColorPicker(vividElement.VividElement))))
610
+ )
611
+ ) {
612
+ constructor() {
613
+ super(...arguments);
614
+ this.disableSavedColors = false;
615
+ this.savedColors = [];
616
+ this.maxSwatches = 6;
617
+ this.copyIconName = "copy-2-line";
618
+ this.#iconResetTimer = null;
619
+ /**
620
+ * @internal
621
+ */
622
+ this._copyValueToClipboard = async (value) => {
623
+ try {
624
+ await navigator.clipboard.writeText(value);
625
+ this._setTemporaryCopyIcon("check-circle-line");
626
+ } catch {
627
+ alert(this.locale?.colorPicker?.copyErrorText);
628
+ this._setTemporaryCopyIcon("error-line");
629
+ }
630
+ };
631
+ /**
632
+ * @internal
633
+ */
634
+ this.#closeOnPointerOutside = (e) => {
635
+ if (this._isInPath(e, this._buttonEl) || this._isInPath(e, this._popupEl)) {
636
+ return;
637
+ }
638
+ this.open = false;
639
+ };
640
+ /**
641
+ * @internal
642
+ */
643
+ this.#closeOnEscape = (e) => {
644
+ if (e.key === "Escape") {
645
+ this.open = false;
646
+ }
647
+ };
648
+ }
649
+ static {
650
+ /**
651
+ * Regular expression pattern for valid hex colors (with # prefix)
652
+ * Matches both 3-digit (#abc) and 6-digit (#aabbcc) hex colors
653
+ * @internal
654
+ */
655
+ this.HEX_COLOR_PATTERN = /^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$/;
656
+ }
657
+ /**
658
+ * @internal
659
+ */
660
+ placeholderChanged() {
661
+ if (this.proxy instanceof HTMLInputElement) {
662
+ this.proxy.placeholder = this.placeholder;
663
+ }
664
+ }
665
+ /**
666
+ * Change event handler for inner control.
667
+ * @remarks
668
+ * @internal
669
+ */
670
+ handleChange() {
671
+ this.$emit("change");
672
+ }
673
+ /**
674
+ * @internal
675
+ */
676
+ savedColorsKeyChanged() {
677
+ this.savedColors = this._loadSavedColors();
678
+ }
679
+ /**
680
+ * @internal
681
+ */
682
+ get _savedColorsStorageKey() {
683
+ if (this.savedColorsKey) return this.savedColorsKey;
684
+ const tag = this.tagName.toLowerCase();
685
+ return `vvd-saved-colors:${tag}`;
686
+ }
687
+ /**
688
+ * @internal
689
+ */
690
+ _handleColorSaving() {
691
+ this._saveCurrentColor();
692
+ }
693
+ /**
694
+ * @internal
695
+ */
696
+ get _maxSwatchesNormalized() {
697
+ return Number.isFinite(this.maxSwatches) ? Math.max(0, Math.floor(this.maxSwatches)) : 0;
698
+ }
699
+ /**
700
+ * @internal
701
+ */
702
+ maxSwatchesChanged() {
703
+ const maxCount = this._maxSwatchesNormalized;
704
+ if (this.savedColors?.length > maxCount) {
705
+ this.savedColors = this.savedColors.slice(0, maxCount);
706
+ this._setSavedColors(this.savedColors);
707
+ }
708
+ }
709
+ /**
710
+ * @internal
711
+ */
712
+ _onPickerColorChanged(e) {
713
+ if (typeof e.detail?.value === "string") {
714
+ this.value = e.detail?.value;
715
+ }
716
+ }
717
+ /**
718
+ * @internal
719
+ */
720
+ valueChanged(_oldVal, newVal) {
721
+ if (this._vcHexPickerEl && typeof newVal === "string") {
722
+ this._vcHexPickerEl.color = newVal;
723
+ }
724
+ if (this._vcHexInputEl && typeof newVal === "string") {
725
+ this._vcHexInputEl.color = newVal;
726
+ }
727
+ }
728
+ /**
729
+ * @internal
730
+ */
731
+ _onTextFieldInput(event) {
732
+ const textField = event.currentTarget;
733
+ this.value = textField.value;
734
+ }
735
+ /**
736
+ * @internal
737
+ */
738
+ get _buttonColor() {
739
+ if (!this._canvasColor) {
740
+ this._refreshCanvasColor();
741
+ }
742
+ if (this.value && baseColorPicker.isValidHexColor(this.value)) {
743
+ return this.value;
744
+ }
745
+ return "var(--vvd-color-canvas-text)";
746
+ }
747
+ /**
748
+ * @internal
749
+ */
750
+ _onButtonClick() {
751
+ this.open = !this.open;
752
+ }
753
+ /**
754
+ * @internal
755
+ */
756
+ _handleCloseRequest() {
757
+ this.open = false;
758
+ }
759
+ /**
760
+ * @internal
761
+ */
762
+ _isInPath(e, el) {
763
+ if (!el) return false;
764
+ const path = e.composedPath?.();
765
+ return !!(path && path.includes(el));
766
+ }
767
+ #iconResetTimer;
768
+ /**
769
+ * @internal
770
+ */
771
+ _setTemporaryCopyIcon(name, ms = 2e3) {
772
+ this.copyIconName = name;
773
+ if (this.#iconResetTimer) clearTimeout(this.#iconResetTimer);
774
+ this.#iconResetTimer = setTimeout(() => {
775
+ this.copyIconName = "copy-2-line";
776
+ this.#iconResetTimer = null;
777
+ }, ms);
778
+ }
779
+ connectedCallback() {
780
+ super.connectedCallback();
781
+ this._refreshCanvasColor();
782
+ this.savedColors = this._loadSavedColors();
783
+ document.addEventListener("mousedown", this.#closeOnPointerOutside, true);
784
+ document.addEventListener("keydown", this.#closeOnEscape);
785
+ }
786
+ disconnectedCallback() {
787
+ super.disconnectedCallback();
788
+ document.removeEventListener(
789
+ "mousedown",
790
+ this.#closeOnPointerOutside,
791
+ true
792
+ );
793
+ document.removeEventListener("keydown", this.#closeOnEscape);
794
+ }
795
+ #closeOnPointerOutside;
796
+ #closeOnEscape;
797
+ /**
798
+ * @internal
799
+ */
800
+ _saveCurrentColor() {
801
+ const value = this.value;
802
+ if (typeof value !== "string" || !baseColorPicker.isValidHexColor(value)) return;
803
+ const swatches = Array.isArray(this.savedColors) ? [...this.savedColors] : [];
804
+ const idx = swatches.findIndex((s) => s?.value === value);
805
+ if (idx !== -1) swatches.splice(idx, 1);
806
+ swatches.unshift({ value });
807
+ this.savedColors = swatches.slice(0, this._maxSwatchesNormalized);
808
+ this._setSavedColors(this.savedColors);
809
+ }
810
+ /**
811
+ * @internal
812
+ */
813
+ _loadSavedColors() {
814
+ try {
815
+ const savedColors = localStorage.getItem(this._savedColorsStorageKey);
816
+ if (!savedColors) return [];
817
+ const parsed = JSON.parse(savedColors);
818
+ if (!Array.isArray(parsed)) return [];
819
+ return parsed.filter(
820
+ (x) => x && typeof x.value === "string" && baseColorPicker.isValidHexColor(x.value)
821
+ ).map((x) => ({
822
+ value: x.value,
823
+ label: typeof x.label === "string" ? x.label : void 0
824
+ }));
825
+ } catch {
826
+ return [];
827
+ }
828
+ }
829
+ /**
830
+ * @internal
831
+ */
832
+ _setSavedColors(swatches) {
833
+ try {
834
+ localStorage.setItem(
835
+ this._savedColorsStorageKey,
836
+ JSON.stringify(swatches)
837
+ );
838
+ } catch {
839
+ }
840
+ }
841
+ /**
842
+ * Get all color swatches combined, both from swatches property and saved colors
843
+ * @internal
844
+ */
845
+ get allSwatches() {
846
+ const predefinedColors = Array.isArray(this.swatches) ? this.swatches : [];
847
+ const savedColors = Array.isArray(this.savedColors) ? this.savedColors : [];
848
+ const seen = /* @__PURE__ */ new Set();
849
+ const merged = [];
850
+ const appendIfUniqueAndValid = (swatch) => {
851
+ if (!swatch || typeof swatch.value !== "string") return;
852
+ if (!baseColorPicker.isValidHexColor(swatch.value) || seen.has(swatch.value)) return;
853
+ seen.add(swatch.value);
854
+ merged.push(swatch);
855
+ };
856
+ if (!this.disableSavedColors) {
857
+ savedColors.forEach(appendIfUniqueAndValid);
858
+ }
859
+ predefinedColors.forEach(appendIfUniqueAndValid);
860
+ return merged.slice(0, this._maxSwatchesNormalized);
861
+ }
862
+ }
863
+ __decorateClass([
864
+ fastElement.attr
865
+ ], ColorPicker.prototype, "placeholder");
866
+ __decorateClass([
867
+ fastElement.attr({ attribute: "saved-colors-key" })
868
+ ], ColorPicker.prototype, "savedColorsKey");
869
+ __decorateClass([
870
+ fastElement.attr({
871
+ mode: "boolean",
872
+ attribute: "disable-saved-colors"
873
+ })
874
+ ], ColorPicker.prototype, "disableSavedColors");
875
+ __decorateClass([
876
+ fastElement.observable
877
+ ], ColorPicker.prototype, "savedColors");
878
+ __decorateClass([
879
+ fastElement.attr({
880
+ attribute: "max-swatches",
881
+ mode: "fromView",
882
+ converter: fastElement.nullableNumberConverter
883
+ })
884
+ ], ColorPicker.prototype, "maxSwatches");
885
+ __decorateClass([
886
+ fastElement.observable
887
+ ], ColorPicker.prototype, "copyIconName");
888
+
889
+ function renderTextField(textFieldTag, iconTag) {
890
+ const getClasses = (_) => fastWebUtilities.classNames("control");
891
+ return fastElement.html`
892
+ <${textFieldTag}
893
+ id="text-field"
894
+ class="${getClasses}"
895
+ pattern="${ColorPicker.HEX_COLOR_PATTERN.source}"
896
+ maxlength="7"
897
+ label="${(x) => x.label}"
898
+ :value="${(x) => x.value}"
899
+ placeholder="${(x) => x.placeholder}"
900
+ helper-text="${(x) => x.helperText}"
901
+ error-text="${(x) => x.errorValidationMessage}"
902
+ success-text="${(x) => x.successText}"
903
+ ?disabled="${(x) => x.disabled}"
904
+ ?required="${(x) => x.required}"
905
+ @input='${(x, c) => x._onTextFieldInput(c.event)}'
906
+ @change="${(x) => x.handleChange()}"
907
+ @blur="${(x) => {
908
+ x.$emit("blur", void 0, { bubbles: false });
909
+ }}"
910
+ @focus="${(x) => {
911
+ x.$emit("focus", void 0, { bubbles: false });
912
+ }}"
913
+ ${delegatesAria.delegateAria()}
914
+ ${fastElement.ref("_textFieldEl")}
915
+ >
916
+ <button
917
+ aria-label="${(x) => x.locale.colorPicker.pickerButtonLabel}"
918
+ class="button ${(x) => fastWebUtilities.classNames(
919
+ x._applyContrastClass(x._buttonColor) ? "contrast" : "",
920
+ x.disabled ? "disabled" : ""
921
+ )}"
922
+ style="--button-color: ${(x) => x._buttonColor};"
923
+ ?disabled="${(x) => x.disabled}"
924
+ @click="${(x) => x._onButtonClick()}"
925
+ slot="action-items"
926
+ ${fastElement.ref("_buttonEl")}>
927
+ <${iconTag} name="edit-line"></${iconTag}>
928
+ </button>
929
+ <slot
930
+ slot="${(x) => x._helperTextSlottedContent?.length ? "helper-text" : void 0}"
931
+ name="helper-text"
932
+ ${fastElement.slotted("_helperTextSlottedContent")}
933
+ ></slot>
934
+ <slot
935
+ slot='${(x) => x._contextualHelpSlottedContent?.length ? "contextual-help" : void 0}'
936
+ name='contextual-help'
937
+ ${fastElement.slotted("_contextualHelpSlottedContent")}
938
+ ></slot>
939
+ </${textFieldTag}>
940
+ `;
941
+ }
942
+ function renderPopupHeader(buttonTag, iconTag) {
943
+ return fastElement.html`
944
+ <div class="header">
945
+ <span class="header-title" id="color-picker-title">
946
+ <slot name="popup-text">${(x) => x.locale.colorPicker.popupLabel}</slot>
947
+ </span>
948
+ <${buttonTag} size="condensed"
949
+ aria-label="${(x) => x.locale.colorPicker.closeButtonLabel}"
950
+ @click="${(x) => x._handleCloseRequest()}">
951
+ <${iconTag} slot="icon" name="close-line"></${iconTag}>
952
+ </${buttonTag}>
953
+ </div>
954
+ `;
955
+ }
956
+ function renderPopupBody(buttonTag, iconTag) {
957
+ return fastElement.html`
958
+ <div class="body">
959
+ <${fastElement.html.partial(vcPickerTag)}
960
+ part="hex-picker"
961
+ color="${(x) => x.value}"
962
+ @color-changed="${(x, c) => x._onPickerColorChanged(c.event)}"
963
+ ${fastElement.ref("_vcHexPickerEl")}
964
+ ></${fastElement.html.partial(vcPickerTag)}>
965
+ <div class="hex-input-wrapper">
966
+ <${fastElement.html.partial(vcInputTag)}
967
+ part="hex-input"
968
+ prefixed
969
+ color="${(x) => x.value}"
970
+ @color-changed="${(x, c) => x._onPickerColorChanged(c.event)}"
971
+ ${fastElement.ref("_vcHexInputEl")}
972
+ ></${fastElement.html.partial(vcInputTag)}>
973
+ <${buttonTag} size="normal"
974
+ aria-label="${(x) => x.locale.colorPicker.copyButtonLabel}"
975
+ @click="${(x) => x._copyValueToClipboard(x.value)}">
976
+ <${iconTag} slot="icon" name="${(x) => x.copyIconName}"></${iconTag}>
977
+ </${buttonTag}>
978
+ </div>
979
+ </div>
980
+ `;
981
+ }
982
+ function renderPopupFooter(buttonTag, iconTag) {
983
+ return fastElement.html`
984
+ <div class="footer">
985
+ <span class="footer-title" id="color-picker-footer-title"
986
+ ><slot name="swatches-text"
987
+ >${(x) => x.locale.colorPicker.swatchesLabel}</slot
988
+ ></span
989
+ >
990
+ <div
991
+ class="palette"
992
+ role="grid"
993
+ aria-rowcount="${(x) => Math.ceil(x.allSwatches.length / x._getRowLength())}"
994
+ aria-colcount="${(x) => x._getRowLength()}"
995
+ style="--swatches-per-row: ${(x) => x._getRowLength()};"
996
+ aria-labelledby="color-picker-footer-title"
997
+ >
998
+ ${fastElement.repeat(
999
+ (x) => x.allSwatches,
1000
+ (x) => x._renderColorSwatch(iconTag),
1001
+ { positioning: true }
1002
+ )}
1003
+ ${fastElement.when(
1004
+ (x) => !x.disableSavedColors,
1005
+ fastElement.html`
1006
+ <${buttonTag}
1007
+ appearance="outlined"
1008
+ size="super-condensed"
1009
+ role="gridcell"
1010
+ tabindex="${(x) => x.allSwatches.length ? "-1" : "0"}"
1011
+ aria-label="${(x) => x.locale.colorPicker.saveButtonLabel}"
1012
+ @click="${(x) => x._saveCurrentColor()}"
1013
+ @keydown="${(x, c) => x._handleCellKeydown(
1014
+ c.event,
1015
+ x.value,
1016
+ x.allSwatches.length,
1017
+ true
1018
+ )}">
1019
+ >
1020
+ <${iconTag} slot="icon" name="plus-line"></${iconTag}>
1021
+ </${buttonTag}>
1022
+ `
1023
+ )}
1024
+ </div>
1025
+ </div>
1026
+ `;
1027
+ }
1028
+ const ColorPickerTemplate = (context) => {
1029
+ const textFieldTag = context.tagFor(textField_definition.VwcTextFieldElement);
1030
+ const iconTag = context.tagFor(icon_definition.VwcIconElement);
1031
+ const popupTag = context.tagFor(popup_definition.Popup);
1032
+ const buttonTag = context.tagFor(button_definition.Button);
1033
+ return fastElement.html`
1034
+ <div class="base">
1035
+ ${renderTextField(textFieldTag, iconTag)}
1036
+ <${popupTag}
1037
+ :open="${(x) => x.open}"
1038
+ :anchor="${(x) => x._buttonEl}"
1039
+ placement="top"
1040
+ offset="10"
1041
+ ${fastElement.ref("_popupEl")}>
1042
+ <div class="dialog"
1043
+ role="dialog"
1044
+ aria-modal="true"
1045
+ aria-labelledby="color-picker-title">
1046
+ ${renderPopupHeader(buttonTag, iconTag)}
1047
+ ${renderPopupBody(buttonTag, iconTag)}
1048
+ ${fastElement.when(
1049
+ (x) => !x.disableSavedColors || x.allSwatches.length > 0,
1050
+ renderPopupFooter(buttonTag, iconTag)
1051
+ )}
1052
+ </div>
1053
+ </${popupTag}>
1054
+ </div>
1055
+ `;
1056
+ };
1057
+
1058
+ const colorPickerDefinition = vividElement.defineVividComponent(
1059
+ "color-picker",
1060
+ ColorPicker,
1061
+ ColorPickerTemplate,
1062
+ [
1063
+ popup_definition.popupDefinition,
1064
+ icon_definition.iconDefinition,
1065
+ textField_definition.textFieldDefinition,
1066
+ button_definition.buttonDefinition,
1067
+ mixins.feedbackMessageDefinition
1068
+ ],
1069
+ {
1070
+ styles
1071
+ }
1072
+ );
1073
+ const registerColorPicker = vividElement.createRegisterFunction(
1074
+ colorPickerDefinition
1075
+ );
1076
+
1077
+ exports.VwcColorPickerElement = ColorPicker;
1078
+ exports.colorPickerDefinition = colorPickerDefinition;
1079
+ exports.registerColorPicker = registerColorPicker;