@boostdev/design-system-components 0.1.15 → 0.1.17
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/AGENTS.md +4 -4
- package/README.md +50 -1
- package/dist/client.cjs +203 -114
- package/dist/client.css +520 -435
- package/dist/client.d.cts +23 -3
- package/dist/client.d.ts +23 -3
- package/dist/client.js +202 -114
- package/dist/index.cjs +203 -114
- package/dist/index.css +520 -435
- package/dist/index.d.cts +23 -3
- package/dist/index.d.ts +23 -3
- package/dist/index.js +202 -114
- package/package.json +1 -1
- package/src/components/interaction/Command/Command.mdx +1 -0
- package/src/components/interaction/Command/Command.spec.tsx +18 -0
- package/src/components/interaction/Command/Command.tsx +5 -0
- package/src/components/interaction/Dialog/Dialog.spec.tsx +18 -0
- package/src/components/interaction/Drawer/Drawer.spec.tsx +18 -0
- package/src/components/interaction/Drawer/Drawer.tsx +5 -0
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.mdx +64 -0
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.module.css +99 -0
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.spec.tsx +87 -0
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.stories.tsx +110 -0
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.tsx +89 -0
- package/src/components/interaction/form/SegmentedControl/index.ts +2 -0
- package/src/components/interaction/form/Switch/Switch.mdx +7 -2
- package/src/components/interaction/form/Switch/Switch.module.css +6 -6
- package/src/components/interaction/form/Switch/Switch.spec.tsx +23 -0
- package/src/components/interaction/form/Switch/Switch.stories.tsx +8 -0
- package/src/components/interaction/form/Switch/Switch.tsx +5 -2
- package/src/components/interaction/form/atoms/Label.module.css +0 -1
- package/src/components/ui/Progress/Progress.module.css +0 -4
- package/src/index.ts +2 -0
- package/src/stories/Introduction.mdx +4 -3
|
@@ -45,4 +45,27 @@ describe('Switch', () => {
|
|
|
45
45
|
render(<Switch label="Disabled" name="disabled" disabled />);
|
|
46
46
|
expect(screen.getByRole('switch')).toBeDisabled();
|
|
47
47
|
});
|
|
48
|
+
|
|
49
|
+
it('renders a prefix label when provided', () => {
|
|
50
|
+
render(<Switch label="On" name="theme" prefix="Off" />);
|
|
51
|
+
expect(screen.getByText('Off')).toBeInTheDocument();
|
|
52
|
+
expect(screen.getByText('On')).toBeInTheDocument();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('associates error message via aria-describedby', () => {
|
|
56
|
+
render(<Switch label="Accept" name="accept" error="Required" />);
|
|
57
|
+
const input = screen.getByRole('switch');
|
|
58
|
+
const error = screen.getByText('Required');
|
|
59
|
+
expect(input).toHaveAttribute('aria-describedby', expect.stringContaining(error.id));
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('renders small size', () => {
|
|
63
|
+
render(<Switch label="Toggle" name="size-s" size="small" />);
|
|
64
|
+
expect(screen.getByRole('switch').closest('.switchGroup')).toHaveClass('--size_small');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('renders large size', () => {
|
|
68
|
+
render(<Switch label="Toggle" name="size-l" size="large" />);
|
|
69
|
+
expect(screen.getByRole('switch').closest('.switchGroup')).toHaveClass('--size_large');
|
|
70
|
+
});
|
|
48
71
|
});
|
|
@@ -19,6 +19,14 @@ export const WithError: Story = { args: { label: 'Required toggle', name: 'requi
|
|
|
19
19
|
export const Disabled: Story = { args: { label: 'Unavailable', name: 'unavailable', disabled: true } };
|
|
20
20
|
export const DisabledChecked: Story = { args: { label: 'Always on', name: 'always-on', defaultChecked: true, disabled: true } };
|
|
21
21
|
|
|
22
|
+
export const WithPrefix: Story = {
|
|
23
|
+
args: {
|
|
24
|
+
label: 'On',
|
|
25
|
+
name: 'theme',
|
|
26
|
+
prefix: 'Off',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
22
30
|
export const AllSizes: Story = {
|
|
23
31
|
render: () => (
|
|
24
32
|
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {InputHTMLAttributes, ReactNode, useId} from 'react';
|
|
2
2
|
import css from './Switch.module.css';
|
|
3
3
|
import { cn } from '@boostdev/design-system-foundation';
|
|
4
4
|
import { InputContainer } from '../atoms/InputContainer';
|
|
5
5
|
import { Label } from '../atoms/Label';
|
|
6
6
|
import { Message } from '../atoms/Message';
|
|
7
7
|
|
|
8
|
-
interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {
|
|
8
|
+
interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'size' | 'prefix'> {
|
|
9
9
|
label: string;
|
|
10
10
|
name: string;
|
|
11
11
|
size?: 'small' | 'medium' | 'large';
|
|
12
12
|
error?: string;
|
|
13
13
|
hint?: string;
|
|
14
14
|
className?: string;
|
|
15
|
+
prefix?: ReactNode;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export function Switch({
|
|
@@ -21,6 +22,7 @@ export function Switch({
|
|
|
21
22
|
error,
|
|
22
23
|
hint,
|
|
23
24
|
className,
|
|
25
|
+
prefix,
|
|
24
26
|
...props
|
|
25
27
|
}: Readonly<SwitchProps>) {
|
|
26
28
|
const id = name + useId();
|
|
@@ -31,6 +33,7 @@ export function Switch({
|
|
|
31
33
|
return (
|
|
32
34
|
<InputContainer className={cn(css.switchGroup, css[`--size_${size}`], className)}>
|
|
33
35
|
<div className={css.inputWrapper}>
|
|
36
|
+
{prefix && <Label id={id} label={prefix}/>}
|
|
34
37
|
<div className={css.trackWrapper}>
|
|
35
38
|
<input
|
|
36
39
|
type="checkbox"
|
package/src/index.ts
CHANGED
|
@@ -48,6 +48,8 @@ export { FileInput } from './components/interaction/form/FileInput';
|
|
|
48
48
|
export { FormInput } from './components/interaction/form/FormInput';
|
|
49
49
|
export { NumberInput } from './components/interaction/form/NumberInput';
|
|
50
50
|
export { Radio } from './components/interaction/form/Radio';
|
|
51
|
+
export { SegmentedControl } from './components/interaction/form/SegmentedControl';
|
|
52
|
+
export type { SegmentedControlProps, SegmentedControlOption } from './components/interaction/form/SegmentedControl';
|
|
51
53
|
export { Select } from './components/interaction/form/Select';
|
|
52
54
|
export type { SelectOption } from './components/interaction/form/Select';
|
|
53
55
|
export { Slider } from './components/interaction/form/Slider';
|
|
@@ -55,8 +55,8 @@ import {Card} from "../components/layout/Card/index.ts";
|
|
|
55
55
|
<strong>UI</strong>
|
|
56
56
|
<div className="cardContent">
|
|
57
57
|
Badge · Typography · Alert · Avatar · Loading · Skeleton · Separator · Tooltip · Progress ·
|
|
58
|
-
ProgressCircle · Tabs · Breadcrumb · Accordion · Pagination · Link · Table ·
|
|
59
|
-
NotificationBanner · SkipLink · Carousel · Calendar
|
|
58
|
+
ProgressCircle · Tabs · Breadcrumb · Accordion · Collapsible · Pagination · Link · Table ·
|
|
59
|
+
DescriptionList · NotificationBanner · SkipLink · Carousel · Calendar
|
|
60
60
|
</div>
|
|
61
61
|
</Card>
|
|
62
62
|
|
|
@@ -70,7 +70,8 @@ import {Card} from "../components/layout/Card/index.ts";
|
|
|
70
70
|
<Card className="card">
|
|
71
71
|
<strong>Form</strong>
|
|
72
72
|
<div className="cardContent">
|
|
73
|
-
FormInput · Checkbox · Radio · Switch · Select · Textarea · Slider ·
|
|
73
|
+
FormInput · Checkbox · Radio · Switch · SegmentedControl · Select · Textarea · Slider ·
|
|
74
|
+
NumberInput · FileInput · Combobox
|
|
74
75
|
</div>
|
|
75
76
|
</Card>
|
|
76
77
|
|