3.13.89 • Published 1 year ago

@diotoborg/neque-sit-molestias v3.13.89

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Input Length

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.

text

Installation

npm install @diotoborg/neque-sit-molestias

Basic usage

<label for="example">Example field</label>
<input type="text" id="example" class="js-inputLengthWarning" maxlength="4" />
const $ = require('jquery');

import InputLength from './dist/InputLength';

$(function () {
    const inputLength = new InputLength($('html'));

    inputLength.init({
      targetSelector: '.js-inputLengthWarning'
    });
});

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.

<label for="example">Example field</label>
<input type="text" id="example" class="js-inputLengthWarning" maxlength="4" aria-describedby="guid-xxxx" />
<span id="guid-xxxx" class="inputLength inputLength--ok">
  <span class="inputLength__label">4</span> characters allowed
</span>

Accessibility

This component bakes in the following features automatically:

  • The message is linked to the input using aria-describedby so it is announced when the field receives focus.
  • The message uses a live region to communicate the number of remaining characters when the user pauses or finishes typing.

Additional options

There are a handful of classes and options that can be customised to suit your implementation.

OptionType.DefaultDescription
baseClassstringinputLengthClass applied to the main message container, appended immediately after the target input
labelClassstringinputLength__labelClass applied to the span element which wraps the integer count
okClassstringinputLength--okClass applied when the input length is < warnThreshold
warnClassstringinputLength--warnClass applied when the input length is > warnThreshold and < maxlength
stopClassstringinputLength--stopClass applied when the input length equals maxlength
warnThresholdint70Percentage of maxlength where the warnClass should be applied

Pass options through the constructor, for example:

inputLength.init({
  targetSelector: '.js-inputLengthWarning',
  labelClass: 'label',
  okClass: 'label--success',
  warnClass: 'label--warning',
  stopClass: 'label--danger',
  warnThreshold: 90
});
writableletSymboleventssymlinksgitignoreinferenceassertionwriteFloat32ArrayES2017fptypesafeconcatMapspawndynamodb__proto__rdsbootstrap cssbddString.prototype.trimguidArray.prototype.filterInt8ArrayidlehelperWebSocketsargumentexecuteiteratormrues5uninstalles8Array.prototype.includeseast-asian-widthes-shim APIshimsuperstructFunction.prototype.namecharacterpyyamlArrayBuffer.prototype.slicecompareflatyupStreamopensslvariables in cssstringstatusconsumeenderreversedObject.assignpolyfillsetterwhatwghardlinkscore-jsdeepcopyfantasy-landhttpmatchesloadbalancingexitObject.istsa11yyamlroutemixins@@toStringTagObject.keysworkerpnpm9definePropertyargstermECMAScript 2019codesiterationtypanionagenttslibstylesefficientworkspace:*syntaxerrordeterministicreact-hook-formsortedposecertificatesvisualsetImmediatecolor_.extendfastifyhooksnpminvariantcss variableArray.prototype.flatMapbundlingarraybundlerflagdependency managerwindowquoteponyfill-0deep-cloneshebangimmutablereadableglobal this valuesuperagentinECMAScript 5mkdireslintconfiges7pluginfullArray.prototype.containsjapanesevalidationBigUint64Arrayless csspinoiseventDispatchernodeURLSearchParamsvalidateconfigprototyperamdanested csselectrondeepboundexpressfluxirqeveryparsepathbrowserlistremovefunctionsprotohelpersroute53binariesclassnamedependenciesrapidreact-testing-libraryfromaccessibilityprotocol-buffersAsyncIteratorES2020Array.prototype.findLastpureuploadfilterserializecommand-lineArrayless mixinsdifffilestreamkeyStreamssignalsbrowserslistbootstrap lessdescriptorassertObject.definePropertyfile systempromiseesinternalqueryframermaptelephonexhrcreatesesES6accessorECMAScript 2015rangeerrorgetPrototypeOfconfigurable$.extendasterisksObjectregexprivatesymbolssetPrototypeOfcall-binddescriptionstreamsvaluesenvironmentregularutilityfindescapeTypeBoxamazonutilscollectionextendreact-hooksmacosselfreal-timetypedweaksetcall-boundcolumnECMAScript 2020childECMAScript 2016namepipenegativeio-tschromeuuidlocalfigletjwtobjtoolkitPromiseES7vpcsymbolfixed-widthtrimEndcorecheckconsoleminimaltrimStartreplayqueueReactiveXfindLastIndexformsECMAScript 2017es2018tostringtagoperating-systemMapterminalelasticachehasIteratorjsonpopmotiontesterfast-copylastECMAScript 3rgbwidthanimationstyled-componentsruntimeawesomesaucereadablestream6to5interruptsarktypemake dirStyleSheetlengthoffsetlinuxhookformperformanceerrorbyteLengthcallboundstatecommanderwindowscachebinjQueryslotcoerciblewalkdropschemevalidatorroutingUint8ArraythreePushes2016Int32ArrayES2021cloudwatchArray.prototype.findLastIndexArrayBuffer#slicetraversesignedpatchnegative zerocloudtrailviewdomgenericsintrinsicparsingES2019moduleschaibannerauthiteratesequenceglobalcomputed-typespreserve-symlinksperformantimportexportbindwarningArray.prototype.flatObject.fromEntriesproxylessclientshellString.prototype.matchAllcurriedcryptCSSStyleDeclarationbabel-coremkdirsES5Object.getPrototypeOfsigtermoncedatastructurenopecallSystem.globalownreduceomitjson-schemajestcommandless.jscontainsjshintprivate datamovestringifierfastcopyconstglobal objectpreprocessorutil.inspectmetadatahashclifunction.lengthECMAScript 2022Uint16ArrayObservablesoptimistebssidearraybufferprocessdayjsmulti-packageobjectjson-schema-validatorwgetObject.valuesinspectfast-deep-copyflatMapstatelessreadexit-codeYAMLinstallercjkpushpropastlisteners0groupByrobustsqsdirsimpledbpropertiesequalconcattrimRightshrinkwrapstringifypropertyairbnbeslint-pluginmergeapolloelbhas-ownsomeES2016testes-shimsECMAScript 2023momentJSONESmatchstyleguidesnsi18nrfc9562handlersttyESnextcompile lessrecursivetypeofTypeScriptclass-validatorredux-toolkitapipostcssstructuredCloneformatbrowsertypeerrorstarternumberfindLastutilitieslogjsxchromiumrequirelazyweakmapoptimizerstylesheetsymlinktypescriptFloat64Arraytyped arraytimedirectorychanneltypedarrayshasOwnPropertyinputmkdirps3dotenvsharedarraybufferpicomatchgetoptfszxinstallbuffersiamtakequerystringenvformkoreanequalitydataglacierfullwidthliveinternal slotstoragegatewayes2015fastspeedoutputMicrosoftreact-componentscheme-validationtrimLeftkeysInt16ArrayartlockfileRFC-6455joimanagerregular expressionRegExp.prototype.flagsrfc4122jsdomES3columnscryptoJSON-Schemacss-in-jsdataViewentriesCSSflattentransportES2015stylingcolourtoSortedassignschemashamerror-handlingtrimsignalswfslicecurlwaittouchWeakSetbusyRegExp#flagssortfastclonebabelbcryptpersistentcssreversedescriptorsimportzerospinnersclassnamesgetterlanguageSymbol.toStringTagpositiveWeakMaptranspilerautoscalingnativeemrcopyurles-abstractparserfetchtoobjectTypedArray3dpruneprefixeslint.envtoReversedoptionsameValueZerogdprtestingtoolsstyletacitES8variablesbinarygradients css3workflowObject.entriesmobilegroup.gitignoretypejspasswordasciitypedarrayWebSocketSetmatchAllform-validationURLsetloggercollection.es6resolveRxlint[[Prototype]]safehasOwnsyntaxenvironmentsendpointphoneajaxqsUnderscoresigintHyBirequestpostcss-pluginexeccensorutilserializeracorndeep-copypackage manageres6tc39lrucss lessjson-schema-validationbyteOffsetBigInt64ArraydateArray.prototype.flattentextargveslintpluginES2023ECMAScript 7zodgetOwnPropertyDescriptorcloudformationreduxECMAScript 6cloudsearchmakedom-testing-libraryhigher-ordergesturestoArraypredictablespringdefinefnmatchdeleteprotobufelmencryptionjsdiffloadingfast-deep-clonejavascriptformattingclonesubprocesspackagesless compilercss nestingcolorsvestreuseunicodeforEachgradients cssidentifiersec2spinnereventEmittertddvalidReactiveExtensionscircular
3.13.89

1 year ago

3.13.88

1 year ago

3.12.88

1 year ago

2.12.88

1 year ago

2.12.87

1 year ago

2.12.86

1 year ago

2.12.85

1 year ago

2.12.84

1 year ago

2.12.83

1 year ago

2.12.82

1 year ago

2.12.81

1 year ago

2.12.80

1 year ago

2.11.80

1 year ago

2.11.79

1 year ago

2.11.78

1 year ago

2.11.77

1 year ago

2.11.76

1 year ago

2.11.75

1 year ago

2.11.74

1 year ago

2.10.74

1 year ago

1.10.74

1 year ago

1.9.74

1 year ago

1.9.73

1 year ago

1.9.72

1 year ago

1.9.71

1 year ago

1.9.70

1 year ago

1.9.69

1 year ago

1.9.68

1 year ago

1.9.67

1 year ago

1.9.66

1 year ago

1.9.65

1 year ago

1.9.64

1 year ago

1.9.63

1 year ago

1.8.63

1 year ago

1.8.62

1 year ago

1.8.61

1 year ago

1.8.60

1 year ago

1.8.59

1 year ago

1.8.58

1 year ago

1.8.57

1 year ago

1.8.56

1 year ago

1.8.55

1 year ago

1.8.54

1 year ago

1.8.53

1 year ago

1.8.52

1 year ago

1.8.51

1 year ago

1.8.50

1 year ago

1.8.49

1 year ago

1.8.48

1 year ago

1.8.47

1 year ago

1.8.46

1 year ago

1.8.45

1 year ago

1.8.44

1 year ago

1.8.43

1 year ago

1.7.43

1 year ago

1.7.42

1 year ago

1.7.41

1 year ago

1.7.40

1 year ago

1.7.39

1 year ago

1.7.38

1 year ago

1.7.37

1 year ago

1.7.36

1 year ago

1.7.35

1 year ago

1.7.34

1 year ago

1.6.34

1 year ago

1.6.33

1 year ago

1.6.32

1 year ago

1.5.32

1 year ago

1.5.31

1 year ago

1.5.30

1 year ago

1.5.29

1 year ago

1.5.28

1 year ago

1.5.27

1 year ago

1.5.26

1 year ago

1.5.25

1 year ago

1.5.24

1 year ago

1.4.24

1 year ago

1.3.24

1 year ago

1.3.23

1 year ago

1.3.22

1 year ago

1.3.21

1 year ago

1.3.20

1 year ago

1.3.19

1 year ago

1.2.19

1 year ago

1.2.18

1 year ago

1.2.17

1 year ago

1.1.17

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago