@wordpress/components
Version:
UI components for WordPress.
87 lines (86 loc) • 4.4 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
// \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
let _wordpress_element = require("@wordpress/element");
let clsx = require("clsx");
clsx = __toESM(clsx);
let re_resizable = require("re-resizable");
let __resize_tooltip_index_tsx = require("./resize-tooltip/index.cjs");
__resize_tooltip_index_tsx = __toESM(__resize_tooltip_index_tsx);
let react_jsx_runtime = require("react/jsx-runtime");
// packages/components/src/resizable-box/index.tsx
const HANDLE_CLASS_NAME = "components-resizable-box__handle";
const SIDE_HANDLE_CLASS_NAME = "components-resizable-box__side-handle";
const CORNER_HANDLE_CLASS_NAME = "components-resizable-box__corner-handle";
const HANDLE_CLASSES = {
top: (0, clsx.default)(HANDLE_CLASS_NAME, SIDE_HANDLE_CLASS_NAME, "components-resizable-box__handle-top"),
right: (0, clsx.default)(HANDLE_CLASS_NAME, SIDE_HANDLE_CLASS_NAME, "components-resizable-box__handle-right"),
bottom: (0, clsx.default)(HANDLE_CLASS_NAME, SIDE_HANDLE_CLASS_NAME, "components-resizable-box__handle-bottom"),
left: (0, clsx.default)(HANDLE_CLASS_NAME, SIDE_HANDLE_CLASS_NAME, "components-resizable-box__handle-left"),
topLeft: (0, clsx.default)(HANDLE_CLASS_NAME, CORNER_HANDLE_CLASS_NAME, "components-resizable-box__handle-top", "components-resizable-box__handle-left"),
topRight: (0, clsx.default)(HANDLE_CLASS_NAME, CORNER_HANDLE_CLASS_NAME, "components-resizable-box__handle-top", "components-resizable-box__handle-right"),
bottomRight: (0, clsx.default)(HANDLE_CLASS_NAME, CORNER_HANDLE_CLASS_NAME, "components-resizable-box__handle-bottom", "components-resizable-box__handle-right"),
bottomLeft: (0, clsx.default)(HANDLE_CLASS_NAME, CORNER_HANDLE_CLASS_NAME, "components-resizable-box__handle-bottom", "components-resizable-box__handle-left")
};
const HANDLE_STYLES_OVERRIDES = {
width: void 0,
height: void 0,
top: void 0,
right: void 0,
bottom: void 0,
left: void 0,
zIndex: void 0
};
const HANDLE_STYLES = {
top: HANDLE_STYLES_OVERRIDES,
right: HANDLE_STYLES_OVERRIDES,
bottom: HANDLE_STYLES_OVERRIDES,
left: HANDLE_STYLES_OVERRIDES,
topLeft: HANDLE_STYLES_OVERRIDES,
topRight: HANDLE_STYLES_OVERRIDES,
bottomRight: HANDLE_STYLES_OVERRIDES,
bottomLeft: HANDLE_STYLES_OVERRIDES
};
function UnforwardedResizableBox({ className, children, showHandle = true, __experimentalShowTooltip: showTooltip = false, __experimentalTooltipProps: tooltipProps = {}, ...props }, ref) {
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(re_resizable.Resizable, {
className: (0, clsx.default)("components-resizable-box__container", showHandle && "has-show-handle", className),
handleComponent: Object.fromEntries(Object.keys(HANDLE_CLASSES).map((key) => [key, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { tabIndex: -1 }, key)])),
handleClasses: HANDLE_CLASSES,
handleStyles: HANDLE_STYLES,
ref,
...props,
children: [children, showTooltip && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__resize_tooltip_index_tsx.default, { ...tooltipProps })]
});
}
/**
* `ResizableBox` wraps content in a container with draggable handles, letting
* users interactively resize it along one or more edges or corners.
*/
const ResizableBox = (0, _wordpress_element.forwardRef)(UnforwardedResizableBox);
ResizableBox.displayName = "ResizableBox";
exports.ResizableBox = ResizableBox;
exports.default = ResizableBox;
//# sourceMappingURL=index.cjs.map