@stackshift-ui/checkbox-group 1.0.0 → 6.0.3

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,14 +1,15 @@
1
1
  {
2
2
  "name": "@stackshift-ui/checkbox-group",
3
3
  "description": "",
4
- "version": "1.0.0",
4
+ "version": "6.0.3",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.mjs",
9
9
  "types": "./dist/index.d.ts",
10
10
  "files": [
11
- "dist/**"
11
+ "dist/**",
12
+ "src"
12
13
  ],
13
14
  "author": "WebriQ <info@webriq.com>",
14
15
  "devDependencies": {
@@ -28,13 +29,13 @@
28
29
  "typescript": "^5.6.2",
29
30
  "vite-tsconfig-paths": "^5.0.1",
30
31
  "vitest": "^2.1.1",
31
- "@stackshift-ui/eslint-config": "1.0.0",
32
- "@stackshift-ui/typescript-config": "2.0.0"
32
+ "@stackshift-ui/eslint-config": "6.0.2",
33
+ "@stackshift-ui/typescript-config": "6.0.2"
33
34
  },
34
35
  "dependencies": {
35
36
  "classnames": "^2.5.1",
36
- "@stackshift-ui/scripts": "1.0.0",
37
- "@stackshift-ui/system": "2.0.0"
37
+ "@stackshift-ui/scripts": "6.0.2",
38
+ "@stackshift-ui/system": "6.0.3"
38
39
  },
39
40
  "peerDependencies": {
40
41
  "@types/react": "16.8 - 19",
@@ -0,0 +1,13 @@
1
+ import { cleanup, render, screen } from "@testing-library/react";
2
+ import { afterEach, describe, test } from "vitest";
3
+ import { CheckboxGroup } from "./checkbox-group";
4
+
5
+ describe.concurrent("checkbox-group", () => {
6
+ afterEach(cleanup);
7
+
8
+ test("Common: Checkbox Group - test if renders without errors", ({ expect }) => {
9
+ const clx = "my-class";
10
+ render(<CheckboxGroup className={clx} />);
11
+ expect(screen.getByTestId("div").classList).toContain(clx);
12
+ });
13
+ });
@@ -0,0 +1,60 @@
1
+ import { DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
2
+ import { Fragment, type ElementType, type HTMLProps, type ReactNode } from "react";
3
+ import cn from "classnames";
4
+
5
+ type StyleVariants<T extends string> = Record<T, string>;
6
+ type Variant = "primary" | "inline";
7
+
8
+ export interface CheckboxGroupProps extends Omit<HTMLProps<HTMLElement>, "as"> {
9
+ variant?: Variant;
10
+ name?: string;
11
+ label?: string;
12
+ noLabel?: boolean;
13
+ labelClass?: string;
14
+ [key: string]: any;
15
+ children?: ReactNode;
16
+ className?: string;
17
+ as?: ElementType;
18
+ }
19
+
20
+ const displayName = "CheckboxGroup";
21
+
22
+ export const CheckboxGroup: React.FC<CheckboxGroupProps> = ({
23
+ variant = "primary",
24
+ name,
25
+ label,
26
+ noLabel = false,
27
+ labelClass,
28
+ children,
29
+ className,
30
+ as,
31
+ ...props
32
+ }) => {
33
+ const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
34
+
35
+ const commonClass = "ml-2";
36
+ const primary = `${commonClass} block`;
37
+ const inline = `${commonClass} flex gap-4`;
38
+
39
+ const variants: StyleVariants<Variant> = {
40
+ primary,
41
+ inline,
42
+ };
43
+
44
+ const variantClass = variants[variant] ?? primary;
45
+
46
+ return (
47
+ <Fragment>
48
+ {!noLabel && <p className={labelClass}>{label || name}</p>}
49
+ <Component
50
+ as={as}
51
+ className={cn(variantClass, className)}
52
+ {...props}
53
+ data-testid={displayName}>
54
+ {children}
55
+ </Component>
56
+ </Fragment>
57
+ );
58
+ };
59
+
60
+ CheckboxGroup.displayName = displayName;
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ "use client";
2
+
3
+ // component exports
4
+ export * from "./checkbox-group";