@popsure/dirty-swan 0.57.8 → 0.57.9
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/cjs/index.js +38 -37
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/input/checkbox/index.d.ts +2 -1
- package/dist/cjs/lib/components/input/checkbox/index.stories.d.ts +11 -7
- package/dist/cjs/lib/components/input/radio/index.d.ts +3 -1
- package/dist/cjs/lib/components/input/radio/index.stories.d.ts +10 -2
- package/dist/esm/components/chip/index.js +2 -2
- package/dist/esm/components/chip/index.js.map +1 -1
- package/dist/esm/components/input/checkbox/index.js +16 -16
- package/dist/esm/components/input/checkbox/index.js.map +1 -1
- package/dist/esm/components/input/checkbox/index.stories.js +24 -20
- package/dist/esm/components/input/checkbox/index.stories.js.map +1 -1
- package/dist/esm/components/input/radio/index.js +23 -21
- package/dist/esm/components/input/radio/index.js.map +1 -1
- package/dist/esm/components/input/radio/index.stories.js +12 -3
- package/dist/esm/components/input/radio/index.stories.js.map +1 -1
- package/dist/esm/components/input/radio/index.test.js +1 -0
- package/dist/esm/components/input/radio/index.test.js.map +1 -1
- package/dist/esm/lib/components/input/checkbox/index.d.ts +2 -1
- package/dist/esm/lib/components/input/checkbox/index.stories.d.ts +11 -7
- package/dist/esm/lib/components/input/radio/index.d.ts +3 -1
- package/dist/esm/lib/components/input/radio/index.stories.d.ts +10 -2
- package/package.json +1 -1
- package/src/lib/components/chip/index.tsx +1 -0
- package/src/lib/components/chip/style.module.scss +5 -0
- package/src/lib/components/input/checkbox/index.stories.tsx +81 -58
- package/src/lib/components/input/checkbox/index.tsx +5 -2
- package/src/lib/components/input/checkbox/styles.module.scss +4 -0
- package/src/lib/components/input/radio/index.stories.tsx +17 -2
- package/src/lib/components/input/radio/index.tsx +11 -2
- package/src/lib/components/input/radio/styles.module.scss +5 -1
|
@@ -2,6 +2,7 @@ import classNames from 'classnames';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
import styles from './styles.module.scss';
|
|
5
|
+
import generateId from '../../../util/generateId';
|
|
5
6
|
export interface RadioWithDescription {
|
|
6
7
|
title: ReactNode;
|
|
7
8
|
description?: string;
|
|
@@ -23,6 +24,8 @@ export interface RadioProps<ValueType extends string> {
|
|
|
23
24
|
};
|
|
24
25
|
bordered?: boolean;
|
|
25
26
|
disabled?: boolean;
|
|
27
|
+
fieldLegend?: string;
|
|
28
|
+
groupName?: string;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
export const Radio = <ValueType extends string>({
|
|
@@ -35,14 +38,18 @@ export const Radio = <ValueType extends string>({
|
|
|
35
38
|
classNames: classNamesObj,
|
|
36
39
|
bordered = true,
|
|
37
40
|
disabled = false,
|
|
41
|
+
fieldLegend = 'Select an option',
|
|
42
|
+
groupName,
|
|
38
43
|
}: RadioProps<ValueType>) => {
|
|
39
44
|
const entries = Object.entries(options) as [
|
|
40
45
|
ValueType,
|
|
41
46
|
ReactNode | RadioWithDescription
|
|
42
47
|
][];
|
|
43
48
|
|
|
49
|
+
const name = groupName ?? generateId();
|
|
50
|
+
|
|
44
51
|
return (
|
|
45
|
-
<
|
|
52
|
+
<fieldset
|
|
46
53
|
className={classNames(
|
|
47
54
|
classNamesObj?.container,
|
|
48
55
|
styles.container,
|
|
@@ -56,6 +63,7 @@ export const Radio = <ValueType extends string>({
|
|
|
56
63
|
}
|
|
57
64
|
)}
|
|
58
65
|
>
|
|
66
|
+
<legend className="sr-only">{fieldLegend}</legend>
|
|
59
67
|
{entries.map(([currentValue, label]) => {
|
|
60
68
|
const checked = value === currentValue;
|
|
61
69
|
const customIcon = (label as RadioWithDescription)?.icon;
|
|
@@ -81,6 +89,7 @@ export const Radio = <ValueType extends string>({
|
|
|
81
89
|
checked={checked}
|
|
82
90
|
data-testid={`radio-input-${currentValue}`}
|
|
83
91
|
disabled={disabled}
|
|
92
|
+
name={name}
|
|
84
93
|
/>
|
|
85
94
|
|
|
86
95
|
<label
|
|
@@ -118,6 +127,6 @@ export const Radio = <ValueType extends string>({
|
|
|
118
127
|
</div>
|
|
119
128
|
);
|
|
120
129
|
})}
|
|
121
|
-
</
|
|
130
|
+
</fieldset>
|
|
122
131
|
);
|
|
123
132
|
};
|