@kkkarsss/ui 1.5.0 → 1.5.2

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.
@@ -0,0 +1,2 @@
1
+ export declare const useMediaQuery: (query: string) => boolean;
2
+ export declare const useIsMobile: () => boolean;
@@ -0,0 +1,15 @@
1
+ import { useEffect, useState } from 'react';
2
+ export const useMediaQuery = (query) => {
3
+ const [matches, setMatches] = useState(false);
4
+ useEffect(() => {
5
+ const media = window.matchMedia(query);
6
+ if (media.matches !== matches) {
7
+ setMatches(media.matches);
8
+ }
9
+ const listener = () => setMatches(media.matches);
10
+ media.addEventListener('change', listener);
11
+ return () => media.removeEventListener('change', listener);
12
+ }, [matches, query]);
13
+ return matches;
14
+ };
15
+ export const useIsMobile = () => useMediaQuery('(max-width: 800px)');
@@ -3,6 +3,7 @@ import type { TBlockProps } from '../../ui';
3
3
  export type TWidget = {
4
4
  ui: ReactElement<TBlockProps>;
5
5
  id: string;
6
+ isFullWidth?: boolean;
6
7
  };
7
8
  type TWidgetProviderState = {
8
9
  widget: TWidget | null;
@@ -1,8 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Maximize2, Minimize2, X } from 'lucide-react';
3
+ import { useIsMobile } from '../../../hooks/use-media-query';
3
4
  import { Flex, IconAction } from '../../layout';
4
5
  import { Block } from '../block/block';
5
6
  export const Widget = ({ children, title, isFullWidth, onToggleFullWidth, onClose, topAcc, maxWidth = '400px', ...blockProps }) => {
7
+ const isMobile = useIsMobile();
6
8
  const systemActions = (_jsxs(Flex, { align: 'center', gap: '4px', children: [onToggleFullWidth && (_jsx(IconAction, { icon: isFullWidth ? (_jsx(Minimize2, { size: 16, color: 'var(--secondary-foreground)' })) : (_jsx(Maximize2, { size: 16, color: 'var(--secondary-foreground)' })), onClick: onToggleFullWidth })), onClose && _jsx(IconAction, { icon: _jsx(X, { size: 16, color: 'var(--secondary-foreground)' }), onClick: onClose })] }));
7
- return (_jsx(Block, { ...blockProps, title: title, maxWidth: isFullWidth ? '100%' : maxWidth, topAcc: _jsxs(Flex, { align: 'center', gap: '8px', children: [topAcc, systemActions] }), children: children }));
9
+ return (_jsx(Block, { ...blockProps, title: title, maxWidth: isMobile ? undefined : isFullWidth ? '100%' : maxWidth, topAcc: _jsxs(Flex, { align: 'center', gap: '8px', children: [topAcc, systemActions] }), children: children }));
8
10
  };
@@ -8,5 +8,5 @@ import { IconAction } from '../icon-action/icon-action';
8
8
  export const MainPageLayout = ({ children, leftPanel, rightPanel, leftIcon, rightIcon, }) => {
9
9
  const { widget } = useWidget();
10
10
  const { expandedPanel, toggleLeftPanel, toggleRightPanel } = useLayout();
11
- return (_jsx("div", { className: "@container w-full h-[100dvh]", children: _jsxs("main", { className: "grid h-full w-full grid-cols-1 @s:grid-cols-[300px_1fr_300px] @s:py-xl @s:px-l @s:gap-l py-m px-s gap-s relative overflow-hidden", children: [_jsx("aside", { className: "hidden @s:block h-full w-full", children: leftPanel }), _jsx("div", { className: "@s:hidden absolute left-4 top-4 z-50", children: _jsx(IconAction, { icon: expandedPanel === 'left' ? _jsx(X, { size: 20 }) : leftIcon || _jsx(Menu, { size: 20 }), onClick: toggleLeftPanel }) }), _jsxs(Flex, { direction: 'column', justify: 'center', gap: '16px', type: 'fill', className: jc(expandedPanel ? 'hidden @s:flex' : 'flex', 'h-full mt-[50px] @s:m-0', '@s:flex-row @s:items-stretch'), children: [_jsx("div", { className: jc('h-full overflow-auto', '@s:flex-1', widget ? 'hidden @s:block' : 'block'), children: children }), widget && (_jsx("div", { className: "flex-1 min-h-0 h-full w-full @s:flex-initial @s:w-[360px]", children: _jsx(Fragment, { children: widget.ui }, widget.id) }))] }), _jsx("aside", { className: "hidden @s:block h-full w-full", children: rightPanel }), _jsx("div", { className: "@s:hidden absolute right-4 top-4 z-50", children: _jsx(IconAction, { icon: expandedPanel === 'right' ? _jsx(X, { size: 20 }) : rightIcon || _jsx(Menu, { size: 20 }), onClick: toggleRightPanel }) }), expandedPanel && (_jsx("div", { className: "@s:hidden absolute inset-0 z-40 bg-background pt-16 px-4 pb-4 overflow-auto", children: expandedPanel === 'left' ? leftPanel : rightPanel }))] }) }));
11
+ return (_jsx("div", { className: "@container w-full h-[100dvh]", children: _jsxs("main", { className: "grid h-full w-full grid-cols-1 @s:grid-cols-[300px_1fr_300px] @s:py-xl @s:px-l @s:gap-l py-m px-s gap-s relative overflow-hidden", children: [_jsx("aside", { className: "hidden @s:block h-full w-full", children: leftPanel }), _jsx("div", { className: "@s:hidden absolute left-4 top-4 z-50", children: _jsx(IconAction, { icon: expandedPanel === 'left' ? _jsx(X, { size: 20 }) : leftIcon || _jsx(Menu, { size: 20 }), onClick: toggleLeftPanel }) }), _jsxs(Flex, { direction: 'column', justify: 'center', gap: '16px', type: 'fill', className: jc(expandedPanel ? 'hidden @s:flex' : 'flex', 'h-full mt-[50px] @s:m-0', '@s:flex-row @s:items-stretch'), children: [!widget?.isFullWidth && (_jsx("div", { className: jc('h-full overflow-auto', '@s:flex-1', widget ? 'hidden @s:block' : 'block'), children: children })), widget && (_jsx("div", { className: jc('flex-1 min-h-0 h-full w-full', !widget.isFullWidth && '@s:flex-initial @s:w-[360px]'), children: _jsx(Fragment, { children: widget.ui }, widget.id) }))] }), _jsx("aside", { className: "hidden @s:block h-full w-full", children: rightPanel }), _jsx("div", { className: "@s:hidden absolute right-4 top-4 z-50", children: _jsx(IconAction, { icon: expandedPanel === 'right' ? _jsx(X, { size: 20 }) : rightIcon || _jsx(Menu, { size: 20 }), onClick: toggleRightPanel }) }), expandedPanel && (_jsx("div", { className: "@s:hidden absolute inset-0 z-40 bg-background pt-16 px-4 pb-4 overflow-auto", children: expandedPanel === 'left' ? leftPanel : rightPanel }))] }) }));
12
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kkkarsss/ui",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "UI Kit for kkkarsss projects",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",