@arbidocs/blocks 0.5.170 → 0.5.172
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/{ConnectedCallDock-2LQZTKQD.cjs → ConnectedCallDock-AQRVWENO.cjs} +4 -4
- package/dist/{ConnectedCallDock-2LQZTKQD.cjs.map → ConnectedCallDock-AQRVWENO.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-YZWAB7E5.cjs → ConnectedCallRoom-7M4YQ4KA.cjs} +4 -4
- package/dist/{ConnectedCallRoom-YZWAB7E5.cjs.map → ConnectedCallRoom-7M4YQ4KA.cjs.map} +1 -1
- package/dist/{ConnectedProductionSetDialog-CTJLD6RF.cjs → ConnectedProductionSetDialog-SHDI7KP6.cjs} +5 -5
- package/dist/{ConnectedProductionSetDialog-CTJLD6RF.cjs.map → ConnectedProductionSetDialog-SHDI7KP6.cjs.map} +1 -1
- package/dist/{FilesViewerDialog-HQFZEDSO.cjs → FilesViewerDialog-KD22ACKY.cjs} +9 -9
- package/dist/{FilesViewerDialog-HQFZEDSO.cjs.map → FilesViewerDialog-KD22ACKY.cjs.map} +1 -1
- package/dist/auth/index.cjs +12 -12
- package/dist/calls/connected/ConnectedConversationCallActions.js +6 -0
- package/dist/calls/connected/ConnectedConversationCallActions.js.map +2 -2
- package/dist/calls/connected/OwnedAgentCallButton.d.ts +4 -0
- package/dist/calls/connected/OwnedAgentCallButton.js +13 -0
- package/dist/calls/connected/OwnedAgentCallButton.js.map +7 -0
- package/dist/calls/index.cjs +22 -22
- package/dist/chat/index.cjs +5 -5
- package/dist/{chunk-3UCRJRNI.cjs → chunk-5OD6DRG7.cjs} +5 -5
- package/dist/{chunk-3UCRJRNI.cjs.map → chunk-5OD6DRG7.cjs.map} +1 -1
- package/dist/{chunk-WWCSRBNZ.cjs → chunk-A7MGQMOV.cjs} +13 -13
- package/dist/{chunk-WWCSRBNZ.cjs.map → chunk-A7MGQMOV.cjs.map} +1 -1
- package/dist/{chunk-O2NHBB3D.cjs → chunk-E23H6FJR.cjs} +4 -4
- package/dist/{chunk-O2NHBB3D.cjs.map → chunk-E23H6FJR.cjs.map} +1 -1
- package/dist/{chunk-2O772C6Y.cjs → chunk-ICZLFE26.cjs} +2 -2
- package/dist/{chunk-2O772C6Y.cjs.map → chunk-ICZLFE26.cjs.map} +1 -1
- package/dist/{chunk-WV3RNWAG.cjs → chunk-KQJUY2OE.cjs} +6 -3
- package/dist/chunk-KQJUY2OE.cjs.map +1 -0
- package/dist/{chunk-Q25CZLK6.cjs → chunk-N33U2SB5.cjs} +28 -4
- package/dist/chunk-N33U2SB5.cjs.map +1 -0
- package/dist/{chunk-IRUQZI6P.cjs → chunk-PIKTGP55.cjs} +3 -2
- package/dist/chunk-PIKTGP55.cjs.map +1 -0
- package/dist/{chunk-7QSZSGUQ.cjs → chunk-QSY2VW7V.cjs} +6 -6
- package/dist/{chunk-7QSZSGUQ.cjs.map → chunk-QSY2VW7V.cjs.map} +1 -1
- package/dist/{chunk-I6SINJQ2.cjs → chunk-RJMKTK4P.cjs} +13 -2
- package/dist/chunk-RJMKTK4P.cjs.map +1 -0
- package/dist/{chunk-6OVP3BUA.cjs → chunk-TV2HTJD6.cjs} +4 -4
- package/dist/{chunk-6OVP3BUA.cjs.map → chunk-TV2HTJD6.cjs.map} +1 -1
- package/dist/{chunk-LYYJDQW6.cjs → chunk-UTYEXDJK.cjs} +28 -28
- package/dist/{chunk-LYYJDQW6.cjs.map → chunk-UTYEXDJK.cjs.map} +1 -1
- package/dist/{chunk-QNNNANQS.cjs → chunk-YOTUWXOV.cjs} +11 -11
- package/dist/{chunk-QNNNANQS.cjs.map → chunk-YOTUWXOV.cjs.map} +1 -1
- package/dist/connect/index.cjs +192 -191
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/viewer.cjs +7 -7
- package/dist/connection/ConnectedAgentChatPanel.js +2 -0
- package/dist/connection/ConnectedAgentChatPanel.js.map +2 -2
- package/dist/connection/messenger/DmAgentProgress.js +1 -1
- package/dist/connection/messenger/DmAgentProgress.js.map +2 -2
- package/dist/databases/DatabaseTable.js +26 -2
- package/dist/databases/DatabaseTable.js.map +2 -2
- package/dist/databases/index.cjs +52 -52
- package/dist/embed/index.cjs +11 -11
- package/dist/index.cjs +94 -94
- package/dist/lib/entity-id.d.ts +1 -1
- package/dist/lib/entity-id.js +1 -0
- package/dist/lib/entity-id.js.map +2 -2
- package/dist/pages/index.cjs +3 -3
- package/dist/shell/index.cjs +21 -21
- package/dist/shell/use-sidebar-controller.js +4 -1
- package/dist/shell/use-sidebar-controller.js.map +2 -2
- package/dist/styles.css +1 -1
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/src/blocks.css +2 -0
- package/dist/chunk-I6SINJQ2.cjs.map +0 -1
- package/dist/chunk-IRUQZI6P.cjs.map +0 -1
- package/dist/chunk-Q25CZLK6.cjs.map +0 -1
- package/dist/chunk-WV3RNWAG.cjs.map +0 -1
package/dist/shell/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var chunkLIDXIX36_cjs = require('../chunk-LIDXIX36.cjs');
|
|
5
5
|
require('../chunk-34HQO4ZQ.cjs');
|
|
6
6
|
var chunkCT3SLXB7_cjs = require('../chunk-CT3SLXB7.cjs');
|
|
7
|
-
var
|
|
7
|
+
var chunkKQJUY2OE_cjs = require('../chunk-KQJUY2OE.cjs');
|
|
8
8
|
var chunk2KGU5G6Z_cjs = require('../chunk-2KGU5G6Z.cjs');
|
|
9
9
|
var chunk2RLA6QO2_cjs = require('../chunk-2RLA6QO2.cjs');
|
|
10
10
|
var chunkVDHBLDQC_cjs = require('../chunk-VDHBLDQC.cjs');
|
|
@@ -92,83 +92,83 @@ Object.defineProperty(exports, "Toaster", {
|
|
|
92
92
|
});
|
|
93
93
|
Object.defineProperty(exports, "ActionCluster", {
|
|
94
94
|
enumerable: true,
|
|
95
|
-
get: function () { return
|
|
95
|
+
get: function () { return chunkKQJUY2OE_cjs.ActionCluster; }
|
|
96
96
|
});
|
|
97
97
|
Object.defineProperty(exports, "AskField", {
|
|
98
98
|
enumerable: true,
|
|
99
|
-
get: function () { return
|
|
99
|
+
get: function () { return chunkKQJUY2OE_cjs.AskField; }
|
|
100
100
|
});
|
|
101
101
|
Object.defineProperty(exports, "AskRow", {
|
|
102
102
|
enumerable: true,
|
|
103
|
-
get: function () { return
|
|
103
|
+
get: function () { return chunkKQJUY2OE_cjs.AskRow; }
|
|
104
104
|
});
|
|
105
105
|
Object.defineProperty(exports, "AskTrigger", {
|
|
106
106
|
enumerable: true,
|
|
107
|
-
get: function () { return
|
|
107
|
+
get: function () { return chunkKQJUY2OE_cjs.AskTrigger; }
|
|
108
108
|
});
|
|
109
109
|
Object.defineProperty(exports, "DEFAULT_ASK_FIELD_LABELS", {
|
|
110
110
|
enumerable: true,
|
|
111
|
-
get: function () { return
|
|
111
|
+
get: function () { return chunkKQJUY2OE_cjs.DEFAULT_ASK_FIELD_LABELS; }
|
|
112
112
|
});
|
|
113
113
|
Object.defineProperty(exports, "DEFAULT_OFFLINE_PILL_LABELS", {
|
|
114
114
|
enumerable: true,
|
|
115
|
-
get: function () { return
|
|
115
|
+
get: function () { return chunkKQJUY2OE_cjs.DEFAULT_OFFLINE_PILL_LABELS; }
|
|
116
116
|
});
|
|
117
117
|
Object.defineProperty(exports, "DEFAULT_REMOTE_CONTROL_PILL_LABELS", {
|
|
118
118
|
enumerable: true,
|
|
119
|
-
get: function () { return
|
|
119
|
+
get: function () { return chunkKQJUY2OE_cjs.DEFAULT_REMOTE_CONTROL_PILL_LABELS; }
|
|
120
120
|
});
|
|
121
121
|
Object.defineProperty(exports, "DEFAULT_TIP_CARD_LABELS", {
|
|
122
122
|
enumerable: true,
|
|
123
|
-
get: function () { return
|
|
123
|
+
get: function () { return chunkKQJUY2OE_cjs.DEFAULT_TIP_CARD_LABELS; }
|
|
124
124
|
});
|
|
125
125
|
Object.defineProperty(exports, "DockZone", {
|
|
126
126
|
enumerable: true,
|
|
127
|
-
get: function () { return
|
|
127
|
+
get: function () { return chunkKQJUY2OE_cjs.DockZone; }
|
|
128
128
|
});
|
|
129
129
|
Object.defineProperty(exports, "OfflinePill", {
|
|
130
130
|
enumerable: true,
|
|
131
|
-
get: function () { return
|
|
131
|
+
get: function () { return chunkKQJUY2OE_cjs.OfflinePill; }
|
|
132
132
|
});
|
|
133
133
|
Object.defineProperty(exports, "RemoteControlPill", {
|
|
134
134
|
enumerable: true,
|
|
135
|
-
get: function () { return
|
|
135
|
+
get: function () { return chunkKQJUY2OE_cjs.RemoteControlPill; }
|
|
136
136
|
});
|
|
137
137
|
Object.defineProperty(exports, "ShellSidebar", {
|
|
138
138
|
enumerable: true,
|
|
139
|
-
get: function () { return
|
|
139
|
+
get: function () { return chunkKQJUY2OE_cjs.ShellSidebar; }
|
|
140
140
|
});
|
|
141
141
|
Object.defineProperty(exports, "SidebarRowAction", {
|
|
142
142
|
enumerable: true,
|
|
143
|
-
get: function () { return
|
|
143
|
+
get: function () { return chunkKQJUY2OE_cjs.SidebarRowAction; }
|
|
144
144
|
});
|
|
145
145
|
Object.defineProperty(exports, "StatusBadge", {
|
|
146
146
|
enumerable: true,
|
|
147
|
-
get: function () { return
|
|
147
|
+
get: function () { return chunkKQJUY2OE_cjs.StatusBadge; }
|
|
148
148
|
});
|
|
149
149
|
Object.defineProperty(exports, "StatusRow", {
|
|
150
150
|
enumerable: true,
|
|
151
|
-
get: function () { return
|
|
151
|
+
get: function () { return chunkKQJUY2OE_cjs.StatusRow; }
|
|
152
152
|
});
|
|
153
153
|
Object.defineProperty(exports, "TipCard", {
|
|
154
154
|
enumerable: true,
|
|
155
|
-
get: function () { return
|
|
155
|
+
get: function () { return chunkKQJUY2OE_cjs.TipCard; }
|
|
156
156
|
});
|
|
157
157
|
Object.defineProperty(exports, "resolveSidebarLayout", {
|
|
158
158
|
enumerable: true,
|
|
159
|
-
get: function () { return
|
|
159
|
+
get: function () { return chunkKQJUY2OE_cjs.resolveSidebarLayout; }
|
|
160
160
|
});
|
|
161
161
|
Object.defineProperty(exports, "useCloseOnEscape", {
|
|
162
162
|
enumerable: true,
|
|
163
|
-
get: function () { return
|
|
163
|
+
get: function () { return chunkKQJUY2OE_cjs.useCloseOnEscape; }
|
|
164
164
|
});
|
|
165
165
|
Object.defineProperty(exports, "useSidebarController", {
|
|
166
166
|
enumerable: true,
|
|
167
|
-
get: function () { return
|
|
167
|
+
get: function () { return chunkKQJUY2OE_cjs.useSidebarController; }
|
|
168
168
|
});
|
|
169
169
|
Object.defineProperty(exports, "useSidebarSettle", {
|
|
170
170
|
enumerable: true,
|
|
171
|
-
get: function () { return
|
|
171
|
+
get: function () { return chunkKQJUY2OE_cjs.useSidebarSettle; }
|
|
172
172
|
});
|
|
173
173
|
Object.defineProperty(exports, "PanelModeSwitcher", {
|
|
174
174
|
enumerable: true,
|
|
@@ -5,6 +5,9 @@ import { useCloseOnEscape } from "../lib/use-close-on-escape.js";
|
|
|
5
5
|
import { useIsNarrow, useIsPhone, useIsTouchScreen } from "../lib/use-media-query.js";
|
|
6
6
|
import { resolveSidebarLayout, useSidebarSettle } from "../lib/sidebar-mode.js";
|
|
7
7
|
const isMenuOpen = () => typeof document !== "undefined" && document.querySelector('[role="menu"][data-state="open"]') !== null;
|
|
8
|
+
const isOverlayOpen = () => typeof document !== "undefined" && document.querySelector(
|
|
9
|
+
'[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"], [role="menu"][data-state="open"]'
|
|
10
|
+
) !== null;
|
|
8
11
|
function useSidebarController(options = {}) {
|
|
9
12
|
const [storedPinned, setPinned] = useControllableState(
|
|
10
13
|
options.isPinned,
|
|
@@ -50,7 +53,7 @@ function useSidebarController(options = {}) {
|
|
|
50
53
|
const onPointerLeave = (event) => {
|
|
51
54
|
if (event.pointerType !== "mouse" && options.hoverExpansion !== "all") return;
|
|
52
55
|
isPointerOver.current = false;
|
|
53
|
-
if (!isSmallScreen) setHovering(false);
|
|
56
|
+
if (!isSmallScreen && !isOverlayOpen()) setHovering(false);
|
|
54
57
|
};
|
|
55
58
|
return {
|
|
56
59
|
layout,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/shell/use-sidebar-controller.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useRef, type PointerEvent } from 'react'\nimport { useControllableState } from '../lib/useControllableState'\nimport { useCloseOnEscape } from '../lib/use-close-on-escape'\nimport { useIsNarrow, useIsPhone, useIsTouchScreen } from '../lib/use-media-query'\nimport { resolveSidebarLayout, useSidebarSettle, type SidebarLayout } from '../lib/sidebar-mode'\nimport type { SidebarRootProps } from './Sidebar'\n\nexport interface UseSidebarControllerOptions {\n /** Pinned open (desktop). Controlled when set; otherwise kept here, seeded by `defaultPinned`. */\n isPinned?: boolean\n /** Default `true`. */\n defaultPinned?: boolean\n onPinnedChange?: (isPinned: boolean) => void\n /** The rail is floated open (hover, or its toggle at a narrow width). Controlled when set. */\n isHovering?: boolean\n onHoveringChange?: (isHovering: boolean) => void\n /** The phone drawer is open. Controlled when set (the app bar's menu button opens it). */\n isDrawerOpen?: boolean\n onDrawerOpenChange?: (isDrawerOpen: boolean) => void\n /**\n * Keep the sidebar a rail even when pinned, on top of the tablet width (for example while a\n * docked panel squeezes the content). The stored pin is left untouched.\n */\n forceRail?: boolean\n /**\n * Which rails expand on pointer enter. The default ignores narrow and emulated touch hover;\n * `all` retains hover expansion for a host whose narrow rail has no separate expand button.\n */\n hoverExpansion?: 'desktop-pointer' | 'all'\n}\n\n/** The `Sidebar.Root` props the controller resolves. */\nexport type SidebarControllerRootProps = Pick<\n SidebarRootProps,\n | 'mode'\n | 'expanded'\n | 'isHovering'\n | 'onBackdropClick'\n | 'hasRailBackdrop'\n | 'onPointerEnter'\n | 'onPointerLeave'\n>\n\nexport interface SidebarController {\n layout: SidebarLayout\n /** Labels shown (settled: they stay on until the closing transition ends). */\n expanded: boolean\n /** Width-bound content (tips, notices) may show: on once fully open, off as closing starts. */\n tipsVisible: boolean\n /** The phone drawer is showing. */\n isDrawer: boolean\n isSmallScreen: boolean\n /** Tablet width (or `forceRail`): pinning is ignored and the sidebar stays a rail. */\n isNarrow: boolean\n /** The pin as it applies (always off while narrow). */\n isPinned: boolean\n /** Spread onto `Sidebar.Root` (or pass the controller to `ShellSidebar`). */\n rootProps: SidebarControllerRootProps\n openDrawer: () => void\n closeDrawer: () => void\n /** The pin toggle: pins/unpins, or floats the rail open/closed while narrow. */\n togglePin: () => void\n /** Open from the rail (its ask button): pins, or floats the rail open while narrow. */\n expand: () => void\n /** After a nav row is chosen: closes the drawer, and a floated rail the pointer has left. */\n afterNavigate: () => void\n}\n\n// A menu opened from the rail (the account menu) is positioned against the sidebar's current\n// layout. Hovering that menu from the content would expand the rail, re-anchor the menu under\n// the pointer and move the item being clicked, so hover does not expand the rail while one is open.\nconst isMenuOpen = () =>\n typeof document !== 'undefined' &&\n document.querySelector('[role=\"menu\"][data-state=\"open\"]') !== null\n\n/**\n * Sidebar behaviour as one hook, shared by every shell: resolves the layout (drawer / pinned /\n * rail) for the viewport, settles labels and tips around the width transition, and owns the hover,\n * pin and drawer rules:\n * - touch: the rail opens only through its toggle, never by the pointer enter of a tap;\n * - narrow: a pointer drifting over the rail does not float the labels over the content;\n * - Escape closes a floated rail; the drawer closes itself when the viewport grows past a phone;\n * - choosing a row closes the drawer, and a floated rail unless the pointer is still over it.\n *\n * State is controlled per field (`isPinned`, `isHovering`, `isDrawerOpen`) so an app can keep it\n * in its own store, or uncontrolled for a shell that does not care.\n */\nexport function useSidebarController(options: UseSidebarControllerOptions = {}): SidebarController {\n const [storedPinned, setPinned] = useControllableState(\n options.isPinned,\n options.defaultPinned ?? true,\n options.onPinnedChange\n )\n const [isHovering, setHovering] = useControllableState(\n options.isHovering,\n false,\n options.onHoveringChange\n )\n const [isDrawerOpen, setDrawerOpen] = useControllableState(\n options.isDrawerOpen,\n false,\n options.onDrawerOpenChange\n )\n\n const isSmallScreen = useIsPhone()\n const isNarrow = useIsNarrow() || !!options.forceRail\n const isTouch = useIsTouchScreen()\n\n const layout = resolveSidebarLayout({\n isSmallScreen,\n isDrawerRequested: isDrawerOpen,\n isCollapsed: false,\n isPinned: storedPinned,\n isHovering,\n isNarrow,\n })\n const isDrawer = layout.mode === 'drawer'\n const { labelsExpanded, tipsVisible } = useSidebarSettle(layout.expanded)\n\n // Whether the pointer is physically over the sidebar (decides if navigating closes the rail).\n const isPointerOver = useRef(false)\n\n const closeDrawer = useCallback(() => setDrawerOpen(false), [setDrawerOpen])\n const openDrawer = useCallback(() => setDrawerOpen(true), [setDrawerOpen])\n\n // The floated rail has no modal behaviour (the drawer gets Escape from `Sidebar.Root`).\n useCloseOnEscape(layout.mode === 'rail' && layout.hovering, () => setHovering(false))\n\n // A drawer left open when the viewport grows past a phone (rotate/resize) would be a stuck overlay.\n useEffect(() => {\n if (isDrawerOpen && !isSmallScreen) setDrawerOpen(false)\n }, [isDrawerOpen, isSmallScreen, setDrawerOpen])\n\n const onPointerEnter = (event: PointerEvent<HTMLElement>) => {\n // Primary-input media queries can report touch even while a mouse is in use.\n if (event.pointerType !== 'mouse' && options.hoverExpansion !== 'all') return\n isPointerOver.current = true\n if (\n !isSmallScreen &&\n (!isNarrow || options.hoverExpansion === 'all') &&\n (!isMenuOpen() || options.hoverExpansion === 'all')\n )\n setHovering(true)\n }\n const onPointerLeave = (event: PointerEvent<HTMLElement>) => {\n if (event.pointerType !== 'mouse' && options.hoverExpansion !== 'all') return\n isPointerOver.current = false\n if (!isSmallScreen) setHovering(false)\n }\n\n return {\n layout,\n expanded: labelsExpanded,\n tipsVisible,\n isDrawer,\n isSmallScreen,\n isNarrow,\n isPinned: storedPinned && !isNarrow,\n rootProps: {\n mode: layout.mode,\n expanded: labelsExpanded,\n isHovering: layout.hovering,\n onBackdropClick: isDrawer ? closeDrawer : () => setHovering(false),\n hasRailBackdrop: isTouch,\n onPointerEnter,\n onPointerLeave,\n },\n openDrawer,\n closeDrawer,\n togglePin: () => (isNarrow ? setHovering(!isHovering) : setPinned(!storedPinned)),\n expand: () => (isNarrow ? setHovering(true) : setPinned(true)),\n afterNavigate: () => {\n if (!isPointerOver.current && !storedPinned) setHovering(false)\n if (isDrawer) closeDrawer()\n },\n }\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,aAAa,WAAW,cAAiC;AAClE,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;AACjC,SAAS,aAAa,YAAY,wBAAwB;AAC1D,SAAS,sBAAsB,wBAA4C;AAmE3E,MAAM,aAAa,MACjB,OAAO,aAAa,eACpB,SAAS,cAAc,kCAAkC,MAAM;
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useRef, type PointerEvent } from 'react'\nimport { useControllableState } from '../lib/useControllableState'\nimport { useCloseOnEscape } from '../lib/use-close-on-escape'\nimport { useIsNarrow, useIsPhone, useIsTouchScreen } from '../lib/use-media-query'\nimport { resolveSidebarLayout, useSidebarSettle, type SidebarLayout } from '../lib/sidebar-mode'\nimport type { SidebarRootProps } from './Sidebar'\n\nexport interface UseSidebarControllerOptions {\n /** Pinned open (desktop). Controlled when set; otherwise kept here, seeded by `defaultPinned`. */\n isPinned?: boolean\n /** Default `true`. */\n defaultPinned?: boolean\n onPinnedChange?: (isPinned: boolean) => void\n /** The rail is floated open (hover, or its toggle at a narrow width). Controlled when set. */\n isHovering?: boolean\n onHoveringChange?: (isHovering: boolean) => void\n /** The phone drawer is open. Controlled when set (the app bar's menu button opens it). */\n isDrawerOpen?: boolean\n onDrawerOpenChange?: (isDrawerOpen: boolean) => void\n /**\n * Keep the sidebar a rail even when pinned, on top of the tablet width (for example while a\n * docked panel squeezes the content). The stored pin is left untouched.\n */\n forceRail?: boolean\n /**\n * Which rails expand on pointer enter. The default ignores narrow and emulated touch hover;\n * `all` retains hover expansion for a host whose narrow rail has no separate expand button.\n */\n hoverExpansion?: 'desktop-pointer' | 'all'\n}\n\n/** The `Sidebar.Root` props the controller resolves. */\nexport type SidebarControllerRootProps = Pick<\n SidebarRootProps,\n | 'mode'\n | 'expanded'\n | 'isHovering'\n | 'onBackdropClick'\n | 'hasRailBackdrop'\n | 'onPointerEnter'\n | 'onPointerLeave'\n>\n\nexport interface SidebarController {\n layout: SidebarLayout\n /** Labels shown (settled: they stay on until the closing transition ends). */\n expanded: boolean\n /** Width-bound content (tips, notices) may show: on once fully open, off as closing starts. */\n tipsVisible: boolean\n /** The phone drawer is showing. */\n isDrawer: boolean\n isSmallScreen: boolean\n /** Tablet width (or `forceRail`): pinning is ignored and the sidebar stays a rail. */\n isNarrow: boolean\n /** The pin as it applies (always off while narrow). */\n isPinned: boolean\n /** Spread onto `Sidebar.Root` (or pass the controller to `ShellSidebar`). */\n rootProps: SidebarControllerRootProps\n openDrawer: () => void\n closeDrawer: () => void\n /** The pin toggle: pins/unpins, or floats the rail open/closed while narrow. */\n togglePin: () => void\n /** Open from the rail (its ask button): pins, or floats the rail open while narrow. */\n expand: () => void\n /** After a nav row is chosen: closes the drawer, and a floated rail the pointer has left. */\n afterNavigate: () => void\n}\n\n// A menu opened from the rail (the account menu) is positioned against the sidebar's current\n// layout. Hovering that menu from the content would expand the rail, re-anchor the menu under\n// the pointer and move the item being clicked, so hover does not expand the rail while one is open.\nconst isMenuOpen = () =>\n typeof document !== 'undefined' &&\n document.querySelector('[role=\"menu\"][data-state=\"open\"]') !== null\n\n// A dialog or menu opened from the floated rail (a skill's launcher from its ask field) sits outside\n// it: moving the pointer there must not fold the rail, which would unmount what opened it.\nconst isOverlayOpen = () =>\n typeof document !== 'undefined' &&\n document.querySelector(\n '[role=\"dialog\"][data-state=\"open\"], [role=\"alertdialog\"][data-state=\"open\"], [role=\"menu\"][data-state=\"open\"]'\n ) !== null\n\n/**\n * Sidebar behaviour as one hook, shared by every shell: resolves the layout (drawer / pinned /\n * rail) for the viewport, settles labels and tips around the width transition, and owns the hover,\n * pin and drawer rules:\n * - touch: the rail opens only through its toggle, never by the pointer enter of a tap;\n * - narrow: a pointer drifting over the rail does not float the labels over the content;\n * - Escape closes a floated rail; the drawer closes itself when the viewport grows past a phone;\n * - choosing a row closes the drawer, and a floated rail unless the pointer is still over it.\n *\n * State is controlled per field (`isPinned`, `isHovering`, `isDrawerOpen`) so an app can keep it\n * in its own store, or uncontrolled for a shell that does not care.\n */\nexport function useSidebarController(options: UseSidebarControllerOptions = {}): SidebarController {\n const [storedPinned, setPinned] = useControllableState(\n options.isPinned,\n options.defaultPinned ?? true,\n options.onPinnedChange\n )\n const [isHovering, setHovering] = useControllableState(\n options.isHovering,\n false,\n options.onHoveringChange\n )\n const [isDrawerOpen, setDrawerOpen] = useControllableState(\n options.isDrawerOpen,\n false,\n options.onDrawerOpenChange\n )\n\n const isSmallScreen = useIsPhone()\n const isNarrow = useIsNarrow() || !!options.forceRail\n const isTouch = useIsTouchScreen()\n\n const layout = resolveSidebarLayout({\n isSmallScreen,\n isDrawerRequested: isDrawerOpen,\n isCollapsed: false,\n isPinned: storedPinned,\n isHovering,\n isNarrow,\n })\n const isDrawer = layout.mode === 'drawer'\n const { labelsExpanded, tipsVisible } = useSidebarSettle(layout.expanded)\n\n // Whether the pointer is physically over the sidebar (decides if navigating closes the rail).\n const isPointerOver = useRef(false)\n\n const closeDrawer = useCallback(() => setDrawerOpen(false), [setDrawerOpen])\n const openDrawer = useCallback(() => setDrawerOpen(true), [setDrawerOpen])\n\n // The floated rail has no modal behaviour (the drawer gets Escape from `Sidebar.Root`).\n useCloseOnEscape(layout.mode === 'rail' && layout.hovering, () => setHovering(false))\n\n // A drawer left open when the viewport grows past a phone (rotate/resize) would be a stuck overlay.\n useEffect(() => {\n if (isDrawerOpen && !isSmallScreen) setDrawerOpen(false)\n }, [isDrawerOpen, isSmallScreen, setDrawerOpen])\n\n const onPointerEnter = (event: PointerEvent<HTMLElement>) => {\n // Primary-input media queries can report touch even while a mouse is in use.\n if (event.pointerType !== 'mouse' && options.hoverExpansion !== 'all') return\n isPointerOver.current = true\n if (\n !isSmallScreen &&\n (!isNarrow || options.hoverExpansion === 'all') &&\n (!isMenuOpen() || options.hoverExpansion === 'all')\n )\n setHovering(true)\n }\n const onPointerLeave = (event: PointerEvent<HTMLElement>) => {\n if (event.pointerType !== 'mouse' && options.hoverExpansion !== 'all') return\n isPointerOver.current = false\n if (!isSmallScreen && !isOverlayOpen()) setHovering(false)\n }\n\n return {\n layout,\n expanded: labelsExpanded,\n tipsVisible,\n isDrawer,\n isSmallScreen,\n isNarrow,\n isPinned: storedPinned && !isNarrow,\n rootProps: {\n mode: layout.mode,\n expanded: labelsExpanded,\n isHovering: layout.hovering,\n onBackdropClick: isDrawer ? closeDrawer : () => setHovering(false),\n hasRailBackdrop: isTouch,\n onPointerEnter,\n onPointerLeave,\n },\n openDrawer,\n closeDrawer,\n togglePin: () => (isNarrow ? setHovering(!isHovering) : setPinned(!storedPinned)),\n expand: () => (isNarrow ? setHovering(true) : setPinned(true)),\n afterNavigate: () => {\n if (!isPointerOver.current && !storedPinned) setHovering(false)\n if (isDrawer) closeDrawer()\n },\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,aAAa,WAAW,cAAiC;AAClE,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;AACjC,SAAS,aAAa,YAAY,wBAAwB;AAC1D,SAAS,sBAAsB,wBAA4C;AAmE3E,MAAM,aAAa,MACjB,OAAO,aAAa,eACpB,SAAS,cAAc,kCAAkC,MAAM;AAIjE,MAAM,gBAAgB,MACpB,OAAO,aAAa,eACpB,SAAS;AAAA,EACP;AACF,MAAM;AAcD,SAAS,qBAAqB,UAAuC,CAAC,GAAsB;AACjG,QAAM,CAAC,cAAc,SAAS,IAAI;AAAA,IAChC,QAAQ;AAAA,IACR,QAAQ,iBAAiB;AAAA,IACzB,QAAQ;AAAA,EACV;AACA,QAAM,CAAC,YAAY,WAAW,IAAI;AAAA,IAChC,QAAQ;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,EACV;AACA,QAAM,CA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