@nestbotics/nct_frontend_common_components
Version:
A collection of reusable React components with theme management and styling utilities
60 lines • 2.51 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["label", "adornment"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import React from 'react';
import { TextField, InputAdornment, styled } from '@mui/material';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var Label = styled('label')(function (_ref) {
var theme = _ref.theme;
return {
display: 'block',
fontSize: '0.875rem',
fontWeight: 600,
marginBottom: '4px',
color: theme.palette.text.primary
};
});
var CustomTextField = function CustomTextField(_ref2) {
var label = _ref2.label,
adornment = _ref2.adornment,
props = _objectWithoutProperties(_ref2, _excluded);
return /*#__PURE__*/_jsxs("div", {
children: [/*#__PURE__*/_jsx(Label, {
children: label
}), /*#__PURE__*/_jsx(TextField, _objectSpread(_objectSpread({
variant: "outlined",
fullWidth: true
}, props), {}, {
sx: {
'& .MuiInputBase-input': {
padding: '13px 12px',
fontSize: '0.875rem'
},
'& .MuiInputAdornment-root': {
// Adjust alignment of the adornment if necessary
height: '100%',
display: 'flex',
alignItems: 'center'
}
},
InputProps: {
startAdornment: adornment && /*#__PURE__*/_jsx(InputAdornment, {
position: "start",
children: /*#__PURE__*/_jsx("span", {
style: {
fontSize: '0.875rem',
marginRight: '4px'
},
children: adornment
})
})
},
InputLabelProps: {
shrink: false // Ensures the label is not inside the input field
}
}))]
});
};
export default CustomTextField;