react-imask
Advanced tools
Comparing version 6.4.3 to 6.5.0-alpha.0
import IMask from 'imask'; | ||
import { Dispatch } from 'react'; | ||
import type { RefObject } from 'react'; | ||
import type { MutableRefObject } from 'react'; | ||
import type { ReactMaskProps, ReactElement } from './mixin'; | ||
export default function useIMask<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, MaskElement extends ReactElement = HTMLInputElement>(opts: Opts, { onAccept, onComplete }?: Pick<ReactMaskProps<Opts, true, IMask.InputMask<Opts>['value'], MaskElement>, 'onAccept' | 'onComplete'>): { | ||
ref: RefObject<MaskElement>; | ||
maskRef: RefObject<IMask.InputMask<Opts>>; | ||
export default function useIMask<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, MaskElement extends ReactElement = HTMLInputElement>(opts: Opts, { onAccept, onComplete }?: Partial<Pick<ReactMaskProps<Opts, true, IMask.InputMask<Opts>['value'], MaskElement>, 'onAccept' | 'onComplete'>>): { | ||
ref: MutableRefObject<MaskElement>; | ||
maskRef: MutableRefObject<IMask.InputMask<Opts>>; | ||
value: IMask.InputMask<Opts>['value']; | ||
@@ -9,0 +9,0 @@ setValue: Dispatch<IMask.InputMask<Opts>['value']>; |
import React from 'react'; | ||
import IMask from 'imask'; | ||
import { IMaskInputProps, ReactElement } from './mixin'; | ||
declare const IMaskInput: React.ForwardRefExoticComponent<(Pick<{ | ||
declare const IMaskInput: React.ForwardRefExoticComponent<(Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: DateConstructor; | ||
} & Partial<Pick<IMask.Masked<DateConstructor>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<IMask.MaskedPattern<DateConstructor>, "blocks" | "definitions" | "placeholderChar" | "lazy">> & Partial<Pick<IMask.MaskedDate, "parse" | "format" | "pattern" | "min" | "max" | "autofix">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "blocks" | "definitions" | "placeholderChar" | "lazy" | "parse" | "format" | "pattern" | "min" | "max" | "autofix" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
} & Partial<Pick<import("imask").default.Masked<DateConstructor>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<import("imask").default.MaskedPattern<DateConstructor>, "blocks" | "definitions" | "placeholderChar" | "lazy">> & Partial<Pick<import("imask").default.MaskedDate, "parse" | "format" | "pattern" | "min" | "max" | "autofix">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: NumberConstructor; | ||
} & Partial<Pick<IMask.Masked<NumberConstructor>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<IMask.MaskedNumber, "min" | "max" | "radix" | "thousandsSeparator" | "mapToRadix" | "scale" | "signed" | "normalizeZeros" | "padFractionalZeros">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "min" | "max" | "radix" | "thousandsSeparator" | "mapToRadix" | "scale" | "signed" | "normalizeZeros" | "padFractionalZeros" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
} & Partial<Pick<import("imask").default.Masked<NumberConstructor>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<import("imask").default.MaskedNumber, "min" | "max" | "radix" | "thousandsSeparator" | "mapToRadix" | "scale" | "signed" | "normalizeZeros" | "padFractionalZeros">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: string; | ||
} & Partial<Pick<IMask.Masked<string>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<IMask.MaskedPattern<string>, "blocks" | "definitions" | "placeholderChar" | "lazy">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "blocks" | "definitions" | "placeholderChar" | "lazy" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
} & Partial<Pick<import("imask").default.Masked<string>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<import("imask").default.MaskedPattern<string>, "blocks" | "definitions" | "placeholderChar" | "lazy">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: string; | ||
} & Partial<Pick<IMask.Masked<string>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<IMask.MaskedPattern<string>, "blocks" | "definitions" | "placeholderChar" | "lazy">> & Partial<Pick<IMask.MaskedRange, "autofix" | "maxLength" | "from" | "to">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "blocks" | "definitions" | "placeholderChar" | "lazy" | "autofix" | "maxLength" | "from" | "to" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.AnyMaskedOptionsArray; | ||
} & Partial<Pick<IMask.Masked<IMask.AnyMaskedOptionsArray>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.AnyMaskedOptionsArray; | ||
} & Partial<Pick<IMask.Masked<IMask.AnyMaskedOptionsArray>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<IMask.MaskedDynamic, "dispatch">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "dispatch" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
} & Partial<Pick<import("imask").default.Masked<string>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<import("imask").default.MaskedPattern<string>, "blocks" | "definitions" | "placeholderChar" | "lazy">> & Partial<Pick<import("imask").default.MaskedRange, "autofix" | "maxLength" | "from" | "to">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.AnyMaskedOptionsArray; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.AnyMaskedOptionsArray>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.AnyMaskedOptionsArray; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.AnyMaskedOptionsArray>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<import("imask").default.MaskedDynamic, "dispatch">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: RegExp; | ||
} & Partial<Pick<IMask.Masked<RegExp>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
} & Partial<Pick<import("imask").default.Masked<RegExp>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: Function; | ||
} & Partial<Pick<IMask.Masked<Function>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.AnyMaskedOptionsMasked; | ||
} & Partial<Pick<IMask.Masked<IMask.AnyMaskedOptionsMasked>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.MaskedFunction; | ||
} & Partial<Pick<IMask.Masked<IMask.MaskedFunction>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.MaskedRegExp; | ||
} & Partial<Pick<IMask.Masked<IMask.MaskedRegExp>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.MaskedEnum; | ||
} & Partial<Pick<IMask.Masked<IMask.MaskedEnum>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.MaskedRange; | ||
} & Partial<Pick<IMask.Masked<IMask.MaskedRange>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: typeof IMask.Masked; | ||
} & Partial<Pick<IMask.Masked<typeof IMask.Masked>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef">) & React.RefAttributes<unknown>>; | ||
} & Partial<Pick<import("imask").default.Masked<Function>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.AnyMaskedOptionsMasked; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.AnyMaskedOptionsMasked>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.MaskedFunction; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.MaskedFunction>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.MaskedRegExp; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.MaskedRegExp>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.MaskedEnum; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.MaskedEnum>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.MaskedRange; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.MaskedRange>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: typeof import("imask").default.Masked; | ||
} & Partial<Pick<import("imask").default.Masked<typeof import("imask").default.Masked>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref">) & React.RefAttributes<React.ComponentType<import("./mixin").IMaskInputProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement, import("./mixin").ReactElementProps<import("./mixin").ReactElement>>>>>; | ||
export default IMaskInput; |
import React from 'react'; | ||
import IMask from 'imask'; | ||
export declare type Falsy = false | 0 | "" | null | undefined; | ||
export declare type ReactElement = IMask.MaskElement | HTMLTextAreaElement | HTMLInputElement; | ||
export declare type ReactElementProps<MaskElement extends ReactElement = ReactElement> = React.HTMLProps<MaskElement>; | ||
export declare type ReactMaskProps<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement> = { | ||
export type Falsy = false | 0 | "" | null | undefined; | ||
export type ReactElement = IMask.MaskElement | HTMLTextAreaElement | HTMLInputElement; | ||
export type ReactElementProps<MaskElement extends ReactElement = ReactElement> = React.HTMLProps<MaskElement>; | ||
export type ReactMaskProps<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement> = { | ||
onAccept?: (value: Value, maskRef: IMask.InputMask<Opts>, e?: InputEvent) => void; | ||
@@ -14,7 +14,7 @@ onComplete?: (value: Value, maskRef: IMask.InputMask<Opts>, e?: InputEvent) => void; | ||
}; | ||
export declare type ReactMixinComponent<MaskElement extends ReactElement = ReactElement, MaskElementProps = ReactElementProps<MaskElement>> = React.ComponentType<MaskElementProps & { | ||
export type ReactMixinComponent<MaskElement extends ReactElement = ReactElement, MaskElementProps = ReactElementProps<MaskElement>> = React.ComponentType<MaskElementProps & { | ||
inputRef: React.Ref<MaskElement>; | ||
}>; | ||
export declare type IMaskMixinProps<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement> = Opts & ReactMaskProps<Opts, Unmask, Value, MaskElement>; | ||
export declare type IMaskInputProps<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement, MaskElementProps = ReactElementProps<MaskElement>> = MaskElementProps & IMaskMixinProps<Opts, Unmask, Value, MaskElement>; | ||
export default function IMaskMixin<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement, MaskElementProps = ReactElementProps<MaskElement>>(ComposedComponent: ReactMixinComponent<MaskElement, MaskElementProps>): React.ComponentType<IMaskInputProps<Opts, Unmask, Value, MaskElement, MaskElementProps>>; | ||
export type IMaskMixinProps<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement> = Opts & ReactMaskProps<Opts, Unmask, Value, MaskElement>; | ||
export type IMaskInputProps<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement, MaskElementProps = ReactElementProps<MaskElement>> = MaskElementProps & IMaskMixinProps<Opts, Unmask, Value, MaskElement>; | ||
export default function IMaskMixin<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement, MaskElementProps = ReactElementProps<MaskElement>>(ComposedComponent: ReactMixinComponent<MaskElement, MaskElementProps>): React.ForwardRefExoticComponent<React.PropsWithoutRef<IMaskInputProps<Opts, Unmask, Value, MaskElement, MaskElementProps>> & React.RefAttributes<React.ComponentType<IMaskInputProps<Opts, Unmask, Value, MaskElement, MaskElementProps>>>>; |
@@ -13,2 +13,29 @@ (function (global, factory) { | ||
function _iterableToArrayLimit(arr, i) { | ||
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; | ||
if (null != _i) { | ||
var _s, | ||
_e, | ||
_x, | ||
_r, | ||
_arr = [], | ||
_n = !0, | ||
_d = !1; | ||
try { | ||
if (_x = (_i = _i.call(arr)).next, 0 === i) { | ||
if (Object(_i) !== _i) return; | ||
_n = !1; | ||
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); | ||
} catch (err) { | ||
_d = !0, _e = err; | ||
} finally { | ||
try { | ||
if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
@@ -19,3 +46,2 @@ if (!(instance instanceof Constructor)) { | ||
} | ||
function _defineProperties(target, props) { | ||
@@ -27,6 +53,5 @@ for (var i = 0; i < props.length; i++) { | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
@@ -40,3 +65,2 @@ if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
} | ||
function _inherits(subClass, superClass) { | ||
@@ -46,3 +70,2 @@ if (typeof superClass !== "function" && superClass !== null) { | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
@@ -60,3 +83,2 @@ constructor: { | ||
} | ||
function _getPrototypeOf(o) { | ||
@@ -68,3 +90,2 @@ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { | ||
} | ||
function _setPrototypeOf(o, p) { | ||
@@ -77,3 +98,2 @@ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { | ||
} | ||
function _isNativeReflectConstruct() { | ||
@@ -83,3 +103,2 @@ if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
@@ -92,3 +111,5 @@ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); | ||
} | ||
function _objectDestructuringEmpty(obj) { | ||
if (obj == null) throw new TypeError("Cannot destructure " + obj); | ||
} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
@@ -99,3 +120,2 @@ if (source == null) return {}; | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
@@ -106,16 +126,10 @@ key = sourceKeys[i]; | ||
} | ||
return target; | ||
} | ||
function _objectWithoutProperties(source, excluded) { | ||
if (source == null) return {}; | ||
var target = _objectWithoutPropertiesLoose(source, excluded); | ||
var key, i; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
@@ -128,6 +142,4 @@ key = sourceSymbolKeys[i]; | ||
} | ||
return target; | ||
} | ||
function _assertThisInitialized(self) { | ||
@@ -137,6 +149,4 @@ if (self === void 0) { | ||
} | ||
return self; | ||
} | ||
function _possibleConstructorReturn(self, call) { | ||
@@ -148,16 +158,11 @@ if (call && (typeof call === "object" || typeof call === "function")) { | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _createSuper(Derived) { | ||
var hasNativeReflectConstruct = _isNativeReflectConstruct(); | ||
return function _createSuperInternal() { | ||
var Super = _getPrototypeOf(Derived), | ||
result; | ||
result; | ||
if (hasNativeReflectConstruct) { | ||
var NewTarget = _getPrototypeOf(this).constructor; | ||
result = Reflect.construct(Super, arguments, NewTarget); | ||
@@ -167,45 +172,11 @@ } else { | ||
} | ||
return _possibleConstructorReturn(this, result); | ||
}; | ||
} | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; | ||
if (_i == null) return; | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _s, _e; | ||
try { | ||
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
@@ -219,14 +190,24 @@ if (!o) return; | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
function _toPrimitive(input, hint) { | ||
if (typeof input !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (typeof res !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
function _toPropertyKey(arg) { | ||
var key = _toPrimitive(arg, "string"); | ||
return typeof key === "symbol" ? key : String(key); | ||
} | ||
@@ -273,3 +254,5 @@ var MASK_PROPS = { | ||
}; | ||
var MASK_PROPS_NAMES = Object.keys(MASK_PROPS); | ||
var MASK_PROPS_NAMES = Object.keys(MASK_PROPS).filter(function (p) { | ||
return p !== 'value'; | ||
}); | ||
var NON_MASK_OPTIONS_PROPS_NAMES = ['value', 'unmask', 'onAccept', 'onComplete', 'inputRef']; | ||
@@ -285,10 +268,6 @@ var MASK_OPTIONS_PROPS_NAMES = MASK_PROPS_NAMES.filter(function (pName) { | ||
_inherits(MaskedComponent, _React$Component); | ||
var _super = _createSuper(MaskedComponent); | ||
function MaskedComponent(props) { | ||
var _this; | ||
_classCallCheck(this, MaskedComponent); | ||
_this = _super.call(this, props); | ||
@@ -298,3 +277,2 @@ _this._inputRef = _this._inputRef.bind(_assertThisInitialized(_this)); | ||
} | ||
_createClass(MaskedComponent, [{ | ||
@@ -310,5 +288,3 @@ key: "componentDidMount", | ||
var props = this.props; | ||
var maskOptions = this._extractMaskOptionsFromProps(props); | ||
if (maskOptions.mask) { | ||
@@ -335,3 +311,2 @@ if (this.maskRef) { | ||
this.element = el; | ||
if (this.props.inputRef) { | ||
@@ -359,5 +334,7 @@ if (Object.prototype.hasOwnProperty.call(this.props.inputRef, 'current')) this.props.inputRef.current = el;else this.props.inputRef(el); | ||
value: function _extractMaskOptionsFromProps(props) { | ||
var cloneProps = Object.assign({}, props); // keep only mask options props | ||
var cloneProps = Object.assign({}, (_objectDestructuringEmpty(props), props)); | ||
Object.keys(cloneProps) // TODO why need cast to string? | ||
// keep only mask options props | ||
Object.keys(cloneProps) | ||
// TODO why need cast to string? | ||
.filter(function (prop) { | ||
@@ -373,3 +350,3 @@ return MASK_OPTIONS_PROPS_NAMES.indexOf(prop) < 0; | ||
value: function _extractNonMaskProps(props) { | ||
var cloneProps = Object.assign({}, props); | ||
var cloneProps = Object.assign({}, (_objectDestructuringEmpty(props), props)); | ||
MASK_PROPS_NAMES.forEach(function (maskProp) { | ||
@@ -409,17 +386,18 @@ delete cloneProps[maskProp]; | ||
}]); | ||
return MaskedComponent; | ||
}(React__default["default"].Component); | ||
var nestedComponentName = ComposedComponent.displayName || ComposedComponent.name || 'Component'; | ||
MaskedComponent.displayName = "IMask(".concat(nestedComponentName, ")"); | ||
MaskedComponent.propTypes = MASK_PROPS; | ||
return MaskedComponent; | ||
return React__default["default"].forwardRef(function (props, ref) { | ||
return React__default["default"].createElement(MaskedComponent, Object.assign({}, props, { | ||
ref: ref | ||
})); | ||
}); | ||
} | ||
var _excluded = ["inputRef"]; | ||
var IMaskInputClass = IMaskMixin(function (_ref) { | ||
var _excluded$1 = ["inputRef"]; | ||
var IMaskInput = IMaskMixin(function (_ref) { | ||
var inputRef = _ref.inputRef, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
props = _objectWithoutProperties(_ref, _excluded$1); | ||
return React__default["default"].createElement('input', Object.assign({}, props, { | ||
@@ -430,57 +408,52 @@ ref: inputRef | ||
var IMaskInputFn = function IMaskInputFn(props, ref) { | ||
return React__default["default"].createElement(IMaskInputClass, Object.assign({}, props, { | ||
ref: ref | ||
})); | ||
}; | ||
var IMaskInput = React__default["default"].forwardRef(IMaskInputFn); | ||
var _excluded = ["value"], | ||
_excluded2 = ["unmaskedValue"], | ||
_excluded3 = ["typedValue"]; | ||
function useIMask(opts) { | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
onAccept = _ref.onAccept, | ||
onComplete = _ref.onComplete; | ||
onAccept = _ref.onAccept, | ||
onComplete = _ref.onComplete; | ||
var ref = React.useRef(null); | ||
var maskRef = React.useRef(null); | ||
var _useState = React.useState(false), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
initialized = _useState2[0], | ||
setInitialized = _useState2[1]; | ||
var _useState3 = React.useState(''), | ||
_useState4 = _slicedToArray(_useState3, 2), | ||
value = _useState4[0], | ||
setValue = _useState4[1]; | ||
_useState2 = _slicedToArray(_useState, 2), | ||
initialized = _useState2[0], | ||
setInitialized = _useState2[1]; | ||
var _useState3 = React.useState({}), | ||
_useState4 = _slicedToArray(_useState3, 2), | ||
lastAcceptState = _useState4[0], | ||
setLastAcceptState = _useState4[1]; | ||
var _useState5 = React.useState(''), | ||
_useState6 = _slicedToArray(_useState5, 2), | ||
unmaskedValue = _useState6[0], | ||
setUnmaskedValue = _useState6[1]; | ||
var _useState7 = React.useState(), | ||
_useState8 = _slicedToArray(_useState7, 2), | ||
typedValue = _useState8[0], | ||
setTypedValue = _useState8[1]; | ||
_useState6 = _slicedToArray(_useState5, 2), | ||
value = _useState6[0], | ||
setValue = _useState6[1]; | ||
var _useState7 = React.useState(''), | ||
_useState8 = _slicedToArray(_useState7, 2), | ||
unmaskedValue = _useState8[0], | ||
setUnmaskedValue = _useState8[1]; | ||
var _useState9 = React.useState(), | ||
_useState10 = _slicedToArray(_useState9, 2), | ||
typedValue = _useState10[0], | ||
setTypedValue = _useState10[1]; | ||
var _destroyMask = React.useCallback(function () { | ||
var _maskRef$current; | ||
(_maskRef$current = maskRef.current) === null || _maskRef$current === void 0 ? void 0 : _maskRef$current.destroy(); | ||
maskRef.current = null; | ||
}, []); | ||
var _onAccept = React.useCallback(function (event) { | ||
if (!maskRef.current) return; | ||
setTypedValue(maskRef.current.typedValue); | ||
setUnmaskedValue(maskRef.current.unmaskedValue); | ||
setValue(maskRef.current.value); | ||
onAccept === null || onAccept === void 0 ? void 0 : onAccept(maskRef.current.value, maskRef.current, event); | ||
var m = maskRef.current; | ||
if (!m) return; | ||
setLastAcceptState({ | ||
value: m.value, | ||
unmaskedValue: m.unmaskedValue, | ||
typedValue: m.typedValue | ||
}); | ||
setTypedValue(m.typedValue); | ||
setUnmaskedValue(m.unmaskedValue); | ||
setValue(m.value); | ||
onAccept === null || onAccept === void 0 ? void 0 : onAccept(m.value, m, event); | ||
}, [onAccept]); | ||
var _onComplete = React.useCallback(function () { | ||
return maskRef.current && (onComplete === null || onComplete === void 0 ? void 0 : onComplete(maskRef.current.value, maskRef.current)); | ||
}, [onComplete]); | ||
React.useEffect(function () { | ||
@@ -490,7 +463,5 @@ var el = ref.current; | ||
var mask = maskRef.current; | ||
if (!mask) { | ||
if (el && opts !== null && opts !== void 0 && opts.mask) { | ||
maskRef.current = IMask__default["default"](el, opts); | ||
_onAccept(); | ||
@@ -501,3 +472,2 @@ } | ||
} | ||
setInitialized(Boolean(mask)); | ||
@@ -516,12 +486,21 @@ }, [opts, _destroyMask, _onAccept]); | ||
React.useEffect(function () { | ||
var lastAcceptValue = lastAcceptState.value, | ||
state = _objectWithoutProperties(lastAcceptState, _excluded); | ||
var mask = maskRef.current; | ||
if (mask && initialized) mask.value = value; | ||
if (mask && initialized && lastAcceptValue !== value) mask.value = value; | ||
setLastAcceptState(state); | ||
}, [value]); | ||
React.useEffect(function () { | ||
var lastAcceptUnmaskedValue = lastAcceptState.unmaskedValue, | ||
state = _objectWithoutProperties(lastAcceptState, _excluded2); | ||
var mask = maskRef.current; | ||
if (mask && initialized) mask.unmaskedValue = unmaskedValue; | ||
if (mask && initialized && lastAcceptUnmaskedValue !== unmaskedValue) mask.unmaskedValue = unmaskedValue; | ||
setLastAcceptState(state); | ||
}, [unmaskedValue]); | ||
React.useEffect(function () { | ||
var lastAcceptTypedValue = lastAcceptState.typedValue, | ||
state = _objectWithoutProperties(lastAcceptState, _excluded3); | ||
var mask = maskRef.current; | ||
if (mask && initialized) mask.typedValue = typedValue; | ||
if (mask && initialized && lastAcceptTypedValue !== typedValue) mask.typedValue = typedValue; | ||
setLastAcceptState(state); | ||
}, [typedValue]); | ||
@@ -528,0 +507,0 @@ React.useEffect(function () { |
import IMask from 'imask'; | ||
import { Dispatch } from 'react'; | ||
import type { RefObject } from 'react'; | ||
import type { MutableRefObject } from 'react'; | ||
import type { ReactMaskProps, ReactElement } from './mixin'; | ||
export default function useIMask<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, MaskElement extends ReactElement = HTMLInputElement>(opts: Opts, { onAccept, onComplete }?: Pick<ReactMaskProps<Opts, true, IMask.InputMask<Opts>['value'], MaskElement>, 'onAccept' | 'onComplete'>): { | ||
ref: RefObject<MaskElement>; | ||
maskRef: RefObject<IMask.InputMask<Opts>>; | ||
export default function useIMask<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, MaskElement extends ReactElement = HTMLInputElement>(opts: Opts, { onAccept, onComplete }?: Partial<Pick<ReactMaskProps<Opts, true, IMask.InputMask<Opts>['value'], MaskElement>, 'onAccept' | 'onComplete'>>): { | ||
ref: MutableRefObject<MaskElement>; | ||
maskRef: MutableRefObject<IMask.InputMask<Opts>>; | ||
value: IMask.InputMask<Opts>['value']; | ||
@@ -9,0 +9,0 @@ setValue: Dispatch<IMask.InputMask<Opts>['value']>; |
@@ -1,52 +0,55 @@ | ||
import { _ as _slicedToArray } from './_rollupPluginBabelHelpers-089ae9b3.js'; | ||
import { _ as _slicedToArray, a as _objectWithoutProperties } from './_rollupPluginBabelHelpers-99d8e6d1.js'; | ||
import IMask from 'imask/esm/imask'; | ||
import { useRef, useState, useCallback, useEffect } from 'react'; | ||
var _excluded = ["value"], | ||
_excluded2 = ["unmaskedValue"], | ||
_excluded3 = ["typedValue"]; | ||
function useIMask(opts) { | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
onAccept = _ref.onAccept, | ||
onComplete = _ref.onComplete; | ||
onAccept = _ref.onAccept, | ||
onComplete = _ref.onComplete; | ||
var ref = useRef(null); | ||
var maskRef = useRef(null); | ||
var _useState = useState(false), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
initialized = _useState2[0], | ||
setInitialized = _useState2[1]; | ||
var _useState3 = useState(''), | ||
_useState4 = _slicedToArray(_useState3, 2), | ||
value = _useState4[0], | ||
setValue = _useState4[1]; | ||
_useState2 = _slicedToArray(_useState, 2), | ||
initialized = _useState2[0], | ||
setInitialized = _useState2[1]; | ||
var _useState3 = useState({}), | ||
_useState4 = _slicedToArray(_useState3, 2), | ||
lastAcceptState = _useState4[0], | ||
setLastAcceptState = _useState4[1]; | ||
var _useState5 = useState(''), | ||
_useState6 = _slicedToArray(_useState5, 2), | ||
unmaskedValue = _useState6[0], | ||
setUnmaskedValue = _useState6[1]; | ||
var _useState7 = useState(), | ||
_useState8 = _slicedToArray(_useState7, 2), | ||
typedValue = _useState8[0], | ||
setTypedValue = _useState8[1]; | ||
_useState6 = _slicedToArray(_useState5, 2), | ||
value = _useState6[0], | ||
setValue = _useState6[1]; | ||
var _useState7 = useState(''), | ||
_useState8 = _slicedToArray(_useState7, 2), | ||
unmaskedValue = _useState8[0], | ||
setUnmaskedValue = _useState8[1]; | ||
var _useState9 = useState(), | ||
_useState10 = _slicedToArray(_useState9, 2), | ||
typedValue = _useState10[0], | ||
setTypedValue = _useState10[1]; | ||
var _destroyMask = useCallback(function () { | ||
var _maskRef$current; | ||
(_maskRef$current = maskRef.current) === null || _maskRef$current === void 0 ? void 0 : _maskRef$current.destroy(); | ||
maskRef.current = null; | ||
}, []); | ||
var _onAccept = useCallback(function (event) { | ||
if (!maskRef.current) return; | ||
setTypedValue(maskRef.current.typedValue); | ||
setUnmaskedValue(maskRef.current.unmaskedValue); | ||
setValue(maskRef.current.value); | ||
onAccept === null || onAccept === void 0 ? void 0 : onAccept(maskRef.current.value, maskRef.current, event); | ||
var m = maskRef.current; | ||
if (!m) return; | ||
setLastAcceptState({ | ||
value: m.value, | ||
unmaskedValue: m.unmaskedValue, | ||
typedValue: m.typedValue | ||
}); | ||
setTypedValue(m.typedValue); | ||
setUnmaskedValue(m.unmaskedValue); | ||
setValue(m.value); | ||
onAccept === null || onAccept === void 0 ? void 0 : onAccept(m.value, m, event); | ||
}, [onAccept]); | ||
var _onComplete = useCallback(function () { | ||
return maskRef.current && (onComplete === null || onComplete === void 0 ? void 0 : onComplete(maskRef.current.value, maskRef.current)); | ||
}, [onComplete]); | ||
useEffect(function () { | ||
@@ -56,7 +59,5 @@ var el = ref.current; | ||
var mask = maskRef.current; | ||
if (!mask) { | ||
if (el && opts !== null && opts !== void 0 && opts.mask) { | ||
maskRef.current = IMask(el, opts); | ||
_onAccept(); | ||
@@ -67,3 +68,2 @@ } | ||
} | ||
setInitialized(Boolean(mask)); | ||
@@ -82,12 +82,21 @@ }, [opts, _destroyMask, _onAccept]); | ||
useEffect(function () { | ||
var lastAcceptValue = lastAcceptState.value, | ||
state = _objectWithoutProperties(lastAcceptState, _excluded); | ||
var mask = maskRef.current; | ||
if (mask && initialized) mask.value = value; | ||
if (mask && initialized && lastAcceptValue !== value) mask.value = value; | ||
setLastAcceptState(state); | ||
}, [value]); | ||
useEffect(function () { | ||
var lastAcceptUnmaskedValue = lastAcceptState.unmaskedValue, | ||
state = _objectWithoutProperties(lastAcceptState, _excluded2); | ||
var mask = maskRef.current; | ||
if (mask && initialized) mask.unmaskedValue = unmaskedValue; | ||
if (mask && initialized && lastAcceptUnmaskedValue !== unmaskedValue) mask.unmaskedValue = unmaskedValue; | ||
setLastAcceptState(state); | ||
}, [unmaskedValue]); | ||
useEffect(function () { | ||
var lastAcceptTypedValue = lastAcceptState.typedValue, | ||
state = _objectWithoutProperties(lastAcceptState, _excluded3); | ||
var mask = maskRef.current; | ||
if (mask && initialized) mask.typedValue = typedValue; | ||
if (mask && initialized && lastAcceptTypedValue !== typedValue) mask.typedValue = typedValue; | ||
setLastAcceptState(state); | ||
}, [typedValue]); | ||
@@ -94,0 +103,0 @@ useEffect(function () { |
@@ -6,4 +6,4 @@ import 'imask/esm'; | ||
export { default as useIMask } from './hook.js'; | ||
import './_rollupPluginBabelHelpers-089ae9b3.js'; | ||
import './_rollupPluginBabelHelpers-99d8e6d1.js'; | ||
import 'react'; | ||
import 'prop-types'; |
import React from 'react'; | ||
import IMask from 'imask'; | ||
import { IMaskInputProps, ReactElement } from './mixin'; | ||
declare const IMaskInput: React.ForwardRefExoticComponent<(Pick<{ | ||
declare const IMaskInput: React.ForwardRefExoticComponent<(Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: DateConstructor; | ||
} & Partial<Pick<IMask.Masked<DateConstructor>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<IMask.MaskedPattern<DateConstructor>, "blocks" | "definitions" | "placeholderChar" | "lazy">> & Partial<Pick<IMask.MaskedDate, "parse" | "format" | "pattern" | "min" | "max" | "autofix">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "blocks" | "definitions" | "placeholderChar" | "lazy" | "parse" | "format" | "pattern" | "min" | "max" | "autofix" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
} & Partial<Pick<import("imask").default.Masked<DateConstructor>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<import("imask").default.MaskedPattern<DateConstructor>, "blocks" | "definitions" | "placeholderChar" | "lazy">> & Partial<Pick<import("imask").default.MaskedDate, "parse" | "format" | "pattern" | "min" | "max" | "autofix">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: NumberConstructor; | ||
} & Partial<Pick<IMask.Masked<NumberConstructor>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<IMask.MaskedNumber, "min" | "max" | "radix" | "thousandsSeparator" | "mapToRadix" | "scale" | "signed" | "normalizeZeros" | "padFractionalZeros">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "min" | "max" | "radix" | "thousandsSeparator" | "mapToRadix" | "scale" | "signed" | "normalizeZeros" | "padFractionalZeros" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
} & Partial<Pick<import("imask").default.Masked<NumberConstructor>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<import("imask").default.MaskedNumber, "min" | "max" | "radix" | "thousandsSeparator" | "mapToRadix" | "scale" | "signed" | "normalizeZeros" | "padFractionalZeros">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: string; | ||
} & Partial<Pick<IMask.Masked<string>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<IMask.MaskedPattern<string>, "blocks" | "definitions" | "placeholderChar" | "lazy">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "blocks" | "definitions" | "placeholderChar" | "lazy" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
} & Partial<Pick<import("imask").default.Masked<string>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<import("imask").default.MaskedPattern<string>, "blocks" | "definitions" | "placeholderChar" | "lazy">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: string; | ||
} & Partial<Pick<IMask.Masked<string>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<IMask.MaskedPattern<string>, "blocks" | "definitions" | "placeholderChar" | "lazy">> & Partial<Pick<IMask.MaskedRange, "autofix" | "maxLength" | "from" | "to">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "blocks" | "definitions" | "placeholderChar" | "lazy" | "autofix" | "maxLength" | "from" | "to" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.AnyMaskedOptionsArray; | ||
} & Partial<Pick<IMask.Masked<IMask.AnyMaskedOptionsArray>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.AnyMaskedOptionsArray; | ||
} & Partial<Pick<IMask.Masked<IMask.AnyMaskedOptionsArray>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<IMask.MaskedDynamic, "dispatch">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "dispatch" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
} & Partial<Pick<import("imask").default.Masked<string>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<import("imask").default.MaskedPattern<string>, "blocks" | "definitions" | "placeholderChar" | "lazy">> & Partial<Pick<import("imask").default.MaskedRange, "autofix" | "maxLength" | "from" | "to">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.AnyMaskedOptionsArray; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.AnyMaskedOptionsArray>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.AnyMaskedOptionsArray; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.AnyMaskedOptionsArray>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & Partial<Pick<import("imask").default.MaskedDynamic, "dispatch">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: RegExp; | ||
} & Partial<Pick<IMask.Masked<RegExp>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
} & Partial<Pick<import("imask").default.Masked<RegExp>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: Function; | ||
} & Partial<Pick<IMask.Masked<Function>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.AnyMaskedOptionsMasked; | ||
} & Partial<Pick<IMask.Masked<IMask.AnyMaskedOptionsMasked>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.MaskedFunction; | ||
} & Partial<Pick<IMask.Masked<IMask.MaskedFunction>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.MaskedRegExp; | ||
} & Partial<Pick<IMask.Masked<IMask.MaskedRegExp>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.MaskedEnum; | ||
} & Partial<Pick<IMask.Masked<IMask.MaskedEnum>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: IMask.MaskedRange; | ||
} & Partial<Pick<IMask.Masked<IMask.MaskedRange>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef"> | Pick<{ | ||
mask: typeof IMask.Masked; | ||
} & Partial<Pick<IMask.Masked<typeof IMask.Masked>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement> & { | ||
ref?: React.Ref<React.ComponentType<IMaskInputProps<IMask.AnyMaskedOptions, boolean | "typed", unknown, ReactElement, unknown>>>; | ||
}, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager" | "mask" | "value" | "onAccept" | "onComplete" | "unmask" | "inputRef">) & React.RefAttributes<unknown>>; | ||
} & Partial<Pick<import("imask").default.Masked<Function>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.AnyMaskedOptionsMasked; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.AnyMaskedOptionsMasked>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.MaskedFunction; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.MaskedFunction>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.MaskedRegExp; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.MaskedRegExp>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.MaskedEnum; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.MaskedEnum>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: import("imask").default.MaskedRange; | ||
} & Partial<Pick<import("imask").default.Masked<import("imask").default.MaskedRange>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref"> | Omit<import("./mixin").ReactElementProps<import("./mixin").ReactElement> & { | ||
mask: typeof import("imask").default.Masked; | ||
} & Partial<Pick<import("imask").default.Masked<typeof import("imask").default.Masked>, "parent" | "prepare" | "validate" | "commit" | "overwrite" | "eager">> & import("./mixin").ReactMaskProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement>, "ref">) & React.RefAttributes<React.ComponentType<import("./mixin").IMaskInputProps<import("imask").default.AnyMaskedOptions, false, string, import("./mixin").ReactElement, import("./mixin").ReactElementProps<import("./mixin").ReactElement>>>>>; | ||
export default IMaskInput; |
@@ -1,2 +0,2 @@ | ||
import { f as _objectWithoutProperties } from './_rollupPluginBabelHelpers-089ae9b3.js'; | ||
import { a as _objectWithoutProperties } from './_rollupPluginBabelHelpers-99d8e6d1.js'; | ||
import React from 'react'; | ||
@@ -8,6 +8,5 @@ import IMaskMixin from './mixin.js'; | ||
var _excluded = ["inputRef"]; | ||
var IMaskInputClass = IMaskMixin(function (_ref) { | ||
var IMaskInput = IMaskMixin(function (_ref) { | ||
var inputRef = _ref.inputRef, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
return React.createElement('input', Object.assign({}, props, { | ||
@@ -18,10 +17,2 @@ ref: inputRef | ||
var IMaskInputFn = function IMaskInputFn(props, ref) { | ||
return React.createElement(IMaskInputClass, Object.assign({}, props, { | ||
ref: ref | ||
})); | ||
}; | ||
var IMaskInput = React.forwardRef(IMaskInputFn); | ||
export { IMaskInput as default }; |
import React from 'react'; | ||
import IMask from 'imask'; | ||
export declare type Falsy = false | 0 | "" | null | undefined; | ||
export declare type ReactElement = IMask.MaskElement | HTMLTextAreaElement | HTMLInputElement; | ||
export declare type ReactElementProps<MaskElement extends ReactElement = ReactElement> = React.HTMLProps<MaskElement>; | ||
export declare type ReactMaskProps<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement> = { | ||
export type Falsy = false | 0 | "" | null | undefined; | ||
export type ReactElement = IMask.MaskElement | HTMLTextAreaElement | HTMLInputElement; | ||
export type ReactElementProps<MaskElement extends ReactElement = ReactElement> = React.HTMLProps<MaskElement>; | ||
export type ReactMaskProps<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement> = { | ||
onAccept?: (value: Value, maskRef: IMask.InputMask<Opts>, e?: InputEvent) => void; | ||
@@ -14,7 +14,7 @@ onComplete?: (value: Value, maskRef: IMask.InputMask<Opts>, e?: InputEvent) => void; | ||
}; | ||
export declare type ReactMixinComponent<MaskElement extends ReactElement = ReactElement, MaskElementProps = ReactElementProps<MaskElement>> = React.ComponentType<MaskElementProps & { | ||
export type ReactMixinComponent<MaskElement extends ReactElement = ReactElement, MaskElementProps = ReactElementProps<MaskElement>> = React.ComponentType<MaskElementProps & { | ||
inputRef: React.Ref<MaskElement>; | ||
}>; | ||
export declare type IMaskMixinProps<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement> = Opts & ReactMaskProps<Opts, Unmask, Value, MaskElement>; | ||
export declare type IMaskInputProps<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement, MaskElementProps = ReactElementProps<MaskElement>> = MaskElementProps & IMaskMixinProps<Opts, Unmask, Value, MaskElement>; | ||
export default function IMaskMixin<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement, MaskElementProps = ReactElementProps<MaskElement>>(ComposedComponent: ReactMixinComponent<MaskElement, MaskElementProps>): React.ComponentType<IMaskInputProps<Opts, Unmask, Value, MaskElement, MaskElementProps>>; | ||
export type IMaskMixinProps<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement> = Opts & ReactMaskProps<Opts, Unmask, Value, MaskElement>; | ||
export type IMaskInputProps<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement, MaskElementProps = ReactElementProps<MaskElement>> = MaskElementProps & IMaskMixinProps<Opts, Unmask, Value, MaskElement>; | ||
export default function IMaskMixin<Opts extends IMask.AnyMaskedOptions = IMask.AnyMaskedOptions, Unmask extends ('typed' | boolean) = false, Value = Unmask extends 'typed' ? IMask.InputMask<Opts>['typedValue'] : Unmask extends Falsy ? IMask.InputMask<Opts>['value'] : IMask.InputMask<Opts>['unmaskedValue'], MaskElement extends ReactElement = ReactElement, MaskElementProps = ReactElementProps<MaskElement>>(ComposedComponent: ReactMixinComponent<MaskElement, MaskElementProps>): React.ForwardRefExoticComponent<React.PropsWithoutRef<IMaskInputProps<Opts, Unmask, Value, MaskElement, MaskElementProps>> & React.RefAttributes<React.ComponentType<IMaskInputProps<Opts, Unmask, Value, MaskElement, MaskElementProps>>>>; |
@@ -1,2 +0,2 @@ | ||
import { a as _inherits, b as _createSuper, c as _createClass, d as _classCallCheck, e as _assertThisInitialized } from './_rollupPluginBabelHelpers-089ae9b3.js'; | ||
import { b as _inherits, c as _createSuper, d as _createClass, e as _classCallCheck, f as _assertThisInitialized, g as _objectDestructuringEmpty } from './_rollupPluginBabelHelpers-99d8e6d1.js'; | ||
import React from 'react'; | ||
@@ -46,3 +46,5 @@ import PropTypes from 'prop-types'; | ||
}; | ||
var MASK_PROPS_NAMES = Object.keys(MASK_PROPS); | ||
var MASK_PROPS_NAMES = Object.keys(MASK_PROPS).filter(function (p) { | ||
return p !== 'value'; | ||
}); | ||
var NON_MASK_OPTIONS_PROPS_NAMES = ['value', 'unmask', 'onAccept', 'onComplete', 'inputRef']; | ||
@@ -58,10 +60,6 @@ var MASK_OPTIONS_PROPS_NAMES = MASK_PROPS_NAMES.filter(function (pName) { | ||
_inherits(MaskedComponent, _React$Component); | ||
var _super = _createSuper(MaskedComponent); | ||
function MaskedComponent(props) { | ||
var _this; | ||
_classCallCheck(this, MaskedComponent); | ||
_this = _super.call(this, props); | ||
@@ -71,3 +69,2 @@ _this._inputRef = _this._inputRef.bind(_assertThisInitialized(_this)); | ||
} | ||
_createClass(MaskedComponent, [{ | ||
@@ -83,5 +80,3 @@ key: "componentDidMount", | ||
var props = this.props; | ||
var maskOptions = this._extractMaskOptionsFromProps(props); | ||
if (maskOptions.mask) { | ||
@@ -108,3 +103,2 @@ if (this.maskRef) { | ||
this.element = el; | ||
if (this.props.inputRef) { | ||
@@ -132,5 +126,7 @@ if (Object.prototype.hasOwnProperty.call(this.props.inputRef, 'current')) this.props.inputRef.current = el;else this.props.inputRef(el); | ||
value: function _extractMaskOptionsFromProps(props) { | ||
var cloneProps = Object.assign({}, props); // keep only mask options props | ||
var cloneProps = Object.assign({}, (_objectDestructuringEmpty(props), props)); | ||
Object.keys(cloneProps) // TODO why need cast to string? | ||
// keep only mask options props | ||
Object.keys(cloneProps) | ||
// TODO why need cast to string? | ||
.filter(function (prop) { | ||
@@ -146,3 +142,3 @@ return MASK_OPTIONS_PROPS_NAMES.indexOf(prop) < 0; | ||
value: function _extractNonMaskProps(props) { | ||
var cloneProps = Object.assign({}, props); | ||
var cloneProps = Object.assign({}, (_objectDestructuringEmpty(props), props)); | ||
MASK_PROPS_NAMES.forEach(function (maskProp) { | ||
@@ -182,12 +178,14 @@ delete cloneProps[maskProp]; | ||
}]); | ||
return MaskedComponent; | ||
}(React.Component); | ||
var nestedComponentName = ComposedComponent.displayName || ComposedComponent.name || 'Component'; | ||
MaskedComponent.displayName = "IMask(".concat(nestedComponentName, ")"); | ||
MaskedComponent.propTypes = MASK_PROPS; | ||
return MaskedComponent; | ||
return React.forwardRef(function (props, ref) { | ||
return React.createElement(MaskedComponent, Object.assign({}, props, { | ||
ref: ref | ||
})); | ||
}); | ||
} | ||
export { IMaskMixin as default }; |
{ | ||
"name": "react-imask", | ||
"version": "6.5.0-alpha.0", | ||
"license": "MIT", | ||
"author": "Alexey Kryazhev", | ||
"license": "MIT", | ||
"version": "6.4.3", | ||
"homepage": "https://imask.js.org/", | ||
@@ -18,3 +18,3 @@ "description": "React input mask", | ||
"react", | ||
"javascript", | ||
"imask", | ||
"input", | ||
@@ -24,4 +24,4 @@ "mask" | ||
"dependencies": { | ||
"imask": "^6.4.3", | ||
"prop-types": "^15.7.2" | ||
"imask": "^6.5.0-alpha.0", | ||
"prop-types": "^15.8.1" | ||
}, | ||
@@ -34,3 +34,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "f10ad01a01d4f051e8e25a45164662881050a431", | ||
"gitHead": "686035f5cd81507e6104de966f169dcd6706dd07", | ||
"devDependencies": { | ||
@@ -37,0 +37,0 @@ "@types/react": "^18.0.20", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
95011
1179
1
Updatedimask@^6.5.0-alpha.0
Updatedprop-types@^15.8.1