@fluentui/react-spinbutton 0.0.0-nightly-20230317-1454.1 → 0.0.0-nightly-20230322-0439.1
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/.swcrc +2 -11
- package/CHANGELOG.json +86 -17
- package/CHANGELOG.md +29 -11
- package/lib/SpinButton.js +1 -1
- package/lib/SpinButtonField.js +1 -1
- package/lib/components/SpinButton/SpinButton.js +6 -6
- package/lib/components/SpinButton/SpinButton.types.js +1 -1
- package/lib/components/SpinButton/index.js +5 -5
- package/lib/components/SpinButton/renderSpinButton.js +2 -2
- package/lib/components/SpinButton/useSpinButton.js +58 -56
- package/lib/components/SpinButton/useSpinButton.js.map +1 -1
- package/lib/components/SpinButton/useSpinButtonStyles.js +14 -14
- package/lib/components/SpinButtonField/SpinButtonField.js +2 -2
- package/lib/components/SpinButtonField/index.js +1 -1
- package/lib/index.js +2 -2
- package/lib/utils/clamp.js +1 -1
- package/lib/utils/getBound.js +4 -4
- package/lib/utils/index.js +3 -3
- package/lib-commonjs/SpinButton.js.map +1 -1
- package/lib-commonjs/SpinButtonField.js.map +1 -1
- package/lib-commonjs/components/SpinButton/SpinButton.js +1 -1
- package/lib-commonjs/components/SpinButton/SpinButton.js.map +1 -1
- package/lib-commonjs/components/SpinButton/SpinButton.types.js.map +1 -1
- package/lib-commonjs/components/SpinButton/index.js.map +1 -1
- package/lib-commonjs/components/SpinButton/renderSpinButton.js.map +1 -1
- package/lib-commonjs/components/SpinButton/useSpinButton.js +56 -54
- package/lib-commonjs/components/SpinButton/useSpinButton.js.map +1 -1
- package/lib-commonjs/components/SpinButton/useSpinButtonStyles.js +16 -16
- package/lib-commonjs/components/SpinButton/useSpinButtonStyles.js.map +1 -1
- package/lib-commonjs/components/SpinButtonField/SpinButtonField.js.map +1 -1
- package/lib-commonjs/components/SpinButtonField/index.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utils/clamp.js +1 -1
- package/lib-commonjs/utils/clamp.js.map +1 -1
- package/lib-commonjs/utils/getBound.js +4 -4
- package/lib-commonjs/utils/getBound.js.map +1 -1
- package/lib-commonjs/utils/index.js.map +1 -1
- package/package.json +10 -9
package/.swcrc
CHANGED
@@ -1,15 +1,5 @@
|
|
1
1
|
{
|
2
2
|
"$schema": "https://json.schemastore.org/swcrc",
|
3
|
-
"env": {
|
4
|
-
"targets": {
|
5
|
-
"chrome": "84",
|
6
|
-
"edge": "84",
|
7
|
-
"firefox": "75",
|
8
|
-
"opera": "73",
|
9
|
-
"safari": "14.1"
|
10
|
-
},
|
11
|
-
"bugfixes": true
|
12
|
-
},
|
13
3
|
"exclude": [
|
14
4
|
"/testing",
|
15
5
|
"/**/*.cy.ts",
|
@@ -32,7 +22,8 @@
|
|
32
22
|
"runtime": "classic",
|
33
23
|
"useSpread": true
|
34
24
|
}
|
35
|
-
}
|
25
|
+
},
|
26
|
+
"target": "es2019"
|
36
27
|
},
|
37
28
|
"minify": false,
|
38
29
|
"sourceMaps": true
|
package/CHANGELOG.json
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
"name": "@fluentui/react-spinbutton",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
6
|
-
"tag": "@fluentui/react-spinbutton_v0.0.0-nightly-
|
7
|
-
"version": "0.0.0-nightly-
|
5
|
+
"date": "Wed, 22 Mar 2023 04:46:51 GMT",
|
6
|
+
"tag": "@fluentui/react-spinbutton_v0.0.0-nightly-20230322-0439.1",
|
7
|
+
"version": "0.0.0-nightly-20230322-0439.1",
|
8
8
|
"comments": {
|
9
9
|
"prerelease": [
|
10
10
|
{
|
@@ -16,44 +16,113 @@
|
|
16
16
|
{
|
17
17
|
"author": "beachball",
|
18
18
|
"package": "@fluentui/react-spinbutton",
|
19
|
-
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-
|
20
|
-
"commit": "
|
19
|
+
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-20230322-0439.1",
|
20
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
21
21
|
},
|
22
22
|
{
|
23
23
|
"author": "beachball",
|
24
24
|
"package": "@fluentui/react-spinbutton",
|
25
|
-
"comment": "Bump @fluentui/react-field to v0.0.0-nightly-
|
26
|
-
"commit": "
|
25
|
+
"comment": "Bump @fluentui/react-field to v0.0.0-nightly-20230322-0439.1",
|
26
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
27
27
|
},
|
28
28
|
{
|
29
29
|
"author": "beachball",
|
30
30
|
"package": "@fluentui/react-spinbutton",
|
31
|
-
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-
|
32
|
-
"commit": "
|
31
|
+
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230322-0439.1",
|
32
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
33
33
|
},
|
34
34
|
{
|
35
35
|
"author": "beachball",
|
36
36
|
"package": "@fluentui/react-spinbutton",
|
37
|
-
"comment": "Bump @fluentui/react-theme to v0.0.0-nightly-
|
38
|
-
"commit": "
|
37
|
+
"comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20230322-0439.1",
|
38
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
39
39
|
},
|
40
40
|
{
|
41
41
|
"author": "beachball",
|
42
42
|
"package": "@fluentui/react-spinbutton",
|
43
|
-
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-
|
44
|
-
"commit": "
|
43
|
+
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230322-0439.1",
|
44
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
45
45
|
},
|
46
46
|
{
|
47
47
|
"author": "beachball",
|
48
48
|
"package": "@fluentui/react-spinbutton",
|
49
|
-
"comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-
|
50
|
-
"commit": "
|
49
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230322-0439.1",
|
50
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
51
51
|
},
|
52
52
|
{
|
53
53
|
"author": "beachball",
|
54
54
|
"package": "@fluentui/react-spinbutton",
|
55
|
-
"comment": "Bump @fluentui/react-label to v0.0.0-nightly-
|
56
|
-
"commit": "
|
55
|
+
"comment": "Bump @fluentui/react-label to v0.0.0-nightly-20230322-0439.1",
|
56
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
57
|
+
}
|
58
|
+
]
|
59
|
+
}
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"date": "Tue, 21 Mar 2023 21:23:03 GMT",
|
63
|
+
"tag": "@fluentui/react-spinbutton_v9.2.5",
|
64
|
+
"version": "9.2.5",
|
65
|
+
"comments": {
|
66
|
+
"patch": [
|
67
|
+
{
|
68
|
+
"author": "tristan.watanabe@gmail.com",
|
69
|
+
"package": "@fluentui/react-spinbutton",
|
70
|
+
"commit": "2fac1a139149bd13b76b1306207bc988dca9c72c",
|
71
|
+
"comment": "chore: migrate to swc transpilation approach."
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"author": "tristan.watanabe@gmail.com",
|
75
|
+
"package": "@fluentui/react-spinbutton",
|
76
|
+
"commit": "ead1c6d4c2ac3f3596b62b8cbc07b0a03041f11f",
|
77
|
+
"comment": "fix: add node field to package.json exports map."
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"author": "makotom@microsoft.com",
|
81
|
+
"package": "@fluentui/react-spinbutton",
|
82
|
+
"commit": "7fde5c94869ff9841b142b7ff1d0a3df0ab58f74",
|
83
|
+
"comment": "chore: Bumping version of @fluentui/react-icons to ^2.0.196."
|
84
|
+
},
|
85
|
+
{
|
86
|
+
"author": "beachball",
|
87
|
+
"package": "@fluentui/react-spinbutton",
|
88
|
+
"comment": "Bump @fluentui/keyboard-keys to v9.0.2",
|
89
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
90
|
+
},
|
91
|
+
{
|
92
|
+
"author": "beachball",
|
93
|
+
"package": "@fluentui/react-spinbutton",
|
94
|
+
"comment": "Bump @fluentui/react-field to v9.0.0-alpha.27",
|
95
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
96
|
+
},
|
97
|
+
{
|
98
|
+
"author": "beachball",
|
99
|
+
"package": "@fluentui/react-spinbutton",
|
100
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.3.2",
|
101
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
102
|
+
},
|
103
|
+
{
|
104
|
+
"author": "beachball",
|
105
|
+
"package": "@fluentui/react-spinbutton",
|
106
|
+
"comment": "Bump @fluentui/react-theme to v9.1.7",
|
107
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
108
|
+
},
|
109
|
+
{
|
110
|
+
"author": "beachball",
|
111
|
+
"package": "@fluentui/react-spinbutton",
|
112
|
+
"comment": "Bump @fluentui/react-utilities to v9.7.2",
|
113
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
114
|
+
},
|
115
|
+
{
|
116
|
+
"author": "beachball",
|
117
|
+
"package": "@fluentui/react-spinbutton",
|
118
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.20",
|
119
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
120
|
+
},
|
121
|
+
{
|
122
|
+
"author": "beachball",
|
123
|
+
"package": "@fluentui/react-spinbutton",
|
124
|
+
"comment": "Bump @fluentui/react-label to v9.1.5",
|
125
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
57
126
|
}
|
58
127
|
]
|
59
128
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,24 +1,42 @@
|
|
1
1
|
# Change Log - @fluentui/react-spinbutton
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Wed, 22 Mar 2023 04:46:51 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-nightly-
|
7
|
+
## [0.0.0-nightly-20230322-0439.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinbutton_v0.0.0-nightly-20230322-0439.1)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinbutton_v9.2.
|
9
|
+
Wed, 22 Mar 2023 04:46:51 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinbutton_v9.2.5..@fluentui/react-spinbutton_v0.0.0-nightly-20230322-0439.1)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
14
14
|
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
|
15
|
-
- Bump @fluentui/keyboard-keys to v0.0.0-nightly-
|
16
|
-
- Bump @fluentui/react-field to v0.0.0-nightly-
|
17
|
-
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-
|
18
|
-
- Bump @fluentui/react-theme to v0.0.0-nightly-
|
19
|
-
- Bump @fluentui/react-utilities to v0.0.0-nightly-
|
20
|
-
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-
|
21
|
-
- Bump @fluentui/react-label to v0.0.0-nightly-
|
15
|
+
- Bump @fluentui/keyboard-keys to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
16
|
+
- Bump @fluentui/react-field to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
17
|
+
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
18
|
+
- Bump @fluentui/react-theme to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
19
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
20
|
+
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
21
|
+
- Bump @fluentui/react-label to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
22
|
+
|
23
|
+
## [9.2.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinbutton_v9.2.5)
|
24
|
+
|
25
|
+
Tue, 21 Mar 2023 21:23:03 GMT
|
26
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinbutton_v9.2.4..@fluentui/react-spinbutton_v9.2.5)
|
27
|
+
|
28
|
+
### Patches
|
29
|
+
|
30
|
+
- chore: migrate to swc transpilation approach. ([PR #27250](https://github.com/microsoft/fluentui/pull/27250) by tristan.watanabe@gmail.com)
|
31
|
+
- fix: add node field to package.json exports map. ([PR #27154](https://github.com/microsoft/fluentui/pull/27154) by tristan.watanabe@gmail.com)
|
32
|
+
- chore: Bumping version of @fluentui/react-icons to ^2.0.196. ([PR #27100](https://github.com/microsoft/fluentui/pull/27100) by makotom@microsoft.com)
|
33
|
+
- Bump @fluentui/keyboard-keys to v9.0.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
34
|
+
- Bump @fluentui/react-field to v9.0.0-alpha.27 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
35
|
+
- Bump @fluentui/react-shared-contexts to v9.3.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
36
|
+
- Bump @fluentui/react-theme to v9.1.7 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
37
|
+
- Bump @fluentui/react-utilities to v9.7.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
38
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.20 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
39
|
+
- Bump @fluentui/react-label to v9.1.5 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
22
40
|
|
23
41
|
## [9.2.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinbutton_v9.2.4)
|
24
42
|
|
package/lib/SpinButton.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from
|
1
|
+
export * from './components/SpinButton/index';
|
2
2
|
//# sourceMappingURL=SpinButton.js.map
|
package/lib/SpinButtonField.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from
|
1
|
+
export * from './components/SpinButtonField/index';
|
2
2
|
//# sourceMappingURL=SpinButtonField.js.map
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { useSpinButton_unstable } from
|
3
|
-
import { renderSpinButton_unstable } from
|
4
|
-
import { useSpinButtonStyles_unstable } from
|
5
|
-
import { useCustomStyleHooks_unstable } from
|
1
|
+
import * as React from 'react';
|
2
|
+
import { useSpinButton_unstable } from './useSpinButton';
|
3
|
+
import { renderSpinButton_unstable } from './renderSpinButton';
|
4
|
+
import { useSpinButtonStyles_unstable } from './useSpinButtonStyles';
|
5
|
+
import { useCustomStyleHooks_unstable } from '@fluentui/react-shared-contexts';
|
6
6
|
/**
|
7
7
|
* A SpinButton allows someone to incrementally adjust a value in small steps.
|
8
8
|
*/
|
@@ -15,5 +15,5 @@ export const SpinButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
15
15
|
useCustomStyles(state);
|
16
16
|
return renderSpinButton_unstable(state);
|
17
17
|
});
|
18
|
-
SpinButton.displayName =
|
18
|
+
SpinButton.displayName = 'SpinButton';
|
19
19
|
//# sourceMappingURL=SpinButton.js.map
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import * as React from
|
1
|
+
import * as React from 'react';
|
2
2
|
//# sourceMappingURL=SpinButton.types.js.map
|
@@ -1,6 +1,6 @@
|
|
1
|
-
export * from
|
2
|
-
export * from
|
3
|
-
export * from
|
4
|
-
export * from
|
5
|
-
export * from
|
1
|
+
export * from './SpinButton';
|
2
|
+
export * from './SpinButton.types';
|
3
|
+
export * from './renderSpinButton';
|
4
|
+
export * from './useSpinButton';
|
5
|
+
export * from './useSpinButtonStyles';
|
6
6
|
//# sourceMappingURL=index.js.map
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useControllableState, useTimeout } from
|
3
|
-
import { ArrowUp, ArrowDown, End, Enter, Escape, Home, PageDown, PageUp } from
|
4
|
-
import { calculatePrecision, precisionRound, getBound, clamp } from
|
5
|
-
import { ChevronUp16Regular, ChevronDown16Regular } from
|
6
|
-
import { useOverrides_unstable as useOverrides } from
|
1
|
+
import * as React from 'react';
|
2
|
+
import { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useControllableState, useTimeout } from '@fluentui/react-utilities';
|
3
|
+
import { ArrowUp, ArrowDown, End, Enter, Escape, Home, PageDown, PageUp } from '@fluentui/keyboard-keys';
|
4
|
+
import { calculatePrecision, precisionRound, getBound, clamp } from '../../utils/index';
|
5
|
+
import { ChevronUp16Regular, ChevronDown16Regular } from '@fluentui/react-icons';
|
6
|
+
import { useOverrides_unstable as useOverrides } from '@fluentui/react-shared-contexts';
|
7
7
|
const DEFAULT_SPIN_DELAY_MS = 150;
|
8
8
|
const MIN_SPIN_DELAY_MS = 80;
|
9
9
|
const MAX_SPIN_TIME_MS = 1000;
|
@@ -23,10 +23,11 @@ const lerp = (start, end, percent) => start + (end - start) * percent;
|
|
23
23
|
export const useSpinButton_unstable = (props, ref) => {
|
24
24
|
const nativeProps = getPartitionedNativeProps({
|
25
25
|
props,
|
26
|
-
primarySlotTagName:
|
27
|
-
excludedPropNames: [
|
26
|
+
primarySlotTagName: 'input',
|
27
|
+
excludedPropNames: ['defaultValue', 'max', 'min', 'onChange', 'size', 'value']
|
28
28
|
});
|
29
29
|
const overrides = useOverrides();
|
30
|
+
var _overrides_inputDefaultAppearance;
|
30
31
|
const {
|
31
32
|
value,
|
32
33
|
displayValue,
|
@@ -37,15 +38,15 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
37
38
|
stepPage = 1,
|
38
39
|
precision: precisionFromProps,
|
39
40
|
onChange,
|
40
|
-
size =
|
41
|
-
appearance = overrides.inputDefaultAppearance
|
41
|
+
size = 'medium',
|
42
|
+
appearance = (_overrides_inputDefaultAppearance = overrides.inputDefaultAppearance) !== null && _overrides_inputDefaultAppearance !== void 0 ? _overrides_inputDefaultAppearance : 'outline',
|
42
43
|
root,
|
43
44
|
input,
|
44
45
|
incrementButton,
|
45
46
|
decrementButton
|
46
47
|
} = props;
|
47
48
|
const precision = React.useMemo(() => {
|
48
|
-
return precisionFromProps
|
49
|
+
return precisionFromProps !== null && precisionFromProps !== void 0 ? precisionFromProps : Math.max(calculatePrecision(step), 0);
|
49
50
|
}, [precisionFromProps, step]);
|
50
51
|
const [currentValue, setCurrentValue] = useControllableState({
|
51
52
|
state: value,
|
@@ -54,13 +55,13 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
54
55
|
});
|
55
56
|
const isControlled = value !== undefined;
|
56
57
|
const [textValue, setTextValue] = React.useState(undefined);
|
57
|
-
const [keyboardSpinState, setKeyboardSpinState] = React.useState(
|
58
|
+
const [keyboardSpinState, setKeyboardSpinState] = React.useState('rest');
|
58
59
|
const internalState = React.useRef({
|
59
60
|
value: currentValue,
|
60
|
-
spinState:
|
61
|
+
spinState: 'rest',
|
61
62
|
spinTime: 0,
|
62
63
|
spinDelay: DEFAULT_SPIN_DELAY_MS,
|
63
|
-
atBound: currentValue !== null ? getBound(precisionRound(currentValue, precision), min, max) :
|
64
|
+
atBound: currentValue !== null ? getBound(precisionRound(currentValue, precision), min, max) : 'none'
|
64
65
|
});
|
65
66
|
const [setStepTimeout, clearStepTimeout] = useTimeout();
|
66
67
|
const stepValue = (e, direction, startFrom) => {
|
@@ -72,8 +73,8 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
72
73
|
}
|
73
74
|
}
|
74
75
|
const val = startValue;
|
75
|
-
const dir = direction ===
|
76
|
-
const stepSize = direction ===
|
76
|
+
const dir = direction === 'up' || direction === 'upPage' ? 1 : -1;
|
77
|
+
const stepSize = direction === 'upPage' || direction === 'downPage' ? stepPage : step;
|
77
78
|
if (val === null) {
|
78
79
|
const stepStart = min === undefined ? 0 : min;
|
79
80
|
const nullStep = clamp(stepStart + stepSize * dir, min, max);
|
@@ -85,7 +86,7 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
85
86
|
newValue = clamp(newValue, min, max);
|
86
87
|
}
|
87
88
|
commit(e, newValue);
|
88
|
-
if (internalState.current.spinState !==
|
89
|
+
if (internalState.current.spinState !== 'rest') {
|
89
90
|
setStepTimeout(() => {
|
90
91
|
// Ease the step speed a bit
|
91
92
|
internalState.current.spinTime += internalState.current.spinDelay;
|
@@ -96,22 +97,22 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
96
97
|
};
|
97
98
|
const handleInputChange = e => {
|
98
99
|
if (!internalState.current.previousTextValue) {
|
99
|
-
internalState.current.previousTextValue = textValue
|
100
|
+
internalState.current.previousTextValue = textValue !== null && textValue !== void 0 ? textValue : String(currentValue);
|
100
101
|
}
|
101
102
|
const newValue = e.target.value;
|
102
103
|
setTextValue(newValue);
|
103
104
|
};
|
104
105
|
const handleIncrementMouseDown = e => {
|
105
|
-
internalState.current.spinState =
|
106
|
-
stepValue(e,
|
106
|
+
internalState.current.spinState = 'up';
|
107
|
+
stepValue(e, 'up');
|
107
108
|
};
|
108
109
|
const handleDecrementMouseDown = e => {
|
109
|
-
internalState.current.spinState =
|
110
|
-
stepValue(e,
|
110
|
+
internalState.current.spinState = 'down';
|
111
|
+
stepValue(e, 'down');
|
111
112
|
};
|
112
113
|
const handleStepMouseUpOrLeave = e => {
|
113
114
|
clearStepTimeout();
|
114
|
-
internalState.current.spinState =
|
115
|
+
internalState.current.spinState = 'rest';
|
115
116
|
internalState.current.spinDelay = DEFAULT_SPIN_DELAY_MS;
|
116
117
|
internalState.current.spinTime = 0;
|
117
118
|
};
|
@@ -120,27 +121,27 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
120
121
|
internalState.current.previousTextValue = undefined;
|
121
122
|
};
|
122
123
|
const handleKeyDown = e => {
|
123
|
-
let nextKeyboardSpinState =
|
124
|
+
let nextKeyboardSpinState = 'rest';
|
124
125
|
if (e.key === ArrowUp) {
|
125
|
-
stepValue(e,
|
126
|
-
nextKeyboardSpinState =
|
126
|
+
stepValue(e, 'up', textValue);
|
127
|
+
nextKeyboardSpinState = 'up';
|
127
128
|
} else if (e.key === ArrowDown) {
|
128
|
-
stepValue(e,
|
129
|
-
nextKeyboardSpinState =
|
129
|
+
stepValue(e, 'down', textValue);
|
130
|
+
nextKeyboardSpinState = 'down';
|
130
131
|
} else if (e.key === PageUp) {
|
131
132
|
e.preventDefault();
|
132
|
-
stepValue(e,
|
133
|
-
nextKeyboardSpinState =
|
133
|
+
stepValue(e, 'upPage', textValue);
|
134
|
+
nextKeyboardSpinState = 'up';
|
134
135
|
} else if (e.key === PageDown) {
|
135
136
|
e.preventDefault();
|
136
|
-
stepValue(e,
|
137
|
-
nextKeyboardSpinState =
|
137
|
+
stepValue(e, 'downPage', textValue);
|
138
|
+
nextKeyboardSpinState = 'down';
|
138
139
|
} else if (!e.shiftKey && e.key === Home && min !== undefined) {
|
139
140
|
commit(e, min);
|
140
|
-
nextKeyboardSpinState =
|
141
|
+
nextKeyboardSpinState = 'down';
|
141
142
|
} else if (!e.shiftKey && e.key === End && max !== undefined) {
|
142
143
|
commit(e, max);
|
143
|
-
nextKeyboardSpinState =
|
144
|
+
nextKeyboardSpinState = 'up';
|
144
145
|
} else if (e.key === Enter) {
|
145
146
|
commit(e, currentValue, textValue);
|
146
147
|
internalState.current.previousTextValue = undefined;
|
@@ -155,9 +156,9 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
155
156
|
}
|
156
157
|
};
|
157
158
|
const handleKeyUp = e => {
|
158
|
-
if (keyboardSpinState !==
|
159
|
-
setKeyboardSpinState(
|
160
|
-
internalState.current.spinState =
|
159
|
+
if (keyboardSpinState !== 'rest') {
|
160
|
+
setKeyboardSpinState('rest');
|
161
|
+
internalState.current.spinState = 'rest';
|
161
162
|
}
|
162
163
|
};
|
163
164
|
const commit = (e, newValue, newDisplayValue) => {
|
@@ -174,7 +175,7 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
174
175
|
}
|
175
176
|
}
|
176
177
|
if (valueChanged || displayValueChanged) {
|
177
|
-
onChange
|
178
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e, {
|
178
179
|
value: roundedValue,
|
179
180
|
displayValue: newDisplayValue
|
180
181
|
});
|
@@ -187,10 +188,10 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
187
188
|
spinState: keyboardSpinState,
|
188
189
|
atBound: internalState.current.atBound,
|
189
190
|
components: {
|
190
|
-
root:
|
191
|
-
input:
|
192
|
-
incrementButton:
|
193
|
-
decrementButton:
|
191
|
+
root: 'span',
|
192
|
+
input: 'input',
|
193
|
+
incrementButton: 'button',
|
194
|
+
decrementButton: 'button'
|
194
195
|
},
|
195
196
|
root: resolveShorthand(root, {
|
196
197
|
required: true,
|
@@ -200,10 +201,10 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
200
201
|
required: true,
|
201
202
|
defaultProps: {
|
202
203
|
ref,
|
203
|
-
autoComplete:
|
204
|
-
role:
|
204
|
+
autoComplete: 'off',
|
205
|
+
role: 'spinbutton',
|
205
206
|
appearance,
|
206
|
-
type:
|
207
|
+
type: 'text',
|
207
208
|
...nativeProps.primary
|
208
209
|
}
|
209
210
|
}),
|
@@ -213,8 +214,8 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
213
214
|
tabIndex: -1,
|
214
215
|
children: /*#__PURE__*/React.createElement(ChevronUp16Regular, null),
|
215
216
|
disabled: nativeProps.primary.disabled,
|
216
|
-
|
217
|
-
type:
|
217
|
+
'aria-label': 'Increment value',
|
218
|
+
type: 'button'
|
218
219
|
}
|
219
220
|
}),
|
220
221
|
decrementButton: resolveShorthand(decrementButton, {
|
@@ -223,8 +224,8 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
223
224
|
tabIndex: -1,
|
224
225
|
children: /*#__PURE__*/React.createElement(ChevronDown16Regular, null),
|
225
226
|
disabled: nativeProps.primary.disabled,
|
226
|
-
|
227
|
-
type:
|
227
|
+
'aria-label': 'Decrement value',
|
228
|
+
type: 'button'
|
228
229
|
}
|
229
230
|
})
|
230
231
|
};
|
@@ -232,24 +233,25 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
232
233
|
if (textValue !== undefined) {
|
233
234
|
valueToDisplay = textValue;
|
234
235
|
} else if (value === null || currentValue === null) {
|
235
|
-
valueToDisplay = displayValue
|
236
|
+
valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : '';
|
236
237
|
internalState.current.value = null;
|
237
|
-
internalState.current.atBound =
|
238
|
+
internalState.current.atBound = 'none';
|
238
239
|
} else {
|
239
240
|
const roundedValue = precisionRound(currentValue, precision);
|
240
241
|
internalState.current.value = roundedValue;
|
241
242
|
internalState.current.atBound = getBound(roundedValue, min, max);
|
242
243
|
if (isControlled) {
|
243
|
-
valueToDisplay = displayValue
|
244
|
+
valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : String(roundedValue);
|
244
245
|
} else {
|
245
246
|
valueToDisplay = String(roundedValue);
|
246
247
|
}
|
247
248
|
}
|
248
249
|
state.input.value = valueToDisplay;
|
249
|
-
state.input[
|
250
|
-
state.input[
|
251
|
-
state.input[
|
252
|
-
|
250
|
+
state.input['aria-valuemin'] = min;
|
251
|
+
state.input['aria-valuemax'] = max;
|
252
|
+
state.input['aria-valuenow'] = currentValue !== null && currentValue !== void 0 ? currentValue : undefined;
|
253
|
+
var _state_input_ariavaluetext;
|
254
|
+
state.input['aria-valuetext'] = (_state_input_ariavaluetext = state.input['aria-valuetext']) !== null && _state_input_ariavaluetext !== void 0 ? _state_input_ariavaluetext : value !== undefined && displayValue || undefined;
|
253
255
|
state.input.onChange = mergeCallbacks(state.input.onChange, handleInputChange);
|
254
256
|
state.input.onBlur = mergeCallbacks(state.input.onBlur, handleBlur);
|
255
257
|
state.input.onKeyDown = mergeCallbacks(state.input.onKeyDown, handleKeyDown);
|