@hyphen/hyphen-components 4.1.0 → 4.1.2
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/Button.d.ts +5 -0
- package/dist/hyphen-components.cjs.development.js +7 -2
- package/dist/hyphen-components.cjs.development.js.map +1 -1
- package/dist/hyphen-components.cjs.production.min.js +1 -1
- package/dist/hyphen-components.cjs.production.min.js.map +1 -1
- package/dist/hyphen-components.esm.js +7 -2
- package/dist/hyphen-components.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/Button.mdx +3 -3
- package/src/components/Button/Button.test.tsx +9 -0
- package/src/components/Button/Button.tsx +9 -0
- package/src/components/Modal/components/ModalHeader/ModalHeader.tsx +1 -0
package/package.json
CHANGED
|
@@ -18,9 +18,6 @@ Actions almost always occur on the same page.
|
|
|
18
18
|
|
|
19
19
|
<ArgTypes of={Button} />
|
|
20
20
|
|
|
21
|
-
## As Child
|
|
22
|
-
|
|
23
|
-
Apply the `asChild` prop to apply the button styles to a child element.
|
|
24
21
|
|
|
25
22
|
<Canvas of={Stories.AsChild} />
|
|
26
23
|
|
|
@@ -76,3 +73,6 @@ The interface should make it clear why the button is disabled and what needs to
|
|
|
76
73
|
|
|
77
74
|
<Canvas of={Stories.Disabled} />
|
|
78
75
|
|
|
76
|
+
## As Child
|
|
77
|
+
|
|
78
|
+
Apply the `asChild` prop to apply the button styles to a child element.
|
|
@@ -392,6 +392,15 @@ describe('Button', () => {
|
|
|
392
392
|
expect(linkElement).toBeInTheDocument();
|
|
393
393
|
expect(linkElement).toHaveAttribute('href', 'https://ux.hyphen.ai');
|
|
394
394
|
});
|
|
395
|
+
|
|
396
|
+
test('does not render type prop when asChild is true', () => {
|
|
397
|
+
renderButton({
|
|
398
|
+
asChild: true,
|
|
399
|
+
children: <a href="https://ux.hyphen.ai">Link Button</a>,
|
|
400
|
+
});
|
|
401
|
+
const linkElement = screen.getByRole('link');
|
|
402
|
+
expect(linkElement).not.toHaveAttribute('type');
|
|
403
|
+
});
|
|
395
404
|
});
|
|
396
405
|
|
|
397
406
|
describe('Button Type', () => {
|
|
@@ -49,6 +49,11 @@ export interface BaseButtonProps {
|
|
|
49
49
|
* Size of the button.
|
|
50
50
|
*/
|
|
51
51
|
size?: ButtonSize | ResponsiveProp<ButtonSize>;
|
|
52
|
+
/**
|
|
53
|
+
* The type of button
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
type?: 'button' | 'submit' | 'reset';
|
|
52
57
|
/**
|
|
53
58
|
* Visual variant of the button
|
|
54
59
|
*/
|
|
@@ -74,6 +79,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
74
79
|
onFocus,
|
|
75
80
|
shadow,
|
|
76
81
|
size = 'md',
|
|
82
|
+
type = 'button',
|
|
77
83
|
variant = 'primary',
|
|
78
84
|
...restProps
|
|
79
85
|
},
|
|
@@ -113,6 +119,9 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
113
119
|
onBlur={handleBlur}
|
|
114
120
|
onFocus={handleFocus}
|
|
115
121
|
ref={ref}
|
|
122
|
+
{...(!asChild && {
|
|
123
|
+
type,
|
|
124
|
+
})}
|
|
116
125
|
{...restProps}
|
|
117
126
|
>
|
|
118
127
|
{isLoading && <Spinner className={styles['spinner-wrapper']} />}
|