1.0.2 • Published 6 years ago

input-ip v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

input-ip

an angular 2 IPv4, IPv6 and MAC ADDRESS input component

input-ip is an IPv4/6 and mac address input component that implements block level IP inputs, each block has it's own input element for better UX control.

This allows highlighting specific blocks with invalid syntax, disabling specific blocks (limit pools, etc...) and more.

input-ip is NOT a mask component, masking is a different approach which uses one input element for the whole IP address.

Install:

npm install input-ip --save or yarn add input-ip --save

Dev:

Download modules: npm i Launch dev server: npm start Build input-ip module (into release folder): npm run release Push to npm: npm publish --access public ./release

DEMO:

https://shlomiassaf.github.io/ng2-ip

Features

  • Supports IPv4, IPv6 and mac address
  • Control if user can type invalid characters
  • Separator behaves like TAB (e.g: in IPv4 pressing dot (.) is like pressing TAB)
  • Support paste (single value or whole address)
  • Support copy block or address
  • Disable specific blocks
  • Highlight invalid blocks (does not replace validation)
  • Themes
  • Implements OnPush
  • Supports AOT

Validation

input-ip performs internal validation at the block level to allow invalid block highlighting.

Block validation does not replace form validation, if you use angular forms you still need to validate the output, as you need with any other control.

Should I use input-ip or mask?

Well, this depends on your requirements, here are some key points:

Copy / Paste

input-ip offers better UX but since it has multiple input elements it has a different copy/paste (CMD/CTRL-C/V) behaviour.

When pasting, input-ip will auto detect the content and handle full address automatically.

When copying, input-ip has 3 copy modes to choose from, these modes fire only if the whole text in a block is selected otherwise copy behavior is native.

  • Block mode: This is similar to the native copy mode, when fired it will copy the content of the block.
  • Address mode: This will copy the whole address.
  • Select mode: Once fired the user will be prompted to select Block or Address copy.
    This mode is not supported in browsers that does not support the document.execCommand('copy'); method (Safari 9), if set in such browser it will fallback to Block mode.

Rendering

input-ip renders more input elements.
This should have no effect on performance, unless you render 1000+ components and if you do you're doing something wrong :)

If these are deal breakers for you you should definitely use a mask component, here are some examples Text Mask, PrimeNG Input Mask, etc...