@dialpad/dialtone 9.150.1 → 9.150.3
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/css/dialtone-default-theme.css +0 -3
- package/dist/css/dialtone-default-theme.min.css +1 -1
- package/dist/css/dialtone.css +0 -3
- package/dist/css/dialtone.min.css +1 -1
- package/dist/js/dialtone_health_check/deprecated_icons.cjs +105 -0
- package/dist/js/dialtone_health_check/index.cjs +82 -0
- package/dist/js/dialtone_health_check/non_dialtone_properties.cjs +44 -0
- package/dist/js/dialtone_migrate_flex_to_stack/examples-edge-cases.vue +329 -0
- package/dist/js/dialtone_migrate_flex_to_stack/index.mjs +1377 -0
- package/dist/js/dialtone_migration_helper/configs/box-shadows.mjs +19 -0
- package/dist/js/dialtone_migration_helper/configs/colors.mjs +69 -0
- package/dist/js/dialtone_migration_helper/configs/fonts.mjs +49 -0
- package/dist/js/dialtone_migration_helper/configs/size-and-space.mjs +124 -0
- package/dist/js/dialtone_migration_helper/helpers.mjs +212 -0
- package/dist/js/dialtone_migration_helper/index.mjs +135 -0
- package/dist/tokens/doc.json +51865 -51865
- package/dist/vue3/common/utils/index.cjs +1 -1
- package/dist/vue3/common/utils/index.cjs.map +1 -1
- package/dist/vue3/common/utils/index.js +67 -62
- package/dist/vue3/common/utils/index.js.map +1 -1
- package/dist/vue3/lib/combobox-multi-select/combobox-multi-select.cjs +1 -1
- package/dist/vue3/lib/combobox-multi-select/combobox-multi-select.cjs.map +1 -1
- package/dist/vue3/lib/combobox-multi-select/combobox-multi-select.js +79 -75
- package/dist/vue3/lib/combobox-multi-select/combobox-multi-select.js.map +1 -1
- package/dist/vue3/lib/toggle/toggle.cjs +1 -1
- package/dist/vue3/lib/toggle/toggle.cjs.map +1 -1
- package/dist/vue3/lib/toggle/toggle.js +1 -1
- package/dist/vue3/lib/toggle/toggle.js.map +1 -1
- package/dist/vue3/types/common/utils/index.d.ts +3 -3
- package/dist/vue3/types/common/utils/index.d.ts.map +1 -1
- package/dist/vue3/types/components/collapsible/collapsible.vue.d.ts +1 -3
- package/dist/vue3/types/components/toast/layouts/toast_layout_alternate.vue.d.ts +1 -3
- package/dist/vue3/types/components/toast/layouts/toast_layout_default.vue.d.ts +1 -3
- package/dist/vue3/types/components/toast/toast.vue.d.ts +2 -6
- package/dist/vue3/types/recipes/buttons/callbar_button/callbar_button.vue.d.ts +7 -0
- package/dist/vue3/types/recipes/buttons/callbar_button/callbar_button.vue.d.ts.map +1 -1
- package/dist/vue3/types/recipes/comboboxes/combobox_multi_select/combobox_multi_select.vue.d.ts.map +1 -1
- package/dist/vue3/types/recipes/leftbar/contact_centers_row/contact_centers_row.vue.d.ts +1 -3
- package/dist/vue3/types/recipes/leftbar/contact_centers_row/contact_centers_row.vue.d.ts.map +1 -1
- package/dist/vue3/types/recipes/leftbar/contact_row/contact_row.vue.d.ts +1 -3
- package/dist/vue3/types/recipes/leftbar/general_row/general_row.vue.d.ts +1 -3
- package/dist/vue3/types/recipes/leftbar/general_row/general_row.vue.d.ts.map +1 -1
- package/dist/vue3/types/recipes/leftbar/group_row/group_row.vue.d.ts +1 -3
- package/dist/vue3/types/recipes/leftbar/group_row/group_row.vue.d.ts.map +1 -1
- package/package.json +4 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("../constants/index.cjs"),f=require("../config/index.cjs"),i=require("vue");let
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("../constants/index.cjs"),f=require("../config/index.cjs"),i=require("vue");let W=0,d;const z="input:not([type=hidden]):not(:disabled)",G="select:not(:disabled),textarea:not(:disabled),button:not(:disabled)",H=`${z},${G}`,B=`a,frame,iframe,${H},*[tabindex]`,Y=typeof setImmediate=="function"?setImmediate:setTimeout;function E(e=r.DEFAULT_PREFIX){return`${e}${W++}`}function m(e,t){if(t){const n=b(t);return e[Math.abs(n)%e.length]}else return e[c(e.length)]}function b(e){let t;for(let n=0;n<e.length;n++)t=Math.imul(31,t)+e.charCodeAt(n)|0;return t}function c(e){return Math.floor(Math.random()*e)}function g(e){return e?e.map(t=>typeof t=="string"?{message:t,type:r.DEFAULT_VALIDATION_MESSAGE_TYPE}:t):[]}function S(e){const t=u(e);return!e||!t?[]:e.filter(n=>!!n.message&&n.type===t)}function u(e){return e?o(e,r.VALIDATION_MESSAGE_TYPES.ERROR)?r.VALIDATION_MESSAGE_TYPES.ERROR:o(e,r.VALIDATION_MESSAGE_TYPES.WARNING)?r.VALIDATION_MESSAGE_TYPES.WARNING:o(e,r.VALIDATION_MESSAGE_TYPES.SUCCESS)?r.VALIDATION_MESSAGE_TYPES.SUCCESS:null:null}function o(e,t){return!e||!t?!1:e.some(n=>(n==null?void 0:n.type)===t)}function q(e){return e==null?void 0:e.querySelector(B)}const h=e=>i.h("div",{innerHTML:e.html}),A=()=>new Promise(e=>{Y(e)});function K(e,t={}){return e?e(t).some(n=>n.type===i.Comment||Array.isArray(n.children)&&!n.children.length?!1:n.type!==i.Text||typeof n.children=="string"&&n.children.trim()!==""):!1}const p=e=>e==null?void 0:e.toLowerCase().split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(""),Z=e=>e.replace(/\.?([A-Z0-9]+)/g,(t,n)=>"-"+n.toLowerCase()).replace(/^-/,""),R=e=>{const t=Object.entries(e).filter(([n])=>n.match(/on[A-Z]/));return Object.fromEntries(t)},T=e=>{const t=Object.entries(e).filter(([n])=>!n.match(/on[A-Z]/));return Object.fromEntries(t)},a=e=>(e==null?void 0:e.nodeType)===Node.ELEMENT_NODE?e:e!=null&&e.nodeType?a(e==null?void 0:e.nextSibling):null;function C(e){if(!f.configVue2StyleClassAttrs)return e;const t=Object.entries(e).filter(([n])=>!["class","style"].includes(n));return Object.fromEntries(t)}function O(e){return f.configVue2StyleClassAttrs?{class:e.class,style:e.style}:{}}function _(e,t=300){clearTimeout(d),d=setTimeout(e,t)}function y(e){const t=e.getBoundingClientRect(),n={top:t.top<0,left:t.left<0,bottom:t.bottom>(window.innerHeight||document.documentElement.clientHeight),right:t.right>(window.innerWidth||document.documentElement.clientWidth)};return n.any=Object.values(n).some(s=>s),n.all=Object.values(n).every(s=>s),n}const Q=/(?:(?:[^\s!@#$%^&*()_=+[\]{}\\|;:'",.<>/?]+)\.)/,X=new RegExp("(?:com|ru|org|net|de|jp|uk|br|it|pl|fr|in|au|ir|info|nl|cn|es|cz|kr|ca|eu|ua|co|gr|za|ro|biz|ch|se|tw|mx|vn|hu|be|tr|at|dk|tv|me|ar|sk|no|us|fi|id|cl|xyz|io|pt|by|il|ie|nz|kz|hk|lt|cc|my|sg|club|bg|edu|рф|pk|su|top|th|hr|rs|pe|pro|si|az|lv|pw|ae|ph|online|ng|ee|ws|ve|cat)"),J=new RegExp("(?:(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])"),x=new RegExp("(?:"+[[Q.source,X.source].join("+"),J.source].join("|")+")"),ee=/(?:(?:[;/][^#?<>\s]*)?)/,L=/(?:(?:\?[^#<>\s]+)?(?:#[^<>\s]+)?)/,N=new RegExp("\\b"+[x.source,ee.source,L.source,"(?!\\w)"].join("+")),I=/\b[a-z\d.-]+:\/\/[^<>\s]+/,w=new RegExp("(?:mailto:)?[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@"+[x.source,L.source].join("+")+"(?!\\w)");function l(e=7,t=15){try{return new RegExp(`(?:^|(?<=\\W))(?![\\s\\-])\\+?(?:[0-9()\\- \\t]{${e},${t}})(?=\\b)(?=\\W(?=\\W|$)|\\s|$)`)}catch{console.warn("This browser doesn't support regex lookahead/lookbehind")}return new RegExp(`(?![\\s\\-])\\+?(?:[0-9()\\- \\t]{${e},${t}})(?=\\b)(?=\\W(?=\\W|$)|\\s|$)`)}const F=l(),P=new RegExp([N.source,I.source,w.source,F.source].join("|"),"gi");function U(e){var t;return!e||!["string","number"].includes(typeof e)?!1:(e=e.toString(),((t=F.exec(e))==null?void 0:t[0])===e)}function D(e){var t,n;return!e||typeof e!="string"?!1:((t=N.exec(e))==null?void 0:t[0])===e||((n=I.exec(e))==null?void 0:n[0])===e}function j(e){var t;return!e||typeof e!="string"?!1:((t=w.exec(e))==null?void 0:t[0])===e}function M(e){return e.filter(t=>!!t).join(", ")}function $(e,t="en-US"){return e.replace(new RegExp("^\\p{CWU}","u"),n=>n.toLocaleUpperCase(t))}function te(e,t){typeof process>"u"||process.env.NODE_ENV==="test"&&(!e||!(e instanceof HTMLElement)||!(document!=null&&document.body)||document.body.contains(e)||console.warn(`The ${t} component is not attached to the document body. This may cause issues.`))}function v(e=document.documentElement){return!!e.hasAttribute("data-overlayscrollbars")}function V(e=document.documentElement){v(e)?e.classList.add("d-scrollbar-disabled"):e.classList.add("d-of-hidden")}function k(e=document.documentElement){v(e)?e.classList.remove("d-scrollbar-disabled"):e.classList.remove("d-of-hidden")}function ne(e){return e.replaceAll(/[ -]/g,"_").replaceAll(/\W/g,"").toUpperCase()}const re={getUniqueString:E,getRandomElement:m,getRandomInt:c,formatMessages:g,filterFormattedMessages:S,hasFormattedMessageOfType:o,getValidationState:u,htmlFragment:h,flushPromises:A,kebabCaseToPascalCase:p,extractVueListeners:R,extractNonListeners:T,removeClassStyleAttrs:C,addClassStyleAttrs:O,returnFirstEl:a,debounce:_,isOutOfViewPort:y,getPhoneNumberRegex:l,linkRegex:P,isEmailAddress:j,isPhoneNumber:U,isURL:D,safeConcatStrings:M,capitalizeFirstLetter:$,disableRootScrolling:V,enableRootScrolling:k};exports.addClassStyleAttrs=O;exports.capitalizeFirstLetter=$;exports.debounce=_;exports.default=re;exports.disableRootScrolling=V;exports.enableRootScrolling=k;exports.extractNonListeners=T;exports.extractVueListeners=R;exports.filterFormattedMessages=S;exports.findFirstFocusableNode=q;exports.flushPromises=A;exports.formatMessages=g;exports.getPhoneNumberRegex=l;exports.getRandomElement=m;exports.getRandomInt=c;exports.getUniqueString=E;exports.getValidationState=u;exports.hasFormattedMessageOfType=o;exports.hasSlotContent=K;exports.htmlFragment=h;exports.isEmailAddress=j;exports.isOutOfViewPort=y;exports.isPhoneNumber=U;exports.isURL=D;exports.javaHashCode=b;exports.kebabCaseToPascalCase=p;exports.linkRegex=P;exports.pascalCaseToKebabCase=Z;exports.removeClassStyleAttrs=C;exports.returnFirstEl=a;exports.safeConcatStrings=M;exports.toFluentKeyString=ne;exports.warnIfUnmounted=te;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../common/utils/index.js"],"sourcesContent":["import {\n DEFAULT_PREFIX,\n DEFAULT_VALIDATION_MESSAGE_TYPE,\n VALIDATION_MESSAGE_TYPES,\n} from '../constants/index.js';\nimport {\n configVue2StyleClassAttrs,\n} from '../config';\nimport {\n h,\n Comment,\n Text,\n} from 'vue';\n\nlet UNIQUE_ID_COUNTER = 0;\nlet TIMER;\n\n// selector to find focusable not hidden inputs\nconst FOCUSABLE_SELECTOR_NOT_HIDDEN = 'input:not([type=hidden]):not(:disabled)';\n// selector to find focusable not disables elements\nconst FOCUSABLE_SELECTOR_NOT_DISABLED = 'select:not(:disabled),textarea:not(:disabled),button:not(:disabled)';\n// // selector to find focusable not hidden and disabled elements\nconst FOCUSABLE_SELECTOR_NOT_HIDDEN_DISABLED = `${FOCUSABLE_SELECTOR_NOT_HIDDEN},${FOCUSABLE_SELECTOR_NOT_DISABLED}`;\n// selector to find focusable elements\nconst FOCUSABLE_SELECTOR = `a,frame,iframe,${FOCUSABLE_SELECTOR_NOT_HIDDEN_DISABLED},*[tabindex]`;\n\nconst scheduler = typeof setImmediate === 'function' ? setImmediate : setTimeout;\n\nexport function getUniqueString (prefix = DEFAULT_PREFIX) {\n return `${prefix}${UNIQUE_ID_COUNTER++}`;\n}\n\n/**\n * Returns a random element from array\n * @param array - the array to return a random element from\n * @param {string} seed - use a string to seed the randomization, so it returns the same element each time\n * based on that string.\n * @returns {*} - the random element\n */\nexport function getRandomElement (array, seed) {\n if (seed) {\n const hash = javaHashCode(seed);\n return array[Math.abs(hash) % array.length];\n } else {\n return array[getRandomInt(array.length)];\n }\n}\n\n/**\n * Returns a hash code for a string.\n * (Compatible to Java's String.hashCode())\n * We use this algo to be in sync with android.\n *\n * The hash code for a string object is computed as\n * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]\n * using number arithmetic, where s[i] is the i th character\n * of the given string, n is the length of the string,\n * and ^ indicates exponentiation.\n * (The hash value of the empty string is zero.)\n *\n * @param {string} str a string\n * @return {number} a hash code value for the given string.\n */\nexport function javaHashCode (str) {\n let h;\n for (let i = 0; i < str.length; i++) {\n h = Math.imul(31, h) + str.charCodeAt(i) | 0;\n }\n\n return h;\n}\n\n/**\n * Generate a random integer\n * @param {number} max - max range of integer to generate\n * @returns {number} randomly generated integer between 0 and max\n */\nexport function getRandomInt (max) {\n return Math.floor(Math.random() * max);\n}\n\nexport function formatMessages (messages) {\n if (!messages) {\n return [];\n }\n\n return messages.map(message => {\n if (typeof message === 'string') {\n return {\n message,\n type: DEFAULT_VALIDATION_MESSAGE_TYPE,\n };\n }\n\n return message;\n });\n}\n\nexport function filterFormattedMessages (formattedMessages) {\n const validationState = getValidationState(formattedMessages);\n\n if (!formattedMessages || !validationState) {\n return [];\n }\n\n return formattedMessages.filter(message => !!message.message && message.type === validationState);\n}\n\n/*\n * The priority order of message types is as flows: 'error' > 'warning' > 'success'.\n * If any message of type 'error' is present in messages, the input state is considered\n * to be 'error', then 'warning' and lastly 'success'.\n */\nexport function getValidationState (formattedMessages) {\n if (!formattedMessages) {\n return null;\n }\n\n if (hasFormattedMessageOfType(formattedMessages, VALIDATION_MESSAGE_TYPES.ERROR)) {\n return VALIDATION_MESSAGE_TYPES.ERROR;\n }\n if (hasFormattedMessageOfType(formattedMessages, VALIDATION_MESSAGE_TYPES.WARNING)) {\n return VALIDATION_MESSAGE_TYPES.WARNING;\n }\n if (hasFormattedMessageOfType(formattedMessages, VALIDATION_MESSAGE_TYPES.SUCCESS)) {\n return VALIDATION_MESSAGE_TYPES.SUCCESS;\n }\n\n return null;\n}\n\nexport function hasFormattedMessageOfType (formattedMessages, messageType) {\n if (!formattedMessages || !messageType) {\n return false;\n }\n\n return formattedMessages.some(message => message?.type === messageType);\n}\n\nexport function findFirstFocusableNode (element) {\n return element?.querySelector(FOCUSABLE_SELECTOR);\n}\n\n/* html-fragment component:\n * To render html without wrapping in another element as when using v-html.\n * props: html\n */\nexport const htmlFragment = (props) => {\n return h('div', { innerHTML: props.html });\n};\n\nexport const flushPromises = () => {\n return new Promise((resolve) => {\n scheduler(resolve);\n });\n};\n\n/*\n It is very cumbersome to check if a slot is empty in vue 3. Copied this method from the following thread\n https://github.com/vuejs/core/issues/4733. There is an RFC to fix this but not yet being worked on.\n https://github.com/vuejs/rfcs/discussions/453\n*/\nexport function hasSlotContent (slot, slotProps = {}) {\n if (!slot) return false;\n\n // eslint-disable-next-line complexity\n return slot(slotProps).some((vnode) => {\n if (vnode.type === Comment) return false;\n\n if (Array.isArray(vnode.children) && !vnode.children.length) return false;\n\n return (\n vnode.type !== Text ||\n (typeof vnode.children === 'string' && vnode.children.trim() !== '')\n );\n });\n}\n\n/**\n * Transform a string from kebab-case to PascalCase\n * @param string\n * @returns {string}\n */\nexport const kebabCaseToPascalCase = (string) => {\n return string?.toLowerCase()\n .split('-')\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join('');\n};\n\n/**\n * Transform a string from PascalCase to kebab-case\n * @param string\n * @returns {string}\n */\nexport const pascalCaseToKebabCase = (string) => {\n return string\n .replace(/\\.?([A-Z0-9]+)/g, (x, y) => '-' + y.toLowerCase())\n .replace(/^-/, '');\n};\n\nexport const extractVueListeners = (attrs) => {\n const listeners = Object.entries(attrs)\n .filter(([key]) => key.match(/on[A-Z]/));\n return Object.fromEntries(listeners);\n};\n\n/**\n * $el works very differently than in vue 2, if the first node in the template is a text node\n * such as a comment it will return that instead of the first actual element. This function\n * will recursively return the first element in the template instead of the first node.\n * @param el\n * @returns {HTMLElement} The first element in the template\n */\nexport const returnFirstEl = (el) => {\n if (el?.nodeType === Node.ELEMENT_NODE) {\n return el;\n } else if (!el?.nodeType) {\n return null;\n } else {\n return returnFirstEl(el?.nextSibling);\n }\n};\n\n/**\n Only will apply changes if the config option configVue2StyleClassAttrs is set to true. It is false by default.\n\n Removes the class and style attributes from the $attrs. This is useful for vue 2 to vue 3 migration\n purposes so we don't cause breaking changes due to INSTANCE_ATTRS_CLASS_STYLE\n https://v3-migration.vuejs.org/breaking-changes/attrs-includes-class-style\n\n Remove the class and style attributes from the v-bind like so so v-bind=\"removeClassStyleAttrs($attrs)\",\n and then apply them to the root element manually via:\n\n :class=\"$attrs.class\"\n :style=\"$attrs.style\"\n*/\nexport function removeClassStyleAttrs (attrs) {\n if (!configVue2StyleClassAttrs) return attrs;\n const listeners = Object.entries(attrs)\n .filter(([key]) => !['class', 'style'].includes(key));\n return Object.fromEntries(listeners);\n}\n\n/**\n This should be applied to the root element on components using inheritAttrs: false.\n This will add the class and style attributes back to the root element if configVue2StyleClassAttrs\n is enabled.\n*/\nexport function addClassStyleAttrs (attrs) {\n if (!configVue2StyleClassAttrs) return {};\n return {\n class: attrs.class,\n style: attrs.style,\n };\n}\n\n/*\n* Set's a global timer to debounce the execution of a function.\n* @param { object } func - the function that is going to be called after timeout\n* @param { number } [timeout=300] timeout\n* */\nexport function debounce (func, timeout = 300) {\n clearTimeout(TIMER);\n TIMER = setTimeout(func, timeout);\n}\n\n/**\n * Checks if the element is out of the viewport\n * https://gomakethings.com/how-to-check-if-any-part-of-an-element-is-out-of-the-viewport-with-vanilla-js/\n * @param {HTMLElement} element The element to check\n * @return {Object} A set of booleans for each side of the element\n */\n\nexport function isOutOfViewPort (element) {\n const bounding = element.getBoundingClientRect();\n\n const isOut = {\n top: bounding.top < 0,\n left: bounding.left < 0,\n bottom: bounding.bottom > (window.innerHeight || document.documentElement.clientHeight),\n right: bounding.right > (window.innerWidth || document.documentElement.clientWidth),\n };\n isOut.any = Object.values(isOut).some(val => val);\n isOut.all = Object.values(isOut).every(val => val);\n return isOut;\n}\n\n// match valid characters for a domain name followed by a dot, e.g. \"dialpad.\"\nconst domainNameRegex = /(?:(?:[^\\s!@#$%^&*()_=+[\\]{}\\\\|;:'\",.<>/?]+)\\.)/;\n\n// match valid TLDs for a hostname (outdated list from ~2017)\nconst tldRegerx = new RegExp(\n '(?:' +\n 'com|ru|org|net|de|jp|uk|br|it|pl|fr|in|au|ir|info|nl|cn|es|cz|kr|ca|eu|ua|co|gr|' +\n 'za|ro|biz|ch|se|tw|mx|vn|hu|be|tr|at|dk|tv|me|ar|sk|no|us|fi|id|cl|xyz|io|pt|by|' +\n 'il|ie|nz|kz|hk|lt|cc|my|sg|club|bg|edu|рф|pk|su|top|th|hr|rs|pe|pro|si|az|lv|pw|' +\n 'ae|ph|online|ng|ee|ws|ve|cat' +\n ')',\n);\n\n// match valid IPv4 addresses, e.g. \"192.158.1.38\"\nconst ipv4Regex = new RegExp(\n '(?:(?:[0-9]|[1-9]\\\\d|1\\\\d{2}|2[0-4]\\\\d|25[0-5])\\\\.){3}' +\n '(?:[0-9]|[1-9]\\\\d|1\\\\d{2}|2[0-4]\\\\d|25[0-5])',\n);\n\n// match hostnames OR IPv4 addresses, e.g. \"dialpad.com\" or \"192.158.1.38\"\nconst hostnameOrIpRegex = new RegExp(\n '(?:' +\n [\n [\n domainNameRegex.source,\n tldRegerx.source,\n ].join('+'),\n ipv4Regex.source,\n ].join('|') +\n ')',\n);\n\n// match URL paths, e.g. \"/news\"\nconst urlPathRegex = /(?:(?:[;/][^#?<>\\s]*)?)/;\n\n// match URL queries and fragments, e.g. \"?cache=1&new=true\" or \"#heading1\"\nconst urlQueryOrFragmentRegex = /(?:(?:\\?[^#<>\\s]+)?(?:#[^<>\\s]+)?)/;\n\n// match complete hostnames or IPv4 addresses without a protocol and with optional\n// URL paths, queries and fragments e.g. \"dialpad.com/news?cache=1#heading1\"\nconst urlWithoutProtocolRegex = new RegExp(\n '\\\\b' +\n [\n hostnameOrIpRegex.source,\n urlPathRegex.source,\n urlQueryOrFragmentRegex.source,\n '(?!\\\\w)',\n ].join('+'),\n);\n\n// match complete hostnames with protocols and optional URL paths, queries and fragments,\n// e.g. \"ws://localhost:9011\" or \"https://dialpad.com/news?cache=1#heading1\"\nconst urlWithProtocolRegex = /\\b[a-z\\d.-]+:\\/\\/[^<>\\s]+/;\n\n// match email addresses with an optional \"mailto:\" prefix and URL queries, e.g.\n// \"hey@dialpad.com\" or \"mailto:hey@dialpad.com?subject=Hi&body=Hey%20there\"\nconst emailAddressRegex = new RegExp(\n '(?:mailto:)?' +\n '[a-z0-9!#$%&\\'*+/=?^_`{|}~-]+(?:\\\\.[a-z0-9!#$%&\\'*+/=?^_`{|}~-]+)*@' +\n [\n hostnameOrIpRegex.source,\n urlQueryOrFragmentRegex.source,\n ].join('+') +\n '(?!\\\\w)',\n);\n\n/**\n * Match phone numbers, e.g. \"765-8813\", \"(778) 765-8813\" or \"+17787658813\".\n * @param {number} minLength\n * @param {number} maxLength\n * @returns {RegExp}\n */\nexport function getPhoneNumberRegex (minLength = 7, maxLength = 15) {\n // Some older browser versions don't support lookbehind, so provide a RegExp\n // version without it. It fails just one test case, so IMO it's still good\n // enough to use. https://caniuse.com/js-regexp-lookbehind\n try {\n return new RegExp(\n '(?:^|(?<=\\\\W))' +\n '(?![\\\\s\\\\-])\\\\+?(?:[0-9()\\\\- \\\\t]' +\n `{${minLength},${maxLength}}` +\n ')(?=\\\\b)(?=\\\\W(?=\\\\W|$)|\\\\s|$)',\n );\n } catch {\n // eslint-disable-next-line no-console\n console.warn('This browser doesn\\'t support regex lookahead/lookbehind');\n }\n\n return new RegExp(\n '(?![\\\\s\\\\-])\\\\+?(?:[0-9()\\\\- \\\\t]' +\n `{${minLength},${maxLength}}` +\n ')(?=\\\\b)(?=\\\\W(?=\\\\W|$)|\\\\s|$)',\n );\n}\n\nconst phoneNumberRegex = getPhoneNumberRegex();\n\n// match all link types\nexport const linkRegex = new RegExp(\n [\n urlWithoutProtocolRegex.source,\n urlWithProtocolRegex.source,\n emailAddressRegex.source,\n phoneNumberRegex.source,\n ].join('|'),\n 'gi',\n);\n\n/**\n * Check if a string is a phone number. Validates only exact matches.\n * @param {string|number} input\n * @returns {boolean}\n */\nexport function isPhoneNumber (input) {\n if (!input || (!['string', 'number'].includes(typeof input))) return false;\n input = input.toString();\n return phoneNumberRegex.exec(input)?.[0] === input;\n}\n\n/**\n * Check if a string is an URL. Validates only exact matches.\n * @param {string} input\n * @returns {boolean}\n */\nexport function isURL (input) {\n if (!input || typeof input !== 'string') return false;\n return urlWithoutProtocolRegex.exec(input)?.[0] === input ||\n urlWithProtocolRegex.exec(input)?.[0] === input;\n}\n\n/**\n * Check if a string is an email address. Validates only exact matches.\n * @param {string} input\n * @returns {boolean}\n */\nexport function isEmailAddress (input) {\n if (!input || typeof input !== 'string') return false;\n return emailAddressRegex.exec(input)?.[0] === input;\n}\n\n/**\n * Concatenate a string removing null or undefined elements\n * avoiding parsing them as string with template strings\n * @param {Array} elements\n * @returns {String}\n */\nexport function safeConcatStrings (elements) {\n return elements.filter(str => !!str).join(', ');\n}\n\n/**\n * Locale safe function to capitalize the first letter of a string.\n * @param {string} str the string to capitalize the first letter of\n * @param {string} locale a string representing the locale to be used. Defaults to 'en-US'\n * @returns The passed in string with the first letter capitalized\n */\nexport function capitalizeFirstLetter (str, locale = 'en-US') {\n return str.replace(/^\\p{CWU}/u, char => char.toLocaleUpperCase(locale));\n}\n\n/**\n * Warns if the component is not mounted properly. Useful for tests.\n * @param {HTMLElement} componentRef - the component reference\n * @param {string} componentName - the component name\n */\n// eslint-disable-next-line complexity\nexport function warnIfUnmounted (componentRef, componentName) {\n if (typeof process === 'undefined') return;\n if (process.env.NODE_ENV !== 'test') return;\n if (!componentRef || !(componentRef instanceof HTMLElement) || !document?.body) return;\n if (!document.body.contains(componentRef)) {\n console.warn(`The ${componentName} component is not attached to the document body. This may cause issues.`);\n }\n}\n\n/**\n * checks whether the dt-scrollbar is being used on the root element.\n * @param rootElement {HTMLElement}\n * @returns {boolean}\n */\nfunction isDtScrollbarInUse (rootElement = document.documentElement) {\n if (rootElement.hasAttribute('data-overlayscrollbars')) {\n return true;\n }\n return false;\n}\n\n/**\n * This will disable scrolling on the root element regardless of whether you are using dt-scrollbar or not.\n * @param rootElement {HTMLElement}\n */\nexport function disableRootScrolling (rootElement = document.documentElement) {\n if (isDtScrollbarInUse(rootElement)) {\n rootElement.classList.add('d-scrollbar-disabled');\n } else {\n rootElement.classList.add('d-of-hidden');\n }\n}\n\n/**\n * This will enable scrolling on the root element regardless of whether you are using dt-scrollbar or not.\n * @param rootElement {HTMLElement}\n */\nexport function enableRootScrolling (rootElement = document.documentElement) {\n if (isDtScrollbarInUse(rootElement)) {\n rootElement.classList.remove('d-scrollbar-disabled');\n } else {\n rootElement.classList.remove('d-of-hidden');\n }\n}\n\n/**\n * This will take a text string e.g \"accessibility-mac\"\n * and convert it to our Fluent Key standard format \"ACCESSIBILITY_MAC\"\n * @param text\n * @returns {string}\n */\nexport function toFluentKeyString (text) {\n return text\n .replaceAll(/[ -]/g, '_')\n .replaceAll(/\\W/g, '')\n .toUpperCase();\n}\n\nexport default {\n getUniqueString,\n getRandomElement,\n getRandomInt,\n formatMessages,\n filterFormattedMessages,\n hasFormattedMessageOfType,\n getValidationState,\n htmlFragment,\n flushPromises,\n kebabCaseToPascalCase,\n extractVueListeners,\n removeClassStyleAttrs,\n addClassStyleAttrs,\n returnFirstEl,\n debounce,\n isOutOfViewPort,\n getPhoneNumberRegex,\n linkRegex,\n isEmailAddress,\n isPhoneNumber,\n isURL,\n safeConcatStrings,\n capitalizeFirstLetter,\n disableRootScrolling,\n enableRootScrolling,\n};\n"],"names":["UNIQUE_ID_COUNTER","TIMER","FOCUSABLE_SELECTOR_NOT_HIDDEN","FOCUSABLE_SELECTOR_NOT_DISABLED","FOCUSABLE_SELECTOR_NOT_HIDDEN_DISABLED","FOCUSABLE_SELECTOR","scheduler","getUniqueString","prefix","DEFAULT_PREFIX","getRandomElement","array","seed","hash","javaHashCode","getRandomInt","str","h","i","max","formatMessages","messages","message","DEFAULT_VALIDATION_MESSAGE_TYPE","filterFormattedMessages","formattedMessages","validationState","getValidationState","hasFormattedMessageOfType","VALIDATION_MESSAGE_TYPES","messageType","findFirstFocusableNode","element","htmlFragment","props","flushPromises","resolve","hasSlotContent","slot","slotProps","vnode","Comment","Text","kebabCaseToPascalCase","string","word","pascalCaseToKebabCase","x","y","extractVueListeners","attrs","listeners","key","returnFirstEl","el","removeClassStyleAttrs","configVue2StyleClassAttrs","addClassStyleAttrs","debounce","func","timeout","isOutOfViewPort","bounding","isOut","val","domainNameRegex","tldRegerx","ipv4Regex","hostnameOrIpRegex","urlPathRegex","urlQueryOrFragmentRegex","urlWithoutProtocolRegex","urlWithProtocolRegex","emailAddressRegex","getPhoneNumberRegex","minLength","maxLength","phoneNumberRegex","linkRegex","isPhoneNumber","input","_a","isURL","_b","isEmailAddress","safeConcatStrings","elements","capitalizeFirstLetter","locale","char","warnIfUnmounted","componentRef","componentName","isDtScrollbarInUse","rootElement","disableRootScrolling","enableRootScrolling","toFluentKeyString","text","utils"],"mappings":"wMAcA,IAAIA,EAAoB,EACpBC,EAGJ,MAAMC,EAAgC,0CAEhCC,EAAkC,sEAElCC,EAAyC,GAAGF,CAA6B,IAAIC,CAA+B,GAE5GE,EAAqB,kBAAkBD,CAAsC,eAE7EE,EAAY,OAAO,cAAiB,WAAa,aAAe,WAE/D,SAASC,EAAiBC,EAASC,iBAAgB,CACxD,MAAO,GAAGD,CAAM,GAAGR,GAAmB,EACxC,CASO,SAASU,EAAkBC,EAAOC,EAAM,CAC7C,GAAIA,EAAM,CACR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,SAAS,gBAAiB,CACnE,MAAI,EAAAA,EAAY,aAAa,wBAAwB,CAIvD,CAMO,SAASC,EAAsBD,EAAc,SAAS,gBAAiB,CACxED,EAAmBC,CAAW,EAChCA,EAAY,UAAU,IAAI,sBAAsB,EAEhDA,EAAY,UAAU,IAAI,aAAa,CAE3C,CAMO,SAASE,EAAqBF,EAAc,SAAS,gBAAiB,CACvED,EAAmBC,CAAW,EAChCA,EAAY,UAAU,OAAO,sBAAsB,EAEnDA,EAAY,UAAU,OAAO,aAAa,CAE9C,CAQO,SAASG,GAAmBC,EAAM,CACvC,OAAOA,EACJ,WAAW,QAAS,GAAG,EACvB,WAAW,MAAO,EAAE,EACpB,YAAW,CAChB,CAEA,MAAAC,GAAe,CACb,gBAAA5F,EACA,iBAAAG,EACA,aAAAK,EACA,eAAAK,EACA,wBAAAI,EACA,0BAAAI,EACA,mBAAAD,EACA,aAAAM,EACA,cAAAE,EACA,sBAAAQ,EACA,oBAAAM,EACA,sBAAAM,EACA,mBAAAE,EACA,cAAAJ,EACA,SAAAK,EACA,gBAAAG,EACA,oBAAAa,EACA,UAAAI,EACA,eAAAM,EACA,cAAAL,EACA,MAAAG,EACA,kBAAAG,EACA,sBAAAE,EACA,qBAAAQ,EACA,oBAAAC,CACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../common/utils/index.js"],"sourcesContent":["import {\n DEFAULT_PREFIX,\n DEFAULT_VALIDATION_MESSAGE_TYPE,\n VALIDATION_MESSAGE_TYPES,\n} from '../constants/index.js';\nimport {\n configVue2StyleClassAttrs,\n} from '../config';\nimport {\n h,\n Comment,\n Text,\n} from 'vue';\n\nlet UNIQUE_ID_COUNTER = 0;\nlet TIMER;\n\n// selector to find focusable not hidden inputs\nconst FOCUSABLE_SELECTOR_NOT_HIDDEN = 'input:not([type=hidden]):not(:disabled)';\n// selector to find focusable not disables elements\nconst FOCUSABLE_SELECTOR_NOT_DISABLED = 'select:not(:disabled),textarea:not(:disabled),button:not(:disabled)';\n// // selector to find focusable not hidden and disabled elements\nconst FOCUSABLE_SELECTOR_NOT_HIDDEN_DISABLED = `${FOCUSABLE_SELECTOR_NOT_HIDDEN},${FOCUSABLE_SELECTOR_NOT_DISABLED}`;\n// selector to find focusable elements\nconst FOCUSABLE_SELECTOR = `a,frame,iframe,${FOCUSABLE_SELECTOR_NOT_HIDDEN_DISABLED},*[tabindex]`;\n\nconst scheduler = typeof setImmediate === 'function' ? setImmediate : setTimeout;\n\nexport function getUniqueString (prefix = DEFAULT_PREFIX) {\n return `${prefix}${UNIQUE_ID_COUNTER++}`;\n}\n\n/**\n * Returns a random element from array\n * @param array - the array to return a random element from\n * @param {string} seed - use a string to seed the randomization, so it returns the same element each time\n * based on that string.\n * @returns {*} - the random element\n */\nexport function getRandomElement (array, seed) {\n if (seed) {\n const hash = javaHashCode(seed);\n return array[Math.abs(hash) % array.length];\n } else {\n return array[getRandomInt(array.length)];\n }\n}\n\n/**\n * Returns a hash code for a string.\n * (Compatible to Java's String.hashCode())\n * We use this algo to be in sync with android.\n *\n * The hash code for a string object is computed as\n * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]\n * using number arithmetic, where s[i] is the i th character\n * of the given string, n is the length of the string,\n * and ^ indicates exponentiation.\n * (The hash value of the empty string is zero.)\n *\n * @param {string} str a string\n * @return {number} a hash code value for the given string.\n */\nexport function javaHashCode (str) {\n let h;\n for (let i = 0; i < str.length; i++) {\n h = Math.imul(31, h) + str.charCodeAt(i) | 0;\n }\n\n return h;\n}\n\n/**\n * Generate a random integer\n * @param {number} max - max range of integer to generate\n * @returns {number} randomly generated integer between 0 and max\n */\nexport function getRandomInt (max) {\n return Math.floor(Math.random() * max);\n}\n\nexport function formatMessages (messages) {\n if (!messages) {\n return [];\n }\n\n return messages.map(message => {\n if (typeof message === 'string') {\n return {\n message,\n type: DEFAULT_VALIDATION_MESSAGE_TYPE,\n };\n }\n\n return message;\n });\n}\n\nexport function filterFormattedMessages (formattedMessages) {\n const validationState = getValidationState(formattedMessages);\n\n if (!formattedMessages || !validationState) {\n return [];\n }\n\n return formattedMessages.filter(message => !!message.message && message.type === validationState);\n}\n\n/*\n * The priority order of message types is as flows: 'error' > 'warning' > 'success'.\n * If any message of type 'error' is present in messages, the input state is considered\n * to be 'error', then 'warning' and lastly 'success'.\n */\nexport function getValidationState (formattedMessages) {\n if (!formattedMessages) {\n return null;\n }\n\n if (hasFormattedMessageOfType(formattedMessages, VALIDATION_MESSAGE_TYPES.ERROR)) {\n return VALIDATION_MESSAGE_TYPES.ERROR;\n }\n if (hasFormattedMessageOfType(formattedMessages, VALIDATION_MESSAGE_TYPES.WARNING)) {\n return VALIDATION_MESSAGE_TYPES.WARNING;\n }\n if (hasFormattedMessageOfType(formattedMessages, VALIDATION_MESSAGE_TYPES.SUCCESS)) {\n return VALIDATION_MESSAGE_TYPES.SUCCESS;\n }\n\n return null;\n}\n\nexport function hasFormattedMessageOfType (formattedMessages, messageType) {\n if (!formattedMessages || !messageType) {\n return false;\n }\n\n return formattedMessages.some(message => message?.type === messageType);\n}\n\nexport function findFirstFocusableNode (element) {\n return element?.querySelector(FOCUSABLE_SELECTOR);\n}\n\n/* html-fragment component:\n * To render html without wrapping in another element as when using v-html.\n * props: html\n */\nexport const htmlFragment = (props) => {\n return h('div', { innerHTML: props.html });\n};\n\nexport const flushPromises = () => {\n return new Promise((resolve) => {\n scheduler(resolve);\n });\n};\n\n/*\n It is very cumbersome to check if a slot is empty in vue 3. Copied this method from the following thread\n https://github.com/vuejs/core/issues/4733. There is an RFC to fix this but not yet being worked on.\n https://github.com/vuejs/rfcs/discussions/453\n*/\nexport function hasSlotContent (slot, slotProps = {}) {\n if (!slot) return false;\n\n\n return slot(slotProps).some((vnode) => {\n if (vnode.type === Comment) return false;\n\n if (Array.isArray(vnode.children) && !vnode.children.length) return false;\n\n return (\n vnode.type !== Text ||\n (typeof vnode.children === 'string' && vnode.children.trim() !== '')\n );\n });\n}\n\n/**\n * Transform a string from kebab-case to PascalCase\n * @param string\n * @returns {string}\n */\nexport const kebabCaseToPascalCase = (string) => {\n return string?.toLowerCase()\n .split('-')\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join('');\n};\n\n/**\n * Transform a string from PascalCase to kebab-case\n * @param string\n * @returns {string}\n */\nexport const pascalCaseToKebabCase = (string) => {\n return string\n .replace(/\\.?([A-Z0-9]+)/g, (x, y) => '-' + y.toLowerCase())\n .replace(/^-/, '');\n};\n\n/**\n * Extracts Vue event listeners from attributes object\n * @param {Object} attrs - The attributes object to extract listeners from\n * @returns {Object} Object containing only Vue event listeners (keys matching on[A-Z])\n */\nexport const extractVueListeners = (attrs) => {\n const listeners = Object.entries(attrs)\n .filter(([key]) => key.match(/on[A-Z]/));\n return Object.fromEntries(listeners);\n};\n\n/**\n * Extracts non-listener attributes from attributes object\n * @param {Object} attrs - The attributes object to extract non-listeners from\n * @returns {Object} Object containing only non-listener attributes (keys not matching on[A-Z])\n */\nexport const extractNonListeners = (attrs) => {\n const nonListeners = Object.entries(attrs)\n .filter(([key]) => !key.match(/on[A-Z]/));\n return Object.fromEntries(nonListeners);\n};\n\n/**\n * $el works very differently than in vue 2, if the first node in the template is a text node\n * such as a comment it will return that instead of the first actual element. This function\n * will recursively return the first element in the template instead of the first node.\n * @param el\n * @returns {HTMLElement} The first element in the template\n */\nexport const returnFirstEl = (el) => {\n if (el?.nodeType === Node.ELEMENT_NODE) {\n return el;\n } else if (!el?.nodeType) {\n return null;\n } else {\n return returnFirstEl(el?.nextSibling);\n }\n};\n\n/**\n Only will apply changes if the config option configVue2StyleClassAttrs is set to true. It is false by default.\n\n Removes the class and style attributes from the $attrs. This is useful for vue 2 to vue 3 migration\n purposes so we don't cause breaking changes due to INSTANCE_ATTRS_CLASS_STYLE\n https://v3-migration.vuejs.org/breaking-changes/attrs-includes-class-style\n\n Remove the class and style attributes from the v-bind like so so v-bind=\"removeClassStyleAttrs($attrs)\",\n and then apply them to the root element manually via:\n\n :class=\"$attrs.class\"\n :style=\"$attrs.style\"\n*/\nexport function removeClassStyleAttrs (attrs) {\n if (!configVue2StyleClassAttrs) return attrs;\n const listeners = Object.entries(attrs)\n .filter(([key]) => !['class', 'style'].includes(key));\n return Object.fromEntries(listeners);\n}\n\n/**\n This should be applied to the root element on components using inheritAttrs: false.\n This will add the class and style attributes back to the root element if configVue2StyleClassAttrs\n is enabled.\n*/\nexport function addClassStyleAttrs (attrs) {\n if (!configVue2StyleClassAttrs) return {};\n return {\n class: attrs.class,\n style: attrs.style,\n };\n}\n\n/*\n* Set's a global timer to debounce the execution of a function.\n* @param { object } func - the function that is going to be called after timeout\n* @param { number } [timeout=300] timeout\n* */\nexport function debounce (func, timeout = 300) {\n clearTimeout(TIMER);\n TIMER = setTimeout(func, timeout);\n}\n\n/**\n * Checks if the element is out of the viewport\n * https://gomakethings.com/how-to-check-if-any-part-of-an-element-is-out-of-the-viewport-with-vanilla-js/\n * @param {HTMLElement} element The element to check\n * @return {Object} A set of booleans for each side of the element\n */\n\nexport function isOutOfViewPort (element) {\n const bounding = element.getBoundingClientRect();\n\n const isOut = {\n top: bounding.top < 0,\n left: bounding.left < 0,\n bottom: bounding.bottom > (window.innerHeight || document.documentElement.clientHeight),\n right: bounding.right > (window.innerWidth || document.documentElement.clientWidth),\n };\n isOut.any = Object.values(isOut).some(val => val);\n isOut.all = Object.values(isOut).every(val => val);\n return isOut;\n}\n\n// match valid characters for a domain name followed by a dot, e.g. \"dialpad.\"\nconst domainNameRegex = /(?:(?:[^\\s!@#$%^&*()_=+[\\]{}\\\\|;:'\",.<>/?]+)\\.)/;\n\n// match valid TLDs for a hostname (outdated list from ~2017)\nconst tldRegerx = new RegExp(\n '(?:' +\n 'com|ru|org|net|de|jp|uk|br|it|pl|fr|in|au|ir|info|nl|cn|es|cz|kr|ca|eu|ua|co|gr|' +\n 'za|ro|biz|ch|se|tw|mx|vn|hu|be|tr|at|dk|tv|me|ar|sk|no|us|fi|id|cl|xyz|io|pt|by|' +\n 'il|ie|nz|kz|hk|lt|cc|my|sg|club|bg|edu|рф|pk|su|top|th|hr|rs|pe|pro|si|az|lv|pw|' +\n 'ae|ph|online|ng|ee|ws|ve|cat' +\n ')',\n);\n\n// match valid IPv4 addresses, e.g. \"192.158.1.38\"\nconst ipv4Regex = new RegExp(\n '(?:(?:[0-9]|[1-9]\\\\d|1\\\\d{2}|2[0-4]\\\\d|25[0-5])\\\\.){3}' +\n '(?:[0-9]|[1-9]\\\\d|1\\\\d{2}|2[0-4]\\\\d|25[0-5])',\n);\n\n// match hostnames OR IPv4 addresses, e.g. \"dialpad.com\" or \"192.158.1.38\"\nconst hostnameOrIpRegex = new RegExp(\n '(?:' +\n [\n [\n domainNameRegex.source,\n tldRegerx.source,\n ].join('+'),\n ipv4Regex.source,\n ].join('|') +\n ')',\n);\n\n// match URL paths, e.g. \"/news\"\nconst urlPathRegex = /(?:(?:[;/][^#?<>\\s]*)?)/;\n\n// match URL queries and fragments, e.g. \"?cache=1&new=true\" or \"#heading1\"\nconst urlQueryOrFragmentRegex = /(?:(?:\\?[^#<>\\s]+)?(?:#[^<>\\s]+)?)/;\n\n// match complete hostnames or IPv4 addresses without a protocol and with optional\n// URL paths, queries and fragments e.g. \"dialpad.com/news?cache=1#heading1\"\nconst urlWithoutProtocolRegex = new RegExp(\n '\\\\b' +\n [\n hostnameOrIpRegex.source,\n urlPathRegex.source,\n urlQueryOrFragmentRegex.source,\n '(?!\\\\w)',\n ].join('+'),\n);\n\n// match complete hostnames with protocols and optional URL paths, queries and fragments,\n// e.g. \"ws://localhost:9011\" or \"https://dialpad.com/news?cache=1#heading1\"\nconst urlWithProtocolRegex = /\\b[a-z\\d.-]+:\\/\\/[^<>\\s]+/;\n\n// match email addresses with an optional \"mailto:\" prefix and URL queries, e.g.\n// \"hey@dialpad.com\" or \"mailto:hey@dialpad.com?subject=Hi&body=Hey%20there\"\nconst emailAddressRegex = new RegExp(\n '(?:mailto:)?' +\n '[a-z0-9!#$%&\\'*+/=?^_`{|}~-]+(?:\\\\.[a-z0-9!#$%&\\'*+/=?^_`{|}~-]+)*@' +\n [\n hostnameOrIpRegex.source,\n urlQueryOrFragmentRegex.source,\n ].join('+') +\n '(?!\\\\w)',\n);\n\n/**\n * Match phone numbers, e.g. \"765-8813\", \"(778) 765-8813\" or \"+17787658813\".\n * @param {number} minLength\n * @param {number} maxLength\n * @returns {RegExp}\n */\nexport function getPhoneNumberRegex (minLength = 7, maxLength = 15) {\n // Some older browser versions don't support lookbehind, so provide a RegExp\n // version without it. It fails just one test case, so IMO it's still good\n // enough to use. https://caniuse.com/js-regexp-lookbehind\n try {\n return new RegExp(\n '(?:^|(?<=\\\\W))' +\n '(?![\\\\s\\\\-])\\\\+?(?:[0-9()\\\\- \\\\t]' +\n `{${minLength},${maxLength}}` +\n ')(?=\\\\b)(?=\\\\W(?=\\\\W|$)|\\\\s|$)',\n );\n } catch {\n // eslint-disable-next-line no-console\n console.warn('This browser doesn\\'t support regex lookahead/lookbehind');\n }\n\n return new RegExp(\n '(?![\\\\s\\\\-])\\\\+?(?:[0-9()\\\\- \\\\t]' +\n `{${minLength},${maxLength}}` +\n ')(?=\\\\b)(?=\\\\W(?=\\\\W|$)|\\\\s|$)',\n );\n}\n\nconst phoneNumberRegex = getPhoneNumberRegex();\n\n// match all link types\nexport const linkRegex = new RegExp(\n [\n urlWithoutProtocolRegex.source,\n urlWithProtocolRegex.source,\n emailAddressRegex.source,\n phoneNumberRegex.source,\n ].join('|'),\n 'gi',\n);\n\n/**\n * Check if a string is a phone number. Validates only exact matches.\n * @param {string|number} input\n * @returns {boolean}\n */\nexport function isPhoneNumber (input) {\n if (!input || (!['string', 'number'].includes(typeof input))) return false;\n input = input.toString();\n return phoneNumberRegex.exec(input)?.[0] === input;\n}\n\n/**\n * Check if a string is an URL. Validates only exact matches.\n * @param {string} input\n * @returns {boolean}\n */\nexport function isURL (input) {\n if (!input || typeof input !== 'string') return false;\n return urlWithoutProtocolRegex.exec(input)?.[0] === input ||\n urlWithProtocolRegex.exec(input)?.[0] === input;\n}\n\n/**\n * Check if a string is an email address. Validates only exact matches.\n * @param {string} input\n * @returns {boolean}\n */\nexport function isEmailAddress (input) {\n if (!input || typeof input !== 'string') return false;\n return emailAddressRegex.exec(input)?.[0] === input;\n}\n\n/**\n * Concatenate a string removing null or undefined elements\n * avoiding parsing them as string with template strings\n * @param {Array} elements\n * @returns {String}\n */\nexport function safeConcatStrings (elements) {\n return elements.filter(str => !!str).join(', ');\n}\n\n/**\n * Locale safe function to capitalize the first letter of a string.\n * @param {string} str the string to capitalize the first letter of\n * @param {string} locale a string representing the locale to be used. Defaults to 'en-US'\n * @returns The passed in string with the first letter capitalized\n */\nexport function capitalizeFirstLetter (str, locale = 'en-US') {\n return str.replace(/^\\p{CWU}/u, char => char.toLocaleUpperCase(locale));\n}\n\n/**\n * Warns if the component is not mounted properly. Useful for tests.\n * @param {HTMLElement} componentRef - the component reference\n * @param {string} componentName - the component name\n */\n\nexport function warnIfUnmounted (componentRef, componentName) {\n if (typeof process === 'undefined') return;\n if (process.env.NODE_ENV !== 'test') return;\n if (!componentRef || !(componentRef instanceof HTMLElement) || !document?.body) return;\n if (!document.body.contains(componentRef)) {\n console.warn(`The ${componentName} component is not attached to the document body. This may cause issues.`);\n }\n}\n\n/**\n * checks whether the dt-scrollbar is being used on the root element.\n * @param rootElement {HTMLElement}\n * @returns {boolean}\n */\nfunction isDtScrollbarInUse (rootElement = document.documentElement) {\n if (rootElement.hasAttribute('data-overlayscrollbars')) {\n return true;\n }\n return false;\n}\n\n/**\n * This will disable scrolling on the root element regardless of whether you are using dt-scrollbar or not.\n * @param rootElement {HTMLElement}\n */\nexport function disableRootScrolling (rootElement = document.documentElement) {\n if (isDtScrollbarInUse(rootElement)) {\n rootElement.classList.add('d-scrollbar-disabled');\n } else {\n rootElement.classList.add('d-of-hidden');\n }\n}\n\n/**\n * This will enable scrolling on the root element regardless of whether you are using dt-scrollbar or not.\n * @param rootElement {HTMLElement}\n */\nexport function enableRootScrolling (rootElement = document.documentElement) {\n if (isDtScrollbarInUse(rootElement)) {\n rootElement.classList.remove('d-scrollbar-disabled');\n } else {\n rootElement.classList.remove('d-of-hidden');\n }\n}\n\n/**\n * This will take a text string e.g \"accessibility-mac\"\n * and convert it to our Fluent Key standard format \"ACCESSIBILITY_MAC\"\n * @param text\n * @returns {string}\n */\nexport function toFluentKeyString (text) {\n return text\n .replaceAll(/[ -]/g, '_')\n .replaceAll(/\\W/g, '')\n .toUpperCase();\n}\n\nexport default {\n getUniqueString,\n getRandomElement,\n getRandomInt,\n formatMessages,\n filterFormattedMessages,\n hasFormattedMessageOfType,\n getValidationState,\n htmlFragment,\n flushPromises,\n kebabCaseToPascalCase,\n extractVueListeners,\n extractNonListeners,\n removeClassStyleAttrs,\n addClassStyleAttrs,\n returnFirstEl,\n debounce,\n isOutOfViewPort,\n getPhoneNumberRegex,\n linkRegex,\n isEmailAddress,\n isPhoneNumber,\n isURL,\n safeConcatStrings,\n capitalizeFirstLetter,\n disableRootScrolling,\n enableRootScrolling,\n};\n"],"names":["UNIQUE_ID_COUNTER","TIMER","FOCUSABLE_SELECTOR_NOT_HIDDEN","FOCUSABLE_SELECTOR_NOT_DISABLED","FOCUSABLE_SELECTOR_NOT_HIDDEN_DISABLED","FOCUSABLE_SELECTOR","scheduler","getUniqueString","prefix","DEFAULT_PREFIX","getRandomElement","array","seed","hash","javaHashCode","getRandomInt","str","h","i","max","formatMessages","messages","message","DEFAULT_VALIDATION_MESSAGE_TYPE","filterFormattedMessages","formattedMessages","validationState","getValidationState","hasFormattedMessageOfType","VALIDATION_MESSAGE_TYPES","messageType","findFirstFocusableNode","element","htmlFragment","props","flushPromises","resolve","hasSlotContent","slot","slotProps","vnode","Comment","Text","kebabCaseToPascalCase","string","word","pascalCaseToKebabCase","x","y","extractVueListeners","attrs","listeners","key","extractNonListeners","nonListeners","returnFirstEl","el","removeClassStyleAttrs","configVue2StyleClassAttrs","addClassStyleAttrs","debounce","func","timeout","isOutOfViewPort","bounding","isOut","val","domainNameRegex","tldRegerx","ipv4Regex","hostnameOrIpRegex","urlPathRegex","urlQueryOrFragmentRegex","urlWithoutProtocolRegex","urlWithProtocolRegex","emailAddressRegex","getPhoneNumberRegex","minLength","maxLength","phoneNumberRegex","linkRegex","isPhoneNumber","input","_a","isURL","_b","isEmailAddress","safeConcatStrings","elements","capitalizeFirstLetter","locale","char","warnIfUnmounted","componentRef","componentName","isDtScrollbarInUse","rootElement","disableRootScrolling","enableRootScrolling","toFluentKeyString","text","utils"],"mappings":"wMAcA,IAAIA,EAAoB,EACpBC,EAGJ,MAAMC,EAAgC,0CAEhCC,EAAkC,sEAElCC,EAAyC,GAAGF,CAA6B,IAAIC,CAA+B,GAE5GE,EAAqB,kBAAkBD,CAAsC,eAE7EE,EAAY,OAAO,cAAiB,WAAa,aAAe,WAE/D,SAASC,EAAiBC,EAASC,iBAAgB,CACxD,MAAO,GAAGD,CAAM,GAAGR,GAAmB,EACxC,CASO,SAASU,EAAkBC,EAAOC,EAAM,CAC7C,GAAIA,EAAM,CACR,MAAMC,EAAOC,EAAaF,CAAI,EAC9B,OAAOD,EAAM,KAAK,IAAIE,CAAI,EAAIF,EAAM,MAAM,CAC5C,KACE,QAAOA,EAAMI,EAAaJ,EAAM,MAAM,CAAC,CAE3C,CAiBO,SAASG,EAAcE,EAAK,CACjC,IAAIC,EACJ,QAASC,EAAI,EAAGA,EAAIF,EAAI,OAAQE,IAC9BD,EAAI,KAAK,KAAK,GAAIA,CAAC,EAAID,EAAI,WAAWE,CAAC,EAAI,EAG7C,OAAOD,CACT,CAOO,SAASF,EAAcI,EAAK,CACjC,OAAO,KAAK,MAAM,KAAK,OAAM,EAAKA,CAAG,CACvC,CAEO,SAASC,EAAgBC,EAAU,CACxC,OAAKA,EAIEA,EAAS,IAAIC,GACd,OAAOA,GAAY,SACd,CACL,QAAAA,EACA,KAAMC,EAAAA,+BACd,EAGWD,CACR,EAZQ,CAAA,CAaX,CAEO,SAASE,EAAyBC,EAAmB,CAC1D,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,EACpB,YAAW,CAChB,CAEA,MAAAC,GAAe,CACb,gBAAA9F,EACA,iBAAAG,EACA,aAAAK,EACA,eAAAK,EACA,wBAAAI,EACA,0BAAAI,EACA,mBAAAD,EACA,aAAAM,EACA,cAAAE,EACA,sBAAAQ,EACA,oBAAAM,EACA,oBAAAI,EACA,sBAAAI,EACA,mBAAAE,EACA,cAAAJ,EACA,SAAAK,EACA,gBAAAG,EACA,oBAAAa,EACA,UAAAI,EACA,eAAAM,EACA,cAAAL,EACA,MAAAG,EACA,kBAAAG,EACA,sBAAAE,EACA,qBAAAQ,EACA,oBAAAC,CACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { DEFAULT_PREFIX as R, DEFAULT_VALIDATION_MESSAGE_TYPE as S, VALIDATION_MESSAGE_TYPES as r } from "../constants/index.js";
|
|
2
2
|
import { configVue2StyleClassAttrs as c } from "../config/index.js";
|
|
3
|
-
import { Comment as
|
|
4
|
-
let
|
|
5
|
-
const
|
|
3
|
+
import { Comment as x, Text as y, h as C } from "vue";
|
|
4
|
+
let O = 0, s;
|
|
5
|
+
const A = "input:not([type=hidden]):not(:disabled)", T = "select:not(:disabled),textarea:not(:disabled),button:not(:disabled)", L = `${A},${T}`, _ = `a,frame,iframe,${L},*[tabindex]`, w = typeof setImmediate == "function" ? setImmediate : setTimeout;
|
|
6
6
|
function N(e = R) {
|
|
7
|
-
return `${e}${
|
|
7
|
+
return `${e}${O++}`;
|
|
8
8
|
}
|
|
9
9
|
function I(e, t) {
|
|
10
10
|
if (t) {
|
|
@@ -22,13 +22,13 @@ function U(e) {
|
|
|
22
22
|
function u(e) {
|
|
23
23
|
return Math.floor(Math.random() * e);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function j(e) {
|
|
26
26
|
return e ? e.map((t) => typeof t == "string" ? {
|
|
27
27
|
message: t,
|
|
28
28
|
type: S
|
|
29
29
|
} : t) : [];
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function $(e) {
|
|
32
32
|
const t = l(e);
|
|
33
33
|
return !e || !t ? [] : e.filter((n) => !!n.message && n.type === t);
|
|
34
34
|
}
|
|
@@ -38,34 +38,37 @@ function l(e) {
|
|
|
38
38
|
function o(e, t) {
|
|
39
39
|
return !e || !t ? !1 : e.some((n) => (n == null ? void 0 : n.type) === t);
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function ie(e) {
|
|
42
42
|
return e == null ? void 0 : e.querySelector(_);
|
|
43
43
|
}
|
|
44
|
-
const
|
|
44
|
+
const D = (e) => C("div", { innerHTML: e.html }), F = () => new Promise((e) => {
|
|
45
45
|
w(e);
|
|
46
46
|
});
|
|
47
|
-
function
|
|
48
|
-
return e ? e(t).some((n) => n.type ===
|
|
47
|
+
function se(e, t = {}) {
|
|
48
|
+
return e ? e(t).some((n) => n.type === x || Array.isArray(n.children) && !n.children.length ? !1 : n.type !== y || typeof n.children == "string" && n.children.trim() !== "") : !1;
|
|
49
49
|
}
|
|
50
|
-
const W = (e) => e == null ? void 0 : e.toLowerCase().split("-").map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(""),
|
|
50
|
+
const W = (e) => e == null ? void 0 : e.toLowerCase().split("-").map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(""), ce = (e) => e.replace(/\.?([A-Z0-9]+)/g, (t, n) => "-" + n.toLowerCase()).replace(/^-/, ""), P = (e) => {
|
|
51
51
|
const t = Object.entries(e).filter(([n]) => n.match(/on[A-Z]/));
|
|
52
52
|
return Object.fromEntries(t);
|
|
53
|
+
}, k = (e) => {
|
|
54
|
+
const t = Object.entries(e).filter(([n]) => !n.match(/on[A-Z]/));
|
|
55
|
+
return Object.fromEntries(t);
|
|
53
56
|
}, a = (e) => (e == null ? void 0 : e.nodeType) === Node.ELEMENT_NODE ? e : e != null && e.nodeType ? a(e == null ? void 0 : e.nextSibling) : null;
|
|
54
|
-
function
|
|
57
|
+
function v(e) {
|
|
55
58
|
if (!c) return e;
|
|
56
59
|
const t = Object.entries(e).filter(([n]) => !["class", "style"].includes(n));
|
|
57
60
|
return Object.fromEntries(t);
|
|
58
61
|
}
|
|
59
|
-
function
|
|
62
|
+
function z(e) {
|
|
60
63
|
return c ? {
|
|
61
64
|
class: e.class,
|
|
62
65
|
style: e.style
|
|
63
66
|
} : {};
|
|
64
67
|
}
|
|
65
|
-
function
|
|
68
|
+
function B(e, t = 300) {
|
|
66
69
|
clearTimeout(s), s = setTimeout(e, t);
|
|
67
70
|
}
|
|
68
|
-
function
|
|
71
|
+
function H(e) {
|
|
69
72
|
const t = e.getBoundingClientRect(), n = {
|
|
70
73
|
top: t.top < 0,
|
|
71
74
|
left: t.left < 0,
|
|
@@ -74,26 +77,26 @@ function B(e) {
|
|
|
74
77
|
};
|
|
75
78
|
return n.any = Object.values(n).some((i) => i), n.all = Object.values(n).every((i) => i), n;
|
|
76
79
|
}
|
|
77
|
-
const
|
|
80
|
+
const M = /(?:(?:[^\s!@#$%^&*()_=+[\]{}\\|;:'",.<>/?]+)\.)/, V = new RegExp(
|
|
78
81
|
"(?:com|ru|org|net|de|jp|uk|br|it|pl|fr|in|au|ir|info|nl|cn|es|cz|kr|ca|eu|ua|co|gr|za|ro|biz|ch|se|tw|mx|vn|hu|be|tr|at|dk|tv|me|ar|sk|no|us|fi|id|cl|xyz|io|pt|by|il|ie|nz|kz|hk|lt|cc|my|sg|club|bg|edu|рф|pk|su|top|th|hr|rs|pe|pro|si|az|lv|pw|ae|ph|online|ng|ee|ws|ve|cat)"
|
|
79
|
-
),
|
|
82
|
+
), G = new RegExp(
|
|
80
83
|
"(?:(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])"
|
|
81
84
|
), f = new RegExp(
|
|
82
85
|
"(?:" + [
|
|
83
86
|
[
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
M.source,
|
|
88
|
+
V.source
|
|
86
89
|
].join("+"),
|
|
87
|
-
|
|
90
|
+
G.source
|
|
88
91
|
].join("|") + ")"
|
|
89
|
-
),
|
|
92
|
+
), Z = /(?:(?:[;/][^#?<>\s]*)?)/, d = /(?:(?:\?[^#<>\s]+)?(?:#[^<>\s]+)?)/, m = new RegExp(
|
|
90
93
|
"\\b" + [
|
|
91
94
|
f.source,
|
|
92
|
-
|
|
95
|
+
Z.source,
|
|
93
96
|
d.source,
|
|
94
97
|
"(?!\\w)"
|
|
95
98
|
].join("+")
|
|
96
|
-
),
|
|
99
|
+
), h = /\b[a-z\d.-]+:\/\/[^<>\s]+/, E = new RegExp(
|
|
97
100
|
"(?:mailto:)?[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@" + [
|
|
98
101
|
f.source,
|
|
99
102
|
d.source
|
|
@@ -113,8 +116,8 @@ function b(e = 7, t = 15) {
|
|
|
113
116
|
}
|
|
114
117
|
const p = b(), q = new RegExp(
|
|
115
118
|
[
|
|
116
|
-
h.source,
|
|
117
119
|
m.source,
|
|
120
|
+
h.source,
|
|
118
121
|
E.source,
|
|
119
122
|
p.source
|
|
120
123
|
].join("|"),
|
|
@@ -126,92 +129,94 @@ function K(e) {
|
|
|
126
129
|
}
|
|
127
130
|
function Q(e) {
|
|
128
131
|
var t, n;
|
|
129
|
-
return !e || typeof e != "string" ? !1 : ((t =
|
|
132
|
+
return !e || typeof e != "string" ? !1 : ((t = m.exec(e)) == null ? void 0 : t[0]) === e || ((n = h.exec(e)) == null ? void 0 : n[0]) === e;
|
|
130
133
|
}
|
|
131
134
|
function Y(e) {
|
|
132
135
|
var t;
|
|
133
136
|
return !e || typeof e != "string" ? !1 : ((t = E.exec(e)) == null ? void 0 : t[0]) === e;
|
|
134
137
|
}
|
|
135
|
-
function
|
|
138
|
+
function X(e) {
|
|
136
139
|
return e.filter((t) => !!t).join(", ");
|
|
137
140
|
}
|
|
138
|
-
function
|
|
141
|
+
function J(e, t = "en-US") {
|
|
139
142
|
return e.replace(new RegExp("^\\p{CWU}", "u"), (n) => n.toLocaleUpperCase(t));
|
|
140
143
|
}
|
|
141
|
-
function
|
|
144
|
+
function ue(e, t) {
|
|
142
145
|
typeof process > "u" || process.env.NODE_ENV === "test" && (!e || !(e instanceof HTMLElement) || !(document != null && document.body) || document.body.contains(e) || console.warn(`The ${t} component is not attached to the document body. This may cause issues.`));
|
|
143
146
|
}
|
|
144
147
|
function g(e = document.documentElement) {
|
|
145
148
|
return !!e.hasAttribute("data-overlayscrollbars");
|
|
146
149
|
}
|
|
147
|
-
function
|
|
150
|
+
function ee(e = document.documentElement) {
|
|
148
151
|
g(e) ? e.classList.add("d-scrollbar-disabled") : e.classList.add("d-of-hidden");
|
|
149
152
|
}
|
|
150
|
-
function
|
|
153
|
+
function te(e = document.documentElement) {
|
|
151
154
|
g(e) ? e.classList.remove("d-scrollbar-disabled") : e.classList.remove("d-of-hidden");
|
|
152
155
|
}
|
|
153
|
-
function
|
|
156
|
+
function le(e) {
|
|
154
157
|
return e.replaceAll(/[ -]/g, "_").replaceAll(/\W/g, "").toUpperCase();
|
|
155
158
|
}
|
|
156
|
-
const
|
|
159
|
+
const ae = {
|
|
157
160
|
getUniqueString: N,
|
|
158
161
|
getRandomElement: I,
|
|
159
162
|
getRandomInt: u,
|
|
160
|
-
formatMessages:
|
|
161
|
-
filterFormattedMessages:
|
|
163
|
+
formatMessages: j,
|
|
164
|
+
filterFormattedMessages: $,
|
|
162
165
|
hasFormattedMessageOfType: o,
|
|
163
166
|
getValidationState: l,
|
|
164
|
-
htmlFragment:
|
|
165
|
-
flushPromises:
|
|
167
|
+
htmlFragment: D,
|
|
168
|
+
flushPromises: F,
|
|
166
169
|
kebabCaseToPascalCase: W,
|
|
167
170
|
extractVueListeners: P,
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
extractNonListeners: k,
|
|
172
|
+
removeClassStyleAttrs: v,
|
|
173
|
+
addClassStyleAttrs: z,
|
|
170
174
|
returnFirstEl: a,
|
|
171
|
-
debounce:
|
|
172
|
-
isOutOfViewPort:
|
|
175
|
+
debounce: B,
|
|
176
|
+
isOutOfViewPort: H,
|
|
173
177
|
getPhoneNumberRegex: b,
|
|
174
178
|
linkRegex: q,
|
|
175
179
|
isEmailAddress: Y,
|
|
176
180
|
isPhoneNumber: K,
|
|
177
181
|
isURL: Q,
|
|
178
|
-
safeConcatStrings:
|
|
179
|
-
capitalizeFirstLetter:
|
|
180
|
-
disableRootScrolling:
|
|
181
|
-
enableRootScrolling:
|
|
182
|
+
safeConcatStrings: X,
|
|
183
|
+
capitalizeFirstLetter: J,
|
|
184
|
+
disableRootScrolling: ee,
|
|
185
|
+
enableRootScrolling: te
|
|
182
186
|
};
|
|
183
187
|
export {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
z as addClassStyleAttrs,
|
|
189
|
+
J as capitalizeFirstLetter,
|
|
190
|
+
B as debounce,
|
|
191
|
+
ae as default,
|
|
192
|
+
ee as disableRootScrolling,
|
|
193
|
+
te as enableRootScrolling,
|
|
194
|
+
k as extractNonListeners,
|
|
190
195
|
P as extractVueListeners,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
196
|
+
$ as filterFormattedMessages,
|
|
197
|
+
ie as findFirstFocusableNode,
|
|
198
|
+
F as flushPromises,
|
|
199
|
+
j as formatMessages,
|
|
195
200
|
b as getPhoneNumberRegex,
|
|
196
201
|
I as getRandomElement,
|
|
197
202
|
u as getRandomInt,
|
|
198
203
|
N as getUniqueString,
|
|
199
204
|
l as getValidationState,
|
|
200
205
|
o as hasFormattedMessageOfType,
|
|
201
|
-
|
|
202
|
-
|
|
206
|
+
se as hasSlotContent,
|
|
207
|
+
D as htmlFragment,
|
|
203
208
|
Y as isEmailAddress,
|
|
204
|
-
|
|
209
|
+
H as isOutOfViewPort,
|
|
205
210
|
K as isPhoneNumber,
|
|
206
211
|
Q as isURL,
|
|
207
212
|
U as javaHashCode,
|
|
208
213
|
W as kebabCaseToPascalCase,
|
|
209
214
|
q as linkRegex,
|
|
210
|
-
|
|
211
|
-
|
|
215
|
+
ce as pascalCaseToKebabCase,
|
|
216
|
+
v as removeClassStyleAttrs,
|
|
212
217
|
a as returnFirstEl,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
218
|
+
X as safeConcatStrings,
|
|
219
|
+
le as toFluentKeyString,
|
|
220
|
+
ue as warnIfUnmounted
|
|
216
221
|
};
|
|
217
222
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../common/utils/index.js"],"sourcesContent":["import {\n DEFAULT_PREFIX,\n DEFAULT_VALIDATION_MESSAGE_TYPE,\n VALIDATION_MESSAGE_TYPES,\n} from '../constants/index.js';\nimport {\n configVue2StyleClassAttrs,\n} from '../config';\nimport {\n h,\n Comment,\n Text,\n} from 'vue';\n\nlet UNIQUE_ID_COUNTER = 0;\nlet TIMER;\n\n// selector to find focusable not hidden inputs\nconst FOCUSABLE_SELECTOR_NOT_HIDDEN = 'input:not([type=hidden]):not(:disabled)';\n// selector to find focusable not disables elements\nconst FOCUSABLE_SELECTOR_NOT_DISABLED = 'select:not(:disabled),textarea:not(:disabled),button:not(:disabled)';\n// // selector to find focusable not hidden and disabled elements\nconst FOCUSABLE_SELECTOR_NOT_HIDDEN_DISABLED = `${FOCUSABLE_SELECTOR_NOT_HIDDEN},${FOCUSABLE_SELECTOR_NOT_DISABLED}`;\n// selector to find focusable elements\nconst FOCUSABLE_SELECTOR = `a,frame,iframe,${FOCUSABLE_SELECTOR_NOT_HIDDEN_DISABLED},*[tabindex]`;\n\nconst scheduler = typeof setImmediate === 'function' ? setImmediate : setTimeout;\n\nexport function getUniqueString (prefix = DEFAULT_PREFIX) {\n return `${prefix}${UNIQUE_ID_COUNTER++}`;\n}\n\n/**\n * Returns a random element from array\n * @param array - the array to return a random element from\n * @param {string} seed - use a string to seed the randomization, so it returns the same element each time\n * based on that string.\n * @returns {*} - the random element\n */\nexport function getRandomElement (array, seed) {\n if (seed) {\n const hash = javaHashCode(seed);\n return array[Math.abs(hash) % array.length];\n } else {\n return array[getRandomInt(array.length)];\n }\n}\n\n/**\n * Returns a hash code for a string.\n * (Compatible to Java's String.hashCode())\n * We use this algo to be in sync with android.\n *\n * The hash code for a string object is computed as\n * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]\n * using number arithmetic, where s[i] is the i th character\n * of the given string, n is the length of the string,\n * and ^ indicates exponentiation.\n * (The hash value of the empty string is zero.)\n *\n * @param {string} str a string\n * @return {number} a hash code value for the given string.\n */\nexport function javaHashCode (str) {\n let h;\n for (let i = 0; i < str.length; i++) {\n h = Math.imul(31, h) + str.charCodeAt(i) | 0;\n }\n\n return h;\n}\n\n/**\n * Generate a random integer\n * @param {number} max - max range of integer to generate\n * @returns {number} randomly generated integer between 0 and max\n */\nexport function getRandomInt (max) {\n return Math.floor(Math.random() * max);\n}\n\nexport function formatMessages (messages) {\n if (!messages) {\n return [];\n }\n\n return messages.map(message => {\n if (typeof message === 'string') {\n return {\n message,\n type: DEFAULT_VALIDATION_MESSAGE_TYPE,\n };\n }\n\n return message;\n });\n}\n\nexport function filterFormattedMessages (formattedMessages) {\n const validationState = getValidationState(formattedMessages);\n\n if (!formattedMessages || !validationState) {\n return [];\n }\n\n return formattedMessages.filter(message => !!message.message && message.type === validationState);\n}\n\n/*\n * The priority order of message types is as flows: 'error' > 'warning' > 'success'.\n * If any message of type 'error' is present in messages, the input state is considered\n * to be 'error', then 'warning' and lastly 'success'.\n */\nexport function getValidationState (formattedMessages) {\n if (!formattedMessages) {\n return null;\n }\n\n if (hasFormattedMessageOfType(formattedMessages, VALIDATION_MESSAGE_TYPES.ERROR)) {\n return VALIDATION_MESSAGE_TYPES.ERROR;\n }\n if (hasFormattedMessageOfType(formattedMessages, VALIDATION_MESSAGE_TYPES.WARNING)) {\n return VALIDATION_MESSAGE_TYPES.WARNING;\n }\n if (hasFormattedMessageOfType(formattedMessages, VALIDATION_MESSAGE_TYPES.SUCCESS)) {\n return VALIDATION_MESSAGE_TYPES.SUCCESS;\n }\n\n return null;\n}\n\nexport function hasFormattedMessageOfType (formattedMessages, messageType) {\n if (!formattedMessages || !messageType) {\n return false;\n }\n\n return formattedMessages.some(message => message?.type === messageType);\n}\n\nexport function findFirstFocusableNode (element) {\n return element?.querySelector(FOCUSABLE_SELECTOR);\n}\n\n/* html-fragment component:\n * To render html without wrapping in another element as when using v-html.\n * props: html\n */\nexport const htmlFragment = (props) => {\n return h('div', { innerHTML: props.html });\n};\n\nexport const flushPromises = () => {\n return new Promise((resolve) => {\n scheduler(resolve);\n });\n};\n\n/*\n It is very cumbersome to check if a slot is empty in vue 3. Copied this method from the following thread\n https://github.com/vuejs/core/issues/4733. There is an RFC to fix this but not yet being worked on.\n https://github.com/vuejs/rfcs/discussions/453\n*/\nexport function hasSlotContent (slot, slotProps = {}) {\n if (!slot) return false;\n\n // eslint-disable-next-line complexity\n return slot(slotProps).some((vnode) => {\n if (vnode.type === Comment) return false;\n\n if (Array.isArray(vnode.children) && !vnode.children.length) return false;\n\n return (\n vnode.type !== Text ||\n (typeof vnode.children === 'string' && vnode.children.trim() !== '')\n );\n });\n}\n\n/**\n * Transform a string from kebab-case to PascalCase\n * @param string\n * @returns {string}\n */\nexport const kebabCaseToPascalCase = (string) => {\n return string?.toLowerCase()\n .split('-')\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join('');\n};\n\n/**\n * Transform a string from PascalCase to kebab-case\n * @param string\n * @returns {string}\n */\nexport const pascalCaseToKebabCase = (string) => {\n return string\n .replace(/\\.?([A-Z0-9]+)/g, (x, y) => '-' + y.toLowerCase())\n .replace(/^-/, '');\n};\n\nexport const extractVueListeners = (attrs) => {\n const listeners = Object.entries(attrs)\n .filter(([key]) => key.match(/on[A-Z]/));\n return Object.fromEntries(listeners);\n};\n\n/**\n * $el works very differently than in vue 2, if the first node in the template is a text node\n * such as a comment it will return that instead of the first actual element. This function\n * will recursively return the first element in the template instead of the first node.\n * @param el\n * @returns {HTMLElement} The first element in the template\n */\nexport const returnFirstEl = (el) => {\n if (el?.nodeType === Node.ELEMENT_NODE) {\n return el;\n } else if (!el?.nodeType) {\n return null;\n } else {\n return returnFirstEl(el?.nextSibling);\n }\n};\n\n/**\n Only will apply changes if the config option configVue2StyleClassAttrs is set to true. It is false by default.\n\n Removes the class and style attributes from the $attrs. This is useful for vue 2 to vue 3 migration\n purposes so we don't cause breaking changes due to INSTANCE_ATTRS_CLASS_STYLE\n https://v3-migration.vuejs.org/breaking-changes/attrs-includes-class-style\n\n Remove the class and style attributes from the v-bind like so so v-bind=\"removeClassStyleAttrs($attrs)\",\n and then apply them to the root element manually via:\n\n :class=\"$attrs.class\"\n :style=\"$attrs.style\"\n*/\nexport function removeClassStyleAttrs (attrs) {\n if (!configVue2StyleClassAttrs) return attrs;\n const listeners = Object.entries(attrs)\n .filter(([key]) => !['class', 'style'].includes(key));\n return Object.fromEntries(listeners);\n}\n\n/**\n This should be applied to the root element on components using inheritAttrs: false.\n This will add the class and style attributes back to the root element if configVue2StyleClassAttrs\n is enabled.\n*/\nexport function addClassStyleAttrs (attrs) {\n if (!configVue2StyleClassAttrs) return {};\n return {\n class: attrs.class,\n style: attrs.style,\n };\n}\n\n/*\n* Set's a global timer to debounce the execution of a function.\n* @param { object } func - the function that is going to be called after timeout\n* @param { number } [timeout=300] timeout\n* */\nexport function debounce (func, timeout = 300) {\n clearTimeout(TIMER);\n TIMER = setTimeout(func, timeout);\n}\n\n/**\n * Checks if the element is out of the viewport\n * https://gomakethings.com/how-to-check-if-any-part-of-an-element-is-out-of-the-viewport-with-vanilla-js/\n * @param {HTMLElement} element The element to check\n * @return {Object} A set of booleans for each side of the element\n */\n\nexport function isOutOfViewPort (element) {\n const bounding = element.getBoundingClientRect();\n\n const isOut = {\n top: bounding.top < 0,\n left: bounding.left < 0,\n bottom: bounding.bottom > (window.innerHeight || document.documentElement.clientHeight),\n right: bounding.right > (window.innerWidth || document.documentElement.clientWidth),\n };\n isOut.any = Object.values(isOut).some(val => val);\n isOut.all = Object.values(isOut).every(val => val);\n return isOut;\n}\n\n// match valid characters for a domain name followed by a dot, e.g. \"dialpad.\"\nconst domainNameRegex = /(?:(?:[^\\s!@#$%^&*()_=+[\\]{}\\\\|;:'\",.<>/?]+)\\.)/;\n\n// match valid TLDs for a hostname (outdated list from ~2017)\nconst tldRegerx = new RegExp(\n '(?:' +\n 'com|ru|org|net|de|jp|uk|br|it|pl|fr|in|au|ir|info|nl|cn|es|cz|kr|ca|eu|ua|co|gr|' +\n 'za|ro|biz|ch|se|tw|mx|vn|hu|be|tr|at|dk|tv|me|ar|sk|no|us|fi|id|cl|xyz|io|pt|by|' +\n 'il|ie|nz|kz|hk|lt|cc|my|sg|club|bg|edu|рф|pk|su|top|th|hr|rs|pe|pro|si|az|lv|pw|' +\n 'ae|ph|online|ng|ee|ws|ve|cat' +\n ')',\n);\n\n// match valid IPv4 addresses, e.g. \"192.158.1.38\"\nconst ipv4Regex = new RegExp(\n '(?:(?:[0-9]|[1-9]\\\\d|1\\\\d{2}|2[0-4]\\\\d|25[0-5])\\\\.){3}' +\n '(?:[0-9]|[1-9]\\\\d|1\\\\d{2}|2[0-4]\\\\d|25[0-5])',\n);\n\n// match hostnames OR IPv4 addresses, e.g. \"dialpad.com\" or \"192.158.1.38\"\nconst hostnameOrIpRegex = new RegExp(\n '(?:' +\n [\n [\n domainNameRegex.source,\n tldRegerx.source,\n ].join('+'),\n ipv4Regex.source,\n ].join('|') +\n ')',\n);\n\n// match URL paths, e.g. \"/news\"\nconst urlPathRegex = /(?:(?:[;/][^#?<>\\s]*)?)/;\n\n// match URL queries and fragments, e.g. \"?cache=1&new=true\" or \"#heading1\"\nconst urlQueryOrFragmentRegex = /(?:(?:\\?[^#<>\\s]+)?(?:#[^<>\\s]+)?)/;\n\n// match complete hostnames or IPv4 addresses without a protocol and with optional\n// URL paths, queries and fragments e.g. \"dialpad.com/news?cache=1#heading1\"\nconst urlWithoutProtocolRegex = new RegExp(\n '\\\\b' +\n [\n hostnameOrIpRegex.source,\n urlPathRegex.source,\n urlQueryOrFragmentRegex.source,\n '(?!\\\\w)',\n ].join('+'),\n);\n\n// match complete hostnames with protocols and optional URL paths, queries and fragments,\n// e.g. \"ws://localhost:9011\" or \"https://dialpad.com/news?cache=1#heading1\"\nconst urlWithProtocolRegex = /\\b[a-z\\d.-]+:\\/\\/[^<>\\s]+/;\n\n// match email addresses with an optional \"mailto:\" prefix and URL queries, e.g.\n// \"hey@dialpad.com\" or \"mailto:hey@dialpad.com?subject=Hi&body=Hey%20there\"\nconst emailAddressRegex = new RegExp(\n '(?:mailto:)?' +\n '[a-z0-9!#$%&\\'*+/=?^_`{|}~-]+(?:\\\\.[a-z0-9!#$%&\\'*+/=?^_`{|}~-]+)*@' +\n [\n hostnameOrIpRegex.source,\n urlQueryOrFragmentRegex.source,\n ].join('+') +\n '(?!\\\\w)',\n);\n\n/**\n * Match phone numbers, e.g. \"765-8813\", \"(778) 765-8813\" or \"+17787658813\".\n * @param {number} minLength\n * @param {number} maxLength\n * @returns {RegExp}\n */\nexport function getPhoneNumberRegex (minLength = 7, maxLength = 15) {\n // Some older browser versions don't support lookbehind, so provide a RegExp\n // version without it. It fails just one test case, so IMO it's still good\n // enough to use. https://caniuse.com/js-regexp-lookbehind\n try {\n return new RegExp(\n '(?:^|(?<=\\\\W))' +\n '(?![\\\\s\\\\-])\\\\+?(?:[0-9()\\\\- \\\\t]' +\n `{${minLength},${maxLength}}` +\n ')(?=\\\\b)(?=\\\\W(?=\\\\W|$)|\\\\s|$)',\n );\n } catch {\n // eslint-disable-next-line no-console\n console.warn('This browser doesn\\'t support regex lookahead/lookbehind');\n }\n\n return new RegExp(\n '(?![\\\\s\\\\-])\\\\+?(?:[0-9()\\\\- \\\\t]' +\n `{${minLength},${maxLength}}` +\n ')(?=\\\\b)(?=\\\\W(?=\\\\W|$)|\\\\s|$)',\n );\n}\n\nconst phoneNumberRegex = getPhoneNumberRegex();\n\n// match all link types\nexport const linkRegex = new RegExp(\n [\n urlWithoutProtocolRegex.source,\n urlWithProtocolRegex.source,\n emailAddressRegex.source,\n phoneNumberRegex.source,\n ].join('|'),\n 'gi',\n);\n\n/**\n * Check if a string is a phone number. Validates only exact matches.\n * @param {string|number} input\n * @returns {boolean}\n */\nexport function isPhoneNumber (input) {\n if (!input || (!['string', 'number'].includes(typeof input))) return false;\n input = input.toString();\n return phoneNumberRegex.exec(input)?.[0] === input;\n}\n\n/**\n * Check if a string is an URL. Validates only exact matches.\n * @param {string} input\n * @returns {boolean}\n */\nexport function isURL (input) {\n if (!input || typeof input !== 'string') return false;\n return urlWithoutProtocolRegex.exec(input)?.[0] === input ||\n urlWithProtocolRegex.exec(input)?.[0] === input;\n}\n\n/**\n * Check if a string is an email address. Validates only exact matches.\n * @param {string} input\n * @returns {boolean}\n */\nexport function isEmailAddress (input) {\n if (!input || typeof input !== 'string') return false;\n return emailAddressRegex.exec(input)?.[0] === input;\n}\n\n/**\n * Concatenate a string removing null or undefined elements\n * avoiding parsing them as string with template strings\n * @param {Array} elements\n * @returns {String}\n */\nexport function safeConcatStrings (elements) {\n return elements.filter(str => !!str).join(', ');\n}\n\n/**\n * Locale safe function to capitalize the first letter of a string.\n * @param {string} str the string to capitalize the first letter of\n * @param {string} locale a string representing the locale to be used. Defaults to 'en-US'\n * @returns The passed in string with the first letter capitalized\n */\nexport function capitalizeFirstLetter (str, locale = 'en-US') {\n return str.replace(/^\\p{CWU}/u, char => char.toLocaleUpperCase(locale));\n}\n\n/**\n * Warns if the component is not mounted properly. Useful for tests.\n * @param {HTMLElement} componentRef - the component reference\n * @param {string} componentName - the component name\n */\n// eslint-disable-next-line complexity\nexport function warnIfUnmounted (componentRef, componentName) {\n if (typeof process === 'undefined') return;\n if (process.env.NODE_ENV !== 'test') return;\n if (!componentRef || !(componentRef instanceof HTMLElement) || !document?.body) return;\n if (!document.body.contains(componentRef)) {\n console.warn(`The ${componentName} component is not attached to the document body. This may cause issues.`);\n }\n}\n\n/**\n * checks whether the dt-scrollbar is being used on the root element.\n * @param rootElement {HTMLElement}\n * @returns {boolean}\n */\nfunction isDtScrollbarInUse (rootElement = document.documentElement) {\n if (rootElement.hasAttribute('data-overlayscrollbars')) {\n return true;\n }\n return false;\n}\n\n/**\n * This will disable scrolling on the root element regardless of whether you are using dt-scrollbar or not.\n * @param rootElement {HTMLElement}\n */\nexport function disableRootScrolling (rootElement = document.documentElement) {\n if (isDtScrollbarInUse(rootElement)) {\n rootElement.classList.add('d-scrollbar-disabled');\n } else {\n rootElement.classList.add('d-of-hidden');\n }\n}\n\n/**\n * This will enable scrolling on the root element regardless of whether you are using dt-scrollbar or not.\n * @param rootElement {HTMLElement}\n */\nexport function enableRootScrolling (rootElement = document.documentElement) {\n if (isDtScrollbarInUse(rootElement)) {\n rootElement.classList.remove('d-scrollbar-disabled');\n } else {\n rootElement.classList.remove('d-of-hidden');\n }\n}\n\n/**\n * This will take a text string e.g \"accessibility-mac\"\n * and convert it to our Fluent Key standard format \"ACCESSIBILITY_MAC\"\n * @param text\n * @returns {string}\n */\nexport function toFluentKeyString (text) {\n return text\n .replaceAll(/[ -]/g, '_')\n .replaceAll(/\\W/g, '')\n .toUpperCase();\n}\n\nexport default {\n getUniqueString,\n getRandomElement,\n getRandomInt,\n formatMessages,\n filterFormattedMessages,\n hasFormattedMessageOfType,\n getValidationState,\n htmlFragment,\n flushPromises,\n kebabCaseToPascalCase,\n extractVueListeners,\n removeClassStyleAttrs,\n addClassStyleAttrs,\n returnFirstEl,\n debounce,\n isOutOfViewPort,\n getPhoneNumberRegex,\n linkRegex,\n isEmailAddress,\n isPhoneNumber,\n isURL,\n safeConcatStrings,\n capitalizeFirstLetter,\n disableRootScrolling,\n enableRootScrolling,\n};\n"],"names":["UNIQUE_ID_COUNTER","TIMER","FOCUSABLE_SELECTOR_NOT_HIDDEN","FOCUSABLE_SELECTOR_NOT_DISABLED","FOCUSABLE_SELECTOR_NOT_HIDDEN_DISABLED","FOCUSABLE_SELECTOR","scheduler","getUniqueString","prefix","DEFAULT_PREFIX","getRandomElement","array","seed","hash","javaHashCode","getRandomInt","str","h","i","max","formatMessages","messages","message","DEFAULT_VALIDATION_MESSAGE_TYPE","filterFormattedMessages","formattedMessages","validationState","getValidationState","hasFormattedMessageOfType","VALIDATION_MESSAGE_TYPES","messageType","findFirstFocusableNode","element","htmlFragment","props","flushPromises","resolve","hasSlotContent","slot","slotProps","vnode","Comment","Text","kebabCaseToPascalCase","string","word","pascalCaseToKebabCase","x","y","extractVueListeners","attrs","listeners","key","returnFirstEl","el","removeClassStyleAttrs","configVue2StyleClassAttrs","addClassStyleAttrs","debounce","func","timeout","isOutOfViewPort","bounding","isOut","val","domainNameRegex","tldRegerx","ipv4Regex","hostnameOrIpRegex","urlPathRegex","urlQueryOrFragmentRegex","urlWithoutProtocolRegex","urlWithProtocolRegex","emailAddressRegex","getPhoneNumberRegex","minLength","maxLength","phoneNumberRegex","linkRegex","isPhoneNumber","input","_a","isURL","_b","isEmailAddress","safeConcatStrings","elements","capitalizeFirstLetter","locale","char","warnIfUnmounted","componentRef","componentName","isDtScrollbarInUse","rootElement","disableRootScrolling","enableRootScrolling","toFluentKeyString","text","utils"],"mappings":";;;AAcA,IAAIA,IAAoB,GACpBC;AAGJ,MAAMC,IAAgC,2CAEhCC,IAAkC,uEAElCC,IAAyC,GAAGF,CAA6B,IAAIC,CAA+B,IAE5GE,IAAqB,kBAAkBD,CAAsC,gBAE7EE,IAAY,OAAO,gBAAiB,aAAa,eAAe;AAE/D,SAASC,EAAiBC,IAASC,GAAgB;AACxD,SAAO,GAAGD,CAAM,GAAGR,GAAmB;AACxC;AASO,SAASU,EAAkBC,GAAOC,GAAM;AAC7C,MAAIA,GAAM;AACR,UAAMC,IAAOC,EAAaF,CAAI;AAC9B,WAAOD,EAAM,KAAK,IAAIE,CAAI,I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n DEFAULT_PREFIX,\n DEFAULT_VALIDATION_MESSAGE_TYPE,\n VALIDATION_MESSAGE_TYPES,\n} from '../constants/index.js';\nimport {\n configVue2StyleClassAttrs,\n} from '../config';\nimport {\n h,\n Comment,\n Text,\n} from 'vue';\n\nlet UNIQUE_ID_COUNTER = 0;\nlet TIMER;\n\n// selector to find focusable not hidden inputs\nconst FOCUSABLE_SELECTOR_NOT_HIDDEN = 'input:not([type=hidden]):not(:disabled)';\n// selector to find focusable not disables elements\nconst FOCUSABLE_SELECTOR_NOT_DISABLED = 'select:not(:disabled),textarea:not(:disabled),button:not(:disabled)';\n// // selector to find focusable not hidden and disabled elements\nconst FOCUSABLE_SELECTOR_NOT_HIDDEN_DISABLED = `${FOCUSABLE_SELECTOR_NOT_HIDDEN},${FOCUSABLE_SELECTOR_NOT_DISABLED}`;\n// selector to find focusable elements\nconst FOCUSABLE_SELECTOR = `a,frame,iframe,${FOCUSABLE_SELECTOR_NOT_HIDDEN_DISABLED},*[tabindex]`;\n\nconst scheduler = typeof setImmediate === 'function' ? setImmediate : setTimeout;\n\nexport function getUniqueString (prefix = DEFAULT_PREFIX) {\n return `${prefix}${UNIQUE_ID_COUNTER++}`;\n}\n\n/**\n * Returns a random element from array\n * @param array - the array to return a random element from\n * @param {string} seed - use a string to seed the randomization, so it returns the same element each time\n * based on that string.\n * @returns {*} - the random element\n */\nexport function getRandomElement (array, seed) {\n if (seed) {\n const hash = javaHashCode(seed);\n return array[Math.abs(hash) % array.length];\n } else {\n return array[getRandomInt(array.length)];\n }\n}\n\n/**\n * Returns a hash code for a string.\n * (Compatible to Java's String.hashCode())\n * We use this algo to be in sync with android.\n *\n * The hash code for a string object is computed as\n * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]\n * using number arithmetic, where s[i] is the i th character\n * of the given string, n is the length of the string,\n * and ^ indicates exponentiation.\n * (The hash value of the empty string is zero.)\n *\n * @param {string} str a string\n * @return {number} a hash code value for the given string.\n */\nexport function javaHashCode (str) {\n let h;\n for (let i = 0; i < str.length; i++) {\n h = Math.imul(31, h) + str.charCodeAt(i) | 0;\n }\n\n return h;\n}\n\n/**\n * Generate a random integer\n * @param {number} max - max range of integer to generate\n * @returns {number} randomly generated integer between 0 and max\n */\nexport function getRandomInt (max) {\n return Math.floor(Math.random() * max);\n}\n\nexport function formatMessages (messages) {\n if (!messages) {\n return [];\n }\n\n return messages.map(message => {\n if (typeof message === 'string') {\n return {\n message,\n type: DEFAULT_VALIDATION_MESSAGE_TYPE,\n };\n }\n\n return message;\n });\n}\n\nexport function filterFormattedMessages (formattedMessages) {\n const validationState = getValidationState(formattedMessages);\n\n if (!formattedMessages || !validationState) {\n return [];\n }\n\n return formattedMessages.filter(message => !!message.message && message.type === validationState);\n}\n\n/*\n * The priority order of message types is as flows: 'error' > 'warning' > 'success'.\n * If any message of type 'error' is present in messages, the input state is considered\n * to be 'error', then 'warning' and lastly 'success'.\n */\nexport function getValidationState (formattedMessages) {\n if (!formattedMessages) {\n return null;\n }\n\n if (hasFormattedMessageOfType(formattedMessages, VALIDATION_MESSAGE_TYPES.ERROR)) {\n return VALIDATION_MESSAGE_TYPES.ERROR;\n }\n if (hasFormattedMessageOfType(formattedMessages, VALIDATION_MESSAGE_TYPES.WARNING)) {\n return VALIDATION_MESSAGE_TYPES.WARNING;\n }\n if (hasFormattedMessageOfType(formattedMessages, VALIDATION_MESSAGE_TYPES.SUCCESS)) {\n return VALIDATION_MESSAGE_TYPES.SUCCESS;\n }\n\n return null;\n}\n\nexport function hasFormattedMessageOfType (formattedMessages, messageType) {\n if (!formattedMessages || !messageType) {\n return false;\n }\n\n return formattedMessages.some(message => message?.type === messageType);\n}\n\nexport function findFirstFocusableNode (element) {\n return element?.querySelector(FOCUSABLE_SELECTOR);\n}\n\n/* html-fragment component:\n * To render html without wrapping in another element as when using v-html.\n * props: html\n */\nexport const htmlFragment = (props) => {\n return h('div', { innerHTML: props.html });\n};\n\nexport const flushPromises = () => {\n return new Promise((resolve) => {\n scheduler(resolve);\n });\n};\n\n/*\n It is very cumbersome to check if a slot is empty in vue 3. Copied this method from the following thread\n https://github.com/vuejs/core/issues/4733. There is an RFC to fix this but not yet being worked on.\n https://github.com/vuejs/rfcs/discussions/453\n*/\nexport function hasSlotContent (slot, slotProps = {}) {\n if (!slot) return false;\n\n\n return slot(slotProps).some((vnode) => {\n if (vnode.type === Comment) return false;\n\n if (Array.isArray(vnode.children) && !vnode.children.length) return false;\n\n return (\n vnode.type !== Text ||\n (typeof vnode.children === 'string' && vnode.children.trim() !== '')\n );\n });\n}\n\n/**\n * Transform a string from kebab-case to PascalCase\n * @param string\n * @returns {string}\n */\nexport const kebabCaseToPascalCase = (string) => {\n return string?.toLowerCase()\n .split('-')\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join('');\n};\n\n/**\n * Transform a string from PascalCase to kebab-case\n * @param string\n * @returns {string}\n */\nexport const pascalCaseToKebabCase = (string) => {\n return string\n .replace(/\\.?([A-Z0-9]+)/g, (x, y) => '-' + y.toLowerCase())\n .replace(/^-/, '');\n};\n\n/**\n * Extracts Vue event listeners from attributes object\n * @param {Object} attrs - The attributes object to extract listeners from\n * @returns {Object} Object containing only Vue event listeners (keys matching on[A-Z])\n */\nexport const extractVueListeners = (attrs) => {\n const listeners = Object.entries(attrs)\n .filter(([key]) => key.match(/on[A-Z]/));\n return Object.fromEntries(listeners);\n};\n\n/**\n * Extracts non-listener attributes from attributes object\n * @param {Object} attrs - The attributes object to extract non-listeners from\n * @returns {Object} Object containing only non-listener attributes (keys not matching on[A-Z])\n */\nexport const extractNonListeners = (attrs) => {\n const nonListeners = Object.entries(attrs)\n .filter(([key]) => !key.match(/on[A-Z]/));\n return Object.fromEntries(nonListeners);\n};\n\n/**\n * $el works very differently than in vue 2, if the first node in the template is a text node\n * such as a comment it will return that instead of the first actual element. This function\n * will recursively return the first element in the template instead of the first node.\n * @param el\n * @returns {HTMLElement} The first element in the template\n */\nexport const returnFirstEl = (el) => {\n if (el?.nodeType === Node.ELEMENT_NODE) {\n return el;\n } else if (!el?.nodeType) {\n return null;\n } else {\n return returnFirstEl(el?.nextSibling);\n }\n};\n\n/**\n Only will apply changes if the config option configVue2StyleClassAttrs is set to true. It is false by default.\n\n Removes the class and style attributes from the $attrs. This is useful for vue 2 to vue 3 migration\n purposes so we don't cause breaking changes due to INSTANCE_ATTRS_CLASS_STYLE\n https://v3-migration.vuejs.org/breaking-changes/attrs-includes-class-style\n\n Remove the class and style attributes from the v-bind like so so v-bind=\"removeClassStyleAttrs($attrs)\",\n and then apply them to the root element manually via:\n\n :class=\"$attrs.class\"\n :style=\"$attrs.style\"\n*/\nexport function removeClassStyleAttrs (attrs) {\n if (!configVue2StyleClassAttrs) return attrs;\n const listeners = Object.entries(attrs)\n .filter(([key]) => !['class', 'style'].includes(key));\n return Object.fromEntries(listeners);\n}\n\n/**\n This should be applied to the root element on components using inheritAttrs: false.\n This will add the class and style attributes back to the root element if configVue2StyleClassAttrs\n is enabled.\n*/\nexport function addClassStyleAttrs (attrs) {\n if (!configVue2StyleClassAttrs) return {};\n return {\n class: attrs.class,\n style: attrs.style,\n };\n}\n\n/*\n* Set's a global timer to debounce the execution of a function.\n* @param { object } func - the function that is going to be called after timeout\n* @param { number } [timeout=300] timeout\n* */\nexport function debounce (func, timeout = 300) {\n clearTimeout(TIMER);\n TIMER = setTimeout(func, timeout);\n}\n\n/**\n * Checks if the element is out of the viewport\n * https://gomakethings.com/how-to-check-if-any-part-of-an-element-is-out-of-the-viewport-with-vanilla-js/\n * @param {HTMLElement} element The element to check\n * @return {Object} A set of booleans for each side of the element\n */\n\nexport function isOutOfViewPort (element) {\n const bounding = element.getBoundingClientRect();\n\n const isOut = {\n top: bounding.top < 0,\n left: bounding.left < 0,\n bottom: bounding.bottom > (window.innerHeight || document.documentElement.clientHeight),\n right: bounding.right > (window.innerWidth || document.documentElement.clientWidth),\n };\n isOut.any = Object.values(isOut).some(val => val);\n isOut.all = Object.values(isOut).every(val => val);\n return isOut;\n}\n\n// match valid characters for a domain name followed by a dot, e.g. \"dialpad.\"\nconst domainNameRegex = /(?:(?:[^\\s!@#$%^&*()_=+[\\]{}\\\\|;:'\",.<>/?]+)\\.)/;\n\n// match valid TLDs for a hostname (outdated list from ~2017)\nconst tldRegerx = new RegExp(\n '(?:' +\n 'com|ru|org|net|de|jp|uk|br|it|pl|fr|in|au|ir|info|nl|cn|es|cz|kr|ca|eu|ua|co|gr|' +\n 'za|ro|biz|ch|se|tw|mx|vn|hu|be|tr|at|dk|tv|me|ar|sk|no|us|fi|id|cl|xyz|io|pt|by|' +\n 'il|ie|nz|kz|hk|lt|cc|my|sg|club|bg|edu|рф|pk|su|top|th|hr|rs|pe|pro|si|az|lv|pw|' +\n 'ae|ph|online|ng|ee|ws|ve|cat' +\n ')',\n);\n\n// match valid IPv4 addresses, e.g. \"192.158.1.38\"\nconst ipv4Regex = new RegExp(\n '(?:(?:[0-9]|[1-9]\\\\d|1\\\\d{2}|2[0-4]\\\\d|25[0-5])\\\\.){3}' +\n '(?:[0-9]|[1-9]\\\\d|1\\\\d{2}|2[0-4]\\\\d|25[0-5])',\n);\n\n// match hostnames OR IPv4 addresses, e.g. \"dialpad.com\" or \"192.158.1.38\"\nconst hostnameOrIpRegex = new RegExp(\n '(?:' +\n [\n [\n domainNameRegex.source,\n tldRegerx.source,\n ].join('+'),\n ipv4Regex.source,\n ].join('|') +\n ')',\n);\n\n// match URL paths, e.g. \"/news\"\nconst urlPathRegex = /(?:(?:[;/][^#?<>\\s]*)?)/;\n\n// match URL queries and fragments, e.g. \"?cache=1&new=true\" or \"#heading1\"\nconst urlQueryOrFragmentRegex = /(?:(?:\\?[^#<>\\s]+)?(?:#[^<>\\s]+)?)/;\n\n// match complete hostnames or IPv4 addresses without a protocol and with optional\n// URL paths, queries and fragments e.g. \"dialpad.com/news?cache=1#heading1\"\nconst urlWithoutProtocolRegex = new RegExp(\n '\\\\b' +\n [\n hostnameOrIpRegex.source,\n urlPathRegex.source,\n urlQueryOrFragmentRegex.source,\n '(?!\\\\w)',\n ].join('+'),\n);\n\n// match complete hostnames with protocols and optional URL paths, queries and fragments,\n// e.g. \"ws://localhost:9011\" or \"https://dialpad.com/news?cache=1#heading1\"\nconst urlWithProtocolRegex = /\\b[a-z\\d.-]+:\\/\\/[^<>\\s]+/;\n\n// match email addresses with an optional \"mailto:\" prefix and URL queries, e.g.\n// \"hey@dialpad.com\" or \"mailto:hey@dialpad.com?subject=Hi&body=Hey%20there\"\nconst emailAddressRegex = new RegExp(\n '(?:mailto:)?' +\n '[a-z0-9!#$%&\\'*+/=?^_`{|}~-]+(?:\\\\.[a-z0-9!#$%&\\'*+/=?^_`{|}~-]+)*@' +\n [\n hostnameOrIpRegex.source,\n urlQueryOrFragmentRegex.source,\n ].join('+') +\n '(?!\\\\w)',\n);\n\n/**\n * Match phone numbers, e.g. \"765-8813\", \"(778) 765-8813\" or \"+17787658813\".\n * @param {number} minLength\n * @param {number} maxLength\n * @returns {RegExp}\n */\nexport function getPhoneNumberRegex (minLength = 7, maxLength = 15) {\n // Some older browser versions don't support lookbehind, so provide a RegExp\n // version without it. It fails just one test case, so IMO it's still good\n // enough to use. https://caniuse.com/js-regexp-lookbehind\n try {\n return new RegExp(\n '(?:^|(?<=\\\\W))' +\n '(?![\\\\s\\\\-])\\\\+?(?:[0-9()\\\\- \\\\t]' +\n `{${minLength},${maxLength}}` +\n ')(?=\\\\b)(?=\\\\W(?=\\\\W|$)|\\\\s|$)',\n );\n } catch {\n // eslint-disable-next-line no-console\n console.warn('This browser doesn\\'t support regex lookahead/lookbehind');\n }\n\n return new RegExp(\n '(?![\\\\s\\\\-])\\\\+?(?:[0-9()\\\\- \\\\t]' +\n `{${minLength},${maxLength}}` +\n ')(?=\\\\b)(?=\\\\W(?=\\\\W|$)|\\\\s|$)',\n );\n}\n\nconst phoneNumberRegex = getPhoneNumberRegex();\n\n// match all link types\nexport const linkRegex = new RegExp(\n [\n urlWithoutProtocolRegex.source,\n urlWithProtocolRegex.source,\n emailAddressRegex.source,\n phoneNumberRegex.source,\n ].join('|'),\n 'gi',\n);\n\n/**\n * Check if a string is a phone number. Validates only exact matches.\n * @param {string|number} input\n * @returns {boolean}\n */\nexport function isPhoneNumber (input) {\n if (!input || (!['string', 'number'].includes(typeof input))) return false;\n input = input.toString();\n return phoneNumberRegex.exec(input)?.[0] === input;\n}\n\n/**\n * Check if a string is an URL. Validates only exact matches.\n * @param {string} input\n * @returns {boolean}\n */\nexport function isURL (input) {\n if (!input || typeof input !== 'string') return false;\n return urlWithoutProtocolRegex.exec(input)?.[0] === input ||\n urlWithProtocolRegex.exec(input)?.[0] === input;\n}\n\n/**\n * Check if a string is an email address. Validates only exact matches.\n * @param {string} input\n * @returns {boolean}\n */\nexport function isEmailAddress (input) {\n if (!input || typeof input !== 'string') return false;\n return emailAddressRegex.exec(input)?.[0] === input;\n}\n\n/**\n * Concatenate a string removing null or undefined elements\n * avoiding parsing them as string with template strings\n * @param {Array} elements\n * @returns {String}\n */\nexport function safeConcatStrings (elements) {\n return elements.filter(str => !!str).join(', ');\n}\n\n/**\n * Locale safe function to capitalize the first letter of a string.\n * @param {string} str the string to capitalize the first letter of\n * @param {string} locale a string representing the locale to be used. Defaults to 'en-US'\n * @returns The passed in string with the first letter capitalized\n */\nexport function capitalizeFirstLetter (str, locale = 'en-US') {\n return str.replace(/^\\p{CWU}/u, char => char.toLocaleUpperCase(locale));\n}\n\n/**\n * Warns if the component is not mounted properly. Useful for tests.\n * @param {HTMLElement} componentRef - the component reference\n * @param {string} componentName - the component name\n */\n\nexport function warnIfUnmounted (componentRef, componentName) {\n if (typeof process === 'undefined') return;\n if (process.env.NODE_ENV !== 'test') return;\n if (!componentRef || !(componentRef instanceof HTMLElement) || !document?.body) return;\n if (!document.body.contains(componentRef)) {\n console.warn(`The ${componentName} component is not attached to the document body. This may cause issues.`);\n }\n}\n\n/**\n * checks whether the dt-scrollbar is being used on the root element.\n * @param rootElement {HTMLElement}\n * @returns {boolean}\n */\nfunction isDtScrollbarInUse (rootElement = document.documentElement) {\n if (rootElement.hasAttribute('data-overlayscrollbars')) {\n return true;\n }\n return false;\n}\n\n/**\n * This will disable scrolling on the root element regardless of whether you are using dt-scrollbar or not.\n * @param rootElement {HTMLElement}\n */\nexport function disableRootScrolling (rootElement = document.documentElement) {\n if (isDtScrollbarInUse(rootElement)) {\n rootElement.classList.add('d-scrollbar-disabled');\n } else {\n rootElement.classList.add('d-of-hidden');\n }\n}\n\n/**\n * This will enable scrolling on the root element regardless of whether you are using dt-scrollbar or not.\n * @param rootElement {HTMLElement}\n */\nexport function enableRootScrolling (rootElement = document.documentElement) {\n if (isDtScrollbarInUse(rootElement)) {\n rootElement.classList.remove('d-scrollbar-disabled');\n } else {\n rootElement.classList.remove('d-of-hidden');\n }\n}\n\n/**\n * This will take a text string e.g \"accessibility-mac\"\n * and convert it to our Fluent Key standard format \"ACCESSIBILITY_MAC\"\n * @param text\n * @returns {string}\n */\nexport function toFluentKeyString (text) {\n return text\n .replaceAll(/[ -]/g, '_')\n .replaceAll(/\\W/g, '')\n .toUpperCase();\n}\n\nexport default {\n getUniqueString,\n getRandomElement,\n getRandomInt,\n formatMessages,\n filterFormattedMessages,\n hasFormattedMessageOfType,\n getValidationState,\n htmlFragment,\n flushPromises,\n kebabCaseToPascalCase,\n extractVueListeners,\n extractNonListeners,\n removeClassStyleAttrs,\n addClassStyleAttrs,\n returnFirstEl,\n debounce,\n isOutOfViewPort,\n getPhoneNumberRegex,\n linkRegex,\n isEmailAddress,\n isPhoneNumber,\n isURL,\n safeConcatStrings,\n capitalizeFirstLetter,\n disableRootScrolling,\n enableRootScrolling,\n};\n"],"names":["UNIQUE_ID_COUNTER","TIMER","FOCUSABLE_SELECTOR_NOT_HIDDEN","FOCUSABLE_SELECTOR_NOT_DISABLED","FOCUSABLE_SELECTOR_NOT_HIDDEN_DISABLED","FOCUSABLE_SELECTOR","scheduler","getUniqueString","prefix","DEFAULT_PREFIX","getRandomElement","array","seed","hash","javaHashCode","getRandomInt","str","h","i","max","formatMessages","messages","message","DEFAULT_VALIDATION_MESSAGE_TYPE","filterFormattedMessages","formattedMessages","validationState","getValidationState","hasFormattedMessageOfType","VALIDATION_MESSAGE_TYPES","messageType","findFirstFocusableNode","element","htmlFragment","props","flushPromises","resolve","hasSlotContent","slot","slotProps","vnode","Comment","Text","kebabCaseToPascalCase","string","word","pascalCaseToKebabCase","x","y","extractVueListeners","attrs","listeners","key","extractNonListeners","nonListeners","returnFirstEl","el","removeClassStyleAttrs","configVue2StyleClassAttrs","addClassStyleAttrs","debounce","func","timeout","isOutOfViewPort","bounding","isOut","val","domainNameRegex","tldRegerx","ipv4Regex","hostnameOrIpRegex","urlPathRegex","urlQueryOrFragmentRegex","urlWithoutProtocolRegex","urlWithProtocolRegex","emailAddressRegex","getPhoneNumberRegex","minLength","maxLength","phoneNumberRegex","linkRegex","isPhoneNumber","input","_a","isURL","_b","isEmailAddress","safeConcatStrings","elements","capitalizeFirstLetter","locale","char","warnIfUnmounted","componentRef","componentName","isDtScrollbarInUse","rootElement","disableRootScrolling","enableRootScrolling","toFluentKeyString","text","utils"],"mappings":";;;AAcA,IAAIA,IAAoB,GACpBC;AAGJ,MAAMC,IAAgC,2CAEhCC,IAAkC,uEAElCC,IAAyC,GAAGF,CAA6B,IAAIC,CAA+B,IAE5GE,IAAqB,kBAAkBD,CAAsC,gBAE7EE,IAAY,OAAO,gBAAiB,aAAa,eAAe;AAE/D,SAASC,EAAiBC,IAASC,GAAgB;AACxD,SAAO,GAAGD,CAAM,GAAGR,GAAmB;AACxC;AASO,SAASU,EAAkBC,GAAOC,GAAM;AAC7C,MAAIA,GAAM;AACR,UAAMC,IAAOC,EAAaF,CAAI;AAC9B,WAAOD,EAAM,KAAK,IAAIE,CAAI,IAAIF,EAAM,MAAM;AAAA,EAC5C;AACE,WAAOA,EAAMI,EAAaJ,EAAM,MAAM,CAAC;AAE3C;AAiBO,SAASG,EAAcE,GAAK;AACjC,MAAIC;AACJ,WAASC,IAAI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-1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("../combobox-with-popover/combobox-with-popover.cjs"),b=require("../input/input.cjs"),C=require("../chip/chip.cjs"),y=require("../validation-messages/validation-messages.cjs"),x=require("../../common/validators/index.cjs"),p=require("../../common/utils/index.cjs"),I=require("../popover/popover-constants.cjs"),u=require("./combobox-multi-select-constants.cjs"),t=require("vue"),w=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),_={compatConfig:{MODE:3},name:"DtRecipeComboboxMultiSelect",components:{DtRecipeComboboxWithPopover:f.default,DtInput:b.default,DtChip:C.default,DtValidationMessages:y.default},props:{label:{type:String,required:!0},labelVisible:{type:Boolean,default:!0},description:{type:String,default:""},placeholder:{type:String,default:"Select one or start typing"},inputMessages:{type:Array,default:()=>[],validator:e=>x.validationMessageValidator(e)},showInputMessages:{type:Boolean,default:!0},loading:{type:Boolean,default:!1},loadingMessage:{type:String,default:"loading..."},showList:{type:Boolean,default:null},listMaxHeight:{type:String,default:"300px"},selectedItems:{type:Array,default:function(){return[]}},maxSelected:{type:Number,default:0},maxSelectedMessage:{type:Array,default:function(){return[]}},hasSuggestionList:{type:Boolean,default:!0},size:{type:String,default:"md",validator:e=>Object.values(u.MULTI_SELECT_SIZES).includes(e)},appendTo:{type:[HTMLElement,String],default:"body",validator:e=>I.POPOVER_APPEND_TO_VALUES.includes(e)||e instanceof HTMLElement},transition:{type:String,default:"fade"},collapseOnFocusOut:{type:Boolean,default:!1},listMaxWidth:{type:String,default:""},reservedRightSpace:{type:Number,default:64},chipMaxWidth:{type:String,default:""},inputClass:{type:[String,Object,Array],default:""},inputWrapperClass:{type:[String,Object,Array],default:""}},emits:["input","select","remove","max-selected","keyup","keydown","combobox-highlight"],data(){return{value:"",popoverOffset:[0,4],showValidationMessages:!1,resizeWindowObserver:null,initialInputHeight:null,CHIP_SIZES:u.CHIP_SIZES,hasSlotContent:p.hasSlotContent,inputFocused:!1,hideInputText:!1}},computed:{inputPlaceHolder(){var e;return((e=this.selectedItems)==null?void 0:e.length)>0?"":this.placeholder},chipListeners(){return{keydown:e=>{this.onChipKeyDown(e),this.$emit("keydown",e)}}},inputListeners(){return{input:e=>{this.$emit("input",e),this.hasSuggestionList&&this.showComboboxList()},keydown:e=>{this.onInputKeyDown(e)},keyup:e=>{this.$emit("keyup",e)},click:()=>{this.hasSuggestionList&&this.showComboboxList()}}},chipWrapperClass(){return{[`d-recipe-combobox-multi-select__chip-wrapper-${this.size}--collapsed`]:!this.inputFocused&&this.collapseOnFocusOut}}},watch:{selectedItems:{deep:!0,handler:async function(){this.initSelectedItems()}},chipMaxWidth:{async handler(){this.initSelectedItems()}},async label(){await this.$nextTick(),this.setChipsTopPosition()},async description(){await this.$nextTick(),this.setChipsTopPosition()},size:{async handler(){await this.$nextTick();const e=this.getInput();this.revertInputPadding(e),this.initialInputHeight=e.getBoundingClientRect().height,this.setInputPadding(),this.setChipsTopPosition()}}},mounted(){this.setInitialInputHeight(),this.resizeWindowObserver=new ResizeObserver(async()=>{this.setChipsTopPosition(),this.setInputPadding()}),this.resizeWindowObserver.observe(document.body),this.initSelectedItems()},beforeUnmount(){var e;(e=this.resizeWindowObserver)==null||e.unobserve(document.body)},methods:{comboboxHighlight(e){this.$emit("combobox-highlight",e)},async initSelectedItems(){await this.$nextTick(),this.setInputPadding(),this.setChipsTopPosition(),this.setInputMinWidth(),this.checkMaxSelected()},onChipRemove(e){var s;this.$emit("remove",e),(s=this.$refs.input)==null||s.focus()},onComboboxSelect(e){this.loading||(this.value="",this.$emit("select",e))},showComboboxList(){var e;this.showList==null&&((e=this.$refs.comboboxWithPopover)==null||e.showComboboxList())},closeComboboxList(){var e;this.showList==null&&((e=this.$refs.comboboxWithPopover)==null||e.closeComboboxList())},getChipButtons(){return this.$refs.chips&&this.$refs.chips.map(e=>p.returnFirstEl(e.$el).querySelector("button"))},getChips(){return this.$refs.chips&&this.$refs.chips.map(e=>p.returnFirstEl(e.$el))},getLastChipButton(){return this.$refs.chips&&this.getChipButtons()[this.getChipButtons().length-1]},getLastChip(){return this.$refs.chips&&this.getChips()[this.getChips().length-1]},getFirstChip(){return this.$refs.chips&&this.getChips()[0]},getInput(){var e;return(e=this.$refs.input)==null?void 0:e.$refs.input},onChipKeyDown(e){var i;const s=(i=e.code)==null?void 0:i.toLowerCase();s==="arrowleft"?this.navigateBetweenChips(e.target,!0):s==="arrowright"&&(e.target.id===this.getLastChipButton().id?this.moveFromChipToInput():this.navigateBetweenChips(e.target,!1))},onInputKeyDown(e){var i;const s=(i=e.code)==null?void 0:i.toLowerCase();if(this.selectedItems.length>0&&e.target.selectionStart===0){if(e.target.selectionEnd!==e.target.selectionStart)return;(s==="backspace"||s==="arrowleft")&&this.moveFromInputToChip()}},moveFromInputToChip(){var e;this.getLastChipButton().focus(),(e=this.$refs.input)==null||e.blur(),this.closeComboboxList()},moveFromChipToInput(){var e;this.getLastChipButton().blur(),(e=this.$refs.input)==null||e.focus(),this.showComboboxList()},navigateBetweenChips(e,s){var o;const i=this.getChipButtons().indexOf(e),r=s?i-1:i+1;r<0||r>=((o=this.$refs.chips)==null?void 0:o.length)||(this.getChipButtons()[i].blur(),this.getChipButtons()[r].focus(),this.closeComboboxList())},setChipsTopPosition(){const e=this.getInput();if(!e)return;const s=this.$refs.inputSlotWrapper,i=e.getBoundingClientRect().top-s.getBoundingClientRect().top,r=this.$refs.chipsWrapper;r.style.top=i-u.CHIP_TOP_POSITION[this.size]+"px"},setInputPadding(){const e=this.getLastChip(),s=this.getInput(),i=this.$refs.chipsWrapper;if(!s||(this.revertInputPadding(s),this.popoverOffset=[0,4],!e)||this.collapseOnFocusOut&&!this.inputFocused)return;const r=e.offsetLeft+this.getFullWidth(e),o=s.getBoundingClientRect().width-r;o>this.reservedRightSpace?s.style.paddingLeft=r+"px":s.style.paddingLeft="4px";const n=i.getBoundingClientRect().height-4,a=e.getBoundingClientRect().height-4,h=o>this.reservedRightSpace?e.offsetTop+2:n+a-9;s.style.paddingTop=`${h}px`},revertInputPadding(e){e.style.paddingLeft="",e.style.paddingTop="",e.style.paddingBottom=""},getFullWidth(e){const s=window.getComputedStyle(e);return e.offsetWidth+parseInt(s.marginLeft)+parseInt(s.marginRight)},setInputMinWidth(){const e=this.getFirstChip(),s=this.getInput();s&&(e?s.style.minWidth=this.getFullWidth(e)+4+"px":s.style.minWidth="")},checkMaxSelected(){this.maxSelected!==0&&(this.selectedItems.length>this.maxSelected?(this.showValidationMessages=!0,this.$emit("max-selected")):this.showValidationMessages=!1)},setInitialInputHeight(){const e=this.getInput();e&&(this.initialInputHeight=e.getBoundingClientRect().height)},async handleInputFocusIn(){this.inputFocused=!0,this.collapseOnFocusOut&&(this.hideInputText=!1,await this.$nextTick(),this.setInputPadding())},async handleInputFocusOut(){if(this.inputFocused=!1,this.collapseOnFocusOut){this.hideInputText=!0;const e=this.getInput();if(!e||!e.style.paddingTop)return;this.revertInputPadding(e)}}}},S={ref:"header"},v={key:1,class:"d-recipe-combobox-multi-select__list--loading"},L={ref:"footer"};function M(e,s,i,r,o,n){const a=t.resolveComponent("dt-chip"),h=t.resolveComponent("dt-input"),c=t.resolveComponent("dt-validation-messages"),d=t.resolveComponent("dt-recipe-combobox-with-popover");return t.openBlock(),t.createBlock(d,{ref:"comboboxWithPopover",label:i.label,"show-list":i.showList,"max-height":i.listMaxHeight,"max-width":i.listMaxWidth,"popover-offset":o.popoverOffset,"has-suggestion-list":i.hasSuggestionList,"content-width":"anchor","append-to":i.appendTo,transition:i.transition,onSelect:n.onComboboxSelect,onHighlight:n.comboboxHighlight},t.createSlots({input:t.withCtx(({onInput:g})=>[t.createElementVNode("span",{ref:"inputSlotWrapper",class:"d-recipe-combobox-multi-select__input-wrapper",onFocusin:s[1]||(s[1]=(...l)=>n.handleInputFocusIn&&n.handleInputFocusIn(...l)),onFocusout:s[2]||(s[2]=(...l)=>n.handleInputFocusOut&&n.handleInputFocusOut(...l))},[t.createElementVNode("span",{ref:"chipsWrapper",class:t.normalizeClass(["d-recipe-combobox-multi-select__chip-wrapper",n.chipWrapperClass])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.selectedItems,l=>(t.openBlock(),t.createBlock(a,t.mergeProps({ref_for:!0,ref:"chips",key:l,"label-class":["d-chip__label"],class:["d-recipe-combobox-multi-select__chip",{"d-recipe-combobox-multi-select__chip--truncate":!!i.chipMaxWidth}],style:{maxWidth:i.chipMaxWidth},size:o.CHIP_SIZES[i.size]},t.toHandlers(n.chipListeners),{onKeydown:t.withKeys(m=>n.onChipRemove(l),["backspace"]),onClose:m=>n.onChipRemove(l)}),{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(l),1)]),_:2},1040,["class","style","size","onKeydown","onClose"]))),128))],2),t.createVNode(h,t.mergeProps({ref:"input",modelValue:o.value,"onUpdate:modelValue":s[0]||(s[0]=l=>o.value=l),class:"d-recipe-combobox-multi-select__input","input-class":[i.inputClass,{"d-recipe-combobox-multi-select__input--hidden":o.hideInputText}],"input-wrapper-class":i.inputWrapperClass,"aria-label":i.label,label:i.labelVisible?i.label:"",description:i.description,placeholder:n.inputPlaceHolder,"show-messages":i.showInputMessages,messages:i.inputMessages,size:i.size},t.toHandlers(n.inputListeners),{onInput:g}),null,16,["modelValue","input-class","input-wrapper-class","aria-label","label","description","placeholder","show-messages","messages","size","onInput"]),t.createVNode(c,{"validation-messages":i.maxSelectedMessage,"show-messages":o.showValidationMessages},null,8,["validation-messages","show-messages"])],544)]),list:t.withCtx(()=>[t.createElementVNode("div",{ref:"list",class:"d-recipe-combobox-multi-select__list",onMousedown:s[3]||(s[3]=t.withModifiers(()=>{},["prevent"]))},[i.loading?(t.openBlock(),t.createElementBlock("div",v,t.toDisplayString(i.loadingMessage),1)):t.renderSlot(e.$slots,"list",{key:0})],544)]),_:2},[o.hasSlotContent(e.$slots.header)?{name:"header",fn:t.withCtx(()=>[t.createElementVNode("div",S,[t.renderSlot(e.$slots,"header")],512)]),key:"0"}:void 0,o.hasSlotContent(e.$slots.footer)?{name:"footer",fn:t.withCtx(()=>[t.createElementVNode("div",L,[t.renderSlot(e.$slots,"footer")],512)]),key:"1"}:void 0]),1032,["label","show-list","max-height","max-width","popover-offset","has-suggestion-list","append-to","transition","onSelect","onHighlight"])}const W=w._(_,[["render",M]]);exports.default=W;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("../combobox-with-popover/combobox-with-popover.cjs"),b=require("../input/input.cjs"),C=require("../chip/chip.cjs"),x=require("../validation-messages/validation-messages.cjs"),y=require("../../common/validators/index.cjs"),a=require("../../common/utils/index.cjs"),I=require("../popover/popover-constants.cjs"),p=require("./combobox-multi-select-constants.cjs"),t=require("vue"),w=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),_={compatConfig:{MODE:3},name:"DtRecipeComboboxMultiSelect",components:{DtRecipeComboboxWithPopover:f.default,DtInput:b.default,DtChip:C.default,DtValidationMessages:x.default},inheritAttrs:!1,props:{label:{type:String,required:!0},labelVisible:{type:Boolean,default:!0},description:{type:String,default:""},placeholder:{type:String,default:"Select one or start typing"},inputMessages:{type:Array,default:()=>[],validator:e=>y.validationMessageValidator(e)},showInputMessages:{type:Boolean,default:!0},loading:{type:Boolean,default:!1},loadingMessage:{type:String,default:"loading..."},showList:{type:Boolean,default:null},listMaxHeight:{type:String,default:"300px"},selectedItems:{type:Array,default:function(){return[]}},maxSelected:{type:Number,default:0},maxSelectedMessage:{type:Array,default:function(){return[]}},hasSuggestionList:{type:Boolean,default:!0},size:{type:String,default:"md",validator:e=>Object.values(p.MULTI_SELECT_SIZES).includes(e)},appendTo:{type:[HTMLElement,String],default:"body",validator:e=>I.POPOVER_APPEND_TO_VALUES.includes(e)||e instanceof HTMLElement},transition:{type:String,default:"fade"},collapseOnFocusOut:{type:Boolean,default:!1},listMaxWidth:{type:String,default:""},reservedRightSpace:{type:Number,default:64},chipMaxWidth:{type:String,default:""},inputClass:{type:[String,Object,Array],default:""},inputWrapperClass:{type:[String,Object,Array],default:""}},emits:["input","select","remove","max-selected","keyup","keydown","combobox-highlight"],data(){return{value:"",popoverOffset:[0,4],showValidationMessages:!1,resizeWindowObserver:null,initialInputHeight:null,CHIP_SIZES:p.CHIP_SIZES,hasSlotContent:a.hasSlotContent,inputFocused:!1,hideInputText:!1}},computed:{inputPlaceHolder(){var e;return((e=this.selectedItems)==null?void 0:e.length)>0?"":this.placeholder},chipListeners(){return{keydown:e=>{this.onChipKeyDown(e),this.$emit("keydown",e)}}},inputListeners(){return{...a.extractVueListeners(this.$attrs),onInput:e=>{this.$emit("input",e),this.hasSuggestionList&&this.showComboboxList()},onKeydown:e=>{this.onInputKeyDown(e)},onKeyup:e=>{this.$emit("keyup",e)},onClick:()=>{this.hasSuggestionList&&this.showComboboxList()}}},chipWrapperClass(){return{[`d-recipe-combobox-multi-select__chip-wrapper-${this.size}--collapsed`]:!this.inputFocused&&this.collapseOnFocusOut}}},watch:{selectedItems:{deep:!0,handler:async function(){this.initSelectedItems()}},chipMaxWidth:{async handler(){this.initSelectedItems()}},async label(){await this.$nextTick(),this.setChipsTopPosition()},async description(){await this.$nextTick(),this.setChipsTopPosition()},size:{async handler(){await this.$nextTick();const e=this.getInput();this.revertInputPadding(e),this.initialInputHeight=e.getBoundingClientRect().height,this.setInputPadding(),this.setChipsTopPosition()}}},mounted(){this.setInitialInputHeight(),this.resizeWindowObserver=new ResizeObserver(async()=>{this.setChipsTopPosition(),this.setInputPadding()}),this.resizeWindowObserver.observe(document.body),this.initSelectedItems()},beforeUnmount(){var e;(e=this.resizeWindowObserver)==null||e.unobserve(document.body)},methods:{extractNonListeners:a.extractNonListeners,comboboxHighlight(e){this.$emit("combobox-highlight",e)},async initSelectedItems(){await this.$nextTick(),this.setInputPadding(),this.setChipsTopPosition(),this.setInputMinWidth(),this.checkMaxSelected()},onChipRemove(e){var s;this.$emit("remove",e),(s=this.$refs.input)==null||s.focus()},onComboboxSelect(e){this.loading||(this.value="",this.$emit("select",e))},showComboboxList(){var e;this.showList==null&&((e=this.$refs.comboboxWithPopover)==null||e.showComboboxList())},closeComboboxList(){var e;this.showList==null&&((e=this.$refs.comboboxWithPopover)==null||e.closeComboboxList())},getChipButtons(){return this.$refs.chips&&this.$refs.chips.map(e=>a.returnFirstEl(e.$el).querySelector("button"))},getChips(){return this.$refs.chips&&this.$refs.chips.map(e=>a.returnFirstEl(e.$el))},getLastChipButton(){return this.$refs.chips&&this.getChipButtons()[this.getChipButtons().length-1]},getLastChip(){return this.$refs.chips&&this.getChips()[this.getChips().length-1]},getFirstChip(){return this.$refs.chips&&this.getChips()[0]},getInput(){var e;return(e=this.$refs.input)==null?void 0:e.$refs.input},onChipKeyDown(e){var i;const s=(i=e.code)==null?void 0:i.toLowerCase();s==="arrowleft"?this.navigateBetweenChips(e.target,!0):s==="arrowright"&&(e.target.id===this.getLastChipButton().id?this.moveFromChipToInput():this.navigateBetweenChips(e.target,!1))},onInputKeyDown(e){var i;const s=(i=e.code)==null?void 0:i.toLowerCase();if(this.selectedItems.length>0&&e.target.selectionStart===0){if(e.target.selectionEnd!==e.target.selectionStart)return;(s==="backspace"||s==="arrowleft")&&this.moveFromInputToChip()}},moveFromInputToChip(){var e;this.getLastChipButton().focus(),(e=this.$refs.input)==null||e.blur(),this.closeComboboxList()},moveFromChipToInput(){var e;this.getLastChipButton().blur(),(e=this.$refs.input)==null||e.focus(),this.showComboboxList()},navigateBetweenChips(e,s){var n;const i=this.getChipButtons().indexOf(e),r=s?i-1:i+1;r<0||r>=((n=this.$refs.chips)==null?void 0:n.length)||(this.getChipButtons()[i].blur(),this.getChipButtons()[r].focus(),this.closeComboboxList())},setChipsTopPosition(){const e=this.getInput();if(!e)return;const s=this.$refs.inputSlotWrapper,i=e.getBoundingClientRect().top-s.getBoundingClientRect().top,r=this.$refs.chipsWrapper;r.style.top=i-p.CHIP_TOP_POSITION[this.size]+"px"},setInputPadding(){const e=this.getLastChip(),s=this.getInput(),i=this.$refs.chipsWrapper;if(!s||(this.revertInputPadding(s),this.popoverOffset=[0,4],!e)||this.collapseOnFocusOut&&!this.inputFocused)return;const r=e.offsetLeft+this.getFullWidth(e),n=s.getBoundingClientRect().width-r;n>this.reservedRightSpace?s.style.paddingLeft=r+"px":s.style.paddingLeft="4px";const o=i.getBoundingClientRect().height-4,h=e.getBoundingClientRect().height-4,u=n>this.reservedRightSpace?e.offsetTop+2:o+h-9;s.style.paddingTop=`${u}px`},revertInputPadding(e){e.style.paddingLeft="",e.style.paddingTop="",e.style.paddingBottom=""},getFullWidth(e){const s=window.getComputedStyle(e);return e.offsetWidth+parseInt(s.marginLeft)+parseInt(s.marginRight)},setInputMinWidth(){const e=this.getFirstChip(),s=this.getInput();s&&(e?s.style.minWidth=this.getFullWidth(e)+4+"px":s.style.minWidth="")},checkMaxSelected(){this.maxSelected!==0&&(this.selectedItems.length>this.maxSelected?(this.showValidationMessages=!0,this.$emit("max-selected")):this.showValidationMessages=!1)},setInitialInputHeight(){const e=this.getInput();e&&(this.initialInputHeight=e.getBoundingClientRect().height)},async handleInputFocusIn(){this.inputFocused=!0,this.collapseOnFocusOut&&(this.hideInputText=!1,await this.$nextTick(),this.setInputPadding())},async handleInputFocusOut(){if(this.inputFocused=!1,this.collapseOnFocusOut){this.hideInputText=!0;const e=this.getInput();if(!e||!e.style.paddingTop)return;this.revertInputPadding(e)}}}},S={ref:"header"},v={key:1,class:"d-recipe-combobox-multi-select__list--loading"},L={ref:"footer"};function M(e,s,i,r,n,o){const h=t.resolveComponent("dt-chip"),u=t.resolveComponent("dt-input"),c=t.resolveComponent("dt-validation-messages"),d=t.resolveComponent("dt-recipe-combobox-with-popover");return t.openBlock(),t.createBlock(d,t.mergeProps({ref:"comboboxWithPopover",label:i.label,"show-list":i.showList,"max-height":i.listMaxHeight,"max-width":i.listMaxWidth,"popover-offset":n.popoverOffset,"has-suggestion-list":i.hasSuggestionList,"content-width":"anchor","append-to":i.appendTo,transition:i.transition},o.extractNonListeners(e.$attrs),{onSelect:o.onComboboxSelect,onHighlight:o.comboboxHighlight}),t.createSlots({input:t.withCtx(({onInput:g})=>[t.createElementVNode("span",{ref:"inputSlotWrapper",class:"d-recipe-combobox-multi-select__input-wrapper",onFocusin:s[1]||(s[1]=(...l)=>o.handleInputFocusIn&&o.handleInputFocusIn(...l)),onFocusout:s[2]||(s[2]=(...l)=>o.handleInputFocusOut&&o.handleInputFocusOut(...l))},[t.createElementVNode("span",{ref:"chipsWrapper",class:t.normalizeClass(["d-recipe-combobox-multi-select__chip-wrapper",o.chipWrapperClass])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.selectedItems,l=>(t.openBlock(),t.createBlock(h,t.mergeProps({ref_for:!0,ref:"chips",key:l,"label-class":["d-chip__label"],class:["d-recipe-combobox-multi-select__chip",{"d-recipe-combobox-multi-select__chip--truncate":!!i.chipMaxWidth}],style:{maxWidth:i.chipMaxWidth},size:n.CHIP_SIZES[i.size]},t.toHandlers(o.chipListeners),{onKeydown:t.withKeys(m=>o.onChipRemove(l),["backspace"]),onClose:m=>o.onChipRemove(l)}),{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(l),1)]),_:2},1040,["class","style","size","onKeydown","onClose"]))),128))],2),t.createVNode(u,t.mergeProps({ref:"input",modelValue:n.value,"onUpdate:modelValue":s[0]||(s[0]=l=>n.value=l),class:"d-recipe-combobox-multi-select__input","input-class":[i.inputClass,{"d-recipe-combobox-multi-select__input--hidden":n.hideInputText}],"input-wrapper-class":i.inputWrapperClass,"aria-label":i.label,label:i.labelVisible?i.label:"",description:i.description,placeholder:o.inputPlaceHolder,"show-messages":i.showInputMessages,messages:i.inputMessages,size:i.size},o.inputListeners,{onInput:g}),null,16,["modelValue","input-class","input-wrapper-class","aria-label","label","description","placeholder","show-messages","messages","size","onInput"]),t.createVNode(c,{"validation-messages":i.maxSelectedMessage,"show-messages":n.showValidationMessages},null,8,["validation-messages","show-messages"])],544)]),list:t.withCtx(()=>[t.createElementVNode("div",{ref:"list",class:"d-recipe-combobox-multi-select__list",onMousedown:s[3]||(s[3]=t.withModifiers(()=>{},["prevent"]))},[i.loading?(t.openBlock(),t.createElementBlock("div",v,t.toDisplayString(i.loadingMessage),1)):t.renderSlot(e.$slots,"list",{key:0})],544)]),_:2},[n.hasSlotContent(e.$slots.header)?{name:"header",fn:t.withCtx(()=>[t.createElementVNode("div",S,[t.renderSlot(e.$slots,"header")],512)]),key:"0"}:void 0,n.hasSlotContent(e.$slots.footer)?{name:"footer",fn:t.withCtx(()=>[t.createElementVNode("div",L,[t.renderSlot(e.$slots,"footer")],512)]),key:"1"}:void 0]),1040,["label","show-list","max-height","max-width","popover-offset","has-suggestion-list","append-to","transition","onSelect","onHighlight"])}const W=w._(_,[["render",M]]);exports.default=W;
|
|
2
2
|
//# sourceMappingURL=combobox-multi-select.cjs.map
|