@vonage/vivid 4.24.0 → 4.25.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 (392) hide show
  1. package/custom-elements.json +12314 -4711
  2. package/elevation/index.cjs +1 -1
  3. package/elevation/index.js +1 -1
  4. package/index.cjs +112 -150
  5. package/index.js +37 -35
  6. package/lib/accordion-item/accordion-item.d.ts +6 -0
  7. package/lib/action-group/action-group.d.ts +6 -0
  8. package/lib/alert/alert.d.ts +20 -0
  9. package/lib/audio-player/audio-player.d.ts +6 -0
  10. package/lib/badge/badge.d.ts +9 -1
  11. package/lib/banner/banner.d.ts +25 -0
  12. package/lib/breadcrumb/breadcrumb.d.ts +6 -0
  13. package/lib/breadcrumb-item/breadcrumb-item.d.ts +63 -7
  14. package/lib/button/button.d.ts +732 -7
  15. package/lib/button/locale.d.ts +3 -0
  16. package/lib/calendar-event/calendar-event.d.ts +6 -0
  17. package/lib/card/card.d.ts +394 -2
  18. package/lib/card/card.template.d.ts +2 -1
  19. package/lib/checkbox/checkbox.d.ts +1822 -5
  20. package/lib/combobox/combobox.d.ts +1827 -20
  21. package/lib/data-grid/data-grid-cell.d.ts +339 -1
  22. package/lib/data-grid/locale.d.ts +5 -0
  23. package/lib/date-picker/date-picker.d.ts +1676 -207
  24. package/lib/date-range-picker/date-range-picker.d.ts +840 -107
  25. package/lib/date-time-picker/date-time-picker.d.ts +1678 -209
  26. package/lib/dial-pad/dial-pad.d.ts +8 -0
  27. package/lib/dialog/dialog.d.ts +12 -0
  28. package/lib/divider/divider.d.ts +6 -0
  29. package/lib/fab/fab.d.ts +6 -0
  30. package/lib/file-picker/file-picker.d.ts +1508 -30
  31. package/lib/header/header.d.ts +6 -0
  32. package/lib/icon/icon.d.ts +1 -0
  33. package/lib/icon/icon.template.d.ts +2 -1
  34. package/lib/menu/menu.d.ts +16 -7
  35. package/lib/menu/name.d.ts +1 -0
  36. package/lib/menu-item/menu-item.d.ts +14 -2
  37. package/lib/nav/nav.d.ts +6 -0
  38. package/lib/nav-disclosure/nav-disclosure.d.ts +13 -0
  39. package/lib/nav-item/nav-item.d.ts +405 -3
  40. package/lib/note/note.d.ts +6 -0
  41. package/lib/number-field/number-field.d.ts +1857 -36
  42. package/lib/option/option.d.ts +12 -0
  43. package/lib/progress/progress.d.ts +6 -0
  44. package/lib/progress-ring/progress-ring.d.ts +6 -0
  45. package/lib/radio/radio.d.ts +1137 -4
  46. package/lib/radio-group/radio-group.d.ts +20 -2
  47. package/lib/range-slider/range-slider.d.ts +752 -5
  48. package/lib/rich-text-editor/definition.d.ts +2 -2
  49. package/lib/rich-text-editor/facades/vivid-prose-mirror.facade.d.ts +3 -1
  50. package/lib/rich-text-editor/locale.d.ts +1 -0
  51. package/lib/rich-text-editor/menubar/menubar.d.ts +6 -0
  52. package/lib/rich-text-editor/rich-text-editor.d.ts +352 -2
  53. package/lib/searchable-select/option-tag.d.ts +6 -0
  54. package/lib/searchable-select/searchable-select.d.ts +1857 -36
  55. package/lib/select/select.d.ts +1843 -28
  56. package/lib/selectable-box/selectable-box.d.ts +6 -0
  57. package/lib/slider/slider.d.ts +384 -2
  58. package/lib/split-button/split-button.d.ts +18 -0
  59. package/lib/switch/switch.d.ts +386 -3
  60. package/lib/tab/tab.d.ts +18 -1
  61. package/lib/tab-panel/tab-panel.d.ts +6 -0
  62. package/lib/tag/tag.d.ts +12 -0
  63. package/lib/tag-group/tag-group.d.ts +6 -0
  64. package/lib/text-area/text-area.d.ts +2174 -19
  65. package/lib/text-field/text-field.d.ts +2195 -31
  66. package/lib/time-picker/time-picker.d.ts +839 -106
  67. package/lib/toggletip/toggletip.d.ts +10 -4
  68. package/lib/tooltip/tooltip.d.ts +10 -4
  69. package/lib/tree-item/tree-item.d.ts +12 -0
  70. package/lib/tree-view/tree-view.d.ts +6 -0
  71. package/lib/video-player/video-player.d.ts +6 -0
  72. package/lib/visually-hidden/definition.d.ts +4 -0
  73. package/lib/visually-hidden/visually-hidden.d.ts +3 -0
  74. package/lib/visually-hidden/visually-hidden.template.d.ts +3 -0
  75. package/locales/de-DE.cjs +33 -1
  76. package/locales/de-DE.js +33 -1
  77. package/locales/en-GB.cjs +33 -1
  78. package/locales/en-GB.js +33 -1
  79. package/locales/en-US.cjs +33 -1
  80. package/locales/en-US.js +33 -1
  81. package/locales/ja-JP.cjs +33 -1
  82. package/locales/ja-JP.js +33 -1
  83. package/locales/zh-CN.cjs +33 -1
  84. package/locales/zh-CN.js +33 -1
  85. package/menu/index.cjs +1 -1
  86. package/menu/index.js +1 -1
  87. package/nav/index.cjs +1 -1
  88. package/nav/index.js +1 -1
  89. package/nav-disclosure/index.cjs +1 -1
  90. package/nav-disclosure/index.js +1 -1
  91. package/nav-item/index.cjs +1 -1
  92. package/nav-item/index.js +1 -1
  93. package/note/index.cjs +1 -1
  94. package/note/index.js +1 -1
  95. package/number-field/index.cjs +1 -1
  96. package/number-field/index.js +1 -1
  97. package/option/index.cjs +1 -1
  98. package/option/index.js +1 -1
  99. package/package.json +1 -1
  100. package/pagination/index.cjs +1 -1
  101. package/pagination/index.js +1 -1
  102. package/popup/index.cjs +1 -1
  103. package/popup/index.js +1 -1
  104. package/progress/index.cjs +1 -1
  105. package/progress/index.js +1 -1
  106. package/progress-ring/index.cjs +1 -1
  107. package/progress-ring/index.js +1 -1
  108. package/radio/index.cjs +1 -1
  109. package/radio/index.js +1 -1
  110. package/radio-group/index.cjs +1 -1
  111. package/radio-group/index.js +1 -1
  112. package/range-slider/index.cjs +1 -1
  113. package/range-slider/index.js +1 -1
  114. package/rich-text-editor/index.cjs +1 -1
  115. package/rich-text-editor/index.js +1 -1
  116. package/searchable-select/index.cjs +1 -1
  117. package/searchable-select/index.js +1 -1
  118. package/select/index.cjs +1 -1
  119. package/select/index.js +1 -1
  120. package/selectable-box/index.cjs +1 -1
  121. package/selectable-box/index.js +1 -1
  122. package/shared/affix.cjs +13 -7
  123. package/shared/affix.js +13 -8
  124. package/shared/aria/delegates-aria.d.ts +6 -0
  125. package/shared/aria/host-semantics.d.ts +6 -0
  126. package/shared/breadcrumb-item.cjs +2 -5
  127. package/shared/breadcrumb-item.js +2 -5
  128. package/shared/button.cjs +13 -11
  129. package/shared/button.js +13 -11
  130. package/shared/calendar-picker.template.cjs +3 -3
  131. package/shared/calendar-picker.template.js +1 -1
  132. package/shared/char-count.cjs +92 -0
  133. package/shared/char-count.js +90 -0
  134. package/shared/definition.js +1 -1
  135. package/shared/definition10.js +1 -1
  136. package/shared/definition11.cjs +27 -44
  137. package/shared/definition11.js +28 -45
  138. package/shared/definition12.js +1 -1
  139. package/shared/definition13.js +1 -1
  140. package/shared/definition14.cjs +53 -22
  141. package/shared/definition14.js +54 -23
  142. package/shared/definition15.cjs +31 -36
  143. package/shared/definition15.js +30 -36
  144. package/shared/definition16.cjs +43 -63
  145. package/shared/definition16.js +42 -63
  146. package/shared/definition17.cjs +8 -4
  147. package/shared/definition17.js +8 -4
  148. package/shared/definition18.cjs +10 -14
  149. package/shared/definition18.js +9 -14
  150. package/shared/definition19.cjs +85 -100
  151. package/shared/definition19.js +75 -91
  152. package/shared/definition2.js +1 -1
  153. package/shared/definition20.cjs +15 -20
  154. package/shared/definition20.js +14 -20
  155. package/shared/definition21.cjs +22 -3
  156. package/shared/definition21.js +23 -4
  157. package/shared/definition22.cjs +4 -4
  158. package/shared/definition22.js +5 -5
  159. package/shared/definition23.cjs +5 -38
  160. package/shared/definition23.js +5 -37
  161. package/shared/definition24.cjs +2 -7
  162. package/shared/definition24.js +3 -8
  163. package/shared/definition25.js +1 -1
  164. package/shared/definition26.cjs +157 -171
  165. package/shared/definition26.js +156 -171
  166. package/shared/definition27.cjs +1 -1
  167. package/shared/definition27.js +2 -2
  168. package/shared/definition28.cjs +32 -17
  169. package/shared/definition28.js +33 -18
  170. package/shared/definition29.js +1 -1
  171. package/shared/definition3.js +1 -1
  172. package/shared/definition30.cjs +96 -482
  173. package/shared/definition30.js +99 -482
  174. package/shared/definition31.cjs +334 -57
  175. package/shared/definition31.js +333 -56
  176. package/shared/definition32.cjs +104 -19
  177. package/shared/definition32.js +105 -20
  178. package/shared/definition33.cjs +67 -15
  179. package/shared/definition33.js +66 -14
  180. package/shared/definition34.cjs +15 -50
  181. package/shared/definition34.js +14 -49
  182. package/shared/definition35.cjs +28 -397
  183. package/shared/definition35.js +27 -397
  184. package/shared/definition36.cjs +404 -54
  185. package/shared/definition36.js +404 -55
  186. package/shared/definition37.cjs +57 -234
  187. package/shared/definition37.js +57 -233
  188. package/shared/definition38.cjs +221 -66
  189. package/shared/definition38.js +220 -65
  190. package/shared/definition39.cjs +52 -44
  191. package/shared/definition39.js +51 -43
  192. package/shared/definition4.cjs +31 -24
  193. package/shared/definition4.js +33 -26
  194. package/shared/definition40.cjs +56 -266
  195. package/shared/definition40.js +55 -265
  196. package/shared/definition41.cjs +285 -142
  197. package/shared/definition41.js +285 -142
  198. package/shared/definition42.cjs +156 -564
  199. package/shared/definition42.js +156 -565
  200. package/shared/definition43.cjs +554 -14378
  201. package/shared/definition43.js +553 -14377
  202. package/shared/definition44.cjs +14418 -1155
  203. package/shared/definition44.js +14417 -1156
  204. package/shared/definition45.cjs +1049 -677
  205. package/shared/definition45.js +1050 -678
  206. package/shared/definition46.cjs +848 -113
  207. package/shared/definition46.js +847 -112
  208. package/shared/definition47.cjs +125 -90
  209. package/shared/definition47.js +124 -89
  210. package/shared/definition48.cjs +88 -455
  211. package/shared/definition48.js +87 -454
  212. package/shared/definition49.cjs +466 -109
  213. package/shared/definition49.js +466 -109
  214. package/shared/definition5.cjs +8 -7
  215. package/shared/definition5.js +6 -5
  216. package/shared/definition50.cjs +106 -106
  217. package/shared/definition50.js +105 -105
  218. package/shared/definition51.cjs +136 -15
  219. package/shared/definition51.js +135 -14
  220. package/shared/definition52.cjs +16 -115
  221. package/shared/definition52.js +15 -114
  222. package/shared/definition53.cjs +78 -412
  223. package/shared/definition53.js +77 -410
  224. package/shared/definition54.cjs +445 -23
  225. package/shared/definition54.js +443 -22
  226. package/shared/definition55.cjs +22 -136
  227. package/shared/definition55.js +21 -135
  228. package/shared/definition56.cjs +95 -291
  229. package/shared/definition56.js +95 -292
  230. package/shared/definition57.cjs +192 -480
  231. package/shared/definition57.js +190 -479
  232. package/shared/definition58.cjs +411 -24
  233. package/shared/definition58.js +410 -24
  234. package/shared/definition59.cjs +27 -144
  235. package/shared/definition59.js +27 -143
  236. package/shared/definition6.js +1 -1
  237. package/shared/definition60.cjs +83 -54
  238. package/shared/definition60.js +82 -53
  239. package/shared/definition61.cjs +78 -166
  240. package/shared/definition61.js +77 -164
  241. package/shared/definition62.cjs +143 -232
  242. package/shared/definition62.js +141 -231
  243. package/shared/definition63.cjs +234 -69417
  244. package/shared/definition63.js +233 -69416
  245. package/shared/definition64.cjs +69454 -28
  246. package/shared/definition64.js +69453 -27
  247. package/shared/definition65.cjs +28 -2168
  248. package/shared/definition65.js +27 -2166
  249. package/shared/definition66.cjs +27 -0
  250. package/shared/definition66.js +23 -0
  251. package/shared/definition67.cjs +2195 -0
  252. package/shared/definition67.js +2190 -0
  253. package/shared/definition7.cjs +11 -2
  254. package/shared/definition7.js +12 -3
  255. package/shared/definition8.cjs +24 -11
  256. package/shared/definition8.js +26 -13
  257. package/shared/definition9.cjs +1 -2
  258. package/shared/definition9.js +2 -3
  259. package/shared/delegates-aria.js +1 -1
  260. package/shared/deprecation/replaced-props.d.ts +20 -0
  261. package/shared/divider.cjs +41 -0
  262. package/shared/divider.js +38 -0
  263. package/shared/feedback/feedback-message.d.ts +345 -0
  264. package/shared/feedback/locale.d.ts +4 -0
  265. package/{lib/text-anchor/text-anchor.d.ts → shared/feedback/mixins.d.ts} +62 -39
  266. package/shared/form-associated.cjs +124 -100
  267. package/shared/form-associated.js +125 -101
  268. package/shared/form-element.cjs +84 -0
  269. package/shared/form-element.js +82 -0
  270. package/shared/foundation/button/button.d.ts +378 -2
  271. package/shared/foundation/form-associated/form-associated.d.ts +753 -49
  272. package/shared/foundation/listbox/listbox.d.ts +1 -1
  273. package/shared/foundation/vivid-element/vivid-element.d.ts +14 -0
  274. package/shared/host-semantics.js +1 -1
  275. package/shared/key-codes.js +1 -1
  276. package/shared/linkable.cjs +70 -0
  277. package/shared/linkable.js +68 -0
  278. package/shared/localization/Locale.d.ts +14 -0
  279. package/shared/mixins.cjs +306 -0
  280. package/shared/mixins.js +300 -0
  281. package/shared/patterns/affix.d.ts +16 -1
  282. package/shared/patterns/anchored.d.ts +20 -8
  283. package/shared/patterns/char-count/char-count.d.ts +351 -0
  284. package/shared/patterns/char-count/index.d.ts +1 -0
  285. package/shared/patterns/char-count/locale.d.ts +4 -0
  286. package/shared/patterns/form-elements/form-element.d.ts +744 -0
  287. package/shared/patterns/form-elements/index.d.ts +3 -1
  288. package/shared/patterns/form-elements/with-error-text.d.ts +1122 -0
  289. package/shared/patterns/form-elements/with-success-text.d.ts +341 -0
  290. package/shared/patterns/index.d.ts +2 -0
  291. package/shared/patterns/linkable.d.ts +394 -0
  292. package/shared/patterns/localized.d.ts +6 -0
  293. package/shared/patterns/trapped-focus.d.ts +6 -0
  294. package/shared/picker-field/mixins/calendar-picker.d.ts +420 -52
  295. package/shared/picker-field/mixins/calendar-picker.template.d.ts +420 -52
  296. package/shared/picker-field/mixins/inline-time-picker/inline-time-picker.d.ts +6 -0
  297. package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +843 -107
  298. package/shared/picker-field/mixins/single-date-picker.d.ts +1259 -155
  299. package/shared/picker-field/mixins/single-value-picker.d.ts +417 -49
  300. package/shared/picker-field/mixins/time-selection-picker.d.ts +842 -106
  301. package/shared/picker-field/mixins/time-selection-picker.template.d.ts +839 -103
  302. package/shared/picker-field/picker-field.d.ts +1491 -15
  303. package/shared/picker-field.template.cjs +13 -22
  304. package/shared/picker-field.template.js +14 -23
  305. package/shared/repeat.js +1 -1
  306. package/shared/slider.template.cjs +1 -1
  307. package/shared/slider.template.js +1 -1
  308. package/shared/time-selection-picker.template.cjs +10 -15
  309. package/shared/time-selection-picker.template.js +10 -16
  310. package/shared/vivid-element.cjs +53 -4
  311. package/shared/vivid-element.js +53 -3
  312. package/shared/with-error-text.cjs +56 -0
  313. package/shared/with-error-text.js +54 -0
  314. package/shared/with-success-text.cjs +23 -0
  315. package/shared/with-success-text.js +21 -0
  316. package/side-drawer/index.cjs +1 -1
  317. package/side-drawer/index.js +1 -1
  318. package/slider/index.cjs +1 -1
  319. package/slider/index.js +1 -1
  320. package/split-button/index.cjs +1 -1
  321. package/split-button/index.js +1 -1
  322. package/styles/core/all.css +1 -1
  323. package/styles/core/theme.css +1 -1
  324. package/styles/core/typography.css +1 -1
  325. package/styles/tokens/theme-dark.css +4 -4
  326. package/styles/tokens/theme-light.css +4 -4
  327. package/styles/tokens/vivid-2-compat.css +1 -1
  328. package/switch/index.cjs +1 -1
  329. package/switch/index.js +1 -1
  330. package/tab/index.cjs +1 -1
  331. package/tab/index.js +1 -1
  332. package/tab-panel/index.cjs +1 -1
  333. package/tab-panel/index.js +1 -1
  334. package/tabs/index.cjs +1 -1
  335. package/tabs/index.js +1 -1
  336. package/tag/index.cjs +1 -1
  337. package/tag/index.js +1 -1
  338. package/tag-group/index.cjs +1 -1
  339. package/tag-group/index.js +1 -1
  340. package/text-area/index.cjs +1 -1
  341. package/text-area/index.js +1 -1
  342. package/text-field/index.cjs +1 -1
  343. package/text-field/index.js +1 -1
  344. package/time-picker/index.cjs +1 -1
  345. package/time-picker/index.js +1 -1
  346. package/toggletip/index.cjs +1 -1
  347. package/toggletip/index.js +1 -1
  348. package/tooltip/index.cjs +1 -1
  349. package/tooltip/index.js +1 -1
  350. package/tree-item/index.cjs +1 -1
  351. package/tree-item/index.js +1 -1
  352. package/tree-view/index.cjs +1 -1
  353. package/tree-view/index.js +1 -1
  354. package/video-player/index.cjs +1 -1
  355. package/video-player/index.js +1 -1
  356. package/visually-hidden/index.cjs +5 -0
  357. package/visually-hidden/index.js +3 -0
  358. package/vivid.api.json +744 -1490
  359. package/lib/checkbox/checkbox.form-associated.d.ts +0 -11
  360. package/lib/file-picker/file-picker.form-associated.d.ts +0 -11
  361. package/lib/number-field/number-field.form-associated.d.ts +0 -11
  362. package/lib/radio/radio.form-associated.d.ts +0 -13
  363. package/lib/range-slider/range-slider.form-associated.d.ts +0 -11
  364. package/lib/searchable-select/searchable-select.form-associated.d.ts +0 -11
  365. package/lib/select/select.form-associated.d.ts +0 -11
  366. package/lib/slider/slider.form-associated.d.ts +0 -11
  367. package/lib/switch/switch.form-associated.d.ts +0 -11
  368. package/lib/text-anchor/definition.d.ts +0 -2
  369. package/lib/text-anchor/text-anchor.template.d.ts +0 -3
  370. package/lib/text-area/text-area.form-associated.d.ts +0 -11
  371. package/lib/text-field/text-field.form-associated.d.ts +0 -11
  372. package/shared/anchor.cjs +0 -49
  373. package/shared/anchor.js +0 -47
  374. package/shared/apply-mixins.cjs +0 -23
  375. package/shared/apply-mixins.js +0 -21
  376. package/shared/applyMixinsWithObservables.cjs +0 -15
  377. package/shared/applyMixinsWithObservables.js +0 -13
  378. package/shared/direction.cjs +0 -17
  379. package/shared/direction.js +0 -15
  380. package/shared/form-elements.cjs +0 -209
  381. package/shared/form-elements.js +0 -202
  382. package/shared/foundation/anchor/anchor.d.ts +0 -11
  383. package/shared/foundation/utilities/apply-mixins.d.ts +0 -1
  384. package/shared/patterns/form-elements/form-elements.d.ts +0 -58
  385. package/shared/picker-field/picker-field.form-associated.d.ts +0 -11
  386. package/shared/text-anchor.cjs +0 -38
  387. package/shared/text-anchor.js +0 -36
  388. package/shared/text-anchor.template.cjs +0 -35
  389. package/shared/text-anchor.template.js +0 -33
  390. package/shared/utils/applyMixinsWithObservables.d.ts +0 -1
  391. package/text-anchor/index.cjs +0 -17
  392. package/text-anchor/index.js +0 -15
@@ -1,93 +1,248 @@
1
1
  'use strict';
2
2
 
3
+ const definition = require('./definition11.cjs');
3
4
  const vividElement = require('./vivid-element.cjs');
4
- const baseProgress = require('./base-progress.cjs');
5
- const delegatesAria = require('./delegates-aria.cjs');
5
+ const enums = require('./enums.cjs');
6
+ const slotted = require('./slotted.cjs');
6
7
  const classNames = require('./class-names.cjs');
8
+ const ref = require('./ref.cjs');
9
+ const children = require('./children.cjs');
10
+ const repeat = require('./repeat.cjs');
7
11
  const when = require('./when.cjs');
8
12
 
9
- const styles = ":host{--_vvd-progress-ring-accent-firm-wrapper: var( --vvd-progress-ring-accent-firm );--_vvd-progress-ring-cta-firm-wrapper: var( --vvd-progress-ring-cta-firm );--_vvd-progress-ring-alert-firm-wrapper: var( --vvd-progress-ring-alert-firm );--_vvd-progress-ring-success-firm-wrapper: var( --vvd-progress-ring-success-firm )}.base{--vvd-progress-ring-accent-firm: var( --_vvd-progress-ring-accent-firm-wrapper, var(--vvd-progress-ring-accent-primary) );--vvd-progress-ring-cta-firm: var( --_vvd-progress-ring-cta-firm-wrapper, var(--vvd-progress-ring-cta-primary) );--vvd-progress-ring-alert-firm: var( --_vvd-progress-ring-alert-firm-wrapper, var(--vvd-progress-ring-alert-primary) );--vvd-progress-ring-success-firm: var( --_vvd-progress-ring-success-firm-wrapper, var(--vvd-progress-ring-success-primary) )}.base.connotation-cta{--_connotation-color-firm: var(--vvd-progress-ring-cta-firm, var(--vvd-color-cta-600))}.base.connotation-alert{--_connotation-color-firm: var(--vvd-progress-ring-alert-firm, var(--vvd-color-alert-600))}.base.connotation-success{--_connotation-color-firm: var(--vvd-progress-ring-success-firm, var(--vvd-color-success-600))}.base:not(.connotation-cta,.connotation-alert,.connotation-success){--_connotation-color-firm: var(--vvd-progress-ring-accent-firm, var(--vvd-color-canvas-text))}.base{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base:where(.disabled,:disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base.size--6{--_size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2)) - (1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))) }.base.size--5{--_size: calc(1px*(20 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size--4{--_size: calc(1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size--3{--_size: calc(1px*(28 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size--2{--_size: calc(1px*(32 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size--1{--_size: calc(1px*(36 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size-1{--_size: calc(1px*(44 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size-2{--_size: calc(1px*(48 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size-3{--_size: calc(1px*(52 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size-4{--_size: calc(1px*(56 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size-5{--_size: calc(1px*(60 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base:not(.size--6,.size--5,.size--4,.size--3,.size--2,.size--1,.size-1,.size-2,.size-3,.size-4,.size-5){--_size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base{align-items:center;block-size:var(--_size);color:var(--_appearance-color-text);inline-size:var(--_size);outline:none}.progress{width:100%;height:100%}.background{fill:none;stroke:transparent;stroke-width:1px}.determinate{fill:none;stroke:currentColor;stroke-linecap:round;stroke-width:1px;transform:rotate(-90deg);transform-origin:50% 50%;transition:all .2s ease-in-out}.indeterminate-indicator-1{animation:spin-infinite 2s linear infinite;fill:none;stroke:currentColor;stroke-linecap:round;stroke-width:1px;transform:rotate(-90deg);transform-origin:50% 50%;transition:all .2s ease-in-out}.base.paused .indeterminate-indicator-1{animation-play-state:paused}@keyframes spin-infinite{0%{stroke-dasharray:.01px 43.97px;transform:rotate(0)}50%{stroke-dasharray:21.99px 21.99px;transform:rotate(450deg)}to{stroke-dasharray:.01px 43.97px;transform:rotate(1080deg)}}";
13
+ const styles = ".control{display:inline-flex;justify-content:space-between}.control:not(.shape-pill){border-radius:4px}.control.shape-pill{border-radius:16px}.buttons-wrapper{display:flex;column-gap:4px}.vwc-pagination-button[size=super-condensed]{--base-size: calc(1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.vwc-pagination-button[size=condensed]{--base-size: calc(1px*(32 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.vwc-pagination-button[size=normal]{--base-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.vwc-pagination-button::part(button){padding-inline:0}.dots{align-self:center;text-align:center}.dots:not(.size-super-condensed){font:var(--vvd-typography-base-bold)}.dots.size-super-condensed{font:var(--vvd-typography-base-condensed-bold);inline-size:calc(1px*(24 + 4*clamp(-1,var(--vvd-size-density, 0),2)))}.dots.size-condensed{inline-size:calc(1px*(32 + 4*clamp(-1,var(--vvd-size-density, 0),2)))}.dots.size-normal{inline-size:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)))}";
10
14
 
11
15
  var __defProp = Object.defineProperty;
16
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
17
  var __decorateClass = (decorators, target, key, kind) => {
13
- var result = void 0 ;
18
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
14
19
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
15
20
  if (decorator = decorators[i])
16
- result = (decorator(target, key, result) ) || result;
17
- if (result) __defProp(target, key, result);
21
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
22
+ if (kind && result) __defProp(target, key, result);
18
23
  return result;
19
24
  };
20
- class ProgressRing extends delegatesAria.DelegatesAria(baseProgress.BaseProgress) {
25
+ const MAX_DIGITS_AND_PLACEHOLDERS = 7;
26
+ const totalConverter = {
27
+ fromView: (value) => parseInt(value, 10),
28
+ toView: (value) => value.toString()
29
+ };
30
+ class Pagination extends vividElement.VividElement {
31
+ constructor() {
32
+ super();
33
+ this.navIcons = false;
34
+ this.total = 0;
35
+ this.selectedIndex = 0;
36
+ this.addEventListener("tabpressed", (e) => {
37
+ const { value: currentLabel, shiftKey } = e.detail;
38
+ const index = this.paginationButtons.findIndex(
39
+ (button) => Number(button.label) === currentLabel
40
+ );
41
+ const focusDirection = shiftKey ? -1 : 1;
42
+ const newIndex = index + focusDirection;
43
+ if (newIndex < 0) {
44
+ return this.prevButton.focus();
45
+ }
46
+ if (newIndex > this.paginationButtons.length - 1) {
47
+ return this.nextButton.focus();
48
+ }
49
+ this.paginationButtons && this.paginationButtons[index + focusDirection].focus();
50
+ });
51
+ }
52
+ get pagesList() {
53
+ return new Array(
54
+ this.total < MAX_DIGITS_AND_PLACEHOLDERS ? this.total : MAX_DIGITS_AND_PLACEHOLDERS
55
+ ).fill(0).map((_, i, arr) => {
56
+ if (i === 0) return 1;
57
+ if (i === arr.length - 1) return this.total;
58
+ if (this.selectedIndex !== void 0 && this.total > MAX_DIGITS_AND_PLACEHOLDERS) {
59
+ if (this.selectedIndex < 4) {
60
+ if (i === MAX_DIGITS_AND_PLACEHOLDERS - 2) return "...";
61
+ }
62
+ if (this.selectedIndex >= 4 && this.selectedIndex <= this.total - 5) {
63
+ if (i > 1 && i < MAX_DIGITS_AND_PLACEHOLDERS - 2)
64
+ return this.selectedIndex + (i - 2);
65
+ if (i === 1 || i === MAX_DIGITS_AND_PLACEHOLDERS - 2) return "...";
66
+ }
67
+ if (this.selectedIndex > this.total - 5) {
68
+ if (i > 1) return this.total - (6 - i);
69
+ if (i === 1) return "...";
70
+ }
71
+ }
72
+ return i + 1;
73
+ });
74
+ }
75
+ totalChanged(_, newValue) {
76
+ if (newValue < 0) {
77
+ this.total = 0;
78
+ return;
79
+ }
80
+ this.#constrainSelectedIndex();
81
+ }
82
+ selectedIndexChanged(oldValue, newValue) {
83
+ if (oldValue === void 0) return;
84
+ this.$emit("pagination-change", {
85
+ selectedIndex: newValue,
86
+ total: this.total,
87
+ oldIndex: oldValue
88
+ });
89
+ this.#constrainSelectedIndex();
90
+ }
91
+ paginationButtonsChanged(_, newValue) {
92
+ newValue.forEach((button) => {
93
+ button.shadowRoot.querySelector("button").setAttribute("part", "button");
94
+ });
95
+ }
96
+ get #constrainedSelectedIndex() {
97
+ return Math.max(0, Math.min(this.selectedIndex ?? 0, this.total - 1));
98
+ }
99
+ #constrainSelectedIndex() {
100
+ if (this.selectedIndex !== this.#constrainedSelectedIndex) {
101
+ window.queueMicrotask(() => {
102
+ if (this.selectedIndex !== this.#constrainedSelectedIndex) {
103
+ this.selectedIndex = this.#constrainedSelectedIndex;
104
+ }
105
+ });
106
+ }
107
+ }
21
108
  }
22
109
  __decorateClass([
23
110
  vividElement.attr
24
- ], ProgressRing.prototype, "connotation");
111
+ ], Pagination.prototype, "size", 2);
25
112
  __decorateClass([
26
113
  vividElement.attr
27
- ], ProgressRing.prototype, "size");
114
+ ], Pagination.prototype, "shape", 2);
115
+ __decorateClass([
116
+ vividElement.observable
117
+ ], Pagination.prototype, "paginationButtons", 2);
118
+ __decorateClass([
119
+ vividElement.observable
120
+ ], Pagination.prototype, "prevButton", 2);
121
+ __decorateClass([
122
+ vividElement.observable
123
+ ], Pagination.prototype, "nextButton", 2);
124
+ __decorateClass([
125
+ vividElement.attr({ attribute: "nav-icons", mode: "boolean" })
126
+ ], Pagination.prototype, "navIcons", 2);
127
+ __decorateClass([
128
+ vividElement.volatile
129
+ ], Pagination.prototype, "pagesList", 1);
130
+ __decorateClass([
131
+ vividElement.attr({ mode: "reflect", converter: totalConverter })
132
+ ], Pagination.prototype, "total", 2);
133
+ __decorateClass([
134
+ vividElement.attr({
135
+ mode: "reflect",
136
+ converter: totalConverter,
137
+ attribute: "selected-index"
138
+ })
139
+ ], Pagination.prototype, "selectedIndex", 2);
28
140
 
29
- const getClasses = ({ connotation, size, paused }) => classNames.classNames(
30
- "base",
31
- ["disabled", !!paused],
32
- [`connotation-${connotation}`, !!connotation],
33
- [`size-${size}`, !!size]
34
- );
35
- const progressSegments = 44;
36
- const ProgressRingTemplate = vividElement.html`<template>
37
- <div
38
- class="${(x) => x.paused ? "paused" : ""} ${getClasses}"
39
- ${delegatesAria.delegateAria({
40
- role: "progressbar",
41
- ariaValueNow: (x) => x.value,
42
- ariaValueMin: (x) => x.min,
43
- ariaValueMax: (x) => x.max
44
- })}
45
- >
46
- ${when.when(
47
- (x) => typeof x.value === "number",
48
- vividElement.html`
49
- <svg class="progress" viewBox="0 0 16 16">
50
- <circle class="background" cx="8px" cy="8px" r="7px"></circle>
51
- <circle
52
- class="determinate"
53
- style="stroke-dasharray: ${(x) => progressSegments * x.percentComplete / 100}px ${progressSegments}px"
54
- cx="8px"
55
- cy="8px"
56
- r="7px"
57
- ></circle>
58
- </svg>
59
- `
60
- )}
61
- ${when.when(
62
- (x) => typeof x.value !== "number",
141
+ const ALLOWED_SIZES = [
142
+ enums.Size.SuperCondensed,
143
+ enums.Size.Condensed,
144
+ enums.Size.Normal
145
+ ];
146
+ const ALLOWED_SHAPES = [enums.Shape.Rounded, enums.Shape.Pill];
147
+ const handleSelection = (value, { parent: x }) => {
148
+ return x.selectedIndex = Number(value) - 1;
149
+ };
150
+ const handleKeyDown = (value, { event, parent }) => {
151
+ if (event.key === " " || event.key === "Enter") {
152
+ handleSelection(value, { parent });
153
+ }
154
+ if (event.key === "Tab") {
155
+ event.target.dispatchEvent(
156
+ new CustomEvent("tabpressed", {
157
+ detail: { value, shiftKey: event.shiftKey },
158
+ bubbles: true,
159
+ composed: true
160
+ })
161
+ );
162
+ }
163
+ };
164
+ const getClasses = (_) => classNames.classNames("control");
165
+ function getButtonAppearance(value, { parent }) {
166
+ return parent.selectedIndex === Number(value) - 1 ? "filled" : "ghost";
167
+ }
168
+ const paginationButtonRenderer = (buttonTag) => vividElement.html` ${when.when(
169
+ (value) => value !== "...",
63
170
  vividElement.html`
64
- <svg class="progress" viewBox="0 0 16 16">
65
- <circle class="background" cx="8px" cy="8px" r="7px"></circle>
66
- <circle
67
- class="indeterminate-indicator-1"
68
- cx="8px"
69
- cy="8px"
70
- r="7px"
71
- ></circle>
72
- </svg>
73
- `
171
+ <${buttonTag} class="vwc-pagination-button"
172
+ label="${(value) => value}"
173
+ appearance="${getButtonAppearance}"
174
+ size="${(_, { parent: x }) => getPaginationSize(x)}"
175
+ shape="${(_, { parent: x }) => getPaginationShape(x)}"
176
+ style="inline-size: ${(value) => getPaginationButtonWidth(value)};"
177
+ tabindex="0"
178
+ aria-current="${(value, { parent }) => parent.selectedIndex === Number(value) - 1}"
179
+ @click="${handleSelection}"
180
+ @keydown="${handleKeyDown}">
181
+ </${buttonTag}>
182
+ `
74
183
  )}
75
- </div>
76
- </template>`;
184
+ ${when.when(
185
+ (value) => value === "...",
186
+ vividElement.html` <div class="dots size-${(_, { parent: x }) => getPaginationSize(x)}">
187
+ ...
188
+ </div>`
189
+ )}`;
190
+ const getPaginationSize = (x) => {
191
+ if (!x.size || !ALLOWED_SIZES.includes(x.size)) {
192
+ return enums.Size.SuperCondensed;
193
+ }
194
+ return x.size;
195
+ };
196
+ const getPaginationShape = (x) => {
197
+ if (!x.shape || !ALLOWED_SHAPES.includes(x.shape)) {
198
+ return enums.Shape.Rounded;
199
+ }
200
+ return x.shape;
201
+ };
202
+ const getPaginationButtonWidth = (value) => {
203
+ return `calc(var(--base-size) + ${String(value).length - 1}ch)`;
204
+ };
205
+ const PaginationTemplate = (context) => {
206
+ const buttonTag = context.tagFor(definition.Button);
207
+ const paginationButtonTemplate = paginationButtonRenderer(buttonTag);
208
+ return vividElement.html`
209
+ <div class="${getClasses}">
210
+ <${buttonTag} class="prev-button" ${ref.ref("prevButton")}
211
+ label="${(x) => !x.navIcons ? "Previous" : null}"
212
+ icon="${(x) => x.navIcons ? "chevron-left-line" : null}"
213
+ size="${getPaginationSize}"
214
+ shape="${getPaginationShape}"
215
+ ?disabled="${(x) => x.total === 0 || x.selectedIndex === 0}"
216
+ @click="${(x) => x.selectedIndex !== void 0 && x.selectedIndex--}"
217
+ ></${buttonTag}>
218
+ <div id="buttons-wrapper" class="buttons-wrapper" ${children.children({
219
+ property: "paginationButtons",
220
+ filter: slotted.elements(buttonTag)
221
+ })}>
222
+ ${repeat.repeat((x) => x.pagesList, paginationButtonTemplate, { positioning: true })}
223
+ </div>
224
+ <${buttonTag} class="next-button" ${ref.ref("nextButton")}
225
+ label="${(x) => !x.navIcons ? "Next" : null}"
226
+ icon="${(x) => x.navIcons ? "chevron-right-line" : null}"
227
+ size="${getPaginationSize}"
228
+ shape="${getPaginationShape}"
229
+ ?disabled="${(x) => x.total === 0 || x.selectedIndex === x.total - 1}"
230
+ @click="${(x) => x.selectedIndex !== void 0 && x.selectedIndex++}"
231
+ ></${buttonTag}>
232
+ </div>`;
233
+ };
77
234
 
78
- const progressRingDefinition = vividElement.defineVividComponent(
79
- "progress-ring",
80
- ProgressRing,
81
- ProgressRingTemplate,
82
- [],
235
+ const paginationDefinition = vividElement.defineVividComponent(
236
+ "pagination",
237
+ Pagination,
238
+ PaginationTemplate,
239
+ [definition.buttonDefinition],
83
240
  {
84
241
  styles
85
242
  }
86
243
  );
87
- const registerProgressRing = vividElement.createRegisterFunction(
88
- progressRingDefinition
89
- );
244
+ const registerPagination = vividElement.createRegisterFunction(paginationDefinition);
90
245
 
91
- exports.ProgressRing = ProgressRing;
92
- exports.progressRingDefinition = progressRingDefinition;
93
- exports.registerProgressRing = registerProgressRing;
246
+ exports.Pagination = Pagination;
247
+ exports.paginationDefinition = paginationDefinition;
248
+ exports.registerPagination = registerPagination;
@@ -1,89 +1,244 @@
1
- import { a as attr, h as html, g as createRegisterFunction, i as defineVividComponent } from './vivid-element.js';
2
- import { B as BaseProgress } from './base-progress.js';
3
- import { D as DelegatesAria, d as delegateAria } from './delegates-aria.js';
1
+ import { B as Button, b as buttonDefinition } from './definition11.js';
2
+ import { V as VividElement, a as attr, o as observable, v as volatile, h as html, d as createRegisterFunction, f as defineVividComponent } from './vivid-element.js';
3
+ import { b as Size, S as Shape } from './enums.js';
4
+ import { e as elements } from './slotted.js';
4
5
  import { c as classNames } from './class-names.js';
6
+ import { r as ref } from './ref.js';
7
+ import { c as children } from './children.js';
8
+ import { r as repeat } from './repeat.js';
5
9
  import { w as when } from './when.js';
6
10
 
7
- const styles = ":host{--_vvd-progress-ring-accent-firm-wrapper: var( --vvd-progress-ring-accent-firm );--_vvd-progress-ring-cta-firm-wrapper: var( --vvd-progress-ring-cta-firm );--_vvd-progress-ring-alert-firm-wrapper: var( --vvd-progress-ring-alert-firm );--_vvd-progress-ring-success-firm-wrapper: var( --vvd-progress-ring-success-firm )}.base{--vvd-progress-ring-accent-firm: var( --_vvd-progress-ring-accent-firm-wrapper, var(--vvd-progress-ring-accent-primary) );--vvd-progress-ring-cta-firm: var( --_vvd-progress-ring-cta-firm-wrapper, var(--vvd-progress-ring-cta-primary) );--vvd-progress-ring-alert-firm: var( --_vvd-progress-ring-alert-firm-wrapper, var(--vvd-progress-ring-alert-primary) );--vvd-progress-ring-success-firm: var( --_vvd-progress-ring-success-firm-wrapper, var(--vvd-progress-ring-success-primary) )}.base.connotation-cta{--_connotation-color-firm: var(--vvd-progress-ring-cta-firm, var(--vvd-color-cta-600))}.base.connotation-alert{--_connotation-color-firm: var(--vvd-progress-ring-alert-firm, var(--vvd-color-alert-600))}.base.connotation-success{--_connotation-color-firm: var(--vvd-progress-ring-success-firm, var(--vvd-color-success-600))}.base:not(.connotation-cta,.connotation-alert,.connotation-success){--_connotation-color-firm: var(--vvd-progress-ring-accent-firm, var(--vvd-color-canvas-text))}.base{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base:where(.disabled,:disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base.size--6{--_size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2)) - (1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))) }.base.size--5{--_size: calc(1px*(20 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size--4{--_size: calc(1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size--3{--_size: calc(1px*(28 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size--2{--_size: calc(1px*(32 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size--1{--_size: calc(1px*(36 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size-1{--_size: calc(1px*(44 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size-2{--_size: calc(1px*(48 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size-3{--_size: calc(1px*(52 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size-4{--_size: calc(1px*(56 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base.size-5{--_size: calc(1px*(60 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base:not(.size--6,.size--5,.size--4,.size--3,.size--2,.size--1,.size-1,.size-2,.size-3,.size-4,.size-5){--_size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.base{align-items:center;block-size:var(--_size);color:var(--_appearance-color-text);inline-size:var(--_size);outline:none}.progress{width:100%;height:100%}.background{fill:none;stroke:transparent;stroke-width:1px}.determinate{fill:none;stroke:currentColor;stroke-linecap:round;stroke-width:1px;transform:rotate(-90deg);transform-origin:50% 50%;transition:all .2s ease-in-out}.indeterminate-indicator-1{animation:spin-infinite 2s linear infinite;fill:none;stroke:currentColor;stroke-linecap:round;stroke-width:1px;transform:rotate(-90deg);transform-origin:50% 50%;transition:all .2s ease-in-out}.base.paused .indeterminate-indicator-1{animation-play-state:paused}@keyframes spin-infinite{0%{stroke-dasharray:.01px 43.97px;transform:rotate(0)}50%{stroke-dasharray:21.99px 21.99px;transform:rotate(450deg)}to{stroke-dasharray:.01px 43.97px;transform:rotate(1080deg)}}";
11
+ const styles = ".control{display:inline-flex;justify-content:space-between}.control:not(.shape-pill){border-radius:4px}.control.shape-pill{border-radius:16px}.buttons-wrapper{display:flex;column-gap:4px}.vwc-pagination-button[size=super-condensed]{--base-size: calc(1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.vwc-pagination-button[size=condensed]{--base-size: calc(1px*(32 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.vwc-pagination-button[size=normal]{--base-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) }.vwc-pagination-button::part(button){padding-inline:0}.dots{align-self:center;text-align:center}.dots:not(.size-super-condensed){font:var(--vvd-typography-base-bold)}.dots.size-super-condensed{font:var(--vvd-typography-base-condensed-bold);inline-size:calc(1px*(24 + 4*clamp(-1,var(--vvd-size-density, 0),2)))}.dots.size-condensed{inline-size:calc(1px*(32 + 4*clamp(-1,var(--vvd-size-density, 0),2)))}.dots.size-normal{inline-size:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)))}";
8
12
 
9
13
  var __defProp = Object.defineProperty;
14
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
15
  var __decorateClass = (decorators, target, key, kind) => {
11
- var result = void 0 ;
16
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
12
17
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
13
18
  if (decorator = decorators[i])
14
- result = (decorator(target, key, result) ) || result;
15
- if (result) __defProp(target, key, result);
19
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
20
+ if (kind && result) __defProp(target, key, result);
16
21
  return result;
17
22
  };
18
- class ProgressRing extends DelegatesAria(BaseProgress) {
23
+ const MAX_DIGITS_AND_PLACEHOLDERS = 7;
24
+ const totalConverter = {
25
+ fromView: (value) => parseInt(value, 10),
26
+ toView: (value) => value.toString()
27
+ };
28
+ class Pagination extends VividElement {
29
+ constructor() {
30
+ super();
31
+ this.navIcons = false;
32
+ this.total = 0;
33
+ this.selectedIndex = 0;
34
+ this.addEventListener("tabpressed", (e) => {
35
+ const { value: currentLabel, shiftKey } = e.detail;
36
+ const index = this.paginationButtons.findIndex(
37
+ (button) => Number(button.label) === currentLabel
38
+ );
39
+ const focusDirection = shiftKey ? -1 : 1;
40
+ const newIndex = index + focusDirection;
41
+ if (newIndex < 0) {
42
+ return this.prevButton.focus();
43
+ }
44
+ if (newIndex > this.paginationButtons.length - 1) {
45
+ return this.nextButton.focus();
46
+ }
47
+ this.paginationButtons && this.paginationButtons[index + focusDirection].focus();
48
+ });
49
+ }
50
+ get pagesList() {
51
+ return new Array(
52
+ this.total < MAX_DIGITS_AND_PLACEHOLDERS ? this.total : MAX_DIGITS_AND_PLACEHOLDERS
53
+ ).fill(0).map((_, i, arr) => {
54
+ if (i === 0) return 1;
55
+ if (i === arr.length - 1) return this.total;
56
+ if (this.selectedIndex !== void 0 && this.total > MAX_DIGITS_AND_PLACEHOLDERS) {
57
+ if (this.selectedIndex < 4) {
58
+ if (i === MAX_DIGITS_AND_PLACEHOLDERS - 2) return "...";
59
+ }
60
+ if (this.selectedIndex >= 4 && this.selectedIndex <= this.total - 5) {
61
+ if (i > 1 && i < MAX_DIGITS_AND_PLACEHOLDERS - 2)
62
+ return this.selectedIndex + (i - 2);
63
+ if (i === 1 || i === MAX_DIGITS_AND_PLACEHOLDERS - 2) return "...";
64
+ }
65
+ if (this.selectedIndex > this.total - 5) {
66
+ if (i > 1) return this.total - (6 - i);
67
+ if (i === 1) return "...";
68
+ }
69
+ }
70
+ return i + 1;
71
+ });
72
+ }
73
+ totalChanged(_, newValue) {
74
+ if (newValue < 0) {
75
+ this.total = 0;
76
+ return;
77
+ }
78
+ this.#constrainSelectedIndex();
79
+ }
80
+ selectedIndexChanged(oldValue, newValue) {
81
+ if (oldValue === void 0) return;
82
+ this.$emit("pagination-change", {
83
+ selectedIndex: newValue,
84
+ total: this.total,
85
+ oldIndex: oldValue
86
+ });
87
+ this.#constrainSelectedIndex();
88
+ }
89
+ paginationButtonsChanged(_, newValue) {
90
+ newValue.forEach((button) => {
91
+ button.shadowRoot.querySelector("button").setAttribute("part", "button");
92
+ });
93
+ }
94
+ get #constrainedSelectedIndex() {
95
+ return Math.max(0, Math.min(this.selectedIndex ?? 0, this.total - 1));
96
+ }
97
+ #constrainSelectedIndex() {
98
+ if (this.selectedIndex !== this.#constrainedSelectedIndex) {
99
+ window.queueMicrotask(() => {
100
+ if (this.selectedIndex !== this.#constrainedSelectedIndex) {
101
+ this.selectedIndex = this.#constrainedSelectedIndex;
102
+ }
103
+ });
104
+ }
105
+ }
19
106
  }
20
107
  __decorateClass([
21
108
  attr
22
- ], ProgressRing.prototype, "connotation");
109
+ ], Pagination.prototype, "size", 2);
23
110
  __decorateClass([
24
111
  attr
25
- ], ProgressRing.prototype, "size");
112
+ ], Pagination.prototype, "shape", 2);
113
+ __decorateClass([
114
+ observable
115
+ ], Pagination.prototype, "paginationButtons", 2);
116
+ __decorateClass([
117
+ observable
118
+ ], Pagination.prototype, "prevButton", 2);
119
+ __decorateClass([
120
+ observable
121
+ ], Pagination.prototype, "nextButton", 2);
122
+ __decorateClass([
123
+ attr({ attribute: "nav-icons", mode: "boolean" })
124
+ ], Pagination.prototype, "navIcons", 2);
125
+ __decorateClass([
126
+ volatile
127
+ ], Pagination.prototype, "pagesList", 1);
128
+ __decorateClass([
129
+ attr({ mode: "reflect", converter: totalConverter })
130
+ ], Pagination.prototype, "total", 2);
131
+ __decorateClass([
132
+ attr({
133
+ mode: "reflect",
134
+ converter: totalConverter,
135
+ attribute: "selected-index"
136
+ })
137
+ ], Pagination.prototype, "selectedIndex", 2);
26
138
 
27
- const getClasses = ({ connotation, size, paused }) => classNames(
28
- "base",
29
- ["disabled", !!paused],
30
- [`connotation-${connotation}`, !!connotation],
31
- [`size-${size}`, !!size]
32
- );
33
- const progressSegments = 44;
34
- const ProgressRingTemplate = html`<template>
35
- <div
36
- class="${(x) => x.paused ? "paused" : ""} ${getClasses}"
37
- ${delegateAria({
38
- role: "progressbar",
39
- ariaValueNow: (x) => x.value,
40
- ariaValueMin: (x) => x.min,
41
- ariaValueMax: (x) => x.max
42
- })}
43
- >
44
- ${when(
45
- (x) => typeof x.value === "number",
46
- html`
47
- <svg class="progress" viewBox="0 0 16 16">
48
- <circle class="background" cx="8px" cy="8px" r="7px"></circle>
49
- <circle
50
- class="determinate"
51
- style="stroke-dasharray: ${(x) => progressSegments * x.percentComplete / 100}px ${progressSegments}px"
52
- cx="8px"
53
- cy="8px"
54
- r="7px"
55
- ></circle>
56
- </svg>
57
- `
58
- )}
59
- ${when(
60
- (x) => typeof x.value !== "number",
139
+ const ALLOWED_SIZES = [
140
+ Size.SuperCondensed,
141
+ Size.Condensed,
142
+ Size.Normal
143
+ ];
144
+ const ALLOWED_SHAPES = [Shape.Rounded, Shape.Pill];
145
+ const handleSelection = (value, { parent: x }) => {
146
+ return x.selectedIndex = Number(value) - 1;
147
+ };
148
+ const handleKeyDown = (value, { event, parent }) => {
149
+ if (event.key === " " || event.key === "Enter") {
150
+ handleSelection(value, { parent });
151
+ }
152
+ if (event.key === "Tab") {
153
+ event.target.dispatchEvent(
154
+ new CustomEvent("tabpressed", {
155
+ detail: { value, shiftKey: event.shiftKey },
156
+ bubbles: true,
157
+ composed: true
158
+ })
159
+ );
160
+ }
161
+ };
162
+ const getClasses = (_) => classNames("control");
163
+ function getButtonAppearance(value, { parent }) {
164
+ return parent.selectedIndex === Number(value) - 1 ? "filled" : "ghost";
165
+ }
166
+ const paginationButtonRenderer = (buttonTag) => html` ${when(
167
+ (value) => value !== "...",
61
168
  html`
62
- <svg class="progress" viewBox="0 0 16 16">
63
- <circle class="background" cx="8px" cy="8px" r="7px"></circle>
64
- <circle
65
- class="indeterminate-indicator-1"
66
- cx="8px"
67
- cy="8px"
68
- r="7px"
69
- ></circle>
70
- </svg>
71
- `
169
+ <${buttonTag} class="vwc-pagination-button"
170
+ label="${(value) => value}"
171
+ appearance="${getButtonAppearance}"
172
+ size="${(_, { parent: x }) => getPaginationSize(x)}"
173
+ shape="${(_, { parent: x }) => getPaginationShape(x)}"
174
+ style="inline-size: ${(value) => getPaginationButtonWidth(value)};"
175
+ tabindex="0"
176
+ aria-current="${(value, { parent }) => parent.selectedIndex === Number(value) - 1}"
177
+ @click="${handleSelection}"
178
+ @keydown="${handleKeyDown}">
179
+ </${buttonTag}>
180
+ `
72
181
  )}
73
- </div>
74
- </template>`;
182
+ ${when(
183
+ (value) => value === "...",
184
+ html` <div class="dots size-${(_, { parent: x }) => getPaginationSize(x)}">
185
+ ...
186
+ </div>`
187
+ )}`;
188
+ const getPaginationSize = (x) => {
189
+ if (!x.size || !ALLOWED_SIZES.includes(x.size)) {
190
+ return Size.SuperCondensed;
191
+ }
192
+ return x.size;
193
+ };
194
+ const getPaginationShape = (x) => {
195
+ if (!x.shape || !ALLOWED_SHAPES.includes(x.shape)) {
196
+ return Shape.Rounded;
197
+ }
198
+ return x.shape;
199
+ };
200
+ const getPaginationButtonWidth = (value) => {
201
+ return `calc(var(--base-size) + ${String(value).length - 1}ch)`;
202
+ };
203
+ const PaginationTemplate = (context) => {
204
+ const buttonTag = context.tagFor(Button);
205
+ const paginationButtonTemplate = paginationButtonRenderer(buttonTag);
206
+ return html`
207
+ <div class="${getClasses}">
208
+ <${buttonTag} class="prev-button" ${ref("prevButton")}
209
+ label="${(x) => !x.navIcons ? "Previous" : null}"
210
+ icon="${(x) => x.navIcons ? "chevron-left-line" : null}"
211
+ size="${getPaginationSize}"
212
+ shape="${getPaginationShape}"
213
+ ?disabled="${(x) => x.total === 0 || x.selectedIndex === 0}"
214
+ @click="${(x) => x.selectedIndex !== void 0 && x.selectedIndex--}"
215
+ ></${buttonTag}>
216
+ <div id="buttons-wrapper" class="buttons-wrapper" ${children({
217
+ property: "paginationButtons",
218
+ filter: elements(buttonTag)
219
+ })}>
220
+ ${repeat((x) => x.pagesList, paginationButtonTemplate, { positioning: true })}
221
+ </div>
222
+ <${buttonTag} class="next-button" ${ref("nextButton")}
223
+ label="${(x) => !x.navIcons ? "Next" : null}"
224
+ icon="${(x) => x.navIcons ? "chevron-right-line" : null}"
225
+ size="${getPaginationSize}"
226
+ shape="${getPaginationShape}"
227
+ ?disabled="${(x) => x.total === 0 || x.selectedIndex === x.total - 1}"
228
+ @click="${(x) => x.selectedIndex !== void 0 && x.selectedIndex++}"
229
+ ></${buttonTag}>
230
+ </div>`;
231
+ };
75
232
 
76
- const progressRingDefinition = defineVividComponent(
77
- "progress-ring",
78
- ProgressRing,
79
- ProgressRingTemplate,
80
- [],
233
+ const paginationDefinition = defineVividComponent(
234
+ "pagination",
235
+ Pagination,
236
+ PaginationTemplate,
237
+ [buttonDefinition],
81
238
  {
82
239
  styles
83
240
  }
84
241
  );
85
- const registerProgressRing = createRegisterFunction(
86
- progressRingDefinition
87
- );
242
+ const registerPagination = createRegisterFunction(paginationDefinition);
88
243
 
89
- export { ProgressRing as P, progressRingDefinition as p, registerProgressRing as r };
244
+ export { Pagination as P, paginationDefinition as p, registerPagination as r };