@charcoal-ui/react 4.0.0-beta.2 → 4.0.0-beta.4
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/dist/components/Button/index.d.ts +9 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.d.ts +9 -20
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/CheckboxInput/index.d.ts +9 -0
- package/dist/components/CheckboxInput/index.d.ts.map +1 -0
- package/dist/components/DropdownSelector/Popover/index.d.ts +1 -2
- package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts +1 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/useCustomModalOverlay.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/Radio/index.d.ts +4 -4
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/core/CharcoalProvider.d.ts +1 -1
- package/dist/core/CharcoalProvider.d.ts.map +1 -1
- package/dist/index.cjs.js +188 -418
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +86 -0
- package/dist/index.css.map +1 -1
- package/dist/index.esm.js +167 -397
- package/dist/index.esm.js.map +1 -1
- package/package.json +14 -17
- package/src/components/Button/__snapshots__/index.story.storyshot +11 -49
- package/src/components/Button/__snapshots__/index.test.tsx.snap +11 -0
- package/src/components/Button/index.story.tsx +13 -66
- package/src/components/Button/index.test.tsx +32 -0
- package/src/components/Button/index.tsx +11 -1
- package/src/components/Checkbox/__snapshots__/index.story.storyshot +163 -517
- package/src/components/Checkbox/index.css +21 -0
- package/src/components/Checkbox/index.story.tsx +44 -79
- package/src/components/Checkbox/index.tsx +19 -157
- package/src/components/CheckboxInput/__snapshots__/index.story.storyshot +109 -0
- package/src/components/CheckboxInput/index.css +77 -0
- package/src/components/CheckboxInput/index.story.tsx +35 -0
- package/src/components/CheckboxInput/index.tsx +53 -0
- package/src/components/DropdownSelector/Popover/index.tsx +1 -2
- package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +15 -0
- package/src/components/DropdownSelector/index.tsx +19 -4
- package/src/components/IconButton/__snapshots__/index.story.storyshot +6 -8
- package/src/components/IconButton/index.story.tsx +14 -37
- package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +139 -1
- package/src/components/LoadingSpinner/index.story.tsx +18 -7
- package/src/components/Modal/__snapshots__/index.story.storyshot +2 -0
- package/src/components/Modal/index.tsx +1 -1
- package/src/components/Modal/useCustomModalOverlay.tsx +5 -4
- package/src/components/MultiSelect/__snapshots__/index.story.storyshot +32 -44
- package/src/components/MultiSelect/index.story.tsx +88 -192
- package/src/components/MultiSelect/index.tsx +2 -1
- package/src/components/Radio/__snapshots__/index.story.storyshot +1 -1
- package/src/components/Radio/index.story.tsx +20 -21
- package/src/components/Radio/index.tsx +14 -13
- package/src/components/Switch/__snapshots__/index.story.storyshot +8 -9
- package/src/components/Switch/index.story.tsx +10 -18
- package/src/components/TagItem/__snapshots__/index.story.storyshot +791 -665
- package/src/components/TagItem/index.story.tsx +44 -161
- package/src/components/TextArea/TextArea.story.tsx +62 -24
- package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +1858 -472
- package/src/components/TextArea/index.tsx +2 -0
- package/src/components/TextField/TextField.story.tsx +77 -67
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +2004 -786
- package/src/components/TextField/index.tsx +2 -0
- package/src/components/a11y.test.tsx +1 -1
- package/src/core/CharcoalProvider.tsx +1 -1
- package/dist/components/Button/index.story.d.ts +0 -24
- package/dist/components/Button/index.story.d.ts.map +0 -1
- package/dist/components/Checkbox/index.story.d.ts +0 -8
- package/dist/components/Checkbox/index.story.d.ts.map +0 -1
- package/dist/components/Clickable/index.story.d.ts +0 -6
- package/dist/components/Clickable/index.story.d.ts.map +0 -1
- package/dist/components/DropdownSelector/ListItem/index.story.d.ts +0 -9
- package/dist/components/DropdownSelector/ListItem/index.story.d.ts.map +0 -1
- package/dist/components/DropdownSelector/MenuList/index.story.d.ts +0 -8
- package/dist/components/DropdownSelector/MenuList/index.story.d.ts.map +0 -1
- package/dist/components/DropdownSelector/Popover/index.story.d.ts +0 -5
- package/dist/components/DropdownSelector/Popover/index.story.d.ts.map +0 -1
- package/dist/components/DropdownSelector/index.story.d.ts +0 -19
- package/dist/components/DropdownSelector/index.story.d.ts.map +0 -1
- package/dist/components/Icon/index.story.d.ts +0 -6
- package/dist/components/Icon/index.story.d.ts.map +0 -1
- package/dist/components/IconButton/index.story.d.ts +0 -9
- package/dist/components/IconButton/index.story.d.ts.map +0 -1
- package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts +0 -8
- package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts.map +0 -1
- package/dist/components/LoadingSpinner/index.story.d.ts +0 -6
- package/dist/components/LoadingSpinner/index.story.d.ts.map +0 -1
- package/dist/components/Modal/index.story.d.ts +0 -21
- package/dist/components/Modal/index.story.d.ts.map +0 -1
- package/dist/components/MultiSelect/index.story.d.ts +0 -82
- package/dist/components/MultiSelect/index.story.d.ts.map +0 -1
- package/dist/components/MultiSelect/index.test.d.ts +0 -2
- package/dist/components/MultiSelect/index.test.d.ts.map +0 -1
- package/dist/components/Radio/index.story.d.ts +0 -26
- package/dist/components/Radio/index.story.d.ts.map +0 -1
- package/dist/components/Radio/index.test.d.ts +0 -2
- package/dist/components/Radio/index.test.d.ts.map +0 -1
- package/dist/components/SegmentedControl/index.story.d.ts +0 -7
- package/dist/components/SegmentedControl/index.story.d.ts.map +0 -1
- package/dist/components/Switch/index.story.d.ts +0 -9
- package/dist/components/Switch/index.story.d.ts.map +0 -1
- package/dist/components/TagItem/index.story.d.ts +0 -16
- package/dist/components/TagItem/index.story.d.ts.map +0 -1
- package/dist/components/TextArea/TextArea.story.d.ts +0 -9
- package/dist/components/TextArea/TextArea.story.d.ts.map +0 -1
- package/dist/components/TextField/TextField.story.d.ts +0 -22
- package/dist/components/TextField/TextField.story.d.ts.map +0 -1
- package/dist/components/a11y.test.d.ts +0 -2
- package/dist/components/a11y.test.d.ts.map +0 -1
- package/src/components/LoadingSpinner/LoadingSpinnerIcon.story.tsx +0 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charcoal-ui/react",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -26,27 +26,23 @@
|
|
|
26
26
|
"clean": "rimraf dist .tsbuildinfo"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@charcoal-ui/esbuild-plugin-styled-components": "^4.0.0-beta.
|
|
29
|
+
"@charcoal-ui/esbuild-plugin-styled-components": "^4.0.0-beta.4",
|
|
30
30
|
"@react-types/switch": "^3.1.2",
|
|
31
|
-
"@storybook/addon-actions": "^
|
|
32
|
-
"@storybook/
|
|
33
|
-
"@storybook/addons": "^7.4.1",
|
|
34
|
-
"@storybook/api": "^7.4.1",
|
|
35
|
-
"@storybook/components": "^7.4.1",
|
|
36
|
-
"@storybook/core-events": "^7.4.1",
|
|
37
|
-
"@storybook/react": "^7.4.1",
|
|
38
|
-
"@storybook/react-webpack5": "^7.4.1",
|
|
39
|
-
"@storybook/theming": "^7.4.1",
|
|
31
|
+
"@storybook/addon-actions": "^8.0.5",
|
|
32
|
+
"@storybook/react": "^8.0.5",
|
|
40
33
|
"@testing-library/jest-dom": "^5.16.1",
|
|
41
34
|
"@testing-library/react": "^12.1.2",
|
|
42
35
|
"@testing-library/user-event": "^13.5.0",
|
|
36
|
+
"@types/glob": "^8.1.0",
|
|
43
37
|
"@types/jest": "^27.4.0",
|
|
44
38
|
"@types/jest-axe": "^3.5.3",
|
|
45
39
|
"@types/react": "^17.0.38",
|
|
46
40
|
"@types/react-dom": "^17.0.11",
|
|
47
41
|
"@types/react-router-dom": "^5.3.3",
|
|
42
|
+
"@types/react-test-renderer": "^18.3.0",
|
|
48
43
|
"@types/styled-components": "^5.1.21",
|
|
49
44
|
"@types/warning": "^3.0.0",
|
|
45
|
+
"autoprefixer": "^10.4.19",
|
|
50
46
|
"jest-axe": "^5.0.1",
|
|
51
47
|
"jest-styled-components": "^7.0.8",
|
|
52
48
|
"npm-run-all": "^4.1.5",
|
|
@@ -54,16 +50,16 @@
|
|
|
54
50
|
"react-dom": "^17.0.2",
|
|
55
51
|
"react-router-dom": "^6.2.1",
|
|
56
52
|
"rimraf": "^3.0.2",
|
|
57
|
-
"storybook": "^7.4.1",
|
|
58
53
|
"styled-components": "^5.3.3",
|
|
59
54
|
"tsup": "^6.5.0",
|
|
60
55
|
"typescript": "^4.9.5"
|
|
61
56
|
},
|
|
62
57
|
"dependencies": {
|
|
63
|
-
"@charcoal-ui/
|
|
64
|
-
"@charcoal-ui/
|
|
65
|
-
"@charcoal-ui/
|
|
66
|
-
"@charcoal-ui/
|
|
58
|
+
"@charcoal-ui/foundation": "^4.0.0-beta.4",
|
|
59
|
+
"@charcoal-ui/icons": "^4.0.0-beta.4",
|
|
60
|
+
"@charcoal-ui/styled": "^4.0.0-beta.4",
|
|
61
|
+
"@charcoal-ui/theme": "^4.0.0-beta.4",
|
|
62
|
+
"@charcoal-ui/utils": "^4.0.0-beta.4",
|
|
67
63
|
"@react-aria/button": "^3.9.1",
|
|
68
64
|
"@react-aria/checkbox": "^3.13.0",
|
|
69
65
|
"@react-aria/dialog": "^3.5.10",
|
|
@@ -75,6 +71,7 @@
|
|
|
75
71
|
"@react-aria/textfield": "^3.14.1",
|
|
76
72
|
"@react-aria/utils": "^3.23.0",
|
|
77
73
|
"@react-aria/visually-hidden": "^3.8.8",
|
|
74
|
+
"@react-stately/radio": "^3.10.2",
|
|
78
75
|
"polished": "^4.1.4",
|
|
79
76
|
"react-spring": "^9.0.0",
|
|
80
77
|
"react-stately": "^3.26.0",
|
|
@@ -96,5 +93,5 @@
|
|
|
96
93
|
"url": "https://github.com/pixiv/charcoal.git",
|
|
97
94
|
"directory": "packages/react"
|
|
98
95
|
},
|
|
99
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "788f785fe5cc2bfbf784d10cd603eb027b430c92"
|
|
100
97
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Storybook Tests Button Active 1`] = `
|
|
4
|
-
<div
|
|
5
|
-
data-dark={false}
|
|
6
|
-
>
|
|
7
|
-
<button
|
|
8
|
-
className="charcoal-button"
|
|
9
|
-
data-active={true}
|
|
10
|
-
>
|
|
11
|
-
Button
|
|
12
|
-
</button>
|
|
13
|
-
</div>
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
3
|
exports[`Storybook Tests Button Danger 1`] = `
|
|
17
4
|
<div
|
|
18
5
|
data-dark={false}
|
|
@@ -21,7 +8,7 @@ exports[`Storybook Tests Button Danger 1`] = `
|
|
|
21
8
|
className="charcoal-button"
|
|
22
9
|
data-variant="Danger"
|
|
23
10
|
>
|
|
24
|
-
|
|
11
|
+
Danger
|
|
25
12
|
</button>
|
|
26
13
|
</div>
|
|
27
14
|
`;
|
|
@@ -46,12 +33,12 @@ exports[`Storybook Tests Button Disabled 1`] = `
|
|
|
46
33
|
className="charcoal-button"
|
|
47
34
|
disabled={true}
|
|
48
35
|
>
|
|
49
|
-
|
|
36
|
+
Disabled
|
|
50
37
|
</button>
|
|
51
38
|
</div>
|
|
52
39
|
`;
|
|
53
40
|
|
|
54
|
-
exports[`Storybook Tests Button
|
|
41
|
+
exports[`Storybook Tests Button FullWidth 1`] = `
|
|
55
42
|
<div
|
|
56
43
|
data-dark={false}
|
|
57
44
|
>
|
|
@@ -59,33 +46,20 @@ exports[`Storybook Tests Button Fixed 1`] = `
|
|
|
59
46
|
className="charcoal-button"
|
|
60
47
|
data-full-width={true}
|
|
61
48
|
>
|
|
62
|
-
|
|
49
|
+
Full width
|
|
63
50
|
</button>
|
|
64
51
|
</div>
|
|
65
52
|
`;
|
|
66
53
|
|
|
67
|
-
exports[`Storybook Tests Button
|
|
54
|
+
exports[`Storybook Tests Button IsActive 1`] = `
|
|
68
55
|
<div
|
|
69
56
|
data-dark={false}
|
|
70
57
|
>
|
|
71
58
|
<button
|
|
72
59
|
className="charcoal-button"
|
|
73
|
-
|
|
74
|
-
>
|
|
75
|
-
Mouse over to focus
|
|
76
|
-
</button>
|
|
77
|
-
</div>
|
|
78
|
-
`;
|
|
79
|
-
|
|
80
|
-
exports[`Storybook Tests Button Link 1`] = `
|
|
81
|
-
<div
|
|
82
|
-
data-dark={false}
|
|
83
|
-
>
|
|
84
|
-
<button
|
|
85
|
-
className="charcoal-button"
|
|
86
|
-
to="#"
|
|
60
|
+
data-active={true}
|
|
87
61
|
>
|
|
88
|
-
|
|
62
|
+
Active
|
|
89
63
|
</button>
|
|
90
64
|
</div>
|
|
91
65
|
`;
|
|
@@ -98,19 +72,7 @@ exports[`Storybook Tests Button Navigation 1`] = `
|
|
|
98
72
|
className="charcoal-button"
|
|
99
73
|
data-variant="Navigation"
|
|
100
74
|
>
|
|
101
|
-
|
|
102
|
-
</button>
|
|
103
|
-
</div>
|
|
104
|
-
`;
|
|
105
|
-
|
|
106
|
-
exports[`Storybook Tests Button Nihongo 1`] = `
|
|
107
|
-
<div
|
|
108
|
-
data-dark={false}
|
|
109
|
-
>
|
|
110
|
-
<button
|
|
111
|
-
className="charcoal-button"
|
|
112
|
-
>
|
|
113
|
-
日本語だよ
|
|
75
|
+
Navigation
|
|
114
76
|
</button>
|
|
115
77
|
</div>
|
|
116
78
|
`;
|
|
@@ -123,7 +85,7 @@ exports[`Storybook Tests Button Overlay 1`] = `
|
|
|
123
85
|
className="charcoal-button"
|
|
124
86
|
data-variant="Overlay"
|
|
125
87
|
>
|
|
126
|
-
|
|
88
|
+
Overlay
|
|
127
89
|
</button>
|
|
128
90
|
</div>
|
|
129
91
|
`;
|
|
@@ -136,7 +98,7 @@ exports[`Storybook Tests Button Primary 1`] = `
|
|
|
136
98
|
className="charcoal-button"
|
|
137
99
|
data-variant="Primary"
|
|
138
100
|
>
|
|
139
|
-
|
|
101
|
+
Primary
|
|
140
102
|
</button>
|
|
141
103
|
</div>
|
|
142
104
|
`;
|
|
@@ -149,7 +111,7 @@ exports[`Storybook Tests Button Small 1`] = `
|
|
|
149
111
|
className="charcoal-button"
|
|
150
112
|
data-size="S"
|
|
151
113
|
>
|
|
152
|
-
|
|
114
|
+
Small
|
|
153
115
|
</button>
|
|
154
116
|
</div>
|
|
155
117
|
`;
|
|
@@ -1,96 +1,43 @@
|
|
|
1
|
-
import { useRef } from 'react'
|
|
2
|
-
import { ClickableElement } from '../Clickable'
|
|
3
1
|
import Button from '.'
|
|
4
2
|
import { Meta, StoryObj } from '@storybook/react'
|
|
5
3
|
|
|
6
4
|
export default {
|
|
7
5
|
title: 'Button',
|
|
8
6
|
component: Button,
|
|
9
|
-
argTypes: {
|
|
10
|
-
variant: {
|
|
11
|
-
control: {
|
|
12
|
-
type: 'inline-radio',
|
|
13
|
-
options: ['Primary', 'Default', 'Overlay', 'Danger', 'Navigation'],
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
size: {
|
|
17
|
-
control: {
|
|
18
|
-
type: 'inline-radio',
|
|
19
|
-
options: ['S', 'M'],
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
render: (args) => <Button {...args}>Button</Button>,
|
|
24
7
|
} as Meta<typeof Button>
|
|
25
8
|
|
|
26
|
-
export const Default: StoryObj<typeof Button> = {
|
|
9
|
+
export const Default: StoryObj<typeof Button> = {
|
|
10
|
+
render: (args) => <Button {...args}>Button</Button>,
|
|
11
|
+
}
|
|
27
12
|
|
|
28
13
|
export const Primary: StoryObj<typeof Button> = {
|
|
29
|
-
|
|
30
|
-
variant: 'Primary',
|
|
31
|
-
},
|
|
14
|
+
render: () => <Button variant="Primary">Primary</Button>,
|
|
32
15
|
}
|
|
33
16
|
|
|
34
17
|
export const Navigation: StoryObj<typeof Button> = {
|
|
35
|
-
|
|
36
|
-
variant: 'Navigation',
|
|
37
|
-
},
|
|
18
|
+
render: () => <Button variant="Navigation">Navigation</Button>,
|
|
38
19
|
}
|
|
39
20
|
|
|
40
21
|
export const Overlay: StoryObj<typeof Button> = {
|
|
41
|
-
|
|
42
|
-
variant: 'Overlay',
|
|
43
|
-
},
|
|
22
|
+
render: () => <Button variant="Overlay">Overlay</Button>,
|
|
44
23
|
}
|
|
45
24
|
|
|
46
25
|
export const Danger: StoryObj<typeof Button> = {
|
|
47
|
-
|
|
48
|
-
variant: 'Danger',
|
|
49
|
-
},
|
|
26
|
+
render: () => <Button variant="Danger">Danger</Button>,
|
|
50
27
|
}
|
|
51
28
|
|
|
52
29
|
export const Small: StoryObj<typeof Button> = {
|
|
53
|
-
|
|
54
|
-
size: 'S',
|
|
55
|
-
},
|
|
30
|
+
render: () => <Button size="S">Small</Button>,
|
|
56
31
|
}
|
|
57
32
|
|
|
58
|
-
export const
|
|
59
|
-
|
|
60
|
-
fullWidth: true,
|
|
61
|
-
},
|
|
33
|
+
export const FullWidth: StoryObj<typeof Button> = {
|
|
34
|
+
render: () => <Button fullWidth>Full width</Button>,
|
|
62
35
|
}
|
|
63
36
|
|
|
64
37
|
export const Disabled: StoryObj<typeof Button> = {
|
|
65
|
-
|
|
66
|
-
disabled: true,
|
|
67
|
-
},
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export const Active: StoryObj<typeof Button> = {
|
|
71
|
-
args: {
|
|
72
|
-
isActive: true,
|
|
73
|
-
},
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export const Link: StoryObj<typeof Button> = {
|
|
77
|
-
args: {
|
|
78
|
-
to: '#',
|
|
79
|
-
},
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export const Nihongo: StoryObj<typeof Button> = {
|
|
83
|
-
render: (args) => <Button {...args}>日本語だよ</Button>,
|
|
38
|
+
render: () => <Button disabled>Disabled</Button>,
|
|
84
39
|
}
|
|
85
40
|
|
|
86
|
-
export const
|
|
87
|
-
render:
|
|
88
|
-
const ref = useRef<ClickableElement>(null)
|
|
89
|
-
const focus = () => ref.current?.focus()
|
|
90
|
-
return (
|
|
91
|
-
<Button {...args} onMouseOver={focus} ref={ref}>
|
|
92
|
-
Mouse over to focus
|
|
93
|
-
</Button>
|
|
94
|
-
)
|
|
95
|
-
},
|
|
41
|
+
export const IsActive: StoryObj<typeof Button> = {
|
|
42
|
+
render: () => <Button isActive>Active</Button>,
|
|
96
43
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import 'jest-styled-components'
|
|
2
|
+
|
|
3
|
+
import renderer from 'react-test-renderer'
|
|
4
|
+
import Button from '.'
|
|
5
|
+
|
|
6
|
+
function Link({
|
|
7
|
+
as,
|
|
8
|
+
children,
|
|
9
|
+
...props
|
|
10
|
+
}: { as: string; children: React.ReactNode } & React.ComponentProps<'a'>) {
|
|
11
|
+
return (
|
|
12
|
+
<a {...props} data-as={as}>
|
|
13
|
+
{children}
|
|
14
|
+
</a>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('<Button />', () => {
|
|
19
|
+
test('componentAs props are passed to the data-as attribute', () => {
|
|
20
|
+
expect(
|
|
21
|
+
renderer.create(
|
|
22
|
+
<Button
|
|
23
|
+
href="/"
|
|
24
|
+
target="_blank"
|
|
25
|
+
fullWidth
|
|
26
|
+
as={Link}
|
|
27
|
+
componentAs="componentAs"
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
30
|
+
).toMatchSnapshot()
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -14,8 +14,16 @@ export type ButtonProps<T extends React.ElementType = 'button'> = {
|
|
|
14
14
|
size?: Size
|
|
15
15
|
fullWidth?: boolean
|
|
16
16
|
isActive?: boolean
|
|
17
|
+
/**
|
|
18
|
+
* The component used for root element.
|
|
19
|
+
* @type T extends React.ElementType = 'button'
|
|
20
|
+
*/
|
|
17
21
|
as?: T
|
|
18
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The as property of the component specified by the Button component's as attribute.
|
|
24
|
+
*/
|
|
25
|
+
componentAs?: React.ComponentPropsWithRef<T>['as']
|
|
26
|
+
} & Omit<React.ComponentPropsWithRef<T>, 'children' | 'as'>
|
|
19
27
|
|
|
20
28
|
const Button = forwardRef(function Button<T extends React.ElementType>(
|
|
21
29
|
{
|
|
@@ -25,6 +33,7 @@ const Button = forwardRef(function Button<T extends React.ElementType>(
|
|
|
25
33
|
className,
|
|
26
34
|
as,
|
|
27
35
|
isActive,
|
|
36
|
+
componentAs,
|
|
28
37
|
...props
|
|
29
38
|
}: ButtonProps<T>,
|
|
30
39
|
ref: ForwardedRef<HTMLButtonElement>
|
|
@@ -34,6 +43,7 @@ const Button = forwardRef(function Button<T extends React.ElementType>(
|
|
|
34
43
|
return (
|
|
35
44
|
<Component
|
|
36
45
|
{...props}
|
|
46
|
+
as={componentAs}
|
|
37
47
|
className={classNames}
|
|
38
48
|
data-variant={variant}
|
|
39
49
|
data-size={size}
|