@stackshift-ui/radio-group 6.0.11 → 7.0.0-beta.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/package.json +9 -7
- package/src/radio-group.test.tsx +5 -2
- package/src/radio-group.tsx +42 -49
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackshift-ui/radio-group",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.0.0-beta.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -29,20 +29,22 @@
|
|
|
29
29
|
"typescript": "^5.6.2",
|
|
30
30
|
"vite-tsconfig-paths": "^5.0.1",
|
|
31
31
|
"vitest": "^2.1.1",
|
|
32
|
-
"@stackshift-ui/
|
|
33
|
-
"@stackshift-ui/
|
|
32
|
+
"@stackshift-ui/eslint-config": "6.0.10",
|
|
33
|
+
"@stackshift-ui/typescript-config": "6.0.10"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@radix-ui/react-radio-group": "^1.3.7",
|
|
36
37
|
"classnames": "^2.5.1",
|
|
37
|
-
"
|
|
38
|
-
"@stackshift-ui/
|
|
38
|
+
"lucide-react": "^0.468.0",
|
|
39
|
+
"@stackshift-ui/scripts": "6.1.0-beta.0",
|
|
40
|
+
"@stackshift-ui/system": "6.1.0-beta.0"
|
|
39
41
|
},
|
|
40
42
|
"peerDependencies": {
|
|
43
|
+
"@stackshift-ui/system": ">=6.1.0-beta.0",
|
|
41
44
|
"@types/react": "16.8 - 19",
|
|
42
45
|
"next": "10 - 14",
|
|
43
46
|
"react": "16.8 - 19",
|
|
44
|
-
"react-dom": "16.8 - 19"
|
|
45
|
-
"@stackshift-ui/system": ">=6.0.11"
|
|
47
|
+
"react-dom": "16.8 - 19"
|
|
46
48
|
},
|
|
47
49
|
"peerDependenciesMeta": {
|
|
48
50
|
"next": {
|
package/src/radio-group.test.tsx
CHANGED
|
@@ -7,7 +7,10 @@ describe.concurrent("radio-group", () => {
|
|
|
7
7
|
|
|
8
8
|
test("Common: Radio Group - test if renders without errors", ({ expect }) => {
|
|
9
9
|
const clx = "radiogroup-class";
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const { unmount } = render(
|
|
11
|
+
<RadioGroup data-testid="radio-group" className={clx} name="stackshift-radiogroup" />,
|
|
12
|
+
);
|
|
13
|
+
expect(screen.getByTestId("radio-group").classList).toContain(clx);
|
|
14
|
+
unmount();
|
|
12
15
|
});
|
|
13
16
|
});
|
package/src/radio-group.tsx
CHANGED
|
@@ -1,59 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export interface RadioGroupProps extends Omit<HTMLProps<HTMLElement>, "as"> {
|
|
9
|
-
variant?: Variant;
|
|
10
|
-
label?: string;
|
|
11
|
-
name: string;
|
|
12
|
-
labelClass?: string;
|
|
13
|
-
noLabel?: boolean;
|
|
14
|
-
children?: ReactNode;
|
|
15
|
-
className?: string;
|
|
16
|
-
as?: ElementType;
|
|
17
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
4
|
+
import { Circle } from "lucide-react";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
|
|
7
|
+
import { cn, DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
|
|
18
8
|
|
|
19
9
|
const displayName = "RadioGroup";
|
|
10
|
+
const displayNameItem = "RadioGroupItem";
|
|
20
11
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
labelClass,
|
|
26
|
-
noLabel = false,
|
|
27
|
-
children,
|
|
28
|
-
className,
|
|
29
|
-
as,
|
|
30
|
-
...props
|
|
31
|
-
}) => {
|
|
12
|
+
const RadioGroup = React.forwardRef<
|
|
13
|
+
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
|
15
|
+
>(({ className, ...props }, ref) => {
|
|
32
16
|
const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
33
17
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
18
|
+
return (
|
|
19
|
+
<Component
|
|
20
|
+
as={RadioGroupPrimitive.Root}
|
|
21
|
+
className={cn("grid gap-2", className)}
|
|
22
|
+
{...props}
|
|
23
|
+
ref={ref}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
RadioGroup.displayName = displayName;
|
|
42
28
|
|
|
43
|
-
|
|
29
|
+
const RadioGroupItem = React.forwardRef<
|
|
30
|
+
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
|
31
|
+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
|
32
|
+
>(({ className, ...props }, ref) => {
|
|
33
|
+
const { [displayNameItem]: Component = DefaultComponent } = useStackShiftUIComponents();
|
|
44
34
|
|
|
45
35
|
return (
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
<Component
|
|
37
|
+
as={RadioGroupPrimitive.Item}
|
|
38
|
+
ref={ref}
|
|
39
|
+
className={cn(
|
|
40
|
+
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
41
|
+
className,
|
|
42
|
+
)}
|
|
43
|
+
{...props}>
|
|
44
|
+
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
|
|
45
|
+
<Circle className="h-2.5 w-2.5 fill-current text-current" />
|
|
46
|
+
</RadioGroupPrimitive.Indicator>
|
|
47
|
+
</Component>
|
|
56
48
|
);
|
|
57
|
-
};
|
|
49
|
+
});
|
|
50
|
+
RadioGroupItem.displayName = displayNameItem;
|
|
58
51
|
|
|
59
|
-
RadioGroup
|
|
52
|
+
export { RadioGroup, RadioGroupItem };
|