defaults.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import {keys} from "./keycode.js";
  2. export default {
  3. _maxTestPos: 500,
  4. placeholder: "_",
  5. optionalmarker: ["[", "]"],
  6. quantifiermarker: ["{", "}"],
  7. groupmarker: ["(", ")"],
  8. alternatormarker: "|",
  9. escapeChar: "\\",
  10. mask: null, //needs tobe null instead of undefined as the extend method does not consider props with the undefined value
  11. regex: null, //regular expression as a mask
  12. oncomplete: () => {
  13. }, //executes when the mask is complete
  14. onincomplete: () => {
  15. }, //executes when the mask is incomplete and focus is lost
  16. oncleared: () => {
  17. }, //executes when the mask is cleared
  18. repeat: 0, //repetitions of the mask: * ~ forever, otherwise specify an integer
  19. greedy: false, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
  20. autoUnmask: false, //automatically unmask when retrieving the value with $.fn.val or value if the browser supports __lookupGetter__ or getOwnPropertyDescriptor
  21. removeMaskOnSubmit: false, //remove the mask before submitting the form.
  22. clearMaskOnLostFocus: true,
  23. insertMode: true, //insert the input or overwrite the input
  24. insertModeVisual: true, //show selected caret when insertmode = false
  25. clearIncomplete: false, //clear the incomplete input on blur
  26. alias: null,
  27. onKeyDown: () => {
  28. }, //callback to implement autocomplete on certain keys for example. args => event, buffer, caretPos, opts
  29. onBeforeMask: null, //executes before masking the initial value to allow preprocessing of the initial value. args => initialValue, opts => return processedValue
  30. onBeforePaste: function (pastedValue, opts) {
  31. return typeof opts.onBeforeMask === "function" ? opts.onBeforeMask.call(this, pastedValue, opts) : pastedValue;
  32. }, //executes before masking the pasted value to allow preprocessing of the pasted value. args => pastedValue, opts => return processedValue
  33. onBeforeWrite: null, //executes before writing to the masked element. args => event, opts
  34. onUnMask: null, //executes after unmasking to allow postprocessing of the unmaskedvalue. args => maskedValue, unmaskedValue, opts
  35. showMaskOnFocus: true, //show the mask-placeholder when the input has focus
  36. showMaskOnHover: true, //show the mask-placeholder when hovering the empty input
  37. onKeyValidation: () => {
  38. }, //executes on every key-press with the result of isValid. Params: key, result, opts
  39. skipOptionalPartCharacter: " ", //a character which can be used to skip an optional part of a mask
  40. numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
  41. rightAlign: false, //align to the right
  42. undoOnEscape: true, //pressing escape reverts the value to the value before focus
  43. //numeric basic properties
  44. radixPoint: "", //".", // | ","
  45. _radixDance: false, //dance around the radixPoint
  46. groupSeparator: "", //",", // | "."
  47. //numeric basic properties
  48. keepStatic: null, //try to keep the mask static while typing. Decisions to alter the mask will be posponed if possible
  49. positionCaretOnTab: true, //when enabled the caret position is set after the latest valid position on TAB
  50. tabThrough: false, //allows for tabbing through the different parts of the masked field
  51. supportsInputType: ["text", "tel", "url", "password", "search"], //list with the supported input types
  52. //specify keyCodes which should not be considered in the keypress event, otherwise the preventDefault will stop their default behavior especially in FF
  53. ignorables: [
  54. keys.Backspace,
  55. keys.Tab,
  56. keys.Pause,
  57. keys.Escape,
  58. keys.PageUp,
  59. keys.PageDown,
  60. keys.End,
  61. keys.Home,
  62. keys.ArrowLeft,
  63. keys.ArrowUp,
  64. keys.ArrowRight,
  65. keys.ArrowDown,
  66. keys.Insert,
  67. keys.Delete,
  68. keys.ContextMenu,
  69. keys.F1,
  70. keys.F2,
  71. keys.F3,
  72. keys.F4,
  73. keys.F5,
  74. keys.F6,
  75. keys.F7,
  76. keys.F8,
  77. keys.F9,
  78. keys.F10,
  79. keys.F11,
  80. keys.F12,
  81. keys.Process,
  82. keys.Unidentified,
  83. keys.Shift,
  84. keys.Control,
  85. keys.Alt,
  86. keys.Tab,
  87. keys.AltGraph,
  88. keys.CapsLock
  89. ],
  90. isComplete: null, //override for isComplete - args => buffer, opts - return true || false
  91. preValidation: null, //hook to preValidate the input. Usefull for validating regardless the definition. args => buffer, pos, char, isSelection, opts, maskset, caretPos, strict => return true/false/command object
  92. postValidation: null, //hook to postValidate the result from isValid. Usefull for validating the entry as a whole. args => buffer, pos, c, currentResult, opts, maskset, strict, fromCheckval => return true/false/json
  93. staticDefinitionSymbol: undefined, //specify a definitionSymbol for static content, used to make matches for alternators
  94. jitMasking: false, //just in time masking ~ only mask while typing, can n (number), true or false
  95. nullable: true, //return nothing instead of the buffertemplate when the user hasn't entered anything.
  96. inputEventOnly: false, //dev option - testing inputfallback behavior
  97. noValuePatching: false, //disable value property patching
  98. positionCaretOnClick: "lvp", //none, lvp (based on the last valid position (default), radixFocus (position caret to radixpoint on initial click), select (select the whole input), ignore (ignore the click and continue the mask)
  99. casing: null, //mask-level casing. Options: null, "upper", "lower" or "title" or callback args => elem, test, pos, validPositions return charValue
  100. inputmode: "text", //specify the inputmode
  101. importDataAttributes: true, //import data-inputmask attributes
  102. shiftPositions: true, //shift position of the mask entries on entry and deletion.
  103. usePrototypeDefinitions: true, //use the default defined definitions from the prototype
  104. validationEventTimeOut: 3000, //Time to show validation error on form submit
  105. substitutes: {} //define character substitutes
  106. };