@zag-js/popover 0.0.0-dev-20230221113221 → 0.0.0-dev-20230222120620
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-4IGGT6KB.mjs +39 -0
- package/dist/{chunk-JDSPKDIN.mjs → chunk-5BYTQ7U3.mjs} +2 -6
- package/dist/{chunk-FRFRU5PG.mjs → chunk-JT2RXXW4.mjs} +5 -72
- package/dist/index.js +30 -210
- package/dist/index.mjs +3 -3
- package/dist/popover.connect.js +28 -142
- package/dist/popover.connect.mjs +2 -2
- package/dist/popover.dom.d.ts +2 -2
- package/dist/popover.dom.js +10 -120
- package/dist/popover.dom.mjs +1 -1
- package/dist/popover.machine.js +27 -205
- package/dist/popover.machine.mjs +2 -2
- package/package.json +10 -8
- package/dist/chunk-Z2WON7A5.mjs +0 -154
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/popover.dom.ts
|
|
2
|
+
import { createScope } from "@zag-js/dom-query";
|
|
3
|
+
import { getFirstTabbable, getFocusables, getLastTabbable, getTabbables } from "@zag-js/tabbable";
|
|
4
|
+
import { runIfFn } from "@zag-js/utils";
|
|
5
|
+
var dom = createScope({
|
|
6
|
+
getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
|
|
7
|
+
getAnchorId: (ctx) => ctx.ids?.anchor ?? `popover:${ctx.id}:anchor`,
|
|
8
|
+
getTriggerId: (ctx) => ctx.ids?.trigger ?? `popover:${ctx.id}:trigger`,
|
|
9
|
+
getContentId: (ctx) => ctx.ids?.content ?? `popover:${ctx.id}:content`,
|
|
10
|
+
getPositionerId: (ctx) => `popover:${ctx.id}:popper`,
|
|
11
|
+
getArrowId: (ctx) => `popover:${ctx.id}:arrow`,
|
|
12
|
+
getTitleId: (ctx) => ctx.ids?.title ?? `popover:${ctx.id}:title`,
|
|
13
|
+
getDescriptionId: (ctx) => ctx.ids?.description ?? `popover:${ctx.id}:desc`,
|
|
14
|
+
getCloseTriggerId: (ctx) => ctx.ids?.closeTrigger ?? `popover:${ctx.id}:close`,
|
|
15
|
+
getAnchorEl: (ctx) => dom.getById(ctx, dom.getAnchorId(ctx)),
|
|
16
|
+
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
|
17
|
+
getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
|
|
18
|
+
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
|
|
19
|
+
getTitleEl: (ctx) => dom.getById(ctx, dom.getTitleId(ctx)),
|
|
20
|
+
getDescriptionEl: (ctx) => dom.getById(ctx, dom.getDescriptionId(ctx)),
|
|
21
|
+
getFocusableEls: (ctx) => getFocusables(dom.getContentEl(ctx)),
|
|
22
|
+
getFirstFocusableEl: (ctx) => dom.getFocusableEls(ctx)[0],
|
|
23
|
+
getDocTabbableEls: (ctx) => getTabbables(dom.getDoc(ctx).body),
|
|
24
|
+
getTabbableEls: (ctx) => getTabbables(dom.getContentEl(ctx), "if-empty"),
|
|
25
|
+
getFirstTabbableEl: (ctx) => getFirstTabbable(dom.getContentEl(ctx), "if-empty"),
|
|
26
|
+
getLastTabbableEl: (ctx) => getLastTabbable(dom.getContentEl(ctx), "if-empty"),
|
|
27
|
+
getInitialFocusEl: (ctx) => {
|
|
28
|
+
let el = runIfFn(ctx.initialFocusEl);
|
|
29
|
+
if (!el && ctx.autoFocus)
|
|
30
|
+
el = dom.getFirstFocusableEl(ctx);
|
|
31
|
+
if (!el)
|
|
32
|
+
el = dom.getContentEl(ctx);
|
|
33
|
+
return el;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
dom
|
|
39
|
+
};
|
|
@@ -3,14 +3,10 @@ import {
|
|
|
3
3
|
} from "./chunk-KTOPDXGV.mjs";
|
|
4
4
|
import {
|
|
5
5
|
dom
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
|
|
8
|
-
// ../../utilities/dom/src/attrs.ts
|
|
9
|
-
var dataAttr = (guard) => {
|
|
10
|
-
return guard ? "" : void 0;
|
|
11
|
-
};
|
|
6
|
+
} from "./chunk-4IGGT6KB.mjs";
|
|
12
7
|
|
|
13
8
|
// src/popover.connect.ts
|
|
9
|
+
import { dataAttr } from "@zag-js/dom-query";
|
|
14
10
|
import { getPlacementStyles } from "@zag-js/popper";
|
|
15
11
|
function connect(state, send, normalize) {
|
|
16
12
|
const isOpen = state.matches("open");
|
|
@@ -1,83 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
runIfFn
|
|
5
|
-
} from "./chunk-Z2WON7A5.mjs";
|
|
2
|
+
dom
|
|
3
|
+
} from "./chunk-4IGGT6KB.mjs";
|
|
6
4
|
|
|
7
5
|
// src/popover.machine.ts
|
|
8
6
|
import { ariaHidden } from "@zag-js/aria-hidden";
|
|
9
7
|
import { createMachine, guards } from "@zag-js/core";
|
|
10
8
|
import { trackDismissableElement } from "@zag-js/dismissable";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function nextIndex(v, idx, opts = {}) {
|
|
14
|
-
const { step = 1, loop = true } = opts;
|
|
15
|
-
const next2 = idx + step;
|
|
16
|
-
const len = v.length;
|
|
17
|
-
const last = len - 1;
|
|
18
|
-
if (idx === -1)
|
|
19
|
-
return step > 0 ? 0 : last;
|
|
20
|
-
if (next2 < 0)
|
|
21
|
-
return loop ? last : 0;
|
|
22
|
-
if (next2 >= len)
|
|
23
|
-
return loop ? 0 : idx > len ? len : idx;
|
|
24
|
-
return next2;
|
|
25
|
-
}
|
|
26
|
-
function next(v, idx, opts = {}) {
|
|
27
|
-
return v[nextIndex(v, idx, opts)];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// ../../utilities/core/src/guard.ts
|
|
31
|
-
var isArray = (v) => Array.isArray(v);
|
|
32
|
-
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
33
|
-
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
34
|
-
|
|
35
|
-
// ../../utilities/core/src/object.ts
|
|
36
|
-
function compact(obj) {
|
|
37
|
-
if (obj === void 0)
|
|
38
|
-
return obj;
|
|
39
|
-
return Object.fromEntries(
|
|
40
|
-
Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// ../../utilities/dom/src/event.ts
|
|
45
|
-
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
46
|
-
|
|
47
|
-
// ../../utilities/dom/src/listener.ts
|
|
48
|
-
var isRef = (v) => hasProp(v, "current");
|
|
49
|
-
function addDomEvent(target, eventName, handler, options) {
|
|
50
|
-
const node = isRef(target) ? target.current : runIfFn(target);
|
|
51
|
-
node?.addEventListener(eventName, handler, options);
|
|
52
|
-
return () => {
|
|
53
|
-
node?.removeEventListener(eventName, handler, options);
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ../../utilities/dom/src/next-tick.ts
|
|
58
|
-
function nextTick(fn) {
|
|
59
|
-
const set = /* @__PURE__ */ new Set();
|
|
60
|
-
function raf2(fn2) {
|
|
61
|
-
const id = globalThis.requestAnimationFrame(fn2);
|
|
62
|
-
set.add(() => globalThis.cancelAnimationFrame(id));
|
|
63
|
-
}
|
|
64
|
-
raf2(() => raf2(fn));
|
|
65
|
-
return function cleanup() {
|
|
66
|
-
set.forEach(function(fn2) {
|
|
67
|
-
fn2();
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function raf(fn) {
|
|
72
|
-
const id = globalThis.requestAnimationFrame(fn);
|
|
73
|
-
return function cleanup() {
|
|
74
|
-
globalThis.cancelAnimationFrame(id);
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// src/popover.machine.ts
|
|
9
|
+
import { contains, nextTick, raf } from "@zag-js/dom-query";
|
|
10
|
+
import { addDomEvent, isModifiedEvent } from "@zag-js/dom-event";
|
|
79
11
|
import { getPlacement } from "@zag-js/popper";
|
|
80
12
|
import { preventBodyScroll } from "@zag-js/remove-scroll";
|
|
13
|
+
import { compact, next, runIfFn } from "@zag-js/utils";
|
|
81
14
|
import { createFocusTrap } from "focus-trap";
|
|
82
15
|
var { and, or, not } = guards;
|
|
83
16
|
function machine(userContext) {
|
package/dist/index.js
CHANGED
|
@@ -41,198 +41,15 @@ var anatomy = (0, import_anatomy.createAnatomy)("popover").parts(
|
|
|
41
41
|
);
|
|
42
42
|
var parts = anatomy.build();
|
|
43
43
|
|
|
44
|
-
// ../../utilities/dom/src/attrs.ts
|
|
45
|
-
var dataAttr = (guard) => {
|
|
46
|
-
return guard ? "" : void 0;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// ../../utilities/core/src/array.ts
|
|
50
|
-
function nextIndex(v, idx, opts = {}) {
|
|
51
|
-
const { step = 1, loop = true } = opts;
|
|
52
|
-
const next2 = idx + step;
|
|
53
|
-
const len = v.length;
|
|
54
|
-
const last = len - 1;
|
|
55
|
-
if (idx === -1)
|
|
56
|
-
return step > 0 ? 0 : last;
|
|
57
|
-
if (next2 < 0)
|
|
58
|
-
return loop ? last : 0;
|
|
59
|
-
if (next2 >= len)
|
|
60
|
-
return loop ? 0 : idx > len ? len : idx;
|
|
61
|
-
return next2;
|
|
62
|
-
}
|
|
63
|
-
function next(v, idx, opts = {}) {
|
|
64
|
-
return v[nextIndex(v, idx, opts)];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// ../../utilities/core/src/functions.ts
|
|
68
|
-
var runIfFn = (v, ...a) => {
|
|
69
|
-
const res = typeof v === "function" ? v(...a) : v;
|
|
70
|
-
return res ?? void 0;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// ../../utilities/core/src/guard.ts
|
|
74
|
-
var isArray = (v) => Array.isArray(v);
|
|
75
|
-
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
76
|
-
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
77
|
-
|
|
78
|
-
// ../../utilities/core/src/object.ts
|
|
79
|
-
function compact(obj) {
|
|
80
|
-
if (obj === void 0)
|
|
81
|
-
return obj;
|
|
82
|
-
return Object.fromEntries(
|
|
83
|
-
Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// ../../utilities/dom/src/query.ts
|
|
88
|
-
function isDocument(el) {
|
|
89
|
-
return el.nodeType === Node.DOCUMENT_NODE;
|
|
90
|
-
}
|
|
91
|
-
function isWindow(value) {
|
|
92
|
-
return value?.toString() === "[object Window]";
|
|
93
|
-
}
|
|
94
|
-
function isFrame(element) {
|
|
95
|
-
return element.localName === "iframe";
|
|
96
|
-
}
|
|
97
|
-
function getDocument(el) {
|
|
98
|
-
if (isWindow(el))
|
|
99
|
-
return el.document;
|
|
100
|
-
if (isDocument(el))
|
|
101
|
-
return el;
|
|
102
|
-
return el?.ownerDocument ?? document;
|
|
103
|
-
}
|
|
104
|
-
function defineDomHelpers(helpers) {
|
|
105
|
-
const dom2 = {
|
|
106
|
-
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
107
|
-
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
108
|
-
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
109
|
-
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
110
|
-
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
|
|
111
|
-
queryById: (ctx, id) => {
|
|
112
|
-
const el = dom2.getById(ctx, id);
|
|
113
|
-
if (!el)
|
|
114
|
-
throw new Error(`Element with id "${id}" not found.`);
|
|
115
|
-
return el;
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
return {
|
|
119
|
-
...dom2,
|
|
120
|
-
...helpers
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function contains(parent, child) {
|
|
124
|
-
if (!parent)
|
|
125
|
-
return false;
|
|
126
|
-
return parent === child || isHTMLElement(parent) && isHTMLElement(child) && parent.contains(child);
|
|
127
|
-
}
|
|
128
|
-
function isHTMLElement(v) {
|
|
129
|
-
return typeof v === "object" && v?.nodeType === Node.ELEMENT_NODE && typeof v?.nodeName === "string";
|
|
130
|
-
}
|
|
131
|
-
function isVisible(el) {
|
|
132
|
-
if (!isHTMLElement(el))
|
|
133
|
-
return false;
|
|
134
|
-
return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// ../../utilities/dom/src/event.ts
|
|
138
|
-
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
139
|
-
|
|
140
|
-
// ../../utilities/dom/src/focusable.ts
|
|
141
|
-
function hasNegativeTabIndex(element) {
|
|
142
|
-
const tabIndex = parseInt(element.getAttribute("tabindex") || "0", 10);
|
|
143
|
-
return tabIndex < 0;
|
|
144
|
-
}
|
|
145
|
-
var focusableSelector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type";
|
|
146
|
-
var getFocusables = (container, includeContainer = false) => {
|
|
147
|
-
if (!container)
|
|
148
|
-
return [];
|
|
149
|
-
const elements = Array.from(container.querySelectorAll(focusableSelector));
|
|
150
|
-
const include = includeContainer == true || includeContainer == "if-empty" && elements.length === 0;
|
|
151
|
-
if (include && isHTMLElement(container) && isFocusable(container)) {
|
|
152
|
-
elements.unshift(container);
|
|
153
|
-
}
|
|
154
|
-
const focusableElements = elements.filter(isFocusable);
|
|
155
|
-
focusableElements.forEach((element, i) => {
|
|
156
|
-
if (isFrame(element) && element.contentDocument) {
|
|
157
|
-
const frameBody = element.contentDocument.body;
|
|
158
|
-
focusableElements.splice(i, 1, ...getFocusables(frameBody));
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
return focusableElements;
|
|
162
|
-
};
|
|
163
|
-
function isFocusable(element) {
|
|
164
|
-
if (!element)
|
|
165
|
-
return false;
|
|
166
|
-
return element.matches(focusableSelector) && isVisible(element);
|
|
167
|
-
}
|
|
168
|
-
function getTabbables(container, includeContainer) {
|
|
169
|
-
if (!container)
|
|
170
|
-
return [];
|
|
171
|
-
const elements = Array.from(container.querySelectorAll(focusableSelector));
|
|
172
|
-
const tabbableElements = elements.filter(isTabbable);
|
|
173
|
-
if (includeContainer && isTabbable(container)) {
|
|
174
|
-
tabbableElements.unshift(container);
|
|
175
|
-
}
|
|
176
|
-
tabbableElements.forEach((element, i) => {
|
|
177
|
-
if (isFrame(element) && element.contentDocument) {
|
|
178
|
-
const frameBody = element.contentDocument.body;
|
|
179
|
-
const allFrameTabbable = getTabbables(frameBody);
|
|
180
|
-
tabbableElements.splice(i, 1, ...allFrameTabbable);
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
if (!tabbableElements.length && includeContainer) {
|
|
184
|
-
return elements;
|
|
185
|
-
}
|
|
186
|
-
return tabbableElements;
|
|
187
|
-
}
|
|
188
|
-
function isTabbable(el) {
|
|
189
|
-
return isFocusable(el) && !hasNegativeTabIndex(el);
|
|
190
|
-
}
|
|
191
|
-
function getFirstTabbable(container, includeContainer) {
|
|
192
|
-
const [first] = getTabbables(container, includeContainer);
|
|
193
|
-
return first || null;
|
|
194
|
-
}
|
|
195
|
-
function getLastTabbable(container, includeContainer) {
|
|
196
|
-
const elements = getTabbables(container, includeContainer);
|
|
197
|
-
return elements[elements.length - 1] || null;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// ../../utilities/dom/src/listener.ts
|
|
201
|
-
var isRef = (v) => hasProp(v, "current");
|
|
202
|
-
function addDomEvent(target, eventName, handler, options) {
|
|
203
|
-
const node = isRef(target) ? target.current : runIfFn(target);
|
|
204
|
-
node?.addEventListener(eventName, handler, options);
|
|
205
|
-
return () => {
|
|
206
|
-
node?.removeEventListener(eventName, handler, options);
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// ../../utilities/dom/src/next-tick.ts
|
|
211
|
-
function nextTick(fn) {
|
|
212
|
-
const set = /* @__PURE__ */ new Set();
|
|
213
|
-
function raf2(fn2) {
|
|
214
|
-
const id = globalThis.requestAnimationFrame(fn2);
|
|
215
|
-
set.add(() => globalThis.cancelAnimationFrame(id));
|
|
216
|
-
}
|
|
217
|
-
raf2(() => raf2(fn));
|
|
218
|
-
return function cleanup() {
|
|
219
|
-
set.forEach(function(fn2) {
|
|
220
|
-
fn2();
|
|
221
|
-
});
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
function raf(fn) {
|
|
225
|
-
const id = globalThis.requestAnimationFrame(fn);
|
|
226
|
-
return function cleanup() {
|
|
227
|
-
globalThis.cancelAnimationFrame(id);
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
|
|
231
44
|
// src/popover.connect.ts
|
|
45
|
+
var import_dom_query2 = require("@zag-js/dom-query");
|
|
232
46
|
var import_popper = require("@zag-js/popper");
|
|
233
47
|
|
|
234
48
|
// src/popover.dom.ts
|
|
235
|
-
var
|
|
49
|
+
var import_dom_query = require("@zag-js/dom-query");
|
|
50
|
+
var import_tabbable = require("@zag-js/tabbable");
|
|
51
|
+
var import_utils = require("@zag-js/utils");
|
|
52
|
+
var dom = (0, import_dom_query.createScope)({
|
|
236
53
|
getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
|
|
237
54
|
getAnchorId: (ctx) => ctx.ids?.anchor ?? `popover:${ctx.id}:anchor`,
|
|
238
55
|
getTriggerId: (ctx) => ctx.ids?.trigger ?? `popover:${ctx.id}:trigger`,
|
|
@@ -248,14 +65,14 @@ var dom = defineDomHelpers({
|
|
|
248
65
|
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
|
|
249
66
|
getTitleEl: (ctx) => dom.getById(ctx, dom.getTitleId(ctx)),
|
|
250
67
|
getDescriptionEl: (ctx) => dom.getById(ctx, dom.getDescriptionId(ctx)),
|
|
251
|
-
getFocusableEls: (ctx) => getFocusables(dom.getContentEl(ctx)),
|
|
68
|
+
getFocusableEls: (ctx) => (0, import_tabbable.getFocusables)(dom.getContentEl(ctx)),
|
|
252
69
|
getFirstFocusableEl: (ctx) => dom.getFocusableEls(ctx)[0],
|
|
253
|
-
getDocTabbableEls: (ctx) => getTabbables(dom.getDoc(ctx).body),
|
|
254
|
-
getTabbableEls: (ctx) => getTabbables(dom.getContentEl(ctx), "if-empty"),
|
|
255
|
-
getFirstTabbableEl: (ctx) => getFirstTabbable(dom.getContentEl(ctx), "if-empty"),
|
|
256
|
-
getLastTabbableEl: (ctx) => getLastTabbable(dom.getContentEl(ctx), "if-empty"),
|
|
70
|
+
getDocTabbableEls: (ctx) => (0, import_tabbable.getTabbables)(dom.getDoc(ctx).body),
|
|
71
|
+
getTabbableEls: (ctx) => (0, import_tabbable.getTabbables)(dom.getContentEl(ctx), "if-empty"),
|
|
72
|
+
getFirstTabbableEl: (ctx) => (0, import_tabbable.getFirstTabbable)(dom.getContentEl(ctx), "if-empty"),
|
|
73
|
+
getLastTabbableEl: (ctx) => (0, import_tabbable.getLastTabbable)(dom.getContentEl(ctx), "if-empty"),
|
|
257
74
|
getInitialFocusEl: (ctx) => {
|
|
258
|
-
let el = runIfFn(ctx.initialFocusEl);
|
|
75
|
+
let el = (0, import_utils.runIfFn)(ctx.initialFocusEl);
|
|
259
76
|
if (!el && ctx.autoFocus)
|
|
260
77
|
el = dom.getFirstFocusableEl(ctx);
|
|
261
78
|
if (!el)
|
|
@@ -303,7 +120,7 @@ function connect(state, send, normalize) {
|
|
|
303
120
|
id: dom.getTriggerId(state.context),
|
|
304
121
|
"aria-haspopup": "dialog",
|
|
305
122
|
"aria-expanded": isOpen,
|
|
306
|
-
"data-expanded": dataAttr(isOpen),
|
|
123
|
+
"data-expanded": (0, import_dom_query2.dataAttr)(isOpen),
|
|
307
124
|
"aria-controls": dom.getContentId(state.context),
|
|
308
125
|
onClick() {
|
|
309
126
|
send("TOGGLE");
|
|
@@ -323,7 +140,7 @@ function connect(state, send, normalize) {
|
|
|
323
140
|
tabIndex: -1,
|
|
324
141
|
role: "dialog",
|
|
325
142
|
hidden: !isOpen,
|
|
326
|
-
"data-expanded": dataAttr(isOpen),
|
|
143
|
+
"data-expanded": (0, import_dom_query2.dataAttr)(isOpen),
|
|
327
144
|
"aria-labelledby": rendered.title ? dom.getTitleId(state.context) : void 0,
|
|
328
145
|
"aria-describedby": rendered.description ? dom.getDescriptionId(state.context) : void 0,
|
|
329
146
|
"data-placement": currentPlacement
|
|
@@ -352,12 +169,15 @@ function connect(state, send, normalize) {
|
|
|
352
169
|
var import_aria_hidden = require("@zag-js/aria-hidden");
|
|
353
170
|
var import_core = require("@zag-js/core");
|
|
354
171
|
var import_dismissable = require("@zag-js/dismissable");
|
|
172
|
+
var import_dom_query3 = require("@zag-js/dom-query");
|
|
173
|
+
var import_dom_event = require("@zag-js/dom-event");
|
|
355
174
|
var import_popper2 = require("@zag-js/popper");
|
|
356
175
|
var import_remove_scroll = require("@zag-js/remove-scroll");
|
|
176
|
+
var import_utils2 = require("@zag-js/utils");
|
|
357
177
|
var import_focus_trap = require("focus-trap");
|
|
358
178
|
var { and, or, not } = import_core.guards;
|
|
359
179
|
function machine(userContext) {
|
|
360
|
-
const ctx = compact(userContext);
|
|
180
|
+
const ctx = (0, import_utils2.compact)(userContext);
|
|
361
181
|
return (0, import_core.createMachine)(
|
|
362
182
|
{
|
|
363
183
|
id: "popover",
|
|
@@ -486,11 +306,11 @@ function machine(userContext) {
|
|
|
486
306
|
trackTabKeyDown(ctx2, _evt, { send }) {
|
|
487
307
|
if (ctx2.modal)
|
|
488
308
|
return;
|
|
489
|
-
return addDomEvent(
|
|
309
|
+
return (0, import_dom_event.addDomEvent)(
|
|
490
310
|
dom.getWin(ctx2),
|
|
491
311
|
"keydown",
|
|
492
312
|
(event) => {
|
|
493
|
-
const isTabKey = event.key === "Tab" && !isModifiedEvent(event);
|
|
313
|
+
const isTabKey = event.key === "Tab" && !(0, import_dom_event.isModifiedEvent)(event);
|
|
494
314
|
if (!isTabKey)
|
|
495
315
|
return;
|
|
496
316
|
send({
|
|
@@ -505,7 +325,7 @@ function machine(userContext) {
|
|
|
505
325
|
if (!ctx2.modal)
|
|
506
326
|
return;
|
|
507
327
|
let cleanup;
|
|
508
|
-
nextTick(() => {
|
|
328
|
+
(0, import_dom_query3.nextTick)(() => {
|
|
509
329
|
cleanup = (0, import_aria_hidden.ariaHidden)([dom.getContentEl(ctx2), dom.getTriggerEl(ctx2)]);
|
|
510
330
|
});
|
|
511
331
|
return () => cleanup?.();
|
|
@@ -519,7 +339,7 @@ function machine(userContext) {
|
|
|
519
339
|
if (!ctx2.modal)
|
|
520
340
|
return;
|
|
521
341
|
let trap;
|
|
522
|
-
nextTick(() => {
|
|
342
|
+
(0, import_dom_query3.nextTick)(() => {
|
|
523
343
|
const el = dom.getContentEl(ctx2);
|
|
524
344
|
if (!el)
|
|
525
345
|
return;
|
|
@@ -529,7 +349,7 @@ function machine(userContext) {
|
|
|
529
349
|
returnFocusOnDeactivate: true,
|
|
530
350
|
document: dom.getDoc(ctx2),
|
|
531
351
|
fallbackFocus: el,
|
|
532
|
-
initialFocus: runIfFn(ctx2.initialFocusEl)
|
|
352
|
+
initialFocus: (0, import_utils2.runIfFn)(ctx2.initialFocusEl)
|
|
533
353
|
});
|
|
534
354
|
try {
|
|
535
355
|
trap.activate();
|
|
@@ -541,7 +361,7 @@ function machine(userContext) {
|
|
|
541
361
|
},
|
|
542
362
|
guards: {
|
|
543
363
|
portalled: (ctx2) => ctx2.currentPortalled,
|
|
544
|
-
isRelatedTargetWithinContent: (ctx2, evt) => contains(dom.getContentEl(ctx2), evt.target),
|
|
364
|
+
isRelatedTargetWithinContent: (ctx2, evt) => (0, import_dom_query3.contains)(dom.getContentEl(ctx2), evt.target),
|
|
545
365
|
closeOnInteractOutside: (ctx2) => !!ctx2.closeOnInteractOutside,
|
|
546
366
|
isContentFocused: (ctx2) => dom.getContentEl(ctx2) === dom.getActiveEl(ctx2),
|
|
547
367
|
isTriggerFocused: (ctx2) => dom.getTriggerEl(ctx2) === dom.getActiveEl(ctx2),
|
|
@@ -550,7 +370,7 @@ function machine(userContext) {
|
|
|
550
370
|
},
|
|
551
371
|
actions: {
|
|
552
372
|
checkRenderedElements(ctx2) {
|
|
553
|
-
raf(() => {
|
|
373
|
+
(0, import_dom_query3.raf)(() => {
|
|
554
374
|
Object.assign(ctx2.renderedElements, {
|
|
555
375
|
title: !!dom.getTitleEl(ctx2),
|
|
556
376
|
description: !!dom.getDescriptionEl(ctx2),
|
|
@@ -559,14 +379,14 @@ function machine(userContext) {
|
|
|
559
379
|
});
|
|
560
380
|
},
|
|
561
381
|
setInitialFocus(ctx2) {
|
|
562
|
-
raf(() => {
|
|
382
|
+
(0, import_dom_query3.raf)(() => {
|
|
563
383
|
dom.getInitialFocusEl(ctx2)?.focus();
|
|
564
384
|
});
|
|
565
385
|
},
|
|
566
386
|
focusTriggerIfNeeded(ctx2) {
|
|
567
387
|
if (!ctx2.focusTriggerOnClose)
|
|
568
388
|
return;
|
|
569
|
-
raf(() => dom.getTriggerEl(ctx2)?.focus());
|
|
389
|
+
(0, import_dom_query3.raf)(() => dom.getTriggerEl(ctx2)?.focus());
|
|
570
390
|
},
|
|
571
391
|
focusFirstTabbableElement(ctx2, evt) {
|
|
572
392
|
evt.preventDefault();
|
|
@@ -591,15 +411,15 @@ function machine(userContext) {
|
|
|
591
411
|
if (lastTabbable !== dom.getActiveEl(ctx2))
|
|
592
412
|
return;
|
|
593
413
|
let tabbables = dom.getDocTabbableEls(ctx2);
|
|
594
|
-
let elementAfterTrigger = next(tabbables, tabbables.indexOf(button), { loop: false });
|
|
414
|
+
let elementAfterTrigger = (0, import_utils2.next)(tabbables, tabbables.indexOf(button), { loop: false });
|
|
595
415
|
if (elementAfterTrigger === content) {
|
|
596
|
-
tabbables = tabbables.filter((el) => !contains(content, el));
|
|
597
|
-
elementAfterTrigger = next(tabbables, tabbables.indexOf(button), { loop: false });
|
|
416
|
+
tabbables = tabbables.filter((el) => !(0, import_dom_query3.contains)(content, el));
|
|
417
|
+
elementAfterTrigger = (0, import_utils2.next)(tabbables, tabbables.indexOf(button), { loop: false });
|
|
598
418
|
}
|
|
599
419
|
if (!elementAfterTrigger || elementAfterTrigger === button)
|
|
600
420
|
return;
|
|
601
421
|
evt.preventDefault();
|
|
602
|
-
raf(() => elementAfterTrigger?.focus());
|
|
422
|
+
(0, import_dom_query3.raf)(() => elementAfterTrigger?.focus());
|
|
603
423
|
}
|
|
604
424
|
}
|
|
605
425
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
connect
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5BYTQ7U3.mjs";
|
|
4
4
|
import {
|
|
5
5
|
anatomy
|
|
6
6
|
} from "./chunk-KTOPDXGV.mjs";
|
|
7
7
|
import {
|
|
8
8
|
machine
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-JT2RXXW4.mjs";
|
|
10
|
+
import "./chunk-4IGGT6KB.mjs";
|
|
11
11
|
export {
|
|
12
12
|
anatomy,
|
|
13
13
|
connect,
|