Skip to content

Commit

Permalink
feat: stepper 组件增加只读属性 (ant-design#1036)
Browse files Browse the repository at this point in the history
  • Loading branch information
HongHaiyang committed Jan 18, 2024
1 parent 07034fd commit d8e738d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
3 changes: 3 additions & 0 deletions demo/pages/Stepper/index.axml.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export default (_, { value, }: InternalData) => (
<Container title="禁用状态">
<Stepper defaultValue={0} disabled />
</Container>
<Container title="输入框只读">
<Stepper defaultValue={0} inputReadOnly />
</Container>
<Container title="受控组件">
<Stepper
value={value}
Expand Down
43 changes: 25 additions & 18 deletions src/Stepper/index.axml.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default (
type,
max,
focus,
inputReadOnly,
}: TSXMLProps<IStepperProps>,
{ mixin, enableNative, alwaysSystem, confirmType, confirmHold }
) => (
Expand All @@ -32,24 +33,30 @@ export default (
onTap="onTap"
/>
<View class="ant-stepper-input-wrap">
<AntInput
className={`ant-stepper-input ${
disabled ? 'ant-stepper-input-disabled' : ''
} ${inputClassName ? inputClassName : ''}`}
style={inputStyle}
type={type}
enableNative={enableNative}
alwaysSystem={alwaysSystem}
confirm-type={confirmType}
confirm-hold={confirmHold}
disabled={disabled}
focus={focus}
onChange="onChange"
onFocus="onFocus"
onBlur="onBlur"
onConfirm="onConfirm"
value={mixin.value}
/>
{inputReadOnly ? (
<View class="ant-stepper-input ant-stepper-input-readonly">
{mixin.value}
</View>
) : (
<AntInput
className={`ant-stepper-input ${
disabled ? 'ant-stepper-input-disabled' : ''
} ${inputClassName ? inputClassName : ''}`}
style={inputStyle}
type={type}
enableNative={enableNative}
alwaysSystem={alwaysSystem}
confirm-type={confirmType}
confirm-hold={confirmHold}
disabled={disabled}
focus={focus}
onChange="onChange"
onFocus="onFocus"
onBlur="onBlur"
onConfirm="onConfirm"
value={mixin.value}
/>
)}
</View>
<AntButton
className={`ant-stepper-button ant-stepper-button-up ${
Expand Down
1 change: 1 addition & 0 deletions src/Stepper/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ toc: 'content'
| -----|-----|-----|----- |
| className | 类名 | string | - |
| disabled | 是否禁用 | boolean | false |
| inputReadOnly | 输入框是否只读状态 | boolean | false |
| defaultValue | 初始值 | number | - |
| focus | 输入框选中状态 | boolean | false |
| inputClassName | 输入框类型 | string | - |
Expand Down
6 changes: 6 additions & 0 deletions src/Stepper/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ export interface IStepperProps extends IBaseProps {
*/
disabled?: boolean;

/**
* @description 输入框是否只读
* @default false
*/
inputReadOnly?: boolean;

/**
* @description 输入框初始值
*/
Expand Down

0 comments on commit d8e738d

Please sign in to comment.