@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,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>;
|
|
@@ -4,38 +4,38 @@ import { computed as i, onScopeDispose as a, provide as o, ref as s, useAttrs as
|
|
|
4
4
|
import { get as d, isEqual as f } from "es-toolkit/compat";
|
|
5
5
|
import { getResizableCursor as p, getResizableHandleAria as m, getResizableItemIndexes as h, getResizableLayoutFromKey as g, getResizablePointerDelta as _, isResizablePanelCollapsed as v, resizeResizableLayout as y, resizeResizablePanel as b, resolveResizableLayout as x, resolveResizablePanelConstraints as S, sortResizableItemsByDocumentOrder as ee } from "@bridge-ui/core/Domain";
|
|
6
6
|
import { resizableOrientationProps as te } from "@bridge-ui/core/Tokens";
|
|
7
|
-
import { cn as ne, mergeBridgeUILayeredClasses as C, splitComponentProps as
|
|
7
|
+
import { cn as ne, mergeBridgeUILayeredClasses as C, splitComponentProps as re } from "@bridge-ui/core/Utils";
|
|
8
8
|
// src/Components/Resizable/composables/useResizable.ts
|
|
9
|
-
var
|
|
9
|
+
var ie = [
|
|
10
10
|
"classes",
|
|
11
11
|
"disabled",
|
|
12
12
|
"orientation",
|
|
13
13
|
"keyboardStep"
|
|
14
14
|
];
|
|
15
|
-
function
|
|
15
|
+
function w(e) {
|
|
16
16
|
return e ? getComputedStyle(e).direction === "rtl" : !1;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
let O =
|
|
18
|
+
function T(T, E, D) {
|
|
19
|
+
let O = l(), k = c(), A = `bridge-resizable${O}`, j = s([]), M = s(null), N = s({}), P = s(null), F = {}, I = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Map(), R = null, z = i(() => re({
|
|
20
20
|
props: {
|
|
21
|
-
...
|
|
22
|
-
...
|
|
21
|
+
...k,
|
|
22
|
+
...T
|
|
23
23
|
},
|
|
24
|
-
bridgeKeys:
|
|
25
|
-
})), { merged:
|
|
26
|
-
libDefaults:
|
|
24
|
+
bridgeKeys: ie
|
|
25
|
+
})), { merged: B, entry: V } = t({
|
|
26
|
+
libDefaults: E,
|
|
27
27
|
componentName: "Resizable",
|
|
28
|
-
props: () =>
|
|
29
|
-
}),
|
|
30
|
-
entry:
|
|
31
|
-
props: () =>
|
|
32
|
-
}),
|
|
33
|
-
function
|
|
34
|
-
let e = [...Array.from(
|
|
28
|
+
props: () => z.value.componentProps
|
|
29
|
+
}), H = n({
|
|
30
|
+
entry: V,
|
|
31
|
+
props: () => z.value.componentProps
|
|
32
|
+
}), U = i(() => C(te, V.value?.tokens?.orientation)), W = i(() => B.value.orientation === "vertical" ? "vertical" : "horizontal"), G = i(() => d(U.value, W.value)), K = i(() => h(j.value)), q = i(() => K.value.panelIds);
|
|
33
|
+
function J() {
|
|
34
|
+
let e = [...Array.from(I, ([e, t]) => ({
|
|
35
35
|
id: e,
|
|
36
36
|
kind: "panel",
|
|
37
37
|
element: t().element
|
|
38
|
-
})), ...Array.from(
|
|
38
|
+
})), ...Array.from(L, ([e, t]) => ({
|
|
39
39
|
id: e,
|
|
40
40
|
kind: "handle",
|
|
41
41
|
element: t().element
|
|
@@ -45,49 +45,49 @@ function D(D, re, ie) {
|
|
|
45
45
|
}));
|
|
46
46
|
f(j.value, t) || (j.value = t);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
50
|
-
|
|
48
|
+
function ae(e, t) {
|
|
49
|
+
return I.set(e, t), J(), () => {
|
|
50
|
+
I.delete(e), J();
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
return
|
|
55
|
-
|
|
53
|
+
function oe(e, t) {
|
|
54
|
+
return L.set(e, t), J(), () => {
|
|
55
|
+
L.delete(e), J();
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
function Y(e) {
|
|
59
|
-
return e.map((e) =>
|
|
59
|
+
return e.map((e) => I.get(e)?.().constraints ?? {});
|
|
60
60
|
}
|
|
61
61
|
function X(e) {
|
|
62
|
-
return e.map((e) =>
|
|
62
|
+
return e.map((e) => N.value[e] ?? 0);
|
|
63
63
|
}
|
|
64
|
-
u(
|
|
64
|
+
u(q, (e) => {
|
|
65
65
|
let t = e.map((e) => {
|
|
66
|
-
let t =
|
|
66
|
+
let t = I.get(e)?.(), n = t?.constraints ?? {};
|
|
67
67
|
return t?.collapsed && n.collapsible ? {
|
|
68
68
|
...n,
|
|
69
69
|
defaultSize: n.collapsedSize ?? 0
|
|
70
70
|
} : n;
|
|
71
|
-
}), n = x(t, e.map((e) =>
|
|
72
|
-
f(
|
|
71
|
+
}), n = x(t, e.map((e) => N.value[e])), r = Object.fromEntries(e.map((e, t) => [e, n[t] ?? 0]));
|
|
72
|
+
f(N.value, r) || (N.value = r);
|
|
73
73
|
});
|
|
74
74
|
function Z(e, t) {
|
|
75
|
-
let n =
|
|
75
|
+
let n = q.value, r = N.value, i = Y(n), a = !1;
|
|
76
76
|
n.forEach((n, o) => {
|
|
77
77
|
let s = r[n], c = e[o] ?? 0, l = t?.[o] ?? s;
|
|
78
|
-
(s === void 0 || Math.abs(s - c) > 1e-6) && (a = !0), l !== void 0 && !v(i[o], l) && v(i[o], c) && (
|
|
79
|
-
}), a && (
|
|
78
|
+
(s === void 0 || Math.abs(s - c) > 1e-6) && (a = !0), l !== void 0 && !v(i[o], l) && v(i[o], c) && (F[n] = l);
|
|
79
|
+
}), a && (N.value = Object.fromEntries(n.map((t, n) => [t, e[n] ?? 0])), D?.("layoutChange", e));
|
|
80
80
|
}
|
|
81
81
|
function Q(e) {
|
|
82
|
-
let t =
|
|
83
|
-
return t === void 0 || t < 0 || t >=
|
|
82
|
+
let t = K.value.handleIndexes[e];
|
|
83
|
+
return t === void 0 || t < 0 || t >= q.value.length - 1 ? null : t;
|
|
84
84
|
}
|
|
85
|
-
function
|
|
86
|
-
let n =
|
|
85
|
+
function $(e, t) {
|
|
86
|
+
let n = M.value, r = Q(e);
|
|
87
87
|
if (!n || r === null) return;
|
|
88
|
-
|
|
89
|
-
let i =
|
|
90
|
-
m.style.userSelect = "none", m.style.cursor = p(a),
|
|
88
|
+
R?.();
|
|
89
|
+
let i = q.value, a = W.value, o = a === "vertical", s = n.getBoundingClientRect(), c = w(n), l = X(i), u = Y(i), d = o ? t.clientY : t.clientX, f = o ? s.height : s.width, m = document.body, h = m.style.cursor, g = m.style.userSelect;
|
|
90
|
+
m.style.userSelect = "none", m.style.cursor = p(a), P.value = e;
|
|
91
91
|
let v = (e) => {
|
|
92
92
|
let t = _({
|
|
93
93
|
rtl: c,
|
|
@@ -103,30 +103,30 @@ function D(D, re, ie) {
|
|
|
103
103
|
panels: u
|
|
104
104
|
}), l);
|
|
105
105
|
}, b = () => {
|
|
106
|
-
window.removeEventListener("pointermove", v), window.removeEventListener("pointerup", b), window.removeEventListener("pointercancel", b), m.style.cursor = h, m.style.userSelect = g,
|
|
106
|
+
window.removeEventListener("pointermove", v), window.removeEventListener("pointerup", b), window.removeEventListener("pointercancel", b), m.style.cursor = h, m.style.userSelect = g, R = null, P.value = null;
|
|
107
107
|
};
|
|
108
|
-
window.addEventListener("pointermove", v), window.addEventListener("pointerup", b), window.addEventListener("pointercancel", b),
|
|
108
|
+
window.addEventListener("pointermove", v), window.addEventListener("pointerup", b), window.addEventListener("pointercancel", b), R = b;
|
|
109
109
|
}
|
|
110
110
|
a(() => {
|
|
111
|
-
|
|
111
|
+
R?.();
|
|
112
112
|
});
|
|
113
|
-
function
|
|
113
|
+
function se(e, t) {
|
|
114
114
|
let n = Q(e);
|
|
115
115
|
if (n === null) return !1;
|
|
116
|
-
let r =
|
|
116
|
+
let r = q.value, i = r[n] ?? "", a = g({
|
|
117
117
|
key: t,
|
|
118
118
|
handleIndex: n,
|
|
119
119
|
layout: X(r),
|
|
120
|
-
rtl:
|
|
120
|
+
rtl: w(M.value),
|
|
121
121
|
panels: Y(r),
|
|
122
|
-
orientation:
|
|
123
|
-
expandedSize:
|
|
124
|
-
step:
|
|
122
|
+
orientation: W.value,
|
|
123
|
+
expandedSize: F[i],
|
|
124
|
+
step: B.value.keyboardStep
|
|
125
125
|
});
|
|
126
126
|
return a ? (Z(a), !0) : !1;
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
let t =
|
|
128
|
+
function ce(e) {
|
|
129
|
+
let t = q.value, n = t.indexOf(e), r = Y(t), i = r[n];
|
|
130
130
|
if (n < 0 || !i?.collapsible) return;
|
|
131
131
|
let a = X(t);
|
|
132
132
|
v(i, a[n]) || Z(b({
|
|
@@ -136,10 +136,10 @@ function D(D, re, ie) {
|
|
|
136
136
|
size: S(i).collapsedSize
|
|
137
137
|
}));
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
let t =
|
|
139
|
+
function le(e) {
|
|
140
|
+
let t = q.value, n = t.indexOf(e), r = Y(t), i = r[n], a = X(t);
|
|
141
141
|
if (n < 0 || !v(i, a[n])) return;
|
|
142
|
-
let { minSize: o } = S(i), s =
|
|
142
|
+
let { minSize: o } = S(i), s = F[e] ?? i?.defaultSize ?? 100 / Math.max(t.length, 1);
|
|
143
143
|
Z(b({
|
|
144
144
|
index: n,
|
|
145
145
|
layout: a,
|
|
@@ -147,48 +147,48 @@ function D(D, re, ie) {
|
|
|
147
147
|
size: Math.max(o, s)
|
|
148
148
|
}));
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function ue(e) {
|
|
151
151
|
let t = Q(e);
|
|
152
152
|
if (t === null) return null;
|
|
153
|
-
let n =
|
|
153
|
+
let n = q.value, r = n[t] ?? "";
|
|
154
154
|
return {
|
|
155
155
|
index: t,
|
|
156
|
-
controls:
|
|
156
|
+
controls: I.get(r)?.().elementId,
|
|
157
157
|
aria: m(X(n), Y(n), t)
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
|
-
let
|
|
161
|
-
startDrag:
|
|
162
|
-
expandPanel:
|
|
163
|
-
id:
|
|
164
|
-
collapsePanel:
|
|
165
|
-
registerPanel:
|
|
166
|
-
resizeFromKey:
|
|
167
|
-
getHandleState:
|
|
168
|
-
registerHandle:
|
|
169
|
-
layout:
|
|
170
|
-
orientation:
|
|
171
|
-
orientationItem:
|
|
172
|
-
draggingHandleId:
|
|
173
|
-
disabled:
|
|
160
|
+
let de = i(() => ({
|
|
161
|
+
startDrag: $,
|
|
162
|
+
expandPanel: le,
|
|
163
|
+
id: A,
|
|
164
|
+
collapsePanel: ce,
|
|
165
|
+
registerPanel: ae,
|
|
166
|
+
resizeFromKey: se,
|
|
167
|
+
getHandleState: ue,
|
|
168
|
+
registerHandle: oe,
|
|
169
|
+
layout: N.value,
|
|
170
|
+
orientation: W.value,
|
|
171
|
+
orientationItem: G.value,
|
|
172
|
+
draggingHandleId: P.value,
|
|
173
|
+
disabled: B.value.disabled === !0
|
|
174
174
|
}));
|
|
175
|
-
o(r,
|
|
176
|
-
let
|
|
177
|
-
id:
|
|
178
|
-
"data-orientation":
|
|
179
|
-
"data-dragging":
|
|
175
|
+
o(r, de);
|
|
176
|
+
let fe = i(() => e({}, z.value.inheritedAttrs, {
|
|
177
|
+
id: A,
|
|
178
|
+
"data-orientation": W.value,
|
|
179
|
+
"data-dragging": P.value ? "" : void 0,
|
|
180
180
|
class: ne({
|
|
181
|
-
[d(
|
|
182
|
-
[d(
|
|
181
|
+
[d(G.value, "root") ?? ""]: !0,
|
|
182
|
+
[d(H.value, "root") ?? ""]: !0
|
|
183
183
|
})
|
|
184
184
|
}));
|
|
185
185
|
return {
|
|
186
|
-
layout:
|
|
187
|
-
rootRef:
|
|
188
|
-
dragging: i(() =>
|
|
189
|
-
panelIds:
|
|
190
|
-
rootBind:
|
|
191
|
-
orientation:
|
|
186
|
+
layout: N,
|
|
187
|
+
rootRef: M,
|
|
188
|
+
dragging: i(() => P.value !== null),
|
|
189
|
+
panelIds: q,
|
|
190
|
+
rootBind: fe,
|
|
191
|
+
orientation: W
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
|
-
export {
|
|
194
|
+
export { T as useResizable };
|