@ringcentral/juno 3.0.0-alpha.10 → 3.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Buttons/Button/Button.js +10 -3
- package/components/Buttons/ButtonBase/ButtonBase.d.ts +17 -3
- package/components/Buttons/ButtonBase/ButtonBase.js +13 -1
- package/components/Buttons/IconButton/IconButton.d.ts +1 -4
- package/components/Buttons/IconButton/IconButton.js +9 -2
- package/components/Dialer/DialPad/utils/useDialKeyboard.d.ts +1 -1
- package/components/Downshift/utils/useDownshift.d.ts +2 -2
- package/components/Forms/TextField/TextField.d.ts +1 -1
- package/components/Stepper/StepButton/StepButton.js +9 -2
- package/components/Tabs/Tab/Tab.js +9 -2
- package/es6/components/Buttons/Button/Button.js +11 -4
- package/es6/components/Buttons/ButtonBase/ButtonBase.js +15 -3
- package/es6/components/Buttons/IconButton/IconButton.js +11 -4
- package/es6/components/Stepper/StepButton/StepButton.js +11 -4
- package/es6/components/Tabs/Tab/Tab.js +11 -4
- package/es6/foundation/hooks/index.js +1 -0
- package/es6/foundation/hooks/useSafeAutoFocus/index.js +1 -0
- package/es6/foundation/hooks/useSafeAutoFocus/useSafeAutoFocus.js +35 -0
- package/foundation/hooks/index.d.ts +1 -0
- package/foundation/hooks/index.js +1 -0
- package/foundation/hooks/useSafeAutoFocus/index.d.ts +1 -0
- package/foundation/hooks/useSafeAutoFocus/index.js +4 -0
- package/foundation/hooks/useSafeAutoFocus/package.json +5 -0
- package/foundation/hooks/useSafeAutoFocus/useSafeAutoFocus.d.ts +7 -0
- package/foundation/hooks/useSafeAutoFocus/useSafeAutoFocus.js +38 -0
- package/package.json +1 -1
|
@@ -23,10 +23,11 @@ var _RcButton = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
23
23
|
},
|
|
24
24
|
]);
|
|
25
25
|
}
|
|
26
|
-
var childrenProp = props.children, classesProp = props.classes, startIconProp = props.startIcon, endIconProp = props.endIcon, loading = props.loading, loadingMode = props.loadingMode, disabled = props.disabled, IconProps = props.IconProps, size = props.size, color = props.color, CircularProgressProps = props.CircularProgressProps, variant = props.variant, disabledVariant = props.disabledVariant, radius = props.radius, keepElevation = props.keepElevation, focusVariant = props.focusVariant, disableFocusRippleProp = props.disableFocusRipple, rest = tslib_1.__rest(props, ["children", "classes", "startIcon", "endIcon", "loading", "loadingMode", "disabled", "IconProps", "size", "color", "CircularProgressProps", "variant", "disabledVariant", "radius", "keepElevation", "focusVariant", "disableFocusRipple"]);
|
|
26
|
+
var childrenProp = props.children, classesProp = props.classes, startIconProp = props.startIcon, endIconProp = props.endIcon, loading = props.loading, loadingMode = props.loadingMode, disabled = props.disabled, IconProps = props.IconProps, size = props.size, color = props.color, CircularProgressProps = props.CircularProgressProps, variant = props.variant, disabledVariant = props.disabledVariant, radius = props.radius, keepElevation = props.keepElevation, focusVariant = props.focusVariant, _c = props.autoFocus, autoFocus = _c === void 0 ? false : _c, disableFocusRippleProp = props.disableFocusRipple, onBlur = props.onBlur, rest = tslib_1.__rest(props, ["children", "classes", "startIcon", "endIcon", "loading", "loadingMode", "disabled", "IconProps", "size", "color", "CircularProgressProps", "variant", "disabledVariant", "radius", "keepElevation", "focusVariant", "autoFocus", "disableFocusRipple", "onBlur"]);
|
|
27
27
|
var theme = (0, foundation_1.useTheme)();
|
|
28
28
|
var innerRef = (0, react_1.useRef)(null);
|
|
29
29
|
var buttonRef = (0, foundation_1.useForkRef)(innerRef, ref);
|
|
30
|
+
var _d = (0, foundation_1.useSafeAutoFocus)(autoFocus && !(disabled || loading), innerRef), suppressInitialFocusRipple = _d.suppressInitialFocusRipple, handleAutoFocusBlur = _d.handleAutoFocusBlur;
|
|
30
31
|
var isPlain = variant === 'plain';
|
|
31
32
|
var isReplace = loadingMode === 'replace';
|
|
32
33
|
var iconSize = (0, utils_2.getButtonIconSize)(size);
|
|
@@ -92,8 +93,14 @@ var _RcButton = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
92
93
|
(0, react_1.useLayoutEffect)(function () {
|
|
93
94
|
(0, foundation_1.removeClassName)(innerRef, 'MuiButton-iconSizeMedium');
|
|
94
95
|
});
|
|
95
|
-
var disableFocusRipple =
|
|
96
|
-
|
|
96
|
+
var disableFocusRipple = suppressInitialFocusRipple
|
|
97
|
+
? true
|
|
98
|
+
: disableFocusRippleProp !== null && disableFocusRippleProp !== void 0 ? disableFocusRippleProp : focusVariant === 'focusRing';
|
|
99
|
+
var handleBlur = (0, foundation_1.useEventCallback)(function (event) {
|
|
100
|
+
handleAutoFocusBlur(event);
|
|
101
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
102
|
+
});
|
|
103
|
+
return (react_1.default.createElement(Button_1.default, tslib_1.__assign({ ref: buttonRef, disabled: disabled || loading, variant: isPlain ? undefined : variant, disableRipple: ((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.props) === null || _a === void 0 ? void 0 : _a.MuiButton) === null || _b === void 0 ? void 0 : _b.disableRipple) || isPlain, startIcon: startIcon, endIcon: endIcon, classes: classes, disableFocusRipple: disableFocusRipple, onBlur: handleBlur }, rest), loading && isReplace ? loadingElm : childrenProp));
|
|
97
104
|
});
|
|
98
105
|
exports.RcButtonDefaultSize = 'large';
|
|
99
106
|
exports.RcButtonDefaultColor = 'primary';
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import { ComponentProps } from 'react';
|
|
1
|
+
import React, { ComponentProps } from 'react';
|
|
2
2
|
import MuiButtonBase from '@material-ui/core/ButtonBase';
|
|
3
3
|
type RcButtonBaseProps = ComponentProps<typeof MuiButtonBase>;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
declare const RcButtonBase: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<Omit<{
|
|
5
|
+
action?: React.Ref<import("@material-ui/core/ButtonBase").ButtonBaseActions> | undefined;
|
|
6
|
+
buttonRef?: React.Ref<unknown> | undefined;
|
|
7
|
+
centerRipple?: boolean | undefined;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
disabled?: boolean | undefined;
|
|
10
|
+
disableRipple?: boolean | undefined;
|
|
11
|
+
disableTouchRipple?: boolean | undefined;
|
|
12
|
+
focusRipple?: boolean | undefined;
|
|
13
|
+
focusVisibleClassName?: string | undefined;
|
|
14
|
+
onFocusVisible?: React.FocusEventHandler<any> | undefined;
|
|
15
|
+
tabIndex?: string | number | undefined;
|
|
16
|
+
TouchRippleProps?: Partial<import("@material-ui/core/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
|
|
17
|
+
} & import("@material-ui/core/OverridableComponent").CommonProps<import("@material-ui/core/ButtonBase").ExtendButtonBaseTypeMap<import("@material-ui/core/ButtonBase").ButtonBaseTypeMap<{}, "button">>> & Pick<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
18
|
+
ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
|
|
19
|
+
}, "ref" | "key" | "suppressHydrationWarning" | "color" | "id" | "lang" | "name" | "type" | "role" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "form" | "slot" | "title" | "translate" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "accessKey" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "nonce" | "spellCheck" | "radioGroup" | "about" | "content" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "value" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget">, "ref"> & React.RefAttributes<any>>, import("../../../foundation").RcTheme, {}, never>;
|
|
6
20
|
export { RcButtonBase };
|
|
7
21
|
export type { RcButtonBaseProps };
|
|
@@ -2,10 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RcButtonBase = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = tslib_1.__importStar(require("react"));
|
|
5
6
|
var ButtonBase_1 = tslib_1.__importDefault(require("@material-ui/core/ButtonBase"));
|
|
6
7
|
var foundation_1 = require("../../../foundation");
|
|
7
8
|
/** @release */
|
|
8
|
-
var
|
|
9
|
+
var _RcButtonBase = (0, react_1.forwardRef)(function (props, ref) {
|
|
10
|
+
var _a = props.autoFocus, autoFocus = _a === void 0 ? false : _a, _b = props.disabled, disabled = _b === void 0 ? false : _b, focusRipple = props.focusRipple, onBlur = props.onBlur, rest = tslib_1.__rest(props, ["autoFocus", "disabled", "focusRipple", "onBlur"]);
|
|
11
|
+
var innerRef = (0, react_1.useRef)(null);
|
|
12
|
+
var buttonRef = (0, foundation_1.useForkRef)(ref, innerRef);
|
|
13
|
+
var _c = (0, foundation_1.useSafeAutoFocus)(autoFocus && !disabled, innerRef), suppressInitialFocusRipple = _c.suppressInitialFocusRipple, handleAutoFocusBlur = _c.handleAutoFocusBlur;
|
|
14
|
+
var handleBlur = (0, foundation_1.useEventCallback)(function (event) {
|
|
15
|
+
handleAutoFocusBlur(event);
|
|
16
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
17
|
+
});
|
|
18
|
+
return react_1.default.createElement(ButtonBase_1.default, tslib_1.__assign(tslib_1.__assign({}, rest), { ref: buttonRef, disabled: disabled, focusRipple: suppressInitialFocusRipple ? false : focusRipple, onBlur: handleBlur }));
|
|
19
|
+
});
|
|
20
|
+
var RcButtonBase = (0, foundation_1.styled)(_RcButtonBase)(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject([""], [""])));
|
|
9
21
|
exports.RcButtonBase = RcButtonBase;
|
|
10
22
|
RcButtonBase.displayName = 'RcButtonBase';
|
|
11
23
|
var templateObject_1;
|
|
@@ -421,10 +421,7 @@ declare const RcIconButton: import("styled-components").StyledComponent<React.Fo
|
|
|
421
421
|
disabled?: boolean | undefined;
|
|
422
422
|
disableRipple?: boolean | undefined;
|
|
423
423
|
disableTouchRipple?: boolean | undefined;
|
|
424
|
-
focusRipple?: boolean | undefined;
|
|
425
|
-
* `box-shadow` with token
|
|
426
|
-
* 0 ~ 24 for different elevation shadow
|
|
427
|
-
*/
|
|
424
|
+
focusRipple?: boolean | undefined;
|
|
428
425
|
focusVisibleClassName?: string | undefined;
|
|
429
426
|
onFocusVisible?: React.FocusEventHandler<any> | undefined;
|
|
430
427
|
tabIndex?: string | number | undefined;
|
|
@@ -17,8 +17,11 @@ var _RcIconButton = (0, react_1.memo)((0, react_1.forwardRef)(function (props, r
|
|
|
17
17
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
18
18
|
(0, foundation_1.useDeprecatedCheck)(RcIconButton, props, IconButtonProps_1.rcIconButtonWarning);
|
|
19
19
|
}
|
|
20
|
-
var _b = props.buttonRef, buttonRef = _b === void 0 ? ref : _b, _c = props.IconProps, IconProps = _c === void 0 ? {} : _c, className = props.className, classesProp = props.classes, children = props.children, title = props.title, disabledFakeBorder = props.disabledFakeBorder, symbol = props.symbol, disabled = props.disabled, invisible = props.invisible, type = props.type, loading = props.loading, TouchRippleProps = props.TouchRippleProps, variant = props.variant, CircularProgressProps = props.CircularProgressProps, color = props.color, shouldPersistBg = props.shouldPersistBg, stretchIcon = props.stretchIcon, iconColor = props.iconColor, iconSize = props.iconSize, disableTouchRipple = props.disableTouchRipple, useColorWhenDisabled = props.useColorWhenDisabled, size = props.size, radius = props.radius, elevation = props.elevation, activeElevation = props.activeElevation, aRef = props.aRef, tooltipTitle = props.tooltipTitle, tooltipForceHide = props.tooltipForceHide, disableToolTip = props.disableToolTip, alwaysEnableTooltip = props.alwaysEnableTooltip, tooltipPlacement = props.tooltipPlacement, ariaLabel = props.ariaLabel, popperProps = props.popperProps, externalLink = props.externalLink, download = props.download, href = props.href, focusVariant = props.focusVariant, rest = tslib_1.__rest(props, ["buttonRef", "IconProps", "className", "classes", "children", "title", "disabledFakeBorder", "symbol", "disabled", "invisible", "type", "loading", "TouchRippleProps", "variant", "CircularProgressProps", "color", "shouldPersistBg", "stretchIcon", "iconColor", "iconSize", "disableTouchRipple", "useColorWhenDisabled", "size", "radius", "elevation", "activeElevation", "aRef", "tooltipTitle", "tooltipForceHide", "disableToolTip", "alwaysEnableTooltip", "tooltipPlacement", "ariaLabel", "popperProps", "externalLink", "download", "href", "focusVariant"]);
|
|
20
|
+
var _b = props.buttonRef, buttonRef = _b === void 0 ? ref : _b, _c = props.IconProps, IconProps = _c === void 0 ? {} : _c, className = props.className, classesProp = props.classes, children = props.children, title = props.title, disabledFakeBorder = props.disabledFakeBorder, symbol = props.symbol, disabled = props.disabled, invisible = props.invisible, type = props.type, loading = props.loading, TouchRippleProps = props.TouchRippleProps, variant = props.variant, CircularProgressProps = props.CircularProgressProps, color = props.color, shouldPersistBg = props.shouldPersistBg, stretchIcon = props.stretchIcon, iconColor = props.iconColor, iconSize = props.iconSize, disableTouchRipple = props.disableTouchRipple, useColorWhenDisabled = props.useColorWhenDisabled, _d = props.autoFocus, autoFocus = _d === void 0 ? false : _d, size = props.size, radius = props.radius, elevation = props.elevation, activeElevation = props.activeElevation, aRef = props.aRef, tooltipTitle = props.tooltipTitle, tooltipForceHide = props.tooltipForceHide, disableToolTip = props.disableToolTip, alwaysEnableTooltip = props.alwaysEnableTooltip, tooltipPlacement = props.tooltipPlacement, ariaLabel = props.ariaLabel, popperProps = props.popperProps, externalLink = props.externalLink, download = props.download, href = props.href, _e = props.focusRipple, focusRippleProp = _e === void 0 ? true : _e, focusVariant = props.focusVariant, onBlur = props.onBlur, rest = tslib_1.__rest(props, ["buttonRef", "IconProps", "className", "classes", "children", "title", "disabledFakeBorder", "symbol", "disabled", "invisible", "type", "loading", "TouchRippleProps", "variant", "CircularProgressProps", "color", "shouldPersistBg", "stretchIcon", "iconColor", "iconSize", "disableTouchRipple", "useColorWhenDisabled", "autoFocus", "size", "radius", "elevation", "activeElevation", "aRef", "tooltipTitle", "tooltipForceHide", "disableToolTip", "alwaysEnableTooltip", "tooltipPlacement", "ariaLabel", "popperProps", "externalLink", "download", "href", "focusRipple", "focusVariant", "onBlur"]);
|
|
21
21
|
var theme = (0, foundation_1.useTheme)();
|
|
22
|
+
var innerButtonRef = (0, react_1.useRef)(null);
|
|
23
|
+
var handleButtonRef = (0, foundation_1.useForkRef)(innerButtonRef, buttonRef);
|
|
24
|
+
var _f = (0, foundation_1.useSafeAutoFocus)(autoFocus && !disabled, innerButtonRef), suppressInitialFocusRipple = _f.suppressInitialFocusRipple, handleAutoFocusBlur = _f.handleAutoFocusBlur;
|
|
22
25
|
var isOutline = variant === 'outline';
|
|
23
26
|
var isContained = variant === 'contained';
|
|
24
27
|
var isInverse = variant === 'inverse';
|
|
@@ -33,13 +36,17 @@ var _RcIconButton = (0, react_1.memo)((0, react_1.forwardRef)(function (props, r
|
|
|
33
36
|
_a[classes.inverse] = isInverse,
|
|
34
37
|
_a[classes.round] = isRound,
|
|
35
38
|
_a));
|
|
39
|
+
var handleBlur = (0, foundation_1.useEventCallback)(function (event) {
|
|
40
|
+
handleAutoFocusBlur(event);
|
|
41
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
42
|
+
});
|
|
36
43
|
var iconButton = (function () {
|
|
37
44
|
var _a, _b;
|
|
38
45
|
// `color` already handle in StyledIconButton
|
|
39
46
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
40
47
|
var color = IconProps.color, IconPropsWithoutColor = tslib_1.__rest(IconProps, ["color"]);
|
|
41
48
|
var icon = react_1.default.isValidElement(children) || children === '' ? children : (react_1.default.createElement(Icon_1.RcIcon, tslib_1.__assign({ symbol: symbol, className: classes.icon, loading: loading, size: "inherit", CircularProgressProps: CircularProgressProps }, IconPropsWithoutColor), children));
|
|
42
|
-
var iconButton = (react_1.default.createElement(ButtonBase_1.RcButtonBase, tslib_1.__assign({ ref:
|
|
49
|
+
var iconButton = (react_1.default.createElement(ButtonBase_1.RcButtonBase, tslib_1.__assign({ ref: handleButtonRef, disableRipple: ((_b = (_a = theme.props) === null || _a === void 0 ? void 0 : _a.MuiButtonBase) === null || _b === void 0 ? void 0 : _b.disableRipple) || isPlain, type: type, disabled: disabled, "aria-label": ariaLabel || tooltipTitle || title, title: title, "aria-disabled": disabled, className: IconClassName, focusRipple: suppressInitialFocusRipple ? false : focusRippleProp, onBlur: handleBlur, TouchRippleProps: (0, foundation_1.combineProps)({
|
|
43
50
|
classes: utils_1.RcIconButtonTouchRippleClasses,
|
|
44
51
|
}, TouchRippleProps) }, rest), icon));
|
|
45
52
|
if (download && href) {
|
|
@@ -9,7 +9,7 @@ export type UseDialKeyboard<E extends KeyboardEvent | React.KeyboardEvent<any>>
|
|
|
9
9
|
* @param options onKeyDown, onKeyUp that you also want apply on target
|
|
10
10
|
* @returns onKeyDown, onKeyUp, control
|
|
11
11
|
*/
|
|
12
|
-
export declare const useDialKeyboard: <E extends
|
|
12
|
+
export declare const useDialKeyboard: <E extends React.KeyboardEvent<any> | KeyboardEvent = React.KeyboardEvent<any>>({ onKeyDown: onKeyDownArg, onKeyUp: onKeyUpArg, }?: UseDialKeyboard<E>) => {
|
|
13
13
|
onKeyDown: (e: E) => void;
|
|
14
14
|
onKeyUp: (e: E) => void;
|
|
15
15
|
control: React.RefObject<RcDialPadControl>;
|
|
@@ -292,7 +292,7 @@ export declare const useDownshift: <T extends RcDownshiftSelectedItem = RcDownsh
|
|
|
292
292
|
getClearButtonProps: (props?: RcIconButtonProps) => {
|
|
293
293
|
variant?: import("../../Buttons/IconButton/IconButton").RcIconButtonVariant | undefined;
|
|
294
294
|
size?: import("../../Buttons/IconButton/IconButton").RcIconButtonSize | undefined;
|
|
295
|
-
shouldPersistBg?: boolean | undefined;
|
|
295
|
+
shouldPersistBg?: boolean | undefined;
|
|
296
296
|
invisible?: boolean | undefined;
|
|
297
297
|
stretchIcon?: boolean | undefined;
|
|
298
298
|
useColorWhenDisabled?: boolean | undefined;
|
|
@@ -324,7 +324,7 @@ export declare const useDownshift: <T extends RcDownshiftSelectedItem = RcDownsh
|
|
|
324
324
|
getToggleButtonProps: (props?: RcIconButtonProps) => {
|
|
325
325
|
variant?: import("../../Buttons/IconButton/IconButton").RcIconButtonVariant | undefined;
|
|
326
326
|
size?: import("../../Buttons/IconButton/IconButton").RcIconButtonSize | undefined;
|
|
327
|
-
shouldPersistBg?: boolean | undefined;
|
|
327
|
+
shouldPersistBg?: boolean | undefined;
|
|
328
328
|
invisible?: boolean | undefined;
|
|
329
329
|
stretchIcon?: boolean | undefined;
|
|
330
330
|
useColorWhenDisabled?: boolean | undefined;
|
|
@@ -74,7 +74,7 @@ declare const RcTextField: import("styled-components").StyledComponent<React.For
|
|
|
74
74
|
elevation?: keyof import("@material-ui/core/styles/shadows").Shadows | undefined;
|
|
75
75
|
activeElevation?: keyof import("@material-ui/core/styles/shadows").Shadows | undefined;
|
|
76
76
|
disabledFakeBorder?: boolean | undefined;
|
|
77
|
-
IconProps?: import("../../Icon/Icon").RcIconProps | undefined;
|
|
77
|
+
IconProps?: import("../../Icon/Icon").RcIconProps | undefined;
|
|
78
78
|
focusVariant?: "highlight" | "focusRing" | undefined;
|
|
79
79
|
} & import("../../Buttons/IconButton/deprecated/IconButtonProps").RcIconButtonDeprecatedProps & Pick<import("../../Icon/Icon").RcIconProps, "symbol" | "color" | "iconColor" | "iconSize" | "loading" | "CircularProgressProps"> & import("../../../foundation").RcClassesProps<"round" | "icon" | "inverse" | "outline" | "invisible" | "contained" | "persistBg"> & RcBaseProps<{
|
|
80
80
|
action?: React.Ref<import("@material-ui/core").ButtonBaseActions> | undefined;
|
|
@@ -10,7 +10,10 @@ var styles_1 = require("./styles");
|
|
|
10
10
|
var utils_1 = require("./utils");
|
|
11
11
|
var _RcStepButton = (0, react_1.forwardRef)(function (inProps, ref) {
|
|
12
12
|
var props = (0, foundation_1.useThemeProps)({ props: inProps, name: 'RcStepButton' });
|
|
13
|
-
var classesProp = props.classes, childrenProp = props.children, icon = props.icon, optional = props.optional, error = props.error, StepLabelProps = props.StepLabelProps, editable = props.editable, rest = tslib_1.__rest(props, ["classes", "children", "icon", "optional", "error", "StepLabelProps", "editable"]);
|
|
13
|
+
var classesProp = props.classes, childrenProp = props.children, icon = props.icon, optional = props.optional, error = props.error, StepLabelProps = props.StepLabelProps, editable = props.editable, _a = props.autoFocus, autoFocus = _a === void 0 ? false : _a, _b = props.disabled, disabled = _b === void 0 ? false : _b, focusRipple = props.focusRipple, onBlur = props.onBlur, rest = tslib_1.__rest(props, ["classes", "children", "icon", "optional", "error", "StepLabelProps", "editable", "autoFocus", "disabled", "focusRipple", "onBlur"]);
|
|
14
|
+
var innerRef = (0, react_1.useRef)(null);
|
|
15
|
+
var handleRef = (0, foundation_1.useForkRef)(innerRef, ref);
|
|
16
|
+
var _c = (0, foundation_1.useSafeAutoFocus)(autoFocus && !disabled, innerRef), suppressInitialFocusRipple = _c.suppressInitialFocusRipple, handleAutoFocusBlur = _c.handleAutoFocusBlur;
|
|
14
17
|
var classes = (0, react_1.useMemo)(function () { return (0, foundation_1.combineClasses)(utils_1.RcStepButtonClasses, classesProp); }, [classesProp]);
|
|
15
18
|
var children = (0, react_1.useMemo)(function () {
|
|
16
19
|
var childProps = (0, foundation_1.combineProps)({
|
|
@@ -21,7 +24,11 @@ var _RcStepButton = (0, react_1.forwardRef)(function (inProps, ref) {
|
|
|
21
24
|
}, StepLabelProps);
|
|
22
25
|
return (0, foundation_1.isRcElement)(childrenProp, ['RcStepLabel']) ? ((0, react_1.cloneElement)(childrenProp, childProps)) : (react_1.default.createElement(StepLabel_1.RcStepLabel, tslib_1.__assign({}, childProps), childrenProp));
|
|
23
26
|
}, [StepLabelProps, childrenProp, editable, error, icon, optional]);
|
|
24
|
-
|
|
27
|
+
var handleBlur = (0, foundation_1.useEventCallback)(function (event) {
|
|
28
|
+
handleAutoFocusBlur(event);
|
|
29
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
30
|
+
});
|
|
31
|
+
return (react_1.default.createElement(StepButton_1.default, tslib_1.__assign({}, rest, { disabled: disabled, focusRipple: suppressInitialFocusRipple ? false : focusRipple, icon: icon, onBlur: handleBlur, optional: optional, ref: handleRef, classes: classes }), children));
|
|
25
32
|
});
|
|
26
33
|
var RcStepButton = (0, foundation_1.styled)(_RcStepButton)(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), styles_1.StepButtonStyle);
|
|
27
34
|
exports.RcStepButton = RcStepButton;
|
|
@@ -9,9 +9,16 @@ var styles_1 = require("./styles");
|
|
|
9
9
|
var utils_1 = require("./utils");
|
|
10
10
|
var _RcTab = (0, react_1.forwardRef)(function (inProps, ref) {
|
|
11
11
|
var props = (0, foundation_1.useThemeProps)({ props: inProps, name: 'RcTab' });
|
|
12
|
-
var classesProp = props.classes, children = props.children, direction = props.direction, rest = tslib_1.__rest(props, ["classes", "children", "direction"]);
|
|
12
|
+
var classesProp = props.classes, children = props.children, direction = props.direction, _a = props.autoFocus, autoFocus = _a === void 0 ? false : _a, _b = props.disableFocusRipple, disableFocusRippleProp = _b === void 0 ? false : _b, _c = props.disabled, disabled = _c === void 0 ? false : _c, onBlur = props.onBlur, rest = tslib_1.__rest(props, ["classes", "children", "direction", "autoFocus", "disableFocusRipple", "disabled", "onBlur"]);
|
|
13
|
+
var innerRef = (0, react_1.useRef)(null);
|
|
14
|
+
var tabRef = (0, foundation_1.useForkRef)(ref, innerRef);
|
|
15
|
+
var _d = (0, foundation_1.useSafeAutoFocus)(autoFocus && !disabled, innerRef), suppressInitialFocusRipple = _d.suppressInitialFocusRipple, handleAutoFocusBlur = _d.handleAutoFocusBlur;
|
|
13
16
|
var classes = (0, react_1.useMemo)(function () { return (0, foundation_1.combineProps)(utils_1.RcTabClasses, classesProp); }, [classesProp]);
|
|
14
|
-
|
|
17
|
+
var handleBlur = (0, foundation_1.useEventCallback)(function (event) {
|
|
18
|
+
handleAutoFocusBlur(event);
|
|
19
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
20
|
+
});
|
|
21
|
+
return (react_1.default.createElement(Tab_1.default, tslib_1.__assign({}, rest, { ref: tabRef, classes: classes, disabled: disabled, disableFocusRipple: suppressInitialFocusRipple ? true : disableFocusRippleProp, onBlur: handleBlur })));
|
|
15
22
|
});
|
|
16
23
|
var RcTab = (0, foundation_1.styled)(_RcTab)(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), styles_1.TabStyle);
|
|
17
24
|
exports.RcTab = RcTab;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __assign, __makeTemplateObject, __rest } from "tslib";
|
|
2
2
|
import React, { forwardRef, useCallback, useLayoutEffect, useMemo, useRef, } from 'react';
|
|
3
3
|
import MuiButton from '@material-ui/core/Button';
|
|
4
|
-
import { combineClasses, isRcElement, removeClassName, styled, useDeprecatedCheck, useForkRef, useTheme, useThemeProps, } from '../../../foundation';
|
|
4
|
+
import { combineClasses, isRcElement, removeClassName, styled, useDeprecatedCheck, useEventCallback, useForkRef, useSafeAutoFocus, useTheme, useThemeProps, } from '../../../foundation';
|
|
5
5
|
import { RcIcon } from '../../Icon';
|
|
6
6
|
import { RcIconSizes } from '../../Icon/utils';
|
|
7
7
|
import { RcCircularProgress } from '../../Progress';
|
|
@@ -20,10 +20,11 @@ var _RcButton = forwardRef(function (props, ref) {
|
|
|
20
20
|
},
|
|
21
21
|
]);
|
|
22
22
|
}
|
|
23
|
-
var childrenProp = props.children, classesProp = props.classes, startIconProp = props.startIcon, endIconProp = props.endIcon, loading = props.loading, loadingMode = props.loadingMode, disabled = props.disabled, IconProps = props.IconProps, size = props.size, color = props.color, CircularProgressProps = props.CircularProgressProps, variant = props.variant, disabledVariant = props.disabledVariant, radius = props.radius, keepElevation = props.keepElevation, focusVariant = props.focusVariant, disableFocusRippleProp = props.disableFocusRipple, rest = __rest(props, ["children", "classes", "startIcon", "endIcon", "loading", "loadingMode", "disabled", "IconProps", "size", "color", "CircularProgressProps", "variant", "disabledVariant", "radius", "keepElevation", "focusVariant", "disableFocusRipple"]);
|
|
23
|
+
var childrenProp = props.children, classesProp = props.classes, startIconProp = props.startIcon, endIconProp = props.endIcon, loading = props.loading, loadingMode = props.loadingMode, disabled = props.disabled, IconProps = props.IconProps, size = props.size, color = props.color, CircularProgressProps = props.CircularProgressProps, variant = props.variant, disabledVariant = props.disabledVariant, radius = props.radius, keepElevation = props.keepElevation, focusVariant = props.focusVariant, _c = props.autoFocus, autoFocus = _c === void 0 ? false : _c, disableFocusRippleProp = props.disableFocusRipple, onBlur = props.onBlur, rest = __rest(props, ["children", "classes", "startIcon", "endIcon", "loading", "loadingMode", "disabled", "IconProps", "size", "color", "CircularProgressProps", "variant", "disabledVariant", "radius", "keepElevation", "focusVariant", "autoFocus", "disableFocusRipple", "onBlur"]);
|
|
24
24
|
var theme = useTheme();
|
|
25
25
|
var innerRef = useRef(null);
|
|
26
26
|
var buttonRef = useForkRef(innerRef, ref);
|
|
27
|
+
var _d = useSafeAutoFocus(autoFocus && !(disabled || loading), innerRef), suppressInitialFocusRipple = _d.suppressInitialFocusRipple, handleAutoFocusBlur = _d.handleAutoFocusBlur;
|
|
27
28
|
var isPlain = variant === 'plain';
|
|
28
29
|
var isReplace = loadingMode === 'replace';
|
|
29
30
|
var iconSize = getButtonIconSize(size);
|
|
@@ -89,8 +90,14 @@ var _RcButton = forwardRef(function (props, ref) {
|
|
|
89
90
|
useLayoutEffect(function () {
|
|
90
91
|
removeClassName(innerRef, 'MuiButton-iconSizeMedium');
|
|
91
92
|
});
|
|
92
|
-
var disableFocusRipple =
|
|
93
|
-
|
|
93
|
+
var disableFocusRipple = suppressInitialFocusRipple
|
|
94
|
+
? true
|
|
95
|
+
: disableFocusRippleProp !== null && disableFocusRippleProp !== void 0 ? disableFocusRippleProp : focusVariant === 'focusRing';
|
|
96
|
+
var handleBlur = useEventCallback(function (event) {
|
|
97
|
+
handleAutoFocusBlur(event);
|
|
98
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
99
|
+
});
|
|
100
|
+
return (React.createElement(MuiButton, __assign({ ref: buttonRef, disabled: disabled || loading, variant: isPlain ? undefined : variant, disableRipple: ((_b = (_a = theme === null || theme === void 0 ? void 0 : theme.props) === null || _a === void 0 ? void 0 : _a.MuiButton) === null || _b === void 0 ? void 0 : _b.disableRipple) || isPlain, startIcon: startIcon, endIcon: endIcon, classes: classes, disableFocusRipple: disableFocusRipple, onBlur: handleBlur }, rest), loading && isReplace ? loadingElm : childrenProp));
|
|
94
101
|
});
|
|
95
102
|
export var RcButtonDefaultSize = 'large';
|
|
96
103
|
export var RcButtonDefaultColor = 'primary';
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import { __makeTemplateObject } from "tslib";
|
|
1
|
+
import { __assign, __makeTemplateObject, __rest } from "tslib";
|
|
2
|
+
import React, { forwardRef, useRef } from 'react';
|
|
2
3
|
import MuiButtonBase from '@material-ui/core/ButtonBase';
|
|
3
|
-
import { styled } from '../../../foundation';
|
|
4
|
+
import { styled, useEventCallback, useForkRef, useSafeAutoFocus, } from '../../../foundation';
|
|
4
5
|
/** @release */
|
|
5
|
-
var
|
|
6
|
+
var _RcButtonBase = forwardRef(function (props, ref) {
|
|
7
|
+
var _a = props.autoFocus, autoFocus = _a === void 0 ? false : _a, _b = props.disabled, disabled = _b === void 0 ? false : _b, focusRipple = props.focusRipple, onBlur = props.onBlur, rest = __rest(props, ["autoFocus", "disabled", "focusRipple", "onBlur"]);
|
|
8
|
+
var innerRef = useRef(null);
|
|
9
|
+
var buttonRef = useForkRef(ref, innerRef);
|
|
10
|
+
var _c = useSafeAutoFocus(autoFocus && !disabled, innerRef), suppressInitialFocusRipple = _c.suppressInitialFocusRipple, handleAutoFocusBlur = _c.handleAutoFocusBlur;
|
|
11
|
+
var handleBlur = useEventCallback(function (event) {
|
|
12
|
+
handleAutoFocusBlur(event);
|
|
13
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
14
|
+
});
|
|
15
|
+
return React.createElement(MuiButtonBase, __assign(__assign({}, rest), { ref: buttonRef, disabled: disabled, focusRipple: suppressInitialFocusRipple ? false : focusRipple, onBlur: handleBlur }));
|
|
16
|
+
});
|
|
17
|
+
var RcButtonBase = styled(_RcButtonBase)(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
|
|
6
18
|
RcButtonBase.displayName = 'RcButtonBase';
|
|
7
19
|
export { RcButtonBase };
|
|
8
20
|
var templateObject_1;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __assign, __makeTemplateObject, __rest } from "tslib";
|
|
2
|
-
import React, { forwardRef, memo, useMemo } from 'react';
|
|
2
|
+
import React, { forwardRef, memo, useMemo, useRef, } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { combineProps, styled, useDeprecatedCheck, useTheme, useThemeProps, combineClasses, } from '../../../foundation';
|
|
4
|
+
import { combineProps, styled, useDeprecatedCheck, useEventCallback, useForkRef, useSafeAutoFocus, useTheme, useThemeProps, combineClasses, } from '../../../foundation';
|
|
5
5
|
import { RcIcon } from '../../Icon';
|
|
6
6
|
import { RcTooltip, withTooltip } from '../../Tooltip';
|
|
7
7
|
import { RcButtonBase } from '../ButtonBase';
|
|
@@ -14,8 +14,11 @@ var _RcIconButton = memo(forwardRef(function (props, ref) {
|
|
|
14
14
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
15
15
|
useDeprecatedCheck(RcIconButton, props, rcIconButtonWarning);
|
|
16
16
|
}
|
|
17
|
-
var _b = props.buttonRef, buttonRef = _b === void 0 ? ref : _b, _c = props.IconProps, IconProps = _c === void 0 ? {} : _c, className = props.className, classesProp = props.classes, children = props.children, title = props.title, disabledFakeBorder = props.disabledFakeBorder, symbol = props.symbol, disabled = props.disabled, invisible = props.invisible, type = props.type, loading = props.loading, TouchRippleProps = props.TouchRippleProps, variant = props.variant, CircularProgressProps = props.CircularProgressProps, color = props.color, shouldPersistBg = props.shouldPersistBg, stretchIcon = props.stretchIcon, iconColor = props.iconColor, iconSize = props.iconSize, disableTouchRipple = props.disableTouchRipple, useColorWhenDisabled = props.useColorWhenDisabled, size = props.size, radius = props.radius, elevation = props.elevation, activeElevation = props.activeElevation, aRef = props.aRef, tooltipTitle = props.tooltipTitle, tooltipForceHide = props.tooltipForceHide, disableToolTip = props.disableToolTip, alwaysEnableTooltip = props.alwaysEnableTooltip, tooltipPlacement = props.tooltipPlacement, ariaLabel = props.ariaLabel, popperProps = props.popperProps, externalLink = props.externalLink, download = props.download, href = props.href, focusVariant = props.focusVariant, rest = __rest(props, ["buttonRef", "IconProps", "className", "classes", "children", "title", "disabledFakeBorder", "symbol", "disabled", "invisible", "type", "loading", "TouchRippleProps", "variant", "CircularProgressProps", "color", "shouldPersistBg", "stretchIcon", "iconColor", "iconSize", "disableTouchRipple", "useColorWhenDisabled", "size", "radius", "elevation", "activeElevation", "aRef", "tooltipTitle", "tooltipForceHide", "disableToolTip", "alwaysEnableTooltip", "tooltipPlacement", "ariaLabel", "popperProps", "externalLink", "download", "href", "focusVariant"]);
|
|
17
|
+
var _b = props.buttonRef, buttonRef = _b === void 0 ? ref : _b, _c = props.IconProps, IconProps = _c === void 0 ? {} : _c, className = props.className, classesProp = props.classes, children = props.children, title = props.title, disabledFakeBorder = props.disabledFakeBorder, symbol = props.symbol, disabled = props.disabled, invisible = props.invisible, type = props.type, loading = props.loading, TouchRippleProps = props.TouchRippleProps, variant = props.variant, CircularProgressProps = props.CircularProgressProps, color = props.color, shouldPersistBg = props.shouldPersistBg, stretchIcon = props.stretchIcon, iconColor = props.iconColor, iconSize = props.iconSize, disableTouchRipple = props.disableTouchRipple, useColorWhenDisabled = props.useColorWhenDisabled, _d = props.autoFocus, autoFocus = _d === void 0 ? false : _d, size = props.size, radius = props.radius, elevation = props.elevation, activeElevation = props.activeElevation, aRef = props.aRef, tooltipTitle = props.tooltipTitle, tooltipForceHide = props.tooltipForceHide, disableToolTip = props.disableToolTip, alwaysEnableTooltip = props.alwaysEnableTooltip, tooltipPlacement = props.tooltipPlacement, ariaLabel = props.ariaLabel, popperProps = props.popperProps, externalLink = props.externalLink, download = props.download, href = props.href, _e = props.focusRipple, focusRippleProp = _e === void 0 ? true : _e, focusVariant = props.focusVariant, onBlur = props.onBlur, rest = __rest(props, ["buttonRef", "IconProps", "className", "classes", "children", "title", "disabledFakeBorder", "symbol", "disabled", "invisible", "type", "loading", "TouchRippleProps", "variant", "CircularProgressProps", "color", "shouldPersistBg", "stretchIcon", "iconColor", "iconSize", "disableTouchRipple", "useColorWhenDisabled", "autoFocus", "size", "radius", "elevation", "activeElevation", "aRef", "tooltipTitle", "tooltipForceHide", "disableToolTip", "alwaysEnableTooltip", "tooltipPlacement", "ariaLabel", "popperProps", "externalLink", "download", "href", "focusRipple", "focusVariant", "onBlur"]);
|
|
18
18
|
var theme = useTheme();
|
|
19
|
+
var innerButtonRef = useRef(null);
|
|
20
|
+
var handleButtonRef = useForkRef(innerButtonRef, buttonRef);
|
|
21
|
+
var _f = useSafeAutoFocus(autoFocus && !disabled, innerButtonRef), suppressInitialFocusRipple = _f.suppressInitialFocusRipple, handleAutoFocusBlur = _f.handleAutoFocusBlur;
|
|
19
22
|
var isOutline = variant === 'outline';
|
|
20
23
|
var isContained = variant === 'contained';
|
|
21
24
|
var isInverse = variant === 'inverse';
|
|
@@ -30,13 +33,17 @@ var _RcIconButton = memo(forwardRef(function (props, ref) {
|
|
|
30
33
|
_a[classes.inverse] = isInverse,
|
|
31
34
|
_a[classes.round] = isRound,
|
|
32
35
|
_a));
|
|
36
|
+
var handleBlur = useEventCallback(function (event) {
|
|
37
|
+
handleAutoFocusBlur(event);
|
|
38
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
39
|
+
});
|
|
33
40
|
var iconButton = (function () {
|
|
34
41
|
var _a, _b;
|
|
35
42
|
// `color` already handle in StyledIconButton
|
|
36
43
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
37
44
|
var color = IconProps.color, IconPropsWithoutColor = __rest(IconProps, ["color"]);
|
|
38
45
|
var icon = React.isValidElement(children) || children === '' ? children : (React.createElement(RcIcon, __assign({ symbol: symbol, className: classes.icon, loading: loading, size: "inherit", CircularProgressProps: CircularProgressProps }, IconPropsWithoutColor), children));
|
|
39
|
-
var iconButton = (React.createElement(RcButtonBase, __assign({ ref:
|
|
46
|
+
var iconButton = (React.createElement(RcButtonBase, __assign({ ref: handleButtonRef, disableRipple: ((_b = (_a = theme.props) === null || _a === void 0 ? void 0 : _a.MuiButtonBase) === null || _b === void 0 ? void 0 : _b.disableRipple) || isPlain, type: type, disabled: disabled, "aria-label": ariaLabel || tooltipTitle || title, title: title, "aria-disabled": disabled, className: IconClassName, focusRipple: suppressInitialFocusRipple ? false : focusRippleProp, onBlur: handleBlur, TouchRippleProps: combineProps({
|
|
40
47
|
classes: RcIconButtonTouchRippleClasses,
|
|
41
48
|
}, TouchRippleProps) }, rest), icon));
|
|
42
49
|
if (download && href) {
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { __assign, __makeTemplateObject, __rest } from "tslib";
|
|
2
|
-
import React, { cloneElement, forwardRef, useMemo, } from 'react';
|
|
2
|
+
import React, { cloneElement, forwardRef, useMemo, useRef, } from 'react';
|
|
3
3
|
import MuiStepButton from '@material-ui/core/StepButton';
|
|
4
|
-
import { combineClasses, combineProps, isRcElement, styled, useThemeProps, } from '../../../foundation';
|
|
4
|
+
import { combineClasses, combineProps, isRcElement, styled, useEventCallback, useForkRef, useSafeAutoFocus, useThemeProps, } from '../../../foundation';
|
|
5
5
|
import { RcStepLabel } from '../StepLabel';
|
|
6
6
|
import { StepButtonStyle } from './styles';
|
|
7
7
|
import { RcStepButtonClasses } from './utils';
|
|
8
8
|
var _RcStepButton = forwardRef(function (inProps, ref) {
|
|
9
9
|
var props = useThemeProps({ props: inProps, name: 'RcStepButton' });
|
|
10
|
-
var classesProp = props.classes, childrenProp = props.children, icon = props.icon, optional = props.optional, error = props.error, StepLabelProps = props.StepLabelProps, editable = props.editable, rest = __rest(props, ["classes", "children", "icon", "optional", "error", "StepLabelProps", "editable"]);
|
|
10
|
+
var classesProp = props.classes, childrenProp = props.children, icon = props.icon, optional = props.optional, error = props.error, StepLabelProps = props.StepLabelProps, editable = props.editable, _a = props.autoFocus, autoFocus = _a === void 0 ? false : _a, _b = props.disabled, disabled = _b === void 0 ? false : _b, focusRipple = props.focusRipple, onBlur = props.onBlur, rest = __rest(props, ["classes", "children", "icon", "optional", "error", "StepLabelProps", "editable", "autoFocus", "disabled", "focusRipple", "onBlur"]);
|
|
11
|
+
var innerRef = useRef(null);
|
|
12
|
+
var handleRef = useForkRef(innerRef, ref);
|
|
13
|
+
var _c = useSafeAutoFocus(autoFocus && !disabled, innerRef), suppressInitialFocusRipple = _c.suppressInitialFocusRipple, handleAutoFocusBlur = _c.handleAutoFocusBlur;
|
|
11
14
|
var classes = useMemo(function () { return combineClasses(RcStepButtonClasses, classesProp); }, [classesProp]);
|
|
12
15
|
var children = useMemo(function () {
|
|
13
16
|
var childProps = combineProps({
|
|
@@ -18,7 +21,11 @@ var _RcStepButton = forwardRef(function (inProps, ref) {
|
|
|
18
21
|
}, StepLabelProps);
|
|
19
22
|
return isRcElement(childrenProp, ['RcStepLabel']) ? (cloneElement(childrenProp, childProps)) : (React.createElement(RcStepLabel, __assign({}, childProps), childrenProp));
|
|
20
23
|
}, [StepLabelProps, childrenProp, editable, error, icon, optional]);
|
|
21
|
-
|
|
24
|
+
var handleBlur = useEventCallback(function (event) {
|
|
25
|
+
handleAutoFocusBlur(event);
|
|
26
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
27
|
+
});
|
|
28
|
+
return (React.createElement(MuiStepButton, __assign({}, rest, { disabled: disabled, focusRipple: suppressInitialFocusRipple ? false : focusRipple, icon: icon, onBlur: handleBlur, optional: optional, ref: handleRef, classes: classes }), children));
|
|
22
29
|
});
|
|
23
30
|
var RcStepButton = styled(_RcStepButton)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), StepButtonStyle);
|
|
24
31
|
RcStepButton.defaultProps = {
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { __assign, __makeTemplateObject, __rest } from "tslib";
|
|
2
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
2
|
+
import React, { forwardRef, useMemo, useRef, } from 'react';
|
|
3
3
|
import MuiTab from '@material-ui/core/Tab';
|
|
4
|
-
import { combineProps, styled, useThemeProps, } from '../../../foundation';
|
|
4
|
+
import { combineProps, styled, useEventCallback, useForkRef, useSafeAutoFocus, useThemeProps, } from '../../../foundation';
|
|
5
5
|
import { TabStyle } from './styles';
|
|
6
6
|
import { RcTabClasses } from './utils';
|
|
7
7
|
var _RcTab = forwardRef(function (inProps, ref) {
|
|
8
8
|
var props = useThemeProps({ props: inProps, name: 'RcTab' });
|
|
9
|
-
var classesProp = props.classes, children = props.children, direction = props.direction, rest = __rest(props, ["classes", "children", "direction"]);
|
|
9
|
+
var classesProp = props.classes, children = props.children, direction = props.direction, _a = props.autoFocus, autoFocus = _a === void 0 ? false : _a, _b = props.disableFocusRipple, disableFocusRippleProp = _b === void 0 ? false : _b, _c = props.disabled, disabled = _c === void 0 ? false : _c, onBlur = props.onBlur, rest = __rest(props, ["classes", "children", "direction", "autoFocus", "disableFocusRipple", "disabled", "onBlur"]);
|
|
10
|
+
var innerRef = useRef(null);
|
|
11
|
+
var tabRef = useForkRef(ref, innerRef);
|
|
12
|
+
var _d = useSafeAutoFocus(autoFocus && !disabled, innerRef), suppressInitialFocusRipple = _d.suppressInitialFocusRipple, handleAutoFocusBlur = _d.handleAutoFocusBlur;
|
|
10
13
|
var classes = useMemo(function () { return combineProps(RcTabClasses, classesProp); }, [classesProp]);
|
|
11
|
-
|
|
14
|
+
var handleBlur = useEventCallback(function (event) {
|
|
15
|
+
handleAutoFocusBlur(event);
|
|
16
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
17
|
+
});
|
|
18
|
+
return (React.createElement(MuiTab, __assign({}, rest, { ref: tabRef, classes: classes, disabled: disabled, disableFocusRipple: suppressInitialFocusRipple ? true : disableFocusRippleProp, onBlur: handleBlur })));
|
|
12
19
|
});
|
|
13
20
|
var RcTab = styled(_RcTab)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), TabStyle);
|
|
14
21
|
RcTab.defaultProps = {
|
|
@@ -26,6 +26,7 @@ export * from './useResizeObserver';
|
|
|
26
26
|
export * from './useResponsiveMatch';
|
|
27
27
|
export * from './useResultRef';
|
|
28
28
|
export * from './useRetry';
|
|
29
|
+
export * from './useSafeAutoFocus';
|
|
29
30
|
export * from './useSleep';
|
|
30
31
|
export * from './useThrottle';
|
|
31
32
|
export * from './useTouchMouseEvent';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useSafeAutoFocus';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { __read } from "tslib";
|
|
2
|
+
import { useEffect, useLayoutEffect, useRef, useState, } from 'react';
|
|
3
|
+
import { useEventCallback } from '../useEventCallback';
|
|
4
|
+
var useEnhancedEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
|
|
5
|
+
var useSafeAutoFocus = function (autoFocus, targetRef) {
|
|
6
|
+
var _a = __read(useState(autoFocus), 2), suppressInitialFocusRipple = _a[0], setSuppressInitialFocusRipple = _a[1];
|
|
7
|
+
var autoFocusAppliedRef = useRef(false);
|
|
8
|
+
var suppressInitialFocusRippleRef = useRef(autoFocus);
|
|
9
|
+
useEnhancedEffect(function () {
|
|
10
|
+
var _a;
|
|
11
|
+
if (!autoFocus) {
|
|
12
|
+
autoFocusAppliedRef.current = false;
|
|
13
|
+
suppressInitialFocusRippleRef.current = false;
|
|
14
|
+
setSuppressInitialFocusRipple(false);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
suppressInitialFocusRippleRef.current = true;
|
|
18
|
+
setSuppressInitialFocusRipple(true);
|
|
19
|
+
if (!autoFocusAppliedRef.current) {
|
|
20
|
+
autoFocusAppliedRef.current = true;
|
|
21
|
+
(_a = targetRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
22
|
+
}
|
|
23
|
+
}, [autoFocus, targetRef]);
|
|
24
|
+
var handleAutoFocusBlur = useEventCallback(function () {
|
|
25
|
+
if (suppressInitialFocusRippleRef.current) {
|
|
26
|
+
suppressInitialFocusRippleRef.current = false;
|
|
27
|
+
setSuppressInitialFocusRipple(false);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
suppressInitialFocusRipple: suppressInitialFocusRipple,
|
|
32
|
+
handleAutoFocusBlur: handleAutoFocusBlur,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export { useSafeAutoFocus };
|
|
@@ -26,6 +26,7 @@ export * from './useResizeObserver';
|
|
|
26
26
|
export * from './useResponsiveMatch';
|
|
27
27
|
export * from './useResultRef';
|
|
28
28
|
export * from './useRetry';
|
|
29
|
+
export * from './useSafeAutoFocus';
|
|
29
30
|
export * from './useSleep';
|
|
30
31
|
export * from './useThrottle';
|
|
31
32
|
export * from './useTouchMouseEvent';
|
|
@@ -29,6 +29,7 @@ tslib_1.__exportStar(require("./useResizeObserver"), exports);
|
|
|
29
29
|
tslib_1.__exportStar(require("./useResponsiveMatch"), exports);
|
|
30
30
|
tslib_1.__exportStar(require("./useResultRef"), exports);
|
|
31
31
|
tslib_1.__exportStar(require("./useRetry"), exports);
|
|
32
|
+
tslib_1.__exportStar(require("./useSafeAutoFocus"), exports);
|
|
32
33
|
tslib_1.__exportStar(require("./useSleep"), exports);
|
|
33
34
|
tslib_1.__exportStar(require("./useThrottle"), exports);
|
|
34
35
|
tslib_1.__exportStar(require("./useTouchMouseEvent"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useSafeAutoFocus';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FocusEventHandler, RefObject } from 'react';
|
|
2
|
+
type UseSafeAutoFocusResult<T extends HTMLElement> = {
|
|
3
|
+
suppressInitialFocusRipple: boolean;
|
|
4
|
+
handleAutoFocusBlur: FocusEventHandler<T>;
|
|
5
|
+
};
|
|
6
|
+
declare const useSafeAutoFocus: <T extends HTMLElement>(autoFocus: boolean, targetRef: RefObject<T>) => UseSafeAutoFocusResult<T>;
|
|
7
|
+
export { useSafeAutoFocus };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSafeAutoFocus = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = require("react");
|
|
6
|
+
var useEventCallback_1 = require("../useEventCallback");
|
|
7
|
+
var useEnhancedEffect = typeof window === 'undefined' ? react_1.useEffect : react_1.useLayoutEffect;
|
|
8
|
+
var useSafeAutoFocus = function (autoFocus, targetRef) {
|
|
9
|
+
var _a = tslib_1.__read((0, react_1.useState)(autoFocus), 2), suppressInitialFocusRipple = _a[0], setSuppressInitialFocusRipple = _a[1];
|
|
10
|
+
var autoFocusAppliedRef = (0, react_1.useRef)(false);
|
|
11
|
+
var suppressInitialFocusRippleRef = (0, react_1.useRef)(autoFocus);
|
|
12
|
+
useEnhancedEffect(function () {
|
|
13
|
+
var _a;
|
|
14
|
+
if (!autoFocus) {
|
|
15
|
+
autoFocusAppliedRef.current = false;
|
|
16
|
+
suppressInitialFocusRippleRef.current = false;
|
|
17
|
+
setSuppressInitialFocusRipple(false);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
suppressInitialFocusRippleRef.current = true;
|
|
21
|
+
setSuppressInitialFocusRipple(true);
|
|
22
|
+
if (!autoFocusAppliedRef.current) {
|
|
23
|
+
autoFocusAppliedRef.current = true;
|
|
24
|
+
(_a = targetRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
25
|
+
}
|
|
26
|
+
}, [autoFocus, targetRef]);
|
|
27
|
+
var handleAutoFocusBlur = (0, useEventCallback_1.useEventCallback)(function () {
|
|
28
|
+
if (suppressInitialFocusRippleRef.current) {
|
|
29
|
+
suppressInitialFocusRippleRef.current = false;
|
|
30
|
+
setSuppressInitialFocusRipple(false);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
suppressInitialFocusRipple: suppressInitialFocusRipple,
|
|
35
|
+
handleAutoFocusBlur: handleAutoFocusBlur,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
exports.useSafeAutoFocus = useSafeAutoFocus;
|