@fluentui/react-spinbutton 9.2.4 → 9.2.6
Sign up to get free protection for your applications and to get access to all the features.
- package/.swcrc +30 -0
- package/CHANGELOG.json +97 -1
- package/CHANGELOG.md +31 -2
- package/lib/SpinButton.js.map +1 -1
- package/lib/SpinButtonField.js.map +1 -1
- package/lib/components/SpinButton/SpinButton.js.map +1 -1
- package/lib/components/SpinButton/SpinButton.types.js +1 -1
- package/lib/components/SpinButton/SpinButton.types.js.map +1 -1
- package/lib/components/SpinButton/index.js.map +1 -1
- package/lib/components/SpinButton/renderSpinButton.js +1 -9
- package/lib/components/SpinButton/renderSpinButton.js.map +1 -1
- package/lib/components/SpinButton/useSpinButton.js +4 -3
- package/lib/components/SpinButton/useSpinButton.js.map +1 -1
- package/lib/components/SpinButton/useSpinButtonStyles.js.map +1 -1
- package/lib/components/SpinButtonField/SpinButtonField.js +1 -2
- package/lib/components/SpinButtonField/SpinButtonField.js.map +1 -1
- package/lib/components/SpinButtonField/index.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/utils/clamp.js.map +1 -1
- package/lib/utils/getBound.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/precision.js +6 -7
- package/lib/utils/precision.js.map +1 -1
- package/lib-commonjs/SpinButton.js +5 -4
- package/lib-commonjs/SpinButton.js.map +1 -1
- package/lib-commonjs/SpinButtonField.js +5 -4
- package/lib-commonjs/SpinButtonField.js.map +1 -1
- package/lib-commonjs/components/SpinButton/SpinButton.js +19 -20
- package/lib-commonjs/components/SpinButton/SpinButton.js.map +1 -1
- package/lib-commonjs/components/SpinButton/SpinButton.types.js +5 -2
- package/lib-commonjs/components/SpinButton/SpinButton.types.js.map +1 -1
- package/lib-commonjs/components/SpinButton/index.js +9 -8
- package/lib-commonjs/components/SpinButton/index.js.map +1 -1
- package/lib-commonjs/components/SpinButton/renderSpinButton.js +13 -24
- package/lib-commonjs/components/SpinButton/renderSpinButton.js.map +1 -1
- package/lib-commonjs/components/SpinButton/useSpinButton.js +248 -259
- package/lib-commonjs/components/SpinButton/useSpinButton.js.map +1 -1
- package/lib-commonjs/components/SpinButton/useSpinButtonStyles.js +506 -246
- package/lib-commonjs/components/SpinButton/useSpinButtonStyles.js.map +1 -1
- package/lib-commonjs/components/SpinButtonField/SpinButtonField.js +17 -11
- package/lib-commonjs/components/SpinButtonField/SpinButtonField.js.map +1 -1
- package/lib-commonjs/components/SpinButtonField/index.js +5 -4
- package/lib-commonjs/components/SpinButtonField/index.js.map +1 -1
- package/lib-commonjs/index.js +21 -49
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utils/clamp.js +28 -21
- package/lib-commonjs/utils/clamp.js.map +1 -1
- package/lib-commonjs/utils/getBound.js +16 -14
- package/lib-commonjs/utils/getBound.js.map +1 -1
- package/lib-commonjs/utils/index.js +7 -6
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/precision.js +33 -33
- package/lib-commonjs/utils/precision.js.map +1 -1
- package/package.json +12 -11
- package/lib-amd/SpinButton.js +0 -6
- package/lib-amd/SpinButton.js.map +0 -1
- package/lib-amd/SpinButtonField.js +0 -6
- package/lib-amd/SpinButtonField.js.map +0 -1
- package/lib-amd/components/SpinButton/SpinButton.js +0 -17
- package/lib-amd/components/SpinButton/SpinButton.js.map +0 -1
- package/lib-amd/components/SpinButton/SpinButton.types.js +0 -5
- package/lib-amd/components/SpinButton/SpinButton.types.js.map +0 -1
- package/lib-amd/components/SpinButton/index.js +0 -10
- package/lib-amd/components/SpinButton/index.js.map +0 -1
- package/lib-amd/components/SpinButton/renderSpinButton.js +0 -17
- package/lib-amd/components/SpinButton/renderSpinButton.js.map +0 -1
- package/lib-amd/components/SpinButton/useSpinButton.js +0 -253
- package/lib-amd/components/SpinButton/useSpinButton.js.map +0 -1
- package/lib-amd/components/SpinButton/useSpinButtonStyles.js +0 -420
- package/lib-amd/components/SpinButton/useSpinButtonStyles.js.map +0 -1
- package/lib-amd/components/SpinButtonField/SpinButtonField.js +0 -10
- package/lib-amd/components/SpinButtonField/SpinButtonField.js.map +0 -1
- package/lib-amd/components/SpinButtonField/index.js +0 -6
- package/lib-amd/components/SpinButtonField/index.js.map +0 -1
- package/lib-amd/index.js +0 -13
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/utils/clamp.js +0 -30
- package/lib-amd/utils/clamp.js.map +0 -1
- package/lib-amd/utils/getBound.js +0 -19
- package/lib-amd/utils/getBound.js.map +0 -1
- package/lib-amd/utils/index.js +0 -8
- package/lib-amd/utils/index.js.map +0 -1
- package/lib-amd/utils/precision.js +0 -44
- package/lib-amd/utils/precision.js.map +0 -1
@@ -1,273 +1,262 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
4
|
-
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useSpinButton_unstable", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>useSpinButton_unstable
|
5
8
|
});
|
6
|
-
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
12
|
+
const _keyboardKeys = require("@fluentui/keyboard-keys");
|
13
|
+
const _index = require("../../utils/index");
|
14
|
+
const _reactIcons = require("@fluentui/react-icons");
|
15
|
+
const _reactSharedContexts = require("@fluentui/react-shared-contexts");
|
13
16
|
const DEFAULT_SPIN_DELAY_MS = 150;
|
14
17
|
const MIN_SPIN_DELAY_MS = 80;
|
15
18
|
const MAX_SPIN_TIME_MS = 1000;
|
16
19
|
// This is here to give an ease for the mouse held down case.
|
17
20
|
// Exact easing it to be defined. Once it is we'll likely
|
18
21
|
// pull this out into a util function in the SpinButton package.
|
19
|
-
const lerp = (start, end, percent)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
}
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
internalState.current.spinState = 'up';
|
113
|
-
stepValue(e, 'up');
|
114
|
-
};
|
115
|
-
const handleDecrementMouseDown = e => {
|
116
|
-
internalState.current.spinState = 'down';
|
117
|
-
stepValue(e, 'down');
|
118
|
-
};
|
119
|
-
const handleStepMouseUpOrLeave = e => {
|
120
|
-
clearStepTimeout();
|
121
|
-
internalState.current.spinState = 'rest';
|
122
|
-
internalState.current.spinDelay = DEFAULT_SPIN_DELAY_MS;
|
123
|
-
internalState.current.spinTime = 0;
|
124
|
-
};
|
125
|
-
const handleBlur = e => {
|
126
|
-
commit(e, currentValue, textValue);
|
127
|
-
internalState.current.previousTextValue = undefined;
|
128
|
-
};
|
129
|
-
const handleKeyDown = e => {
|
130
|
-
let nextKeyboardSpinState = 'rest';
|
131
|
-
if (e.key === keyboard_keys_1.ArrowUp) {
|
132
|
-
stepValue(e, 'up', textValue);
|
133
|
-
nextKeyboardSpinState = 'up';
|
134
|
-
} else if (e.key === keyboard_keys_1.ArrowDown) {
|
135
|
-
stepValue(e, 'down', textValue);
|
136
|
-
nextKeyboardSpinState = 'down';
|
137
|
-
} else if (e.key === keyboard_keys_1.PageUp) {
|
138
|
-
e.preventDefault();
|
139
|
-
stepValue(e, 'upPage', textValue);
|
140
|
-
nextKeyboardSpinState = 'up';
|
141
|
-
} else if (e.key === keyboard_keys_1.PageDown) {
|
142
|
-
e.preventDefault();
|
143
|
-
stepValue(e, 'downPage', textValue);
|
144
|
-
nextKeyboardSpinState = 'down';
|
145
|
-
} else if (!e.shiftKey && e.key === keyboard_keys_1.Home && min !== undefined) {
|
146
|
-
commit(e, min);
|
147
|
-
nextKeyboardSpinState = 'down';
|
148
|
-
} else if (!e.shiftKey && e.key === keyboard_keys_1.End && max !== undefined) {
|
149
|
-
commit(e, max);
|
150
|
-
nextKeyboardSpinState = 'up';
|
151
|
-
} else if (e.key === keyboard_keys_1.Enter) {
|
152
|
-
commit(e, currentValue, textValue);
|
153
|
-
internalState.current.previousTextValue = undefined;
|
154
|
-
} else if (e.key === keyboard_keys_1.Escape) {
|
155
|
-
if (internalState.current.previousTextValue) {
|
156
|
-
setTextValue(undefined);
|
22
|
+
const lerp = (start, end, percent)=>start + (end - start) * percent;
|
23
|
+
const useSpinButton_unstable = (props, ref)=>{
|
24
|
+
const nativeProps = (0, _reactUtilities.getPartitionedNativeProps)({
|
25
|
+
props,
|
26
|
+
primarySlotTagName: 'input',
|
27
|
+
excludedPropNames: [
|
28
|
+
'defaultValue',
|
29
|
+
'max',
|
30
|
+
'min',
|
31
|
+
'onChange',
|
32
|
+
'size',
|
33
|
+
'value'
|
34
|
+
]
|
35
|
+
});
|
36
|
+
const overrides = (0, _reactSharedContexts.useOverrides_unstable)();
|
37
|
+
var _overrides_inputDefaultAppearance;
|
38
|
+
const { value , displayValue , defaultValue , min , max , step =1 , stepPage =1 , precision: precisionFromProps , onChange , size ='medium' , appearance =(_overrides_inputDefaultAppearance = overrides.inputDefaultAppearance) !== null && _overrides_inputDefaultAppearance !== void 0 ? _overrides_inputDefaultAppearance : 'outline' , root , input , incrementButton , decrementButton } = props;
|
39
|
+
const precision = _react.useMemo(()=>{
|
40
|
+
return precisionFromProps !== null && precisionFromProps !== void 0 ? precisionFromProps : Math.max((0, _index.calculatePrecision)(step), 0);
|
41
|
+
}, [
|
42
|
+
precisionFromProps,
|
43
|
+
step
|
44
|
+
]);
|
45
|
+
const [currentValue, setCurrentValue] = (0, _reactUtilities.useControllableState)({
|
46
|
+
state: value,
|
47
|
+
defaultState: defaultValue,
|
48
|
+
initialState: 0
|
49
|
+
});
|
50
|
+
const isControlled = value !== undefined;
|
51
|
+
const [textValue, setTextValue] = _react.useState(undefined);
|
52
|
+
const [keyboardSpinState, setKeyboardSpinState] = _react.useState('rest');
|
53
|
+
const internalState = _react.useRef({
|
54
|
+
value: currentValue,
|
55
|
+
spinState: 'rest',
|
56
|
+
spinTime: 0,
|
57
|
+
spinDelay: DEFAULT_SPIN_DELAY_MS,
|
58
|
+
atBound: currentValue !== null ? (0, _index.getBound)((0, _index.precisionRound)(currentValue, precision), min, max) : 'none'
|
59
|
+
});
|
60
|
+
const [setStepTimeout, clearStepTimeout] = (0, _reactUtilities.useTimeout)();
|
61
|
+
const stepValue = (e, direction, startFrom)=>{
|
62
|
+
let startValue = internalState.current.value;
|
63
|
+
if (startFrom) {
|
64
|
+
const num = parseFloat(startFrom);
|
65
|
+
if (!isNaN(num)) {
|
66
|
+
startValue = num;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
const val = startValue;
|
70
|
+
const dir = direction === 'up' || direction === 'upPage' ? 1 : -1;
|
71
|
+
const stepSize = direction === 'upPage' || direction === 'downPage' ? stepPage : step;
|
72
|
+
if (val === null) {
|
73
|
+
const stepStart = min === undefined ? 0 : min;
|
74
|
+
const nullStep = (0, _index.clamp)(stepStart + stepSize * dir, min, max);
|
75
|
+
commit(e, nullStep);
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
let newValue = val + stepSize * dir;
|
79
|
+
if (!Number.isNaN(newValue)) {
|
80
|
+
newValue = (0, _index.clamp)(newValue, min, max);
|
81
|
+
}
|
82
|
+
commit(e, newValue);
|
83
|
+
if (internalState.current.spinState !== 'rest') {
|
84
|
+
setStepTimeout(()=>{
|
85
|
+
// Ease the step speed a bit
|
86
|
+
internalState.current.spinTime += internalState.current.spinDelay;
|
87
|
+
internalState.current.spinDelay = lerp(DEFAULT_SPIN_DELAY_MS, MIN_SPIN_DELAY_MS, internalState.current.spinTime / MAX_SPIN_TIME_MS);
|
88
|
+
stepValue(e, direction);
|
89
|
+
}, internalState.current.spinDelay);
|
90
|
+
}
|
91
|
+
};
|
92
|
+
const handleInputChange = (e)=>{
|
93
|
+
if (!internalState.current.previousTextValue) {
|
94
|
+
internalState.current.previousTextValue = textValue !== null && textValue !== void 0 ? textValue : String(currentValue);
|
95
|
+
}
|
96
|
+
const newValue = e.target.value;
|
97
|
+
setTextValue(newValue);
|
98
|
+
};
|
99
|
+
const handleIncrementMouseDown = (e)=>{
|
100
|
+
internalState.current.spinState = 'up';
|
101
|
+
stepValue(e, 'up');
|
102
|
+
};
|
103
|
+
const handleDecrementMouseDown = (e)=>{
|
104
|
+
internalState.current.spinState = 'down';
|
105
|
+
stepValue(e, 'down');
|
106
|
+
};
|
107
|
+
const handleStepMouseUpOrLeave = (e)=>{
|
108
|
+
clearStepTimeout();
|
109
|
+
internalState.current.spinState = 'rest';
|
110
|
+
internalState.current.spinDelay = DEFAULT_SPIN_DELAY_MS;
|
111
|
+
internalState.current.spinTime = 0;
|
112
|
+
};
|
113
|
+
const handleBlur = (e)=>{
|
114
|
+
commit(e, currentValue, textValue);
|
157
115
|
internalState.current.previousTextValue = undefined;
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
116
|
+
};
|
117
|
+
const handleKeyDown = (e)=>{
|
118
|
+
let nextKeyboardSpinState = 'rest';
|
119
|
+
if (e.key === _keyboardKeys.ArrowUp) {
|
120
|
+
stepValue(e, 'up', textValue);
|
121
|
+
nextKeyboardSpinState = 'up';
|
122
|
+
} else if (e.key === _keyboardKeys.ArrowDown) {
|
123
|
+
stepValue(e, 'down', textValue);
|
124
|
+
nextKeyboardSpinState = 'down';
|
125
|
+
} else if (e.key === _keyboardKeys.PageUp) {
|
126
|
+
e.preventDefault();
|
127
|
+
stepValue(e, 'upPage', textValue);
|
128
|
+
nextKeyboardSpinState = 'up';
|
129
|
+
} else if (e.key === _keyboardKeys.PageDown) {
|
130
|
+
e.preventDefault();
|
131
|
+
stepValue(e, 'downPage', textValue);
|
132
|
+
nextKeyboardSpinState = 'down';
|
133
|
+
} else if (!e.shiftKey && e.key === _keyboardKeys.Home && min !== undefined) {
|
134
|
+
commit(e, min);
|
135
|
+
nextKeyboardSpinState = 'down';
|
136
|
+
} else if (!e.shiftKey && e.key === _keyboardKeys.End && max !== undefined) {
|
137
|
+
commit(e, max);
|
138
|
+
nextKeyboardSpinState = 'up';
|
139
|
+
} else if (e.key === _keyboardKeys.Enter) {
|
140
|
+
commit(e, currentValue, textValue);
|
141
|
+
internalState.current.previousTextValue = undefined;
|
142
|
+
} else if (e.key === _keyboardKeys.Escape) {
|
143
|
+
if (internalState.current.previousTextValue) {
|
144
|
+
setTextValue(undefined);
|
145
|
+
internalState.current.previousTextValue = undefined;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
if (keyboardSpinState !== nextKeyboardSpinState) {
|
149
|
+
setKeyboardSpinState(nextKeyboardSpinState);
|
150
|
+
}
|
151
|
+
};
|
152
|
+
const handleKeyUp = (e)=>{
|
153
|
+
if (keyboardSpinState !== 'rest') {
|
154
|
+
setKeyboardSpinState('rest');
|
155
|
+
internalState.current.spinState = 'rest';
|
156
|
+
}
|
157
|
+
};
|
158
|
+
const commit = (e, newValue, newDisplayValue)=>{
|
159
|
+
const valueChanged = newValue !== undefined && currentValue !== newValue;
|
160
|
+
const displayValueChanged = newDisplayValue !== undefined && internalState.current.previousTextValue !== undefined && internalState.current.previousTextValue !== newDisplayValue;
|
161
|
+
let roundedValue;
|
162
|
+
if (valueChanged) {
|
163
|
+
roundedValue = (0, _index.precisionRound)(newValue, precision);
|
164
|
+
setCurrentValue(roundedValue);
|
165
|
+
} else if (displayValueChanged && !isControlled) {
|
166
|
+
const nextValue = parseFloat(newDisplayValue);
|
167
|
+
if (!isNaN(nextValue)) {
|
168
|
+
setCurrentValue((0, _index.precisionRound)(nextValue, precision));
|
169
|
+
}
|
170
|
+
}
|
171
|
+
if (valueChanged || displayValueChanged) {
|
172
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e, {
|
173
|
+
value: roundedValue,
|
174
|
+
displayValue: newDisplayValue
|
175
|
+
});
|
176
|
+
}
|
177
|
+
setTextValue(undefined);
|
178
|
+
};
|
179
|
+
const state = {
|
180
|
+
size,
|
212
181
|
appearance,
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
182
|
+
spinState: keyboardSpinState,
|
183
|
+
atBound: internalState.current.atBound,
|
184
|
+
components: {
|
185
|
+
root: 'span',
|
186
|
+
input: 'input',
|
187
|
+
incrementButton: 'button',
|
188
|
+
decrementButton: 'button'
|
189
|
+
},
|
190
|
+
root: (0, _reactUtilities.resolveShorthand)(root, {
|
191
|
+
required: true,
|
192
|
+
defaultProps: nativeProps.root
|
193
|
+
}),
|
194
|
+
input: (0, _reactUtilities.resolveShorthand)(input, {
|
195
|
+
required: true,
|
196
|
+
defaultProps: {
|
197
|
+
ref,
|
198
|
+
autoComplete: 'off',
|
199
|
+
role: 'spinbutton',
|
200
|
+
appearance,
|
201
|
+
type: 'text',
|
202
|
+
...nativeProps.primary
|
203
|
+
}
|
204
|
+
}),
|
205
|
+
incrementButton: (0, _reactUtilities.resolveShorthand)(incrementButton, {
|
206
|
+
required: true,
|
207
|
+
defaultProps: {
|
208
|
+
tabIndex: -1,
|
209
|
+
children: /*#__PURE__*/ _react.createElement(_reactIcons.ChevronUp16Regular, null),
|
210
|
+
disabled: nativeProps.primary.disabled,
|
211
|
+
'aria-label': 'Increment value',
|
212
|
+
type: 'button'
|
213
|
+
}
|
214
|
+
}),
|
215
|
+
decrementButton: (0, _reactUtilities.resolveShorthand)(decrementButton, {
|
216
|
+
required: true,
|
217
|
+
defaultProps: {
|
218
|
+
tabIndex: -1,
|
219
|
+
children: /*#__PURE__*/ _react.createElement(_reactIcons.ChevronDown16Regular, null),
|
220
|
+
disabled: nativeProps.primary.disabled,
|
221
|
+
'aria-label': 'Decrement value',
|
222
|
+
type: 'button'
|
223
|
+
}
|
224
|
+
})
|
225
|
+
};
|
226
|
+
let valueToDisplay;
|
227
|
+
if (textValue !== undefined) {
|
228
|
+
valueToDisplay = textValue;
|
229
|
+
} else if (value === null || currentValue === null) {
|
230
|
+
valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : '';
|
231
|
+
internalState.current.value = null;
|
232
|
+
internalState.current.atBound = 'none';
|
251
233
|
} else {
|
252
|
-
|
234
|
+
const roundedValue = (0, _index.precisionRound)(currentValue, precision);
|
235
|
+
internalState.current.value = roundedValue;
|
236
|
+
internalState.current.atBound = (0, _index.getBound)(roundedValue, min, max);
|
237
|
+
if (isControlled) {
|
238
|
+
valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : String(roundedValue);
|
239
|
+
} else {
|
240
|
+
valueToDisplay = String(roundedValue);
|
241
|
+
}
|
253
242
|
}
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
};
|
272
|
-
|
243
|
+
state.input.value = valueToDisplay;
|
244
|
+
state.input['aria-valuemin'] = min;
|
245
|
+
state.input['aria-valuemax'] = max;
|
246
|
+
state.input['aria-valuenow'] = currentValue !== null && currentValue !== void 0 ? currentValue : undefined;
|
247
|
+
var _state_input_ariavaluetext;
|
248
|
+
state.input['aria-valuetext'] = (_state_input_ariavaluetext = state.input['aria-valuetext']) !== null && _state_input_ariavaluetext !== void 0 ? _state_input_ariavaluetext : value !== undefined && displayValue || undefined;
|
249
|
+
state.input.onChange = (0, _reactUtilities.mergeCallbacks)(state.input.onChange, handleInputChange);
|
250
|
+
state.input.onBlur = (0, _reactUtilities.mergeCallbacks)(state.input.onBlur, handleBlur);
|
251
|
+
state.input.onKeyDown = (0, _reactUtilities.mergeCallbacks)(state.input.onKeyDown, handleKeyDown);
|
252
|
+
state.input.onKeyUp = (0, _reactUtilities.mergeCallbacks)(state.input.onKeyUp, handleKeyUp);
|
253
|
+
state.incrementButton.onMouseDown = (0, _reactUtilities.mergeCallbacks)(handleIncrementMouseDown, state.incrementButton.onMouseDown);
|
254
|
+
state.incrementButton.onMouseUp = (0, _reactUtilities.mergeCallbacks)(state.incrementButton.onMouseUp, handleStepMouseUpOrLeave);
|
255
|
+
state.incrementButton.onMouseLeave = (0, _reactUtilities.mergeCallbacks)(state.incrementButton.onMouseLeave, handleStepMouseUpOrLeave);
|
256
|
+
state.decrementButton.onMouseDown = (0, _reactUtilities.mergeCallbacks)(handleDecrementMouseDown, state.decrementButton.onMouseDown);
|
257
|
+
state.decrementButton.onMouseUp = (0, _reactUtilities.mergeCallbacks)(state.decrementButton.onMouseUp, handleStepMouseUpOrLeave);
|
258
|
+
state.decrementButton.onMouseLeave = (0, _reactUtilities.mergeCallbacks)(state.decrementButton.onMouseLeave, handleStepMouseUpOrLeave);
|
259
|
+
return state;
|
260
|
+
}; //# sourceMappingURL=useSpinButton.js.map
|
261
|
+
|
273
262
|
//# sourceMappingURL=useSpinButton.js.map
|