diff --git a/package.json b/package.json index acd1d8ff..74bce6e7 100644 --- a/package.json +++ b/package.json @@ -119,9 +119,9 @@ "@emotion/jest": "^11.11.0", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", - "@testing-library/user-event": "^14.5.0", + "@testing-library/user-event": "^14.5.1", "@types/color": "^3.0.4", - "@types/json-schema": "^7.0.12", + "@types/json-schema": "^7.0.13", "@types/react": "^18.2.21", "@types/react-dom": "^18.2.7", "@umijs/lint": "^4.0.81", @@ -148,7 +148,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "rxjs-spy": "^8.0.2", - "semantic-release": "^21.1.1", + "semantic-release": "^21.1.2", "semantic-release-config-gitmoji": "^1.5.3", "stylelint": "^15.10.3", "typescript": "~5.1.6", diff --git a/src/FieldTitle/demos/description.tsx b/src/FieldTitle/demos/description.tsx index aa42387b..46e25b86 100644 --- a/src/FieldTitle/demos/description.tsx +++ b/src/FieldTitle/demos/description.tsx @@ -7,18 +7,6 @@ const Demo = () => { - - - - - - ); }; diff --git a/src/FieldTitle/index.md b/src/FieldTitle/index.md index aab13d38..53795d63 100644 --- a/src/FieldTitle/index.md +++ b/src/FieldTitle/index.md @@ -21,11 +21,9 @@ group: 基础组件 ## API -| 参数 | 说明 | 类型 | 默认值 | -| :------------ | :----------------------------- | :-------------------------------- | :----- | -| type | 字段类型 | 参考 `FieldIcon` 字段类型类型枚举 | - | -| isParentArray | 父级是否是数组 | boolean | - | -| title | 字段标题 | `React.ReactNode` | - | -| description | 标题右侧描述 | `React.ReactNode` | - | -| extra | 额外内容 | `React.ReactNode` | - | -| checkable | 是否可选,可选会添加 `padding` | `boolean` | true | +| 参数 | 说明 | 类型 | 默认值 | +| :------------ | :------------- | :-------------------------------- | :----- | +| type | 字段类型 | 参考 `FieldIcon` 字段类型类型枚举 | - | +| isParentArray | 父级是否是数组 | boolean | - | +| title | 字段标题 | `React.ReactNode` | - | +| description | 标题右侧描述 | `React.ReactNode` | - | diff --git a/src/FieldTitle/index.tsx b/src/FieldTitle/index.tsx index 402bcaa6..510ad396 100644 --- a/src/FieldTitle/index.tsx +++ b/src/FieldTitle/index.tsx @@ -33,14 +33,6 @@ export interface FieldTitleProps { * 标题右侧描述 */ description?: React.ReactNode; - /** - * 额外内容 - */ - extra?: React.ReactNode; - /** - * 是否可选 - */ - checkable?: boolean; } const FieldTitle: React.FC = (props) => { @@ -52,12 +44,10 @@ const FieldTitle: React.FC = (props) => { isParentArray, title, description = null, - extra = null, - checkable = true, } = props; const prefixCls = getPrefixCls('field-title', customizePrefixCls); - const { styles } = useStyle({ prefixCls, checkable }); + const { styles } = useStyle({ prefixCls }); let finalType = type; if (finalType === 'boolean') { @@ -67,14 +57,11 @@ const FieldTitle: React.FC = (props) => { finalType += 'Array'; } return ( -
-
- {finalType ? : null} - {title ? {title} : null} - {description ? {description} : null} -
- {extra ?
{extra}
: null} -
+ + {finalType ? : null} + {title ? {title} : null} + {description ? {description} : null} + ); }; diff --git a/src/FieldTitle/style.ts b/src/FieldTitle/style.ts index f3d5d005..931cff7c 100644 --- a/src/FieldTitle/style.ts +++ b/src/FieldTitle/style.ts @@ -1,11 +1,11 @@ import { createStyles } from '../theme'; -export const useStyle = createStyles(({ token, css, cx }, { prefixCls, checkable }) => { +export const useStyle = createStyles(({ token, css, cx }, { prefixCls }) => { return { - content: cx( - `${prefixCls}-content`, + container: cx( + `${prefixCls}-container`, css({ - display: 'flex', + display: 'inline-flex', alignItems: 'center', fontSize: token.fontSize, }), @@ -22,11 +22,5 @@ export const useStyle = createStyles(({ token, css, cx }, { prefixCls, checkable marginLeft: token.marginXXS, }), ), - extra: cx( - `${prefixCls}-extra`, - css({ - paddingLeft: checkable ? token.paddingLG : undefined, - }), - ), }; }); diff --git a/tests/__snapshots__/demo.test.tsx.snap b/tests/__snapshots__/demo.test.tsx.snap index b8f6a5cb..109c55a3 100644 --- a/tests/__snapshots__/demo.test.tsx.snap +++ b/tests/__snapshots__/demo.test.tsx.snap @@ -15206,10 +15206,10 @@ exports[` > renders basic.tsx correctly 1`] = ` } .emotion-1 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -15256,57 +15256,53 @@ exports[` > renders basic.tsx correctly 1`] = ` -
- -
+ + +
+ + orderId + + > renders basic.tsx correctly 1`] = ` exports[` > renders basic.tsx correctly 1`] = ` .emotion-0 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -15377,54 +15373,50 @@ exports[` > renders basic.tsx correctly 1`] = `
-
- -
+ + + + + any + +
@@ -15438,90 +15430,86 @@ exports[` > renders basic.tsx correctly 1`] = `
-
- -
+ + + + + anyArray + +
@@ -15535,57 +15523,53 @@ exports[` > renders basic.tsx correctly 1`] = `
-
- -
+ + + + + bool + +
@@ -15599,57 +15583,53 @@ exports[` > renders basic.tsx correctly 1`] = `
-
- -
+ + + + + boolArray + +
@@ -15663,57 +15643,53 @@ exports[` > renders basic.tsx correctly 1`] = `
-
- -
+ + + + + integer + +
@@ -15727,57 +15703,53 @@ exports[` > renders basic.tsx correctly 1`] = `
-
- -
+ + + + + integerArray + +
@@ -15791,57 +15763,53 @@ exports[` > renders basic.tsx correctly 1`] = `
-
- -
+ + + + + number + +
@@ -15855,57 +15823,53 @@ exports[` > renders basic.tsx correctly 1`] = `
-
- -
+ + + + + numberArray + +
@@ -15919,56 +15883,52 @@ exports[` > renders basic.tsx correctly 1`] = `
-
- -
+ + + + + object + +
@@ -15982,56 +15942,52 @@ exports[` > renders basic.tsx correctly 1`] = `
-
- -
+ + + + + objectArray + +
@@ -16045,57 +16001,53 @@ exports[` > renders basic.tsx correctly 1`] = `
-
- -
+ + + + + string + +
@@ -16109,57 +16061,53 @@ exports[` > renders basic.tsx correctly 1`] = `
-
- -
+ + + + + + + stringArray + +
@@ -16173,57 +16121,53 @@ exports[` > renders basic.tsx correctly 1`] = `
-
- -
+ + + + + boolean + +
@@ -16237,19 +16181,15 @@ exports[` > renders basic.tsx correctly 1`] = `
-
-
- - empty - -
-
+ empty + +
@@ -16260,10 +16200,10 @@ exports[` > renders basic.tsx correctly 1`] = ` exports[` > renders description.tsx correctly 1`] = ` .emotion-0 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -16279,10 +16219,6 @@ exports[` > renders description.tsx correctly 1`] = ` margin-left: 4px; } -.emotion-7 { - padding-left: 16px; -} -
> renders description.tsx correctly 1`] = `
-
-
- - - - - success - - - 成功标识 - -
-
-
-
-
-
-
-
-
-
-
- 额外 -
-
- 额外内容在字段下面 -
-
-
-
-
-
- -
- 额外内容 -
-
-
-
-
-
-
-
-
-
-
- 可选 -
-
- 可选为false 则额外内容左侧有 padding -
-
-
-
-
-
-
+ + + - - - - - success - -
-
+ - 额外内容 -
-
+ 成功标识 + +