@vonage/vivid 5.24.0 → 5.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 (331) hide show
  1. package/README.md +1 -1
  2. package/avatar/index.cjs +10 -10
  3. package/avatar/index.js +4 -3
  4. package/breadcrumb-item/index.cjs +9 -5
  5. package/breadcrumb-item/index.js +11 -6
  6. package/bundled/affix.cjs +1 -1
  7. package/bundled/affix.js +1 -1
  8. package/bundled/definition10.cjs +2 -1
  9. package/bundled/definition10.js +3 -2
  10. package/bundled/definition11.cjs +4 -4
  11. package/bundled/definition11.js +4 -3
  12. package/bundled/definition12.cjs +1 -1
  13. package/bundled/definition12.js +1 -0
  14. package/bundled/definition15.cjs +5 -5
  15. package/bundled/definition15.js +4 -3
  16. package/bundled/definition17.cjs +7 -7
  17. package/bundled/definition17.js +22 -109
  18. package/bundled/definition18.cjs +3 -3
  19. package/bundled/definition18.js +9 -31
  20. package/bundled/definition19.cjs +19 -19
  21. package/bundled/definition19.js +3 -2
  22. package/bundled/definition21.cjs +8 -8
  23. package/bundled/definition21.js +5 -4
  24. package/bundled/definition22.cjs +2 -2
  25. package/bundled/definition22.js +2 -2
  26. package/bundled/definition24.cjs +4 -4
  27. package/bundled/definition24.js +4 -3
  28. package/bundled/definition25.cjs +3 -3
  29. package/bundled/definition25.js +32 -28
  30. package/bundled/definition3.cjs +5 -5
  31. package/bundled/definition3.js +10 -40
  32. package/bundled/definition4.cjs +6 -6
  33. package/bundled/definition4.js +4 -3
  34. package/bundled/definition6.cjs +11 -11
  35. package/bundled/definition6.js +4 -3
  36. package/bundled/definition9.cjs +12 -6
  37. package/bundled/definition9.js +66 -43
  38. package/bundled/extractOptions.cjs +1 -1
  39. package/bundled/extractOptions.js +2 -2
  40. package/bundled/icon.cjs +1 -0
  41. package/bundled/icon.js +34 -0
  42. package/bundled/listbox.cjs +1 -1
  43. package/bundled/listbox.js +5 -2
  44. package/bundled/mixins.cjs +8 -8
  45. package/bundled/mixins.js +4 -3
  46. package/bundled/optgroup.cjs +1 -0
  47. package/bundled/optgroup.js +27 -0
  48. package/bundled/option.cjs +1 -0
  49. package/bundled/option.js +93 -0
  50. package/bundled/vivid-element.cjs +1 -1
  51. package/bundled/vivid-element.js +1 -1
  52. package/card/index.cjs +22 -22
  53. package/card/index.js +4 -3
  54. package/color-picker/index.cjs +18 -18
  55. package/color-picker/index.js +4 -3
  56. package/combobox/index.cjs +7 -7
  57. package/combobox/index.js +4 -2
  58. package/custom-elements.json +4159 -3847
  59. package/data-grid/index.cjs +24 -24
  60. package/data-grid/index.js +4 -3
  61. package/dial-pad/index.cjs +21 -21
  62. package/dial-pad/index.js +4 -3
  63. package/dialog/index.cjs +14 -14
  64. package/dialog/index.js +4 -3
  65. package/empty-state/index.cjs +3 -3
  66. package/empty-state/index.js +4 -3
  67. package/file-picker/index.cjs +7 -7
  68. package/file-picker/index.js +4 -3
  69. package/icon/definition.cjs +2 -1
  70. package/icon/definition.js +2 -1
  71. package/index.cjs +148 -141
  72. package/index.js +41 -37
  73. package/lib/accordion-item/accordion-item.d.ts +1 -0
  74. package/lib/combobox/combobox.d.ts +1 -1
  75. package/lib/components.d.ts +1 -0
  76. package/lib/dial-pad/dial-pad.d.ts +0 -1
  77. package/lib/listbox/definition.d.ts +3 -0
  78. package/lib/listbox/index.d.ts +1 -0
  79. package/lib/listbox/listbox.d.ts +1302 -0
  80. package/lib/listbox/listbox.template.d.ts +3 -0
  81. package/lib/listbox/variations.browser-spec.d.ts +1 -0
  82. package/lib/menu/menu.d.ts +0 -1
  83. package/lib/number-field/number-field.d.ts +0 -1
  84. package/lib/rich-text-editor/rte/features/base.d.ts +1 -0
  85. package/lib/rich-text-editor/rte/utils/default-textblock.d.ts +2 -2
  86. package/lib/tag-name-map.d.ts +2 -1
  87. package/lib/text-field/text-field.d.ts +1 -0
  88. package/lib/toggletip/toggletip.d.ts +1 -0
  89. package/lib/tooltip/tooltip.d.ts +1 -0
  90. package/listbox/definition.cjs +5 -0
  91. package/listbox/definition.js +2 -0
  92. package/listbox/index.cjs +11 -0
  93. package/listbox/index.js +540 -0
  94. package/nav/definition.cjs +1 -1
  95. package/nav/definition.js +1 -1
  96. package/nav-disclosure/definition.cjs +1 -1
  97. package/nav-disclosure/definition.js +1 -1
  98. package/nav-disclosure/index.cjs +4 -4
  99. package/nav-disclosure/index.js +4 -3
  100. package/nav-item/definition.cjs +1 -1
  101. package/nav-item/definition.js +1 -1
  102. package/note/definition.cjs +1 -1
  103. package/note/definition.js +1 -1
  104. package/number-field/definition.cjs +1 -1
  105. package/number-field/definition.js +1 -1
  106. package/optgroup/definition.cjs +2 -1
  107. package/optgroup/definition.js +2 -1
  108. package/option/definition.cjs +2 -1
  109. package/option/definition.js +2 -1
  110. package/package.json +8 -7
  111. package/pagination/definition.cjs +1 -1
  112. package/pagination/definition.js +1 -1
  113. package/platform-switch/definition.cjs +1 -1
  114. package/platform-switch/definition.js +1 -1
  115. package/popover/definition.cjs +1 -1
  116. package/popover/definition.js +1 -1
  117. package/popover/index.cjs +5 -5
  118. package/popover/index.js +4 -3
  119. package/progress/definition.cjs +1 -1
  120. package/progress/definition.js +1 -1
  121. package/radio/definition.cjs +1 -1
  122. package/radio/definition.js +1 -1
  123. package/radio-group/definition.cjs +1 -1
  124. package/radio-group/definition.js +1 -1
  125. package/range-slider/definition.cjs +1 -1
  126. package/range-slider/definition.js +1 -1
  127. package/rich-text-editor/definition.cjs +1 -1
  128. package/rich-text-editor/definition.js +1 -1
  129. package/rich-text-editor/index.cjs +13 -13
  130. package/rich-text-editor/index.js +22 -19
  131. package/rich-text-view/definition.cjs +1 -1
  132. package/rich-text-view/definition.js +1 -1
  133. package/searchable-select/definition.cjs +1 -1
  134. package/searchable-select/definition.js +1 -1
  135. package/searchable-select/index.cjs +23 -23
  136. package/searchable-select/index.js +10 -7
  137. package/select/definition.cjs +1 -1
  138. package/select/definition.js +1 -1
  139. package/selectable-box/definition.cjs +1 -1
  140. package/selectable-box/definition.js +1 -1
  141. package/shared/listbox/commands.d.ts +17 -0
  142. package/shared/listbox/move.d.ts +6 -0
  143. package/shared/listbox/options.d.ts +12 -0
  144. package/shared/listbox/selection.d.ts +28 -0
  145. package/shared/listbox/state.d.ts +26 -0
  146. package/shared/listbox/typeahead.d.ts +8 -0
  147. package/shared/listbox/with-options-filter.d.ts +440 -0
  148. package/shared/listbox/with-options.d.ts +862 -0
  149. package/side-drawer/definition.cjs +1 -1
  150. package/side-drawer/definition.js +1 -1
  151. package/simple-color-picker/definition.cjs +1 -1
  152. package/simple-color-picker/definition.js +1 -1
  153. package/simple-color-picker/index.cjs +6 -6
  154. package/simple-color-picker/index.js +4 -3
  155. package/split-button/definition.cjs +1 -1
  156. package/split-button/definition.js +1 -1
  157. package/status/definition.cjs +1 -1
  158. package/status/definition.js +1 -1
  159. package/switch/definition.cjs +1 -1
  160. package/switch/definition.js +1 -1
  161. package/tab/definition.cjs +1 -1
  162. package/tab/definition.js +1 -1
  163. package/tab-panel/definition.cjs +1 -1
  164. package/tab-panel/definition.js +1 -1
  165. package/table/definition.cjs +1 -1
  166. package/table/definition.js +1 -1
  167. package/table/index.cjs +13 -13
  168. package/table/index.js +4 -3
  169. package/tabs/definition.cjs +1 -1
  170. package/tabs/definition.js +1 -1
  171. package/tag/definition.cjs +1 -1
  172. package/tag/definition.js +1 -1
  173. package/tag/index.cjs +11 -11
  174. package/tag/index.js +4 -3
  175. package/tag-group/definition.cjs +1 -1
  176. package/tag-group/definition.js +1 -1
  177. package/text-area/definition.cjs +1 -1
  178. package/text-area/definition.js +1 -1
  179. package/time-picker/definition.cjs +1 -1
  180. package/time-picker/definition.js +1 -1
  181. package/tree-item/definition.cjs +1 -1
  182. package/tree-item/definition.js +1 -1
  183. package/tree-view/definition.cjs +1 -1
  184. package/tree-view/definition.js +1 -1
  185. package/unbundled/affix.cjs +2 -2
  186. package/unbundled/affix.js +1 -1
  187. package/unbundled/base-progress.cjs +1 -1
  188. package/unbundled/base-progress.js +1 -1
  189. package/unbundled/button.cjs +2 -2
  190. package/unbundled/button.js +2 -2
  191. package/unbundled/definition.cjs +2 -65
  192. package/unbundled/definition.js +4 -61
  193. package/unbundled/definition11.cjs +4 -3
  194. package/unbundled/definition11.js +3 -2
  195. package/unbundled/definition12.cjs +3 -2
  196. package/unbundled/definition12.js +3 -2
  197. package/unbundled/definition14.cjs +2 -1
  198. package/unbundled/definition14.js +2 -1
  199. package/unbundled/definition17.cjs +9 -4
  200. package/unbundled/definition17.js +9 -4
  201. package/unbundled/definition2.cjs +7 -2
  202. package/unbundled/definition2.js +8 -3
  203. package/unbundled/definition21.cjs +2 -1
  204. package/unbundled/definition21.js +2 -1
  205. package/unbundled/definition23.cjs +2 -1
  206. package/unbundled/definition23.js +2 -1
  207. package/unbundled/definition24.cjs +6 -4
  208. package/unbundled/definition24.js +6 -4
  209. package/unbundled/definition25.cjs +2 -1
  210. package/unbundled/definition25.js +2 -1
  211. package/unbundled/definition26.cjs +7 -4
  212. package/unbundled/definition26.js +7 -4
  213. package/unbundled/definition27.cjs +39 -5
  214. package/unbundled/definition27.js +40 -6
  215. package/unbundled/definition28.cjs +4 -3
  216. package/unbundled/definition28.js +4 -3
  217. package/unbundled/definition29.cjs +5 -168
  218. package/unbundled/definition29.js +11 -162
  219. package/unbundled/definition30.cjs +2 -63
  220. package/unbundled/definition30.js +5 -54
  221. package/unbundled/definition31.cjs +5 -3
  222. package/unbundled/definition31.js +5 -3
  223. package/unbundled/definition32.cjs +2 -1
  224. package/unbundled/definition32.js +2 -1
  225. package/unbundled/definition35.cjs +2 -1
  226. package/unbundled/definition35.js +2 -1
  227. package/unbundled/definition37.cjs +1 -1
  228. package/unbundled/definition37.js +1 -1
  229. package/unbundled/definition39.cjs +1 -1
  230. package/unbundled/definition39.js +1 -1
  231. package/unbundled/definition40.cjs +4 -2
  232. package/unbundled/definition40.js +4 -2
  233. package/unbundled/definition41.cjs +11 -6
  234. package/unbundled/definition41.js +11 -6
  235. package/unbundled/definition42.cjs +5 -4
  236. package/unbundled/definition42.js +5 -4
  237. package/unbundled/definition44.cjs +3 -2
  238. package/unbundled/definition44.js +3 -2
  239. package/unbundled/definition45.cjs +2 -2
  240. package/unbundled/definition45.js +2 -2
  241. package/unbundled/definition49.cjs +583 -79
  242. package/unbundled/definition49.js +579 -76
  243. package/unbundled/definition50.cjs +71 -33
  244. package/unbundled/definition50.js +67 -29
  245. package/unbundled/definition51.cjs +54 -23
  246. package/unbundled/definition51.js +52 -18
  247. package/unbundled/definition52.cjs +23 -39
  248. package/unbundled/definition52.js +17 -36
  249. package/unbundled/definition53.cjs +29 -314
  250. package/unbundled/definition53.js +27 -312
  251. package/unbundled/definition54.cjs +302 -195
  252. package/unbundled/definition54.js +298 -191
  253. package/unbundled/definition55.cjs +210 -40
  254. package/unbundled/definition55.js +206 -36
  255. package/unbundled/definition56.cjs +42 -266
  256. package/unbundled/definition56.js +38 -262
  257. package/unbundled/definition57.cjs +270 -50
  258. package/unbundled/definition57.js +267 -46
  259. package/unbundled/definition58.cjs +48 -146
  260. package/unbundled/definition58.js +47 -143
  261. package/unbundled/definition59.cjs +127 -225
  262. package/unbundled/definition59.js +122 -223
  263. package/unbundled/definition6.cjs +2 -1
  264. package/unbundled/definition6.js +2 -1
  265. package/unbundled/definition60.cjs +199 -418
  266. package/unbundled/definition60.js +196 -415
  267. package/unbundled/definition61.cjs +442 -3738
  268. package/unbundled/definition61.js +432 -3565
  269. package/unbundled/definition62.cjs +3717 -730
  270. package/unbundled/definition62.js +3544 -720
  271. package/unbundled/definition63.cjs +770 -97
  272. package/unbundled/definition63.js +767 -94
  273. package/unbundled/definition64.cjs +100 -999
  274. package/unbundled/definition64.js +98 -994
  275. package/unbundled/definition65.cjs +991 -93
  276. package/unbundled/definition65.js +985 -90
  277. package/unbundled/definition66.cjs +109 -73
  278. package/unbundled/definition66.js +105 -63
  279. package/unbundled/definition67.cjs +69 -155
  280. package/unbundled/definition67.js +60 -152
  281. package/unbundled/definition68.cjs +155 -119
  282. package/unbundled/definition68.js +151 -115
  283. package/unbundled/definition69.cjs +124 -49
  284. package/unbundled/definition69.js +120 -45
  285. package/unbundled/definition70.cjs +51 -85
  286. package/unbundled/definition70.js +50 -81
  287. package/unbundled/definition71.cjs +91 -19
  288. package/unbundled/definition71.js +86 -14
  289. package/unbundled/definition72.cjs +20 -87
  290. package/unbundled/definition72.js +14 -84
  291. package/unbundled/definition73.cjs +77 -294
  292. package/unbundled/definition73.js +72 -217
  293. package/unbundled/definition74.cjs +289 -311
  294. package/unbundled/definition74.js +219 -306
  295. package/unbundled/definition75.cjs +326 -26
  296. package/unbundled/definition75.js +317 -23
  297. package/unbundled/definition76.cjs +27 -122
  298. package/unbundled/definition76.js +22 -118
  299. package/unbundled/definition77.cjs +105 -232
  300. package/unbundled/definition77.js +101 -228
  301. package/unbundled/definition78.cjs +259 -26
  302. package/unbundled/definition78.js +249 -23
  303. package/unbundled/definition79.cjs +29 -148
  304. package/unbundled/definition79.js +27 -133
  305. package/unbundled/definition80.cjs +118 -173
  306. package/unbundled/definition80.js +109 -169
  307. package/unbundled/definition81.cjs +181 -477
  308. package/unbundled/definition81.js +176 -471
  309. package/unbundled/definition82.cjs +517 -0
  310. package/unbundled/definition82.js +497 -0
  311. package/unbundled/extractOptions.cjs +5 -5
  312. package/unbundled/extractOptions.js +2 -2
  313. package/unbundled/icon.cjs +67 -0
  314. package/unbundled/icon.js +61 -0
  315. package/unbundled/linkable.cjs +1 -1
  316. package/unbundled/linkable.js +1 -1
  317. package/unbundled/listbox.cjs +8 -3
  318. package/unbundled/listbox.js +7 -2
  319. package/unbundled/mixins.cjs +2 -1
  320. package/unbundled/mixins.js +2 -1
  321. package/unbundled/optgroup.cjs +66 -0
  322. package/unbundled/optgroup.js +54 -0
  323. package/unbundled/option.cjs +176 -0
  324. package/unbundled/option.js +164 -0
  325. package/unbundled/time-selection-picker.template.cjs +1 -1
  326. package/unbundled/time-selection-picker.template.js +1 -1
  327. package/unbundled/vivid-element.cjs +1 -1
  328. package/unbundled/vivid-element.js +1 -1
  329. package/video-player/definition.cjs +1 -1
  330. package/video-player/definition.js +1 -1
  331. package/vivid.api.json +336 -193
@@ -1,75 +1,245 @@
1
1
  require("./chunk.cjs");
2
2
  const require_vivid_element = require("./vivid-element.cjs");
3
3
  const require_decorate = require("./decorate.cjs");
4
- const require_platform = require("./platform.cjs");
4
+ const require_localized = require("./localized.cjs");
5
+ const require_definition = require("./definition6.cjs");
6
+ const require_enums = require("./enums.cjs");
5
7
  let _microsoft_fast_element = require("@microsoft/fast-element");
6
- //#region src/lib/platform-switch/platform-switch.scss?inline
7
- var platform_switch_default = ":host{display:contents}";
8
+ let _microsoft_fast_web_utilities = require("@microsoft/fast-web-utilities");
9
+ //#region src/lib/pagination/pagination.scss?inline
10
+ var pagination_default = ".control{justify-content:space-between;display:inline-flex}.control:not(.shape-pill){border-radius:4px}.control.shape-pill{border-radius:16px}.buttons-wrapper{column-gap:4px;display:flex}.vwc-pagination-button[size=super-condensed]{--base-size:calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 16))}.vwc-pagination-button[size=condensed]{--base-size:calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 8))}.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{text-align:center;align-self: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 * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 16))}.dots.size-condensed{inline-size:calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 8))}.dots.size-normal{inline-size:calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2)))}";
8
11
  //#endregion
9
- //#region src/lib/platform-switch/platform-switch.ts
12
+ //#region src/lib/pagination/pagination.ts
13
+ var MAX_DIGITS_AND_PLACEHOLDERS = 7;
14
+ var totalConverter = {
15
+ fromView: (value) => parseInt(value, 10),
16
+ toView: (value) => value.toString()
17
+ };
10
18
  /**
11
19
  * @public
12
- * @component platform-switch
13
- * @slot - Default slot accepts children with optional platform constraints.
20
+ * @component pagination
21
+ * @event {CustomEvent<{selectedIndex: number, total: number, oldIndex: number}>} pagination-change - Fires when the page changes.
22
+ * @vueModel modelValue selectedIndex pagination-change `event.currentTarget.selectedIndex`
23
+ * @testAction clickNext click #nextButton
24
+ * @testAction clickPrev click #prevButton
25
+ * @testAction clickPageIndex clickPaginationPage
26
+ * @testQuery total total
27
+ * @testQuery selectedPage paginationSelectedPage
28
+ * @testRef nextButton shadow .next-button
29
+ * @testRef prevButton shadow .prev-button
14
30
  */
15
- var PlatformSwitch = class extends require_vivid_element.VividElement {
16
- /** @internal */
17
- slottedContentChanged() {
18
- this.#updateVisibility();
31
+ var Pagination = class extends require_localized.Localized(require_vivid_element.VividElement) {
32
+ get pagesList() {
33
+ return new Array(this.total < MAX_DIGITS_AND_PLACEHOLDERS ? this.total : MAX_DIGITS_AND_PLACEHOLDERS).fill(0).map((_, i, arr) => {
34
+ if (i === 0) return 1;
35
+ if (i === arr.length - 1) return this.total;
36
+ if (this.selectedIndex !== void 0 && this.total > MAX_DIGITS_AND_PLACEHOLDERS) {
37
+ if (this.selectedIndex < 4) {
38
+ if (i === MAX_DIGITS_AND_PLACEHOLDERS - 2) return "...";
39
+ }
40
+ if (this.selectedIndex >= 4 && this.selectedIndex <= this.total - 5) {
41
+ if (i > 1 && i < MAX_DIGITS_AND_PLACEHOLDERS - 2) return this.selectedIndex + (i - 2);
42
+ /* v8 ignore else -- @preserve */
43
+ if (i === 1 || i === MAX_DIGITS_AND_PLACEHOLDERS - 2) return "...";
44
+ }
45
+ if (this.selectedIndex > this.total - 5) {
46
+ if (i > 1) return this.total - (6 - i);
47
+ /* v8 ignore else -- @preserve */
48
+ if (i === 1) return "...";
49
+ }
50
+ }
51
+ return i + 1;
52
+ });
19
53
  }
20
- #updateVisibility() {
21
- const children = this.slottedContent.filter((n) => n instanceof HTMLElement);
22
- let matched = false;
23
- for (const child of children) {
24
- if (matched) {
25
- child.hidden = true;
26
- continue;
54
+ constructor() {
55
+ super();
56
+ this.navIcons = false;
57
+ this.total = 0;
58
+ this.selectedIndex = 0;
59
+ this.addEventListener("tabpressed", (e) => {
60
+ const { value: currentLabel, shiftKey } = e.detail;
61
+ const index = this.paginationButtons.findIndex((button) => Number(button.label) === currentLabel);
62
+ const focusDirection = shiftKey ? -1 : 1;
63
+ const newIndex = index + focusDirection;
64
+ if (newIndex < 0) {
65
+ this.prevButton.focus();
66
+ return;
67
+ }
68
+ if (newIndex > this.paginationButtons.length - 1) {
69
+ this.nextButton.focus();
70
+ return;
27
71
  }
28
- if (this.#matches(child)) {
29
- child.hidden = false;
30
- matched = true;
31
- } else child.hidden = true;
72
+ /* v8 ignore else -- @preserve */
73
+ if (this.paginationButtons) this.paginationButtons[index + focusDirection].focus();
74
+ });
75
+ }
76
+ /** @internal */
77
+ totalChanged(_, newValue) {
78
+ if (newValue < 0) {
79
+ this.total = 0;
80
+ return;
32
81
  }
82
+ this.#constrainSelectedIndex();
83
+ }
84
+ /** @internal */
85
+ selectedIndexChanged(oldValue, newValue) {
86
+ if (oldValue === void 0) return;
87
+ this.$emit("pagination-change", {
88
+ selectedIndex: newValue,
89
+ total: this.total,
90
+ oldIndex: oldValue
91
+ });
92
+ this.#constrainSelectedIndex();
33
93
  }
34
- #matches(el) {
35
- const keyboard = require_platform.isApplePlatform() ? "apple" : "standard";
36
- const keyboardConstraint = el.dataset.keyboard;
37
- if (keyboardConstraint === void 0) return true;
38
- return keyboardConstraint === keyboard;
94
+ /** @internal */
95
+ paginationButtonsChanged(_, newValue) {
96
+ newValue.forEach((button) => {
97
+ button.shadowRoot.querySelector("button").setAttribute("part", "button");
98
+ });
99
+ }
100
+ get #constrainedSelectedIndex() {
101
+ return Math.max(0, Math.min(this.selectedIndex ?? 0, this.total - 1));
102
+ }
103
+ #constrainSelectedIndex() {
104
+ if (this.selectedIndex !== this.#constrainedSelectedIndex) window.queueMicrotask(() => {
105
+ if (this.selectedIndex !== this.#constrainedSelectedIndex) this.selectedIndex = this.#constrainedSelectedIndex;
106
+ });
39
107
  }
40
108
  };
41
- require_decorate.__decorate([_microsoft_fast_element.observable], PlatformSwitch.prototype, "slottedContent", void 0);
109
+ require_decorate.__decorate([_microsoft_fast_element.attr], Pagination.prototype, "size", void 0);
110
+ require_decorate.__decorate([_microsoft_fast_element.attr], Pagination.prototype, "shape", void 0);
111
+ require_decorate.__decorate([_microsoft_fast_element.observable], Pagination.prototype, "paginationButtons", void 0);
112
+ require_decorate.__decorate([_microsoft_fast_element.observable], Pagination.prototype, "prevButton", void 0);
113
+ require_decorate.__decorate([_microsoft_fast_element.observable], Pagination.prototype, "nextButton", void 0);
114
+ require_decorate.__decorate([(0, _microsoft_fast_element.attr)({
115
+ attribute: "nav-icons",
116
+ mode: "boolean"
117
+ })], Pagination.prototype, "navIcons", void 0);
118
+ require_decorate.__decorate([_microsoft_fast_element.volatile], Pagination.prototype, "pagesList", null);
119
+ require_decorate.__decorate([(0, _microsoft_fast_element.attr)({
120
+ mode: "reflect",
121
+ converter: totalConverter
122
+ })], Pagination.prototype, "total", void 0);
123
+ require_decorate.__decorate([(0, _microsoft_fast_element.attr)({
124
+ mode: "reflect",
125
+ converter: totalConverter,
126
+ attribute: "selected-index"
127
+ })], Pagination.prototype, "selectedIndex", void 0);
42
128
  //#endregion
43
- //#region src/lib/platform-switch/platform-switch.template.ts
44
- var PlatformSwitchTemplate = () => {
45
- return _microsoft_fast_element.html`<slot ${(0, _microsoft_fast_element.slotted)("slottedContent")}></slot>`;
129
+ //#region src/lib/pagination/pagination.template.ts
130
+ var ALLOWED_SIZES = [
131
+ require_enums.Size.SuperCondensed,
132
+ require_enums.Size.Condensed,
133
+ require_enums.Size.Normal
134
+ ];
135
+ var ALLOWED_SHAPES = [require_enums.Shape.Rounded, require_enums.Shape.Pill];
136
+ var handleSelection = (value, { parent: x }) => {
137
+ return x.selectedIndex = Number(value) - 1;
138
+ };
139
+ var handleKeyDown = (value, { event, parent }) => {
140
+ if (event.key === " " || event.key === "Enter") handleSelection(value, { parent });
141
+ if (event.key === "Tab") event.target.dispatchEvent(new CustomEvent("tabpressed", {
142
+ detail: {
143
+ value,
144
+ shiftKey: event.shiftKey
145
+ },
146
+ bubbles: true,
147
+ composed: true
148
+ }));
149
+ };
150
+ var getClasses = (_) => (0, _microsoft_fast_web_utilities.classNames)("control");
151
+ function getButtonAppearance(value, { parent }) {
152
+ return parent.selectedIndex === Number(value) - 1 ? "filled" : "ghost";
153
+ }
154
+ var paginationButtonRenderer = (buttonTag) => _microsoft_fast_element.html` ${(0, _microsoft_fast_element.when)((value) => value !== "...", _microsoft_fast_element.html`
155
+ <${buttonTag} class="vwc-pagination-button"
156
+ label="${(value) => value}"
157
+ appearance="${getButtonAppearance}"
158
+ size="${(_, { parent: x }) => getPaginationSize(x)}"
159
+ shape="${(_, { parent: x }) => getPaginationShape(x)}"
160
+ style="inline-size: ${(value) => getPaginationButtonWidth(value)};"
161
+ tabindex="0"
162
+ aria-label="${(value, { parent: x }) => x.locale.pagination.goToPageLabel(value)}"
163
+ aria-current="${(value, { parent }) => parent.selectedIndex === Number(value) - 1}"
164
+ @click="${handleSelection}"
165
+ @keydown="${handleKeyDown}">
166
+ </${buttonTag}>
167
+ `)}
168
+ ${(0, _microsoft_fast_element.when)((value) => value === "...", _microsoft_fast_element.html` <div
169
+ class="dots size-${(_, { parent: x }) => getPaginationSize(x)}"
170
+ aria-hidden="true"
171
+ >
172
+ ...
173
+ </div>`)}`;
174
+ var getPaginationSize = (x) => {
175
+ if (!x.size || !ALLOWED_SIZES.includes(x.size)) return require_enums.Size.SuperCondensed;
176
+ return x.size;
177
+ };
178
+ var getPaginationShape = (x) => {
179
+ if (!x.shape || !ALLOWED_SHAPES.includes(x.shape)) return require_enums.Shape.Rounded;
180
+ return x.shape;
181
+ };
182
+ var getPaginationButtonWidth = (value) => {
183
+ return `calc(var(--base-size) + ${String(value).length - 1}ch)`;
184
+ };
185
+ var PaginationTemplate = (context) => {
186
+ const buttonTag = context.tagFor(require_definition.Button);
187
+ const buttonTagName = context.tagFor(require_definition.Button, true);
188
+ const paginationButtonTemplate = paginationButtonRenderer(buttonTag);
189
+ return _microsoft_fast_element.html`
190
+ <div class="${getClasses}">
191
+ <${buttonTag} class="prev-button" ${(0, _microsoft_fast_element.ref)("prevButton")}
192
+ label="${(x) => !x.navIcons ? "Previous" : null}"
193
+ icon="${(x) => x.navIcons ? "chevron-left-line" : null}"
194
+ size="${getPaginationSize}"
195
+ shape="${getPaginationShape}"
196
+ ?disabled="${(x) => x.total === 0 || x.selectedIndex === 0}"
197
+ @click="${(x) => x.selectedIndex !== void 0 && x.selectedIndex--}"
198
+ aria-label="${(x) => x.locale.pagination.previousPageLabel}"
199
+ ></${buttonTag}>
200
+ <div id="buttons-wrapper" class="buttons-wrapper" ${(0, _microsoft_fast_element.children)({
201
+ property: "paginationButtons",
202
+ filter: (0, _microsoft_fast_element.elements)(buttonTagName)
203
+ })}>
204
+ ${(0, _microsoft_fast_element.repeat)((x) => x.pagesList, paginationButtonTemplate, { positioning: true })}
205
+ </div>
206
+ <${buttonTag} class="next-button" ${(0, _microsoft_fast_element.ref)("nextButton")}
207
+ label="${(x) => !x.navIcons ? "Next" : null}"
208
+ icon="${(x) => x.navIcons ? "chevron-right-line" : null}"
209
+ size="${getPaginationSize}"
210
+ shape="${getPaginationShape}"
211
+ ?disabled="${(x) => x.total === 0 || x.selectedIndex === x.total - 1}"
212
+ @click="${(x) => x.selectedIndex !== void 0 && x.selectedIndex++}"
213
+ aria-label="${(x) => x.locale.pagination.nextPageLabel}"
214
+ ></${buttonTag}>
215
+ </div>`;
46
216
  };
47
217
  //#endregion
48
- //#region src/lib/platform-switch/definition.ts
218
+ //#region src/lib/pagination/definition.ts
49
219
  /** @internal */
50
- var platformSwitchDefinition = require_vivid_element.defineVividComponent("platform-switch", PlatformSwitch, PlatformSwitchTemplate, [], { styles: platform_switch_default });
220
+ var paginationDefinition = require_vivid_element.defineVividComponent("pagination", Pagination, PaginationTemplate, [require_definition.buttonDefinition], { styles: pagination_default });
51
221
  /**
52
- * Registers the platform-switch element with the design system.
222
+ * Registers the pagination element with the design system.
53
223
  *
54
224
  * @param prefix - the prefix to use for the component name
55
225
  */
56
- var registerPlatformSwitch = require_vivid_element.createRegisterFunction(platformSwitchDefinition);
226
+ var registerPagination = require_vivid_element.createRegisterFunction(paginationDefinition);
57
227
  //#endregion
58
- Object.defineProperty(exports, "PlatformSwitch", {
228
+ Object.defineProperty(exports, "Pagination", {
59
229
  enumerable: true,
60
230
  get: function() {
61
- return PlatformSwitch;
231
+ return Pagination;
62
232
  }
63
233
  });
64
- Object.defineProperty(exports, "platformSwitchDefinition", {
234
+ Object.defineProperty(exports, "paginationDefinition", {
65
235
  enumerable: true,
66
236
  get: function() {
67
- return platformSwitchDefinition;
237
+ return paginationDefinition;
68
238
  }
69
239
  });
70
- Object.defineProperty(exports, "registerPlatformSwitch", {
240
+ Object.defineProperty(exports, "registerPagination", {
71
241
  enumerable: true,
72
242
  get: function() {
73
- return registerPlatformSwitch;
243
+ return registerPagination;
74
244
  }
75
245
  });
@@ -1,57 +1,227 @@
1
1
  import { d as createRegisterFunction, t as VividElement, u as defineVividComponent } from "./vivid-element.js";
2
2
  import { t as __decorate } from "./decorate.js";
3
- import { t as isApplePlatform } from "./platform.js";
4
- import { html, observable, slotted } from "@microsoft/fast-element";
5
- //#region src/lib/platform-switch/platform-switch.scss?inline
6
- var platform_switch_default = ":host{display:contents}";
3
+ import { t as Localized } from "./localized.js";
4
+ import { i as Button, t as buttonDefinition } from "./definition6.js";
5
+ import { d as Size, u as Shape } from "./enums.js";
6
+ import { attr, children, elements, html, observable, ref, repeat, volatile, when } from "@microsoft/fast-element";
7
+ import { classNames } from "@microsoft/fast-web-utilities";
8
+ //#region src/lib/pagination/pagination.scss?inline
9
+ var pagination_default = ".control{justify-content:space-between;display:inline-flex}.control:not(.shape-pill){border-radius:4px}.control.shape-pill{border-radius:16px}.buttons-wrapper{column-gap:4px;display:flex}.vwc-pagination-button[size=super-condensed]{--base-size:calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 16))}.vwc-pagination-button[size=condensed]{--base-size:calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 8))}.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{text-align:center;align-self: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 * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 16))}.dots.size-condensed{inline-size:calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2) - 8))}.dots.size-normal{inline-size:calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density,0), 2)))}";
7
10
  //#endregion
8
- //#region src/lib/platform-switch/platform-switch.ts
11
+ //#region src/lib/pagination/pagination.ts
12
+ var MAX_DIGITS_AND_PLACEHOLDERS = 7;
13
+ var totalConverter = {
14
+ fromView: (value) => parseInt(value, 10),
15
+ toView: (value) => value.toString()
16
+ };
9
17
  /**
10
18
  * @public
11
- * @component platform-switch
12
- * @slot - Default slot accepts children with optional platform constraints.
19
+ * @component pagination
20
+ * @event {CustomEvent<{selectedIndex: number, total: number, oldIndex: number}>} pagination-change - Fires when the page changes.
21
+ * @vueModel modelValue selectedIndex pagination-change `event.currentTarget.selectedIndex`
22
+ * @testAction clickNext click #nextButton
23
+ * @testAction clickPrev click #prevButton
24
+ * @testAction clickPageIndex clickPaginationPage
25
+ * @testQuery total total
26
+ * @testQuery selectedPage paginationSelectedPage
27
+ * @testRef nextButton shadow .next-button
28
+ * @testRef prevButton shadow .prev-button
13
29
  */
14
- var PlatformSwitch = class extends VividElement {
15
- /** @internal */
16
- slottedContentChanged() {
17
- this.#updateVisibility();
30
+ var Pagination = class extends Localized(VividElement) {
31
+ get pagesList() {
32
+ return new Array(this.total < MAX_DIGITS_AND_PLACEHOLDERS ? this.total : MAX_DIGITS_AND_PLACEHOLDERS).fill(0).map((_, i, arr) => {
33
+ if (i === 0) return 1;
34
+ if (i === arr.length - 1) return this.total;
35
+ if (this.selectedIndex !== void 0 && this.total > MAX_DIGITS_AND_PLACEHOLDERS) {
36
+ if (this.selectedIndex < 4) {
37
+ if (i === MAX_DIGITS_AND_PLACEHOLDERS - 2) return "...";
38
+ }
39
+ if (this.selectedIndex >= 4 && this.selectedIndex <= this.total - 5) {
40
+ if (i > 1 && i < MAX_DIGITS_AND_PLACEHOLDERS - 2) return this.selectedIndex + (i - 2);
41
+ /* v8 ignore else -- @preserve */
42
+ if (i === 1 || i === MAX_DIGITS_AND_PLACEHOLDERS - 2) return "...";
43
+ }
44
+ if (this.selectedIndex > this.total - 5) {
45
+ if (i > 1) return this.total - (6 - i);
46
+ /* v8 ignore else -- @preserve */
47
+ if (i === 1) return "...";
48
+ }
49
+ }
50
+ return i + 1;
51
+ });
18
52
  }
19
- #updateVisibility() {
20
- const children = this.slottedContent.filter((n) => n instanceof HTMLElement);
21
- let matched = false;
22
- for (const child of children) {
23
- if (matched) {
24
- child.hidden = true;
25
- continue;
53
+ constructor() {
54
+ super();
55
+ this.navIcons = false;
56
+ this.total = 0;
57
+ this.selectedIndex = 0;
58
+ this.addEventListener("tabpressed", (e) => {
59
+ const { value: currentLabel, shiftKey } = e.detail;
60
+ const index = this.paginationButtons.findIndex((button) => Number(button.label) === currentLabel);
61
+ const focusDirection = shiftKey ? -1 : 1;
62
+ const newIndex = index + focusDirection;
63
+ if (newIndex < 0) {
64
+ this.prevButton.focus();
65
+ return;
66
+ }
67
+ if (newIndex > this.paginationButtons.length - 1) {
68
+ this.nextButton.focus();
69
+ return;
26
70
  }
27
- if (this.#matches(child)) {
28
- child.hidden = false;
29
- matched = true;
30
- } else child.hidden = true;
71
+ /* v8 ignore else -- @preserve */
72
+ if (this.paginationButtons) this.paginationButtons[index + focusDirection].focus();
73
+ });
74
+ }
75
+ /** @internal */
76
+ totalChanged(_, newValue) {
77
+ if (newValue < 0) {
78
+ this.total = 0;
79
+ return;
31
80
  }
81
+ this.#constrainSelectedIndex();
82
+ }
83
+ /** @internal */
84
+ selectedIndexChanged(oldValue, newValue) {
85
+ if (oldValue === void 0) return;
86
+ this.$emit("pagination-change", {
87
+ selectedIndex: newValue,
88
+ total: this.total,
89
+ oldIndex: oldValue
90
+ });
91
+ this.#constrainSelectedIndex();
32
92
  }
33
- #matches(el) {
34
- const keyboard = isApplePlatform() ? "apple" : "standard";
35
- const keyboardConstraint = el.dataset.keyboard;
36
- if (keyboardConstraint === void 0) return true;
37
- return keyboardConstraint === keyboard;
93
+ /** @internal */
94
+ paginationButtonsChanged(_, newValue) {
95
+ newValue.forEach((button) => {
96
+ button.shadowRoot.querySelector("button").setAttribute("part", "button");
97
+ });
98
+ }
99
+ get #constrainedSelectedIndex() {
100
+ return Math.max(0, Math.min(this.selectedIndex ?? 0, this.total - 1));
101
+ }
102
+ #constrainSelectedIndex() {
103
+ if (this.selectedIndex !== this.#constrainedSelectedIndex) window.queueMicrotask(() => {
104
+ if (this.selectedIndex !== this.#constrainedSelectedIndex) this.selectedIndex = this.#constrainedSelectedIndex;
105
+ });
38
106
  }
39
107
  };
40
- __decorate([observable], PlatformSwitch.prototype, "slottedContent", void 0);
108
+ __decorate([attr], Pagination.prototype, "size", void 0);
109
+ __decorate([attr], Pagination.prototype, "shape", void 0);
110
+ __decorate([observable], Pagination.prototype, "paginationButtons", void 0);
111
+ __decorate([observable], Pagination.prototype, "prevButton", void 0);
112
+ __decorate([observable], Pagination.prototype, "nextButton", void 0);
113
+ __decorate([attr({
114
+ attribute: "nav-icons",
115
+ mode: "boolean"
116
+ })], Pagination.prototype, "navIcons", void 0);
117
+ __decorate([volatile], Pagination.prototype, "pagesList", null);
118
+ __decorate([attr({
119
+ mode: "reflect",
120
+ converter: totalConverter
121
+ })], Pagination.prototype, "total", void 0);
122
+ __decorate([attr({
123
+ mode: "reflect",
124
+ converter: totalConverter,
125
+ attribute: "selected-index"
126
+ })], Pagination.prototype, "selectedIndex", void 0);
41
127
  //#endregion
42
- //#region src/lib/platform-switch/platform-switch.template.ts
43
- var PlatformSwitchTemplate = () => {
44
- return html`<slot ${slotted("slottedContent")}></slot>`;
128
+ //#region src/lib/pagination/pagination.template.ts
129
+ var ALLOWED_SIZES = [
130
+ Size.SuperCondensed,
131
+ Size.Condensed,
132
+ Size.Normal
133
+ ];
134
+ var ALLOWED_SHAPES = [Shape.Rounded, Shape.Pill];
135
+ var handleSelection = (value, { parent: x }) => {
136
+ return x.selectedIndex = Number(value) - 1;
137
+ };
138
+ var handleKeyDown = (value, { event, parent }) => {
139
+ if (event.key === " " || event.key === "Enter") handleSelection(value, { parent });
140
+ if (event.key === "Tab") event.target.dispatchEvent(new CustomEvent("tabpressed", {
141
+ detail: {
142
+ value,
143
+ shiftKey: event.shiftKey
144
+ },
145
+ bubbles: true,
146
+ composed: true
147
+ }));
148
+ };
149
+ var getClasses = (_) => classNames("control");
150
+ function getButtonAppearance(value, { parent }) {
151
+ return parent.selectedIndex === Number(value) - 1 ? "filled" : "ghost";
152
+ }
153
+ var paginationButtonRenderer = (buttonTag) => html` ${when((value) => value !== "...", html`
154
+ <${buttonTag} class="vwc-pagination-button"
155
+ label="${(value) => value}"
156
+ appearance="${getButtonAppearance}"
157
+ size="${(_, { parent: x }) => getPaginationSize(x)}"
158
+ shape="${(_, { parent: x }) => getPaginationShape(x)}"
159
+ style="inline-size: ${(value) => getPaginationButtonWidth(value)};"
160
+ tabindex="0"
161
+ aria-label="${(value, { parent: x }) => x.locale.pagination.goToPageLabel(value)}"
162
+ aria-current="${(value, { parent }) => parent.selectedIndex === Number(value) - 1}"
163
+ @click="${handleSelection}"
164
+ @keydown="${handleKeyDown}">
165
+ </${buttonTag}>
166
+ `)}
167
+ ${when((value) => value === "...", html` <div
168
+ class="dots size-${(_, { parent: x }) => getPaginationSize(x)}"
169
+ aria-hidden="true"
170
+ >
171
+ ...
172
+ </div>`)}`;
173
+ var getPaginationSize = (x) => {
174
+ if (!x.size || !ALLOWED_SIZES.includes(x.size)) return Size.SuperCondensed;
175
+ return x.size;
176
+ };
177
+ var getPaginationShape = (x) => {
178
+ if (!x.shape || !ALLOWED_SHAPES.includes(x.shape)) return Shape.Rounded;
179
+ return x.shape;
180
+ };
181
+ var getPaginationButtonWidth = (value) => {
182
+ return `calc(var(--base-size) + ${String(value).length - 1}ch)`;
183
+ };
184
+ var PaginationTemplate = (context) => {
185
+ const buttonTag = context.tagFor(Button);
186
+ const buttonTagName = context.tagFor(Button, true);
187
+ const paginationButtonTemplate = paginationButtonRenderer(buttonTag);
188
+ return html`
189
+ <div class="${getClasses}">
190
+ <${buttonTag} class="prev-button" ${ref("prevButton")}
191
+ label="${(x) => !x.navIcons ? "Previous" : null}"
192
+ icon="${(x) => x.navIcons ? "chevron-left-line" : null}"
193
+ size="${getPaginationSize}"
194
+ shape="${getPaginationShape}"
195
+ ?disabled="${(x) => x.total === 0 || x.selectedIndex === 0}"
196
+ @click="${(x) => x.selectedIndex !== void 0 && x.selectedIndex--}"
197
+ aria-label="${(x) => x.locale.pagination.previousPageLabel}"
198
+ ></${buttonTag}>
199
+ <div id="buttons-wrapper" class="buttons-wrapper" ${children({
200
+ property: "paginationButtons",
201
+ filter: elements(buttonTagName)
202
+ })}>
203
+ ${repeat((x) => x.pagesList, paginationButtonTemplate, { positioning: true })}
204
+ </div>
205
+ <${buttonTag} class="next-button" ${ref("nextButton")}
206
+ label="${(x) => !x.navIcons ? "Next" : null}"
207
+ icon="${(x) => x.navIcons ? "chevron-right-line" : null}"
208
+ size="${getPaginationSize}"
209
+ shape="${getPaginationShape}"
210
+ ?disabled="${(x) => x.total === 0 || x.selectedIndex === x.total - 1}"
211
+ @click="${(x) => x.selectedIndex !== void 0 && x.selectedIndex++}"
212
+ aria-label="${(x) => x.locale.pagination.nextPageLabel}"
213
+ ></${buttonTag}>
214
+ </div>`;
45
215
  };
46
216
  //#endregion
47
- //#region src/lib/platform-switch/definition.ts
217
+ //#region src/lib/pagination/definition.ts
48
218
  /** @internal */
49
- var platformSwitchDefinition = defineVividComponent("platform-switch", PlatformSwitch, PlatformSwitchTemplate, [], { styles: platform_switch_default });
219
+ var paginationDefinition = defineVividComponent("pagination", Pagination, PaginationTemplate, [buttonDefinition], { styles: pagination_default });
50
220
  /**
51
- * Registers the platform-switch element with the design system.
221
+ * Registers the pagination element with the design system.
52
222
  *
53
223
  * @param prefix - the prefix to use for the component name
54
224
  */
55
- var registerPlatformSwitch = createRegisterFunction(platformSwitchDefinition);
225
+ var registerPagination = createRegisterFunction(paginationDefinition);
56
226
  //#endregion
57
- export { registerPlatformSwitch as n, PlatformSwitch as r, platformSwitchDefinition as t };
227
+ export { registerPagination as n, Pagination as r, paginationDefinition as t };