Latest updates from IceHrmPro
This commit is contained in:
70
web/node_modules/rc-input-number/HISTORY.md
generated
vendored
Normal file
70
web/node_modules/rc-input-number/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
# History
|
||||
----
|
||||
|
||||
## 4.5.0
|
||||
|
||||
- Fix React lifecycle warning.
|
||||
- Add `onPressEnter`.
|
||||
|
||||
## 4.4.0
|
||||
|
||||
- `onChange` will return `null` instead `undefined` when it is empty.
|
||||
|
||||
## 4.0.0
|
||||
|
||||
- Drop React Native support, please use https://github.com/react-component/m-input-number instead.
|
||||
|
||||
## 3.5.0
|
||||
|
||||
- Added prop `precision`.
|
||||
|
||||
## 3.4.0
|
||||
|
||||
- Added prop `parser`.
|
||||
|
||||
## 3.3.0
|
||||
|
||||
- Added prop `formatter`.
|
||||
- Support changing radio using ctrl and shift.
|
||||
|
||||
## 3.2.0
|
||||
|
||||
- Fixed touch events.
|
||||
|
||||
## 3.1.0
|
||||
|
||||
- Added props `upHanlder` and `downHanlder`.
|
||||
|
||||
## 3.0.4
|
||||
|
||||
- Fixed long press not working in Android. #42
|
||||
|
||||
## 3.0.3
|
||||
|
||||
- Fixed https://github.com/ant-design/ant-design/issues/4757
|
||||
|
||||
## 3.0.2
|
||||
|
||||
- Fixed `onKeyUp`.
|
||||
|
||||
## 3.0.1
|
||||
|
||||
- Fixed invalid input like '11x'.
|
||||
|
||||
## 3.0.0
|
||||
|
||||
- Trigger onChange when user input
|
||||
- support `keyboardType` prop for fixing crash on Android on textInput blur
|
||||
|
||||
## 2.8.0 / 2016-11-29
|
||||
|
||||
- support tap state by rc-touchable
|
||||
|
||||
## 2.7.0 / 2016-09-03
|
||||
|
||||
- support long press auto step
|
||||
- support `readOnly`
|
||||
|
||||
## 2.6.0 / 2016-07-20
|
||||
|
||||
- support react-native
|
||||
9
web/node_modules/rc-input-number/LICENSE.md
generated
vendored
Normal file
9
web/node_modules/rc-input-number/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-present yiminghe
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
258
web/node_modules/rc-input-number/README.md
generated
vendored
Normal file
258
web/node_modules/rc-input-number/README.md
generated
vendored
Normal file
@@ -0,0 +1,258 @@
|
||||
# rc-input-number
|
||||
---
|
||||
|
||||
input number ui component for react
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[![build status][travis-image]][travis-url]
|
||||
[![Test coverage][coveralls-image]][coveralls-url]
|
||||
[![david-dm deps][david-dm-image]][david-dm-url]
|
||||
[](https://david-dm.org/react-component/input-number?type=dev)
|
||||
[![node version][node-image]][node-url]
|
||||
[![npm download][download-image]][download-url]
|
||||
|
||||
[npm-image]: http://img.shields.io/npm/v/rc-input-number.svg?style=flat-square
|
||||
[npm-url]: http://npmjs.org/package/rc-input-number
|
||||
[travis-image]: https://img.shields.io/travis/react-component/input-number.svg?style=flat-square
|
||||
[travis-url]: https://travis-ci.org/react-component/input-number
|
||||
[coveralls-image]: https://img.shields.io/coveralls/react-component/input-number.svg?style=flat-square
|
||||
[coveralls-url]: https://coveralls.io/r/react-component/input-number?branch=master
|
||||
[david-dm-image]: https://david-dm.org/react-component/input-number/status.svg
|
||||
[david-dm-url]: https://david-dm.org/react-component/input-number
|
||||
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square
|
||||
[node-url]: http://nodejs.org/download/
|
||||
[download-image]: https://img.shields.io/npm/dm/rc-input-number.svg?style=flat-square
|
||||
[download-url]: https://npmjs.org/package/rc-input-number
|
||||
|
||||
## Screenshots
|
||||
|
||||
<img src="http://gtms01.alicdn.com/tps/i1/TB18CIlIpXXXXaxXFXXDa5hRXXX-268-124.png" width="288"/>
|
||||
|
||||
## install
|
||||
|
||||
[](https://npmjs.org/package/rc-input-number)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var InputNumber = require('rc-input-number');
|
||||
var React = require('react');
|
||||
var ReactDOM = require('react-dom');
|
||||
ReactDOM.render(<InputNumber defaultValue={19}/>, container);
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
```
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
http://127.0.0.1:8000/examples/
|
||||
|
||||
online example: http://react-component.github.io/input-number/examples/
|
||||
|
||||
## API
|
||||
|
||||
### props
|
||||
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 100px;">name</th>
|
||||
<th style="width: 50px;">type</th>
|
||||
<th style="width: 50px;">default</th>
|
||||
<th>description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>prefixCls</td>
|
||||
<td>string</td>
|
||||
<td>rc-input-number</td>
|
||||
<td>Specifies the class prefix</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>min</td>
|
||||
<td>Number</td>
|
||||
<td></td>
|
||||
<td>Specifies the minimum value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>onClick</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>placeholder</td>
|
||||
<td>string</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>max</td>
|
||||
<td>Number</td>
|
||||
<td></td>
|
||||
<td>Specifies the maximum value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>step</td>
|
||||
<td>Number or String</td>
|
||||
<td>1</td>
|
||||
<td>Specifies the legal number intervals</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>precision</td>
|
||||
<td>Number</td>
|
||||
<td></td>
|
||||
<td>Specifies the precision length of value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>disabled</td>
|
||||
<td>Boolean</td>
|
||||
<td>false</td>
|
||||
<td>Specifies that an InputNumber should be disabled</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>focusOnUpDown</td>
|
||||
<td>Boolean</td>
|
||||
<td>true</td>
|
||||
<td>whether focus input when click up or down button</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>required</td>
|
||||
<td>Boolean</td>
|
||||
<td>false</td>
|
||||
<td>Specifies that an InputNumber is required</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>autoFocus</td>
|
||||
<td>Boolean</td>
|
||||
<td>false</td>
|
||||
<td>Specifies that an InputNumber should automatically get focus when the page loads</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>readOnly</td>
|
||||
<td>Boolean</td>
|
||||
<td>false</td>
|
||||
<td>Specifies that an InputNumber is read only </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>name</td>
|
||||
<td>String</td>
|
||||
<td></td>
|
||||
<td>Specifies the name of an InputNumber</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>id</td>
|
||||
<td>String</td>
|
||||
<td></td>
|
||||
<td>Specifies the id of an InputNumber</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>value</td>
|
||||
<td>Number</td>
|
||||
<td></td>
|
||||
<td>Specifies the value of an InputNumber</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>defaultValue</td>
|
||||
<td>Number</td>
|
||||
<td></td>
|
||||
<td>Specifies the defaultValue of an InputNumber</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>onChange</td>
|
||||
<td>Function</td>
|
||||
<td></td>
|
||||
<td>Called when value of an InputNumber changed</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>onPressEnter</td>
|
||||
<td>Function</td>
|
||||
<td></td>
|
||||
<td>The callback function that is triggered when Enter key is pressed.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>onFocus</td>
|
||||
<td>Function</td>
|
||||
<td></td>
|
||||
<td>Called when an element gets focus</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>style</td>
|
||||
<td>Object</td>
|
||||
<td></td>
|
||||
<td>root style. such as {width:100}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>upHandler</td>
|
||||
<td>React.Node</td>
|
||||
<td></td>
|
||||
<td>custom the up step element</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>downHandler</td>
|
||||
<td>React.Node</td>
|
||||
<td></td>
|
||||
<td>custom the down step element</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>formatter</td>
|
||||
<td>(value: number|string): displayValue: string</td>
|
||||
<td></td>
|
||||
<td>Specifies the format of the value presented</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>parser</td>
|
||||
<td>(displayValue: string) => value: number</td>
|
||||
<td>`input => input.replace(/[^\w\.-]*/g, '')`</td>
|
||||
<td>Specifies the value extracted from formatter</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>pattern</td>
|
||||
<td>string</td>
|
||||
<td></td>
|
||||
<td>Specifies a regex pattern to be added to the input number element - useful for forcing iOS to open the number pad instead of the normal keyboard (supply a regex of "\d*" to do this) or form validation</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>decimalSeparator</td>
|
||||
<td>string</td>
|
||||
<td></td>
|
||||
<td>Specifies the decimal separator</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>inputMode</td>
|
||||
<td>string</td>
|
||||
<td></td>
|
||||
<td>Specifies the inputmode of input</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Keyboard Navigation
|
||||
* When you hit the <kbd>⬆</kbd> or <kbd>⬇</kbd> key, the input value will be increased or decreased by `step`
|
||||
* With the <kbd>Shift</kbd> key (<kbd>Shift+⬆</kbd>, <kbd>Shift+⬇</kbd>), the input value will be changed by `10 * step`
|
||||
* With the <kbd>Ctrl</kbd> or <kbd>⌘</kbd> key (<kbd>Ctrl+⬆</kbd> or <kbd>⌘+⬆</kbd> or <kbd>Ctrl+⬇</kbd> or <kbd>⌘+⬇</kbd> ), the input value will be changed by `0.1 * step`
|
||||
|
||||
## Test Case
|
||||
|
||||
```
|
||||
npm test
|
||||
npm run chrome-test
|
||||
```
|
||||
|
||||
## Coverage
|
||||
|
||||
```
|
||||
npm run coverage
|
||||
```
|
||||
|
||||
open coverage/ dir
|
||||
|
||||
## License
|
||||
|
||||
rc-input-number is released under the MIT license.
|
||||
110
web/node_modules/rc-input-number/assets/index.css
generated
vendored
Normal file
110
web/node_modules/rc-input-number/assets/index.css
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
.rc-input-number {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 26px;
|
||||
font-size: 12px;
|
||||
height: 26px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
border: 1px solid #D9D9D9;
|
||||
border-radius: 4px;
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-focused {
|
||||
border-color: #1890ff;
|
||||
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
||||
}
|
||||
.rc-input-number-handler {
|
||||
text-align: center;
|
||||
line-height: 12px;
|
||||
height: 12px;
|
||||
overflow: hidden;
|
||||
display: block;
|
||||
-ms-touch-action: none;
|
||||
touch-action: none;
|
||||
}
|
||||
.rc-input-number-handler-active {
|
||||
background: #ddd;
|
||||
}
|
||||
.rc-input-number-handler-up-inner,
|
||||
.rc-input-number-handler-down-inner {
|
||||
color: #666666;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
.rc-input-number:hover {
|
||||
border-color: #1890ff;
|
||||
}
|
||||
.rc-input-number:hover .rc-input-number-handler-up,
|
||||
.rc-input-number:hover .rc-input-number-handler-wrap {
|
||||
border-color: #1890ff;
|
||||
}
|
||||
.rc-input-number-disabled:hover {
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
.rc-input-number-disabled:hover .rc-input-number-handler-up,
|
||||
.rc-input-number-disabled:hover .rc-input-number-handler-wrap {
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
.rc-input-number-input-wrap {
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
}
|
||||
.rc-input-number-input {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
outline: 0;
|
||||
-moz-appearance: textfield;
|
||||
line-height: 26px;
|
||||
height: 100%;
|
||||
transition: all 0.3s ease;
|
||||
color: #666666;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
padding: 0;
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-handler-wrap {
|
||||
float: right;
|
||||
border-left: 1px solid #D9D9D9;
|
||||
width: 20px;
|
||||
height: 100%;
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-handler-up {
|
||||
border-bottom: 1px solid #D9D9D9;
|
||||
padding-top: 1px;
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-handler-up-inner:after {
|
||||
content: '+';
|
||||
}
|
||||
.rc-input-number-handler-down {
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-handler-down-inner:after {
|
||||
content: '-';
|
||||
}
|
||||
.rc-input-number-handler-down-disabled,
|
||||
.rc-input-number-handler-up-disabled {
|
||||
opacity: 0.72;
|
||||
}
|
||||
.rc-input-number-handler-down-disabled:hover,
|
||||
.rc-input-number-handler-up-disabled:hover {
|
||||
color: #999;
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
.rc-input-number-disabled .rc-input-number-input {
|
||||
opacity: 0.72;
|
||||
cursor: not-allowed;
|
||||
background-color: #f3f3f3;
|
||||
}
|
||||
.rc-input-number-disabled .rc-input-number-handler {
|
||||
opacity: 0.72;
|
||||
}
|
||||
.rc-input-number-disabled .rc-input-number-handler:hover {
|
||||
color: #999;
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
127
web/node_modules/rc-input-number/assets/index.less
generated
vendored
Normal file
127
web/node_modules/rc-input-number/assets/index.less
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
@inputNumberPrefixCls: rc-input-number;
|
||||
|
||||
.@{inputNumberPrefixCls} {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 26px;
|
||||
font-size: 12px;
|
||||
height: 26px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
border: 1px solid #D9D9D9;
|
||||
border-radius: 4px;
|
||||
transition: all .3s;
|
||||
|
||||
&-focused {
|
||||
border-color: #1890ff;
|
||||
box-shadow: 0 0 0 2px rgba(24,144,255,.2);
|
||||
}
|
||||
|
||||
&-handler {
|
||||
text-align: center;
|
||||
line-height: 12px;
|
||||
height: 12px;
|
||||
overflow: hidden;
|
||||
display:block;
|
||||
touch-action: none;
|
||||
|
||||
&-active {
|
||||
background: #ddd;
|
||||
}
|
||||
}
|
||||
|
||||
&-handler-up-inner, &-handler-down-inner {
|
||||
color: #666666;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: #1890ff;
|
||||
|
||||
.@{inputNumberPrefixCls}-handler-up, .@{inputNumberPrefixCls}-handler-wrap {
|
||||
border-color: #1890ff;
|
||||
}
|
||||
}
|
||||
|
||||
&-disabled:hover {
|
||||
border-color: #d9d9d9;
|
||||
|
||||
.@{inputNumberPrefixCls}-handler-up, .@{inputNumberPrefixCls}-handler-wrap {
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
}
|
||||
|
||||
&-input-wrap {
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
&-input {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
outline: 0;
|
||||
-moz-appearance: textfield;
|
||||
line-height: 26px;
|
||||
height: 100%;
|
||||
transition: all 0.3s ease;
|
||||
color: #666666;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
padding: 0;
|
||||
transition: all .3s;
|
||||
}
|
||||
|
||||
&-handler-wrap {
|
||||
float: right;
|
||||
border-left: 1px solid #D9D9D9;
|
||||
width: 20px;
|
||||
height: 100%;
|
||||
transition: all .3s;
|
||||
}
|
||||
|
||||
&-handler-up {
|
||||
border-bottom: 1px solid #D9D9D9;
|
||||
padding-top: 1px;
|
||||
transition: all .3s;
|
||||
|
||||
&-inner {
|
||||
&:after {
|
||||
content: '+';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-handler-down {
|
||||
transition: all .3s;
|
||||
|
||||
&-inner {
|
||||
&:after {
|
||||
content: '-';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.handler-disabled() {
|
||||
opacity: 0.72;
|
||||
&:hover {
|
||||
color: #999;
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
}
|
||||
|
||||
&-handler-down-disabled, &-handler-up-disabled {
|
||||
.handler-disabled();
|
||||
}
|
||||
|
||||
&-disabled {
|
||||
.@{inputNumberPrefixCls}-input {
|
||||
opacity: 0.72;
|
||||
cursor: not-allowed;
|
||||
background-color: #f3f3f3;
|
||||
}
|
||||
.@{inputNumberPrefixCls}-handler {
|
||||
.handler-disabled();
|
||||
}
|
||||
}
|
||||
}
|
||||
112
web/node_modules/rc-input-number/dist/rc-input-number.css
generated
vendored
Normal file
112
web/node_modules/rc-input-number/dist/rc-input-number.css
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
.rc-input-number {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 26px;
|
||||
font-size: 12px;
|
||||
height: 26px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
border: 1px solid #D9D9D9;
|
||||
border-radius: 4px;
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-focused {
|
||||
border-color: #1890ff;
|
||||
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
||||
}
|
||||
.rc-input-number-handler {
|
||||
text-align: center;
|
||||
line-height: 12px;
|
||||
height: 12px;
|
||||
overflow: hidden;
|
||||
display: block;
|
||||
-ms-touch-action: none;
|
||||
touch-action: none;
|
||||
}
|
||||
.rc-input-number-handler-active {
|
||||
background: #ddd;
|
||||
}
|
||||
.rc-input-number-handler-up-inner,
|
||||
.rc-input-number-handler-down-inner {
|
||||
color: #666666;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
.rc-input-number:hover {
|
||||
border-color: #1890ff;
|
||||
}
|
||||
.rc-input-number:hover .rc-input-number-handler-up,
|
||||
.rc-input-number:hover .rc-input-number-handler-wrap {
|
||||
border-color: #1890ff;
|
||||
}
|
||||
.rc-input-number-disabled:hover {
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
.rc-input-number-disabled:hover .rc-input-number-handler-up,
|
||||
.rc-input-number-disabled:hover .rc-input-number-handler-wrap {
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
.rc-input-number-input-wrap {
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
}
|
||||
.rc-input-number-input {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
outline: 0;
|
||||
-moz-appearance: textfield;
|
||||
line-height: 26px;
|
||||
height: 100%;
|
||||
transition: all 0.3s ease;
|
||||
color: #666666;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
padding: 0;
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-handler-wrap {
|
||||
float: right;
|
||||
border-left: 1px solid #D9D9D9;
|
||||
width: 20px;
|
||||
height: 100%;
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-handler-up {
|
||||
border-bottom: 1px solid #D9D9D9;
|
||||
padding-top: 1px;
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-handler-up-inner:after {
|
||||
content: '+';
|
||||
}
|
||||
.rc-input-number-handler-down {
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-handler-down-inner:after {
|
||||
content: '-';
|
||||
}
|
||||
.rc-input-number-handler-down-disabled,
|
||||
.rc-input-number-handler-up-disabled {
|
||||
opacity: 0.72;
|
||||
}
|
||||
.rc-input-number-handler-down-disabled:hover,
|
||||
.rc-input-number-handler-up-disabled:hover {
|
||||
color: #999;
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
.rc-input-number-disabled .rc-input-number-input {
|
||||
opacity: 0.72;
|
||||
cursor: not-allowed;
|
||||
background-color: #f3f3f3;
|
||||
}
|
||||
.rc-input-number-disabled .rc-input-number-handler {
|
||||
opacity: 0.72;
|
||||
}
|
||||
.rc-input-number-disabled .rc-input-number-handler:hover {
|
||||
color: #999;
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=rc-input-number.css.map*/
|
||||
1
web/node_modules/rc-input-number/dist/rc-input-number.css.map
generated
vendored
Normal file
1
web/node_modules/rc-input-number/dist/rc-input-number.css.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["webpack:///./assets/index.less"],"names":[],"mappings":"AAEA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CADD;AAGC;EACE;EACA;CADH;AAIC;EACE;EACA;EACA;EACA;EACA;EACA;MAAA;CAFH;AAIG;EACE;CAFL;AAMC;;EACE;EACA;GAAA;OAAA;EACA;CAHH;AAMC;EACE;CAJH;AAGC;;EAII;CAHL;AAOC;EACE;CALH;AAIC;;EAII;CAJL;AAQC;EACE;EACA;CANH;AASC;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAPH;AAUC;EACE;EACA;EACA;EACA;EACA;CARH;AAWC;EACE;EACA;EACA;CATH;AAYK;EACE;CAVP;AAeC;EACE;CAbH;AAgBK;EACE;CAdP;AA2BC;;EAPE;CAhBH;AAiBG;;EACE;EACA;CAdL;AAsBC;EAEI;EACA;EACA;CArBL;AAiBC;EAXE;CAHH;AAIG;EACE;EACA;CAFL","file":"rc-input-number.css","sourcesContent":["@inputNumberPrefixCls: rc-input-number;\n\n.@{inputNumberPrefixCls} {\n margin: 0;\n padding: 0;\n line-height: 26px;\n font-size: 12px;\n height: 26px;\n display: inline-block;\n vertical-align: middle;\n border: 1px solid #D9D9D9;\n border-radius: 4px;\n transition: all .3s;\n\n &-focused {\n border-color: #1890ff;\n box-shadow: 0 0 0 2px rgba(24,144,255,.2);\n }\n\n &-handler {\n text-align: center;\n line-height: 12px;\n height: 12px;\n overflow: hidden;\n display:block;\n touch-action: none;\n\n &-active {\n background: #ddd;\n }\n }\n\n &-handler-up-inner, &-handler-down-inner {\n color: #666666;\n user-select: none;\n -webkit-user-select: none;\n }\n\n &:hover {\n border-color: #1890ff;\n\n .@{inputNumberPrefixCls}-handler-up, .@{inputNumberPrefixCls}-handler-wrap {\n border-color: #1890ff;\n }\n }\n\n &-disabled:hover {\n border-color: #d9d9d9;\n\n .@{inputNumberPrefixCls}-handler-up, .@{inputNumberPrefixCls}-handler-wrap {\n border-color: #d9d9d9;\n }\n }\n\n &-input-wrap {\n overflow: hidden;\n height: 100%;\n }\n\n &-input {\n width: 100%;\n text-align: center;\n outline: 0;\n -moz-appearance: textfield;\n line-height: 26px;\n height: 100%;\n transition: all 0.3s ease;\n color: #666666;\n border: 0;\n border-radius: 4px;\n padding: 0;\n transition: all .3s;\n }\n\n &-handler-wrap {\n float: right;\n border-left: 1px solid #D9D9D9;\n width: 20px;\n height: 100%;\n transition: all .3s;\n }\n\n &-handler-up {\n border-bottom: 1px solid #D9D9D9;\n padding-top: 1px;\n transition: all .3s;\n\n &-inner {\n &:after {\n content: '+';\n }\n }\n }\n\n &-handler-down {\n transition: all .3s;\n\n &-inner {\n &:after {\n content: '-';\n }\n }\n }\n\n .handler-disabled() {\n opacity: 0.72;\n &:hover {\n color: #999;\n border-color: #d9d9d9;\n }\n }\n\n &-handler-down-disabled, &-handler-up-disabled {\n .handler-disabled();\n }\n\n &-disabled {\n .@{inputNumberPrefixCls}-input {\n opacity: 0.72;\n cursor: not-allowed;\n background-color: #f3f3f3;\n }\n .@{inputNumberPrefixCls}-handler {\n .handler-disabled();\n }\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./assets/index.less"],"sourceRoot":""}
|
||||
5007
web/node_modules/rc-input-number/dist/rc-input-number.js
generated
vendored
Normal file
5007
web/node_modules/rc-input-number/dist/rc-input-number.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
web/node_modules/rc-input-number/dist/rc-input-number.js.map
generated
vendored
Normal file
1
web/node_modules/rc-input-number/dist/rc-input-number.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
112
web/node_modules/rc-input-number/dist/rc-input-number.min.css
generated
vendored
Normal file
112
web/node_modules/rc-input-number/dist/rc-input-number.min.css
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
.rc-input-number {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 26px;
|
||||
font-size: 12px;
|
||||
height: 26px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
border: 1px solid #D9D9D9;
|
||||
border-radius: 4px;
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-focused {
|
||||
border-color: #1890ff;
|
||||
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
||||
}
|
||||
.rc-input-number-handler {
|
||||
text-align: center;
|
||||
line-height: 12px;
|
||||
height: 12px;
|
||||
overflow: hidden;
|
||||
display: block;
|
||||
-ms-touch-action: none;
|
||||
touch-action: none;
|
||||
}
|
||||
.rc-input-number-handler-active {
|
||||
background: #ddd;
|
||||
}
|
||||
.rc-input-number-handler-up-inner,
|
||||
.rc-input-number-handler-down-inner {
|
||||
color: #666666;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
.rc-input-number:hover {
|
||||
border-color: #1890ff;
|
||||
}
|
||||
.rc-input-number:hover .rc-input-number-handler-up,
|
||||
.rc-input-number:hover .rc-input-number-handler-wrap {
|
||||
border-color: #1890ff;
|
||||
}
|
||||
.rc-input-number-disabled:hover {
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
.rc-input-number-disabled:hover .rc-input-number-handler-up,
|
||||
.rc-input-number-disabled:hover .rc-input-number-handler-wrap {
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
.rc-input-number-input-wrap {
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
}
|
||||
.rc-input-number-input {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
outline: 0;
|
||||
-moz-appearance: textfield;
|
||||
line-height: 26px;
|
||||
height: 100%;
|
||||
transition: all 0.3s ease;
|
||||
color: #666666;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
padding: 0;
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-handler-wrap {
|
||||
float: right;
|
||||
border-left: 1px solid #D9D9D9;
|
||||
width: 20px;
|
||||
height: 100%;
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-handler-up {
|
||||
border-bottom: 1px solid #D9D9D9;
|
||||
padding-top: 1px;
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-handler-up-inner:after {
|
||||
content: '+';
|
||||
}
|
||||
.rc-input-number-handler-down {
|
||||
transition: all .3s;
|
||||
}
|
||||
.rc-input-number-handler-down-inner:after {
|
||||
content: '-';
|
||||
}
|
||||
.rc-input-number-handler-down-disabled,
|
||||
.rc-input-number-handler-up-disabled {
|
||||
opacity: 0.72;
|
||||
}
|
||||
.rc-input-number-handler-down-disabled:hover,
|
||||
.rc-input-number-handler-up-disabled:hover {
|
||||
color: #999;
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
.rc-input-number-disabled .rc-input-number-input {
|
||||
opacity: 0.72;
|
||||
cursor: not-allowed;
|
||||
background-color: #f3f3f3;
|
||||
}
|
||||
.rc-input-number-disabled .rc-input-number-handler {
|
||||
opacity: 0.72;
|
||||
}
|
||||
.rc-input-number-disabled .rc-input-number-handler:hover {
|
||||
color: #999;
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=rc-input-number.min.css.map*/
|
||||
1
web/node_modules/rc-input-number/dist/rc-input-number.min.css.map
generated
vendored
Normal file
1
web/node_modules/rc-input-number/dist/rc-input-number.min.css.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["webpack:///./assets/index.less"],"names":[],"mappings":"AAEA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CADD;AAGC;EACE;EACA;CADH;AAIC;EACE;EACA;EACA;EACA;EACA;EACA;MAAA;CAFH;AAIG;EACE;CAFL;AAMC;;EACE;EACA;GAAA;OAAA;EACA;CAHH;AAMC;EACE;CAJH;AAGC;;EAII;CAHL;AAOC;EACE;CALH;AAIC;;EAII;CAJL;AAQC;EACE;EACA;CANH;AASC;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAPH;AAUC;EACE;EACA;EACA;EACA;EACA;CARH;AAWC;EACE;EACA;EACA;CATH;AAYK;EACE;CAVP;AAeC;EACE;CAbH;AAgBK;EACE;CAdP;AA2BC;;EAPE;CAhBH;AAiBG;;EACE;EACA;CAdL;AAsBC;EAEI;EACA;EACA;CArBL;AAiBC;EAXE;CAHH;AAIG;EACE;EACA;CAFL","file":"rc-input-number.min.css","sourcesContent":["@inputNumberPrefixCls: rc-input-number;\n\n.@{inputNumberPrefixCls} {\n margin: 0;\n padding: 0;\n line-height: 26px;\n font-size: 12px;\n height: 26px;\n display: inline-block;\n vertical-align: middle;\n border: 1px solid #D9D9D9;\n border-radius: 4px;\n transition: all .3s;\n\n &-focused {\n border-color: #1890ff;\n box-shadow: 0 0 0 2px rgba(24,144,255,.2);\n }\n\n &-handler {\n text-align: center;\n line-height: 12px;\n height: 12px;\n overflow: hidden;\n display:block;\n touch-action: none;\n\n &-active {\n background: #ddd;\n }\n }\n\n &-handler-up-inner, &-handler-down-inner {\n color: #666666;\n user-select: none;\n -webkit-user-select: none;\n }\n\n &:hover {\n border-color: #1890ff;\n\n .@{inputNumberPrefixCls}-handler-up, .@{inputNumberPrefixCls}-handler-wrap {\n border-color: #1890ff;\n }\n }\n\n &-disabled:hover {\n border-color: #d9d9d9;\n\n .@{inputNumberPrefixCls}-handler-up, .@{inputNumberPrefixCls}-handler-wrap {\n border-color: #d9d9d9;\n }\n }\n\n &-input-wrap {\n overflow: hidden;\n height: 100%;\n }\n\n &-input {\n width: 100%;\n text-align: center;\n outline: 0;\n -moz-appearance: textfield;\n line-height: 26px;\n height: 100%;\n transition: all 0.3s ease;\n color: #666666;\n border: 0;\n border-radius: 4px;\n padding: 0;\n transition: all .3s;\n }\n\n &-handler-wrap {\n float: right;\n border-left: 1px solid #D9D9D9;\n width: 20px;\n height: 100%;\n transition: all .3s;\n }\n\n &-handler-up {\n border-bottom: 1px solid #D9D9D9;\n padding-top: 1px;\n transition: all .3s;\n\n &-inner {\n &:after {\n content: '+';\n }\n }\n }\n\n &-handler-down {\n transition: all .3s;\n\n &-inner {\n &:after {\n content: '-';\n }\n }\n }\n\n .handler-disabled() {\n opacity: 0.72;\n &:hover {\n color: #999;\n border-color: #d9d9d9;\n }\n }\n\n &-handler-down-disabled, &-handler-up-disabled {\n .handler-disabled();\n }\n\n &-disabled {\n .@{inputNumberPrefixCls}-input {\n opacity: 0.72;\n cursor: not-allowed;\n background-color: #f3f3f3;\n }\n .@{inputNumberPrefixCls}-handler {\n .handler-disabled();\n }\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./assets/index.less"],"sourceRoot":""}
|
||||
1
web/node_modules/rc-input-number/dist/rc-input-number.min.js
generated
vendored
Normal file
1
web/node_modules/rc-input-number/dist/rc-input-number.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
47
web/node_modules/rc-input-number/es/InputHandler.js
generated
vendored
Normal file
47
web/node_modules/rc-input-number/es/InputHandler.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
||||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
||||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
||||
import _inherits from 'babel-runtime/helpers/inherits';
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Touchable from 'rmc-feedback';
|
||||
|
||||
var InputHandler = function (_Component) {
|
||||
_inherits(InputHandler, _Component);
|
||||
|
||||
function InputHandler() {
|
||||
_classCallCheck(this, InputHandler);
|
||||
|
||||
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
|
||||
}
|
||||
|
||||
InputHandler.prototype.render = function render() {
|
||||
var _props = this.props,
|
||||
prefixCls = _props.prefixCls,
|
||||
disabled = _props.disabled,
|
||||
otherProps = _objectWithoutProperties(_props, ['prefixCls', 'disabled']);
|
||||
|
||||
return React.createElement(
|
||||
Touchable,
|
||||
{
|
||||
disabled: disabled,
|
||||
activeClassName: prefixCls + '-handler-active'
|
||||
},
|
||||
React.createElement('span', otherProps)
|
||||
);
|
||||
};
|
||||
|
||||
return InputHandler;
|
||||
}(Component);
|
||||
|
||||
InputHandler.propTypes = {
|
||||
prefixCls: PropTypes.string,
|
||||
disabled: PropTypes.bool,
|
||||
onTouchStart: PropTypes.func,
|
||||
onTouchEnd: PropTypes.func,
|
||||
onMouseDown: PropTypes.func,
|
||||
onMouseUp: PropTypes.func,
|
||||
onMouseLeave: PropTypes.func
|
||||
};
|
||||
|
||||
export default InputHandler;
|
||||
869
web/node_modules/rc-input-number/es/index.js
generated
vendored
Normal file
869
web/node_modules/rc-input-number/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,869 @@
|
||||
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
||||
import _extends from 'babel-runtime/helpers/extends';
|
||||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
||||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
||||
import _inherits from 'babel-runtime/helpers/inherits';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import KeyCode from 'rc-util/es/KeyCode';
|
||||
import InputHandler from './InputHandler';
|
||||
|
||||
function noop() {}
|
||||
|
||||
function preventDefault(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
function defaultParser(input) {
|
||||
return input.replace(/[^\w\.-]+/g, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* When click and hold on a button - the speed of auto changin the value.
|
||||
*/
|
||||
var SPEED = 200;
|
||||
|
||||
/**
|
||||
* When click and hold on a button - the delay before auto changin the value.
|
||||
*/
|
||||
var DELAY = 600;
|
||||
|
||||
/**
|
||||
* Max Safe Integer -- on IE this is not available, so manually set the number in that case.
|
||||
* The reason this is used, instead of Infinity is because numbers above the MSI are unstable
|
||||
*/
|
||||
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
|
||||
|
||||
var isValidProps = function isValidProps(value) {
|
||||
return value !== undefined && value !== null;
|
||||
};
|
||||
|
||||
var isEqual = function isEqual(oldValue, newValue) {
|
||||
return newValue === oldValue || typeof newValue === 'number' && typeof oldValue === 'number' && isNaN(newValue) && isNaN(oldValue);
|
||||
};
|
||||
|
||||
var InputNumber = function (_React$Component) {
|
||||
_inherits(InputNumber, _React$Component);
|
||||
|
||||
function InputNumber(props) {
|
||||
_classCallCheck(this, InputNumber);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
|
||||
|
||||
_initialiseProps.call(_this);
|
||||
|
||||
var value = void 0;
|
||||
if ('value' in props) {
|
||||
value = props.value;
|
||||
} else {
|
||||
value = props.defaultValue;
|
||||
}
|
||||
_this.state = {
|
||||
focused: props.autoFocus
|
||||
};
|
||||
var validValue = _this.getValidValue(_this.toNumber(value));
|
||||
_this.state = _extends({}, _this.state, {
|
||||
inputValue: _this.toPrecisionAsStep(validValue),
|
||||
value: validValue
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
|
||||
InputNumber.prototype.componentDidMount = function componentDidMount() {
|
||||
this.componentDidUpdate();
|
||||
};
|
||||
|
||||
InputNumber.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
|
||||
var _props = this.props,
|
||||
value = _props.value,
|
||||
onChange = _props.onChange,
|
||||
max = _props.max,
|
||||
min = _props.min;
|
||||
var focused = this.state.focused;
|
||||
|
||||
// Don't trigger in componentDidMount
|
||||
|
||||
if (prevProps) {
|
||||
if (!isEqual(prevProps.value, value) || !isEqual(prevProps.max, max) || !isEqual(prevProps.min, min)) {
|
||||
var validValue = focused ? value : this.getValidValue(value);
|
||||
var nextInputValue = void 0;
|
||||
if (this.pressingUpOrDown) {
|
||||
nextInputValue = validValue;
|
||||
} else if (this.inputting) {
|
||||
nextInputValue = this.rawInput;
|
||||
} else {
|
||||
nextInputValue = this.toPrecisionAsStep(validValue);
|
||||
}
|
||||
this.setState({ // eslint-disable-line
|
||||
value: validValue,
|
||||
inputValue: nextInputValue
|
||||
});
|
||||
}
|
||||
|
||||
// Trigger onChange when max or min change
|
||||
// https://github.com/ant-design/ant-design/issues/11574
|
||||
var nextValue = 'value' in this.props ? value : this.state.value;
|
||||
// ref: null < 20 === true
|
||||
// https://github.com/ant-design/ant-design/issues/14277
|
||||
if ('max' in this.props && prevProps.max !== max && typeof nextValue === 'number' && nextValue > max && onChange) {
|
||||
onChange(max);
|
||||
}
|
||||
if ('min' in this.props && prevProps.min !== min && typeof nextValue === 'number' && nextValue < min && onChange) {
|
||||
onChange(min);
|
||||
}
|
||||
}
|
||||
|
||||
// Restore cursor
|
||||
try {
|
||||
// Firefox set the input cursor after it get focused.
|
||||
// This caused that if an input didn't init with the selection,
|
||||
// set will cause cursor not correct when first focus.
|
||||
// Safari will focus input if set selection. We need skip this.
|
||||
if (this.cursorStart !== undefined && this.state.focused) {
|
||||
// In most cases, the string after cursor is stable.
|
||||
// We can move the cursor before it
|
||||
|
||||
if (
|
||||
// If not match full str, try to match part of str
|
||||
!this.partRestoreByAfter(this.cursorAfter) && this.state.value !== this.props.value) {
|
||||
// If not match any of then, let's just keep the position
|
||||
// TODO: Logic should not reach here, need check if happens
|
||||
var pos = this.cursorStart + 1;
|
||||
|
||||
// If not have last string, just position to the end
|
||||
if (!this.cursorAfter) {
|
||||
pos = this.input.value.length;
|
||||
} else if (this.lastKeyCode === KeyCode.BACKSPACE) {
|
||||
pos = this.cursorStart - 1;
|
||||
} else if (this.lastKeyCode === KeyCode.DELETE) {
|
||||
pos = this.cursorStart;
|
||||
}
|
||||
this.fixCaret(pos, pos);
|
||||
} else if (this.currentValue === this.input.value) {
|
||||
// Handle some special key code
|
||||
switch (this.lastKeyCode) {
|
||||
case KeyCode.BACKSPACE:
|
||||
this.fixCaret(this.cursorStart - 1, this.cursorStart - 1);
|
||||
break;
|
||||
case KeyCode.DELETE:
|
||||
this.fixCaret(this.cursorStart + 1, this.cursorStart + 1);
|
||||
break;
|
||||
default:
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
// Do nothing
|
||||
|
||||
|
||||
// Reset last key
|
||||
this.lastKeyCode = null;
|
||||
|
||||
// pressingUpOrDown is true means that someone just click up or down button
|
||||
if (!this.pressingUpOrDown) {
|
||||
return;
|
||||
}
|
||||
if (this.props.focusOnUpDown && this.state.focused) {
|
||||
if (document.activeElement !== this.input) {
|
||||
this.focus();
|
||||
}
|
||||
}
|
||||
|
||||
this.pressingUpOrDown = false;
|
||||
};
|
||||
|
||||
InputNumber.prototype.componentWillUnmount = function componentWillUnmount() {
|
||||
this.stop();
|
||||
};
|
||||
|
||||
InputNumber.prototype.getCurrentValidValue = function getCurrentValidValue(value) {
|
||||
var val = value;
|
||||
if (val === '') {
|
||||
val = '';
|
||||
} else if (!this.isNotCompleteNumber(parseFloat(val, 10))) {
|
||||
val = this.getValidValue(val);
|
||||
} else {
|
||||
val = this.state.value;
|
||||
}
|
||||
return this.toNumber(val);
|
||||
};
|
||||
|
||||
InputNumber.prototype.getRatio = function getRatio(e) {
|
||||
var ratio = 1;
|
||||
if (e.metaKey || e.ctrlKey) {
|
||||
ratio = 0.1;
|
||||
} else if (e.shiftKey) {
|
||||
ratio = 10;
|
||||
}
|
||||
return ratio;
|
||||
};
|
||||
|
||||
InputNumber.prototype.getValueFromEvent = function getValueFromEvent(e) {
|
||||
// optimize for chinese input expierence
|
||||
// https://github.com/ant-design/ant-design/issues/8196
|
||||
var value = e.target.value.trim().replace(/。/g, '.');
|
||||
|
||||
if (isValidProps(this.props.decimalSeparator)) {
|
||||
value = value.replace(this.props.decimalSeparator, '.');
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
InputNumber.prototype.getValidValue = function getValidValue(value) {
|
||||
var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.min;
|
||||
var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.props.max;
|
||||
|
||||
var val = parseFloat(value, 10);
|
||||
// https://github.com/ant-design/ant-design/issues/7358
|
||||
if (isNaN(val)) {
|
||||
return value;
|
||||
}
|
||||
if (val < min) {
|
||||
val = min;
|
||||
}
|
||||
if (val > max) {
|
||||
val = max;
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
InputNumber.prototype.setValue = function setValue(v, callback) {
|
||||
// trigger onChange
|
||||
var precision = this.props.precision;
|
||||
|
||||
var newValue = this.isNotCompleteNumber(parseFloat(v, 10)) ? null : parseFloat(v, 10);
|
||||
var _state = this.state,
|
||||
_state$value = _state.value,
|
||||
value = _state$value === undefined ? null : _state$value,
|
||||
_state$inputValue = _state.inputValue,
|
||||
inputValue = _state$inputValue === undefined ? null : _state$inputValue;
|
||||
// https://github.com/ant-design/ant-design/issues/7363
|
||||
// https://github.com/ant-design/ant-design/issues/16622
|
||||
|
||||
var newValueInString = typeof newValue === 'number' ? newValue.toFixed(precision) : '' + newValue;
|
||||
var changed = newValue !== value || newValueInString !== '' + inputValue;
|
||||
if (!('value' in this.props)) {
|
||||
this.setState({
|
||||
value: newValue,
|
||||
inputValue: this.toPrecisionAsStep(v)
|
||||
}, callback);
|
||||
} else {
|
||||
// always set input value same as value
|
||||
this.setState({
|
||||
inputValue: this.toPrecisionAsStep(this.state.value)
|
||||
}, callback);
|
||||
}
|
||||
if (changed) {
|
||||
this.props.onChange(newValue);
|
||||
}
|
||||
|
||||
return newValue;
|
||||
};
|
||||
|
||||
InputNumber.prototype.getPrecision = function getPrecision(value) {
|
||||
if (isValidProps(this.props.precision)) {
|
||||
return this.props.precision;
|
||||
}
|
||||
var valueString = value.toString();
|
||||
if (valueString.indexOf('e-') >= 0) {
|
||||
return parseInt(valueString.slice(valueString.indexOf('e-') + 2), 10);
|
||||
}
|
||||
var precision = 0;
|
||||
if (valueString.indexOf('.') >= 0) {
|
||||
precision = valueString.length - valueString.indexOf('.') - 1;
|
||||
}
|
||||
return precision;
|
||||
};
|
||||
|
||||
// step={1.0} value={1.51}
|
||||
// press +
|
||||
// then value should be 2.51, rather than 2.5
|
||||
// if this.props.precision is undefined
|
||||
// https://github.com/react-component/input-number/issues/39
|
||||
|
||||
|
||||
InputNumber.prototype.getMaxPrecision = function getMaxPrecision(currentValue) {
|
||||
var ratio = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
||||
var _props2 = this.props,
|
||||
precision = _props2.precision,
|
||||
step = _props2.step;
|
||||
|
||||
if (isValidProps(precision)) {
|
||||
return precision;
|
||||
}
|
||||
var ratioPrecision = this.getPrecision(ratio);
|
||||
var stepPrecision = this.getPrecision(step);
|
||||
var currentValuePrecision = this.getPrecision(currentValue);
|
||||
if (!currentValue) {
|
||||
return ratioPrecision + stepPrecision;
|
||||
}
|
||||
return Math.max(currentValuePrecision, ratioPrecision + stepPrecision);
|
||||
};
|
||||
|
||||
InputNumber.prototype.getPrecisionFactor = function getPrecisionFactor(currentValue) {
|
||||
var ratio = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
||||
|
||||
var precision = this.getMaxPrecision(currentValue, ratio);
|
||||
return Math.pow(10, precision);
|
||||
};
|
||||
|
||||
InputNumber.prototype.fixCaret = function fixCaret(start, end) {
|
||||
if (start === undefined || end === undefined || !this.input || !this.input.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var currentStart = this.input.selectionStart;
|
||||
var currentEnd = this.input.selectionEnd;
|
||||
|
||||
if (start !== currentStart || end !== currentEnd) {
|
||||
this.input.setSelectionRange(start, end);
|
||||
}
|
||||
} catch (e) {
|
||||
// Fix error in Chrome:
|
||||
// Failed to read the 'selectionStart' property from 'HTMLInputElement'
|
||||
// http://stackoverflow.com/q/21177489/3040605
|
||||
}
|
||||
};
|
||||
|
||||
InputNumber.prototype.focus = function focus() {
|
||||
this.input.focus();
|
||||
this.recordCursorPosition();
|
||||
};
|
||||
|
||||
InputNumber.prototype.blur = function blur() {
|
||||
this.input.blur();
|
||||
};
|
||||
|
||||
InputNumber.prototype.formatWrapper = function formatWrapper(num) {
|
||||
// http://2ality.com/2012/03/signedzero.html
|
||||
// https://github.com/ant-design/ant-design/issues/9439
|
||||
if (this.props.formatter) {
|
||||
return this.props.formatter(num);
|
||||
}
|
||||
return num;
|
||||
};
|
||||
|
||||
InputNumber.prototype.toPrecisionAsStep = function toPrecisionAsStep(num) {
|
||||
if (this.isNotCompleteNumber(num) || num === '') {
|
||||
return num;
|
||||
}
|
||||
var precision = Math.abs(this.getMaxPrecision(num));
|
||||
if (!isNaN(precision)) {
|
||||
return Number(num).toFixed(precision);
|
||||
}
|
||||
return num.toString();
|
||||
};
|
||||
|
||||
// '1.' '1x' 'xx' '' => are not complete numbers
|
||||
|
||||
|
||||
InputNumber.prototype.isNotCompleteNumber = function isNotCompleteNumber(num) {
|
||||
return isNaN(num) || num === '' || num === null || num && num.toString().indexOf('.') === num.toString().length - 1;
|
||||
};
|
||||
|
||||
InputNumber.prototype.toNumber = function toNumber(num) {
|
||||
var precision = this.props.precision;
|
||||
var focused = this.state.focused;
|
||||
// num.length > 16 => This is to prevent input of large numbers
|
||||
|
||||
var numberIsTooLarge = num && num.length > 16 && focused;
|
||||
if (this.isNotCompleteNumber(num) || numberIsTooLarge) {
|
||||
return num;
|
||||
}
|
||||
if (isValidProps(precision)) {
|
||||
return Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision);
|
||||
}
|
||||
return Number(num);
|
||||
};
|
||||
|
||||
InputNumber.prototype.upStep = function upStep(val, rat) {
|
||||
var step = this.props.step;
|
||||
|
||||
var precisionFactor = this.getPrecisionFactor(val, rat);
|
||||
var precision = Math.abs(this.getMaxPrecision(val, rat));
|
||||
var result = ((precisionFactor * val + precisionFactor * step * rat) / precisionFactor).toFixed(precision);
|
||||
return this.toNumber(result);
|
||||
};
|
||||
|
||||
InputNumber.prototype.downStep = function downStep(val, rat) {
|
||||
var step = this.props.step;
|
||||
|
||||
var precisionFactor = this.getPrecisionFactor(val, rat);
|
||||
var precision = Math.abs(this.getMaxPrecision(val, rat));
|
||||
var result = ((precisionFactor * val - precisionFactor * step * rat) / precisionFactor).toFixed(precision);
|
||||
return this.toNumber(result);
|
||||
};
|
||||
|
||||
InputNumber.prototype.step = function step(type, e) {
|
||||
var _this2 = this;
|
||||
|
||||
var ratio = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
||||
var recursive = arguments[3];
|
||||
|
||||
this.stop();
|
||||
if (e) {
|
||||
e.persist();
|
||||
e.preventDefault();
|
||||
}
|
||||
var props = this.props;
|
||||
if (props.disabled) {
|
||||
return;
|
||||
}
|
||||
var value = this.getCurrentValidValue(this.state.inputValue) || 0;
|
||||
if (this.isNotCompleteNumber(value)) {
|
||||
return;
|
||||
}
|
||||
var val = this[type + 'Step'](value, ratio);
|
||||
var outOfRange = val > props.max || val < props.min;
|
||||
if (val > props.max) {
|
||||
val = props.max;
|
||||
} else if (val < props.min) {
|
||||
val = props.min;
|
||||
}
|
||||
this.setValue(val);
|
||||
this.setState({
|
||||
focused: true
|
||||
});
|
||||
if (outOfRange) {
|
||||
return;
|
||||
}
|
||||
this.autoStepTimer = setTimeout(function () {
|
||||
_this2[type](e, ratio, true);
|
||||
}, recursive ? SPEED : DELAY);
|
||||
};
|
||||
|
||||
InputNumber.prototype.render = function render() {
|
||||
var _classNames;
|
||||
|
||||
var props = _extends({}, this.props);
|
||||
|
||||
var prefixCls = props.prefixCls,
|
||||
disabled = props.disabled,
|
||||
readOnly = props.readOnly,
|
||||
useTouch = props.useTouch,
|
||||
autoComplete = props.autoComplete,
|
||||
upHandler = props.upHandler,
|
||||
downHandler = props.downHandler,
|
||||
rest = _objectWithoutProperties(props, ['prefixCls', 'disabled', 'readOnly', 'useTouch', 'autoComplete', 'upHandler', 'downHandler']);
|
||||
|
||||
var classes = classNames((_classNames = {}, _classNames[prefixCls] = true, _classNames[props.className] = !!props.className, _classNames[prefixCls + '-disabled'] = disabled, _classNames[prefixCls + '-focused'] = this.state.focused, _classNames));
|
||||
var upDisabledClass = '';
|
||||
var downDisabledClass = '';
|
||||
var value = this.state.value;
|
||||
|
||||
if (value || value === 0) {
|
||||
if (!isNaN(value)) {
|
||||
var val = Number(value);
|
||||
if (val >= props.max) {
|
||||
upDisabledClass = prefixCls + '-handler-up-disabled';
|
||||
}
|
||||
if (val <= props.min) {
|
||||
downDisabledClass = prefixCls + '-handler-down-disabled';
|
||||
}
|
||||
} else {
|
||||
upDisabledClass = prefixCls + '-handler-up-disabled';
|
||||
downDisabledClass = prefixCls + '-handler-down-disabled';
|
||||
}
|
||||
}
|
||||
|
||||
var dataOrAriaAttributeProps = {};
|
||||
for (var key in props) {
|
||||
if (props.hasOwnProperty(key) && (key.substr(0, 5) === 'data-' || key.substr(0, 5) === 'aria-' || key === 'role')) {
|
||||
dataOrAriaAttributeProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
var editable = !props.readOnly && !props.disabled;
|
||||
|
||||
// focus state, show input value
|
||||
// unfocus state, show valid value
|
||||
var inputDisplayValue = this.getInputDisplayValue();
|
||||
|
||||
var upEvents = void 0;
|
||||
var downEvents = void 0;
|
||||
if (useTouch) {
|
||||
upEvents = {
|
||||
onTouchStart: editable && !upDisabledClass ? this.up : noop,
|
||||
onTouchEnd: this.stop
|
||||
};
|
||||
downEvents = {
|
||||
onTouchStart: editable && !downDisabledClass ? this.down : noop,
|
||||
onTouchEnd: this.stop
|
||||
};
|
||||
} else {
|
||||
upEvents = {
|
||||
onMouseDown: editable && !upDisabledClass ? this.up : noop,
|
||||
onMouseUp: this.stop,
|
||||
onMouseLeave: this.stop
|
||||
};
|
||||
downEvents = {
|
||||
onMouseDown: editable && !downDisabledClass ? this.down : noop,
|
||||
onMouseUp: this.stop,
|
||||
onMouseLeave: this.stop
|
||||
};
|
||||
}
|
||||
|
||||
var isUpDisabled = !!upDisabledClass || disabled || readOnly;
|
||||
var isDownDisabled = !!downDisabledClass || disabled || readOnly;
|
||||
// ref for test
|
||||
return React.createElement(
|
||||
'div',
|
||||
{
|
||||
className: classes,
|
||||
style: props.style,
|
||||
title: props.title,
|
||||
onMouseEnter: props.onMouseEnter,
|
||||
onMouseLeave: props.onMouseLeave,
|
||||
onMouseOver: props.onMouseOver,
|
||||
onMouseOut: props.onMouseOut
|
||||
},
|
||||
React.createElement(
|
||||
'div',
|
||||
{ className: prefixCls + '-handler-wrap' },
|
||||
React.createElement(
|
||||
InputHandler,
|
||||
_extends({
|
||||
ref: this.saveUp,
|
||||
disabled: isUpDisabled,
|
||||
prefixCls: prefixCls,
|
||||
unselectable: 'unselectable'
|
||||
}, upEvents, {
|
||||
role: 'button',
|
||||
'aria-label': 'Increase Value',
|
||||
'aria-disabled': !!isUpDisabled,
|
||||
className: prefixCls + '-handler ' + prefixCls + '-handler-up ' + upDisabledClass
|
||||
}),
|
||||
upHandler || React.createElement('span', {
|
||||
unselectable: 'unselectable',
|
||||
className: prefixCls + '-handler-up-inner',
|
||||
onClick: preventDefault
|
||||
})
|
||||
),
|
||||
React.createElement(
|
||||
InputHandler,
|
||||
_extends({
|
||||
ref: this.saveDown,
|
||||
disabled: isDownDisabled,
|
||||
prefixCls: prefixCls,
|
||||
unselectable: 'unselectable'
|
||||
}, downEvents, {
|
||||
role: 'button',
|
||||
'aria-label': 'Decrease Value',
|
||||
'aria-disabled': !!isDownDisabled,
|
||||
className: prefixCls + '-handler ' + prefixCls + '-handler-down ' + downDisabledClass
|
||||
}),
|
||||
downHandler || React.createElement('span', {
|
||||
unselectable: 'unselectable',
|
||||
className: prefixCls + '-handler-down-inner',
|
||||
onClick: preventDefault
|
||||
})
|
||||
)
|
||||
),
|
||||
React.createElement(
|
||||
'div',
|
||||
{
|
||||
className: prefixCls + '-input-wrap'
|
||||
},
|
||||
React.createElement('input', _extends({
|
||||
role: 'spinbutton',
|
||||
'aria-valuemin': props.min,
|
||||
'aria-valuemax': props.max,
|
||||
'aria-valuenow': value,
|
||||
required: props.required,
|
||||
type: props.type,
|
||||
placeholder: props.placeholder,
|
||||
onClick: props.onClick,
|
||||
onMouseUp: this.onMouseUp,
|
||||
className: prefixCls + '-input',
|
||||
tabIndex: props.tabIndex,
|
||||
autoComplete: autoComplete,
|
||||
onFocus: this.onFocus,
|
||||
onBlur: this.onBlur,
|
||||
onKeyDown: editable ? this.onKeyDown : noop,
|
||||
onKeyUp: editable ? this.onKeyUp : noop,
|
||||
autoFocus: props.autoFocus,
|
||||
maxLength: props.maxLength,
|
||||
readOnly: props.readOnly,
|
||||
disabled: props.disabled,
|
||||
max: props.max,
|
||||
min: props.min,
|
||||
step: props.step,
|
||||
name: props.name,
|
||||
title: props.title,
|
||||
id: props.id,
|
||||
onChange: this.onChange,
|
||||
ref: this.saveInput,
|
||||
value: inputDisplayValue,
|
||||
pattern: props.pattern,
|
||||
inputMode: props.inputMode
|
||||
}, dataOrAriaAttributeProps))
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
return InputNumber;
|
||||
}(React.Component);
|
||||
|
||||
InputNumber.propTypes = {
|
||||
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
focusOnUpDown: PropTypes.bool,
|
||||
autoFocus: PropTypes.bool,
|
||||
onChange: PropTypes.func,
|
||||
onPressEnter: PropTypes.func,
|
||||
onKeyDown: PropTypes.func,
|
||||
onKeyUp: PropTypes.func,
|
||||
prefixCls: PropTypes.string,
|
||||
tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
disabled: PropTypes.bool,
|
||||
onFocus: PropTypes.func,
|
||||
onBlur: PropTypes.func,
|
||||
readOnly: PropTypes.bool,
|
||||
max: PropTypes.number,
|
||||
min: PropTypes.number,
|
||||
step: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
upHandler: PropTypes.node,
|
||||
downHandler: PropTypes.node,
|
||||
useTouch: PropTypes.bool,
|
||||
formatter: PropTypes.func,
|
||||
parser: PropTypes.func,
|
||||
onMouseEnter: PropTypes.func,
|
||||
onMouseLeave: PropTypes.func,
|
||||
onMouseOver: PropTypes.func,
|
||||
onMouseOut: PropTypes.func,
|
||||
onMouseUp: PropTypes.func,
|
||||
precision: PropTypes.number,
|
||||
required: PropTypes.bool,
|
||||
pattern: PropTypes.string,
|
||||
decimalSeparator: PropTypes.string,
|
||||
inputMode: PropTypes.string
|
||||
};
|
||||
InputNumber.defaultProps = {
|
||||
focusOnUpDown: true,
|
||||
useTouch: false,
|
||||
prefixCls: 'rc-input-number',
|
||||
min: -MAX_SAFE_INTEGER,
|
||||
step: 1,
|
||||
style: {},
|
||||
onChange: noop,
|
||||
onKeyDown: noop,
|
||||
onPressEnter: noop,
|
||||
onFocus: noop,
|
||||
onBlur: noop,
|
||||
parser: defaultParser,
|
||||
required: false,
|
||||
autoComplete: 'off'
|
||||
};
|
||||
|
||||
var _initialiseProps = function _initialiseProps() {
|
||||
var _this3 = this;
|
||||
|
||||
this.onKeyDown = function (e) {
|
||||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
var _props3 = _this3.props,
|
||||
onKeyDown = _props3.onKeyDown,
|
||||
onPressEnter = _props3.onPressEnter;
|
||||
|
||||
|
||||
if (e.keyCode === KeyCode.UP) {
|
||||
var ratio = _this3.getRatio(e);
|
||||
_this3.up(e, ratio);
|
||||
_this3.stop();
|
||||
} else if (e.keyCode === KeyCode.DOWN) {
|
||||
var _ratio = _this3.getRatio(e);
|
||||
_this3.down(e, _ratio);
|
||||
_this3.stop();
|
||||
} else if (e.keyCode === KeyCode.ENTER && onPressEnter) {
|
||||
onPressEnter(e);
|
||||
}
|
||||
|
||||
// Trigger user key down
|
||||
_this3.recordCursorPosition();
|
||||
_this3.lastKeyCode = e.keyCode;
|
||||
if (onKeyDown) {
|
||||
onKeyDown.apply(undefined, [e].concat(args));
|
||||
}
|
||||
};
|
||||
|
||||
this.onKeyUp = function (e) {
|
||||
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
var onKeyUp = _this3.props.onKeyUp;
|
||||
|
||||
|
||||
_this3.stop();
|
||||
|
||||
_this3.recordCursorPosition();
|
||||
|
||||
// Trigger user key up
|
||||
if (onKeyUp) {
|
||||
onKeyUp.apply(undefined, [e].concat(args));
|
||||
}
|
||||
};
|
||||
|
||||
this.onChange = function (e) {
|
||||
var onChange = _this3.props.onChange;
|
||||
|
||||
|
||||
if (_this3.state.focused) {
|
||||
_this3.inputting = true;
|
||||
}
|
||||
_this3.rawInput = _this3.props.parser(_this3.getValueFromEvent(e));
|
||||
_this3.setState({ inputValue: _this3.rawInput });
|
||||
onChange(_this3.toNumber(_this3.rawInput)); // valid number or invalid string
|
||||
};
|
||||
|
||||
this.onMouseUp = function () {
|
||||
var onMouseUp = _this3.props.onMouseUp;
|
||||
|
||||
|
||||
_this3.recordCursorPosition();
|
||||
|
||||
if (onMouseUp) {
|
||||
onMouseUp.apply(undefined, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
this.onFocus = function () {
|
||||
var _props4;
|
||||
|
||||
_this3.setState({
|
||||
focused: true
|
||||
});
|
||||
(_props4 = _this3.props).onFocus.apply(_props4, arguments);
|
||||
};
|
||||
|
||||
this.onBlur = function () {
|
||||
var onBlur = _this3.props.onBlur;
|
||||
|
||||
_this3.inputting = false;
|
||||
_this3.setState({
|
||||
focused: false
|
||||
});
|
||||
var value = _this3.getCurrentValidValue(_this3.state.inputValue);
|
||||
var newValue = _this3.setValue(value);
|
||||
|
||||
if (onBlur) {
|
||||
var originValue = _this3.input.value;
|
||||
var inputValue = _this3.getInputDisplayValue({ focus: false, value: newValue });
|
||||
_this3.input.value = inputValue;
|
||||
onBlur.apply(undefined, arguments);
|
||||
_this3.input.value = originValue;
|
||||
}
|
||||
};
|
||||
|
||||
this.getInputDisplayValue = function (state) {
|
||||
var _ref = state || _this3.state,
|
||||
focused = _ref.focused,
|
||||
inputValue = _ref.inputValue,
|
||||
value = _ref.value;
|
||||
|
||||
var inputDisplayValue = void 0;
|
||||
if (focused) {
|
||||
inputDisplayValue = inputValue;
|
||||
} else {
|
||||
inputDisplayValue = _this3.toPrecisionAsStep(value);
|
||||
}
|
||||
|
||||
if (inputDisplayValue === undefined || inputDisplayValue === null) {
|
||||
inputDisplayValue = '';
|
||||
}
|
||||
|
||||
var inputDisplayValueFormat = _this3.formatWrapper(inputDisplayValue);
|
||||
if (isValidProps(_this3.props.decimalSeparator)) {
|
||||
inputDisplayValueFormat = inputDisplayValueFormat.toString().replace('.', _this3.props.decimalSeparator);
|
||||
}
|
||||
|
||||
return inputDisplayValueFormat;
|
||||
};
|
||||
|
||||
this.recordCursorPosition = function () {
|
||||
// Record position
|
||||
try {
|
||||
_this3.cursorStart = _this3.input.selectionStart;
|
||||
_this3.cursorEnd = _this3.input.selectionEnd;
|
||||
_this3.currentValue = _this3.input.value;
|
||||
_this3.cursorBefore = _this3.input.value.substring(0, _this3.cursorStart);
|
||||
_this3.cursorAfter = _this3.input.value.substring(_this3.cursorEnd);
|
||||
} catch (e) {
|
||||
// Fix error in Chrome:
|
||||
// Failed to read the 'selectionStart' property from 'HTMLInputElement'
|
||||
// http://stackoverflow.com/q/21177489/3040605
|
||||
}
|
||||
};
|
||||
|
||||
this.restoreByAfter = function (str) {
|
||||
if (str === undefined) return false;
|
||||
|
||||
var fullStr = _this3.input.value;
|
||||
var index = fullStr.lastIndexOf(str);
|
||||
|
||||
if (index === -1) return false;
|
||||
|
||||
var prevCursorPos = _this3.cursorBefore.length;
|
||||
if (_this3.lastKeyCode === KeyCode.DELETE && _this3.cursorBefore.charAt(prevCursorPos - 1) === str[0]) {
|
||||
_this3.fixCaret(prevCursorPos, prevCursorPos);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (index + str.length === fullStr.length) {
|
||||
_this3.fixCaret(index, index);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
this.partRestoreByAfter = function (str) {
|
||||
if (str === undefined) return false;
|
||||
|
||||
// For loop from full str to the str with last char to map. e.g. 123
|
||||
// -> 123
|
||||
// -> 23
|
||||
// -> 3
|
||||
return Array.prototype.some.call(str, function (_, start) {
|
||||
var partStr = str.substring(start);
|
||||
|
||||
return _this3.restoreByAfter(partStr);
|
||||
});
|
||||
};
|
||||
|
||||
this.stop = function () {
|
||||
if (_this3.autoStepTimer) {
|
||||
clearTimeout(_this3.autoStepTimer);
|
||||
}
|
||||
};
|
||||
|
||||
this.down = function (e, ratio, recursive) {
|
||||
_this3.pressingUpOrDown = true;
|
||||
_this3.step('down', e, ratio, recursive);
|
||||
};
|
||||
|
||||
this.up = function (e, ratio, recursive) {
|
||||
_this3.pressingUpOrDown = true;
|
||||
_this3.step('up', e, ratio, recursive);
|
||||
};
|
||||
|
||||
this.saveUp = function (node) {
|
||||
_this3.upHandler = node;
|
||||
};
|
||||
|
||||
this.saveDown = function (node) {
|
||||
_this3.downHandler = node;
|
||||
};
|
||||
|
||||
this.saveInput = function (node) {
|
||||
_this3.input = node;
|
||||
};
|
||||
};
|
||||
|
||||
export default InputNumber;
|
||||
73
web/node_modules/rc-input-number/lib/InputHandler.js
generated
vendored
Normal file
73
web/node_modules/rc-input-number/lib/InputHandler.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
||||
|
||||
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
||||
|
||||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
||||
|
||||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
||||
|
||||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
||||
|
||||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
||||
|
||||
var _inherits2 = require('babel-runtime/helpers/inherits');
|
||||
|
||||
var _inherits3 = _interopRequireDefault(_inherits2);
|
||||
|
||||
var _react = require('react');
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
||||
var _propTypes = require('prop-types');
|
||||
|
||||
var _propTypes2 = _interopRequireDefault(_propTypes);
|
||||
|
||||
var _rmcFeedback = require('rmc-feedback');
|
||||
|
||||
var _rmcFeedback2 = _interopRequireDefault(_rmcFeedback);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
var InputHandler = function (_Component) {
|
||||
(0, _inherits3['default'])(InputHandler, _Component);
|
||||
|
||||
function InputHandler() {
|
||||
(0, _classCallCheck3['default'])(this, InputHandler);
|
||||
return (0, _possibleConstructorReturn3['default'])(this, _Component.apply(this, arguments));
|
||||
}
|
||||
|
||||
InputHandler.prototype.render = function render() {
|
||||
var _props = this.props,
|
||||
prefixCls = _props.prefixCls,
|
||||
disabled = _props.disabled,
|
||||
otherProps = (0, _objectWithoutProperties3['default'])(_props, ['prefixCls', 'disabled']);
|
||||
|
||||
return _react2['default'].createElement(
|
||||
_rmcFeedback2['default'],
|
||||
{
|
||||
disabled: disabled,
|
||||
activeClassName: prefixCls + '-handler-active'
|
||||
},
|
||||
_react2['default'].createElement('span', otherProps)
|
||||
);
|
||||
};
|
||||
|
||||
return InputHandler;
|
||||
}(_react.Component);
|
||||
|
||||
InputHandler.propTypes = {
|
||||
prefixCls: _propTypes2['default'].string,
|
||||
disabled: _propTypes2['default'].bool,
|
||||
onTouchStart: _propTypes2['default'].func,
|
||||
onTouchEnd: _propTypes2['default'].func,
|
||||
onMouseDown: _propTypes2['default'].func,
|
||||
onMouseUp: _propTypes2['default'].func,
|
||||
onMouseLeave: _propTypes2['default'].func
|
||||
};
|
||||
|
||||
exports['default'] = InputHandler;
|
||||
module.exports = exports['default'];
|
||||
904
web/node_modules/rc-input-number/lib/index.js
generated
vendored
Normal file
904
web/node_modules/rc-input-number/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,904 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
||||
|
||||
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
||||
|
||||
var _extends2 = require('babel-runtime/helpers/extends');
|
||||
|
||||
var _extends3 = _interopRequireDefault(_extends2);
|
||||
|
||||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
||||
|
||||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
||||
|
||||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
||||
|
||||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
||||
|
||||
var _inherits2 = require('babel-runtime/helpers/inherits');
|
||||
|
||||
var _inherits3 = _interopRequireDefault(_inherits2);
|
||||
|
||||
var _react = require('react');
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
||||
var _propTypes = require('prop-types');
|
||||
|
||||
var _propTypes2 = _interopRequireDefault(_propTypes);
|
||||
|
||||
var _classnames = require('classnames');
|
||||
|
||||
var _classnames2 = _interopRequireDefault(_classnames);
|
||||
|
||||
var _KeyCode = require('rc-util/lib/KeyCode');
|
||||
|
||||
var _KeyCode2 = _interopRequireDefault(_KeyCode);
|
||||
|
||||
var _InputHandler = require('./InputHandler');
|
||||
|
||||
var _InputHandler2 = _interopRequireDefault(_InputHandler);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
function noop() {}
|
||||
|
||||
function preventDefault(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
function defaultParser(input) {
|
||||
return input.replace(/[^\w\.-]+/g, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* When click and hold on a button - the speed of auto changin the value.
|
||||
*/
|
||||
var SPEED = 200;
|
||||
|
||||
/**
|
||||
* When click and hold on a button - the delay before auto changin the value.
|
||||
*/
|
||||
var DELAY = 600;
|
||||
|
||||
/**
|
||||
* Max Safe Integer -- on IE this is not available, so manually set the number in that case.
|
||||
* The reason this is used, instead of Infinity is because numbers above the MSI are unstable
|
||||
*/
|
||||
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
|
||||
|
||||
var isValidProps = function isValidProps(value) {
|
||||
return value !== undefined && value !== null;
|
||||
};
|
||||
|
||||
var isEqual = function isEqual(oldValue, newValue) {
|
||||
return newValue === oldValue || typeof newValue === 'number' && typeof oldValue === 'number' && isNaN(newValue) && isNaN(oldValue);
|
||||
};
|
||||
|
||||
var InputNumber = function (_React$Component) {
|
||||
(0, _inherits3['default'])(InputNumber, _React$Component);
|
||||
|
||||
function InputNumber(props) {
|
||||
(0, _classCallCheck3['default'])(this, InputNumber);
|
||||
|
||||
var _this = (0, _possibleConstructorReturn3['default'])(this, _React$Component.call(this, props));
|
||||
|
||||
_initialiseProps.call(_this);
|
||||
|
||||
var value = void 0;
|
||||
if ('value' in props) {
|
||||
value = props.value;
|
||||
} else {
|
||||
value = props.defaultValue;
|
||||
}
|
||||
_this.state = {
|
||||
focused: props.autoFocus
|
||||
};
|
||||
var validValue = _this.getValidValue(_this.toNumber(value));
|
||||
_this.state = (0, _extends3['default'])({}, _this.state, {
|
||||
inputValue: _this.toPrecisionAsStep(validValue),
|
||||
value: validValue
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
|
||||
InputNumber.prototype.componentDidMount = function componentDidMount() {
|
||||
this.componentDidUpdate();
|
||||
};
|
||||
|
||||
InputNumber.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
|
||||
var _props = this.props,
|
||||
value = _props.value,
|
||||
onChange = _props.onChange,
|
||||
max = _props.max,
|
||||
min = _props.min;
|
||||
var focused = this.state.focused;
|
||||
|
||||
// Don't trigger in componentDidMount
|
||||
|
||||
if (prevProps) {
|
||||
if (!isEqual(prevProps.value, value) || !isEqual(prevProps.max, max) || !isEqual(prevProps.min, min)) {
|
||||
var validValue = focused ? value : this.getValidValue(value);
|
||||
var nextInputValue = void 0;
|
||||
if (this.pressingUpOrDown) {
|
||||
nextInputValue = validValue;
|
||||
} else if (this.inputting) {
|
||||
nextInputValue = this.rawInput;
|
||||
} else {
|
||||
nextInputValue = this.toPrecisionAsStep(validValue);
|
||||
}
|
||||
this.setState({ // eslint-disable-line
|
||||
value: validValue,
|
||||
inputValue: nextInputValue
|
||||
});
|
||||
}
|
||||
|
||||
// Trigger onChange when max or min change
|
||||
// https://github.com/ant-design/ant-design/issues/11574
|
||||
var nextValue = 'value' in this.props ? value : this.state.value;
|
||||
// ref: null < 20 === true
|
||||
// https://github.com/ant-design/ant-design/issues/14277
|
||||
if ('max' in this.props && prevProps.max !== max && typeof nextValue === 'number' && nextValue > max && onChange) {
|
||||
onChange(max);
|
||||
}
|
||||
if ('min' in this.props && prevProps.min !== min && typeof nextValue === 'number' && nextValue < min && onChange) {
|
||||
onChange(min);
|
||||
}
|
||||
}
|
||||
|
||||
// Restore cursor
|
||||
try {
|
||||
// Firefox set the input cursor after it get focused.
|
||||
// This caused that if an input didn't init with the selection,
|
||||
// set will cause cursor not correct when first focus.
|
||||
// Safari will focus input if set selection. We need skip this.
|
||||
if (this.cursorStart !== undefined && this.state.focused) {
|
||||
// In most cases, the string after cursor is stable.
|
||||
// We can move the cursor before it
|
||||
|
||||
if (
|
||||
// If not match full str, try to match part of str
|
||||
!this.partRestoreByAfter(this.cursorAfter) && this.state.value !== this.props.value) {
|
||||
// If not match any of then, let's just keep the position
|
||||
// TODO: Logic should not reach here, need check if happens
|
||||
var pos = this.cursorStart + 1;
|
||||
|
||||
// If not have last string, just position to the end
|
||||
if (!this.cursorAfter) {
|
||||
pos = this.input.value.length;
|
||||
} else if (this.lastKeyCode === _KeyCode2['default'].BACKSPACE) {
|
||||
pos = this.cursorStart - 1;
|
||||
} else if (this.lastKeyCode === _KeyCode2['default'].DELETE) {
|
||||
pos = this.cursorStart;
|
||||
}
|
||||
this.fixCaret(pos, pos);
|
||||
} else if (this.currentValue === this.input.value) {
|
||||
// Handle some special key code
|
||||
switch (this.lastKeyCode) {
|
||||
case _KeyCode2['default'].BACKSPACE:
|
||||
this.fixCaret(this.cursorStart - 1, this.cursorStart - 1);
|
||||
break;
|
||||
case _KeyCode2['default'].DELETE:
|
||||
this.fixCaret(this.cursorStart + 1, this.cursorStart + 1);
|
||||
break;
|
||||
default:
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
// Do nothing
|
||||
|
||||
|
||||
// Reset last key
|
||||
this.lastKeyCode = null;
|
||||
|
||||
// pressingUpOrDown is true means that someone just click up or down button
|
||||
if (!this.pressingUpOrDown) {
|
||||
return;
|
||||
}
|
||||
if (this.props.focusOnUpDown && this.state.focused) {
|
||||
if (document.activeElement !== this.input) {
|
||||
this.focus();
|
||||
}
|
||||
}
|
||||
|
||||
this.pressingUpOrDown = false;
|
||||
};
|
||||
|
||||
InputNumber.prototype.componentWillUnmount = function componentWillUnmount() {
|
||||
this.stop();
|
||||
};
|
||||
|
||||
InputNumber.prototype.getCurrentValidValue = function getCurrentValidValue(value) {
|
||||
var val = value;
|
||||
if (val === '') {
|
||||
val = '';
|
||||
} else if (!this.isNotCompleteNumber(parseFloat(val, 10))) {
|
||||
val = this.getValidValue(val);
|
||||
} else {
|
||||
val = this.state.value;
|
||||
}
|
||||
return this.toNumber(val);
|
||||
};
|
||||
|
||||
InputNumber.prototype.getRatio = function getRatio(e) {
|
||||
var ratio = 1;
|
||||
if (e.metaKey || e.ctrlKey) {
|
||||
ratio = 0.1;
|
||||
} else if (e.shiftKey) {
|
||||
ratio = 10;
|
||||
}
|
||||
return ratio;
|
||||
};
|
||||
|
||||
InputNumber.prototype.getValueFromEvent = function getValueFromEvent(e) {
|
||||
// optimize for chinese input expierence
|
||||
// https://github.com/ant-design/ant-design/issues/8196
|
||||
var value = e.target.value.trim().replace(/。/g, '.');
|
||||
|
||||
if (isValidProps(this.props.decimalSeparator)) {
|
||||
value = value.replace(this.props.decimalSeparator, '.');
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
InputNumber.prototype.getValidValue = function getValidValue(value) {
|
||||
var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.min;
|
||||
var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.props.max;
|
||||
|
||||
var val = parseFloat(value, 10);
|
||||
// https://github.com/ant-design/ant-design/issues/7358
|
||||
if (isNaN(val)) {
|
||||
return value;
|
||||
}
|
||||
if (val < min) {
|
||||
val = min;
|
||||
}
|
||||
if (val > max) {
|
||||
val = max;
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
InputNumber.prototype.setValue = function setValue(v, callback) {
|
||||
// trigger onChange
|
||||
var precision = this.props.precision;
|
||||
|
||||
var newValue = this.isNotCompleteNumber(parseFloat(v, 10)) ? null : parseFloat(v, 10);
|
||||
var _state = this.state,
|
||||
_state$value = _state.value,
|
||||
value = _state$value === undefined ? null : _state$value,
|
||||
_state$inputValue = _state.inputValue,
|
||||
inputValue = _state$inputValue === undefined ? null : _state$inputValue;
|
||||
// https://github.com/ant-design/ant-design/issues/7363
|
||||
// https://github.com/ant-design/ant-design/issues/16622
|
||||
|
||||
var newValueInString = typeof newValue === 'number' ? newValue.toFixed(precision) : '' + newValue;
|
||||
var changed = newValue !== value || newValueInString !== '' + inputValue;
|
||||
if (!('value' in this.props)) {
|
||||
this.setState({
|
||||
value: newValue,
|
||||
inputValue: this.toPrecisionAsStep(v)
|
||||
}, callback);
|
||||
} else {
|
||||
// always set input value same as value
|
||||
this.setState({
|
||||
inputValue: this.toPrecisionAsStep(this.state.value)
|
||||
}, callback);
|
||||
}
|
||||
if (changed) {
|
||||
this.props.onChange(newValue);
|
||||
}
|
||||
|
||||
return newValue;
|
||||
};
|
||||
|
||||
InputNumber.prototype.getPrecision = function getPrecision(value) {
|
||||
if (isValidProps(this.props.precision)) {
|
||||
return this.props.precision;
|
||||
}
|
||||
var valueString = value.toString();
|
||||
if (valueString.indexOf('e-') >= 0) {
|
||||
return parseInt(valueString.slice(valueString.indexOf('e-') + 2), 10);
|
||||
}
|
||||
var precision = 0;
|
||||
if (valueString.indexOf('.') >= 0) {
|
||||
precision = valueString.length - valueString.indexOf('.') - 1;
|
||||
}
|
||||
return precision;
|
||||
};
|
||||
|
||||
// step={1.0} value={1.51}
|
||||
// press +
|
||||
// then value should be 2.51, rather than 2.5
|
||||
// if this.props.precision is undefined
|
||||
// https://github.com/react-component/input-number/issues/39
|
||||
|
||||
|
||||
InputNumber.prototype.getMaxPrecision = function getMaxPrecision(currentValue) {
|
||||
var ratio = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
||||
var _props2 = this.props,
|
||||
precision = _props2.precision,
|
||||
step = _props2.step;
|
||||
|
||||
if (isValidProps(precision)) {
|
||||
return precision;
|
||||
}
|
||||
var ratioPrecision = this.getPrecision(ratio);
|
||||
var stepPrecision = this.getPrecision(step);
|
||||
var currentValuePrecision = this.getPrecision(currentValue);
|
||||
if (!currentValue) {
|
||||
return ratioPrecision + stepPrecision;
|
||||
}
|
||||
return Math.max(currentValuePrecision, ratioPrecision + stepPrecision);
|
||||
};
|
||||
|
||||
InputNumber.prototype.getPrecisionFactor = function getPrecisionFactor(currentValue) {
|
||||
var ratio = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
||||
|
||||
var precision = this.getMaxPrecision(currentValue, ratio);
|
||||
return Math.pow(10, precision);
|
||||
};
|
||||
|
||||
InputNumber.prototype.fixCaret = function fixCaret(start, end) {
|
||||
if (start === undefined || end === undefined || !this.input || !this.input.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
var currentStart = this.input.selectionStart;
|
||||
var currentEnd = this.input.selectionEnd;
|
||||
|
||||
if (start !== currentStart || end !== currentEnd) {
|
||||
this.input.setSelectionRange(start, end);
|
||||
}
|
||||
} catch (e) {
|
||||
// Fix error in Chrome:
|
||||
// Failed to read the 'selectionStart' property from 'HTMLInputElement'
|
||||
// http://stackoverflow.com/q/21177489/3040605
|
||||
}
|
||||
};
|
||||
|
||||
InputNumber.prototype.focus = function focus() {
|
||||
this.input.focus();
|
||||
this.recordCursorPosition();
|
||||
};
|
||||
|
||||
InputNumber.prototype.blur = function blur() {
|
||||
this.input.blur();
|
||||
};
|
||||
|
||||
InputNumber.prototype.formatWrapper = function formatWrapper(num) {
|
||||
// http://2ality.com/2012/03/signedzero.html
|
||||
// https://github.com/ant-design/ant-design/issues/9439
|
||||
if (this.props.formatter) {
|
||||
return this.props.formatter(num);
|
||||
}
|
||||
return num;
|
||||
};
|
||||
|
||||
InputNumber.prototype.toPrecisionAsStep = function toPrecisionAsStep(num) {
|
||||
if (this.isNotCompleteNumber(num) || num === '') {
|
||||
return num;
|
||||
}
|
||||
var precision = Math.abs(this.getMaxPrecision(num));
|
||||
if (!isNaN(precision)) {
|
||||
return Number(num).toFixed(precision);
|
||||
}
|
||||
return num.toString();
|
||||
};
|
||||
|
||||
// '1.' '1x' 'xx' '' => are not complete numbers
|
||||
|
||||
|
||||
InputNumber.prototype.isNotCompleteNumber = function isNotCompleteNumber(num) {
|
||||
return isNaN(num) || num === '' || num === null || num && num.toString().indexOf('.') === num.toString().length - 1;
|
||||
};
|
||||
|
||||
InputNumber.prototype.toNumber = function toNumber(num) {
|
||||
var precision = this.props.precision;
|
||||
var focused = this.state.focused;
|
||||
// num.length > 16 => This is to prevent input of large numbers
|
||||
|
||||
var numberIsTooLarge = num && num.length > 16 && focused;
|
||||
if (this.isNotCompleteNumber(num) || numberIsTooLarge) {
|
||||
return num;
|
||||
}
|
||||
if (isValidProps(precision)) {
|
||||
return Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision);
|
||||
}
|
||||
return Number(num);
|
||||
};
|
||||
|
||||
InputNumber.prototype.upStep = function upStep(val, rat) {
|
||||
var step = this.props.step;
|
||||
|
||||
var precisionFactor = this.getPrecisionFactor(val, rat);
|
||||
var precision = Math.abs(this.getMaxPrecision(val, rat));
|
||||
var result = ((precisionFactor * val + precisionFactor * step * rat) / precisionFactor).toFixed(precision);
|
||||
return this.toNumber(result);
|
||||
};
|
||||
|
||||
InputNumber.prototype.downStep = function downStep(val, rat) {
|
||||
var step = this.props.step;
|
||||
|
||||
var precisionFactor = this.getPrecisionFactor(val, rat);
|
||||
var precision = Math.abs(this.getMaxPrecision(val, rat));
|
||||
var result = ((precisionFactor * val - precisionFactor * step * rat) / precisionFactor).toFixed(precision);
|
||||
return this.toNumber(result);
|
||||
};
|
||||
|
||||
InputNumber.prototype.step = function step(type, e) {
|
||||
var _this2 = this;
|
||||
|
||||
var ratio = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
||||
var recursive = arguments[3];
|
||||
|
||||
this.stop();
|
||||
if (e) {
|
||||
e.persist();
|
||||
e.preventDefault();
|
||||
}
|
||||
var props = this.props;
|
||||
if (props.disabled) {
|
||||
return;
|
||||
}
|
||||
var value = this.getCurrentValidValue(this.state.inputValue) || 0;
|
||||
if (this.isNotCompleteNumber(value)) {
|
||||
return;
|
||||
}
|
||||
var val = this[type + 'Step'](value, ratio);
|
||||
var outOfRange = val > props.max || val < props.min;
|
||||
if (val > props.max) {
|
||||
val = props.max;
|
||||
} else if (val < props.min) {
|
||||
val = props.min;
|
||||
}
|
||||
this.setValue(val);
|
||||
this.setState({
|
||||
focused: true
|
||||
});
|
||||
if (outOfRange) {
|
||||
return;
|
||||
}
|
||||
this.autoStepTimer = setTimeout(function () {
|
||||
_this2[type](e, ratio, true);
|
||||
}, recursive ? SPEED : DELAY);
|
||||
};
|
||||
|
||||
InputNumber.prototype.render = function render() {
|
||||
var _classNames;
|
||||
|
||||
var props = (0, _extends3['default'])({}, this.props);
|
||||
var prefixCls = props.prefixCls,
|
||||
disabled = props.disabled,
|
||||
readOnly = props.readOnly,
|
||||
useTouch = props.useTouch,
|
||||
autoComplete = props.autoComplete,
|
||||
upHandler = props.upHandler,
|
||||
downHandler = props.downHandler,
|
||||
rest = (0, _objectWithoutProperties3['default'])(props, ['prefixCls', 'disabled', 'readOnly', 'useTouch', 'autoComplete', 'upHandler', 'downHandler']);
|
||||
|
||||
var classes = (0, _classnames2['default'])((_classNames = {}, _classNames[prefixCls] = true, _classNames[props.className] = !!props.className, _classNames[prefixCls + '-disabled'] = disabled, _classNames[prefixCls + '-focused'] = this.state.focused, _classNames));
|
||||
var upDisabledClass = '';
|
||||
var downDisabledClass = '';
|
||||
var value = this.state.value;
|
||||
|
||||
if (value || value === 0) {
|
||||
if (!isNaN(value)) {
|
||||
var val = Number(value);
|
||||
if (val >= props.max) {
|
||||
upDisabledClass = prefixCls + '-handler-up-disabled';
|
||||
}
|
||||
if (val <= props.min) {
|
||||
downDisabledClass = prefixCls + '-handler-down-disabled';
|
||||
}
|
||||
} else {
|
||||
upDisabledClass = prefixCls + '-handler-up-disabled';
|
||||
downDisabledClass = prefixCls + '-handler-down-disabled';
|
||||
}
|
||||
}
|
||||
|
||||
var dataOrAriaAttributeProps = {};
|
||||
for (var key in props) {
|
||||
if (props.hasOwnProperty(key) && (key.substr(0, 5) === 'data-' || key.substr(0, 5) === 'aria-' || key === 'role')) {
|
||||
dataOrAriaAttributeProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
var editable = !props.readOnly && !props.disabled;
|
||||
|
||||
// focus state, show input value
|
||||
// unfocus state, show valid value
|
||||
var inputDisplayValue = this.getInputDisplayValue();
|
||||
|
||||
var upEvents = void 0;
|
||||
var downEvents = void 0;
|
||||
if (useTouch) {
|
||||
upEvents = {
|
||||
onTouchStart: editable && !upDisabledClass ? this.up : noop,
|
||||
onTouchEnd: this.stop
|
||||
};
|
||||
downEvents = {
|
||||
onTouchStart: editable && !downDisabledClass ? this.down : noop,
|
||||
onTouchEnd: this.stop
|
||||
};
|
||||
} else {
|
||||
upEvents = {
|
||||
onMouseDown: editable && !upDisabledClass ? this.up : noop,
|
||||
onMouseUp: this.stop,
|
||||
onMouseLeave: this.stop
|
||||
};
|
||||
downEvents = {
|
||||
onMouseDown: editable && !downDisabledClass ? this.down : noop,
|
||||
onMouseUp: this.stop,
|
||||
onMouseLeave: this.stop
|
||||
};
|
||||
}
|
||||
|
||||
var isUpDisabled = !!upDisabledClass || disabled || readOnly;
|
||||
var isDownDisabled = !!downDisabledClass || disabled || readOnly;
|
||||
// ref for test
|
||||
return _react2['default'].createElement(
|
||||
'div',
|
||||
{
|
||||
className: classes,
|
||||
style: props.style,
|
||||
title: props.title,
|
||||
onMouseEnter: props.onMouseEnter,
|
||||
onMouseLeave: props.onMouseLeave,
|
||||
onMouseOver: props.onMouseOver,
|
||||
onMouseOut: props.onMouseOut
|
||||
},
|
||||
_react2['default'].createElement(
|
||||
'div',
|
||||
{ className: prefixCls + '-handler-wrap' },
|
||||
_react2['default'].createElement(
|
||||
_InputHandler2['default'],
|
||||
(0, _extends3['default'])({
|
||||
ref: this.saveUp,
|
||||
disabled: isUpDisabled,
|
||||
prefixCls: prefixCls,
|
||||
unselectable: 'unselectable'
|
||||
}, upEvents, {
|
||||
role: 'button',
|
||||
'aria-label': 'Increase Value',
|
||||
'aria-disabled': !!isUpDisabled,
|
||||
className: prefixCls + '-handler ' + prefixCls + '-handler-up ' + upDisabledClass
|
||||
}),
|
||||
upHandler || _react2['default'].createElement('span', {
|
||||
unselectable: 'unselectable',
|
||||
className: prefixCls + '-handler-up-inner',
|
||||
onClick: preventDefault
|
||||
})
|
||||
),
|
||||
_react2['default'].createElement(
|
||||
_InputHandler2['default'],
|
||||
(0, _extends3['default'])({
|
||||
ref: this.saveDown,
|
||||
disabled: isDownDisabled,
|
||||
prefixCls: prefixCls,
|
||||
unselectable: 'unselectable'
|
||||
}, downEvents, {
|
||||
role: 'button',
|
||||
'aria-label': 'Decrease Value',
|
||||
'aria-disabled': !!isDownDisabled,
|
||||
className: prefixCls + '-handler ' + prefixCls + '-handler-down ' + downDisabledClass
|
||||
}),
|
||||
downHandler || _react2['default'].createElement('span', {
|
||||
unselectable: 'unselectable',
|
||||
className: prefixCls + '-handler-down-inner',
|
||||
onClick: preventDefault
|
||||
})
|
||||
)
|
||||
),
|
||||
_react2['default'].createElement(
|
||||
'div',
|
||||
{
|
||||
className: prefixCls + '-input-wrap'
|
||||
},
|
||||
_react2['default'].createElement('input', (0, _extends3['default'])({
|
||||
role: 'spinbutton',
|
||||
'aria-valuemin': props.min,
|
||||
'aria-valuemax': props.max,
|
||||
'aria-valuenow': value,
|
||||
required: props.required,
|
||||
type: props.type,
|
||||
placeholder: props.placeholder,
|
||||
onClick: props.onClick,
|
||||
onMouseUp: this.onMouseUp,
|
||||
className: prefixCls + '-input',
|
||||
tabIndex: props.tabIndex,
|
||||
autoComplete: autoComplete,
|
||||
onFocus: this.onFocus,
|
||||
onBlur: this.onBlur,
|
||||
onKeyDown: editable ? this.onKeyDown : noop,
|
||||
onKeyUp: editable ? this.onKeyUp : noop,
|
||||
autoFocus: props.autoFocus,
|
||||
maxLength: props.maxLength,
|
||||
readOnly: props.readOnly,
|
||||
disabled: props.disabled,
|
||||
max: props.max,
|
||||
min: props.min,
|
||||
step: props.step,
|
||||
name: props.name,
|
||||
title: props.title,
|
||||
id: props.id,
|
||||
onChange: this.onChange,
|
||||
ref: this.saveInput,
|
||||
value: inputDisplayValue,
|
||||
pattern: props.pattern,
|
||||
inputMode: props.inputMode
|
||||
}, dataOrAriaAttributeProps))
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
return InputNumber;
|
||||
}(_react2['default'].Component);
|
||||
|
||||
InputNumber.propTypes = {
|
||||
value: _propTypes2['default'].oneOfType([_propTypes2['default'].number, _propTypes2['default'].string]),
|
||||
defaultValue: _propTypes2['default'].oneOfType([_propTypes2['default'].number, _propTypes2['default'].string]),
|
||||
focusOnUpDown: _propTypes2['default'].bool,
|
||||
autoFocus: _propTypes2['default'].bool,
|
||||
onChange: _propTypes2['default'].func,
|
||||
onPressEnter: _propTypes2['default'].func,
|
||||
onKeyDown: _propTypes2['default'].func,
|
||||
onKeyUp: _propTypes2['default'].func,
|
||||
prefixCls: _propTypes2['default'].string,
|
||||
tabIndex: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].number]),
|
||||
disabled: _propTypes2['default'].bool,
|
||||
onFocus: _propTypes2['default'].func,
|
||||
onBlur: _propTypes2['default'].func,
|
||||
readOnly: _propTypes2['default'].bool,
|
||||
max: _propTypes2['default'].number,
|
||||
min: _propTypes2['default'].number,
|
||||
step: _propTypes2['default'].oneOfType([_propTypes2['default'].number, _propTypes2['default'].string]),
|
||||
upHandler: _propTypes2['default'].node,
|
||||
downHandler: _propTypes2['default'].node,
|
||||
useTouch: _propTypes2['default'].bool,
|
||||
formatter: _propTypes2['default'].func,
|
||||
parser: _propTypes2['default'].func,
|
||||
onMouseEnter: _propTypes2['default'].func,
|
||||
onMouseLeave: _propTypes2['default'].func,
|
||||
onMouseOver: _propTypes2['default'].func,
|
||||
onMouseOut: _propTypes2['default'].func,
|
||||
onMouseUp: _propTypes2['default'].func,
|
||||
precision: _propTypes2['default'].number,
|
||||
required: _propTypes2['default'].bool,
|
||||
pattern: _propTypes2['default'].string,
|
||||
decimalSeparator: _propTypes2['default'].string,
|
||||
inputMode: _propTypes2['default'].string
|
||||
};
|
||||
InputNumber.defaultProps = {
|
||||
focusOnUpDown: true,
|
||||
useTouch: false,
|
||||
prefixCls: 'rc-input-number',
|
||||
min: -MAX_SAFE_INTEGER,
|
||||
step: 1,
|
||||
style: {},
|
||||
onChange: noop,
|
||||
onKeyDown: noop,
|
||||
onPressEnter: noop,
|
||||
onFocus: noop,
|
||||
onBlur: noop,
|
||||
parser: defaultParser,
|
||||
required: false,
|
||||
autoComplete: 'off'
|
||||
};
|
||||
|
||||
var _initialiseProps = function _initialiseProps() {
|
||||
var _this3 = this;
|
||||
|
||||
this.onKeyDown = function (e) {
|
||||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
var _props3 = _this3.props,
|
||||
onKeyDown = _props3.onKeyDown,
|
||||
onPressEnter = _props3.onPressEnter;
|
||||
|
||||
|
||||
if (e.keyCode === _KeyCode2['default'].UP) {
|
||||
var ratio = _this3.getRatio(e);
|
||||
_this3.up(e, ratio);
|
||||
_this3.stop();
|
||||
} else if (e.keyCode === _KeyCode2['default'].DOWN) {
|
||||
var _ratio = _this3.getRatio(e);
|
||||
_this3.down(e, _ratio);
|
||||
_this3.stop();
|
||||
} else if (e.keyCode === _KeyCode2['default'].ENTER && onPressEnter) {
|
||||
onPressEnter(e);
|
||||
}
|
||||
|
||||
// Trigger user key down
|
||||
_this3.recordCursorPosition();
|
||||
_this3.lastKeyCode = e.keyCode;
|
||||
if (onKeyDown) {
|
||||
onKeyDown.apply(undefined, [e].concat(args));
|
||||
}
|
||||
};
|
||||
|
||||
this.onKeyUp = function (e) {
|
||||
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
var onKeyUp = _this3.props.onKeyUp;
|
||||
|
||||
|
||||
_this3.stop();
|
||||
|
||||
_this3.recordCursorPosition();
|
||||
|
||||
// Trigger user key up
|
||||
if (onKeyUp) {
|
||||
onKeyUp.apply(undefined, [e].concat(args));
|
||||
}
|
||||
};
|
||||
|
||||
this.onChange = function (e) {
|
||||
var onChange = _this3.props.onChange;
|
||||
|
||||
|
||||
if (_this3.state.focused) {
|
||||
_this3.inputting = true;
|
||||
}
|
||||
_this3.rawInput = _this3.props.parser(_this3.getValueFromEvent(e));
|
||||
_this3.setState({ inputValue: _this3.rawInput });
|
||||
onChange(_this3.toNumber(_this3.rawInput)); // valid number or invalid string
|
||||
};
|
||||
|
||||
this.onMouseUp = function () {
|
||||
var onMouseUp = _this3.props.onMouseUp;
|
||||
|
||||
|
||||
_this3.recordCursorPosition();
|
||||
|
||||
if (onMouseUp) {
|
||||
onMouseUp.apply(undefined, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
this.onFocus = function () {
|
||||
var _props4;
|
||||
|
||||
_this3.setState({
|
||||
focused: true
|
||||
});
|
||||
(_props4 = _this3.props).onFocus.apply(_props4, arguments);
|
||||
};
|
||||
|
||||
this.onBlur = function () {
|
||||
var onBlur = _this3.props.onBlur;
|
||||
|
||||
_this3.inputting = false;
|
||||
_this3.setState({
|
||||
focused: false
|
||||
});
|
||||
var value = _this3.getCurrentValidValue(_this3.state.inputValue);
|
||||
var newValue = _this3.setValue(value);
|
||||
|
||||
if (onBlur) {
|
||||
var originValue = _this3.input.value;
|
||||
var inputValue = _this3.getInputDisplayValue({ focus: false, value: newValue });
|
||||
_this3.input.value = inputValue;
|
||||
onBlur.apply(undefined, arguments);
|
||||
_this3.input.value = originValue;
|
||||
}
|
||||
};
|
||||
|
||||
this.getInputDisplayValue = function (state) {
|
||||
var _ref = state || _this3.state,
|
||||
focused = _ref.focused,
|
||||
inputValue = _ref.inputValue,
|
||||
value = _ref.value;
|
||||
|
||||
var inputDisplayValue = void 0;
|
||||
if (focused) {
|
||||
inputDisplayValue = inputValue;
|
||||
} else {
|
||||
inputDisplayValue = _this3.toPrecisionAsStep(value);
|
||||
}
|
||||
|
||||
if (inputDisplayValue === undefined || inputDisplayValue === null) {
|
||||
inputDisplayValue = '';
|
||||
}
|
||||
|
||||
var inputDisplayValueFormat = _this3.formatWrapper(inputDisplayValue);
|
||||
if (isValidProps(_this3.props.decimalSeparator)) {
|
||||
inputDisplayValueFormat = inputDisplayValueFormat.toString().replace('.', _this3.props.decimalSeparator);
|
||||
}
|
||||
|
||||
return inputDisplayValueFormat;
|
||||
};
|
||||
|
||||
this.recordCursorPosition = function () {
|
||||
// Record position
|
||||
try {
|
||||
_this3.cursorStart = _this3.input.selectionStart;
|
||||
_this3.cursorEnd = _this3.input.selectionEnd;
|
||||
_this3.currentValue = _this3.input.value;
|
||||
_this3.cursorBefore = _this3.input.value.substring(0, _this3.cursorStart);
|
||||
_this3.cursorAfter = _this3.input.value.substring(_this3.cursorEnd);
|
||||
} catch (e) {
|
||||
// Fix error in Chrome:
|
||||
// Failed to read the 'selectionStart' property from 'HTMLInputElement'
|
||||
// http://stackoverflow.com/q/21177489/3040605
|
||||
}
|
||||
};
|
||||
|
||||
this.restoreByAfter = function (str) {
|
||||
if (str === undefined) return false;
|
||||
|
||||
var fullStr = _this3.input.value;
|
||||
var index = fullStr.lastIndexOf(str);
|
||||
|
||||
if (index === -1) return false;
|
||||
|
||||
var prevCursorPos = _this3.cursorBefore.length;
|
||||
if (_this3.lastKeyCode === _KeyCode2['default'].DELETE && _this3.cursorBefore.charAt(prevCursorPos - 1) === str[0]) {
|
||||
_this3.fixCaret(prevCursorPos, prevCursorPos);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (index + str.length === fullStr.length) {
|
||||
_this3.fixCaret(index, index);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
this.partRestoreByAfter = function (str) {
|
||||
if (str === undefined) return false;
|
||||
|
||||
// For loop from full str to the str with last char to map. e.g. 123
|
||||
// -> 123
|
||||
// -> 23
|
||||
// -> 3
|
||||
return Array.prototype.some.call(str, function (_, start) {
|
||||
var partStr = str.substring(start);
|
||||
|
||||
return _this3.restoreByAfter(partStr);
|
||||
});
|
||||
};
|
||||
|
||||
this.stop = function () {
|
||||
if (_this3.autoStepTimer) {
|
||||
clearTimeout(_this3.autoStepTimer);
|
||||
}
|
||||
};
|
||||
|
||||
this.down = function (e, ratio, recursive) {
|
||||
_this3.pressingUpOrDown = true;
|
||||
_this3.step('down', e, ratio, recursive);
|
||||
};
|
||||
|
||||
this.up = function (e, ratio, recursive) {
|
||||
_this3.pressingUpOrDown = true;
|
||||
_this3.step('up', e, ratio, recursive);
|
||||
};
|
||||
|
||||
this.saveUp = function (node) {
|
||||
_this3.upHandler = node;
|
||||
};
|
||||
|
||||
this.saveDown = function (node) {
|
||||
_this3.downHandler = node;
|
||||
};
|
||||
|
||||
this.saveInput = function (node) {
|
||||
_this3.input = node;
|
||||
};
|
||||
};
|
||||
|
||||
exports['default'] = InputNumber;
|
||||
module.exports = exports['default'];
|
||||
100
web/node_modules/rc-input-number/package.json
generated
vendored
Normal file
100
web/node_modules/rc-input-number/package.json
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
{
|
||||
"_from": "rc-input-number@~4.5.4",
|
||||
"_id": "rc-input-number@4.5.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-AXbL4gtQ1mSQnu6v/JtMv3UbGRCzLvQznmf0a7U/SAtZ8+dCEAqD4JpJhkjv73Wog53eRYhw4l7ApdXflc9ymg==",
|
||||
"_location": "/rc-input-number",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "rc-input-number@~4.5.4",
|
||||
"name": "rc-input-number",
|
||||
"escapedName": "rc-input-number",
|
||||
"rawSpec": "~4.5.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~4.5.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/antd"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/rc-input-number/-/rc-input-number-4.5.6.tgz",
|
||||
"_shasum": "0d52762b0ac39432256e2c6c5c836102f9797c46",
|
||||
"_spec": "rc-input-number@~4.5.4",
|
||||
"_where": "/Users/thilina/TestProjects/icehrm-pro/web/node_modules/antd",
|
||||
"author": {
|
||||
"name": "tsjxyz@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/react-component/input-number/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"config": {
|
||||
"port": 8000,
|
||||
"entry": {
|
||||
"rc-input-number": [
|
||||
"./src/index.js",
|
||||
"./assets/index.less"
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-runtime": "6.x",
|
||||
"classnames": "^2.2.0",
|
||||
"prop-types": "^15.5.7",
|
||||
"rc-util": "^4.5.1",
|
||||
"rmc-feedback": "^2.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "React input-number component",
|
||||
"devDependencies": {
|
||||
"core-js": "^2.5.1",
|
||||
"create-react-class": "^15.6.2",
|
||||
"expect.js": "~0.3.1",
|
||||
"pre-commit": "1.x",
|
||||
"rc-test": "^6.0.1",
|
||||
"rc-tools": "^7.0.2",
|
||||
"react": "^16.0.0",
|
||||
"react-dom": "^16.0.0",
|
||||
"sinon": "^8.0.1"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"es",
|
||||
"assets",
|
||||
"dist"
|
||||
],
|
||||
"homepage": "https://github.com/react-component/input-number",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-component",
|
||||
"react-input-number",
|
||||
"input-number"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/index",
|
||||
"module": "es/index",
|
||||
"name": "rc-input-number",
|
||||
"pre-commit": [
|
||||
"lint"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/react-component/input-number.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rc-tools run build",
|
||||
"chrome-test": "rc-test run chrome-test",
|
||||
"compile": "rc-tools run compile --babel-runtime",
|
||||
"coverage": "rc-test run coverage",
|
||||
"dist": "rc-tools run dist",
|
||||
"gh-pages": "rc-tools run gh-pages",
|
||||
"karma": "rc-test run karma",
|
||||
"lint": "rc-tools run lint",
|
||||
"pub": "rc-tools run pub --babel-runtime",
|
||||
"saucelabs": "rc-test run saucelabs",
|
||||
"start": "rc-tools run server",
|
||||
"test": "rc-test run test"
|
||||
},
|
||||
"version": "4.5.6"
|
||||
}
|
||||
Reference in New Issue
Block a user