@dialpad/dialtone-vue 3.222.0 → 3.222.1
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 +5 -5
- 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/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/modal/modal.cjs +1 -1
- package/dist/lib/modal/modal.cjs.map +1 -1
- package/dist/lib/modal/modal.js +56 -56
- 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 +75 -74
- 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/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/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/package.json +1 -1
|
@@ -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,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EACX,wBAAsB,EAAA;EACtB,mBAAiB,EAAA;IACV,EAAA,QAAM;EACb,QAAQ,EAAA;EACR,YAAY,EAAA;IACb,EAAwB,EAAlB,kBAAiB,CAAA,EAAA;EAEZ,QAAM,GAMb,EANiB,eAAK,CAExB,EAIE,EAAA,QAAA,UAJF,EAIE,EAHA,KAAI,UAAQ,EAEJ,EAAK,CAAA,CAAA,CAAA;EAGN,SAAO,GAgBX,EAhBe,eAAK,CAGzB,EAaK,MAAA;GAZF,IAAI,EAAA;GACL,KAAI;GACH,OAAK,EAAE,EAAA,YAAW;GACnB,WAAQ;GACP,cAAU,EAAA,OAAA,EAAA,MAAA,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;GAC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,EAhBe,eAAK,CAGzB,EAaK,MAAA;GAZF,IAAI,EAAA;GACL,KAAI;GACH,OAAK,EAAE,EAAA,YAAW;GACnB,WAAQ;GACP,cAAU,EAAA,OAAA,EAAA,MAAA,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,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,CACpB,GAAA,EAAA,EAAA,KAAe,KAAK,CACpB,GAAA,EAAA,EAAA,KAAc,KAAK,EAEzB,EAAA,EAAA,eAAgB,EACd,EAA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AAA,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 (!mouseOverHovercard.value) {\n setOutTimer();\n }\n}\n</script>\n"],"mappings":"o0CA+DA,IAAM,EAAQ,EAqKR,GAAA,EAAA,EAAA,KAAo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AqB,CAC5B,EAAe,MAAQ,GAGlB,EAAmB,OACtB,GAAa,+DAhQF,EAAA,QAAA,CAAA,CAlDV,GAAI,EAAA,WACD,UAAJ,IAAI,EACH,KAAM,EAAA,MACN,UAAW,EAAA,UACX,gBAAe,EAAA,aACf,eAAc,EAAA,YACd,sBAAqB,EAAA,mBACrB,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,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import i from "../popover/popover.js";
|
|
5
|
-
import
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8DA,IAAM,IAAQ,GAqKR,IAAgB,EAAI,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AAA,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 //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,IAC3B,GAAY;;EAGd,SAAS,IAAgB;AACvB,KAAmB,QAAQ,IACvB,GAAe,SAGnB,GAAa;;EAGf,SAAS,IAAoB;AAE3B,GADA,EAAe,QAAQ,IACvB,GAAY;;EAGd,SAAS,IAAqB;AAI5B,GAHA,EAAe,QAAQ,IAGlB,EAAmB,SACtB,GAAa;;yBAnTf,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"}
|
package/dist/lib/input/input.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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}},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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.cjs","names":[],"sources":["../../../components/input/input.vue"],"sourcesContent":["<template>\n <div\n ref=\"container\"\n :class=\"[rootClass, 'd-input__root', { 'd-input--hidden': hidden }]\"\n v-bind=\"addClassStyleAttrs($attrs)\"\n data-qa=\"dt-input\"\n >\n <label\n class=\"d-input__label\"\n :aria-details=\"$slots.description || description ? descriptionKey : undefined\"\n data-qa=\"dt-input-label-wrapper\"\n >\n <!-- @slot Slot for label, defaults to label prop -->\n <slot name=\"labelSlot\">\n <div\n v-if=\"labelVisible && label\"\n ref=\"label\"\n data-qa=\"dt-input-label\"\n :class=\"[\n 'd-input__label-text',\n 'd-label',\n labelSizeClasses[size],\n ]\"\n >\n {{ label }}\n </div>\n </slot>\n <div\n v-if=\"hasSlotContent($slots.description) || description || shouldValidateLength\"\n :id=\"descriptionKey\"\n ref=\"description\"\n :class=\"[\n 'd-input__description',\n 'd-description',\n descriptionSizeClasses[size],\n ]\"\n data-qa=\"dt-input-description\"\n >\n <div\n v-if=\"hasSlotContent($slots.description) || description\"\n >\n <!-- @slot Slot for description, defaults to description prop -->\n <slot name=\"description\">{{ description }}</slot>\n </div>\n <div\n v-if=\"shouldValidateLength\"\n data-qa=\"dt-input-length-description\"\n class=\"d-input__length-description\"\n >\n {{ validationProps.length.description }}\n </div>\n </div>\n <div\n :class=\"inputWrapperClasses()\"\n :read-only=\"disabled === true ? true : undefined\"\n >\n <span\n class=\"d-input-icon d-input-icon--left\"\n data-qa=\"dt-input-left-icon-wrapper\"\n @focusout=\"onBlur\"\n >\n <!-- @slot Slot for left icon -->\n <slot\n name=\"leftIcon\"\n :icon-size=\"iconSize\"\n />\n </span>\n <textarea\n v-if=\"isTextarea\"\n ref=\"input\"\n :name=\"name\"\n :disabled=\"disabled\"\n :autocomplete=\"$attrs.autocomplete ?? 'off'\"\n :class=\"inputClasses()\"\n :maxlength=\"shouldLimitMaxLength ? validationProps.length.max : null\"\n data-qa=\"dt-input-input\"\n v-bind=\"removeClassStyleAttrs($attrs)\"\n v-on=\"inputListeners\"\n />\n <input\n v-else\n ref=\"input\"\n :value=\"modelValue\"\n :name=\"name\"\n :type=\"type\"\n :disabled=\"disabled\"\n :autocomplete=\"$attrs.autocomplete ?? 'off'\"\n :class=\"inputClasses()\"\n :maxlength=\"shouldLimitMaxLength ? validationProps.length.max : null\"\n data-qa=\"dt-input-input\"\n v-bind=\"removeClassStyleAttrs($attrs)\"\n v-on=\"inputListeners\"\n >\n <span\n class=\"d-input-icon d-input-icon--right\"\n data-qa=\"dt-input-right-icon-wrapper\"\n @focusout=\"onBlur\"\n >\n <!-- @slot Slot for right icon -->\n <slot\n name=\"rightIcon\"\n :icon-size=\"iconSize\"\n :clear=\"clearInput\"\n />\n </span>\n </div>\n </label>\n <dt-validation-messages\n :validation-messages=\"validationMessages\"\n :show-messages=\"showMessages\"\n :class=\"messagesClass\"\n v-bind=\"messagesChildProps\"\n data-qa=\"dt-input-messages\"\n />\n </div>\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport { DESCRIPTION_SIZE_TYPES, VALIDATION_MESSAGE_TYPES } from '@/common/constants';\nimport {\n INPUT_TYPES,\n INPUT_SIZES,\n INPUT_SIZE_CLASSES,\n INPUT_ICON_SIZES,\n INPUT_STATE_CLASSES,\n DESCRIPTION_SIZE_CLASSES,\n LABEL_SIZE_CLASSES,\n} from './input_constants';\nimport {\n getUniqueString,\n getValidationState,\n hasSlotContent,\n removeClassStyleAttrs,\n addClassStyleAttrs,\n} from '@/common/utils';\nimport { DtValidationMessages } from '@/components/validation_messages';\nimport { MessagesMixin } from '@/common/mixins/input';\n\n/**\n * An input field is an input control that allows users to enter alphanumeric information.\n * It can have a range of options and supports single line and multi-line lengths,\n * as well as varying formats, including numbers, masked passwords, etc.\n * @property {Boolean} placeholder attribute\n * @see https://dialtone.dialpad.com/components/input.html\n */\nexport default {\n compatConfig: { MODE: 3 },\n name: 'DtInput',\n\n components: { DtValidationMessages },\n\n mixins: [MessagesMixin],\n\n inheritAttrs: false,\n\n props: {\n /**\n * Name property of the input element\n */\n name: {\n type: String,\n default: '',\n },\n\n /**\n * Type of the input.\n * When `textarea` a `<textarea>` element will be rendered instead of an `<input>` element.\n * @values text, password, email, number, textarea, date, time, file, tel, search, color\n * @default 'text'\n */\n type: {\n type: String,\n default: INPUT_TYPES.TEXT,\n validator: (t) => Object.values(INPUT_TYPES).includes(t),\n },\n\n /**\n * Value of the input\n */\n modelValue: {\n type: [String, Number],\n default: '',\n },\n\n /**\n * Disables the input\n * @values true, false\n */\n disabled: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Label for the input\n */\n label: {\n type: String,\n default: '',\n },\n\n /**\n * Determines visibility of input label.\n * @values true, false\n */\n labelVisible: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Description for the input\n */\n description: {\n type: String,\n default: '',\n },\n\n /**\n * Size of the input, one of `xs`, `sm`, `md`, `lg`, `xl`\n * @values xs, sm, md, lg, xl\n */\n size: {\n type: String,\n default: 'md',\n validator: (t) => Object.values(INPUT_SIZES).includes(t),\n },\n\n /**\n * Additional class name for the input element.\n * Can accept String, Object, and Array, i.e. has the\n * same API as Vue's built-in handling of the class attribute.\n */\n inputClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Additional class name for the input wrapper element.\n * Can accept all of: String, Object, and Array, i.e. has the\n * same api as Vue's built-in handling of the class attribute.\n */\n inputWrapperClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Additional class name for the root element.\n * Can accept all of: String, Object, and Array, i.e. has the\n * same api as Vue's built-in handling of the class attribute.\n */\n rootClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * The current character length that the user has entered into the input.\n * This will only need to be used if you are using `validate.length` and\n * the string contains abnormal characters.\n * For example, an emoji could take up many characters in the input, but should only count as 1 character.\n * If no number is provided, a built-in length calculation will be used for the length validation.\n */\n currentLength: {\n type: Number,\n default: null,\n },\n\n /**\n * Whether the input will continue to display a warning validation message even if the input has lost focus.\n */\n retainWarning: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Validation for the input. Supports maximum length validation with the structure:\n * `{ \"length\": {\"description\": string, \"max\": number, \"warn\": number, \"message\": string,\n * \"limitMaxLength\": boolean }}`\n */\n validate: {\n type: Object,\n default: null,\n },\n\n /**\n * hidden allows to use input without the element visually present in DOM\n */\n hidden: {\n type: Boolean,\n default: false,\n },\n },\n\n emits: [\n /**\n * Native input event\n *\n * @event input\n * @type {String}\n */\n 'input',\n\n /**\n * Native input blur event\n *\n * @event blur\n * @type {FocusEvent}\n */\n 'blur',\n\n /**\n * Input clear event\n *\n * @event clear\n */\n 'clear',\n\n /**\n * Native input focus event\n *\n * @event focus\n * @type {FocusEvent}\n */\n 'focus',\n\n /**\n * Native input focusin event\n *\n * @event focusin\n * @type {FocusEvent}\n */\n 'focusin',\n\n /**\n * Native input focusout event\n *\n * @event focusout\n * @type {FocusEvent}\n */\n 'focusout',\n\n /**\n * Event fired to sync the modelValue prop with the parent component\n * @event update:modelValue\n */\n 'update:modelValue',\n\n /**\n * Length of the input when currentLength prop is not passed\n *\n * @event update:length\n * @type {Number}\n */\n 'update:length',\n\n /**\n * Result of the input validation\n *\n * @event update:invalid\n * @type {Boolean}\n */\n 'update:invalid',\n ],\n\n data () {\n return {\n isInputFocused: false,\n isInvalid: false,\n defaultLength: 0,\n hasSlotContent,\n isComposing: false,\n justEndedComposition: false,\n };\n },\n\n computed: {\n\n isTextarea () {\n return this.type === INPUT_TYPES.TEXTAREA;\n },\n\n isDefaultSize () {\n return this.size === INPUT_SIZES.DEFAULT;\n },\n\n iconSize () {\n return INPUT_ICON_SIZES[this.size];\n },\n\n isValidSize () {\n return Object.values(INPUT_SIZES).includes(this.size);\n },\n\n isValidDescriptionSize () {\n return Object.values(DESCRIPTION_SIZE_TYPES).includes(this.size);\n },\n\n inputComponent () {\n if (this.isTextarea) {\n return 'textarea';\n }\n\n return 'input';\n },\n\n inputListeners () {\n return {\n compositionstart: () => {\n this.isComposing = true;\n },\n\n compositionend: () => {\n this.isComposing = false;\n this.justEndedComposition = true;\n const val = this.$refs.input.value;\n this.$emit('input', val);\n this.$emit('update:modelValue', val);\n // Clear the flag after the current synchronous event processing so\n // Firefox's post-compositionend input event is skipped, but the\n // next real user input (a separate browser task) is not.\n Promise.resolve().then(() => { this.justEndedComposition = false; });\n },\n\n input: async event => {\n if (this.isComposing) return;\n if (this.justEndedComposition) return;\n let val = event.target.value;\n if (this.type === INPUT_TYPES.FILE) {\n const files = Array.from(event.target.files);\n val = files.map(file => file.name);\n }\n this.$emit('input', val);\n this.$emit('update:modelValue', val);\n },\n\n blur: event => {\n this.isInputFocused = false;\n this.onBlur(event);\n },\n\n focus: event => {\n this.isInputFocused = true;\n this.$emit('focus', event);\n },\n\n focusin: event => this.$emit('focusin', event),\n focusout: event => this.$emit('focusout', event),\n };\n },\n\n descriptionKey () {\n return `input-description-${getUniqueString()}`;\n },\n\n inputState () {\n return getValidationState(this.validationMessages);\n },\n\n defaultLengthCalculation () {\n return this.calculateLength(this.modelValue);\n },\n\n validationProps () {\n return {\n length: {\n description: this?.validate?.length?.description,\n max: this?.validate?.length?.max,\n warn: this?.validate?.length?.warn,\n message: this?.validate?.length?.message,\n limitMaxLength: this?.validate?.length?.limitMaxLength ? this.validate.length.limitMaxLength : false,\n },\n };\n },\n\n validationMessages () {\n // Add length validation message if exists\n if (this.showLengthLimitValidation) {\n return this.formattedMessages.concat([this.inputLengthErrorMessage()]);\n }\n\n return this.formattedMessages;\n },\n\n showInputState () {\n return this.showMessages && this.inputState;\n },\n\n inputLength () {\n return this.currentLength ? this.currentLength : this.defaultLengthCalculation;\n },\n\n inputLengthState () {\n if (this.inputLength < this.validationProps.length.warn) {\n return null;\n } else if (this.inputLength <= this.validationProps.length.max) {\n return this.validationProps.length.warn ? VALIDATION_MESSAGE_TYPES.WARNING : null;\n } else {\n return VALIDATION_MESSAGE_TYPES.ERROR;\n }\n },\n\n shouldValidateLength () {\n return !!(\n this.validationProps.length.description &&\n this.validationProps.length.max\n );\n },\n\n shouldLimitMaxLength () {\n return this.shouldValidateLength && this.validationProps.length.limitMaxLength;\n },\n\n showLengthLimitValidation () {\n return (\n this.shouldValidateLength &&\n this.inputLengthState !== null &&\n this.validationProps.length.message &&\n (this.retainWarning || this.isInputFocused || this.isInvalid)\n );\n },\n\n sizeModifierClass () {\n if (this.isDefaultSize || !this.isValidSize) {\n return '';\n }\n\n return INPUT_SIZE_CLASSES[this.inputComponent][this.size];\n },\n\n stateClass () {\n return [INPUT_STATE_CLASSES[this.inputState]];\n },\n },\n\n watch: {\n isInvalid (val) {\n this.$emit('update:invalid', val);\n },\n\n modelValue: {\n immediate: true,\n handler (newValue) {\n if (this.shouldValidateLength) {\n this.validateLength(this.inputLength);\n }\n\n if (this.currentLength == null) {\n this.$emit('update:length', this.calculateLength(newValue));\n }\n\n // Set textarea value programmatically to avoid attribute binding\n // Skip during IME composition to avoid interrupting in-progress input\n if (this.isTextarea && !this.isComposing && this.$refs.input && this.$refs.input.value !== newValue) {\n this.$refs.input.value = newValue;\n }\n },\n },\n },\n\n beforeMount () {\n this.descriptionSizeClasses = DESCRIPTION_SIZE_CLASSES;\n this.labelSizeClasses = LABEL_SIZE_CLASSES;\n },\n\n mounted () {\n // Set initial textarea value programmatically\n if (this.isTextarea && this.$refs.input) {\n this.$refs.input.value = this.modelValue;\n }\n },\n\n methods: {\n removeClassStyleAttrs,\n addClassStyleAttrs,\n inputClasses () {\n return [\n 'd-input__input',\n this.inputComponent === 'input' ? 'd-input' : 'd-textarea',\n {\n [this.stateClass]: this.showInputState,\n 'd-input-icon--left': this.$slots.leftIcon,\n 'd-input-icon--right': this.$slots.rightIcon,\n },\n this.sizeModifierClass,\n this.inputClass,\n ];\n },\n\n inputWrapperClasses () {\n if (this.hidden) {\n return [];\n }\n return [\n 'd-input__wrapper',\n { [this.stateClass]: this.showInputState },\n this.inputWrapperClass,\n ];\n },\n\n calculateLength (value) {\n if (typeof value !== 'string') {\n return 0;\n }\n\n return [...value].length;\n },\n\n inputLengthErrorMessage () {\n return {\n message: this.validationProps.length.message,\n type: this.inputLengthState,\n };\n },\n\n onBlur (e) {\n // Do not emit a blur event if the target element is a child of this component\n if (!this.$refs.container?.contains(e.relatedTarget)) {\n this.$emit('blur', e);\n }\n },\n\n emitClearEvents () {\n this.$emit('input', '');\n this.$emit('clear');\n this.$emit('update:modelValue', '');\n },\n\n blur () {\n this.$refs.input.blur();\n },\n\n focus () {\n this.$refs.input.focus();\n },\n\n select () {\n this.$refs.input.select();\n },\n\n getMessageKey (type, index) {\n return `message-${type}-${index}`;\n },\n\n validateLength (length) {\n this.isInvalid = (length > this.validationProps.length.max);\n },\n\n clearInput () {\n this.$refs.input.value = '';\n this.$refs.input.focus();\n this.emitCl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,sBAAsB,EAAA,OAAM,EAAA,EAAA,EAAA,YACf,EAAf,eAAc,GAAA,CAAA,CAAA,KAAA,GAAA,EAAA,2BAaf,OAAA,CAVL,MAAM,mCACN,UAAQ,8BACP,WAAQ,EAAA,KAAA,EAAA,IAAA,GAAA,IAAE,EAAA,QAAA,EAAA,OAAA,GAAA,EAAM,qBAOf,EAAA,OAAA,YAAA,CAFC,SAAW,EAAA,SACX,MAAO,EAAA,iDAWd,GAAA,EAAA,EAAA,YAAA,CALC,sBAAqB,EAAA,mBACrB,gBAAe,EAAA,aACf,MAAO,EAAA,eACA,EAAA,mBAAkB,CAC1B,UAAQ,oBAAmB,CAAA,CAAA,KAAA,GAAA,CAAA,sBAAA,gBAAA,QAAA,CAAA,CAAA,CAAA,GAAA"}
|
|
1
|
+
{"version":3,"file":"input.cjs","names":[],"sources":["../../../components/input/input.vue"],"sourcesContent":["<template>\n <div\n ref=\"container\"\n :class=\"[rootClass, 'd-input__root', { 'd-input--hidden': hidden }]\"\n v-bind=\"addClassStyleAttrs($attrs)\"\n data-qa=\"dt-input\"\n >\n <label\n class=\"d-input__label\"\n :aria-details=\"$slots.description || description ? descriptionKey : undefined\"\n data-qa=\"dt-input-label-wrapper\"\n >\n <!-- @slot Slot for label, defaults to label prop -->\n <slot name=\"labelSlot\">\n <div\n v-if=\"labelVisible && label\"\n ref=\"label\"\n data-qa=\"dt-input-label\"\n :class=\"[\n 'd-input__label-text',\n 'd-label',\n labelSizeClasses[size],\n ]\"\n >\n {{ label }}\n </div>\n </slot>\n <div\n v-if=\"hasSlotContent($slots.description) || description || shouldValidateLength\"\n :id=\"descriptionKey\"\n ref=\"description\"\n :class=\"[\n 'd-input__description',\n 'd-description',\n descriptionSizeClasses[size],\n ]\"\n data-qa=\"dt-input-description\"\n >\n <div\n v-if=\"hasSlotContent($slots.description) || description\"\n >\n <!-- @slot Slot for description, defaults to description prop -->\n <slot name=\"description\">{{ description }}</slot>\n </div>\n <div\n v-if=\"shouldValidateLength\"\n data-qa=\"dt-input-length-description\"\n class=\"d-input__length-description\"\n >\n {{ validationProps.length.description }}\n </div>\n </div>\n <div\n :class=\"inputWrapperClasses()\"\n :read-only=\"disabled === true ? true : undefined\"\n >\n <span\n class=\"d-input-icon d-input-icon--left\"\n data-qa=\"dt-input-left-icon-wrapper\"\n @focusout=\"onBlur\"\n >\n <!-- @slot Slot for left icon -->\n <slot\n name=\"leftIcon\"\n :icon-size=\"iconSize\"\n />\n </span>\n <textarea\n v-if=\"isTextarea\"\n ref=\"input\"\n :name=\"name\"\n :disabled=\"disabled\"\n :autocomplete=\"$attrs.autocomplete ?? 'off'\"\n :class=\"inputClasses()\"\n :maxlength=\"shouldLimitMaxLength ? validationProps.length.max : null\"\n data-qa=\"dt-input-input\"\n v-bind=\"removeClassStyleAttrs($attrs)\"\n v-on=\"inputListeners\"\n />\n <input\n v-else\n ref=\"input\"\n :value=\"modelValue\"\n :name=\"name\"\n :type=\"type\"\n :disabled=\"disabled\"\n :autocomplete=\"$attrs.autocomplete ?? 'off'\"\n :class=\"inputClasses()\"\n :maxlength=\"shouldLimitMaxLength ? validationProps.length.max : null\"\n data-qa=\"dt-input-input\"\n v-bind=\"removeClassStyleAttrs($attrs)\"\n v-on=\"inputListeners\"\n >\n <span\n class=\"d-input-icon d-input-icon--right\"\n data-qa=\"dt-input-right-icon-wrapper\"\n @focusout=\"onBlur\"\n >\n <!-- @slot Slot for right icon -->\n <slot\n name=\"rightIcon\"\n :icon-size=\"iconSize\"\n :clear=\"clearInput\"\n />\n </span>\n </div>\n </label>\n <dt-validation-messages\n :validation-messages=\"validationMessages\"\n :show-messages=\"showMessages\"\n :class=\"messagesClass\"\n v-bind=\"messagesChildProps\"\n data-qa=\"dt-input-messages\"\n />\n </div>\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport { DESCRIPTION_SIZE_TYPES, VALIDATION_MESSAGE_TYPES } from '@/common/constants';\nimport {\n INPUT_TYPES,\n INPUT_SIZES,\n INPUT_SIZE_CLASSES,\n INPUT_ICON_SIZES,\n INPUT_STATE_CLASSES,\n DESCRIPTION_SIZE_CLASSES,\n LABEL_SIZE_CLASSES,\n} from './input_constants';\nimport {\n getUniqueString,\n getValidationState,\n hasSlotContent,\n removeClassStyleAttrs,\n addClassStyleAttrs,\n} from '@/common/utils';\nimport { DtValidationMessages } from '@/components/validation_messages';\nimport { MessagesMixin } from '@/common/mixins/input';\n\n/**\n * An input field is an input control that allows users to enter alphanumeric information.\n * It can have a range of options and supports single line and multi-line lengths,\n * as well as varying formats, including numbers, masked passwords, etc.\n * @property {Boolean} placeholder attribute\n * @see https://dialtone.dialpad.com/components/input.html\n */\nexport default {\n compatConfig: { MODE: 3 },\n name: 'DtInput',\n\n components: { DtValidationMessages },\n\n mixins: [MessagesMixin],\n\n inheritAttrs: false,\n\n props: {\n /**\n * Name property of the input element\n */\n name: {\n type: String,\n default: '',\n },\n\n /**\n * Type of the input.\n * When `textarea` a `<textarea>` element will be rendered instead of an `<input>` element.\n * @values text, password, email, number, textarea, date, time, file, tel, search, color\n * @default 'text'\n */\n type: {\n type: String,\n default: INPUT_TYPES.TEXT,\n validator: (t) => Object.values(INPUT_TYPES).includes(t),\n },\n\n /**\n * Value of the input\n */\n modelValue: {\n type: [String, Number],\n default: '',\n },\n\n /**\n * Disables the input\n * @values true, false\n */\n disabled: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Label for the input\n */\n label: {\n type: String,\n default: '',\n },\n\n /**\n * Determines visibility of input label.\n * @values true, false\n */\n labelVisible: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Description for the input\n */\n description: {\n type: String,\n default: '',\n },\n\n /**\n * Size of the input, one of `xs`, `sm`, `md`, `lg`, `xl`\n * @values xs, sm, md, lg, xl\n */\n size: {\n type: String,\n default: 'md',\n validator: (t) => Object.values(INPUT_SIZES).includes(t),\n },\n\n /**\n * Additional class name for the input element.\n * Can accept String, Object, and Array, i.e. has the\n * same API as Vue's built-in handling of the class attribute.\n */\n inputClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Additional class name for the input wrapper element.\n * Can accept all of: String, Object, and Array, i.e. has the\n * same api as Vue's built-in handling of the class attribute.\n */\n inputWrapperClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * Additional class name for the root element.\n * Can accept all of: String, Object, and Array, i.e. has the\n * same api as Vue's built-in handling of the class attribute.\n */\n rootClass: {\n type: [String, Object, Array],\n default: '',\n },\n\n /**\n * The current character length that the user has entered into the input.\n * This will only need to be used if you are using `validate.length` and\n * the string contains abnormal characters.\n * For example, an emoji could take up many characters in the input, but should only count as 1 character.\n * If no number is provided, a built-in length calculation will be used for the length validation.\n */\n currentLength: {\n type: Number,\n default: null,\n },\n\n /**\n * Whether the input will continue to display a warning validation message even if the input has lost focus.\n */\n retainWarning: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Validation for the input. Supports maximum length validation with the structure:\n * `{ \"length\": {\"description\": string, \"max\": number, \"warn\": number, \"message\": string,\n * \"limitMaxLength\": boolean }}`\n */\n validate: {\n type: Object,\n default: null,\n },\n\n /**\n * hidden allows to use input without the element visually present in DOM\n */\n hidden: {\n type: Boolean,\n default: false,\n },\n },\n\n emits: [\n /**\n * Native input event\n *\n * @event input\n * @type {String}\n */\n 'input',\n\n /**\n * Native input blur event\n *\n * @event blur\n * @type {FocusEvent}\n */\n 'blur',\n\n /**\n * Input clear event\n *\n * @event clear\n */\n 'clear',\n\n /**\n * Native input focus event\n *\n * @event focus\n * @type {FocusEvent}\n */\n 'focus',\n\n /**\n * Native input focusin event\n *\n * @event focusin\n * @type {FocusEvent}\n */\n 'focusin',\n\n /**\n * Native input focusout event\n *\n * @event focusout\n * @type {FocusEvent}\n */\n 'focusout',\n\n /**\n * Event fired to sync the modelValue prop with the parent component\n * @event update:modelValue\n */\n 'update:modelValue',\n\n /**\n * Length of the input when currentLength prop is not passed\n *\n * @event update:length\n * @type {Number}\n */\n 'update:length',\n\n /**\n * Result of the input validation\n *\n * @event update:invalid\n * @type {Boolean}\n */\n 'update:invalid',\n ],\n\n data () {\n return {\n isInputFocused: false,\n isInvalid: false,\n defaultLength: 0,\n hasSlotContent,\n isComposing: false,\n justEndedComposition: false,\n // Moved from beforeMount so these are available during SSR (beforeMount\n // does not run server-side, causing labelSizeClasses to be undefined).\n labelSizeClasses: LABEL_SIZE_CLASSES,\n descriptionSizeClasses: DESCRIPTION_SIZE_CLASSES,\n };\n },\n\n computed: {\n\n isTextarea () {\n return this.type === INPUT_TYPES.TEXTAREA;\n },\n\n isDefaultSize () {\n return this.size === INPUT_SIZES.DEFAULT;\n },\n\n iconSize () {\n return INPUT_ICON_SIZES[this.size];\n },\n\n isValidSize () {\n return Object.values(INPUT_SIZES).includes(this.size);\n },\n\n isValidDescriptionSize () {\n return Object.values(DESCRIPTION_SIZE_TYPES).includes(this.size);\n },\n\n inputComponent () {\n if (this.isTextarea) {\n return 'textarea';\n }\n\n return 'input';\n },\n\n inputListeners () {\n return {\n compositionstart: () => {\n this.isComposing = true;\n },\n\n compositionend: () => {\n this.isComposing = false;\n this.justEndedComposition = true;\n const val = this.$refs.input.value;\n this.$emit('input', val);\n this.$emit('update:modelValue', val);\n // Clear the flag after the current synchronous event processing so\n // Firefox's post-compositionend input event is skipped, but the\n // next real user input (a separate browser task) is not.\n Promise.resolve().then(() => { this.justEndedComposition = false; });\n },\n\n input: async event => {\n if (this.isComposing) return;\n if (this.justEndedComposition) return;\n let val = event.target.value;\n if (this.type === INPUT_TYPES.FILE) {\n const files = Array.from(event.target.files);\n val = files.map(file => file.name);\n }\n this.$emit('input', val);\n this.$emit('update:modelValue', val);\n },\n\n blur: event => {\n this.isInputFocused = false;\n this.onBlur(event);\n },\n\n focus: event => {\n this.isInputFocused = true;\n this.$emit('focus', event);\n },\n\n focusin: event => this.$emit('focusin', event),\n focusout: event => this.$emit('focusout', event),\n };\n },\n\n descriptionKey () {\n return `input-description-${getUniqueString()}`;\n },\n\n inputState () {\n return getValidationState(this.validationMessages);\n },\n\n defaultLengthCalculation () {\n return this.calculateLength(this.modelValue);\n },\n\n validationProps () {\n return {\n length: {\n description: this?.validate?.length?.description,\n max: this?.validate?.length?.max,\n warn: this?.validate?.length?.warn,\n message: this?.validate?.length?.message,\n limitMaxLength: this?.validate?.length?.limitMaxLength ? this.validate.length.limitMaxLength : false,\n },\n };\n },\n\n validationMessages () {\n // Add length validation message if exists\n if (this.showLengthLimitValidation) {\n return this.formattedMessages.concat([this.inputLengthErrorMessage()]);\n }\n\n return this.formattedMessages;\n },\n\n showInputState () {\n return this.showMessages && this.inputState;\n },\n\n inputLength () {\n return this.currentLength ? this.currentLength : this.defaultLengthCalculation;\n },\n\n inputLengthState () {\n if (this.inputLength < this.validationProps.length.warn) {\n return null;\n } else if (this.inputLength <= this.validationProps.length.max) {\n return this.validationProps.length.warn ? VALIDATION_MESSAGE_TYPES.WARNING : null;\n } else {\n return VALIDATION_MESSAGE_TYPES.ERROR;\n }\n },\n\n shouldValidateLength () {\n return !!(\n this.validationProps.length.description &&\n this.validationProps.length.max\n );\n },\n\n shouldLimitMaxLength () {\n return this.shouldValidateLength && this.validationProps.length.limitMaxLength;\n },\n\n showLengthLimitValidation () {\n return (\n this.shouldValidateLength &&\n this.inputLengthState !== null &&\n this.validationProps.length.message &&\n (this.retainWarning || this.isInputFocused || this.isInvalid)\n );\n },\n\n sizeModifierClass () {\n if (this.isDefaultSize || !this.isValidSize) {\n return '';\n }\n\n return INPUT_SIZE_CLASSES[this.inputComponent][this.size];\n },\n\n stateClass () {\n return [INPUT_STATE_CLASSES[this.inputState]];\n },\n },\n\n watch: {\n isInvalid (val) {\n this.$emit('update:invalid', val);\n },\n\n modelValue: {\n immediate: true,\n handler (newValue) {\n if (this.shouldValidateLength) {\n this.validateLength(this.inputLength);\n }\n\n if (this.currentLength == null) {\n this.$emit('update:length', this.calculateLength(newValue));\n }\n\n // Set textarea value programmatically to avoid attribute binding\n // Skip during IME composition to avoid interrupting in-progress input\n if (this.isTextarea && !this.isComposing && this.$refs.input && this.$refs.input.value !== newValue) {\n this.$refs.input.value = newValue;\n }\n },\n },\n },\n\n beforeMount () {\n // labelSizeClasses and descriptionSizeClasses are now initialized in data()\n // so they are available during SSR (beforeMount does not run server-side).\n },\n\n mounted () {\n // Set initial textarea value programmatically\n if (this.isTextarea && this.$refs.input) {\n this.$refs.input.value = this.modelValue;\n }\n },\n\n methods: {\n removeClassStyleAttrs,\n addClassStyleAttrs,\n inputClasses () {\n return [\n 'd-input__input',\n this.inputComponent === 'input' ? 'd-input' : 'd-textarea',\n {\n [this.stateClass]: this.showInputState,\n 'd-input-icon--left': this.$slots.leftIcon,\n 'd-input-icon--right': this.$slots.rightIcon,\n },\n this.sizeModifierClass,\n this.inputClass,\n ];\n },\n\n inputWrapperClasses () {\n if (this.hidden) {\n return [];\n }\n return [\n 'd-input__wrapper',\n { [this.stateClass]: this.showInputState },\n this.inputWrapperClass,\n ];\n },\n\n calculateLength (value) {\n if (typeof value !== 'string') {\n return 0;\n }\n\n return [...value].length;\n },\n\n inputLengthErrorMessage () {\n return {\n message: this.validationProps.length.message,\n type: this.inputLengthState,\n };\n },\n\n onBlur (e) {\n // Do not emit a blur event if the target element is a child of this component\n if (!this.$refs.container?.contains(e.relatedTarget)) {\n this.$emit('blur', e);\n }\n },\n\n emitClearEvents () {\n this.$emit('input', '');\n this.$emit('clear');\n this.$emit('update:modelValue', '');\n },\n\n blur () {\n this.$refs.input.blur();\n },\n\n focus () {\n this.$refs.input.focus();\n },\n\n select () {\n this.$refs.input.select();\n },\n\n getMessageKey (type, index) {\n return `message-${type}-${index}`;\n },\n\n validateLength (length) {\n this.isInvalid = (length > this.validationProps.length.max);\n },\n\n clearInput () {\n this.$refs.input.value = '';\n this.$refs.input.focus();\n this.emitClearEvents();\n },\n },\n};\n</script>\n"],"mappings":"0bAkJA,IAAK,EAAU,CACb,aAAc,CAAE,KAAM,EAAG,CACzB,KAAM,UAEN,WAAY,CAAE,qBAAA,EAAA,QAAsB,CAEpC,OAAQ,CAAC,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A,GAAA,IAAE,EAAA,QAAA,EAAA,OAAA,GAAA,EAAM,qBAOf,EAAA,OAAA,YAAA,CAFC,SAAW,EAAA,SACX,MAAO,EAAA,iDAWd,GAAA,EAAA,EAAA,YAAA,CALC,sBAAqB,EAAA,mBACrB,gBAAe,EAAA,aACf,MAAO,EAAA,eACA,EAAA,mBAAkB,CAC1B,UAAQ,oBAAmB,CAAA,CAAA,KAAA,GAAA,CAAA,sBAAA,gBAAA,QAAA,CAAA,CAAA,CAAA,GAAA"}
|
package/dist/lib/input/input.js
CHANGED
|
@@ -106,7 +106,9 @@ var k = {
|
|
|
106
106
|
defaultLength: 0,
|
|
107
107
|
hasSlotContent: a,
|
|
108
108
|
isComposing: !1,
|
|
109
|
-
justEndedComposition: !1
|
|
109
|
+
justEndedComposition: !1,
|
|
110
|
+
labelSizeClasses: g,
|
|
111
|
+
descriptionSizeClasses: u
|
|
110
112
|
};
|
|
111
113
|
},
|
|
112
114
|
computed: {
|
|
@@ -212,9 +214,7 @@ var k = {
|
|
|
212
214
|
}
|
|
213
215
|
}
|
|
214
216
|
},
|
|
215
|
-
beforeMount() {
|
|
216
|
-
this.descriptionSizeClasses = u, this.labelSizeClasses = g;
|
|
217
|
-
},
|
|
217
|
+
beforeMount() {},
|
|
218
218
|
mounted() {
|
|
219
219
|
this.isTextarea && this.$refs.input && (this.$refs.input.value = this.modelValue);
|
|
220
220
|
},
|
|
@@ -313,7 +313,7 @@ function L(e, t, n, r, i, a) {
|
|
|
313
313
|
class: C([
|
|
314
314
|
"d-input__label-text",
|
|
315
315
|
"d-label",
|
|
316
|
-
|
|
316
|
+
i.labelSizeClasses[n.size]
|
|
317
317
|
])
|
|
318
318
|
}, D(n.label), 3)) : _("", !0)]),
|
|
319
319
|
i.hasSlotContent(e.$slots.description) || n.description || a.shouldValidateLength ? (w(), v("div", {
|
|
@@ -323,7 +323,7 @@ function L(e, t, n, r, i, a) {
|
|
|
323
323
|
class: C([
|
|
324
324
|
"d-input__description",
|
|
325
325
|
"d-description",
|
|
326
|
-
|
|
326
|
+
i.descriptionSizeClasses[n.size]
|
|
327
327
|
]),
|
|
328
328
|
"data-qa": "dt-input-description"
|
|
329
329
|
}, [i.hasSlotContent(e.$slots.description) || n.description ? (w(), v("div", M, [T(e.$slots, "description", {}, () => [b(D(n.description), 1)])])) : _("", !0), a.shouldValidateLength ? (w(), v("div", N, D(a.validationProps.length.description), 1)) : _("", !0)], 10, j)) : _("", !0),
|