@zag-js/popover 0.0.0-dev-20230220134212 → 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-JNFEFPEH.mjs → chunk-5BYTQ7U3.mjs} +2 -6
- package/dist/{chunk-NMCDKPIS.mjs → chunk-JT2RXXW4.mjs} +5 -72
- package/dist/index.js +30 -204
- package/dist/index.mjs +3 -3
- package/dist/popover.connect.js +28 -136
- package/dist/popover.connect.mjs +2 -2
- package/dist/popover.dom.d.ts +4 -1
- package/dist/popover.dom.js +10 -114
- package/dist/popover.dom.mjs +1 -1
- package/dist/popover.machine.js +27 -199
- package/dist/popover.machine.mjs +2 -2
- package/package.json +10 -8
- package/dist/chunk-2EVL5G6H.mjs +0 -148
|
@@ -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-2EVL5G6H.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,192 +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
|
-
};
|
|
112
|
-
return {
|
|
113
|
-
...dom2,
|
|
114
|
-
...helpers
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function contains(parent, child) {
|
|
118
|
-
if (!parent)
|
|
119
|
-
return false;
|
|
120
|
-
return parent === child || isHTMLElement(parent) && isHTMLElement(child) && parent.contains(child);
|
|
121
|
-
}
|
|
122
|
-
function isHTMLElement(v) {
|
|
123
|
-
return typeof v === "object" && v?.nodeType === Node.ELEMENT_NODE && typeof v?.nodeName === "string";
|
|
124
|
-
}
|
|
125
|
-
function isVisible(el) {
|
|
126
|
-
if (!isHTMLElement(el))
|
|
127
|
-
return false;
|
|
128
|
-
return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// ../../utilities/dom/src/event.ts
|
|
132
|
-
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
133
|
-
|
|
134
|
-
// ../../utilities/dom/src/focusable.ts
|
|
135
|
-
function hasNegativeTabIndex(element) {
|
|
136
|
-
const tabIndex = parseInt(element.getAttribute("tabindex") || "0", 10);
|
|
137
|
-
return tabIndex < 0;
|
|
138
|
-
}
|
|
139
|
-
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";
|
|
140
|
-
var getFocusables = (container, includeContainer = false) => {
|
|
141
|
-
if (!container)
|
|
142
|
-
return [];
|
|
143
|
-
const elements = Array.from(container.querySelectorAll(focusableSelector));
|
|
144
|
-
const include = includeContainer == true || includeContainer == "if-empty" && elements.length === 0;
|
|
145
|
-
if (include && isHTMLElement(container) && isFocusable(container)) {
|
|
146
|
-
elements.unshift(container);
|
|
147
|
-
}
|
|
148
|
-
const focusableElements = elements.filter(isFocusable);
|
|
149
|
-
focusableElements.forEach((element, i) => {
|
|
150
|
-
if (isFrame(element) && element.contentDocument) {
|
|
151
|
-
const frameBody = element.contentDocument.body;
|
|
152
|
-
focusableElements.splice(i, 1, ...getFocusables(frameBody));
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
return focusableElements;
|
|
156
|
-
};
|
|
157
|
-
function isFocusable(element) {
|
|
158
|
-
if (!element)
|
|
159
|
-
return false;
|
|
160
|
-
return element.matches(focusableSelector) && isVisible(element);
|
|
161
|
-
}
|
|
162
|
-
function getTabbables(container, includeContainer) {
|
|
163
|
-
if (!container)
|
|
164
|
-
return [];
|
|
165
|
-
const elements = Array.from(container.querySelectorAll(focusableSelector));
|
|
166
|
-
const tabbableElements = elements.filter(isTabbable);
|
|
167
|
-
if (includeContainer && isTabbable(container)) {
|
|
168
|
-
tabbableElements.unshift(container);
|
|
169
|
-
}
|
|
170
|
-
tabbableElements.forEach((element, i) => {
|
|
171
|
-
if (isFrame(element) && element.contentDocument) {
|
|
172
|
-
const frameBody = element.contentDocument.body;
|
|
173
|
-
const allFrameTabbable = getTabbables(frameBody);
|
|
174
|
-
tabbableElements.splice(i, 1, ...allFrameTabbable);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
if (!tabbableElements.length && includeContainer) {
|
|
178
|
-
return elements;
|
|
179
|
-
}
|
|
180
|
-
return tabbableElements;
|
|
181
|
-
}
|
|
182
|
-
function isTabbable(el) {
|
|
183
|
-
return isFocusable(el) && !hasNegativeTabIndex(el);
|
|
184
|
-
}
|
|
185
|
-
function getFirstTabbable(container, includeContainer) {
|
|
186
|
-
const [first] = getTabbables(container, includeContainer);
|
|
187
|
-
return first || null;
|
|
188
|
-
}
|
|
189
|
-
function getLastTabbable(container, includeContainer) {
|
|
190
|
-
const elements = getTabbables(container, includeContainer);
|
|
191
|
-
return elements[elements.length - 1] || null;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// ../../utilities/dom/src/listener.ts
|
|
195
|
-
var isRef = (v) => hasProp(v, "current");
|
|
196
|
-
function addDomEvent(target, eventName, handler, options) {
|
|
197
|
-
const node = isRef(target) ? target.current : runIfFn(target);
|
|
198
|
-
node?.addEventListener(eventName, handler, options);
|
|
199
|
-
return () => {
|
|
200
|
-
node?.removeEventListener(eventName, handler, options);
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// ../../utilities/dom/src/next-tick.ts
|
|
205
|
-
function nextTick(fn) {
|
|
206
|
-
const set = /* @__PURE__ */ new Set();
|
|
207
|
-
function raf2(fn2) {
|
|
208
|
-
const id = globalThis.requestAnimationFrame(fn2);
|
|
209
|
-
set.add(() => globalThis.cancelAnimationFrame(id));
|
|
210
|
-
}
|
|
211
|
-
raf2(() => raf2(fn));
|
|
212
|
-
return function cleanup() {
|
|
213
|
-
set.forEach(function(fn2) {
|
|
214
|
-
fn2();
|
|
215
|
-
});
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
function raf(fn) {
|
|
219
|
-
const id = globalThis.requestAnimationFrame(fn);
|
|
220
|
-
return function cleanup() {
|
|
221
|
-
globalThis.cancelAnimationFrame(id);
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
|
|
225
44
|
// src/popover.connect.ts
|
|
45
|
+
var import_dom_query2 = require("@zag-js/dom-query");
|
|
226
46
|
var import_popper = require("@zag-js/popper");
|
|
227
47
|
|
|
228
48
|
// src/popover.dom.ts
|
|
229
|
-
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)({
|
|
230
53
|
getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
|
|
231
54
|
getAnchorId: (ctx) => ctx.ids?.anchor ?? `popover:${ctx.id}:anchor`,
|
|
232
55
|
getTriggerId: (ctx) => ctx.ids?.trigger ?? `popover:${ctx.id}:trigger`,
|
|
@@ -242,14 +65,14 @@ var dom = defineDomHelpers({
|
|
|
242
65
|
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
|
|
243
66
|
getTitleEl: (ctx) => dom.getById(ctx, dom.getTitleId(ctx)),
|
|
244
67
|
getDescriptionEl: (ctx) => dom.getById(ctx, dom.getDescriptionId(ctx)),
|
|
245
|
-
getFocusableEls: (ctx) => getFocusables(dom.getContentEl(ctx)),
|
|
68
|
+
getFocusableEls: (ctx) => (0, import_tabbable.getFocusables)(dom.getContentEl(ctx)),
|
|
246
69
|
getFirstFocusableEl: (ctx) => dom.getFocusableEls(ctx)[0],
|
|
247
|
-
getDocTabbableEls: (ctx) => getTabbables(dom.getDoc(ctx).body),
|
|
248
|
-
getTabbableEls: (ctx) => getTabbables(dom.getContentEl(ctx), "if-empty"),
|
|
249
|
-
getFirstTabbableEl: (ctx) => getFirstTabbable(dom.getContentEl(ctx), "if-empty"),
|
|
250
|
-
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"),
|
|
251
74
|
getInitialFocusEl: (ctx) => {
|
|
252
|
-
let el = runIfFn(ctx.initialFocusEl);
|
|
75
|
+
let el = (0, import_utils.runIfFn)(ctx.initialFocusEl);
|
|
253
76
|
if (!el && ctx.autoFocus)
|
|
254
77
|
el = dom.getFirstFocusableEl(ctx);
|
|
255
78
|
if (!el)
|
|
@@ -297,7 +120,7 @@ function connect(state, send, normalize) {
|
|
|
297
120
|
id: dom.getTriggerId(state.context),
|
|
298
121
|
"aria-haspopup": "dialog",
|
|
299
122
|
"aria-expanded": isOpen,
|
|
300
|
-
"data-expanded": dataAttr(isOpen),
|
|
123
|
+
"data-expanded": (0, import_dom_query2.dataAttr)(isOpen),
|
|
301
124
|
"aria-controls": dom.getContentId(state.context),
|
|
302
125
|
onClick() {
|
|
303
126
|
send("TOGGLE");
|
|
@@ -317,7 +140,7 @@ function connect(state, send, normalize) {
|
|
|
317
140
|
tabIndex: -1,
|
|
318
141
|
role: "dialog",
|
|
319
142
|
hidden: !isOpen,
|
|
320
|
-
"data-expanded": dataAttr(isOpen),
|
|
143
|
+
"data-expanded": (0, import_dom_query2.dataAttr)(isOpen),
|
|
321
144
|
"aria-labelledby": rendered.title ? dom.getTitleId(state.context) : void 0,
|
|
322
145
|
"aria-describedby": rendered.description ? dom.getDescriptionId(state.context) : void 0,
|
|
323
146
|
"data-placement": currentPlacement
|
|
@@ -346,12 +169,15 @@ function connect(state, send, normalize) {
|
|
|
346
169
|
var import_aria_hidden = require("@zag-js/aria-hidden");
|
|
347
170
|
var import_core = require("@zag-js/core");
|
|
348
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");
|
|
349
174
|
var import_popper2 = require("@zag-js/popper");
|
|
350
175
|
var import_remove_scroll = require("@zag-js/remove-scroll");
|
|
176
|
+
var import_utils2 = require("@zag-js/utils");
|
|
351
177
|
var import_focus_trap = require("focus-trap");
|
|
352
178
|
var { and, or, not } = import_core.guards;
|
|
353
179
|
function machine(userContext) {
|
|
354
|
-
const ctx = compact(userContext);
|
|
180
|
+
const ctx = (0, import_utils2.compact)(userContext);
|
|
355
181
|
return (0, import_core.createMachine)(
|
|
356
182
|
{
|
|
357
183
|
id: "popover",
|
|
@@ -480,11 +306,11 @@ function machine(userContext) {
|
|
|
480
306
|
trackTabKeyDown(ctx2, _evt, { send }) {
|
|
481
307
|
if (ctx2.modal)
|
|
482
308
|
return;
|
|
483
|
-
return addDomEvent(
|
|
309
|
+
return (0, import_dom_event.addDomEvent)(
|
|
484
310
|
dom.getWin(ctx2),
|
|
485
311
|
"keydown",
|
|
486
312
|
(event) => {
|
|
487
|
-
const isTabKey = event.key === "Tab" && !isModifiedEvent(event);
|
|
313
|
+
const isTabKey = event.key === "Tab" && !(0, import_dom_event.isModifiedEvent)(event);
|
|
488
314
|
if (!isTabKey)
|
|
489
315
|
return;
|
|
490
316
|
send({
|
|
@@ -499,7 +325,7 @@ function machine(userContext) {
|
|
|
499
325
|
if (!ctx2.modal)
|
|
500
326
|
return;
|
|
501
327
|
let cleanup;
|
|
502
|
-
nextTick(() => {
|
|
328
|
+
(0, import_dom_query3.nextTick)(() => {
|
|
503
329
|
cleanup = (0, import_aria_hidden.ariaHidden)([dom.getContentEl(ctx2), dom.getTriggerEl(ctx2)]);
|
|
504
330
|
});
|
|
505
331
|
return () => cleanup?.();
|
|
@@ -513,7 +339,7 @@ function machine(userContext) {
|
|
|
513
339
|
if (!ctx2.modal)
|
|
514
340
|
return;
|
|
515
341
|
let trap;
|
|
516
|
-
nextTick(() => {
|
|
342
|
+
(0, import_dom_query3.nextTick)(() => {
|
|
517
343
|
const el = dom.getContentEl(ctx2);
|
|
518
344
|
if (!el)
|
|
519
345
|
return;
|
|
@@ -523,7 +349,7 @@ function machine(userContext) {
|
|
|
523
349
|
returnFocusOnDeactivate: true,
|
|
524
350
|
document: dom.getDoc(ctx2),
|
|
525
351
|
fallbackFocus: el,
|
|
526
|
-
initialFocus: runIfFn(ctx2.initialFocusEl)
|
|
352
|
+
initialFocus: (0, import_utils2.runIfFn)(ctx2.initialFocusEl)
|
|
527
353
|
});
|
|
528
354
|
try {
|
|
529
355
|
trap.activate();
|
|
@@ -535,7 +361,7 @@ function machine(userContext) {
|
|
|
535
361
|
},
|
|
536
362
|
guards: {
|
|
537
363
|
portalled: (ctx2) => ctx2.currentPortalled,
|
|
538
|
-
isRelatedTargetWithinContent: (ctx2, evt) => contains(dom.getContentEl(ctx2), evt.target),
|
|
364
|
+
isRelatedTargetWithinContent: (ctx2, evt) => (0, import_dom_query3.contains)(dom.getContentEl(ctx2), evt.target),
|
|
539
365
|
closeOnInteractOutside: (ctx2) => !!ctx2.closeOnInteractOutside,
|
|
540
366
|
isContentFocused: (ctx2) => dom.getContentEl(ctx2) === dom.getActiveEl(ctx2),
|
|
541
367
|
isTriggerFocused: (ctx2) => dom.getTriggerEl(ctx2) === dom.getActiveEl(ctx2),
|
|
@@ -544,7 +370,7 @@ function machine(userContext) {
|
|
|
544
370
|
},
|
|
545
371
|
actions: {
|
|
546
372
|
checkRenderedElements(ctx2) {
|
|
547
|
-
raf(() => {
|
|
373
|
+
(0, import_dom_query3.raf)(() => {
|
|
548
374
|
Object.assign(ctx2.renderedElements, {
|
|
549
375
|
title: !!dom.getTitleEl(ctx2),
|
|
550
376
|
description: !!dom.getDescriptionEl(ctx2),
|
|
@@ -553,14 +379,14 @@ function machine(userContext) {
|
|
|
553
379
|
});
|
|
554
380
|
},
|
|
555
381
|
setInitialFocus(ctx2) {
|
|
556
|
-
raf(() => {
|
|
382
|
+
(0, import_dom_query3.raf)(() => {
|
|
557
383
|
dom.getInitialFocusEl(ctx2)?.focus();
|
|
558
384
|
});
|
|
559
385
|
},
|
|
560
386
|
focusTriggerIfNeeded(ctx2) {
|
|
561
387
|
if (!ctx2.focusTriggerOnClose)
|
|
562
388
|
return;
|
|
563
|
-
raf(() => dom.getTriggerEl(ctx2)?.focus());
|
|
389
|
+
(0, import_dom_query3.raf)(() => dom.getTriggerEl(ctx2)?.focus());
|
|
564
390
|
},
|
|
565
391
|
focusFirstTabbableElement(ctx2, evt) {
|
|
566
392
|
evt.preventDefault();
|
|
@@ -585,15 +411,15 @@ function machine(userContext) {
|
|
|
585
411
|
if (lastTabbable !== dom.getActiveEl(ctx2))
|
|
586
412
|
return;
|
|
587
413
|
let tabbables = dom.getDocTabbableEls(ctx2);
|
|
588
|
-
let elementAfterTrigger = next(tabbables, tabbables.indexOf(button), { loop: false });
|
|
414
|
+
let elementAfterTrigger = (0, import_utils2.next)(tabbables, tabbables.indexOf(button), { loop: false });
|
|
589
415
|
if (elementAfterTrigger === content) {
|
|
590
|
-
tabbables = tabbables.filter((el) => !contains(content, el));
|
|
591
|
-
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 });
|
|
592
418
|
}
|
|
593
419
|
if (!elementAfterTrigger || elementAfterTrigger === button)
|
|
594
420
|
return;
|
|
595
421
|
evt.preventDefault();
|
|
596
|
-
raf(() => elementAfterTrigger?.focus());
|
|
422
|
+
(0, import_dom_query3.raf)(() => elementAfterTrigger?.focus());
|
|
597
423
|
}
|
|
598
424
|
}
|
|
599
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,
|