-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update npm dependencies + rebuild + vue 3
- Loading branch information
1 parent
bd33a7d
commit 19c7ab7
Showing
18 changed files
with
537 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
declare function bind(el: any, binding: any, vnode: any): void; | ||
declare function componentUpdated(el: any, binding: any, vnode: any, oldVnode: any): void; | ||
declare const _default: { | ||
bind: typeof bind; | ||
componentUpdated: typeof componentUpdated; | ||
}; | ||
export default _default; | ||
declare function bind(el: any, binding: any, vnode: any): void; | ||
declare function componentUpdated(el: any, binding: any, vnode: any, oldVnode: any): void; | ||
declare const _default: { | ||
bind: typeof bind; | ||
componentUpdated: typeof componentUpdated; | ||
}; | ||
export default _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,115 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
var lodash_1 = require("lodash"); | ||
var masker_1 = require("./masker"); | ||
var predefined_1 = require("./predefined"); | ||
var tokens_1 = require("./tokens"); | ||
var utils_1 = require("./utils"); | ||
function run(el, eventName, config, vnode) { | ||
// Handle when initial value is not set | ||
var beforeValue = el.value === 'undefined' ? '' : el.value; | ||
var position = el.selectionEnd; | ||
// save the character just inserted | ||
var digit = beforeValue[position - 1]; | ||
el.value = (0, masker_1["default"])(beforeValue, config.mask, config.masked, config.tokens); | ||
// if the digit was changed, increment position until find the digit again | ||
while (position < el.value.length && | ||
el.value.charAt(position - 1) !== digit) { | ||
position++; | ||
} | ||
if (el === document.activeElement) { | ||
el.setSelectionRange(position, position); | ||
setTimeout(function () { | ||
el.setSelectionRange(position, position); | ||
}, 0); | ||
} | ||
// Set unmasked value if required | ||
if (config.unmaskedVar) { | ||
var ut = (0, utils_1.unmaskText)(el.value); | ||
if (config.nullIfEmpty && ut.trim().length === 0) { | ||
// Set null instead of empty if required | ||
(0, lodash_1.set)(vnode.context, config.unmaskedVar, null); | ||
} | ||
else { | ||
if (config.number) { | ||
// Convert to number if required | ||
var vNumber = parseFloat(ut); | ||
(0, lodash_1.set)(vnode.context, config.unmaskedVar, isNaN(vNumber) ? ut : vNumber); | ||
} | ||
else { | ||
(0, lodash_1.set)(vnode.context, config.unmaskedVar, ut); | ||
} | ||
} | ||
} | ||
// Notify listeners only if value changed (ie send an extra 'input' event) | ||
if (beforeValue !== el.value) { | ||
el.dispatchEvent(event(eventName)); | ||
} | ||
} | ||
// ------- | ||
// Helpers | ||
// ------- | ||
function event(name) { | ||
var evt = document.createEvent('Event'); | ||
evt.initEvent(name, true, true); | ||
return evt; | ||
} | ||
function getInput(el) { | ||
if (el.tagName.toLocaleUpperCase() !== 'INPUT') { | ||
var els = el.getElementsByTagName('input'); | ||
if (els.length !== 1) { | ||
throw new Error("v-mask requires 1 input, found ".concat(els.length)); | ||
} | ||
else { | ||
el = els[0]; | ||
} | ||
} | ||
return el; | ||
} | ||
function getConfig(binding) { | ||
var config = { | ||
masked: true, | ||
mask: 'null', | ||
unmaskedVar: null, | ||
nullIfEmpty: true, | ||
number: false, | ||
tokens: tokens_1["default"] | ||
}; | ||
if (typeof binding.value === 'string') { | ||
config.mask = binding.value; | ||
} | ||
else { | ||
Object.assign(config, binding.value); | ||
} | ||
// Capture ".number" modifier | ||
var modifiers = binding.modifiers; | ||
config.number = modifiers && modifiers.number; | ||
// Set mask from a predefined one eventually | ||
config.mask = (0, predefined_1["default"])(config.mask) || config.mask || ''; | ||
return config; | ||
} | ||
// ------------------------------- | ||
// Vue.js directive hook functions | ||
// ------------------------------- | ||
function bind(el, binding, vnode) { | ||
if (binding.value === false) { | ||
return; | ||
} | ||
var realEl = getInput(el); | ||
run(realEl, 'input', getConfig(binding), vnode); | ||
} | ||
function componentUpdated(el, binding, vnode, oldVnode) { | ||
if (binding.value === false) { | ||
return; | ||
} | ||
// Prevent firing endless events | ||
var data = vnode.data.props || vnode.data.model; | ||
var oldData = oldVnode.data.props || oldVnode.data.model; | ||
if (data && data.value === oldData.value) { | ||
return; | ||
} | ||
var realEl = getInput(el); | ||
realEl.value = data ? data.value : realEl.value; | ||
run(realEl, 'input', getConfig(binding), vnode); | ||
} | ||
exports["default"] = { bind: bind, componentUpdated: componentUpdated }; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var lodash_1 = require("lodash"); | ||
var masker_1 = require("./masker"); | ||
var predefined_1 = require("./predefined"); | ||
var tokens_1 = require("./tokens"); | ||
var utils_1 = require("./utils"); | ||
function run(el, eventName, config, vnode) { | ||
// Handle when initial value is not set | ||
var beforeValue = el.value === 'undefined' ? '' : el.value; | ||
var position = el.selectionEnd; | ||
// save the character just inserted | ||
var digit = beforeValue[position - 1]; | ||
el.value = (0, masker_1.default)(beforeValue, config.mask, config.masked, config.tokens); | ||
// if the digit was changed, increment position until find the digit again | ||
while (position < el.value.length && | ||
el.value.charAt(position - 1) !== digit) { | ||
position++; | ||
} | ||
if (el === document.activeElement) { | ||
el.setSelectionRange(position, position); | ||
setTimeout(function () { | ||
el.setSelectionRange(position, position); | ||
}, 0); | ||
} | ||
// Set unmasked value if required | ||
if (config.unmaskedVar) { | ||
var ut = (0, utils_1.unmaskText)(el.value); | ||
if (config.nullIfEmpty && ut.trim().length === 0) { | ||
// Set null instead of empty if required | ||
(0, lodash_1.set)(vnode.context, config.unmaskedVar, null); | ||
} | ||
else { | ||
if (config.number) { | ||
// Convert to number if required | ||
var vNumber = parseFloat(ut); | ||
(0, lodash_1.set)(vnode.context, config.unmaskedVar, isNaN(vNumber) ? ut : vNumber); | ||
} | ||
else { | ||
(0, lodash_1.set)(vnode.context, config.unmaskedVar, ut); | ||
} | ||
} | ||
} | ||
// Notify listeners only if value changed (ie send an extra 'input' event) | ||
if (beforeValue !== el.value) { | ||
el.dispatchEvent(event(eventName)); | ||
} | ||
} | ||
// ------- | ||
// Helpers | ||
// ------- | ||
function event(name) { | ||
var evt = document.createEvent('Event'); | ||
evt.initEvent(name, true, true); | ||
return evt; | ||
} | ||
function getInput(el) { | ||
if (el.tagName.toLocaleUpperCase() !== 'INPUT') { | ||
var els = el.getElementsByTagName('input'); | ||
if (els.length !== 1) { | ||
throw new Error("v-mask requires 1 input, found ".concat(els.length)); | ||
} | ||
else { | ||
el = els[0]; | ||
} | ||
} | ||
return el; | ||
} | ||
function getConfig(binding) { | ||
var config = { | ||
masked: true, | ||
mask: 'null', | ||
unmaskedVar: null, | ||
nullIfEmpty: true, | ||
number: false, | ||
tokens: tokens_1.default | ||
}; | ||
if (typeof binding.value === 'string') { | ||
config.mask = binding.value; | ||
} | ||
else { | ||
Object.assign(config, binding.value); | ||
} | ||
// Capture ".number" modifier | ||
var modifiers = binding.modifiers; | ||
config.number = modifiers && modifiers.number; | ||
// Set mask from a predefined one eventually | ||
config.mask = (0, predefined_1.default)(config.mask) || config.mask || ''; | ||
return config; | ||
} | ||
// ------------------------------- | ||
// Vue.js directive hook functions | ||
// ------------------------------- | ||
function bind(el, binding, vnode) { | ||
if (binding.value === false) { | ||
return; | ||
} | ||
var realEl = getInput(el); | ||
run(realEl, 'input', getConfig(binding), vnode); | ||
} | ||
function componentUpdated(el, binding, vnode, oldVnode) { | ||
if (binding.value === false) { | ||
return; | ||
} | ||
// Prevent firing endless events | ||
var data = vnode.data.props || vnode.data.model; | ||
var oldData = oldVnode.data.props || oldVnode.data.model; | ||
if (data && data.value === oldData.value) { | ||
return; | ||
} | ||
var realEl = getInput(el); | ||
realEl.value = data ? data.value : realEl.value; | ||
run(realEl, 'input', getConfig(binding), vnode); | ||
} | ||
exports.default = { bind: bind, componentUpdated: componentUpdated }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export default function dynamicMask(maskit: any, masks: any, tokens: any): (value: any, mask: any, masked?: boolean) => any; | ||
export default function dynamicMask(maskit: any, masks: any, tokens: any): (value: any, mask: any, masked?: boolean) => any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
function dynamicMask(maskit, masks, tokens) { | ||
masks = masks.slice().sort(function (a, b) { return a.length - b.length; }); | ||
return function (value, mask, masked) { | ||
if (masked === void 0) { masked = true; } | ||
var i = 0; | ||
while (i < masks.length) { | ||
var currentMask = masks[i]; | ||
i++; | ||
var nextMask = masks[i]; | ||
// tslint:disable-next-line: max-line-length | ||
if (!(nextMask && maskit(value, nextMask, true, tokens).length > currentMask.length)) { | ||
return maskit(value, currentMask, masked, tokens); | ||
} | ||
} | ||
return ''; // empty masks | ||
}; | ||
} | ||
exports["default"] = dynamicMask; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function dynamicMask(maskit, masks, tokens) { | ||
masks = masks.slice().sort(function (a, b) { return a.length - b.length; }); | ||
return function (value, mask, masked) { | ||
if (masked === void 0) { masked = true; } | ||
var i = 0; | ||
while (i < masks.length) { | ||
var currentMask = masks[i]; | ||
i++; | ||
var nextMask = masks[i]; | ||
// tslint:disable-next-line: max-line-length | ||
if (!(nextMask && maskit(value, nextMask, true, tokens).length > currentMask.length)) { | ||
return maskit(value, currentMask, masked, tokens); | ||
} | ||
} | ||
return ''; // empty masks | ||
}; | ||
} | ||
exports.default = dynamicMask; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import mask from './directive'; | ||
import { unmaskText } from './utils'; | ||
declare function install(Vue: any): void; | ||
export { mask }; | ||
export { unmaskText }; | ||
export default install; | ||
import mask from './directive'; | ||
import { unmaskText } from './utils'; | ||
declare function install(Vue: any): void; | ||
export { mask }; | ||
export { unmaskText }; | ||
export default install; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.unmaskText = exports.mask = void 0; | ||
var directive_1 = require("./directive"); | ||
exports.mask = directive_1["default"]; | ||
var utils_1 = require("./utils"); | ||
exports.unmaskText = utils_1.unmaskText; | ||
/* tslint:disable-next-line:variable-name */ | ||
function install(Vue) { | ||
Vue.directive('mask', directive_1["default"]); | ||
} | ||
exports["default"] = install; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.unmaskText = exports.mask = void 0; | ||
var directive_1 = require("./directive"); | ||
exports.mask = directive_1.default; | ||
var utils_1 = require("./utils"); | ||
Object.defineProperty(exports, "unmaskText", { enumerable: true, get: function () { return utils_1.unmaskText; } }); | ||
/* tslint:disable-next-line:variable-name */ | ||
function install(Vue) { | ||
Vue.directive('mask', directive_1.default); | ||
} | ||
exports.default = install; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
export default function (value: string, mask: string, masked?: boolean, tokens?: { | ||
'#': { | ||
pattern: RegExp; | ||
}; | ||
X: { | ||
pattern: RegExp; | ||
}; | ||
S: { | ||
pattern: RegExp; | ||
}; | ||
A: { | ||
pattern: RegExp; | ||
transform: (v: string) => string; | ||
}; | ||
a: { | ||
pattern: RegExp; | ||
transform: (v: string) => string; | ||
}; | ||
'!': { | ||
escape: boolean; | ||
}; | ||
}): string | ((value: any, mask: any, masked?: boolean) => any); | ||
export default function (value: string, mask: string, masked?: boolean, tokens?: { | ||
'#': { | ||
pattern: RegExp; | ||
}; | ||
X: { | ||
pattern: RegExp; | ||
}; | ||
S: { | ||
pattern: RegExp; | ||
}; | ||
A: { | ||
pattern: RegExp; | ||
transform: (v: string) => string; | ||
}; | ||
a: { | ||
pattern: RegExp; | ||
transform: (v: string) => string; | ||
}; | ||
'!': { | ||
escape: boolean; | ||
}; | ||
}): string | ((value: any, mask: any, masked?: boolean) => any); |
Oops, something went wrong.