2024-08-02 22:31:46 +08:00
|
|
|
import React, { useMemo } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import classnames from 'classnames';
|
2024-08-15 17:38:42 +08:00
|
|
|
import { Icon } from '@seafile/sf-metadata-ui-component';
|
2024-09-14 16:31:32 +08:00
|
|
|
import { CellType, COLUMNS_ICON_CONFIG } from '../../../metadata/constants';
|
2024-08-02 22:31:46 +08:00
|
|
|
|
|
|
|
import './index.css';
|
|
|
|
|
2025-02-17 11:50:29 +08:00
|
|
|
const DetailItem = ({ readonly = true, field, className, children }) => {
|
2024-08-02 22:31:46 +08:00
|
|
|
const icon = useMemo(() => {
|
|
|
|
if (field.type === 'size') return COLUMNS_ICON_CONFIG[CellType.NUMBER];
|
|
|
|
return COLUMNS_ICON_CONFIG[field.type];
|
|
|
|
}, [field]);
|
|
|
|
|
|
|
|
return (
|
2024-08-15 17:38:42 +08:00
|
|
|
<div className={classnames('dirent-detail-item', className)}>
|
2024-10-16 17:20:37 +08:00
|
|
|
<div className="dirent-detail-item-name d-flex">
|
|
|
|
<div><Icon iconName={icon} /></div>
|
2024-08-07 14:01:01 +08:00
|
|
|
<span className="dirent-detail-item-name-value">{field.name}</span>
|
2024-08-02 22:31:46 +08:00
|
|
|
</div>
|
2024-08-15 17:38:42 +08:00
|
|
|
<div className={classnames('dirent-detail-item-value', { 'editable': !readonly })} >
|
|
|
|
{children}
|
2024-08-02 22:31:46 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
DetailItem.propTypes = {
|
2024-08-15 17:38:42 +08:00
|
|
|
readonly: PropTypes.bool,
|
2024-08-02 22:31:46 +08:00
|
|
|
field: PropTypes.object.isRequired,
|
2024-08-15 17:38:42 +08:00
|
|
|
className: PropTypes.string,
|
2024-08-02 22:31:46 +08:00
|
|
|
children: PropTypes.any,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default DetailItem;
|