fix
This commit is contained in:
parent
cbc22411b7
commit
a64af5fb1e
|
|
@ -31,6 +31,7 @@ export type PropTypeInput = {
|
||||||
| "import"
|
| "import"
|
||||||
| "monthly"
|
| "monthly"
|
||||||
| "key-value"
|
| "key-value"
|
||||||
|
| "mask"
|
||||||
| "phone";
|
| "phone";
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
onFocus?: (e: FocusEvent<HTMLDivElement>) => void;
|
onFocus?: (e: FocusEvent<HTMLDivElement>) => void;
|
||||||
|
|
@ -269,6 +270,45 @@ export const FieldTypeInput: FC<{
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
case "mask":
|
||||||
|
const mask = arg.mask || "____-____-_______";
|
||||||
|
return (
|
||||||
|
<div className="c-flex c-relative c-flex-1">
|
||||||
|
<InputMask
|
||||||
|
mask={mask}
|
||||||
|
replacement={{ _: /\d/ }}
|
||||||
|
onChange={(ev) => {
|
||||||
|
fm.data[field.name] = ev.currentTarget.value.replace(/\D/g, "");
|
||||||
|
renderOnChange();
|
||||||
|
|
||||||
|
if (prop.onChange) {
|
||||||
|
prop.onChange(fm.data[field.name]);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
value={format(value, {
|
||||||
|
mask: mask,
|
||||||
|
replacement: { _: /\d/ },
|
||||||
|
})}
|
||||||
|
placeholder={prop.placeholder || arg.placeholder || ""}
|
||||||
|
disabled={disabled}
|
||||||
|
className="c-flex-1 c-transition-all c-bg-transparent c-outline-none c-px-2 c-text-sm c-w-full"
|
||||||
|
spellCheck={false}
|
||||||
|
onFocus={(e) => {
|
||||||
|
field.focused = true;
|
||||||
|
field.render();
|
||||||
|
prop.onFocus?.(e);
|
||||||
|
}}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter" && fm.status === "ready") fm.submit();
|
||||||
|
}}
|
||||||
|
onBlur={(e) => {
|
||||||
|
field.focused = false;
|
||||||
|
field.render();
|
||||||
|
prop.onBlur?.(e);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
case "monthly": {
|
case "monthly": {
|
||||||
return (
|
return (
|
||||||
<Datepicker
|
<Datepicker
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ export type FieldProp = {
|
||||||
label: string;
|
label: string;
|
||||||
desc?: string;
|
desc?: string;
|
||||||
props?: any;
|
props?: any;
|
||||||
|
mask?:string;
|
||||||
kv?: { default: any; index: "preserve" | "auto-sort" };
|
kv?: { default: any; index: "preserve" | "auto-sort" };
|
||||||
upload?: {
|
upload?: {
|
||||||
mode: "single-file" | "multi-file";
|
mode: "single-file" | "multi-file";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue