From 89ddd3d6497fca2f1248125727535c853d12457d Mon Sep 17 00:00:00 2001 From: byq1213 Date: Sun, 18 Aug 2024 19:38:26 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(radio):=20=E9=87=8D=E6=9E=84radio=20do?= =?UTF-8?q?m=E6=8E=A5=E5=8F=A3,=E8=A1=A5=E5=85=85=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E5=92=8C=E9=80=82=E9=85=8D=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #461 --- site/mobile/mobile.config.js | 2 +- src/_common | 2 +- src/radio/Radio.tsx | 126 +- src/radio/RadioGroup.tsx | 13 +- src/radio/_example/{base.jsx => base.tsx} | 8 +- src/radio/_example/card.tsx | 25 + src/radio/_example/custom.tsx | 39 + src/radio/_example/group.jsx | 40 - src/radio/_example/horizontal.tsx | 13 + src/radio/_example/icon.jsx | 15 - src/radio/_example/icon.tsx | 11 + src/radio/_example/{index.jsx => index.tsx} | 38 +- src/radio/_example/leftStrokeLine.jsx | 24 - src/radio/_example/placement.tsx | 11 + src/radio/_example/right.jsx | 19 - src/radio/_example/rightStrokeLine.jsx | 23 - src/radio/_example/size.jsx | 10 - src/radio/_example/status.jsx | 46 - src/radio/_example/status.tsx | 21 + src/radio/_example/style/index.less | 66 +- src/radio/defaultProps.ts | 28 + src/radio/radio.en-US.md | 47 + src/radio/radio.md | 44 +- src/radio/style/index.js | 4 +- src/radio/style/index.less | 9 - src/radio/type.ts | 71 +- test/snap/__snapshots__/csr.test.jsx.snap | 1848 +++++++++++++++++++ test/snap/__snapshots__/ssr.test.jsx.snap | 16 + 28 files changed, 2304 insertions(+), 315 deletions(-) rename src/radio/_example/{base.jsx => base.tsx} (72%) create mode 100644 src/radio/_example/card.tsx create mode 100644 src/radio/_example/custom.tsx delete mode 100644 src/radio/_example/group.jsx create mode 100644 src/radio/_example/horizontal.tsx delete mode 100644 src/radio/_example/icon.jsx create mode 100644 src/radio/_example/icon.tsx rename src/radio/_example/{index.jsx => index.tsx} (59%) delete mode 100644 src/radio/_example/leftStrokeLine.jsx create mode 100644 src/radio/_example/placement.tsx delete mode 100644 src/radio/_example/right.jsx delete mode 100644 src/radio/_example/rightStrokeLine.jsx delete mode 100644 src/radio/_example/size.jsx delete mode 100644 src/radio/_example/status.jsx create mode 100644 src/radio/_example/status.tsx create mode 100644 src/radio/defaultProps.ts create mode 100644 src/radio/radio.en-US.md delete mode 100644 src/radio/style/index.less diff --git a/site/mobile/mobile.config.js b/site/mobile/mobile.config.js index b02c6b3c..e61b732c 100644 --- a/site/mobile/mobile.config.js +++ b/site/mobile/mobile.config.js @@ -58,7 +58,7 @@ export default { { title: 'Radio 单选框', name: 'radio', - component: () => import('tdesign-mobile-react/radio/_example/index.jsx'), + component: () => import('tdesign-mobile-react/radio/_example/index.tsx'), }, { title: 'Rate 评分', diff --git a/src/_common b/src/_common index 762c4d5d..a61e5fef 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 762c4d5d576db1262a4c26d03b133077422749ca +Subproject commit a61e5fef4566350e771377500dafdbcd46a23d3b diff --git a/src/radio/Radio.tsx b/src/radio/Radio.tsx index 905899cc..c222abb1 100644 --- a/src/radio/Radio.tsx +++ b/src/radio/Radio.tsx @@ -1,11 +1,14 @@ -import React, { createContext, CSSProperties, forwardRef, Ref, useContext, useRef } from 'react'; +import React, { createContext, forwardRef, useContext, useRef } from 'react'; +import type { CSSProperties, Ref } from 'react'; import classNames from 'classnames'; -import { CheckIcon } from 'tdesign-icons-react'; +import { CheckIcon, CheckCircleFilledIcon } from 'tdesign-icons-react'; import forwardRefWithStatics from '../_util/forwardRefWithStatics'; import useConfig from '../_util/useConfig'; import useDefault from '../_util/useDefault'; -import { TdRadioProps } from './type'; +import type { TdRadioProps } from './type'; import RadioGroup from './RadioGroup'; +import useDefaultProps from '../hooks/useDefaultProps'; +import { radioDefaultProps } from './defaultProps'; export interface RadioProps extends TdRadioProps { ref?: Ref; @@ -31,23 +34,23 @@ const Radio = forwardRef((_props: RadioProps, ref: Ref) => { const props = context ? context.inject(_props) : _props; const { - align = 'left', - allowUncheck = false, - checked = false, - defaultChecked = false, - children, + allowUncheck, + block, + checked, content, + defaultChecked, contentDisabled, + placement, disabled, icon, label, - maxContentRow = 5, - maxLabelRow = 3, + maxContentRow, + maxLabelRow, name, value, - // borderless = false, + borderless, onChange, - } = props; + } = useDefaultProps(props, radioDefaultProps); const [radioChecked, setRadioChecked] = useDefault(checked, defaultChecked, onChange); @@ -66,21 +69,30 @@ const Radio = forwardRef((_props: RadioProps, ref: Ref) => { const renderIcon = () => { if (Array.isArray(icon)) { - return radioChecked ? icon[0] : icon[1] ?? null; + return radioChecked ? icon[0] : (icon[1] ?? null); + } + if (radioChecked) { + if (icon === 'circle') { + return ; + } + if (icon === 'line') { + return ; + } + if (icon === 'dot') { + let dotIconClassName = `${classPrefix}__icon-${icon}`; + disabled && (dotIconClassName += ` ${classPrefix}__icon-${icon}--disabled`); + return
; + } + } else { + if (icon === 'circle' || icon === 'dot') { + let circleIconClassName = `${classPrefix}__icon-circle`; + disabled && (circleIconClassName += ` ${classPrefix}__icon-circle--disabled`); + return
; + } + if (icon === 'line') { + return
; + } } - return ( -
- -
- ); }; const labelStyle = { @@ -88,18 +100,11 @@ const Radio = forwardRef((_props: RadioProps, ref: Ref) => { color: disabled ? '#dcdcdc' : 'inherit', }; - const radioClassName = classNames( - `${classPrefix}`, - { [`${prefix}-is-checked`]: radioChecked }, - { [`${prefix}-is-disabled`]: disabled }, - - ); + const radioClassName = classNames(`${classPrefix}`, `${classPrefix}--${placement}`, { + [`${classPrefix}--block`]: block, + }); - const titleClassName = classNames( - `${prefix}__content-title`, - { [`${prefix}-is-disabled`]: disabled }, - { [`${prefix}__content-right-title`]: align === 'right' }, - ) + const titleClassName = classNames(`${classPrefix}__title`, { [`${classPrefix}__title--disabled`]: disabled }); const input = ( ) => { // @ts-ignore value={value} disabled={disabled} - className={classNames(`${classPrefix}__original-${align}`)} + className={classNames(`${classPrefix}__original`)} checked={radioChecked} onClick={(e) => { e.stopPropagation(); @@ -122,30 +127,31 @@ const Radio = forwardRef((_props: RadioProps, ref: Ref) => { /> ); + const iconClass = classNames(`${classPrefix}__icon`, `${classPrefix}__icon--${placement}`, { + [`${classPrefix}__icon--checked`]: radioChecked, + [`${classPrefix}__icon--disabled`]: disabled, + }); return (
switchRadioChecked()}> - - {align === 'left' && - {input} - {renderIcon()} - } - - {label && {label}} - {(children || content) && ( -
- {children || content} -
- )} -
- {align === 'right' && - {input} - {renderIcon()} - } -
- {/* 下边框 */} - {
} - {/* { !borderless &&
} */} -
+ {input} +
{renderIcon()}
+
+ {label && ( + + {label} + + )} + {content && ( +
+ {content} +
+ )} +
+ + {!borderless && block &&
}
); }); diff --git a/src/radio/RadioGroup.tsx b/src/radio/RadioGroup.tsx index 25fa61e9..059b3523 100644 --- a/src/radio/RadioGroup.tsx +++ b/src/radio/RadioGroup.tsx @@ -1,8 +1,9 @@ -import React, { FC, ReactNode, useRef } from 'react'; +import React, { useRef } from 'react'; +import type { FC, ReactNode } from 'react'; import useConfig from '../_util/useConfig'; import Radio, { RadioContext, RadioContextValue, RadioProps } from './Radio'; -import { TdRadioGroupProps } from './type'; import useDefault from '../_util/useDefault'; +import type { TdRadioGroupProps } from './type'; export interface RadioGroupProps extends TdRadioGroupProps { children?: ReactNode; @@ -53,12 +54,8 @@ const RadioGroup: FC = (props) => { ); }); return ( -
-
-
- {options?.length ? renderOptions() : children} -
-
+
+ {options?.length ? renderOptions() : children}
); }; diff --git a/src/radio/_example/base.jsx b/src/radio/_example/base.tsx similarity index 72% rename from src/radio/_example/base.jsx rename to src/radio/_example/base.tsx index 8f34b309..29c0b4d5 100644 --- a/src/radio/_example/base.jsx +++ b/src/radio/_example/base.tsx @@ -8,9 +8,11 @@ export default function Base() { - - 单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选 - + ); } diff --git a/src/radio/_example/card.tsx b/src/radio/_example/card.tsx new file mode 100644 index 00000000..4e6b9cf3 --- /dev/null +++ b/src/radio/_example/card.tsx @@ -0,0 +1,25 @@ +import React, { useState } from 'react'; +import { Radio, RadioGroup } from 'tdesign-mobile-react'; + +export default function () { + const [defaultValue, setDefaultValue] = useState('1'); + const options = [ + { + value: '1', + label: '单选', + }, + { + value: '2', + label: '单选', + }, + { + value: '3', + label: '单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行', + }, + ]; + return ( + + {options.map((opt) => )} + + ); +} diff --git a/src/radio/_example/custom.tsx b/src/radio/_example/custom.tsx new file mode 100644 index 00000000..5fef346e --- /dev/null +++ b/src/radio/_example/custom.tsx @@ -0,0 +1,39 @@ +import React, { useState } from 'react'; +import { Radio, RadioGroup } from 'tdesign-mobile-react'; +import { Icon } from 'tdesign-icons-react'; +import TDemoBlock from '../../../site/mobile/components/DemoBlock'; + +export default function () { + const [defaultValue, setDefaultValue] = useState(0); + const [defaultValueH, setDefaultValueH] = useState(0); + return ( + <> + + setDefaultValue(value)}> + {Array.from(Array(3), (_, key) => ( +
+ {defaultValue === key && } + +
+ ))} +
+
+ + setDefaultValueH(value)}> + {Array.from(Array(3), (_, key) => ( +
+ {defaultValueH === key && } + +
+ ))} +
+
+ + ); +} diff --git a/src/radio/_example/group.jsx b/src/radio/_example/group.jsx deleted file mode 100644 index ec4fe54f..00000000 --- a/src/radio/_example/group.jsx +++ /dev/null @@ -1,40 +0,0 @@ -import React, { useState } from 'react'; -import { RadioGroup, Radio } from 'tdesign-mobile-react'; - -export default function () { - const itemOptions = ['北京', '上海', '广州', '深圳']; - const [city, setCity] = useState('北京'); - const [city2, setCity2] = useState(''); - const [city3, setCity3] = useState(''); - return ( - <> - setCity(`${value}`)}> -
- setCity2(`${value}`)}> - 北京 - 上海 - 广州 - 深圳 - -
-
- setCity2(`${value}`)} disabled> - 北京 - 上海 - 广州 - 深圳 - -
-
- setCity3(`${value}`)}> - 北京 - - 上海 - - 广州 - 深圳 - -
- - ); -} diff --git a/src/radio/_example/horizontal.tsx b/src/radio/_example/horizontal.tsx new file mode 100644 index 00000000..cd44e51e --- /dev/null +++ b/src/radio/_example/horizontal.tsx @@ -0,0 +1,13 @@ +import React, { useState } from 'react'; +import { Radio, RadioGroup } from 'tdesign-mobile-react'; + +export default function Base() { + const [defaultValue, setDefaultValue] = useState('idx0'); + return ( + setDefaultValue(value)}> + + + + + ); +} diff --git a/src/radio/_example/icon.jsx b/src/radio/_example/icon.jsx deleted file mode 100644 index f3bfe874..00000000 --- a/src/radio/_example/icon.jsx +++ /dev/null @@ -1,15 +0,0 @@ -import React, { useState } from 'react'; -import { CheckRectangleFilledIcon, RectangleIcon } from 'tdesign-icons-react'; -import { Radio, RadioGroup } from 'tdesign-mobile-react'; - -export default function () { - const [defaultValue, setDefaultValue] = useState('idx2'); - const icons = [, ]; - - return ( - setDefaultValue(value)}> - - - - ); -} diff --git a/src/radio/_example/icon.tsx b/src/radio/_example/icon.tsx new file mode 100644 index 00000000..14689768 --- /dev/null +++ b/src/radio/_example/icon.tsx @@ -0,0 +1,11 @@ +import React from 'react'; +import { Radio } from 'tdesign-mobile-react'; + +export default function () { + return ( + <> + + + + ); +} diff --git a/src/radio/_example/index.jsx b/src/radio/_example/index.tsx similarity index 59% rename from src/radio/_example/index.jsx rename to src/radio/_example/index.tsx index 76a7e55a..f261c30c 100644 --- a/src/radio/_example/index.jsx +++ b/src/radio/_example/index.tsx @@ -2,57 +2,57 @@ import React from 'react'; import TDemoHeader from '../../../site/mobile/components/DemoHeader'; import TDemoBlock from '../../../site/mobile/components/DemoBlock'; import BaseDemo from './base'; -import RightDemo from './right'; -import LeftStrokeLineDemo from './leftStrokeLine'; -import RightStrokeLineDemo from './rightStrokeLine'; +import HorizontalDemo from './horizontal'; import StatusDemo from './status'; import IconDemo from './icon'; -import SizeDemo from './size'; -import './style/index.less' +import PlacementDemo from './placement'; +import CardDemo from './card'; +import CustomDemo from './custom'; +import './style/index.less'; export default function RadioDemo() { return (
- +
- + +
- +
- +
- +
- +
- +
- - +
- +
- +
- +
- +
- +
diff --git a/src/radio/_example/leftStrokeLine.jsx b/src/radio/_example/leftStrokeLine.jsx deleted file mode 100644 index fb612b75..00000000 --- a/src/radio/_example/leftStrokeLine.jsx +++ /dev/null @@ -1,24 +0,0 @@ -import React, { useState } from 'react'; -import { Radio, RadioGroup } from 'tdesign-mobile-react'; -import { CheckIcon } from 'tdesign-icons-react'; - -export default function Base() { - const [defaultValue, setDefaultValue] = useState('idx0'); - const CheckedIcon = ; - return ( - <> - setDefaultValue(value)}> - - - - - 单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选 - - - - ); -} diff --git a/src/radio/_example/placement.tsx b/src/radio/_example/placement.tsx new file mode 100644 index 00000000..cfeb39c8 --- /dev/null +++ b/src/radio/_example/placement.tsx @@ -0,0 +1,11 @@ +import React from 'react'; +import { Radio } from 'tdesign-mobile-react'; + +export default function () { + return ( + <> + + + + ); +} diff --git a/src/radio/_example/right.jsx b/src/radio/_example/right.jsx deleted file mode 100644 index 3baa08f2..00000000 --- a/src/radio/_example/right.jsx +++ /dev/null @@ -1,19 +0,0 @@ -import React, { useState } from 'react'; -import { Radio, RadioGroup } from 'tdesign-mobile-react'; - -export default function () { - const [defaultValue, setDefaultValue] = useState('idx0'); - return ( - - - - - - - ); -} diff --git a/src/radio/_example/rightStrokeLine.jsx b/src/radio/_example/rightStrokeLine.jsx deleted file mode 100644 index 35462a51..00000000 --- a/src/radio/_example/rightStrokeLine.jsx +++ /dev/null @@ -1,23 +0,0 @@ -import React, { useState } from 'react'; -import { Radio, RadioGroup } from 'tdesign-mobile-react'; -import { CheckIcon } from 'tdesign-icons-react'; - -export default function () { - const [defaultValue, setDefaultValue] = useState('idx1'); - const CheckedIcon = ; - - return ( - - - - - 单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选 - - - ); -} diff --git a/src/radio/_example/size.jsx b/src/radio/_example/size.jsx deleted file mode 100644 index 6bc8bc6c..00000000 --- a/src/radio/_example/size.jsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; -import { Radio, RadioGroup } from 'tdesign-mobile-react'; - -export default function () { - return ( - - - - ); -} diff --git a/src/radio/_example/status.jsx b/src/radio/_example/status.jsx deleted file mode 100644 index f117cc5f..00000000 --- a/src/radio/_example/status.jsx +++ /dev/null @@ -1,46 +0,0 @@ -import React from 'react'; -import { CheckIcon } from 'tdesign-icons-react'; -import { Radio, RadioGroup } from 'tdesign-mobile-react'; -import TDemoBlock from '../../../site/mobile/components/DemoBlock'; - -export default function () { - const defaultValue = 'idx2'; - const icon = ; - - return ( - <> -
- - - - - - -
-
- - - - - - -
-
- - - - - - -
-
- - - - - - -
- - ); -} diff --git a/src/radio/_example/status.tsx b/src/radio/_example/status.tsx new file mode 100644 index 00000000..69ea5cb1 --- /dev/null +++ b/src/radio/_example/status.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import { Radio, RadioGroup } from 'tdesign-mobile-react'; + +export default function () { + const defaultValue = '1'; + const options = [ + { + value: '1', + label: '选项禁用-已选', + }, + { + value: '2', + label: '选项禁用-默认', + }, + ]; + return ( + + {options.map((opt) => )} + + ); +} diff --git a/src/radio/_example/style/index.less b/src/radio/_example/style/index.less index be559a92..1fd3797d 100644 --- a/src/radio/_example/style/index.less +++ b/src/radio/_example/style/index.less @@ -1,4 +1,66 @@ -.radio-demo { - background-color: #fff; +.box { + padding: 16px; + display: flex; + justify-content: space-between; + background-color: var(--bg-color-demo, #fff); } + +.theme-card { + border-radius: 12px; + margin: 16px; + overflow: hidden; +} +.card { + display: block; + position: relative; + margin: 16px; + border-radius: 6px; + overflow: hidden; + box-sizing: border-box; + border: 1.5px solid #fff; +} + +.card--active { + border-color: #0052d9; + z-index: 0; +} + +.card--active::after { + content: ''; + display: block; + position: absolute; + left: 0; + top: 0; + width: 0; + border: 14px solid #0052d9; + border-bottom-color: transparent; + border-right-color: transparent; + z-index: inherit !important; +} + +.card__icon { + display: block; + color: #fff; + position: absolute; + left: 1.5px; + top: 1.5px; + z-index: 1; +} + +/* 横向布局 */ +.horizontal-box { + width: calc(100% - 32px); + display: flex; + align-items: center; + margin: 16px; +} + +.horizontal-box .card { + flex: 1; + margin: 0; +} + +.horizontal-box .card + .card { + margin-left: 12px; +} \ No newline at end of file diff --git a/src/radio/defaultProps.ts b/src/radio/defaultProps.ts new file mode 100644 index 00000000..781f4fa0 --- /dev/null +++ b/src/radio/defaultProps.ts @@ -0,0 +1,28 @@ +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { TdRadioProps, TdRadioGroupProps } from './type'; + +export const radioDefaultProps: TdRadioProps = { + align: 'left', + allowUncheck: false, + block: true, + borderless: undefined, + defaultChecked: false, + contentDisabled: false, + disabled: undefined, + icon: 'circle', + maxContentRow: 5, + maxLabelRow: 3, + placement: 'left', + value: undefined, +}; + +export const radioGroupDefaultProps: TdRadioGroupProps = { + allowUncheck: false, + borderless: false, + disabled: undefined, + icon: 'circle', + placement: 'left', +}; diff --git a/src/radio/radio.en-US.md b/src/radio/radio.en-US.md new file mode 100644 index 00000000..92810c64 --- /dev/null +++ b/src/radio/radio.en-US.md @@ -0,0 +1,47 @@ +:: BASE_DOC :: + +## API + +### Radio Props + +name | type | default | description | required +-- | -- | -- | -- | -- +className | String | - | className of component | N +style | Object | - | CSS(Cascading Style Sheets),Typescript:`React.CSSProperties` | N +align | String | left | options: left/right | N +allowUncheck | Boolean | false | \- | N +block | Boolean | true | \- | N +borderless | Boolean | undefined | \- | N +checked | Boolean | false | \- | N +defaultChecked | Boolean | false | uncontrolled property | N +children | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +content | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +contentDisabled | Boolean | false | \- | N +disabled | Boolean | undefined | \- | N +icon | String / Array | 'circle' | Typescript:`'circle' \| 'line' \| 'dot' \| 'none' \|Array`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +label | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +maxContentRow | Number | 5 | \- | N +maxLabelRow | Number | 3 | \- | N +name | String | - | \- | N +placement | String | left | options: left/right | N +value | String / Number / Boolean | undefined | Typescript:`string \| number \| boolean` | N +onChange | Function | | Typescript:`(checked: boolean, context: { e: ChangeEvent }) => void`
| N + + +### RadioGroup Props + +name | type | default | description | required +-- | -- | -- | -- | -- +className | String | - | className of component | N +style | Object | - | CSS(Cascading Style Sheets),Typescript:`React.CSSProperties` | N +allowUncheck | Boolean | false | \- | N +borderless | Boolean | false | \- | N +disabled | Boolean | undefined | \- | N +icon | String / Array | 'circle' | Typescript:`'circle' \| 'line' \| 'dot' \| Array`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +keys | Object | - | Typescript:`KeysType`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +name | String | - | \- | N +options | Array | - | Typescript:`Array` `type RadioOption = string \| number \| RadioOptionObj` `interface RadioOptionObj { label?: string \| TNode; value?: string \| number \| boolean; disabled?: boolean }`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/radio/type.ts) | N +placement | String | left | options: left/right | N +value | String / Number / Boolean | - | Typescript:`T` `type RadioValue = string \| number \| boolean`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/radio/type.ts) | N +defaultValue | String / Number / Boolean | - | uncontrolled property。Typescript:`T` `type RadioValue = string \| number \| boolean`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/radio/type.ts) | N +onChange | Function | | Typescript:`(value: T, context: { e: ChangeEvent }) => void`
| N diff --git a/src/radio/radio.md b/src/radio/radio.md index 9a806bd6..6bbe974c 100644 --- a/src/radio/radio.md +++ b/src/radio/radio.md @@ -1,37 +1,47 @@ :: BASE_DOC :: ## API + ### Radio Props -名称 | 类型 | 默认值 | 说明 | 必传 +名称 | 类型 | 默认值 | 描述 | 必传 -- | -- | -- | -- | -- className | String | - | 类名 | N style | Object | - | 样式,TS 类型:`React.CSSProperties` | N -align | String | left | 复选框和内容相对位置。可选项:left/right | N +align | String | left | 已废弃。复选框和内容相对位置。可选项:left/right | N allowUncheck | Boolean | false | 是否允许取消选中 | N -checked | Boolean | - | 是否选中 | N -defaultChecked | Boolean | - | 是否选中。非受控属性 | N -children | TNode | - | 单选内容,同 label。TS 类型:`string | TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N -content | TNode | - | 单选内容。TS 类型:`string | TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N -contentDisabled | Boolean | - | 是否禁用组件内容(content)触发选中 | N -disabled | Boolean | undefined | 是否为禁用态 | N -icon | Array | - | 自定义选中图标和非选中图标。示例:[选中态图标,非选中态图标]。TS 类型:`Array`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N -label | TNode | - | 主文案。TS 类型:`string | TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +block | Boolean | true | 是否为块级元素 | N +borderless | Boolean | undefined | 是否开启无边框模式 | N +checked | Boolean | false | 是否选中 | N +defaultChecked | Boolean | false | 是否选中。非受控属性 | N +children | TNode | - | 单选内容,同 label。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +content | TNode | - | 单选内容。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +contentDisabled | Boolean | false | 是否禁用组件内容(content)触发选中 | N +disabled | Boolean | undefined | 是否为禁用态。如果存在父组件 RadioGroup,默认值由 RadioGroup.disabled 控制。优先级:Radio.disabled > RadioGroup.disabled > Form.disabled | N +icon | String / Array | 'circle' | 自定义选中图标和非选中图标。示例:[选中态图标地址,非选中态图标地址]。使用 String 时,值为 circle 表示填充型图标、值为 line 表示描边型图标、值为 dot 表示圆点图标、值为 'none' 则表示没有图标。TS 类型:`'circle' \| 'line' \| 'dot' \| 'none' \|Array`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +label | TNode | - | 主文案。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N maxContentRow | Number | 5 | 内容最大行数限制 | N maxLabelRow | Number | 3 | 主文案最大行数限制 | N name | String | - | HTML 元素原生属性 | N -value | String / Number / Boolean | undefined | 单选按钮的值。TS 类型:`RadioValue` `type RadioValue = string | number | boolean`。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/radio/type.ts) | N +placement | String | left | 复选框和内容相对位置。可选项:left/right | N +value | String / Number / Boolean | undefined | 单选按钮的值。TS 类型:`string \| number \| boolean` | N onChange | Function | | TS 类型:`(checked: boolean, context: { e: ChangeEvent }) => void`
选中状态变化时触发 | N + ### RadioGroup Props -名称 | 类型 | 默认值 | 说明 | 必传 +名称 | 类型 | 默认值 | 描述 | 必传 -- | -- | -- | -- | -- className | String | - | 类名 | N style | Object | - | 样式,TS 类型:`React.CSSProperties` | N -disabled | Boolean | undefined | 是否禁用全部子单选框 | N +allowUncheck | Boolean | false | 是否允许取消选中 | N +borderless | Boolean | false | 是否开启无边框模式;优先级低于 Radio | N +disabled | Boolean | undefined | 是否禁用全部子单选框。优先级:Radio.disabled > RadioGroup.disabled > Form.disabled | N +icon | String / Array | 'circle' | 自定义选中图标和非选中图标。示例:[选中态图标地址,非选中态图标地址]。使用 String 时,值为 circle 表示填充型图标、值为 line 表示描边型图标、值为 dot 表示圆点图标。TS 类型:`'circle' \| 'line' \| 'dot' \| Array`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +keys | Object | - | 用来定义 value / label 在 `options` 中对应的字段别名。TS 类型:`KeysType`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N name | String | - | HTML 元素原生属性 | N -options | Array | - | 单选组件按钮形式。RadioOption 数据类型为 string 或 number 时,表示 label 和 value 值相同。TS 类型:`Array` `type RadioOption = string | number | RadioOptionObj` `interface RadioOptionObj { label?: string | TNode; value?: string | number; disabled?: boolean }`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts)。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/radio/type.ts) | N -value | String / Number / Boolean | undefined | 选中的值。TS 类型:`RadioValue` | N -defaultValue | String / Number / Boolean | undefined | 选中的值。非受控属性。TS 类型:`RadioValue` | N -onChange | Function | | TS 类型:`(value: RadioValue, context: { e: ChangeEvent }) => void`
选中值发生变化时触发 | N +options | Array | - | 单选组件按钮形式。RadioOption 数据类型为 string 或 number 时,表示 label 和 value 值相同。TS 类型:`Array` `type RadioOption = string \| number \| RadioOptionObj` `interface RadioOptionObj { label?: string \| TNode; value?: string \| number \| boolean; disabled?: boolean }`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts)。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/radio/type.ts) | N +placement | String | left | 复选框和内容相对位置。可选项:left/right | N +value | String / Number / Boolean | - | 选中的值。TS 类型:`T` `type RadioValue = string \| number \| boolean`。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/radio/type.ts) | N +defaultValue | String / Number / Boolean | - | 选中的值。非受控属性。TS 类型:`T` `type RadioValue = string \| number \| boolean`。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/radio/type.ts) | N +onChange | Function | | TS 类型:`(value: T, context: { e: ChangeEvent }) => void`
选中值发生变化时触发 | N diff --git a/src/radio/style/index.js b/src/radio/style/index.js index f23ec6ac..1b755a93 100644 --- a/src/radio/style/index.js +++ b/src/radio/style/index.js @@ -1,4 +1,2 @@ -import '../../_common/style/mobile/components/radio/_index.less'; +import '../../_common/style/mobile/components/radio/v2/_index.less'; import '../../_common/style/mobile/components/radio-group/_index.less'; - -import './index.less'; diff --git a/src/radio/style/index.less b/src/radio/style/index.less deleted file mode 100644 index 916806e4..00000000 --- a/src/radio/style/index.less +++ /dev/null @@ -1,9 +0,0 @@ -.t-radio__wrap { - align-self: flex-start; -} - -.t-radio.t-is-checked { - .t-radio__checked__disable-icon { - color: #dcdcdc; - } -} diff --git a/src/radio/type.ts b/src/radio/type.ts index aa000cb9..cfc5954d 100644 --- a/src/radio/type.ts +++ b/src/radio/type.ts @@ -4,12 +4,12 @@ * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC * */ -import { TNode } from '../common'; +import { TNode, KeysType } from '../common'; import { ChangeEvent } from 'react'; export interface TdRadioProps { /** - * 复选框和内容相对位置 + * 已废弃。复选框和内容相对位置 * @default left */ align?: 'left' | 'right'; @@ -18,12 +18,23 @@ export interface TdRadioProps { * @default false */ allowUncheck?: boolean; + /** + * 是否为块级元素 + * @default true + */ + block?: boolean; + /** + * 是否开启无边框模式 + */ + borderless?: boolean; /** * 是否选中 + * @default false */ checked?: boolean; /** * 是否选中,非受控属性 + * @default false */ defaultChecked?: boolean; /** @@ -36,17 +47,18 @@ export interface TdRadioProps { content?: TNode; /** * 是否禁用组件内容(content)触发选中 + * @default false */ contentDisabled?: boolean; /** - * 是否为禁用态 + * 是否为禁用态。如果存在父组件 RadioGroup,默认值由 RadioGroup.disabled 控制。优先级:Radio.disabled > RadioGroup.disabled > Form.disabled */ disabled?: boolean; /** - * 自定义选中图标和非选中图标。示例:[选中态图标地址,非选中态图标地址]。值为 fill-circle 表示图标为填充型图标,值为 stroke-line 表示图标为描边型图标 - * @default 'fill-circle' + * 自定义选中图标和非选中图标。示例:[选中态图标地址,非选中态图标地址]。使用 String 时,值为 circle 表示填充型图标、值为 line 表示描边型图标、值为 dot 表示圆点图标、值为 'none' 则表示没有图标 + * @default 'circle' */ - icon?: Array; + icon?: 'circle' | 'line' | 'dot' | 'none' | Array; /** * 主文案 */ @@ -66,21 +78,45 @@ export interface TdRadioProps { * @default '' */ name?: string; + /** + * 复选框和内容相对位置 + * @default left + */ + placement?: 'left' | 'right'; /** * 单选按钮的值 */ - value?: RadioValue; + value?: string | number | boolean; /** * 选中状态变化时触发 */ onChange?: (checked: boolean, context: { e: ChangeEvent }) => void; } -export interface TdRadioGroupProps { +export interface TdRadioGroupProps { + /** + * 是否允许取消选中 + * @default false + */ + allowUncheck?: boolean; + /** + * 是否开启无边框模式;优先级低于 Radio + * @default false + */ + borderless?: boolean; /** - * 是否禁用全部子单选框 + * 是否禁用全部子单选框。优先级:Radio.disabled > RadioGroup.disabled > Form.disabled */ disabled?: boolean; + /** + * 自定义选中图标和非选中图标。示例:[选中态图标地址,非选中态图标地址]。使用 String 时,值为 circle 表示填充型图标、值为 line 表示描边型图标、值为 dot 表示圆点图标 + * @default 'circle' + */ + icon?: 'circle' | 'line' | 'dot' | Array; + /** + * 用来定义 value / label 在 `options` 中对应的字段别名 + */ + keys?: KeysType; /** * HTML 元素原生属性 * @default '' @@ -90,26 +126,31 @@ export interface TdRadioGroupProps { * 单选组件按钮形式。RadioOption 数据类型为 string 或 number 时,表示 label 和 value 值相同 */ options?: Array; + /** + * 复选框和内容相对位置 + * @default left + */ + placement?: 'left' | 'right'; /** * 选中的值 */ - value?: RadioValue; + value?: T; /** * 选中的值,非受控属性 */ - defaultValue?: RadioValue; + defaultValue?: T; /** * 选中值发生变化时触发 */ - onChange?: (value: RadioValue, context: { e: ChangeEvent }) => void; + onChange?: (value: T, context: { e: ChangeEvent }) => void; } -export type RadioValue = string | number | boolean; - export type RadioOption = string | number | RadioOptionObj; export interface RadioOptionObj { label?: string | TNode; - value?: string | number; + value?: string | number | boolean; disabled?: boolean; } + +export type RadioValue = string | number | boolean; diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index 0a91d394..06cc7642 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -6122,6 +6122,1838 @@ exports[`csr snapshot test > csr test src/progress/_example/transition.tsx 1`] =
`; +exports[`csr snapshot test > csr test src/radio/_example/base.tsx 1`] = ` +
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/card.tsx 1`] = ` +
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行 + +
+
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` +
+
+
+

+ 单选框尺寸规格 +

+
+
+
+
+ + + +
+ +
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+ +
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+ +
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+
+
+
+

+ 横向卡片单选框 +

+
+
+
+
+ + + +
+ +
+
+ + 单选 + +
+
+
+
+
+ +
+
+ + 单选 + +
+
+
+
+
+ +
+
+ + 单选 + +
+
+
+
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/horizontal.tsx 1`] = ` +
+
+
+ +
+ + + +
+
+ + 单选标题 + +
+
+
+ +
+
+
+
+ + 单选标题 + +
+
+
+ +
+
+
+
+ + 单选标题 + +
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/icon.tsx 1`] = ` +
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` +
+
+
+

+ Radio 单选框 +

+

+ 用于在预设的一组选项中执行单项选择,并呈现选择结果。 +

+
+
+
+

+ 01 组件类型 +

+

+ 纵向单选框 +

+
+
+
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+
+
+
+
+

+ 横向单选框 +

+
+
+
+
+
+ +
+ + + +
+
+ + 单选标题 + +
+
+
+ +
+
+
+
+ + 单选标题 + +
+
+
+ +
+
+
+
+ + 单选标题 + +
+
+
+
+
+
+
+
+

+ 02 组件状态 +

+

+ 单选框禁用状态 +

+
+
+
+
+
+ +
+ + + +
+
+ + 选项禁用-已选 + +
+
+
+
+ +
+
+
+
+ + 选项禁用-默认 + +
+
+
+
+
+
+
+
+
+

+ 03 组件样式 +

+

+ 勾选样式 +

+
+
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+
+
+
+
+
+
+
+

+ 勾选显示位置 +

+
+
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+
+
+
+
+

+ 非通栏单选样式 +

+
+
+
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行 + +
+
+
+
+
+
+
+
+
+

+ 04 特殊样式 +

+
+
+
+
+
+

+ 单选框尺寸规格 +

+
+
+
+
+ + + +
+ +
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+ +
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+ +
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+
+
+
+

+ 横向卡片单选框 +

+
+
+
+
+ + + +
+ +
+
+ + 单选 + +
+
+
+
+
+ +
+
+ + 单选 + +
+
+
+
+
+ +
+
+ + 单选 + +
+
+
+
+
+
+
+
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/placement.tsx 1`] = ` +
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/status.tsx 1`] = ` +
+
+
+ +
+ + + +
+
+ + 选项禁用-已选 + +
+
+
+
+ +
+
+
+
+ + 选项禁用-默认 + +
+
+
+
+
+`; + exports[`csr snapshot test > csr test src/result/_example/custom.tsx 1`] = `
ssr test src/progress/_example/plump.tsx 1`] = `" ssr test src/progress/_example/transition.tsx 1`] = `"
88%
"`; +exports[`ssr snapshot test > ssr test src/radio/_example/base.tsx 1`] = `"
单选
单选
单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选
单选
描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/card.tsx 1`] = `"
单选
单选
单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/custom.tsx 1`] = `"

单选框尺寸规格

单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息

横向卡片单选框

单选
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/horizontal.tsx 1`] = `"
单选标题
单选标题
单选标题
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/icon.tsx 1`] = `"
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/index.tsx 1`] = `"

Radio 单选框

用于在预设的一组选项中执行单项选择,并呈现选择结果。

01 组件类型

纵向单选框

单选
单选
单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选
单选
描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息

横向单选框

单选标题
单选标题
单选标题

02 组件状态

单选框禁用状态

选项禁用-已选
选项禁用-默认

03 组件样式

勾选样式

单选
单选

勾选显示位置

单选
单选

非通栏单选样式

单选
单选
单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行

04 特殊样式

单选框尺寸规格

单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息

横向卡片单选框

单选
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/placement.tsx 1`] = `"
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/status.tsx 1`] = `"
选项禁用-已选
选项禁用-默认
"`; + exports[`ssr snapshot test > ssr test src/result/_example/custom.tsx 1`] = `"
自定义结果
描述文字
"`; exports[`ssr snapshot test > ssr test src/result/_example/index.tsx 1`] = `"

Result 结果

结果反馈

01类型

不同结果反馈

成功状态
描述文字
失败状态
描述文字
警示状态
描述文字
默认状态
描述文字

自定义结果

自定义结果
描述文字

页面位置展示

"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index 10456527..352ddde1 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -72,6 +72,22 @@ exports[`ssr snapshot test > ssr test src/progress/_example/plump.tsx 1`] = `" ssr test src/progress/_example/transition.tsx 1`] = `"
88%
"`; +exports[`ssr snapshot test > ssr test src/radio/_example/base.tsx 1`] = `"
单选
单选
单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选
单选
描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/card.tsx 1`] = `"
单选
单选
单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/custom.tsx 1`] = `"

单选框尺寸规格

单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息

横向卡片单选框

单选
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/horizontal.tsx 1`] = `"
单选标题
单选标题
单选标题
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/icon.tsx 1`] = `"
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/index.tsx 1`] = `"

Radio 单选框

用于在预设的一组选项中执行单项选择,并呈现选择结果。

01 组件类型

纵向单选框

单选
单选
单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选
单选
描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息

横向单选框

单选标题
单选标题
单选标题

02 组件状态

单选框禁用状态

选项禁用-已选
选项禁用-默认

03 组件样式

勾选样式

单选
单选

勾选显示位置

单选
单选

非通栏单选样式

单选
单选
单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行

04 特殊样式

单选框尺寸规格

单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息

横向卡片单选框

单选
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/placement.tsx 1`] = `"
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/status.tsx 1`] = `"
选项禁用-已选
选项禁用-默认
"`; + exports[`ssr snapshot test > ssr test src/result/_example/custom.tsx 1`] = `"
自定义结果
描述文字
"`; exports[`ssr snapshot test > ssr test src/result/_example/index.tsx 1`] = `"

Result 结果

结果反馈

01类型

不同结果反馈

成功状态
描述文字
失败状态
描述文字
警示状态
描述文字
默认状态
描述文字

自定义结果

自定义结果
描述文字

页面位置展示

"`; From 19a4f5fafad642fbe73e0039d29da79f904efb2a Mon Sep 17 00:00:00 2001 From: byq1213 Date: Sun, 22 Sep 2024 10:32:57 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix(radio):=20readonly=20&=20allowUncheck?= =?UTF-8?q?=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #461 --- src/radio/Radio.tsx | 54 +++---- src/radio/RadioGroup.tsx | 11 +- src/radio/defaultProps.ts | 1 + src/radio/radio.en-US.md | 5 +- src/radio/radio.md | 5 +- src/radio/style/index.js | 1 - src/radio/type.ts | 13 +- test/snap/__snapshots__/csr.test.jsx.snap | 180 ++++++++++------------ test/snap/__snapshots__/ssr.test.jsx.snap | 24 ++- 9 files changed, 150 insertions(+), 144 deletions(-) diff --git a/src/radio/Radio.tsx b/src/radio/Radio.tsx index c222abb1..fb379498 100644 --- a/src/radio/Radio.tsx +++ b/src/radio/Radio.tsx @@ -2,8 +2,8 @@ import React, { createContext, forwardRef, useContext, useRef } from 'react'; import type { CSSProperties, Ref } from 'react'; import classNames from 'classnames'; import { CheckIcon, CheckCircleFilledIcon } from 'tdesign-icons-react'; +import { usePrefixClass } from 'tdesign-mobile-react/hooks/useClass'; import forwardRefWithStatics from '../_util/forwardRefWithStatics'; -import useConfig from '../_util/useConfig'; import useDefault from '../_util/useDefault'; import type { TdRadioProps } from './type'; import RadioGroup from './RadioGroup'; @@ -27,8 +27,7 @@ const getLimitRow = (row: number): CSSProperties => ({ }); const Radio = forwardRef((_props: RadioProps, ref: Ref) => { - const { classPrefix: prefix } = useConfig(); - const classPrefix = `${prefix}-radio`; + const radioClass = usePrefixClass('radio'); const inputRef = useRef(); const context = useContext(RadioContext); const props = context ? context.inject(_props) : _props; @@ -50,12 +49,14 @@ const Radio = forwardRef((_props: RadioProps, ref: Ref) => { value, borderless, onChange, + readonly, + children, } = useDefaultProps(props, radioDefaultProps); const [radioChecked, setRadioChecked] = useDefault(checked, defaultChecked, onChange); const switchRadioChecked = (area?: string) => { - if (disabled) { + if (disabled || readonly) { return; } if (area === 'content' && contentDisabled) { @@ -73,20 +74,20 @@ const Radio = forwardRef((_props: RadioProps, ref: Ref) => { } if (radioChecked) { if (icon === 'circle') { - return ; + return ; } if (icon === 'line') { - return ; + return ; } if (icon === 'dot') { - let dotIconClassName = `${classPrefix}__icon-${icon}`; - disabled && (dotIconClassName += ` ${classPrefix}__icon-${icon}--disabled`); + let dotIconClassName = `${radioClass}__icon-${icon}`; + disabled && (dotIconClassName += ` ${radioClass}__icon-${icon}--disabled`); return
; } } else { if (icon === 'circle' || icon === 'dot') { - let circleIconClassName = `${classPrefix}__icon-circle`; - disabled && (circleIconClassName += ` ${classPrefix}__icon-circle--disabled`); + let circleIconClassName = `${radioClass}__icon-circle`; + disabled && (circleIconClassName += ` ${radioClass}__icon-circle--disabled`); return
; } if (icon === 'line') { @@ -95,27 +96,22 @@ const Radio = forwardRef((_props: RadioProps, ref: Ref) => { } }; - const labelStyle = { - ...getLimitRow(maxLabelRow), - color: disabled ? '#dcdcdc' : 'inherit', - }; - - const radioClassName = classNames(`${classPrefix}`, `${classPrefix}--${placement}`, { - [`${classPrefix}--block`]: block, + const radioClassName = classNames(`${radioClass}`, `${radioClass}--${placement}`, { + [`${radioClass}--block`]: block, }); - const titleClassName = classNames(`${classPrefix}__title`, { [`${classPrefix}__title--disabled`]: disabled }); + const titleClassName = classNames(`${radioClass}__title`, { [`${radioClass}__title--disabled`]: disabled }); const input = ( { e.stopPropagation(); @@ -127,23 +123,23 @@ const Radio = forwardRef((_props: RadioProps, ref: Ref) => { /> ); - const iconClass = classNames(`${classPrefix}__icon`, `${classPrefix}__icon--${placement}`, { - [`${classPrefix}__icon--checked`]: radioChecked, - [`${classPrefix}__icon--disabled`]: disabled, + const iconClass = classNames(`${radioClass}__icon`, `${radioClass}__icon--${placement}`, { + [`${radioClass}__icon--checked`]: radioChecked, + [`${radioClass}__icon--disabled`]: disabled, }); return (
switchRadioChecked()}> {input}
{renderIcon()}
-
- {label && ( - - {label} +
+ {(label || children) && ( + + {label || children} )} {content && (
{content} @@ -151,7 +147,7 @@ const Radio = forwardRef((_props: RadioProps, ref: Ref) => { )}
- {!borderless && block &&
} + {!borderless && block &&
}
); }); diff --git a/src/radio/RadioGroup.tsx b/src/radio/RadioGroup.tsx index 059b3523..d03a7ee3 100644 --- a/src/radio/RadioGroup.tsx +++ b/src/radio/RadioGroup.tsx @@ -7,11 +7,12 @@ import type { TdRadioGroupProps } from './type'; export interface RadioGroupProps extends TdRadioGroupProps { children?: ReactNode; + className: string; } const RadioGroup: FC = (props) => { const { classPrefix } = useConfig(); - const { disabled, options, value, defaultValue, children, onChange } = props; + const { disabled, options, value, defaultValue, children, onChange, allowUncheck, borderless, className } = props; const groupRef = useRef(null); const [internalValue, setInternalValue] = useDefault(value, defaultValue, onChange); @@ -27,6 +28,8 @@ const RadioGroup: FC = (props) => { typeof radioProps.value !== 'undefined' && internalValue === radioProps.value, disabled: radioProps.disabled || disabled, + allowUncheck: radioProps.allowUncheck || allowUncheck, + borderless: radioProps.borderless || borderless, onChange: (checked, { e }) => { if (typeof radioProps.onChange === 'function') { radioProps.onChange(checked, { e }); @@ -39,7 +42,7 @@ const RadioGroup: FC = (props) => { }; const renderOptions = () => - options.map((option) => { + options.map((option, index) => { if (typeof option === 'number' || typeof option === 'string') { return ( @@ -48,13 +51,13 @@ const RadioGroup: FC = (props) => { ); } return ( - + {option.label} ); }); return ( -
+
{options?.length ? renderOptions() : children}
); diff --git a/src/radio/defaultProps.ts b/src/radio/defaultProps.ts index 781f4fa0..8beff2f0 100644 --- a/src/radio/defaultProps.ts +++ b/src/radio/defaultProps.ts @@ -16,6 +16,7 @@ export const radioDefaultProps: TdRadioProps = { maxContentRow: 5, maxLabelRow: 3, placement: 'left', + readonly: false, value: undefined, }; diff --git a/src/radio/radio.en-US.md b/src/radio/radio.en-US.md index 92810c64..c2911e20 100644 --- a/src/radio/radio.en-US.md +++ b/src/radio/radio.en-US.md @@ -24,7 +24,8 @@ maxContentRow | Number | 5 | \- | N maxLabelRow | Number | 3 | \- | N name | String | - | \- | N placement | String | left | options: left/right | N -value | String / Number / Boolean | undefined | Typescript:`string \| number \| boolean` | N +readonly | Boolean | false | \- | N +value | String / Number / Boolean | undefined | Typescript:`T` | N onChange | Function | | Typescript:`(checked: boolean, context: { e: ChangeEvent }) => void`
| N @@ -44,4 +45,4 @@ options | Array | - | Typescript:`Array` `type RadioOption = stri placement | String | left | options: left/right | N value | String / Number / Boolean | - | Typescript:`T` `type RadioValue = string \| number \| boolean`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/radio/type.ts) | N defaultValue | String / Number / Boolean | - | uncontrolled property。Typescript:`T` `type RadioValue = string \| number \| boolean`。[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/radio/type.ts) | N -onChange | Function | | Typescript:`(value: T, context: { e: ChangeEvent }) => void`
| N +onChange | Function | | Typescript:`(value: T, context: { e: ChangeEvent; name?: string }) => void`
| N diff --git a/src/radio/radio.md b/src/radio/radio.md index 6bbe974c..832c1a20 100644 --- a/src/radio/radio.md +++ b/src/radio/radio.md @@ -24,7 +24,8 @@ maxContentRow | Number | 5 | 内容最大行数限制 | N maxLabelRow | Number | 3 | 主文案最大行数限制 | N name | String | - | HTML 元素原生属性 | N placement | String | left | 复选框和内容相对位置。可选项:left/right | N -value | String / Number / Boolean | undefined | 单选按钮的值。TS 类型:`string \| number \| boolean` | N +readonly | Boolean | false | 只读状态 | N +value | String / Number / Boolean | undefined | 单选按钮的值。TS 类型:`T` | N onChange | Function | | TS 类型:`(checked: boolean, context: { e: ChangeEvent }) => void`
选中状态变化时触发 | N @@ -44,4 +45,4 @@ options | Array | - | 单选组件按钮形式。RadioOption 数据类型为 str placement | String | left | 复选框和内容相对位置。可选项:left/right | N value | String / Number / Boolean | - | 选中的值。TS 类型:`T` `type RadioValue = string \| number \| boolean`。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/radio/type.ts) | N defaultValue | String / Number / Boolean | - | 选中的值。非受控属性。TS 类型:`T` `type RadioValue = string \| number \| boolean`。[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/radio/type.ts) | N -onChange | Function | | TS 类型:`(value: T, context: { e: ChangeEvent }) => void`
选中值发生变化时触发 | N +onChange | Function | | TS 类型:`(value: T, context: { e: ChangeEvent; name?: string }) => void`
选中值发生变化时触发, `context.name` 指 RadioGroup 的 name 属性 | N diff --git a/src/radio/style/index.js b/src/radio/style/index.js index 1b755a93..dab3f1cc 100644 --- a/src/radio/style/index.js +++ b/src/radio/style/index.js @@ -1,2 +1 @@ import '../../_common/style/mobile/components/radio/v2/_index.less'; -import '../../_common/style/mobile/components/radio-group/_index.less'; diff --git a/src/radio/type.ts b/src/radio/type.ts index cfc5954d..0972209c 100644 --- a/src/radio/type.ts +++ b/src/radio/type.ts @@ -7,7 +7,7 @@ import { TNode, KeysType } from '../common'; import { ChangeEvent } from 'react'; -export interface TdRadioProps { +export interface TdRadioProps { /** * 已废弃。复选框和内容相对位置 * @default left @@ -83,10 +83,15 @@ export interface TdRadioProps { * @default left */ placement?: 'left' | 'right'; + /** + * 只读状态 + * @default false + */ + readonly?: boolean; /** * 单选按钮的值 */ - value?: string | number | boolean; + value?: T; /** * 选中状态变化时触发 */ @@ -140,9 +145,9 @@ export interface TdRadioGroupProps { */ defaultValue?: T; /** - * 选中值发生变化时触发 + * 选中值发生变化时触发, `context.name` 指 RadioGroup 的 name 属性 */ - onChange?: (value: T, context: { e: ChangeEvent }) => void; + onChange?: (value: T, context: { e: ChangeEvent; name?: string }) => void; } export type RadioOption = string | number | RadioOptionObj; diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index a33fd5ff..b3647135 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -2987,8 +2987,10 @@ exports[`csr snapshot test > csr test src/cell/_example/base.tsx 1`] = ` width="1em" >
@@ -3270,8 +3272,10 @@ exports[`csr snapshot test > csr test src/cell/_example/base.tsx 1`] = ` width="1em" >
@@ -3462,8 +3466,10 @@ exports[`csr snapshot test > csr test src/cell/_example/base.tsx 1`] = ` width="1em" >
@@ -3623,8 +3629,10 @@ exports[`csr snapshot test > csr test src/cell/_example/group.tsx 1`] = ` width="1em" >
@@ -3986,8 +3994,10 @@ exports[`csr snapshot test > csr test src/cell/_example/multiple.tsx 1`] = ` width="1em" >
@@ -4344,8 +4354,10 @@ exports[`csr snapshot test > csr test src/cell/_example/single.tsx 1`] = ` width="1em" >
@@ -31972,7 +31984,6 @@ exports[`csr snapshot test > csr test src/radio/_example/base.tsx 1`] = ` @@ -31997,7 +32008,7 @@ exports[`csr snapshot test > csr test src/radio/_example/base.tsx 1`] = ` > 单选 @@ -32011,7 +32022,6 @@ exports[`csr snapshot test > csr test src/radio/_example/base.tsx 1`] = ` > @@ -32027,7 +32037,7 @@ exports[`csr snapshot test > csr test src/radio/_example/base.tsx 1`] = ` > 单选 @@ -32041,7 +32051,6 @@ exports[`csr snapshot test > csr test src/radio/_example/base.tsx 1`] = ` > @@ -32057,7 +32066,7 @@ exports[`csr snapshot test > csr test src/radio/_example/base.tsx 1`] = ` > 单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选 @@ -32071,7 +32080,6 @@ exports[`csr snapshot test > csr test src/radio/_example/base.tsx 1`] = ` > @@ -32087,7 +32095,7 @@ exports[`csr snapshot test > csr test src/radio/_example/base.tsx 1`] = ` > 单选 @@ -32117,7 +32125,6 @@ exports[`csr snapshot test > csr test src/radio/_example/card.tsx 1`] = ` @@ -32142,7 +32149,7 @@ exports[`csr snapshot test > csr test src/radio/_example/card.tsx 1`] = ` > 单选 @@ -32156,7 +32163,6 @@ exports[`csr snapshot test > csr test src/radio/_example/card.tsx 1`] = ` > @@ -32172,7 +32178,7 @@ exports[`csr snapshot test > csr test src/radio/_example/card.tsx 1`] = ` > 单选 @@ -32186,7 +32192,6 @@ exports[`csr snapshot test > csr test src/radio/_example/card.tsx 1`] = ` > @@ -32202,7 +32207,7 @@ exports[`csr snapshot test > csr test src/radio/_example/card.tsx 1`] = ` > 单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行 @@ -32252,7 +32257,6 @@ exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` @@ -32264,7 +32268,7 @@ exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` > 单选 @@ -32285,7 +32289,6 @@ exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` > @@ -32297,7 +32300,7 @@ exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` > 单选 @@ -32318,7 +32321,6 @@ exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` > @@ -32330,7 +32332,7 @@ exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` > 单选 @@ -32381,7 +32383,6 @@ exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` @@ -32393,7 +32394,7 @@ exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` > 单选 @@ -32408,7 +32409,6 @@ exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` > @@ -32420,7 +32420,7 @@ exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` > 单选 @@ -32435,7 +32435,6 @@ exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` > @@ -32447,7 +32446,7 @@ exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` > 单选 @@ -32471,7 +32470,6 @@ exports[`csr snapshot test > csr test src/radio/_example/horizontal.tsx 1`] = ` @@ -32496,7 +32494,7 @@ exports[`csr snapshot test > csr test src/radio/_example/horizontal.tsx 1`] = ` > 单选标题 @@ -32507,7 +32505,6 @@ exports[`csr snapshot test > csr test src/radio/_example/horizontal.tsx 1`] = ` > @@ -32523,7 +32520,7 @@ exports[`csr snapshot test > csr test src/radio/_example/horizontal.tsx 1`] = ` > 单选标题 @@ -32534,7 +32531,6 @@ exports[`csr snapshot test > csr test src/radio/_example/horizontal.tsx 1`] = ` > @@ -32550,7 +32546,7 @@ exports[`csr snapshot test > csr test src/radio/_example/horizontal.tsx 1`] = ` > 单选标题 @@ -32568,7 +32564,6 @@ exports[`csr snapshot test > csr test src/radio/_example/icon.tsx 1`] = ` @@ -32593,7 +32588,7 @@ exports[`csr snapshot test > csr test src/radio/_example/icon.tsx 1`] = ` > 单选 @@ -32608,7 +32603,6 @@ exports[`csr snapshot test > csr test src/radio/_example/icon.tsx 1`] = ` @@ -32624,7 +32618,7 @@ exports[`csr snapshot test > csr test src/radio/_example/icon.tsx 1`] = ` > 单选 @@ -32687,7 +32681,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` @@ -32712,7 +32705,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -32726,7 +32719,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > @@ -32742,7 +32734,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -32756,7 +32748,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > @@ -32772,7 +32763,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选 @@ -32786,7 +32777,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > @@ -32802,7 +32792,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -32848,7 +32838,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` @@ -32873,7 +32862,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选标题 @@ -32884,7 +32873,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > @@ -32900,7 +32888,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选标题 @@ -32911,7 +32899,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > @@ -32927,7 +32914,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选标题 @@ -32970,7 +32957,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` checked="" class="t-radio__original" disabled="" - readonly="" type="radio" value="1" /> @@ -32995,7 +32981,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 选项禁用-已选 @@ -33010,7 +32996,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` @@ -33026,7 +33011,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 选项禁用-默认 @@ -33068,7 +33053,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` @@ -33093,7 +33077,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -33108,7 +33092,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` @@ -33124,7 +33107,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -33160,7 +33143,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` @@ -33185,7 +33167,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -33200,7 +33182,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` @@ -33225,7 +33206,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -33264,7 +33245,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` @@ -33289,7 +33269,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -33303,7 +33283,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > @@ -33319,7 +33298,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -33333,7 +33312,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > @@ -33349,7 +33327,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行 @@ -33415,7 +33393,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` @@ -33427,7 +33404,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -33448,7 +33425,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > @@ -33460,7 +33436,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -33481,7 +33457,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > @@ -33493,7 +33468,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -33544,7 +33519,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` @@ -33556,7 +33530,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -33571,7 +33545,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > @@ -33583,7 +33556,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -33598,7 +33571,6 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > @@ -33610,7 +33582,7 @@ exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` > 单选 @@ -33635,7 +33607,6 @@ exports[`csr snapshot test > csr test src/radio/_example/placement.tsx 1`] = ` @@ -33660,7 +33631,7 @@ exports[`csr snapshot test > csr test src/radio/_example/placement.tsx 1`] = ` > 单选 @@ -33675,7 +33646,6 @@ exports[`csr snapshot test > csr test src/radio/_example/placement.tsx 1`] = ` @@ -33700,7 +33670,7 @@ exports[`csr snapshot test > csr test src/radio/_example/placement.tsx 1`] = ` > 单选 @@ -33724,7 +33694,6 @@ exports[`csr snapshot test > csr test src/radio/_example/status.tsx 1`] = ` checked="" class="t-radio__original" disabled="" - readonly="" type="radio" value="1" /> @@ -33749,7 +33718,7 @@ exports[`csr snapshot test > csr test src/radio/_example/status.tsx 1`] = ` > 选项禁用-已选 @@ -33764,7 +33733,6 @@ exports[`csr snapshot test > csr test src/radio/_example/status.tsx 1`] = ` @@ -33780,7 +33748,7 @@ exports[`csr snapshot test > csr test src/radio/_example/status.tsx 1`] = ` > 选项禁用-默认 @@ -55164,13 +55132,13 @@ exports[`ssr snapshot test > ssr test src/button/_example/test.tsx 1`] = `"
exports[`ssr snapshot test > ssr test src/button/_example/theme.tsx 1`] = `"
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/base.tsx 1`] = `"

Cell 单元格

一行内容/功能的垂直排列方式。一行项目左侧为主要内容展示区域,右侧可增加更多操作内容

01 类型

单行单元格

单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题

02

多行单元格

单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字

03 组件样式

卡片单元格

单行标题
单行标题
单行标题
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/base.tsx 1`] = `"

Cell 单元格

一行内容/功能的垂直排列方式。一行项目左侧为主要内容展示区域,右侧可增加更多操作内容

01 类型

单行单元格

单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题

02

多行单元格

单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字

03 组件样式

卡片单元格

单行标题
单行标题
单行标题
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/group.tsx 1`] = `"
单行标题
单行标题
单行标题
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/group.tsx 1`] = `"
单行标题
单行标题
单行标题
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/multiple.tsx 1`] = `"
单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/multiple.tsx 1`] = `"
单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/single.tsx 1`] = `"
单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/single.tsx 1`] = `"
单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题
"`; exports[`ssr snapshot test > ssr test src/checkbox/_example/all.tsx 1`] = `"
全选
多选
多选
多选
单选描述信息单选描述信息单选描述信息单选描述信息单选描述信息单选描述信息单选描述信息
"`; @@ -55412,6 +55380,22 @@ exports[`ssr snapshot test > ssr test src/progress/_example/plump.tsx 1`] = `" ssr test src/progress/_example/transition.tsx 1`] = `"
88%
"`; +exports[`ssr snapshot test > ssr test src/radio/_example/base.tsx 1`] = `"
单选
单选
单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选
单选
描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/card.tsx 1`] = `"
单选
单选
单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/custom.tsx 1`] = `"

单选框尺寸规格

单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息

横向卡片单选框

单选
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/horizontal.tsx 1`] = `"
单选标题
单选标题
单选标题
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/icon.tsx 1`] = `"
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/index.tsx 1`] = `"

Radio 单选框

用于在预设的一组选项中执行单项选择,并呈现选择结果。

01 组件类型

纵向单选框

单选
单选
单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选
单选
描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息

横向单选框

单选标题
单选标题
单选标题

02 组件状态

单选框禁用状态

选项禁用-已选
选项禁用-默认

03 组件样式

勾选样式

单选
单选

勾选显示位置

单选
单选

非通栏单选样式

单选
单选
单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行

04 特殊样式

单选框尺寸规格

单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息

横向卡片单选框

单选
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/placement.tsx 1`] = `"
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/status.tsx 1`] = `"
选项禁用-已选
选项禁用-默认
"`; + exports[`ssr snapshot test > ssr test src/result/_example/custom.tsx 1`] = `"
自定义结果
描述文字
"`; exports[`ssr snapshot test > ssr test src/result/_example/index.tsx 1`] = `"

Result 结果

结果反馈

01类型

不同结果反馈

成功状态
描述文字
失败状态
描述文字
警示状态
描述文字
默认状态
描述文字

自定义结果

自定义结果
描述文字

页面位置展示

"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index b3964200..5a7685f8 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -34,13 +34,13 @@ exports[`ssr snapshot test > ssr test src/button/_example/test.tsx 1`] = `"
exports[`ssr snapshot test > ssr test src/button/_example/theme.tsx 1`] = `"
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/base.tsx 1`] = `"

Cell 单元格

一行内容/功能的垂直排列方式。一行项目左侧为主要内容展示区域,右侧可增加更多操作内容

01 类型

单行单元格

单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题

02

多行单元格

单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字

03 组件样式

卡片单元格

单行标题
单行标题
单行标题
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/base.tsx 1`] = `"

Cell 单元格

一行内容/功能的垂直排列方式。一行项目左侧为主要内容展示区域,右侧可增加更多操作内容

01 类型

单行单元格

单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题

02

多行单元格

单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字

03 组件样式

卡片单元格

单行标题
单行标题
单行标题
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/group.tsx 1`] = `"
单行标题
单行标题
单行标题
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/group.tsx 1`] = `"
单行标题
单行标题
单行标题
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/multiple.tsx 1`] = `"
单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/multiple.tsx 1`] = `"
单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/single.tsx 1`] = `"
单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/single.tsx 1`] = `"
单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题
"`; exports[`ssr snapshot test > ssr test src/checkbox/_example/all.tsx 1`] = `"
全选
多选
多选
多选
单选描述信息单选描述信息单选描述信息单选描述信息单选描述信息单选描述信息单选描述信息
"`; @@ -282,6 +282,22 @@ exports[`ssr snapshot test > ssr test src/progress/_example/plump.tsx 1`] = `" ssr test src/progress/_example/transition.tsx 1`] = `"
88%
"`; +exports[`ssr snapshot test > ssr test src/radio/_example/base.tsx 1`] = `"
单选
单选
单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选
单选
描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/card.tsx 1`] = `"
单选
单选
单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/custom.tsx 1`] = `"

单选框尺寸规格

单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息

横向卡片单选框

单选
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/horizontal.tsx 1`] = `"
单选标题
单选标题
单选标题
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/icon.tsx 1`] = `"
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/index.tsx 1`] = `"

Radio 单选框

用于在预设的一组选项中执行单项选择,并呈现选择结果。

01 组件类型

纵向单选框

单选
单选
单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选
单选
描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息

横向单选框

单选标题
单选标题
单选标题

02 组件状态

单选框禁用状态

选项禁用-已选
选项禁用-默认

03 组件样式

勾选样式

单选
单选

勾选显示位置

单选
单选

非通栏单选样式

单选
单选
单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行

04 特殊样式

单选框尺寸规格

单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息

横向卡片单选框

单选
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/placement.tsx 1`] = `"
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/status.tsx 1`] = `"
选项禁用-已选
选项禁用-默认
"`; + exports[`ssr snapshot test > ssr test src/result/_example/custom.tsx 1`] = `"
自定义结果
描述文字
"`; exports[`ssr snapshot test > ssr test src/result/_example/index.tsx 1`] = `"

Result 结果

结果反馈

01类型

不同结果反馈

成功状态
描述文字
失败状态
描述文字
警示状态
描述文字
默认状态
描述文字

自定义结果

自定义结果
描述文字

页面位置展示

"`; From 1b9fd7be73ddf7006ee74cbf904f00a9f052aaa6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 23 Sep 2024 02:46:55 +0000 Subject: [PATCH 3/5] chore: update snapshot --- test/snap/__snapshots__/csr.test.jsx.snap | 32 +++++++---------------- test/snap/__snapshots__/ssr.test.jsx.snap | 8 +++--- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index b3647135..3068b3e1 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -2987,10 +2987,8 @@ exports[`csr snapshot test > csr test src/cell/_example/base.tsx 1`] = ` width="1em" >
@@ -3272,10 +3270,8 @@ exports[`csr snapshot test > csr test src/cell/_example/base.tsx 1`] = ` width="1em" >
@@ -3466,10 +3462,8 @@ exports[`csr snapshot test > csr test src/cell/_example/base.tsx 1`] = ` width="1em" >
@@ -3629,10 +3623,8 @@ exports[`csr snapshot test > csr test src/cell/_example/group.tsx 1`] = ` width="1em" >
@@ -3994,10 +3986,8 @@ exports[`csr snapshot test > csr test src/cell/_example/multiple.tsx 1`] = ` width="1em" >
@@ -4354,10 +4344,8 @@ exports[`csr snapshot test > csr test src/cell/_example/single.tsx 1`] = ` width="1em" >
@@ -55132,13 +55120,13 @@ exports[`ssr snapshot test > ssr test src/button/_example/test.tsx 1`] = `"
exports[`ssr snapshot test > ssr test src/button/_example/theme.tsx 1`] = `"
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/base.tsx 1`] = `"

Cell 单元格

一行内容/功能的垂直排列方式。一行项目左侧为主要内容展示区域,右侧可增加更多操作内容

01 类型

单行单元格

单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题

02

多行单元格

单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字

03 组件样式

卡片单元格

单行标题
单行标题
单行标题
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/base.tsx 1`] = `"

Cell 单元格

一行内容/功能的垂直排列方式。一行项目左侧为主要内容展示区域,右侧可增加更多操作内容

01 类型

单行单元格

单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题

02

多行单元格

单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字

03 组件样式

卡片单元格

单行标题
单行标题
单行标题
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/group.tsx 1`] = `"
单行标题
单行标题
单行标题
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/group.tsx 1`] = `"
单行标题
单行标题
单行标题
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/multiple.tsx 1`] = `"
单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/multiple.tsx 1`] = `"
单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/single.tsx 1`] = `"
单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/single.tsx 1`] = `"
单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题
"`; exports[`ssr snapshot test > ssr test src/checkbox/_example/all.tsx 1`] = `"
全选
多选
多选
多选
单选描述信息单选描述信息单选描述信息单选描述信息单选描述信息单选描述信息单选描述信息
"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index 5a7685f8..d98d07a7 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -34,13 +34,13 @@ exports[`ssr snapshot test > ssr test src/button/_example/test.tsx 1`] = `"
exports[`ssr snapshot test > ssr test src/button/_example/theme.tsx 1`] = `"
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/base.tsx 1`] = `"

Cell 单元格

一行内容/功能的垂直排列方式。一行项目左侧为主要内容展示区域,右侧可增加更多操作内容

01 类型

单行单元格

单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题

02

多行单元格

单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字

03 组件样式

卡片单元格

单行标题
单行标题
单行标题
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/base.tsx 1`] = `"

Cell 单元格

一行内容/功能的垂直排列方式。一行项目左侧为主要内容展示区域,右侧可增加更多操作内容

01 类型

单行单元格

单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题

02

多行单元格

单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字

03 组件样式

卡片单元格

单行标题
单行标题
单行标题
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/group.tsx 1`] = `"
单行标题
单行标题
单行标题
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/group.tsx 1`] = `"
单行标题
单行标题
单行标题
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/multiple.tsx 1`] = `"
单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/multiple.tsx 1`] = `"
单行标题
一段很长很长的内容文字
单行标题 *
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
16
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字
辅助信息
单行标题
一段很长很长的内容文字
单行标题
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行高度不定,长文本自动换行,该选项的描述是一段很长的内容
一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容
多行带头像
一段很长很长的内容文字
多行带图片
一段很长很长的内容文字
"`; -exports[`ssr snapshot test > ssr test src/cell/_example/single.tsx 1`] = `"
单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题
"`; +exports[`ssr snapshot test > ssr test src/cell/_example/single.tsx 1`] = `"
单行标题
单行标题 *
单行标题
16
单行标题
单行标题
辅助信息
单行标题
"`; exports[`ssr snapshot test > ssr test src/checkbox/_example/all.tsx 1`] = `"
全选
多选
多选
多选
单选描述信息单选描述信息单选描述信息单选描述信息单选描述信息单选描述信息单选描述信息
"`; From 153069031b047da0ec781ee0ed9a11cddc651e15 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 8 Nov 2024 12:30:48 +0000 Subject: [PATCH 4/5] chore: update snapshot --- test/snap/__snapshots__/csr.test.jsx.snap | 1804 +++++++++++++++++++++ test/snap/__snapshots__/ssr.test.jsx.snap | 16 + 2 files changed, 1820 insertions(+) diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index 2bcb17b3..727169d6 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -37724,6 +37724,1794 @@ exports[`csr snapshot test > csr test src/pull-down-refresh/_example/top.tsx 1`]
`; +exports[`csr snapshot test > csr test src/radio/_example/base.tsx 1`] = ` +
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/card.tsx 1`] = ` +
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行 + +
+
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/custom.tsx 1`] = ` +
+
+
+

+ 单选框尺寸规格 +

+
+
+
+
+ + + +
+ +
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+ +
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+ +
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+
+
+
+

+ 横向卡片单选框 +

+
+
+
+
+ + + +
+ +
+
+ + 单选 + +
+
+
+
+
+ +
+
+ + 单选 + +
+
+
+
+
+ +
+
+ + 单选 + +
+
+
+
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/horizontal.tsx 1`] = ` +
+
+
+ +
+ + + +
+
+ + 单选标题 + +
+
+
+ +
+
+
+
+ + 单选标题 + +
+
+
+ +
+
+
+
+ + 单选标题 + +
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/icon.tsx 1`] = ` +
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/index.tsx 1`] = ` +
+
+
+

+ Radio 单选框 +

+

+ 用于在预设的一组选项中执行单项选择,并呈现选择结果。 +

+
+
+
+

+ 01 组件类型 +

+

+ 纵向单选框 +

+
+
+
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+
+
+
+
+

+ 横向单选框 +

+
+
+
+
+
+ +
+ + + +
+
+ + 单选标题 + +
+
+
+ +
+
+
+
+ + 单选标题 + +
+
+
+ +
+
+
+
+ + 单选标题 + +
+
+
+
+
+
+
+
+

+ 02 组件状态 +

+

+ 单选框禁用状态 +

+
+
+
+
+
+ +
+ + + +
+
+ + 选项禁用-已选 + +
+
+
+
+ +
+
+
+
+ + 选项禁用-默认 + +
+
+
+
+
+
+
+
+
+

+ 03 组件样式 +

+

+ 勾选样式 +

+
+
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+
+
+
+
+
+
+
+

+ 勾选显示位置 +

+
+
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+
+
+
+
+

+ 非通栏单选样式 +

+
+
+
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选 + +
+
+
+
+ +
+
+
+
+ + 单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行 + +
+
+
+
+
+
+
+
+
+

+ 04 特殊样式 +

+
+
+
+
+
+

+ 单选框尺寸规格 +

+
+
+
+
+ + + +
+ +
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+ +
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+ +
+
+ + 单选 + +
+ 描述信息描述信息描述信息描述信息描述信息 +
+
+
+
+
+
+
+
+
+

+ 横向卡片单选框 +

+
+
+
+
+ + + +
+ +
+
+ + 单选 + +
+
+
+
+
+ +
+
+ + 单选 + +
+
+
+
+
+ +
+
+ + 单选 + +
+
+
+
+
+
+
+
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/placement.tsx 1`] = ` +
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+ +
+ + + +
+
+ + 单选 + +
+
+
+
+`; + +exports[`csr snapshot test > csr test src/radio/_example/status.tsx 1`] = ` +
+
+
+ +
+ + + +
+
+ + 选项禁用-已选 + +
+
+
+
+ +
+
+
+
+ + 选项禁用-默认 + +
+
+
+
+
+`; + exports[`csr snapshot test > csr test src/result/_example/custom.tsx 1`] = `
ssr test src/pull-down-refresh/_example/timeout.tsx exports[`ssr snapshot test > ssr test src/pull-down-refresh/_example/top.tsx 1`] = `"
拖拽该区域演示 中间下拉刷新
"`; +exports[`ssr snapshot test > ssr test src/radio/_example/base.tsx 1`] = `"
单选
单选
单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选
单选
描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/card.tsx 1`] = `"
单选
单选
单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/custom.tsx 1`] = `"

单选框尺寸规格

单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息

横向卡片单选框

单选
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/horizontal.tsx 1`] = `"
单选标题
单选标题
单选标题
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/icon.tsx 1`] = `"
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/index.tsx 1`] = `"

Radio 单选框

用于在预设的一组选项中执行单项选择,并呈现选择结果。

01 组件类型

纵向单选框

单选
单选
单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选
单选
描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息

横向单选框

单选标题
单选标题
单选标题

02 组件状态

单选框禁用状态

选项禁用-已选
选项禁用-默认

03 组件样式

勾选样式

单选
单选

勾选显示位置

单选
单选

非通栏单选样式

单选
单选
单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行

04 特殊样式

单选框尺寸规格

单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息

横向卡片单选框

单选
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/placement.tsx 1`] = `"
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/status.tsx 1`] = `"
选项禁用-已选
选项禁用-默认
"`; + exports[`ssr snapshot test > ssr test src/result/_example/custom.tsx 1`] = `"
自定义结果
描述文字
"`; exports[`ssr snapshot test > ssr test src/result/_example/index.tsx 1`] = `"

Result 结果

结果反馈

01类型

不同结果反馈

成功状态
描述文字
失败状态
描述文字
警示状态
描述文字
默认状态
描述文字

自定义结果

自定义结果
描述文字

页面位置展示

"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index 7f56d84a..ea2a563b 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -334,6 +334,22 @@ exports[`ssr snapshot test > ssr test src/pull-down-refresh/_example/timeout.tsx exports[`ssr snapshot test > ssr test src/pull-down-refresh/_example/top.tsx 1`] = `"
拖拽该区域演示 中间下拉刷新
"`; +exports[`ssr snapshot test > ssr test src/radio/_example/base.tsx 1`] = `"
单选
单选
单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选
单选
描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/card.tsx 1`] = `"
单选
单选
单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/custom.tsx 1`] = `"

单选框尺寸规格

单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息

横向卡片单选框

单选
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/horizontal.tsx 1`] = `"
单选标题
单选标题
单选标题
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/icon.tsx 1`] = `"
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/index.tsx 1`] = `"

Radio 单选框

用于在预设的一组选项中执行单项选择,并呈现选择结果。

01 组件类型

纵向单选框

单选
单选
单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选单选
单选
描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息描述信息

横向单选框

单选标题
单选标题
单选标题

02 组件状态

单选框禁用状态

选项禁用-已选
选项禁用-默认

03 组件样式

勾选样式

单选
单选

勾选显示位置

单选
单选

非通栏单选样式

单选
单选
单选标题多行单选标题多行单选标题多行单选标题多行单选标题多行

04 特殊样式

单选框尺寸规格

单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息
单选
描述信息描述信息描述信息描述信息描述信息

横向卡片单选框

单选
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/placement.tsx 1`] = `"
单选
单选
"`; + +exports[`ssr snapshot test > ssr test src/radio/_example/status.tsx 1`] = `"
选项禁用-已选
选项禁用-默认
"`; + exports[`ssr snapshot test > ssr test src/result/_example/custom.tsx 1`] = `"
自定义结果
描述文字
"`; exports[`ssr snapshot test > ssr test src/result/_example/index.tsx 1`] = `"

Result 结果

结果反馈

01类型

不同结果反馈

成功状态
描述文字
失败状态
描述文字
警示状态
描述文字
默认状态
描述文字

自定义结果

自定义结果
描述文字

页面位置展示

"`; From 3992bff5c23eded526be034b9ac9b1dde34fd5e3 Mon Sep 17 00:00:00 2001 From: anlyyao Date: Mon, 11 Nov 2024 15:36:42 +0800 Subject: [PATCH 5/5] chore: update _common --- src/_common | 2 +- src/radio/Radio.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_common b/src/_common index 89f8f376..aff70309 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 89f8f3768417d13c550cf8d98011d78882002bf7 +Subproject commit aff7030919f99fce6093fbec65317e5f07762af0 diff --git a/src/radio/Radio.tsx b/src/radio/Radio.tsx index fb379498..f606cb2d 100644 --- a/src/radio/Radio.tsx +++ b/src/radio/Radio.tsx @@ -2,7 +2,7 @@ import React, { createContext, forwardRef, useContext, useRef } from 'react'; import type { CSSProperties, Ref } from 'react'; import classNames from 'classnames'; import { CheckIcon, CheckCircleFilledIcon } from 'tdesign-icons-react'; -import { usePrefixClass } from 'tdesign-mobile-react/hooks/useClass'; +import { usePrefixClass } from '../hooks/useClass'; import forwardRefWithStatics from '../_util/forwardRefWithStatics'; import useDefault from '../_util/useDefault'; import type { TdRadioProps } from './type';