@vaneui/md 0.0.3-alpha.20250730172254.8352948 → 0.0.3-alpha.20250803164622.cc5ccbc

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.
Files changed (66) hide show
  1. package/dist/components/blocks/MdBlockquote.d.ts +2 -0
  2. package/dist/components/blocks/MdHr.d.ts +2 -0
  3. package/dist/components/breaks/MdHardbreak.d.ts +2 -0
  4. package/dist/components/breaks/MdSoftbreak.d.ts +2 -0
  5. package/dist/components/code/MdFence.d.ts +2 -0
  6. package/dist/components/errors/MdError.d.ts +2 -0
  7. package/dist/components/headings/MdHeading.d.ts +2 -0
  8. package/dist/components/links/MdLink.d.ts +2 -0
  9. package/dist/components/lists/MdItem.d.ts +2 -0
  10. package/dist/components/lists/MdList.d.ts +2 -0
  11. package/dist/components/md-components.d.ts +25 -0
  12. package/dist/components/md.d.ts +2 -6
  13. package/dist/components/media/MdImage.d.ts +2 -0
  14. package/dist/components/structure/MdDocument.d.ts +2 -0
  15. package/dist/components/structure/MdInline.d.ts +2 -0
  16. package/dist/components/tables/MdTable.d.ts +2 -0
  17. package/dist/components/tables/MdTbody.d.ts +2 -0
  18. package/dist/components/tables/MdTd.d.ts +2 -0
  19. package/dist/components/tables/MdTh.d.ts +2 -0
  20. package/dist/components/tables/MdThead.d.ts +2 -0
  21. package/dist/components/tables/MdTr.d.ts +2 -0
  22. package/dist/components/text/MdCode.d.ts +2 -0
  23. package/dist/components/text/MdEm.d.ts +2 -0
  24. package/dist/components/text/MdParagraph.d.ts +2 -0
  25. package/dist/components/text/MdS.d.ts +2 -0
  26. package/dist/components/text/MdStrong.d.ts +2 -0
  27. package/dist/components/text/MdText.d.ts +2 -0
  28. package/dist/config/default-config.d.ts +3 -0
  29. package/dist/index.d.ts +4 -1
  30. package/dist/index.esm.js +285 -54
  31. package/dist/index.esm.js.map +1 -1
  32. package/dist/index.js +310 -52
  33. package/dist/index.js.map +1 -1
  34. package/dist/styles/index.css +2425 -0
  35. package/dist/tests/components/MdBlockquote.test.d.ts +1 -0
  36. package/dist/tests/components/MdCode.test.d.ts +1 -0
  37. package/dist/tests/components/MdDocument.test.d.ts +1 -0
  38. package/dist/tests/components/MdEm.test.d.ts +1 -0
  39. package/dist/tests/components/MdError.test.d.ts +1 -0
  40. package/dist/tests/components/MdFence.test.d.ts +1 -0
  41. package/dist/tests/components/MdHardbreak.test.d.ts +1 -0
  42. package/dist/tests/components/MdHeading.test.d.ts +1 -0
  43. package/dist/tests/components/MdHr.test.d.ts +1 -0
  44. package/dist/tests/components/MdImage.test.d.ts +1 -0
  45. package/dist/tests/components/MdInline.test.d.ts +1 -0
  46. package/dist/tests/components/MdItem.test.d.ts +1 -0
  47. package/dist/tests/components/MdLink.test.d.ts +1 -0
  48. package/dist/tests/components/MdList.test.d.ts +1 -0
  49. package/dist/tests/components/MdParagraph.test.d.ts +1 -0
  50. package/dist/tests/components/MdS.test.d.ts +1 -0
  51. package/dist/tests/components/MdSoftbreak.test.d.ts +1 -0
  52. package/dist/tests/components/MdStrong.test.d.ts +1 -0
  53. package/dist/tests/components/MdTable.test.d.ts +1 -0
  54. package/dist/tests/components/MdTbody.test.d.ts +1 -0
  55. package/dist/tests/components/MdTd.test.d.ts +1 -0
  56. package/dist/tests/components/MdText.test.d.ts +1 -0
  57. package/dist/tests/components/MdTh.test.d.ts +1 -0
  58. package/dist/tests/components/MdThead.test.d.ts +1 -0
  59. package/dist/tests/components/MdTr.test.d.ts +1 -0
  60. package/dist/tests/md-nodes.test.d.ts +1 -0
  61. package/dist/types/index.d.ts +79 -0
  62. package/package.json +17 -9
  63. /package/dist/{components/tests → tests}/md.test.d.ts +0 -0
  64. /package/dist/{components/tests → tests}/md.theme-defaults.test.d.ts +0 -0
  65. /package/dist/{components/tests → tests}/md.theme-override.test.d.ts +0 -0
  66. /package/dist/{components/tests → tests}/md.theme-structure.test.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ var React = require('react');
3
4
  var jsxRuntime = require('react/jsx-runtime');
4
5
  var ui = require('@vaneui/ui');
5
- var React = require('react');
6
6
 
7
7
  var __create = Object.create;
8
8
  var __defProp = Object.defineProperty;
@@ -8462,7 +8462,7 @@ function validateTree(content, config) {
8462
8462
 
8463
8463
  // index.ts
8464
8464
  var tokenizer = new Tokenizer();
8465
- function mergeConfig(config = {}) {
8465
+ function mergeConfig$1(config = {}) {
8466
8466
  return {
8467
8467
  ...config,
8468
8468
  tags: {
@@ -8490,14 +8490,14 @@ function resolve2(content, config) {
8490
8490
  return content.resolve(config);
8491
8491
  }
8492
8492
  function transform2(nodes, options) {
8493
- const config = mergeConfig(options);
8493
+ const config = mergeConfig$1(options);
8494
8494
  const content = resolve2(nodes, config);
8495
8495
  if (Array.isArray(content))
8496
8496
  return content.flatMap((child) => child.transform(config));
8497
8497
  return content.transform(config);
8498
8498
  }
8499
8499
  function validate(content, options) {
8500
- const config = mergeConfig(options);
8500
+ const config = mergeConfig$1(options);
8501
8501
  return validateTree(content, config);
8502
8502
  }
8503
8503
  function createElement(name, attributes = {}, ...children) {
@@ -8531,8 +8531,17 @@ Markdoc.createElement = createElement;
8531
8531
  Markdoc.truthy = truthy;
8532
8532
  Markdoc.format = format;
8533
8533
 
8534
+ const MdDocument = (props) => {
8535
+ return jsxRuntime.jsx(ui.Col, { ...props });
8536
+ };
8537
+
8538
+ const MdInline = (props) => {
8539
+ const { children, ...rest } = props;
8540
+ return jsxRuntime.jsx("span", { ...rest, children: children });
8541
+ };
8542
+
8534
8543
  const MdHeading = (props) => {
8535
- const { level, ...rest } = props;
8544
+ const { level, children, ...rest } = props;
8536
8545
  const tag = `h${level}`;
8537
8546
  let size = {};
8538
8547
  switch (level) {
@@ -8549,66 +8558,315 @@ const MdHeading = (props) => {
8549
8558
  size = { sm: true };
8550
8559
  break;
8551
8560
  case 5:
8561
+ case 6:
8552
8562
  size = { xs: true };
8553
8563
  break;
8554
8564
  }
8555
- return jsxRuntime.jsx(ui.Title, { ...rest, ...size, tag: tag });
8565
+ return jsxRuntime.jsx(ui.Title, { ...rest, ...size, tag: tag, children: children });
8566
+ };
8567
+
8568
+ const MdParagraph = (props) => {
8569
+ const { children, ...rest } = props;
8570
+ return jsxRuntime.jsx(ui.Text, { ...rest, tag: "p", children: children });
8571
+ };
8572
+
8573
+ const MdText = (props) => {
8574
+ const { content, children, ...rest } = props;
8575
+ return jsxRuntime.jsx(ui.Text, { ...rest, tag: "span", children: content || children });
8576
+ };
8577
+
8578
+ const MdStrong = (props) => {
8579
+ const { children, ...rest } = props;
8580
+ return jsxRuntime.jsx(ui.Text, { ...rest, tag: "strong", bold: true, children: children });
8581
+ };
8582
+
8583
+ const MdEm = (props) => {
8584
+ const { children, ...rest } = props;
8585
+ return jsxRuntime.jsx(ui.Text, { ...rest, tag: "em", italic: true, children: children });
8556
8586
  };
8587
+
8588
+ const MdS = (props) => {
8589
+ const { children, ...rest } = props;
8590
+ return jsxRuntime.jsx(ui.Text, { ...rest, tag: "s", style: { textDecoration: 'line-through' }, children: children });
8591
+ };
8592
+
8593
+ const MdCode = (props) => {
8594
+ const { content, children, ...rest } = props;
8595
+ return jsxRuntime.jsx(ui.Badge, { ...rest, children: content || children });
8596
+ };
8597
+
8557
8598
  const MdLink = (props) => {
8558
- const { href, title, ...rest } = props;
8559
- return jsxRuntime.jsx(ui.Link, { link: true, ...rest, href: href, title: title, tag: ui.Link });
8599
+ const { href, title, children, ...rest } = props;
8600
+ return jsxRuntime.jsx(ui.Link, { ...rest, href: href, title: title, children: children });
8560
8601
  };
8561
- const MdImg = (props) => {
8602
+
8603
+ const MdImage = (props) => {
8562
8604
  const { src, alt, title, ...rest } = props;
8563
- return (jsxRuntime.jsx("img", { ...rest, title: title, src: src, alt: alt, className: "w-fit rounded-lg" }));
8605
+ return (jsxRuntime.jsx("img", { ...rest, title: title, src: src, alt: alt || "", style: { display: 'block', maxWidth: '100%', height: 'auto', borderRadius: '0.5rem' } }));
8564
8606
  };
8565
- const MdContainer = (props) => jsxRuntime.jsx(ui.Col, { ...props });
8566
- const MdList = (props) => jsxRuntime.jsx(ui.List, { ...props });
8567
- const Md = ({ content, frontmatter }) => {
8568
- const ast = Markdoc.parse(content);
8569
- const config = {
8570
- nodes: {
8571
- document: {
8572
- render: "MdContainer",
8573
- },
8574
- heading: {
8575
- render: "MdHeading",
8576
- attributes: {
8577
- level: { type: Number },
8578
- },
8579
- },
8580
- link: {
8581
- render: "MdLink",
8582
- attributes: {
8583
- href: { type: String },
8584
- title: { type: String },
8585
- },
8586
- },
8587
- list: {
8588
- render: "MdList",
8589
- },
8590
- image: {
8591
- render: "MdImg",
8592
- attributes: {
8593
- src: { type: String },
8594
- alt: { type: String },
8595
- title: { type: String },
8596
- },
8597
- },
8607
+
8608
+ const MdList = (props) => {
8609
+ const { children, ordered, ...rest } = props;
8610
+ // Use the ordered attribute to determine list type
8611
+ const listProps = ordered
8612
+ ? { decimal: true }
8613
+ : { disc: true };
8614
+ return jsxRuntime.jsx(ui.List, { ...rest, ...listProps, children: children });
8615
+ };
8616
+
8617
+ const MdItem = (props) => {
8618
+ const { children, ...rest } = props;
8619
+ return jsxRuntime.jsx(ui.ListItem, { ...rest, children: children });
8620
+ };
8621
+
8622
+ const MdBlockquote = (props) => {
8623
+ const { children, ...rest } = props;
8624
+ return (jsxRuntime.jsx(ui.Card, { ...rest, style: { borderLeft: '4px solid #d1d5db', paddingLeft: '1rem' }, children: children }));
8625
+ };
8626
+
8627
+ const MdHr = (props) => {
8628
+ return jsxRuntime.jsx(ui.Divider, { ...props });
8629
+ };
8630
+
8631
+ const MdFence = (props) => {
8632
+ const { content, language, ...rest } = props;
8633
+ return (jsxRuntime.jsx(ui.Card, { ...rest, children: jsxRuntime.jsx("pre", { style: { margin: 0, fontFamily: 'monospace', fontSize: '0.875rem' }, children: jsxRuntime.jsx("code", { className: language ? `language-${language}` : "", children: content }) }) }));
8634
+ };
8635
+
8636
+ const MdTable = (props) => {
8637
+ const { children, ...rest } = props;
8638
+ return (jsxRuntime.jsx(ui.Card, { style: { overflow: 'auto', margin: '1rem 0' }, children: jsxRuntime.jsx("table", { ...rest, style: { width: '100%', borderCollapse: 'collapse' }, children: children }) }));
8639
+ };
8640
+
8641
+ const MdThead = (props) => {
8642
+ const { children, ...rest } = props;
8643
+ return jsxRuntime.jsx("thead", { ...rest, children: children });
8644
+ };
8645
+
8646
+ const MdTbody = (props) => {
8647
+ const { children, ...rest } = props;
8648
+ return jsxRuntime.jsx("tbody", { ...rest, children: children });
8649
+ };
8650
+
8651
+ const MdTr = (props) => {
8652
+ const { children, ...rest } = props;
8653
+ return jsxRuntime.jsx("tr", { ...rest, children: children });
8654
+ };
8655
+
8656
+ const MdTd = (props) => {
8657
+ const { children, align, colspan, rowspan, ...rest } = props;
8658
+ return (jsxRuntime.jsx("td", { ...rest, style: { textAlign: align }, colSpan: colspan, rowSpan: rowspan, children: children }));
8659
+ };
8660
+
8661
+ const MdTh = (props) => {
8662
+ const { children, align, width, ...rest } = props;
8663
+ return (jsxRuntime.jsx("th", { ...rest, style: { textAlign: align, width }, children: children }));
8664
+ };
8665
+
8666
+ const MdHardbreak = () => {
8667
+ return jsxRuntime.jsx("br", {});
8668
+ };
8669
+
8670
+ const MdSoftbreak = () => {
8671
+ return jsxRuntime.jsx(jsxRuntime.Fragment, { children: " " });
8672
+ };
8673
+
8674
+ const MdError = (props) => {
8675
+ const { children, ...rest } = props;
8676
+ return (jsxRuntime.jsxs(ui.Card, { ...rest, style: { backgroundColor: '#fef2f2', borderColor: '#fecaca', color: '#dc2626', margin: '1rem 0' }, children: [jsxRuntime.jsx(ui.Text, { bold: true, children: "Error:" }), " ", children] }));
8677
+ };
8678
+
8679
+ // Default node configuration for Markdoc
8680
+ const defaultNodesConfig = {
8681
+ document: {
8682
+ render: "MdDocument",
8683
+ },
8684
+ heading: {
8685
+ render: "MdHeading",
8686
+ attributes: {
8687
+ level: { type: Number, required: true },
8688
+ },
8689
+ },
8690
+ paragraph: {
8691
+ render: "MdParagraph",
8692
+ },
8693
+ hr: {
8694
+ render: "MdHr",
8695
+ },
8696
+ image: {
8697
+ render: "MdImage",
8698
+ attributes: {
8699
+ src: { type: String, required: true },
8700
+ alt: { type: String },
8701
+ title: { type: String },
8702
+ },
8703
+ },
8704
+ fence: {
8705
+ render: "MdFence",
8706
+ attributes: {
8707
+ content: { type: String },
8708
+ language: { type: String },
8709
+ },
8710
+ },
8711
+ blockquote: {
8712
+ render: "MdBlockquote",
8713
+ },
8714
+ list: {
8715
+ render: "MdList",
8716
+ attributes: {
8717
+ ordered: { type: Boolean },
8598
8718
  },
8599
- variables: { markdoc: { frontmatter } }
8719
+ },
8720
+ item: {
8721
+ render: "MdItem",
8722
+ },
8723
+ table: {
8724
+ render: "MdTable",
8725
+ },
8726
+ thead: {
8727
+ render: "MdThead",
8728
+ },
8729
+ tbody: {
8730
+ render: "MdTbody",
8731
+ },
8732
+ tr: {
8733
+ render: "MdTr",
8734
+ },
8735
+ td: {
8736
+ render: "MdTd",
8737
+ attributes: {
8738
+ align: { type: String },
8739
+ colspan: { type: Number },
8740
+ rowspan: { type: Number },
8741
+ },
8742
+ },
8743
+ th: {
8744
+ render: "MdTh",
8745
+ attributes: {
8746
+ align: { type: String },
8747
+ width: { type: String },
8748
+ },
8749
+ },
8750
+ strong: {
8751
+ render: "MdStrong",
8752
+ },
8753
+ em: {
8754
+ render: "MdEm",
8755
+ },
8756
+ s: {
8757
+ render: "MdS",
8758
+ },
8759
+ link: {
8760
+ render: "MdLink",
8761
+ attributes: {
8762
+ href: { type: String, required: true },
8763
+ title: { type: String },
8764
+ },
8765
+ },
8766
+ code: {
8767
+ render: "MdCode",
8768
+ attributes: {
8769
+ content: { type: String }
8770
+ }
8771
+ },
8772
+ hardbreak: {
8773
+ render: "MdHardbreak",
8774
+ },
8775
+ softbreak: {
8776
+ render: "MdSoftbreak",
8777
+ },
8778
+ error: {
8779
+ render: "MdError",
8780
+ },
8781
+ };
8782
+ // Default component mapping
8783
+ const defaultComponents = {
8784
+ MdDocument: MdDocument,
8785
+ MdHeading: MdHeading,
8786
+ MdParagraph: MdParagraph,
8787
+ MdHr: MdHr,
8788
+ MdImage: MdImage,
8789
+ MdFence: MdFence,
8790
+ MdBlockquote: MdBlockquote,
8791
+ MdList: MdList,
8792
+ MdItem: MdItem,
8793
+ MdTable: MdTable,
8794
+ MdThead: MdThead,
8795
+ MdTbody: MdTbody,
8796
+ MdTr: MdTr,
8797
+ MdTd: MdTd,
8798
+ MdTh: MdTh,
8799
+ MdInline: MdInline,
8800
+ MdText: MdText,
8801
+ MdStrong: MdStrong,
8802
+ MdEm: MdEm,
8803
+ MdS: MdS,
8804
+ MdLink: MdLink,
8805
+ MdCode: MdCode,
8806
+ MdHardbreak: MdHardbreak,
8807
+ MdSoftbreak: MdSoftbreak,
8808
+ MdError: MdError,
8809
+ };
8810
+
8811
+ // Helper function to merge configurations
8812
+ function mergeConfig(defaultConfig, userConfig) {
8813
+ if (!userConfig)
8814
+ return defaultConfig;
8815
+ return {
8816
+ nodes: { ...defaultConfig.nodes, ...userConfig.nodes },
8817
+ components: { ...defaultConfig.components, ...userConfig.components },
8818
+ variables: { ...defaultConfig.variables, ...userConfig.variables },
8819
+ tags: { ...defaultConfig.tags, ...userConfig.tags },
8820
+ functions: { ...defaultConfig.functions, ...userConfig.functions },
8600
8821
  };
8601
- const transformed = Markdoc.transform(ast, config);
8822
+ }
8823
+ const Md = ({ content, frontmatter, config: userConfig }) => {
8824
+ const ast = Markdoc.parse(content);
8825
+ // Merge user config with defaults
8826
+ const mergedConfig = mergeConfig({
8827
+ nodes: defaultNodesConfig,
8828
+ components: defaultComponents,
8829
+ variables: { markdoc: { frontmatter } },
8830
+ }, userConfig);
8831
+ // Create Markdoc config
8832
+ const markdocConfig = {
8833
+ nodes: mergedConfig.nodes,
8834
+ tags: mergedConfig.tags,
8835
+ functions: mergedConfig.functions,
8836
+ variables: mergedConfig.variables,
8837
+ };
8838
+ const transformed = Markdoc.transform(ast, markdocConfig);
8602
8839
  return Markdoc.renderers.react(transformed, React, {
8603
- components: {
8604
- MdHeading: MdHeading,
8605
- MdContainer: MdContainer,
8606
- MdLink: MdLink,
8607
- MdList: MdList,
8608
- MdImg: MdImg,
8609
- },
8840
+ components: mergedConfig.components,
8610
8841
  });
8611
8842
  };
8612
8843
 
8613
8844
  exports.Md = Md;
8845
+ exports.MdBlockquote = MdBlockquote;
8846
+ exports.MdCode = MdCode;
8847
+ exports.MdDocument = MdDocument;
8848
+ exports.MdEm = MdEm;
8849
+ exports.MdError = MdError;
8850
+ exports.MdFence = MdFence;
8851
+ exports.MdHardbreak = MdHardbreak;
8852
+ exports.MdHeading = MdHeading;
8853
+ exports.MdHr = MdHr;
8854
+ exports.MdImage = MdImage;
8855
+ exports.MdInline = MdInline;
8856
+ exports.MdItem = MdItem;
8857
+ exports.MdLink = MdLink;
8858
+ exports.MdList = MdList;
8859
+ exports.MdParagraph = MdParagraph;
8860
+ exports.MdS = MdS;
8861
+ exports.MdSoftbreak = MdSoftbreak;
8862
+ exports.MdStrong = MdStrong;
8863
+ exports.MdTable = MdTable;
8864
+ exports.MdTbody = MdTbody;
8865
+ exports.MdTd = MdTd;
8866
+ exports.MdText = MdText;
8867
+ exports.MdTh = MdTh;
8868
+ exports.MdThead = MdThead;
8869
+ exports.MdTr = MdTr;
8870
+ exports.defaultComponents = defaultComponents;
8871
+ exports.defaultNodesConfig = defaultNodesConfig;
8614
8872
  //# sourceMappingURL=index.js.map