@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.
Files changed (169) hide show
  1. package/package.json +16 -1
  2. package/packages/config/package.json +23 -27
  3. package/packages/config/src/index.ts +66 -1
  4. package/packages/config/tests/index.test.ts +1 -1
  5. package/packages/config/tsconfig.json +9 -17
  6. package/packages/config/tsconfig.node.json +6 -0
  7. package/packages/config/vite.config.ts +5 -3
  8. package/packages/core/package.json +27 -44
  9. package/packages/core/src/components/Button.tsx +23 -56
  10. package/packages/core/src/components/Card.tsx +30 -20
  11. package/packages/core/src/components/Code.tsx +1 -1
  12. package/packages/core/src/components/Faq.tsx +3 -5
  13. package/packages/core/src/components/Heading.tsx +1 -1
  14. package/packages/core/src/components/Icon.tsx +15 -10
  15. package/packages/core/src/components/IconButton.tsx +47 -76
  16. package/packages/core/src/components/InfoCard.tsx +1 -1
  17. package/packages/core/src/components/Link.tsx +44 -44
  18. package/packages/core/src/components/List.tsx +1 -1
  19. package/packages/core/src/components/Pre.tsx +1 -1
  20. package/packages/core/src/components/Table.tsx +4 -3
  21. package/packages/core/src/components/buttonStyle.ts +84 -0
  22. package/packages/core/src/components/index.ts +24 -7
  23. package/packages/core/src/index.ts +26 -0
  24. package/packages/core/src/libs/forward-ref.ts +41 -0
  25. package/packages/core/src/types/component.ts +82 -0
  26. package/packages/core/tsconfig.json +2 -1
  27. package/packages/core/tsconfig.node.json +1 -4
  28. package/packages/core/vite.config.ts +6 -3
  29. package/packages/forms/dist/components/Checkbox.js +27 -24
  30. package/packages/forms/dist/components/Checkbox.js.map +1 -1
  31. package/packages/forms/dist/components/FileInput.js +55 -0
  32. package/packages/forms/dist/components/FileInput.js.map +1 -0
  33. package/packages/forms/dist/components/Input.js +15 -13
  34. package/packages/forms/dist/components/Input.js.map +1 -1
  35. package/packages/forms/dist/components/LabelControl.js +7 -1
  36. package/packages/forms/dist/components/LabelControl.js.map +1 -1
  37. package/packages/forms/dist/components/Radio.js +26 -24
  38. package/packages/forms/dist/components/Radio.js.map +1 -1
  39. package/packages/forms/dist/components/Select.js +27 -25
  40. package/packages/forms/dist/components/Select.js.map +1 -1
  41. package/packages/forms/dist/components/Textarea.js +15 -13
  42. package/packages/forms/dist/components/Textarea.js.map +1 -1
  43. package/packages/forms/dist/components/index.js +1 -0
  44. package/packages/forms/dist/components/index.js.map +1 -1
  45. package/packages/forms/dist/index.cjs.js +155 -101
  46. package/packages/forms/dist/index.es.js +490 -411
  47. package/packages/forms/dist/index.js +1 -1
  48. package/packages/forms/dist/index.js.map +1 -1
  49. package/packages/forms/dist/types/components/Checkbox.d.ts.map +1 -0
  50. package/packages/forms/dist/types/components/FieldsetControl.d.ts.map +1 -0
  51. package/packages/forms/dist/types/components/FileInput.d.ts +5 -0
  52. package/packages/forms/dist/types/components/FileInput.d.ts.map +1 -0
  53. package/packages/forms/dist/types/components/Input.d.ts.map +1 -0
  54. package/packages/forms/dist/types/components/LabelControl.d.ts.map +1 -0
  55. package/packages/forms/dist/types/components/Radio.d.ts.map +1 -0
  56. package/packages/forms/dist/types/components/Select.d.ts.map +1 -0
  57. package/packages/forms/dist/types/components/Textarea.d.ts.map +1 -0
  58. package/packages/forms/dist/types/components/context.d.ts.map +1 -0
  59. package/packages/forms/dist/types/components/controlled/CheckboxGroup.d.ts.map +1 -0
  60. package/packages/forms/dist/types/components/controlled/InputItem.d.ts.map +1 -0
  61. package/packages/forms/dist/types/components/controlled/RadioGroup.d.ts.map +1 -0
  62. package/packages/forms/dist/types/components/controlled/SelectControl.d.ts.map +1 -0
  63. package/packages/forms/dist/types/components/controlled/TextareaControl.d.ts.map +1 -0
  64. package/packages/forms/dist/types/components/controlled/index.d.ts.map +1 -0
  65. package/packages/forms/dist/types/components/index.d.ts +9 -0
  66. package/packages/forms/dist/types/components/index.d.ts.map +1 -0
  67. package/packages/forms/dist/types/index.d.ts +4 -0
  68. package/packages/forms/dist/types/index.d.ts.map +1 -0
  69. package/packages/forms/dist/types/utils/class.d.ts.map +1 -0
  70. package/packages/forms/node_modules/.bin/eslint +17 -0
  71. package/packages/forms/node_modules/.bin/tailwind +2 -2
  72. package/packages/forms/node_modules/.bin/tailwindcss +2 -2
  73. package/packages/forms/node_modules/.bin/ts-node +4 -4
  74. package/packages/forms/node_modules/.bin/ts-node-cwd +4 -4
  75. package/packages/forms/node_modules/.bin/ts-node-esm +4 -4
  76. package/packages/forms/node_modules/.bin/ts-node-script +4 -4
  77. package/packages/forms/node_modules/.bin/ts-node-transpile-only +4 -4
  78. package/packages/forms/node_modules/.bin/ts-script +4 -4
  79. package/packages/forms/node_modules/.bin/vitest +17 -0
  80. package/packages/forms/node_modules/.vitest/results.json +1 -0
  81. package/packages/forms/package.json +23 -31
  82. package/packages/forms/src/components/Checkbox.tsx +27 -23
  83. package/packages/forms/src/components/FileInput.tsx +74 -0
  84. package/packages/forms/src/components/Input.tsx +16 -14
  85. package/packages/forms/src/components/LabelControl.tsx +13 -6
  86. package/packages/forms/src/components/Radio.tsx +28 -23
  87. package/packages/forms/src/components/Select.tsx +28 -26
  88. package/packages/forms/src/components/Textarea.tsx +16 -13
  89. package/packages/forms/src/components/index.ts +8 -7
  90. package/packages/forms/src/index.ts +12 -0
  91. package/packages/forms/tsconfig.json +4 -3
  92. package/packages/forms/tsconfig.node.json +1 -4
  93. package/packages/forms/vite.config.ts +6 -3
  94. package/packages/config/jest.config.ts +0 -10
  95. package/packages/core/coverage/clover.xml +0 -258
  96. package/packages/core/coverage/coverage-final.json +0 -2700
  97. package/packages/core/coverage/lcov-report/base.css +0 -362
  98. package/packages/core/coverage/lcov-report/block-navigation.js +0 -85
  99. package/packages/core/coverage/lcov-report/favicon.png +0 -0
  100. package/packages/core/coverage/lcov-report/index.html +0 -216
  101. package/packages/core/coverage/lcov-report/prettify.css +0 -101
  102. package/packages/core/coverage/lcov-report/prettify.js +0 -1004
  103. package/packages/core/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  104. package/packages/core/coverage/lcov-report/sorter.js +0 -191
  105. package/packages/core/coverage/lcov-report/src/components/Button.tsx.html +0 -303
  106. package/packages/core/coverage/lcov-report/src/components/Card.tsx.html +0 -399
  107. package/packages/core/coverage/lcov-report/src/components/Code.tsx.html +0 -144
  108. package/packages/core/coverage/lcov-report/src/components/Heading.tsx.html +0 -405
  109. package/packages/core/coverage/lcov-report/src/components/Icon.tsx.html +0 -183
  110. package/packages/core/coverage/lcov-report/src/components/IconButton.tsx.html +0 -378
  111. package/packages/core/coverage/lcov-report/src/components/InfoCard.tsx.html +0 -240
  112. package/packages/core/coverage/lcov-report/src/components/Link.tsx.html +0 -324
  113. package/packages/core/coverage/lcov-report/src/components/List.tsx.html +0 -204
  114. package/packages/core/coverage/lcov-report/src/components/Pre.tsx.html +0 -153
  115. package/packages/core/coverage/lcov-report/src/components/Table.tsx.html +0 -429
  116. package/packages/core/coverage/lcov-report/src/components/index.html +0 -396
  117. package/packages/core/coverage/lcov-report/src/components/index.ts.html +0 -126
  118. package/packages/core/coverage/lcov-report/src/index.html +0 -176
  119. package/packages/core/coverage/lcov-report/src/index.ts.html +0 -171
  120. package/packages/core/coverage/lcov-report/src/utils/class.ts.html +0 -90
  121. package/packages/core/coverage/lcov-report/src/utils/index.html +0 -176
  122. package/packages/core/coverage/lcov.info +0 -523
  123. package/packages/core/jest.config.ts +0 -11
  124. package/packages/forms/dist/components/Checkbox.d.ts.map +0 -1
  125. package/packages/forms/dist/components/FieldsetControl.d.ts.map +0 -1
  126. package/packages/forms/dist/components/Input.d.ts.map +0 -1
  127. package/packages/forms/dist/components/LabelControl.d.ts.map +0 -1
  128. package/packages/forms/dist/components/Radio.d.ts.map +0 -1
  129. package/packages/forms/dist/components/Select.d.ts.map +0 -1
  130. package/packages/forms/dist/components/Textarea.d.ts.map +0 -1
  131. package/packages/forms/dist/components/context.d.ts.map +0 -1
  132. package/packages/forms/dist/components/controlled/CheckboxGroup.d.ts.map +0 -1
  133. package/packages/forms/dist/components/controlled/InputItem.d.ts.map +0 -1
  134. package/packages/forms/dist/components/controlled/RadioGroup.d.ts.map +0 -1
  135. package/packages/forms/dist/components/controlled/SelectControl.d.ts.map +0 -1
  136. package/packages/forms/dist/components/controlled/TextareaControl.d.ts.map +0 -1
  137. package/packages/forms/dist/components/controlled/index.d.ts.map +0 -1
  138. package/packages/forms/dist/components/index.d.ts +0 -8
  139. package/packages/forms/dist/components/index.d.ts.map +0 -1
  140. package/packages/forms/dist/index.cjs.js.map +0 -1
  141. package/packages/forms/dist/index.d.ts +0 -3
  142. package/packages/forms/dist/index.d.ts.map +0 -1
  143. package/packages/forms/dist/index.es.js.map +0 -1
  144. package/packages/forms/dist/utils/class.d.ts.map +0 -1
  145. package/packages/forms/node_modules/.bin/jest +0 -17
  146. package/packages/forms/node_modules/.bin/npm-run-all +0 -17
  147. package/packages/forms/node_modules/.bin/run-p +0 -17
  148. package/packages/forms/node_modules/.bin/run-s +0 -17
  149. package/packages/forms/node_modules/.bin/ts-jest +0 -17
  150. package/packages/forms/node_modules/.bin/tsc +0 -17
  151. package/packages/forms/node_modules/.bin/tsc-alias +0 -17
  152. package/packages/forms/node_modules/.bin/tsserver +0 -17
  153. package/packages/forms/node_modules/.bin/vite +0 -17
  154. /package/packages/core/src/{utils/class.ts → libs/cx.ts} +0 -0
  155. /package/packages/forms/dist/{components → types/components}/Checkbox.d.ts +0 -0
  156. /package/packages/forms/dist/{components → types/components}/FieldsetControl.d.ts +0 -0
  157. /package/packages/forms/dist/{components → types/components}/Input.d.ts +0 -0
  158. /package/packages/forms/dist/{components → types/components}/LabelControl.d.ts +0 -0
  159. /package/packages/forms/dist/{components → types/components}/Radio.d.ts +0 -0
  160. /package/packages/forms/dist/{components → types/components}/Select.d.ts +0 -0
  161. /package/packages/forms/dist/{components → types/components}/Textarea.d.ts +0 -0
  162. /package/packages/forms/dist/{components → types/components}/context.d.ts +0 -0
  163. /package/packages/forms/dist/{components → types/components}/controlled/CheckboxGroup.d.ts +0 -0
  164. /package/packages/forms/dist/{components → types/components}/controlled/InputItem.d.ts +0 -0
  165. /package/packages/forms/dist/{components → types/components}/controlled/RadioGroup.d.ts +0 -0
  166. /package/packages/forms/dist/{components → types/components}/controlled/SelectControl.d.ts +0 -0
  167. /package/packages/forms/dist/{components → types/components}/controlled/TextareaControl.d.ts +0 -0
  168. /package/packages/forms/dist/{components → types/components}/controlled/index.d.ts +0 -0
  169. /package/packages/forms/dist/{utils → types/utils}/class.d.ts +0 -0
@@ -1,107 +1,78 @@
1
- import React from 'react'
2
- import { cx } from '../utils/class'
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 extends React.ComponentPropsWithRef<'button'> {
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 = React.forwardRef<HTMLButtonElement, IconButtonProps>(
12
- (props, ref) => {
14
+ export const IconButton: ComponentWithAs<'button', IconButtonProps> =
15
+ forwardRef((props, ref) => {
13
16
  const {
14
- className,
15
- children,
16
- variant,
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 layout = iconLayout ?? 'left'
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 primary = `
49
- text-white-1000
50
- bg-sea-800
51
- active:enabled:bg-sea-800/[.8]
52
- hover:enabled:bg-sea-800/[.85]
53
- disabled:bg-sumi-500
54
- disabled:text-white-1000
55
- `
56
- const secondary = `
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 styles = {
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
- <button
87
- className={cx(style, styles[variant ?? 'primary'], className)}
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
- {layout == 'left' && (
92
- <span className={cx(iconStyle)} aria-hidden={ariaHidden}>
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 inline-block">{children}</span>}
97
- {layout == 'right' && (
98
- <span className={cx(iconStyle)} aria-hidden={ariaHidden}>
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
- </button>
74
+ </Component>
103
75
  )
104
- }
105
- )
76
+ })
106
77
 
107
78
  IconButton.displayName = 'IconButton'
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { cx } from '../utils/class'
2
+ import { cx } from '../libs/cx'
3
3
 
4
4
  export interface InfoCardProps
5
5
  extends React.ComponentPropsWithoutRef<'section'> {
@@ -1,47 +1,29 @@
1
- import React from 'react'
2
- import { cx } from '../utils/class'
1
+ import { cx } from '../libs/cx'
2
+ import { ComponentWithAs } from '../types/component'
3
+ import { forwardRef } from '../libs/forward-ref'
3
4
 
4
- const getFileType = (url: string) => {
5
- const converted = url.toLowerCase()
5
+ export interface LinkProps {}
6
6
 
7
- if (converted.endsWith('.pdf')) {
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 { className, children, ...restProps } = props
36
- const href = props.href ?? ''
37
- const fileType = getFileType(href)
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.startsWith('http')) {
47
+ if (href?.startsWith('http')) {
55
48
  return (
56
- <a
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
- {fileType ? `(${fileType})` : null}
66
- </a>
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
- <a className={cx(style, className)} href={href} {...restProps} ref={ref}>
66
+ <Component
67
+ className={cx(style, styleUnderLine, className)}
68
+ href={href}
69
+ {...restProps}
70
+ ref={ref}
71
+ >
71
72
  {children}
72
- {fileType ? `(${fileType})` : null}
73
- </a>
73
+ </Component>
74
74
  )
75
75
  }
76
76
  )
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { cx } from '../utils/class'
2
+ import { cx } from '../libs/cx'
3
3
 
4
4
  export interface UlProps extends React.ComponentPropsWithoutRef<'ul'> {}
5
5
 
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { cx } from '../utils/class'
2
+ import { cx } from '../libs/cx'
3
3
 
4
4
  export interface PreProps extends React.ComponentPropsWithoutRef<'pre'> {}
5
5
 
@@ -1,12 +1,12 @@
1
1
  import React from 'react'
2
- import { cx } from '../utils/class'
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-sumi-900
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-sumi-100
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 { Code } from './Code'
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 { Icon } from './Icon'
7
- export { IconButton } from './IconButton'
8
- export { Link } from './Link'
9
- export { Ol, Ul } from './List'
10
- export { Pre } from './Pre'
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,7 +1,8 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
- "outDir": "dist",
4
+ "declarationDir": "./dist/types",
5
+ "outDir": "./dist",
5
6
  "baseUrl": ".",
6
7
  "paths": {
7
8
  "@/*": ["src/*"]
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "composite": true,
4
- "module": "ESNext",
5
- "moduleResolution": "node",
6
- "allowSyntheticDefaultImports": true
3
+ "composite": true
7
4
  },
8
5
  "include": ["vite.config.ts"]
9
6
  }
@@ -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
- target: 'esnext',
24
- sourcemap: true
23
+ }
24
+ },
25
+ test: {
26
+ globals: true,
27
+ environment: 'jsdom'
25
28
  }
26
29
  })