{"_id":"@algrith/safari-numfix","_rev":"2-53cfca9eb0c83e56c0d09e09e22a9aa3","name":"@algrith/safari-numfix","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@algrith/safari-numfix","version":"1.0.0","keywords":["safari","paste","number input","keydown","input-sanitization","form-validation"],"author":{"url":"https://algrith-astongemmy.vercel.app","name":"Algrith LLC","email":"algrithllc@gmail.com"},"license":"MIT","_id":"@algrith/safari-numfix@1.0.0","maintainers":[{"name":"astongemmy","email":"astongemmy@gmail.com"}],"homepage":"https://github.com/algrith/safari-numfix.git","bugs":{"url":"https://github.com/algrith/safari-numfix/issues"},"dist":{"shasum":"775268bc01bd02d82290f6dc10256e9c0a1999f8","tarball":"https://registry.npmjs.org/@algrith/safari-numfix/-/safari-numfix-1.0.0.tgz","fileCount":13,"integrity":"sha512-g9fz6mK12wRGZ+gTLU6WOhjQ2kGiHti5uC5VesUtED8Tl+WZ+GYCmyRHMH+y/OmlMOeJEJeJA2G84EPvmnPvLg==","signatures":[{"sig":"MEUCIQD/iJhjZ6c6qzONHNtZbTKMch6EGv3qlTDQyQ/U1nnBjwIgRo1BT2yPTQTRIPdOwD2+aWzJF95symKDC7fcYza7PdM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":48996},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","unpkg":"dist/index.umd.js","module":"dist/index.module.js","source":"src/index.ts","engines":{"node":"18.0.0 - 22.x.x"},"gitHead":"376901308650d70c14dd1ad0caae423873f354c5","scripts":{"dev":"microbundle --css-modules true watch","build":"microbundle --css-modules true"},"_npmUser":{"name":"astongemmy","email":"astongemmy@gmail.com"},"repository":{"url":"git+https://github.com/algrith/safari-numfix.git","type":"git"},"_npmVersion":"10.9.2","description":"A lightweight utility to safely handle paste & keydown events on <input type=\"number\"> fields in Safari. Provides a browser-aware workaround that preserves caret position, sanitizes multiple decimal points, and works with React, Vue, Angular, or vanilla J","directories":{},"_nodeVersion":"22.13.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.2","microbundle":"^0.15.1"},"_npmOperationalInternal":{"tmp":"tmp/safari-numfix_1.0.0_1744868090845_0.01359016562865345","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"repository":{"url":"git+https://github.com/algrith/safari-numfix.git","type":"git"},"homepage":"https://github.com/algrith/safari-numfix.git","name":"@algrith/safari-numfix","module":"dist/index.module.js","unpkg":"dist/index.umd.js","source":"src/index.ts","main":"dist/index.js","version":"1.0.2","type":"module","scripts":{"dev":"microbundle --css-modules true watch","build":"microbundle --css-modules true"},"devDependencies":{"microbundle":"^0.15.1","typescript":"^5.7.2"},"engines":{"node":"18.0.0 - 22.x.x"},"description":"A lightweight utility to safely handle paste & keydown events on <input type=\"number\"> fields in Safari. Provides a browser-aware workaround that preserves caret position, sanitizes multiple decimal points, and works with React, Vue, Angular, or vanilla J","keywords":["safari","paste","number input","keydown","input-sanitization","form-validation"],"author":{"name":"Algrith LLC","email":"algrithllc@gmail.com","url":"https://algrith-astongemmy.vercel.app"},"license":"MIT","types":"./dist/index.d.ts","bugs":{"url":"https://github.com/algrith/safari-numfix/issues"},"publishConfig":{"access":"public"},"_id":"@algrith/safari-numfix@1.0.2","gitHead":"376901308650d70c14dd1ad0caae423873f354c5","_nodeVersion":"22.13.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-o8B7El1YhiJwegB6TFEQmHdtxkvmN+35W6KFt9DVyLLLlfWVlsZrMqh7izqP732w/Mza7RYJX3Lz5YVZscG8IA==","shasum":"ab7666691ebba0736fe7e06b1de0d401babf2e23","tarball":"https://registry.npmjs.org/@algrith/safari-numfix/-/safari-numfix-1.0.2.tgz","fileCount":13,"unpackedSize":49045,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDlEnZEVJ/Wlj4ezHUDD4t+TW643GDXQ/HZfHO64RK8EgIgExQYk9CvBchanGtw7UW2vvbWVdHnxoWuNb2keHE9gMA="}]},"_npmUser":{"name":"astongemmy","email":"astongemmy@gmail.com"},"directories":{},"maintainers":[{"name":"astongemmy","email":"astongemmy@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/safari-numfix_1.0.2_1744869227282_0.3906932314776652"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-17T05:34:50.762Z","modified":"2025-04-17T05:53:47.659Z","1.0.0":"2025-04-17T05:34:51.024Z","1.0.2":"2025-04-17T05:53:47.469Z"},"bugs":{"url":"https://github.com/algrith/safari-numfix/issues"},"author":{"name":"Algrith LLC","email":"algrithllc@gmail.com","url":"https://algrith-astongemmy.vercel.app"},"license":"MIT","homepage":"https://github.com/algrith/safari-numfix.git","keywords":["safari","paste","number input","keydown","input-sanitization","form-validation"],"repository":{"url":"git+https://github.com/algrith/safari-numfix.git","type":"git"},"description":"A lightweight utility to safely handle paste & keydown events on <input type=\"number\"> fields in Safari. Provides a browser-aware workaround that preserves caret position, sanitizes multiple decimal points, and works with React, Vue, Angular, or vanilla J","maintainers":[{"name":"astongemmy","email":"astongemmy@gmail.com"}],"readme":"<h4 align=\"center\">\n  <a href=\"#\">Algrith Safari Number Fix (safari-numfix)</a>\n</h4>\n\n<div align=\"center\">\n  <h2>\n    🧩 A lightweight utility to safely handle paste and keydown events on number input fields in Safari.\n  </h2>\n</div>\n\nSafari has a sanitization deficiency in `<input type=\"number\">` fields compared to modern browsers. It allows non-numeric characters and multiple decimal points, leading to unexpected or invalid values. This package provides a browser-aware workaround that intercepts paste & keydown events, corrects invalid numeric formats, and updates the input value correctly.\n\n<br />\n<p align=\"center\">\n  <a href=\"https://github.com/astongemmy/safari-numfix/main/LICENSE\">\n    <img alt=\"Algrith Safari Number Fix (safari-numfix) is released under the MIT license.\" src=\"https://img.shields.io/badge/license-MIT-blue.svg\" />\n  </a>\n  <a href=\"https://www.npmjs.com/package/@algrith/safari-numfix\">\n    <img alt=\"npm downloads/month\" src=\"https://img.shields.io/npm/dm/@algrith/safari-numfix\" />\n  </a>\n</p>\n\n\n##  🚀 Features\n\n- ✅ Ignores paste actions that include non-numeric characters\n- ✅ Fixes Safari-specific paste behavior for number inputs\n- ✅ Works with React, Vue, Angular, or plain JavaScript\n- ✅ Maintains accurate caret position on insert\n- ✅ Ensures only one decimal point is allowed\n- ✅ Restricts non-numeric entries on keydown\n- ✅ TypeScript support\n\n\n##  📦 Installation\n\n```bash\nnpm install @algrith/safari-numfix\n# or\nyarn add @algrith/safari-numfix\n```\n\n\n##  🔧 Usage\n\n### ReactJs\n\n```tsx\nimport { keyDownEventHandler, pasteEventHandler } from '@algrith/safari-numfix';\n\nconst handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n  console.log(event.target.value);\n};\n\n<input\n  onPaste={(e) => pasteEventHandler(e, handleChange)}\n  onKeyDown={keyDownEventHandler}\n  onChange={handleChange}\n  type=\"number\"\n/>\n```\n\n\n### VueJs\n\n```vue\n<script setup>\nimport { keyDownEventHandler, pasteEventHandler } from '@algrith/safari-numfix';\n\nconst handleChange = (e) => {\n  console.log(e.target.value);\n};\n</script>\n\n<template>\n  <input\n    @paste=\"(e) => pasteEventHandler(e, handleChange)\"\n    @keydown=\"keyDownEventHandler\"\n    @input=\"handleChange\"\n    type=\"number\"\n  />\n</template>\n```\n\n### Angular\n\n```ts\nimport { keyDownEventHandler, pasteEventHandler } from '@algrith/safari-numfix';\n\nonKeyDown(event: KeyboardEvent) {\n  keyDownEventHandler(event);\n};\n\nonPaste(event: ClipboardEvent) {\n  pasteEventHandler(event, this.onChange.bind(this));\n}\n```\n\n### VanillaJs\n\n```html\n<input id=\"numInput\" type=\"number\" />\n\n<script type=\"module\">\n  import { keyDownEventHandler, pasteEventHandler } from 'https://cdn.skypack.dev/@algrith/safari-numfix';\n\n  const input = document.getElementById('numInput');\n\n  input.addEventListener('keydown', keyDownEventHandler);\n\n  input.addEventListener('paste', (e) => {\n    pasteEventHandler(e, (event) => {\n      console.log('Updated value:', event.target.value);\n    });\n  });\n</script>\n```\n\n\n##  TypeScript Support\n\nTypes files can be found at https://github.com/algrith/safari-numfix/tree/main/src/types.ts.\n\n\n## Contributing\n\n- Missing something or found a bug? [Report here](https://github.com/algrith/safari-numfix/issues).","readmeFilename":"README.md"}