@bridge-ui/vue 0.23.0 → 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/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/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,39 @@
|
|
|
1
|
+
import { PopoverOwnProps, PopoverSlots } from './popover.types';
|
|
2
|
+
type __VLS_Slots = PopoverSlots;
|
|
3
|
+
type __VLS_Props = PopoverOwnProps;
|
|
4
|
+
type __VLS_ModelProps = {
|
|
5
|
+
modelValue?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
8
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
9
|
+
close: () => any;
|
|
10
|
+
"update:modelValue": (value: boolean) => any;
|
|
11
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
12
|
+
onClose?: (() => any) | undefined;
|
|
13
|
+
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
14
|
+
}>, {
|
|
15
|
+
offset: number;
|
|
16
|
+
rounded: import('@bridge-ui/core/Utils').MergeProps<import('@bridge-ui/core/Tokens').PopoverRounded, import('./popover.types').PopoverRoundedOverrides>;
|
|
17
|
+
shadow: import('@bridge-ui/core/Utils').MergeProps<import('@bridge-ui/core/Tokens').PopoverShadow, import('./popover.types').PopoverShadowOverrides>;
|
|
18
|
+
closeOnEscape: boolean;
|
|
19
|
+
disableScrollLock: boolean;
|
|
20
|
+
keepMounted: boolean;
|
|
21
|
+
persistent: boolean;
|
|
22
|
+
placement: import('@floating-ui/utils').Placement;
|
|
23
|
+
teleportTo: false | string;
|
|
24
|
+
anchorEl: null | HTMLElement;
|
|
25
|
+
closeOnClickAway: boolean;
|
|
26
|
+
disableAutoFocus: boolean;
|
|
27
|
+
matchWidth: boolean;
|
|
28
|
+
strategy: import('@bridge-ui/core/Runtime').PositionStrategy;
|
|
29
|
+
arrow: boolean;
|
|
30
|
+
closeOnFocusOut: boolean;
|
|
31
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
32
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
33
|
+
declare const _default: typeof __VLS_export;
|
|
34
|
+
export default _default;
|
|
35
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
36
|
+
new (): {
|
|
37
|
+
$slots: S;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { hasNamedSlot as e } from "../../Utils/slotOrProp.js";
|
|
2
|
+
import { usePopover as t } from "./composables/usePopover.js";
|
|
3
|
+
import { Fragment as n, Teleport as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createTextVNode as l, defineComponent as u, mergeModels as d, mergeProps as f, normalizeProps as p, openBlock as m, renderSlot as h, toDisplayString as g, unref as _, useModel as v, useSlots as y } from "vue";
|
|
4
|
+
// src/Components/Popover/Popover.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var b = /*@__PURE__*/ u({
|
|
6
|
+
inheritAttrs: !1,
|
|
7
|
+
__name: "Popover",
|
|
8
|
+
props: /*@__PURE__*/ d({
|
|
9
|
+
anchorEl: { default: null },
|
|
10
|
+
arrow: {
|
|
11
|
+
type: Boolean,
|
|
12
|
+
default: !1
|
|
13
|
+
},
|
|
14
|
+
classes: {},
|
|
15
|
+
closeOnClickAway: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: !0
|
|
18
|
+
},
|
|
19
|
+
closeOnEscape: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: !0
|
|
22
|
+
},
|
|
23
|
+
closeOnFocusOut: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: !0
|
|
26
|
+
},
|
|
27
|
+
customProps: {},
|
|
28
|
+
disableAutoFocus: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: !1
|
|
31
|
+
},
|
|
32
|
+
disableScrollLock: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: !0
|
|
35
|
+
},
|
|
36
|
+
keepMounted: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: !1
|
|
39
|
+
},
|
|
40
|
+
matchWidth: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: !1
|
|
43
|
+
},
|
|
44
|
+
offset: { default: 8 },
|
|
45
|
+
onShowChange: {},
|
|
46
|
+
persistent: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: !1
|
|
49
|
+
},
|
|
50
|
+
placement: { default: "bottom-start" },
|
|
51
|
+
rounded: { default: "md" },
|
|
52
|
+
shadow: { default: "md" },
|
|
53
|
+
strategy: { default: "fixed" },
|
|
54
|
+
teleportTo: {
|
|
55
|
+
type: [Boolean, String],
|
|
56
|
+
default: "body"
|
|
57
|
+
},
|
|
58
|
+
title: {}
|
|
59
|
+
}, {
|
|
60
|
+
modelValue: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: !1
|
|
63
|
+
},
|
|
64
|
+
modelModifiers: {}
|
|
65
|
+
}),
|
|
66
|
+
emits: /*@__PURE__*/ d(["close"], ["update:modelValue"]),
|
|
67
|
+
setup(u, { emit: d }) {
|
|
68
|
+
let b = y(), x = d, S = u, C = v(u, "modelValue"), { close: w, merged: T, mounted: E, hasTitle: D, rootBind: O, titleBind: k, arrowBind: A, triggerBind: j, contentBind: M, setArrowRef: N, setTriggerRef: P, setContentRef: F } = t(S, {
|
|
69
|
+
offset: 8,
|
|
70
|
+
arrow: !1,
|
|
71
|
+
shadow: "md",
|
|
72
|
+
rounded: "md",
|
|
73
|
+
strategy: "fixed",
|
|
74
|
+
teleportTo: "body",
|
|
75
|
+
closeOnEscape: !0,
|
|
76
|
+
closeOnFocusOut: !0,
|
|
77
|
+
closeOnClickAway: !0,
|
|
78
|
+
disableScrollLock: !0,
|
|
79
|
+
placement: "bottom-start"
|
|
80
|
+
}, {
|
|
81
|
+
show: C,
|
|
82
|
+
onClose: () => x("close"),
|
|
83
|
+
hasTitleSlot: () => e(b, "title"),
|
|
84
|
+
onShowChange: (e) => S.onShowChange?.(e)
|
|
85
|
+
}), I = i(() => T.value.teleportTo === !1), L = i(() => T.value.teleportTo === !1 ? "body" : T.value.teleportTo);
|
|
86
|
+
return (t, i) => (m(), s(n, null, [_(e)(_(b), "trigger") ? (m(), s("div", p(f({ key: 0 }, _(O))), [c("div", f({ ref: _(P) }, _(j)), [h(t.$slots, "trigger")], 16)], 16)) : o("", !0), _(E) ? (m(), a(r, {
|
|
87
|
+
key: 1,
|
|
88
|
+
to: L.value,
|
|
89
|
+
disabled: I.value
|
|
90
|
+
}, [c("div", f({ ref: _(F) }, _(M)), [
|
|
91
|
+
_(D) ? (m(), s("div", p(f({ key: 0 }, _(k))), [h(t.$slots, "title", {}, () => [l(g(_(T).title), 1)])], 16)) : o("", !0),
|
|
92
|
+
h(t.$slots, "default", { close: _(w) }),
|
|
93
|
+
_(A) ? (m(), s("div", f({
|
|
94
|
+
key: 1,
|
|
95
|
+
ref: _(N)
|
|
96
|
+
}, _(A)), null, 16)) : o("", !0)
|
|
97
|
+
], 16)], 8, ["to", "disabled"])) : o("", !0)], 64));
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
export { b as default };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { HTMLAttributes, Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Root and trigger parts shared by Popover and Menu (the anchored panels
|
|
4
|
+
* built on `usePopoverBase`). Content, roles and keyboard handling
|
|
5
|
+
* stay in each component.
|
|
6
|
+
*/
|
|
7
|
+
type PartClasses = undefined | Partial<Record<"root" | "trigger", string>>;
|
|
8
|
+
type PartProps = undefined | HTMLAttributes;
|
|
9
|
+
/**
|
|
10
|
+
* `setShow` for an overlay bound with `v-model:show`: calls `onClose` on
|
|
11
|
+
* close, updates the model, then calls `onShowChange`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createPopoverSetShow(options: {
|
|
14
|
+
onClose?: () => void;
|
|
15
|
+
onShowChange?: (show: boolean) => void;
|
|
16
|
+
show?: Ref<boolean>;
|
|
17
|
+
}): (show: boolean) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Panel token class (`rounded`, `shadow`): the base token map merged with
|
|
20
|
+
* the registry overrides, resolved for the selected key.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getPopoverPanelTokenClass<T extends object>(props: T, overrides: undefined | Partial<T>, key: keyof T | undefined): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Root wrapper bind (holds the trigger).
|
|
25
|
+
*/
|
|
26
|
+
export declare function getPopoverRootBind(options: {
|
|
27
|
+
classes: PartClasses;
|
|
28
|
+
customProps: PartProps;
|
|
29
|
+
inheritedAttrs: object;
|
|
30
|
+
}): import('@bridge-ui/core/Utils').MergePartBind<object, "class", PartProps, object>;
|
|
31
|
+
/**
|
|
32
|
+
* Trigger wrapper bind: a focusable button that toggles the panel.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getPopoverTriggerBind(options: {
|
|
35
|
+
classes: PartClasses;
|
|
36
|
+
controlsId: string;
|
|
37
|
+
customProps: PartProps;
|
|
38
|
+
hasPopup: "menu" | "dialog";
|
|
39
|
+
onKeydown: (event: KeyboardEvent) => void;
|
|
40
|
+
show: boolean;
|
|
41
|
+
toggle: () => void;
|
|
42
|
+
}): import('@bridge-ui/core/Utils').MergePartBind<{
|
|
43
|
+
tabindex: number;
|
|
44
|
+
role: string;
|
|
45
|
+
onKeydown: (event: KeyboardEvent) => void;
|
|
46
|
+
"aria-expanded": boolean;
|
|
47
|
+
onClickCapture: () => void;
|
|
48
|
+
"aria-haspopup": "menu" | "dialog";
|
|
49
|
+
"aria-controls": string | undefined;
|
|
50
|
+
class: string;
|
|
51
|
+
}, "class", PartProps, {}>;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { mergePartBind as e } from "../../../Utils/index.js";
|
|
2
|
+
import { get as t } from "es-toolkit/compat";
|
|
3
|
+
import { cn as n, mergeBridgeUILayeredClasses as r } from "@bridge-ui/core/Utils";
|
|
4
|
+
// src/Components/Popover/composables/popoverParts.ts
|
|
5
|
+
function i(e) {
|
|
6
|
+
return (t) => {
|
|
7
|
+
t || e.onClose?.(), e.show && (e.show.value = t), e.onShowChange?.(t);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function a(e, n, i) {
|
|
11
|
+
let a = r(e, n);
|
|
12
|
+
return t(a, i);
|
|
13
|
+
}
|
|
14
|
+
function o(r) {
|
|
15
|
+
return e(r.customProps, r.inheritedAttrs, n({
|
|
16
|
+
"relative inline-flex": !0,
|
|
17
|
+
[t(r.classes, "root") ?? ""]: !0
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
function s(r) {
|
|
21
|
+
return e(r.customProps, {}, {
|
|
22
|
+
tabindex: 0,
|
|
23
|
+
role: "button",
|
|
24
|
+
onKeydown: r.onKeydown,
|
|
25
|
+
"aria-expanded": r.show,
|
|
26
|
+
onClickCapture: r.toggle,
|
|
27
|
+
"aria-haspopup": r.hasPopup,
|
|
28
|
+
"aria-controls": r.show ? r.controlsId : void 0,
|
|
29
|
+
class: n({
|
|
30
|
+
"inline-flex w-fit max-w-full cursor-pointer outline-hidden": !0,
|
|
31
|
+
[t(r.classes, "trigger") ?? ""]: !0
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export { i as createPopoverSetShow, a as getPopoverPanelTokenClass, o as getPopoverRootBind, s as getPopoverTriggerBind };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { LibDefaultsShape, MergeLibDefaults } from '@bridge-ui/core/Utils';
|
|
3
|
+
import { PopoverOwnProps } from '../popover.types';
|
|
4
|
+
type PopoverLibDefaults = LibDefaultsShape<PopoverOwnProps, "arrow" | "offset" | "shadow" | "rounded" | "strategy" | "placement" | "teleportTo" | "closeOnEscape" | "closeOnFocusOut" | "closeOnClickAway" | "disableScrollLock">;
|
|
5
|
+
type PopoverMerged = MergeLibDefaults<PopoverOwnProps, PopoverLibDefaults>;
|
|
6
|
+
export type PopoverOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* Whether the `title` slot is provided (labels the dialog).
|
|
9
|
+
*/
|
|
10
|
+
hasTitleSlot?: () => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Called when the user dismisses the popover.
|
|
13
|
+
* Sugar for `onShowChange(false)`.
|
|
14
|
+
*/
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Called when `show` should change (controlled state).
|
|
18
|
+
*/
|
|
19
|
+
onShowChange?: (show: boolean) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the popover is visible (`defineModel()` / `v-model`).
|
|
22
|
+
*
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
show?: Ref<boolean>;
|
|
26
|
+
};
|
|
27
|
+
export declare function usePopover(props: PopoverOwnProps, libDefaults: PopoverLibDefaults, options?: PopoverOptions): {
|
|
28
|
+
close: () => void;
|
|
29
|
+
merged: import('vue').ComputedRef<PopoverMerged>;
|
|
30
|
+
hasTitle: import('vue').ComputedRef<boolean>;
|
|
31
|
+
rootBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, object>>;
|
|
32
|
+
popoverId: string;
|
|
33
|
+
titleBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<{
|
|
34
|
+
id: string;
|
|
35
|
+
class: string;
|
|
36
|
+
}, "class", import('vue').HTMLAttributes | undefined, {}>>;
|
|
37
|
+
arrowBind: import('vue').ComputedRef<({
|
|
38
|
+
"aria-hidden": boolean;
|
|
39
|
+
class: string;
|
|
40
|
+
} & object & Record<"class", string>) | null>;
|
|
41
|
+
isPortaled: import('vue').ComputedRef<boolean>;
|
|
42
|
+
triggerBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<{
|
|
43
|
+
tabindex: number;
|
|
44
|
+
role: string;
|
|
45
|
+
onKeydown: (event: KeyboardEvent) => void;
|
|
46
|
+
"aria-expanded": boolean;
|
|
47
|
+
onClickCapture: () => void;
|
|
48
|
+
"aria-haspopup": "menu" | "dialog";
|
|
49
|
+
"aria-controls": string | undefined;
|
|
50
|
+
class: string;
|
|
51
|
+
}, "class", import('vue').HTMLAttributes | undefined, {}>>;
|
|
52
|
+
contentBind: import('vue').ComputedRef<import('@bridge-ui/core/Utils').MergePartBind<{
|
|
53
|
+
tabindex: number;
|
|
54
|
+
id: string;
|
|
55
|
+
role: string;
|
|
56
|
+
"aria-labelledby": string | undefined;
|
|
57
|
+
style: {
|
|
58
|
+
zIndex: number;
|
|
59
|
+
};
|
|
60
|
+
"aria-hidden": boolean | undefined;
|
|
61
|
+
class: string;
|
|
62
|
+
}, "class", import('vue').HTMLAttributes | undefined, {}>>;
|
|
63
|
+
mounted: Ref<boolean, boolean>;
|
|
64
|
+
setArrowRef: (element: null | Element | import('vue').ComponentPublicInstance) => void;
|
|
65
|
+
setTriggerRef: (element: null | Element | import('vue').ComponentPublicInstance) => void;
|
|
66
|
+
setContentRef: (element: null | Element | import('vue').ComponentPublicInstance) => void;
|
|
67
|
+
};
|
|
68
|
+
export {};
|
|
@@ -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
|
+
};
|