@adyen/bento-mcp 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (429) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +24 -2
  3. package/SKILL.md +37 -7
  4. package/dist/assets/components/accordion/accordion.stories.ts +1 -1
  5. package/dist/assets/components/accordion/components/accordion-item.stories.ts +1 -1
  6. package/dist/assets/components/accordion/components/accordion-item.vue +1 -1
  7. package/dist/assets/components/action-bar/action-bar.docs.mdx +10 -3
  8. package/dist/assets/components/action-bar/action-bar.internal.types.ts +1 -0
  9. package/dist/assets/components/action-bar/action-bar.stories.ts +1 -1
  10. package/dist/assets/components/action-bar/action-bar.types.ts +1 -1
  11. package/dist/assets/components/action-bar/action-bar.vue +1 -1
  12. package/dist/assets/components/ai-tag/ai-tag.stories.ts +1 -1
  13. package/dist/assets/components/ai-tag/ai-tag.vue +1 -1
  14. package/dist/assets/components/alert/alert.stories.ts +1 -1
  15. package/dist/assets/components/alert/alert.types.ts +1 -1
  16. package/dist/assets/components/anchor-scroller/anchor-scroller.stories.ts +1 -1
  17. package/dist/assets/components/anchor-scroller/anchor-scroller.vue +1 -1
  18. package/dist/assets/components/avatar/avatar.internal.types.ts +1 -0
  19. package/dist/assets/components/avatar/avatar.stories.ts +1 -1
  20. package/dist/assets/components/avatar/avatar.types.ts +1 -1
  21. package/dist/assets/components/button/button.docs.mdx +4 -3
  22. package/dist/assets/components/button/button.stories.ts +1 -1
  23. package/dist/assets/components/button/button.types.ts +1 -1
  24. package/dist/assets/components/button/components/ai-button/ai-button.stories.ts +1 -1
  25. package/dist/assets/components/button/components/ai-button/ai-button.vue +1 -1
  26. package/dist/assets/components/button/components/button-actions/button-actions.docs.mdx +3 -0
  27. package/dist/assets/components/button/components/button-actions/button-actions.internal.types.ts +1 -0
  28. package/dist/assets/components/button/components/button-actions/button-actions.stories.ts +1 -1
  29. package/dist/assets/components/button/components/button-actions/button-actions.types.ts +1 -1
  30. package/dist/assets/components/button/components/button-actions/button-actions.vue +1 -1
  31. package/dist/assets/components/button/components/loading-button/loading-button.docs.mdx +26 -23
  32. package/dist/assets/components/button/components/loading-button/loading-button.stories.ts +1 -1
  33. package/dist/assets/components/button/components/loading-button/loading-button.vue +1 -1
  34. package/dist/assets/components/button/components/toggle-button/toggle-button.stories.ts +1 -1
  35. package/dist/assets/components/card/card.docs.mdx +18 -1
  36. package/dist/assets/components/card/card.stories.ts +1 -1
  37. package/dist/assets/components/card/card.types.ts +1 -1
  38. package/dist/assets/components/card/card.vue +1 -1
  39. package/dist/assets/components/checkbox/checkbox.stories.ts +1 -1
  40. package/dist/assets/components/checkbox/checkbox.types.ts +1 -1
  41. package/dist/assets/components/checkbox/checkbox.vue +1 -1
  42. package/dist/assets/components/checkbox/components/checkbox-group/checkbox-group.docs.mdx +9 -14
  43. package/dist/assets/components/checkbox/components/checkbox-group/checkbox-group.stories.ts +1 -1
  44. package/dist/assets/components/checkbox/components/checkbox-group/checkbox-group.types.ts +1 -1
  45. package/dist/assets/components/checkbox/components/checkbox-group/checkbox-group.vue +1 -1
  46. package/dist/assets/components/chip/chip.stories.ts +1 -1
  47. package/dist/assets/components/chip/chip.vue +1 -1
  48. package/dist/assets/components/click-outside/click-outside.stories.ts +1 -1
  49. package/dist/assets/components/code-snippet/code-snippet.types.ts +1 -1
  50. package/dist/assets/components/code-snippet/code-snippet.vue +1 -1
  51. package/dist/assets/components/country/country.stories.ts +1 -1
  52. package/dist/assets/components/country/country.types.ts +1 -1
  53. package/dist/assets/components/country/country.vue +1 -1
  54. package/dist/assets/components/currency/currency.stories.ts +1 -1
  55. package/dist/assets/components/currency/currency.vue +1 -1
  56. package/dist/assets/components/dashed-underline/dashed-underline.stories.ts +1 -1
  57. package/dist/assets/components/data-grid/components/data-grid-cell-actions/data-grid-cell-actions.types.ts +1 -1
  58. package/dist/assets/components/data-grid/components/data-grid-cell-actions/data-grid-cell-actions.vue +1 -1
  59. package/dist/assets/components/data-grid/components/data-grid-config-settings/data-grid-config-settings.vue +1 -1
  60. package/dist/assets/components/data-grid/components/data-grid-row/data-grid-row.vue +1 -1
  61. package/dist/assets/components/data-grid/components/data-grid-static-icon/data-grid-static-icon.stories.ts +1 -1
  62. package/dist/assets/components/data-grid/components/data-grid-summary-cell/data-grid-summary-cell.stories.ts +1 -1
  63. package/dist/assets/components/data-grid/components/data-grid-summary-cell/data-grid-summary-cell.vue +1 -1
  64. package/dist/assets/components/data-grid/components/data-grid-tag-with-text-cell/data-grid-tag-with-text-cell.stories.ts +1 -1
  65. package/dist/assets/components/data-grid/components/data-grid-trend-cell/data-grid-trend-cell.stories.ts +1 -1
  66. package/dist/assets/components/data-grid/components/data-grid-trend-cell/data-grid-trend-cell.vue +1 -1
  67. package/dist/assets/components/data-grid/data-grid.docs.mdx +3 -60
  68. package/dist/assets/components/data-grid/data-grid.stories.ts +1 -1
  69. package/dist/assets/components/data-grid/data-grid.vue +1 -1
  70. package/dist/assets/components/date/date.stories.ts +1 -1
  71. package/dist/assets/components/date-picker/date-picker.stories.ts +1 -1
  72. package/dist/assets/components/date-picker/date-picker.types.ts +1 -1
  73. package/dist/assets/components/date-picker/date-picker.vue +1 -1
  74. package/dist/assets/components/date-range-picker/components/date-range-picker-calendar/date-range-picker-calendar.vue +1 -1
  75. package/dist/assets/components/date-range-picker/components/date-time-input/date-time-input.types.ts +1 -1
  76. package/dist/assets/components/date-range-picker/components/date-time-input/date-time-input.vue +1 -1
  77. package/dist/assets/components/date-range-picker/date-range-picker.docs.mdx +31 -6
  78. package/dist/assets/components/date-range-picker/date-range-picker.stories.ts +1 -1
  79. package/dist/assets/components/date-range-picker/date-range-picker.types.ts +1 -1
  80. package/dist/assets/components/date-range-picker/date-range-picker.vue +1 -1
  81. package/dist/assets/components/date-time-picker/date-time-picker.stories.ts +1 -1
  82. package/dist/assets/components/date-time-picker/date-time-picker.types.ts +1 -1
  83. package/dist/assets/components/divider/divider.internal.types.ts +1 -0
  84. package/dist/assets/components/divider/divider.stories.ts +1 -1
  85. package/dist/assets/components/divider/divider.types.ts +1 -1
  86. package/dist/assets/components/divider/divider.vue +1 -1
  87. package/dist/assets/components/draggable/components/draggable-handle/draggable-handle.stories.ts +1 -1
  88. package/dist/assets/components/draggable/draggable.stories.ts +1 -1
  89. package/dist/assets/components/draggable/draggable.vue +1 -1
  90. package/dist/assets/components/drawer/drawer.stories.ts +1 -1
  91. package/dist/assets/components/dropdown/components/dropdown-base-textbox/dropdown-base-textbox.internal.types.ts +1 -0
  92. package/dist/assets/components/dropdown/components/dropdown-base-textbox/dropdown-base-textbox.types.ts +1 -1
  93. package/dist/assets/components/dropdown/components/dropdown-base-textbox/dropdown-base-textbox.vue +1 -1
  94. package/dist/assets/components/dropdown/components/dropdown-default-textbox/dropdown-default-textbox.vue +1 -1
  95. package/dist/assets/components/dropdown/components/dropdown-options-container/dropdown-options-container.vue +1 -1
  96. package/dist/assets/components/dropdown/components/dropdown-small-textbox/dropdown-small-textbox.vue +1 -1
  97. package/dist/assets/components/dropdown/components/variants/dropdown-avatar/dropdown-avatar.stories.ts +1 -1
  98. package/dist/assets/components/dropdown/components/variants/dropdown-avatar/dropdown-avatar.types.ts +1 -1
  99. package/dist/assets/components/dropdown/components/variants/dropdown-avatar/dropdown-avatar.vue +1 -1
  100. package/dist/assets/components/dropdown/components/variants/dropdown-country/dropdown-country.stories.ts +1 -1
  101. package/dist/assets/components/dropdown/components/variants/dropdown-country/dropdown-country.types.ts +1 -1
  102. package/dist/assets/components/dropdown/components/variants/dropdown-country/dropdown-country.vue +1 -1
  103. package/dist/assets/components/dropdown/components/variants/dropdown-currency/dropdown-currency.stories.ts +1 -1
  104. package/dist/assets/components/dropdown/components/variants/dropdown-currency/dropdown-currency.types.ts +1 -1
  105. package/dist/assets/components/dropdown/components/variants/dropdown-currency/dropdown-currency.vue +1 -1
  106. package/dist/assets/components/dropdown/components/variants/dropdown-payment-method/dropdown-payment-method.stories.ts +1 -1
  107. package/dist/assets/components/dropdown/components/variants/dropdown-payment-method/dropdown-payment-method.types.ts +1 -1
  108. package/dist/assets/components/dropdown/components/variants/dropdown-payment-method/dropdown-payment-method.vue +1 -1
  109. package/dist/assets/components/dropdown/components/variants/dropdown-tag/dropdown-tag.stories.ts +1 -1
  110. package/dist/assets/components/dropdown/components/variants/dropdown-tag/dropdown-tag.types.ts +1 -1
  111. package/dist/assets/components/dropdown/components/variants/dropdown-tag/dropdown-tag.vue +1 -1
  112. package/dist/assets/components/dropdown/dropdown.docs.mdx +4 -40
  113. package/dist/assets/components/dropdown/dropdown.internal.types.ts +1 -0
  114. package/dist/assets/components/dropdown/dropdown.stories.ts +1 -1
  115. package/dist/assets/components/dropdown/dropdown.types.ts +1 -1
  116. package/dist/assets/components/dropdown/dropdown.vue +1 -1
  117. package/dist/assets/components/empty-state/empty-state.stories.ts +1 -1
  118. package/dist/assets/components/empty-state/empty-state.types.ts +1 -1
  119. package/dist/assets/components/file-uploader/components/file-uploader-file-card/file-uploader-file-card.stories.ts +1 -1
  120. package/dist/assets/components/file-uploader/components/file-uploader-file-card/file-uploader-file-card.types.ts +1 -1
  121. package/dist/assets/components/file-uploader/components/file-uploader-file-card/file-uploader-file-card.vue +1 -1
  122. package/dist/assets/components/file-uploader/components/file-uploader-restrictions/file-uploader-restrictions.types.ts +1 -1
  123. package/dist/assets/components/file-uploader/components/file-uploader-restrictions/file-uploader-restrictions.vue +1 -1
  124. package/dist/assets/components/file-uploader/file-uploader.internal.types.ts +1 -0
  125. package/dist/assets/components/file-uploader/file-uploader.stories.ts +1 -1
  126. package/dist/assets/components/file-uploader/file-uploader.types.ts +1 -1
  127. package/dist/assets/components/file-uploader/file-uploader.vue +1 -1
  128. package/dist/assets/components/filter-bar/components/all-filters-modal/all-filters-modal.stories.ts +1 -1
  129. package/dist/assets/components/filter-bar/components/all-filters-modal/all-filters-modal.types.ts +1 -1
  130. package/dist/assets/components/filter-bar/components/all-filters-modal/all-filters-modal.vue +1 -1
  131. package/dist/assets/components/filter-bar/components/all-filters-modal/components/all-filters-modal-filter-selection/all-filters-modal-filter-selection.types.ts +1 -0
  132. package/dist/assets/components/filter-bar/components/all-filters-modal/components/all-filters-modal-filter-selection/all-filters-modal-filter-selection.vue +1 -0
  133. package/dist/assets/components/filter-bar/components/all-filters-modal/components/all-filters-modal-selected-filter/all-filters-modal-selected-filter.vue +1 -0
  134. package/dist/assets/components/filter-bar/components/base-filter/base-filter.internal.types.ts +1 -0
  135. package/dist/assets/components/filter-bar/components/base-filter/base-filter.types.ts +1 -1
  136. package/dist/assets/components/filter-bar/components/base-filter/base-filter.vue +1 -1
  137. package/dist/assets/components/filter-bar/components/boolean-filter/boolean-filter.vue +1 -1
  138. package/dist/assets/components/filter-bar/components/date-filter/date-filter.vue +1 -1
  139. package/dist/assets/components/filter-bar/components/date-range-filter/date-range-filter.vue +1 -1
  140. package/dist/assets/components/filter-bar/components/input-filter/input-filter.types.ts +1 -1
  141. package/dist/assets/components/filter-bar/components/input-filter/input-filter.vue +1 -1
  142. package/dist/assets/components/filter-bar/components/input-with-dropdown-filter/input-with-dropdown-filter.stories.ts +1 -1
  143. package/dist/assets/components/filter-bar/components/input-with-dropdown-filter/input-with-dropdown-filter.vue +1 -1
  144. package/dist/assets/components/filter-bar/components/select-filter/components/select-filter-button/select-filter-button.vue +1 -1
  145. package/dist/assets/components/filter-bar/components/select-filter/select-filter.vue +1 -1
  146. package/dist/assets/components/filter-bar/components/select-filter/variants/select-avatar-filter/select-avatar-filter.stories.ts +1 -1
  147. package/dist/assets/components/filter-bar/components/select-filter/variants/select-country-filter/select-country-filter.stories.ts +1 -1
  148. package/dist/assets/components/filter-bar/components/select-filter/variants/select-country-filter/select-country-filter.vue +1 -1
  149. package/dist/assets/components/filter-bar/components/toggle-filter/toggle-filter.vue +1 -1
  150. package/dist/assets/components/filter-bar/filter-bar.docs.mdx +4 -62
  151. package/dist/assets/components/filter-bar/filter-bar.stories.ts +1 -1
  152. package/dist/assets/components/filter-bar/filter-bar.types.ts +1 -1
  153. package/dist/assets/components/filter-bar/filter-bar.vue +1 -1
  154. package/dist/assets/components/form-layout/form-layout.docs.mdx +0 -23
  155. package/dist/assets/components/form-layout/form-layout.stories.ts +1 -1
  156. package/dist/assets/components/header/header.stories.ts +1 -1
  157. package/dist/assets/components/header/header.types.ts +1 -1
  158. package/dist/assets/components/header/header.vue +1 -1
  159. package/dist/assets/components/header-with-views/components/header-with-views-all-views/header-with-views-all-views.vue +1 -1
  160. package/dist/assets/components/header-with-views/components/header-with-views-item-edit-form/header-with-views-edit-form.types.ts +1 -1
  161. package/dist/assets/components/header-with-views/components/header-with-views-item-edit-form/header-with-views-edit-form.vue +1 -1
  162. package/dist/assets/components/header-with-views/header-with-views.internal.types.ts +1 -0
  163. package/dist/assets/components/header-with-views/header-with-views.stories.ts +1 -1
  164. package/dist/assets/components/header-with-views/header-with-views.types.ts +1 -1
  165. package/dist/assets/components/header-with-views/header-with-views.vue +1 -1
  166. package/dist/assets/components/image/image.stories.ts +1 -1
  167. package/dist/assets/components/info-icon/info-icon.stories.ts +1 -1
  168. package/dist/assets/components/input-field/input-field.docs.mdx +1 -13
  169. package/dist/assets/components/input-field/input-field.stories.ts +1 -1
  170. package/dist/assets/components/input-field/input-field.types.ts +1 -1
  171. package/dist/assets/components/input-field/input-field.vue +1 -1
  172. package/dist/assets/components/input-field-password/input-field-password.internal.types.ts +1 -0
  173. package/dist/assets/components/input-field-password/input-field-password.stories.ts +1 -1
  174. package/dist/assets/components/input-field-password/input-field-password.types.ts +1 -1
  175. package/dist/assets/components/input-field-password/input-field-password.vue +1 -1
  176. package/dist/assets/components/input-field-phone-number/input-field-phone-number.stories.ts +1 -1
  177. package/dist/assets/components/input-field-phone-number/input-field-phone-number.types.ts +1 -1
  178. package/dist/assets/components/input-field-phone-number/input-field-phone-number.vue +1 -1
  179. package/dist/assets/components/input-time/input-time.docs.mdx +17 -0
  180. package/dist/assets/components/input-time/input-time.stories.ts +1 -1
  181. package/dist/assets/components/input-time/input-time.types.ts +1 -1
  182. package/dist/assets/components/input-time/input-time.vue +1 -1
  183. package/dist/assets/components/inspector/inspector.stories.ts +1 -1
  184. package/dist/assets/components/inspector/inspector.vue +1 -1
  185. package/dist/assets/components/layout/components/layout-row/layout-row.stories.ts +1 -1
  186. package/dist/assets/components/layout/components/layout-row/layout-row.vue +1 -1
  187. package/dist/assets/components/layout/layout.docs.mdx +10 -0
  188. package/dist/assets/components/layout/layout.internal.types.ts +1 -0
  189. package/dist/assets/components/layout/layout.stories.ts +1 -1
  190. package/dist/assets/components/layout/layout.types.ts +1 -1
  191. package/dist/assets/components/link/link.stories.ts +1 -1
  192. package/dist/assets/components/link/link.types.ts +1 -1
  193. package/dist/assets/components/link/link.vue +1 -1
  194. package/dist/assets/components/list/list.stories.ts +1 -1
  195. package/dist/assets/components/loading-indicator/loading-indicator.stories.ts +1 -1
  196. package/dist/assets/components/menu/components/menu-item/menu-item.types.ts +1 -1
  197. package/dist/assets/components/menu/components/menu-item/menu-item.vue +1 -1
  198. package/dist/assets/components/menu/components/menu-item-list/menu-item-list.vue +1 -1
  199. package/dist/assets/components/menu/components/sub-menu-item-list/sub-menu-item-list.vue +1 -1
  200. package/dist/assets/components/menu/menu.docs.mdx +17 -7
  201. package/dist/assets/components/menu/menu.stories.ts +1 -1
  202. package/dist/assets/components/menu/menu.types.ts +1 -1
  203. package/dist/assets/components/menu/menu.vue +1 -1
  204. package/dist/assets/components/modal/components/base-modal/base-modal.vue +1 -1
  205. package/dist/assets/components/modal/components/modal-page/modal-page.vue +1 -1
  206. package/dist/assets/components/modal/modal.internal.types.ts +1 -0
  207. package/dist/assets/components/modal/modal.stories.ts +1 -1
  208. package/dist/assets/components/modal/modal.types.ts +1 -1
  209. package/dist/assets/components/modal/modal.vue +1 -1
  210. package/dist/assets/components/modal-fullscreen/components/modal-fullscreen-page.vue +1 -1
  211. package/dist/assets/components/modal-fullscreen/modal-fullscreen.stories.ts +1 -1
  212. package/dist/assets/components/modal-fullscreen/modal-fullscreen.vue +1 -1
  213. package/dist/assets/components/navigation-menu/components/navigation-menu-group/navigation-menu-group.internal.types.ts +1 -0
  214. package/dist/assets/components/navigation-menu/components/navigation-menu-group/navigation-menu-group.types.ts +1 -1
  215. package/dist/assets/components/navigation-menu/components/navigation-menu-group/navigation-menu-group.vue +1 -1
  216. package/dist/assets/components/navigation-menu/components/navigation-menu-item/navigation-menu-item.vue +1 -1
  217. package/dist/assets/components/navigation-menu/navigation-menu.internal.types.ts +1 -0
  218. package/dist/assets/components/navigation-menu/navigation-menu.stories.ts +1 -1
  219. package/dist/assets/components/navigation-menu/navigation-menu.types.ts +1 -1
  220. package/dist/assets/components/navigation-menu/navigation-menu.vue +1 -1
  221. package/dist/assets/components/pagination/components/pagination-context/pagination-context.vue +1 -1
  222. package/dist/assets/components/pagination/components/pagination-results-per-page/pagination-results-per-page.vue +1 -1
  223. package/dist/assets/components/pagination/pagination.stories.ts +1 -1
  224. package/dist/assets/components/pagination/pagination.types.ts +1 -1
  225. package/dist/assets/components/pagination/pagination.vue +1 -1
  226. package/dist/assets/components/payment-method/payment-method.stories.ts +1 -1
  227. package/dist/assets/components/payment-method/payment-method.types.ts +1 -1
  228. package/dist/assets/components/popover/popover.docs.mdx +32 -9
  229. package/dist/assets/components/popover/popover.stories.ts +1 -1
  230. package/dist/assets/components/popover/popover.types.ts +1 -1
  231. package/dist/assets/components/popover/popover.vue +1 -1
  232. package/dist/assets/components/popper-container/popper-container.types.ts +1 -1
  233. package/dist/assets/components/popper-container/popper-container.vue +1 -1
  234. package/dist/assets/components/progress-bar/progress-bar.docs.mdx +102 -0
  235. package/dist/assets/components/progress-bar/progress-bar.stories.ts +1 -0
  236. package/dist/assets/components/progress-bar/progress-bar.types.ts +1 -0
  237. package/dist/assets/components/progress-bar/progress-bar.vue +1 -0
  238. package/dist/assets/components/promo-banner/promo-banner.stories.ts +1 -1
  239. package/dist/assets/components/promo-banner/promo-banner.types.ts +1 -1
  240. package/dist/assets/components/promo-banner/promo-banner.vue +1 -1
  241. package/dist/assets/components/radio-group/components/radio-button/radio-button.vue +1 -1
  242. package/dist/assets/components/radio-group/radio-group.docs.mdx +1 -6
  243. package/dist/assets/components/radio-group/radio-group.stories.ts +1 -1
  244. package/dist/assets/components/radio-group/radio-group.types.ts +1 -1
  245. package/dist/assets/components/radio-group/radio-group.vue +1 -1
  246. package/dist/assets/components/rich-text-editor/rich-text-editor.internal.types.ts +1 -0
  247. package/dist/assets/components/rich-text-editor/rich-text-editor.stories.ts +1 -1
  248. package/dist/assets/components/rich-text-editor/rich-text-editor.types.ts +1 -1
  249. package/dist/assets/components/rich-text-editor/rich-text-editor.vue +1 -1
  250. package/dist/assets/components/search-bar/search-bar.stories.ts +1 -1
  251. package/dist/assets/components/search-bar/search-bar.vue +1 -1
  252. package/dist/assets/components/secondary-nav/components/secondary-nav-item/secondary-nav-item.vue +1 -1
  253. package/dist/assets/components/secondary-nav/secondary-nav.stories.ts +1 -1
  254. package/dist/assets/components/secondary-nav/secondary-nav.vue +1 -1
  255. package/dist/assets/components/segmented-control/components/segmented-control-button/segmented-control-button.vue +1 -1
  256. package/dist/assets/components/segmented-control/segmented-control.stories.ts +1 -1
  257. package/dist/assets/components/segmented-control/segmented-control.types.ts +1 -1
  258. package/dist/assets/components/segmented-control/segmented-control.vue +1 -1
  259. package/dist/assets/components/selection-card/components/selection-card-group/selection-card-group.docs.mdx +12 -13
  260. package/dist/assets/components/selection-card/components/selection-card-group/selection-card-group.stories.ts +1 -1
  261. package/dist/assets/components/selection-card/components/selection-card-group/selection-card-group.vue +1 -1
  262. package/dist/assets/components/selection-card/selection-card.stories.ts +1 -1
  263. package/dist/assets/components/selection-card/selection-card.types.ts +1 -1
  264. package/dist/assets/components/selection-card/selection-card.vue +1 -1
  265. package/dist/assets/components/sidepanel/sidepanel.docs.mdx +1 -1
  266. package/dist/assets/components/sidepanel/sidepanel.stories.ts +1 -1
  267. package/dist/assets/components/sidepanel/sidepanel.vue +1 -1
  268. package/dist/assets/components/status/status.stories.ts +1 -1
  269. package/dist/assets/components/status/status.types.ts +1 -1
  270. package/dist/assets/components/stepper/components/step/step.vue +1 -1
  271. package/dist/assets/components/stepper/stepper.stories.ts +1 -1
  272. package/dist/assets/components/stepper/stepper.vue +1 -1
  273. package/dist/assets/components/structured-list/structured-list.stories.ts +1 -1
  274. package/dist/assets/components/structured-list/structured-list.vue +1 -1
  275. package/dist/assets/components/summary-grid/components/summary-grid-item/summary-grid-item.types.ts +1 -1
  276. package/dist/assets/components/summary-grid/summary-grid.stories.ts +1 -1
  277. package/dist/assets/components/summary-grid/summary-grid.types.ts +1 -1
  278. package/dist/assets/components/table-of-contents/components/table-of-contents-list/table-of-contents-list.vue +1 -1
  279. package/dist/assets/components/table-of-contents/table-of-contents.internal.types.ts +1 -0
  280. package/dist/assets/components/table-of-contents/table-of-contents.stories.ts +1 -1
  281. package/dist/assets/components/table-of-contents/table-of-contents.types.ts +1 -1
  282. package/dist/assets/components/table-of-contents/table-of-contents.vue +1 -1
  283. package/dist/assets/components/tabs/components/tab.internal.types.ts +1 -0
  284. package/dist/assets/components/tabs/components/tab.types.ts +1 -1
  285. package/dist/assets/components/tabs/components/tab.vue +1 -1
  286. package/dist/assets/components/tabs/tabs.stories.ts +1 -1
  287. package/dist/assets/components/tabs/tabs.vue +1 -1
  288. package/dist/assets/components/tag/tag.docs.mdx +1 -1
  289. package/dist/assets/components/tag/tag.stories.ts +1 -1
  290. package/dist/assets/components/tag/tag.types.ts +1 -1
  291. package/dist/assets/components/tag/tag.vue +1 -1
  292. package/dist/assets/components/textarea/textarea.docs.mdx +0 -7
  293. package/dist/assets/components/textarea/textarea.stories.ts +1 -1
  294. package/dist/assets/components/textarea/textarea.types.ts +1 -1
  295. package/dist/assets/components/textarea/textarea.vue +1 -1
  296. package/dist/assets/components/timeline/components/timeline-item/timeline-item.stories.ts +1 -1
  297. package/dist/assets/components/timeline/components/timeline-item/timeline-item.vue +1 -1
  298. package/dist/assets/components/timeline/timeline.docs.mdx +0 -10
  299. package/dist/assets/components/timeline/timeline.internal.types.ts +1 -0
  300. package/dist/assets/components/timeline/timeline.stories.ts +1 -1
  301. package/dist/assets/components/timeline/timeline.types.ts +1 -1
  302. package/dist/assets/components/timeline/timeline.vue +1 -1
  303. package/dist/assets/components/toast/components/toast-item/toast-item.vue +1 -1
  304. package/dist/assets/components/toggle/toggle.stories.ts +1 -1
  305. package/dist/assets/components/toggle/toggle.types.ts +1 -1
  306. package/dist/assets/components/toggle/toggle.vue +1 -1
  307. package/dist/assets/components/tutorial/tutorial.stories.ts +1 -1
  308. package/dist/assets/components/typography/typography.stories.ts +1 -1
  309. package/dist/assets/components/typography/typography.types.ts +1 -1
  310. package/dist/assets/components/typography/typography.vue +1 -1
  311. package/dist/assets/components.json +1 -0
  312. package/dist/assets/composables/use-bento-base-filter/index.ts +1 -0
  313. package/dist/assets/composables/use-bento-base-filter/use-bento-base-filter.ts +1 -0
  314. package/dist/assets/composables/use-bento-base-filter/utils/index.ts +1 -0
  315. package/dist/assets/composables/use-bento-base-filter/utils/utils.ts +1 -0
  316. package/dist/assets/composables/use-bento-currency/index.ts +1 -0
  317. package/dist/assets/composables/use-bento-currency/use-bento-currency.stories.ts +1 -1
  318. package/dist/assets/composables/use-bento-currency/use-bento-currency.ts +1 -0
  319. package/dist/assets/composables/use-bento-delayed-hover/index.ts +1 -0
  320. package/dist/assets/composables/use-bento-delayed-hover/use-bento-delayed-hover.stories.ts +1 -1
  321. package/dist/assets/composables/use-bento-delayed-hover/use-bento-delayed-hover.ts +1 -0
  322. package/dist/assets/composables/use-bento-theme/index.ts +1 -0
  323. package/dist/assets/composables/use-bento-theme/install.ts +1 -1
  324. package/dist/assets/composables/use-bento-theme/install.types.ts +1 -1
  325. package/dist/assets/composables/use-bento-theme/use-bento-theme.ts +1 -0
  326. package/dist/assets/composables/use-bento-toast-controller/index.ts +1 -0
  327. package/dist/assets/composables/use-bento-toast-controller/toast-stack.ts +1 -0
  328. package/dist/assets/composables/use-bento-toast-controller/use-bento-toast-controller.ts +1 -0
  329. package/dist/assets/composables/use-click-outside/index.ts +1 -0
  330. package/dist/assets/composables/use-click-outside/use-click-outside.stories.ts +1 -1
  331. package/dist/assets/composables/use-click-outside/use-click-outside.ts +1 -0
  332. package/dist/assets/composables/use-form-validate/index.ts +1 -0
  333. package/dist/assets/composables/use-form-validate/use-form.ts +1 -0
  334. package/dist/assets/composables/use-form-validate/use-form.types.ts +1 -1
  335. package/dist/assets/composables.json +9 -0
  336. package/dist/assets/deprecations.md +139 -243
  337. package/dist/assets/directives/highlight/highlight.stories.ts +1 -1
  338. package/dist/assets/directives/keyboard-navigation/keyboard-navigation.stories.ts +1 -1
  339. package/dist/assets/directives/tooltip/tooltip.internal.types.ts +1 -0
  340. package/dist/assets/directives/tooltip/tooltip.stories.ts +1 -1
  341. package/dist/assets/directives/tooltip/tooltip.types.ts +1 -1
  342. package/dist/assets/icons.json +1 -0
  343. package/dist/assets/index.ts +1 -1
  344. package/dist/assets/install.ts +1 -1
  345. package/dist/assets/tailwind/README.md +3 -3
  346. package/dist/assets/templates/dashboard-template/components/dashboard-section/dashboard-section.stories.ts +1 -1
  347. package/dist/assets/templates/dashboard-template/dashboard-template.stories.ts +1 -1
  348. package/dist/assets/templates/data-grid-template/data-grid-template.stories.ts +1 -1
  349. package/dist/assets/usage.json +81 -80
  350. package/dist/assets/variables.css +152 -140
  351. package/dist/main.js +228 -34
  352. package/package.json +2 -2
  353. package/dist/assets/components/internal/base-button/base-button.types.ts +0 -1
  354. package/dist/assets/components/internal/base-button/base-button.vue +0 -1
  355. package/dist/assets/components/internal/button-actions-with-menu/button-actions-with-menu.stories.ts +0 -1
  356. package/dist/assets/components/internal/button-actions-with-menu/button-actions-with-menu.types.ts +0 -1
  357. package/dist/assets/components/internal/button-actions-with-menu/button-actions-with-menu.vue +0 -1
  358. package/dist/assets/components/internal/calendar/calendar.stories.ts +0 -1
  359. package/dist/assets/components/internal/calendar/calendar.types.ts +0 -1
  360. package/dist/assets/components/internal/calendar/calendar.vue +0 -1
  361. package/dist/assets/components/internal/calendar/components/calendar-month/calendar-month.stories.ts +0 -1
  362. package/dist/assets/components/internal/calendar/components/calendar-month/calendar-month.types.ts +0 -1
  363. package/dist/assets/components/internal/calendar/components/calendar-month/calendar-month.vue +0 -1
  364. package/dist/assets/components/internal/calendar/components/calendar-month/components/calendar-month-day/__test__/calendar-month-day-stub.vue +0 -1
  365. package/dist/assets/components/internal/calendar/components/calendar-month/components/calendar-month-day/calendar-month-day.stories.ts +0 -1
  366. package/dist/assets/components/internal/calendar/components/calendar-month/components/calendar-month-day/calendar-month-day.types.ts +0 -1
  367. package/dist/assets/components/internal/calendar/components/calendar-month/components/calendar-month-day/calendar-month-day.vue +0 -1
  368. package/dist/assets/components/internal/calendar/components/calendar-month/composables/granular-min-max-date.types.ts +0 -1
  369. package/dist/assets/components/internal/calendar/components/calendar-year/calendar-year.types.ts +0 -1
  370. package/dist/assets/components/internal/calendar/components/calendar-year/calendar-year.vue +0 -1
  371. package/dist/assets/components/internal/calendar/components/calendar-year/components/calendar-year-month/__test__/calendar-year-month-stub.vue +0 -1
  372. package/dist/assets/components/internal/calendar/components/calendar-year/components/calendar-year-month/calendar-year-month.types.ts +0 -1
  373. package/dist/assets/components/internal/calendar/components/calendar-year/components/calendar-year-month/calendar-year-month.vue +0 -1
  374. package/dist/assets/components/internal/calendar/components/calendar-year-selector/calendar-year-selector.types.ts +0 -1
  375. package/dist/assets/components/internal/calendar/components/calendar-year-selector/calendar-year-selector.vue +0 -1
  376. package/dist/assets/components/internal/calendar/composables/use-granularity-adjustments.types.ts +0 -1
  377. package/dist/assets/components/internal/calendar/composables/use-range-pane.types.ts +0 -1
  378. package/dist/assets/components/internal/checkbox-input/checkbox-input.stories.ts +0 -1
  379. package/dist/assets/components/internal/checkbox-input/checkbox-input.types.ts +0 -1
  380. package/dist/assets/components/internal/checkbox-input/checkbox-input.vue +0 -1
  381. package/dist/assets/components/internal/controls-group/controls-group.vue +0 -1
  382. package/dist/assets/components/internal/copy/copy.docs.mdx +0 -43
  383. package/dist/assets/components/internal/copy/copy.stories.ts +0 -1
  384. package/dist/assets/components/internal/copy/copy.types.ts +0 -1
  385. package/dist/assets/components/internal/copy/copy.vue +0 -1
  386. package/dist/assets/components/internal/decorative-checkbox/decorative-checkbox.vue +0 -1
  387. package/dist/assets/components/internal/dialog-page/dialog-page.types.ts +0 -1
  388. package/dist/assets/components/internal/dialog-page/dialog-page.vue +0 -1
  389. package/dist/assets/components/internal/error-message/error-message.vue +0 -1
  390. package/dist/assets/components/internal/field-label/field-label.vue +0 -1
  391. package/dist/assets/components/internal/fixed-scroller/fixed-scroller.docs.mdx +0 -21
  392. package/dist/assets/components/internal/fixed-scroller/fixed-scroller.stories.ts +0 -1
  393. package/dist/assets/components/internal/fixed-scroller/fixed-scroller.vue +0 -1
  394. package/dist/assets/components/internal/footer-actions/footer-actions.vue +0 -1
  395. package/dist/assets/components/internal/grid-layout/grid-layout.types.ts +0 -1
  396. package/dist/assets/components/internal/grid-layout/grid-layout.vue +0 -1
  397. package/dist/assets/components/internal/header-meta/header-meta.types.ts +0 -1
  398. package/dist/assets/components/internal/header-meta/header-meta.vue +0 -1
  399. package/dist/assets/components/internal/info-icon-with-popover/info-icon-with-popover.vue +0 -1
  400. package/dist/assets/components/internal/listbox/components/listbox-lazy-load/listbox-lazy-load.types.ts +0 -1
  401. package/dist/assets/components/internal/listbox/components/listbox-lazy-load/listbox-lazy-load.vue +0 -1
  402. package/dist/assets/components/internal/listbox/components/listbox-multi-select/components/listbox-multi-select-options/components/listbox-multi-select-category/listbox-multi-select-category.types.ts +0 -1
  403. package/dist/assets/components/internal/listbox/components/listbox-multi-select/components/listbox-multi-select-options/components/listbox-multi-select-category/listbox-multi-select-category.vue +0 -1
  404. package/dist/assets/components/internal/listbox/components/listbox-multi-select/components/listbox-multi-select-options/components/listbox-multi-select-nested-lazy-load/listbox-multi-select-nested-lazy-load.types.ts +0 -1
  405. package/dist/assets/components/internal/listbox/components/listbox-multi-select/components/listbox-multi-select-options/components/listbox-multi-select-nested-lazy-load/listbox-multi-select-nested-lazy-load.vue +0 -1
  406. package/dist/assets/components/internal/listbox/components/listbox-multi-select/components/listbox-multi-select-options/listbox-multi-select-options.types.ts +0 -1
  407. package/dist/assets/components/internal/listbox/components/listbox-multi-select/components/listbox-multi-select-options/listbox-multi-select-options.vue +0 -1
  408. package/dist/assets/components/internal/listbox/components/listbox-multi-select/listbox-multi-select.types.ts +0 -1
  409. package/dist/assets/components/internal/listbox/components/listbox-multi-select/listbox-multi-select.vue +0 -1
  410. package/dist/assets/components/internal/listbox/components/listbox-option/listbox-option.vue +0 -1
  411. package/dist/assets/components/internal/listbox/components/listbox-option-tag/listbox-option-tag.vue +0 -1
  412. package/dist/assets/components/internal/listbox/components/listbox-single-select/components/listbox-single-select-category/listbox-single-select-category.vue +0 -1
  413. package/dist/assets/components/internal/listbox/components/listbox-single-select/listbox-single-select.vue +0 -1
  414. package/dist/assets/components/internal/listbox/components/listbox-single-select-option/listbox-single-select-option.vue +0 -1
  415. package/dist/assets/components/internal/listbox/listbox.stories.ts +0 -1
  416. package/dist/assets/components/internal/listbox/listbox.types.ts +0 -1
  417. package/dist/assets/components/internal/listbox/listbox.vue +0 -1
  418. package/dist/assets/components/internal/radio-input/radio-input.stories.ts +0 -1
  419. package/dist/assets/components/internal/radio-input/radio-input.types.ts +0 -1
  420. package/dist/assets/components/internal/radio-input/radio-input.vue +0 -1
  421. package/dist/assets/components/internal/teleport/teleport.types.ts +0 -1
  422. package/dist/assets/components/internal/teleport/teleport.vue +0 -1
  423. package/dist/assets/components/internal/tooltip/tooltip.test.vue +0 -1
  424. package/dist/assets/components/internal/tooltip/tooltip.types.ts +0 -1
  425. package/dist/assets/components/internal/tooltip/tooltip.vue +0 -1
  426. package/dist/assets/composables/use-form-validate-zod-4/use-form.types.ts +0 -1
  427. package/dist/assets/composables/use-numeric-input/use-numeric-input.types.ts +0 -1
  428. package/dist/assets/composables/use-section-navigation-keyboard/use-section-navigation-keyboard.types.ts +0 -1
  429. package/dist/assets/composables/use-virtual-list/use-virtual-list.types.ts +0 -1
@@ -1 +1 @@
1
- import { action } from '@storybook/addon-actions'; import type { Meta, StoryObj } from '@storybook/vue'; import { ref } from 'vue'; import { isVue2 } from 'vue-demi'; import { BentoSegmentedControlEvent } from './segmented-control.types'; import BentoSegmentedControl from './segmented-control.vue'; import { storybookDocsParameter } from '@/core/utils/ts/storybook'; const ITEMS = [ { label: 'Segment 1', value: 1 }, { label: 'Segment 2', value: 2 }, { label: 'Segment 3', value: 3, disabled: true }, ]; const meta: Meta = { title: 'Segmented Control', component: BentoSegmentedControl, argTypes: { items: { control: { disable: true }, }, modelValue: { control: { disable: true }, }, // Events 'update:model-value': { table: { type: { summary: '(modelValue: string | number) => void' } }, control: { disable: true }, }, input: { table: { type: { summary: '(modelValue: string | number) => void' } }, control: { disable: true }, }, }, }; export default meta; type Story = StoryObj<typeof BentoSegmentedControl>; const defaultCode = ` <template> <bento-segmented-control v-model="selectedValue" :items="${JSON.stringify(ITEMS)}" aria-label="Segmented control example" full-width wrap @update:model-value="updateaction" @input="inputAction" /> </template> <script setup lang="ts"> import { BentoSegmentedControl, BentoSegmentedControlValue } from '@adyen/bento-vue2' import { ref } from 'vue' const selectedValue = ref<BentoSegmentedControlValue>() // Events const updateaction = () => { // Manually control the "@update:model-value" event in Vue3 } const inputAction = () => { // Manually control the "input" event in Vue2 } </script> `; export const Default: Story = { render: (_args, { argTypes }) => ({ components: { BentoSegmentedControl }, props: Object.keys(argTypes), template: ` <bento-segmented-control v-bind="args" v-model="selectedValue" :items="items" aria-label="Segmented control example" @update:model-value="updateAction" @input="inputAction" /> `, setup(props) { const selectedValue = ref(ITEMS[0].value); const items = ITEMS; const updateAction = value => { action(BentoSegmentedControlEvent.UPDATE)(value); }; const inputAction = value => { action('input')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, items, // Events updateAction, inputAction, }; }, }), args: {}, parameters: storybookDocsParameter(defaultCode), };
1
+ import { action } from '@storybook/addon-actions'; import type { Meta, StoryObj } from '@storybook/vue'; import { ref } from 'vue'; import { isVue2 } from 'vue-demi'; import BentoSegmentedControl from './segmented-control.vue'; const SegmentedControlDefaultExample = "<template>\n <bento-segmented-control v-model=\"selectedValue\" :items=\"items\" aria-label=\"Segmented control example\" />\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import {\n BentoSegmentedControl,\n type BentoSegmentedControlItem,\n type BentoSegmentedControlValue,\n } from '@adyen/bento-vue2';\n\n const items: Array<BentoSegmentedControlItem> = [\n { label: 'Segment 1', value: 1 },\n { label: 'Segment 2', value: 2 },\n { label: 'Segment 3', value: 3, disabled: true },\n ];\n const selectedValue = ref<BentoSegmentedControlValue>(items[0].value);\n</script>\n"; import { storybookDocsParameter } from '@/utils/ts/storybook'; const ITEMS = [ { label: 'Segment 1', value: 1 }, { label: 'Segment 2', value: 2 }, { label: 'Segment 3', value: 3, disabled: true }, ]; const meta: Meta = { title: 'Segmented Control', component: BentoSegmentedControl, argTypes: { items: { control: { disable: true }, }, modelValue: { control: { disable: true }, }, // Events 'update:model-value': { table: { type: { summary: '(modelValue: string | number) => void' } }, control: { disable: true }, }, input: { table: { type: { summary: '(modelValue: string | number) => void' } }, control: { disable: true }, }, }, }; export default meta; type Story = StoryObj<typeof BentoSegmentedControl>; export const Default: Story = { render: (_args, { argTypes }) => ({ components: { BentoSegmentedControl }, props: Object.keys(argTypes), template: ` <bento-segmented-control v-bind="args" v-model="selectedValue" :items="items" aria-label="Segmented control example" @update:model-value="updateAction" @input="inputAction" /> `, setup(props) { const selectedValue = ref(ITEMS[0].value); const items = ITEMS; const updateAction = value => { action('update:model-value')(value); }; const inputAction = value => { action('input')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, items, // Events updateAction, inputAction, }; }, }), args: {}, parameters: storybookDocsParameter(SegmentedControlDefaultExample), };
@@ -1 +1 @@
1
- export type BentoSegmentedControlValue = string | number; export interface BentoSegmentedControlProps { /** * Accessible name describing the segmented control. * @deprecated Since v2.0.0. Use `aria-label` instead. */ ariaLabel?: string; /** * If set to true, renders the component full width. */ fullWidth?: boolean; /** * Items that will populate the segmented control. */ items: Array<BentoSegmentedControlItem>; /** * Determines the selected value of the group. Corresponds to the BentoSegmentedControlItem's value. */ modelValue?: BentoSegmentedControlValue; /** * If set to true, wraps the items in the segmented control to show their content whenever these don't fit in the available space anymore. */ wrap?: boolean; } export interface BentoSegmentedControlItem { label: string; value: string | number; disabled?: boolean; } /** * @deprecated Since v2.0.0. Use `update:model-value` or `v-model` instead. */ export enum BentoSegmentedControlEvent { UPDATE = 'update:model-value', }
1
+ export type BentoSegmentedControlValue = string | number; export interface BentoSegmentedControlProps { /** * If set to true, renders the component full width. */ fullWidth?: boolean; /** * Items that will populate the segmented control. */ items: Array<BentoSegmentedControlItem>; /** * Determines the selected value of the group. Corresponds to the BentoSegmentedControlItem's value. */ modelValue?: BentoSegmentedControlValue; /** * If set to true, wraps the items in the segmented control to show their content whenever these don't fit in the available space anymore. */ wrap?: boolean; } export interface BentoSegmentedControlItem { label: string; value: string | number; disabled?: boolean; } /** * @deprecated Since v3.0.0. Use `update:model-value` or `v-model` instead. */ export enum BentoSegmentedControlEvent { UPDATE = 'update:model-value', }
@@ -1 +1 @@
1
- <template> <div ref="segmentedControlRef" role="group" class="b-segmented-control" :class="conditionalClasses"> <segmented-control-button v-for="(item, index) in computedItems" ref="segmentedControlButtonRef" :key="`segmented-control-item-${index}-${item.label}`" class="b-segmented-control__item" :label="item.label" :value="item.value" :disabled="item.disabled" :truncate="truncate" :wrap="wrap" :full-width="fullWidth" :model-value="inputValue" :tooltip-text="item.tooltipText" @update:model-value="onInput" /> </div> </template> <script setup lang="ts"> import { computed, onMounted, ref, toRef, watch } from 'vue'; import SegmentedControlButton from './components/segmented-control-button/segmented-control-button.vue'; import { type BentoSegmentedControlProps, type BentoSegmentedControlValue } from './segmented-control.types'; import { observeSizeOfElement } from '@/utils/ts/resize'; import { printDevelopmentWarning } from '@/utils/ts/print-development-warning'; const emit = defineEmits<{ /** * Emitted every time the segmented control internal value is changed for Vue3 */ (e: 'update:model-value', value: any); /** * Emitted every time the segmented control internal value is changed for Vue2 * */ (e: 'input', value: BentoSegmentedControlValue): void; }>(); const props = withDefaults(defineProps<BentoSegmentedControlProps>(), { ariaLabel: null, fullWidth: false, wrap: false, modelValue: null, }); const inputValue = toRef(props, 'modelValue'); const segmentedControlRef = ref(); const segmentedControlButtonRef = ref(); const hasEllipsis = ref(); const truncate = computed(() => !props.wrap); watch( () => props.items, () => { if (props.items.length > 5) { printDevelopmentWarning( 'Do not use when you need to provide more than 5 segments at a time. If you need to provide more options, use a dropdown component.' ); } }, { immediate: true } ); onMounted(() => { observeSizeOfElement(segmentedControlRef.value, () => { if (segmentedControlRef.value) { hasEllipsis.value = segmentedControlButtonRef?.value?.map( el => el.$refs.segmentedControlButtonLabel.$el.offsetWidth < el.$refs.segmentedControlButtonLabel.$el.scrollWidth ); } }); }); const computedItems = computed(() => props.items.map((el, index) => ({ ...el, tooltipText: truncate.value && hasEllipsis?.value?.[index] ? el.label : undefined, })) ); const onInput = value => { emit('update:model-value', value); emit('input', value); }; const conditionalClasses = computed(() => ({ 'b-segmented-control--hug': !props.fullWidth, 'b-segmented-control--full-width': props.fullWidth, 'b-segmented-control--truncate': truncate.value, 'b-segmented-control--wrap': props.wrap, })); </script> <script lang="ts"> /** * @example * import { BentoSegmentedControl } from '@adyen/bento-vue2'; * * export default { * components: { BentoSegmentedControl }, * template: ` * <bento-segmented-control * :items="[{ label: 'Segment 1', value: 1 }, { label: 'Segment 2', value: 2 }, { label: 'Segment 3', value: 3, disabled: true }]" * :model-value="1" * @update:model-value="yourUpdateHandler" * /> * ` * } */ export default { name: 'bento-segmented-control', model: { prop: 'modelValue' }, }; </script> <style lang="scss" scoped src="./segmented-control.scss" />
1
+ <template> <div ref="segmentedControlRef" role="group" class="b-segmented-control" :class="conditionalClasses"> <segmented-control-button v-for="(item, index) in computedItems" ref="segmentedControlButtonRef" :key="`segmented-control-item-${index}-${item.label}`" class="b-segmented-control__item" :label="item.label" :value="item.value" :disabled="item.disabled" :truncate="truncate" :wrap="wrap" :full-width="fullWidth" :model-value="inputValue" :tooltip-text="item.tooltipText" @update:model-value="onInput" /> </div> </template> <script setup lang="ts"> import { computed, onMounted, ref, toRef, watch } from 'vue'; import SegmentedControlButton from './components/segmented-control-button/segmented-control-button.vue'; import { type BentoSegmentedControlProps, type BentoSegmentedControlValue } from './segmented-control.types'; import { observeSizeOfElement } from '@/utils/ts/resize'; import { printDevelopmentWarning } from '@/utils/ts/print-development-warning'; const emit = defineEmits<{ /** * Emitted every time the segmented control internal value is changed for Vue3 */ (e: 'update:model-value', value: any); /** * Emitted every time the segmented control internal value is changed for Vue2 * */ (e: 'input', value: BentoSegmentedControlValue): void; }>(); const props = withDefaults(defineProps<BentoSegmentedControlProps>(), { fullWidth: false, wrap: false, modelValue: null, }); const inputValue = toRef(props, 'modelValue'); const segmentedControlRef = ref(); const segmentedControlButtonRef = ref(); const hasEllipsis = ref(); const truncate = computed(() => !props.wrap); watch( () => props.items, () => { if (props.items.length > 5) { printDevelopmentWarning( 'Do not use when you need to provide more than 5 segments at a time. If you need to provide more options, use a dropdown component.' ); } }, { immediate: true } ); onMounted(() => { observeSizeOfElement(segmentedControlRef.value, () => { if (segmentedControlRef.value) { hasEllipsis.value = segmentedControlButtonRef?.value?.map( el => el.$refs.segmentedControlButtonLabel.$el.offsetWidth < el.$refs.segmentedControlButtonLabel.$el.scrollWidth ); } }); }); const computedItems = computed(() => props.items.map((el, index) => ({ ...el, tooltipText: truncate.value && hasEllipsis?.value?.[index] ? el.label : undefined, })) ); const onInput = value => { emit('update:model-value', value); emit('input', value); }; const conditionalClasses = computed(() => ({ 'b-segmented-control--hug': !props.fullWidth, 'b-segmented-control--full-width': props.fullWidth, 'b-segmented-control--truncate': truncate.value, 'b-segmented-control--wrap': props.wrap, })); </script> <script lang="ts"> /** * @example * import { BentoSegmentedControl } from '@adyen/bento-vue2'; * * export default { * components: { BentoSegmentedControl }, * template: ` * <bento-segmented-control * :items="[{ label: 'Segment 1', value: 1 }, { label: 'Segment 2', value: 2 }, { label: 'Segment 3', value: 3, disabled: true }]" * :model-value="1" * @update:model-value="yourUpdateHandler" * /> * ` * } */ export default { name: 'bento-segmented-control', model: { prop: 'modelValue' }, }; </script> <style lang="scss" scoped src="./segmented-control.scss" />
@@ -14,8 +14,8 @@ handles the group's label and error handling logic.
14
14
 
15
15
  Use a `bento-selection-card-group` if:
16
16
 
17
- - You need to render related `bento-selection-card`
18
- - You need to render `bento-selection-card` with a `radio` input
17
+ - You need to render related `bento-selection-card`
18
+ - You need to render `bento-selection-card` with a `radio` input
19
19
 
20
20
  ### Do not use
21
21
 
@@ -29,14 +29,13 @@ with a `checkbox` input and without an associated label). In this case, use the
29
29
  Determines what kind of input element and selection logic is applied to the `bento-selection-card`s. The possible
30
30
  `variants` supported are:
31
31
 
32
- - `checkbox`: Renders a group of `bento-selection-card` with checkbox inputs. Multiple values can be selected at the
33
- same time. The `modelValue` prop should be an array of values (or an empty array if no card is selected).
32
+ - `checkbox`: Renders a group of `bento-selection-card` with checkbox inputs. Multiple values can be selected at the
33
+ same time. The `modelValue` prop should be an array of values (or an empty array if no card is selected).
34
34
 
35
35
  <Canvas of={SelectionCardGroupStories.Default} />
36
36
 
37
- - `radio`: Renders a group of `bento-selection-card` with radio inputs. Only one value can be selected at a time. The
38
- `modelValue` prop should correspond to the `value` of the selected card (or `undefined` if no card has been
39
- selected).
37
+ - `radio`: Renders a group of `bento-selection-card` with radio inputs. Only one value can be selected at a time. The
38
+ `modelValue` prop should correspond to the `value` of the selected card (or `undefined` if no card has been selected).
40
39
 
41
40
  <Canvas of={SelectionCardGroupStories.Radio} />
42
41
 
@@ -47,8 +46,8 @@ Determines what kind of input element and selection logic is applied to the `ben
47
46
  Items in a `bento-selection-card-group` can be stacked vertically or horizontally by passing the correct value to the
48
47
  `layout` prop. In particular:
49
48
 
50
- - `horizontal`: will render the cards in the group next to each other.
51
- - `vertical`: will stack the cards in the group vertically.
49
+ - `horizontal`: will render the cards in the group next to each other.
50
+ - `vertical`: will stack the cards in the group vertically.
52
51
 
53
52
  ### Items per row
54
53
 
@@ -67,8 +66,8 @@ The `itemsPerRow` props is an object of type `BentoSelectionCardGroupItemsPerRow
67
66
  }
68
67
  ```
69
68
 
70
- Where the values for each key represent the number of cards displayed per row on the specific container size. Note that
71
- you can pass a maximum of 6 items per row.
69
+ Where the values for each key represent the number of cards displayed per row on the specific container size. Each value
70
+ must be an integer between 1 and 6.
72
71
 
73
72
  ### Optional label
74
73
 
@@ -115,5 +114,5 @@ navigation flow of the page. A detailed list of keyboard interactions is provide
115
114
 
116
115
  ## Resources
117
116
 
118
- - [Figma link](https://www.figma.com/design/uLabwF3243jdMDsNSP7U9I/Bento---Components?node-id=25526-44502&node-type=frame&t=vr0mgcsqz2FWuNua-0)
119
- - [WAI-ARIA guidelines for grouping controls](https://www.w3.org/WAI/tutorials/forms/grouping/)
117
+ - [Figma link](https://www.figma.com/design/uLabwF3243jdMDsNSP7U9I/Bento---Components?node-id=25526-44502&node-type=frame&t=vr0mgcsqz2FWuNua-0)
118
+ - [WAI-ARIA guidelines for grouping controls](https://www.w3.org/WAI/tutorials/forms/grouping/)
@@ -1 +1 @@
1
- import { ref } from 'vue'; import { isVue2 } from 'vue-demi'; import { action } from '@storybook/addon-actions'; import RetailIcon from '@adyen/ui-assets-icons-16/vue/retail'; import LeafIcon from '@adyen/ui-assets-icons-16/vue/leaf'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import BentoSelectionCardGroup from './selection-card-group.vue'; import type { Meta, StoryObj } from '@storybook/vue'; import SelectCardGroupEverythingBagelExample from './__tests__/selection-card-group-everything-bagel-example.vue?raw'; import SelectCardGroupWithSlotsExample from './__tests__/selection-card-group-with-slots-example.vue?raw'; const meta: Meta = { title: 'Selection Card/Selection Card Group', component: BentoSelectionCardGroup, argTypes: { layout: { control: { type: 'radio' }, }, input: { description: 'Deprecated since version 2.0. Use `v-model` or `update:model-value` instead', table: { category: 'Deprecated', }, control: { disable: true }, }, }, }; export default meta; type Story = StoryObj<typeof BentoSelectionCardGroup>; const ITEMS = [ { title: 'Card 1', value: 'card-1', }, { title: 'Card 2', value: 'card-2', }, { title: 'Card 3', value: 'card-3', }, { title: 'Card 4', value: 'card-4', }, ]; const ITEMS_WITH_CONTENT = [ { title: 'Card 1', value: 'card-1', content: 'Slot content 1', icon: RetailIcon, fullyClickable: true, }, { title: 'Card 2', value: 'card-2', content: 'Slot content 2', icon: LeafIcon, fullyClickable: true, }, ]; const ITEMS_EVERYTHING_BAGEL = [ { title: 'Card 1', value: 'card-1', description: 'Description card 1', subtitle: 'Subtitle card 1', content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus et tellus at sem finibus posuere. Quisque nec velit sapien. Proin ultrices enim at placerat rhoncus. Ut volutpat nisl non hendrerit laoreet. ', dynamicContent: 'Dynamic content 1', icon: RetailIcon, fullyClickable: true, }, { title: 'Card 2', value: 'card-2', description: 'Description card 2', subtitle: 'Subtitle card 2', content: 'Content slot 2', icon: LeafIcon, fullyClickable: true, }, ]; const defaultCode = ` <template> <bento-selection-card-group label="Your group label" :items="items" v-model="selectedValue" /> </template> <script setup lang="ts"> import { BentoSelectionCardGroup } from '@adyen/bento-vue2'; const items = ref(${JSON.stringify(ITEMS)}); const selectedValue = ref([]); </script> `; export const Default: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCardGroup }, props: Object.keys(argTypes), template: ` <bento-selection-card-group v-bind="args" :model-value="selectedValue" @update:model-value="updateAction" /> `, setup(props) { const args = isVue2 ? props : _args; const selectedValue = ref(args.modelValue); const updateAction = value => { selectedValue.value = value; action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, updateAction, }; }, }), args: { label: 'Label', items: ITEMS, itemsPerRow: {}, modelValue: [], }, parameters: storybookDocsParameter(defaultCode), }; const radioCode = ` <template> <bento-selection-card-group label="Your group label" variant="radio" :items="items" v-model="selectedValue" /> </template> <script setup lang="ts"> import { BentoSelectionCardGroup } from '@adyen/bento-vue2'; const items = ref(${JSON.stringify(ITEMS)}); const selectedValue = ref(undefined); </script> `; export const Radio: Story = { ...Default, args: { label: 'Label', variant: 'radio', items: ITEMS, itemsPerRow: {}, modelValue: undefined, }, parameters: storybookDocsParameter(radioCode), }; export const WithSlots: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCardGroup, LeafIcon, RetailIcon }, props: Object.keys(argTypes), template: ` <bento-selection-card-group v-bind="args" :model-value="selectedValue" @update:model-value="updateAction" > <template #icon="{ icon }"> <component :is="icon"/> </template> <template #content="{ content }"> <div>{{ content }}</div> </template> <template #dynamicContent="{ dynamicContent }"> <div>{{ dynamicContent }}</div> </template> </bento-selection-card-group> `, setup(props) { const selectedValue = ref([]); const updateAction = value => { selectedValue.value = value; action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, updateAction, }; }, }), args: { label: 'Label', items: ITEMS_WITH_CONTENT, }, parameters: storybookDocsParameter(SelectCardGroupWithSlotsExample), }; const itemsPerRowCode = ` <template> <bento-selection-card-group label="Your group label" :items="items" :items-per-row="{ small: 2, medium: 3, large: 4 }" v-model="selectedValue" /> </template> <script setup lang="ts"> import { BentoSelectionCardGroup } from '@adyen/bento-vue2'; const items = ref(${JSON.stringify(ITEMS)}); const selectedValue = ref([]); </script> `; export const ItemsPerRow: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCardGroup }, props: Object.keys(argTypes), template: ` <bento-selection-card-group v-bind="args" :model-value="selectedValue" @update:model-value="updateAction" /> `, setup(props) { const args = isVue2 ? props : _args; const selectedValue = ref(args.modelValue); const updateAction = value => { selectedValue.value = value; action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, updateAction, }; }, }), args: { label: 'With responsive items per row', items: ITEMS, layout: 'horizontal', itemsPerRow: { small: 2, medium: 3, large: 4 }, modelValue: [], }, parameters: storybookDocsParameter(itemsPerRowCode), }; export const EverythingBagel: Story = { ...WithSlots, args: { label: 'Label', items: ITEMS_EVERYTHING_BAGEL, required: true, hideLabel: false, description: 'Supporting text', tooltipText: 'Tooltip text', }, parameters: storybookDocsParameter(SelectCardGroupEverythingBagelExample), };
1
+ import { ref } from 'vue'; import { isVue2 } from 'vue-demi'; import { action } from '@storybook/addon-actions'; import RetailIcon from '@adyen/ui-assets-icons-16/vue/retail'; import LeafIcon from '@adyen/ui-assets-icons-16/vue/leaf'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import BentoSelectionCardGroup from './selection-card-group.vue'; import type { Meta, StoryObj } from '@storybook/vue'; const SelectCardGroupEverythingBagelExample = "<template>\n <bento-selection-card-group\n v-model=\"selectedValue\"\n label=\"Label\"\n description=\"Supporting text\"\n tooltip-text=\"Tooltip text\"\n required\n :hide-label=\"false\"\n :error-message=\"errorMessage\"\n :items=\"items\"\n :readonly=\"readonly\"\n :disabled=\"disabled\"\n >\n <template #icon=\"{ icon }\">\n <component :is=\"icon\" />\n </template>\n <template #content=\"{ content }\">\n <!-- You can also render a component here -->\n <div>{{ content }}</div>\n </template>\n <template #dynamicContent=\"{ dynamicContent }\">\n <!-- You can also render a component here -->\n <div>{{ dynamicContent }}</div>\n </template>\n </bento-selection-card-group>\n</template>\n\n<script setup lang=\"ts\">\n import {\n BentoSelectionCardGroup,\n type BentoSelectionCardItem,\n type BentoSelectionCardModelValue,\n } from '@adyen/bento-vue2';\n import RetailIcon from '@adyen/ui-assets-icons-16/vue/retail';\n import LeafIcon from '@adyen/ui-assets-icons-16/vue/leaf';\n import { ref } from 'vue';\n\n const items = ref<Array<BentoSelectionCardItem>>([\n {\n title: 'Card 1',\n value: 'card-1',\n description: 'Description card 1',\n subtitle: 'Subtitle card 1',\n content:\n 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus et tellus at sem finibus posuere. Quisque nec velit sapien. Proin ultrices enim at placerat rhoncus. Ut volutpat nisl non hendrerit laoreet. ',\n dynamicContent: 'Dynamic content 1',\n icon: RetailIcon,\n fullyClickable: true,\n },\n {\n title: 'Card 2',\n value: 'card-2',\n description: 'Description card 2',\n subtitle: 'Subtitle card 2',\n content: 'Content slot 2',\n icon: LeafIcon,\n fullyClickable: true,\n },\n ]);\n\n const selectedValue = ref<BentoSelectionCardModelValue>([]);\n const errorMessage = ref<string | null>(null);\n const readonly = ref(false);\n const disabled = ref(false);\n</script>\n"; const SelectCardGroupWithSlotsExample = "<template>\n <bento-selection-card-group v-model=\"selectedValue\" label=\"Label\" :items=\"items\">\n <template #icon=\"{ icon }\">\n <component :is=\"icon\" />\n </template>\n <template #content=\"{ content }\">\n <!-- You can also render a component here -->\n <div>{{ content }}</div>\n </template>\n </bento-selection-card-group>\n</template>\n\n<script setup lang=\"ts\">\n import {\n BentoSelectionCardGroup,\n type BentoSelectionCardItem,\n type BentoSelectionCardModelValue,\n } from '@adyen/bento-vue2';\n import RetailIcon from '@adyen/ui-assets-icons-16/vue/retail';\n import LeafIcon from '@adyen/ui-assets-icons-16/vue/leaf';\n import { ref } from 'vue';\n\n const items = ref<Array<BentoSelectionCardItem>>([\n {\n title: 'Card 1',\n value: 'card-1',\n content: 'Slot content 1',\n icon: RetailIcon,\n fullyClickable: true,\n },\n {\n title: 'Card 2',\n value: 'card-2',\n content: 'Slot content 2',\n icon: LeafIcon,\n fullyClickable: true,\n },\n ]);\n\n const selectedValue = ref<BentoSelectionCardModelValue>([]);\n</script>\n"; const meta: Meta = { title: 'Selection Card/Selection Card Group', component: BentoSelectionCardGroup, argTypes: { layout: { control: { type: 'radio' }, }, }, }; export default meta; type Story = StoryObj<typeof BentoSelectionCardGroup>; const ITEMS = [ { title: 'Card 1', value: 'card-1', }, { title: 'Card 2', value: 'card-2', }, { title: 'Card 3', value: 'card-3', }, { title: 'Card 4', value: 'card-4', }, ]; const ITEMS_WITH_CONTENT = [ { title: 'Card 1', value: 'card-1', content: 'Slot content 1', icon: RetailIcon, fullyClickable: true, }, { title: 'Card 2', value: 'card-2', content: 'Slot content 2', icon: LeafIcon, fullyClickable: true, }, ]; const ITEMS_EVERYTHING_BAGEL = [ { title: 'Card 1', value: 'card-1', description: 'Description card 1', subtitle: 'Subtitle card 1', content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus et tellus at sem finibus posuere. Quisque nec velit sapien. Proin ultrices enim at placerat rhoncus. Ut volutpat nisl non hendrerit laoreet. ', dynamicContent: 'Dynamic content 1', icon: RetailIcon, fullyClickable: true, }, { title: 'Card 2', value: 'card-2', description: 'Description card 2', subtitle: 'Subtitle card 2', content: 'Content slot 2', icon: LeafIcon, fullyClickable: true, }, ]; const defaultCode = ` <template> <bento-selection-card-group label="Your group label" :items="items" v-model="selectedValue" /> </template> <script setup lang="ts"> import { BentoSelectionCardGroup } from '@adyen/bento-vue2'; const items = ref(${JSON.stringify(ITEMS)}); const selectedValue = ref([]); </script> `; export const Default: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCardGroup }, props: Object.keys(argTypes), template: ` <bento-selection-card-group v-bind="args" :model-value="selectedValue" @update:model-value="updateAction" /> `, setup(props) { const args = isVue2 ? props : _args; const selectedValue = ref(args.modelValue); const updateAction = value => { selectedValue.value = value; action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, updateAction, }; }, }), args: { label: 'Label', items: ITEMS, itemsPerRow: {}, modelValue: [], }, parameters: storybookDocsParameter(defaultCode), }; const radioCode = ` <template> <bento-selection-card-group label="Your group label" variant="radio" :items="items" v-model="selectedValue" /> </template> <script setup lang="ts"> import { BentoSelectionCardGroup } from '@adyen/bento-vue2'; const items = ref(${JSON.stringify(ITEMS)}); const selectedValue = ref(undefined); </script> `; export const Radio: Story = { ...Default, args: { label: 'Label', variant: 'radio', items: ITEMS, itemsPerRow: {}, modelValue: undefined, }, parameters: storybookDocsParameter(radioCode), }; export const WithSlots: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCardGroup, LeafIcon, RetailIcon }, props: Object.keys(argTypes), template: ` <bento-selection-card-group v-bind="args" :model-value="selectedValue" @update:model-value="updateAction" > <template #icon="{ icon }"> <component :is="icon"/> </template> <template #content="{ content }"> <div>{{ content }}</div> </template> <template #dynamicContent="{ dynamicContent }"> <div>{{ dynamicContent }}</div> </template> </bento-selection-card-group> `, setup(props) { const selectedValue = ref([]); const updateAction = value => { selectedValue.value = value; action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, updateAction, }; }, }), args: { label: 'Label', items: ITEMS_WITH_CONTENT, }, parameters: storybookDocsParameter(SelectCardGroupWithSlotsExample), }; const itemsPerRowCode = ` <template> <bento-selection-card-group label="Your group label" :items="items" :items-per-row="{ small: 2, medium: 3, large: 4 }" v-model="selectedValue" /> </template> <script setup lang="ts"> import { BentoSelectionCardGroup } from '@adyen/bento-vue2'; const items = ref(${JSON.stringify(ITEMS)}); const selectedValue = ref([]); </script> `; export const ItemsPerRow: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCardGroup }, props: Object.keys(argTypes), template: ` <bento-selection-card-group v-bind="args" :model-value="selectedValue" @update:model-value="updateAction" /> `, setup(props) { const args = isVue2 ? props : _args; const selectedValue = ref(args.modelValue); const updateAction = value => { selectedValue.value = value; action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, updateAction, }; }, }), args: { label: 'With responsive items per row', items: ITEMS, layout: 'horizontal', itemsPerRow: { small: 2, medium: 3, large: 4 }, modelValue: [], }, parameters: storybookDocsParameter(itemsPerRowCode), }; export const EverythingBagel: Story = { ...WithSlots, args: { label: 'Label', items: ITEMS_EVERYTHING_BAGEL, required: true, hideLabel: false, description: 'Supporting text', tooltipText: 'Tooltip text', }, parameters: storybookDocsParameter(SelectCardGroupEverythingBagelExample), };
@@ -1 +1 @@
1
- <template> <controls-group ref="containerRef" :aria-describedby="shouldShowGroupError ? errorMessageId : null" :aria-required="required" :label="label" :hide-label="hideLabel" :description="description" :disabled="disabled" :tooltip-text="tooltipText" :readonly="readonly" :required="required" :optional="optional" class="b-selection-card-group" component-name="selection-card-group" > <div v-if="!itemsPerRow || layout === 'vertical'" class="b-selection-card-group__items" :class="conditionalItemsClasses" > <bento-selection-card v-for="item in items" :key="`selection-card-${item.value}`" class="b-selection-card-group__item" v-bind="item" :model-value="inputValue" :readonly="readonly || item.readonly" :has-error="shouldShowGroupError" :disabled="disabled || item.disabled" @update:model-value="onInput" > <template v-if="hasSlot('icon') && item.icon" #icon> <slot name="icon" v-bind="item"></slot> </template> <template v-if="hasSlot('content') && item.content" #content> <slot name="content" v-bind="item"></slot> </template> <template v-if="hasSlot('dynamicContent') && item.dynamicContent" #dynamicContent> <slot name="dynamicContent" v-bind="item"></slot> </template> </bento-selection-card> </div> <template v-else> <div :key="`selection-card-group-layout-breakpoint-${currentBreakpoint}`"> <grid-layout v-for="(row, rowIndex) in computedRows" :key="`selection-card-group-row-${rowIndex}-cols-${computedItemsPerRow}`" class="b-selection-card-group__items--wrap" :column-width="computedColumnWidth" > <template v-for="(item, columnIndex) in row" #[`col-${Number(columnIndex)+1}`]> <bento-selection-card :key="`selection-card-${item.value}`" class="b-selection-card-group__item b-selection-card-group__item--full-height" v-bind="item" :model-value="inputValue" :readonly="readonly || item.readonly" :has-error="shouldShowGroupError" :disabled="disabled || item.disabled" @update:model-value="onInput" > <template v-if="hasSlot('icon') && item.icon" #icon> <slot name="icon" v-bind="item"></slot> </template> <template v-if="hasSlot('content') && item.content" #content> <slot name="content" v-bind="item"></slot> </template> <template v-if="hasSlot('dynamicContent') && item.dynamicContent" #dynamicContent> <slot name="dynamicContent" v-bind="item"></slot> </template> </bento-selection-card> </template> </grid-layout> </div> </template> <error-message v-if="shouldShowGroupError" :id="errorMessageId" :error-message="errorMessage" class="b-selection-card-group__error-message" /> </controls-group> </template> <script setup lang="ts"> import { computed, onMounted, provide, ref, useSlots, watch } from 'vue'; import { useElementSize } from '@vueuse/core'; import { BMediaQueryMMax, BMediaQuerySMax } from '@adyen/bento-design-tokens/dist/js/bento/es6'; import { type BentoSelectionCardGroupEmits, type BentoSelectionCardGroupProps } from './selection-card-group.types'; import BentoSelectionCard from '../../selection-card.vue'; import { ControlsGroup, ErrorMessage, GridLayout } from '../../../internal'; import { SELECTION_CARD_RADIO_INPUT_INJECTION_KEY } from '../../selection-card.keys'; import { generateUid } from '@/core/utils/ts'; import { useFormFieldEmits } from '@/utils/ts/form-field/form-field'; const props = withDefaults(defineProps<BentoSelectionCardGroupProps>(), { description: null, disabled: false, errorMessage: null, formId: null, hideLabel: null, label: null, layout: 'vertical', itemsPerRow: undefined, modelValue: null, optional: false, required: false, tooltipText: null, readonly: false, variant: 'checkbox', }); const emit = defineEmits<BentoSelectionCardGroupEmits>(); const { emitValue } = useFormFieldEmits(emit); const slots = useSlots(); // Slots logic // Temporary, use-has-slots composable doesn't currently work for vue3 named scoped slots // We do the same in bento-checkbox-group const hasSlot = name => !!slots[name]; const conditionalItemsClasses = computed(() => ({ 'b-selection-card-group__items--horizontal': props.layout === 'horizontal', })); const inputValue = ref(props.modelValue); watch( () => props.modelValue, () => { inputValue.value = props.modelValue; } ); // Error message logic const errorMessageId = generateUid('error'); const shouldShowGroupError = computed(() => !props.disabled && !props.readonly && !!props.errorMessage); // itemsPerRow logic const containerRef = ref<HTMLElement | null>(null); const { width } = useElementSize(containerRef); const smallBreakpoint = computed(() => BMediaQuerySMax.split('px')[0]); const mediumBreakpoint = computed(() => BMediaQueryMMax.split('px')[0]); const currentBreakpoint = computed(() => { if (width.value < smallBreakpoint.value) { return 'small'; } if (width.value >= smallBreakpoint.value && width.value < mediumBreakpoint.value) { return 'medium'; } return 'large'; }); const computedItemsPerRow = computed(() => { return (props.itemsPerRow?.[currentBreakpoint?.value] as number) || props.items.length; }); const computedRows = computed(() => { if (!props.itemsPerRow) { return []; } const rows = []; for (let i = 0; i < props.items.length; i += computedItemsPerRow?.value) { rows.push(props.items.slice(i, i + computedItemsPerRow?.value)); } return rows; }); // We need to compute the column width on 12 because we're using a 12-column system for out grid-layout logic const itemColumnWidth = computed(() => 12 / computedItemsPerRow?.value); /** * Filling the columnWidth array with the same parameters per item to pass * to the `grid-layout` layout so the each card can have * the same width according to the screen size. */ const computedColumnWidth = computed(() => { return computedItemsPerRow?.value ? new Array(computedItemsPerRow?.value).fill({ // Instead of passing the actual screen sizes values, passing the same values per each screen size and recomputing it makes sure visually the change is smoother and not laggy small: itemColumnWidth.value, medium: itemColumnWidth.value, large: itemColumnWidth.value, }) : []; }); const onInput = value => { inputValue.value = value; emitValue(value); }; const isRadioVariant = computed(() => props.variant === 'radio'); provide(SELECTION_CARD_RADIO_INPUT_INJECTION_KEY, isRadioVariant); onMounted(() => { if (props.itemsPerRow) { Object.values(props.itemsPerRow).forEach(el => { if (el && (el < 2 || el > 6)) { throw new Error( 'itemsPerRow values must have a value between 2 and 6 items per row. Read the documentation for more information.' ); } }); } }); </script> <script lang="ts"> /** * Group of bento-selection-cards. * * @example * import { BentoSelectionCardGroup } from '@adyen/bento-vue2'; * * export default { * components: { BentoSelectionCardGroup }, * template: ` * <bento-selection-card-group * :items="[ * { * title: 'Card 1', * value: 'card-1', * content: 'Slot content 1', * icon: RetailIcon, * }, * { * title: 'Card 2', * value: 'card-2', * content: 'Slot content 2', * icon: LeafIcon, * }, * ]" * > * <template #icon="{ icon }"> * <component :is="icon"/> * </template> * <template #content="{ content }"> * <div>{{ content }}</div> * </template> * </bento-selection-card-group> * `, * } */ export default { model: { prop: 'modelValue' }, }; </script> <style lang="scss" scoped src="./selection-card-group.scss" />
1
+ <template> <controls-group ref="containerRef" :aria-describedby="shouldShowGroupError ? errorMessageId : null" :aria-required="required" :label="label" :hide-label="hideLabel" :description="description" :disabled="disabled" :tooltip-text="tooltipText" :readonly="readonly" :required="required" :optional="optional" class="b-selection-card-group" component-name="selection-card-group" > <div v-if="!itemsPerRow || layout === 'vertical'" class="b-selection-card-group__items" :class="conditionalItemsClasses" > <bento-selection-card v-for="item in items" :key="`selection-card-${item.value}`" class="b-selection-card-group__item" v-bind="item" :model-value="inputValue" :readonly="readonly || item.readonly" :has-error="shouldShowGroupError" :disabled="disabled || item.disabled" @update:model-value="onInput" > <template v-if="hasSlot('icon') && item.icon" #icon> <slot name="icon" v-bind="item"></slot> </template> <template v-if="hasSlot('content') && item.content" #content> <slot name="content" v-bind="item"></slot> </template> <template v-if="hasSlot('dynamicContent') && item.dynamicContent" #dynamicContent> <slot name="dynamicContent" v-bind="item"></slot> </template> </bento-selection-card> </div> <template v-else> <div :key="`selection-card-group-layout-breakpoint-${currentBreakpoint}`"> <grid-layout v-for="(row, rowIndex) in computedRows" :key="`selection-card-group-row-${rowIndex}-cols-${computedItemsPerRow}`" class="b-selection-card-group__items--wrap" :column-width="computedColumnWidth" > <template v-for="(item, columnIndex) in row" #[`col-${Number(columnIndex)+1}`]> <bento-selection-card :key="`selection-card-${item.value}`" class="b-selection-card-group__item b-selection-card-group__item--full-height" v-bind="item" :model-value="inputValue" :readonly="readonly || item.readonly" :has-error="shouldShowGroupError" :disabled="disabled || item.disabled" @update:model-value="onInput" > <template v-if="hasSlot('icon') && item.icon" #icon> <slot name="icon" v-bind="item"></slot> </template> <template v-if="hasSlot('content') && item.content" #content> <slot name="content" v-bind="item"></slot> </template> <template v-if="hasSlot('dynamicContent') && item.dynamicContent" #dynamicContent> <slot name="dynamicContent" v-bind="item"></slot> </template> </bento-selection-card> </template> </grid-layout> </div> </template> <error-message v-if="shouldShowGroupError" :id="errorMessageId" :error-message="errorMessage" class="b-selection-card-group__error-message" /> </controls-group> </template> <script setup lang="ts"> import { computed, onMounted, provide, ref, useSlots, watch } from 'vue'; import { useElementSize } from '@vueuse/core'; import { BMediaQueryMMax, BMediaQuerySMax } from '@adyen/bento-design-tokens/dist/js/bento/es6'; import { type BentoSelectionCardGroupEmits, type BentoSelectionCardGroupProps } from './selection-card-group.types'; import BentoSelectionCard from '../../selection-card.vue'; import { ControlsGroup, ErrorMessage, GridLayout } from '../../../internal'; import { SELECTION_CARD_RADIO_INPUT_INJECTION_KEY } from '../../selection-card.keys'; import { generateUid } from '@/utils/ts/generate-uid'; import { useFormFieldEmits } from '@/utils/ts/form-field/form-field'; const props = withDefaults(defineProps<BentoSelectionCardGroupProps>(), { description: null, disabled: false, errorMessage: null, formId: null, hideLabel: null, label: null, layout: 'vertical', itemsPerRow: undefined, modelValue: null, optional: false, required: false, tooltipText: null, readonly: false, variant: 'checkbox', }); const emit = defineEmits<BentoSelectionCardGroupEmits>(); const { emitValue } = useFormFieldEmits(emit); const slots = useSlots(); // Slots logic // Temporary, use-has-slots composable doesn't currently work for vue3 named scoped slots // We do the same in bento-checkbox-group const hasSlot = name => !!slots[name]; const conditionalItemsClasses = computed(() => ({ 'b-selection-card-group__items--horizontal': props.layout === 'horizontal', })); const inputValue = ref(props.modelValue); watch( () => props.modelValue, () => { inputValue.value = props.modelValue; } ); // Error message logic const errorMessageId = generateUid('error'); const shouldShowGroupError = computed(() => !props.disabled && !props.readonly && !!props.errorMessage); // itemsPerRow logic const containerRef = ref<HTMLElement | null>(null); const { width } = useElementSize(containerRef); const smallBreakpoint = computed(() => BMediaQuerySMax.split('px')[0]); const mediumBreakpoint = computed(() => BMediaQueryMMax.split('px')[0]); const currentBreakpoint = computed(() => { if (width.value < smallBreakpoint.value) { return 'small'; } if (width.value >= smallBreakpoint.value && width.value < mediumBreakpoint.value) { return 'medium'; } return 'large'; }); const computedItemsPerRow = computed(() => { return (props.itemsPerRow?.[currentBreakpoint?.value] as number) || props.items.length; }); const computedRows = computed(() => { if (!props.itemsPerRow) { return []; } const rows = []; for (let i = 0; i < props.items.length; i += computedItemsPerRow?.value) { rows.push(props.items.slice(i, i + computedItemsPerRow?.value)); } return rows; }); // We need to compute the column width on 12 because we're using a 12-column system for out grid-layout logic const itemColumnWidth = computed(() => 12 / computedItemsPerRow?.value); /** * Filling the columnWidth array with the same parameters per item to pass * to the `grid-layout` layout so the each card can have * the same width according to the screen size. */ const computedColumnWidth = computed(() => { return computedItemsPerRow?.value ? new Array(computedItemsPerRow?.value).fill({ // Instead of passing the actual screen sizes values, passing the same values per each screen size and recomputing it makes sure visually the change is smoother and not laggy small: itemColumnWidth.value, medium: itemColumnWidth.value, large: itemColumnWidth.value, }) : []; }); const onInput = value => { inputValue.value = value; emitValue(value); }; const isRadioVariant = computed(() => props.variant === 'radio'); provide(SELECTION_CARD_RADIO_INPUT_INJECTION_KEY, isRadioVariant); onMounted(() => { if (props.itemsPerRow) { Object.values(props.itemsPerRow).forEach(value => { const numericValue = Number(value); if (!Number.isInteger(numericValue) || numericValue < 1 || numericValue > 6) { throw new Error( 'itemsPerRow values must have a value between 1 and 6 items per row. Read the documentation for more information.' ); } }); } }); </script> <script lang="ts"> /** * Group of bento-selection-cards. * * @example * import { BentoSelectionCardGroup } from '@adyen/bento-vue2'; * * export default { * components: { BentoSelectionCardGroup }, * template: ` * <bento-selection-card-group * :items="[ * { * title: 'Card 1', * value: 'card-1', * content: 'Slot content 1', * icon: RetailIcon, * }, * { * title: 'Card 2', * value: 'card-2', * content: 'Slot content 2', * icon: LeafIcon, * }, * ]" * > * <template #icon="{ icon }"> * <component :is="icon"/> * </template> * <template #content="{ content }"> * <div>{{ content }}</div> * </template> * </bento-selection-card-group> * `, * } */ export default { model: { prop: 'modelValue', event: 'update:model-value' }, }; </script> <style lang="scss" scoped src="./selection-card-group.scss" />
@@ -1 +1 @@
1
- import { action } from '@storybook/addon-actions'; import { isVue2 } from 'vue-demi'; import { ref } from 'vue'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import BentoSelectionCard from './selection-card.vue'; import type { Meta, StoryObj } from '@storybook/vue'; import EmoticonHappyIcon from '@adyen/ui-assets-icons-16/vue/emoticon-happy'; const meta: Meta = { title: 'Selection Card', component: BentoSelectionCard, }; export default meta; type Story = StoryObj<typeof BentoSelectionCard>; const defaultCode = ` <bento-selection-card title="Card title" value="card-value" :model-value.sync="yourModelValueVariable" /> `; export const Default: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCard }, props: Object.keys(argTypes), template: ` <bento-selection-card v-bind="args" :model-value="selectedValue" @update:model-value="clickedAction" /> `, setup(props) { const selectedValue = ref(undefined); const clickedAction = value => { selectedValue.value = value; action('input')(value); action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, // Events clickedAction, }; }, }), args: { title: 'Card title', value: 'value', }, parameters: storybookDocsParameter(defaultCode), }; const withIconCode = ` <template> <bento-selection-card title="Card title" value="card-value" :model-value.sync="yourModelValueVariable" > <template #icon> <emoticon-happy-icon /> </template> </bento-selection-card> </template> <script setup lang="ts"> import { BentoSelectionCard } from '@adyen/bento-vue2'; import EmoticonHappyIcon from '@adyen/ui-assets-icons-16/vue/emoticon-happy'; </script> `; export const WithIcon: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCard, EmoticonHappyIcon }, props: Object.keys(argTypes), template: ` <bento-selection-card v-bind="args" :model-value="selectedValue" @update:model-value="clickedAction" > <template #icon> <emoticon-happy-icon /> </template> </bento-selection-card> `, setup(props) { const selectedValue = ref(undefined); const clickedAction = value => { selectedValue.value = value; action('input')(value); action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, // Events clickedAction, }; }, }), args: { title: 'Card title', value: 'value', }, parameters: storybookDocsParameter(withIconCode), }; const withContentSlotCode = ` <template> <bento-selection-card title="Card title" value="card-value" :model-value.sync="yourModelValueVariable" > <template #content> I'm a content slot that can be replaced with any content! </template> </bento-selection-card> </template> `; export const WithContentSlot: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCard }, props: Object.keys(argTypes), template: ` <bento-selection-card v-bind="args" :model-value="selectedValue" @update:model-value="clickedAction" > <template #content> I'm a content slot that can be replaced with any content! </template> </bento-selection-card> `, setup(props) { const selectedValue = ref(undefined); const clickedAction = value => { selectedValue.value = value; action('input')(value); action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, // Events clickedAction, }; }, }), args: { title: 'Card title', value: 'value', }, parameters: storybookDocsParameter(withContentSlotCode), }; const withDynamicContentSlotCode = ` <template> <bento-selection-card title="Card title" value="card-value" :model-value.sync="yourModelValueVariable" > <template #dynamicContent> I'm a content slot that will only show when the card is selected! </template> </bento-selection-card> </template> `; export const WithDynamicContentSlot: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCard }, props: Object.keys(argTypes), template: ` <bento-selection-card v-bind="args" :model-value="selectedValue" @update:model-value="clickedAction" > <template #dynamicContent> I'm a content slot that will only show when the card is selected! </template> </bento-selection-card> `, setup(props) { const selectedValue = ref(undefined); const clickedAction = value => { selectedValue.value = value; action('input')(value); action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, // Events clickedAction, }; }, }), args: { title: 'Card title', value: 'value', }, parameters: storybookDocsParameter(withDynamicContentSlotCode), }; const everythingBagelCode = ` <template> <bento-selection-card title="Card title" subtitle="Subtitle" description="Description" value="card-value" :model-value.sync="yourModelValueVariable" > <template #icon> <emoticon-happy-icon /> </template> <template #content> I'm a content slot that can be replaced with any content! </template> <template #dynamicContent> I'm a content slot that will only show when the card is selected! </template> </bento-selection-card> </template> <script setup lang="ts"> import { BentoSelectionCard } from '@adyen/bento-vue2'; import EmoticonHappyIcon from '@adyen/ui-assets-icons-16/vue/emoticon-happy'; </script> `; export const EverythingBagel: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCard, EmoticonHappyIcon }, props: Object.keys(argTypes), template: ` <bento-selection-card v-bind="args" :model-value="selectedValue" @update:model-value="clickedAction" > <template #icon> <emoticon-happy-icon /> </template> <template #content> I'm a content slot that can be replaced with any content! </template> <template #dynamicContent> I'm a content slot that will only show when the card is selected! </template> </bento-selection-card> `, setup(props) { const selectedValue = ref(undefined); const clickedAction = value => { selectedValue.value = value; action('input')(value); action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, // Events clickedAction, }; }, }), args: { title: 'Card title', description: 'Description', subtitle: 'Subtitle', value: 'value', }, parameters: storybookDocsParameter(everythingBagelCode), };
1
+ import { action } from '@storybook/addon-actions'; import { isVue2 } from 'vue-demi'; import { ref } from 'vue'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import BentoSelectionCard from './selection-card.vue'; const SelectionCardDefaultExample = "<template>\n <bento-selection-card\n title=\"Card title\"\n value=\"value\"\n :model-value=\"selectedValue\"\n @update:model-value=\"selectCard\"\n />\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import {\n BentoSelectionCard,\n type BentoSelectionCardModelValue,\n type BentoSelectionCardValue,\n } from '@adyen/bento-vue2';\n\n const selectedValue = ref<BentoSelectionCardModelValue>();\n const selectCard = (value: BentoSelectionCardValue) => {\n selectedValue.value = value;\n };\n</script>\n"; const SelectionCardEverythingBagelExample = "<template>\n <bento-selection-card\n title=\"Card title\"\n subtitle=\"Subtitle\"\n description=\"Description\"\n value=\"value\"\n :model-value=\"selectedValue\"\n @update:model-value=\"selectCard\"\n >\n <template #icon>\n <emoticon-happy-icon />\n </template>\n <template #content>I'm a content slot that can be replaced with any content!</template>\n <template #dynamicContent>I'm a content slot that will only show when the card is selected!</template>\n </bento-selection-card>\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import {\n BentoSelectionCard,\n type BentoSelectionCardModelValue,\n type BentoSelectionCardValue,\n } from '@adyen/bento-vue2';\n import EmoticonHappyIcon from '@adyen/ui-assets-icons-16/vue/emoticon-happy';\n\n const selectedValue = ref<BentoSelectionCardModelValue>();\n const selectCard = (value: BentoSelectionCardValue) => {\n selectedValue.value = value;\n };\n</script>\n"; const SelectionCardWithContentSlotExample = "<template>\n <bento-selection-card\n title=\"Card title\"\n value=\"value\"\n :model-value=\"selectedValue\"\n @update:model-value=\"selectCard\"\n >\n <template #content>I'm a content slot that can be replaced with any content!</template>\n </bento-selection-card>\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import {\n BentoSelectionCard,\n type BentoSelectionCardModelValue,\n type BentoSelectionCardValue,\n } from '@adyen/bento-vue2';\n\n const selectedValue = ref<BentoSelectionCardModelValue>();\n const selectCard = (value: BentoSelectionCardValue) => {\n selectedValue.value = value;\n };\n</script>\n"; const SelectionCardWithDynamicContentSlotExample = "<template>\n <bento-selection-card\n title=\"Card title\"\n value=\"value\"\n :model-value=\"selectedValue\"\n @update:model-value=\"selectCard\"\n >\n <template #dynamicContent>I'm a content slot that will only show when the card is selected!</template>\n </bento-selection-card>\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import {\n BentoSelectionCard,\n type BentoSelectionCardModelValue,\n type BentoSelectionCardValue,\n } from '@adyen/bento-vue2';\n\n const selectedValue = ref<BentoSelectionCardModelValue>();\n const selectCard = (value: BentoSelectionCardValue) => {\n selectedValue.value = value;\n };\n</script>\n"; const SelectionCardWithIconExample = "<template>\n <bento-selection-card\n title=\"Card title\"\n value=\"value\"\n :model-value=\"selectedValue\"\n @update:model-value=\"selectCard\"\n >\n <template #icon>\n <emoticon-happy-icon />\n </template>\n </bento-selection-card>\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import {\n BentoSelectionCard,\n type BentoSelectionCardModelValue,\n type BentoSelectionCardValue,\n } from '@adyen/bento-vue2';\n import EmoticonHappyIcon from '@adyen/ui-assets-icons-16/vue/emoticon-happy';\n\n const selectedValue = ref<BentoSelectionCardModelValue>();\n const selectCard = (value: BentoSelectionCardValue) => {\n selectedValue.value = value;\n };\n</script>\n"; import type { Meta, StoryObj } from '@storybook/vue'; import EmoticonHappyIcon from '@adyen/ui-assets-icons-16/vue/emoticon-happy'; const meta: Meta = { title: 'Selection Card', component: BentoSelectionCard, }; export default meta; type Story = StoryObj<typeof BentoSelectionCard>; export const Default: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCard }, props: Object.keys(argTypes), template: ` <bento-selection-card v-bind="args" :model-value="selectedValue" @update:model-value="clickedAction" /> `, setup(props) { const selectedValue = ref(undefined); const clickedAction = value => { selectedValue.value = value; action('input')(value); action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, // Events clickedAction, }; }, }), args: { title: 'Card title', value: 'value', }, parameters: storybookDocsParameter(SelectionCardDefaultExample), }; export const WithIcon: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCard, EmoticonHappyIcon }, props: Object.keys(argTypes), template: ` <bento-selection-card v-bind="args" :model-value="selectedValue" @update:model-value="clickedAction" > <template #icon> <emoticon-happy-icon /> </template> </bento-selection-card> `, setup(props) { const selectedValue = ref(undefined); const clickedAction = value => { selectedValue.value = value; action('input')(value); action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, // Events clickedAction, }; }, }), args: { title: 'Card title', value: 'value', }, parameters: storybookDocsParameter(SelectionCardWithIconExample), }; export const WithContentSlot: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCard }, props: Object.keys(argTypes), template: ` <bento-selection-card v-bind="args" :model-value="selectedValue" @update:model-value="clickedAction" > <template #content> I'm a content slot that can be replaced with any content! </template> </bento-selection-card> `, setup(props) { const selectedValue = ref(undefined); const clickedAction = value => { selectedValue.value = value; action('input')(value); action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, // Events clickedAction, }; }, }), args: { title: 'Card title', value: 'value', }, parameters: storybookDocsParameter(SelectionCardWithContentSlotExample), }; export const WithDynamicContentSlot: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCard }, props: Object.keys(argTypes), template: ` <bento-selection-card v-bind="args" :model-value="selectedValue" @update:model-value="clickedAction" > <template #dynamicContent> I'm a content slot that will only show when the card is selected! </template> </bento-selection-card> `, setup(props) { const selectedValue = ref(undefined); const clickedAction = value => { selectedValue.value = value; action('input')(value); action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, // Events clickedAction, }; }, }), args: { title: 'Card title', value: 'value', }, parameters: storybookDocsParameter(SelectionCardWithDynamicContentSlotExample), }; export const EverythingBagel: Story = { render: (_args, { argTypes }) => ({ components: { BentoSelectionCard, EmoticonHappyIcon }, props: Object.keys(argTypes), template: ` <bento-selection-card v-bind="args" :model-value="selectedValue" @update:model-value="clickedAction" > <template #icon> <emoticon-happy-icon /> </template> <template #content> I'm a content slot that can be replaced with any content! </template> <template #dynamicContent> I'm a content slot that will only show when the card is selected! </template> </bento-selection-card> `, setup(props) { const selectedValue = ref(undefined); const clickedAction = value => { selectedValue.value = value; action('input')(value); action('update:model-value')(value); }; return { // Values args: isVue2 ? props : _args, selectedValue, // Events clickedAction, }; }, }), args: { title: 'Card title', description: 'Description', subtitle: 'Subtitle', value: 'value', }, parameters: storybookDocsParameter(SelectionCardEverythingBagelExample), };
@@ -1 +1 @@
1
- import { type RadioInputValue } from '@/components/internal/radio-input'; import { type BentoCheckboxType } from '../checkbox/checkbox.types'; import { type VueNodeElement } from '@/types/elements'; export enum BentoSelectionCardState { DISABLED = 'disabled', READONLY = 'readonly', ERROR = 'error', } export type BentoSelectionCardValue = string | number; export type BentoSelectionCardModelValue = BentoCheckboxType | RadioInputValue; export interface BentoSelectionCardItem { content?: string | object; description?: string; disabled?: boolean; dynamicContent?: string | object; fullyClickable?: boolean; hasError?: boolean; icon?: VueNodeElement; readonly?: boolean; subtitle?: string; title: string; value: BentoSelectionCardValue; }
1
+ import { type RadioInputValue } from '@/components/internal/radio-input'; import { type BentoCheckboxType } from '@/types/checkbox'; import { type VueNodeElement } from '@/types/elements'; export enum BentoSelectionCardState { DISABLED = 'disabled', READONLY = 'readonly', ERROR = 'error', } export type BentoSelectionCardValue = string | number; export type BentoSelectionCardModelValue = BentoCheckboxType | RadioInputValue; export interface BentoSelectionCardItem { content?: string | object; description?: string; disabled?: boolean; dynamicContent?: string | object; fullyClickable?: boolean; hasError?: boolean; icon?: VueNodeElement; readonly?: boolean; subtitle?: string; title: string; value: BentoSelectionCardValue; }
@@ -1 +1 @@
1
- <template> <div class="b-selection-card" :class="conditionalClasses" @click="handleCardClick"> <div class="b-selection-card__container" :class="containerConditionalClasses"> <div class="b-selection-card__checkbox-container" :class="checkboxContainerConditionalClasses"> <div class="b-selection-card__checkbox-container-text" :class="checkboxContainerTextConditionalClasses"> <div v-if="hasSlot('icon')" class="b-selection-card__icon" role="presentation" aria-hidden="true"> <slot name="icon" /> </div> <label :for="inputId" class="b-selection-card__text" @click.stop.prevent="handleCardClick"> <bento-typography v-if="subtitle" class="b-selection-card__description" el="span" variant="caption" > {{ subtitle }} </bento-typography> <bento-typography el="span" variant="title">{{ title }}</bento-typography> <bento-typography v-if="description" id="descriptionId" class="b-selection-card__description" el="span" variant="body" > {{ description }} </bento-typography> </label> </div> <radio-input v-if="isRadioInput" :id="inputId" ref="inputRef" :aria-label="ariaLabel" :aria-describedby="description ? descriptionId : undefined" :disabled="disabled" :has-error="hasError" :aria-readonly="readonly ?? undefined" :value="value" :readonly="readonly" :model-value="computedRadioInputModelValue" /> <checkbox-input v-else :id="inputId" ref="inputRef" :aria-label="ariaLabel" :aria-describedby="description ? descriptionId : undefined" :disabled="disabled" :has-error="hasError" :aria-readonly="readonly ?? undefined" :value="value" :readonly="readonly" :model-value="computedCheckboxInputModelValue" /> </div> <bento-typography v-if="hasSlot('content')" ref="slotRef" el="div" class="b-selection-card__slot" :class="slotConditionalClasses" > <slot name="content" /> </bento-typography> <bento-typography v-if="hasSlot('dynamicContent') && isChecked" ref="dynamicSlotRef" el="div" class="b-selection-card__slot" :class="slotConditionalClasses" > <slot name="dynamicContent" /> </bento-typography> </div> </div> </template> <script setup lang="ts"> import { BentoTypography } from '@/components/typography'; import { type BentoCheckboxType, type BentoMultiCheckboxType, CheckboxInput } from '../internal/checkbox-input'; import { RadioInput, type RadioInputValue } from '../internal/radio-input'; import { useAriaLabel } from '@/utils/ts/aria-label'; import { generateUid } from '@/core/utils/ts'; import { computed, type ComputedRef, inject, type PropType, type Ref, ref, useSlots } from 'vue'; import { useHasSlot } from '@/composables'; import type { BentoSelectionCardModelValue, BentoSelectionCardValue } from './selection-card.types'; import { BentoSelectionCardState } from './selection-card.types'; import { SELECTION_CARD_RADIO_INPUT_INJECTION_KEY } from './selection-card.keys'; const props = defineProps({ /** * The description of the selection card */ description: { type: String, default: undefined, }, /** * Disables the selection card */ disabled: { type: Boolean, default: false }, /** * Makes the entire selection card clickable. Clicking over interactive elements inside the card with this prop enabled will not be possible. */ fullyClickable: { type: Boolean, default: false }, /** * Shows the selection card in error state */ hasError: { type: Boolean, default: false }, /** * This property should not be used directly. * It will be used by v-model directive on selection card component. * * When handling a single input, use a string or a number. * * When handling multiple inputs, use an array of keys. * These keys exist as a set "value" prop for each input. */ modelValue: { type: [Boolean, String, Array] as PropType<BentoSelectionCardModelValue>, default: null, }, /** * Sets the selection card to readonly */ readonly: { type: Boolean, default: false }, /** * The subtitle of the selection card */ subtitle: { type: String, default: undefined, }, /** * The title of the selection card */ title: { type: String, required: true, }, /** * Indicates the value of the input that will be returned when it's checked. */ value: { type: [String, Number] as PropType<BentoSelectionCardValue>, required: true, }, }); const emit = defineEmits<{ /** * Emitted when the selection card is clicked. Enables Vue2 "v-model" */ (e: 'input', value: BentoSelectionCardValue); /** * Emitted when the selection card is clicked. Enables Vue3 "v-model" */ (e: 'update:model-value', value: BentoSelectionCardValue); }>(); const slots = useSlots(); const hasSlot = useHasSlot(slots); const inputId = generateUid('selection-card-input-id'); const descriptionId = generateUid('selection-card-description'); const computedRadioInputModelValue: ComputedRef<RadioInputValue> = computed( () => props.modelValue as RadioInputValue ); const computedCheckboxInputModelValue: ComputedRef<BentoCheckboxType> = computed( () => props.modelValue as BentoCheckboxType ); const conditionalClasses = computed(() => ({ 'b-selection-card--checked': isChecked.value, 'b-selection-card--fully-clickable': props.fullyClickable, })); const containerConditionalClasses = computed(() => ({ [`b-selection-card--${BentoSelectionCardState.DISABLED}`]: props.disabled, [`b-selection-card--${BentoSelectionCardState.ERROR}`]: props.hasError, [`b-selection-card--${BentoSelectionCardState.READONLY}`]: props.readonly, 'b-selection-card--center-aligned': isTitleOnly.value, })); const checkboxContainerConditionalClasses = computed(() => ({ 'b-selection-card__checkbox-container--center-aligned': isTitleOnly.value, })); const checkboxContainerTextConditionalClasses = computed(() => ({ 'b-selection-card__checkbox-container-text--center-aligned': isTitleOnly.value, })); const slotConditionalClasses = computed(() => ({ 'b-selection-card__slot--with-icon': hasSlot('icon'), })); const ariaLabel = useAriaLabel({ ariaLabel: props.title, label: props.value as string, }); const isCheckboxGroup = computed(() => Array.isArray(props.modelValue)); const isChecked: ComputedRef<boolean> = computed(() => { if (isRadioInput.value) { return props.value === props.modelValue; } if (!isCheckboxGroup.value) { return props.modelValue as boolean; } return (props.modelValue as BentoMultiCheckboxType).some(item => item === props.value); }); const isRadioInput: Ref<boolean> = inject(SELECTION_CARD_RADIO_INPUT_INJECTION_KEY, ref(false)); const isTitleOnly = computed(() => !props.subtitle && !props.description); const inputRef = ref<InstanceType<typeof RadioInput> | InstanceType<typeof CheckboxInput>>(null); const slotRef = ref(null); const dynamicSlotRef = ref(null); // Handle click on the whole card area const handleCardClick = (event: Event) => { if (inputRef.value.$refs.inputRef === event.target) { const newValue = toggleInput(); onChange(newValue); return; } // Do nothing if disabled or readonly if (props.disabled && props.readonly) { return; } // If it's not fully clickable prevent selecting the card if the click // originated in a slot if (!props.fullyClickable) { // Check if the click originated from the slot - in that case, do nothng if (slotRef.value && slotRef.value?.$el?.contains(event.target)) { return; } // Check if the click originated from the dynamic slot - in that case, do nothng if (dynamicSlotRef.value && dynamicSlotRef.value?.$el?.contains(event.target)) { return; } // Check if the click originated from the input - in that case do nothing, as the input will emit the event already if (inputRef.value && inputRef.value?.$el?.contains(event.target as Node)) { return; } } // If the click originated outside of these two areas, emit the change event const newValue = toggleInput(); onChange(newValue); }; const toggleInput = (): BentoSelectionCardModelValue => { const currentValue: boolean = (inputRef.value?.$refs.inputRef as HTMLInputElement).checked; if (isCheckboxGroup.value) { const newCheckedList = [...(props.modelValue as BentoMultiCheckboxType)]; const index = newCheckedList.indexOf(props.value); if (index === -1) { newCheckedList.push(props.value); } else { newCheckedList.splice(index, 1); } return newCheckedList; } if (isRadioInput.value) { return props.value; } return currentValue; }; const onChange = newValue => { if (!props.disabled && !props.readonly) { emit('update:model-value', newValue); emit('input', newValue); } }; </script> <script lang="ts"> /** * Selection card component. If used standalone, only the checkbox variant can be used. If the checkbox variant is needed, please use the bento-selection-card-group component. * * @example * import { BentoSelectionCard } from '@adyen/bento-vue2'; * import EmoticonHappyIcon from '@adyen/ui-assets-icons-16/vue/emoticon-happy'; * * export default { * components: { BentoSelectionCard, EmoticonHappyIcon }, * template: ` * <bento-selection-card title="Card title" :model-value.sync="yourModelValue"> * <template #icon> * <emoticon-happy-icon /> * </template> * </bento-selection-card> * ` * } */ export default { name: 'bento-selection-card', }; </script> <style lang="scss" scoped src="./selection-card.scss" />
1
+ <template> <div class="b-selection-card" :class="conditionalClasses" @click="handleCardClick"> <div class="b-selection-card__container" :class="containerConditionalClasses"> <div class="b-selection-card__checkbox-container" :class="checkboxContainerConditionalClasses"> <div class="b-selection-card__checkbox-container-text" :class="checkboxContainerTextConditionalClasses"> <div v-if="hasSlot('icon')" class="b-selection-card__icon" role="presentation" aria-hidden="true"> <slot name="icon" /> </div> <label :for="inputId" class="b-selection-card__text" @click.stop.prevent="handleCardClick"> <bento-typography v-if="subtitle" class="b-selection-card__description" el="span" variant="caption" > {{ subtitle }} </bento-typography> <bento-typography el="span" variant="title">{{ title }}</bento-typography> <bento-typography v-if="description" id="descriptionId" class="b-selection-card__description" el="span" variant="body" > {{ description }} </bento-typography> </label> </div> <radio-input v-if="isRadioInput" :id="inputId" ref="inputRef" :aria-label="ariaLabel" :aria-describedby="description ? descriptionId : undefined" :disabled="disabled" :has-error="hasError" :aria-readonly="readonly ?? undefined" :value="value" :readonly="readonly" :model-value="computedRadioInputModelValue" /> <checkbox-input v-else :id="inputId" ref="inputRef" :aria-label="ariaLabel" :aria-describedby="description ? descriptionId : undefined" :disabled="disabled" :has-error="hasError" :aria-readonly="readonly ?? undefined" :value="value" :readonly="readonly" :model-value="computedCheckboxInputModelValue" /> </div> <bento-typography v-if="hasSlot('content')" ref="slotRef" el="div" class="b-selection-card__slot" :class="slotConditionalClasses" > <slot name="content" /> </bento-typography> <bento-typography v-if="hasSlot('dynamicContent') && isChecked" ref="dynamicSlotRef" el="div" class="b-selection-card__slot" :class="slotConditionalClasses" > <slot name="dynamicContent" /> </bento-typography> </div> </div> </template> <script setup lang="ts"> import { BentoTypography } from '@/components/typography'; import { CheckboxInput } from '../internal/checkbox-input'; import { RadioInput, type RadioInputValue } from '../internal/radio-input'; import { type BentoCheckboxType, type BentoMultiCheckboxType } from '@/types/checkbox'; import { useAriaLabel } from '@/utils/ts/aria-label'; import { generateUid } from '@/utils/ts/generate-uid'; import { computed, type ComputedRef, inject, type PropType, type Ref, ref, useSlots } from 'vue'; import { useHasSlot } from '@/composables'; import type { BentoSelectionCardModelValue, BentoSelectionCardValue } from './selection-card.types'; import { BentoSelectionCardState } from './selection-card.types'; import { SELECTION_CARD_RADIO_INPUT_INJECTION_KEY } from './selection-card.keys'; const props = defineProps({ /** * The description of the selection card */ description: { type: String, default: undefined, }, /** * Disables the selection card */ disabled: { type: Boolean, default: false }, /** * Makes the entire selection card clickable. Clicking over interactive elements inside the card with this prop enabled will not be possible. */ fullyClickable: { type: Boolean, default: false }, /** * Shows the selection card in error state */ hasError: { type: Boolean, default: false }, /** * This property should not be used directly. * It will be used by v-model directive on selection card component. * * When handling a single input, use a string or a number. * * When handling multiple inputs, use an array of keys. * These keys exist as a set "value" prop for each input. */ modelValue: { type: [Boolean, String, Array] as PropType<BentoSelectionCardModelValue>, default: null, }, /** * Sets the selection card to readonly */ readonly: { type: Boolean, default: false }, /** * The subtitle of the selection card */ subtitle: { type: String, default: undefined, }, /** * The title of the selection card */ title: { type: String, required: true, }, /** * Indicates the value of the input that will be returned when it's checked. */ value: { type: [String, Number] as PropType<BentoSelectionCardValue>, required: true, }, }); const emit = defineEmits<{ /** * Emitted when the selection card is clicked. Enables Vue2 "v-model" */ (e: 'input', value: BentoSelectionCardValue); /** * Emitted when the selection card is clicked. Enables Vue3 "v-model" */ (e: 'update:model-value', value: BentoSelectionCardValue); }>(); const slots = useSlots(); const hasSlot = useHasSlot(slots); const inputId = generateUid('selection-card-input-id'); const descriptionId = generateUid('selection-card-description'); const computedRadioInputModelValue: ComputedRef<RadioInputValue> = computed( () => props.modelValue as RadioInputValue ); const computedCheckboxInputModelValue: ComputedRef<BentoCheckboxType> = computed( () => props.modelValue as BentoCheckboxType ); const conditionalClasses = computed(() => ({ 'b-selection-card--checked': isChecked.value, 'b-selection-card--fully-clickable': props.fullyClickable, })); const containerConditionalClasses = computed(() => ({ [`b-selection-card--${BentoSelectionCardState.DISABLED}`]: props.disabled, [`b-selection-card--${BentoSelectionCardState.ERROR}`]: props.hasError, [`b-selection-card--${BentoSelectionCardState.READONLY}`]: props.readonly, 'b-selection-card--center-aligned': isTitleOnly.value, })); const checkboxContainerConditionalClasses = computed(() => ({ 'b-selection-card__checkbox-container--center-aligned': isTitleOnly.value, })); const checkboxContainerTextConditionalClasses = computed(() => ({ 'b-selection-card__checkbox-container-text--center-aligned': isTitleOnly.value, })); const slotConditionalClasses = computed(() => ({ 'b-selection-card__slot--with-icon': hasSlot('icon'), })); const ariaLabel = useAriaLabel({ ariaLabel: props.title, label: props.value as string, }); const isCheckboxGroup = computed(() => Array.isArray(props.modelValue)); const isChecked: ComputedRef<boolean> = computed(() => { if (isRadioInput.value) { return props.value === props.modelValue; } if (!isCheckboxGroup.value) { return props.modelValue as boolean; } return (props.modelValue as BentoMultiCheckboxType).some(item => item === props.value); }); const isRadioInput: Ref<boolean> = inject(SELECTION_CARD_RADIO_INPUT_INJECTION_KEY, ref(false)); const isTitleOnly = computed(() => !props.subtitle && !props.description); const inputRef = ref<InstanceType<typeof RadioInput> | InstanceType<typeof CheckboxInput>>(null); const slotRef = ref(null); const dynamicSlotRef = ref(null); // Handle click on the whole card area const handleCardClick = (event: Event) => { if (inputRef.value.$refs.inputRef === event.target) { const newValue = toggleInput(); onChange(newValue); return; } // Do nothing if disabled or readonly if (props.disabled && props.readonly) { return; } // If it's not fully clickable prevent selecting the card if the click // originated in a slot if (!props.fullyClickable) { // Check if the click originated from the slot - in that case, do nothng if (slotRef.value && slotRef.value?.$el?.contains(event.target)) { return; } // Check if the click originated from the dynamic slot - in that case, do nothng if (dynamicSlotRef.value && dynamicSlotRef.value?.$el?.contains(event.target)) { return; } // Check if the click originated from the input - in that case do nothing, as the input will emit the event already if (inputRef.value && inputRef.value?.$el?.contains(event.target as Node)) { return; } } // If the click originated outside of these two areas, emit the change event const newValue = toggleInput(); onChange(newValue); }; const toggleInput = (): BentoSelectionCardModelValue => { const currentValue: boolean = (inputRef.value?.$refs.inputRef as HTMLInputElement).checked; if (isCheckboxGroup.value) { const newCheckedList = [...(props.modelValue as BentoMultiCheckboxType)]; const index = newCheckedList.indexOf(props.value); if (index === -1) { newCheckedList.push(props.value); } else { newCheckedList.splice(index, 1); } return newCheckedList; } if (isRadioInput.value) { return props.value; } return currentValue; }; const onChange = newValue => { if (!props.disabled && !props.readonly) { emit('update:model-value', newValue); emit('input', newValue); } }; </script> <script lang="ts"> /** * Selection card component. If used standalone, only the checkbox variant can be used. If the checkbox variant is needed, please use the bento-selection-card-group component. * * @example * import { BentoSelectionCard } from '@adyen/bento-vue2'; * import EmoticonHappyIcon from '@adyen/ui-assets-icons-16/vue/emoticon-happy'; * * export default { * components: { BentoSelectionCard, EmoticonHappyIcon }, * template: ` * <bento-selection-card title="Card title" :model-value.sync="yourModelValue"> * <template #icon> * <emoticon-happy-icon /> * </template> * </bento-selection-card> * ` * } */ export default { name: 'bento-selection-card', }; </script> <style lang="scss" scoped src="./selection-card.scss" />
@@ -101,7 +101,7 @@ The `isDismissible` property determines whether the sidepanel can be closed by c
101
101
  To independently control the visibility of the close button while `isDismissible` is set, use the `hideCloseButton`
102
102
  property.
103
103
 
104
- **Upcoming in v2.0.0:** The appearance of the close button will no longer depend on the `isDismissible` property.
104
+ **Upcoming in v3.0.0:** The appearance of the close button will no longer depend on the `isDismissible` property.
105
105
  Instead, you will have full control over its visibility using the `hideCloseButton` property. By default,
106
106
  `hideCloseButton` will be set to `false`, meaning the close button will be shown regardless of the value of
107
107
  `isDismissible`.
@@ -1 +1 @@
1
- import { ref, watch } from 'vue'; import { BentoButton } from '@/components/button'; import BentoSidepanel from './sidepanel.vue'; import BentoSidepanelPage from './components/sidepanel-page.vue'; import { isVue2 } from 'vue-demi'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import { action } from '@storybook/addon-actions'; import { type Meta, type StoryObj } from '@storybook/vue'; export default { title: 'Sidepanel', component: BentoSidepanel, argTypes: { default: { name: 'default', type: { name: 'string', required: false }, description: 'BentoSidepanelPage components', control: 'text', table: { type: { summary: 'VNode[]' }, }, }, }, } as Meta; type Story = StoryObj<typeof BentoSidepanel>; const DEFAULT_PROPS = { isOpen: false, isDismissible: true, }; const onePageCode = ` <bento-sidepanel :is-open="isOpen" @update:is-open="isOpen = $event"> <bento-sidepanel-page title="One page" :actions="actionsArray"> This is the content of the sidepanel. </bento-sidepanel-page> </bento-sidepanel> `; export const OnePage: Story = { render: (_args, { argTypes }) => ({ components: { BentoButton, BentoSidepanel, BentoSidepanelPage }, props: Object.keys(argTypes), template: ` <div> <bento-button :aria-expanded="isOpen" @click="isOpen = true" > Open sidepanel </bento-button> <bento-sidepanel v-bind="args" :is-open="isOpen" @update:is-open='isOpen = false'> <bento-sidepanel-page title="Intro">This is my only page</bento-sidepanel-page> </bento-sidepanel> </div> `, setup(props) { const isOpen = ref(false); const args = isVue2 ? props : _args; watch( () => args.isOpen, () => { isOpen.value = args.isOpen; } ); return { args, isOpen, }; }, }), args: { ...DEFAULT_PROPS }, parameters: storybookDocsParameter(onePageCode), }; const multiplePagesCode = ` <bento-sidepanel :is-open="isOpen" :active-page="activePage" @update:is-open="isOpen = $event" @update:active-page="activePage = $event" > <bento-sidepanel-page pageId="step1" title="Step 1" :actions="actionsArray" actions-label="Label"> This is the content of step 1 of the sidepanel. With an label next to the actions. </bento-sidepanel-page> <bento-sidepanel-page pageId="step2" title="Step 2" :actions="actionsArray"> This is the content of step 2 of the sidepanel. </bento-sidepanel-page> <bento-sidepanel-page pageId="step3" title="Step 3" :actions="actionsArray" destructive-actions> This is the content of step 3 of the sidepanel. With the primary action as a destructive action. </bento-sidepanel-page> <bento-sidepanel-page pageId="step4" title="Step 4" :actions="actionsArray" :previous-page="null"> This is the content of step 4 of the sidepanel. With no back arrow showing. </bento-sidepanel-page> </bento-sidepanel> `; export const MultiplePages: Story = { render: (_args, { argTypes }) => ({ components: { BentoButton, BentoSidepanel, BentoSidepanelPage }, props: Object.keys(argTypes), template: ` <div> <bento-button :aria-expanded="isOpen" @click="isOpen = true" > Open sidepanel </bento-button> <bento-sidepanel v-bind="args" :is-open="isOpen" :active-page="activePage" @update:active-page="activePage = $event" @update:is-open='isOpen = $event'> <bento-sidepanel-page v-bind="intro"> <p style="margin-top: 0;">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </bento-sidepanel-page> <bento-sidepanel-page v-bind="newProfile" > This page has some info about creating a new profile </bento-sidepanel-page> <bento-sidepanel-page v-bind="editProfile" > This is where you edit your profile </bento-sidepanel-page> <bento-sidepanel-page v-bind="newProfileForm"> This is where you create a new profile </bento-sidepanel-page> <bento-sidepanel-page v-bind="success"> Your profile is created </bento-sidepanel-page> </bento-sidepanel> </div> `, setup(props) { const isOpen = ref(false); const activePage = ref('intro'); const args = isVue2 ? props : _args; watch( () => args.isOpen, () => { isOpen.value = args.isOpen; } ); watch( () => args.activePage, () => { activePage.value = args.activePage; } ); const intro = { pageId: 'intro', title: 'Intro', actions: [ { title: 'New profile', event: () => { activePage.value = 'newProfile'; }, }, { title: 'Edit profile', event: () => { activePage.value = 'editProfile'; }, }, ], actionsLabel: 'What do you wanna do?', }; const newProfile = { pageId: 'newProfile', title: 'New profile', actions: [ { title: 'Go to form', event: () => { activePage.value = 'newProfileForm'; }, }, ], }; const editProfile = { pageId: 'editProfile', title: 'Edit profile', actions: [ { title: 'Save', event: () => { activePage.value = 'success'; }, }, { title: 'Cancel', event: () => { isOpen.value = false; action('cancel')(); }, }, ], }; const newProfileForm = { pageId: 'newProfileForm', title: 'New profile form', actions: [ { title: 'Save', event: () => { activePage.value = 'success'; }, }, { title: 'Cancel', event: () => { isOpen.value = false; action('cancel')(); }, }, ], }; const success = { pageId: 'success', title: 'Success!', destructiveActions: true, actions: [ { title: 'Delete', event: () => { isOpen.value = false; action('delete')(); }, }, { title: 'Cancel', event: () => { isOpen.value = false; action('cancel')(); }, }, ], previousPage: null, }; return { args, activePage, intro, newProfile, newProfileForm, success, editProfile, isOpen, }; }, }), args: { ...DEFAULT_PROPS, activePage: 'intro' }, parameters: storybookDocsParameter(multiplePagesCode), };
1
+ import { ref, watch } from 'vue'; import { BentoButton } from '@/components/button'; import BentoSidepanel from './sidepanel.vue'; import BentoSidepanelPage from './components/sidepanel-page.vue'; const SidepanelMultiplePagesExample = "<template>\n <div>\n <bento-button :aria-expanded=\"isOpen\" @click=\"isOpen = true\">Open sidepanel</bento-button>\n <bento-sidepanel\n :is-open=\"isOpen\"\n is-dismissible\n :active-page=\"activePage\"\n @update:active-page=\"activePage = $event\"\n @update:is-open=\"isOpen = $event\"\n >\n <bento-sidepanel-page v-bind=\"intro\">\n <p style=\"margin-top: 0\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore\n et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut\n aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\n cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in\n culpa qui officia deserunt mollit anim id est laborum.\n </p>\n <p>\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore\n et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut\n aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\n cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in\n culpa qui officia deserunt mollit anim id est laborum.\n </p>\n <p>\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore\n et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut\n aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\n cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in\n culpa qui officia deserunt mollit anim id est laborum.\n </p>\n <p>\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore\n et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut\n aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\n cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in\n culpa qui officia deserunt mollit anim id est laborum.\n </p>\n <p>\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore\n et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut\n aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\n cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in\n culpa qui officia deserunt mollit anim id est laborum.\n </p>\n </bento-sidepanel-page>\n <bento-sidepanel-page v-bind=\"newProfile\">\n This page has some info about creating a new profile\n </bento-sidepanel-page>\n <bento-sidepanel-page v-bind=\"editProfile\">This is where you edit your profile</bento-sidepanel-page>\n <bento-sidepanel-page v-bind=\"newProfileForm\">This is where you create a new profile</bento-sidepanel-page>\n <bento-sidepanel-page v-bind=\"success\">Your profile is created</bento-sidepanel-page>\n </bento-sidepanel>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import { BentoButton, type BentoButtonActionsList, BentoSidepanel, BentoSidepanelPage } from '@adyen/bento-vue2';\n\n const isOpen = ref(false);\n const activePage = ref('intro');\n\n const intro = {\n pageId: 'intro',\n title: 'Intro',\n actions: [\n {\n title: 'New profile',\n event: () => {\n activePage.value = 'newProfile';\n },\n },\n {\n title: 'Edit profile',\n event: () => {\n activePage.value = 'editProfile';\n },\n },\n ] as BentoButtonActionsList,\n actionsLabel: 'What do you wanna do?',\n };\n\n const newProfile = {\n pageId: 'newProfile',\n title: 'New profile',\n actions: [\n {\n title: 'Go to form',\n event: () => {\n activePage.value = 'newProfileForm';\n },\n },\n ] as BentoButtonActionsList,\n };\n\n const editProfile = {\n pageId: 'editProfile',\n title: 'Edit profile',\n actions: [\n {\n title: 'Save',\n event: () => {\n activePage.value = 'success';\n },\n },\n {\n title: 'Cancel',\n event: () => {\n isOpen.value = false;\n },\n },\n ] as BentoButtonActionsList,\n };\n\n const newProfileForm = {\n pageId: 'newProfileForm',\n title: 'New profile form',\n actions: [\n {\n title: 'Save',\n event: () => {\n activePage.value = 'success';\n },\n },\n {\n title: 'Cancel',\n event: () => {\n isOpen.value = false;\n },\n },\n ] as BentoButtonActionsList,\n };\n\n const success = {\n pageId: 'success',\n title: 'Success!',\n destructiveActions: true,\n actions: [\n {\n title: 'Delete',\n event: () => {\n isOpen.value = false;\n },\n },\n {\n title: 'Cancel',\n event: () => {\n isOpen.value = false;\n },\n },\n ] as BentoButtonActionsList,\n previousPage: null,\n };\n</script>\n"; const SidepanelOnePageExample = "<template>\n <div>\n <bento-button :aria-expanded=\"isOpen\" @click=\"isOpen = true\">Open sidepanel</bento-button>\n <bento-sidepanel :is-open=\"isOpen\" is-dismissible @update:is-open=\"isOpen = $event\">\n <bento-sidepanel-page title=\"Intro\">This is my only page</bento-sidepanel-page>\n </bento-sidepanel>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import { BentoButton, BentoSidepanel, BentoSidepanelPage } from '@adyen/bento-vue2';\n\n const isOpen = ref(false);\n</script>\n"; import { isVue2 } from 'vue-demi'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import { action } from '@storybook/addon-actions'; import { type Meta, type StoryObj } from '@storybook/vue'; export default { title: 'Sidepanel', component: BentoSidepanel, argTypes: { default: { name: 'default', type: { name: 'string', required: false }, description: 'BentoSidepanelPage components', control: 'text', table: { type: { summary: 'VNode[]' }, }, }, }, } as Meta; type Story = StoryObj<typeof BentoSidepanel>; const DEFAULT_PROPS = { isOpen: false, isDismissible: true, }; export const OnePage: Story = { render: (_args, { argTypes }) => ({ components: { BentoButton, BentoSidepanel, BentoSidepanelPage }, props: Object.keys(argTypes), template: ` <div> <bento-button :aria-expanded="isOpen" @click="isOpen = true" > Open sidepanel </bento-button> <bento-sidepanel v-bind="args" :is-open="isOpen" @update:is-open='isOpen = false'> <bento-sidepanel-page title="Intro">This is my only page</bento-sidepanel-page> </bento-sidepanel> </div> `, setup(props) { const isOpen = ref(false); const args = isVue2 ? props : _args; watch( () => args.isOpen, () => { isOpen.value = args.isOpen; } ); return { args, isOpen, }; }, }), args: { ...DEFAULT_PROPS }, parameters: storybookDocsParameter(SidepanelOnePageExample), }; export const MultiplePages: Story = { render: (_args, { argTypes }) => ({ components: { BentoButton, BentoSidepanel, BentoSidepanelPage }, props: Object.keys(argTypes), template: ` <div> <bento-button :aria-expanded="isOpen" @click="isOpen = true" > Open sidepanel </bento-button> <bento-sidepanel v-bind="args" :is-open="isOpen" :active-page="activePage" @update:active-page="activePage = $event" @update:is-open='isOpen = $event'> <bento-sidepanel-page v-bind="intro"> <p style="margin-top: 0;">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </bento-sidepanel-page> <bento-sidepanel-page v-bind="newProfile" > This page has some info about creating a new profile </bento-sidepanel-page> <bento-sidepanel-page v-bind="editProfile" > This is where you edit your profile </bento-sidepanel-page> <bento-sidepanel-page v-bind="newProfileForm"> This is where you create a new profile </bento-sidepanel-page> <bento-sidepanel-page v-bind="success"> Your profile is created </bento-sidepanel-page> </bento-sidepanel> </div> `, setup(props) { const isOpen = ref(false); const activePage = ref('intro'); const args = isVue2 ? props : _args; watch( () => args.isOpen, () => { isOpen.value = args.isOpen; } ); watch( () => args.activePage, () => { activePage.value = args.activePage; } ); const intro = { pageId: 'intro', title: 'Intro', actions: [ { title: 'New profile', event: () => { activePage.value = 'newProfile'; }, }, { title: 'Edit profile', event: () => { activePage.value = 'editProfile'; }, }, ], actionsLabel: 'What do you wanna do?', }; const newProfile = { pageId: 'newProfile', title: 'New profile', actions: [ { title: 'Go to form', event: () => { activePage.value = 'newProfileForm'; }, }, ], }; const editProfile = { pageId: 'editProfile', title: 'Edit profile', actions: [ { title: 'Save', event: () => { activePage.value = 'success'; }, }, { title: 'Cancel', event: () => { isOpen.value = false; action('cancel')(); }, }, ], }; const newProfileForm = { pageId: 'newProfileForm', title: 'New profile form', actions: [ { title: 'Save', event: () => { activePage.value = 'success'; }, }, { title: 'Cancel', event: () => { isOpen.value = false; action('cancel')(); }, }, ], }; const success = { pageId: 'success', title: 'Success!', destructiveActions: true, actions: [ { title: 'Delete', event: () => { isOpen.value = false; action('delete')(); }, }, { title: 'Cancel', event: () => { isOpen.value = false; action('cancel')(); }, }, ], previousPage: null, }; return { args, activePage, intro, newProfile, newProfileForm, success, editProfile, isOpen, }; }, }), args: { ...DEFAULT_PROPS, activePage: 'intro' }, parameters: storybookDocsParameter(SidepanelMultiplePagesExample), };
@@ -1 +1 @@
1
- <template> <dialog ref="sidepanel" class="b-sidepanel" :class="conditionalClasses" @animationend="closeSidepanelAfterAnimation" @keydown.esc.prevent="isDismissible && startCloseSidepanelAnimation" > <bento-focus-trap :id="sidepanelId" v-bento-click-outside-directive="closeSidepanelOnClickOutside"> <div v-if="!computedHideCloseButton" class="b-sidepanel__close-button"> <bento-button variant="tertiary" @click="startCloseSidepanelAnimation"> <cross-icon :svg-title="t('close')" /> </bento-button> </div> <slot /> </bento-focus-trap> </dialog> </template> <script setup lang="ts"> import { computed, onMounted, onUnmounted, provide, ref, toRefs, watch } from 'vue'; import { BentoButton } from '@/components/button'; import { BentoFocusTrap } from '@/components/focus-trap'; import CrossIcon from '@adyen/ui-assets-icons-16/vue/cross'; import { BentoSidepanelEvent } from './sidepanel.types'; import { BentoDialogPageAnimation, type BentoDialogPageConfigData, type BentoDialogPageRegisterPage, DIALOG_PAGE_CONFIG_INJECTION_KEY, DIALOG_PAGE_REGISTER_PAGE_INJECTION_KEY, } from '@/internal'; import { SIDEPANEL_DIALOG_ID_INJECTION_KEY } from './sidepanel.keys'; import { BentoClickOutsideDirective as vBentoClickOutsideDirective } from '@/directives/click-outside'; import { useI18n } from '@/utils/ts/i18n'; import messages from './messages.json'; import { generateUid } from '@/core/utils/ts'; import { deprecate } from '@/utils/ts/deprecate'; type MessageSchema = (typeof messages)['en-US']; const props = defineProps({ /** * The id of the current active page * Should be the same id as the BentoSidepanelPage to be displayed * If the component only has one page, it can be left null/undefined. */ activePage: { type: String, default: null, }, /** * If set to true, it allows the sidepanel to be closed. * Shows close button when `true` and hides close button when `false`. * * _Note: This property will not set the visibility of the close button in v2.0.0_ */ isDismissible: { type: Boolean, default: false, }, /** * Controls the sidepanel's state from the outside. Set it to true to open the sidepanel. */ isOpen: { type: Boolean, default: null, }, /** * Controls the visibility of close button on the sidepanel. * Defaults to `true` when `isDismissible=false`, and `true` when `isDimissible=true`. * * _Note: This property will be set to `false` by default, independent of `isDismissible` in v2.0.0_ */ hideCloseButton: { type: Boolean, default: null, }, }); const emit = defineEmits<{ /** * Emits update event when page is changed internally */ (e: BentoSidepanelEvent.UPDATE_ACTIVE_PAGE, page: string): void; /** * Emits close-sidepanel event when the sidepanel is closed */ (e: BentoSidepanelEvent.UPDATE_IS_OPEN, isOpen: boolean): void; }>(); // Refs const { activePage, isOpen } = toRefs(props); const { t } = useI18n<{ message: MessageSchema }>({ messages }); const sidepanel = ref(null); const pages = ref<Array<string>>([]); const previousPages = ref([]); const animation = ref(BentoDialogPageAnimation.TRANSITION_LEVEL_DEEPER); const isClosing = ref(false); const sidepanelId = generateUid('sidepanel'); const internalIsOpen = ref(false); const isAnimationActive = ref(false); const isMounted = ref(false); // Animation styling const conditionalClasses = computed(() => ({ 'b-sidepanel--hide': isClosing.value, 'b-sidepanel--animation': isAnimationActive.value, })); // Handle closing and closing animation for dialog element const closeSidepanelAfterAnimation = () => { if (isClosing.value && sidepanel.value) { sidepanel.value.close(); if (previousPages.value[0]) { emit(BentoSidepanelEvent.UPDATE_ACTIVE_PAGE, previousPages.value[0]); } previousPages.value = []; isClosing.value = false; internalIsOpen.value = false; emit(BentoSidepanelEvent.UPDATE_IS_OPEN, false); } }; const startCloseSidepanelAnimation = () => { if (!sidepanel.value || !sidepanel.value.open) { return; } isClosing.value = true; }; const closeSidepanelOnClickOutside = () => { if (props.isDismissible) { startCloseSidepanelAnimation(); } }; // TODO: Remove in upcoming major. See properties `hideCloseButton` and `isDismissible`. const computedHideCloseButton = computed(() => { if (props.hideCloseButton !== null) { return props.hideCloseButton; } return !props.isDismissible; }); onMounted(() => { isMounted.value = true; }); onUnmounted(() => { isMounted.value = false; }); // Watching isOpen prop to toggle open/close the dialog element watch( [() => isOpen.value, sidepanel], ([newIsOpen, newSidepanelValue]) => { if (!isMounted.value || !newSidepanelValue) { return; } if (newIsOpen) { internalIsOpen.value = true; if (!newSidepanelValue.open) { newSidepanelValue.showModal(); } if (!previousPages.value.length) { previousPages.value.push(activePage.value); } } else if (newSidepanelValue.open) { startCloseSidepanelAnimation(); } }, { immediate: true, flush: 'post' } ); // Pages const updatePage = page => emit(BentoSidepanelEvent.UPDATE_ACTIVE_PAGE, page); // unregister page if removed / destroyed const unregisterPage = (pageIdToRemove: string) => () => { pages.value = pages.value?.filter(pageId => pageId !== pageIdToRemove); }; // Provide data and function to register page to subcomponent const registerPage: BentoDialogPageRegisterPage = pageId => { pages.value.push(pageId); return { unregisterPage: unregisterPage(pageId) }; }; provide<BentoDialogPageConfigData>(DIALOG_PAGE_CONFIG_INJECTION_KEY, { activePage, animation, isAnimationActive, isOpen: internalIsOpen, pages, previousPages, updatePage, }); provide(DIALOG_PAGE_REGISTER_PAGE_INJECTION_KEY, registerPage); // Let's Children components know they are inside a SidePanel (dialog element) provide(SIDEPANEL_DIALOG_ID_INJECTION_KEY, sidepanelId); if (!props.isDismissible && props.hideCloseButton === null) { deprecate( 'BentoSidepanel "isDismissible" property’s behavior', 'BentoSidepanel "isDismissible" will no longer hide the close button. Use "hideCloseButton=true" instead.', '2.0.0' ); } </script> <script lang="ts"> /** * Sidepanel component is a slide-in panel that should be used for presenting actions, settings or features that are directly associated with a specific task or interaction on the main screen. * * @example * import { BentoSidepanel, BentoSidepanelPage } from '@adyen/bento-vue2'; * * export default { * components: { BentoSidepanel, BentoSidepanelPage }, * template: ` * <bento-sidepanel active-page='step1' is-open='true'> * <bento-sidepanel-page * title='Step 1' * pageId='step1' * :actions="[ * { * title: 'Next step', * event: () => { * activePage.value = 'step2'; * }, * }]"> * Step 1 info * </bento-sidepanel-page> * <bento-sidepanel-page * title='Step 2' * pageId='step2' * :actions="[ * { * title: 'Save', * event: () => {}, * }]"> * Step 2 info * </bento-sidepanel-page> * </bento-sidepanel> * ` * } */ export default { i18n: { messages }, }; </script> <style lang="scss" scoped src="./sidepanel.scss" />
1
+ <template> <dialog ref="sidepanel" class="b-sidepanel" :class="conditionalClasses" @animationend="closeSidepanelAfterAnimation" @keydown.esc.prevent="isDismissible && startCloseSidepanelAnimation" > <bento-focus-trap :id="sidepanelId" v-bento-click-outside-directive="closeSidepanelOnClickOutside"> <div v-if="!computedHideCloseButton" class="b-sidepanel__close-button"> <bento-button variant="tertiary" @click="startCloseSidepanelAnimation"> <cross-icon :svg-title="t('close')" /> </bento-button> </div> <slot /> </bento-focus-trap> </dialog> </template> <script setup lang="ts"> import { computed, onMounted, onUnmounted, provide, ref, toRefs, watch } from 'vue'; import { BentoButton } from '@/components/button'; import { BentoFocusTrap } from '@/components/focus-trap'; import CrossIcon from '@adyen/ui-assets-icons-16/vue/cross'; import { BentoSidepanelEvent } from './sidepanel.types'; import { BentoDialogPageAnimation, type BentoDialogPageConfigData, type BentoDialogPageRegisterPage, DIALOG_PAGE_CONFIG_INJECTION_KEY, DIALOG_PAGE_REGISTER_PAGE_INJECTION_KEY, } from '@/internal'; import { SIDEPANEL_DIALOG_ID_INJECTION_KEY } from './sidepanel.keys'; import { BentoClickOutsideDirective as vBentoClickOutsideDirective } from '@/directives/click-outside'; import { useI18n } from '@/utils/ts/i18n'; import messages from './messages.json'; import { generateUid } from '@/utils/ts/generate-uid'; import { deprecate } from '@/utils/ts/deprecate'; type MessageSchema = (typeof messages)['en-US']; const props = defineProps({ /** * The id of the current active page * Should be the same id as the BentoSidepanelPage to be displayed * If the component only has one page, it can be left null/undefined. */ activePage: { type: String, default: null, }, /** * If set to true, it allows the sidepanel to be closed. * Shows close button when `true` and hides close button when `false`. * * _Note: This property will not set the visibility of the close button in v3.0.0_ */ isDismissible: { type: Boolean, default: false, }, /** * Controls the sidepanel's state from the outside. Set it to true to open the sidepanel. */ isOpen: { type: Boolean, default: null, }, /** * Controls the visibility of close button on the sidepanel. * Defaults to `true` when `isDismissible=false`, and `true` when `isDimissible=true`. * * _Note: This property will be set to `false` by default, independent of `isDismissible` in v3.0.0_ */ hideCloseButton: { type: Boolean, default: null, }, }); const emit = defineEmits<{ /** * Emits update event when page is changed internally */ (e: BentoSidepanelEvent.UPDATE_ACTIVE_PAGE, page: string): void; /** * Emits close-sidepanel event when the sidepanel is closed */ (e: BentoSidepanelEvent.UPDATE_IS_OPEN, isOpen: boolean): void; }>(); // Refs const { activePage, isOpen } = toRefs(props); const { t } = useI18n<{ message: MessageSchema }>({ messages }); const sidepanel = ref(null); const pages = ref<Array<string>>([]); const previousPages = ref([]); const animation = ref(BentoDialogPageAnimation.TRANSITION_LEVEL_DEEPER); const isClosing = ref(false); const sidepanelId = generateUid('sidepanel'); const internalIsOpen = ref(false); const isAnimationActive = ref(false); const isMounted = ref(false); // Animation styling const conditionalClasses = computed(() => ({ 'b-sidepanel--hide': isClosing.value, 'b-sidepanel--animation': isAnimationActive.value, })); // Handle closing and closing animation for dialog element const closeSidepanelAfterAnimation = () => { if (isClosing.value && sidepanel.value) { sidepanel.value.close(); if (previousPages.value[0]) { emit(BentoSidepanelEvent.UPDATE_ACTIVE_PAGE, previousPages.value[0]); } previousPages.value = []; isClosing.value = false; internalIsOpen.value = false; emit(BentoSidepanelEvent.UPDATE_IS_OPEN, false); } }; const startCloseSidepanelAnimation = () => { if (!sidepanel.value || !sidepanel.value.open) { return; } isClosing.value = true; }; const closeSidepanelOnClickOutside = () => { if (props.isDismissible) { startCloseSidepanelAnimation(); } }; // TODO: Remove in upcoming major. See properties `hideCloseButton` and `isDismissible`. const computedHideCloseButton = computed(() => { if (props.hideCloseButton !== null) { return props.hideCloseButton; } return !props.isDismissible; }); onMounted(() => { isMounted.value = true; }); onUnmounted(() => { isMounted.value = false; }); // Watching isOpen prop to toggle open/close the dialog element watch( [() => isOpen.value, sidepanel], ([newIsOpen, newSidepanelValue]) => { if (!isMounted.value || !newSidepanelValue) { return; } if (newIsOpen) { internalIsOpen.value = true; if (!newSidepanelValue.open) { newSidepanelValue.showModal(); } if (!previousPages.value.length) { previousPages.value.push(activePage.value); } } else if (newSidepanelValue.open) { startCloseSidepanelAnimation(); } }, { immediate: true, flush: 'post' } ); // Pages const updatePage = page => emit(BentoSidepanelEvent.UPDATE_ACTIVE_PAGE, page); // unregister page if removed / destroyed const unregisterPage = (pageIdToRemove: string) => () => { pages.value = pages.value?.filter(pageId => pageId !== pageIdToRemove); }; // Provide data and function to register page to subcomponent const registerPage: BentoDialogPageRegisterPage = pageId => { pages.value.push(pageId); return { unregisterPage: unregisterPage(pageId) }; }; provide<BentoDialogPageConfigData>(DIALOG_PAGE_CONFIG_INJECTION_KEY, { activePage, animation, isAnimationActive, isOpen: internalIsOpen, pages, previousPages, updatePage, }); provide(DIALOG_PAGE_REGISTER_PAGE_INJECTION_KEY, registerPage); // Let's Children components know they are inside a SidePanel (dialog element) provide(SIDEPANEL_DIALOG_ID_INJECTION_KEY, sidepanelId); if (!props.isDismissible && props.hideCloseButton === null) { deprecate( 'BentoSidepanel "isDismissible" property’s behavior', 'BentoSidepanel "isDismissible" will no longer hide the close button. Use "hideCloseButton=true" instead.', '3.0.0' ); } </script> <script lang="ts"> /** * Sidepanel component is a slide-in panel that should be used for presenting actions, settings or features that are directly associated with a specific task or interaction on the main screen. * * @example * import { BentoSidepanel, BentoSidepanelPage } from '@adyen/bento-vue2'; * * export default { * components: { BentoSidepanel, BentoSidepanelPage }, * template: ` * <bento-sidepanel active-page='step1' is-open='true'> * <bento-sidepanel-page * title='Step 1' * pageId='step1' * :actions="[ * { * title: 'Next step', * event: () => { * activePage.value = 'step2'; * }, * }]"> * Step 1 info * </bento-sidepanel-page> * <bento-sidepanel-page * title='Step 2' * pageId='step2' * :actions="[ * { * title: 'Save', * event: () => {}, * }]"> * Step 2 info * </bento-sidepanel-page> * </bento-sidepanel> * ` * } */ export default { i18n: { messages }, name: 'bento-sidepanel', }; </script> <style lang="scss" scoped src="./sidepanel.scss" />
@@ -1 +1 @@
1
- import { BentoStatusVariant } from './status.types'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import { type Meta, type StoryObj } from '@storybook/vue'; import { isVue2 } from 'vue-demi'; import BentoStatus from './status.vue'; const meta: Meta = { title: 'Status', component: BentoStatus, argTypes: { // Slots default: { name: 'default', type: { name: 'string', required: false }, description: 'Default slot content', control: 'text', table: { type: { summary: 'VNode[]' }, }, }, // Enum props variant: { options: Object.values(BentoStatusVariant), mapping: BentoStatusVariant, control: { type: 'select', }, }, }, }; export default meta; type Story = StoryObj<typeof BentoStatus>; const DEFAULT_TEXT = 'Status'; const defaultCode = ` <bento-status variant="grey"> ${DEFAULT_TEXT} </bento-status> `; export const Default: Story = { render: (_args, { argTypes }) => ({ components: { BentoStatus }, props: Object.keys(argTypes), template: ` <bento-status v-bind="args"> {{args.default}} </bento-status> `, setup(props) { return { args: isVue2 ? props : _args, }; }, }), args: { default: DEFAULT_TEXT, variant: 'grey', }, parameters: storybookDocsParameter(defaultCode), };
1
+ import { BentoStatusVariant } from './status.types'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import { type Meta, type StoryObj } from '@storybook/vue'; import { isVue2 } from 'vue-demi'; import BentoStatus from './status.vue'; const StatusDefaultExample = "<template>\n <bento-status variant=\"grey\">Status</bento-status>\n</template>\n\n<script setup lang=\"ts\">\n import { BentoStatus } from '@adyen/bento-vue2';\n</script>\n"; const meta: Meta = { title: 'Status', component: BentoStatus, argTypes: { // Slots default: { name: 'default', type: { name: 'string', required: false }, description: 'Default slot content', control: 'text', table: { type: { summary: 'VNode[]' }, }, }, // Enum props variant: { options: Object.values(BentoStatusVariant), mapping: BentoStatusVariant, control: { type: 'select', }, }, }, }; export default meta; type Story = StoryObj<typeof BentoStatus>; const DEFAULT_TEXT = 'Status'; export const Default: Story = { render: (_args, { argTypes }) => ({ components: { BentoStatus }, props: Object.keys(argTypes), template: ` <bento-status v-bind="args"> {{args.default}} </bento-status> `, setup(props) { return { args: isVue2 ? props : _args, }; }, }), args: { default: DEFAULT_TEXT, variant: 'grey', }, parameters: storybookDocsParameter(StatusDefaultExample), };
@@ -1 +1 @@
1
- /** * @deprecated Since v2.0.0. Use string literal instead. */ export enum BentoStatusVariant { BLUE = 'blue', GREEN = 'green', GREY = 'grey', ORANGE = 'orange', RED = 'red', YELLOW = 'yellow', } export interface BentoStatusProps { /** * Defines the type and color of the Status */ variant: BentoStatusVariant | `${BentoStatusVariant}`; }
1
+ /** * @deprecated Since v3.0.0. Use string literal instead. */ export enum BentoStatusVariant { BLUE = 'blue', GREEN = 'green', GREY = 'grey', ORANGE = 'orange', RED = 'red', YELLOW = 'yellow', } export interface BentoStatusProps { /** * Defines the type and color of the Status */ variant: BentoStatusVariant | `${BentoStatusVariant}`; }
@@ -1 +1 @@
1
- <template> <li :class="conditionalClasses" class="b-step"> <base-button ref="buttonComponent" :aria-current="ariaCurrentValue" :aria-disabled="ariaDisabledValue" class="b-step__button" type="button" :tabindex="tabIndexValue" :disabled="isDisabled" @click="navigateToStep" @focus="isFocused = true" @blur="isFocused = false" > <template #iconLeft> <bento-typography el="span" variant="body" stronger class="b-step__index" aria-hidden="true"> <checkmark-small-icon v-if="isCompleted" /> <template v-else-if="!isSubstep">{{ index + 1 }}</template> <dot-icon v-else /> </bento-typography> </template> <bento-typography ref="stepContent" el="span" variant="body" :stronger="isActive" class="b-step__content"> <slot></slot> </bento-typography> </base-button> <ul v-show="isSubstepsVisible" ref="substepList" class="b-step__substep-list"> <slot name="substeps"></slot> </ul> </li> </template> <script setup lang="ts"> import { computed, inject, onBeforeUnmount, onMounted, provide, ref, useSlots, watch } from 'vue'; import { BaseButton } from '@/components/internal/base-button'; import { BentoTypography } from '@/components/typography'; import CheckmarkSmallIcon from '@adyen/ui-assets-icons-16/vue/checkmark-small'; import DotIcon from '@adyen/ui-assets-icons-16/vue/dot'; import { useStepRegister } from '../../composables'; import { STEPPER_STATE } from '../../stepper.keys'; import { type BentoStepperState, type BentoStepperStepExposeState, BentoStepperTypeOption, BentoStepperVariantOption, } from '../../stepper.types'; import { type Booleanish } from '@/types/prop-types'; const slots = useSlots(); const props = defineProps({ /** * Completed status. Used on non-linear steppers to indicate if the step is completed. */ completed: { type: Boolean, default: false, }, /** * Active substep index */ substepIndex: { type: Number, default: 0, }, }); const emit = defineEmits<{ /** * Event triggered when substep is updated by the parent step */ (e: 'update:substep-index', index: number): void; }>(); // Element refs const buttonComponent = ref<InstanceType<typeof BaseButton> | null>(null); const stepContent = ref<InstanceType<typeof BentoTypography> | null>(null); const substeps = ref<Array<BentoStepperStepExposeState>>([]); // Injects parent BentoStepper state data const stepper = inject<BentoStepperState>(STEPPER_STATE); const buttonElement = computed(() => buttonComponent.value?.$el as HTMLButtonElement); const index = computed(() => stepper?.value.steps.indexOf(buttonElement.value)); const stepContentValue = computed(() => stepContent.value?.$el.textContent); // Substep logic const substepsButtonElements = computed(() => substeps.value.map(({ buttonElement }) => buttonElement)); const activeSubStepIndex = ref(props.substepIndex); const latestActiveSubStepIndex = ref(activeSubStepIndex.value); const navigateToSubstep = (value: number) => { if (value > latestActiveSubStepIndex.value) { latestActiveSubStepIndex.value = value; } activeSubStepIndex.value = value; }; const { registerStep, removeStep } = useStepRegister(substeps); const stepState: BentoStepperState = ref({ activeStepIndex: activeSubStepIndex, latestActiveStep: latestActiveSubStepIndex, type: stepper.value.type, variant: stepper.value.variant, steps: substepsButtonElements, isParentStep: true, navigateToStep: navigateToSubstep, registerStep, removeStep, }); provide(STEPPER_STATE, stepState); watch(() => props.substepIndex, navigateToSubstep); watch(activeSubStepIndex, value => { emit('update:substep-index', value); }); onMounted(() => { if (!stepper) { throw new Error( 'BentoStep components should only be used inside BentoStepper or other BentoStep components.' ); } stepper.value.registerStep({ buttonElement, stepContent: stepContentValue, substeps, }); }); onBeforeUnmount(() => { stepper.value.removeStep({ buttonElement, stepContent: stepContentValue, substeps, }); }); // Step states const isSubstep = computed(() => stepper.value.isParentStep); const isFocused = ref(false); const isActive = computed(() => stepper?.value.activeStepIndex === index.value); const isSubstepsVisible = computed( () => isActive.value && stepper.value.variant !== BentoStepperVariantOption.HORIZONTAL && !isSubstep.value && slots.substeps ); const isCompleted = computed(() => { if (stepper?.value.type === BentoStepperTypeOption.NON_LINEAR) { return props.completed; } return stepper?.value.latestActiveStep > index.value; }); const isDisabled = computed( () => stepper?.value.type === BentoStepperTypeOption.LINEAR && index.value > stepper?.value.latestActiveStep ); const navigateToStep = () => { if (isDisabled.value) { return; } stepper.value.navigateToStep(index.value); }; // Styling and a11y const ariaCurrentValue = computed(() => (isActive.value ? 'step' : ('false' as Booleanish))); const ariaDisabledValue = computed(() => isDisabled.value.toString() as Booleanish); const tabIndexValue = computed(() => (isFocused.value || (index.value === 0 && !isSubstep.value) ? '0' : '-1')); const conditionalClasses = computed(() => ({ 'b-step--active': isActive.value, 'b-step--completed': isCompleted.value, 'b-step--substep': isSubstep.value, })); </script> <script lang="ts"> /** * Steps are components placed inside BentoSteppers to break down complex processes * * @example * import { BentoStep } from '@adyen/bento-vue2'; * * export default { * components: { BentoStep }, * template: ` * <bento-stepper> * <bento-step>Step 1</bento-step> * <bento-step> * Step 2 * <template #substeps> * <bento-step>Substep 1</bento-step> * <bento-step>Substep 2</bento-step> * </template> * </bento-step> * </bento-stepper> * ` * } */ export default { name: 'step', }; </script> <style lang="scss" scoped src="./step.scss" />
1
+ <template> <li :class="conditionalClasses" class="b-step"> <base-button ref="buttonComponent" :aria-current="ariaCurrentValue" :aria-disabled="ariaDisabledValue" class="b-step__button" type="button" :tabindex="tabIndexValue" :disabled="isDisabled" @click="navigateToStep" @focus="isFocused = true" @blur="isFocused = false" > <template #iconLeft> <bento-typography el="span" variant="caption" stronger class="b-step__index" aria-hidden="true"> <checkmark-small-icon v-if="isCompleted" /> <template v-else-if="!isSubstep">{{ index + 1 }}</template> <dot-icon v-else /> </bento-typography> </template> <bento-typography ref="stepContent" el="span" variant="body" :stronger="isActive" class="b-step__content"> <slot></slot> </bento-typography> </base-button> <ul v-show="isSubstepsVisible" ref="substepList" class="b-step__substep-list"> <slot name="substeps"></slot> </ul> </li> </template> <script setup lang="ts"> import { computed, inject, onBeforeUnmount, onMounted, provide, ref, useSlots, watch } from 'vue'; import { BaseButton } from '@/components/internal/base-button'; import { BentoTypography } from '@/components/typography'; import CheckmarkSmallIcon from '@adyen/ui-assets-icons-16/vue/checkmark-small'; import DotIcon from '@adyen/ui-assets-icons-16/vue/dot'; import { useStepRegister } from '../../composables'; import { STEPPER_STATE } from '../../stepper.keys'; import { type BentoStepperState, type BentoStepperStepExposeState, BentoStepperTypeOption, BentoStepperVariantOption, } from '../../stepper.types'; import { type Booleanish } from '@/types/prop-types'; const slots = useSlots(); const props = defineProps({ /** * Completed status. Used on non-linear steppers to indicate if the step is completed. */ completed: { type: Boolean, default: false, }, /** * Active substep index */ substepIndex: { type: Number, default: 0, }, }); const emit = defineEmits<{ /** * Event triggered when substep is updated by the parent step */ (e: 'update:substep-index', index: number): void; }>(); // Element refs const buttonComponent = ref<InstanceType<typeof BaseButton> | null>(null); const stepContent = ref<InstanceType<typeof BentoTypography> | null>(null); const substeps = ref<Array<BentoStepperStepExposeState>>([]); // Injects parent BentoStepper state data const stepper = inject<BentoStepperState>(STEPPER_STATE); const buttonElement = computed(() => buttonComponent.value?.$el as HTMLButtonElement); const index = computed(() => stepper?.value.steps.indexOf(buttonElement.value)); const stepContentValue = computed(() => stepContent.value?.$el.textContent); // Substep logic const substepsButtonElements = computed(() => substeps.value.map(({ buttonElement }) => buttonElement)); const activeSubStepIndex = ref(props.substepIndex); const latestActiveSubStepIndex = ref(activeSubStepIndex.value); const navigateToSubstep = (value: number) => { if (value > latestActiveSubStepIndex.value) { latestActiveSubStepIndex.value = value; } activeSubStepIndex.value = value; }; const { registerStep, removeStep } = useStepRegister(substeps); const stepState: BentoStepperState = ref({ activeStepIndex: activeSubStepIndex, latestActiveStep: latestActiveSubStepIndex, type: stepper.value.type, variant: stepper.value.variant, steps: substepsButtonElements, isParentStep: true, navigateToStep: navigateToSubstep, registerStep, removeStep, }); provide(STEPPER_STATE, stepState); watch(() => props.substepIndex, navigateToSubstep); watch(activeSubStepIndex, value => { emit('update:substep-index', value); }); onMounted(() => { if (!stepper) { throw new Error( 'BentoStep components should only be used inside BentoStepper or other BentoStep components.' ); } stepper.value.registerStep({ buttonElement, stepContent: stepContentValue, substeps, }); }); onBeforeUnmount(() => { stepper.value.removeStep({ buttonElement, stepContent: stepContentValue, substeps, }); }); // Step states const isSubstep = computed(() => stepper.value.isParentStep); const isFocused = ref(false); const isActive = computed(() => stepper?.value.activeStepIndex === index.value); const isSubstepsVisible = computed( () => isActive.value && stepper.value.variant !== BentoStepperVariantOption.HORIZONTAL && !isSubstep.value && slots.substeps ); const isCompleted = computed(() => { if (stepper?.value.type === BentoStepperTypeOption.NON_LINEAR) { return props.completed; } return stepper?.value.latestActiveStep > index.value; }); const isDisabled = computed( () => stepper?.value.type === BentoStepperTypeOption.LINEAR && index.value > stepper?.value.latestActiveStep ); const navigateToStep = () => { if (isDisabled.value) { return; } stepper.value.navigateToStep(index.value); }; // Styling and a11y const ariaCurrentValue = computed(() => (isActive.value ? 'step' : ('false' as Booleanish))); const ariaDisabledValue = computed(() => isDisabled.value.toString() as Booleanish); const tabIndexValue = computed(() => (isFocused.value || (index.value === 0 && !isSubstep.value) ? '0' : '-1')); const conditionalClasses = computed(() => ({ 'b-step--active': isActive.value, 'b-step--completed': isCompleted.value, 'b-step--substep': isSubstep.value, })); </script> <script lang="ts"> /** * Steps are components placed inside BentoSteppers to break down complex processes * * @example * import { BentoStep } from '@adyen/bento-vue2'; * * export default { * components: { BentoStep }, * template: ` * <bento-stepper> * <bento-step>Step 1</bento-step> * <bento-step> * Step 2 * <template #substeps> * <bento-step>Substep 1</bento-step> * <bento-step>Substep 2</bento-step> * </template> * </bento-step> * </bento-stepper> * ` * } */ export default { name: 'step', }; </script> <style lang="scss" scoped src="./step.scss" />
@@ -1 +1 @@
1
- import BentoStepper from './stepper.vue'; import BentoStep from './components/step/step.vue'; import { BentoButton } from '@/components/button'; import { action } from '@storybook/addon-actions'; import { computed, isVue2, ref } from 'vue-demi'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import type { Meta, StoryObj } from '@storybook/vue'; import { BentoStepperTypeOption, BentoStepperVariantOption } from './stepper.types'; import NonLinearStepperSource from './__tests__/non-linear-stepper-example.vue?raw'; import './stepper.stories.scss?module'; const meta: Meta = { title: 'Stepper', component: BentoStepper, argTypes: { // Slots default: { name: 'default', type: { name: 'string', required: false }, description: 'BentoStep components', control: 'text', table: { type: { summary: 'VNode[]' }, }, }, // Enum props type: { options: Object.values(BentoStepperTypeOption), mapping: BentoStepperTypeOption, control: { type: 'select', }, }, variant: { options: Object.values(BentoStepperVariantOption), mapping: BentoStepperVariantOption, control: { type: 'select', }, }, }, }; export default meta; type Story = StoryObj<typeof BentoStepper>; export const Default: Story = { render(_args, { argTypes }) { return { components: { BentoStepper, BentoStep }, props: Object.keys(argTypes), template: ` <bento-stepper v-bind="args" :key="JSON.stringify(args)" @update:index="updateIndex"> <bento-step>Step 1</bento-step> <bento-step>Step 2</bento-step> <bento-step>Step 3</bento-step> <bento-step>Step 4</bento-step> </bento-stepper> `, setup(props) { const updateIndex = (index: number) => action('update:index')(index); return { updateIndex, args: isVue2 ? props : _args, }; }, }; }, args: { index: 2, }, }; Default.parameters = storybookDocsParameter(` <bento-stepper :index="index" @update:index="index = $event"> <bento-step>Step 1</bento-step> <bento-step>Step 2</bento-step> <bento-step>Step 3</bento-step> <bento-step>Step 4</bento-step> </bento-stepper> <div role="status"> A dynamic content such as computed(() => steps[activeIndex]) is needed here in order for the section to be announced by the screen reader on step change </div> `); export const Substeps: Story = { render(_args, { argTypes }) { return { components: { BentoStepper, BentoStep }, props: Object.keys(argTypes), template: ` <bento-stepper :index="index" @update:index="index = $event"> <bento-step>Step 1</bento-step> <bento-step :substep-index="args.substepIndex" @update:substep-index="substepAction"> Step 2 <template #substeps> <bento-step>Substep 1</bento-step> <bento-step>Substep 2</bento-step> <bento-step>Substep 3</bento-step> </template> </bento-step> <bento-step>Step 3</bento-step> </bento-stepper> `, setup(props) { const updateIndex = (index: number) => action('update:index')(index); const substepAction = (index: number) => action('update:substep-index')(index); return { updateIndex, substepAction, args: isVue2 ? props : _args, }; }, }; }, args: { index: 1, substepIndex: 1, }, }; Substeps.parameters = storybookDocsParameter(` <bento-stepper :index="index" @update:index="index = $event"> <bento-step>Step 1</bento-step> <bento-step :substep-index="args.substepIndex" @update:substep-index="substepAction"> Step 2 <template #substeps> <bento-step>Substep 1</bento-step> <bento-step>Substep 2</bento-step> <bento-step>Substep 3</bento-step> </template> </bento-step> <bento-step>Step 3</bento-step> </bento-stepper> <div role="status"> A dynamic content such as computed(() => steps[activeIndex]) is needed here in order for the section to be announced by the screen reader on step change </div> `); export const ConditionalSteps: Story = { render(_args, { argTypes }) { return { components: { BentoStepper, BentoStep, BentoButton }, props: Object.keys(argTypes), template: ` <div class="b-stepper-story" :class="args.variant === 'horizontal' && 'b-stepper-story--horizontal'"> <bento-stepper v-bind="args" :key="JSON.stringify(args)" :style="stepperStyle" @update:index="updateIndex"> <bento-step v-for="(step, index) in steps" :key="step">{{ step }}</bento-step> </bento-stepper> <bento-button @click="toggleSteps">Toggle extra steps</bento-button> </div> `, setup(props) { const updateIndex = (index: number) => action('update:index')(index); const withMiddleSteps = ref(true); const steps = computed(() => [ 'General config', withMiddleSteps.value && 'Online settings', withMiddleSteps.value && 'Offline settings', 'Summary', withMiddleSteps.value && 'Extra: post config', ].filter(Boolean) ); const toggleSteps = () => { withMiddleSteps.value = !withMiddleSteps.value; }; const stepperStyle = computed(() => ({ width: props.variant === 'horizontal' ? 'unset' : '200px' })); return { updateIndex, args: isVue2 ? props : _args, withMiddleSteps, steps, toggleSteps, stepperStyle, }; }, }; }, args: { index: 1, }, }; ConditionalSteps.parameters = storybookDocsParameter(` <bento-stepper :index="index" @update:index="index = $event"> <bento-step v-for="step in steps" :key="step">{{ step }}</bento-step> </bento-stepper> <div role="status"> A dynamic content such as computed(() => steps[activeIndex]) is needed here in order for the section to be announced by the screen reader on step change </div> `); export const NonLinear: Story = { render(_args, { argTypes }) { return { components: { BentoStepper, BentoStep }, props: Object.keys(argTypes), template: ` <bento-stepper :index="activeStep" non-linear @update:index="index => setStep(index)" > <bento-step v-for="(step, index) in steps" :key="index" :completed="completedSteps[index]" > {{ step.title }} </bento-step> </bento-stepper> `, setup(props) { const steps = [{ title: 'Step 1' }, { title: 'Step 2' }, { title: 'Step 3' }, { title: 'Step 4' }]; const activeStep = ref(1); const completedSteps = ref<Record<number, boolean>>({ 0: true, }); const setStep = (index: number) => { action('update:index')(index); completedSteps.value[activeStep.value] = true; activeStep.value = index; }; return { args: isVue2 ? props : _args, steps, activeStep, completedSteps, setStep, }; }, }; }, args: { index: 1, nonLinear: true, }, parameters: storybookDocsParameter(NonLinearStepperSource), };
1
+ import BentoStepper from './stepper.vue'; import BentoStep from './components/step/step.vue'; import { BentoButton } from '@/components/button'; import { action } from '@storybook/addon-actions'; import { computed, isVue2, ref } from 'vue-demi'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import type { Meta, StoryObj } from '@storybook/vue'; import { BentoStepperTypeOption, BentoStepperVariantOption } from './stepper.types'; const ConditionalStepsExample = "<template>\n <div>\n <bento-stepper :index=\"activeIndex\" @update:index=\"activeIndex = $event\">\n <bento-step v-for=\"step in steps\" :key=\"step\">{{ step }}</bento-step>\n </bento-stepper>\n <div role=\"status\">{{ steps[activeIndex] }}</div>\n <bento-button @click=\"withMiddleSteps = !withMiddleSteps\">Toggle extra steps</bento-button>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, ref } from 'vue';\n import { BentoButton, BentoStep, BentoStepper } from '@adyen/bento-vue2';\n\n const activeIndex = ref(1);\n const withMiddleSteps = ref(true);\n const steps = computed(() => [\n 'General config',\n ...(withMiddleSteps.value ? ['Online settings', 'Offline settings'] : []),\n 'Summary',\n ...(withMiddleSteps.value ? ['Extra: post config'] : []),\n ]);\n</script>\n"; const DefaultStepperExample = "<template>\n <div>\n <bento-stepper :index=\"activeIndex\" @update:index=\"activeIndex = $event\">\n <bento-step>Step 1</bento-step>\n <bento-step>Step 2</bento-step>\n <bento-step>Step 3</bento-step>\n <bento-step>Step 4</bento-step>\n </bento-stepper>\n <div role=\"status\">{{ steps[activeIndex] }}</div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import { BentoStep, BentoStepper } from '@adyen/bento-vue2';\n\n const steps = ['Step 1', 'Step 2', 'Step 3', 'Step 4'];\n const activeIndex = ref(2);\n</script>\n"; const NonLinearStepperSource = "<template>\n <bento-stepper :index=\"activeStep\" type=\"non-linear\" @update:index=\"index => setStep(index)\">\n <bento-step v-for=\"(step, index) in steps\" :key=\"index\" :completed=\"completedSteps[index]\">\n {{ step.title }}\n </bento-step>\n </bento-stepper>\n</template>\n\n<script lang=\"ts\" setup>\n import { ref } from 'vue';\n import BentoStepper from '../stepper.vue';\n import BentoStep from '../components/step/step.vue';\n\n const steps = [{ title: 'Step 1' }, { title: 'Step 2' }, { title: 'Step 3' }, { title: 'Step 4' }];\n\n const activeStep = ref(1);\n const completedSteps = ref<Record<number, boolean>>({\n 0: true,\n });\n\n const setStep = (index: number) => {\n completedSteps.value[activeStep.value] = true;\n activeStep.value = index;\n };\n</script>\n"; const SubstepsStepperExample = "<template>\n <div>\n <bento-stepper :index=\"activeIndex\" @update:index=\"activeIndex = $event\">\n <bento-step>Step 1</bento-step>\n <bento-step :substep-index=\"substepIndex\" @update:substep-index=\"substepIndex = $event\">\n Step 2\n <template #substeps>\n <bento-step>Substep 1</bento-step>\n <bento-step>Substep 2</bento-step>\n <bento-step>Substep 3</bento-step>\n </template>\n </bento-step>\n <bento-step>Step 3</bento-step>\n </bento-stepper>\n <div role=\"status\">{{ steps[activeIndex] }}</div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import { BentoStep, BentoStepper } from '@adyen/bento-vue2';\n\n const steps = ['Step 1', 'Step 2', 'Step 3'];\n const activeIndex = ref(1);\n const substepIndex = ref(1);\n</script>\n"; import './stepper.stories.scss?module'; const meta: Meta = { title: 'Stepper', component: BentoStepper, argTypes: { // Slots default: { name: 'default', type: { name: 'string', required: false }, description: 'BentoStep components', control: 'text', table: { type: { summary: 'VNode[]' }, }, }, // Enum props type: { options: Object.values(BentoStepperTypeOption), mapping: BentoStepperTypeOption, control: { type: 'select', }, }, variant: { options: Object.values(BentoStepperVariantOption), mapping: BentoStepperVariantOption, control: { type: 'select', }, }, }, }; export default meta; type Story = StoryObj<typeof BentoStepper>; export const Default: Story = { render(_args, { argTypes }) { return { components: { BentoStepper, BentoStep }, props: Object.keys(argTypes), template: ` <bento-stepper v-bind="args" :key="JSON.stringify(args)" @update:index="updateIndex"> <bento-step>Step 1</bento-step> <bento-step>Step 2</bento-step> <bento-step>Step 3</bento-step> <bento-step>Step 4</bento-step> </bento-stepper> `, setup(props) { const updateIndex = (index: number) => action('update:index')(index); return { updateIndex, args: isVue2 ? props : _args, }; }, }; }, args: { index: 2, }, }; Default.parameters = storybookDocsParameter(DefaultStepperExample); export const Substeps: Story = { render(_args, { argTypes }) { return { components: { BentoStepper, BentoStep }, props: Object.keys(argTypes), template: ` <bento-stepper :index="index" @update:index="index = $event"> <bento-step>Step 1</bento-step> <bento-step :substep-index="args.substepIndex" @update:substep-index="substepAction"> Step 2 <template #substeps> <bento-step>Substep 1</bento-step> <bento-step>Substep 2</bento-step> <bento-step>Substep 3</bento-step> </template> </bento-step> <bento-step>Step 3</bento-step> </bento-stepper> `, setup(props) { const updateIndex = (index: number) => action('update:index')(index); const substepAction = (index: number) => action('update:substep-index')(index); return { updateIndex, substepAction, args: isVue2 ? props : _args, }; }, }; }, args: { index: 1, substepIndex: 1, }, }; Substeps.parameters = storybookDocsParameter(SubstepsStepperExample); export const ConditionalSteps: Story = { render(_args, { argTypes }) { return { components: { BentoStepper, BentoStep, BentoButton }, props: Object.keys(argTypes), template: ` <div class="b-stepper-story" :class="args.variant === 'horizontal' && 'b-stepper-story--horizontal'"> <bento-stepper v-bind="args" :key="JSON.stringify(args)" :style="stepperStyle" @update:index="updateIndex"> <bento-step v-for="(step, index) in steps" :key="step">{{ step }}</bento-step> </bento-stepper> <bento-button @click="toggleSteps">Toggle extra steps</bento-button> </div> `, setup(props) { const updateIndex = (index: number) => action('update:index')(index); const withMiddleSteps = ref(true); const steps = computed(() => [ 'General config', withMiddleSteps.value && 'Online settings', withMiddleSteps.value && 'Offline settings', 'Summary', withMiddleSteps.value && 'Extra: post config', ].filter(Boolean) ); const toggleSteps = () => { withMiddleSteps.value = !withMiddleSteps.value; }; const stepperStyle = computed(() => ({ width: props.variant === 'horizontal' ? 'unset' : '200px' })); return { updateIndex, args: isVue2 ? props : _args, withMiddleSteps, steps, toggleSteps, stepperStyle, }; }, }; }, args: { index: 1, }, }; ConditionalSteps.parameters = storybookDocsParameter(ConditionalStepsExample); export const NonLinear: Story = { render(_args, { argTypes }) { return { components: { BentoStepper, BentoStep }, props: Object.keys(argTypes), template: ` <bento-stepper :index="activeStep" non-linear @update:index="index => setStep(index)" > <bento-step v-for="(step, index) in steps" :key="index" :completed="completedSteps[index]" > {{ step.title }} </bento-step> </bento-stepper> `, setup(props) { const steps = [{ title: 'Step 1' }, { title: 'Step 2' }, { title: 'Step 3' }, { title: 'Step 4' }]; const activeStep = ref(1); const completedSteps = ref<Record<number, boolean>>({ 0: true, }); const setStep = (index: number) => { action('update:index')(index); completedSteps.value[activeStep.value] = true; activeStep.value = index; }; return { args: isVue2 ? props : _args, steps, activeStep, completedSteps, setStep, }; }, }; }, args: { index: 1, nonLinear: true, }, parameters: storybookDocsParameter(NonLinearStepperSource), };
@@ -1 +1 @@
1
- <template> <nav class="b-stepper"> <ol v-bento-keyboard-navigation-directive class="b-stepper__list" :class="conditionalClasses" v-on="keyboardNavigationListeners" > <slot></slot> </ol> <bento-typography el="span" variant="body" stronger class="b-stepper__text-stepper" >{{ t('step', { currentIndex: n(activeStepIndex + 1), totalSteps: n(stepsAmount), content: currentStepContent, }) }} </bento-typography> </nav> </template> <script setup lang="ts"> import { BentoTypography } from '@/components/typography'; import { computed, type DeepReadonly, type PropType, provide, readonly, ref, watch } from 'vue'; import { BentoKeyboardNavigationDirective as vBentoKeyboardNavigationDirective } from '@/directives'; import { useKeyboardNavigation, useStepRegister } from './composables'; import { useI18n } from '@/utils/ts/i18n'; import { STEPPER_STATE } from './stepper.keys'; import { type BentoStepperState, type BentoStepperStepExposeState, type BentoStepperTypeOption, BentoStepperVariantOption, } from './stepper.types'; import messages from './messages.json'; const props = defineProps({ /** * Type of stepper; defines how the stepper should behave. Default: linear * @values linear, non-linear */ type: { type: String as PropType<`${BentoStepperTypeOption}`>, default: 'linear', }, /** * Stepper variant; defines how the stepper should be displayed. Default: vertical * @values vertical, horizontal */ variant: { type: String as PropType<`${BentoStepperVariantOption}`>, default: 'vertical', }, /** * Active step index */ index: { type: Number, default: 0, }, }); const emit = defineEmits<{ /** * Event triggered when step is updated by the stepper */ (e: 'update:index', index: number): void; }>(); type MessageSchema = (typeof messages)['en-US']; const { t, n } = useI18n<{ message: MessageSchema }>({ messages }); const childrenSteps = ref<Array<BentoStepperStepExposeState>>([]); const activeStepIndex = ref(props.index); const latestActiveStep = ref(activeStepIndex.value); const navigateToStep = (index: number) => { // Stores latest active step index so users can navigate backwards and forwards on linear stepper if (index > latestActiveStep.value) { latestActiveStep.value = index; } activeStepIndex.value = index; }; const currentStepContent = computed(() => childrenSteps.value[activeStepIndex.value]?.stepContent); const stepsAmount = computed(() => childrenSteps.value.length); const childrenStepsElements = computed(() => childrenSteps.value.map(({ buttonElement }) => buttonElement)); const isHorizontalVariant = computed(() => props.variant === BentoStepperVariantOption.HORIZONTAL); // List of all visible steps nested on the stepper, including the substeps of the children steps // Flattening the steps on a single list makes the keyboard navigation easier to be handled const allVisibleStepsElements = computed(() => childrenSteps.value .map(({ buttonElement, substeps }, index) => { const isStepActive = activeStepIndex.value === index; const isSubstepsVisible = !isHorizontalVariant.value && isStepActive; if (!isSubstepsVisible) { return [buttonElement]; } return [buttonElement].concat(substeps.map(step => step.buttonElement)); }) .flat() ); const { registerStep, removeStep } = useStepRegister(childrenSteps); const stepperState: BentoStepperState = ref({ activeStepIndex, latestActiveStep, steps: childrenStepsElements, type: props.type, variant: props.variant, navigateToStep, registerStep, removeStep, }); const conditionalClasses = computed(() => ({ 'b-stepper__list--horizontal': isHorizontalVariant.value, })); watch(() => props.index, navigateToStep); watch(activeStepIndex, index => { emit('update:index', index); }); const keyboardNavigationListeners = useKeyboardNavigation(allVisibleStepsElements); // Provides stepper state to BentoStep children components provide<DeepReadonly<BentoStepperState>>(STEPPER_STATE, readonly(stepperState)); const reset = () => { activeStepIndex.value = 0; latestActiveStep.value = 0; }; defineExpose({ reset, }); </script> <script lang="ts"> /** * Steppers break down complex processes into manageable steps to guide users through a sequential or multi-step process. * * @example * import { BentoStep, BentoStepper } from '@adyen/bento-vue2'; * * export default { * components: { BentoStep, BentoStepper }, * template: ` * <bento-stepper :index="1"> * <bento-step>Step 1</bento-step> * <bento-step>Step 2</bento-step> * <bento-step>Step 3</bento-step> * </bento-stepper> * ` * } */ export default { i18n: { messages }, name: 'stepper', }; </script> <style scoped src="./stepper.scss" />
1
+ <template> <nav class="b-stepper"> <ol v-bento-keyboard-navigation-directive class="b-stepper__list" :class="conditionalClasses" v-on="keyboardNavigationListeners" > <slot></slot> </ol> <bento-typography el="span" variant="body" stronger class="b-stepper__text-stepper" >{{ t('step', { currentIndex: n(activeStepIndex + 1), totalSteps: n(stepsAmount), content: currentStepContent, }) }} </bento-typography> </nav> </template> <script setup lang="ts"> import { BentoTypography } from '@/components/typography'; import { computed, type DeepReadonly, type PropType, provide, readonly, ref, watch } from 'vue'; import { BentoKeyboardNavigationDirective as vBentoKeyboardNavigationDirective } from '@/directives'; import { useKeyboardNavigation, useStepRegister } from './composables'; import { useI18n } from '@/utils/ts/i18n'; import { STEPPER_STATE } from './stepper.keys'; import { type BentoStepperState, type BentoStepperStepExposeState, type BentoStepperTypeOption, BentoStepperVariantOption, } from './stepper.types'; import messages from './messages.json'; const props = defineProps({ /** * Type of stepper; defines how the stepper should behave. Default: linear * @values linear, non-linear */ type: { type: String as PropType<`${BentoStepperTypeOption}`>, default: 'linear', }, /** * Stepper variant; defines how the stepper should be displayed. Default: vertical * @values vertical, horizontal */ variant: { type: String as PropType<`${BentoStepperVariantOption}`>, default: 'vertical', }, /** * Active step index */ index: { type: Number, default: 0, }, }); const emit = defineEmits<{ /** * Event triggered when step is updated by the stepper */ (e: 'update:index', index: number): void; }>(); type MessageSchema = (typeof messages)['en-US']; const { t, n } = useI18n<{ message: MessageSchema }>({ messages }); const childrenSteps = ref<Array<BentoStepperStepExposeState>>([]); const activeStepIndex = ref(props.index); const latestActiveStep = ref(activeStepIndex.value); const navigateToStep = (index: number) => { // Stores latest active step index so users can navigate backwards and forwards on linear stepper if (index > latestActiveStep.value) { latestActiveStep.value = index; } activeStepIndex.value = index; }; const currentStepContent = computed(() => childrenSteps.value[activeStepIndex.value]?.stepContent); const stepsAmount = computed(() => childrenSteps.value.length); const childrenStepsElements = computed(() => childrenSteps.value.map(({ buttonElement }) => buttonElement)); const isHorizontalVariant = computed(() => props.variant === BentoStepperVariantOption.HORIZONTAL); // List of all visible steps nested on the stepper, including the substeps of the children steps // Flattening the steps on a single list makes the keyboard navigation easier to be handled const allVisibleStepsElements = computed(() => childrenSteps.value .map(({ buttonElement, substeps }, index) => { const isStepActive = activeStepIndex.value === index; const isSubstepsVisible = !isHorizontalVariant.value && isStepActive; if (!isSubstepsVisible) { return [buttonElement]; } return [buttonElement].concat(substeps.map(step => step.buttonElement)); }) .flat() ); const { registerStep, removeStep } = useStepRegister(childrenSteps); const stepperState: BentoStepperState = ref({ activeStepIndex, latestActiveStep, steps: childrenStepsElements, type: props.type, variant: props.variant, navigateToStep, registerStep, removeStep, }); const conditionalClasses = computed(() => ({ 'b-stepper__list--horizontal': isHorizontalVariant.value, })); watch(() => props.index, navigateToStep); watch(activeStepIndex, index => { emit('update:index', index); }); const keyboardNavigationListeners = useKeyboardNavigation(allVisibleStepsElements); // Provides stepper state to BentoStep children components provide<DeepReadonly<BentoStepperState>>(STEPPER_STATE, readonly(stepperState)); const reset = () => { activeStepIndex.value = 0; latestActiveStep.value = 0; }; defineExpose({ reset, }); </script> <script lang="ts"> /** * Steppers break down complex processes into manageable steps to guide users through a sequential or multi-step process. * * @example * import { BentoStep, BentoStepper } from '@adyen/bento-vue2'; * * export default { * components: { BentoStep, BentoStepper }, * template: ` * <bento-stepper :index="1"> * <bento-step>Step 1</bento-step> * <bento-step>Step 2</bento-step> * <bento-step>Step 3</bento-step> * </bento-stepper> * ` * } */ export default { i18n: { messages }, name: 'bento-stepper', }; </script> <style scoped src="./stepper.scss" />
@@ -1 +1 @@
1
- import { BentoPaymentMethod } from '@/components/payment-method'; import { BentoStatus } from '@/components/status'; import { BentoCurrency, BentoCurrencyISOCode } from '@/components/currency'; import { BentoCountry, BentoCountryCode } from '@/components/country'; import { BentoTypography } from '@/components/typography'; import { BentoDate, BentoDateFormat } from '@/components/date'; import { BentoLink } from '@/components/link'; import BentoStructuredList from './structured-list.vue'; import BentoStructuredListItem from './components/structered-list-item/structured-list-item.vue'; import type { Meta, StoryObj } from '@storybook/vue'; import { action } from '@storybook/addon-actions'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import { isVue2 } from 'vue-demi'; import { BentoStructuredListLayoutOptions } from './structured-list.types'; import BentoStructuredListDefault from './__tests__/structured-list-default.vue?raw'; const meta: Meta = { title: 'Structured list', component: BentoStructuredList, argTypes: { layout: { options: Object.values(BentoStructuredListLayoutOptions), mapping: BentoStructuredListLayoutOptions, control: { type: 'select', }, }, default: { control: false, table: { type: { summary: 'BentoStructuredListItem[]' }, }, }, }, } as Meta; export default meta; type Story = StoryObj<typeof BentoStructuredList>; export const EverythingBagel: Story = { render: (_args, { argTypes }) => ({ components: { BentoStructuredList, BentoStructuredListItem, BentoPaymentMethod, BentoCurrency, BentoLink, BentoTypography, BentoDate, BentoStatus, BentoCountry, }, props: Object.keys(argTypes), template: ` <bento-structured-list v-bind="args"> <bento-structured-list-item label="Status"> <bento-status variant="green">Approved</bento-status> </bento-structured-list-item> <bento-structured-list-item label="Linked"> <bento-link to="router/path">This is a link</bento-link> </bento-structured-list-item> <bento-structured-list-item label="Amount"> <bento-currency currency="USD" :value="123456" /> </bento-structured-list-item> <bento-structured-list-item label="Funding source"> <bento-typography>Credit</bento-typography> </bento-structured-list-item> <bento-structured-list-item label="Date" label-info="Payment date"> <bento-date :date="new Date('2017-09-25')" :format="BentoDateFormat.SHORT_DATE" /> </bento-structured-list-item> <bento-structured-list-item label="Country/Region"> <bento-country :code="BentoCountryCode.NL" /> </bento-structured-list-item> <bento-structured-list-item label="PSP reference" copy="P1234DBE2435" @copy="copyAction"> <bento-typography>P1234DBE2435</bento-typography> </bento-structured-list-item> <bento-structured-list-item label="Payment method"> <bento-payment-method type="Klarna" label="Klarna" /> </bento-structured-list-item> <bento-structured-list-item label="Shopper" :search="search" search-tooltip="Search in payments list" > <bento-typography>143442642</bento-typography> </bento-structured-list-item> </bento-structured-list> `, setup(props) { const copyAction = value => action('copy')(value); return { BentoCurrencyISOCode, BentoDateFormat, BentoCountryCode, // eslint-disable-next-line @typescript-eslint/no-empty-function search: () => {}, copyAction, dateObject: new Date('2017-09-25'), args: isVue2 ? props : _args, }; }, }), args: { layout: '33-66' }, parameters: storybookDocsParameter(BentoStructuredListDefault), };
1
+ import { BentoPaymentMethod } from '@/components/payment-method'; import { BentoStatus } from '@/components/status'; import { BentoCurrency, BentoCurrencyISOCode } from '@/components/currency'; import { BentoCountry, BentoCountryCode } from '@/components/country'; import { BentoTypography } from '@/components/typography'; import { BentoDate, BentoDateFormat } from '@/components/date'; import { BentoLink } from '@/components/link'; import BentoStructuredList from './structured-list.vue'; import BentoStructuredListItem from './components/structered-list-item/structured-list-item.vue'; import type { Meta, StoryObj } from '@storybook/vue'; import { action } from '@storybook/addon-actions'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import { isVue2 } from 'vue-demi'; import { BentoStructuredListLayoutOptions } from './structured-list.types'; const BentoStructuredListDefault = "<template>\n <bento-structured-list>\n <bento-structured-list-item label=\"Status\">\n <bento-status variant=\"green\">Approved</bento-status>\n </bento-structured-list-item>\n <bento-structured-list-item label=\"Linked\">\n <bento-link to=\"router/path\">This is a link</bento-link>\n </bento-structured-list-item>\n <bento-structured-list-item label=\"Amount\">\n <bento-currency currency=\"USD\" :value=\"123456\" />\n </bento-structured-list-item>\n <bento-structured-list-item label=\"Funding source\">\n <bento-typography>Credit</bento-typography>\n </bento-structured-list-item>\n <bento-structured-list-item label=\"Date\">\n <bento-date :date=\"new Date('2017-09-25')\" />\n </bento-structured-list-item>\n <bento-structured-list-item label=\"Country/Region\">\n <bento-country code=\"NL\" />\n </bento-structured-list-item>\n <bento-structured-list-item label=\"PSP reference\" copy=\"P1234DBE2435\" @copy=\"copyFn\">\n <bento-typography>P1234DBE2435</bento-typography>\n </bento-structured-list-item>\n <bento-structured-list-item label=\"Payment method\">\n <bento-payment-method type=\"Klarna\" label=\"Klarna\" />\n </bento-structured-list-item>\n <bento-structured-list-item label=\"Shopper\" :search=\"searchFn\" search-tooltip=\"Search in payments list\">\n <bento-typography>143442642</bento-typography>\n </bento-structured-list-item>\n </bento-structured-list>\n</template>\n\n<script setup lang=\"ts\">\n import { BentoStructuredList, BentoStructuredListItem } from '@adyen/bento-vue2';\n\n const copyFn = () => {\n // write your copy fn here\n };\n\n const searchFn = () => {\n // write your search fn here\n };\n</script>\n"; const meta: Meta = { title: 'Structured list', component: BentoStructuredList, argTypes: { layout: { options: Object.values(BentoStructuredListLayoutOptions), mapping: BentoStructuredListLayoutOptions, control: { type: 'select', }, }, default: { control: false, table: { type: { summary: 'BentoStructuredListItem[]' }, }, }, }, } as Meta; export default meta; type Story = StoryObj<typeof BentoStructuredList>; export const EverythingBagel: Story = { render: (_args, { argTypes }) => ({ components: { BentoStructuredList, BentoStructuredListItem, BentoPaymentMethod, BentoCurrency, BentoLink, BentoTypography, BentoDate, BentoStatus, BentoCountry, }, props: Object.keys(argTypes), template: ` <bento-structured-list v-bind="args"> <bento-structured-list-item label="Status"> <bento-status variant="green">Approved</bento-status> </bento-structured-list-item> <bento-structured-list-item label="Linked"> <bento-link to="router/path">This is a link</bento-link> </bento-structured-list-item> <bento-structured-list-item label="Amount"> <bento-currency currency="USD" :value="123456" /> </bento-structured-list-item> <bento-structured-list-item label="Funding source"> <bento-typography>Credit</bento-typography> </bento-structured-list-item> <bento-structured-list-item label="Date" label-info="Payment date"> <bento-date :date="new Date('2017-09-25')" :format="BentoDateFormat.SHORT_DATE" /> </bento-structured-list-item> <bento-structured-list-item label="Country/Region"> <bento-country :code="BentoCountryCode.NL" /> </bento-structured-list-item> <bento-structured-list-item label="PSP reference" copy="P1234DBE2435" @copy="copyAction"> <bento-typography>P1234DBE2435</bento-typography> </bento-structured-list-item> <bento-structured-list-item label="Payment method"> <bento-payment-method type="Klarna" label="Klarna" /> </bento-structured-list-item> <bento-structured-list-item label="Shopper" :search="search" search-tooltip="Search in payments list" > <bento-typography>143442642</bento-typography> </bento-structured-list-item> </bento-structured-list> `, setup(props) { const copyAction = value => action('copy')(value); return { BentoCurrencyISOCode, BentoDateFormat, BentoCountryCode, // eslint-disable-next-line @typescript-eslint/no-empty-function search: () => {}, copyAction, dateObject: new Date('2017-09-25'), args: isVue2 ? props : _args, }; }, }), args: { layout: '33-66' }, parameters: storybookDocsParameter(BentoStructuredListDefault), };
@@ -1 +1 @@
1
- <template> <dl class="b-structured-list"> <slot /> </dl> </template> <script setup lang="ts"> import { computed, inject, provide } from 'vue'; import { STRUCTURED_LIST_CONDENSED_INJECTION_KEY, STRUCTURED_LIST_LABELS_WIDTH_INJECTION_KEY, } from '@/components/structured-list/structured-list.keys'; import { BentoStructuredListLayoutOptions } from './structured-list.types'; const props = withDefaults( defineProps<{ /** * Width of the labels container, in pixels. Overrides layout prop. */ labelsWidth?: number; /** * The layout of the label value pair in percentage. * If labelsWidth is set, layout will be overriden by the static pixel value. * * If the value entered is not listed in the example * list below '33-66' will be applied * @example * '25-75' * '33-66' * '42-58' * '50-50' * '75-25' * '66-33' * '58-42' */ layout?: BentoStructuredListLayoutOptions; }>(), { labelsWidth: null, layout: '33-66', } ); const isCondensed = inject(STRUCTURED_LIST_CONDENSED_INJECTION_KEY, false); const computedLayout = computed(() => BentoStructuredListLayoutOptions.includes(props.layout) ? props.layout : '33-66' ); const computedLabelsWidth = computed(() => { if (isCondensed) { return '130px'; } if (props.labelsWidth) { return `${props.labelsWidth}px`; } return `${computedLayout.value.split('-')[0]}%`; }); provide(STRUCTURED_LIST_LABELS_WIDTH_INJECTION_KEY, computedLabelsWidth); </script> <script lang="ts"> /** * This is a list used to display pairs of information in a clear and organized manner. * `BentoStructureListItem` should be used to pass the label/value pairs to the list. * * @example * import { BentoStructuredListItem, BentoStructuredListItem } from '@adyen/bento-vue2'; * * export default { * components: { BentoStructuredList, BentoStructuredListItem }, * template: ` * <bento-structured-list> * <bento-structured-list-item label="Payment"> * <bento-payment-method label="Klarna" type="Klarna" /> * </bento-structured-list-item> * <bento-structured-list-item label="Amount"> * <bento-currency :currency="BentoCurrencyISOCode.USD" :value="123456" /> * </bento-structured-list-item> * </bento-structured-list> * ` * } */ export default {}; </script> <style lang="scss" scoped src="./structured-list.scss" />
1
+ <template> <dl class="b-structured-list"> <slot /> </dl> </template> <script setup lang="ts"> import { computed, inject, provide } from 'vue'; import { STRUCTURED_LIST_CONDENSED_INJECTION_KEY, STRUCTURED_LIST_LABELS_WIDTH_INJECTION_KEY, } from '@/components/structured-list/structured-list.keys'; import { BentoStructuredListLayoutOptions } from './structured-list.types'; const props = withDefaults( defineProps<{ /** * Width of the labels container, in pixels. Overrides layout prop. */ labelsWidth?: number; /** * The layout of the label value pair in percentage. * If labelsWidth is set, layout will be overriden by the static pixel value. * * If the value entered is not listed in the example * list below '33-66' will be applied * @example * '25-75' * '33-66' * '42-58' * '50-50' * '75-25' * '66-33' * '58-42' */ layout?: BentoStructuredListLayoutOptions; }>(), { labelsWidth: null, layout: '33-66', } ); const isCondensed = inject(STRUCTURED_LIST_CONDENSED_INJECTION_KEY, false); const computedLayout = computed(() => BentoStructuredListLayoutOptions.includes(props.layout) ? props.layout : '33-66' ); const computedLabelsWidth = computed(() => { if (isCondensed) { return '130px'; } if (props.labelsWidth) { return `${props.labelsWidth}px`; } return `${computedLayout.value.split('-')[0]}%`; }); provide(STRUCTURED_LIST_LABELS_WIDTH_INJECTION_KEY, computedLabelsWidth); </script> <script lang="ts"> /** * This is a list used to display pairs of information in a clear and organized manner. * `BentoStructureListItem` should be used to pass the label/value pairs to the list. * * @example * import { BentoStructuredListItem, BentoStructuredListItem } from '@adyen/bento-vue2'; * * export default { * components: { BentoStructuredList, BentoStructuredListItem }, * template: ` * <bento-structured-list> * <bento-structured-list-item label="Payment"> * <bento-payment-method label="Klarna" type="Klarna" /> * </bento-structured-list-item> * <bento-structured-list-item label="Amount"> * <bento-currency :currency="BentoCurrencyISOCode.USD" :value="123456" /> * </bento-structured-list-item> * </bento-structured-list> * ` * } */ export default { name: 'bento-structured-list', }; </script> <style lang="scss" scoped src="./structured-list.scss" />