@itwin/itwinui-react
Version:
A react component library for iTwinUI
83 lines (82 loc) • 2.71 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', {
value: true,
});
Object.defineProperty(exports, 'InputWithDecorations', {
enumerable: true,
get: function () {
return InputWithDecorations;
},
});
const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard');
const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react'));
const _index = require('../../utils/index.js');
const InputWithDecorationsContext = _react.createContext(void 0);
if ('development' === process.env.NODE_ENV)
InputWithDecorationsContext.displayName = 'InputWithDecorationsContext';
const InputWithDecorationsComponent = _react.forwardRef((props, ref) => {
let { children, size, isDisabled, ...rest } = props;
return _react.createElement(
InputWithDecorationsContext.Provider,
{
value: {
size,
isDisabled,
},
},
_react.createElement(
_index.InputFlexContainer,
{
isDisabled: isDisabled,
size: size,
ref: ref,
...rest,
},
children,
),
);
});
if ('development' === process.env.NODE_ENV)
InputWithDecorationsComponent.displayName = 'InputWithDecorations';
const InputWithDecorationsInput = _react.forwardRef((props, ref) => {
let { id: idProp, size, disabled: localDisabled, ...rest } = props;
let { size: contextSize, isDisabled } = (0, _index.useSafeContext)(
InputWithDecorationsContext,
);
return _react.createElement(_index.Box, {
as: 'input',
ref: ref,
'data-iui-size': size ?? contextSize,
disabled: localDisabled ?? isDisabled,
id: idProp,
...rest,
});
});
if ('development' === process.env.NODE_ENV)
InputWithDecorationsInput.displayName = 'InputWithDecorations.Input';
const InputWithDecorationsButton = _react.forwardRef((props, ref) => {
let { children, size, disabled: localDisabled, ...rest } = props;
let { size: contextSize, isDisabled } = (0, _index.useSafeContext)(
InputWithDecorationsContext,
);
return _react.createElement(
_index.InputFlexContainerButton,
{
ref: ref,
size: size ?? contextSize,
disabled: localDisabled ?? isDisabled,
...rest,
},
children,
);
});
if ('development' === process.env.NODE_ENV)
InputWithDecorationsButton.displayName = 'InputWithDecorations.Button';
const InputWithDecorationsIcon = _index.InputFlexContainerIcon;
if ('development' === process.env.NODE_ENV)
InputWithDecorationsIcon.displayName = 'InputWithDecorations.Icon';
const InputWithDecorations = Object.assign(InputWithDecorationsComponent, {
Input: InputWithDecorationsInput,
Button: InputWithDecorationsButton,
Icon: InputWithDecorationsIcon,
});