imask

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, args)
selectionStart
cursorPos
_saveSelection()
updateValue()
updateControl()
updateOptions(opts)
updateCursor(cursorPos)
_fireChangeEvents()
alignCursor()
alignCursorFriendly()
on(ev, handler)
off(ev, handler)
_onInput(e)
_onChange()
_onDrop(ev)
_onFocus(ev)
_onClick(ev)
destroy()

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

Direction

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
Properties
start (number)
end (number)

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

MaskedDate

Date mask

new MaskedDate(opts: Object)

Extends MaskedPattern

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

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

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
Properties
input (boolean?)
tail (boolean?)
raw (boolean?)
_beforeTailState (any?)

ExtractFlags

Extract flags

ExtractFlags
Properties
raw (boolean?)

Masked

Provides common masking stuff

new Masked(opts: {})
Parameters
opts ({})
Instance Members
mask
parent
prepare
validate
commit
format
parse
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)
runIsolated(fn)
doPrepare(str, flags)
doValidate(flags)
doCommit()
doFormat(value)
doParse(str)
splice(start, deleteCount, inserted, removeDirection)

PatternInputDefinitionOptions

PatternInputDefinitionOptions
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
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

MaskedRegExp

Masking by RegExp

new MaskedRegExp()

Extends Masked

Instance Members
_update(opts)

MaskedRange

Pattern which accepts ranges

new MaskedRange()

Extends MaskedPattern

Instance Members
maxLength
from
to
autofix
_update(opts)
isComplete
doPrepare(str, flags)
doValidate(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>)): Masked<any>
Parameters
opts (({mask: Mask} | Masked<any>))
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
rootElement
isActive
_unsafeSelectionStart
_unsafeSelectionEnd
_unsafeSelect(start, end)
value
bindEvents(handlers)
unbindEvents()
_toggleEventHandler(event, handler?)

_unsafeSelectionStart

Returns HTMLElement selection start

_unsafeSelectionStart

Type: number

Returns
number

_unsafeSelectionEnd

Returns HTMLElement selection end

_unsafeSelectionEnd

Type: number

Returns
number

_unsafeSelect

Sets HTMLElement selection

_unsafeSelect(start: number, end: number)
Parameters
start (number)
end (number)

value

HTMLElement value

value

Type: string

Returns
string

IMask

Applies mask on element.

Parameters
el ((HTMLInputElement | HTMLTextAreaElement | MaskElement)) Element to apply mask
opts (Object = {}) Custom mask options
Returns
InputMask: