@dxos/react-ui 0.4.5-main.623c49f → 0.4.5-main.8a5190e
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/lib/browser/index.mjs +31 -7
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/Main/Main.d.ts +4 -2
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/components/Main/Main.tsx +38 -3
|
@@ -1250,7 +1250,7 @@ import { Root as DialogRoot2, DialogContent as DialogContent2 } from "@radix-ui/
|
|
|
1250
1250
|
import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
|
|
1251
1251
|
import { Slot as Slot9 } from "@radix-ui/react-slot";
|
|
1252
1252
|
import { useControllableState as useControllableState2 } from "@radix-ui/react-use-controllable-state";
|
|
1253
|
-
import React19, { forwardRef as forwardRef16, useCallback as useCallback3, useRef } from "react";
|
|
1253
|
+
import React19, { forwardRef as forwardRef16, useCallback as useCallback3, useEffect as useEffect4, useRef, useState as useState4 } from "react";
|
|
1254
1254
|
import { useMediaQuery, useForwardedRef } from "@dxos/react-hooks";
|
|
1255
1255
|
|
|
1256
1256
|
// packages/ui/react-ui/src/components/Main/useSwipeToDismiss.ts
|
|
@@ -1357,6 +1357,7 @@ var COMPLEMENTARY_SIDEBAR_NAME = "ComplementarySidebar";
|
|
|
1357
1357
|
var MAIN_NAME = "Main";
|
|
1358
1358
|
var GENERIC_CONSUMER_NAME = "GenericConsumer";
|
|
1359
1359
|
var [MainProvider, useMainContext] = createContext8(MAIN_NAME, {
|
|
1360
|
+
resizing: false,
|
|
1360
1361
|
navigationSidebarOpen: false,
|
|
1361
1362
|
setNavigationSidebarOpen: (nextOpen) => {
|
|
1362
1363
|
console.warn("Attempt to set sidebar state without initializing `MainRoot`");
|
|
@@ -1395,6 +1396,7 @@ var useSidebars = (consumerName = GENERIC_CONSUMER_NAME) => {
|
|
|
1395
1396
|
])
|
|
1396
1397
|
};
|
|
1397
1398
|
};
|
|
1399
|
+
var resizeDebounce = 3e3;
|
|
1398
1400
|
var MainRoot = ({ navigationSidebarOpen: propsNavigationSidebarOpen, defaultNavigationSidebarOpen, onNavigationSidebarOpenChange, complementarySidebarOpen: propsComplementarySidebarOpen, defaultComplementarySidebarOpen, onComplementarySidebarOpenChange, children, ...props }) => {
|
|
1399
1401
|
const [isLg] = useMediaQuery("lg", {
|
|
1400
1402
|
ssr: false
|
|
@@ -1409,19 +1411,38 @@ var MainRoot = ({ navigationSidebarOpen: propsNavigationSidebarOpen, defaultNavi
|
|
|
1409
1411
|
defaultProp: defaultComplementarySidebarOpen,
|
|
1410
1412
|
onChange: onComplementarySidebarOpenChange
|
|
1411
1413
|
});
|
|
1414
|
+
const [resizing, setResizing] = useState4(false);
|
|
1415
|
+
const resizeInterval = useRef(null);
|
|
1416
|
+
const handleResize = useCallback3(() => {
|
|
1417
|
+
setResizing(true);
|
|
1418
|
+
if (resizeInterval.current) {
|
|
1419
|
+
clearTimeout(resizeInterval.current);
|
|
1420
|
+
}
|
|
1421
|
+
resizeInterval.current = setTimeout(() => {
|
|
1422
|
+
setResizing(false);
|
|
1423
|
+
resizeInterval.current = null;
|
|
1424
|
+
}, resizeDebounce);
|
|
1425
|
+
}, []);
|
|
1426
|
+
useEffect4(() => {
|
|
1427
|
+
window.addEventListener("resize", handleResize);
|
|
1428
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
1429
|
+
}, [
|
|
1430
|
+
handleResize
|
|
1431
|
+
]);
|
|
1412
1432
|
return /* @__PURE__ */ React19.createElement(MainProvider, {
|
|
1413
1433
|
...props,
|
|
1414
1434
|
navigationSidebarOpen,
|
|
1415
1435
|
setNavigationSidebarOpen,
|
|
1416
1436
|
complementarySidebarOpen,
|
|
1417
|
-
setComplementarySidebarOpen
|
|
1437
|
+
setComplementarySidebarOpen,
|
|
1438
|
+
resizing
|
|
1418
1439
|
}, children);
|
|
1419
1440
|
};
|
|
1420
1441
|
MainRoot.displayName = MAIN_ROOT_NAME;
|
|
1421
1442
|
var handleOpenAutoFocus = (event) => {
|
|
1422
1443
|
!document.body.hasAttribute("data-is-keyboard") && event.preventDefault();
|
|
1423
1444
|
};
|
|
1424
|
-
var MainSidebar = /* @__PURE__ */ forwardRef16(({ classNames, children, swipeToDismiss, onOpenAutoFocus, open, setOpen, side, ...props }, forwardedRef) => {
|
|
1445
|
+
var MainSidebar = /* @__PURE__ */ forwardRef16(({ classNames, children, swipeToDismiss, onOpenAutoFocus, open, resizing, setOpen, side, ...props }, forwardedRef) => {
|
|
1425
1446
|
const [isLg] = useMediaQuery("lg", {
|
|
1426
1447
|
ssr: false
|
|
1427
1448
|
});
|
|
@@ -1444,6 +1465,7 @@ var MainSidebar = /* @__PURE__ */ forwardRef16(({ classNames, children, swipeToD
|
|
|
1444
1465
|
...props,
|
|
1445
1466
|
"data-side": side === "inline-end" ? "ie" : "is",
|
|
1446
1467
|
"data-state": open ? "open" : "closed",
|
|
1468
|
+
"data-resizing": resizing ? "true" : "false",
|
|
1447
1469
|
className: tx("main.sidebar", "main__sidebar", {}, classNames),
|
|
1448
1470
|
...!open && {
|
|
1449
1471
|
inert: "true"
|
|
@@ -1454,22 +1476,24 @@ var MainSidebar = /* @__PURE__ */ forwardRef16(({ classNames, children, swipeToD
|
|
|
1454
1476
|
}, children)));
|
|
1455
1477
|
});
|
|
1456
1478
|
var MainNavigationSidebar = /* @__PURE__ */ forwardRef16((props, forwardedRef) => {
|
|
1457
|
-
const { navigationSidebarOpen, setNavigationSidebarOpen } = useMainContext(NAVIGATION_SIDEBAR_NAME);
|
|
1479
|
+
const { navigationSidebarOpen, setNavigationSidebarOpen, resizing } = useMainContext(NAVIGATION_SIDEBAR_NAME);
|
|
1458
1480
|
return /* @__PURE__ */ React19.createElement(MainSidebar, {
|
|
1459
1481
|
...props,
|
|
1460
1482
|
open: navigationSidebarOpen,
|
|
1461
1483
|
setOpen: setNavigationSidebarOpen,
|
|
1484
|
+
resizing,
|
|
1462
1485
|
side: "inline-start",
|
|
1463
1486
|
ref: forwardedRef
|
|
1464
1487
|
});
|
|
1465
1488
|
});
|
|
1466
1489
|
MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
|
|
1467
1490
|
var MainComplementarySidebar = /* @__PURE__ */ forwardRef16((props, forwardedRef) => {
|
|
1468
|
-
const { complementarySidebarOpen, setComplementarySidebarOpen } = useMainContext(COMPLEMENTARY_SIDEBAR_NAME);
|
|
1491
|
+
const { complementarySidebarOpen, setComplementarySidebarOpen, resizing } = useMainContext(COMPLEMENTARY_SIDEBAR_NAME);
|
|
1469
1492
|
return /* @__PURE__ */ React19.createElement(MainSidebar, {
|
|
1470
1493
|
...props,
|
|
1471
1494
|
open: complementarySidebarOpen,
|
|
1472
1495
|
setOpen: setComplementarySidebarOpen,
|
|
1496
|
+
resizing,
|
|
1473
1497
|
side: "inline-end",
|
|
1474
1498
|
ref: forwardedRef
|
|
1475
1499
|
});
|
|
@@ -2049,7 +2073,7 @@ var Tooltip = {
|
|
|
2049
2073
|
|
|
2050
2074
|
// packages/ui/react-ui/src/components/ThemeProvider/ThemeProvider.tsx
|
|
2051
2075
|
import { createKeyborg } from "keyborg";
|
|
2052
|
-
import React30, { createContext as createContext10, useEffect as
|
|
2076
|
+
import React30, { createContext as createContext10, useEffect as useEffect5 } from "react";
|
|
2053
2077
|
|
|
2054
2078
|
// packages/ui/react-ui/src/util/hasIosKeyboard.ts
|
|
2055
2079
|
var hasIosKeyboard = () => {
|
|
@@ -2070,7 +2094,7 @@ var handleInputModalityChange = (isUsingKeyboard) => {
|
|
|
2070
2094
|
}
|
|
2071
2095
|
};
|
|
2072
2096
|
var ThemeProvider = ({ children, fallback = null, resourceExtensions, appNs, tx = (_path, defaultClassName, _styleProps, ..._options) => defaultClassName, themeMode = "dark", rootElevation = "base", rootDensity = "coarse" }) => {
|
|
2073
|
-
|
|
2097
|
+
useEffect5(() => {
|
|
2074
2098
|
if (document.defaultView) {
|
|
2075
2099
|
const kb = createKeyborg(document.defaultView);
|
|
2076
2100
|
kb.subscribe(handleInputModalityChange);
|