@arco-design/mobile-react 2.22.3 → 2.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/image-picker/index.js +18 -12
- package/cjs/image-picker/type.d.ts +10 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +5 -1
- package/cjs/input/style/css/index.css +1 -0
- package/cjs/input/style/index.less +1 -0
- package/cjs/stepper/demo/style/css/mobile.css +4 -0
- package/cjs/stepper/demo/style/mobile.less +10 -0
- package/cjs/stepper/hooks/useButtonClick.d.ts +11 -0
- package/cjs/stepper/hooks/useButtonClick.js +74 -0
- package/cjs/stepper/hooks/useInputEvent.d.ts +9 -0
- package/cjs/stepper/hooks/useInputEvent.js +59 -0
- package/cjs/stepper/hooks/useValue.d.ts +6 -0
- package/cjs/stepper/hooks/useValue.js +44 -0
- package/cjs/stepper/index.d.ts +13 -0
- package/cjs/stepper/index.js +184 -0
- package/cjs/stepper/style/css/index.css +76 -0
- package/cjs/stepper/style/css/index.d.ts +2 -0
- package/cjs/stepper/style/css/index.js +5 -0
- package/cjs/stepper/style/index.d.ts +2 -0
- package/cjs/stepper/style/index.js +5 -0
- package/cjs/stepper/style/index.less +80 -0
- package/cjs/stepper/type.d.ts +159 -0
- package/cjs/stepper/type.js +3 -0
- package/cjs/style.d.ts +1 -0
- package/cjs/style.js +2 -0
- package/dist/index.js +349 -10
- package/dist/index.min.js +3 -3
- package/dist/style.css +64 -0
- package/dist/style.min.css +1 -1
- package/esm/image-picker/index.js +18 -12
- package/esm/image-picker/type.d.ts +10 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/input/style/css/index.css +1 -0
- package/esm/input/style/index.less +1 -0
- package/esm/stepper/demo/style/css/mobile.css +4 -0
- package/esm/stepper/demo/style/mobile.less +10 -0
- package/esm/stepper/hooks/useButtonClick.d.ts +11 -0
- package/esm/stepper/hooks/useButtonClick.js +69 -0
- package/esm/stepper/hooks/useInputEvent.d.ts +9 -0
- package/esm/stepper/hooks/useInputEvent.js +53 -0
- package/esm/stepper/hooks/useValue.d.ts +6 -0
- package/esm/stepper/hooks/useValue.js +38 -0
- package/esm/stepper/index.d.ts +13 -0
- package/esm/stepper/index.js +157 -0
- package/esm/stepper/style/css/index.css +76 -0
- package/esm/stepper/style/css/index.d.ts +2 -0
- package/esm/stepper/style/css/index.js +2 -0
- package/esm/stepper/style/index.d.ts +2 -0
- package/esm/stepper/style/index.js +2 -0
- package/esm/stepper/style/index.less +80 -0
- package/esm/stepper/type.d.ts +159 -0
- package/esm/stepper/type.js +1 -0
- package/esm/style.d.ts +1 -0
- package/esm/style.js +1 -0
- package/package.json +3 -3
- package/tokens/app/arcodesign/default/css-variables.less +15 -0
- package/tokens/app/arcodesign/default/index.d.ts +15 -0
- package/tokens/app/arcodesign/default/index.js +16 -1
- package/tokens/app/arcodesign/default/index.json +180 -0
- package/tokens/app/arcodesign/default/index.less +15 -0
- package/umd/image-picker/index.js +18 -12
- package/umd/image-picker/type.d.ts +10 -0
- package/umd/index.d.ts +1 -0
- package/umd/index.js +7 -5
- package/umd/input/style/css/index.css +1 -0
- package/umd/input/style/index.less +1 -0
- package/umd/stepper/demo/style/css/mobile.css +4 -0
- package/umd/stepper/demo/style/mobile.less +10 -0
- package/umd/stepper/hooks/useButtonClick.d.ts +11 -0
- package/umd/stepper/hooks/useButtonClick.js +86 -0
- package/umd/stepper/hooks/useInputEvent.d.ts +9 -0
- package/umd/stepper/hooks/useInputEvent.js +71 -0
- package/umd/stepper/hooks/useValue.d.ts +6 -0
- package/umd/stepper/hooks/useValue.js +56 -0
- package/umd/stepper/index.d.ts +13 -0
- package/umd/stepper/index.js +185 -0
- package/umd/stepper/style/css/index.css +76 -0
- package/umd/stepper/style/css/index.d.ts +2 -0
- package/umd/stepper/style/css/index.js +15 -0
- package/umd/stepper/style/index.d.ts +2 -0
- package/umd/stepper/style/index.js +15 -0
- package/umd/stepper/style/index.less +80 -0
- package/umd/stepper/type.d.ts +159 -0
- package/umd/stepper/type.js +17 -0
- package/umd/style.d.ts +1 -0
- package/umd/style.js +4 -4
|
@@ -164,6 +164,16 @@ export interface ImagePickerProps {
|
|
|
164
164
|
* @en Select Adaptor
|
|
165
165
|
*/
|
|
166
166
|
selectAdapter?: () => Promise<SelectCallback>;
|
|
167
|
+
/**
|
|
168
|
+
* 选图点击事件
|
|
169
|
+
* @en Select Icon Click Event
|
|
170
|
+
*/
|
|
171
|
+
onSelectClick?: () => void;
|
|
172
|
+
/**
|
|
173
|
+
* 删除点击事件
|
|
174
|
+
* @en Delete Icon Click Event
|
|
175
|
+
*/
|
|
176
|
+
onDeleteClick?: (index: number) => void;
|
|
167
177
|
}
|
|
168
178
|
export interface ImagePickerRef {
|
|
169
179
|
/**
|
package/esm/index.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export { default as Radio } from './radio';
|
|
|
42
42
|
export { default as Rate } from './rate';
|
|
43
43
|
export { default as Slider } from './slider';
|
|
44
44
|
export { default as SearchBar } from './search-bar';
|
|
45
|
+
export { default as Stepper } from './stepper';
|
|
45
46
|
export { default as Steps } from './steps';
|
|
46
47
|
export { default as Sticky } from './sticky';
|
|
47
48
|
export { default as SwipeAction } from './swipe-action';
|
package/esm/index.js
CHANGED
|
@@ -42,6 +42,7 @@ export { default as Radio } from './radio';
|
|
|
42
42
|
export { default as Rate } from './rate';
|
|
43
43
|
export { default as Slider } from './slider';
|
|
44
44
|
export { default as SearchBar } from './search-bar';
|
|
45
|
+
export { default as Stepper } from './stepper';
|
|
45
46
|
export { default as Steps } from './steps';
|
|
46
47
|
export { default as Sticky } from './sticky';
|
|
47
48
|
export { default as SwipeAction } from './swipe-action';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StepperProps } from '../type';
|
|
3
|
+
export default function useButtonClick(params: Required<Pick<StepperProps, 'min' | 'max' | 'step' | 'disabled' | 'digits' | 'digits' | 'equalLimitDisabled'>> & Pick<StepperProps, 'onAddButtonClick' | 'onMinusButtonClick'> & {
|
|
4
|
+
actualInputValue: number;
|
|
5
|
+
updateValue: (updater: number | ((oldValue: number) => number)) => void;
|
|
6
|
+
}): {
|
|
7
|
+
minusButtonDisable: boolean;
|
|
8
|
+
addButtonDisable: boolean;
|
|
9
|
+
handleMinusButtonClick: (e: React.MouseEvent) => void;
|
|
10
|
+
handleAddButtonClick: (e: React.MouseEvent) => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
function correctCalculation(leftNumber, rightNumber, operator) {
|
|
4
|
+
var magnification = 1e17;
|
|
5
|
+
var left = leftNumber * magnification;
|
|
6
|
+
var right = rightNumber * magnification;
|
|
7
|
+
return operator === '-' ? (left - right) / magnification : (left + right) / magnification;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function useButtonClick(params) {
|
|
11
|
+
var actualInputValue = params.actualInputValue,
|
|
12
|
+
min = params.min,
|
|
13
|
+
max = params.max,
|
|
14
|
+
step = params.step,
|
|
15
|
+
disabled = params.disabled,
|
|
16
|
+
equalLimitDisabled = params.equalLimitDisabled,
|
|
17
|
+
updateValue = params.updateValue,
|
|
18
|
+
onAddButtonClick = params.onAddButtonClick,
|
|
19
|
+
onMinusButtonClick = params.onMinusButtonClick;
|
|
20
|
+
|
|
21
|
+
var _useState = useState(function () {
|
|
22
|
+
return actualInputValue === min || disabled;
|
|
23
|
+
}),
|
|
24
|
+
minusButtonDisable = _useState[0],
|
|
25
|
+
setMinusButtonDisable = _useState[1];
|
|
26
|
+
|
|
27
|
+
var _useState2 = useState(function () {
|
|
28
|
+
return actualInputValue === max || disabled;
|
|
29
|
+
}),
|
|
30
|
+
addButtonDisable = _useState2[0],
|
|
31
|
+
setAddButtonDisable = _useState2[1];
|
|
32
|
+
|
|
33
|
+
var handleMinusButtonClick = function handleMinusButtonClick(e) {
|
|
34
|
+
if (minusButtonDisable) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
updateValue(function (oldValue) {
|
|
39
|
+
var result = correctCalculation(oldValue, step, '-');
|
|
40
|
+
return result < min ? equalLimitDisabled ? oldValue : min : result;
|
|
41
|
+
});
|
|
42
|
+
onMinusButtonClick && onMinusButtonClick(e);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var handleAddButtonClick = function handleAddButtonClick(e) {
|
|
46
|
+
if (addButtonDisable) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
updateValue(function (oldValue) {
|
|
51
|
+
var result = correctCalculation(Number(oldValue), step, '+');
|
|
52
|
+
return result > max ? equalLimitDisabled ? oldValue : max : result;
|
|
53
|
+
});
|
|
54
|
+
onAddButtonClick && onAddButtonClick(e);
|
|
55
|
+
}; // 当前值改变时,更新按钮状态
|
|
56
|
+
// Changes button status when value changed
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
useEffect(function () {
|
|
60
|
+
setMinusButtonDisable(actualInputValue <= min);
|
|
61
|
+
setAddButtonDisable(actualInputValue >= max);
|
|
62
|
+
}, [actualInputValue]);
|
|
63
|
+
return {
|
|
64
|
+
minusButtonDisable: minusButtonDisable,
|
|
65
|
+
addButtonDisable: addButtonDisable,
|
|
66
|
+
handleMinusButtonClick: handleMinusButtonClick,
|
|
67
|
+
handleAddButtonClick: handleAddButtonClick
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StepperProps } from '../type';
|
|
3
|
+
export default function useInputEvent(params: Required<Pick<StepperProps, 'defaultValue' | 'min' | 'max' | 'digits' | 'allowEmpty'>> & Pick<StepperProps, 'onBlur' | 'onChange' | 'onInput'> & {
|
|
4
|
+
actualInputValue: number;
|
|
5
|
+
updateValue: (updater: number | ((oldValue: number) => number)) => void;
|
|
6
|
+
}): {
|
|
7
|
+
handleInput: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
8
|
+
handleBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useUpdateEffect } from '../../_helpers';
|
|
2
|
+
export default function useInputEvent(params) {
|
|
3
|
+
var defaultValue = params.defaultValue,
|
|
4
|
+
min = params.min,
|
|
5
|
+
max = params.max,
|
|
6
|
+
digits = params.digits,
|
|
7
|
+
actualInputValue = params.actualInputValue,
|
|
8
|
+
allowEmpty = params.allowEmpty,
|
|
9
|
+
updateValue = params.updateValue,
|
|
10
|
+
onBlur = params.onBlur,
|
|
11
|
+
onChange = params.onChange,
|
|
12
|
+
onInput = params.onInput;
|
|
13
|
+
|
|
14
|
+
var handleInput = function handleInput(e) {
|
|
15
|
+
var targetValue = e.target.value;
|
|
16
|
+
var numberValue = Number(targetValue);
|
|
17
|
+
var pointIndex = targetValue.indexOf('.');
|
|
18
|
+
|
|
19
|
+
if (digits > 0 && pointIndex !== -1) {
|
|
20
|
+
var decimalLength = targetValue.slice(pointIndex + 1).length;
|
|
21
|
+
updateValue(decimalLength > digits ? actualInputValue : numberValue);
|
|
22
|
+
} else if (allowEmpty && targetValue === '') {
|
|
23
|
+
updateValue(Number.MIN_VALUE);
|
|
24
|
+
} else {
|
|
25
|
+
updateValue(numberValue);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
onInput && onInput(e);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
var handleBlur = function handleBlur(e) {
|
|
32
|
+
var targetValue = e.target.value;
|
|
33
|
+
var numberValue = Number(targetValue);
|
|
34
|
+
|
|
35
|
+
if (allowEmpty && targetValue === '') {
|
|
36
|
+
updateValue(Number.MIN_VALUE);
|
|
37
|
+
} else if (!allowEmpty && targetValue === '') {
|
|
38
|
+
updateValue(defaultValue);
|
|
39
|
+
} else {
|
|
40
|
+
updateValue(Math.max(min, Math.min(max, numberValue)));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
onBlur && onBlur(e);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
useUpdateEffect(function () {
|
|
47
|
+
onChange && onChange(actualInputValue);
|
|
48
|
+
}, [actualInputValue]);
|
|
49
|
+
return {
|
|
50
|
+
handleInput: handleInput,
|
|
51
|
+
handleBlur: handleBlur
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StepperProps } from '..';
|
|
2
|
+
export default function useValue(params: Required<Pick<StepperProps, 'defaultValue' | 'min' | 'max' | 'digits'>> & Pick<StepperProps, 'formatter' | 'value'>): {
|
|
3
|
+
updateValue: (updater: number | ((oldValue: number) => number)) => void;
|
|
4
|
+
actualInputValue: number;
|
|
5
|
+
showValue: string | number;
|
|
6
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
export default function useValue(params) {
|
|
3
|
+
var defaultValue = params.defaultValue,
|
|
4
|
+
formatter = params.formatter,
|
|
5
|
+
max = params.max,
|
|
6
|
+
min = params.min,
|
|
7
|
+
value = params.value,
|
|
8
|
+
digits = params.digits;
|
|
9
|
+
|
|
10
|
+
var _useState = useState(defaultValue),
|
|
11
|
+
innerValue = _useState[0],
|
|
12
|
+
setInnerValue = _useState[1];
|
|
13
|
+
|
|
14
|
+
var updateValue = function updateValue(updater) {
|
|
15
|
+
var tempValue = typeof updater === 'function' ? updater(innerValue) : updater;
|
|
16
|
+
|
|
17
|
+
if (formatter) {
|
|
18
|
+
new Promise(function (resolve) {
|
|
19
|
+
resolve(formatter(Number(tempValue)));
|
|
20
|
+
}).then(function (result) {
|
|
21
|
+
var res = Math.max(min, Math.min(max, result));
|
|
22
|
+
setInnerValue(res);
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
setInnerValue(tempValue);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var actualInputValue = value !== undefined ? value : innerValue; // 将actualInputValue等于Number.MIN_VALUE的情况视为空值
|
|
30
|
+
// @en If actualInputValue equal Number.MIN_VALUE, actualInputValue equal ''
|
|
31
|
+
|
|
32
|
+
var showValue = actualInputValue === Number.MIN_VALUE ? '' : digits > 0 ? parseFloat(String(actualInputValue)).toFixed(digits) : actualInputValue;
|
|
33
|
+
return {
|
|
34
|
+
updateValue: updateValue,
|
|
35
|
+
actualInputValue: actualInputValue,
|
|
36
|
+
showValue: showValue
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StepperProps, StepperRef } from './type';
|
|
3
|
+
export * from './type';
|
|
4
|
+
/**
|
|
5
|
+
* 步进器组件,支持受控模式
|
|
6
|
+
* @en Stepper component, provide controlled mode
|
|
7
|
+
* @type 数据录入
|
|
8
|
+
* @type_en Data Entry
|
|
9
|
+
* @name 步进器
|
|
10
|
+
* @name_en Stepper
|
|
11
|
+
*/
|
|
12
|
+
declare const Stepper: React.ForwardRefExoticComponent<StepperProps & React.RefAttributes<StepperRef>>;
|
|
13
|
+
export default Stepper;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { cls } from '@arco-design/mobile-utils';
|
|
2
|
+
import React, { useRef, forwardRef, useImperativeHandle } from 'react';
|
|
3
|
+
import { ContextLayout } from '../context-provider';
|
|
4
|
+
import useButtonClick from './hooks/useButtonClick';
|
|
5
|
+
import useInputEvent from './hooks/useInputEvent';
|
|
6
|
+
import { IconAdd, IconMinus } from '../icon';
|
|
7
|
+
import useValue from './hooks/useValue';
|
|
8
|
+
export * from './type';
|
|
9
|
+
/**
|
|
10
|
+
* 步进器组件,支持受控模式
|
|
11
|
+
* @en Stepper component, provide controlled mode
|
|
12
|
+
* @type 数据录入
|
|
13
|
+
* @type_en Data Entry
|
|
14
|
+
* @name 步进器
|
|
15
|
+
* @name_en Stepper
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
var Stepper = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
19
|
+
var _props$className = props.className,
|
|
20
|
+
className = _props$className === void 0 ? '' : _props$className,
|
|
21
|
+
style = props.style,
|
|
22
|
+
inputStyle = props.inputStyle,
|
|
23
|
+
_props$inputClass = props.inputClass,
|
|
24
|
+
inputClass = _props$inputClass === void 0 ? '' : _props$inputClass,
|
|
25
|
+
value = props.value,
|
|
26
|
+
_props$defaultValue = props.defaultValue,
|
|
27
|
+
defaultValue = _props$defaultValue === void 0 ? 1 : _props$defaultValue,
|
|
28
|
+
_props$allowEmpty = props.allowEmpty,
|
|
29
|
+
allowEmpty = _props$allowEmpty === void 0 ? false : _props$allowEmpty,
|
|
30
|
+
_props$digits = props.digits,
|
|
31
|
+
digits = _props$digits === void 0 ? 0 : _props$digits,
|
|
32
|
+
_props$disabled = props.disabled,
|
|
33
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
34
|
+
_props$inputReadonly = props.inputReadonly,
|
|
35
|
+
inputReadonly = _props$inputReadonly === void 0 ? false : _props$inputReadonly,
|
|
36
|
+
_props$max = props.max,
|
|
37
|
+
max = _props$max === void 0 ? Infinity : _props$max,
|
|
38
|
+
_props$min = props.min,
|
|
39
|
+
min = _props$min === void 0 ? 1 : _props$min,
|
|
40
|
+
_props$equalLimitDisa = props.equalLimitDisabled,
|
|
41
|
+
equalLimitDisabled = _props$equalLimitDisa === void 0 ? false : _props$equalLimitDisa,
|
|
42
|
+
_props$step = props.step,
|
|
43
|
+
step = _props$step === void 0 ? 1 : _props$step,
|
|
44
|
+
_props$theme = props.theme,
|
|
45
|
+
theme = _props$theme === void 0 ? 'default' : _props$theme,
|
|
46
|
+
formatter = props.formatter,
|
|
47
|
+
addButton = props.addButton,
|
|
48
|
+
minusButton = props.minusButton,
|
|
49
|
+
renderContent = props.renderContent,
|
|
50
|
+
onBlur = props.onBlur,
|
|
51
|
+
onChange = props.onChange,
|
|
52
|
+
onFocus = props.onFocus,
|
|
53
|
+
onAddButtonClick = props.onAddButtonClick,
|
|
54
|
+
onMinusButtonClick = props.onMinusButtonClick,
|
|
55
|
+
onClick = props.onClick,
|
|
56
|
+
onInput = props.onInput; // 值的相关逻辑
|
|
57
|
+
// @en The logic is that handle value
|
|
58
|
+
|
|
59
|
+
var _useValue = useValue({
|
|
60
|
+
defaultValue: defaultValue,
|
|
61
|
+
formatter: formatter,
|
|
62
|
+
min: min,
|
|
63
|
+
max: max,
|
|
64
|
+
value: value,
|
|
65
|
+
digits: digits
|
|
66
|
+
}),
|
|
67
|
+
updateValue = _useValue.updateValue,
|
|
68
|
+
actualInputValue = _useValue.actualInputValue,
|
|
69
|
+
showValue = _useValue.showValue; // 按钮点击的相关逻辑
|
|
70
|
+
// @en The logic is that handle button click
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
var _useButtonClick = useButtonClick({
|
|
74
|
+
actualInputValue: actualInputValue,
|
|
75
|
+
min: min,
|
|
76
|
+
max: max,
|
|
77
|
+
step: step,
|
|
78
|
+
disabled: disabled,
|
|
79
|
+
digits: digits,
|
|
80
|
+
equalLimitDisabled: equalLimitDisabled,
|
|
81
|
+
updateValue: updateValue,
|
|
82
|
+
onAddButtonClick: onAddButtonClick,
|
|
83
|
+
onMinusButtonClick: onMinusButtonClick
|
|
84
|
+
}),
|
|
85
|
+
minusButtonDisable = _useButtonClick.minusButtonDisable,
|
|
86
|
+
addButtonDisable = _useButtonClick.addButtonDisable,
|
|
87
|
+
handleAddButtonClick = _useButtonClick.handleAddButtonClick,
|
|
88
|
+
handleMinusButtonClick = _useButtonClick.handleMinusButtonClick; // 输入框操作的相关逻辑
|
|
89
|
+
// @en The logic is that handle input operation
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
var _useInputEvent = useInputEvent({
|
|
93
|
+
defaultValue: defaultValue,
|
|
94
|
+
min: min,
|
|
95
|
+
max: max,
|
|
96
|
+
digits: digits,
|
|
97
|
+
actualInputValue: actualInputValue,
|
|
98
|
+
allowEmpty: allowEmpty,
|
|
99
|
+
updateValue: updateValue,
|
|
100
|
+
onBlur: onBlur,
|
|
101
|
+
onChange: onChange,
|
|
102
|
+
onInput: onInput
|
|
103
|
+
}),
|
|
104
|
+
handleInput = _useInputEvent.handleInput,
|
|
105
|
+
handleBlur = _useInputEvent.handleBlur;
|
|
106
|
+
|
|
107
|
+
var domRef = useRef(null);
|
|
108
|
+
var inputRef = useRef(null);
|
|
109
|
+
useImperativeHandle(ref, function () {
|
|
110
|
+
return {
|
|
111
|
+
dom: domRef.current,
|
|
112
|
+
input: inputRef.current,
|
|
113
|
+
changeValue: function changeValue(newValue) {
|
|
114
|
+
var tempValue = newValue != null ? newValue : defaultValue;
|
|
115
|
+
tempValue = Math.min(max, Math.max(tempValue, min));
|
|
116
|
+
updateValue(tempValue);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
return /*#__PURE__*/React.createElement(ContextLayout, null, function (_ref) {
|
|
121
|
+
var prefixCls = _ref.prefixCls;
|
|
122
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
123
|
+
className: cls(prefixCls + "-stepper", prefixCls + "-" + theme, className),
|
|
124
|
+
style: style,
|
|
125
|
+
ref: domRef,
|
|
126
|
+
onClick: onClick
|
|
127
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
128
|
+
onClick: handleMinusButtonClick
|
|
129
|
+
}, minusButton || /*#__PURE__*/React.createElement("div", {
|
|
130
|
+
className: cls(prefixCls + "-stepper-minus-button")
|
|
131
|
+
}, /*#__PURE__*/React.createElement(IconMinus, {
|
|
132
|
+
className: cls(prefixCls + "-stepper-minus-button-icon", {
|
|
133
|
+
disabled: minusButtonDisable
|
|
134
|
+
})
|
|
135
|
+
}))), renderContent ? renderContent(actualInputValue) : /*#__PURE__*/React.createElement("input", {
|
|
136
|
+
style: inputStyle,
|
|
137
|
+
className: cls(prefixCls + "-stepper-input", inputClass),
|
|
138
|
+
onFocus: onFocus,
|
|
139
|
+
onInput: handleInput,
|
|
140
|
+
onBlur: handleBlur,
|
|
141
|
+
disabled: disabled,
|
|
142
|
+
value: showValue,
|
|
143
|
+
readOnly: inputReadonly,
|
|
144
|
+
ref: inputRef,
|
|
145
|
+
type: "number"
|
|
146
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
147
|
+
onClick: handleAddButtonClick
|
|
148
|
+
}, addButton || /*#__PURE__*/React.createElement("div", {
|
|
149
|
+
className: cls(prefixCls + "-stepper-add-button")
|
|
150
|
+
}, /*#__PURE__*/React.createElement(IconAdd, {
|
|
151
|
+
className: cls(prefixCls + "-stepper-add-button-icon", {
|
|
152
|
+
disabled: addButtonDisable
|
|
153
|
+
})
|
|
154
|
+
}))));
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
export default Stepper;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.arco-stepper {
|
|
2
|
+
display: -webkit-box;
|
|
3
|
+
display: -webkit-flex;
|
|
4
|
+
display: flex;
|
|
5
|
+
font-size: 0.28rem ;
|
|
6
|
+
}
|
|
7
|
+
.arco-stepper.arco-square {
|
|
8
|
+
border: 1PX solid #f2f3f5 ;
|
|
9
|
+
border-radius: 0.04rem ;
|
|
10
|
+
}
|
|
11
|
+
.arco-stepper.arco-square .arco-stepper-add-button,
|
|
12
|
+
.arco-stepper.arco-square .arco-stepper-minus-button,
|
|
13
|
+
.arco-stepper.arco-square .arco-stepper-input {
|
|
14
|
+
background: #ffffff ;
|
|
15
|
+
}
|
|
16
|
+
.arco-stepper.arco-square .arco-stepper-input {
|
|
17
|
+
border-left: 1PX solid #f2f3f5 ;
|
|
18
|
+
border-right: 1PX solid #f2f3f5 ;
|
|
19
|
+
}
|
|
20
|
+
.arco-stepper.arco-round .arco-stepper-minus-button,
|
|
21
|
+
.arco-stepper.arco-round .arco-stepper-add-button {
|
|
22
|
+
border-radius: 50% ;
|
|
23
|
+
}
|
|
24
|
+
.arco-stepper.arco-round .arco-stepper-input {
|
|
25
|
+
background: transparent ;
|
|
26
|
+
}
|
|
27
|
+
.arco-stepper-minus-button {
|
|
28
|
+
display: -webkit-box;
|
|
29
|
+
display: -webkit-flex;
|
|
30
|
+
display: flex;
|
|
31
|
+
-webkit-box-align: center;
|
|
32
|
+
-webkit-align-items: center;
|
|
33
|
+
align-items: center;
|
|
34
|
+
-webkit-box-pack: center;
|
|
35
|
+
-webkit-justify-content: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
font-size: 0.2rem ;
|
|
38
|
+
width: 0.56rem ;
|
|
39
|
+
height: 0.56rem ;
|
|
40
|
+
background: #f7f8fa ;
|
|
41
|
+
}
|
|
42
|
+
.arco-stepper-minus-button-icon {
|
|
43
|
+
color: #1d2129 ;
|
|
44
|
+
}
|
|
45
|
+
.arco-stepper-minus-button-icon.disabled {
|
|
46
|
+
color: #c9cdd4 ;
|
|
47
|
+
}
|
|
48
|
+
.arco-stepper-input {
|
|
49
|
+
text-align: center;
|
|
50
|
+
width: 0.8rem ;
|
|
51
|
+
height: 0.56rem ;
|
|
52
|
+
background: #f7f8fa ;
|
|
53
|
+
color: #1d2129 ;
|
|
54
|
+
margin: 0 1PX ;
|
|
55
|
+
}
|
|
56
|
+
.arco-stepper-add-button {
|
|
57
|
+
display: -webkit-box;
|
|
58
|
+
display: -webkit-flex;
|
|
59
|
+
display: flex;
|
|
60
|
+
-webkit-box-align: center;
|
|
61
|
+
-webkit-align-items: center;
|
|
62
|
+
align-items: center;
|
|
63
|
+
-webkit-box-pack: center;
|
|
64
|
+
-webkit-justify-content: center;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
font-size: 0.2rem ;
|
|
67
|
+
width: 0.56rem ;
|
|
68
|
+
height: 0.56rem ;
|
|
69
|
+
background: #f7f8fa ;
|
|
70
|
+
}
|
|
71
|
+
.arco-stepper-add-button-icon {
|
|
72
|
+
color: #1d2129 ;
|
|
73
|
+
}
|
|
74
|
+
.arco-stepper-add-button-icon.disabled {
|
|
75
|
+
color: #c9cdd4 ;
|
|
76
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
@import '../../../style/mixin.less';
|
|
2
|
+
|
|
3
|
+
.@{prefix}-stepper {
|
|
4
|
+
display: flex;
|
|
5
|
+
.use-var(font-size, stepper-font-size);
|
|
6
|
+
|
|
7
|
+
&.@{prefix}-square {
|
|
8
|
+
.use-var(border, stepper-square-border);
|
|
9
|
+
.use-var(border-radius, stepper-square-border-radius);
|
|
10
|
+
|
|
11
|
+
.@{prefix}-stepper {
|
|
12
|
+
&-add-button,
|
|
13
|
+
&-minus-button,
|
|
14
|
+
&-input {
|
|
15
|
+
.use-var(background, stepper-square-background-color);
|
|
16
|
+
}
|
|
17
|
+
&-input {
|
|
18
|
+
.use-var(border-left, stepper-square-border);
|
|
19
|
+
.use-var(border-right, stepper-square-border);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.@{prefix}-round {
|
|
25
|
+
.@{prefix}-stepper {
|
|
26
|
+
&-minus-button,
|
|
27
|
+
&-add-button {
|
|
28
|
+
.use-var(border-radius, stepper-round-button-border-radius);
|
|
29
|
+
}
|
|
30
|
+
&-input {
|
|
31
|
+
.use-var(background, stepper-round-input-background-color);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&-minus-button {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
.use-var(font-size, stepper-button-icon-size);
|
|
41
|
+
.use-var(width, stepper-button-size);
|
|
42
|
+
.use-var(height, stepper-button-size);
|
|
43
|
+
.use-var(background, stepper-default-background-color);
|
|
44
|
+
|
|
45
|
+
&-icon {
|
|
46
|
+
.use-var(color, stepper-content-color);
|
|
47
|
+
|
|
48
|
+
&.disabled {
|
|
49
|
+
.use-var(color, stepper-disable-color);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&-input {
|
|
55
|
+
text-align: center;
|
|
56
|
+
.use-var(width, stepper-input-width);
|
|
57
|
+
.use-var(height, stepper-input-height);
|
|
58
|
+
.use-var(background, stepper-default-background-color);
|
|
59
|
+
.use-var(color, stepper-content-color);
|
|
60
|
+
.use-var(margin, stepper-input-margin);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&-add-button {
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
.use-var(font-size, stepper-button-icon-size);
|
|
68
|
+
.use-var(width, stepper-button-size);
|
|
69
|
+
.use-var(height, stepper-button-size);
|
|
70
|
+
.use-var(background, stepper-default-background-color);
|
|
71
|
+
|
|
72
|
+
&-icon {
|
|
73
|
+
.use-var(color, stepper-content-color);
|
|
74
|
+
|
|
75
|
+
&.disabled {
|
|
76
|
+
.use-var(color, stepper-disable-color);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|