Skip to content

Commit

Permalink
Merge pull request #937 from sheinsight/fix-ui-issues2
Browse files Browse the repository at this point in the history
fix: 修复 `Table` 在虚拟列表大数据下拖拽滚动条时的性能问题 & UI验收问题
  • Loading branch information
saint3347 authored Jan 21, 2025
2 parents fb6ec85 + 1a9cf2e commit 6fc7615
Show file tree
Hide file tree
Showing 53 changed files with 230 additions and 615 deletions.
7 changes: 6 additions & 1 deletion docs/theme/components/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,17 @@ export default createUseStyles(
display: 'flex',
marginTop: top,
position: 'relative',
overflow: 'auto',
'& .examples': {
flex: 1,
minWidth: 0,
minWidth: 800,
},
'& .anchor': {
width: 192,

'@media (max-width: 1200px)': {
display: 'none',
},
},
},
guide: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sheinx",
"private": true,
"version": "3.5.8-beta.7",
"version": "3.5.8-beta.8",
"description": "A react library developed with sheinx",
"module": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
5 changes: 3 additions & 2 deletions packages/base/src/alert/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Alert = (props: AlertProps) => {
children,
icon,
title,
titleStyle,
iconSize,
closable,
hideClose,
Expand Down Expand Up @@ -75,7 +76,7 @@ const Alert = (props: AlertProps) => {
};

const renderIcon = () => {
const style: { width?: number } = {};
const style: React.CSSProperties = titleStyle || {}
if (iconSize) {
style.width = iconSize;
}
Expand All @@ -91,7 +92,7 @@ const Alert = (props: AlertProps) => {
};

const renderTitle = () => {
return <div className={alertStyle.title}>{title}</div>;
return <div className={alertStyle.title} style={titleStyle}>{title}</div>;
};

const renderClose = () => {
Expand Down
7 changes: 7 additions & 0 deletions packages/base/src/alert/alert.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ export interface AlertProps extends Pick<CommonType, 'className' | 'style'> {
* @cn 标题模式
*/
title?: React.ReactNode;

/**
* @en The style of the title
* @cn 标题样式
* @private
*/
titleStyle?: React.CSSProperties;
/**
* @en Whether to display the close button, when set to only, only the close button is displayed
* @cn 是否可以关闭Alert,当设置为only的时候,点击按钮不会自动隐藏Alert
Expand Down
1 change: 1 addition & 0 deletions packages/base/src/popover/confirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const Confirm = (props: PopoverConfirmProps) => {
jssStyle={jssStyle}
type={type as any}
title={title}
titleStyle={{ fontSize: 14 }}
icon={icon}
>
{children}
Expand Down
8 changes: 4 additions & 4 deletions packages/hooks/src/components/use-table/use-table-virtual.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { usePersistFn } from '../../common/use-persist-fn';
import { useState, useRef, useEffect, useMemo, useLayoutEffect } from 'react';
import { useState, useRef, useEffect, useMemo } from 'react';
import { TableFormatColumn } from './use-table.type';

// 找出最大的连续数字的个数
Expand Down Expand Up @@ -147,7 +147,7 @@ const useTableVirtual = (props: UseTableVirtualProps) => {
}
});

const updateIndexAndTopFromTop = (scrollTop: number) => {
const updateIndexAndTopFromTop = (scrollTop: number, fromDrag?: boolean) => {
if (props.disabled) return;
let sum = 0;
let currentIndex = 0;
Expand Down Expand Up @@ -187,7 +187,7 @@ const useTableVirtual = (props: UseTableVirtualProps) => {
setStartIndex(currentIndex);

// startIndex处于上方某个合并行的中间一行时,可能引起translate闪烁
if(startIndex < currentIndex){
if(!fromDrag && startIndex < currentIndex){
context.autoAddRows = currentIndex - startIndex
setTimeout(() => {
context.autoAddRows = 0
Expand Down Expand Up @@ -252,7 +252,7 @@ const useTableVirtual = (props: UseTableVirtualProps) => {
// 拖动滚动条
if (fromDrag) {
const top = y * max;
updateIndexAndTopFromTop(top);
updateIndexAndTopFromTop(top, fromDrag);
if (context.rateTimer) clearTimeout(context.rateTimer);
context.rateTimer = setTimeout(() => {
updateRateScroll(y);
Expand Down
11 changes: 6 additions & 5 deletions packages/shineout-style/src/alert/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ const alertStyle: JsStyles<keyof AlertClasses> = {
},
widthTitle: {
'& $icon': {
fontSize: Token.alertTitleFontSize,
// marginBottom: Token.alertNearlyMargin,
width: Token.alertTitleIconWidth,
height: Token.alertTitleIconHeight,
height: Token.lineHeightDynamic,
},
'& $title': {
lineHeight: Token.lineHeightDynamic,
},
'& $close': {
// marginBottom: Token.alertNearlyMargin,
// marginTop: 2,
'& $closeWrapper': {
fontSize: Token.alertTitleFontSize,
},
},
title: {
Expand Down Expand Up @@ -103,8 +103,9 @@ const alertStyle: JsStyles<keyof AlertClasses> = {
},
},
closeWrapper: {
fontSize: Token.alertFontSize,
width: Token.alertFontSize,
height: `calc(${Token.lineHeightDynamic} + 2px)`,
height: Token.lineHeightDynamic,
display: 'flex',
alignItems: 'center',
marginLeft: Token.alertNearlyMargin,
Expand Down
5 changes: 5 additions & 0 deletions packages/shineout-style/src/descriptions/descriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ const descriptionsStyle: JsStyles<DescriptionsClassType> = {
'& $item': {
paddingBottom: 0,
},
'& $row': {
'& td:last-child': {
borderRight: 'none',
}
},
},
};

Expand Down
4 changes: 2 additions & 2 deletions packages/shineout/src/descriptions/__example__/02-colums.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const data = [

export default () => {
return (
<div style={{ marginBottom: '-12px' }}>
<>
<Descriptions
items={data}
title='User Info'
Expand All @@ -39,6 +39,6 @@ export default () => {
column={1}
labelStyle={{ textAlign: 'end' }}
/>
</div>
</>
);
};
4 changes: 2 additions & 2 deletions packages/shineout/src/descriptions/__example__/04-border.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default () => {
layout='horizontal'
border
tableLayout='fixed'
style={{ marginBottom: '20px' }}
style={{ marginBottom: 24 }}
/>
<Descriptions
items={data}
Expand All @@ -48,7 +48,7 @@ export default () => {
border
tableLayout='fixed'
labelStyle={{ textAlign: 'end' }}
style={{ marginBottom: '20px' }}
style={{ marginBottom: 24 }}
/>
<Descriptions
items={data}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default () => {
border={border}
labelStyle={{
marginBottom: layout === 'inlineVertical' ? '2px' : '',
paddingBottom: layout === 'vertical' ? '2px' : '',
paddingBottom: layout === 'vertical' && !border ? '2px' : '',
}}
/>
</div>
Expand Down
Loading

0 comments on commit 6fc7615

Please sign in to comment.