From 1c197fa7c4f17f59ea53f820cf88abc25a38c3a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=9A=D1=80?=
 =?UTF-8?q?=D1=8F=D0=B6=D0=B5=D0=B2?= <ubivaza@gmail.com>
Date: Wed, 13 Dec 2023 08:51:46 +0300
Subject: [PATCH] fix #946

---
 packages/imask/src/masked/factory.ts |  8 ++++----
 packages/react-imask/src/mixin.ts    | 20 +++++++++++++-------
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/packages/imask/src/masked/factory.ts b/packages/imask/src/masked/factory.ts
index a92dc911..24617b3e 100644
--- a/packages/imask/src/masked/factory.ts
+++ b/packages/imask/src/masked/factory.ts
@@ -124,7 +124,7 @@ type UpdateStaticOpts<Opts extends FactoryStaticOpts> =
   never
 ;
 
-type UpdateAnyOpts = Record<string, any>;
+type AnyOpts = Record<string, any>;
 
 export
 type UpdateInstanceOpts<M extends Masked> =
@@ -136,7 +136,7 @@ type UpdateInstanceOpts<M extends Masked> =
   M extends MaskedRange ? MaskedRangeOptions :
   M extends MaskedEnum ? MaskedEnumOptions :
   M extends MaskedPattern ? MaskedPatternOptions :
-  UpdateAnyOpts
+  AnyOpts
 ;
 
 export
@@ -149,7 +149,7 @@ type UpdateConstructorOpts<M extends FactoryConstructorOpts> =
   M extends { mask: typeof MaskedFunction } ? MaskedFunctionOptions :
   M extends { mask: typeof MaskedPattern } ? MaskedPatternOptions :
   M extends { mask: typeof MaskedDynamic } ? MaskedDynamicOptions :
-  UpdateAnyOpts
+  AnyOpts
 ;
 
 export
@@ -170,7 +170,7 @@ type UpdateOpts<Opts extends FactoryArg> = Partial<
   Opts extends FactoryStaticOpts ? UpdateStaticOpts<Opts> :
   Opts extends FactoryInstanceOpts ? UpdateInstanceOpts<Opts['mask']> :
   Opts extends FactoryConstructorOpts ? UpdateConstructorOpts<Opts> :
-  UpdateAnyOpts
+  AnyOpts
 >;
 
 export
diff --git a/packages/react-imask/src/mixin.ts b/packages/react-imask/src/mixin.ts
index 2e5671cd..d903f33c 100644
--- a/packages/react-imask/src/mixin.ts
+++ b/packages/react-imask/src/mixin.ts
@@ -125,7 +125,12 @@ type NonMaskProps<
 export
 type ReactMixinComponent<
   MaskElement extends InputMaskElement,
-> = React.ComponentType<ReactElementProps<MaskElement> & { inputRef: React.Ref<MaskElement>; }>;
+  Props extends IMaskInputProps<MaskElement>,
+> = React.ComponentType<
+  & ReactElementProps<MaskElement>
+  & { inputRef: React.Ref<MaskElement> }
+  & NonMaskProps<MaskElement, Props>
+>;
 
 export
 type MaskPropsKeys = Exclude<keyof typeof MASK_PROPS, typeof NON_MASK_OPTIONS_PROPS_NAMES[number]>;
@@ -152,11 +157,13 @@ type IMaskInputProps<
 > = ReactElementProps<MaskElement> & IMaskMixinProps<MaskElement, Props>;
 
 
+type AnyProps = Record<string, unknown>;
+
 export default
 function IMaskMixin<
   MaskElement extends InputMaskElement,
-  Props extends IMaskInputProps<MaskElement>,
->(ComposedComponent: ReactMixinComponent<MaskElement>) {
+  Props extends IMaskInputProps<MaskElement>=AnyProps,
+>(ComposedComponent: ReactMixinComponent<MaskElement, Props>) {
   const MaskedComponent = class extends React.Component<Props> {
     static displayName: string;
     static propTypes: typeof MASK_PROPS;
@@ -285,8 +292,7 @@ function IMaskMixin<
   MaskedComponent.displayName = `IMask(${nestedComponentName})`;
   MaskedComponent.propTypes = MASK_PROPS;
 
-  return React.forwardRef<
-    React.ComponentType<Props>,
-    Props
-  >((props, ref) => React.createElement(MaskedComponent, { ...props, ref }));
+  return React.forwardRef<React.ComponentType<Props>, Props>(
+    (props, ref) => React.createElement(MaskedComponent, { ...props, ref })
+  );
 }