@yahoo/uds 3.175.1 → 3.176.0-beta.1
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/components/client/Menu/Menu.ItemCheckbox.d.cts +1 -1
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +1 -1
- package/dist/components/client/Popover/Popover.cjs +18 -2
- package/dist/components/client/Popover/Popover.d.cts +14 -2
- package/dist/components/client/Popover/Popover.d.ts +14 -2
- package/dist/components/client/Popover/Popover.js +19 -3
- package/dist/components/client/Popover/PopoverAnchor.cjs +42 -0
- package/dist/components/client/Popover/PopoverAnchor.d.cts +41 -0
- package/dist/components/client/Popover/PopoverAnchor.d.ts +42 -0
- package/dist/components/client/Popover/PopoverAnchor.js +40 -0
- package/dist/components/client/Popover/PopoverContent.cjs +3 -1
- package/dist/components/client/Popover/PopoverContent.d.cts +5 -1
- package/dist/components/client/Popover/PopoverContent.d.ts +5 -1
- package/dist/components/client/Popover/PopoverContent.js +3 -1
- package/dist/components/client/Popover/PopoverContext.d.cts +1 -0
- package/dist/components/client/Popover/PopoverContext.d.ts +1 -0
- package/dist/components/client/Popover/PopoverTrigger.cjs +4 -0
- package/dist/components/client/Popover/PopoverTrigger.js +5 -1
- package/dist/components/client/Popover/index.cjs +2 -0
- package/dist/components/client/Popover/index.d.cts +5 -4
- package/dist/components/client/Popover/index.d.ts +5 -4
- package/dist/components/client/Popover/index.js +2 -1
- package/dist/components/client/Toast/UDSToastConfigProvider.d.cts +5 -5
- package/dist/components/client/Toast/UDSToastConfigProvider.d.ts +5 -5
- package/dist/components/client/index.cjs +2 -0
- package/dist/components/client/index.d.cts +5 -4
- package/dist/components/client/index.d.ts +5 -4
- package/dist/components/client/index.js +2 -1
- package/dist/components/index.d.cts +4 -4
- package/dist/components/index.d.ts +4 -4
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/uds/generated/componentData.cjs +81 -67
- package/dist/uds/generated/componentData.js +81 -67
- package/generated/componentData.json +131 -105
- package/package.json +1 -1
|
@@ -131,6 +131,6 @@ interface MenuItemCheckboxProps extends Omit<PressableProps, 'asChild'>, HtmlBut
|
|
|
131
131
|
*
|
|
132
132
|
* @related [Menu](https://uds.build/docs/components/menu), [Menu.Item](https://uds.build/docs/components/menu-item)
|
|
133
133
|
**/
|
|
134
|
-
declare const MenuItemCheckbox: _$react.ForwardRefExoticComponent<Omit<MenuItemCheckboxProps, "
|
|
134
|
+
declare const MenuItemCheckbox: _$react.ForwardRefExoticComponent<Omit<MenuItemCheckboxProps, "hideEndIcon" | "rootProps" | "active"> & _$react.RefAttributes<HTMLDivElement>>;
|
|
135
135
|
//#endregion
|
|
136
136
|
export { MenuItemCheckbox, type MenuItemCheckboxProps };
|
|
@@ -132,6 +132,6 @@ interface MenuItemCheckboxProps extends Omit<PressableProps, 'asChild'>, HtmlBut
|
|
|
132
132
|
*
|
|
133
133
|
* @related [Menu](https://uds.build/docs/components/menu), [Menu.Item](https://uds.build/docs/components/menu-item)
|
|
134
134
|
**/
|
|
135
|
-
declare const MenuItemCheckbox: _$react.ForwardRefExoticComponent<Omit<MenuItemCheckboxProps, "
|
|
135
|
+
declare const MenuItemCheckbox: _$react.ForwardRefExoticComponent<Omit<MenuItemCheckboxProps, "hideEndIcon" | "rootProps" | "active"> & _$react.RefAttributes<HTMLDivElement>>;
|
|
136
136
|
//#endregion
|
|
137
137
|
export { MenuItemCheckbox, type MenuItemCheckboxProps };
|
|
@@ -9,6 +9,10 @@ let react = require("react");
|
|
|
9
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
10
|
let _ariakit_react = require("@ariakit/react");
|
|
11
11
|
//#region src/components/client/Popover/Popover.tsx
|
|
12
|
+
function resolveAnchor(anchor) {
|
|
13
|
+
if (!anchor) return null;
|
|
14
|
+
return anchor instanceof HTMLElement ? anchor : anchor.current;
|
|
15
|
+
}
|
|
12
16
|
const POPOVER_OPEN_EVENT = "uds:popover-open";
|
|
13
17
|
/**
|
|
14
18
|
* **⚙️️ A Popover component that anchors to a trigger element
|
|
@@ -37,7 +41,7 @@ const POPOVER_OPEN_EVENT = "uds:popover-open";
|
|
|
37
41
|
*
|
|
38
42
|
* @related [Toast](https://uds.build/docs/components/toast), [Tooltip](https://uds.build/docs/components/tooltip)
|
|
39
43
|
**/
|
|
40
|
-
function Popover({ children, placement, open, defaultOpen = false, portal = true, hideArrow = false, hideDismissButton = false, onClose, onOpen, reduceMotion: forceReduceMotion = false, disableAutoFocus = false, disableVerticalSpacing = false, disableHorizontalSpacing = false, sameWidth = false, gutter = 4, unmountOnHide = false }) {
|
|
44
|
+
function Popover({ children, placement, anchor, open, defaultOpen = false, portal = true, hideArrow = false, hideDismissButton = false, onClose, onOpen, reduceMotion: forceReduceMotion = false, disableAutoFocus = false, disableVerticalSpacing = false, disableHorizontalSpacing = false, sameWidth = false, gutter = 4, unmountOnHide = false }) {
|
|
41
45
|
const controlledProps = open !== void 0 ? {
|
|
42
46
|
showTimeout: 0,
|
|
43
47
|
hideTimeout: 0,
|
|
@@ -47,6 +51,17 @@ function Popover({ children, placement, open, defaultOpen = false, portal = true
|
|
|
47
51
|
const { animationDuration: animationDurationConfig, ariaKitPlacement } = require_components_client_Popover_UDSPopoverConfigProvider.usePopoverConfig(void 0, void 0, { placement });
|
|
48
52
|
const id = (0, react.useId)();
|
|
49
53
|
const store = (0, _ariakit_react.usePopoverStore)({ defaultOpen });
|
|
54
|
+
(0, react.useLayoutEffect)(() => {
|
|
55
|
+
if (anchor === void 0) return;
|
|
56
|
+
const element = resolveAnchor(anchor);
|
|
57
|
+
store.setAnchorElement(element);
|
|
58
|
+
store.setDisclosureElement(element);
|
|
59
|
+
store.render();
|
|
60
|
+
}, [
|
|
61
|
+
store,
|
|
62
|
+
anchor,
|
|
63
|
+
open
|
|
64
|
+
]);
|
|
50
65
|
const handleSetOpen = (0, react.useCallback)((newOpen) => {
|
|
51
66
|
if (newOpen) {
|
|
52
67
|
onOpen?.();
|
|
@@ -77,7 +92,8 @@ function Popover({ children, placement, open, defaultOpen = false, portal = true
|
|
|
77
92
|
disableHorizontalSpacing,
|
|
78
93
|
sameWidth,
|
|
79
94
|
gutter,
|
|
80
|
-
unmountOnHide
|
|
95
|
+
unmountOnHide,
|
|
96
|
+
hasAnchor: anchor !== void 0
|
|
81
97
|
},
|
|
82
98
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ariakit_react.PopoverProvider, {
|
|
83
99
|
placement: ariaKitPlacement,
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
|
|
2
2
|
import { UniversalPopoverProps } from "../../../types/dist/index.cjs";
|
|
3
|
+
import { RefObject } from "react";
|
|
3
4
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
5
|
|
|
5
6
|
//#region src/components/client/Popover/Popover.d.ts
|
|
6
|
-
|
|
7
|
+
/** An element (or ref to one) that the popover points at without modifying it. */
|
|
8
|
+
type PopoverAnchorTarget = HTMLElement | RefObject<HTMLElement | null> | null;
|
|
9
|
+
interface PopoverProps extends UniversalPopoverProps {
|
|
10
|
+
/**
|
|
11
|
+
* Anchors the popover to an element the consumer doesn't render (e.g. for
|
|
12
|
+
* onboarding cues). Only the element's position is read — no attributes,
|
|
13
|
+
* roles, or handlers are applied to it. When set, omit `PopoverTrigger` and
|
|
14
|
+
* control visibility with the `open` prop.
|
|
15
|
+
*/
|
|
16
|
+
anchor?: PopoverAnchorTarget;
|
|
17
|
+
}
|
|
7
18
|
/**
|
|
8
19
|
* **⚙️️ A Popover component that anchors to a trigger element
|
|
9
20
|
*
|
|
@@ -34,6 +45,7 @@ type PopoverProps = UniversalPopoverProps;
|
|
|
34
45
|
declare function Popover({
|
|
35
46
|
children,
|
|
36
47
|
placement,
|
|
48
|
+
anchor,
|
|
37
49
|
open,
|
|
38
50
|
defaultOpen,
|
|
39
51
|
portal,
|
|
@@ -53,4 +65,4 @@ declare namespace Popover {
|
|
|
53
65
|
var displayName: string;
|
|
54
66
|
}
|
|
55
67
|
//#endregion
|
|
56
|
-
export { Popover };
|
|
68
|
+
export { Popover, type PopoverAnchorTarget, type PopoverProps };
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { UniversalPopoverProps } from "../../../types/dist/index.js";
|
|
4
|
+
import { RefObject } from "react";
|
|
4
5
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
6
|
|
|
6
7
|
//#region src/components/client/Popover/Popover.d.ts
|
|
7
|
-
|
|
8
|
+
/** An element (or ref to one) that the popover points at without modifying it. */
|
|
9
|
+
type PopoverAnchorTarget = HTMLElement | RefObject<HTMLElement | null> | null;
|
|
10
|
+
interface PopoverProps extends UniversalPopoverProps {
|
|
11
|
+
/**
|
|
12
|
+
* Anchors the popover to an element the consumer doesn't render (e.g. for
|
|
13
|
+
* onboarding cues). Only the element's position is read — no attributes,
|
|
14
|
+
* roles, or handlers are applied to it. When set, omit `PopoverTrigger` and
|
|
15
|
+
* control visibility with the `open` prop.
|
|
16
|
+
*/
|
|
17
|
+
anchor?: PopoverAnchorTarget;
|
|
18
|
+
}
|
|
8
19
|
/**
|
|
9
20
|
* **⚙️️ A Popover component that anchors to a trigger element
|
|
10
21
|
*
|
|
@@ -35,6 +46,7 @@ type PopoverProps = UniversalPopoverProps;
|
|
|
35
46
|
declare function Popover({
|
|
36
47
|
children,
|
|
37
48
|
placement,
|
|
49
|
+
anchor,
|
|
38
50
|
open,
|
|
39
51
|
defaultOpen,
|
|
40
52
|
portal,
|
|
@@ -54,4 +66,4 @@ declare namespace Popover {
|
|
|
54
66
|
var displayName: string;
|
|
55
67
|
}
|
|
56
68
|
//#endregion
|
|
57
|
-
export { Popover };
|
|
69
|
+
export { Popover, type PopoverAnchorTarget, type PopoverProps };
|
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
import { usePrefersReducedMotion } from "../../../hooks/usePrefersReducedMotion.js";
|
|
4
4
|
import { PopoverInternalContext } from "./PopoverContext.js";
|
|
5
5
|
import { usePopoverConfig } from "./UDSPopoverConfigProvider.js";
|
|
6
|
-
import { useCallback, useEffect, useId } from "react";
|
|
6
|
+
import { useCallback, useEffect, useId, useLayoutEffect } from "react";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
import { PopoverProvider, usePopoverStore } from "@ariakit/react";
|
|
9
9
|
//#region src/components/client/Popover/Popover.tsx
|
|
10
|
+
function resolveAnchor(anchor) {
|
|
11
|
+
if (!anchor) return null;
|
|
12
|
+
return anchor instanceof HTMLElement ? anchor : anchor.current;
|
|
13
|
+
}
|
|
10
14
|
const POPOVER_OPEN_EVENT = "uds:popover-open";
|
|
11
15
|
/**
|
|
12
16
|
* **⚙️️ A Popover component that anchors to a trigger element
|
|
@@ -35,7 +39,7 @@ const POPOVER_OPEN_EVENT = "uds:popover-open";
|
|
|
35
39
|
*
|
|
36
40
|
* @related [Toast](https://uds.build/docs/components/toast), [Tooltip](https://uds.build/docs/components/tooltip)
|
|
37
41
|
**/
|
|
38
|
-
function Popover({ children, placement, open, defaultOpen = false, portal = true, hideArrow = false, hideDismissButton = false, onClose, onOpen, reduceMotion: forceReduceMotion = false, disableAutoFocus = false, disableVerticalSpacing = false, disableHorizontalSpacing = false, sameWidth = false, gutter = 4, unmountOnHide = false }) {
|
|
42
|
+
function Popover({ children, placement, anchor, open, defaultOpen = false, portal = true, hideArrow = false, hideDismissButton = false, onClose, onOpen, reduceMotion: forceReduceMotion = false, disableAutoFocus = false, disableVerticalSpacing = false, disableHorizontalSpacing = false, sameWidth = false, gutter = 4, unmountOnHide = false }) {
|
|
39
43
|
const controlledProps = open !== void 0 ? {
|
|
40
44
|
showTimeout: 0,
|
|
41
45
|
hideTimeout: 0,
|
|
@@ -45,6 +49,17 @@ function Popover({ children, placement, open, defaultOpen = false, portal = true
|
|
|
45
49
|
const { animationDuration: animationDurationConfig, ariaKitPlacement } = usePopoverConfig(void 0, void 0, { placement });
|
|
46
50
|
const id = useId();
|
|
47
51
|
const store = usePopoverStore({ defaultOpen });
|
|
52
|
+
useLayoutEffect(() => {
|
|
53
|
+
if (anchor === void 0) return;
|
|
54
|
+
const element = resolveAnchor(anchor);
|
|
55
|
+
store.setAnchorElement(element);
|
|
56
|
+
store.setDisclosureElement(element);
|
|
57
|
+
store.render();
|
|
58
|
+
}, [
|
|
59
|
+
store,
|
|
60
|
+
anchor,
|
|
61
|
+
open
|
|
62
|
+
]);
|
|
48
63
|
const handleSetOpen = useCallback((newOpen) => {
|
|
49
64
|
if (newOpen) {
|
|
50
65
|
onOpen?.();
|
|
@@ -75,7 +90,8 @@ function Popover({ children, placement, open, defaultOpen = false, portal = true
|
|
|
75
90
|
disableHorizontalSpacing,
|
|
76
91
|
sameWidth,
|
|
77
92
|
gutter,
|
|
78
|
-
unmountOnHide
|
|
93
|
+
unmountOnHide,
|
|
94
|
+
hasAnchor: anchor !== void 0
|
|
79
95
|
},
|
|
80
96
|
children: /* @__PURE__ */ jsx(PopoverProvider, {
|
|
81
97
|
placement: ariaKitPlacement,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
require("../../../_virtual/_rolldown/runtime.cjs");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _ariakit_react = require("@ariakit/react");
|
|
8
|
+
//#region src/components/client/Popover/PopoverAnchor.tsx
|
|
9
|
+
/**
|
|
10
|
+
* **⚙️️ Designates a consumer-rendered element as the popover's positioning anchor**
|
|
11
|
+
*
|
|
12
|
+
* @componentType Client component
|
|
13
|
+
*
|
|
14
|
+
* @description
|
|
15
|
+
* Unlike `PopoverTrigger`, `PopoverAnchor` only marks what the popover points at —
|
|
16
|
+
* it does not open the popover and writes no disclosure semantics to the element.
|
|
17
|
+
* Use it with a controlled `open` on `Popover` when the anchor is already
|
|
18
|
+
* interactive (or shouldn't be), e.g. onboarding cues pointing at existing UI.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* 'use client';
|
|
23
|
+
* import { Popover, PopoverAnchor, PopoverContent } from "@yahoo/uds";
|
|
24
|
+
*
|
|
25
|
+
* <Popover open={showCue} onClose={dismissCue}>
|
|
26
|
+
* <PopoverAnchor>
|
|
27
|
+
* <a href="/folders/trash">Trash</a>
|
|
28
|
+
* </PopoverAnchor>
|
|
29
|
+
* <PopoverContent aria-label="Onboarding tip">Tip content</PopoverContent>
|
|
30
|
+
* </Popover>
|
|
31
|
+
* ```
|
|
32
|
+
**/
|
|
33
|
+
function PopoverAnchor({ children }) {
|
|
34
|
+
if ((0, react.isValidElement)(children) && children.type !== react.Fragment) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ariakit_react.PopoverAnchor, { render: children });
|
|
35
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_ariakit_react.PopoverAnchor, {
|
|
36
|
+
className: "inline",
|
|
37
|
+
children
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
PopoverAnchor.displayName = "PopoverAnchor";
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.PopoverAnchor = PopoverAnchor;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/components/client/Popover/PopoverAnchor.d.ts
|
|
6
|
+
interface PopoverAnchorProps {
|
|
7
|
+
/** The element the popover points at. Only its position is used — no disclosure semantics (role, tabindex, aria-*) are applied. */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* **⚙️️ Designates a consumer-rendered element as the popover's positioning anchor**
|
|
12
|
+
*
|
|
13
|
+
* @componentType Client component
|
|
14
|
+
*
|
|
15
|
+
* @description
|
|
16
|
+
* Unlike `PopoverTrigger`, `PopoverAnchor` only marks what the popover points at —
|
|
17
|
+
* it does not open the popover and writes no disclosure semantics to the element.
|
|
18
|
+
* Use it with a controlled `open` on `Popover` when the anchor is already
|
|
19
|
+
* interactive (or shouldn't be), e.g. onboarding cues pointing at existing UI.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* 'use client';
|
|
24
|
+
* import { Popover, PopoverAnchor, PopoverContent } from "@yahoo/uds";
|
|
25
|
+
*
|
|
26
|
+
* <Popover open={showCue} onClose={dismissCue}>
|
|
27
|
+
* <PopoverAnchor>
|
|
28
|
+
* <a href="/folders/trash">Trash</a>
|
|
29
|
+
* </PopoverAnchor>
|
|
30
|
+
* <PopoverContent aria-label="Onboarding tip">Tip content</PopoverContent>
|
|
31
|
+
* </Popover>
|
|
32
|
+
* ```
|
|
33
|
+
**/
|
|
34
|
+
declare function PopoverAnchor({
|
|
35
|
+
children
|
|
36
|
+
}: PopoverAnchorProps): _$react_jsx_runtime0.JSX.Element;
|
|
37
|
+
declare namespace PopoverAnchor {
|
|
38
|
+
var displayName: string;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { PopoverAnchor, type PopoverAnchorProps };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
"use client";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/client/Popover/PopoverAnchor.d.ts
|
|
7
|
+
interface PopoverAnchorProps {
|
|
8
|
+
/** The element the popover points at. Only its position is used — no disclosure semantics (role, tabindex, aria-*) are applied. */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* **⚙️️ Designates a consumer-rendered element as the popover's positioning anchor**
|
|
13
|
+
*
|
|
14
|
+
* @componentType Client component
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* Unlike `PopoverTrigger`, `PopoverAnchor` only marks what the popover points at —
|
|
18
|
+
* it does not open the popover and writes no disclosure semantics to the element.
|
|
19
|
+
* Use it with a controlled `open` on `Popover` when the anchor is already
|
|
20
|
+
* interactive (or shouldn't be), e.g. onboarding cues pointing at existing UI.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* 'use client';
|
|
25
|
+
* import { Popover, PopoverAnchor, PopoverContent } from "@yahoo/uds";
|
|
26
|
+
*
|
|
27
|
+
* <Popover open={showCue} onClose={dismissCue}>
|
|
28
|
+
* <PopoverAnchor>
|
|
29
|
+
* <a href="/folders/trash">Trash</a>
|
|
30
|
+
* </PopoverAnchor>
|
|
31
|
+
* <PopoverContent aria-label="Onboarding tip">Tip content</PopoverContent>
|
|
32
|
+
* </Popover>
|
|
33
|
+
* ```
|
|
34
|
+
**/
|
|
35
|
+
declare function PopoverAnchor({
|
|
36
|
+
children
|
|
37
|
+
}: PopoverAnchorProps): _$react_jsx_runtime0.JSX.Element;
|
|
38
|
+
declare namespace PopoverAnchor {
|
|
39
|
+
var displayName: string;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { PopoverAnchor, type PopoverAnchorProps };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
"use client";
|
|
3
|
+
import { Fragment, isValidElement } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { PopoverAnchor as PopoverAnchor$1 } from "@ariakit/react";
|
|
6
|
+
//#region src/components/client/Popover/PopoverAnchor.tsx
|
|
7
|
+
/**
|
|
8
|
+
* **⚙️️ Designates a consumer-rendered element as the popover's positioning anchor**
|
|
9
|
+
*
|
|
10
|
+
* @componentType Client component
|
|
11
|
+
*
|
|
12
|
+
* @description
|
|
13
|
+
* Unlike `PopoverTrigger`, `PopoverAnchor` only marks what the popover points at —
|
|
14
|
+
* it does not open the popover and writes no disclosure semantics to the element.
|
|
15
|
+
* Use it with a controlled `open` on `Popover` when the anchor is already
|
|
16
|
+
* interactive (or shouldn't be), e.g. onboarding cues pointing at existing UI.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* 'use client';
|
|
21
|
+
* import { Popover, PopoverAnchor, PopoverContent } from "@yahoo/uds";
|
|
22
|
+
*
|
|
23
|
+
* <Popover open={showCue} onClose={dismissCue}>
|
|
24
|
+
* <PopoverAnchor>
|
|
25
|
+
* <a href="/folders/trash">Trash</a>
|
|
26
|
+
* </PopoverAnchor>
|
|
27
|
+
* <PopoverContent aria-label="Onboarding tip">Tip content</PopoverContent>
|
|
28
|
+
* </Popover>
|
|
29
|
+
* ```
|
|
30
|
+
**/
|
|
31
|
+
function PopoverAnchor({ children }) {
|
|
32
|
+
if (isValidElement(children) && children.type !== Fragment) return /* @__PURE__ */ jsx(PopoverAnchor$1, { render: children });
|
|
33
|
+
return /* @__PURE__ */ jsx(PopoverAnchor$1, {
|
|
34
|
+
className: "inline",
|
|
35
|
+
children
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
PopoverAnchor.displayName = "PopoverAnchor";
|
|
39
|
+
//#endregion
|
|
40
|
+
export { PopoverAnchor };
|
|
@@ -21,7 +21,7 @@ let _ariakit_react = require("@ariakit/react");
|
|
|
21
21
|
const ARROW_HEIGHT = 12;
|
|
22
22
|
const ARROW_WIDTH = 22;
|
|
23
23
|
const ARROW_TIP_RADIUS_FRACTION = .3;
|
|
24
|
-
const PopoverContent = (0, react.forwardRef)(function PopoverContent({ children, className, closeIcon = _yahoo_uds_icons.Cross, slotProps, maxWidth, maxHeight }, ref) {
|
|
24
|
+
const PopoverContent = (0, react.forwardRef)(function PopoverContent({ children, className, closeIcon = _yahoo_uds_icons.Cross, slotProps, maxWidth, maxHeight, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }, ref) {
|
|
25
25
|
const store = (0, _ariakit_react.usePopoverContext)();
|
|
26
26
|
const open = (0, _ariakit_react.useStoreState)(store, "open");
|
|
27
27
|
const internalContext = (0, react.useContext)(require_components_client_Popover_PopoverContext.PopoverInternalContext);
|
|
@@ -104,6 +104,8 @@ const PopoverContent = (0, react.forwardRef)(function PopoverContent({ children,
|
|
|
104
104
|
ref: mergedRef,
|
|
105
105
|
className: classNames.root,
|
|
106
106
|
unmountOnHide: internalContext?.unmountOnHide,
|
|
107
|
+
"aria-label": ariaLabel,
|
|
108
|
+
"aria-labelledby": ariaLabelledBy,
|
|
107
109
|
...slotProps?.root,
|
|
108
110
|
portal: internalContext ? internalContext.portal : true,
|
|
109
111
|
gutter: internalContext?.hideArrow ? gutter : ARROW_HEIGHT + gutter,
|
|
@@ -9,6 +9,10 @@ type DataAttributes = {
|
|
|
9
9
|
[name: `data-${string}`]: string;
|
|
10
10
|
};
|
|
11
11
|
interface PopoverContentProps extends UniversalPopoverContentProps {
|
|
12
|
+
/** Accessible name for the popover dialog. Required when no visible heading is referenced via `aria-labelledby`. */
|
|
13
|
+
'aria-label'?: string;
|
|
14
|
+
/** ID of the element that labels the popover dialog. */
|
|
15
|
+
'aria-labelledby'?: string;
|
|
12
16
|
slotProps?: {
|
|
13
17
|
root?: Partial<React.HTMLAttributes<HTMLDivElement> & DataAttributes>;
|
|
14
18
|
content?: Partial<React.HTMLAttributes<HTMLDivElement> & DataAttributes>;
|
|
@@ -25,4 +29,4 @@ interface PopoverContentProps extends UniversalPopoverContentProps {
|
|
|
25
29
|
}
|
|
26
30
|
declare const PopoverContent: _$react.ForwardRefExoticComponent<PopoverContentProps & _$react.RefAttributes<HTMLInputElement>>;
|
|
27
31
|
//#endregion
|
|
28
|
-
export { PopoverContent };
|
|
32
|
+
export { PopoverContent, type PopoverContentProps };
|
|
@@ -10,6 +10,10 @@ type DataAttributes = {
|
|
|
10
10
|
[name: `data-${string}`]: string;
|
|
11
11
|
};
|
|
12
12
|
interface PopoverContentProps extends UniversalPopoverContentProps {
|
|
13
|
+
/** Accessible name for the popover dialog. Required when no visible heading is referenced via `aria-labelledby`. */
|
|
14
|
+
'aria-label'?: string;
|
|
15
|
+
/** ID of the element that labels the popover dialog. */
|
|
16
|
+
'aria-labelledby'?: string;
|
|
13
17
|
slotProps?: {
|
|
14
18
|
root?: Partial<React.HTMLAttributes<HTMLDivElement> & DataAttributes>;
|
|
15
19
|
content?: Partial<React.HTMLAttributes<HTMLDivElement> & DataAttributes>;
|
|
@@ -26,4 +30,4 @@ interface PopoverContentProps extends UniversalPopoverContentProps {
|
|
|
26
30
|
}
|
|
27
31
|
declare const PopoverContent: _$react.ForwardRefExoticComponent<PopoverContentProps & _$react.RefAttributes<HTMLInputElement>>;
|
|
28
32
|
//#endregion
|
|
29
|
-
export { PopoverContent };
|
|
33
|
+
export { PopoverContent, type PopoverContentProps };
|
|
@@ -19,7 +19,7 @@ import { Popover, PopoverArrow, PopoverDismiss, usePopoverContext, useStoreState
|
|
|
19
19
|
const ARROW_HEIGHT = 12;
|
|
20
20
|
const ARROW_WIDTH = 22;
|
|
21
21
|
const ARROW_TIP_RADIUS_FRACTION = .3;
|
|
22
|
-
const PopoverContent = forwardRef(function PopoverContent({ children, className, closeIcon = Cross, slotProps, maxWidth, maxHeight }, ref) {
|
|
22
|
+
const PopoverContent = forwardRef(function PopoverContent({ children, className, closeIcon = Cross, slotProps, maxWidth, maxHeight, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }, ref) {
|
|
23
23
|
const store = usePopoverContext();
|
|
24
24
|
const open = useStoreState(store, "open");
|
|
25
25
|
const internalContext = useContext(PopoverInternalContext);
|
|
@@ -102,6 +102,8 @@ const PopoverContent = forwardRef(function PopoverContent({ children, className,
|
|
|
102
102
|
ref: mergedRef,
|
|
103
103
|
className: classNames.root,
|
|
104
104
|
unmountOnHide: internalContext?.unmountOnHide,
|
|
105
|
+
"aria-label": ariaLabel,
|
|
106
|
+
"aria-labelledby": ariaLabelledBy,
|
|
105
107
|
...slotProps?.root,
|
|
106
108
|
portal: internalContext ? internalContext.portal : true,
|
|
107
109
|
gutter: internalContext?.hideArrow ? gutter : ARROW_HEIGHT + gutter,
|
|
@@ -11,6 +11,10 @@ function PopoverTrigger({ children }) {
|
|
|
11
11
|
const internalContext = (0, react.useContext)(require_components_client_Popover_PopoverContext.PopoverInternalContext);
|
|
12
12
|
const open = (0, _ariakit_react.useStoreState)((0, _ariakit_react.usePopoverContext)(), "open");
|
|
13
13
|
const toggleOnClick = !internalContext?.isControlled;
|
|
14
|
+
const hasAnchor = internalContext?.hasAnchor ?? false;
|
|
15
|
+
(0, react.useEffect)(() => {
|
|
16
|
+
if (process.env.NODE_ENV !== "production" && hasAnchor) console.warn("UDS Popover: `PopoverTrigger` is ignored for positioning when the `anchor` prop is set on `Popover`. Remove one of them.");
|
|
17
|
+
}, [hasAnchor]);
|
|
14
18
|
const handleClick = (event) => {
|
|
15
19
|
if (internalContext?.isControlled && open) internalContext.onClose?.(event.nativeEvent);
|
|
16
20
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
"use client";
|
|
3
3
|
import { PopoverInternalContext } from "./PopoverContext.js";
|
|
4
|
-
import { Fragment, isValidElement, useContext } from "react";
|
|
4
|
+
import { Fragment, isValidElement, useContext, useEffect } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { PopoverDisclosure, usePopoverContext, useStoreState } from "@ariakit/react";
|
|
7
7
|
//#region src/components/client/Popover/PopoverTrigger.tsx
|
|
@@ -9,6 +9,10 @@ function PopoverTrigger({ children }) {
|
|
|
9
9
|
const internalContext = useContext(PopoverInternalContext);
|
|
10
10
|
const open = useStoreState(usePopoverContext(), "open");
|
|
11
11
|
const toggleOnClick = !internalContext?.isControlled;
|
|
12
|
+
const hasAnchor = internalContext?.hasAnchor ?? false;
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (process.env.NODE_ENV !== "production" && hasAnchor) console.warn("UDS Popover: `PopoverTrigger` is ignored for positioning when the `anchor` prop is set on `Popover`. Remove one of them.");
|
|
15
|
+
}, [hasAnchor]);
|
|
12
16
|
const handleClick = (event) => {
|
|
13
17
|
if (internalContext?.isControlled && open) internalContext.onClose?.(event.nativeEvent);
|
|
14
18
|
};
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const require_components_client_Popover_UDSPopoverConfigProvider = require("./UDSPopoverConfigProvider.cjs");
|
|
5
5
|
const require_components_client_Popover_Popover = require("./Popover.cjs");
|
|
6
|
+
const require_components_client_Popover_PopoverAnchor = require("./PopoverAnchor.cjs");
|
|
6
7
|
const require_components_client_Popover_PopoverContent = require("./PopoverContent.cjs");
|
|
7
8
|
const require_components_client_Popover_PopoverTrigger = require("./PopoverTrigger.cjs");
|
|
8
9
|
exports.Popover = require_components_client_Popover_Popover.Popover;
|
|
10
|
+
exports.PopoverAnchor = require_components_client_Popover_PopoverAnchor.PopoverAnchor;
|
|
9
11
|
exports.PopoverContent = require_components_client_Popover_PopoverContent.PopoverContent;
|
|
10
12
|
exports.PopoverTrigger = require_components_client_Popover_PopoverTrigger.PopoverTrigger;
|
|
11
13
|
exports.UDSPopoverConfigProvider = require_components_client_Popover_UDSPopoverConfigProvider.UDSPopoverConfigProvider;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import { Popover } from "./Popover.cjs";
|
|
4
|
-
import {
|
|
2
|
+
import { UniversalPopoverTriggerProps } from "../../../types/dist/index.cjs";
|
|
3
|
+
import { Popover, PopoverAnchorTarget, PopoverProps } from "./Popover.cjs";
|
|
4
|
+
import { PopoverAnchor, PopoverAnchorProps } from "./PopoverAnchor.cjs";
|
|
5
|
+
import { PopoverContent, PopoverContentProps } from "./PopoverContent.cjs";
|
|
5
6
|
import { PopoverTrigger } from "./PopoverTrigger.cjs";
|
|
6
7
|
import { UDSPopoverConfigProvider, UDSPopoverConfigProviderProps } from "./UDSPopoverConfigProvider.cjs";
|
|
7
|
-
export { Popover,
|
|
8
|
+
export { Popover, PopoverAnchor, PopoverAnchorProps, PopoverAnchorTarget, PopoverContent, PopoverContentProps, PopoverProps, PopoverTrigger, type UniversalPopoverTriggerProps as PopoverTriggerProps, UDSPopoverConfigProvider, type UDSPopoverConfigProviderProps };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
"use client";
|
|
3
|
-
import {
|
|
4
|
-
import { Popover } from "./Popover.js";
|
|
5
|
-
import {
|
|
3
|
+
import { UniversalPopoverTriggerProps } from "../../../types/dist/index.js";
|
|
4
|
+
import { Popover, PopoverAnchorTarget, PopoverProps } from "./Popover.js";
|
|
5
|
+
import { PopoverAnchor, PopoverAnchorProps } from "./PopoverAnchor.js";
|
|
6
|
+
import { PopoverContent, PopoverContentProps } from "./PopoverContent.js";
|
|
6
7
|
import { PopoverTrigger } from "./PopoverTrigger.js";
|
|
7
8
|
import { UDSPopoverConfigProvider, UDSPopoverConfigProviderProps } from "./UDSPopoverConfigProvider.js";
|
|
8
|
-
export { Popover,
|
|
9
|
+
export { Popover, PopoverAnchor, PopoverAnchorProps, PopoverAnchorTarget, PopoverContent, PopoverContentProps, PopoverProps, PopoverTrigger, type UniversalPopoverTriggerProps as PopoverTriggerProps, UDSPopoverConfigProvider, type UDSPopoverConfigProviderProps };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import { UDSPopoverConfigProvider } from "./UDSPopoverConfigProvider.js";
|
|
4
4
|
import { Popover } from "./Popover.js";
|
|
5
|
+
import { PopoverAnchor } from "./PopoverAnchor.js";
|
|
5
6
|
import { PopoverContent } from "./PopoverContent.js";
|
|
6
7
|
import { PopoverTrigger } from "./PopoverTrigger.js";
|
|
7
|
-
export { Popover, PopoverContent, PopoverTrigger, UDSPopoverConfigProvider };
|
|
8
|
+
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger, UDSPopoverConfigProvider };
|