@hyperbook/markdown 0.44.1 → 0.45.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.
package/dist/index.js CHANGED
@@ -61265,6 +61265,7 @@ function remarkDirectiveTabs_default(ctx) {
61265
61265
  if (!tabsId) {
61266
61266
  tabsId = hash(node3);
61267
61267
  }
61268
+ const instanceId = hash(node3);
61268
61269
  registerDirective(
61269
61270
  file,
61270
61271
  "tabs",
@@ -61291,8 +61292,23 @@ function remarkDirectiveTabs_default(ctx) {
61291
61292
  }
61292
61293
  tabTitleElements.push({
61293
61294
  type: "element",
61294
- tagName: "button",
61295
+ tagName: "input",
61295
61296
  properties: {
61297
+ type: "radio",
61298
+ name: `tabs-${instanceId}`,
61299
+ id: `tab-${instanceId}-${tabId}`,
61300
+ "data-tab-id": tabId,
61301
+ "data-tabs-id": tabsId,
61302
+ class: "tab-input",
61303
+ checked: first
61304
+ },
61305
+ children: []
61306
+ });
61307
+ tabTitleElements.push({
61308
+ type: "element",
61309
+ tagName: "label",
61310
+ properties: {
61311
+ for: `tab-${instanceId}-${tabId}`,
61296
61312
  "data-tab-id": tabId,
61297
61313
  "data-tabs-id": tabsId,
61298
61314
  class: "tab" + (first ? " active" : "")
@@ -61312,7 +61328,15 @@ function remarkDirectiveTabs_default(ctx) {
61312
61328
  });
61313
61329
  first = false;
61314
61330
  }
61331
+ const radioInputs = [];
61332
+ const labelElements = [];
61333
+ for (let i = 0; i < tabTitleElements.length; i += 2) {
61334
+ radioInputs.push(tabTitleElements[i]);
61335
+ labelElements.push(tabTitleElements[i + 1]);
61336
+ }
61315
61337
  data.hChildren = [
61338
+ ...radioInputs,
61339
+ // Radio inputs as direct children
61316
61340
  {
61317
61341
  type: "element",
61318
61342
  tagName: "div",
@@ -61320,7 +61344,8 @@ function remarkDirectiveTabs_default(ctx) {
61320
61344
  class: "tabs",
61321
61345
  "data-tabs-id": tabsId
61322
61346
  },
61323
- children: tabTitleElements
61347
+ children: labelElements
61348
+ // Only labels in tabs div
61324
61349
  },
61325
61350
  ...tabContentElements
61326
61351
  ];
@@ -62509,7 +62534,8 @@ var rehypeHtmlStructure_default = (ctx) => () => {
62509
62534
  type: "element",
62510
62535
  tagName: "html",
62511
62536
  properties: {
62512
- lang: config2.language || "es"
62537
+ lang: config2.language || "es",
62538
+ class: "no-js"
62513
62539
  },
62514
62540
  children: [
62515
62541
  {
@@ -62649,6 +62675,19 @@ var rehypeHtmlStructure_default = (ctx) => () => {
62649
62675
  }
62650
62676
  ]
62651
62677
  },
62678
+ {
62679
+ type: "element",
62680
+ tagName: "script",
62681
+ properties: {},
62682
+ children: [
62683
+ {
62684
+ type: "raw",
62685
+ value: `
62686
+ // Remove no-js class as soon as JavaScript is available
62687
+ document.documentElement.classList.remove('no-js');`
62688
+ }
62689
+ ]
62690
+ },
62652
62691
  {
62653
62692
  type: "element",
62654
62693
  tagName: "script",
@@ -62979,69 +63018,7 @@ var makeNavigationPageElement = (ctx, page) => {
62979
63018
  };
62980
63019
  var makeNavigationSectionElement = (ctx, section) => {
62981
63020
  const { virtual, isEmpty, href, name, pages, sections, expanded } = section;
62982
- const children = [];
62983
63021
  let isExpanded = ctx.navigation.current?.href?.startsWith(href || "") || expanded;
62984
- if (!virtual) {
62985
- if (isEmpty) {
62986
- children.push({
62987
- type: "element",
62988
- tagName: "div",
62989
- properties: {
62990
- class: [
62991
- "collapsible",
62992
- "name",
62993
- "empty",
62994
- ctx.navigation.current?.href === href ? "active" : "",
62995
- isExpanded ? "expanded" : ""
62996
- ].join(" ")
62997
- },
62998
- children: [
62999
- {
63000
- type: "element",
63001
- tagName: "span",
63002
- properties: {
63003
- class: "label"
63004
- },
63005
- children: [
63006
- {
63007
- type: "text",
63008
- value: name
63009
- }
63010
- ]
63011
- }
63012
- ]
63013
- });
63014
- } else {
63015
- children.push({
63016
- type: "element",
63017
- tagName: "div",
63018
- properties: {
63019
- class: [
63020
- "collapsible",
63021
- "name",
63022
- ctx.navigation.current?.href === href ? "active" : "",
63023
- isExpanded ? "expanded" : ""
63024
- ].join(" ")
63025
- },
63026
- children: [
63027
- {
63028
- type: "element",
63029
- tagName: "a",
63030
- properties: {
63031
- href: ctx.makeUrl(href || "", "book"),
63032
- class: "label"
63033
- },
63034
- children: [
63035
- {
63036
- type: "text",
63037
- value: name
63038
- }
63039
- ]
63040
- }
63041
- ]
63042
- });
63043
- }
63044
- }
63045
63022
  const pagesElements = pages.filter((page) => !page.hide).map((page) => makeNavigationPageElement(ctx, page));
63046
63023
  const linksElements = [];
63047
63024
  if (pagesElements.length > 0) {
@@ -63056,22 +63033,86 @@ var makeNavigationSectionElement = (ctx, section) => {
63056
63033
  }
63057
63034
  const sectionElements = sections.filter((s3) => !s3.hide).map((s3) => makeNavigationSectionElement(ctx, s3));
63058
63035
  linksElements.push(...sectionElements);
63059
- children.push({
63060
- type: "element",
63061
- tagName: "div",
63062
- properties: {
63063
- class: virtual ? "links" : "collapsible-content links"
63064
- },
63065
- children: linksElements
63066
- });
63036
+ if (virtual) {
63037
+ return {
63038
+ type: "element",
63039
+ tagName: "div",
63040
+ properties: {
63041
+ class: "virtual-section"
63042
+ },
63043
+ children: [
63044
+ {
63045
+ type: "element",
63046
+ tagName: "div",
63047
+ properties: {
63048
+ class: "links"
63049
+ },
63050
+ children: linksElements
63051
+ }
63052
+ ]
63053
+ };
63054
+ }
63055
+ const summaryChildren = [];
63056
+ if (isEmpty) {
63057
+ summaryChildren.push({
63058
+ type: "element",
63059
+ tagName: "span",
63060
+ properties: {
63061
+ class: "label"
63062
+ },
63063
+ children: [
63064
+ {
63065
+ type: "text",
63066
+ value: name
63067
+ }
63068
+ ]
63069
+ });
63070
+ } else {
63071
+ summaryChildren.push({
63072
+ type: "element",
63073
+ tagName: "a",
63074
+ properties: {
63075
+ href: ctx.makeUrl(href || "", "book"),
63076
+ class: "label"
63077
+ },
63078
+ children: [
63079
+ {
63080
+ type: "text",
63081
+ value: name
63082
+ }
63083
+ ]
63084
+ });
63085
+ }
63067
63086
  return {
63068
63087
  type: "element",
63069
- tagName: "div",
63088
+ tagName: "details",
63070
63089
  properties: {
63071
63090
  "data-id": `_nav:${href}`,
63072
- class: virtual ? "virtual-section" : "section"
63091
+ class: [
63092
+ "section",
63093
+ ctx.navigation.current?.href === href ? "active" : "",
63094
+ isEmpty ? "empty" : ""
63095
+ ].join(" "),
63096
+ open: isExpanded
63073
63097
  },
63074
- children
63098
+ children: [
63099
+ {
63100
+ type: "element",
63101
+ tagName: "summary",
63102
+ properties: {
63103
+ class: "name"
63104
+ },
63105
+ children: summaryChildren
63106
+ },
63107
+ {
63108
+ type: "element",
63109
+ tagName: "div",
63110
+ properties: {
63111
+ class: "links"
63112
+ },
63113
+ children: linksElements
63114
+ }
63115
+ ]
63075
63116
  };
63076
63117
  };
63077
63118
  var makeNavigationElements = (ctx) => {
@@ -64338,10 +64379,8 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
64338
64379
  return [
64339
64380
  {
64340
64381
  type: "element",
64341
- tagName: "button",
64342
- properties: {
64343
- class: "collapsible"
64344
- },
64382
+ tagName: "summary",
64383
+ properties: {},
64345
64384
  children: [
64346
64385
  {
64347
64386
  type: "text",
@@ -64353,7 +64392,7 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
64353
64392
  type: "element",
64354
64393
  tagName: "div",
64355
64394
  properties: {
64356
- class: "collapsible-content"
64395
+ class: "content"
64357
64396
  },
64358
64397
  children: element5.children.flatMap(transformCollapsible)
64359
64398
  }
@@ -64376,7 +64415,7 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
64376
64415
  expectContainerDirective(node3, file, name);
64377
64416
  registerDirective(file, name, [], ["style.css"], []);
64378
64417
  node3.attributes = {};
64379
- data.hName = "div";
64418
+ data.hName = "details";
64380
64419
  data.hProperties = {
64381
64420
  class: "directive-collapsible",
64382
64421
  "data-id": id
@@ -64388,10 +64427,8 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
64388
64427
  data.hChildren = [
64389
64428
  {
64390
64429
  type: "element",
64391
- tagName: "button",
64392
- properties: {
64393
- class: "collapsible"
64394
- },
64430
+ tagName: "summary",
64431
+ properties: {},
64395
64432
  children: [
64396
64433
  {
64397
64434
  type: "text",
@@ -64403,7 +64440,7 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
64403
64440
  type: "element",
64404
64441
  tagName: "div",
64405
64442
  properties: {
64406
- class: "collapsible-content"
64443
+ class: "content"
64407
64444
  },
64408
64445
  children: collapsibleContent
64409
64446
  }