@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.
- package/CHANGELOG.md +36 -0
- package/README.md +24 -2
- package/SKILL.md +37 -7
- package/dist/assets/components/accordion/accordion.stories.ts +1 -1
- package/dist/assets/components/accordion/components/accordion-item.stories.ts +1 -1
- package/dist/assets/components/accordion/components/accordion-item.vue +1 -1
- package/dist/assets/components/action-bar/action-bar.docs.mdx +10 -3
- package/dist/assets/components/action-bar/action-bar.internal.types.ts +1 -0
- package/dist/assets/components/action-bar/action-bar.stories.ts +1 -1
- package/dist/assets/components/action-bar/action-bar.types.ts +1 -1
- package/dist/assets/components/action-bar/action-bar.vue +1 -1
- package/dist/assets/components/ai-tag/ai-tag.stories.ts +1 -1
- package/dist/assets/components/ai-tag/ai-tag.vue +1 -1
- package/dist/assets/components/alert/alert.stories.ts +1 -1
- package/dist/assets/components/alert/alert.types.ts +1 -1
- package/dist/assets/components/anchor-scroller/anchor-scroller.stories.ts +1 -1
- package/dist/assets/components/anchor-scroller/anchor-scroller.vue +1 -1
- package/dist/assets/components/avatar/avatar.internal.types.ts +1 -0
- package/dist/assets/components/avatar/avatar.stories.ts +1 -1
- package/dist/assets/components/avatar/avatar.types.ts +1 -1
- package/dist/assets/components/button/button.docs.mdx +4 -3
- package/dist/assets/components/button/button.stories.ts +1 -1
- package/dist/assets/components/button/button.types.ts +1 -1
- package/dist/assets/components/button/components/ai-button/ai-button.stories.ts +1 -1
- package/dist/assets/components/button/components/ai-button/ai-button.vue +1 -1
- package/dist/assets/components/button/components/button-actions/button-actions.docs.mdx +3 -0
- package/dist/assets/components/button/components/button-actions/button-actions.internal.types.ts +1 -0
- package/dist/assets/components/button/components/button-actions/button-actions.stories.ts +1 -1
- package/dist/assets/components/button/components/button-actions/button-actions.types.ts +1 -1
- package/dist/assets/components/button/components/button-actions/button-actions.vue +1 -1
- package/dist/assets/components/button/components/loading-button/loading-button.docs.mdx +26 -23
- package/dist/assets/components/button/components/loading-button/loading-button.stories.ts +1 -1
- package/dist/assets/components/button/components/loading-button/loading-button.vue +1 -1
- package/dist/assets/components/button/components/toggle-button/toggle-button.stories.ts +1 -1
- package/dist/assets/components/card/card.docs.mdx +18 -1
- package/dist/assets/components/card/card.stories.ts +1 -1
- package/dist/assets/components/card/card.types.ts +1 -1
- package/dist/assets/components/card/card.vue +1 -1
- package/dist/assets/components/checkbox/checkbox.stories.ts +1 -1
- package/dist/assets/components/checkbox/checkbox.types.ts +1 -1
- package/dist/assets/components/checkbox/checkbox.vue +1 -1
- package/dist/assets/components/checkbox/components/checkbox-group/checkbox-group.docs.mdx +9 -14
- package/dist/assets/components/checkbox/components/checkbox-group/checkbox-group.stories.ts +1 -1
- package/dist/assets/components/checkbox/components/checkbox-group/checkbox-group.types.ts +1 -1
- package/dist/assets/components/checkbox/components/checkbox-group/checkbox-group.vue +1 -1
- package/dist/assets/components/chip/chip.stories.ts +1 -1
- package/dist/assets/components/chip/chip.vue +1 -1
- package/dist/assets/components/click-outside/click-outside.stories.ts +1 -1
- package/dist/assets/components/code-snippet/code-snippet.types.ts +1 -1
- package/dist/assets/components/code-snippet/code-snippet.vue +1 -1
- package/dist/assets/components/country/country.stories.ts +1 -1
- package/dist/assets/components/country/country.types.ts +1 -1
- package/dist/assets/components/country/country.vue +1 -1
- package/dist/assets/components/currency/currency.stories.ts +1 -1
- package/dist/assets/components/currency/currency.vue +1 -1
- package/dist/assets/components/dashed-underline/dashed-underline.stories.ts +1 -1
- package/dist/assets/components/data-grid/components/data-grid-cell-actions/data-grid-cell-actions.types.ts +1 -1
- package/dist/assets/components/data-grid/components/data-grid-cell-actions/data-grid-cell-actions.vue +1 -1
- package/dist/assets/components/data-grid/components/data-grid-config-settings/data-grid-config-settings.vue +1 -1
- package/dist/assets/components/data-grid/components/data-grid-row/data-grid-row.vue +1 -1
- package/dist/assets/components/data-grid/components/data-grid-static-icon/data-grid-static-icon.stories.ts +1 -1
- package/dist/assets/components/data-grid/components/data-grid-summary-cell/data-grid-summary-cell.stories.ts +1 -1
- package/dist/assets/components/data-grid/components/data-grid-summary-cell/data-grid-summary-cell.vue +1 -1
- package/dist/assets/components/data-grid/components/data-grid-tag-with-text-cell/data-grid-tag-with-text-cell.stories.ts +1 -1
- package/dist/assets/components/data-grid/components/data-grid-trend-cell/data-grid-trend-cell.stories.ts +1 -1
- package/dist/assets/components/data-grid/components/data-grid-trend-cell/data-grid-trend-cell.vue +1 -1
- package/dist/assets/components/data-grid/data-grid.docs.mdx +3 -60
- package/dist/assets/components/data-grid/data-grid.stories.ts +1 -1
- package/dist/assets/components/data-grid/data-grid.vue +1 -1
- package/dist/assets/components/date/date.stories.ts +1 -1
- package/dist/assets/components/date-picker/date-picker.stories.ts +1 -1
- package/dist/assets/components/date-picker/date-picker.types.ts +1 -1
- package/dist/assets/components/date-picker/date-picker.vue +1 -1
- package/dist/assets/components/date-range-picker/components/date-range-picker-calendar/date-range-picker-calendar.vue +1 -1
- package/dist/assets/components/date-range-picker/components/date-time-input/date-time-input.types.ts +1 -1
- package/dist/assets/components/date-range-picker/components/date-time-input/date-time-input.vue +1 -1
- package/dist/assets/components/date-range-picker/date-range-picker.docs.mdx +31 -6
- package/dist/assets/components/date-range-picker/date-range-picker.stories.ts +1 -1
- package/dist/assets/components/date-range-picker/date-range-picker.types.ts +1 -1
- package/dist/assets/components/date-range-picker/date-range-picker.vue +1 -1
- package/dist/assets/components/date-time-picker/date-time-picker.stories.ts +1 -1
- package/dist/assets/components/date-time-picker/date-time-picker.types.ts +1 -1
- package/dist/assets/components/divider/divider.internal.types.ts +1 -0
- package/dist/assets/components/divider/divider.stories.ts +1 -1
- package/dist/assets/components/divider/divider.types.ts +1 -1
- package/dist/assets/components/divider/divider.vue +1 -1
- package/dist/assets/components/draggable/components/draggable-handle/draggable-handle.stories.ts +1 -1
- package/dist/assets/components/draggable/draggable.stories.ts +1 -1
- package/dist/assets/components/draggable/draggable.vue +1 -1
- package/dist/assets/components/drawer/drawer.stories.ts +1 -1
- package/dist/assets/components/dropdown/components/dropdown-base-textbox/dropdown-base-textbox.internal.types.ts +1 -0
- package/dist/assets/components/dropdown/components/dropdown-base-textbox/dropdown-base-textbox.types.ts +1 -1
- package/dist/assets/components/dropdown/components/dropdown-base-textbox/dropdown-base-textbox.vue +1 -1
- package/dist/assets/components/dropdown/components/dropdown-default-textbox/dropdown-default-textbox.vue +1 -1
- package/dist/assets/components/dropdown/components/dropdown-options-container/dropdown-options-container.vue +1 -1
- package/dist/assets/components/dropdown/components/dropdown-small-textbox/dropdown-small-textbox.vue +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-avatar/dropdown-avatar.stories.ts +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-avatar/dropdown-avatar.types.ts +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-avatar/dropdown-avatar.vue +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-country/dropdown-country.stories.ts +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-country/dropdown-country.types.ts +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-country/dropdown-country.vue +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-currency/dropdown-currency.stories.ts +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-currency/dropdown-currency.types.ts +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-currency/dropdown-currency.vue +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-payment-method/dropdown-payment-method.stories.ts +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-payment-method/dropdown-payment-method.types.ts +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-payment-method/dropdown-payment-method.vue +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-tag/dropdown-tag.stories.ts +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-tag/dropdown-tag.types.ts +1 -1
- package/dist/assets/components/dropdown/components/variants/dropdown-tag/dropdown-tag.vue +1 -1
- package/dist/assets/components/dropdown/dropdown.docs.mdx +4 -40
- package/dist/assets/components/dropdown/dropdown.internal.types.ts +1 -0
- package/dist/assets/components/dropdown/dropdown.stories.ts +1 -1
- package/dist/assets/components/dropdown/dropdown.types.ts +1 -1
- package/dist/assets/components/dropdown/dropdown.vue +1 -1
- package/dist/assets/components/empty-state/empty-state.stories.ts +1 -1
- package/dist/assets/components/empty-state/empty-state.types.ts +1 -1
- package/dist/assets/components/file-uploader/components/file-uploader-file-card/file-uploader-file-card.stories.ts +1 -1
- package/dist/assets/components/file-uploader/components/file-uploader-file-card/file-uploader-file-card.types.ts +1 -1
- package/dist/assets/components/file-uploader/components/file-uploader-file-card/file-uploader-file-card.vue +1 -1
- package/dist/assets/components/file-uploader/components/file-uploader-restrictions/file-uploader-restrictions.types.ts +1 -1
- package/dist/assets/components/file-uploader/components/file-uploader-restrictions/file-uploader-restrictions.vue +1 -1
- package/dist/assets/components/file-uploader/file-uploader.internal.types.ts +1 -0
- package/dist/assets/components/file-uploader/file-uploader.stories.ts +1 -1
- package/dist/assets/components/file-uploader/file-uploader.types.ts +1 -1
- package/dist/assets/components/file-uploader/file-uploader.vue +1 -1
- package/dist/assets/components/filter-bar/components/all-filters-modal/all-filters-modal.stories.ts +1 -1
- package/dist/assets/components/filter-bar/components/all-filters-modal/all-filters-modal.types.ts +1 -1
- package/dist/assets/components/filter-bar/components/all-filters-modal/all-filters-modal.vue +1 -1
- 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
- package/dist/assets/components/filter-bar/components/all-filters-modal/components/all-filters-modal-filter-selection/all-filters-modal-filter-selection.vue +1 -0
- package/dist/assets/components/filter-bar/components/all-filters-modal/components/all-filters-modal-selected-filter/all-filters-modal-selected-filter.vue +1 -0
- package/dist/assets/components/filter-bar/components/base-filter/base-filter.internal.types.ts +1 -0
- package/dist/assets/components/filter-bar/components/base-filter/base-filter.types.ts +1 -1
- package/dist/assets/components/filter-bar/components/base-filter/base-filter.vue +1 -1
- package/dist/assets/components/filter-bar/components/boolean-filter/boolean-filter.vue +1 -1
- package/dist/assets/components/filter-bar/components/date-filter/date-filter.vue +1 -1
- package/dist/assets/components/filter-bar/components/date-range-filter/date-range-filter.vue +1 -1
- package/dist/assets/components/filter-bar/components/input-filter/input-filter.types.ts +1 -1
- package/dist/assets/components/filter-bar/components/input-filter/input-filter.vue +1 -1
- package/dist/assets/components/filter-bar/components/input-with-dropdown-filter/input-with-dropdown-filter.stories.ts +1 -1
- package/dist/assets/components/filter-bar/components/input-with-dropdown-filter/input-with-dropdown-filter.vue +1 -1
- package/dist/assets/components/filter-bar/components/select-filter/components/select-filter-button/select-filter-button.vue +1 -1
- package/dist/assets/components/filter-bar/components/select-filter/select-filter.vue +1 -1
- package/dist/assets/components/filter-bar/components/select-filter/variants/select-avatar-filter/select-avatar-filter.stories.ts +1 -1
- package/dist/assets/components/filter-bar/components/select-filter/variants/select-country-filter/select-country-filter.stories.ts +1 -1
- package/dist/assets/components/filter-bar/components/select-filter/variants/select-country-filter/select-country-filter.vue +1 -1
- package/dist/assets/components/filter-bar/components/toggle-filter/toggle-filter.vue +1 -1
- package/dist/assets/components/filter-bar/filter-bar.docs.mdx +4 -62
- package/dist/assets/components/filter-bar/filter-bar.stories.ts +1 -1
- package/dist/assets/components/filter-bar/filter-bar.types.ts +1 -1
- package/dist/assets/components/filter-bar/filter-bar.vue +1 -1
- package/dist/assets/components/form-layout/form-layout.docs.mdx +0 -23
- package/dist/assets/components/form-layout/form-layout.stories.ts +1 -1
- package/dist/assets/components/header/header.stories.ts +1 -1
- package/dist/assets/components/header/header.types.ts +1 -1
- package/dist/assets/components/header/header.vue +1 -1
- package/dist/assets/components/header-with-views/components/header-with-views-all-views/header-with-views-all-views.vue +1 -1
- package/dist/assets/components/header-with-views/components/header-with-views-item-edit-form/header-with-views-edit-form.types.ts +1 -1
- package/dist/assets/components/header-with-views/components/header-with-views-item-edit-form/header-with-views-edit-form.vue +1 -1
- package/dist/assets/components/header-with-views/header-with-views.internal.types.ts +1 -0
- package/dist/assets/components/header-with-views/header-with-views.stories.ts +1 -1
- package/dist/assets/components/header-with-views/header-with-views.types.ts +1 -1
- package/dist/assets/components/header-with-views/header-with-views.vue +1 -1
- package/dist/assets/components/image/image.stories.ts +1 -1
- package/dist/assets/components/info-icon/info-icon.stories.ts +1 -1
- package/dist/assets/components/input-field/input-field.docs.mdx +1 -13
- package/dist/assets/components/input-field/input-field.stories.ts +1 -1
- package/dist/assets/components/input-field/input-field.types.ts +1 -1
- package/dist/assets/components/input-field/input-field.vue +1 -1
- package/dist/assets/components/input-field-password/input-field-password.internal.types.ts +1 -0
- package/dist/assets/components/input-field-password/input-field-password.stories.ts +1 -1
- package/dist/assets/components/input-field-password/input-field-password.types.ts +1 -1
- package/dist/assets/components/input-field-password/input-field-password.vue +1 -1
- package/dist/assets/components/input-field-phone-number/input-field-phone-number.stories.ts +1 -1
- package/dist/assets/components/input-field-phone-number/input-field-phone-number.types.ts +1 -1
- package/dist/assets/components/input-field-phone-number/input-field-phone-number.vue +1 -1
- package/dist/assets/components/input-time/input-time.docs.mdx +17 -0
- package/dist/assets/components/input-time/input-time.stories.ts +1 -1
- package/dist/assets/components/input-time/input-time.types.ts +1 -1
- package/dist/assets/components/input-time/input-time.vue +1 -1
- package/dist/assets/components/inspector/inspector.stories.ts +1 -1
- package/dist/assets/components/inspector/inspector.vue +1 -1
- package/dist/assets/components/layout/components/layout-row/layout-row.stories.ts +1 -1
- package/dist/assets/components/layout/components/layout-row/layout-row.vue +1 -1
- package/dist/assets/components/layout/layout.docs.mdx +10 -0
- package/dist/assets/components/layout/layout.internal.types.ts +1 -0
- package/dist/assets/components/layout/layout.stories.ts +1 -1
- package/dist/assets/components/layout/layout.types.ts +1 -1
- package/dist/assets/components/link/link.stories.ts +1 -1
- package/dist/assets/components/link/link.types.ts +1 -1
- package/dist/assets/components/link/link.vue +1 -1
- package/dist/assets/components/list/list.stories.ts +1 -1
- package/dist/assets/components/loading-indicator/loading-indicator.stories.ts +1 -1
- package/dist/assets/components/menu/components/menu-item/menu-item.types.ts +1 -1
- package/dist/assets/components/menu/components/menu-item/menu-item.vue +1 -1
- package/dist/assets/components/menu/components/menu-item-list/menu-item-list.vue +1 -1
- package/dist/assets/components/menu/components/sub-menu-item-list/sub-menu-item-list.vue +1 -1
- package/dist/assets/components/menu/menu.docs.mdx +17 -7
- package/dist/assets/components/menu/menu.stories.ts +1 -1
- package/dist/assets/components/menu/menu.types.ts +1 -1
- package/dist/assets/components/menu/menu.vue +1 -1
- package/dist/assets/components/modal/components/base-modal/base-modal.vue +1 -1
- package/dist/assets/components/modal/components/modal-page/modal-page.vue +1 -1
- package/dist/assets/components/modal/modal.internal.types.ts +1 -0
- package/dist/assets/components/modal/modal.stories.ts +1 -1
- package/dist/assets/components/modal/modal.types.ts +1 -1
- package/dist/assets/components/modal/modal.vue +1 -1
- package/dist/assets/components/modal-fullscreen/components/modal-fullscreen-page.vue +1 -1
- package/dist/assets/components/modal-fullscreen/modal-fullscreen.stories.ts +1 -1
- package/dist/assets/components/modal-fullscreen/modal-fullscreen.vue +1 -1
- package/dist/assets/components/navigation-menu/components/navigation-menu-group/navigation-menu-group.internal.types.ts +1 -0
- package/dist/assets/components/navigation-menu/components/navigation-menu-group/navigation-menu-group.types.ts +1 -1
- package/dist/assets/components/navigation-menu/components/navigation-menu-group/navigation-menu-group.vue +1 -1
- package/dist/assets/components/navigation-menu/components/navigation-menu-item/navigation-menu-item.vue +1 -1
- package/dist/assets/components/navigation-menu/navigation-menu.internal.types.ts +1 -0
- package/dist/assets/components/navigation-menu/navigation-menu.stories.ts +1 -1
- package/dist/assets/components/navigation-menu/navigation-menu.types.ts +1 -1
- package/dist/assets/components/navigation-menu/navigation-menu.vue +1 -1
- package/dist/assets/components/pagination/components/pagination-context/pagination-context.vue +1 -1
- package/dist/assets/components/pagination/components/pagination-results-per-page/pagination-results-per-page.vue +1 -1
- package/dist/assets/components/pagination/pagination.stories.ts +1 -1
- package/dist/assets/components/pagination/pagination.types.ts +1 -1
- package/dist/assets/components/pagination/pagination.vue +1 -1
- package/dist/assets/components/payment-method/payment-method.stories.ts +1 -1
- package/dist/assets/components/payment-method/payment-method.types.ts +1 -1
- package/dist/assets/components/popover/popover.docs.mdx +32 -9
- package/dist/assets/components/popover/popover.stories.ts +1 -1
- package/dist/assets/components/popover/popover.types.ts +1 -1
- package/dist/assets/components/popover/popover.vue +1 -1
- package/dist/assets/components/popper-container/popper-container.types.ts +1 -1
- package/dist/assets/components/popper-container/popper-container.vue +1 -1
- package/dist/assets/components/progress-bar/progress-bar.docs.mdx +102 -0
- package/dist/assets/components/progress-bar/progress-bar.stories.ts +1 -0
- package/dist/assets/components/progress-bar/progress-bar.types.ts +1 -0
- package/dist/assets/components/progress-bar/progress-bar.vue +1 -0
- package/dist/assets/components/promo-banner/promo-banner.stories.ts +1 -1
- package/dist/assets/components/promo-banner/promo-banner.types.ts +1 -1
- package/dist/assets/components/promo-banner/promo-banner.vue +1 -1
- package/dist/assets/components/radio-group/components/radio-button/radio-button.vue +1 -1
- package/dist/assets/components/radio-group/radio-group.docs.mdx +1 -6
- package/dist/assets/components/radio-group/radio-group.stories.ts +1 -1
- package/dist/assets/components/radio-group/radio-group.types.ts +1 -1
- package/dist/assets/components/radio-group/radio-group.vue +1 -1
- package/dist/assets/components/rich-text-editor/rich-text-editor.internal.types.ts +1 -0
- package/dist/assets/components/rich-text-editor/rich-text-editor.stories.ts +1 -1
- package/dist/assets/components/rich-text-editor/rich-text-editor.types.ts +1 -1
- package/dist/assets/components/rich-text-editor/rich-text-editor.vue +1 -1
- package/dist/assets/components/search-bar/search-bar.stories.ts +1 -1
- package/dist/assets/components/search-bar/search-bar.vue +1 -1
- package/dist/assets/components/secondary-nav/components/secondary-nav-item/secondary-nav-item.vue +1 -1
- package/dist/assets/components/secondary-nav/secondary-nav.stories.ts +1 -1
- package/dist/assets/components/secondary-nav/secondary-nav.vue +1 -1
- package/dist/assets/components/segmented-control/components/segmented-control-button/segmented-control-button.vue +1 -1
- package/dist/assets/components/segmented-control/segmented-control.stories.ts +1 -1
- package/dist/assets/components/segmented-control/segmented-control.types.ts +1 -1
- package/dist/assets/components/segmented-control/segmented-control.vue +1 -1
- package/dist/assets/components/selection-card/components/selection-card-group/selection-card-group.docs.mdx +12 -13
- package/dist/assets/components/selection-card/components/selection-card-group/selection-card-group.stories.ts +1 -1
- package/dist/assets/components/selection-card/components/selection-card-group/selection-card-group.vue +1 -1
- package/dist/assets/components/selection-card/selection-card.stories.ts +1 -1
- package/dist/assets/components/selection-card/selection-card.types.ts +1 -1
- package/dist/assets/components/selection-card/selection-card.vue +1 -1
- package/dist/assets/components/sidepanel/sidepanel.docs.mdx +1 -1
- package/dist/assets/components/sidepanel/sidepanel.stories.ts +1 -1
- package/dist/assets/components/sidepanel/sidepanel.vue +1 -1
- package/dist/assets/components/status/status.stories.ts +1 -1
- package/dist/assets/components/status/status.types.ts +1 -1
- package/dist/assets/components/stepper/components/step/step.vue +1 -1
- package/dist/assets/components/stepper/stepper.stories.ts +1 -1
- package/dist/assets/components/stepper/stepper.vue +1 -1
- package/dist/assets/components/structured-list/structured-list.stories.ts +1 -1
- package/dist/assets/components/structured-list/structured-list.vue +1 -1
- package/dist/assets/components/summary-grid/components/summary-grid-item/summary-grid-item.types.ts +1 -1
- package/dist/assets/components/summary-grid/summary-grid.stories.ts +1 -1
- package/dist/assets/components/summary-grid/summary-grid.types.ts +1 -1
- package/dist/assets/components/table-of-contents/components/table-of-contents-list/table-of-contents-list.vue +1 -1
- package/dist/assets/components/table-of-contents/table-of-contents.internal.types.ts +1 -0
- package/dist/assets/components/table-of-contents/table-of-contents.stories.ts +1 -1
- package/dist/assets/components/table-of-contents/table-of-contents.types.ts +1 -1
- package/dist/assets/components/table-of-contents/table-of-contents.vue +1 -1
- package/dist/assets/components/tabs/components/tab.internal.types.ts +1 -0
- package/dist/assets/components/tabs/components/tab.types.ts +1 -1
- package/dist/assets/components/tabs/components/tab.vue +1 -1
- package/dist/assets/components/tabs/tabs.stories.ts +1 -1
- package/dist/assets/components/tabs/tabs.vue +1 -1
- package/dist/assets/components/tag/tag.docs.mdx +1 -1
- package/dist/assets/components/tag/tag.stories.ts +1 -1
- package/dist/assets/components/tag/tag.types.ts +1 -1
- package/dist/assets/components/tag/tag.vue +1 -1
- package/dist/assets/components/textarea/textarea.docs.mdx +0 -7
- package/dist/assets/components/textarea/textarea.stories.ts +1 -1
- package/dist/assets/components/textarea/textarea.types.ts +1 -1
- package/dist/assets/components/textarea/textarea.vue +1 -1
- package/dist/assets/components/timeline/components/timeline-item/timeline-item.stories.ts +1 -1
- package/dist/assets/components/timeline/components/timeline-item/timeline-item.vue +1 -1
- package/dist/assets/components/timeline/timeline.docs.mdx +0 -10
- package/dist/assets/components/timeline/timeline.internal.types.ts +1 -0
- package/dist/assets/components/timeline/timeline.stories.ts +1 -1
- package/dist/assets/components/timeline/timeline.types.ts +1 -1
- package/dist/assets/components/timeline/timeline.vue +1 -1
- package/dist/assets/components/toast/components/toast-item/toast-item.vue +1 -1
- package/dist/assets/components/toggle/toggle.stories.ts +1 -1
- package/dist/assets/components/toggle/toggle.types.ts +1 -1
- package/dist/assets/components/toggle/toggle.vue +1 -1
- package/dist/assets/components/tutorial/tutorial.stories.ts +1 -1
- package/dist/assets/components/typography/typography.stories.ts +1 -1
- package/dist/assets/components/typography/typography.types.ts +1 -1
- package/dist/assets/components/typography/typography.vue +1 -1
- package/dist/assets/components.json +1 -0
- package/dist/assets/composables/use-bento-base-filter/index.ts +1 -0
- package/dist/assets/composables/use-bento-base-filter/use-bento-base-filter.ts +1 -0
- package/dist/assets/composables/use-bento-base-filter/utils/index.ts +1 -0
- package/dist/assets/composables/use-bento-base-filter/utils/utils.ts +1 -0
- package/dist/assets/composables/use-bento-currency/index.ts +1 -0
- package/dist/assets/composables/use-bento-currency/use-bento-currency.stories.ts +1 -1
- package/dist/assets/composables/use-bento-currency/use-bento-currency.ts +1 -0
- package/dist/assets/composables/use-bento-delayed-hover/index.ts +1 -0
- package/dist/assets/composables/use-bento-delayed-hover/use-bento-delayed-hover.stories.ts +1 -1
- package/dist/assets/composables/use-bento-delayed-hover/use-bento-delayed-hover.ts +1 -0
- package/dist/assets/composables/use-bento-theme/index.ts +1 -0
- package/dist/assets/composables/use-bento-theme/install.ts +1 -1
- package/dist/assets/composables/use-bento-theme/install.types.ts +1 -1
- package/dist/assets/composables/use-bento-theme/use-bento-theme.ts +1 -0
- package/dist/assets/composables/use-bento-toast-controller/index.ts +1 -0
- package/dist/assets/composables/use-bento-toast-controller/toast-stack.ts +1 -0
- package/dist/assets/composables/use-bento-toast-controller/use-bento-toast-controller.ts +1 -0
- package/dist/assets/composables/use-click-outside/index.ts +1 -0
- package/dist/assets/composables/use-click-outside/use-click-outside.stories.ts +1 -1
- package/dist/assets/composables/use-click-outside/use-click-outside.ts +1 -0
- package/dist/assets/composables/use-form-validate/index.ts +1 -0
- package/dist/assets/composables/use-form-validate/use-form.ts +1 -0
- package/dist/assets/composables/use-form-validate/use-form.types.ts +1 -1
- package/dist/assets/composables.json +9 -0
- package/dist/assets/deprecations.md +139 -243
- package/dist/assets/directives/highlight/highlight.stories.ts +1 -1
- package/dist/assets/directives/keyboard-navigation/keyboard-navigation.stories.ts +1 -1
- package/dist/assets/directives/tooltip/tooltip.internal.types.ts +1 -0
- package/dist/assets/directives/tooltip/tooltip.stories.ts +1 -1
- package/dist/assets/directives/tooltip/tooltip.types.ts +1 -1
- package/dist/assets/icons.json +1 -0
- package/dist/assets/index.ts +1 -1
- package/dist/assets/install.ts +1 -1
- package/dist/assets/tailwind/README.md +3 -3
- package/dist/assets/templates/dashboard-template/components/dashboard-section/dashboard-section.stories.ts +1 -1
- package/dist/assets/templates/dashboard-template/dashboard-template.stories.ts +1 -1
- package/dist/assets/templates/data-grid-template/data-grid-template.stories.ts +1 -1
- package/dist/assets/usage.json +81 -80
- package/dist/assets/variables.css +152 -140
- package/dist/main.js +228 -34
- package/package.json +2 -2
- package/dist/assets/components/internal/base-button/base-button.types.ts +0 -1
- package/dist/assets/components/internal/base-button/base-button.vue +0 -1
- package/dist/assets/components/internal/button-actions-with-menu/button-actions-with-menu.stories.ts +0 -1
- package/dist/assets/components/internal/button-actions-with-menu/button-actions-with-menu.types.ts +0 -1
- package/dist/assets/components/internal/button-actions-with-menu/button-actions-with-menu.vue +0 -1
- package/dist/assets/components/internal/calendar/calendar.stories.ts +0 -1
- package/dist/assets/components/internal/calendar/calendar.types.ts +0 -1
- package/dist/assets/components/internal/calendar/calendar.vue +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-month/calendar-month.stories.ts +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-month/calendar-month.types.ts +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-month/calendar-month.vue +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-month/components/calendar-month-day/__test__/calendar-month-day-stub.vue +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-month/components/calendar-month-day/calendar-month-day.stories.ts +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-month/components/calendar-month-day/calendar-month-day.types.ts +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-month/components/calendar-month-day/calendar-month-day.vue +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-month/composables/granular-min-max-date.types.ts +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-year/calendar-year.types.ts +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-year/calendar-year.vue +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-year/components/calendar-year-month/__test__/calendar-year-month-stub.vue +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-year/components/calendar-year-month/calendar-year-month.types.ts +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-year/components/calendar-year-month/calendar-year-month.vue +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-year-selector/calendar-year-selector.types.ts +0 -1
- package/dist/assets/components/internal/calendar/components/calendar-year-selector/calendar-year-selector.vue +0 -1
- package/dist/assets/components/internal/calendar/composables/use-granularity-adjustments.types.ts +0 -1
- package/dist/assets/components/internal/calendar/composables/use-range-pane.types.ts +0 -1
- package/dist/assets/components/internal/checkbox-input/checkbox-input.stories.ts +0 -1
- package/dist/assets/components/internal/checkbox-input/checkbox-input.types.ts +0 -1
- package/dist/assets/components/internal/checkbox-input/checkbox-input.vue +0 -1
- package/dist/assets/components/internal/controls-group/controls-group.vue +0 -1
- package/dist/assets/components/internal/copy/copy.docs.mdx +0 -43
- package/dist/assets/components/internal/copy/copy.stories.ts +0 -1
- package/dist/assets/components/internal/copy/copy.types.ts +0 -1
- package/dist/assets/components/internal/copy/copy.vue +0 -1
- package/dist/assets/components/internal/decorative-checkbox/decorative-checkbox.vue +0 -1
- package/dist/assets/components/internal/dialog-page/dialog-page.types.ts +0 -1
- package/dist/assets/components/internal/dialog-page/dialog-page.vue +0 -1
- package/dist/assets/components/internal/error-message/error-message.vue +0 -1
- package/dist/assets/components/internal/field-label/field-label.vue +0 -1
- package/dist/assets/components/internal/fixed-scroller/fixed-scroller.docs.mdx +0 -21
- package/dist/assets/components/internal/fixed-scroller/fixed-scroller.stories.ts +0 -1
- package/dist/assets/components/internal/fixed-scroller/fixed-scroller.vue +0 -1
- package/dist/assets/components/internal/footer-actions/footer-actions.vue +0 -1
- package/dist/assets/components/internal/grid-layout/grid-layout.types.ts +0 -1
- package/dist/assets/components/internal/grid-layout/grid-layout.vue +0 -1
- package/dist/assets/components/internal/header-meta/header-meta.types.ts +0 -1
- package/dist/assets/components/internal/header-meta/header-meta.vue +0 -1
- package/dist/assets/components/internal/info-icon-with-popover/info-icon-with-popover.vue +0 -1
- package/dist/assets/components/internal/listbox/components/listbox-lazy-load/listbox-lazy-load.types.ts +0 -1
- package/dist/assets/components/internal/listbox/components/listbox-lazy-load/listbox-lazy-load.vue +0 -1
- 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
- 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
- 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
- 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
- package/dist/assets/components/internal/listbox/components/listbox-multi-select/components/listbox-multi-select-options/listbox-multi-select-options.types.ts +0 -1
- package/dist/assets/components/internal/listbox/components/listbox-multi-select/components/listbox-multi-select-options/listbox-multi-select-options.vue +0 -1
- package/dist/assets/components/internal/listbox/components/listbox-multi-select/listbox-multi-select.types.ts +0 -1
- package/dist/assets/components/internal/listbox/components/listbox-multi-select/listbox-multi-select.vue +0 -1
- package/dist/assets/components/internal/listbox/components/listbox-option/listbox-option.vue +0 -1
- package/dist/assets/components/internal/listbox/components/listbox-option-tag/listbox-option-tag.vue +0 -1
- package/dist/assets/components/internal/listbox/components/listbox-single-select/components/listbox-single-select-category/listbox-single-select-category.vue +0 -1
- package/dist/assets/components/internal/listbox/components/listbox-single-select/listbox-single-select.vue +0 -1
- package/dist/assets/components/internal/listbox/components/listbox-single-select-option/listbox-single-select-option.vue +0 -1
- package/dist/assets/components/internal/listbox/listbox.stories.ts +0 -1
- package/dist/assets/components/internal/listbox/listbox.types.ts +0 -1
- package/dist/assets/components/internal/listbox/listbox.vue +0 -1
- package/dist/assets/components/internal/radio-input/radio-input.stories.ts +0 -1
- package/dist/assets/components/internal/radio-input/radio-input.types.ts +0 -1
- package/dist/assets/components/internal/radio-input/radio-input.vue +0 -1
- package/dist/assets/components/internal/teleport/teleport.types.ts +0 -1
- package/dist/assets/components/internal/teleport/teleport.vue +0 -1
- package/dist/assets/components/internal/tooltip/tooltip.test.vue +0 -1
- package/dist/assets/components/internal/tooltip/tooltip.types.ts +0 -1
- package/dist/assets/components/internal/tooltip/tooltip.vue +0 -1
- package/dist/assets/composables/use-form-validate-zod-4/use-form.types.ts +0 -1
- package/dist/assets/composables/use-numeric-input/use-numeric-input.types.ts +0 -1
- package/dist/assets/composables/use-section-navigation-keyboard/use-section-navigation-keyboard.types.ts +0 -1
- package/dist/assets/composables/use-virtual-list/use-virtual-list.types.ts +0 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/blocks';
|
|
2
|
+
import * as ProgressBarStories from './progress-bar.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={ProgressBarStories} />
|
|
5
|
+
|
|
6
|
+
# Progress Bar
|
|
7
|
+
|
|
8
|
+
A progress bar communicates the completion status of a task or process, such as a file upload or a multi-step flow.
|
|
9
|
+
|
|
10
|
+
<Canvas withSource="closed">
|
|
11
|
+
<Story of={ProgressBarStories.Default} />
|
|
12
|
+
</Canvas>
|
|
13
|
+
|
|
14
|
+
## Use Cases
|
|
15
|
+
|
|
16
|
+
Use a progress bar to give feedback about the duration and progression of a process.
|
|
17
|
+
|
|
18
|
+
- Use a determinate progress bar when the completion percentage can be calculated.
|
|
19
|
+
- Use an indeterminate progress bar when the remaining wait time is unknown.
|
|
20
|
+
|
|
21
|
+
## Value
|
|
22
|
+
|
|
23
|
+
The `value` prop sets the current progress as a percentage. Values are clamped between `0` and `100`. The current
|
|
24
|
+
percentage is shown to the right of the label; set `valueVisible` to `false` to hide it.
|
|
25
|
+
|
|
26
|
+
Use the `value` slot to display custom text (for example `3 of 5 files`) in place of the percentage. A `value` is still
|
|
27
|
+
required to fill the bar.
|
|
28
|
+
|
|
29
|
+
The value shown next to the label follows this priority: `valueVisible` (`false` hides it entirely), then `variant`
|
|
30
|
+
(`indeterminate` shows nothing), then the `value` slot, then the percentage. When `valueVisible` is `true` and neither a
|
|
31
|
+
`value` nor a `value` slot is provided, the bar falls back to `indeterminate`.
|
|
32
|
+
|
|
33
|
+
<Canvas withSource="closed">
|
|
34
|
+
<Story of={ProgressBarStories.CustomValue} />
|
|
35
|
+
</Canvas>
|
|
36
|
+
|
|
37
|
+
## Variant
|
|
38
|
+
|
|
39
|
+
The `variant` prop controls how progress is represented:
|
|
40
|
+
|
|
41
|
+
- `determinate` (default) animates the bar to the current `value` and shows a gradient that moves across the fill.
|
|
42
|
+
- `indeterminate` shows a continuously animated bar for when progress cannot be measured.
|
|
43
|
+
- `static` animates from 0% to the current `value` when mounted. Set `staticAnimation` to `false` to render the value
|
|
44
|
+
immediately. It does not show the moving gradient, stop indicator, or success flash.
|
|
45
|
+
|
|
46
|
+
Set `shimmer`, `stopIndicator`, or `successFlash` to `false` to disable the corresponding determinate effect.
|
|
47
|
+
|
|
48
|
+
The moving gradient, indeterminate animation and static animation on load are paused for users who prefer reduced
|
|
49
|
+
motion.
|
|
50
|
+
|
|
51
|
+
## Type
|
|
52
|
+
|
|
53
|
+
The `type` prop sets the color of the indicator to convey status: `default`, `highlight`, `success`, or `critical`.
|
|
54
|
+
|
|
55
|
+
## Error
|
|
56
|
+
|
|
57
|
+
Set the `errorMessage` prop to render an error message below the bar and apply the error styling.
|
|
58
|
+
|
|
59
|
+
## Height
|
|
60
|
+
|
|
61
|
+
The `height` prop adjusts the thickness of the bar: `default`, `small`, or `large`.
|
|
62
|
+
|
|
63
|
+
## Direction
|
|
64
|
+
|
|
65
|
+
The `direction` prop sets the fill origin. Use `reverse` to fill the bar from the opposite end.
|
|
66
|
+
|
|
67
|
+
## Label, description and tooltip
|
|
68
|
+
|
|
69
|
+
Set the `label` prop to render a visible label above the bar. Add supporting `description` text below the bar, and pass
|
|
70
|
+
`tooltipText` to show an info icon next to the label that reveals the message on hover or focus.
|
|
71
|
+
|
|
72
|
+
## Accessibility
|
|
73
|
+
|
|
74
|
+
The progress bar exposes the `progressbar` role together with `aria-valuemin`, `aria-valuemax` and `aria-valuenow` so
|
|
75
|
+
assistive technologies can announce the current progress. The `aria-valuenow` attribute is omitted while the progress
|
|
76
|
+
bar is `indeterminate`. When a `label` is set it names the progress bar through `aria-labelledby`, while the
|
|
77
|
+
`description` and `errorMessage` are linked through `aria-describedby`.
|
|
78
|
+
|
|
79
|
+
### Live announcements
|
|
80
|
+
|
|
81
|
+
Screen readers do not reliably announce `progressbar` value changes unless the bar is focused, so completion is surfaced
|
|
82
|
+
through a visually hidden polite live region (`role="status"`) when a `determinate` bar's value crosses into 100. It
|
|
83
|
+
announces a localised _"Complete"_ by default; use `completionAnnouncement` to provide a custom message (e.g. _"Upload
|
|
84
|
+
complete"_).
|
|
85
|
+
|
|
86
|
+
The `errorMessage` is rendered in its own polite live region, so failures are announced when they appear even when focus
|
|
87
|
+
is elsewhere.
|
|
88
|
+
|
|
89
|
+
### Roles, states and properties
|
|
90
|
+
|
|
91
|
+
| ARIA attribute | is automatic? | fallback used | manual override |
|
|
92
|
+
| ------------------ | --------------------------------------------------------------------------------------------------- | -------------------- | ------------------------ |
|
|
93
|
+
| `role` | Yes, the `progressbar` role is set on the bar element. | - | - |
|
|
94
|
+
| `aria-valuenow` | Yes, it reflects the current value and is removed when the component is indeterminate. | - | - |
|
|
95
|
+
| `aria-labelledby` | Yes, it links the bar to the `label` when one is provided. | - | - |
|
|
96
|
+
| `aria-describedby` | Yes, it links the bar to the `description` and `errorMessage` when provided. | - | - |
|
|
97
|
+
| `role="status"` | Yes, a polite live region announces completion. Customise the message via `completionAnnouncement`. | Localised "Complete" | `completionAnnouncement` |
|
|
98
|
+
| `aria-live` | Yes, the `errorMessage` is announced through its own polite live region when it appears. | - | - |
|
|
99
|
+
|
|
100
|
+
## Resources
|
|
101
|
+
|
|
102
|
+
- [WAI-ARIA progressbar role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/progressbar_role)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import BentoProgressBar from './progress-bar.vue'; import { BentoTypography } from '@/components/typography'; import type { Meta, StoryObj } from '@storybook/vue'; import { isVue2 } from 'vue-demi'; import { storybookDocsParameter } from '@/utils/ts/storybook'; const ProgressBarDefaultExample = "<template>\n <bento-progress-bar\n :value=\"40\"\n label=\"Uploading files\"\n description=\"This may take a few moments\"\n tooltip-text=\"Only PDF files are supported\"\n />\n</template>\n\n<script setup lang=\"ts\">\n import { BentoProgressBar } from '@adyen/bento-vue2';\n</script>\n"; const ProgressBarCustomValueExample = "<template>\n <bento-progress-bar :value=\"60\" label=\"Uploading supporting documents\">\n <template #value>\n <bento-typography el=\"span\" strongest>2.4 MB</bento-typography>\n <bento-typography el=\"span\"> of 10 MB uploaded</bento-typography>\n </template>\n </bento-progress-bar>\n</template>\n\n<script setup lang=\"ts\">\n import { BentoProgressBar, BentoTypography } from '@adyen/bento-vue2';\n</script>\n"; import { BentoProgressBarDirectionOptions, BentoProgressBarHeightOptions, BentoProgressBarTypeOptions, BentoProgressBarVariantOptions, } from './progress-bar.types'; const meta: Meta = { title: 'Progress Bar', component: BentoProgressBar, parameters: { layout: 'padded', }, argTypes: { value: { control: { type: 'range', min: 0, max: 100, step: 1 }, }, variant: { control: { type: 'select' }, options: BentoProgressBarVariantOptions, }, type: { control: { type: 'select' }, options: BentoProgressBarTypeOptions, }, height: { control: { type: 'select' }, options: BentoProgressBarHeightOptions, }, direction: { control: { type: 'select' }, options: BentoProgressBarDirectionOptions, }, }, }; export default meta; type Story = StoryObj<typeof BentoProgressBar>; const render: Story['render'] = (_args, { argTypes }) => ({ components: { BentoProgressBar }, props: Object.keys(argTypes), setup(props) { return { args: isVue2 ? props : _args, }; }, template: `<bento-progress-bar v-bind="args" />`, }); export const Default: Story = { render, args: { value: 40, staticAnimation: true, shimmer: true, stopIndicator: true, successFlash: true, valueVisible: true, label: 'Uploading files', description: 'This may take a few moments', tooltipText: 'Only PDF files are supported', }, parameters: storybookDocsParameter(ProgressBarDefaultExample), }; export const CustomValue: Story = { render: (_args, { argTypes }) => ({ components: { BentoProgressBar, BentoTypography }, props: Object.keys(argTypes), setup(props) { return { args: isVue2 ? props : _args, }; }, template: ` <bento-progress-bar v-bind="args"> <template #value> <bento-typography el="span" strongest>2.4 MB</bento-typography> <bento-typography el="span"> of 10 MB uploaded</bento-typography> </template> </bento-progress-bar> `, }), args: { value: 60, label: 'Uploading supporting documents', }, parameters: storybookDocsParameter(ProgressBarCustomValueExample), };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const BentoProgressBarDirectionOptions = ['default', 'reverse'] as const; export const BentoProgressBarHeightOptions = ['default', 'small', 'large'] as const; export const BentoProgressBarTypeOptions = ['default', 'highlight', 'success', 'critical'] as const; export const BentoProgressBarVariantOptions = ['determinate', 'indeterminate', 'static'] as const; export type BentoProgressBarDirection = (typeof BentoProgressBarDirectionOptions)[number]; export type BentoProgressBarHeight = (typeof BentoProgressBarHeightOptions)[number]; export type BentoProgressBarType = (typeof BentoProgressBarTypeOptions)[number]; export type BentoProgressBarVariant = (typeof BentoProgressBarVariantOptions)[number]; export interface BentoProgressBarProps { /** * Whether the static variant animates from 0% to its value when mounted. */ staticAnimation?: boolean; /** * The message announced to screen readers when a determinate bar reaches 100%. * Defaults to a localized "Complete". */ completionAnnouncement?: string; /** * If set, displays a description text below the progress bar. */ description?: string; /** * Sets the direction in which the bar fills. Use `reverse` to fill from the opposite end. */ direction?: BentoProgressBarDirection; /** * If set, displays an error message below the bar and applies error styling. */ errorMessage?: string; /** * Sets the thickness of the progress bar. */ height?: BentoProgressBarHeight; /** * Whether an animated shimmer overlay plays across the indicator. */ shimmer?: boolean; /** * Whether a stop indicator marks the end of the track (determinate only). */ stopIndicator?: boolean; /** * Whether a green success flash plays when the value reaches 100. */ successFlash?: boolean; /** * Whether the percentage value is shown next to the label. */ valueVisible?: boolean; /** * The text label displayed above the progress bar. */ label?: string; /** * If set, displays an info icon with this tooltip message next to the label. */ tooltipText?: string; /** * Sets the visual style of the progress bar to convey its status. */ type?: BentoProgressBarType; /** * Sets the current value of the progress bar, clamped to the range 0 to 100. */ value?: number; /** * Determines how progress is represented: `determinate` for a known value, * `indeterminate` for an animated bar when progress cannot be determined, and * `static` for a fixed bar. */ variant?: BentoProgressBarVariant; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<template> <div class="b-progress-bar" :class="conditionalClasses"> <div class="b-progress-bar__header"> <field-label v-if="label" :id="labelId" class="b-progress-bar__label" :label="label" :tooltip-text="tooltipText" /> <div v-if="shouldShowValue" class="b-progress-bar__value"> <slot name="value"> <bento-typography el="span" stronger>{{ valueText }}</bento-typography> </slot> </div> </div> <div class="b-progress-bar__track" :class="conditionalTrackClasses" role="progressbar" v-bind="trackA11yAttrs"> <div class="b-progress-bar__track-indicator" :class="conditionalIndicatorClasses" :style="indicatorStyle" @animationend="onIndicatorAnimationEnd" ></div> </div> <error-message v-if="!!errorMessage" :id="errorId" :error-message="errorMessage" class="b-progress-bar__error-message" /> <bento-typography v-if="description" :id="descriptionId" el="span" class="b-progress-bar__description" :class="conditionalDescriptionClasses" > {{ description }} </bento-typography> <div class="b-progress-bar__announcement" role="status" aria-live="polite"> {{ completionMessage }} </div> </div> </template> <script setup lang="ts"> import { computed, ref, useSlots, watch } from 'vue'; import { BentoTypography } from '@/components/typography'; import { ErrorMessage, FieldLabel } from '@/internal'; import { useHasSlot } from '@/composables'; import { generateUid } from '@/utils/ts/generate-uid'; import { useI18n } from '@/utils/ts/i18n'; import { type BentoProgressBarProps } from './progress-bar.types'; import messages from './messages.json'; type MessageSchema = (typeof messages)['en-US']; const { t } = useI18n<{ message: MessageSchema }>({ messages }); const props = withDefaults(defineProps<BentoProgressBarProps>(), { staticAnimation: true, completionAnnouncement: undefined, description: undefined, direction: 'default', errorMessage: undefined, height: 'default', shimmer: true, stopIndicator: true, successFlash: true, valueVisible: true, label: undefined, tooltipText: undefined, type: 'default', value: undefined, variant: 'determinate', }); const slots = useSlots(); const hasSlot = useHasSlot(slots); const labelId = generateUid('progress-bar-label'); const descriptionId = generateUid('progress-bar-description'); const errorId = generateUid('progress-bar-error'); // Value const clampedValue = computed(() => { if (props.value === undefined) { return 0; } return Math.min(Math.max(props.value, 0), 100); }); const valueText = computed(() => `${clampedValue.value}%`); // Success flash, triggered once when the value crosses into 100 const isSuccessFlashing = ref(false); // Screen readers do not reliably announce progressbar value changes, so completion is announced // through a polite live region when the value crosses into 100. const completionMessage = ref(''); watch(clampedValue, (value, previousValue) => { if (props.variant !== 'determinate' || previousValue >= 100 || value < 100) { return; } if (props.successFlash) { isSuccessFlashing.value = true; } completionMessage.value = props.completionAnnouncement ?? t('progressComplete'); }); // Variant state const effectiveVariant = computed(() => { if (props.valueVisible && props.value === undefined && !hasSlot('value')) { return 'indeterminate'; } return props.variant; }); const isIndeterminate = computed(() => effectiveVariant.value === 'indeterminate'); // Display flags const shouldShowValue = computed( () => props.valueVisible && !isIndeterminate.value && (hasSlot('value') || props.value !== undefined) ); const shouldShowError = computed(() => !!props.errorMessage); // Indicator styling const indicatorStyle = computed(() => { if (isIndeterminate.value) { return undefined; } const width = props.direction === 'default' ? `${clampedValue.value}%` : `${100 - clampedValue.value}%`; return { width }; }); // Accessibility const trackA11yAttrs = computed(() => { const describedBy = [props.description ? descriptionId : null, props.errorMessage ? errorId : null].filter(Boolean).join(' ') || undefined; return { 'aria-labelledby': props.label ? labelId : undefined, 'aria-describedby': describedBy, 'aria-busy': isIndeterminate.value || undefined, 'aria-valuemin': isIndeterminate.value ? undefined : 0, 'aria-valuemax': isIndeterminate.value ? undefined : 100, 'aria-valuenow': isIndeterminate.value ? undefined : clampedValue.value, }; }); // Conditional classes const conditionalClasses = computed(() => ({ [`b-progress-bar--${props.height}`]: props.height !== 'default', [`b-progress-bar--${props.type}`]: props.type !== 'default', 'b-progress-bar--error': shouldShowError.value, })); const conditionalTrackClasses = computed(() => ({ 'b-progress-bar__track--reverse': props.direction === 'reverse', 'b-progress-bar__track--with-stop-indicator': props.stopIndicator && effectiveVariant.value === 'determinate', 'b-progress-bar__track--with-success-flash': isSuccessFlashing.value && effectiveVariant.value === 'determinate', })); const conditionalIndicatorClasses = computed(() => ({ 'b-progress-bar__track-indicator--indeterminate': isIndeterminate.value, 'b-progress-bar__track-indicator--static': effectiveVariant.value === 'static', 'b-progress-bar__track-indicator--static-animated': props.staticAnimation && effectiveVariant.value === 'static', 'b-progress-bar__track-indicator--with-shimmer': props.shimmer && !props.errorMessage && effectiveVariant.value === 'determinate', 'b-progress-bar__track-indicator--with-success-flash': isSuccessFlashing.value && effectiveVariant.value === 'determinate', [`b-progress-bar__track-indicator--${props.type}`]: props.type !== 'default', 'b-progress-bar__track-indicator--error': shouldShowError.value, })); const conditionalDescriptionClasses = computed(() => ({ 'b-progress-bar__description--error': !!props.errorMessage, })); const onIndicatorAnimationEnd = (event: AnimationEvent) => { if (event.animationName?.includes('success-flash')) { isSuccessFlashing.value = false; } }; </script> <script lang="ts"> /** * A progress bar communicates the completion status of a task or process. * * @usage * import { BentoProgressBar } from '@adyen/bento-vue2'; * * export default { * components: { BentoProgressBar }, * template: ` * <bento-progress-bar :value="40" label="Uploading files" /> * ` * }; */ export default { name: 'bento-progress-bar', i18n: { messages }, }; </script> <style lang="scss" scoped src="./progress-bar.scss" />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { storybookDocsParameter } from '@/utils/ts/storybook'; import { action } from '@storybook/addon-actions'; import type { Meta, StoryObj } from '@storybook/vue'; import { isVue2 } from 'vue-demi'; import { BentoImageAspectRatio } from '../image'; import { BentoTypography } from '../typography'; import { BentoPromoBannerColor, BentoPromoBannerLayout } from './promo-banner.types'; import BentoPromoBanner from './promo-banner.vue'; const meta: Meta = { title: 'Promo banner', component: BentoPromoBanner, argTypes: { // Slots description: { name: 'description', description: "Provides supplementary information that reinforces the banner's title", table: { type: { summary: 'VNode[]' }, category: 'slots', }, control: { type: 'text', }, }, color: { options: Object.values(BentoPromoBannerColor), mapping: BentoPromoBannerColor, control: { type: 'select', }, }, layout: { options: Object.values(BentoPromoBannerLayout), mapping: BentoPromoBannerLayout, defaultValue: BentoPromoBannerLayout.HORIZONTAL, control: { type: 'select', }, }, // Events dismiss: { table: { type: { summary: '() => void' }, category: 'events', }, control: { disable: true }, }, }, }; export default meta; type Story = StoryObj<typeof BentoPromoBanner>; const DEFAULT_TITLE = 'Title'; const DEFAULT_DESCRIPTION = 'Brief description explaining and giving more information about the title'; const DEFAULT_PROPS = { actions: [ { title: 'Primary', event: () => action('onClick'), }, { title: 'Secondary', event: () => action('onClick'), variant: 'secondary', }, ], color: BentoPromoBannerColor.GREY, description: DEFAULT_DESCRIPTION, image: { src: './16-9.png', alt: '', aspectRatio: BentoImageAspectRatio.P16_9, }, isDismissible: true, layout: 'horizontal', title: DEFAULT_TITLE, };
|
|
1
|
+
import { storybookDocsParameter } from '@/utils/ts/storybook'; import { action } from '@storybook/addon-actions'; import type { Meta, StoryObj } from '@storybook/vue'; import { isVue2 } from 'vue-demi'; import { BentoImageAspectRatio } from '../image'; import { BentoTypography } from '../typography'; import { BentoPromoBannerColor, BentoPromoBannerLayout } from './promo-banner.types'; import BentoPromoBanner from './promo-banner.vue'; const PromoBannerDefaultExample = "<template>\n <bento-promo-banner :actions=\"actions\" color=\"grey\" :image=\"image\" is-dismissible layout=\"horizontal\" title=\"Title\">\n <template #description>\n <bento-typography variant=\"body\">\n Brief description explaining and giving more information about the title\n </bento-typography>\n </template>\n </bento-promo-banner>\n</template>\n\n<script lang=\"ts\" setup>\n import { BentoPromoBanner, BentoTypography } from '@adyen/bento-vue2';\n\n const actions = [\n { title: 'Primary', event: () => true, variant: 'primary' as const },\n { title: 'Secondary', event: () => true, variant: 'secondary' as const },\n ];\n const image = {\n src: './16-9.png',\n alt: '',\n aspectRatio: '16:9' as const,\n };\n</script>\n"; const meta: Meta = { title: 'Promo banner', component: BentoPromoBanner, argTypes: { // Slots description: { name: 'description', description: "Provides supplementary information that reinforces the banner's title", table: { type: { summary: 'VNode[]' }, category: 'slots', }, control: { type: 'text', }, }, color: { options: Object.values(BentoPromoBannerColor), mapping: BentoPromoBannerColor, control: { type: 'select', }, }, layout: { options: Object.values(BentoPromoBannerLayout), mapping: BentoPromoBannerLayout, defaultValue: BentoPromoBannerLayout.HORIZONTAL, control: { type: 'select', }, }, // Events dismiss: { table: { type: { summary: '() => void' }, category: 'events', }, control: { disable: true }, }, }, }; export default meta; type Story = StoryObj<typeof BentoPromoBanner>; const DEFAULT_TITLE = 'Title'; const DEFAULT_DESCRIPTION = 'Brief description explaining and giving more information about the title'; const DEFAULT_PROPS = { actions: [ { title: 'Primary', event: () => action('onClick'), }, { title: 'Secondary', event: () => action('onClick'), variant: 'secondary', }, ], color: BentoPromoBannerColor.GREY, description: DEFAULT_DESCRIPTION, image: { src: './16-9.png', alt: '', aspectRatio: BentoImageAspectRatio.P16_9, }, isDismissible: true, layout: 'horizontal', title: DEFAULT_TITLE, }; export const Default: Story = { render: (_args, { argTypes }) => ({ components: { BentoPromoBanner, BentoTypography }, props: Object.keys(argTypes), template: ` <bento-promo-banner v-bind="args" @dismiss="dismissAction"> <template #description> <bento-typography variant="body"> ${DEFAULT_DESCRIPTION} </bento-typography> </template> </bento-promo-banner> `, setup(props) { return { // Values args: isVue2 ? props : _args, // Events dismissAction: action('dismiss'), }; }, }), args: DEFAULT_PROPS, parameters: storybookDocsParameter(PromoBannerDefaultExample), };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { type BentoButtonActionObject } from '@/components/button'; import { type BentoButtonVariant } from '../button'; import { type BentoImageAspectRatio, type BentoImageProps } from '../image'; export interface BentoPromoBannerProps { /** * List of actions that will be used to render the buttons. * * Each object in the list should have a `title`, an `event` and a `variant`. * * `title`: Button's text. * `event`: Event triggered when clicking the Button. * `variant`: Button's style. * * ``` * [{ * title: 'Primary', * event: () => { ... }, * variant: 'primary' * }, { * title: 'Secondary', * event: () => { ... } * variant: 'secondary' * }] * ``` */ actions?: Array<BentoPromoBannerAction>; /** * Defines the color of banner's background */ color?: `${BentoPromoBannerColor}`; /** * Defines whether the banner has a `Dismiss` button */ isDismissible?: boolean; /** * Defines whether the banner has a `Dismiss` button */ dismissButtonText?: string; /** * Defines the image used in the banner. * * The promotional banner adapts to different container sizes based on the image's `aspect-ratio`. * Only the following `aspect-ratio` values are supported: `16:9`, `2:1`, and `1:1`. * * In Storybook, to verify the image display, update `image.src` and `image.aspectRatio` as follows: * - `./1-1.png` with an aspect ratio of `1:1` * - `./2-1.png` with an aspect ratio of `2:1` * - `./16-9.png` with an aspect ratio of `16:9` */ image: BentoPromoBannerImage; /** * Defines style of the banner. * * The horizontal layout is responsive to the container size and * changes depending on the image aspect ratio. * * The vertical layout remains the same regardless of container size. */ layout?: `${BentoPromoBannerLayout}`; /** * Defines the title text to be shown on the banner */ title: string; } export type BentoPromoBannerImageAspectRatio = `${ | BentoImageAspectRatio.P16_9 | BentoImageAspectRatio.P2_1 | BentoImageAspectRatio.P1_1}`; export type BentoPromoBannerButtonVariant = `${BentoButtonVariant.PRIMARY | BentoButtonVariant.SECONDARY}`; /** * @deprecated Since
|
|
1
|
+
import { type BentoButtonActionObject } from '@/components/button'; import { type BentoButtonVariant } from '../button'; import { type BentoImageAspectRatio, type BentoImageProps } from '../image'; export interface BentoPromoBannerProps { /** * List of actions that will be used to render the buttons. * * Each object in the list should have a `title`, an `event` and a `variant`. * * `title`: Button's text. * `event`: Event triggered when clicking the Button. * `variant`: Button's style. * * ``` * [{ * title: 'Primary', * event: () => { ... }, * variant: 'primary' * }, { * title: 'Secondary', * event: () => { ... } * variant: 'secondary' * }] * ``` */ actions?: Array<BentoPromoBannerAction>; /** * Defines the color of banner's background */ color?: `${BentoPromoBannerColor}`; /** * Defines whether the banner has a `Dismiss` button */ isDismissible?: boolean; /** * Defines whether the banner has a `Dismiss` button */ dismissButtonText?: string; /** * Defines the image used in the banner. * * The promotional banner adapts to different container sizes based on the image's `aspect-ratio`. * Only the following `aspect-ratio` values are supported: `16:9`, `2:1`, and `1:1`. * * In Storybook, to verify the image display, update `image.src` and `image.aspectRatio` as follows: * - `./1-1.png` with an aspect ratio of `1:1` * - `./2-1.png` with an aspect ratio of `2:1` * - `./16-9.png` with an aspect ratio of `16:9` */ image: BentoPromoBannerImage; /** * Defines style of the banner. * * The horizontal layout is responsive to the container size and * changes depending on the image aspect ratio. * * The vertical layout remains the same regardless of container size. */ layout?: `${BentoPromoBannerLayout}`; /** * Defines the title text to be shown on the banner */ title: string; } export type BentoPromoBannerImageAspectRatio = `${ | BentoImageAspectRatio.P16_9 | BentoImageAspectRatio.P2_1 | BentoImageAspectRatio.P1_1}`; export type BentoPromoBannerButtonVariant = `${BentoButtonVariant.PRIMARY | BentoButtonVariant.SECONDARY}`; /** * @deprecated Since v3.0.0. Use `BentoPromoBannerAction` without the generic instead. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars export type BentoPromoBannerAction<IconType = object> = BentoButtonActionObject & { variant: BentoPromoBannerButtonVariant; }; export interface BentoPromoBannerImage { src: BentoImageProps['src']; alt?: BentoImageProps['alt']; aspectRatio: BentoPromoBannerImageAspectRatio; } export enum BentoPromoBannerColor { BLUE = 'blue', GREY = 'grey', GREEN = 'green', } export enum BentoPromoBannerLayout { HORIZONTAL = 'horizontal', VERTICAL = 'vertical', }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<template> <section ref="promoBannerRef" class="b-promo-banner" :class="bannerConditionalClass" :aria-labelledby="promoBannerTitleId" > <div class="b-promo-banner__content"> <div class="b-promo-banner__content-header"> <bento-typography :id="promoBannerTitleId" variant="title" large> {{ title }} </bento-typography> <slot name="description" /> </div> <div class="b-promo-banner__content-actions"> <template v-if="actions"> <bento-button v-for="(button, index) in actions" :key="index" :variant="button.variant" :critical="button.critical" :disabled="button.disabled" :inverse="button.inverse" :icon-only="button.iconOnly" :link="button.link" @click="button.event" > <template v-if="button.icon || button.iconLeft" #iconLeft> <component :is="button.icon || button.iconLeft" :svg-title="button.title"></component> </template> <template v-if="!isIconOnly(button)" #default> {{ button.title }} </template> <template v-if="button.iconRight" #iconRight> <component :is="button.iconRight" :svg-title="button.title"></component> </template> </bento-button> </template> <bento-button v-if="isDismissible" variant="secondary" @click="emit('dismiss')"> {{ computedDismissButtonText }} </bento-button> </div> </div> <div class="b-promo-banner__image"> <bento-image class="b-promo-banner__image-item" :src="image.src" :alt="image.alt ?? ''" :aspect-ratio="image.aspectRatio" :object-fit="BentoImageObjectFit.CONTAIN" ></bento-image> </div> </section> </template> <script setup lang="ts"> import { useElementSize } from '@vueuse/core'; import { computed, ref } from 'vue'; // Components import { BentoButton, type BentoButtonActionObject } from '@/components/button'; import { BentoImage, BentoImageAspectRatio, BentoImageObjectFit } from '@/components/image'; import { BentoTypography } from '@/components/typography'; import { BentoPromoBannerColor, BentoPromoBannerLayout, type BentoPromoBannerProps } from './promo-banner.types'; // Utils import { useI18n } from '@/utils/ts/i18n'; import { generateUid } from '@/
|
|
1
|
+
<template> <section ref="promoBannerRef" class="b-promo-banner" :class="bannerConditionalClass" :aria-labelledby="promoBannerTitleId" > <div class="b-promo-banner__content"> <div class="b-promo-banner__content-header"> <bento-typography :id="promoBannerTitleId" variant="title" large> {{ title }} </bento-typography> <slot name="description" /> </div> <div class="b-promo-banner__content-actions"> <template v-if="actions"> <bento-button v-for="(button, index) in actions" :key="index" :variant="button.variant" :critical="button.critical" :disabled="button.disabled" :inverse="button.inverse" :icon-only="button.iconOnly" :link="button.link" @click="button.event" > <template v-if="button.icon || button.iconLeft" #iconLeft> <component :is="button.icon || button.iconLeft" :svg-title="button.title"></component> </template> <template v-if="!isIconOnly(button)" #default> {{ button.title }} </template> <template v-if="button.iconRight" #iconRight> <component :is="button.iconRight" :svg-title="button.title"></component> </template> </bento-button> </template> <bento-button v-if="isDismissible" variant="secondary" @click="emit('dismiss')"> {{ computedDismissButtonText }} </bento-button> </div> </div> <div class="b-promo-banner__image"> <bento-image class="b-promo-banner__image-item" :src="image.src" :alt="image.alt ?? ''" :aspect-ratio="image.aspectRatio" :object-fit="BentoImageObjectFit.CONTAIN" ></bento-image> </div> </section> </template> <script setup lang="ts"> import { useElementSize } from '@vueuse/core'; import { computed, ref } from 'vue'; // Components import { BentoButton, type BentoButtonActionObject } from '@/components/button'; import { BentoImage, BentoImageAspectRatio, BentoImageObjectFit } from '@/components/image'; import { BentoTypography } from '@/components/typography'; import { BentoPromoBannerColor, BentoPromoBannerLayout, type BentoPromoBannerProps } from './promo-banner.types'; // Utils import { useI18n } from '@/utils/ts/i18n'; import { generateUid } from '@/utils/ts/generate-uid'; import messages from './messages.json'; type MessageSchema = (typeof messages)['en-US']; const { t } = useI18n<{ message: MessageSchema }>({ messages }); const props = withDefaults(defineProps<BentoPromoBannerProps>(), { actions: null, color: BentoPromoBannerColor.GREY, isDismissible: true, dismissButtonText: null, layout: BentoPromoBannerLayout.HORIZONTAL, }); const emit = defineEmits<{ /** * Emits a dismiss event when dismiss button on the promotional banner is pressed */ (e: 'dismiss'); }>(); const promoBannerRef = ref(null); const promoBannerSize = useElementSize(promoBannerRef); const promoBannerTitleId = generateUid('promoBannerTitle'); const horizontalLayoutBreakpoint = computed(() => { if (props.image.aspectRatio === BentoImageAspectRatio.P16_9) { return 800; } else if (props.image.aspectRatio === BentoImageAspectRatio.P2_1) { return 850; } else if (props.image.aspectRatio === BentoImageAspectRatio.P1_1) { return 623; } return 0; }); const bannerLayoutClass = computed(() => { // only horizontal layout is responsive and, by design, follows the container size if ( props.layout === BentoPromoBannerLayout.HORIZONTAL && promoBannerSize.width.value <= horizontalLayoutBreakpoint.value ) { return BentoPromoBannerLayout.VERTICAL; } return props.layout; }); const bannerConditionalClass = computed(() => [`b-promo-banner--${bannerLayoutClass.value}`, `b-promo-banner--${props.color}`].join(' ') ); const isIconOnly = (button: BentoButtonActionObject) => button.iconOnly && (button.iconLeft || button.iconRight || button.icon); const computedDismissButtonText = computed(() => props.dismissButtonText || t('dismiss')); </script> <script lang="ts"> /** * Promotional Banner highlights important information, announcements, or promotions. * * @example * import { BentoPromoBanner } from '@adyen/bento-vue2'; * * export default { * components: { BentoPromoBanner }, * template: ` * <bento-promo-banner * title="Title" * description="Brief description explaining and giving more information about the title" * :image="{ src: '16-1.png', aspectRatio: '16:9' }" * :actions="[{ title: 'Primary', event: () => {} }]" * > * </bento-promo-banner> * ` * }; */ export default { i18n: { messages }, name: 'bento-promo-banner', }; </script> <style lang="scss" scoped src="./promo-banner.scss" />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<template> <div class="b-radio-button" data-testid="radio-button-container" :class="conditionalClassContainer"> <radio-input :id="radioButtonId" ref="radioInputRef" :aria-label="ariaLabel" :aria-describedby="hasSlot('description') ? descriptionId : ''" :checked="isChecked" :disabled="disabled" :readonly="readonly" :has-error="hasError" :value="value" :model-value="modelValue" :name="name" @update:model-value="onChange" /> <div> <label v-if="hasSlot('default')" :for="radioButtonId" class="b-radio-button__label-container"> <span v-if="hasSlot('default')" class="b-radio-button__primary-label"> <bento-typography class="b-radio-button__label" el="span" variant="body"><slot /></bento-typography> <bento-tag v-if="tag" class="b-radio-button__label-tag" v-bind="tag" /> </span> <bento-typography v-if="hasSlot('default') && hasSlot('description')" :id="descriptionId" class="b-radio-button__description" el="span" variant="body" > <slot name="description"></slot> </bento-typography> </label> <bento-typography v-if="hasSlot('content') && isChecked" class="b-radio-button__content" el="div"> <slot name="content"></slot> </bento-typography> </div> </div> </template> <script setup lang="ts"> import { BentoTag } from '@/components/tag'; import { BentoTypography } from '@/components/typography'; import { RadioInput } from '../../../internal/radio-input'; import { useAriaLabel } from '@/utils/ts/aria-label'; import { generateUid } from '@/
|
|
1
|
+
<template> <div class="b-radio-button" data-testid="radio-button-container" :class="conditionalClassContainer"> <radio-input :id="radioButtonId" ref="radioInputRef" :aria-label="ariaLabel" :aria-describedby="hasSlot('description') ? descriptionId : ''" :checked="isChecked" :disabled="disabled" :readonly="readonly" :has-error="hasError" :value="value" :model-value="modelValue" :name="name" @update:model-value="onChange" /> <div> <label v-if="hasSlot('default')" :for="radioButtonId" class="b-radio-button__label-container"> <span v-if="hasSlot('default')" class="b-radio-button__primary-label"> <bento-typography class="b-radio-button__label" el="span" variant="body"><slot /></bento-typography> <bento-tag v-if="tag" class="b-radio-button__label-tag" v-bind="tag" /> </span> <bento-typography v-if="hasSlot('default') && hasSlot('description')" :id="descriptionId" class="b-radio-button__description" el="span" variant="body" > <slot name="description"></slot> </bento-typography> </label> <bento-typography v-if="hasSlot('content') && isChecked" class="b-radio-button__content" el="div"> <slot name="content"></slot> </bento-typography> </div> </div> </template> <script setup lang="ts"> import { BentoTag } from '@/components/tag'; import { BentoTypography } from '@/components/typography'; import { RadioInput } from '../../../internal/radio-input'; import { useAriaLabel } from '@/utils/ts/aria-label'; import { generateUid } from '@/utils/ts/generate-uid'; import { computed, type ComputedRef, type PropType, ref, toRefs, useSlots } from 'vue'; import { useDefaultSlotValidator, useHasSlot } from '@/composables'; import { BentoRadioButtonStateClass, type BentoRadioButtonTag, type BentoRadioButtonValue, } from './radio-button.types'; import { getSlotText } from '@/utils/ts/get-slot-text'; const slots = useSlots(); const hasSlot = useHasSlot(slots); const props = defineProps({ /** * Disable the radio button (optional) */ disabled: { type: Boolean, default: false }, /** * Shows bento-radio-button in error state (optional) */ hasError: { type: Boolean, default: false }, /** * This property should not be used directly. * It will be used by v-model directive on radio component. */ modelValue: { type: [String, Number] as PropType<BentoRadioButtonValue>, default: null, }, /** * Sets the radio button to readonly (optional) */ readonly: { type: Boolean, default: false }, /** * Sets the properties of the BentoTag component that is placed next to the label. * {@see BentoTag} */ tag: { type: Object as PropType<BentoRadioButtonTag>, default: undefined }, /** * Indicates the value of the input that will be returned when it's checked */ value: { type: [String, Number] as PropType<BentoRadioButtonValue>, required: true, }, /** * Sets the name of the radio input. * Used for differentiating radio groups or accessing input via form submission. */ name: { type: String, default: null, }, }); const emit = defineEmits<{ /** * Emitted when the radio button is clicked. Enables Vue2 "v-model" */ (e: 'input', value: BentoRadioButtonValue); /** * Emitted when the radio button is clicked. Enables Vue3 "v-model" */ (e: 'update:model-value', value: BentoRadioButtonValue); }>(); const { value } = toRefs(props); const radioButtonId = generateUid('bento-radio-button'); const descriptionId = generateUid('description'); const radioInputRef = ref(null); useDefaultSlotValidator('bento-radio-button', slots.default, slots.description); const conditionalClassContainer = computed(() => ({ [`b-radio-button--${BentoRadioButtonStateClass.DISABLED}`]: props.disabled, [`b-radio-button--${BentoRadioButtonStateClass.READONLY}`]: props.readonly, })); const ariaLabel = useAriaLabel({ ariaLabel: getSlotText(slots)('default'), label: value.value as string, }); const isChecked: ComputedRef<boolean> = computed(() => props.value === props.modelValue); const onChange = () => { if (!props.disabled && !props.readonly) { emit('update:model-value', props.value); emit('input', props.value); } }; const focus = () => { radioInputRef.value.focus(); }; defineExpose({ focus, }); </script> <script lang="ts"> /** * Radio buttons are used when two or more options are mutually exclusive, * the user can only select a single option from a list of pre-defined options. * The label tag area is also clickable. * Only to be used internally. * * @example * import { BentoRadioButton } from '@adyen/bento-vue2'; * * export default { * components: { BentoRadioButton }, * template: ` * <bento-radio-button * disabled * value="inputRadio" * model-value.sync="modelValue" * > * Label text * <template #description>Description text below label</template> * <template #content>Content shown when checked</template> * </bento-radio-button> * `, * setup() { * const modelValue = ref('anyValue') * const value = 'option-value' * * return { * modelValue, * value, * } * } * } */ export default { name: 'bento-radio-button', model: { prop: 'modelValue' }, }; </script> <style lang="scss" scoped src="./radio-button.scss" />
|
|
@@ -71,12 +71,7 @@ prop.
|
|
|
71
71
|
|
|
72
72
|
### Error
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
- `errorMessage`: renders all radio buttons with an error state and displays an error message beneath the buttons
|
|
77
|
-
- `hasError`: renders all radio buttons with an error state
|
|
78
|
-
|
|
79
|
-
`hasError` is deprecated and will be removed in the near future, so please use `errorMessage`.
|
|
74
|
+
The `errorMessage` prop renders all radio buttons with an error state and displays an error message beneath the buttons.
|
|
80
75
|
|
|
81
76
|
### Hide Label
|
|
82
77
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import BentoRadioGroup from './radio-group.vue'; import { BentoInputField } from '@/components/input-field'; import { BentoRadioGroupVariant } from './radio-group.types'; import { action } from '@storybook/addon-actions'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import { ref } from 'vue'; import { isVue2 } from 'vue-demi';
|
|
1
|
+
import BentoRadioGroup from './radio-group.vue'; import { BentoInputField } from '@/components/input-field'; import { BentoRadioGroupVariant } from './radio-group.types'; import { action } from '@storybook/addon-actions'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import { ref } from 'vue'; import { isVue2 } from 'vue-demi'; const RadioGroupDefaultExample = "<template>\n <bento-radio-group\n :items=\"items\"\n :model-value=\"selectedValue\"\n label=\"Group label\"\n description=\"Optional description\"\n tooltip-text=\"Tooltip text\"\n @update:model-value=\"selectedValue = $event\"\n />\n</template>\n\n<script lang=\"ts\" setup>\n import { ref } from 'vue';\n import { BentoRadioGroup, type BentoRadioGroupValue } from '@adyen/bento-vue2';\n\n const selectedValue = ref<BentoRadioGroupValue | null>();\n const items = [\n { value: 1, label: 'Label text' },\n { value: 2, label: 'Label text 2', description: 'Descriptive sub label' },\n { value: 3, label: 'Label text readonly', readonly: true },\n ];\n</script>\n"; const RadioGroupSlotsExample = "<template>\n <div>\n <!-- With model-value -->\n <bento-radio-group\n :items=\"ITEMS\"\n :model-value=\"yourModelValueVariable\"\n label=\"Group label\"\n variant=\"vertical\"\n @update:model-value=\"yourUpdateHandler\"\n >\n <template #description>{{ DESCRIPTION_SLOT_TEXT }}</template>\n <template #content>\n <bento-input-field />\n </template>\n </bento-radio-group>\n\n <!-- With v-model Vue2/Vue3 -->\n <bento-radio-group v-model=\"yourModelValueVariable\" :items=\"ITEMS\" label=\"Group label\" variant=\"vertical\">\n <template #description>{{ DESCRIPTION_SLOT_TEXT }}</template>\n <template #content>\n <bento-input-field />\n </template>\n </bento-radio-group>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import { BentoInputField, BentoRadioGroup, type BentoRadioGroupItems } from '@adyen/bento-vue2';\n\n const ITEMS: BentoRadioGroupItems = [\n { value: 1, label: 'Label text' },\n { value: 2, label: 'Label text 2', description: 'Description text' },\n ];\n const DESCRIPTION_SLOT_TEXT = 'Description slot text.';\n\n const yourModelValueVariable = ref<number>(1);\n const yourUpdateHandler = (newValue: number) => {\n yourModelValueVariable.value = newValue;\n };\n</script>\n"; const RadioGroupWithTagExample = "<template>\n <bento-radio-group\n :items=\"items\"\n :model-value=\"selectedValue\"\n label=\"Group label\"\n description=\"Optional description\"\n tooltip-text=\"Tooltip text\"\n @update:model-value=\"selectedValue = $event\"\n />\n</template>\n\n<script lang=\"ts\" setup>\n import { ref } from 'vue';\n import { BentoRadioGroup, type BentoRadioGroupValue } from '@adyen/bento-vue2';\n\n const selectedValue = ref<BentoRadioGroupValue | null>();\n const items = [\n { value: 1, label: 'Label text', tag: { label: 'Recommended' } },\n { value: 2, label: 'Label text 2', description: 'Descriptive sub label' },\n { value: 3, label: 'Label text readonly', readonly: true },\n ];\n</script>\n"; import type { Meta, StoryObj } from '@storybook/vue'; const meta: Meta = { title: 'Radio Group', component: BentoRadioGroup, argTypes: { variant: { options: Object.values(BentoRadioGroupVariant), mapping: BentoRadioGroupVariant, control: { type: 'select', }, }, items: { table: { type: { summary: 'BentoRadioGroupItems' }, }, }, disabled: { control: { type: 'boolean', }, }, 'update:model-value': { name: 'update:model-value', defaultValue: '', description: 'Input event handler.', table: { type: { summary: '(newValue: number | string | null) => void' }, }, control: { disable: true }, }, }, }; export default meta; type Story = StoryObj<typeof BentoRadioGroup>; const RADIO_DEFAULT_LABEL = 'Label text'; const DEFAULT_PROPS = { label: 'Group label', description: 'Optional description', tooltipText: 'Tooltip text', items: [ { value: 1, label: RADIO_DEFAULT_LABEL }, { value: 2, label: `${RADIO_DEFAULT_LABEL} 2`, description: 'Descriptive sub label' }, { value: 3, label: `${RADIO_DEFAULT_LABEL} readonly`, readonly: true }, ], }; export const Default: Story = { render: (_args, { argTypes }) => ({ components: { BentoRadioGroup }, props: Object.keys(argTypes), template: ` <bento-radio-group v-bind="args" :model-value="selectedValue" @update:model-value="clickedAction" /> `, setup(props) { const selectedValue = ref(undefined); const clickedAction = value => { selectedValue.value = value; action('update:model-value')(value); }; return { // Values selectedValue, args: isVue2 ? props : _args, // Events clickedAction, }; }, }), args: { ...DEFAULT_PROPS, }, parameters: storybookDocsParameter(RadioGroupDefaultExample), }; export const Slots: Story = { render: (_args, { argTypes }) => ({ components: { BentoRadioGroup, BentoInputField }, props: Object.keys(argTypes), template: ` <bento-radio-group v-bind="args" :model-value="selectedValue" @update:model-value="clickedAction" > <template #description> Description slot text. </template> <template #content> <bento-input-field /> </template> </bento-radio-group> `, setup(props) { const selectedValue = ref(undefined); const clickedAction = value => { selectedValue.value = value; action('update:model-value')(value); }; return { // Values selectedValue, args: isVue2 ? props : _args, // Events clickedAction, }; }, }), args: { ...DEFAULT_PROPS, }, parameters: storybookDocsParameter(RadioGroupSlotsExample), }; export const WithTag = { ...Default, args: { ...Default.args, items: [ { value: 1, label: RADIO_DEFAULT_LABEL, tag: { label: 'Recommended' } }, { value: 2, label: `${RADIO_DEFAULT_LABEL} 2`, description: 'Descriptive sub label', }, { value: 3, label: `${RADIO_DEFAULT_LABEL} readonly`, readonly: true }, ], }, parameters: storybookDocsParameter(RadioGroupWithTagExample), };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import type { FormField, FormFieldEmits } from '../../types/form-field'; import type { BentoRadioButtonTag, BentoRadioButtonValue } from './components/radio-button'; /** * @deprecated Since
|
|
1
|
+
import type { FormField, FormFieldEmits } from '../../types/form-field'; import type { BentoRadioButtonTag, BentoRadioButtonValue } from './components/radio-button'; /** * @deprecated Since v3.0.0. Use string literal instead. */ export enum BentoRadioGroupVariant { HORIZONTAL = 'horizontal', VERTICAL = 'vertical', } export type BentoRadioGroupValue = BentoRadioButtonValue; export interface BentoRadioGroupItem { value: BentoRadioGroupValue; label: string; description?: string; disabled?: boolean; readonly?: boolean; hasError?: boolean; tag?: BentoRadioButtonTag; } export type BentoRadioGroupItems = Array<BentoRadioGroupItem>; export type BentoRadioGroupEmits = FormFieldEmits<BentoRadioGroupValue>; export interface BentoRadioGroupProps extends FormField { /** * The form id the radio group is associated with. Defaults to null, as a radio group can also be used standalone. * @default null */ formId?: string | null; /** * Shows/hides the group label. * @default null */ hideLabel?: boolean | null; /** * The radio group's items. * Required. */ items: BentoRadioGroupItems; /** * The name associated with the group. Required for accessibility purposes. * Required. */ label: string; /** * Determines the initially selected value of the group. Corresponds to the BentoRadioButtonItem's value. * Defaults to no value selected. * @default null */ modelValue?: BentoRadioGroupValue | null; /** * The radio group's layout. It can be vertical or horizontal. Defaults to vertical. * @default BentoRadioGroupVariant.VERTICAL */ variant?: BentoRadioGroupVariant | `${BentoRadioGroupVariant}`; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<template> <div class="b-radio-group"> <controls-group class="b-radio-group__buttons" :aria-describedby="
|
|
1
|
+
<template> <div class="b-radio-group"> <controls-group class="b-radio-group__buttons" :aria-describedby="shouldShowError ? errorId : ''" :aria-required="required" :component-name="COMPONENT_NAME" :class="conditionalClasses" :description="description" :disabled="disabled" :form="formId" :label="label" :optional="optional" :required="required" :hide-label="hideLabel" :tooltip-text="tooltipText" role="radiogroup" :aria-readonly="isReadOnly" > <bento-radio-button v-for="item in items" ref="radioButton" :key="item.value" :model-value="inputValue" :value="item.value" :disabled="disabled || item.disabled" :readonly="isReadOnly || item.readonly" :has-error="shouldShowError || item.hasError" :tag="item.tag" :name="formId || label" @update:model-value="onUpdateModelValue" > <template #default>{{ item.label }}</template> <template v-if="item.description" #description>{{ item.description }}</template> <template v-if="hasSlot('content') && isVertical" #content> <slot name="content"></slot> </template> </bento-radio-button> <template v-if="hasSlot('description')" #description> <slot name="description" /> </template> </controls-group> <error-message v-if="shouldShowError" :id="errorId" :error-message="errorMessage" class="b-radio-group__error-message" /> </div> </template> <script setup lang="ts"> import { computed, ref, toRef, useSlots, watch } from 'vue'; import { ControlsGroup, ErrorMessage } from '@/components/internal'; import { BentoRadioButton } from './components/radio-button'; import { useHasSlot } from '@/composables'; import { generateUid } from '@/utils/ts/generate-uid'; import { useFormFieldEmits } from '@/utils/ts/form-field/form-field'; import { type BentoRadioGroupEmits, type BentoRadioGroupProps, BentoRadioGroupVariant } from './radio-group.types'; import { useFormLayoutFieldLoading } from '@/composables/use-form-layout-loading/use-form-layout-loading'; /** * The name of the component to be used in the Vue devtools and console warnings. */ const COMPONENT_NAME = 'bento-radio-group'; const slots = useSlots(); const hasSlot = useHasSlot(slots); const emit = defineEmits<BentoRadioGroupEmits>(); const props = withDefaults(defineProps<BentoRadioGroupProps>(), { description: null, disabled: false, errorMessage: null, formId: null, hideLabel: null, modelValue: null, optional: false, readonly: false, required: false, tooltipText: null, variant: BentoRadioGroupVariant.VERTICAL, }); const inputValue = toRef(props, 'modelValue'); const errorId = generateUid('error'); const { isReadOnly } = useFormLayoutFieldLoading(toRef(props, 'readonly')); const { emitValue } = useFormFieldEmits(emit); const radioButton = ref(null); const shouldShowError = computed(() => !props.disabled && !isReadOnly.value && !!props.errorMessage); const conditionalClasses = computed(() => ({ 'b-radio-group__buttons--horizontal': props.variant === BentoRadioGroupVariant.HORIZONTAL, })); // Content slot logic const isVertical = computed(() => props.variant === 'vertical'); const shouldShowSlotError = computed(() => hasSlot('content') && !isVertical?.value); const onUpdateModelValue = value => { emitValue(value); }; watch( shouldShowSlotError, newVal => { if (newVal) { throw new Error('The content slot is only available for the vertical radio group layout'); } }, { immediate: true, } ); const focus = () => { radioButton.value[0].focus(); }; defineExpose({ focus, }); </script> <script lang="ts"> /** * A radio group component should be used whenever it is necessary to use a set of radio buttons * This component conforms to the official WAI-ARIA guidelines for grouping controls: https://www.w3.org/WAI/tutorials/forms/grouping/ * * import { BentoRadioGroup } from '@adyen/bento-vue2/'; * * export default { * components: { BentoRadioGroup }, * template: ` * <bento-radio-group * label="Your group label" * :items="[ * { value: 1, label: 'Your label' }, * { value: 2, label: 'Another label', description: 'Your descriptive sub label' }, * ]" * variant="horizontal" * /> * ` * }; */ export default { name: 'bento-radio-group', model: { prop: 'modelValue', event: 'update:model-value' }, }; </script> <style lang="scss" scoped src="./radio-group.scss" />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const BentoRichTextEditorModeOptions = ['markdown', 'visual'] as const;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { isVue2 } from 'vue-demi'; import { ref, watch } from 'vue'; import { action } from '@storybook/addon-actions'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import BentoRichTextEditor from './rich-text-editor.vue'; import type { Meta, StoryObj } from '@storybook/vue'; const meta: Meta = { title: 'Rich text editor', component: BentoRichTextEditor, argTypes: { mode: { name: 'mode', type: { name: 'string', required: false }, description: 'switch between Markdown or Visual mode', options:
|
|
1
|
+
import { isVue2 } from 'vue-demi'; import { ref, watch } from 'vue'; import { action } from '@storybook/addon-actions'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import BentoRichTextEditor from './rich-text-editor.vue'; const RichTextEditorDefaultExample = "<template>\n <bento-rich-text-editor\n label=\"Label\"\n description=\"Supporting text\"\n :value=\"inputValue\"\n @input=\"inputValue = $event\"\n />\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import { BentoRichTextEditor } from '@adyen/bento-vue2';\n\n const closingScriptTag = ['</', 'script>'].join('');\n const inputValue = ref(`\n# All rendering elements\n\n## Renders a paragraph\nThis is just a plain paragraph\n\n## Renders a table\n| Month | Savings |\n| -------- | ------- |\n| January | $250 |\n| February | $80 |\n| March | $420 |\n\n## Renders a link\n[Adyen.com](https://adyen.com)\n\n## Renders lists\n### An unordered list\n* An unordered\n* List of things\n* To test how it renders\n### An ordered list\n1. An ordered\n2. List of things\n3. To test how it renders\n### A tasks list\n- [ ] a task list item\n- [ ] list syntax required\n\n## Renders html as plain text\n<html>\n<body>\n<p>This is html content</p>\n<script>alert('This should be rendered as text')${closingScriptTag}\n</body>\n</html>\n\n## Renders code\n\\`\\`\\`\ngit status\ngit add\ngit commit\n\\`\\`\\`\n\n## Renders quotes\n> Text that is a quote\n`);\n</script>\n"; const RichTextEditorVisualModeExample = "<template>\n <bento-rich-text-editor\n label=\"Label\"\n description=\"Supporting text\"\n mode=\"visual\"\n :value=\"inputValue\"\n @input=\"inputValue = $event\"\n />\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import { BentoRichTextEditor } from '@adyen/bento-vue2';\n\n const closingScriptTag = ['</', 'script>'].join('');\n const inputValue = ref(`\n# All rendering elements\n\n## Renders a paragraph\nThis is just a plain paragraph\n\n## Renders a table\n| Month | Savings |\n| -------- | ------- |\n| January | $250 |\n| February | $80 |\n| March | $420 |\n\n## Renders a link\n[Adyen.com](https://adyen.com)\n\n## Renders lists\n### An unordered list\n* An unordered\n* List of things\n* To test how it renders\n### An ordered list\n1. An ordered\n2. List of things\n3. To test how it renders\n### A tasks list\n- [ ] a task list item\n- [ ] list syntax required\n\n## Renders html as plain text\n<html>\n<body>\n<p>This is html content</p>\n<script>alert('This should be rendered as text')${closingScriptTag}\n</body>\n</html>\n\n## Renders code\n\\`\\`\\`\ngit status\ngit add\ngit commit\n\\`\\`\\`\n\n## Renders quotes\n> Text that is a quote\n`);\n</script>\n"; import { BentoRichTextEditorModeOptions } from './rich-text-editor.internal.types'; import type { Meta, StoryObj } from '@storybook/vue'; const meta: Meta = { title: 'Rich text editor', component: BentoRichTextEditor, argTypes: { mode: { name: 'mode', type: { name: 'string', required: false }, description: 'switch between Markdown or Visual mode', options: BentoRichTextEditorModeOptions, control: { type: 'select', }, }, }, }; export default meta; type Story = StoryObj<typeof BentoRichTextEditor>; const DEFAULT_LABEL = 'Label'; const DEFAULT_DESCRIPTION = 'Supporting text'; const DEFAULT_MARKDOWN_VALUE = ` # All rendering elements ## Renders a paragraph This is just a plain paragraph ## Renders a table | Month | Savings | | -------- | ------- | | January | $250 | | February | $80 | | March | $420 | ## Renders a link [Adyen.com](https://adyen.com) ## Renders lists ### An unordered list * An unordered * List of things * To test how it renders ### An ordered list 1. An ordered 2. List of things 3. To test how it renders ### A tasks list - [ ] a task list item - [ ] list syntax required ## Renders html as plain text <html> <body> <p>This is html content</p> <script>alert('This should be rendered as text')</script> </body> </html> ## Renders code \`\`\` git status git add git commit \`\`\` ## Renders quotes > Text that is a quote `; const defaultProps = { label: DEFAULT_LABEL, hideLabel: false, disabled: false, description: DEFAULT_DESCRIPTION, value: DEFAULT_MARKDOWN_VALUE, }; export const Default: Story = { render: (_args, { argTypes }) => ({ components: { BentoRichTextEditor }, props: Object.keys(argTypes), template: ` <bento-rich-text-editor v-bind="args" :label="args.label" :hideLabel="args.hideLabel" :description="args.description" :value="inputValue" @input="inputAction" /> `, setup(props) { const args = isVue2 ? props : _args; const inputValue = ref(args.value); const inputAction = (value: string) => { inputValue.value = value; action('input')(value); }; watch( () => args.value, () => { inputValue.value = args.value; } ); return { args, inputValue, inputAction, }; }, }), args: { ...defaultProps, }, parameters: storybookDocsParameter(RichTextEditorDefaultExample), }; export const VisualMode: Story = { render: (_args, { argTypes }) => ({ components: { BentoRichTextEditor }, props: Object.keys(argTypes), template: ` <bento-rich-text-editor v-bind="args" :label="args.label" :hideLabel="args.hideLabel" :description="args.description" mode="visual" :value="inputValue" @input="inputAction" /> `, setup(props) { const args = isVue2 ? props : _args; const inputValue = ref(args.value); const inputAction = (value: string) => { inputValue.value = value; action('input')(value); }; watch( () => args.value, () => { inputValue.value = args.value; } ); return { args, inputValue, inputAction, }; }, }), args: { ...defaultProps, mode: 'visual', }, parameters: storybookDocsParameter(RichTextEditorVisualModeExample), };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import type { BentoRichTextEditorModeOptions } from './rich-text-editor.internal.types'; export type BentoRichTextEditorMode = (typeof BentoRichTextEditorModeOptions)[number]; export interface BentoRichTextEditorProps { /** * Descriptive supporting text visibile underneath the rich text editor. */ description?: string; /** * Disables rich text editor functionality. */ disabled?: boolean; /** * Highlights the rich text editor in an erroneous state with an error message. */ errorMessage?: string; /** * Shows/hides the label. */ hideLabel?: boolean; /** * Text that is displayed as a label above the element. */ label?: string; /** * Allows the component to render first in visual mode. */ mode?: BentoRichTextEditorMode; /** * Highlights the rich text editor is required. */ required?: boolean; /** * Adds a info icon next to the label to display the passed tooltip message. */ tooltipText?: string; /** * Text displayed as the value of the rich text editor */ value?: string; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<template> <bento-typography el="div" class="b-rich-text-editor" rich-text> <field-label v-if="!hideLabel" :label="label" :tooltip-text="tooltipText" :required="required" /> <div v-bind="attrs" class="b-rich-text-editor__container" data-testid="rich-text-editor-container" :aria-disabled="disabled" :class="conditionalClasses" > <div class="b-rich-text-editor__toolbar"> <bento-segmented-control v-model="selectedMode" :items="richTextEditorModeOptions" /> </div> <keep-alive> <rich-text-editor-content-area v-if="selectedMode === 'markdown'" :value="internalValue" role="textbox" aria-multiline="true" :disabled="disabled" :aria-label="computedAriaLabel" :aria-describedby="ariaDescribedBy" :aria-required="required" @input="onInput" /> <bento-alert v-else-if="error" type="critical"> <template #default> {{ t('errorProcessingMarkdown', { value: error }) }} </template> </bento-alert> <rich-text-editor-renderer v-else :node="node" class="b-rich-text-editor__renderer" :class="rendererConditionalClasses" /> </keep-alive> </div> <error-message v-if="!!errorMessage" :id="errorId" :error-message="errorMessage" class="b-rich-text-editor__error-message" /> <span v-if="description" :id="descriptionId" class="b-rich-text-editor__description"> <bento-typography el="span" variant="body">{{ description }}</bento-typography> </span> </bento-typography> </template> <script setup lang="ts"> import { computed, ref, useAttrs, watch } from 'vue'; import type { Root } from 'mdast'; // Components import BentoTypography from '@/components/typography/typography.vue'; import BentoSegmentedControl from '@/components/segmented-control/segmented-control.vue'; import BentoAlert from '@/components/alert/alert.vue'; import { ErrorMessage, FieldLabel } from '@/internal'; import RichTextEditorContentArea from './components/rich-text-editor-content-area/rich-text-editor-content-area.vue'; import RichTextEditorRenderer from './components/rich-text-editor-renderer/rich-text-editor-renderer'; import type { BentoRichTextEditorMode, BentoRichTextEditorProps } from './rich-text-editor.types'; // Utils import { useI18n } from '@/utils/ts/i18n'; import { useAriaLabel } from '@/utils/ts/aria-label'; import { generateUid } from '@/
|
|
1
|
+
<template> <bento-typography el="div" class="b-rich-text-editor" rich-text> <field-label v-if="!hideLabel" :label="label" :tooltip-text="tooltipText" :required="required" /> <div v-bind="attrs" class="b-rich-text-editor__container" data-testid="rich-text-editor-container" :aria-disabled="disabled" :class="conditionalClasses" > <div class="b-rich-text-editor__toolbar"> <bento-segmented-control v-model="selectedMode" :items="richTextEditorModeOptions" /> </div> <keep-alive> <rich-text-editor-content-area v-if="selectedMode === 'markdown'" :value="internalValue" role="textbox" aria-multiline="true" :disabled="disabled" :aria-label="computedAriaLabel" :aria-describedby="ariaDescribedBy" :aria-required="required" @input="onInput" /> <bento-alert v-else-if="error" type="critical"> <template #default> {{ t('errorProcessingMarkdown', { value: error }) }} </template> </bento-alert> <rich-text-editor-renderer v-else :node="node" class="b-rich-text-editor__renderer" :class="rendererConditionalClasses" /> </keep-alive> </div> <error-message v-if="!!errorMessage" :id="errorId" :error-message="errorMessage" class="b-rich-text-editor__error-message" /> <span v-if="description" :id="descriptionId" class="b-rich-text-editor__description"> <bento-typography el="span" variant="body">{{ description }}</bento-typography> </span> </bento-typography> </template> <script setup lang="ts"> import { computed, ref, useAttrs, watch } from 'vue'; import type { Root } from 'mdast'; // Components import BentoTypography from '@/components/typography/typography.vue'; import BentoSegmentedControl from '@/components/segmented-control/segmented-control.vue'; import BentoAlert from '@/components/alert/alert.vue'; import { ErrorMessage, FieldLabel } from '@/internal'; import RichTextEditorContentArea from './components/rich-text-editor-content-area/rich-text-editor-content-area.vue'; import RichTextEditorRenderer from './components/rich-text-editor-renderer/rich-text-editor-renderer'; import type { BentoRichTextEditorMode, BentoRichTextEditorProps } from './rich-text-editor.types'; // Utils import { useI18n } from '@/utils/ts/i18n'; import { useAriaLabel } from '@/utils/ts/aria-label'; import { generateUid } from '@/utils/ts/generate-uid'; import { parseMarkdown } from './utils'; import messages from './messages.json'; type MessageSchema = (typeof messages)['en-US']; const { t } = useI18n<{ message: MessageSchema }>({ messages }); const errorId = generateUid('rich-text-editor-error'); const descriptionId = generateUid('rich-text-editor-description'); const attrs = useAttrs(); const props = withDefaults(defineProps<BentoRichTextEditorProps>(), { description: null, disabled: false, errorMessage: null, hideLabel: null, label: null, mode: 'markdown', required: false, tooltipText: null, value: null, }); const emit = defineEmits<{ /** * Emmited when the content of the editor changes */ (e: 'input', value: string): void; }>(); const selectedMode = ref<BentoRichTextEditorMode>(props.mode); const internalValue = ref(props.value); const node = ref<Root>(null); const error = ref<Error>(null); const richTextEditorModeOptions = computed< Array<{ label: string; value: BentoRichTextEditorMode; disabled: boolean; }> >(() => [ { label: t('visual'), value: 'visual', disabled: props.disabled, }, { label: t('markdown'), value: 'markdown', disabled: props.disabled, }, ]); const conditionalClasses = computed(() => ({ 'b-rich-text-editor__container--disabled': props.disabled, 'b-rich-text-editor__container--error': props.errorMessage, })); const rendererConditionalClasses = computed(() => ({ 'b-rich-text-editor__renderer--disabled': props.disabled, })); // ARIA const computedAriaLabelFallbackMessage = computed(() => t('ariaLabelFallback')); const ariaLabelAttribute = ref(attrs['aria-label']); const computedAriaLabel = useAriaLabel({ ariaLabel: ariaLabelAttribute.value as string, defaultFallback: computedAriaLabelFallbackMessage, }); const ariaDescribedBy = computed( () => `${props.description ? descriptionId : ''} ${props.errorMessage ? errorId : ''}`.trim() || null ); /** * Turns internal value into an AST Node */ function updateNodeValue() { try { node.value = parseMarkdown(internalValue.value); error.value = null; } catch (e) { node.value = null; error.value = e.message.split(':')[1]; } } const onInput = (newContentValue: string) => { internalValue.value = newContentValue; }; watch(internalValue, (newValue: string) => { node.value = null; // Invalidate previously parsed node emit('input', newValue); }); watch( selectedMode, newVal => { if (newVal === 'visual' && !node.value) { updateNodeValue(); } }, { immediate: true } ); </script> <script lang="ts"> /** * An editable content area with additional functionality * that allows to change text styling and add links and tables. * * @example * import { BentoRichTextEditor } from '@adyen/bento-vue2'; * * export default { * components: { BentoRichTextEditor }, * template: ` * <bento-rich-text-editor * v-model="value" * :label="label" * :description="description" * :disabled="false" * /> * ` * } */ export default { i18n: { messages }, name: 'bento-rich-text-editor', }; </script> <style lang="scss" scoped src="./rich-text-editor.scss" />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { action } from '@storybook/addon-actions'; import { ref } from 'vue'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import { isVue2 } from 'vue-demi'; import BentoSearchBar from './search-bar.vue'; export default { title: 'Search bar', component: BentoSearchBar, }; export const Default = (_args, { argTypes }) => ({ components: { BentoSearchBar }, props: Object.keys(argTypes), setup(props) { const searchTerm = ref(props.value); const inputAction = inputValue => { action('input')(inputValue); }; const clearAction = () => { searchTerm.value = ''; action('clear')(); }; return { // Values searchTerm, args: isVue2 ? props : _args, // Methods inputAction, clearAction, }; }, // :input-field-aria-label="args.inputFieldAriaLabel" template: ` <bento-search-bar v-bind="args" :debounce-time="args.debounceTime" v-model="searchTerm" @input="inputAction" @clear="clearAction" /> `, }); Default.args = { inputFieldAriaLabel: 'Search bar short description', placeholder: 'Placeholder text', };
|
|
1
|
+
import { action } from '@storybook/addon-actions'; import { ref } from 'vue'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import { isVue2 } from 'vue-demi'; import BentoSearchBar from './search-bar.vue'; const SearchBarDefaultExample = "<template>\n <bento-search-bar\n v-model=\"searchTerm\"\n input-field-aria-label=\"Search bar short description\"\n placeholder=\"Placeholder text\"\n />\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import { BentoSearchBar } from '@adyen/bento-vue2';\n\n const searchTerm = ref('');\n</script>\n"; export default { title: 'Search bar', component: BentoSearchBar, }; export const Default = (_args, { argTypes }) => ({ components: { BentoSearchBar }, props: Object.keys(argTypes), setup(props) { const searchTerm = ref(props.value); const inputAction = inputValue => { action('input')(inputValue); }; const clearAction = () => { searchTerm.value = ''; action('clear')(); }; return { // Values searchTerm, args: isVue2 ? props : _args, // Methods inputAction, clearAction, }; }, // :input-field-aria-label="args.inputFieldAriaLabel" template: ` <bento-search-bar v-bind="args" :debounce-time="args.debounceTime" v-model="searchTerm" @input="inputAction" @clear="clearAction" /> `, }); Default.args = { inputFieldAriaLabel: 'Search bar short description', placeholder: 'Placeholder text', }; Default.parameters = storybookDocsParameter(SearchBarDefaultExample);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<template> <div class="b-search-bar"> <bento-input-field ref="bentoInputField" v-bind="attrs" :model-value="searchTerm" type="search" :condensed="condensed" :aria-label="inputFieldAriaLabel" :aria-hidden="false" :disabled="disabled" :placeholder="placeholder" @update:model-value="onInputEvent" @focus="emit('focus')" @blur="emit('blur')" @escape-pressed="emit(BentoSearchBarInternalEvent.ESCAPE)" > <template #iconBefore> <search-icon :svg-title="t('search')" aria-hidden="true" /> </template> <template v-if="searchTerm" #iconAfter> <div class="b-search-bar__clear-search" tabindex="0" data-testid="b-search-bar-clear-search-button" @click="onClearSearch" @keypress.enter="onClearSearch" @keyup.space="onClearSearch" > <cross-circle-fill-icon :svg-title="t('clearSearch')" /> </div> </template> </bento-input-field> </div> </template> <script setup lang="ts"> import { provide, ref, toRef, useAttrs, watch } from 'vue'; import { debounce } from '@/utils/ts/debounce'; import { BentoSearchBarInternalEvent, type BentoSearchBarProps } from './search-bar.types'; import { useI18n } from '@/utils/ts/i18n'; import { INPUT_FIELD_HINT_INJECTION_KEY } from '@/components/input-field/input-field.keys'; // eslint-disable-next-line @typescript-eslint/consistent-type-imports import BentoInputField from '@/components/input-field/input-field.vue'; import SearchIcon from '@adyen/ui-assets-icons-16/vue/search'; import CrossCircleFillIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill'; import messages from './messages.json'; type MessageSchema = (typeof messages)['en-US']; const { t } = useI18n<{ message: MessageSchema }>({ messages }); const props = withDefaults(defineProps<BentoSearchBarProps>(), { condensed: false, debounceTime: 300, disabled: false, hint: '', placeholder: '', value: undefined, }); const emit = defineEmits<{ /** * Emitted when the input value changes by typing a search. Debounced by the `debounceTime` property */ (e: 'input', inputValue: string): void; /** * Emitted when the "clear search" button is clicked */ (e: 'clear'): void; /** * Emitted when the "ESC" key is pressed inside the Search Bar input */ (e: 'escape-pressed'): void; /** * Emitted when the element has lost focus */ (e: 'blur'): void; /** * Emitted when the element has received focus */ (e: 'focus'): void; }>(); provide(INPUT_FIELD_HINT_INJECTION_KEY, toRef(props, 'hint')); const attrs = useAttrs(); const searchTerm = ref(props.value); const bentoInputField = ref<InstanceType<typeof BentoInputField> | null>(); watch( () => props.value, () => { searchTerm.value = props.value; }, { immediate: true } ); const onClearSearch = () => { searchTerm.value = ''; emit('clear'); emit('input', ''); }; const debouncedEmit = debounce(() => { emit('input', searchTerm.value); }, props.debounceTime); const onInputEvent = (value: string) => { searchTerm.value = value; debouncedEmit(); }; const focus = () => { // bentoInputField.value?.focusInput(); bentoInputField.value.focusInput(); }; // Expose method so that it can be used to focus on the input from outside the component defineExpose({ /** * Focus on the input field when called. */ focus, }); </script> <script lang="ts"> /** * Search functionality to help users find the desired data quicker. * When a user starts typing, the data is dynamically filtered to * only show the relevant results. * * Clearing the search field displays the entire list again. * * @example * import { * BentoSearchBar, * BentoSearchBarData, * useSearchBarFilter * } from '@adyen/bento-vue2'; * * export default { * components: { BentoSearchBar }, * template: ` * <bento-search-bar * input-field-aria-label="Search bar" * v-model="searchTerm" * @input="onInput" * @clear="onClearSearch" * /> * // Render the filtered data * {{ filteredData }} * `, * setup() { * const searchTerm = ref(''); * const data = ref<BentoSearchBarData>([]); * const filteredData = useSearchBarFilter(searchTerm, data); * * consdt onInput = () => {} * consdt onClearSearch = () => {} * * return { * searchTerm, * filteredData, * onInput, * onClearSearch, * }; * } * } */ export default { i18n: { messages }, }; </script> <style lang="scss" scoped src="./search-bar.scss" />
|
|
1
|
+
<template> <div class="b-search-bar"> <bento-input-field ref="bentoInputField" v-bind="attrs" :model-value="searchTerm" type="search" :condensed="condensed" :aria-label="inputFieldAriaLabel" :aria-hidden="false" :disabled="disabled" :placeholder="placeholder" @update:model-value="onInputEvent" @focus="emit('focus')" @blur="emit('blur')" @escape-pressed="emit(BentoSearchBarInternalEvent.ESCAPE)" > <template #iconBefore> <search-icon :svg-title="t('search')" aria-hidden="true" /> </template> <template v-if="searchTerm" #iconAfter> <div class="b-search-bar__clear-search" tabindex="0" data-testid="b-search-bar-clear-search-button" @click="onClearSearch" @keypress.enter="onClearSearch" @keyup.space="onClearSearch" > <cross-circle-fill-icon :svg-title="t('clearSearch')" /> </div> </template> </bento-input-field> </div> </template> <script setup lang="ts"> import { provide, ref, toRef, useAttrs, watch } from 'vue'; import { debounce } from '@/utils/ts/debounce'; import { BentoSearchBarInternalEvent, type BentoSearchBarProps } from './search-bar.types'; import { useI18n } from '@/utils/ts/i18n'; import { INPUT_FIELD_HINT_INJECTION_KEY } from '@/components/input-field/input-field.keys'; // eslint-disable-next-line @typescript-eslint/consistent-type-imports import BentoInputField from '@/components/input-field/input-field.vue'; import SearchIcon from '@adyen/ui-assets-icons-16/vue/search'; import CrossCircleFillIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill'; import messages from './messages.json'; type MessageSchema = (typeof messages)['en-US']; const { t } = useI18n<{ message: MessageSchema }>({ messages }); const props = withDefaults(defineProps<BentoSearchBarProps>(), { condensed: false, debounceTime: 300, disabled: false, hint: '', placeholder: '', value: undefined, }); const emit = defineEmits<{ /** * Emitted when the input value changes by typing a search. Debounced by the `debounceTime` property */ (e: 'input', inputValue: string): void; /** * Emitted when the "clear search" button is clicked */ (e: 'clear'): void; /** * Emitted when the "ESC" key is pressed inside the Search Bar input */ (e: 'escape-pressed'): void; /** * Emitted when the element has lost focus */ (e: 'blur'): void; /** * Emitted when the element has received focus */ (e: 'focus'): void; }>(); provide(INPUT_FIELD_HINT_INJECTION_KEY, toRef(props, 'hint')); const attrs = useAttrs(); const searchTerm = ref(props.value); const bentoInputField = ref<InstanceType<typeof BentoInputField> | null>(); watch( () => props.value, () => { searchTerm.value = props.value; }, { immediate: true } ); const onClearSearch = () => { searchTerm.value = ''; emit('clear'); emit('input', ''); }; const debouncedEmit = debounce(() => { emit('input', searchTerm.value); }, props.debounceTime); const onInputEvent = (value: string) => { searchTerm.value = value; debouncedEmit(); }; const focus = () => { // bentoInputField.value?.focusInput(); bentoInputField.value.focusInput(); }; // Expose method so that it can be used to focus on the input from outside the component defineExpose({ /** * Focus on the input field when called. */ focus, }); </script> <script lang="ts"> /** * Search functionality to help users find the desired data quicker. * When a user starts typing, the data is dynamically filtered to * only show the relevant results. * * Clearing the search field displays the entire list again. * * @example * import { * BentoSearchBar, * BentoSearchBarData, * useSearchBarFilter * } from '@adyen/bento-vue2'; * * export default { * components: { BentoSearchBar }, * template: ` * <bento-search-bar * input-field-aria-label="Search bar" * v-model="searchTerm" * @input="onInput" * @clear="onClearSearch" * /> * // Render the filtered data * {{ filteredData }} * `, * setup() { * const searchTerm = ref(''); * const data = ref<BentoSearchBarData>([]); * const filteredData = useSearchBarFilter(searchTerm, data); * * consdt onInput = () => {} * consdt onClearSearch = () => {} * * return { * searchTerm, * filteredData, * onInput, * onClearSearch, * }; * } * } */ export default { i18n: { messages }, name: 'bento-search-bar', }; </script> <style lang="scss" scoped src="./search-bar.scss" />
|
package/dist/assets/components/secondary-nav/components/secondary-nav-item/secondary-nav-item.vue
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<template> <div class="b-secondary-nav-item"> <div class="b-secondary-nav-item__wrapper"> <button class="b-secondary-nav-item__option" :class="conditionalClasses" :aria-current="isItemSelected ? 'page' : undefined" :aria-expanded="expandleItemIsToggleOnly ? `${isOpen}` : undefined" :aria-controls="expandleItemIsToggleOnly ? subItemsId : undefined" @click="expandleItemIsToggleOnly ? onToggleClick() : onClick($event)" > <bento-typography class="b-secondary-nav-item__title" variant="body" stronger> {{ label }} </bento-typography> <bento-tag v-if="errorCounter" class="b-secondary-nav-item__error-counter" variant="red"> <template #icon> <cross-circle-fill-icon aria-hidden="true" /> </template>
|
|
1
|
+
<template> <div class="b-secondary-nav-item"> <div class="b-secondary-nav-item__wrapper"> <button class="b-secondary-nav-item__option" :class="conditionalClasses" :aria-current="isItemSelected ? 'page' : undefined" :aria-expanded="expandleItemIsToggleOnly ? `${isOpen}` : undefined" :aria-controls="expandleItemIsToggleOnly ? subItemsId : undefined" @click="expandleItemIsToggleOnly ? onToggleClick() : onClick($event)" > <bento-typography class="b-secondary-nav-item__title" variant="body" stronger> {{ label }} </bento-typography> <bento-tag v-if="errorCounter" class="b-secondary-nav-item__error-counter" variant="red" :label="errorCounter.toString()" :aria-label="tc('errorCount', errorCounter)" > <template #icon> <cross-circle-fill-icon aria-hidden="true" /> </template> </bento-tag> </button> <bento-button v-if="hasSubItems" :aria-hidden="expandleItemIsToggleOnly" :tabindex="expandleItemIsToggleOnly ? -1 : undefined" class="b-secondary-nav-item__toggle" variant="tertiary" :aria-label="isOpen ? `Collapse ${label}` : `Expand ${label}`" :aria-expanded="!expandleItemIsToggleOnly ? `${isOpen}` : undefined" :aria-controls="!expandleItemIsToggleOnly ? subItemsId : undefined" @click.stop="onToggleClick" > <template #iconLeft> <chevron-up-icon v-if="isOpen" class="b-secondary-nav-item__icon" aria-hidden="true" /> <chevron-down-icon v-else class="b-secondary-nav-item__icon" aria-hidden="true" /> </template> </bento-button> </div> <Transition :name="CONTENT_TRANSITION_NAME"> <div v-if="hasSubItems && isOpen" :id="subItemsId" :style="subItemsMaxHeight"> <ul ref="subItemsRef" class="b-secondary-nav-item__sub-items"> <li v-for="item in items" :key="item.value"> <secondary-nav-item :label="item.label" :value="item.value" :items="item.items" :error-counter="item.errorCounter" is-sub-item /> </li> </ul> </div> </Transition> </div> </template> <script lang="ts" setup> import { SECONDARY_NAV_STATE } from '../../secondary-nav.keys'; import { BentoButton } from '@/components/button'; import { BentoTag } from '@/components/tag'; import { BentoTypography } from '@/components/typography'; import ChevronDownIcon from '@adyen/ui-assets-icons-16/vue/chevron-down'; import ChevronUpIcon from '@adyen/ui-assets-icons-16/vue/chevron-up'; import CrossCircleFillIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill'; import { computed, inject, ref, watch } from 'vue'; import { useI18n } from '@/utils/ts/i18n'; import { generateUid } from '@/utils/ts/generate-uid'; import { type BentoSecondaryNavItemsItem } from '../../secondary-nav.types'; import { useExpandableContentHeight } from '@/composables/use-expandable-content-height/use-expandable-content-height'; import messages from './messages.json'; type MessageSchema = (typeof messages)['en-US']; const { tc } = useI18n<{ message: MessageSchema }>({ messages }); const { activeItemValue, updateActiveItemValue, allowExpandableItemNavigation } = inject(SECONDARY_NAV_STATE); const CONTENT_TRANSITION_NAME = 'b-secondary-nav-item__animation--content'; const props = defineProps<{ /** * The display name of the navigation item */ label: string; /** * The value of this item. */ value: string; /** * Nested sub-items for this item. */ items?: Array<BentoSecondaryNavItemsItem>; /** * Defines if the item is a subitem */ isSubItem?: boolean; /** * Defines the number of errors pertaining to this item */ errorCounter?: number; }>(); const isOpen = ref(false); const subItemsId = generateUid('secondary-nav-sub-items'); const subItemsRef = ref<HTMLUListElement>(null); const hasSubItems = computed(() => !!props.items?.length); const isItemSelected = computed(() => activeItemValue.value === props.value); const expandleItemIsToggleOnly = computed(() => hasSubItems.value && !allowExpandableItemNavigation.value); const { contentHeight } = useExpandableContentHeight(subItemsRef, isOpen); const subItemsMaxHeight = computed(() => (contentHeight.value ? { 'max-height': contentHeight.value } : {})); const conditionalClasses = computed(() => ({ 'b-secondary-nav-item__option--active': isItemSelected.value, 'b-secondary-nav-item__option--expandable': hasSubItems.value, 'b-secondary-nav-item__option--sub-item': props.isSubItem, })); const emit = defineEmits<{ /** * Event emitted when this element is clicked */ (e: 'click', clickEvent: MouseEvent): void; }>(); const onClick = (e: MouseEvent) => { emit('click', e); updateActiveItemValue(props.value); }; const onToggleClick = () => { isOpen.value = !isOpen.value; }; const hasActiveDescendant = (items: Array<BentoSecondaryNavItemsItem>, value: string): boolean => { return items.some( item => item.value === value || (item.items ? hasActiveDescendant(item.items, value) : false) ); }; const hasDescendantErrors = (items: Array<BentoSecondaryNavItemsItem>): boolean => items.some(item => !!item.errorCounter || (item.items ? hasDescendantErrors(item.items) : false)); watch( [activeItemValue, () => props.items], ([activeValue]) => { if (hasSubItems.value && props.items) { if (hasActiveDescendant(props.items, activeValue) || hasDescendantErrors(props.items)) { isOpen.value = true; } } }, { immediate: true, deep: true } ); </script> <script lang="ts"> /** * This component shouldn't be used directly. It is internally used by {@see BentoSecondaryNav} */ export default { i18n: { messages } }; </script> <style lang="scss" scoped src="./secondary-nav-item.scss" />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { action } from '@storybook/addon-actions'; import { isVue2 } from 'vue-demi'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import BentoSecondaryNav from './secondary-nav.vue';
|
|
1
|
+
import { action } from '@storybook/addon-actions'; import { isVue2 } from 'vue-demi'; import { storybookDocsParameter } from '@/utils/ts/storybook'; import BentoSecondaryNav from './secondary-nav.vue'; const DefaultCodeSample = "<template>\n <bento-secondary-nav :items=\"items\" :value=\"activeItem\" @change=\"onChange\" />\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import { BentoSecondaryNav, type BentoSecondaryNavItems } from '@adyen/bento-vue2';\n\n const items: BentoSecondaryNavItems = [\n {\n label: 'Option 1',\n value: 'option_1',\n },\n {\n label: 'Option 2',\n value: 'option_2',\n errorCounter: 3,\n },\n {\n label: 'Option 3',\n value: 'option_3',\n },\n ];\n\n const activeItem = ref('option_1');\n\n const onChange = (newActiveItem: string) => {\n activeItem.value = newActiveItem;\n };\n</script>\n"; const WithCategoriesCodeSample = "<template>\n <bento-secondary-nav :items=\"items\" :value=\"activeItem\" @change=\"onChange\" />\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import { BentoSecondaryNav, type BentoSecondaryNavItems } from '@adyen/bento-vue2';\n\n const items: BentoSecondaryNavItems = [\n {\n label: 'Category 1',\n items: [\n {\n label: 'Option 1',\n value: 'option_1',\n errorCounter: 1,\n },\n {\n label: 'Option 2',\n value: 'option_2',\n },\n ],\n },\n\n {\n label: 'Category 2',\n items: [\n {\n label: 'Option 3',\n value: 'option_3',\n },\n {\n label: 'Option 4',\n value: 'option_4',\n },\n {\n label: 'Option 5',\n value: 'option_5',\n },\n ],\n },\n ];\n\n const activeItem = ref('option_1');\n\n const onChange = (newActiveItem: string) => {\n activeItem.value = newActiveItem;\n };\n</script>\n"; const WithSubItemsCodeSample = "<template>\n <bento-secondary-nav :items=\"items\" :value=\"activeItem\" @change=\"onChange\" />\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import { BentoSecondaryNav, type BentoSecondaryNavItems } from '@adyen/bento-vue2';\n\n const items: BentoSecondaryNavItems = [\n {\n label: 'Category 1',\n items: [\n {\n label: 'Option 1',\n value: 'option_1',\n errorCounter: 1,\n },\n {\n label: 'Option 2',\n value: 'option_2',\n items: [\n {\n label: 'Option 2.1',\n value: 'option_2_1',\n },\n {\n label: 'Option 2.2',\n value: 'option_2_2',\n },\n ],\n },\n ],\n },\n {\n label: 'Category 2',\n items: [\n {\n label: 'Option 3',\n value: 'option_3',\n },\n {\n label: 'Option 4',\n value: 'option_4',\n items: [\n {\n label: 'Option 4.1',\n value: 'option_4_1',\n errorCounter: 2,\n },\n {\n label: 'Option 4.2',\n value: 'option_4_2',\n },\n ],\n },\n {\n label: 'Option 5',\n value: 'option_5',\n },\n ],\n },\n ];\n\n const activeItem = ref('option_2_1');\n\n const onChange = (newActiveItem: string) => {\n activeItem.value = newActiveItem;\n };\n</script>\n"; import type { Meta, StoryObj } from '@storybook/vue'; import { type BentoSecondaryNavItems } from '@/components/secondary-nav/secondary-nav.types'; const meta: Meta = { title: 'Secondary Nav', component: BentoSecondaryNav, }; export default meta; type Story = StoryObj<typeof BentoSecondaryNav>; const DEFAULT_ITEMS: BentoSecondaryNavItems = [ { label: 'Option 1', value: 'option_1', }, { label: 'Option 2', value: 'option_2', errorCounter: 3, }, { label: 'Option 3', value: 'option_3', }, ]; const ITEMS_WITH_CATEGORIES: BentoSecondaryNavItems = [ { label: 'Category 1', items: [ { label: 'Option 1', value: 'option_1', errorCounter: 1, }, { label: 'Option 2', value: 'option_2', }, ], }, { label: 'Category 2', items: [ { label: 'Option 3', value: 'option_3', }, { label: 'Option 4', value: 'option_4', }, { label: 'Option 5', value: 'option_5', }, ], }, ]; const ITEMS_WITH_SUB_ITEMS: BentoSecondaryNavItems = ITEMS_WITH_CATEGORIES.map(category => ({ ...category, items: category.items.map(item => { if (item.value === 'option_2') { return { ...item, items: [ { label: 'Option 2.1', value: 'option_2_1', }, { label: 'Option 2.2', value: 'option_2_2', }, ], }; } if (item.value === 'option_4') { return { ...item, items: [ { label: 'Option 4.1', value: 'option_4_1', errorCounter: 2, }, { label: 'Option 4.2', value: 'option_4_2', }, ], }; } return item; }), })); export const Default: Story = { render: (_args, { argTypes }) => ({ components: { BentoSecondaryNav, }, props: Object.keys(argTypes), template: ` <bento-secondary-nav v-bind="args" @change="clickedAction" /> `, setup(props) { const clickedAction = value => action('change')(value); return { // Values args: isVue2 ? props : _args, // Events clickedAction, }; }, }), args: { items: DEFAULT_ITEMS, value: 'option_1', }, parameters: storybookDocsParameter(DefaultCodeSample), }; export const WithCategories: Story = { render: (_args, { argTypes }) => ({ components: { BentoSecondaryNav, }, props: Object.keys(argTypes), template: ` <bento-secondary-nav v-bind="args" @change="clickedAction" /> `, setup(props) { const clickedAction = value => action('change')(value); return { // Values args: isVue2 ? props : _args, // Events clickedAction, }; }, }), args: { items: ITEMS_WITH_CATEGORIES, }, parameters: storybookDocsParameter(WithCategoriesCodeSample), }; export const WithSubItems: Story = { render: (_args, { argTypes }) => ({ components: { BentoSecondaryNav, }, props: Object.keys(argTypes), template: ` <bento-secondary-nav v-bind="args" @change="clickedAction" /> `, setup(props) { const clickedAction = value => action('change')(value); return { args: isVue2 ? props : _args, clickedAction, }; }, }), args: { value: 'option_2_1', items: ITEMS_WITH_SUB_ITEMS, }, parameters: storybookDocsParameter(WithSubItemsCodeSample), };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<template> <nav class="b-secondary-nav"> <bento-dropdown v-if="isMobile" :aria-label="t('mobileDropdownAriaLabel')" :items="mobileDropdownItems" :static-categories="hasCategories" :model-value="activeItemValue" :is-option-disabled="isMobileOptionDisabled" @update:model-value="updateActiveItemValue" > <template #display-value="{ label }"> <bento-typography el="span"> {{ label }} </bento-typography> </template> <template #default="{ label, data }"> <bento-typography el="div" :class="{ 'b-secondary-nav__option': true, 'b-secondary-nav__nested-option': !!data?.level }" > {{ label }} <bento-tag v-if="data?.errorCounter" class="b-secondary-nav__error-counter" variant="red"> <template #icon> <cross-circle-fill-icon aria-hidden="true" /> </template>
|
|
1
|
+
<template> <nav class="b-secondary-nav"> <bento-dropdown v-if="isMobile" :aria-label="t('mobileDropdownAriaLabel')" :items="mobileDropdownItems" :static-categories="hasCategories" :model-value="activeItemValue" :is-option-disabled="isMobileOptionDisabled" @update:model-value="updateActiveItemValue" > <template #display-value="{ label }"> <bento-typography el="span"> {{ label }} </bento-typography> </template> <template #default="{ label, data }"> <bento-typography el="div" :class="{ 'b-secondary-nav__option': true, 'b-secondary-nav__nested-option': !!data?.level }" > {{ label }} <bento-tag v-if="data?.errorCounter" class="b-secondary-nav__error-counter" variant="red" :label="data.errorCounter" :aria-label="tc('errorCount', data.errorCounter)" > <template #icon> <cross-circle-fill-icon aria-hidden="true" /> </template> </bento-tag> </bento-typography> </template> </bento-dropdown> <ul v-else class="b-secondary-nav__list"> <li v-for="item in items" :key="item.label"> <secondary-nav-category v-if="'items' in item && !('value' in item)" :label="item.label" :items="item.items" /> <secondary-nav-item v-else :label="item.label" :value="item.value" :items="item.items" :error-counter="item.errorCounter" /> </li> </ul> </nav> </template> <script setup lang="ts"> import { computed, provide, readonly, ref, toRef, watch } from 'vue'; import { SecondaryNavItem } from './components/secondary-nav-item'; import { SecondaryNavCategory } from './components/secondary-nav-category'; import { SECONDARY_NAV_STATE } from './secondary-nav.keys'; import { type BentoSecondaryNavItems, type BentoSecondaryNavItemsCategory, type BentoSecondaryNavItemsItem, type BentoSecondaryNavState, } from './secondary-nav.types'; import { BentoDropdown } from '@/components/dropdown'; import { BentoTypography } from '@/components/typography'; import { BentoTag } from '@/components/tag'; import CrossCircleFillIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill'; import { useBreakpoints } from '@vueuse/core'; import { useI18n } from '@/utils/ts/i18n'; import { type BentoListboxOptionItem, type BentoListboxOptions } from '@/types/listbox'; import { BMediaQuerySMax } from '@adyen/bento-design-tokens/dist/js/bento/es6'; import messages from './messages.json'; type MessageSchema = (typeof messages)['en-US']; const { t, tc } = useI18n<{ message: MessageSchema }>({ messages }); const breakpoints = useBreakpoints({ s: BMediaQuerySMax, }); const isMobile = breakpoints.smallerOrEqual('s'); const props = defineProps<{ /** * An array containing all the items on the nav. The array can have either {@see BentoSecondaryNavItemsCategory }, * which is used to group different items or {@see BentoSecondaryNavItemsItem } if you don't need to group them. */ items: BentoSecondaryNavItems; /** * The value of the selected item. * If nothing is passed, it defaults to the first item value in items. */ value?: string; /** * When true, items that contain subitems are also clickable and can be selected. * When false, those items only act as expand/collapse toggles. */ allowExpandableItemNavigation?: boolean; }>(); const emit = defineEmits<{ /** * Emmited when the current selected item changes */ (e: 'change', category: string): void; }>(); const isCategory = (item: BentoSecondaryNavItems[number]): item is BentoSecondaryNavItemsCategory => 'items' in item && !('value' in item); const mapNestedItems = (items: Array<BentoSecondaryNavItemsItem>, level = 0): BentoListboxOptions => items.flatMap((item): BentoListboxOptions => { const currentItem: BentoListboxOptionItem = { label: item.label, value: item.value, data: { level, hasSubItems: !!item.items?.length, errorCounter: item.errorCounter }, }; if (item.items?.length) { return [currentItem, ...mapNestedItems(item.items, level + 1)]; } return [currentItem]; }); const isMobileOptionDisabled = (option: BentoListboxOptionItem): boolean => !props.allowExpandableItemNavigation && (option.data as { hasSubItems?: boolean })?.hasSubItems; const hasCategories = computed(() => props.items.some(item => isCategory(item))); const mobileDropdownItems = computed<BentoListboxOptions>(() => { return props.items.flatMap(item => { if (isCategory(item)) { return [ { label: item.label, value: `category-${item.label}`, items: mapNestedItems(item.items), } satisfies BentoListboxOptionItem, ]; } if (item.items?.length) { return mapNestedItems([item]); } return [ { label: item.label, value: item.value, data: { level: 0, errorCounter: item.errorCounter }, } satisfies BentoListboxOptionItem, ]; }); }); const flattenNestedItems = (items: Array<BentoSecondaryNavItemsItem>): Array<BentoSecondaryNavItemsItem> => items.flatMap(item => [item, ...(item.items?.length ? flattenNestedItems(item.items) : [])]); const findFirstSelectableNestedItemValue = (items: Array<BentoSecondaryNavItemsItem>): string => flattenNestedItems(items).find(item => props.allowExpandableItemNavigation || !item.items?.length)?.value ?? ''; const activeItemValueFallback = computed(() => { if (!props.items.length) { return ''; } return findFirstSelectableNestedItemValue( props.items.flatMap(item => isCategory(item) ? flattenNestedItems(item.items) : flattenNestedItems([item]) ) ); }); const activeItemValue = ref(props.value ?? activeItemValueFallback.value); const updateActiveItemValue = (value: string) => { activeItemValue.value = value; emit('change', value); }; // The component's state is inject on `secondary-nav-item` to determine the // current active item and to change its value const state: BentoSecondaryNavState = { activeItemValue: readonly(activeItemValue), updateActiveItemValue, allowExpandableItemNavigation: toRef(props, 'allowExpandableItemNavigation'), }; watch( () => props.value, value => { if (value !== undefined) { activeItemValue.value = value; } } ); provide(SECONDARY_NAV_STATE, state); </script> <script lang="ts"> /** * Secondary Nav offers users a structured way to access information. * It also provides a clear hierarchy for users to understand and navigate through various information. * * @example * import { BentoSecondaryNav } from '@adyen/bento-vue2'; * * export default { * components: { BentoSecondaryNav }, * template: ` * <bento-secondary-nav :value="value" :items="items" /> * `, * setup() { * const value = ref(2) // Active item value * const items: BentoSecondaryNavItemInfo[] = [ * { label: 'Option 1', value: 1 }, * { label: 'Option 2', value: 2 }, * ]; * return { items, value }; * } * } */ export default { i18n: { messages }, name: 'bento-secondary-nav', }; </script> <style lang="scss" scoped src="./secondary-nav.scss" />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<template> <div class="b-segmented-control-button" :class="conditionalClasses"> <input :id="segmentedControlButtonId" v-bento-tooltip-directive="tooltipText" :aria-checked="isChecked" :aria-label="label" :checked="isChecked" :disabled="disabled" :value="value" type="radio" class="b-segmented-control-button__input" role="radio" @change="onClick" /> <label v-if="label" :for="segmentedControlButtonId" class="b-segmented-control-button__label-container"> <bento-typography ref="segmentedControlButtonLabel" class="b-segmented-control-button__label" el="span" variant="body" stronger > {{ label }} </bento-typography> </label> </div> </template> <script setup lang="ts"> import { computed, type ComputedRef, ref } from 'vue'; import { BentoTypography } from '@/components/typography'; import { generateUid } from '@/
|
|
1
|
+
<template> <div class="b-segmented-control-button" :class="conditionalClasses"> <input :id="segmentedControlButtonId" v-bento-tooltip-directive="tooltipText" :aria-checked="isChecked" :aria-label="label" :checked="isChecked" :disabled="disabled" :value="value" type="radio" class="b-segmented-control-button__input" role="radio" @change="onClick" /> <label v-if="label" :for="segmentedControlButtonId" class="b-segmented-control-button__label-container"> <bento-typography ref="segmentedControlButtonLabel" class="b-segmented-control-button__label" el="span" variant="body" stronger > {{ label }} </bento-typography> </label> </div> </template> <script setup lang="ts"> import { computed, type ComputedRef, ref } from 'vue'; import { BentoTypography } from '@/components/typography'; import { generateUid } from '@/utils/ts/generate-uid'; import { BentoTooltipDirective as vBentoTooltipDirective } from '@/directives'; const props = withDefaults( defineProps<{ /** * Disable the radio button (optional) */ disabled?: boolean; /** * Renders the button with a 100% width */ fullWidth?: boolean; /** * The string the button will showcase */ label: string; /** * This property should not be used directly. * It will be used by v-model directive on the segmented control component */ modelValue?: string | number; /** * Renders tooltip text if provided */ tooltipText?: string; /** * Renders the button with a truncated text if the space is not enough to render the whole content */ truncate?: boolean; /** * Indicates the value of the input that will be returned when it's selected */ value: string | number; /** * Renders the button with centered text in case the text has to wrap multiple lines */ wrap?: boolean; }>(), { disabled: false, fullWidth: false, modelValue: null, truncate: false, wrap: false, tooltipText: undefined, } ); const emit = defineEmits<{ /** * Emitted every time the segmented control internal value is changed */ (e: 'update:model-value', value: string | number); }>(); const segmentedControlButtonLabel = ref(); const segmentedControlButtonId = generateUid('segmented-control-button'); const isChecked: ComputedRef<boolean> = computed(() => props.value === props.modelValue); const conditionalClasses = computed(() => ({ 'b-segmented-control-button--hug-content': !props.fullWidth, 'b-segmented-control-button--full-width': props.fullWidth, 'b-segmented-control-button--truncate': props.truncate, 'b-segmented-control-button--wrap': props.wrap && !props.truncate, })); const onClick = () => { if (!props.disabled) { emit('update:model-value', props.value); } }; </script> <script lang="ts"> /** * Internal component to be used within the BentoSegmentedControl component only */ export default { name: 'bento-segmented-control-button', }; </script> <style lang="scss" scoped src="./segmented-control-button.scss" />
|