Gathering detailed insights and metrics for @diotoborg/neque-sit-molestias
Gathering detailed insights and metrics for @diotoborg/neque-sit-molestias
Gathering detailed insights and metrics for @diotoborg/neque-sit-molestias
Gathering detailed insights and metrics for @diotoborg/neque-sit-molestias
npm install @diotoborg/neque-sit-molestias
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
8
Last Day
1
Last Week
4
Last Month
6
Last Year
8
1,775 Commits
1 Watching
1 Branches
1 Contributors
Latest Version
3.13.89
Package Id
@diotoborg/neque-sit-molestias@3.13.89
Unpacked Size
224.39 kB
Size
116.83 kB
File Count
611
NPM Version
10.8.2
Node Version
20.17.0
Publised On
22 Sept 2024
Cumulative downloads
Total Downloads
Last day
-50%
1
Compared to previous day
Last week
100%
4
Compared to previous week
Last month
200%
6
Compared to previous month
Last year
0%
8
Compared to previous year
29
This component creates a visual representation of the maxlength
constraint
and updates it as the user interacts with that field, with customisation
to allow custom classes and styling.
npm install @diotoborg/neque-sit-molestias
1<label for="example">Example field</label> 2<input type="text" id="example" class="js-inputLengthWarning" maxlength="4" />
1const $ = require('jquery'); 2 3import InputLength from './dist/InputLength'; 4 5$(function () { 6 const inputLength = new InputLength($('html')); 7 8 inputLength.init({ 9 targetSelector: '.js-inputLengthWarning' 10 }); 11});
A new element will be inserted immediately after the target input, and new
attributes will be added. The aria-describedby
guid will be added to
the existing aria-describedy value if one is already present.
1<label for="example">Example field</label> 2<input type="text" id="example" class="js-inputLengthWarning" maxlength="4" aria-describedby="guid-xxxx" /> 3<span id="guid-xxxx" class="inputLength inputLength--ok"> 4 <span class="inputLength__label">4</span> characters allowed 5</span>
This component bakes in the following features automatically:
aria-describedby
so it is announced
when the field receives focus.There are a handful of classes and options that can be customised to suit your implementation.
Option | Type. | Default | Description |
---|---|---|---|
baseClass | string | inputLength | Class applied to the main message container, appended immediately after the target input |
labelClass | string | inputLength__label | Class applied to the span element which wraps the integer count |
okClass | string | inputLength--ok | Class applied when the input length is < warnThreshold |
warnClass | string | inputLength--warn | Class applied when the input length is > warnThreshold and < maxlength |
stopClass | string | inputLength--stop | Class applied when the input length equals maxlength |
warnThreshold | int | 70 | Percentage of maxlength where the warnClass should be applied |
Pass options through the constructor, for example:
1inputLength.init({ 2 targetSelector: '.js-inputLengthWarning', 3 labelClass: 'label', 4 okClass: 'label--success', 5 warnClass: 'label--warning', 6 stopClass: 'label--danger', 7 warnThreshold: 90 8});
No vulnerabilities found.
No security vulnerabilities found.