@ttoss/layouts 0.4.15 → 0.4.16

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/dist/esm/index.js CHANGED
@@ -2275,8 +2275,8 @@ var Icon2 = React2.forwardRef((props, ref) => {
2275
2275
  Icon2.displayName = "Icon";
2276
2276
 
2277
2277
  // src/components/Header.tsx
2278
- import { Box as Box3, Flex, IconButton } from "@ttoss/ui";
2279
- import * as React4 from "react";
2278
+ import { Box as Box3, Flex as Flex2, IconButton as IconButton2 } from "@ttoss/ui";
2279
+ import * as React5 from "react";
2280
2280
 
2281
2281
  // src/components/LayoutProvider.tsx
2282
2282
  import * as React3 from "react";
@@ -2285,7 +2285,7 @@ import * as React3 from "react";
2285
2285
  import { useBreakpointIndex } from "@ttoss/ui";
2286
2286
  var useIsDesktop = () => {
2287
2287
  const breakpointIndex = useBreakpointIndex();
2288
- const isDesktop = breakpointIndex >= 1;
2288
+ const isDesktop = breakpointIndex >= 2;
2289
2289
  return {
2290
2290
  isDesktop
2291
2291
  };
@@ -2332,10 +2332,16 @@ var useLayout = () => {
2332
2332
 
2333
2333
  // src/components/Sidebar.tsx
2334
2334
  import { Drawer } from "@ttoss/components/Drawer";
2335
- import { Box as Box2 } from "@ttoss/ui";
2336
- import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
2335
+ import { Box as Box2, Flex, IconButton } from "@ttoss/ui";
2336
+ import * as React4 from "react";
2337
+ import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
2337
2338
  var SIDEBAR_WIDTH = "2xs";
2338
- var Sidebar = props => {
2339
+ var Sidebar = ({
2340
+ drawerSlot,
2341
+ showSidebarButtonInDrawer,
2342
+ children,
2343
+ ...boxProps
2344
+ }) => {
2339
2345
  const {
2340
2346
  isSidebarOpen,
2341
2347
  toggleSidebar
@@ -2343,6 +2349,42 @@ var Sidebar = props => {
2343
2349
  const {
2344
2350
  isDesktop
2345
2351
  } = useIsDesktop();
2352
+ const sidebarButtonInDrawer = React4.useMemo(() => {
2353
+ if (!showSidebarButtonInDrawer) {
2354
+ return null;
2355
+ }
2356
+ return /* @__PURE__ */jsx4(IconButton, {
2357
+ "aria-label": isSidebarOpen ? "Close sidebar" : "Open sidebar",
2358
+ "aria-expanded": isSidebarOpen,
2359
+ "aria-controls": "sidebar",
2360
+ sx: {
2361
+ cursor: "pointer",
2362
+ fontSize: ["xl", "2xl"]
2363
+ },
2364
+ "data-testid": "sidebar-button",
2365
+ children: /* @__PURE__ */jsx4(Icon2, {
2366
+ icon: isSidebarOpen ? "sidebar-close" : "sidebar-open"
2367
+ })
2368
+ });
2369
+ }, [isSidebarOpen, showSidebarButtonInDrawer]);
2370
+ const memoizedDrawerSlot = React4.useMemo(() => {
2371
+ if (!drawerSlot) {
2372
+ return /* @__PURE__ */jsx4(Fragment, {
2373
+ children: sidebarButtonInDrawer
2374
+ });
2375
+ }
2376
+ return /* @__PURE__ */jsxs(Flex, {
2377
+ sx: {
2378
+ minWidth: SIDEBAR_WIDTH,
2379
+ width: SIDEBAR_WIDTH,
2380
+ borderRight: "sm",
2381
+ borderColor: "display.border.muted.default",
2382
+ alignItems: "center",
2383
+ gap: "2"
2384
+ },
2385
+ children: [sidebarButtonInDrawer, drawerSlot]
2386
+ });
2387
+ }, [drawerSlot, sidebarButtonInDrawer]);
2346
2388
  return /* @__PURE__ */jsx4(Fragment, {
2347
2389
  children: isDesktop ? /* @__PURE__ */jsx4(Box2, {
2348
2390
  role: "complementary",
@@ -2360,19 +2402,22 @@ var Sidebar = props => {
2360
2402
  borderRight: isSidebarOpen ? "sm" : "none",
2361
2403
  borderColor: "display.border.muted.default",
2362
2404
  backgroundColor: "navigation.background.muted.default",
2363
- paddingX: isSidebarOpen ? "3" : "0",
2364
- paddingY: isSidebarOpen ? "10" : "0",
2365
- ...props.sx
2405
+ paddingX: isSidebarOpen ? "6" : "0",
2406
+ paddingY: isSidebarOpen ? "6" : "0",
2407
+ overflowY: "auto",
2408
+ ...boxProps.sx
2366
2409
  },
2367
- children: isSidebarOpen ? props.children : null
2410
+ children: isSidebarOpen ? children : null
2368
2411
  }) : /* @__PURE__ */jsx4(Box2, {
2369
2412
  role: "complementary",
2370
2413
  "aria-label": "Sidebar",
2371
2414
  "aria-hidden": !isSidebarOpen,
2372
2415
  sx: {
2416
+ position: "fixed",
2373
2417
  border: "none",
2374
- width: "full",
2375
- ...props.sx
2418
+ width: isSidebarOpen ? "full" : "0",
2419
+ height: isSidebarOpen ? "full" : "0",
2420
+ ...boxProps.sx
2376
2421
  },
2377
2422
  onClick: () => {
2378
2423
  if (isSidebarOpen) {
@@ -2382,8 +2427,17 @@ var Sidebar = props => {
2382
2427
  children: /* @__PURE__ */jsx4(Drawer, {
2383
2428
  open: isSidebarOpen,
2384
2429
  direction: "left",
2385
- size: "min",
2386
- children: isSidebarOpen ? props.children : null
2430
+ size: "100%",
2431
+ enableOverlay: false,
2432
+ children: /* @__PURE__ */jsxs(Flex, {
2433
+ sx: {
2434
+ width: "full",
2435
+ height: "full",
2436
+ gap: "6",
2437
+ flexDirection: "column"
2438
+ },
2439
+ children: [memoizedDrawerSlot, isSidebarOpen ? children : null]
2440
+ })
2387
2441
  })
2388
2442
  })
2389
2443
  });
@@ -2391,7 +2445,7 @@ var Sidebar = props => {
2391
2445
  Sidebar.displayName = "Sidebar";
2392
2446
 
2393
2447
  // src/components/Header.tsx
2394
- import { Fragment as Fragment2, jsx as jsx5, jsxs } from "react/jsx-runtime";
2448
+ import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
2395
2449
  var paddingSx = {
2396
2450
  paddingX: "4",
2397
2451
  paddingY: "3"
@@ -2406,11 +2460,11 @@ var Header = ({
2406
2460
  isSidebarOpen,
2407
2461
  toggleSidebar
2408
2462
  } = useLayout();
2409
- const sidebarButton = React4.useMemo(() => {
2463
+ const sidebarButton = React5.useMemo(() => {
2410
2464
  if (!showSidebarButton) {
2411
2465
  return null;
2412
2466
  }
2413
- return /* @__PURE__ */jsx5(IconButton, {
2467
+ return /* @__PURE__ */jsx5(IconButton2, {
2414
2468
  "aria-label": isSidebarOpen ? "Close sidebar" : "Open sidebar",
2415
2469
  "aria-expanded": isSidebarOpen,
2416
2470
  "aria-controls": "sidebar",
@@ -2425,13 +2479,13 @@ var Header = ({
2425
2479
  })
2426
2480
  });
2427
2481
  }, [isSidebarOpen, showSidebarButton, toggleSidebar]);
2428
- const memoizedSidebarSlot = React4.useMemo(() => {
2482
+ const memoizedSidebarSlot = React5.useMemo(() => {
2429
2483
  if (!sidebarSlot) {
2430
2484
  return /* @__PURE__ */jsx5(Fragment2, {
2431
2485
  children: sidebarButton
2432
2486
  });
2433
2487
  }
2434
- return /* @__PURE__ */jsxs(Flex, {
2488
+ return /* @__PURE__ */jsxs2(Flex2, {
2435
2489
  sx: {
2436
2490
  minWidth: SIDEBAR_WIDTH,
2437
2491
  width: SIDEBAR_WIDTH,
@@ -2444,7 +2498,7 @@ var Header = ({
2444
2498
  children: [sidebarButton, sidebarSlot]
2445
2499
  });
2446
2500
  }, [sidebarButton, sidebarSlot]);
2447
- return /* @__PURE__ */jsxs(Flex, {
2501
+ return /* @__PURE__ */jsxs2(Flex2, {
2448
2502
  variant: "layout.header",
2449
2503
  ...boxProps,
2450
2504
  as: "header",
@@ -2507,10 +2561,10 @@ Layout.Footer = Footer;
2507
2561
  Layout.Container = Container;
2508
2562
 
2509
2563
  // src/components/SidebarCollapseLayout.tsx
2510
- import { Flex as Flex2, Stack } from "@ttoss/ui";
2564
+ import { Flex as Flex3, Stack } from "@ttoss/ui";
2511
2565
 
2512
2566
  // src/getSemanticElements.ts
2513
- import * as React5 from "react";
2567
+ import * as React6 from "react";
2514
2568
  var semanticComponents = {
2515
2569
  Header: "header",
2516
2570
  Sidebar: "sidebar",
@@ -2521,7 +2575,7 @@ var getSematicElements = ({
2521
2575
  children
2522
2576
  }) => {
2523
2577
  const semanticElements = {};
2524
- React5.Children.forEach(children, child => {
2578
+ React6.Children.forEach(children, child => {
2525
2579
  const displayName = child?.type?.displayName;
2526
2580
  if (!displayName) {
2527
2581
  return;
@@ -2534,7 +2588,7 @@ var getSematicElements = ({
2534
2588
  };
2535
2589
 
2536
2590
  // src/components/SidebarCollapseLayout.tsx
2537
- import { jsx as jsx8, jsxs as jsxs2 } from "react/jsx-runtime";
2591
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
2538
2592
  var SidebarCollapseLayout = ({
2539
2593
  children,
2540
2594
  ...props
@@ -2547,7 +2601,7 @@ var SidebarCollapseLayout = ({
2547
2601
  children
2548
2602
  });
2549
2603
  return /* @__PURE__ */jsx8(LayoutProvider, {
2550
- children: /* @__PURE__ */jsxs2(Stack, {
2604
+ children: /* @__PURE__ */jsxs3(Stack, {
2551
2605
  ...props,
2552
2606
  sx: {
2553
2607
  height: ["100vh"],
@@ -2555,12 +2609,12 @@ var SidebarCollapseLayout = ({
2555
2609
  overflow: "hidden",
2556
2610
  ...props.sx
2557
2611
  },
2558
- children: [header, /* @__PURE__ */jsxs2(Flex2, {
2612
+ children: [header, /* @__PURE__ */jsxs3(Flex3, {
2559
2613
  sx: {
2560
2614
  width: "full",
2561
2615
  flex: 1,
2562
2616
  overflow: "hidden",
2563
- flexDirection: ["column", "row", "row"]
2617
+ flexDirection: ["row"]
2564
2618
  },
2565
2619
  children: [sidebar, main]
2566
2620
  })]
@@ -2570,7 +2624,7 @@ var SidebarCollapseLayout = ({
2570
2624
 
2571
2625
  // src/components/StackedLayout.tsx
2572
2626
  import { Stack as Stack2 } from "@ttoss/ui";
2573
- import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
2627
+ import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
2574
2628
  var StackedLayout = ({
2575
2629
  children,
2576
2630
  ...props
@@ -2583,13 +2637,13 @@ var StackedLayout = ({
2583
2637
  children
2584
2638
  });
2585
2639
  return /* @__PURE__ */jsx9(LayoutProvider, {
2586
- children: /* @__PURE__ */jsxs3(Stack2, {
2640
+ children: /* @__PURE__ */jsxs4(Stack2, {
2587
2641
  ...props,
2588
2642
  children: [header, main, footer]
2589
2643
  })
2590
2644
  });
2591
2645
  };
2592
- export { Layout, SidebarCollapseLayout, StackedLayout };
2646
+ export { Layout, SidebarCollapseLayout, StackedLayout, useIsDesktop };
2593
2647
  /*! Bundled license information:
2594
2648
 
2595
2649
  iconify-icon/dist/iconify-icon.mjs:
package/dist/index.d.ts CHANGED
@@ -12,7 +12,10 @@ declare const Layout: {
12
12
  displayName: string;
13
13
  };
14
14
  Sidebar: {
15
- (props: BoxProps): react_jsx_runtime.JSX.Element;
15
+ ({ drawerSlot, showSidebarButtonInDrawer, children, ...boxProps }: BoxProps & {
16
+ showSidebarButtonInDrawer?: boolean;
17
+ drawerSlot?: React.ReactNode;
18
+ }): react_jsx_runtime.JSX.Element;
16
19
  displayName: string;
17
20
  };
18
21
  Main: {
@@ -30,4 +33,8 @@ declare const SidebarCollapseLayout: ({ children, ...props }: React.PropsWithChi
30
33
 
31
34
  declare const StackedLayout: ({ children, ...props }: react.PropsWithChildren<StackProps>) => react_jsx_runtime.JSX.Element;
32
35
 
33
- export { Layout, SidebarCollapseLayout, StackedLayout };
36
+ declare const useIsDesktop: () => {
37
+ isDesktop: boolean;
38
+ };
39
+
40
+ export { Layout, SidebarCollapseLayout, StackedLayout, useIsDesktop };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/layouts",
3
- "version": "0.4.15",
3
+ "version": "0.4.16",
4
4
  "description": "Layout components for React",
5
5
  "license": "MIT",
6
6
  "author": "ttoss",
@@ -25,7 +25,7 @@
25
25
  "sideEffects": false,
26
26
  "peerDependencies": {
27
27
  "react": ">=16.8.0",
28
- "@ttoss/components": "^2.2.7",
28
+ "@ttoss/components": "^2.2.8",
29
29
  "@ttoss/ui": "^5.5.5"
30
30
  },
31
31
  "devDependencies": {
@@ -34,11 +34,11 @@
34
34
  "jest": "^29.7.0",
35
35
  "react": "^19.0.0",
36
36
  "tsup": "^8.3.5",
37
- "@ttoss/components": "^2.2.7",
37
+ "@ttoss/components": "^2.2.8",
38
38
  "@ttoss/config": "^1.35.2",
39
- "@ttoss/react-icons": "^0.4.9",
40
39
  "@ttoss/test-utils": "^2.1.22",
41
- "@ttoss/ui": "^5.5.5"
40
+ "@ttoss/ui": "^5.5.5",
41
+ "@ttoss/react-icons": "^0.4.9"
42
42
  },
43
43
  "keywords": [
44
44
  "React"