UNPKG

@dialpad/dialtone

Version:

Dialpad's Dialtone design system monorepo

198 lines (197 loc) 6.24 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const modal = require("../../common/mixins/modal.cjs"); const common_utils = require("../../common/utils.cjs"); const sr_only_close_button = require("../../common/mixins/sr_only_close_button.cjs"); const _pluginVue2_normalizer = require("../../_virtual/_plugin-vue2_normalizer.cjs"); const notice_icon = require("../notice/notice_icon.vue.cjs"); const notice_content = require("../notice/notice_content.vue.cjs"); const notice_action = require("../notice/notice_action.vue.cjs"); const notice_constants = require("../notice/notice_constants.cjs"); const _sfc_main = { name: "DtBanner", components: { DtNoticeIcon: notice_icon.default, DtNoticeContent: notice_content.default, DtNoticeAction: notice_action.default }, mixins: [modal.default, sr_only_close_button.default], props: { /** * Sets an ID on the title element of the component. Useful for aria-describedby * or aria-labelledby or any other reason you may need an id to refer to the title. */ titleId: { type: String, default() { return common_utils.default.getUniqueString(); } }, /** * Sets an ID on the content element of the component. Useful for aria-describedby * or aria-labelledby or any other reason you may need an id to refer to the content. */ contentId: { type: String, default() { return common_utils.default.getUniqueString(); } }, /** * Title header of the notice. This can be left blank to remove the title from the notice entirely. */ title: { type: String, default: "" }, /** * Used in scenarios where the message needs to visually dominate the screen. * This will also change the aria role from status to alertdialog. * and will modally trap the keyboard focus in the dialog as soon as it displays. * @values true, false */ important: { type: Boolean, default: false }, /** * Pins the banner to the top of the window and pushes all app content down. * @values true, false */ pinned: { type: Boolean, default: false }, /** * Severity level of the notice, sets the icon and background * @values base, error, info, success, warning */ kind: { type: String, default: "base", validate(kind) { return notice_constants.NOTICE_KINDS.includes(kind); } }, /** * Props for the notice close button. */ closeButtonProps: { type: Object, default: () => ({}) }, /** * Hides the close button from the notice * @values true, false */ hideClose: { type: Boolean, default: false }, /** * Hides the icon from the notice * @values true, false */ hideIcon: { type: Boolean, default: false }, /** * Hides the action from the notice * @values true, false */ hideAction: { type: Boolean, default: false }, /** * Inner dialog class */ dialogClass: { type: String, default: "" }, /** * Banner background image */ backgroundImage: { type: String, default: "" }, /** * Background image size, follows the background-size CSS property values * <a class="d-link" href="https://developer.mozilla.org/en-US/docs/Web/CSS/background-size" target="_blank"> * CSS background-sizes * </a> */ backgroundSize: { type: String, default: "cover" } }, emits: [ /** * Close button click event * * @event close */ "close" ], computed: { role() { return this.important ? "alertdialog" : "status"; }, bannerClass() { const kindClasses = { error: "d-banner--error", info: "d-banner--info", success: "d-banner--success", warning: "d-banner--warning", base: "d-banner--base" }; return [ "d-banner", kindClasses[this.kind], { "d-banner--important": this.important, "d-banner--pinned": this.pinned } ]; }, bannerBackgroundImage() { if (this.backgroundImage === "") return null; return `background-image: url(${this.backgroundImage}); background-size: ${this.backgroundSize};`; } }, mounted() { if (this.important) { this.focusFirstElement(); } }, methods: { trapFocus(e) { if (this.important) { this.focusTrappedTabPress(e); } } } }; var _sfc_render = function render() { var _vm = this, _c = _vm._self._c; return _c("aside", { class: _vm.bannerClass, style: _vm.bannerBackgroundImage, on: { "keydown": function($event) { if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "tab", 9, $event.key, "Tab")) return null; return _vm.trapFocus.apply(null, arguments); } } }, [_c("div", { staticClass: "d-banner__dialog", class: _vm.dialogClass, attrs: { "role": _vm.role, "aria-labelledby": _vm.titleId, "aria-describedby": _vm.contentId } }, [!_vm.hideIcon ? _c("dt-notice-icon", _vm._g({ attrs: { "kind": _vm.kind } }, _vm.$listeners), [_vm._t("icon")], 2) : _vm._e(), _c("dt-notice-content", _vm._g({ attrs: { "title-id": _vm.titleId, "content-id": _vm.contentId, "title": _vm.title }, scopedSlots: _vm._u([{ key: "titleOverride", fn: function() { return [_vm._t("titleOverride")]; }, proxy: true }], null, true) }, _vm.$listeners), [_vm._t("default")], 2), _c("dt-notice-action", _vm._g({ attrs: { "hide-action": _vm.hideAction, "hide-close": _vm.hideClose, "close-button-props": _vm.closeButtonProps, "visually-hidden-close": _vm.visuallyHiddenClose, "visually-hidden-close-label": _vm.visuallyHiddenCloseLabel } }, _vm.$listeners), [_vm._t("action")], 2)], 1)]); }; var _sfc_staticRenderFns = []; var __component__ = /* @__PURE__ */ _pluginVue2_normalizer.default( _sfc_main, _sfc_render, _sfc_staticRenderFns ); const banner = __component__.exports; exports.default = banner; //# sourceMappingURL=banner.vue.cjs.map