Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kne/column-split",
"version": "1.0.3",
"version": "1.0.4",
"description": "通过拖动分隔条分配元素占比",
"syntax": {
"esmodules": true
Expand Down
56 changes: 29 additions & 27 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,33 +99,35 @@ const ColumnSplit = ({ columns = [], className, renderItem, readOnly, disabled,
);
})}
</Splitter>
<Space.Compact block>
{disabledColumns.map((column, index) => {
const itemValue = 0;
const valueStr = typeof column.render === 'function' ? column.render({ value: itemValue }) : `${Math.round(100 * itemValue)}%`;
const el = (
<Button
variant="outlined"
className={style['zero-item']}
shape="round"
size="small"
style={{
'--color': column.color
}}
onClick={() => {
const newValue = showColumn(value, column, activeColumns);
onChange(newValue);
}}
>
<Flex align="center" justify="center">
{column.title}
<span>{valueStr}</span>
</Flex>
</Button>
);
return <Fragment key={column.name || index}>{typeof renderItem === 'function' ? renderItem({ item: column, value: itemValue, valueStr, el, index }) : el}</Fragment>;
})}
</Space.Compact>
{disabled || readOnly || !allowZero ? null : (
<Space.Compact block>
{disabledColumns.map((column, index) => {
const itemValue = 0;
const valueStr = typeof column.render === 'function' ? column.render({ value: itemValue }) : `${Math.round(100 * itemValue)}%`;
const el = (
<Button
variant="outlined"
className={style['zero-item']}
shape="round"
size="small"
style={{
'--color': column.color
}}
onClick={() => {
const newValue = showColumn(value, column, activeColumns);
onChange(newValue);
}}
>
<Flex align="center" justify="center">
{column.title}
<span>{valueStr}</span>
</Flex>
</Button>
);
return <Fragment key={column.name || index}>{typeof renderItem === 'function' ? renderItem({ item: column, value: itemValue, valueStr, el, index }) : el}</Fragment>;
})}
</Space.Compact>
)}
</Flex>
);
};
Expand Down
Loading