61 lines
2.3 KiB
JavaScript
61 lines
2.3 KiB
JavaScript
'use client';
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
function _export(target, all) {
|
|
for(var name in all)Object.defineProperty(target, name, {
|
|
enumerable: true,
|
|
get: all[name]
|
|
});
|
|
}
|
|
_export(exports, {
|
|
useButtonBase_unstable: function() {
|
|
return useButtonBase_unstable;
|
|
},
|
|
useButton_unstable: function() {
|
|
return useButton_unstable;
|
|
}
|
|
});
|
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
const _ButtonContext = require("../../contexts/ButtonContext");
|
|
const _reactaria = require("@fluentui/react-aria");
|
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
const useButton_unstable = (props, ref)=>{
|
|
const { size: contextSize } = (0, _ButtonContext.useButtonContext)();
|
|
const { appearance = 'secondary', shape = 'rounded', size = contextSize !== null && contextSize !== void 0 ? contextSize : 'medium', ...buttonProps } = props;
|
|
const state = useButtonBase_unstable(buttonProps, ref);
|
|
return {
|
|
appearance,
|
|
shape,
|
|
size,
|
|
...state
|
|
};
|
|
};
|
|
const useButtonBase_unstable = (props, ref)=>{
|
|
const { icon, iconPosition = 'before', ...buttonProps } = props;
|
|
const iconShorthand = _reactutilities.slot.optional(icon, {
|
|
elementType: 'span'
|
|
});
|
|
var _props_disabled, _props_disabledFocusable;
|
|
return {
|
|
disabled: (_props_disabled = props.disabled) !== null && _props_disabled !== void 0 ? _props_disabled : false,
|
|
disabledFocusable: (_props_disabledFocusable = props.disabledFocusable) !== null && _props_disabledFocusable !== void 0 ? _props_disabledFocusable : false,
|
|
iconPosition,
|
|
iconOnly: Boolean((iconShorthand === null || iconShorthand === void 0 ? void 0 : iconShorthand.children) && !props.children),
|
|
components: {
|
|
root: 'button',
|
|
icon: 'span'
|
|
},
|
|
root: _reactutilities.slot.always((0, _reactaria.useARIAButtonProps)(buttonProps.as, buttonProps), {
|
|
elementType: 'button',
|
|
defaultProps: {
|
|
ref: ref,
|
|
type: props.as !== 'a' ? 'button' : undefined
|
|
}
|
|
}),
|
|
icon: iconShorthand
|
|
};
|
|
};
|