@sakura-ui/sakura-ui 0.4.2 → 0.5.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 -0
- package/package.json +5 -5
- package/packages/core/package.json +1 -1
- package/packages/core/src/components/Card.tsx +51 -32
- package/packages/core/src/components/Faq.tsx +8 -24
- package/packages/core/src/components/LangSelector.tsx +2 -2
- package/packages/core/src/components/LinkCard.tsx +103 -54
- package/packages/core/src/components/PopoverMenu.tsx +2 -13
- package/packages/core/src/components/Table.tsx +1 -1
- package/packages/core/src/components/index.ts +1 -0
- package/packages/core/src/index.ts +2 -0
- package/packages/core/tests/Card.test.tsx +124 -20
- package/packages/core/tests/Faq.test.tsx +75 -0
- package/packages/core/tests/LinkCard.test.tsx +151 -0
- package/packages/forms/.turbo/turbo-build.log +3 -3
- 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/package.json +1 -1
- package/packages/helper/src/styles.ts +2 -14
- package/packages/markdown/.turbo/turbo-build.log +4 -4
- package/packages/markdown/dist/index.cjs.js +25 -33
- package/packages/markdown/dist/index.es.js +1531 -1534
- package/packages/markdown/dist/types/components/Markdown.d.ts.map +1 -1
- package/packages/markdown/dist/types/plugins/card.d.ts.map +1 -1
- package/packages/markdown/package.json +3 -2
- package/packages/markdown/src/components/Markdown.tsx +35 -11
- package/packages/markdown/src/plugins/card.ts +14 -0
- package/packages/tailwind-theme-plugin/.turbo/turbo-build.log +2 -2
- package/packages/tailwind-theme-plugin/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../src/components/Markdown.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../src/components/Markdown.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAgD/C,OAAO,EASL,KAAK,WAAW,EACjB,MAAM,YAAY,CAAA;AAEnB,UAAU,QAAQ;IAChB,KAAK,EAAE,WAAW,EAAE,CAAA;CACrB;AAED,eAAO,MAAM,eAAe,GAAI,WAAW,QAAQ,2BAelD,CAAA;AA2KD,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,8CAKtB,KAAK,2BA6HP,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../src/plugins/card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAQjC,eAAO,MAAM,UAAU,SACb,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../src/plugins/card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAQjC,eAAO,MAAM,UAAU,SACb,MAAM,IAAI,SA6DnB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sakura-ui/markdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"test:watch": "vitest"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@sakura-ui/core": "^0.
|
|
45
|
+
"@sakura-ui/core": "^0.5.0",
|
|
46
46
|
"react": "^19.2.1",
|
|
47
47
|
"react-dom": "^19.2.1",
|
|
48
48
|
"tailwindcss": "^4.1.17"
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"unist-util-visit": "^5.1.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
+
"@sakura-ui/core": "workspace:*",
|
|
71
72
|
"@testing-library/jest-dom": "catalog:",
|
|
72
73
|
"@testing-library/react": "catalog:",
|
|
73
74
|
"@types/mdast": "^4.0.4",
|
|
@@ -38,10 +38,13 @@ import {
|
|
|
38
38
|
Button,
|
|
39
39
|
Card,
|
|
40
40
|
CardImg,
|
|
41
|
+
CardHeader,
|
|
41
42
|
CardBody,
|
|
42
43
|
CardFooter,
|
|
43
44
|
LinkCard,
|
|
44
45
|
LinkCardHeader,
|
|
46
|
+
LinkCardFooter,
|
|
47
|
+
type CardHeaderAs,
|
|
45
48
|
OverflowContainer
|
|
46
49
|
} from '@sakura-ui/core'
|
|
47
50
|
import {
|
|
@@ -125,14 +128,9 @@ const Article = (props: ArticleProps) => {
|
|
|
125
128
|
const node = restProps['data-node']
|
|
126
129
|
|
|
127
130
|
if (node === 'card') {
|
|
131
|
+
// The href now lives on the title, which is what carries the link.
|
|
128
132
|
if (restProps['data-behavior'] === 'link') {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return (
|
|
132
|
-
<LinkCard href={href} className={cx(className)}>
|
|
133
|
-
{children}
|
|
134
|
-
</LinkCard>
|
|
135
|
-
)
|
|
133
|
+
return <LinkCard className={cx(className)}>{children}</LinkCard>
|
|
136
134
|
}
|
|
137
135
|
return <Card className={cx(className)}>{children}</Card>
|
|
138
136
|
}
|
|
@@ -144,20 +142,36 @@ const Article = (props: ArticleProps) => {
|
|
|
144
142
|
)
|
|
145
143
|
}
|
|
146
144
|
|
|
147
|
-
interface DivProps extends React.ComponentPropsWithoutRef<'div'>, DataProps {
|
|
145
|
+
interface DivProps extends React.ComponentPropsWithoutRef<'div'>, DataProps {
|
|
146
|
+
headingLevel?: CardHeaderAs
|
|
147
|
+
}
|
|
148
148
|
|
|
149
149
|
const Div = (props: DivProps) => {
|
|
150
|
-
const { children, ...restProps } = props
|
|
150
|
+
const { children, headingLevel = 'h3', ...restProps } = props
|
|
151
151
|
|
|
152
152
|
const node = restProps['data-node']
|
|
153
|
+
const isLink = restProps['data-behavior'] === 'link'
|
|
153
154
|
|
|
154
155
|
if (node === 'card-title') {
|
|
155
|
-
|
|
156
|
+
if (isLink) {
|
|
157
|
+
return (
|
|
158
|
+
<LinkCardHeader
|
|
159
|
+
as={headingLevel}
|
|
160
|
+
href={restProps['data-href'] as string}
|
|
161
|
+
>
|
|
162
|
+
{children}
|
|
163
|
+
</LinkCardHeader>
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
return <CardHeader as={headingLevel}>{children}</CardHeader>
|
|
156
167
|
}
|
|
157
168
|
if (node === 'card-description') {
|
|
158
169
|
return <CardBody>{children}</CardBody>
|
|
159
170
|
}
|
|
160
171
|
if (node === 'card-footer') {
|
|
172
|
+
if (isLink) {
|
|
173
|
+
return <LinkCardFooter>{children}</LinkCardFooter>
|
|
174
|
+
}
|
|
161
175
|
return <CardFooter>{children}</CardFooter>
|
|
162
176
|
}
|
|
163
177
|
|
|
@@ -264,6 +278,14 @@ export const Markdown = ({
|
|
|
264
278
|
|
|
265
279
|
const markdown2ReactElements = React.useCallback(
|
|
266
280
|
(md: string) => {
|
|
281
|
+
// Card titles sit in the body of the document, so h3 is the natural base.
|
|
282
|
+
// rehype-shift-heading cannot reach them because they are still divs when
|
|
283
|
+
// it runs, so the same shift is applied here.
|
|
284
|
+
const cardHeadingLevel = `h${Math.min(
|
|
285
|
+
6,
|
|
286
|
+
Math.max(1, 3 + shiftHeding)
|
|
287
|
+
)}` as CardHeaderAs
|
|
288
|
+
|
|
267
289
|
const rhypeReactOptions = {
|
|
268
290
|
...production,
|
|
269
291
|
components: {
|
|
@@ -292,7 +314,9 @@ export const Markdown = ({
|
|
|
292
314
|
th: Th,
|
|
293
315
|
tr: Tr,
|
|
294
316
|
td: Td,
|
|
295
|
-
div:
|
|
317
|
+
div: (props: DivProps) => (
|
|
318
|
+
<Div {...props} headingLevel={cardHeadingLevel} />
|
|
319
|
+
)
|
|
296
320
|
}
|
|
297
321
|
}
|
|
298
322
|
|
|
@@ -33,6 +33,9 @@ export const cardPlugin = () => {
|
|
|
33
33
|
|
|
34
34
|
node.data.hProperties = h(tagName, node.attributes).properties
|
|
35
35
|
|
|
36
|
+
const attributes = node.attributes
|
|
37
|
+
const isLink = attributes['data-behavior'] === 'link'
|
|
38
|
+
|
|
36
39
|
node.children.forEach((child) => {
|
|
37
40
|
if (!isDirective(child)) {
|
|
38
41
|
return
|
|
@@ -50,6 +53,17 @@ export const cardPlugin = () => {
|
|
|
50
53
|
child.attributes = child.attributes ?? {}
|
|
51
54
|
child.attributes['data-node'] = child.name
|
|
52
55
|
|
|
56
|
+
// The title carries the link, so it needs the href of the card. The
|
|
57
|
+
// footer only needs to know that it belongs to a link card, to render
|
|
58
|
+
// the arrow. A child cannot read its parent once this is a React tree,
|
|
59
|
+
// so the marker is copied down here.
|
|
60
|
+
if (isLink && (child.name === 'card-title' || child.name === 'card-footer')) {
|
|
61
|
+
child.attributes['data-behavior'] = 'link'
|
|
62
|
+
if (child.name === 'card-title') {
|
|
63
|
+
child.attributes['data-href'] = attributes['data-href'] || ''
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
53
67
|
child.data.hProperties = h(tagName, child.attributes).properties
|
|
54
68
|
})
|
|
55
69
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
$ rimraf dist
|
|
2
2
|
$ run-p build:*
|
|
3
|
-
$ vite build
|
|
4
3
|
$ tsc && tsc-alias
|
|
4
|
+
$ vite build
|
|
5
5
|
[36mvite v7.3.6 [32mbuilding client environment for production...[36m[39m
|
|
6
6
|
transforming...
|
|
7
7
|
[32m✓[39m 5 modules transformed.
|
|
@@ -9,4 +9,4 @@ rendering chunks...
|
|
|
9
9
|
computing gzip size...
|
|
10
10
|
[2mdist/[22m[36mindex.es.js [39m[1m[2m160.05 kB[22m[1m[22m[2m │ gzip: 10.15 kB[22m
|
|
11
11
|
[2mdist/[22m[36mindex.cjs.js [39m[1m[2m88.17 kB[22m[1m[22m[2m │ gzip: 8.80 kB[22m
|
|
12
|
-
[32m✓ built in
|
|
12
|
+
[32m✓ built in 707ms[39m
|