@fluentui/react-button 9.3.4 → 9.3.6
Sign up to get free protection for your applications and to get access to all the features.
- package/.swcrc +30 -0
- package/CHANGELOG.json +91 -1
- package/CHANGELOG.md +30 -2
- package/lib/Button.js.map +1 -1
- package/lib/CompoundButton.js.map +1 -1
- package/lib/MenuButton.js.map +1 -1
- package/lib/SplitButton.js.map +1 -1
- package/lib/ToggleButton.js.map +1 -1
- package/lib/components/Button/Button.js.map +1 -1
- package/lib/components/Button/Button.types.js.map +1 -1
- package/lib/components/Button/index.js.map +1 -1
- package/lib/components/Button/renderButton.js +1 -7
- package/lib/components/Button/renderButton.js.map +1 -1
- package/lib/components/Button/useButton.js +1 -0
- package/lib/components/Button/useButton.js.map +1 -1
- package/lib/components/Button/useButtonStyles.js.map +1 -1
- package/lib/components/CompoundButton/CompoundButton.js.map +1 -1
- package/lib/components/CompoundButton/CompoundButton.types.js.map +1 -1
- package/lib/components/CompoundButton/index.js.map +1 -1
- package/lib/components/CompoundButton/renderCompoundButton.js +1 -11
- package/lib/components/CompoundButton/renderCompoundButton.js.map +1 -1
- package/lib/components/CompoundButton/useCompoundButton.js +3 -2
- package/lib/components/CompoundButton/useCompoundButton.js.map +1 -1
- package/lib/components/CompoundButton/useCompoundButtonStyles.js.map +1 -1
- package/lib/components/MenuButton/MenuButton.js.map +1 -1
- package/lib/components/MenuButton/MenuButton.types.js.map +1 -1
- package/lib/components/MenuButton/index.js.map +1 -1
- package/lib/components/MenuButton/renderMenuButton.js +1 -7
- package/lib/components/MenuButton/renderMenuButton.js.map +1 -1
- package/lib/components/MenuButton/useMenuButton.js +2 -2
- package/lib/components/MenuButton/useMenuButton.js.map +1 -1
- package/lib/components/MenuButton/useMenuButtonStyles.js.map +1 -1
- package/lib/components/SplitButton/SplitButton.js.map +1 -1
- package/lib/components/SplitButton/SplitButton.types.js.map +1 -1
- package/lib/components/SplitButton/index.js.map +1 -1
- package/lib/components/SplitButton/renderSplitButton.js +1 -7
- package/lib/components/SplitButton/renderSplitButton.js.map +1 -1
- package/lib/components/SplitButton/useSplitButton.js +1 -0
- package/lib/components/SplitButton/useSplitButton.js.map +1 -1
- package/lib/components/SplitButton/useSplitButtonStyles.js.map +1 -1
- package/lib/components/ToggleButton/ToggleButton.js.map +1 -1
- package/lib/components/ToggleButton/ToggleButton.types.js.map +1 -1
- package/lib/components/ToggleButton/index.js.map +1 -1
- package/lib/components/ToggleButton/renderToggleButton.js.map +1 -1
- package/lib/components/ToggleButton/useToggleButton.js +1 -0
- package/lib/components/ToggleButton/useToggleButton.js.map +1 -1
- package/lib/components/ToggleButton/useToggleButtonStyles.js.map +1 -1
- package/lib/contexts/ButtonContext.js +2 -4
- package/lib/contexts/ButtonContext.js.map +1 -1
- package/lib/contexts/index.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/useToggleState.js.map +1 -1
- package/lib-commonjs/Button.js +5 -4
- package/lib-commonjs/Button.js.map +1 -1
- package/lib-commonjs/CompoundButton.js +5 -4
- package/lib-commonjs/CompoundButton.js.map +1 -1
- package/lib-commonjs/MenuButton.js +5 -4
- package/lib-commonjs/MenuButton.js.map +1 -1
- package/lib-commonjs/SplitButton.js +5 -4
- package/lib-commonjs/SplitButton.js.map +1 -1
- package/lib-commonjs/ToggleButton.js +5 -4
- package/lib-commonjs/ToggleButton.js.map +1 -1
- package/lib-commonjs/components/Button/Button.js +19 -21
- package/lib-commonjs/components/Button/Button.js.map +1 -1
- package/lib-commonjs/components/Button/Button.types.js +3 -2
- package/lib-commonjs/components/Button/Button.types.js.map +1 -1
- package/lib-commonjs/components/Button/index.js +17 -19
- package/lib-commonjs/components/Button/index.js.map +1 -1
- package/lib-commonjs/components/Button/renderButton.js +14 -26
- package/lib-commonjs/components/Button/renderButton.js.map +1 -1
- package/lib-commonjs/components/Button/useButton.js +40 -52
- package/lib-commonjs/components/Button/useButton.js.map +1 -1
- package/lib-commonjs/components/Button/useButtonStyles.js +1129 -471
- package/lib-commonjs/components/Button/useButtonStyles.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/CompoundButton.js +19 -21
- package/lib-commonjs/components/CompoundButton/CompoundButton.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/CompoundButton.types.js +3 -2
- package/lib-commonjs/components/CompoundButton/CompoundButton.types.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/index.js +18 -20
- package/lib-commonjs/components/CompoundButton/index.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/renderCompoundButton.js +14 -30
- package/lib-commonjs/components/CompoundButton/renderCompoundButton.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/useCompoundButton.js +31 -36
- package/lib-commonjs/components/CompoundButton/useCompoundButton.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/useCompoundButtonStyles.js +315 -184
- package/lib-commonjs/components/CompoundButton/useCompoundButtonStyles.js.map +1 -1
- package/lib-commonjs/components/MenuButton/MenuButton.js +19 -22
- package/lib-commonjs/components/MenuButton/MenuButton.js.map +1 -1
- package/lib-commonjs/components/MenuButton/MenuButton.types.js +3 -2
- package/lib-commonjs/components/MenuButton/MenuButton.types.js.map +1 -1
- package/lib-commonjs/components/MenuButton/index.js +18 -20
- package/lib-commonjs/components/MenuButton/index.js.map +1 -1
- package/lib-commonjs/components/MenuButton/renderMenuButton.js +14 -26
- package/lib-commonjs/components/MenuButton/renderMenuButton.js.map +1 -1
- package/lib-commonjs/components/MenuButton/useMenuButton.js +34 -37
- package/lib-commonjs/components/MenuButton/useMenuButton.js.map +1 -1
- package/lib-commonjs/components/MenuButton/useMenuButtonStyles.js +166 -106
- package/lib-commonjs/components/MenuButton/useMenuButtonStyles.js.map +1 -1
- package/lib-commonjs/components/SplitButton/SplitButton.js +19 -22
- package/lib-commonjs/components/SplitButton/SplitButton.js.map +1 -1
- package/lib-commonjs/components/SplitButton/SplitButton.types.js +3 -2
- package/lib-commonjs/components/SplitButton/SplitButton.types.js.map +1 -1
- package/lib-commonjs/components/SplitButton/index.js +18 -20
- package/lib-commonjs/components/SplitButton/index.js.map +1 -1
- package/lib-commonjs/components/SplitButton/renderSplitButton.js +13 -22
- package/lib-commonjs/components/SplitButton/renderSplitButton.js.map +1 -1
- package/lib-commonjs/components/SplitButton/useSplitButton.js +66 -79
- package/lib-commonjs/components/SplitButton/useSplitButton.js.map +1 -1
- package/lib-commonjs/components/SplitButton/useSplitButtonStyles.js +263 -106
- package/lib-commonjs/components/SplitButton/useSplitButtonStyles.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/ToggleButton.js +19 -21
- package/lib-commonjs/components/ToggleButton/ToggleButton.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/ToggleButton.types.js +3 -2
- package/lib-commonjs/components/ToggleButton/ToggleButton.types.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/index.js +18 -20
- package/lib-commonjs/components/ToggleButton/index.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/renderToggleButton.js +6 -8
- package/lib-commonjs/components/ToggleButton/renderToggleButton.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/useToggleButton.js +14 -16
- package/lib-commonjs/components/ToggleButton/useToggleButton.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/useToggleButtonStyles.js +897 -380
- package/lib-commonjs/components/ToggleButton/useToggleButtonStyles.js.map +1 -1
- package/lib-commonjs/contexts/ButtonContext.js +18 -19
- package/lib-commonjs/contexts/ButtonContext.js.map +1 -1
- package/lib-commonjs/contexts/index.js +5 -4
- package/lib-commonjs/contexts/index.js.map +1 -1
- package/lib-commonjs/index.js +47 -179
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utils/index.js +5 -4
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/useToggleState.js +40 -40
- package/lib-commonjs/utils/useToggleState.js.map +1 -1
- package/package.json +12 -11
- package/lib-amd/Button.js +0 -6
- package/lib-amd/Button.js.map +0 -1
- package/lib-amd/CompoundButton.js +0 -6
- package/lib-amd/CompoundButton.js.map +0 -1
- package/lib-amd/MenuButton.js +0 -6
- package/lib-amd/MenuButton.js.map +0 -1
- package/lib-amd/SplitButton.js +0 -6
- package/lib-amd/SplitButton.js.map +0 -1
- package/lib-amd/ToggleButton.js +0 -6
- package/lib-amd/ToggleButton.js.map +0 -1
- package/lib-amd/components/Button/Button.js +0 -18
- package/lib-amd/components/Button/Button.js.map +0 -1
- package/lib-amd/components/Button/Button.types.js +0 -5
- package/lib-amd/components/Button/Button.types.js.map +0 -1
- package/lib-amd/components/Button/index.js +0 -11
- package/lib-amd/components/Button/index.js.map +0 -1
- package/lib-amd/components/Button/renderButton.js +0 -18
- package/lib-amd/components/Button/renderButton.js.map +0 -1
- package/lib-amd/components/Button/useButton.js +0 -41
- package/lib-amd/components/Button/useButton.js.map +0 -1
- package/lib-amd/components/Button/useButtonStyles.js +0 -227
- package/lib-amd/components/Button/useButtonStyles.js.map +0 -1
- package/lib-amd/components/CompoundButton/CompoundButton.js +0 -18
- package/lib-amd/components/CompoundButton/CompoundButton.js.map +0 -1
- package/lib-amd/components/CompoundButton/CompoundButton.types.js +0 -5
- package/lib-amd/components/CompoundButton/CompoundButton.types.js.map +0 -1
- package/lib-amd/components/CompoundButton/index.js +0 -12
- package/lib-amd/components/CompoundButton/index.js.map +0 -1
- package/lib-amd/components/CompoundButton/renderCompoundButton.js +0 -20
- package/lib-amd/components/CompoundButton/renderCompoundButton.js.map +0 -1
- package/lib-amd/components/CompoundButton/useCompoundButton.js +0 -27
- package/lib-amd/components/CompoundButton/useCompoundButton.js.map +0 -1
- package/lib-amd/components/CompoundButton/useCompoundButtonStyles.js +0 -216
- package/lib-amd/components/CompoundButton/useCompoundButtonStyles.js.map +0 -1
- package/lib-amd/components/MenuButton/MenuButton.js +0 -19
- package/lib-amd/components/MenuButton/MenuButton.js.map +0 -1
- package/lib-amd/components/MenuButton/MenuButton.types.js +0 -5
- package/lib-amd/components/MenuButton/MenuButton.types.js.map +0 -1
- package/lib-amd/components/MenuButton/index.js +0 -12
- package/lib-amd/components/MenuButton/index.js.map +0 -1
- package/lib-amd/components/MenuButton/renderMenuButton.js +0 -18
- package/lib-amd/components/MenuButton/renderMenuButton.js.map +0 -1
- package/lib-amd/components/MenuButton/useMenuButton.js +0 -30
- package/lib-amd/components/MenuButton/useMenuButton.js.map +0 -1
- package/lib-amd/components/MenuButton/useMenuButtonStyles.js +0 -97
- package/lib-amd/components/MenuButton/useMenuButtonStyles.js.map +0 -1
- package/lib-amd/components/SplitButton/SplitButton.js +0 -19
- package/lib-amd/components/SplitButton/SplitButton.js.map +0 -1
- package/lib-amd/components/SplitButton/SplitButton.types.js +0 -5
- package/lib-amd/components/SplitButton/SplitButton.types.js.map +0 -1
- package/lib-amd/components/SplitButton/index.js +0 -12
- package/lib-amd/components/SplitButton/index.js.map +0 -1
- package/lib-amd/components/SplitButton/renderSplitButton.js +0 -16
- package/lib-amd/components/SplitButton/renderSplitButton.js.map +0 -1
- package/lib-amd/components/SplitButton/useSplitButton.js +0 -67
- package/lib-amd/components/SplitButton/useSplitButton.js.map +0 -1
- package/lib-amd/components/SplitButton/useSplitButtonStyles.js +0 -162
- package/lib-amd/components/SplitButton/useSplitButtonStyles.js.map +0 -1
- package/lib-amd/components/ToggleButton/ToggleButton.js +0 -18
- package/lib-amd/components/ToggleButton/ToggleButton.js.map +0 -1
- package/lib-amd/components/ToggleButton/ToggleButton.types.js +0 -5
- package/lib-amd/components/ToggleButton/ToggleButton.types.js.map +0 -1
- package/lib-amd/components/ToggleButton/index.js +0 -12
- package/lib-amd/components/ToggleButton/index.js.map +0 -1
- package/lib-amd/components/ToggleButton/renderToggleButton.js +0 -7
- package/lib-amd/components/ToggleButton/renderToggleButton.js.map +0 -1
- package/lib-amd/components/ToggleButton/useToggleButton.js +0 -17
- package/lib-amd/components/ToggleButton/useToggleButton.js.map +0 -1
- package/lib-amd/components/ToggleButton/useToggleButtonStyles.js +0 -87
- package/lib-amd/components/ToggleButton/useToggleButtonStyles.js.map +0 -1
- package/lib-amd/contexts/ButtonContext.js +0 -19
- package/lib-amd/contexts/ButtonContext.js.map +0 -1
- package/lib-amd/contexts/index.js +0 -6
- package/lib-amd/contexts/index.js.map +0 -1
- package/lib-amd/index.js +0 -34
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/utils/index.js +0 -6
- package/lib-amd/utils/index.js.map +0 -1
- package/lib-amd/utils/useToggleState.js +0 -27
- package/lib-amd/utils/useToggleState.js.map +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-button/src/utils/index.ts"],"names":[],"mappings":";;;IAAA,gDAAiC","sourcesContent":["export * from './useToggleState';\n"]}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
define(["require", "exports", "tslib", "react", "@fluentui/react-utilities"], function (require, exports, tslib_1, React, react_utilities_1) {
|
2
|
-
"use strict";
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.useToggleState = void 0;
|
5
|
-
function useToggleState(props, state) {
|
6
|
-
var _a;
|
7
|
-
var checked = props.checked, defaultChecked = props.defaultChecked, disabled = props.disabled, disabledFocusable = props.disabledFocusable;
|
8
|
-
var _b = state.root, onClick = _b.onClick, role = _b.role;
|
9
|
-
var _c = react_utilities_1.useControllableState({
|
10
|
-
state: checked,
|
11
|
-
defaultState: defaultChecked,
|
12
|
-
initialState: false,
|
13
|
-
}), checkedValue = _c[0], setCheckedValue = _c[1];
|
14
|
-
var isCheckboxTypeRole = role === 'menuitemcheckbox' || role === 'checkbox';
|
15
|
-
var onToggleClick = React.useCallback(function (ev) {
|
16
|
-
if (!disabled && !disabledFocusable) {
|
17
|
-
if (ev.defaultPrevented) {
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
setCheckedValue(!checkedValue);
|
21
|
-
}
|
22
|
-
}, [checkedValue, disabled, disabledFocusable, setCheckedValue]);
|
23
|
-
return tslib_1.__assign(tslib_1.__assign({}, state), { checked: checkedValue, root: tslib_1.__assign(tslib_1.__assign({}, state.root), (_a = {}, _a[isCheckboxTypeRole ? 'aria-checked' : 'aria-pressed'] = checkedValue, _a.onClick = react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(onClick, onToggleClick)), _a)) });
|
24
|
-
}
|
25
|
-
exports.useToggleState = useToggleState;
|
26
|
-
});
|
27
|
-
//# sourceMappingURL=useToggleState.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useToggleState.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-button/src/utils/useToggleState.ts"],"names":[],"mappings":";;;;IAKA,SAAgB,cAAc,CAI5B,KAAyB,EAAE,KAAmB;;QACtC,IAAA,OAAO,GAAkD,KAAK,QAAvD,EAAE,cAAc,GAAkC,KAAK,eAAvC,EAAE,QAAQ,GAAwB,KAAK,SAA7B,EAAE,iBAAiB,GAAK,KAAK,kBAAV,CAAW;QACjE,IAAA,KAAoB,KAAK,CAAC,IAAI,EAA5B,OAAO,aAAA,EAAE,IAAI,UAAe,CAAC;QAE/B,IAAA,KAAkC,sCAAoB,CAAC;YAC3D,KAAK,EAAE,OAAO;YACd,YAAY,EAAE,cAAc;YAC5B,YAAY,EAAE,KAAK;SACpB,CAAC,EAJK,YAAY,QAAA,EAAE,eAAe,QAIlC,CAAC;QAEH,IAAM,kBAAkB,GAAG,IAAI,KAAK,kBAAkB,IAAI,IAAI,KAAK,UAAU,CAAC;QAE9E,IAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CACrC,UAAA,EAAE;YACA,IAAI,CAAC,QAAQ,IAAI,CAAC,iBAAiB,EAAE;gBACnC,IAAI,EAAE,CAAC,gBAAgB,EAAE;oBACvB,OAAO;iBACR;gBAED,eAAe,CAAC,CAAC,YAAY,CAAC,CAAC;aAChC;QACH,CAAC,EACD,CAAC,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,eAAe,CAAC,CAC7D,CAAC;QAEF,OAAO,sCACF,KAAK,KAER,OAAO,EAAE,YAAY,EAErB,IAAI,wCACC,KAAK,CAAC,IAAI,gBACZ,kBAAkB,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,IAAG,YAAY,EACpE,UAAO,GAAE,kCAAgB,CACvB,gCAAc,CAAC,OAAyE,EAAE,aAAa,CAAC,CACzG,SAEkB,CAAC;IAC1B,CAAC;IA1CD,wCA0CC","sourcesContent":["import * as React from 'react';\nimport { mergeCallbacks, useControllableState, useEventCallback } 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: useEventCallback(\n mergeCallbacks(onClick as React.MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>, onToggleClick),\n ),\n },\n } as TToggleButtonState;\n}\n"]}
|