@dialpad/dialtone 9.77.0 → 9.79.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/dialtone-default-theme.css +795 -810
- package/dist/css/dialtone-default-theme.min.css +1 -1
- package/dist/css/tokens/tokens-base-dark.css +0 -5
- package/dist/css/tokens/tokens-base-light.css +0 -5
- package/dist/css/tokens/tokens-dp-dark.css +795 -805
- package/dist/css/tokens/tokens-dp-light.css +795 -805
- package/dist/css/tokens/tokens-expressive-dark.css +795 -805
- package/dist/css/tokens/tokens-expressive-light.css +795 -805
- package/dist/css/tokens/tokens-expressive-sm-dark.css +795 -805
- package/dist/css/tokens/tokens-expressive-sm-light.css +795 -805
- package/dist/css/tokens/tokens-tmo-dark.css +780 -790
- package/dist/css/tokens/tokens-tmo-light.css +780 -790
- package/dist/tokens/css/tokens-base-dark.css +0 -5
- package/dist/tokens/css/tokens-base-light.css +0 -5
- package/dist/tokens/css/tokens-dp-dark.css +795 -805
- package/dist/tokens/css/tokens-dp-light.css +795 -805
- package/dist/tokens/css/tokens-expressive-dark.css +795 -805
- package/dist/tokens/css/tokens-expressive-light.css +795 -805
- package/dist/tokens/css/tokens-expressive-sm-dark.css +795 -805
- package/dist/tokens/css/tokens-expressive-sm-light.css +795 -805
- package/dist/tokens/css/tokens-tmo-dark.css +780 -790
- package/dist/tokens/css/tokens-tmo-light.css +780 -790
- package/dist/tokens/doc.json +14103 -14103
- package/dist/tokens/themes/chunks/{tokens-base-dark-D9QWQ06G.js → tokens-base-dark-DPDbA0Im.js} +1 -1
- package/dist/tokens/themes/chunks/{tokens-base-dark-BspLyPe6.js → tokens-base-dark-OGkvNn32.js} +1 -1
- package/dist/tokens/themes/chunks/{tokens-base-light-CCF-uj56.js → tokens-base-light-C0l67sjm.js} +1 -1
- package/dist/tokens/themes/chunks/{tokens-base-light-B2jKQq80.js → tokens-base-light-nNZ2WKLp.js} +2 -2
- package/dist/tokens/themes/dp-dark.cjs +1 -1
- package/dist/tokens/themes/dp-dark.js +2 -2
- package/dist/tokens/themes/dp-light.cjs +1 -1
- package/dist/tokens/themes/dp-light.js +2 -2
- package/dist/tokens/themes/expressive-dark.cjs +1 -1
- package/dist/tokens/themes/expressive-dark.js +3 -3
- package/dist/tokens/themes/expressive-light.cjs +1 -1
- package/dist/tokens/themes/expressive-light.js +3 -3
- package/dist/tokens/themes/expressive-sm-dark.cjs +1 -1
- package/dist/tokens/themes/expressive-sm-dark.js +3 -3
- package/dist/tokens/themes/expressive-sm-light.cjs +1 -1
- package/dist/tokens/themes/expressive-sm-light.js +3 -3
- package/dist/tokens/themes/tmo-dark.cjs +1 -1
- package/dist/tokens/themes/tmo-dark.js +3 -3
- package/dist/tokens/themes/tmo-light.cjs +1 -1
- package/dist/tokens/themes/tmo-light.js +3 -3
- package/dist/tokens/types/postcss/constants.d.cts +1 -0
- package/dist/vue2/common/utils.cjs +7 -0
- package/dist/vue2/common/utils.cjs.map +1 -1
- package/dist/vue2/common/utils.js +8 -1
- package/dist/vue2/common/utils.js.map +1 -1
- package/dist/vue2/components/datepicker/datepicker.vue.cjs +4 -0
- package/dist/vue2/components/datepicker/datepicker.vue.cjs.map +1 -1
- package/dist/vue2/components/datepicker/datepicker.vue.js +4 -0
- package/dist/vue2/components/datepicker/datepicker.vue.js.map +1 -1
- package/dist/vue2/components/emoji_picker/modules/emoji_selector.vue.cjs +3 -3
- package/dist/vue2/components/emoji_picker/modules/emoji_selector.vue.cjs.map +1 -1
- package/dist/vue2/components/emoji_picker/modules/emoji_selector.vue.js +3 -3
- package/dist/vue2/components/emoji_picker/modules/emoji_selector.vue.js.map +1 -1
- package/dist/vue2/components/popover/popover.vue.cjs +1 -0
- package/dist/vue2/components/popover/popover.vue.cjs.map +1 -1
- package/dist/vue2/components/popover/popover.vue.js +2 -1
- package/dist/vue2/components/popover/popover.vue.js.map +1 -1
- package/dist/vue2/components/rich_text_editor/extensions/emoji/suggestion.cjs +10 -9
- package/dist/vue2/components/rich_text_editor/extensions/emoji/suggestion.cjs.map +1 -1
- package/dist/vue2/components/rich_text_editor/extensions/emoji/suggestion.js +10 -9
- package/dist/vue2/components/rich_text_editor/extensions/emoji/suggestion.js.map +1 -1
- package/dist/vue2/components/rich_text_editor/rich_text_editor.vue.cjs +20 -9
- package/dist/vue2/components/rich_text_editor/rich_text_editor.vue.cjs.map +1 -1
- package/dist/vue2/components/rich_text_editor/rich_text_editor.vue.js +20 -9
- package/dist/vue2/components/rich_text_editor/rich_text_editor.vue.js.map +1 -1
- package/dist/vue2/components/split_button/split_button.vue.cjs +4 -0
- package/dist/vue2/components/split_button/split_button.vue.cjs.map +1 -1
- package/dist/vue2/components/split_button/split_button.vue.js +4 -0
- package/dist/vue2/components/split_button/split_button.vue.js.map +1 -1
- package/dist/vue2/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.cjs +3 -0
- package/dist/vue2/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.cjs.map +1 -1
- package/dist/vue2/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.js +4 -1
- package/dist/vue2/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.js.map +1 -1
- package/dist/vue2/types/common/utils/index.d.ts +1 -0
- package/dist/vue2/types/common/utils/index.d.ts.map +1 -1
- package/dist/vue2/types/components/dropdown/dropdown.vue.d.ts +4 -4
- package/dist/vue2/types/components/emoji_picker/modules/emoji_selector.vue.d.ts +1 -0
- package/dist/vue2/types/components/modal/modal.vue.d.ts +4 -4
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts +1 -0
- package/dist/vue2/types/components/tooltip/tooltip.vue.d.ts +4 -4
- package/dist/vue2/types/recipes/comboboxes/combobox_with_popover/combobox_with_popover.vue.d.ts +4 -4
- package/dist/vue3/common/utils.cjs +7 -0
- package/dist/vue3/common/utils.cjs.map +1 -1
- package/dist/vue3/common/utils.js +8 -1
- package/dist/vue3/common/utils.js.map +1 -1
- package/dist/vue3/components/datepicker/datepicker.vue.cjs +5 -0
- package/dist/vue3/components/datepicker/datepicker.vue.cjs.map +1 -1
- package/dist/vue3/components/datepicker/datepicker.vue.js +6 -1
- package/dist/vue3/components/datepicker/datepicker.vue.js.map +1 -1
- package/dist/vue3/components/popover/popover.vue.cjs +1 -0
- package/dist/vue3/components/popover/popover.vue.cjs.map +1 -1
- package/dist/vue3/components/popover/popover.vue.js +2 -1
- package/dist/vue3/components/popover/popover.vue.js.map +1 -1
- package/dist/vue3/components/rich_text_editor/extensions/emoji/suggestion.cjs +10 -9
- package/dist/vue3/components/rich_text_editor/extensions/emoji/suggestion.cjs.map +1 -1
- package/dist/vue3/components/rich_text_editor/extensions/emoji/suggestion.js +10 -9
- package/dist/vue3/components/rich_text_editor/extensions/emoji/suggestion.js.map +1 -1
- package/dist/vue3/components/rich_text_editor/rich_text_editor.vue.cjs +20 -9
- package/dist/vue3/components/rich_text_editor/rich_text_editor.vue.cjs.map +1 -1
- package/dist/vue3/components/rich_text_editor/rich_text_editor.vue.js +20 -9
- package/dist/vue3/components/rich_text_editor/rich_text_editor.vue.js.map +1 -1
- package/dist/vue3/components/split_button/split_button.vue.cjs +3 -0
- package/dist/vue3/components/split_button/split_button.vue.cjs.map +1 -1
- package/dist/vue3/components/split_button/split_button.vue.js +4 -1
- package/dist/vue3/components/split_button/split_button.vue.js.map +1 -1
- package/dist/vue3/components/tooltip/tooltip.vue.cjs +1 -0
- package/dist/vue3/components/tooltip/tooltip.vue.cjs.map +1 -1
- package/dist/vue3/components/tooltip/tooltip.vue.js +2 -1
- package/dist/vue3/components/tooltip/tooltip.vue.js.map +1 -1
- package/dist/vue3/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.cjs +3 -0
- package/dist/vue3/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.cjs.map +1 -1
- package/dist/vue3/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.js +4 -1
- package/dist/vue3/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.js.map +1 -1
- package/dist/vue3/types/common/utils/index.d.ts +1 -0
- package/dist/vue3/types/common/utils/index.d.ts.map +1 -1
- package/dist/vue3/types/components/dropdown/dropdown.vue.d.ts +5 -5
- package/dist/vue3/types/components/keyboard_shortcut/keyboard_shortcut.vue.d.ts +7 -210
- package/dist/vue3/types/components/lazy_show/lazy_show.vue.d.ts +1 -1
- package/dist/vue3/types/components/modal/modal.vue.d.ts +4 -4
- package/dist/vue3/types/components/notice/notice_icon.vue.d.ts +1 -30
- package/dist/vue3/types/components/notice/notice_icon.vue.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts +1 -0
- package/dist/vue3/types/components/tooltip/tooltip.vue.d.ts +5 -5
- package/dist/vue3/types/components/tooltip/tooltip.vue.d.ts.map +1 -1
- package/dist/vue3/types/recipes/cards/ivr_node/ivr_node.vue.d.ts +1 -30
- package/dist/vue3/types/recipes/comboboxes/combobox_with_popover/combobox_with_popover.vue.d.ts +5 -5
- package/dist/vue3/types/recipes/conversation_view/editor/editor.vue.d.ts +8 -240
- package/dist/vue3/types/recipes/conversation_view/feed_pill/feed_item_pill.vue.d.ts +1 -30
- package/dist/vue3/types/recipes/leftbar/general_row/leftbar_general_row_icon.vue.d.ts +1 -30
- package/package.json +4 -20
package/dist/vue2/types/recipes/comboboxes/combobox_with_popover/combobox_with_popover.vue.d.ts
CHANGED
|
@@ -83,10 +83,10 @@ declare const _default: import('vue').DefineComponent<{
|
|
|
83
83
|
default: string;
|
|
84
84
|
};
|
|
85
85
|
appendTo: {
|
|
86
|
-
type: (
|
|
86
|
+
type: ({
|
|
87
87
|
new (): HTMLElement;
|
|
88
88
|
prototype: HTMLElement;
|
|
89
|
-
})[];
|
|
89
|
+
} | StringConstructor)[];
|
|
90
90
|
default: string;
|
|
91
91
|
validator: (appendTo: unknown) => boolean;
|
|
92
92
|
};
|
|
@@ -230,10 +230,10 @@ declare const _default: import('vue').DefineComponent<{
|
|
|
230
230
|
default: string;
|
|
231
231
|
};
|
|
232
232
|
appendTo: {
|
|
233
|
-
type: (
|
|
233
|
+
type: ({
|
|
234
234
|
new (): HTMLElement;
|
|
235
235
|
prototype: HTMLElement;
|
|
236
|
-
})[];
|
|
236
|
+
} | StringConstructor)[];
|
|
237
237
|
default: string;
|
|
238
238
|
validator: (appendTo: unknown) => boolean;
|
|
239
239
|
};
|
|
@@ -194,6 +194,12 @@ function safeConcatStrings(elements) {
|
|
|
194
194
|
function capitalizeFirstLetter(str, locale = "en-US") {
|
|
195
195
|
return str.replace(new RegExp("^\\p{CWU}", "u"), (char) => char.toLocaleUpperCase(locale));
|
|
196
196
|
}
|
|
197
|
+
function warnIfUnmounted(componentRef, componentName) {
|
|
198
|
+
if (!componentRef || !(componentRef instanceof HTMLElement) || !(document == null ? void 0 : document.body)) return;
|
|
199
|
+
if (!document.body.contains(componentRef)) {
|
|
200
|
+
console.warn(`The ${componentName} component is not attached to the document body. This may cause issues.`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
197
203
|
const utils = {
|
|
198
204
|
getUniqueString,
|
|
199
205
|
getRandomElement,
|
|
@@ -241,4 +247,5 @@ exports.kebabCaseToPascalCase = kebabCaseToPascalCase;
|
|
|
241
247
|
exports.linkRegex = linkRegex;
|
|
242
248
|
exports.pascalCaseToKebabCase = pascalCaseToKebabCase;
|
|
243
249
|
exports.safeConcatStrings = safeConcatStrings;
|
|
250
|
+
exports.warnIfUnmounted = warnIfUnmounted;
|
|
244
251
|
//# sourceMappingURL=utils.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../../common/utils/index.js"],"sourcesContent":["import {\n DEFAULT_PREFIX,\n DEFAULT_VALIDATION_MESSAGE_TYPE,\n VALIDATION_MESSAGE_TYPES,\n} from '../constants';\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.startsWith('on'));\n return Object.fromEntries(listeners);\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 (e) {\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\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 debounce,\n isOutOfViewPort,\n getPhoneNumberRegex,\n linkRegex,\n isEmailAddress,\n isPhoneNumber,\n isURL,\n safeConcatStrings,\n capitalizeFirstLetter,\n};\n"],"names":["DEFAULT_PREFIX","DEFAULT_VALIDATION_MESSAGE_TYPE","VALIDATION_MESSAGE_TYPES","h","Comment","Text"],"mappings":";;;;AAWA,IAAI,oBAAoB;AACxB,I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AG,EAAE,KAAK,GAAG;AAC/C;AAQO,SAAS,sBAAuB,KAAK,SAAS,SAAS;AAC5D,SAAO,IAAI,QAAQ,2BAAW,GAAE,UAAQ,KAAK,kBAAkB,MAAM,CAAC;AACxE;AAEA,MAAe,QAAA;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"utils.cjs","sources":["../../common/utils/index.js"],"sourcesContent":["import {\n DEFAULT_PREFIX,\n DEFAULT_VALIDATION_MESSAGE_TYPE,\n VALIDATION_MESSAGE_TYPES,\n} from '../constants';\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.startsWith('on'));\n return Object.fromEntries(listeners);\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 (e) {\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 */\nexport function warnIfUnmounted (componentRef, componentName) {\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\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 debounce,\n isOutOfViewPort,\n getPhoneNumberRegex,\n linkRegex,\n isEmailAddress,\n isPhoneNumber,\n isURL,\n safeConcatStrings,\n capitalizeFirstLetter,\n};\n"],"names":["DEFAULT_PREFIX","DEFAULT_VALIDATION_MESSAGE_TYPE","VALIDATION_MESSAGE_TYPES","h","Comment","Text"],"mappings":";;;;AAWA,IAAI,oBAAoB;AACxB,IAAI;AAGJ,MAAM,gCAAgC;AAEtC,MAAM,kCAAkC;AAExC,MAAM,yCAAyC,GAAG,6BAA6B,IAAI,+BAA+B;AAElH,MAAM,qBAAqB,kBAAkB,sCAAsC;AAEnF,MAAM,YAAY,OAAO,iBAAiB,aAAa,eAAe;AAE/D,SAAS,gBAAiB,SAASA,iCAAgB;AACxD,SAAO,GAAG,MAAM,GAAG,mBAAmB;AACxC;AASO,SAAS,iBAAkB,OAAO,MAAM;AAC7C,MAAI,MAAM;AACR,UAAM,OAAO,aAAa,IAAI;AAC9B,WAAO,MAAM,KAAK,IAAI,IAAI,IAAI,MAAM,MAAM;AAAA,EAC9C,OAAS;AACL,WAAO,MAAM,aAAa,MAAM,MAAM,CAAC;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ACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -192,6 +192,12 @@ function safeConcatStrings(elements) {
|
|
|
192
192
|
function capitalizeFirstLetter(str, locale = "en-US") {
|
|
193
193
|
return str.replace(new RegExp("^\\p{CWU}", "u"), (char) => char.toLocaleUpperCase(locale));
|
|
194
194
|
}
|
|
195
|
+
function warnIfUnmounted(componentRef, componentName) {
|
|
196
|
+
if (!componentRef || !(componentRef instanceof HTMLElement) || !(document == null ? void 0 : document.body)) return;
|
|
197
|
+
if (!document.body.contains(componentRef)) {
|
|
198
|
+
console.warn(`The ${componentName} component is not attached to the document body. This may cause issues.`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
195
201
|
const utils = {
|
|
196
202
|
getUniqueString,
|
|
197
203
|
getRandomElement,
|
|
@@ -239,6 +245,7 @@ export {
|
|
|
239
245
|
kebabCaseToPascalCase,
|
|
240
246
|
linkRegex,
|
|
241
247
|
pascalCaseToKebabCase,
|
|
242
|
-
safeConcatStrings
|
|
248
|
+
safeConcatStrings,
|
|
249
|
+
warnIfUnmounted
|
|
243
250
|
};
|
|
244
251
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../common/utils/index.js"],"sourcesContent":["import {\n DEFAULT_PREFIX,\n DEFAULT_VALIDATION_MESSAGE_TYPE,\n VALIDATION_MESSAGE_TYPES,\n} from '../constants';\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.startsWith('on'));\n return Object.fromEntries(listeners);\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 (e) {\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\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 debounce,\n isOutOfViewPort,\n getPhoneNumberRegex,\n linkRegex,\n isEmailAddress,\n isPhoneNumber,\n isURL,\n safeConcatStrings,\n capitalizeFirstLetter,\n};\n"],"names":["h"],"mappings":";;AAWA,IAAI,oBAAoB;AACxB,IAAI;AAGJ,MAAM,gCAAgC;AAEtC,MAAM,kCAAkC;AAExC,MAAM,yCAAyC,GAAG,6BAA6B,IAAI,+BAA+B;AAElH,MAAM,qBAAqB,kBAAkB,sCAAsC;AAEnF,MAAM,YAAY,OAAO,iBAAiB,aAAa,eAAe;AAE/D,SAAS,gBAAiB,SAAS,gBAAgB;AACxD,SAAO,GAAG,MAAM,GAAG,mBAAmB;AACxC;AASO,SAAS,iBAAkB,OAAO,MAAM;AAC7C,MAAI,MAAM;A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|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../common/utils/index.js"],"sourcesContent":["import {\n DEFAULT_PREFIX,\n DEFAULT_VALIDATION_MESSAGE_TYPE,\n VALIDATION_MESSAGE_TYPES,\n} from '../constants';\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.startsWith('on'));\n return Object.fromEntries(listeners);\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 (e) {\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 */\nexport function warnIfUnmounted (componentRef, componentName) {\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\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 debounce,\n isOutOfViewPort,\n getPhoneNumberRegex,\n linkRegex,\n isEmailAddress,\n isPhoneNumber,\n isURL,\n safeConcatStrings,\n capitalizeFirstLetter,\n};\n"],"names":["h"],"mappings":";;AAWA,IAAI,oBAAoB;AACxB,IAAI;AAGJ,MAAM,gCAAgC;AAEtC,MAAM,kCAAkC;AAExC,MAAM,yCAAyC,GAAG,6BAA6B,IAAI,+BAA+B;AAElH,MAAM,qBAAqB,kBAAkB,sCAAsC;AAEnF,MAAM,YAAY,OAAO,iBAAiB,aAAa,eAAe;AAE/D,SAAS,gBAAiB,SAAS,gBAAgB;AACxD,SAAO,GAAG,MAAM,GAAG,mBAAmB;AACxC;AASO,SAAS,iBAAkB,OAAO,MAAM;AAC7C,MAAI,MAAM;AACR,UAAM,OAAO,aAAa,IAAI;AAC9B,WAAO,MAAM,KAAK,IAAI,IAAI,IAAI,MAAM,MAAM;AAAA,EAC9C,OAAS;AACL,WAAO,MAAM,aAAa,MAAM,MAAM,CAAC;AAAA,EACxC;AACH;AAiBO,SAAS,aAAc,KAAK;AACjC,MAAIA;AACJ,WAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AACnC,IAAAA,KAAI,KAAK,KAAK,IAAIA,EAAC,IAAI,IAAI,WAAW,CAAC,IAAI;AAAA,EAC5C;AAED,SAAOA;AACT;AAOO,SAAS,aAAc,KAAK;AACjC,SAAO,KAAK,MAAM,KAAK,OAAQ,IAAG,GAAG;AACvC;AAEO,SAAS,eAAgB,UAAU;AACxC,MAAI,CAAC,UAAU;AACb,WAAO;EACR;AAED,SAAO,SAAS,IAAI,aAAW;AAC7B,QAAI,OAAO,YAAY,UAAU;AAC/B,aAAO;AAAA,QACL;AAAA,QACA,MAAM;AAAA,MACd;AAAA,IACK;AAED,WAAO;AAAA,EACX,CAAG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,eAAgB,OAAO;;AACrC,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,WAAO,uBAAkB,KAAK,KAAK,MAA5B,mBAAgC,QAAO;AAChD;AAQO,SAAS,kBAAmB,UAAU;AAC3C,SAAO,SAAS,OAAO,SAAO,CAAC,CAAC,GAAG,EAAE,KAAK,GAAG;AAC/C;AAQO,SAAS,sBAAuB,KAAK,SAAS,SAAS;AAC5D,SAAO,IAAI,QAAQ,2BAAW,GAAE,UAAQ,KAAK,kBAAkB,MAAM,CAAC;AACxE;AAOO,SAAS,gBAAiB,cAAc,eAAe;AAC5D,MAAI,CAAC,gBAAgB,EAAE,wBAAwB,gBAAgB,EAAC,qCAAU,MAAM;AAChF,MAAI,CAAC,SAAS,KAAK,SAAS,YAAY,GAAG;AACzC,YAAQ,KAAK,OAAO,aAAa,yEAAyE;AAAA,EAC3G;AACH;AAEA,MAAe,QAAA;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
const vue = require("vue");
|
|
3
3
|
const monthYearPicker = require("./modules/month-year-picker.vue.cjs");
|
|
4
4
|
const calendar = require("./modules/calendar.vue.cjs");
|
|
5
|
+
const common_utils = require("../../common/utils.cjs");
|
|
5
6
|
const stack = require("../stack/stack.vue.cjs");
|
|
6
7
|
const _hoisted_1 = { class: "d-datepicker__hd" };
|
|
7
8
|
const _hoisted_2 = { class: "d-datepicker__bd" };
|
|
@@ -107,6 +108,10 @@ const _sfc_main = {
|
|
|
107
108
|
function updateCalendarDays(days) {
|
|
108
109
|
calendarDays.value = days;
|
|
109
110
|
}
|
|
111
|
+
vue.onMounted(() => {
|
|
112
|
+
const instance = vue.getCurrentInstance();
|
|
113
|
+
common_utils.warnIfUnmounted(instance.proxy.$el, "datepicker");
|
|
114
|
+
});
|
|
110
115
|
return (_ctx, _cache) => {
|
|
111
116
|
return vue.openBlock(), vue.createBlock(vue.unref(stack), {
|
|
112
117
|
class: "d-datepicker",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datepicker.vue.cjs","sources":["../../../components/datepicker/datepicker.vue"],"sourcesContent":["<!-- eslint-disable vue/multi-word-component-names -->\n<template>\n <dt-stack\n class=\"d-datepicker\"\n gap=\"400\"\n >\n <div class=\"d-datepicker__hd\">\n <month-year-picker\n ref=\"monthYearPicker\"\n :locale=\"locale\"\n :prev-month-label=\"prevMonthLabel\"\n :next-month-label=\"nextMonthLabel\"\n :prev-year-label=\"prevYearLabel\"\n :next-year-label=\"nextYearLabel\"\n :change-to-label=\"changeToLabel\"\n :selected-date=\"selectedDate\"\n @calendar-days=\"updateCalendarDays\"\n @focus-first-day=\"$refs.calendar.focusFirstDay()\"\n @focus-last-day=\"$refs.calendar.focusLastDay()\"\n @close-datepicker=\"$emit('close-datepicker')\"\n />\n </div>\n <div class=\"d-datepicker__bd\">\n <calendar\n ref=\"calendar\"\n :locale=\"locale\"\n :calendar-days=\"calendarDays\"\n :select-day-label=\"selectDayLabel\"\n @select-date=\"$emit('selected-date', $event)\"\n @focus-month-year-picker=\"$refs.monthYearPicker.focusMonthYearPicker()\"\n @close-datepicker=\"$emit('close-datepicker')\"\n @go-to-next-month=\"$refs.monthYearPicker.goToNextMonth()\"\n @go-to-prev-month=\"$refs.monthYearPicker.goToPrevMonth()\"\n />\n </div>\n </dt-stack>\n</template>\n\n<script setup>\nimport MonthYearPicker from './modules/month-year-picker.vue';\nimport Calendar from './modules/calendar.vue';\nimport { DtStack } from '@/components/stack';\n\nimport { ref } from 'vue';\n\ndefineProps({\n /**\n * Label for the previous month button\n *\n * @type {String}\n * @example 'Previous month'\n */\n prevMonthLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the next month button\n *\n * @type {String}\n * @example 'Next month'\n */\n nextMonthLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the previous year button\n *\n * @type {String}\n * @example 'Previous year'\n */\n prevYearLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the next year button\n *\n * @type {String}\n * @example 'Next year'\n */\n nextYearLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the select day button\n *\n * @type {String}\n * @example 'Select day'\n */\n selectDayLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the change to button\n *\n * @type {String}\n * @example 'Change to'\n */\n changeToLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Locale for the calendar\n *\n * @type {String}\n */\n locale: {\n type: String,\n default: 'en-US',\n },\n\n /**\n * Selected date\n *\n * @type {Date}\n */\n selectedDate: {\n type: Date,\n default: () => (new Date()),\n },\n});\n\ndefineEmits([\n /**\n * Event fired when a date is selected\n *\n * @event selected-date\n * @type {Date}\n */\n 'selected-date',\n\n /**\n * Event fired when user presses the esc key\n *\n * @event close-datepicker\n */\n 'close-datepicker',\n]);\n\nconst calendarDays = ref([]);\n\nfunction updateCalendarDays (days) {\n calendarDays.value = days;\n}\n</script>\n"],"names":["ref"],"mappings":"
|
|
1
|
+
{"version":3,"file":"datepicker.vue.cjs","sources":["../../../components/datepicker/datepicker.vue"],"sourcesContent":["<!-- eslint-disable vue/multi-word-component-names -->\n<template>\n <dt-stack\n class=\"d-datepicker\"\n gap=\"400\"\n >\n <div class=\"d-datepicker__hd\">\n <month-year-picker\n ref=\"monthYearPicker\"\n :locale=\"locale\"\n :prev-month-label=\"prevMonthLabel\"\n :next-month-label=\"nextMonthLabel\"\n :prev-year-label=\"prevYearLabel\"\n :next-year-label=\"nextYearLabel\"\n :change-to-label=\"changeToLabel\"\n :selected-date=\"selectedDate\"\n @calendar-days=\"updateCalendarDays\"\n @focus-first-day=\"$refs.calendar.focusFirstDay()\"\n @focus-last-day=\"$refs.calendar.focusLastDay()\"\n @close-datepicker=\"$emit('close-datepicker')\"\n />\n </div>\n <div class=\"d-datepicker__bd\">\n <calendar\n ref=\"calendar\"\n :locale=\"locale\"\n :calendar-days=\"calendarDays\"\n :select-day-label=\"selectDayLabel\"\n @select-date=\"$emit('selected-date', $event)\"\n @focus-month-year-picker=\"$refs.monthYearPicker.focusMonthYearPicker()\"\n @close-datepicker=\"$emit('close-datepicker')\"\n @go-to-next-month=\"$refs.monthYearPicker.goToNextMonth()\"\n @go-to-prev-month=\"$refs.monthYearPicker.goToPrevMonth()\"\n />\n </div>\n </dt-stack>\n</template>\n\n<script setup>\nimport MonthYearPicker from './modules/month-year-picker.vue';\nimport Calendar from './modules/calendar.vue';\nimport { DtStack } from '@/components/stack';\n\nimport { onMounted, ref, getCurrentInstance } from 'vue';\nimport { warnIfUnmounted } from '@/common/utils';\n\ndefineProps({\n /**\n * Label for the previous month button\n *\n * @type {String}\n * @example 'Previous month'\n */\n prevMonthLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the next month button\n *\n * @type {String}\n * @example 'Next month'\n */\n nextMonthLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the previous year button\n *\n * @type {String}\n * @example 'Previous year'\n */\n prevYearLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the next year button\n *\n * @type {String}\n * @example 'Next year'\n */\n nextYearLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the select day button\n *\n * @type {String}\n * @example 'Select day'\n */\n selectDayLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the change to button\n *\n * @type {String}\n * @example 'Change to'\n */\n changeToLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Locale for the calendar\n *\n * @type {String}\n */\n locale: {\n type: String,\n default: 'en-US',\n },\n\n /**\n * Selected date\n *\n * @type {Date}\n */\n selectedDate: {\n type: Date,\n default: () => (new Date()),\n },\n});\n\ndefineEmits([\n /**\n * Event fired when a date is selected\n *\n * @event selected-date\n * @type {Date}\n */\n 'selected-date',\n\n /**\n * Event fired when user presses the esc key\n *\n * @event close-datepicker\n */\n 'close-datepicker',\n]);\n\nconst calendarDays = ref([]);\n\nfunction updateCalendarDays (days) {\n calendarDays.value = days;\n}\n\nonMounted(() => {\n const instance = getCurrentInstance();\n warnIfUnmounted(instance.proxy.$el, 'datepicker');\n});\n</script>\n"],"names":["ref","onMounted","getCurrentInstance","warnIfUnmounted"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuJA,UAAM,eAAeA,IAAAA,IAAI,CAAA,CAAE;AAE3B,aAAS,mBAAoB,MAAM;AACjC,mBAAa,QAAQ;AAAA,IACvB;AAEAC,QAAAA,UAAU,MAAM;AACd,YAAM,WAAWC,IAAAA;AACjBC,mBAAAA,gBAAgB,SAAS,MAAM,KAAK,YAAY;AAAA,IAClD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ref, openBlock, createBlock, unref, withCtx, createElementVNode, createVNode } from "vue";
|
|
1
|
+
import { ref, onMounted, getCurrentInstance, openBlock, createBlock, unref, withCtx, createElementVNode, createVNode } from "vue";
|
|
2
2
|
import _sfc_main$2 from "./modules/month-year-picker.vue.js";
|
|
3
3
|
import _sfc_main$3 from "./modules/calendar.vue.js";
|
|
4
|
+
import { warnIfUnmounted } from "../../common/utils.js";
|
|
4
5
|
import DtStack from "../stack/stack.vue.js";
|
|
5
6
|
const _hoisted_1 = { class: "d-datepicker__hd" };
|
|
6
7
|
const _hoisted_2 = { class: "d-datepicker__bd" };
|
|
@@ -106,6 +107,10 @@ const _sfc_main = {
|
|
|
106
107
|
function updateCalendarDays(days) {
|
|
107
108
|
calendarDays.value = days;
|
|
108
109
|
}
|
|
110
|
+
onMounted(() => {
|
|
111
|
+
const instance = getCurrentInstance();
|
|
112
|
+
warnIfUnmounted(instance.proxy.$el, "datepicker");
|
|
113
|
+
});
|
|
109
114
|
return (_ctx, _cache) => {
|
|
110
115
|
return openBlock(), createBlock(unref(DtStack), {
|
|
111
116
|
class: "d-datepicker",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datepicker.vue.js","sources":["../../../components/datepicker/datepicker.vue"],"sourcesContent":["<!-- eslint-disable vue/multi-word-component-names -->\n<template>\n <dt-stack\n class=\"d-datepicker\"\n gap=\"400\"\n >\n <div class=\"d-datepicker__hd\">\n <month-year-picker\n ref=\"monthYearPicker\"\n :locale=\"locale\"\n :prev-month-label=\"prevMonthLabel\"\n :next-month-label=\"nextMonthLabel\"\n :prev-year-label=\"prevYearLabel\"\n :next-year-label=\"nextYearLabel\"\n :change-to-label=\"changeToLabel\"\n :selected-date=\"selectedDate\"\n @calendar-days=\"updateCalendarDays\"\n @focus-first-day=\"$refs.calendar.focusFirstDay()\"\n @focus-last-day=\"$refs.calendar.focusLastDay()\"\n @close-datepicker=\"$emit('close-datepicker')\"\n />\n </div>\n <div class=\"d-datepicker__bd\">\n <calendar\n ref=\"calendar\"\n :locale=\"locale\"\n :calendar-days=\"calendarDays\"\n :select-day-label=\"selectDayLabel\"\n @select-date=\"$emit('selected-date', $event)\"\n @focus-month-year-picker=\"$refs.monthYearPicker.focusMonthYearPicker()\"\n @close-datepicker=\"$emit('close-datepicker')\"\n @go-to-next-month=\"$refs.monthYearPicker.goToNextMonth()\"\n @go-to-prev-month=\"$refs.monthYearPicker.goToPrevMonth()\"\n />\n </div>\n </dt-stack>\n</template>\n\n<script setup>\nimport MonthYearPicker from './modules/month-year-picker.vue';\nimport Calendar from './modules/calendar.vue';\nimport { DtStack } from '@/components/stack';\n\nimport { ref } from 'vue';\n\ndefineProps({\n /**\n * Label for the previous month button\n *\n * @type {String}\n * @example 'Previous month'\n */\n prevMonthLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the next month button\n *\n * @type {String}\n * @example 'Next month'\n */\n nextMonthLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the previous year button\n *\n * @type {String}\n * @example 'Previous year'\n */\n prevYearLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the next year button\n *\n * @type {String}\n * @example 'Next year'\n */\n nextYearLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the select day button\n *\n * @type {String}\n * @example 'Select day'\n */\n selectDayLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the change to button\n *\n * @type {String}\n * @example 'Change to'\n */\n changeToLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Locale for the calendar\n *\n * @type {String}\n */\n locale: {\n type: String,\n default: 'en-US',\n },\n\n /**\n * Selected date\n *\n * @type {Date}\n */\n selectedDate: {\n type: Date,\n default: () => (new Date()),\n },\n});\n\ndefineEmits([\n /**\n * Event fired when a date is selected\n *\n * @event selected-date\n * @type {Date}\n */\n 'selected-date',\n\n /**\n * Event fired when user presses the esc key\n *\n * @event close-datepicker\n */\n 'close-datepicker',\n]);\n\nconst calendarDays = ref([]);\n\nfunction updateCalendarDays (days) {\n calendarDays.value = days;\n}\n</script>\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"datepicker.vue.js","sources":["../../../components/datepicker/datepicker.vue"],"sourcesContent":["<!-- eslint-disable vue/multi-word-component-names -->\n<template>\n <dt-stack\n class=\"d-datepicker\"\n gap=\"400\"\n >\n <div class=\"d-datepicker__hd\">\n <month-year-picker\n ref=\"monthYearPicker\"\n :locale=\"locale\"\n :prev-month-label=\"prevMonthLabel\"\n :next-month-label=\"nextMonthLabel\"\n :prev-year-label=\"prevYearLabel\"\n :next-year-label=\"nextYearLabel\"\n :change-to-label=\"changeToLabel\"\n :selected-date=\"selectedDate\"\n @calendar-days=\"updateCalendarDays\"\n @focus-first-day=\"$refs.calendar.focusFirstDay()\"\n @focus-last-day=\"$refs.calendar.focusLastDay()\"\n @close-datepicker=\"$emit('close-datepicker')\"\n />\n </div>\n <div class=\"d-datepicker__bd\">\n <calendar\n ref=\"calendar\"\n :locale=\"locale\"\n :calendar-days=\"calendarDays\"\n :select-day-label=\"selectDayLabel\"\n @select-date=\"$emit('selected-date', $event)\"\n @focus-month-year-picker=\"$refs.monthYearPicker.focusMonthYearPicker()\"\n @close-datepicker=\"$emit('close-datepicker')\"\n @go-to-next-month=\"$refs.monthYearPicker.goToNextMonth()\"\n @go-to-prev-month=\"$refs.monthYearPicker.goToPrevMonth()\"\n />\n </div>\n </dt-stack>\n</template>\n\n<script setup>\nimport MonthYearPicker from './modules/month-year-picker.vue';\nimport Calendar from './modules/calendar.vue';\nimport { DtStack } from '@/components/stack';\n\nimport { onMounted, ref, getCurrentInstance } from 'vue';\nimport { warnIfUnmounted } from '@/common/utils';\n\ndefineProps({\n /**\n * Label for the previous month button\n *\n * @type {String}\n * @example 'Previous month'\n */\n prevMonthLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the next month button\n *\n * @type {String}\n * @example 'Next month'\n */\n nextMonthLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the previous year button\n *\n * @type {String}\n * @example 'Previous year'\n */\n prevYearLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the next year button\n *\n * @type {String}\n * @example 'Next year'\n */\n nextYearLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the select day button\n *\n * @type {String}\n * @example 'Select day'\n */\n selectDayLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Label for the change to button\n *\n * @type {String}\n * @example 'Change to'\n */\n changeToLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Locale for the calendar\n *\n * @type {String}\n */\n locale: {\n type: String,\n default: 'en-US',\n },\n\n /**\n * Selected date\n *\n * @type {Date}\n */\n selectedDate: {\n type: Date,\n default: () => (new Date()),\n },\n});\n\ndefineEmits([\n /**\n * Event fired when a date is selected\n *\n * @event selected-date\n * @type {Date}\n */\n 'selected-date',\n\n /**\n * Event fired when user presses the esc key\n *\n * @event close-datepicker\n */\n 'close-datepicker',\n]);\n\nconst calendarDays = ref([]);\n\nfunction updateCalendarDays (days) {\n calendarDays.value = days;\n}\n\nonMounted(() => {\n const instance = getCurrentInstance();\n warnIfUnmounted(instance.proxy.$el, 'datepicker');\n});\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuJA,UAAM,eAAe,IAAI,CAAA,CAAE;AAE3B,aAAS,mBAAoB,MAAM;AACjC,mBAAa,QAAQ;AAAA,IACvB;AAEA,cAAU,MAAM;AACd,YAAM,WAAW;AACjB,sBAAgB,SAAS,MAAM,KAAK,YAAY;AAAA,IAClD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -512,6 +512,7 @@ const _sfc_main = {
|
|
|
512
512
|
},
|
|
513
513
|
mounted() {
|
|
514
514
|
var _a;
|
|
515
|
+
common_utils.warnIfUnmounted(this.$el, this.$options.name);
|
|
515
516
|
const externalAnchorEl = this.externalAnchor ? this.$refs.anchor.getRootNode().querySelector(`#${this.externalAnchor}`) : null;
|
|
516
517
|
this.anchorEl = externalAnchorEl ?? this.$refs.anchor.children[0];
|
|
517
518
|
this.popoverContentEl = (_a = this.$refs.content) == null ? void 0 : _a.$el;
|