@vonage/vivid 5.16.0 → 5.17.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 (317) hide show
  1. package/accordion/index.cjs +1 -1
  2. package/accordion/index.js +1 -1
  3. package/accordion-item/index.cjs +1 -1
  4. package/accordion-item/index.js +1 -1
  5. package/action-group/index.cjs +3 -3
  6. package/action-group/index.js +5 -5
  7. package/alert/index.cjs +3 -3
  8. package/alert/index.js +17 -17
  9. package/audio-player/index.cjs +16 -16
  10. package/audio-player/index.js +27 -27
  11. package/avatar/index.cjs +2 -2
  12. package/avatar/index.js +6 -6
  13. package/badge/index.cjs +2 -2
  14. package/badge/index.js +6 -6
  15. package/banner/index.cjs +3 -3
  16. package/banner/index.js +15 -15
  17. package/bundled/base-color-picker.cjs +2 -2
  18. package/bundled/base-color-picker.js +5 -5
  19. package/bundled/button.cjs +1 -1
  20. package/bundled/button.js +2 -2
  21. package/bundled/calendar-picker.template.cjs +2 -2
  22. package/bundled/calendar-picker.template.js +498 -498
  23. package/bundled/definition10.cjs +18 -30
  24. package/bundled/definition10.js +53 -155
  25. package/bundled/definition11.cjs +10 -19
  26. package/bundled/definition11.js +25 -74
  27. package/bundled/definition12.cjs +72 -18
  28. package/bundled/definition12.js +171 -107
  29. package/bundled/definition13.cjs +18 -17
  30. package/bundled/definition13.js +45 -65
  31. package/bundled/definition14.cjs +5 -10
  32. package/bundled/definition14.js +9 -27
  33. package/bundled/definition15.cjs +17 -71
  34. package/bundled/definition15.js +64 -181
  35. package/bundled/definition16.cjs +12 -4
  36. package/bundled/definition16.js +79 -14
  37. package/bundled/definition17.cjs +19 -13
  38. package/bundled/definition17.js +119 -70
  39. package/bundled/definition18.cjs +87 -12
  40. package/bundled/definition18.js +409 -52
  41. package/bundled/definition19.cjs +5 -87
  42. package/bundled/definition19.js +14 -422
  43. package/bundled/definition2.cjs +3 -3
  44. package/bundled/definition2.js +27 -27
  45. package/bundled/definition20.cjs +30 -5
  46. package/bundled/definition20.js +159 -9
  47. package/bundled/definition21.cjs +28 -19
  48. package/bundled/definition21.js +164 -47
  49. package/bundled/definition22.cjs +38 -23
  50. package/bundled/definition22.js +64 -82
  51. package/bundled/definition3.cjs +1 -1
  52. package/bundled/definition3.js +15 -15
  53. package/bundled/definition4.cjs +23 -38
  54. package/bundled/definition4.js +82 -64
  55. package/bundled/definition5.cjs +2 -2
  56. package/bundled/definition5.js +5 -5
  57. package/bundled/definition6.cjs +2 -2
  58. package/bundled/definition6.js +24 -24
  59. package/bundled/definition9.cjs +12 -30
  60. package/bundled/definition9.js +55 -148
  61. package/bundled/divider.cjs +1 -1
  62. package/bundled/divider.js +5 -5
  63. package/bundled/listbox.cjs +1 -1
  64. package/bundled/listbox.js +1 -1
  65. package/bundled/mixins.cjs +4 -4
  66. package/bundled/mixins.js +43 -43
  67. package/bundled/picker-field.template.cjs +7 -7
  68. package/bundled/picker-field.template.js +14 -14
  69. package/bundled/slider.template.cjs +7 -7
  70. package/bundled/slider.template.js +12 -12
  71. package/bundled/slottable-request.cjs +1 -1
  72. package/bundled/slottable-request.js +8 -38
  73. package/bundled/time-selection-picker.template.cjs +4 -4
  74. package/bundled/time-selection-picker.template.js +35 -35
  75. package/bundled/vivid-element.cjs +1 -1
  76. package/bundled/vivid-element.js +1 -1
  77. package/calendar/index.cjs +11 -11
  78. package/calendar/index.js +30 -237
  79. package/calendar-event/index.cjs +3 -3
  80. package/calendar-event/index.js +4 -4
  81. package/card/index.cjs +14 -11
  82. package/card/index.js +16 -13
  83. package/checkbox/index.cjs +1 -1
  84. package/checkbox/index.js +1 -1
  85. package/color-picker/definition.cjs +1 -1
  86. package/color-picker/definition.js +1 -1
  87. package/color-picker/index.cjs +6 -6
  88. package/color-picker/index.js +24 -24
  89. package/combobox/definition.cjs +1 -1
  90. package/combobox/definition.js +1 -1
  91. package/combobox/index.cjs +9 -8
  92. package/combobox/index.js +32 -28
  93. package/contextual-help/definition.cjs +1 -1
  94. package/contextual-help/definition.js +1 -1
  95. package/contextual-help/index.cjs +1 -1
  96. package/contextual-help/index.js +1 -1
  97. package/custom-elements.json +1027 -615
  98. package/data-grid/definition.js +1 -1
  99. package/data-grid/index.cjs +17 -17
  100. package/data-grid/index.js +261 -264
  101. package/date-picker/index.cjs +1 -1
  102. package/date-picker/index.js +12 -12
  103. package/date-range-picker/index.cjs +1 -1
  104. package/date-range-picker/index.js +7 -7
  105. package/date-time-picker/index.cjs +4 -4
  106. package/date-time-picker/index.js +24 -24
  107. package/dial-pad/index.cjs +3 -2
  108. package/dial-pad/index.js +6 -5
  109. package/dialog/index.cjs +4 -4
  110. package/dialog/index.js +5 -5
  111. package/divider/index.cjs +1 -1
  112. package/divider/index.js +1 -1
  113. package/fab/index.cjs +3 -3
  114. package/fab/index.js +8 -8
  115. package/file-picker/index.cjs +16 -13
  116. package/file-picker/index.js +31 -28
  117. package/header/index.cjs +4 -4
  118. package/header/index.js +5 -5
  119. package/index.cjs +24 -21
  120. package/index.js +11 -11
  121. package/lib/combobox/combobox.d.ts +0 -3
  122. package/lib/date-time-picker/date-time-picker.d.ts +0 -4
  123. package/lib/dial-pad/dial-pad.d.ts +6 -2
  124. package/lib/dialog/dialog.d.ts +0 -1
  125. package/lib/menu/menu.d.ts +0 -1
  126. package/lib/option/option.d.ts +0 -1
  127. package/lib/rich-text-editor/rte/exports.d.ts +1 -0
  128. package/lib/rich-text-editor/rte/features/alignment.d.ts +1 -1
  129. package/lib/rich-text-editor/rte/features/character-count.d.ts +21 -0
  130. package/lib/rich-text-editor/rte/features/font-size-picker.d.ts +1 -1
  131. package/lib/rich-text-editor/rte/features/internal/basic-text-blocks.d.ts +1 -1
  132. package/lib/rich-text-editor/rte/features/keyboard-shortcuts.d.ts +1 -1
  133. package/lib/rich-text-editor/rte/features/text-color-picker.d.ts +1 -1
  134. package/lib/rich-text-editor/rte/public-interface.d.ts +6 -0
  135. package/lib/searchable-select/option-tag.d.ts +0 -1
  136. package/lib/table/definition.d.ts +2 -1
  137. package/lib/table/table-header-cell.d.ts +3 -0
  138. package/lib/table/table-sorting-button.d.ts +415 -0
  139. package/lib/table/table-sorting-button.template.d.ts +3 -0
  140. package/locales/de-DE.cjs +4 -178
  141. package/locales/de-DE.js +2 -179
  142. package/locales/en-GB.cjs +4 -9
  143. package/locales/en-GB.js +2 -10
  144. package/locales/en-US.cjs +268 -2
  145. package/locales/en-US.js +265 -1
  146. package/locales/ja-JP.cjs +4 -171
  147. package/locales/ja-JP.js +2 -172
  148. package/locales/zh-CN.cjs +4 -172
  149. package/locales/zh-CN.js +2 -173
  150. package/menu/index.cjs +1 -1
  151. package/menu/index.js +1 -1
  152. package/menu-item/index.cjs +1 -1
  153. package/menu-item/index.js +1 -1
  154. package/nav-disclosure/index.cjs +3 -3
  155. package/nav-disclosure/index.js +8 -8
  156. package/nav-item/index.cjs +1 -1
  157. package/nav-item/index.js +7 -7
  158. package/note/index.cjs +2 -2
  159. package/note/index.js +6 -6
  160. package/number-field/index.cjs +4 -4
  161. package/number-field/index.js +31 -31
  162. package/option/definition.cjs +1 -1
  163. package/option/definition.js +1 -1
  164. package/option/index.cjs +1 -1
  165. package/option/index.js +1 -1
  166. package/package.json +7 -8
  167. package/pagination/index.cjs +3 -3
  168. package/pagination/index.js +15 -15
  169. package/popover/index.cjs +4 -4
  170. package/popover/index.js +5 -5
  171. package/progress/index.cjs +2 -2
  172. package/progress/index.js +5 -5
  173. package/radio/index.cjs +1 -1
  174. package/radio/index.js +1 -1
  175. package/radio-group/index.cjs +4 -4
  176. package/radio-group/index.js +10 -10
  177. package/range-slider/index.cjs +4 -4
  178. package/range-slider/index.js +17 -17
  179. package/rich-text-editor/definition.cjs +1 -0
  180. package/rich-text-editor/definition.js +2 -2
  181. package/rich-text-editor/index.cjs +13 -13
  182. package/rich-text-editor/index.js +1886 -1829
  183. package/rich-text-view/index.cjs +1 -1
  184. package/rich-text-view/index.js +8 -8
  185. package/searchable-select/index.cjs +12 -12
  186. package/searchable-select/index.js +25 -25
  187. package/select/index.cjs +1 -1
  188. package/select/index.js +1 -1
  189. package/selectable-box/index.cjs +7 -7
  190. package/selectable-box/index.js +11 -11
  191. package/shared/foundation/test-utilities/fixture.d.ts +1 -1
  192. package/shared/patterns/linkable.d.ts +1 -1
  193. package/simple-color-picker/index.cjs +3 -3
  194. package/simple-color-picker/index.js +10 -10
  195. package/split-button/index.cjs +5 -5
  196. package/split-button/index.js +10 -10
  197. package/status/index.cjs +2 -2
  198. package/status/index.js +12 -12
  199. package/switch/index.cjs +3 -3
  200. package/switch/index.js +5 -5
  201. package/tab/index.cjs +1 -1
  202. package/tab/index.js +1 -1
  203. package/tab-panel/index.cjs +1 -1
  204. package/tab-panel/index.js +1 -1
  205. package/table/definition.cjs +17 -14
  206. package/table/definition.js +3 -2
  207. package/table/index.cjs +19 -10
  208. package/table/index.js +69 -21
  209. package/tabs/index.cjs +2 -2
  210. package/tabs/index.js +4 -4
  211. package/tag/index.cjs +7 -7
  212. package/tag/index.js +9 -9
  213. package/tag-group/index.cjs +3 -3
  214. package/tag-group/index.js +5 -5
  215. package/text-area/index.cjs +2 -2
  216. package/text-area/index.js +12 -12
  217. package/text-field/definition.cjs +1 -1
  218. package/text-field/definition.js +1 -1
  219. package/text-field/index.cjs +1 -1
  220. package/text-field/index.js +1 -1
  221. package/time-picker/index.cjs +1 -1
  222. package/time-picker/index.js +1 -1
  223. package/toggletip/definition.cjs +1 -1
  224. package/toggletip/definition.js +1 -1
  225. package/toggletip/index.cjs +1 -1
  226. package/toggletip/index.js +1 -1
  227. package/tooltip/definition.cjs +1 -1
  228. package/tooltip/definition.js +1 -1
  229. package/tooltip/index.cjs +1 -1
  230. package/tooltip/index.js +1 -1
  231. package/tree-item/index.cjs +1 -1
  232. package/tree-item/index.js +1 -1
  233. package/tree-view/index.cjs +3 -3
  234. package/tree-view/index.js +17 -17
  235. package/unbundled/button.cjs +2 -2
  236. package/unbundled/button.js +2 -2
  237. package/unbundled/calendar-picker.template.cjs +4347 -9
  238. package/unbundled/calendar-picker.template.js +4345 -7
  239. package/unbundled/chunk.cjs +0 -22
  240. package/unbundled/definition13.cjs +1 -8
  241. package/unbundled/definition13.js +1 -8
  242. package/unbundled/definition14.cjs +2 -2
  243. package/unbundled/definition14.js +2 -2
  244. package/unbundled/definition2.cjs +1 -1
  245. package/unbundled/definition2.js +1 -1
  246. package/unbundled/definition21.cjs +1 -2
  247. package/unbundled/definition21.js +1 -2
  248. package/unbundled/definition22.cjs +7 -2
  249. package/unbundled/definition22.js +7 -2
  250. package/unbundled/definition24.cjs +98 -979
  251. package/unbundled/definition24.js +93 -974
  252. package/unbundled/definition25.cjs +37 -322
  253. package/unbundled/definition25.js +33 -318
  254. package/unbundled/definition26.cjs +317 -91
  255. package/unbundled/definition26.js +313 -87
  256. package/unbundled/definition27.cjs +94 -192
  257. package/unbundled/definition27.js +91 -183
  258. package/unbundled/definition28.cjs +387 -395
  259. package/unbundled/definition28.js +387 -395
  260. package/unbundled/definition29.cjs +189 -110
  261. package/unbundled/definition29.js +180 -107
  262. package/unbundled/definition30.cjs +520 -36
  263. package/unbundled/definition30.js +519 -35
  264. package/unbundled/definition32.cjs +477 -477
  265. package/unbundled/definition32.js +475 -475
  266. package/unbundled/definition33.cjs +87 -2
  267. package/unbundled/definition33.js +77 -4
  268. package/unbundled/definition35.cjs +2 -2
  269. package/unbundled/definition35.js +2 -2
  270. package/unbundled/definition36.cjs +1 -1
  271. package/unbundled/definition36.js +1 -1
  272. package/unbundled/definition37.cjs +6 -2
  273. package/unbundled/definition37.js +6 -2
  274. package/unbundled/definition38.cjs +7 -5
  275. package/unbundled/definition38.js +7 -5
  276. package/unbundled/definition39.cjs +1 -0
  277. package/unbundled/definition39.js +1 -0
  278. package/unbundled/definition42.cjs +22 -11
  279. package/unbundled/definition42.js +22 -11
  280. package/unbundled/definition49.cjs +3 -3
  281. package/unbundled/definition49.js +3 -3
  282. package/unbundled/definition56.cjs +437 -9506
  283. package/unbundled/definition56.js +340 -9415
  284. package/unbundled/definition57.cjs +5 -5
  285. package/unbundled/definition57.js +5 -5
  286. package/unbundled/definition58.cjs +4 -3
  287. package/unbundled/definition58.js +2 -1
  288. package/unbundled/definition59.cjs +4 -3
  289. package/unbundled/definition59.js +4 -3
  290. package/unbundled/definition62.cjs +2 -2
  291. package/unbundled/definition62.js +2 -2
  292. package/unbundled/definition64.cjs +1 -1
  293. package/unbundled/definition64.js +1 -1
  294. package/unbundled/definition71.cjs +2 -2
  295. package/unbundled/definition71.js +2 -2
  296. package/unbundled/definition72.cjs +1 -2
  297. package/unbundled/definition72.js +1 -2
  298. package/unbundled/definition75.cjs +3 -51711
  299. package/unbundled/definition75.js +1 -51711
  300. package/unbundled/listbox.cjs +1 -1
  301. package/unbundled/listbox.js +1 -1
  302. package/unbundled/localized.cjs +2 -2
  303. package/unbundled/localized.js +1 -1
  304. package/unbundled/picker-field.template.cjs +1 -1
  305. package/unbundled/picker-field.template.js +1 -1
  306. package/unbundled/slottable-request.cjs +2 -3168
  307. package/unbundled/slottable-request.js +3 -3097
  308. package/unbundled/time-selection-picker.template.cjs +1 -1
  309. package/unbundled/time-selection-picker.template.js +1 -1
  310. package/unbundled/vivid-element.cjs +1 -1
  311. package/unbundled/vivid-element.js +1 -1
  312. package/video-player/index.cjs +3 -3
  313. package/video-player/index.js +9 -9
  314. package/vivid.api.json +220 -282
  315. package/unbundled/chunk.js +0 -33
  316. package/unbundled/en-US.cjs +0 -447
  317. package/unbundled/en-US.js +0 -443
@@ -1,1020 +1,139 @@
1
1
  import { o as defineVividComponent, s as createRegisterFunction, t as VividElement } from "./vivid-element.js";
2
- import { r as Icon, t as iconDefinition } from "./definition2.js";
3
2
  import { t as __decorate } from "./decorate.js";
4
- import { n as delegateAria, t as DelegatesAria } from "./delegates-aria.js";
5
- import { t as WithSuccessText } from "./with-success-text.js";
6
- import { t as WithErrorText } from "./with-error-text.js";
7
- import { t as WithContextualHelp } from "./with-contextual-help.js";
8
- import { t as TrappedFocus } from "./trapped-focus.js";
9
- import { i as Button, t as buttonDefinition } from "./definition7.js";
3
+ import { t as Localized } from "./localized.js";
10
4
  import { t as handleEscapeKeyAndStopPropogation } from "./dialog.js";
11
5
  import { i as Popup, t as popupDefinition } from "./definition10.js";
12
- import { a as feedbackMessageDefinition, t as WithFeedback } from "./mixins.js";
13
- import { n as isValidHexColor, t as BaseColorPicker } from "./base-color-picker.js";
14
- import { n as textFieldDefinition, r as TextField } from "./definition25.js";
15
- import { n as tooltipDefinition, r as Tooltip } from "./definition26.js";
16
- import { attr, html, nullableNumberConverter, observable, ref, repeat, slotted, when } from "@microsoft/fast-element";
6
+ import { n as anchorSlotTemplateFactory, t as Anchored } from "./anchored.js";
7
+ import { Updates, attr, html, when } from "@microsoft/fast-element";
17
8
  import { classNames } from "@microsoft/fast-web-utilities";
18
- //#region src/lib/color-picker/color-picker.scss?inline
19
- var color_picker_default$1 = ".palette{grid-template-columns:repeat(var(--swatches-per-row,7), var(--_color-swatch-size,24px));display:grid}.swatch{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);border-radius:4px;padding:0;position:relative}.swatch:not(.contrast){border:none}.swatch.contrast{border:1px solid var(--vvd-color-neutral-400);color:var(--vvd-color-canvas-text)}.swatch:focus-visible{box-shadow:0 0 0 4px color-mix(in srgb, var(--focus-stroke-color,var(--vvd-color-cta-500)), transparent 85%), inset 0 0 0 3px var(--focus-stroke-gap-color,currentColor);outline:none;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{--_low-ink-color:var(--vvd-color-neutral-600);display:inline-block}.base{min-inline-size:var(--_color-picker-min-inline-size,280px);display:inline-block}.control{inline-size:100%}.button{box-sizing:border-box;background-color:var(--button-color,var(--vvd-color-canvas-text));block-size:calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 8));color:var(--vvd-color-canvas);inline-size:calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 8));padding-inline:calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 8)) / 4);vertical-align:middle;border:0;border-radius:4px;align-items:center;margin:0;text-decoration:none;display:inline-flex}.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(--focus-stroke-color,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(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 8)) / 2);line-height:1}.dialog{min-inline-size:var(--_color-picker-popup-min-inline-size,264px);flex-direction:column;display:flex}.dialog .header{justify-content:space-between;align-items:center;padding-block:8px;padding-inline:16px;display:inline-flex}.dialog .header-title{font:var(--vvd-typography-base-extended-bold);margin-block:0}.dialog .body{flex-direction:column;gap:16px;margin-block-end:16px;padding-inline:16px;display:flex}.dialog .hex-input-wrapper{align-items:stretch;gap:8px;display:flex}.dialog .hex-input-wrapper [data-vvd-component=button]{flex:none}.dialog .footer{border-top:1px solid var(--vvd-color-neutral-200);padding:16px}.dialog .footer-header{margin-block-end:8px}.dialog .swatches-count{color:var(--_low-ink-color);font:var(--vvd-typography-base)}.dialog .palette{gap:var(--_color-swatches-gap,8px)}vvd-hex-input{flex:auto;min-width:0}vvd-hex-input::part(input),vvd-hex-input>input{box-sizing:border-box;background-color:var(--vvd-color-canvas);width:100%;height:100%;box-shadow:inset 0 0 0 1px var(--vvd-color-neutral-500);font:var(--vvd-typography-base);padding-inline:calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2))) / 2.5);border:0;border-radius:8px;outline:#0000}vvd-hex-input::part(input):focus-visible,vvd-hex-input>input:focus-visible{box-shadow:0 0 0 4px color-mix(in srgb, var(--focus-stroke-color,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){border-radius:8px;flex:0 0 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)}.visually-hidden{clip:rect(0 0 0 0);border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}";
9
+ //#region src/lib/toggletip/toggletip.scss?inline
10
+ var toggletip_default = ":host :host{display:var(--_popup-display,inline)}:host :host([slotted-anchor]){--_popup-display:contents}.content-wrapper{width:var(--toggletip-inline-size,auto);max-inline-size:var(--toggletip-max-inline-size,30ch);padding:16px}.headline{font:var(--vvd-typography-base-bold);margin:0}.action-items{justify-content:flex-end;gap:10px;display:flex}::slotted([slot=action-items]){margin-block-start:16px}";
20
11
  //#endregion
21
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/lib/utils/math.js
22
- var clamp = (number, min = 0, max = 1) => {
23
- return number > max ? max : number < min ? min : number;
24
- };
25
- var round = (number, digits = 0, base = Math.pow(10, digits)) => {
26
- return Math.round(base * number) / base;
27
- };
28
- 360 / (Math.PI * 2);
29
- var hexToHsva = (hex) => rgbaToHsva(hexToRgba(hex));
30
- var hexToRgba = (hex) => {
31
- if (hex[0] === "#") hex = hex.substring(1);
32
- if (hex.length < 6) 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
- return {
39
- r: parseInt(hex.substring(0, 2), 16),
40
- g: parseInt(hex.substring(2, 4), 16),
41
- b: parseInt(hex.substring(4, 6), 16),
42
- a: hex.length === 8 ? round(parseInt(hex.substring(6, 8), 16) / 255, 2) : 1
43
- };
44
- };
45
- var hsvaToHex = (hsva) => rgbaToHex(hsvaToRgba(hsva));
46
- var hsvaToHsla = ({ h, s, v, a }) => {
47
- const hh = (200 - s) * v / 100;
48
- return {
49
- h: round(h),
50
- s: round(hh > 0 && hh < 200 ? s * v / 100 / (hh <= 100 ? hh : 200 - hh) * 100 : 0),
51
- l: round(hh / 2),
52
- a: round(a, 2)
53
- };
54
- };
55
- var hsvaToHslString = (hsva) => {
56
- const { h, s, l } = hsvaToHsla(hsva);
57
- return `hsl(${h}, ${s}%, ${l}%)`;
58
- };
59
- var hsvaToRgba = ({ h, s, v, a }) => {
60
- h = h / 360 * 6;
61
- s = s / 100;
62
- v = v / 100;
63
- 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;
64
- return {
65
- r: round([
66
- v,
67
- c,
68
- b,
69
- b,
70
- d,
71
- v
72
- ][module] * 255),
73
- g: round([
74
- d,
75
- v,
76
- v,
77
- c,
78
- b,
79
- b
80
- ][module] * 255),
81
- b: round([
82
- b,
83
- b,
84
- d,
85
- v,
86
- v,
87
- c
88
- ][module] * 255),
89
- a: round(a, 2)
90
- };
91
- };
92
- var format = (number) => {
93
- const hex = number.toString(16);
94
- return hex.length < 2 ? "0" + hex : hex;
95
- };
96
- var rgbaToHex = ({ r, g, b, a }) => {
97
- const alphaHex = a < 1 ? format(round(a * 255)) : "";
98
- return "#" + format(r) + format(g) + format(b) + alphaHex;
99
- };
100
- var rgbaToHsva = ({ r, g, b, a }) => {
101
- const max = Math.max(r, g, b);
102
- const delta = max - Math.min(r, g, b);
103
- const hh = delta ? max === r ? (g - b) / delta : max === g ? 2 + (b - r) / delta : 4 + (r - g) / delta : 0;
104
- return {
105
- h: round(60 * (hh < 0 ? hh + 6 : hh)),
106
- s: round(max ? delta / max * 100 : 0),
107
- v: round(max / 255 * 100),
108
- a
109
- };
110
- };
111
- //#endregion
112
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/lib/utils/compare.js
113
- var equalColorObjects = (first, second) => {
114
- if (first === second) return true;
115
- for (const prop in first) if (first[prop] !== second[prop]) return false;
116
- return true;
117
- };
118
- var equalHex = (first, second) => {
119
- if (first.toLowerCase() === second.toLowerCase()) return true;
120
- return equalColorObjects(hexToRgba(first), hexToRgba(second));
121
- };
122
- //#endregion
123
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/lib/utils/dom.js
124
- var cache = {};
125
- var tpl = (html) => {
126
- let template = cache[html];
127
- if (!template) {
128
- template = document.createElement("template");
129
- template.innerHTML = html;
130
- cache[html] = template;
131
- }
132
- return template;
133
- };
134
- var fire = (target, type, detail) => {
135
- target.dispatchEvent(new CustomEvent(type, {
136
- bubbles: true,
137
- detail
138
- }));
139
- };
140
- //#endregion
141
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/lib/components/slider.js
142
- var hasTouched = false;
143
- var isTouch = (e) => "touches" in e;
144
- var isValid = (event) => {
145
- if (hasTouched && !isTouch(event)) return false;
146
- if (!hasTouched) hasTouched = isTouch(event);
147
- return true;
148
- };
149
- var pointerMove = (target, event) => {
150
- const pointer = isTouch(event) ? event.touches[0] : event;
151
- const rect = target.el.getBoundingClientRect();
152
- fire(target.el, "move", target.getMove({
153
- x: clamp((pointer.pageX - (rect.left + window.pageXOffset)) / rect.width),
154
- y: clamp((pointer.pageY - (rect.top + window.pageYOffset)) / rect.height)
155
- }));
156
- };
157
- var keyMove = (target, event) => {
158
- const keyCode = event.keyCode;
159
- if (keyCode > 40 || target.xy && keyCode < 37 || keyCode < 33) return;
160
- event.preventDefault();
161
- fire(target.el, "move", target.getMove({
162
- x: keyCode === 39 ? .01 : keyCode === 37 ? -.01 : keyCode === 34 ? .05 : keyCode === 33 ? -.05 : keyCode === 35 ? 1 : keyCode === 36 ? -1 : 0,
163
- y: keyCode === 40 ? .01 : keyCode === 38 ? -.01 : 0
164
- }, true));
165
- };
166
- var Slider = class {
167
- constructor(root, part, aria, xy) {
168
- const template = tpl(`<div role="slider" tabindex="0" part="${part}" ${aria}><div part="${part}-pointer"></div></div>`);
169
- root.appendChild(template.content.cloneNode(true));
170
- const el = root.querySelector(`[part=${part}]`);
171
- el.addEventListener("mousedown", this);
172
- el.addEventListener("touchstart", this);
173
- el.addEventListener("keydown", this);
174
- this.el = el;
175
- this.xy = xy;
176
- this.nodes = [el.firstChild, el];
177
- }
178
- set dragging(state) {
179
- const toggleEvent = state ? document.addEventListener : document.removeEventListener;
180
- toggleEvent(hasTouched ? "touchmove" : "mousemove", this);
181
- toggleEvent(hasTouched ? "touchend" : "mouseup", this);
182
- }
183
- handleEvent(event) {
184
- switch (event.type) {
185
- case "mousedown":
186
- case "touchstart":
187
- event.preventDefault();
188
- if (!isValid(event) || !hasTouched && event.button != 0) return;
189
- this.el.focus();
190
- pointerMove(this, event);
191
- this.dragging = true;
192
- break;
193
- case "mousemove":
194
- case "touchmove":
195
- event.preventDefault();
196
- pointerMove(this, event);
197
- break;
198
- case "mouseup":
199
- case "touchend":
200
- this.dragging = false;
201
- break;
202
- case "keydown":
203
- keyMove(this, event);
204
- break;
205
- }
206
- }
207
- style(styles) {
208
- styles.forEach((style, i) => {
209
- for (const p in style) this.nodes[i].style.setProperty(p, style[p]);
210
- });
211
- }
212
- };
213
- //#endregion
214
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/lib/components/hue.js
215
- var Hue = class extends Slider {
216
- constructor(root) {
217
- super(root, "hue", "aria-label=\"Hue\" aria-valuemin=\"0\" aria-valuemax=\"360\"", false);
218
- }
219
- update({ h }) {
220
- this.h = h;
221
- this.style([{
222
- left: `${h / 360 * 100}%`,
223
- color: hsvaToHslString({
224
- h,
225
- s: 100,
226
- v: 100,
227
- a: 1
228
- })
229
- }]);
230
- this.el.setAttribute("aria-valuenow", `${round(h)}`);
231
- }
232
- getMove(offset, key) {
233
- return { h: key ? clamp(this.h + offset.x * 360, 0, 360) : 360 * offset.x };
234
- }
235
- };
236
- //#endregion
237
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/lib/components/saturation.js
238
- var Saturation = class extends Slider {
239
- constructor(root) {
240
- super(root, "saturation", "aria-label=\"Color\"", true);
241
- }
242
- update(hsva) {
243
- this.hsva = hsva;
244
- this.style([{
245
- top: `${100 - hsva.v}%`,
246
- left: `${hsva.s}%`,
247
- color: hsvaToHslString(hsva)
248
- }, { "background-color": hsvaToHslString({
249
- h: hsva.h,
250
- s: 100,
251
- v: 100,
252
- a: 1
253
- }) }]);
254
- this.el.setAttribute("aria-valuetext", `Saturation ${round(hsva.s)}%, Brightness ${round(hsva.v)}%`);
255
- }
256
- getMove(offset, key) {
257
- return {
258
- s: key ? clamp(this.hsva.s + offset.x * 100, 0, 100) : offset.x * 100,
259
- v: key ? clamp(this.hsva.v - offset.y * 100, 0, 100) : Math.round(100 - offset.y * 100)
260
- };
261
- }
262
- };
263
- //#endregion
264
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/lib/styles/color-picker.js
265
- var color_picker_default = `: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)}`;
266
- //#endregion
267
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/lib/styles/hue.js
268
- var hue_default = `[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}`;
269
- //#endregion
270
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/lib/styles/saturation.js
271
- var saturation_default = `[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}`;
272
- //#endregion
273
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/lib/components/color-picker.js
274
- var $isSame = Symbol("same");
275
- var $color$1 = Symbol("color");
276
- var $hsva = Symbol("hsva");
277
- var $update$1 = Symbol("update");
278
- var $parts = Symbol("parts");
279
- var $css = Symbol("css");
280
- var $sliders = Symbol("sliders");
281
- var ColorPicker$1 = class extends HTMLElement {
282
- static get observedAttributes() {
283
- return ["color"];
284
- }
285
- get [$css]() {
286
- return [
287
- color_picker_default,
288
- hue_default,
289
- saturation_default
290
- ];
291
- }
292
- get [$sliders]() {
293
- return [Saturation, Hue];
294
- }
295
- get color() {
296
- return this[$color$1];
297
- }
298
- set color(newColor) {
299
- if (!this[$isSame](newColor)) {
300
- const newHsva = this.colorModel.toHsva(newColor);
301
- this[$update$1](newHsva);
302
- this[$color$1] = newColor;
303
- }
304
- }
305
- constructor() {
306
- super();
307
- const template = tpl(`<style>${this[$css].join("")}</style>`);
308
- const root = this.attachShadow({ mode: "open" });
309
- root.appendChild(template.content.cloneNode(true));
310
- root.addEventListener("move", this);
311
- this[$parts] = this[$sliders].map((slider) => new slider(root));
312
- }
313
- connectedCallback() {
314
- if (this.hasOwnProperty("color")) {
315
- const value = this.color;
316
- delete this["color"];
317
- this.color = value;
318
- } else if (!this.color) this.color = this.colorModel.defaultColor;
319
- }
320
- attributeChangedCallback(_attr, _oldVal, newVal) {
321
- const color = this.colorModel.fromAttr(newVal);
322
- if (!this[$isSame](color)) this.color = color;
323
- }
324
- handleEvent(event) {
325
- const oldHsva = this[$hsva];
326
- const newHsva = {
327
- ...oldHsva,
328
- ...event.detail
329
- };
330
- this[$update$1](newHsva);
331
- let newColor;
332
- if (!equalColorObjects(newHsva, oldHsva) && !this[$isSame](newColor = this.colorModel.fromHsva(newHsva))) {
333
- this[$color$1] = newColor;
334
- fire(this, "color-changed", { value: newColor });
335
- }
336
- }
337
- [$isSame](color) {
338
- return this.color && this.colorModel.equal(color, this.color);
339
- }
340
- [$update$1](hsva) {
341
- this[$hsva] = hsva;
342
- this[$parts].forEach((part) => part.update(hsva));
343
- }
344
- };
345
- //#endregion
346
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/lib/entrypoints/hex.js
347
- var colorModel = {
348
- defaultColor: "#000",
349
- toHsva: hexToHsva,
350
- fromHsva: ({ h, s, v }) => hsvaToHex({
351
- h,
352
- s,
353
- v,
354
- a: 1
355
- }),
356
- equal: equalHex,
357
- fromAttr: (color) => color
358
- };
359
- var HexBase = class extends ColorPicker$1 {
360
- get colorModel() {
361
- return colorModel;
362
- }
363
- };
364
- //#endregion
365
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/hex-color-picker.js
366
- /**
367
- * A color picker custom element that uses HEX format.
368
- *
369
- * @element hex-color-picker
370
- *
371
- * @prop {string} color - Selected color in HEX format.
372
- * @attr {string} color - Selected color in HEX format.
373
- *
374
- * @fires color-changed - Event fired when color property changes.
375
- *
376
- * @csspart hue - A hue selector container.
377
- * @csspart saturation - A saturation selector container
378
- * @csspart hue-pointer - A hue pointer element.
379
- * @csspart saturation-pointer - A saturation pointer element.
380
- */
381
- var HexColorPicker = class extends HexBase {};
382
- customElements.define("hex-color-picker", HexColorPicker);
383
- //#endregion
384
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/lib/utils/validate.js
385
- var matcher = /^#?([0-9A-F]{3,8})$/i;
386
- var validHex = (value, alpha) => {
387
- const match = matcher.exec(value);
388
- const length = match ? match[1].length : 0;
389
- return length === 3 || length === 6 || !!alpha && length === 4 || !!alpha && length === 8;
390
- };
391
- //#endregion
392
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/lib/entrypoints/hex-input.js
393
- var template = tpl("<slot><input part=\"input\" spellcheck=\"false\"></slot>");
394
- var escape = (hex, alpha) => hex.replace(/([^0-9A-F]+)/gi, "").substring(0, alpha ? 8 : 6);
395
- var $alpha = Symbol("alpha");
396
- var $color = Symbol("color");
397
- var $saved = Symbol("saved");
398
- var $input = Symbol("input");
399
- var $init = Symbol("init");
400
- var $prefix = Symbol("prefix");
401
- var $update = Symbol("update");
402
- var HexInputBase = class extends HTMLElement {
403
- static get observedAttributes() {
404
- return [
405
- "alpha",
406
- "color",
407
- "prefixed"
408
- ];
409
- }
410
- get color() {
411
- return this[$color];
412
- }
413
- set color(hex) {
414
- this[$color] = hex;
415
- this[$update](hex);
416
- }
417
- get alpha() {
418
- return this[$alpha];
419
- }
420
- set alpha(alpha) {
421
- this[$alpha] = alpha;
422
- this.toggleAttribute("alpha", alpha);
423
- const color = this.color;
424
- if (color && !validHex(color, alpha)) this.color = color.startsWith("#") ? color.substring(0, color.length === 5 ? 4 : 7) : color.substring(0, color.length === 4 ? 3 : 6);
425
- }
426
- get prefixed() {
427
- return this[$prefix];
428
- }
429
- set prefixed(prefixed) {
430
- this[$prefix] = prefixed;
431
- this.toggleAttribute("prefixed", prefixed);
432
- this[$update](this.color);
433
- }
434
- constructor() {
435
- super();
436
- const root = this.attachShadow({ mode: "open" });
437
- root.appendChild(template.content.cloneNode(true));
438
- root.firstElementChild.addEventListener("slotchange", () => this[$init](root));
439
- }
440
- connectedCallback() {
441
- this[$init](this.shadowRoot);
442
- if (this.hasOwnProperty("alpha")) {
443
- const value = this.alpha;
444
- delete this["alpha"];
445
- this.alpha = value;
446
- } else this.alpha = this.hasAttribute("alpha");
447
- if (this.hasOwnProperty("prefixed")) {
448
- const value = this.prefixed;
449
- delete this["prefixed"];
450
- this.prefixed = value;
451
- } else this.prefixed = this.hasAttribute("prefixed");
452
- if (this.hasOwnProperty("color")) {
453
- const value = this.color;
454
- delete this["color"];
455
- this.color = value;
456
- } else if (this.color == null) this.color = this.getAttribute("color") || "";
457
- else if (this[$color]) this[$update](this[$color]);
458
- }
459
- handleEvent(event) {
460
- const { value } = event.target;
461
- switch (event.type) {
462
- case "input":
463
- const hex = escape(value, this.alpha);
464
- this[$saved] = this.color;
465
- if (validHex(hex, this.alpha) || value === "") {
466
- this.color = hex;
467
- this.dispatchEvent(new CustomEvent("color-changed", {
468
- bubbles: true,
469
- detail: { value: hex ? "#" + hex : "" }
470
- }));
471
- }
472
- break;
473
- case "blur": if (value && !validHex(value, this.alpha)) this.color = this[$saved];
474
- }
475
- }
476
- attributeChangedCallback(attr, _oldVal, newVal) {
477
- if (attr === "color" && this.color !== newVal) this.color = newVal;
478
- const hasBooleanAttr = newVal != null;
479
- if (attr === "alpha") {
480
- if (this.alpha !== hasBooleanAttr) this.alpha = hasBooleanAttr;
481
- }
482
- if (attr === "prefixed") {
483
- if (this.prefixed !== hasBooleanAttr) this.prefixed = hasBooleanAttr;
484
- }
485
- }
486
- [$init](root) {
487
- let input = this.querySelector("input");
488
- if (!input) {
489
- let c;
490
- while (c = this.firstChild) c.remove();
491
- input = root.querySelector("input");
492
- }
493
- input.addEventListener("input", this);
494
- input.addEventListener("blur", this);
495
- this[$input] = input;
496
- this[$update](this.color);
497
- }
498
- [$update](hex) {
499
- if (this[$input]) this[$input].value = hex == null || hex == "" ? "" : (this.prefixed ? "#" : "") + escape(hex, this.alpha);
500
- }
501
- };
502
- //#endregion
503
- //#region ../../node_modules/.pnpm/vanilla-colorful@0.7.2/node_modules/vanilla-colorful/hex-input.js
504
- /**
505
- * A custom element for entering color in HEX format.
506
- *
507
- * @element hex-input
508
- *
509
- * @prop {string} color - Color in HEX format.
510
- * @attr {string} color - Selected color in HEX format.
511
- * @prop {boolean} alpha - When true, `#rgba` and `#rrggbbaa` color formats are allowed.
512
- * @attr {boolean} alpha - Allows `#rgba` and `#rrggbbaa` color formats.
513
- * @prop {boolean} prefixed - When true, `#` prefix is displayed in the input.
514
- * @attr {boolean} prefixed - Enables `#` prefix displaying.
515
- *
516
- * @fires color-changed - Event fired when color is changed.
517
- *
518
- * @csspart input - A native input element.
519
- */
520
- var HexInput = class extends HexInputBase {};
521
- customElements.define("hex-input", HexInput);
522
- //#endregion
523
- //#region src/lib/color-picker/color-picker.ts
524
- var VC_HEX_PICKER_TAG = "vvd-hex-picker";
525
- var VC_HEX_INPUT_TAG = "vvd-hex-input";
526
- var VvdHexPicker = class extends HexColorPicker {
527
- static {
528
- this.displayName = "VvdHexPicker";
529
- }
530
- };
531
- var VvdHexInput = class extends HexInput {
532
- static {
533
- this.displayName = "VvdHexInput";
534
- }
535
- };
536
- /* v8 ignore if -- @preserve */
537
- if (!customElements.get(VC_HEX_PICKER_TAG)) customElements.define(VC_HEX_PICKER_TAG, VvdHexPicker);
538
- /* v8 ignore if -- @preserve */
539
- if (!customElements.get(VC_HEX_INPUT_TAG)) customElements.define(VC_HEX_INPUT_TAG, VvdHexInput);
540
- var vcPickerTag = VC_HEX_PICKER_TAG;
541
- var vcInputTag = VC_HEX_INPUT_TAG;
12
+ //#region src/lib/toggletip/toggletip.ts
542
13
  /**
543
14
  * @public
544
- * @component color-picker
545
- * @slot helper-text - Describes how to use the text-field. Alternative to the `helper-text` attribute.
546
- * @slot popup-text - Overrides the default "Color Picker" title of the Popup window.
547
- * @slot swatches-text - Overrides the default "Saved colors:" text above color swatches.
548
- * @event {CustomEvent<undefined>} change - Fires when the value changes
549
- * @vueModel modelValue value input `event.currentTarget.value`
15
+ * @component toggletip
16
+ * @slot - The content to display in the toggletip.
17
+ * @slot anchor - Used to set the anchor element for the toggletip.
18
+ * @slot action-items - The content to display in the toggletip action items.
19
+ * @testSelector byHeadline byHeadline
20
+ * @testQuery open open true
21
+ * @testQuery closed open false
550
22
  */
551
- var ColorPicker = class extends WithContextualHelp(WithFeedback(WithErrorText(WithSuccessText(DelegatesAria(TrappedFocus(BaseColorPicker(VividElement))))))) {
23
+ var Toggletip = class extends Localized(Anchored(VividElement)) {
552
24
  constructor(..._args) {
553
25
  super(..._args);
554
- this.disableSavedColors = false;
555
- this.savedColors = [];
556
- this.maxSwatches = 6;
557
- this.copyIconName = "copy-2-line";
558
- this._copyValueToClipboard = async (value) => {
559
- try {
560
- await navigator.clipboard.writeText(value);
561
- this._setTemporaryCopyIcon("check-circle-line");
562
- this._ariaLiveDescription = this.locale.colorPicker.copySuccessMessage(value);
563
- } catch {
564
- alert(this.locale.colorPicker.copyErrorText);
565
- this._setTemporaryCopyIcon("error-line");
566
- this._ariaLiveDescription = this.locale.colorPicker.copyErrorText;
567
- }
568
- };
569
- this._ariaLiveDescription = "";
570
- }
571
- static {
572
- this.HEX_COLOR_PATTERN = /^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$/;
573
- }
574
- /**
575
- * @internal
576
- */
577
- placeholderChanged() {
578
- /* v8 ignore if -- @preserve */
579
- if (this.proxy instanceof HTMLInputElement) this.proxy.placeholder = this.placeholder;
580
- }
581
- /**
582
- * Change event handler for inner control.
583
- * @remarks
584
- * @internal
585
- */
586
- handleChange() {
587
- this.$emit("change");
588
- }
589
- /**
590
- * @internal
591
- */
592
- openChanged(_oldValue, newValue) {
593
- if (newValue && this.isConnected) requestAnimationFrame(() => {
594
- this._refreshCanvasColor();
595
- });
596
- }
597
- /**
598
- * @internal
599
- */
600
- savedColorsKeyChanged() {
601
- this.savedColors = this._loadSavedColors();
602
- }
603
- /**
604
- * @internal
605
- */
606
- get _savedColorsStorageKey() {
607
- if (this.savedColorsKey) return this.savedColorsKey;
608
- return `vvd-saved-colors:${this.tagName.toLowerCase()}`;
609
- }
610
- /**
611
- * @internal
612
- */
613
- _handleColorSaving() {
614
- this._saveCurrentColor();
615
- }
616
- /**
617
- * @internal
618
- */
619
- _saveCurrentColor() {
620
- const value = this.value;
621
- if (typeof value !== "string" || !isValidHexColor(value)) return;
622
- const swatches = Array.isArray(this.savedColors) ? [...this.savedColors] : [];
623
- const idx = swatches.findIndex((s) => s?.value === value);
624
- if (idx !== -1) swatches.splice(idx, 1);
625
- swatches.unshift({ value });
626
- this.savedColors = swatches.slice(0, this._maxSwatchesNormalized);
627
- this._setSavedColors(this.savedColors);
628
- }
629
- /**
630
- * @internal
631
- */
632
- _loadSavedColors() {
633
- try {
634
- const savedColors = localStorage.getItem(this._savedColorsStorageKey);
635
- if (!savedColors) return [];
636
- const parsed = JSON.parse(savedColors);
637
- if (!Array.isArray(parsed)) return [];
638
- return parsed.filter((x) => x && typeof x.value === "string" && isValidHexColor(x.value)).map((x) => ({
639
- value: x.value,
640
- label: typeof x.label === "string" ? x.label : void 0
641
- }));
642
- } catch {
643
- return [];
644
- }
645
- }
646
- /**
647
- * @internal
648
- */
649
- _setSavedColors(swatches) {
650
- try {
651
- localStorage.setItem(this._savedColorsStorageKey, JSON.stringify(swatches));
652
- } catch {}
653
- }
654
- /**
655
- * Get all color swatches combined, both from swatches property and saved colors
656
- * @internal
657
- */
658
- get allSwatches() {
659
- const predefinedColors = Array.isArray(this.swatches) ? this.swatches : [];
660
- const savedColors = Array.isArray(this.savedColors) ? this.savedColors : [];
661
- const seen = /* @__PURE__ */ new Set();
662
- const merged = [];
663
- const appendIfUniqueAndValid = (swatch) => {
664
- if (!swatch || typeof swatch.value !== "string") return;
665
- if (!isValidHexColor(swatch.value) || seen.has(swatch.value)) return;
666
- seen.add(swatch.value);
667
- merged.push(swatch);
668
- };
669
- if (!this.disableSavedColors) savedColors.forEach(appendIfUniqueAndValid);
670
- predefinedColors.forEach(appendIfUniqueAndValid);
671
- return merged.slice(0, this._maxSwatchesNormalized);
672
- }
673
- /**
674
- * @internal
675
- */
676
- get _maxSwatchesNormalized() {
677
- return Number.isFinite(this.maxSwatches) ? Math.max(0, Math.floor(this.maxSwatches)) : 0;
678
- }
679
- /**
680
- * @internal
681
- */
682
- maxSwatchesChanged() {
683
- const maxCount = this._maxSwatchesNormalized;
684
- if (this.savedColors?.length > maxCount) {
685
- this.savedColors = this.savedColors.slice(0, maxCount);
686
- this._setSavedColors(this.savedColors);
687
- }
688
- }
689
- /**
690
- * @internal
691
- */
692
- _onPickerColorChanged(e) {
693
- if (typeof e.detail?.value === "string") this.value = e.detail?.value;
694
- }
695
- /**
696
- * @internal
697
- */
698
- valueChanged(_oldVal, newVal) {
699
- if (this._vcHexPickerEl && typeof newVal === "string") this._vcHexPickerEl.color = newVal;
700
- if (this._vcHexInputEl && typeof newVal === "string") this._vcHexInputEl.color = newVal;
701
- }
702
- /**
703
- * @internal
704
- */
705
- _onTextFieldInput(event) {
706
- this.value = event.currentTarget.value;
707
- }
708
- /**
709
- * @internal
710
- */
711
- get _buttonColor() {
712
- /* v8 ignore else -- @preserve */
713
- if (!this._canvasColor) this._refreshCanvasColor();
714
- if (this.value && isValidHexColor(this.value)) return this.value;
715
- return "var(--vvd-color-canvas-text)";
716
- }
717
- /**
718
- * @internal
719
- */
720
- _onButtonClick() {
721
- this.open = !this.open;
722
- }
723
- /**
724
- * @internal
725
- */
726
- _handleCloseRequest() {
26
+ this.alternate = false;
27
+ this.placement = "right";
727
28
  this.open = false;
728
29
  }
30
+ #originalAriaLabel = null;
729
31
  /**
730
32
  * @internal
731
33
  */
732
- _isInPath(e, el) {
733
- if (!el) return false;
734
- const path = e.composedPath?.();
735
- return !!(path && path.includes(el));
34
+ openChanged(oldValue, newValue) {
35
+ if (oldValue === void 0) return;
36
+ if (newValue) this.setAttribute("role", "status");
37
+ else this.removeAttribute("role");
38
+ this.#updateListeners();
39
+ if (this._anchorEl) this.#updateAnchor(this._anchorEl);
736
40
  }
737
- /**
738
- * @internal
739
- */
740
- #closeOnPointerOutside = (e) => {
741
- if (this._isInPath(e, this._buttonEl) || this._isInPath(e, this._popupEl)) return;
742
- this.open = false;
743
- };
744
41
  connectedCallback() {
745
42
  super.connectedCallback();
746
- this.savedColors = this._loadSavedColors();
747
- document.addEventListener("mousedown", this.#closeOnPointerOutside, true);
43
+ this.#updateListeners();
748
44
  }
749
45
  disconnectedCallback() {
750
46
  super.disconnectedCallback();
751
- document.removeEventListener("mousedown", this.#closeOnPointerOutside, true);
47
+ this.#updateListeners();
752
48
  }
753
- #iconResetTimer = null;
754
49
  /**
755
50
  * @internal
756
51
  */
757
- _setTemporaryCopyIcon(name, ms = 2e3) {
758
- this.copyIconName = name;
759
- if (this.#iconResetTimer) clearTimeout(this.#iconResetTimer);
760
- this.#iconResetTimer = setTimeout(() => {
761
- this.copyIconName = "copy-2-line";
762
- this.#iconResetTimer = null;
763
- }, ms);
52
+ _anchorElChanged(oldValue, newValue) {
53
+ if (oldValue) this.#cleanupAnchor(oldValue);
54
+ if (newValue) this.#setupAnchor(newValue);
764
55
  }
765
- /**
766
- * @internal
767
- */
768
- _onBaseKeydown(event) {
769
- if (this.open && handleEscapeKeyAndStopPropogation(event)) {
770
- this.open = false;
771
- return false;
772
- }
773
- if (this._trappedFocus(event, () => this._focusableElsWithinDialog())) return false;
774
- return true;
56
+ #setupAnchor(a) {
57
+ a.addEventListener("click", this.#openIfClosed, true);
58
+ this.#originalAriaLabel = a.ariaLabel;
59
+ a.ariaLabel = `${this.locale.toggletip.anchorLabel(a.ariaLabel || "")}`;
60
+ this.#updateAnchor(a);
775
61
  }
776
- /**
777
- * @internal
778
- */
779
- _focusableElsWithinDialog() {
780
- return this._popupEl.querySelectorAll("button:not([role=\"gridcell\"]), [data-vvd-component=\"button\"], vwc-button:not([role=\"gridcell\"])");
62
+ #updateAnchor(a) {
63
+ a.setAttribute("aria-expanded", this.open.toString());
64
+ a.setAttribute("data-expanded", this.open.toString());
781
65
  }
782
- /**
783
- * @internal
784
- */
785
- _handleCellKeydown(event, value, index, isSaveCell) {
786
- if (event.key === "Tab") {
787
- event.preventDefault();
788
- const focusableEls = this._focusableElsWithinDialog();
789
- const idx = Array.prototype.indexOf.call(focusableEls, event.currentTarget);
790
- focusableEls[event.shiftKey ? (idx - 1 + focusableEls.length) % focusableEls.length : (idx + 1) % focusableEls.length]?.focus();
791
- return false;
66
+ #cleanupAnchor(a) {
67
+ a.removeEventListener("click", this.#openIfClosed, true);
68
+ a.removeAttribute("aria-expanded");
69
+ a.removeAttribute("data-expanded");
70
+ /* v8 ignore else -- @preserve */
71
+ if (a.ariaLabel) a.ariaLabel = this.#originalAriaLabel;
72
+ }
73
+ #openIfClosed = () => {
74
+ if (!this.open) Updates.enqueue(() => this.open = true);
75
+ };
76
+ #updateListeners() {
77
+ document.removeEventListener("click", this.#closeOnClickOutside);
78
+ document.removeEventListener("keydown", this.#closeOnEscape);
79
+ if (this.open && this.isConnected) {
80
+ document.addEventListener("click", this.#closeOnClickOutside);
81
+ document.addEventListener("keydown", this.#closeOnEscape);
792
82
  }
793
- return super._handleCellKeydown(event, value, index, isSaveCell);
794
83
  }
795
- /**
796
- * @internal
797
- */
798
- _handleSwatchSelection(value) {
84
+ #closeOnClickOutside = (e) => {
85
+ const clickedOutside = !this.contains(e.target);
86
+ const clickedOnAnchor = this._anchorEl?.contains(e.target);
87
+ if (clickedOutside || clickedOnAnchor) this.open = false;
88
+ };
89
+ #closeOnEscape = (e) => {
799
90
  /* v8 ignore else -- @preserve */
800
- if (this.value !== value) this._ariaLiveDescription = this.locale.colorPicker.selectionSuccessMessage(value);
801
- super._handleSwatchSelection(value);
802
- }
91
+ if (e.key === "Escape") this.open = false;
92
+ };
803
93
  };
804
- __decorate([attr], ColorPicker.prototype, "placeholder", void 0);
805
- __decorate([attr({ attribute: "saved-colors-key" })], ColorPicker.prototype, "savedColorsKey", void 0);
806
- __decorate([attr({
807
- mode: "boolean",
808
- attribute: "disable-saved-colors"
809
- })], ColorPicker.prototype, "disableSavedColors", void 0);
810
- __decorate([observable], ColorPicker.prototype, "savedColors", void 0);
811
- __decorate([attr({
812
- attribute: "max-swatches",
813
- mode: "fromView",
814
- converter: nullableNumberConverter
815
- })], ColorPicker.prototype, "maxSwatches", void 0);
816
- __decorate([observable], ColorPicker.prototype, "copyIconName", void 0);
817
- __decorate([observable], ColorPicker.prototype, "_ariaLiveDescription", void 0);
94
+ __decorate([attr], Toggletip.prototype, "headline", void 0);
95
+ __decorate([attr({ mode: "boolean" })], Toggletip.prototype, "alternate", void 0);
96
+ __decorate([attr({ mode: "fromView" })], Toggletip.prototype, "placement", void 0);
97
+ __decorate([attr({ mode: "boolean" })], Toggletip.prototype, "open", void 0);
818
98
  //#endregion
819
- //#region src/lib/color-picker/color-picker.template.ts
820
- function renderTextField(textFieldTag, iconTag) {
821
- const getClasses = (_) => classNames("control");
99
+ //#region src/lib/toggletip/toggletip.template.ts
100
+ var getClasses = (_) => classNames("control");
101
+ var ToggletipTemplate = (context) => {
102
+ const popup = context.tagFor(Popup);
822
103
  return html`
823
- <${textFieldTag}
824
- id="text-field"
825
- class="${getClasses}"
826
- pattern="${ColorPicker.HEX_COLOR_PATTERN.source}"
827
- maxlength="7"
828
- label="${(x) => x.label}"
829
- :value="${(x) => x.value}"
830
- placeholder="${(x) => x.placeholder}"
831
- helper-text="${(x) => x.helperText}"
832
- error-text="${(x) => x.errorValidationMessage}"
833
- success-text="${(x) => x.successText}"
834
- ?disabled="${(x) => x.disabled}"
835
- ?required="${(x) => x.required}"
836
- @input='${(x, c) => x._onTextFieldInput(c.event)}'
837
- @change="${(x) => x.handleChange()}"
838
- @blur="${(x) => {
839
- x.$emit("blur", void 0, { bubbles: false });
840
- }}"
841
- @focus="${(x) => {
842
- x.$emit("focus", void 0, { bubbles: false });
104
+ ${anchorSlotTemplateFactory()}
105
+ <${popup}
106
+ @keydown="${(x, { event }) => {
107
+ if (x.open && handleEscapeKeyAndStopPropogation(event)) return false;
108
+ return true;
843
109
  }}"
844
- ${delegateAria()}
845
- ${ref("_textFieldEl")}
110
+ class="${getClasses}"
111
+ arrow
112
+ :anchor="${(x) => x._anchorEl}"
113
+ :open="${(x) => x.open}"
114
+ ?alternate="${(x) => !x.alternate}"
115
+ placement="${(x) => x.placement}"
116
+ exportparts="vvd-theme-alternate"
846
117
  >
847
- <button
848
- aria-label="${(x) => x.locale.colorPicker.pickerButtonLabel}"
849
- aria-expanded="${(x) => x.open}"
850
- aria-haspopup="dialog"
851
- class="button ${(x) => classNames(x._applyContrastClass(x._buttonColor) ? "contrast" : "", x.disabled ? "disabled" : "")}"
852
- style="--button-color: ${(x) => x._buttonColor};"
853
- ?disabled="${(x) => x.disabled}"
854
- @click="${(x) => x._onButtonClick()}"
855
- slot="action-items"
856
- ${ref("_buttonEl")}>
857
- <${iconTag} name="edit-line"></${iconTag}>
858
- </button>
859
- <slot
860
- slot="${(x) => x._helperTextSlottedContent?.length ? "helper-text" : void 0}"
861
- name="helper-text"
862
- ${slotted("_helperTextSlottedContent")}
863
- ></slot>
864
- <slot
865
- slot='${(x) => x._contextualHelpSlottedContent?.length ? "contextual-help" : void 0}'
866
- name='contextual-help'
867
- ${slotted("_contextualHelpSlottedContent")}
868
- ></slot>
869
- </${textFieldTag}>
870
- `;
871
- }
872
- function renderPopupHeader(buttonTag, iconTag) {
873
- return html`
874
- <div class="header">
875
- <h2 class="header-title" id="color-picker-title">
876
- <slot name="popup-text">${(x) => x.locale.colorPicker.popupLabel}</slot>
877
- </h2>
878
- <${buttonTag} size="condensed"
879
- aria-label="${(x) => x.locale.colorPicker.closeButtonLabel}"
880
- @click="${(x) => x._handleCloseRequest()}">
881
- <${iconTag} slot="icon" name="close-line"></${iconTag}>
882
- </${buttonTag}>
883
- </div>
884
- `;
885
- }
886
- function renderPopupBody(buttonTag, iconTag, tooltipTag) {
887
- return html`
888
- <div class="body">
889
- <${html.partial(vcPickerTag)}
890
- part="hex-picker"
891
- color="${(x) => x.value}"
892
- @color-changed="${(x, c) => x._onPickerColorChanged(c.event)}"
893
- ${ref("_vcHexPickerEl")}
894
- ></${html.partial(vcPickerTag)}>
895
- <div class="hex-input-wrapper">
896
- <${html.partial(vcInputTag)}
897
- part="hex-input"
898
- prefixed
899
- color="${(x) => x.value}"
900
- @color-changed="${(x, c) => x._onPickerColorChanged(c.event)}"
901
- ${ref("_vcHexInputEl")}
902
- >
903
- <input name="hex-code-input" aria-label="${(x) => x.locale.colorPicker.hexInputLabel}"
904
- placeholder="${(x) => x.placeholder}"
905
- @blur="${(x, c) => c.event.stopImmediatePropagation()}"
906
- part="input">
907
- </${html.partial(vcInputTag)}>
908
- <${tooltipTag} placement="top"
909
- text="${(x) => x.locale.colorPicker.copyButtonLabel}"
910
- exportparts="vvd-theme-alternate">
911
- <${buttonTag}
912
- slot="anchor" size="normal"
913
- aria-label="${(x) => x.locale.colorPicker.copyButtonLabel}"
914
- @click="${(x) => x._copyValueToClipboard(x.value)}">
915
- <${iconTag} slot="icon" name="${(x) => x.copyIconName}"></${iconTag}>
916
- </${buttonTag}>
917
- </${tooltipTag}>
918
- </div>
919
- </div>
920
- `;
921
- }
922
- function renderPopupFooter(buttonTag, iconTag, tooltipTag) {
923
- return html`
924
- <div class="footer">
925
- <div class="footer-header">
926
- <span class="footer-title" id="color-picker-footer-title"
927
- ><slot name="swatches-text"
928
- >${(x) => x.locale.colorPicker.swatchesLabel}</slot
929
- ></span
930
- >
931
- ${when((x) => !x.disableSavedColors, renderSwatchesCount())}
932
- </div>
933
- <div
934
- class="palette"
935
- role="grid"
936
- aria-rowcount="${(x) => Math.ceil(x.allSwatches.length / x._getRowLength())}"
937
- aria-colcount="${(x) => x._getRowLength()}"
938
- style="--swatches-per-row: ${(x) => x._getRowLength()};"
939
- aria-labelledby="color-picker-footer-title"
940
- >
941
- ${repeat((x) => x.allSwatches, (x) => x._renderColorSwatch(iconTag, tooltipTag), { positioning: true })}
942
- ${when((x) => !x.disableSavedColors, html`
943
- <${tooltipTag} placement="top"
944
- text="${(x) => x.locale.colorPicker.saveButtonLabel}"
945
- exportparts="vvd-theme-alternate">
946
- <${buttonTag}
947
- slot="anchor"
948
- appearance="outlined"
949
- size="super-condensed"
950
- role="gridcell"
951
- tabindex="${(x) => x.allSwatches.length ? "-1" : "0"}"
952
- aria-label="${(x) => x.locale.colorPicker.saveButtonLabel}"
953
- @click="${(x) => x._saveCurrentColor()}"
954
- @keydown="${(x, c) => x._handleCellKeydown(c.event, x.value, x.allSwatches.length, true)}">
955
- <${iconTag} slot="icon" name="plus-line"></${iconTag}>
956
- </${buttonTag}>
957
- </${tooltipTag}>
958
- `)}
118
+ <div class="content-wrapper">
119
+ ${when((x) => x.headline, html`<h2 class="headline">${(x) => x.headline}</h2>`)}
120
+ <slot></slot>
121
+ <div class="action-items"><slot name="action-items"></slot></div>
959
122
  </div>
960
- </div>
961
- `;
962
- }
963
- function renderSwatchesCount() {
964
- return html`
965
- <span
966
- id="swatches-count"
967
- class="swatches-count"
968
- aria-label="${(x) => x.locale.colorPicker.maxSwatchesMessage(x.allSwatches.length, x.maxSwatches)}"
969
- >${(x) => `${x.allSwatches.length}/${x.maxSwatches}`}</span
970
- >
971
- `;
972
- }
973
- var ColorPickerTemplate = (context) => {
974
- const textFieldTag = context.tagFor(TextField);
975
- const iconTag = context.tagFor(Icon);
976
- const popupTag = context.tagFor(Popup);
977
- const buttonTag = context.tagFor(Button);
978
- const tooltipTag = context.tagFor(Tooltip);
979
- return html`
980
- <div class="base" @keydown="${(x, { event }) => x._onBaseKeydown(event)}">
981
- <span aria-live="assertive" aria-relevant="text" class="visually-hidden">
982
- ${(x) => x._ariaLiveDescription}
983
- </span>
984
- ${renderTextField(textFieldTag, iconTag)}
985
- <${popupTag}
986
- :open="${(x) => x.open}"
987
- :anchor="${(x) => x._buttonEl}"
988
- placement="top"
989
- offset="10"
990
- ${ref("_popupEl")}>
991
- <div class="dialog"
992
- role="dialog"
993
- aria-modal="true"
994
- aria-labelledby="color-picker-title">
995
- ${renderPopupHeader(buttonTag, iconTag)}
996
- ${renderPopupBody(buttonTag, iconTag, tooltipTag)}
997
- ${when((x) => !x.disableSavedColors || x.allSwatches.length > 0, renderPopupFooter(buttonTag, iconTag, tooltipTag))}
998
- </div>
999
- </${popupTag}>
1000
- </div>
123
+ </${popup}>
1001
124
  `;
1002
125
  };
1003
126
  //#endregion
1004
- //#region src/lib/color-picker/definition.ts
1005
- var colorPickerDefinition = defineVividComponent("color-picker", ColorPicker, ColorPickerTemplate, [
1006
- popupDefinition,
1007
- iconDefinition,
1008
- textFieldDefinition,
1009
- buttonDefinition,
1010
- tooltipDefinition,
1011
- feedbackMessageDefinition
1012
- ], { styles: color_picker_default$1 });
127
+ //#region src/lib/toggletip/definition.ts
128
+ /**
129
+ * @internal
130
+ */
131
+ var toggletipDefinition = defineVividComponent("toggletip", Toggletip, ToggletipTemplate, [popupDefinition], { styles: toggletip_default });
1013
132
  /**
1014
- * Registers the color-picker element with the design system.
133
+ * Registers the toggletip element with the design system.
1015
134
  *
1016
135
  * @param prefix - the prefix to use for the component name
1017
136
  */
1018
- var registerColorPicker = createRegisterFunction(colorPickerDefinition);
137
+ var registerToggletip = createRegisterFunction(toggletipDefinition);
1019
138
  //#endregion
1020
- export { registerColorPicker as n, ColorPicker as r, colorPickerDefinition as t };
139
+ export { toggletipDefinition as n, Toggletip as r, registerToggletip as t };