IMask

Applies mask on element.

Parameters
el ((HTMLInputElement | HTMLTextAreaElement | MaskElement)) Element to apply mask
opts (Object = {}) Custom mask options
Returns
InputMask:
Static Members
InputMask
Masked
MaskedPattern
MaskedEnum
MaskedRange
MaskedNumber
MaskedDate
MaskedRegExp
MaskedFunction
MaskedDynamic
createMask
MaskElement
HTMLMaskElement

isString

Checks if value is string

isString(str: any): boolean
Parameters
str (any)
Returns
boolean

DIRECTION

Direction

DIRECTION
Properties
NONE (string)
LEFT (string)
FORCE_LEFT (string)
RIGHT (string)
FORCE_RIGHT (string)

Direction

Type: string

indexInDirection

Returns next char index in direction

indexInDirection(pos: number, direction: Direction): number
Parameters
pos (number)
direction (Direction)
Returns
number

posInDirection

Returns next char position in direction

posInDirection(pos: number, direction: Direction): number
Parameters
pos (number)
direction (Direction)
Returns
number

forceDirection

forceDirection(direction: Direction): Direction
Parameters
direction (Direction)
Returns
Direction

escapeRegExp

Escapes regular expression control chars

escapeRegExp(str: string): string
Parameters
str (string)
Returns
string

Selection

Selection range

Selection

Type: {start: number, end: number}

Properties
start (number)
end (number)

InputMask

Listens to element events and controls changes between element and Masked

new InputMask(el: (MaskElement | HTMLInputElement | HTMLTextAreaElement), opts: Object)
Parameters
Instance Members
el
masked
mask
value
unmaskedValue
typedValue
_bindEvents()
_unbindEvents()
_fireEvent(ev)
selectionStart
cursorPos
_saveSelection()
updateValue()
updateControl()
updateOptions(opts)
updateCursor(cursorPos)
_fireChangeEvents()
alignCursor()
alignCursorFriendly()
on(ev, handler)
off(ev, handler)
_onInput()
_onChange()
_onDrop(ev)
_onFocus(ev)
destroy()

ActionDetails

Provides details of changing input

new ActionDetails(value: string, cursorPos: number, oldValue: string, oldSelection: Selection)
Parameters
value (string)
cursorPos (number)
oldValue (string)
oldSelection (Selection)
Instance Members
value
cursorPos
oldValue
oldSelection
startChangePos
insertedCount
inserted
removedCount
removed
head
tail
removeDirection

Mask

Supported mask type

Mask

Type: (string | String | RegExp | Class<Number> | Class<Date> | Array<any> | $PropertyType<Masked<any>, "validate"> | Masked<any> | Class<Masked<any>>)

AppendFlags

Append flags

AppendFlags

Type: {input: boolean?, tail: boolean?, raw: boolean?, _beforeTailState: any?}

Properties
input (boolean?)
tail (boolean?)
raw (boolean?)
_beforeTailState (any?)

ExtractFlags

Extract flags

ExtractFlags

Type: {raw: boolean?}

Properties
raw (boolean?)

Masked

Provides common masking stuff

new Masked(opts: {})
Parameters
opts ({})
Instance Members
mask
parent
prepare
validate
commit
overwrite
isInitialized
updateOptions(opts)
_update(opts)
state
reset()
value
resolve(value)
unmaskedValue
typedValue
rawInputValue
isComplete
nearestInputPos(cursorPos, direction?)
extractInput(fromPos, toPos, flags?)
extractTail(fromPos, toPos)
appendTail(tail)
_appendCharRaw(ch, flags)
_appendChar(ch, flags, checkTail?)
_appendPlaceholder()
append(str, flags?, tail?)
remove(fromPos, toPos)
withValueRefresh(fn)
doPrepare(str, flags)
doValidate(flags)
doCommit()
splice(start, deleteCount, inserted, removeDirection)

MaskedPattern

Pattern mask

new MaskedPattern(opts: Object)

Extends Masked

Parameters
opts (Object = {})
Name Description
opts.blocks Object
opts.definitions Object
opts.placeholderChar string
opts.lazy boolean
Instance Members
blocks
definitions
placeholderChar
lazy
_update(opts)
_rebuildMask()
state
reset()
isComplete
doCommit()
unmaskedValue
value
appendTail(tail)
_appendCharRaw(ch, flags)
extractTail(fromPos, toPos)
extractInput(fromPos, toPos, flags)
_appendPlaceholder(toBlockIndex)
_mapPosToBlock(pos)
_blockStartPos(blockIndex)
_forEachBlocksInRange(fromPos, toPos, fn)
remove(fromPos, toPos)
nearestInputPos(cursorPos, direction)
maskedBlock(name)
maskedBlocks(name)

ChangeDetails

Provides details of changing model value

new ChangeDetails(details: Object?)
Parameters
details (Object?)
Name Description
details.inserted string? Inserted symbols
details.skip boolean? Can skip chars
details.removeCount number? Removed symbols count
details.tailShift number? Additional offset if any changes occurred before tail
Instance Members
inserted
skip
tailShift
rawInserted
aggregate(details)
offset

PatternInputDefinitionOptions

PatternInputDefinitionOptions

Type: {parent: $PropertyType<PatternInputDefinition, "parent">, mask: Mask, isOptional: $PropertyType<PatternInputDefinition, "isOptional">, lazy: $PropertyType<PatternInputDefinition, "lazy">, placeholderChar: $PropertyType<PatternInputDefinition, "placeholderChar">}

Properties
parent ($PropertyType<PatternInputDefinition, "parent">)
mask (Mask)
isOptional ($PropertyType<PatternInputDefinition, "isOptional">)
lazy ($PropertyType<PatternInputDefinition, "lazy">)
placeholderChar ($PropertyType<PatternInputDefinition, "placeholderChar">)

PatternInputDefinition

new PatternInputDefinition(opts: PatternInputDefinitionOptions)
Parameters
Instance Members
masked
parent
isOptional
_isFilled
lazy
placeholderChar

PatternFixedDefinitionOptions

PatternFixedDefinitionOptions

Type: {char: $PropertyType<PatternFixedDefinition, "char">, isUnmasking: $PropertyType<PatternFixedDefinition, "isUnmasking">?}

Properties
char ($PropertyType<PatternFixedDefinition, "char">)
isUnmasking ($PropertyType<PatternFixedDefinition, "isUnmasking">?)

_value

_value

Type: string

char

char

Type: string

isUnmasking

isUnmasking

Type: boolean?

_isRawInput

_isRawInput

Type: boolean?

blockIndex

blockIndex

Type: number?

ContinuousTailDetails

Provides details of continuous extracted tail

new ContinuousTailDetails(value: string, from: number, stop: number?)
Parameters
value (string = '')
from (number = 0)
stop (number?)
Instance Members
value
from
stop

MaskedEnum

Pattern which validates enum values

new MaskedEnum()

Extends MaskedPattern

Instance Members
_update(opts)
doValidate(args)

MaskedRange

Pattern which accepts ranges

new MaskedRange()

Extends MaskedPattern

Instance Members
maxLength
from
to
autofix
_update(opts)
isComplete
doPrepare(str, flags)
doValidate(args)

MaskedNumber

Number mask

new MaskedNumber(opts: Object)

Extends Masked

Parameters
opts (Object)
Name Description
opts.radix string Single char
opts.thousandsSeparator string Single char
opts.mapToRadix Array<string> Array of single chars
opts.min number
opts.max number
opts.scale number Digits after point
opts.signed boolean Allow negative
opts.normalizeZeros boolean Flag to remove leading and trailing zeros in the end of editing
opts.padFractionalZeros boolean Flag to pad trailing zeros after point in the end of editing
Instance Members
radix
thousandsSeparator
mapToRadix
min
max
scale
signed
normalizeZeros
padFractionalZeros
_update(opts)
_updateRegExps()
_removeThousandsSeparators(value)
_insertThousandsSeparators(value)
doPrepare(str, args)
_separatorsCount(to, extendOnSeparators)
_separatorsCountFromSlice(slice)
extractInput(fromPos, toPos, flags?)
_appendCharRaw(ch, flags)
_findSeparatorAround(pos)
remove(fromPos, toPos)
nearestInputPos(cursorPos, direction?)
doValidate(flags)
doCommit()
_normalizeZeros(value)
_padFractionalZeros(value)
unmaskedValue
number
typedValue
allowNegative

MaskedDate

Date mask

new MaskedDate(opts: Object)

Extends MaskedPattern

Parameters
opts (Object)
Instance Members
parse
format
pattern
min
max
autofix
_update(opts)
doValidate(args)
isDateExist(str)
date
typedValue

MaskedRegExp

Masking by RegExp

new MaskedRegExp()

Extends Masked

Instance Members
_update(opts)

MaskedFunction

Masking by custom Function

new MaskedFunction()

Extends Masked

Instance Members
_update(opts)

MaskedDynamic

Dynamic mask for choosing apropriate mask in run-time

new MaskedDynamic(opts: Object)

Extends Masked

Parameters
opts (Object)
Instance Members
currentMask
compiledMasks
dispatch
_update(opts)
_appendCharRaw(args)
doDispatch(appended, flags)
doValidate(args)
reset()
value
unmaskedValue
typedValue
isComplete
remove(args)
state
extractInput(args)
extractTail(args)
doCommit()
nearestInputPos(args)

maskedClass

Get Masked class by mask type

maskedClass(mask: Mask): Class<Masked<any>>
Parameters
mask (Mask)
Returns
Class<Masked<any>>

createMask

Creates new Masked depending on mask type

createMask(opts: {mask: Mask}): Masked<any>
Parameters
opts ({mask: Mask})
Returns
Masked<any>

MaskElement

Generic element API to use with mask

MaskElement
Instance Members
_unsafeSelectionStart
_unsafeSelectionEnd
value
selectionStart
selectionEnd
select(start, end)
_unsafeSelect(start, end)
isActive
bindEvents(handlers)
unbindEvents()

HTMLMaskElement

Bridge between HTMLElement and Masked

new HTMLMaskElement(input: (HTMLInputElement | HTMLTextAreaElement))

Extends MaskElement

Parameters
Static Members
EVENTS_MAP
Instance Members
input
isActive
_unsafeSelectionStart
_unsafeSelectionEnd
_unsafeSelect(start, end)
value
bindEvents(handlers)
unbindEvents()
_toggleEventHandler(event, handler?)