@cwncollab-org/mui-component-kit 0.3.0 → 0.3.1
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.
package/README.md
CHANGED
|
@@ -862,6 +862,7 @@ function AdvancedMaskingExamples() {
|
|
|
862
862
|
time: '',
|
|
863
863
|
currency: '',
|
|
864
864
|
alphanumeric: '',
|
|
865
|
+
ipAddress: '',
|
|
865
866
|
},
|
|
866
867
|
onSubmit: ({ value }) => {
|
|
867
868
|
console.log('Advanced mask values:', value)
|
|
@@ -899,42 +900,31 @@ function AdvancedMaskingExamples() {
|
|
|
899
900
|
)}
|
|
900
901
|
/>
|
|
901
902
|
|
|
902
|
-
{/*
|
|
903
|
+
{/* Mixed alphanumeric */}
|
|
903
904
|
<form.AppField
|
|
904
|
-
name="
|
|
905
|
+
name="alphanumeric"
|
|
905
906
|
children={field => (
|
|
906
907
|
<field.MaskedTextField
|
|
907
|
-
mask="
|
|
908
|
-
|
|
909
|
-
num: {
|
|
910
|
-
mask: Number,
|
|
911
|
-
scale: 2,
|
|
912
|
-
thousandsSeparator: ',',
|
|
913
|
-
padFractionalZeros: true,
|
|
914
|
-
normalizeZeros: true,
|
|
915
|
-
radix: '.',
|
|
916
|
-
mapToRadix: ['.'],
|
|
917
|
-
},
|
|
918
|
-
}}
|
|
919
|
-
label="Amount"
|
|
908
|
+
mask="aa00aa"
|
|
909
|
+
label="Product Code"
|
|
920
910
|
labelBehavior="shrink"
|
|
921
911
|
size="small"
|
|
922
|
-
|
|
923
|
-
placeholder="$1,234.56"
|
|
912
|
+
placeholder="AB12CD"
|
|
924
913
|
/>
|
|
925
914
|
)}
|
|
926
915
|
/>
|
|
927
916
|
|
|
928
|
-
{/*
|
|
917
|
+
{/* IP Address */}
|
|
929
918
|
<form.AppField
|
|
930
|
-
name="
|
|
919
|
+
name="ipAddress"
|
|
931
920
|
children={field => (
|
|
932
921
|
<field.MaskedTextField
|
|
933
|
-
mask="
|
|
934
|
-
label="
|
|
922
|
+
mask="000.000.000.000"
|
|
923
|
+
label="IP Address"
|
|
935
924
|
labelBehavior="shrink"
|
|
936
925
|
size="small"
|
|
937
|
-
|
|
926
|
+
fullWidth
|
|
927
|
+
placeholder="192.168.1.1"
|
|
938
928
|
/>
|
|
939
929
|
)}
|
|
940
930
|
/>
|
|
@@ -962,9 +952,11 @@ The MaskedTextField component accepts all standard MUI TextField props and forwa
|
|
|
962
952
|
**Mask Patterns:**
|
|
963
953
|
- `0` - any digit (0-9)
|
|
964
954
|
- `a` - any letter (a-z, A-Z)
|
|
965
|
-
- `*` - any
|
|
955
|
+
- `*` - any character
|
|
966
956
|
- `[]` - make input optional (example: `[00]` for optional digits)
|
|
967
|
-
- `{}` -
|
|
957
|
+
- `{}` - include fixed part in unmasked value
|
|
958
|
+
- ``` - prevent symbols shift back
|
|
959
|
+
- `\\` - escape character to treat definition characters as fixed (example: `\\0` treats 0 as literal)
|
|
968
960
|
|
|
969
961
|
**Label Behaviors:**
|
|
970
962
|
- `'auto'`: Default MUI behavior - label floats when focused or has value
|
|
@@ -972,7 +964,10 @@ The MaskedTextField component accepts all standard MUI TextField props and forwa
|
|
|
972
964
|
- `'static'`: Label appears as a static label above the input
|
|
973
965
|
|
|
974
966
|
**Advanced Masking:**
|
|
975
|
-
For
|
|
967
|
+
The current MaskedTextField component supports basic mask patterns. For more advanced masking scenarios like currency formatting, custom validation, or nested patterns with custom definitions and blocks, you would need to extend the component or use IMask directly.
|
|
968
|
+
|
|
969
|
+
**Available Mask Patterns:**
|
|
970
|
+
The component currently supports simple string patterns where each character in the mask string represents a constraint for the corresponding input character.
|
|
976
971
|
|
|
977
972
|
**SubscribeMaskedTextField:**
|
|
978
973
|
The `SubscribeMaskedTextField` component has the same props as `MaskedTextField` but automatically disables the field when the form is submitting, providing better UX during form submission.
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { IMaskInputProps } from 'react-imask';
|
|
2
2
|
export type MaskedInputProps = {
|
|
3
3
|
mask: IMaskInputProps<HTMLInputElement>['mask'];
|
|
4
|
+
pattern?: string;
|
|
5
|
+
definitions?: Record<string, RegExp>;
|
|
6
|
+
blocks?: Record<string, any>;
|
|
4
7
|
value?: string;
|
|
5
8
|
onChange?: (value: string) => void;
|
|
6
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaskedInput.d.ts","sourceRoot":"","sources":["../../src/lib/form/MaskedInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,eAAe,EAAE,MAAM,aAAa,CAAA;AAIzD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,eAAe,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACnC,CAAA;
|
|
1
|
+
{"version":3,"file":"MaskedInput.d.ts","sourceRoot":"","sources":["../../src/lib/form/MaskedInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,eAAe,EAAE,MAAM,aAAa,CAAA;AAIzD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,eAAe,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACnC,CAAA;AA0BD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,2CAiBlD"}
|
package/dist/form/MaskedInput.js
CHANGED
|
@@ -3,15 +3,16 @@ import { IMaskInput } from 'react-imask';
|
|
|
3
3
|
import { Input as MuiInput } from '@mui/material';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
const TextMaskCustom = React.forwardRef(function TextMaskCustom(props, ref) {
|
|
6
|
-
const { onChange,
|
|
7
|
-
return (_jsx(IMaskInput, { ...other,
|
|
8
|
-
'#': /[1-9]/,
|
|
9
|
-
}, inputRef: ref, onAccept: (value) => onChange({ target: { name: props.name, value } }), overwrite: true }));
|
|
6
|
+
const { onChange, ...other } = props;
|
|
7
|
+
return (_jsx(IMaskInput, { ...other, inputRef: ref, onAccept: (value) => onChange({ target: { name: props.name, value } }), overwrite: true }));
|
|
10
8
|
});
|
|
11
9
|
export function MaskedInput(props) {
|
|
12
|
-
const { mask, value, onChange } = props;
|
|
10
|
+
const { mask, value, onChange, definitions, blocks, pattern } = props;
|
|
13
11
|
return (_jsx(MuiInput, { value: value, onChange: e => onChange?.(e.target.value), name: 'maskedInput', inputComponent: TextMaskCustom, inputProps: {
|
|
14
12
|
mask: mask,
|
|
13
|
+
definitions: definitions,
|
|
14
|
+
blocks: blocks,
|
|
15
|
+
pattern: pattern,
|
|
15
16
|
} }));
|
|
16
17
|
}
|
|
17
18
|
//# sourceMappingURL=MaskedInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaskedInput.js","sourceRoot":"","sources":["../../src/lib/form/MaskedInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"MaskedInput.js","sourceRoot":"","sources":["../../src/lib/form/MaskedInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,KAAK,MAAM,OAAO,CA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