@sakura-ui/sakura-ui 0.2.0 → 0.4.1
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/README.md +77 -6
- package/package.json +28 -21
- package/packages/core/package.json +30 -17
- package/packages/core/src/components/Button.tsx +33 -32
- package/packages/core/src/components/Card.tsx +37 -20
- package/packages/core/src/components/Code.tsx +6 -4
- package/packages/core/src/components/Faq.tsx +13 -7
- package/packages/core/src/components/Heading.tsx +42 -32
- package/packages/core/src/components/Icon.tsx +43 -13
- package/packages/core/src/components/IconButton.tsx +54 -43
- package/packages/core/src/components/LangSelector.tsx +135 -0
- package/packages/core/src/components/Link.tsx +37 -66
- package/packages/core/src/components/LinkCard.tsx +126 -0
- package/packages/core/src/components/List.tsx +14 -12
- package/packages/core/src/components/MenuButton.tsx +112 -0
- package/packages/core/src/components/NavigationItem.tsx +41 -0
- package/packages/core/src/components/NotificationBanner.tsx +20 -0
- package/packages/core/src/components/OverflowContainer.tsx +24 -0
- package/packages/core/src/components/PopoverMenu.tsx +82 -0
- package/packages/core/src/components/Pre.tsx +6 -4
- package/packages/core/src/components/Table.tsx +31 -25
- package/packages/core/src/components/buttonStyle.ts +43 -32
- package/packages/core/src/components/index.ts +13 -25
- package/packages/core/src/icons/Close.tsx +21 -0
- package/packages/core/src/icons/CloseMobile.tsx +43 -0
- package/packages/core/src/icons/KeyboardArrowDown.tsx +24 -0
- package/packages/core/src/icons/Language.tsx +25 -0
- package/packages/core/src/icons/LanguageMobile.tsx +40 -0
- package/packages/core/src/icons/Menu.tsx +24 -0
- package/packages/core/src/icons/MenuMobile.tsx +40 -0
- package/packages/core/src/icons/index.ts +8 -0
- package/packages/core/src/icons/props.ts +5 -0
- package/packages/core/src/index.ts +10 -28
- package/packages/core/src/type.d.ts +1 -0
- package/packages/core/tests/Button.test.tsx +20 -10
- package/packages/core/tests/Card.test.tsx +16 -11
- package/packages/core/tests/IconButton.test.tsx +57 -0
- package/packages/core/tests/Link.test.tsx +60 -0
- package/packages/core/tests/vitest.setup.ts +1 -0
- package/packages/core/tsconfig.node.json +3 -2
- package/packages/core/vite.config.ts +2 -1
- package/packages/forms/.turbo/turbo-build.log +12 -0
- package/packages/forms/dist/index.cjs.js +183 -131
- package/packages/forms/dist/index.es.js +750 -1062
- package/packages/forms/dist/types/components/Checkbox.d.ts +9 -4
- package/packages/forms/dist/types/components/Checkbox.d.ts.map +1 -1
- package/packages/forms/dist/types/components/FieldsetControl.d.ts +14 -9
- package/packages/forms/dist/types/components/FieldsetControl.d.ts.map +1 -1
- package/packages/forms/dist/types/components/FileInput.d.ts +10 -3
- package/packages/forms/dist/types/components/FileInput.d.ts.map +1 -1
- package/packages/forms/dist/types/components/Input.d.ts +9 -4
- package/packages/forms/dist/types/components/Input.d.ts.map +1 -1
- package/packages/forms/dist/types/components/LabelControl.d.ts +13 -8
- package/packages/forms/dist/types/components/LabelControl.d.ts.map +1 -1
- package/packages/forms/dist/types/components/Radio.d.ts +9 -4
- package/packages/forms/dist/types/components/Radio.d.ts.map +1 -1
- package/packages/forms/dist/types/components/Select.d.ts +9 -4
- package/packages/forms/dist/types/components/Select.d.ts.map +1 -1
- package/packages/forms/dist/types/components/Textarea.d.ts +8 -3
- package/packages/forms/dist/types/components/Textarea.d.ts.map +1 -1
- package/packages/forms/dist/types/components/controlled/CheckboxGroup.d.ts +16 -11
- package/packages/forms/dist/types/components/controlled/CheckboxGroup.d.ts.map +1 -1
- package/packages/forms/dist/types/components/controlled/RadioGroup.d.ts +17 -12
- package/packages/forms/dist/types/components/controlled/RadioGroup.d.ts.map +1 -1
- package/packages/forms/dist/types/components/index.d.ts +8 -8
- package/packages/forms/dist/types/components/index.d.ts.map +1 -1
- package/packages/forms/dist/types/components/inputStyle.d.ts +1 -1
- package/packages/forms/dist/types/components/inputStyle.d.ts.map +1 -1
- package/packages/forms/dist/types/index.d.ts +0 -1
- package/packages/forms/dist/types/index.d.ts.map +1 -1
- package/packages/forms/node_modules/.bin/autoprefixer +44 -6
- package/packages/forms/package.json +21 -16
- package/packages/forms/src/components/Checkbox.tsx +76 -80
- package/packages/forms/src/components/FieldsetControl.tsx +21 -28
- package/packages/forms/src/components/FileInput.tsx +92 -63
- package/packages/forms/src/components/Input.tsx +29 -31
- package/packages/forms/src/components/LabelControl.tsx +19 -25
- package/packages/forms/src/components/Radio.tsx +68 -69
- package/packages/forms/src/components/Select.tsx +65 -65
- package/packages/forms/src/components/Textarea.tsx +49 -54
- package/packages/forms/src/components/controlled/CheckboxGroup.tsx +15 -17
- package/packages/forms/src/components/controlled/RadioGroup.tsx +16 -18
- package/packages/forms/src/components/index.ts +8 -8
- package/packages/forms/src/components/inputStyle.ts +7 -8
- package/packages/forms/src/index.ts +0 -11
- package/packages/forms/tests/Checkbox.test.tsx +44 -0
- package/packages/forms/tests/FieldsetControl.test.tsx +68 -11
- package/packages/forms/tests/FileInput.test.tsx +25 -0
- package/packages/forms/tests/Input.test.tsx +12 -83
- package/packages/forms/tests/LabelControl.test.tsx +88 -20
- package/packages/forms/tests/Radio.test.tsx +23 -78
- package/packages/forms/tests/Select.test.tsx +30 -0
- package/packages/forms/tests/Textarea.test.tsx +25 -0
- package/packages/forms/tests/vitest.setup.ts +1 -0
- package/packages/forms/tsconfig.node.json +3 -2
- package/packages/forms/vite.config.ts +2 -1
- package/packages/helper/.turbo/turbo-build.log +12 -0
- package/packages/helper/dist/index.cjs.js +76 -0
- package/packages/helper/dist/index.es.js +119 -0
- package/packages/helper/dist/types/calc.d.ts +2 -0
- package/packages/helper/dist/types/calc.d.ts.map +1 -0
- package/packages/{forms/dist/types/utils/class.d.ts → helper/dist/types/cx.d.ts} +1 -1
- package/packages/helper/dist/types/cx.d.ts.map +1 -0
- package/packages/helper/dist/types/index.d.ts +6 -0
- package/packages/helper/dist/types/index.d.ts.map +1 -0
- package/packages/helper/dist/types/querySelector.d.ts +2 -0
- package/packages/helper/dist/types/querySelector.d.ts.map +1 -0
- package/packages/helper/dist/types/styles.d.ts +22 -0
- package/packages/helper/dist/types/styles.d.ts.map +1 -0
- package/packages/helper/dist/types/treefy.d.ts +8 -0
- package/packages/helper/dist/types/treefy.d.ts.map +1 -0
- package/packages/helper/node_modules/.bin/vitest +55 -0
- package/packages/helper/package.json +50 -0
- package/packages/helper/src/calc.ts +1 -0
- package/packages/helper/src/cx.ts +2 -0
- package/packages/helper/src/index.ts +5 -0
- package/packages/helper/src/querySelector.ts +20 -0
- package/packages/helper/src/styles.ts +114 -0
- package/packages/helper/src/treefy.ts +24 -0
- package/packages/helper/tests/calc.test.ts +22 -0
- package/packages/helper/tests/cx.test.ts +30 -0
- package/packages/helper/tests/querySelector.test.ts +24 -0
- package/packages/helper/tests/treefy.test.ts +111 -0
- package/packages/helper/tests/vitest.setup.ts +2 -0
- package/packages/helper/tsconfig.json +13 -0
- package/packages/helper/tsconfig.node.json +6 -0
- package/packages/helper/vite.config.ts +26 -0
- package/packages/markdown/.turbo/turbo-build.log +12 -0
- package/packages/markdown/README.md +129 -0
- package/packages/markdown/dist/index.cjs.js +149 -0
- package/packages/markdown/dist/index.es.js +16960 -0
- package/packages/markdown/dist/types/components/Markdown.d.ts +15 -0
- package/packages/markdown/dist/types/components/Markdown.d.ts.map +1 -0
- package/packages/markdown/dist/types/components/index.d.ts +2 -0
- package/packages/markdown/dist/types/components/index.d.ts.map +1 -0
- package/packages/markdown/dist/types/index.d.ts +2 -0
- package/packages/markdown/dist/types/index.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/attr.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/attr.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/card.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/card.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/cell.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/cell.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/faq.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/faq.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/grid.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/grid.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/headings.d.ts +11 -0
- package/packages/markdown/dist/types/plugins/headings.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/helper.d.ts +9 -0
- package/packages/markdown/dist/types/plugins/helper.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/index.d.ts +9 -0
- package/packages/markdown/dist/types/plugins/index.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/linkButton.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/linkButton.d.ts.map +1 -0
- package/packages/markdown/dist/types/plugins/youtube.d.ts +3 -0
- package/packages/markdown/dist/types/plugins/youtube.d.ts.map +1 -0
- package/packages/markdown/node_modules/.bin/autoprefixer +55 -0
- package/packages/markdown/package.json +84 -0
- package/packages/markdown/src/components/Markdown.tsx +365 -0
- package/packages/markdown/src/components/index.ts +1 -0
- package/packages/markdown/src/global.d.ts +9 -0
- package/packages/markdown/src/index.ts +1 -0
- package/packages/markdown/src/plugins/attr.ts +19 -0
- package/packages/markdown/src/plugins/card.ts +57 -0
- package/packages/markdown/src/plugins/cell.ts +47 -0
- package/packages/markdown/src/plugins/faq.ts +40 -0
- package/packages/markdown/src/plugins/grid.ts +54 -0
- package/packages/markdown/src/plugins/headings.ts +38 -0
- package/packages/markdown/src/plugins/helper.ts +27 -0
- package/packages/markdown/src/plugins/index.ts +8 -0
- package/packages/markdown/src/plugins/linkButton.ts +26 -0
- package/packages/markdown/src/plugins/youtube.ts +49 -0
- package/packages/markdown/tsconfig.json +13 -0
- package/packages/markdown/tsconfig.node.json +7 -0
- package/packages/markdown/vite.config.ts +30 -0
- package/packages/tailwind-theme-plugin/#package.json# +51 -0
- package/packages/tailwind-theme-plugin/.turbo/turbo-build.log +12 -0
- package/packages/tailwind-theme-plugin/dist/index.cjs.js +1 -1
- package/packages/tailwind-theme-plugin/dist/index.es.js +4970 -6093
- package/packages/tailwind-theme-plugin/dist/types/index.d.ts +1 -4
- package/packages/tailwind-theme-plugin/dist/types/index.d.ts.map +1 -1
- package/packages/tailwind-theme-plugin/node_modules/.bin/autoprefixer +44 -6
- package/packages/tailwind-theme-plugin/package.json +11 -9
- package/packages/tailwind-theme-plugin/src/index.ts +241 -349
- package/packages/tailwind-theme-plugin/vite.config.ts +2 -0
- package/packages/core/src/libs/cx.ts +0 -2
- package/packages/core/src/libs/forward-ref.ts +0 -44
- package/packages/core/src/types/component.ts +0 -83
- package/packages/forms/dist/types/utils/class.d.ts.map +0 -1
- package/packages/forms/node_modules/.bin/acorn +0 -17
- package/packages/forms/node_modules/.bin/browserslist +0 -17
- package/packages/forms/node_modules/.bin/eslint +0 -17
- package/packages/forms/node_modules/.bin/tailwind +0 -17
- package/packages/forms/node_modules/.bin/tailwindcss +0 -17
- package/packages/forms/node_modules/.bin/ts-node +0 -17
- package/packages/forms/node_modules/.bin/ts-node-cwd +0 -17
- package/packages/forms/node_modules/.bin/ts-node-esm +0 -17
- package/packages/forms/node_modules/.bin/ts-node-script +0 -17
- package/packages/forms/node_modules/.bin/ts-node-transpile-only +0 -17
- package/packages/forms/node_modules/.bin/ts-script +0 -17
- package/packages/forms/node_modules/.bin/vitest +0 -17
- package/packages/forms/src/utils/class.ts +0 -2
- package/packages/tailwind-theme-plugin/node_modules/.bin/browserslist +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/tailwind +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/tailwindcss +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-cwd +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-esm +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-script +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-transpile-only +0 -17
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-script +0 -17
|
@@ -0,0 +1,19 @@
|
|
|
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 { isDirective } from './helper'
|
|
6
|
+
|
|
7
|
+
// This plugin is an example to turn `::node` into divs, passing arbitrary
|
|
8
|
+
// attributes.
|
|
9
|
+
export const attrPlugin = () => {
|
|
10
|
+
return (tree: Root) => {
|
|
11
|
+
visit(tree, isDirective, (node: Directives) => {
|
|
12
|
+
node.data = node.data ?? {}
|
|
13
|
+
const hast = h(node.name, node.attributes || {})
|
|
14
|
+
|
|
15
|
+
node.data.hName = hast.tagName
|
|
16
|
+
node.data.hProperties = hast.properties
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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 { isDirective } from './helper'
|
|
6
|
+
|
|
7
|
+
// This plugin is to turn `:::card` into divs, passing arbitrary
|
|
8
|
+
// attributes.
|
|
9
|
+
export const cardPlugin = () => {
|
|
10
|
+
return (tree: Root) => {
|
|
11
|
+
visit(tree, isDirective, (node: Directives) => {
|
|
12
|
+
if (node.type !== 'containerDirective') {
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
if (node.name !== 'card') {
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
node.data = node.data ?? {}
|
|
20
|
+
|
|
21
|
+
const tagName = 'article'
|
|
22
|
+
|
|
23
|
+
node.data.hName = tagName
|
|
24
|
+
|
|
25
|
+
node.attributes = node.attributes ?? {}
|
|
26
|
+
node.attributes['data-node'] = node.name
|
|
27
|
+
|
|
28
|
+
if (node.attributes.as === 'link') {
|
|
29
|
+
node.attributes.as = undefined
|
|
30
|
+
node.attributes['data-behavior'] = 'link'
|
|
31
|
+
node.attributes['data-href'] = node.attributes.href || ''
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
node.data.hProperties = h(tagName, node.attributes).properties
|
|
35
|
+
|
|
36
|
+
node.children.forEach((child) => {
|
|
37
|
+
if (!isDirective(child)) {
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
child.data = child.data ?? {}
|
|
42
|
+
|
|
43
|
+
let tagName = 'div'
|
|
44
|
+
if (child.name === 'card-img') {
|
|
45
|
+
tagName = 'img'
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
child.data.hName = tagName
|
|
49
|
+
|
|
50
|
+
child.attributes = child.attributes ?? {}
|
|
51
|
+
child.attributes['data-node'] = child.name
|
|
52
|
+
|
|
53
|
+
child.data.hProperties = h(tagName, child.attributes).properties
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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 `:::cell` into divs, passing arbitrary
|
|
8
|
+
// attributes.
|
|
9
|
+
export const cellPlugin = () => {
|
|
10
|
+
return (tree: Root) => {
|
|
11
|
+
visit(tree, isContainerDirective, (node: Directives) => {
|
|
12
|
+
if (node.name !== 'cell') {
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
node.data = node.data ?? {}
|
|
17
|
+
const tagName = 'div'
|
|
18
|
+
|
|
19
|
+
node.data.hName = tagName
|
|
20
|
+
|
|
21
|
+
node.attributes = node.attributes ?? {}
|
|
22
|
+
node.attributes['data-node'] = node.name
|
|
23
|
+
|
|
24
|
+
node.data.hProperties = h(tagName, node.attributes).properties
|
|
25
|
+
|
|
26
|
+
node.children.forEach((child) => {
|
|
27
|
+
if (!isDirective(child)) {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
if (child.name !== 'cell-img') {
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
child.data = child.data ?? {}
|
|
35
|
+
|
|
36
|
+
const tagName = 'img'
|
|
37
|
+
|
|
38
|
+
child.data.hName = tagName
|
|
39
|
+
|
|
40
|
+
child.attributes = child.attributes ?? {}
|
|
41
|
+
child.attributes['data-node'] = child.name
|
|
42
|
+
|
|
43
|
+
child.data.hProperties = h(tagName, child.attributes).properties
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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'
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declarationDir": "./dist/types",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"baseUrl": ".",
|
|
7
|
+
"paths": {
|
|
8
|
+
"@/*": ["src/*"]
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"include": ["src"],
|
|
12
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
13
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="vitest" />
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
|
+
import { defineConfig } from 'vite'
|
|
4
|
+
import react from '@vitejs/plugin-react-swc'
|
|
5
|
+
import { peerDependencies } from './package.json'
|
|
6
|
+
|
|
7
|
+
// https://vitejs.dev/config/
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
plugins: [react()],
|
|
10
|
+
resolve: {
|
|
11
|
+
alias: {
|
|
12
|
+
'@': resolve(__dirname, 'src')
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
build: {
|
|
16
|
+
lib: {
|
|
17
|
+
entry: resolve(__dirname, 'src', 'index.ts'),
|
|
18
|
+
formats: ['es', 'cjs'],
|
|
19
|
+
fileName: (ext: string) => `index.${ext}.js`
|
|
20
|
+
},
|
|
21
|
+
rollupOptions: {
|
|
22
|
+
external: [...Object.keys(peerDependencies)]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
test: {
|
|
26
|
+
globals: true,
|
|
27
|
+
environment: 'happy-dom',
|
|
28
|
+
setupFiles: 'tests/vitest.setup.ts'
|
|
29
|
+
}
|
|
30
|
+
})
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sakura-ui/tailwind-theme-plugin",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"author": "glassonion1",
|
|
7
|
+
"homepage": "https://github.com/glassonion1/sakura-ui",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+ssh://git@github.com:glassonion1/sakura-ui.git",
|
|
11
|
+
"directory": "packages/config"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "dist/index.cjs.js",
|
|
16
|
+
"types": "dist/types/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/types/index.d.ts",
|
|
20
|
+
"require": "./dist/index.cjs.js",
|
|
21
|
+
"import": "./dist/index.es.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"lint": "run-s lint:*",
|
|
33
|
+
"lint:eslint": "biome lint ./",
|
|
34
|
+
"lint:prettier": "prettier --write --ignore-path .gitignore './src/*.ts'",
|
|
35
|
+
"prebuild": "rimraf dist",
|
|
36
|
+
"build": "run-p build:*",
|
|
37
|
+
"build:scripts": "vite build",
|
|
38
|
+
"build:types": "tsc && tsc-alias",
|
|
39
|
+
"test": "vitest"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"tailwindcss": "^4.1.17"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@digital-go-jp/design-tokens": "^1.1.0",
|
|
46
|
+
"@tailwindcss/vite": "catalog:",
|
|
47
|
+
"autoprefixer": "catalog:",
|
|
48
|
+
"postcss": "catalog:",
|
|
49
|
+
"tailwindcss": "catalog:"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
$ rimraf dist
|
|
2
|
+
$ run-p build:*
|
|
3
|
+
$ vite build
|
|
4
|
+
$ tsc && tsc-alias
|
|
5
|
+
[36mvite v7.3.6 [32mbuilding client environment for production...[36m[39m
|
|
6
|
+
transforming...
|
|
7
|
+
[32m✓[39m 5 modules transformed.
|
|
8
|
+
rendering chunks...
|
|
9
|
+
computing gzip size...
|
|
10
|
+
[2mdist/[22m[36mindex.es.js [39m[1m[2m160.05 kB[22m[1m[22m[2m │ gzip: 10.15 kB[22m
|
|
11
|
+
[2mdist/[22m[36mindex.cjs.js [39m[1m[2m88.17 kB[22m[1m[22m[2m │ gzip: 8.80 kB[22m
|
|
12
|
+
[32m✓ built in 609ms[39m
|