@misael703/ui 1.0.1 → 1.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/dist/chunk-2S6JJYN7.js +209 -0
- package/dist/chunk-2S6JJYN7.js.map +1 -0
- package/dist/{chunk-GDFYAUHT.mjs → chunk-3N4IBCLW.mjs} +11 -29
- package/dist/chunk-3N4IBCLW.mjs.map +1 -0
- package/dist/{chunk-TB6EHWRF.mjs → chunk-3OVWAAGP.mjs} +3 -3
- package/dist/{chunk-TB6EHWRF.mjs.map → chunk-3OVWAAGP.mjs.map} +1 -1
- package/dist/chunk-427NHGTX.js +4 -0
- package/dist/chunk-427NHGTX.js.map +1 -0
- package/dist/chunk-6P2TKRTL.mjs +45 -0
- package/dist/chunk-6P2TKRTL.mjs.map +1 -0
- package/dist/chunk-6RVCYULF.mjs +78 -0
- package/dist/chunk-6RVCYULF.mjs.map +1 -0
- package/dist/chunk-BVQRDAR7.mjs +3 -0
- package/dist/chunk-BVQRDAR7.mjs.map +1 -0
- package/dist/{chunk-TXKFCVCN.mjs → chunk-C35GKQJO.mjs} +3 -3
- package/dist/{chunk-TXKFCVCN.mjs.map → chunk-C35GKQJO.mjs.map} +1 -1
- package/dist/chunk-DPMUWQHL.js +95 -0
- package/dist/chunk-DPMUWQHL.js.map +1 -0
- package/dist/chunk-GIOMV3J7.js +48 -0
- package/dist/chunk-GIOMV3J7.js.map +1 -0
- package/dist/chunk-GLYGO7WX.js +13 -0
- package/dist/chunk-GLYGO7WX.js.map +1 -0
- package/dist/chunk-H3PRT76O.mjs +73 -0
- package/dist/chunk-H3PRT76O.mjs.map +1 -0
- package/dist/{chunk-Z4GRQHIG.mjs → chunk-IEJXZ67E.mjs} +3 -3
- package/dist/{chunk-Z4GRQHIG.mjs.map → chunk-IEJXZ67E.mjs.map} +1 -1
- package/dist/chunk-IMHLJKYR.mjs +176 -0
- package/dist/chunk-IMHLJKYR.mjs.map +1 -0
- package/dist/{chunk-EJJDJJEM.js → chunk-K5S3SV2U.js} +108 -106
- package/dist/chunk-K5S3SV2U.js.map +1 -0
- package/dist/{chunk-ADIKHOEG.js → chunk-KOIRRZRD.js} +72 -6
- package/dist/chunk-KOIRRZRD.js.map +1 -0
- package/dist/{chunk-ZXSSOEIM.js → chunk-LXNHGGAK.js} +4 -4
- package/dist/{chunk-ZXSSOEIM.js.map → chunk-LXNHGGAK.js.map} +1 -1
- package/dist/{chunk-HI3JT6SI.mjs → chunk-MM7VE7YN.mjs} +72 -6
- package/dist/chunk-MM7VE7YN.mjs.map +1 -0
- package/dist/chunk-MUL2FKYF.js +100 -0
- package/dist/chunk-MUL2FKYF.js.map +1 -0
- package/dist/chunk-N2Y2KWX5.mjs +216 -0
- package/dist/chunk-N2Y2KWX5.mjs.map +1 -0
- package/dist/{chunk-CVXS7IHA.js → chunk-N7LFCAAY.js} +112 -113
- package/dist/chunk-N7LFCAAY.js.map +1 -0
- package/dist/chunk-OCLBAGNF.mjs +184 -0
- package/dist/chunk-OCLBAGNF.mjs.map +1 -0
- package/dist/{chunk-QSCJ2CER.mjs → chunk-OHCS5CYV.mjs} +108 -106
- package/dist/chunk-OHCS5CYV.mjs.map +1 -0
- package/dist/{chunk-LUXTZOTJ.js → chunk-OHMFYAB2.js} +4 -4
- package/dist/{chunk-LUXTZOTJ.js.map → chunk-OHMFYAB2.js.map} +1 -1
- package/dist/{chunk-T4R2LSRL.js → chunk-PROKTOL7.js} +3 -2
- package/dist/chunk-PROKTOL7.js.map +1 -0
- package/dist/{chunk-3UHX7ITQ.mjs → chunk-QI4JT3V3.mjs} +29 -34
- package/dist/chunk-QI4JT3V3.mjs.map +1 -0
- package/dist/{chunk-Z3FAKG3E.mjs → chunk-QW2CSXPH.mjs} +3 -2
- package/dist/chunk-QW2CSXPH.mjs.map +1 -0
- package/dist/chunk-QX5GGPV5.mjs +11 -0
- package/dist/chunk-QX5GGPV5.mjs.map +1 -0
- package/dist/{chunk-2RVSLQEA.mjs → chunk-R76SJURE.mjs} +3 -3
- package/dist/{chunk-2RVSLQEA.mjs.map → chunk-R76SJURE.mjs.map} +1 -1
- package/dist/{chunk-E2XOUDAH.js → chunk-REL2RZTI.js} +14 -32
- package/dist/chunk-REL2RZTI.js.map +1 -0
- package/dist/{chunk-R76YER7O.js → chunk-TBAKKSAN.js} +4 -4
- package/dist/{chunk-R76YER7O.js.map → chunk-TBAKKSAN.js.map} +1 -1
- package/dist/chunk-V7MK42GX.js +238 -0
- package/dist/chunk-V7MK42GX.js.map +1 -0
- package/dist/chunk-VR4OXVKE.js +198 -0
- package/dist/chunk-VR4OXVKE.js.map +1 -0
- package/dist/chunk-WLDQP4KD.mjs +75 -0
- package/dist/chunk-WLDQP4KD.mjs.map +1 -0
- package/dist/{chunk-W6YOBPL5.js → chunk-WVN5JJVV.js} +27 -40
- package/dist/chunk-WVN5JJVV.js.map +1 -0
- package/dist/chunk-XMLBKK7X.js +67 -0
- package/dist/chunk-XMLBKK7X.js.map +1 -0
- package/dist/chunk-XXUSZD5I.mjs +26 -0
- package/dist/chunk-XXUSZD5I.mjs.map +1 -0
- package/dist/{chunk-IIYQO6BL.js → chunk-YAORRBMU.js} +29 -34
- package/dist/chunk-YAORRBMU.js.map +1 -0
- package/dist/{chunk-AAQ7KUZH.mjs → chunk-YFLVB62R.mjs} +112 -113
- package/dist/chunk-YFLVB62R.mjs.map +1 -0
- package/dist/{chunk-UIKCTWKG.js → chunk-YRACSKAT.js} +4 -4
- package/dist/{chunk-UIKCTWKG.js.map → chunk-YRACSKAT.js.map} +1 -1
- package/dist/components/AdvancedPickers.js +8 -5
- package/dist/components/AdvancedPickers.mjs +4 -1
- package/dist/components/AppShell.js +3 -3
- package/dist/components/AppShell.mjs +1 -1
- package/dist/components/Comments.js +8 -5
- package/dist/components/Comments.mjs +5 -2
- package/dist/components/Commerce.js +14 -13
- package/dist/components/Commerce.mjs +3 -2
- package/dist/components/ContextMenu.js +5 -2
- package/dist/components/ContextMenu.mjs +4 -1
- package/dist/components/Display2.js +8 -5
- package/dist/components/Display2.mjs +4 -1
- package/dist/components/Display3.js +11 -8
- package/dist/components/Display3.mjs +5 -2
- package/dist/components/Editing.js +8 -7
- package/dist/components/Editing.mjs +3 -2
- package/dist/components/HoverCard.js +4 -2
- package/dist/components/HoverCard.mjs +3 -1
- package/dist/components/Layout.js +20 -18
- package/dist/components/Layout.mjs +3 -1
- package/dist/components/Menubar.js +5 -2
- package/dist/components/Menubar.mjs +4 -1
- package/dist/components/NavigationMenu.js +5 -2
- package/dist/components/NavigationMenu.mjs +4 -1
- package/dist/components/Overlay.js +4 -3
- package/dist/components/Overlay.mjs +2 -1
- package/dist/components/Pickers.js +7 -4
- package/dist/components/Pickers.mjs +4 -1
- package/dist/components/Popover.js +5 -2
- package/dist/components/Popover.mjs +4 -1
- package/dist/components/Portal.d.mts +30 -0
- package/dist/components/Portal.d.ts +30 -0
- package/dist/components/Portal.js +12 -0
- package/dist/components/Portal.js.map +1 -0
- package/dist/components/Portal.mjs +3 -0
- package/dist/components/Portal.mjs.map +1 -0
- package/dist/hooks/index.d.mts +4 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +23 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +6 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/hooks/useDelayedUnmount.d.mts +22 -0
- package/dist/hooks/useDelayedUnmount.d.ts +22 -0
- package/dist/hooks/useDelayedUnmount.js +12 -0
- package/dist/hooks/useDelayedUnmount.js.map +1 -0
- package/dist/hooks/useDelayedUnmount.mjs +3 -0
- package/dist/hooks/useDelayedUnmount.mjs.map +1 -0
- package/dist/hooks/useDismiss.d.mts +23 -0
- package/dist/hooks/useDismiss.d.ts +23 -0
- package/dist/hooks/useDismiss.js +12 -0
- package/dist/hooks/useDismiss.js.map +1 -0
- package/dist/hooks/useDismiss.mjs +3 -0
- package/dist/hooks/useDismiss.mjs.map +1 -0
- package/dist/hooks/usePopoverPosition.d.mts +50 -0
- package/dist/hooks/usePopoverPosition.d.ts +50 -0
- package/dist/hooks/usePopoverPosition.js +12 -0
- package/dist/hooks/usePopoverPosition.js.map +1 -0
- package/dist/hooks/usePopoverPosition.mjs +3 -0
- package/dist/hooks/usePopoverPosition.mjs.map +1 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +95 -78
- package/dist/index.mjs +21 -16
- package/dist/styles.css +1 -1
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/chunk-3UHX7ITQ.mjs.map +0 -1
- package/dist/chunk-5VMZMDJF.js +0 -145
- package/dist/chunk-5VMZMDJF.js.map +0 -1
- package/dist/chunk-7AKN7FDA.mjs +0 -103
- package/dist/chunk-7AKN7FDA.mjs.map +0 -1
- package/dist/chunk-AAQ7KUZH.mjs.map +0 -1
- package/dist/chunk-ADIKHOEG.js.map +0 -1
- package/dist/chunk-CVXS7IHA.js.map +0 -1
- package/dist/chunk-E2XOUDAH.js.map +0 -1
- package/dist/chunk-EJJDJJEM.js.map +0 -1
- package/dist/chunk-GDFYAUHT.mjs.map +0 -1
- package/dist/chunk-HI3JT6SI.mjs.map +0 -1
- package/dist/chunk-HPFJ2A24.js +0 -125
- package/dist/chunk-HPFJ2A24.js.map +0 -1
- package/dist/chunk-IIYQO6BL.js.map +0 -1
- package/dist/chunk-JDOXRLZW.js +0 -138
- package/dist/chunk-JDOXRLZW.js.map +0 -1
- package/dist/chunk-NLCKWF3Y.mjs +0 -88
- package/dist/chunk-NLCKWF3Y.mjs.map +0 -1
- package/dist/chunk-NUURPO3J.mjs +0 -120
- package/dist/chunk-NUURPO3J.mjs.map +0 -1
- package/dist/chunk-OCE4ODTM.mjs +0 -116
- package/dist/chunk-OCE4ODTM.mjs.map +0 -1
- package/dist/chunk-QI6TVWWF.js +0 -121
- package/dist/chunk-QI6TVWWF.js.map +0 -1
- package/dist/chunk-QSCJ2CER.mjs.map +0 -1
- package/dist/chunk-T4R2LSRL.js.map +0 -1
- package/dist/chunk-W6YOBPL5.js.map +0 -1
- package/dist/chunk-YBOTLQ3G.mjs +0 -99
- package/dist/chunk-YBOTLQ3G.mjs.map +0 -1
- package/dist/chunk-Z3FAKG3E.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"Portal.mjs"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useDelayedUnmount } from './useDelayedUnmount.mjs';
|
|
2
|
+
export { PopoverAlign, PopoverPosition, PopoverSide, UsePopoverPositionOptions, VirtualElement, usePopoverPosition } from './usePopoverPosition.mjs';
|
|
3
|
+
export { UseDismissOptions, useDismiss } from './useDismiss.mjs';
|
|
4
|
+
import 'react';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useDelayedUnmount } from './useDelayedUnmount.js';
|
|
2
|
+
export { PopoverAlign, PopoverPosition, PopoverSide, UsePopoverPositionOptions, VirtualElement, usePopoverPosition } from './usePopoverPosition.js';
|
|
3
|
+
export { UseDismissOptions, useDismiss } from './useDismiss.js';
|
|
4
|
+
import 'react';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../chunk-427NHGTX.js');
|
|
4
|
+
var chunkGIOMV3J7_js = require('../chunk-GIOMV3J7.js');
|
|
5
|
+
var chunkXMLBKK7X_js = require('../chunk-XMLBKK7X.js');
|
|
6
|
+
var chunkDPMUWQHL_js = require('../chunk-DPMUWQHL.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "useDelayedUnmount", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return chunkGIOMV3J7_js.useDelayedUnmount; }
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "useDismiss", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return chunkXMLBKK7X_js.useDismiss; }
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "usePopoverPosition", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return chunkDPMUWQHL_js.usePopoverPosition; }
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import '../chunk-BVQRDAR7.mjs';
|
|
2
|
+
export { useDelayedUnmount } from '../chunk-XXUSZD5I.mjs';
|
|
3
|
+
export { useDismiss } from '../chunk-6P2TKRTL.mjs';
|
|
4
|
+
export { usePopoverPosition } from '../chunk-H3PRT76O.mjs';
|
|
5
|
+
//# sourceMappingURL=index.mjs.map
|
|
6
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delays unmounting of a component so an exit animation can play.
|
|
3
|
+
*
|
|
4
|
+
* When `open` flips to false, the hook keeps `mounted` true for `durationMs`
|
|
5
|
+
* (giving CSS time to play `is-closing` keyframes) and then flips it to
|
|
6
|
+
* false. The `closing` flag toggles during that window so the consumer can
|
|
7
|
+
* apply a class like `is-closing` for the CSS animation.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const { mounted, closing } = useDelayedUnmount(open, 200);
|
|
13
|
+
* if (!mounted) return null;
|
|
14
|
+
* return <div className={cx('modal', closing && 'is-closing')} />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare function useDelayedUnmount(open: boolean, durationMs: number): {
|
|
18
|
+
mounted: boolean;
|
|
19
|
+
closing: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { useDelayedUnmount };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delays unmounting of a component so an exit animation can play.
|
|
3
|
+
*
|
|
4
|
+
* When `open` flips to false, the hook keeps `mounted` true for `durationMs`
|
|
5
|
+
* (giving CSS time to play `is-closing` keyframes) and then flips it to
|
|
6
|
+
* false. The `closing` flag toggles during that window so the consumer can
|
|
7
|
+
* apply a class like `is-closing` for the CSS animation.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const { mounted, closing } = useDelayedUnmount(open, 200);
|
|
13
|
+
* if (!mounted) return null;
|
|
14
|
+
* return <div className={cx('modal', closing && 'is-closing')} />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare function useDelayedUnmount(open: boolean, durationMs: number): {
|
|
18
|
+
mounted: boolean;
|
|
19
|
+
closing: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { useDelayedUnmount };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkGIOMV3J7_js = require('../chunk-GIOMV3J7.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "useDelayedUnmount", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkGIOMV3J7_js.useDelayedUnmount; }
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=useDelayedUnmount.js.map
|
|
12
|
+
//# sourceMappingURL=useDelayedUnmount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"useDelayedUnmount.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"useDelayedUnmount.mjs"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface UseDismissOptions {
|
|
4
|
+
open: boolean;
|
|
5
|
+
onDismiss: () => void;
|
|
6
|
+
/** Refs whose subtree should NOT count as "outside" (trigger + panel). */
|
|
7
|
+
refs: Array<React.RefObject<HTMLElement | null>>;
|
|
8
|
+
closeOnEscape?: boolean;
|
|
9
|
+
closeOnOutsideClick?: boolean;
|
|
10
|
+
/** Focus returns here when the panel closes (usually the trigger). */
|
|
11
|
+
returnFocusRef?: React.RefObject<HTMLElement | null>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Shared dismiss behaviour for floating panels: closes on outside
|
|
15
|
+
* pointer-down and on Escape, and restores focus to the trigger when the
|
|
16
|
+
* panel closes (focus hygiene for keyboard/AT users).
|
|
17
|
+
*
|
|
18
|
+
* `onDismiss` and `refs` are read through refs internally, so callers
|
|
19
|
+
* don't need to memoize them to avoid re-subscribing listeners.
|
|
20
|
+
*/
|
|
21
|
+
declare function useDismiss({ open, onDismiss, refs, closeOnEscape, closeOnOutsideClick, returnFocusRef, }: UseDismissOptions): void;
|
|
22
|
+
|
|
23
|
+
export { type UseDismissOptions, useDismiss };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface UseDismissOptions {
|
|
4
|
+
open: boolean;
|
|
5
|
+
onDismiss: () => void;
|
|
6
|
+
/** Refs whose subtree should NOT count as "outside" (trigger + panel). */
|
|
7
|
+
refs: Array<React.RefObject<HTMLElement | null>>;
|
|
8
|
+
closeOnEscape?: boolean;
|
|
9
|
+
closeOnOutsideClick?: boolean;
|
|
10
|
+
/** Focus returns here when the panel closes (usually the trigger). */
|
|
11
|
+
returnFocusRef?: React.RefObject<HTMLElement | null>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Shared dismiss behaviour for floating panels: closes on outside
|
|
15
|
+
* pointer-down and on Escape, and restores focus to the trigger when the
|
|
16
|
+
* panel closes (focus hygiene for keyboard/AT users).
|
|
17
|
+
*
|
|
18
|
+
* `onDismiss` and `refs` are read through refs internally, so callers
|
|
19
|
+
* don't need to memoize them to avoid re-subscribing listeners.
|
|
20
|
+
*/
|
|
21
|
+
declare function useDismiss({ open, onDismiss, refs, closeOnEscape, closeOnOutsideClick, returnFocusRef, }: UseDismissOptions): void;
|
|
22
|
+
|
|
23
|
+
export { type UseDismissOptions, useDismiss };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkXMLBKK7X_js = require('../chunk-XMLBKK7X.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "useDismiss", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkXMLBKK7X_js.useDismiss; }
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=useDismiss.js.map
|
|
12
|
+
//# sourceMappingURL=useDismiss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"useDismiss.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"useDismiss.mjs"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type PopoverSide = 'top' | 'bottom' | 'left' | 'right';
|
|
4
|
+
type PopoverAlign = 'start' | 'center' | 'end';
|
|
5
|
+
/** Anything that can report its viewport rect: a DOM element or a virtual
|
|
6
|
+
* anchor (e.g. a point under the cursor for a context menu). */
|
|
7
|
+
interface VirtualElement {
|
|
8
|
+
getBoundingClientRect: () => DOMRect;
|
|
9
|
+
}
|
|
10
|
+
interface UsePopoverPositionOptions {
|
|
11
|
+
open: boolean;
|
|
12
|
+
side?: PopoverSide;
|
|
13
|
+
align?: PopoverAlign;
|
|
14
|
+
offset?: number;
|
|
15
|
+
/** Expose the anchor's width so the consumer can match it (comboboxes). */
|
|
16
|
+
matchAnchorWidth?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface PopoverPosition {
|
|
19
|
+
/** Document-relative coords (use with `position: absolute` in a body portal). */
|
|
20
|
+
top: number;
|
|
21
|
+
left: number;
|
|
22
|
+
/** Side actually used after flipping; useful for arrow/animation origin. */
|
|
23
|
+
side: PopoverSide;
|
|
24
|
+
/** False until the first measure. Keep content `visibility: hidden` until true. */
|
|
25
|
+
ready: boolean;
|
|
26
|
+
/** Anchor width, only when `matchAnchorWidth` is set. */
|
|
27
|
+
width?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Positions a floating panel relative to an anchor, for panels portaled to
|
|
31
|
+
* `document.body`. Computes document-relative coords from
|
|
32
|
+
* `getBoundingClientRect()`, flips to the opposite side when the preferred
|
|
33
|
+
* side doesn't fit the viewport, clamps into the viewport, and recomputes
|
|
34
|
+
* on scroll of *any* ancestor (capture-phase) and on resize
|
|
35
|
+
* (rAF-coalesced). Listeners are torn down on close/unmount.
|
|
36
|
+
*
|
|
37
|
+
* The content must be mounted (it can be visually hidden) so its size can
|
|
38
|
+
* be measured — gate visibility on the returned `ready` flag.
|
|
39
|
+
*
|
|
40
|
+
* ```tsx
|
|
41
|
+
* const pos = usePopoverPosition(triggerRef, contentRef, { open, side: 'bottom' });
|
|
42
|
+
* <Portal><div ref={contentRef} style={{
|
|
43
|
+
* position: 'absolute', top: pos.top, left: pos.left,
|
|
44
|
+
* visibility: pos.ready ? 'visible' : 'hidden',
|
|
45
|
+
* }} /></Portal>
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare function usePopoverPosition(anchorRef: React.RefObject<HTMLElement | VirtualElement | null>, contentRef: React.RefObject<HTMLElement | null>, { open, side, align, offset, matchAnchorWidth }: UsePopoverPositionOptions): PopoverPosition;
|
|
49
|
+
|
|
50
|
+
export { type PopoverAlign, type PopoverPosition, type PopoverSide, type UsePopoverPositionOptions, type VirtualElement, usePopoverPosition };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type PopoverSide = 'top' | 'bottom' | 'left' | 'right';
|
|
4
|
+
type PopoverAlign = 'start' | 'center' | 'end';
|
|
5
|
+
/** Anything that can report its viewport rect: a DOM element or a virtual
|
|
6
|
+
* anchor (e.g. a point under the cursor for a context menu). */
|
|
7
|
+
interface VirtualElement {
|
|
8
|
+
getBoundingClientRect: () => DOMRect;
|
|
9
|
+
}
|
|
10
|
+
interface UsePopoverPositionOptions {
|
|
11
|
+
open: boolean;
|
|
12
|
+
side?: PopoverSide;
|
|
13
|
+
align?: PopoverAlign;
|
|
14
|
+
offset?: number;
|
|
15
|
+
/** Expose the anchor's width so the consumer can match it (comboboxes). */
|
|
16
|
+
matchAnchorWidth?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface PopoverPosition {
|
|
19
|
+
/** Document-relative coords (use with `position: absolute` in a body portal). */
|
|
20
|
+
top: number;
|
|
21
|
+
left: number;
|
|
22
|
+
/** Side actually used after flipping; useful for arrow/animation origin. */
|
|
23
|
+
side: PopoverSide;
|
|
24
|
+
/** False until the first measure. Keep content `visibility: hidden` until true. */
|
|
25
|
+
ready: boolean;
|
|
26
|
+
/** Anchor width, only when `matchAnchorWidth` is set. */
|
|
27
|
+
width?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Positions a floating panel relative to an anchor, for panels portaled to
|
|
31
|
+
* `document.body`. Computes document-relative coords from
|
|
32
|
+
* `getBoundingClientRect()`, flips to the opposite side when the preferred
|
|
33
|
+
* side doesn't fit the viewport, clamps into the viewport, and recomputes
|
|
34
|
+
* on scroll of *any* ancestor (capture-phase) and on resize
|
|
35
|
+
* (rAF-coalesced). Listeners are torn down on close/unmount.
|
|
36
|
+
*
|
|
37
|
+
* The content must be mounted (it can be visually hidden) so its size can
|
|
38
|
+
* be measured — gate visibility on the returned `ready` flag.
|
|
39
|
+
*
|
|
40
|
+
* ```tsx
|
|
41
|
+
* const pos = usePopoverPosition(triggerRef, contentRef, { open, side: 'bottom' });
|
|
42
|
+
* <Portal><div ref={contentRef} style={{
|
|
43
|
+
* position: 'absolute', top: pos.top, left: pos.left,
|
|
44
|
+
* visibility: pos.ready ? 'visible' : 'hidden',
|
|
45
|
+
* }} /></Portal>
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare function usePopoverPosition(anchorRef: React.RefObject<HTMLElement | VirtualElement | null>, contentRef: React.RefObject<HTMLElement | null>, { open, side, align, offset, matchAnchorWidth }: UsePopoverPositionOptions): PopoverPosition;
|
|
49
|
+
|
|
50
|
+
export { type PopoverAlign, type PopoverPosition, type PopoverSide, type UsePopoverPositionOptions, type VirtualElement, usePopoverPosition };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkDPMUWQHL_js = require('../chunk-DPMUWQHL.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "usePopoverPosition", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkDPMUWQHL_js.usePopoverPosition; }
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=usePopoverPosition.js.map
|
|
12
|
+
//# sourceMappingURL=usePopoverPosition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"usePopoverPosition.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"usePopoverPosition.mjs"}
|
package/dist/index.d.mts
CHANGED
|
@@ -28,7 +28,7 @@ export { PermissionAction, PermissionMatrix, PermissionMatrixProps, PermissionRo
|
|
|
28
28
|
export { GalleryImage, ImageGallery, ImageGalleryProps, Lightbox, LightboxProps } from './components/Gallery.mjs';
|
|
29
29
|
export { AddressField, AddressFieldOption, AddressForm, AddressFormProps, CartDrawer, CartDrawerProps, CartLineItem, CompareAttribute, CompareItem, CompareTable, CompareTableProps, FreeShippingProgress, FreeShippingProgressProps, OrderLineRow, OrderSummary, OrderSummaryProps, PriceDisplay, PriceDisplayProps, PromoCodeInput, PromoCodeInputProps, QuantitySelector, QuantitySelectorProps, Rating, RatingProps, VariantOption, VariantSelector, VariantSelectorProps, WishlistButton, WishlistButtonProps } from './components/Commerce.mjs';
|
|
30
30
|
export { CategoryItem, CategoryNav, CategoryNavProps, Hero, HeroProps, Testimonial, TestimonialProps } from './components/Marketing.mjs';
|
|
31
|
-
export { Popover,
|
|
31
|
+
export { Popover, PopoverPlacement, PopoverProps } from './components/Popover.mjs';
|
|
32
32
|
export { HoverCard, HoverCardPlacement, HoverCardProps } from './components/HoverCard.mjs';
|
|
33
33
|
export { ContextMenu, ContextMenuItem, ContextMenuProps } from './components/ContextMenu.mjs';
|
|
34
34
|
export { Toggle, ToggleGroup, ToggleGroupItem, ToggleGroupItemProps, ToggleGroupMultipleProps, ToggleGroupProps, ToggleGroupSingleProps, ToggleProps, ToggleSize, ToggleVariant } from './components/Toggle.mjs';
|
|
@@ -39,5 +39,8 @@ export { ResizableDirection, ResizableGroup, ResizableGroupProps, ResizableHandl
|
|
|
39
39
|
export { Menubar, MenubarItem, MenubarMenu, MenubarProps } from './components/Menubar.mjs';
|
|
40
40
|
export { NavLink, NavMenuItem, NavigationMenu, NavigationMenuProps } from './components/NavigationMenu.mjs';
|
|
41
41
|
export { Collapsible, CollapsibleContent, CollapsibleProps, CollapsibleTrigger } from './components/Collapsible.mjs';
|
|
42
|
+
export { Portal, PortalProps } from './components/Portal.mjs';
|
|
43
|
+
export { PopoverAlign, PopoverPosition, PopoverSide, UsePopoverPositionOptions, VirtualElement, usePopoverPosition } from './hooks/usePopoverPosition.mjs';
|
|
44
|
+
export { UseDismissOptions, useDismiss } from './hooks/useDismiss.mjs';
|
|
42
45
|
import 'react/jsx-runtime';
|
|
43
46
|
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export { PermissionAction, PermissionMatrix, PermissionMatrixProps, PermissionRo
|
|
|
28
28
|
export { GalleryImage, ImageGallery, ImageGalleryProps, Lightbox, LightboxProps } from './components/Gallery.js';
|
|
29
29
|
export { AddressField, AddressFieldOption, AddressForm, AddressFormProps, CartDrawer, CartDrawerProps, CartLineItem, CompareAttribute, CompareItem, CompareTable, CompareTableProps, FreeShippingProgress, FreeShippingProgressProps, OrderLineRow, OrderSummary, OrderSummaryProps, PriceDisplay, PriceDisplayProps, PromoCodeInput, PromoCodeInputProps, QuantitySelector, QuantitySelectorProps, Rating, RatingProps, VariantOption, VariantSelector, VariantSelectorProps, WishlistButton, WishlistButtonProps } from './components/Commerce.js';
|
|
30
30
|
export { CategoryItem, CategoryNav, CategoryNavProps, Hero, HeroProps, Testimonial, TestimonialProps } from './components/Marketing.js';
|
|
31
|
-
export { Popover,
|
|
31
|
+
export { Popover, PopoverPlacement, PopoverProps } from './components/Popover.js';
|
|
32
32
|
export { HoverCard, HoverCardPlacement, HoverCardProps } from './components/HoverCard.js';
|
|
33
33
|
export { ContextMenu, ContextMenuItem, ContextMenuProps } from './components/ContextMenu.js';
|
|
34
34
|
export { Toggle, ToggleGroup, ToggleGroupItem, ToggleGroupItemProps, ToggleGroupMultipleProps, ToggleGroupProps, ToggleGroupSingleProps, ToggleProps, ToggleSize, ToggleVariant } from './components/Toggle.js';
|
|
@@ -39,5 +39,8 @@ export { ResizableDirection, ResizableGroup, ResizableGroupProps, ResizableHandl
|
|
|
39
39
|
export { Menubar, MenubarItem, MenubarMenu, MenubarProps } from './components/Menubar.js';
|
|
40
40
|
export { NavLink, NavMenuItem, NavigationMenu, NavigationMenuProps } from './components/NavigationMenu.js';
|
|
41
41
|
export { Collapsible, CollapsibleContent, CollapsibleProps, CollapsibleTrigger } from './components/Collapsible.js';
|
|
42
|
+
export { Portal, PortalProps } from './components/Portal.js';
|
|
43
|
+
export { PopoverAlign, PopoverPosition, PopoverSide, UsePopoverPositionOptions, VirtualElement, usePopoverPosition } from './hooks/usePopoverPosition.js';
|
|
44
|
+
export { UseDismissOptions, useDismiss } from './hooks/useDismiss.js';
|
|
42
45
|
import 'react/jsx-runtime';
|
|
43
46
|
import 'react';
|