@sakura-ui/sakura-ui 0.1.16 → 0.1.19
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 -1
- package/packages/config/package.json +23 -27
- package/packages/config/src/index.ts +66 -1
- package/packages/config/tests/index.test.ts +1 -1
- package/packages/config/tsconfig.json +9 -17
- package/packages/config/tsconfig.node.json +6 -0
- package/packages/config/vite.config.ts +5 -3
- package/packages/core/package.json +27 -44
- package/packages/core/src/components/Button.tsx +23 -56
- package/packages/core/src/components/Card.tsx +30 -20
- package/packages/core/src/components/Code.tsx +1 -1
- package/packages/core/src/components/Faq.tsx +3 -5
- package/packages/core/src/components/Heading.tsx +1 -1
- package/packages/core/src/components/Icon.tsx +15 -10
- package/packages/core/src/components/IconButton.tsx +47 -76
- package/packages/core/src/components/InfoCard.tsx +1 -1
- package/packages/core/src/components/Link.tsx +44 -44
- package/packages/core/src/components/List.tsx +1 -1
- package/packages/core/src/components/Pre.tsx +1 -1
- package/packages/core/src/components/Table.tsx +4 -3
- package/packages/core/src/components/buttonStyle.ts +84 -0
- package/packages/core/src/components/index.ts +24 -7
- package/packages/core/src/index.ts +26 -0
- package/packages/core/src/libs/forward-ref.ts +41 -0
- package/packages/core/src/types/component.ts +82 -0
- package/packages/core/tsconfig.json +2 -1
- package/packages/core/tsconfig.node.json +1 -4
- package/packages/core/vite.config.ts +6 -3
- package/packages/forms/dist/components/Checkbox.js +27 -24
- package/packages/forms/dist/components/Checkbox.js.map +1 -1
- package/packages/forms/dist/components/FileInput.js +55 -0
- package/packages/forms/dist/components/FileInput.js.map +1 -0
- package/packages/forms/dist/components/Input.js +15 -13
- package/packages/forms/dist/components/Input.js.map +1 -1
- package/packages/forms/dist/components/LabelControl.js +7 -1
- package/packages/forms/dist/components/LabelControl.js.map +1 -1
- package/packages/forms/dist/components/Radio.js +26 -24
- package/packages/forms/dist/components/Radio.js.map +1 -1
- package/packages/forms/dist/components/Select.js +27 -25
- package/packages/forms/dist/components/Select.js.map +1 -1
- package/packages/forms/dist/components/Textarea.js +15 -13
- package/packages/forms/dist/components/Textarea.js.map +1 -1
- package/packages/forms/dist/components/index.js +1 -0
- package/packages/forms/dist/components/index.js.map +1 -1
- package/packages/forms/dist/index.cjs.js +155 -101
- package/packages/forms/dist/index.es.js +490 -411
- package/packages/forms/dist/index.js +1 -1
- package/packages/forms/dist/index.js.map +1 -1
- package/packages/forms/dist/types/components/Checkbox.d.ts.map +1 -0
- package/packages/forms/dist/types/components/FieldsetControl.d.ts.map +1 -0
- package/packages/forms/dist/types/components/FileInput.d.ts +5 -0
- package/packages/forms/dist/types/components/FileInput.d.ts.map +1 -0
- package/packages/forms/dist/types/components/Input.d.ts.map +1 -0
- package/packages/forms/dist/types/components/LabelControl.d.ts.map +1 -0
- package/packages/forms/dist/types/components/Radio.d.ts.map +1 -0
- package/packages/forms/dist/types/components/Select.d.ts.map +1 -0
- package/packages/forms/dist/types/components/Textarea.d.ts.map +1 -0
- package/packages/forms/dist/types/components/context.d.ts.map +1 -0
- package/packages/forms/dist/types/components/controlled/CheckboxGroup.d.ts.map +1 -0
- package/packages/forms/dist/types/components/controlled/InputItem.d.ts.map +1 -0
- package/packages/forms/dist/types/components/controlled/RadioGroup.d.ts.map +1 -0
- package/packages/forms/dist/types/components/controlled/SelectControl.d.ts.map +1 -0
- package/packages/forms/dist/types/components/controlled/TextareaControl.d.ts.map +1 -0
- package/packages/forms/dist/types/components/controlled/index.d.ts.map +1 -0
- package/packages/forms/dist/types/components/index.d.ts +9 -0
- package/packages/forms/dist/types/components/index.d.ts.map +1 -0
- package/packages/forms/dist/types/index.d.ts +4 -0
- package/packages/forms/dist/types/index.d.ts.map +1 -0
- package/packages/forms/dist/types/utils/class.d.ts.map +1 -0
- package/packages/forms/node_modules/.bin/eslint +17 -0
- 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 +17 -0
- package/packages/forms/node_modules/.vitest/results.json +1 -0
- package/packages/forms/package.json +23 -31
- package/packages/forms/src/components/Checkbox.tsx +27 -23
- package/packages/forms/src/components/FileInput.tsx +74 -0
- package/packages/forms/src/components/Input.tsx +16 -14
- package/packages/forms/src/components/LabelControl.tsx +13 -6
- package/packages/forms/src/components/Radio.tsx +28 -23
- package/packages/forms/src/components/Select.tsx +28 -26
- package/packages/forms/src/components/Textarea.tsx +16 -13
- package/packages/forms/src/components/index.ts +8 -7
- package/packages/forms/src/index.ts +12 -0
- package/packages/forms/tsconfig.json +4 -3
- package/packages/forms/tsconfig.node.json +1 -4
- package/packages/forms/vite.config.ts +6 -3
- package/packages/config/jest.config.ts +0 -10
- package/packages/core/coverage/clover.xml +0 -258
- package/packages/core/coverage/coverage-final.json +0 -2700
- package/packages/core/coverage/lcov-report/base.css +0 -362
- package/packages/core/coverage/lcov-report/block-navigation.js +0 -85
- package/packages/core/coverage/lcov-report/favicon.png +0 -0
- package/packages/core/coverage/lcov-report/index.html +0 -216
- package/packages/core/coverage/lcov-report/prettify.css +0 -101
- package/packages/core/coverage/lcov-report/prettify.js +0 -1004
- package/packages/core/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/packages/core/coverage/lcov-report/sorter.js +0 -191
- package/packages/core/coverage/lcov-report/src/components/Button.tsx.html +0 -303
- package/packages/core/coverage/lcov-report/src/components/Card.tsx.html +0 -399
- package/packages/core/coverage/lcov-report/src/components/Code.tsx.html +0 -144
- package/packages/core/coverage/lcov-report/src/components/Heading.tsx.html +0 -405
- package/packages/core/coverage/lcov-report/src/components/Icon.tsx.html +0 -183
- package/packages/core/coverage/lcov-report/src/components/IconButton.tsx.html +0 -378
- package/packages/core/coverage/lcov-report/src/components/InfoCard.tsx.html +0 -240
- package/packages/core/coverage/lcov-report/src/components/Link.tsx.html +0 -324
- package/packages/core/coverage/lcov-report/src/components/List.tsx.html +0 -204
- package/packages/core/coverage/lcov-report/src/components/Pre.tsx.html +0 -153
- package/packages/core/coverage/lcov-report/src/components/Table.tsx.html +0 -429
- package/packages/core/coverage/lcov-report/src/components/index.html +0 -396
- package/packages/core/coverage/lcov-report/src/components/index.ts.html +0 -126
- package/packages/core/coverage/lcov-report/src/index.html +0 -176
- package/packages/core/coverage/lcov-report/src/index.ts.html +0 -171
- package/packages/core/coverage/lcov-report/src/utils/class.ts.html +0 -90
- package/packages/core/coverage/lcov-report/src/utils/index.html +0 -176
- package/packages/core/coverage/lcov.info +0 -523
- package/packages/core/jest.config.ts +0 -11
- package/packages/forms/dist/components/Checkbox.d.ts.map +0 -1
- package/packages/forms/dist/components/FieldsetControl.d.ts.map +0 -1
- package/packages/forms/dist/components/Input.d.ts.map +0 -1
- package/packages/forms/dist/components/LabelControl.d.ts.map +0 -1
- package/packages/forms/dist/components/Radio.d.ts.map +0 -1
- package/packages/forms/dist/components/Select.d.ts.map +0 -1
- package/packages/forms/dist/components/Textarea.d.ts.map +0 -1
- package/packages/forms/dist/components/context.d.ts.map +0 -1
- package/packages/forms/dist/components/controlled/CheckboxGroup.d.ts.map +0 -1
- package/packages/forms/dist/components/controlled/InputItem.d.ts.map +0 -1
- package/packages/forms/dist/components/controlled/RadioGroup.d.ts.map +0 -1
- package/packages/forms/dist/components/controlled/SelectControl.d.ts.map +0 -1
- package/packages/forms/dist/components/controlled/TextareaControl.d.ts.map +0 -1
- package/packages/forms/dist/components/controlled/index.d.ts.map +0 -1
- package/packages/forms/dist/components/index.d.ts +0 -8
- package/packages/forms/dist/components/index.d.ts.map +0 -1
- package/packages/forms/dist/index.cjs.js.map +0 -1
- package/packages/forms/dist/index.d.ts +0 -3
- package/packages/forms/dist/index.d.ts.map +0 -1
- package/packages/forms/dist/index.es.js.map +0 -1
- package/packages/forms/dist/utils/class.d.ts.map +0 -1
- package/packages/forms/node_modules/.bin/jest +0 -17
- package/packages/forms/node_modules/.bin/npm-run-all +0 -17
- package/packages/forms/node_modules/.bin/run-p +0 -17
- package/packages/forms/node_modules/.bin/run-s +0 -17
- package/packages/forms/node_modules/.bin/ts-jest +0 -17
- package/packages/forms/node_modules/.bin/tsc +0 -17
- package/packages/forms/node_modules/.bin/tsc-alias +0 -17
- package/packages/forms/node_modules/.bin/tsserver +0 -17
- package/packages/forms/node_modules/.bin/vite +0 -17
- /package/packages/core/src/{utils/class.ts → libs/cx.ts} +0 -0
- /package/packages/forms/dist/{components → types/components}/Checkbox.d.ts +0 -0
- /package/packages/forms/dist/{components → types/components}/FieldsetControl.d.ts +0 -0
- /package/packages/forms/dist/{components → types/components}/Input.d.ts +0 -0
- /package/packages/forms/dist/{components → types/components}/LabelControl.d.ts +0 -0
- /package/packages/forms/dist/{components → types/components}/Radio.d.ts +0 -0
- /package/packages/forms/dist/{components → types/components}/Select.d.ts +0 -0
- /package/packages/forms/dist/{components → types/components}/Textarea.d.ts +0 -0
- /package/packages/forms/dist/{components → types/components}/context.d.ts +0 -0
- /package/packages/forms/dist/{components → types/components}/controlled/CheckboxGroup.d.ts +0 -0
- /package/packages/forms/dist/{components → types/components}/controlled/InputItem.d.ts +0 -0
- /package/packages/forms/dist/{components → types/components}/controlled/RadioGroup.d.ts +0 -0
- /package/packages/forms/dist/{components → types/components}/controlled/SelectControl.d.ts +0 -0
- /package/packages/forms/dist/{components → types/components}/controlled/TextareaControl.d.ts +0 -0
- /package/packages/forms/dist/{components → types/components}/controlled/index.d.ts +0 -0
- /package/packages/forms/dist/{utils → types/utils}/class.d.ts +0 -0
|
@@ -1,107 +1,78 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { cx } from '../libs/cx'
|
|
2
|
+
import { ComponentWithAs } from '../types/component'
|
|
3
|
+
import { forwardRef } from '../libs/forward-ref'
|
|
4
|
+
import { base, getVariantStyle, getSizeStyle } from './buttonStyle'
|
|
3
5
|
|
|
4
|
-
export interface IconButtonProps
|
|
6
|
+
export interface IconButtonProps {
|
|
5
7
|
variant?: 'primary' | 'secondary'
|
|
8
|
+
size?: 'lg' | 'md' | 'sm' | 'xs'
|
|
6
9
|
iconLayout?: 'left' | 'right'
|
|
7
|
-
rounded?: string
|
|
8
10
|
icon: string
|
|
11
|
+
rounded?: string
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
export const IconButton
|
|
12
|
-
(props, ref) => {
|
|
14
|
+
export const IconButton: ComponentWithAs<'button', IconButtonProps> =
|
|
15
|
+
forwardRef((props, ref) => {
|
|
13
16
|
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
as: Component = 'button',
|
|
18
|
+
variant = 'primary',
|
|
19
|
+
size = 'lg',
|
|
20
|
+
iconLayout = 'left',
|
|
17
21
|
icon,
|
|
18
|
-
iconLayout,
|
|
19
22
|
rounded,
|
|
23
|
+
className,
|
|
24
|
+
children,
|
|
20
25
|
...restProps
|
|
21
26
|
} = props
|
|
22
27
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const align = 'center'
|
|
26
|
-
|
|
27
|
-
const style = `
|
|
28
|
-
${rounded === 'full' ? 'aspect-square' : ''}
|
|
29
|
-
inline-block
|
|
30
|
-
p-4
|
|
31
|
-
text-button
|
|
32
|
-
text-${align}
|
|
33
|
-
rounded-${rounded ? rounded : 'lg'}
|
|
34
|
-
cursor-pointer
|
|
35
|
-
whitespace-nowrap
|
|
36
|
-
border
|
|
37
|
-
border-solid
|
|
38
|
-
border-sea-800
|
|
39
|
-
active:enabled:border-sea-800/[.8]
|
|
40
|
-
hover:enabled:border-sea-800/[.85]
|
|
41
|
-
focus:outline
|
|
42
|
-
focus:outline-2
|
|
43
|
-
focus:outline-wood-600
|
|
44
|
-
disabled:border-sumi-500
|
|
45
|
-
disabled:cursor-not-allowed
|
|
46
|
-
`
|
|
28
|
+
const styleFontSize = `${size === 'xs' ? `scale-105` : `scale-125`}`
|
|
47
29
|
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
text-sea-800
|
|
58
|
-
bg-transparent
|
|
59
|
-
active:enabled:bg-sea-50/[.60]
|
|
60
|
-
hover:enabled:bg-sea-50
|
|
61
|
-
active:enabled:text-sea-800/[.85]
|
|
62
|
-
hover:enabled:text-sea-800/[.85]
|
|
63
|
-
disabled:text-sumi-500
|
|
64
|
-
`
|
|
30
|
+
const styleIcon = `
|
|
31
|
+
inline-block
|
|
32
|
+
align-middle
|
|
33
|
+
mb-1
|
|
34
|
+
font-icon
|
|
35
|
+
font-light
|
|
36
|
+
leading-[0px]
|
|
37
|
+
antialiased
|
|
38
|
+
`
|
|
65
39
|
|
|
66
|
-
const
|
|
67
|
-
primary: primary,
|
|
68
|
-
secondary: secondary
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const iconStyle = `
|
|
72
|
-
inline-block
|
|
73
|
-
align-middle
|
|
74
|
-
font-icon
|
|
75
|
-
text-2xl
|
|
76
|
-
font-light
|
|
77
|
-
leading-4
|
|
78
|
-
antialiased
|
|
79
|
-
mb-1
|
|
80
|
-
`
|
|
40
|
+
const styleRounded = `${rounded ? `aspect-square !rounded-full !py-0` : ''}`
|
|
81
41
|
|
|
82
42
|
// When text is specified on a button, set the 'aria-hidden' attribute of the icon to true.
|
|
83
43
|
const ariaHidden = children ? true : false
|
|
84
44
|
|
|
85
45
|
return (
|
|
86
|
-
<
|
|
87
|
-
className={cx(
|
|
46
|
+
<Component
|
|
47
|
+
className={cx(
|
|
48
|
+
base,
|
|
49
|
+
getVariantStyle(variant),
|
|
50
|
+
getSizeStyle(size),
|
|
51
|
+
styleRounded,
|
|
52
|
+
className
|
|
53
|
+
)}
|
|
88
54
|
{...restProps}
|
|
89
55
|
ref={ref}
|
|
90
56
|
>
|
|
91
|
-
{
|
|
92
|
-
<span
|
|
57
|
+
{iconLayout == 'left' && (
|
|
58
|
+
<span
|
|
59
|
+
className={cx(styleIcon, styleFontSize)}
|
|
60
|
+
aria-hidden={ariaHidden}
|
|
61
|
+
>
|
|
93
62
|
{icon}
|
|
94
63
|
</span>
|
|
95
64
|
)}
|
|
96
|
-
{children && <span className="mx-1
|
|
97
|
-
{
|
|
98
|
-
<span
|
|
65
|
+
{children && <span className="mx-1">{children}</span>}
|
|
66
|
+
{iconLayout == 'right' && (
|
|
67
|
+
<span
|
|
68
|
+
className={cx(styleIcon, styleFontSize)}
|
|
69
|
+
aria-hidden={ariaHidden}
|
|
70
|
+
>
|
|
99
71
|
{icon}
|
|
100
72
|
</span>
|
|
101
73
|
)}
|
|
102
|
-
</
|
|
74
|
+
</Component>
|
|
103
75
|
)
|
|
104
|
-
}
|
|
105
|
-
)
|
|
76
|
+
})
|
|
106
77
|
|
|
107
78
|
IconButton.displayName = 'IconButton'
|
|
@@ -1,47 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { cx } from '../libs/cx'
|
|
2
|
+
import { ComponentWithAs } from '../types/component'
|
|
3
|
+
import { forwardRef } from '../libs/forward-ref'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
const converted = url.toLowerCase()
|
|
5
|
+
export interface LinkProps {}
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
return 'PDF'
|
|
9
|
-
}
|
|
10
|
-
if (converted.endsWith('.doc') || converted.endsWith('.docx')) {
|
|
11
|
-
return 'Word'
|
|
12
|
-
}
|
|
13
|
-
if (converted.endsWith('.xls') || converted.endsWith('.xlsx')) {
|
|
14
|
-
return 'Excel'
|
|
15
|
-
}
|
|
16
|
-
if (converted.endsWith('.csv')) {
|
|
17
|
-
return 'CSV'
|
|
18
|
-
}
|
|
19
|
-
if (converted.endsWith('.json')) {
|
|
20
|
-
return 'JSON'
|
|
21
|
-
}
|
|
22
|
-
if (converted.endsWith('.ndjson')) {
|
|
23
|
-
return 'NDJSON'
|
|
24
|
-
}
|
|
25
|
-
if (converted.includes('youtu.be')) {
|
|
26
|
-
return 'YouTube'
|
|
27
|
-
}
|
|
28
|
-
return null
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface LinkProps extends React.ComponentPropsWithRef<'a'> {}
|
|
32
|
-
|
|
33
|
-
export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
7
|
+
export const Link: ComponentWithAs<'a', LinkProps> = forwardRef(
|
|
34
8
|
(props, ref) => {
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
|
|
9
|
+
const {
|
|
10
|
+
as: Component = 'a',
|
|
11
|
+
href,
|
|
12
|
+
className,
|
|
13
|
+
children,
|
|
14
|
+
...restProps
|
|
15
|
+
} = props
|
|
38
16
|
|
|
17
|
+
const styleUnderLine = `
|
|
18
|
+
underline
|
|
19
|
+
underline-offset-[0.125em]
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
// Make lines break at each word
|
|
39
23
|
const style = `
|
|
40
24
|
rounded-sm
|
|
41
25
|
cursor-pointer
|
|
42
26
|
text-sea-600
|
|
43
|
-
underline
|
|
44
|
-
underline-offset-[0.125em]
|
|
45
27
|
hover:text-sea-800
|
|
46
28
|
active:text-sea-800
|
|
47
29
|
visited:text-sea-900
|
|
@@ -49,11 +31,22 @@ export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
49
31
|
focus:outline-2
|
|
50
32
|
focus:outline-wood-500
|
|
51
33
|
disabled:border-sumi-500
|
|
34
|
+
[overflow-wrap:anywhere]
|
|
35
|
+
`
|
|
36
|
+
|
|
37
|
+
const styleIcon = `
|
|
38
|
+
align-middle
|
|
39
|
+
ml-0.5
|
|
40
|
+
text-sumi-700
|
|
41
|
+
font-icon
|
|
42
|
+
font-light
|
|
43
|
+
leading-4
|
|
44
|
+
antialiased
|
|
52
45
|
`
|
|
53
46
|
|
|
54
|
-
if (href
|
|
47
|
+
if (href?.startsWith('http')) {
|
|
55
48
|
return (
|
|
56
|
-
<
|
|
49
|
+
<Component
|
|
57
50
|
className={cx(style, className)}
|
|
58
51
|
href={href}
|
|
59
52
|
target="_blank"
|
|
@@ -61,16 +54,23 @@ export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
61
54
|
{...restProps}
|
|
62
55
|
ref={ref}
|
|
63
56
|
>
|
|
64
|
-
{children}
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
<span className={styleUnderLine}>{children}</span>
|
|
58
|
+
<span className={cx(styleIcon)} aria-hidden="true">
|
|
59
|
+
open_in_new
|
|
60
|
+
</span>
|
|
61
|
+
<span className="sr-only">Opens in new tab</span>
|
|
62
|
+
</Component>
|
|
67
63
|
)
|
|
68
64
|
}
|
|
69
65
|
return (
|
|
70
|
-
<
|
|
66
|
+
<Component
|
|
67
|
+
className={cx(style, styleUnderLine, className)}
|
|
68
|
+
href={href}
|
|
69
|
+
{...restProps}
|
|
70
|
+
ref={ref}
|
|
71
|
+
>
|
|
71
72
|
{children}
|
|
72
|
-
|
|
73
|
-
</a>
|
|
73
|
+
</Component>
|
|
74
74
|
)
|
|
75
75
|
}
|
|
76
76
|
)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { cx } from '../
|
|
2
|
+
import { cx } from '../libs/cx'
|
|
3
3
|
|
|
4
4
|
export interface TableProps extends React.ComponentPropsWithoutRef<'table'> {}
|
|
5
5
|
|
|
6
6
|
const styleBorder = `
|
|
7
7
|
border
|
|
8
8
|
border-collapse
|
|
9
|
-
border-
|
|
9
|
+
border-[#cccccc]
|
|
10
10
|
`
|
|
11
11
|
|
|
12
12
|
export const Table = (props: TableProps) => {
|
|
@@ -71,7 +71,8 @@ export const Th = (props: ThProps) => {
|
|
|
71
71
|
|
|
72
72
|
const style = `
|
|
73
73
|
p-2
|
|
74
|
-
bg-
|
|
74
|
+
bg-[#f8f8fb]
|
|
75
|
+
text-base
|
|
75
76
|
text-left
|
|
76
77
|
`
|
|
77
78
|
return (
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export const base = `
|
|
2
|
+
inline-block
|
|
3
|
+
text-button
|
|
4
|
+
text-center
|
|
5
|
+
cursor-pointer
|
|
6
|
+
select-none
|
|
7
|
+
touch-manipulation
|
|
8
|
+
whitespace-nowrap
|
|
9
|
+
outline-offset-2
|
|
10
|
+
border
|
|
11
|
+
border-solid
|
|
12
|
+
border-sea-800
|
|
13
|
+
active:border-sea-1200
|
|
14
|
+
hover:border-sea-900
|
|
15
|
+
focus:outline
|
|
16
|
+
focus:outline-2
|
|
17
|
+
focus:outline-wood-600
|
|
18
|
+
disabled:border-sumi-500
|
|
19
|
+
disabled:cursor-not-allowed
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
const primary = `
|
|
23
|
+
text-white-1000
|
|
24
|
+
bg-sea-800
|
|
25
|
+
active:bg-sea-1200
|
|
26
|
+
hover:bg-sea-900
|
|
27
|
+
disabled:bg-sumi-500
|
|
28
|
+
disabled:text-white-1000
|
|
29
|
+
`
|
|
30
|
+
|
|
31
|
+
const secondary = `
|
|
32
|
+
text-sea-800
|
|
33
|
+
bg-transparent
|
|
34
|
+
active:bg-sea-200
|
|
35
|
+
hover:bg-sea-100
|
|
36
|
+
active:text-sea-1200
|
|
37
|
+
hover:text-sea-900
|
|
38
|
+
disabled:text-sumi-500
|
|
39
|
+
disabled:bg-transparent
|
|
40
|
+
`
|
|
41
|
+
|
|
42
|
+
const styles: { [key: string]: string } = {
|
|
43
|
+
primary: primary,
|
|
44
|
+
secondary: secondary
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const getVariantStyle = (variant: 'primary' | 'secondary') => {
|
|
48
|
+
return styles[variant]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const params: {
|
|
52
|
+
[key: string]: string
|
|
53
|
+
} = {
|
|
54
|
+
lg: `
|
|
55
|
+
p-4
|
|
56
|
+
text-button
|
|
57
|
+
rounded-lg
|
|
58
|
+
`,
|
|
59
|
+
md: `
|
|
60
|
+
px-4
|
|
61
|
+
py-3
|
|
62
|
+
text-button
|
|
63
|
+
rounded-lg
|
|
64
|
+
`,
|
|
65
|
+
sm: `
|
|
66
|
+
px-3
|
|
67
|
+
py-1.5
|
|
68
|
+
my-1
|
|
69
|
+
text-button
|
|
70
|
+
rounded-md
|
|
71
|
+
`,
|
|
72
|
+
xs: `
|
|
73
|
+
px-2
|
|
74
|
+
py-[7px]
|
|
75
|
+
my-2
|
|
76
|
+
text-button-sm
|
|
77
|
+
!leading-[14px]
|
|
78
|
+
rounded
|
|
79
|
+
`
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const getSizeStyle = (size: 'lg' | 'md' | 'sm' | 'xs') => {
|
|
83
|
+
return params[size]
|
|
84
|
+
}
|
|
@@ -1,14 +1,31 @@
|
|
|
1
|
-
export { Button } from './Button'
|
|
1
|
+
export { Button, type ButtonProps } from './Button'
|
|
2
2
|
export { Card, CardHeader, CardBody, CardFooter } from './Card'
|
|
3
|
-
export {
|
|
3
|
+
export type {
|
|
4
|
+
CardProps,
|
|
5
|
+
CardHeaderProps,
|
|
6
|
+
CardBodyProps,
|
|
7
|
+
CardFooterProps
|
|
8
|
+
} from './Card'
|
|
9
|
+
export { Code, type CodeProps } from './Code'
|
|
4
10
|
export { Faq, Question, Answer } from './Faq'
|
|
11
|
+
export type { FaqProps, QuestionProps, AnswerProps } from './Faq'
|
|
5
12
|
export { H1, H2, H3, H4, H5, H6 } from './Heading'
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
13
|
+
export type { HeadingProps } from './Heading'
|
|
14
|
+
export { Icon, type IconProps } from './Icon'
|
|
15
|
+
export { IconButton, type IconButtonProps } from './IconButton'
|
|
16
|
+
export { Link, type LinkProps } from './Link'
|
|
17
|
+
export { Ol, Ul, type OlProps, type UlProps } from './List'
|
|
18
|
+
export { Pre, type PreProps } from './Pre'
|
|
11
19
|
export { Table, Caption, Thead, Tbody, Th, Tr, Td } from './Table'
|
|
20
|
+
export type {
|
|
21
|
+
TableProps,
|
|
22
|
+
CaptionProps,
|
|
23
|
+
TheadProps,
|
|
24
|
+
TbodyProps,
|
|
25
|
+
ThProps,
|
|
26
|
+
TrProps,
|
|
27
|
+
TdProps
|
|
28
|
+
} from './Table'
|
|
12
29
|
|
|
13
30
|
/** @deprecated use Card instead */
|
|
14
31
|
export { InfoCard } from './InfoCard'
|
|
@@ -29,3 +29,29 @@ export {
|
|
|
29
29
|
Tr,
|
|
30
30
|
Td
|
|
31
31
|
} from './components'
|
|
32
|
+
|
|
33
|
+
export type {
|
|
34
|
+
ButtonProps,
|
|
35
|
+
CardProps,
|
|
36
|
+
CardHeaderProps,
|
|
37
|
+
CardBodyProps,
|
|
38
|
+
CardFooterProps,
|
|
39
|
+
CodeProps,
|
|
40
|
+
FaqProps,
|
|
41
|
+
QuestionProps,
|
|
42
|
+
AnswerProps,
|
|
43
|
+
HeadingProps,
|
|
44
|
+
IconProps,
|
|
45
|
+
IconButtonProps,
|
|
46
|
+
LinkProps,
|
|
47
|
+
OlProps,
|
|
48
|
+
UlProps,
|
|
49
|
+
PreProps,
|
|
50
|
+
TableProps,
|
|
51
|
+
CaptionProps,
|
|
52
|
+
TheadProps,
|
|
53
|
+
TbodyProps,
|
|
54
|
+
ThProps,
|
|
55
|
+
TrProps,
|
|
56
|
+
TdProps
|
|
57
|
+
} from './components'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2019 Segun Adebayo
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { ComponentProps, forwardRef as forwardReactRef } from 'react'
|
|
26
|
+
import { As, ComponentWithAs, RightJoinProps } from '../types/component'
|
|
27
|
+
|
|
28
|
+
export function forwardRef<Props extends object, Component extends As>(
|
|
29
|
+
component: React.ForwardRefRenderFunction<
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
any,
|
|
32
|
+
RightJoinProps<ComponentProps<Component>, Props> & {
|
|
33
|
+
as?: As
|
|
34
|
+
}
|
|
35
|
+
>
|
|
36
|
+
) {
|
|
37
|
+
return forwardReactRef(component) as unknown as ComponentWithAs<
|
|
38
|
+
Component,
|
|
39
|
+
Props
|
|
40
|
+
>
|
|
41
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2019 Segun Adebayo
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { ComponentProps } from 'react'
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
export type As<Props = any> = React.ElementType<Props>
|
|
29
|
+
|
|
30
|
+
export type OmitCommonProps<
|
|
31
|
+
Target,
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
OmitAdditionalProps extends keyof any = never
|
|
34
|
+
> = Omit<Target, 'as' | OmitAdditionalProps>
|
|
35
|
+
|
|
36
|
+
export type RightJoinProps<
|
|
37
|
+
SourceProps extends object = object,
|
|
38
|
+
OverrideProps extends object = object
|
|
39
|
+
> = OmitCommonProps<SourceProps, keyof OverrideProps> & OverrideProps
|
|
40
|
+
|
|
41
|
+
type MergeWithAs<
|
|
42
|
+
ComponentProps extends object,
|
|
43
|
+
AsProps extends object,
|
|
44
|
+
AdditionalProps extends object = object,
|
|
45
|
+
AsComponent extends As = As
|
|
46
|
+
> = RightJoinProps<ComponentProps, AdditionalProps> &
|
|
47
|
+
RightJoinProps<AsProps, AdditionalProps> & {
|
|
48
|
+
as?: AsComponent
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type PropsWithAs<
|
|
52
|
+
Component extends As,
|
|
53
|
+
Props extends object
|
|
54
|
+
> = RightJoinProps<ComponentProps<Component>, Props> & {
|
|
55
|
+
as?: As
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type PropsOf<T extends As> = React.ComponentPropsWithoutRef<T> & {
|
|
59
|
+
as?: As
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type ComponentWithAs<
|
|
63
|
+
Component extends As,
|
|
64
|
+
Props extends object = object
|
|
65
|
+
> = {
|
|
66
|
+
<AsComponent extends As = Component>(
|
|
67
|
+
props: MergeWithAs<
|
|
68
|
+
React.ComponentProps<Component>,
|
|
69
|
+
React.ComponentProps<AsComponent>,
|
|
70
|
+
Props,
|
|
71
|
+
AsComponent
|
|
72
|
+
>
|
|
73
|
+
): JSX.Element
|
|
74
|
+
displayName?: string
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
+
propTypes?: React.WeakValidationMap<any>
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
+
contextTypes?: React.ValidationMap<any>
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
+
defaultProps?: Partial<any>
|
|
81
|
+
id?: string
|
|
82
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="vitest" />
|
|
1
2
|
import { resolve } from 'path'
|
|
2
3
|
import { defineConfig } from 'vite'
|
|
3
4
|
import react from '@vitejs/plugin-react-swc'
|
|
@@ -19,8 +20,10 @@ export default defineConfig({
|
|
|
19
20
|
},
|
|
20
21
|
rollupOptions: {
|
|
21
22
|
external: [...Object.keys(peerDependencies)]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
test: {
|
|
26
|
+
globals: true,
|
|
27
|
+
environment: 'jsdom'
|
|
25
28
|
}
|
|
26
29
|
})
|