@fluentui/react-button 9.0.0-rc.5 → 9.0.0-rc.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. package/CHANGELOG.json +196 -1
  2. package/CHANGELOG.md +221 -175
  3. package/dist/{react-button.d.ts → index.d.ts} +22 -3
  4. package/lib/components/Button/Button.types.d.ts +3 -1
  5. package/lib/components/Button/Button.types.js.map +1 -1
  6. package/lib/components/Button/index.d.ts +1 -1
  7. package/lib/components/Button/index.js +3 -1
  8. package/lib/components/Button/index.js.map +1 -1
  9. package/lib/components/Button/useButton.js +1 -0
  10. package/lib/components/Button/useButton.js.map +1 -1
  11. package/lib/components/Button/useButtonStyles.d.ts +3 -0
  12. package/lib/components/Button/useButtonStyles.js +103 -57
  13. package/lib/components/Button/useButtonStyles.js.map +1 -1
  14. package/lib/components/CompoundButton/CompoundButton.d.ts +1 -1
  15. package/lib/components/CompoundButton/CompoundButton.js.map +1 -1
  16. package/lib/components/CompoundButton/index.js +3 -1
  17. package/lib/components/CompoundButton/index.js.map +1 -1
  18. package/lib/components/CompoundButton/useCompoundButton.js +7 -2
  19. package/lib/components/CompoundButton/useCompoundButton.js.map +1 -1
  20. package/lib/components/CompoundButton/useCompoundButtonStyles.d.ts +3 -0
  21. package/lib/components/CompoundButton/useCompoundButtonStyles.js +22 -10
  22. package/lib/components/CompoundButton/useCompoundButtonStyles.js.map +1 -1
  23. package/lib/components/MenuButton/index.d.ts +1 -1
  24. package/lib/components/MenuButton/index.js +3 -1
  25. package/lib/components/MenuButton/index.js.map +1 -1
  26. package/lib/components/MenuButton/useMenuButtonStyles.d.ts +3 -0
  27. package/lib/components/MenuButton/useMenuButtonStyles.js +5 -2
  28. package/lib/components/MenuButton/useMenuButtonStyles.js.map +1 -1
  29. package/lib/components/SplitButton/SplitButton.types.d.ts +1 -1
  30. package/lib/components/SplitButton/SplitButton.types.js.map +1 -1
  31. package/lib/components/SplitButton/index.d.ts +1 -1
  32. package/lib/components/SplitButton/index.js +3 -1
  33. package/lib/components/SplitButton/index.js.map +1 -1
  34. package/lib/components/SplitButton/useSplitButton.js +1 -0
  35. package/lib/components/SplitButton/useSplitButton.js.map +1 -1
  36. package/lib/components/SplitButton/useSplitButtonStyles.d.ts +3 -0
  37. package/lib/components/SplitButton/useSplitButtonStyles.js +17 -8
  38. package/lib/components/SplitButton/useSplitButtonStyles.js.map +1 -1
  39. package/lib/components/ToggleButton/index.d.ts +1 -1
  40. package/lib/components/ToggleButton/index.js +3 -1
  41. package/lib/components/ToggleButton/index.js.map +1 -1
  42. package/lib/components/ToggleButton/useToggleButton.d.ts +1 -1
  43. package/lib/components/ToggleButton/useToggleButton.js +3 -41
  44. package/lib/components/ToggleButton/useToggleButton.js.map +1 -1
  45. package/lib/components/ToggleButton/useToggleButtonStyles.d.ts +5 -0
  46. package/lib/components/ToggleButton/useToggleButtonStyles.js +73 -60
  47. package/lib/components/ToggleButton/useToggleButtonStyles.js.map +1 -1
  48. package/lib/index.d.ts +11 -5
  49. package/lib/index.js +11 -5
  50. package/lib/index.js.map +1 -1
  51. package/lib/utils/index.d.ts +1 -0
  52. package/lib/utils/index.js +2 -0
  53. package/lib/utils/index.js.map +1 -0
  54. package/lib/utils/useToggleState.d.ts +3 -0
  55. package/lib/utils/useToggleState.js +37 -0
  56. package/lib/utils/useToggleState.js.map +1 -0
  57. package/lib-commonjs/components/Button/Button.types.d.ts +3 -1
  58. package/lib-commonjs/components/Button/index.d.ts +1 -1
  59. package/lib-commonjs/components/Button/index.js +2 -0
  60. package/lib-commonjs/components/Button/index.js.map +1 -1
  61. package/lib-commonjs/components/Button/useButton.js +1 -0
  62. package/lib-commonjs/components/Button/useButton.js.map +1 -1
  63. package/lib-commonjs/components/Button/useButtonStyles.d.ts +3 -0
  64. package/lib-commonjs/components/Button/useButtonStyles.js +104 -57
  65. package/lib-commonjs/components/Button/useButtonStyles.js.map +1 -1
  66. package/lib-commonjs/components/CompoundButton/CompoundButton.d.ts +1 -1
  67. package/lib-commonjs/components/CompoundButton/CompoundButton.js.map +1 -1
  68. package/lib-commonjs/components/CompoundButton/index.js +2 -0
  69. package/lib-commonjs/components/CompoundButton/index.js.map +1 -1
  70. package/lib-commonjs/components/CompoundButton/useCompoundButton.js +7 -2
  71. package/lib-commonjs/components/CompoundButton/useCompoundButton.js.map +1 -1
  72. package/lib-commonjs/components/CompoundButton/useCompoundButtonStyles.d.ts +3 -0
  73. package/lib-commonjs/components/CompoundButton/useCompoundButtonStyles.js +22 -10
  74. package/lib-commonjs/components/CompoundButton/useCompoundButtonStyles.js.map +1 -1
  75. package/lib-commonjs/components/MenuButton/index.d.ts +1 -1
  76. package/lib-commonjs/components/MenuButton/index.js +2 -0
  77. package/lib-commonjs/components/MenuButton/index.js.map +1 -1
  78. package/lib-commonjs/components/MenuButton/useMenuButtonStyles.d.ts +3 -0
  79. package/lib-commonjs/components/MenuButton/useMenuButtonStyles.js +5 -2
  80. package/lib-commonjs/components/MenuButton/useMenuButtonStyles.js.map +1 -1
  81. package/lib-commonjs/components/SplitButton/SplitButton.types.d.ts +1 -1
  82. package/lib-commonjs/components/SplitButton/index.d.ts +1 -1
  83. package/lib-commonjs/components/SplitButton/index.js +2 -0
  84. package/lib-commonjs/components/SplitButton/index.js.map +1 -1
  85. package/lib-commonjs/components/SplitButton/useSplitButton.js +1 -0
  86. package/lib-commonjs/components/SplitButton/useSplitButton.js.map +1 -1
  87. package/lib-commonjs/components/SplitButton/useSplitButtonStyles.d.ts +3 -0
  88. package/lib-commonjs/components/SplitButton/useSplitButtonStyles.js +17 -8
  89. package/lib-commonjs/components/SplitButton/useSplitButtonStyles.js.map +1 -1
  90. package/lib-commonjs/components/ToggleButton/index.d.ts +1 -1
  91. package/lib-commonjs/components/ToggleButton/index.js +2 -0
  92. package/lib-commonjs/components/ToggleButton/index.js.map +1 -1
  93. package/lib-commonjs/components/ToggleButton/useToggleButton.d.ts +1 -1
  94. package/lib-commonjs/components/ToggleButton/useToggleButton.js +3 -42
  95. package/lib-commonjs/components/ToggleButton/useToggleButton.js.map +1 -1
  96. package/lib-commonjs/components/ToggleButton/useToggleButtonStyles.d.ts +5 -0
  97. package/lib-commonjs/components/ToggleButton/useToggleButtonStyles.js +77 -62
  98. package/lib-commonjs/components/ToggleButton/useToggleButtonStyles.js.map +1 -1
  99. package/lib-commonjs/index.d.ts +11 -5
  100. package/lib-commonjs/index.js +204 -6
  101. package/lib-commonjs/index.js.map +1 -1
  102. package/lib-commonjs/utils/index.d.ts +1 -0
  103. package/lib-commonjs/utils/index.js +10 -0
  104. package/lib-commonjs/utils/index.js.map +1 -0
  105. package/lib-commonjs/utils/useToggleState.d.ts +3 -0
  106. package/lib-commonjs/utils/useToggleState.js +48 -0
  107. package/lib-commonjs/utils/useToggleState.js.map +1 -0
  108. package/package.json +12 -22
  109. package/dist/demo/index.html +0 -71
  110. package/dist/demo/react-dom.development.js +0 -21413
  111. package/dist/demo/react.development.js +0 -3155
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utils/useToggleState.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAIA,SAAgB,cAAhB,CAIE,KAJF,EAI6B,KAJ7B,EAIgD;AAC9C,QAAM;AAAE,IAAA,OAAF;AAAW,IAAA,cAAX;AAA2B,IAAA,QAA3B;AAAqC,IAAA;AAArC,MAA2D,KAAjE;AACA,QAAM;AAAE,IAAA,OAAF;AAAW,IAAA;AAAX,MAAoB,KAAK,CAAC,IAAhC;AAEA,QAAM,CAAC,YAAD,EAAe,eAAf,IAAkC,iBAAA,CAAA,oBAAA,CAAqB;AAC3D,IAAA,KAAK,EAAE,OADoD;AAE3D,IAAA,YAAY,EAAE,cAF6C;AAG3D,IAAA,YAAY,EAAE;AAH6C,GAArB,CAAxC;AAMA,QAAM,kBAAkB,GAAG,IAAI,KAAK,kBAAT,IAA+B,IAAI,KAAK,UAAnE;AAEA,QAAM,aAAa,GAAG,KAAK,CAAC,WAAN,CACpB,EAAE,IAAG;AACH,QAAI,CAAC,QAAD,IAAa,CAAC,iBAAlB,EAAqC;AACnC,UAAI,EAAE,CAAC,gBAAP,EAAyB;AACvB;AACD;;AAED,MAAA,eAAe,CAAC,CAAC,YAAF,CAAf;AACD;AACF,GATmB,EAUpB,CAAC,YAAD,EAAe,QAAf,EAAyB,iBAAzB,EAA4C,eAA5C,CAVoB,CAAtB;AAaA,SAAO,EACL,GAAG,KADE;AAGL,IAAA,OAAO,EAAE,YAHJ;AAKL,IAAA,IAAI,EAAE,EACJ,GAAG,KAAK,CAAC,IADL;AAEJ,OAAC,kBAAkB,GAAG,cAAH,GAAoB,cAAvC,GAAwD,YAFpD;AAGJ,MAAA,OAAO,EAAE,iBAAA,CAAA,uBAAA,CACP,OADO,EAEP,aAFO;AAHL;AALD,GAAP;AAcD;;AA3CD,OAAA,CAAA,cAAA,GAAA,cAAA","sourcesContent":["import * as React from 'react';\nimport { useControllableState, useMergedEventCallbacks } from '@fluentui/react-utilities';\nimport type { ButtonState } from '../Button';\nimport type { ToggleButtonProps, ToggleButtonState } from '../ToggleButton';\n\nexport function useToggleState<\n TToggleButtonProps extends Pick<ToggleButtonProps, 'checked' | 'defaultChecked' | 'disabled' | 'disabledFocusable'>,\n TButtonState extends Pick<ButtonState, 'root'>,\n TToggleButtonState extends Pick<ToggleButtonState, 'checked' | 'root'>\n>(props: TToggleButtonProps, state: TButtonState): TToggleButtonState {\n const { checked, defaultChecked, disabled, disabledFocusable } = props;\n const { onClick, role } = state.root;\n\n const [checkedValue, setCheckedValue] = useControllableState({\n state: checked,\n defaultState: defaultChecked,\n initialState: false,\n });\n\n const isCheckboxTypeRole = role === 'menuitemcheckbox' || role === 'checkbox';\n\n const onToggleClick = React.useCallback(\n ev => {\n if (!disabled && !disabledFocusable) {\n if (ev.defaultPrevented) {\n return;\n }\n\n setCheckedValue(!checkedValue);\n }\n },\n [checkedValue, disabled, disabledFocusable, setCheckedValue],\n );\n\n return {\n ...state,\n\n checked: checkedValue,\n\n root: {\n ...state.root,\n [isCheckboxTypeRole ? 'aria-checked' : 'aria-pressed']: checkedValue,\n onClick: useMergedEventCallbacks(\n onClick as React.MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>,\n onToggleClick,\n ),\n },\n } as TToggleButtonState;\n}\n"],"sourceRoot":"../src/"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-button",
3
- "version": "9.0.0-rc.5",
3
+ "version": "9.0.0-rc.8",
4
4
  "description": "Fluent UI React Button component.",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -21,35 +21,25 @@
21
21
  "start": "yarn storybook",
22
22
  "test": "jest --passWithNoTests",
23
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-button/src && yarn docs",
25
- "storybook": "node ../../scripts/storybook/runner",
24
+ "build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/packages/react-components/react-button/src && yarn docs",
25
+ "storybook": "node ../../../scripts/storybook/runner",
26
26
  "type-check": "tsc -b tsconfig.json"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@fluentui/a11y-testing": "^0.1.0",
30
30
  "@fluentui/eslint-plugin": "*",
31
31
  "@fluentui/react-conformance": "*",
32
- "@fluentui/react-conformance-griffel": "9.0.0-beta.3",
33
- "@fluentui/scripts": "^1.0.0",
34
- "@types/enzyme": "3.10.3",
35
- "@types/enzyme-adapter-react-16": "1.0.3",
36
- "@types/react": "16.9.42",
37
- "@types/react-dom": "16.9.10",
38
- "@types/react-test-renderer": "^16.0.0",
39
- "enzyme": "~3.10.0",
40
- "enzyme-adapter-react-16": "^1.15.0",
41
- "react": "16.8.6",
42
- "react-dom": "16.8.6",
43
- "react-test-renderer": "^16.3.0"
32
+ "@fluentui/react-conformance-griffel": "9.0.0-beta.4",
33
+ "@fluentui/scripts": "^1.0.0"
44
34
  },
45
35
  "dependencies": {
46
- "@fluentui/keyboard-keys": "9.0.0-rc.4",
47
- "@fluentui/react-aria": "9.0.0-rc.5",
48
- "@fluentui/react-icons": "^2.0.159-beta.10",
49
- "@fluentui/react-tabster": "9.0.0-rc.5",
50
- "@fluentui/react-theme": "9.0.0-rc.4",
51
- "@fluentui/react-utilities": "9.0.0-rc.5",
52
- "@griffel/react": "1.0.0",
36
+ "@fluentui/keyboard-keys": "9.0.0-rc.5",
37
+ "@fluentui/react-aria": "9.0.0-rc.7",
38
+ "@fluentui/react-icons": "^2.0.166-rc.3",
39
+ "@fluentui/react-tabster": "9.0.0-rc.8",
40
+ "@fluentui/react-theme": "9.0.0-rc.6",
41
+ "@fluentui/react-utilities": "9.0.0-rc.7",
42
+ "@griffel/react": "1.0.3",
53
43
  "tslib": "^2.1.0"
54
44
  },
55
45
  "peerDependencies": {
@@ -1,71 +0,0 @@
1
- <!DOCTYPE html>
2
- <html dir="ltr" lang="en-us">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" user-scalable="no" />
7
- <title>Fluent UI React Examples</title>
8
- </head>
9
-
10
- <body>
11
- <div id="content"></div>
12
- <script type="text/javascript">
13
- // @ts-check
14
- window.FabricConfig = {
15
- // Uncommenting this prevents the fontfaces from being registered.
16
- // Alternatively you can specify a base url which contains the font/icon assets.
17
- // fontBaseUrl: '',
18
- // mergeStyles: {
19
- // injectionMode: 2
20
- // }
21
- };
22
-
23
- var isLocal = ['localhost', '[::]', '127.0.0.1'].indexOf(location.hostname) !== -1;
24
-
25
- var isDev = getParameterByName('dev') === '1' || !!getParameterByName('strict');
26
- var minParam = getParameterByName('min');
27
- var useMinified =
28
- !isDev && minParam !== '0' && (minParam === '1' || location.pathname === '/fabric-react/master/');
29
-
30
- function loadScript(n) {
31
- for (var i = 0; i < n.length; i++) {
32
- var s = document.createElement('script');
33
- s.src = n[i];
34
- s.async = false;
35
- document.body.appendChild(s);
36
- }
37
- }
38
-
39
- const scripts = [];
40
-
41
- if (isLocal) {
42
- scripts.push('./react.development.js');
43
- scripts.push('./react-dom.development.js');
44
- } else {
45
- const reactVersion = isDev ? 'development.js' : 'production.min.js';
46
- scripts.push('//cdnjs.cloudflare.com/ajax/libs/react/16.8.6/umd/react.' + reactVersion);
47
- scripts.push('//cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.6/umd/react-dom.' + reactVersion);
48
- }
49
-
50
- if (useMinified) {
51
- scripts.push('demo-app.min.js');
52
- } else {
53
- scripts.push('demo-app.js');
54
- }
55
-
56
- loadScript(scripts);
57
-
58
- function getParameterByName(name, url) {
59
- if (!url) {
60
- url = location.href;
61
- }
62
- name = name.replace(/[\[\]]/g, '\\$&');
63
- var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
64
- results = regex.exec(url);
65
- if (!results) return null;
66
- if (!results[2]) return '';
67
- return decodeURIComponent(results[2].replace(/\+/g, ' '));
68
- }
69
- </script>
70
- </body>
71
- </html>