Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: package optimisations #3355

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clever-cherries-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/system-rsc": patch
---

fixed `extendVariants` when having `defaultVariants` (#3009)
5 changes: 5 additions & 0 deletions .changeset/cyan-emus-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/date-picker": patch
---

Fix calendar props on date-range-picker
5 changes: 5 additions & 0 deletions .changeset/dry-foxes-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/radio": patch
---

Fix ensure radio input correctly references description (#2932)
5 changes: 5 additions & 0 deletions .changeset/eleven-panthers-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/avatar": patch
---

Removed extra `disableAnimation` prop in `getImageProps` (#3257)
6 changes: 6 additions & 0 deletions .changeset/great-avocados-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nextui-org/chip": patch
"@nextui-org/input": patch
---

Add accessible name to the icon button (#2802, #2808)
6 changes: 6 additions & 0 deletions .changeset/nasty-forks-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nextui-org/accordion": patch
"@nextui-org/theme": patch
---

Fixed variants for nested accordions (#3285)
20 changes: 20 additions & 0 deletions .changeset/pink-rivers-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
"@nextui-org/accordion": patch
"@nextui-org/autocomplete": patch
"@nextui-org/button": patch
"@nextui-org/calendar": patch
"@nextui-org/card": patch
"@nextui-org/dropdown": patch
"@nextui-org/modal": patch
"@nextui-org/navbar": patch
"@nextui-org/popover": patch
"@nextui-org/ripple": patch
"@nextui-org/select": patch
"@nextui-org/snippet": patch
"@nextui-org/tabs": patch
"@nextui-org/tooltip": patch
"@nextui-org/system": patch
"@nextui-org/framer-utils": patch
---

update `framer-motion` versions
15 changes: 15 additions & 0 deletions .changeset/tiny-kids-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@nextui-org/accordion": patch
"@nextui-org/calendar": patch
"@nextui-org/modal": patch
"@nextui-org/navbar": patch
"@nextui-org/popover": patch
"@nextui-org/ripple": patch
"@nextui-org/tooltip": patch
"@nextui-org/theme": patch
"@nextui-org/use-infinite-scroll": patch
"@nextui-org/dom-animation": patch
"@nextui-org/shared-utils": patch
---

framer motion optimization (#3340)
8 changes: 8 additions & 0 deletions .changeset/warm-suits-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@nextui-org/calendar": patch
"@nextui-org/theme": patch
"@nextui-org/use-infinite-scroll": patch
"@nextui-org/shared-utils": patch
---

replaced lodash with native approaches
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"prev": ["const", "let", "var"],
"next": ["const", "let", "var"]
}
],
"import/consistent-type-specifier-style": ["error", "prefer-top-level"]
]
}
}
9 changes: 1 addition & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,5 @@
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"tailwindCSS.experimental.configFile": {
"packages/storybook/tailwind.config.js": ["packages/core/theme/**/*", "packages/components/**/*"],
"apps/docs/tailwind.config.js": "apps/docs/**/*"
},
"tailwindCSS.experimental.classRegex": [
["([\"'`][^\"'`]*.*?[\"'`])", "[\"'`]([^\"'`]*).*?[\"'`]"]
]
}
}
4 changes: 0 additions & 4 deletions apps/docs/app/blog/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {Image} from "@nextui-org/react";

import {ScriptProviders} from "@/components/scripts/script-providers";

interface DocsLayoutProps {
children: React.ReactNode;
}
Expand All @@ -24,8 +22,6 @@ export default function DocsLayout({children}: DocsLayoutProps) {
>
<Image removeWrapper alt="docs right background" src="/gradients/docs-right.png" />
</div>

<ScriptProviders />
</>
);
}
3 changes: 0 additions & 3 deletions apps/docs/app/docs/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Image} from "@nextui-org/react";

import manifest from "@/config/routes.json";
import {DocsSidebar} from "@/components/docs/sidebar";
import {ScriptProviders} from "@/components/scripts/script-providers";

interface DocsLayoutProps {
children: React.ReactNode;
Expand Down Expand Up @@ -31,8 +30,6 @@ export default function DocsLayout({children}: DocsLayoutProps) {
>
<Image removeWrapper alt="docs right background" src="/gradients/docs-right.png" />
</div>

<ScriptProviders />
</>
);
}
2 changes: 1 addition & 1 deletion apps/docs/app/examples/table/custom-styles/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from "@nextui-org/react";
import {ChevronDownIcon, SearchIcon} from "@nextui-org/shared-icons";
import {useCallback, useMemo, useState} from "react";
import {capitalize} from "lodash";
import {capitalize} from "@nextui-org/shared-utils";

import {PlusLinearIcon} from "@/components/icons";
import {VerticalDotsIcon} from "@/components/icons/vertical-dots";
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/app/examples/table/use-case/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from "@nextui-org/react";
import {ChevronDownIcon, SearchIcon} from "@nextui-org/shared-icons";
import {useCallback, useMemo, useState} from "react";
import {capitalize} from "lodash";
import {capitalize} from "@nextui-org/shared-utils";

import {PlusLinearIcon} from "@/components/icons";
import {VerticalDotsIcon} from "@/components/icons/vertical-dots";
Expand Down
3 changes: 0 additions & 3 deletions apps/docs/app/figma/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Image} from "@nextui-org/react";

import {Blockquote} from "@/components/docs/components/blockquote";
import {FigmaButton} from "@/components/figma-button";
import {ScriptProviders} from "@/components/scripts/script-providers";

export default function FigmaPage() {
return (
Expand Down Expand Up @@ -44,8 +43,6 @@ export default function FigmaPage() {
>
<Image removeWrapper alt="docs right background" src="/gradients/docs-right.png" />
</div>

<ScriptProviders />
</>
);
}
2 changes: 2 additions & 0 deletions apps/docs/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {fontSans} from "@/config/fonts";
import {Navbar} from "@/components/navbar";
import {Footer} from "@/components/footer";
import {ProBanner} from "@/components/pro-banner";
import {ScriptProviders} from "@/components/scripts/script-providers";

export const metadata: Metadata = {
title: {
Expand Down Expand Up @@ -76,6 +77,7 @@ export default function RootLayout({children}: {children: React.ReactNode}) {
</div>
<Cmdk />
</Providers>
<ScriptProviders />
</body>
</html>
);
Expand Down
3 changes: 2 additions & 1 deletion apps/docs/components/cmdk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {clsx} from "@nextui-org/shared-utils";
import scrollIntoView from "scroll-into-view-if-needed";
import {isAppleDevice, isWebKit} from "@react-aria/utils";
import {create} from "zustand";
import {intersectionBy, isEmpty} from "lodash";
import {isEmpty} from "@nextui-org/shared-utils";
import intersectionBy from "lodash/intersectionBy";
import {writeStorage, useLocalStorage} from "@rehooks/local-storage";

import {
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/components/code-window/code-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type CodeBlockProps = PreProps & {
* recursively get all text nodes as an array for a given element
*/
function getTextNodes(node: any): any[] {
let childTextNodes: React.ReactNode[] = [];
let childTextNodes = [];

if (!node.hasChildNodes()) return [];

Expand Down
5 changes: 2 additions & 3 deletions apps/docs/components/demo-code-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Skeleton,
} from "@nextui-org/react";
import Link from "next/link";
import {toLower} from "lodash";

import {CodeWindow} from "@/components/code-window";
import {useIsMobile} from "@/hooks/use-media-query";
Expand All @@ -30,8 +29,8 @@ export const DemoCodeModal: FC<DemoCodeModalProps> = ({isOpen, code, title, subt

const isMobile = useIsMobile();

const lowerTitle = toLower(title);
const fileName = `${toLower(lowerTitle)}.tsx`;
const lowerTitle = title.toLowerCase();
const fileName = `${lowerTitle}.tsx`;

return (
<Modal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface CodeDemoProps extends UseCodeDemoProps, WindowResizerProps {
displayMode?: "always" | "visible";
isGradientBox?: boolean;
gradientColor?: GradientBoxProps["color"];
defaultExpanded?: boolean;
previewHeight?: string | number;
overflow?: "auto" | "visible" | "hidden";
className?: string;
Expand All @@ -60,6 +61,7 @@ export const CodeDemo: React.FC<CodeDemoProps> = ({
typescriptStrict = false,
showOpenInCodeSandbox,
isGradientBox = false,
defaultExpanded = false,
previewHeight = "auto",
overflow = "visible",
displayMode = "always",
Expand Down Expand Up @@ -136,6 +138,7 @@ export const CodeDemo: React.FC<CodeDemoProps> = ({

const content = (
<DynamicSandpack
defaultExpanded={defaultExpanded}
files={files}
highlightedLines={highlightedLines}
showEditor={showEditor}
Expand All @@ -152,6 +155,7 @@ export const CodeDemo: React.FC<CodeDemoProps> = ({
isInView,
files,
highlightedLines,
defaultExpanded,
showPreview,
showSandpackPreview,
showOpenInCodeSandbox,
Expand Down
10 changes: 6 additions & 4 deletions apps/docs/components/docs/components/code-demo/utils.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import {get} from "lodash";

import {FileCode} from "./types";

const importRegex = /^(import)\s(?!type(of\s|\s)(?!from)).*?$/gm;

const exportDefaultRegex = /export\s+default\s+function\s+\w+\s*\(\s*\)\s*\{/;

export const transformCode = (code: string, imports = {}, compName = "App") => {
export const transformCode = (
code: string,
imports: {[key: string]: any} = {},
compName = "App",
) => {
let cleanedCode = code
.replace(importRegex, (match) => {
// get component name from the match ex. "import { Table } from '@nextui-org/react'"
const componentName = match.match(/\w+/g)?.[1] || "";
const matchingImport = get(imports, componentName);
const matchingImport = imports[componentName] || {};

if (matchingImport) {
// remove the matching import
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/components/docs/components/codeblock.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {forwardRef, useEffect} from "react";
import {clsx, dataAttr, getUniqueID} from "@nextui-org/shared-utils";
import BaseHighlight, {Language, PrismTheme, defaultProps} from "prism-react-renderer";
import {debounce, omit} from "lodash";
import {debounce, omit} from "@nextui-org/shared-utils";

import defaultTheme from "@/libs/prism-theme";

Expand Down
10 changes: 5 additions & 5 deletions apps/docs/components/docs/components/swatch-colors-set.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {parseToRgba, readableColor} from "color2k";
import {Button, Tooltip} from "@nextui-org/react";
import {commonColors, semanticColors} from "@nextui-org/theme";
import {commonColors, semanticColors, SemanticBaseColors, ThemeColors} from "@nextui-org/theme";
import {useClipboard} from "@nextui-org/use-clipboard";
import {useState} from "react";
import {useTheme} from "next-themes";
import {get, isEmpty} from "lodash";
import {isEmpty} from "@nextui-org/shared-utils";

type ColorsItem = {
color: string;
Expand Down Expand Up @@ -106,12 +106,12 @@ const SemanticSwatch = ({
let value: string = "";
const [colorName, colorScale] = color.split("-");

let currentPalette = get(semanticColors, theme ?? "", {});
const currentPalette = semanticColors[theme as keyof SemanticBaseColors] || {};

if (!colorScale) {
value = get(currentPalette, `${colorName}.DEFAULT`, "");
value = (currentPalette[colorName as keyof ThemeColors] as any)?.DEFAULT || "";
} else {
value = get(currentPalette, `${colorName}.${colorScale}`, "");
value = (currentPalette[colorName as keyof ThemeColors] as any)?.colorScale || "";
}

const handleCopy = () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/components/docs/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
dataFocusVisibleClasses,
} from "@nextui-org/react";
import Link from "next/link";
import {isEmpty} from "lodash";
import {isEmpty} from "@nextui-org/shared-utils";
import {usePathname, useRouter} from "next/navigation";

import {ScrollArea} from "../scroll-area";
Expand Down
4 changes: 1 addition & 3 deletions apps/docs/components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ export const Footer = () => {
return (
<footer className="container mx-auto max-w-7xl pb-12 px-12">
<div className="flex flex-col justify-center items-center gap-1">
<p className="text-sm text-default-400">
© {getCurrentYear()} NextUI Inc. All rights reserved.
</p>
<p className="text-sm text-default-400">© {getCurrentYear()} NextUI Inc.</p>
</div>
</footer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/* eslint-disable react/display-name */
import {useMemo, useState} from "react";
import {Tabs, Tab, Card, CardBody, Image, Button, RadioGroup, Radio} from "@nextui-org/react";
import get from "lodash/get";
import NextLink from "next/link";
import NextImage from "next/image";

Expand Down Expand Up @@ -238,7 +237,7 @@ export const CustomThemes = () => {
<CodeWindow
showWindowIcons
className="max-h-[440px] min-h-[390px]"
highlightLines={get(codeHighlights, selectedTheme)}
highlightLines={codeHighlights[selectedTheme]}
isScrollable={false}
language="jsx"
title="tailwind.config.js"
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/components/marketing/custom-themes/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const shopCartStyles = tv({
"!ease-soft-spring",
"!duration-300",
],
contentWrapper: "flex flex-col justify-center transition-all h-full min-h-[200px]",
contentWrapper: "flex flex-col justify-center transition-all h-full h-[200px]",
title: ["relative", "w-full", "flex-none", "text-xl", "font-semibold", "text-foreground"],
description: ["my-2", "w-full", "text-base", "text-default-500"],
price: "relative text-lg font-semibold text-foreground",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const FloatingComponents: React.FC<{}> = () => {
alt="Professional camera"
as={NextImage}
className="object-cover -translate-y-12 h-[100%]"
height={180}
height={120}
src="/images/card-example-6.webp"
width={120}
/>
Expand Down
6 changes: 2 additions & 4 deletions apps/docs/components/marketing/support.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import {FC, useMemo, useRef} from "react";
import {Avatar, AvatarProps, Button, Spacer, Tooltip} from "@nextui-org/react";
import {clamp, get} from "lodash";
import {clamp} from "@nextui-org/shared-utils";

import {sectionWrapper, titleWrapper, title, subtitle} from "../primitives";

Expand Down Expand Up @@ -132,9 +132,7 @@ export const Support: FC<SupportProps> = ({sponsors = []}) => {
size={getSponsorSize(sponsor, isMobile)}
src={sponsor.image}
style={getSponsorAvatarStyles(index, sponsors)}
onClick={() =>
handleExternalLinkClick(get(sponsor, "website") || get(sponsor, "profile"))
}
onClick={() => handleExternalLinkClick(sponsor["website"] || sponsor["profile"])}
/>
))}
</div>
Expand Down
Loading
Loading