@dxos/react-ui 0.8.2-main.f11618f → 0.8.2-main.fbd8ed0
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 +838 -305
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +956 -421
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +838 -305
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts +2 -2
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts +0 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Button.stories.d.ts +10 -44
- package/dist/types/src/components/Buttons/Button.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/IconButton.d.ts +4 -5
- package/dist/types/src/components/Buttons/IconButton.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/IconButton.stories.d.ts +7 -6
- package/dist/types/src/components/Buttons/IconButton.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Toggle.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts +1 -4
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/ClipboardProvider.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/CopyButton.d.ts +2 -1
- package/dist/types/src/components/Clipboard/CopyButton.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/index.d.ts +2 -2
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts +2 -2
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/Dialog.d.ts +2 -2
- package/dist/types/src/components/Dialogs/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts +2 -2
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/ElevationProvider/ElevationProvider.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.d.ts +1 -1
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +33 -159
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/ListDropIndicator.d.ts.map +1 -1
- package/dist/types/src/components/Lists/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/TreeDropIndicator.d.ts.map +1 -1
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts +1 -1
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/useSwipeToDismiss.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +2 -2
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +13 -5
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts +5 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/Status/Status.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.stories.d.ts +2 -2
- package/dist/types/src/components/Toast/Toast.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.d.ts +94 -20
- package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +41 -17
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/useDensityContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useElevationContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useIconHref.d.ts.map +1 -1
- package/dist/types/src/hooks/useSafeCollisionPadding.d.ts.map +1 -1
- package/dist/types/src/hooks/useVisualViewport.d.ts.map +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Custom.stories.d.ts +8 -0
- package/dist/types/src/playground/Custom.stories.d.ts.map +1 -0
- package/dist/types/src/testing/decorators/withVariants.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -13
- package/src/components/Avatars/Avatar.stories.tsx +27 -27
- package/src/components/Avatars/AvatarGroup.stories.tsx +4 -5
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +2 -2
- package/src/components/Buttons/Button.stories.tsx +19 -14
- package/src/components/Buttons/IconButton.stories.tsx +9 -10
- package/src/components/Buttons/IconButton.tsx +8 -33
- package/src/components/Buttons/Toggle.stories.tsx +2 -2
- package/src/components/Buttons/ToggleGroup.stories.tsx +3 -7
- package/src/components/Clipboard/CopyButton.tsx +22 -24
- package/src/components/Dialogs/AlertDialog.stories.tsx +4 -11
- package/src/components/Dialogs/Dialog.stories.tsx +3 -3
- package/src/components/Dialogs/Dialog.tsx +7 -4
- package/src/components/Input/Input.stories.tsx +67 -56
- package/src/components/Input/Input.tsx +1 -0
- package/src/components/Lists/Tree.stories.tsx +2 -2
- package/src/components/Lists/Treegrid.stories.tsx +12 -12
- package/src/components/Main/Main.stories.tsx +2 -2
- package/src/components/Menus/ContextMenu.stories.tsx +2 -2
- package/src/components/Menus/DropdownMenu.stories.tsx +2 -2
- package/src/components/Message/Message.stories.tsx +3 -3
- package/src/components/Popover/Popover.stories.tsx +2 -2
- package/src/components/Popover/Popover.tsx +5 -4
- package/src/components/ScrollArea/ScrollArea.stories.tsx +2 -2
- package/src/components/ScrollArea/ScrollArea.tsx +3 -0
- package/src/components/Toast/Toast.stories.tsx +15 -10
- package/src/components/Toolbar/Toolbar.stories.tsx +2 -2
- package/src/components/Tooltip/Tooltip.stories.tsx +43 -18
- package/src/components/Tooltip/Tooltip.tsx +748 -58
- package/src/playground/Controls.stories.tsx +2 -2
- package/src/playground/Custom.stories.tsx +137 -0
- package/src/playground/Typography.stories.tsx +2 -2
|
@@ -150,8 +150,8 @@ var useVisualViewport = (deps) => {
|
|
|
150
150
|
// packages/ui/react-ui/src/components/AnchoredOverflow/AnchoredOverflow.tsx
|
|
151
151
|
var AnchoredOverflowRoot = /* @__PURE__ */ forwardRef(({ asChild, classNames, children, ...props }, forwardedRef) => {
|
|
152
152
|
const { tx } = useThemeContext();
|
|
153
|
-
const
|
|
154
|
-
return /* @__PURE__ */ React2.createElement(
|
|
153
|
+
const Root7 = asChild ? Slot : Primitive.div;
|
|
154
|
+
return /* @__PURE__ */ React2.createElement(Root7, {
|
|
155
155
|
role: "none",
|
|
156
156
|
...props,
|
|
157
157
|
className: tx("anchoredOverflow.root", "overflow-anchored", {}, classNames),
|
|
@@ -160,8 +160,8 @@ var AnchoredOverflowRoot = /* @__PURE__ */ forwardRef(({ asChild, classNames, ch
|
|
|
160
160
|
});
|
|
161
161
|
var AnchoredOverflowAnchor = /* @__PURE__ */ forwardRef(({ asChild, classNames, children, ...props }, forwardedRef) => {
|
|
162
162
|
const { tx } = useThemeContext();
|
|
163
|
-
const
|
|
164
|
-
return /* @__PURE__ */ React2.createElement(
|
|
163
|
+
const Root7 = asChild ? Slot : Primitive.div;
|
|
164
|
+
return /* @__PURE__ */ React2.createElement(Root7, {
|
|
165
165
|
role: "none",
|
|
166
166
|
...props,
|
|
167
167
|
className: tx("anchoredOverflow.anchor", "overflow-anchor", {}, classNames),
|
|
@@ -211,10 +211,10 @@ var AvatarContent = /* @__PURE__ */ forwardRef2(({ icon, classNames, ...props },
|
|
|
211
211
|
});
|
|
212
212
|
});
|
|
213
213
|
var AvatarLabel = /* @__PURE__ */ forwardRef2(({ asChild, srOnly, classNames, ...props }, forwardedRef) => {
|
|
214
|
-
const
|
|
214
|
+
const Root7 = asChild ? Slot2 : Primitive2.span;
|
|
215
215
|
const { tx } = useThemeContext();
|
|
216
216
|
const { labelId } = useAvatarContext("AvatarLabel");
|
|
217
|
-
return /* @__PURE__ */ React3.createElement(
|
|
217
|
+
return /* @__PURE__ */ React3.createElement(Root7, {
|
|
218
218
|
...props,
|
|
219
219
|
id: labelId,
|
|
220
220
|
ref: forwardedRef,
|
|
@@ -224,10 +224,10 @@ var AvatarLabel = /* @__PURE__ */ forwardRef2(({ asChild, srOnly, classNames, ..
|
|
|
224
224
|
});
|
|
225
225
|
});
|
|
226
226
|
var AvatarDescription = /* @__PURE__ */ forwardRef2(({ asChild, srOnly, classNames, ...props }, forwardedRef) => {
|
|
227
|
-
const
|
|
227
|
+
const Root7 = asChild ? Slot2 : Primitive2.span;
|
|
228
228
|
const { tx } = useThemeContext();
|
|
229
229
|
const { descriptionId } = useAvatarContext("AvatarDescription");
|
|
230
|
-
return /* @__PURE__ */ React3.createElement(
|
|
230
|
+
return /* @__PURE__ */ React3.createElement(Root7, {
|
|
231
231
|
...props,
|
|
232
232
|
id: descriptionId,
|
|
233
233
|
ref: forwardedRef,
|
|
@@ -255,8 +255,8 @@ import { Slot as Slot3 } from "@radix-ui/react-slot";
|
|
|
255
255
|
import React4, { forwardRef as forwardRef3 } from "react";
|
|
256
256
|
var Link = /* @__PURE__ */ forwardRef3(({ asChild, variant, classNames, ...props }, forwardedRef) => {
|
|
257
257
|
const { tx } = useThemeContext();
|
|
258
|
-
const
|
|
259
|
-
return /* @__PURE__ */ React4.createElement(
|
|
258
|
+
const Root7 = asChild ? Slot3 : Primitive3.a;
|
|
259
|
+
return /* @__PURE__ */ React4.createElement(Root7, {
|
|
260
260
|
...props,
|
|
261
261
|
className: tx("link.root", "link", {
|
|
262
262
|
variant
|
|
@@ -268,8 +268,8 @@ var Link = /* @__PURE__ */ forwardRef3(({ asChild, variant, classNames, ...props
|
|
|
268
268
|
// packages/ui/react-ui/src/components/Breadcrumb/Breadcrumb.tsx
|
|
269
269
|
var BreadcrumbRoot = /* @__PURE__ */ forwardRef4(({ asChild, classNames, ...props }, forwardedRef) => {
|
|
270
270
|
const { tx } = useThemeContext();
|
|
271
|
-
const
|
|
272
|
-
return /* @__PURE__ */ React5.createElement(
|
|
271
|
+
const Root7 = asChild ? Slot4 : Primitive4.div;
|
|
272
|
+
return /* @__PURE__ */ React5.createElement(Root7, {
|
|
273
273
|
role: "navigation",
|
|
274
274
|
...props,
|
|
275
275
|
className: tx("breadcrumb.root", "breadcrumb", {}, classNames),
|
|
@@ -278,8 +278,8 @@ var BreadcrumbRoot = /* @__PURE__ */ forwardRef4(({ asChild, classNames, ...prop
|
|
|
278
278
|
});
|
|
279
279
|
var BreadcrumbList = /* @__PURE__ */ forwardRef4(({ asChild, classNames, ...props }, forwardedRef) => {
|
|
280
280
|
const { tx } = useThemeContext();
|
|
281
|
-
const
|
|
282
|
-
return /* @__PURE__ */ React5.createElement(
|
|
281
|
+
const Root7 = asChild ? Slot4 : Primitive4.ol;
|
|
282
|
+
return /* @__PURE__ */ React5.createElement(Root7, {
|
|
283
283
|
role: "list",
|
|
284
284
|
...props,
|
|
285
285
|
className: tx("breadcrumb.list", "breadcrumb__list", {}, classNames),
|
|
@@ -288,8 +288,8 @@ var BreadcrumbList = /* @__PURE__ */ forwardRef4(({ asChild, classNames, ...prop
|
|
|
288
288
|
});
|
|
289
289
|
var BreadcrumbListItem = /* @__PURE__ */ forwardRef4(({ asChild, classNames, ...props }, forwardedRef) => {
|
|
290
290
|
const { tx } = useThemeContext();
|
|
291
|
-
const
|
|
292
|
-
return /* @__PURE__ */ React5.createElement(
|
|
291
|
+
const Root7 = asChild ? Slot4 : Primitive4.li;
|
|
292
|
+
return /* @__PURE__ */ React5.createElement(Root7, {
|
|
293
293
|
role: "listitem",
|
|
294
294
|
...props,
|
|
295
295
|
className: tx("breadcrumb.listItem", "breadcrumb__list__item", {}, classNames),
|
|
@@ -297,16 +297,16 @@ var BreadcrumbListItem = /* @__PURE__ */ forwardRef4(({ asChild, classNames, ...
|
|
|
297
297
|
});
|
|
298
298
|
});
|
|
299
299
|
var BreadcrumbLink = /* @__PURE__ */ forwardRef4(({ asChild, ...props }, forwardedRef) => {
|
|
300
|
-
const
|
|
301
|
-
return /* @__PURE__ */ React5.createElement(
|
|
300
|
+
const Root7 = asChild ? Slot4 : Link;
|
|
301
|
+
return /* @__PURE__ */ React5.createElement(Root7, {
|
|
302
302
|
...props,
|
|
303
303
|
ref: forwardedRef
|
|
304
304
|
});
|
|
305
305
|
});
|
|
306
306
|
var BreadcrumbCurrent = /* @__PURE__ */ forwardRef4(({ asChild, classNames, ...props }, forwardedRef) => {
|
|
307
307
|
const { tx } = useThemeContext();
|
|
308
|
-
const
|
|
309
|
-
return /* @__PURE__ */ React5.createElement(
|
|
308
|
+
const Root7 = asChild ? Slot4 : "h1";
|
|
309
|
+
return /* @__PURE__ */ React5.createElement(Root7, {
|
|
310
310
|
...props,
|
|
311
311
|
"aria-current": "page",
|
|
312
312
|
className: tx("breadcrumb.current", "breadcrumb__item__heading--current", {}, classNames),
|
|
@@ -348,8 +348,8 @@ var Button = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef5(({ classNames, chi
|
|
|
348
348
|
const { tx } = useThemeContext();
|
|
349
349
|
const elevation = useElevationContext(propsElevation);
|
|
350
350
|
const density = useDensityContext(propsDensity);
|
|
351
|
-
const
|
|
352
|
-
return /* @__PURE__ */ React6.createElement(
|
|
351
|
+
const Root7 = asChild ? Slot5 : Primitive5.button;
|
|
352
|
+
return /* @__PURE__ */ React6.createElement(Root7, {
|
|
353
353
|
ref,
|
|
354
354
|
...props,
|
|
355
355
|
"data-variant": variant,
|
|
@@ -371,8 +371,8 @@ Button.displayName = BUTTON_NAME;
|
|
|
371
371
|
var ButtonGroup = /* @__PURE__ */ forwardRef5(({ children, elevation: propsElevation, classNames, asChild, ...props }, forwardedRef) => {
|
|
372
372
|
const { tx } = useThemeContext();
|
|
373
373
|
const elevation = useElevationContext(propsElevation);
|
|
374
|
-
const
|
|
375
|
-
return /* @__PURE__ */ React6.createElement(
|
|
374
|
+
const Root7 = asChild ? Slot5 : Primitive5.div;
|
|
375
|
+
return /* @__PURE__ */ React6.createElement(Root7, {
|
|
376
376
|
role: "none",
|
|
377
377
|
...props,
|
|
378
378
|
className: tx("button.group", "button-group", {
|
|
@@ -386,7 +386,7 @@ var ButtonGroup = /* @__PURE__ */ forwardRef5(({ children, elevation: propsEleva
|
|
|
386
386
|
ButtonGroup.displayName = BUTTON_GROUP_NAME;
|
|
387
387
|
|
|
388
388
|
// packages/ui/react-ui/src/components/Buttons/IconButton.tsx
|
|
389
|
-
import React9, { forwardRef as forwardRef8
|
|
389
|
+
import React9, { forwardRef as forwardRef8 } from "react";
|
|
390
390
|
|
|
391
391
|
// packages/ui/react-ui/src/components/Icon/Icon.tsx
|
|
392
392
|
import React7, { forwardRef as forwardRef6, memo as memo2 } from "react";
|
|
@@ -405,98 +405,618 @@ var Icon = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef6(({ icon, classNames
|
|
|
405
405
|
}));
|
|
406
406
|
|
|
407
407
|
// packages/ui/react-ui/src/components/Tooltip/Tooltip.tsx
|
|
408
|
-
import {
|
|
409
|
-
import
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
import {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
408
|
+
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
409
|
+
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
410
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
411
|
+
import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
|
|
412
|
+
import { useId as useId2 } from "@radix-ui/react-id";
|
|
413
|
+
import * as PopperPrimitive from "@radix-ui/react-popper";
|
|
414
|
+
import { createPopperScope } from "@radix-ui/react-popper";
|
|
415
|
+
import { Portal as PortalPrimitive } from "@radix-ui/react-portal";
|
|
416
|
+
import { Presence } from "@radix-ui/react-presence";
|
|
417
|
+
import { Primitive as Primitive6 } from "@radix-ui/react-primitive";
|
|
418
|
+
import { Slottable } from "@radix-ui/react-slot";
|
|
419
|
+
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
420
|
+
import * as VisuallyHiddenPrimitive from "@radix-ui/react-visually-hidden";
|
|
421
|
+
import React8, { forwardRef as forwardRef7, useCallback as useCallback3, useEffect as useEffect2, useMemo, useRef, useState as useState4 } from "react";
|
|
422
|
+
var [createTooltipContext, createTooltipScope] = createContextScope("Tooltip", [
|
|
423
|
+
createPopperScope
|
|
424
|
+
]);
|
|
425
|
+
var usePopperScope = createPopperScope();
|
|
426
|
+
var DEFAULT_DELAY_DURATION = 700;
|
|
427
|
+
var TOOLTIP_OPEN = "tooltip.open";
|
|
428
|
+
var TOOLTIP_NAME = "Tooltip";
|
|
429
|
+
var [TooltipContextProvider, useTooltipContext] = createTooltipContext(TOOLTIP_NAME);
|
|
430
|
+
var TooltipProvider = (props) => {
|
|
431
|
+
const { __scopeTooltip, children, open: openProp, defaultOpen = false, onOpenChange, disableHoverableContent = false, delayDuration = DEFAULT_DELAY_DURATION, skipDelayDuration = 300 } = props;
|
|
432
|
+
const isOpenDelayedRef = useRef(true);
|
|
433
|
+
const isPointerInTransitRef = useRef(false);
|
|
434
|
+
const skipDelayTimerRef = useRef(0);
|
|
435
|
+
useEffect2(() => {
|
|
436
|
+
const skipDelayTimer = skipDelayTimerRef.current;
|
|
437
|
+
return () => window.clearTimeout(skipDelayTimer);
|
|
438
|
+
}, []);
|
|
439
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
440
|
+
const [trigger, setTrigger] = useState4(null);
|
|
441
|
+
const [content, setContent] = useState4("");
|
|
442
|
+
const [side, setSide] = useState4(void 0);
|
|
443
|
+
const triggerRef = useRef(trigger);
|
|
444
|
+
const handleTriggerChange = useCallback3((nextTrigger) => {
|
|
445
|
+
setTrigger(nextTrigger);
|
|
446
|
+
triggerRef.current = nextTrigger;
|
|
447
|
+
setContent(nextTrigger?.getAttribute("data-tooltip-content") ?? "");
|
|
448
|
+
setSide(nextTrigger?.getAttribute("data-tooltip-side") ?? void 0);
|
|
449
|
+
}, []);
|
|
450
|
+
const contentId = useId2();
|
|
451
|
+
const openTimerRef = useRef(0);
|
|
452
|
+
const wasOpenDelayedRef = useRef(false);
|
|
453
|
+
const handleOpenChange = useCallback3((open2) => {
|
|
454
|
+
if (open2) {
|
|
455
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
456
|
+
isOpenDelayedRef.current = false;
|
|
457
|
+
document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));
|
|
458
|
+
} else {
|
|
459
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
460
|
+
skipDelayTimerRef.current = window.setTimeout(() => isOpenDelayedRef.current = true, skipDelayDuration);
|
|
461
|
+
}
|
|
462
|
+
onOpenChange?.(open2);
|
|
463
|
+
}, [
|
|
464
|
+
skipDelayDuration,
|
|
465
|
+
onOpenChange
|
|
428
466
|
]);
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
var TooltipRoot = TooltipRootPrimitive;
|
|
434
|
-
var TooltipPortal = TooltipPortalPrimitive;
|
|
435
|
-
var TooltipTrigger = TooltipTriggerPrimitive;
|
|
436
|
-
var TooltipArrow = /* @__PURE__ */ forwardRef7(({ classNames, ...props }, forwardedRef) => {
|
|
437
|
-
const { tx } = useThemeContext();
|
|
438
|
-
return /* @__PURE__ */ React8.createElement(TooltipArrowPrimitive, {
|
|
439
|
-
...props,
|
|
440
|
-
className: tx("tooltip.arrow", "tooltip__arrow", {}, classNames),
|
|
441
|
-
ref: forwardedRef
|
|
467
|
+
const [open = false, setOpen] = useControllableState({
|
|
468
|
+
prop: openProp,
|
|
469
|
+
defaultProp: defaultOpen,
|
|
470
|
+
onChange: handleOpenChange
|
|
442
471
|
});
|
|
443
|
-
|
|
444
|
-
|
|
472
|
+
const stateAttribute = useMemo(() => {
|
|
473
|
+
return open ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
|
|
474
|
+
}, [
|
|
475
|
+
open
|
|
476
|
+
]);
|
|
477
|
+
const handleOpen = useCallback3(() => {
|
|
478
|
+
window.clearTimeout(openTimerRef.current);
|
|
479
|
+
openTimerRef.current = 0;
|
|
480
|
+
wasOpenDelayedRef.current = false;
|
|
481
|
+
setOpen(true);
|
|
482
|
+
}, [
|
|
483
|
+
setOpen
|
|
484
|
+
]);
|
|
485
|
+
const handleClose = useCallback3(() => {
|
|
486
|
+
window.clearTimeout(openTimerRef.current);
|
|
487
|
+
openTimerRef.current = 0;
|
|
488
|
+
setOpen(false);
|
|
489
|
+
}, [
|
|
490
|
+
setOpen
|
|
491
|
+
]);
|
|
492
|
+
const handleDelayedOpen = useCallback3(() => {
|
|
493
|
+
window.clearTimeout(openTimerRef.current);
|
|
494
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
495
|
+
wasOpenDelayedRef.current = true;
|
|
496
|
+
setOpen(true);
|
|
497
|
+
openTimerRef.current = 0;
|
|
498
|
+
}, delayDuration);
|
|
499
|
+
}, [
|
|
500
|
+
delayDuration,
|
|
501
|
+
setOpen
|
|
502
|
+
]);
|
|
503
|
+
useEffect2(() => {
|
|
504
|
+
return () => {
|
|
505
|
+
if (openTimerRef.current) {
|
|
506
|
+
window.clearTimeout(openTimerRef.current);
|
|
507
|
+
openTimerRef.current = 0;
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
}, []);
|
|
445
511
|
const { tx } = useThemeContext();
|
|
446
512
|
const elevation = useElevationContext();
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
513
|
+
return /* @__PURE__ */ React8.createElement(PopperPrimitive.Root, popperScope, /* @__PURE__ */ React8.createElement(TooltipContextProvider, {
|
|
514
|
+
scope: __scopeTooltip,
|
|
515
|
+
contentId,
|
|
516
|
+
open,
|
|
517
|
+
stateAttribute,
|
|
518
|
+
trigger,
|
|
519
|
+
onTriggerChange: handleTriggerChange,
|
|
520
|
+
onTriggerEnter: useCallback3(() => {
|
|
521
|
+
if (isOpenDelayedRef.current) {
|
|
522
|
+
handleDelayedOpen();
|
|
523
|
+
} else {
|
|
524
|
+
handleOpen();
|
|
525
|
+
}
|
|
526
|
+
}, [
|
|
527
|
+
isOpenDelayedRef,
|
|
528
|
+
handleDelayedOpen,
|
|
529
|
+
handleOpen
|
|
530
|
+
]),
|
|
531
|
+
onTriggerLeave: useCallback3(() => {
|
|
532
|
+
if (disableHoverableContent) {
|
|
533
|
+
handleClose();
|
|
534
|
+
} else {
|
|
535
|
+
window.clearTimeout(openTimerRef.current);
|
|
536
|
+
openTimerRef.current = 0;
|
|
537
|
+
}
|
|
538
|
+
}, [
|
|
539
|
+
handleClose,
|
|
540
|
+
disableHoverableContent
|
|
541
|
+
]),
|
|
542
|
+
onOpen: handleOpen,
|
|
543
|
+
onClose: handleClose,
|
|
544
|
+
disableHoverableContent,
|
|
545
|
+
isPointerInTransitRef,
|
|
546
|
+
onPointerInTransitChange: useCallback3((inTransit) => {
|
|
547
|
+
isPointerInTransitRef.current = inTransit;
|
|
548
|
+
}, [])
|
|
549
|
+
}, /* @__PURE__ */ React8.createElement(TooltipContent, {
|
|
550
|
+
side,
|
|
452
551
|
className: tx("tooltip.content", "tooltip", {
|
|
453
552
|
elevation
|
|
454
|
-
}
|
|
553
|
+
})
|
|
554
|
+
}, content, /* @__PURE__ */ React8.createElement(TooltipArrow, {
|
|
555
|
+
className: tx("tooltip.arrow", "tooltip__arrow")
|
|
556
|
+
})), /* @__PURE__ */ React8.createElement(TooltipVirtualTrigger, {
|
|
557
|
+
virtualRef: triggerRef
|
|
558
|
+
}), children));
|
|
559
|
+
};
|
|
560
|
+
TooltipProvider.displayName = TOOLTIP_NAME;
|
|
561
|
+
var TooltipVirtualTrigger = ({ virtualRef, __scopeTooltip }) => {
|
|
562
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
563
|
+
return /* @__PURE__ */ React8.createElement(PopperPrimitive.Anchor, {
|
|
564
|
+
asChild: true,
|
|
565
|
+
...popperScope,
|
|
566
|
+
virtualRef
|
|
567
|
+
});
|
|
568
|
+
};
|
|
569
|
+
var TRIGGER_NAME = "TooltipTrigger";
|
|
570
|
+
var TooltipTrigger = /* @__PURE__ */ forwardRef7((props, forwardedRef) => {
|
|
571
|
+
const {
|
|
572
|
+
__scopeTooltip,
|
|
573
|
+
onInteract,
|
|
574
|
+
// TODO(thure): Pass `delayDuration` into the context.
|
|
575
|
+
delayDuration: _delayDuration,
|
|
576
|
+
suppressNextTooltip,
|
|
577
|
+
side,
|
|
578
|
+
content,
|
|
579
|
+
...triggerProps
|
|
580
|
+
} = props;
|
|
581
|
+
const context = useTooltipContext(TRIGGER_NAME, __scopeTooltip);
|
|
582
|
+
const ref = useRef(null);
|
|
583
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
584
|
+
const isPointerDownRef = useRef(false);
|
|
585
|
+
const hasPointerMoveOpenedRef = useRef(false);
|
|
586
|
+
const handlePointerUp = useCallback3(() => isPointerDownRef.current = false, []);
|
|
587
|
+
useEffect2(() => {
|
|
588
|
+
return () => document.removeEventListener("pointerup", handlePointerUp);
|
|
589
|
+
}, [
|
|
590
|
+
handlePointerUp
|
|
591
|
+
]);
|
|
592
|
+
return /* @__PURE__ */ React8.createElement(Primitive6.button, {
|
|
593
|
+
// We purposefully avoid adding `type=button` here because tooltip triggers are also
|
|
594
|
+
// commonly anchors and the anchor `type` attribute signifies MIME type.
|
|
595
|
+
"aria-describedby": context.open ? context.contentId : void 0,
|
|
596
|
+
"data-state": context.stateAttribute,
|
|
597
|
+
"data-tooltip-content": content,
|
|
598
|
+
"data-tooltip-side": side,
|
|
599
|
+
...triggerProps,
|
|
600
|
+
ref: composedRefs,
|
|
601
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, (event) => {
|
|
602
|
+
if (event.pointerType === "touch") {
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
if (!hasPointerMoveOpenedRef.current && !context.isPointerInTransitRef.current) {
|
|
606
|
+
onInteract?.(event);
|
|
607
|
+
if (event.defaultPrevented) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
context.onTriggerChange(ref.current);
|
|
611
|
+
context.onTriggerEnter();
|
|
612
|
+
hasPointerMoveOpenedRef.current = true;
|
|
613
|
+
}
|
|
614
|
+
}),
|
|
615
|
+
onPointerLeave: composeEventHandlers(props.onPointerLeave, () => {
|
|
616
|
+
context.onTriggerLeave();
|
|
617
|
+
hasPointerMoveOpenedRef.current = false;
|
|
618
|
+
}),
|
|
619
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, () => {
|
|
620
|
+
if (context.open) {
|
|
621
|
+
context.onClose();
|
|
622
|
+
}
|
|
623
|
+
isPointerDownRef.current = true;
|
|
624
|
+
document.addEventListener("pointerup", handlePointerUp, {
|
|
625
|
+
once: true
|
|
626
|
+
});
|
|
627
|
+
}),
|
|
628
|
+
onFocus: composeEventHandlers(props.onFocus, (event) => {
|
|
629
|
+
if (!isPointerDownRef.current) {
|
|
630
|
+
onInteract?.(event);
|
|
631
|
+
if (event.defaultPrevented) {
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
if (suppressNextTooltip?.current) {
|
|
635
|
+
suppressNextTooltip.current = false;
|
|
636
|
+
} else {
|
|
637
|
+
context.onTriggerChange(ref.current);
|
|
638
|
+
context.onOpen();
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}),
|
|
642
|
+
onBlur: composeEventHandlers(props.onBlur, context.onClose),
|
|
643
|
+
onClick: composeEventHandlers(props.onClick, context.onClose)
|
|
644
|
+
});
|
|
645
|
+
});
|
|
646
|
+
TooltipTrigger.displayName = TRIGGER_NAME;
|
|
647
|
+
var PORTAL_NAME = "TooltipPortal";
|
|
648
|
+
var [PortalProvider, usePortalContext] = createTooltipContext(PORTAL_NAME, {
|
|
649
|
+
forceMount: void 0
|
|
650
|
+
});
|
|
651
|
+
var TooltipPortal = (props) => {
|
|
652
|
+
const { __scopeTooltip, forceMount, children, container } = props;
|
|
653
|
+
const context = useTooltipContext(PORTAL_NAME, __scopeTooltip);
|
|
654
|
+
return /* @__PURE__ */ React8.createElement(PortalProvider, {
|
|
655
|
+
scope: __scopeTooltip,
|
|
656
|
+
forceMount
|
|
657
|
+
}, /* @__PURE__ */ React8.createElement(Presence, {
|
|
658
|
+
present: forceMount || context.open
|
|
659
|
+
}, /* @__PURE__ */ React8.createElement(PortalPrimitive, {
|
|
660
|
+
asChild: true,
|
|
661
|
+
container
|
|
662
|
+
}, children)));
|
|
663
|
+
};
|
|
664
|
+
TooltipPortal.displayName = PORTAL_NAME;
|
|
665
|
+
var CONTENT_NAME = "TooltipContent";
|
|
666
|
+
var TooltipContent = /* @__PURE__ */ forwardRef7((props, forwardedRef) => {
|
|
667
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeTooltip);
|
|
668
|
+
const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
|
|
669
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
|
670
|
+
return /* @__PURE__ */ React8.createElement(Presence, {
|
|
671
|
+
present: forceMount || context.open
|
|
672
|
+
}, context.disableHoverableContent ? /* @__PURE__ */ React8.createElement(TooltipContentImpl, {
|
|
673
|
+
side,
|
|
674
|
+
...contentProps,
|
|
675
|
+
ref: forwardedRef
|
|
676
|
+
}) : /* @__PURE__ */ React8.createElement(TooltipContentHoverable, {
|
|
677
|
+
side,
|
|
678
|
+
...contentProps,
|
|
679
|
+
ref: forwardedRef
|
|
680
|
+
}));
|
|
681
|
+
});
|
|
682
|
+
var TooltipContentHoverable = /* @__PURE__ */ forwardRef7((props, forwardedRef) => {
|
|
683
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
|
684
|
+
const ref = useRef(null);
|
|
685
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
686
|
+
const [pointerGraceArea, setPointerGraceArea] = useState4(null);
|
|
687
|
+
const { trigger, onClose } = context;
|
|
688
|
+
const content = ref.current;
|
|
689
|
+
const { onPointerInTransitChange } = context;
|
|
690
|
+
const handleRemoveGraceArea = useCallback3(() => {
|
|
691
|
+
setPointerGraceArea(null);
|
|
692
|
+
onPointerInTransitChange(false);
|
|
693
|
+
}, [
|
|
694
|
+
onPointerInTransitChange
|
|
695
|
+
]);
|
|
696
|
+
const handleCreateGraceArea = useCallback3((event, hoverTarget) => {
|
|
697
|
+
const currentTarget = event.currentTarget;
|
|
698
|
+
const exitPoint = {
|
|
699
|
+
x: event.clientX,
|
|
700
|
+
y: event.clientY
|
|
701
|
+
};
|
|
702
|
+
const exitSide = getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
|
|
703
|
+
const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide);
|
|
704
|
+
const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());
|
|
705
|
+
const graceArea = getHull([
|
|
706
|
+
...paddedExitPoints,
|
|
707
|
+
...hoverTargetPoints
|
|
708
|
+
]);
|
|
709
|
+
setPointerGraceArea(graceArea);
|
|
710
|
+
onPointerInTransitChange(true);
|
|
711
|
+
}, [
|
|
712
|
+
onPointerInTransitChange
|
|
713
|
+
]);
|
|
714
|
+
useEffect2(() => {
|
|
715
|
+
return () => handleRemoveGraceArea();
|
|
716
|
+
}, [
|
|
717
|
+
handleRemoveGraceArea
|
|
718
|
+
]);
|
|
719
|
+
useEffect2(() => {
|
|
720
|
+
if (trigger && content) {
|
|
721
|
+
const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
|
|
722
|
+
const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
|
|
723
|
+
trigger.addEventListener("pointerleave", handleTriggerLeave);
|
|
724
|
+
content.addEventListener("pointerleave", handleContentLeave);
|
|
725
|
+
return () => {
|
|
726
|
+
trigger.removeEventListener("pointerleave", handleTriggerLeave);
|
|
727
|
+
content.removeEventListener("pointerleave", handleContentLeave);
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
}, [
|
|
731
|
+
trigger,
|
|
732
|
+
content,
|
|
733
|
+
handleCreateGraceArea,
|
|
734
|
+
handleRemoveGraceArea
|
|
735
|
+
]);
|
|
736
|
+
useEffect2(() => {
|
|
737
|
+
if (pointerGraceArea) {
|
|
738
|
+
const handleTrackPointerGrace = (event) => {
|
|
739
|
+
const target = event.target;
|
|
740
|
+
const pointerPosition = {
|
|
741
|
+
x: event.clientX,
|
|
742
|
+
y: event.clientY
|
|
743
|
+
};
|
|
744
|
+
const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);
|
|
745
|
+
const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
|
|
746
|
+
if (hasEnteredTarget) {
|
|
747
|
+
handleRemoveGraceArea();
|
|
748
|
+
} else if (isPointerOutsideGraceArea) {
|
|
749
|
+
handleRemoveGraceArea();
|
|
750
|
+
onClose();
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
document.addEventListener("pointermove", handleTrackPointerGrace);
|
|
754
|
+
return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
|
|
755
|
+
}
|
|
756
|
+
}, [
|
|
757
|
+
trigger,
|
|
758
|
+
content,
|
|
759
|
+
pointerGraceArea,
|
|
760
|
+
onClose,
|
|
761
|
+
handleRemoveGraceArea
|
|
762
|
+
]);
|
|
763
|
+
return /* @__PURE__ */ React8.createElement(TooltipContentImpl, {
|
|
764
|
+
...props,
|
|
765
|
+
ref: composedRefs
|
|
766
|
+
});
|
|
767
|
+
});
|
|
768
|
+
var [VisuallyHiddenContentContextProvider, useVisuallyHiddenContentContext] = createTooltipContext(TOOLTIP_NAME, {
|
|
769
|
+
isInside: false
|
|
770
|
+
});
|
|
771
|
+
var TooltipContentImpl = /* @__PURE__ */ forwardRef7((props, forwardedRef) => {
|
|
772
|
+
const { __scopeTooltip, children, "aria-label": ariaLabel, onEscapeKeyDown, onPointerDownOutside, ...contentProps } = props;
|
|
773
|
+
const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);
|
|
774
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
775
|
+
const { onClose } = context;
|
|
776
|
+
useEffect2(() => {
|
|
777
|
+
document.addEventListener(TOOLTIP_OPEN, onClose);
|
|
778
|
+
return () => document.removeEventListener(TOOLTIP_OPEN, onClose);
|
|
779
|
+
}, [
|
|
780
|
+
onClose
|
|
781
|
+
]);
|
|
782
|
+
useEffect2(() => {
|
|
783
|
+
if (context.trigger) {
|
|
784
|
+
const handleScroll = (event) => {
|
|
785
|
+
const target = event.target;
|
|
786
|
+
if (target?.contains(context.trigger)) {
|
|
787
|
+
onClose();
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
window.addEventListener("scroll", handleScroll, {
|
|
791
|
+
capture: true
|
|
792
|
+
});
|
|
793
|
+
return () => window.removeEventListener("scroll", handleScroll, {
|
|
794
|
+
capture: true
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
}, [
|
|
798
|
+
context.trigger,
|
|
799
|
+
onClose
|
|
800
|
+
]);
|
|
801
|
+
return /* @__PURE__ */ React8.createElement(DismissableLayer, {
|
|
802
|
+
asChild: true,
|
|
803
|
+
disableOutsidePointerEvents: false,
|
|
804
|
+
onEscapeKeyDown,
|
|
805
|
+
onPointerDownOutside,
|
|
806
|
+
onFocusOutside: (event) => event.preventDefault(),
|
|
807
|
+
onDismiss: onClose
|
|
808
|
+
}, /* @__PURE__ */ React8.createElement(PopperPrimitive.Content, {
|
|
809
|
+
"data-state": context.stateAttribute,
|
|
810
|
+
...popperScope,
|
|
811
|
+
...contentProps,
|
|
812
|
+
ref: forwardedRef,
|
|
813
|
+
style: {
|
|
814
|
+
...contentProps.style,
|
|
815
|
+
// re-namespace exposed content custom properties
|
|
816
|
+
...{
|
|
817
|
+
"--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
818
|
+
"--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
|
|
819
|
+
"--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
|
|
820
|
+
"--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
|
|
821
|
+
"--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}, /* @__PURE__ */ React8.createElement(Slottable, null, children), /* @__PURE__ */ React8.createElement(VisuallyHiddenContentContextProvider, {
|
|
825
|
+
scope: __scopeTooltip,
|
|
826
|
+
isInside: true
|
|
827
|
+
}, /* @__PURE__ */ React8.createElement(VisuallyHiddenPrimitive.Root, {
|
|
828
|
+
id: context.contentId,
|
|
829
|
+
role: "tooltip"
|
|
830
|
+
}, ariaLabel || children))));
|
|
831
|
+
});
|
|
832
|
+
TooltipContent.displayName = CONTENT_NAME;
|
|
833
|
+
var ARROW_NAME = "TooltipArrow";
|
|
834
|
+
var TooltipArrow = /* @__PURE__ */ forwardRef7((props, forwardedRef) => {
|
|
835
|
+
const { __scopeTooltip, ...arrowProps } = props;
|
|
836
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
837
|
+
const visuallyHiddenContentContext = useVisuallyHiddenContentContext(ARROW_NAME, __scopeTooltip);
|
|
838
|
+
return visuallyHiddenContentContext.isInside ? null : /* @__PURE__ */ React8.createElement(PopperPrimitive.Arrow, {
|
|
839
|
+
...popperScope,
|
|
840
|
+
...arrowProps,
|
|
455
841
|
ref: forwardedRef
|
|
456
842
|
});
|
|
457
843
|
});
|
|
844
|
+
TooltipArrow.displayName = ARROW_NAME;
|
|
845
|
+
var getExitSideFromRect = (point, rect) => {
|
|
846
|
+
const top = Math.abs(rect.top - point.y);
|
|
847
|
+
const bottom = Math.abs(rect.bottom - point.y);
|
|
848
|
+
const right = Math.abs(rect.right - point.x);
|
|
849
|
+
const left = Math.abs(rect.left - point.x);
|
|
850
|
+
switch (Math.min(top, bottom, right, left)) {
|
|
851
|
+
case left:
|
|
852
|
+
return "left";
|
|
853
|
+
case right:
|
|
854
|
+
return "right";
|
|
855
|
+
case top:
|
|
856
|
+
return "top";
|
|
857
|
+
case bottom:
|
|
858
|
+
return "bottom";
|
|
859
|
+
default:
|
|
860
|
+
throw new Error("unreachable");
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
var getPaddedExitPoints = (exitPoint, exitSide, padding = 5) => {
|
|
864
|
+
const paddedExitPoints = [];
|
|
865
|
+
switch (exitSide) {
|
|
866
|
+
case "top":
|
|
867
|
+
paddedExitPoints.push({
|
|
868
|
+
x: exitPoint.x - padding,
|
|
869
|
+
y: exitPoint.y + padding
|
|
870
|
+
}, {
|
|
871
|
+
x: exitPoint.x + padding,
|
|
872
|
+
y: exitPoint.y + padding
|
|
873
|
+
});
|
|
874
|
+
break;
|
|
875
|
+
case "bottom":
|
|
876
|
+
paddedExitPoints.push({
|
|
877
|
+
x: exitPoint.x - padding,
|
|
878
|
+
y: exitPoint.y - padding
|
|
879
|
+
}, {
|
|
880
|
+
x: exitPoint.x + padding,
|
|
881
|
+
y: exitPoint.y - padding
|
|
882
|
+
});
|
|
883
|
+
break;
|
|
884
|
+
case "left":
|
|
885
|
+
paddedExitPoints.push({
|
|
886
|
+
x: exitPoint.x + padding,
|
|
887
|
+
y: exitPoint.y - padding
|
|
888
|
+
}, {
|
|
889
|
+
x: exitPoint.x + padding,
|
|
890
|
+
y: exitPoint.y + padding
|
|
891
|
+
});
|
|
892
|
+
break;
|
|
893
|
+
case "right":
|
|
894
|
+
paddedExitPoints.push({
|
|
895
|
+
x: exitPoint.x - padding,
|
|
896
|
+
y: exitPoint.y - padding
|
|
897
|
+
}, {
|
|
898
|
+
x: exitPoint.x - padding,
|
|
899
|
+
y: exitPoint.y + padding
|
|
900
|
+
});
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
return paddedExitPoints;
|
|
904
|
+
};
|
|
905
|
+
var getPointsFromRect = (rect) => {
|
|
906
|
+
const { top, right, bottom, left } = rect;
|
|
907
|
+
return [
|
|
908
|
+
{
|
|
909
|
+
x: left,
|
|
910
|
+
y: top
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
x: right,
|
|
914
|
+
y: top
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
x: right,
|
|
918
|
+
y: bottom
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
x: left,
|
|
922
|
+
y: bottom
|
|
923
|
+
}
|
|
924
|
+
];
|
|
925
|
+
};
|
|
926
|
+
var isPointInPolygon = (point, polygon) => {
|
|
927
|
+
const { x, y } = point;
|
|
928
|
+
let inside = false;
|
|
929
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
930
|
+
const xi = polygon[i].x;
|
|
931
|
+
const yi = polygon[i].y;
|
|
932
|
+
const xj = polygon[j].x;
|
|
933
|
+
const yj = polygon[j].y;
|
|
934
|
+
const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
|
|
935
|
+
if (intersect) {
|
|
936
|
+
inside = !inside;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
return inside;
|
|
940
|
+
};
|
|
941
|
+
var getHull = (points) => {
|
|
942
|
+
const newPoints = points.slice();
|
|
943
|
+
newPoints.sort((a, b) => {
|
|
944
|
+
if (a.x < b.x) {
|
|
945
|
+
return -1;
|
|
946
|
+
} else if (a.x > b.x) {
|
|
947
|
+
return 1;
|
|
948
|
+
} else if (a.y < b.y) {
|
|
949
|
+
return -1;
|
|
950
|
+
} else if (a.y > b.y) {
|
|
951
|
+
return 1;
|
|
952
|
+
} else {
|
|
953
|
+
return 0;
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
return getHullPresorted(newPoints);
|
|
957
|
+
};
|
|
958
|
+
var getHullPresorted = (points) => {
|
|
959
|
+
if (points.length <= 1) {
|
|
960
|
+
return points.slice();
|
|
961
|
+
}
|
|
962
|
+
const upperHull = [];
|
|
963
|
+
for (let i = 0; i < points.length; i++) {
|
|
964
|
+
const p = points[i];
|
|
965
|
+
while (upperHull.length >= 2) {
|
|
966
|
+
const q = upperHull[upperHull.length - 1];
|
|
967
|
+
const r = upperHull[upperHull.length - 2];
|
|
968
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) {
|
|
969
|
+
upperHull.pop();
|
|
970
|
+
} else {
|
|
971
|
+
break;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
upperHull.push(p);
|
|
975
|
+
}
|
|
976
|
+
upperHull.pop();
|
|
977
|
+
const lowerHull = [];
|
|
978
|
+
for (let i = points.length - 1; i >= 0; i--) {
|
|
979
|
+
const p = points[i];
|
|
980
|
+
while (lowerHull.length >= 2) {
|
|
981
|
+
const q = lowerHull[lowerHull.length - 1];
|
|
982
|
+
const r = lowerHull[lowerHull.length - 2];
|
|
983
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) {
|
|
984
|
+
lowerHull.pop();
|
|
985
|
+
} else {
|
|
986
|
+
break;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
lowerHull.push(p);
|
|
990
|
+
}
|
|
991
|
+
lowerHull.pop();
|
|
992
|
+
if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y) {
|
|
993
|
+
return upperHull;
|
|
994
|
+
} else {
|
|
995
|
+
return upperHull.concat(lowerHull);
|
|
996
|
+
}
|
|
997
|
+
};
|
|
458
998
|
var Tooltip = {
|
|
459
999
|
Provider: TooltipProvider,
|
|
460
|
-
|
|
461
|
-
Portal: TooltipPortal,
|
|
462
|
-
Trigger: TooltipTrigger,
|
|
463
|
-
Arrow: TooltipArrow,
|
|
464
|
-
Content: TooltipContent
|
|
1000
|
+
Trigger: TooltipTrigger
|
|
465
1001
|
};
|
|
466
1002
|
|
|
467
1003
|
// packages/ui/react-ui/src/components/Buttons/IconButton.tsx
|
|
468
|
-
var IconOnlyButton = /* @__PURE__ */ forwardRef8(({ noTooltip, tooltipPortal = true,
|
|
469
|
-
const [triggerTooltipOpen, setTriggerTooltipOpen] = useState4(false);
|
|
1004
|
+
var IconOnlyButton = /* @__PURE__ */ forwardRef8(({ noTooltip, tooltipPortal = true, tooltipSide, suppressNextTooltip, ...props }, forwardedRef) => {
|
|
470
1005
|
if (noTooltip) {
|
|
471
1006
|
return /* @__PURE__ */ React9.createElement(LabelledIconButton, {
|
|
472
1007
|
...props,
|
|
473
1008
|
ref: forwardedRef
|
|
474
1009
|
});
|
|
475
1010
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
},
|
|
482
|
-
side: tooltipSide
|
|
483
|
-
}, props.label, /* @__PURE__ */ React9.createElement(Tooltip.Arrow, null));
|
|
484
|
-
return /* @__PURE__ */ React9.createElement(Tooltip.Root, {
|
|
485
|
-
open: triggerTooltipOpen,
|
|
486
|
-
onOpenChange: (nextOpen) => {
|
|
487
|
-
if (suppressNextTooltip?.current) {
|
|
488
|
-
setTriggerTooltipOpen(false);
|
|
489
|
-
suppressNextTooltip.current = false;
|
|
490
|
-
} else {
|
|
491
|
-
setTriggerTooltipOpen(nextOpen);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
}, /* @__PURE__ */ React9.createElement(Tooltip.Trigger, {
|
|
495
|
-
asChild: true
|
|
1011
|
+
return /* @__PURE__ */ React9.createElement(Tooltip.Trigger, {
|
|
1012
|
+
asChild: true,
|
|
1013
|
+
content: props.label,
|
|
1014
|
+
side: tooltipSide,
|
|
1015
|
+
suppressNextTooltip
|
|
496
1016
|
}, /* @__PURE__ */ React9.createElement(LabelledIconButton, {
|
|
497
1017
|
...props,
|
|
498
1018
|
ref: forwardedRef
|
|
499
|
-
}))
|
|
1019
|
+
}));
|
|
500
1020
|
});
|
|
501
1021
|
var LabelledIconButton = /* @__PURE__ */ forwardRef8(({ icon, size, iconOnly, label, classNames, iconClassNames, caretDown, suppressNextTooltip, ...props }, forwardedRef) => {
|
|
502
1022
|
const { tx } = useThemeContext();
|
|
@@ -566,7 +1086,7 @@ var ToggleGroupItem = /* @__PURE__ */ forwardRef10(({ variant, elevation, densit
|
|
|
566
1086
|
});
|
|
567
1087
|
|
|
568
1088
|
// packages/ui/react-ui/src/components/Clipboard/ClipboardProvider.tsx
|
|
569
|
-
import React12, { createContext as createContext4, useCallback as
|
|
1089
|
+
import React12, { createContext as createContext4, useCallback as useCallback4, useContext as useContext6, useState as useState5 } from "react";
|
|
570
1090
|
var ClipboardContext = /* @__PURE__ */ createContext4({
|
|
571
1091
|
textValue: "",
|
|
572
1092
|
setTextValue: async (_) => {
|
|
@@ -575,7 +1095,7 @@ var ClipboardContext = /* @__PURE__ */ createContext4({
|
|
|
575
1095
|
var useClipboard = () => useContext6(ClipboardContext);
|
|
576
1096
|
var ClipboardProvider = ({ children }) => {
|
|
577
1097
|
const [textValue, setInternalTextValue] = useState5("");
|
|
578
|
-
const setTextValue =
|
|
1098
|
+
const setTextValue = useCallback4(async (nextValue) => {
|
|
579
1099
|
await navigator.clipboard.writeText(nextValue);
|
|
580
1100
|
return setInternalTextValue(nextValue);
|
|
581
1101
|
}, []);
|
|
@@ -588,12 +1108,12 @@ var ClipboardProvider = ({ children }) => {
|
|
|
588
1108
|
};
|
|
589
1109
|
|
|
590
1110
|
// packages/ui/react-ui/src/components/Clipboard/CopyButton.tsx
|
|
591
|
-
import React16
|
|
1111
|
+
import React16 from "react";
|
|
592
1112
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
593
1113
|
|
|
594
1114
|
// packages/ui/react-ui/src/components/ThemeProvider/ThemeProvider.tsx
|
|
595
1115
|
import { createKeyborg } from "keyborg";
|
|
596
|
-
import React15, { createContext as createContext7, useEffect as
|
|
1116
|
+
import React15, { createContext as createContext7, useEffect as useEffect3, useMemo as useMemo2 } from "react";
|
|
597
1117
|
|
|
598
1118
|
// packages/ui/react-ui/src/util/hasIosKeyboard.ts
|
|
599
1119
|
var hasIosKeyboard = () => {
|
|
@@ -625,7 +1145,7 @@ var ElevationProvider = ({ elevation, children }) => /* @__PURE__ */ React14.cre
|
|
|
625
1145
|
// packages/ui/react-ui/src/components/ThemeProvider/ThemeProvider.tsx
|
|
626
1146
|
var ThemeContext = /* @__PURE__ */ createContext7(void 0);
|
|
627
1147
|
var ThemeProvider = ({ children, fallback = null, resourceExtensions, appNs, tx = (_path, defaultClassName, _styleProps, ..._options) => defaultClassName, themeMode = "dark", rootDensity = "fine", ...rest }) => {
|
|
628
|
-
|
|
1148
|
+
useEffect3(() => {
|
|
629
1149
|
if (document.defaultView) {
|
|
630
1150
|
const kb = createKeyborg(document.defaultView);
|
|
631
1151
|
kb.subscribe(handleInputModalityChange);
|
|
@@ -699,36 +1219,25 @@ var CopyButton = ({ value, classNames, iconProps, ...props }) => {
|
|
|
699
1219
|
...iconProps
|
|
700
1220
|
})));
|
|
701
1221
|
};
|
|
702
|
-
var CopyButtonIconOnly = ({ value, classNames, iconProps, variant, ...props }) => {
|
|
1222
|
+
var CopyButtonIconOnly = ({ __scopeTooltip, value, classNames, iconProps, variant, ...props }) => {
|
|
703
1223
|
const { t } = useTranslation("os");
|
|
704
1224
|
const { textValue, setTextValue } = useClipboard();
|
|
705
1225
|
const isCopied = textValue === value;
|
|
706
1226
|
const label = isCopied ? t("copy success label") : props.label ?? t("copy label");
|
|
707
|
-
const
|
|
708
|
-
return /* @__PURE__ */ React16.createElement(
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
side: "bottom",
|
|
714
|
-
sideOffset: 12
|
|
715
|
-
}, /* @__PURE__ */ React16.createElement("span", null, label), /* @__PURE__ */ React16.createElement(Tooltip.Arrow, null))), /* @__PURE__ */ React16.createElement(Tooltip.Trigger, {
|
|
716
|
-
"aria-label": label,
|
|
717
|
-
...props,
|
|
718
|
-
onClick: () => setTextValue(value).then(() => setOpen(true)),
|
|
719
|
-
"data-testid": "copy-invitation",
|
|
720
|
-
asChild: true
|
|
721
|
-
}, /* @__PURE__ */ React16.createElement(Button, {
|
|
1227
|
+
const { onOpen } = useTooltipContext("CopyButton", __scopeTooltip);
|
|
1228
|
+
return /* @__PURE__ */ React16.createElement(IconButton, {
|
|
1229
|
+
iconOnly: true,
|
|
1230
|
+
label,
|
|
1231
|
+
icon: "ph--copy--regular",
|
|
1232
|
+
size: 5,
|
|
722
1233
|
variant,
|
|
723
1234
|
classNames: [
|
|
724
1235
|
"inline-flex flex-col justify-center",
|
|
725
1236
|
classNames
|
|
726
|
-
]
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
...iconProps
|
|
731
|
-
}))));
|
|
1237
|
+
],
|
|
1238
|
+
onClick: () => setTextValue(value).then(onOpen),
|
|
1239
|
+
"data-testid": "copy-invitation"
|
|
1240
|
+
});
|
|
732
1241
|
};
|
|
733
1242
|
|
|
734
1243
|
// packages/ui/react-ui/src/components/Clipboard/index.ts
|
|
@@ -770,9 +1279,7 @@ var DialogDescription = /* @__PURE__ */ forwardRef11(({ classNames, srOnly, ...p
|
|
|
770
1279
|
var DialogClose = DialogClosePrimitive;
|
|
771
1280
|
var DIALOG_OVERLAY_NAME = "DialogOverlay";
|
|
772
1281
|
var DIALOG_CONTENT_NAME = "DialogContent";
|
|
773
|
-
var [OverlayLayoutProvider, useOverlayLayoutContext] = createContext8(DIALOG_OVERLAY_NAME, {
|
|
774
|
-
inOverlayLayout: false
|
|
775
|
-
});
|
|
1282
|
+
var [OverlayLayoutProvider, useOverlayLayoutContext] = createContext8(DIALOG_OVERLAY_NAME, {});
|
|
776
1283
|
var DialogOverlay = /* @__PURE__ */ forwardRef11(({ classNames, children, blockAlign, ...props }, forwardedRef) => {
|
|
777
1284
|
const { tx } = useThemeContext();
|
|
778
1285
|
return /* @__PURE__ */ React17.createElement(DialogOverlayPrimitive, {
|
|
@@ -789,6 +1296,8 @@ var DialogContent = /* @__PURE__ */ forwardRef11(({ classNames, children, inOver
|
|
|
789
1296
|
const { tx } = useThemeContext();
|
|
790
1297
|
const { inOverlayLayout } = useOverlayLayoutContext(DIALOG_CONTENT_NAME);
|
|
791
1298
|
return /* @__PURE__ */ React17.createElement(DialogContentPrimitive, {
|
|
1299
|
+
// NOTE: Radix warning unless set to undefined.
|
|
1300
|
+
// https://www.radix-ui.com/primitives/docs/components/dialog#description
|
|
792
1301
|
"aria-describedby": void 0,
|
|
793
1302
|
...props,
|
|
794
1303
|
className: tx("dialog.content", "dialog", {
|
|
@@ -883,8 +1392,8 @@ var AlertDialog = {
|
|
|
883
1392
|
|
|
884
1393
|
// packages/ui/react-ui/src/components/Input/Input.tsx
|
|
885
1394
|
import { Root as CheckboxPrimitive } from "@radix-ui/react-checkbox";
|
|
886
|
-
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
887
|
-
import React19, { forwardRef as forwardRef13, useCallback as
|
|
1395
|
+
import { useControllableState as useControllableState2 } from "@radix-ui/react-use-controllable-state";
|
|
1396
|
+
import React19, { forwardRef as forwardRef13, useCallback as useCallback5 } from "react";
|
|
888
1397
|
import { InputRoot, PinInput as PinInputPrimitive, TextInput as TextInputPrimitive, TextArea as TextAreaPrimitive, useInputContext, INPUT_NAME, Description as DescriptionPrimitive, DescriptionAndValidation as DescriptionAndValidationPrimitive, Label as LabelPrimitive, Validation as ValidationPrimitive } from "@dxos/react-input";
|
|
889
1398
|
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
890
1399
|
var Label = /* @__PURE__ */ forwardRef13(({ srOnly, classNames, children, ...props }, forwardedRef) => {
|
|
@@ -934,7 +1443,7 @@ var PinInput = /* @__PURE__ */ forwardRef13(({ density: propsDensity, elevation:
|
|
|
934
1443
|
const { tx } = useThemeContext();
|
|
935
1444
|
const density = useDensityContext(propsDensity);
|
|
936
1445
|
const elevation = useElevationContext(propsElevation);
|
|
937
|
-
const segmentClassName =
|
|
1446
|
+
const segmentClassName = useCallback5(({ focused, validationValence }) => tx("input.input", "input--pin-segment", {
|
|
938
1447
|
variant: "static",
|
|
939
1448
|
focused,
|
|
940
1449
|
disabled: props.disabled,
|
|
@@ -1004,7 +1513,7 @@ var TextArea = /* @__PURE__ */ forwardRef13(({ __inputScope, classNames, density
|
|
|
1004
1513
|
});
|
|
1005
1514
|
});
|
|
1006
1515
|
var Checkbox = /* @__PURE__ */ forwardRef13(({ __inputScope, checked: propsChecked, defaultChecked: propsDefaultChecked, onCheckedChange: propsOnCheckedChange, size, weight = "bold", classNames, ...props }, forwardedRef) => {
|
|
1007
|
-
const [checked, onCheckedChange] =
|
|
1516
|
+
const [checked, onCheckedChange] = useControllableState2({
|
|
1008
1517
|
prop: propsChecked,
|
|
1009
1518
|
defaultProp: propsDefaultChecked,
|
|
1010
1519
|
onChange: propsOnCheckedChange
|
|
@@ -1034,7 +1543,7 @@ var Checkbox = /* @__PURE__ */ forwardRef13(({ __inputScope, checked: propsCheck
|
|
|
1034
1543
|
}));
|
|
1035
1544
|
});
|
|
1036
1545
|
var Switch = /* @__PURE__ */ forwardRef13(({ __inputScope, checked: propsChecked, defaultChecked: propsDefaultChecked, onCheckedChange: propsOnCheckedChange, classNames, ...props }, forwardedRef) => {
|
|
1037
|
-
const [checked, onCheckedChange] =
|
|
1546
|
+
const [checked, onCheckedChange] = useControllableState2({
|
|
1038
1547
|
prop: propsChecked,
|
|
1039
1548
|
defaultProp: propsDefaultChecked ?? false,
|
|
1040
1549
|
onChange: propsOnCheckedChange
|
|
@@ -1127,10 +1636,10 @@ var List = /* @__PURE__ */ forwardRef14(({ classNames, children, ...props }, for
|
|
|
1127
1636
|
}, children));
|
|
1128
1637
|
});
|
|
1129
1638
|
var ListItemEndcap = /* @__PURE__ */ forwardRef14(({ children, classNames, asChild, ...props }, forwardedRef) => {
|
|
1130
|
-
const
|
|
1639
|
+
const Root7 = asChild ? Slot6 : "div";
|
|
1131
1640
|
const density = useDensityContext();
|
|
1132
1641
|
const { tx } = useThemeContext();
|
|
1133
|
-
return /* @__PURE__ */ React21.createElement(
|
|
1642
|
+
return /* @__PURE__ */ React21.createElement(Root7, {
|
|
1134
1643
|
...!asChild && {
|
|
1135
1644
|
role: "none"
|
|
1136
1645
|
},
|
|
@@ -1290,25 +1799,25 @@ var TreeItem = {
|
|
|
1290
1799
|
|
|
1291
1800
|
// packages/ui/react-ui/src/components/Lists/Treegrid.tsx
|
|
1292
1801
|
import { useArrowNavigationGroup, useFocusableGroup } from "@fluentui/react-tabster";
|
|
1293
|
-
import { createContextScope } from "@radix-ui/react-context";
|
|
1294
|
-
import { Primitive as
|
|
1802
|
+
import { createContextScope as createContextScope2 } from "@radix-ui/react-context";
|
|
1803
|
+
import { Primitive as Primitive7 } from "@radix-ui/react-primitive";
|
|
1295
1804
|
import { Slot as Slot7 } from "@radix-ui/react-slot";
|
|
1296
|
-
import { useControllableState as
|
|
1805
|
+
import { useControllableState as useControllableState3 } from "@radix-ui/react-use-controllable-state";
|
|
1297
1806
|
import React24, { forwardRef as forwardRef16 } from "react";
|
|
1298
1807
|
var TREEGRID_ROW_NAME = "TreegridRow";
|
|
1299
|
-
var [createTreegridRowContext, createTreegridRowScope] =
|
|
1808
|
+
var [createTreegridRowContext, createTreegridRowScope] = createContextScope2(TREEGRID_ROW_NAME, []);
|
|
1300
1809
|
var [TreegridRowProvider, useTreegridRowContext] = createTreegridRowContext(TREEGRID_ROW_NAME);
|
|
1301
1810
|
var PATH_SEPARATOR = "~";
|
|
1302
1811
|
var PARENT_OF_SEPARATOR = " ";
|
|
1303
1812
|
var TreegridRoot = /* @__PURE__ */ forwardRef16(({ asChild, classNames, children, style, gridTemplateColumns, ...props }, forwardedRef) => {
|
|
1304
1813
|
const { tx } = useThemeContext();
|
|
1305
|
-
const
|
|
1814
|
+
const Root7 = asChild ? Slot7 : Primitive7.div;
|
|
1306
1815
|
const arrowNavigationAttrs = useArrowNavigationGroup({
|
|
1307
1816
|
axis: "vertical",
|
|
1308
1817
|
tabbable: false,
|
|
1309
1818
|
circular: true
|
|
1310
1819
|
});
|
|
1311
|
-
return /* @__PURE__ */ React24.createElement(
|
|
1820
|
+
return /* @__PURE__ */ React24.createElement(Root7, {
|
|
1312
1821
|
role: "treegrid",
|
|
1313
1822
|
...arrowNavigationAttrs,
|
|
1314
1823
|
...props,
|
|
@@ -1322,10 +1831,10 @@ var TreegridRoot = /* @__PURE__ */ forwardRef16(({ asChild, classNames, children
|
|
|
1322
1831
|
});
|
|
1323
1832
|
var TreegridRow = /* @__PURE__ */ forwardRef16(({ __treegridRowScope, asChild, classNames, children, id, parentOf, open: propsOpen, defaultOpen, onOpenChange: propsOnOpenChange, ...props }, forwardedRef) => {
|
|
1324
1833
|
const { tx } = useThemeContext();
|
|
1325
|
-
const
|
|
1834
|
+
const Root7 = asChild ? Slot7 : Primitive7.div;
|
|
1326
1835
|
const pathParts = id.split(PATH_SEPARATOR);
|
|
1327
1836
|
const level = pathParts.length - 1;
|
|
1328
|
-
const [open, onOpenChange] =
|
|
1837
|
+
const [open, onOpenChange] = useControllableState3({
|
|
1329
1838
|
prop: propsOpen,
|
|
1330
1839
|
onChange: propsOnOpenChange,
|
|
1331
1840
|
defaultProp: defaultOpen
|
|
@@ -1343,7 +1852,7 @@ var TreegridRow = /* @__PURE__ */ forwardRef16(({ __treegridRowScope, asChild, c
|
|
|
1343
1852
|
open,
|
|
1344
1853
|
onOpenChange,
|
|
1345
1854
|
scope: __treegridRowScope
|
|
1346
|
-
}, /* @__PURE__ */ React24.createElement(
|
|
1855
|
+
}, /* @__PURE__ */ React24.createElement(Root7, {
|
|
1347
1856
|
role: "row",
|
|
1348
1857
|
"aria-level": level,
|
|
1349
1858
|
className: tx("treegrid.row", "treegrid__row", {
|
|
@@ -1388,15 +1897,15 @@ var Treegrid = {
|
|
|
1388
1897
|
// packages/ui/react-ui/src/components/Main/Main.tsx
|
|
1389
1898
|
import { createContext as createContext10 } from "@radix-ui/react-context";
|
|
1390
1899
|
import { Root as DialogRoot2, DialogContent as DialogContent2, DialogTitle as DialogTitle2 } from "@radix-ui/react-dialog";
|
|
1391
|
-
import { Primitive as
|
|
1900
|
+
import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
|
|
1392
1901
|
import { Slot as Slot8 } from "@radix-ui/react-slot";
|
|
1393
|
-
import { useControllableState as
|
|
1394
|
-
import React25, { forwardRef as forwardRef17, useCallback as
|
|
1902
|
+
import { useControllableState as useControllableState4 } from "@radix-ui/react-use-controllable-state";
|
|
1903
|
+
import React25, { forwardRef as forwardRef17, useCallback as useCallback7, useEffect as useEffect5, useRef as useRef2, useState as useState7 } from "react";
|
|
1395
1904
|
import { log } from "@dxos/log";
|
|
1396
1905
|
import { useMediaQuery, useForwardedRef } from "@dxos/react-hooks";
|
|
1397
1906
|
|
|
1398
1907
|
// packages/ui/react-ui/src/components/Main/useSwipeToDismiss.ts
|
|
1399
|
-
import { useCallback as
|
|
1908
|
+
import { useCallback as useCallback6, useEffect as useEffect4, useState as useState6 } from "react";
|
|
1400
1909
|
var MotionState;
|
|
1401
1910
|
(function(MotionState2) {
|
|
1402
1911
|
MotionState2[MotionState2["IDLE"] = 0] = "IDLE";
|
|
@@ -1411,22 +1920,22 @@ var useSwipeToDismiss = (ref, {
|
|
|
1411
1920
|
/* side = 'inline-start' */
|
|
1412
1921
|
}) => {
|
|
1413
1922
|
const $root = ref.current;
|
|
1414
|
-
const [motionState, setMotionState] =
|
|
1415
|
-
const [gestureStartX, setGestureStartX] =
|
|
1416
|
-
const setIdle =
|
|
1923
|
+
const [motionState, setMotionState] = useState6(0);
|
|
1924
|
+
const [gestureStartX, setGestureStartX] = useState6(0);
|
|
1925
|
+
const setIdle = useCallback6(() => {
|
|
1417
1926
|
setMotionState(0);
|
|
1418
1927
|
$root?.style.removeProperty("inset-inline-start");
|
|
1419
1928
|
$root?.style.setProperty("transition-duration", "200ms");
|
|
1420
1929
|
}, [
|
|
1421
1930
|
$root
|
|
1422
1931
|
]);
|
|
1423
|
-
const setFollowing =
|
|
1932
|
+
const setFollowing = useCallback6(() => {
|
|
1424
1933
|
setMotionState(2);
|
|
1425
1934
|
$root?.style.setProperty("transition-duration", "0ms");
|
|
1426
1935
|
}, [
|
|
1427
1936
|
$root
|
|
1428
1937
|
]);
|
|
1429
|
-
const handlePointerDown =
|
|
1938
|
+
const handlePointerDown = useCallback6(({ screenX }) => {
|
|
1430
1939
|
if (motionState === 0) {
|
|
1431
1940
|
setMotionState(1);
|
|
1432
1941
|
setGestureStartX(screenX);
|
|
@@ -1434,7 +1943,7 @@ var useSwipeToDismiss = (ref, {
|
|
|
1434
1943
|
}, [
|
|
1435
1944
|
motionState
|
|
1436
1945
|
]);
|
|
1437
|
-
const handlePointerMove =
|
|
1946
|
+
const handlePointerMove = useCallback6(({ screenX }) => {
|
|
1438
1947
|
if ($root) {
|
|
1439
1948
|
const delta = Math.min(screenX - gestureStartX, 0);
|
|
1440
1949
|
switch (motionState) {
|
|
@@ -1458,12 +1967,12 @@ var useSwipeToDismiss = (ref, {
|
|
|
1458
1967
|
motionState,
|
|
1459
1968
|
gestureStartX
|
|
1460
1969
|
]);
|
|
1461
|
-
const handlePointerUp =
|
|
1970
|
+
const handlePointerUp = useCallback6(() => {
|
|
1462
1971
|
setIdle();
|
|
1463
1972
|
}, [
|
|
1464
1973
|
setIdle
|
|
1465
1974
|
]);
|
|
1466
|
-
|
|
1975
|
+
useEffect4(() => {
|
|
1467
1976
|
$root?.addEventListener("pointerdown", handlePointerDown);
|
|
1468
1977
|
return () => {
|
|
1469
1978
|
$root?.removeEventListener("pointerdown", handlePointerDown);
|
|
@@ -1472,7 +1981,7 @@ var useSwipeToDismiss = (ref, {
|
|
|
1472
1981
|
$root,
|
|
1473
1982
|
handlePointerDown
|
|
1474
1983
|
]);
|
|
1475
|
-
|
|
1984
|
+
useEffect4(() => {
|
|
1476
1985
|
$root && document.documentElement.addEventListener("pointermove", handlePointerMove);
|
|
1477
1986
|
return () => {
|
|
1478
1987
|
document.documentElement.removeEventListener("pointermove", handlePointerMove);
|
|
@@ -1481,7 +1990,7 @@ var useSwipeToDismiss = (ref, {
|
|
|
1481
1990
|
$root,
|
|
1482
1991
|
handlePointerMove
|
|
1483
1992
|
]);
|
|
1484
|
-
|
|
1993
|
+
useEffect4(() => {
|
|
1485
1994
|
$root && document.documentElement.addEventListener("pointerup", handlePointerUp);
|
|
1486
1995
|
return () => {
|
|
1487
1996
|
document.documentElement.removeEventListener("pointerup", handlePointerUp);
|
|
@@ -1501,7 +2010,7 @@ var MAIN_NAME = "Main";
|
|
|
1501
2010
|
var GENERIC_CONSUMER_NAME = "GenericConsumer";
|
|
1502
2011
|
var landmarkAttr = "data-main-landmark";
|
|
1503
2012
|
var useLandmarkMover = (propsOnKeyDown, landmark) => {
|
|
1504
|
-
const handleKeyDown =
|
|
2013
|
+
const handleKeyDown = useCallback7((event) => {
|
|
1505
2014
|
const target = event.target;
|
|
1506
2015
|
if (event.target === event.currentTarget && event.key === "Tab" && target.hasAttribute(landmarkAttr)) {
|
|
1507
2016
|
event.preventDefault();
|
|
@@ -1554,22 +2063,22 @@ var useSidebars = (consumerName = GENERIC_CONSUMER_NAME) => {
|
|
|
1554
2063
|
return {
|
|
1555
2064
|
navigationSidebarState,
|
|
1556
2065
|
setNavigationSidebarState,
|
|
1557
|
-
toggleNavigationSidebar:
|
|
2066
|
+
toggleNavigationSidebar: useCallback7(() => setNavigationSidebarState(navigationSidebarState === "expanded" ? "closed" : "expanded"), [
|
|
1558
2067
|
navigationSidebarState,
|
|
1559
2068
|
setNavigationSidebarState
|
|
1560
2069
|
]),
|
|
1561
|
-
openNavigationSidebar:
|
|
1562
|
-
collapseNavigationSidebar:
|
|
1563
|
-
closeNavigationSidebar:
|
|
2070
|
+
openNavigationSidebar: useCallback7(() => setNavigationSidebarState("expanded"), []),
|
|
2071
|
+
collapseNavigationSidebar: useCallback7(() => setNavigationSidebarState("collapsed"), []),
|
|
2072
|
+
closeNavigationSidebar: useCallback7(() => setNavigationSidebarState("closed"), []),
|
|
1564
2073
|
complementarySidebarState,
|
|
1565
2074
|
setComplementarySidebarState,
|
|
1566
|
-
toggleComplementarySidebar:
|
|
2075
|
+
toggleComplementarySidebar: useCallback7(() => setComplementarySidebarState(complementarySidebarState === "expanded" ? "closed" : "expanded"), [
|
|
1567
2076
|
complementarySidebarState,
|
|
1568
2077
|
setComplementarySidebarState
|
|
1569
2078
|
]),
|
|
1570
|
-
openComplementarySidebar:
|
|
1571
|
-
collapseComplementarySidebar:
|
|
1572
|
-
closeComplementarySidebar:
|
|
2079
|
+
openComplementarySidebar: useCallback7(() => setComplementarySidebarState("expanded"), []),
|
|
2080
|
+
collapseComplementarySidebar: useCallback7(() => setComplementarySidebarState("collapsed"), []),
|
|
2081
|
+
closeComplementarySidebar: useCallback7(() => setComplementarySidebarState("closed"), [])
|
|
1573
2082
|
};
|
|
1574
2083
|
};
|
|
1575
2084
|
var resizeDebounce = 3e3;
|
|
@@ -1577,19 +2086,19 @@ var MainRoot = ({ navigationSidebarState: propsNavigationSidebarState, defaultNa
|
|
|
1577
2086
|
const [isLg] = useMediaQuery("lg", {
|
|
1578
2087
|
ssr: false
|
|
1579
2088
|
});
|
|
1580
|
-
const [navigationSidebarState = isLg ? "expanded" : "collapsed", setNavigationSidebarState] =
|
|
2089
|
+
const [navigationSidebarState = isLg ? "expanded" : "collapsed", setNavigationSidebarState] = useControllableState4({
|
|
1581
2090
|
prop: propsNavigationSidebarState,
|
|
1582
2091
|
defaultProp: defaultNavigationSidebarState,
|
|
1583
2092
|
onChange: onNavigationSidebarStateChange
|
|
1584
2093
|
});
|
|
1585
|
-
const [complementarySidebarState = isLg ? "expanded" : "collapsed", setComplementarySidebarState] =
|
|
2094
|
+
const [complementarySidebarState = isLg ? "expanded" : "collapsed", setComplementarySidebarState] = useControllableState4({
|
|
1586
2095
|
prop: propsComplementarySidebarState,
|
|
1587
2096
|
defaultProp: defaultComplementarySidebarState,
|
|
1588
2097
|
onChange: onComplementarySidebarStateChange
|
|
1589
2098
|
});
|
|
1590
|
-
const [resizing, setResizing] =
|
|
1591
|
-
const resizeInterval =
|
|
1592
|
-
const handleResize =
|
|
2099
|
+
const [resizing, setResizing] = useState7(false);
|
|
2100
|
+
const resizeInterval = useRef2(null);
|
|
2101
|
+
const handleResize = useCallback7(() => {
|
|
1593
2102
|
setResizing(true);
|
|
1594
2103
|
if (resizeInterval.current) {
|
|
1595
2104
|
clearTimeout(resizeInterval.current);
|
|
@@ -1599,7 +2108,7 @@ var MainRoot = ({ navigationSidebarState: propsNavigationSidebarState, defaultNa
|
|
|
1599
2108
|
resizeInterval.current = null;
|
|
1600
2109
|
}, resizeDebounce);
|
|
1601
2110
|
}, []);
|
|
1602
|
-
|
|
2111
|
+
useEffect5(() => {
|
|
1603
2112
|
window.addEventListener("resize", handleResize);
|
|
1604
2113
|
return () => window.removeEventListener("resize", handleResize);
|
|
1605
2114
|
}, [
|
|
@@ -1625,11 +2134,11 @@ var MainSidebar = /* @__PURE__ */ forwardRef17(({ classNames, children, swipeToD
|
|
|
1625
2134
|
const { tx } = useThemeContext();
|
|
1626
2135
|
const { t } = useTranslation();
|
|
1627
2136
|
const ref = useForwardedRef(forwardedRef);
|
|
1628
|
-
const noopRef =
|
|
2137
|
+
const noopRef = useRef2(null);
|
|
1629
2138
|
useSwipeToDismiss(swipeToDismiss ? ref : noopRef, {
|
|
1630
2139
|
onDismiss: () => onStateChange?.("closed")
|
|
1631
2140
|
});
|
|
1632
|
-
const handleKeyDown =
|
|
2141
|
+
const handleKeyDown = useCallback7((event) => {
|
|
1633
2142
|
if (event.key === "Escape") {
|
|
1634
2143
|
event.target.closest("[data-tabster]")?.focus();
|
|
1635
2144
|
}
|
|
@@ -1637,14 +2146,14 @@ var MainSidebar = /* @__PURE__ */ forwardRef17(({ classNames, children, swipeToD
|
|
|
1637
2146
|
}, [
|
|
1638
2147
|
props.onKeyDown
|
|
1639
2148
|
]);
|
|
1640
|
-
const
|
|
2149
|
+
const Root7 = isLg ? Primitive8.div : DialogContent2;
|
|
1641
2150
|
return /* @__PURE__ */ React25.createElement(DialogRoot2, {
|
|
1642
2151
|
open: state !== "closed",
|
|
1643
2152
|
"aria-label": toLocalizedString(label, t),
|
|
1644
2153
|
modal: false
|
|
1645
2154
|
}, !isLg && /* @__PURE__ */ React25.createElement(DialogTitle2, {
|
|
1646
2155
|
className: "sr-only"
|
|
1647
|
-
}, toLocalizedString(label, t)), /* @__PURE__ */ React25.createElement(
|
|
2156
|
+
}, toLocalizedString(label, t)), /* @__PURE__ */ React25.createElement(Root7, {
|
|
1648
2157
|
...!isLg && {
|
|
1649
2158
|
forceMount: true,
|
|
1650
2159
|
tabIndex: -1,
|
|
@@ -1693,9 +2202,9 @@ MainNavigationSidebar.displayName = NAVIGATION_SIDEBAR_NAME;
|
|
|
1693
2202
|
var MainContent = /* @__PURE__ */ forwardRef17(({ asChild, classNames, bounce, handlesFocus, children, role, ...props }, forwardedRef) => {
|
|
1694
2203
|
const { navigationSidebarState, complementarySidebarState } = useMainContext(MAIN_NAME);
|
|
1695
2204
|
const { tx } = useThemeContext();
|
|
1696
|
-
const
|
|
2205
|
+
const Root7 = asChild ? Slot8 : role ? "div" : "main";
|
|
1697
2206
|
const mover = useLandmarkMover(props.onKeyDown, "1");
|
|
1698
|
-
return /* @__PURE__ */ React25.createElement(
|
|
2207
|
+
return /* @__PURE__ */ React25.createElement(Root7, {
|
|
1699
2208
|
role,
|
|
1700
2209
|
...handlesFocus && {
|
|
1701
2210
|
...mover
|
|
@@ -1743,9 +2252,31 @@ var Main = {
|
|
|
1743
2252
|
|
|
1744
2253
|
// packages/ui/react-ui/src/components/Menus/ContextMenu.tsx
|
|
1745
2254
|
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
|
1746
|
-
import { Primitive as
|
|
2255
|
+
import { Primitive as Primitive9 } from "@radix-ui/react-primitive";
|
|
1747
2256
|
import { Slot as Slot9 } from "@radix-ui/react-slot";
|
|
1748
2257
|
import React26, { forwardRef as forwardRef18 } from "react";
|
|
2258
|
+
|
|
2259
|
+
// packages/ui/react-ui/src/hooks/useSafeCollisionPadding.ts
|
|
2260
|
+
import { useMemo as useMemo3 } from "react";
|
|
2261
|
+
var propIsNumber = (prop) => Number.isFinite(prop);
|
|
2262
|
+
var propsIsRecord = (prop) => !!(prop && typeof prop === "object");
|
|
2263
|
+
var safePadding = (propsPadding, safePadding2, side) => {
|
|
2264
|
+
return (propIsNumber(safePadding2[side]) ? safePadding2[side] : 0) + (propIsNumber(propsPadding) ? propsPadding : propsIsRecord(propsPadding) ? propsPadding[side] ?? 0 : 0);
|
|
2265
|
+
};
|
|
2266
|
+
var useSafeCollisionPadding = (collisionPadding) => {
|
|
2267
|
+
const { safeAreaPadding } = useThemeContext();
|
|
2268
|
+
return useMemo3(() => ({
|
|
2269
|
+
top: safePadding(collisionPadding, safeAreaPadding, "top"),
|
|
2270
|
+
right: safePadding(collisionPadding, safeAreaPadding, "right"),
|
|
2271
|
+
bottom: safePadding(collisionPadding, safeAreaPadding, "bottom"),
|
|
2272
|
+
left: safePadding(collisionPadding, safeAreaPadding, "left")
|
|
2273
|
+
}), [
|
|
2274
|
+
collisionPadding,
|
|
2275
|
+
safeAreaPadding
|
|
2276
|
+
]);
|
|
2277
|
+
};
|
|
2278
|
+
|
|
2279
|
+
// packages/ui/react-ui/src/components/Menus/ContextMenu.tsx
|
|
1749
2280
|
var ContextMenuRoot = ContextMenuPrimitive.ContextMenu;
|
|
1750
2281
|
var ContextMenuTrigger = ContextMenuPrimitive.Trigger;
|
|
1751
2282
|
var ContextMenuPortal = ContextMenuPrimitive.Portal;
|
|
@@ -1764,8 +2295,8 @@ var ContextMenuContent = /* @__PURE__ */ forwardRef18(({ classNames, children, c
|
|
|
1764
2295
|
});
|
|
1765
2296
|
var ContextMenuViewport = /* @__PURE__ */ forwardRef18(({ classNames, asChild, children, ...props }, forwardedRef) => {
|
|
1766
2297
|
const { tx } = useThemeContext();
|
|
1767
|
-
const
|
|
1768
|
-
return /* @__PURE__ */ React26.createElement(
|
|
2298
|
+
const Root7 = asChild ? Slot9 : Primitive9.div;
|
|
2299
|
+
return /* @__PURE__ */ React26.createElement(Root7, {
|
|
1769
2300
|
...props,
|
|
1770
2301
|
className: tx("menu.viewport", "menu__viewport", {}, classNames),
|
|
1771
2302
|
ref: forwardedRef
|
|
@@ -1829,18 +2360,18 @@ var ContextMenu2 = {
|
|
|
1829
2360
|
};
|
|
1830
2361
|
|
|
1831
2362
|
// packages/ui/react-ui/src/components/Menus/DropdownMenu.tsx
|
|
1832
|
-
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
2363
|
+
import { composeEventHandlers as composeEventHandlers2 } from "@radix-ui/primitive";
|
|
1833
2364
|
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
1834
|
-
import { createContextScope as
|
|
1835
|
-
import { useId as
|
|
2365
|
+
import { createContextScope as createContextScope3 } from "@radix-ui/react-context";
|
|
2366
|
+
import { useId as useId3 } from "@radix-ui/react-id";
|
|
1836
2367
|
import * as MenuPrimitive from "@radix-ui/react-menu";
|
|
1837
2368
|
import { createMenuScope } from "@radix-ui/react-menu";
|
|
1838
|
-
import { Primitive as
|
|
2369
|
+
import { Primitive as Primitive10 } from "@radix-ui/react-primitive";
|
|
1839
2370
|
import { Slot as Slot10 } from "@radix-ui/react-slot";
|
|
1840
|
-
import { useControllableState as
|
|
1841
|
-
import React27, { useRef as
|
|
2371
|
+
import { useControllableState as useControllableState5 } from "@radix-ui/react-use-controllable-state";
|
|
2372
|
+
import React27, { useRef as useRef3, useCallback as useCallback8, forwardRef as forwardRef19, useEffect as useEffect6 } from "react";
|
|
1842
2373
|
var DROPDOWN_MENU_NAME = "DropdownMenu";
|
|
1843
|
-
var [createDropdownMenuContext, createDropdownMenuScope] =
|
|
2374
|
+
var [createDropdownMenuContext, createDropdownMenuScope] = createContextScope3(DROPDOWN_MENU_NAME, [
|
|
1844
2375
|
createMenuScope
|
|
1845
2376
|
]);
|
|
1846
2377
|
var useMenuScope = createMenuScope();
|
|
@@ -1848,20 +2379,20 @@ var [DropdownMenuProvider, useDropdownMenuContext] = createDropdownMenuContext(D
|
|
|
1848
2379
|
var DropdownMenuRoot = (props) => {
|
|
1849
2380
|
const { __scopeDropdownMenu, children, dir, open: openProp, defaultOpen, onOpenChange, modal = true } = props;
|
|
1850
2381
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1851
|
-
const triggerRef =
|
|
1852
|
-
const [open = false, setOpen] =
|
|
2382
|
+
const triggerRef = useRef3(null);
|
|
2383
|
+
const [open = false, setOpen] = useControllableState5({
|
|
1853
2384
|
prop: openProp,
|
|
1854
2385
|
defaultProp: defaultOpen,
|
|
1855
2386
|
onChange: onOpenChange
|
|
1856
2387
|
});
|
|
1857
2388
|
return /* @__PURE__ */ React27.createElement(DropdownMenuProvider, {
|
|
1858
2389
|
scope: __scopeDropdownMenu,
|
|
1859
|
-
triggerId:
|
|
2390
|
+
triggerId: useId3(),
|
|
1860
2391
|
triggerRef,
|
|
1861
|
-
contentId:
|
|
2392
|
+
contentId: useId3(),
|
|
1862
2393
|
open,
|
|
1863
2394
|
onOpenChange: setOpen,
|
|
1864
|
-
onOpenToggle:
|
|
2395
|
+
onOpenToggle: useCallback8(() => setOpen((prevOpen) => !prevOpen), [
|
|
1865
2396
|
setOpen
|
|
1866
2397
|
]),
|
|
1867
2398
|
modal
|
|
@@ -1874,15 +2405,15 @@ var DropdownMenuRoot = (props) => {
|
|
|
1874
2405
|
}, children));
|
|
1875
2406
|
};
|
|
1876
2407
|
DropdownMenuRoot.displayName = DROPDOWN_MENU_NAME;
|
|
1877
|
-
var
|
|
2408
|
+
var TRIGGER_NAME2 = "DropdownMenuTrigger";
|
|
1878
2409
|
var DropdownMenuTrigger = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
|
|
1879
2410
|
const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props;
|
|
1880
|
-
const context = useDropdownMenuContext(
|
|
2411
|
+
const context = useDropdownMenuContext(TRIGGER_NAME2, __scopeDropdownMenu);
|
|
1881
2412
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1882
2413
|
return /* @__PURE__ */ React27.createElement(MenuPrimitive.Anchor, {
|
|
1883
2414
|
asChild: true,
|
|
1884
2415
|
...menuScope
|
|
1885
|
-
}, /* @__PURE__ */ React27.createElement(
|
|
2416
|
+
}, /* @__PURE__ */ React27.createElement(Primitive10.button, {
|
|
1886
2417
|
type: "button",
|
|
1887
2418
|
id: context.triggerId,
|
|
1888
2419
|
"aria-haspopup": "menu",
|
|
@@ -1893,7 +2424,7 @@ var DropdownMenuTrigger = /* @__PURE__ */ forwardRef19((props, forwardedRef) =>
|
|
|
1893
2424
|
disabled,
|
|
1894
2425
|
...triggerProps,
|
|
1895
2426
|
ref: composeRefs(forwardedRef, context.triggerRef),
|
|
1896
|
-
onPointerDown:
|
|
2427
|
+
onPointerDown: composeEventHandlers2(props.onPointerDown, (event) => {
|
|
1897
2428
|
if (!disabled && event.button === 0 && event.ctrlKey === false) {
|
|
1898
2429
|
context.onOpenToggle();
|
|
1899
2430
|
if (!context.open) {
|
|
@@ -1901,7 +2432,7 @@ var DropdownMenuTrigger = /* @__PURE__ */ forwardRef19((props, forwardedRef) =>
|
|
|
1901
2432
|
}
|
|
1902
2433
|
}
|
|
1903
2434
|
}),
|
|
1904
|
-
onKeyDown:
|
|
2435
|
+
onKeyDown: composeEventHandlers2(props.onKeyDown, (event) => {
|
|
1905
2436
|
if (disabled) {
|
|
1906
2437
|
return;
|
|
1907
2438
|
}
|
|
@@ -1924,13 +2455,13 @@ var DropdownMenuTrigger = /* @__PURE__ */ forwardRef19((props, forwardedRef) =>
|
|
|
1924
2455
|
})
|
|
1925
2456
|
}));
|
|
1926
2457
|
});
|
|
1927
|
-
DropdownMenuTrigger.displayName =
|
|
2458
|
+
DropdownMenuTrigger.displayName = TRIGGER_NAME2;
|
|
1928
2459
|
var VIRTUAL_TRIGGER_NAME = "DropdownMenuVirtualTrigger";
|
|
1929
2460
|
var DropdownMenuVirtualTrigger = (props) => {
|
|
1930
2461
|
const { __scopeDropdownMenu, virtualRef } = props;
|
|
1931
2462
|
const context = useDropdownMenuContext(VIRTUAL_TRIGGER_NAME, __scopeDropdownMenu);
|
|
1932
2463
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1933
|
-
|
|
2464
|
+
useEffect6(() => {
|
|
1934
2465
|
if (virtualRef.current) {
|
|
1935
2466
|
context.triggerRef.current = virtualRef.current;
|
|
1936
2467
|
}
|
|
@@ -1941,7 +2472,7 @@ var DropdownMenuVirtualTrigger = (props) => {
|
|
|
1941
2472
|
});
|
|
1942
2473
|
};
|
|
1943
2474
|
DropdownMenuVirtualTrigger.displayName = VIRTUAL_TRIGGER_NAME;
|
|
1944
|
-
var
|
|
2475
|
+
var PORTAL_NAME2 = "DropdownMenuPortal";
|
|
1945
2476
|
var DropdownMenuPortal = (props) => {
|
|
1946
2477
|
const { __scopeDropdownMenu, ...portalProps } = props;
|
|
1947
2478
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
@@ -1950,24 +2481,24 @@ var DropdownMenuPortal = (props) => {
|
|
|
1950
2481
|
...portalProps
|
|
1951
2482
|
});
|
|
1952
2483
|
};
|
|
1953
|
-
DropdownMenuPortal.displayName =
|
|
2484
|
+
DropdownMenuPortal.displayName = PORTAL_NAME2;
|
|
1954
2485
|
var DropdownMenuViewport = /* @__PURE__ */ forwardRef19(({ classNames, asChild, children, ...props }, forwardedRef) => {
|
|
1955
2486
|
const { tx } = useThemeContext();
|
|
1956
|
-
const
|
|
1957
|
-
return /* @__PURE__ */ React27.createElement(
|
|
2487
|
+
const Root7 = asChild ? Slot10 : Primitive10.div;
|
|
2488
|
+
return /* @__PURE__ */ React27.createElement(Root7, {
|
|
1958
2489
|
...props,
|
|
1959
2490
|
className: tx("menu.viewport", "menu__viewport", {}, classNames),
|
|
1960
2491
|
ref: forwardedRef
|
|
1961
2492
|
}, children);
|
|
1962
2493
|
});
|
|
1963
|
-
var
|
|
2494
|
+
var CONTENT_NAME2 = "DropdownMenuContent";
|
|
1964
2495
|
var DropdownMenuContent = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
|
|
1965
2496
|
const { __scopeDropdownMenu, classNames, collisionPadding = 8, ...contentProps } = props;
|
|
1966
2497
|
const { tx } = useThemeContext();
|
|
1967
|
-
const context = useDropdownMenuContext(
|
|
2498
|
+
const context = useDropdownMenuContext(CONTENT_NAME2, __scopeDropdownMenu);
|
|
1968
2499
|
const elevation = useElevationContext();
|
|
1969
2500
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1970
|
-
const hasInteractedOutsideRef =
|
|
2501
|
+
const hasInteractedOutsideRef = useRef3(false);
|
|
1971
2502
|
const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
|
|
1972
2503
|
return /* @__PURE__ */ React27.createElement(MenuPrimitive.Content, {
|
|
1973
2504
|
id: context.contentId,
|
|
@@ -1976,14 +2507,14 @@ var DropdownMenuContent = /* @__PURE__ */ forwardRef19((props, forwardedRef) =>
|
|
|
1976
2507
|
...contentProps,
|
|
1977
2508
|
collisionPadding: safeCollisionPadding,
|
|
1978
2509
|
ref: forwardedRef,
|
|
1979
|
-
onCloseAutoFocus:
|
|
2510
|
+
onCloseAutoFocus: composeEventHandlers2(props.onCloseAutoFocus, (event) => {
|
|
1980
2511
|
if (!hasInteractedOutsideRef.current) {
|
|
1981
2512
|
context.triggerRef.current?.focus();
|
|
1982
2513
|
}
|
|
1983
2514
|
hasInteractedOutsideRef.current = false;
|
|
1984
2515
|
event.preventDefault();
|
|
1985
2516
|
}),
|
|
1986
|
-
onInteractOutside:
|
|
2517
|
+
onInteractOutside: composeEventHandlers2(props.onInteractOutside, (event) => {
|
|
1987
2518
|
const originalEvent = event.detail.originalEvent;
|
|
1988
2519
|
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
1989
2520
|
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
@@ -2007,7 +2538,7 @@ var DropdownMenuContent = /* @__PURE__ */ forwardRef19((props, forwardedRef) =>
|
|
|
2007
2538
|
}
|
|
2008
2539
|
});
|
|
2009
2540
|
});
|
|
2010
|
-
DropdownMenuContent.displayName =
|
|
2541
|
+
DropdownMenuContent.displayName = CONTENT_NAME2;
|
|
2011
2542
|
var GROUP_NAME = "DropdownMenuGroup";
|
|
2012
2543
|
var DropdownMenuGroup = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
|
|
2013
2544
|
const { __scopeDropdownMenu, ...groupProps } = props;
|
|
@@ -2104,7 +2635,7 @@ var DropdownMenuSeparator = /* @__PURE__ */ forwardRef19((props, forwardedRef) =
|
|
|
2104
2635
|
});
|
|
2105
2636
|
});
|
|
2106
2637
|
DropdownMenuSeparator.displayName = SEPARATOR_NAME;
|
|
2107
|
-
var
|
|
2638
|
+
var ARROW_NAME2 = "DropdownMenuArrow";
|
|
2108
2639
|
var DropdownMenuArrow = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
|
|
2109
2640
|
const { __scopeDropdownMenu, classNames, ...arrowProps } = props;
|
|
2110
2641
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
@@ -2116,11 +2647,11 @@ var DropdownMenuArrow = /* @__PURE__ */ forwardRef19((props, forwardedRef) => {
|
|
|
2116
2647
|
ref: forwardedRef
|
|
2117
2648
|
});
|
|
2118
2649
|
});
|
|
2119
|
-
DropdownMenuArrow.displayName =
|
|
2650
|
+
DropdownMenuArrow.displayName = ARROW_NAME2;
|
|
2120
2651
|
var DropdownMenuSub = (props) => {
|
|
2121
2652
|
const { __scopeDropdownMenu, children, open: openProp, onOpenChange, defaultOpen } = props;
|
|
2122
2653
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
2123
|
-
const [open = false, setOpen] =
|
|
2654
|
+
const [open = false, setOpen] = useControllableState5({
|
|
2124
2655
|
prop: openProp,
|
|
2125
2656
|
defaultProp: defaultOpen,
|
|
2126
2657
|
onChange: onOpenChange
|
|
@@ -2188,22 +2719,22 @@ var useDropdownMenuMenuScope = useMenuScope;
|
|
|
2188
2719
|
|
|
2189
2720
|
// packages/ui/react-ui/src/components/Message/Message.tsx
|
|
2190
2721
|
import { createContext as createContext11 } from "@radix-ui/react-context";
|
|
2191
|
-
import { Primitive as
|
|
2722
|
+
import { Primitive as Primitive11 } from "@radix-ui/react-primitive";
|
|
2192
2723
|
import { Slot as Slot11 } from "@radix-ui/react-slot";
|
|
2193
2724
|
import React28, { forwardRef as forwardRef20 } from "react";
|
|
2194
|
-
import { useId as
|
|
2725
|
+
import { useId as useId4 } from "@dxos/react-hooks";
|
|
2195
2726
|
var MESSAGE_NAME = "Message";
|
|
2196
2727
|
var [MessageProvider, useMessageContext] = createContext11(MESSAGE_NAME);
|
|
2197
2728
|
var MessageRoot = /* @__PURE__ */ forwardRef20(({ asChild, valence, elevation: propsElevation, className, titleId: propsTitleId, descriptionId: propsDescriptionId, children, ...props }, forwardedRef) => {
|
|
2198
2729
|
const { tx } = useThemeContext();
|
|
2199
|
-
const titleId =
|
|
2200
|
-
const descriptionId =
|
|
2730
|
+
const titleId = useId4("message__title", propsTitleId);
|
|
2731
|
+
const descriptionId = useId4("message__description", propsDescriptionId);
|
|
2201
2732
|
const elevation = useElevationContext(propsElevation);
|
|
2202
|
-
const
|
|
2733
|
+
const Root7 = asChild ? Slot11 : Primitive11.div;
|
|
2203
2734
|
return /* @__PURE__ */ React28.createElement(MessageProvider, {
|
|
2204
2735
|
titleId,
|
|
2205
2736
|
descriptionId
|
|
2206
|
-
}, /* @__PURE__ */ React28.createElement(
|
|
2737
|
+
}, /* @__PURE__ */ React28.createElement(Root7, {
|
|
2207
2738
|
...props,
|
|
2208
2739
|
className: tx("message.root", "message", {
|
|
2209
2740
|
valence,
|
|
@@ -2219,8 +2750,8 @@ var MESSAGE_TITLE_NAME = "MessageTitle";
|
|
|
2219
2750
|
var MessageTitle = /* @__PURE__ */ forwardRef20(({ asChild, className, children, ...props }, forwardedRef) => {
|
|
2220
2751
|
const { tx } = useThemeContext();
|
|
2221
2752
|
const { titleId } = useMessageContext(MESSAGE_TITLE_NAME);
|
|
2222
|
-
const
|
|
2223
|
-
return /* @__PURE__ */ React28.createElement(
|
|
2753
|
+
const Root7 = asChild ? Slot11 : Primitive11.h2;
|
|
2754
|
+
return /* @__PURE__ */ React28.createElement(Root7, {
|
|
2224
2755
|
...props,
|
|
2225
2756
|
className: tx("message.title", "message__title", {}, className),
|
|
2226
2757
|
id: titleId,
|
|
@@ -2232,8 +2763,8 @@ var MESSAGE_BODY_NAME = "MessageBody";
|
|
|
2232
2763
|
var MessageBody = /* @__PURE__ */ forwardRef20(({ asChild, className, children, ...props }, forwardedRef) => {
|
|
2233
2764
|
const { tx } = useThemeContext();
|
|
2234
2765
|
const { descriptionId } = useMessageContext(MESSAGE_BODY_NAME);
|
|
2235
|
-
const
|
|
2236
|
-
return /* @__PURE__ */ React28.createElement(
|
|
2766
|
+
const Root7 = asChild ? Slot11 : Primitive11.p;
|
|
2767
|
+
return /* @__PURE__ */ React28.createElement(Root7, {
|
|
2237
2768
|
...props,
|
|
2238
2769
|
className: tx("message.body", "message__body", {}, className),
|
|
2239
2770
|
id: descriptionId,
|
|
@@ -2248,51 +2779,51 @@ var Message = {
|
|
|
2248
2779
|
};
|
|
2249
2780
|
|
|
2250
2781
|
// packages/ui/react-ui/src/components/Popover/Popover.tsx
|
|
2251
|
-
import { composeEventHandlers as
|
|
2252
|
-
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
2253
|
-
import { createContextScope as
|
|
2254
|
-
import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
|
|
2782
|
+
import { composeEventHandlers as composeEventHandlers3 } from "@radix-ui/primitive";
|
|
2783
|
+
import { useComposedRefs as useComposedRefs2 } from "@radix-ui/react-compose-refs";
|
|
2784
|
+
import { createContextScope as createContextScope4 } from "@radix-ui/react-context";
|
|
2785
|
+
import { DismissableLayer as DismissableLayer2 } from "@radix-ui/react-dismissable-layer";
|
|
2255
2786
|
import { useFocusGuards } from "@radix-ui/react-focus-guards";
|
|
2256
2787
|
import { FocusScope } from "@radix-ui/react-focus-scope";
|
|
2257
|
-
import { useId as
|
|
2258
|
-
import * as
|
|
2259
|
-
import { createPopperScope } from "@radix-ui/react-popper";
|
|
2260
|
-
import { Portal as
|
|
2261
|
-
import { Presence } from "@radix-ui/react-presence";
|
|
2262
|
-
import { Primitive as
|
|
2788
|
+
import { useId as useId5 } from "@radix-ui/react-id";
|
|
2789
|
+
import * as PopperPrimitive2 from "@radix-ui/react-popper";
|
|
2790
|
+
import { createPopperScope as createPopperScope2 } from "@radix-ui/react-popper";
|
|
2791
|
+
import { Portal as PortalPrimitive2 } from "@radix-ui/react-portal";
|
|
2792
|
+
import { Presence as Presence2 } from "@radix-ui/react-presence";
|
|
2793
|
+
import { Primitive as Primitive12 } from "@radix-ui/react-primitive";
|
|
2263
2794
|
import { Slot as Slot12 } from "@radix-ui/react-slot";
|
|
2264
|
-
import { useControllableState as
|
|
2795
|
+
import { useControllableState as useControllableState6 } from "@radix-ui/react-use-controllable-state";
|
|
2265
2796
|
import { hideOthers } from "aria-hidden";
|
|
2266
|
-
import React29, { forwardRef as forwardRef21, useRef as
|
|
2797
|
+
import React29, { forwardRef as forwardRef21, useRef as useRef4, useCallback as useCallback9, useState as useState8, useEffect as useEffect7 } from "react";
|
|
2267
2798
|
import { RemoveScroll } from "react-remove-scroll";
|
|
2268
2799
|
var POPOVER_NAME = "Popover";
|
|
2269
|
-
var [createPopoverContext, createPopoverScope] =
|
|
2270
|
-
|
|
2800
|
+
var [createPopoverContext, createPopoverScope] = createContextScope4(POPOVER_NAME, [
|
|
2801
|
+
createPopperScope2
|
|
2271
2802
|
]);
|
|
2272
|
-
var
|
|
2803
|
+
var usePopperScope2 = createPopperScope2();
|
|
2273
2804
|
var [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);
|
|
2274
2805
|
var PopoverRoot = (props) => {
|
|
2275
2806
|
const { __scopePopover, children, open: openProp, defaultOpen, onOpenChange, modal = false } = props;
|
|
2276
|
-
const popperScope =
|
|
2277
|
-
const triggerRef =
|
|
2278
|
-
const [hasCustomAnchor, setHasCustomAnchor] =
|
|
2279
|
-
const [open = false, setOpen] =
|
|
2807
|
+
const popperScope = usePopperScope2(__scopePopover);
|
|
2808
|
+
const triggerRef = useRef4(null);
|
|
2809
|
+
const [hasCustomAnchor, setHasCustomAnchor] = useState8(false);
|
|
2810
|
+
const [open = false, setOpen] = useControllableState6({
|
|
2280
2811
|
prop: openProp,
|
|
2281
2812
|
defaultProp: defaultOpen,
|
|
2282
2813
|
onChange: onOpenChange
|
|
2283
2814
|
});
|
|
2284
|
-
return /* @__PURE__ */ React29.createElement(
|
|
2815
|
+
return /* @__PURE__ */ React29.createElement(PopperPrimitive2.Root, popperScope, /* @__PURE__ */ React29.createElement(PopoverProvider, {
|
|
2285
2816
|
scope: __scopePopover,
|
|
2286
|
-
contentId:
|
|
2817
|
+
contentId: useId5(),
|
|
2287
2818
|
triggerRef,
|
|
2288
2819
|
open,
|
|
2289
2820
|
onOpenChange: setOpen,
|
|
2290
|
-
onOpenToggle:
|
|
2821
|
+
onOpenToggle: useCallback9(() => setOpen((prevOpen) => !prevOpen), [
|
|
2291
2822
|
setOpen
|
|
2292
2823
|
]),
|
|
2293
2824
|
hasCustomAnchor,
|
|
2294
|
-
onCustomAnchorAdd:
|
|
2295
|
-
onCustomAnchorRemove:
|
|
2825
|
+
onCustomAnchorAdd: useCallback9(() => setHasCustomAnchor(true), []),
|
|
2826
|
+
onCustomAnchorRemove: useCallback9(() => setHasCustomAnchor(false), []),
|
|
2296
2827
|
modal
|
|
2297
2828
|
}, children));
|
|
2298
2829
|
};
|
|
@@ -2301,29 +2832,29 @@ var ANCHOR_NAME = "PopoverAnchor";
|
|
|
2301
2832
|
var PopoverAnchor = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
|
|
2302
2833
|
const { __scopePopover, ...anchorProps } = props;
|
|
2303
2834
|
const context = usePopoverContext(ANCHOR_NAME, __scopePopover);
|
|
2304
|
-
const popperScope =
|
|
2835
|
+
const popperScope = usePopperScope2(__scopePopover);
|
|
2305
2836
|
const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
|
|
2306
|
-
|
|
2837
|
+
useEffect7(() => {
|
|
2307
2838
|
onCustomAnchorAdd();
|
|
2308
2839
|
return () => onCustomAnchorRemove();
|
|
2309
2840
|
}, [
|
|
2310
2841
|
onCustomAnchorAdd,
|
|
2311
2842
|
onCustomAnchorRemove
|
|
2312
2843
|
]);
|
|
2313
|
-
return /* @__PURE__ */ React29.createElement(
|
|
2844
|
+
return /* @__PURE__ */ React29.createElement(PopperPrimitive2.Anchor, {
|
|
2314
2845
|
...popperScope,
|
|
2315
2846
|
...anchorProps,
|
|
2316
2847
|
ref: forwardedRef
|
|
2317
2848
|
});
|
|
2318
2849
|
});
|
|
2319
2850
|
PopoverAnchor.displayName = ANCHOR_NAME;
|
|
2320
|
-
var
|
|
2851
|
+
var TRIGGER_NAME3 = "PopoverTrigger";
|
|
2321
2852
|
var PopoverTrigger = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
|
|
2322
2853
|
const { __scopePopover, ...triggerProps } = props;
|
|
2323
|
-
const context = usePopoverContext(
|
|
2324
|
-
const popperScope =
|
|
2325
|
-
const composedTriggerRef =
|
|
2326
|
-
const trigger = /* @__PURE__ */ React29.createElement(
|
|
2854
|
+
const context = usePopoverContext(TRIGGER_NAME3, __scopePopover);
|
|
2855
|
+
const popperScope = usePopperScope2(__scopePopover);
|
|
2856
|
+
const composedTriggerRef = useComposedRefs2(forwardedRef, context.triggerRef);
|
|
2857
|
+
const trigger = /* @__PURE__ */ React29.createElement(Primitive12.button, {
|
|
2327
2858
|
type: "button",
|
|
2328
2859
|
"aria-haspopup": "dialog",
|
|
2329
2860
|
"aria-expanded": context.open,
|
|
@@ -2331,54 +2862,54 @@ var PopoverTrigger = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
|
|
|
2331
2862
|
"data-state": getState(context.open),
|
|
2332
2863
|
...triggerProps,
|
|
2333
2864
|
ref: composedTriggerRef,
|
|
2334
|
-
onClick:
|
|
2865
|
+
onClick: composeEventHandlers3(props.onClick, context.onOpenToggle)
|
|
2335
2866
|
});
|
|
2336
|
-
return context.hasCustomAnchor ? trigger : /* @__PURE__ */ React29.createElement(
|
|
2867
|
+
return context.hasCustomAnchor ? trigger : /* @__PURE__ */ React29.createElement(PopperPrimitive2.Anchor, {
|
|
2337
2868
|
asChild: true,
|
|
2338
2869
|
...popperScope
|
|
2339
2870
|
}, trigger);
|
|
2340
2871
|
});
|
|
2341
|
-
PopoverTrigger.displayName =
|
|
2872
|
+
PopoverTrigger.displayName = TRIGGER_NAME3;
|
|
2342
2873
|
var VIRTUAL_TRIGGER_NAME2 = "PopoverVirtualTrigger";
|
|
2343
2874
|
var PopoverVirtualTrigger = (props) => {
|
|
2344
2875
|
const { __scopePopover, virtualRef } = props;
|
|
2345
2876
|
const context = usePopoverContext(VIRTUAL_TRIGGER_NAME2, __scopePopover);
|
|
2346
|
-
const popperScope =
|
|
2347
|
-
|
|
2877
|
+
const popperScope = usePopperScope2(__scopePopover);
|
|
2878
|
+
useEffect7(() => {
|
|
2348
2879
|
if (virtualRef.current) {
|
|
2349
2880
|
context.triggerRef.current = virtualRef.current;
|
|
2350
2881
|
}
|
|
2351
2882
|
});
|
|
2352
|
-
return /* @__PURE__ */ React29.createElement(
|
|
2883
|
+
return /* @__PURE__ */ React29.createElement(PopperPrimitive2.Anchor, {
|
|
2353
2884
|
...popperScope,
|
|
2354
2885
|
virtualRef
|
|
2355
2886
|
});
|
|
2356
2887
|
};
|
|
2357
2888
|
PopoverVirtualTrigger.displayName = VIRTUAL_TRIGGER_NAME2;
|
|
2358
|
-
var
|
|
2359
|
-
var [
|
|
2889
|
+
var PORTAL_NAME3 = "PopoverPortal";
|
|
2890
|
+
var [PortalProvider2, usePortalContext2] = createPopoverContext(PORTAL_NAME3, {
|
|
2360
2891
|
forceMount: void 0
|
|
2361
2892
|
});
|
|
2362
2893
|
var PopoverPortal = (props) => {
|
|
2363
2894
|
const { __scopePopover, forceMount, children, container } = props;
|
|
2364
|
-
const context = usePopoverContext(
|
|
2365
|
-
return /* @__PURE__ */ React29.createElement(
|
|
2895
|
+
const context = usePopoverContext(PORTAL_NAME3, __scopePopover);
|
|
2896
|
+
return /* @__PURE__ */ React29.createElement(PortalProvider2, {
|
|
2366
2897
|
scope: __scopePopover,
|
|
2367
2898
|
forceMount
|
|
2368
|
-
}, /* @__PURE__ */ React29.createElement(
|
|
2899
|
+
}, /* @__PURE__ */ React29.createElement(Presence2, {
|
|
2369
2900
|
present: forceMount || context.open
|
|
2370
|
-
}, /* @__PURE__ */ React29.createElement(
|
|
2901
|
+
}, /* @__PURE__ */ React29.createElement(PortalPrimitive2, {
|
|
2371
2902
|
asChild: true,
|
|
2372
2903
|
container
|
|
2373
2904
|
}, children)));
|
|
2374
2905
|
};
|
|
2375
|
-
PopoverPortal.displayName =
|
|
2376
|
-
var
|
|
2906
|
+
PopoverPortal.displayName = PORTAL_NAME3;
|
|
2907
|
+
var CONTENT_NAME3 = "PopoverContent";
|
|
2377
2908
|
var PopoverContent = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
|
|
2378
|
-
const portalContext =
|
|
2909
|
+
const portalContext = usePortalContext2(CONTENT_NAME3, props.__scopePopover);
|
|
2379
2910
|
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
2380
|
-
const context = usePopoverContext(
|
|
2381
|
-
return /* @__PURE__ */ React29.createElement(
|
|
2911
|
+
const context = usePopoverContext(CONTENT_NAME3, props.__scopePopover);
|
|
2912
|
+
return /* @__PURE__ */ React29.createElement(Presence2, {
|
|
2382
2913
|
present: forceMount || context.open
|
|
2383
2914
|
}, context.modal ? /* @__PURE__ */ React29.createElement(PopoverContentModal, {
|
|
2384
2915
|
...contentProps,
|
|
@@ -2388,13 +2919,13 @@ var PopoverContent = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
|
|
|
2388
2919
|
ref: forwardedRef
|
|
2389
2920
|
}));
|
|
2390
2921
|
});
|
|
2391
|
-
PopoverContent.displayName =
|
|
2922
|
+
PopoverContent.displayName = CONTENT_NAME3;
|
|
2392
2923
|
var PopoverContentModal = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
|
|
2393
|
-
const context = usePopoverContext(
|
|
2394
|
-
const contentRef =
|
|
2395
|
-
const composedRefs =
|
|
2396
|
-
const isRightClickOutsideRef =
|
|
2397
|
-
|
|
2924
|
+
const context = usePopoverContext(CONTENT_NAME3, props.__scopePopover);
|
|
2925
|
+
const contentRef = useRef4(null);
|
|
2926
|
+
const composedRefs = useComposedRefs2(forwardedRef, contentRef);
|
|
2927
|
+
const isRightClickOutsideRef = useRef4(false);
|
|
2928
|
+
useEffect7(() => {
|
|
2398
2929
|
const content = contentRef.current;
|
|
2399
2930
|
if (content) {
|
|
2400
2931
|
return hideOthers(content);
|
|
@@ -2410,13 +2941,13 @@ var PopoverContentModal = /* @__PURE__ */ forwardRef21((props, forwardedRef) =>
|
|
|
2410
2941
|
// (closed !== unmounted when animating out)
|
|
2411
2942
|
trapFocus: context.open,
|
|
2412
2943
|
disableOutsidePointerEvents: true,
|
|
2413
|
-
onCloseAutoFocus:
|
|
2944
|
+
onCloseAutoFocus: composeEventHandlers3(props.onCloseAutoFocus, (event) => {
|
|
2414
2945
|
event.preventDefault();
|
|
2415
2946
|
if (!isRightClickOutsideRef.current) {
|
|
2416
2947
|
context.triggerRef.current?.focus();
|
|
2417
2948
|
}
|
|
2418
2949
|
}),
|
|
2419
|
-
onPointerDownOutside:
|
|
2950
|
+
onPointerDownOutside: composeEventHandlers3(props.onPointerDownOutside, (event) => {
|
|
2420
2951
|
const originalEvent = event.detail.originalEvent;
|
|
2421
2952
|
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
2422
2953
|
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
@@ -2426,15 +2957,15 @@ var PopoverContentModal = /* @__PURE__ */ forwardRef21((props, forwardedRef) =>
|
|
|
2426
2957
|
}),
|
|
2427
2958
|
// When focus is trapped, a `focusout` event may still happen.
|
|
2428
2959
|
// We make sure we don't trigger our `onDismiss` in such case.
|
|
2429
|
-
onFocusOutside:
|
|
2960
|
+
onFocusOutside: composeEventHandlers3(props.onFocusOutside, (event) => event.preventDefault(), {
|
|
2430
2961
|
checkForDefaultPrevented: false
|
|
2431
2962
|
})
|
|
2432
2963
|
}));
|
|
2433
2964
|
});
|
|
2434
2965
|
var PopoverContentNonModal = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
|
|
2435
|
-
const context = usePopoverContext(
|
|
2436
|
-
const hasInteractedOutsideRef =
|
|
2437
|
-
const hasPointerDownOutsideRef =
|
|
2966
|
+
const context = usePopoverContext(CONTENT_NAME3, props.__scopePopover);
|
|
2967
|
+
const hasInteractedOutsideRef = useRef4(false);
|
|
2968
|
+
const hasPointerDownOutsideRef = useRef4(false);
|
|
2438
2969
|
return /* @__PURE__ */ React29.createElement(PopoverContentImpl, {
|
|
2439
2970
|
...props,
|
|
2440
2971
|
ref: forwardedRef,
|
|
@@ -2472,8 +3003,8 @@ var PopoverContentNonModal = /* @__PURE__ */ forwardRef21((props, forwardedRef)
|
|
|
2472
3003
|
});
|
|
2473
3004
|
var PopoverContentImpl = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
|
|
2474
3005
|
const { __scopePopover, trapFocus, onOpenAutoFocus, onCloseAutoFocus, disableOutsidePointerEvents, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, collisionPadding = 8, classNames, ...contentProps } = props;
|
|
2475
|
-
const context = usePopoverContext(
|
|
2476
|
-
const popperScope =
|
|
3006
|
+
const context = usePopoverContext(CONTENT_NAME3, __scopePopover);
|
|
3007
|
+
const popperScope = usePopperScope2(__scopePopover);
|
|
2477
3008
|
const { tx } = useThemeContext();
|
|
2478
3009
|
const elevation = useElevationContext();
|
|
2479
3010
|
const safeCollisionPadding = useSafeCollisionPadding(collisionPadding);
|
|
@@ -2484,7 +3015,7 @@ var PopoverContentImpl = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
|
|
|
2484
3015
|
trapped: trapFocus,
|
|
2485
3016
|
onMountAutoFocus: onOpenAutoFocus,
|
|
2486
3017
|
onUnmountAutoFocus: onCloseAutoFocus
|
|
2487
|
-
}, /* @__PURE__ */ React29.createElement(
|
|
3018
|
+
}, /* @__PURE__ */ React29.createElement(DismissableLayer2, {
|
|
2488
3019
|
asChild: true,
|
|
2489
3020
|
disableOutsidePointerEvents,
|
|
2490
3021
|
onInteractOutside,
|
|
@@ -2492,7 +3023,7 @@ var PopoverContentImpl = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
|
|
|
2492
3023
|
onPointerDownOutside,
|
|
2493
3024
|
onFocusOutside,
|
|
2494
3025
|
onDismiss: () => context.onOpenChange(false)
|
|
2495
|
-
}, /* @__PURE__ */ React29.createElement(
|
|
3026
|
+
}, /* @__PURE__ */ React29.createElement(PopperPrimitive2.Content, {
|
|
2496
3027
|
"data-state": getState(context.open),
|
|
2497
3028
|
role: "dialog",
|
|
2498
3029
|
id: context.contentId,
|
|
@@ -2520,31 +3051,31 @@ var CLOSE_NAME = "PopoverClose";
|
|
|
2520
3051
|
var PopoverClose = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
|
|
2521
3052
|
const { __scopePopover, ...closeProps } = props;
|
|
2522
3053
|
const context = usePopoverContext(CLOSE_NAME, __scopePopover);
|
|
2523
|
-
return /* @__PURE__ */ React29.createElement(
|
|
3054
|
+
return /* @__PURE__ */ React29.createElement(Primitive12.button, {
|
|
2524
3055
|
type: "button",
|
|
2525
3056
|
...closeProps,
|
|
2526
3057
|
ref: forwardedRef,
|
|
2527
|
-
onClick:
|
|
3058
|
+
onClick: composeEventHandlers3(props.onClick, () => context.onOpenChange(false))
|
|
2528
3059
|
});
|
|
2529
3060
|
});
|
|
2530
3061
|
PopoverClose.displayName = CLOSE_NAME;
|
|
2531
|
-
var
|
|
3062
|
+
var ARROW_NAME3 = "PopoverArrow";
|
|
2532
3063
|
var PopoverArrow = /* @__PURE__ */ forwardRef21((props, forwardedRef) => {
|
|
2533
3064
|
const { __scopePopover, classNames, ...arrowProps } = props;
|
|
2534
|
-
const popperScope =
|
|
3065
|
+
const popperScope = usePopperScope2(__scopePopover);
|
|
2535
3066
|
const { tx } = useThemeContext();
|
|
2536
|
-
return /* @__PURE__ */ React29.createElement(
|
|
3067
|
+
return /* @__PURE__ */ React29.createElement(PopperPrimitive2.Arrow, {
|
|
2537
3068
|
...popperScope,
|
|
2538
3069
|
...arrowProps,
|
|
2539
3070
|
className: tx("popover.arrow", "popover__arrow", {}, classNames),
|
|
2540
3071
|
ref: forwardedRef
|
|
2541
3072
|
});
|
|
2542
3073
|
});
|
|
2543
|
-
PopoverArrow.displayName =
|
|
3074
|
+
PopoverArrow.displayName = ARROW_NAME3;
|
|
2544
3075
|
var PopoverViewport = /* @__PURE__ */ forwardRef21(({ classNames, asChild, constrainInline = true, constrainBlock = true, children, ...props }, forwardedRef) => {
|
|
2545
3076
|
const { tx } = useThemeContext();
|
|
2546
|
-
const
|
|
2547
|
-
return /* @__PURE__ */ React29.createElement(
|
|
3077
|
+
const Root7 = asChild ? Slot12 : Primitive12.div;
|
|
3078
|
+
return /* @__PURE__ */ React29.createElement(Root7, {
|
|
2548
3079
|
...props,
|
|
2549
3080
|
className: tx("popover.viewport", "popover__viewport", {
|
|
2550
3081
|
constrainInline,
|
|
@@ -2795,13 +3326,13 @@ var Separator4 = /* @__PURE__ */ forwardRef25(({ classNames, orientation = "hori
|
|
|
2795
3326
|
});
|
|
2796
3327
|
|
|
2797
3328
|
// packages/ui/react-ui/src/components/Tag/Tag.tsx
|
|
2798
|
-
import { Primitive as
|
|
3329
|
+
import { Primitive as Primitive13 } from "@radix-ui/react-primitive";
|
|
2799
3330
|
import { Slot as Slot13 } from "@radix-ui/react-slot";
|
|
2800
3331
|
import React34, { forwardRef as forwardRef26 } from "react";
|
|
2801
3332
|
var Tag = /* @__PURE__ */ forwardRef26(({ asChild, palette = "neutral", classNames, ...props }, forwardedRef) => {
|
|
2802
3333
|
const { tx } = useThemeContext();
|
|
2803
|
-
const
|
|
2804
|
-
return /* @__PURE__ */ React34.createElement(
|
|
3334
|
+
const Root7 = asChild ? Slot13 : Primitive13.span;
|
|
3335
|
+
return /* @__PURE__ */ React34.createElement(Root7, {
|
|
2805
3336
|
...props,
|
|
2806
3337
|
className: tx("tag.root", "dx-tag", {
|
|
2807
3338
|
palette
|
|
@@ -2812,7 +3343,7 @@ var Tag = /* @__PURE__ */ forwardRef26(({ asChild, palette = "neutral", classNam
|
|
|
2812
3343
|
});
|
|
2813
3344
|
|
|
2814
3345
|
// packages/ui/react-ui/src/components/Toast/Toast.tsx
|
|
2815
|
-
import { Primitive as
|
|
3346
|
+
import { Primitive as Primitive14 } from "@radix-ui/react-primitive";
|
|
2816
3347
|
import { Slot as Slot14 } from "@radix-ui/react-slot";
|
|
2817
3348
|
import { ToastProvider as ToastProviderPrimitive, ToastViewport as ToastViewportPrimitive, Root as ToastRootPrimitive, ToastTitle as ToastTitlePrimitive, ToastDescription as ToastDescriptionPrimitive, ToastAction as ToastActionPrimitive, ToastClose as ToastClosePrimitive } from "@radix-ui/react-toast";
|
|
2818
3349
|
import React35, { forwardRef as forwardRef27 } from "react";
|
|
@@ -2836,8 +3367,8 @@ var ToastRoot = /* @__PURE__ */ forwardRef27(({ classNames, children, ...props }
|
|
|
2836
3367
|
});
|
|
2837
3368
|
var ToastBody = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props }, forwardedRef) => {
|
|
2838
3369
|
const { tx } = useThemeContext();
|
|
2839
|
-
const
|
|
2840
|
-
return /* @__PURE__ */ React35.createElement(
|
|
3370
|
+
const Root7 = asChild ? Slot14 : Primitive14.div;
|
|
3371
|
+
return /* @__PURE__ */ React35.createElement(Root7, {
|
|
2841
3372
|
...props,
|
|
2842
3373
|
className: tx("toast.body", "toast__body", {}, classNames),
|
|
2843
3374
|
ref: forwardedRef
|
|
@@ -2845,8 +3376,8 @@ var ToastBody = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props },
|
|
|
2845
3376
|
});
|
|
2846
3377
|
var ToastTitle = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props }, forwardedRef) => {
|
|
2847
3378
|
const { tx } = useThemeContext();
|
|
2848
|
-
const
|
|
2849
|
-
return /* @__PURE__ */ React35.createElement(
|
|
3379
|
+
const Root7 = asChild ? Slot14 : ToastTitlePrimitive;
|
|
3380
|
+
return /* @__PURE__ */ React35.createElement(Root7, {
|
|
2850
3381
|
...props,
|
|
2851
3382
|
className: tx("toast.title", "toast__title", {}, classNames),
|
|
2852
3383
|
ref: forwardedRef
|
|
@@ -2854,8 +3385,8 @@ var ToastTitle = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props }
|
|
|
2854
3385
|
});
|
|
2855
3386
|
var ToastDescription = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props }, forwardedRef) => {
|
|
2856
3387
|
const { tx } = useThemeContext();
|
|
2857
|
-
const
|
|
2858
|
-
return /* @__PURE__ */ React35.createElement(
|
|
3388
|
+
const Root7 = asChild ? Slot14 : ToastDescriptionPrimitive;
|
|
3389
|
+
return /* @__PURE__ */ React35.createElement(Root7, {
|
|
2859
3390
|
...props,
|
|
2860
3391
|
className: tx("toast.description", "toast__description", {}, classNames),
|
|
2861
3392
|
ref: forwardedRef
|
|
@@ -2863,8 +3394,8 @@ var ToastDescription = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...p
|
|
|
2863
3394
|
});
|
|
2864
3395
|
var ToastActions = /* @__PURE__ */ forwardRef27(({ asChild, classNames, ...props }, forwardedRef) => {
|
|
2865
3396
|
const { tx } = useThemeContext();
|
|
2866
|
-
const
|
|
2867
|
-
return /* @__PURE__ */ React35.createElement(
|
|
3397
|
+
const Root7 = asChild ? Slot14 : Primitive14.div;
|
|
3398
|
+
return /* @__PURE__ */ React35.createElement(Root7, {
|
|
2868
3399
|
...props,
|
|
2869
3400
|
className: tx("toast.actions", "toast__actions", {}, classNames),
|
|
2870
3401
|
ref: forwardedRef
|
|
@@ -3034,6 +3565,7 @@ export {
|
|
|
3034
3565
|
Treegrid,
|
|
3035
3566
|
createDropdownMenuScope,
|
|
3036
3567
|
createPopoverScope,
|
|
3568
|
+
createTooltipScope,
|
|
3037
3569
|
hasIosKeyboard,
|
|
3038
3570
|
initialSafeArea,
|
|
3039
3571
|
isLabel,
|
|
@@ -3053,6 +3585,7 @@ export {
|
|
|
3053
3585
|
useSafeArea,
|
|
3054
3586
|
useSidebars,
|
|
3055
3587
|
useThemeContext,
|
|
3588
|
+
useTooltipContext,
|
|
3056
3589
|
useTranslation,
|
|
3057
3590
|
useTranslationsContext,
|
|
3058
3591
|
useVisualViewport
|