@sakura-ui/sakura-ui 0.2.0 → 0.3.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/README.md +16 -6
- package/package.json +21 -15
- package/packages/core/package.json +26 -15
- package/packages/core/src/components/Button.tsx +33 -32
- package/packages/core/src/components/Card.tsx +29 -17
- 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 +38 -66
- package/packages/core/src/components/LinkCard.tsx +91 -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/OverflowContainer.tsx +24 -0
- package/packages/core/src/components/PopoverMenu.tsx +81 -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 +42 -31
- 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 +9 -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/forms/.turbo/turbo-build.log +22 -0
- package/packages/forms/dist/index.cjs.js +199 -120
- package/packages/forms/dist/index.es.js +890 -1023
- 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 +2 -2
- package/packages/forms/node_modules/.bin/tailwind +2 -2
- package/packages/forms/node_modules/.bin/tailwindcss +2 -2
- package/packages/forms/node_modules/.bin/ts-node +4 -4
- package/packages/forms/node_modules/.bin/ts-node-cwd +4 -4
- package/packages/forms/node_modules/.bin/ts-node-esm +4 -4
- package/packages/forms/node_modules/.bin/ts-node-script +4 -4
- package/packages/forms/node_modules/.bin/ts-node-transpile-only +4 -4
- package/packages/forms/node_modules/.bin/ts-script +4 -4
- package/packages/forms/node_modules/.bin/tsc +17 -0
- package/packages/forms/node_modules/.bin/tsserver +17 -0
- package/packages/forms/node_modules/.vite/vitest/results.json +1 -0
- package/packages/forms/package.json +17 -14
- 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 +87 -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 +66 -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 +62 -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 +82 -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/helper/.turbo/turbo-build.log +23 -0
- package/packages/helper/dist/index.cjs.js +78 -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/package.json +40 -0
- package/packages/helper/src/calc.ts +1 -0
- package/packages/helper/src/index.ts +5 -0
- package/packages/helper/src/querySelector.ts +20 -0
- package/packages/helper/src/styles.ts +116 -0
- package/packages/helper/src/treefy.ts +22 -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 +22 -0
- package/packages/markdown/README.md +129 -0
- package/packages/markdown/dist/index.cjs.js +175 -0
- package/packages/markdown/dist/index.es.js +17098 -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 +9 -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 +17 -0
- package/packages/markdown/node_modules/.bin/tailwind +17 -0
- package/packages/markdown/node_modules/.bin/tailwindcss +17 -0
- package/packages/markdown/node_modules/.bin/ts-node +17 -0
- package/packages/markdown/node_modules/.bin/ts-node-cwd +17 -0
- package/packages/markdown/node_modules/.bin/ts-node-esm +17 -0
- package/packages/markdown/node_modules/.bin/ts-node-script +17 -0
- package/packages/markdown/node_modules/.bin/ts-node-transpile-only +17 -0
- package/packages/markdown/node_modules/.bin/ts-script +17 -0
- package/packages/markdown/node_modules/.bin/tsc +17 -0
- package/packages/markdown/node_modules/.bin/tsserver +17 -0
- package/packages/markdown/package.json +83 -0
- package/packages/markdown/src/components/Markdown.tsx +361 -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 +51 -0
- package/packages/markdown/src/plugins/headings.ts +35 -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 +25 -0
- package/packages/markdown/src/plugins/youtube.ts +48 -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/.turbo/turbo-build.log +22 -0
- package/packages/tailwind-theme-plugin/dist/index.cjs.js +1 -1
- package/packages/tailwind-theme-plugin/dist/index.es.js +5354 -6111
- package/packages/tailwind-theme-plugin/dist/types/index.d.ts +1 -1
- package/packages/tailwind-theme-plugin/dist/types/index.d.ts.map +1 -1
- package/packages/tailwind-theme-plugin/node_modules/.bin/autoprefixer +2 -2
- package/packages/tailwind-theme-plugin/node_modules/.bin/tailwind +2 -2
- package/packages/tailwind-theme-plugin/node_modules/.bin/tailwindcss +2 -2
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node +4 -4
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-cwd +4 -4
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-esm +4 -4
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-script +4 -4
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-node-transpile-only +4 -4
- package/packages/tailwind-theme-plugin/node_modules/.bin/ts-script +4 -4
- package/packages/tailwind-theme-plugin/node_modules/.bin/tsc +17 -0
- package/packages/tailwind-theme-plugin/node_modules/.bin/tsserver +17 -0
- package/packages/tailwind-theme-plugin/package.json +6 -6
- package/packages/tailwind-theme-plugin/src/index.ts +226 -291
- 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/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/{core/src/libs → helper/src}/cx.ts +0 -0
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export {
|
|
2
2
|
Button,
|
|
3
|
+
MenuButton,
|
|
3
4
|
Card,
|
|
4
5
|
CardImg,
|
|
5
6
|
CardHeader,
|
|
6
7
|
CardBody,
|
|
7
8
|
CardFooter,
|
|
9
|
+
LinkCard,
|
|
10
|
+
LinkCardHeader,
|
|
8
11
|
Code,
|
|
9
12
|
Faq,
|
|
10
13
|
Question,
|
|
@@ -27,32 +30,10 @@ export {
|
|
|
27
30
|
Tbody,
|
|
28
31
|
Th,
|
|
29
32
|
Tr,
|
|
30
|
-
Td
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
CardImgProps,
|
|
37
|
-
CardHeaderProps,
|
|
38
|
-
CardBodyProps,
|
|
39
|
-
CardFooterProps,
|
|
40
|
-
CodeProps,
|
|
41
|
-
FaqProps,
|
|
42
|
-
QuestionProps,
|
|
43
|
-
AnswerProps,
|
|
44
|
-
HeadingProps,
|
|
45
|
-
IconProps,
|
|
46
|
-
IconButtonProps,
|
|
47
|
-
LinkProps,
|
|
48
|
-
OlProps,
|
|
49
|
-
UlProps,
|
|
50
|
-
PreProps,
|
|
51
|
-
TableProps,
|
|
52
|
-
CaptionProps,
|
|
53
|
-
TheadProps,
|
|
54
|
-
TbodyProps,
|
|
55
|
-
ThProps,
|
|
56
|
-
TrProps,
|
|
57
|
-
TdProps
|
|
33
|
+
Td,
|
|
34
|
+
OverflowContainer,
|
|
35
|
+
LangSelector,
|
|
36
|
+
NavigationItem,
|
|
37
|
+
PopoverMenu,
|
|
38
|
+
PopoverMenuItem
|
|
58
39
|
} from './components'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="react/canary" />
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { describe,
|
|
2
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
3
3
|
import { render, screen } from '@testing-library/react'
|
|
4
4
|
|
|
5
5
|
import { Button } from '../src'
|
|
6
6
|
|
|
7
|
-
describe('
|
|
8
|
-
|
|
9
|
-
render(<Button>Button</Button>)
|
|
10
|
-
|
|
11
|
-
const text = screen.getByText(/Button/)
|
|
12
|
-
expect(text).toBeInTheDocument()
|
|
13
|
-
})
|
|
14
|
-
test('as button', async () => {
|
|
7
|
+
describe('Button', () => {
|
|
8
|
+
it('should render a button', async () => {
|
|
15
9
|
render(<Button>Button</Button>)
|
|
16
10
|
|
|
17
11
|
const button = screen.getByRole('button')
|
|
18
12
|
expect(button).toBeInTheDocument()
|
|
19
13
|
})
|
|
20
|
-
|
|
14
|
+
|
|
15
|
+
it('should render a link', async () => {
|
|
21
16
|
render(
|
|
22
17
|
<Button as="a" href="https://example.com">
|
|
23
18
|
Button
|
|
@@ -27,4 +22,19 @@ describe('should labeled text from Button', () => {
|
|
|
27
22
|
const button = screen.getByRole('link')
|
|
28
23
|
expect(button).toBeInTheDocument()
|
|
29
24
|
})
|
|
25
|
+
|
|
26
|
+
it('should labeled text from Button', async () => {
|
|
27
|
+
render(<Button>button</Button>)
|
|
28
|
+
|
|
29
|
+
const text = screen.getByText(/button/)
|
|
30
|
+
expect(text).toBeInTheDocument()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('should pass an object to the ref property', async () => {
|
|
34
|
+
const ref = vi.fn()
|
|
35
|
+
|
|
36
|
+
render(<Button ref={ref}>button</Button>)
|
|
37
|
+
|
|
38
|
+
expect(ref).toHaveBeenCalledTimes(1)
|
|
39
|
+
})
|
|
30
40
|
})
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { describe,
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
3
|
import { render, screen } from '@testing-library/react'
|
|
4
4
|
|
|
5
5
|
import { Card, CardBody, CardHeader } from '../src'
|
|
6
6
|
|
|
7
|
-
describe('
|
|
8
|
-
|
|
7
|
+
describe('Card', () => {
|
|
8
|
+
it('should labeled text from Card', async () => {
|
|
9
9
|
render(
|
|
10
10
|
<Card>
|
|
11
11
|
<CardHeader>Card-Header</CardHeader>
|
|
@@ -19,24 +19,29 @@ describe('should labeled text from Card', () => {
|
|
|
19
19
|
const text2 = screen.getByText(/Card-Body/)
|
|
20
20
|
expect(text2).toBeInTheDocument()
|
|
21
21
|
})
|
|
22
|
-
|
|
22
|
+
it('should set the role and id correctly', async () => {
|
|
23
23
|
render(
|
|
24
24
|
<Card>
|
|
25
|
-
<CardHeader>Card-Header</CardHeader>
|
|
26
|
-
<CardBody>Card-Body</CardBody>
|
|
25
|
+
<CardHeader data-testid="header">Card-Header</CardHeader>
|
|
26
|
+
<CardBody data-testid="body">Card-Body</CardBody>
|
|
27
27
|
</Card>
|
|
28
28
|
)
|
|
29
29
|
|
|
30
30
|
const card = screen.getByRole('article')
|
|
31
31
|
expect(card).toBeInTheDocument()
|
|
32
|
-
expect(card).toHaveProperty('id')
|
|
33
32
|
|
|
34
|
-
const header = screen.
|
|
33
|
+
const header = screen.getByTestId('header')
|
|
35
34
|
expect(header).toBeInTheDocument()
|
|
36
|
-
expect(header).
|
|
35
|
+
expect(header).toHaveAttribute('id')
|
|
37
36
|
|
|
38
|
-
const
|
|
37
|
+
const headerText = screen.getByLabelText('Card-Header')
|
|
38
|
+
expect(headerText).toBeInTheDocument()
|
|
39
|
+
|
|
40
|
+
const body = screen.getByTestId('body')
|
|
39
41
|
expect(body).toBeInTheDocument()
|
|
40
|
-
expect(body).
|
|
42
|
+
expect(body).toHaveAttribute('id')
|
|
43
|
+
|
|
44
|
+
const bodyText = screen.getByRole('article', { description: 'Card-Body' })
|
|
45
|
+
expect(bodyText).toBeInTheDocument()
|
|
41
46
|
})
|
|
42
47
|
})
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
3
|
+
import { render, screen } from '@testing-library/react'
|
|
4
|
+
|
|
5
|
+
import { IconButton } from '../src'
|
|
6
|
+
|
|
7
|
+
describe('IconButton', () => {
|
|
8
|
+
it('should render a button with icon', async () => {
|
|
9
|
+
render(<IconButton icon="home">Button with icon</IconButton>)
|
|
10
|
+
|
|
11
|
+
const button = screen.getByRole('button')
|
|
12
|
+
expect(button).toBeInTheDocument()
|
|
13
|
+
|
|
14
|
+
const text = screen.getByText(/home/)
|
|
15
|
+
expect(text).toBeInTheDocument()
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('should render a link with icon', async () => {
|
|
19
|
+
render(
|
|
20
|
+
<IconButton as="a" icon="home" href="https://googl.com">
|
|
21
|
+
Button with icon
|
|
22
|
+
</IconButton>
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const button = screen.getByRole('link')
|
|
26
|
+
expect(button).toBeInTheDocument()
|
|
27
|
+
|
|
28
|
+
const text = screen.getByText(/home/)
|
|
29
|
+
expect(text).toBeInTheDocument()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('should aria-hidden true', async () => {
|
|
33
|
+
render(<IconButton icon="home">button</IconButton>)
|
|
34
|
+
|
|
35
|
+
const text = screen.getByText(/home/)
|
|
36
|
+
expect(text).toHaveAttribute('aria-hidden', 'true')
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('should aria-hidden false', async () => {
|
|
40
|
+
render(<IconButton icon="home" />)
|
|
41
|
+
|
|
42
|
+
const text = screen.getByText(/home/)
|
|
43
|
+
expect(text).toHaveAttribute('aria-hidden', 'false')
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('should pass an object to the ref property', async () => {
|
|
47
|
+
const ref = vi.fn()
|
|
48
|
+
|
|
49
|
+
render(
|
|
50
|
+
<IconButton icon="home" ref={ref}>
|
|
51
|
+
button
|
|
52
|
+
</IconButton>
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
expect(ref).toHaveBeenCalledTimes(1)
|
|
56
|
+
})
|
|
57
|
+
})
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
3
|
+
import { render, screen } from '@testing-library/react'
|
|
4
|
+
|
|
5
|
+
import { Link } from '../src'
|
|
6
|
+
|
|
7
|
+
describe('Link', () => {
|
|
8
|
+
it('should render a link', async () => {
|
|
9
|
+
render(<Link href="/">Button</Link>)
|
|
10
|
+
|
|
11
|
+
const link = screen.getByRole('link')
|
|
12
|
+
expect(link).toBeInTheDocument()
|
|
13
|
+
expect(link).not.toHaveAttribute('target')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('should render a link with icon', async () => {
|
|
17
|
+
render(<Link href="https://google.com">Button</Link>)
|
|
18
|
+
|
|
19
|
+
const link = screen.getByRole('link')
|
|
20
|
+
expect(link).toBeInTheDocument()
|
|
21
|
+
expect(link).toHaveAttribute('target')
|
|
22
|
+
|
|
23
|
+
const text = screen.getByText(/open_in_new/)
|
|
24
|
+
expect(text).toBeInTheDocument()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('should render a link with icon', async () => {
|
|
28
|
+
render(
|
|
29
|
+
<Link href="/test" target="_blank">
|
|
30
|
+
Button
|
|
31
|
+
</Link>
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
const link = screen.getByRole('link')
|
|
35
|
+
expect(link).toBeInTheDocument()
|
|
36
|
+
expect(link).toHaveAttribute('target')
|
|
37
|
+
|
|
38
|
+
const text = screen.getByText(/open_in_new/)
|
|
39
|
+
expect(text).toBeInTheDocument()
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should labeled text from Button', async () => {
|
|
43
|
+
render(<Link href="/">here</Link>)
|
|
44
|
+
|
|
45
|
+
const text = screen.getByText(/here/)
|
|
46
|
+
expect(text).toBeInTheDocument()
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('should pass an object to the ref property', async () => {
|
|
50
|
+
const ref = vi.fn()
|
|
51
|
+
|
|
52
|
+
render(
|
|
53
|
+
<Link ref={ref} href="/">
|
|
54
|
+
link
|
|
55
|
+
</Link>
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
expect(ref).toHaveBeenCalledTimes(1)
|
|
59
|
+
})
|
|
60
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @sakura-ui/forms@0.3.0 prebuild /Users/t.fujita/Documents/Repos/sakura-ui/packages/forms
|
|
4
|
+
> rimraf dist
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
> @sakura-ui/forms@0.3.0 build /Users/t.fujita/Documents/Repos/sakura-ui/packages/forms
|
|
8
|
+
> run-p build:*
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
> @sakura-ui/forms@0.3.0 build:types /Users/t.fujita/Documents/Repos/sakura-ui/packages/forms
|
|
12
|
+
> tsc && tsc-alias
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
> @sakura-ui/forms@0.3.0 build:scripts /Users/t.fujita/Documents/Repos/sakura-ui/packages/forms
|
|
16
|
+
> vite build
|
|
17
|
+
|
|
18
|
+
[36mvite v6.0.3 [32mbuilding for production...[36m[39m
|
|
19
|
+
[2K[1Gtransforming (1) [2msrc/index.ts[22m[2K[1G[32m✓[39m 25 modules transformed.
|
|
20
|
+
[2K[1Grendering chunks (1)...[2K[1G[2K[1Gcomputing gzip size (0)...[2K[1Gcomputing gzip size (1)...[2K[1G[2mdist/[22m[36mindex.es.js [39m[1m[2m31.87 kB[22m[1m[22m[2m │ gzip: 8.19 kB[22m
|
|
21
|
+
[2K[1Grendering chunks (1)...[2K[1G[2K[1Gcomputing gzip size (1)...[2K[1G[2mdist/[22m[36mindex.cjs.js [39m[1m[2m21.92 kB[22m[1m[22m[2m │ gzip: 7.09 kB[22m
|
|
22
|
+
[32m✓ built in 170ms[39m
|