@uifabric/experiments
Version:
Experimental React components for building experiences for Microsoft 365.
32 lines • 2.06 kB
JavaScript
import { __assign, __rest } from "tslib";
import { KeytipData } from 'office-ui-fabric-react';
import { withSlots } from '../../../Foundation';
import { getNativeProps, anchorProperties, buttonProperties } from '../../../Utilities';
/* eslint-disable deprecation/deprecation */
/** @deprecated */
export var ActionableSlots = function (props) { return ({
root: props.href ? 'a' : 'button',
}); };
/** @deprecated */
export var 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 = __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 = __assign({}, getNativeProps(rest, propertiesType));
var _onClick = function (ev) {
if (!disabled && onClick) {
onClick(ev);
if (ev.defaultPrevented) {
return;
}
}
};
var Button = function (keytipAttributes) { return (withSlots(slots.root, __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 ? (withSlots(KeytipData, { keytipProps: keytipProps, disabled: disabled && !allowDisabledFocus }, function (keytipAttributes) { return Button(keytipAttributes); })) : (Button());
};
function _deriveRootType(props) {
return props.href
? { htmlType: 'link', propertiesType: anchorProperties }
: { htmlType: 'button', propertiesType: buttonProperties };
}
//# sourceMappingURL=Actionable.view.js.map