@stackshift-ui/grid-item 6.0.2 → 6.0.4-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 CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@stackshift-ui/grid-item",
3
3
  "description": "",
4
- "version": "6.0.2",
4
+ "version": "6.0.4-beta.0",
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,16 +29,16 @@
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": "6.0.2",
32
- "@stackshift-ui/typescript-config": "6.0.2"
32
+ "@stackshift-ui/typescript-config": "6.0.3-beta.0",
33
+ "@stackshift-ui/eslint-config": "6.0.3-beta.0"
33
34
  },
34
35
  "dependencies": {
35
36
  "classnames": "^2.5.1",
36
- "@stackshift-ui/system": "6.0.2",
37
- "@stackshift-ui/scripts": "6.0.2"
37
+ "@stackshift-ui/scripts": "6.0.3-beta.0",
38
+ "@stackshift-ui/system": "6.0.4-beta.0"
38
39
  },
39
40
  "peerDependencies": {
40
- "@stackshift-ui/system": ">=0.0.0",
41
+ "@stackshift-ui/system": ">=6.0.4-beta.0",
41
42
  "@types/react": "16.8 - 19",
42
43
  "next": "10 - 14",
43
44
  "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 { GridItem } from "./grid-item";
4
+
5
+ describe.concurrent("grid-item", () => {
6
+ afterEach(cleanup);
7
+
8
+ test("Layout: Grid Item - test if renders without errors", ({ expect }) => {
9
+ const clx = "griditem-class";
10
+ render(<GridItem className={clx} />);
11
+ expect(screen.getByTestId("div").classList).toContain(clx);
12
+ });
13
+ });
@@ -0,0 +1,50 @@
1
+ import { DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
2
+ import type { ElementType, HTMLProps, ReactNode } from "react";
3
+ import cn from "classnames";
4
+
5
+ export interface GridItemProps extends Omit<HTMLProps<HTMLElement>, "as" | "span"> {
6
+ span?: Span;
7
+ children?: ReactNode;
8
+ className?: string;
9
+ as?: ElementType;
10
+ }
11
+
12
+ type Span = "auto" | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
13
+
14
+ const displayName = "GridItem";
15
+
16
+ export const GridItem: React.FC<GridItemProps> = ({
17
+ span = "auto",
18
+ children,
19
+ className,
20
+ as,
21
+ ...props
22
+ }) => {
23
+ const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
24
+
25
+ const spanVariants = {
26
+ auto: "col-span-auto",
27
+ 1: "col-span-1",
28
+ 2: "col-span-2",
29
+ 3: "col-span-3",
30
+ 4: "col-span-4",
31
+ 5: "col-span-5",
32
+ 6: "col-span-6",
33
+ 7: "col-span-7",
34
+ 8: "col-span-8",
35
+ 9: "col-span-9",
36
+ 10: "col-span-10",
37
+ 11: "col-span-11",
38
+ 12: "col-span-12",
39
+ };
40
+ const spanClass = spanVariants[span];
41
+ const classes = `${spanClass}`;
42
+
43
+ return (
44
+ <Component as={as} className={cn(classes, className)} {...props} data-testid={displayName}>
45
+ {children}
46
+ </Component>
47
+ );
48
+ };
49
+
50
+ GridItem.displayName = displayName;
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ "use client";
2
+
3
+ // component exports
4
+ export * from "./grid-item";