@fluentui/react-spinbutton 0.0.0-nightly-20221227-0422.1 → 0.0.0-nightly-20221229-0425.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.
Files changed (48) hide show
  1. package/CHANGELOG.json +17 -17
  2. package/CHANGELOG.md +11 -11
  3. package/lib/components/SpinButton/SpinButton.js +0 -1
  4. package/lib/components/SpinButton/SpinButton.js.map +1 -1
  5. package/lib/components/SpinButton/renderSpinButton.js +8 -5
  6. package/lib/components/SpinButton/renderSpinButton.js.map +1 -1
  7. package/lib/components/SpinButton/useSpinButton.js +2 -33
  8. package/lib/components/SpinButton/useSpinButton.js.map +1 -1
  9. package/lib/components/SpinButton/useSpinButtonStyles.js +8 -13
  10. package/lib/components/SpinButton/useSpinButtonStyles.js.map +1 -1
  11. package/lib/components/SpinButtonField/SpinButtonField.js.map +1 -1
  12. package/lib/index.js.map +1 -1
  13. package/lib/utils/clamp.js +0 -6
  14. package/lib/utils/clamp.js.map +1 -1
  15. package/lib/utils/getBound.js +0 -2
  16. package/lib/utils/getBound.js.map +1 -1
  17. package/lib/utils/precision.js +0 -5
  18. package/lib/utils/precision.js.map +1 -1
  19. package/lib-commonjs/SpinButton.js +0 -2
  20. package/lib-commonjs/SpinButton.js.map +1 -1
  21. package/lib-commonjs/SpinButtonField.js +0 -2
  22. package/lib-commonjs/SpinButtonField.js.map +1 -1
  23. package/lib-commonjs/components/SpinButton/SpinButton.js +0 -6
  24. package/lib-commonjs/components/SpinButton/SpinButton.js.map +1 -1
  25. package/lib-commonjs/components/SpinButton/SpinButton.types.js.map +1 -1
  26. package/lib-commonjs/components/SpinButton/index.js +0 -6
  27. package/lib-commonjs/components/SpinButton/index.js.map +1 -1
  28. package/lib-commonjs/components/SpinButton/renderSpinButton.js +8 -9
  29. package/lib-commonjs/components/SpinButton/renderSpinButton.js.map +1 -1
  30. package/lib-commonjs/components/SpinButton/useSpinButton.js +2 -40
  31. package/lib-commonjs/components/SpinButton/useSpinButton.js.map +1 -1
  32. package/lib-commonjs/components/SpinButton/useSpinButtonStyles.js +8 -18
  33. package/lib-commonjs/components/SpinButton/useSpinButtonStyles.js.map +1 -1
  34. package/lib-commonjs/components/SpinButtonField/SpinButtonField.js +0 -4
  35. package/lib-commonjs/components/SpinButtonField/SpinButtonField.js.map +1 -1
  36. package/lib-commonjs/components/SpinButtonField/index.js +0 -2
  37. package/lib-commonjs/components/SpinButtonField/index.js.map +1 -1
  38. package/lib-commonjs/index.js +0 -4
  39. package/lib-commonjs/index.js.map +1 -1
  40. package/lib-commonjs/utils/clamp.js +0 -8
  41. package/lib-commonjs/utils/clamp.js.map +1 -1
  42. package/lib-commonjs/utils/getBound.js +0 -4
  43. package/lib-commonjs/utils/getBound.js.map +1 -1
  44. package/lib-commonjs/utils/index.js +0 -4
  45. package/lib-commonjs/utils/index.js.map +1 -1
  46. package/lib-commonjs/utils/precision.js +0 -8
  47. package/lib-commonjs/utils/precision.js.map +1 -1
  48. package/package.json +8 -8
package/CHANGELOG.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@fluentui/react-spinbutton",
3
3
  "entries": [
4
4
  {
5
- "date": "Tue, 27 Dec 2022 04:29:53 GMT",
6
- "tag": "@fluentui/react-spinbutton_v0.0.0-nightly-20221227-0422.1",
7
- "version": "0.0.0-nightly-20221227-0422.1",
5
+ "date": "Thu, 29 Dec 2022 04:34:25 GMT",
6
+ "tag": "@fluentui/react-spinbutton_v0.0.0-nightly-20221229-0425.1",
7
+ "version": "0.0.0-nightly-20221229-0425.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-20221227-0422.1",
20
- "commit": "73065888fbb9ba2242737048d68e9b664cb3d913"
19
+ "comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-20221229-0425.1",
20
+ "commit": "f91b275fd9b1829634e1dc1de59d8fbf68359edc"
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-20221227-0422.1",
26
- "commit": "73065888fbb9ba2242737048d68e9b664cb3d913"
25
+ "comment": "Bump @fluentui/react-field to v0.0.0-nightly-20221229-0425.1",
26
+ "commit": "f91b275fd9b1829634e1dc1de59d8fbf68359edc"
27
27
  },
28
28
  {
29
29
  "author": "beachball",
30
30
  "package": "@fluentui/react-spinbutton",
31
- "comment": "Bump @fluentui/react-input to v0.0.0-nightly-20221227-0422.1",
32
- "commit": "73065888fbb9ba2242737048d68e9b664cb3d913"
31
+ "comment": "Bump @fluentui/react-input to v0.0.0-nightly-20221229-0425.1",
32
+ "commit": "f91b275fd9b1829634e1dc1de59d8fbf68359edc"
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-20221227-0422.1",
38
- "commit": "73065888fbb9ba2242737048d68e9b664cb3d913"
37
+ "comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20221229-0425.1",
38
+ "commit": "f91b275fd9b1829634e1dc1de59d8fbf68359edc"
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-20221227-0422.1",
44
- "commit": "73065888fbb9ba2242737048d68e9b664cb3d913"
43
+ "comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20221229-0425.1",
44
+ "commit": "f91b275fd9b1829634e1dc1de59d8fbf68359edc"
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-20221227-0422.1",
50
- "commit": "73065888fbb9ba2242737048d68e9b664cb3d913"
49
+ "comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20221229-0425.1",
50
+ "commit": "f91b275fd9b1829634e1dc1de59d8fbf68359edc"
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-20221227-0422.1",
56
- "commit": "73065888fbb9ba2242737048d68e9b664cb3d913"
55
+ "comment": "Bump @fluentui/react-label to v0.0.0-nightly-20221229-0425.1",
56
+ "commit": "f91b275fd9b1829634e1dc1de59d8fbf68359edc"
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 Tue, 27 Dec 2022 04:29:53 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 29 Dec 2022 04:34:25 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [0.0.0-nightly-20221227-0422.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinbutton_v0.0.0-nightly-20221227-0422.1)
7
+ ## [0.0.0-nightly-20221229-0425.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinbutton_v0.0.0-nightly-20221229-0425.1)
8
8
 
9
- Tue, 27 Dec 2022 04:29:53 GMT
10
- [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinbutton_v9.0.12..@fluentui/react-spinbutton_v0.0.0-nightly-20221227-0422.1)
9
+ Thu, 29 Dec 2022 04:34:25 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinbutton_v9.0.12..@fluentui/react-spinbutton_v0.0.0-nightly-20221229-0425.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-20221227-0422.1 ([commit](https://github.com/microsoft/fluentui/commit/73065888fbb9ba2242737048d68e9b664cb3d913) by beachball)
16
- - Bump @fluentui/react-field to v0.0.0-nightly-20221227-0422.1 ([commit](https://github.com/microsoft/fluentui/commit/73065888fbb9ba2242737048d68e9b664cb3d913) by beachball)
17
- - Bump @fluentui/react-input to v0.0.0-nightly-20221227-0422.1 ([commit](https://github.com/microsoft/fluentui/commit/73065888fbb9ba2242737048d68e9b664cb3d913) by beachball)
18
- - Bump @fluentui/react-theme to v0.0.0-nightly-20221227-0422.1 ([commit](https://github.com/microsoft/fluentui/commit/73065888fbb9ba2242737048d68e9b664cb3d913) by beachball)
19
- - Bump @fluentui/react-utilities to v0.0.0-nightly-20221227-0422.1 ([commit](https://github.com/microsoft/fluentui/commit/73065888fbb9ba2242737048d68e9b664cb3d913) by beachball)
20
- - Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20221227-0422.1 ([commit](https://github.com/microsoft/fluentui/commit/73065888fbb9ba2242737048d68e9b664cb3d913) by beachball)
21
- - Bump @fluentui/react-label to v0.0.0-nightly-20221227-0422.1 ([commit](https://github.com/microsoft/fluentui/commit/73065888fbb9ba2242737048d68e9b664cb3d913) by beachball)
15
+ - Bump @fluentui/keyboard-keys to v0.0.0-nightly-20221229-0425.1 ([commit](https://github.com/microsoft/fluentui/commit/f91b275fd9b1829634e1dc1de59d8fbf68359edc) by beachball)
16
+ - Bump @fluentui/react-field to v0.0.0-nightly-20221229-0425.1 ([commit](https://github.com/microsoft/fluentui/commit/f91b275fd9b1829634e1dc1de59d8fbf68359edc) by beachball)
17
+ - Bump @fluentui/react-input to v0.0.0-nightly-20221229-0425.1 ([commit](https://github.com/microsoft/fluentui/commit/f91b275fd9b1829634e1dc1de59d8fbf68359edc) by beachball)
18
+ - Bump @fluentui/react-theme to v0.0.0-nightly-20221229-0425.1 ([commit](https://github.com/microsoft/fluentui/commit/f91b275fd9b1829634e1dc1de59d8fbf68359edc) by beachball)
19
+ - Bump @fluentui/react-utilities to v0.0.0-nightly-20221229-0425.1 ([commit](https://github.com/microsoft/fluentui/commit/f91b275fd9b1829634e1dc1de59d8fbf68359edc) by beachball)
20
+ - Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20221229-0425.1 ([commit](https://github.com/microsoft/fluentui/commit/f91b275fd9b1829634e1dc1de59d8fbf68359edc) by beachball)
21
+ - Bump @fluentui/react-label to v0.0.0-nightly-20221229-0425.1 ([commit](https://github.com/microsoft/fluentui/commit/f91b275fd9b1829634e1dc1de59d8fbf68359edc) by beachball)
22
22
 
23
23
  ## [9.0.12](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinbutton_v9.0.12)
24
24
 
@@ -5,7 +5,6 @@ import { useSpinButtonStyles_unstable } from './useSpinButtonStyles';
5
5
  /**
6
6
  * A SpinButton allows someone to incrementally adjust a value in small steps.
7
7
  */
8
-
9
8
  export const SpinButton = /*#__PURE__*/React.forwardRef((props, ref) => {
10
9
  const state = useSpinButton_unstable(props, ref);
11
10
  useSpinButtonStyles_unstable(state);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../packages/react-components/react-spinbutton/src/components/SpinButton/SpinButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,sBAAT,QAAuC,iBAAvC;AACA,SAAS,yBAAT,QAA0C,oBAA1C;AACA,SAAS,4BAAT,QAA6C,uBAA7C;AAIA;;AAEG;;AACH,OAAO,MAAM,UAAU,gBAAyC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;EAC9F,MAAM,KAAK,GAAG,sBAAsB,CAAC,KAAD,EAAQ,GAAR,CAApC;EAEA,4BAA4B,CAAC,KAAD,CAA5B;EACA,OAAO,yBAAyB,CAAC,KAAD,CAAhC;AACD,CAL+D,CAAzD;AAOP,UAAU,CAAC,WAAX,GAAyB,YAAzB","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';\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 return renderSpinButton_unstable(state);\n});\n\nSpinButton.displayName = 'SpinButton';\n"],"sourceRoot":""}
1
+ {"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,sBAAsB,QAAQ,iBAAiB;AACxD,SAASC,yBAAyB,QAAQ,oBAAoB;AAC9D,SAASC,4BAA4B,QAAQ,uBAAuB;AAIpE;;;AAGA,OAAO,MAAMC,UAAU,gBAAyCJ,KAAK,CAACK,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EAC9F,MAAMC,KAAK,GAAGP,sBAAsB,CAACK,KAAK,EAAEC,GAAG,CAAC;EAEhDJ,4BAA4B,CAACK,KAAK,CAAC;EACnC,OAAON,yBAAyB,CAACM,KAAK,CAAC;AACzC,CAAC,CAAC;AAEFJ,UAAU,CAACK,WAAW,GAAG,YAAY","names":["React","useSpinButton_unstable","renderSpinButton_unstable","useSpinButtonStyles_unstable","SpinButton","forwardRef","props","ref","state","displayName"],"sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-spinbutton/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';\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 return renderSpinButton_unstable(state);\n});\n\nSpinButton.displayName = 'SpinButton';\n"]}
@@ -3,7 +3,6 @@ import { getSlots } from '@fluentui/react-utilities';
3
3
  /**
4
4
  * Render the final JSX of SpinButton
5
5
  */
6
-
7
6
  export const renderSpinButton_unstable = state => {
8
7
  // Leaving this here for now.
9
8
  // This is the approach using react-input's Input component.
@@ -28,10 +27,14 @@ export const renderSpinButton_unstable = state => {
28
27
  slots,
29
28
  slotProps
30
29
  } = getSlots(state);
31
- return /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
32
- }, /*#__PURE__*/React.createElement(slots.input, { ...slotProps.input
33
- }), /*#__PURE__*/React.createElement(slots.incrementButton, { ...slotProps.incrementButton
34
- }), /*#__PURE__*/React.createElement(slots.decrementButton, { ...slotProps.decrementButton
30
+ return /*#__PURE__*/React.createElement(slots.root, {
31
+ ...slotProps.root
32
+ }, /*#__PURE__*/React.createElement(slots.input, {
33
+ ...slotProps.input
34
+ }), /*#__PURE__*/React.createElement(slots.incrementButton, {
35
+ ...slotProps.incrementButton
36
+ }), /*#__PURE__*/React.createElement(slots.decrementButton, {
37
+ ...slotProps.decrementButton
35
38
  }));
36
39
  };
37
40
  //# sourceMappingURL=renderSpinButton.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../packages/react-components/react-spinbutton/src/components/SpinButton/renderSpinButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,yBAAyB,GAAI,KAAD,IAA2B;EAClE;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EAEA,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,QAAQ,CAAkB,KAAlB,CAArC;EAEA,oBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,eACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;EAAf,CAAZ,CADF,eAEE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,eAAP,EAAsB,EAAA,GAAK,SAAS,CAAC;EAAf,CAAtB,CAFF,eAGE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,eAAP,EAAsB,EAAA,GAAK,SAAS,CAAC;EAAf,CAAtB,CAHF,CADF;AAOD,CAhCM","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 // Leaving this here for now.\n // This is the approach using react-input's Input component.\n // It has some Typescript problems and feels hacky.\n // const { slots, slotProps } = getSlots<SpinButtonSlots>(state);\n\n // const { contentAfter, ...otherInputSlotProps } = slotProps.input as SpinButtonSlots['input'];\n // const inputContentAfter = {\n // ...contentAfter,\n // children: (\n // <>\n // <slots.incrementButton {...slotProps.incrementButton} />\n // <slots.decrementButton {...slotProps.decrementButton} />\n // </>\n // ),\n // };\n\n // return (\n // <slots.root {...slotProps.root}>\n // <slots.input {...otherInputSlotProps} contentAfter={inputContentAfter}/>\n // </slots.root>\n // );\n\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"],"sourceRoot":""}
1
+ {"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,QAAQ,QAAQ,2BAA2B;AAGpD;;;AAGA,OAAO,MAAMC,yBAAyB,GAAIC,KAAsB,IAAI;EAClE;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EAEA,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGJ,QAAQ,CAAkBE,KAAK,CAAC;EAE7D,oBACEH,oBAACI,KAAK,CAACE,IAAI;IAAA,GAAKD,SAAS,CAACC;EAAI,gBAC5BN,oBAACI,KAAK,CAACG,KAAK;IAAA,GAAKF,SAAS,CAACE;EAAK,EAAI,eACpCP,oBAACI,KAAK,CAACI,eAAe;IAAA,GAAKH,SAAS,CAACG;EAAe,EAAI,eACxDR,oBAACI,KAAK,CAACK,eAAe;IAAA,GAAKJ,SAAS,CAACI;EAAe,EAAI,CAC7C;AAEjB,CAAC","names":["React","getSlots","renderSpinButton_unstable","state","slots","slotProps","root","input","incrementButton","decrementButton"],"sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-spinbutton/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 // Leaving this here for now.\n // This is the approach using react-input's Input component.\n // It has some Typescript problems and feels hacky.\n // const { slots, slotProps } = getSlots<SpinButtonSlots>(state);\n\n // const { contentAfter, ...otherInputSlotProps } = slotProps.input as SpinButtonSlots['input'];\n // const inputContentAfter = {\n // ...contentAfter,\n // children: (\n // <>\n // <slots.incrementButton {...slotProps.incrementButton} />\n // <slots.decrementButton {...slotProps.decrementButton} />\n // </>\n // ),\n // };\n\n // return (\n // <slots.root {...slotProps.root}>\n // <slots.input {...otherInputSlotProps} contentAfter={inputContentAfter}/>\n // </slots.root>\n // );\n\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"]}
@@ -5,10 +5,10 @@ import { calculatePrecision, precisionRound, getBound, clamp } from '../../utils
5
5
  import { ChevronUp16Regular, ChevronDown16Regular } from '@fluentui/react-icons';
6
6
  const DEFAULT_SPIN_DELAY_MS = 150;
7
7
  const MIN_SPIN_DELAY_MS = 80;
8
- const MAX_SPIN_TIME_MS = 1000; // This is here to give an ease the mouse held down case.
8
+ const MAX_SPIN_TIME_MS = 1000;
9
+ // This is here to give an ease the mouse held down case.
9
10
  // Exact easing it to be defined. Once it is we'll likely
10
11
  // pull this out into a util function in the SpinButton package.
11
-
12
12
  const lerp = (start, end, percent) => start + (end - start) * percent;
13
13
  /**
14
14
  * Create the state required to render SpinButton.
@@ -19,11 +19,8 @@ const lerp = (start, end, percent) => start + (end - start) * percent;
19
19
  * @param props - props from this instance of SpinButton
20
20
  * @param ref - reference to root HTMLElement of SpinButton
21
21
  */
22
-
23
-
24
22
  export const useSpinButton_unstable = (props, ref) => {
25
23
  var _a;
26
-
27
24
  const nativeProps = getPartitionedNativeProps({
28
25
  props,
29
26
  primarySlotTagName: 'input',
@@ -65,37 +62,28 @@ export const useSpinButton_unstable = (props, ref) => {
65
62
  atBound: currentValue !== null ? getBound(precisionRound(currentValue, precision), min, max) : 'none'
66
63
  });
67
64
  const [setStepTimeout, clearStepTimeout] = useTimeout();
68
-
69
65
  const stepValue = (e, direction, startFrom) => {
70
66
  let startValue = internalState.current.value;
71
-
72
67
  if (startFrom) {
73
68
  const num = parseFloat(startFrom);
74
-
75
69
  if (!isNaN(num)) {
76
70
  startValue = num;
77
71
  }
78
72
  }
79
-
80
73
  const val = startValue;
81
74
  const dir = direction === 'up' || direction === 'upPage' ? 1 : -1;
82
75
  const stepSize = direction === 'upPage' || direction === 'downPage' ? stepPage : step;
83
-
84
76
  if (val === null) {
85
77
  const stepStart = min === undefined ? 0 : min;
86
78
  const nullStep = clamp(stepStart + stepSize * dir, min, max);
87
79
  commit(e, nullStep);
88
80
  return;
89
81
  }
90
-
91
82
  let newValue = val + stepSize * dir;
92
-
93
83
  if (!Number.isNaN(newValue)) {
94
84
  newValue = clamp(newValue, min, max);
95
85
  }
96
-
97
86
  commit(e, newValue);
98
-
99
87
  if (internalState.current.spinState !== 'rest') {
100
88
  setStepTimeout(() => {
101
89
  // Ease the step speed a bit
@@ -105,41 +93,33 @@ export const useSpinButton_unstable = (props, ref) => {
105
93
  }, internalState.current.spinDelay);
106
94
  }
107
95
  };
108
-
109
96
  const handleInputChange = e => {
110
97
  if (!internalState.current.previousTextValue) {
111
98
  internalState.current.previousTextValue = textValue;
112
99
  }
113
-
114
100
  const newValue = e.target.value;
115
101
  setTextValue(newValue);
116
102
  };
117
-
118
103
  const handleIncrementMouseDown = e => {
119
104
  internalState.current.spinState = 'up';
120
105
  stepValue(e, 'up');
121
106
  };
122
-
123
107
  const handleDecrementMouseDown = e => {
124
108
  internalState.current.spinState = 'down';
125
109
  stepValue(e, 'down');
126
110
  };
127
-
128
111
  const handleStepMouseUpOrLeave = e => {
129
112
  clearStepTimeout();
130
113
  internalState.current.spinState = 'rest';
131
114
  internalState.current.spinDelay = DEFAULT_SPIN_DELAY_MS;
132
115
  internalState.current.spinTime = 0;
133
116
  };
134
-
135
117
  const handleBlur = e => {
136
118
  commit(e, currentValue, textValue);
137
119
  internalState.current.previousTextValue = undefined;
138
120
  };
139
-
140
121
  const handleKeyDown = e => {
141
122
  let nextKeyboardSpinState = 'rest';
142
-
143
123
  if (e.key === Keys.ArrowUp) {
144
124
  stepValue(e, 'up', textValue);
145
125
  nextKeyboardSpinState = 'up';
@@ -169,45 +149,37 @@ export const useSpinButton_unstable = (props, ref) => {
169
149
  internalState.current.previousTextValue = undefined;
170
150
  }
171
151
  }
172
-
173
152
  if (keyboardSpinState !== nextKeyboardSpinState) {
174
153
  setKeyboardSpinState(nextKeyboardSpinState);
175
154
  }
176
155
  };
177
-
178
156
  const handleKeyUp = e => {
179
157
  if (keyboardSpinState !== 'rest') {
180
158
  setKeyboardSpinState('rest');
181
159
  internalState.current.spinState = 'rest';
182
160
  }
183
161
  };
184
-
185
162
  const commit = (e, newValue, newDisplayValue) => {
186
163
  const valueChanged = newValue !== undefined && currentValue !== newValue;
187
164
  const displayValueChanged = newDisplayValue !== undefined && internalState.current.previousTextValue !== undefined && internalState.current.previousTextValue !== newDisplayValue;
188
165
  let roundedValue;
189
-
190
166
  if (valueChanged) {
191
167
  roundedValue = precisionRound(newValue, precision);
192
168
  setCurrentValue(roundedValue);
193
169
  } else if (displayValueChanged && !isControlled) {
194
170
  const nextValue = parseFloat(newDisplayValue);
195
-
196
171
  if (!isNaN(nextValue)) {
197
172
  setCurrentValue(precisionRound(nextValue, precision));
198
173
  }
199
174
  }
200
-
201
175
  if (valueChanged || displayValueChanged) {
202
176
  onChange === null || onChange === void 0 ? void 0 : onChange(e, {
203
177
  value: roundedValue,
204
178
  displayValue: newDisplayValue
205
179
  });
206
180
  }
207
-
208
181
  setTextValue(undefined);
209
182
  };
210
-
211
183
  const state = {
212
184
  size,
213
185
  appearance,
@@ -256,7 +228,6 @@ export const useSpinButton_unstable = (props, ref) => {
256
228
  })
257
229
  };
258
230
  let valueToDisplay;
259
-
260
231
  if (textValue !== undefined) {
261
232
  valueToDisplay = textValue;
262
233
  } else if (value === null || currentValue === null) {
@@ -267,14 +238,12 @@ export const useSpinButton_unstable = (props, ref) => {
267
238
  const roundedValue = precisionRound(currentValue, precision);
268
239
  internalState.current.value = roundedValue;
269
240
  internalState.current.atBound = getBound(roundedValue, min, max);
270
-
271
241
  if (isControlled) {
272
242
  valueToDisplay = displayValue !== null && displayValue !== void 0 ? displayValue : String(roundedValue);
273
243
  } else {
274
244
  valueToDisplay = String(roundedValue);
275
245
  }
276
246
  }
277
-
278
247
  state.input.value = valueToDisplay;
279
248
  state.input['aria-valuemin'] = min;
280
249
  state.input['aria-valuemax'] = max;
@@ -1 +1 @@
1
- {"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AY,QAAZ,GAAuB,cAAc,CAAC,KAAK,CAAC,KAAN,CAAY,QAAb,EAAuB,iBAAvB,CAArC;EACA,KAAK,CAAC,KAAN,CAAY,MAAZ,GAAqB,cAAc,CAAC,KAAK,CAAC,KAAN,CAAY,MAAb,EAAqB,UAArB,CAAnC;EACA,KAAK,CAAC,KAAN,CAAY,SAAZ,GAAwB,cAAc,CAAC,KAAK,CAAC,KAAN,CAAY,SAAb,EAAwB,aAAxB,CAAtC;EACA,KAAK,CAAC,KAAN,CAAY,OAAZ,GAAsB,cAAc,CAAC,KAAK,CAAC,KAAN,CAAY,OAAb,EAAsB,WAAtB,CAApC;EAEA,KAAK,CAAC,eAAN,CAAsB,WAAtB,GAAoC,cAAc,CAAC,wBAAD,EAA2B,KAAK,CAAC,eAAN,CAAsB,WAAjD,CAAlD;EACA,KAAK,CAAC,eAAN,CAAsB,SAAtB,GAAkC,cAAc,CAAC,KAAK,CAAC,eAAN,CAAsB,SAAvB,EAAkC,wBAAlC,CAAhD;EACA,KAAK,CAAC,eAAN,CAAsB,YAAtB,GAAqC,cAAc,CAAC,KAAK,CAAC,eAAN,CAAsB,YAAvB,EAAqC,wBAArC,CAAnD;EAEA,KAAK,CAAC,eAAN,CAAsB,WAAtB,GAAoC,cAAc,CAAC,wBAAD,EAA2B,KAAK,CAAC,eAAN,CAAsB,WAAjD,CAAlD;EACA,KAAK,CAAC,eAAN,CAAsB,SAAtB,GAAkC,cAAc,CAAC,KAAK,CAAC,eAAN,CAAsB,SAAvB,EAAkC,wBAAlC,CAAhD;EACA,KAAK,CAAC,eAAN,CAAsB,YAAtB,GAAqC,cAAc,CAAC,KAAK,CAAC,eAAN,CAAsB,YAAvB,EAAqC,wBAArC,CAAnD;EAEA,OAAO,KAAP;AACD,CAxRM","sourcesContent":["import * as React from 'react';\nimport {\n getPartitionedNativeProps,\n mergeCallbacks,\n resolveShorthand,\n useControllableState,\n useTimeout,\n} from '@fluentui/react-utilities';\nimport * as Keys from '@fluentui/keyboard-keys';\nimport {\n SpinButtonProps,\n SpinButtonState,\n SpinButtonSpinState,\n SpinButtonChangeEvent,\n SpinButtonBounds,\n} from './SpinButton.types';\nimport { calculatePrecision, precisionRound, getBound, clamp } from '../../utils/index';\nimport { ChevronUp16Regular, ChevronDown16Regular } from '@fluentui/react-icons';\n\ntype InternalState = {\n value: number | null;\n spinState: SpinButtonSpinState;\n spinTime: number;\n spinDelay: number;\n previousTextValue?: string;\n atBound: SpinButtonBounds;\n};\n\nconst DEFAULT_SPIN_DELAY_MS = 150;\nconst MIN_SPIN_DELAY_MS = 80;\nconst MAX_SPIN_TIME_MS = 1000;\n\n// This is here to give an ease the mouse held down case.\n// Exact easing it to be defined. Once it is we'll likely\n// pull this out into a util function in the SpinButton package.\nconst lerp = (start: number, end: number, percent: number): number => start + (end - start) * percent;\n\n/**\n * Create the state required to render SpinButton.\n *\n * The returned state can be modified with hooks such as useSpinButtonStyles_unstable,\n * before being passed to renderSpinButton_unstable.\n *\n * @param props - props from this instance of SpinButton\n * @param ref - reference to root HTMLElement of SpinButton\n */\nexport const useSpinButton_unstable = (props: SpinButtonProps, ref: React.Ref<HTMLInputElement>): SpinButtonState => {\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['defaultValue', 'max', 'min', 'onChange', 'size', 'value'],\n });\n\n const {\n value,\n displayValue,\n defaultValue,\n min,\n max,\n step = 1,\n stepPage = 1,\n precision: precisionFromProps,\n onChange,\n size = 'medium',\n appearance = 'outline',\n root,\n input,\n incrementButton,\n decrementButton,\n } = props;\n\n const precision = React.useMemo(() => {\n return precisionFromProps ?? Math.max(calculatePrecision(step), 0);\n }, [precisionFromProps, step]);\n\n const [currentValue, setCurrentValue] = useControllableState({\n state: value,\n defaultState: defaultValue,\n initialState: 0,\n });\n\n const isControlled = value !== undefined;\n\n const [textValue, setTextValue] = React.useState<string | undefined>(undefined);\n const [keyboardSpinState, setKeyboardSpinState] = React.useState<SpinButtonSpinState>('rest');\n\n const internalState = React.useRef<InternalState>({\n value: currentValue,\n spinState: 'rest',\n spinTime: 0,\n spinDelay: DEFAULT_SPIN_DELAY_MS,\n atBound: currentValue !== null ? getBound(precisionRound(currentValue, precision), min, max) : 'none',\n });\n\n const [setStepTimeout, clearStepTimeout] = useTimeout();\n\n const stepValue = (\n e: SpinButtonChangeEvent,\n direction: 'up' | 'down' | 'upPage' | 'downPage',\n startFrom?: string,\n ) => {\n let startValue = internalState.current.value;\n if (startFrom) {\n const num = parseFloat(startFrom);\n if (!isNaN(num)) {\n startValue = num;\n }\n }\n const val = startValue;\n const dir = direction === 'up' || direction === 'upPage' ? 1 : -1;\n const stepSize = direction === 'upPage' || direction === 'downPage' ? stepPage : step;\n\n if (val === null) {\n const stepStart = min === undefined ? 0 : min;\n const nullStep = clamp(stepStart + stepSize * dir, min, max);\n commit(e, nullStep);\n return;\n }\n\n let newValue = val + stepSize * dir;\n if (!Number.isNaN(newValue)) {\n newValue = clamp(newValue, min, max);\n }\n\n commit(e, newValue);\n\n if (internalState.current.spinState !== 'rest') {\n setStepTimeout(() => {\n // Ease the step speed a bit\n internalState.current.spinTime += internalState.current.spinDelay;\n internalState.current.spinDelay = lerp(\n DEFAULT_SPIN_DELAY_MS,\n MIN_SPIN_DELAY_MS,\n internalState.current.spinTime / MAX_SPIN_TIME_MS,\n );\n stepValue(e, direction);\n }, internalState.current.spinDelay);\n }\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (!internalState.current.previousTextValue) {\n internalState.current.previousTextValue = textValue;\n }\n const newValue = e.target.value;\n setTextValue(newValue);\n };\n\n const handleIncrementMouseDown = (e: React.MouseEvent<HTMLButtonElement>) => {\n internalState.current.spinState = 'up';\n stepValue(e, 'up');\n };\n\n const handleDecrementMouseDown = (e: React.MouseEvent<HTMLButtonElement>) => {\n internalState.current.spinState = 'down';\n stepValue(e, 'down');\n };\n\n const handleStepMouseUpOrLeave = (e: React.MouseEvent<HTMLButtonElement>) => {\n clearStepTimeout();\n internalState.current.spinState = 'rest';\n internalState.current.spinDelay = DEFAULT_SPIN_DELAY_MS;\n internalState.current.spinTime = 0;\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n commit(e, currentValue, textValue);\n internalState.current.previousTextValue = undefined;\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n let nextKeyboardSpinState: SpinButtonSpinState = 'rest';\n\n if (e.key === Keys.ArrowUp) {\n stepValue(e, 'up', textValue);\n nextKeyboardSpinState = 'up';\n } else if (e.key === Keys.ArrowDown) {\n stepValue(e, 'down', textValue);\n nextKeyboardSpinState = 'down';\n } else if (e.key === Keys.PageUp) {\n e.preventDefault();\n stepValue(e, 'upPage', textValue);\n nextKeyboardSpinState = 'up';\n } else if (e.key === Keys.PageDown) {\n e.preventDefault();\n stepValue(e, 'downPage', textValue);\n nextKeyboardSpinState = 'down';\n } else if (!e.shiftKey && e.key === Keys.Home && min !== undefined) {\n commit(e, min);\n nextKeyboardSpinState = 'down';\n } else if (!e.shiftKey && e.key === Keys.End && max !== undefined) {\n commit(e, max);\n nextKeyboardSpinState = 'up';\n } else if (e.key === Keys.Enter) {\n commit(e, currentValue, textValue);\n internalState.current.previousTextValue = undefined;\n } else if (e.key === Keys.Escape) {\n if (internalState.current.previousTextValue) {\n setTextValue(undefined);\n internalState.current.previousTextValue = undefined;\n }\n }\n\n if (keyboardSpinState !== nextKeyboardSpinState) {\n setKeyboardSpinState(nextKeyboardSpinState);\n }\n };\n\n const handleKeyUp = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (keyboardSpinState !== 'rest') {\n setKeyboardSpinState('rest');\n internalState.current.spinState = 'rest';\n }\n };\n\n const commit = (e: SpinButtonChangeEvent, newValue?: number | null, newDisplayValue?: string) => {\n const valueChanged = newValue !== undefined && currentValue !== newValue;\n const displayValueChanged =\n newDisplayValue !== undefined &&\n internalState.current.previousTextValue !== undefined &&\n internalState.current.previousTextValue !== newDisplayValue;\n\n let roundedValue;\n if (valueChanged) {\n roundedValue = precisionRound(newValue!, precision);\n setCurrentValue(roundedValue);\n } else if (displayValueChanged && !isControlled) {\n const nextValue = parseFloat(newDisplayValue as string);\n if (!isNaN(nextValue)) {\n setCurrentValue(precisionRound(nextValue, precision));\n }\n }\n\n if (valueChanged || displayValueChanged) {\n onChange?.(e, { value: roundedValue, displayValue: newDisplayValue });\n }\n\n setTextValue(undefined);\n };\n\n const state: SpinButtonState = {\n size,\n appearance,\n spinState: keyboardSpinState,\n atBound: internalState.current.atBound,\n\n components: {\n root: 'span',\n input: 'input',\n incrementButton: 'button',\n decrementButton: 'button',\n },\n root: resolveShorthand(root, {\n required: true,\n defaultProps: nativeProps.root,\n }),\n input: resolveShorthand(input, {\n required: true,\n defaultProps: {\n ref,\n autoComplete: 'off',\n role: 'spinbutton',\n appearance,\n type: 'text',\n ...nativeProps.primary,\n },\n }),\n incrementButton: resolveShorthand(incrementButton, {\n required: true,\n defaultProps: {\n tabIndex: -1,\n children: <ChevronUp16Regular />,\n disabled: nativeProps.primary.disabled,\n 'aria-label': 'Increment value',\n type: 'button',\n },\n }),\n decrementButton: resolveShorthand(decrementButton, {\n required: true,\n defaultProps: {\n tabIndex: -1,\n children: <ChevronDown16Regular />,\n disabled: nativeProps.primary.disabled,\n 'aria-label': 'Decrement value',\n type: 'button',\n },\n }),\n };\n\n let valueToDisplay;\n if (textValue !== undefined) {\n valueToDisplay = textValue;\n } else if (value === null || currentValue === null) {\n valueToDisplay = displayValue ?? '';\n internalState.current.value = null;\n internalState.current.atBound = 'none';\n } else {\n const roundedValue = precisionRound(currentValue, precision);\n internalState.current.value = roundedValue;\n internalState.current.atBound = getBound(roundedValue, min, max);\n if (isControlled) {\n valueToDisplay = displayValue ?? String(roundedValue);\n } else {\n valueToDisplay = String(roundedValue);\n }\n }\n\n state.input.value = valueToDisplay;\n state.input['aria-valuemin'] = min;\n state.input['aria-valuemax'] = max;\n state.input['aria-valuenow'] = currentValue ?? undefined;\n state.input['aria-valuetext'] = state.input['aria-valuetext'] ?? ((value !== undefined && displayValue) || undefined);\n state.input.onChange = mergeCallbacks(state.input.onChange, handleInputChange);\n state.input.onBlur = mergeCallbacks(state.input.onBlur, handleBlur);\n state.input.onKeyDown = mergeCallbacks(state.input.onKeyDown, handleKeyDown);\n state.input.onKeyUp = mergeCallbacks(state.input.onKeyUp, handleKeyUp);\n\n state.incrementButton.onMouseDown = mergeCallbacks(handleIncrementMouseDown, state.incrementButton.onMouseDown);\n state.incrementButton.onMouseUp = mergeCallbacks(state.incrementButton.onMouseUp, handleStepMouseUpOrLeave);\n state.incrementButton.onMouseLeave = mergeCallbacks(state.incrementButton.onMouseLeave, handleStepMouseUpOrLeave);\n\n state.decrementButton.onMouseDown = mergeCallbacks(handleDecrementMouseDown, state.decrementButton.onMouseDown);\n state.decrementButton.onMouseUp = mergeCallbacks(state.decrementButton.onMouseUp, handleStepMouseUpOrLeave);\n state.decrementButton.onMouseLeave = mergeCallbacks(state.decrementButton.onMouseLeave, handleStepMouseUpOrLeave);\n\n return state;\n};\n"],"sourceRoot":""}
1
+ {"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SACEC,yBAAyB,EACzBC,cAAc,EACdC,gBAAgB,EAChBC,oBAAoB,EACpBC,UAAU,QACL,2BAA2B;AAClC,OAAO,KAAKC,IAAI,MAAM,yBAAyB;AAQ/C,SAASC,kBAAkB,EAAEC,cAAc,EAAEC,QAAQ,EAAEC,KAAK,QAAQ,mBAAmB;AACvF,SAASC,kBAAkB,EAAEC,oBAAoB,QAAQ,uBAAuB;AAWhF,MAAMC,qBAAqB,GAAG,GAAG;AACjC,MAAMC,iBAAiB,GAAG,EAAE;AAC5B,MAAMC,gBAAgB,GAAG,IAAI;AAE7B;AACA;AACA;AACA,MAAMC,IAAI,GAAG,CAACC,KAAa,EAAEC,GAAW,EAAEC,OAAe,KAAaF,KAAK,GAAG,CAACC,GAAG,GAAGD,KAAK,IAAIE,O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K,CAACN,eAAe,CAACmF,SAAS,EAAErC,wBAAwB,CAAC;EAC3GxC,KAAK,CAACN,eAAe,CAACoF,YAAY,GAAG1H,cAAc,CAAC4C,KAAK,CAACN,eAAe,CAACoF,YAAY,EAAEtC,wBAAwB,CAAC;EAEjHxC,KAAK,CAACL,eAAe,CAACiF,WAAW,GAAGxH,cAAc,CAACmF,wBAAwB,EAAEvC,KAAK,CAACL,eAAe,CAACiF,WAAW,CAAC;EAC/G5E,KAAK,CAACL,eAAe,CAACkF,SAAS,GAAGzH,cAAc,CAAC4C,KAAK,CAACL,eAAe,CAACkF,SAAS,EAAErC,wBAAwB,CAAC;EAC3GxC,KAAK,CAACL,eAAe,CAACmF,YAAY,GAAG1H,cAAc,CAAC4C,KAAK,CAACL,eAAe,CAACmF,YAAY,EAAEtC,wBAAwB,CAAC;EAEjH,OAAOxC,KAAK;AACd,CAAC","names":["React","getPartitionedNativeProps","mergeCallbacks","resolveShorthand","useControllableState","useTimeout","Keys","calculatePrecision","precisionRound","getBound","clamp","ChevronUp16Regular","ChevronDown16Regular","DEFAULT_SPIN_DELAY_MS","MIN_SPIN_DELAY_MS","MAX_SPIN_TIME_MS","lerp","start","end","percent","useSpinButton_unstable","props","ref","nativeProps","primarySlotTagName","excludedPropNames","value","displayValue","defaultValue","min","max","step","stepPage","precision","precisionFromProps","onChange","size","appearance","root","input","incrementButton","decrementButton","useMemo","Math","currentValue","setCurrentValue","state","defaultState","initialState","isControlled","undefined","textValue","setTextValue","useState","keyboardSpinState","setKeyboardSpinState","internalState","useRef","spinState","spinTime","spinDelay","atBound","setStepTimeout","clearStepTimeout","stepValue","e","direction","startFrom","startValue","current","num","parseFloat","isNaN","val","dir","stepSize","stepStart","nullStep","commit","newValue","Number","handleInputChange","previousTextValue","target","handleIncrementMouseDown","handleDecrementMouseDown","handleStepMouseUpOrLeave","handleBlur","handleKeyDown","nextKeyboardSpinState","key","ArrowUp","ArrowDown","PageUp","preventDefault","PageDown","shiftKey","Home","End","Enter","Escape","handleKeyUp","newDisplayValue","valueChanged","displayValueChanged","roundedValue","nextValue","components","required","defaultProps","autoComplete","role","type","primary","tabIndex","children","disabled","valueToDisplay","String","onBlur","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave"],"sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-spinbutton/src/components/SpinButton/useSpinButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n getPartitionedNativeProps,\n mergeCallbacks,\n resolveShorthand,\n useControllableState,\n useTimeout,\n} from '@fluentui/react-utilities';\nimport * as Keys from '@fluentui/keyboard-keys';\nimport {\n SpinButtonProps,\n SpinButtonState,\n SpinButtonSpinState,\n SpinButtonChangeEvent,\n SpinButtonBounds,\n} from './SpinButton.types';\nimport { calculatePrecision, precisionRound, getBound, clamp } from '../../utils/index';\nimport { ChevronUp16Regular, ChevronDown16Regular } from '@fluentui/react-icons';\n\ntype InternalState = {\n value: number | null;\n spinState: SpinButtonSpinState;\n spinTime: number;\n spinDelay: number;\n previousTextValue?: string;\n atBound: SpinButtonBounds;\n};\n\nconst DEFAULT_SPIN_DELAY_MS = 150;\nconst MIN_SPIN_DELAY_MS = 80;\nconst MAX_SPIN_TIME_MS = 1000;\n\n// This is here to give an ease the mouse held down case.\n// Exact easing it to be defined. Once it is we'll likely\n// pull this out into a util function in the SpinButton package.\nconst lerp = (start: number, end: number, percent: number): number => start + (end - start) * percent;\n\n/**\n * Create the state required to render SpinButton.\n *\n * The returned state can be modified with hooks such as useSpinButtonStyles_unstable,\n * before being passed to renderSpinButton_unstable.\n *\n * @param props - props from this instance of SpinButton\n * @param ref - reference to root HTMLElement of SpinButton\n */\nexport const useSpinButton_unstable = (props: SpinButtonProps, ref: React.Ref<HTMLInputElement>): SpinButtonState => {\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['defaultValue', 'max', 'min', 'onChange', 'size', 'value'],\n });\n\n const {\n value,\n displayValue,\n defaultValue,\n min,\n max,\n step = 1,\n stepPage = 1,\n precision: precisionFromProps,\n onChange,\n size = 'medium',\n appearance = 'outline',\n root,\n input,\n incrementButton,\n decrementButton,\n } = props;\n\n const precision = React.useMemo(() => {\n return precisionFromProps ?? Math.max(calculatePrecision(step), 0);\n }, [precisionFromProps, step]);\n\n const [currentValue, setCurrentValue] = useControllableState({\n state: value,\n defaultState: defaultValue,\n initialState: 0,\n });\n\n const isControlled = value !== undefined;\n\n const [textValue, setTextValue] = React.useState<string | undefined>(undefined);\n const [keyboardSpinState, setKeyboardSpinState] = React.useState<SpinButtonSpinState>('rest');\n\n const internalState = React.useRef<InternalState>({\n value: currentValue,\n spinState: 'rest',\n spinTime: 0,\n spinDelay: DEFAULT_SPIN_DELAY_MS,\n atBound: currentValue !== null ? getBound(precisionRound(currentValue, precision), min, max) : 'none',\n });\n\n const [setStepTimeout, clearStepTimeout] = useTimeout();\n\n const stepValue = (\n e: SpinButtonChangeEvent,\n direction: 'up' | 'down' | 'upPage' | 'downPage',\n startFrom?: string,\n ) => {\n let startValue = internalState.current.value;\n if (startFrom) {\n const num = parseFloat(startFrom);\n if (!isNaN(num)) {\n startValue = num;\n }\n }\n const val = startValue;\n const dir = direction === 'up' || direction === 'upPage' ? 1 : -1;\n const stepSize = direction === 'upPage' || direction === 'downPage' ? stepPage : step;\n\n if (val === null) {\n const stepStart = min === undefined ? 0 : min;\n const nullStep = clamp(stepStart + stepSize * dir, min, max);\n commit(e, nullStep);\n return;\n }\n\n let newValue = val + stepSize * dir;\n if (!Number.isNaN(newValue)) {\n newValue = clamp(newValue, min, max);\n }\n\n commit(e, newValue);\n\n if (internalState.current.spinState !== 'rest') {\n setStepTimeout(() => {\n // Ease the step speed a bit\n internalState.current.spinTime += internalState.current.spinDelay;\n internalState.current.spinDelay = lerp(\n DEFAULT_SPIN_DELAY_MS,\n MIN_SPIN_DELAY_MS,\n internalState.current.spinTime / MAX_SPIN_TIME_MS,\n );\n stepValue(e, direction);\n }, internalState.current.spinDelay);\n }\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (!internalState.current.previousTextValue) {\n internalState.current.previousTextValue = textValue;\n }\n const newValue = e.target.value;\n setTextValue(newValue);\n };\n\n const handleIncrementMouseDown = (e: React.MouseEvent<HTMLButtonElement>) => {\n internalState.current.spinState = 'up';\n stepValue(e, 'up');\n };\n\n const handleDecrementMouseDown = (e: React.MouseEvent<HTMLButtonElement>) => {\n internalState.current.spinState = 'down';\n stepValue(e, 'down');\n };\n\n const handleStepMouseUpOrLeave = (e: React.MouseEvent<HTMLButtonElement>) => {\n clearStepTimeout();\n internalState.current.spinState = 'rest';\n internalState.current.spinDelay = DEFAULT_SPIN_DELAY_MS;\n internalState.current.spinTime = 0;\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n commit(e, currentValue, textValue);\n internalState.current.previousTextValue = undefined;\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n let nextKeyboardSpinState: SpinButtonSpinState = 'rest';\n\n if (e.key === Keys.ArrowUp) {\n stepValue(e, 'up', textValue);\n nextKeyboardSpinState = 'up';\n } else if (e.key === Keys.ArrowDown) {\n stepValue(e, 'down', textValue);\n nextKeyboardSpinState = 'down';\n } else if (e.key === Keys.PageUp) {\n e.preventDefault();\n stepValue(e, 'upPage', textValue);\n nextKeyboardSpinState = 'up';\n } else if (e.key === Keys.PageDown) {\n e.preventDefault();\n stepValue(e, 'downPage', textValue);\n nextKeyboardSpinState = 'down';\n } else if (!e.shiftKey && e.key === Keys.Home && min !== undefined) {\n commit(e, min);\n nextKeyboardSpinState = 'down';\n } else if (!e.shiftKey && e.key === Keys.End && max !== undefined) {\n commit(e, max);\n nextKeyboardSpinState = 'up';\n } else if (e.key === Keys.Enter) {\n commit(e, currentValue, textValue);\n internalState.current.previousTextValue = undefined;\n } else if (e.key === Keys.Escape) {\n if (internalState.current.previousTextValue) {\n setTextValue(undefined);\n internalState.current.previousTextValue = undefined;\n }\n }\n\n if (keyboardSpinState !== nextKeyboardSpinState) {\n setKeyboardSpinState(nextKeyboardSpinState);\n }\n };\n\n const handleKeyUp = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (keyboardSpinState !== 'rest') {\n setKeyboardSpinState('rest');\n internalState.current.spinState = 'rest';\n }\n };\n\n const commit = (e: SpinButtonChangeEvent, newValue?: number | null, newDisplayValue?: string) => {\n const valueChanged = newValue !== undefined && currentValue !== newValue;\n const displayValueChanged =\n newDisplayValue !== undefined &&\n internalState.current.previousTextValue !== undefined &&\n internalState.current.previousTextValue !== newDisplayValue;\n\n let roundedValue;\n if (valueChanged) {\n roundedValue = precisionRound(newValue!, precision);\n setCurrentValue(roundedValue);\n } else if (displayValueChanged && !isControlled) {\n const nextValue = parseFloat(newDisplayValue as string);\n if (!isNaN(nextValue)) {\n setCurrentValue(precisionRound(nextValue, precision));\n }\n }\n\n if (valueChanged || displayValueChanged) {\n onChange?.(e, { value: roundedValue, displayValue: newDisplayValue });\n }\n\n setTextValue(undefined);\n };\n\n const state: SpinButtonState = {\n size,\n appearance,\n spinState: keyboardSpinState,\n atBound: internalState.current.atBound,\n\n components: {\n root: 'span',\n input: 'input',\n incrementButton: 'button',\n decrementButton: 'button',\n },\n root: resolveShorthand(root, {\n required: true,\n defaultProps: nativeProps.root,\n }),\n input: resolveShorthand(input, {\n required: true,\n defaultProps: {\n ref,\n autoComplete: 'off',\n role: 'spinbutton',\n appearance,\n type: 'text',\n ...nativeProps.primary,\n },\n }),\n incrementButton: resolveShorthand(incrementButton, {\n required: true,\n defaultProps: {\n tabIndex: -1,\n children: <ChevronUp16Regular />,\n disabled: nativeProps.primary.disabled,\n 'aria-label': 'Increment value',\n type: 'button',\n },\n }),\n decrementButton: resolveShorthand(decrementButton, {\n required: true,\n defaultProps: {\n tabIndex: -1,\n children: <ChevronDown16Regular />,\n disabled: nativeProps.primary.disabled,\n 'aria-label': 'Decrement value',\n type: 'button',\n },\n }),\n };\n\n let valueToDisplay;\n if (textValue !== undefined) {\n valueToDisplay = textValue;\n } else if (value === null || currentValue === null) {\n valueToDisplay = displayValue ?? '';\n internalState.current.value = null;\n internalState.current.atBound = 'none';\n } else {\n const roundedValue = precisionRound(currentValue, precision);\n internalState.current.value = roundedValue;\n internalState.current.atBound = getBound(roundedValue, min, max);\n if (isControlled) {\n valueToDisplay = displayValue ?? String(roundedValue);\n } else {\n valueToDisplay = String(roundedValue);\n }\n }\n\n state.input.value = valueToDisplay;\n state.input['aria-valuemin'] = min;\n state.input['aria-valuemax'] = max;\n state.input['aria-valuenow'] = currentValue ?? undefined;\n state.input['aria-valuetext'] = state.input['aria-valuetext'] ?? ((value !== undefined && displayValue) || undefined);\n state.input.onChange = mergeCallbacks(state.input.onChange, handleInputChange);\n state.input.onBlur = mergeCallbacks(state.input.onBlur, handleBlur);\n state.input.onKeyDown = mergeCallbacks(state.input.onKeyDown, handleKeyDown);\n state.input.onKeyUp = mergeCallbacks(state.input.onKeyUp, handleKeyUp);\n\n state.incrementButton.onMouseDown = mergeCallbacks(handleIncrementMouseDown, state.incrementButton.onMouseDown);\n state.incrementButton.onMouseUp = mergeCallbacks(state.incrementButton.onMouseUp, handleStepMouseUpOrLeave);\n state.incrementButton.onMouseLeave = mergeCallbacks(state.incrementButton.onMouseLeave, handleStepMouseUpOrLeave);\n\n state.decrementButton.onMouseDown = mergeCallbacks(handleDecrementMouseDown, state.decrementButton.onMouseDown);\n state.decrementButton.onMouseUp = mergeCallbacks(state.decrementButton.onMouseUp, handleStepMouseUpOrLeave);\n state.decrementButton.onMouseLeave = mergeCallbacks(state.decrementButton.onMouseLeave, handleStepMouseUpOrLeave);\n\n return state;\n};\n"]}
@@ -10,7 +10,6 @@ export const spinButtonClassNames = {
10
10
  const spinButtonExtraClassNames = {
11
11
  buttonActive: 'fui-SpinButton__button_active'
12
12
  };
13
-
14
13
  const useRootStyles = /*#__PURE__*/__styles({
15
14
  "base": {
16
15
  "mc9l5x": "fwk3njj",
@@ -134,7 +133,6 @@ const useRootStyles = /*#__PURE__*/__styles({
134
133
  "m": "(forced-colors: active)"
135
134
  }]]
136
135
  });
137
-
138
136
  const useInputStyles = /*#__PURE__*/__styles({
139
137
  "base": {
140
138
  "Br312pm": "fwpfdsa",
@@ -150,7 +148,6 @@ const useInputStyles = /*#__PURE__*/__styles({
150
148
  }, {
151
149
  "d": [".fwpfdsa{grid-column-start:1;}", ".f1e2fz10{grid-column-end:2;}", ".f16hsg94{grid-row-start:1;}", ".fcu02xx{grid-row-end:3;}", ".f1s6fcnf{outline-style:none;}", ".f1g0x7ka{padding-top:0;}", ".fhxju0i{padding-right:0;}", ".f1cnd47f{padding-left:0;}", ".f1qch9an{padding-bottom:0;}"]
152
150
  });
153
-
154
151
  const useButtonStyles = /*#__PURE__*/__styles({
155
152
  "base": {
156
153
  "mc9l5x": "ftuwxu6",
@@ -257,10 +254,9 @@ const useButtonStyles = /*#__PURE__*/__styles({
257
254
  }, {
258
255
  "d": [".ftuwxu6{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;}", ".fq4mcun{width:24px;}", ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".f4d9j23{-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;}", ".fre7gi1{border-top-width:0;}", ".f1358rze{border-right-width:0;}", ".f1rvrf73{border-left-width:0;}", ".fqdk4by{border-bottom-width:0;}", ".f1euv43f{position:absolute;}", ".f1s6fcnf{outline-style:none;}", ".f1l02sjl{height:100%;}", ".fe4wpbb:enabled:hover{cursor:pointer;}", ".f9f7vaa:disabled{cursor:not-allowed;}", ".fd46tj4{grid-column-start:2;}", ".fz1yyy6{grid-column-end:3;}", ".f16hsg94{grid-row-start:1;}", ".f88nxoq{grid-row-end:2;}", ".f1krrbdw{border-bottom-right-radius:0;}", ".f1deotkl{border-bottom-left-radius:0;}", ".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}", ".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}", ".f1ozlkrg{border-top-left-radius:0;}", ".f10ostut{border-top-right-radius:0;}", ".f1khb0e9{padding-top:3px;}", ".f1sgzk6v{padding-right:6px;}", ".f1bg5zqg{padding-left:6px;}", ".f1ov4xf1{padding-bottom:0px;}", ".fycuoez{padding-left:4px;}", ".f8wuabp{padding-right:4px;}", ".f10ra9hq{padding-top:4px;}", ".fwiuce9{padding-right:5px;}", ".f15vdbe4{padding-left:5px;}", ".f1brlhvm{padding-bottom:1px;}", ".faunodf{grid-row-start:2;}", ".fcu02xx{grid-row-end:3;}", ".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f1nbblvp{padding-top:0px;}", ".f1jnq6q7{padding-bottom:3px;}", ".f1sl3k7w{padding-top:1px;}", ".f1y2xyjm{padding-bottom:4px;}", ".f3rmtva{background-color:transparent;}", ".f11d4kpn{color:var(--colorNeutralForeground3);}", ".f1no7wuu:enabled:hover{color:var(--colorNeutralForeground3Hover);}", ".f1bifk9c:enabled:hover{background-color:var(--colorSubtleBackgroundHover);}", ".fp1zg4s:enabled:active{color:var(--colorNeutralForeground3Pressed);}", ".fo6hitd:enabled:active{background-color:var(--colorSubtleBackgroundPressed);}", ".f1wiab75:enabled.fui-SpinButton__button_active{color:var(--colorNeutralForeground3Pressed);}", ".fj9zm5z:enabled.fui-SpinButton__button_active{background-color:var(--colorSubtleBackgroundPressed);}", ".f1cqwcg4:disabled{color:var(--colorNeutralForegroundDisabled);}", ".fwwxidx:enabled:hover{background-color:var(--colorNeutralBackground3Hover);}", ".f14i52sd:enabled:active{background-color:var(--colorNeutralBackground3Pressed);}", ".fwry2ka:enabled.fui-SpinButton__button_active{background-color:var(--colorNeutralBackground3Pressed);}", ".f1yywxnv:enabled:hover{background-color:var(--colorNeutralBackground1Hover);}", ".fzaa11h:enabled:active,.fzaa11h:enabled.fui-SpinButton__button_active{color:var(--colorNeutralForeground3Pressed);}", ".f4fpmm9:enabled:active,.f4fpmm9:enabled.fui-SpinButton__button_active{background-color:var(--colorNeutralBackground1Pressed);}"],
259
256
  "a": [".fb0xa7e:active{outline-style:none;}"]
260
- }); // Cannot just disable button as they need to remain
257
+ });
258
+ // Cannot just disable button as they need to remain
261
259
  // exposed to ATs like screen readers.
262
-
263
-
264
260
  const useButtonDisabledStyles = /*#__PURE__*/__styles({
265
261
  "base": {
266
262
  "Bceei9c": "fdrzuqr",
@@ -309,8 +305,6 @@ const useButtonDisabledStyles = /*#__PURE__*/__styles({
309
305
  /**
310
306
  * Apply styling to the SpinButton slots based on the state
311
307
  */
312
-
313
-
314
308
  export const useSpinButtonStyles_unstable = state => {
315
309
  const {
316
310
  appearance,
@@ -324,11 +318,11 @@ export const useSpinButtonStyles_unstable = state => {
324
318
  const rootStyles = useRootStyles();
325
319
  const buttonStyles = useButtonStyles();
326
320
  const buttonDisabledStyles = useButtonDisabledStyles();
327
- const inputStyles = useInputStyles(); // Grab the root className here so we can be sure to merge is last
328
-
321
+ const inputStyles = useInputStyles();
322
+ // Grab the root className here so we can be sure to merge is last
329
323
  const rootClassName = state.root.className;
330
- state.root.className = undefined; // Reuse react-input's styles without re-using the Input component.
331
-
324
+ state.root.className = undefined;
325
+ // Reuse react-input's styles without re-using the Input component.
332
326
  useInputStyles_unstable({
333
327
  size,
334
328
  appearance,
@@ -341,7 +335,8 @@ export const useSpinButtonStyles_unstable = state => {
341
335
  contentAfter: 'span'
342
336
  }
343
337
  });
344
- state.root.className = mergeClasses(state.root.className, // Get the classes from useInputStyles_unstable
338
+ state.root.className = mergeClasses(state.root.className,
339
+ // Get the classes from useInputStyles_unstable
345
340
  spinButtonClassNames.root, rootStyles.base, rootStyles[size], appearance === 'outline' && rootStyles.outline, appearance === 'underline' && rootStyles.underline, filled && rootStyles.filled, !disabled && appearance === 'outline' && rootStyles.outlineInteractive, !disabled && appearance === 'underline' && rootStyles.underlineInteractive, !disabled && filled && rootStyles.filledInteractive, !disabled && invalid && rootStyles.invalid, disabled && rootStyles.disabled, rootClassName);
346
341
  state.incrementButton.className = mergeClasses(spinButtonClassNames.incrementButton, spinState === 'up' && `${spinButtonExtraClassNames.buttonActive}`, buttonStyles.base, buttonStyles.incrementButton, buttonStyles[appearance], size === 'small' ? buttonStyles.incrementButtonSmall : buttonStyles.incrementButtonMedium, (atBound === 'max' || atBound === 'both') && buttonDisabledStyles.base, (atBound === 'max' || atBound === 'both') && buttonDisabledStyles[appearance], state.incrementButton.className);
347
342
  state.decrementButton.className = mergeClasses(spinButtonClassNames.decrementButton, spinState === 'down' && `${spinButtonExtraClassNames.buttonActive}`, buttonStyles.base, buttonStyles.decrementButton, buttonStyles[appearance], size === 'small' ? buttonStyles.decrementButtonSmall : buttonStyles.decrementButtonMedium, (atBound === 'min' || atBound === 'both') && buttonDisabledStyles.base, (atBound === 'min' || atBound === 'both') && buttonDisabledStyles[appearance], state.decrementButton.className);