mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
ui: bug fix
This commit is contained in:
1 parent
03a6e79946
commit
fcd81fbcc9
2 files changed
+25
-6
No files matched your search
+24
-5
@@ -6,17 +6,31 @@ import PropTypes from 'prop-types';
|
||||
import api, { gql } from 'vj/utils/api';
|
||||
import AutoComplete from './AutoComplete';
|
||||
|
||||
interface UserSelectAutoCompleteProps {
|
||||
multi?: boolean;
|
||||
defaultItems?: string;
|
||||
width: string,
|
||||
height: string,
|
||||
listStyle: any,
|
||||
onChange: (value) => any,
|
||||
allowEmptyQuery: boolean,
|
||||
freeSolo: boolean,
|
||||
freeSoloConverter: any,
|
||||
}
|
||||
|
||||
// eslint-disable-next-line prefer-arrow-callback
|
||||
const UserSelectAutoComplete = forwardRef(function UserSelectAutoComplete(props, ref) {
|
||||
const UserSelectAutoComplete = forwardRef(function UserSelectAutoComplete(
|
||||
props: UserSelectAutoCompleteProps, ref: React.Ref<AutoComplete>,
|
||||
) {
|
||||
const multi = props.multi ?? false;
|
||||
const rawDefaultItems = props.defaultItems ?? '';
|
||||
const defaultItems = multi ? rawDefaultItems
|
||||
.split(',')
|
||||
.map((i) => i.trim())
|
||||
.filter((i) => i.length > 0)
|
||||
.filter((i) => i.length)
|
||||
.map((i) => +i) : rawDefaultItems;
|
||||
|
||||
const comRef = createRef();
|
||||
const comRef = createRef<AutoComplete>();
|
||||
const itemsBox = useRef([]);
|
||||
const { isLoading } = useQuery(['default_user', defaultItems], async () => {
|
||||
if (!multi || defaultItems.length === 0) return;
|
||||
@@ -35,8 +49,13 @@ const UserSelectAutoComplete = forwardRef(function UserSelectAutoComplete(props,
|
||||
}
|
||||
}, [itemsBox.current]);
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
...comRef.current,
|
||||
useImperativeHandle(ref, () => new Proxy(comRef, {
|
||||
get(target, propKey) {
|
||||
if (typeof target.current?.[propKey] === 'function') {
|
||||
return (...args: any[]) => target.current[propKey](...args);
|
||||
}
|
||||
return target.current?.[propKey];
|
||||
},
|
||||
}));
|
||||
|
||||
const itemsFn = (query) => api(gql`
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.29.3",
|
||||
"version": "4.29.4",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
Reference in new issue
Block a user