Socket
Socket
Sign inDemoInstall

@satrong/v-input

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4-alpha.1 to 0.0.4-alpha.2

2

lib/v-input.es.js

@@ -1,1 +0,1 @@

function t(t,e,r){new Function("obj","value",`return obj.${e} = value`)(t,r)}function e(t,e,r,n="input"){if(""===t)return t;let i=String(t);const o=r["!0"]||r.integer||r.negative||r.number||r.positive||Array.isArray(e);if(r.number&&!/^[-.\d]+$/.test(i)&&(i=i.replace(/[^-.\d]+/g,"")),r.integer&&!/^[-\d]+$/.test(i)&&(i=i.replace(/[^-\d]+/g,"")),r.positive&&!r.negative&&(i=i.replace(/[^.\d]+/g,"")),r.negative&&!r.positive&&(i=i.replace(/[^-.\d]+/g,"")),o&&""!==i&&"-"!==i&&!isFinite(+i)){const t=i.match(/-?\d+\.?\d+/);i=t?t[0]:""}if("blur"!==n||!r.negative||r.positive||/^-/.test(i)||0===Number(i)||(i=""),Array.isArray(e)){const[t,r]=e,o=Number(i);(r!==1/0&&t!==-1/0||"blur"===n)&&(o<t||o>r)&&(i="")}return"blur"===n&&o&&""!==i&&(i=String(Number(i))),"function"==typeof e&&(i=e(i)),i}function r(r,n,i){const o=(i.arg||"").replace(/:/g,"."),u=i.modifiers;if(!function(t,e){let r=t;return e.split(".").every((t=>!!Object.prototype.hasOwnProperty.call(r,t)&&(r=r[t],!0)))}(r.$data,o))throw new Error(`The expression \`this.${o}\` not found.`);!function(t){if(Array.isArray(t)){const[e,r]=t;if(2!==t.length)throw Error("Array length must be 2");if("number"!=typeof e||"number"!=typeof r)throw Error("Array's elements must be `Number`");if(e>r)throw Error("In the array `[min, max]`, min cannot be greater than max")}else if(void 0!==t){if("function"!=typeof t)throw Error("The `bindValue` must be `Function`");if(["","123","12ab","1.2.3.4"].some((e=>{const r=t(e);return r!==t(r)})))throw Error("Make sure `bindValue` function DONOT return dynamic value.")}}(i.value),n.vInputUnwatch=r.$watch(o,((n,a)=>{if("string"==typeof n){let s=e(n,i.value,u);""!==n&&""===s&&""!==a&&(s=e(a,i.value,u)),t(r.$data,o,s)}}));const a=function(t){const e=Object.prototype.toString.call(t).slice(8,-1);return["HTMLInputElement","HTMLTextAreaElement"].indexOf(e)>-1}(n)?n:n.querySelector("input,textarea");if(a){const s=()=>{const n=(a=r.$data,o.split(".").reduce(((t,e)=>t[e]),a));var a;let s=n;u["!0"]&&(isNaN(n)||(s=String(Number(n)),"0"===s&&(s=""))),t(r.$data,o,e(s,i.value,u,"blur"))};a.addEventListener("blur",s),n.vInputBlur=[a,s]}}function n(t){var e;null==(e=t.vInputUnwatch)||e.call(t),t.vInputBlur&&t.vInputBlur[0].removeEventListener("blur",t.vInputBlur[1])}const i={mounted(t,e){const n=e.instance;n&&r(n,t,e)},beforeUnmount:n};var o={install:t=>{t.version.startsWith("2.")?t.directive("input",{bind(t,e,n){r(n.context,t,e)},unbind:n}):t.version.startsWith("3.")&&t.directive("input",i)}};export default o;export{i as directive};
function e(e,t,r){new Function("obj","value",`return obj.${t} = value`)(e,r)}function t(e,t,r,n="input"){if(""===e)return e;let i=String(e);const o=r["!0"]||r.integer||r.negative||r.number||r.positive||Array.isArray(t);if(r.number&&!/^[-.\d]+$/.test(i)&&(i=i.replace(/[^-.\d]+/g,"")),r.integer&&!/^[-\d]+$/.test(i)&&(i=i.replace(/[^-\d]+/g,"")),r.positive&&!r.negative&&(i=i.replace(/[^.\d]+/g,"")),r.negative&&!r.positive&&(i=i.replace(/[^-.\d]+/g,"")),o&&(i=i.replace(/\s+/g,""),""!==i&&"-"!==i&&!isFinite(+i))){const e=i.match(/-?\d+\.?\d+/);i=e?e[0]:""}if("blur"!==n||!r.negative||r.positive||/^-/.test(i)||0===Number(i)||(i=""),Array.isArray(t)&&""!==i){const[e,r]=t,o=Number(i);"blur"===n&&(o<e||o>r)&&(i="")}return"blur"===n&&o&&""!==i&&(i=String(Number(i))),"function"==typeof t&&(i=t(i)),i}function r(r,n,i){const o=(i.arg||"").replace(/:/g,"."),u=i.modifiers;if(!function(e,t){let r=e;return t.split(".").every((e=>!!(Object.prototype.hasOwnProperty.call(r,e)||window.Reflect&&Reflect.has(r,e))&&(r=r[e],!0)))}(r,o))throw new Error(`The expression \`this.${o}\` not found.`);!function(e){if(Array.isArray(e)){const[t,r]=e;if(2!==e.length)throw Error("Array length must be 2");if("number"!=typeof t||"number"!=typeof r)throw Error("Array's elements must be `Number`");if(t>r)throw Error("In the array `[min, max]`, min cannot be greater than max")}else if(void 0!==e){if("function"!=typeof e)throw Error("The `bindValue` must be `Function`");if(["","123","12ab","1.2.3.4"].some((t=>{const r=e(t);return r!==e(r)})))throw Error("Make sure `bindValue` function DONOT return dynamic value.")}}(i.value),n.vInputUnwatch=r.$watch(o,((n,a)=>{if("string"==typeof n){let s=t(n,i.value,u);""!==n&&""===s&&""!==a&&(s=t(a,i.value,u)),e(r,o,s)}}));const a=function(e){const t=Object.prototype.toString.call(e).slice(8,-1);return["HTMLInputElement","HTMLTextAreaElement"].indexOf(t)>-1}(n)?n:n.querySelector("input,textarea");if(a){const s=()=>{const n=(a=r,o.split(".").reduce(((e,t)=>e[t]),a));var a;let s=n;u["!0"]&&(isNaN(n)||(s=String(Number(n)),"0"===s&&(s=""))),e(r,o,t(s,i.value,u,"blur"))};a.addEventListener("blur",s),n.vInputBlur=[a,s]}}function n(e){var t;null==(t=e.vInputUnwatch)||t.call(e),e.vInputBlur&&e.vInputBlur[0].removeEventListener("blur",e.vInputBlur[1])}const i={mounted(e,t){const n=t.instance;n&&r(n,e,t)},beforeUnmount:n};var o={install:e=>{e.version.startsWith("2.")?e.directive("input",{bind(e,t,n){r(n.context,e,t)},unbind:n}):e.version.startsWith("3.")&&e.directive("input",i)}};export default o;export{i as directive};

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VInput={})}(this,(function(e){"use strict";function t(e,t,n){new Function("obj","value",`return obj.${t} = value`)(e,n)}function n(e,t,n,r="input"){if(""===e)return e;let i=String(e);const o=n["!0"]||n.integer||n.negative||n.number||n.positive||Array.isArray(t);if(n.number&&!/^[-.\d]+$/.test(i)&&(i=i.replace(/[^-.\d]+/g,"")),n.integer&&!/^[-\d]+$/.test(i)&&(i=i.replace(/[^-\d]+/g,"")),n.positive&&!n.negative&&(i=i.replace(/[^.\d]+/g,"")),n.negative&&!n.positive&&(i=i.replace(/[^-.\d]+/g,"")),o&&""!==i&&"-"!==i&&!isFinite(+i)){const e=i.match(/-?\d+\.?\d+/);i=e?e[0]:""}if("blur"!==r||!n.negative||n.positive||/^-/.test(i)||0===Number(i)||(i=""),Array.isArray(t)){const[e,n]=t,o=Number(i);(n!==1/0&&e!==-1/0||"blur"===r)&&(o<e||o>n)&&(i="")}return"blur"===r&&o&&""!==i&&(i=String(Number(i))),"function"==typeof t&&(i=t(i)),i}function r(e,r,i){const o=(i.arg||"").replace(/:/g,"."),u=i.modifiers;if(!function(e,t){let n=e;return t.split(".").every((e=>!!Object.prototype.hasOwnProperty.call(n,e)&&(n=n[e],!0)))}(e.$data,o))throw new Error(`The expression \`this.${o}\` not found.`);!function(e){if(Array.isArray(e)){const[t,n]=e;if(2!==e.length)throw Error("Array length must be 2");if("number"!=typeof t||"number"!=typeof n)throw Error("Array's elements must be `Number`");if(t>n)throw Error("In the array `[min, max]`, min cannot be greater than max")}else if(void 0!==e){if("function"!=typeof e)throw Error("The `bindValue` must be `Function`");if(["","123","12ab","1.2.3.4"].some((t=>{const n=e(t);return n!==e(n)})))throw Error("Make sure `bindValue` function DONOT return dynamic value.")}}(i.value),r.vInputUnwatch=e.$watch(o,((r,a)=>{if("string"==typeof r){let s=n(r,i.value,u);""!==r&&""===s&&""!==a&&(s=n(a,i.value,u)),t(e.$data,o,s)}}));const a=function(e){const t=Object.prototype.toString.call(e).slice(8,-1);return["HTMLInputElement","HTMLTextAreaElement"].indexOf(t)>-1}(r)?r:r.querySelector("input,textarea");if(a){const s=()=>{const r=(a=e.$data,o.split(".").reduce(((e,t)=>e[t]),a));var a;let s=r;u["!0"]&&(isNaN(r)||(s=String(Number(r)),"0"===s&&(s=""))),t(e.$data,o,n(s,i.value,u,"blur"))};a.addEventListener("blur",s),r.vInputBlur=[a,s]}}function i(e){var t;null==(t=e.vInputUnwatch)||t.call(e),e.vInputBlur&&e.vInputBlur[0].removeEventListener("blur",e.vInputBlur[1])}const o={mounted(e,t){const n=t.instance;n&&r(n,e,t)},beforeUnmount:i};var u={install:e=>{e.version.startsWith("2.")?e.directive("input",{bind(e,t,n){r(n.context,e,t)},unbind:i}):e.version.startsWith("3.")&&e.directive("input",o)}};e.default=u,e.directive=o,Object.defineProperty(e,"__esModule",{value:!0}),e[Symbol.toStringTag]="Module"}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VInput={})}(this,(function(e){"use strict";function t(e,t,n){new Function("obj","value",`return obj.${t} = value`)(e,n)}function n(e,t,n,r="input"){if(""===e)return e;let i=String(e);const o=n["!0"]||n.integer||n.negative||n.number||n.positive||Array.isArray(t);if(n.number&&!/^[-.\d]+$/.test(i)&&(i=i.replace(/[^-.\d]+/g,"")),n.integer&&!/^[-\d]+$/.test(i)&&(i=i.replace(/[^-\d]+/g,"")),n.positive&&!n.negative&&(i=i.replace(/[^.\d]+/g,"")),n.negative&&!n.positive&&(i=i.replace(/[^-.\d]+/g,"")),o&&(i=i.replace(/\s+/g,""),""!==i&&"-"!==i&&!isFinite(+i))){const e=i.match(/-?\d+\.?\d+/);i=e?e[0]:""}if("blur"!==r||!n.negative||n.positive||/^-/.test(i)||0===Number(i)||(i=""),Array.isArray(t)&&""!==i){const[e,n]=t,o=Number(i);"blur"===r&&(o<e||o>n)&&(i="")}return"blur"===r&&o&&""!==i&&(i=String(Number(i))),"function"==typeof t&&(i=t(i)),i}function r(e,r,i){const o=(i.arg||"").replace(/:/g,"."),u=i.modifiers;if(!function(e,t){let n=e;return t.split(".").every((e=>!!(Object.prototype.hasOwnProperty.call(n,e)||window.Reflect&&Reflect.has(n,e))&&(n=n[e],!0)))}(e,o))throw new Error(`The expression \`this.${o}\` not found.`);!function(e){if(Array.isArray(e)){const[t,n]=e;if(2!==e.length)throw Error("Array length must be 2");if("number"!=typeof t||"number"!=typeof n)throw Error("Array's elements must be `Number`");if(t>n)throw Error("In the array `[min, max]`, min cannot be greater than max")}else if(void 0!==e){if("function"!=typeof e)throw Error("The `bindValue` must be `Function`");if(["","123","12ab","1.2.3.4"].some((t=>{const n=e(t);return n!==e(n)})))throw Error("Make sure `bindValue` function DONOT return dynamic value.")}}(i.value),r.vInputUnwatch=e.$watch(o,((r,a)=>{if("string"==typeof r){let s=n(r,i.value,u);""!==r&&""===s&&""!==a&&(s=n(a,i.value,u)),t(e,o,s)}}));const a=function(e){const t=Object.prototype.toString.call(e).slice(8,-1);return["HTMLInputElement","HTMLTextAreaElement"].indexOf(t)>-1}(r)?r:r.querySelector("input,textarea");if(a){const s=()=>{const r=(a=e,o.split(".").reduce(((e,t)=>e[t]),a));var a;let s=r;u["!0"]&&(isNaN(r)||(s=String(Number(r)),"0"===s&&(s=""))),t(e,o,n(s,i.value,u,"blur"))};a.addEventListener("blur",s),r.vInputBlur=[a,s]}}function i(e){var t;null==(t=e.vInputUnwatch)||t.call(e),e.vInputBlur&&e.vInputBlur[0].removeEventListener("blur",e.vInputBlur[1])}const o={mounted(e,t){const n=t.instance;n&&r(n,e,t)},beforeUnmount:i};var u={install:e=>{e.version.startsWith("2.")?e.directive("input",{bind(e,t,n){r(n.context,e,t)},unbind:i}):e.version.startsWith("3.")&&e.directive("input",o)}};e.default=u,e.directive=o,Object.defineProperty(e,"__esModule",{value:!0}),e[Symbol.toStringTag]="Module"}));
{
"name": "@satrong/v-input",
"version": "0.0.4-alpha.1",
"version": "0.0.4-alpha.2",
"description": "A Vue directive to control HTML input/textarea element value. Support Vue 2 and Vue 3.",

@@ -56,3 +56,3 @@ "keywords": [

"license": "ISC",
"gitHead": "a9faf574718daf8cbd03c9a5aa7f5daf63be285e"
"gitHead": "7fd749ff2ae33d632af2e5f89a7564597767cee4"
}

@@ -78,3 +78,3 @@ A Vue directive to control HTML input/textarea element value. Support Vue 2 and Vue 3.

## bindValue
- `[min, max]` Limit the value range
- `[min, max]` Limit the value range. Trigger by blur event.
- `(val) => string` Custom function. **⚠ DONOT RETURN DYNAMIC VALUE**
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc