@hyphen/hyphen-components 6.9.0 → 6.12.0
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/Badge/Badge.d.ts +3 -10
- package/dist/components/Formik/FormikToggleGroupMulti/FormikToggleGroupMulti.d.ts +3 -1
- package/dist/components/Modal/Modal.d.ts +9 -1
- package/dist/components/SelectInputNative/SelectInputNative.stories.d.ts +4 -1
- package/dist/css/index.css +1 -1
- package/dist/hyphen-components.cjs.development.js +15 -6
- 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 +15 -6
- package/dist/hyphen-components.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Badge/Badge.stories.tsx +6 -3
- package/src/components/Badge/Badge.test.tsx +1 -2
- package/src/components/Badge/Badge.tsx +8 -13
- package/src/components/Formik/FormikToggleGroupMulti/FormikToggleGroupMulti.tsx +4 -0
- package/src/components/Modal/Modal.tsx +13 -2
- package/src/components/SelectInputNative/SelectInputNative.module.scss +11 -0
- package/src/components/SelectInputNative/SelectInputNative.stories.tsx +49 -2
- package/src/components/Table/Table.stories.tsx +3 -3
- package/src/components/Tooltip/Tooltip.stories.tsx +3 -1
package/package.json
CHANGED
|
@@ -27,7 +27,9 @@ export const Variants = () => {
|
|
|
27
27
|
return (
|
|
28
28
|
<Box direction="row" gap="sm">
|
|
29
29
|
{variants.map((variant) => (
|
|
30
|
-
<Badge
|
|
30
|
+
<Badge variant={variant} key={variant}>
|
|
31
|
+
{variant}
|
|
32
|
+
</Badge>
|
|
31
33
|
))}
|
|
32
34
|
</Box>
|
|
33
35
|
);
|
|
@@ -45,8 +47,9 @@ export const Sizes = () => (
|
|
|
45
47
|
tablet: 'md',
|
|
46
48
|
desktop: 'lg',
|
|
47
49
|
}}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
>
|
|
51
|
+
Responsive
|
|
52
|
+
</Badge>
|
|
50
53
|
</Box>
|
|
51
54
|
</>
|
|
52
55
|
);
|
|
@@ -3,7 +3,7 @@ import classNames from 'classnames';
|
|
|
3
3
|
import { FontSize, BaseSpacing, ResponsiveProp } from '../../types';
|
|
4
4
|
import { generateResponsiveClasses } from '../../lib/generateResponsiveClasses';
|
|
5
5
|
import styles from './Badge.module.scss';
|
|
6
|
-
import { Box } from '../Box/Box';
|
|
6
|
+
import { Box, BoxProps } from '../Box/Box';
|
|
7
7
|
|
|
8
8
|
export type BadgeSize = 'sm' | 'md' | 'lg';
|
|
9
9
|
|
|
@@ -19,13 +19,9 @@ export type BadgeVariant =
|
|
|
19
19
|
| 'hyphen';
|
|
20
20
|
|
|
21
21
|
export type BadgeSizeAttributes = { fontSize: FontSize; padding: BaseSpacing };
|
|
22
|
-
export interface BadgeProps {
|
|
22
|
+
export interface BadgeProps extends BoxProps {
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
className?: string;
|
|
27
|
-
/**
|
|
28
|
-
* The text message or ReactNode to be rendered in the badge.
|
|
24
|
+
* @deprecated Use children instead. The text message or ReactNode to be rendered in the badge.
|
|
29
25
|
*/
|
|
30
26
|
message?: string | ReactNode;
|
|
31
27
|
/**
|
|
@@ -36,10 +32,6 @@ export interface BadgeProps {
|
|
|
36
32
|
* The type/color of the badge to show.
|
|
37
33
|
*/
|
|
38
34
|
variant?: BadgeVariant;
|
|
39
|
-
/**
|
|
40
|
-
* Additional props to be spread to rendered element
|
|
41
|
-
*/
|
|
42
|
-
[x: string]: any; // eslint-disable-line
|
|
43
35
|
}
|
|
44
36
|
|
|
45
37
|
export const Badge = forwardRef<HTMLDivElement, BadgeProps>(
|
|
@@ -49,6 +41,7 @@ export const Badge = forwardRef<HTMLDivElement, BadgeProps>(
|
|
|
49
41
|
message = '',
|
|
50
42
|
variant = 'light-grey',
|
|
51
43
|
size = 'md',
|
|
44
|
+
children,
|
|
52
45
|
...restProps
|
|
53
46
|
},
|
|
54
47
|
ref
|
|
@@ -70,10 +63,12 @@ export const Badge = forwardRef<HTMLDivElement, BadgeProps>(
|
|
|
70
63
|
<Box
|
|
71
64
|
ref={ref}
|
|
72
65
|
className={badgeClasses}
|
|
73
|
-
display="inline-
|
|
66
|
+
display="inline-flex"
|
|
67
|
+
alignItems="center"
|
|
68
|
+
direction="row"
|
|
74
69
|
{...restProps}
|
|
75
70
|
>
|
|
76
|
-
{message}
|
|
71
|
+
{children || message}
|
|
77
72
|
</Box>
|
|
78
73
|
);
|
|
79
74
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from '../../ToggleGroup/ToggleGroup';
|
|
8
8
|
import { Box } from '../../Box/Box';
|
|
9
9
|
import { HelpText } from '../../HelpText/HelpText';
|
|
10
|
+
import { BaseSpacing, ResponsiveProp } from 'src/types';
|
|
10
11
|
|
|
11
12
|
export interface FormikToggleGroupMultiProps {
|
|
12
13
|
name: string;
|
|
@@ -20,6 +21,7 @@ export interface FormikToggleGroupMultiProps {
|
|
|
20
21
|
label?: string;
|
|
21
22
|
children?: React.ReactNode;
|
|
22
23
|
variant: ToggleVariant;
|
|
24
|
+
gap?: BaseSpacing | ResponsiveProp<BaseSpacing>;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export const FormikToggleGroupMulti = ({
|
|
@@ -29,6 +31,7 @@ export const FormikToggleGroupMulti = ({
|
|
|
29
31
|
label,
|
|
30
32
|
children,
|
|
31
33
|
variant,
|
|
34
|
+
gap,
|
|
32
35
|
...props
|
|
33
36
|
}: FormikToggleGroupMultiProps) => {
|
|
34
37
|
const [field, meta, helpers] = useField(name);
|
|
@@ -44,6 +47,7 @@ export const FormikToggleGroupMulti = ({
|
|
|
44
47
|
{() => (
|
|
45
48
|
<ToggleGroup
|
|
46
49
|
{...props}
|
|
50
|
+
gap={gap}
|
|
47
51
|
name={name}
|
|
48
52
|
onValueChange={(selectedValues: string[]) => {
|
|
49
53
|
helpers.setValue(selectedValues);
|
|
@@ -3,7 +3,7 @@ import ReactModal from 'react-modal';
|
|
|
3
3
|
import FocusLock from 'react-focus-lock';
|
|
4
4
|
import { RemoveScroll } from 'react-remove-scroll';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import { CssOverflowValue } from '../../types';
|
|
6
|
+
import { BackgroundColor, CssOverflowValue } from '../../types';
|
|
7
7
|
import { getDimensionCss } from '../../lib/getDimensionCss';
|
|
8
8
|
import { Box, BoxProps } from '../Box/Box';
|
|
9
9
|
import { ModalFooter, ModalHeader, ModalBody } from './components';
|
|
@@ -43,6 +43,10 @@ export interface ModalProps {
|
|
|
43
43
|
* At mobile viewport widths, the modal will take up the fullscreen
|
|
44
44
|
*/
|
|
45
45
|
fullScreenMobile?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Background color for the modal content using design tokens
|
|
48
|
+
*/
|
|
49
|
+
background?: BackgroundColor;
|
|
46
50
|
/**
|
|
47
51
|
* By default the first focusable element will receive focus when the dialog
|
|
48
52
|
* opens but you can provide a ref to focus instead.
|
|
@@ -67,6 +71,10 @@ export interface ModalProps {
|
|
|
67
71
|
* The css overflow behavior of the Modal
|
|
68
72
|
*/
|
|
69
73
|
overflow?: CssOverflowValue;
|
|
74
|
+
/**
|
|
75
|
+
* Inline styles for the modal container
|
|
76
|
+
*/
|
|
77
|
+
style?: React.CSSProperties;
|
|
70
78
|
/**
|
|
71
79
|
* Allows spread props
|
|
72
80
|
*/
|
|
@@ -82,6 +90,7 @@ export const ModalBaseComponent: React.FC<ModalProps> = forwardRef<
|
|
|
82
90
|
ariaLabel,
|
|
83
91
|
ariaLabelledBy,
|
|
84
92
|
allowPinchZoom = false,
|
|
93
|
+
background = undefined,
|
|
85
94
|
children,
|
|
86
95
|
className,
|
|
87
96
|
containerRef = undefined,
|
|
@@ -91,6 +100,7 @@ export const ModalBaseComponent: React.FC<ModalProps> = forwardRef<
|
|
|
91
100
|
maxWidth = undefined,
|
|
92
101
|
onDismiss,
|
|
93
102
|
overflow = 'hidden',
|
|
103
|
+
style,
|
|
94
104
|
...restProps
|
|
95
105
|
},
|
|
96
106
|
ref
|
|
@@ -139,12 +149,13 @@ export const ModalBaseComponent: React.FC<ModalProps> = forwardRef<
|
|
|
139
149
|
onRequestClose={onDismiss}
|
|
140
150
|
ariaHideApp={false}
|
|
141
151
|
parentSelector={parentElement ? () => parentElement : undefined}
|
|
142
|
-
style={{ content: { ...maxWidthCss.styles } }}
|
|
152
|
+
style={{ content: { ...maxWidthCss.styles, ...style } }}
|
|
143
153
|
{...restProps}
|
|
144
154
|
>
|
|
145
155
|
<Box
|
|
146
156
|
aria-label={ariaLabel}
|
|
147
157
|
aria-labelledby={ariaLabelledBy}
|
|
158
|
+
background={background}
|
|
148
159
|
height="100"
|
|
149
160
|
padding={{ base: '2xl', tablet: '4xl' }}
|
|
150
161
|
gap="3xl"
|
|
@@ -253,6 +253,17 @@
|
|
|
253
253
|
var(--INTERNAL_form-control-line-height)
|
|
254
254
|
);
|
|
255
255
|
|
|
256
|
+
option {
|
|
257
|
+
background-color: var(
|
|
258
|
+
--form-control-background-color,
|
|
259
|
+
var(--INTERNAL_form-control-background-color)
|
|
260
|
+
);
|
|
261
|
+
color: var(
|
|
262
|
+
--form-control-font-color,
|
|
263
|
+
var(--INTERNAL_form-control-font-color)
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
256
267
|
&:focus {
|
|
257
268
|
outline: none;
|
|
258
269
|
border-color: var(
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { SelectInputNative } from './SelectInputNative';
|
|
3
|
-
import type { Meta } from '@storybook/react-vite';
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
4
4
|
import { Box } from '../Box/Box';
|
|
5
|
+
import { within, userEvent, expect } from 'storybook/test';
|
|
5
6
|
|
|
6
7
|
const meta: Meta<typeof SelectInputNative> = {
|
|
7
8
|
title: 'Components/SelectInputNative',
|
|
@@ -24,7 +25,7 @@ export const Default = () => {
|
|
|
24
25
|
return (
|
|
25
26
|
<div>
|
|
26
27
|
<SelectInputNative
|
|
27
|
-
id="
|
|
28
|
+
id="defaultSelect"
|
|
28
29
|
label="Label"
|
|
29
30
|
onChange={(event) => {
|
|
30
31
|
setValue(event.target.value);
|
|
@@ -231,3 +232,49 @@ export const Sizes = () => {
|
|
|
231
232
|
</Box>
|
|
232
233
|
);
|
|
233
234
|
};
|
|
235
|
+
|
|
236
|
+
export const InteractionTest: StoryObj<typeof SelectInputNative> = {
|
|
237
|
+
render: Default,
|
|
238
|
+
play: async ({ canvasElement }) => {
|
|
239
|
+
const canvas = within(canvasElement);
|
|
240
|
+
const select = canvas.getByLabelText('Label');
|
|
241
|
+
|
|
242
|
+
// Select 'chocolate'
|
|
243
|
+
await userEvent.selectOptions(select, 'chocolate');
|
|
244
|
+
|
|
245
|
+
// Assert value
|
|
246
|
+
await expect(select).toHaveValue('chocolate');
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export const InteractionDisabled: StoryObj<typeof SelectInputNative> = {
|
|
251
|
+
render: Disabled,
|
|
252
|
+
play: async ({ canvasElement }) => {
|
|
253
|
+
const canvas = within(canvasElement);
|
|
254
|
+
const select = canvas.getByLabelText('Label');
|
|
255
|
+
|
|
256
|
+
// Assert disabled
|
|
257
|
+
await expect(select).toBeDisabled();
|
|
258
|
+
|
|
259
|
+
// Attempt to select should fail (or we just verify it's disabled)
|
|
260
|
+
// userEvent.selectOptions throws on disabled elements, so we primarily verify state
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
export const InteractionChangePreSelected: StoryObj<typeof SelectInputNative> =
|
|
265
|
+
{
|
|
266
|
+
render: PreSelected,
|
|
267
|
+
play: async ({ canvasElement }) => {
|
|
268
|
+
const canvas = within(canvasElement);
|
|
269
|
+
const select = canvas.getByLabelText('Label');
|
|
270
|
+
|
|
271
|
+
// Assert initial value
|
|
272
|
+
await expect(select).toHaveValue('strawberry');
|
|
273
|
+
|
|
274
|
+
// Select 'vanilla'
|
|
275
|
+
await userEvent.selectOptions(select, 'vanilla');
|
|
276
|
+
|
|
277
|
+
// Assert new value
|
|
278
|
+
await expect(select).toHaveValue('vanilla');
|
|
279
|
+
},
|
|
280
|
+
};
|
|
@@ -871,13 +871,13 @@ export const ComponentAsColumnHeader = () =>
|
|
|
871
871
|
{
|
|
872
872
|
id: 1,
|
|
873
873
|
color: 'red',
|
|
874
|
-
status: <Badge
|
|
874
|
+
status: <Badge variant="red">danger</Badge>,
|
|
875
875
|
},
|
|
876
|
-
{ id: 2, color: 'blue', status: <Badge
|
|
876
|
+
{ id: 2, color: 'blue', status: <Badge variant="blue">info</Badge> },
|
|
877
877
|
{
|
|
878
878
|
id: 3,
|
|
879
879
|
color: 'green',
|
|
880
|
-
status: <Badge
|
|
880
|
+
status: <Badge variant="green">success</Badge>,
|
|
881
881
|
},
|
|
882
882
|
];
|
|
883
883
|
return <Table rowKey="id" columns={columnConfig} rows={tableData} />;
|
|
@@ -45,7 +45,9 @@ export const BadgeTooltip = () => (
|
|
|
45
45
|
<TooltipProvider delayDuration={100}>
|
|
46
46
|
<Tooltip>
|
|
47
47
|
<TooltipTrigger asChild>
|
|
48
|
-
<Badge as="button"
|
|
48
|
+
<Badge as="button" variant="blue">
|
|
49
|
+
hover
|
|
50
|
+
</Badge>
|
|
49
51
|
</TooltipTrigger>
|
|
50
52
|
<TooltipPortal>
|
|
51
53
|
<TooltipContent>This is the tooltip content</TooltipContent>
|