mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-11 19:42:54 +08:00
feat: InputNumber support addon (#31432)
* feat: InputNumber support addon * docs: Update InputNumber doc * chore: Update snapshot and fix lint * chore: Add release version Co-authored-by: afc163 <afc163@gmail.com> Co-authored-by: afc163 <afc163@gmail.com>
This commit is contained in:
parent
47f2bd47e1
commit
d86e1b5153
@ -3600,6 +3600,178 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-row ant-form-item"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
class="ant-form-item-required"
|
||||||
|
for="register_donation"
|
||||||
|
title="Donation"
|
||||||
|
>
|
||||||
|
Donation
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-col ant-form-item-control ant-col-xs-24 ant-col-sm-16"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-form-item-control-input"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-form-item-control-input-content"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-group-wrapper"
|
||||||
|
style="width:100%"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-wrapper ant-input-number-group"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-handler-wrap"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-label="Increase Value"
|
||||||
|
class="ant-input-number-handler ant-input-number-handler-up"
|
||||||
|
role="button"
|
||||||
|
unselectable="on"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="up"
|
||||||
|
class="anticon anticon-up ant-input-number-handler-up-inner"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="up"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M890.5 755.3L537.9 269.2c-12.8-17.6-39-17.6-51.7 0L133.5 755.3A8 8 0 00140 768h75c5.1 0 9.9-2.5 12.9-6.6L512 369.8l284.1 391.6c3 4.1 7.8 6.6 12.9 6.6h75c6.5 0 10.3-7.4 6.5-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-label="Decrease Value"
|
||||||
|
class="ant-input-number-handler ant-input-number-handler-down"
|
||||||
|
role="button"
|
||||||
|
unselectable="on"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="down"
|
||||||
|
class="anticon anticon-down ant-input-number-handler-down-inner"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="down"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-input-wrap"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
autocomplete="off"
|
||||||
|
class="ant-input-number-input"
|
||||||
|
id="register_donation"
|
||||||
|
role="spinbutton"
|
||||||
|
step="1"
|
||||||
|
value=""
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-group-addon"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-select ant-select-single ant-select-show-arrow"
|
||||||
|
style="width:70px"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-select-selector"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="ant-select-selection-search"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
aria-activedescendant="register_suffix_list_0"
|
||||||
|
aria-autocomplete="list"
|
||||||
|
aria-controls="register_suffix_list"
|
||||||
|
aria-haspopup="listbox"
|
||||||
|
aria-owns="register_suffix_list"
|
||||||
|
autocomplete="off"
|
||||||
|
class="ant-select-selection-search-input"
|
||||||
|
id="register_suffix"
|
||||||
|
readonly=""
|
||||||
|
role="combobox"
|
||||||
|
style="opacity:0"
|
||||||
|
type="search"
|
||||||
|
unselectable="on"
|
||||||
|
value=""
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
class="ant-select-selection-placeholder"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
class="ant-select-arrow"
|
||||||
|
style="user-select:none;-webkit-user-select:none"
|
||||||
|
unselectable="on"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="down"
|
||||||
|
class="anticon anticon-down ant-select-suffix"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="down"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
class="ant-row ant-form-item"
|
class="ant-row ant-form-item"
|
||||||
>
|
>
|
||||||
|
@ -15,7 +15,18 @@ Fill in this form to create a new account for you.
|
|||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Form, Input, Cascader, Select, Row, Col, Checkbox, Button, AutoComplete } from 'antd';
|
import {
|
||||||
|
Form,
|
||||||
|
Input,
|
||||||
|
InputNumber,
|
||||||
|
Cascader,
|
||||||
|
Select,
|
||||||
|
Row,
|
||||||
|
Col,
|
||||||
|
Checkbox,
|
||||||
|
Button,
|
||||||
|
AutoComplete,
|
||||||
|
} from 'antd';
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
|
|
||||||
@ -93,6 +104,15 @@ const RegistrationForm = () => {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const suffixSelector = (
|
||||||
|
<Form.Item name="suffix" noStyle>
|
||||||
|
<Select style={{ width: 70 }}>
|
||||||
|
<Option value="USD">$</Option>
|
||||||
|
<Option value="CNY">¥</Option>
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
);
|
||||||
|
|
||||||
const [autoCompleteResult, setAutoCompleteResult] = useState<string[]>([]);
|
const [autoCompleteResult, setAutoCompleteResult] = useState<string[]>([]);
|
||||||
|
|
||||||
const onWebsiteChange = (value: string) => {
|
const onWebsiteChange = (value: string) => {
|
||||||
@ -201,6 +221,14 @@ const RegistrationForm = () => {
|
|||||||
<Input addonBefore={prefixSelector} style={{ width: '100%' }} />
|
<Input addonBefore={prefixSelector} style={{ width: '100%' }} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item
|
||||||
|
name="donation"
|
||||||
|
label="Donation"
|
||||||
|
rules={[{ required: true, message: 'Please input donation amount!' }]}
|
||||||
|
>
|
||||||
|
<InputNumber addonAfter={suffixSelector} style={{ width: '100%' }} />
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="website"
|
name="website"
|
||||||
label="Website"
|
label="Website"
|
||||||
|
@ -65,7 +65,9 @@
|
|||||||
.@{ant-prefix}-picker-calendar-year-select,
|
.@{ant-prefix}-picker-calendar-year-select,
|
||||||
.@{ant-prefix}-picker-calendar-month-select,
|
.@{ant-prefix}-picker-calendar-month-select,
|
||||||
.@{ant-prefix}-input-group .@{ant-prefix}-select,
|
.@{ant-prefix}-input-group .@{ant-prefix}-select,
|
||||||
.@{ant-prefix}-input-group .@{ant-prefix}-cascader-picker {
|
.@{ant-prefix}-input-group .@{ant-prefix}-cascader-picker,
|
||||||
|
.@{ant-prefix}-input-number-group .@{ant-prefix}-select,
|
||||||
|
.@{ant-prefix}-input-number-group .@{ant-prefix}-cascader-picker {
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
color: @text-color;
|
color: @text-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
.@{ant-prefix}-input-group-addon {
|
.@{ant-prefix}-input-group-addon,
|
||||||
|
.@{ant-prefix}-input-number-group-addon {
|
||||||
color: @text-color;
|
color: @text-color;
|
||||||
border-color: @border-color;
|
border-color: @border-color;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,13 @@
|
|||||||
> .@{ant-prefix}-select .@{ant-prefix}-select-arrow,
|
> .@{ant-prefix}-select .@{ant-prefix}-select-arrow,
|
||||||
> .@{ant-prefix}-select .@{ant-prefix}-select-clear,
|
> .@{ant-prefix}-select .@{ant-prefix}-select-clear,
|
||||||
:not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-arrow,
|
:not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-arrow,
|
||||||
:not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-clear {
|
:not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-clear,
|
||||||
|
:not(.@{ant-prefix}-input-number-group-addon)
|
||||||
|
> .@{ant-prefix}-select
|
||||||
|
.@{ant-prefix}-select-arrow,
|
||||||
|
:not(.@{ant-prefix}-input-number-group-addon)
|
||||||
|
> .@{ant-prefix}-select
|
||||||
|
.@{ant-prefix}-select-clear {
|
||||||
.@{form-prefix-cls}-rtl & {
|
.@{form-prefix-cls}-rtl & {
|
||||||
right: auto;
|
right: auto;
|
||||||
left: 32px;
|
left: 32px;
|
||||||
@ -106,6 +112,9 @@
|
|||||||
|
|
||||||
> .@{ant-prefix}-select .@{ant-prefix}-select-selection-selected-value,
|
> .@{ant-prefix}-select .@{ant-prefix}-select-selection-selected-value,
|
||||||
:not(.@{ant-prefix}-input-group-addon)
|
:not(.@{ant-prefix}-input-group-addon)
|
||||||
|
> .@{ant-prefix}-select
|
||||||
|
.@{ant-prefix}-select-selection-selected-value,
|
||||||
|
:not(.@{ant-prefix}-input-number-group-addon)
|
||||||
> .@{ant-prefix}-select
|
> .@{ant-prefix}-select
|
||||||
.@{ant-prefix}-select-selection-selected-value {
|
.@{ant-prefix}-select-selection-selected-value {
|
||||||
.@{form-prefix-cls}-rtl & {
|
.@{form-prefix-cls}-rtl & {
|
||||||
|
@ -48,11 +48,20 @@
|
|||||||
> .@{ant-prefix}-select .@{ant-prefix}-select-arrow,
|
> .@{ant-prefix}-select .@{ant-prefix}-select-arrow,
|
||||||
> .@{ant-prefix}-select .@{ant-prefix}-select-clear,
|
> .@{ant-prefix}-select .@{ant-prefix}-select-clear,
|
||||||
:not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-arrow,
|
:not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-arrow,
|
||||||
:not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-clear {
|
:not(.@{ant-prefix}-input-group-addon) > .@{ant-prefix}-select .@{ant-prefix}-select-clear,
|
||||||
|
:not(.@{ant-prefix}-input-number-group-addon)
|
||||||
|
> .@{ant-prefix}-select
|
||||||
|
.@{ant-prefix}-select-arrow,
|
||||||
|
:not(.@{ant-prefix}-input-number-group-addon)
|
||||||
|
> .@{ant-prefix}-select
|
||||||
|
.@{ant-prefix}-select-clear {
|
||||||
right: 32px;
|
right: 32px;
|
||||||
}
|
}
|
||||||
> .@{ant-prefix}-select .@{ant-prefix}-select-selection-selected-value,
|
> .@{ant-prefix}-select .@{ant-prefix}-select-selection-selected-value,
|
||||||
:not(.@{ant-prefix}-input-group-addon)
|
:not(.@{ant-prefix}-input-group-addon)
|
||||||
|
> .@{ant-prefix}-select
|
||||||
|
.@{ant-prefix}-select-selection-selected-value,
|
||||||
|
:not(.@{ant-prefix}-input-number-group-addon)
|
||||||
> .@{ant-prefix}-select
|
> .@{ant-prefix}-select
|
||||||
.@{ant-prefix}-select-selection-selected-value {
|
.@{ant-prefix}-select-selection-selected-value {
|
||||||
padding-right: 42px;
|
padding-right: 42px;
|
||||||
@ -179,12 +188,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fixes https://github.com/ant-design/ant-design/issues/20482
|
// fixes https://github.com/ant-design/ant-design/issues/20482
|
||||||
.@{ant-prefix}-input-group-addon .@{ant-prefix}-select {
|
.@{ant-prefix}-input-group-addon,
|
||||||
&.@{ant-prefix}-select-single:not(.@{ant-prefix}-select-customize-input)
|
.@{ant-prefix}-input-number-group-addon {
|
||||||
.@{ant-prefix}-select-selector {
|
.@{ant-prefix}-select {
|
||||||
background-color: inherit;
|
&.@{ant-prefix}-select-single:not(.@{ant-prefix}-select-customize-input)
|
||||||
border: 0;
|
.@{ant-prefix}-select-selector {
|
||||||
box-shadow: none;
|
background-color: inherit;
|
||||||
|
border: 0;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,559 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`renders ./components/input-number/demo/addon.md correctly 1`] = `
|
||||||
|
<div
|
||||||
|
class="ant-space ant-space-vertical"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-space-item"
|
||||||
|
style="margin-bottom:8px"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-group-wrapper"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-wrapper ant-input-number-group"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-group-addon"
|
||||||
|
>
|
||||||
|
+
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-input-number"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-handler-wrap"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-label="Increase Value"
|
||||||
|
class="ant-input-number-handler ant-input-number-handler-up"
|
||||||
|
role="button"
|
||||||
|
unselectable="on"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="up"
|
||||||
|
class="anticon anticon-up ant-input-number-handler-up-inner"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="up"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M890.5 755.3L537.9 269.2c-12.8-17.6-39-17.6-51.7 0L133.5 755.3A8 8 0 00140 768h75c5.1 0 9.9-2.5 12.9-6.6L512 369.8l284.1 391.6c3 4.1 7.8 6.6 12.9 6.6h75c6.5 0 10.3-7.4 6.5-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-label="Decrease Value"
|
||||||
|
class="ant-input-number-handler ant-input-number-handler-down"
|
||||||
|
role="button"
|
||||||
|
unselectable="on"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="down"
|
||||||
|
class="anticon anticon-down ant-input-number-handler-down-inner"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="down"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-input-wrap"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
aria-valuenow="100"
|
||||||
|
autocomplete="off"
|
||||||
|
class="ant-input-number-input"
|
||||||
|
role="spinbutton"
|
||||||
|
step="1"
|
||||||
|
value="100"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-group-addon"
|
||||||
|
>
|
||||||
|
$
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-space-item"
|
||||||
|
style="margin-bottom:8px"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-group-wrapper"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-wrapper ant-input-number-group"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-group-addon"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-select select-before ant-select-single ant-select-show-arrow"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-select-selector"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="ant-select-selection-search"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
aria-activedescendant="undefined_list_0"
|
||||||
|
aria-autocomplete="list"
|
||||||
|
aria-controls="undefined_list"
|
||||||
|
aria-haspopup="listbox"
|
||||||
|
aria-owns="undefined_list"
|
||||||
|
autocomplete="off"
|
||||||
|
class="ant-select-selection-search-input"
|
||||||
|
readonly=""
|
||||||
|
role="combobox"
|
||||||
|
style="opacity:0"
|
||||||
|
type="search"
|
||||||
|
unselectable="on"
|
||||||
|
value=""
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
class="ant-select-selection-item"
|
||||||
|
title="+"
|
||||||
|
>
|
||||||
|
+
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
class="ant-select-arrow"
|
||||||
|
style="user-select:none;-webkit-user-select:none"
|
||||||
|
unselectable="on"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="down"
|
||||||
|
class="anticon anticon-down ant-select-suffix"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="down"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-input-number"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-handler-wrap"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-label="Increase Value"
|
||||||
|
class="ant-input-number-handler ant-input-number-handler-up"
|
||||||
|
role="button"
|
||||||
|
unselectable="on"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="up"
|
||||||
|
class="anticon anticon-up ant-input-number-handler-up-inner"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="up"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M890.5 755.3L537.9 269.2c-12.8-17.6-39-17.6-51.7 0L133.5 755.3A8 8 0 00140 768h75c5.1 0 9.9-2.5 12.9-6.6L512 369.8l284.1 391.6c3 4.1 7.8 6.6 12.9 6.6h75c6.5 0 10.3-7.4 6.5-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-label="Decrease Value"
|
||||||
|
class="ant-input-number-handler ant-input-number-handler-down"
|
||||||
|
role="button"
|
||||||
|
unselectable="on"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="down"
|
||||||
|
class="anticon anticon-down ant-input-number-handler-down-inner"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="down"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-input-wrap"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
aria-valuenow="100"
|
||||||
|
autocomplete="off"
|
||||||
|
class="ant-input-number-input"
|
||||||
|
role="spinbutton"
|
||||||
|
step="1"
|
||||||
|
value="100"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-group-addon"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-select select-after ant-select-single ant-select-show-arrow"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-select-selector"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="ant-select-selection-search"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
aria-activedescendant="undefined_list_0"
|
||||||
|
aria-autocomplete="list"
|
||||||
|
aria-controls="undefined_list"
|
||||||
|
aria-haspopup="listbox"
|
||||||
|
aria-owns="undefined_list"
|
||||||
|
autocomplete="off"
|
||||||
|
class="ant-select-selection-search-input"
|
||||||
|
readonly=""
|
||||||
|
role="combobox"
|
||||||
|
style="opacity:0"
|
||||||
|
type="search"
|
||||||
|
unselectable="on"
|
||||||
|
value=""
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
class="ant-select-selection-item"
|
||||||
|
title="$"
|
||||||
|
>
|
||||||
|
$
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
class="ant-select-arrow"
|
||||||
|
style="user-select:none;-webkit-user-select:none"
|
||||||
|
unselectable="on"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="down"
|
||||||
|
class="anticon anticon-down ant-select-suffix"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="down"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-space-item"
|
||||||
|
style="margin-bottom:8px"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-group-wrapper"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-wrapper ant-input-number-group"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-handler-wrap"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-label="Increase Value"
|
||||||
|
class="ant-input-number-handler ant-input-number-handler-up"
|
||||||
|
role="button"
|
||||||
|
unselectable="on"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="up"
|
||||||
|
class="anticon anticon-up ant-input-number-handler-up-inner"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="up"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M890.5 755.3L537.9 269.2c-12.8-17.6-39-17.6-51.7 0L133.5 755.3A8 8 0 00140 768h75c5.1 0 9.9-2.5 12.9-6.6L512 369.8l284.1 391.6c3 4.1 7.8 6.6 12.9 6.6h75c6.5 0 10.3-7.4 6.5-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-label="Decrease Value"
|
||||||
|
class="ant-input-number-handler ant-input-number-handler-down"
|
||||||
|
role="button"
|
||||||
|
unselectable="on"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="down"
|
||||||
|
class="anticon anticon-down ant-input-number-handler-down-inner"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="down"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-input-wrap"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
aria-valuenow="100"
|
||||||
|
autocomplete="off"
|
||||||
|
class="ant-input-number-input"
|
||||||
|
role="spinbutton"
|
||||||
|
step="1"
|
||||||
|
value="100"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-group-addon"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="setting"
|
||||||
|
class="anticon anticon-setting"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="setting"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M924.8 625.7l-65.5-56c3.1-19 4.7-38.4 4.7-57.8s-1.6-38.8-4.7-57.8l65.5-56a32.03 32.03 0 009.3-35.2l-.9-2.6a443.74 443.74 0 00-79.7-137.9l-1.8-2.1a32.12 32.12 0 00-35.1-9.5l-81.3 28.9c-30-24.6-63.5-44-99.7-57.6l-15.7-85a32.05 32.05 0 00-25.8-25.7l-2.7-.5c-52.1-9.4-106.9-9.4-159 0l-2.7.5a32.05 32.05 0 00-25.8 25.7l-15.8 85.4a351.86 351.86 0 00-99 57.4l-81.9-29.1a32 32 0 00-35.1 9.5l-1.8 2.1a446.02 446.02 0 00-79.7 137.9l-.9 2.6c-4.5 12.5-.8 26.5 9.3 35.2l66.3 56.6c-3.1 18.8-4.6 38-4.6 57.1 0 19.2 1.5 38.4 4.6 57.1L99 625.5a32.03 32.03 0 00-9.3 35.2l.9 2.6c18.1 50.4 44.9 96.9 79.7 137.9l1.8 2.1a32.12 32.12 0 0035.1 9.5l81.9-29.1c29.8 24.5 63.1 43.9 99 57.4l15.8 85.4a32.05 32.05 0 0025.8 25.7l2.7.5a449.4 449.4 0 00159 0l2.7-.5a32.05 32.05 0 0025.8-25.7l15.7-85a350 350 0 0099.7-57.6l81.3 28.9a32 32 0 0035.1-9.5l1.8-2.1c34.8-41.1 61.6-87.5 79.7-137.9l.9-2.6c4.5-12.3.8-26.3-9.3-35zM788.3 465.9c2.5 15.1 3.8 30.6 3.8 46.1s-1.3 31-3.8 46.1l-6.6 40.1 74.7 63.9a370.03 370.03 0 01-42.6 73.6L721 702.8l-31.4 25.8c-23.9 19.6-50.5 35-79.3 45.8l-38.1 14.3-17.9 97a377.5 377.5 0 01-85 0l-17.9-97.2-37.8-14.5c-28.5-10.8-55-26.2-78.7-45.7l-31.4-25.9-93.4 33.2c-17-22.9-31.2-47.6-42.6-73.6l75.5-64.5-6.5-40c-2.4-14.9-3.7-30.3-3.7-45.5 0-15.3 1.2-30.6 3.7-45.5l6.5-40-75.5-64.5c11.3-26.1 25.6-50.7 42.6-73.6l93.4 33.2 31.4-25.9c23.7-19.5 50.2-34.9 78.7-45.7l37.9-14.3 17.9-97.2c28.1-3.2 56.8-3.2 85 0l17.9 97 38.1 14.3c28.7 10.8 55.4 26.2 79.3 45.8l31.4 25.8 92.8-32.9c17 22.9 31.2 47.6 42.6 73.6L781.8 426l6.5 39.9zM512 326c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm79.2 255.2A111.6 111.6 0 01512 614c-29.9 0-58-11.7-79.2-32.8A111.6 111.6 0 01400 502c0-29.9 11.7-58 32.8-79.2C454 401.6 482.1 390 512 390c29.9 0 58 11.6 79.2 32.8A111.6 111.6 0 01624 502c0 29.9-11.7 58-32.8 79.2z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-space-item"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-group-wrapper"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-wrapper ant-input-number-group"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-group-addon"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="ant-cascader-picker"
|
||||||
|
style="width:150px"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="ant-cascader-picker-label"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
autocomplete="off"
|
||||||
|
class="ant-input ant-cascader-input "
|
||||||
|
placeholder="cascader"
|
||||||
|
readonly=""
|
||||||
|
tabindex="-1"
|
||||||
|
type="text"
|
||||||
|
value=""
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
aria-label="down"
|
||||||
|
class="anticon anticon-down ant-cascader-picker-arrow"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="down"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-input-number"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-handler-wrap"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-label="Increase Value"
|
||||||
|
class="ant-input-number-handler ant-input-number-handler-up"
|
||||||
|
role="button"
|
||||||
|
unselectable="on"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="up"
|
||||||
|
class="anticon anticon-up ant-input-number-handler-up-inner"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="up"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M890.5 755.3L537.9 269.2c-12.8-17.6-39-17.6-51.7 0L133.5 755.3A8 8 0 00140 768h75c5.1 0 9.9-2.5 12.9-6.6L512 369.8l284.1 391.6c3 4.1 7.8 6.6 12.9 6.6h75c6.5 0 10.3-7.4 6.5-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
aria-disabled="false"
|
||||||
|
aria-label="Decrease Value"
|
||||||
|
class="ant-input-number-handler ant-input-number-handler-down"
|
||||||
|
role="button"
|
||||||
|
unselectable="on"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-label="down"
|
||||||
|
class="anticon anticon-down ant-input-number-handler-down-inner"
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
data-icon="down"
|
||||||
|
fill="currentColor"
|
||||||
|
focusable="false"
|
||||||
|
height="1em"
|
||||||
|
viewBox="64 64 896 896"
|
||||||
|
width="1em"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-input-number-input-wrap"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
aria-valuenow="100"
|
||||||
|
autocomplete="off"
|
||||||
|
class="ant-input-number-input"
|
||||||
|
role="spinbutton"
|
||||||
|
step="1"
|
||||||
|
value="100"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`renders ./components/input-number/demo/basic.md correctly 1`] = `
|
exports[`renders ./components/input-number/demo/basic.md correctly 1`] = `
|
||||||
<div
|
<div
|
||||||
class="ant-input-number"
|
class="ant-input-number"
|
||||||
|
59
components/input-number/demo/addon.md
Normal file
59
components/input-number/demo/addon.md
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
---
|
||||||
|
order: 2
|
||||||
|
title:
|
||||||
|
zh-CN: 前置/后置标签
|
||||||
|
en-US: Pre / Post tab
|
||||||
|
---
|
||||||
|
|
||||||
|
## zh-CN
|
||||||
|
|
||||||
|
用于配置一些固定组合。
|
||||||
|
|
||||||
|
## en-US
|
||||||
|
|
||||||
|
Using pre & post tabs example.
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
import { InputNumber, Select, Space, Cascader } from 'antd';
|
||||||
|
import { SettingOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
|
const { Option } = Select;
|
||||||
|
|
||||||
|
const selectBefore = (
|
||||||
|
<Select defaultValue="add" className="select-before">
|
||||||
|
<Option value="add">+</Option>
|
||||||
|
<Option value="minus">-</Option>
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
const selectAfter = (
|
||||||
|
<Select defaultValue="USD" className="select-after">
|
||||||
|
<Option value="USD">$</Option>
|
||||||
|
<Option value="EUR">€</Option>
|
||||||
|
<Option value="GBP">£</Option>
|
||||||
|
<Option value="CNY">¥</Option>
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
|
||||||
|
ReactDOM.render(
|
||||||
|
<Space direction="vertical">
|
||||||
|
<InputNumber addonBefore="+" addonAfter="$" defaultValue={100} />
|
||||||
|
<InputNumber addonBefore={selectBefore} addonAfter={selectAfter} defaultValue={100} />
|
||||||
|
<InputNumber addonAfter={<SettingOutlined />} defaultValue={100} />
|
||||||
|
<InputNumber
|
||||||
|
addonBefore={<Cascader placeholder="cascader" style={{ width: 150 }} />}
|
||||||
|
defaultValue={100}
|
||||||
|
/>
|
||||||
|
</Space>,
|
||||||
|
mountNode,
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
.select-before {
|
||||||
|
width: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-after {
|
||||||
|
width: 50px;
|
||||||
|
}
|
||||||
|
```
|
@ -15,6 +15,8 @@ When a numeric value needs to be provided.
|
|||||||
|
|
||||||
| Property | Description | Type | Default | Version |
|
| Property | Description | Type | Default | Version |
|
||||||
| --- | --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- |
|
||||||
|
| addonAfter | The label text displayed after (on the right side of) the input field | ReactNode | - | |
|
||||||
|
| addonBefore | The label text displayed before (on the left side of) the input field | ReactNode | - | |
|
||||||
| autoFocus | If get focus when component mounted | boolean | false | - |
|
| autoFocus | If get focus when component mounted | boolean | false | - |
|
||||||
| bordered | Whether has border style | boolean | true | 4.12.0 |
|
| bordered | Whether has border style | boolean | true | 4.12.0 |
|
||||||
| controls | Whether to show `+-` controls | boolean | true | 4.17.0 |
|
| controls | Whether to show `+-` controls | boolean | true | 4.17.0 |
|
||||||
|
@ -6,12 +6,15 @@ import DownOutlined from '@ant-design/icons/DownOutlined';
|
|||||||
|
|
||||||
import { ConfigContext } from '../config-provider';
|
import { ConfigContext } from '../config-provider';
|
||||||
import SizeContext, { SizeType } from '../config-provider/SizeContext';
|
import SizeContext, { SizeType } from '../config-provider/SizeContext';
|
||||||
|
import { cloneElement } from '../_util/reactNode';
|
||||||
|
|
||||||
type ValueType = string | number;
|
type ValueType = string | number;
|
||||||
|
|
||||||
export interface InputNumberProps<T extends ValueType = ValueType>
|
export interface InputNumberProps<T extends ValueType = ValueType>
|
||||||
extends Omit<RcInputNumberProps<T>, 'size'> {
|
extends Omit<RcInputNumberProps<T>, 'size'> {
|
||||||
prefixCls?: string;
|
prefixCls?: string;
|
||||||
|
addonBefore?: React.ReactNode;
|
||||||
|
addonAfter?: React.ReactNode;
|
||||||
size?: SizeType;
|
size?: SizeType;
|
||||||
bordered?: boolean;
|
bordered?: boolean;
|
||||||
}
|
}
|
||||||
@ -24,6 +27,8 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>((props,
|
|||||||
className,
|
className,
|
||||||
size: customizeSize,
|
size: customizeSize,
|
||||||
prefixCls: customizePrefixCls,
|
prefixCls: customizePrefixCls,
|
||||||
|
addonBefore,
|
||||||
|
addonAfter,
|
||||||
bordered = true,
|
bordered = true,
|
||||||
readOnly,
|
readOnly,
|
||||||
...others
|
...others
|
||||||
@ -45,7 +50,7 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>((props,
|
|||||||
className,
|
className,
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
const element = (
|
||||||
<RcInputNumber
|
<RcInputNumber
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={inputNumberClass}
|
className={inputNumberClass}
|
||||||
@ -56,6 +61,40 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>((props,
|
|||||||
{...others}
|
{...others}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (addonBefore != null || addonAfter != null) {
|
||||||
|
const wrapperClassName = `${prefixCls}-group`;
|
||||||
|
const addonClassName = `${wrapperClassName}-addon`;
|
||||||
|
const addonBeforeNode = addonBefore ? (
|
||||||
|
<div className={addonClassName}>{addonBefore}</div>
|
||||||
|
) : null;
|
||||||
|
const addonAfterNode = addonAfter ? <div className={addonClassName}>{addonAfter}</div> : null;
|
||||||
|
|
||||||
|
const mergedWrapperClassName = classNames(`${prefixCls}-wrapper`, wrapperClassName, {
|
||||||
|
[`${wrapperClassName}-rtl`]: direction === 'rtl',
|
||||||
|
});
|
||||||
|
|
||||||
|
const mergedGroupClassName = classNames(
|
||||||
|
`${prefixCls}-group-wrapper`,
|
||||||
|
{
|
||||||
|
[`${prefixCls}-group-wrapper-sm`]: size === 'small',
|
||||||
|
[`${prefixCls}-group-wrapper-lg`]: size === 'large',
|
||||||
|
[`${prefixCls}-group-wrapper-rtl`]: direction === 'rtl',
|
||||||
|
},
|
||||||
|
className,
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<div className={mergedGroupClassName} style={props.style}>
|
||||||
|
<div className={mergedWrapperClassName}>
|
||||||
|
{addonBeforeNode}
|
||||||
|
{cloneElement(element, { style: null })}
|
||||||
|
{addonAfterNode}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return element;
|
||||||
});
|
});
|
||||||
|
|
||||||
export default InputNumber as (<T extends ValueType = ValueType>(
|
export default InputNumber as (<T extends ValueType = ValueType>(
|
||||||
|
@ -18,6 +18,8 @@ cover: https://gw.alipayobjects.com/zos/alicdn/XOS8qZ0kU/InputNumber.svg
|
|||||||
|
|
||||||
| 成员 | 说明 | 类型 | 默认值 | 版本 |
|
| 成员 | 说明 | 类型 | 默认值 | 版本 |
|
||||||
| --- | --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- |
|
||||||
|
| addonAfter | 带标签的 input,设置后置标签 | ReactNode | - | 4.17.0 |
|
||||||
|
| addonBefore | 带标签的 input,设置前置标签 | ReactNode | - | 4.17.0 |
|
||||||
| autoFocus | 自动获取焦点 | boolean | false | - |
|
| autoFocus | 自动获取焦点 | boolean | false | - |
|
||||||
| bordered | 是否有边框 | boolean | true | 4.12.0 |
|
| bordered | 是否有边框 | boolean | true | 4.12.0 |
|
||||||
| controls | 是否显示增减按钮 | boolean | true | 4.17.0 |
|
| controls | 是否显示增减按钮 | boolean | true | 4.17.0 |
|
||||||
|
@ -9,6 +9,17 @@
|
|||||||
.reset-component();
|
.reset-component();
|
||||||
.input();
|
.input();
|
||||||
|
|
||||||
|
//== Style for input-group: input with label, with button or dropdown...
|
||||||
|
&-group {
|
||||||
|
.reset-component();
|
||||||
|
.input-group(~'@{input-number-prefix-cls}');
|
||||||
|
&-wrapper {
|
||||||
|
display: inline-block;
|
||||||
|
text-align: start;
|
||||||
|
vertical-align: top; // https://github.com/ant-design/ant-design/issues/6403
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 90px;
|
width: 90px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user