@dialpad/dialtone-vue 3.222.0 → 3.222.2
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/dist/common/constants/index.cjs +1 -1
- package/dist/common/constants/index.cjs.map +1 -1
- package/dist/common/constants/index.d.ts +4 -0
- package/dist/common/constants/index.d.ts.map +1 -1
- package/dist/common/constants/index.js +10 -10
- package/dist/common/constants/index.js.map +1 -1
- package/dist/component-documentation.json +1 -1
- package/dist/components/combobox_with_popover/combobox_with_popover.vue.d.ts +18 -18
- package/dist/components/combobox_with_popover/combobox_with_popover.vue.d.ts.map +1 -1
- package/dist/components/dropdown/dropdown.vue.d.ts +18 -18
- package/dist/components/dropdown/dropdown.vue.d.ts.map +1 -1
- package/dist/components/emoji_picker/emoji_picker.vue.d.ts +22 -0
- package/dist/components/emoji_picker/modules/emoji_search.vue.d.ts +22 -0
- package/dist/components/emoji_picker/modules/emoji_search.vue.d.ts.map +1 -1
- package/dist/components/hovercard/hovercard.vue.d.ts +32 -32
- package/dist/components/hovercard/hovercard.vue.d.ts.map +1 -1
- package/dist/components/input/input.vue.d.ts +11 -0
- package/dist/components/input/input.vue.d.ts.map +1 -1
- package/dist/components/modal/modal.vue.d.ts +6 -5
- package/dist/components/modal/modal.vue.d.ts.map +1 -1
- package/dist/components/popover/popover.vue.d.ts +13 -13
- package/dist/components/popover/popover.vue.d.ts.map +1 -1
- package/dist/components/resizable/composables/useResizableGroup.d.ts.map +1 -1
- package/dist/components/rich_text_editor/extensions/variable/VariableComponent.vue.d.ts +24 -13
- package/dist/components/split_button/split_button.vue.d.ts +18 -18
- package/dist/components/tooltip/tooltip.vue.d.ts +8 -8
- package/dist/components/tooltip/tooltip.vue.d.ts.map +1 -1
- package/dist/dialtone-vue.cjs +1 -1
- package/dist/dialtone-vue.js +149 -149
- package/dist/lib/combobox-multi-select/combobox-multi-select.cjs +1 -1
- package/dist/lib/combobox-multi-select/combobox-multi-select.cjs.map +1 -1
- package/dist/lib/combobox-multi-select/combobox-multi-select.js +49 -48
- package/dist/lib/combobox-multi-select/combobox-multi-select.js.map +1 -1
- package/dist/lib/combobox-with-popover/combobox-with-popover.cjs +1 -1
- package/dist/lib/combobox-with-popover/combobox-with-popover.cjs.map +1 -1
- package/dist/lib/combobox-with-popover/combobox-with-popover.js +43 -42
- package/dist/lib/combobox-with-popover/combobox-with-popover.js.map +1 -1
- package/dist/lib/dropdown/dropdown.cjs +1 -1
- package/dist/lib/dropdown/dropdown.cjs.map +1 -1
- package/dist/lib/dropdown/dropdown.js +33 -33
- package/dist/lib/dropdown/dropdown.js.map +1 -1
- package/dist/lib/editor/editor.cjs +1 -1
- package/dist/lib/editor/editor.js +1 -1
- package/dist/lib/hovercard/hovercard.cjs +1 -1
- package/dist/lib/hovercard/hovercard.cjs.map +1 -1
- package/dist/lib/hovercard/hovercard.js +28 -27
- package/dist/lib/hovercard/hovercard.js.map +1 -1
- package/dist/lib/input/input.cjs +1 -1
- package/dist/lib/input/input.cjs.map +1 -1
- package/dist/lib/input/input.js +6 -6
- package/dist/lib/input/input.js.map +1 -1
- package/dist/lib/message-input/index.cjs +1 -1
- package/dist/lib/message-input/index.js +1 -1
- package/dist/lib/message-input/message-input.cjs +1 -1
- package/dist/lib/message-input/message-input.js +1 -1
- package/dist/lib/modal/modal.cjs +1 -1
- package/dist/lib/modal/modal.cjs.map +1 -1
- package/dist/lib/modal/modal.js +61 -58
- package/dist/lib/modal/modal.js.map +1 -1
- package/dist/lib/popover/popover.cjs +1 -1
- package/dist/lib/popover/popover.cjs.map +1 -1
- package/dist/lib/popover/popover.js +76 -75
- package/dist/lib/popover/popover.js.map +1 -1
- package/dist/lib/resizable/index.cjs +1 -1
- package/dist/lib/resizable/index.js +1 -1
- package/dist/lib/resizable/resizable.cjs +1 -1
- package/dist/lib/resizable/resizable.js +1 -1
- package/dist/lib/rich-text-editor/index.cjs +1 -1
- package/dist/lib/rich-text-editor/index.js +1 -1
- package/dist/lib/rich-text-editor/rich-text-editor.cjs +1 -1
- package/dist/lib/rich-text-editor/rich-text-editor.js +1 -1
- package/dist/lib/tooltip/tooltip.cjs +2 -2
- package/dist/lib/tooltip/tooltip.cjs.map +1 -1
- package/dist/lib/tooltip/tooltip.js +30 -29
- package/dist/lib/tooltip/tooltip.js.map +1 -1
- package/dist/{message_input-B47LB7C8.js → message_input-B2fppje7.js} +2 -2
- package/dist/{message_input-B47LB7C8.js.map → message_input-B2fppje7.js.map} +1 -1
- package/dist/{message_input-BCIq_1AD.cjs → message_input-DmLi63dh.cjs} +2 -2
- package/dist/{message_input-BCIq_1AD.cjs.map → message_input-DmLi63dh.cjs.map} +1 -1
- package/dist/recipes/buttons/callbar_button/callbar_button.vue.d.ts +8 -8
- package/dist/recipes/buttons/callbar_button_with_dropdown/callbar_button_with_dropdown.vue.d.ts +26 -26
- package/dist/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.d.ts +21 -21
- package/dist/recipes/cards/ivr_node/ivr_node.vue.d.ts +18 -18
- package/dist/recipes/conversation_view/editor/EditorToolbarDropdownButton.vue.d.ts +18 -18
- package/dist/recipes/conversation_view/editor/EditorToolbarPopoverButton.vue.d.ts +13 -13
- package/dist/recipes/conversation_view/editor/editor.vue.d.ts +63 -52
- package/dist/recipes/conversation_view/editor/editor.vue.d.ts.map +1 -1
- package/dist/recipes/conversation_view/emoji_row/emoji_row.vue.d.ts +8 -8
- package/dist/recipes/conversation_view/message_input/message_input.vue.d.ts +94 -50
- package/dist/recipes/conversation_view/message_input/message_input.vue.d.ts.map +1 -1
- package/dist/recipes/conversation_view/message_input/message_input_button.vue.d.ts +8 -8
- package/dist/recipes/conversation_view/message_input/message_input_link.vue.d.ts +32 -21
- package/dist/recipes/conversation_view/message_input/message_input_link.vue.d.ts.map +1 -1
- package/dist/recipes/conversation_view/message_input/message_input_topbar.vue.d.ts +8 -8
- package/dist/recipes/leftbar/contact_row/contact_row.vue.d.ts +8 -8
- package/dist/recipes/leftbar/general_row/general_row.vue.d.ts +8 -8
- package/dist/recipes/leftbar/group_row/group_row.vue.d.ts +8 -8
- package/dist/{resizable-aOVGO_Os.cjs → resizable-BOCf9EIc.cjs} +2 -2
- package/dist/{resizable-aOVGO_Os.cjs.map → resizable-BOCf9EIc.cjs.map} +1 -1
- package/dist/{resizable-D4-peBOl.js → resizable-CPaF9dgG.js} +7 -3
- package/dist/{resizable-D4-peBOl.js.map → resizable-CPaF9dgG.js.map} +1 -1
- package/dist/{rich_text_editor-CNFb6tIx.js → rich_text_editor-BhUKyR0E.js} +2 -2
- package/dist/{rich_text_editor-CNFb6tIx.js.map → rich_text_editor-BhUKyR0E.js.map} +1 -1
- package/dist/{rich_text_editor-DRytK1_9.cjs → rich_text_editor-wvONcbYd.cjs} +2 -2
- package/dist/{rich_text_editor-DRytK1_9.cjs.map → rich_text_editor-wvONcbYd.cjs.map} +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.js","names":[],"sources":["../../../components/dropdown/dropdown.vue"],"sourcesContent":["<!-- eslint-disable max-lines -->\n<template>\n <dt-popover\n ref=\"popover\"\n :content-width=\"contentWidth\"\n :open=\"open\"\n :placement=\"placement\"\n :initial-focus-element=\"openedWithKeyboard ? 'first' : 'dialog'\"\n :fallback-placements=\"fallbackPlacements\"\n padding=\"none\"\n role=\"menu\"\n :append-to=\"appendTo\"\n :modal=\"modal\"\n :max-height=\"maxHeight\"\n :max-width=\"maxWidth\"\n :open-with-arrow-keys=\"shouldOpenWithArrowKeys\"\n :open-on-context=\"openOnContext\"\n v-bind=\"$attrs\"\n :tether=\"tether\"\n :transition=\"transition\"\n v-on=\"dropdownListeners\"\n >\n <template #anchor=\"{ attrs }\">\n <!-- @slot Anchor element that activates the dropdown -->\n <slot\n ref=\"anchor\"\n name=\"anchor\"\n v-bind=\"attrs\"\n />\n </template>\n <template #content=\"{ close }\">\n <!-- eslint-disable-next-line max-len -->\n <!-- eslint-disable-next-line vuejs-accessibility/mouse-events-have-key-events vuejs-accessibility/no-static-element-interactions -->\n <ul\n :id=\"listId\"\n ref=\"listWrapper\"\n :class=\"listClasses\"\n data-qa=\"dt-dropdown-list-wrapper\"\n @mouseleave=\"clearHighlightIndex\"\n @mousemove.capture=\"onMouseHighlight\"\n >\n <!-- @slot Slot for the list component -->\n <slot\n name=\"list\"\n :close=\"close\"\n />\n </ul>\n </template>\n <template #footerContent=\"{ close }\">\n <!-- @slot Slot for the footer content -->\n <slot\n name=\"footer\"\n :close=\"close\"\n />\n </template>\n </dt-popover>\n</template>\n\n<script>\nimport KeyboardNavigation from '@/common/mixins/keyboard_list_navigation';\nimport { DtPopover, POPOVER_APPEND_TO_VALUES } from '@/components/popover';\nimport { LIST_ITEM_NAVIGATION_TYPES } from '@/components/list_item';\nimport { DROPDOWN_PADDING_CLASSES } from './dropdown_constants';\nimport { getUniqueString } from '@/common/utils';\nimport { EVENT_KEYNAMES } from '@/common/constants';\n\nexport default {\n compatConfig: { MODE: 3 },\n name: 'DtDropdown',\n\n components: {\n DtPopover,\n },\n\n mixins: [\n KeyboardNavigation({\n indexKey: 'highlightIndex',\n idKey: 'highlightId',\n listElementKey: 'getListElement',\n listItemRole: 'menuitem',\n afterHighlightMethod: 'afterHighlight',\n beginningOfListMethod: 'beginningOfListMethod',\n endOfListMethod: 'endOfListMethod',\n activeItemKey: 'activeItemEl',\n focusOnKeyboardNavigation: true,\n }),\n ],\n\n inheritAttrs: false,\n\n props: {\n /**\n * Controls whether the dropdown is shown. Leaving this null will have the dropdown trigger on click by default.\n * If you set this value, the default trigger behavior will be disabled and you can control it as you need.\n * Supports v-model\n */\n open: {\n type: Boolean,\n default: null,\n },\n\n /**\n * Opens the dropdown on right click (context menu). If you set this value to `true`,\n * the default trigger behavior will be disabled.\n */\n openOnContext: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Vertical padding size around the list element.\n * @values none, small, large\n */\n padding: {\n type: String,\n default: 'small',\n validator: (padding) => {\n return Object.keys(DROPDOWN_PADDING_CLASSES).some((item) => item === padding);\n },\n },\n\n /**\n * Determines modal state, dropdown has a modal overlay preventing interaction with elements\n * below it, but it is invisible.\n */\n modal: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Width configuration for the popover content. When its value is 'anchor',\n * the popover content will have the same width as the anchor.\n * @values null, anchor\n */\n contentWidth: {\n type: String,\n default: null,\n },\n\n /**\n * Determines maximum height for the popover before overflow.\n * Possible units rem|px|em\n */\n maxHeight: {\n type: String,\n default: '',\n },\n\n /**\n * Determines maximum width for the popover before overflow.\n * Possible units rem|px|%|em\n */\n maxWidth: {\n type: String,\n default: '',\n },\n\n /**\n * Sets an ID on the list element of the component. Used by several aria attributes\n * as well as when deriving the IDs for each item.\n */\n listId: {\n type: String,\n default () { return getUniqueString(); },\n },\n\n /**\n * The type of navigation that this component should support.\n * - \"arrow-keys\" for items that are navigated with UP/DOWN keys.\n * - \"tab\" for items that are navigated using the TAB key.\n * - \"none\" for static items that are not interactive.\n * @values arrow-keys, tab, none\n */\n navigationType: {\n type: String,\n default: LIST_ITEM_NAVIGATION_TYPES.ARROW_KEYS,\n validator: (t) => Object.values(LIST_ITEM_NAVIGATION_TYPES).includes(t),\n },\n\n /**\n * If the dropdown does not fit in the direction described by \"placement\",\n * it will attempt to change it's direction to the \"fallbackPlacements\".\n *\n * @values top, top-start, top-end,\n * right, right-start, right-end,\n * left, left-start, left-end,\n * bottom, bottom-start, bottom-end,\n * auto, auto-start, auto-end\n * */\n fallbackPlacements: {\n type: Array,\n default: () => {\n return ['auto'];\n },\n },\n\n /**\n * The direction the dropdown displays relative to the anchor.\n */\n placement: {\n type: String,\n default: 'bottom',\n },\n\n /**\n * A method that will be called when the selection goes past the beginning of the list.\n */\n onBeginningOfList: {\n type: Function,\n default: null,\n },\n\n /**\n * A method that will be called when the selection goes past the end of the list.\n */\n onEndOfList: {\n type: Function,\n default: null,\n },\n\n /**\n * Additional class for the wrapper list element.\n */\n listClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Sets the element to which the popover is going to append to.\n * 'body' will append to the nearest body (supports shadow DOM).\n * @values 'body', 'parent', HTMLElement,\n */\n appendTo: {\n type: [HTMLElement, String],\n default: 'body',\n validator: appendTo => {\n return POPOVER_APPEND_TO_VALUES.includes(appendTo) ||\n (appendTo instanceof HTMLElement);\n },\n },\n\n /**\n * If set to false the dialog will display over top of the anchor when there is insufficient space.\n * If set to true it will never move from its position relative to the anchor and will clip instead.\n * <a\n * class=\"d-link\"\n * href=\"https://popper.js.org/docs/v2/modifiers/prevent-overflow/#tether\"\n * target=\"_blank\"\n * >\n * Popper.js docs\n * </a>\n * @values true, false\n */\n tether: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Named transition when the content display is toggled.\n * @see DtLazyShow\n */\n transition: {\n type: String,\n default: 'fade',\n },\n },\n\n emits: [\n /**\n * Native keydown event\n *\n * @event keydown\n * @type {KeyboardEvent}\n */\n 'keydown',\n\n /**\n * Event fired when the highlight changes\n *\n * @event highlight\n * @type {Number}\n */\n 'highlight',\n\n /**\n * Event fired to sync the open prop with the parent component\n * @event update:open\n */\n 'update:open',\n\n /**\n * Event fired when dropdown is shown or hidden\n *\n * @event opened\n * @type {Boolean | Array}\n */\n 'opened',\n ],\n\n data () {\n return {\n LIST_ITEM_NAVIGATION_TYPES,\n DROPDOWN_PADDING_CLASSES,\n EVENT_KEYNAMES,\n openedWithKeyboard: false,\n isOpen: null,\n };\n },\n\n computed: {\n dropdownListeners () {\n return {\n\n 'update:open': value => {\n this.$emit('update:open', value);\n },\n\n opened: isPopoverOpen => {\n this.updateInitialHighlightIndex(isPopoverOpen);\n },\n\n keydown: event => {\n const eventCode = event.code;\n\n switch (eventCode) {\n case EVENT_KEYNAMES.up:\n case EVENT_KEYNAMES.arrowup:\n this.onUpKeyPress(event);\n event.stopPropagation();\n event.preventDefault();\n break;\n case EVENT_KEYNAMES.down:\n case EVENT_KEYNAMES.arrowdown:\n this.onDownKeyPress(event);\n event.stopPropagation();\n event.preventDefault();\n break;\n case EVENT_KEYNAMES.space:\n case EVENT_KEYNAMES.spacebar:\n this.onSpaceKey();\n break;\n case EVENT_KEYNAMES.enter:\n this.onEnterKey();\n break;\n case EVENT_KEYNAMES.home:\n this.onHomeKeyPress(event);\n event.stopPropagation();\n event.preventDefault();\n break;\n case EVENT_KEYNAMES.end:\n this.onEndKeyPress(event);\n event.stopPropagation();\n event.preventDefault();\n break;\n default:\n this.onKeyPress(event);\n break;\n }\n\n this.$emit('keydown', event);\n },\n };\n },\n\n beginningOfListMethod () {\n return this.onBeginningOfList || this.jumpToEnd;\n },\n\n endOfListMethod () {\n return this.onEndOfList || this.jumpToBeginning;\n },\n\n activeItemEl () {\n return this.getListElement().querySelector('#' + this.highlightId);\n },\n\n isArrowKeyNav () {\n return this.navigationType === this.LIST_ITEM_NAVIGATION_TYPES.ARROW_KEYS;\n },\n\n listClasses () {\n return [\n 'd-dropdown-list',\n DROPDOWN_PADDING_CLASSES[this.padding],\n this.listClass,\n { 'd-context-menu-list': this.openOnContext },\n ];\n },\n\n shouldOpenWithArrowKeys () {\n return !this.openOnContext;\n },\n },\n\n methods: {\n onMouseHighlight (e) {\n const liElement = e.target.closest('li');\n\n if (liElement && liElement.role && this.highlightId !== liElement.id) {\n this.setHighlightId(liElement.id);\n liElement.focus();\n }\n },\n\n getListElement () {\n return this.$refs.listWrapper;\n },\n\n clearHighlightIndex () {\n this.setHighlightIndex(-1);\n },\n\n afterHighlight () {\n if (this.highlightIndex === this._itemsLength() - 1) {\n return;\n }\n\n this.$emit('highlight', this.highlightIndex);\n },\n\n updateInitialHighlightIndex (isPopoverOpen) {\n this.isOpen = isPopoverOpen;\n\n if (isPopoverOpen) {\n if (this.openedWithKeyboard && this.isArrowKeyNav) {\n this.setHighlightIndex(0);\n }\n this.$emit('opened', true);\n } else {\n this.clearHighlightIndex();\n this.openedWithKeyboard = false;\n this.$emit('opened', false);\n }\n },\n\n onSpaceKey () {\n if (!this.open) {\n this.openedWithKeyboard = true;\n }\n },\n\n onEnterKey () {\n if (!this.open) {\n this.openedWithKeyboard = true;\n }\n },\n\n onUpKeyPress () {\n if (!this.isOpen) {\n this.openedWithKeyboard = true;\n return;\n }\n if (this.isArrowKeyNav) {\n return this.onUpKey();\n }\n },\n\n onDownKeyPress () {\n if (!this.isOpen) {\n this.openedWithKeyboard = true;\n return;\n }\n if (this.isArrowKeyNav) {\n return this.onDownKey();\n }\n },\n\n onHomeKeyPress () {\n if (!this.isOpen || !this.isArrowKeyNav) {\n return;\n }\n\n return this.onHomeKey();\n },\n\n onEndKeyPress () {\n if (!this.isOpen || !this.isArrowKeyNav) {\n return;\n }\n\n return this.onEndKey();\n },\n\n onKeyPress (e) {\n if (!this.isOpen || !this.isArrowKeyNav || !this.isValidLetter(e.key)) {\n return;\n }\n\n e.stopPropagation();\n e.preventDefault();\n\n return this.onNavigationKey(e.key);\n },\n },\n};\n</script>\n"],"mappings":";;;;;;;;;;AAkEA,IAAK,IAAU;CACb,cAAc,EAAE,MAAM,GAAG;CACzB,MAAM;CAEN,YAAY,EACV,WAAA,GACD;CAED,QAAQ,CACN,EAAmB;EACjB,UAAU;EACV,OAAO;EACP,gBAAgB;EAChB,cAAc;EACd,sBAAsB;EACtB,uBAAuB;EACvB,iBAAiB;EACjB,eAAe;EACf,2BAA2B;EAC5B,CAAC,CACH;CAED,cAAc;CAEd,OAAO;EAML,MAAM;GACJ,MAAM;GACN,SAAS;GACV;EAMD,eAAe;GACb,MAAM;GACN,SAAS;GACV;EAMD,SAAS;GACP,MAAM;GACN,SAAS;GACT,YAAY,MACH,OAAO,KAAK,EAAyB,CAAC,MAAM,MAAS,MAAS,EAAQ;GAEhF;EAMD,OAAO;GACL,MAAM;GACN,SAAS;GACV;EAOD,cAAc;GACZ,MAAM;GACN,SAAS;GACV;EAMD,WAAW;GACT,MAAM;GACN,SAAS;GACV;EAMD,UAAU;GACR,MAAM;GACN,SAAS;GACV;EAMD,QAAQ;GACN,MAAM;GACN,UAAW;AAAE,WAAO,G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,GAAA,MAAE,EAAA,uBAAA,EAAA,oBAAA,GAAA,EAAmB;iDACZ,EAAA,oBAAA,EAAA,iBAAA,GAAA,EAAgB;MAGpC,EAGE,EAAA,QAAA,QAAA,EADQ,UAAK,CAAA,CAAA,EAAA,IAAA,EAAA,CAAA,CAAA;EAIR,eAAa,GAKpB,EALwB,eAAK,CAE/B,EAGE,EAAA,QAAA,UAAA,EADQ,UAAK,CAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"dropdown.js","names":[],"sources":["../../../components/dropdown/dropdown.vue"],"sourcesContent":["<!-- eslint-disable max-lines -->\n<template>\n <dt-popover\n ref=\"popover\"\n :content-width=\"contentWidth\"\n :open=\"open\"\n :placement=\"placement\"\n :initial-focus-element=\"openedWithKeyboard ? 'first' : 'dialog'\"\n :fallback-placements=\"fallbackPlacements\"\n padding=\"none\"\n role=\"menu\"\n :append-to=\"appendTo\"\n :modal=\"modal\"\n :max-height=\"maxHeight\"\n :max-width=\"maxWidth\"\n :open-with-arrow-keys=\"shouldOpenWithArrowKeys\"\n :open-on-context=\"openOnContext\"\n v-bind=\"$attrs\"\n :tether=\"tether\"\n :transition=\"transition\"\n v-on=\"dropdownListeners\"\n >\n <template #anchor=\"{ attrs }\">\n <!-- @slot Anchor element that activates the dropdown -->\n <slot\n ref=\"anchor\"\n name=\"anchor\"\n v-bind=\"attrs\"\n />\n </template>\n <template #content=\"{ close }\">\n <!-- eslint-disable-next-line max-len -->\n <!-- eslint-disable-next-line vuejs-accessibility/mouse-events-have-key-events vuejs-accessibility/no-static-element-interactions -->\n <ul\n :id=\"listId\"\n ref=\"listWrapper\"\n :class=\"listClasses\"\n data-qa=\"dt-dropdown-list-wrapper\"\n @mouseleave=\"clearHighlightIndex\"\n @mousemove.capture=\"onMouseHighlight\"\n >\n <!-- @slot Slot for the list component -->\n <slot\n name=\"list\"\n :close=\"close\"\n />\n </ul>\n </template>\n <template #footerContent=\"{ close }\">\n <!-- @slot Slot for the footer content -->\n <slot\n name=\"footer\"\n :close=\"close\"\n />\n </template>\n </dt-popover>\n</template>\n\n<script>\nimport KeyboardNavigation from '@/common/mixins/keyboard_list_navigation';\nimport { DtPopover, POPOVER_APPEND_TO_VALUES } from '@/components/popover';\nimport { LIST_ITEM_NAVIGATION_TYPES } from '@/components/list_item';\nimport { DROPDOWN_PADDING_CLASSES } from './dropdown_constants';\nimport { getUniqueString } from '@/common/utils';\nimport { EVENT_KEYNAMES, HTML_ELEMENT_TYPE } from '@/common/constants';\n\nexport default {\n compatConfig: { MODE: 3 },\n name: 'DtDropdown',\n\n components: {\n DtPopover,\n },\n\n mixins: [\n KeyboardNavigation({\n indexKey: 'highlightIndex',\n idKey: 'highlightId',\n listElementKey: 'getListElement',\n listItemRole: 'menuitem',\n afterHighlightMethod: 'afterHighlight',\n beginningOfListMethod: 'beginningOfListMethod',\n endOfListMethod: 'endOfListMethod',\n activeItemKey: 'activeItemEl',\n focusOnKeyboardNavigation: true,\n }),\n ],\n\n inheritAttrs: false,\n\n props: {\n /**\n * Controls whether the dropdown is shown. Leaving this null will have the dropdown trigger on click by default.\n * If you set this value, the default trigger behavior will be disabled and you can control it as you need.\n * Supports v-model\n */\n open: {\n type: Boolean,\n default: null,\n },\n\n /**\n * Opens the dropdown on right click (context menu). If you set this value to `true`,\n * the default trigger behavior will be disabled.\n */\n openOnContext: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Vertical padding size around the list element.\n * @values none, small, large\n */\n padding: {\n type: String,\n default: 'small',\n validator: (padding) => {\n return Object.keys(DROPDOWN_PADDING_CLASSES).some((item) => item === padding);\n },\n },\n\n /**\n * Determines modal state, dropdown has a modal overlay preventing interaction with elements\n * below it, but it is invisible.\n */\n modal: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Width configuration for the popover content. When its value is 'anchor',\n * the popover content will have the same width as the anchor.\n * @values null, anchor\n */\n contentWidth: {\n type: String,\n default: null,\n },\n\n /**\n * Determines maximum height for the popover before overflow.\n * Possible units rem|px|em\n */\n maxHeight: {\n type: String,\n default: '',\n },\n\n /**\n * Determines maximum width for the popover before overflow.\n * Possible units rem|px|%|em\n */\n maxWidth: {\n type: String,\n default: '',\n },\n\n /**\n * Sets an ID on the list element of the component. Used by several aria attributes\n * as well as when deriving the IDs for each item.\n */\n listId: {\n type: String,\n default () { return getUniqueString(); },\n },\n\n /**\n * The type of navigation that this component should support.\n * - \"arrow-keys\" for items that are navigated with UP/DOWN keys.\n * - \"tab\" for items that are navigated using the TAB key.\n * - \"none\" for static items that are not interactive.\n * @values arrow-keys, tab, none\n */\n navigationType: {\n type: String,\n default: LIST_ITEM_NAVIGATION_TYPES.ARROW_KEYS,\n validator: (t) => Object.values(LIST_ITEM_NAVIGATION_TYPES).includes(t),\n },\n\n /**\n * If the dropdown does not fit in the direction described by \"placement\",\n * it will attempt to change it's direction to the \"fallbackPlacements\".\n *\n * @values top, top-start, top-end,\n * right, right-start, right-end,\n * left, left-start, left-end,\n * bottom, bottom-start, bottom-end,\n * auto, auto-start, auto-end\n * */\n fallbackPlacements: {\n type: Array,\n default: () => {\n return ['auto'];\n },\n },\n\n /**\n * The direction the dropdown displays relative to the anchor.\n */\n placement: {\n type: String,\n default: 'bottom',\n },\n\n /**\n * A method that will be called when the selection goes past the beginning of the list.\n */\n onBeginningOfList: {\n type: Function,\n default: null,\n },\n\n /**\n * A method that will be called when the selection goes past the end of the list.\n */\n onEndOfList: {\n type: Function,\n default: null,\n },\n\n /**\n * Additional class for the wrapper list element.\n */\n listClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Sets the element to which the popover is going to append to.\n * 'body' will append to the nearest body (supports shadow DOM).\n * @values 'body', 'parent', HTMLElement,\n */\n appendTo: {\n type: [HTML_ELEMENT_TYPE, String],\n default: 'body',\n validator: appendTo => {\n return POPOVER_APPEND_TO_VALUES.includes(appendTo) ||\n (appendTo instanceof HTMLElement);\n },\n },\n\n /**\n * If set to false the dialog will display over top of the anchor when there is insufficient space.\n * If set to true it will never move from its position relative to the anchor and will clip instead.\n * <a\n * class=\"d-link\"\n * href=\"https://popper.js.org/docs/v2/modifiers/prevent-overflow/#tether\"\n * target=\"_blank\"\n * >\n * Popper.js docs\n * </a>\n * @values true, false\n */\n tether: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Named transition when the content display is toggled.\n * @see DtLazyShow\n */\n transition: {\n type: String,\n default: 'fade',\n },\n },\n\n emits: [\n /**\n * Native keydown event\n *\n * @event keydown\n * @type {KeyboardEvent}\n */\n 'keydown',\n\n /**\n * Event fired when the highlight changes\n *\n * @event highlight\n * @type {Number}\n */\n 'highlight',\n\n /**\n * Event fired to sync the open prop with the parent component\n * @event update:open\n */\n 'update:open',\n\n /**\n * Event fired when dropdown is shown or hidden\n *\n * @event opened\n * @type {Boolean | Array}\n */\n 'opened',\n ],\n\n data () {\n return {\n LIST_ITEM_NAVIGATION_TYPES,\n DROPDOWN_PADDING_CLASSES,\n EVENT_KEYNAMES,\n openedWithKeyboard: false,\n isOpen: null,\n };\n },\n\n computed: {\n dropdownListeners () {\n return {\n\n 'update:open': value => {\n this.$emit('update:open', value);\n },\n\n opened: isPopoverOpen => {\n this.updateInitialHighlightIndex(isPopoverOpen);\n },\n\n keydown: event => {\n const eventCode = event.code;\n\n switch (eventCode) {\n case EVENT_KEYNAMES.up:\n case EVENT_KEYNAMES.arrowup:\n this.onUpKeyPress(event);\n event.stopPropagation();\n event.preventDefault();\n break;\n case EVENT_KEYNAMES.down:\n case EVENT_KEYNAMES.arrowdown:\n this.onDownKeyPress(event);\n event.stopPropagation();\n event.preventDefault();\n break;\n case EVENT_KEYNAMES.space:\n case EVENT_KEYNAMES.spacebar:\n this.onSpaceKey();\n break;\n case EVENT_KEYNAMES.enter:\n this.onEnterKey();\n break;\n case EVENT_KEYNAMES.home:\n this.onHomeKeyPress(event);\n event.stopPropagation();\n event.preventDefault();\n break;\n case EVENT_KEYNAMES.end:\n this.onEndKeyPress(event);\n event.stopPropagation();\n event.preventDefault();\n break;\n default:\n this.onKeyPress(event);\n break;\n }\n\n this.$emit('keydown', event);\n },\n };\n },\n\n beginningOfListMethod () {\n return this.onBeginningOfList || this.jumpToEnd;\n },\n\n endOfListMethod () {\n return this.onEndOfList || this.jumpToBeginning;\n },\n\n activeItemEl () {\n return this.getListElement().querySelector('#' + this.highlightId);\n },\n\n isArrowKeyNav () {\n return this.navigationType === this.LIST_ITEM_NAVIGATION_TYPES.ARROW_KEYS;\n },\n\n listClasses () {\n return [\n 'd-dropdown-list',\n DROPDOWN_PADDING_CLASSES[this.padding],\n this.listClass,\n { 'd-context-menu-list': this.openOnContext },\n ];\n },\n\n shouldOpenWithArrowKeys () {\n return !this.openOnContext;\n },\n },\n\n methods: {\n onMouseHighlight (e) {\n const liElement = e.target.closest('li');\n\n if (liElement && liElement.role && this.highlightId !== liElement.id) {\n this.setHighlightId(liElement.id);\n liElement.focus();\n }\n },\n\n getListElement () {\n return this.$refs.listWrapper;\n },\n\n clearHighlightIndex () {\n this.setHighlightIndex(-1);\n },\n\n afterHighlight () {\n if (this.highlightIndex === this._itemsLength() - 1) {\n return;\n }\n\n this.$emit('highlight', this.highlightIndex);\n },\n\n updateInitialHighlightIndex (isPopoverOpen) {\n this.isOpen = isPopoverOpen;\n\n if (isPopoverOpen) {\n if (this.openedWithKeyboard && this.isArrowKeyNav) {\n this.setHighlightIndex(0);\n }\n this.$emit('opened', true);\n } else {\n this.clearHighlightIndex();\n this.openedWithKeyboard = false;\n this.$emit('opened', false);\n }\n },\n\n onSpaceKey () {\n if (!this.open) {\n this.openedWithKeyboard = true;\n }\n },\n\n onEnterKey () {\n if (!this.open) {\n this.openedWithKeyboard = true;\n }\n },\n\n onUpKeyPress () {\n if (!this.isOpen) {\n this.openedWithKeyboard = true;\n return;\n }\n if (this.isArrowKeyNav) {\n return this.onUpKey();\n }\n },\n\n onDownKeyPress () {\n if (!this.isOpen) {\n this.openedWithKeyboard = true;\n return;\n }\n if (this.isArrowKeyNav) {\n return this.onDownKey();\n }\n },\n\n onHomeKeyPress () {\n if (!this.isOpen || !this.isArrowKeyNav) {\n return;\n }\n\n return this.onHomeKey();\n },\n\n onEndKeyPress () {\n if (!this.isOpen || !this.isArrowKeyNav) {\n return;\n }\n\n return this.onEndKey();\n },\n\n onKeyPress (e) {\n if (!this.isOpen || !this.isArrowKeyNav || !this.isValidLetter(e.key)) {\n return;\n }\n\n e.stopPropagation();\n e.preventDefault();\n\n return this.onNavigationKey(e.key);\n },\n },\n};\n</script>\n"],"mappings":";;;;;;;;;;AAkEA,IAAK,IAAU;CACb,cAAc,EAAE,MAAM,GAAG;CACzB,MAAM;CAEN,YAAY,EACV,WAAA,GACD;CAED,QAAQ,CACN,EAAmB;EACjB,UAAU;EACV,OAAO;EACP,gBAAgB;EAChB,cAAc;EACd,sBAAsB;EACtB,uBAAuB;EACvB,iBAAiB;EACjB,eAAe;EACf,2BAA2B;EAC5B,CAAC,CACH;CAED,cAAc;CAEd,OAAO;EAML,MAAM;GACJ,MAAM;GACN,SAAS;GACV;EAMD,eAAe;GACb,MAAM;GACN,SAAS;GACV;EAMD,SAAS;GACP,MAAM;GACN,SAAS;GACT,YAAY,MACH,OAAO,KAAK,EAAyB,CAAC,MAAM,MAAS,MAAS,EAAQ;GAEhF;EAMD,OAAO;GACL,MAAM;GACN,SAAS;GACV;EAOD,cAAc;GACZ,MAAM;GACN,SAAS;GACV;EAMD,WAAW;GACT,MAAM;GACN,SAAS;GACV;EAMD,UAAU;GACR,MAAM;GACN,SAAS;GACV;EAMD,QAAQ;GACN,MAAM;GACN,UAAW;AAAE,WAAO,GAAiB;;GACtC;EASD,gBAAgB;GACd,MAAM;GACN,SAAS,EAA2B;GACpC,YAAY,MAAM,OAAO,OAAO,EAA2B,CAAC,SAAS,EAAE;GACxE;EAYD,oBAAoB;GAClB,MAAM;GACN,eACS,CAAC,OAAO;GAElB;EAKD,WAAW;GACT,MAAM;GACN,SAAS;GACV;EAKD,mBAAmB;GACjB,MAAM;GACN,SAAS;GACV;EAKD,aAAa;GACX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AAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../../chunk-Bmb41Sf3.cjs`);const e=require(`../../common/utils/index.cjs`),t=require(`../../_plugin-vue_export-helper-D8jCH6HB.cjs`),n=require(`../../localization/index.cjs`),r=require(`../button/button.cjs`),i=require(`../list-item/list-item.cjs`),a=require(`../../combobox-DhjZxfUw.cjs`),o=require(`../stack/stack.cjs`),s=require(`../tooltip/tooltip.cjs`),c=require(`../popover/popover.cjs`),l=require(`../dropdown/dropdown-separator.cjs`),u=require(`../input/input.cjs`),d=require(`../list-item-group/list-item-group.cjs`),f=require(`../../rich_text_editor-DRytK1_9.cjs`),p=require(`../rich-text-editor/rich-text-editor-constants.cjs`),m=require(`./editor-constants.cjs`),h=require(`./EditorToolbarButton.cjs`),g=require(`./EditorToolbarDropdownButton.cjs`),_=require(`./EditorToolbarPopoverButton.cjs`);let v=require(`vue`),y=require(`@dialpad/dialtone-icons/vue3`);var b={compatConfig:{MODE:3},name:`DtRecipeEditor`,components:{DtListItemGroup:d.default,DtDropdownSeparator:l.default,DtListItem:i.default,DtRichTextEditor:f.t,DtButton:r.default,DtPopover:c.default,DtStack:o.default,DtInput:u.default,DtTooltip:s.default,DtCombobox:a.t,EditorToolbarButton:h.default,EditorToolbarDropdownButton:g.default,EditorToolbarPopoverButton:_.default,DtIconQuickReply:y.DtIconQuickReply,DtIconBold:y.DtIconBold,DtIconItalic:y.DtIconItalic,DtIconUnderline:y.DtIconUnderline,DtIconStrikethrough:y.DtIconStrikethrough,DtIconListBullet:y.DtIconListBullet,DtIconListOrdered:y.DtIconListOrdered,DtIconAlignLeft:y.DtIconAlignLeft,DtIconAlignCenter:y.DtIconAlignCenter,DtIconAlignRight:y.DtIconAlignRight,DtIconAlignJustify:y.DtIconAlignJustify,DtIconQuote:y.DtIconQuote,DtIconCodeBlock:y.DtIconCodeBlock,DtIconLink2:y.DtIconLink2,DtIconImage:y.DtIconImage,DtIconSearch:y.DtIconSearch,DtIconType:y.DtIconType,DtIconBraces:y.DtIconBraces,DtIconChevronDown:y.DtIconChevronDown,DtIconFontSize:y.DtIconFontSize,DtIconStopFilled:y.DtIconStopFilled},mixins:[],inheritAttrs:!1,props:{modelValue:{type:[Object,String],default:``},editable:{type:Boolean,default:!0},inputAriaLabel:{type:String,required:!0,default:``},inputClass:{type:String,default:``},autoFocus:{type:[Boolean,String,Number],default:!1,validator(e){return typeof e==`string`?p.RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(e):!0}},placeholder:{type:String,default:``},maxHeight:{type:String,default:`unset`},setLinkPlaceholder:{type:String,default:``},showBoldButton:{type:Boolean,default:!0},showItalicsButton:{type:Boolean,default:!0},showUnderlineButton:{type:Boolean,default:!0},showStrikeButton:{type:Boolean,default:!0},showListItemsButton:{type:Boolean,default:!0},showOrderedListButton:{type:Boolean,default:!0},showAlignLeftButton:{type:Boolean,default:!0},showAlignCenterButton:{type:Boolean,default:!0},showAlignRightButton:{type:Boolean,default:!0},showAlignJustifyButton:{type:Boolean,default:!0},showQuoteButton:{type:Boolean,default:!0},showCodeBlockButton:{type:Boolean,default:!0},showQuickRepliesButton:{type:Boolean,default:!0},showInlineImageButton:{type:Boolean,default:!1},showVariableButton:{type:Boolean,default:!1},variableCategories:{type:Array,default:()=>[]},showAddLink:{type:Object,default:()=>({showAddLinkButton:!0})},showFontStyleButton:{type:Boolean,default:!1},showFontSizeButton:{type:Boolean,default:!1},showFontColorButton:{type:Boolean,default:!1},fontStyles:{type:Array,default:()=>[{name:`Arial`,value:null},{name:`Georgia`,value:`Georgia`},{name:`Helvetica`,value:`Helvetica`},{name:`Verdana`,value:`Verdana`},{name:`Times New Roman`,value:`Times New Roman`}]},fontSizes:{type:Array,default:()=>[{name:`Small`,value:`12px`},{name:`Normal`,value:`15px`},{name:`Large`,value:`24px`},{name:`Huge`,value:`36px`}]},allowBackgroundColor:{type:Boolean,default:!1},allowLineHeight:{type:Boolean,default:!1},preserveWhitespace:{type:[Boolean,String],default:`full`},useDivTags:{type:Boolean,default:!1},allowTables:{type:Boolean,default:!1},allowImageResize:{type:Boolean,default:!1}},emits:[`focus`,`blur`,`input`,`update:modelValue`,`quick-replies-click`,`inline-image-click`,`text-input`],data(){return{internalInputValue:this.modelValue,hasFocus:!1,linkOptions:{class:`d-recipe-editor__link`},currentFontColor:void 0,showLinkInput:!1,fontStyleSearch:``,linkInput:``,currentButtonRefIndex:0,variableSearchValue:``,i18n:new n.DialtoneLocalization}},computed:{inputLength(){return this.internalInputValue.length},htmlOutputFormat(){return p.RICH_TEXT_EDITOR_OUTPUT_FORMATS[2]},flattenedVariableItems(){return this.variableCategories?this.variableCategories.reduce((e,t)=>e.concat(t.items||[]),[]):[]},showingTextFormatButtons(){return this.showBoldButton||this.showItalicsButton||this.showStrikeButton||this.showUnderlineButton},showingAlignmentButtons(){return this.showAlignLeftButton||this.showAlignCenterButton||this.showAlignRightButton||this.showAlignJustifyButton},showingListButtons(){return this.showListItemsButton||this.showOrderedListButton},orderedRefs(){let e=this.buttonGroups.reduce(function(e,t){return t.buttonGroup.forEach(n=>{e.push(this.getButtonRef(t.key,n.selector))},this),e}.bind(this),[]);return e.push(this.getButtonRef(`custom`,`link`)),e},buttonGroups(){let e=this.individualButtons.map(e=>({key:e.selector,buttonGroup:[e]}));return[{key:`new`,buttonGroup:this.newButtons},{key:`format`,buttonGroup:this.textFormatButtons},{key:`alignment`,buttonGroup:this.alignmentButtons},{key:`list`,buttonGroup:this.listButtons},...e].filter(e=>e.buttonGroup.length>0)},newButtons(){return[{showBtn:this.showQuickRepliesButton,buttonType:`button`,label:this.i18n.$t(`DIALTONE_EDITOR_QUICK_REPLY_BUTTON_LABEL`),selector:`quickReplies`,icon:y.DtIconQuickReply,dataQA:`dt-recipe-editor-quick-replies-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_QUICK_REPLY_BUTTON_LABEL`),onClick:this.onQuickRepliesClick}].filter(e=>e.showBtn)},textFormatButtons(){return[{showBtn:this.showFontStyleButton,buttonType:`popover`,selector:`fontStyle`,icon:y.DtIconType,dataQA:`dt-recipe-editor-font-style-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_FONT_STYLE_BUTTON_LABEL`)},{showBtn:this.showFontSizeButton,buttonType:`popover`,selector:`fontSize`,icon:y.DtIconFontSize,dataQA:`dt-recipe-editor-font-size-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_FONT_SIZE_BUTTON_LABEL`)},{showBtn:this.showFontColorButton,buttonType:`custom`,selector:`fontColor`,icon:y.DtIconStopFilled,dataQA:`dt-recipe-editor-font-color-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_FONT_COLOR_BUTTON_LABEL`),onClick:this.onColorPickerButtonClick},{showBtn:this.showBoldButton,buttonType:`button`,selector:`bold`,icon:y.DtIconBold,dataQA:`dt-recipe-editor-bold-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_BOLD_BUTTON_LABEL`),onClick:this.onBoldTextToggle},{showBtn:this.showItalicsButton,buttonType:`button`,selector:`italic`,icon:y.DtIconItalic,dataQA:`dt-recipe-editor-italics-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_ITALICS_BUTTON_LABEL`),onClick:this.onItalicTextToggle},{showBtn:this.showUnderlineButton,buttonType:`button`,selector:`underline`,icon:y.DtIconUnderline,dataQA:`dt-recipe-editor-underline-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_UNDERLINE_BUTTON_LABEL`),onClick:this.onUnderlineTextToggle},{showBtn:this.showStrikeButton,buttonType:`button`,selector:`strike`,icon:y.DtIconStrikethrough,dataQA:`dt-recipe-editor-strike-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_STRIKE_BUTTON_LABEL`),onClick:this.onStrikethroughTextToggle}].filter(e=>e.showBtn)},alignmentButtons(){return[{showBtn:this.showAlignLeftButton,buttonType:`button`,selector:{textAlign:`left`},icon:y.DtIconAlignLeft,dataQA:`dt-recipe-editor-align-left-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_ALIGN_LEFT_BUTTON_LABEL`),onClick:()=>this.onTextAlign(`left`)},{showBtn:this.showAlignCenterButton,buttonType:`button`,selector:{textAlign:`center`},icon:y.DtIconAlignCenter,dataQA:`dt-recipe-editor-align-center-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_ALIGN_CENTER_BUTTON_LABEL`),onClick:()=>this.onTextAlign(`center`)},{showBtn:this.showAlignRightButton,buttonType:`button`,selector:{textAlign:`right`},icon:y.DtIconAlignRight,dataQA:`dt-recipe-editor-align-right-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_ALIGN_RIGHT_BUTTON_LABEL`),onClick:()=>this.onTextAlign(`right`)},{showBtn:this.showAlignJustifyButton,buttonType:`button`,selector:{textAlign:`justify`},icon:y.DtIconAlignJustify,dataQA:`dt-recipe-editor-align-justify-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_ALIGN_JUSTIFY_BUTTON_LABEL`),onClick:()=>this.onTextAlign(`justify`)}].filter(e=>e.showBtn)},listButtons(){return[{showBtn:this.showListItemsButton,buttonType:`button`,selector:`bulletList`,icon:y.DtIconListBullet,dataQA:`dt-recipe-editor-list-items-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_BULLET_LIST_BUTTON_LABEL`),onClick:this.onBulletListToggle},{showBtn:this.showOrderedListButton,buttonType:`button`,selector:`orderedList`,icon:y.DtIconListOrdered,dataQA:`dt-recipe-editor-ordered-list-items-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_ORDERED_LIST_BUTTON_LABEL`),onClick:this.onOrderedListToggle}].filter(e=>e.showBtn)},individualButtons(){return[{showBtn:this.showQuoteButton,buttonType:`button`,selector:`blockquote`,icon:y.DtIconQuote,dataQA:`dt-recipe-editor-blockquote-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_QUOTE_BUTTON_LABEL`),onClick:this.onBlockquoteToggle},{showBtn:this.showCodeBlockButton,buttonType:`button`,selector:`codeBlock`,icon:y.DtIconCodeBlock,dataQA:`dt-recipe-editor-code-block-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_CODE_BUTTON_LABEL`),onClick:this.onCodeBlockToggle},{showBtn:this.showInlineImageButton,buttonType:`button`,selector:`image`,icon:y.DtIconImage,dataQA:`dt-recipe-editor-inline-image-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_IMAGE_BUTTON_LABEL`),onClick:this.onInsertInlineImageClick},{showBtn:this.showVariableButton,buttonType:`popover`,selector:`variable`,icon:y.DtIconBraces,dataQA:`dt-recipe-editor-variable-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_VARIABLE_BUTTON_LABEL`)}].filter(e=>e.showBtn)},linkButton(){return{showBtn:this.showAddLink.showAddLinkButton,buttonType:`custom`,selector:`link`,icon:y.DtIconLink2,dataQA:`dt-recipe-editor-add-link-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_LINK_BUTTON_LABEL`),onClick:this.openLinkInput}},confirmSetLinkButtonLabels(){return this.i18n.$ta(`DIALTONE_EDITOR_CONFIRM_SET_LINK_BUTTON`)},cancelSetLinkButtonLabels(){return this.i18n.$ta(`DIALTONE_EDITOR_CANCEL_SET_LINK_BUTTON`)},removeLinkButtonLabels(){return this.i18n.$ta(`DIALTONE_EDITOR_REMOVE_LINK_BUTTON`)},showAddLinkButtonLabels(){return this.i18n.$ta(`DIALTONE_EDITOR_ADD_LINK_BUTTON`)},filteredFontStyles(){let e=this.fontStyleSearch.toLowerCase();return this.fontStyles.filter(t=>t.name.toLowerCase().includes(e))},filteredCategories(){return this.variableCategories.filter(e=>this.getFilteredItemsForCategory(e).length)},colorPickerInput(){return this.$refs.editorRoot?.querySelector(`.colorPickerInput`)},isDefaultFontColor(){return this.currentFontColor===m.EDITOR_DEFAULT_FONT_COLOR},actionBarBtn(){let e=this.$refs[this.orderedRefs[this.currentButtonRefIndex]][0]?.$refs?.buttonRef||this.$refs[this.orderedRefs[this.currentButtonRefIndex]];return Array.isArray(e)?e[0]:e}},watch:{modelValue(e){this.internalInputValue=e}},methods:{removeClassStyleAttrs:e.removeClassStyleAttrs,addClassStyleAttrs:e.addClassStyleAttrs,focusEditor(){this.$refs.richTextEditor?.editor?.commands.focus()},onInputFocus(e){e?.stopPropagation()},removeLink(){this.$refs.richTextEditor?.editor?.chain()?.focus()?.unsetLink()?.run(),this.closeLinkInput()},setLink(e){let t=this.$refs.richTextEditor?.editor;if(e?.preventDefault(),e?.stopPropagation(),!this.linkInput){this.removeLink();return}m.EDITOR_SUPPORTED_LINK_PROTOCOLS.find(e=>e.test(this.linkInput))||(this.linkInput=`${m.EDITOR_DEFAULT_LINK_PREFIX}${this.linkInput}`);let n=t?.view?.state?.selection;n.anchor===n.head?t.chain().focus().insertContentAt(n.anchor,`<a class="${this.linkOptions.class}" href=${this.linkInput}>${this.linkInput}</a>`).run():t.chain().focus().extendMarkRange(`link`).setLink({href:this.linkInput,class:this.linkOptions.class}).run(),this.closeLinkInput()},openLinkInput(){this.showLinkInput=!0},updateInput(e){if(!e)return this.closeLinkInput();this.linkInput=this.$refs.richTextEditor?.editor?.getAttributes(`link`)?.href},closeLinkInput(){this.showLinkInput=!1,this.linkInput=``,this.$refs.richTextEditor.editor?.chain().focus()},onBoldTextToggle(){this.$refs.richTextEditor?.editor?.chain().focus().toggleBold().run()},onItalicTextToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleItalic().run()},onUnderlineTextToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleUnderline().run()},onStrikethroughTextToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleStrike().run()},onTextAlign(e){if(this.$refs.richTextEditor?.editor?.isActive({textAlign:e}))return this.$refs.richTextEditor?.editor.chain().focus().unsetTextAlign().run();this.$refs.richTextEditor?.editor.chain().focus().setTextAlign(e).run()},onBulletListToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleBulletList().run()},onOrderedListToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleOrderedList().run()},onCodeBlockToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleCodeBlock().run()},onQuickRepliesClick(){this.$emit(`quick-replies-click`)},onInsertInlineImageClick(){this.$emit(`inline-image-click`)},insertVariable(e,t){this.$refs.richTextEditor?.editor.chain().focus().insertVariable({id:t.id,placeholder:t.placeholder||``,altText:``,enableAltText:t.enableAltText}).run()},insertInlineImage(e){this.$refs.richTextEditor?.editor.chain().focus().setImage({src:e}).run()},insertInMessageBody(e){this.$refs.richTextEditor?.editor.chain().focus().insertContent(e).run()},setCursorPosition(e=null){this.$refs.richTextEditor?.editor.chain().focus(e).run()},onBlockquoteToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleBlockquote().run()},onTextInput(e){this.$emit(`text-input`,e)},onFocus(e){this.hasFocus=!0,this.$emit(`focus`,e)},onBlur(e){this.hasFocus=!1,this.$emit(`blur`,e)},onInput(e){this.$emit(`input`,e),this.$emit(`update:modelValue`,e)},onSelected(){this.updateFontColorInput()},getButtonKey(e,t){return`${e}-${JSON.stringify(t)}`},getButtonRef(e,t){return`${this.getButtonKey(e,t)}-ref`},canFocus(e){return e===this.orderedRefs[this.currentButtonRefIndex]},shiftActionBarFocusRight(){this.shiftButtonRefIndex(1)},shiftActionBarFocusLeft(){this.shiftButtonRefIndex(-1)},shiftButtonRefIndex(e){let t=this.actionBarBtn,n=(this.currentButtonRefIndex+e)%this.orderedRefs.length;this.currentButtonRefIndex=n>=0?n:this.orderedRefs.length+n;let r=this.actionBarBtn;t.$el.blur(),r.$el.focus()},onFontStyleSelect(e){e?this.$refs.richTextEditor?.editor?.chain().focus().setFontFamily(e).run():this.$refs.richTextEditor?.editor?.chain().focus().unsetFontFamily().run(),this.$refs.richTextEditor?.editor?.commands.focus()},isCurrentFontFamily(e){return e?this.$refs.richTextEditor?.editor?.isActive(`textStyle`,{fontFamily:e}):!this.$refs.richTextEditor?.editor?.getAttributes(`textStyle`)?.fontFamily},onFontSizeSelect(e){this.$refs.richTextEditor?.editor?.chain().focus().setFontSize(e).run(),this.$refs.richTextEditor?.editor?.commands.focus()},isCurrentFontSize(e){return e?this.$refs.richTextEditor?.editor?.isActive(`textStyle`,{fontSize:e}):!this.$refs.richTextEditor?.editor?.getAttributes(`textStyle`)?.fontSize},getFilteredItemsForCategory(e){let t=this.variableSearchValue.toLowerCase();return e.name.toLowerCase().includes(t)?e.items:e.items.filter(e=>e.name.toLowerCase().includes(t))},updateFontColorInput(){this.currentFontColor=this.$refs.richTextEditor?.editor?.getAttributes(`textStyle`)?.color||`#000000`},onColorPickerButtonClick(){this.colorPickerInput?.click()},onColorPickerInput(e){this.$refs.richTextEditor?.editor?.chain().focus().setColor(e).run(),this.$refs.richTextEditor?.editor?.commands.focus(),this.updateFontColorInput()}}},x={class:`d-recipe-editor__popover-content`};function S(e,t,n,r,i,a){let o=(0,v.resolveComponent)(`dt-icon-search`),s=(0,v.resolveComponent)(`dt-input`),c=(0,v.resolveComponent)(`dt-list-item`),l=(0,v.resolveComponent)(`dt-combobox`),u=(0,v.resolveComponent)(`editor-toolbar-popover-button`),d=(0,v.resolveComponent)(`editor-toolbar-dropdown-button`),f=(0,v.resolveComponent)(`dt-button`),p=(0,v.resolveComponent)(`dt-dropdown-separator`),m=(0,v.resolveComponent)(`dt-list-item-group`),h=(0,v.resolveComponent)(`editor-toolbar-button`),g=(0,v.resolveComponent)(`dt-stack`),_=(0,v.resolveComponent)(`dt-tooltip`),y=(0,v.resolveComponent)(`dt-popover`),b=(0,v.resolveComponent)(`dt-rich-text-editor`),S=(0,v.resolveDirective)(`dt-tooltip`);return(0,v.openBlock)(),(0,v.createElementBlock)(`div`,(0,v.mergeProps)({ref:`editorRoot`,class:`d-recipe-editor`},a.addClassStyleAttrs(e.$attrs),{"data-qa":`dt-recipe-editor`,role:`presentation`,onClick:t[7]||(t[7]=t=>e.$refs.richTextEditor.focusEditor())}),[(0,v.createVNode)(g,{class:`d-recipe-editor__top-bar`,direction:`row`,gap:`450`},{default:(0,v.withCtx)(()=>[((0,v.openBlock)(!0),(0,v.createElementBlock)(v.Fragment,null,(0,v.renderList)(a.buttonGroups,r=>((0,v.openBlock)(),(0,v.createBlock)(g,{key:r.key,direction:`row`,gap:`300`},{default:(0,v.withCtx)(()=>[((0,v.openBlock)(!0),(0,v.createElementBlock)(v.Fragment,null,(0,v.renderList)(r.buttonGroup,g=>((0,v.openBlock)(),(0,v.createElementBlock)(v.Fragment,null,[g.buttonType===`popover`&&g.selector===`fontStyle`?((0,v.openBlock)(),(0,v.createBlock)(u,{key:a.getButtonKey(r.key,g.selector),ref_for:!0,ref:a.getButtonRef(r.key,g.selector),"is-active":e.$refs.richTextEditor?.editor?.isActive(g.selector),"tooltip-message":g.tooltipMessage,"data-qa":g.dataQA,"popover-data-qa":`dt-recipe-editor-font-style-input-popover`,tabindex:a.canFocus(a.getButtonRef(r.key,g.selector))?0:-1,icon:g.icon,onShiftFocusRight:a.shiftActionBarFocusRight,onShiftFocusLeft:a.shiftActionBarFocusLeft},{content:(0,v.withCtx)(({close:e})=>[(0,v.createVNode)(l,{label:``,"label-visible":!1,"show-list":!0,"click-on-select":!0,onEscape:t=>e()},{input:(0,v.withCtx)(({inputProps:e})=>[(0,v.createVNode)(s,(0,v.mergeProps)({ref_for:!0},e,{modelValue:i.fontStyleSearch,"onUpdate:modelValue":t[0]||(t[0]=e=>i.fontStyleSearch=e),"root-class":`d-p8 d-pb4 d-w216`,type:`search`,placeholder:i.i18n.$t(`DIALTONE_EDITOR_FONT_STYLE_SEARCH_PLACEHOLDER`),size:`sm`,role:`menuitem`}),{leftIcon:(0,v.withCtx)(({iconSize:e})=>[(0,v.createVNode)(o,{size:e},null,8,[`size`])]),_:1},16,[`modelValue`,`placeholder`])]),list:(0,v.withCtx)(({listProps:t})=>[(0,v.createElementVNode)(`ul`,(0,v.mergeProps)({ref_for:!0},t),[((0,v.openBlock)(!0),(0,v.createElementBlock)(v.Fragment,null,(0,v.renderList)(a.filteredFontStyles,t=>((0,v.openBlock)(),(0,v.createBlock)(c,{key:t.name,selected:a.isCurrentFontFamily(t.value),style:(0,v.normalizeStyle)({fontFamily:t.value||`inherit`}),role:`option`,"navigation-type":`arrow-keys`,onClick:n=>{e(a.focusEditor),a.onFontStyleSelect(t.value)}},{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(t.name),1)]),_:2},1032,[`selected`,`style`,`onClick`]))),128))],16)]),_:2},1032,[`onEscape`])]),_:1},8,[`is-active`,`tooltip-message`,`data-qa`,`tabindex`,`icon`,`onShiftFocusRight`,`onShiftFocusLeft`])):g.buttonType===`popover`&&g.selector===`fontSize`?((0,v.openBlock)(),(0,v.createBlock)(d,{key:a.getButtonKey(r.key,g.selector),ref_for:!0,ref:a.getButtonRef(r.key,g.selector),"is-active":e.$refs.richTextEditor?.editor?.isActive(g.selector),"tooltip-message":g.tooltipMessage,"data-qa":g.dataQA,"dropdown-data-qa":`dt-recipe-editor-font-size-input-popover`,tabindex:a.canFocus(a.getButtonRef(r.key,g.selector))?0:-1,icon:g.icon,onShiftFocusRight:a.shiftActionBarFocusRight,onShiftFocusLeft:a.shiftActionBarFocusLeft},{list:(0,v.withCtx)(({close:e})=>[((0,v.openBlock)(!0),(0,v.createElementBlock)(v.Fragment,null,(0,v.renderList)(n.fontSizes,t=>((0,v.openBlock)(),(0,v.createBlock)(c,{key:t.name,selected:a.isCurrentFontSize(t.value),role:`menuitem`,"navigation-type":`arrow-keys`,onClick:n=>{e(a.focusEditor),a.onFontSizeSelect(t.value,n)}},{default:(0,v.withCtx)(()=>[(0,v.createElementVNode)(`span`,{style:(0,v.normalizeStyle)({fontSize:t.value})},(0,v.toDisplayString)(t.name),5)]),_:2},1032,[`selected`,`onClick`]))),128))]),_:1},8,[`is-active`,`tooltip-message`,`data-qa`,`tabindex`,`icon`,`onShiftFocusRight`,`onShiftFocusLeft`])):g.buttonType===`custom`&&g.selector===`fontColor`?(0,v.withDirectives)(((0,v.openBlock)(),(0,v.createBlock)(f,{key:a.getButtonKey(r.key,g.selector),ref_for:!0,ref:a.getButtonRef(r.key,g.selector),kind:`muted`,importance:`clear`,size:`xs`,active:e.$refs.richTextEditor?.editor?.isActive(g.selector),tabindex:a.canFocus(a.getButtonRef(r.key,g.selector))?0:-1,"aria-label":g.tooltipMessage,"data-qa":g.dataQA,onKeydown:[(0,v.withKeys)((0,v.withModifiers)(a.shiftActionBarFocusRight,[`stop`]),[`right`]),(0,v.withKeys)((0,v.withModifiers)(a.shiftActionBarFocusLeft,[`stop`]),[`left`])],onClick:e=>g.onClick()},{icon:(0,v.withCtx)(()=>[((0,v.openBlock)(),(0,v.createBlock)((0,v.resolveDynamicComponent)(g.icon),{size:`200`,style:(0,v.normalizeStyle)(a.isDefaultFontColor?{}:{color:i.currentFontColor})},null,8,[`style`])),(0,v.createVNode)(s,{value:i.currentFontColor,"root-class":`d-w0 d-h0 d-of-hidden`,"input-class":`colorPickerInput d-w0 d-h0 d-p0 d-bar0`,"input-wrapper-class":`d-w0 d-h0 d-ba-none`,size:`sm`,type:`color`,onInput:a.onColorPickerInput,onClick:t[1]||(t[1]=(0,v.withModifiers)(()=>{},[`stop`]))},null,8,[`value`,`onInput`])]),_:2},1032,[`active`,`tabindex`,`aria-label`,`data-qa`,`onKeydown`,`onClick`])),[[S,{message:g.tooltipMessage,placement:`top`,externalAnchorElement:e.$refs[a.getButtonRef(r.key,g.selector)]?.$el}]]):g.buttonType===`popover`&&g.selector===`variable`?((0,v.openBlock)(),(0,v.createBlock)(u,{key:a.getButtonKey(r.key,g.selector),ref_for:!0,ref:a.getButtonRef(r.key,g.selector),"is-active":!1,"tooltip-message":g.tooltipMessage,"data-qa":g.dataQA,"popover-data-qa":`dt-recipe-editor-variable-popover`,tabindex:a.canFocus(a.getButtonRef(r.key,g.selector))?0:-1,icon:g.icon,onShiftFocusRight:a.shiftActionBarFocusRight,onShiftFocusLeft:a.shiftActionBarFocusLeft},{content:(0,v.withCtx)(({close:e})=>[(0,v.createVNode)(l,{label:``,"label-visible":!1,"show-list":!0,"click-on-select":!0,onEscape:t=>e()},{input:(0,v.withCtx)(({inputProps:e})=>[(0,v.createVNode)(s,(0,v.mergeProps)({ref_for:!0},e,{modelValue:i.variableSearchValue,"onUpdate:modelValue":t[2]||(t[2]=e=>i.variableSearchValue=e),"root-class":`d-p8 d-pb4 d-w264`,type:`search`,placeholder:i.i18n.$t(`DIALTONE_EDITOR_VARIABLE_POPOVER_SEARCH_PLACEHOLDER`),size:`md`,role:`menuitem`}),{leftIcon:(0,v.withCtx)(({iconSize:e})=>[(0,v.createVNode)(o,{size:e},null,8,[`size`])]),_:1},16,[`modelValue`,`placeholder`])]),list:(0,v.withCtx)(({listProps:t})=>[(0,v.createElementVNode)(`div`,(0,v.mergeProps)({ref_for:!0},t),[((0,v.openBlock)(!0),(0,v.createElementBlock)(v.Fragment,null,(0,v.renderList)(a.filteredCategories,(t,n)=>((0,v.openBlock)(),(0,v.createBlock)(m,{key:t.name,heading:t.name,"heading-class":`d-headline--sm-compact d-p8`},{default:(0,v.withCtx)(()=>[((0,v.openBlock)(!0),(0,v.createElementBlock)(v.Fragment,null,(0,v.renderList)(a.getFilteredItemsForCategory(t),n=>((0,v.openBlock)(),(0,v.createBlock)(c,{key:t.name+n.name,role:`option`,"navigation-type":`arrow-keys`,onClick:r=>{a.insertVariable(t.name,n),e(a.focusEditor)}},{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(n.name),1)]),_:2},1032,[`onClick`]))),128)),n<a.filteredCategories.length-1?((0,v.openBlock)(),(0,v.createBlock)(p,{key:0})):(0,v.createCommentVNode)(``,!0)]),_:2},1032,[`heading`]))),128))],16)]),_:2},1032,[`onEscape`])]),_:1},8,[`tooltip-message`,`data-qa`,`tabindex`,`icon`,`onShiftFocusRight`,`onShiftFocusLeft`])):g.buttonType===`button`?((0,v.openBlock)(),(0,v.createBlock)(h,{key:a.getButtonKey(r.key,g.selector),ref_for:!0,ref:a.getButtonRef(r.key,g.selector),"is-active":e.$refs.richTextEditor?.editor?.isActive(g.selector),"tooltip-message":g.tooltipMessage,"data-qa":g.dataQA,tabindex:a.canFocus(a.getButtonRef(r.key,g.selector))?0:-1,icon:g.icon,label:g.label,"on-click":g.onClick,onShiftFocusRight:a.shiftActionBarFocusRight,onShiftFocusLeft:a.shiftActionBarFocusLeft},null,8,[`is-active`,`tooltip-message`,`data-qa`,`tabindex`,`icon`,`label`,`on-click`,`onShiftFocusRight`,`onShiftFocusLeft`])):(0,v.createCommentVNode)(``,!0)],64))),256)),t[8]||(t[8]=(0,v.createElementVNode)(`div`,{class:`d-recipe-editor__button-group-divider`},null,-1))]),_:2},1024))),128)),a.linkButton.showBtn?((0,v.openBlock)(),(0,v.createBlock)(g,{key:0,direction:`row`,gap:`300`},{default:(0,v.withCtx)(()=>[(0,v.createVNode)(y,{open:i.showLinkInput,"show-close-button":!1,"data-qa":`dt-recipe-editor-link-input-popover`,padding:`none`,placement:`bottom-start`,onClick:[a.onInputFocus,(0,v.withModifiers)(a.onInputFocus,[`stop`])],onOpened:a.updateInput},{anchor:(0,v.withCtx)(()=>[((0,v.openBlock)(),(0,v.createBlock)(_,{key:a.linkButton.key,message:a.linkButton.tooltipMessage,placement:`top`},{anchor:(0,v.withCtx)(()=>[(0,v.createVNode)(f,{ref:a.getButtonRef(`custom`,`link`),active:e.$refs.richTextEditor?.editor?.isActive(a.linkButton.selector),"aria-label":a.linkButton.tooltipMessage,"data-qa":a.linkButton.dataQA,tabindex:a.canFocus(a.getButtonRef(`custom`,`link`))?0:-1,importance:`clear`,kind:`muted`,size:`xs`,onClick:t[3]||(t[3]=e=>a.linkButton.onClick()),onKeydown:[(0,v.withKeys)((0,v.withModifiers)(a.shiftActionBarFocusRight,[`stop`]),[`right`]),(0,v.withKeys)((0,v.withModifiers)(a.shiftActionBarFocusLeft,[`stop`]),[`left`])]},{icon:(0,v.withCtx)(()=>[((0,v.openBlock)(),(0,v.createBlock)((0,v.resolveDynamicComponent)(a.linkButton.icon),{size:`200`}))]),_:1},8,[`active`,`aria-label`,`data-qa`,`tabindex`,`onKeydown`])]),_:1},8,[`message`]))]),content:(0,v.withCtx)(()=>[(0,v.createElementVNode)(`div`,x,[(0,v.createElementVNode)(`span`,null,(0,v.toDisplayString)(a.showAddLinkButtonLabels.title),1),(0,v.createVNode)(s,{modelValue:i.linkInput,"onUpdate:modelValue":t[4]||(t[4]=e=>i.linkInput=e),"input-aria-label":a.showAddLinkButtonLabels[`aria-label`],placeholder:n.setLinkPlaceholder,"data-qa":`dt-recipe-editor-link-input`,"input-wrapper-class":`d-recipe-editor-link__input-wrapper`,onClick:[a.onInputFocus,(0,v.withModifiers)(a.onInputFocus,[`stop`])],onFocus:a.onInputFocus,onKeydown:(0,v.withKeys)(a.setLink,[`enter`])},null,8,[`modelValue`,`input-aria-label`,`placeholder`,`onClick`,`onFocus`,`onKeydown`])])]),footerContent:(0,v.withCtx)(()=>[(0,v.createVNode)(g,{direction:`row`,gap:`300`,class:`d-recipe-editor__popover-footer`},{default:(0,v.withCtx)(()=>[(0,v.createVNode)(f,(0,v.mergeProps)({"data-qa":`dt-recipe-editor-remove-link-btn`,importance:`clear`,kind:`muted`,size:`sm`},a.removeLinkButtonLabels,{onClick:a.removeLink}),{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(a.removeLinkButtonLabels.title),1)]),_:1},16,[`onClick`]),(0,v.createVNode)(f,(0,v.mergeProps)({"data-qa":`dt-recipe-editor-set-link-cancel-btn`,importance:`clear`,kind:`muted`,size:`sm`},a.cancelSetLinkButtonLabels,{onClick:a.closeLinkInput}),{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(a.cancelSetLinkButtonLabels.title),1)]),_:1},16,[`onClick`]),(0,v.createVNode)(f,(0,v.mergeProps)({"data-qa":`dt-recipe-editor-set-link-confirm-btn`,size:`sm`},a.confirmSetLinkButtonLabels,{onClick:a.setLink}),{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(a.confirmSetLinkButtonLabels.title),1)]),_:1},16,[`onClick`])]),_:1})]),_:1},8,[`open`,`onClick`,`onOpened`])]),_:1})):(0,v.createCommentVNode)(``,!0)]),_:1}),(0,v.createElementVNode)(`div`,{style:(0,v.normalizeStyle)({"max-height":n.maxHeight}),class:(0,v.normalizeClass)([`d-recipe-editor__content`,{"d-recipe-editor__content-image-resize":n.allowImageResize}])},[(0,v.createVNode)(b,(0,v.mergeProps)({ref:`richTextEditor`,modelValue:i.internalInputValue,"onUpdate:modelValue":t[5]||(t[5]=e=>i.internalInputValue=e),"allow-font-color":!0,"allow-font-family":!0,"allow-inline-images":!0,"allow-line-breaks":!0,"allow-variable":!0,"allow-font-size":n.showFontSizeButton,"allow-background-color":n.allowBackgroundColor,"allow-line-height":n.allowLineHeight,"variable-items":a.flattenedVariableItems,"hide-link-bubble-menu":!0,"auto-focus":n.autoFocus,editable:n.editable,"input-aria-label":n.inputAriaLabel,"input-class":`d-recipe-editor__content-input ${n.inputClass}`,link:!0,"output-format":a.htmlOutputFormat,placeholder:n.placeholder,"preserve-whitespace":n.preserveWhitespace,"use-div-tags":n.useDivTags,"allow-tables":n.allowTables,"allow-image-resize":n.allowImageResize,"data-qa":`dt-rich-text-editor`},a.removeClassStyleAttrs(e.$attrs),{onTextInput:a.onTextInput,onBlur:a.onBlur,onFocus:a.onFocus,onInput:t[6]||(t[6]=e=>a.onInput(e)),onSelected:a.onSelected}),null,16,[`modelValue`,`allow-font-size`,`allow-background-color`,`allow-line-height`,`variable-items`,`auto-focus`,`editable`,`input-aria-label`,`input-class`,`output-format`,`placeholder`,`preserve-whitespace`,`use-div-tags`,`allow-tables`,`allow-image-resize`,`onTextInput`,`onBlur`,`onFocus`,`onSelected`])],6)],16)}var C=t.t(b,[[`render`,S]]);exports.default=C;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../../chunk-Bmb41Sf3.cjs`);const e=require(`../../common/utils/index.cjs`),t=require(`../../_plugin-vue_export-helper-D8jCH6HB.cjs`),n=require(`../../localization/index.cjs`),r=require(`../button/button.cjs`),i=require(`../list-item/list-item.cjs`),a=require(`../../combobox-DhjZxfUw.cjs`),o=require(`../stack/stack.cjs`),s=require(`../tooltip/tooltip.cjs`),c=require(`../popover/popover.cjs`),l=require(`../dropdown/dropdown-separator.cjs`),u=require(`../input/input.cjs`),d=require(`../list-item-group/list-item-group.cjs`),f=require(`../../rich_text_editor-wvONcbYd.cjs`),p=require(`../rich-text-editor/rich-text-editor-constants.cjs`),m=require(`./editor-constants.cjs`),h=require(`./EditorToolbarButton.cjs`),g=require(`./EditorToolbarDropdownButton.cjs`),_=require(`./EditorToolbarPopoverButton.cjs`);let v=require(`vue`),y=require(`@dialpad/dialtone-icons/vue3`);var b={compatConfig:{MODE:3},name:`DtRecipeEditor`,components:{DtListItemGroup:d.default,DtDropdownSeparator:l.default,DtListItem:i.default,DtRichTextEditor:f.t,DtButton:r.default,DtPopover:c.default,DtStack:o.default,DtInput:u.default,DtTooltip:s.default,DtCombobox:a.t,EditorToolbarButton:h.default,EditorToolbarDropdownButton:g.default,EditorToolbarPopoverButton:_.default,DtIconQuickReply:y.DtIconQuickReply,DtIconBold:y.DtIconBold,DtIconItalic:y.DtIconItalic,DtIconUnderline:y.DtIconUnderline,DtIconStrikethrough:y.DtIconStrikethrough,DtIconListBullet:y.DtIconListBullet,DtIconListOrdered:y.DtIconListOrdered,DtIconAlignLeft:y.DtIconAlignLeft,DtIconAlignCenter:y.DtIconAlignCenter,DtIconAlignRight:y.DtIconAlignRight,DtIconAlignJustify:y.DtIconAlignJustify,DtIconQuote:y.DtIconQuote,DtIconCodeBlock:y.DtIconCodeBlock,DtIconLink2:y.DtIconLink2,DtIconImage:y.DtIconImage,DtIconSearch:y.DtIconSearch,DtIconType:y.DtIconType,DtIconBraces:y.DtIconBraces,DtIconChevronDown:y.DtIconChevronDown,DtIconFontSize:y.DtIconFontSize,DtIconStopFilled:y.DtIconStopFilled},mixins:[],inheritAttrs:!1,props:{modelValue:{type:[Object,String],default:``},editable:{type:Boolean,default:!0},inputAriaLabel:{type:String,required:!0,default:``},inputClass:{type:String,default:``},autoFocus:{type:[Boolean,String,Number],default:!1,validator(e){return typeof e==`string`?p.RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(e):!0}},placeholder:{type:String,default:``},maxHeight:{type:String,default:`unset`},setLinkPlaceholder:{type:String,default:``},showBoldButton:{type:Boolean,default:!0},showItalicsButton:{type:Boolean,default:!0},showUnderlineButton:{type:Boolean,default:!0},showStrikeButton:{type:Boolean,default:!0},showListItemsButton:{type:Boolean,default:!0},showOrderedListButton:{type:Boolean,default:!0},showAlignLeftButton:{type:Boolean,default:!0},showAlignCenterButton:{type:Boolean,default:!0},showAlignRightButton:{type:Boolean,default:!0},showAlignJustifyButton:{type:Boolean,default:!0},showQuoteButton:{type:Boolean,default:!0},showCodeBlockButton:{type:Boolean,default:!0},showQuickRepliesButton:{type:Boolean,default:!0},showInlineImageButton:{type:Boolean,default:!1},showVariableButton:{type:Boolean,default:!1},variableCategories:{type:Array,default:()=>[]},showAddLink:{type:Object,default:()=>({showAddLinkButton:!0})},showFontStyleButton:{type:Boolean,default:!1},showFontSizeButton:{type:Boolean,default:!1},showFontColorButton:{type:Boolean,default:!1},fontStyles:{type:Array,default:()=>[{name:`Arial`,value:null},{name:`Georgia`,value:`Georgia`},{name:`Helvetica`,value:`Helvetica`},{name:`Verdana`,value:`Verdana`},{name:`Times New Roman`,value:`Times New Roman`}]},fontSizes:{type:Array,default:()=>[{name:`Small`,value:`12px`},{name:`Normal`,value:`15px`},{name:`Large`,value:`24px`},{name:`Huge`,value:`36px`}]},allowBackgroundColor:{type:Boolean,default:!1},allowLineHeight:{type:Boolean,default:!1},preserveWhitespace:{type:[Boolean,String],default:`full`},useDivTags:{type:Boolean,default:!1},allowTables:{type:Boolean,default:!1},allowImageResize:{type:Boolean,default:!1}},emits:[`focus`,`blur`,`input`,`update:modelValue`,`quick-replies-click`,`inline-image-click`,`text-input`],data(){return{internalInputValue:this.modelValue,hasFocus:!1,linkOptions:{class:`d-recipe-editor__link`},currentFontColor:void 0,showLinkInput:!1,fontStyleSearch:``,linkInput:``,currentButtonRefIndex:0,variableSearchValue:``,i18n:new n.DialtoneLocalization}},computed:{inputLength(){return this.internalInputValue.length},htmlOutputFormat(){return p.RICH_TEXT_EDITOR_OUTPUT_FORMATS[2]},flattenedVariableItems(){return this.variableCategories?this.variableCategories.reduce((e,t)=>e.concat(t.items||[]),[]):[]},showingTextFormatButtons(){return this.showBoldButton||this.showItalicsButton||this.showStrikeButton||this.showUnderlineButton},showingAlignmentButtons(){return this.showAlignLeftButton||this.showAlignCenterButton||this.showAlignRightButton||this.showAlignJustifyButton},showingListButtons(){return this.showListItemsButton||this.showOrderedListButton},orderedRefs(){let e=this.buttonGroups.reduce(function(e,t){return t.buttonGroup.forEach(n=>{e.push(this.getButtonRef(t.key,n.selector))},this),e}.bind(this),[]);return e.push(this.getButtonRef(`custom`,`link`)),e},buttonGroups(){let e=this.individualButtons.map(e=>({key:e.selector,buttonGroup:[e]}));return[{key:`new`,buttonGroup:this.newButtons},{key:`format`,buttonGroup:this.textFormatButtons},{key:`alignment`,buttonGroup:this.alignmentButtons},{key:`list`,buttonGroup:this.listButtons},...e].filter(e=>e.buttonGroup.length>0)},newButtons(){return[{showBtn:this.showQuickRepliesButton,buttonType:`button`,label:this.i18n.$t(`DIALTONE_EDITOR_QUICK_REPLY_BUTTON_LABEL`),selector:`quickReplies`,icon:y.DtIconQuickReply,dataQA:`dt-recipe-editor-quick-replies-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_QUICK_REPLY_BUTTON_LABEL`),onClick:this.onQuickRepliesClick}].filter(e=>e.showBtn)},textFormatButtons(){return[{showBtn:this.showFontStyleButton,buttonType:`popover`,selector:`fontStyle`,icon:y.DtIconType,dataQA:`dt-recipe-editor-font-style-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_FONT_STYLE_BUTTON_LABEL`)},{showBtn:this.showFontSizeButton,buttonType:`popover`,selector:`fontSize`,icon:y.DtIconFontSize,dataQA:`dt-recipe-editor-font-size-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_FONT_SIZE_BUTTON_LABEL`)},{showBtn:this.showFontColorButton,buttonType:`custom`,selector:`fontColor`,icon:y.DtIconStopFilled,dataQA:`dt-recipe-editor-font-color-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_FONT_COLOR_BUTTON_LABEL`),onClick:this.onColorPickerButtonClick},{showBtn:this.showBoldButton,buttonType:`button`,selector:`bold`,icon:y.DtIconBold,dataQA:`dt-recipe-editor-bold-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_BOLD_BUTTON_LABEL`),onClick:this.onBoldTextToggle},{showBtn:this.showItalicsButton,buttonType:`button`,selector:`italic`,icon:y.DtIconItalic,dataQA:`dt-recipe-editor-italics-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_ITALICS_BUTTON_LABEL`),onClick:this.onItalicTextToggle},{showBtn:this.showUnderlineButton,buttonType:`button`,selector:`underline`,icon:y.DtIconUnderline,dataQA:`dt-recipe-editor-underline-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_UNDERLINE_BUTTON_LABEL`),onClick:this.onUnderlineTextToggle},{showBtn:this.showStrikeButton,buttonType:`button`,selector:`strike`,icon:y.DtIconStrikethrough,dataQA:`dt-recipe-editor-strike-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_STRIKE_BUTTON_LABEL`),onClick:this.onStrikethroughTextToggle}].filter(e=>e.showBtn)},alignmentButtons(){return[{showBtn:this.showAlignLeftButton,buttonType:`button`,selector:{textAlign:`left`},icon:y.DtIconAlignLeft,dataQA:`dt-recipe-editor-align-left-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_ALIGN_LEFT_BUTTON_LABEL`),onClick:()=>this.onTextAlign(`left`)},{showBtn:this.showAlignCenterButton,buttonType:`button`,selector:{textAlign:`center`},icon:y.DtIconAlignCenter,dataQA:`dt-recipe-editor-align-center-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_ALIGN_CENTER_BUTTON_LABEL`),onClick:()=>this.onTextAlign(`center`)},{showBtn:this.showAlignRightButton,buttonType:`button`,selector:{textAlign:`right`},icon:y.DtIconAlignRight,dataQA:`dt-recipe-editor-align-right-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_ALIGN_RIGHT_BUTTON_LABEL`),onClick:()=>this.onTextAlign(`right`)},{showBtn:this.showAlignJustifyButton,buttonType:`button`,selector:{textAlign:`justify`},icon:y.DtIconAlignJustify,dataQA:`dt-recipe-editor-align-justify-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_ALIGN_JUSTIFY_BUTTON_LABEL`),onClick:()=>this.onTextAlign(`justify`)}].filter(e=>e.showBtn)},listButtons(){return[{showBtn:this.showListItemsButton,buttonType:`button`,selector:`bulletList`,icon:y.DtIconListBullet,dataQA:`dt-recipe-editor-list-items-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_BULLET_LIST_BUTTON_LABEL`),onClick:this.onBulletListToggle},{showBtn:this.showOrderedListButton,buttonType:`button`,selector:`orderedList`,icon:y.DtIconListOrdered,dataQA:`dt-recipe-editor-ordered-list-items-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_ORDERED_LIST_BUTTON_LABEL`),onClick:this.onOrderedListToggle}].filter(e=>e.showBtn)},individualButtons(){return[{showBtn:this.showQuoteButton,buttonType:`button`,selector:`blockquote`,icon:y.DtIconQuote,dataQA:`dt-recipe-editor-blockquote-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_QUOTE_BUTTON_LABEL`),onClick:this.onBlockquoteToggle},{showBtn:this.showCodeBlockButton,buttonType:`button`,selector:`codeBlock`,icon:y.DtIconCodeBlock,dataQA:`dt-recipe-editor-code-block-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_CODE_BUTTON_LABEL`),onClick:this.onCodeBlockToggle},{showBtn:this.showInlineImageButton,buttonType:`button`,selector:`image`,icon:y.DtIconImage,dataQA:`dt-recipe-editor-inline-image-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_IMAGE_BUTTON_LABEL`),onClick:this.onInsertInlineImageClick},{showBtn:this.showVariableButton,buttonType:`popover`,selector:`variable`,icon:y.DtIconBraces,dataQA:`dt-recipe-editor-variable-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_VARIABLE_BUTTON_LABEL`)}].filter(e=>e.showBtn)},linkButton(){return{showBtn:this.showAddLink.showAddLinkButton,buttonType:`custom`,selector:`link`,icon:y.DtIconLink2,dataQA:`dt-recipe-editor-add-link-btn`,tooltipMessage:this.i18n.$t(`DIALTONE_EDITOR_LINK_BUTTON_LABEL`),onClick:this.openLinkInput}},confirmSetLinkButtonLabels(){return this.i18n.$ta(`DIALTONE_EDITOR_CONFIRM_SET_LINK_BUTTON`)},cancelSetLinkButtonLabels(){return this.i18n.$ta(`DIALTONE_EDITOR_CANCEL_SET_LINK_BUTTON`)},removeLinkButtonLabels(){return this.i18n.$ta(`DIALTONE_EDITOR_REMOVE_LINK_BUTTON`)},showAddLinkButtonLabels(){return this.i18n.$ta(`DIALTONE_EDITOR_ADD_LINK_BUTTON`)},filteredFontStyles(){let e=this.fontStyleSearch.toLowerCase();return this.fontStyles.filter(t=>t.name.toLowerCase().includes(e))},filteredCategories(){return this.variableCategories.filter(e=>this.getFilteredItemsForCategory(e).length)},colorPickerInput(){return this.$refs.editorRoot?.querySelector(`.colorPickerInput`)},isDefaultFontColor(){return this.currentFontColor===m.EDITOR_DEFAULT_FONT_COLOR},actionBarBtn(){let e=this.$refs[this.orderedRefs[this.currentButtonRefIndex]][0]?.$refs?.buttonRef||this.$refs[this.orderedRefs[this.currentButtonRefIndex]];return Array.isArray(e)?e[0]:e}},watch:{modelValue(e){this.internalInputValue=e}},methods:{removeClassStyleAttrs:e.removeClassStyleAttrs,addClassStyleAttrs:e.addClassStyleAttrs,focusEditor(){this.$refs.richTextEditor?.editor?.commands.focus()},onInputFocus(e){e?.stopPropagation()},removeLink(){this.$refs.richTextEditor?.editor?.chain()?.focus()?.unsetLink()?.run(),this.closeLinkInput()},setLink(e){let t=this.$refs.richTextEditor?.editor;if(e?.preventDefault(),e?.stopPropagation(),!this.linkInput){this.removeLink();return}m.EDITOR_SUPPORTED_LINK_PROTOCOLS.find(e=>e.test(this.linkInput))||(this.linkInput=`${m.EDITOR_DEFAULT_LINK_PREFIX}${this.linkInput}`);let n=t?.view?.state?.selection;n.anchor===n.head?t.chain().focus().insertContentAt(n.anchor,`<a class="${this.linkOptions.class}" href=${this.linkInput}>${this.linkInput}</a>`).run():t.chain().focus().extendMarkRange(`link`).setLink({href:this.linkInput,class:this.linkOptions.class}).run(),this.closeLinkInput()},openLinkInput(){this.showLinkInput=!0},updateInput(e){if(!e)return this.closeLinkInput();this.linkInput=this.$refs.richTextEditor?.editor?.getAttributes(`link`)?.href},closeLinkInput(){this.showLinkInput=!1,this.linkInput=``,this.$refs.richTextEditor.editor?.chain().focus()},onBoldTextToggle(){this.$refs.richTextEditor?.editor?.chain().focus().toggleBold().run()},onItalicTextToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleItalic().run()},onUnderlineTextToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleUnderline().run()},onStrikethroughTextToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleStrike().run()},onTextAlign(e){if(this.$refs.richTextEditor?.editor?.isActive({textAlign:e}))return this.$refs.richTextEditor?.editor.chain().focus().unsetTextAlign().run();this.$refs.richTextEditor?.editor.chain().focus().setTextAlign(e).run()},onBulletListToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleBulletList().run()},onOrderedListToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleOrderedList().run()},onCodeBlockToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleCodeBlock().run()},onQuickRepliesClick(){this.$emit(`quick-replies-click`)},onInsertInlineImageClick(){this.$emit(`inline-image-click`)},insertVariable(e,t){this.$refs.richTextEditor?.editor.chain().focus().insertVariable({id:t.id,placeholder:t.placeholder||``,altText:``,enableAltText:t.enableAltText}).run()},insertInlineImage(e){this.$refs.richTextEditor?.editor.chain().focus().setImage({src:e}).run()},insertInMessageBody(e){this.$refs.richTextEditor?.editor.chain().focus().insertContent(e).run()},setCursorPosition(e=null){this.$refs.richTextEditor?.editor.chain().focus(e).run()},onBlockquoteToggle(){this.$refs.richTextEditor?.editor.chain().focus().toggleBlockquote().run()},onTextInput(e){this.$emit(`text-input`,e)},onFocus(e){this.hasFocus=!0,this.$emit(`focus`,e)},onBlur(e){this.hasFocus=!1,this.$emit(`blur`,e)},onInput(e){this.$emit(`input`,e),this.$emit(`update:modelValue`,e)},onSelected(){this.updateFontColorInput()},getButtonKey(e,t){return`${e}-${JSON.stringify(t)}`},getButtonRef(e,t){return`${this.getButtonKey(e,t)}-ref`},canFocus(e){return e===this.orderedRefs[this.currentButtonRefIndex]},shiftActionBarFocusRight(){this.shiftButtonRefIndex(1)},shiftActionBarFocusLeft(){this.shiftButtonRefIndex(-1)},shiftButtonRefIndex(e){let t=this.actionBarBtn,n=(this.currentButtonRefIndex+e)%this.orderedRefs.length;this.currentButtonRefIndex=n>=0?n:this.orderedRefs.length+n;let r=this.actionBarBtn;t.$el.blur(),r.$el.focus()},onFontStyleSelect(e){e?this.$refs.richTextEditor?.editor?.chain().focus().setFontFamily(e).run():this.$refs.richTextEditor?.editor?.chain().focus().unsetFontFamily().run(),this.$refs.richTextEditor?.editor?.commands.focus()},isCurrentFontFamily(e){return e?this.$refs.richTextEditor?.editor?.isActive(`textStyle`,{fontFamily:e}):!this.$refs.richTextEditor?.editor?.getAttributes(`textStyle`)?.fontFamily},onFontSizeSelect(e){this.$refs.richTextEditor?.editor?.chain().focus().setFontSize(e).run(),this.$refs.richTextEditor?.editor?.commands.focus()},isCurrentFontSize(e){return e?this.$refs.richTextEditor?.editor?.isActive(`textStyle`,{fontSize:e}):!this.$refs.richTextEditor?.editor?.getAttributes(`textStyle`)?.fontSize},getFilteredItemsForCategory(e){let t=this.variableSearchValue.toLowerCase();return e.name.toLowerCase().includes(t)?e.items:e.items.filter(e=>e.name.toLowerCase().includes(t))},updateFontColorInput(){this.currentFontColor=this.$refs.richTextEditor?.editor?.getAttributes(`textStyle`)?.color||`#000000`},onColorPickerButtonClick(){this.colorPickerInput?.click()},onColorPickerInput(e){this.$refs.richTextEditor?.editor?.chain().focus().setColor(e).run(),this.$refs.richTextEditor?.editor?.commands.focus(),this.updateFontColorInput()}}},x={class:`d-recipe-editor__popover-content`};function S(e,t,n,r,i,a){let o=(0,v.resolveComponent)(`dt-icon-search`),s=(0,v.resolveComponent)(`dt-input`),c=(0,v.resolveComponent)(`dt-list-item`),l=(0,v.resolveComponent)(`dt-combobox`),u=(0,v.resolveComponent)(`editor-toolbar-popover-button`),d=(0,v.resolveComponent)(`editor-toolbar-dropdown-button`),f=(0,v.resolveComponent)(`dt-button`),p=(0,v.resolveComponent)(`dt-dropdown-separator`),m=(0,v.resolveComponent)(`dt-list-item-group`),h=(0,v.resolveComponent)(`editor-toolbar-button`),g=(0,v.resolveComponent)(`dt-stack`),_=(0,v.resolveComponent)(`dt-tooltip`),y=(0,v.resolveComponent)(`dt-popover`),b=(0,v.resolveComponent)(`dt-rich-text-editor`),S=(0,v.resolveDirective)(`dt-tooltip`);return(0,v.openBlock)(),(0,v.createElementBlock)(`div`,(0,v.mergeProps)({ref:`editorRoot`,class:`d-recipe-editor`},a.addClassStyleAttrs(e.$attrs),{"data-qa":`dt-recipe-editor`,role:`presentation`,onClick:t[7]||(t[7]=t=>e.$refs.richTextEditor.focusEditor())}),[(0,v.createVNode)(g,{class:`d-recipe-editor__top-bar`,direction:`row`,gap:`450`},{default:(0,v.withCtx)(()=>[((0,v.openBlock)(!0),(0,v.createElementBlock)(v.Fragment,null,(0,v.renderList)(a.buttonGroups,r=>((0,v.openBlock)(),(0,v.createBlock)(g,{key:r.key,direction:`row`,gap:`300`},{default:(0,v.withCtx)(()=>[((0,v.openBlock)(!0),(0,v.createElementBlock)(v.Fragment,null,(0,v.renderList)(r.buttonGroup,g=>((0,v.openBlock)(),(0,v.createElementBlock)(v.Fragment,null,[g.buttonType===`popover`&&g.selector===`fontStyle`?((0,v.openBlock)(),(0,v.createBlock)(u,{key:a.getButtonKey(r.key,g.selector),ref_for:!0,ref:a.getButtonRef(r.key,g.selector),"is-active":e.$refs.richTextEditor?.editor?.isActive(g.selector),"tooltip-message":g.tooltipMessage,"data-qa":g.dataQA,"popover-data-qa":`dt-recipe-editor-font-style-input-popover`,tabindex:a.canFocus(a.getButtonRef(r.key,g.selector))?0:-1,icon:g.icon,onShiftFocusRight:a.shiftActionBarFocusRight,onShiftFocusLeft:a.shiftActionBarFocusLeft},{content:(0,v.withCtx)(({close:e})=>[(0,v.createVNode)(l,{label:``,"label-visible":!1,"show-list":!0,"click-on-select":!0,onEscape:t=>e()},{input:(0,v.withCtx)(({inputProps:e})=>[(0,v.createVNode)(s,(0,v.mergeProps)({ref_for:!0},e,{modelValue:i.fontStyleSearch,"onUpdate:modelValue":t[0]||(t[0]=e=>i.fontStyleSearch=e),"root-class":`d-p8 d-pb4 d-w216`,type:`search`,placeholder:i.i18n.$t(`DIALTONE_EDITOR_FONT_STYLE_SEARCH_PLACEHOLDER`),size:`sm`,role:`menuitem`}),{leftIcon:(0,v.withCtx)(({iconSize:e})=>[(0,v.createVNode)(o,{size:e},null,8,[`size`])]),_:1},16,[`modelValue`,`placeholder`])]),list:(0,v.withCtx)(({listProps:t})=>[(0,v.createElementVNode)(`ul`,(0,v.mergeProps)({ref_for:!0},t),[((0,v.openBlock)(!0),(0,v.createElementBlock)(v.Fragment,null,(0,v.renderList)(a.filteredFontStyles,t=>((0,v.openBlock)(),(0,v.createBlock)(c,{key:t.name,selected:a.isCurrentFontFamily(t.value),style:(0,v.normalizeStyle)({fontFamily:t.value||`inherit`}),role:`option`,"navigation-type":`arrow-keys`,onClick:n=>{e(a.focusEditor),a.onFontStyleSelect(t.value)}},{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(t.name),1)]),_:2},1032,[`selected`,`style`,`onClick`]))),128))],16)]),_:2},1032,[`onEscape`])]),_:1},8,[`is-active`,`tooltip-message`,`data-qa`,`tabindex`,`icon`,`onShiftFocusRight`,`onShiftFocusLeft`])):g.buttonType===`popover`&&g.selector===`fontSize`?((0,v.openBlock)(),(0,v.createBlock)(d,{key:a.getButtonKey(r.key,g.selector),ref_for:!0,ref:a.getButtonRef(r.key,g.selector),"is-active":e.$refs.richTextEditor?.editor?.isActive(g.selector),"tooltip-message":g.tooltipMessage,"data-qa":g.dataQA,"dropdown-data-qa":`dt-recipe-editor-font-size-input-popover`,tabindex:a.canFocus(a.getButtonRef(r.key,g.selector))?0:-1,icon:g.icon,onShiftFocusRight:a.shiftActionBarFocusRight,onShiftFocusLeft:a.shiftActionBarFocusLeft},{list:(0,v.withCtx)(({close:e})=>[((0,v.openBlock)(!0),(0,v.createElementBlock)(v.Fragment,null,(0,v.renderList)(n.fontSizes,t=>((0,v.openBlock)(),(0,v.createBlock)(c,{key:t.name,selected:a.isCurrentFontSize(t.value),role:`menuitem`,"navigation-type":`arrow-keys`,onClick:n=>{e(a.focusEditor),a.onFontSizeSelect(t.value,n)}},{default:(0,v.withCtx)(()=>[(0,v.createElementVNode)(`span`,{style:(0,v.normalizeStyle)({fontSize:t.value})},(0,v.toDisplayString)(t.name),5)]),_:2},1032,[`selected`,`onClick`]))),128))]),_:1},8,[`is-active`,`tooltip-message`,`data-qa`,`tabindex`,`icon`,`onShiftFocusRight`,`onShiftFocusLeft`])):g.buttonType===`custom`&&g.selector===`fontColor`?(0,v.withDirectives)(((0,v.openBlock)(),(0,v.createBlock)(f,{key:a.getButtonKey(r.key,g.selector),ref_for:!0,ref:a.getButtonRef(r.key,g.selector),kind:`muted`,importance:`clear`,size:`xs`,active:e.$refs.richTextEditor?.editor?.isActive(g.selector),tabindex:a.canFocus(a.getButtonRef(r.key,g.selector))?0:-1,"aria-label":g.tooltipMessage,"data-qa":g.dataQA,onKeydown:[(0,v.withKeys)((0,v.withModifiers)(a.shiftActionBarFocusRight,[`stop`]),[`right`]),(0,v.withKeys)((0,v.withModifiers)(a.shiftActionBarFocusLeft,[`stop`]),[`left`])],onClick:e=>g.onClick()},{icon:(0,v.withCtx)(()=>[((0,v.openBlock)(),(0,v.createBlock)((0,v.resolveDynamicComponent)(g.icon),{size:`200`,style:(0,v.normalizeStyle)(a.isDefaultFontColor?{}:{color:i.currentFontColor})},null,8,[`style`])),(0,v.createVNode)(s,{value:i.currentFontColor,"root-class":`d-w0 d-h0 d-of-hidden`,"input-class":`colorPickerInput d-w0 d-h0 d-p0 d-bar0`,"input-wrapper-class":`d-w0 d-h0 d-ba-none`,size:`sm`,type:`color`,onInput:a.onColorPickerInput,onClick:t[1]||(t[1]=(0,v.withModifiers)(()=>{},[`stop`]))},null,8,[`value`,`onInput`])]),_:2},1032,[`active`,`tabindex`,`aria-label`,`data-qa`,`onKeydown`,`onClick`])),[[S,{message:g.tooltipMessage,placement:`top`,externalAnchorElement:e.$refs[a.getButtonRef(r.key,g.selector)]?.$el}]]):g.buttonType===`popover`&&g.selector===`variable`?((0,v.openBlock)(),(0,v.createBlock)(u,{key:a.getButtonKey(r.key,g.selector),ref_for:!0,ref:a.getButtonRef(r.key,g.selector),"is-active":!1,"tooltip-message":g.tooltipMessage,"data-qa":g.dataQA,"popover-data-qa":`dt-recipe-editor-variable-popover`,tabindex:a.canFocus(a.getButtonRef(r.key,g.selector))?0:-1,icon:g.icon,onShiftFocusRight:a.shiftActionBarFocusRight,onShiftFocusLeft:a.shiftActionBarFocusLeft},{content:(0,v.withCtx)(({close:e})=>[(0,v.createVNode)(l,{label:``,"label-visible":!1,"show-list":!0,"click-on-select":!0,onEscape:t=>e()},{input:(0,v.withCtx)(({inputProps:e})=>[(0,v.createVNode)(s,(0,v.mergeProps)({ref_for:!0},e,{modelValue:i.variableSearchValue,"onUpdate:modelValue":t[2]||(t[2]=e=>i.variableSearchValue=e),"root-class":`d-p8 d-pb4 d-w264`,type:`search`,placeholder:i.i18n.$t(`DIALTONE_EDITOR_VARIABLE_POPOVER_SEARCH_PLACEHOLDER`),size:`md`,role:`menuitem`}),{leftIcon:(0,v.withCtx)(({iconSize:e})=>[(0,v.createVNode)(o,{size:e},null,8,[`size`])]),_:1},16,[`modelValue`,`placeholder`])]),list:(0,v.withCtx)(({listProps:t})=>[(0,v.createElementVNode)(`div`,(0,v.mergeProps)({ref_for:!0},t),[((0,v.openBlock)(!0),(0,v.createElementBlock)(v.Fragment,null,(0,v.renderList)(a.filteredCategories,(t,n)=>((0,v.openBlock)(),(0,v.createBlock)(m,{key:t.name,heading:t.name,"heading-class":`d-headline--sm-compact d-p8`},{default:(0,v.withCtx)(()=>[((0,v.openBlock)(!0),(0,v.createElementBlock)(v.Fragment,null,(0,v.renderList)(a.getFilteredItemsForCategory(t),n=>((0,v.openBlock)(),(0,v.createBlock)(c,{key:t.name+n.name,role:`option`,"navigation-type":`arrow-keys`,onClick:r=>{a.insertVariable(t.name,n),e(a.focusEditor)}},{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(n.name),1)]),_:2},1032,[`onClick`]))),128)),n<a.filteredCategories.length-1?((0,v.openBlock)(),(0,v.createBlock)(p,{key:0})):(0,v.createCommentVNode)(``,!0)]),_:2},1032,[`heading`]))),128))],16)]),_:2},1032,[`onEscape`])]),_:1},8,[`tooltip-message`,`data-qa`,`tabindex`,`icon`,`onShiftFocusRight`,`onShiftFocusLeft`])):g.buttonType===`button`?((0,v.openBlock)(),(0,v.createBlock)(h,{key:a.getButtonKey(r.key,g.selector),ref_for:!0,ref:a.getButtonRef(r.key,g.selector),"is-active":e.$refs.richTextEditor?.editor?.isActive(g.selector),"tooltip-message":g.tooltipMessage,"data-qa":g.dataQA,tabindex:a.canFocus(a.getButtonRef(r.key,g.selector))?0:-1,icon:g.icon,label:g.label,"on-click":g.onClick,onShiftFocusRight:a.shiftActionBarFocusRight,onShiftFocusLeft:a.shiftActionBarFocusLeft},null,8,[`is-active`,`tooltip-message`,`data-qa`,`tabindex`,`icon`,`label`,`on-click`,`onShiftFocusRight`,`onShiftFocusLeft`])):(0,v.createCommentVNode)(``,!0)],64))),256)),t[8]||(t[8]=(0,v.createElementVNode)(`div`,{class:`d-recipe-editor__button-group-divider`},null,-1))]),_:2},1024))),128)),a.linkButton.showBtn?((0,v.openBlock)(),(0,v.createBlock)(g,{key:0,direction:`row`,gap:`300`},{default:(0,v.withCtx)(()=>[(0,v.createVNode)(y,{open:i.showLinkInput,"show-close-button":!1,"data-qa":`dt-recipe-editor-link-input-popover`,padding:`none`,placement:`bottom-start`,onClick:[a.onInputFocus,(0,v.withModifiers)(a.onInputFocus,[`stop`])],onOpened:a.updateInput},{anchor:(0,v.withCtx)(()=>[((0,v.openBlock)(),(0,v.createBlock)(_,{key:a.linkButton.key,message:a.linkButton.tooltipMessage,placement:`top`},{anchor:(0,v.withCtx)(()=>[(0,v.createVNode)(f,{ref:a.getButtonRef(`custom`,`link`),active:e.$refs.richTextEditor?.editor?.isActive(a.linkButton.selector),"aria-label":a.linkButton.tooltipMessage,"data-qa":a.linkButton.dataQA,tabindex:a.canFocus(a.getButtonRef(`custom`,`link`))?0:-1,importance:`clear`,kind:`muted`,size:`xs`,onClick:t[3]||(t[3]=e=>a.linkButton.onClick()),onKeydown:[(0,v.withKeys)((0,v.withModifiers)(a.shiftActionBarFocusRight,[`stop`]),[`right`]),(0,v.withKeys)((0,v.withModifiers)(a.shiftActionBarFocusLeft,[`stop`]),[`left`])]},{icon:(0,v.withCtx)(()=>[((0,v.openBlock)(),(0,v.createBlock)((0,v.resolveDynamicComponent)(a.linkButton.icon),{size:`200`}))]),_:1},8,[`active`,`aria-label`,`data-qa`,`tabindex`,`onKeydown`])]),_:1},8,[`message`]))]),content:(0,v.withCtx)(()=>[(0,v.createElementVNode)(`div`,x,[(0,v.createElementVNode)(`span`,null,(0,v.toDisplayString)(a.showAddLinkButtonLabels.title),1),(0,v.createVNode)(s,{modelValue:i.linkInput,"onUpdate:modelValue":t[4]||(t[4]=e=>i.linkInput=e),"input-aria-label":a.showAddLinkButtonLabels[`aria-label`],placeholder:n.setLinkPlaceholder,"data-qa":`dt-recipe-editor-link-input`,"input-wrapper-class":`d-recipe-editor-link__input-wrapper`,onClick:[a.onInputFocus,(0,v.withModifiers)(a.onInputFocus,[`stop`])],onFocus:a.onInputFocus,onKeydown:(0,v.withKeys)(a.setLink,[`enter`])},null,8,[`modelValue`,`input-aria-label`,`placeholder`,`onClick`,`onFocus`,`onKeydown`])])]),footerContent:(0,v.withCtx)(()=>[(0,v.createVNode)(g,{direction:`row`,gap:`300`,class:`d-recipe-editor__popover-footer`},{default:(0,v.withCtx)(()=>[(0,v.createVNode)(f,(0,v.mergeProps)({"data-qa":`dt-recipe-editor-remove-link-btn`,importance:`clear`,kind:`muted`,size:`sm`},a.removeLinkButtonLabels,{onClick:a.removeLink}),{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(a.removeLinkButtonLabels.title),1)]),_:1},16,[`onClick`]),(0,v.createVNode)(f,(0,v.mergeProps)({"data-qa":`dt-recipe-editor-set-link-cancel-btn`,importance:`clear`,kind:`muted`,size:`sm`},a.cancelSetLinkButtonLabels,{onClick:a.closeLinkInput}),{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(a.cancelSetLinkButtonLabels.title),1)]),_:1},16,[`onClick`]),(0,v.createVNode)(f,(0,v.mergeProps)({"data-qa":`dt-recipe-editor-set-link-confirm-btn`,size:`sm`},a.confirmSetLinkButtonLabels,{onClick:a.setLink}),{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(a.confirmSetLinkButtonLabels.title),1)]),_:1},16,[`onClick`])]),_:1})]),_:1},8,[`open`,`onClick`,`onOpened`])]),_:1})):(0,v.createCommentVNode)(``,!0)]),_:1}),(0,v.createElementVNode)(`div`,{style:(0,v.normalizeStyle)({"max-height":n.maxHeight}),class:(0,v.normalizeClass)([`d-recipe-editor__content`,{"d-recipe-editor__content-image-resize":n.allowImageResize}])},[(0,v.createVNode)(b,(0,v.mergeProps)({ref:`richTextEditor`,modelValue:i.internalInputValue,"onUpdate:modelValue":t[5]||(t[5]=e=>i.internalInputValue=e),"allow-font-color":!0,"allow-font-family":!0,"allow-inline-images":!0,"allow-line-breaks":!0,"allow-variable":!0,"allow-font-size":n.showFontSizeButton,"allow-background-color":n.allowBackgroundColor,"allow-line-height":n.allowLineHeight,"variable-items":a.flattenedVariableItems,"hide-link-bubble-menu":!0,"auto-focus":n.autoFocus,editable:n.editable,"input-aria-label":n.inputAriaLabel,"input-class":`d-recipe-editor__content-input ${n.inputClass}`,link:!0,"output-format":a.htmlOutputFormat,placeholder:n.placeholder,"preserve-whitespace":n.preserveWhitespace,"use-div-tags":n.useDivTags,"allow-tables":n.allowTables,"allow-image-resize":n.allowImageResize,"data-qa":`dt-rich-text-editor`},a.removeClassStyleAttrs(e.$attrs),{onTextInput:a.onTextInput,onBlur:a.onBlur,onFocus:a.onFocus,onInput:t[6]||(t[6]=e=>a.onInput(e)),onSelected:a.onSelected}),null,16,[`modelValue`,`allow-font-size`,`allow-background-color`,`allow-line-height`,`variable-items`,`auto-focus`,`editable`,`input-aria-label`,`input-class`,`output-format`,`placeholder`,`preserve-whitespace`,`use-div-tags`,`allow-tables`,`allow-image-resize`,`onTextInput`,`onBlur`,`onFocus`,`onSelected`])],6)],16)}var C=t.t(b,[[`render`,S]]);exports.default=C;
|
|
2
2
|
//# sourceMappingURL=editor.cjs.map
|
|
@@ -10,7 +10,7 @@ import l from "../popover/popover.js";
|
|
|
10
10
|
import u from "../dropdown/dropdown-separator.js";
|
|
11
11
|
import d from "../input/input.js";
|
|
12
12
|
import f from "../list-item-group/list-item-group.js";
|
|
13
|
-
import { t as p } from "../../rich_text_editor-
|
|
13
|
+
import { t as p } from "../../rich_text_editor-BhUKyR0E.js";
|
|
14
14
|
import { RICH_TEXT_EDITOR_AUTOFOCUS_TYPES as m, RICH_TEXT_EDITOR_OUTPUT_FORMATS as h } from "../rich-text-editor/rich-text-editor-constants.js";
|
|
15
15
|
import { EDITOR_DEFAULT_FONT_COLOR as g, EDITOR_DEFAULT_LINK_PREFIX as _, EDITOR_SUPPORTED_LINK_PROTOCOLS as v } from "./editor-constants.js";
|
|
16
16
|
import y from "./EditorToolbarButton.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../../chunk-Bmb41Sf3.cjs`);const e=require(`../../common/
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../../chunk-Bmb41Sf3.cjs`);const e=require(`../../common/constants/index.cjs`),t=require(`../../common/utils/index.cjs`),n=require(`../tooltip/tooltip-constants.cjs`),r=require(`../popover/popover-constants.cjs`),i=require(`../popover/popover.cjs`);let a=require(`vue`);var o={__name:`hovercard`,props:{transition:{type:Boolean,default:!1},open:{type:Boolean,default:null},fallbackPlacements:{type:Array,default:()=>[`auto`]},placement:{type:String,default:`top-start`,validator(e){return n.TOOLTIP_DIRECTIONS.includes(e)}},padding:{type:String,default:`large`,validator:e=>Object.keys(r.POPOVER_PADDING_CLASSES).some(t=>t===e)},offset:{type:Array,default:()=>[0,16]},id:{type:String,default(){return t.getUniqueString()}},headerClass:{type:[String,Array,Object],default:``},footerClass:{type:[String,Array,Object],default:``},dialogClass:{type:[String,Array,Object],default:``},contentClass:{type:[String,Array,Object],default:``},appendTo:{type:[e.HTML_ELEMENT_TYPE,String],default:`body`,validator:e=>r.POPOVER_APPEND_TO_VALUES.includes(e)||e instanceof HTMLElement},enterDelay:{type:Number,default:300},leaveDelay:{type:Number,default:300},externalAnchorElement:{type:e.HTML_ELEMENT_TYPE,default:null}},emits:[`opened`],setup(e,{expose:t}){let n=e,r=(0,a.ref)(n.open),o=(0,a.ref)(!1),s=(0,a.ref)(!1),c=(0,a.ref)(null),l=(0,a.ref)(null),u=(0,a.ref)(null),d=(0,a.ref)(null),f=(0,a.ref)(null);(0,a.onMounted)(()=>{(0,a.nextTick)(()=>{u.value=f.value?.$refs?.anchor?.firstElementChild,d.value=new MutationObserver(()=>{u.value&&!u.value.isConnected&&(r.value=!1)}),d.value.observe(document.body,{childList:!0,subtree:!0})})}),(0,a.onBeforeUnmount)(()=>{d.value&&d.value.disconnect(),clearTimeout(c),clearTimeout(l)}),(0,a.watch)(()=>n.open,e=>{r.value=e},{immediate:!0}),t({show:h,hide:g});function p(){n.open===null&&(clearTimeout(l.value),c.value=setTimeout(()=>{r.value=!0},n.enterDelay))}function m(){n.open===null&&(clearTimeout(c.value),l.value=setTimeout(()=>{r.value=!1},n.leaveDelay))}function h(){s.value=!0,p()}function g(){s.value=!1,!o.value&&m()}function _(){o.value=!0,p()}function v(){o.value=!1,s.value||m()}return(t,n)=>((0,a.openBlock)(),(0,a.createBlock)((0,a.unref)(i.default),{id:e.id,ref_key:`popover`,ref:f,open:r.value,placement:e.placement,"content-class":e.contentClass,"dialog-class":e.dialogClass,"fallback-placements":e.fallbackPlacements,padding:e.padding,transition:e.transition?`fade`:null,offset:e.offset,modal:!1,"initial-focus-element":`none`,"header-class":e.headerClass,"footer-class":e.footerClass,"append-to":e.appendTo,"external-anchor-element":e.externalAnchorElement,"data-qa":`dt-hovercard`,"enter-delay":e.enterDelay,"leave-delay":e.leaveDelay,onOpened:n[0]||(n[0]=e=>t.$emit(`opened`,e)),onMouseenterPopover:h,onMouseleavePopover:g,onMouseenterPopoverAnchor:h,onMouseleavePopoverAnchor:g},{anchor:(0,a.withCtx)(({attrs:e})=>[(0,a.renderSlot)(t.$slots,`anchor`,(0,a.normalizeProps)((0,a.guardReactiveProps)(e)))]),content:(0,a.withCtx)(()=>[(0,a.createElementVNode)(`div`,{onFocusin:_,onFocusout:v},[(0,a.renderSlot)(t.$slots,`content`)],32)]),headerContent:(0,a.withCtx)(()=>[(0,a.renderSlot)(t.$slots,`headerContent`)]),footerContent:(0,a.withCtx)(()=>[(0,a.renderSlot)(t.$slots,`footerContent`)]),_:3},8,[`id`,`open`,`placement`,`content-class`,`dialog-class`,`fallback-placements`,`padding`,`transition`,`offset`,`header-class`,`footer-class`,`append-to`,`external-anchor-element`,`enter-delay`,`leave-delay`]))}};exports.default=o;
|
|
2
2
|
//# sourceMappingURL=hovercard.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hovercard.cjs","names":["$emit"],"sources":["../../../components/hovercard/hovercard.vue"],"sourcesContent":["<!-- eslint-disable vue/multi-word-component-names -->\n<template>\n <dt-popover\n :id=\"id\"\n ref=\"popover\"\n :open=\"hovercardOpen\"\n :placement=\"placement\"\n :content-class=\"contentClass\"\n :dialog-class=\"dialogClass\"\n :fallback-placements=\"fallbackPlacements\"\n :padding=\"padding\"\n :transition=\"transition ? 'fade' : null\"\n :offset=\"offset\"\n :modal=\"false\"\n initial-focus-element=\"none\"\n :header-class=\"headerClass\"\n :footer-class=\"footerClass\"\n :append-to=\"appendTo\"\n :external-anchor-element=\"externalAnchorElement\"\n data-qa=\"dt-hovercard\"\n :enter-delay=\"enterDelay\"\n :leave-delay=\"leaveDelay\"\n @opened=\"(e) => ($emit('opened', e))\"\n @mouseenter-popover=\"onMouseEnter\"\n @mouseleave-popover=\"onMouseLeave\"\n @mouseenter-popover-anchor=\"onMouseEnter\"\n @mouseleave-popover-anchor=\"onMouseLeave\"\n >\n <template #anchor=\"{ attrs }\">\n <!-- @slot Anchor element that activates the hovercard. Usually a button. -->\n <slot\n name=\"anchor\"\n v-bind=\"attrs\"\n />\n </template>\n <template #content>\n <div\n @focusin=\"onContentFocusIn\"\n @focusout=\"onContentFocusOut\"\n >\n <!-- @slot Slot for the content that is displayed in the hovercard. -->\n <slot name=\"content\" />\n </div>\n </template>\n <template #headerContent>\n <!-- @slot Slot for hovercard header content -->\n <slot name=\"headerContent\" />\n </template>\n\n <template #footerContent>\n <!-- @slot Slot for the footer content. -->\n <slot name=\"footerContent\" />\n </template>\n </dt-popover>\n</template>\n\n<script setup>\nimport { ref, watch, nextTick, onMounted, onBeforeUnmount } from 'vue';\nimport { POPOVER_APPEND_TO_VALUES, POPOVER_PADDING_CLASSES, DtPopover } from '@/components/popover/index.js';\nimport { TOOLTIP_DIRECTIONS, TOOLTIP_DELAY_MS } from '@/components/tooltip/index.js';\nimport { getUniqueString } from '@/common/utils';\n\nconst props = defineProps({\n /**\n * Fade transition when the content display is toggled.\n * @type boolean\n * @values true, false\n */\n transition: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Controls whether the hovercard is shown. Leaving this null will have the hovercard trigger on hover by default.\n * If you set this value, the default trigger behavior will be disabled, and you can control it as you need.\n * Supports .sync modifier\n * @values null, true, false\n */\n open: {\n type: Boolean,\n default: null,\n },\n\n /**\n * If the popover does not fit in the direction described by \"placement\",\n * it will attempt to change its direction to the \"fallbackPlacements\".\n * @see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements\"\n */\n fallbackPlacements: {\n type: Array,\n default: () => {\n return ['auto'];\n },\n },\n\n /**\n * The direction the popover displays relative to the anchor.\n * @see https://atomiks.github.io/tippyjs/v6/all-props/#placement\"\n * @values top, top-start, top-end,\n * right, right-start, right-end,\n * left, left-start, left-end,\n * bottom, bottom-start, bottom-end,\n * auto, auto-start, auto-end\n */\n placement: {\n type: String,\n default: 'top-start',\n validator (placement) {\n return TOOLTIP_DIRECTIONS.includes(placement);\n },\n },\n\n /**\n * Padding size class for the popover content.\n * @values none, small, medium, large\n */\n padding: {\n type: String,\n default: 'large',\n validator: (padding) => {\n return Object.keys(POPOVER_PADDING_CLASSES).some((item) => item === padding);\n },\n },\n\n /**\n * Displaces the content box from its anchor element\n * by the specified number of pixels.\n * @see https://atomiks.github.io/tippyjs/v6/all-props/#offset\"\n */\n offset: {\n type: Array,\n default: () => [0, 16],\n },\n\n /**\n * The id of the tooltip\n */\n id: {\n type: String,\n default () { return getUniqueString(); },\n },\n\n /**\n * Additional class name for the header content wrapper element.\n */\n headerClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Additional class name for the footer content wrapper element.\n */\n footerClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Additional class name for the dialog element.\n */\n dialogClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Additional class name for the content wrapper element.\n */\n contentClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Sets the element to which the popover is going to append to.\n * 'body' will append to the nearest body (supports shadow DOM).\n * @values 'body', 'parent', HTMLElement,\n */\n appendTo: {\n type: [HTMLElement, String],\n default: 'body',\n validator: appendTo => {\n return POPOVER_APPEND_TO_VALUES.includes(appendTo) ||\n (appendTo instanceof HTMLElement);\n },\n },\n\n /**\n * The enter delay in milliseconds before the hovercard is shown.\n * @type number\n */\n enterDelay: {\n type: Number,\n default: TOOLTIP_DELAY_MS,\n },\n\n /**\n * The leave delay in milliseconds before the hovercard is hidden.\n * @type number\n */\n leaveDelay: {\n type: Number,\n default: TOOLTIP_DELAY_MS,\n },\n\n /**\n * External anchor element reference. Use this instead of the anchor slot when\n * the anchor may be inside a Shadow DOM, as querySelector cannot pierce shadow boundaries.\n */\n externalAnchorElement: {\n type: HTMLElement,\n default: null,\n },\n});\n\ndefineEmits([\n /**\n * Emitted when hovercard is shown or hidden\n *\n * @event opened\n * @type {Boolean | Array}\n */\n 'opened',\n]);\n\nconst hovercardOpen = ref(props.open);\nconst contentFocused = ref(false);\nconst mouseOverHovercard = ref(false);\nconst inTimer = ref(null);\nconst outTimer = ref(null);\nconst anchorEl = ref(null);\nconst observer = ref(null);\nconst popover = ref(null);\n\nonMounted(() => {\n nextTick(() => {\n anchorEl.value = popover.value?.$refs?.anchor?.firstElementChild;\n\n observer.value = new MutationObserver(() => {\n if (anchorEl.value && !anchorEl.value.isConnected) {\n hovercardOpen.value = false;\n }\n });\n\n observer.value.observe(document.body, {\n childList: true,\n subtree: true,\n });\n });\n});\n\nonBeforeUnmount(() => {\n if (observer.value) {\n observer.value.disconnect();\n }\n clearTimeout(inTimer);\n clearTimeout(outTimer);\n});\n\nwatch(() => props.open, (open) => {\n hovercardOpen.value = open;\n}, { immediate: true });\n\ndefineExpose({ show: onMouseEnter, hide: onMouseLeave });\n\nfunction setInTimer () {\n if (props.open === null) {\n clearTimeout(outTimer.value);\n inTimer.value = setTimeout(() => {\n hovercardOpen.value = true;\n }, props.enterDelay);\n }\n}\n\nfunction setOutTimer () {\n if (props.open === null) {\n clearTimeout(inTimer.value);\n outTimer.value = setTimeout(() => {\n hovercardOpen.value = false;\n }, props.leaveDelay);\n }\n}\n\nfunction onMouseEnter () {\n mouseOverHovercard.value = true;\n setInTimer();\n}\n\nfunction onMouseLeave () {\n mouseOverHovercard.value = false;\n if (contentFocused.value) {\n return;\n }\n setOutTimer();\n}\n\nfunction onContentFocusIn () {\n contentFocused.value = true;\n setInTimer();\n}\n\nfunction onContentFocusOut () {\n contentFocused.value = false;\n\n // If mouse is not over the hovercard, close it\n if (!mouseOverHovercard.value) {\n setOutTimer();\n }\n}\n</script>\n"],"mappings":"swCA8DA,IAAM,EAAQ,EAqKR,GAAA,EAAA,EAAA,KAAoB,EAAM,KAAK,CAC/B,GAAA,EAAA,EAAA,KAAqB,GAAM,CAC3B,GAAA,EAAA,EAAA,KAAyB,GAAM,CAC/B,GAAA,EAAA,EAAA,KAAc,KAAK,CACnB,GAAA,EAAA,EAAA,KAAe,KAAK,CACpB,GAAA,EAAA,EAAA,KAAe,KAAK,CACp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BACrB,QAAS,EAAA,QACT,WAAY,EAAA,WAAU,OAAA,KACtB,OAAQ,EAAA,OACR,MAAO,GACR,wBAAsB,OACrB,eAAc,EAAA,YACd,eAAc,EAAA,YACd,YAAW,EAAA,SACX,0BAAyB,EAAA,sBAC1B,UAAQ,eACP,cAAa,EAAA,WACb,cAAa,EAAA,WACb,SAAM,EAAA,KAAA,EAAA,GAAG,GAAOA,EAAAA,MAAK,SAAW,EAAC,EACjC,oBAAoB,EACpB,oBAAoB,EACpB,0BAA2B,EAC3B,0BAA2B,IAEjB,QAAA,EAAA,EAAA,UAKP,CALiB,WAAK,EAAA,EAAA,EAAA,YAKtB,EAAA,OAAA,UAAA,EAAA,EAAA,iBAAA,EAAA,EAAA,oBADQ,EAAK,CAAA,CAAA,CAAA,CAAA,CAGN,SAAA,EAAA,EAAA,aAOH,EAAA,EAAA,EAAA,oBAAA,MAAA,CALH,UAAS,EACT,WAAU,qBAGY,EAAA,OAAA,UAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAGhB,eAAA,EAAA,EAAA,aAEoB,EAAA,EAAA,EAAA,YAAA,EAAA,OAAA,gBAAA,CAAA,CAAA,CAGpB,eAAA,EAAA,EAAA,aAEoB,EAAA,EAAA,EAAA,YAAA,EAAA,OAAA,gBAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"hovercard.cjs","names":["$emit"],"sources":["../../../components/hovercard/hovercard.vue"],"sourcesContent":["<!-- eslint-disable vue/multi-word-component-names -->\n<template>\n <dt-popover\n :id=\"id\"\n ref=\"popover\"\n :open=\"hovercardOpen\"\n :placement=\"placement\"\n :content-class=\"contentClass\"\n :dialog-class=\"dialogClass\"\n :fallback-placements=\"fallbackPlacements\"\n :padding=\"padding\"\n :transition=\"transition ? 'fade' : null\"\n :offset=\"offset\"\n :modal=\"false\"\n initial-focus-element=\"none\"\n :header-class=\"headerClass\"\n :footer-class=\"footerClass\"\n :append-to=\"appendTo\"\n :external-anchor-element=\"externalAnchorElement\"\n data-qa=\"dt-hovercard\"\n :enter-delay=\"enterDelay\"\n :leave-delay=\"leaveDelay\"\n @opened=\"(e) => ($emit('opened', e))\"\n @mouseenter-popover=\"onMouseEnter\"\n @mouseleave-popover=\"onMouseLeave\"\n @mouseenter-popover-anchor=\"onMouseEnter\"\n @mouseleave-popover-anchor=\"onMouseLeave\"\n >\n <template #anchor=\"{ attrs }\">\n <!-- @slot Anchor element that activates the hovercard. Usually a button. -->\n <slot\n name=\"anchor\"\n v-bind=\"attrs\"\n />\n </template>\n <template #content>\n <div\n @focusin=\"onContentFocusIn\"\n @focusout=\"onContentFocusOut\"\n >\n <!-- @slot Slot for the content that is displayed in the hovercard. -->\n <slot name=\"content\" />\n </div>\n </template>\n <template #headerContent>\n <!-- @slot Slot for hovercard header content -->\n <slot name=\"headerContent\" />\n </template>\n\n <template #footerContent>\n <!-- @slot Slot for the footer content. -->\n <slot name=\"footerContent\" />\n </template>\n </dt-popover>\n</template>\n\n<script setup>\nimport { ref, watch, nextTick, onMounted, onBeforeUnmount } from 'vue';\nimport { POPOVER_APPEND_TO_VALUES, POPOVER_PADDING_CLASSES, DtPopover } from '@/components/popover/index.js';\nimport { TOOLTIP_DIRECTIONS, TOOLTIP_DELAY_MS } from '@/components/tooltip/index.js';\nimport { getUniqueString } from '@/common/utils';\nimport { HTML_ELEMENT_TYPE } from '@/common/constants';\n\nconst props = defineProps({\n /**\n * Fade transition when the content display is toggled.\n * @type boolean\n * @values true, false\n */\n transition: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Controls whether the hovercard is shown. Leaving this null will have the hovercard trigger on hover by default.\n * If you set this value, the default trigger behavior will be disabled, and you can control it as you need.\n * Supports .sync modifier\n * @values null, true, false\n */\n open: {\n type: Boolean,\n default: null,\n },\n\n /**\n * If the popover does not fit in the direction described by \"placement\",\n * it will attempt to change its direction to the \"fallbackPlacements\".\n * @see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements\"\n */\n fallbackPlacements: {\n type: Array,\n default: () => {\n return ['auto'];\n },\n },\n\n /**\n * The direction the popover displays relative to the anchor.\n * @see https://atomiks.github.io/tippyjs/v6/all-props/#placement\"\n * @values top, top-start, top-end,\n * right, right-start, right-end,\n * left, left-start, left-end,\n * bottom, bottom-start, bottom-end,\n * auto, auto-start, auto-end\n */\n placement: {\n type: String,\n default: 'top-start',\n validator (placement) {\n return TOOLTIP_DIRECTIONS.includes(placement);\n },\n },\n\n /**\n * Padding size class for the popover content.\n * @values none, small, medium, large\n */\n padding: {\n type: String,\n default: 'large',\n validator: (padding) => {\n return Object.keys(POPOVER_PADDING_CLASSES).some((item) => item === padding);\n },\n },\n\n /**\n * Displaces the content box from its anchor element\n * by the specified number of pixels.\n * @see https://atomiks.github.io/tippyjs/v6/all-props/#offset\"\n */\n offset: {\n type: Array,\n default: () => [0, 16],\n },\n\n /**\n * The id of the tooltip\n */\n id: {\n type: String,\n default () { return getUniqueString(); },\n },\n\n /**\n * Additional class name for the header content wrapper element.\n */\n headerClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Additional class name for the footer content wrapper element.\n */\n footerClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Additional class name for the dialog element.\n */\n dialogClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Additional class name for the content wrapper element.\n */\n contentClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Sets the element to which the popover is going to append to.\n * 'body' will append to the nearest body (supports shadow DOM).\n * @values 'body', 'parent', HTMLElement,\n */\n appendTo: {\n type: [HTML_ELEMENT_TYPE, String],\n default: 'body',\n validator: appendTo => {\n return POPOVER_APPEND_TO_VALUES.includes(appendTo) ||\n (appendTo instanceof HTMLElement);\n },\n },\n\n /**\n * The enter delay in milliseconds before the hovercard is shown.\n * @type number\n */\n enterDelay: {\n type: Number,\n default: TOOLTIP_DELAY_MS,\n },\n\n /**\n * The leave delay in milliseconds before the hovercard is hidden.\n * @type number\n */\n leaveDelay: {\n type: Number,\n default: TOOLTIP_DELAY_MS,\n },\n\n /**\n * External anchor element reference. Use this instead of the anchor slot when\n * the anchor may be inside a Shadow DOM, as querySelector cannot pierce shadow boundaries.\n */\n externalAnchorElement: {\n type: HTML_ELEMENT_TYPE,\n default: null,\n },\n});\n\ndefineEmits([\n /**\n * Emitted when hovercard is shown or hidden\n *\n * @event opened\n * @type {Boolean | Array}\n */\n 'opened',\n]);\n\nconst hovercardOpen = ref(props.open);\nconst contentFocused = ref(false);\nconst mouseOverHovercard = ref(false);\nconst inTimer = ref(null);\nconst outTimer = ref(null);\nconst anchorEl = ref(null);\nconst observer = ref(null);\nconst popover = ref(null);\n\nonMounted(() => {\n nextTick(() => {\n anchorEl.value = popover.value?.$refs?.anchor?.firstElementChild;\n\n observer.value = new MutationObserver(() => {\n if (anchorEl.value && !anchorEl.value.isConnected) {\n hovercardOpen.value = false;\n }\n });\n\n observer.value.observe(document.body, {\n childList: true,\n subtree: true,\n });\n });\n});\n\nonBeforeUnmount(() => {\n if (observer.value) {\n observer.value.disconnect();\n }\n clearTimeout(inTimer);\n clearTimeout(outTimer);\n});\n\nwatch(() => props.open, (open) => {\n hovercardOpen.value = open;\n}, { immediate: true });\n\ndefineExpose({ show: onMouseEnter, hide: onMouseLeave });\n\nfunction setInTimer () {\n if (props.open === null) {\n clearTimeout(outTimer.value);\n inTimer.value = setTimeout(() => {\n hovercardOpen.value = true;\n }, props.enterDelay);\n }\n}\n\nfunction setOutTimer () {\n if (props.open === null) {\n clearTimeout(inTimer.value);\n outTimer.value = setTimeout(() => {\n hovercardOpen.value = false;\n }, props.leaveDelay);\n }\n}\n\nfunction onMouseEnter () {\n mouseOverHovercard.value = true;\n setInTimer();\n}\n\nfunction onMouseLeave () {\n mouseOverHovercard.value = false;\n if (contentFocused.value) {\n return;\n }\n setOutTimer();\n}\n\nfunction onContentFocusIn () {\n contentFocused.value = true;\n setInTimer();\n}\n\nfunction onContentFocusOut () {\n contentFocused.value = false;\n\n // If mouse is not over the hovercard, close it\n if (!m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
|
|
1
|
+
import { HTML_ELEMENT_TYPE as e } from "../../common/constants/index.js";
|
|
2
|
+
import { getUniqueString as t } from "../../common/utils/index.js";
|
|
3
|
+
import { TOOLTIP_DIRECTIONS as n } from "../tooltip/tooltip-constants.js";
|
|
4
|
+
import { POPOVER_APPEND_TO_VALUES as r, POPOVER_PADDING_CLASSES as i } from "../popover/popover-constants.js";
|
|
5
|
+
import a from "../popover/popover.js";
|
|
6
|
+
import { createBlock as o, createElementVNode as s, guardReactiveProps as c, nextTick as l, normalizeProps as u, onBeforeUnmount as d, onMounted as f, openBlock as p, ref as m, renderSlot as h, unref as g, watch as _, withCtx as v } from "vue";
|
|
6
7
|
//#region components/hovercard/hovercard.vue
|
|
7
|
-
var
|
|
8
|
+
var y = {
|
|
8
9
|
__name: "hovercard",
|
|
9
10
|
props: {
|
|
10
11
|
transition: {
|
|
@@ -23,13 +24,13 @@ var v = {
|
|
|
23
24
|
type: String,
|
|
24
25
|
default: "top-start",
|
|
25
26
|
validator(e) {
|
|
26
|
-
return
|
|
27
|
+
return n.includes(e);
|
|
27
28
|
}
|
|
28
29
|
},
|
|
29
30
|
padding: {
|
|
30
31
|
type: String,
|
|
31
32
|
default: "large",
|
|
32
|
-
validator: (e) => Object.keys(
|
|
33
|
+
validator: (e) => Object.keys(i).some((t) => t === e)
|
|
33
34
|
},
|
|
34
35
|
offset: {
|
|
35
36
|
type: Array,
|
|
@@ -38,7 +39,7 @@ var v = {
|
|
|
38
39
|
id: {
|
|
39
40
|
type: String,
|
|
40
41
|
default() {
|
|
41
|
-
return
|
|
42
|
+
return t();
|
|
42
43
|
}
|
|
43
44
|
},
|
|
44
45
|
headerClass: {
|
|
@@ -74,9 +75,9 @@ var v = {
|
|
|
74
75
|
default: ""
|
|
75
76
|
},
|
|
76
77
|
appendTo: {
|
|
77
|
-
type: [
|
|
78
|
+
type: [e, String],
|
|
78
79
|
default: "body",
|
|
79
|
-
validator: (e) =>
|
|
80
|
+
validator: (e) => r.includes(e) || e instanceof HTMLElement
|
|
80
81
|
},
|
|
81
82
|
enterDelay: {
|
|
82
83
|
type: Number,
|
|
@@ -87,15 +88,15 @@ var v = {
|
|
|
87
88
|
default: 300
|
|
88
89
|
},
|
|
89
90
|
externalAnchorElement: {
|
|
90
|
-
type:
|
|
91
|
+
type: e,
|
|
91
92
|
default: null
|
|
92
93
|
}
|
|
93
94
|
},
|
|
94
95
|
emits: ["opened"],
|
|
95
96
|
setup(e, { expose: t }) {
|
|
96
|
-
let n = e, r =
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
let n = e, r = m(n.open), i = m(!1), y = m(!1), b = m(null), x = m(null), S = m(null), C = m(null), w = m(null);
|
|
98
|
+
f(() => {
|
|
99
|
+
l(() => {
|
|
99
100
|
S.value = w.value?.$refs?.anchor?.firstElementChild, C.value = new MutationObserver(() => {
|
|
100
101
|
S.value && !S.value.isConnected && (r.value = !1);
|
|
101
102
|
}), C.value.observe(document.body, {
|
|
@@ -103,9 +104,9 @@ var v = {
|
|
|
103
104
|
subtree: !0
|
|
104
105
|
});
|
|
105
106
|
});
|
|
106
|
-
}),
|
|
107
|
+
}), d(() => {
|
|
107
108
|
C.value && C.value.disconnect(), clearTimeout(b), clearTimeout(x);
|
|
108
|
-
}),
|
|
109
|
+
}), _(() => n.open, (e) => {
|
|
109
110
|
r.value = e;
|
|
110
111
|
}, { immediate: !0 }), t({
|
|
111
112
|
show: D,
|
|
@@ -125,15 +126,15 @@ var v = {
|
|
|
125
126
|
y.value = !0, T();
|
|
126
127
|
}
|
|
127
128
|
function O() {
|
|
128
|
-
y.value = !1, !
|
|
129
|
+
y.value = !1, !i.value && E();
|
|
129
130
|
}
|
|
130
131
|
function k() {
|
|
131
|
-
|
|
132
|
+
i.value = !0, T();
|
|
132
133
|
}
|
|
133
134
|
function A() {
|
|
134
|
-
|
|
135
|
+
i.value = !1, y.value || E();
|
|
135
136
|
}
|
|
136
|
-
return (t, n) => (
|
|
137
|
+
return (t, n) => (p(), o(g(a), {
|
|
137
138
|
id: e.id,
|
|
138
139
|
ref_key: "popover",
|
|
139
140
|
ref: w,
|
|
@@ -160,13 +161,13 @@ var v = {
|
|
|
160
161
|
onMouseenterPopoverAnchor: D,
|
|
161
162
|
onMouseleavePopoverAnchor: O
|
|
162
163
|
}, {
|
|
163
|
-
anchor:
|
|
164
|
-
content:
|
|
164
|
+
anchor: v(({ attrs: e }) => [h(t.$slots, "anchor", u(c(e)))]),
|
|
165
|
+
content: v(() => [s("div", {
|
|
165
166
|
onFocusin: k,
|
|
166
167
|
onFocusout: A
|
|
167
|
-
}, [
|
|
168
|
-
headerContent:
|
|
169
|
-
footerContent:
|
|
168
|
+
}, [h(t.$slots, "content")], 32)]),
|
|
169
|
+
headerContent: v(() => [h(t.$slots, "headerContent")]),
|
|
170
|
+
footerContent: v(() => [h(t.$slots, "footerContent")]),
|
|
170
171
|
_: 3
|
|
171
172
|
}, 8, [
|
|
172
173
|
"id",
|
|
@@ -188,6 +189,6 @@ var v = {
|
|
|
188
189
|
}
|
|
189
190
|
};
|
|
190
191
|
//#endregion
|
|
191
|
-
export {
|
|
192
|
+
export { y as default };
|
|
192
193
|
|
|
193
194
|
//# sourceMappingURL=hovercard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hovercard.js","names":["$emit"],"sources":["../../../components/hovercard/hovercard.vue"],"sourcesContent":["<!-- eslint-disable vue/multi-word-component-names -->\n<template>\n <dt-popover\n :id=\"id\"\n ref=\"popover\"\n :open=\"hovercardOpen\"\n :placement=\"placement\"\n :content-class=\"contentClass\"\n :dialog-class=\"dialogClass\"\n :fallback-placements=\"fallbackPlacements\"\n :padding=\"padding\"\n :transition=\"transition ? 'fade' : null\"\n :offset=\"offset\"\n :modal=\"false\"\n initial-focus-element=\"none\"\n :header-class=\"headerClass\"\n :footer-class=\"footerClass\"\n :append-to=\"appendTo\"\n :external-anchor-element=\"externalAnchorElement\"\n data-qa=\"dt-hovercard\"\n :enter-delay=\"enterDelay\"\n :leave-delay=\"leaveDelay\"\n @opened=\"(e) => ($emit('opened', e))\"\n @mouseenter-popover=\"onMouseEnter\"\n @mouseleave-popover=\"onMouseLeave\"\n @mouseenter-popover-anchor=\"onMouseEnter\"\n @mouseleave-popover-anchor=\"onMouseLeave\"\n >\n <template #anchor=\"{ attrs }\">\n <!-- @slot Anchor element that activates the hovercard. Usually a button. -->\n <slot\n name=\"anchor\"\n v-bind=\"attrs\"\n />\n </template>\n <template #content>\n <div\n @focusin=\"onContentFocusIn\"\n @focusout=\"onContentFocusOut\"\n >\n <!-- @slot Slot for the content that is displayed in the hovercard. -->\n <slot name=\"content\" />\n </div>\n </template>\n <template #headerContent>\n <!-- @slot Slot for hovercard header content -->\n <slot name=\"headerContent\" />\n </template>\n\n <template #footerContent>\n <!-- @slot Slot for the footer content. -->\n <slot name=\"footerContent\" />\n </template>\n </dt-popover>\n</template>\n\n<script setup>\nimport { ref, watch, nextTick, onMounted, onBeforeUnmount } from 'vue';\nimport { POPOVER_APPEND_TO_VALUES, POPOVER_PADDING_CLASSES, DtPopover } from '@/components/popover/index.js';\nimport { TOOLTIP_DIRECTIONS, TOOLTIP_DELAY_MS } from '@/components/tooltip/index.js';\nimport { getUniqueString } from '@/common/utils';\n\nconst props = defineProps({\n /**\n * Fade transition when the content display is toggled.\n * @type boolean\n * @values true, false\n */\n transition: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Controls whether the hovercard is shown. Leaving this null will have the hovercard trigger on hover by default.\n * If you set this value, the default trigger behavior will be disabled, and you can control it as you need.\n * Supports .sync modifier\n * @values null, true, false\n */\n open: {\n type: Boolean,\n default: null,\n },\n\n /**\n * If the popover does not fit in the direction described by \"placement\",\n * it will attempt to change its direction to the \"fallbackPlacements\".\n * @see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements\"\n */\n fallbackPlacements: {\n type: Array,\n default: () => {\n return ['auto'];\n },\n },\n\n /**\n * The direction the popover displays relative to the anchor.\n * @see https://atomiks.github.io/tippyjs/v6/all-props/#placement\"\n * @values top, top-start, top-end,\n * right, right-start, right-end,\n * left, left-start, left-end,\n * bottom, bottom-start, bottom-end,\n * auto, auto-start, auto-end\n */\n placement: {\n type: String,\n default: 'top-start',\n validator (placement) {\n return TOOLTIP_DIRECTIONS.includes(placement);\n },\n },\n\n /**\n * Padding size class for the popover content.\n * @values none, small, medium, large\n */\n padding: {\n type: String,\n default: 'large',\n validator: (padding) => {\n return Object.keys(POPOVER_PADDING_CLASSES).some((item) => item === padding);\n },\n },\n\n /**\n * Displaces the content box from its anchor element\n * by the specified number of pixels.\n * @see https://atomiks.github.io/tippyjs/v6/all-props/#offset\"\n */\n offset: {\n type: Array,\n default: () => [0, 16],\n },\n\n /**\n * The id of the tooltip\n */\n id: {\n type: String,\n default () { return getUniqueString(); },\n },\n\n /**\n * Additional class name for the header content wrapper element.\n */\n headerClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Additional class name for the footer content wrapper element.\n */\n footerClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Additional class name for the dialog element.\n */\n dialogClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Additional class name for the content wrapper element.\n */\n contentClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Sets the element to which the popover is going to append to.\n * 'body' will append to the nearest body (supports shadow DOM).\n * @values 'body', 'parent', HTMLElement,\n */\n appendTo: {\n type: [HTMLElement, String],\n default: 'body',\n validator: appendTo => {\n return POPOVER_APPEND_TO_VALUES.includes(appendTo) ||\n (appendTo instanceof HTMLElement);\n },\n },\n\n /**\n * The enter delay in milliseconds before the hovercard is shown.\n * @type number\n */\n enterDelay: {\n type: Number,\n default: TOOLTIP_DELAY_MS,\n },\n\n /**\n * The leave delay in milliseconds before the hovercard is hidden.\n * @type number\n */\n leaveDelay: {\n type: Number,\n default: TOOLTIP_DELAY_MS,\n },\n\n /**\n * External anchor element reference. Use this instead of the anchor slot when\n * the anchor may be inside a Shadow DOM, as querySelector cannot pierce shadow boundaries.\n */\n externalAnchorElement: {\n type: HTMLElement,\n default: null,\n },\n});\n\ndefineEmits([\n /**\n * Emitted when hovercard is shown or hidden\n *\n * @event opened\n * @type {Boolean | Array}\n */\n 'opened',\n]);\n\nconst hovercardOpen = ref(props.open);\nconst contentFocused = ref(false);\nconst mouseOverHovercard = ref(false);\nconst inTimer = ref(null);\nconst outTimer = ref(null);\nconst anchorEl = ref(null);\nconst observer = ref(null);\nconst popover = ref(null);\n\nonMounted(() => {\n nextTick(() => {\n anchorEl.value = popover.value?.$refs?.anchor?.firstElementChild;\n\n observer.value = new MutationObserver(() => {\n if (anchorEl.value && !anchorEl.value.isConnected) {\n hovercardOpen.value = false;\n }\n });\n\n observer.value.observe(document.body, {\n childList: true,\n subtree: true,\n });\n });\n});\n\nonBeforeUnmount(() => {\n if (observer.value) {\n observer.value.disconnect();\n }\n clearTimeout(inTimer);\n clearTimeout(outTimer);\n});\n\nwatch(() => props.open, (open) => {\n hovercardOpen.value = open;\n}, { immediate: true });\n\ndefineExpose({ show: onMouseEnter, hide: onMouseLeave });\n\nfunction setInTimer () {\n if (props.open === null) {\n clearTimeout(outTimer.value);\n inTimer.value = setTimeout(() => {\n hovercardOpen.value = true;\n }, props.enterDelay);\n }\n}\n\nfunction setOutTimer () {\n if (props.open === null) {\n clearTimeout(inTimer.value);\n outTimer.value = setTimeout(() => {\n hovercardOpen.value = false;\n }, props.leaveDelay);\n }\n}\n\nfunction onMouseEnter () {\n mouseOverHovercard.value = true;\n setInTimer();\n}\n\nfunction onMouseLeave () {\n mouseOverHovercard.value = false;\n if (contentFocused.value) {\n return;\n }\n setOutTimer();\n}\n\nfunction onContentFocusIn () {\n contentFocused.value = true;\n setInTimer();\n}\n\nfunction onContentFocusOut () {\n contentFocused.value = false;\n\n // If mouse is not over the hovercard, close it\n if (!mouseOverHovercard.value) {\n setOutTimer();\n }\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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IACvB,GAAY;;EAGd,SAAS,IAAqB;AAI5B,GAHA,EAAe,QAAQ,IAGlB,EAAmB,SACtB,GAAa;;yBAlTf,EAmDa,EAAA,EAAA,EAAA;GAlDV,IAAI,EAAA;YACD;GAAJ,KAAI;GACH,MAAM,EAAA;GACN,WAAW,EAAA;GACX,iBAAe,EAAA;GACf,gBAAc,EAAA;GACd,uBAAqB,EAAA;GACrB,SAAS,EAAA;GACT,YAAY,EAAA,aAAU,SAAA;GACtB,QAAQ,EAAA;GACR,OAAO;GACR,yBAAsB;GACrB,gBAAc,EAAA;GACd,gBAAc,EAAA;GACd,aAAW,EAAA;GACX,2BAAyB,EAAA;GAC1B,WAAQ;GACP,eAAa,EAAA;GACb,eAAa,EAAA;GACb,UAAM,EAAA,OAAA,EAAA,MAAG,MAAOA,EAAAA,MAAK,UAAW,EAAC;GACjC,qBAAoB;GACpB,qBAAoB;GACpB,2BAA2B;GAC3B,2BAA2B;;GAEjB,QAAM,GAKb,EALiB,eAAK,CAExB,EAGE,EAAA,QAAA,UAAA,EAAA,EADQ,EAAK,CAAA,CAAA,CAAA,CAAA;GAGN,SAAO,QAOV,CANN,EAMM,OAAA;IALH,WAAS;IACT,YAAU;OAGX,EAAuB,EAAA,QAAA,UAAA,CAAA,EAAA,GAAA,CAAA,CAAA;GAGhB,eAAa,QAEO,CAA7B,EAA6B,EAAA,QAAA,gBAAA,CAAA,CAAA;GAGpB,eAAa,QAEO,CAA7B,EAA6B,EAAA,QAAA,gBAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"hovercard.js","names":["$emit"],"sources":["../../../components/hovercard/hovercard.vue"],"sourcesContent":["<!-- eslint-disable vue/multi-word-component-names -->\n<template>\n <dt-popover\n :id=\"id\"\n ref=\"popover\"\n :open=\"hovercardOpen\"\n :placement=\"placement\"\n :content-class=\"contentClass\"\n :dialog-class=\"dialogClass\"\n :fallback-placements=\"fallbackPlacements\"\n :padding=\"padding\"\n :transition=\"transition ? 'fade' : null\"\n :offset=\"offset\"\n :modal=\"false\"\n initial-focus-element=\"none\"\n :header-class=\"headerClass\"\n :footer-class=\"footerClass\"\n :append-to=\"appendTo\"\n :external-anchor-element=\"externalAnchorElement\"\n data-qa=\"dt-hovercard\"\n :enter-delay=\"enterDelay\"\n :leave-delay=\"leaveDelay\"\n @opened=\"(e) => ($emit('opened', e))\"\n @mouseenter-popover=\"onMouseEnter\"\n @mouseleave-popover=\"onMouseLeave\"\n @mouseenter-popover-anchor=\"onMouseEnter\"\n @mouseleave-popover-anchor=\"onMouseLeave\"\n >\n <template #anchor=\"{ attrs }\">\n <!-- @slot Anchor element that activates the hovercard. Usually a button. -->\n <slot\n name=\"anchor\"\n v-bind=\"attrs\"\n />\n </template>\n <template #content>\n <div\n @focusin=\"onContentFocusIn\"\n @focusout=\"onContentFocusOut\"\n >\n <!-- @slot Slot for the content that is displayed in the hovercard. -->\n <slot name=\"content\" />\n </div>\n </template>\n <template #headerContent>\n <!-- @slot Slot for hovercard header content -->\n <slot name=\"headerContent\" />\n </template>\n\n <template #footerContent>\n <!-- @slot Slot for the footer content. -->\n <slot name=\"footerContent\" />\n </template>\n </dt-popover>\n</template>\n\n<script setup>\nimport { ref, watch, nextTick, onMounted, onBeforeUnmount } from 'vue';\nimport { POPOVER_APPEND_TO_VALUES, POPOVER_PADDING_CLASSES, DtPopover } from '@/components/popover/index.js';\nimport { TOOLTIP_DIRECTIONS, TOOLTIP_DELAY_MS } from '@/components/tooltip/index.js';\nimport { getUniqueString } from '@/common/utils';\nimport { HTML_ELEMENT_TYPE } from '@/common/constants';\n\nconst props = defineProps({\n /**\n * Fade transition when the content display is toggled.\n * @type boolean\n * @values true, false\n */\n transition: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Controls whether the hovercard is shown. Leaving this null will have the hovercard trigger on hover by default.\n * If you set this value, the default trigger behavior will be disabled, and you can control it as you need.\n * Supports .sync modifier\n * @values null, true, false\n */\n open: {\n type: Boolean,\n default: null,\n },\n\n /**\n * If the popover does not fit in the direction described by \"placement\",\n * it will attempt to change its direction to the \"fallbackPlacements\".\n * @see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements\"\n */\n fallbackPlacements: {\n type: Array,\n default: () => {\n return ['auto'];\n },\n },\n\n /**\n * The direction the popover displays relative to the anchor.\n * @see https://atomiks.github.io/tippyjs/v6/all-props/#placement\"\n * @values top, top-start, top-end,\n * right, right-start, right-end,\n * left, left-start, left-end,\n * bottom, bottom-start, bottom-end,\n * auto, auto-start, auto-end\n */\n placement: {\n type: String,\n default: 'top-start',\n validator (placement) {\n return TOOLTIP_DIRECTIONS.includes(placement);\n },\n },\n\n /**\n * Padding size class for the popover content.\n * @values none, small, medium, large\n */\n padding: {\n type: String,\n default: 'large',\n validator: (padding) => {\n return Object.keys(POPOVER_PADDING_CLASSES).some((item) => item === padding);\n },\n },\n\n /**\n * Displaces the content box from its anchor element\n * by the specified number of pixels.\n * @see https://atomiks.github.io/tippyjs/v6/all-props/#offset\"\n */\n offset: {\n type: Array,\n default: () => [0, 16],\n },\n\n /**\n * The id of the tooltip\n */\n id: {\n type: String,\n default () { return getUniqueString(); },\n },\n\n /**\n * Additional class name for the header content wrapper element.\n */\n headerClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Additional class name for the footer content wrapper element.\n */\n footerClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Additional class name for the dialog element.\n */\n dialogClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Additional class name for the content wrapper element.\n */\n contentClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Sets the element to which the popover is going to append to.\n * 'body' will append to the nearest body (supports shadow DOM).\n * @values 'body', 'parent', HTMLElement,\n */\n appendTo: {\n type: [HTML_ELEMENT_TYPE, String],\n default: 'body',\n validator: appendTo => {\n return POPOVER_APPEND_TO_VALUES.includes(appendTo) ||\n (appendTo instanceof HTMLElement);\n },\n },\n\n /**\n * The enter delay in milliseconds before the hovercard is shown.\n * @type number\n */\n enterDelay: {\n type: Number,\n default: TOOLTIP_DELAY_MS,\n },\n\n /**\n * The leave delay in milliseconds before the hovercard is hidden.\n * @type number\n */\n leaveDelay: {\n type: Number,\n default: TOOLTIP_DELAY_MS,\n },\n\n /**\n * External anchor element reference. Use this instead of the anchor slot when\n * the anchor may be inside a Shadow DOM, as querySelector cannot pierce shadow boundaries.\n */\n externalAnchorElement: {\n type: HTML_ELEMENT_TYPE,\n default: null,\n },\n});\n\ndefineEmits([\n /**\n * Emitted when hovercard is shown or hidden\n *\n * @event opened\n * @type {Boolean | Array}\n */\n 'opened',\n]);\n\nconst hovercardOpen = ref(props.open);\nconst contentFocused = ref(false);\nconst mouseOverHovercard = ref(false);\nconst inTimer = ref(null);\nconst outTimer = ref(null);\nconst anchorEl = ref(null);\nconst observer = ref(null);\nconst popover = ref(null);\n\nonMounted(() => {\n nextTick(() => {\n anchorEl.value = popover.value?.$refs?.anchor?.firstElementChild;\n\n observer.value = new MutationObserver(() => {\n if (anchorEl.value && !anchorEl.value.isConnected) {\n hovercardOpen.value = false;\n }\n });\n\n observer.value.observe(document.body, {\n childList: true,\n subtree: true,\n });\n });\n});\n\nonBeforeUnmount(() => {\n if (observer.value) {\n observer.value.disconnect();\n }\n clearTimeout(inTimer);\n clearTimeout(outTimer);\n});\n\nwatch(() => props.open, (open) => {\n hovercardOpen.value = open;\n}, { immediate: true });\n\ndefineExpose({ show: onMouseEnter, hide: onMouseLeave });\n\nfunction setInTimer () {\n if (props.open === null) {\n clearTimeout(outTimer.value);\n inTimer.value = setTimeout(() => {\n hovercardOpen.value = true;\n }, props.enterDelay);\n }\n}\n\nfunction setOutTimer () {\n if (props.open === null) {\n clearTimeout(inTimer.value);\n outTimer.value = setTimeout(() => {\n hovercardOpen.value = false;\n }, props.leaveDelay);\n }\n}\n\nfunction onMouseEnter () {\n mouseOverHovercard.value = true;\n setInTimer();\n}\n\nfunction onMouseLeave () {\n mouseOverHovercard.value = false;\n if (contentFocused.value) {\n return;\n }\n setOutTimer();\n}\n\nfunction onContentFocusIn () {\n contentFocused.value = true;\n setInTimer();\n}\n\nfunction onContentFocusOut () {\n contentFocused.value = false;\n\n // If mouse is not over the hovercard, close it\n if (!mouseOverHovercard.value) {\n setOutTimer();\n }\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+DA,IAAM,IAAQ,GAqKR,IAAgB,EAAI,EAAM,KAAK,EAC/B,IAAiB,EAAI,GAAM,EAC3B,IAAqB,EAAI,GAAM,EAC/B,IAAU,EAAI,KAAK,EACnB,IAAW,EAAI,KAAK,EACpB,IAAW,EAAI,KAAK,EACpB,IAAW,EAAI,KAAK,EACpB,IAAU,EAAI,KAAK;AA+BzB,EA7BA,QAAgB;AACd,WAAe;AASb,IARA,EAAS,QAAQ,EAAQ,OAAO,OAAO,QAAQ,mBAE/C,EAAS,QAAQ,IAAI,uBAAuB;AAC1C,KAAI,EAAS,SAAS,CAAC,EAAS,MAAM,gBACpC,EAAc,QAAQ;MAExB,EAEF,EAAS,MAAM,QAAQ,SAAS,MAAM;KACpC,WAAW;KACX,SAAS;KACV,CAAC;KACF;IACF,EAEF,QAAsB;AAKpB,GAJI,EAAS,SACX,EAAS,MAAM,YAAY,EAE7B,aAAa,EAAQ,EACrB,aAAa,EAAS;IACtB,EAEF,QAAY,EAAM,OAAO,MAAS;AAChC,KAAc,QAAQ;KACrB,EAAE,WAAW,IAAM,CAAC,EAEvB,EAAa;GAAE,MAAM;GAAc,MAAM;GAAc,CAAC;EAExD,SAAS,IAAc;AACrB,GAAI,EAAM,SAAS,SACjB,aAAa,EAAS,MAAM,EAC5B,EAAQ,QAAQ,iBAAiB;AAC/B,MAAc,QAAQ;MACrB,EAAM,WAAW;;EAIxB,SAAS,IAAe;AACtB,GAAI,EAAM,SAAS,SACjB,aAAa,EAAQ,MAAM,EAC3B,E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
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../../chunk-Bmb41Sf3.cjs`);const e=require(`../../common/constants/index.cjs`),t=require(`../../common/utils/index.cjs`),n=require(`../../common/mixins/input.cjs`),r=require(`../../_plugin-vue_export-helper-D8jCH6HB.cjs`),i=require(`../validation-messages/validation-messages.cjs`),a=require(`./input-constants.cjs`);let o=require(`vue`);var s={compatConfig:{MODE:3},name:`DtInput`,components:{DtValidationMessages:i.default},mixins:[n.MessagesMixin],inheritAttrs:!1,props:{name:{type:String,default:``},type:{type:String,default:a.INPUT_TYPES.TEXT,validator:e=>Object.values(a.INPUT_TYPES).includes(e)},modelValue:{type:[String,Number],default:``},disabled:{type:Boolean,default:!1},label:{type:String,default:``},labelVisible:{type:Boolean,default:!0},description:{type:String,default:``},size:{type:String,default:`md`,validator:e=>Object.values(a.INPUT_SIZES).includes(e)},inputClass:{type:[String,Object,Array],default:``},inputWrapperClass:{type:[String,Object,Array],default:``},rootClass:{type:[String,Object,Array],default:``},currentLength:{type:Number,default:null},retainWarning:{type:Boolean,default:!1},validate:{type:Object,default:null},hidden:{type:Boolean,default:!1}},emits:[`input`,`blur`,`clear`,`focus`,`focusin`,`focusout`,`update:modelValue`,`update:length`,`update:invalid`],data(){return{isInputFocused:!1,isInvalid:!1,defaultLength:0,hasSlotContent:t.hasSlotContent,isComposing:!1,justEndedComposition:!1}},computed:{isTextarea(){return this.type===a.INPUT_TYPES.TEXTAREA},isDefaultSize(){return this.size===a.INPUT_SIZES.DEFAULT},iconSize(){return a.INPUT_ICON_SIZES[this.size]},isValidSize(){return Object.values(a.INPUT_SIZES).includes(this.size)},isValidDescriptionSize(){return Object.values(e.DESCRIPTION_SIZE_TYPES).includes(this.size)},inputComponent(){return this.isTextarea?`textarea`:`input`},inputListeners(){return{compositionstart:()=>{this.isComposing=!0},compositionend:()=>{this.isComposing=!1,this.justEndedComposition=!0;let e=this.$refs.input.value;this.$emit(`input`,e),this.$emit(`update:modelValue`,e),Promise.resolve().then(()=>{this.justEndedComposition=!1})},input:async e=>{if(this.isComposing||this.justEndedComposition)return;let t=e.target.value;this.type===a.INPUT_TYPES.FILE&&(t=Array.from(e.target.files).map(e=>e.name)),this.$emit(`input`,t),this.$emit(`update:modelValue`,t)},blur:e=>{this.isInputFocused=!1,this.onBlur(e)},focus:e=>{this.isInputFocused=!0,this.$emit(`focus`,e)},focusin:e=>this.$emit(`focusin`,e),focusout:e=>this.$emit(`focusout`,e)}},descriptionKey(){return`input-description-${t.getUniqueString()}`},inputState(){return t.getValidationState(this.validationMessages)},defaultLengthCalculation(){return this.calculateLength(this.modelValue)},validationProps(){return{length:{description:this?.validate?.length?.description,max:this?.validate?.length?.max,warn:this?.validate?.length?.warn,message:this?.validate?.length?.message,limitMaxLength:this?.validate?.length?.limitMaxLength?this.validate.length.limitMaxLength:!1}}},validationMessages(){return this.showLengthLimitValidation?this.formattedMessages.concat([this.inputLengthErrorMessage()]):this.formattedMessages},showInputState(){return this.showMessages&&this.inputState},inputLength(){return this.currentLength?this.currentLength:this.defaultLengthCalculation},inputLengthState(){return this.inputLength<this.validationProps.length.warn?null:this.inputLength<=this.validationProps.length.max?this.validationProps.length.warn?e.VALIDATION_MESSAGE_TYPES.WARNING:null:e.VALIDATION_MESSAGE_TYPES.ERROR},shouldValidateLength(){return!!(this.validationProps.length.description&&this.validationProps.length.max)},shouldLimitMaxLength(){return this.shouldValidateLength&&this.validationProps.length.limitMaxLength},showLengthLimitValidation(){return this.shouldValidateLength&&this.inputLengthState!==null&&this.validationProps.length.message&&(this.retainWarning||this.isInputFocused||this.isInvalid)},sizeModifierClass(){return this.isDefaultSize||!this.isValidSize?``:a.INPUT_SIZE_CLASSES[this.inputComponent][this.size]},stateClass(){return[a.INPUT_STATE_CLASSES[this.inputState]]}},watch:{isInvalid(e){this.$emit(`update:invalid`,e)},modelValue:{immediate:!0,handler(e){this.shouldValidateLength&&this.validateLength(this.inputLength),this.currentLength??this.$emit(`update:length`,this.calculateLength(e)),this.isTextarea&&!this.isComposing&&this.$refs.input&&this.$refs.input.value!==e&&(this.$refs.input.value=e)}}},beforeMount(){
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../../chunk-Bmb41Sf3.cjs`);const e=require(`../../common/constants/index.cjs`),t=require(`../../common/utils/index.cjs`),n=require(`../../common/mixins/input.cjs`),r=require(`../../_plugin-vue_export-helper-D8jCH6HB.cjs`),i=require(`../validation-messages/validation-messages.cjs`),a=require(`./input-constants.cjs`);let o=require(`vue`);var s={compatConfig:{MODE:3},name:`DtInput`,components:{DtValidationMessages:i.default},mixins:[n.MessagesMixin],inheritAttrs:!1,props:{name:{type:String,default:``},type:{type:String,default:a.INPUT_TYPES.TEXT,validator:e=>Object.values(a.INPUT_TYPES).includes(e)},modelValue:{type:[String,Number],default:``},disabled:{type:Boolean,default:!1},label:{type:String,default:``},labelVisible:{type:Boolean,default:!0},description:{type:String,default:``},size:{type:String,default:`md`,validator:e=>Object.values(a.INPUT_SIZES).includes(e)},inputClass:{type:[String,Object,Array],default:``},inputWrapperClass:{type:[String,Object,Array],default:``},rootClass:{type:[String,Object,Array],default:``},currentLength:{type:Number,default:null},retainWarning:{type:Boolean,default:!1},validate:{type:Object,default:null},hidden:{type:Boolean,default:!1}},emits:[`input`,`blur`,`clear`,`focus`,`focusin`,`focusout`,`update:modelValue`,`update:length`,`update:invalid`],data(){return{isInputFocused:!1,isInvalid:!1,defaultLength:0,hasSlotContent:t.hasSlotContent,isComposing:!1,justEndedComposition:!1,labelSizeClasses:a.LABEL_SIZE_CLASSES,descriptionSizeClasses:a.DESCRIPTION_SIZE_CLASSES}},computed:{isTextarea(){return this.type===a.INPUT_TYPES.TEXTAREA},isDefaultSize(){return this.size===a.INPUT_SIZES.DEFAULT},iconSize(){return a.INPUT_ICON_SIZES[this.size]},isValidSize(){return Object.values(a.INPUT_SIZES).includes(this.size)},isValidDescriptionSize(){return Object.values(e.DESCRIPTION_SIZE_TYPES).includes(this.size)},inputComponent(){return this.isTextarea?`textarea`:`input`},inputListeners(){return{compositionstart:()=>{this.isComposing=!0},compositionend:()=>{this.isComposing=!1,this.justEndedComposition=!0;let e=this.$refs.input.value;this.$emit(`input`,e),this.$emit(`update:modelValue`,e),Promise.resolve().then(()=>{this.justEndedComposition=!1})},input:async e=>{if(this.isComposing||this.justEndedComposition)return;let t=e.target.value;this.type===a.INPUT_TYPES.FILE&&(t=Array.from(e.target.files).map(e=>e.name)),this.$emit(`input`,t),this.$emit(`update:modelValue`,t)},blur:e=>{this.isInputFocused=!1,this.onBlur(e)},focus:e=>{this.isInputFocused=!0,this.$emit(`focus`,e)},focusin:e=>this.$emit(`focusin`,e),focusout:e=>this.$emit(`focusout`,e)}},descriptionKey(){return`input-description-${t.getUniqueString()}`},inputState(){return t.getValidationState(this.validationMessages)},defaultLengthCalculation(){return this.calculateLength(this.modelValue)},validationProps(){return{length:{description:this?.validate?.length?.description,max:this?.validate?.length?.max,warn:this?.validate?.length?.warn,message:this?.validate?.length?.message,limitMaxLength:this?.validate?.length?.limitMaxLength?this.validate.length.limitMaxLength:!1}}},validationMessages(){return this.showLengthLimitValidation?this.formattedMessages.concat([this.inputLengthErrorMessage()]):this.formattedMessages},showInputState(){return this.showMessages&&this.inputState},inputLength(){return this.currentLength?this.currentLength:this.defaultLengthCalculation},inputLengthState(){return this.inputLength<this.validationProps.length.warn?null:this.inputLength<=this.validationProps.length.max?this.validationProps.length.warn?e.VALIDATION_MESSAGE_TYPES.WARNING:null:e.VALIDATION_MESSAGE_TYPES.ERROR},shouldValidateLength(){return!!(this.validationProps.length.description&&this.validationProps.length.max)},shouldLimitMaxLength(){return this.shouldValidateLength&&this.validationProps.length.limitMaxLength},showLengthLimitValidation(){return this.shouldValidateLength&&this.inputLengthState!==null&&this.validationProps.length.message&&(this.retainWarning||this.isInputFocused||this.isInvalid)},sizeModifierClass(){return this.isDefaultSize||!this.isValidSize?``:a.INPUT_SIZE_CLASSES[this.inputComponent][this.size]},stateClass(){return[a.INPUT_STATE_CLASSES[this.inputState]]}},watch:{isInvalid(e){this.$emit(`update:invalid`,e)},modelValue:{immediate:!0,handler(e){this.shouldValidateLength&&this.validateLength(this.inputLength),this.currentLength??this.$emit(`update:length`,this.calculateLength(e)),this.isTextarea&&!this.isComposing&&this.$refs.input&&this.$refs.input.value!==e&&(this.$refs.input.value=e)}}},beforeMount(){},mounted(){this.isTextarea&&this.$refs.input&&(this.$refs.input.value=this.modelValue)},methods:{removeClassStyleAttrs:t.removeClassStyleAttrs,addClassStyleAttrs:t.addClassStyleAttrs,inputClasses(){return[`d-input__input`,this.inputComponent===`input`?`d-input`:`d-textarea`,{[this.stateClass]:this.showInputState,"d-input-icon--left":this.$slots.leftIcon,"d-input-icon--right":this.$slots.rightIcon},this.sizeModifierClass,this.inputClass]},inputWrapperClasses(){return this.hidden?[]:[`d-input__wrapper`,{[this.stateClass]:this.showInputState},this.inputWrapperClass]},calculateLength(e){return typeof e==`string`?[...e].length:0},inputLengthErrorMessage(){return{message:this.validationProps.length.message,type:this.inputLengthState}},onBlur(e){this.$refs.container?.contains(e.relatedTarget)||this.$emit(`blur`,e)},emitClearEvents(){this.$emit(`input`,``),this.$emit(`clear`),this.$emit(`update:modelValue`,``)},blur(){this.$refs.input.blur()},focus(){this.$refs.input.focus()},select(){this.$refs.input.select()},getMessageKey(e,t){return`message-${e}-${t}`},validateLength(e){this.isInvalid=e>this.validationProps.length.max},clearInput(){this.$refs.input.value=``,this.$refs.input.focus(),this.emitClearEvents()}}},c=[`aria-details`],l=[`id`],u={key:0},d={key:1,"data-qa":`dt-input-length-description`,class:`d-input__length-description`},f=[`read-only`],p=[`name`,`disabled`,`autocomplete`,`maxlength`],m=[`value`,`name`,`type`,`disabled`,`autocomplete`,`maxlength`];function h(e,t,n,r,i,a){let s=(0,o.resolveComponent)(`dt-validation-messages`);return(0,o.openBlock)(),(0,o.createElementBlock)(`div`,(0,o.mergeProps)({ref:`container`,class:[n.rootClass,`d-input__root`,{"d-input--hidden":n.hidden}]},a.addClassStyleAttrs(e.$attrs),{"data-qa":`dt-input`}),[(0,o.createElementVNode)(`label`,{class:`d-input__label`,"aria-details":e.$slots.description||n.description?a.descriptionKey:void 0,"data-qa":`dt-input-label-wrapper`},[(0,o.renderSlot)(e.$slots,`labelSlot`,{},()=>[n.labelVisible&&n.label?((0,o.openBlock)(),(0,o.createElementBlock)(`div`,{key:0,ref:`label`,"data-qa":`dt-input-label`,class:(0,o.normalizeClass)([`d-input__label-text`,`d-label`,i.labelSizeClasses[n.size]])},(0,o.toDisplayString)(n.label),3)):(0,o.createCommentVNode)(``,!0)]),i.hasSlotContent(e.$slots.description)||n.description||a.shouldValidateLength?((0,o.openBlock)(),(0,o.createElementBlock)(`div`,{key:0,id:a.descriptionKey,ref:`description`,class:(0,o.normalizeClass)([`d-input__description`,`d-description`,i.descriptionSizeClasses[n.size]]),"data-qa":`dt-input-description`},[i.hasSlotContent(e.$slots.description)||n.description?((0,o.openBlock)(),(0,o.createElementBlock)(`div`,u,[(0,o.renderSlot)(e.$slots,`description`,{},()=>[(0,o.createTextVNode)((0,o.toDisplayString)(n.description),1)])])):(0,o.createCommentVNode)(``,!0),a.shouldValidateLength?((0,o.openBlock)(),(0,o.createElementBlock)(`div`,d,(0,o.toDisplayString)(a.validationProps.length.description),1)):(0,o.createCommentVNode)(``,!0)],10,l)):(0,o.createCommentVNode)(``,!0),(0,o.createElementVNode)(`div`,{class:(0,o.normalizeClass)(a.inputWrapperClasses()),"read-only":n.disabled===!0?!0:void 0},[(0,o.createElementVNode)(`span`,{class:`d-input-icon d-input-icon--left`,"data-qa":`dt-input-left-icon-wrapper`,onFocusout:t[0]||(t[0]=(...e)=>a.onBlur&&a.onBlur(...e))},[(0,o.renderSlot)(e.$slots,`leftIcon`,{iconSize:a.iconSize})],32),a.isTextarea?((0,o.openBlock)(),(0,o.createElementBlock)(`textarea`,(0,o.mergeProps)({key:0,ref:`input`,name:n.name,disabled:n.disabled,autocomplete:e.$attrs.autocomplete??`off`,class:a.inputClasses(),maxlength:a.shouldLimitMaxLength?a.validationProps.length.max:null,"data-qa":`dt-input-input`},a.removeClassStyleAttrs(e.$attrs),(0,o.toHandlers)(a.inputListeners,!0)),null,16,p)):((0,o.openBlock)(),(0,o.createElementBlock)(`input`,(0,o.mergeProps)({key:1,ref:`input`,value:n.modelValue,name:n.name,type:n.type,disabled:n.disabled,autocomplete:e.$attrs.autocomplete??`off`,class:a.inputClasses(),maxlength:a.shouldLimitMaxLength?a.validationProps.length.max:null,"data-qa":`dt-input-input`},a.removeClassStyleAttrs(e.$attrs),(0,o.toHandlers)(a.inputListeners,!0)),null,16,m)),(0,o.createElementVNode)(`span`,{class:`d-input-icon d-input-icon--right`,"data-qa":`dt-input-right-icon-wrapper`,onFocusout:t[1]||(t[1]=(...e)=>a.onBlur&&a.onBlur(...e))},[(0,o.renderSlot)(e.$slots,`rightIcon`,{iconSize:a.iconSize,clear:a.clearInput})],32)],10,f)],8,c),(0,o.createVNode)(s,(0,o.mergeProps)({"validation-messages":a.validationMessages,"show-messages":e.showMessages,class:e.messagesClass},e.messagesChildProps,{"data-qa":`dt-input-messages`}),null,16,[`validation-messages`,`show-messages`,`class`])],16)}var g=r.t(s,[[`render`,h]]);exports.default=g;
|
|
2
2
|
//# sourceMappingURL=input.cjs.map
|