@dxos/react-ui 0.4.5-main.f8d6c4e → 0.4.5-next.ea4f804
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 +53 -23
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.d.ts +1 -1
- package/dist/types/src/components/Link/Link.d.ts +5 -4
- package/dist/types/src/components/Link/Link.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.d.ts +6 -2
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +1 -1
- package/package.json +8 -8
- package/src/components/Link/Link.tsx +12 -8
- package/src/components/Main/Main.tsx +62 -23
|
@@ -411,12 +411,14 @@ import React6, { forwardRef as forwardRef5 } from "react";
|
|
|
411
411
|
import { Primitive as Primitive3 } from "@radix-ui/react-primitive";
|
|
412
412
|
import { Slot as Slot3 } from "@radix-ui/react-slot";
|
|
413
413
|
import React5, { forwardRef as forwardRef4 } from "react";
|
|
414
|
-
var Link = /* @__PURE__ */ forwardRef4(({ asChild, classNames, ...props }, forwardedRef) => {
|
|
414
|
+
var Link = /* @__PURE__ */ forwardRef4(({ asChild, variant, classNames, ...props }, forwardedRef) => {
|
|
415
415
|
const { tx } = useThemeContext();
|
|
416
416
|
const Root3 = asChild ? Slot3 : Primitive3.a;
|
|
417
417
|
return /* @__PURE__ */ React5.createElement(Root3, {
|
|
418
418
|
...props,
|
|
419
|
-
className: tx("link.root", "link", {
|
|
419
|
+
className: tx("link.root", "link", {
|
|
420
|
+
variant
|
|
421
|
+
}, classNames),
|
|
420
422
|
ref: forwardedRef
|
|
421
423
|
});
|
|
422
424
|
});
|
|
@@ -1248,7 +1250,7 @@ import { Root as DialogRoot2, DialogContent as DialogContent2 } from "@radix-ui/
|
|
|
1248
1250
|
import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
|
|
1249
1251
|
import { Slot as Slot9 } from "@radix-ui/react-slot";
|
|
1250
1252
|
import { useControllableState as useControllableState2 } from "@radix-ui/react-use-controllable-state";
|
|
1251
|
-
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";
|
|
1252
1254
|
import { useMediaQuery, useForwardedRef } from "@dxos/react-hooks";
|
|
1253
1255
|
|
|
1254
1256
|
// packages/ui/react-ui/src/components/Main/useSwipeToDismiss.ts
|
|
@@ -1355,6 +1357,7 @@ var COMPLEMENTARY_SIDEBAR_NAME = "ComplementarySidebar";
|
|
|
1355
1357
|
var MAIN_NAME = "Main";
|
|
1356
1358
|
var GENERIC_CONSUMER_NAME = "GenericConsumer";
|
|
1357
1359
|
var [MainProvider, useMainContext] = createContext8(MAIN_NAME, {
|
|
1360
|
+
resizing: false,
|
|
1358
1361
|
navigationSidebarOpen: false,
|
|
1359
1362
|
setNavigationSidebarOpen: (nextOpen) => {
|
|
1360
1363
|
console.warn("Attempt to set sidebar state without initializing `MainRoot`");
|
|
@@ -1393,6 +1396,7 @@ var useSidebars = (consumerName = GENERIC_CONSUMER_NAME) => {
|
|
|
1393
1396
|
])
|
|
1394
1397
|
};
|
|
1395
1398
|
};
|
|
1399
|
+
var resizeDebounce = 3e3;
|
|
1396
1400
|
var MainRoot = ({ navigationSidebarOpen: propsNavigationSidebarOpen, defaultNavigationSidebarOpen, onNavigationSidebarOpenChange, complementarySidebarOpen: propsComplementarySidebarOpen, defaultComplementarySidebarOpen, onComplementarySidebarOpenChange, children, ...props }) => {
|
|
1397
1401
|
const [isLg] = useMediaQuery("lg", {
|
|
1398
1402
|
ssr: false
|
|
@@ -1407,19 +1411,38 @@ var MainRoot = ({ navigationSidebarOpen: propsNavigationSidebarOpen, defaultNavi
|
|
|
1407
1411
|
defaultProp: defaultComplementarySidebarOpen,
|
|
1408
1412
|
onChange: onComplementarySidebarOpenChange
|
|
1409
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
|
+
]);
|
|
1410
1432
|
return /* @__PURE__ */ React19.createElement(MainProvider, {
|
|
1411
1433
|
...props,
|
|
1412
1434
|
navigationSidebarOpen,
|
|
1413
1435
|
setNavigationSidebarOpen,
|
|
1414
1436
|
complementarySidebarOpen,
|
|
1415
|
-
setComplementarySidebarOpen
|
|
1437
|
+
setComplementarySidebarOpen,
|
|
1438
|
+
resizing
|
|
1416
1439
|
}, children);
|
|
1417
1440
|
};
|
|
1418
1441
|
MainRoot.displayName = MAIN_ROOT_NAME;
|
|
1419
1442
|
var handleOpenAutoFocus = (event) => {
|
|
1420
1443
|
!document.body.hasAttribute("data-is-keyboard") && event.preventDefault();
|
|
1421
1444
|
};
|
|
1422
|
-
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) => {
|
|
1423
1446
|
const [isLg] = useMediaQuery("lg", {
|
|
1424
1447
|
ssr: false
|
|
1425
1448
|
});
|
|
@@ -1440,11 +1463,10 @@ var MainSidebar = /* @__PURE__ */ forwardRef16(({ classNames, children, swipeToD
|
|
|
1440
1463
|
onOpenAutoFocus: onOpenAutoFocus ?? handleOpenAutoFocus
|
|
1441
1464
|
},
|
|
1442
1465
|
...props,
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
}, classNames),
|
|
1466
|
+
"data-side": side === "inline-end" ? "ie" : "is",
|
|
1467
|
+
"data-state": open ? "open" : "closed",
|
|
1468
|
+
"data-resizing": resizing ? "true" : "false",
|
|
1469
|
+
className: tx("main.sidebar", "main__sidebar", {}, classNames),
|
|
1448
1470
|
...!open && {
|
|
1449
1471
|
inert: "true"
|
|
1450
1472
|
},
|
|
@@ -1454,40 +1476,38 @@ 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
|
});
|
|
1476
1500
|
});
|
|
1477
1501
|
MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
|
|
1478
1502
|
var MainContent = /* @__PURE__ */ forwardRef16(({ asChild, classNames, bounce, children, ...props }, forwardedRef) => {
|
|
1479
|
-
const [isLg] = useMediaQuery("lg", {
|
|
1480
|
-
ssr: false
|
|
1481
|
-
});
|
|
1482
1503
|
const { navigationSidebarOpen, complementarySidebarOpen } = useMainContext(MAIN_NAME);
|
|
1483
1504
|
const { tx } = useThemeContext();
|
|
1484
1505
|
const Root3 = asChild ? Slot9 : "main";
|
|
1485
1506
|
return /* @__PURE__ */ React19.createElement(Root3, {
|
|
1486
1507
|
...props,
|
|
1508
|
+
"data-sidebar-inline-start-state": navigationSidebarOpen ? "open" : "closed",
|
|
1509
|
+
"data-sidebar-inline-end-state": complementarySidebarOpen ? "open" : "closed",
|
|
1487
1510
|
className: tx("main.content", "main", {
|
|
1488
|
-
isLg,
|
|
1489
|
-
inlineStartSidebarOpen: navigationSidebarOpen,
|
|
1490
|
-
inlineEndSidebarOpen: complementarySidebarOpen,
|
|
1491
1511
|
bounce
|
|
1492
1512
|
}, classNames),
|
|
1493
1513
|
ref: forwardedRef
|
|
@@ -1511,9 +1531,18 @@ var MainOverlay = /* @__PURE__ */ forwardRef16(({ classNames, ...props }, forwar
|
|
|
1511
1531
|
inlineStartSidebarOpen: navigationSidebarOpen,
|
|
1512
1532
|
inlineEndSidebarOpen: complementarySidebarOpen
|
|
1513
1533
|
}, classNames),
|
|
1514
|
-
"data-open":
|
|
1534
|
+
"data-state": navigationSidebarOpen || complementarySidebarOpen ? "open" : "closed",
|
|
1515
1535
|
"aria-hidden": "true",
|
|
1516
|
-
|
|
1536
|
+
ref: forwardedRef
|
|
1537
|
+
});
|
|
1538
|
+
});
|
|
1539
|
+
var MainNotch = /* @__PURE__ */ forwardRef16(({ classNames, ...props }, forwardedRef) => {
|
|
1540
|
+
const { tx } = useThemeContext();
|
|
1541
|
+
const { navigationSidebarOpen } = useMainContext(MAIN_NAME);
|
|
1542
|
+
return /* @__PURE__ */ React19.createElement("nav", {
|
|
1543
|
+
...props,
|
|
1544
|
+
"data-nav-sidebar-state": navigationSidebarOpen ? "open" : "closed",
|
|
1545
|
+
className: tx("main.notch", "main__notch", {}, classNames),
|
|
1517
1546
|
ref: forwardedRef
|
|
1518
1547
|
});
|
|
1519
1548
|
});
|
|
@@ -1522,7 +1551,8 @@ var Main = {
|
|
|
1522
1551
|
Content: MainContent,
|
|
1523
1552
|
Overlay: MainOverlay,
|
|
1524
1553
|
NavigationSidebar: MainNavigationSidebar,
|
|
1525
|
-
ComplementarySidebar: MainComplementarySidebar
|
|
1554
|
+
ComplementarySidebar: MainComplementarySidebar,
|
|
1555
|
+
Notch: MainNotch
|
|
1526
1556
|
};
|
|
1527
1557
|
|
|
1528
1558
|
// packages/ui/react-ui/src/components/Message/Message.tsx
|
|
@@ -2043,7 +2073,7 @@ var Tooltip = {
|
|
|
2043
2073
|
|
|
2044
2074
|
// packages/ui/react-ui/src/components/ThemeProvider/ThemeProvider.tsx
|
|
2045
2075
|
import { createKeyborg } from "keyborg";
|
|
2046
|
-
import React30, { createContext as createContext10, useEffect as
|
|
2076
|
+
import React30, { createContext as createContext10, useEffect as useEffect5 } from "react";
|
|
2047
2077
|
|
|
2048
2078
|
// packages/ui/react-ui/src/util/hasIosKeyboard.ts
|
|
2049
2079
|
var hasIosKeyboard = () => {
|
|
@@ -2064,7 +2094,7 @@ var handleInputModalityChange = (isUsingKeyboard) => {
|
|
|
2064
2094
|
}
|
|
2065
2095
|
};
|
|
2066
2096
|
var ThemeProvider = ({ children, fallback = null, resourceExtensions, appNs, tx = (_path, defaultClassName, _styleProps, ..._options) => defaultClassName, themeMode = "dark", rootElevation = "base", rootDensity = "coarse" }) => {
|
|
2067
|
-
|
|
2097
|
+
useEffect5(() => {
|
|
2068
2098
|
if (document.defaultView) {
|
|
2069
2099
|
const kb = createKeyborg(document.defaultView);
|
|
2070
2100
|
kb.subscribe(handleInputModalityChange);
|