{"version":3,"file":"callbar-button-with-popover.cjs","names":[],"sources":["../../../recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue"],"sourcesContent":["<template>\n  <div\n    class=\"d-recipe-callbar-button-with-popover\"\n    v-bind=\"addClassStyleAttrs($attrs)\"\n  >\n    <dt-recipe-callbar-button\n      :aria-label=\"ariaLabel\"\n      :disabled=\"disabled\"\n      :active=\"active\"\n      :danger=\"danger\"\n      :button-class=\"buttonClass\"\n      :button-width-size=\"buttonWidthSize\"\n      :text-class=\"textClass\"\n      :inverted-tooltip=\"invertedTooltip\"\n      :show-tooltip=\"showTooltip\"\n      :tooltip-text=\"tooltipText\"\n      :tooltip-delay=\"tooltipDelay\"\n      class=\"d-recipe-callbar-button-with-popover--main-button\"\n      @click=\"buttonClick\"\n    >\n      <template #icon>\n        <slot name=\"icon\" />\n      </template>\n      <template #tooltip>\n        <slot name=\"tooltip\" />\n      </template>\n      <slot />\n    </dt-recipe-callbar-button>\n    <dt-popover\n      v-if=\"showArrowButton\"\n      :id=\"id\"\n      :modal=\"false\"\n      :open=\"open\"\n      :placement=\"placement\"\n      :initial-focus-element=\"initialFocusElement\"\n      :show-close-button=\"showCloseButton\"\n      :offset=\"offset\"\n      padding=\"none\"\n      class=\"d-recipe-callbar-button-with-popover__popover-wrapper\"\n      :dialog-class=\"['d-recipe-callbar-button-with-popover__popover', contentClass]\"\n      v-bind=\"removeClassStyleAttrs($attrs)\"\n      :open-popover=\"showPopover\"\n      @opened=\"onModalIsOpened\"\n    >\n      <template #anchor>\n        <dt-button\n          :active=\"open\"\n          :class=\"['d-recipe-callbar-button-with-popover__arrow',\n                   { 'd-recipe-callbar-button-with-popover__arrow--large': !isCompactMode }]\"\n          :circle=\"true\"\n          importance=\"clear\"\n          size=\"lg\"\n          :aria-label=\"arrowButtonLabel\"\n          :title=\"arrowButtonLabel\"\n          width=\"2rem\"\n          @click=\"arrowClick\"\n        >\n          <template #icon>\n            <dt-icon-chevron-up\n              class=\"d-recipe-callbar-button-with-popover__arrow-icon\"\n              size=\"200\"\n            />\n          </template>\n        </dt-button>\n      </template>\n      <template #content>\n        <slot name=\"content\" />\n      </template>\n      <template #headerContent>\n        <slot name=\"headerContent\" />\n      </template>\n      <template #footerContent>\n        <slot name=\"footerContent\" />\n      </template>\n    </dt-popover>\n  </div>\n</template>\n\n<script>\nimport { DtButton } from '@/components/button';\nimport { DtPopover } from '@/components/popover';\nimport { DtIconChevronUp } from '@dialpad/dialtone-icons/vue3';\nimport { DtRecipeCallbarButton, CALLBAR_BUTTON_VALID_WIDTH_SIZE } from '../callbar_button';\nimport utils, { warnIfUnmounted, removeClassStyleAttrs, addClassStyleAttrs, returnFirstEl } from '@/common/utils';\nimport { DialtoneLocalization } from '@/localization';\n\nexport default {\n  compatConfig: { MODE: 3 },\n  name: 'DtRecipeCallbarButtonWithPopover',\n\n  components: { DtRecipeCallbarButton, DtPopover, DtButton, DtIconChevronUp },\n\n  /* inheritAttrs: false is generally an option we want to set on library\n    components. This allows any attributes passed in that are not recognized\n    as props to be passed down to another element or component using v-bind:$attrs\n    more info: https://vuejs.org/v2/api/#inheritAttrs */\n  inheritAttrs: false,\n\n  props: {\n    /**\n     * Id for the item.\n     */\n    id: {\n      type: String,\n      default () {\n        return utils.getUniqueString();\n      },\n    },\n\n    /**\n     * Aria label for the button. If empty, it takes its value from the default slot.\n     */\n    ariaLabel: {\n      type: String,\n      default: null,\n      validator: (label) => {\n        return label || this.$slots.default;\n      },\n    },\n\n    /**\n     * The direction the popover displays relative to the anchor.\n     * @values 'bottom', 'bottom-start', 'bottom-end',\n     *         'right', 'right-start', 'right-end',\n     *         'left', 'left-start', 'left-end',\n     *         'top', 'top-start', 'top-end'\n     * @default 'top'\n     */\n    placement: {\n      type: String,\n      default: 'top',\n    },\n\n    /**\n     *  Displaces the content box from its anchor element\n     *  by the specified number of pixels.\n     *  <a\n     *    class=\"d-link\"\n     *    href=\"https://atomiks.github.io/tippyjs/v6/all-props/#offset\"\n     *    target=\"_blank\"\n     *  >\n     *    Tippy.js docs\n     *  </a>\n     */\n    offset: {\n      type: Array,\n      default: () => [0, 16],\n    },\n\n    /**\n     * The element that is focused when the popover is opened. This can be an\n     * HTMLElement within the popover, a string starting with '#' which will\n     * find the element by ID. 'first' which will automatically focus\n     * the first element, or 'dialog' which will focus the dialog window itself.\n     * If the dialog is modal this prop cannot be 'none'.\n     */\n    initialFocusElement: {\n      type: String,\n      default: 'first',\n    },\n\n    /**\n     * Determines visibility for close button\n     */\n    showCloseButton: {\n      type: Boolean,\n      default: true,\n    },\n\n    /**\n     * Determines whether the button should be disabled\n     * default is false.\n     * @values true, false\n     */\n    disabled: {\n      type: Boolean,\n      default: false,\n    },\n\n    /**\n     * Forces showing the arrow, even if the button is disabled.\n     * default is false\n     * @values true, false\n     */\n    forceShowArrow: {\n      type: Boolean,\n      default: false,\n    },\n\n    /**\n     * Determines whether the button should have active styling\n     * default is false.\n     * @values true, false\n     * @see https://dialtone.dialpad.com/components/button/\n     */\n    active: {\n      type: Boolean,\n      default: false,\n    },\n\n    /**\n     * Determines whether the button should have danger styling\n     * default is false.\n     * @values true, false\n     * @see https://dialtone.dialpad.com/components/button/\n     */\n    danger: {\n      type: Boolean,\n      default: false,\n    },\n\n    /**\n     * We need this declaration because of how Vue3 informs the component about a listener.\n     * Spoiler alert: it doesn't.\n     * Vue3 intends to work as a real pub-sub, meaning the publisher has not a clue of who the subscribers are.\n     * This makes it impossible from the regular declaration (emits: ['click']) to check whether\n     * we actually have a click handler or not.\n     * We're hacking it by adding an onClick prop: https://github.com/vuejs/core/issues/5220\n    */\n     \n    onClick: {\n      type: Function,\n      default: null,\n    },\n\n    /**\n     * Additional class name for the button wrapper element.\n     */\n    buttonClass: {\n      type: [String, Array, Object],\n      default: '',\n    },\n\n    /**\n     * Additional class name for the button text.\n     */\n    textClass: {\n      type: [String, Array, Object],\n      default: '',\n    },\n\n    /*\n     * Width size. Valid values are: 'xl', 'lg', 'md' and 'sm'.\n     */\n    buttonWidthSize: {\n      type: String,\n      default: 'xl',\n      validator: size => CALLBAR_BUTTON_VALID_WIDTH_SIZE.includes(size),\n    },\n\n    /**\n     * Additional class name for the popover content wrapper element.\n     */\n    contentClass: {\n      type: [String, Array, Object],\n      default: '',\n    },\n\n    /**\n     * To auto open the modal popover.\n     */\n    openPopover: {\n      type: Boolean,\n      default: false,\n    },\n\n    /**\n     * Whether the tooltip has an inverted background color.\n     * @values true, false\n     */\n    invertedTooltip: {\n      type: Boolean,\n      default: false,\n    },\n\n    /**\n     * Use this if you would like to manually override the logic for when the tooltip shows.\n     * Otherwise it will just show on hover/focus.\n     * @values null, true, false\n     */\n    showTooltip: {\n      type: Boolean,\n      default: null,\n    },\n\n    /**\n     * The message that displays in the tooltip. This will be overridden by the tooltip slot.\n     */\n    tooltipText: {\n      type: String,\n      default: undefined,\n    },\n\n    /**\n     * Whether there is a delay before the tooltip shows on hover/focus.\n     * @values true, false\n     */\n    tooltipDelay: {\n      type: Boolean,\n      default: undefined,\n    },\n  },\n\n  emits: [\n    /**\n     * Emitted when the arrow is clicked\n     */\n    'arrow-click',\n\n    /**\n     * Native click event\n     *\n     * @event click\n     * @type {PointerEvent | KeyboardEvent}\n     */\n    'click',\n\n    /**\n     * Emitted when modal popover is opened or closed.\n     */\n    'opened',\n  ],\n\n  data () {\n    return {\n      open: false,\n      i18n: new DialtoneLocalization(),\n    };\n  },\n\n  computed: {\n    showArrowButton () {\n      return this.forceShowArrow || !this.disabled;\n    },\n\n    isCompactMode () {\n      return this.buttonWidthSize === 'sm' || this.buttonWidthSize === 'md';\n    },\n\n    showPopover () {\n      if (!this.openPopover || this.open) {\n        this.syncOpenState();\n        return false;\n      }\n\n      return this.toggleOpen();\n    },\n\n    arrowButtonLabel () {\n      return this.i18n.$t('DIALTONE_CALLBAR_BUTTON_WITH_POPOVER_ARROW_BUTTON_ARIA_LABEL');\n    },\n  },\n\n  mounted () {\n    warnIfUnmounted(returnFirstEl(this.$el), this.$options.name);\n  },\n\n  methods: {\n    removeClassStyleAttrs,\n    addClassStyleAttrs,\n    arrowClick (ev) {\n      this.$emit('arrow-click', ev);\n      return this.toggleOpen();\n    },\n\n    toggleOpen () {\n      return (this.open = !this.open);\n    },\n\n    syncOpenState () {\n      this.open = this.openPopover;\n    },\n\n    buttonClick (ev) {\n      // If no listener for the click event, the button click opens the popover\n      // the same as if the arrow was clicked.\n      if (!this.$props.onClick) {\n        this.arrowClick(ev);\n      } else {\n        this.$emit('click', ev);\n      }\n    },\n\n    onModalIsOpened (isOpened) {\n      this.open = isOpened;\n      this.$emit('opened', isOpened);\n    },\n  },\n\n};\n</script>\n"],"mappings":"0gBAsFA,IAAK,EAAU,CACb,aAAc,CAAE,KAAM,EAAG,CACzB,KAAM,mCAEN,WAAY,CAAE,sBAAA,EAAA,QAAuB,UAAA,EAAA,QAAW,SAAA,EAAA,QAAU,gBAAA,EAAA,gBAAiB,CAM3E,aAAc,GAEd,MAAO,CAIL,GAAI,CACF,KAAM,OACN,SAAW,CACT,OAAO,EAAA,QAAM,iBAAiB,EAEjC,CAKD,UAAW,CACT,KAAM,OACN,QAAS,KACT,UAAY,GACH,IAAA,IAAA,IAAc,OAAO,QAE/B,CAUD,UAAW,CACT,KAAM,OACN,QAAS,MACV,CAaD,OAAQ,CACN,KAAM,MACN,YAAe,CAAC,EAAG,GAAG,CACvB,CASD,oBAAqB,CACnB,KAAM,OACN,QAAS,QACV,CAKD,gBAAiB,CACf,KAAM,QACN,QAAS,GACV,CAOD,SAAU,CACR,KAAM,QACN,QAAS,GACV,CAOD,eAAgB,CACd,KAAM,QACN,QAAS,GACV,CAQD,OAAQ,CACN,KAAM,QACN,QAAS,GACV,CAQD,OAAQ,CACN,KAAM,QACN,QAAS,GACV,CAWD,QAAS,CACP,KAAM,SACN,QAAS,KACV,CAKD,YAAa,CACX,KAAM,CAAC,OAAQ,MAAO,OAAO,CAC7B,QAAS,GACV,CAKD,UAAW,CACT,KAAM,CAAC,OAAQ,MAAO,OAAO,CAC7B,QAAS,GAC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