UNPKG

@formant/ava-react

Version:

React components of AVA.

87 lines (85 loc) 3.8 kB
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/NarrativeTextVis/paragraph/index.tsx var paragraph_exports = {}; __export(paragraph_exports, { Headline: () => import_Headline.Headline, Paragraph: () => Paragraph }); module.exports = __toCommonJS(paragraph_exports); var import_react = __toESM(require("react")); var import_antd = require("antd"); var import_ava = require("@formant/ava"); var import_Heading = require("./Heading"); var import_TextLine = require("./TextLine"); var import_Bullets = require("./Bullets"); var import_Headline = require("./Headline"); function Paragraph({ spec, pluginManager, size = "normal", theme = "dark", palette, ...events }) { const themeStyles = { size, theme, palette }; const { onClickParagraph, onMouseEnterParagraph, onMouseLeaveParagraph, ...phraseEvents } = events || {}; const onClick = () => { onClickParagraph == null ? void 0 : onClickParagraph(spec); }; const onMouseEnter = () => { onMouseEnterParagraph == null ? void 0 : onMouseEnterParagraph(spec); }; const onMouseLeave = () => { onMouseLeaveParagraph == null ? void 0 : onMouseLeaveParagraph(spec); }; if ((0, import_ava.isDividerParagraph)(spec)) { return /* @__PURE__ */ import_react.default.createElement(import_antd.Divider, { style: spec.styles, className: spec.className }); } let content = null; if ((0, import_ava.isCustomParagraph)(spec)) { const descriptor = pluginManager.getBlockDescriptor(spec.customType); if (descriptor && (descriptor == null ? void 0 : descriptor.render)) content = descriptor.render(spec, themeStyles); } if ((0, import_ava.isHeadingParagraph)(spec)) { content = /* @__PURE__ */ import_react.default.createElement(import_Heading.Heading, { spec, pluginManager, ...themeStyles, ...phraseEvents }); } if ((0, import_ava.isTextParagraph)(spec)) { content = /* @__PURE__ */ import_react.default.createElement(import_TextLine.TextLine, { spec, pluginManager, ...themeStyles, ...phraseEvents }); } if ((0, import_ava.isBulletParagraph)(spec)) { content = /* @__PURE__ */ import_react.default.createElement(import_Bullets.Bullets, { spec, pluginManager, ...themeStyles, ...events }); } return content && /* @__PURE__ */ import_react.default.createElement("div", { onClick, onMouseEnter, onMouseLeave }, content); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Headline, Paragraph });