| 1 |
import HTMLMaskElement from './html-mask-element.js'; |
| 2 |
import IMask from '../core/holder.js'; |
| 3 |
import './mask-element.js'; |
| 4 |
|
| 5 |
/** Bridge between InputElement and {@link Masked} */ |
| 6 |
class HTMLInputMaskElement extends HTMLMaskElement { |
| 7 |
/** InputElement to use mask on */ |
| 8 |
|
| 9 |
constructor(input) { |
| 10 |
super(input); |
| 11 |
this.input = input; |
| 12 |
} |
| 13 |
|
| 14 |
/** Returns InputElement selection start */ |
| 15 |
get _unsafeSelectionStart() { |
| 16 |
return this.input.selectionStart != null ? this.input.selectionStart : this.value.length; |
| 17 |
} |
| 18 |
|
| 19 |
/** Returns InputElement selection end */ |
| 20 |
get _unsafeSelectionEnd() { |
| 21 |
return this.input.selectionEnd; |
| 22 |
} |
| 23 |
|
| 24 |
/** Sets InputElement selection */ |
| 25 |
_unsafeSelect(start, end) { |
| 26 |
this.input.setSelectionRange(start, end); |
| 27 |
} |
| 28 |
get value() { |
| 29 |
return this.input.value; |
| 30 |
} |
| 31 |
set value(value) { |
| 32 |
this.input.value = value; |
| 33 |
} |
| 34 |
} |
| 35 |
IMask.HTMLMaskElement = HTMLMaskElement; |
| 36 |
|
| 37 |
export { HTMLInputMaskElement as default }; |
| 38 |
|