@sakura-ui/sakura-ui 0.5.0 → 0.5.2
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/package.json +5 -5
- package/packages/core/package.json +1 -1
- package/packages/core/src/components/Card.tsx +52 -56
- package/packages/core/src/components/Code.tsx +6 -6
- package/packages/core/src/components/Faq.tsx +30 -26
- package/packages/core/src/components/Heading.tsx +50 -48
- package/packages/core/src/components/Icon.tsx +34 -34
- package/packages/core/src/components/LangSelector.tsx +2 -2
- package/packages/core/src/components/Link.tsx +13 -12
- package/packages/core/src/components/LinkCard.tsx +87 -76
- package/packages/core/src/components/List.tsx +20 -13
- package/packages/core/src/components/OverflowContainer.tsx +9 -9
- package/packages/core/src/components/PopoverMenu.tsx +2 -13
- package/packages/core/src/components/Pre.tsx +9 -9
- package/packages/core/src/components/Table.tsx +30 -25
- package/packages/core/src/components/index.ts +1 -0
- package/packages/core/src/components/styles.ts +42 -0
- package/packages/core/src/index.ts +2 -0
- package/packages/forms/.turbo/turbo-build.log +4 -4
- package/packages/forms/dist/index.cjs.js +13 -21
- package/packages/forms/dist/index.es.js +91 -99
- package/packages/forms/package.json +1 -1
- package/packages/helper/.turbo/turbo-build.log +3 -3
- package/packages/helper/dist/index.cjs.js +6 -14
- package/packages/helper/dist/index.es.js +18 -26
- package/packages/helper/dist/types/styles.d.ts +2 -4
- package/packages/helper/dist/types/styles.d.ts.map +1 -1
- package/packages/helper/node_modules/.bin/vitest +2 -2
- package/packages/helper/package.json +1 -1
- package/packages/helper/src/styles.ts +2 -14
- package/packages/markdown/.turbo/turbo-build.log +4 -4
- package/packages/markdown/README.md +240 -4
- package/packages/markdown/dist/index.cjs.js +71 -145
- package/packages/markdown/dist/index.es.js +2624 -16747
- package/packages/markdown/dist/types/components/Markdown.d.ts +15 -10
- package/packages/markdown/dist/types/components/Markdown.d.ts.map +1 -1
- package/packages/markdown/dist/types/components/index.d.ts +1 -1
- package/packages/markdown/dist/types/components/index.d.ts.map +1 -1
- package/packages/markdown/dist/types/decorate.d.ts +24 -0
- package/packages/markdown/dist/types/decorate.d.ts.map +1 -0
- package/packages/markdown/dist/types/index.d.ts +3 -1
- package/packages/markdown/dist/types/index.d.ts.map +1 -1
- package/packages/markdown/dist/types/marked/attributes.d.ts +31 -0
- package/packages/markdown/dist/types/marked/attributes.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/card.d.ts +3 -0
- package/packages/markdown/dist/types/marked/directives/card.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/context.d.ts +36 -0
- package/packages/markdown/dist/types/marked/directives/context.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/faq.d.ts +11 -0
- package/packages/markdown/dist/types/marked/directives/faq.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/grid.d.ts +9 -0
- package/packages/markdown/dist/types/marked/directives/grid.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/index.d.ts +8 -0
- package/packages/markdown/dist/types/marked/directives/index.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/linkButton.d.ts +6 -0
- package/packages/markdown/dist/types/marked/directives/linkButton.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/youtube.d.ts +3 -0
- package/packages/markdown/dist/types/marked/directives/youtube.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/html.d.ts +15 -0
- package/packages/markdown/dist/types/marked/html.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/index.d.ts +13 -0
- package/packages/markdown/dist/types/marked/index.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/registry.d.ts +8 -0
- package/packages/markdown/dist/types/marked/registry.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/renderer.d.ts +16 -0
- package/packages/markdown/dist/types/marked/renderer.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/tokenizer.d.ts +40 -0
- package/packages/markdown/dist/types/marked/tokenizer.d.ts.map +1 -0
- package/packages/markdown/dist/types/render.d.ts +22 -0
- package/packages/markdown/dist/types/render.d.ts.map +1 -0
- package/packages/markdown/dist/types/sanitize.d.ts +11 -0
- package/packages/markdown/dist/types/sanitize.d.ts.map +1 -0
- package/packages/markdown/node_modules/.bin/marked +55 -0
- package/packages/markdown/package.json +6 -19
- package/packages/markdown/src/components/Markdown.tsx +44 -346
- package/packages/markdown/src/components/index.ts +1 -1
- package/packages/markdown/src/decorate.ts +164 -0
- package/packages/markdown/src/index.ts +3 -1
- package/packages/markdown/src/marked/attributes.ts +88 -0
- package/packages/markdown/src/marked/directives/card.ts +77 -0
- package/packages/markdown/src/marked/directives/context.ts +39 -0
- package/packages/markdown/src/marked/directives/faq.ts +29 -0
- package/packages/markdown/src/marked/directives/grid.ts +50 -0
- package/packages/markdown/src/marked/directives/index.ts +29 -0
- package/packages/markdown/src/marked/directives/linkButton.ts +20 -0
- package/packages/markdown/src/marked/directives/youtube.ts +46 -0
- package/packages/markdown/src/marked/html.ts +55 -0
- package/packages/markdown/src/marked/index.ts +45 -0
- package/packages/markdown/src/marked/registry.ts +34 -0
- package/packages/markdown/src/marked/renderer.ts +52 -0
- package/packages/markdown/src/marked/tokenizer.ts +175 -0
- package/packages/markdown/src/render.ts +55 -0
- package/packages/markdown/src/sanitize.ts +194 -0
- package/packages/markdown/tests/Markdown.test.tsx +122 -0
- package/packages/markdown/tests/__snapshots__/Markdown.test.tsx.snap +451 -0
- package/packages/markdown/tests/anchors.test.ts +108 -0
- package/packages/markdown/tests/fixtures.ts +100 -0
- package/packages/markdown/tests/sanitize.test.ts +168 -0
- package/packages/markdown/tests/server.test.tsx +51 -0
- package/packages/markdown/tests/vitest.setup.ts +4 -0
- package/packages/markdown/tsconfig.test.json +11 -0
- package/packages/markdown/vite.config.ts +5 -1
- package/packages/tailwind-theme-plugin/.turbo/turbo-build.log +1 -1
- package/packages/tailwind-theme-plugin/package.json +1 -1
- package/packages/markdown/dist/types/plugins/attr.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/attr.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/card.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/card.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/cell.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/cell.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/faq.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/faq.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/grid.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/grid.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/headings.d.ts +0 -11
- package/packages/markdown/dist/types/plugins/headings.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/helper.d.ts +0 -9
- package/packages/markdown/dist/types/plugins/helper.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/index.d.ts +0 -9
- package/packages/markdown/dist/types/plugins/index.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/linkButton.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/linkButton.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/youtube.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/youtube.d.ts.map +0 -1
- package/packages/markdown/src/plugins/attr.ts +0 -19
- package/packages/markdown/src/plugins/card.ts +0 -71
- package/packages/markdown/src/plugins/cell.ts +0 -47
- package/packages/markdown/src/plugins/faq.ts +0 -40
- package/packages/markdown/src/plugins/grid.ts +0 -54
- package/packages/markdown/src/plugins/headings.ts +0 -38
- package/packages/markdown/src/plugins/helper.ts +0 -27
- package/packages/markdown/src/plugins/index.ts +0 -8
- package/packages/markdown/src/plugins/linkButton.ts +0 -26
- package/packages/markdown/src/plugins/youtube.ts +0 -49
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { Root } from 'mdast'
|
|
2
|
-
import { h } from 'hastscript'
|
|
3
|
-
import { visit } from 'unist-util-visit'
|
|
4
|
-
import type { Directives } from 'mdast-util-directive'
|
|
5
|
-
import { isContainerDirective, isDirective } from './helper'
|
|
6
|
-
|
|
7
|
-
// This plugin is to turn `::linkButton` into divs, passing arbitrary
|
|
8
|
-
// attributes.
|
|
9
|
-
export const faqPlugin = () => {
|
|
10
|
-
return (tree: Root) => {
|
|
11
|
-
visit(tree, isContainerDirective, (node: Directives) => {
|
|
12
|
-
if (node.name !== 'faq') {
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
node.data = node.data ?? {}
|
|
17
|
-
const tagName = 'dl'
|
|
18
|
-
|
|
19
|
-
node.data.hName = tagName
|
|
20
|
-
|
|
21
|
-
node.data.hProperties = h(tagName, node.attributes || {}).properties
|
|
22
|
-
|
|
23
|
-
node.children.forEach((child) => {
|
|
24
|
-
if (!isDirective(child)) {
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
if (child.name !== 'faq-q' && child.name !== 'faq-a') {
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
child.data = child.data ?? {}
|
|
32
|
-
const tagName = child.name === 'faq-q' ? 'dt' : 'dd'
|
|
33
|
-
|
|
34
|
-
child.data.hName = tagName
|
|
35
|
-
|
|
36
|
-
child.data.hProperties = h(tagName, child.attributes || {}).properties
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { Root } from 'mdast'
|
|
2
|
-
import { h } from 'hastscript'
|
|
3
|
-
import { visit } from 'unist-util-visit'
|
|
4
|
-
import type { Directives } from 'mdast-util-directive'
|
|
5
|
-
import { isContainerDirective } from './helper'
|
|
6
|
-
|
|
7
|
-
// This plugin is to turn `::linkButton` into divs, passing arbitrary
|
|
8
|
-
// attributes.
|
|
9
|
-
export const gridPlugin = () => {
|
|
10
|
-
return (tree: Root) => {
|
|
11
|
-
visit(tree, isContainerDirective, (node: Directives) => {
|
|
12
|
-
if (!node.name.startsWith('grid-cols-')) {
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
node.attributes = node.attributes ?? {}
|
|
17
|
-
|
|
18
|
-
if (node.attributes.as === 'list') {
|
|
19
|
-
node.attributes.as = undefined
|
|
20
|
-
node.attributes['data-behavior'] = 'list'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const gridNum: number = Number.parseInt(
|
|
24
|
-
node.name.split('-').pop() || '1',
|
|
25
|
-
10
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
// Tailwind doesn't generate CSS for string interpolation
|
|
29
|
-
const gridClass: { [key: number]: string } = {
|
|
30
|
-
1: 'md:grid-cols-1',
|
|
31
|
-
2: 'md:grid-cols-2',
|
|
32
|
-
3: 'md:grid-cols-3',
|
|
33
|
-
4: 'md:grid-cols-4',
|
|
34
|
-
5: 'md:grid-cols-5',
|
|
35
|
-
6: 'md:grid-cols-6',
|
|
36
|
-
7: 'md:grid-cols-6',
|
|
37
|
-
8: 'md:grid-cols-6',
|
|
38
|
-
9: 'md:grid-cols-6',
|
|
39
|
-
10: 'md:grid-cols-6',
|
|
40
|
-
11: 'md:grid-cols-6',
|
|
41
|
-
12: 'md:grid-cols-12'
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
node.data = node.data ?? {}
|
|
45
|
-
const tagName = 'div'
|
|
46
|
-
|
|
47
|
-
node.data.hName = tagName
|
|
48
|
-
|
|
49
|
-
node.attributes.class = `flex flex-col md:grid ${gridClass[gridNum]} gap-8`
|
|
50
|
-
|
|
51
|
-
node.data.hProperties = h(tagName, node.attributes).properties
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { Heading, Root } from 'mdast'
|
|
2
|
-
import Slugger from 'github-slugger'
|
|
3
|
-
import { visit } from 'unist-util-visit'
|
|
4
|
-
import { toString as mdastToString } from 'mdast-util-to-string'
|
|
5
|
-
import { treefy } from '@sakura-ui/helper'
|
|
6
|
-
import { isHeading } from './helper'
|
|
7
|
-
|
|
8
|
-
export type HeadingItem = {
|
|
9
|
-
id?: string
|
|
10
|
-
depth: number
|
|
11
|
-
value?: string
|
|
12
|
-
children?: Array<HeadingItem>
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const headingsPlugin = () => {
|
|
16
|
-
return (tree: Root, vFile: { data: Record<string, unknown> }) => {
|
|
17
|
-
const headings: Array<HeadingItem> = []
|
|
18
|
-
const slugger = new Slugger()
|
|
19
|
-
|
|
20
|
-
const getFlatHeadingsList = (node: Heading) => {
|
|
21
|
-
const h: HeadingItem = {
|
|
22
|
-
id: slugger.slug(mdastToString(node)),
|
|
23
|
-
depth: node.depth,
|
|
24
|
-
value: mdastToString(node)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
headings.push(h)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
visit(tree, isHeading, getFlatHeadingsList)
|
|
31
|
-
|
|
32
|
-
if (!vFile.data.fm) {
|
|
33
|
-
vFile.data.fm = {}
|
|
34
|
-
}
|
|
35
|
-
const fm = vFile.data.fm as { headings?: Array<HeadingItem> }
|
|
36
|
-
fm.headings = treefy(headings)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Directives } from 'mdast-util-directive'
|
|
2
|
-
import type { Node } from 'unist'
|
|
3
|
-
import type { Heading } from 'mdast'
|
|
4
|
-
|
|
5
|
-
export const isDirective = (node: Node): node is Directives => {
|
|
6
|
-
return (
|
|
7
|
-
node.type === 'containerDirective' ||
|
|
8
|
-
node.type === 'leafDirective' ||
|
|
9
|
-
node.type === 'textDirective'
|
|
10
|
-
)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const isContainerDirective = (node: Node): node is Directives => {
|
|
14
|
-
return node.type === 'containerDirective'
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const isLeafDirective = (node: Node): node is Directives => {
|
|
18
|
-
return node.type === 'leafDirective'
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const isTextDirective = (node: Node): node is Directives => {
|
|
22
|
-
return node.type === 'textDirective'
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const isHeading = (node: Node): node is Heading => {
|
|
26
|
-
return node.type === 'heading'
|
|
27
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { youtubePlugin } from './youtube'
|
|
2
|
-
export { attrPlugin } from './attr'
|
|
3
|
-
export { linkButtonPlugin } from './linkButton'
|
|
4
|
-
export { gridPlugin } from './grid'
|
|
5
|
-
export { cellPlugin } from './cell'
|
|
6
|
-
export { cardPlugin } from './card'
|
|
7
|
-
export { faqPlugin } from './faq'
|
|
8
|
-
export { headingsPlugin, type HeadingItem } from './headings'
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Root } from 'mdast'
|
|
2
|
-
import { h } from 'hastscript'
|
|
3
|
-
import { visit } from 'unist-util-visit'
|
|
4
|
-
import type { Directives } from 'mdast-util-directive'
|
|
5
|
-
import { isTextDirective } from './helper'
|
|
6
|
-
|
|
7
|
-
// This plugin is to turn `::linkButton` into divs, passing arbitrary
|
|
8
|
-
// attributes.
|
|
9
|
-
export const linkButtonPlugin = () => {
|
|
10
|
-
return (tree: Root) => {
|
|
11
|
-
visit(tree, isTextDirective, (node: Directives) => {
|
|
12
|
-
if (node.name !== 'link-button') return
|
|
13
|
-
|
|
14
|
-
node.data ??= {}
|
|
15
|
-
const data = node.data
|
|
16
|
-
const tagName = 'a'
|
|
17
|
-
|
|
18
|
-
data.hName = tagName
|
|
19
|
-
|
|
20
|
-
node.attributes = node.attributes ?? {}
|
|
21
|
-
node.attributes['data-node'] = node.name
|
|
22
|
-
|
|
23
|
-
data.hProperties = h(tagName, node.attributes).properties
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { Root } from 'mdast'
|
|
2
|
-
import { visit } from 'unist-util-visit'
|
|
3
|
-
import type { Directives } from 'mdast-util-directive'
|
|
4
|
-
import type { Literal } from 'unist'
|
|
5
|
-
import { isDirective } from './helper'
|
|
6
|
-
|
|
7
|
-
// This plugin is turn `::youtube` into iframes.
|
|
8
|
-
export const youtubePlugin = () => {
|
|
9
|
-
return (tree: Root) => {
|
|
10
|
-
visit(tree, isDirective, (node: Directives) => {
|
|
11
|
-
if (node.type === 'containerDirective' || node.type === 'leafDirective') {
|
|
12
|
-
if (node.name !== 'youtube') return
|
|
13
|
-
|
|
14
|
-
node.data ??= {}
|
|
15
|
-
const data = node.data
|
|
16
|
-
const attributes = node.attributes || {}
|
|
17
|
-
const id = attributes.id
|
|
18
|
-
|
|
19
|
-
if (!id) {
|
|
20
|
-
console.error('Unexpected missing `id` on `youtube` directive')
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const child = node.children[0] as Literal
|
|
24
|
-
|
|
25
|
-
const title = child.value as string
|
|
26
|
-
const width = attributes.width ?? undefined
|
|
27
|
-
const height = attributes.height ?? undefined
|
|
28
|
-
const allow =
|
|
29
|
-
attributes.allow ||
|
|
30
|
-
'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture'
|
|
31
|
-
const referrerpolicy =
|
|
32
|
-
attributes.referrerpolicy || 'strict-origin-when-cross-origin'
|
|
33
|
-
|
|
34
|
-
data.hName = 'iframe'
|
|
35
|
-
data.hProperties = {
|
|
36
|
-
title: title,
|
|
37
|
-
src: `https://www.youtube-nocookie.com/embed/${id}`,
|
|
38
|
-
width: width,
|
|
39
|
-
height: height,
|
|
40
|
-
frameBorder: '0',
|
|
41
|
-
allow: allow,
|
|
42
|
-
referrerpolicy: referrerpolicy,
|
|
43
|
-
allowFullScreen: true,
|
|
44
|
-
loading: 'lazy'
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
}
|