@fluentui/react-spinbutton 0.0.0-nightly-20220421-0418.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 (90) hide show
  1. package/CHANGELOG.json +173 -0
  2. package/CHANGELOG.md +71 -0
  3. package/LICENSE +15 -0
  4. package/MIGRATION.md +67 -0
  5. package/README.md +37 -0
  6. package/Spec.md +370 -0
  7. package/dist/react-spinbutton.d.ts +192 -0
  8. package/lib/SpinButton.d.ts +1 -0
  9. package/lib/SpinButton.js +2 -0
  10. package/lib/SpinButton.js.map +1 -0
  11. package/lib/components/SpinButton/SpinButton.d.ts +6 -0
  12. package/lib/components/SpinButton/SpinButton.js +15 -0
  13. package/lib/components/SpinButton/SpinButton.js.map +1 -0
  14. package/lib/components/SpinButton/SpinButton.strings.d.ts +2 -0
  15. package/lib/components/SpinButton/SpinButton.strings.js +5 -0
  16. package/lib/components/SpinButton/SpinButton.strings.js.map +1 -0
  17. package/lib/components/SpinButton/SpinButton.types.d.ts +149 -0
  18. package/lib/components/SpinButton/SpinButton.types.js +2 -0
  19. package/lib/components/SpinButton/SpinButton.types.js.map +1 -0
  20. package/lib/components/SpinButton/index.d.ts +5 -0
  21. package/lib/components/SpinButton/index.js +6 -0
  22. package/lib/components/SpinButton/index.js.map +1 -0
  23. package/lib/components/SpinButton/renderSpinButton.d.ts +5 -0
  24. package/lib/components/SpinButton/renderSpinButton.js +37 -0
  25. package/lib/components/SpinButton/renderSpinButton.js.map +1 -0
  26. package/lib/components/SpinButton/useSpinButton.d.ts +12 -0
  27. package/lib/components/SpinButton/useSpinButton.js +263 -0
  28. package/lib/components/SpinButton/useSpinButton.js.map +1 -0
  29. package/lib/components/SpinButton/useSpinButtonStyles.d.ts +7 -0
  30. package/lib/components/SpinButton/useSpinButtonStyles.js +367 -0
  31. package/lib/components/SpinButton/useSpinButtonStyles.js.map +1 -0
  32. package/lib/index.d.ts +2 -0
  33. package/lib/index.js +2 -0
  34. package/lib/index.js.map +1 -0
  35. package/lib/tsdoc-metadata.json +11 -0
  36. package/lib/utils/clamp.d.ts +1 -0
  37. package/lib/utils/clamp.js +31 -0
  38. package/lib/utils/clamp.js.map +1 -0
  39. package/lib/utils/getBound.d.ts +2 -0
  40. package/lib/utils/getBound.js +14 -0
  41. package/lib/utils/getBound.js.map +1 -0
  42. package/lib/utils/index.d.ts +3 -0
  43. package/lib/utils/index.js +4 -0
  44. package/lib/utils/index.js.map +1 -0
  45. package/lib/utils/precision.d.ts +14 -0
  46. package/lib/utils/precision.js +41 -0
  47. package/lib/utils/precision.js.map +1 -0
  48. package/lib-commonjs/SpinButton.d.ts +1 -0
  49. package/lib-commonjs/SpinButton.js +10 -0
  50. package/lib-commonjs/SpinButton.js.map +1 -0
  51. package/lib-commonjs/components/SpinButton/SpinButton.d.ts +6 -0
  52. package/lib-commonjs/components/SpinButton/SpinButton.js +26 -0
  53. package/lib-commonjs/components/SpinButton/SpinButton.js.map +1 -0
  54. package/lib-commonjs/components/SpinButton/SpinButton.strings.d.ts +2 -0
  55. package/lib-commonjs/components/SpinButton/SpinButton.strings.js +11 -0
  56. package/lib-commonjs/components/SpinButton/SpinButton.strings.js.map +1 -0
  57. package/lib-commonjs/components/SpinButton/SpinButton.types.d.ts +149 -0
  58. package/lib-commonjs/components/SpinButton/SpinButton.types.js +6 -0
  59. package/lib-commonjs/components/SpinButton/SpinButton.types.js.map +1 -0
  60. package/lib-commonjs/components/SpinButton/index.d.ts +5 -0
  61. package/lib-commonjs/components/SpinButton/index.js +18 -0
  62. package/lib-commonjs/components/SpinButton/index.js.map +1 -0
  63. package/lib-commonjs/components/SpinButton/renderSpinButton.d.ts +5 -0
  64. package/lib-commonjs/components/SpinButton/renderSpinButton.js +48 -0
  65. package/lib-commonjs/components/SpinButton/renderSpinButton.js.map +1 -0
  66. package/lib-commonjs/components/SpinButton/useSpinButton.d.ts +12 -0
  67. package/lib-commonjs/components/SpinButton/useSpinButton.js +278 -0
  68. package/lib-commonjs/components/SpinButton/useSpinButton.js.map +1 -0
  69. package/lib-commonjs/components/SpinButton/useSpinButtonStyles.d.ts +7 -0
  70. package/lib-commonjs/components/SpinButton/useSpinButtonStyles.js +379 -0
  71. package/lib-commonjs/components/SpinButton/useSpinButtonStyles.js.map +1 -0
  72. package/lib-commonjs/index.d.ts +2 -0
  73. package/lib-commonjs/index.js +40 -0
  74. package/lib-commonjs/index.js.map +1 -0
  75. package/lib-commonjs/utils/clamp.d.ts +1 -0
  76. package/lib-commonjs/utils/clamp.js +40 -0
  77. package/lib-commonjs/utils/clamp.js.map +1 -0
  78. package/lib-commonjs/utils/getBound.d.ts +2 -0
  79. package/lib-commonjs/utils/getBound.js +23 -0
  80. package/lib-commonjs/utils/getBound.js.map +1 -0
  81. package/lib-commonjs/utils/index.d.ts +3 -0
  82. package/lib-commonjs/utils/index.js +14 -0
  83. package/lib-commonjs/utils/index.js.map +1 -0
  84. package/lib-commonjs/utils/precision.d.ts +14 -0
  85. package/lib-commonjs/utils/precision.js +52 -0
  86. package/lib-commonjs/utils/precision.js.map +1 -0
  87. package/package.json +64 -0
  88. package/spec-assets/spec-spinbutton-anatomy-alt-optional.png +0 -0
  89. package/spec-assets/spec-spinbutton-anatomy.png +0 -0
  90. package/spec-assets/spec-spinbutton-rtl.png +0 -0
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.precisionRound = exports.calculatePrecision = void 0;
7
+ /**
8
+ * Calculates a number's precision based on the number of trailing
9
+ * zeros if the number does not have a decimal indicated by a negative
10
+ * precision. Otherwise, it calculates the number of digits after
11
+ * the decimal point indicated by a positive precision.
12
+ * @param value - the value to determine the precision of
13
+ */
14
+
15
+ function calculatePrecision(value) {
16
+ /**
17
+ * Group 1:
18
+ * [1-9]([0]+$) matches trailing zeros
19
+ * Group 2:
20
+ * \.([0-9]*) matches all digits after a decimal point.
21
+ */
22
+ const groups = /[1-9]([0]+$)|\.([0-9]*)/.exec(String(value));
23
+
24
+ if (!groups) {
25
+ return 0;
26
+ }
27
+
28
+ if (groups[1]) {
29
+ return -groups[1].length;
30
+ }
31
+
32
+ if (groups[2]) {
33
+ return groups[2].length;
34
+ }
35
+
36
+ return 0;
37
+ }
38
+
39
+ exports.calculatePrecision = calculatePrecision;
40
+ /**
41
+ * Rounds a number to a certain level of precision. Accepts negative precision.
42
+ * @param value - The value that is being rounded.
43
+ * @param precision - The number of decimal places to round the number to
44
+ */
45
+
46
+ function precisionRound(value, precision, base = 10) {
47
+ const exp = Math.pow(base, precision);
48
+ return Math.round(value * exp) / exp;
49
+ }
50
+
51
+ exports.precisionRound = precisionRound;
52
+ //# sourceMappingURL=precision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/precision.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;AAMG;;AACH,SAAgB,kBAAhB,CAAmC,KAAnC,EAAyD;AACvD;;;;;AAKG;AACH,QAAM,MAAM,GAAG,0BAA0B,IAA1B,CAA+B,MAAM,CAAC,KAAD,CAArC,CAAf;;AACA,MAAI,CAAC,MAAL,EAAa;AACX,WAAO,CAAP;AACD;;AACD,MAAI,MAAM,CAAC,CAAD,CAAV,EAAe;AACb,WAAO,CAAC,MAAM,CAAC,CAAD,CAAN,CAAU,MAAlB;AACD;;AACD,MAAI,MAAM,CAAC,CAAD,CAAV,EAAe;AACb,WAAO,MAAM,CAAC,CAAD,CAAN,CAAU,MAAjB;AACD;;AACD,SAAO,CAAP;AACD;;AAlBD,OAAA,CAAA,kBAAA,GAAA,kBAAA;AAoBA;;;;AAIG;;AACH,SAAgB,cAAhB,CAA+B,KAA/B,EAA8C,SAA9C,EAAiE,IAAA,GAAe,EAAhF,EAAkF;AAChF,QAAM,GAAG,GAAG,IAAI,CAAC,GAAL,CAAS,IAAT,EAAe,SAAf,CAAZ;AACA,SAAO,IAAI,CAAC,KAAL,CAAW,KAAK,GAAG,GAAnB,IAA0B,GAAjC;AACD;;AAHD,OAAA,CAAA,cAAA,GAAA,cAAA","sourcesContent":["/**\n * Calculates a number's precision based on the number of trailing\n * zeros if the number does not have a decimal indicated by a negative\n * precision. Otherwise, it calculates the number of digits after\n * the decimal point indicated by a positive precision.\n * @param value - the value to determine the precision of\n */\nexport function calculatePrecision(value: number | string): number {\n /**\n * Group 1:\n * [1-9]([0]+$) matches trailing zeros\n * Group 2:\n * \\.([0-9]*) matches all digits after a decimal point.\n */\n const groups = /[1-9]([0]+$)|\\.([0-9]*)/.exec(String(value));\n if (!groups) {\n return 0;\n }\n if (groups[1]) {\n return -groups[1].length;\n }\n if (groups[2]) {\n return groups[2].length;\n }\n return 0;\n}\n\n/**\n * Rounds a number to a certain level of precision. Accepts negative precision.\n * @param value - The value that is being rounded.\n * @param precision - The number of decimal places to round the number to\n */\nexport function precisionRound(value: number, precision: number, base: number = 10): number {\n const exp = Math.pow(base, precision);\n return Math.round(value * exp) / exp;\n}\n"],"sourceRoot":"../src/"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@fluentui/react-spinbutton",
3
+ "version": "0.0.0-nightly-20220421-0418.1",
4
+ "description": "Fluent UI React SpinButton component.",
5
+ "main": "lib-commonjs/index.js",
6
+ "module": "lib/index.js",
7
+ "typings": "lib/index.d.ts",
8
+ "sideEffects": false,
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/microsoft/fluentui"
12
+ },
13
+ "license": "MIT",
14
+ "scripts": {
15
+ "build": "just-scripts build",
16
+ "bundle-size": "bundle-size measure",
17
+ "clean": "just-scripts clean",
18
+ "code-style": "just-scripts code-style",
19
+ "just": "just-scripts",
20
+ "lint": "just-scripts lint",
21
+ "start": "yarn storybook",
22
+ "test": "jest --passWithNoTests",
23
+ "docs": "api-extractor run --config=config/api-extractor.local.json --local",
24
+ "build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output ./dist/packages/react-spinbutton/src && yarn docs",
25
+ "storybook": "node ../../scripts/storybook/runner",
26
+ "type-check": "tsc -b tsconfig.json"
27
+ },
28
+ "devDependencies": {
29
+ "@fluentui/eslint-plugin": "*",
30
+ "@fluentui/react-conformance": "*",
31
+ "@fluentui/react-conformance-griffel": "0.0.0-nightly-20220421-0418.1",
32
+ "@fluentui/react-label": "0.0.0-nightly-20220421-0418.1",
33
+ "@fluentui/scripts": "^1.0.0"
34
+ },
35
+ "dependencies": {
36
+ "@griffel/react": "1.0.3",
37
+ "@fluentui/keyboard-keys": "0.0.0-nightly-20220421-0418.1",
38
+ "@fluentui/react-icons": "^2.0.166-rc.3",
39
+ "@fluentui/react-input": "0.0.0-nightly-20220421-0418.1",
40
+ "@fluentui/react-theme": "0.0.0-nightly-20220421-0418.1",
41
+ "@fluentui/react-utilities": "0.0.0-nightly-20220421-0418.1",
42
+ "tslib": "^2.1.0"
43
+ },
44
+ "peerDependencies": {
45
+ "@types/react": ">=16.8.0 <18.0.0",
46
+ "@types/react-dom": ">=16.8.0 <18.0.0",
47
+ "react": ">=16.8.0 <18.0.0",
48
+ "react-dom": ">=16.8.0 <18.0.0"
49
+ },
50
+ "beachball": {
51
+ "disallowedChangeTypes": [
52
+ "major",
53
+ "minor",
54
+ "patch"
55
+ ]
56
+ },
57
+ "exports": {
58
+ ".": {
59
+ "types": "./lib/index.d.ts",
60
+ "import": "./lib/index.js",
61
+ "require": "./lib-commonjs/index.js"
62
+ }
63
+ }
64
+ }