@uifabric/experiments
Version:
Experimental React components for building experiences for Microsoft 365.
36 lines • 2.59 kB
JavaScript
define(["require", "exports", "tslib", "office-ui-fabric-react", "../../Foundation", "../../Utilities", "../../utilities/factoryComponents"], function (require, exports, tslib_1, office_ui_fabric_react_1, Foundation_1, Utilities_1, factoryComponents_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable deprecation/deprecation */
/** @deprecated */
exports.ButtonSlots = function (props) { return ({
root: props.href ? 'a' : 'button',
icon: factoryComponents_1.FontIcon,
content: office_ui_fabric_react_1.Text,
}); };
/** @deprecated */
exports.ButtonView = function (props, slots) {
var icon = props.icon, content = props.content, children = props.children, disabled = props.disabled, onClick = props.onClick, allowDisabledFocus = props.allowDisabledFocus, ariaLabel = props.ariaLabel, keytipProps = props.keytipProps, buttonRef = props.buttonRef, rest = tslib_1.__rest(props, ["icon", "content", "children", "disabled", "onClick", "allowDisabledFocus", "ariaLabel", "keytipProps", "buttonRef"]);
var _a = _deriveRootType(props), htmlType = _a.htmlType, propertiesType = _a.propertiesType;
var buttonProps = tslib_1.__assign({}, Utilities_1.getNativeProps(rest, propertiesType));
var _onClick = function (ev) {
if (!disabled && onClick) {
onClick(ev);
if (ev.defaultPrevented) {
return;
}
}
};
var Button = function (keytipAttributes) { return (Foundation_1.withSlots(slots.root, tslib_1.__assign({ type: htmlType, role: "button", onClick: _onClick }, buttonProps, keytipAttributes, { disabled: disabled && !allowDisabledFocus, "aria-disabled": disabled, tabIndex: !disabled || allowDisabledFocus ? 0 : undefined, "aria-label": ariaLabel, ref: buttonRef }),
icon && Foundation_1.withSlots(slots.icon, null),
content && Foundation_1.withSlots(slots.content, null),
children)); };
return keytipProps ? (Foundation_1.withSlots(office_ui_fabric_react_1.KeytipData, { keytipProps: keytipProps, disabled: disabled && !allowDisabledFocus }, function (keytipAttributes) { return Button(keytipAttributes); })) : (Button());
};
function _deriveRootType(props) {
return props.href
? { htmlType: 'link', propertiesType: Utilities_1.anchorProperties }
: { htmlType: 'button', propertiesType: Utilities_1.buttonProperties };
}
});
//# sourceMappingURL=Button.view.js.map