fix
This commit is contained in:
parent
c11982132f
commit
cb3299d1ef
|
|
@ -36,7 +36,8 @@ export const Field: FC<FieldProp> = (arg) => {
|
|||
delete props.className;
|
||||
|
||||
return (
|
||||
<label
|
||||
<LabelDiv
|
||||
mode={sub_type === "table-edit" ? "div" : "label"}
|
||||
className={cx(
|
||||
"field",
|
||||
"c-flex",
|
||||
|
|
@ -89,6 +90,17 @@ export const Field: FC<FieldProp> = (arg) => {
|
|||
</div>
|
||||
)}
|
||||
</div>
|
||||
</label>
|
||||
</LabelDiv>
|
||||
);
|
||||
};
|
||||
|
||||
const LabelDiv = (arg: any) => {
|
||||
const props = { ...arg };
|
||||
const mode = arg.mode;
|
||||
delete props.mode;
|
||||
|
||||
if (mode === "label") {
|
||||
return <label {...props} />;
|
||||
}
|
||||
return <div {...props} />;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ export const FieldTypeInput: FC<{
|
|||
type_field = "text";
|
||||
}
|
||||
|
||||
let display: any = null;
|
||||
let value: any = fm.data[field.name] || "";
|
||||
|
||||
// let value: any = "2024-05-14T05:58:01.376Z" // case untuk date time
|
||||
|
|
@ -176,7 +175,11 @@ export const FieldTypeInput: FC<{
|
|||
/>
|
||||
);
|
||||
case "money":
|
||||
return <FieldMoney field={field} fm={fm} prop={prop} arg={arg} />;
|
||||
return (
|
||||
<>
|
||||
<FieldMoney field={field} fm={fm} prop={prop} arg={arg} />
|
||||
</>
|
||||
);
|
||||
case "rich-text":
|
||||
return <FieldRichText field={field} fm={fm} prop={prop} />;
|
||||
case "date":
|
||||
|
|
@ -230,7 +233,6 @@ export const FieldTypeInput: FC<{
|
|||
spellCheck={false}
|
||||
onFocus={(e) => {
|
||||
field.focused = true;
|
||||
display = "";
|
||||
field.render();
|
||||
prop.onFocus?.(e);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -13,39 +13,21 @@ export const FieldMoney: FC<{
|
|||
let value: any = fm.data[field.name];
|
||||
const input = useLocal({
|
||||
value: 0 as any,
|
||||
display: false as any,
|
||||
ref: null as any,
|
||||
});
|
||||
useEffect(() => {
|
||||
input.value = value;
|
||||
input.render();
|
||||
}, [fm.data[field.name]]);
|
||||
let display: any = null;
|
||||
|
||||
const disabled =
|
||||
typeof field.disabled === "function" ? field.disabled() : field.disabled;
|
||||
const money = formatMoney(Number(value) || 0);
|
||||
return (
|
||||
<div className="c-flex-grow c-flex-row c-flex c-w-full c-h-full">
|
||||
{/* <div
|
||||
className={cx(
|
||||
input.display ? "c-hidden" : "",
|
||||
"c-flex-grow c-px-2 c-flex c-flex-row c-items-center",
|
||||
isEmptyString(value) ? "c-text-gray-400" : ""
|
||||
)}
|
||||
onClick={() => {
|
||||
if (input.ref) {
|
||||
input.display = !input.display;
|
||||
input.ref.focus();
|
||||
input.render();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{isEmptyString(value) ? arg.placeholder : money}
|
||||
</div> */}
|
||||
<input
|
||||
ref={(el) => (input.ref = el)}
|
||||
type={"text"}
|
||||
onClick={() => {}}
|
||||
onChange={(ev) => {
|
||||
const rawValue = ev.currentTarget.value
|
||||
.replace(/[^0-9,-]/g, "")
|
||||
|
|
@ -80,20 +62,23 @@ export const FieldMoney: FC<{
|
|||
value={formatCurrency(input.value)}
|
||||
disabled={disabled}
|
||||
className={cx(
|
||||
// !input.display ? "c-hidden" : "",
|
||||
"c-flex-1 c-bg-transparent c-outline-none c-px-2 c-text-sm c-w-full"
|
||||
)}
|
||||
spellCheck={false}
|
||||
onFocus={() => {
|
||||
onFocus={(e) => {
|
||||
field.focused = true;
|
||||
field.render();
|
||||
prop.onFocus?.(e);
|
||||
}}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
placeholder={arg.placeholder || ""}
|
||||
onBlur={() => {
|
||||
onBlur={(e) => {
|
||||
field.focused = false;
|
||||
input.display = !input.display;
|
||||
input.render();
|
||||
field.render();
|
||||
prop.onBlur?.(e);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue