use-mask-input 1.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/example/App.example.d.ts +3 -0
  2. package/dist/{useMaskInput.test.d.ts → example/index.d.ts} +0 -0
  3. package/dist/index.js +1 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.modern.js +1 -2
  6. package/dist/index.modern.js.map +1 -1
  7. package/dist/useMaskInput.d.ts +3 -3
  8. package/node_modules/inputmask/README.md +109 -79
  9. package/node_modules/inputmask/bundle.js +6 -5
  10. package/node_modules/inputmask/dist/inputmask.es6.js +5 -0
  11. package/node_modules/inputmask/dist/inputmask.js +2892 -2608
  12. package/node_modules/inputmask/dist/inputmask.min.js +3 -3
  13. package/node_modules/inputmask/dist/jquery.inputmask.js +2829 -2534
  14. package/node_modules/inputmask/dist/jquery.inputmask.min.js +3 -3
  15. package/node_modules/inputmask/lib/bindings/inputmask.es6.js +5 -0
  16. package/node_modules/inputmask/lib/canUseDOM.js +7 -0
  17. package/node_modules/inputmask/lib/defaults.js +101 -0
  18. package/node_modules/inputmask/lib/definitions.js +13 -0
  19. package/node_modules/inputmask/lib/dependencyLibs/data.js +8 -0
  20. package/node_modules/inputmask/lib/dependencyLibs/events.js +199 -0
  21. package/node_modules/inputmask/lib/dependencyLibs/extend.js +58 -0
  22. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.jquery.js +4 -3
  23. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.js +12 -343
  24. package/node_modules/inputmask/lib/environment.js +9 -0
  25. package/node_modules/inputmask/lib/escapeRegex.js +4 -0
  26. package/node_modules/inputmask/lib/eventhandlers.js +513 -0
  27. package/node_modules/inputmask/lib/eventruler.js +124 -0
  28. package/node_modules/inputmask/lib/extensions/inputmask.date.extensions.js +552 -385
  29. package/node_modules/inputmask/lib/extensions/inputmask.extensions.js +116 -97
  30. package/node_modules/inputmask/lib/extensions/inputmask.numeric.extensions.js +594 -565
  31. package/node_modules/inputmask/lib/global/window.js +2 -6
  32. package/node_modules/inputmask/lib/inputHandling.js +252 -0
  33. package/node_modules/inputmask/lib/inputmask.js +129 -126
  34. package/node_modules/inputmask/lib/inputmaskElement.js +26 -20
  35. package/node_modules/inputmask/lib/jquery.inputmask.js +3 -1
  36. package/node_modules/inputmask/lib/keycode.json +6 -1
  37. package/node_modules/inputmask/lib/mask-lexer.js +467 -0
  38. package/node_modules/inputmask/lib/mask.js +244 -0
  39. package/node_modules/inputmask/lib/masktoken.js +13 -0
  40. package/node_modules/inputmask/lib/polyfills/Array.includes.js +48 -0
  41. package/node_modules/inputmask/lib/polyfills/Object.getPrototypeOf.js +7 -0
  42. package/node_modules/inputmask/lib/positioning.js +348 -0
  43. package/node_modules/inputmask/lib/validation-tests.js +597 -0
  44. package/node_modules/inputmask/lib/validation.js +664 -0
  45. package/node_modules/inputmask/package.json +41 -71
  46. package/package.json +40 -43
  47. package/node_modules/inputmask/CHANGELOG.md +0 -714
  48. package/node_modules/inputmask/index.js +0 -1
  49. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.jqlite.js +0 -170
  50. package/node_modules/inputmask/lib/maskScope.js +0 -2498
  51. package/node_modules/inputmask/lib/maskset.js +0 -466
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare function App(): JSX.Element;
3
+ export default App;
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ var react = require('react');
4
4
  var Inputmask = _interopDefault(require('inputmask'));
5
5
 
6
6
  function _extends() {
7
- _extends = Object.assign || function (target) {
7
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
8
8
  for (var i = 1; i < arguments.length; i++) {
9
9
  var source = arguments[i];
10
10
 
@@ -17,7 +17,6 @@ function _extends() {
17
17
 
18
18
  return target;
19
19
  };
20
-
21
20
  return _extends.apply(this, arguments);
22
21
  }
23
22
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/useMaskInput.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport Inputmask, { Options as InputMaskOptions } from 'inputmask'\n\ninterface UseInputMaskOptions {\n mask: InputMaskOptions['mask']\n register?(element: HTMLElement): void\n options?: InputMaskOptions\n}\n\nconst useInputMask = (props: UseInputMaskOptions) => {\n const { mask, register, options } = props\n\n const ref = useRef<HTMLInputElement>(null)\n\n useEffect(() => {\n if (!ref.current) {\n return\n }\n\n const maskInput = Inputmask({\n mask,\n ...options\n })\n\n maskInput.mask(ref.current)\n\n if (register && ref.current) {\n register(ref.current)\n }\n }, [mask, register, options])\n\n return ref\n}\n\nexport default useInputMask\n"],"names":["useInputMask","props","mask","register","options","ref","useRef","useEffect","current","maskInput","Inputmask"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AASA,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,KAAD;MACXC,OAA4BD,MAA5BC;MAAMC,WAAsBF,MAAtBE;MAAUC,UAAYH,MAAZG;AAExB,MAAMC,GAAG,GAAGC,YAAM,CAAmB,IAAnB,CAAlB;AAEAC,EAAAA,eAAS,CAAC;AACR,QAAI,CAACF,GAAG,CAACG,OAAT,EAAkB;AAChB;AACD;;AAED,QAAMC,SAAS,GAAGC,SAAS;AACzBR,MAAAA,IAAI,EAAJA;AADyB,OAEtBE,OAFsB,EAA3B;AAKAK,IAAAA,SAAS,CAACP,IAAV,CAAeG,GAAG,CAACG,OAAnB;;AAEA,QAAIL,QAAQ,IAAIE,GAAG,CAACG,OAApB,EAA6B;AAC3BL,MAAAA,QAAQ,CAACE,GAAG,CAACG,OAAL,CAAR;AACD;AACF,GAfQ,EAeN,CAACN,IAAD,EAAOC,QAAP,EAAiBC,OAAjB,CAfM,CAAT;AAiBA,SAAOC,GAAP;AACD,CAvBD;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/useMaskInput.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport Inputmask from 'inputmask';\n\ninterface UseInputMaskOptions {\n mask: Inputmask.Options['mask']\n register?(element: HTMLElement): void\n options?: Inputmask.Options\n}\n\nconst useInputMask = (props: UseInputMaskOptions) => {\n const { mask, register, options } = props;\n\n const ref = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n const maskInput = Inputmask({\n mask,\n ...options,\n });\n\n maskInput.mask(ref.current);\n\n if (register && ref.current) {\n register(ref.current);\n }\n }, [mask, register, options]);\n\n return ref;\n};\n\nexport default useInputMask;\n"],"names":["useInputMask","props","mask","register","options","ref","useRef","useEffect","current","maskInput","Inputmask"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AASA,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,KAAD;EACnB,IAAQC,IAAR,GAAoCD,KAApC,CAAQC,IAAR;MAAcC,QAAd,GAAoCF,KAApC,CAAcE,QAAd;MAAwBC,OAAxB,GAAoCH,KAApC,CAAwBG,OAAxB;EAEA,IAAMC,GAAG,GAAGC,YAAM,CAAmB,IAAnB,CAAlB;EAEAC,eAAS,CAAC;IACR,IAAI,CAACF,GAAG,CAACG,OAAT,EAAkB;MAChB;;;IAGF,IAAMC,SAAS,GAAGC,SAAS;MACzBR,IAAI,EAAJA;OACGE,OAFsB,EAA3B;IAKAK,SAAS,CAACP,IAAV,CAAeG,GAAG,CAACG,OAAnB;;IAEA,IAAIL,QAAQ,IAAIE,GAAG,CAACG,OAApB,EAA6B;MAC3BL,QAAQ,CAACE,GAAG,CAACG,OAAL,CAAR;;GAbK,EAeN,CAACN,IAAD,EAAOC,QAAP,EAAiBC,OAAjB,CAfM,CAAT;EAiBA,OAAOC,GAAP;AACD,CAvBD;;;;"}
@@ -2,7 +2,7 @@ import { useRef, useEffect } from 'react';
2
2
  import Inputmask from 'inputmask';
3
3
 
4
4
  function _extends() {
5
- _extends = Object.assign || function (target) {
5
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
6
6
  for (var i = 1; i < arguments.length; i++) {
7
7
  var source = arguments[i];
8
8
 
@@ -15,7 +15,6 @@ function _extends() {
15
15
 
16
16
  return target;
17
17
  };
18
-
19
18
  return _extends.apply(this, arguments);
20
19
  }
21
20
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.modern.js","sources":["../src/useMaskInput.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport Inputmask, { Options as InputMaskOptions } from 'inputmask'\n\ninterface UseInputMaskOptions {\n mask: InputMaskOptions['mask']\n register?(element: HTMLElement): void\n options?: InputMaskOptions\n}\n\nconst useInputMask = (props: UseInputMaskOptions) => {\n const { mask, register, options } = props\n\n const ref = useRef<HTMLInputElement>(null)\n\n useEffect(() => {\n if (!ref.current) {\n return\n }\n\n const maskInput = Inputmask({\n mask,\n ...options\n })\n\n maskInput.mask(ref.current)\n\n if (register && ref.current) {\n register(ref.current)\n }\n }, [mask, register, options])\n\n return ref\n}\n\nexport default useInputMask\n"],"names":["useInputMask","props","mask","register","options","ref","useRef","useEffect","current","maskInput","Inputmask"],"mappings":";;;;;;;;;;;;;;;;;;;;;AASA,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,KAAD;MACXC,OAA4BD,MAA5BC;MAAMC,WAAsBF,MAAtBE;MAAUC,UAAYH,MAAZG;AAExB,MAAMC,GAAG,GAAGC,MAAM,CAAmB,IAAnB,CAAlB;AAEAC,EAAAA,SAAS,CAAC;AACR,QAAI,CAACF,GAAG,CAACG,OAAT,EAAkB;AAChB;AACD;;AAED,QAAMC,SAAS,GAAGC,SAAS;AACzBR,MAAAA,IAAI,EAAJA;AADyB,OAEtBE,OAFsB,EAA3B;AAKAK,IAAAA,SAAS,CAACP,IAAV,CAAeG,GAAG,CAACG,OAAnB;;AAEA,QAAIL,QAAQ,IAAIE,GAAG,CAACG,OAApB,EAA6B;AAC3BL,MAAAA,QAAQ,CAACE,GAAG,CAACG,OAAL,CAAR;AACD;AACF,GAfQ,EAeN,CAACN,IAAD,EAAOC,QAAP,EAAiBC,OAAjB,CAfM,CAAT;AAiBA,SAAOC,GAAP;AACD,CAvBD;;;;"}
1
+ {"version":3,"file":"index.modern.js","sources":["../src/useMaskInput.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport Inputmask from 'inputmask';\n\ninterface UseInputMaskOptions {\n mask: Inputmask.Options['mask']\n register?(element: HTMLElement): void\n options?: Inputmask.Options\n}\n\nconst useInputMask = (props: UseInputMaskOptions) => {\n const { mask, register, options } = props;\n\n const ref = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n const maskInput = Inputmask({\n mask,\n ...options,\n });\n\n maskInput.mask(ref.current);\n\n if (register && ref.current) {\n register(ref.current);\n }\n }, [mask, register, options]);\n\n return ref;\n};\n\nexport default useInputMask;\n"],"names":["useInputMask","props","mask","register","options","ref","useRef","useEffect","current","maskInput","Inputmask"],"mappings":";;;;;;;;;;;;;;;;;;;;AASA,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,KAAD;EACnB,IAAQC,IAAR,GAAoCD,KAApC,CAAQC,IAAR;MAAcC,QAAd,GAAoCF,KAApC,CAAcE,QAAd;MAAwBC,OAAxB,GAAoCH,KAApC,CAAwBG,OAAxB;EAEA,IAAMC,GAAG,GAAGC,MAAM,CAAmB,IAAnB,CAAlB;EAEAC,SAAS,CAAC;IACR,IAAI,CAACF,GAAG,CAACG,OAAT,EAAkB;MAChB;;;IAGF,IAAMC,SAAS,GAAGC,SAAS;MACzBR,IAAI,EAAJA;OACGE,OAFsB,EAA3B;IAKAK,SAAS,CAACP,IAAV,CAAeG,GAAG,CAACG,OAAnB;;IAEA,IAAIL,QAAQ,IAAIE,GAAG,CAACG,OAApB,EAA6B;MAC3BL,QAAQ,CAACE,GAAG,CAACG,OAAL,CAAR;;GAbK,EAeN,CAACN,IAAD,EAAOC,QAAP,EAAiBC,OAAjB,CAfM,CAAT;EAiBA,OAAOC,GAAP;AACD,CAvBD;;;;"}
@@ -1,9 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { Options as InputMaskOptions } from 'inputmask';
2
+ import Inputmask from 'inputmask';
3
3
  interface UseInputMaskOptions {
4
- mask: InputMaskOptions['mask'];
4
+ mask: Inputmask.Options['mask'];
5
5
  register?(element: HTMLElement): void;
6
- options?: InputMaskOptions;
6
+ options?: Inputmask.Options;
7
7
  }
8
8
  declare const useInputMask: (props: UseInputMaskOptions) => import("react").RefObject<HTMLInputElement>;
9
9
  export default useInputMask;
@@ -1,27 +1,28 @@
1
1
  # Inputmask
2
2
 
3
- Copyright (c) 2010 - 2020 Robin Herbots Licensed under the MIT license ([http://opensource.org/licenses/mit-license.php](http://opensource.org/licenses/mit-license.php))
3
+ Copyright (c) 2010 - 2021 Robin Herbots Licensed under the MIT license (<https://opensource.org/licenses/MIT>)
4
+
5
+ The Inputmask has a very permissive license and this will stay that way. But when you use the Inputmask in a commercial setting, be so honest to make a small donation.
6
+ This will be appreciated very much.
4
7
 
5
8
  [![donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZNR3EB6JTMMSS)
6
9
 
7
- [Make a donation with crypto](https://commerce.coinbase.com/checkout/9b2138a0-ad82-4155-92ba-bfc688fb6974)
8
-
9
- [![NPM Version][npm-image]][npm-url] [![Dependency Status][david-image]][david-url] [![devDependency Status][david-dev-image]][david-dev-url]
10
+ ![npm](https://img.shields.io/npm/v/inputmask) ![npm (tag)](https://img.shields.io/npm/v/inputmask/next) ![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/inputmask)
10
11
 
11
- Inputmask is a javascript library which creates an input mask. Inputmask can run against vanilla javascript, jQuery and jqlite.
12
+ Inputmask is a javascript library that creates an input mask. Inputmask can run against vanilla javascript, jQuery, and jqlite.
12
13
 
13
14
  An inputmask helps the user with the input by ensuring a predefined format. This can be useful for dates, numerics, phone numbers, ...
14
15
 
15
16
  Highlights:
16
17
  - easy to use
17
- - optional parts anywere in the mask
18
- - possibility to define aliases which hide complexity
19
- - date / datetime masks
18
+ - optional parts anywhere in the mask
19
+ - possibility to define aliases which hide the complexity
20
+ - date / DateTime masks
20
21
  - numeric masks
21
22
  - lots of callbacks
22
23
  - non-greedy masks
23
24
  - many features can be enabled/disabled/configured by options
24
- - supports readonly/disabled/dir="rtl" attributes
25
+ - supports read-only/disabled/dir="rtl" attributes
25
26
  - support data-inputmask attribute(s)
26
27
  - alternator-mask
27
28
  - regex-mask
@@ -31,11 +32,15 @@ Highlights:
31
32
  - value formatting / validating without input element
32
33
  - AMD/CommonJS support
33
34
  - dependencyLibs: vanilla javascript, jQuery, jqlite
34
- - \<input-mask\> htmlelenent
35
+ - \<input-mask\> htmlelement
35
36
 
36
- Demo page see [http://robinherbots.github.io/Inputmask](http://robinherbots.github.io/Inputmask)
37
+ Demo page see <https://robinherbots.github.io/Inputmask/>
37
38
 
38
- Thanks to [Jetbrains](https://www.jetbrains.com/) for providing a free license for their excellent Webstorm IDE.
39
+ Thanks to [Jetbrains](https://www.jetbrains.com/?from=inputmask) for providing a free license for their excellent Webstorm IDE.
40
+ <a href="https://www.jetbrains.com/?from=inputmask">
41
+ <img src="https://upload.wikimedia.org/wikipedia/commons/1/1a/JetBrains_Logo_2016.svg" alt="Jetbrains">
42
+ </a>
43
+
39
44
  Thanks to [Browserstack](https://www.browserstack.com) for providing a free license, so we can start automating test in different browsers and devices.
40
45
  <a href="https://www.browserstack.com">
41
46
  <img src="https://www.browserstack.com/images/layout/browserstack-logo-600x315.png" alt="Browserstack" width="150">
@@ -48,8 +53,6 @@ Inputmask can run against different javascript libraries.
48
53
  You can choose between:
49
54
  - inputmask.dependencyLib (vanilla)
50
55
  - inputmask.dependencyLib.jquery
51
- - inputmask.dependencyLib.jqlite
52
- - .... (others are welcome)
53
56
 
54
57
  ### Classic web with <script\> tag
55
58
  Include the js-files which you can find in the `dist` folder.
@@ -92,17 +95,11 @@ var Inputmask = require('inputmask');
92
95
  import Inputmask from "inputmask";
93
96
  ```
94
97
 
95
- #### Selecting the dependencyLib
96
- By default the vanilla dependencyLib is used. You can select another dependency
97
- by creating an alias in the webpack.config.
98
-
98
+ ### ES6
99
99
  ```
100
- resolve: {
101
- alias: {
102
- "./dependencyLibs/inputmask.dependencyLib": "./dependencyLibs/inputmask.dependencyLib.jquery"
103
- }
104
- },
100
+ import Inputmask from "inputmask.es6.js";
105
101
  ```
102
+
106
103
  ## Usage
107
104
  ### via Inputmask class
108
105
 
@@ -114,7 +111,7 @@ im.mask(selector);
114
111
 
115
112
  //or
116
113
 
117
- Inputmask({"mask": "(999) 999-9999", .... other options .....}).mask(selector);
114
+ Inputmask({"mask": "(999) 999-9999", ... other_options, ...}).mask(selector);
118
115
  Inputmask("9-a{1,3}9{1,3}").mask(selector);
119
116
  Inputmask("9", { repeat: 10 }).mask(selector);
120
117
 
@@ -163,7 +160,7 @@ $(document).ready(function(){
163
160
  ```
164
161
 
165
162
  ### via \<input-mask\> element
166
- Use the input-mask element in your html code and set the options as attributes.
163
+ Use the input-mask element in your HTML code and set the options as attributes.
167
164
 
168
165
  ```html
169
166
  <input-mask alias="currency"></input-mask>
@@ -190,13 +187,13 @@ The allowed input types are defined in the supportsInputType option. Also see ([
190
187
  There are more definitions defined within the extensions.<br>You can find info within the js-files or by further exploring the options.
191
188
 
192
189
  ###### Note:
193
- When your newly mask is acting strange and replaces some static chars with the mask, then there is a definition which uses the char as symbol.
190
+ When your new mask is acting strange and replaces some static chars with the mask, then there is a definition that uses the char as a symbol.
194
191
  To solve this you need to [double escape the char](#escape-special-mask-chars).
195
192
 
196
193
 
197
194
  ## Masking types
198
195
  ### Static masks
199
- These are the very basic of masking. The mask is defined and will not change during the input.
196
+ These are the very basics of masking. The mask is defined and will not change during the input.
200
197
 
201
198
  ```javascript
202
199
  $(document).ready(function(){
@@ -214,14 +211,14 @@ Example:
214
211
  $('#test').inputmask('(99) 9999[9]-9999');
215
212
  ```
216
213
 
217
- This mask wil allow input like `(99) 99999-9999` or `(99) 9999-9999`.
214
+ This mask will allow input like `(99) 99999-9999` or `(99) 9999-9999`.
218
215
 
219
216
  Input => 12123451234 mask => (12) 12345-1234 (trigger complete)<br>
220
217
  Input => 121234-1234 mask => (12) 1234-1234 (trigger complete)<br>
221
218
  Input => 1212341234 mask => (12) 12341-234_ (trigger incomplete)
222
219
 
223
220
  #### skipOptionalPartCharacter
224
- As an extra there is another configurable character which is used to skip an optional part in the mask.
221
+ As an extra, there is another configurable character which is used to skip an optional part in the mask.
225
222
 
226
223
  ```javascript
227
224
  skipOptionalPartCharacter: " "
@@ -229,7 +226,7 @@ skipOptionalPartCharacter: " "
229
226
 
230
227
  Input => 121234 1234 mask => (12) 1234-1234 (trigger complete)
231
228
 
232
- When `clearMaskOnLostFocus: true` is set in the options (default), the mask will clear out the optional part when it is not filled in and this only in case the optional part is at the end of the mask.
229
+ When `clearMaskOnLostFocus: true` is set in the options (default), the mask will clear out the optional part when it is not filled in, and this only in case the optional part is at the end of the mask.
233
230
 
234
231
  For example, given:
235
232
 
@@ -249,7 +246,7 @@ $(selector).inputmask({ mask: "9[-9999]", greedy: false });
249
246
  The initial mask shown will be "**_**" instead of "**_**-____".
250
247
 
251
248
  ### Dynamic masks
252
- Dynamic masks can change during the input. To define a dynamic part use { }.
249
+ Dynamic masks can change during input. To define a dynamic part use { }.
253
250
 
254
251
  {n} => n repeats
255
252
  {n|j} => n repeats, with j jitmasking
@@ -300,9 +297,10 @@ The alternator syntax is like an **OR** statement. The mask can be one of the 3
300
297
  To define an alternator use the |.
301
298
  ex: "a|9" => a or 9
302
299
  "(aaa)|(999)" => aaa or 999
303
- "(aaa|999|9AA)" => aaa or 999 or 9AA
300
+ "(aaa|999|9AA)" => aaa or 999 or 9AA
301
+ "aaaa|9999" => aaa a or 9 999
304
302
 
305
- Also make sure to read about the keepStatic option.
303
+ **Also make sure to read about the [keepStatic](#keepStatic) option.**
306
304
 
307
305
  ```javascript
308
306
  $("selector").inputmask("(99.9)|(X)", {
@@ -330,14 +328,14 @@ $("selector").inputmask({
330
328
  ```
331
329
 
332
330
  ### Preprocessing masks
333
- You can define the mask as a function which can allow to preprocess the resulting mask. Example sorting for multiple masks or retrieving mask definitions dynamically through ajax. The preprocessing fn should return a valid mask definition.
331
+ You can define the mask as a function that can allow you to preprocess the resulting mask. Example sorting for multiple masks or retrieving mask definitions dynamically through ajax. The preprocessing fn should return a valid mask definition.
334
332
 
335
333
  ```javascript
336
334
  $(selector).inputmask({ mask: function () { /* do stuff */ return ["[1-]AAA-999", "[1-]999-AAA"]; }});
337
335
  ```
338
336
 
339
337
  ### JIT Masking
340
- Just in time masking. With the jitMasking option you can enable jit masking. The mask will only be visible for the user entered characters.
338
+ Just in time masking. With the jitMasking option, you can enable jit masking. The mask will only be visible for the user-entered characters.
341
339
  Default: false
342
340
 
343
341
  Value can be true or a threshold number or false.
@@ -350,9 +348,9 @@ Inputmask("datetime", { jitMasking: true }).mask(selector);
350
348
  You can define your own definitions to use in your mask.<br>Start by choosing a masksymbol.
351
349
 
352
350
  ### validator(chrs, maskset, pos, strict, opts)
353
- Next define your validator. The validator can be a regular expression or a function.
351
+ Next, define your validator. The validator can be a regular expression or a function.
354
352
 
355
- The return value of a validator can be true, false or a command object.
353
+ The return value of a validator can be true, false, or a command object.
356
354
 
357
355
  #### Options of the command object
358
356
  - pos : position to insert
@@ -365,15 +363,16 @@ The return value of a validator can be true, false or a command object.
365
363
  - { pos : position to insert, c : character to insert, fromIsValid : true/false, strict : true/false }
366
364
  - [{ pos : position to insert, c : character to insert, fromIsValid : true/false, strict : true/false }, { ...}, ... ]
367
365
 
368
- fromIsValid & strict
366
+ fromIsValid & strict defaults to true.
369
367
 
370
368
  - refreshFromBuffer :
371
369
  - true => refresh validPositions from the complete buffer
372
370
  - { start: , end: } => refresh from start to end
373
- - rewritePosition: rewrite the maskPos within the isvalid function
371
+ - rewritePosition: rewrite the maskPos within the isvalid function
372
+ See [preValidation option](#preValidation)
374
373
 
375
374
  ### definitionSymbol
376
- When you insert or delete characters, they are only shifted when the definition type is the same. This behavior can be overridden by giving a definitionSymbol. (see example x, y, z, which can be used for ip-address masking, the validation is different, but it is allowed to shift the characters between the definitions)
375
+ When you insert or delete characters, they are only shifted when the definition type is the same. This behavior can be overridden by giving a definitionSymbol. (see example x, y, z, which can be used for IP-address masking, the validation is different, but it is allowed to shift the characters between the definitions)
377
376
 
378
377
  ```javascript
379
378
  Inputmask.extendDefinitions({
@@ -412,8 +411,21 @@ Inputmask.extendDefinitions({
412
411
  ### placeholder
413
412
  Specify a placeholder for a definition. This can also be a function.
414
413
 
415
- ### set defaults
416
- Defaults can be set as below.
414
+ ### optional
415
+ Mark the definition as optional
416
+
417
+ ### static
418
+ Mark the definition as static
419
+
420
+ ### casing (definition option)
421
+ Specify casing options.
422
+ The options are the same as the [Casing option](#casing)
423
+
424
+ ### generated
425
+ Mark the definition as generated
426
+
427
+ ## set defaults
428
+ The defaults can be set as below.
417
429
 
418
430
  ```javascript
419
431
  Inputmask.extendDefaults({
@@ -439,7 +451,7 @@ Inputmask.extendAliases({
439
451
  ```
440
452
 
441
453
  But if the property is defined within an alias you need to set it for the alias definition.
442
- This is also for default plugin options. If the alias definitions extends on default options, you can only override it at alias level.
454
+ This is also for default plugin options. If the alias definitions extend on default options, you can only override it at alias level.
443
455
 
444
456
  ```javascript
445
457
  Inputmask.extendAliases({
@@ -451,7 +463,7 @@ Inputmask.extendAliases({
451
463
  });
452
464
  ```
453
465
 
454
- However, the preferred way to alter properties for an alias is by creating a new alias which inherits from the default alias definition.
466
+ However, the preferred way to alter properties for an alias is by creating a new alias that inherits from the default alias definition.
455
467
 
456
468
  ```javascript
457
469
  Inputmask.extendAliases({
@@ -535,7 +547,8 @@ if (input.inputmask)
535
547
  Unmask a given value against the mask.
536
548
 
537
549
  ```javascript
538
- var unformattedDate = Inputmask.unmask("23/03/1973", { alias: "dd/mm/yyyy"}); //23031973
550
+ var unformattedMask = Inputmask.unmask("123-45678-90", { mask: "999-99999-99" }); //1234567890
551
+ var unformattedDate = Inputmask.unmask("23/03/1973", { alias: "datetime", inputFormat: "dd/mm/yyyy", outputFormat: "ddmmyyyy"});//23031973
539
552
  ```
540
553
 
541
554
  ### remove
@@ -607,7 +620,7 @@ $(selector).inputmask("getmetadata");
607
620
  The setvalue functionality is to set a value to the inputmask like you would do with jQuery.val,
608
621
  BUT it will trigger the internal event used by the inputmask always, whatever the case.
609
622
  This is particular usefull when cloning an inputmask with jQuery.clone. Cloning an inputmask is not a fully functional clone.
610
- On the first event (mouseenter, focus, ...) the inputmask can detect if it where cloned and can reactivate the masking. However when setting the value with jQuery.val there is none of the events triggered in that case. The setvalue functionality does this for you.
623
+ On the first event (mouseenter, focus, ...) the inputmask can detect if it were cloned and can reactivate the masking. However when setting the value with jQuery.val there is none of the events triggered in that case. The setvalue functionality does this for you.
611
624
 
612
625
  ```
613
626
  $(selector).inputmask("setvalue", value);
@@ -643,7 +656,7 @@ $("#CellPhone").inputmask("option", {
643
656
  ```
644
657
 
645
658
  ### format
646
- Instead of masking an input element it is also possible to use the inputmask for formatting given values. Think of formatting values to show in jqGrid or on other elements then inputs.
659
+ Instead of masking an input element, it is also possible to use the inputmask for formatting given values. Think of formatting values to show in jqGrid or on other elements then inputs.
647
660
 
648
661
  ```javascript
649
662
  var formattedDate = Inputmask.format("2331973", { alias: "datetime", inputFormat: "dd/mm/yyyy"});
@@ -793,7 +806,7 @@ Automatically unmask the value when retrieved.<br>Default: false.
793
806
  Remove the mask before submitting the form.<br>Default: false
794
807
 
795
808
  ### clearMaskOnLostFocus
796
- Remove the empty mask on blur or when not empty removes the optional trailing part Default: true
809
+ Remove the empty mask on blur or when not empty remove the optional trailing part Default: true
797
810
 
798
811
  ```javascript
799
812
  $(document).ready(function(){
@@ -819,11 +832,11 @@ $(document).ready(function(){
819
832
  ### aliases
820
833
  Definitions of aliases.
821
834
 
822
- With an alias you can define a complex mask definition and call it by using an alias name. So this is mainly to simplify the use of your masks. Some aliases found in the extensions are: email, currency, decimal, integer, date, datetime, dd/mm/yyyy, etc.
835
+ With an alias, you can define a complex mask definition and call it by using an alias name. So this is mainly to simplify the use of your masks. Some aliases found in the extensions are email, currency, decimal, integer, date, DateTime, dd/mm/yyyy, etc.
823
836
 
824
- First you have to create an alias definition. The alias definition can contain options for the mask, custom definitions, the mask to use etc.
837
+ First, you have to create an alias definition. The alias definition can contain options for the mask, custom definitions, the mask to use, etc.
825
838
 
826
- When you pass in an alias, the alias is first resolved and then the other options are applied. So you can call an alias and pass another mask to be applied over the alias. This also means that you can write aliases which "inherit" from another alias.
839
+ When you pass in an alias, the alias is first resolved and then the other options are applied. So you can call an alias and pass another mask to be applied over the alias. This also means that you can write aliases that "inherit" from another alias.
827
840
 
828
841
  Some examples can be found in jquery.inputmask.xxx.extensions.js
829
842
 
@@ -883,7 +896,7 @@ $(selector).inputmask({
883
896
  ```
884
897
 
885
898
  ### onBeforePaste
886
- This callback allows for preprocessing the pasted value before actually handling the value for masking. This can be usefull for stripping away some characters before processing.
899
+ This callback allows for preprocessing the pasted value before actually handling the value for masking. This can be useful for stripping away some characters before processing.
887
900
 
888
901
  Function arguments: pastedValue, opts<br>Function return: processedValue
889
902
 
@@ -910,9 +923,9 @@ Default: Calls the onBeforeMask
910
923
  ### onBeforeWrite
911
924
  Executes before writing to the masked element
912
925
 
913
- Use this to do some extra processing of the input. This can be usefull when implementing an alias, ex. decimal alias, autofill the digits when leaving the inputfield.
926
+ Use this to do some extra processing of the input. This can be useful when implementing an alias, ex. decimal alias, autofill the digits when leaving the inputfield.
914
927
 
915
- Function arguments: event, buffer, caretPos, opts<br>Function return: command object (see Define custom definitions)
928
+ Function arguments: event, buffer, caretPos, opts<br>Function return: command object (see [Define custom definitions](#define-custom-definitions))
916
929
 
917
930
  ### onUnMask
918
931
  Executes after unmasking to allow post-processing of the unmaskedvalue.
@@ -949,7 +962,7 @@ $(document).ready(function(){
949
962
  ```
950
963
 
951
964
  ### onKeyValidation
952
- Callback function is executed on every keyvalidation with the key, result as parameter.
965
+ Callback function is executed on every keyvalidation with the key, result as the parameter.
953
966
 
954
967
  ```javascript
955
968
  $(document).ready(function(){
@@ -975,7 +988,7 @@ $(document).ready(function(){
975
988
  ### rightAlign
976
989
  Align the input to the right
977
990
 
978
- By setting the rightAlign you can specify to right align an inputmask. This is only applied in combination op the numericInput option or the dir-attribute. Default is true.
991
+ By setting the rightAlign you can specify to right-align an inputmask. This is only applied in combination op the numericInput option or the dir-attribute. The default is true.
979
992
 
980
993
  ```javascript
981
994
  $(document).ready(function(){
@@ -999,7 +1012,11 @@ ex. $(selector).inputmask({ mask: ["+55-99-9999-9999", "+55-99-99999-9999", ], k
999
1012
 
1000
1013
  typing 1212345123 => should result in +55-12-1234-5123 type extra 4 => switch to +55-12-12345-1234
1001
1014
 
1002
- **When the option is not set, it will default to false, except for multiple masks it will default to true!!**
1015
+ **When the option is not set, it will default to false.**
1016
+ **Except:**
1017
+ - for multiple masks it will default to true
1018
+ - when the first alternation is shorter then the next it will also default to true.
1019
+ - ex: (9|999), (99)|(aaaa)
1003
1020
 
1004
1021
  ### positionCaretOnTab
1005
1022
  When enabled the caret position is set after the latest valid position on TAB Default: true
@@ -1037,16 +1054,19 @@ $(selector).inputmask({
1037
1054
  ```
1038
1055
 
1039
1056
  ### postValidation
1040
- Hook to postValidate the result from isValid. Usefull for validating the entry as a whole. Args => buffer, pos, c, currentResult, opts, maskset, strict<br>Return => true|false|command object
1057
+ Hook to postValidate the result from isValid. Usefull for validating the entry as a whole. Args => buffer, pos, c, currentResult, opts, maskset, strict, fromCheckval<br>Return => true|false|command object
1041
1058
 
1042
1059
  ### preValidation
1043
- Hook to preValidate the input. Useful for validating regardless the definition. Args => buffer, pos, char, isSelection, opts, maskset, caretPos, strict => return true/false/command object
1044
- When return true, the normal validation kicks in, otherwise it is skipped.
1060
+ Hook to preValidate the input. Useful for validating regardless of the definition. Args => buffer, pos, char, isSelection, opts, maskset, caretPos, strict => return true/false/command object
1061
+ When returning true, the normal validation kicks in, otherwise, it is skipped.
1062
+
1063
+ When returning a command object the actions are executed and further validation is stopped.
1064
+ If you want to continue further validation, you need to add the rewritePosition action.
1045
1065
 
1046
1066
  ### staticDefinitionSymbol
1047
- The staticDefinitionSymbol option is used to indicate that the static entries in the mask can match a certain definition. Especially usefull with alternators so that static element in the mask can match another alternation.
1067
+ The staticDefinitionSymbol option is used to indicate that the static entries in the mask can match a certain definition. Especially useful with alternators so that the static element in the mask can match another alternation.
1048
1068
 
1049
- In the example below we mark the spaces as a possible match for the "i" definition. By doing so the mask can alternate to the second mask even when we typed already "12 3".
1069
+ In the example below, we mark the spaces as a possible match for the "i" definition. By doing so the mask can alternate to the second mask even when we typed already "12 3".
1050
1070
 
1051
1071
  ```javascript
1052
1072
  Inputmask("(99 99 999999)|(i{+})", {
@@ -1094,9 +1114,10 @@ casing: function(elem, test, pos, validPositions) {
1094
1114
  Default: null
1095
1115
 
1096
1116
  ### inputmode
1097
- Default: "verbatim"
1098
- Specify the inputmode - already in place for when browsers start to support them
1099
- https://html.spec.whatwg.org/#input-modalities:-the-inputmode-attribute
1117
+ Default: "text"
1118
+ The inputmode hints at the type of data that might be entered by the user while editing the element or its contents.
1119
+
1120
+ https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode
1100
1121
 
1101
1122
  ### importDataAttributes
1102
1123
  Specify to use the data-inputmask attributes or to ignore them.
@@ -1117,8 +1138,27 @@ Default: true
1117
1138
  true = shift on the "def" match
1118
1139
  false = shift on the "nativeDef" match
1119
1140
 
1141
+ ### usePrototypeDefinitions
1142
+ Use the default defined definitions from the prototype.
1143
+
1144
+ Default: true
1145
+
1146
+ ### validationEventTimeOut
1147
+ Time to show html5 validation error on form submit.
1148
+
1149
+ Default: 3000
1150
+
1151
+ ### substitutes
1152
+ Define character substitutes.
1153
+ ```
1154
+ substitutes: {
1155
+ ",": "."
1156
+ }
1157
+ ```
1158
+ Default: {}
1159
+
1120
1160
  ## General
1121
- ### set a value and apply mask
1161
+ ### set a value and apply the mask
1122
1162
  this can be done with the traditional jquery.val function (all browsers) or JavaScript value property for browsers which implement lookupGetter or getOwnPropertyDescriptor
1123
1163
 
1124
1164
  ```javascript
@@ -1154,7 +1194,7 @@ $(document).ready(function(){
1154
1194
  Extra example see https://github.com/RobinHerbots/Inputmask/issues/2251
1155
1195
 
1156
1196
  ### auto-casing inputmask
1157
- You can define within a definition to automatically apply some casing on the entry in an input by giving the casing.<br>Casing can be null, "upper", "lower" or "title".
1197
+ You can define within a definition to automatically apply some casing on the entry in input by giving the casing.<br>Casing can be null, "upper", "lower" or "title".
1158
1198
 
1159
1199
  ```javascript
1160
1200
  Inputmask.extendDefinitions({
@@ -1203,7 +1243,7 @@ $(document).ready(function(){
1203
1243
  ```
1204
1244
 
1205
1245
  ### data-inputmask attribute
1206
- You can also apply an inputmask by using the data-inputmask attribute. In the attribute you specify the options wanted for the inputmask. This gets parsed with $.parseJSON (for the moment), so be sure to use a well-formed json-string without the {}.
1246
+ You can also apply an inputmask by using the data-inputmask attribute. In the attribute, you specify the options wanted for the inputmask. This gets parsed with $.parseJSON (for the moment), so be sure to use a well-formed JSON-string without the {}.
1207
1247
 
1208
1248
  ```html
1209
1249
  <input data-inputmask="'alias': 'datetime'" />
@@ -1235,15 +1275,5 @@ When cloning a inputmask, the inputmask reactivates on the first event (mouseent
1235
1275
  Be sure to pass true in the jQuery.clone fn to clone with data and events and use jQuery as dependencyLib
1236
1276
  (https://api.jquery.com/clone/)
1237
1277
 
1238
- # Extensions
1239
- ## [date & datetime extensions](README_date.md)
1240
- ## [numeric extensions](README_numeric.md)
1241
- ## [other extensions](README_other.md)
1242
-
1243
- [npm-url]: https://npmjs.org/package/inputmask
1244
- [npm-image]: https://img.shields.io/npm/v/inputmask.svg
1245
- [david-url]: https://david-dm.org/RobinHerbots/inputmask#info=dependencies
1246
- [david-image]: https://img.shields.io/david/RobinHerbots/inputmask.svg
1247
- [david-dev-url]: https://david-dm.org/RobinHerbots/inputmask#info=devDependencies
1248
- [david-dev-image]: https://img.shields.io/david/dev/RobinHerbots/inputmask.svg
1278
+
1249
1279
  [input-type-ref]: https://html.spec.whatwg.org/multipage/forms.html#do-not-apply
@@ -1,5 +1,6 @@
1
- require("./lib/extensions/inputmask.extensions");
2
- require("./lib/extensions/inputmask.date.extensions");
3
- require("./lib/extensions/inputmask.numeric.extensions");
4
- require("./lib/inputmaskElement");
5
- module.exports = require("./lib/inputmask.js");
1
+ import "./lib/extensions/inputmask.extensions";
2
+ import "./lib/extensions/inputmask.date.extensions";
3
+ import "./lib/extensions/inputmask.numeric.extensions";
4
+ import "./lib/inputmaskElement";
5
+ import Inputmask from "./lib/inputmask";
6
+ export default Inputmask;
@@ -0,0 +1,5 @@
1
+ import "./inputmask.js";
2
+
3
+ const inputmask = window.Inputmask;
4
+ window.Inputmask = undefined;
5
+ export default inputmask;