@prisma-cms/front-editor
Version:
74 lines • 3.2 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 });
exports.TableRow = void 0;
const react_1 = __importDefault(require("react"));
const __1 = __importDefault(require(".."));
const TableCell_1 = __importDefault(require("../TableCell"));
const EditorComponent_1 = __importDefault(require("../../../EditorComponent"));
const ListView_1 = __importDefault(require("../../Connectors/Connector/ListView"));
const Iterable_1 = __importDefault(require("../../Connectors/Connector/ListView/Iterable"));
const EditableObject_1 = __importDefault(require("../../form/EditableObject"));
class TableRow extends EditorComponent_1.default {
renderPanelView(content) {
return super.renderPanelView(content || react_1.default.createElement("div", { className: "editor-component--panel-icon" }, "TableRow"));
}
// getRootElement() {
// return "tr";
// }
canBeParent(parent) {
return (parent instanceof __1.default ||
parent instanceof ListView_1.default ||
parent instanceof Iterable_1.default ||
parent instanceof EditableObject_1.default);
}
canBeChild(child) {
return child instanceof TableCell_1.default;
}
renderMainView() {
const { inEditMode } = this.getEditorContext();
let inEditModeProps;
if (inEditMode) {
const { style } = this.getComponentProps(this);
inEditModeProps = {
style: Object.assign(Object.assign({}, style), { width: '100%', flexBasis: '100%' }),
};
return super.renderMainView(inEditModeProps);
}
else {
return this.renderChildren();
}
}
renderChildren() {
const { inEditMode } = this.getEditorContext();
const _a = this.getComponentProps(this), {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
children } = _a, other = __rest(_a, ["children"]);
let inEditModeProps;
if (inEditMode) {
const { style } = this.getComponentProps(this);
inEditModeProps = {
style: Object.assign(Object.assign({}, style), { display: 'flex', width: '100%' }),
};
}
return (react_1.default.createElement("tr", Object.assign({ key: "tr" }, other, inEditModeProps), super.renderChildren()));
}
}
exports.TableRow = TableRow;
TableRow.Name = 'TableRow';
TableRow.defaultProps = Object.assign({}, EditorComponent_1.default.defaultProps);
exports.default = TableRow;
//# sourceMappingURL=index.js.map