mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
feat: wip import resource UI
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import { Ref, useCallback } from 'react';
|
||||
import clsx from 'classnames';
|
||||
import {
|
||||
Accept,
|
||||
@@ -226,6 +227,7 @@ export const Dropzone = (_props: DropzoneProps) => {
|
||||
});
|
||||
|
||||
const isIdle = !isDragAccept && !isDragReject;
|
||||
assignRef(openRef, open);
|
||||
|
||||
return (
|
||||
<DropzoneProvider
|
||||
@@ -264,3 +266,26 @@ Dropzone.displayName = '@mantine/dropzone/Dropzone';
|
||||
Dropzone.Accept = DropzoneAccept;
|
||||
Dropzone.Idle = DropzoneIdle;
|
||||
Dropzone.Reject = DropzoneReject;
|
||||
|
||||
|
||||
|
||||
|
||||
type PossibleRef<T> = Ref<T> | undefined;
|
||||
|
||||
export function assignRef<T>(ref: PossibleRef<T>, value: T) {
|
||||
if (typeof ref === 'function') {
|
||||
ref(value);
|
||||
} else if (typeof ref === 'object' && ref !== null && 'current' in ref) {
|
||||
(ref as React.MutableRefObject<T>).current = value;
|
||||
}
|
||||
}
|
||||
|
||||
export function mergeRefs<T>(...refs: PossibleRef<T>[]) {
|
||||
return (node: T | null) => {
|
||||
refs.forEach((ref) => assignRef(ref, node));
|
||||
};
|
||||
}
|
||||
|
||||
export function useMergedRef<T>(...refs: PossibleRef<T>[]) {
|
||||
return useCallback(mergeRefs(...refs), refs);
|
||||
}
|
||||
Reference in New Issue
Block a user