@bridge-ui/vue 0.22.1 → 0.24.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/ai/skills/bridge-ui-overlays/SKILL.md +4 -2
- package/dist/Actions/Snackbar/BridgeSnackbarAction.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/Actions/Snackbar/BridgeSnackbarItem.vue_vue_type_script_setup_true_lang.js +31 -25
- package/dist/Actions/Snackbar/bridgeSnackbar.types.d.ts +14 -7
- package/dist/Actions/Snackbar/index.d.ts +1 -1
- package/dist/Actions/index.d.ts +1 -1
- package/dist/Components/ColorField/composables/useColorField.js +1 -1
- package/dist/Components/DateField/composables/useDateField.js +1 -1
- package/dist/Components/DateRangeField/composables/useDateRangeField.js +1 -1
- package/dist/Components/DateTimeField/composables/useDateTimeField.js +1 -1
- package/dist/Components/DateTimeRangeField/composables/useDateTimeRangeField.js +1 -1
- package/dist/Components/Drawer/Drawer.vue_vue_type_script_setup_true_lang.js +7 -7
- package/dist/Components/Drawer/composables/useDrawer.d.ts +1 -0
- package/dist/Components/Drawer/composables/useDrawer.js +96 -90
- package/dist/Components/Menu/composables/useMenu.d.ts +8 -8
- package/dist/Components/Menu/composables/useMenu.js +81 -195
- package/dist/Components/Modal/Modal.vue_vue_type_script_setup_true_lang.js +7 -7
- package/dist/Components/Modal/composables/useModal.d.ts +1 -0
- package/dist/Components/Modal/composables/useModal.js +120 -114
- package/dist/Components/Popover/Popover.js +4 -0
- package/dist/Components/Popover/Popover.vue.d.ts +39 -0
- package/dist/Components/Popover/Popover.vue_vue_type_script_setup_true_lang.js +100 -0
- package/dist/Components/Popover/composables/popoverParts.d.ts +52 -0
- package/dist/Components/Popover/composables/popoverParts.js +35 -0
- package/dist/Components/Popover/composables/usePopover.d.ts +68 -0
- package/dist/Components/Popover/composables/usePopover.js +119 -0
- package/dist/Components/Popover/composables/usePopoverBase.d.ts +130 -0
- package/dist/Components/Popover/composables/usePopoverBase.js +210 -0
- package/dist/Components/Popover/index.d.ts +4 -0
- package/dist/Components/Popover/index.js +3 -0
- package/dist/Components/Popover/popover.types.d.ts +207 -0
- package/dist/Components/Resizable/composables/useResizable.js +85 -85
- package/dist/Components/Snackbar/Snackbar.vue.d.ts +1 -1
- package/dist/Components/Snackbar/Snackbar.vue_vue_type_script_setup_true_lang.js +23 -23
- package/dist/Components/Snackbar/composables/useSnackbar.js +107 -107
- package/dist/Components/Snackbar/snackbar.types.d.ts +1 -1
- package/dist/Components/TimeField/composables/useTimeField.js +1 -1
- package/dist/Components/TimeRangeField/composables/useTimeRangeField.js +1 -1
- package/dist/augments.d.ts +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +78 -76
- package/docs/README.md +1 -0
- package/docs/components/Menu.md +4 -0
- package/docs/components/Popover.md +210 -0
- package/package.json +2 -2
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { mergePartBind as e, useBridgeUIComponent as t, useBridgeUIMergedRegistryClasses as n } from "../../../Utils/index.js";
|
|
2
|
+
import { createPopoverSetShow as r, getPopoverPanelTokenClass as i, getPopoverRootBind as a, getPopoverTriggerBind as o } from "./popoverParts.js";
|
|
3
|
+
import { usePopoverBase as s } from "./usePopoverBase.js";
|
|
4
|
+
import { computed as c, toValue as l, useAttrs as u, useId as d } from "vue";
|
|
5
|
+
import { get as f, isEmpty as p, isNil as m, omit as h } from "es-toolkit/compat";
|
|
6
|
+
import { popoverRoundedProps as g, popoverShadowProps as _ } from "@bridge-ui/core/Tokens";
|
|
7
|
+
import { cn as v, splitComponentProps as y } from "@bridge-ui/core/Utils";
|
|
8
|
+
import { closeOpenMenu as b } from "@bridge-ui/core/Layer";
|
|
9
|
+
// src/Components/Popover/composables/usePopover.ts
|
|
10
|
+
var x = [
|
|
11
|
+
"arrow",
|
|
12
|
+
"title",
|
|
13
|
+
"offset",
|
|
14
|
+
"shadow",
|
|
15
|
+
"classes",
|
|
16
|
+
"rounded",
|
|
17
|
+
"strategy",
|
|
18
|
+
"placement",
|
|
19
|
+
"matchWidth",
|
|
20
|
+
"persistent",
|
|
21
|
+
"teleportTo",
|
|
22
|
+
"customProps",
|
|
23
|
+
"keepMounted",
|
|
24
|
+
"closeOnEscape",
|
|
25
|
+
"closeOnFocusOut",
|
|
26
|
+
"closeOnClickAway",
|
|
27
|
+
"disableAutoFocus",
|
|
28
|
+
"disableScrollLock"
|
|
29
|
+
];
|
|
30
|
+
function S(S, C, w = {}) {
|
|
31
|
+
let T = u(), E = d(), D = `${E}-title`, O = c(() => l(w.show ?? !1)), k = r(w), A = c(() => y({
|
|
32
|
+
bridgeKeys: x,
|
|
33
|
+
props: {
|
|
34
|
+
...T,
|
|
35
|
+
...S
|
|
36
|
+
}
|
|
37
|
+
})), { merged: j, entry: M } = t({
|
|
38
|
+
libDefaults: C,
|
|
39
|
+
componentName: "Popover",
|
|
40
|
+
props: () => A.value.componentProps
|
|
41
|
+
}), N = c(() => j.value.customProps), P = n({
|
|
42
|
+
entry: M,
|
|
43
|
+
props: () => A.value.componentProps
|
|
44
|
+
}), F = c(() => w.hasTitleSlot?.() ? !0 : !m(j.value.title) && !p(j.value.title)), I = c(() => j.value.teleportTo !== !1), L = c(() => i(g, M.value?.tokens?.rounded, j.value.rounded)), R = c(() => i(_, M.value?.tokens?.shadow, j.value.shadow)), z = c(() => h(A.value.inheritedAttrs, ["anchorEl", "onShowChange"])), B = s({
|
|
45
|
+
show: O,
|
|
46
|
+
setShow: k,
|
|
47
|
+
id: E,
|
|
48
|
+
config: j,
|
|
49
|
+
restoreFocus: !0,
|
|
50
|
+
onOpen: b,
|
|
51
|
+
autoFocusContent: !0,
|
|
52
|
+
anchorEl: () => S.anchorEl
|
|
53
|
+
});
|
|
54
|
+
function V() {
|
|
55
|
+
O.value && k(!1);
|
|
56
|
+
}
|
|
57
|
+
function H(e) {
|
|
58
|
+
e.target === e.currentTarget && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), B.toggle());
|
|
59
|
+
}
|
|
60
|
+
let U = c(() => a({
|
|
61
|
+
classes: P.value,
|
|
62
|
+
customProps: N.value?.root,
|
|
63
|
+
inheritedAttrs: z.value
|
|
64
|
+
})), W = c(() => o({
|
|
65
|
+
show: O.value,
|
|
66
|
+
hasPopup: "dialog",
|
|
67
|
+
controlsId: E,
|
|
68
|
+
toggle: B.toggle,
|
|
69
|
+
classes: P.value,
|
|
70
|
+
onKeydown: H,
|
|
71
|
+
customProps: N.value?.trigger
|
|
72
|
+
})), G = c(() => e(N.value?.content, {}, {
|
|
73
|
+
tabindex: -1,
|
|
74
|
+
id: E,
|
|
75
|
+
role: "dialog",
|
|
76
|
+
"aria-labelledby": F.value ? D : void 0,
|
|
77
|
+
style: { zIndex: B.stackZIndex.value },
|
|
78
|
+
"aria-hidden": B.isHiddenWhileMounted.value ? !0 : void 0,
|
|
79
|
+
class: v({
|
|
80
|
+
"bg-white text-dark-900 dark:bg-dark-800 dark:text-dark-100 ring-1 ring-black/5 dark:ring-white/10 outline-hidden p-3 max-w-[calc(100vw-16px)]": !0,
|
|
81
|
+
"min-w-0 w-full": j.value.matchWidth === !0,
|
|
82
|
+
"w-max": j.value.matchWidth !== !0,
|
|
83
|
+
"invisible pointer-events-none": B.isHiddenWhileMounted.value,
|
|
84
|
+
[L.value ?? ""]: !0,
|
|
85
|
+
[R.value ?? ""]: !0,
|
|
86
|
+
[f(P.value, "content") ?? ""]: !0
|
|
87
|
+
})
|
|
88
|
+
}));
|
|
89
|
+
return {
|
|
90
|
+
close: V,
|
|
91
|
+
merged: j,
|
|
92
|
+
hasTitle: F,
|
|
93
|
+
rootBind: U,
|
|
94
|
+
popoverId: E,
|
|
95
|
+
titleBind: c(() => e(N.value?.title, {}, {
|
|
96
|
+
id: D,
|
|
97
|
+
class: v({
|
|
98
|
+
"mb-2 text-sm font-semibold": !0,
|
|
99
|
+
[f(P.value, "title") ?? ""]: !0
|
|
100
|
+
})
|
|
101
|
+
})),
|
|
102
|
+
arrowBind: c(() => j.value.arrow ? e(N.value?.arrow, {}, {
|
|
103
|
+
"aria-hidden": !0,
|
|
104
|
+
class: v({
|
|
105
|
+
"pointer-events-none absolute size-2 rotate-45 bg-white dark:bg-dark-800 border-black/5 dark:border-white/10": !0,
|
|
106
|
+
"data-[side=top]:border-r data-[side=top]:border-b data-[side=bottom]:border-l data-[side=bottom]:border-t data-[side=left]:border-t data-[side=left]:border-r data-[side=right]:border-b data-[side=right]:border-l": !0,
|
|
107
|
+
[f(P.value, "arrow") ?? ""]: !0
|
|
108
|
+
})
|
|
109
|
+
}) : null),
|
|
110
|
+
isPortaled: I,
|
|
111
|
+
triggerBind: W,
|
|
112
|
+
contentBind: G,
|
|
113
|
+
mounted: B.mounted,
|
|
114
|
+
setArrowRef: B.setArrowRef,
|
|
115
|
+
setTriggerRef: B.setTriggerRef,
|
|
116
|
+
setContentRef: B.setContentRef
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export { S as usePopover };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ComponentPublicInstance, MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { PositionPlacement, PositionStrategy } from '@bridge-ui/core/Runtime';
|
|
3
|
+
/**
|
|
4
|
+
* Behavior settings read reactively by {@link usePopoverBase}.
|
|
5
|
+
*/
|
|
6
|
+
export type PopoverBaseConfig = {
|
|
7
|
+
/**
|
|
8
|
+
* When true, positions the element set with `setArrowRef` against the anchor.
|
|
9
|
+
*/
|
|
10
|
+
arrow?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether a pointer down outside the trigger and content closes the overlay.
|
|
13
|
+
*/
|
|
14
|
+
closeOnClickAway?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether Escape closes the overlay (top-most layer only).
|
|
17
|
+
*/
|
|
18
|
+
closeOnEscape?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether focus moving outside the trigger and content closes the overlay.
|
|
21
|
+
*/
|
|
22
|
+
closeOnFocusOut?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* When true, opening does not move focus into the content.
|
|
25
|
+
*/
|
|
26
|
+
disableAutoFocus?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* When true, body scroll stays enabled while open.
|
|
29
|
+
*/
|
|
30
|
+
disableScrollLock?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Keeps the content mounted (hidden) after closing.
|
|
33
|
+
*/
|
|
34
|
+
keepMounted?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Content width matches the anchor.
|
|
37
|
+
*/
|
|
38
|
+
matchWidth?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Gap between the anchor and the content (px).
|
|
41
|
+
*/
|
|
42
|
+
offset?: number;
|
|
43
|
+
/**
|
|
44
|
+
* When true, Escape, click-away and reference-hidden do not close.
|
|
45
|
+
*/
|
|
46
|
+
persistent?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Preferred placement relative to the anchor.
|
|
49
|
+
*/
|
|
50
|
+
placement?: PositionPlacement;
|
|
51
|
+
/**
|
|
52
|
+
* CSS position strategy for the content.
|
|
53
|
+
*/
|
|
54
|
+
strategy?: PositionStrategy;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Options for {@link usePopoverBase}.
|
|
58
|
+
*/
|
|
59
|
+
export type UsePopoverBaseOptions = {
|
|
60
|
+
/**
|
|
61
|
+
* Anchor used instead of the trigger wrapper.
|
|
62
|
+
*/
|
|
63
|
+
anchorEl?: MaybeRefOrGetter<null | undefined | HTMLElement>;
|
|
64
|
+
/**
|
|
65
|
+
* Focuses the content itself when it has no focusable children.
|
|
66
|
+
*/
|
|
67
|
+
autoFocusContent?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Registers the overlay as the single open menu. Returns a release callback.
|
|
70
|
+
*/
|
|
71
|
+
claimOpen?: (claim: {
|
|
72
|
+
contains: (node: Node) => boolean;
|
|
73
|
+
id: string;
|
|
74
|
+
origin: null | HTMLElement;
|
|
75
|
+
requestClose: () => void;
|
|
76
|
+
}) => () => void;
|
|
77
|
+
/**
|
|
78
|
+
* Reactive behavior settings (usually the merged component props).
|
|
79
|
+
*/
|
|
80
|
+
config: MaybeRefOrGetter<PopoverBaseConfig>;
|
|
81
|
+
/**
|
|
82
|
+
* Stable id for the overlay (used for the open-menu claim).
|
|
83
|
+
*/
|
|
84
|
+
id: string;
|
|
85
|
+
/**
|
|
86
|
+
* Extra click-away targets that must not close the overlay.
|
|
87
|
+
*/
|
|
88
|
+
isClickAwayIgnored?: (target: Element) => boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Called once each time the overlay opens, with the element it opened
|
|
91
|
+
* from: the trigger, or the anchor when there is no trigger.
|
|
92
|
+
*/
|
|
93
|
+
onOpen?: (reference: null | HTMLElement) => void;
|
|
94
|
+
/**
|
|
95
|
+
* When true, closing while focus is inside the content moves focus back
|
|
96
|
+
* to the anchor (instead of letting it fall to `<body>`).
|
|
97
|
+
*/
|
|
98
|
+
restoreFocus?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Requests a visibility change (controlled state).
|
|
101
|
+
*/
|
|
102
|
+
setShow: (show: boolean) => void;
|
|
103
|
+
/**
|
|
104
|
+
* Whether the overlay is open.
|
|
105
|
+
*/
|
|
106
|
+
show: MaybeRefOrGetter<boolean>;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Popover base: the anchored-panel behavior shared by Popover and Menu
|
|
110
|
+
* (mount state, layer stack for Escape / scroll lock / z-index, positioning,
|
|
111
|
+
* click-away and auto-focus). Roles, ARIA and keyboard navigation stay in
|
|
112
|
+
* the caller.
|
|
113
|
+
*/
|
|
114
|
+
export declare function usePopoverBase(options: UsePopoverBaseOptions): {
|
|
115
|
+
toggle: () => void;
|
|
116
|
+
mounted: import('vue').Ref<boolean, boolean>;
|
|
117
|
+
arrowRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
|
|
118
|
+
triggerRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
|
|
119
|
+
contentRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
|
|
120
|
+
stackZIndex: import('vue').Ref<number, number>;
|
|
121
|
+
setArrowRef: (element: null | Element | ComponentPublicInstance) => void;
|
|
122
|
+
requestClose: () => boolean;
|
|
123
|
+
setTriggerRef: (element: null | Element | ComponentPublicInstance) => void;
|
|
124
|
+
setContentRef: (element: null | Element | ComponentPublicInstance) => void;
|
|
125
|
+
focusReference: () => void;
|
|
126
|
+
isInsideOverlay: (target: Node) => boolean;
|
|
127
|
+
isInsideReference: (target: Node) => boolean;
|
|
128
|
+
isInsideNestedLayer: (target: Node) => boolean;
|
|
129
|
+
isHiddenWhileMounted: import('vue').ComputedRef<boolean>;
|
|
130
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { resolveVnodeRefElement as e } from "../../../Utils/index.js";
|
|
2
|
+
import { computed as t, nextTick as n, onBeforeUnmount as r, ref as i, toValue as a, watch as o } from "vue";
|
|
3
|
+
import { createFocusable as ee, createPositionable as te, hasDocument as s } from "@bridge-ui/core/Runtime";
|
|
4
|
+
import { LAYER_STACK_BASE_Z_INDEX as c, acquireLayerStackOrder as ne, getLayerStackEntry as l, isInsideNestedLayer as re, pushLayerStack as ie, subscribeLayerStack as u } from "@bridge-ui/core/Layer";
|
|
5
|
+
// src/Components/Popover/composables/usePopoverBase.ts
|
|
6
|
+
function d(d) {
|
|
7
|
+
let { id: ae, setShow: f, claimOpen: p, isClickAwayIgnored: m } = d, h = i(!1), g = i(""), _ = i(c), v = i(null), y = i(null), b = i(null), x = !1, S = null, C = !1, w = null, T = null, E = null, D = null, O = null, k = null, A = !1, j = !1, M = null, N = t(() => a(d.show)), P = t(() => a(d.config)), F = t(() => a(d.anchorEl) ?? null), I = t(() => !P.value.persistent), L = t(() => !(!P.value.keepMounted || N.value));
|
|
8
|
+
function R() {
|
|
9
|
+
return F.value ?? y.value;
|
|
10
|
+
}
|
|
11
|
+
function z() {
|
|
12
|
+
R()?.focus({ preventScroll: !0 });
|
|
13
|
+
}
|
|
14
|
+
function B() {
|
|
15
|
+
return y.value ?? R();
|
|
16
|
+
}
|
|
17
|
+
function V(e) {
|
|
18
|
+
return R()?.contains(e) ? !0 : y.value?.contains(e) ?? !1;
|
|
19
|
+
}
|
|
20
|
+
function H(e) {
|
|
21
|
+
return b.value?.contains(e) === !0 || U(e);
|
|
22
|
+
}
|
|
23
|
+
function U(e) {
|
|
24
|
+
return re(e, g.value);
|
|
25
|
+
}
|
|
26
|
+
function W(e) {
|
|
27
|
+
return V(e) || H(e);
|
|
28
|
+
}
|
|
29
|
+
function G() {
|
|
30
|
+
return !I.value || !N.value || j ? !1 : (j = !0, setTimeout(() => {
|
|
31
|
+
j = !1;
|
|
32
|
+
}, 0), f(!1), !0);
|
|
33
|
+
}
|
|
34
|
+
function K(e) {
|
|
35
|
+
let t = e.target, n = e.relatedTarget;
|
|
36
|
+
P.value.closeOnFocusOut === !0 && t instanceof Node && (y.value?.contains(t) === !0 || b.value?.contains(t) === !0 || U(t)) && n instanceof Node && !W(n) && G();
|
|
37
|
+
}
|
|
38
|
+
function q() {
|
|
39
|
+
k?.(), k = null, s() && N.value && P.value.closeOnFocusOut === !0 && (document.addEventListener("focusout", K, !0), k = () => {
|
|
40
|
+
document.removeEventListener("focusout", K, !0);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function oe() {
|
|
44
|
+
P.value.persistent && N.value || f(!N.value);
|
|
45
|
+
}
|
|
46
|
+
function J() {
|
|
47
|
+
C = !1, E?.destroy(), E = null;
|
|
48
|
+
}
|
|
49
|
+
function se() {
|
|
50
|
+
J();
|
|
51
|
+
let e = R(), t = b.value;
|
|
52
|
+
N.value && e && t && (E = te({
|
|
53
|
+
floating: t,
|
|
54
|
+
reference: e,
|
|
55
|
+
offset: P.value.offset,
|
|
56
|
+
strategy: P.value.strategy,
|
|
57
|
+
placement: P.value.placement,
|
|
58
|
+
matchWidth: P.value.matchWidth === !0,
|
|
59
|
+
arrow: P.value.arrow ? () => v.value : void 0,
|
|
60
|
+
onReferenceHidden: () => {
|
|
61
|
+
C && G();
|
|
62
|
+
}
|
|
63
|
+
}), E.start(), n(() => {
|
|
64
|
+
C = !0;
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
function ce() {
|
|
68
|
+
let e = b.value;
|
|
69
|
+
if (!N.value || P.value.disableAutoFocus || !e) return;
|
|
70
|
+
let t = ee(e);
|
|
71
|
+
t.first() ? t.focusFirst() : d.autoFocusContent && e.focus({ preventScroll: !0 });
|
|
72
|
+
}
|
|
73
|
+
function le(e, t) {
|
|
74
|
+
if (!e.defaultPrevented || !t || x || N.value || !d.restoreFocus) return;
|
|
75
|
+
let n = document.activeElement;
|
|
76
|
+
(!n || n === document.body || b.value?.contains(n)) && z();
|
|
77
|
+
}
|
|
78
|
+
function ue(e) {
|
|
79
|
+
let t = document.activeElement, n = !!(t && b.value?.contains(t));
|
|
80
|
+
A = !0, !G() && !j ? A = !1 : setTimeout(() => {
|
|
81
|
+
A = !1, le(e, n);
|
|
82
|
+
}, 0);
|
|
83
|
+
}
|
|
84
|
+
function Y() {
|
|
85
|
+
if (O?.(), !s() || !N.value) {
|
|
86
|
+
O = null;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
function e(e) {
|
|
90
|
+
let t = e.target;
|
|
91
|
+
I.value && P.value.closeOnClickAway !== !1 && (W(t) || t instanceof Element && m?.(t) || ue(e));
|
|
92
|
+
}
|
|
93
|
+
document.addEventListener("pointerdown", e, !0), O = () => {
|
|
94
|
+
document.removeEventListener("pointerdown", e, !0);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function X() {
|
|
98
|
+
T?.setContainer(b.value);
|
|
99
|
+
}
|
|
100
|
+
function de() {
|
|
101
|
+
d.onOpen?.(B()), p && (w = p({
|
|
102
|
+
id: ae,
|
|
103
|
+
requestClose: G,
|
|
104
|
+
contains: H,
|
|
105
|
+
origin: B()
|
|
106
|
+
})), Y();
|
|
107
|
+
}
|
|
108
|
+
function Z(e) {
|
|
109
|
+
if (M) {
|
|
110
|
+
M.open ||= e.open === !0, M.focus ||= e.focus === !0, M.position ||= e.position === !0;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
let t = {
|
|
114
|
+
open: e.open === !0,
|
|
115
|
+
focus: e.focus === !0,
|
|
116
|
+
position: e.position === !0
|
|
117
|
+
};
|
|
118
|
+
M = t, n(() => {
|
|
119
|
+
M === t && (M = null, !x && N.value && (X(), t.open && de(), t.position && se(), t.focus && ce()));
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function fe() {
|
|
123
|
+
T?.release(), S ??= ne(), T = ie({
|
|
124
|
+
order: S,
|
|
125
|
+
onEscape: _e,
|
|
126
|
+
origin: () => B(),
|
|
127
|
+
container: b.value ?? void 0,
|
|
128
|
+
lockScroll: P.value.disableScrollLock !== !0
|
|
129
|
+
}), g.value = T.id, _.value = T.zIndex, Q();
|
|
130
|
+
}
|
|
131
|
+
function pe() {
|
|
132
|
+
if (A) {
|
|
133
|
+
A = !1;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (!d.restoreFocus || !s()) return;
|
|
137
|
+
let e = b.value, t = document.activeElement;
|
|
138
|
+
e && t && e.contains(t) && z();
|
|
139
|
+
}
|
|
140
|
+
function me(t) {
|
|
141
|
+
let n = e(t);
|
|
142
|
+
y.value !== n && (y.value = n, n && N.value && Z({ position: !0 }));
|
|
143
|
+
}
|
|
144
|
+
function he(t) {
|
|
145
|
+
let n = e(t);
|
|
146
|
+
b.value !== n && (b.value = n, X(), n && N.value && Z({
|
|
147
|
+
focus: !0,
|
|
148
|
+
position: !0
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
function ge(t) {
|
|
152
|
+
v.value = e(t);
|
|
153
|
+
}
|
|
154
|
+
function _e() {
|
|
155
|
+
P.value.closeOnEscape !== !1 && G() && z();
|
|
156
|
+
}
|
|
157
|
+
function Q() {
|
|
158
|
+
let e = l(g.value);
|
|
159
|
+
e && (_.value = e.zIndex);
|
|
160
|
+
}
|
|
161
|
+
function $() {
|
|
162
|
+
M = null, S = null, w?.(), w = null, O?.(), O = null, k?.(), k = null, D?.(), D = null, T?.release(), T = null, g.value = "", _.value = c, J();
|
|
163
|
+
}
|
|
164
|
+
return o(N, (e) => {
|
|
165
|
+
if (j = !1, e) {
|
|
166
|
+
if (A = !1, h.value = !0, !s()) return;
|
|
167
|
+
fe(), q(), D = u(Q), Z({
|
|
168
|
+
open: !0,
|
|
169
|
+
focus: !0,
|
|
170
|
+
position: !0
|
|
171
|
+
});
|
|
172
|
+
} else pe(), $(), P.value.keepMounted || (h.value = !1);
|
|
173
|
+
}, { immediate: !0 }), o(() => P.value.disableScrollLock, (e) => {
|
|
174
|
+
T?.setLockScroll(e !== !0);
|
|
175
|
+
}), o([
|
|
176
|
+
F,
|
|
177
|
+
() => P.value.arrow,
|
|
178
|
+
() => P.value.offset,
|
|
179
|
+
() => P.value.strategy,
|
|
180
|
+
() => P.value.placement,
|
|
181
|
+
() => P.value.matchWidth
|
|
182
|
+
], () => {
|
|
183
|
+
N.value && Z({ position: !0 });
|
|
184
|
+
}), o(() => P.value.keepMounted, (e) => {
|
|
185
|
+
!e && !N.value && (h.value = !1);
|
|
186
|
+
}), o(() => P.value.closeOnFocusOut, () => {
|
|
187
|
+
N.value && q();
|
|
188
|
+
}), o(() => P.value.disableAutoFocus, () => {
|
|
189
|
+
N.value && Z({ focus: !0 });
|
|
190
|
+
}), r(() => {
|
|
191
|
+
x = !0, $();
|
|
192
|
+
}), {
|
|
193
|
+
toggle: oe,
|
|
194
|
+
mounted: h,
|
|
195
|
+
arrowRef: v,
|
|
196
|
+
triggerRef: y,
|
|
197
|
+
contentRef: b,
|
|
198
|
+
stackZIndex: _,
|
|
199
|
+
setArrowRef: ge,
|
|
200
|
+
requestClose: G,
|
|
201
|
+
setTriggerRef: me,
|
|
202
|
+
setContentRef: he,
|
|
203
|
+
focusReference: z,
|
|
204
|
+
isInsideOverlay: W,
|
|
205
|
+
isInsideReference: V,
|
|
206
|
+
isInsideNestedLayer: U,
|
|
207
|
+
isHiddenWhileMounted: L
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
export { d as usePopoverBase };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { usePopover } from './composables/usePopover';
|
|
2
|
+
export type { PopoverOptions } from './composables/usePopover';
|
|
3
|
+
export type { PopoverClasses, PopoverCustomProps, PopoverEmits, PopoverOwnProps, PopoverProps, PopoverRoundedOverrides, PopoverShadowOverrides, PopoverSlots, } from './popover.types';
|
|
4
|
+
export { default as Popover } from './Popover.vue';
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { HTMLAttributes, Slot } from 'vue';
|
|
2
|
+
import { PositionPlacement, PositionStrategy } from '@bridge-ui/core/Runtime';
|
|
3
|
+
import { PopoverRounded, PopoverShadow } from '@bridge-ui/core/Tokens';
|
|
4
|
+
import { MergeHtmlProps, MergeProps } from '@bridge-ui/core/Utils';
|
|
5
|
+
export interface PopoverShadowOverrides {}
|
|
6
|
+
export interface PopoverRoundedOverrides {}
|
|
7
|
+
export interface PopoverClasses {
|
|
8
|
+
/**
|
|
9
|
+
* The classes to apply to the arrow.
|
|
10
|
+
*/
|
|
11
|
+
arrow?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The classes to apply to the floating content.
|
|
14
|
+
*/
|
|
15
|
+
content?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The classes to apply to the root.
|
|
18
|
+
*/
|
|
19
|
+
root?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The classes to apply to the title.
|
|
22
|
+
*/
|
|
23
|
+
title?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The classes to apply to the trigger.
|
|
26
|
+
*/
|
|
27
|
+
trigger?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface PopoverCustomProps {
|
|
30
|
+
/**
|
|
31
|
+
* Props forwarded to the arrow element.
|
|
32
|
+
*/
|
|
33
|
+
arrow?: HTMLAttributes;
|
|
34
|
+
/**
|
|
35
|
+
* Props forwarded to the floating content (`role="dialog"`).
|
|
36
|
+
*/
|
|
37
|
+
content?: HTMLAttributes;
|
|
38
|
+
/**
|
|
39
|
+
* Props forwarded to the root wrapper (contains the trigger).
|
|
40
|
+
*/
|
|
41
|
+
root?: HTMLAttributes;
|
|
42
|
+
/**
|
|
43
|
+
* Props forwarded to the title element.
|
|
44
|
+
*/
|
|
45
|
+
title?: HTMLAttributes;
|
|
46
|
+
/**
|
|
47
|
+
* Props forwarded to the trigger wrapper.
|
|
48
|
+
*/
|
|
49
|
+
trigger?: HTMLAttributes;
|
|
50
|
+
}
|
|
51
|
+
export interface PopoverEmits {
|
|
52
|
+
/**
|
|
53
|
+
* Emitted when the user dismisses the popover (Escape, click-away or focus leaving).
|
|
54
|
+
* Not emitted when the parent sets `v-model` to `false` directly.
|
|
55
|
+
*/
|
|
56
|
+
close: [];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Anchored, non-modal floating panel for free-form content (forms, filters, cards).
|
|
60
|
+
* Visibility is controlled with `v-model` (not listed here — `defineModel` handles it).
|
|
61
|
+
* Anchor with `anchorEl` or put the opener in the `trigger` slot.
|
|
62
|
+
*/
|
|
63
|
+
export interface PopoverOwnProps {
|
|
64
|
+
/**
|
|
65
|
+
* Element that anchors the popover. When set, it is used
|
|
66
|
+
* for positioning and click-away instead of the `trigger` slot wrapper.
|
|
67
|
+
* Not merged into Bridge defaults (DOM nodes must not be deep-merged).
|
|
68
|
+
*
|
|
69
|
+
* @default undefined
|
|
70
|
+
*/
|
|
71
|
+
anchorEl?: null | HTMLElement;
|
|
72
|
+
/**
|
|
73
|
+
* Whether to show an arrow pointing at the anchor.
|
|
74
|
+
*
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
arrow?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The classes to apply to the popover.
|
|
80
|
+
*
|
|
81
|
+
* @default undefined
|
|
82
|
+
*/
|
|
83
|
+
classes?: PopoverClasses;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the popover closes when clicking outside the trigger and content.
|
|
86
|
+
*
|
|
87
|
+
* @default true
|
|
88
|
+
*/
|
|
89
|
+
closeOnClickAway?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Whether the popover closes on escape key press.
|
|
92
|
+
*
|
|
93
|
+
* @default true
|
|
94
|
+
*/
|
|
95
|
+
closeOnEscape?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the popover closes when focus moves outside the trigger and
|
|
98
|
+
* content (Tab past the last field, for example).
|
|
99
|
+
*
|
|
100
|
+
* @default true
|
|
101
|
+
*/
|
|
102
|
+
closeOnFocusOut?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Props forwarded to each popover part.
|
|
105
|
+
*
|
|
106
|
+
* @default undefined
|
|
107
|
+
*/
|
|
108
|
+
customProps?: PopoverCustomProps;
|
|
109
|
+
/**
|
|
110
|
+
* When true, the popover does not move focus into the content on open.
|
|
111
|
+
*
|
|
112
|
+
* @default false
|
|
113
|
+
*/
|
|
114
|
+
disableAutoFocus?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* When true, body scroll is not locked while the popover is open.
|
|
117
|
+
*
|
|
118
|
+
* @default true
|
|
119
|
+
*/
|
|
120
|
+
disableScrollLock?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* When true, the popover stays mounted in the DOM after closing (hidden).
|
|
123
|
+
*
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
keepMounted?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* When true, the content width matches the trigger / anchor.
|
|
129
|
+
*
|
|
130
|
+
* @default false
|
|
131
|
+
*/
|
|
132
|
+
matchWidth?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Gap between the anchor and the content (px).
|
|
135
|
+
*
|
|
136
|
+
* @default 8
|
|
137
|
+
*/
|
|
138
|
+
offset?: number;
|
|
139
|
+
/**
|
|
140
|
+
* Called when `show` should change (controlled state without `v-model`).
|
|
141
|
+
*
|
|
142
|
+
* @default undefined
|
|
143
|
+
*/
|
|
144
|
+
onShowChange?: (show: boolean) => void;
|
|
145
|
+
/**
|
|
146
|
+
* When true, escape, click-away and focus leaving do not close the popover.
|
|
147
|
+
*
|
|
148
|
+
* @default false
|
|
149
|
+
*/
|
|
150
|
+
persistent?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Preferred placement of the content relative to the anchor.
|
|
153
|
+
*
|
|
154
|
+
* @default "bottom-start"
|
|
155
|
+
*/
|
|
156
|
+
placement?: PositionPlacement;
|
|
157
|
+
/**
|
|
158
|
+
* The roundedness of the content.
|
|
159
|
+
*
|
|
160
|
+
* @default "md"
|
|
161
|
+
*/
|
|
162
|
+
rounded?: MergeProps<PopoverRounded, PopoverRoundedOverrides>;
|
|
163
|
+
/**
|
|
164
|
+
* The shadow to apply to the content.
|
|
165
|
+
*
|
|
166
|
+
* @default "md"
|
|
167
|
+
*/
|
|
168
|
+
shadow?: MergeProps<PopoverShadow, PopoverShadowOverrides>;
|
|
169
|
+
/**
|
|
170
|
+
* CSS position strategy for the content.
|
|
171
|
+
*
|
|
172
|
+
* @default "fixed"
|
|
173
|
+
*/
|
|
174
|
+
strategy?: PositionStrategy;
|
|
175
|
+
/**
|
|
176
|
+
* Where to portal the content. Pass `false` to render in place
|
|
177
|
+
* (keeps the natural Tab order after the trigger).
|
|
178
|
+
*
|
|
179
|
+
* @default "body"
|
|
180
|
+
*/
|
|
181
|
+
teleportTo?: false | string;
|
|
182
|
+
/**
|
|
183
|
+
* Heading rendered at the top of the content. Labels the dialog
|
|
184
|
+
* (`aria-labelledby`); without it, pass `aria-label` via `customProps.content`.
|
|
185
|
+
* The `title` slot takes precedence.
|
|
186
|
+
*
|
|
187
|
+
* @default undefined
|
|
188
|
+
*/
|
|
189
|
+
title?: string;
|
|
190
|
+
}
|
|
191
|
+
export interface PopoverSlots {
|
|
192
|
+
/**
|
|
193
|
+
* The popover content. Receives `close` to dismiss from inside.
|
|
194
|
+
*/
|
|
195
|
+
default?: Slot<{
|
|
196
|
+
close: () => void;
|
|
197
|
+
}>;
|
|
198
|
+
/**
|
|
199
|
+
* Custom heading content (labels the dialog).
|
|
200
|
+
*/
|
|
201
|
+
title?: Slot<undefined>;
|
|
202
|
+
/**
|
|
203
|
+
* The trigger element that opens the popover.
|
|
204
|
+
*/
|
|
205
|
+
trigger?: Slot<undefined>;
|
|
206
|
+
}
|
|
207
|
+
export type PopoverProps = MergeHtmlProps<PopoverOwnProps, HTMLAttributes>;
|