@code-editor/preview-pip
Version:
A Resizable Picture-in-Picture component.
34 lines (32 loc) • 1.7 kB
JavaScript
;
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const PIP_1 = __importDefault(require("./PIP"));
const react_resizable_1 = require("react-resizable");
const styled_1 = __importDefault(require("@emotion/styled"));
function ResizablePIP(_a) {
var { children, axis = "both", resizeHandle, width = 500, height = 500, minConstraints = [300, 300], maxConstraints = [800, 800] } = _a, otherResizableProps = __rest(_a, ["children", "axis", "resizeHandle", "width", "height", "minConstraints", "maxConstraints"]);
return (react_1.default.createElement(PIP_1.default, null,
react_1.default.createElement(StyledResizableBox, Object.assign({}, otherResizableProps, { axis: axis, handle: resizeHandle, width: width, height: height, minConstraints: minConstraints, maxConstraints: maxConstraints }), children)));
}
const StyledResizableBox = (0, styled_1.default)(react_resizable_1.ResizableBox) `
overflow: auto;
:hover {
cursor: default;
}
`;
exports.default = ResizablePIP;