1import Inputmask from "./vendors/inputmask.js?v=2.3.2.0"; 2import { createEvent, getRequiredElement } from "./utilities.js?v=2.3.2.0"; 3 4let _instances = []; 5 6export function initialize(dotnetAdapter, element, elementId, options) { 7 element = getRequiredElement(element, elementId); 8 9 if (!element) 10 return; 11 12 let initializing = true; 13 14 const maskOptions = options.mask ? { mask: options.mask } : {}; 15 const regexOptions = options.mask ? { regex: options.regex } : {}; 16 const aliasOptions = options.alias ? { alias: options.alias, inputFormat: options.inputFormat, outputFormat: options.outputFormat } : {}; 17 const eventOptions = dotnetAdapter 18 ? { 19 oncomplete: function (e) { 20 dotnetAdapter.invokeMethodAsync('NotifyCompleted', e.target.value); 21 }, 22 onincomplete: function (e) { 23 dotnetAdapter.invokeMethodAsync('NotifyIncompleted', e.target.value); 24 }, 25 oncleared: function () { 26 dotnetAdapter.invokeMethodAsync('NotifyCleared'); 27 } 28 } 29 : options.dispatchChangeOnComplete 30 ? { 31 oncomplete: function (e) { 32 if (!initializing) { 33 e.target.dispatchEvent(createEvent("change")); 34 } 35 } 36 } 37 : {}; 38 39 const otherOptions = { 40 placeholder: options.maskPlaceholder || "_", 41 showMaskOnFocus: options.showMaskOnFocus, 42 showMaskOnHover: options.showMaskOnHover, 43 numericInput: options.numericInput || false, 44 rightAlign: options.rightAlign || false, 45 radixPoint: options.decimalSeparator || "", 46 groupSeparator: options.groupSeparator || "", 47 nullable: options.nullable || false, 48 positionCaretOnClick: options.positionCaretOnClick || "lvp", 49 clearMaskOnLostFocus: options.clearMaskOnLostFocus || true, 50 clearIncomplete: options.clearIncomplete || false, 51 autoUnmask: options.autoUnmask || false 52 }; 53 54 const finalOptions = options.alias 55 ? Object.assign({}, aliasOptions, eventOptions, otherOptions) 56 : Object.assign({}, maskOptions, regexOptions, eventOptions, otherOptions); 57 58 let inputMask = new Inputmask(finalOptions); 59 60 inputMask.mask(element); 61 62 setTimeout(() => initializing = false, 0); 63 64 _instances[elementId] = { 65 dotnetAdapter: dotnetAdapter, 66 element: element, 67 elementId: elementId, 68 inputMask: inputMask 69 }; 70 71 return inputMask; 72} 73 74export function destroy(element, elementId) { 75 let instances = _instances || {}; 76 const instance = instances[elementId]; 77 78 if (instance) { 79 try { 80 if (instance.element && instance.element.inputmask && typeof instance.element.inputmask.remove === "function") { 81 instance.element.inputmask.remove(); 82 } 83 else if (instance.inputMask && typeof instance.inputMask.remove === "function") { 84 instance.inputMask.remove(); 85 } 86 } 87 catch (error) { 88 console.error(error); 89 } 90 91 instance.inputMask = null; 92 } 93 94 delete instances[elementId]; 95} 96 97export function extendAliases(element, elementId, aliasOptions) { 98 const instance = _instances[elementId]; 99 100 if (instance && instance.inputMask) { 101 instance.inputMask.extendAliases(aliasOptions); 102 } 103}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.