style: multiple selection tag
This commit is contained in:
@@ -8,6 +8,7 @@ import React, {
|
|||||||
useRef,
|
useRef,
|
||||||
useState
|
useState
|
||||||
} from 'react';
|
} from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
import { TooltipOverlayScroller } from '../overlay-scroller';
|
import { TooltipOverlayScroller } from '../overlay-scroller';
|
||||||
|
|
||||||
// type TagProps = React.ComponentProps<typeof Tag>;
|
// type TagProps = React.ComponentProps<typeof Tag>;
|
||||||
@@ -22,9 +23,18 @@ interface AutoTooltipProps extends Omit<TagProps, 'title'> {
|
|||||||
title?: React.ReactNode;
|
title?: React.ReactNode;
|
||||||
showTitle?: boolean;
|
showTitle?: boolean;
|
||||||
closable?: boolean;
|
closable?: boolean;
|
||||||
|
radius?: number | string;
|
||||||
|
filled?: boolean;
|
||||||
tooltipProps?: React.ComponentProps<typeof Tooltip>;
|
tooltipProps?: React.ComponentProps<typeof Tooltip>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const StyledTag = styled(Tag)`
|
||||||
|
&.tag-filled {
|
||||||
|
border: none;
|
||||||
|
background-color: var(--ant-color-fill-secondary);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
const AutoTooltip: React.FC<AutoTooltipProps> = ({
|
const AutoTooltip: React.FC<AutoTooltipProps> = ({
|
||||||
children,
|
children,
|
||||||
maxWidth = '100%',
|
maxWidth = '100%',
|
||||||
@@ -33,6 +43,8 @@ const AutoTooltip: React.FC<AutoTooltipProps> = ({
|
|||||||
title,
|
title,
|
||||||
showTitle = false,
|
showTitle = false,
|
||||||
tooltipProps,
|
tooltipProps,
|
||||||
|
radius = 12,
|
||||||
|
filled = false,
|
||||||
...tagProps
|
...tagProps
|
||||||
}) => {
|
}) => {
|
||||||
const contentRef = useRef<HTMLDivElement>(null);
|
const contentRef = useRef<HTMLDivElement>(null);
|
||||||
@@ -103,13 +115,14 @@ const AutoTooltip: React.FC<AutoTooltipProps> = ({
|
|||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<Tag
|
<StyledTag
|
||||||
{...tagProps}
|
{...tagProps}
|
||||||
|
className={`${tagProps.className || ''} ${filled ? 'tag-filled' : ''}`}
|
||||||
ref={contentRef}
|
ref={contentRef}
|
||||||
style={{
|
style={{
|
||||||
...tagStyle,
|
...tagStyle,
|
||||||
paddingInline: tagProps.closable ? '8px 22px' : 8,
|
paddingInline: tagProps.closable ? '8px 22px' : 8,
|
||||||
borderRadius: 12
|
borderRadius: radius
|
||||||
}}
|
}}
|
||||||
closeIcon={
|
closeIcon={
|
||||||
tagProps.closable ? (
|
tagProps.closable ? (
|
||||||
@@ -117,7 +130,8 @@ const AutoTooltip: React.FC<AutoTooltipProps> = ({
|
|||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
right: 8,
|
right: 8,
|
||||||
top: 6
|
top: '50%',
|
||||||
|
transform: 'translateY(-50%)'
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -126,7 +140,7 @@ const AutoTooltip: React.FC<AutoTooltipProps> = ({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Tag>
|
</StyledTag>
|
||||||
)}
|
)}
|
||||||
</TooltipOverlayScroller>
|
</TooltipOverlayScroller>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import React, {
|
|||||||
useRef,
|
useRef,
|
||||||
useState
|
useState
|
||||||
} from 'react';
|
} from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
import LogsList from './logs-list';
|
import LogsList from './logs-list';
|
||||||
import LogsPagination from './logs-pagination';
|
import LogsPagination from './logs-pagination';
|
||||||
import './styles/index.less';
|
import './styles/index.less';
|
||||||
@@ -26,6 +27,13 @@ interface LogsViewerProps {
|
|||||||
enableScorllLoad?: boolean;
|
enableScorllLoad?: boolean;
|
||||||
diffHeight?: number;
|
diffHeight?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const PaginationWrapper = styled.div`
|
||||||
|
position: absolute;
|
||||||
|
right: 50px;
|
||||||
|
top: 30px;
|
||||||
|
`;
|
||||||
|
|
||||||
const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
|
const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
|
||||||
const { diffHeight, url, tail: defaultTail, enableScorllLoad = true } = props;
|
const { diffHeight, url, tail: defaultTail, enableScorllLoad = true } = props;
|
||||||
const { pageSize, page, setPage, setTotalPage, totalPage } =
|
const { pageSize, page, setPage, setTotalPage, totalPage } =
|
||||||
@@ -294,6 +302,16 @@ const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="logs-viewer-wrap-w2">
|
<div className="logs-viewer-wrap-w2">
|
||||||
|
{/* <PaginationWrapper>
|
||||||
|
<Pagination
|
||||||
|
simple={{ readOnly: true }}
|
||||||
|
total={totalPage}
|
||||||
|
current={page}
|
||||||
|
pageSize={pageSize}
|
||||||
|
showSizeChanger={false}
|
||||||
|
hideOnSinglePage={false}
|
||||||
|
></Pagination>
|
||||||
|
</PaginationWrapper> */}
|
||||||
<div className="wrap">
|
<div className="wrap">
|
||||||
<div>
|
<div>
|
||||||
<LogsList
|
<LogsList
|
||||||
|
|||||||
@@ -1,20 +1,33 @@
|
|||||||
import AutoTooltip from '@/components/auto-tooltip';
|
import AutoTooltip from '@/components/auto-tooltip';
|
||||||
|
import React, { useMemo } from 'react';
|
||||||
|
|
||||||
interface SelectRenderProps {
|
interface SelectRenderProps {
|
||||||
maxTagWidth?: number;
|
maxTagWidth?: number;
|
||||||
|
radius?: number | string;
|
||||||
|
style?: React.CSSProperties;
|
||||||
|
filled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function useSelectRender(config?: SelectRenderProps) {
|
export default function useSelectRender(config?: SelectRenderProps) {
|
||||||
const { maxTagWidth = 100 } = config || {};
|
const { maxTagWidth = 100, radius, filled, style } = config || {};
|
||||||
const TagRender = (props: any) => {
|
const TagRender = (props: any) => {
|
||||||
const { label } = props;
|
const { label } = props;
|
||||||
|
const labelText = useMemo(() => {
|
||||||
|
if (!props.isMaxTag) {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
return label.slice(0, -3);
|
||||||
|
}, [label, props.isMaxTag]);
|
||||||
return (
|
return (
|
||||||
<AutoTooltip
|
<AutoTooltip
|
||||||
maxWidth={maxTagWidth}
|
maxWidth={maxTagWidth}
|
||||||
closable={props.closable}
|
closable={props.closable}
|
||||||
onClose={props.onClose}
|
onClose={props.onClose}
|
||||||
|
radius={radius}
|
||||||
|
filled={filled}
|
||||||
|
style={style}
|
||||||
>
|
>
|
||||||
{label}
|
{labelText}
|
||||||
</AutoTooltip>
|
</AutoTooltip>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import SelectWrapper from './wrapper/select';
|
|||||||
|
|
||||||
const tag = (props: any) => {
|
const tag = (props: any) => {
|
||||||
if (props.isMaxTag) {
|
if (props.isMaxTag) {
|
||||||
return props.label;
|
return props.label?.slice(0, -3);
|
||||||
}
|
}
|
||||||
const parent = _.split(props.value, '__RC_CASCADER_SPLIT__')?.[0];
|
const parent = _.split(props.value, '__RC_CASCADER_SPLIT__')?.[0];
|
||||||
return `${parent} / ${props?.label}`;
|
return `${parent} / ${props?.label}`;
|
||||||
@@ -24,6 +24,7 @@ const renderTag = (props: any) => {
|
|||||||
closable={props.closable}
|
closable={props.closable}
|
||||||
onClose={props.onClose}
|
onClose={props.onClose}
|
||||||
maxWidth={240}
|
maxWidth={240}
|
||||||
|
filled
|
||||||
>
|
>
|
||||||
{tag(props)}
|
{tag(props)}
|
||||||
</AutoTooltip>
|
</AutoTooltip>
|
||||||
|
|||||||
+3
-5
@@ -277,12 +277,10 @@ body {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ant-pro-base-menu-vertical-item-title {
|
.ant-pro-base-menu-vertical-item-title,
|
||||||
// height: var(--ant-menu-item-height) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-pro-base-menu-vertical-item-title-collapsed {
|
.ant-pro-base-menu-vertical-item-title-collapsed {
|
||||||
// height: var(--ant-menu-item-height) !important;
|
height: var(--ant-menu-item-height) !important;
|
||||||
|
line-height: var(--ant-menu-item-height) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ant-pro-layout {
|
.ant-pro-layout {
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ const FilterWrapper = styled.div`
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
.ant-select-selection-overflow-item > span {
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
interface RequestTokenData {
|
interface RequestTokenData {
|
||||||
@@ -99,7 +102,12 @@ export default function useUseageData<T>(config: {
|
|||||||
const { url, defaultData, disabledDate = false } = config || {};
|
const { url, defaultData, disabledDate = false } = config || {};
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const { TagRender } = useSelectRender({
|
const { TagRender } = useSelectRender({
|
||||||
maxTagWidth: 100
|
maxTagWidth: 100,
|
||||||
|
filled: true,
|
||||||
|
style: {
|
||||||
|
height: 24,
|
||||||
|
lineHeight: '24px'
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const { disabledRangeDaysDate, rangePresets } = useRangePickerPreset({
|
const { disabledRangeDaysDate, rangePresets } = useRangePickerPreset({
|
||||||
range: DefaultDateConfig.maxRange,
|
range: DefaultDateConfig.maxRange,
|
||||||
@@ -332,7 +340,10 @@ export default function useUseageData<T>(config: {
|
|||||||
<div className="selection">
|
<div className="selection">
|
||||||
<DatePicker.RangePicker
|
<DatePicker.RangePicker
|
||||||
maxDate={dayjs()}
|
maxDate={dayjs()}
|
||||||
defaultValue={[dayjs().add(-29, 'd'), dayjs()]}
|
defaultValue={[
|
||||||
|
dayjs().add(-DefaultDateConfig.defaultRange, 'd'),
|
||||||
|
dayjs()
|
||||||
|
]}
|
||||||
disabledDate={disabledRangeDaysDate}
|
disabledDate={disabledRangeDaysDate}
|
||||||
presets={rangePresets}
|
presets={rangePresets}
|
||||||
allowClear={false}
|
allowClear={false}
|
||||||
|
|||||||
@@ -209,12 +209,6 @@ const MessageInput: React.FC<MessageInputProps> = forwardRef(
|
|||||||
const handleClearAll = (e: any) => {
|
const handleClearAll = (e: any) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
clearAll();
|
clearAll();
|
||||||
// handleInputChange({ target: { value: '' } });
|
|
||||||
// setMessage({
|
|
||||||
// role: Roles.User,
|
|
||||||
// content: '',
|
|
||||||
// imgs: []
|
|
||||||
// });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddMessage = (e?: any) => {
|
const handleAddMessage = (e?: any) => {
|
||||||
|
|||||||
@@ -114,11 +114,15 @@ const ModelItem: React.FC<ModelItemProps> = forwardRef((props, ref) => {
|
|||||||
handleDeleteModel(instanceId);
|
handleDeleteModel(instanceId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const generateValidMessage = (message: Omit<MessageItem, 'uid'>) => {
|
||||||
|
if (!message.content && !message.imgs?.length && !message.audio?.length) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
};
|
||||||
|
|
||||||
const handleSubmit = (currentMessage: Omit<MessageItem, 'uid'>) => {
|
const handleSubmit = (currentMessage: Omit<MessageItem, 'uid'>) => {
|
||||||
const currentMsg =
|
const currentMsg = generateValidMessage(currentMessage);
|
||||||
currentMessage.content || currentMessage.imgs?.length
|
|
||||||
? currentMessage
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
submitMessage({
|
submitMessage({
|
||||||
system: systemMessage
|
system: systemMessage
|
||||||
@@ -289,11 +293,11 @@ const ModelItem: React.FC<ModelItemProps> = forwardRef((props, ref) => {
|
|||||||
</Dropdown>
|
</Dropdown>
|
||||||
<Popover
|
<Popover
|
||||||
autoAdjustOverflow={true}
|
autoAdjustOverflow={true}
|
||||||
overlayInnerStyle={{ width: 384, paddingInline: 0 }}
|
overlayInnerStyle={{ width: 375, paddingInline: 0 }}
|
||||||
content={
|
content={
|
||||||
<OverlayScroller
|
<OverlayScroller
|
||||||
maxHeight={500}
|
maxHeight={500}
|
||||||
style={{ paddingInline: '16px' }}
|
style={{ paddingInline: '24px' }}
|
||||||
oppositeTheme={true}
|
oppositeTheme={true}
|
||||||
>
|
>
|
||||||
<DynamicParams
|
<DynamicParams
|
||||||
@@ -302,21 +306,25 @@ const ModelItem: React.FC<ModelItemProps> = forwardRef((props, ref) => {
|
|||||||
paramsConfig={paramsConfig}
|
paramsConfig={paramsConfig}
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
showModelSelector={false}
|
showModelSelector={false}
|
||||||
|
parametersTitle={
|
||||||
|
<div className="flex-center flex-between">
|
||||||
|
<span>
|
||||||
|
{intl.formatMessage({ id: 'playground.parameters' })}
|
||||||
|
</span>
|
||||||
|
<Checkbox onChange={handleApplyToAllModels}>
|
||||||
|
{intl.formatMessage({
|
||||||
|
id: 'playground.compare.applytoall'
|
||||||
|
})}
|
||||||
|
</Checkbox>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</OverlayScroller>
|
</OverlayScroller>
|
||||||
}
|
}
|
||||||
trigger={['click']}
|
trigger={['click']}
|
||||||
arrow={false}
|
arrow={false}
|
||||||
fresh={true}
|
fresh={true}
|
||||||
title={
|
title={false}
|
||||||
<div style={{ paddingInline: '16px' }}>
|
|
||||||
<Checkbox onChange={handleApplyToAllModels}>
|
|
||||||
{intl.formatMessage({
|
|
||||||
id: 'playground.compare.applytoall'
|
|
||||||
})}
|
|
||||||
</Checkbox>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
type="text"
|
type="text"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
padding-left: 16px;
|
padding-left: 16px;
|
||||||
background: var(--ant-color-fill-tertiary);
|
background: var(--ant-color-fill-tertiary);
|
||||||
|
color: var(--ant-color-text-secondary);
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
list-style-type: decimal;
|
list-style-type: decimal;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user