UNPKG

@prisma-cms/front-editor

Version:
93 lines 4.33 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; 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.Tabs = void 0; const react_1 = __importDefault(require("react")); const Tab_1 = __importDefault(require("./Tab")); const EditorComponent_1 = __importDefault(require("../../EditorComponent")); const Tabs_1 = __importStar(require("material-ui/Tabs")); class Tabs extends EditorComponent_1.default { constructor(props) { super(props); this.onTabChange = (item, tabIndex) => { this.setState({ tabIndex, }); }; this.state = Object.assign(Object.assign({}, this.state), { tabIndex: 0 }); } renderPanelView() { return super.renderPanelView(react_1.default.createElement("div", { className: "editor-component--panel-icon" }, "Tabs")); } getRootElement() { return super.getRootElement(); } canBeParent(parent) { return super.canBeParent(parent); } canBeChild(child) { return child instanceof Tab_1.default; } renderChildren() { const _a = this.getComponentProps(this), { centered, fullWidth, indicatorColor, scrollable, scrollButtons, textColor, // eslint-disable-next-line @typescript-eslint/no-unused-vars hide_wrapper_in_default_mode } = _a, other = __rest(_a, ["centered", "fullWidth", "indicatorColor", "scrollable", "scrollButtons", "textColor", "hide_wrapper_in_default_mode"]); const { tabIndex } = this.state; const { components } = this.getObjectWithMutations(); const tabs = []; let content = null; if (components && components.length) { components.map((n, index) => { if (!n) { return null; } const { props: { label }, } = n; tabs.push(react_1.default.createElement(Tabs_1.Tab, { key: index, label: label || '' })); if (index === tabIndex) { content = this.renderComponent(n, index); } return null; }); } return (react_1.default.createElement("div", Object.assign({ key: "tabs" }, other), react_1.default.createElement(Tabs_1.default, { centered: centered, fullWidth: fullWidth, indicatorColor: indicatorColor, scrollable: scrollable, scrollButtons: scrollButtons, textColor: textColor, value: tabIndex, onChange: this.onTabChange }, tabs), content)); } } exports.Tabs = Tabs; Tabs.Name = 'Tabs'; Tabs.defaultProps = Object.assign(Object.assign({}, EditorComponent_1.default.defaultProps), { centered: false, fullWidth: false, indicatorColor: 'secondary', scrollable: false, scrollButtons: 'auto', textColor: 'inherit', hide_wrapper_in_default_mode: true }); exports.default = Tabs; //# sourceMappingURL=index.js.map