@zag-js/popover 0.0.0-dev-20221018140542 → 0.0.0-dev-20221031083441
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/index.js +23 -19
- package/dist/index.mjs +23 -19
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var dataAttr = (guard) => {
|
|
|
31
31
|
};
|
|
32
32
|
var runIfFn = (v, ...a) => {
|
|
33
33
|
const res = typeof v === "function" ? v(...a) : v;
|
|
34
|
-
return res
|
|
34
|
+
return res != null ? res : void 0;
|
|
35
35
|
};
|
|
36
36
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
37
37
|
function isDocument(el) {
|
|
@@ -44,26 +44,30 @@ function isFrame(element) {
|
|
|
44
44
|
return element.localName === "iframe";
|
|
45
45
|
}
|
|
46
46
|
function getDocument(el) {
|
|
47
|
+
var _a;
|
|
47
48
|
if (isWindow(el))
|
|
48
49
|
return el.document;
|
|
49
50
|
if (isDocument(el))
|
|
50
51
|
return el;
|
|
51
|
-
return (el == null ? void 0 : el.ownerDocument)
|
|
52
|
+
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
52
53
|
}
|
|
53
54
|
function defineDomHelpers(helpers) {
|
|
54
55
|
const dom2 = {
|
|
55
56
|
getRootNode: (ctx) => {
|
|
56
|
-
var _a;
|
|
57
|
-
return ((_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx))
|
|
57
|
+
var _a, _b;
|
|
58
|
+
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
58
59
|
},
|
|
59
60
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
60
|
-
getWin: (ctx) =>
|
|
61
|
+
getWin: (ctx) => {
|
|
62
|
+
var _a;
|
|
63
|
+
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
64
|
+
},
|
|
61
65
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
62
66
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
|
|
63
67
|
createEmitter: (ctx, target) => {
|
|
64
68
|
const win = dom2.getWin(ctx);
|
|
65
69
|
return function emit(evt, detail, options) {
|
|
66
|
-
const { bubbles = true, cancelable, composed = true } = options
|
|
70
|
+
const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
|
|
67
71
|
const eventName = `zag:${evt}`;
|
|
68
72
|
const init = { bubbles, cancelable, composed, detail };
|
|
69
73
|
const event = new win.CustomEvent(eventName, init);
|
|
@@ -206,37 +210,37 @@ function next(v, idx, opts = {}) {
|
|
|
206
210
|
}
|
|
207
211
|
var runIfFn2 = (v, ...a) => {
|
|
208
212
|
const res = typeof v === "function" ? v(...a) : v;
|
|
209
|
-
return res
|
|
213
|
+
return res != null ? res : void 0;
|
|
210
214
|
};
|
|
211
215
|
|
|
212
216
|
// src/popover.dom.ts
|
|
213
217
|
var dom = defineDomHelpers({
|
|
214
218
|
getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
|
|
215
219
|
getAnchorId: (ctx) => {
|
|
216
|
-
var _a;
|
|
217
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.anchor)
|
|
220
|
+
var _a, _b;
|
|
221
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.anchor) != null ? _b : `popover:${ctx.id}:anchor`;
|
|
218
222
|
},
|
|
219
223
|
getTriggerId: (ctx) => {
|
|
220
|
-
var _a;
|
|
221
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.trigger)
|
|
224
|
+
var _a, _b;
|
|
225
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `popover:${ctx.id}:trigger`;
|
|
222
226
|
},
|
|
223
227
|
getContentId: (ctx) => {
|
|
224
|
-
var _a;
|
|
225
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.content)
|
|
228
|
+
var _a, _b;
|
|
229
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `popover:${ctx.id}:content`;
|
|
226
230
|
},
|
|
227
231
|
getPositionerId: (ctx) => `popover:${ctx.id}:popper`,
|
|
228
232
|
getArrowId: (ctx) => `popover:${ctx.id}:arrow`,
|
|
229
233
|
getTitleId: (ctx) => {
|
|
230
|
-
var _a;
|
|
231
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.title)
|
|
234
|
+
var _a, _b;
|
|
235
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.title) != null ? _b : `popover:${ctx.id}:title`;
|
|
232
236
|
},
|
|
233
237
|
getDescriptionId: (ctx) => {
|
|
234
|
-
var _a;
|
|
235
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.description)
|
|
238
|
+
var _a, _b;
|
|
239
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.description) != null ? _b : `popover:${ctx.id}:desc`;
|
|
236
240
|
},
|
|
237
241
|
getCloseButtonId: (ctx) => {
|
|
238
|
-
var _a;
|
|
239
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.closeBtn)
|
|
242
|
+
var _a, _b;
|
|
243
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.closeBtn) != null ? _b : `popover:${ctx.id}:close-button`;
|
|
240
244
|
},
|
|
241
245
|
getAnchorEl: (ctx) => dom.getById(ctx, dom.getAnchorId(ctx)),
|
|
242
246
|
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ var dataAttr = (guard) => {
|
|
|
4
4
|
};
|
|
5
5
|
var runIfFn = (v, ...a) => {
|
|
6
6
|
const res = typeof v === "function" ? v(...a) : v;
|
|
7
|
-
return res
|
|
7
|
+
return res != null ? res : void 0;
|
|
8
8
|
};
|
|
9
9
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
10
10
|
function isDocument(el) {
|
|
@@ -17,26 +17,30 @@ function isFrame(element) {
|
|
|
17
17
|
return element.localName === "iframe";
|
|
18
18
|
}
|
|
19
19
|
function getDocument(el) {
|
|
20
|
+
var _a;
|
|
20
21
|
if (isWindow(el))
|
|
21
22
|
return el.document;
|
|
22
23
|
if (isDocument(el))
|
|
23
24
|
return el;
|
|
24
|
-
return (el == null ? void 0 : el.ownerDocument)
|
|
25
|
+
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
25
26
|
}
|
|
26
27
|
function defineDomHelpers(helpers) {
|
|
27
28
|
const dom2 = {
|
|
28
29
|
getRootNode: (ctx) => {
|
|
29
|
-
var _a;
|
|
30
|
-
return ((_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx))
|
|
30
|
+
var _a, _b;
|
|
31
|
+
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
31
32
|
},
|
|
32
33
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
33
|
-
getWin: (ctx) =>
|
|
34
|
+
getWin: (ctx) => {
|
|
35
|
+
var _a;
|
|
36
|
+
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
37
|
+
},
|
|
34
38
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
35
39
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
|
|
36
40
|
createEmitter: (ctx, target) => {
|
|
37
41
|
const win = dom2.getWin(ctx);
|
|
38
42
|
return function emit(evt, detail, options) {
|
|
39
|
-
const { bubbles = true, cancelable, composed = true } = options
|
|
43
|
+
const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
|
|
40
44
|
const eventName = `zag:${evt}`;
|
|
41
45
|
const init = { bubbles, cancelable, composed, detail };
|
|
42
46
|
const event = new win.CustomEvent(eventName, init);
|
|
@@ -179,37 +183,37 @@ function next(v, idx, opts = {}) {
|
|
|
179
183
|
}
|
|
180
184
|
var runIfFn2 = (v, ...a) => {
|
|
181
185
|
const res = typeof v === "function" ? v(...a) : v;
|
|
182
|
-
return res
|
|
186
|
+
return res != null ? res : void 0;
|
|
183
187
|
};
|
|
184
188
|
|
|
185
189
|
// src/popover.dom.ts
|
|
186
190
|
var dom = defineDomHelpers({
|
|
187
191
|
getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
|
|
188
192
|
getAnchorId: (ctx) => {
|
|
189
|
-
var _a;
|
|
190
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.anchor)
|
|
193
|
+
var _a, _b;
|
|
194
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.anchor) != null ? _b : `popover:${ctx.id}:anchor`;
|
|
191
195
|
},
|
|
192
196
|
getTriggerId: (ctx) => {
|
|
193
|
-
var _a;
|
|
194
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.trigger)
|
|
197
|
+
var _a, _b;
|
|
198
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `popover:${ctx.id}:trigger`;
|
|
195
199
|
},
|
|
196
200
|
getContentId: (ctx) => {
|
|
197
|
-
var _a;
|
|
198
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.content)
|
|
201
|
+
var _a, _b;
|
|
202
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `popover:${ctx.id}:content`;
|
|
199
203
|
},
|
|
200
204
|
getPositionerId: (ctx) => `popover:${ctx.id}:popper`,
|
|
201
205
|
getArrowId: (ctx) => `popover:${ctx.id}:arrow`,
|
|
202
206
|
getTitleId: (ctx) => {
|
|
203
|
-
var _a;
|
|
204
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.title)
|
|
207
|
+
var _a, _b;
|
|
208
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.title) != null ? _b : `popover:${ctx.id}:title`;
|
|
205
209
|
},
|
|
206
210
|
getDescriptionId: (ctx) => {
|
|
207
|
-
var _a;
|
|
208
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.description)
|
|
211
|
+
var _a, _b;
|
|
212
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.description) != null ? _b : `popover:${ctx.id}:desc`;
|
|
209
213
|
},
|
|
210
214
|
getCloseButtonId: (ctx) => {
|
|
211
|
-
var _a;
|
|
212
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.closeBtn)
|
|
215
|
+
var _a, _b;
|
|
216
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.closeBtn) != null ? _b : `popover:${ctx.id}:close-button`;
|
|
213
217
|
},
|
|
214
218
|
getAnchorEl: (ctx) => dom.getById(ctx, dom.getAnchorId(ctx)),
|
|
215
219
|
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/popover",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20221031083441",
|
|
4
4
|
"description": "Core logic for the popover widget implemented as a state machine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/aria-hidden": "0.
|
|
33
|
-
"@zag-js/core": "0.
|
|
34
|
-
"@zag-js/dismissable": "0.
|
|
35
|
-
"@zag-js/popper": "0.0.0-dev-
|
|
36
|
-
"@zag-js/remove-scroll": "0.
|
|
37
|
-
"@zag-js/types": "0.
|
|
32
|
+
"@zag-js/aria-hidden": "0.0.0-dev-20221031083441",
|
|
33
|
+
"@zag-js/core": "0.0.0-dev-20221031083441",
|
|
34
|
+
"@zag-js/dismissable": "0.0.0-dev-20221031083441",
|
|
35
|
+
"@zag-js/popper": "0.0.0-dev-20221031083441",
|
|
36
|
+
"@zag-js/remove-scroll": "0.0.0-dev-20221031083441",
|
|
37
|
+
"@zag-js/types": "0.0.0-dev-20221031083441",
|
|
38
38
|
"focus-trap": "7.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@zag-js/dom-utils": "0.0.0-dev-
|
|
42
|
-
"@zag-js/utils": "0.
|
|
41
|
+
"@zag-js/dom-utils": "0.0.0-dev-20221031083441",
|
|
42
|
+
"@zag-js/utils": "0.0.0-dev-20221031083441"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build-fast": "tsup src/index.ts --format=esm,cjs",
|