@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyphen/hyphen-components",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "@hyphen"
@@ -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']} />}
@@ -47,6 +47,7 @@ export const ModalHeader: FC<ModalHeaderProps> = ({
47
47
  onClick={onDismiss}
48
48
  iconPrefix="remove"
49
49
  size="sm"
50
+ type="button"
50
51
  />
51
52
  )}
52
53
  </Box>