@formant/ava-react
Version:
React components of AVA.
76 lines (74 loc) • 3.35 kB
JavaScript
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 __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/InsightCard/ntvPlugins/components/ChartCarousel.tsx
var ChartCarousel_exports = {};
__export(ChartCarousel_exports, {
ChartCarousel: () => ChartCarousel
});
module.exports = __toCommonJS(ChartCarousel_exports);
var import_react = __toESM(require("react"));
var import_constants = require("../../constants");
var import_G2Chart = require("./G2Chart");
var ChartCarousel = ({
charts,
height = import_constants.CHART_HEIGHT,
width
}) => {
const [selectedChartIndex, setSelectedCardIndex] = (0, import_react.useState)(0);
const onSelect = (value) => {
setSelectedCardIndex(value);
};
const chartsOptions = charts.map((chart, index) => {
return {
label: /* @__PURE__ */ import_react.default.createElement(
"span",
{
style: {
border: index === selectedChartIndex ? "1px solid rgba(0,0,0,0.1)" : "1px solid rgba(0,0,0,0.15)",
borderRadius: "2px",
display: "inline-block",
width: index === selectedChartIndex ? "8px" : "12px",
height: "8px",
backgroundColor: index === selectedChartIndex ? "rgba(0,0,0,0.15)" : "#fff",
cursor: "pointer",
margin: "2px"
},
onClick: () => {
onSelect(index);
}
}
),
value: index
};
});
return /* @__PURE__ */ import_react.default.createElement("div", { className: `${import_constants.INSIGHT_CARD_PREFIX_CLS}-chart-carousel` }, /* @__PURE__ */ import_react.default.createElement(import_G2Chart.G2Chart, { spec: charts[selectedChartIndex], height, width }), chartsOptions.length > 1 && /* @__PURE__ */ import_react.default.createElement("div", { style: { textAlign: "center" } }, chartsOptions.map((option) => /* @__PURE__ */ import_react.default.createElement("span", { key: option.value }, option.label))));
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ChartCarousel
});