@uifabric/experiments
Version:
Experimental React components for building experiences for Microsoft 365.
34 lines • 2.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var office_ui_fabric_react_1 = require("office-ui-fabric-react");
var Foundation_1 = require("../../../Foundation");
var Utilities_1 = require("../../../Utilities");
/* eslint-disable deprecation/deprecation */
/** @deprecated */
exports.ActionableSlots = function (props) { return ({
root: props.href ? 'a' : 'button',
}); };
/** @deprecated */
exports.ActionableView = function (props, slots) {
var 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, ["children", "disabled", "onClick", "allowDisabledFocus", "ariaLabel", "keytipProps", "buttonRef"]);
var _a = _deriveRootType(props), htmlType = _a.htmlType, propertiesType = _a.propertiesType;
// TODO: 'href' is anchor property... consider getNativeProps by root type
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 }), 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=Actionable.view.js.map