Comments (7)
We probably also need a way to format an arbitrary string with given MaskitoOptions
🤔
from maskito.
Since there is no function to get a resulted formatting like formatValue(value: string): string
i've decided to use a hack to fire input
event and trigger all the maskito
processing:
const originalWriteValue = this.ngControl.valueAccessor.writeValue.bind(this.ngControl.valueAccessor);
this.ngControl.valueAccessor.writeValue = (obj: any) => {
originalWriteValue(obj);
this.elRef.nativeElement.dispatchEvent(new Event("input"));
};
Edit: But this leads to multiple valueChanges
events.
from maskito.
Would be great to have this method in the Maskito
class itself.
from maskito.
Input is not formatted after setting value via FormControl methods setValue, patchValue, reset.
Maskito libraries were created to prevent user from typing invalid value.
Maskito listens beforeinput
and input
events.
Programatic changes of input's value (by developer) don't trigger these events!
Of course, we can use MutationObserver
to detect these programatic changes. But it is overkill.
Maskito is based on the assumption that developer is capable to programatically patch input with valid value.
However, Alex suggests good idea that we can add utility-helper for these cases:
We probably also need a way to format an arbitrary string with given
MaskitoOptions
🤔
This issue will be solved in the following issue
from maskito.
Well, it is not affects me as i'm not using the @maskito/angular
library, but as an Angular developer i assume that angular
-library would properly support Angular features by default. Otherwise it seems like a useless library, because you still need to implement your own Angular logic.
from maskito.
Well, it is not affects me as i'm not using the
@maskito/angular
library, but as an Angular developer i assume thatangular
-library would properly support Angular features by default. Otherwise it seems like a useless library, because you still need to implement your own Angular logic.
@nsbarsukov I think other masking solutions watch for programmatic changes too.
from maskito.
@nsbarsukov I think other masking solutions watch for programmatic changes too.
We can take our legacy text-mask as an example.
Programatic update of the value via vanilla JS doesn't trigger value's validations.
Angular package angular2-text-mask
implements ControlValueAccessor
.
Our library doesn't do it (because it doesn't always have direct access to native input).
We suppose that library can be used with Taiga UI, Material, Ant and other design libraries.
from maskito.
Related Issues (20)
- Mask US zipcode with optional dash and 4 digits HOT 5
- Why the last part of any phone number is joined with a - ? HOT 2
- 🚀 - Allow importing plugins and processors HOT 2
- 🐞 - Number mask from kit has problems with processing postfix with dot
- 🐞 - maskitoPhoneOptionsGenerator allows to enter invalid Ukrainian phone number HOT 1
- 🐞 - maskitoWithPlaceholder("DD/MMM/YYYY") blocks input of any month beginning with M
- 🚀 - Fancy currency input HOT 2
- 🐞 - Plugins, that set value into input don't call onInput in React HOT 8
- 🚀 - `Locale`-utilities for `@maskito/kit`
- 🐞 - Formatting errors in the "mm/yyyy" mode
- 🚀 - Formatting when pasting from the clipboard HOT 1
- 🚀 - New plugin to enable validation on every keystroke for composition event (IME) HOT 5
- 🐞 - MaskitPipe in Angular Standalone Component HOT 1
- 🚀 - Support for full width numbers for `maskitoNumberOptionsGenerator`
- 🐞 - Typing multiple full width numbers will delete original value HOT 3
- 🐞 - `min` is not working of `maskitoNumberOptionsGenerator` HOT 2
- 🐞 - Input element masked with date range mask fires InputEvent twice first time HOT 6
- 🚀 - Add full-width numbers support for `Time`, `Date`, `DateTime`, `DateRange` HOT 3
- 🤖 - Rewrite some Cypress tests using component testing
- 🚀 - Angular Standalone Directive not exist in latest package HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from maskito.