UNPKG

opendash

Version:

open.DASH data visualization framework

78 lines 7.1 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; import * as React from "react"; import { useTranslation, DataSelect, DataItemHistoryOptionsPicker, } from ".."; import { Steps, Tabs, Divider } from "antd"; import { Container, StepNav, SettingsHolder, Description, } from "./WidgetSettingsRenderWithSteps.layout"; export var WidgetSettingsRenderWithSteps = React.memo(function WidgetSettingsRenderWithSteps(_a) { var context = _a.context, baseContext = _a.baseContext; var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y; var t = useTranslation(["opendash"])[0]; var _z = React.useState(0), step = _z[0], setStep = _z[1]; var SettingsComponent = React.useMemo(function () { var _a, _b; return ((_b = (_a = baseContext) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.settingsComponent) ? React.lazy(baseContext.type.settingsComponent) : null; }, [(_c = (_b = baseContext) === null || _b === void 0 ? void 0 : _b.type) === null || _c === void 0 ? void 0 : _c.settingsComponent]); return (React.createElement(Container, null, React.createElement(StepNav, null, React.createElement(Steps, { current: step, onChange: setStep }, React.createElement(Steps.Step, { disabled: !((_e = (_d = baseContext) === null || _d === void 0 ? void 0 : _d.type) === null || _e === void 0 ? void 0 : _e.dataItems), title: t("monitoring.widgets.settings.step_0_title"), subTitle: t("monitoring.widgets.settings.step_0_subtitle", { count: Math.max((_f = context.draft._sources) === null || _f === void 0 ? void 0 : _f.length, (_g = context.draft._items) === null || _g === void 0 ? void 0 : _g.length, (_h = context.draft._dimensions) === null || _h === void 0 ? void 0 : _h.length), }) }), React.createElement(Steps.Step, { disabled: !((_k = (_j = baseContext) === null || _j === void 0 ? void 0 : _j.type) === null || _k === void 0 ? void 0 : _k.dataHistory), title: t("monitoring.widgets.settings.step_1_title"), subTitle: t("monitoring.widgets.settings.step_1_subtitle") }), React.createElement(Steps.Step, { disabled: !SettingsComponent, title: t("monitoring.widgets.settings.step_2_title"), subTitle: !SettingsComponent ? t("monitoring.widgets.settings.step_2_no_settings") : t("monitoring.widgets.settings.step_2_subtitle") }))), React.createElement(Divider, null), React.createElement(SettingsHolder, null, React.createElement(Tabs, { activeKey: step.toString(), renderTabBar: function () { return React.createElement(React.Fragment, null); } }, React.createElement(Tabs.TabPane, { tab: t("monitoring.widgets.settings.step_0_title"), key: "0" }, React.createElement(Description, { children: t("monitoring.widgets.settings.step_0_description") }), React.createElement(DataSelect, { selectionOptions: (_m = (_l = baseContext) === null || _l === void 0 ? void 0 : _l.type) === null || _m === void 0 ? void 0 : _m.dataItems, selection: ((_q = (_p = (_o = baseContext) === null || _o === void 0 ? void 0 : _o.type) === null || _p === void 0 ? void 0 : _p.dataItems) === null || _q === void 0 ? void 0 : _q.select) === "source" ? context.draft._sources : ((_t = (_s = (_r = baseContext) === null || _r === void 0 ? void 0 : _r.type) === null || _s === void 0 ? void 0 : _s.dataItems) === null || _t === void 0 ? void 0 : _t.select) === "item" ? context.draft._items : ((_w = (_v = (_u = baseContext) === null || _u === void 0 ? void 0 : _u.type) === null || _v === void 0 ? void 0 : _v.dataItems) === null || _w === void 0 ? void 0 : _w.select) === "dimension" ? context.draft._dimensions : [], onSelection: function (nextValue) { context.updateDraft(function (draft) { var _a, _b, _c, _d, _e, _f, _g, _h, _j; if (((_c = (_b = (_a = baseContext) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.dataItems) === null || _c === void 0 ? void 0 : _c.select) === "source") { draft._sources = nextValue; draft._items = []; draft._dimensions = []; } if (((_f = (_e = (_d = baseContext) === null || _d === void 0 ? void 0 : _d.type) === null || _e === void 0 ? void 0 : _e.dataItems) === null || _f === void 0 ? void 0 : _f.select) === "item") { draft._sources = []; draft._items = nextValue; draft._dimensions = []; } if (((_j = (_h = (_g = baseContext) === null || _g === void 0 ? void 0 : _g.type) === null || _h === void 0 ? void 0 : _h.dataItems) === null || _j === void 0 ? void 0 : _j.select) === "dimension") { draft._sources = []; draft._items = []; draft._dimensions = nextValue; } }); } })), React.createElement(Tabs.TabPane, { tab: t("monitoring.widgets.settings.step_1_title"), key: "1" }, React.createElement(Description, { children: t("monitoring.widgets.settings.step_1_description") }), React.createElement(DataItemHistoryOptionsPicker, { options: (_y = (_x = baseContext) === null || _x === void 0 ? void 0 : _x.type) === null || _y === void 0 ? void 0 : _y.dataHistory, value: context.draft._history, onChange: function (nextValue) { context.updateDraft(function (draft) { draft._history = nextValue; }); } })), React.createElement(Tabs.TabPane, { tab: t("monitoring.widgets.settings.step_2_title"), key: "2" }, React.createElement(Description, { children: t("monitoring.widgets.settings.step_2_description") }), React.createElement(SettingsComponent, __assign({}, context))))))); }); //# sourceMappingURL=WidgetSettingsRenderWithSteps.js.map