@vonage/vivid 5.1.0 → 5.3.0

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