@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
@@ -3,48 +3,15 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const vividElement = require('../unbundled/vivid-element.cjs');
6
- const popup_definition = require('../unbundled/definition4.cjs');
6
+ const popup_definition = require('../unbundled/definition5.cjs');
7
7
  const icon_definition = require('../icon/definition.cjs');
8
8
  const fastElement = require('@microsoft/fast-element');
9
9
  const anchored = require('../unbundled/anchored.cjs');
10
- const formAssociated = require('../unbundled/form-associated.cjs');
11
- const localized = require('../unbundled/localized.cjs');
12
- const formElement = require('../unbundled/form-element.cjs');
10
+ const baseColorPicker = require('../unbundled/base-color-picker.cjs');
13
11
  const fastWebUtilities = require('@microsoft/fast-web-utilities');
14
12
  const index = require('../unbundled/index.cjs');
15
13
 
16
- const styles = ":host :host{display:var(--_popup-display, inline)}:host :host([slotted-anchor]){--_popup-display: contents}.palette{display:grid;padding:var(--_color-palette-spacing, 16px);gap:var(--_color-palette-gap, 12px);grid-template-columns:repeat(var(--swatches-per-row, 7),1fr)}.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}::part(popup-base){block-size:max-content;inline-size:max-content;max-block-size:100vh;max-inline-size:100vw;min-block-size:var(--_color-swatch-size, 24px);min-inline-size:var(--_color-swatch-size, 24px)}";
17
-
18
- function parseHexColor(input) {
19
- if (!input) return null;
20
- const hex = input.trim().replace(/^#/, "");
21
- if (/^[0-9a-fA-F]{6}$/.test(hex)) return hex.toLowerCase();
22
- return null;
23
- }
24
- function getLuminance(hexColor) {
25
- const hex = parseHexColor(hexColor);
26
- if (!hex) return 0;
27
- const r = parseInt(hex.slice(0, 2), 16) / 255;
28
- const g = parseInt(hex.slice(2, 4), 16) / 255;
29
- const b = parseInt(hex.slice(4, 6), 16) / 255;
30
- const sR = r <= 0.03928 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4);
31
- const sG = g <= 0.03928 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4);
32
- const sB = b <= 0.03928 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4);
33
- return 0.2126 * sR + 0.7152 * sG + 0.0722 * sB;
34
- }
35
- function getContrastRatio(color1, color2) {
36
- const lum1 = getLuminance(color1);
37
- const lum2 = getLuminance(color2);
38
- const brightest = Math.max(lum1, lum2);
39
- const darkest = Math.min(lum1, lum2);
40
- return (brightest + 0.05) / (darkest + 0.05);
41
- }
42
- function getCSSCustomProperty(propertyName, element) {
43
- if (!element) {
44
- element = document.querySelector(".vvd-root") || document.documentElement;
45
- }
46
- return getComputedStyle(element).getPropertyValue(propertyName).trim();
47
- }
14
+ 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 :host{display:var(--_popup-display, inline)}:host :host([slotted-anchor]){--_popup-display: contents}.palette{padding:var(--_color-palette-spacing, 16px);gap:var(--_color-palette-gap, 12px)}::part(popup-base){block-size:max-content;inline-size:max-content;max-block-size:100vh;max-inline-size:100vw;min-block-size:var(--_color-swatch-size, 24px);min-inline-size:var(--_color-swatch-size, 24px)}";
48
15
 
49
16
  var __defProp = Object.defineProperty;
50
17
  var __decorateClass = (decorators, target, key, kind) => {
@@ -55,28 +22,16 @@ var __decorateClass = (decorators, target, key, kind) => {
55
22
  if (result) __defProp(target, key, result);
56
23
  return result;
57
24
  };
58
- class SimpleColorPicker extends localized.Localized(
59
- anchored.Anchored(formElement.FormElement(formAssociated.FormAssociated(vividElement.VividElement)))
60
- ) {
25
+ class SimpleColorPicker extends anchored.Anchored(baseColorPicker.BaseColorPicker(vividElement.VividElement)) {
61
26
  constructor() {
62
27
  super(...arguments);
63
- /**
64
- * @internal
65
- */
66
- this.proxy = document.createElement("input");
67
- this.open = false;
68
28
  this.placement = "top-start";
69
- this.swatches = [];
70
29
  this.swatchesPerRow = 7;
71
- /**
72
- * @internal
73
- */
74
- this._canvasColor = "";
75
30
  /**
76
31
  * @internal
77
32
  */
78
33
  this.#openPopup = () => {
79
- if (!this.open) fastElement.DOM.queueUpdate(() => this.open = true);
34
+ if (!this.open) fastElement.Updates.enqueue(() => this.open = true);
80
35
  };
81
36
  /**
82
37
  * @internal
@@ -84,7 +39,7 @@ class SimpleColorPicker extends localized.Localized(
84
39
  this.#handleAnchorKeydown = (event) => {
85
40
  if (event.key === "Enter" || event.key === " ") {
86
41
  if (!this.open) {
87
- fastElement.DOM.queueUpdate(() => this.open = true);
42
+ fastElement.Updates.enqueue(() => this.open = true);
88
43
  }
89
44
  event.preventDefault();
90
45
  }
@@ -92,7 +47,7 @@ class SimpleColorPicker extends localized.Localized(
92
47
  /**
93
48
  * @internal
94
49
  */
95
- this.#closeOnClickOutside = (e) => {
50
+ this._closeOnClickOutside = (e) => {
96
51
  const clickedOutside = !this.contains(e.target);
97
52
  const clickedOnAnchor = this._anchorEl?.contains(e.target);
98
53
  if (clickedOutside || clickedOnAnchor) this.open = false;
@@ -100,108 +55,17 @@ class SimpleColorPicker extends localized.Localized(
100
55
  /**
101
56
  * @internal
102
57
  */
103
- this.#closeOnEscape = (e) => {
58
+ this._closeOnEscape = (e) => {
104
59
  if (e.key === "Escape") {
105
60
  this.open = false;
106
61
  }
107
62
  };
108
- /**
109
- * @internal
110
- */
111
- this._handleSwatchSelection = (swatch) => {
112
- if (this.value === swatch.value) {
113
- this.value = "";
114
- } else {
115
- this.value = swatch.value;
116
- }
117
- this.$emit("change");
118
- this.open = false;
119
- };
120
- /**
121
- * @internal
122
- */
123
- this._handleSwatchKeydown = (event, swatch, index) => {
124
- const rowLength = this.swatchesPerRow;
125
- const totalCells = this.swatches.length;
126
- const currentRow = Math.floor(index / rowLength);
127
- const currentCol = index % rowLength;
128
- const totalRows = Math.ceil(totalCells / rowLength);
129
- switch (event.key) {
130
- case "ArrowRight":
131
- if (currentCol < rowLength - 1 && index + 1 < totalCells) {
132
- this.#focusSwatchByIndex(index + 1);
133
- }
134
- return false;
135
- case "ArrowLeft":
136
- if (currentCol > 0) {
137
- this.#focusSwatchByIndex(index - 1);
138
- }
139
- return false;
140
- case "ArrowDown":
141
- if (currentRow < totalRows - 1 && index + rowLength < totalCells) {
142
- this.#focusSwatchByIndex(index + rowLength);
143
- }
144
- return false;
145
- case "ArrowUp":
146
- if (currentRow > 0) {
147
- this.#focusSwatchByIndex(index - rowLength);
148
- }
149
- return false;
150
- case "PageDown": {
151
- const lastRowStart = (totalRows - 1) * rowLength;
152
- const targetIndex = Math.min(lastRowStart + currentCol, totalCells - 1);
153
- if (index !== targetIndex) {
154
- this.#focusSwatchByIndex(targetIndex);
155
- }
156
- return false;
157
- }
158
- case "PageUp": {
159
- const targetIndex = Math.min(currentCol, totalCells - 1);
160
- if (index !== targetIndex) {
161
- this.#focusSwatchByIndex(targetIndex);
162
- }
163
- return false;
164
- }
165
- case "Home":
166
- if (event.ctrlKey) {
167
- this.#focusSwatchByIndex(0);
168
- } else {
169
- this.#focusSwatchByIndex(currentRow * rowLength);
170
- }
171
- return false;
172
- case "End":
173
- if (event.ctrlKey) {
174
- this.#focusSwatchByIndex(totalCells - 1);
175
- } else {
176
- const rowEnd = Math.min(
177
- (currentRow + 1) * rowLength - 1,
178
- totalCells - 1
179
- );
180
- this.#focusSwatchByIndex(rowEnd);
181
- }
182
- return false;
183
- case "Enter":
184
- case " ":
185
- this._handleSwatchSelection(swatch);
186
- this.#returnFocusToAnchor();
187
- return false;
188
- case "Escape":
189
- this.open = false;
190
- this.#returnFocusToAnchor();
191
- return false;
192
- case "Tab":
193
- this.open = false;
194
- return true;
195
- default:
196
- return true;
197
- }
198
- };
199
63
  }
200
64
  /**
201
65
  * @internal
202
66
  */
203
67
  openChanged() {
204
- this.#updateListeners();
68
+ this._updateListeners();
205
69
  if (this._anchorEl) {
206
70
  this.#updateAnchor(this._anchorEl);
207
71
  }
@@ -212,43 +76,40 @@ class SimpleColorPicker extends localized.Localized(
212
76
  (swatch) => swatch.value === this.value
213
77
  );
214
78
  const targetIndex = selectedIndex >= 0 ? selectedIndex : 0;
215
- this.#focusSwatchByIndex(targetIndex);
79
+ this._focusSwatchByIndex(targetIndex);
216
80
  });
217
81
  }
218
82
  }
83
+ /**
84
+ * @internal
85
+ */
86
+ _getRowLength() {
87
+ return this.swatchesPerRow;
88
+ }
219
89
  connectedCallback() {
220
90
  super.connectedCallback();
221
- this.#updateListeners();
222
- this._refreshCanvasColor();
91
+ this._updateListeners();
223
92
  }
224
93
  disconnectedCallback() {
225
94
  super.disconnectedCallback();
226
- this.#updateListeners();
95
+ this._updateListeners();
227
96
  }
228
97
  /**
229
98
  * @internal
230
99
  */
231
- #updateListeners() {
232
- document.removeEventListener("click", this.#closeOnClickOutside);
233
- document.removeEventListener("keydown", this.#closeOnEscape);
100
+ _updateListeners() {
101
+ document.removeEventListener("click", this._closeOnClickOutside);
102
+ document.removeEventListener("keydown", this._closeOnEscape);
234
103
  if (this.open && this.isConnected) {
235
- document.addEventListener("click", this.#closeOnClickOutside);
236
- document.addEventListener("keydown", this.#closeOnEscape);
104
+ document.addEventListener("click", this._closeOnClickOutside);
105
+ document.addEventListener("keydown", this._closeOnEscape);
237
106
  }
238
107
  }
239
108
  /**
240
109
  * @internal
241
110
  */
242
- _refreshCanvasColor() {
243
- this._canvasColor = getCSSCustomProperty("--vvd-color-canvas", this);
244
- }
245
- /**
246
- * @internal
247
- */
248
- _applyContrastClass(swatchColor, threshold = 3) {
249
- if (!swatchColor || !this._canvasColor) return false;
250
- const ratio = getContrastRatio(swatchColor, this._canvasColor);
251
- return ratio < threshold;
111
+ _getFocusReturnEl() {
112
+ return this._anchorEl ?? null;
252
113
  }
253
114
  /**
254
115
  * @internal
@@ -285,32 +146,10 @@ class SimpleColorPicker extends localized.Localized(
285
146
  }
286
147
  #openPopup;
287
148
  #handleAnchorKeydown;
288
- #closeOnClickOutside;
289
- #closeOnEscape;
290
- /**
291
- * @internal
292
- */
293
- #focusSwatchByIndex(index) {
294
- if (index < 0 || index >= this.swatches.length) return;
295
- const element = this.shadowRoot?.querySelectorAll('[role="gridcell"]')?.[index];
296
- element?.focus();
297
- }
298
- /**
299
- * @internal
300
- */
301
- #returnFocusToAnchor() {
302
- fastElement.DOM.queueUpdate(() => this._anchorEl?.focus());
303
- }
304
149
  }
305
- __decorateClass([
306
- fastElement.attr({ mode: "boolean" })
307
- ], SimpleColorPicker.prototype, "open");
308
150
  __decorateClass([
309
151
  fastElement.attr({ mode: "fromView" })
310
152
  ], SimpleColorPicker.prototype, "placement");
311
- __decorateClass([
312
- fastElement.observable
313
- ], SimpleColorPicker.prototype, "swatches");
314
153
  __decorateClass([
315
154
  fastElement.attr({
316
155
  attribute: "swatches-per-row",
@@ -340,39 +179,13 @@ const SimpleColorPickerTemplate = (context) => {
340
179
  }}"
341
180
  >
342
181
  <div class="palette" role="grid"
343
- aria-rowcount="${(x) => Math.ceil(x.swatches.length / x.swatchesPerRow)}"
344
- aria-colcount="${(x) => x.swatchesPerRow}"
345
- style="--swatches-per-row: ${(x) => x.swatchesPerRow};"
182
+ aria-rowcount="${(x) => Math.ceil(x.swatches.length / x._getRowLength())}"
183
+ aria-colcount="${(x) => x._getRowLength()}"
184
+ style="--swatches-per-row: ${(x) => x._getRowLength()};"
346
185
  aria-label="${(x) => x.locale.simpleColorPicker.colorPaletteLabel}">
347
186
  ${fastElement.repeat(
348
187
  (x) => x.swatches,
349
- fastElement.html`
350
- <button
351
- class="swatch ${(x, c) => fastWebUtilities.classNames(
352
- c.parent.value === x.value ? "selected" : "",
353
- c.parent._applyContrastClass(x.value) ? "contrast" : ""
354
- )}"
355
- role="gridcell"
356
- style="--swatch-color: ${(x) => x.value};"
357
- tabindex="${(x, c) => c.index === 0 ? "0" : "-1"}"
358
- aria-label="${(x, c) => c.parent.locale.simpleColorPicker.colorSwatchLabel(
359
- x.value,
360
- x.label,
361
- c.parent.value === x.value
362
- )}"
363
- @click="${(x, c) => c.parent._handleSwatchSelection(x)}"
364
- @keydown="${(x, c) => c.parent._handleSwatchKeydown(
365
- c.event,
366
- x,
367
- c.index
368
- )}"
369
- >
370
- ${fastElement.when(
371
- (x, c) => c.parent.value === x.value,
372
- fastElement.html`<${iconTag} size="-6" name="check-solid" aria-hidden="true"></${iconTag}>`
373
- )}
374
- </button>
375
- `,
188
+ (x) => x._renderColorSwatch(iconTag),
376
189
  { positioning: true }
377
190
  )}
378
191
  </div>
@@ -1,46 +1,13 @@
1
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';
2
+ import { P as Popup, p as popupDefinition } from '../unbundled/definition5.js';
3
3
  import { VwcIconElement as Icon, iconDefinition } from '../icon/definition.js';
4
- import { DOM, attr, observable, nullableNumberConverter, repeat, when, html } from '@microsoft/fast-element';
4
+ import { Updates, attr, nullableNumberConverter, repeat, html } from '@microsoft/fast-element';
5
5
  import { A as Anchored, a as anchorSlotTemplateFactory } from '../unbundled/anchored.js';
6
- import { F as FormAssociated } from '../unbundled/form-associated.js';
7
- import { L as Localized } from '../unbundled/localized.js';
8
- import { F as FormElement } from '../unbundled/form-element.js';
6
+ import { B as BaseColorPicker } from '../unbundled/base-color-picker.js';
9
7
  import { classNames } from '@microsoft/fast-web-utilities';
10
8
  import { h as handleEscapeKeyAndStopPropogation } from '../unbundled/index.js';
11
9
 
12
- const styles = ":host :host{display:var(--_popup-display, inline)}:host :host([slotted-anchor]){--_popup-display: contents}.palette{display:grid;padding:var(--_color-palette-spacing, 16px);gap:var(--_color-palette-gap, 12px);grid-template-columns:repeat(var(--swatches-per-row, 7),1fr)}.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}::part(popup-base){block-size:max-content;inline-size:max-content;max-block-size:100vh;max-inline-size:100vw;min-block-size:var(--_color-swatch-size, 24px);min-inline-size:var(--_color-swatch-size, 24px)}";
13
-
14
- function parseHexColor(input) {
15
- if (!input) return null;
16
- const hex = input.trim().replace(/^#/, "");
17
- if (/^[0-9a-fA-F]{6}$/.test(hex)) return hex.toLowerCase();
18
- return null;
19
- }
20
- function getLuminance(hexColor) {
21
- const hex = parseHexColor(hexColor);
22
- if (!hex) return 0;
23
- const r = parseInt(hex.slice(0, 2), 16) / 255;
24
- const g = parseInt(hex.slice(2, 4), 16) / 255;
25
- const b = parseInt(hex.slice(4, 6), 16) / 255;
26
- const sR = r <= 0.03928 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4);
27
- const sG = g <= 0.03928 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4);
28
- const sB = b <= 0.03928 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4);
29
- return 0.2126 * sR + 0.7152 * sG + 0.0722 * sB;
30
- }
31
- function getContrastRatio(color1, color2) {
32
- const lum1 = getLuminance(color1);
33
- const lum2 = getLuminance(color2);
34
- const brightest = Math.max(lum1, lum2);
35
- const darkest = Math.min(lum1, lum2);
36
- return (brightest + 0.05) / (darkest + 0.05);
37
- }
38
- function getCSSCustomProperty(propertyName, element) {
39
- if (!element) {
40
- element = document.querySelector(".vvd-root") || document.documentElement;
41
- }
42
- return getComputedStyle(element).getPropertyValue(propertyName).trim();
43
- }
10
+ 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 :host{display:var(--_popup-display, inline)}:host :host([slotted-anchor]){--_popup-display: contents}.palette{padding:var(--_color-palette-spacing, 16px);gap:var(--_color-palette-gap, 12px)}::part(popup-base){block-size:max-content;inline-size:max-content;max-block-size:100vh;max-inline-size:100vw;min-block-size:var(--_color-swatch-size, 24px);min-inline-size:var(--_color-swatch-size, 24px)}";
44
11
 
45
12
  var __defProp = Object.defineProperty;
46
13
  var __decorateClass = (decorators, target, key, kind) => {
@@ -51,28 +18,16 @@ var __decorateClass = (decorators, target, key, kind) => {
51
18
  if (result) __defProp(target, key, result);
52
19
  return result;
53
20
  };
54
- class SimpleColorPicker extends Localized(
55
- Anchored(FormElement(FormAssociated(VividElement)))
56
- ) {
21
+ class SimpleColorPicker extends Anchored(BaseColorPicker(VividElement)) {
57
22
  constructor() {
58
23
  super(...arguments);
59
- /**
60
- * @internal
61
- */
62
- this.proxy = document.createElement("input");
63
- this.open = false;
64
24
  this.placement = "top-start";
65
- this.swatches = [];
66
25
  this.swatchesPerRow = 7;
67
- /**
68
- * @internal
69
- */
70
- this._canvasColor = "";
71
26
  /**
72
27
  * @internal
73
28
  */
74
29
  this.#openPopup = () => {
75
- if (!this.open) DOM.queueUpdate(() => this.open = true);
30
+ if (!this.open) Updates.enqueue(() => this.open = true);
76
31
  };
77
32
  /**
78
33
  * @internal
@@ -80,7 +35,7 @@ class SimpleColorPicker extends Localized(
80
35
  this.#handleAnchorKeydown = (event) => {
81
36
  if (event.key === "Enter" || event.key === " ") {
82
37
  if (!this.open) {
83
- DOM.queueUpdate(() => this.open = true);
38
+ Updates.enqueue(() => this.open = true);
84
39
  }
85
40
  event.preventDefault();
86
41
  }
@@ -88,7 +43,7 @@ class SimpleColorPicker extends Localized(
88
43
  /**
89
44
  * @internal
90
45
  */
91
- this.#closeOnClickOutside = (e) => {
46
+ this._closeOnClickOutside = (e) => {
92
47
  const clickedOutside = !this.contains(e.target);
93
48
  const clickedOnAnchor = this._anchorEl?.contains(e.target);
94
49
  if (clickedOutside || clickedOnAnchor) this.open = false;
@@ -96,108 +51,17 @@ class SimpleColorPicker extends Localized(
96
51
  /**
97
52
  * @internal
98
53
  */
99
- this.#closeOnEscape = (e) => {
54
+ this._closeOnEscape = (e) => {
100
55
  if (e.key === "Escape") {
101
56
  this.open = false;
102
57
  }
103
58
  };
104
- /**
105
- * @internal
106
- */
107
- this._handleSwatchSelection = (swatch) => {
108
- if (this.value === swatch.value) {
109
- this.value = "";
110
- } else {
111
- this.value = swatch.value;
112
- }
113
- this.$emit("change");
114
- this.open = false;
115
- };
116
- /**
117
- * @internal
118
- */
119
- this._handleSwatchKeydown = (event, swatch, index) => {
120
- const rowLength = this.swatchesPerRow;
121
- const totalCells = this.swatches.length;
122
- const currentRow = Math.floor(index / rowLength);
123
- const currentCol = index % rowLength;
124
- const totalRows = Math.ceil(totalCells / rowLength);
125
- switch (event.key) {
126
- case "ArrowRight":
127
- if (currentCol < rowLength - 1 && index + 1 < totalCells) {
128
- this.#focusSwatchByIndex(index + 1);
129
- }
130
- return false;
131
- case "ArrowLeft":
132
- if (currentCol > 0) {
133
- this.#focusSwatchByIndex(index - 1);
134
- }
135
- return false;
136
- case "ArrowDown":
137
- if (currentRow < totalRows - 1 && index + rowLength < totalCells) {
138
- this.#focusSwatchByIndex(index + rowLength);
139
- }
140
- return false;
141
- case "ArrowUp":
142
- if (currentRow > 0) {
143
- this.#focusSwatchByIndex(index - rowLength);
144
- }
145
- return false;
146
- case "PageDown": {
147
- const lastRowStart = (totalRows - 1) * rowLength;
148
- const targetIndex = Math.min(lastRowStart + currentCol, totalCells - 1);
149
- if (index !== targetIndex) {
150
- this.#focusSwatchByIndex(targetIndex);
151
- }
152
- return false;
153
- }
154
- case "PageUp": {
155
- const targetIndex = Math.min(currentCol, totalCells - 1);
156
- if (index !== targetIndex) {
157
- this.#focusSwatchByIndex(targetIndex);
158
- }
159
- return false;
160
- }
161
- case "Home":
162
- if (event.ctrlKey) {
163
- this.#focusSwatchByIndex(0);
164
- } else {
165
- this.#focusSwatchByIndex(currentRow * rowLength);
166
- }
167
- return false;
168
- case "End":
169
- if (event.ctrlKey) {
170
- this.#focusSwatchByIndex(totalCells - 1);
171
- } else {
172
- const rowEnd = Math.min(
173
- (currentRow + 1) * rowLength - 1,
174
- totalCells - 1
175
- );
176
- this.#focusSwatchByIndex(rowEnd);
177
- }
178
- return false;
179
- case "Enter":
180
- case " ":
181
- this._handleSwatchSelection(swatch);
182
- this.#returnFocusToAnchor();
183
- return false;
184
- case "Escape":
185
- this.open = false;
186
- this.#returnFocusToAnchor();
187
- return false;
188
- case "Tab":
189
- this.open = false;
190
- return true;
191
- default:
192
- return true;
193
- }
194
- };
195
59
  }
196
60
  /**
197
61
  * @internal
198
62
  */
199
63
  openChanged() {
200
- this.#updateListeners();
64
+ this._updateListeners();
201
65
  if (this._anchorEl) {
202
66
  this.#updateAnchor(this._anchorEl);
203
67
  }
@@ -208,43 +72,40 @@ class SimpleColorPicker extends Localized(
208
72
  (swatch) => swatch.value === this.value
209
73
  );
210
74
  const targetIndex = selectedIndex >= 0 ? selectedIndex : 0;
211
- this.#focusSwatchByIndex(targetIndex);
75
+ this._focusSwatchByIndex(targetIndex);
212
76
  });
213
77
  }
214
78
  }
79
+ /**
80
+ * @internal
81
+ */
82
+ _getRowLength() {
83
+ return this.swatchesPerRow;
84
+ }
215
85
  connectedCallback() {
216
86
  super.connectedCallback();
217
- this.#updateListeners();
218
- this._refreshCanvasColor();
87
+ this._updateListeners();
219
88
  }
220
89
  disconnectedCallback() {
221
90
  super.disconnectedCallback();
222
- this.#updateListeners();
91
+ this._updateListeners();
223
92
  }
224
93
  /**
225
94
  * @internal
226
95
  */
227
- #updateListeners() {
228
- document.removeEventListener("click", this.#closeOnClickOutside);
229
- document.removeEventListener("keydown", this.#closeOnEscape);
96
+ _updateListeners() {
97
+ document.removeEventListener("click", this._closeOnClickOutside);
98
+ document.removeEventListener("keydown", this._closeOnEscape);
230
99
  if (this.open && this.isConnected) {
231
- document.addEventListener("click", this.#closeOnClickOutside);
232
- document.addEventListener("keydown", this.#closeOnEscape);
100
+ document.addEventListener("click", this._closeOnClickOutside);
101
+ document.addEventListener("keydown", this._closeOnEscape);
233
102
  }
234
103
  }
235
104
  /**
236
105
  * @internal
237
106
  */
238
- _refreshCanvasColor() {
239
- this._canvasColor = getCSSCustomProperty("--vvd-color-canvas", this);
240
- }
241
- /**
242
- * @internal
243
- */
244
- _applyContrastClass(swatchColor, threshold = 3) {
245
- if (!swatchColor || !this._canvasColor) return false;
246
- const ratio = getContrastRatio(swatchColor, this._canvasColor);
247
- return ratio < threshold;
107
+ _getFocusReturnEl() {
108
+ return this._anchorEl ?? null;
248
109
  }
249
110
  /**
250
111
  * @internal
@@ -281,32 +142,10 @@ class SimpleColorPicker extends Localized(
281
142
  }
282
143
  #openPopup;
283
144
  #handleAnchorKeydown;
284
- #closeOnClickOutside;
285
- #closeOnEscape;
286
- /**
287
- * @internal
288
- */
289
- #focusSwatchByIndex(index) {
290
- if (index < 0 || index >= this.swatches.length) return;
291
- const element = this.shadowRoot?.querySelectorAll('[role="gridcell"]')?.[index];
292
- element?.focus();
293
- }
294
- /**
295
- * @internal
296
- */
297
- #returnFocusToAnchor() {
298
- DOM.queueUpdate(() => this._anchorEl?.focus());
299
- }
300
145
  }
301
- __decorateClass([
302
- attr({ mode: "boolean" })
303
- ], SimpleColorPicker.prototype, "open");
304
146
  __decorateClass([
305
147
  attr({ mode: "fromView" })
306
148
  ], SimpleColorPicker.prototype, "placement");
307
- __decorateClass([
308
- observable
309
- ], SimpleColorPicker.prototype, "swatches");
310
149
  __decorateClass([
311
150
  attr({
312
151
  attribute: "swatches-per-row",
@@ -336,39 +175,13 @@ const SimpleColorPickerTemplate = (context) => {
336
175
  }}"
337
176
  >
338
177
  <div class="palette" role="grid"
339
- aria-rowcount="${(x) => Math.ceil(x.swatches.length / x.swatchesPerRow)}"
340
- aria-colcount="${(x) => x.swatchesPerRow}"
341
- style="--swatches-per-row: ${(x) => x.swatchesPerRow};"
178
+ aria-rowcount="${(x) => Math.ceil(x.swatches.length / x._getRowLength())}"
179
+ aria-colcount="${(x) => x._getRowLength()}"
180
+ style="--swatches-per-row: ${(x) => x._getRowLength()};"
342
181
  aria-label="${(x) => x.locale.simpleColorPicker.colorPaletteLabel}">
343
182
  ${repeat(
344
183
  (x) => x.swatches,
345
- html`
346
- <button
347
- class="swatch ${(x, c) => classNames(
348
- c.parent.value === x.value ? "selected" : "",
349
- c.parent._applyContrastClass(x.value) ? "contrast" : ""
350
- )}"
351
- role="gridcell"
352
- style="--swatch-color: ${(x) => x.value};"
353
- tabindex="${(x, c) => c.index === 0 ? "0" : "-1"}"
354
- aria-label="${(x, c) => c.parent.locale.simpleColorPicker.colorSwatchLabel(
355
- x.value,
356
- x.label,
357
- c.parent.value === x.value
358
- )}"
359
- @click="${(x, c) => c.parent._handleSwatchSelection(x)}"
360
- @keydown="${(x, c) => c.parent._handleSwatchKeydown(
361
- c.event,
362
- x,
363
- c.index
364
- )}"
365
- >
366
- ${when(
367
- (x, c) => c.parent.value === x.value,
368
- html`<${iconTag} size="-6" name="check-solid" aria-hidden="true"></${iconTag}>`
369
- )}
370
- </button>
371
- `,
184
+ (x) => x._renderColorSwatch(iconTag),
372
185
  { positioning: true }
373
186
  )}
374
187
  </div>