@sakura-ui/sakura-ui 0.1.21 → 0.2.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/package.json +16 -16
- package/packages/core/package.json +15 -14
- package/packages/core/src/components/Button.tsx +1 -1
- package/packages/core/src/components/Card.tsx +10 -4
- package/packages/core/src/components/IconButton.tsx +6 -6
- package/packages/core/src/components/Link.tsx +2 -1
- package/packages/core/src/components/Table.tsx +4 -3
- package/packages/core/src/components/buttonStyle.ts +20 -14
- package/packages/core/src/components/index.ts +0 -3
- package/packages/core/src/index.ts +0 -1
- package/packages/core/src/libs/cx.ts +1 -0
- package/packages/core/src/libs/forward-ref.ts +7 -4
- package/packages/core/src/types/component.ts +7 -6
- package/packages/core/tests/Button.test.tsx +30 -0
- package/packages/core/tests/Card.test.tsx +30 -7
- package/packages/core/tests/vitest.setup.ts +1 -0
- package/packages/core/vite.config.ts +3 -2
- package/packages/forms/dist/index.cjs.js +92 -81
- package/packages/forms/dist/index.es.js +697 -627
- package/packages/forms/dist/types/components/Checkbox.d.ts +3 -1
- package/packages/forms/dist/types/components/Checkbox.d.ts.map +1 -1
- package/packages/forms/dist/types/components/FileInput.d.ts.map +1 -1
- package/packages/forms/dist/types/components/Input.d.ts +3 -1
- package/packages/forms/dist/types/components/Input.d.ts.map +1 -1
- package/packages/forms/dist/types/components/Radio.d.ts +3 -1
- package/packages/forms/dist/types/components/Radio.d.ts.map +1 -1
- package/packages/forms/dist/types/components/Select.d.ts +3 -1
- package/packages/forms/dist/types/components/Select.d.ts.map +1 -1
- package/packages/forms/dist/types/components/Textarea.d.ts.map +1 -1
- package/packages/forms/dist/types/components/controlled/CheckboxGroup.d.ts +3 -1
- package/packages/forms/dist/types/components/controlled/CheckboxGroup.d.ts.map +1 -1
- package/packages/forms/dist/types/components/controlled/RadioGroup.d.ts +3 -1
- package/packages/forms/dist/types/components/controlled/RadioGroup.d.ts.map +1 -1
- package/packages/forms/dist/types/components/controlled/index.d.ts +0 -2
- package/packages/forms/dist/types/components/controlled/index.d.ts.map +1 -1
- package/packages/forms/dist/types/components/inputStyle.d.ts +13 -0
- package/packages/forms/dist/types/components/inputStyle.d.ts.map +1 -0
- package/packages/forms/dist/types/index.d.ts +1 -1
- package/packages/forms/dist/types/index.d.ts.map +1 -1
- package/packages/forms/dist/types/utils/class.d.ts.map +1 -1
- package/packages/forms/node_modules/.bin/acorn +17 -0
- package/packages/forms/node_modules/.bin/autoprefixer +2 -2
- package/packages/forms/node_modules/.bin/browserslist +4 -4
- package/packages/forms/node_modules/.bin/eslint +4 -4
- 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/vitest +4 -4
- package/packages/forms/package.json +15 -14
- package/packages/forms/src/components/Checkbox.tsx +39 -17
- package/packages/forms/src/components/FieldsetControl.tsx +1 -1
- package/packages/forms/src/components/FileInput.tsx +5 -3
- package/packages/forms/src/components/Input.tsx +16 -20
- package/packages/forms/src/components/LabelControl.tsx +2 -2
- package/packages/forms/src/components/Radio.tsx +34 -19
- package/packages/forms/src/components/Select.tsx +41 -31
- package/packages/forms/src/components/Textarea.tsx +4 -3
- package/packages/forms/src/components/controlled/CheckboxGroup.tsx +11 -3
- package/packages/forms/src/components/controlled/RadioGroup.tsx +7 -3
- package/packages/forms/src/components/controlled/index.ts +0 -2
- package/packages/forms/src/components/inputStyle.ts +83 -0
- package/packages/forms/src/index.ts +1 -6
- package/packages/forms/src/utils/class.ts +1 -0
- package/packages/forms/tests/FieldsetControl.test.tsx +2 -2
- package/packages/forms/tests/Input.test.tsx +2 -2
- package/packages/forms/tests/LabelControl.test.tsx +2 -2
- package/packages/forms/tests/Radio.test.tsx +2 -2
- package/packages/forms/tests/vitest.setup.ts +1 -0
- package/packages/forms/vite.config.ts +3 -2
- package/packages/tailwind-theme-plugin/dist/index.cjs.js +1 -1
- package/packages/tailwind-theme-plugin/dist/index.es.js +14 -14
- package/packages/tailwind-theme-plugin/node_modules/.bin/autoprefixer +2 -2
- package/packages/tailwind-theme-plugin/node_modules/.bin/tailwind +4 -4
- package/packages/tailwind-theme-plugin/node_modules/.bin/tailwindcss +4 -4
- 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/package.json +8 -5
- package/packages/tailwind-theme-plugin/src/index.ts +14 -14
- package/packages/tailwind-theme-plugin/vite.config.ts +1 -1
- package/packages/config/package.json +0 -46
- package/packages/config/src/index.ts +0 -347
- package/packages/config/tests/index.test.ts +0 -13
- package/packages/config/tsconfig.json +0 -13
- package/packages/config/tsconfig.node.json +0 -6
- package/packages/config/vite.config.ts +0 -26
- package/packages/core/.eslintrc.json +0 -25
- package/packages/core/src/components/InfoCard.tsx +0 -50
- package/packages/forms/coverage/clover.xml +0 -209
- package/packages/forms/coverage/coverage-final.json +0 -18
- package/packages/forms/coverage/lcov-report/base.css +0 -224
- package/packages/forms/coverage/lcov-report/block-navigation.js +0 -87
- package/packages/forms/coverage/lcov-report/favicon.png +0 -0
- package/packages/forms/coverage/lcov-report/index.html +0 -161
- package/packages/forms/coverage/lcov-report/prettify.css +0 -1
- package/packages/forms/coverage/lcov-report/prettify.js +0 -2
- package/packages/forms/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/packages/forms/coverage/lcov-report/sorter.js +0 -196
- package/packages/forms/coverage/lcov-report/src/components/Checkbox.tsx.html +0 -295
- package/packages/forms/coverage/lcov-report/src/components/FieldsetControl.tsx.html +0 -295
- package/packages/forms/coverage/lcov-report/src/components/LabelControl.tsx.html +0 -289
- package/packages/forms/coverage/lcov-report/src/components/Radio.tsx.html +0 -262
- package/packages/forms/coverage/lcov-report/src/components/Select.tsx.html +0 -259
- package/packages/forms/coverage/lcov-report/src/components/Text.tsx.html +0 -220
- package/packages/forms/coverage/lcov-report/src/components/Textarea.tsx.html +0 -229
- package/packages/forms/coverage/lcov-report/src/components/context.ts.html +0 -136
- package/packages/forms/coverage/lcov-report/src/components/controlled/CheckboxGroup.tsx.html +0 -244
- package/packages/forms/coverage/lcov-report/src/components/controlled/RadioGroup.tsx.html +0 -265
- package/packages/forms/coverage/lcov-report/src/components/controlled/SelectControl.tsx.html +0 -205
- package/packages/forms/coverage/lcov-report/src/components/controlled/TextControl.tsx.html +0 -202
- package/packages/forms/coverage/lcov-report/src/components/controlled/TextareaControl.tsx.html +0 -205
- package/packages/forms/coverage/lcov-report/src/components/controlled/index.html +0 -191
- package/packages/forms/coverage/lcov-report/src/components/controlled/index.ts.html +0 -100
- package/packages/forms/coverage/lcov-report/src/components/index.html +0 -236
- package/packages/forms/coverage/lcov-report/src/components/index.ts.html +0 -106
- package/packages/forms/coverage/lcov-report/src/index.html +0 -116
- package/packages/forms/coverage/lcov-report/src/index.ts.html +0 -136
- package/packages/forms/coverage/lcov-report/src/utils/index.html +0 -116
- package/packages/forms/coverage/lcov-report/src/utils/index.ts.html +0 -88
- package/packages/forms/coverage/lcov.info +0 -434
- package/packages/forms/dist/types/components/controlled/SelectControl.d.ts +0 -10
- package/packages/forms/dist/types/components/controlled/SelectControl.d.ts.map +0 -1
- package/packages/forms/dist/types/components/controlled/TextareaControl.d.ts +0 -10
- package/packages/forms/dist/types/components/controlled/TextareaControl.d.ts.map +0 -1
- package/packages/forms/jest.config.ts +0 -11
- package/packages/forms/node_modules/.vitest/results.json +0 -1
- package/packages/forms/src/components/controlled/SelectControl.tsx +0 -42
- package/packages/forms/src/components/controlled/TextareaControl.tsx +0 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sakura-ui/sakura-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "glassonion1",
|
|
6
6
|
"homepage": "https://github.com/glassonion1/sakura-ui",
|
|
@@ -12,11 +12,14 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"packages"
|
|
14
14
|
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
15
18
|
"scripts": {
|
|
16
|
-
"build": "pnpm --parallel --filter
|
|
19
|
+
"build": "pnpm --parallel --filter=./packages/* build"
|
|
17
20
|
},
|
|
18
21
|
"dependencies": {
|
|
19
|
-
"@sakura-ui/
|
|
22
|
+
"@sakura-ui/tailwind-theme-plugin": "workspace:*",
|
|
20
23
|
"@sakura-ui/core": "workspace:*",
|
|
21
24
|
"@sakura-ui/forms": "workspace:*"
|
|
22
25
|
},
|
|
@@ -26,18 +29,15 @@
|
|
|
26
29
|
"tailwindcss": "^3.2.7"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"typescript": "^5.1.6",
|
|
40
|
-
"vite": "^4.4.2",
|
|
41
|
-
"vitest": "^1.3.1"
|
|
32
|
+
"@biomejs/biome": "^1.8.0",
|
|
33
|
+
"@types/node": "^20.14.1",
|
|
34
|
+
"@vitejs/plugin-react-swc": "^3.7.0",
|
|
35
|
+
"npm-run-all2": "^6.2.0",
|
|
36
|
+
"rimraf": "^5.0.7",
|
|
37
|
+
"ts-node": "^10.9.2",
|
|
38
|
+
"tsc-alias": "^1.8.10",
|
|
39
|
+
"typescript": "^5.4.5",
|
|
40
|
+
"vite": "^5.2.12",
|
|
41
|
+
"vitest": "^1.6.0"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sakura-ui/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "glassonion1",
|
|
@@ -25,9 +25,12 @@
|
|
|
25
25
|
"files": [
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
28
31
|
"scripts": {
|
|
29
32
|
"lint": "run-s lint:*",
|
|
30
|
-
"lint:
|
|
33
|
+
"lint:lint": "biome lint ./",
|
|
31
34
|
"lint:prettier": "prettier --write --ignore-path .gitignore './src/*.ts'",
|
|
32
35
|
"prebuild": "rimraf dist",
|
|
33
36
|
"build": "run-p build:*",
|
|
@@ -41,17 +44,15 @@
|
|
|
41
44
|
"tailwindcss": "^3.2.7"
|
|
42
45
|
},
|
|
43
46
|
"devDependencies": {
|
|
44
|
-
"@testing-library/jest-dom": "^6.4.
|
|
45
|
-
"@testing-library/react": "^
|
|
46
|
-
"@types/react": "^18.
|
|
47
|
-
"@types/react-dom": "^18.
|
|
48
|
-
"autoprefixer": "^10.4.
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"react-dom": "^18.2.0",
|
|
55
|
-
"tailwindcss": "^3.4.1"
|
|
47
|
+
"@testing-library/jest-dom": "^6.4.5",
|
|
48
|
+
"@testing-library/react": "^16.0.0",
|
|
49
|
+
"@types/react": "^18.3.3",
|
|
50
|
+
"@types/react-dom": "^18.3.0",
|
|
51
|
+
"autoprefixer": "^10.4.19",
|
|
52
|
+
"happy-dom": "^14.12.0",
|
|
53
|
+
"postcss": "^8.4.38",
|
|
54
|
+
"react": "^18.3.1",
|
|
55
|
+
"react-dom": "^18.3.1",
|
|
56
|
+
"tailwindcss": "^3.4.3"
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -7,7 +7,7 @@ interface IdContextType {
|
|
|
7
7
|
|
|
8
8
|
const IdContext = React.createContext<IdContextType>({ id: '' })
|
|
9
9
|
|
|
10
|
-
export interface CardProps extends React.ComponentPropsWithoutRef<'
|
|
10
|
+
export interface CardProps extends React.ComponentPropsWithoutRef<'article'> {}
|
|
11
11
|
|
|
12
12
|
export const Card = (props: CardProps) => {
|
|
13
13
|
const { className, children, ...restProps } = props
|
|
@@ -29,13 +29,14 @@ export const Card = (props: CardProps) => {
|
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
31
|
<IdContext.Provider value={ctx}>
|
|
32
|
-
<
|
|
32
|
+
<article
|
|
33
33
|
aria-labelledby={ctx.id}
|
|
34
|
+
aria-describedby={`${ctx.id}-desc`}
|
|
34
35
|
className={cx(style, className)}
|
|
35
36
|
{...restProps}
|
|
36
37
|
>
|
|
37
38
|
{children}
|
|
38
|
-
</
|
|
39
|
+
</article>
|
|
39
40
|
</IdContext.Provider>
|
|
40
41
|
)
|
|
41
42
|
}
|
|
@@ -47,8 +48,10 @@ export const CardImg = (props: CardImgProps) => {
|
|
|
47
48
|
|
|
48
49
|
const style = `
|
|
49
50
|
object-cover
|
|
51
|
+
mb-2
|
|
50
52
|
`
|
|
51
53
|
|
|
54
|
+
// biome-ignore lint/a11y/useAltText: things to check on the user side
|
|
52
55
|
return <img className={cx(style, className)} {...restProps} />
|
|
53
56
|
}
|
|
54
57
|
|
|
@@ -63,6 +66,7 @@ export const CardHeader = (props: CardHeaderProps) => {
|
|
|
63
66
|
const style = `
|
|
64
67
|
text-base
|
|
65
68
|
font-medium
|
|
69
|
+
first:pt-4
|
|
66
70
|
last:pb-4
|
|
67
71
|
px-6
|
|
68
72
|
`
|
|
@@ -79,6 +83,8 @@ export interface CardBodyProps extends React.ComponentPropsWithoutRef<'div'> {}
|
|
|
79
83
|
export const CardBody = (props: CardBodyProps) => {
|
|
80
84
|
const { className, children, ...restProps } = props
|
|
81
85
|
|
|
86
|
+
const ctx = React.useContext(IdContext)
|
|
87
|
+
|
|
82
88
|
const style = `
|
|
83
89
|
text-base-sm
|
|
84
90
|
first:pt-4
|
|
@@ -87,7 +93,7 @@ export const CardBody = (props: CardBodyProps) => {
|
|
|
87
93
|
`
|
|
88
94
|
|
|
89
95
|
return (
|
|
90
|
-
<div className={cx(style, className)} {...restProps}>
|
|
96
|
+
<div id={`${ctx.id}-desc`} className={cx(style, className)} {...restProps}>
|
|
91
97
|
{children}
|
|
92
98
|
</div>
|
|
93
99
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cx } from '../libs/cx'
|
|
2
|
-
import { ComponentWithAs } from '../types/component'
|
|
2
|
+
import type { ComponentWithAs } from '../types/component'
|
|
3
3
|
import { forwardRef } from '../libs/forward-ref'
|
|
4
4
|
import { base, getVariantStyle, getSizeStyle } from './buttonStyle'
|
|
5
5
|
|
|
@@ -25,7 +25,7 @@ export const IconButton: ComponentWithAs<'button', IconButtonProps> =
|
|
|
25
25
|
...restProps
|
|
26
26
|
} = props
|
|
27
27
|
|
|
28
|
-
const styleFontSize = `${size === 'xs' ?
|
|
28
|
+
const styleFontSize = `${size === 'xs' ? 'scale-105' : 'scale-125'}`
|
|
29
29
|
|
|
30
30
|
const styleIcon = `
|
|
31
31
|
inline-block
|
|
@@ -37,10 +37,10 @@ export const IconButton: ComponentWithAs<'button', IconButtonProps> =
|
|
|
37
37
|
antialiased
|
|
38
38
|
`
|
|
39
39
|
|
|
40
|
-
const styleRounded = `${rounded ?
|
|
40
|
+
const styleRounded = `${rounded ? 'aspect-square !rounded-full !py-0' : ''}`
|
|
41
41
|
|
|
42
42
|
// When text is specified on a button, set the 'aria-hidden' attribute of the icon to true.
|
|
43
|
-
const ariaHidden = children
|
|
43
|
+
const ariaHidden = !!children
|
|
44
44
|
|
|
45
45
|
return (
|
|
46
46
|
<Component
|
|
@@ -54,7 +54,7 @@ export const IconButton: ComponentWithAs<'button', IconButtonProps> =
|
|
|
54
54
|
{...restProps}
|
|
55
55
|
ref={ref}
|
|
56
56
|
>
|
|
57
|
-
{iconLayout
|
|
57
|
+
{iconLayout === 'left' && (
|
|
58
58
|
<span
|
|
59
59
|
className={cx(styleIcon, styleFontSize)}
|
|
60
60
|
aria-hidden={ariaHidden}
|
|
@@ -63,7 +63,7 @@ export const IconButton: ComponentWithAs<'button', IconButtonProps> =
|
|
|
63
63
|
</span>
|
|
64
64
|
)}
|
|
65
65
|
{children && <span className="mx-1">{children}</span>}
|
|
66
|
-
{iconLayout
|
|
66
|
+
{iconLayout === 'right' && (
|
|
67
67
|
<span
|
|
68
68
|
className={cx(styleIcon, styleFontSize)}
|
|
69
69
|
aria-hidden={ariaHidden}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { cx } from '../libs/cx'
|
|
2
|
-
import { ComponentWithAs } from '../types/component'
|
|
2
|
+
import type { ComponentWithAs } from '../types/component'
|
|
3
3
|
import { forwardRef } from '../libs/forward-ref'
|
|
4
4
|
|
|
5
|
+
// biome-ignore lint/suspicious/noEmptyInterface:
|
|
5
6
|
export interface LinkProps {}
|
|
6
7
|
|
|
7
8
|
export const Link: ComponentWithAs<'a', LinkProps> = forwardRef(
|
|
@@ -32,7 +32,7 @@ export interface CaptionProps
|
|
|
32
32
|
export const Caption = (props: CaptionProps) => {
|
|
33
33
|
const { className, children, ...restProps } = props
|
|
34
34
|
|
|
35
|
-
const style =
|
|
35
|
+
const style = 'text-left'
|
|
36
36
|
return (
|
|
37
37
|
<caption className={cx(style, className)} {...restProps}>
|
|
38
38
|
{children}
|
|
@@ -72,7 +72,7 @@ export const Th = (props: ThProps) => {
|
|
|
72
72
|
const style = `
|
|
73
73
|
p-2
|
|
74
74
|
bg-[#f8f8fb]
|
|
75
|
-
text-
|
|
75
|
+
text-label
|
|
76
76
|
text-left
|
|
77
77
|
`
|
|
78
78
|
return (
|
|
@@ -87,7 +87,7 @@ export interface TrProps extends React.ComponentPropsWithoutRef<'tr'> {}
|
|
|
87
87
|
export const Tr = (props: TrProps) => {
|
|
88
88
|
const { className, children, ...restProps } = props
|
|
89
89
|
|
|
90
|
-
const style =
|
|
90
|
+
const style = ''
|
|
91
91
|
|
|
92
92
|
return (
|
|
93
93
|
<tr className={cx(style, styleBorder, className)} {...restProps}>
|
|
@@ -103,6 +103,7 @@ export const Td = (props: TdProps) => {
|
|
|
103
103
|
|
|
104
104
|
const style = `
|
|
105
105
|
p-2
|
|
106
|
+
text-label
|
|
106
107
|
`
|
|
107
108
|
|
|
108
109
|
return (
|
|
@@ -23,12 +23,12 @@ export const base = `
|
|
|
23
23
|
`
|
|
24
24
|
|
|
25
25
|
const primary = `
|
|
26
|
-
text-white
|
|
26
|
+
text-white
|
|
27
27
|
bg-sea-800
|
|
28
28
|
active:bg-sea-1200
|
|
29
29
|
hover:bg-sea-900
|
|
30
30
|
disabled:bg-sumi-500
|
|
31
|
-
disabled:text-white
|
|
31
|
+
disabled:text-white
|
|
32
32
|
`
|
|
33
33
|
|
|
34
34
|
const secondary = `
|
|
@@ -43,16 +43,16 @@ const secondary = `
|
|
|
43
43
|
`
|
|
44
44
|
|
|
45
45
|
const tertiary = `
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
bg-transparent
|
|
47
|
+
text-blue-900
|
|
48
|
+
underline
|
|
49
|
+
hover:bg-blue-200
|
|
50
|
+
hover:text-blue-1000
|
|
51
|
+
active:bg-blue-300
|
|
52
|
+
active:text-blue-1200
|
|
53
|
+
disabled:bg-transparent
|
|
54
|
+
disabled:text-solid-grey-420
|
|
55
|
+
`
|
|
56
56
|
|
|
57
57
|
const styles: { [key in ButtonVariant]: string } = {
|
|
58
58
|
primary: primary,
|
|
@@ -61,30 +61,36 @@ const styles: { [key in ButtonVariant]: string } = {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const params: { [key in ButtonSize]: string } = {
|
|
64
|
+
// 16(p-4) * 2 + 22(text-button * leading-snug) + boader * 2 = 56px
|
|
64
65
|
lg: `
|
|
65
66
|
p-4
|
|
66
67
|
text-button
|
|
67
68
|
rounded-lg
|
|
69
|
+
leading-snug
|
|
68
70
|
`,
|
|
71
|
+
// 12(py-3) * 2 + 22(text-button * leading-snug) + boader * 2 = 48px
|
|
69
72
|
md: `
|
|
70
73
|
px-4
|
|
71
74
|
py-3
|
|
72
75
|
text-button
|
|
73
76
|
rounded-lg
|
|
77
|
+
leading-snug
|
|
74
78
|
`,
|
|
79
|
+
// 6(py-1.5) * 2 + 22(text-button * leading-snug) + boader * 2 = 36px
|
|
75
80
|
sm: `
|
|
76
81
|
px-3
|
|
77
82
|
py-1.5
|
|
78
83
|
my-1
|
|
79
84
|
text-button
|
|
80
85
|
rounded-md
|
|
86
|
+
leading-snug
|
|
81
87
|
`,
|
|
88
|
+
// 6(py-1.5) * 2 + 14(text-button-sm) + boader * 2 = 28p
|
|
82
89
|
xs: `
|
|
83
90
|
px-2
|
|
84
|
-
py-
|
|
91
|
+
py-1.5
|
|
85
92
|
my-2
|
|
86
93
|
text-button-sm
|
|
87
|
-
!leading-[14px]
|
|
88
94
|
rounded
|
|
89
95
|
`
|
|
90
96
|
}
|
|
@@ -22,12 +22,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
22
22
|
SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import
|
|
26
|
-
|
|
25
|
+
import React, {
|
|
26
|
+
type ComponentProps,
|
|
27
|
+
forwardRef as forwardReactRef
|
|
28
|
+
} from 'react'
|
|
29
|
+
import type { As, ComponentWithAs, RightJoinProps } from '../types/component'
|
|
27
30
|
|
|
28
|
-
export function forwardRef<
|
|
31
|
+
export function forwardRef<Component extends As, Props extends object>(
|
|
29
32
|
component: React.ForwardRefRenderFunction<
|
|
30
|
-
//
|
|
33
|
+
// biome-ignore lint/suspicious/noExplicitAny:
|
|
31
34
|
any,
|
|
32
35
|
RightJoinProps<ComponentProps<Component>, Props> & {
|
|
33
36
|
as?: As
|
|
@@ -22,14 +22,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
22
22
|
SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import { ComponentProps } from 'react'
|
|
25
|
+
import React, { type ComponentProps } from 'react'
|
|
26
26
|
|
|
27
|
-
//
|
|
27
|
+
// biome-ignore lint/suspicious/noExplicitAny:
|
|
28
28
|
export type As<Props = any> = React.ElementType<Props>
|
|
29
29
|
|
|
30
30
|
export type OmitCommonProps<
|
|
31
31
|
Target,
|
|
32
|
-
//
|
|
32
|
+
// biome-ignore lint/suspicious/noExplicitAny:
|
|
33
33
|
OmitAdditionalProps extends keyof any = never
|
|
34
34
|
> = Omit<Target, 'as' | OmitAdditionalProps>
|
|
35
35
|
|
|
@@ -70,13 +70,14 @@ export type ComponentWithAs<
|
|
|
70
70
|
Props,
|
|
71
71
|
AsComponent
|
|
72
72
|
>
|
|
73
|
+
// biome-ignore lint/correctness/noUndeclaredVariables:
|
|
73
74
|
): JSX.Element
|
|
74
75
|
displayName?: string
|
|
75
|
-
//
|
|
76
|
+
// biome-ignore lint/suspicious/noExplicitAny:
|
|
76
77
|
propTypes?: React.WeakValidationMap<any>
|
|
77
|
-
//
|
|
78
|
+
// biome-ignore lint/suspicious/noExplicitAny:
|
|
78
79
|
contextTypes?: React.ValidationMap<any>
|
|
79
|
-
//
|
|
80
|
+
// biome-ignore lint/suspicious/noExplicitAny:
|
|
80
81
|
defaultProps?: Partial<any>
|
|
81
82
|
id?: string
|
|
82
83
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { describe, test, expect } from 'vitest'
|
|
3
|
+
import { render, screen } from '@testing-library/react'
|
|
4
|
+
|
|
5
|
+
import { Button } from '../src'
|
|
6
|
+
|
|
7
|
+
describe('should labeled text from Button', () => {
|
|
8
|
+
test('text', async () => {
|
|
9
|
+
render(<Button>Button</Button>)
|
|
10
|
+
|
|
11
|
+
const text = screen.getByText(/Button/)
|
|
12
|
+
expect(text).toBeInTheDocument()
|
|
13
|
+
})
|
|
14
|
+
test('as button', async () => {
|
|
15
|
+
render(<Button>Button</Button>)
|
|
16
|
+
|
|
17
|
+
const button = screen.getByRole('button')
|
|
18
|
+
expect(button).toBeInTheDocument()
|
|
19
|
+
})
|
|
20
|
+
test('as link', async () => {
|
|
21
|
+
render(
|
|
22
|
+
<Button as="a" href="https://example.com">
|
|
23
|
+
Button
|
|
24
|
+
</Button>
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const button = screen.getByRole('link')
|
|
28
|
+
expect(button).toBeInTheDocument()
|
|
29
|
+
})
|
|
30
|
+
})
|
|
@@ -1,19 +1,42 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { describe, test, expect } from 'vitest'
|
|
2
3
|
import { render, screen } from '@testing-library/react'
|
|
3
|
-
import '@testing-library/jest-dom'
|
|
4
4
|
|
|
5
|
-
import { Card, CardHeader } from '../src'
|
|
5
|
+
import { Card, CardBody, CardHeader } from '../src'
|
|
6
6
|
|
|
7
7
|
describe('should labeled text from Card', () => {
|
|
8
|
-
test('
|
|
8
|
+
test('text', async () => {
|
|
9
9
|
render(
|
|
10
10
|
<Card>
|
|
11
|
-
<CardHeader>Card-
|
|
11
|
+
<CardHeader>Card-Header</CardHeader>
|
|
12
|
+
<CardBody>Card-Body</CardBody>
|
|
12
13
|
</Card>
|
|
13
14
|
)
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
+
const text1 = screen.getByText(/Card-Header/)
|
|
17
|
+
expect(text1).toBeInTheDocument()
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
const text2 = screen.getByText(/Card-Body/)
|
|
20
|
+
expect(text2).toBeInTheDocument()
|
|
21
|
+
})
|
|
22
|
+
test('role and id', async () => {
|
|
23
|
+
render(
|
|
24
|
+
<Card>
|
|
25
|
+
<CardHeader>Card-Header</CardHeader>
|
|
26
|
+
<CardBody>Card-Body</CardBody>
|
|
27
|
+
</Card>
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
const card = screen.getByRole('article')
|
|
31
|
+
expect(card).toBeInTheDocument()
|
|
32
|
+
expect(card).toHaveProperty('id')
|
|
33
|
+
|
|
34
|
+
const header = screen.getByLabelText('Card-Header')
|
|
35
|
+
expect(header).toBeInTheDocument()
|
|
36
|
+
expect(header).toHaveProperty('id')
|
|
37
|
+
|
|
38
|
+
const body = screen.getByRole('article', { description: 'Card-Body' })
|
|
39
|
+
expect(body).toBeInTheDocument()
|
|
40
|
+
expect(body).toHaveProperty('id')
|
|
18
41
|
})
|
|
19
42
|
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="vitest" />
|
|
2
|
-
import { resolve } from 'path'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
3
|
import { defineConfig } from 'vite'
|
|
4
4
|
import react from '@vitejs/plugin-react-swc'
|
|
5
5
|
import { peerDependencies } from './package.json'
|
|
@@ -24,6 +24,7 @@ export default defineConfig({
|
|
|
24
24
|
},
|
|
25
25
|
test: {
|
|
26
26
|
globals: true,
|
|
27
|
-
environment: '
|
|
27
|
+
environment: 'happy-dom',
|
|
28
|
+
setupFiles: 'tests/vitest.setup.ts'
|
|
28
29
|
}
|
|
29
30
|
})
|