@hashicorp/design-system-components 4.16.0 → 4.17.1

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 (443) hide show
  1. package/README.md +4 -8
  2. package/declarations/components/hds/advanced-table/expandable-tr-group.d.ts +2 -1
  3. package/declarations/components/hds/advanced-table/expandable-tr-group.d.ts.map +1 -1
  4. package/declarations/components/hds/advanced-table/index.d.ts +1 -2
  5. package/declarations/components/hds/advanced-table/index.d.ts.map +1 -1
  6. package/declarations/components/hds/advanced-table/td.d.ts +1 -3
  7. package/declarations/components/hds/advanced-table/td.d.ts.map +1 -1
  8. package/declarations/components/hds/advanced-table/th-sort.d.ts +1 -3
  9. package/declarations/components/hds/advanced-table/th-sort.d.ts.map +1 -1
  10. package/declarations/components/hds/advanced-table/th.d.ts +1 -3
  11. package/declarations/components/hds/advanced-table/th.d.ts.map +1 -1
  12. package/declarations/components/hds/alert/index.d.ts +2 -1
  13. package/declarations/components/hds/alert/index.d.ts.map +1 -1
  14. package/declarations/components/hds/app-footer/status-link.d.ts +3 -2
  15. package/declarations/components/hds/app-footer/status-link.d.ts.map +1 -1
  16. package/declarations/components/hds/app-header/index.d.ts +2 -1
  17. package/declarations/components/hds/app-header/index.d.ts.map +1 -1
  18. package/declarations/components/hds/app-side-nav/index.d.ts +2 -1
  19. package/declarations/components/hds/app-side-nav/index.d.ts.map +1 -1
  20. package/declarations/components/hds/app-side-nav/portal/target.d.ts.map +1 -1
  21. package/declarations/components/hds/breadcrumb/item.d.ts +1 -1
  22. package/declarations/components/hds/breadcrumb/item.d.ts.map +1 -1
  23. package/declarations/components/hds/code-block/copy-button.d.ts +5 -2
  24. package/declarations/components/hds/code-block/copy-button.d.ts.map +1 -1
  25. package/declarations/components/hds/code-block/index.d.ts +3 -0
  26. package/declarations/components/hds/code-block/index.d.ts.map +1 -1
  27. package/declarations/components/hds/code-editor/index.d.ts +6 -2
  28. package/declarations/components/hds/code-editor/index.d.ts.map +1 -1
  29. package/declarations/components/hds/code-editor/title.d.ts +1 -1
  30. package/declarations/components/hds/code-editor/title.d.ts.map +1 -1
  31. package/declarations/components/hds/dropdown/list-item/interactive.d.ts +2 -1
  32. package/declarations/components/hds/dropdown/list-item/interactive.d.ts.map +1 -1
  33. package/declarations/components/hds/dropdown/toggle/icon.d.ts +2 -1
  34. package/declarations/components/hds/dropdown/toggle/icon.d.ts.map +1 -1
  35. package/declarations/components/hds/flyout/body.d.ts +2 -1
  36. package/declarations/components/hds/flyout/body.d.ts.map +1 -1
  37. package/declarations/components/hds/flyout/description.d.ts +2 -1
  38. package/declarations/components/hds/flyout/description.d.ts.map +1 -1
  39. package/declarations/components/hds/flyout/footer.d.ts +2 -1
  40. package/declarations/components/hds/flyout/footer.d.ts.map +1 -1
  41. package/declarations/components/hds/flyout/header.d.ts +2 -1
  42. package/declarations/components/hds/flyout/header.d.ts.map +1 -1
  43. package/declarations/components/hds/form/masked-input/base.d.ts +5 -2
  44. package/declarations/components/hds/form/masked-input/base.d.ts.map +1 -1
  45. package/declarations/components/hds/form/super-select/multiple/base.d.ts +1 -1
  46. package/declarations/components/hds/form/super-select/multiple/base.d.ts.map +1 -1
  47. package/declarations/components/hds/form/super-select/single/base.d.ts +1 -1
  48. package/declarations/components/hds/form/super-select/single/base.d.ts.map +1 -1
  49. package/declarations/components/hds/form/text-input/field.d.ts +3 -2
  50. package/declarations/components/hds/form/text-input/field.d.ts.map +1 -1
  51. package/declarations/components/hds/icon/index.d.ts +2 -1
  52. package/declarations/components/hds/icon/index.d.ts.map +1 -1
  53. package/declarations/components/hds/interactive/index.d.ts.map +1 -1
  54. package/declarations/components/hds/link/inline.d.ts +2 -1
  55. package/declarations/components/hds/link/inline.d.ts.map +1 -1
  56. package/declarations/components/hds/link/standalone.d.ts +2 -1
  57. package/declarations/components/hds/link/standalone.d.ts.map +1 -1
  58. package/declarations/components/hds/menu-primitive/index.d.ts +2 -1
  59. package/declarations/components/hds/menu-primitive/index.d.ts.map +1 -1
  60. package/declarations/components/hds/modal/body.d.ts +2 -1
  61. package/declarations/components/hds/modal/body.d.ts.map +1 -1
  62. package/declarations/components/hds/modal/footer.d.ts +2 -1
  63. package/declarations/components/hds/modal/footer.d.ts.map +1 -1
  64. package/declarations/components/hds/modal/header.d.ts +2 -1
  65. package/declarations/components/hds/modal/header.d.ts.map +1 -1
  66. package/declarations/components/hds/pagination/compact/index.d.ts +2 -1
  67. package/declarations/components/hds/pagination/compact/index.d.ts.map +1 -1
  68. package/declarations/components/hds/pagination/numbered/index.d.ts +2 -1
  69. package/declarations/components/hds/pagination/numbered/index.d.ts.map +1 -1
  70. package/declarations/components/hds/popover-primitive/index.d.ts +2 -1
  71. package/declarations/components/hds/popover-primitive/index.d.ts.map +1 -1
  72. package/declarations/components/hds/side-nav/header/icon-button.d.ts +2 -1
  73. package/declarations/components/hds/side-nav/header/icon-button.d.ts.map +1 -1
  74. package/declarations/components/hds/side-nav/index.d.ts +2 -1
  75. package/declarations/components/hds/side-nav/index.d.ts.map +1 -1
  76. package/declarations/components/hds/side-nav/portal/target.d.ts.map +1 -1
  77. package/declarations/components/hds/stepper/task/indicator.d.ts +1 -1
  78. package/declarations/components/hds/table/index.d.ts +2 -1
  79. package/declarations/components/hds/table/index.d.ts.map +1 -1
  80. package/declarations/components/hds/table/th-selectable.d.ts +3 -3
  81. package/declarations/components/hds/table/th-selectable.d.ts.map +1 -1
  82. package/declarations/components/hds/tabs/index.d.ts +2 -1
  83. package/declarations/components/hds/tabs/index.d.ts.map +1 -1
  84. package/declarations/components/hds/tag/index.d.ts +16 -0
  85. package/declarations/components/hds/tag/index.d.ts.map +1 -1
  86. package/declarations/components/hds/tag/types.d.ts +15 -0
  87. package/declarations/components/hds/tag/types.d.ts.map +1 -1
  88. package/declarations/components/hds/time/index.d.ts.map +1 -1
  89. package/declarations/helpers/hds-format-date.d.ts +16 -3
  90. package/declarations/helpers/hds-format-date.d.ts.map +1 -1
  91. package/declarations/helpers/hds-format-relative.d.ts +9 -3
  92. package/declarations/helpers/hds-format-relative.d.ts.map +1 -1
  93. package/declarations/helpers/hds-link-to-models.d.ts +7 -1
  94. package/declarations/helpers/hds-link-to-models.d.ts.map +1 -1
  95. package/declarations/helpers/hds-link-to-query.d.ts +9 -3
  96. package/declarations/helpers/hds-link-to-query.d.ts.map +1 -1
  97. package/declarations/instance-initializers/load-sprite.d.ts.map +1 -1
  98. package/declarations/{components/hds/advanced-table/helpers.d.ts → modifiers/hds-advanced-table-cell/dom-management.d.ts} +3 -4
  99. package/declarations/modifiers/hds-advanced-table-cell/dom-management.d.ts.map +1 -0
  100. package/declarations/modifiers/hds-advanced-table-cell/keyboard-navigation.d.ts +6 -0
  101. package/declarations/modifiers/hds-advanced-table-cell/keyboard-navigation.d.ts.map +1 -0
  102. package/declarations/modifiers/hds-advanced-table-cell.d.ts +26 -0
  103. package/declarations/modifiers/hds-advanced-table-cell.d.ts.map +1 -0
  104. package/declarations/modifiers/hds-clipboard.d.ts.map +1 -1
  105. package/declarations/modifiers/hds-code-editor/languages/rego.d.ts +48 -0
  106. package/declarations/modifiers/hds-code-editor/languages/rego.d.ts.map +1 -0
  107. package/declarations/modifiers/hds-code-editor/languages/sentinel.d.ts +4 -0
  108. package/declarations/modifiers/hds-code-editor/languages/sentinel.d.ts.map +1 -1
  109. package/declarations/modifiers/hds-code-editor/types.d.ts +2 -0
  110. package/declarations/modifiers/hds-code-editor/types.d.ts.map +1 -1
  111. package/declarations/modifiers/hds-code-editor.d.ts +9 -5
  112. package/declarations/modifiers/hds-code-editor.d.ts.map +1 -1
  113. package/declarations/modifiers/hds-tooltip.d.ts +4 -2
  114. package/declarations/modifiers/hds-tooltip.d.ts.map +1 -1
  115. package/declarations/services/hds-time-types.d.ts +7 -7
  116. package/declarations/services/hds-time-types.d.ts.map +1 -1
  117. package/declarations/services/hds-time.d.ts +3 -3
  118. package/declarations/services/hds-time.d.ts.map +1 -1
  119. package/declarations/template-registry.d.ts +2 -0
  120. package/declarations/template-registry.d.ts.map +1 -1
  121. package/dist/README.md +4 -8
  122. package/dist/_app_/modifiers/hds-advanced-table-cell/dom-management.js +1 -0
  123. package/dist/_app_/modifiers/hds-advanced-table-cell/keyboard-navigation.js +1 -0
  124. package/dist/_app_/modifiers/hds-advanced-table-cell.js +1 -0
  125. package/dist/_app_/modifiers/hds-code-editor/languages/rego.js +1 -0
  126. package/dist/components/hds/accordion/index.js.map +1 -1
  127. package/dist/components/hds/accordion/item/button.js +11 -4
  128. package/dist/components/hds/accordion/item/button.js.map +1 -1
  129. package/dist/components/hds/accordion/item/index.js +12 -11
  130. package/dist/components/hds/accordion/item/index.js.map +1 -1
  131. package/dist/components/hds/advanced-table/expandable-tr-group.js +16 -12
  132. package/dist/components/hds/advanced-table/expandable-tr-group.js.map +1 -1
  133. package/dist/components/hds/advanced-table/index.js +69 -53
  134. package/dist/components/hds/advanced-table/index.js.map +1 -1
  135. package/dist/components/hds/advanced-table/td.js +30 -36
  136. package/dist/components/hds/advanced-table/td.js.map +1 -1
  137. package/dist/components/hds/advanced-table/th-button-expand.js +13 -9
  138. package/dist/components/hds/advanced-table/th-button-expand.js.map +1 -1
  139. package/dist/components/hds/advanced-table/th-button-sort.js +8 -7
  140. package/dist/components/hds/advanced-table/th-button-sort.js.map +1 -1
  141. package/dist/components/hds/advanced-table/th-button-tooltip.js +7 -6
  142. package/dist/components/hds/advanced-table/th-button-tooltip.js.map +1 -1
  143. package/dist/components/hds/advanced-table/th-selectable.js +25 -17
  144. package/dist/components/hds/advanced-table/th-selectable.js.map +1 -1
  145. package/dist/components/hds/advanced-table/th-sort.js +30 -37
  146. package/dist/components/hds/advanced-table/th-sort.js.map +1 -1
  147. package/dist/components/hds/advanced-table/th.js +29 -36
  148. package/dist/components/hds/advanced-table/th.js.map +1 -1
  149. package/dist/components/hds/advanced-table/tr.js.map +1 -1
  150. package/dist/components/hds/alert/description.js.map +1 -1
  151. package/dist/components/hds/alert/index.js +19 -16
  152. package/dist/components/hds/alert/index.js.map +1 -1
  153. package/dist/components/hds/alert/title.js.map +1 -1
  154. package/dist/components/hds/app-footer/copyright.js.map +1 -1
  155. package/dist/components/hds/app-footer/index.js.map +1 -1
  156. package/dist/components/hds/app-footer/item.js.map +1 -1
  157. package/dist/components/hds/app-footer/legal-links.js.map +1 -1
  158. package/dist/components/hds/app-footer/link.js.map +1 -1
  159. package/dist/components/hds/app-footer/status-link.js.map +1 -1
  160. package/dist/components/hds/app-frame/index.js.map +1 -1
  161. package/dist/components/hds/app-frame/parts/footer.js.map +1 -1
  162. package/dist/components/hds/app-frame/parts/header.js.map +1 -1
  163. package/dist/components/hds/app-frame/parts/main.js.map +1 -1
  164. package/dist/components/hds/app-frame/parts/modals.js.map +1 -1
  165. package/dist/components/hds/app-frame/parts/sidebar.js.map +1 -1
  166. package/dist/components/hds/app-header/home-link.js.map +1 -1
  167. package/dist/components/hds/app-header/index.js +42 -34
  168. package/dist/components/hds/app-header/index.js.map +1 -1
  169. package/dist/components/hds/app-header/menu-button.js +11 -4
  170. package/dist/components/hds/app-header/menu-button.js.map +1 -1
  171. package/dist/components/hds/app-side-nav/index.js +44 -31
  172. package/dist/components/hds/app-side-nav/index.js.map +1 -1
  173. package/dist/components/hds/app-side-nav/list/back-link.js.map +1 -1
  174. package/dist/components/hds/app-side-nav/list/index.js +15 -13
  175. package/dist/components/hds/app-side-nav/list/index.js.map +1 -1
  176. package/dist/components/hds/app-side-nav/list/item.js.map +1 -1
  177. package/dist/components/hds/app-side-nav/list/link.js.map +1 -1
  178. package/dist/components/hds/app-side-nav/list/title.js +13 -9
  179. package/dist/components/hds/app-side-nav/list/title.js.map +1 -1
  180. package/dist/components/hds/app-side-nav/portal/index.js.map +1 -1
  181. package/dist/components/hds/app-side-nav/portal/target.js +31 -28
  182. package/dist/components/hds/app-side-nav/portal/target.js.map +1 -1
  183. package/dist/components/hds/app-side-nav/toggle-button.js.map +1 -1
  184. package/dist/components/hds/application-state/body.js.map +1 -1
  185. package/dist/components/hds/application-state/footer.js.map +1 -1
  186. package/dist/components/hds/application-state/header.js.map +1 -1
  187. package/dist/components/hds/application-state/index.js.map +1 -1
  188. package/dist/components/hds/application-state/media.js.map +1 -1
  189. package/dist/components/hds/badge/index.js.map +1 -1
  190. package/dist/components/hds/badge-count/index.js.map +1 -1
  191. package/dist/components/hds/breadcrumb/index.js.map +1 -1
  192. package/dist/components/hds/breadcrumb/item.js +1 -1
  193. package/dist/components/hds/breadcrumb/item.js.map +1 -1
  194. package/dist/components/hds/breadcrumb/truncation.js.map +1 -1
  195. package/dist/components/hds/button/index.js.map +1 -1
  196. package/dist/components/hds/button-set/index.js.map +1 -1
  197. package/dist/components/hds/card/container.js.map +1 -1
  198. package/dist/components/hds/code-block/copy-button.js +9 -5
  199. package/dist/components/hds/code-block/copy-button.js.map +1 -1
  200. package/dist/components/hds/code-block/description.js.map +1 -1
  201. package/dist/components/hds/code-block/index.js +27 -21
  202. package/dist/components/hds/code-block/index.js.map +1 -1
  203. package/dist/components/hds/code-block/title.js.map +1 -1
  204. package/dist/components/hds/code-editor/description.js +6 -5
  205. package/dist/components/hds/code-editor/description.js.map +1 -1
  206. package/dist/components/hds/code-editor/full-screen-button.js.map +1 -1
  207. package/dist/components/hds/code-editor/generic.js.map +1 -1
  208. package/dist/components/hds/code-editor/index.js +67 -52
  209. package/dist/components/hds/code-editor/index.js.map +1 -1
  210. package/dist/components/hds/code-editor/title.js +6 -5
  211. package/dist/components/hds/code-editor/title.js.map +1 -1
  212. package/dist/components/hds/copy/button/index.js +23 -20
  213. package/dist/components/hds/copy/button/index.js.map +1 -1
  214. package/dist/components/hds/copy/snippet/index.js +23 -20
  215. package/dist/components/hds/copy/snippet/index.js.map +1 -1
  216. package/dist/components/hds/dialog-primitive/body.js.map +1 -1
  217. package/dist/components/hds/dialog-primitive/description.js.map +1 -1
  218. package/dist/components/hds/dialog-primitive/footer.js.map +1 -1
  219. package/dist/components/hds/dialog-primitive/header.js.map +1 -1
  220. package/dist/components/hds/dialog-primitive/overlay.js.map +1 -1
  221. package/dist/components/hds/dialog-primitive/wrapper.js.map +1 -1
  222. package/dist/components/hds/disclosure-primitive/index.js +27 -21
  223. package/dist/components/hds/disclosure-primitive/index.js.map +1 -1
  224. package/dist/components/hds/dismiss-button/index.js.map +1 -1
  225. package/dist/components/hds/dropdown/footer.js.map +1 -1
  226. package/dist/components/hds/dropdown/header.js.map +1 -1
  227. package/dist/components/hds/dropdown/index.js +12 -5
  228. package/dist/components/hds/dropdown/index.js.map +1 -1
  229. package/dist/components/hds/dropdown/list-item/checkbox.js.map +1 -1
  230. package/dist/components/hds/dropdown/list-item/checkmark.js.map +1 -1
  231. package/dist/components/hds/dropdown/list-item/copy-item.js.map +1 -1
  232. package/dist/components/hds/dropdown/list-item/description.js.map +1 -1
  233. package/dist/components/hds/dropdown/list-item/generic.js.map +1 -1
  234. package/dist/components/hds/dropdown/list-item/interactive.js.map +1 -1
  235. package/dist/components/hds/dropdown/list-item/radio.js.map +1 -1
  236. package/dist/components/hds/dropdown/list-item/separator.js.map +1 -1
  237. package/dist/components/hds/dropdown/list-item/title.js.map +1 -1
  238. package/dist/components/hds/dropdown/toggle/button.js +12 -10
  239. package/dist/components/hds/dropdown/toggle/button.js.map +1 -1
  240. package/dist/components/hds/dropdown/toggle/chevron.js.map +1 -1
  241. package/dist/components/hds/dropdown/toggle/icon.js +20 -12
  242. package/dist/components/hds/dropdown/toggle/icon.js.map +1 -1
  243. package/dist/components/hds/flyout/body.js +2 -1
  244. package/dist/components/hds/flyout/body.js.map +1 -1
  245. package/dist/components/hds/flyout/description.js +1 -0
  246. package/dist/components/hds/flyout/description.js.map +1 -1
  247. package/dist/components/hds/flyout/footer.js +2 -1
  248. package/dist/components/hds/flyout/footer.js.map +1 -1
  249. package/dist/components/hds/flyout/header.js +2 -1
  250. package/dist/components/hds/flyout/header.js.map +1 -1
  251. package/dist/components/hds/flyout/index.js +33 -18
  252. package/dist/components/hds/flyout/index.js.map +1 -1
  253. package/dist/components/hds/form/character-count/index.js.map +1 -1
  254. package/dist/components/hds/form/checkbox/base.js.map +1 -1
  255. package/dist/components/hds/form/checkbox/field.js.map +1 -1
  256. package/dist/components/hds/form/checkbox/group.js.map +1 -1
  257. package/dist/components/hds/form/error/index.js.map +1 -1
  258. package/dist/components/hds/form/error/message.js.map +1 -1
  259. package/dist/components/hds/form/field/index.js +15 -7
  260. package/dist/components/hds/form/field/index.js.map +1 -1
  261. package/dist/components/hds/form/fieldset/index.js +15 -7
  262. package/dist/components/hds/form/fieldset/index.js.map +1 -1
  263. package/dist/components/hds/form/file-input/base.js.map +1 -1
  264. package/dist/components/hds/form/file-input/field.js.map +1 -1
  265. package/dist/components/hds/form/helper-text/index.js.map +1 -1
  266. package/dist/components/hds/form/indicator/index.js.map +1 -1
  267. package/dist/components/hds/form/label/index.js.map +1 -1
  268. package/dist/components/hds/form/legend/index.js.map +1 -1
  269. package/dist/components/hds/form/masked-input/base.js +45 -15
  270. package/dist/components/hds/form/masked-input/base.js.map +1 -1
  271. package/dist/components/hds/form/masked-input/field.js.map +1 -1
  272. package/dist/components/hds/form/radio/base.js.map +1 -1
  273. package/dist/components/hds/form/radio/field.js.map +1 -1
  274. package/dist/components/hds/form/radio/group.js.map +1 -1
  275. package/dist/components/hds/form/radio-card/description.js.map +1 -1
  276. package/dist/components/hds/form/radio-card/group.js.map +1 -1
  277. package/dist/components/hds/form/radio-card/index.js.map +1 -1
  278. package/dist/components/hds/form/radio-card/label.js.map +1 -1
  279. package/dist/components/hds/form/select/base.js.map +1 -1
  280. package/dist/components/hds/form/select/field.js.map +1 -1
  281. package/dist/components/hds/form/super-select/after-options.js.map +1 -1
  282. package/dist/components/hds/form/super-select/multiple/base.js +38 -28
  283. package/dist/components/hds/form/super-select/multiple/base.js.map +1 -1
  284. package/dist/components/hds/form/super-select/multiple/field.js.map +1 -1
  285. package/dist/components/hds/form/super-select/option-group.js +11 -10
  286. package/dist/components/hds/form/super-select/option-group.js.map +1 -1
  287. package/dist/components/hds/form/super-select/placeholder.js.map +1 -1
  288. package/dist/components/hds/form/super-select/single/base.js +17 -12
  289. package/dist/components/hds/form/super-select/single/base.js.map +1 -1
  290. package/dist/components/hds/form/super-select/single/field.js.map +1 -1
  291. package/dist/components/hds/form/text-input/base.js.map +1 -1
  292. package/dist/components/hds/form/text-input/field.js +21 -18
  293. package/dist/components/hds/form/text-input/field.js.map +1 -1
  294. package/dist/components/hds/form/textarea/base.js.map +1 -1
  295. package/dist/components/hds/form/textarea/field.js.map +1 -1
  296. package/dist/components/hds/form/toggle/base.js.map +1 -1
  297. package/dist/components/hds/form/toggle/field.js.map +1 -1
  298. package/dist/components/hds/form/toggle/group.js.map +1 -1
  299. package/dist/components/hds/form/visibility-toggle/index.js.map +1 -1
  300. package/dist/components/hds/icon/index.js +7 -3
  301. package/dist/components/hds/icon/index.js.map +1 -1
  302. package/dist/components/hds/icon-tile/index.js.map +1 -1
  303. package/dist/components/hds/interactive/index.js +12 -5
  304. package/dist/components/hds/interactive/index.js.map +1 -1
  305. package/dist/components/hds/link/inline.js.map +1 -1
  306. package/dist/components/hds/link/standalone.js.map +1 -1
  307. package/dist/components/hds/menu-primitive/index.js +37 -24
  308. package/dist/components/hds/menu-primitive/index.js.map +1 -1
  309. package/dist/components/hds/modal/body.js +1 -0
  310. package/dist/components/hds/modal/body.js.map +1 -1
  311. package/dist/components/hds/modal/footer.js +2 -1
  312. package/dist/components/hds/modal/footer.js.map +1 -1
  313. package/dist/components/hds/modal/header.js +1 -0
  314. package/dist/components/hds/modal/header.js.map +1 -1
  315. package/dist/components/hds/modal/index.js +30 -16
  316. package/dist/components/hds/modal/index.js.map +1 -1
  317. package/dist/components/hds/page-header/actions.js.map +1 -1
  318. package/dist/components/hds/page-header/badges.js.map +1 -1
  319. package/dist/components/hds/page-header/description.js.map +1 -1
  320. package/dist/components/hds/page-header/index.js.map +1 -1
  321. package/dist/components/hds/page-header/subtitle.js.map +1 -1
  322. package/dist/components/hds/page-header/title.js.map +1 -1
  323. package/dist/components/hds/pagination/compact/index.js +31 -28
  324. package/dist/components/hds/pagination/compact/index.js.map +1 -1
  325. package/dist/components/hds/pagination/info/index.js.map +1 -1
  326. package/dist/components/hds/pagination/nav/arrow.js +10 -4
  327. package/dist/components/hds/pagination/nav/arrow.js.map +1 -1
  328. package/dist/components/hds/pagination/nav/ellipsis.js.map +1 -1
  329. package/dist/components/hds/pagination/nav/number.js +10 -4
  330. package/dist/components/hds/pagination/nav/number.js.map +1 -1
  331. package/dist/components/hds/pagination/numbered/index.js +44 -47
  332. package/dist/components/hds/pagination/numbered/index.js.map +1 -1
  333. package/dist/components/hds/pagination/size-selector/index.js +12 -8
  334. package/dist/components/hds/pagination/size-selector/index.js.map +1 -1
  335. package/dist/components/hds/popover-primitive/index.js +130 -103
  336. package/dist/components/hds/popover-primitive/index.js.map +1 -1
  337. package/dist/components/hds/reveal/index.js +26 -24
  338. package/dist/components/hds/reveal/index.js.map +1 -1
  339. package/dist/components/hds/reveal/toggle/button.js.map +1 -1
  340. package/dist/components/hds/rich-tooltip/bubble.js.map +1 -1
  341. package/dist/components/hds/rich-tooltip/index.js +8 -7
  342. package/dist/components/hds/rich-tooltip/index.js.map +1 -1
  343. package/dist/components/hds/rich-tooltip/toggle.js.map +1 -1
  344. package/dist/components/hds/segmented-group/index.js.map +1 -1
  345. package/dist/components/hds/separator/index.js.map +1 -1
  346. package/dist/components/hds/side-nav/base.js.map +1 -1
  347. package/dist/components/hds/side-nav/header/home-link.js.map +1 -1
  348. package/dist/components/hds/side-nav/header/icon-button.js +1 -0
  349. package/dist/components/hds/side-nav/header/icon-button.js.map +1 -1
  350. package/dist/components/hds/side-nav/header/index.js.map +1 -1
  351. package/dist/components/hds/side-nav/index.js +47 -34
  352. package/dist/components/hds/side-nav/index.js.map +1 -1
  353. package/dist/components/hds/side-nav/list/back-link.js.map +1 -1
  354. package/dist/components/hds/side-nav/list/index.js +15 -13
  355. package/dist/components/hds/side-nav/list/index.js.map +1 -1
  356. package/dist/components/hds/side-nav/list/item.js.map +1 -1
  357. package/dist/components/hds/side-nav/list/link.js.map +1 -1
  358. package/dist/components/hds/side-nav/list/title.js +13 -9
  359. package/dist/components/hds/side-nav/list/title.js.map +1 -1
  360. package/dist/components/hds/side-nav/portal/index.js.map +1 -1
  361. package/dist/components/hds/side-nav/portal/target.js +31 -28
  362. package/dist/components/hds/side-nav/portal/target.js.map +1 -1
  363. package/dist/components/hds/side-nav/toggle-button.js.map +1 -1
  364. package/dist/components/hds/stepper/step/indicator.js.map +1 -1
  365. package/dist/components/hds/stepper/task/indicator.js.map +1 -1
  366. package/dist/components/hds/table/index.js +54 -40
  367. package/dist/components/hds/table/index.js.map +1 -1
  368. package/dist/components/hds/table/td.js.map +1 -1
  369. package/dist/components/hds/table/th-button-sort.js +8 -7
  370. package/dist/components/hds/table/th-button-sort.js.map +1 -1
  371. package/dist/components/hds/table/th-button-tooltip.js +7 -6
  372. package/dist/components/hds/table/th-button-tooltip.js.map +1 -1
  373. package/dist/components/hds/table/th-selectable.js +24 -25
  374. package/dist/components/hds/table/th-selectable.js.map +1 -1
  375. package/dist/components/hds/table/th-sort.js +12 -10
  376. package/dist/components/hds/table/th-sort.js.map +1 -1
  377. package/dist/components/hds/table/th.js +12 -10
  378. package/dist/components/hds/table/th.js.map +1 -1
  379. package/dist/components/hds/table/tr.js.map +1 -1
  380. package/dist/components/hds/tabs/index.js +77 -54
  381. package/dist/components/hds/tabs/index.js.map +1 -1
  382. package/dist/components/hds/tabs/panel.js +21 -14
  383. package/dist/components/hds/tabs/panel.js.map +1 -1
  384. package/dist/components/hds/tabs/tab.js +29 -13
  385. package/dist/components/hds/tabs/tab.js.map +1 -1
  386. package/dist/components/hds/tag/index.js +43 -3
  387. package/dist/components/hds/tag/index.js.map +1 -1
  388. package/dist/components/hds/tag/types.js +16 -1
  389. package/dist/components/hds/tag/types.js.map +1 -1
  390. package/dist/components/hds/text/body.js.map +1 -1
  391. package/dist/components/hds/text/code.js.map +1 -1
  392. package/dist/components/hds/text/display.js.map +1 -1
  393. package/dist/components/hds/text/index.js.map +1 -1
  394. package/dist/components/hds/time/index.js +19 -14
  395. package/dist/components/hds/time/index.js.map +1 -1
  396. package/dist/components/hds/time/range.js +11 -12
  397. package/dist/components/hds/time/range.js.map +1 -1
  398. package/dist/components/hds/time/single.js.map +1 -1
  399. package/dist/components/hds/toast/index.js.map +1 -1
  400. package/dist/components/hds/tooltip-button/index.js.map +1 -1
  401. package/dist/components/hds/yield/index.js.map +1 -1
  402. package/dist/components.js +1 -1
  403. package/dist/helpers/hds-format-date.js.map +1 -1
  404. package/dist/helpers/hds-format-relative.js.map +1 -1
  405. package/dist/helpers/hds-link-to-query.js.map +1 -1
  406. package/dist/instance-initializers/load-sprite.js +3 -1
  407. package/dist/instance-initializers/load-sprite.js.map +1 -1
  408. package/dist/modifiers/hds-advanced-table-cell/dom-management.js +51 -0
  409. package/dist/modifiers/hds-advanced-table-cell/dom-management.js.map +1 -0
  410. package/dist/{components/hds/advanced-table/helpers.js → modifiers/hds-advanced-table-cell/keyboard-navigation.js} +5 -44
  411. package/dist/modifiers/hds-advanced-table-cell/keyboard-navigation.js.map +1 -0
  412. package/dist/modifiers/hds-advanced-table-cell.js +55 -0
  413. package/dist/modifiers/hds-advanced-table-cell.js.map +1 -0
  414. package/dist/modifiers/hds-clipboard.js +29 -35
  415. package/dist/modifiers/hds-clipboard.js.map +1 -1
  416. package/dist/modifiers/hds-code-editor/languages/rego.js +191 -0
  417. package/dist/modifiers/hds-code-editor/languages/rego.js.map +1 -0
  418. package/dist/modifiers/hds-code-editor/languages/sentinel.js +5 -0
  419. package/dist/modifiers/hds-code-editor/languages/sentinel.js.map +1 -1
  420. package/dist/modifiers/hds-code-editor/types.js +2 -0
  421. package/dist/modifiers/hds-code-editor/types.js.map +1 -1
  422. package/dist/modifiers/hds-code-editor.js +182 -155
  423. package/dist/modifiers/hds-code-editor.js.map +1 -1
  424. package/dist/modifiers/hds-tooltip.js +128 -108
  425. package/dist/modifiers/hds-tooltip.js.map +1 -1
  426. package/dist/services/hds-time.js +29 -23
  427. package/dist/services/hds-time.js.map +1 -1
  428. package/dist/styles/@hashicorp/design-system-components.css +94 -3
  429. package/dist/styles/components/advanced-table.scss +4 -0
  430. package/dist/styles/components/badge-count.scss +1 -1
  431. package/dist/styles/components/badge.scss +11 -1
  432. package/dist/styles/components/rich-tooltip.scss +3 -1
  433. package/dist/styles/components/tag.scss +28 -0
  434. package/dist/styles/components/time.scss +7 -0
  435. package/dist/styles/components/tooltip.scss +49 -0
  436. package/dist/utils/hds-aria-described-by.js +14 -17
  437. package/dist/utils/hds-aria-described-by.js.map +1 -1
  438. package/package.json +30 -31
  439. package/declarations/components/hds/advanced-table/helpers.d.ts.map +0 -1
  440. package/dist/_app_/components/hds/advanced-table/helpers.js +0 -1
  441. package/dist/_rollupPluginBabelHelpers-C_TsMG3M.js +0 -57
  442. package/dist/_rollupPluginBabelHelpers-C_TsMG3M.js.map +0 -1
  443. package/dist/components/hds/advanced-table/helpers.js.map +0 -1
@@ -1,36 +1,43 @@
1
- import { _ as _applyDecoratedDescriptor, b as _initializerDefineProperty, a as _defineProperty } from '../../../../_rollupPluginBabelHelpers-C_TsMG3M.js';
2
1
  import Component from '@glimmer/component';
3
2
  import { tracked } from '@glimmer/tracking';
4
3
  import { action } from '@ember/object';
5
4
  import { assert } from '@ember/debug';
6
5
  import { HdsPaginationDirectionValues } from '../types.js';
7
6
  import { precompileTemplate } from '@ember/template-compilation';
7
+ import { g, i, n } from 'decorator-transforms/runtime';
8
8
  import { setComponentTemplate } from '@ember/component';
9
9
 
10
10
  var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n<div class=\"hds-pagination\" ...attributes>\n <nav class=\"hds-pagination-nav\" aria-label={{this.ariaLabel}}>\n <Hds::Pagination::Nav::Arrow\n @direction=\"prev\"\n @showLabel={{this.showLabels}}\n @route={{this.routing.route}}\n @query={{this.routing.queryPrev}}\n @model={{this.routing.model}}\n @models={{this.routing.models}}\n @replace={{this.routing.replace}}\n @onClick={{this.onPageChange}}\n @disabled={{@isDisabledPrev}}\n />\n <Hds::Pagination::Nav::Arrow\n @direction=\"next\"\n @showLabel={{this.showLabels}}\n @route={{this.routing.route}}\n @query={{this.routing.queryNext}}\n @model={{this.routing.model}}\n @models={{this.routing.models}}\n @replace={{this.routing.replace}}\n @onClick={{this.onPageChange}}\n @disabled={{@isDisabledNext}}\n />\n </nav>\n\n {{#if this.showSizeSelector}}\n <Hds::Pagination::SizeSelector\n @pageSizes={{this.pageSizes}}\n @label={{@sizeSelectorLabel}}\n @selectedSize={{this.currentPageSize}}\n @onChange={{this.onPageSizeChange}}\n />\n {{/if}}\n</div>");
11
11
 
12
- var _class, _descriptor, _descriptor2;
12
+ /**
13
+ * Copyright (c) HashiCorp, Inc.
14
+ * SPDX-License-Identifier: MPL-2.0
15
+ */
16
+
13
17
  // for context about the decision to use these values, see:
14
18
  // https://hashicorp.slack.com/archives/C03A0N1QK8S/p1673546329082759
15
19
  const DEFAULT_PAGE_SIZES = [10, 30, 50];
16
- let HdsPaginationCompact = (_class = class HdsPaginationCompact extends Component {
17
- // if the "size selector" block is visible
20
+ class HdsPaginationCompact extends Component {
21
+ static {
22
+ g(this.prototype, "_currentPageSize", [tracked]);
23
+ }
24
+ #_currentPageSize = (i(this, "_currentPageSize"), undefined); // This private variable is used to differentiate between
25
+ // "uncontrolled" component (where the state is handled internally) and
26
+ // "controlled" component (where the state is handled externally, by the consumer's code).
27
+ // In the first case, the variable stores the internal state of the component at any moment,
28
+ // and its value is updated internally according to the user's interaction with the component.
29
+ // In the second case, the variable stores *only* the initial state of the component (coming from the arguments)
30
+ // at rendering time, but from that moment on it's not updated anymore, no matter what interaction the user
31
+ // has with the component (the state is controlled externally, eg. via query parameters)
32
+ static {
33
+ g(this.prototype, "_isControlled", [tracked]);
34
+ }
35
+ #_isControlled = (i(this, "_isControlled"), undefined);
36
+ showLabels = this.args.showLabels ?? true; // if the labels for the "prev/next" controls are visible
37
+ showSizeSelector = this.args.showSizeSelector ?? false; // if the "size selector" block is visible
18
38
 
19
39
  constructor(owner, args) {
20
40
  super(owner, args);
21
- // This private variable is used to differentiate between
22
- // "uncontrolled" component (where the state is handled internally) and
23
- // "controlled" component (where the state is handled externally, by the consumer's code).
24
- // In the first case, the variable stores the internal state of the component at any moment,
25
- // and its value is updated internally according to the user's interaction with the component.
26
- // In the second case, the variable stores *only* the initial state of the component (coming from the arguments)
27
- // at rendering time, but from that moment on it's not updated anymore, no matter what interaction the user
28
- // has with the component (the state is controlled externally, eg. via query parameters)
29
- _initializerDefineProperty(this, "_currentPageSize", _descriptor, this);
30
- _initializerDefineProperty(this, "_isControlled", _descriptor2, this);
31
- _defineProperty(this, "showLabels", this.args.showLabels ?? true);
32
- // if the labels for the "prev/next" controls are visible
33
- _defineProperty(this, "showSizeSelector", this.args.showSizeSelector ?? false);
34
41
  const {
35
42
  queryFunction
36
43
  } = this.args;
@@ -124,6 +131,9 @@ let HdsPaginationCompact = (_class = class HdsPaginationCompact extends Componen
124
131
  onPageChange(newPage);
125
132
  }
126
133
  }
134
+ static {
135
+ n(this.prototype, "onPageChange", [action]);
136
+ }
127
137
  onPageSizeChange(newPageSize) {
128
138
  const {
129
139
  onPageSizeChange
@@ -134,17 +144,10 @@ let HdsPaginationCompact = (_class = class HdsPaginationCompact extends Componen
134
144
  onPageSizeChange(newPageSize);
135
145
  }
136
146
  }
137
- }, _descriptor = _applyDecoratedDescriptor(_class.prototype, "_currentPageSize", [tracked], {
138
- configurable: true,
139
- enumerable: true,
140
- writable: true,
141
- initializer: null
142
- }), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "_isControlled", [tracked], {
143
- configurable: true,
144
- enumerable: true,
145
- writable: true,
146
- initializer: null
147
- }), _applyDecoratedDescriptor(_class.prototype, "onPageChange", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onPageChange"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "onPageSizeChange", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onPageSizeChange"), _class.prototype), _class);
147
+ static {
148
+ n(this.prototype, "onPageSizeChange", [action]);
149
+ }
150
+ }
148
151
  setComponentTemplate(TEMPLATE, HdsPaginationCompact);
149
152
 
150
153
  export { DEFAULT_PAGE_SIZES, HdsPaginationCompact as default };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/components/hds/pagination/compact/index.hbs","../../../../../src/components/hds/pagination/compact/index.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n<div class=\\\"hds-pagination\\\" ...attributes>\\n <nav class=\\\"hds-pagination-nav\\\" aria-label={{this.ariaLabel}}>\\n <Hds::Pagination::Nav::Arrow\\n @direction=\\\"prev\\\"\\n @showLabel={{this.showLabels}}\\n @route={{this.routing.route}}\\n @query={{this.routing.queryPrev}}\\n @model={{this.routing.model}}\\n @models={{this.routing.models}}\\n @replace={{this.routing.replace}}\\n @onClick={{this.onPageChange}}\\n @disabled={{@isDisabledPrev}}\\n />\\n <Hds::Pagination::Nav::Arrow\\n @direction=\\\"next\\\"\\n @showLabel={{this.showLabels}}\\n @route={{this.routing.route}}\\n @query={{this.routing.queryNext}}\\n @model={{this.routing.model}}\\n @models={{this.routing.models}}\\n @replace={{this.routing.replace}}\\n @onClick={{this.onPageChange}}\\n @disabled={{@isDisabledNext}}\\n />\\n </nav>\\n\\n {{#if this.showSizeSelector}}\\n <Hds::Pagination::SizeSelector\\n @pageSizes={{this.pageSizes}}\\n @label={{@sizeSelectorLabel}}\\n @selectedSize={{this.currentPageSize}}\\n @onChange={{this.onPageSizeChange}}\\n />\\n {{/if}}\\n</div>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport { HdsPaginationDirectionValues } from '../types.ts';\n\nimport type {\n HdsPaginationRoutingProps,\n HdsPaginationDirections,\n} from '../types';\nimport type { HdsInteractiveSignature } from '../../interactive';\n\ntype HdsInteractiveQuery = HdsInteractiveSignature['Args']['query'];\n\ntype HdsPaginationCompactRoutingQueryProps = HdsPaginationRoutingProps & {\n queryNext?: HdsInteractiveQuery;\n queryPrev?: HdsInteractiveQuery;\n};\n\ntype HdsPaginationQueryFunction = (\n page: HdsPaginationDirections,\n pageSize?: number\n) => HdsInteractiveQuery;\n\ninterface HdsPaginationCompactArgs extends HdsPaginationRoutingProps {\n ariaLabel?: string;\n showLabels?: boolean;\n isDisabledPrev?: boolean;\n isDisabledNext?: boolean;\n showSizeSelector?: boolean;\n sizeSelectorLabel?: string;\n pageSizes?: number[];\n currentPageSize?: number;\n queryFunction?: HdsPaginationQueryFunction;\n onPageChange?: (page: HdsPaginationDirections) => void;\n onPageSizeChange?: (pageSize: number) => void;\n}\n\ninterface HdsPaginationCompactArgsControlledBase\n extends HdsPaginationCompactArgs {\n queryFunction: HdsPaginationQueryFunction;\n}\n\ninterface HdsPaginationCompactArgsControlledWithModel\n extends HdsPaginationCompactArgsControlledBase {\n model: string | number;\n}\n\ninterface HdsPaginationCompactArgsControlledWithModels\n extends HdsPaginationCompactArgsControlledBase {\n models: Array<string | number>;\n}\ninterface HdsPaginationCompactArgsControlledWithRoute\n extends HdsPaginationCompactArgsControlledBase {\n route: string;\n}\n\ntype HdsPaginationCompactArgsControlled =\n | HdsPaginationCompactArgsControlledWithModel\n | HdsPaginationCompactArgsControlledWithModels\n | HdsPaginationCompactArgsControlledWithRoute;\n\ninterface HdsPaginationCompactArgsUncontrolled\n extends HdsPaginationCompactArgs {\n queryFunction?: undefined;\n}\n\nexport interface HdsPaginationCompactSignature {\n Args:\n | HdsPaginationCompactArgsControlled\n | HdsPaginationCompactArgsUncontrolled;\n Element: HTMLDivElement;\n}\n\n// for context about the decision to use these values, see:\n// https://hashicorp.slack.com/archives/C03A0N1QK8S/p1673546329082759\nexport const DEFAULT_PAGE_SIZES = [10, 30, 50];\nexport default class HdsPaginationCompact extends Component<HdsPaginationCompactSignature> {\n // This private variable is used to differentiate between\n // \"uncontrolled\" component (where the state is handled internally) and\n // \"controlled\" component (where the state is handled externally, by the consumer's code).\n // In the first case, the variable stores the internal state of the component at any moment,\n // and its value is updated internally according to the user's interaction with the component.\n // In the second case, the variable stores *only* the initial state of the component (coming from the arguments)\n // at rendering time, but from that moment on it's not updated anymore, no matter what interaction the user\n // has with the component (the state is controlled externally, eg. via query parameters)\n @tracked private _currentPageSize;\n @tracked private _isControlled;\n\n showLabels = this.args.showLabels ?? true; // if the labels for the \"prev/next\" controls are visible\n showSizeSelector = this.args.showSizeSelector ?? false; // if the \"size selector\" block is visible\n\n constructor(owner: unknown, args: HdsPaginationCompactSignature['Args']) {\n super(owner, args);\n\n const { queryFunction } = this.args;\n\n // This component works in two different ways, depending if we need to support\n // routing through links (`LinkTo`) for the \"navigation controls\", or not.\n // If there's no routing then the component behaves as \"uncontrolled\"\n // (the state updates are handled by its internal logic).\n // If instead the component needs to update the routing (and we infer this via the \"query\" arguments)\n // then the component behaves as \"controlled\", where the state is\n // initialized and updated using the arguments passed to it.\n\n if (queryFunction === undefined) {\n this._isControlled = false;\n } else {\n assert(\n '@model, @models, or @route for \"Hds::Pagination::Compact\" must be provided when using the `@queryFunction` argument',\n this.args.model !== undefined ||\n this.args.models !== undefined ||\n this.args.route !== undefined\n );\n assert(\n '@queryFunction for \"Hds::Pagination::Compact\" must be a function',\n typeof queryFunction === 'function'\n );\n this._isControlled = true;\n }\n\n // we assert that `this.pageSizes` will always be an array with at least one item\n this._currentPageSize = this.args.currentPageSize ?? this.pageSizes[0];\n }\n\n get ariaLabel(): string {\n return this.args.ariaLabel ?? 'Pagination';\n }\n\n // This very specific `get/set` pattern is used to handle the two different use cases of the component\n // being \"controlled\" (when it has routing, meaning it needs to support pagination controls as links/`LinkTo`)\n // vs being \"uncontrolled\" (see comments above for details).\n //\n // If it has routing (and so it's \"controlled\"), than the value (\"state\") of the `currentPageSize` variable\n // is *always* determined by the controller via arguments (most of the times, connected to query parameters in the URL).\n // For this reason the \"get\" method always returns the value from the `args`,\n // while the \"set\" method never updates the private internal state (_variable).\n //\n // If instead it doesn't have routing (and so it's \"uncontrolled\") than the value (\"state\") of the `currentPageSize` variables\n // is *always* determined by the component's internal logic (and updated according to the user interaction with it).\n // For this reason the \"get\" and \"set\" methods always read from or write to the private internal state (_variable).\n\n get currentPageSize(): number | undefined {\n if (this._isControlled) {\n return this.args.currentPageSize;\n } else {\n return this._currentPageSize;\n }\n }\n set currentPageSize(value) {\n if (this._isControlled) {\n // noop\n } else {\n this._currentPageSize = value;\n }\n }\n\n get pageSizes(): number[] {\n const { pageSizes = DEFAULT_PAGE_SIZES } = this.args;\n\n assert(\n `pageSizes argument must be an array. Received: ${pageSizes}`,\n Array.isArray(pageSizes) === true && pageSizes.length > 0\n );\n\n return pageSizes;\n }\n\n buildQueryParamsObject(\n page: HdsPaginationDirections,\n pageSize?: number\n ): HdsInteractiveQuery {\n if (this._isControlled) {\n // if the component is controlled, we can assert that the queryFunction is defined\n return this.args.queryFunction!(page, pageSize);\n } else {\n return {};\n }\n }\n\n get routing(): HdsPaginationCompactRoutingQueryProps {\n const routing: HdsPaginationCompactRoutingQueryProps = {\n route: this.args.route ?? undefined,\n model: this.args.model ?? undefined,\n models: this.args.models ?? undefined,\n replace: this.args.replace ?? undefined,\n };\n\n // the \"query\" is dynamic and needs to be calculated\n if (this._isControlled) {\n routing.queryPrev = this.buildQueryParamsObject(\n HdsPaginationDirectionValues.Prev,\n this.currentPageSize\n );\n routing.queryNext = this.buildQueryParamsObject(\n HdsPaginationDirectionValues.Next,\n this.currentPageSize\n );\n } else {\n routing.queryPrev = undefined;\n routing.queryNext = undefined;\n }\n\n return routing;\n }\n\n @action\n onPageChange(newPage: HdsPaginationDirections): void {\n const { onPageChange } = this.args;\n\n if (typeof onPageChange === 'function') {\n onPageChange(newPage);\n }\n }\n\n @action\n onPageSizeChange(newPageSize: number): void {\n const { onPageSizeChange } = this.args;\n\n // invoke the callback function\n if (typeof onPageSizeChange === 'function') {\n onPageSizeChange(newPageSize);\n }\n }\n}\n"],"names":["DEFAULT_PAGE_SIZES","HdsPaginationCompact","_class","Component","constructor","owner","args","_initializerDefineProperty","_descriptor","_descriptor2","_defineProperty","showLabels","showSizeSelector","queryFunction","undefined","_isControlled","assert","model","models","route","_currentPageSize","currentPageSize","pageSizes","ariaLabel","value","Array","isArray","length","buildQueryParamsObject","page","pageSize","routing","replace","queryPrev","HdsPaginationDirectionValues","Prev","queryNext","Next","onPageChange","newPage","onPageSizeChange","newPageSize","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;AACA,eAAe,kBAAkB,CAAC,isCAAisC;;;AC8EnuC;AACA;AACO,MAAMA,kBAAkB,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;AACxBC,IAAAA,oBAAoB,IAAAC,MAAA,GAA1B,MAAMD,oBAAoB,SAASE,SAAS,CAAgC;AAajC;;AAExDC,EAAAA,WAAWA,CAACC,KAAc,EAAEC,IAA2C,EAAE;AACvE,IAAA,KAAK,CAACD,KAAK,EAAEC,IAAI,CAAC;AAfpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAAC,IAAAA,0BAAA,2BAAAC,WAAA,EAAA,IAAA,CAAA;AAAAD,IAAAA,0BAAA,wBAAAE,YAAA,EAAA,IAAA,CAAA;AAAAC,IAAAA,eAAA,qBAIa,IAAI,CAACJ,IAAI,CAACK,UAAU,IAAI,IAAI,CAAA;AAAE;AAAAD,IAAAA,eAAA,2BACxB,IAAI,CAACJ,IAAI,CAACM,gBAAgB,IAAI,KAAK,CAAA;IAKpD,MAAM;AAAEC,MAAAA;KAAe,GAAG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AE;MACtCA,YAAY,CAACC,OAAO,CAAC;AACvB;AACF;EAGAC,gBAAgBA,CAACC,WAAmB,EAAQ;IAC1C,MAAM;AAAED,MAAAA;KAAkB,GAAG,IAAI,CAAClC,IAAI;;AAEtC;AACA,IAAA,IAAI,OAAOkC,gBAAgB,KAAK,UAAU,EAAE;MAC1CA,gBAAgB,CAACC,WAAW,CAAC;AAC/B;AACF;AACF,CAAC,EAAAjC,WAAA,GAAAkC,yBAAA,CAAAxC,MAAA,CAAAyC,SAAA,EAAA,kBAAA,EAAA,CA1IEC,OAAO,CAAA,EAAA;EAAAC,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;EAAAC,WAAA,EAAA;AAAA,CAAAvC,CAAAA,EAAAA,YAAA,GAAAiC,yBAAA,CAAAxC,MAAA,CAAAyC,SAAA,oBACPC,OAAO,CAAA,EAAA;EAAAC,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;EAAAC,WAAA,EAAA;AAAA,CAAA,CAAA,EAAAN,yBAAA,CAAAxC,MAAA,CAAAyC,SAAA,EAAA,cAAA,EAAA,CAuHPM,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAAjD,MAAA,CAAAyC,SAAA,EAAAzC,cAAAA,CAAAA,EAAAA,MAAA,CAAAyC,SAAA,CAAA,EAAAD,yBAAA,CAAAxC,MAAA,CAAAyC,SAAA,uBASNM,MAAM,CAAA,EAAAC,MAAA,CAAAC,wBAAA,CAAAjD,MAAA,CAAAyC,SAAA,EAAA,kBAAA,CAAA,EAAAzC,MAAA,CAAAyC,SAAA,GAAAzC,MAAA;AA1IgCkD,oBAAA,CAAAC,QAAA,EAApBpD,oBAAoB,CAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/components/hds/pagination/compact/index.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport { HdsPaginationDirectionValues } from '../types.ts';\n\nimport type {\n HdsPaginationRoutingProps,\n HdsPaginationDirections,\n} from '../types';\nimport type { HdsInteractiveSignature } from '../../interactive';\nimport type Owner from '@ember/owner';\n\ntype HdsInteractiveQuery = HdsInteractiveSignature['Args']['query'];\n\ntype HdsPaginationCompactRoutingQueryProps = HdsPaginationRoutingProps & {\n queryNext?: HdsInteractiveQuery;\n queryPrev?: HdsInteractiveQuery;\n};\n\ntype HdsPaginationQueryFunction = (\n page: HdsPaginationDirections,\n pageSize?: number\n) => HdsInteractiveQuery;\n\ninterface HdsPaginationCompactArgs extends HdsPaginationRoutingProps {\n ariaLabel?: string;\n showLabels?: boolean;\n isDisabledPrev?: boolean;\n isDisabledNext?: boolean;\n showSizeSelector?: boolean;\n sizeSelectorLabel?: string;\n pageSizes?: number[];\n currentPageSize?: number;\n queryFunction?: HdsPaginationQueryFunction;\n onPageChange?: (page: HdsPaginationDirections) => void;\n onPageSizeChange?: (pageSize: number) => void;\n}\n\ninterface HdsPaginationCompactArgsControlledBase\n extends HdsPaginationCompactArgs {\n queryFunction: HdsPaginationQueryFunction;\n}\n\ninterface HdsPaginationCompactArgsControlledWithModel\n extends HdsPaginationCompactArgsControlledBase {\n model: string | number;\n}\n\ninterface HdsPaginationCompactArgsControlledWithModels\n extends HdsPaginationCompactArgsControlledBase {\n models: Array<string | number>;\n}\ninterface HdsPaginationCompactArgsControlledWithRoute\n extends HdsPaginationCompactArgsControlledBase {\n route: string;\n}\n\ntype HdsPaginationCompactArgsControlled =\n | HdsPaginationCompactArgsControlledWithModel\n | HdsPaginationCompactArgsControlledWithModels\n | HdsPaginationCompactArgsControlledWithRoute;\n\ninterface HdsPaginationCompactArgsUncontrolled\n extends HdsPaginationCompactArgs {\n queryFunction?: undefined;\n}\n\nexport interface HdsPaginationCompactSignature {\n Args:\n | HdsPaginationCompactArgsControlled\n | HdsPaginationCompactArgsUncontrolled;\n Element: HTMLDivElement;\n}\n\n// for context about the decision to use these values, see:\n// https://hashicorp.slack.com/archives/C03A0N1QK8S/p1673546329082759\nexport const DEFAULT_PAGE_SIZES = [10, 30, 50];\nexport default class HdsPaginationCompact extends Component<HdsPaginationCompactSignature> {\n // This private variable is used to differentiate between\n // \"uncontrolled\" component (where the state is handled internally) and\n // \"controlled\" component (where the state is handled externally, by the consumer's code).\n // In the first case, the variable stores the internal state of the component at any moment,\n // and its value is updated internally according to the user's interaction with the component.\n // In the second case, the variable stores *only* the initial state of the component (coming from the arguments)\n // at rendering time, but from that moment on it's not updated anymore, no matter what interaction the user\n // has with the component (the state is controlled externally, eg. via query parameters)\n @tracked private _currentPageSize;\n @tracked private _isControlled;\n\n showLabels = this.args.showLabels ?? true; // if the labels for the \"prev/next\" controls are visible\n showSizeSelector = this.args.showSizeSelector ?? false; // if the \"size selector\" block is visible\n\n constructor(owner: Owner, args: HdsPaginationCompactSignature['Args']) {\n super(owner, args);\n\n const { queryFunction } = this.args;\n\n // This component works in two different ways, depending if we need to support\n // routing through links (`LinkTo`) for the \"navigation controls\", or not.\n // If there's no routing then the component behaves as \"uncontrolled\"\n // (the state updates are handled by its internal logic).\n // If instead the component needs to update the routing (and we infer this via the \"query\" arguments)\n // then the component behaves as \"controlled\", where the state is\n // initialized and updated using the arguments passed to it.\n\n if (queryFunction === undefined) {\n this._isControlled = false;\n } else {\n assert(\n '@model, @models, or @route for \"Hds::Pagination::Compact\" must be provided when using the `@queryFunction` argument',\n this.args.model !== undefined ||\n this.args.models !== undefined ||\n this.args.route !== undefined\n );\n assert(\n '@queryFunction for \"Hds::Pagination::Compact\" must be a function',\n typeof queryFunction === 'function'\n );\n this._isControlled = true;\n }\n\n // we assert that `this.pageSizes` will always be an array with at least one item\n this._currentPageSize = this.args.currentPageSize ?? this.pageSizes[0];\n }\n\n get ariaLabel(): string {\n return this.args.ariaLabel ?? 'Pagination';\n }\n\n // This very specific `get/set` pattern is used to handle the two different use cases of the component\n // being \"controlled\" (when it has routing, meaning it needs to support pagination controls as links/`LinkTo`)\n // vs being \"uncontrolled\" (see comments above for details).\n //\n // If it has routing (and so it's \"controlled\"), than the value (\"state\") of the `currentPageSize` variable\n // is *always* determined by the controller via arguments (most of the times, connected to query parameters in the URL).\n // For this reason the \"get\" method always returns the value from the `args`,\n // while the \"set\" method never updates the private internal state (_variable).\n //\n // If instead it doesn't have routing (and so it's \"uncontrolled\") than the value (\"state\") of the `currentPageSize` variables\n // is *always* determined by the component's internal logic (and updated according to the user interaction with it).\n // For this reason the \"get\" and \"set\" methods always read from or write to the private internal state (_variable).\n\n get currentPageSize(): number | undefined {\n if (this._isControlled) {\n return this.args.currentPageSize;\n } else {\n return this._currentPageSize;\n }\n }\n set currentPageSize(value) {\n if (this._isControlled) {\n // noop\n } else {\n this._currentPageSize = value;\n }\n }\n\n get pageSizes(): number[] {\n const { pageSizes = DEFAULT_PAGE_SIZES } = this.args;\n\n assert(\n `pageSizes argument must be an array. Received: ${pageSizes}`,\n Array.isArray(pageSizes) === true && pageSizes.length > 0\n );\n\n return pageSizes;\n }\n\n buildQueryParamsObject(\n page: HdsPaginationDirections,\n pageSize?: number\n ): HdsInteractiveQuery {\n if (this._isControlled) {\n // if the component is controlled, we can assert that the queryFunction is defined\n return this.args.queryFunction!(page, pageSize);\n } else {\n return {};\n }\n }\n\n get routing(): HdsPaginationCompactRoutingQueryProps {\n const routing: HdsPaginationCompactRoutingQueryProps = {\n route: this.args.route ?? undefined,\n model: this.args.model ?? undefined,\n models: this.args.models ?? undefined,\n replace: this.args.replace ?? undefined,\n };\n\n // the \"query\" is dynamic and needs to be calculated\n if (this._isControlled) {\n routing.queryPrev = this.buildQueryParamsObject(\n HdsPaginationDirectionValues.Prev,\n this.currentPageSize\n );\n routing.queryNext = this.buildQueryParamsObject(\n HdsPaginationDirectionValues.Next,\n this.currentPageSize\n );\n } else {\n routing.queryPrev = undefined;\n routing.queryNext = undefined;\n }\n\n return routing;\n }\n\n @action\n onPageChange(newPage: HdsPaginationDirections): void {\n const { onPageChange } = this.args;\n\n if (typeof onPageChange === 'function') {\n onPageChange(newPage);\n }\n }\n\n @action\n onPageSizeChange(newPageSize: number): void {\n const { onPageSizeChange } = this.args;\n\n // invoke the callback function\n if (typeof onPageSizeChange === 'function') {\n onPageSizeChange(newPageSize);\n }\n }\n}\n"],"names":["DEFAULT_PAGE_SIZES","HdsPaginationCompact","Component","g","prototype","tracked","i","void 0","showLabels","args","showSizeSelector","constructor","owner","queryFunction","undefined","_isControlled","assert","model","models","route","_currentPageSize","currentPageSize","pageSizes","ariaLabel","value","Array","isArray","length","buildQueryParamsObject","page","pageSize","routing","replace","queryPrev","HdsPaginationDirectionValues","Prev","queryNext","Next","onPageChange","newPage","n","action","onPageSizeChange","newPageSize","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;;AA6EA;AACA;AACO,MAAMA,kBAAkB,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;AAC9B,MAAMC,oBAAoB,SAASC,SAAS,CAAgC;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,kBAAA,EAAA,CASxFC,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,iBAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,kBAAA,CAAA,EAAAC,SAAA,EARR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EAAA;IAAAJ,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,eAAA,EAAA,CAECC,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,cAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,eAAA,CAAA,EAAAC,SAAA;EAERC,UAAU,GAAG,IAAI,CAACC,IAAI,CAACD,UAAU,IAAI,IAAI,CAAC;EAC1CE,gBAAgB,GAAG,IAAI,CAACD,IAAI,CAACC,gBAAgB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OAAOiB,OAAO;AAChB;EAGAO,YAAYA,CAACC,OAAgC,EAAQ;IACnD,MAAM;AAAED,MAAAA;KAAc,GAAG,IAAI,CAAC7B,IAAI;AAElC,IAAA,IAAI,OAAO6B,YAAY,KAAK,UAAU,EAAE;MACtCA,YAAY,CAACC,OAAO,CAAC;AACvB;AACF;AAAC,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAApC,SAAA,EAAA,cAAA,EAAA,CAPAqC,MAAM,CAAA,CAAA;AAAA;EAUPC,gBAAgBA,CAACC,WAAmB,EAAQ;IAC1C,MAAM;AAAED,MAAAA;KAAkB,GAAG,IAAI,CAACjC,IAAI;;AAEtC;AACA,IAAA,IAAI,OAAOiC,gBAAgB,KAAK,UAAU,EAAE;MAC1CA,gBAAgB,CAACC,WAAW,CAAC;AAC/B;AACF;AAAC,EAAA;IAAAH,CAAA,CAAA,IAAA,CAAApC,SAAA,EAAA,kBAAA,EAAA,CARAqC,MAAM,CAAA,CAAA;AAAA;AAST;AAACG,oBAAA,CAAAC,QAAA,EAnJoB5C,oBAAoB,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/components/hds/pagination/info/index.hbs","../../../../../src/components/hds/pagination/info/index.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n<Hds::Text::Body class=\\\"hds-pagination-info\\\" @tag=\\\"div\\\" @size=\\\"100\\\" @weight=\\\"medium\\\" ...attributes>\\n {{@itemsRangeStart}}–{{@itemsRangeEnd}}\\n {{#if this.showTotalItems}}\\n of\\n {{@totalItems}}\\n {{/if}}\\n</Hds::Text::Body>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport type { HdsPaginationNumberedSignature } from '../numbered/index';\nimport type { HdsTextBodySignature } from '../../text/body';\nexport interface HdsPaginationInfoSignature {\n Args: {\n itemsRangeStart: number;\n itemsRangeEnd: number;\n showTotalItems?: HdsPaginationNumberedSignature['Args']['showTotalItems'];\n totalItems: HdsPaginationNumberedSignature['Args']['totalItems'];\n };\n Element: HdsTextBodySignature['Element'];\n}\n\nexport default class HdsPaginationInfo extends Component<HdsPaginationInfoSignature> {\n get showTotalItems(): boolean {\n return this.args.showTotalItems ?? true;\n }\n}\n"],"names":["HdsPaginationInfo","Component","showTotalItems","args","setComponentTemplate","TEMPLATE"],"mappings":";;;;AACA,eAAe,kBAAkB,CAAC,iUAAiU;;ACDnW;AACA;AACA;AACA;;AAee,MAAMA,iBAAiB,SAASC,SAAS,CAA6B;EACnF,IAAIC,cAAcA,GAAY;AAC5B,IAAA,OAAO,IAAI,CAACC,IAAI,CAACD,cAAc,IAAI,IAAI;AACzC;AACF;AAACE,oBAAA,CAAAC,QAAA,EAJoBL,iBAAiB,CAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/components/hds/pagination/info/index.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\n\nimport Component from '@glimmer/component';\nimport type { HdsPaginationNumberedSignature } from '../numbered/index';\nimport type { HdsTextBodySignature } from '../../text/body';\nexport interface HdsPaginationInfoSignature {\n Args: {\n itemsRangeStart: number;\n itemsRangeEnd: number;\n showTotalItems?: HdsPaginationNumberedSignature['Args']['showTotalItems'];\n totalItems: HdsPaginationNumberedSignature['Args']['totalItems'];\n };\n Element: HdsTextBodySignature['Element'];\n}\n\nexport default class HdsPaginationInfo extends Component<HdsPaginationInfoSignature> {\n get showTotalItems(): boolean {\n return this.args.showTotalItems ?? true;\n }\n}\n"],"names":["HdsPaginationInfo","Component","showTotalItems","args","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAee,MAAMA,iBAAiB,SAASC,SAAS,CAA6B;EACnF,IAAIC,cAAcA,GAAY;AAC5B,IAAA,OAAO,IAAI,CAACC,IAAI,CAACD,cAAc,IAAI,IAAI;AACzC;AACF;AAACE,oBAAA,CAAAC,QAAA,EAJoBL,iBAAiB,CAAA;;;;"}
@@ -1,16 +1,19 @@
1
- import { _ as _applyDecoratedDescriptor } from '../../../../_rollupPluginBabelHelpers-C_TsMG3M.js';
2
1
  import Component from '@glimmer/component';
3
2
  import { action } from '@ember/object';
4
3
  import { assert } from '@ember/debug';
5
4
  import { HdsPaginationDirectionValues, HdsPaginationDirectionLabelValues, HdsPaginationDirectionAriaLabelValues } from '../types.js';
6
5
  import { precompileTemplate } from '@ember/template-compilation';
6
+ import { n } from 'decorator-transforms/runtime';
7
7
  import { setComponentTemplate } from '@ember/component';
8
8
 
9
9
  var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n{{#if @disabled}}\n <Hds::Interactive class={{this.classNames}} aria-label={{this.content.ariaLabel}} disabled={{true}} ...attributes>\n <Hds::Icon @name={{this.content.icon}} />\n {{#if this.showLabel}}\n <Hds::Text::Body\n class=\"hds-pagination-nav__arrow-label\"\n @tag=\"span\"\n @size=\"100\"\n @weight=\"medium\"\n aria-hidden=\"true\"\n >\n {{this.content.label}}\n </Hds::Text::Body>\n {{/if}}\n </Hds::Interactive>\n{{else}}\n <Hds::Interactive\n class={{this.classNames}}\n @route={{@route}}\n @query={{hds-link-to-query @query}}\n @models={{hds-link-to-models @model @models}}\n @replace={{@replace}}\n {{on \"click\" this.onClick}}\n aria-label={{this.content.ariaLabel}}\n ...attributes\n >\n <Hds::Icon @name={{this.content.icon}} />\n {{#if this.showLabel}}\n <Hds::Text::Body\n class=\"hds-pagination-nav__arrow-label\"\n @tag=\"span\"\n @size=\"100\"\n @weight=\"medium\"\n aria-hidden=\"true\"\n >\n {{this.content.label}}\n </Hds::Text::Body>\n {{/if}}\n </Hds::Interactive>\n{{/if}}");
10
10
 
11
- var _class;
11
+ /**
12
+ * Copyright (c) HashiCorp, Inc.
13
+ * SPDX-License-Identifier: MPL-2.0
14
+ */
12
15
  const DIRECTIONS = [HdsPaginationDirectionValues.Prev, HdsPaginationDirectionValues.Next];
13
- let HdsPaginationControlArrow = (_class = class HdsPaginationControlArrow extends Component {
16
+ class HdsPaginationControlArrow extends Component {
14
17
  get content() {
15
18
  const {
16
19
  direction
@@ -48,7 +51,10 @@ let HdsPaginationControlArrow = (_class = class HdsPaginationControlArrow extend
48
51
  onClick(this.args.direction);
49
52
  }
50
53
  }
51
- }, _applyDecoratedDescriptor(_class.prototype, "onClick", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onClick"), _class.prototype), _class);
54
+ static {
55
+ n(this.prototype, "onClick", [action]);
56
+ }
57
+ }
52
58
  setComponentTemplate(TEMPLATE, HdsPaginationControlArrow);
53
59
 
54
60
  export { DIRECTIONS, HdsPaginationControlArrow as default };
@@ -1 +1 @@
1
- {"version":3,"file":"arrow.js","sources":["../../../../../src/components/hds/pagination/nav/arrow.hbs","../../../../../src/components/hds/pagination/nav/arrow.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n{{#if @disabled}}\\n <Hds::Interactive class={{this.classNames}} aria-label={{this.content.ariaLabel}} disabled={{true}} ...attributes>\\n <Hds::Icon @name={{this.content.icon}} />\\n {{#if this.showLabel}}\\n <Hds::Text::Body\\n class=\\\"hds-pagination-nav__arrow-label\\\"\\n @tag=\\\"span\\\"\\n @size=\\\"100\\\"\\n @weight=\\\"medium\\\"\\n aria-hidden=\\\"true\\\"\\n >\\n {{this.content.label}}\\n </Hds::Text::Body>\\n {{/if}}\\n </Hds::Interactive>\\n{{else}}\\n <Hds::Interactive\\n class={{this.classNames}}\\n @route={{@route}}\\n @query={{hds-link-to-query @query}}\\n @models={{hds-link-to-models @model @models}}\\n @replace={{@replace}}\\n {{on \\\"click\\\" this.onClick}}\\n aria-label={{this.content.ariaLabel}}\\n ...attributes\\n >\\n <Hds::Icon @name={{this.content.icon}} />\\n {{#if this.showLabel}}\\n <Hds::Text::Body\\n class=\\\"hds-pagination-nav__arrow-label\\\"\\n @tag=\\\"span\\\"\\n @size=\\\"100\\\"\\n @weight=\\\"medium\\\"\\n aria-hidden=\\\"true\\\"\\n >\\n {{this.content.label}}\\n </Hds::Text::Body>\\n {{/if}}\\n </Hds::Interactive>\\n{{/if}}\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport {\n HdsPaginationDirectionValues,\n HdsPaginationDirectionAriaLabelValues,\n HdsPaginationDirectionLabelValues,\n} from '../types.ts';\n\nimport type { HdsIconSignature } from '../../icon/index.ts';\nimport type { HdsInteractiveSignature } from '../../interactive';\nimport type {\n HdsPaginationDirections,\n HdsPaginationDirectionAriaLabels,\n HdsPaginationDirectionLabels,\n} from '../types';\n\ninterface HdsPaginationControlArrowContent {\n label: HdsPaginationDirectionLabels;\n icon: HdsIconSignature['Args']['name'];\n ariaLabel: HdsPaginationDirectionAriaLabels;\n}\n\ninterface HdsPaginationControlArrowArgs {\n direction: HdsPaginationDirections;\n disabled?: boolean;\n showLabel?: boolean;\n onClick?: (direction: HdsPaginationDirections) => void;\n}\n\nexport interface HdsPaginationControlArrowSignature {\n Args: HdsPaginationControlArrowArgs & HdsInteractiveSignature['Args'];\n Element: HdsInteractiveSignature['Element'];\n}\n\nexport const DIRECTIONS: HdsPaginationDirections[] = [\n HdsPaginationDirectionValues.Prev,\n HdsPaginationDirectionValues.Next,\n];\n\nexport default class HdsPaginationControlArrow extends Component<HdsPaginationControlArrowSignature> {\n get content(): HdsPaginationControlArrowContent {\n const { direction } = this.args;\n\n assert(\n `@direction for \"Pagination::Nav::Arrow\" must be one of the following: ${DIRECTIONS.join(\n ', '\n )}; received: ${direction}`,\n DIRECTIONS.includes(direction)\n );\n\n const hdsPaginationNavArrowContentDirectionMap: Record<\n HdsPaginationDirections,\n HdsPaginationControlArrowContent\n > = {\n [HdsPaginationDirectionValues.Prev]: {\n label: HdsPaginationDirectionLabelValues.Prev,\n icon: 'chevron-left',\n ariaLabel: HdsPaginationDirectionAriaLabelValues.Prev,\n },\n [HdsPaginationDirectionValues.Next]: {\n label: HdsPaginationDirectionLabelValues.Next,\n icon: 'chevron-right',\n ariaLabel: HdsPaginationDirectionAriaLabelValues.Next,\n },\n };\n\n return hdsPaginationNavArrowContentDirectionMap[direction];\n }\n\n get showLabel(): boolean {\n const { showLabel = true } = this.args;\n\n return showLabel;\n }\n\n get classNames(): string {\n const classes = [\n 'hds-pagination-nav__control',\n 'hds-pagination-nav__arrow',\n `hds-pagination-nav__arrow--direction-${this.args.direction}`,\n ];\n\n return classes.join(' ');\n }\n\n @action\n onClick(): void {\n const { onClick } = this.args;\n\n if (typeof onClick === 'function') {\n onClick(this.args.direction);\n }\n }\n}\n"],"names":["DIRECTIONS","HdsPaginationDirectionValues","Prev","Next","HdsPaginationControlArrow","_class","Component","content","direction","args","assert","join","includes","hdsPaginationNavArrowContentDirectionMap","label","HdsPaginationDirectionLabelValues","icon","ariaLabel","HdsPaginationDirectionAriaLabelValues","showLabel","classNames","classes","onClick","_applyDecoratedDescriptor","prototype","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;AACA,eAAe,kBAAkB,CAAC,4tCAA4tC;;;ACsCvvC,MAAMA,UAAqC,GAAG,CACnDC,4BAA4B,CAACC,IAAI,EACjCD,4BAA4B,CAACE,IAAI;AAGdC,IAAAA,yBAAyB,IAAAC,MAAA,GAA/B,MAAMD,yBAAyB,SAASE,SAAS,CAAqC;EACnG,IAAIC,OAAOA,GAAqC;IAC9C,MAAM;AAAEC,MAAAA;KAAW,GAAG,IAAI,CAACC,IAAI;AAE/BC,IAAAA,MAAM,CACJ,CA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AAmB,SAAA,cAAAnB,MAAA,CAAAmB,SAAA,CAAA,EAAAnB,MAAA;AA9CqCuB,oBAAA,CAAAC,QAAA,EAAzBzB,yBAAyB,CAAA;;;;"}
1
+ {"version":3,"file":"arrow.js","sources":["../../../../../src/components/hds/pagination/nav/arrow.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport {\n HdsPaginationDirectionValues,\n HdsPaginationDirectionAriaLabelValues,\n HdsPaginationDirectionLabelValues,\n} from '../types.ts';\n\nimport type { HdsIconSignature } from '../../icon/index.ts';\nimport type { HdsInteractiveSignature } from '../../interactive';\nimport type {\n HdsPaginationDirections,\n HdsPaginationDirectionAriaLabels,\n HdsPaginationDirectionLabels,\n} from '../types';\n\ninterface HdsPaginationControlArrowContent {\n label: HdsPaginationDirectionLabels;\n icon: HdsIconSignature['Args']['name'];\n ariaLabel: HdsPaginationDirectionAriaLabels;\n}\n\ninterface HdsPaginationControlArrowArgs {\n direction: HdsPaginationDirections;\n disabled?: boolean;\n showLabel?: boolean;\n onClick?: (direction: HdsPaginationDirections) => void;\n}\n\nexport interface HdsPaginationControlArrowSignature {\n Args: HdsPaginationControlArrowArgs & HdsInteractiveSignature['Args'];\n Element: HdsInteractiveSignature['Element'];\n}\n\nexport const DIRECTIONS: HdsPaginationDirections[] = [\n HdsPaginationDirectionValues.Prev,\n HdsPaginationDirectionValues.Next,\n];\n\nexport default class HdsPaginationControlArrow extends Component<HdsPaginationControlArrowSignature> {\n get content(): HdsPaginationControlArrowContent {\n const { direction } = this.args;\n\n assert(\n `@direction for \"Pagination::Nav::Arrow\" must be one of the following: ${DIRECTIONS.join(\n ', '\n )}; received: ${direction}`,\n DIRECTIONS.includes(direction)\n );\n\n const hdsPaginationNavArrowContentDirectionMap: Record<\n HdsPaginationDirections,\n HdsPaginationControlArrowContent\n > = {\n [HdsPaginationDirectionValues.Prev]: {\n label: HdsPaginationDirectionLabelValues.Prev,\n icon: 'chevron-left',\n ariaLabel: HdsPaginationDirectionAriaLabelValues.Prev,\n },\n [HdsPaginationDirectionValues.Next]: {\n label: HdsPaginationDirectionLabelValues.Next,\n icon: 'chevron-right',\n ariaLabel: HdsPaginationDirectionAriaLabelValues.Next,\n },\n };\n\n return hdsPaginationNavArrowContentDirectionMap[direction];\n }\n\n get showLabel(): boolean {\n const { showLabel = true } = this.args;\n\n return showLabel;\n }\n\n get classNames(): string {\n const classes = [\n 'hds-pagination-nav__control',\n 'hds-pagination-nav__arrow',\n `hds-pagination-nav__arrow--direction-${this.args.direction}`,\n ];\n\n return classes.join(' ');\n }\n\n @action\n onClick(): void {\n const { onClick } = this.args;\n\n if (typeof onClick === 'function') {\n onClick(this.args.direction);\n }\n }\n}\n"],"names":["DIRECTIONS","HdsPaginationDirectionValues","Prev","Next","HdsPaginationControlArrow","Component","content","direction","args","assert","join","includes","hdsPaginationNavArrowContentDirectionMap","label","HdsPaginationDirectionLabelValues","icon","ariaLabel","HdsPaginationDirectionAriaLabelValues","showLabel","classNames","classes","onClick","n","prototype","action","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AAoCO,MAAMA,UAAqC,GAAG,CACnDC,4BAA4B,CAACC,IAAI,EACjCD,4BAA4B,CAACE,IAAI;AAGpB,MAAMC,yBAAyB,SAASC,SAAS,CAAqC;EACnG,IAAIC,OAAOA,GAAqC;IAC9C,MAAM;AAAEC,MAAAA;KAAW,GAAG,IAAI,CAACC,IAAI;AAE/BC,IAAAA,MAAM,CACJ,CAAyET,sEAAAA,EAAAA,UAAU,CAACU,IAAI,CACtF,IACF,CAAC,CAAA,YAAA,EAAeH,SAAS,CAAA,CAAE,EAC3BP,UAAU,CAACW,QAAQ,CAACJ,SAAS,CAC/B,CAAC;AAED,IAAA,MAAMK,wCAGL,GAAG;MACF,CAACX,4BAA4B,CAACC,IAAI,GAAG;QACnCW,KAAK,EAAEC,iCAAiC,CAACZ,IAAI;AAC7Ca,QAAAA,IAAI,EAAE,cAAc;QACpBC,SAAS,EAAEC,qCAAqC,CAACf;OAClD;MACD,CAACD,4BAA4B,CAACE,IAAI,GAAG;QACnCU,KAAK,EAAEC,iCAAiC,CAACX,IAAI;AAC7CY,QAAAA,IAAI,EAAE,eAAe;QACrBC,SAAS,EAAEC,qCAAqC,CAACd;AACnD;KACD;IAED,OAAOS,wCAAwC,CAACL,SAAS,CAAC;AAC5D;EAEA,IAAIW,SAASA,GAAY;IACvB,MAAM;AAAEA,MAAAA,SAAS,GAAG;KAAM,GAAG,IAAI,CAACV,IAAI;AAEtC,IAAA,OAAOU,SAAS;AAClB;EAEA,IAAIC,UAAUA,GAAW;AACvB,IAAA,MAAMC,OAAO,GAAG,CACd,6BAA6B,EAC7B,2BAA2B,EAC3B,CAAwC,qCAAA,EAAA,IAAI,CAACZ,IAAI,CAACD,SAAS,EAAE,CAC9D;AAED,IAAA,OAAOa,OAAO,CAACV,IAAI,CAAC,GAAG,CAAC;AAC1B;AAGAW,EAAAA,OAAOA,GAAS;IACd,MAAM;AAAEA,MAAAA;KAAS,GAAG,IAAI,CAACb,IAAI;AAE7B,IAAA,IAAI,OAAOa,OAAO,KAAK,UAAU,EAAE;AACjCA,MAAAA,OAAO,CAAC,IAAI,CAACb,IAAI,CAACD,SAAS,CAAC;AAC9B;AACF;AAAC,EAAA;IAAAe,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CAPAC,MAAM,CAAA,CAAA;AAAA;AAQT;AAACC,oBAAA,CAAAC,QAAA,EAtDoBtB,yBAAyB,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ellipsis.js","sources":["../../../../../src/components/hds/pagination/nav/ellipsis.hbs","../../../../../src/components/hds/pagination/nav/ellipsis.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n<div class=\\\"hds-pagination-nav__ellipsis\\\" ...attributes>...</div>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\nimport TemplateOnlyComponent from '@ember/component/template-only';\n\nexport interface HdsApplicationPaginationNavEllipsisSignature {\n Element: HTMLDivElement;\n}\n\nconst HdsApplicationPaginationNavEllipsis =\n TemplateOnlyComponent<HdsApplicationPaginationNavEllipsisSignature>();\n\nexport default HdsApplicationPaginationNavEllipsis;\n"],"names":["HdsApplicationPaginationNavEllipsis","TemplateOnlyComponent","setComponentTemplate","TEMPLATE"],"mappings":";;;;AACA,eAAe,kBAAkB,CAAC,mJAAmJ;;ACDrL;AACA;AACA;AACA;AAOA,MAAMA,mCAAmC,GACvCC,qBAAqB,EAAgD;AAEvE,eAAAC,oBAAA,CAAAC,QAAA,EAAeH,mCAAmC,CAAA;;;;"}
1
+ {"version":3,"file":"ellipsis.js","sources":["../../../../../src/components/hds/pagination/nav/ellipsis.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\nimport TemplateOnlyComponent from '@ember/component/template-only';\n\nexport interface HdsApplicationPaginationNavEllipsisSignature {\n Element: HTMLDivElement;\n}\n\nconst HdsApplicationPaginationNavEllipsis =\n TemplateOnlyComponent<HdsApplicationPaginationNavEllipsisSignature>();\n\nexport default HdsApplicationPaginationNavEllipsis;\n"],"names":["HdsApplicationPaginationNavEllipsis","TemplateOnlyComponent","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAOA,MAAMA,mCAAmC,GACvCC,qBAAqB,EAAgD;AAEvE,eAAAC,oBAAA,CAAAC,QAAA,EAAeH,mCAAmC,CAAA;;;;"}
@@ -1,14 +1,17 @@
1
- import { _ as _applyDecoratedDescriptor } from '../../../../_rollupPluginBabelHelpers-C_TsMG3M.js';
2
1
  import Component from '@glimmer/component';
3
2
  import { action } from '@ember/object';
4
3
  import { assert } from '@ember/debug';
5
4
  import { precompileTemplate } from '@ember/template-compilation';
5
+ import { n } from 'decorator-transforms/runtime';
6
6
  import { setComponentTemplate } from '@ember/component';
7
7
 
8
8
  var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n<Hds::Interactive\n class={{this.classNames}}\n @route={{@route}}\n @query={{hds-link-to-query @query}}\n @models={{hds-link-to-models @model @models}}\n @replace={{@replace}}\n {{on \"click\" this.onClick}}\n ...attributes\n aria-current={{if @isSelected \"page\" null}}\n>\n <Hds::Text::Body @tag=\"span\" @size=\"100\" @weight=\"medium\"><span class=\"sr-only\">page\n </span>{{this.page}}</Hds::Text::Body>\n</Hds::Interactive>");
9
9
 
10
- var _class;
11
- let HdsPaginationControlNumber = (_class = class HdsPaginationControlNumber extends Component {
10
+ /**
11
+ * Copyright (c) HashiCorp, Inc.
12
+ * SPDX-License-Identifier: MPL-2.0
13
+ */
14
+ class HdsPaginationControlNumber extends Component {
12
15
  get page() {
13
16
  const {
14
17
  page
@@ -31,7 +34,10 @@ let HdsPaginationControlNumber = (_class = class HdsPaginationControlNumber exte
31
34
  onClick(this.args.page);
32
35
  }
33
36
  }
34
- }, _applyDecoratedDescriptor(_class.prototype, "onClick", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onClick"), _class.prototype), _class);
37
+ static {
38
+ n(this.prototype, "onClick", [action]);
39
+ }
40
+ }
35
41
  setComponentTemplate(TEMPLATE, HdsPaginationControlNumber);
36
42
 
37
43
  export { HdsPaginationControlNumber as default };
@@ -1 +1 @@
1
- {"version":3,"file":"number.js","sources":["../../../../../src/components/hds/pagination/nav/number.hbs","../../../../../src/components/hds/pagination/nav/number.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n<Hds::Interactive\\n class={{this.classNames}}\\n @route={{@route}}\\n @query={{hds-link-to-query @query}}\\n @models={{hds-link-to-models @model @models}}\\n @replace={{@replace}}\\n {{on \\\"click\\\" this.onClick}}\\n ...attributes\\n aria-current={{if @isSelected \\\"page\\\" null}}\\n>\\n <Hds::Text::Body @tag=\\\"span\\\" @size=\\\"100\\\" @weight=\\\"medium\\\"><span class=\\\"sr-only\\\">page\\n </span>{{this.page}}</Hds::Text::Body>\\n</Hds::Interactive>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\n\nimport type { HdsInteractiveSignature } from '../../interactive';\n\ninterface HdsPaginationNavNumberArgs {\n page: number;\n onClick: (page: number) => void;\n isSelected: boolean;\n}\n\nexport interface HdsPaginationNavNumberSignature {\n Args: HdsPaginationNavNumberArgs & HdsInteractiveSignature['Args'];\n Element: HdsInteractiveSignature['Element'];\n}\n\nexport default class HdsPaginationControlNumber extends Component<HdsPaginationNavNumberSignature> {\n get page(): number {\n const { page } = this.args;\n\n assert(\n '@page for \"Pagination::Nav::Number\" must have a valid value',\n page !== undefined\n );\n\n return page;\n }\n\n get classNames(): string {\n const classes = [\n 'hds-pagination-nav__control',\n 'hds-pagination-nav__number',\n ];\n\n if (this.args.isSelected) {\n classes.push(`hds-pagination-nav__number--is-selected`);\n }\n\n return classes.join(' ');\n }\n\n @action\n onClick(): void {\n const { onClick } = this.args;\n\n if (typeof onClick === 'function') {\n onClick(this.args.page);\n }\n }\n}\n"],"names":["HdsPaginationControlNumber","_class","Component","page","args","assert","undefined","classNames","classes","isSelected","push","join","onClick","_applyDecoratedDescriptor","prototype","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;AACA,eAAe,kBAAkB,CAAC,2gBAA2gB;;;ACoBxhBA,IAAAA,0BAA0B,IAAAC,MAAA,GAAhC,MAAMD,0BAA0B,SAASE,SAAS,CAAkC;EACjG,IAAIC,IAAIA,GAAW;IACjB,MAAM;AAAEA,MAAAA;KAAM,GAAG,IAAI,CAACC,IAAI;AAE1BC,IAAAA,MAAM,CACJ,6DAA6D,EAC7DF,IAAI,KAAKG,SACX,CAAC;AAED,IAAA,OAAOH,IAAI;AACb;EAEA,IAAII,UAAUA,GAAW;AACvB,IAAA,MAAMC,OAAO,GAAG,CACd,6BAA6B,EAC7B,4BAA4B,CAC7B;AAED,IAAA,IAAI,IAAI,CAACJ,IAAI,CAACK,UAAU,EAAE;AACxBD,MAAAA,OAAO,CAACE,IAAI,CAAC,CAAA,uCAAA,CAAyC,CAAC;AACzD;AAEA,IAAA,OAAOF,OAAO,CAACG,IAAI,CAAC,GAAG,CAAC;AAC1B;AAGAC,EAAAA,OAAOA,GAAS;IACd,MAAM;AAAEA,MAAAA;KAAS,GAAG,IAAI,CAACR,IAAI;AAE7B,IAAA,IAAI,OAAOQ,OAAO,KAAK,UAAU,EAAE;AACjCA,MAAAA,OAAO,CAAC,IAAI,CAACR,IAAI,CAACD,IAAI,CAAC;AACzB;AACF;AACF,CAAC,EAAAU,yBAAA,CAAAZ,MAAA,CAAAa,SAAA,EAAA,SAAA,EAAA,CAREC,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAAhB,MAAA,CAAAa,SAAA,cAAAb,MAAA,CAAAa,SAAA,CAAA,EAAAb,MAAA;AAzBsCiB,oBAAA,CAAAC,QAAA,EAA1BnB,0BAA0B,CAAA;;;;"}
1
+ {"version":3,"file":"number.js","sources":["../../../../../src/components/hds/pagination/nav/number.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\n\nimport type { HdsInteractiveSignature } from '../../interactive';\n\ninterface HdsPaginationNavNumberArgs {\n page: number;\n onClick: (page: number) => void;\n isSelected: boolean;\n}\n\nexport interface HdsPaginationNavNumberSignature {\n Args: HdsPaginationNavNumberArgs & HdsInteractiveSignature['Args'];\n Element: HdsInteractiveSignature['Element'];\n}\n\nexport default class HdsPaginationControlNumber extends Component<HdsPaginationNavNumberSignature> {\n get page(): number {\n const { page } = this.args;\n\n assert(\n '@page for \"Pagination::Nav::Number\" must have a valid value',\n page !== undefined\n );\n\n return page;\n }\n\n get classNames(): string {\n const classes = [\n 'hds-pagination-nav__control',\n 'hds-pagination-nav__number',\n ];\n\n if (this.args.isSelected) {\n classes.push(`hds-pagination-nav__number--is-selected`);\n }\n\n return classes.join(' ');\n }\n\n @action\n onClick(): void {\n const { onClick } = this.args;\n\n if (typeof onClick === 'function') {\n onClick(this.args.page);\n }\n }\n}\n"],"names":["HdsPaginationControlNumber","Component","page","args","assert","undefined","classNames","classes","isSelected","push","join","onClick","n","prototype","action","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AAkBe,MAAMA,0BAA0B,SAASC,SAAS,CAAkC;EACjG,IAAIC,IAAIA,GAAW;IACjB,MAAM;AAAEA,MAAAA;KAAM,GAAG,IAAI,CAACC,IAAI;AAE1BC,IAAAA,MAAM,CACJ,6DAA6D,EAC7DF,IAAI,KAAKG,SACX,CAAC;AAED,IAAA,OAAOH,IAAI;AACb;EAEA,IAAII,UAAUA,GAAW;AACvB,IAAA,MAAMC,OAAO,GAAG,CACd,6BAA6B,EAC7B,4BAA4B,CAC7B;AAED,IAAA,IAAI,IAAI,CAACJ,IAAI,CAACK,UAAU,EAAE;AACxBD,MAAAA,OAAO,CAACE,IAAI,CAAC,CAAA,uCAAA,CAAyC,CAAC;AACzD;AAEA,IAAA,OAAOF,OAAO,CAACG,IAAI,CAAC,GAAG,CAAC;AAC1B;AAGAC,EAAAA,OAAOA,GAAS;IACd,MAAM;AAAEA,MAAAA;KAAS,GAAG,IAAI,CAACR,IAAI;AAE7B,IAAA,IAAI,OAAOQ,OAAO,KAAK,UAAU,EAAE;AACjCA,MAAAA,OAAO,CAAC,IAAI,CAACR,IAAI,CAACD,IAAI,CAAC;AACzB;AACF;AAAC,EAAA;IAAAU,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CAPAC,MAAM,CAAA,CAAA;AAAA;AAQT;AAACC,oBAAA,CAAAC,QAAA,EAjCoBhB,0BAA0B,CAAA;;;;"}
@@ -1,15 +1,18 @@
1
- import { _ as _applyDecoratedDescriptor, b as _initializerDefineProperty, a as _defineProperty } from '../../../../_rollupPluginBabelHelpers-C_TsMG3M.js';
2
1
  import Component from '@glimmer/component';
3
2
  import { tracked } from '@glimmer/tracking';
4
3
  import { action } from '@ember/object';
5
4
  import { assert } from '@ember/debug';
6
5
  import { HdsPaginationDirectionValues } from '../types.js';
7
6
  import { precompileTemplate } from '@ember/template-compilation';
7
+ import { g, i, n } from 'decorator-transforms/runtime';
8
8
  import { setComponentTemplate } from '@ember/component';
9
9
 
10
10
  var TEMPLATE = precompileTemplate("{{!\n Copyright (c) HashiCorp, Inc.\n SPDX-License-Identifier: MPL-2.0\n}}\n<div class=\"hds-pagination\" ...attributes>\n {{#if this.showInfo}}\n <Hds::Pagination::Info\n @itemsRangeStart={{this.itemsRangeStart}}\n @itemsRangeEnd={{this.itemsRangeEnd}}\n @totalItems={{@totalItems}}\n @showTotalItems={{@showTotalItems}}\n />\n {{/if}}\n\n <nav class=\"hds-pagination-nav\" aria-label={{this.ariaLabel}}>\n <Hds::Pagination::Nav::Arrow\n @direction=\"prev\"\n @showLabel={{this.showLabels}}\n @route={{this.routing.route}}\n @query={{this.routing.queryPrev}}\n @model={{this.routing.model}}\n @models={{this.routing.models}}\n @replace={{this.routing.replace}}\n @onClick={{this.onPageChange}}\n @disabled={{this.isDisabledPrev}}\n />\n {{#if this.showPageNumbers}}\n <ul class=\"hds-pagination-nav__page-list\">\n {{#each this.pages as |page|}}\n <li class=\"hds-pagination-nav__page-item\">\n {{#if (eq page \"…\")}}\n <Hds::Pagination::Nav::Ellipsis />\n {{else}}\n <Hds::Pagination::Nav::Number\n @page={{this.elliptizedPageArrayItemAsNumber page}}\n @route={{this.routing.route}}\n @query={{get this.routing.queryPages page}}\n @model={{this.routing.model}}\n @models={{this.routing.models}}\n @replace={{this.routing.replace}}\n @onClick={{this.onPageChange}}\n @isSelected={{if (eq page this.currentPage) true false}}\n />\n {{/if}}\n </li>\n {{/each}}\n </ul>\n {{/if}}\n <Hds::Pagination::Nav::Arrow\n @direction=\"next\"\n @showLabel={{this.showLabels}}\n @route={{this.routing.route}}\n @query={{this.routing.queryNext}}\n @model={{this.routing.model}}\n @models={{this.routing.models}}\n @replace={{this.routing.replace}}\n @onClick={{this.onPageChange}}\n @disabled={{this.isDisabledNext}}\n />\n </nav>\n\n {{#if this.showSizeSelector}}\n <Hds::Pagination::SizeSelector\n @pageSizes={{this.pageSizes}}\n @label={{@sizeSelectorLabel}}\n @selectedSize={{this.currentPageSize}}\n @onChange={{this.onPageSizeChange}}\n />\n {{/if}}\n</div>");
11
11
 
12
- var _class, _descriptor, _descriptor2, _descriptor3;
12
+ /**
13
+ * Copyright (c) HashiCorp, Inc.
14
+ * SPDX-License-Identifier: MPL-2.0
15
+ */
13
16
  const ELLIPSIS = '…';
14
17
 
15
18
  // for context about the decision to use these values, see:
@@ -56,38 +59,34 @@ const elliptize = ({
56
59
  }
57
60
  return result;
58
61
  };
59
- let HdsPaginationNumbered = (_class = class HdsPaginationNumbered extends Component {
60
- // if the list of "page numbers" is truncated
62
+ class HdsPaginationNumbered extends Component {
63
+ static {
64
+ g(this.prototype, "_currentPage", [tracked]);
65
+ }
66
+ #_currentPage = (i(this, "_currentPage"), undefined); // These two private variables are used to differentiate between
67
+ // "uncontrolled" component (where the state is handled internally) and
68
+ // "controlled" component (where the state is handled externally, by the consumer's code).
69
+ // In the first case, these variables store the internal state of the component at any moment,
70
+ // and their value is updated internally according to the user's interaction with the component.
71
+ // In the second case, these variables store *only* the initial state of the component (coming from the arguments)
72
+ // at rendering time, but from that moment on they're not updated anymore, no matter what interaction the user
73
+ // has with the component (the state is controlled externally, eg. via query parameters)
74
+ static {
75
+ g(this.prototype, "_currentPageSize", [tracked]);
76
+ }
77
+ #_currentPageSize = (i(this, "_currentPageSize"), undefined);
78
+ static {
79
+ g(this.prototype, "_isControlled", [tracked]);
80
+ }
81
+ #_isControlled = (i(this, "_isControlled"), undefined);
82
+ showInfo = this.args.showInfo ?? true; // if the "info" block is visible
83
+ showLabels = this.args.showLabels ?? false; // if the labels for the "prev/next" controls are visible
84
+ showSizeSelector = this.args.showSizeSelector ?? true; // if the "size selector" block is visible
85
+ showPageNumbers = this.args.showPageNumbers ?? true; // if the "page numbers" block is visible
86
+ isTruncated = this.args.isTruncated ?? true; // if the list of "page numbers" is truncated
61
87
 
62
88
  constructor(owner, args) {
63
89
  super(owner, args);
64
- // These two private variables are used to differentiate between
65
- // "uncontrolled" component (where the state is handled internally) and
66
- // "controlled" component (where the state is handled externally, by the consumer's code).
67
- // In the first case, these variables store the internal state of the component at any moment,
68
- // and their value is updated internally according to the user's interaction with the component.
69
- // In the second case, these variables store *only* the initial state of the component (coming from the arguments)
70
- // at rendering time, but from that moment on they're not updated anymore, no matter what interaction the user
71
- // has with the component (the state is controlled externally, eg. via query parameters)
72
- _initializerDefineProperty(this, "_currentPage", _descriptor, this);
73
- _initializerDefineProperty(this, "_currentPageSize", _descriptor2, this);
74
- _initializerDefineProperty(this, "_isControlled", _descriptor3, this);
75
- _defineProperty(this, "showInfo", this.args.showInfo ?? true);
76
- // if the "info" block is visible
77
- _defineProperty(this, "showLabels", this.args.showLabels ?? false);
78
- // if the labels for the "prev/next" controls are visible
79
- _defineProperty(this, "showSizeSelector", this.args.showSizeSelector ?? true);
80
- // if the "size selector" block is visible
81
- _defineProperty(this, "showPageNumbers", this.args.showPageNumbers ?? true);
82
- // if the "page numbers" block is visible
83
- _defineProperty(this, "isTruncated", this.args.isTruncated ?? true);
84
- _defineProperty(this, "elliptizedPageArrayItemAsNumber", item => {
85
- if (typeof item === 'number') {
86
- return item;
87
- } else {
88
- throw new Error('Expected a number, but got an ellipsis');
89
- }
90
- });
91
90
  const {
92
91
  queryFunction
93
92
  } = this.args;
@@ -263,6 +262,9 @@ let HdsPaginationNumbered = (_class = class HdsPaginationNumbered extends Compon
263
262
  }
264
263
  }
265
264
  }
265
+ static {
266
+ n(this.prototype, "onPageChange", [action]);
267
+ }
266
268
  onPageSizeChange(newPageSize) {
267
269
  const {
268
270
  onPageSizeChange
@@ -278,25 +280,20 @@ let HdsPaginationNumbered = (_class = class HdsPaginationNumbered extends Compon
278
280
  onPageSizeChange(newPageSize);
279
281
  }
280
282
  }
283
+ static {
284
+ n(this.prototype, "onPageSizeChange", [action]);
285
+ }
286
+ elliptizedPageArrayItemAsNumber = item => {
287
+ if (typeof item === 'number') {
288
+ return item;
289
+ } else {
290
+ throw new Error('Expected a number, but got an ellipsis');
291
+ }
292
+ };
281
293
  getPageNumberQuery(page) {
282
294
  return this.routing.queryPages[this.elliptizedPageArrayItemAsNumber(page)];
283
295
  }
284
- }, _descriptor = _applyDecoratedDescriptor(_class.prototype, "_currentPage", [tracked], {
285
- configurable: true,
286
- enumerable: true,
287
- writable: true,
288
- initializer: null
289
- }), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "_currentPageSize", [tracked], {
290
- configurable: true,
291
- enumerable: true,
292
- writable: true,
293
- initializer: null
294
- }), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, "_isControlled", [tracked], {
295
- configurable: true,
296
- enumerable: true,
297
- writable: true,
298
- initializer: null
299
- }), _applyDecoratedDescriptor(_class.prototype, "onPageChange", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onPageChange"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "onPageSizeChange", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onPageSizeChange"), _class.prototype), _class);
296
+ }
300
297
  setComponentTemplate(TEMPLATE, HdsPaginationNumbered);
301
298
 
302
299
  export { DEFAULT_PAGE_SIZES, HdsPaginationNumbered as default, elliptize };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/components/hds/pagination/numbered/index.hbs","../../../../../src/components/hds/pagination/numbered/index.ts"],"sourcesContent":["import { precompileTemplate } from \"@ember/template-compilation\";\nexport default precompileTemplate(\"{{!\\n Copyright (c) HashiCorp, Inc.\\n SPDX-License-Identifier: MPL-2.0\\n}}\\n<div class=\\\"hds-pagination\\\" ...attributes>\\n {{#if this.showInfo}}\\n <Hds::Pagination::Info\\n @itemsRangeStart={{this.itemsRangeStart}}\\n @itemsRangeEnd={{this.itemsRangeEnd}}\\n @totalItems={{@totalItems}}\\n @showTotalItems={{@showTotalItems}}\\n />\\n {{/if}}\\n\\n <nav class=\\\"hds-pagination-nav\\\" aria-label={{this.ariaLabel}}>\\n <Hds::Pagination::Nav::Arrow\\n @direction=\\\"prev\\\"\\n @showLabel={{this.showLabels}}\\n @route={{this.routing.route}}\\n @query={{this.routing.queryPrev}}\\n @model={{this.routing.model}}\\n @models={{this.routing.models}}\\n @replace={{this.routing.replace}}\\n @onClick={{this.onPageChange}}\\n @disabled={{this.isDisabledPrev}}\\n />\\n {{#if this.showPageNumbers}}\\n <ul class=\\\"hds-pagination-nav__page-list\\\">\\n {{#each this.pages as |page|}}\\n <li class=\\\"hds-pagination-nav__page-item\\\">\\n {{#if (eq page \\\"…\\\")}}\\n <Hds::Pagination::Nav::Ellipsis />\\n {{else}}\\n <Hds::Pagination::Nav::Number\\n @page={{this.elliptizedPageArrayItemAsNumber page}}\\n @route={{this.routing.route}}\\n @query={{get this.routing.queryPages page}}\\n @model={{this.routing.model}}\\n @models={{this.routing.models}}\\n @replace={{this.routing.replace}}\\n @onClick={{this.onPageChange}}\\n @isSelected={{if (eq page this.currentPage) true false}}\\n />\\n {{/if}}\\n </li>\\n {{/each}}\\n </ul>\\n {{/if}}\\n <Hds::Pagination::Nav::Arrow\\n @direction=\\\"next\\\"\\n @showLabel={{this.showLabels}}\\n @route={{this.routing.route}}\\n @query={{this.routing.queryNext}}\\n @model={{this.routing.model}}\\n @models={{this.routing.models}}\\n @replace={{this.routing.replace}}\\n @onClick={{this.onPageChange}}\\n @disabled={{this.isDisabledNext}}\\n />\\n </nav>\\n\\n {{#if this.showSizeSelector}}\\n <Hds::Pagination::SizeSelector\\n @pageSizes={{this.pageSizes}}\\n @label={{@sizeSelectorLabel}}\\n @selectedSize={{this.currentPageSize}}\\n @onChange={{this.onPageSizeChange}}\\n />\\n {{/if}}\\n</div>\")","/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport { HdsPaginationDirectionValues } from '../types.ts';\n\nimport type {\n HdsPaginationPage,\n HdsPaginationRoutingProps,\n HdsPaginationElliptizedPageArray,\n HdsPaginationElliptizedPageArrayItem,\n} from '../types';\nimport type { HdsInteractiveSignature } from '../../interactive/index.ts';\ninterface ElliptizeProps {\n pages: number[];\n current: number;\n limit?: number;\n}\n\ntype HdsInteractiveQuery = HdsInteractiveSignature['Args']['query'];\n\ntype HdsPaginationNumberedRoutingQueryProps = HdsPaginationRoutingProps & {\n queryNext?: HdsInteractiveQuery;\n queryPrev?: HdsInteractiveQuery;\n queryPages?: Record<\n HdsPaginationElliptizedPageArrayItem,\n HdsInteractiveQuery\n >;\n};\n\ntype HdsPaginationQueryFunction = (\n page: number,\n pageSize: number\n) => HdsInteractiveQuery;\n\ninterface HdsPaginationNumberedArgs extends HdsPaginationRoutingProps {\n ariaLabel?: string;\n totalItems: number;\n showLabels?: boolean;\n isTruncated?: boolean;\n currentPage?: number;\n showInfo?: boolean;\n showPageNumbers?: boolean;\n showTotalItems?: boolean;\n showSizeSelector?: boolean;\n sizeSelectorLabel?: string;\n pageSizes?: number[];\n currentPageSize?: number;\n queryFunction?: HdsPaginationQueryFunction;\n onPageChange?: (page: number, pageSize: number) => unknown;\n onPageSizeChange?: (pageSize: number) => unknown;\n}\n\ninterface HdsPaginationNumberedArgsControlledBase\n extends HdsPaginationNumberedArgs {\n currentPage: number;\n currentPageSize: number;\n queryFunction: HdsPaginationQueryFunction;\n}\n\ninterface HdsPaginationNumberedArgsControlledWithModel\n extends HdsPaginationNumberedArgsControlledBase {\n model: string | number;\n}\n\ninterface HdsPaginationNumberedArgsControlledWithModels\n extends HdsPaginationNumberedArgsControlledBase {\n models: Array<string | number>;\n}\ninterface HdsPaginationNumberedArgsControlledWithRoute\n extends HdsPaginationNumberedArgsControlledBase {\n route: string;\n}\n\ntype HdsPaginationNumberedArgsControlled =\n | HdsPaginationNumberedArgsControlledWithModel\n | HdsPaginationNumberedArgsControlledWithModels\n | HdsPaginationNumberedArgsControlledWithRoute;\n\ninterface HdsPaginationNumberedArgsUncontrolled\n extends HdsPaginationNumberedArgs {\n queryFunction?: undefined;\n}\n\nexport interface HdsPaginationNumberedSignature {\n Args:\n | HdsPaginationNumberedArgsControlled\n | HdsPaginationNumberedArgsUncontrolled;\n Element: HTMLDivElement;\n}\n\nconst ELLIPSIS = '…';\n\n// for context about the decision to use these values, see:\n// https://hashicorp.slack.com/archives/C03A0N1QK8S/p1673546329082759\nexport const DEFAULT_PAGE_SIZES = [10, 30, 50];\n\nexport const elliptize = ({\n pages,\n current,\n limit = 7,\n}: ElliptizeProps): HdsPaginationElliptizedPageArray => {\n const length = pages.length;\n\n let result = [];\n let start;\n let end;\n\n if (length <= limit) {\n return pages;\n }\n\n if (current <= length / 2) {\n start = Math.ceil(limit / 2);\n end = limit - start;\n } else {\n end = Math.ceil(limit / 2);\n start = limit - end;\n }\n\n const sliceStart: HdsPaginationElliptizedPageArray = pages.slice(0, start);\n const sliceEnd: HdsPaginationElliptizedPageArray = pages.slice(-end);\n\n if (sliceStart.includes(current) && sliceStart.includes(current + 1)) {\n // \"current\" (and its next sibling) is contained within the \"sliceStart\" block\n sliceEnd.splice(0, 1, ELLIPSIS);\n result = ([] as HdsPaginationElliptizedPageArray).concat(\n sliceStart,\n sliceEnd\n );\n } else if (sliceEnd.includes(current - 1) && sliceEnd.includes(current)) {\n // \"current\" (and its prev sibling) is contained within the \"sliceEnd\" block\n sliceStart.splice(-1, 1, ELLIPSIS);\n result = ([] as HdsPaginationElliptizedPageArray).concat(\n sliceStart,\n sliceEnd\n );\n } else {\n // this is a bit more tricky :)\n // we need to calculate how many items there are before/after the current item\n // since both the initial and ending blocks are always 2 items long (number + ellipsis)\n // and there is always the \"current\" item, we can just subtract 5 from the limit\n const delta = (limit - 5) / 2; // this is why the limit needs to be an odd number\n // we slice the array starting at the \"current\" index, minus the delta, minus one because it's an array (zero-based)\n const sliceCurr = pages.slice(current - delta - 1, current + delta);\n result = ([] as HdsPaginationElliptizedPageArray).concat(\n sliceStart.shift() as number,\n ELLIPSIS,\n sliceCurr,\n ELLIPSIS,\n sliceEnd.pop() as number\n );\n }\n\n return result;\n};\nexport default class HdsPaginationNumbered extends Component<HdsPaginationNumberedSignature> {\n // These two private variables are used to differentiate between\n // \"uncontrolled\" component (where the state is handled internally) and\n // \"controlled\" component (where the state is handled externally, by the consumer's code).\n // In the first case, these variables store the internal state of the component at any moment,\n // and their value is updated internally according to the user's interaction with the component.\n // In the second case, these variables store *only* the initial state of the component (coming from the arguments)\n // at rendering time, but from that moment on they're not updated anymore, no matter what interaction the user\n // has with the component (the state is controlled externally, eg. via query parameters)\n @tracked private _currentPage;\n @tracked private _currentPageSize;\n @tracked private _isControlled;\n\n showInfo = this.args.showInfo ?? true; // if the \"info\" block is visible\n showLabels = this.args.showLabels ?? false; // if the labels for the \"prev/next\" controls are visible\n showSizeSelector = this.args.showSizeSelector ?? true; // if the \"size selector\" block is visible\n showPageNumbers = this.args.showPageNumbers ?? true; // if the \"page numbers\" block is visible\n isTruncated = this.args.isTruncated ?? true; // if the list of \"page numbers\" is truncated\n\n constructor(owner: unknown, args: HdsPaginationNumberedSignature['Args']) {\n super(owner, args);\n\n const { queryFunction } = this.args;\n\n // This component works in two different ways, depending if we need to support\n // routing through links (`LinkTo`) for the \"navigation controls\", or not.\n // If there's no routing then the component behaves as \"uncontrolled\"\n // (the state updates - eg to the \"currentPage\" and \"currentPageSize\"\n // are handled by its internal logic).\n // If instead the component needs to update the routing (and we infer this via the \"query\" arguments)\n // then the component behaves as \"controlled\", where the state is\n // initialized and updated using the arguments passed to it.\n\n if (queryFunction === undefined) {\n this._isControlled = false;\n } else {\n assert(\n '@model, @models, or @route for \"Hds::Pagination::Numbered\" must be provided when using the @queryFunction argument',\n this.args.model !== undefined ||\n this.args.models !== undefined ||\n this.args.route !== undefined\n );\n assert(\n '@queryFunction for \"Hds::Pagination::Numbered\" must be a function',\n typeof queryFunction === 'function'\n );\n assert(\n '@currentPage and @currentPageSize for \"Hds::Pagination::Numbered\" must be provided as numeric arguments when the pagination controls the routing',\n typeof this.args.currentPageSize === 'number' &&\n typeof this.args.currentPage === 'number'\n );\n this._isControlled = true;\n }\n\n assert(\n '@totalItems for \"Hds::Pagination::Numbered\" must be defined as an integer number',\n typeof this.args.totalItems === 'number'\n );\n\n this._currentPage = this.args.currentPage ?? 1;\n // we assert that `this.pageSizes` will always be an array with at least one item\n this._currentPageSize = this.args.currentPageSize ?? this.pageSizes[0];\n }\n\n get ariaLabel(): string {\n return this.args.ariaLabel ?? 'Pagination';\n }\n\n // This very specific `get/set` pattern is used to handle the two different use cases of the component\n // being \"controlled\" (when it has routing, meaning it needs to support pagination controls as links/`LinkTo`)\n // vs being \"uncontrolled\" (see comments above for details).\n //\n // If it has routing (and so it's \"controlled\"), than the value (\"state\") of the `currentPage/currentPageSize` variables\n // is *always* determined by the controller via arguments (most of the times, connected to query parameters in the URL).\n // For this reason the \"get\" method always returns the value from the `args`,\n // while the \"set\" method never updates the private internal state (_variable).\n //\n // If instead it doesn't have routing (and so it's \"uncontrolled\") than the value (\"state\") of the `currentPage/currentPageSize` variables\n // is *always* determined by the component's internal logic (and updated according to the user interaction with it).\n // For this reason the \"get\" and \"set\" methods always read from or write to the private internal state (_variable).\n\n get currentPage(): number {\n if (this._isControlled) {\n // if the component is controlled, `@currentPage` is asserted to be a number\n return this.args.currentPage as number;\n } else {\n return this._currentPage;\n }\n }\n set currentPage(value) {\n if (this._isControlled) {\n // noop\n } else {\n // if `this._isControlled` is `false`\n this._currentPage = value as number;\n }\n }\n\n get currentPageSize(): number {\n if (this._isControlled) {\n // if the component is controlled, `@currentPageSize` is asserted to be a number\n return this.args.currentPageSize as number;\n } else {\n return this._currentPageSize as number;\n }\n }\n set currentPageSize(value) {\n if (this._isControlled) {\n // noop\n } else {\n this._currentPageSize = value;\n }\n }\n\n get pageSizes(): number[] {\n const { pageSizes = DEFAULT_PAGE_SIZES } = this.args;\n\n assert(\n // TODO: Add test for this\n `pageSizes argument must be an array with at least one item. Received: ${pageSizes}`,\n Array.isArray(pageSizes) === true && pageSizes.length > 0\n );\n\n return pageSizes;\n }\n\n get itemsRangeStart(): number {\n // Calculate the starting range of items displayed on current page\n // if currentPage = 1st page and # of items per page is 10:\n // ( (1 - 1 = 0) * 10 = 0 ) + 1 = 1\n // if current page = 2nd page:\n // ( (2 - 1 = 1) * 10 = 10 ) + 1 = 11\n return (this.currentPage - 1) * this.currentPageSize + 1;\n }\n\n get itemsRangeEnd(): number {\n // Calculate ending range of items displayed on current page\n // 2 cases: 1) full page of items or 2) last page of items\n if (this.currentPage * this.currentPageSize < this.args.totalItems) {\n // 1) full page of items (pages 1 to page before last):\n return this.itemsRangeStart + this.currentPageSize - 1;\n } else {\n // 2) last page of items:\n return this.args.totalItems;\n }\n }\n\n get pages(): HdsPaginationElliptizedPageArray {\n const pages = [];\n\n for (let i = 1; i <= this.totalPages; i++) {\n pages.push(i);\n }\n\n if (this.isTruncated) {\n return elliptize({ pages, current: this.currentPage });\n } else {\n return pages;\n }\n }\n\n get totalPages() {\n return Math.max(Math.ceil(this.args.totalItems / this.currentPageSize), 1);\n }\n\n buildQueryParamsObject(\n page: HdsPaginationElliptizedPageArrayItem,\n pageSize: number\n ): HdsInteractiveQuery {\n // `page` may also be ellipsis\n if (this._isControlled && typeof page === 'number') {\n // if the component is controlled, `@queryFunction` is asserted to be a function\n return this.args.queryFunction!(page, pageSize);\n } else {\n return {};\n }\n }\n\n get routing(): HdsPaginationNumberedRoutingQueryProps {\n const routing: HdsPaginationNumberedRoutingQueryProps = {\n route: this.args.route ?? undefined,\n model: this.args.model ?? undefined,\n models: this.args.models ?? undefined,\n replace: this.args.replace ?? undefined,\n };\n\n // the \"query\" is dynamic and needs to be calculated\n if (this._isControlled) {\n routing.queryPrev = this.buildQueryParamsObject(\n this.currentPage - 1,\n this.currentPageSize\n );\n routing.queryNext = this.buildQueryParamsObject(\n this.currentPage + 1,\n this.currentPageSize\n );\n // IMPORTANT: here we need to use an object and not an array\n // otherwise the {{get object page}} will be shifted by one\n // (the pages are 1-based while the array would be zero-based)\n routing.queryPages = {};\n this.pages.forEach(\n (page) =>\n (routing.queryPages![page] = this.buildQueryParamsObject(\n page,\n this.currentPageSize\n ))\n );\n } else {\n routing.queryPrev = undefined;\n routing.queryNext = undefined;\n }\n\n return routing;\n }\n\n get isDisabledPrev() {\n return this.currentPage === 1;\n }\n\n get isDisabledNext() {\n return this.currentPage === this.totalPages;\n }\n\n @action\n onPageChange(page: HdsPaginationPage) {\n let gotoPageNumber;\n if (page === HdsPaginationDirectionValues.Prev && this.currentPage > 1) {\n gotoPageNumber = this.currentPage - 1;\n } else if (\n page === HdsPaginationDirectionValues.Next &&\n this.currentPage < this.totalPages\n ) {\n gotoPageNumber = this.currentPage + 1;\n } else {\n gotoPageNumber = page;\n }\n\n // we want to invoke the `onPageChange` callback only on actual page change\n if (gotoPageNumber !== this.currentPage) {\n // we have already determined that `gotoPageNumber` is not `prev` or `next`\n this.currentPage = gotoPageNumber as number;\n\n const { onPageChange } = this.args;\n\n if (typeof onPageChange === 'function') {\n onPageChange(this.currentPage, this.currentPageSize);\n }\n }\n }\n\n @action\n onPageSizeChange(newPageSize: number) {\n const { onPageSizeChange } = this.args;\n\n if (!this._isControlled) {\n // notice: we agreed to reset the pagination to the first element (any alternative would result in an unpredictable UX)\n this.currentPage = 1;\n this.currentPageSize = newPageSize;\n }\n\n // invoke the callback function\n if (typeof onPageSizeChange === 'function') {\n onPageSizeChange(newPageSize);\n }\n }\n\n elliptizedPageArrayItemAsNumber = (\n item: HdsPaginationElliptizedPageArrayItem\n ): number => {\n if (typeof item === 'number') {\n return item;\n } else {\n throw new Error('Expected a number, but got an ellipsis');\n }\n };\n\n getPageNumberQuery(page: HdsPaginationElliptizedPageArrayItem) {\n return this.routing.queryPages![this.elliptizedPageArrayItemAsNumber(page)];\n }\n}\n"],"names":["ELLIPSIS","DEFAULT_PAGE_SIZES","elliptize","pages","current","limit","length","result","start","end","Math","ceil","sliceStart","slice","sliceEnd","includes","splice","concat","delta","sliceCurr","shift","pop","HdsPaginationNumbered","_class","Component","constructor","owner","args","_initializerDefineProperty","_descriptor","_descriptor2","_descriptor3","_defineProperty","showInfo","showLabels","showSizeSelector","showPageNumbers","isTruncated","item","Error","queryFunction","undefined","_isControlled","assert","model","models","route","currentPageSize","currentPage","totalItems","_currentPage","_currentPageSize","pageSizes","ariaLabel","value","Array","isArray","itemsRangeStart","itemsRangeEnd","i","totalPages","push","max","buildQueryParamsObject","page","pageSize","routing","replace","queryPrev","queryNext","queryPages","forEach","isDisabledPrev","isDisabledNext","onPageChange","gotoPageNumber","HdsPaginationDirectionValues","Prev","Next","onPageSizeChange","newPageSize","getPageNumberQuery","elliptizedPageArrayItemAsNumber","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;AACA,eAAe,kBAAkB,CAAC,kzEAAkzE;;;AC8Fp1E,MAAMA,QAAQ,GAAG,GAAG;;AAEpB;AACA;AACO,MAAMC,kBAAkB,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;AAEtC,MAAMC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IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;EAAAC,WAAA,EAAA;AAAA,CAAA3D,CAAAA,EAAAA,YAAA,GAAAqD,yBAAA,CAAA5D,MAAA,CAAA6D,SAAA,uBACPC,OAAO,CAAA,EAAA;EAAAC,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;EAAAC,WAAA,EAAA;AAAA,CAAA1D,CAAAA,EAAAA,YAAA,GAAAoD,yBAAA,CAAA5D,MAAA,CAAA6D,SAAA,oBACPC,OAAO,CAAA,EAAA;EAAAC,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;EAAAC,WAAA,EAAA;AAAA,CAAA,CAAA,EAAAN,yBAAA,CAAA5D,MAAA,CAAA6D,SAAA,EAAA,cAAA,EAAA,CAoNPM,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAArE,MAAA,CAAA6D,SAAA,EAAA7D,cAAAA,CAAAA,EAAAA,MAAA,CAAA6D,SAAA,CAAA,EAAAD,yBAAA,CAAA5D,MAAA,CAAA6D,SAAA,uBA2BNM,MAAM,CAAA,EAAAC,MAAA,CAAAC,wBAAA,CAAArE,MAAA,CAAA6D,SAAA,EAAA,kBAAA,CAAA,EAAA7D,MAAA,CAAA6D,SAAA,GAAA7D,MAAA;AA1PiCsE,oBAAA,CAAAC,QAAA,EAArBxE,qBAAqB,CAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/components/hds/pagination/numbered/index.ts"],"sourcesContent":["/**\n * Copyright (c) HashiCorp, Inc.\n * SPDX-License-Identifier: MPL-2.0\n */\nimport Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { assert } from '@ember/debug';\nimport { HdsPaginationDirectionValues } from '../types.ts';\n\nimport type {\n HdsPaginationPage,\n HdsPaginationRoutingProps,\n HdsPaginationElliptizedPageArray,\n HdsPaginationElliptizedPageArrayItem,\n} from '../types';\nimport type { HdsInteractiveSignature } from '../../interactive/index.ts';\nimport type Owner from '@ember/owner';\ninterface ElliptizeProps {\n pages: number[];\n current: number;\n limit?: number;\n}\n\ntype HdsInteractiveQuery = HdsInteractiveSignature['Args']['query'];\n\ntype HdsPaginationNumberedRoutingQueryProps = HdsPaginationRoutingProps & {\n queryNext?: HdsInteractiveQuery;\n queryPrev?: HdsInteractiveQuery;\n queryPages?: Record<\n HdsPaginationElliptizedPageArrayItem,\n HdsInteractiveQuery\n >;\n};\n\ntype HdsPaginationQueryFunction = (\n page: number,\n pageSize: number\n) => HdsInteractiveQuery;\n\ninterface HdsPaginationNumberedArgs extends HdsPaginationRoutingProps {\n ariaLabel?: string;\n totalItems: number;\n showLabels?: boolean;\n isTruncated?: boolean;\n currentPage?: number;\n showInfo?: boolean;\n showPageNumbers?: boolean;\n showTotalItems?: boolean;\n showSizeSelector?: boolean;\n sizeSelectorLabel?: string;\n pageSizes?: number[];\n currentPageSize?: number;\n queryFunction?: HdsPaginationQueryFunction;\n onPageChange?: (page: number, pageSize: number) => unknown;\n onPageSizeChange?: (pageSize: number) => unknown;\n}\n\ninterface HdsPaginationNumberedArgsControlledBase\n extends HdsPaginationNumberedArgs {\n currentPage: number;\n currentPageSize: number;\n queryFunction: HdsPaginationQueryFunction;\n}\n\ninterface HdsPaginationNumberedArgsControlledWithModel\n extends HdsPaginationNumberedArgsControlledBase {\n model: string | number;\n}\n\ninterface HdsPaginationNumberedArgsControlledWithModels\n extends HdsPaginationNumberedArgsControlledBase {\n models: Array<string | number>;\n}\ninterface HdsPaginationNumberedArgsControlledWithRoute\n extends HdsPaginationNumberedArgsControlledBase {\n route: string;\n}\n\ntype HdsPaginationNumberedArgsControlled =\n | HdsPaginationNumberedArgsControlledWithModel\n | HdsPaginationNumberedArgsControlledWithModels\n | HdsPaginationNumberedArgsControlledWithRoute;\n\ninterface HdsPaginationNumberedArgsUncontrolled\n extends HdsPaginationNumberedArgs {\n queryFunction?: undefined;\n}\n\nexport interface HdsPaginationNumberedSignature {\n Args:\n | HdsPaginationNumberedArgsControlled\n | HdsPaginationNumberedArgsUncontrolled;\n Element: HTMLDivElement;\n}\n\nconst ELLIPSIS = '…';\n\n// for context about the decision to use these values, see:\n// https://hashicorp.slack.com/archives/C03A0N1QK8S/p1673546329082759\nexport const DEFAULT_PAGE_SIZES = [10, 30, 50];\n\nexport const elliptize = ({\n pages,\n current,\n limit = 7,\n}: ElliptizeProps): HdsPaginationElliptizedPageArray => {\n const length = pages.length;\n\n let result = [];\n let start;\n let end;\n\n if (length <= limit) {\n return pages;\n }\n\n if (current <= length / 2) {\n start = Math.ceil(limit / 2);\n end = limit - start;\n } else {\n end = Math.ceil(limit / 2);\n start = limit - end;\n }\n\n const sliceStart: HdsPaginationElliptizedPageArray = pages.slice(0, start);\n const sliceEnd: HdsPaginationElliptizedPageArray = pages.slice(-end);\n\n if (sliceStart.includes(current) && sliceStart.includes(current + 1)) {\n // \"current\" (and its next sibling) is contained within the \"sliceStart\" block\n sliceEnd.splice(0, 1, ELLIPSIS);\n result = ([] as HdsPaginationElliptizedPageArray).concat(\n sliceStart,\n sliceEnd\n );\n } else if (sliceEnd.includes(current - 1) && sliceEnd.includes(current)) {\n // \"current\" (and its prev sibling) is contained within the \"sliceEnd\" block\n sliceStart.splice(-1, 1, ELLIPSIS);\n result = ([] as HdsPaginationElliptizedPageArray).concat(\n sliceStart,\n sliceEnd\n );\n } else {\n // this is a bit more tricky :)\n // we need to calculate how many items there are before/after the current item\n // since both the initial and ending blocks are always 2 items long (number + ellipsis)\n // and there is always the \"current\" item, we can just subtract 5 from the limit\n const delta = (limit - 5) / 2; // this is why the limit needs to be an odd number\n // we slice the array starting at the \"current\" index, minus the delta, minus one because it's an array (zero-based)\n const sliceCurr = pages.slice(current - delta - 1, current + delta);\n result = ([] as HdsPaginationElliptizedPageArray).concat(\n sliceStart.shift() as number,\n ELLIPSIS,\n sliceCurr,\n ELLIPSIS,\n sliceEnd.pop() as number\n );\n }\n\n return result;\n};\nexport default class HdsPaginationNumbered extends Component<HdsPaginationNumberedSignature> {\n // These two private variables are used to differentiate between\n // \"uncontrolled\" component (where the state is handled internally) and\n // \"controlled\" component (where the state is handled externally, by the consumer's code).\n // In the first case, these variables store the internal state of the component at any moment,\n // and their value is updated internally according to the user's interaction with the component.\n // In the second case, these variables store *only* the initial state of the component (coming from the arguments)\n // at rendering time, but from that moment on they're not updated anymore, no matter what interaction the user\n // has with the component (the state is controlled externally, eg. via query parameters)\n @tracked private _currentPage;\n @tracked private _currentPageSize;\n @tracked private _isControlled;\n\n showInfo = this.args.showInfo ?? true; // if the \"info\" block is visible\n showLabels = this.args.showLabels ?? false; // if the labels for the \"prev/next\" controls are visible\n showSizeSelector = this.args.showSizeSelector ?? true; // if the \"size selector\" block is visible\n showPageNumbers = this.args.showPageNumbers ?? true; // if the \"page numbers\" block is visible\n isTruncated = this.args.isTruncated ?? true; // if the list of \"page numbers\" is truncated\n\n constructor(owner: Owner, args: HdsPaginationNumberedSignature['Args']) {\n super(owner, args);\n\n const { queryFunction } = this.args;\n\n // This component works in two different ways, depending if we need to support\n // routing through links (`LinkTo`) for the \"navigation controls\", or not.\n // If there's no routing then the component behaves as \"uncontrolled\"\n // (the state updates - eg to the \"currentPage\" and \"currentPageSize\"\n // are handled by its internal logic).\n // If instead the component needs to update the routing (and we infer this via the \"query\" arguments)\n // then the component behaves as \"controlled\", where the state is\n // initialized and updated using the arguments passed to it.\n\n if (queryFunction === undefined) {\n this._isControlled = false;\n } else {\n assert(\n '@model, @models, or @route for \"Hds::Pagination::Numbered\" must be provided when using the @queryFunction argument',\n this.args.model !== undefined ||\n this.args.models !== undefined ||\n this.args.route !== undefined\n );\n assert(\n '@queryFunction for \"Hds::Pagination::Numbered\" must be a function',\n typeof queryFunction === 'function'\n );\n assert(\n '@currentPage and @currentPageSize for \"Hds::Pagination::Numbered\" must be provided as numeric arguments when the pagination controls the routing',\n typeof this.args.currentPageSize === 'number' &&\n typeof this.args.currentPage === 'number'\n );\n this._isControlled = true;\n }\n\n assert(\n '@totalItems for \"Hds::Pagination::Numbered\" must be defined as an integer number',\n typeof this.args.totalItems === 'number'\n );\n\n this._currentPage = this.args.currentPage ?? 1;\n // we assert that `this.pageSizes` will always be an array with at least one item\n this._currentPageSize = this.args.currentPageSize ?? this.pageSizes[0];\n }\n\n get ariaLabel(): string {\n return this.args.ariaLabel ?? 'Pagination';\n }\n\n // This very specific `get/set` pattern is used to handle the two different use cases of the component\n // being \"controlled\" (when it has routing, meaning it needs to support pagination controls as links/`LinkTo`)\n // vs being \"uncontrolled\" (see comments above for details).\n //\n // If it has routing (and so it's \"controlled\"), than the value (\"state\") of the `currentPage/currentPageSize` variables\n // is *always* determined by the controller via arguments (most of the times, connected to query parameters in the URL).\n // For this reason the \"get\" method always returns the value from the `args`,\n // while the \"set\" method never updates the private internal state (_variable).\n //\n // If instead it doesn't have routing (and so it's \"uncontrolled\") than the value (\"state\") of the `currentPage/currentPageSize` variables\n // is *always* determined by the component's internal logic (and updated according to the user interaction with it).\n // For this reason the \"get\" and \"set\" methods always read from or write to the private internal state (_variable).\n\n get currentPage(): number {\n if (this._isControlled) {\n // if the component is controlled, `@currentPage` is asserted to be a number\n return this.args.currentPage as number;\n } else {\n return this._currentPage;\n }\n }\n set currentPage(value) {\n if (this._isControlled) {\n // noop\n } else {\n // if `this._isControlled` is `false`\n this._currentPage = value as number;\n }\n }\n\n get currentPageSize(): number {\n if (this._isControlled) {\n // if the component is controlled, `@currentPageSize` is asserted to be a number\n return this.args.currentPageSize as number;\n } else {\n return this._currentPageSize as number;\n }\n }\n set currentPageSize(value) {\n if (this._isControlled) {\n // noop\n } else {\n this._currentPageSize = value;\n }\n }\n\n get pageSizes(): number[] {\n const { pageSizes = DEFAULT_PAGE_SIZES } = this.args;\n\n assert(\n // TODO: Add test for this\n `pageSizes argument must be an array with at least one item. Received: ${pageSizes}`,\n Array.isArray(pageSizes) === true && pageSizes.length > 0\n );\n\n return pageSizes;\n }\n\n get itemsRangeStart(): number {\n // Calculate the starting range of items displayed on current page\n // if currentPage = 1st page and # of items per page is 10:\n // ( (1 - 1 = 0) * 10 = 0 ) + 1 = 1\n // if current page = 2nd page:\n // ( (2 - 1 = 1) * 10 = 10 ) + 1 = 11\n return (this.currentPage - 1) * this.currentPageSize + 1;\n }\n\n get itemsRangeEnd(): number {\n // Calculate ending range of items displayed on current page\n // 2 cases: 1) full page of items or 2) last page of items\n if (this.currentPage * this.currentPageSize < this.args.totalItems) {\n // 1) full page of items (pages 1 to page before last):\n return this.itemsRangeStart + this.currentPageSize - 1;\n } else {\n // 2) last page of items:\n return this.args.totalItems;\n }\n }\n\n get pages(): HdsPaginationElliptizedPageArray {\n const pages = [];\n\n for (let i = 1; i <= this.totalPages; i++) {\n pages.push(i);\n }\n\n if (this.isTruncated) {\n return elliptize({ pages, current: this.currentPage });\n } else {\n return pages;\n }\n }\n\n get totalPages() {\n return Math.max(Math.ceil(this.args.totalItems / this.currentPageSize), 1);\n }\n\n buildQueryParamsObject(\n page: HdsPaginationElliptizedPageArrayItem,\n pageSize: number\n ): HdsInteractiveQuery {\n // `page` may also be ellipsis\n if (this._isControlled && typeof page === 'number') {\n // if the component is controlled, `@queryFunction` is asserted to be a function\n return this.args.queryFunction!(page, pageSize);\n } else {\n return {};\n }\n }\n\n get routing(): HdsPaginationNumberedRoutingQueryProps {\n const routing: HdsPaginationNumberedRoutingQueryProps = {\n route: this.args.route ?? undefined,\n model: this.args.model ?? undefined,\n models: this.args.models ?? undefined,\n replace: this.args.replace ?? undefined,\n };\n\n // the \"query\" is dynamic and needs to be calculated\n if (this._isControlled) {\n routing.queryPrev = this.buildQueryParamsObject(\n this.currentPage - 1,\n this.currentPageSize\n );\n routing.queryNext = this.buildQueryParamsObject(\n this.currentPage + 1,\n this.currentPageSize\n );\n // IMPORTANT: here we need to use an object and not an array\n // otherwise the {{get object page}} will be shifted by one\n // (the pages are 1-based while the array would be zero-based)\n routing.queryPages = {};\n this.pages.forEach(\n (page) =>\n (routing.queryPages![page] = this.buildQueryParamsObject(\n page,\n this.currentPageSize\n ))\n );\n } else {\n routing.queryPrev = undefined;\n routing.queryNext = undefined;\n }\n\n return routing;\n }\n\n get isDisabledPrev() {\n return this.currentPage === 1;\n }\n\n get isDisabledNext() {\n return this.currentPage === this.totalPages;\n }\n\n @action\n onPageChange(page: HdsPaginationPage) {\n let gotoPageNumber;\n if (page === HdsPaginationDirectionValues.Prev && this.currentPage > 1) {\n gotoPageNumber = this.currentPage - 1;\n } else if (\n page === HdsPaginationDirectionValues.Next &&\n this.currentPage < this.totalPages\n ) {\n gotoPageNumber = this.currentPage + 1;\n } else {\n gotoPageNumber = page;\n }\n\n // we want to invoke the `onPageChange` callback only on actual page change\n if (gotoPageNumber !== this.currentPage) {\n // we have already determined that `gotoPageNumber` is not `prev` or `next`\n this.currentPage = gotoPageNumber as number;\n\n const { onPageChange } = this.args;\n\n if (typeof onPageChange === 'function') {\n onPageChange(this.currentPage, this.currentPageSize);\n }\n }\n }\n\n @action\n onPageSizeChange(newPageSize: number) {\n const { onPageSizeChange } = this.args;\n\n if (!this._isControlled) {\n // notice: we agreed to reset the pagination to the first element (any alternative would result in an unpredictable UX)\n this.currentPage = 1;\n this.currentPageSize = newPageSize;\n }\n\n // invoke the callback function\n if (typeof onPageSizeChange === 'function') {\n onPageSizeChange(newPageSize);\n }\n }\n\n elliptizedPageArrayItemAsNumber = (\n item: HdsPaginationElliptizedPageArrayItem\n ): number => {\n if (typeof item === 'number') {\n return item;\n } else {\n throw new Error('Expected a number, but got an ellipsis');\n }\n };\n\n getPageNumberQuery(page: HdsPaginationElliptizedPageArrayItem) {\n return this.routing.queryPages![this.elliptizedPageArrayItemAsNumber(page)];\n }\n}\n"],"names":["ELLIPSIS","DEFAULT_PAGE_SIZES","elliptize","pages","current","limit","length","result","start","end","Math","ceil","sliceStart","slice","sliceEnd","includes","splice","concat","delta","sliceCurr","shift","pop","HdsPaginationNumbered","Component","g","prototype","tracked","i","void 0","showInfo","args","showLabels","showSizeSelector","showPageNumbers","isTruncated","constructor","owner","queryFunction","undefined","_isControlled","assert","model","models","route","currentPageSize","currentPage","totalItems","_currentPage","_currentPageSize","pageSizes","ariaLabel","value","Array","isArray","itemsRangeStart","itemsRangeEnd","totalPages","push","max","buildQueryParamsObject","page","pageSize","routing","replace","queryPrev","queryNext","queryPages","forEach","isDisabledPrev","isDisabledNext","onPageChange","gotoPageNumber","HdsPaginationDirectionValues","Prev","Next","n","action","onPageSizeChange","newPageSize","elliptizedPageArrayItemAsNumber","item","Error","getPageNumberQuery","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AA6FA,MAAMA,QAAQ,GAAG,GAAG;;AAEpB;AACA;AACO,MAAMC,kBAAkB,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;AAEtC,MAAMC,SAAS,GAAGA,CAAC;EACxBC,KAAK;EACLC,OAAO;AACPC,EAAAA,KAAK,GAAG;AACM,CAAC,KAAuC;AACtD,EAAA,MAAMC,MAAM,GAAGH,KAAK,CAACG,MAAM;EAE3B,IAAIC,MAAM,GAAG,EAAE;AACf,EAAA,IAAIC,KAAK;AACT,EAAA,IAAIC,GAAG;EAEP,IAAIH,MAAM,IAAID,KAAK,EAAE;AACnB,IAAA,OAAOF,KAAK;AACd;AAEA,EAAA,IAAIC,OAAO,IAAIE,MAAM,GAAG,CAAC,EAAE;IACzBE,KAAK,GAAGE,IAAI,CAACC,IAAI,CAACN,KAAK,GAAG,CAAC,CAAC;IAC5BI,GAAG,GAAGJ,KAAK,GAAGG,KAAK;AACrB,GAAC,MAAM;IACLC,GAAG,GAAGC,IAAI,CAACC,IAAI,CAACN,KAAK,GAAG,CAAC,CAAC;IAC1BG,KAAK,GAAGH,KAAK,GAAGI,GAAG;AACrB;EAEA,MAAMG,UAA4C,GAAGT,KAAK,CAACU,KAAK,CAAC,CAAC,EAAEL,KA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