@sakura-ui/sakura-ui 0.5.5 → 0.5.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"decorate.d.ts","sourceRoot":"","sources":["../../src/decorate.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAA;CACzB,CAAA;AAoED,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,WAAW,EAAE,CAAA;CACxB,CAAA;AAID,eAAO,MAAM,QAAQ,GACnB,MAAM,gBAAgB,GAAG,OAAO,EAChC,UAAU,QAAQ,EAClB,SAAS,eAAe,KACvB,cAuEF,CAAA"}
1
+ {"version":3,"file":"decorate.d.ts","sourceRoot":"","sources":["../../src/decorate.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAA;CACzB,CAAA;AAoED,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,WAAW,EAAE,CAAA;CACxB,CAAA;AAID,eAAO,MAAM,QAAQ,GACnB,MAAM,gBAAgB,GAAG,OAAO,EAChC,UAAU,QAAQ,EAClB,SAAS,eAAe,KACvB,cA0EF,CAAA"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sakura-ui/markdown",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "markdown"
@@ -1,4 +1,5 @@
1
1
  import { styles } from '@sakura-ui/core'
2
+ import { treefy } from '@sakura-ui/helper'
2
3
  import Slugger from 'github-slugger'
3
4
  import { classNames } from './marked/html'
4
5
 
@@ -165,7 +166,10 @@ export const decorate = (
165
166
  container.appendChild(table)
166
167
  }
167
168
 
169
+ // Nested, so that the table of contents can show a heading under the one it
170
+ // belongs to. Cut to depth before nesting: filtering the tree afterwards
171
+ // would only reach the headings sitting at its root.
168
172
  return {
169
- headings: flat.filter((h) => h.depth <= tocMaxDepth) as HeadingItem[]
173
+ headings: treefy(flat.filter((h) => h.depth <= tocMaxDepth))
170
174
  }
171
175
  }
@@ -101,6 +101,23 @@ describe('Markdown', () => {
101
101
  expect(html).toMatchSnapshot()
102
102
  })
103
103
 
104
+ // The nesting is read from the DOM rather than left to the snapshot, so a
105
+ // return to one flat list says which shape was lost.
106
+ it('should put a heading under the one it belongs to', async () => {
107
+ render(<Markdown showToc>{'# 章1\n\n## 節1\n\n## 節2\n\n# 章2'}</Markdown>)
108
+ const toc = await screen.findByRole('navigation')
109
+
110
+ const chapters = toc.querySelectorAll(':scope > ul > li')
111
+ expect(
112
+ Array.from(chapters, (li) => li.querySelector('a')?.textContent)
113
+ ).toEqual(['章1', '章2'])
114
+
115
+ const sections = chapters[0].querySelectorAll(':scope > ul > li')
116
+ expect(
117
+ Array.from(sections, (li) => li.querySelector('a')?.textContent)
118
+ ).toEqual(['節1', '節2'])
119
+ })
120
+
104
121
  it('should use the given title', async () => {
105
122
  render(
106
123
  <Markdown showToc tocTitle="もくじ">
@@ -301,7 +301,12 @@ exports[`Markdown > table of contents > should render the table of contents when
301
301
 
302
302
  disabled:border-solid-gray-500
303
303
  [overflow-wrap:anywhere]
304
- " href="#章1">章1</a></li><li><a class="
304
+ " href="#章1">章1</a><ul class="
305
+ list-disc
306
+ [&amp;_&amp;]:list-circle
307
+ [&amp;_&amp;_&amp;]:list-square
308
+ pl-8
309
+ "><li><a class="
305
310
  cursor-pointer
306
311
  text-blue-1000
307
312
  active:text-orange-700
@@ -355,7 +360,7 @@ exports[`Markdown > table of contents > should render the table of contents when
355
360
 
356
361
  disabled:border-solid-gray-500
357
362
  [overflow-wrap:anywhere]
358
- " href="#節2">節2</a></li><li><a class="
363
+ " href="#節2">節2</a></li></ul></li><li><a class="
359
364
  cursor-pointer
360
365
  text-blue-1000
361
366
  active:text-orange-700
@@ -9,4 +9,4 @@ rendering chunks...
9
9
  computing gzip size...
10
10
  dist/index.es.js 160.05 kB │ gzip: 10.15 kB
11
11
  dist/index.cjs.js 88.17 kB │ gzip: 8.80 kB
12
- ✓ built in 502ms
12
+ ✓ built in 522ms