Import only the lodash helpers twui uses, so a page does not carry the whole library
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/twui",
|
||||
"version": "0.1.13",
|
||||
"version": "0.1.14",
|
||||
"description": "A modular skeletal React component framework for Tailwind CSS v4",
|
||||
"author": "Benjamin Toby",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import _ from "lodash";
|
||||
import merge from "lodash/merge";
|
||||
import omit from "lodash/omit";
|
||||
import React from "react";
|
||||
import { TWUIPopoverStyles } from "../../elements/Modal";
|
||||
import twuiNumberfy from "../../utils/numberfy";
|
||||
@@ -58,19 +59,19 @@ export default function twuiGrabPopoverStyles({
|
||||
};
|
||||
|
||||
if (position === "bottom") {
|
||||
popoverStyle = _.merge(popoverStyle, defaultBottomStyle);
|
||||
popoverStyle = merge(popoverStyle, defaultBottomStyle);
|
||||
} else if (position === "bottom-left") {
|
||||
popoverStyle = _.merge(
|
||||
popoverStyle = merge(
|
||||
popoverStyle,
|
||||
_.omit(defaultBottomStyle, ["transform"]),
|
||||
omit(defaultBottomStyle, ["transform"]),
|
||||
{
|
||||
left: rect.left + window.scrollX,
|
||||
} as React.CSSProperties
|
||||
);
|
||||
} else if (position === "bottom-right") {
|
||||
popoverStyle = _.merge(
|
||||
popoverStyle = merge(
|
||||
popoverStyle,
|
||||
_.omit(defaultBottomStyle, ["left", "transform"]),
|
||||
omit(defaultBottomStyle, ["left", "transform"]),
|
||||
{
|
||||
right:
|
||||
viewportWidth -
|
||||
@@ -80,7 +81,7 @@ export default function twuiGrabPopoverStyles({
|
||||
} as React.CSSProperties
|
||||
);
|
||||
} else if (position === "top") {
|
||||
popoverStyle = _.merge(popoverStyle, defaultTopStyleStyle);
|
||||
popoverStyle = merge(popoverStyle, defaultTopStyleStyle);
|
||||
} else if (position === "right") {
|
||||
popoverStyle.top = rect.top + window.scrollY + rect.height / 2;
|
||||
popoverStyle.left = rect.right + window.scrollX + 8;
|
||||
|
||||
@@ -5,7 +5,7 @@ import Button from "../layout/Button";
|
||||
import { X } from "lucide-react";
|
||||
import { type TWUI_MODAL_PROPS } from "../elements/Modal";
|
||||
import Paper from "../elements/Paper";
|
||||
import _ from "lodash";
|
||||
import omit from "lodash/omit";
|
||||
|
||||
type Props = TWUI_MODAL_PROPS & {
|
||||
open: boolean;
|
||||
@@ -54,7 +54,7 @@ export default function ModalComponent({
|
||||
}}
|
||||
></div>
|
||||
<Paper
|
||||
{..._.omit(props, [
|
||||
{...omit(props, [
|
||||
"target",
|
||||
"targetRef",
|
||||
"targetWrapperProps",
|
||||
|
||||
@@ -3,7 +3,7 @@ import { twMerge } from "tailwind-merge";
|
||||
import ReactDOM from "react-dom";
|
||||
import type { TWUI_MODAL_PROPS } from "../elements/Modal";
|
||||
import Paper from "../elements/Paper";
|
||||
import _ from "lodash";
|
||||
import omit from "lodash/omit";
|
||||
import twuiGrabPopoverStyles from "../(functions)/popver/grab-popover-styles";
|
||||
|
||||
type Props = TWUI_MODAL_PROPS & {
|
||||
@@ -93,7 +93,7 @@ export default function PopoverComponent({
|
||||
|
||||
return ReactDOM.createPortal(
|
||||
<Paper
|
||||
{..._.omit(props, [
|
||||
{...omit(props, [
|
||||
"target",
|
||||
"targetRef",
|
||||
"targetWrapperProps",
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { ComponentProps, Dispatch, SetStateAction } from "react";
|
||||
import _ from "lodash";
|
||||
import { ChevronLeft, ChevronRight } from "lucide-react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import Row from "../layout/Row";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from "react";
|
||||
import _ from "lodash";
|
||||
import throttle from "lodash/throttle";
|
||||
import twuiStripMarkdown from "../../utils/strip-markdown";
|
||||
import {
|
||||
twuiAIChatMessageId,
|
||||
@@ -190,7 +190,7 @@ export default function useAIChatHistory({
|
||||
// Writing on every streamed chunk would thrash storage: throttle
|
||||
const persist = React.useMemo(
|
||||
() =>
|
||||
_.throttle(
|
||||
throttle(
|
||||
(list: TWUIAIChatConversation[], active: string | null) => {
|
||||
if (storageKey) {
|
||||
try {
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import _ from "lodash";
|
||||
import omit from "lodash/omit";
|
||||
import type { DetailedHTMLProps, FormHTMLAttributes, RefObject } from "react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
@@ -16,7 +16,7 @@ type Props<T extends { [key: string]: any } = { [key: string]: any }> =
|
||||
export default function Form<
|
||||
T extends { [key: string]: any } = { [key: string]: any },
|
||||
>({ formRef, ...props }: Props<T>) {
|
||||
const finalProps = _.omit(props, ["submitHandler", "changeHandler"]);
|
||||
const finalProps = omit(props, ["submitHandler", "changeHandler"]);
|
||||
|
||||
return (
|
||||
<form
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import _ from "lodash";
|
||||
import omit from "lodash/omit";
|
||||
import React, {
|
||||
type DetailedHTMLProps,
|
||||
type ImgHTMLAttributes,
|
||||
@@ -44,7 +44,7 @@ export default function Img({
|
||||
|
||||
const [imageError, setImageError] = React.useState(false);
|
||||
|
||||
const finalProps = _.omit(props, [
|
||||
const finalProps = omit(props, [
|
||||
"size",
|
||||
"circle",
|
||||
"bgImg",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import _ from "lodash";
|
||||
import type { DetailedHTMLProps, HTMLAttributes } from "react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ from "lodash";
|
||||
import omit from "lodash/omit";
|
||||
import type { DetailedHTMLProps, HTMLAttributes } from "react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
@@ -16,7 +16,7 @@ type Props = DetailedHTMLProps<
|
||||
* @className twui-stack
|
||||
*/
|
||||
export default function Stack({ gap, componentRef, ...props }: Props) {
|
||||
const finalProps = _.omit(props, "center");
|
||||
const finalProps = omit(props, "center");
|
||||
return (
|
||||
<div
|
||||
{...finalProps}
|
||||
|
||||
Reference in New Issue
Block a user