Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: stepper 组件增加只读属性 (#1036) #1039

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiled/alipay/demo/pages/Stepper/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
defaultValue="{{ 0 }}"
disabled />
</container>
<container title="输入框只读">
<stepper
defaultValue="{{ 0 }}"
inputReadOnly />
</container>
<container title="受控组件">
<stepper
value="{{ value }}"
Expand Down
6 changes: 6 additions & 0 deletions compiled/alipay/src/Stepper/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
disabled="{{ disabled || (mixin.value !== '' && mixin.value <= min) }}"
onTap="onTap" />
<view class="ant-stepper-input-wrap">
<view
a:if="{{ inputReadOnly }}"
class="ant-stepper-input ant-stepper-input-readonly">
{{ mixin.value }}
</view>
<ant-input
a:else
className="ant-stepper-input {{ disabled ? 'ant-stepper-input-disabled' : '' }} {{ inputClassName ? inputClassName : '' }}"
style="{{ inputStyle }}"
type="{{ type }}"
Expand Down
1 change: 1 addition & 0 deletions compiled/alipay/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 compiled/alipay/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
5 changes: 5 additions & 0 deletions compiled/wechat/demo/pages/Stepper/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
defaultValue="{{ 0 }}"
disabled />
</container>
<container title="输入框只读">
<stepper
defaultValue="{{ 0 }}"
inputReadOnly />
</container>
<container title="受控组件">
<stepper
value="{{ value }}"
Expand Down
1 change: 1 addition & 0 deletions compiled/wechat/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 compiled/wechat/src/Stepper/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
disabled="{{ disabled || (mixin.value !== '' && mixin.value <= min) }}"
bind:tap="onTap" />
<view class="ant-stepper-input-wrap">
<view
wx:if="{{ inputReadOnly }}"
class="ant-stepper-input ant-stepper-input-readonly">
{{ mixin.value }}
</view>
<ant-input
wx:else
className="ant-stepper-input {{ disabled ? 'ant-stepper-input-disabled' : '' }} {{ inputClassName ? inputClassName : '' }}"
style="{{ inputStyle }}"
type="{{ type }}"
Expand Down
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
7 changes: 7 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 Expand Up @@ -98,4 +104,5 @@ export const StepperFunctionalProps: Partial<IStepperProps> = {
inputClassName: '',
inputStyle: '',
disabled: false,
inputReadOnly: false,
};
Loading