diff --git a/.eslintrc.js b/.eslintrc.js index 2e99e4580..ed13419ab 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,32 +1,22 @@ module.exports = { extends: [ - 'plugin:react/recommended', - 'plugin:@typescript-eslint/eslint-recommended', + 'eslint:recommended', 'plugin:@typescript-eslint/recommended', - 'plugin:react-hooks/recommended', 'plugin:prettier/recommended', - 'prettier/prettier', + 'plugin:react-hooks/recommended', 'plugin:storybook/recommended', ], - root: true, + ignorePatterns: ['.eslintrc.js', 'config-overrides.js', 'lint-staged.js', 'postcss.config.js', 'tailwind.config.js'], parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint/eslint-plugin'], - ignorePatterns: ['/node_modules/**', '/build/**'], - rules: { - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - '@typescript-eslint/no-inferrable-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/ban-ts-ignore': 'off', - '@typescript-eslint/ban-types': 'off', - 'react/react-in-jsx-scope': 'off', - 'prettier/prettier': ['error'], - 'react/display-name': 'off', - 'react/prop-types': 'off', - }, - settings: { - react: { - version: 'detect', + parserOptions: { + ecmaFeatures: { + jsx: true, }, + project: ['tsconfig.json', 'tsconfig.lib.json', 'cypress/tsconfig.json'], + }, + plugins: ['@typescript-eslint', 'prettier', 'react-hooks', 'storybook'], + root: true, + rules: { + '@typescript-eslint/consistent-type-imports': 'warn', }, }; diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json index 5dc3c01f2..136a93b13 100644 --- a/cypress/tsconfig.json +++ b/cypress/tsconfig.json @@ -1,4 +1,5 @@ { + "extends": "../tsconfig.json", "compilerOptions": { "types": ["cypress", "cypress-axe", "node"] }, diff --git a/package.json b/package.json index 2bdeb7903..92a601b7c 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "cypress:open": "cypress open", "cypress:run": "cypress run", "eject": "react-app-rewired eject", - "lint": "eslint --color", + "lint": "eslint --color --ignore-path .gitignore .", "lint:staged": "lint-staged --config lint-staged.js", "prettier": "prettier --check {src,test,.storybook}/**/*.{js,jsx,ts,tsx,json,css,scss}", "prettier:fix": "prettier --write {src,test,.storybook}/**/*.{js,jsx,ts,tsx,json,css,scss}", @@ -81,19 +81,19 @@ "@types/react": "^18.0.5", "@types/react-dom": "^18.0.1", "@types/react-syntax-highlighter": "^13.5.2", - "@typescript-eslint/eslint-plugin": "^5.10.1", - "@typescript-eslint/parser": "^5.10.1", + "@typescript-eslint/eslint-plugin": "^5.27.0", + "@typescript-eslint/parser": "^5.27.0", "autoprefixer": "^10.4.4", "axe-core": "^4.4.1", "babel-loader": "^8.2.4", "cypress": "^9.6.0", "cypress-axe": "^0.14.0", - "eslint": "^7.32.0", - "eslint-config-prettier": "^8.3.0", - "eslint-plugin-prettier": "^3.4.1", - "eslint-plugin-react": "^7.28.0", - "eslint-plugin-react-hooks": "^4.3.0", - "eslint-plugin-storybook": "^0.5.8", + "eslint": "^8.17.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-react": "^7.30.0", + "eslint-plugin-react-hooks": "^4.5.0", + "eslint-plugin-storybook": "^0.5.12", "flowbite": "^1.4.2", "husky": "^7.0.4", "lint-staged": "^12.3.8", diff --git a/src/docs/Root.tsx b/src/docs/Root.tsx index 9a862856b..a9470ecf4 100644 --- a/src/docs/Root.tsx +++ b/src/docs/Root.tsx @@ -1,4 +1,5 @@ -import { FC, Suspense, useRef, useState } from 'react'; +import type { FC } from 'react'; +import { Suspense, useRef, useState } from 'react'; import { BsGithub } from 'react-icons/bs'; import { HiMenuAlt1 } from 'react-icons/hi'; import { SiStorybook } from 'react-icons/si'; diff --git a/src/docs/pages/AccordionPage.tsx b/src/docs/pages/AccordionPage.tsx index f39323a95..4aff808e0 100644 --- a/src/docs/pages/AccordionPage.tsx +++ b/src/docs/pages/AccordionPage.tsx @@ -1,8 +1,9 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { HiOutlineArrowCircleDown } from 'react-icons/hi'; import { Accordion } from '../../lib'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const AccordionPage: FC = () => { const examples: CodeExample[] = [ diff --git a/src/docs/pages/AlertsPage.tsx b/src/docs/pages/AlertsPage.tsx index 5de76b1a5..32b724586 100644 --- a/src/docs/pages/AlertsPage.tsx +++ b/src/docs/pages/AlertsPage.tsx @@ -1,8 +1,9 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { HiEye, HiInformationCircle } from 'react-icons/hi'; import { Alert } from '../../lib'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const AlertsPage: FC = () => { const alertText = ( diff --git a/src/docs/pages/AvatarPage.tsx b/src/docs/pages/AvatarPage.tsx index 09d45a23d..1059597e6 100644 --- a/src/docs/pages/AvatarPage.tsx +++ b/src/docs/pages/AvatarPage.tsx @@ -1,7 +1,8 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { Avatar, Dropdown } from '../../lib'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const AvatarPage: FC = () => { const examples: CodeExample[] = [ diff --git a/src/docs/pages/BadgesPage.tsx b/src/docs/pages/BadgesPage.tsx index e0977e345..1e2099ca7 100644 --- a/src/docs/pages/BadgesPage.tsx +++ b/src/docs/pages/BadgesPage.tsx @@ -1,8 +1,9 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { HiCheck, HiClock } from 'react-icons/hi'; import { Badge } from '../../lib'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const BadgesPage: FC = () => { const examples: CodeExample[] = [ diff --git a/src/docs/pages/BreadcrumbPage.tsx b/src/docs/pages/BreadcrumbPage.tsx index 37a85da12..4640af2ae 100644 --- a/src/docs/pages/BreadcrumbPage.tsx +++ b/src/docs/pages/BreadcrumbPage.tsx @@ -1,8 +1,9 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { HiHome } from 'react-icons/hi'; import { Breadcrumb } from '../../lib'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const BreadcrumbPage: FC = () => { const examples: CodeExample[] = [ diff --git a/src/docs/pages/ButtonGroupPage.tsx b/src/docs/pages/ButtonGroupPage.tsx index 2346a9664..ce54cc755 100644 --- a/src/docs/pages/ButtonGroupPage.tsx +++ b/src/docs/pages/ButtonGroupPage.tsx @@ -1,7 +1,8 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { HiAdjustments, HiCloudDownload, HiUserCircle } from 'react-icons/hi'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; import { Button } from '../../lib'; const ButtonGroupPage: FC = () => { diff --git a/src/docs/pages/ButtonsPage.tsx b/src/docs/pages/ButtonsPage.tsx index 7545586c0..b70895f2f 100644 --- a/src/docs/pages/ButtonsPage.tsx +++ b/src/docs/pages/ButtonsPage.tsx @@ -1,8 +1,9 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { HiOutlineArrowRight, HiShoppingCart } from 'react-icons/hi'; import { Button, Spinner } from '../../lib'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const ButtonsPage: FC = () => { const examples: CodeExample[] = [ diff --git a/src/docs/pages/CardPage.tsx b/src/docs/pages/CardPage.tsx index 6b7148a3e..27dd22771 100644 --- a/src/docs/pages/CardPage.tsx +++ b/src/docs/pages/CardPage.tsx @@ -1,7 +1,8 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { Card } from '../../lib'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const CardPage: FC = () => { const examples: CodeExample[] = [ diff --git a/src/docs/pages/CarouselPage.tsx b/src/docs/pages/CarouselPage.tsx index 8e864b670..5163b0e65 100644 --- a/src/docs/pages/CarouselPage.tsx +++ b/src/docs/pages/CarouselPage.tsx @@ -1,6 +1,7 @@ -import { FC } from 'react'; +import type { FC } from 'react'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; import { Carousel } from '../../lib'; const CarouselPage: FC = () => { diff --git a/src/docs/pages/DashboardPage.tsx b/src/docs/pages/DashboardPage.tsx index 89c113da8..5825f9857 100644 --- a/src/docs/pages/DashboardPage.tsx +++ b/src/docs/pages/DashboardPage.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { HiExternalLink } from 'react-icons/hi'; import { Link } from 'react-router-dom'; import classNames from 'classnames'; diff --git a/src/docs/pages/DemoPage.tsx b/src/docs/pages/DemoPage.tsx index d133b3d78..c2a74ef65 100644 --- a/src/docs/pages/DemoPage.tsx +++ b/src/docs/pages/DemoPage.tsx @@ -1,5 +1,6 @@ -import { FC, ReactNode } from 'react'; -import reactElementToJSXString, { Options } from 'react-element-to-jsx-string'; +import type { FC, ReactNode } from 'react'; +import type { Options } from 'react-element-to-jsx-string'; +import reactElementToJSXString from 'react-element-to-jsx-string'; import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter'; import { dracula } from 'react-syntax-highlighter/dist/esm/styles/prism'; import tsx from 'react-syntax-highlighter/dist/esm/languages/prism/tsx'; @@ -22,8 +23,6 @@ export type DemoPageProps = { }; export const DemoPage: FC = ({ examples }) => { - const SyntaxHighlighterFix = SyntaxHighlighter as any; - return (
{examples.map(({ title, content, code, showCode = true, codeClassName, codeStringifierOptions }, index) => ( @@ -33,7 +32,7 @@ export const DemoPage: FC = ({ examples }) => {
{showCode && code} - + {reactElementToJSXString(code, { showFunctions: true, functionValue: (fn) => fn.name, @@ -42,7 +41,7 @@ export const DemoPage: FC = ({ examples }) => { useFragmentShortSyntax: false, ...codeStringifierOptions, })} - +
diff --git a/src/docs/pages/DropdownPage.tsx b/src/docs/pages/DropdownPage.tsx index 5e06084e7..0627e4d70 100644 --- a/src/docs/pages/DropdownPage.tsx +++ b/src/docs/pages/DropdownPage.tsx @@ -1,6 +1,7 @@ -import { FC } from 'react'; +import type { FC } from 'react'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; import { Dropdown } from '../../lib'; const DropdownPage: FC = () => { diff --git a/src/docs/pages/FooterPage.tsx b/src/docs/pages/FooterPage.tsx index d0ff9f5bd..66db24b00 100644 --- a/src/docs/pages/FooterPage.tsx +++ b/src/docs/pages/FooterPage.tsx @@ -1,5 +1,6 @@ -import { FC } from 'react'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { FC } from 'react'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; import { Footer } from '../../lib/components/Footer'; import { BsDribbble, BsFacebook, BsGithub, BsInstagram, BsTwitter } from 'react-icons/bs'; diff --git a/src/docs/pages/FormsPage.tsx b/src/docs/pages/FormsPage.tsx index 143d1147f..700f679b2 100644 --- a/src/docs/pages/FormsPage.tsx +++ b/src/docs/pages/FormsPage.tsx @@ -1,7 +1,9 @@ -import { FC, useState } from 'react'; +import type { FC } from 'react'; +import { useState } from 'react'; import { HiMail } from 'react-icons/hi'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; import { Button, Checkbox, FileInput, Label, Radio, Select, Textarea, TextInput, ToggleSwitch } from '../../lib'; const FormsPage: FC = () => { diff --git a/src/docs/pages/ListGroupPage.tsx b/src/docs/pages/ListGroupPage.tsx index b72cb5eef..2d63d4caa 100644 --- a/src/docs/pages/ListGroupPage.tsx +++ b/src/docs/pages/ListGroupPage.tsx @@ -1,8 +1,9 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { HiCloudDownload, HiInbox, HiOutlineAdjustments, HiUserCircle } from 'react-icons/hi'; import { ListGroup } from '../../lib'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const ListGroupPage: FC = () => { const examples: CodeExample[] = [ diff --git a/src/docs/pages/ModalPage.tsx b/src/docs/pages/ModalPage.tsx index 6e5091738..a0a56b1e1 100644 --- a/src/docs/pages/ModalPage.tsx +++ b/src/docs/pages/ModalPage.tsx @@ -1,7 +1,10 @@ -import { FC, useState } from 'react'; +import type { FC } from 'react'; +import { useState } from 'react'; import { HiOutlineExclamationCircle } from 'react-icons/hi'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; +import type { ModalSize, ModalPlacement } from '../../lib'; import { Button, Checkbox, Label, Modal, Select, TextInput } from '../../lib'; const ModalPage: FC = () => { @@ -129,7 +132,7 @@ const ModalPage: FC = () => { - setOpenModal(undefined)}> + setOpenModal(undefined)}> Small modal

@@ -172,7 +175,7 @@ const ModalPage: FC = () => { setOpenModal(undefined)} > Small modal diff --git a/src/docs/pages/NavbarPage.tsx b/src/docs/pages/NavbarPage.tsx index 51c53d883..3bf7d9ad2 100644 --- a/src/docs/pages/NavbarPage.tsx +++ b/src/docs/pages/NavbarPage.tsx @@ -1,5 +1,6 @@ -import { FC } from 'react'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { FC } from 'react'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; import { Avatar, Button, Dropdown, Navbar } from '../../lib'; const NavbarPage: FC = () => { diff --git a/src/docs/pages/PaginationPage.tsx b/src/docs/pages/PaginationPage.tsx index bdf1469dd..9dd497419 100644 --- a/src/docs/pages/PaginationPage.tsx +++ b/src/docs/pages/PaginationPage.tsx @@ -1,7 +1,9 @@ -import { FC, useState } from 'react'; +import type { FC } from 'react'; +import { useState } from 'react'; import { Pagination } from '../../lib/components/Pagination'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const PaginationPage: FC = (): JSX.Element => { const [currentPage, setCurrentPage] = useState(1); diff --git a/src/docs/pages/ProgressPage.tsx b/src/docs/pages/ProgressPage.tsx index b85874eb8..174d1a2ad 100644 --- a/src/docs/pages/ProgressPage.tsx +++ b/src/docs/pages/ProgressPage.tsx @@ -1,7 +1,8 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { Progress } from '../../lib'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const ProgressPage: FC = () => { const examples: CodeExample[] = [ diff --git a/src/docs/pages/RatingPage.tsx b/src/docs/pages/RatingPage.tsx index 177c7636c..ac25020c8 100644 --- a/src/docs/pages/RatingPage.tsx +++ b/src/docs/pages/RatingPage.tsx @@ -1,6 +1,7 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { Rating } from '../../lib'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const RatingPage: FC = () => { const examples: CodeExample[] = [ diff --git a/src/docs/pages/SidebarPage.tsx b/src/docs/pages/SidebarPage.tsx index 4050ec48e..d817c9377 100644 --- a/src/docs/pages/SidebarPage.tsx +++ b/src/docs/pages/SidebarPage.tsx @@ -1,8 +1,9 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { BiBuoy } from 'react-icons/bi'; import { HiArrowSmRight, HiChartPie, HiInbox, HiShoppingBag, HiTable, HiUser, HiViewBoards } from 'react-icons/hi'; import { Sidebar, Badge, Button } from '../../lib'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const SidebarPage: FC = () => { const examples: CodeExample[] = [ diff --git a/src/docs/pages/SpinnersPage.tsx b/src/docs/pages/SpinnersPage.tsx index e50034f17..7b40476bc 100644 --- a/src/docs/pages/SpinnersPage.tsx +++ b/src/docs/pages/SpinnersPage.tsx @@ -1,7 +1,8 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { Button, Spinner } from '../../lib'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const SpinnersPage: FC = () => { const examples: CodeExample[] = [ diff --git a/src/docs/pages/TablePage.tsx b/src/docs/pages/TablePage.tsx index 4c227da5e..9e4c0ce69 100644 --- a/src/docs/pages/TablePage.tsx +++ b/src/docs/pages/TablePage.tsx @@ -1,6 +1,7 @@ -import { FC } from 'react'; +import type { FC } from 'react'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; import { Checkbox, Table } from '../../lib'; const TablePage: FC = () => { diff --git a/src/docs/pages/TabsPage.tsx b/src/docs/pages/TabsPage.tsx index 2ad297ada..c889f75d6 100644 --- a/src/docs/pages/TabsPage.tsx +++ b/src/docs/pages/TabsPage.tsx @@ -1,8 +1,9 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { HiAdjustments, HiClipboardList, HiUserCircle } from 'react-icons/hi'; import { MdDashboard } from 'react-icons/md'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; import { Tabs } from '../../lib'; const TabsPage: FC = () => { diff --git a/src/docs/pages/ThemePage.tsx b/src/docs/pages/ThemePage.tsx index 514f470eb..39891b3fd 100644 --- a/src/docs/pages/ThemePage.tsx +++ b/src/docs/pages/ThemePage.tsx @@ -1,11 +1,11 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import reactElementToJSXString from 'react-element-to-jsx-string'; import { HiInformationCircle } from 'react-icons/hi'; import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter'; import { dracula } from 'react-syntax-highlighter/dist/esm/styles/prism'; import { Alert, Card, DarkThemeToggle } from '../../lib'; import { Flowbite } from '../../lib/components'; -import { CustomFlowbiteTheme } from '../../lib/components/Flowbite/FlowbiteTheme'; +import type { CustomFlowbiteTheme } from '../../lib/components/Flowbite/FlowbiteTheme'; const ThemePage: FC = () => { const theme: CustomFlowbiteTheme = { alert: { color: { primary: 'bg-primary' } } }; diff --git a/src/docs/pages/TimelinePage.tsx b/src/docs/pages/TimelinePage.tsx index c5376b576..e525a5034 100644 --- a/src/docs/pages/TimelinePage.tsx +++ b/src/docs/pages/TimelinePage.tsx @@ -1,5 +1,6 @@ -import { FC } from 'react'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { FC } from 'react'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; import { Timeline, Button } from '../../lib'; import { HiArrowNarrowRight, HiCalendar } from 'react-icons/hi'; diff --git a/src/docs/pages/ToastPage.tsx b/src/docs/pages/ToastPage.tsx index 0ba1df420..1c5cc0be1 100644 --- a/src/docs/pages/ToastPage.tsx +++ b/src/docs/pages/ToastPage.tsx @@ -1,9 +1,10 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { HiFire, HiCheck, HiExclamation, HiX } from 'react-icons/hi'; import { FaTelegramPlane } from 'react-icons/fa'; import { MdLoop } from 'react-icons/md'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; import { Button, Toast } from '../../lib'; const ToastPage: FC = () => { diff --git a/src/docs/pages/TooltipsPage.tsx b/src/docs/pages/TooltipsPage.tsx index c54c578cd..4049b14f9 100644 --- a/src/docs/pages/TooltipsPage.tsx +++ b/src/docs/pages/TooltipsPage.tsx @@ -1,7 +1,8 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import { Button, Tooltip } from '../../lib'; -import { CodeExample, DemoPage } from './DemoPage'; +import type { CodeExample } from './DemoPage'; +import { DemoPage } from './DemoPage'; const TooltipsPage: FC = () => { const examples: CodeExample[] = [ diff --git a/src/docs/routes.tsx b/src/docs/routes.tsx index 9c6172f03..249c4f9d5 100644 --- a/src/docs/routes.tsx +++ b/src/docs/routes.tsx @@ -1,4 +1,4 @@ -import { ComponentProps, FC, ReactNode } from 'react'; +import type { ComponentProps, FC, ReactNode } from 'react'; import { BiNotification } from 'react-icons/bi'; import { BsCreditCard2FrontFill, BsImages } from 'react-icons/bs'; diff --git a/src/index.tsx b/src/index.tsx index bae5c6206..bd71e0ec6 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -6,12 +6,16 @@ import { Flowbite } from './lib/components'; import './index.css'; import 'flowbite'; -const container = document.getElementById('root')!; -const root = createRoot(container); -root.render( - - - - - , -); +const container = document.getElementById('root'); + +if (container) { + const root = createRoot(container); + + root.render( + + + + + , + ); +} diff --git a/src/lib/components/Accordion/Accordion.spec.tsx b/src/lib/components/Accordion/Accordion.spec.tsx index feceb00bd..ac1f0994c 100644 --- a/src/lib/components/Accordion/Accordion.spec.tsx +++ b/src/lib/components/Accordion/Accordion.spec.tsx @@ -1,8 +1,10 @@ -import { render, RenderResult, waitFor } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { HiOutlineArrowCircleDown } from 'react-icons/hi'; -import { Accordion, AccordionProps } from '.'; +import type { AccordionProps } from '.'; +import { Accordion } from '.'; import { Flowbite } from '../Flowbite'; describe('Components / Accordion', () => { diff --git a/src/lib/components/Accordion/Accordion.stories.tsx b/src/lib/components/Accordion/Accordion.stories.tsx index a5ebd5dd7..dee88f255 100644 --- a/src/lib/components/Accordion/Accordion.stories.tsx +++ b/src/lib/components/Accordion/Accordion.stories.tsx @@ -1,9 +1,10 @@ -import { ComponentProps, FC } from 'react'; +import type { ComponentProps, FC } from 'react'; -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; import { HiChevronDown, HiOutlineArrowCircleDown } from 'react-icons/hi'; -import { Accordion, AccordionProps } from '.'; +import type { AccordionProps } from '.'; +import { Accordion } from '.'; export default { title: 'Components/Accordion', diff --git a/src/lib/components/Accordion/AccordionContent.tsx b/src/lib/components/Accordion/AccordionContent.tsx index 06f73f573..d450aaa0e 100644 --- a/src/lib/components/Accordion/AccordionContent.tsx +++ b/src/lib/components/Accordion/AccordionContent.tsx @@ -1,4 +1,4 @@ -import { ComponentProps, FC } from 'react'; +import type { ComponentProps, FC } from 'react'; import { excludeClassName } from '../../helpers/exclude'; import { useTheme } from '../Flowbite/ThemeContext'; diff --git a/src/lib/components/Accordion/AccordionPanel.tsx b/src/lib/components/Accordion/AccordionPanel.tsx index 201f78eec..55ee382a7 100644 --- a/src/lib/components/Accordion/AccordionPanel.tsx +++ b/src/lib/components/Accordion/AccordionPanel.tsx @@ -1,5 +1,6 @@ -import { FC, PropsWithChildren, useState } from 'react'; -import { AccordionProps } from '.'; +import type { FC, PropsWithChildren } from 'react'; +import { useState } from 'react'; +import type { AccordionProps } from '.'; import { AccordionPanelContext } from './AccordionPanelContext'; export interface AccordionPanelProps extends PropsWithChildren { diff --git a/src/lib/components/Accordion/AccordionPanelContext.tsx b/src/lib/components/Accordion/AccordionPanelContext.tsx index 9955ea805..c92ff3b54 100644 --- a/src/lib/components/Accordion/AccordionPanelContext.tsx +++ b/src/lib/components/Accordion/AccordionPanelContext.tsx @@ -1,5 +1,5 @@ import { createContext, useContext } from 'react'; -import { AccordionPanelProps } from './AccordionPanel'; +import type { AccordionPanelProps } from './AccordionPanel'; type AccordionPanelContext = Omit; diff --git a/src/lib/components/Accordion/AccordionTitle.tsx b/src/lib/components/Accordion/AccordionTitle.tsx index 33b6855e2..5c5faa45f 100644 --- a/src/lib/components/Accordion/AccordionTitle.tsx +++ b/src/lib/components/Accordion/AccordionTitle.tsx @@ -1,9 +1,9 @@ -import { ComponentProps, FC } from 'react'; +import type { ComponentProps, FC } from 'react'; import classNames from 'classnames'; import { useAccordionContext } from './AccordionPanelContext'; import { useTheme } from '../Flowbite/ThemeContext'; import { excludeClassName } from '../../helpers/exclude'; -import { FlowbiteHeadingLevel } from '../Flowbite/FlowbiteTheme'; +import type { FlowbiteHeadingLevel } from '../Flowbite/FlowbiteTheme'; export interface AccordionTitleProps extends ComponentProps<'button'> { arrowIcon?: FC>; diff --git a/src/lib/components/Accordion/index.tsx b/src/lib/components/Accordion/index.tsx index 98f752663..c8685e5ea 100644 --- a/src/lib/components/Accordion/index.tsx +++ b/src/lib/components/Accordion/index.tsx @@ -1,5 +1,7 @@ -import { Children, cloneElement, ComponentProps, FC, PropsWithChildren, ReactElement, useMemo, useState } from 'react'; -import { AccordionPanel, AccordionPanelProps } from './AccordionPanel'; +import type { ComponentProps, FC, PropsWithChildren, ReactElement } from 'react'; +import { Children, cloneElement, useMemo, useState } from 'react'; +import type { AccordionPanelProps } from './AccordionPanel'; +import { AccordionPanel } from './AccordionPanel'; import { AccordionTitle } from './AccordionTitle'; import { AccordionContent } from './AccordionContent'; import classNames from 'classnames'; diff --git a/src/lib/components/Alert/Alert.stories.tsx b/src/lib/components/Alert/Alert.stories.tsx index 600125332..ed3f70fcc 100644 --- a/src/lib/components/Alert/Alert.stories.tsx +++ b/src/lib/components/Alert/Alert.stories.tsx @@ -1,7 +1,8 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; import { HiEye, HiInformationCircle } from 'react-icons/hi'; -import { Alert, AlertProps } from '.'; +import type { AlertProps } from '.'; +import { Alert } from '.'; export default { title: 'Components/Alert', diff --git a/src/lib/components/Alert/index.tsx b/src/lib/components/Alert/index.tsx index f0b57343a..deeb8a3e1 100644 --- a/src/lib/components/Alert/index.tsx +++ b/src/lib/components/Alert/index.tsx @@ -1,8 +1,8 @@ -import { ComponentProps, FC, PropsWithChildren, ReactNode } from 'react'; +import type { ComponentProps, FC, PropsWithChildren, ReactNode } from 'react'; import classNames from 'classnames'; import { HiX } from 'react-icons/hi'; import { useTheme } from '../Flowbite/ThemeContext'; -import { FlowbiteColors } from '../Flowbite/FlowbiteTheme'; +import type { FlowbiteColors } from '../Flowbite/FlowbiteTheme'; export interface AlertProps extends PropsWithChildren, 'color'>> { additionalContent?: ReactNode; diff --git a/src/lib/components/Avatar/Avatar.spec.tsx b/src/lib/components/Avatar/Avatar.spec.tsx index c73a585d5..1fe927c8c 100644 --- a/src/lib/components/Avatar/Avatar.spec.tsx +++ b/src/lib/components/Avatar/Avatar.spec.tsx @@ -1,7 +1,7 @@ import { render } from '@testing-library/react'; import { Avatar } from '.'; import { Flowbite } from '../Flowbite'; -import { CustomFlowbiteTheme } from '../Flowbite/FlowbiteTheme'; +import type { CustomFlowbiteTheme } from '../Flowbite/FlowbiteTheme'; import AvatarGroup from './AvatarGroup'; describe('Components / Avatar', () => { diff --git a/src/lib/components/Avatar/Avatar.stories.tsx b/src/lib/components/Avatar/Avatar.stories.tsx index 412b508fb..51a24ff76 100644 --- a/src/lib/components/Avatar/Avatar.stories.tsx +++ b/src/lib/components/Avatar/Avatar.stories.tsx @@ -1,6 +1,7 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; -import { Avatar, AvatarProps } from '.'; +import type { AvatarProps } from '.'; +import { Avatar } from '.'; export default { title: 'Components/Avatar', diff --git a/src/lib/components/Avatar/AvatarGroup.stories.tsx b/src/lib/components/Avatar/AvatarGroup.stories.tsx index c1363e2fc..f0beebd4a 100644 --- a/src/lib/components/Avatar/AvatarGroup.stories.tsx +++ b/src/lib/components/Avatar/AvatarGroup.stories.tsx @@ -1,6 +1,6 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; import { Avatar } from '.'; -import { AvatarGroupProps } from './AvatarGroup'; +import type { AvatarGroupProps } from './AvatarGroup'; export default { title: 'Components/Avatar', diff --git a/src/lib/components/Avatar/AvatarGroup.tsx b/src/lib/components/Avatar/AvatarGroup.tsx index 8b4657422..cc91220a9 100644 --- a/src/lib/components/Avatar/AvatarGroup.tsx +++ b/src/lib/components/Avatar/AvatarGroup.tsx @@ -1,4 +1,5 @@ -import React, { PropsWithChildren, ReactNode } from 'react'; +import type { PropsWithChildren, ReactNode } from 'react'; +import React from 'react'; export type AvatarGroupProps = PropsWithChildren<{ children: ReactNode; diff --git a/src/lib/components/Avatar/AvatarGroupCounter.tsx b/src/lib/components/Avatar/AvatarGroupCounter.tsx index ba8969d23..68ced943c 100644 --- a/src/lib/components/Avatar/AvatarGroupCounter.tsx +++ b/src/lib/components/Avatar/AvatarGroupCounter.tsx @@ -1,4 +1,5 @@ -import React, { PropsWithChildren } from 'react'; +import type { PropsWithChildren } from 'react'; +import React from 'react'; export type AvatarGroupdCounterProps = PropsWithChildren<{ total?: number; diff --git a/src/lib/components/Avatar/index.tsx b/src/lib/components/Avatar/index.tsx index beb16538e..e83c4e18f 100644 --- a/src/lib/components/Avatar/index.tsx +++ b/src/lib/components/Avatar/index.tsx @@ -1,7 +1,7 @@ import classNames from 'classnames'; -import { ComponentProps, FC, PropsWithChildren } from 'react'; +import type { ComponentProps, FC, PropsWithChildren } from 'react'; import { excludeClassName } from '../../helpers/exclude'; -import { FlowbitePositions, FlowbiteSizes } from '../Flowbite/FlowbiteTheme'; +import type { FlowbitePositions, FlowbiteSizes } from '../Flowbite/FlowbiteTheme'; import { useTheme } from '../Flowbite/ThemeContext'; import AvatarGroup from './AvatarGroup'; import AvatarGroupCounter from './AvatarGroupCounter'; diff --git a/src/lib/components/Badge/Badge.stories.tsx b/src/lib/components/Badge/Badge.stories.tsx index 84e75b4f3..16725120d 100644 --- a/src/lib/components/Badge/Badge.stories.tsx +++ b/src/lib/components/Badge/Badge.stories.tsx @@ -1,7 +1,8 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; import { HiCheck } from 'react-icons/hi'; -import { Badge, BadgeProps } from '.'; +import type { BadgeProps } from '.'; +import { Badge } from '.'; export default { title: 'Components/Badge', diff --git a/src/lib/components/Badge/index.tsx b/src/lib/components/Badge/index.tsx index f81c83e14..ac69cfa0c 100644 --- a/src/lib/components/Badge/index.tsx +++ b/src/lib/components/Badge/index.tsx @@ -1,7 +1,7 @@ -import { ComponentProps, FC, PropsWithChildren } from 'react'; +import type { ComponentProps, FC, PropsWithChildren } from 'react'; import classNames from 'classnames'; import { useTheme } from '../Flowbite/ThemeContext'; -import { FlowbiteColors, FlowbiteSizes } from '../Flowbite/FlowbiteTheme'; +import type { FlowbiteColors, FlowbiteSizes } from '../Flowbite/FlowbiteTheme'; import { excludeClassName } from '../../helpers/exclude'; export interface BadgeProps extends PropsWithChildren, 'color'>> { diff --git a/src/lib/components/Breadcrumb/Breadcrumb.stories.tsx b/src/lib/components/Breadcrumb/Breadcrumb.stories.tsx index 406427d5a..07fa4a1e6 100644 --- a/src/lib/components/Breadcrumb/Breadcrumb.stories.tsx +++ b/src/lib/components/Breadcrumb/Breadcrumb.stories.tsx @@ -1,4 +1,4 @@ -import { Meta } from '@storybook/react/types-6-0'; +import type { Meta } from '@storybook/react/types-6-0'; import { HiHome } from 'react-icons/hi'; import { Breadcrumb } from '.'; diff --git a/src/lib/components/Breadcrumb/BreadcrumbItem.tsx b/src/lib/components/Breadcrumb/BreadcrumbItem.tsx index efcf0ab30..a3dbec2a3 100644 --- a/src/lib/components/Breadcrumb/BreadcrumbItem.tsx +++ b/src/lib/components/Breadcrumb/BreadcrumbItem.tsx @@ -1,4 +1,4 @@ -import { FC, ComponentProps, PropsWithChildren } from 'react'; +import type { FC, ComponentProps, PropsWithChildren } from 'react'; import { HiOutlineChevronRight } from 'react-icons/hi'; import { excludeClassName } from '../../helpers/exclude'; import { useTheme } from '../Flowbite/ThemeContext'; diff --git a/src/lib/components/Breadcrumb/index.tsx b/src/lib/components/Breadcrumb/index.tsx index d1f12e88e..b577df44e 100644 --- a/src/lib/components/Breadcrumb/index.tsx +++ b/src/lib/components/Breadcrumb/index.tsx @@ -1,4 +1,4 @@ -import { ComponentProps, FC } from 'react'; +import type { ComponentProps, FC } from 'react'; import { useTheme } from '../Flowbite/ThemeContext'; import BreadcrumbItem from './BreadcrumbItem'; diff --git a/src/lib/components/Button/Button.spec.tsx b/src/lib/components/Button/Button.spec.tsx index 64d5959c2..10510d7c2 100644 --- a/src/lib/components/Button/Button.spec.tsx +++ b/src/lib/components/Button/Button.spec.tsx @@ -1,4 +1,5 @@ -import { render, RenderResult } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { Button } from '.'; import { Flowbite } from '../Flowbite'; diff --git a/src/lib/components/Button/Button.stories.tsx b/src/lib/components/Button/Button.stories.tsx index cbf85c1ac..cb1c975dc 100644 --- a/src/lib/components/Button/Button.stories.tsx +++ b/src/lib/components/Button/Button.stories.tsx @@ -1,6 +1,7 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; -import { Button, ButtonComponentProps } from '.'; +import type { ButtonComponentProps } from '.'; +import { Button } from '.'; export default { title: 'Components/Button', diff --git a/src/lib/components/Button/ButtonGroup.spec.tsx b/src/lib/components/Button/ButtonGroup.spec.tsx index 3a762e4c2..7ca7d0b91 100644 --- a/src/lib/components/Button/ButtonGroup.spec.tsx +++ b/src/lib/components/Button/ButtonGroup.spec.tsx @@ -1,4 +1,5 @@ -import { render, RenderResult } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { Button } from '.'; import { Flowbite } from '../Flowbite'; diff --git a/src/lib/components/Button/ButtonGroup.stories.tsx b/src/lib/components/Button/ButtonGroup.stories.tsx index 8a3d43710..6632af63e 100644 --- a/src/lib/components/Button/ButtonGroup.stories.tsx +++ b/src/lib/components/Button/ButtonGroup.stories.tsx @@ -1,7 +1,7 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; import { Button } from '.'; -import { ButtonGroupProps } from './ButtonGroup'; +import type { ButtonGroupProps } from './ButtonGroup'; export default { title: 'Components/Button', diff --git a/src/lib/components/Button/ButtonGroup.tsx b/src/lib/components/Button/ButtonGroup.tsx index a12b94d2d..13c725f18 100644 --- a/src/lib/components/Button/ButtonGroup.tsx +++ b/src/lib/components/Button/ButtonGroup.tsx @@ -1,6 +1,7 @@ -import { Children, cloneElement, ComponentProps, FC, PropsWithChildren, ReactElement, useMemo } from 'react'; +import type { ComponentProps, FC, PropsWithChildren, ReactElement } from 'react'; +import { Children, cloneElement, useMemo } from 'react'; -import { ButtonComponentProps } from '.'; +import type { ButtonComponentProps } from '.'; import { excludeClassName } from '../../helpers/exclude'; import { useTheme } from '../Flowbite/ThemeContext'; diff --git a/src/lib/components/Button/index.tsx b/src/lib/components/Button/index.tsx index 1192d5ccc..699a7ab07 100644 --- a/src/lib/components/Button/index.tsx +++ b/src/lib/components/Button/index.tsx @@ -1,7 +1,8 @@ -import { ComponentProps, FC, ReactNode } from 'react'; +import type { ComponentProps, FC, ReactNode } from 'react'; import classNames from 'classnames'; -import ButtonGroup, { PositionInButtonGroup } from './ButtonGroup'; -import { +import type { PositionInButtonGroup } from './ButtonGroup'; +import ButtonGroup from './ButtonGroup'; +import type { FlowbiteColors, FlowbiteGradientColors, FlowbiteGradientDuoToneColors, diff --git a/src/lib/components/Card/Card.spec.tsx b/src/lib/components/Card/Card.spec.tsx index eb3029145..ce1822202 100644 --- a/src/lib/components/Card/Card.spec.tsx +++ b/src/lib/components/Card/Card.spec.tsx @@ -1,4 +1,5 @@ -import { render, RenderResult } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render } from '@testing-library/react'; import { Card } from '.'; import { Flowbite } from '../Flowbite'; diff --git a/src/lib/components/Card/Card.stories.tsx b/src/lib/components/Card/Card.stories.tsx index 42559043b..543d76056 100644 --- a/src/lib/components/Card/Card.stories.tsx +++ b/src/lib/components/Card/Card.stories.tsx @@ -1,6 +1,7 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; -import { Card, CardProps } from '.'; +import type { CardProps } from '.'; +import { Card } from '.'; export default { title: 'Components/Card', diff --git a/src/lib/components/Card/index.tsx b/src/lib/components/Card/index.tsx index 711f26b44..15ee678e9 100644 --- a/src/lib/components/Card/index.tsx +++ b/src/lib/components/Card/index.tsx @@ -1,4 +1,4 @@ -import { ComponentProps, FC, PropsWithChildren } from 'react'; +import type { ComponentProps, FC, PropsWithChildren } from 'react'; import classNames from 'classnames'; import { useTheme } from '../Flowbite/ThemeContext'; import { excludeClassName } from '../../helpers/exclude'; diff --git a/src/lib/components/Carousel/Carousel.stories.tsx b/src/lib/components/Carousel/Carousel.stories.tsx index c93fefe4c..598705b54 100644 --- a/src/lib/components/Carousel/Carousel.stories.tsx +++ b/src/lib/components/Carousel/Carousel.stories.tsx @@ -1,6 +1,7 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; -import { Carousel, CarouselProps } from '.'; +import type { CarouselProps } from '.'; +import { Carousel } from '.'; export default { title: 'Components/Carousel', diff --git a/src/lib/components/Carousel/index.tsx b/src/lib/components/Carousel/index.tsx index 4ecd2e10c..b75352bb4 100644 --- a/src/lib/components/Carousel/index.tsx +++ b/src/lib/components/Carousel/index.tsx @@ -1,17 +1,5 @@ -import { - Children, - cloneElement, - ComponentProps, - FC, - PropsWithChildren, - ReactElement, - ReactNode, - useCallback, - useEffect, - useMemo, - useRef, - useState, -} from 'react'; +import type { ComponentProps, FC, PropsWithChildren, ReactElement, ReactNode } from 'react'; +import { Children, cloneElement, useCallback, useEffect, useMemo, useRef, useState } from 'react'; import classNames from 'classnames'; import { HiOutlineChevronLeft, HiOutlineChevronRight } from 'react-icons/hi'; import ScrollContainer from 'react-indiana-drag-scroll'; diff --git a/src/lib/components/DarkThemeToggle/DarkThemeToggle.stories.tsx b/src/lib/components/DarkThemeToggle/DarkThemeToggle.stories.tsx index c38b1a522..1e7071d25 100644 --- a/src/lib/components/DarkThemeToggle/DarkThemeToggle.stories.tsx +++ b/src/lib/components/DarkThemeToggle/DarkThemeToggle.stories.tsx @@ -1,4 +1,4 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; import { DarkThemeToggle } from '.'; import { Flowbite } from '../Flowbite'; diff --git a/src/lib/components/DarkThemeToggle/index.tsx b/src/lib/components/DarkThemeToggle/index.tsx index dab8a4d58..40dae3fd0 100644 --- a/src/lib/components/DarkThemeToggle/index.tsx +++ b/src/lib/components/DarkThemeToggle/index.tsx @@ -1,4 +1,5 @@ -import { FC, useContext } from 'react'; +import type { FC } from 'react'; +import { useContext } from 'react'; import { HiMoon, HiSun } from 'react-icons/hi'; import { ThemeContext } from '../Flowbite/ThemeContext'; diff --git a/src/lib/components/Dropdown/Dropdown.stories.tsx b/src/lib/components/Dropdown/Dropdown.stories.tsx index 3f55abd23..4b14fee7b 100644 --- a/src/lib/components/Dropdown/Dropdown.stories.tsx +++ b/src/lib/components/Dropdown/Dropdown.stories.tsx @@ -1,7 +1,8 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; import { action } from '@storybook/addon-actions'; -import { Dropdown, DropdownProps } from '.'; +import type { DropdownProps } from '.'; +import { Dropdown } from '.'; export default { title: 'Components/Dropdown', diff --git a/src/lib/components/Dropdown/DropdownDivider.tsx b/src/lib/components/Dropdown/DropdownDivider.tsx index 7d23a5ed8..5ad4485af 100644 --- a/src/lib/components/Dropdown/DropdownDivider.tsx +++ b/src/lib/components/Dropdown/DropdownDivider.tsx @@ -1,3 +1,3 @@ -import { FC } from 'react'; +import type { FC } from 'react'; export const DropdownDivider: FC = () =>

; diff --git a/src/lib/components/Dropdown/DropdownHeader.tsx b/src/lib/components/Dropdown/DropdownHeader.tsx index 431b90521..20b6b5145 100644 --- a/src/lib/components/Dropdown/DropdownHeader.tsx +++ b/src/lib/components/Dropdown/DropdownHeader.tsx @@ -1,9 +1,16 @@ -import { FC, PropsWithChildren } from 'react'; +import type { ComponentProps, FC, PropsWithChildren } from 'react'; +import { excludeClassName } from '../../helpers/exclude'; import { DropdownDivider } from './DropdownDivider'; -export const DropdownHeader: FC> = ({ children }) => ( - <> -
{children}
- - -); +export const DropdownHeader: FC>> = ({ children, ...props }): JSX.Element => { + const theirProps = excludeClassName(props); + + return ( + <> +
+ {children} +
+ + + ); +}; diff --git a/src/lib/components/Dropdown/DropdownItem.tsx b/src/lib/components/Dropdown/DropdownItem.tsx index 30c7f564e..75747ba5e 100644 --- a/src/lib/components/Dropdown/DropdownItem.tsx +++ b/src/lib/components/Dropdown/DropdownItem.tsx @@ -1,4 +1,4 @@ -import { FC, PropsWithChildren } from 'react'; +import type { FC, PropsWithChildren } from 'react'; export type DropdownItemProps = PropsWithChildren<{ onClick?: () => void; diff --git a/src/lib/components/Dropdown/index.tsx b/src/lib/components/Dropdown/index.tsx index 4f65dcaef..6e8044ee0 100644 --- a/src/lib/components/Dropdown/index.tsx +++ b/src/lib/components/Dropdown/index.tsx @@ -1,9 +1,12 @@ -import { ComponentProps, FC, PropsWithChildren, ReactNode, useMemo } from 'react'; +import type { ComponentProps, FC, PropsWithChildren, ReactNode } from 'react'; +import { useMemo } from 'react'; import { HiOutlineChevronDown, HiOutlineChevronLeft, HiOutlineChevronRight, HiOutlineChevronUp } from 'react-icons/hi'; import classNames from 'classnames'; -import { Button, ButtonComponentProps } from '../Button'; -import { Tooltip, TooltipProps } from '../Tooltip'; +import type { ButtonComponentProps } from '../Button'; +import { Button } from '../Button'; +import type { TooltipProps } from '../Tooltip'; +import { Tooltip } from '../Tooltip'; import { DropdownItem } from './DropdownItem'; import { DropdownDivider } from './DropdownDivider'; import { DropdownHeader } from './DropdownHeader'; @@ -35,7 +38,7 @@ const DropdownComponent: FC = (props) => { }, [placement]); const content = useMemo(() =>
    {children}
, [children]); - const TriggerWrapper = ({ children }: PropsWithChildren) => + const TriggerWrapper: FC>> = ({ children }): JSX.Element => inline ? : ; return ( diff --git a/src/lib/components/Flowbite/ThemeContext.tsx b/src/lib/components/Flowbite/ThemeContext.tsx index 0ed76ee02..a958626b4 100644 --- a/src/lib/components/Flowbite/ThemeContext.tsx +++ b/src/lib/components/Flowbite/ThemeContext.tsx @@ -1,8 +1,9 @@ /* eslint-disable react-hooks/rules-of-hooks */ -import { FC, ReactNode, createContext, useContext, useState, useEffect } from 'react'; +import type { FC, ReactNode } from 'react'; +import { createContext, useContext, useState, useEffect } from 'react'; import windowExists from '../../helpers/window-exists'; import defaultTheme from '../../theme/default'; -import { FlowbiteTheme } from './FlowbiteTheme'; +import type { FlowbiteTheme } from './FlowbiteTheme'; export type Mode = string | undefined | 'light' | 'dark'; @@ -18,7 +19,7 @@ export const ThemeContext = createContext({ interface ThemeProviderProps { children: ReactNode; - value?: any; + value: ThemeContextProps; } export const ThemeProvider: FC = ({ children, value }) => { diff --git a/src/lib/components/Flowbite/index.tsx b/src/lib/components/Flowbite/index.tsx index 7055e8599..fbb415bac 100644 --- a/src/lib/components/Flowbite/index.tsx +++ b/src/lib/components/Flowbite/index.tsx @@ -1,10 +1,11 @@ -import { FC, HTMLAttributes, useLayoutEffect, useMemo } from 'react'; +import type { FC, HTMLAttributes } from 'react'; +import { useLayoutEffect, useMemo } from 'react'; import { ThemeContext, useThemeMode } from './ThemeContext'; import { mergeDeep } from '../../helpers/mergeDeep'; import defaultTheme from '../../theme/default'; import windowExists from '../../helpers/window-exists'; -import { FlowbiteTheme } from './FlowbiteTheme'; -import { DeepPartial } from '../../helpers/deep-partial'; +import type { FlowbiteTheme } from './FlowbiteTheme'; +import type { DeepPartial } from '../../helpers/deep-partial'; export interface ThemeProps { dark?: boolean; @@ -18,10 +19,10 @@ interface FlowbiteProps extends HTMLAttributes { } export const Flowbite: FC = ({ children, theme = {} }) => { - const { theme: customTheme, dark, usePreferences = true } = theme; + const { theme: customTheme = {}, dark, usePreferences = true } = theme; const [mode, setMode, toggleMode] = useThemeMode(usePreferences); - const mergedTheme = mergeDeep(defaultTheme, customTheme); + const mergedTheme = mergeDeep(defaultTheme, customTheme) as unknown as FlowbiteTheme; useLayoutEffect(() => { if (dark) { diff --git a/src/lib/components/Footer/Footer.stories.tsx b/src/lib/components/Footer/Footer.stories.tsx index 2b01fcaf4..c4e19a446 100644 --- a/src/lib/components/Footer/Footer.stories.tsx +++ b/src/lib/components/Footer/Footer.stories.tsx @@ -1,4 +1,4 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; import { Footer } from '.'; import { BsDribbble, BsFacebook, BsGithub, BsInstagram, BsTwitter } from 'react-icons/bs'; diff --git a/src/lib/components/Footer/FooterBrand.tsx b/src/lib/components/Footer/FooterBrand.tsx index 08e61cb61..7ec1f4913 100644 --- a/src/lib/components/Footer/FooterBrand.tsx +++ b/src/lib/components/Footer/FooterBrand.tsx @@ -1,5 +1,5 @@ import classNames from 'classnames'; -import { FC, PropsWithChildren } from 'react'; +import type { FC, PropsWithChildren } from 'react'; export type FooterBrandProps = PropsWithChildren<{ href?: string; diff --git a/src/lib/components/Footer/FooterCopyright.tsx b/src/lib/components/Footer/FooterCopyright.tsx index c6b2c730f..bd9066bcd 100644 --- a/src/lib/components/Footer/FooterCopyright.tsx +++ b/src/lib/components/Footer/FooterCopyright.tsx @@ -1,5 +1,5 @@ import classNames from 'classnames'; -import { FC, PropsWithChildren } from 'react'; +import type { FC, PropsWithChildren } from 'react'; export type CopyrightProps = PropsWithChildren<{ href?: string; diff --git a/src/lib/components/Footer/FooterIcon.tsx b/src/lib/components/Footer/FooterIcon.tsx index 7a1990b33..3dfe1e847 100644 --- a/src/lib/components/Footer/FooterIcon.tsx +++ b/src/lib/components/Footer/FooterIcon.tsx @@ -1,4 +1,4 @@ -import { FC, PropsWithChildren, ComponentProps } from 'react'; +import type { FC, PropsWithChildren, ComponentProps } from 'react'; import classNames from 'classnames'; export type FooterIconProps = PropsWithChildren<{ diff --git a/src/lib/components/Footer/FooterLink.tsx b/src/lib/components/Footer/FooterLink.tsx index b415b24de..9651dbfc9 100644 --- a/src/lib/components/Footer/FooterLink.tsx +++ b/src/lib/components/Footer/FooterLink.tsx @@ -1,5 +1,5 @@ import classNames from 'classnames'; -import { FC, PropsWithChildren } from 'react'; +import type { FC, PropsWithChildren } from 'react'; export type FooterLinkProps = PropsWithChildren<{ href: string; diff --git a/src/lib/components/Footer/FooterLinkGroup.tsx b/src/lib/components/Footer/FooterLinkGroup.tsx index 2894af618..cf5592642 100644 --- a/src/lib/components/Footer/FooterLinkGroup.tsx +++ b/src/lib/components/Footer/FooterLinkGroup.tsx @@ -1,5 +1,5 @@ import classNames from 'classnames'; -import { FC, PropsWithChildren } from 'react'; +import type { FC, PropsWithChildren } from 'react'; export type FooterLinkGroupProps = PropsWithChildren<{ className?: string; diff --git a/src/lib/components/Footer/index.tsx b/src/lib/components/Footer/index.tsx index 7ac888c1c..5aa6ab752 100644 --- a/src/lib/components/Footer/index.tsx +++ b/src/lib/components/Footer/index.tsx @@ -1,5 +1,5 @@ import classNames from 'classnames'; -import { FC, PropsWithChildren } from 'react'; +import type { FC, PropsWithChildren } from 'react'; import { FooterBrand } from './FooterBrand'; import { FooterCopyright } from './FooterCopyright'; import { FooterLink } from './FooterLink'; diff --git a/src/lib/components/FormControls/Checkbox.stories.tsx b/src/lib/components/FormControls/Checkbox.stories.tsx index 3d7ca901b..2ce814acb 100644 --- a/src/lib/components/FormControls/Checkbox.stories.tsx +++ b/src/lib/components/FormControls/Checkbox.stories.tsx @@ -1,6 +1,7 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; -import { Checkbox, CheckboxProps } from './Checkbox'; +import type { CheckboxProps } from './Checkbox'; +import { Checkbox } from './Checkbox'; export default { title: 'Components/FormControls', diff --git a/src/lib/components/FormControls/Checkbox.tsx b/src/lib/components/FormControls/Checkbox.tsx index a5d6a04dc..ba97494b1 100644 --- a/src/lib/components/FormControls/Checkbox.tsx +++ b/src/lib/components/FormControls/Checkbox.tsx @@ -1,4 +1,4 @@ -import { ComponentProps, FC } from 'react'; +import type { ComponentProps, FC } from 'react'; import classNames from 'classnames'; export type CheckboxProps = Omit, 'type'>; diff --git a/src/lib/components/FormControls/FileInput.stories.tsx b/src/lib/components/FormControls/FileInput.stories.tsx index df30dc4f1..7977a28f9 100644 --- a/src/lib/components/FormControls/FileInput.stories.tsx +++ b/src/lib/components/FormControls/FileInput.stories.tsx @@ -1,6 +1,7 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; -import { FileInput, FileInputProps } from './FileInput'; +import type { FileInputProps } from './FileInput'; +import { FileInput } from './FileInput'; export default { title: 'Components/FormControls', diff --git a/src/lib/components/FormControls/FileInput.tsx b/src/lib/components/FormControls/FileInput.tsx index ba41751d2..8034e1d54 100644 --- a/src/lib/components/FormControls/FileInput.tsx +++ b/src/lib/components/FormControls/FileInput.tsx @@ -1,7 +1,8 @@ -import { FC } from 'react'; +import type { FC } from 'react'; import classNames from 'classnames'; -import { TextInput, TextInputProps } from './TextInput'; +import type { TextInputProps } from './TextInput'; +import { TextInput } from './TextInput'; export type FileInputProps = Omit; diff --git a/src/lib/components/FormControls/Label.stories.tsx b/src/lib/components/FormControls/Label.stories.tsx index 5f1b23df3..b9986bebb 100644 --- a/src/lib/components/FormControls/Label.stories.tsx +++ b/src/lib/components/FormControls/Label.stories.tsx @@ -1,6 +1,7 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; -import { Label, LabelProps } from './Label'; +import type { LabelProps } from './Label'; +import { Label } from './Label'; export default { title: 'Components/FormControls', diff --git a/src/lib/components/FormControls/Label.tsx b/src/lib/components/FormControls/Label.tsx index 3ee9c58fa..c47211b57 100644 --- a/src/lib/components/FormControls/Label.tsx +++ b/src/lib/components/FormControls/Label.tsx @@ -1,4 +1,4 @@ -import { ComponentProps, FC } from 'react'; +import type { ComponentProps, FC } from 'react'; import classNames from 'classnames'; type Color = 'gray' | 'green' | 'red'; diff --git a/src/lib/components/FormControls/Radio.stories.tsx b/src/lib/components/FormControls/Radio.stories.tsx index 8cc7c0a3c..3183202f6 100644 --- a/src/lib/components/FormControls/Radio.stories.tsx +++ b/src/lib/components/FormControls/Radio.stories.tsx @@ -1,6 +1,7 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; -import { Radio, RadioProps } from './Radio'; +import type { RadioProps } from './Radio'; +import { Radio } from './Radio'; export default { title: 'Components/FormControls', diff --git a/src/lib/components/FormControls/Radio.tsx b/src/lib/components/FormControls/Radio.tsx index 588da268d..68e59748d 100644 --- a/src/lib/components/FormControls/Radio.tsx +++ b/src/lib/components/FormControls/Radio.tsx @@ -1,4 +1,4 @@ -import { ComponentProps, FC } from 'react'; +import type { ComponentProps, FC } from 'react'; import classNames from 'classnames'; export type RadioProps = Omit, 'type'>; diff --git a/src/lib/components/FormControls/Select.stories.tsx b/src/lib/components/FormControls/Select.stories.tsx index d5b46a5a0..16c5b335b 100644 --- a/src/lib/components/FormControls/Select.stories.tsx +++ b/src/lib/components/FormControls/Select.stories.tsx @@ -1,6 +1,7 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; -import { Select, SelectProps } from './Select'; +import type { SelectProps } from './Select'; +import { Select } from './Select'; export default { title: 'Components/FormControls', diff --git a/src/lib/components/FormControls/Select.tsx b/src/lib/components/FormControls/Select.tsx index ed504c4dc..305f0ff85 100644 --- a/src/lib/components/FormControls/Select.tsx +++ b/src/lib/components/FormControls/Select.tsx @@ -1,4 +1,4 @@ -import { ComponentProps, FC, ReactNode } from 'react'; +import type { ComponentProps, FC, ReactNode } from 'react'; import classNames from 'classnames'; type Size = 'sm' | 'md' | 'lg'; diff --git a/src/lib/components/FormControls/TextInput.stories.tsx b/src/lib/components/FormControls/TextInput.stories.tsx index db692c021..869984232 100644 --- a/src/lib/components/FormControls/TextInput.stories.tsx +++ b/src/lib/components/FormControls/TextInput.stories.tsx @@ -1,6 +1,7 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; -import { TextInput, TextInputProps } from './TextInput'; +import type { TextInputProps } from './TextInput'; +import { TextInput } from './TextInput'; export default { title: 'Components/FormControls', diff --git a/src/lib/components/FormControls/TextInput.tsx b/src/lib/components/FormControls/TextInput.tsx index 97f0752ce..c0f5ad972 100644 --- a/src/lib/components/FormControls/TextInput.tsx +++ b/src/lib/components/FormControls/TextInput.tsx @@ -1,4 +1,4 @@ -import { ComponentProps, FC, ReactNode } from 'react'; +import type { ComponentProps, FC, ReactNode } from 'react'; import classNames from 'classnames'; type Size = 'sm' | 'md' | 'lg'; diff --git a/src/lib/components/FormControls/Textarea.stories.tsx b/src/lib/components/FormControls/Textarea.stories.tsx index d387aaf24..a4ff4d794 100644 --- a/src/lib/components/FormControls/Textarea.stories.tsx +++ b/src/lib/components/FormControls/Textarea.stories.tsx @@ -1,6 +1,7 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; -import { Textarea, TextareaProps } from './Textarea'; +import type { TextareaProps } from './Textarea'; +import { Textarea } from './Textarea'; export default { title: 'Components/FormControls', diff --git a/src/lib/components/FormControls/Textarea.tsx b/src/lib/components/FormControls/Textarea.tsx index 070d34202..c7cce09c0 100644 --- a/src/lib/components/FormControls/Textarea.tsx +++ b/src/lib/components/FormControls/Textarea.tsx @@ -1,4 +1,4 @@ -import { ComponentProps, FC, ReactNode } from 'react'; +import type { ComponentProps, FC, ReactNode } from 'react'; import classNames from 'classnames'; type Color = 'base' | 'green' | 'red'; diff --git a/src/lib/components/FormControls/ToggleSwitch.spec.tsx b/src/lib/components/FormControls/ToggleSwitch.spec.tsx index dda0776e5..a8a346596 100644 --- a/src/lib/components/FormControls/ToggleSwitch.spec.tsx +++ b/src/lib/components/FormControls/ToggleSwitch.spec.tsx @@ -1,4 +1,5 @@ -import { render, RenderResult } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { useState } from 'react'; import { TextInput } from './TextInput'; diff --git a/src/lib/components/FormControls/ToggleSwitch.stories.tsx b/src/lib/components/FormControls/ToggleSwitch.stories.tsx index 4bf1f907c..a169c0e27 100644 --- a/src/lib/components/FormControls/ToggleSwitch.stories.tsx +++ b/src/lib/components/FormControls/ToggleSwitch.stories.tsx @@ -1,6 +1,7 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; -import { ToggleSwitch, ToggleSwitchProps } from './ToggleSwitch'; +import type { ToggleSwitchProps } from './ToggleSwitch'; +import { ToggleSwitch } from './ToggleSwitch'; export default { title: 'Components/FormControls', diff --git a/src/lib/components/FormControls/ToggleSwitch.tsx b/src/lib/components/FormControls/ToggleSwitch.tsx index fe9f81bea..58aed4c61 100644 --- a/src/lib/components/FormControls/ToggleSwitch.tsx +++ b/src/lib/components/FormControls/ToggleSwitch.tsx @@ -1,4 +1,5 @@ -import { ComponentProps, FC, KeyboardEvent, MouseEvent, useMemo } from 'react'; +import type { ComponentProps, FC, KeyboardEvent, MouseEvent } from 'react'; +import { useMemo } from 'react'; import classNames from 'classnames'; import * as nanoid from 'nanoid'; diff --git a/src/lib/components/ListGroup/ListGroup.stories.tsx b/src/lib/components/ListGroup/ListGroup.stories.tsx index f927a1f57..567959a03 100644 --- a/src/lib/components/ListGroup/ListGroup.stories.tsx +++ b/src/lib/components/ListGroup/ListGroup.stories.tsx @@ -1,7 +1,8 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; import { HiUserCircle, HiOutlineAdjustments, HiInbox, HiCloudDownload } from 'react-icons/hi'; -import { ListGroup, ListGroupProps } from '.'; +import type { ListGroupProps } from '.'; +import { ListGroup } from '.'; export default { title: 'Components/ListGroup', diff --git a/src/lib/components/ListGroup/ListGroupItem.tsx b/src/lib/components/ListGroup/ListGroupItem.tsx index cb7cc92f3..6e9dc622d 100644 --- a/src/lib/components/ListGroup/ListGroupItem.tsx +++ b/src/lib/components/ListGroup/ListGroupItem.tsx @@ -1,4 +1,4 @@ -import { ComponentProps, FC, PropsWithChildren } from 'react'; +import type { ComponentProps, FC, PropsWithChildren } from 'react'; import classNames from 'classnames'; export type ListGroupItemProps = PropsWithChildren<{ diff --git a/src/lib/components/ListGroup/index.tsx b/src/lib/components/ListGroup/index.tsx index c37b5caed..ae7179a5f 100644 --- a/src/lib/components/ListGroup/index.tsx +++ b/src/lib/components/ListGroup/index.tsx @@ -1,4 +1,4 @@ -import { FC, PropsWithChildren } from 'react'; +import type { FC, PropsWithChildren } from 'react'; import classNames from 'classnames'; import { ListGroupItem } from './ListGroupItem'; diff --git a/src/lib/components/Modal/Modal.spec.tsx b/src/lib/components/Modal/Modal.spec.tsx index 61963c612..80ca37bc0 100644 --- a/src/lib/components/Modal/Modal.spec.tsx +++ b/src/lib/components/Modal/Modal.spec.tsx @@ -1,7 +1,8 @@ import { render, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { useState } from 'react'; -import { Modal, ModalProps } from '.'; +import type { ModalProps } from '.'; +import { Modal } from '.'; import { Button } from '../Button'; describe('Components / Modal', () => { diff --git a/src/lib/components/Modal/Modal.stories.tsx b/src/lib/components/Modal/Modal.stories.tsx index e4f678688..70101a9ac 100644 --- a/src/lib/components/Modal/Modal.stories.tsx +++ b/src/lib/components/Modal/Modal.stories.tsx @@ -1,7 +1,8 @@ -import { Meta, Story } from '@storybook/react/types-6-0'; +import type { Meta, Story } from '@storybook/react/types-6-0'; import { action } from '@storybook/addon-actions'; -import { Modal, ModalProps } from '.'; +import type { ModalProps } from '.'; +import { Modal } from '.'; import { Button } from '../Button'; import { HiOutlineExclamationCircle } from 'react-icons/hi'; import { Label, TextInput, Checkbox } from '../FormControls'; diff --git a/src/lib/components/Modal/ModalBody.tsx b/src/lib/components/Modal/ModalBody.tsx index c1157b53f..732568efa 100644 --- a/src/lib/components/Modal/ModalBody.tsx +++ b/src/lib/components/Modal/ModalBody.tsx @@ -1,4 +1,4 @@ -import { FC, PropsWithChildren } from 'react'; +import type { FC, PropsWithChildren } from 'react'; import classNames from 'classnames'; import { useModalContext } from './ModalContext'; diff --git a/src/lib/components/Modal/ModalFooter.tsx b/src/lib/components/Modal/ModalFooter.tsx index d5d29e725..e7706cb41 100644 --- a/src/lib/components/Modal/ModalFooter.tsx +++ b/src/lib/components/Modal/ModalFooter.tsx @@ -1,4 +1,4 @@ -import { FC, PropsWithChildren } from 'react'; +import type { FC, PropsWithChildren } from 'react'; import classNames from 'classnames'; import { useModalContext } from './ModalContext'; diff --git a/src/lib/components/Modal/ModalHeader.tsx b/src/lib/components/Modal/ModalHeader.tsx index 02c5dd6b2..d21eda912 100644 --- a/src/lib/components/Modal/ModalHeader.tsx +++ b/src/lib/components/Modal/ModalHeader.tsx @@ -1,10 +1,13 @@ -import { FC, PropsWithChildren } from 'react'; +import type { ComponentProps, FC, PropsWithChildren } from 'react'; import classNames from 'classnames'; import { HiOutlineX } from 'react-icons/hi'; import { useModalContext } from './ModalContext'; +import { excludeClassName } from '../../helpers/exclude'; + +export const ModalHeader: FC>> = ({ children, ...props }): JSX.Element => { + const theirProps = excludeClassName(props); -export const ModalHeader: FC> = ({ children }) => { const { popup, onClose } = useModalContext(); return ( @@ -13,6 +16,7 @@ export const ModalHeader: FC> = ({ children }) => { 'p-2': popup, 'border-b p-5': !popup, })} + {...theirProps} >

{children}