@apia/theme 4.0.37 → 4.0.40

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.
@@ -7835,6 +7835,37 @@ const ApiaThemeProvider = ({
7835
7835
  return /* @__PURE__ */ jsx(ThemeProvider, { theme, children });
7836
7836
  };
7837
7837
 
7838
+ const name$5 = "pageBreak";
7839
+ const pageBreakTag = "@@@ PAGEBREAK @@@";
7840
+ const pageBreakExtension = {
7841
+ name: name$5,
7842
+ parser: (state, startLine, _endLine, checkMode) => {
7843
+ const line = state.getLines(startLine, startLine + 1, 0, false);
7844
+ if (line.trim() !== pageBreakTag)
7845
+ return false;
7846
+ if (checkMode)
7847
+ return true;
7848
+ state.tokens.push({
7849
+ type: name$5,
7850
+ level: 0,
7851
+ lines: [startLine, startLine + 1]
7852
+ });
7853
+ state.line = startLine + 1;
7854
+ return true;
7855
+ },
7856
+ replacer: () => () => `<div class="${name$5}"></div>`,
7857
+ styles: () => `
7858
+ .${name$5} + * {
7859
+ page-break-before: always;
7860
+ }
7861
+
7862
+ .${name$5} {
7863
+ display: none;
7864
+ }
7865
+
7866
+ `
7867
+ };
7868
+
7838
7869
  function assignHelp(fn) {
7839
7870
  Object.assign(fn, {
7840
7871
  help: `A markdown parser. Accepts a configuration object with the following structure:
@@ -7900,17 +7931,17 @@ const errorExtension = {
7900
7931
  }`
7901
7932
  };
7902
7933
 
7903
- var __defProp$4 = Object.defineProperty;
7904
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7905
- var __publicField$4 = (obj, key, value) => {
7906
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
7934
+ var __defProp$5 = Object.defineProperty;
7935
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7936
+ var __publicField$5 = (obj, key, value) => {
7937
+ __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
7907
7938
  return value;
7908
7939
  };
7909
7940
  class HeadingToken {
7910
7941
  constructor(content, level) {
7911
7942
  this.level = level;
7912
- __publicField$4(this, "_content");
7913
- __publicField$4(this, "type", "heading");
7943
+ __publicField$5(this, "_content");
7944
+ __publicField$5(this, "type", "heading");
7914
7945
  this._content = content;
7915
7946
  }
7916
7947
  get content() {
@@ -7979,10 +8010,10 @@ const successExtension = {
7979
8010
  }`
7980
8011
  };
7981
8012
 
7982
- var __defProp$3 = Object.defineProperty;
7983
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7984
- var __publicField$3 = (obj, key, value) => {
7985
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
8013
+ var __defProp$4 = Object.defineProperty;
8014
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8015
+ var __publicField$4 = (obj, key, value) => {
8016
+ __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
7986
8017
  return value;
7987
8018
  };
7988
8019
  var __accessCheck$1 = (obj, member, msg) => {
@@ -8010,9 +8041,9 @@ class TableToken {
8010
8041
  constructor(content, lines) {
8011
8042
  this.lines = lines;
8012
8043
  __privateAdd$1(this, _getColumnAlignment$1);
8013
- __publicField$3(this, "content");
8014
- __publicField$3(this, "level", 1);
8015
- __publicField$3(this, "type", name$1);
8044
+ __publicField$4(this, "content");
8045
+ __publicField$4(this, "level", 1);
8046
+ __publicField$4(this, "type", name$1);
8016
8047
  this.content = JSON.stringify(content);
8017
8048
  }
8018
8049
  getTable() {
@@ -8047,7 +8078,7 @@ getColumnAlignment_fn$1 = function(table, index) {
8047
8078
  return getCell(table.header[i - 1]).align;
8048
8079
  };
8049
8080
  const name$1 = "advancedTable";
8050
- const headerRowRegex = /^ *(?:\{ *#([\w\-]+) *\})? *((?:\|.+)+\|) *$/;
8081
+ const headerRowRegex = /^ *(?:\{ *#([\w-]+) *\})? *((?:\|.+)+\|) *$/;
8051
8082
  const rowRegex = /^ *(?:\|.+)+\| *$/;
8052
8083
  const separatorRegex = /^ *(?:\| *:? *----* *:? *)+\| *$/;
8053
8084
  class TableExtension {
@@ -8062,7 +8093,7 @@ class TableExtension {
8062
8093
  return `${cell.className ? ` class="${cell.className ?? ""}"` : ""}`;
8063
8094
  },
8064
8095
  parseCellString(content) {
8065
- const classNameRegex = /\(\.([^\)]+)\)/;
8096
+ const classNameRegex = /\(\.([^)]+)\)/;
8066
8097
  const className = content.match(classNameRegex)?.[1];
8067
8098
  return {
8068
8099
  parsedCell: { className },
@@ -8104,7 +8135,7 @@ class TableExtension {
8104
8135
  return `${style ? ` style="${style}"` : ""}`;
8105
8136
  },
8106
8137
  parseCellString(content) {
8107
- const stylesRegex = /\(\{style:([^\}]+)\}\)/;
8138
+ const stylesRegex = /\(\{style:([^}]+)\}\)/;
8108
8139
  const style = content.match(stylesRegex)?.[1] ?? "";
8109
8140
  return {
8110
8141
  parsedCell: { style },
@@ -8113,8 +8144,8 @@ class TableExtension {
8113
8144
  }
8114
8145
  }
8115
8146
  ]);
8116
- __publicField$3(this, "name", name$1);
8117
- __publicField$3(this, "parser", (state, startLine, endLine, checkMode) => {
8147
+ __publicField$4(this, "name", name$1);
8148
+ __publicField$4(this, "parser", (state, startLine, endLine, checkMode) => {
8118
8149
  if (startLine + 1 >= endLine) {
8119
8150
  return false;
8120
8151
  }
@@ -8169,10 +8200,10 @@ class TableExtension {
8169
8200
  }
8170
8201
  return false;
8171
8202
  });
8172
- __publicField$3(this, "replacer", (md) => (tokens, idx) => {
8203
+ __publicField$4(this, "replacer", (md) => (tokens, idx) => {
8173
8204
  return tokens[idx].getTableString(__privateGet$1(this, _cellParsers), md);
8174
8205
  });
8175
- __publicField$3(this, "styles", () => "");
8206
+ __publicField$4(this, "styles", () => "");
8176
8207
  }
8177
8208
  }
8178
8209
  _cellParsers = new WeakMap();
@@ -8245,7 +8276,8 @@ const markdownExtensions = [
8245
8276
  errorExtension,
8246
8277
  successExtension,
8247
8278
  new TableExtension(),
8248
- warningExtension
8279
+ warningExtension,
8280
+ pageBreakExtension
8249
8281
  ];
8250
8282
 
8251
8283
  function isInlineExtension(ext) {
@@ -8273,7 +8305,7 @@ async function getRemarkable(extensions) {
8273
8305
 
8274
8306
  const parseMarkdown = async (options) => {
8275
8307
  const markdownLibrary = await getRemarkable(options.extensions);
8276
- const css = (await import('./styles-BQLlZhHD.js')).markdownParserStyles ?? new ErrorImporting();
8308
+ const css = (await import('./styles-CAgWhp1H.js')).markdownParserStyles ?? new ErrorImporting();
8277
8309
  if (css instanceof ErrorImporting)
8278
8310
  throw new Error("Could not import css, cannot continue");
8279
8311
  const html = options.htmlTemplate ?? (await import('./html-B-K0BIiw.js')).markdownHtml ?? new ErrorImporting();
@@ -8282,59 +8314,16 @@ const parseMarkdown = async (options) => {
8282
8314
  const markdownString = options.content;
8283
8315
  const markdownParser = markdownLibrary.render.bind(markdownLibrary);
8284
8316
  let htmlString = markdownParser(markdownString);
8285
- if (options.tableOfContentsTitle) {
8317
+ if (options.tocProps) {
8286
8318
  const b = new MarkdownBuilder();
8287
- htmlString = b.addTableOfContents(options.tableOfContentsTitle, htmlString);
8319
+ htmlString = b.addTableOfContents(options.tocProps, htmlString);
8288
8320
  }
8289
8321
  const rendered = html(
8290
8322
  options.title,
8291
8323
  css(options.additionalStyles, options.extensions),
8292
8324
  `${options?.additionalBodyContent?.before ?? ""}${htmlString}${options?.additionalBodyContent?.after ?? ""}`
8293
8325
  );
8294
- let finalHtml = rendered;
8295
- try {
8296
- const DOMParserCtor = globalThis.DOMParser;
8297
- const hasDOM = typeof DOMParserCtor !== "undefined" && typeof globalThis.document !== "undefined";
8298
- if (hasDOM) {
8299
- const parser = new DOMParserCtor();
8300
- const doc = parser.parseFromString(finalHtml, "text/html");
8301
- const body = doc.body;
8302
- const headings = Array.from(
8303
- body.querySelectorAll("h1, h2, h3")
8304
- );
8305
- for (const h of headings) {
8306
- if (h.tagName === "H1") {
8307
- h.classList.add("mt-high");
8308
- }
8309
- const parent = h.parentElement;
8310
- if (parent && parent.tagName === "DIV" && parent.getAttribute("data-keep-with-next") === "true") {
8311
- continue;
8312
- }
8313
- const wrapper = doc.createElement("div");
8314
- wrapper.setAttribute(
8315
- "style",
8316
- "break-inside: avoid; display: flex; flex-direction: column; gap: var(--space-6)"
8317
- );
8318
- wrapper.setAttribute("data-keep-with-next", "true");
8319
- h.parentNode.insertBefore(wrapper, h);
8320
- let node = h;
8321
- while (node) {
8322
- const next = node.nextSibling;
8323
- wrapper.appendChild(node);
8324
- if (next && next.tagName) {
8325
- const tag = String(next.tagName);
8326
- if (/^H[1-6]$/.test(tag)) {
8327
- break;
8328
- }
8329
- }
8330
- node = next;
8331
- }
8332
- }
8333
- finalHtml = doc.documentElement.outerHTML;
8334
- }
8335
- } catch {
8336
- }
8337
- return finalHtml;
8326
+ return rendered;
8338
8327
  };
8339
8328
  assignHelp(parseMarkdown);
8340
8329
 
@@ -8381,17 +8370,17 @@ class MarkdownHeader extends MarkdownParagraph {
8381
8370
  }
8382
8371
  }
8383
8372
 
8384
- var __defProp$2 = Object.defineProperty;
8385
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8386
- var __publicField$2 = (obj, key, value) => {
8387
- __defNormalProp$2(obj, key + "" , value);
8373
+ var __defProp$3 = Object.defineProperty;
8374
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8375
+ var __publicField$3 = (obj, key, value) => {
8376
+ __defNormalProp$3(obj, key + "" , value);
8388
8377
  return value;
8389
8378
  };
8390
8379
  class MarkdownList extends MarkdownBlock {
8391
8380
  constructor(sorted = false) {
8392
8381
  super();
8393
8382
  this.sorted = sorted;
8394
- __publicField$2(this, "items", []);
8383
+ __publicField$3(this, "items", []);
8395
8384
  }
8396
8385
  /**
8397
8386
  * Cada elemento de la lista es un MarkdownBuilder.
@@ -8431,6 +8420,39 @@ class MarkdownList extends MarkdownBlock {
8431
8420
  }
8432
8421
  }
8433
8422
 
8423
+ var __defProp$2 = Object.defineProperty;
8424
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8425
+ var __publicField$2 = (obj, key, value) => {
8426
+ __defNormalProp$2(obj, key + "" , value);
8427
+ return value;
8428
+ };
8429
+ class MarkdownPage extends MarkdownBlock {
8430
+ constructor() {
8431
+ super(...arguments);
8432
+ __publicField$2(this, "items", []);
8433
+ }
8434
+ /**
8435
+ * Cada elemento de la lista es un MarkdownBuilder.
8436
+ *
8437
+ * Si se pasa text como parámetro, este texto será agregado mediante
8438
+ * builder.p(text)
8439
+ */
8440
+ add(text) {
8441
+ const newBuilder = new MarkdownBuilder();
8442
+ if (text)
8443
+ newBuilder.p(text);
8444
+ this.items.push(newBuilder);
8445
+ return newBuilder;
8446
+ }
8447
+ toString() {
8448
+ return `<div class="md-page">
8449
+
8450
+ ${this.items.map((c) => c.toMarkdown()).join("\n")}
8451
+
8452
+ </div>`;
8453
+ }
8454
+ }
8455
+
8434
8456
  var __defProp$1 = Object.defineProperty;
8435
8457
  var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8436
8458
  var __publicField$1 = (obj, key, value) => {
@@ -8593,25 +8615,29 @@ class MarkdownTableOfContents extends MarkdownParagraph {
8593
8615
  * procesados por setUniqueIds) y crea una tabla de contenidos a partir de
8594
8616
  * esos ids
8595
8617
  */
8596
- static makeTableOfContents(title, html) {
8618
+ static makeTableOfContents(props, html) {
8597
8619
  const idMap = {};
8598
8620
  const parser = new DOMParser();
8599
8621
  const parsedDocument = parser.parseFromString(html, "text/html");
8600
- const headers = parsedDocument.querySelectorAll("h1, h2, h3, h4, h5, h6");
8622
+ const headers = parsedDocument.querySelectorAll(
8623
+ new Array(props.maxLevel || 3).fill(1).map((_, i) => `h${i}`).join(", ")
8624
+ );
8601
8625
  const root = document.createElement("ul");
8602
8626
  root.id = "TableOfContents";
8603
8627
  const prevParentMap = { 0: root };
8604
8628
  for (const header of headers) {
8605
- this.setUniqueId(idMap, header);
8606
- const depth = this.getNodeDepth(header);
8607
- const parentDepth = depth - 1;
8608
- this.deletePrevValues(prevParentMap, depth);
8609
- const ulParent = this.getParent(prevParentMap, parentDepth);
8610
- this.createNewLevel(header, ulParent, prevParentMap, parentDepth);
8629
+ if (!props.filter || props.filter(header)) {
8630
+ this.setUniqueId(idMap, header);
8631
+ const depth = this.getNodeDepth(header);
8632
+ const parentDepth = depth - 1;
8633
+ this.deletePrevValues(prevParentMap, depth);
8634
+ const ulParent = this.getParent(prevParentMap, parentDepth);
8635
+ this.createNewLevel(header, ulParent, prevParentMap, parentDepth);
8636
+ }
8611
8637
  }
8612
8638
  return parsedDocument.documentElement.outerHTML.replace(
8613
8639
  tocPlaceholder,
8614
- `<h2>${title}</h2>${root.outerHTML}`
8640
+ `<h2>${props.title}</h2>${root.outerHTML}`
8615
8641
  );
8616
8642
  }
8617
8643
  static deletePrevValues(prevParentMap, depth) {
@@ -8654,7 +8680,7 @@ class MarkdownTableOfContents extends MarkdownParagraph {
8654
8680
  * De esta forma, nos aseguramos que ningún heading tenga un id igual a otro
8655
8681
  */
8656
8682
  static setUniqueId(idMap, element) {
8657
- const replacementRegex = /[\s\(\)]+/g;
8683
+ const replacementRegex = /[\s()]+/g;
8658
8684
  const replacementChar = "-";
8659
8685
  const id = (element.id ? element.id : element.textContent)?.toLocaleLowerCase().trim().replaceAll(replacementRegex, replacementChar);
8660
8686
  const tokens = id.split("_-_", 2);
@@ -8670,8 +8696,8 @@ class MarkdownTableOfContents extends MarkdownParagraph {
8670
8696
  cond = idMap[`${tokens[0]}_-_${tokens[1]}`];
8671
8697
  element.id = `${tokens[0]}_-_${tokens[1]}`;
8672
8698
  }
8673
- static appendTableOfContents(title, html) {
8674
- return this.makeTableOfContents(title, html);
8699
+ static appendTableOfContents(props, html) {
8700
+ return this.makeTableOfContents(props, html);
8675
8701
  }
8676
8702
  }
8677
8703
 
@@ -8723,11 +8749,23 @@ class MarkdownBuilder {
8723
8749
  this.blocks.push(heading);
8724
8750
  return heading;
8725
8751
  }
8752
+ html(text) {
8753
+ this.blocks.push({
8754
+ toString() {
8755
+ return text.replaceAll(/\s{2,}/g, " ");
8756
+ }
8757
+ });
8758
+ }
8726
8759
  p(text) {
8727
8760
  const p = new MarkdownParagraph(text);
8728
8761
  this.blocks.push(p);
8729
8762
  return p;
8730
8763
  }
8764
+ page() {
8765
+ const page = new MarkdownPage();
8766
+ this.blocks.push(page);
8767
+ return page;
8768
+ }
8731
8769
  list(sorted = false) {
8732
8770
  const list = new MarkdownList(sorted);
8733
8771
  this.blocks.push(list);
@@ -8738,6 +8776,14 @@ class MarkdownBuilder {
8738
8776
  this.blocks.push(box);
8739
8777
  return box;
8740
8778
  }
8779
+ pageBreak() {
8780
+ this.blocks.push({
8781
+ toString() {
8782
+ return `
8783
+ ${pageBreakTag}`;
8784
+ }
8785
+ });
8786
+ }
8741
8787
  table(header = [], rows = []) {
8742
8788
  const table = new MarkdownTable(header, rows);
8743
8789
  this.blocks.push(table);
@@ -8752,13 +8798,10 @@ class MarkdownBuilder {
8752
8798
  }
8753
8799
  /**
8754
8800
  * Este método recibe un html y le agrega la tabla de contenidos, dentro de
8755
- * un div con id="TableOfCOntents"
8801
+ * un div con id="TableOfContents"
8756
8802
  */
8757
- addTableOfContents(tableOfContentsTitle, html) {
8758
- return MarkdownTableOfContents.appendTableOfContents(
8759
- tableOfContentsTitle,
8760
- html
8761
- );
8803
+ addTableOfContents(props, html) {
8804
+ return MarkdownTableOfContents.appendTableOfContents(props, html);
8762
8805
  }
8763
8806
  toMarkdown() {
8764
8807
  let markdown = this.blocks.map((current) => current.toString()).join("\n\n");
@@ -8767,11 +8810,11 @@ class MarkdownBuilder {
8767
8810
  }
8768
8811
  toHtml(options) {
8769
8812
  let content = this.toMarkdown();
8770
- if (options?.tableOfContentsTitle)
8771
- content = this.addTableOfContents(options.tableOfContentsTitle, content);
8813
+ if (options?.tocProps)
8814
+ content = this.addTableOfContents(options.tocProps, content);
8772
8815
  return parseMarkdown({ ...options, content });
8773
8816
  }
8774
8817
  }
8775
8818
 
8776
8819
  export { ApiaThemeProvider as A, MarkdownTableOfContents as B, Form as F, MaterialInput as M, Table as T, getColorStates as a, getColorsAndStatesByDefinition as b, getColorsAndStatesByPath as c, getColorsByDefinition as d, getColorsByPath as e, getOneColorState as f, getColorState as g, applyStatesGetColor as h, makeStyledComponent as i, injectStyles as j, getSpacingLayouts as k, spacing as l, markdownExtensions as m, smallButton as n, focusOutline as o, parsePalette as p, getVariant as q, responsive$1 as r, spacingLayouts as s, MarkdownBlock as t, useMainTheme as u, MarkdownBuilder as v, parseMarkdown as w, MarkdownList as x, MarkdownParagraph as y, MarkdownTable as z };
8777
- //# sourceMappingURL=index-DYGQfvLC.js.map
8820
+ //# sourceMappingURL=index-BxGPqOIP.js.map