![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
org.webjars.npm:custom-input
Advanced tools
A library helps you create custom input elements in the browser. Add mask and validation to input[text]! Originally included in angular-datetime.
It has 2 components, InputMask and TextParser. Import them with require
:
var {InputMask, TextParser} = require("custom-input");
Or you can use the pre-built dist:
<!-- export cusomInput into global -->
<script src="path/to/custom-input/dist/custom-input.js"></script>
var {InputMask, TextParser} = customInput;
The pre-built dist is compatible with IE 8 by transpiling using Babel and babel-polyfill.
npm install -S custom-input
A small example showing how it works: https://rawgit.com/eight04/custom-input/master/demo.html
Both TextParser and InputMask extend event-lite.
Create a stateful parser which can convert a model to a string and vise versa. The parser uses a series of Token to form a text template. For example, the IP address: xxx.xxx.xxx.xxx
can be represented with 7 tokens, which are Number{1,3}, String ".", Number{1,3}, String ".", Number{1,3}, String ".", Number{1,3}. The parser will try to parse text along the tokens, extract the value from text and convert them into the model.
value => clone(value)
Parse the string and create a model value. The value is saved in the parser.
Set model value and convert to text.
If preserveEmptyFlag is not true, parser will reset all empty flag to false before converting to text.
Get model value in the parser.
Get text in the parser.
If text is supplied, parse the text without saving data and check if the text contains empty node.
If omitted, check if the text in the parser contains empty node.
Return true if there is no empty node.
Mark every nodes empty.
Get node list. If name
is provided, return the nodes having the same name.
A token is an object that contains special information for parsing. Each token may represents a static string, a number, or a choice list.
Optional name. See TextParser.getNodes()
.
Can be static
, number
, or select
, which represents 3 different types of node.
A placeholder to show when the node is empty.
The string value.
A list of word that the string should match.
When converting text to model, parser will get the index of matched text, plus 1, then save as node value.
If there are two nodes whose value has been changed in the same time, the node having higher prior will apply the change to the model first.
Next 4 optional properties only affect tokens with number type:
The min length of the number.
The max length of the number.
The min value of the number.
The max value of the number.
Following functions are used to manipulate model value.
A function that can extract node value from the model. It is used to convert model value to string.
A function that can add node value to the model.
A function that can restore node value to the model.
InputMask is built on top of an input element and a TextParser. It handles most of the HTML stuff like listening to events, tracking selection range of the input element...
After the mask is applied, user can only edit partial text that is not defined as "static". User can also press left/right arrow keys or tab to navigate between each non-static node. Use up/down arrow keys to increase/decrease node value. If it is a "select" node, it will act like a typeahead component. If the user try to delete the node, it will be replaced by a placeholder.
Arguments:
The mask will try to parse the text. If there are any errors, try fixing it and parse it again.
Arguments:
node - can be null
If node is null, digest will parse text as textParser.parse(text)
.
If node is a Node, digest will parse text as node.parse(text)
.
text
The text to parse.
fixError - default to false
If fixError is true, digest will try hardest to fix the error, even revert back the text to previous state.
If fixError is false, digest will fix those fatal error, but leaves NUMBER_TOOSHORT
, LEADING_ZERO
...
The Element interface wraps native input element and exposes some methods similar to jQuery.
Wrap addEventListener. InputMask will listen to input
event for text update, you might want to proxy it for cross browser compatibility.
InputMask uses following events:
Range object has two properties, start and end, showing the current state of the selection.
Return null if the element is not focused.
Set selection on the input. You might need to check if the input is active or some browsers will try to focus the input when selection changed.
Set/get the value of the input. Like jQuery.
Convert number to string, padding with zeros and trim out text after maxLength.
textParser
arg to token.add
and token.restore
.name
attribute to Node
.name
arg to TextParser.getNodes
.FAQs
WebJar for custom-input
We found that org.webjars.npm:custom-input demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.