mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-19 11:34:59 +03:00
8332ba67ae
Upgrade frontend deps (antd 6.4.5 -> 6.5.0, Ant Design icons, TanStack Query, i18next, eslint) and fasthttp 1.71 -> 1.72. AntD 6.5 deprecated several Input/Card/Space props, so adapt the panel UI: - Input/InputNumber addonBefore/addonAfter -> prefix/suffix - Card bordered -> variant="outlined" - Space direction -> orientation - swap the hand-rolled Telegram SVG for the new TelegramFilled icon - guard SettingListItem against cloning aria-labelledby onto a Fragment, which only accepts key/children
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { cloneElement, Fragment, isValidElement, useId, type ReactElement, type ReactNode } from 'react';
|
|
import { Col, Row } from 'antd';
|
|
import './SettingListItem.css';
|
|
|
|
interface SettingListItemProps {
|
|
paddings?: 'small' | 'default';
|
|
title?: ReactNode;
|
|
description?: ReactNode;
|
|
children?: ReactNode;
|
|
control?: ReactNode;
|
|
}
|
|
|
|
export default function SettingListItem({
|
|
paddings = 'default',
|
|
title,
|
|
description,
|
|
children,
|
|
control,
|
|
}: SettingListItemProps) {
|
|
const padding = paddings === 'small' ? '10px 20px' : '20px';
|
|
const titleId = useId();
|
|
const node = control ?? children;
|
|
const labelledNode = title && isValidElement(node) && node.type !== Fragment
|
|
? cloneElement(node as ReactElement<{ 'aria-labelledby'?: string }>, { 'aria-labelledby': titleId })
|
|
: node;
|
|
return (
|
|
<div className="setting-list-item" style={{ padding }}>
|
|
<Row gutter={[8, 16]} style={{ width: '100%' }}>
|
|
<Col xs={24} lg={12}>
|
|
<div className="setting-list-meta">
|
|
{title && <div className="setting-list-title" id={titleId}>{title}</div>}
|
|
{description && <div className="setting-list-description">{description}</div>}
|
|
</div>
|
|
</Col>
|
|
<Col xs={24} lg={12}>
|
|
{labelledNode}
|
|
</Col>
|
|
</Row>
|
|
</div>
|
|
);
|
|
}
|