@ttoss/layouts 0.4.14 → 0.4.15
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 +76 -24
- package/package.json +6 -4
package/dist/esm/index.js
CHANGED
|
@@ -2280,6 +2280,18 @@ import * as React4 from "react";
|
|
|
2280
2280
|
|
|
2281
2281
|
// src/components/LayoutProvider.tsx
|
|
2282
2282
|
import * as React3 from "react";
|
|
2283
|
+
|
|
2284
|
+
// src/useIsDesktop.ts
|
|
2285
|
+
import { useBreakpointIndex } from "@ttoss/ui";
|
|
2286
|
+
var useIsDesktop = () => {
|
|
2287
|
+
const breakpointIndex = useBreakpointIndex();
|
|
2288
|
+
const isDesktop = breakpointIndex >= 1;
|
|
2289
|
+
return {
|
|
2290
|
+
isDesktop
|
|
2291
|
+
};
|
|
2292
|
+
};
|
|
2293
|
+
|
|
2294
|
+
// src/components/LayoutProvider.tsx
|
|
2283
2295
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
2284
2296
|
var LayoutContext = React3.createContext({
|
|
2285
2297
|
isSidebarOpen: true,
|
|
@@ -2289,6 +2301,14 @@ var LayoutProvider = ({
|
|
|
2289
2301
|
children
|
|
2290
2302
|
}) => {
|
|
2291
2303
|
const [isSidebarOpen, setIsSidebarOpen] = React3.useState(true);
|
|
2304
|
+
const {
|
|
2305
|
+
isDesktop
|
|
2306
|
+
} = useIsDesktop();
|
|
2307
|
+
React3.useEffect(() => {
|
|
2308
|
+
if (!isDesktop) {
|
|
2309
|
+
setIsSidebarOpen(false);
|
|
2310
|
+
}
|
|
2311
|
+
}, [isDesktop]);
|
|
2292
2312
|
const toggleSidebar = () => {
|
|
2293
2313
|
setIsSidebarOpen(prev => {
|
|
2294
2314
|
return !prev;
|
|
@@ -2311,37 +2331,67 @@ var useLayout = () => {
|
|
|
2311
2331
|
};
|
|
2312
2332
|
|
|
2313
2333
|
// src/components/Sidebar.tsx
|
|
2334
|
+
import { Drawer } from "@ttoss/components/Drawer";
|
|
2314
2335
|
import { Box as Box2 } from "@ttoss/ui";
|
|
2315
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
2336
|
+
import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
|
|
2316
2337
|
var SIDEBAR_WIDTH = "2xs";
|
|
2317
2338
|
var Sidebar = props => {
|
|
2318
2339
|
const {
|
|
2319
|
-
isSidebarOpen
|
|
2340
|
+
isSidebarOpen,
|
|
2341
|
+
toggleSidebar
|
|
2320
2342
|
} = useLayout();
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2343
|
+
const {
|
|
2344
|
+
isDesktop
|
|
2345
|
+
} = useIsDesktop();
|
|
2346
|
+
return /* @__PURE__ */jsx4(Fragment, {
|
|
2347
|
+
children: isDesktop ? /* @__PURE__ */jsx4(Box2, {
|
|
2348
|
+
role: "complementary",
|
|
2349
|
+
"aria-label": "Sidebar",
|
|
2350
|
+
"aria-hidden": !isSidebarOpen,
|
|
2351
|
+
sx: {
|
|
2352
|
+
position: "relative",
|
|
2353
|
+
zIndex: "dropdown",
|
|
2354
|
+
height: "full",
|
|
2355
|
+
minHeight: isSidebarOpen ? "full" : "0",
|
|
2356
|
+
width: isSidebarOpen ? SIDEBAR_WIDTH : "0",
|
|
2357
|
+
minWidth: isSidebarOpen ? SIDEBAR_WIDTH : "0",
|
|
2358
|
+
opacity: isSidebarOpen ? 1 : 0,
|
|
2359
|
+
transition: "width 0.5s ease, opacity 0.5s ease",
|
|
2360
|
+
borderRight: isSidebarOpen ? "sm" : "none",
|
|
2361
|
+
borderColor: "display.border.muted.default",
|
|
2362
|
+
backgroundColor: "navigation.background.muted.default",
|
|
2363
|
+
paddingX: isSidebarOpen ? "3" : "0",
|
|
2364
|
+
paddingY: isSidebarOpen ? "10" : "0",
|
|
2365
|
+
...props.sx
|
|
2366
|
+
},
|
|
2367
|
+
children: isSidebarOpen ? props.children : null
|
|
2368
|
+
}) : /* @__PURE__ */jsx4(Box2, {
|
|
2369
|
+
role: "complementary",
|
|
2370
|
+
"aria-label": "Sidebar",
|
|
2371
|
+
"aria-hidden": !isSidebarOpen,
|
|
2372
|
+
sx: {
|
|
2373
|
+
border: "none",
|
|
2374
|
+
width: "full",
|
|
2375
|
+
...props.sx
|
|
2376
|
+
},
|
|
2377
|
+
onClick: () => {
|
|
2378
|
+
if (isSidebarOpen) {
|
|
2379
|
+
toggleSidebar();
|
|
2380
|
+
}
|
|
2381
|
+
},
|
|
2382
|
+
children: /* @__PURE__ */jsx4(Drawer, {
|
|
2383
|
+
open: isSidebarOpen,
|
|
2384
|
+
direction: "left",
|
|
2385
|
+
size: "min",
|
|
2386
|
+
children: isSidebarOpen ? props.children : null
|
|
2387
|
+
})
|
|
2388
|
+
})
|
|
2339
2389
|
});
|
|
2340
2390
|
};
|
|
2341
2391
|
Sidebar.displayName = "Sidebar";
|
|
2342
2392
|
|
|
2343
2393
|
// src/components/Header.tsx
|
|
2344
|
-
import { Fragment, jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
2394
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
2345
2395
|
var paddingSx = {
|
|
2346
2396
|
paddingX: "4",
|
|
2347
2397
|
paddingY: "3"
|
|
@@ -2377,7 +2427,7 @@ var Header = ({
|
|
|
2377
2427
|
}, [isSidebarOpen, showSidebarButton, toggleSidebar]);
|
|
2378
2428
|
const memoizedSidebarSlot = React4.useMemo(() => {
|
|
2379
2429
|
if (!sidebarSlot) {
|
|
2380
|
-
return /* @__PURE__ */jsx5(
|
|
2430
|
+
return /* @__PURE__ */jsx5(Fragment2, {
|
|
2381
2431
|
children: sidebarButton
|
|
2382
2432
|
});
|
|
2383
2433
|
}
|
|
@@ -2404,6 +2454,7 @@ var Header = ({
|
|
|
2404
2454
|
alignItems: "center",
|
|
2405
2455
|
borderBottom: "sm",
|
|
2406
2456
|
borderColor: "display.border.muted.default",
|
|
2457
|
+
backgroundColor: "navigation.background.primary.default",
|
|
2407
2458
|
...(sidebarSlot ? {} : paddingSx),
|
|
2408
2459
|
...boxProps.sx
|
|
2409
2460
|
},
|
|
@@ -2499,7 +2550,7 @@ var SidebarCollapseLayout = ({
|
|
|
2499
2550
|
children: /* @__PURE__ */jsxs2(Stack, {
|
|
2500
2551
|
...props,
|
|
2501
2552
|
sx: {
|
|
2502
|
-
height: ["
|
|
2553
|
+
height: ["100vh"],
|
|
2503
2554
|
width: "full",
|
|
2504
2555
|
overflow: "hidden",
|
|
2505
2556
|
...props.sx
|
|
@@ -2508,7 +2559,8 @@ var SidebarCollapseLayout = ({
|
|
|
2508
2559
|
sx: {
|
|
2509
2560
|
width: "full",
|
|
2510
2561
|
flex: 1,
|
|
2511
|
-
overflow: "hidden"
|
|
2562
|
+
overflow: "hidden",
|
|
2563
|
+
flexDirection: ["column", "row", "row"]
|
|
2512
2564
|
},
|
|
2513
2565
|
children: [sidebar, main]
|
|
2514
2566
|
})]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/layouts",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"description": "Layout components for React",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": ">=16.8.0",
|
|
28
|
-
"@ttoss/
|
|
28
|
+
"@ttoss/components": "^2.2.7",
|
|
29
|
+
"@ttoss/ui": "^5.5.5"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@types/jest": "^29.5.14",
|
|
@@ -33,10 +34,11 @@
|
|
|
33
34
|
"jest": "^29.7.0",
|
|
34
35
|
"react": "^19.0.0",
|
|
35
36
|
"tsup": "^8.3.5",
|
|
36
|
-
"@ttoss/
|
|
37
|
+
"@ttoss/components": "^2.2.7",
|
|
37
38
|
"@ttoss/config": "^1.35.2",
|
|
39
|
+
"@ttoss/react-icons": "^0.4.9",
|
|
38
40
|
"@ttoss/test-utils": "^2.1.22",
|
|
39
|
-
"@ttoss/ui": "^5.5.
|
|
41
|
+
"@ttoss/ui": "^5.5.5"
|
|
40
42
|
},
|
|
41
43
|
"keywords": [
|
|
42
44
|
"React"
|