first commit
This commit is contained in:
9
frontend/node_modules/rc-input-number/LICENSE.md
generated
vendored
Normal file
9
frontend/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.
|
||||
277
frontend/node_modules/rc-input-number/README.md
generated
vendored
Normal file
277
frontend/node_modules/rc-input-number/README.md
generated
vendored
Normal file
@@ -0,0 +1,277 @@
|
||||
# rc-input-number
|
||||
|
||||
Input number control.
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[![npm download][download-image]][download-url]
|
||||
[![build status][github-actions-image]][github-actions-url]
|
||||
[![Codecov][codecov-image]][codecov-url]
|
||||
[![bundle size][bundlephobia-image]][bundlephobia-url]
|
||||
[![dumi][dumi-image]][dumi-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/master?style=flat-square
|
||||
[travis-url]: https://travis-ci.com/react-component/input-number
|
||||
[github-actions-image]: https://github.com/react-component/input-number/workflows/CI/badge.svg
|
||||
[github-actions-url]: https://github.com/react-component/input-number/actions
|
||||
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/input-number/master.svg?style=flat-square
|
||||
[codecov-url]: https://app.codecov.io/gh/react-component/input-number
|
||||
[david-url]: https://david-dm.org/react-component/input-number
|
||||
[david-image]: https://david-dm.org/react-component/input-number/status.svg?style=flat-square
|
||||
[david-dev-url]: https://david-dm.org/react-component/input-number?type=dev
|
||||
[david-dev-image]: https://david-dm.org/react-component/input-number/dev-status.svg?style=flat-square
|
||||
[download-image]: https://img.shields.io/npm/dm/rc-input-number.svg?style=flat-square
|
||||
[download-url]: https://npmjs.org/package/rc-input-number
|
||||
[bundlephobia-url]: https://bundlephobia.com/package/rc-input-number
|
||||
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-input-number
|
||||
[dumi-url]: https://github.com/umijs/dumi
|
||||
[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square
|
||||
|
||||
## Screenshots
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/507615/83162463-61414a80-a13c-11ea-9420-971f8697d490.png" width="288"/>
|
||||
|
||||
## Install
|
||||
|
||||
[](https://npmjs.org/package/rc-input-number)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import InputNumber from 'rc-input-number';
|
||||
|
||||
export default () => <InputNumber defaultValue={10} />;
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
```
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
http://127.0.0.1:8000/examples/
|
||||
|
||||
online example: https://input-number.vercel.app/
|
||||
|
||||
## 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>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>controls</td>
|
||||
<td>Boolean</td>
|
||||
<td>true</td>
|
||||
<td>Whether to enable the control buttons</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>onBlur</td>
|
||||
<td>Function</td>
|
||||
<td></td>
|
||||
<td>Called when user leaves an input field</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>
|
||||
<tr>
|
||||
<td>wheel</td>
|
||||
<td>Boolean</td>
|
||||
<td>true</td>
|
||||
<td>Allows changing value with mouse wheel</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`
|
||||
|
||||
## Mouse Wheel
|
||||
* When you scroll up or down, the input value will be increased or decreased by `step`
|
||||
* Scrolling with the <kbd>Shift</kbd> key, the input value will be changed by `10 * 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
frontend/node_modules/rc-input-number/assets/index.css
generated
vendored
Normal file
110
frontend/node_modules/rc-input-number/assets/index.css
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
.rc-input-number {
|
||||
display: inline-block;
|
||||
height: 26px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 12px;
|
||||
line-height: 26px;
|
||||
vertical-align: middle;
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 4px;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
.rc-input-number-focused {
|
||||
border-color: #1890ff;
|
||||
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
||||
}
|
||||
.rc-input-number-out-of-range input {
|
||||
color: red;
|
||||
}
|
||||
.rc-input-number-handler {
|
||||
display: block;
|
||||
height: 12px;
|
||||
overflow: hidden;
|
||||
line-height: 12px;
|
||||
text-align: center;
|
||||
touch-action: none;
|
||||
}
|
||||
.rc-input-number-handler-active {
|
||||
background: #ddd;
|
||||
}
|
||||
.rc-input-number-handler-up-inner,
|
||||
.rc-input-number-handler-down-inner {
|
||||
color: #666666;
|
||||
-webkit-user-select: none;
|
||||
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 {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.rc-input-number-input {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
color: #666666;
|
||||
line-height: 26px;
|
||||
text-align: center;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
outline: 0;
|
||||
transition: all 0.3s ease;
|
||||
transition: all 0.3s;
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
.rc-input-number-handler-wrap {
|
||||
float: right;
|
||||
width: 20px;
|
||||
height: 100%;
|
||||
border-left: 1px solid #d9d9d9;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
.rc-input-number-handler-up {
|
||||
padding-top: 1px;
|
||||
border-bottom: 1px solid #d9d9d9;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
.rc-input-number-handler-up-inner:after {
|
||||
content: '+';
|
||||
}
|
||||
.rc-input-number-handler-down {
|
||||
transition: all 0.3s;
|
||||
}
|
||||
.rc-input-number-handler-down-inner:after {
|
||||
content: '-';
|
||||
}
|
||||
.rc-input-number-handler-down-disabled,
|
||||
.rc-input-number-handler-up-disabled {
|
||||
opacity: 0.3;
|
||||
}
|
||||
.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 {
|
||||
background-color: #f3f3f3;
|
||||
cursor: not-allowed;
|
||||
opacity: 0.72;
|
||||
}
|
||||
.rc-input-number-disabled .rc-input-number-handler {
|
||||
opacity: 0.3;
|
||||
}
|
||||
.rc-input-number-disabled .rc-input-number-handler:hover {
|
||||
color: #999;
|
||||
border-color: #d9d9d9;
|
||||
}
|
||||
66
frontend/node_modules/rc-input-number/es/InputNumber.d.ts
generated
vendored
Normal file
66
frontend/node_modules/rc-input-number/es/InputNumber.d.ts
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
import { ValueType } from '@rc-component/mini-decimal';
|
||||
import * as React from 'react';
|
||||
import { BaseInputProps } from 'rc-input/lib/interface';
|
||||
import { InputFocusOptions } from 'rc-input/lib/utils/commonUtils';
|
||||
export type { ValueType };
|
||||
export interface InputNumberRef extends HTMLInputElement {
|
||||
focus: (options?: InputFocusOptions) => void;
|
||||
blur: () => void;
|
||||
nativeElement: HTMLElement;
|
||||
}
|
||||
export interface InputNumberProps<T extends ValueType = ValueType> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onInput' | 'onChange' | 'prefix' | 'suffix'> {
|
||||
/** value will show as string */
|
||||
stringMode?: boolean;
|
||||
defaultValue?: T;
|
||||
value?: T | null;
|
||||
prefixCls?: string;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
min?: T;
|
||||
max?: T;
|
||||
step?: ValueType;
|
||||
tabIndex?: number;
|
||||
controls?: boolean;
|
||||
prefix?: React.ReactNode;
|
||||
suffix?: React.ReactNode;
|
||||
addonBefore?: React.ReactNode;
|
||||
addonAfter?: React.ReactNode;
|
||||
classNames?: BaseInputProps['classNames'] & {
|
||||
input?: string;
|
||||
};
|
||||
upHandler?: React.ReactNode;
|
||||
downHandler?: React.ReactNode;
|
||||
keyboard?: boolean;
|
||||
changeOnWheel?: boolean;
|
||||
/** Parse display value to validate number */
|
||||
parser?: (displayValue: string | undefined) => T;
|
||||
/** Transform `value` to display value show in input */
|
||||
formatter?: (value: T | undefined, info: {
|
||||
userTyping: boolean;
|
||||
input: string;
|
||||
}) => string;
|
||||
/** Syntactic sugar of `formatter`. Config precision of display. */
|
||||
precision?: number;
|
||||
/** Syntactic sugar of `formatter`. Config decimal separator of display. */
|
||||
decimalSeparator?: string;
|
||||
onInput?: (text: string) => void;
|
||||
onChange?: (value: T | null) => void;
|
||||
onPressEnter?: React.KeyboardEventHandler<HTMLInputElement>;
|
||||
onStep?: (value: T, info: {
|
||||
offset: ValueType;
|
||||
type: 'up' | 'down';
|
||||
}) => void;
|
||||
/**
|
||||
* Trigger change onBlur event.
|
||||
* If disabled, user must press enter or click handler to confirm the value update
|
||||
*/
|
||||
changeOnBlur?: boolean;
|
||||
}
|
||||
declare const InputNumber: (<T extends ValueType = ValueType>(props: InputNumberProps<T> & {
|
||||
children?: React.ReactNode;
|
||||
} & {
|
||||
ref?: React.Ref<HTMLInputElement>;
|
||||
}) => React.ReactElement) & {
|
||||
displayName?: string;
|
||||
};
|
||||
export default InputNumber;
|
||||
574
frontend/node_modules/rc-input-number/es/InputNumber.js
generated
vendored
Normal file
574
frontend/node_modules/rc-input-number/es/InputNumber.js
generated
vendored
Normal file
@@ -0,0 +1,574 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
var _excluded = ["prefixCls", "className", "style", "min", "max", "step", "defaultValue", "value", "disabled", "readOnly", "upHandler", "downHandler", "keyboard", "changeOnWheel", "controls", "classNames", "stringMode", "parser", "formatter", "precision", "decimalSeparator", "onChange", "onInput", "onPressEnter", "onStep", "changeOnBlur", "domRef"],
|
||||
_excluded2 = ["disabled", "style", "prefixCls", "value", "prefix", "suffix", "addonBefore", "addonAfter", "className", "classNames"];
|
||||
import getMiniDecimal, { getNumberPrecision, num2str, toFixed, validateNumber } from '@rc-component/mini-decimal';
|
||||
import clsx from 'classnames';
|
||||
import { BaseInput } from 'rc-input';
|
||||
import { useLayoutUpdateEffect } from "rc-util/es/hooks/useLayoutEffect";
|
||||
import proxyObject from "rc-util/es/proxyObject";
|
||||
import { composeRef } from "rc-util/es/ref";
|
||||
import * as React from 'react';
|
||||
import useCursor from "./hooks/useCursor";
|
||||
import StepHandler from "./StepHandler";
|
||||
import { getDecupleSteps } from "./utils/numberUtil";
|
||||
import { triggerFocus } from "rc-input/es/utils/commonUtils";
|
||||
import useFrame from "./hooks/useFrame";
|
||||
/**
|
||||
* We support `stringMode` which need handle correct type when user call in onChange
|
||||
* format max or min value
|
||||
* 1. if isInvalid return null
|
||||
* 2. if precision is undefined, return decimal
|
||||
* 3. format with precision
|
||||
* I. if max > 0, round down with precision. Example: max= 3.5, precision=0 afterFormat: 3
|
||||
* II. if max < 0, round up with precision. Example: max= -3.5, precision=0 afterFormat: -4
|
||||
* III. if min > 0, round up with precision. Example: min= 3.5, precision=0 afterFormat: 4
|
||||
* IV. if min < 0, round down with precision. Example: max= -3.5, precision=0 afterFormat: -3
|
||||
*/
|
||||
var getDecimalValue = function getDecimalValue(stringMode, decimalValue) {
|
||||
if (stringMode || decimalValue.isEmpty()) {
|
||||
return decimalValue.toString();
|
||||
}
|
||||
return decimalValue.toNumber();
|
||||
};
|
||||
var getDecimalIfValidate = function getDecimalIfValidate(value) {
|
||||
var decimal = getMiniDecimal(value);
|
||||
return decimal.isInvalidate() ? null : decimal;
|
||||
};
|
||||
var InternalInputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
var prefixCls = props.prefixCls,
|
||||
className = props.className,
|
||||
style = props.style,
|
||||
min = props.min,
|
||||
max = props.max,
|
||||
_props$step = props.step,
|
||||
step = _props$step === void 0 ? 1 : _props$step,
|
||||
defaultValue = props.defaultValue,
|
||||
value = props.value,
|
||||
disabled = props.disabled,
|
||||
readOnly = props.readOnly,
|
||||
upHandler = props.upHandler,
|
||||
downHandler = props.downHandler,
|
||||
keyboard = props.keyboard,
|
||||
_props$changeOnWheel = props.changeOnWheel,
|
||||
changeOnWheel = _props$changeOnWheel === void 0 ? false : _props$changeOnWheel,
|
||||
_props$controls = props.controls,
|
||||
controls = _props$controls === void 0 ? true : _props$controls,
|
||||
classNames = props.classNames,
|
||||
stringMode = props.stringMode,
|
||||
parser = props.parser,
|
||||
formatter = props.formatter,
|
||||
precision = props.precision,
|
||||
decimalSeparator = props.decimalSeparator,
|
||||
onChange = props.onChange,
|
||||
onInput = props.onInput,
|
||||
onPressEnter = props.onPressEnter,
|
||||
onStep = props.onStep,
|
||||
_props$changeOnBlur = props.changeOnBlur,
|
||||
changeOnBlur = _props$changeOnBlur === void 0 ? true : _props$changeOnBlur,
|
||||
domRef = props.domRef,
|
||||
inputProps = _objectWithoutProperties(props, _excluded);
|
||||
var inputClassName = "".concat(prefixCls, "-input");
|
||||
var inputRef = React.useRef(null);
|
||||
var _React$useState = React.useState(false),
|
||||
_React$useState2 = _slicedToArray(_React$useState, 2),
|
||||
focus = _React$useState2[0],
|
||||
setFocus = _React$useState2[1];
|
||||
var userTypingRef = React.useRef(false);
|
||||
var compositionRef = React.useRef(false);
|
||||
var shiftKeyRef = React.useRef(false);
|
||||
|
||||
// ============================ Value =============================
|
||||
// Real value control
|
||||
var _React$useState3 = React.useState(function () {
|
||||
return getMiniDecimal(value !== null && value !== void 0 ? value : defaultValue);
|
||||
}),
|
||||
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
||||
decimalValue = _React$useState4[0],
|
||||
setDecimalValue = _React$useState4[1];
|
||||
function setUncontrolledDecimalValue(newDecimal) {
|
||||
if (value === undefined) {
|
||||
setDecimalValue(newDecimal);
|
||||
}
|
||||
}
|
||||
|
||||
// ====================== Parser & Formatter ======================
|
||||
/**
|
||||
* `precision` is used for formatter & onChange.
|
||||
* It will auto generate by `value` & `step`.
|
||||
* But it will not block user typing.
|
||||
*
|
||||
* Note: Auto generate `precision` is used for legacy logic.
|
||||
* We should remove this since we already support high precision with BigInt.
|
||||
*
|
||||
* @param number Provide which number should calculate precision
|
||||
* @param userTyping Change by user typing
|
||||
*/
|
||||
var getPrecision = React.useCallback(function (numStr, userTyping) {
|
||||
if (userTyping) {
|
||||
return undefined;
|
||||
}
|
||||
if (precision >= 0) {
|
||||
return precision;
|
||||
}
|
||||
return Math.max(getNumberPrecision(numStr), getNumberPrecision(step));
|
||||
}, [precision, step]);
|
||||
|
||||
// >>> Parser
|
||||
var mergedParser = React.useCallback(function (num) {
|
||||
var numStr = String(num);
|
||||
if (parser) {
|
||||
return parser(numStr);
|
||||
}
|
||||
var parsedStr = numStr;
|
||||
if (decimalSeparator) {
|
||||
parsedStr = parsedStr.replace(decimalSeparator, '.');
|
||||
}
|
||||
|
||||
// [Legacy] We still support auto convert `$ 123,456` to `123456`
|
||||
return parsedStr.replace(/[^\w.-]+/g, '');
|
||||
}, [parser, decimalSeparator]);
|
||||
|
||||
// >>> Formatter
|
||||
var inputValueRef = React.useRef('');
|
||||
var mergedFormatter = React.useCallback(function (number, userTyping) {
|
||||
if (formatter) {
|
||||
return formatter(number, {
|
||||
userTyping: userTyping,
|
||||
input: String(inputValueRef.current)
|
||||
});
|
||||
}
|
||||
var str = typeof number === 'number' ? num2str(number) : number;
|
||||
|
||||
// User typing will not auto format with precision directly
|
||||
if (!userTyping) {
|
||||
var mergedPrecision = getPrecision(str, userTyping);
|
||||
if (validateNumber(str) && (decimalSeparator || mergedPrecision >= 0)) {
|
||||
// Separator
|
||||
var separatorStr = decimalSeparator || '.';
|
||||
str = toFixed(str, separatorStr, mergedPrecision);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}, [formatter, getPrecision, decimalSeparator]);
|
||||
|
||||
// ========================== InputValue ==========================
|
||||
/**
|
||||
* Input text value control
|
||||
*
|
||||
* User can not update input content directly. It updates with follow rules by priority:
|
||||
* 1. controlled `value` changed
|
||||
* * [SPECIAL] Typing like `1.` should not immediately convert to `1`
|
||||
* 2. User typing with format (not precision)
|
||||
* 3. Blur or Enter trigger revalidate
|
||||
*/
|
||||
var _React$useState5 = React.useState(function () {
|
||||
var initValue = defaultValue !== null && defaultValue !== void 0 ? defaultValue : value;
|
||||
if (decimalValue.isInvalidate() && ['string', 'number'].includes(_typeof(initValue))) {
|
||||
return Number.isNaN(initValue) ? '' : initValue;
|
||||
}
|
||||
return mergedFormatter(decimalValue.toString(), false);
|
||||
}),
|
||||
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
||||
inputValue = _React$useState6[0],
|
||||
setInternalInputValue = _React$useState6[1];
|
||||
inputValueRef.current = inputValue;
|
||||
|
||||
// Should always be string
|
||||
function setInputValue(newValue, userTyping) {
|
||||
setInternalInputValue(mergedFormatter(
|
||||
// Invalidate number is sometime passed by external control, we should let it go
|
||||
// Otherwise is controlled by internal interactive logic which check by userTyping
|
||||
// You can ref 'show limited value when input is not focused' test for more info.
|
||||
newValue.isInvalidate() ? newValue.toString(false) : newValue.toString(!userTyping), userTyping));
|
||||
}
|
||||
|
||||
// >>> Max & Min limit
|
||||
var maxDecimal = React.useMemo(function () {
|
||||
return getDecimalIfValidate(max);
|
||||
}, [max, precision]);
|
||||
var minDecimal = React.useMemo(function () {
|
||||
return getDecimalIfValidate(min);
|
||||
}, [min, precision]);
|
||||
var upDisabled = React.useMemo(function () {
|
||||
if (!maxDecimal || !decimalValue || decimalValue.isInvalidate()) {
|
||||
return false;
|
||||
}
|
||||
return maxDecimal.lessEquals(decimalValue);
|
||||
}, [maxDecimal, decimalValue]);
|
||||
var downDisabled = React.useMemo(function () {
|
||||
if (!minDecimal || !decimalValue || decimalValue.isInvalidate()) {
|
||||
return false;
|
||||
}
|
||||
return decimalValue.lessEquals(minDecimal);
|
||||
}, [minDecimal, decimalValue]);
|
||||
|
||||
// Cursor controller
|
||||
var _useCursor = useCursor(inputRef.current, focus),
|
||||
_useCursor2 = _slicedToArray(_useCursor, 2),
|
||||
recordCursor = _useCursor2[0],
|
||||
restoreCursor = _useCursor2[1];
|
||||
|
||||
// ============================= Data =============================
|
||||
/**
|
||||
* Find target value closet within range.
|
||||
* e.g. [11, 28]:
|
||||
* 3 => 11
|
||||
* 23 => 23
|
||||
* 99 => 28
|
||||
*/
|
||||
var getRangeValue = function getRangeValue(target) {
|
||||
// target > max
|
||||
if (maxDecimal && !target.lessEquals(maxDecimal)) {
|
||||
return maxDecimal;
|
||||
}
|
||||
|
||||
// target < min
|
||||
if (minDecimal && !minDecimal.lessEquals(target)) {
|
||||
return minDecimal;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check value is in [min, max] range
|
||||
*/
|
||||
var isInRange = function isInRange(target) {
|
||||
return !getRangeValue(target);
|
||||
};
|
||||
|
||||
/**
|
||||
* Trigger `onChange` if value validated and not equals of origin.
|
||||
* Return the value that re-align in range.
|
||||
*/
|
||||
var triggerValueUpdate = function triggerValueUpdate(newValue, userTyping) {
|
||||
var updateValue = newValue;
|
||||
var isRangeValidate = isInRange(updateValue) || updateValue.isEmpty();
|
||||
|
||||
// Skip align value when trigger value is empty.
|
||||
// We just trigger onChange(null)
|
||||
// This should not block user typing
|
||||
if (!updateValue.isEmpty() && !userTyping) {
|
||||
// Revert value in range if needed
|
||||
updateValue = getRangeValue(updateValue) || updateValue;
|
||||
isRangeValidate = true;
|
||||
}
|
||||
if (!readOnly && !disabled && isRangeValidate) {
|
||||
var numStr = updateValue.toString();
|
||||
var mergedPrecision = getPrecision(numStr, userTyping);
|
||||
if (mergedPrecision >= 0) {
|
||||
updateValue = getMiniDecimal(toFixed(numStr, '.', mergedPrecision));
|
||||
|
||||
// When to fixed. The value may out of min & max range.
|
||||
// 4 in [0, 3.8] => 3.8 => 4 (toFixed)
|
||||
if (!isInRange(updateValue)) {
|
||||
updateValue = getMiniDecimal(toFixed(numStr, '.', mergedPrecision, true));
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger event
|
||||
if (!updateValue.equals(decimalValue)) {
|
||||
setUncontrolledDecimalValue(updateValue);
|
||||
onChange === null || onChange === void 0 || onChange(updateValue.isEmpty() ? null : getDecimalValue(stringMode, updateValue));
|
||||
|
||||
// Reformat input if value is not controlled
|
||||
if (value === undefined) {
|
||||
setInputValue(updateValue, userTyping);
|
||||
}
|
||||
}
|
||||
return updateValue;
|
||||
}
|
||||
return decimalValue;
|
||||
};
|
||||
|
||||
// ========================== User Input ==========================
|
||||
var onNextPromise = useFrame();
|
||||
|
||||
// >>> Collect input value
|
||||
var collectInputValue = function collectInputValue(inputStr) {
|
||||
recordCursor();
|
||||
|
||||
// Update inputValue in case input can not parse as number
|
||||
// Refresh ref value immediately since it may used by formatter
|
||||
inputValueRef.current = inputStr;
|
||||
setInternalInputValue(inputStr);
|
||||
|
||||
// Parse number
|
||||
if (!compositionRef.current) {
|
||||
var finalValue = mergedParser(inputStr);
|
||||
var finalDecimal = getMiniDecimal(finalValue);
|
||||
if (!finalDecimal.isNaN()) {
|
||||
triggerValueUpdate(finalDecimal, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger onInput later to let user customize value if they want to handle something after onChange
|
||||
onInput === null || onInput === void 0 || onInput(inputStr);
|
||||
|
||||
// optimize for chinese input experience
|
||||
// https://github.com/ant-design/ant-design/issues/8196
|
||||
onNextPromise(function () {
|
||||
var nextInputStr = inputStr;
|
||||
if (!parser) {
|
||||
nextInputStr = inputStr.replace(/。/g, '.');
|
||||
}
|
||||
if (nextInputStr !== inputStr) {
|
||||
collectInputValue(nextInputStr);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// >>> Composition
|
||||
var onCompositionStart = function onCompositionStart() {
|
||||
compositionRef.current = true;
|
||||
};
|
||||
var onCompositionEnd = function onCompositionEnd() {
|
||||
compositionRef.current = false;
|
||||
collectInputValue(inputRef.current.value);
|
||||
};
|
||||
|
||||
// >>> Input
|
||||
var onInternalInput = function onInternalInput(e) {
|
||||
collectInputValue(e.target.value);
|
||||
};
|
||||
|
||||
// ============================= Step =============================
|
||||
var onInternalStep = function onInternalStep(up) {
|
||||
var _inputRef$current;
|
||||
// Ignore step since out of range
|
||||
if (up && upDisabled || !up && downDisabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear typing status since it may be caused by up & down key.
|
||||
// We should sync with input value.
|
||||
userTypingRef.current = false;
|
||||
var stepDecimal = getMiniDecimal(shiftKeyRef.current ? getDecupleSteps(step) : step);
|
||||
if (!up) {
|
||||
stepDecimal = stepDecimal.negate();
|
||||
}
|
||||
var target = (decimalValue || getMiniDecimal(0)).add(stepDecimal.toString());
|
||||
var updatedValue = triggerValueUpdate(target, false);
|
||||
onStep === null || onStep === void 0 || onStep(getDecimalValue(stringMode, updatedValue), {
|
||||
offset: shiftKeyRef.current ? getDecupleSteps(step) : step,
|
||||
type: up ? 'up' : 'down'
|
||||
});
|
||||
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
|
||||
};
|
||||
|
||||
// ============================ Flush =============================
|
||||
/**
|
||||
* Flush current input content to trigger value change & re-formatter input if needed.
|
||||
* This will always flush input value for update.
|
||||
* If it's invalidate, will fallback to last validate value.
|
||||
*/
|
||||
var flushInputValue = function flushInputValue(userTyping) {
|
||||
var parsedValue = getMiniDecimal(mergedParser(inputValue));
|
||||
var formatValue;
|
||||
if (!parsedValue.isNaN()) {
|
||||
// Only validate value or empty value can be re-fill to inputValue
|
||||
// Reassign the formatValue within ranged of trigger control
|
||||
formatValue = triggerValueUpdate(parsedValue, userTyping);
|
||||
} else {
|
||||
formatValue = triggerValueUpdate(decimalValue, userTyping);
|
||||
}
|
||||
if (value !== undefined) {
|
||||
// Reset back with controlled value first
|
||||
setInputValue(decimalValue, false);
|
||||
} else if (!formatValue.isNaN()) {
|
||||
// Reset input back since no validate value
|
||||
setInputValue(formatValue, false);
|
||||
}
|
||||
};
|
||||
|
||||
// Solve the issue of the event triggering sequence when entering numbers in chinese input (Safari)
|
||||
var onBeforeInput = function onBeforeInput() {
|
||||
userTypingRef.current = true;
|
||||
};
|
||||
var onKeyDown = function onKeyDown(event) {
|
||||
var key = event.key,
|
||||
shiftKey = event.shiftKey;
|
||||
userTypingRef.current = true;
|
||||
shiftKeyRef.current = shiftKey;
|
||||
if (key === 'Enter') {
|
||||
if (!compositionRef.current) {
|
||||
userTypingRef.current = false;
|
||||
}
|
||||
flushInputValue(false);
|
||||
onPressEnter === null || onPressEnter === void 0 || onPressEnter(event);
|
||||
}
|
||||
if (keyboard === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Do step
|
||||
if (!compositionRef.current && ['Up', 'ArrowUp', 'Down', 'ArrowDown'].includes(key)) {
|
||||
onInternalStep(key === 'Up' || key === 'ArrowUp');
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
var onKeyUp = function onKeyUp() {
|
||||
userTypingRef.current = false;
|
||||
shiftKeyRef.current = false;
|
||||
};
|
||||
React.useEffect(function () {
|
||||
if (changeOnWheel && focus) {
|
||||
var onWheel = function onWheel(event) {
|
||||
// moving mouse wheel rises wheel event with deltaY < 0
|
||||
// scroll value grows from top to bottom, as screen Y coordinate
|
||||
onInternalStep(event.deltaY < 0);
|
||||
event.preventDefault();
|
||||
};
|
||||
var input = inputRef.current;
|
||||
if (input) {
|
||||
// React onWheel is passive and we can't preventDefault() in it.
|
||||
// That's why we should subscribe with DOM listener
|
||||
// https://stackoverflow.com/questions/63663025/react-onwheel-handler-cant-preventdefault-because-its-a-passive-event-listenev
|
||||
input.addEventListener('wheel', onWheel, {
|
||||
passive: false
|
||||
});
|
||||
return function () {
|
||||
return input.removeEventListener('wheel', onWheel);
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// >>> Focus & Blur
|
||||
var onBlur = function onBlur() {
|
||||
if (changeOnBlur) {
|
||||
flushInputValue(false);
|
||||
}
|
||||
setFocus(false);
|
||||
userTypingRef.current = false;
|
||||
};
|
||||
|
||||
// ========================== Controlled ==========================
|
||||
// Input by precision & formatter
|
||||
useLayoutUpdateEffect(function () {
|
||||
if (!decimalValue.isInvalidate()) {
|
||||
setInputValue(decimalValue, false);
|
||||
}
|
||||
}, [precision, formatter]);
|
||||
|
||||
// Input by value
|
||||
useLayoutUpdateEffect(function () {
|
||||
var newValue = getMiniDecimal(value);
|
||||
setDecimalValue(newValue);
|
||||
var currentParsedValue = getMiniDecimal(mergedParser(inputValue));
|
||||
|
||||
// When user typing from `1.2` to `1.`, we should not convert to `1` immediately.
|
||||
// But let it go if user set `formatter`
|
||||
if (!newValue.equals(currentParsedValue) || !userTypingRef.current || formatter) {
|
||||
// Update value as effect
|
||||
setInputValue(newValue, userTypingRef.current);
|
||||
}
|
||||
}, [value]);
|
||||
|
||||
// ============================ Cursor ============================
|
||||
useLayoutUpdateEffect(function () {
|
||||
if (formatter) {
|
||||
restoreCursor();
|
||||
}
|
||||
}, [inputValue]);
|
||||
|
||||
// ============================ Render ============================
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
ref: domRef,
|
||||
className: clsx(prefixCls, className, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-focused"), focus), "".concat(prefixCls, "-disabled"), disabled), "".concat(prefixCls, "-readonly"), readOnly), "".concat(prefixCls, "-not-a-number"), decimalValue.isNaN()), "".concat(prefixCls, "-out-of-range"), !decimalValue.isInvalidate() && !isInRange(decimalValue))),
|
||||
style: style,
|
||||
onFocus: function onFocus() {
|
||||
setFocus(true);
|
||||
},
|
||||
onBlur: onBlur,
|
||||
onKeyDown: onKeyDown,
|
||||
onKeyUp: onKeyUp,
|
||||
onCompositionStart: onCompositionStart,
|
||||
onCompositionEnd: onCompositionEnd,
|
||||
onBeforeInput: onBeforeInput
|
||||
}, controls && /*#__PURE__*/React.createElement(StepHandler, {
|
||||
prefixCls: prefixCls,
|
||||
upNode: upHandler,
|
||||
downNode: downHandler,
|
||||
upDisabled: upDisabled,
|
||||
downDisabled: downDisabled,
|
||||
onStep: onInternalStep
|
||||
}), /*#__PURE__*/React.createElement("div", {
|
||||
className: "".concat(inputClassName, "-wrap")
|
||||
}, /*#__PURE__*/React.createElement("input", _extends({
|
||||
autoComplete: "off",
|
||||
role: "spinbutton",
|
||||
"aria-valuemin": min,
|
||||
"aria-valuemax": max,
|
||||
"aria-valuenow": decimalValue.isInvalidate() ? null : decimalValue.toString(),
|
||||
step: step
|
||||
}, inputProps, {
|
||||
ref: composeRef(inputRef, ref),
|
||||
className: inputClassName,
|
||||
value: inputValue,
|
||||
onChange: onInternalInput,
|
||||
disabled: disabled,
|
||||
readOnly: readOnly
|
||||
}))));
|
||||
});
|
||||
var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
var disabled = props.disabled,
|
||||
style = props.style,
|
||||
_props$prefixCls = props.prefixCls,
|
||||
prefixCls = _props$prefixCls === void 0 ? 'rc-input-number' : _props$prefixCls,
|
||||
value = props.value,
|
||||
prefix = props.prefix,
|
||||
suffix = props.suffix,
|
||||
addonBefore = props.addonBefore,
|
||||
addonAfter = props.addonAfter,
|
||||
className = props.className,
|
||||
classNames = props.classNames,
|
||||
rest = _objectWithoutProperties(props, _excluded2);
|
||||
var holderRef = React.useRef(null);
|
||||
var inputNumberDomRef = React.useRef(null);
|
||||
var inputFocusRef = React.useRef(null);
|
||||
var focus = function focus(option) {
|
||||
if (inputFocusRef.current) {
|
||||
triggerFocus(inputFocusRef.current, option);
|
||||
}
|
||||
};
|
||||
React.useImperativeHandle(ref, function () {
|
||||
return proxyObject(inputFocusRef.current, {
|
||||
focus: focus,
|
||||
nativeElement: holderRef.current.nativeElement || inputNumberDomRef.current
|
||||
});
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(BaseInput, {
|
||||
className: className,
|
||||
triggerFocus: focus,
|
||||
prefixCls: prefixCls,
|
||||
value: value,
|
||||
disabled: disabled,
|
||||
style: style,
|
||||
prefix: prefix,
|
||||
suffix: suffix,
|
||||
addonAfter: addonAfter,
|
||||
addonBefore: addonBefore,
|
||||
classNames: classNames,
|
||||
components: {
|
||||
affixWrapper: 'div',
|
||||
groupWrapper: 'div',
|
||||
wrapper: 'div',
|
||||
groupAddon: 'div'
|
||||
},
|
||||
ref: holderRef
|
||||
}, /*#__PURE__*/React.createElement(InternalInputNumber, _extends({
|
||||
prefixCls: prefixCls,
|
||||
disabled: disabled,
|
||||
ref: inputFocusRef,
|
||||
domRef: inputNumberDomRef,
|
||||
className: classNames === null || classNames === void 0 ? void 0 : classNames.input
|
||||
}, rest)));
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
InputNumber.displayName = 'InputNumber';
|
||||
}
|
||||
export default InputNumber;
|
||||
10
frontend/node_modules/rc-input-number/es/StepHandler.d.ts
generated
vendored
Normal file
10
frontend/node_modules/rc-input-number/es/StepHandler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as React from 'react';
|
||||
export interface StepHandlerProps {
|
||||
prefixCls: string;
|
||||
upNode?: React.ReactNode;
|
||||
downNode?: React.ReactNode;
|
||||
upDisabled?: boolean;
|
||||
downDisabled?: boolean;
|
||||
onStep: (up: boolean) => void;
|
||||
}
|
||||
export default function StepHandler({ prefixCls, upNode, downNode, upDisabled, downDisabled, onStep, }: StepHandlerProps): React.JSX.Element;
|
||||
104
frontend/node_modules/rc-input-number/es/StepHandler.js
generated
vendored
Normal file
104
frontend/node_modules/rc-input-number/es/StepHandler.js
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
/* eslint-disable react/no-unknown-property */
|
||||
import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import useMobile from "rc-util/es/hooks/useMobile";
|
||||
import raf from "rc-util/es/raf";
|
||||
|
||||
/**
|
||||
* When click and hold on a button - the speed of auto changing the value.
|
||||
*/
|
||||
var STEP_INTERVAL = 200;
|
||||
|
||||
/**
|
||||
* When click and hold on a button - the delay before auto changing the value.
|
||||
*/
|
||||
var STEP_DELAY = 600;
|
||||
export default function StepHandler(_ref) {
|
||||
var prefixCls = _ref.prefixCls,
|
||||
upNode = _ref.upNode,
|
||||
downNode = _ref.downNode,
|
||||
upDisabled = _ref.upDisabled,
|
||||
downDisabled = _ref.downDisabled,
|
||||
onStep = _ref.onStep;
|
||||
// ======================== Step ========================
|
||||
var stepTimeoutRef = React.useRef();
|
||||
var frameIds = React.useRef([]);
|
||||
var onStepRef = React.useRef();
|
||||
onStepRef.current = onStep;
|
||||
var onStopStep = function onStopStep() {
|
||||
clearTimeout(stepTimeoutRef.current);
|
||||
};
|
||||
|
||||
// We will interval update step when hold mouse down
|
||||
var onStepMouseDown = function onStepMouseDown(e, up) {
|
||||
e.preventDefault();
|
||||
onStopStep();
|
||||
onStepRef.current(up);
|
||||
|
||||
// Loop step for interval
|
||||
function loopStep() {
|
||||
onStepRef.current(up);
|
||||
stepTimeoutRef.current = setTimeout(loopStep, STEP_INTERVAL);
|
||||
}
|
||||
|
||||
// First time press will wait some time to trigger loop step update
|
||||
stepTimeoutRef.current = setTimeout(loopStep, STEP_DELAY);
|
||||
};
|
||||
React.useEffect(function () {
|
||||
return function () {
|
||||
onStopStep();
|
||||
frameIds.current.forEach(function (id) {
|
||||
return raf.cancel(id);
|
||||
});
|
||||
};
|
||||
}, []);
|
||||
|
||||
// ======================= Render =======================
|
||||
var isMobile = useMobile();
|
||||
if (isMobile) {
|
||||
return null;
|
||||
}
|
||||
var handlerClassName = "".concat(prefixCls, "-handler");
|
||||
var upClassName = classNames(handlerClassName, "".concat(handlerClassName, "-up"), _defineProperty({}, "".concat(handlerClassName, "-up-disabled"), upDisabled));
|
||||
var downClassName = classNames(handlerClassName, "".concat(handlerClassName, "-down"), _defineProperty({}, "".concat(handlerClassName, "-down-disabled"), downDisabled));
|
||||
|
||||
// fix: https://github.com/ant-design/ant-design/issues/43088
|
||||
// In Safari, When we fire onmousedown and onmouseup events in quick succession,
|
||||
// there may be a problem that the onmouseup events are executed first,
|
||||
// resulting in a disordered program execution.
|
||||
// So, we need to use requestAnimationFrame to ensure that the onmouseup event is executed after the onmousedown event.
|
||||
var safeOnStopStep = function safeOnStopStep() {
|
||||
return frameIds.current.push(raf(onStopStep));
|
||||
};
|
||||
var sharedHandlerProps = {
|
||||
unselectable: 'on',
|
||||
role: 'button',
|
||||
onMouseUp: safeOnStopStep,
|
||||
onMouseLeave: safeOnStopStep
|
||||
};
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
className: "".concat(handlerClassName, "-wrap")
|
||||
}, /*#__PURE__*/React.createElement("span", _extends({}, sharedHandlerProps, {
|
||||
onMouseDown: function onMouseDown(e) {
|
||||
onStepMouseDown(e, true);
|
||||
},
|
||||
"aria-label": "Increase Value",
|
||||
"aria-disabled": upDisabled,
|
||||
className: upClassName
|
||||
}), upNode || /*#__PURE__*/React.createElement("span", {
|
||||
unselectable: "on",
|
||||
className: "".concat(prefixCls, "-handler-up-inner")
|
||||
})), /*#__PURE__*/React.createElement("span", _extends({}, sharedHandlerProps, {
|
||||
onMouseDown: function onMouseDown(e) {
|
||||
onStepMouseDown(e, false);
|
||||
},
|
||||
"aria-label": "Decrease Value",
|
||||
"aria-disabled": downDisabled,
|
||||
className: downClassName
|
||||
}), downNode || /*#__PURE__*/React.createElement("span", {
|
||||
unselectable: "on",
|
||||
className: "".concat(prefixCls, "-handler-down-inner")
|
||||
})));
|
||||
}
|
||||
5
frontend/node_modules/rc-input-number/es/hooks/useCursor.d.ts
generated
vendored
Normal file
5
frontend/node_modules/rc-input-number/es/hooks/useCursor.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Keep input cursor in the correct position if possible.
|
||||
* Is this necessary since we have `formatter` which may mass the content?
|
||||
*/
|
||||
export default function useCursor(input: HTMLInputElement, focused: boolean): [() => void, () => void];
|
||||
63
frontend/node_modules/rc-input-number/es/hooks/useCursor.js
generated
vendored
Normal file
63
frontend/node_modules/rc-input-number/es/hooks/useCursor.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
import { useRef } from 'react';
|
||||
import warning from "rc-util/es/warning";
|
||||
/**
|
||||
* Keep input cursor in the correct position if possible.
|
||||
* Is this necessary since we have `formatter` which may mass the content?
|
||||
*/
|
||||
export default function useCursor(input, focused) {
|
||||
var selectionRef = useRef(null);
|
||||
function recordCursor() {
|
||||
// Record position
|
||||
try {
|
||||
var start = input.selectionStart,
|
||||
end = input.selectionEnd,
|
||||
value = input.value;
|
||||
var beforeTxt = value.substring(0, start);
|
||||
var afterTxt = value.substring(end);
|
||||
selectionRef.current = {
|
||||
start: start,
|
||||
end: end,
|
||||
value: value,
|
||||
beforeTxt: beforeTxt,
|
||||
afterTxt: afterTxt
|
||||
};
|
||||
} catch (e) {
|
||||
// Fix error in Chrome:
|
||||
// Failed to read the 'selectionStart' property from 'HTMLInputElement'
|
||||
// http://stackoverflow.com/q/21177489/3040605
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore logic:
|
||||
* 1. back string same
|
||||
* 2. start string same
|
||||
*/
|
||||
function restoreCursor() {
|
||||
if (input && selectionRef.current && focused) {
|
||||
try {
|
||||
var value = input.value;
|
||||
var _selectionRef$current = selectionRef.current,
|
||||
beforeTxt = _selectionRef$current.beforeTxt,
|
||||
afterTxt = _selectionRef$current.afterTxt,
|
||||
start = _selectionRef$current.start;
|
||||
var startPos = value.length;
|
||||
if (value.startsWith(beforeTxt)) {
|
||||
startPos = beforeTxt.length;
|
||||
} else if (value.endsWith(afterTxt)) {
|
||||
startPos = value.length - selectionRef.current.afterTxt.length;
|
||||
} else {
|
||||
var beforeLastChar = beforeTxt[start - 1];
|
||||
var newIndex = value.indexOf(beforeLastChar, start - 1);
|
||||
if (newIndex !== -1) {
|
||||
startPos = newIndex + 1;
|
||||
}
|
||||
}
|
||||
input.setSelectionRange(startPos, startPos);
|
||||
} catch (e) {
|
||||
warning(false, "Something warning of cursor restore. Please fire issue about this: ".concat(e.message));
|
||||
}
|
||||
}
|
||||
}
|
||||
return [recordCursor, restoreCursor];
|
||||
}
|
||||
5
frontend/node_modules/rc-input-number/es/hooks/useFrame.d.ts
generated
vendored
Normal file
5
frontend/node_modules/rc-input-number/es/hooks/useFrame.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Always trigger latest once when call multiple time
|
||||
*/
|
||||
declare const _default: () => (callback: () => void) => void;
|
||||
export default _default;
|
||||
21
frontend/node_modules/rc-input-number/es/hooks/useFrame.js
generated
vendored
Normal file
21
frontend/node_modules/rc-input-number/es/hooks/useFrame.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { useRef, useEffect } from 'react';
|
||||
import raf from "rc-util/es/raf";
|
||||
|
||||
/**
|
||||
* Always trigger latest once when call multiple time
|
||||
*/
|
||||
export default (function () {
|
||||
var idRef = useRef(0);
|
||||
var cleanUp = function cleanUp() {
|
||||
raf.cancel(idRef.current);
|
||||
};
|
||||
useEffect(function () {
|
||||
return cleanUp;
|
||||
}, []);
|
||||
return function (callback) {
|
||||
cleanUp();
|
||||
idRef.current = raf(function () {
|
||||
callback();
|
||||
});
|
||||
};
|
||||
});
|
||||
4
frontend/node_modules/rc-input-number/es/index.d.ts
generated
vendored
Normal file
4
frontend/node_modules/rc-input-number/es/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { InputNumberProps, ValueType, InputNumberRef } from './InputNumber';
|
||||
import InputNumber from './InputNumber';
|
||||
export type { InputNumberProps, ValueType, InputNumberRef };
|
||||
export default InputNumber;
|
||||
2
frontend/node_modules/rc-input-number/es/index.js
generated
vendored
Normal file
2
frontend/node_modules/rc-input-number/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import InputNumber from "./InputNumber";
|
||||
export default InputNumber;
|
||||
1
frontend/node_modules/rc-input-number/es/utils/numberUtil.d.ts
generated
vendored
Normal file
1
frontend/node_modules/rc-input-number/es/utils/numberUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function getDecupleSteps(step: string | number): string;
|
||||
9
frontend/node_modules/rc-input-number/es/utils/numberUtil.js
generated
vendored
Normal file
9
frontend/node_modules/rc-input-number/es/utils/numberUtil.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { trimNumber, num2str } from '@rc-component/mini-decimal';
|
||||
export function getDecupleSteps(step) {
|
||||
var stepStr = typeof step === 'number' ? num2str(step) : trimNumber(step).fullStr;
|
||||
var hasPoint = stepStr.includes('.');
|
||||
if (!hasPoint) {
|
||||
return step + '0';
|
||||
}
|
||||
return trimNumber(stepStr.replace(/(\d)\.(\d)/g, '$1$2.')).fullStr;
|
||||
}
|
||||
66
frontend/node_modules/rc-input-number/lib/InputNumber.d.ts
generated
vendored
Normal file
66
frontend/node_modules/rc-input-number/lib/InputNumber.d.ts
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
import { ValueType } from '@rc-component/mini-decimal';
|
||||
import * as React from 'react';
|
||||
import { BaseInputProps } from 'rc-input/lib/interface';
|
||||
import { InputFocusOptions } from 'rc-input/lib/utils/commonUtils';
|
||||
export type { ValueType };
|
||||
export interface InputNumberRef extends HTMLInputElement {
|
||||
focus: (options?: InputFocusOptions) => void;
|
||||
blur: () => void;
|
||||
nativeElement: HTMLElement;
|
||||
}
|
||||
export interface InputNumberProps<T extends ValueType = ValueType> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onInput' | 'onChange' | 'prefix' | 'suffix'> {
|
||||
/** value will show as string */
|
||||
stringMode?: boolean;
|
||||
defaultValue?: T;
|
||||
value?: T | null;
|
||||
prefixCls?: string;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
min?: T;
|
||||
max?: T;
|
||||
step?: ValueType;
|
||||
tabIndex?: number;
|
||||
controls?: boolean;
|
||||
prefix?: React.ReactNode;
|
||||
suffix?: React.ReactNode;
|
||||
addonBefore?: React.ReactNode;
|
||||
addonAfter?: React.ReactNode;
|
||||
classNames?: BaseInputProps['classNames'] & {
|
||||
input?: string;
|
||||
};
|
||||
upHandler?: React.ReactNode;
|
||||
downHandler?: React.ReactNode;
|
||||
keyboard?: boolean;
|
||||
changeOnWheel?: boolean;
|
||||
/** Parse display value to validate number */
|
||||
parser?: (displayValue: string | undefined) => T;
|
||||
/** Transform `value` to display value show in input */
|
||||
formatter?: (value: T | undefined, info: {
|
||||
userTyping: boolean;
|
||||
input: string;
|
||||
}) => string;
|
||||
/** Syntactic sugar of `formatter`. Config precision of display. */
|
||||
precision?: number;
|
||||
/** Syntactic sugar of `formatter`. Config decimal separator of display. */
|
||||
decimalSeparator?: string;
|
||||
onInput?: (text: string) => void;
|
||||
onChange?: (value: T | null) => void;
|
||||
onPressEnter?: React.KeyboardEventHandler<HTMLInputElement>;
|
||||
onStep?: (value: T, info: {
|
||||
offset: ValueType;
|
||||
type: 'up' | 'down';
|
||||
}) => void;
|
||||
/**
|
||||
* Trigger change onBlur event.
|
||||
* If disabled, user must press enter or click handler to confirm the value update
|
||||
*/
|
||||
changeOnBlur?: boolean;
|
||||
}
|
||||
declare const InputNumber: (<T extends ValueType = ValueType>(props: InputNumberProps<T> & {
|
||||
children?: React.ReactNode;
|
||||
} & {
|
||||
ref?: React.Ref<HTMLInputElement>;
|
||||
}) => React.ReactElement) & {
|
||||
displayName?: string;
|
||||
};
|
||||
export default InputNumber;
|
||||
584
frontend/node_modules/rc-input-number/lib/InputNumber.js
generated
vendored
Normal file
584
frontend/node_modules/rc-input-number/lib/InputNumber.js
generated
vendored
Normal file
@@ -0,0 +1,584 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
||||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
||||
var _miniDecimal = _interopRequireWildcard(require("@rc-component/mini-decimal"));
|
||||
var _classnames = _interopRequireDefault(require("classnames"));
|
||||
var _rcInput = require("rc-input");
|
||||
var _useLayoutEffect = require("rc-util/lib/hooks/useLayoutEffect");
|
||||
var _proxyObject = _interopRequireDefault(require("rc-util/lib/proxyObject"));
|
||||
var _ref = require("rc-util/lib/ref");
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _useCursor3 = _interopRequireDefault(require("./hooks/useCursor"));
|
||||
var _StepHandler = _interopRequireDefault(require("./StepHandler"));
|
||||
var _numberUtil = require("./utils/numberUtil");
|
||||
var _commonUtils = require("rc-input/lib/utils/commonUtils");
|
||||
var _useFrame = _interopRequireDefault(require("./hooks/useFrame"));
|
||||
var _excluded = ["prefixCls", "className", "style", "min", "max", "step", "defaultValue", "value", "disabled", "readOnly", "upHandler", "downHandler", "keyboard", "changeOnWheel", "controls", "classNames", "stringMode", "parser", "formatter", "precision", "decimalSeparator", "onChange", "onInput", "onPressEnter", "onStep", "changeOnBlur", "domRef"],
|
||||
_excluded2 = ["disabled", "style", "prefixCls", "value", "prefix", "suffix", "addonBefore", "addonAfter", "className", "classNames"];
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
/**
|
||||
* We support `stringMode` which need handle correct type when user call in onChange
|
||||
* format max or min value
|
||||
* 1. if isInvalid return null
|
||||
* 2. if precision is undefined, return decimal
|
||||
* 3. format with precision
|
||||
* I. if max > 0, round down with precision. Example: max= 3.5, precision=0 afterFormat: 3
|
||||
* II. if max < 0, round up with precision. Example: max= -3.5, precision=0 afterFormat: -4
|
||||
* III. if min > 0, round up with precision. Example: min= 3.5, precision=0 afterFormat: 4
|
||||
* IV. if min < 0, round down with precision. Example: max= -3.5, precision=0 afterFormat: -3
|
||||
*/
|
||||
var getDecimalValue = function getDecimalValue(stringMode, decimalValue) {
|
||||
if (stringMode || decimalValue.isEmpty()) {
|
||||
return decimalValue.toString();
|
||||
}
|
||||
return decimalValue.toNumber();
|
||||
};
|
||||
var getDecimalIfValidate = function getDecimalIfValidate(value) {
|
||||
var decimal = (0, _miniDecimal.default)(value);
|
||||
return decimal.isInvalidate() ? null : decimal;
|
||||
};
|
||||
var InternalInputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
var prefixCls = props.prefixCls,
|
||||
className = props.className,
|
||||
style = props.style,
|
||||
min = props.min,
|
||||
max = props.max,
|
||||
_props$step = props.step,
|
||||
step = _props$step === void 0 ? 1 : _props$step,
|
||||
defaultValue = props.defaultValue,
|
||||
value = props.value,
|
||||
disabled = props.disabled,
|
||||
readOnly = props.readOnly,
|
||||
upHandler = props.upHandler,
|
||||
downHandler = props.downHandler,
|
||||
keyboard = props.keyboard,
|
||||
_props$changeOnWheel = props.changeOnWheel,
|
||||
changeOnWheel = _props$changeOnWheel === void 0 ? false : _props$changeOnWheel,
|
||||
_props$controls = props.controls,
|
||||
controls = _props$controls === void 0 ? true : _props$controls,
|
||||
classNames = props.classNames,
|
||||
stringMode = props.stringMode,
|
||||
parser = props.parser,
|
||||
formatter = props.formatter,
|
||||
precision = props.precision,
|
||||
decimalSeparator = props.decimalSeparator,
|
||||
onChange = props.onChange,
|
||||
onInput = props.onInput,
|
||||
onPressEnter = props.onPressEnter,
|
||||
onStep = props.onStep,
|
||||
_props$changeOnBlur = props.changeOnBlur,
|
||||
changeOnBlur = _props$changeOnBlur === void 0 ? true : _props$changeOnBlur,
|
||||
domRef = props.domRef,
|
||||
inputProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
||||
var inputClassName = "".concat(prefixCls, "-input");
|
||||
var inputRef = React.useRef(null);
|
||||
var _React$useState = React.useState(false),
|
||||
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
|
||||
focus = _React$useState2[0],
|
||||
setFocus = _React$useState2[1];
|
||||
var userTypingRef = React.useRef(false);
|
||||
var compositionRef = React.useRef(false);
|
||||
var shiftKeyRef = React.useRef(false);
|
||||
|
||||
// ============================ Value =============================
|
||||
// Real value control
|
||||
var _React$useState3 = React.useState(function () {
|
||||
return (0, _miniDecimal.default)(value !== null && value !== void 0 ? value : defaultValue);
|
||||
}),
|
||||
_React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
|
||||
decimalValue = _React$useState4[0],
|
||||
setDecimalValue = _React$useState4[1];
|
||||
function setUncontrolledDecimalValue(newDecimal) {
|
||||
if (value === undefined) {
|
||||
setDecimalValue(newDecimal);
|
||||
}
|
||||
}
|
||||
|
||||
// ====================== Parser & Formatter ======================
|
||||
/**
|
||||
* `precision` is used for formatter & onChange.
|
||||
* It will auto generate by `value` & `step`.
|
||||
* But it will not block user typing.
|
||||
*
|
||||
* Note: Auto generate `precision` is used for legacy logic.
|
||||
* We should remove this since we already support high precision with BigInt.
|
||||
*
|
||||
* @param number Provide which number should calculate precision
|
||||
* @param userTyping Change by user typing
|
||||
*/
|
||||
var getPrecision = React.useCallback(function (numStr, userTyping) {
|
||||
if (userTyping) {
|
||||
return undefined;
|
||||
}
|
||||
if (precision >= 0) {
|
||||
return precision;
|
||||
}
|
||||
return Math.max((0, _miniDecimal.getNumberPrecision)(numStr), (0, _miniDecimal.getNumberPrecision)(step));
|
||||
}, [precision, step]);
|
||||
|
||||
// >>> Parser
|
||||
var mergedParser = React.useCallback(function (num) {
|
||||
var numStr = String(num);
|
||||
if (parser) {
|
||||
return parser(numStr);
|
||||
}
|
||||
var parsedStr = numStr;
|
||||
if (decimalSeparator) {
|
||||
parsedStr = parsedStr.replace(decimalSeparator, '.');
|
||||
}
|
||||
|
||||
// [Legacy] We still support auto convert `$ 123,456` to `123456`
|
||||
return parsedStr.replace(/[^\w.-]+/g, '');
|
||||
}, [parser, decimalSeparator]);
|
||||
|
||||
// >>> Formatter
|
||||
var inputValueRef = React.useRef('');
|
||||
var mergedFormatter = React.useCallback(function (number, userTyping) {
|
||||
if (formatter) {
|
||||
return formatter(number, {
|
||||
userTyping: userTyping,
|
||||
input: String(inputValueRef.current)
|
||||
});
|
||||
}
|
||||
var str = typeof number === 'number' ? (0, _miniDecimal.num2str)(number) : number;
|
||||
|
||||
// User typing will not auto format with precision directly
|
||||
if (!userTyping) {
|
||||
var mergedPrecision = getPrecision(str, userTyping);
|
||||
if ((0, _miniDecimal.validateNumber)(str) && (decimalSeparator || mergedPrecision >= 0)) {
|
||||
// Separator
|
||||
var separatorStr = decimalSeparator || '.';
|
||||
str = (0, _miniDecimal.toFixed)(str, separatorStr, mergedPrecision);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}, [formatter, getPrecision, decimalSeparator]);
|
||||
|
||||
// ========================== InputValue ==========================
|
||||
/**
|
||||
* Input text value control
|
||||
*
|
||||
* User can not update input content directly. It updates with follow rules by priority:
|
||||
* 1. controlled `value` changed
|
||||
* * [SPECIAL] Typing like `1.` should not immediately convert to `1`
|
||||
* 2. User typing with format (not precision)
|
||||
* 3. Blur or Enter trigger revalidate
|
||||
*/
|
||||
var _React$useState5 = React.useState(function () {
|
||||
var initValue = defaultValue !== null && defaultValue !== void 0 ? defaultValue : value;
|
||||
if (decimalValue.isInvalidate() && ['string', 'number'].includes((0, _typeof2.default)(initValue))) {
|
||||
return Number.isNaN(initValue) ? '' : initValue;
|
||||
}
|
||||
return mergedFormatter(decimalValue.toString(), false);
|
||||
}),
|
||||
_React$useState6 = (0, _slicedToArray2.default)(_React$useState5, 2),
|
||||
inputValue = _React$useState6[0],
|
||||
setInternalInputValue = _React$useState6[1];
|
||||
inputValueRef.current = inputValue;
|
||||
|
||||
// Should always be string
|
||||
function setInputValue(newValue, userTyping) {
|
||||
setInternalInputValue(mergedFormatter(
|
||||
// Invalidate number is sometime passed by external control, we should let it go
|
||||
// Otherwise is controlled by internal interactive logic which check by userTyping
|
||||
// You can ref 'show limited value when input is not focused' test for more info.
|
||||
newValue.isInvalidate() ? newValue.toString(false) : newValue.toString(!userTyping), userTyping));
|
||||
}
|
||||
|
||||
// >>> Max & Min limit
|
||||
var maxDecimal = React.useMemo(function () {
|
||||
return getDecimalIfValidate(max);
|
||||
}, [max, precision]);
|
||||
var minDecimal = React.useMemo(function () {
|
||||
return getDecimalIfValidate(min);
|
||||
}, [min, precision]);
|
||||
var upDisabled = React.useMemo(function () {
|
||||
if (!maxDecimal || !decimalValue || decimalValue.isInvalidate()) {
|
||||
return false;
|
||||
}
|
||||
return maxDecimal.lessEquals(decimalValue);
|
||||
}, [maxDecimal, decimalValue]);
|
||||
var downDisabled = React.useMemo(function () {
|
||||
if (!minDecimal || !decimalValue || decimalValue.isInvalidate()) {
|
||||
return false;
|
||||
}
|
||||
return decimalValue.lessEquals(minDecimal);
|
||||
}, [minDecimal, decimalValue]);
|
||||
|
||||
// Cursor controller
|
||||
var _useCursor = (0, _useCursor3.default)(inputRef.current, focus),
|
||||
_useCursor2 = (0, _slicedToArray2.default)(_useCursor, 2),
|
||||
recordCursor = _useCursor2[0],
|
||||
restoreCursor = _useCursor2[1];
|
||||
|
||||
// ============================= Data =============================
|
||||
/**
|
||||
* Find target value closet within range.
|
||||
* e.g. [11, 28]:
|
||||
* 3 => 11
|
||||
* 23 => 23
|
||||
* 99 => 28
|
||||
*/
|
||||
var getRangeValue = function getRangeValue(target) {
|
||||
// target > max
|
||||
if (maxDecimal && !target.lessEquals(maxDecimal)) {
|
||||
return maxDecimal;
|
||||
}
|
||||
|
||||
// target < min
|
||||
if (minDecimal && !minDecimal.lessEquals(target)) {
|
||||
return minDecimal;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check value is in [min, max] range
|
||||
*/
|
||||
var isInRange = function isInRange(target) {
|
||||
return !getRangeValue(target);
|
||||
};
|
||||
|
||||
/**
|
||||
* Trigger `onChange` if value validated and not equals of origin.
|
||||
* Return the value that re-align in range.
|
||||
*/
|
||||
var triggerValueUpdate = function triggerValueUpdate(newValue, userTyping) {
|
||||
var updateValue = newValue;
|
||||
var isRangeValidate = isInRange(updateValue) || updateValue.isEmpty();
|
||||
|
||||
// Skip align value when trigger value is empty.
|
||||
// We just trigger onChange(null)
|
||||
// This should not block user typing
|
||||
if (!updateValue.isEmpty() && !userTyping) {
|
||||
// Revert value in range if needed
|
||||
updateValue = getRangeValue(updateValue) || updateValue;
|
||||
isRangeValidate = true;
|
||||
}
|
||||
if (!readOnly && !disabled && isRangeValidate) {
|
||||
var numStr = updateValue.toString();
|
||||
var mergedPrecision = getPrecision(numStr, userTyping);
|
||||
if (mergedPrecision >= 0) {
|
||||
updateValue = (0, _miniDecimal.default)((0, _miniDecimal.toFixed)(numStr, '.', mergedPrecision));
|
||||
|
||||
// When to fixed. The value may out of min & max range.
|
||||
// 4 in [0, 3.8] => 3.8 => 4 (toFixed)
|
||||
if (!isInRange(updateValue)) {
|
||||
updateValue = (0, _miniDecimal.default)((0, _miniDecimal.toFixed)(numStr, '.', mergedPrecision, true));
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger event
|
||||
if (!updateValue.equals(decimalValue)) {
|
||||
setUncontrolledDecimalValue(updateValue);
|
||||
onChange === null || onChange === void 0 || onChange(updateValue.isEmpty() ? null : getDecimalValue(stringMode, updateValue));
|
||||
|
||||
// Reformat input if value is not controlled
|
||||
if (value === undefined) {
|
||||
setInputValue(updateValue, userTyping);
|
||||
}
|
||||
}
|
||||
return updateValue;
|
||||
}
|
||||
return decimalValue;
|
||||
};
|
||||
|
||||
// ========================== User Input ==========================
|
||||
var onNextPromise = (0, _useFrame.default)();
|
||||
|
||||
// >>> Collect input value
|
||||
var collectInputValue = function collectInputValue(inputStr) {
|
||||
recordCursor();
|
||||
|
||||
// Update inputValue in case input can not parse as number
|
||||
// Refresh ref value immediately since it may used by formatter
|
||||
inputValueRef.current = inputStr;
|
||||
setInternalInputValue(inputStr);
|
||||
|
||||
// Parse number
|
||||
if (!compositionRef.current) {
|
||||
var finalValue = mergedParser(inputStr);
|
||||
var finalDecimal = (0, _miniDecimal.default)(finalValue);
|
||||
if (!finalDecimal.isNaN()) {
|
||||
triggerValueUpdate(finalDecimal, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger onInput later to let user customize value if they want to handle something after onChange
|
||||
onInput === null || onInput === void 0 || onInput(inputStr);
|
||||
|
||||
// optimize for chinese input experience
|
||||
// https://github.com/ant-design/ant-design/issues/8196
|
||||
onNextPromise(function () {
|
||||
var nextInputStr = inputStr;
|
||||
if (!parser) {
|
||||
nextInputStr = inputStr.replace(/。/g, '.');
|
||||
}
|
||||
if (nextInputStr !== inputStr) {
|
||||
collectInputValue(nextInputStr);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// >>> Composition
|
||||
var onCompositionStart = function onCompositionStart() {
|
||||
compositionRef.current = true;
|
||||
};
|
||||
var onCompositionEnd = function onCompositionEnd() {
|
||||
compositionRef.current = false;
|
||||
collectInputValue(inputRef.current.value);
|
||||
};
|
||||
|
||||
// >>> Input
|
||||
var onInternalInput = function onInternalInput(e) {
|
||||
collectInputValue(e.target.value);
|
||||
};
|
||||
|
||||
// ============================= Step =============================
|
||||
var onInternalStep = function onInternalStep(up) {
|
||||
var _inputRef$current;
|
||||
// Ignore step since out of range
|
||||
if (up && upDisabled || !up && downDisabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear typing status since it may be caused by up & down key.
|
||||
// We should sync with input value.
|
||||
userTypingRef.current = false;
|
||||
var stepDecimal = (0, _miniDecimal.default)(shiftKeyRef.current ? (0, _numberUtil.getDecupleSteps)(step) : step);
|
||||
if (!up) {
|
||||
stepDecimal = stepDecimal.negate();
|
||||
}
|
||||
var target = (decimalValue || (0, _miniDecimal.default)(0)).add(stepDecimal.toString());
|
||||
var updatedValue = triggerValueUpdate(target, false);
|
||||
onStep === null || onStep === void 0 || onStep(getDecimalValue(stringMode, updatedValue), {
|
||||
offset: shiftKeyRef.current ? (0, _numberUtil.getDecupleSteps)(step) : step,
|
||||
type: up ? 'up' : 'down'
|
||||
});
|
||||
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
|
||||
};
|
||||
|
||||
// ============================ Flush =============================
|
||||
/**
|
||||
* Flush current input content to trigger value change & re-formatter input if needed.
|
||||
* This will always flush input value for update.
|
||||
* If it's invalidate, will fallback to last validate value.
|
||||
*/
|
||||
var flushInputValue = function flushInputValue(userTyping) {
|
||||
var parsedValue = (0, _miniDecimal.default)(mergedParser(inputValue));
|
||||
var formatValue;
|
||||
if (!parsedValue.isNaN()) {
|
||||
// Only validate value or empty value can be re-fill to inputValue
|
||||
// Reassign the formatValue within ranged of trigger control
|
||||
formatValue = triggerValueUpdate(parsedValue, userTyping);
|
||||
} else {
|
||||
formatValue = triggerValueUpdate(decimalValue, userTyping);
|
||||
}
|
||||
if (value !== undefined) {
|
||||
// Reset back with controlled value first
|
||||
setInputValue(decimalValue, false);
|
||||
} else if (!formatValue.isNaN()) {
|
||||
// Reset input back since no validate value
|
||||
setInputValue(formatValue, false);
|
||||
}
|
||||
};
|
||||
|
||||
// Solve the issue of the event triggering sequence when entering numbers in chinese input (Safari)
|
||||
var onBeforeInput = function onBeforeInput() {
|
||||
userTypingRef.current = true;
|
||||
};
|
||||
var onKeyDown = function onKeyDown(event) {
|
||||
var key = event.key,
|
||||
shiftKey = event.shiftKey;
|
||||
userTypingRef.current = true;
|
||||
shiftKeyRef.current = shiftKey;
|
||||
if (key === 'Enter') {
|
||||
if (!compositionRef.current) {
|
||||
userTypingRef.current = false;
|
||||
}
|
||||
flushInputValue(false);
|
||||
onPressEnter === null || onPressEnter === void 0 || onPressEnter(event);
|
||||
}
|
||||
if (keyboard === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Do step
|
||||
if (!compositionRef.current && ['Up', 'ArrowUp', 'Down', 'ArrowDown'].includes(key)) {
|
||||
onInternalStep(key === 'Up' || key === 'ArrowUp');
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
var onKeyUp = function onKeyUp() {
|
||||
userTypingRef.current = false;
|
||||
shiftKeyRef.current = false;
|
||||
};
|
||||
React.useEffect(function () {
|
||||
if (changeOnWheel && focus) {
|
||||
var onWheel = function onWheel(event) {
|
||||
// moving mouse wheel rises wheel event with deltaY < 0
|
||||
// scroll value grows from top to bottom, as screen Y coordinate
|
||||
onInternalStep(event.deltaY < 0);
|
||||
event.preventDefault();
|
||||
};
|
||||
var input = inputRef.current;
|
||||
if (input) {
|
||||
// React onWheel is passive and we can't preventDefault() in it.
|
||||
// That's why we should subscribe with DOM listener
|
||||
// https://stackoverflow.com/questions/63663025/react-onwheel-handler-cant-preventdefault-because-its-a-passive-event-listenev
|
||||
input.addEventListener('wheel', onWheel, {
|
||||
passive: false
|
||||
});
|
||||
return function () {
|
||||
return input.removeEventListener('wheel', onWheel);
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// >>> Focus & Blur
|
||||
var onBlur = function onBlur() {
|
||||
if (changeOnBlur) {
|
||||
flushInputValue(false);
|
||||
}
|
||||
setFocus(false);
|
||||
userTypingRef.current = false;
|
||||
};
|
||||
|
||||
// ========================== Controlled ==========================
|
||||
// Input by precision & formatter
|
||||
(0, _useLayoutEffect.useLayoutUpdateEffect)(function () {
|
||||
if (!decimalValue.isInvalidate()) {
|
||||
setInputValue(decimalValue, false);
|
||||
}
|
||||
}, [precision, formatter]);
|
||||
|
||||
// Input by value
|
||||
(0, _useLayoutEffect.useLayoutUpdateEffect)(function () {
|
||||
var newValue = (0, _miniDecimal.default)(value);
|
||||
setDecimalValue(newValue);
|
||||
var currentParsedValue = (0, _miniDecimal.default)(mergedParser(inputValue));
|
||||
|
||||
// When user typing from `1.2` to `1.`, we should not convert to `1` immediately.
|
||||
// But let it go if user set `formatter`
|
||||
if (!newValue.equals(currentParsedValue) || !userTypingRef.current || formatter) {
|
||||
// Update value as effect
|
||||
setInputValue(newValue, userTypingRef.current);
|
||||
}
|
||||
}, [value]);
|
||||
|
||||
// ============================ Cursor ============================
|
||||
(0, _useLayoutEffect.useLayoutUpdateEffect)(function () {
|
||||
if (formatter) {
|
||||
restoreCursor();
|
||||
}
|
||||
}, [inputValue]);
|
||||
|
||||
// ============================ Render ============================
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
ref: domRef,
|
||||
className: (0, _classnames.default)(prefixCls, className, (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".concat(prefixCls, "-focused"), focus), "".concat(prefixCls, "-disabled"), disabled), "".concat(prefixCls, "-readonly"), readOnly), "".concat(prefixCls, "-not-a-number"), decimalValue.isNaN()), "".concat(prefixCls, "-out-of-range"), !decimalValue.isInvalidate() && !isInRange(decimalValue))),
|
||||
style: style,
|
||||
onFocus: function onFocus() {
|
||||
setFocus(true);
|
||||
},
|
||||
onBlur: onBlur,
|
||||
onKeyDown: onKeyDown,
|
||||
onKeyUp: onKeyUp,
|
||||
onCompositionStart: onCompositionStart,
|
||||
onCompositionEnd: onCompositionEnd,
|
||||
onBeforeInput: onBeforeInput
|
||||
}, controls && /*#__PURE__*/React.createElement(_StepHandler.default, {
|
||||
prefixCls: prefixCls,
|
||||
upNode: upHandler,
|
||||
downNode: downHandler,
|
||||
upDisabled: upDisabled,
|
||||
downDisabled: downDisabled,
|
||||
onStep: onInternalStep
|
||||
}), /*#__PURE__*/React.createElement("div", {
|
||||
className: "".concat(inputClassName, "-wrap")
|
||||
}, /*#__PURE__*/React.createElement("input", (0, _extends2.default)({
|
||||
autoComplete: "off",
|
||||
role: "spinbutton",
|
||||
"aria-valuemin": min,
|
||||
"aria-valuemax": max,
|
||||
"aria-valuenow": decimalValue.isInvalidate() ? null : decimalValue.toString(),
|
||||
step: step
|
||||
}, inputProps, {
|
||||
ref: (0, _ref.composeRef)(inputRef, ref),
|
||||
className: inputClassName,
|
||||
value: inputValue,
|
||||
onChange: onInternalInput,
|
||||
disabled: disabled,
|
||||
readOnly: readOnly
|
||||
}))));
|
||||
});
|
||||
var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
var disabled = props.disabled,
|
||||
style = props.style,
|
||||
_props$prefixCls = props.prefixCls,
|
||||
prefixCls = _props$prefixCls === void 0 ? 'rc-input-number' : _props$prefixCls,
|
||||
value = props.value,
|
||||
prefix = props.prefix,
|
||||
suffix = props.suffix,
|
||||
addonBefore = props.addonBefore,
|
||||
addonAfter = props.addonAfter,
|
||||
className = props.className,
|
||||
classNames = props.classNames,
|
||||
rest = (0, _objectWithoutProperties2.default)(props, _excluded2);
|
||||
var holderRef = React.useRef(null);
|
||||
var inputNumberDomRef = React.useRef(null);
|
||||
var inputFocusRef = React.useRef(null);
|
||||
var focus = function focus(option) {
|
||||
if (inputFocusRef.current) {
|
||||
(0, _commonUtils.triggerFocus)(inputFocusRef.current, option);
|
||||
}
|
||||
};
|
||||
React.useImperativeHandle(ref, function () {
|
||||
return (0, _proxyObject.default)(inputFocusRef.current, {
|
||||
focus: focus,
|
||||
nativeElement: holderRef.current.nativeElement || inputNumberDomRef.current
|
||||
});
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(_rcInput.BaseInput, {
|
||||
className: className,
|
||||
triggerFocus: focus,
|
||||
prefixCls: prefixCls,
|
||||
value: value,
|
||||
disabled: disabled,
|
||||
style: style,
|
||||
prefix: prefix,
|
||||
suffix: suffix,
|
||||
addonAfter: addonAfter,
|
||||
addonBefore: addonBefore,
|
||||
classNames: classNames,
|
||||
components: {
|
||||
affixWrapper: 'div',
|
||||
groupWrapper: 'div',
|
||||
wrapper: 'div',
|
||||
groupAddon: 'div'
|
||||
},
|
||||
ref: holderRef
|
||||
}, /*#__PURE__*/React.createElement(InternalInputNumber, (0, _extends2.default)({
|
||||
prefixCls: prefixCls,
|
||||
disabled: disabled,
|
||||
ref: inputFocusRef,
|
||||
domRef: inputNumberDomRef,
|
||||
className: classNames === null || classNames === void 0 ? void 0 : classNames.input
|
||||
}, rest)));
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
InputNumber.displayName = 'InputNumber';
|
||||
}
|
||||
var _default = exports.default = InputNumber;
|
||||
10
frontend/node_modules/rc-input-number/lib/StepHandler.d.ts
generated
vendored
Normal file
10
frontend/node_modules/rc-input-number/lib/StepHandler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as React from 'react';
|
||||
export interface StepHandlerProps {
|
||||
prefixCls: string;
|
||||
upNode?: React.ReactNode;
|
||||
downNode?: React.ReactNode;
|
||||
upDisabled?: boolean;
|
||||
downDisabled?: boolean;
|
||||
onStep: (up: boolean) => void;
|
||||
}
|
||||
export default function StepHandler({ prefixCls, upNode, downNode, upDisabled, downDisabled, onStep, }: StepHandlerProps): React.JSX.Element;
|
||||
114
frontend/node_modules/rc-input-number/lib/StepHandler.js
generated
vendored
Normal file
114
frontend/node_modules/rc-input-number/lib/StepHandler.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
var _typeof = require("@babel/runtime/helpers/typeof");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = StepHandler;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _classnames = _interopRequireDefault(require("classnames"));
|
||||
var _useMobile = _interopRequireDefault(require("rc-util/lib/hooks/useMobile"));
|
||||
var _raf = _interopRequireDefault(require("rc-util/lib/raf"));
|
||||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
||||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
||||
/* eslint-disable react/no-unknown-property */
|
||||
|
||||
/**
|
||||
* When click and hold on a button - the speed of auto changing the value.
|
||||
*/
|
||||
var STEP_INTERVAL = 200;
|
||||
|
||||
/**
|
||||
* When click and hold on a button - the delay before auto changing the value.
|
||||
*/
|
||||
var STEP_DELAY = 600;
|
||||
function StepHandler(_ref) {
|
||||
var prefixCls = _ref.prefixCls,
|
||||
upNode = _ref.upNode,
|
||||
downNode = _ref.downNode,
|
||||
upDisabled = _ref.upDisabled,
|
||||
downDisabled = _ref.downDisabled,
|
||||
onStep = _ref.onStep;
|
||||
// ======================== Step ========================
|
||||
var stepTimeoutRef = React.useRef();
|
||||
var frameIds = React.useRef([]);
|
||||
var onStepRef = React.useRef();
|
||||
onStepRef.current = onStep;
|
||||
var onStopStep = function onStopStep() {
|
||||
clearTimeout(stepTimeoutRef.current);
|
||||
};
|
||||
|
||||
// We will interval update step when hold mouse down
|
||||
var onStepMouseDown = function onStepMouseDown(e, up) {
|
||||
e.preventDefault();
|
||||
onStopStep();
|
||||
onStepRef.current(up);
|
||||
|
||||
// Loop step for interval
|
||||
function loopStep() {
|
||||
onStepRef.current(up);
|
||||
stepTimeoutRef.current = setTimeout(loopStep, STEP_INTERVAL);
|
||||
}
|
||||
|
||||
// First time press will wait some time to trigger loop step update
|
||||
stepTimeoutRef.current = setTimeout(loopStep, STEP_DELAY);
|
||||
};
|
||||
React.useEffect(function () {
|
||||
return function () {
|
||||
onStopStep();
|
||||
frameIds.current.forEach(function (id) {
|
||||
return _raf.default.cancel(id);
|
||||
});
|
||||
};
|
||||
}, []);
|
||||
|
||||
// ======================= Render =======================
|
||||
var isMobile = (0, _useMobile.default)();
|
||||
if (isMobile) {
|
||||
return null;
|
||||
}
|
||||
var handlerClassName = "".concat(prefixCls, "-handler");
|
||||
var upClassName = (0, _classnames.default)(handlerClassName, "".concat(handlerClassName, "-up"), (0, _defineProperty2.default)({}, "".concat(handlerClassName, "-up-disabled"), upDisabled));
|
||||
var downClassName = (0, _classnames.default)(handlerClassName, "".concat(handlerClassName, "-down"), (0, _defineProperty2.default)({}, "".concat(handlerClassName, "-down-disabled"), downDisabled));
|
||||
|
||||
// fix: https://github.com/ant-design/ant-design/issues/43088
|
||||
// In Safari, When we fire onmousedown and onmouseup events in quick succession,
|
||||
// there may be a problem that the onmouseup events are executed first,
|
||||
// resulting in a disordered program execution.
|
||||
// So, we need to use requestAnimationFrame to ensure that the onmouseup event is executed after the onmousedown event.
|
||||
var safeOnStopStep = function safeOnStopStep() {
|
||||
return frameIds.current.push((0, _raf.default)(onStopStep));
|
||||
};
|
||||
var sharedHandlerProps = {
|
||||
unselectable: 'on',
|
||||
role: 'button',
|
||||
onMouseUp: safeOnStopStep,
|
||||
onMouseLeave: safeOnStopStep
|
||||
};
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
className: "".concat(handlerClassName, "-wrap")
|
||||
}, /*#__PURE__*/React.createElement("span", (0, _extends2.default)({}, sharedHandlerProps, {
|
||||
onMouseDown: function onMouseDown(e) {
|
||||
onStepMouseDown(e, true);
|
||||
},
|
||||
"aria-label": "Increase Value",
|
||||
"aria-disabled": upDisabled,
|
||||
className: upClassName
|
||||
}), upNode || /*#__PURE__*/React.createElement("span", {
|
||||
unselectable: "on",
|
||||
className: "".concat(prefixCls, "-handler-up-inner")
|
||||
})), /*#__PURE__*/React.createElement("span", (0, _extends2.default)({}, sharedHandlerProps, {
|
||||
onMouseDown: function onMouseDown(e) {
|
||||
onStepMouseDown(e, false);
|
||||
},
|
||||
"aria-label": "Decrease Value",
|
||||
"aria-disabled": downDisabled,
|
||||
className: downClassName
|
||||
}), downNode || /*#__PURE__*/React.createElement("span", {
|
||||
unselectable: "on",
|
||||
className: "".concat(prefixCls, "-handler-down-inner")
|
||||
})));
|
||||
}
|
||||
5
frontend/node_modules/rc-input-number/lib/hooks/useCursor.d.ts
generated
vendored
Normal file
5
frontend/node_modules/rc-input-number/lib/hooks/useCursor.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Keep input cursor in the correct position if possible.
|
||||
* Is this necessary since we have `formatter` which may mass the content?
|
||||
*/
|
||||
export default function useCursor(input: HTMLInputElement, focused: boolean): [() => void, () => void];
|
||||
70
frontend/node_modules/rc-input-number/lib/hooks/useCursor.js
generated
vendored
Normal file
70
frontend/node_modules/rc-input-number/lib/hooks/useCursor.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = useCursor;
|
||||
var _react = require("react");
|
||||
var _warning = _interopRequireDefault(require("rc-util/lib/warning"));
|
||||
/**
|
||||
* Keep input cursor in the correct position if possible.
|
||||
* Is this necessary since we have `formatter` which may mass the content?
|
||||
*/
|
||||
function useCursor(input, focused) {
|
||||
var selectionRef = (0, _react.useRef)(null);
|
||||
function recordCursor() {
|
||||
// Record position
|
||||
try {
|
||||
var start = input.selectionStart,
|
||||
end = input.selectionEnd,
|
||||
value = input.value;
|
||||
var beforeTxt = value.substring(0, start);
|
||||
var afterTxt = value.substring(end);
|
||||
selectionRef.current = {
|
||||
start: start,
|
||||
end: end,
|
||||
value: value,
|
||||
beforeTxt: beforeTxt,
|
||||
afterTxt: afterTxt
|
||||
};
|
||||
} catch (e) {
|
||||
// Fix error in Chrome:
|
||||
// Failed to read the 'selectionStart' property from 'HTMLInputElement'
|
||||
// http://stackoverflow.com/q/21177489/3040605
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore logic:
|
||||
* 1. back string same
|
||||
* 2. start string same
|
||||
*/
|
||||
function restoreCursor() {
|
||||
if (input && selectionRef.current && focused) {
|
||||
try {
|
||||
var value = input.value;
|
||||
var _selectionRef$current = selectionRef.current,
|
||||
beforeTxt = _selectionRef$current.beforeTxt,
|
||||
afterTxt = _selectionRef$current.afterTxt,
|
||||
start = _selectionRef$current.start;
|
||||
var startPos = value.length;
|
||||
if (value.startsWith(beforeTxt)) {
|
||||
startPos = beforeTxt.length;
|
||||
} else if (value.endsWith(afterTxt)) {
|
||||
startPos = value.length - selectionRef.current.afterTxt.length;
|
||||
} else {
|
||||
var beforeLastChar = beforeTxt[start - 1];
|
||||
var newIndex = value.indexOf(beforeLastChar, start - 1);
|
||||
if (newIndex !== -1) {
|
||||
startPos = newIndex + 1;
|
||||
}
|
||||
}
|
||||
input.setSelectionRange(startPos, startPos);
|
||||
} catch (e) {
|
||||
(0, _warning.default)(false, "Something warning of cursor restore. Please fire issue about this: ".concat(e.message));
|
||||
}
|
||||
}
|
||||
}
|
||||
return [recordCursor, restoreCursor];
|
||||
}
|
||||
5
frontend/node_modules/rc-input-number/lib/hooks/useFrame.d.ts
generated
vendored
Normal file
5
frontend/node_modules/rc-input-number/lib/hooks/useFrame.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Always trigger latest once when call multiple time
|
||||
*/
|
||||
declare const _default: () => (callback: () => void) => void;
|
||||
export default _default;
|
||||
27
frontend/node_modules/rc-input-number/lib/hooks/useFrame.js
generated
vendored
Normal file
27
frontend/node_modules/rc-input-number/lib/hooks/useFrame.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _react = require("react");
|
||||
var _raf = _interopRequireDefault(require("rc-util/lib/raf"));
|
||||
/**
|
||||
* Always trigger latest once when call multiple time
|
||||
*/
|
||||
var _default = exports.default = function _default() {
|
||||
var idRef = (0, _react.useRef)(0);
|
||||
var cleanUp = function cleanUp() {
|
||||
_raf.default.cancel(idRef.current);
|
||||
};
|
||||
(0, _react.useEffect)(function () {
|
||||
return cleanUp;
|
||||
}, []);
|
||||
return function (callback) {
|
||||
cleanUp();
|
||||
idRef.current = (0, _raf.default)(function () {
|
||||
callback();
|
||||
});
|
||||
};
|
||||
};
|
||||
4
frontend/node_modules/rc-input-number/lib/index.d.ts
generated
vendored
Normal file
4
frontend/node_modules/rc-input-number/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { InputNumberProps, ValueType, InputNumberRef } from './InputNumber';
|
||||
import InputNumber from './InputNumber';
|
||||
export type { InputNumberProps, ValueType, InputNumberRef };
|
||||
export default InputNumber;
|
||||
9
frontend/node_modules/rc-input-number/lib/index.js
generated
vendored
Normal file
9
frontend/node_modules/rc-input-number/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _InputNumber = _interopRequireDefault(require("./InputNumber"));
|
||||
var _default = exports.default = _InputNumber.default;
|
||||
1
frontend/node_modules/rc-input-number/lib/utils/numberUtil.d.ts
generated
vendored
Normal file
1
frontend/node_modules/rc-input-number/lib/utils/numberUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function getDecupleSteps(step: string | number): string;
|
||||
15
frontend/node_modules/rc-input-number/lib/utils/numberUtil.js
generated
vendored
Normal file
15
frontend/node_modules/rc-input-number/lib/utils/numberUtil.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getDecupleSteps = getDecupleSteps;
|
||||
var _miniDecimal = require("@rc-component/mini-decimal");
|
||||
function getDecupleSteps(step) {
|
||||
var stepStr = typeof step === 'number' ? (0, _miniDecimal.num2str)(step) : (0, _miniDecimal.trimNumber)(step).fullStr;
|
||||
var hasPoint = stepStr.includes('.');
|
||||
if (!hasPoint) {
|
||||
return step + '0';
|
||||
}
|
||||
return (0, _miniDecimal.trimNumber)(stepStr.replace(/(\d)\.(\d)/g, '$1$2.')).fullStr;
|
||||
}
|
||||
92
frontend/node_modules/rc-input-number/package.json
generated
vendored
Normal file
92
frontend/node_modules/rc-input-number/package.json
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"name": "rc-input-number",
|
||||
"version": "9.5.0",
|
||||
"description": "React input-number component",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-component",
|
||||
"react-input-number",
|
||||
"input-number"
|
||||
],
|
||||
"homepage": "https://github.com/react-component/input-number",
|
||||
"bugs": {
|
||||
"url": "https://github.com/react-component/input-number/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:react-component/input-number.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "tsjxyz@gmail.com",
|
||||
"main": "./lib/index",
|
||||
"module": "./es/index",
|
||||
"types": "./es/index.d.ts",
|
||||
"files": [
|
||||
"lib",
|
||||
"es",
|
||||
"assets/*.css"
|
||||
],
|
||||
"scripts": {
|
||||
"compile": "father build && lessc assets/index.less assets/index.css",
|
||||
"coverage": "rc-test --coverage",
|
||||
"docs:build": "dumi build",
|
||||
"docs:deploy": "gh-pages -d docs-dist",
|
||||
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
|
||||
"now-build": "npm run docs:build",
|
||||
"prepare": "husky install",
|
||||
"prepublishOnly": "npm run compile && np --yolo --no-publish --branch=antd-5.x",
|
||||
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
|
||||
"start": "dumi dev",
|
||||
"test": "rc-test"
|
||||
},
|
||||
"lint-staged": {
|
||||
"**/*.{js,jsx,tsx,ts,md,json}": [
|
||||
"prettier --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.10.1",
|
||||
"@rc-component/mini-decimal": "^1.0.1",
|
||||
"classnames": "^2.2.5",
|
||||
"rc-input": "~1.8.0",
|
||||
"rc-util": "^5.40.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rc-component/father-plugin": "^1.0.1",
|
||||
"@swc-node/jest": "^1.5.5",
|
||||
"@testing-library/jest-dom": "^6.1.5",
|
||||
"@testing-library/react": "^16.0.0",
|
||||
"@types/classnames": "^2.2.9",
|
||||
"@types/jest": "^29.2.4",
|
||||
"@types/react": "^18.0.26",
|
||||
"@types/react-dom": "^18.0.9",
|
||||
"@types/responselike": "^1.0.0",
|
||||
"@umijs/fabric": "^4.0.1",
|
||||
"@umijs/test": "^4.0.36",
|
||||
"cross-env": "^7.0.3",
|
||||
"dumi": "^2.0.13",
|
||||
"eslint": "^8.54.0",
|
||||
"eslint-plugin-jest": "^27.2.1",
|
||||
"eslint-plugin-unicorn": "^56.0.0",
|
||||
"expect.js": "~0.3.1",
|
||||
"father": "^4.1.1",
|
||||
"glob": "^11.0.0",
|
||||
"husky": "^8.0.3",
|
||||
"jest-environment-jsdom": "^29.3.1",
|
||||
"less": "^4.1.3",
|
||||
"lint-staged": "^15.1.0",
|
||||
"np": "^10.0.5",
|
||||
"rc-test": "^7.0.14",
|
||||
"rc-tooltip": "^6.0.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"regenerator-runtime": "^0.14.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=16.9.0",
|
||||
"react-dom": ">=16.9.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user