diff --git a/packages/core/client/src/common/SelectWithTitle.tsx b/packages/core/client/src/common/SelectWithTitle.tsx new file mode 100644 index 0000000000..9e515d1aac --- /dev/null +++ b/packages/core/client/src/common/SelectWithTitle.tsx @@ -0,0 +1,44 @@ +import { Select } from 'antd'; +import React, { useRef, useState } from 'react'; + +export interface SelectWithTitleProps { + title?: any; + defaultValue?: any; + options?: any; + fieldNames?: any; + onChange?: (...args: any[]) => void; +} + +export function SelectWithTitle({ title, defaultValue, onChange, options, fieldNames }: SelectWithTitleProps) { + const [open, setOpen] = useState(false); + const timerRef = useRef(null); + return ( +
{ + e.stopPropagation(); + setOpen((v) => !v); + }} + onMouseLeave={() => { + timerRef.current = setTimeout(() => { + setOpen(false); + }, 200); + }} + > + {title} + { return fieldSchema?.['x-component-props']?.['pattern-disable'] == true; }; -interface SelectWithTitleProps { - title?: any; - defaultValue?: any; - options?: any; - onChange?: (...args: any[]) => void; -} -export function SelectWithTitle({ title, defaultValue, onChange, options }: SelectWithTitleProps) { - const [open, setOpen] = useState(false); - const timerRef = useRef(null); - return ( -
{ - e.stopPropagation(); - setOpen((v) => !v); - }} - onMouseLeave={() => { - timerRef.current = setTimeout(() => { - setOpen(false); - }, 200); - }} - > - {title} - { - api.auth.setRole(roleName); - await api.resource('users').setDefaultRole({ values: { roleName } }); - location.reload(); - window.location.reload(); - }} - onMouseEnter={() => { - clearTimeout(timerRef.current); - }} - /> -
- ); -}