@macolmenerori/component-library 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ "use strict";const n=require("react/jsx-runtime"),h=require("react"),j=require("react-markdown"),l=require("remark-gfm"),x=({content:d,className:c,components:e,linkTarget:r,responsiveImages:o,rehypePlugins:u})=>{const a=h.useMemo(()=>{const s={};return r&&!e?.a&&(s.a=({children:i,...t})=>n.jsx("a",{...t,target:r,rel:r==="_blank"?"noreferrer":void 0,children:i})),o&&!e?.img&&(s.img=({alt:i,...t})=>n.jsx("img",{alt:i??"",...t,style:{maxWidth:"100%",height:"auto",...t.style}})),{...s,...e}},[e,r,o]),m=Object.keys(a).length>0;return n.jsx("div",{className:c,children:n.jsx(j,{remarkPlugins:[l],rehypePlugins:u,components:m?a:void 0,children:d})})};exports.MarkdownRender=x;
2
+ //# sourceMappingURL=MarkdownRender-BOGosy9w.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownRender-BOGosy9w.cjs","sources":["../src/components/MarkdownRender/MarkdownRender.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport ReactMarkdown, { type Components, type Options } from 'react-markdown';\n\nimport remarkGfm from 'remark-gfm';\n\nexport interface MarkdownProps {\n /** The markdown string to render */\n content: string;\n /** Optional CSS class name for the container */\n className?: string;\n /** Custom component overrides for markdown elements */\n components?: Partial<Components>;\n /** Target for all links (defaults to '_self') */\n linkTarget?: '_blank' | '_self' | '_parent' | '_top';\n /** Make all images responsive (defaults to false) */\n responsiveImages?: boolean;\n /** Optional rehype plugins for HTML processing */\n rehypePlugins?: Options['rehypePlugins'];\n}\n\n/**\n * A component that renders a markdown string as HTML.\n * Supports GitHub Flavored Markdown (GFM) including tables,\n * strikethrough, task lists, and autolinks.\n */\nconst MarkdownRender: React.FC<MarkdownProps> = ({\n content,\n className,\n components,\n linkTarget,\n responsiveImages,\n rehypePlugins\n}) => {\n const mergedComponents = useMemo(() => {\n const generated: Partial<Components> = {};\n\n // Auto-generate link component if linkTarget is set and no custom 'a' provided\n if (linkTarget && !components?.a) {\n generated.a = ({ children, ...props }) => (\n <a {...props} target={linkTarget} rel={linkTarget === '_blank' ? 'noreferrer' : undefined}>\n {children}\n </a>\n );\n }\n\n // Auto-generate image component if responsiveImages and no custom 'img' provided\n if (responsiveImages && !components?.img) {\n generated.img = ({ alt, ...props }) => (\n <img\n alt={alt ?? ''}\n {...props}\n style={{ maxWidth: '100%', height: 'auto', ...props.style }}\n />\n );\n }\n\n // User-provided components override auto-generated ones\n return { ...generated, ...components };\n }, [components, linkTarget, responsiveImages]);\n\n const hasComponents = Object.keys(mergedComponents).length > 0;\n\n return (\n <div className={className}>\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n rehypePlugins={rehypePlugins}\n components={hasComponents ? mergedComponents : undefined}\n >\n {content}\n </ReactMarkdown>\n </div>\n );\n};\n\nexport default MarkdownRender;\n"],"names":["MarkdownRender","content","className","components","linkTarget","responsiveImages","rehypePlugins","mergedComponents","useMemo","generated","children","props","jsx","alt","hasComponents","ReactMarkdown","remarkGfm"],"mappings":"yHAyBMA,EAA0C,CAAC,CAC/C,QAAAC,EACA,UAAAC,EACA,WAAAC,EACA,WAAAC,EACA,iBAAAC,EACA,cAAAC,CACF,IAAM,CACJ,MAAMC,EAAmBC,EAAAA,QAAQ,IAAM,CACrC,MAAMC,EAAiC,CAAA,EAGvC,OAAIL,GAAc,CAACD,GAAY,IAC7BM,EAAU,EAAI,CAAC,CAAE,SAAAC,EAAU,GAAGC,KAC5BC,EAAAA,IAAC,IAAA,CAAG,GAAGD,EAAO,OAAQP,EAAY,IAAKA,IAAe,SAAW,aAAe,OAC7E,SAAAM,EACH,GAKAL,GAAoB,CAACF,GAAY,MACnCM,EAAU,IAAM,CAAC,CAAE,IAAAI,EAAK,GAAGF,KACzBC,EAAAA,IAAC,MAAA,CACC,IAAKC,GAAO,GACX,GAAGF,EACJ,MAAO,CAAE,SAAU,OAAQ,OAAQ,OAAQ,GAAGA,EAAM,KAAA,CAAM,CAAA,GAMzD,CAAE,GAAGF,EAAW,GAAGN,CAAA,CAC5B,EAAG,CAACA,EAAYC,EAAYC,CAAgB,CAAC,EAEvCS,EAAgB,OAAO,KAAKP,CAAgB,EAAE,OAAS,EAE7D,OACEK,EAAAA,IAAC,OAAI,UAAAV,EACH,SAAAU,EAAAA,IAACG,EAAA,CACC,cAAe,CAACC,CAAS,EACzB,cAAAV,EACA,WAAYQ,EAAgBP,EAAmB,OAE9C,SAAAN,CAAA,CAAA,EAEL,CAEJ"}
@@ -0,0 +1,37 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { useMemo as c } from "react";
3
+ import l from "react-markdown";
4
+ import g from "remark-gfm";
5
+ const y = ({
6
+ content: d,
7
+ className: f,
8
+ components: r,
9
+ linkTarget: e,
10
+ responsiveImages: a,
11
+ rehypePlugins: s
12
+ }) => {
13
+ const n = c(() => {
14
+ const m = {};
15
+ return e && !r?.a && (m.a = ({ children: i, ...t }) => /* @__PURE__ */ o("a", { ...t, target: e, rel: e === "_blank" ? "noreferrer" : void 0, children: i })), a && !r?.img && (m.img = ({ alt: i, ...t }) => /* @__PURE__ */ o(
16
+ "img",
17
+ {
18
+ alt: i ?? "",
19
+ ...t,
20
+ style: { maxWidth: "100%", height: "auto", ...t.style }
21
+ }
22
+ )), { ...m, ...r };
23
+ }, [r, e, a]), h = Object.keys(n).length > 0;
24
+ return /* @__PURE__ */ o("div", { className: f, children: /* @__PURE__ */ o(
25
+ l,
26
+ {
27
+ remarkPlugins: [g],
28
+ rehypePlugins: s,
29
+ components: h ? n : void 0,
30
+ children: d
31
+ }
32
+ ) });
33
+ };
34
+ export {
35
+ y as M
36
+ };
37
+ //# sourceMappingURL=MarkdownRender-BmrS3q0l.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownRender-BmrS3q0l.js","sources":["../src/components/MarkdownRender/MarkdownRender.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport ReactMarkdown, { type Components, type Options } from 'react-markdown';\n\nimport remarkGfm from 'remark-gfm';\n\nexport interface MarkdownProps {\n /** The markdown string to render */\n content: string;\n /** Optional CSS class name for the container */\n className?: string;\n /** Custom component overrides for markdown elements */\n components?: Partial<Components>;\n /** Target for all links (defaults to '_self') */\n linkTarget?: '_blank' | '_self' | '_parent' | '_top';\n /** Make all images responsive (defaults to false) */\n responsiveImages?: boolean;\n /** Optional rehype plugins for HTML processing */\n rehypePlugins?: Options['rehypePlugins'];\n}\n\n/**\n * A component that renders a markdown string as HTML.\n * Supports GitHub Flavored Markdown (GFM) including tables,\n * strikethrough, task lists, and autolinks.\n */\nconst MarkdownRender: React.FC<MarkdownProps> = ({\n content,\n className,\n components,\n linkTarget,\n responsiveImages,\n rehypePlugins\n}) => {\n const mergedComponents = useMemo(() => {\n const generated: Partial<Components> = {};\n\n // Auto-generate link component if linkTarget is set and no custom 'a' provided\n if (linkTarget && !components?.a) {\n generated.a = ({ children, ...props }) => (\n <a {...props} target={linkTarget} rel={linkTarget === '_blank' ? 'noreferrer' : undefined}>\n {children}\n </a>\n );\n }\n\n // Auto-generate image component if responsiveImages and no custom 'img' provided\n if (responsiveImages && !components?.img) {\n generated.img = ({ alt, ...props }) => (\n <img\n alt={alt ?? ''}\n {...props}\n style={{ maxWidth: '100%', height: 'auto', ...props.style }}\n />\n );\n }\n\n // User-provided components override auto-generated ones\n return { ...generated, ...components };\n }, [components, linkTarget, responsiveImages]);\n\n const hasComponents = Object.keys(mergedComponents).length > 0;\n\n return (\n <div className={className}>\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n rehypePlugins={rehypePlugins}\n components={hasComponents ? mergedComponents : undefined}\n >\n {content}\n </ReactMarkdown>\n </div>\n );\n};\n\nexport default MarkdownRender;\n"],"names":["MarkdownRender","content","className","components","linkTarget","responsiveImages","rehypePlugins","mergedComponents","useMemo","generated","children","props","jsx","alt","hasComponents","ReactMarkdown","remarkGfm"],"mappings":";;;;AAyBA,MAAMA,IAA0C,CAAC;AAAA,EAC/C,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,eAAAC;AACF,MAAM;AACJ,QAAMC,IAAmBC,EAAQ,MAAM;AACrC,UAAMC,IAAiC,CAAA;AAGvC,WAAIL,KAAc,CAACD,GAAY,MAC7BM,EAAU,IAAI,CAAC,EAAE,UAAAC,GAAU,GAAGC,QAC5B,gBAAAC,EAAC,KAAA,EAAG,GAAGD,GAAO,QAAQP,GAAY,KAAKA,MAAe,WAAW,eAAe,QAC7E,UAAAM,GACH,IAKAL,KAAoB,CAACF,GAAY,QACnCM,EAAU,MAAM,CAAC,EAAE,KAAAI,GAAK,GAAGF,QACzB,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAKC,KAAO;AAAA,QACX,GAAGF;AAAA,QACJ,OAAO,EAAE,UAAU,QAAQ,QAAQ,QAAQ,GAAGA,EAAM,MAAA;AAAA,MAAM;AAAA,IAAA,IAMzD,EAAE,GAAGF,GAAW,GAAGN,EAAA;AAAA,EAC5B,GAAG,CAACA,GAAYC,GAAYC,CAAgB,CAAC,GAEvCS,IAAgB,OAAO,KAAKP,CAAgB,EAAE,SAAS;AAE7D,SACE,gBAAAK,EAAC,SAAI,WAAAV,GACH,UAAA,gBAAAU;AAAA,IAACG;AAAA,IAAA;AAAA,MACC,eAAe,CAACC,CAAS;AAAA,MACzB,eAAAV;AAAA,MACA,YAAYQ,IAAgBP,IAAmB;AAAA,MAE9C,UAAAN;AAAA,IAAA;AAAA,EAAA,GAEL;AAEJ;"}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./MarkdownRender-C-bSlM80.cjs"),r=require("./ThemeSwitch-C7k1_MA4.cjs");exports.MarkdownRender=e.MarkdownRender;exports.ThemeSwitch=r.ThemeSwitch;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./MarkdownRender-BOGosy9w.cjs"),r=require("./ThemeSwitch-C7k1_MA4.cjs");exports.MarkdownRender=e.MarkdownRender;exports.ThemeSwitch=r.ThemeSwitch;
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { M as o } from "./MarkdownRender-DLY5lZNG.js";
1
+ import { M as o } from "./MarkdownRender-BmrS3q0l.js";
2
2
  import { T as m } from "./ThemeSwitch-DbaEio36.js";
3
3
  export {
4
4
  o as MarkdownRender,
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./MarkdownRender-C-bSlM80.cjs");exports.MarkdownRender=e.MarkdownRender;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./MarkdownRender-BOGosy9w.cjs");exports.MarkdownRender=e.MarkdownRender;
2
2
  //# sourceMappingURL=markdown-render.cjs.map
@@ -1,4 +1,4 @@
1
- import { M as o } from "./MarkdownRender-DLY5lZNG.js";
1
+ import { M as o } from "./MarkdownRender-BmrS3q0l.js";
2
2
  export {
3
3
  o as MarkdownRender
4
4
  };
@@ -1,8 +1,17 @@
1
+ import { Components, Options } from 'react-markdown';
1
2
  export interface MarkdownProps {
2
3
  /** The markdown string to render */
3
4
  content: string;
4
5
  /** Optional CSS class name for the container */
5
6
  className?: string;
7
+ /** Custom component overrides for markdown elements */
8
+ components?: Partial<Components>;
9
+ /** Target for all links (defaults to '_self') */
10
+ linkTarget?: '_blank' | '_self' | '_parent' | '_top';
11
+ /** Make all images responsive (defaults to false) */
12
+ responsiveImages?: boolean;
13
+ /** Optional rehype plugins for HTML processing */
14
+ rehypePlugins?: Options['rehypePlugins'];
6
15
  }
7
16
  /**
8
17
  * A component that renders a markdown string as HTML.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@macolmenerori/component-library",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "keywords": [],
@@ -1,2 +0,0 @@
1
- "use strict";const r=require("react/jsx-runtime"),s=require("react-markdown"),i=require("remark-gfm"),t=({content:e,className:n})=>r.jsx("div",{className:n,children:r.jsx(s,{remarkPlugins:[i],children:e})});exports.MarkdownRender=t;
2
- //# sourceMappingURL=MarkdownRender-C-bSlM80.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownRender-C-bSlM80.cjs","sources":["../src/components/MarkdownRender/MarkdownRender.tsx"],"sourcesContent":["import ReactMarkdown from 'react-markdown';\n\nimport remarkGfm from 'remark-gfm';\n\nexport interface MarkdownProps {\n /** The markdown string to render */\n content: string;\n /** Optional CSS class name for the container */\n className?: string;\n}\n\n/**\n * A component that renders a markdown string as HTML.\n * Supports GitHub Flavored Markdown (GFM) including tables,\n * strikethrough, task lists, and autolinks.\n */\nconst MarkdownRender: React.FC<MarkdownProps> = ({ content, className }) => {\n return (\n <div className={className}>\n <ReactMarkdown remarkPlugins={[remarkGfm]}>{content}</ReactMarkdown>\n </div>\n );\n};\n\nexport default MarkdownRender;\n"],"names":["MarkdownRender","content","className","jsx","ReactMarkdown","remarkGfm"],"mappings":"sGAgBMA,EAA0C,CAAC,CAAE,QAAAC,EAAS,UAAAC,KAExDC,EAAAA,IAAC,MAAA,CAAI,UAAAD,EACH,SAAAC,EAAAA,IAACC,EAAA,CAAc,cAAe,CAACC,CAAS,EAAI,SAAAJ,CAAA,CAAQ,CAAA,CACtD"}
@@ -1,8 +0,0 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import m from "react-markdown";
3
- import n from "remark-gfm";
4
- const d = ({ content: o, className: e }) => /* @__PURE__ */ r("div", { className: e, children: /* @__PURE__ */ r(m, { remarkPlugins: [n], children: o }) });
5
- export {
6
- d as M
7
- };
8
- //# sourceMappingURL=MarkdownRender-DLY5lZNG.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MarkdownRender-DLY5lZNG.js","sources":["../src/components/MarkdownRender/MarkdownRender.tsx"],"sourcesContent":["import ReactMarkdown from 'react-markdown';\n\nimport remarkGfm from 'remark-gfm';\n\nexport interface MarkdownProps {\n /** The markdown string to render */\n content: string;\n /** Optional CSS class name for the container */\n className?: string;\n}\n\n/**\n * A component that renders a markdown string as HTML.\n * Supports GitHub Flavored Markdown (GFM) including tables,\n * strikethrough, task lists, and autolinks.\n */\nconst MarkdownRender: React.FC<MarkdownProps> = ({ content, className }) => {\n return (\n <div className={className}>\n <ReactMarkdown remarkPlugins={[remarkGfm]}>{content}</ReactMarkdown>\n </div>\n );\n};\n\nexport default MarkdownRender;\n"],"names":["MarkdownRender","content","className","jsx","ReactMarkdown","remarkGfm"],"mappings":";;;AAgBA,MAAMA,IAA0C,CAAC,EAAE,SAAAC,GAAS,WAAAC,QAExD,gBAAAC,EAAC,OAAA,EAAI,WAAAD,GACH,UAAA,gBAAAC,EAACC,GAAA,EAAc,eAAe,CAACC,CAAS,GAAI,UAAAJ,EAAA,CAAQ,EAAA,CACtD;"}