@ttoss/layouts 0.4.15 → 0.4.17

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,48 @@ 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
+ width: "full",
2379
+ paddingY: "3",
2380
+ borderBottom: "sm",
2381
+ borderColor: "display.border.muted.default",
2382
+ alignItems: "center",
2383
+ gap: "2"
2384
+ },
2385
+ children: [sidebarButtonInDrawer, /* @__PURE__ */jsx4(Flex, {
2386
+ sx: {
2387
+ minWidth: SIDEBAR_WIDTH,
2388
+ width: SIDEBAR_WIDTH
2389
+ },
2390
+ children: drawerSlot
2391
+ })]
2392
+ });
2393
+ }, [drawerSlot, sidebarButtonInDrawer]);
2346
2394
  return /* @__PURE__ */jsx4(Fragment, {
2347
2395
  children: isDesktop ? /* @__PURE__ */jsx4(Box2, {
2348
2396
  role: "complementary",
@@ -2350,7 +2398,7 @@ var Sidebar = props => {
2350
2398
  "aria-hidden": !isSidebarOpen,
2351
2399
  sx: {
2352
2400
  position: "relative",
2353
- zIndex: "dropdown",
2401
+ zIndex: "overlay",
2354
2402
  height: "full",
2355
2403
  minHeight: isSidebarOpen ? "full" : "0",
2356
2404
  width: isSidebarOpen ? SIDEBAR_WIDTH : "0",
@@ -2360,19 +2408,23 @@ var Sidebar = props => {
2360
2408
  borderRight: isSidebarOpen ? "sm" : "none",
2361
2409
  borderColor: "display.border.muted.default",
2362
2410
  backgroundColor: "navigation.background.muted.default",
2363
- paddingX: isSidebarOpen ? "3" : "0",
2364
- paddingY: isSidebarOpen ? "10" : "0",
2365
- ...props.sx
2411
+ paddingX: isSidebarOpen ? "6" : "0",
2412
+ paddingY: isSidebarOpen ? "6" : "0",
2413
+ overflowY: "auto",
2414
+ ...boxProps.sx
2366
2415
  },
2367
- children: isSidebarOpen ? props.children : null
2416
+ children: isSidebarOpen ? children : null
2368
2417
  }) : /* @__PURE__ */jsx4(Box2, {
2369
2418
  role: "complementary",
2370
2419
  "aria-label": "Sidebar",
2371
2420
  "aria-hidden": !isSidebarOpen,
2372
2421
  sx: {
2422
+ position: "fixed",
2423
+ zIndex: "overlay",
2373
2424
  border: "none",
2374
- width: "full",
2375
- ...props.sx
2425
+ width: isSidebarOpen ? "full" : "0",
2426
+ height: isSidebarOpen ? "full" : "0",
2427
+ ...boxProps.sx
2376
2428
  },
2377
2429
  onClick: () => {
2378
2430
  if (isSidebarOpen) {
@@ -2382,8 +2434,17 @@ var Sidebar = props => {
2382
2434
  children: /* @__PURE__ */jsx4(Drawer, {
2383
2435
  open: isSidebarOpen,
2384
2436
  direction: "left",
2385
- size: "min",
2386
- children: isSidebarOpen ? props.children : null
2437
+ size: "100%",
2438
+ enableOverlay: false,
2439
+ children: /* @__PURE__ */jsxs(Flex, {
2440
+ sx: {
2441
+ width: "full",
2442
+ height: "full",
2443
+ gap: "6",
2444
+ flexDirection: "column"
2445
+ },
2446
+ children: [memoizedDrawerSlot, isSidebarOpen ? children : null]
2447
+ })
2387
2448
  })
2388
2449
  })
2389
2450
  });
@@ -2391,7 +2452,7 @@ var Sidebar = props => {
2391
2452
  Sidebar.displayName = "Sidebar";
2392
2453
 
2393
2454
  // src/components/Header.tsx
2394
- import { Fragment as Fragment2, jsx as jsx5, jsxs } from "react/jsx-runtime";
2455
+ import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
2395
2456
  var paddingSx = {
2396
2457
  paddingX: "4",
2397
2458
  paddingY: "3"
@@ -2406,11 +2467,11 @@ var Header = ({
2406
2467
  isSidebarOpen,
2407
2468
  toggleSidebar
2408
2469
  } = useLayout();
2409
- const sidebarButton = React4.useMemo(() => {
2470
+ const sidebarButton = React5.useMemo(() => {
2410
2471
  if (!showSidebarButton) {
2411
2472
  return null;
2412
2473
  }
2413
- return /* @__PURE__ */jsx5(IconButton, {
2474
+ return /* @__PURE__ */jsx5(IconButton2, {
2414
2475
  "aria-label": isSidebarOpen ? "Close sidebar" : "Open sidebar",
2415
2476
  "aria-expanded": isSidebarOpen,
2416
2477
  "aria-controls": "sidebar",
@@ -2425,13 +2486,13 @@ var Header = ({
2425
2486
  })
2426
2487
  });
2427
2488
  }, [isSidebarOpen, showSidebarButton, toggleSidebar]);
2428
- const memoizedSidebarSlot = React4.useMemo(() => {
2489
+ const memoizedSidebarSlot = React5.useMemo(() => {
2429
2490
  if (!sidebarSlot) {
2430
2491
  return /* @__PURE__ */jsx5(Fragment2, {
2431
2492
  children: sidebarButton
2432
2493
  });
2433
2494
  }
2434
- return /* @__PURE__ */jsxs(Flex, {
2495
+ return /* @__PURE__ */jsxs2(Flex2, {
2435
2496
  sx: {
2436
2497
  minWidth: SIDEBAR_WIDTH,
2437
2498
  width: SIDEBAR_WIDTH,
@@ -2444,7 +2505,7 @@ var Header = ({
2444
2505
  children: [sidebarButton, sidebarSlot]
2445
2506
  });
2446
2507
  }, [sidebarButton, sidebarSlot]);
2447
- return /* @__PURE__ */jsxs(Flex, {
2508
+ return /* @__PURE__ */jsxs2(Flex2, {
2448
2509
  variant: "layout.header",
2449
2510
  ...boxProps,
2450
2511
  as: "header",
@@ -2507,10 +2568,10 @@ Layout.Footer = Footer;
2507
2568
  Layout.Container = Container;
2508
2569
 
2509
2570
  // src/components/SidebarCollapseLayout.tsx
2510
- import { Flex as Flex2, Stack } from "@ttoss/ui";
2571
+ import { Flex as Flex3, Stack } from "@ttoss/ui";
2511
2572
 
2512
2573
  // src/getSemanticElements.ts
2513
- import * as React5 from "react";
2574
+ import * as React6 from "react";
2514
2575
  var semanticComponents = {
2515
2576
  Header: "header",
2516
2577
  Sidebar: "sidebar",
@@ -2521,7 +2582,7 @@ var getSematicElements = ({
2521
2582
  children
2522
2583
  }) => {
2523
2584
  const semanticElements = {};
2524
- React5.Children.forEach(children, child => {
2585
+ React6.Children.forEach(children, child => {
2525
2586
  const displayName = child?.type?.displayName;
2526
2587
  if (!displayName) {
2527
2588
  return;
@@ -2534,7 +2595,7 @@ var getSematicElements = ({
2534
2595
  };
2535
2596
 
2536
2597
  // src/components/SidebarCollapseLayout.tsx
2537
- import { jsx as jsx8, jsxs as jsxs2 } from "react/jsx-runtime";
2598
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
2538
2599
  var SidebarCollapseLayout = ({
2539
2600
  children,
2540
2601
  ...props
@@ -2547,7 +2608,7 @@ var SidebarCollapseLayout = ({
2547
2608
  children
2548
2609
  });
2549
2610
  return /* @__PURE__ */jsx8(LayoutProvider, {
2550
- children: /* @__PURE__ */jsxs2(Stack, {
2611
+ children: /* @__PURE__ */jsxs3(Stack, {
2551
2612
  ...props,
2552
2613
  sx: {
2553
2614
  height: ["100vh"],
@@ -2555,12 +2616,12 @@ var SidebarCollapseLayout = ({
2555
2616
  overflow: "hidden",
2556
2617
  ...props.sx
2557
2618
  },
2558
- children: [header, /* @__PURE__ */jsxs2(Flex2, {
2619
+ children: [header, /* @__PURE__ */jsxs3(Flex3, {
2559
2620
  sx: {
2560
2621
  width: "full",
2561
2622
  flex: 1,
2562
2623
  overflow: "hidden",
2563
- flexDirection: ["column", "row", "row"]
2624
+ flexDirection: ["row"]
2564
2625
  },
2565
2626
  children: [sidebar, main]
2566
2627
  })]
@@ -2570,7 +2631,7 @@ var SidebarCollapseLayout = ({
2570
2631
 
2571
2632
  // src/components/StackedLayout.tsx
2572
2633
  import { Stack as Stack2 } from "@ttoss/ui";
2573
- import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
2634
+ import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
2574
2635
  var StackedLayout = ({
2575
2636
  children,
2576
2637
  ...props
@@ -2583,13 +2644,13 @@ var StackedLayout = ({
2583
2644
  children
2584
2645
  });
2585
2646
  return /* @__PURE__ */jsx9(LayoutProvider, {
2586
- children: /* @__PURE__ */jsxs3(Stack2, {
2647
+ children: /* @__PURE__ */jsxs4(Stack2, {
2587
2648
  ...props,
2588
2649
  children: [header, main, footer]
2589
2650
  })
2590
2651
  });
2591
2652
  };
2592
- export { Layout, SidebarCollapseLayout, StackedLayout };
2653
+ export { Layout, SidebarCollapseLayout, StackedLayout, useIsDesktop };
2593
2654
  /*! Bundled license information:
2594
2655
 
2595
2656
  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.17",
4
4
  "description": "Layout components for React",
5
5
  "license": "MIT",
6
6
  "author": "ttoss",
@@ -25,8 +25,8 @@
25
25
  "sideEffects": false,
26
26
  "peerDependencies": {
27
27
  "react": ">=16.8.0",
28
- "@ttoss/components": "^2.2.7",
29
- "@ttoss/ui": "^5.5.5"
28
+ "@ttoss/ui": "^5.5.5",
29
+ "@ttoss/components": "^2.2.9"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/jest": "^29.5.14",
@@ -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",
38
- "@ttoss/config": "^1.35.2",
39
37
  "@ttoss/react-icons": "^0.4.9",
40
38
  "@ttoss/test-utils": "^2.1.22",
41
- "@ttoss/ui": "^5.5.5"
39
+ "@ttoss/config": "^1.35.2",
40
+ "@ttoss/ui": "^5.5.5",
41
+ "@ttoss/components": "^2.2.9"
42
42
  },
43
43
  "keywords": [
44
44
  "React"