@stackshift-ui/swiper-pagination 6.0.2 → 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/swiper-pagination",
3
3
  "description": "",
4
- "version": "6.0.2",
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": {
@@ -34,7 +35,7 @@
34
35
  "dependencies": {
35
36
  "classnames": "^2.5.1",
36
37
  "@stackshift-ui/scripts": "6.0.2",
37
- "@stackshift-ui/system": "6.0.2"
38
+ "@stackshift-ui/system": "6.0.3"
38
39
  },
39
40
  "peerDependencies": {
40
41
  "@types/react": "16.8 - 19",
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ "use client";
2
+
3
+ // component exports
4
+ export * from "./swiper-pagination";
@@ -0,0 +1,13 @@
1
+ import { cleanup, render, screen } from "@testing-library/react";
2
+ import { afterEach, describe, test } from "vitest";
3
+ import { SwiperPagination } from "./swiper-pagination";
4
+
5
+ describe.concurrent("swiper-pagination", () => {
6
+ afterEach(cleanup);
7
+
8
+ test("Common: Swiper Pagination - test if renders without errors", ({ expect }) => {
9
+ const clx = "swiperpgn-class";
10
+ render(<SwiperPagination className={clx} />);
11
+ expect(screen.getByTestId("button").classList).toContain(clx);
12
+ });
13
+ });
@@ -0,0 +1,52 @@
1
+ import { DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
2
+ import type { ElementType, HTMLProps, ReactNode } from "react";
3
+ import cn from "classnames";
4
+
5
+ type ColorScheme = "blue" | "white";
6
+
7
+ export interface SwiperPaginationProps extends Omit<HTMLProps<HTMLElement>, "as"> {
8
+ isActive?: boolean;
9
+ colorScheme?: ColorScheme;
10
+ onClick?: (...arg0: any[]) => any;
11
+ ariaLabel?: string;
12
+ children?: ReactNode;
13
+ className?: string;
14
+ as?: ElementType;
15
+ }
16
+
17
+ const displayName = "SwiperPagination";
18
+
19
+ export const SwiperPagination: React.FC<SwiperPaginationProps> = ({
20
+ isActive = false,
21
+ colorScheme = "blue",
22
+ onClick,
23
+ ariaLabel,
24
+ children,
25
+ className,
26
+ as = "button",
27
+ ...props
28
+ }) => {
29
+ const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
30
+
31
+ const variantClass = {
32
+ blue: `mr-1 ${isActive ? "bg-primary" : "bg-gray-200"} rounded-full p-1 focus:outline-none`,
33
+ white: `mr-2 inline-block h-2 w-2 rounded-full ${
34
+ isActive ? "bg-white focus:outline-none" : "focus:outline-none"
35
+ }`,
36
+ };
37
+
38
+ const classes = variantClass[colorScheme];
39
+
40
+ return (
41
+ <Component
42
+ onClick={onClick}
43
+ aria-label={ariaLabel}
44
+ as={as}
45
+ className={cn(classes, className)}
46
+ {...props}
47
+ data-testid={displayName}
48
+ />
49
+ );
50
+ };
51
+
52
+ SwiperPagination.displayName = displayName;