@react-awesome-query-builder-dev/ui
Version:
User-friendly query builder for React. Core React UI
59 lines • 2.09 kB
JavaScript
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["children"];
import React from "react";
var Col = function Col(_ref) {
var children = _ref.children,
props = _objectWithoutProperties(_ref, _excluded);
return /*#__PURE__*/React.createElement("div", props, children);
};
var dummyFn = function dummyFn() {};
var DragIcon = function DragIcon() {
return /*#__PURE__*/React.createElement("svg", {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24",
fill: "gray",
width: "18px",
height: "18px"
}, /*#__PURE__*/React.createElement("path", {
d: "M0 0h24v24H0V0z",
fill: "none"
}), /*#__PURE__*/React.createElement("path", {
d: "M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"
}));
};
var WithConfirmFn = function WithConfirmFn(Cmp) {
return function (props) {
var useConfirm = props.config.settings.useConfirm;
var confirmFn = useConfirm ? useConfirm.call(props.config.ctx, props.config.ctx) : null;
return /*#__PURE__*/React.createElement(Cmp, _extends({}, props, {
confirmFn: confirmFn
}));
};
};
var getWidgetId = function getWidgetId(_ref2) {
var id = _ref2.id,
isLHS = _ref2.isLHS,
delta = _ref2.delta,
parentFuncs = _ref2.parentFuncs;
return [id, isLHS ? "L" : "R", isLHS ? -1 : delta || 0, (parentFuncs || []).map(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
f = _ref4[0],
a = _ref4[1];
return "".concat(f, "(").concat(a, ")");
}).join("/")].join(":");
};
var getRenderFromConfig = function getRenderFromConfig(config, renderFn) {
var Cmp;
if (typeof renderFn === "function") {
Cmp = function Cmp(pr) {
return renderFn === null || renderFn === void 0 ? void 0 : renderFn(pr, config.ctx);
};
Cmp.displayName = renderFn.name;
} else {
Cmp = renderFn;
}
return Cmp;
};
export { Col, dummyFn, DragIcon, WithConfirmFn, getWidgetId, getRenderFromConfig };