fix lib
This commit is contained in:
parent
bc73112e50
commit
1453a545ab
|
|
@ -237,6 +237,7 @@ export const FieldUploadSingle: FC<{
|
||||||
<FilePreview url={value || ""} />
|
<FilePreview url={value || ""} />
|
||||||
{!disabled ? (
|
{!disabled ? (
|
||||||
<>
|
<>
|
||||||
|
{field.required !== true ? (
|
||||||
<div
|
<div
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
if (!disabled) {
|
if (!disabled) {
|
||||||
|
|
@ -255,6 +256,37 @@ export const FieldUploadSingle: FC<{
|
||||||
>
|
>
|
||||||
<Trash2 className="c-text-red-500 c-h-4 c-w-4" />
|
<Trash2 className="c-text-red-500 c-h-4 c-w-4" />
|
||||||
</div>
|
</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"
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ export const toast = {
|
||||||
sonner.dismiss(t.id);
|
sonner.dismiss(t.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sonner.dismiss()
|
sonner.dismiss();
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(timer.timeout);
|
clearTimeout(timer.timeout);
|
||||||
timer.timeout = null;
|
timer.timeout = null;
|
||||||
|
|
@ -31,6 +31,7 @@ export const toast = {
|
||||||
timer.timeout = setTimeout(() => {
|
timer.timeout = setTimeout(() => {
|
||||||
toast.toasting.push(
|
toast.toasting.push(
|
||||||
sonner.loading(el, {
|
sonner.loading(el, {
|
||||||
|
dismissible: true,
|
||||||
...props,
|
...props,
|
||||||
onDismiss: (t) => {
|
onDismiss: (t) => {
|
||||||
toast.toasting = toast.toasting.filter((e) => e !== t.id);
|
toast.toasting = toast.toasting.filter((e) => e !== t.id);
|
||||||
|
|
@ -42,12 +43,18 @@ export const toast = {
|
||||||
},
|
},
|
||||||
success: (
|
success: (
|
||||||
el: ReactElement,
|
el: ReactElement,
|
||||||
props?: { dismissible?: boolean; className?: string; duration?: number }
|
props?: {
|
||||||
|
dismissible?: boolean;
|
||||||
|
className?: string;
|
||||||
|
duration?: number;
|
||||||
|
onClick?: () => void;
|
||||||
|
}
|
||||||
) => {
|
) => {
|
||||||
clearTimeout(timer.timeout);
|
clearTimeout(timer.timeout);
|
||||||
timer.timeout = setTimeout(() => {
|
timer.timeout = setTimeout(() => {
|
||||||
toast.toasting.push(
|
toast.toasting.push(
|
||||||
sonner.success(el, {
|
sonner.success(el, {
|
||||||
|
dismissible: true,
|
||||||
...props,
|
...props,
|
||||||
onDismiss: (t) => {
|
onDismiss: (t) => {
|
||||||
toast.toasting = toast.toasting.filter((e) => e !== t.id);
|
toast.toasting = toast.toasting.filter((e) => e !== t.id);
|
||||||
|
|
@ -65,6 +72,7 @@ export const toast = {
|
||||||
timer.timeout = setTimeout(() => {
|
timer.timeout = setTimeout(() => {
|
||||||
toast.toasting.push(
|
toast.toasting.push(
|
||||||
sonner.error(el, {
|
sonner.error(el, {
|
||||||
|
dismissible: true,
|
||||||
...props,
|
...props,
|
||||||
onDismiss: (t) => {
|
onDismiss: (t) => {
|
||||||
toast.toasting = toast.toasting.filter((e) => e !== t.id);
|
toast.toasting = toast.toasting.filter((e) => e !== t.id);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue