@nestbotics/nct_frontend_common_components
Version:
A collection of reusable React components with theme management and styling utilities
74 lines (73 loc) • 3.58 kB
JavaScript
;
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _material = require("@mui/material");
var _jsxRuntime = require("react/jsx-runtime");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var SubContainer = function SubContainer(_ref) {
var title = _ref.title,
data = _ref.data;
var containerRef = (0, _react.useRef)(null);
var scrollToBottom = function scrollToBottom() {
if (containerRef.current) {
containerRef.current.scrollTop += 170;
console.log("Current height", containerRef.current.scrollHeight);
}
};
var scrollToTop = function scrollToTop() {
if (containerRef.current) {
containerRef.current.scrollTop = 0;
}
};
(0, _react.useEffect)(function () {
scrollToBottom();
});
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
className: "flex-1 justify-center p-4 ml-[3px] pl-0 pr-0 rounded overflow-hidden max-h-64 relative",
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
ref: containerRef,
className: "max-h-64 overflow-y-hidden relative",
style: {
overflowY: 'auto',
scrollbarWidth: 'none'
},
children: !data.length ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
variant: "h5",
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
className: "flex flex-col gap-5",
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
variant: "h5",
children: "Pick Pallet 1"
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
variant: "h5",
children: "Pick Pallet 1"
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
variant: "h5",
children: "Pick Pallet 1"
})]
})
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
children: data.map(function (item, index) {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
variant: "body1",
children: item
}, index);
})
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
onClick: scrollToBottom,
className: "absolute top-4 right-[27px] mb-2 mr-2 text-gray-700 rounded-full w-6 h-6 flex items-center justify-center rotate-[267deg] text-2xl font-bold",
children: ">"
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
onClick: scrollToTop,
className: "absolute top-10 right-[27px] mt-2 mr-2 text-gray-700 rounded-full w-6 h-6 flex items-center justify-center rotate-[267deg] text-2xl font-bold",
children: "<"
})]
});
};
var _default = exports.default = SubContainer;