@ariakit/react-core 0.1.7 → 0.2.0
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/CHANGELOG.md +108 -0
- package/cjs/__chunks/{XFZ3MEQZ.cjs → 27JG67F3.cjs} +3 -3
- package/cjs/__chunks/{ASQZCUUA.cjs → 4SZYU2PD.cjs} +2 -2
- package/cjs/__chunks/5P6HRGY6.cjs +21 -0
- package/cjs/__chunks/{DCDTT7UY.cjs → A6ZSQXNQ.cjs} +2 -2
- package/cjs/__chunks/{QXXZLOZG.cjs → D3EUPD6P.cjs} +22 -41
- package/cjs/__chunks/{EEXWIKOB.cjs → GOXUG4RX.cjs} +41 -53
- package/cjs/__chunks/{RHO5OVPE.cjs → GRL5KGV3.cjs} +2 -2
- package/cjs/__chunks/MHL3EECX.cjs +363 -0
- package/cjs/__chunks/{AUDANYMJ.cjs → W2XKIB23.cjs} +1 -20
- package/cjs/__chunks/{PFD4TS6B.cjs → WWDX5YPG.cjs} +28 -15
- package/cjs/combobox/combobox-item.cjs +1 -1
- package/cjs/combobox/combobox-popover.cjs +12 -11
- package/cjs/combobox/combobox-store.cjs +3 -3
- package/cjs/combobox/combobox-store.d.ts +0 -7
- package/cjs/combobox/combobox.cjs +3 -3
- package/cjs/composite/composite-item.cjs +1 -1
- package/cjs/composite/composite-overflow-disclosure.cjs +5 -5
- package/cjs/composite/composite-overflow-store.cjs +3 -3
- package/cjs/composite/composite-overflow-store.d.ts +1 -13
- package/cjs/composite/composite-overflow.cjs +12 -11
- package/cjs/composite/composite.cjs +3 -3
- package/cjs/dialog/dialog-backdrop.cjs +6 -3
- package/cjs/dialog/dialog-backdrop.d.ts +2 -5
- package/cjs/dialog/dialog-dismiss.cjs +1 -1
- package/cjs/dialog/dialog.cjs +11 -10
- package/cjs/dialog/dialog.d.ts +21 -8
- package/cjs/dialog/utils/is-backdrop.cjs +21 -0
- package/cjs/dialog/utils/is-backdrop.d.ts +1 -0
- package/cjs/form/form-radio.cjs +1 -1
- package/cjs/heading/heading-level.d.ts +1 -1
- package/cjs/hovercard/hovercard-dismiss.cjs +1 -1
- package/cjs/hovercard/hovercard-store.cjs +3 -3
- package/cjs/hovercard/hovercard-store.d.ts +1 -13
- package/cjs/hovercard/hovercard.cjs +13 -12
- package/cjs/menu/menu-bar.cjs +3 -3
- package/cjs/menu/menu-button.cjs +8 -8
- package/cjs/menu/menu-dismiss.cjs +1 -1
- package/cjs/menu/menu-item-checkbox.cjs +1 -1
- package/cjs/menu/menu-item-radio.cjs +1 -1
- package/cjs/menu/menu-item.cjs +1 -1
- package/cjs/menu/menu-list.cjs +4 -4
- package/cjs/menu/menu-store.cjs +7 -7
- package/cjs/menu/menu-store.d.ts +0 -7
- package/cjs/menu/menu.cjs +21 -20
- package/cjs/popover/popover-disclosure.cjs +4 -4
- package/cjs/popover/popover-dismiss.cjs +1 -1
- package/cjs/popover/popover-store.cjs +2 -2
- package/cjs/popover/popover-store.d.ts +1 -13
- package/cjs/popover/popover.cjs +12 -11
- package/cjs/popover/popover.d.ts +96 -0
- package/cjs/portal/portal.cjs +2 -2
- package/cjs/radio/radio-group.cjs +3 -3
- package/cjs/radio/radio.cjs +1 -1
- package/cjs/role/role.cjs +3 -14
- package/cjs/select/select-item.cjs +1 -1
- package/cjs/select/select-list.cjs +4 -4
- package/cjs/select/select-popover.cjs +21 -20
- package/cjs/select/select-store.cjs +3 -3
- package/cjs/select/select-store.d.ts +0 -7
- package/cjs/select/select.cjs +5 -5
- package/cjs/tab/tab-list.cjs +3 -3
- package/cjs/tab/tab-panel.cjs +3 -3
- package/cjs/tab/tab.cjs +1 -1
- package/cjs/toolbar/toolbar-container.cjs +1 -1
- package/cjs/toolbar/toolbar-input.cjs +1 -1
- package/cjs/toolbar/toolbar-item.cjs +1 -1
- package/cjs/toolbar/toolbar.cjs +3 -3
- package/cjs/tooltip/tooltip-anchor.cjs +58 -28
- package/cjs/tooltip/tooltip-anchor.d.ts +2 -18
- package/cjs/tooltip/tooltip-store.cjs +4 -3
- package/cjs/tooltip/tooltip-store.d.ts +5 -17
- package/cjs/tooltip/tooltip.cjs +66 -67
- package/cjs/tooltip/tooltip.d.ts +6 -25
- package/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dialog/utils/is-backdrop/package.json +7 -0
- package/esm/__chunks/{USCWE5QL.js → 2CA5JWPW.js} +28 -15
- package/esm/__chunks/5PIH3SMS.js +35 -0
- package/esm/__chunks/{PZK3B6LX.js → 776K5FXB.js} +1 -1
- package/esm/__chunks/{DQSQP4IL.js → GDDVBILZ.js} +1 -1
- package/esm/__chunks/{3L2YBPR3.js → HJWYYQGA.js} +1 -1
- package/esm/__chunks/{3FKA4P4C.js → K5R24MFH.js} +1 -1
- package/esm/__chunks/MLEIJKSM.js +363 -0
- package/esm/__chunks/{JXNLCNWG.js → MR75RQGW.js} +25 -44
- package/esm/__chunks/{TCX5FQUL.js → NAG6UD2X.js} +43 -55
- package/esm/__chunks/XIACQCPS.js +21 -0
- package/esm/combobox/combobox-item.js +1 -1
- package/esm/combobox/combobox-popover.js +11 -10
- package/esm/combobox/combobox-store.d.ts +0 -7
- package/esm/combobox/combobox-store.js +1 -1
- package/esm/combobox/combobox.js +2 -2
- package/esm/composite/composite-item.js +1 -1
- package/esm/composite/composite-overflow-disclosure.js +4 -4
- package/esm/composite/composite-overflow-store.d.ts +1 -13
- package/esm/composite/composite-overflow-store.js +1 -1
- package/esm/composite/composite-overflow.js +11 -10
- package/esm/composite/composite.js +2 -2
- package/esm/dialog/dialog-backdrop.d.ts +2 -5
- package/esm/dialog/dialog-backdrop.js +5 -2
- package/esm/dialog/dialog-dismiss.js +1 -1
- package/esm/dialog/dialog.d.ts +21 -8
- package/esm/dialog/dialog.js +10 -9
- package/esm/dialog/utils/is-backdrop.d.ts +1 -0
- package/esm/dialog/utils/is-backdrop.js +21 -0
- package/esm/form/form-radio.js +1 -1
- package/esm/heading/heading-level.d.ts +1 -1
- package/esm/hovercard/hovercard-dismiss.js +1 -1
- package/esm/hovercard/hovercard-store.d.ts +1 -13
- package/esm/hovercard/hovercard-store.js +2 -2
- package/esm/hovercard/hovercard.js +12 -11
- package/esm/menu/menu-bar.js +2 -2
- package/esm/menu/menu-button.js +7 -7
- package/esm/menu/menu-dismiss.js +1 -1
- package/esm/menu/menu-item-checkbox.js +1 -1
- package/esm/menu/menu-item-radio.js +1 -1
- package/esm/menu/menu-item.js +1 -1
- package/esm/menu/menu-list.js +3 -3
- package/esm/menu/menu-store.d.ts +0 -7
- package/esm/menu/menu-store.js +5 -5
- package/esm/menu/menu.js +20 -19
- package/esm/popover/popover-disclosure.js +3 -3
- package/esm/popover/popover-dismiss.js +1 -1
- package/esm/popover/popover-store.d.ts +1 -13
- package/esm/popover/popover-store.js +1 -1
- package/esm/popover/popover.d.ts +96 -0
- package/esm/popover/popover.js +11 -10
- package/esm/portal/portal.js +1 -1
- package/esm/radio/radio-group.js +2 -2
- package/esm/radio/radio.js +1 -1
- package/esm/role/role.js +4 -15
- package/esm/select/select-item.js +1 -1
- package/esm/select/select-list.js +3 -3
- package/esm/select/select-popover.js +19 -18
- package/esm/select/select-store.d.ts +0 -7
- package/esm/select/select-store.js +1 -1
- package/esm/select/select.js +4 -4
- package/esm/tab/tab-list.js +2 -2
- package/esm/tab/tab-panel.js +3 -3
- package/esm/tab/tab.js +1 -1
- package/esm/toolbar/toolbar-container.js +1 -1
- package/esm/toolbar/toolbar-input.js +1 -1
- package/esm/toolbar/toolbar-item.js +1 -1
- package/esm/toolbar/toolbar.js +2 -2
- package/esm/tooltip/tooltip-anchor.d.ts +2 -18
- package/esm/tooltip/tooltip-anchor.js +59 -29
- package/esm/tooltip/tooltip-store.d.ts +5 -17
- package/esm/tooltip/tooltip-store.js +6 -5
- package/esm/tooltip/tooltip.d.ts +6 -25
- package/esm/tooltip/tooltip.js +67 -68
- package/esm/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -2
- package/cjs/__chunks/FU76FHC2.cjs +0 -125
- package/esm/__chunks/RVIGSXKO.js +0 -125
- package/esm/__chunks/SHGWT5HV.js +0 -54
- package/cjs/__chunks/{OV363CW6.cjs → BDJYHP43.cjs} +2 -2
- package/cjs/__chunks/{5I6IQHKQ.cjs → BIPONQXE.cjs} +2 -2
- package/esm/__chunks/{OY5YT7OV.js → RTOWJJVI.js} +3 -3
- package/esm/__chunks/{6O3TZMB4.js → U2KSDJ3W.js} +3 -3
|
@@ -6,13 +6,6 @@ import type { Store } from "../utils/store.js";
|
|
|
6
6
|
type Item = Core.SelectStoreItem;
|
|
7
7
|
type Value = Core.SelectStoreValue;
|
|
8
8
|
export declare function useSelectStoreOptions<T extends Value = Value>(props: SelectStoreProps<T>): {
|
|
9
|
-
getAnchorRect: ((anchor: HTMLElement | null) => {
|
|
10
|
-
x?: number | undefined;
|
|
11
|
-
y?: number | undefined;
|
|
12
|
-
width?: number | undefined;
|
|
13
|
-
height?: number | undefined;
|
|
14
|
-
} | null) | undefined;
|
|
15
|
-
renderCallback: ((props: import("@ariakit/core/popover/popover-store").PopoverStoreRenderCallbackProps) => void | (() => void)) | undefined;
|
|
16
9
|
setOpen?: ((open: boolean) => void) | undefined;
|
|
17
10
|
defaultOpen?: boolean | undefined;
|
|
18
11
|
open?: boolean | undefined;
|
package/esm/select/select.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
usePopoverDisclosure
|
|
3
|
-
} from "../__chunks/
|
|
3
|
+
} from "../__chunks/U2KSDJ3W.js";
|
|
4
4
|
import "../__chunks/LSTZ5Q72.js";
|
|
5
5
|
import "../__chunks/24P2K6AU.js";
|
|
6
|
+
import "../__chunks/D6NPK2DL.js";
|
|
6
7
|
import "../__chunks/OQUXG6FE.js";
|
|
7
8
|
import {
|
|
8
9
|
SelectArrow
|
|
@@ -14,13 +15,12 @@ import {
|
|
|
14
15
|
import {
|
|
15
16
|
SelectContext
|
|
16
17
|
} from "../__chunks/EEVSGAZW.js";
|
|
17
|
-
import "../__chunks/6GS36SYX.js";
|
|
18
|
-
import "../__chunks/D6NPK2DL.js";
|
|
19
18
|
import "../__chunks/4QNHBDVS.js";
|
|
20
19
|
import "../__chunks/OXPV2NBK.js";
|
|
20
|
+
import "../__chunks/Z3X3QN6P.js";
|
|
21
|
+
import "../__chunks/6GS36SYX.js";
|
|
21
22
|
import "../__chunks/AGWM73EZ.js";
|
|
22
23
|
import "../__chunks/BMLNRUFQ.js";
|
|
23
|
-
import "../__chunks/Z3X3QN6P.js";
|
|
24
24
|
import {
|
|
25
25
|
VisuallyHidden
|
|
26
26
|
} from "../__chunks/JQEVJM46.js";
|
package/esm/tab/tab-list.js
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
} from "../__chunks/UZKBEGMB.js";
|
|
4
4
|
import {
|
|
5
5
|
useComposite
|
|
6
|
-
} from "../__chunks/
|
|
6
|
+
} from "../__chunks/RTOWJJVI.js";
|
|
7
7
|
import "../__chunks/OXPV2NBK.js";
|
|
8
|
+
import "../__chunks/Z3X3QN6P.js";
|
|
8
9
|
import "../__chunks/AGWM73EZ.js";
|
|
9
10
|
import "../__chunks/BMLNRUFQ.js";
|
|
10
|
-
import "../__chunks/Z3X3QN6P.js";
|
|
11
11
|
import {
|
|
12
12
|
createComponent,
|
|
13
13
|
createElement,
|
package/esm/tab/tab-panel.js
CHANGED
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
useCollectionItem
|
|
3
3
|
} from "../__chunks/X7UZWWYG.js";
|
|
4
4
|
import "../__chunks/T3DJZG63.js";
|
|
5
|
+
import {
|
|
6
|
+
useDisclosureContent
|
|
7
|
+
} from "../__chunks/6AJCHLAV.js";
|
|
5
8
|
import {
|
|
6
9
|
useFocusable
|
|
7
10
|
} from "../__chunks/AGWM73EZ.js";
|
|
8
11
|
import "../__chunks/BMLNRUFQ.js";
|
|
9
|
-
import {
|
|
10
|
-
useDisclosureContent
|
|
11
|
-
} from "../__chunks/6AJCHLAV.js";
|
|
12
12
|
import {
|
|
13
13
|
createComponent,
|
|
14
14
|
createElement,
|
package/esm/tab/tab.js
CHANGED
|
@@ -8,9 +8,9 @@ import "../__chunks/4QNHBDVS.js";
|
|
|
8
8
|
import "../__chunks/X7UZWWYG.js";
|
|
9
9
|
import "../__chunks/T3DJZG63.js";
|
|
10
10
|
import "../__chunks/OXPV2NBK.js";
|
|
11
|
+
import "../__chunks/Z3X3QN6P.js";
|
|
11
12
|
import "../__chunks/AGWM73EZ.js";
|
|
12
13
|
import "../__chunks/BMLNRUFQ.js";
|
|
13
|
-
import "../__chunks/Z3X3QN6P.js";
|
|
14
14
|
import {
|
|
15
15
|
createElement,
|
|
16
16
|
createHook,
|
|
@@ -9,9 +9,9 @@ import "../__chunks/4QNHBDVS.js";
|
|
|
9
9
|
import "../__chunks/X7UZWWYG.js";
|
|
10
10
|
import "../__chunks/T3DJZG63.js";
|
|
11
11
|
import "../__chunks/OXPV2NBK.js";
|
|
12
|
+
import "../__chunks/Z3X3QN6P.js";
|
|
12
13
|
import "../__chunks/AGWM73EZ.js";
|
|
13
14
|
import "../__chunks/BMLNRUFQ.js";
|
|
14
|
-
import "../__chunks/Z3X3QN6P.js";
|
|
15
15
|
import {
|
|
16
16
|
createElement,
|
|
17
17
|
createHook,
|
|
@@ -9,9 +9,9 @@ import "../__chunks/4QNHBDVS.js";
|
|
|
9
9
|
import "../__chunks/X7UZWWYG.js";
|
|
10
10
|
import "../__chunks/T3DJZG63.js";
|
|
11
11
|
import "../__chunks/OXPV2NBK.js";
|
|
12
|
+
import "../__chunks/Z3X3QN6P.js";
|
|
12
13
|
import "../__chunks/AGWM73EZ.js";
|
|
13
14
|
import "../__chunks/BMLNRUFQ.js";
|
|
14
|
-
import "../__chunks/Z3X3QN6P.js";
|
|
15
15
|
import {
|
|
16
16
|
createElement,
|
|
17
17
|
createHook,
|
|
@@ -7,9 +7,9 @@ import "../__chunks/4QNHBDVS.js";
|
|
|
7
7
|
import "../__chunks/X7UZWWYG.js";
|
|
8
8
|
import "../__chunks/T3DJZG63.js";
|
|
9
9
|
import "../__chunks/OXPV2NBK.js";
|
|
10
|
+
import "../__chunks/Z3X3QN6P.js";
|
|
10
11
|
import "../__chunks/AGWM73EZ.js";
|
|
11
12
|
import "../__chunks/BMLNRUFQ.js";
|
|
12
|
-
import "../__chunks/Z3X3QN6P.js";
|
|
13
13
|
import "../__chunks/5ETIGB6O.js";
|
|
14
14
|
import "../__chunks/AV5WE37O.js";
|
|
15
15
|
import "../__chunks/ASYR66PQ.js";
|
package/esm/toolbar/toolbar.js
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
} from "../__chunks/DFUIIKXE.js";
|
|
4
4
|
import {
|
|
5
5
|
useComposite
|
|
6
|
-
} from "../__chunks/
|
|
6
|
+
} from "../__chunks/RTOWJJVI.js";
|
|
7
7
|
import "../__chunks/OXPV2NBK.js";
|
|
8
|
+
import "../__chunks/Z3X3QN6P.js";
|
|
8
9
|
import "../__chunks/AGWM73EZ.js";
|
|
9
10
|
import "../__chunks/BMLNRUFQ.js";
|
|
10
|
-
import "../__chunks/Z3X3QN6P.js";
|
|
11
11
|
import {
|
|
12
12
|
createComponent,
|
|
13
13
|
createElement,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HovercardAnchorOptions } from "../hovercard/hovercard-anchor.js";
|
|
2
2
|
import type { As, Props } from "../utils/types.js";
|
|
3
3
|
import type { TooltipStore } from "./tooltip-store.js";
|
|
4
4
|
/**
|
|
@@ -26,26 +26,10 @@ export declare const useTooltipAnchor: import("../utils/types.js").Hook<TooltipA
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
export declare const TooltipAnchor: import("../utils/types.js").Component<TooltipAnchorOptions<"div">>;
|
|
29
|
-
export interface TooltipAnchorOptions<T extends As = "div"> extends
|
|
29
|
+
export interface TooltipAnchorOptions<T extends As = "div"> extends HovercardAnchorOptions<T> {
|
|
30
30
|
/**
|
|
31
31
|
* Object returned by the `useTooltipStore` hook.
|
|
32
32
|
*/
|
|
33
33
|
store: TooltipStore;
|
|
34
|
-
/**
|
|
35
|
-
* Determines wether the tooltip anchor is described or labelled by the
|
|
36
|
-
* tooltip. If `true`, the tooltip id will be set as the `aria-describedby`
|
|
37
|
-
* attribute on the anchor element, and not as the `aria-labelledby`
|
|
38
|
-
* attribute.
|
|
39
|
-
* @default false
|
|
40
|
-
* @example
|
|
41
|
-
* ```jsx
|
|
42
|
-
* const tooltip = useTooltipStore();
|
|
43
|
-
* <TooltipAnchor store={tooltip} described>
|
|
44
|
-
* This is an element with a visible label.
|
|
45
|
-
* </TooltipAnchor>
|
|
46
|
-
* <Tooltip store={tooltip}>Description</Tooltip>
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
described?: boolean;
|
|
50
34
|
}
|
|
51
35
|
export type TooltipAnchorProps<T extends As = "div"> = Props<TooltipAnchorOptions<T>>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../__chunks/
|
|
2
|
+
useHovercardAnchor
|
|
3
|
+
} from "../__chunks/65MJJ4BW.js";
|
|
4
|
+
import "../__chunks/AGWM73EZ.js";
|
|
5
|
+
import "../__chunks/BMLNRUFQ.js";
|
|
4
6
|
import {
|
|
5
7
|
createComponent,
|
|
6
8
|
createElement,
|
|
@@ -17,12 +19,39 @@ import {
|
|
|
17
19
|
} from "../__chunks/4BKCJXBM.js";
|
|
18
20
|
|
|
19
21
|
// src/tooltip/tooltip-anchor.ts
|
|
22
|
+
import { useEffect } from "react";
|
|
23
|
+
import { isFalsyBooleanCallback } from "@ariakit/core/utils/misc";
|
|
24
|
+
import { createStore } from "@ariakit/core/utils/store";
|
|
25
|
+
var globalStore = createStore({
|
|
26
|
+
activeStore: null
|
|
27
|
+
});
|
|
20
28
|
var useTooltipAnchor = createHook(
|
|
21
29
|
(_a) => {
|
|
22
|
-
var _b = _a, { store,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
var _b = _a, { store, showOnHover = true } = _b, props = __objRest(_b, ["store", "showOnHover"]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
return store.sync(
|
|
33
|
+
(state) => {
|
|
34
|
+
if (state.mounted) {
|
|
35
|
+
const { activeStore } = globalStore.getState();
|
|
36
|
+
if (activeStore !== store) {
|
|
37
|
+
activeStore == null ? void 0 : activeStore.hide();
|
|
38
|
+
}
|
|
39
|
+
return globalStore.setState("activeStore", store);
|
|
40
|
+
}
|
|
41
|
+
const id = setTimeout(() => {
|
|
42
|
+
const { activeStore } = globalStore.getState();
|
|
43
|
+
if (activeStore !== store)
|
|
44
|
+
return;
|
|
45
|
+
globalStore.setState("activeStore", null);
|
|
46
|
+
}, state.skipTimeout);
|
|
47
|
+
return () => clearTimeout(id);
|
|
48
|
+
},
|
|
49
|
+
["mounted", "skipTimeout"]
|
|
50
|
+
);
|
|
51
|
+
}, [store]);
|
|
52
|
+
const onFocusVisibleProp = props.onFocusVisible;
|
|
53
|
+
const onFocusVisible = useEvent((event) => {
|
|
54
|
+
onFocusVisibleProp == null ? void 0 : onFocusVisibleProp(event);
|
|
26
55
|
if (event.defaultPrevented)
|
|
27
56
|
return;
|
|
28
57
|
store.setAnchorElement(event.currentTarget);
|
|
@@ -33,35 +62,36 @@ var useTooltipAnchor = createHook(
|
|
|
33
62
|
onBlurProp == null ? void 0 : onBlurProp(event);
|
|
34
63
|
if (event.defaultPrevented)
|
|
35
64
|
return;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
onMouseEnterProp == null ? void 0 : onMouseEnterProp(event);
|
|
41
|
-
if (event.defaultPrevented)
|
|
42
|
-
return;
|
|
43
|
-
store.setAnchorElement(event.currentTarget);
|
|
44
|
-
store.show();
|
|
65
|
+
const { activeStore } = globalStore.getState();
|
|
66
|
+
if (activeStore === store) {
|
|
67
|
+
globalStore.setState("activeStore", null);
|
|
68
|
+
}
|
|
45
69
|
});
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return;
|
|
51
|
-
store.hide();
|
|
70
|
+
const type = store.useState("type");
|
|
71
|
+
const contentId = store.useState((state) => {
|
|
72
|
+
var _a2;
|
|
73
|
+
return (_a2 = state.contentElement) == null ? void 0 : _a2.id;
|
|
52
74
|
});
|
|
53
|
-
const contentElement = store.useState("contentElement");
|
|
54
75
|
props = __spreadProps(__spreadValues({
|
|
55
76
|
tabIndex: 0,
|
|
56
|
-
"aria-labelledby":
|
|
57
|
-
"aria-describedby":
|
|
77
|
+
"aria-labelledby": type === "label" ? contentId : void 0,
|
|
78
|
+
"aria-describedby": type === "description" ? contentId : void 0
|
|
58
79
|
}, props), {
|
|
59
|
-
|
|
60
|
-
onBlur
|
|
61
|
-
onMouseEnter,
|
|
62
|
-
onMouseLeave
|
|
80
|
+
onFocusVisible,
|
|
81
|
+
onBlur
|
|
63
82
|
});
|
|
64
|
-
props =
|
|
83
|
+
props = useHovercardAnchor(__spreadValues({
|
|
84
|
+
store,
|
|
85
|
+
showOnHover: (event) => {
|
|
86
|
+
if (isFalsyBooleanCallback(showOnHover, event))
|
|
87
|
+
return false;
|
|
88
|
+
const { activeStore } = globalStore.getState();
|
|
89
|
+
if (!activeStore)
|
|
90
|
+
return true;
|
|
91
|
+
store.show();
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}, props));
|
|
65
95
|
return props;
|
|
66
96
|
}
|
|
67
97
|
);
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import * as Core from "@ariakit/core/tooltip/tooltip-store";
|
|
2
|
-
import type {
|
|
2
|
+
import type { HovercardStoreFunctions, HovercardStoreOptions, HovercardStoreState } from "../hovercard/hovercard-store.js";
|
|
3
3
|
import type { Store } from "../utils/store.js";
|
|
4
|
-
export declare function useTooltipStoreOptions(props: TooltipStoreProps):
|
|
5
|
-
getAnchorRect: ((anchor: HTMLElement | null) => {
|
|
6
|
-
x?: number | undefined;
|
|
7
|
-
y?: number | undefined;
|
|
8
|
-
width?: number | undefined;
|
|
9
|
-
height?: number | undefined;
|
|
10
|
-
} | null) | undefined;
|
|
11
|
-
renderCallback: ((props: import("@ariakit/core/popover/popover-store").PopoverStoreRenderCallbackProps) => void | (() => void)) | undefined;
|
|
12
|
-
setOpen?: ((open: boolean) => void) | undefined;
|
|
13
|
-
defaultOpen?: boolean | undefined;
|
|
14
|
-
open?: boolean | undefined;
|
|
15
|
-
animated?: number | boolean | undefined;
|
|
16
|
-
};
|
|
4
|
+
export declare function useTooltipStoreOptions(props: TooltipStoreProps): Partial<import("../disclosure/disclosure-store.js").DisclosureStoreOptions>;
|
|
17
5
|
export declare function useTooltipStoreProps<T extends TooltipStore>(store: T, props: TooltipStoreProps): T;
|
|
18
6
|
/**
|
|
19
7
|
* Creates a tooltip store.
|
|
@@ -26,11 +14,11 @@ export declare function useTooltipStoreProps<T extends TooltipStore>(store: T, p
|
|
|
26
14
|
* ```
|
|
27
15
|
*/
|
|
28
16
|
export declare function useTooltipStore(props?: TooltipStoreProps): TooltipStore;
|
|
29
|
-
export interface TooltipStoreState extends Core.TooltipStoreState,
|
|
17
|
+
export interface TooltipStoreState extends Core.TooltipStoreState, HovercardStoreState {
|
|
30
18
|
}
|
|
31
|
-
export interface TooltipStoreFunctions extends Core.TooltipStoreFunctions,
|
|
19
|
+
export interface TooltipStoreFunctions extends Core.TooltipStoreFunctions, HovercardStoreFunctions {
|
|
32
20
|
}
|
|
33
|
-
export interface TooltipStoreOptions extends Core.TooltipStoreOptions,
|
|
21
|
+
export interface TooltipStoreOptions extends Core.TooltipStoreOptions, HovercardStoreOptions {
|
|
34
22
|
}
|
|
35
23
|
export type TooltipStoreProps = TooltipStoreOptions & Core.TooltipStoreProps;
|
|
36
24
|
export type TooltipStore = TooltipStoreFunctions & Store<Core.TooltipStore>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "../__chunks/
|
|
2
|
+
useHovercardStoreOptions,
|
|
3
|
+
useHovercardStoreProps
|
|
4
|
+
} from "../__chunks/K5R24MFH.js";
|
|
5
|
+
import "../__chunks/5PIH3SMS.js";
|
|
5
6
|
import "../__chunks/OBNQHP6V.js";
|
|
6
7
|
import "../__chunks/HN4VMOUI.js";
|
|
7
8
|
import {
|
|
@@ -16,10 +17,10 @@ import {
|
|
|
16
17
|
// src/tooltip/tooltip-store.ts
|
|
17
18
|
import * as Core from "@ariakit/core/tooltip/tooltip-store";
|
|
18
19
|
function useTooltipStoreOptions(props) {
|
|
19
|
-
return
|
|
20
|
+
return useHovercardStoreOptions(props);
|
|
20
21
|
}
|
|
21
22
|
function useTooltipStoreProps(store, props) {
|
|
22
|
-
return
|
|
23
|
+
return useHovercardStoreProps(store, props);
|
|
23
24
|
}
|
|
24
25
|
function useTooltipStore(props = {}) {
|
|
25
26
|
const options = useTooltipStoreOptions(props);
|
package/esm/tooltip/tooltip.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { BooleanOrCallback } from "@ariakit/core/utils/types";
|
|
3
|
-
import type { DisclosureContentOptions } from "../disclosure/disclosure-content.js";
|
|
4
|
-
import type { PortalOptions } from "../portal/portal.js";
|
|
1
|
+
import type { HovercardOptions } from "../hovercard/hovercard.js";
|
|
5
2
|
import type { As, Props } from "../utils/types.js";
|
|
6
3
|
import type { TooltipStore } from "./tooltip-store.js";
|
|
7
4
|
/**
|
|
@@ -27,30 +24,14 @@ export declare const useTooltip: import("../utils/types.js").Hook<TooltipOptions
|
|
|
27
24
|
* ```
|
|
28
25
|
*/
|
|
29
26
|
export declare const Tooltip: import("../utils/types.js").Component<TooltipOptions<"div">>;
|
|
30
|
-
export interface TooltipOptions<T extends As = "div"> extends
|
|
27
|
+
export interface TooltipOptions<T extends As = "div"> extends HovercardOptions<T> {
|
|
31
28
|
/**
|
|
32
29
|
* Object returned by the `useTooltipStore` hook.
|
|
33
30
|
*/
|
|
34
31
|
store: TooltipStore;
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*/
|
|
40
|
-
hideOnEscape?: BooleanOrCallback<KeyboardEvent>;
|
|
41
|
-
/**
|
|
42
|
-
* Determines whether the tooltip will be hidden when the user presses the
|
|
43
|
-
* Control key. This has been proposed as an alternative to the Escape key,
|
|
44
|
-
* which may introduce some issues, especially when tooltips are used within
|
|
45
|
-
* dialogs that also hide on Escape. See
|
|
46
|
-
* https://github.com/w3c/aria-practices/issues/1506
|
|
47
|
-
* @default false
|
|
48
|
-
*/
|
|
49
|
-
hideOnControl?: BooleanOrCallback<KeyboardEvent>;
|
|
50
|
-
/**
|
|
51
|
-
* Props that will be passed to the popover wrapper element. This element
|
|
52
|
-
* will be used to position the popover.
|
|
53
|
-
*/
|
|
54
|
-
wrapperProps?: HTMLAttributes<HTMLDivElement>;
|
|
32
|
+
/** @default true */
|
|
33
|
+
portal?: HovercardOptions<T>["portal"];
|
|
34
|
+
/** @default 8 */
|
|
35
|
+
gutter?: HovercardOptions<T>["gutter"];
|
|
55
36
|
}
|
|
56
37
|
export type TooltipProps<T extends As = "div"> = Props<TooltipOptions<T>>;
|
package/esm/tooltip/tooltip.js
CHANGED
|
@@ -1,14 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../__chunks/
|
|
2
|
+
useHovercard
|
|
3
|
+
} from "../__chunks/HJWYYQGA.js";
|
|
4
|
+
import "../__chunks/X7FKJQME.js";
|
|
5
|
+
import "../__chunks/MLEIJKSM.js";
|
|
6
|
+
import "../__chunks/NAG6UD2X.js";
|
|
7
|
+
import "../__chunks/MR75RQGW.js";
|
|
8
|
+
import "../__chunks/4H6H5RRM.js";
|
|
9
|
+
import "../__chunks/7A3SODQV.js";
|
|
10
|
+
import "../__chunks/RBUEJWRA.js";
|
|
11
|
+
import "../__chunks/T3WBUAHU.js";
|
|
12
|
+
import "../__chunks/KUXENZYT.js";
|
|
13
|
+
import "../__chunks/KOVUJERF.js";
|
|
14
|
+
import "../__chunks/62DFK33R.js";
|
|
15
|
+
import "../__chunks/BH4YAZB2.js";
|
|
16
|
+
import "../__chunks/DJESYNLE.js";
|
|
17
|
+
import "../__chunks/6WVG5KFF.js";
|
|
18
|
+
import "../__chunks/ISPCL6N4.js";
|
|
19
|
+
import "../__chunks/7JNF6I52.js";
|
|
20
|
+
import "../__chunks/6OMX4H3W.js";
|
|
21
|
+
import "../__chunks/2CA5JWPW.js";
|
|
4
22
|
import "../__chunks/DIO64N2C.js";
|
|
5
23
|
import "../__chunks/LDDPB3PY.js";
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
24
|
+
import "../__chunks/COQHFAEN.js";
|
|
25
|
+
import "../__chunks/LNHZLQEK.js";
|
|
26
|
+
import "../__chunks/XIACQCPS.js";
|
|
27
|
+
import "../__chunks/6AJCHLAV.js";
|
|
28
|
+
import "../__chunks/6GS36SYX.js";
|
|
9
29
|
import {
|
|
10
30
|
TooltipContext
|
|
11
31
|
} from "../__chunks/Z5BJMNGY.js";
|
|
32
|
+
import "../__chunks/AGWM73EZ.js";
|
|
33
|
+
import "../__chunks/BMLNRUFQ.js";
|
|
12
34
|
import "../__chunks/JQEVJM46.js";
|
|
13
35
|
import {
|
|
14
36
|
createComponent,
|
|
@@ -16,8 +38,6 @@ import {
|
|
|
16
38
|
createHook
|
|
17
39
|
} from "../__chunks/5ETIGB6O.js";
|
|
18
40
|
import {
|
|
19
|
-
useBooleanEvent,
|
|
20
|
-
useSafeLayoutEffect,
|
|
21
41
|
useWrapElement
|
|
22
42
|
} from "../__chunks/ASYR66PQ.js";
|
|
23
43
|
import "../__chunks/SXC6BPOF.js";
|
|
@@ -28,82 +48,61 @@ import {
|
|
|
28
48
|
} from "../__chunks/4BKCJXBM.js";
|
|
29
49
|
|
|
30
50
|
// src/tooltip/tooltip.tsx
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
51
|
+
import { contains } from "@ariakit/core/utils/dom";
|
|
52
|
+
import { isFalsyBooleanCallback } from "@ariakit/core/utils/misc";
|
|
33
53
|
import { jsx } from "react/jsx-runtime";
|
|
34
54
|
var useTooltip = createHook(
|
|
35
55
|
(_a) => {
|
|
36
56
|
var _b = _a, {
|
|
37
57
|
store,
|
|
38
58
|
portal = true,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
59
|
+
gutter = 8,
|
|
60
|
+
preserveTabOrder = false,
|
|
61
|
+
hideOnHoverOutside = true,
|
|
62
|
+
hideOnInteractOutside = true
|
|
42
63
|
} = _b, props = __objRest(_b, [
|
|
43
64
|
"store",
|
|
44
65
|
"portal",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
66
|
+
"gutter",
|
|
67
|
+
"preserveTabOrder",
|
|
68
|
+
"hideOnHoverOutside",
|
|
69
|
+
"hideOnInteractOutside"
|
|
48
70
|
]);
|
|
49
|
-
const popoverElement = store.useState("popoverElement");
|
|
50
|
-
const contentElement = store.useState("contentElement");
|
|
51
|
-
useSafeLayoutEffect(() => {
|
|
52
|
-
const wrapper = popoverElement;
|
|
53
|
-
const popover = contentElement;
|
|
54
|
-
if (!wrapper)
|
|
55
|
-
return;
|
|
56
|
-
if (!popover)
|
|
57
|
-
return;
|
|
58
|
-
wrapper.style.zIndex = getComputedStyle(popover).zIndex;
|
|
59
|
-
}, [popoverElement, contentElement]);
|
|
60
|
-
const hideOnEscapeProp = useBooleanEvent(hideOnEscape);
|
|
61
|
-
const hideOnControlProp = useBooleanEvent(hideOnControl);
|
|
62
|
-
const open = store.useState("open");
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (!open)
|
|
65
|
-
return;
|
|
66
|
-
return addGlobalEventListener("keydown", (event) => {
|
|
67
|
-
if (event.defaultPrevented)
|
|
68
|
-
return;
|
|
69
|
-
const isEscape = event.key === "Escape" && hideOnEscapeProp(event);
|
|
70
|
-
const isControl = event.key === "Control" && hideOnControlProp(event);
|
|
71
|
-
if (isEscape || isControl) {
|
|
72
|
-
store.hide();
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}, [store, open, hideOnEscapeProp, hideOnControlProp]);
|
|
76
|
-
const position = store.useState(
|
|
77
|
-
(state) => state.fixed ? "fixed" : "absolute"
|
|
78
|
-
);
|
|
79
|
-
props = useWrapElement(
|
|
80
|
-
props,
|
|
81
|
-
(element) => /* @__PURE__ */ jsx(
|
|
82
|
-
"div",
|
|
83
|
-
__spreadProps(__spreadValues({
|
|
84
|
-
role: "presentation"
|
|
85
|
-
}, wrapperProps), {
|
|
86
|
-
style: __spreadValues({
|
|
87
|
-
position,
|
|
88
|
-
top: 0,
|
|
89
|
-
left: 0
|
|
90
|
-
}, wrapperProps == null ? void 0 : wrapperProps.style),
|
|
91
|
-
ref: store.setPopoverElement,
|
|
92
|
-
children: element
|
|
93
|
-
})
|
|
94
|
-
),
|
|
95
|
-
[store, position, wrapperProps]
|
|
96
|
-
);
|
|
97
71
|
props = useWrapElement(
|
|
98
72
|
props,
|
|
99
73
|
(element) => /* @__PURE__ */ jsx(TooltipContext.Provider, { value: store, children: element }),
|
|
100
74
|
[store]
|
|
101
75
|
);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
props =
|
|
106
|
-
props =
|
|
76
|
+
const role = store.useState(
|
|
77
|
+
(state) => state.type === "description" ? "tooltip" : "none"
|
|
78
|
+
);
|
|
79
|
+
props = __spreadValues({ role }, props);
|
|
80
|
+
props = useHovercard(__spreadProps(__spreadValues({}, props), {
|
|
81
|
+
store,
|
|
82
|
+
portal,
|
|
83
|
+
gutter,
|
|
84
|
+
preserveTabOrder,
|
|
85
|
+
hideOnHoverOutside: (event) => {
|
|
86
|
+
if (isFalsyBooleanCallback(hideOnHoverOutside, event))
|
|
87
|
+
return false;
|
|
88
|
+
const { anchorElement } = store.getState();
|
|
89
|
+
if (!anchorElement)
|
|
90
|
+
return true;
|
|
91
|
+
if ("focusVisible" in anchorElement.dataset)
|
|
92
|
+
return false;
|
|
93
|
+
return true;
|
|
94
|
+
},
|
|
95
|
+
hideOnInteractOutside: (event) => {
|
|
96
|
+
if (isFalsyBooleanCallback(hideOnInteractOutside, event))
|
|
97
|
+
return false;
|
|
98
|
+
const { anchorElement } = store.getState();
|
|
99
|
+
if (!anchorElement)
|
|
100
|
+
return true;
|
|
101
|
+
if (contains(anchorElement, event.target))
|
|
102
|
+
return false;
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}));
|
|
107
106
|
return props;
|
|
108
107
|
}
|
|
109
108
|
);
|