@mbao01/common 0.0.1

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/.eslintrc.cjs ADDED
@@ -0,0 +1,34 @@
1
+ module.exports = {
2
+ root: true,
3
+ env: { browser: true, es2020: true },
4
+ extends: [
5
+ "eslint:recommended",
6
+ "plugin:@typescript-eslint/recommended-type-checked",
7
+ "plugin:@typescript-eslint/stylistic-type-checked",
8
+ "plugin:react-hooks/recommended",
9
+ "plugin:storybook/recommended",
10
+ "plugin:react/recommended",
11
+ "plugin:react/jsx-runtime",
12
+ ],
13
+ ignorePatterns: ["dist", ".eslintrc.cjs", "storybook-static"],
14
+ parser: "@typescript-eslint/parser",
15
+ plugins: ["react-refresh"],
16
+ parserOptions: {
17
+ ecmaVersion: "latest",
18
+ sourceType: "module",
19
+ project: ["./tsconfig.json", "./tsconfig.node.json"],
20
+ tsconfigRootDir: __dirname,
21
+ },
22
+ rules: {
23
+ "react-refresh/only-export-components": [
24
+ "warn",
25
+ { allowConstantExport: true },
26
+ ],
27
+ "@typescript-eslint/consistent-type-definitions": ["error", "type"],
28
+ },
29
+ settings: {
30
+ react: {
31
+ version: "detect",
32
+ },
33
+ },
34
+ };
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+
2
+ Shared react meta-framework agnostic components used by [@mbao01/ui](https://www.npmjs.com/package/@mbao01/ui) and [@mbao01/next](https://www.npmjs.com/package/@mbao01/next)
3
+
4
+
5
+ ```bash
6
+ pnpm add @mbao01/common
7
+ ```
8
+
9
+ or
10
+
11
+ ```bash
12
+ npm install @mbao01/common
13
+ ```
14
+
15
+ 2. Install tailwind - do so by following the [installation guide](https://tailwindcss.com/docs/installation)
16
+
17
+ 3. Configure tailwind
18
+
19
+ ```typescript
20
+ export default {
21
+ content: [
22
+ "node_modules/@mbao01/common/src/**/*", // -> ensure to add this to allow tailwind to scan the library for classes
23
+ ...
24
+ ],
25
+ "plugins": [
26
+ require("@mbao01/common/plugin"), // -> import the library plugin
27
+ ...
28
+ ]
29
+ }
30
+ ```
package/package.json ADDED
@@ -0,0 +1,104 @@
1
+ {
2
+ "name": "@mbao01/common",
3
+ "private": false,
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "author": "Ayomide Bakare",
7
+ "license": "MIT",
8
+ "description": "Common components/utilities for @mbao01/ui and @mbao01/next",
9
+ "keywords": [
10
+ "react",
11
+ "components",
12
+ "ui",
13
+ "common",
14
+ "library"
15
+ ],
16
+ "main": "./src/index.ts",
17
+ "files": [
18
+ "src",
19
+ "plugin.js",
20
+ "plugin.d.ts",
21
+ ".eslintrc.cjs",
22
+ "postcss.config.js",
23
+ "tailwind.config.ts",
24
+ "tsconfig.node.json",
25
+ "tsconfig.shared.json",
26
+ "vitest-setup.ts",
27
+ "vitest.config.ts"
28
+ ],
29
+ "exports": {
30
+ "./plugin": "./plugin.js",
31
+ "./styles": "./src/stylesheets/index.css"
32
+ },
33
+ "bugs": "https://github.com/mbao01/mbao01/issues",
34
+ "homepage": "https://shared.ayomidebakare.site",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/mbao01/mbao01.git"
38
+ },
39
+ "sideEffects": [
40
+ "*.css"
41
+ ],
42
+ "dependencies": {
43
+ "clsx": "^2.1.0",
44
+ "daisyui": "^4.6.2"
45
+ },
46
+ "devDependencies": {
47
+ "@heroicons/react": "^2.1.1",
48
+ "@storybook/addon-essentials": "^7.6.14",
49
+ "@storybook/addon-interactions": "^7.6.14",
50
+ "@storybook/addon-links": "^7.6.14",
51
+ "@storybook/addon-onboarding": "^1.0.11",
52
+ "@storybook/addon-themes": "^7.6.14",
53
+ "@storybook/blocks": "^7.6.14",
54
+ "@storybook/react": "^7.6.14",
55
+ "@storybook/react-vite": "^7.6.14",
56
+ "@storybook/test": "^7.6.14",
57
+ "@testing-library/jest-dom": "^6.4.2",
58
+ "@testing-library/react": "^14.2.1",
59
+ "@testing-library/user-event": "^14.5.2",
60
+ "@types/node": "^20.11.17",
61
+ "@types/react": "^18.2.55",
62
+ "@types/react-dom": "^18.2.19",
63
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
64
+ "@typescript-eslint/parser": "^6.21.0",
65
+ "@vitejs/plugin-react": "^4.2.1",
66
+ "@vitest/coverage-v8": "^1.2.2",
67
+ "@vitest/ui": "^1.2.2",
68
+ "autoprefixer": "^10.4.17",
69
+ "eslint": "^8.56.0",
70
+ "eslint-plugin-react": "^7.33.2",
71
+ "eslint-plugin-react-hooks": "^4.6.0",
72
+ "eslint-plugin-react-refresh": "^0.4.5",
73
+ "eslint-plugin-storybook": "^0.6.15",
74
+ "jsdom": "^23.2.0",
75
+ "path": "^0.12.7",
76
+ "postcss": "^8.4.35",
77
+ "react": "^18.2.0",
78
+ "react-dom": "^18.2.0",
79
+ "react-router-dom": "^6.22.0",
80
+ "storybook": "^7.6.14",
81
+ "tailwindcss": "^3.4.1",
82
+ "typescript": "^5.3.3",
83
+ "vite": "^5.1.1",
84
+ "vite-plugin-dts": "^3.7.2",
85
+ "vitest": "^1.2.2"
86
+ },
87
+ "peerDependencies": {
88
+ "@heroicons/react": "^2.1.1",
89
+ "react": "^18.2.0",
90
+ "react-dom": "^18.2.0",
91
+ "typescript": "^5.2.2"
92
+ },
93
+ "scripts": {
94
+ "dev": "storybook dev -p 6006",
95
+ "build": "tsc && vite build",
96
+ "build-storybook": "storybook build",
97
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
98
+ "preview": "vite preview",
99
+ "test": "vitest run",
100
+ "test:ui": "vitest --ui",
101
+ "test:watch": "vitest",
102
+ "test:coverage": "vitest run --coverage"
103
+ }
104
+ }
package/plugin.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import type { Config } from "tailwindcss";
2
+
3
+ declare const plugin: { handler: () => void; config?: Config };
4
+ export = plugin;
package/plugin.js ADDED
@@ -0,0 +1,3 @@
1
+ const daisyui = require("daisyui");
2
+
3
+ module.exports = daisyui;
@@ -0,0 +1,6 @@
1
+ export default {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ };
@@ -0,0 +1,28 @@
1
+ import c from "clsx";
2
+ import { getBadgeClasses } from "./constants";
3
+ import { type BadgeProps } from "./types";
4
+
5
+ export const Badge = ({
6
+ size,
7
+ outline,
8
+ variant = "ghost",
9
+ children,
10
+ className,
11
+ ...props
12
+ }: BadgeProps) => {
13
+ return (
14
+ <span
15
+ {...props}
16
+ className={c(
17
+ getBadgeClasses({ size, variant }),
18
+ {
19
+ "badge-outline": outline,
20
+ "text-base-200": !["ghost", "neutral"].includes(variant),
21
+ },
22
+ className
23
+ )}
24
+ >
25
+ {children}
26
+ </span>
27
+ );
28
+ };
@@ -0,0 +1,31 @@
1
+ import c from "clsx";
2
+ import type { BadgeSize, BadgeVariant } from "./types";
3
+
4
+ const BADGE_SIZE = {
5
+ xs: c("badge-xs"),
6
+ sm: c("badge-sm"),
7
+ md: c("badge-md"),
8
+ lg: c("badge-lg"),
9
+ } satisfies Record<BadgeSize, string>;
10
+
11
+ const BADGE_VARIANTS = {
12
+ accent: c("badge-accent"),
13
+ error: c("badge-error"),
14
+ ghost: c("badge-ghost"),
15
+ info: c("badge-info"),
16
+ neutral: c("badge-neutral"),
17
+ primary: c("badge-primary"),
18
+ secondary: c("badge-secondary"),
19
+ success: c("badge-success"),
20
+ warning: c("badge-warning"),
21
+ } satisfies Record<BadgeVariant, string>;
22
+
23
+ export const getBadgeClasses = ({
24
+ size,
25
+ variant,
26
+ }: {
27
+ size?: BadgeSize;
28
+ variant?: BadgeVariant;
29
+ }) => {
30
+ return c("badge", BADGE_VARIANTS[variant!], BADGE_SIZE[size!]);
31
+ };
@@ -0,0 +1 @@
1
+ export { Badge } from './Badge';
@@ -0,0 +1,18 @@
1
+ export type BadgeSize = "xs" | "sm" | "md" | "lg";
2
+
3
+ export type BadgeVariant =
4
+ | "neutral"
5
+ | "primary"
6
+ | "secondary"
7
+ | "accent"
8
+ | "ghost"
9
+ | "info"
10
+ | "success"
11
+ | "warning"
12
+ | "error";
13
+
14
+ export type BadgeProps = React.HTMLAttributes<HTMLSpanElement> & {
15
+ size?: BadgeSize;
16
+ outline?: boolean;
17
+ variant?: BadgeVariant;
18
+ };
@@ -0,0 +1,40 @@
1
+ import c from "clsx";
2
+ import { getButtonClasses } from "./constants";
3
+ import { type ButtonProps } from "./types";
4
+
5
+ export const Button = (props: ButtonProps) => {
6
+ const {
7
+ className,
8
+ outline,
9
+ label,
10
+ disabled,
11
+ onClick,
12
+ loading,
13
+ variant,
14
+ size,
15
+ wide,
16
+ ...rest
17
+ } = props;
18
+
19
+ return (
20
+ <button
21
+ {...rest}
22
+ onClick={onClick}
23
+ disabled={disabled}
24
+ className={c(
25
+ getButtonClasses({ size, wide, outline, variant, loading }),
26
+ className
27
+ )}
28
+ >
29
+ {label}
30
+ {loading ? (
31
+ <span
32
+ className="absolute left-0 top-0 flex h-full w-full items-center justify-center bg-[inherit]"
33
+ data-testid="loading"
34
+ >
35
+ <span className="loading loading-spinner" />
36
+ </span>
37
+ ) : null}
38
+ </button>
39
+ );
40
+ };
@@ -0,0 +1,44 @@
1
+ import c from 'clsx';
2
+ import type { ButtonSize, ButtonVariant } from './types';
3
+
4
+ const BUTTON_SIZE = {
5
+ xs: c('btn-xs'),
6
+ sm: c('btn-sm'),
7
+ md: c('btn-md'),
8
+ lg: c('btn-lg'),
9
+ } satisfies Record<ButtonSize, string>;
10
+
11
+ const BUTTON_VARIANTS = {
12
+ accent: c('btn-accent'),
13
+ default: c('btn-default'),
14
+ error: c('btn-error'),
15
+ ghost: c('btn-ghost'),
16
+ info: c('btn-info'),
17
+ link: c('btn-link'),
18
+ neutral: c('btn-neutral'),
19
+ primary: c('btn-primary'),
20
+ secondary: c('btn-secondary'),
21
+ success: c('btn-success'),
22
+ warning: c('btn-warning'),
23
+ } satisfies Record<ButtonVariant, string>;
24
+
25
+ export const getButtonClasses = ({
26
+ size,
27
+ wide,
28
+ loading,
29
+ outline,
30
+ variant,
31
+ }: {
32
+ size?: ButtonSize;
33
+ wide?: boolean;
34
+ loading?: boolean;
35
+ outline?: boolean;
36
+ variant?: ButtonVariant;
37
+ }) => {
38
+ return c('btn', BUTTON_VARIANTS[variant!], BUTTON_SIZE[size!], {
39
+ 'btn-outline': outline,
40
+ 'btn-wide': wide,
41
+ 'relative overflow-hidden': loading,
42
+ 'min-h-fit h-10': !size,
43
+ });
44
+ };
@@ -0,0 +1 @@
1
+ export { Button } from "./Button";
@@ -0,0 +1,26 @@
1
+ import type { ButtonHTMLAttributes, ReactNode } from 'react';
2
+
3
+ export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg';
4
+
5
+ export type ButtonVariant =
6
+ | 'default'
7
+ | 'neutral'
8
+ | 'primary'
9
+ | 'secondary'
10
+ | 'accent'
11
+ | 'ghost'
12
+ | 'link'
13
+ | 'info'
14
+ | 'success'
15
+ | 'warning'
16
+ | 'error';
17
+
18
+ export type ButtonProps = {
19
+ size?: ButtonSize;
20
+ wide?: boolean;
21
+ label: ReactNode;
22
+ loading?: boolean;
23
+ outline?: boolean;
24
+ variant?: ButtonVariant;
25
+ disabled?: boolean;
26
+ } & ButtonHTMLAttributes<HTMLButtonElement>;
@@ -0,0 +1,64 @@
1
+ import c from "clsx";
2
+ import {
3
+ CardContentProps,
4
+ CardDescriptionProps,
5
+ CardFooterProps,
6
+ CardHeaderProps,
7
+ CardImageProps,
8
+ CardProps,
9
+ } from "./types";
10
+
11
+ const Card = ({
12
+ compact,
13
+ bordered,
14
+ horizontal,
15
+ overlay,
16
+ className,
17
+ ...props
18
+ }: CardProps) => (
19
+ <div
20
+ className={c(
21
+ "card",
22
+ {
23
+ "card-bordered": bordered,
24
+ "card-compact": compact,
25
+ "card-normal": !compact,
26
+ "image-full": overlay,
27
+ "card-side": horizontal,
28
+ },
29
+ className
30
+ )}
31
+ {...props}
32
+ />
33
+ );
34
+
35
+ const CardHeader = ({ className, ...props }: CardHeaderProps) => (
36
+ <h3 className={c("card-title", className)} {...props} />
37
+ );
38
+
39
+ const CardDescription = ({ className, ...props }: CardDescriptionProps) => (
40
+ <p className={c("text-sm text-muted-foreground", className)} {...props} />
41
+ );
42
+
43
+ const CardContent = ({ className, ...props }: CardContentProps) => (
44
+ <div className={c("card-body p-6 pt-0", className)} {...props} />
45
+ );
46
+
47
+ const CardImage = ({ className, src, alt, ...props }: CardImageProps) => (
48
+ <figure>
49
+ <img className={className} src={src} alt={alt} {...props} />
50
+ </figure>
51
+ );
52
+
53
+ const CardFooter = ({ className, ...props }: CardFooterProps) => (
54
+ <div className={c("card-actions", className)} {...props} />
55
+ );
56
+
57
+ export {
58
+ Card,
59
+ CardHeader,
60
+ CardFooter,
61
+ CardDescription,
62
+ CardContent,
63
+ CardImage,
64
+ };
@@ -0,0 +1 @@
1
+ export * from "./Card";
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+
3
+ export type CardProps = {
4
+ /**
5
+ * applies smaller padding to the card.
6
+ */
7
+ compact?: boolean;
8
+ /**
9
+ * applies border to the card.
10
+ */
11
+ bordered?: boolean;
12
+ /**
13
+ * shows the card horizontally with image to the right or left of it.
14
+ */
15
+ horizontal?: boolean;
16
+ /**
17
+ * overlay is used to make the image full width with the content on top.
18
+ */
19
+ overlay?: boolean;
20
+ } & React.HTMLAttributes<HTMLDivElement>;
21
+
22
+ export type CardContentProps = React.HTMLAttributes<HTMLDivElement>;
23
+ export type CardImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
24
+ export type CardHeaderProps = React.HTMLAttributes<HTMLDivElement>;
25
+ export type CardFooterProps = React.HTMLAttributes<HTMLDivElement>;
26
+ export type CardDescriptionProps = React.HTMLAttributes<HTMLParagraphElement>;
@@ -0,0 +1,10 @@
1
+ import { type DetailProps } from './types';
2
+
3
+ export const Detail = ({ term, children }: DetailProps) => {
4
+ return (
5
+ <dl>
6
+ <dt className="mb-1 py-2 text-sm font-medium">{term}</dt>
7
+ <dd className="text-base">{children}</dd>
8
+ </dl>
9
+ );
10
+ };
@@ -0,0 +1 @@
1
+ export { Detail } from './Detail';
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from 'react';
2
+
3
+ export type DetailProps = {
4
+ term: string;
5
+ children: ReactNode;
6
+ };
@@ -0,0 +1,12 @@
1
+ import c from 'clsx';
2
+ import { createElement } from 'react';
3
+ import { type TextProps } from './types';
4
+ import { getTextClasses } from './constants';
5
+
6
+ export const Text = ({ as = 'span', size, variant, children, className }: TextProps) => {
7
+ return createElement(
8
+ as,
9
+ { className: c(getTextClasses({ size, variant }), className) },
10
+ children
11
+ );
12
+ };
@@ -0,0 +1,29 @@
1
+ import c from 'clsx';
2
+ import type { TextSize, TextVariant } from './types';
3
+
4
+ const TEXT_SIZE = {
5
+ xs: c('text-xs'),
6
+ sm: c('text-sm'),
7
+ base: c('text-base'),
8
+ lg: c('text-lg'),
9
+ xl: c('text-xl'),
10
+ '2xl': c('text-2xl'),
11
+ '3xl': c('text-3xl'),
12
+ '4xl': c('text-4xl'),
13
+ '5xl': c('text-5xl'),
14
+ } satisfies Record<TextSize, string>;
15
+
16
+ const TEXT_VARIANT = {
17
+ info: c('text-info'),
18
+ error: c('text-error'),
19
+ success: c('text-success'),
20
+ warning: c('text-warning'),
21
+ primary: c('text-primary'),
22
+ secondary: c('text-secondary'),
23
+ accent: c('text-accent'),
24
+ neutral: c('text-neutral'),
25
+ } satisfies Record<TextVariant, string>;
26
+
27
+ export const getTextClasses = ({ size, variant }: { size?: TextSize; variant?: TextVariant }) => {
28
+ return c(TEXT_VARIANT[variant!], TEXT_SIZE[size!]);
29
+ };
@@ -0,0 +1 @@
1
+ export { Text } from './Text';
@@ -0,0 +1,21 @@
1
+ export type TextSize = 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl';
2
+
3
+ export type TextTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'p' | 'span';
4
+
5
+ export type TextVariant =
6
+ | 'info'
7
+ | 'error'
8
+ | 'success'
9
+ | 'warning'
10
+ | 'primary'
11
+ | 'secondary'
12
+ | 'accent'
13
+ | 'neutral';
14
+
15
+ export type TextProps = {
16
+ as?: TextTag;
17
+ size?: TextSize;
18
+ variant?: TextVariant;
19
+ children: React.ReactNode;
20
+ className?: string;
21
+ };
@@ -0,0 +1,11 @@
1
+ import c from 'clsx';
2
+ import { getTooltipClasses } from './constants';
3
+ import { type TooltipProps } from './types';
4
+
5
+ export const Tooltip = ({ tip, children, variant, position, className }: TooltipProps) => {
6
+ return (
7
+ <div className={c(getTooltipClasses({ variant, position }), className)} data-tip={tip}>
8
+ {children}
9
+ </div>
10
+ );
11
+ };
@@ -0,0 +1,33 @@
1
+ import c from "clsx";
2
+ import type { TooltipPosition, TooltipVariant } from "./types";
3
+
4
+ const TOOLTIP_POSITION = {
5
+ top: c("tooltip-top"),
6
+ right: c("tooltip-right"),
7
+ bottom: c("tooltip-bottom"),
8
+ left: c("tooltip-left"),
9
+ } satisfies Record<TooltipPosition, string>;
10
+
11
+ const TOOLTIP_VARIANTS = {
12
+ accent: c("tooltip-accent"),
13
+ default: c("tooltip-default"),
14
+ error: c("tooltip-error"),
15
+ ghost: c("tooltip-ghost"),
16
+ info: c("tooltip-info"),
17
+ link: c("tooltip-link"),
18
+ neutral: c("tooltip-neutral"),
19
+ primary: c("tooltip-primary"),
20
+ secondary: c("tooltip-secondary"),
21
+ success: c("tooltip-success"),
22
+ warning: c("tooltip-warning"),
23
+ } satisfies Record<TooltipVariant, string>;
24
+
25
+ export const getTooltipClasses = ({
26
+ variant,
27
+ position,
28
+ }: {
29
+ variant?: TooltipVariant;
30
+ position?: TooltipPosition;
31
+ }) => {
32
+ return c("tooltip", TOOLTIP_VARIANTS[variant!], TOOLTIP_POSITION[position!]);
33
+ };
@@ -0,0 +1 @@
1
+ export { Tooltip } from './Tooltip';
@@ -0,0 +1,24 @@
1
+ import { type ReactNode } from 'react';
2
+
3
+ export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
4
+
5
+ export type TooltipVariant =
6
+ | 'default'
7
+ | 'neutral'
8
+ | 'primary'
9
+ | 'secondary'
10
+ | 'accent'
11
+ | 'ghost'
12
+ | 'link'
13
+ | 'info'
14
+ | 'success'
15
+ | 'warning'
16
+ | 'error';
17
+
18
+ export type TooltipProps = {
19
+ tip: string;
20
+ children: ReactNode;
21
+ variant?: TooltipVariant;
22
+ position?: TooltipPosition;
23
+ className?: string;
24
+ };
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./components/Badge";
2
+ export * from "./components/Button";
3
+ export * from "./components/Card";
4
+ export * from "./components/Detail";
5
+ export * from "./components/Text";
6
+ export * from "./components/Tooltip";
@@ -0,0 +1,2 @@
1
+ @import url('./tailwind.css');
2
+ @import url('./reset.css');
@@ -0,0 +1,25 @@
1
+ .scroll-shadow {
2
+ background-image: linear-gradient(to top, white, white),
3
+ linear-gradient(to top, white, white),
4
+ linear-gradient(to top, rgba(100, 100, 100, 0.25), rgba(255, 255, 255, 0)),
5
+ linear-gradient(
6
+ to bottom,
7
+ rgba(100, 100, 100, 0.25),
8
+ rgba(255, 255, 255, 0)
9
+ );
10
+ background-position: bottom center, top center, bottom center, top center;
11
+ background-color: white;
12
+ background-repeat: no-repeat;
13
+ background-size: 100% 12px, 100% 12px, 100% 10px, 100% 10px;
14
+ background-attachment: local, local, scroll, scroll;
15
+ }
16
+
17
+ input[type="number"]::-webkit-outer-spin-button,
18
+ input[type="number"]::-webkit-inner-spin-button {
19
+ -webkit-appearance: none;
20
+ margin: 0;
21
+ }
22
+
23
+ input[type="number"] {
24
+ -moz-appearance: textfield;
25
+ }
@@ -0,0 +1,11 @@
1
+ import type { Config } from "tailwindcss";
2
+ import daisyui from "daisyui";
3
+
4
+ const config: Config = {
5
+ content: ["./src/**/*.{js,ts,jsx,tsx,mdx}"],
6
+ plugins: [daisyui],
7
+ daisyui: {
8
+ themes: ["light", "dark"],
9
+ },
10
+ };
11
+ export default config;
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "skipLibCheck": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "allowSyntheticDefaultImports": true
8
+ },
9
+ "include": ["vite.config.ts"]
10
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["dom", "dom.iterable", "esnext"],
6
+ "module": "esnext",
7
+ "allowJs": true,
8
+ "skipLibCheck": true,
9
+ "incremental": true,
10
+
11
+ /* Bundler mode */
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "resolveJsonModule": true,
15
+ "isolatedModules": true,
16
+ "esModuleInterop": true,
17
+ "noEmit": true,
18
+ "jsx": "react-jsx",
19
+
20
+ /* Linting */
21
+ "strict": true,
22
+ "noUnusedLocals": true,
23
+ "noUnusedParameters": true,
24
+ "noFallthroughCasesInSwitch": true,
25
+ "types": ["vitest/globals", "@testing-library/jest-dom"]
26
+ }
27
+ }
@@ -0,0 +1,8 @@
1
+ import { afterEach } from "vitest";
2
+ import { cleanup } from "@testing-library/react";
3
+ import "@testing-library/jest-dom/vitest";
4
+
5
+ // runs a cleanup after each test case (e.g. clearing jsdom)
6
+ afterEach(() => {
7
+ cleanup();
8
+ });
@@ -0,0 +1,22 @@
1
+ import { defineConfig } from "vitest/config";
2
+ import react from "@vitejs/plugin-react";
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ test: {
7
+ globals: true,
8
+ environment: "jsdom",
9
+ setupFiles: ["vitest-setup.ts"],
10
+ coverage: {
11
+ all: false,
12
+ enabled: true,
13
+ provider: "v8",
14
+ reporter: ["text", "html", "clover", "json"],
15
+ reportsDirectory: "coverage",
16
+ thresholds: {
17
+ autoUpdate: true,
18
+ },
19
+ exclude: ["**/*.stories.*"],
20
+ },
21
+ },
22
+ });