@fluentui/react-spinbutton 0.0.0-nightly-20230317-0436.1 → 0.0.0-nightly-20230317-1454.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 +39 -0
- package/CHANGELOG.json +17 -17
- package/CHANGELOG.md +11 -11
- package/lib/SpinButton.js +1 -1
- package/lib/SpinButton.js.map +1 -1
- package/lib/SpinButtonField.js +1 -1
- package/lib/SpinButtonField.js.map +1 -1
- package/lib/components/SpinButton/SpinButton.js +6 -6
- 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 +5 -5
- package/lib/components/SpinButton/index.js.map +1 -1
- package/lib/components/SpinButton/renderSpinButton.js +3 -11
- package/lib/components/SpinButton/renderSpinButton.js.map +1 -1
- package/lib/components/SpinButton/useSpinButton.js +56 -57
- package/lib/components/SpinButton/useSpinButton.js.map +1 -1
- package/lib/components/SpinButton/useSpinButtonStyles.js +14 -14
- package/lib/components/SpinButton/useSpinButtonStyles.js.map +1 -1
- package/lib/components/SpinButtonField/SpinButtonField.js +2 -3
- package/lib/components/SpinButtonField/SpinButtonField.js.map +1 -1
- package/lib/components/SpinButtonField/index.js +1 -1
- package/lib/components/SpinButtonField/index.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/utils/clamp.js +1 -1
- package/lib/utils/clamp.js.map +1 -1
- package/lib/utils/getBound.js +4 -4
- package/lib/utils/getBound.js.map +1 -1
- package/lib/utils/index.js +3 -3
- 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 +246 -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 +10 -10
package/.swcrc
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
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
|
+
"exclude": [
|
14
|
+
"/testing",
|
15
|
+
"/**/*.cy.ts",
|
16
|
+
"/**/*.cy.tsx",
|
17
|
+
"/**/*.spec.ts",
|
18
|
+
"/**/*.spec.tsx",
|
19
|
+
"/**/*.test.ts",
|
20
|
+
"/**/*.test.tsx"
|
21
|
+
],
|
22
|
+
"jsc": {
|
23
|
+
"parser": {
|
24
|
+
"syntax": "typescript",
|
25
|
+
"tsx": true,
|
26
|
+
"decorators": false,
|
27
|
+
"dynamicImport": false
|
28
|
+
},
|
29
|
+
"externalHelpers": true,
|
30
|
+
"transform": {
|
31
|
+
"react": {
|
32
|
+
"runtime": "classic",
|
33
|
+
"useSpread": true
|
34
|
+
}
|
35
|
+
}
|
36
|
+
},
|
37
|
+
"minify": false,
|
38
|
+
"sourceMaps": true
|
39
|
+
}
|
package/CHANGELOG.json
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
"name": "@fluentui/react-spinbutton",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "Fri, 17 Mar 2023
|
6
|
-
"tag": "@fluentui/react-spinbutton_v0.0.0-nightly-20230317-
|
7
|
-
"version": "0.0.0-nightly-20230317-
|
5
|
+
"date": "Fri, 17 Mar 2023 15:00:04 GMT",
|
6
|
+
"tag": "@fluentui/react-spinbutton_v0.0.0-nightly-20230317-1454.1",
|
7
|
+
"version": "0.0.0-nightly-20230317-1454.1",
|
8
8
|
"comments": {
|
9
9
|
"prerelease": [
|
10
10
|
{
|
@@ -16,44 +16,44 @@
|
|
16
16
|
{
|
17
17
|
"author": "beachball",
|
18
18
|
"package": "@fluentui/react-spinbutton",
|
19
|
-
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-20230317-
|
20
|
-
"commit": "
|
19
|
+
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-20230317-1454.1",
|
20
|
+
"commit": "636275472966fa37b1efc14ac2e70ad32bd39b86"
|
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-20230317-
|
26
|
-
"commit": "
|
25
|
+
"comment": "Bump @fluentui/react-field to v0.0.0-nightly-20230317-1454.1",
|
26
|
+
"commit": "636275472966fa37b1efc14ac2e70ad32bd39b86"
|
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-20230317-
|
32
|
-
"commit": "
|
31
|
+
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230317-1454.1",
|
32
|
+
"commit": "636275472966fa37b1efc14ac2e70ad32bd39b86"
|
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-20230317-
|
38
|
-
"commit": "
|
37
|
+
"comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20230317-1454.1",
|
38
|
+
"commit": "636275472966fa37b1efc14ac2e70ad32bd39b86"
|
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-20230317-
|
44
|
-
"commit": "
|
43
|
+
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230317-1454.1",
|
44
|
+
"commit": "636275472966fa37b1efc14ac2e70ad32bd39b86"
|
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-20230317-
|
50
|
-
"commit": "
|
49
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230317-1454.1",
|
50
|
+
"commit": "636275472966fa37b1efc14ac2e70ad32bd39b86"
|
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-20230317-
|
56
|
-
"commit": "
|
55
|
+
"comment": "Bump @fluentui/react-label to v0.0.0-nightly-20230317-1454.1",
|
56
|
+
"commit": "636275472966fa37b1efc14ac2e70ad32bd39b86"
|
57
57
|
}
|
58
58
|
]
|
59
59
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# Change Log - @fluentui/react-spinbutton
|
2
2
|
|
3
|
-
This log was last generated on Fri, 17 Mar 2023
|
3
|
+
This log was last generated on Fri, 17 Mar 2023 15:00:04 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-nightly-20230317-
|
7
|
+
## [0.0.0-nightly-20230317-1454.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinbutton_v0.0.0-nightly-20230317-1454.1)
|
8
8
|
|
9
|
-
Fri, 17 Mar 2023
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinbutton_v9.2.4..@fluentui/react-spinbutton_v0.0.0-nightly-20230317-
|
9
|
+
Fri, 17 Mar 2023 15:00:04 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinbutton_v9.2.4..@fluentui/react-spinbutton_v0.0.0-nightly-20230317-1454.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-20230317-
|
16
|
-
- Bump @fluentui/react-field to v0.0.0-nightly-20230317-
|
17
|
-
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230317-
|
18
|
-
- Bump @fluentui/react-theme to v0.0.0-nightly-20230317-
|
19
|
-
- Bump @fluentui/react-utilities to v0.0.0-nightly-20230317-
|
20
|
-
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230317-
|
21
|
-
- Bump @fluentui/react-label to v0.0.0-nightly-20230317-
|
15
|
+
- Bump @fluentui/keyboard-keys to v0.0.0-nightly-20230317-1454.1 ([commit](https://github.com/microsoft/fluentui/commit/636275472966fa37b1efc14ac2e70ad32bd39b86) by beachball)
|
16
|
+
- Bump @fluentui/react-field to v0.0.0-nightly-20230317-1454.1 ([commit](https://github.com/microsoft/fluentui/commit/636275472966fa37b1efc14ac2e70ad32bd39b86) by beachball)
|
17
|
+
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230317-1454.1 ([commit](https://github.com/microsoft/fluentui/commit/636275472966fa37b1efc14ac2e70ad32bd39b86) by beachball)
|
18
|
+
- Bump @fluentui/react-theme to v0.0.0-nightly-20230317-1454.1 ([commit](https://github.com/microsoft/fluentui/commit/636275472966fa37b1efc14ac2e70ad32bd39b86) by beachball)
|
19
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly-20230317-1454.1 ([commit](https://github.com/microsoft/fluentui/commit/636275472966fa37b1efc14ac2e70ad32bd39b86) by beachball)
|
20
|
+
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230317-1454.1 ([commit](https://github.com/microsoft/fluentui/commit/636275472966fa37b1efc14ac2e70ad32bd39b86) by beachball)
|
21
|
+
- Bump @fluentui/react-label to v0.0.0-nightly-20230317-1454.1 ([commit](https://github.com/microsoft/fluentui/commit/636275472966fa37b1efc14ac2e70ad32bd39b86) by beachball)
|
22
22
|
|
23
23
|
## [9.2.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinbutton_v9.2.4)
|
24
24
|
|
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/SpinButton.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":[],"sources":["../src/SpinButton.ts"],"sourcesContent":["export * from './components/SpinButton/index';\n"],"mappings":"AAAA,cAAc"}
|
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 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":[],"sources":["../src/SpinButtonField.ts"],"sourcesContent":["export * from './components/SpinButtonField/index';\n"],"mappings":"AAAA,cAAc"}
|
@@ -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 +1 @@
|
|
1
|
-
{"version":3,"names":["React","useSpinButton_unstable","renderSpinButton_unstable","useSpinButtonStyles_unstable","useCustomStyleHooks_unstable","SpinButton","forwardRef","props","ref","state","useCustomStyles","displayName"],"sources":["
|
1
|
+
{"version":3,"names":["React","useSpinButton_unstable","renderSpinButton_unstable","useSpinButtonStyles_unstable","useCustomStyleHooks_unstable","SpinButton","forwardRef","props","ref","state","useCustomStyles","displayName"],"sources":["../../../src/components/SpinButton/SpinButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useSpinButton_unstable } from './useSpinButton';\nimport { renderSpinButton_unstable } from './renderSpinButton';\nimport { useSpinButtonStyles_unstable } from './useSpinButtonStyles';\nimport type { SpinButtonProps } from './SpinButton.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHooks_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * A SpinButton allows someone to incrementally adjust a value in small steps.\n */\nexport const SpinButton: ForwardRefComponent<SpinButtonProps> = React.forwardRef((props, ref) => {\n const state = useSpinButton_unstable(props, ref);\n\n useSpinButtonStyles_unstable(state);\n\n const { useSpinButtonStyles_unstable: useCustomStyles } = useCustomStyleHooks_unstable();\n useCustomStyles(state);\n\n return renderSpinButton_unstable(state);\n});\n\nSpinButton.displayName = 'SpinButton';\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,sBAAsB,QAAQ;AACvC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,4BAA4B,QAAQ;AAG7C,SAASC,4BAA4B,QAAQ;AAE7C;;;AAGA,OAAO,MAAMC,UAAA,gBAAmDL,KAAA,CAAMM,UAAU,CAAC,CAACC,KAAA,EAAOC,GAAA,KAAQ;EAC/F,MAAMC,KAAA,GAAQR,sBAAA,CAAuBM,KAAA,EAAOC,GAAA;EAE5CL,4BAAA,CAA6BM,KAAA;EAE7B,MAAM;IAAEN,4BAAA,EAA8BO;EAAe,CAAE,GAAGN,4BAAA;EAC1DM,eAAA,CAAgBD,KAAA;EAEhB,OAAOP,yBAAA,CAA0BO,KAAA;AACnC;AAEAJ,UAAA,CAAWM,WAAW,GAAG"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
import * as React from "react";
|
2
2
|
//# sourceMappingURL=SpinButton.types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["React"],"sources":["../../../src/components/SpinButton/SpinButton.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nexport type SpinButtonSlots = {\n /**\n * The root element of SpinButton is a container `<div>`.\n * The root slot receives the `className` and `style` specified on the `<SpinButton>`.\n * All other native props are applied to the primary slot: `input`.\n */\n root: NonNullable<Slot<'span'>>;\n\n /**\n * Input that displays the current value and accepts direct input from the user.\n * Displayed value is formatted.\n *\n * This is the primary slot.\n */\n input: NonNullable<Slot<'input'>>;\n\n /**\n * Renders the increment control.\n */\n incrementButton: NonNullable<Slot<'button'>>;\n\n /**\n * Renders the decrement control.\n */\n decrementButton: NonNullable<Slot<'button'>>;\n};\n\n/**\n * SpinButton Props\n */\nexport type SpinButtonProps = Omit<\n ComponentProps<Partial<SpinButtonSlots>, 'input'>,\n 'defaultValue' | 'onChange' | 'size' | 'value'\n> & {\n /**\n * Controls the colors and borders of the input.\n * @default 'outline'\n */\n appearance?: 'outline' | 'underline' | 'filled-darker' | 'filled-lighter';\n\n /**\n * Initial value of the control (assumed to be valid). Updates to this prop will not be respected.\n *\n * Use this if you intend for the SpinButton to be an uncontrolled component which maintains its\n * own value. For a controlled component, use `value` instead. (Mutually exclusive with `value`.)\n *\n * Use `null` to indicate the control has no value.\n */\n defaultValue?: number | null;\n\n /**\n * String representation of `value`.\n *\n * Use this when displaying the value to users as something other than a plain number.\n * For example, when displaying currency values this might be \"$1.00\" when value is `1`.\n *\n * Only provide this if the SpinButton is a controlled component where you are maintaining its\n * current state and passing updates based on change events. When SpinButton is used as an\n * uncontrolled component this prop is ignored.\n */\n displayValue?: string;\n\n /**\n * Max value of the control. If not provided, the control has no maximum value.\n */\n max?: number;\n\n /**\n * Min value of the control. If not provided, the control has no minimum value.\n */\n min?: number;\n\n /**\n * Callback for when the committed value changes.\n * - User presses the up/down buttons (on single press or every spin)\n * - User presses the up/down arrow keys (on single press or every spin)\n * - User *commits* edits to the input text by focusing away (blurring) or pressing enter.\n * Note that this is NOT called for every key press while the user is editing.\n */\n onChange?: (event: SpinButtonChangeEvent, data: SpinButtonOnChangeData) => void;\n\n /**\n * How many decimal places the value should be rounded to.\n *\n * The default is calculated based on the precision of `step`: i.e. if step = 1, precision = 0.\n * step = 0.0089, precision = 4. step = 300, precision = 2. step = 23.00, precision = 2.\n */\n precision?: number;\n\n /**\n * Size of the input.\n * @default 'medium'\n */\n size?: 'small' | 'medium';\n\n /**\n * Difference between two adjacent values of the control.\n * This value is used to calculate the precision of the input if no `precision` is given.\n * The precision calculated this way will always be greater than or equal 0.\n * @default 1\n */\n step?: number;\n\n /**\n * Large difference between two values. This should be greater than `step` and is used\n * when users hit the Page Up or Page Down keys.\n * @default 1\n */\n stepPage?: number;\n\n /**\n * Current value of the control (assumed to be valid).\n *\n * Only provide this if the SpinButton is a controlled component where you are maintaining its\n * current state and passing updates based on change events; otherwise, use the `defaultValue`\n * property.\n *\n * Use `null` to indicate the control has no value.\n *\n * Mutually exclusive with `defaultValue`.\n */\n value?: number | null;\n};\n\n/**\n * State used in rendering SpinButton\n */\nexport type SpinButtonState = ComponentState<SpinButtonSlots> &\n Required<Pick<SpinButtonProps, 'appearance' | 'size'>> & {\n /**\n * State used to track which direction, if any, SpinButton is currently spinning.\n * @default 'rest'\n */\n spinState: SpinButtonSpinState;\n\n /**\n * State used to track if the value is at the range bounds of [min-max].\n * @default 'none'\n */\n atBound: SpinButtonBounds;\n };\n\nexport type SpinButtonChangeEvent =\n | React.MouseEvent<HTMLButtonElement>\n | React.ChangeEvent<HTMLElement>\n | React.FocusEvent<HTMLInputElement>\n | React.KeyboardEvent<HTMLInputElement>;\n\nexport type SpinButtonOnChangeData = {\n value?: number | null;\n displayValue?: string;\n};\n\nexport type SpinButtonSpinState = 'rest' | 'up' | 'down';\nexport type SpinButtonBounds = 'none' | 'min' | 'max' | 'both';\n"],"mappings":"AACA,YAAYA,KAAA,MAAW"}
|
@@ -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 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/components/SpinButton/index.ts"],"sourcesContent":["export * from './SpinButton';\nexport * from './SpinButton.types';\nexport * from './renderSpinButton';\nexport * from './useSpinButton';\nexport * from './useSpinButtonStyles';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc"}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { getSlots } from
|
1
|
+
import * as React from "react";
|
2
|
+
import { getSlots } from "@fluentui/react-utilities";
|
3
3
|
/**
|
4
4
|
* Render the final JSX of SpinButton
|
5
5
|
*/
|
@@ -8,14 +8,6 @@ export const renderSpinButton_unstable = state => {
|
|
8
8
|
slots,
|
9
9
|
slotProps
|
10
10
|
} = getSlots(state);
|
11
|
-
return /*#__PURE__*/React.createElement(slots.root,
|
12
|
-
...slotProps.root
|
13
|
-
}, /*#__PURE__*/React.createElement(slots.input, {
|
14
|
-
...slotProps.input
|
15
|
-
}), /*#__PURE__*/React.createElement(slots.incrementButton, {
|
16
|
-
...slotProps.incrementButton
|
17
|
-
}), /*#__PURE__*/React.createElement(slots.decrementButton, {
|
18
|
-
...slotProps.decrementButton
|
19
|
-
}));
|
11
|
+
return /*#__PURE__*/React.createElement(slots.root, slotProps.root, /*#__PURE__*/React.createElement(slots.input, slotProps.input), /*#__PURE__*/React.createElement(slots.incrementButton, slotProps.incrementButton), /*#__PURE__*/React.createElement(slots.decrementButton, slotProps.decrementButton));
|
20
12
|
};
|
21
13
|
//# sourceMappingURL=renderSpinButton.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","getSlots","renderSpinButton_unstable","state","slots","slotProps","createElement","root","input","incrementButton","decrementButton"],"sources":["
|
1
|
+
{"version":3,"names":["React","getSlots","renderSpinButton_unstable","state","slots","slotProps","createElement","root","input","incrementButton","decrementButton"],"sources":["../../../src/components/SpinButton/renderSpinButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { SpinButtonState, SpinButtonSlots } from './SpinButton.types';\n\n/**\n * Render the final JSX of SpinButton\n */\nexport const renderSpinButton_unstable = (state: SpinButtonState) => {\n const { slots, slotProps } = getSlots<SpinButtonSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n <slots.input {...slotProps.input} />\n <slots.incrementButton {...slotProps.incrementButton} />\n <slots.decrementButton {...slotProps.decrementButton} />\n </slots.root>\n );\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,QAAQ,QAAQ;AAGzB;;;AAGA,OAAO,MAAMC,yBAAA,GAA6BC,KAAA,IAA2B;EACnE,MAAM;IAAEC,KAAA;IAAOC;EAAS,CAAE,GAAGJ,QAAA,CAA0BE,KAAA;EAEvD,oBACEH,KAAA,CAAAM,aAAA,CAACF,KAAA,CAAMG,IAAI,EAAKF,SAAA,CAAUE,IAAI,eAC5BP,KAAA,CAAAM,aAAA,CAACF,KAAA,CAAMI,KAAK,EAAKH,SAAA,CAAUG,KAAK,gBAChCR,KAAA,CAAAM,aAAA,CAACF,KAAA,CAAMK,eAAe,EAAKJ,SAAA,CAAUI,eAAe,gBACpDT,KAAA,CAAAM,aAAA,CAACF,KAAA,CAAMM,eAAe,EAAKL,SAAA,CAAUK,eAAe;AAG1D"}
|
@@ -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;
|
@@ -21,11 +21,10 @@ const lerp = (start, end, percent) => start + (end - start) * percent;
|
|
21
21
|
* @param ref - reference to root HTMLElement of SpinButton
|
22
22
|
*/
|
23
23
|
export const useSpinButton_unstable = (props, ref) => {
|
24
|
-
var _a, _b;
|
25
24
|
const nativeProps = getPartitionedNativeProps({
|
26
25
|
props,
|
27
|
-
primarySlotTagName:
|
28
|
-
excludedPropNames: [
|
26
|
+
primarySlotTagName: "input",
|
27
|
+
excludedPropNames: ["defaultValue", "max", "min", "onChange", "size", "value"]
|
29
28
|
});
|
30
29
|
const overrides = useOverrides();
|
31
30
|
const {
|
@@ -38,15 +37,15 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
38
37
|
stepPage = 1,
|
39
38
|
precision: precisionFromProps,
|
40
39
|
onChange,
|
41
|
-
size =
|
42
|
-
appearance =
|
40
|
+
size = "medium",
|
41
|
+
appearance = overrides.inputDefaultAppearance ?? "outline",
|
43
42
|
root,
|
44
43
|
input,
|
45
44
|
incrementButton,
|
46
45
|
decrementButton
|
47
46
|
} = props;
|
48
47
|
const precision = React.useMemo(() => {
|
49
|
-
return precisionFromProps
|
48
|
+
return precisionFromProps ?? Math.max(calculatePrecision(step), 0);
|
50
49
|
}, [precisionFromProps, step]);
|
51
50
|
const [currentValue, setCurrentValue] = useControllableState({
|
52
51
|
state: value,
|
@@ -55,13 +54,13 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
55
54
|
});
|
56
55
|
const isControlled = value !== undefined;
|
57
56
|
const [textValue, setTextValue] = React.useState(undefined);
|
58
|
-
const [keyboardSpinState, setKeyboardSpinState] = React.useState(
|
57
|
+
const [keyboardSpinState, setKeyboardSpinState] = React.useState("rest");
|
59
58
|
const internalState = React.useRef({
|
60
59
|
value: currentValue,
|
61
|
-
spinState:
|
60
|
+
spinState: "rest",
|
62
61
|
spinTime: 0,
|
63
62
|
spinDelay: DEFAULT_SPIN_DELAY_MS,
|
64
|
-
atBound: currentValue !== null ? getBound(precisionRound(currentValue, precision), min, max) :
|
63
|
+
atBound: currentValue !== null ? getBound(precisionRound(currentValue, precision), min, max) : "none"
|
65
64
|
});
|
66
65
|
const [setStepTimeout, clearStepTimeout] = useTimeout();
|
67
66
|
const stepValue = (e, direction, startFrom) => {
|
@@ -73,8 +72,8 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
73
72
|
}
|
74
73
|
}
|
75
74
|
const val = startValue;
|
76
|
-
const dir = direction ===
|
77
|
-
const stepSize = direction ===
|
75
|
+
const dir = direction === "up" || direction === "upPage" ? 1 : -1;
|
76
|
+
const stepSize = direction === "upPage" || direction === "downPage" ? stepPage : step;
|
78
77
|
if (val === null) {
|
79
78
|
const stepStart = min === undefined ? 0 : min;
|
80
79
|
const nullStep = clamp(stepStart + stepSize * dir, min, max);
|
@@ -86,7 +85,7 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
86
85
|
newValue = clamp(newValue, min, max);
|
87
86
|
}
|
88
87
|
commit(e, newValue);
|
89
|
-
if (internalState.current.spinState !==
|
88
|
+
if (internalState.current.spinState !== "rest") {
|
90
89
|
setStepTimeout(() => {
|
91
90
|
// Ease the step speed a bit
|
92
91
|
internalState.current.spinTime += internalState.current.spinDelay;
|
@@ -97,22 +96,22 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
97
96
|
};
|
98
97
|
const handleInputChange = e => {
|
99
98
|
if (!internalState.current.previousTextValue) {
|
100
|
-
internalState.current.previousTextValue = textValue
|
99
|
+
internalState.current.previousTextValue = textValue ?? String(currentValue);
|
101
100
|
}
|
102
101
|
const newValue = e.target.value;
|
103
102
|
setTextValue(newValue);
|
104
103
|
};
|
105
104
|
const handleIncrementMouseDown = e => {
|
106
|
-
internalState.current.spinState =
|
107
|
-
stepValue(e,
|
105
|
+
internalState.current.spinState = "up";
|
106
|
+
stepValue(e, "up");
|
108
107
|
};
|
109
108
|
const handleDecrementMouseDown = e => {
|
110
|
-
internalState.current.spinState =
|
111
|
-
stepValue(e,
|
109
|
+
internalState.current.spinState = "down";
|
110
|
+
stepValue(e, "down");
|
112
111
|
};
|
113
112
|
const handleStepMouseUpOrLeave = e => {
|
114
113
|
clearStepTimeout();
|
115
|
-
internalState.current.spinState =
|
114
|
+
internalState.current.spinState = "rest";
|
116
115
|
internalState.current.spinDelay = DEFAULT_SPIN_DELAY_MS;
|
117
116
|
internalState.current.spinTime = 0;
|
118
117
|
};
|
@@ -121,27 +120,27 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
121
120
|
internalState.current.previousTextValue = undefined;
|
122
121
|
};
|
123
122
|
const handleKeyDown = e => {
|
124
|
-
let nextKeyboardSpinState =
|
123
|
+
let nextKeyboardSpinState = "rest";
|
125
124
|
if (e.key === ArrowUp) {
|
126
|
-
stepValue(e,
|
127
|
-
nextKeyboardSpinState =
|
125
|
+
stepValue(e, "up", textValue);
|
126
|
+
nextKeyboardSpinState = "up";
|
128
127
|
} else if (e.key === ArrowDown) {
|
129
|
-
stepValue(e,
|
130
|
-
nextKeyboardSpinState =
|
128
|
+
stepValue(e, "down", textValue);
|
129
|
+
nextKeyboardSpinState = "down";
|
131
130
|
} else if (e.key === PageUp) {
|
132
131
|
e.preventDefault();
|
133
|
-
stepValue(e,
|
134
|
-
nextKeyboardSpinState =
|
132
|
+
stepValue(e, "upPage", textValue);
|
133
|
+
nextKeyboardSpinState = "up";
|
135
134
|
} else if (e.key === PageDown) {
|
136
135
|
e.preventDefault();
|
137
|
-
stepValue(e,
|
138
|
-
nextKeyboardSpinState =
|
136
|
+
stepValue(e, "downPage", textValue);
|
137
|
+
nextKeyboardSpinState = "down";
|
139
138
|
} else if (!e.shiftKey && e.key === Home && min !== undefined) {
|
140
139
|
commit(e, min);
|
141
|
-
nextKeyboardSpinState =
|
140
|
+
nextKeyboardSpinState = "down";
|
142
141
|
} else if (!e.shiftKey && e.key === End && max !== undefined) {
|
143
142
|
commit(e, max);
|
144
|
-
nextKeyboardSpinState =
|
143
|
+
nextKeyboardSpinState = "up";
|
145
144
|
} else if (e.key === Enter) {
|
146
145
|
commit(e, currentValue, textValue);
|
147
146
|
internalState.current.previousTextValue = undefined;
|
@@ -156,9 +155,9 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
156
155
|
}
|
157
156
|
};
|
158
157
|
const handleKeyUp = e => {
|
159
|
-
if (keyboardSpinState !==
|
160
|
-
setKeyboardSpinState(
|
161
|
-
internalState.current.spinState =
|
158
|
+
if (keyboardSpinState !== "rest") {
|
159
|
+
setKeyboardSpinState("rest");
|
160
|
+
internalState.current.spinState = "rest";
|
162
161
|
}
|
163
162
|
};
|
164
163
|
const commit = (e, newValue, newDisplayValue) => {
|
@@ -175,7 +174,7 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
175
174
|
}
|
176
175
|
}
|
177
176
|
if (valueChanged || displayValueChanged) {
|
178
|
-
onChange
|
177
|
+
onChange?.(e, {
|
179
178
|
value: roundedValue,
|
180
179
|
displayValue: newDisplayValue
|
181
180
|
});
|
@@ -188,10 +187,10 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
188
187
|
spinState: keyboardSpinState,
|
189
188
|
atBound: internalState.current.atBound,
|
190
189
|
components: {
|
191
|
-
root:
|
192
|
-
input:
|
193
|
-
incrementButton:
|
194
|
-
decrementButton:
|
190
|
+
root: "span",
|
191
|
+
input: "input",
|
192
|
+
incrementButton: "button",
|
193
|
+
decrementButton: "button"
|
195
194
|
},
|
196
195
|
root: resolveShorthand(root, {
|
197
196
|
required: true,
|
@@ -201,10 +200,10 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
201
200
|
required: true,
|
202
201
|
defaultProps: {
|
203
202
|
ref,
|
204
|
-
autoComplete:
|
205
|
-
role:
|
203
|
+
autoComplete: "off",
|
204
|
+
role: "spinbutton",
|
206
205
|
appearance,
|
207
|
-
type:
|
206
|
+
type: "text",
|
208
207
|
...nativeProps.primary
|
209
208
|
}
|
210
209
|
}),
|
@@ -214,8 +213,8 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
214
213
|
tabIndex: -1,
|
215
214
|
children: /*#__PURE__*/React.createElement(ChevronUp16Regular, null),
|
216
215
|
disabled: nativeProps.primary.disabled,
|
217
|
-
|
218
|
-
type:
|
216
|
+
"aria-label": "Increment value",
|
217
|
+
type: "button"
|
219
218
|
}
|
220
219
|
}),
|
221
220
|
decrementButton: resolveShorthand(decrementButton, {
|
@@ -224,8 +223,8 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
224
223
|
tabIndex: -1,
|
225
224
|
children: /*#__PURE__*/React.createElement(ChevronDown16Regular, null),
|
226
225
|
disabled: nativeProps.primary.disabled,
|
227
|
-
|
228
|
-
type:
|
226
|
+
"aria-label": "Decrement value",
|
227
|
+
type: "button"
|
229
228
|
}
|
230
229
|
})
|
231
230
|
};
|
@@ -233,24 +232,24 @@ export const useSpinButton_unstable = (props, ref) => {
|
|
233
232
|
if (textValue !== undefined) {
|
234
233
|
valueToDisplay = textValue;
|
235
234
|
} else if (value === null || currentValue === null) {
|
236
|
-
valueToDisplay = displayValue
|
235
|
+
valueToDisplay = displayValue ?? "";
|
237
236
|
internalState.current.value = null;
|
238
|
-
internalState.current.atBound =
|
237
|
+
internalState.current.atBound = "none";
|
239
238
|
} else {
|
240
239
|
const roundedValue = precisionRound(currentValue, precision);
|
241
240
|
internalState.current.value = roundedValue;
|
242
241
|
internalState.current.atBound = getBound(roundedValue, min, max);
|
243
242
|
if (isControlled) {
|
244
|
-
valueToDisplay = displayValue
|
243
|
+
valueToDisplay = displayValue ?? String(roundedValue);
|
245
244
|
} else {
|
246
245
|
valueToDisplay = String(roundedValue);
|
247
246
|
}
|
248
247
|
}
|
249
248
|
state.input.value = valueToDisplay;
|
250
|
-
state.input[
|
251
|
-
state.input[
|
252
|
-
state.input[
|
253
|
-
state.input[
|
249
|
+
state.input["aria-valuemin"] = min;
|
250
|
+
state.input["aria-valuemax"] = max;
|
251
|
+
state.input["aria-valuenow"] = currentValue ?? undefined;
|
252
|
+
state.input["aria-valuetext"] = state.input["aria-valuetext"] ?? (value !== undefined && displayValue || undefined);
|
254
253
|
state.input.onChange = mergeCallbacks(state.input.onChange, handleInputChange);
|
255
254
|
state.input.onBlur = mergeCallbacks(state.input.onBlur, handleBlur);
|
256
255
|
state.input.onKeyDown = mergeCallbacks(state.input.onKeyDown, handleKeyDown);
|