tw-react-components 0.0.191 → 0.0.197

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/index.esm.js CHANGED
@@ -569,7 +569,7 @@ const sizeClassNames = {
569
569
  const Button = (_a) => {
570
570
  var { children, className, size = 'medium', color = 'slate', variant = 'filled', rounded, loading, disabled, prefixIcon: PrefixIcon, suffixIcon: SuffixIcon, unstyled, dataTestId = 'button' } = _a, props = __rest(_a, ["children", "className", "size", "color", "variant", "rounded", "loading", "disabled", "prefixIcon", "suffixIcon", "unstyled", "dataTestId"]);
571
571
  return (jsxs("button", Object.assign({ className: cn('inline-flex aspect-square shrink-0 items-center justify-center font-medium whitespace-nowrap transition-all outline-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:shrink-0', 'focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive focus-visible:ring-[3px]', sizeClassNames[size].base, variantClassNames[variant].base, variantClassNames[variant].colors[color].base, !unstyled &&
572
- `${variantClassNames[variant].colors[color].hover} ${variantClassNames[variant].colors[color].focus} ${variantClassNames[variant].colors[color].active} cursor-pointer`, unstyled && 'cursor-default', rounded ? 'rounded-full' : 'rounded-md', children ? `${sizeClassNames[size].withChildren} aspect-[initial]` : 'justify-center', className), "data-testid": dataTestId, type: "button", disabled: disabled || loading }, props, { children: [PrefixIcon && !loading && (jsx(PrefixIcon, { className: children ? sizeClassNames[size].icon.withChildren : sizeClassNames[size].icon.base })), loading && (jsx(Spinner, { className: "bg-transparent dark:bg-transparent", spinnerClassName: children ? sizeClassNames[size].icon.withChildren : sizeClassNames[size].icon.base, dataTestId: `${dataTestId}-spinner` })), children, SuffixIcon && !loading && (jsx(SuffixIcon, { className: children ? sizeClassNames[size].icon.withChildren : sizeClassNames[size].icon.base }))] })));
572
+ `${variantClassNames[variant].colors[color].hover} ${variantClassNames[variant].colors[color].focus} ${variantClassNames[variant].colors[color].active} cursor-pointer`, unstyled && 'cursor-default', rounded ? 'rounded-full' : 'rounded-md', children ? `${sizeClassNames[size].withChildren} aspect-[initial]` : 'justify-center', className), "data-testid": dataTestId, type: "button", disabled: disabled || loading }, props, { children: [loading ? (jsx(Spinner, { className: "w-fit bg-transparent dark:bg-transparent", spinnerClassName: children ? sizeClassNames[size].icon.withChildren : sizeClassNames[size].icon.base, dataTestId: `${dataTestId}-spinner` })) : (PrefixIcon && (jsx(PrefixIcon, { className: children ? sizeClassNames[size].icon.withChildren : sizeClassNames[size].icon.base }))), children, SuffixIcon && !loading && (jsx(SuffixIcon, { className: children ? sizeClassNames[size].icon.withChildren : sizeClassNames[size].icon.base }))] })));
573
573
  };
574
574
 
575
575
  const Badge = (_a) => {
@@ -680,8 +680,8 @@ function useIsMobile() {
680
680
  const onChange = () => {
681
681
  setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
682
682
  };
683
+ onChange();
683
684
  mql.addEventListener('change', onChange);
684
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
685
685
  return () => mql.removeEventListener('change', onChange);
686
686
  }, []);
687
687
  return !!isMobile;
@@ -1207,18 +1207,20 @@ const DateTimeInput = (_a) => {
1207
1207
  var { className, value, clearable, type = 'datetime-local', step = 1, minDate, maxDate, hasErrors, onChange, onBlur, displayFormat = 'dddd, MMMM Do YYYY, HH:mm:ss', displayLocale = 'en', ref, dataTestId = 'date-time-input' } = _a, props = __rest(_a, ["className", "value", "clearable", "type", "step", "minDate", "maxDate", "hasErrors", "onChange", "onBlur", "displayFormat", "displayLocale", "ref", "dataTestId"]);
1208
1208
  const [isOpen, setIsOpen] = useState();
1209
1209
  const [calendarView, setCalendarView] = useState('days');
1210
+ const now = useMemo(() => new Date(), []);
1210
1211
  const date = useMemo(() => {
1211
1212
  const result = value
1212
1213
  ? new Date(value)
1213
- : new Date(Math.min(Math.max(new Date(minDate !== null && minDate !== void 0 ? minDate : Date.now()).getTime(), Date.now()), new Date(maxDate !== null && maxDate !== void 0 ? maxDate : Date.now()).getTime()));
1214
+ : new Date(Math.min(Math.max(new Date(minDate !== null && minDate !== void 0 ? minDate : now).getTime(), now.getTime()), new Date(maxDate !== null && maxDate !== void 0 ? maxDate : now).getTime()));
1214
1215
  result.setMinutes(result.getMinutes() - ((result.getMinutes() + step) % step));
1215
1216
  return result;
1216
- }, [step, maxDate, minDate, value]);
1217
+ }, [step, maxDate, minDate, value, now]);
1217
1218
  const displayDate = useMemo(() => value && getDisplayDate(date, { format: displayFormat, locale: displayLocale }), [date, value, displayFormat, displayLocale]);
1218
1219
  const calendarRef = useRef(null);
1219
1220
  useOutsideClick(calendarRef, () => setIsOpen(false));
1220
1221
  useEffect(() => {
1221
1222
  if (!isOpen) {
1223
+ // eslint-disable-next-line react-hooks/set-state-in-effect
1222
1224
  setCalendarView('days');
1223
1225
  }
1224
1226
  }, [isOpen]);
@@ -2167,9 +2169,8 @@ SidebarMenuBadge.displayName = 'SidebarMenuBadge';
2167
2169
  const SidebarMenuSkeleton = (_a) => {
2168
2170
  var { className, showIcon = false, dataTestId = 'sidebar-menu-skeleton' } = _a, props = __rest(_a, ["className", "showIcon", "dataTestId"]);
2169
2171
  // Random width between 50 to 90%.
2170
- const width = useMemo(() => {
2171
- return `${Math.floor(Math.random() * 40) + 50}%`;
2172
- }, []);
2172
+ // eslint-disable-next-line react-hooks/purity
2173
+ const width = useMemo(() => `${Math.floor(Math.random() * 40) + 50}%`, []);
2173
2174
  return (jsxs("div", Object.assign({ "data-testid": dataTestId, "data-sidebar": "menu-skeleton", className: cn('flex h-9 items-center gap-2 rounded-md px-2', className) }, props, { children: [showIcon && jsx(Skeleton, { className: "size-4 rounded-md", "data-sidebar": "menu-skeleton-icon" }), jsx(Skeleton, { className: "h-4 max-w-[--skeleton-width] flex-1", "data-sidebar": "menu-skeleton-text", style: {
2174
2175
  '--skeleton-width': width,
2175
2176
  } })] })));
@@ -2217,14 +2218,14 @@ const Sidebar = Object.assign(SidebarComp, {
2217
2218
 
2218
2219
  const Navbar = ({ className, sidebarTriggerClassName, leftSlot, rightSlot, dataTestId = 'navbar', }) => (jsx(Block, { className: cn('border-b p-2 dark:border-slate-700', className), fullWidth: true, dataTestId: dataTestId, children: jsxs(Flex, { align: "center", justify: "between", children: [jsxs(Flex, { align: "center", children: [jsx(Sidebar.Trigger, { className: sidebarTriggerClassName }), leftSlot] }), rightSlot] }) }));
2219
2220
 
2221
+ const Wrapper = ({ children, variant }) => variant === 'inset' ? (jsx(Block, { className: "overflow-hidden p-2", fullHeight: true, fullWidth: true, children: jsx(Block, { className: "bg-background overflow-hidden rounded-xl shadow-sm", fullHeight: true, fullWidth: true, children: children }) })) : (children);
2220
2222
  const Layout = (_a) => {
2221
2223
  var { children, className } = _a, _b = _a.sidebarProps, { basePath, header, items, extraContent, footer } = _b, sidebarProps = __rest(_b, ["basePath", "header", "items", "extraContent", "footer"]), { navbarProps, NavLink, useLocation } = _a;
2222
- const Wrapper = ({ children }) => sidebarProps.variant === 'inset' ? (jsx(Block, { className: "overflow-hidden p-2", fullHeight: true, fullWidth: true, children: jsx(Block, { className: "bg-background overflow-hidden rounded-xl shadow-sm", fullHeight: true, fullWidth: true, children: children }) })) : (children);
2223
2224
  return (jsxs(Flex, { className: "bg-sidebar h-screen w-screen gap-0 text-black dark:text-white", children: [jsxs(Sidebar, Object.assign({ collapsible: "icon" }, sidebarProps, { className: cn('h-full overflow-hidden', sidebarProps.className), children: [header && (jsx(Sidebar.Header, { children: jsx(Sidebar.Menu, { children: jsx(Sidebar.MenuItem, { children: header }) }) })), jsxs(Sidebar.Content, { className: "gap-0", children: [items
2224
2225
  .filter((item) => !item.hidden)
2225
2226
  .map((item, index) => item.type === 'item' ? (jsx(Sidebar.Group, { children: jsx(Sidebar.Menu, { children: jsx(RenderSideBarItem, Object.assign({ basePath: basePath }, item, { NavLink: NavLink, useLocation: useLocation })) }) }, index)) : (jsxs(Sidebar.Group, { children: [item.title && jsx(Sidebar.GroupLabel, { children: item.title }), jsx(Sidebar.GroupContent, { children: jsx(Sidebar.Menu, { children: item.items
2226
2227
  .filter((subItem) => !subItem.hidden)
2227
- .map((subItem, index) => (jsx(RenderSideBarItem, Object.assign({ basePath: basePath }, subItem, { NavLink: NavLink, useLocation: useLocation }), index))) }) })] }, index))), extraContent] }), footer && (jsx(Sidebar.Footer, { children: jsx(Sidebar.Menu, { children: jsx(Sidebar.MenuItem, { children: footer }) }) })), sidebarProps.variant === 'sidebar' && jsx(Sidebar.Rail, {})] })), jsx(Wrapper, { children: jsxs(Flex, { className: "gap-0 overflow-hidden", direction: "column", fullWidth: true, fullHeight: true, children: [navbarProps && jsx(Navbar, Object.assign({}, navbarProps)), jsx(Flex, { className: cn('overflow-hidden p-3', className), direction: "column", fullWidth: true, fullHeight: true, children: children })] }) })] }));
2228
+ .map((subItem, index) => (jsx(RenderSideBarItem, Object.assign({ basePath: basePath }, subItem, { NavLink: NavLink, useLocation: useLocation }), index))) }) })] }, index))), extraContent] }), footer && (jsx(Sidebar.Footer, { children: jsx(Sidebar.Menu, { children: jsx(Sidebar.MenuItem, { children: footer }) }) })), sidebarProps.variant === 'sidebar' && jsx(Sidebar.Rail, {})] })), jsx(Wrapper, { variant: sidebarProps.variant, children: jsxs(Flex, { className: "gap-0 overflow-hidden", direction: "column", fullWidth: true, fullHeight: true, children: [navbarProps && jsx(Navbar, Object.assign({}, navbarProps)), jsx(Flex, { className: cn('overflow-hidden p-3', className), direction: "column", fullWidth: true, fullHeight: true, children: children })] }) })] }));
2228
2229
  };
2229
2230
  const RenderSideBarItem = ({ basePath = '/', pathname, title, Icon, items, NavLink, useLocation }) => {
2230
2231
  const location = useLocation();
@@ -2257,22 +2258,22 @@ const Popover = Object.assign($Popover, {
2257
2258
  Content: PopoverContent,
2258
2259
  });
2259
2260
 
2260
- const ResizablePanelGroup = (_a) => {
2261
- var { className, dataTestId = 'resizable-panel-group' } = _a, props = __rest(_a, ["className", "dataTestId"]);
2262
- return (jsx(ResizablePrimitive.PanelGroup, Object.assign({ className: cn('flex h-full w-full data-[panel-group-direction=vertical]:flex-col', className), "data-testid": dataTestId }, props)));
2261
+ const ResizableGroup = (_a) => {
2262
+ var { className, dataTestId } = _a, props = __rest(_a, ["className", "dataTestId"]);
2263
+ return (jsx(ResizablePrimitive.Group, Object.assign({ className: cn('flex h-full w-full', className), id: dataTestId }, props)));
2263
2264
  };
2264
2265
  const ResizablePanel = (_a) => {
2265
- var { dataTestId = 'resizable-panel' } = _a, props = __rest(_a, ["dataTestId"]);
2266
- return (jsx(ResizablePrimitive.Panel, Object.assign({ "data-testid": dataTestId }, props)));
2266
+ var { dataTestId } = _a, props = __rest(_a, ["dataTestId"]);
2267
+ return (jsx(ResizablePrimitive.Panel, Object.assign({ id: dataTestId }, props)));
2267
2268
  };
2268
- const ResizableHandle = (_a) => {
2269
- var { withHandle, className, dataTestId = 'resizable-handle' } = _a, props = __rest(_a, ["withHandle", "className", "dataTestId"]);
2270
- return (jsx(ResizablePrimitive.PanelResizeHandle, Object.assign({ className: cn('bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden', 'data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90', className), "data-testid": dataTestId }, props, { children: withHandle && (jsx("div", { className: "bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border", "data-testid": `${dataTestId}-handle`, children: jsx(GripVertical, { className: "h-2.5 w-2.5" }) })) })));
2269
+ const ResizableSeparator = (_a) => {
2270
+ var { withHandle, className, dataTestId } = _a, props = __rest(_a, ["withHandle", "className", "dataTestId"]);
2271
+ return (jsx(ResizablePrimitive.Separator, Object.assign({ className: cn('bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden', 'aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90', className), id: dataTestId }, props, { children: withHandle && (jsx("div", { className: "bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border", "data-testid": `${dataTestId}-handle`, children: jsx(GripVertical, { className: "h-2.5 w-2.5" }) })) })));
2271
2272
  };
2272
2273
  const Resizable = {
2273
- PanelGroup: ResizablePanelGroup,
2274
+ Group: ResizableGroup,
2274
2275
  Panel: ResizablePanel,
2275
- Handle: ResizableHandle,
2276
+ Separator: ResizableSeparator,
2276
2277
  };
2277
2278
 
2278
2279
  const Switch = (_a) => {
@@ -2327,6 +2328,7 @@ const LayoutContextProvider = ({ children, theme: defaultTheme, showIds: default
2327
2328
  }, [resolvedTheme]);
2328
2329
  useEffect(() => {
2329
2330
  if (theme !== 'system') {
2331
+ // eslint-disable-next-line react-hooks/set-state-in-effect
2330
2332
  setResolvedTheme(theme);
2331
2333
  return;
2332
2334
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tw-react-components",
3
3
  "description": "A set of React components build with TailwindCSS to make a nice dashboard.",
4
- "version": "0.0.191",
4
+ "version": "0.0.197",
5
5
  "license": "MIT",
6
6
  "homepage": "https://bacali95.github.io/tw-react-components",
7
7
  "type": "module",
@@ -1,17 +1,17 @@
1
1
  import type { FC } from 'react';
2
2
  import * as ResizablePrimitive from 'react-resizable-panels';
3
- export type ResizablePanelGroupProps = React.ComponentProps<typeof ResizablePrimitive.PanelGroup> & {
3
+ export type ResizableGroupProps = React.ComponentProps<typeof ResizablePrimitive.Group> & {
4
4
  dataTestId?: string;
5
5
  };
6
6
  export type ResizablePanelProps = React.ComponentProps<typeof ResizablePrimitive.Panel> & {
7
7
  dataTestId?: string;
8
8
  };
9
- export type ResizableHandleProps = React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
9
+ export type ResizableSeparatorProps = React.ComponentProps<typeof ResizablePrimitive.Separator> & {
10
10
  withHandle?: boolean;
11
11
  dataTestId?: string;
12
12
  };
13
13
  export declare const Resizable: {
14
- PanelGroup: FC<ResizablePanelGroupProps>;
14
+ Group: FC<ResizableGroupProps>;
15
15
  Panel: FC<ResizablePanelProps>;
16
- Handle: FC<ResizableHandleProps>;
16
+ Separator: FC<ResizableSeparatorProps>;
17
17
  };
@@ -5,7 +5,7 @@ type SheetOverlayProps = ComponentProps<typeof SheetPrimitive.Overlay> & {
5
5
  dataTestId?: string;
6
6
  };
7
7
  declare const sheetVariants: (props?: ({
8
- side?: "top" | "bottom" | "left" | "right" | null | undefined;
8
+ side?: "left" | "bottom" | "right" | "top" | null | undefined;
9
9
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
10
10
  interface SheetContentProps extends ComponentProps<typeof SheetPrimitive.Content>, VariantProps<typeof sheetVariants> {
11
11
  dataTestId?: string;