@dialpad/dialtone-vue 3.190.0 → 3.190.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component-documentation.json +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 +4 -6
- package/dist/lib/dropdown/dropdown.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 +21 -13
- package/dist/lib/input/input.js.map +1 -1
- package/dist/lib/loader/loader.cjs +1 -1
- package/dist/lib/loader/loader.cjs.map +1 -1
- package/dist/lib/loader/loader.js +1 -1
- package/dist/lib/loader/loader.js.map +1 -1
- package/dist/localization/de-DE.cjs +16 -1
- package/dist/localization/de-DE.cjs.map +1 -1
- package/dist/localization/de-DE.js +16 -1
- package/dist/localization/de-DE.js.map +1 -1
- package/dist/localization/es-LA.cjs +13 -5
- package/dist/localization/es-LA.cjs.map +1 -1
- package/dist/localization/es-LA.js +13 -5
- package/dist/localization/es-LA.js.map +1 -1
- package/dist/localization/fr-FR.cjs +16 -1
- package/dist/localization/fr-FR.cjs.map +1 -1
- package/dist/localization/fr-FR.js +16 -1
- package/dist/localization/fr-FR.js.map +1 -1
- package/dist/localization/it-IT.cjs +16 -1
- package/dist/localization/it-IT.cjs.map +1 -1
- package/dist/localization/it-IT.js +16 -1
- package/dist/localization/it-IT.js.map +1 -1
- package/dist/localization/ja-JP.cjs +9 -1
- package/dist/localization/ja-JP.cjs.map +1 -1
- package/dist/localization/ja-JP.js +9 -1
- package/dist/localization/ja-JP.js.map +1 -1
- package/dist/localization/nl-NL.cjs +16 -1
- package/dist/localization/nl-NL.cjs.map +1 -1
- package/dist/localization/nl-NL.js +16 -1
- package/dist/localization/nl-NL.js.map +1 -1
- package/dist/localization/pt-BR.cjs +16 -1
- package/dist/localization/pt-BR.cjs.map +1 -1
- package/dist/localization/pt-BR.js +16 -1
- package/dist/localization/pt-BR.js.map +1 -1
- package/dist/localization/ru-RU.cjs +26 -1
- package/dist/localization/ru-RU.cjs.map +1 -1
- package/dist/localization/ru-RU.js +26 -1
- package/dist/localization/ru-RU.js.map +1 -1
- package/dist/localization/zh-CN.cjs +11 -1
- package/dist/localization/zh-CN.cjs.map +1 -1
- package/dist/localization/zh-CN.js +11 -1
- package/dist/localization/zh-CN.js.map +1 -1
- package/dist/types/components/dropdown/dropdown.vue.d.ts +1 -0
- package/dist/types/components/input/input.vue.d.ts +9 -0
- package/dist/types/components/input/input.vue.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("../../common/mixins/keyboard-list-navigation.cjs"),l=require("./dropdown-constants.cjs"),g=require("../../common/utils/index.cjs"),o=require("../../common/constants/index.cjs"),t=require("vue"),c=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),d=require("../list-item/list-item-constants.cjs"),E=require("../popover/popover.cjs"),f=require("../popover/popover-constants.cjs"),m={compatConfig:{MODE:3},name:"DtDropdown",components:{DtPopover:E.default},mixins:[p.default({indexKey:"highlightIndex",idKey:"highlightId",listElementKey:"getListElement",listItemRole:"menuitem",afterHighlightMethod:"afterHighlight",beginningOfListMethod:"beginningOfListMethod",endOfListMethod:"endOfListMethod",activeItemKey:"activeItemEl",focusOnKeyboardNavigation:!0})],inheritAttrs:!1,props:{open:{type:Boolean,default:null},openOnContext:{type:Boolean,default:!1},padding:{type:String,default:"small",validator:e=>Object.keys(l.DROPDOWN_PADDING_CLASSES).some(i=>i===e)},modal:{type:Boolean,default:!0},contentWidth:{type:String,default:null},maxHeight:{type:String,default:""},maxWidth:{type:String,default:""},listId:{type:String,default(){return g.getUniqueString()}},navigationType:{type:String,default:d.LIST_ITEM_NAVIGATION_TYPES.ARROW_KEYS,validator:e=>Object.values(d.LIST_ITEM_NAVIGATION_TYPES).includes(e)},fallbackPlacements:{type:Array,default:()=>["auto"]},placement:{type:String,default:"bottom"},onBeginningOfList:{type:Function,default:null},onEndOfList:{type:Function,default:null},listClass:{type:[String,Array,Object],default:""},appendTo:{type:[HTMLElement,String],default:"body",validator:e=>f.POPOVER_APPEND_TO_VALUES.includes(e)||e instanceof HTMLElement},tether:{type:Boolean,default:!0},transition:{type:String,default:"fade"}},emits:["keydown","highlight","update:open","opened"
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("../../common/mixins/keyboard-list-navigation.cjs"),l=require("./dropdown-constants.cjs"),g=require("../../common/utils/index.cjs"),o=require("../../common/constants/index.cjs"),t=require("vue"),c=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),d=require("../list-item/list-item-constants.cjs"),E=require("../popover/popover.cjs"),f=require("../popover/popover-constants.cjs"),m={compatConfig:{MODE:3},name:"DtDropdown",components:{DtPopover:E.default},mixins:[p.default({indexKey:"highlightIndex",idKey:"highlightId",listElementKey:"getListElement",listItemRole:"menuitem",afterHighlightMethod:"afterHighlight",beginningOfListMethod:"beginningOfListMethod",endOfListMethod:"endOfListMethod",activeItemKey:"activeItemEl",focusOnKeyboardNavigation:!0})],inheritAttrs:!1,props:{open:{type:Boolean,default:null},openOnContext:{type:Boolean,default:!1},padding:{type:String,default:"small",validator:e=>Object.keys(l.DROPDOWN_PADDING_CLASSES).some(i=>i===e)},modal:{type:Boolean,default:!0},contentWidth:{type:String,default:null},maxHeight:{type:String,default:""},maxWidth:{type:String,default:""},listId:{type:String,default(){return g.getUniqueString()}},navigationType:{type:String,default:d.LIST_ITEM_NAVIGATION_TYPES.ARROW_KEYS,validator:e=>Object.values(d.LIST_ITEM_NAVIGATION_TYPES).includes(e)},fallbackPlacements:{type:Array,default:()=>["auto"]},placement:{type:String,default:"bottom"},onBeginningOfList:{type:Function,default:null},onEndOfList:{type:Function,default:null},listClass:{type:[String,Array,Object],default:""},appendTo:{type:[HTMLElement,String],default:"body",validator:e=>f.POPOVER_APPEND_TO_VALUES.includes(e)||e instanceof HTMLElement},tether:{type:Boolean,default:!0},transition:{type:String,default:"fade"}},emits:["keydown","highlight","update:open","opened"],data(){return{LIST_ITEM_NAVIGATION_TYPES:d.LIST_ITEM_NAVIGATION_TYPES,DROPDOWN_PADDING_CLASSES:l.DROPDOWN_PADDING_CLASSES,EVENT_KEYNAMES:o.EVENT_KEYNAMES,openedWithKeyboard:!1,isOpen:null}},computed:{dropdownListeners(){return{"update:open":e=>{this.$emit("update:open",e)},opened:e=>{this.updateInitialHighlightIndex(e)},keydown:e=>{switch(e.code){case o.EVENT_KEYNAMES.up:case o.EVENT_KEYNAMES.arrowup:this.onUpKeyPress(e),e.stopPropagation(),e.preventDefault();break;case o.EVENT_KEYNAMES.down:case o.EVENT_KEYNAMES.arrowdown:this.onDownKeyPress(e),e.stopPropagation(),e.preventDefault();break;case o.EVENT_KEYNAMES.space:case o.EVENT_KEYNAMES.spacebar:this.onSpaceKey();break;case o.EVENT_KEYNAMES.enter:this.onEnterKey();break;case o.EVENT_KEYNAMES.home:this.onHomeKeyPress(e),e.stopPropagation(),e.preventDefault();break;case o.EVENT_KEYNAMES.end:this.onEndKeyPress(e),e.stopPropagation(),e.preventDefault();break;default:this.onKeyPress(e);break}this.$emit("keydown",e)}}},beginningOfListMethod(){return this.onBeginningOfList||this.jumpToEnd},endOfListMethod(){return this.onEndOfList||this.jumpToBeginning},activeItemEl(){return this.getListElement().querySelector("#"+this.highlightId)},isArrowKeyNav(){return this.navigationType===this.LIST_ITEM_NAVIGATION_TYPES.ARROW_KEYS},listClasses(){return["d-dropdown-list",l.DROPDOWN_PADDING_CLASSES[this.padding],this.listClass,{"d-context-menu-list":this.openOnContext}]},shouldOpenWithArrowKeys(){return!this.openOnContext}},methods:{onMouseHighlight(e){const i=e.target.closest("li");i&&i.role&&this.highlightId!==i.id&&(this.setHighlightId(i.id),i.focus())},getListElement(){return this.$refs.listWrapper},clearHighlightIndex(){this.setHighlightIndex(-1)},afterHighlight(){this.highlightIndex!==this._itemsLength()-1&&this.$emit("highlight",this.highlightIndex)},updateInitialHighlightIndex(e){this.isOpen=e,e?(this.openedWithKeyboard&&this.isArrowKeyNav&&this.setHighlightIndex(0),this.$emit("opened",!0)):(this.clearHighlightIndex(),this.openedWithKeyboard=!1,this.$emit("opened",!1))},onSpaceKey(){this.open||(this.openedWithKeyboard=!0)},onEnterKey(){this.open||(this.openedWithKeyboard=!0)},onUpKeyPress(){if(!this.isOpen){this.openedWithKeyboard=!0;return}if(this.isArrowKeyNav)return this.onUpKey()},onDownKeyPress(){if(!this.isOpen){this.openedWithKeyboard=!0;return}if(this.isArrowKeyNav)return this.onDownKey()},onHomeKeyPress(){if(!(!this.isOpen||!this.isArrowKeyNav))return this.onHomeKey()},onEndKeyPress(){if(!(!this.isOpen||!this.isArrowKeyNav))return this.onEndKey()},onKeyPress(e){if(!(!this.isOpen||!this.isArrowKeyNav||!this.isValidLetter(e.key)))return e.stopPropagation(),e.preventDefault(),this.onNavigationKey(e.key)}}},y=["id"];function _(e,i,n,K,h,s){const u=t.resolveComponent("dt-popover");return t.openBlock(),t.createBlock(u,t.mergeProps({ref:"popover","content-width":n.contentWidth,open:n.open,placement:n.placement,"initial-focus-element":h.openedWithKeyboard?"first":"dialog","fallback-placements":n.fallbackPlacements,padding:"none",role:"menu","append-to":n.appendTo,modal:n.modal,"max-height":n.maxHeight,"max-width":n.maxWidth,"open-with-arrow-keys":s.shouldOpenWithArrowKeys,"open-on-context":n.openOnContext},e.$attrs,{tether:n.tether,transition:n.transition},t.toHandlers(s.dropdownListeners)),{anchor:t.withCtx(({attrs:r})=>[t.renderSlot(e.$slots,"anchor",t.mergeProps({ref:"anchor"},r))]),content:t.withCtx(({close:r})=>[t.createElementVNode("ul",{id:n.listId,ref:"listWrapper",class:t.normalizeClass(s.listClasses),"data-qa":"dt-dropdown-list-wrapper",onMouseleave:i[0]||(i[0]=(...a)=>s.clearHighlightIndex&&s.clearHighlightIndex(...a)),onMousemoveCapture:i[1]||(i[1]=(...a)=>s.onMouseHighlight&&s.onMouseHighlight(...a))},[t.renderSlot(e.$slots,"list",{close:r})],42,y)]),footerContent:t.withCtx(({close:r})=>[t.renderSlot(e.$slots,"footer",{close:r})]),_:3},16,["content-width","open","placement","initial-focus-element","fallback-placements","append-to","modal","max-height","max-width","open-with-arrow-keys","open-on-context","tether","transition"])}const S=c._(m,[["render",_]]);exports.default=S;
|
|
2
2
|
//# sourceMappingURL=dropdown.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.cjs","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 * Event fired to sync the open prop with the parent component\n * @event update:open\n */\n 'update:open',\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 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"],"names":["_sfc_main","DtPopover","KeyboardNavigation","padding","DROPDOWN_PADDING_CLASSES","item","getUniqueString","LIST_ITEM_NAVIGATION_TYPES","t","appendTo","POPOVER_APPEND_TO_VALUES","EVENT_KEYNAMES","isPopoverOpen","event","liElement","_hoisted_1","_openBlock","_createBlock","_component_dt_popover","_mergeProps","$props","$data","$options","_ctx","_toHandlers","_withCtx","attrs","_renderSlot","close","_createElementVNode","_normalizeClass","args","_cache"],"mappings":"6fAkEKA,EAAU,CACb,aAAc,CAAE,KAAM,GACtB,KAAM,aAEN,WAAY,CACV,UAAAC,EAAAA,SAGF,OAAQ,CACNC,UAAmB,CACjB,SAAU,iBACV,MAAO,cACP,eAAgB,iBAChB,aAAc,WACd,qBAAsB,iBACtB,sBAAuB,wBACvB,gBAAiB,kBACjB,cAAe,eACf,0BAA2B,EAC7B,CAAC,GAGH,aAAc,GAEd,MAAO,CAML,KAAM,CACJ,KAAM,QACN,QAAS,MAOX,cAAe,CACb,KAAM,QACN,QAAS,IAOX,QAAS,CACP,KAAM,OACN,QAAS,QACT,UAAYC,GACH,OAAO,KAAKC,0BAAwB,EAAE,KAAMC,GAASA,IAASF,CAAO,GAQhF,MAAO,CACL,KAAM,QACN,QAAS,IAQX,aAAc,CACZ,KAAM,OACN,QAAS,MAOX,UAAW,CACT,KAAM,OACN,QAAS,IAOX,SAAU,CACR,KAAM,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AAAC,KAAK,CAExBC,aAIEJ,kBAJFJ,EAAAA,WAIE,CAHA,IAAI,QAAQ,EAEJO,CAAK,CAAA,IAGN,QAAOD,EAAAA,QAGhB,CAaK,CAhBe,MAAAG,KAAK,CAGzBC,EAAAA,mBAaK,KAAA,CAZF,GAAIT,EAAA,OACL,IAAI,cACH,MApCTU,EAAAA,eAoCgBR,EAAA,WAAW,EACnB,UAAQ,2BACP,iCAAYA,EAAA,qBAAAA,EAAA,oBAAA,GAAAS,CAAA,GAtCrB,mBAAAC,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAA,IAAAD,IAuC4BT,EAAA,kBAAAA,EAAA,iBAAA,GAAAS,CAAA,KAGpBJ,EAAAA,WAGEJ,EAAA,OAAA,OAAA,CADC,MAAOK,CAAK,CAAA,CA5CvB,EAAA,GAAAb,CAAA,IAgDe,cAAaU,EAAAA,QAEtB,CAGE,CALwB,MAAAG,KAAK,CAE/BD,EAAAA,WAGEJ,EAAA,OAAA,SAAA,CADC,MAAOK,CAAK,CAAA,IApDrB,EAAA"}
|
|
1
|
+
{"version":3,"file":"dropdown.cjs","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"],"names":["_sfc_main","DtPopover","KeyboardNavigation","padding","DROPDOWN_PADDING_CLASSES","item","getUniqueString","LIST_ITEM_NAVIGATION_TYPES","t","appendTo","POPOVER_APPEND_TO_VALUES","EVENT_KEYNAMES","value","isPopoverOpen","event","liElement","_hoisted_1","_openBlock","_createBlock","_component_dt_popover","_mergeProps","$props","$data","$options","_ctx","_toHandlers","_withCtx","attrs","_renderSlot","close","_createElementVNode","_normalizeClass","args","_cache"],"mappings":"6fAkEKA,EAAU,CACb,aAAc,CAAE,KAAM,GACtB,KAAM,aAEN,WAAY,CACV,UAAAC,EAAAA,SAGF,OAAQ,CACNC,UAAmB,CACjB,SAAU,iBACV,MAAO,cACP,eAAgB,iBAChB,aAAc,WACd,qBAAsB,iBACtB,sBAAuB,wBACvB,gBAAiB,kBACjB,cAAe,eACf,0BAA2B,EAC7B,CAAC,GAGH,aAAc,GAEd,MAAO,CAML,KAAM,CACJ,KAAM,QACN,QAAS,MAOX,cAAe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C,sBAAqBD,EAAA,mBACtB,QAAQ,OACR,KAAK,OACJ,YAAWA,EAAA,SACX,MAAOA,EAAA,MACP,aAAYA,EAAA,UACZ,YAAWA,EAAA,SACX,uBAAsBE,EAAA,wBACtB,kBAAiBF,EAAA,eACVG,EAAA,OAAM,CACb,OAAQH,EAAA,OACR,WAAYA,EAAA,UACb,EAAAI,aAAwBF,EAAlB,iBAAiB,CAAA,EAAA,CAEZ,OAAMG,EAAAA,QAEf,CAIE,CANiB,MAAAC,KAAK,CAExBC,aAIEJ,kBAJFJ,EAAAA,WAIE,CAHA,IAAI,QAAQ,EAEJO,CAAK,CAAA,IAGN,QAAOD,EAAAA,QAGhB,CAaK,CAhBe,MAAAG,KAAK,CAGzBC,EAAAA,mBAaK,KAAA,CAZF,GAAIT,EAAA,OACL,IAAI,cACH,MApCTU,EAAAA,eAoCgBR,EAAA,WAAW,EACnB,UAAQ,2BACP,iCAAYA,EAAA,qBAAAA,EAAA,oBAAA,GAAAS,CAAA,GAtCrB,mBAAAC,EAAA,CAAA,IAAAA,EAAA,CAAA,EAAA,IAAAD,IAuC4BT,EAAA,kBAAAA,EAAA,iBAAA,GAAAS,CAAA,KAGpBJ,EAAAA,WAGEJ,EAAA,OAAA,OAAA,CADC,MAAOK,CAAK,CAAA,CA5CvB,EAAA,GAAAb,CAAA,IAgDe,cAAaU,EAAAA,QAEtB,CAGE,CALwB,MAAAG,KAAK,CAE/BD,EAAAA,WAGEJ,EAAA,OAAA,SAAA,CADC,MAAOK,CAAK,CAAA,IApDrB,EAAA"}
|
|
@@ -212,12 +212,7 @@ const P = {
|
|
|
212
212
|
* @event opened
|
|
213
213
|
* @type {Boolean | Array}
|
|
214
214
|
*/
|
|
215
|
-
"opened"
|
|
216
|
-
/**
|
|
217
|
-
* Event fired to sync the open prop with the parent component
|
|
218
|
-
* @event update:open
|
|
219
|
-
*/
|
|
220
|
-
"update:open"
|
|
215
|
+
"opened"
|
|
221
216
|
],
|
|
222
217
|
data() {
|
|
223
218
|
return {
|
|
@@ -231,6 +226,9 @@ const P = {
|
|
|
231
226
|
computed: {
|
|
232
227
|
dropdownListeners() {
|
|
233
228
|
return {
|
|
229
|
+
"update:open": (e) => {
|
|
230
|
+
this.$emit("update:open", e);
|
|
231
|
+
},
|
|
234
232
|
opened: (e) => {
|
|
235
233
|
this.updateInitialHighlightIndex(e);
|
|
236
234
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.js","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 * Event fired to sync the open prop with the parent component\n * @event update:open\n */\n 'update:open',\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 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"],"names":["_sfc_main","DtPopover","KeyboardNavigation","padding","DROPDOWN_PADDING_CLASSES","item","getUniqueString","LIST_ITEM_NAVIGATION_TYPES","t","appendTo","POPOVER_APPEND_TO_VALUES","EVENT_KEYNAMES","isPopoverOpen","event","liElement","_hoisted_1","_openBlock","_createBlock","_component_dt_popover","_mergeProps","$props","$data","$options","_ctx","_toHandlers","_withCtx","attrs","_renderSlot","close","_createElementVNode","_normalizeClass","args","_cache"],"mappings":";;;;;;;;;AAkEA,MAAKA,IAAU;AAAA,EACb,cAAc,EAAE,MAAM;EACtB,MAAM;AAAA,EAEN,YAAY;AAAA,IACV,WAAAC;AAAA;EAGF,QAAQ;AAAA,IACNC,EAAmB;AAAA,MACjB,UAAU;AAAA,MACV,OAAO;AAAA,MACP,gBAAgB;AAAA,MAChB,cAAc;AAAA,MACd,sBAAsB;AAAA,MACtB,uBAAuB;AAAA,MACvB,iBAAiB;AAAA,MACjB,eAAe;AAAA,MACf,2BAA2B;AAAA,IAC7B,CAAC;AAAA;EAGH,cAAc;AAAA,EAEd,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAML,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA;;;;;IAOX,eAAe;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA;;;;;IAOX,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA,MACT,WAAW,CAACC,MACH,OAAO,KAAKC,CAAwB,EAAE,KAAK,CAACC,MAASA,MAASF,CAAO;AAAA;;;;;IAQhF,OAAO;AAAA,MACL,MAAM;AAAA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,QAAK;AAAA,MAGzBC,EAaK,MAAA;AAAA,QAZF,IAAIT,EAAA;AAAA,QACL,KAAI;AAAA,QACH,OApCTU,EAoCgBR,EAAA,WAAW;AAAA,QACnB,WAAQ;AAAA,QACP,wCAAYA,EAAA,uBAAAA,EAAA,oBAAA,GAAAS,CAAA;AAAA,QAtCrB,oBAAAC,EAAA,CAAA,MAAAA,EAAA,CAAA,IAAA,IAAAD,MAuC4BT,EAAA,oBAAAA,EAAA,iBAAA,GAAAS,CAAA;AAAA;QAGpBJ,EAGEJ,EAAA,QAAA,QAAA,EADC,OAAOK,EAAK,CAAA;AAAA,MA5CvB,GAAA,IAAAb,CAAA;AAAA;IAgDe,eAAaU,EAEtB,CAGE,EALwB,OAAAG,QAAK;AAAA,MAE/BD,EAGEJ,EAAA,QAAA,UAAA,EADC,OAAOK,EAAK,CAAA;AAAA;IApDrB,GAAA;AAAA;;;"}
|
|
1
|
+
{"version":3,"file":"dropdown.js","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"],"names":["_sfc_main","DtPopover","KeyboardNavigation","padding","DROPDOWN_PADDING_CLASSES","item","getUniqueString","LIST_ITEM_NAVIGATION_TYPES","t","appendTo","POPOVER_APPEND_TO_VALUES","EVENT_KEYNAMES","value","isPopoverOpen","event","liElement","_hoisted_1","_openBlock","_createBlock","_component_dt_popover","_mergeProps","$props","$data","$options","_ctx","_toHandlers","_withCtx","attrs","_renderSlot","close","_createElementVNode","_normalizeClass","args","_cache"],"mappings":";;;;;;;;;AAkEA,MAAKA,IAAU;AAAA,EACb,cAAc,EAAE,MAAM;EACtB,MAAM;AAAA,EAEN,YAAY;AAAA,IACV,WAAAC;AAAA;EAGF,QAAQ;AAAA,IACNC,EAAmB;AAAA,MACjB,UAAU;AAAA,MACV,OAAO;AAAA,MACP,gBAAgB;AAAA,MAChB,cAAc;AAAA,MACd,sBAAsB;AAAA,MACtB,uBAAuB;AAAA,MACvB,iBAAiB;AAAA,MACjB,eAAe;AAAA,MACf,2BAA2B;AAAA,IAC7B,CAAC;AAAA;EAGH,cAAc;AAAA,EAEd,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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A;AAAA,IACtB,mBAAiBF,EAAA;AAAA,KACVG,EAAA,QAAM;AAAA,IACb,QAAQH,EAAA;AAAA,IACR,YAAYA,EAAA;AAAA,EACb,GAAAI,EAAwBF,EAAlB,iBAAiB,CAAA,GAAA;AAAA,IAEZ,QAAMG,EAEf,CAIE,EANiB,OAAAC,QAAK;AAAA,MAExBC,EAIEJ,oBAJFJ,EAIE,EAHA,KAAI,SAAQ,GAEJO,CAAK,CAAA;AAAA;IAGN,SAAOD,EAGhB,CAaK,EAhBe,OAAAG,QAAK;AAAA,MAGzBC,EAaK,MAAA;AAAA,QAZF,IAAIT,EAAA;AAAA,QACL,KAAI;AAAA,QACH,OApCTU,EAoCgBR,EAAA,WAAW;AAAA,QACnB,WAAQ;AAAA,QACP,wCAAYA,EAAA,uBAAAA,EAAA,oBAAA,GAAAS,CAAA;AAAA,QAtCrB,oBAAAC,EAAA,CAAA,MAAAA,EAAA,CAAA,IAAA,IAAAD,MAuC4BT,EAAA,oBAAAA,EAAA,iBAAA,GAAAS,CAAA;AAAA;QAGpBJ,EAGEJ,EAAA,QAAA,QAAA,EADC,OAAOK,EAAK,CAAA;AAAA,MA5CvB,GAAA,IAAAb,CAAA;AAAA;IAgDe,eAAaU,EAEtB,CAGE,EALwB,OAAAG,QAAK;AAAA,MAE/BD,EAGEJ,EAAA,QAAA,UAAA,EADC,OAAOK,EAAK,CAAA;AAAA;IApDrB,GAAA;AAAA;;;"}
|
package/dist/lib/input/input.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("../../common/constants/index.cjs"),n=require("./input-constants.cjs"),d=require("../../common/utils/index.cjs"),m=require("../../common/mixins/input.cjs"),t=require("vue"),g=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),S=require("../validation-messages/validation-messages.cjs"),f={compatConfig:{MODE:3},name:"DtInput",components:{DtValidationMessages:S.default},mixins:[m.MessagesMixin],inheritAttrs:!1,props:{name:{type:String,default:""},type:{type:String,default:n.INPUT_TYPES.TEXT,validator:e=>Object.values(n.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(n.INPUT_SIZES).includes(e)},inputClass:{type:[String,Object,Array],default:""},inputWrapperClass:{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:d.hasSlotContent}},computed:{isTextarea(){return this.type===n.INPUT_TYPES.TEXTAREA},isDefaultSize(){return this.size===n.INPUT_SIZES.DEFAULT},iconSize(){return n.INPUT_ICON_SIZES[this.size]},isValidSize(){return Object.values(n.INPUT_SIZES).includes(this.size)},isValidDescriptionSize(){return Object.values(h.DESCRIPTION_SIZE_TYPES).includes(this.size)},inputComponent(){return this.isTextarea?"textarea":"input"},inputListeners(){return{input:async e=>{let a=e.target.value;this.type===n.INPUT_TYPES.FILE&&(a=Array.from(e.target.files).map(r=>r.name)),this.$emit("input",a),this.$emit("update:modelValue",a)},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-${d.getUniqueString()}`},inputState(){return d.getValidationState(this.validationMessages)},defaultLengthCalculation(){return this.calculateLength(this.modelValue)},validationProps(){var e,a,s,r,u,i,o,l,c,p;return{length:{description:(a=(e=this==null?void 0:this.validate)==null?void 0:e.length)==null?void 0:a.description,max:(r=(s=this==null?void 0:this.validate)==null?void 0:s.length)==null?void 0:r.max,warn:(i=(u=this==null?void 0:this.validate)==null?void 0:u.length)==null?void 0:i.warn,message:(l=(o=this==null?void 0:this.validate)==null?void 0:o.length)==null?void 0:l.message,limitMaxLength:(p=(c=this==null?void 0:this.validate)==null?void 0:c.length)!=null&&p.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?h.VALIDATION_MESSAGE_TYPES.WARNING:null:h.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?"":n.INPUT_SIZE_CLASSES[this.inputComponent][this.size]},stateClass(){return[n.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==null&&this.$emit("update:length",this.calculateLength(e))}}},beforeMount(){this.descriptionSizeClasses=n.DESCRIPTION_SIZE_CLASSES,this.labelSizeClasses=n.LABEL_SIZE_CLASSES},methods:{removeClassStyleAttrs:d.removeClassStyleAttrs,addClassStyleAttrs:d.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"?0:[...e].length},inputLengthErrorMessage(){return{message:this.validationProps.length.message,type:this.inputLengthState}},onBlur(e){var a;(a=this.$refs.container)!=null&&a.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,a){return`message-${e}-${a}`},validateLength(e){this.isInvalid=e>this.validationProps.length.max},clearInput(){this.$refs.input.value="",this.$refs.input.focus(),this.emitClearEvents()}}},v=["aria-details"],C=["id"],_={key:0},L={key:1,"data-qa":"dt-input-length-description",class:"d-input__length-description"},y=["read-only"],E=["value","name","disabled","autocomplete","maxlength"],I=["value","name","type","disabled","autocomplete","maxlength"];function b(e,a,s,r,u,i){const o=t.resolveComponent("dt-validation-messages");return t.openBlock(),t.createElementBlock("div",t.mergeProps({ref:"container",class:["d-input__root",{"d-input--hidden":s.hidden}]},i.addClassStyleAttrs(e.$attrs),{"data-qa":"dt-input"}),[t.createElementVNode("label",{class:"d-input__label","aria-details":e.$slots.description||s.description?i.descriptionKey:void 0,"data-qa":"dt-input-label-wrapper"},[t.renderSlot(e.$slots,"labelSlot",{},()=>[s.labelVisible&&s.label?(t.openBlock(),t.createElementBlock("div",{key:0,ref:"label","data-qa":"dt-input-label",class:t.normalizeClass(["d-input__label-text","d-label",e.labelSizeClasses[s.size]])},t.toDisplayString(s.label),3)):t.createCommentVNode("",!0)]),u.hasSlotContent(e.$slots.description)||s.description||i.shouldValidateLength?(t.openBlock(),t.createElementBlock("div",{key:0,id:i.descriptionKey,ref:"description",class:t.normalizeClass(["d-input__description","d-description",e.descriptionSizeClasses[s.size]]),"data-qa":"dt-input-description"},[u.hasSlotContent(e.$slots.description)||s.description?(t.openBlock(),t.createElementBlock("div",_,[t.renderSlot(e.$slots,"description",{},()=>[t.createTextVNode(t.toDisplayString(s.description),1)])])):t.createCommentVNode("",!0),i.shouldValidateLength?(t.openBlock(),t.createElementBlock("div",L,t.toDisplayString(i.validationProps.length.description),1)):t.createCommentVNode("",!0)],10,C)):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(i.inputWrapperClasses()),"read-only":s.disabled===!0?!0:void 0},[t.createElementVNode("span",{class:"d-input-icon d-input-icon--left","data-qa":"dt-input-left-icon-wrapper",onFocusout:a[0]||(a[0]=(...l)=>i.onBlur&&i.onBlur(...l))},[t.renderSlot(e.$slots,"leftIcon",{iconSize:i.iconSize})],32),i.isTextarea?(t.openBlock(),t.createElementBlock("textarea",t.mergeProps({key:0,ref:"input",value:s.modelValue,name:s.name,disabled:s.disabled,autocomplete:e.$attrs.autocomplete??"off",class:i.inputClasses(),maxlength:i.shouldLimitMaxLength?i.validationProps.length.max:null,"data-qa":"dt-input-input"},i.removeClassStyleAttrs(e.$attrs),t.toHandlers(i.inputListeners,!0)),null,16,E)):(t.openBlock(),t.createElementBlock("input",t.mergeProps({key:1,ref:"input",value:s.modelValue,name:s.name,type:s.type,disabled:s.disabled,autocomplete:e.$attrs.autocomplete??"off",class:i.inputClasses(),maxlength:i.shouldLimitMaxLength?i.validationProps.length.max:null,"data-qa":"dt-input-input"},i.removeClassStyleAttrs(e.$attrs),t.toHandlers(i.inputListeners,!0)),null,16,I)),t.createElementVNode("span",{class:"d-input-icon d-input-icon--right","data-qa":"dt-input-right-icon-wrapper",onFocusout:a[1]||(a[1]=(...l)=>i.onBlur&&i.onBlur(...l))},[t.renderSlot(e.$slots,"rightIcon",{iconSize:i.iconSize,clear:i.clearInput})],32)],10,y)],8,v),t.createVNode(o,t.mergeProps({"validation-messages":i.validationMessages,"show-messages":e.showMessages,class:e.messagesClass},e.messagesChildProps,{"data-qa":"dt-input-messages"}),null,16,["validation-messages","show-messages","class"])],16)}const P=g._(f,[["render",b]]);exports.default=P;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("../../common/constants/index.cjs"),n=require("./input-constants.cjs"),d=require("../../common/utils/index.cjs"),m=require("../../common/mixins/input.cjs"),t=require("vue"),g=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),S=require("../validation-messages/validation-messages.cjs"),f={compatConfig:{MODE:3},name:"DtInput",components:{DtValidationMessages:S.default},mixins:[m.MessagesMixin],inheritAttrs:!1,props:{name:{type:String,default:""},type:{type:String,default:n.INPUT_TYPES.TEXT,validator:e=>Object.values(n.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(n.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:d.hasSlotContent}},computed:{isTextarea(){return this.type===n.INPUT_TYPES.TEXTAREA},isDefaultSize(){return this.size===n.INPUT_SIZES.DEFAULT},iconSize(){return n.INPUT_ICON_SIZES[this.size]},isValidSize(){return Object.values(n.INPUT_SIZES).includes(this.size)},isValidDescriptionSize(){return Object.values(h.DESCRIPTION_SIZE_TYPES).includes(this.size)},inputComponent(){return this.isTextarea?"textarea":"input"},inputListeners(){return{input:async e=>{let a=e.target.value;this.type===n.INPUT_TYPES.FILE&&(a=Array.from(e.target.files).map(r=>r.name)),this.$emit("input",a),this.$emit("update:modelValue",a)},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-${d.getUniqueString()}`},inputState(){return d.getValidationState(this.validationMessages)},defaultLengthCalculation(){return this.calculateLength(this.modelValue)},validationProps(){var e,a,s,r,u,i,o,l,c,p;return{length:{description:(a=(e=this==null?void 0:this.validate)==null?void 0:e.length)==null?void 0:a.description,max:(r=(s=this==null?void 0:this.validate)==null?void 0:s.length)==null?void 0:r.max,warn:(i=(u=this==null?void 0:this.validate)==null?void 0:u.length)==null?void 0:i.warn,message:(l=(o=this==null?void 0:this.validate)==null?void 0:o.length)==null?void 0:l.message,limitMaxLength:(p=(c=this==null?void 0:this.validate)==null?void 0:c.length)!=null&&p.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?h.VALIDATION_MESSAGE_TYPES.WARNING:null:h.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?"":n.INPUT_SIZE_CLASSES[this.inputComponent][this.size]},stateClass(){return[n.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==null&&this.$emit("update:length",this.calculateLength(e))}}},beforeMount(){this.descriptionSizeClasses=n.DESCRIPTION_SIZE_CLASSES,this.labelSizeClasses=n.LABEL_SIZE_CLASSES},methods:{removeClassStyleAttrs:d.removeClassStyleAttrs,addClassStyleAttrs:d.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"?0:[...e].length},inputLengthErrorMessage(){return{message:this.validationProps.length.message,type:this.inputLengthState}},onBlur(e){var a;(a=this.$refs.container)!=null&&a.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,a){return`message-${e}-${a}`},validateLength(e){this.isInvalid=e>this.validationProps.length.max},clearInput(){this.$refs.input.value="",this.$refs.input.focus(),this.emitClearEvents()}}},v=["aria-details"],C=["id"],_={key:0},L={key:1,"data-qa":"dt-input-length-description",class:"d-input__length-description"},y=["read-only"],E=["value","name","disabled","autocomplete","maxlength"],I=["value","name","type","disabled","autocomplete","maxlength"];function b(e,a,s,r,u,i){const o=t.resolveComponent("dt-validation-messages");return t.openBlock(),t.createElementBlock("div",t.mergeProps({ref:"container",class:[s.rootClass,"d-input__root",{"d-input--hidden":s.hidden}]},i.addClassStyleAttrs(e.$attrs),{"data-qa":"dt-input"}),[t.createElementVNode("label",{class:"d-input__label","aria-details":e.$slots.description||s.description?i.descriptionKey:void 0,"data-qa":"dt-input-label-wrapper"},[t.renderSlot(e.$slots,"labelSlot",{},()=>[s.labelVisible&&s.label?(t.openBlock(),t.createElementBlock("div",{key:0,ref:"label","data-qa":"dt-input-label",class:t.normalizeClass(["d-input__label-text","d-label",e.labelSizeClasses[s.size]])},t.toDisplayString(s.label),3)):t.createCommentVNode("",!0)]),u.hasSlotContent(e.$slots.description)||s.description||i.shouldValidateLength?(t.openBlock(),t.createElementBlock("div",{key:0,id:i.descriptionKey,ref:"description",class:t.normalizeClass(["d-input__description","d-description",e.descriptionSizeClasses[s.size]]),"data-qa":"dt-input-description"},[u.hasSlotContent(e.$slots.description)||s.description?(t.openBlock(),t.createElementBlock("div",_,[t.renderSlot(e.$slots,"description",{},()=>[t.createTextVNode(t.toDisplayString(s.description),1)])])):t.createCommentVNode("",!0),i.shouldValidateLength?(t.openBlock(),t.createElementBlock("div",L,t.toDisplayString(i.validationProps.length.description),1)):t.createCommentVNode("",!0)],10,C)):t.createCommentVNode("",!0),t.createElementVNode("div",{class:t.normalizeClass(i.inputWrapperClasses()),"read-only":s.disabled===!0?!0:void 0},[t.createElementVNode("span",{class:"d-input-icon d-input-icon--left","data-qa":"dt-input-left-icon-wrapper",onFocusout:a[0]||(a[0]=(...l)=>i.onBlur&&i.onBlur(...l))},[t.renderSlot(e.$slots,"leftIcon",{iconSize:i.iconSize})],32),i.isTextarea?(t.openBlock(),t.createElementBlock("textarea",t.mergeProps({key:0,ref:"input",value:s.modelValue,name:s.name,disabled:s.disabled,autocomplete:e.$attrs.autocomplete??"off",class:i.inputClasses(),maxlength:i.shouldLimitMaxLength?i.validationProps.length.max:null,"data-qa":"dt-input-input"},i.removeClassStyleAttrs(e.$attrs),t.toHandlers(i.inputListeners,!0)),null,16,E)):(t.openBlock(),t.createElementBlock("input",t.mergeProps({key:1,ref:"input",value:s.modelValue,name:s.name,type:s.type,disabled:s.disabled,autocomplete:e.$attrs.autocomplete??"off",class:i.inputClasses(),maxlength:i.shouldLimitMaxLength?i.validationProps.length.max:null,"data-qa":"dt-input-input"},i.removeClassStyleAttrs(e.$attrs),t.toHandlers(i.inputListeners,!0)),null,16,I)),t.createElementVNode("span",{class:"d-input-icon d-input-icon--right","data-qa":"dt-input-right-icon-wrapper",onFocusout:a[1]||(a[1]=(...l)=>i.onBlur&&i.onBlur(...l))},[t.renderSlot(e.$slots,"rightIcon",{iconSize:i.iconSize,clear:i.clearInput})],32)],10,y)],8,v),t.createVNode(o,t.mergeProps({"validation-messages":i.validationMessages,"show-messages":e.showMessages,class:e.messagesClass},e.messagesChildProps,{"data-qa":"dt-input-messages"}),null,16,["validation-messages","show-messages","class"])],16)}const P=g._(f,[["render",b]]);exports.default=P;
|
|
2
2
|
//# sourceMappingURL=input.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.cjs","sources":["../../../components/input/input.vue"],"sourcesContent":["<template>\n <div\n ref=\"container\"\n :class=\"['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 :value=\"modelValue\"\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\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 * 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 };\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 input: async event => {\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 // eslint-disable-next-line complexity\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 },\n },\n\n beforeMount () {\n this.descriptionSizeClasses = DESCRIPTION_SIZE_CLASSES;\n this.labelSizeClasses = LABEL_SIZE_CLASSES;\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"],"names":["_sfc_main","DtValidationMessages","MessagesMixin","INPUT_TYPES","t","INPUT_SIZES","hasSlotContent","INPUT_ICON_SIZES","DESCRIPTION_SIZE_TYPES","event","val","file","getUniqueString","getValidationState","_b","_a","_d","_c","_f","_e","_h","_g","_j","_i","VALIDATION_MESSAGE_TYPES","INPUT_SIZE_CLASSES","INPUT_STATE_CLASSES","newValue","DESCRIPTION_SIZE_CLASSES","LABEL_SIZE_CLASSES","removeClassStyleAttrs","addClassStyleAttrs","value","type","index","length","_hoisted_1","_hoisted_2","_hoisted_5","_hoisted_6","_hoisted_7","_openBlock","_createElementBlock","_mergeProps","$props","$options","_ctx","_createElementVNode","_renderSlot","_normalizeClass","_createCommentVNode","$data","_hoisted_3","_createTextVNode","_toDisplayString","_hoisted_4","args","_toHandlers","_createVNode","_component_dt_validation_messages"],"mappings":"+ZAmJKA,EAAU,CACb,aAAc,CAAE,KAAM,GACtB,KAAM,UAEN,WAAY,CAAA,qBAAEC,EAAAA,SAEd,OAAQ,CAACC,EAAAA,aAAa,EAEtB,aAAc,GAEd,MAAO,CAIL,KAAM,CACJ,KAAM,OACN,QAAS,IASX,KAAM,CACJ,KAAM,OACN,QAASC,EAAAA,YAAY,KACrB,UAAYC,GAAM,OAAO,OAAOD,aAAW,EAAE,SAASC,CAAC,GAMzD,WAAY,CACV,KAAM,CAAC,OAAQ,MAAM,EACrB,QAAS,IAOX,SAAU,CACR,KAAM,QACN,QAAS,IAMX,MAAO,CACL,KAAM,OACN,QAAS,IAOX,aAAc,CACZ,KAAM,QACN,QAAS,IAMX,YAAa,CACX,KAAM,OACN,QAAS,IAOX,KAAM,CACJ,KAAM,OACN,QAAS,KACT,UAAYA,GAAM,OAAO,OAAOC,aAAW,EAAE,SAASD,CAAC,GAQzD,WAAY,CACV,KAAM,CAAC,OAAQ,OAAQ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A,WACP,KAAMA,EAAA,KACN,SAAUA,EAAA,SACV,aAAcE,EAAA,OAAO,cAAY,MACjC,MAAOD,EAAA,aAAY,EACnB,UAAWA,EAAA,qBAAuBA,kBAAgB,OAAO,IAAG,KAC7D,UAAQ,gBACA,EAAAA,EAAA,sBAAsBC,EAAA,MAAM,EACpCW,EAAAA,WAAMZ,iBAAc,EAAA,CAAA,EAAA,KAAA,GA9E9BN,CAAA,IAgFQE,EAAAA,YAAAC,EAAAA,mBAaC,QAbDC,aAaC,CA7FT,IAAA,EAkFU,IAAI,QACH,MAAOC,EAAA,WACP,KAAMA,EAAA,KACN,KAAMA,EAAA,KACN,SAAUA,EAAA,SACV,aAAcE,EAAA,OAAO,cAAY,MACjC,MAAOD,EAAA,aAAY,EACnB,UAAWA,EAAA,qBAAuBA,kBAAgB,OAAO,IAAG,KAC7D,UAAQ,gBACA,EAAAA,EAAA,sBAAsBC,EAAA,MAAM,EACpCW,EAAAA,WAAMZ,iBAAc,EAAA,CAAA,EAAA,KAAA,GA5F9BL,CAAA,GA8FQO,EAAAA,mBAWO,OAAA,CAVL,MAAM,mCACN,UAAQ,8BACP,+BAAUF,EAAA,QAAAA,EAAA,OAAA,GAAAW,CAAA,KAGXR,aAIEF,EAAA,OAAA,YAAA,CAFC,SAAWD,EAAA,SACX,MAAOA,EAAA,iBAvGpB,EAAA,GAAAP,CAAA,CAAA,EAAA,EAAAF,CAAA,EA4GIsB,EAAAA,YAMEC,EANFhB,aAME,CALC,sBAAqBE,EAAA,mBACrB,gBAAeC,EAAA,aACf,MAAOA,EAAA,eACAA,EAAA,mBAAkB,CAC1B,UAAQ,mBAAmB,CAAA,EAAA,KAAA,GAAA,CAAA,sBAAA,gBAAA,OAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"input.cjs","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 :value=\"modelValue\"\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\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 };\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 input: async event => {\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 },\n },\n\n beforeMount () {\n this.descriptionSizeClasses = DESCRIPTION_SIZE_CLASSES;\n this.labelSizeClasses = LABEL_SIZE_CLASSES;\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"],"names":["_sfc_main","DtValidationMessages","MessagesMixin","INPUT_TYPES","t","INPUT_SIZES","hasSlotContent","INPUT_ICON_SIZES","DESCRIPTION_SIZE_TYPES","event","val","file","getUniqueString","getValidationState","_b","_a","_d","_c","_f","_e","_h","_g","_j","_i","VALIDATION_MESSAGE_TYPES","INPUT_SIZE_CLASSES","INPUT_STATE_CLASSES","newValue","DESCRIPTION_SIZE_CLASSES","LABEL_SIZE_CLASSES","removeClassStyleAttrs","addClassStyleAttrs","value","type","index","length","_hoisted_1","_hoisted_2","_hoisted_5","_hoisted_6","_hoisted_7","_openBlock","_createElementBlock","_mergeProps","$props","$options","_ctx","_createElementVNode","_renderSlot","_normalizeClass","_createCommentVNode","$data","_hoisted_3","_createTextVNode","_toDisplayString","_hoisted_4","args","_toHandlers","_createVNode","_component_dt_validation_messages"],"mappings":"+ZAmJKA,EAAU,CACb,aAAc,CAAE,KAAM,GACtB,KAAM,UAEN,WAAY,CAAA,qBAAEC,EAAAA,SAEd,OAAQ,CAACC,EAAAA,aAAa,EAEtB,aAAc,GAEd,MAAO,CAIL,KAAM,CACJ,KAAM,OACN,QAAS,IASX,KAAM,CACJ,KAAM,OACN,QAASC,EAAAA,YAAY,KACrB,UAAYC,GAAM,OAAO,OAAOD,aAAW,EAAE,SAASC,CAAC,GAMzD,WAAY,CACV,KAAM,CAAC,OAAQ,MAAM,EACrB,QAAS,IAOX,SAAU,CACR,KAAM,QACN,QAAS,IAMX,MAAO,CACL,KAAM,OACN,QAAS,IAOX,aAAc,CACZ,KAAM,QACN,QAAS,IAMX,YAAa,CACX,KAAM,OACN,QAAS,IAOX,KAAM,CACJ,KAAM,OACN,QAAS,KACT,UAAYA,GAAM,OAAO,OAAOC,aAAW,EAAE,SAASD,CAAC,GAQzD,WAAY,CACV,KAAM,CAAC,OAAQ,OAAQ,KAAK,EAC5B,QAAS,IAQX,kBAAmB,CACjB,KAAM,CAAC,OAAQ,OAAQ,KAAK,EAC5B,QAAS,IAQX,UAAW,CACT,KAAM,CAAC,OAAQ,OAAQ,KAAK,EAC5B,QAAS,IAUX,cAAe,CACb,KAAM,OACN,QAAS,MAMX,cAAe,CACb,KAAM,QACN,QAAS,IAQX,SAAU,CACR,KAAM,OACN,QAAS,MAMX,OAAQ,CACN,KAAM,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,sBAAsBC,EAAA,MAAM,EACpCW,EAAAA,WAAMZ,iBAAc,EAAA,CAAA,EAAA,KAAA,GA9E9BN,CAAA,IAgFQE,EAAAA,YAAAC,EAAAA,mBAaC,QAbDC,aAaC,CA7FT,IAAA,EAkFU,IAAI,QACH,MAAOC,EAAA,WACP,KAAMA,EAAA,KACN,KAAMA,EAAA,KACN,SAAUA,EAAA,SACV,aAAcE,EAAA,OAAO,cAAY,MACjC,MAAOD,EAAA,aAAY,EACnB,UAAWA,EAAA,qBAAuBA,kBAAgB,OAAO,IAAG,KAC7D,UAAQ,gBACA,EAAAA,EAAA,sBAAsBC,EAAA,MAAM,EACpCW,EAAAA,WAAMZ,iBAAc,EAAA,CAAA,EAAA,KAAA,GA5F9BL,CAAA,GA8FQO,EAAAA,mBAWO,OAAA,CAVL,MAAM,mCACN,UAAQ,8BACP,+BAAUF,EAAA,QAAAA,EAAA,OAAA,GAAAW,CAAA,KAGXR,aAIEF,EAAA,OAAA,YAAA,CAFC,SAAWD,EAAA,SACX,MAAOA,EAAA,iBAvGpB,EAAA,GAAAP,CAAA,CAAA,EAAA,EAAAF,CAAA,EA4GIsB,EAAAA,YAMEC,EANFhB,aAME,CALC,sBAAqBE,EAAA,mBACrB,gBAAeC,EAAA,aACf,MAAOA,EAAA,eACAA,EAAA,mBAAkB,CAC1B,UAAQ,mBAAmB,CAAA,EAAA,KAAA,GAAA,CAAA,sBAAA,gBAAA,OAAA,CAAA"}
|
package/dist/lib/input/input.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { VALIDATION_MESSAGE_TYPES as C, DESCRIPTION_SIZE_TYPES as b } from "../../common/constants/index.js";
|
|
2
2
|
import { INPUT_TYPES as o, DESCRIPTION_SIZE_CLASSES as I, LABEL_SIZE_CLASSES as _, INPUT_STATE_CLASSES as E, INPUT_SIZE_CLASSES as V, INPUT_SIZES as m, INPUT_ICON_SIZES as z } from "./input-constants.js";
|
|
3
|
-
import { addClassStyleAttrs as M, removeClassStyleAttrs as P, getValidationState as
|
|
3
|
+
import { addClassStyleAttrs as M, removeClassStyleAttrs as P, getValidationState as A, getUniqueString as T, hasSlotContent as w } from "../../common/utils/index.js";
|
|
4
4
|
import { MessagesMixin as N } from "../../common/mixins/input.js";
|
|
5
|
-
import { resolveComponent as x, createElementBlock as a, openBlock as n, mergeProps as h, createElementVNode as p, createVNode as
|
|
5
|
+
import { resolveComponent as x, createElementBlock as a, openBlock as n, mergeProps as h, createElementVNode as p, createVNode as O, renderSlot as c, createCommentVNode as g, normalizeClass as f, toDisplayString as S, createTextVNode as B, toHandlers as y } from "vue";
|
|
6
6
|
import { _ as D } from "../../_plugin-vue_export-helper-CHgC5LLL.js";
|
|
7
7
|
import q from "../validation-messages/validation-messages.js";
|
|
8
|
-
const
|
|
8
|
+
const j = {
|
|
9
9
|
compatConfig: { MODE: 3 },
|
|
10
10
|
name: "DtInput",
|
|
11
11
|
components: { DtValidationMessages: q },
|
|
@@ -94,6 +94,15 @@ const k = {
|
|
|
94
94
|
type: [String, Object, Array],
|
|
95
95
|
default: ""
|
|
96
96
|
},
|
|
97
|
+
/**
|
|
98
|
+
* Additional class name for the root element.
|
|
99
|
+
* Can accept all of String, Object, and Array, i.e. has the
|
|
100
|
+
* same api as Vue's built-in handling of the class attribute.
|
|
101
|
+
*/
|
|
102
|
+
rootClass: {
|
|
103
|
+
type: [String, Object, Array],
|
|
104
|
+
default: ""
|
|
105
|
+
},
|
|
97
106
|
/**
|
|
98
107
|
* The current character length that the user has entered into the input.
|
|
99
108
|
* This will only need to be used if you are using `validate.length` and
|
|
@@ -235,10 +244,10 @@ const k = {
|
|
|
235
244
|
};
|
|
236
245
|
},
|
|
237
246
|
descriptionKey() {
|
|
238
|
-
return `input-description-${
|
|
247
|
+
return `input-description-${T()}`;
|
|
239
248
|
},
|
|
240
249
|
inputState() {
|
|
241
|
-
return
|
|
250
|
+
return A(this.validationMessages);
|
|
242
251
|
},
|
|
243
252
|
defaultLengthCalculation() {
|
|
244
253
|
return this.calculateLength(this.modelValue);
|
|
@@ -273,7 +282,6 @@ const k = {
|
|
|
273
282
|
shouldLimitMaxLength() {
|
|
274
283
|
return this.shouldValidateLength && this.validationProps.length.limitMaxLength;
|
|
275
284
|
},
|
|
276
|
-
// eslint-disable-next-line complexity
|
|
277
285
|
showLengthLimitValidation() {
|
|
278
286
|
return this.shouldValidateLength && this.inputLengthState !== null && this.validationProps.length.message && (this.retainWarning || this.isInputFocused || this.isInvalid);
|
|
279
287
|
},
|
|
@@ -356,7 +364,7 @@ const k = {
|
|
|
356
364
|
this.$refs.input.value = "", this.$refs.input.focus(), this.emitClearEvents();
|
|
357
365
|
}
|
|
358
366
|
}
|
|
359
|
-
},
|
|
367
|
+
}, k = ["aria-details"], F = ["id"], R = { key: 0 }, U = {
|
|
360
368
|
key: 1,
|
|
361
369
|
"data-qa": "dt-input-length-description",
|
|
362
370
|
class: "d-input__length-description"
|
|
@@ -365,7 +373,7 @@ function Y(t, s, i, r, u, e) {
|
|
|
365
373
|
const d = x("dt-validation-messages");
|
|
366
374
|
return n(), a("div", h({
|
|
367
375
|
ref: "container",
|
|
368
|
-
class: ["d-input__root", { "d-input--hidden": i.hidden }]
|
|
376
|
+
class: [i.rootClass, "d-input__root", { "d-input--hidden": i.hidden }]
|
|
369
377
|
}, e.addClassStyleAttrs(t.$attrs), { "data-qa": "dt-input" }), [
|
|
370
378
|
p("label", {
|
|
371
379
|
class: "d-input__label",
|
|
@@ -397,11 +405,11 @@ function Y(t, s, i, r, u, e) {
|
|
|
397
405
|
}, [
|
|
398
406
|
u.hasSlotContent(t.$slots.description) || i.description ? (n(), a("div", R, [
|
|
399
407
|
c(t.$slots, "description", {}, () => [
|
|
400
|
-
|
|
408
|
+
B(S(i.description), 1)
|
|
401
409
|
])
|
|
402
410
|
])) : g("", !0),
|
|
403
411
|
e.shouldValidateLength ? (n(), a("div", U, S(e.validationProps.length.description), 1)) : g("", !0)
|
|
404
|
-
], 10,
|
|
412
|
+
], 10, F)) : g("", !0),
|
|
405
413
|
p("div", {
|
|
406
414
|
class: f(e.inputWrapperClasses()),
|
|
407
415
|
"read-only": i.disabled === !0 ? !0 : void 0
|
|
@@ -446,15 +454,15 @@ function Y(t, s, i, r, u, e) {
|
|
|
446
454
|
})
|
|
447
455
|
], 32)
|
|
448
456
|
], 10, W)
|
|
449
|
-
], 8,
|
|
450
|
-
|
|
457
|
+
], 8, k),
|
|
458
|
+
O(d, h({
|
|
451
459
|
"validation-messages": e.validationMessages,
|
|
452
460
|
"show-messages": t.showMessages,
|
|
453
461
|
class: t.messagesClass
|
|
454
462
|
}, t.messagesChildProps, { "data-qa": "dt-input-messages" }), null, 16, ["validation-messages", "show-messages", "class"])
|
|
455
463
|
], 16);
|
|
456
464
|
}
|
|
457
|
-
const et = /* @__PURE__ */ D(
|
|
465
|
+
const et = /* @__PURE__ */ D(j, [["render", Y]]);
|
|
458
466
|
export {
|
|
459
467
|
et as default
|
|
460
468
|
};
|