UNPKG

@itwin/itwinui-react

Version:

A react component library for iTwinUI

103 lines (102 loc) 2.84 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true, }); Object.defineProperty(exports, 'Button', { enumerable: true, get: function () { return Button; }, }); const _interop_require_default = require('@swc/helpers/_/_interop_require_default'); const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard'); const _classnames = /*#__PURE__*/ _interop_require_default._( require('classnames'), ); const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react')); const _index = require('../../utils/index.js'); const _ProgressRadial = require('../ProgressIndicators/ProgressRadial.js'); const _Popover = require('../Popover/Popover.js'); const Button = _react.forwardRef((props, ref) => { let { children, className, size, styleType = 'default', startIcon, endIcon, labelProps, startIconProps, endIconProps, stretched, loading: loading, disabled: disabledProp, ...rest } = props; let hasPopoverOpen = _react.useContext(_Popover.PopoverOpenContext); return _react.createElement( _index.ButtonBase, { ref: ref, className: (0, _classnames.default)('iui-button', 'iui-field', className), 'data-iui-variant': 'default' !== styleType ? styleType : void 0, 'data-iui-size': size, 'data-iui-loading': loading ? 'true' : void 0, 'data-iui-has-popover': hasPopoverOpen ? 'open' : void 0, disabled: disabledProp || loading, ...rest, style: { '--_iui-width': stretched ? '100%' : void 0, ...props.style, }, }, startIcon && _react.createElement( _index.Box, { as: 'span', 'aria-hidden': true, ...startIconProps, className: (0, _classnames.default)( 'iui-button-icon', startIconProps?.className, ), }, startIcon, ), children && _react.createElement( _index.Box, { as: 'span', ...labelProps, className: (0, _classnames.default)( 'iui-button-label', labelProps?.className, ), }, children, ), endIcon && _react.createElement( _index.Box, { as: 'span', 'aria-hidden': true, ...endIconProps, className: (0, _classnames.default)( 'iui-button-icon', endIconProps?.className, ), }, endIcon, ), loading && _react.createElement(_ProgressRadial.ProgressRadial, { size: 'small' === size ? 'x-small' : 'small', className: 'iui-button-spinner', 'aria-hidden': true, }), ); }); if ('development' === process.env.NODE_ENV) Button.displayName = 'Button';