This commit is contained in:
Rizky 2024-12-01 09:47:18 +00:00
parent bc73112e50
commit 1453a545ab
2 changed files with 59 additions and 19 deletions

View File

@ -237,24 +237,56 @@ export const FieldUploadSingle: FC<{
<FilePreview url={value || ""} />
{!disabled ? (
<>
<div
onClick={(e) => {
if (!disabled) {
e.preventDefault();
e.stopPropagation();
if (confirm("Clear this file ?")) {
input.fase = "start";
fm.data[field.name] = null;
fm.render();
{field.required !== true ? (
<div
onClick={(e) => {
if (!disabled) {
e.preventDefault();
e.stopPropagation();
if (confirm("Clear this file ?")) {
input.fase = "start";
fm.data[field.name] = null;
fm.render();
}
}
}
}}
className={cx(
"c-flex c-flex-row c-items-center c-border c-px-2 c-rounded c-cursor-pointer hover:c-bg-red-100"
)}
>
<Trash2 className="c-text-red-500 c-h-4 c-w-4" />
</div>
}}
className={cx(
"c-flex c-flex-row c-items-center c-border c-px-2 c-rounded c-cursor-pointer hover:c-bg-red-100"
)}
>
<Trash2 className="c-text-red-500 c-h-4 c-w-4" />
</div>
) : (
<>
<div
onClick={() => {
console.log(input.ref);
if (input.ref) {
input.ref.click();
}
}}
className="c-items-center c-flex c-text-base c-px-1 c-outline-none c-rounded c-cursor-pointer "
>
<div className="c-flex c-flex-row c-items-center c-px-2">
<Upload className="c-h-4 c-w-4" />
</div>
<div className="c-flex c-flex-row c-items-center c-text-sm">
Replace
</div>
</div>
<input
ref={(ref) => (input.ref = ref)}
type="file"
multiple={false}
// accept={field.prop.upload?.accept}
accept={"file/**"}
onChange={on_upload}
className={cx(
"c-absolute c-w-full c-h-full c-cursor-pointer c-top-0 c-left-0 c-opacity-0"
)}
/>
</>
)}
</>
) : (
<></>

View File

@ -17,7 +17,7 @@ export const toast = {
sonner.dismiss(t.id);
}
}
sonner.dismiss()
sonner.dismiss();
} else {
clearTimeout(timer.timeout);
timer.timeout = null;
@ -31,6 +31,7 @@ export const toast = {
timer.timeout = setTimeout(() => {
toast.toasting.push(
sonner.loading(el, {
dismissible: true,
...props,
onDismiss: (t) => {
toast.toasting = toast.toasting.filter((e) => e !== t.id);
@ -42,12 +43,18 @@ export const toast = {
},
success: (
el: ReactElement,
props?: { dismissible?: boolean; className?: string; duration?: number }
props?: {
dismissible?: boolean;
className?: string;
duration?: number;
onClick?: () => void;
}
) => {
clearTimeout(timer.timeout);
timer.timeout = setTimeout(() => {
toast.toasting.push(
sonner.success(el, {
dismissible: true,
...props,
onDismiss: (t) => {
toast.toasting = toast.toasting.filter((e) => e !== t.id);
@ -65,6 +72,7 @@ export const toast = {
timer.timeout = setTimeout(() => {
toast.toasting.push(
sonner.error(el, {
dismissible: true,
...props,
onDismiss: (t) => {
toast.toasting = toast.toasting.filter((e) => e !== t.id);