@zag-js/popover 0.10.2 → 0.10.4
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.d.ts +4 -9
- package/dist/index.js +8 -409
- package/dist/index.mjs +3 -15
- package/dist/popover.anatomy.d.ts +3 -6
- package/dist/popover.anatomy.js +10 -33
- package/dist/popover.anatomy.mjs +16 -8
- package/dist/popover.connect.d.ts +4 -9
- package/dist/popover.connect.js +31 -104
- package/dist/popover.connect.mjs +106 -8
- package/dist/popover.dom.d.ts +24 -31
- package/dist/popover.dom.js +16 -38
- package/dist/popover.dom.mjs +37 -6
- package/dist/popover.machine.d.ts +3 -9
- package/dist/popover.machine.js +43 -102
- package/dist/popover.machine.mjs +227 -7
- package/dist/popover.types.d.ts +10 -12
- package/package.json +13 -18
- package/src/index.ts +1 -1
- package/src/popover.types.ts +2 -0
- package/dist/chunk-EDQUDEDS.mjs +0 -232
- package/dist/chunk-HRZXZNMW.mjs +0 -113
- package/dist/chunk-KTOPDXGV.mjs +0 -19
- package/dist/chunk-UA4OMIJI.mjs +0 -39
- package/dist/popover.types.js +0 -18
- package/dist/popover.types.mjs +0 -0
package/dist/popover.connect.js
CHANGED
|
@@ -1,89 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var popover_connect_exports = {};
|
|
22
|
-
__export(popover_connect_exports, {
|
|
23
|
-
connect: () => connect
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(popover_connect_exports);
|
|
26
|
-
var import_dom_query2 = require("@zag-js/dom-query");
|
|
27
|
-
var import_popper = require("@zag-js/popper");
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
28
4
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"arrowTip",
|
|
34
|
-
"anchor",
|
|
35
|
-
"trigger",
|
|
36
|
-
"positioner",
|
|
37
|
-
"content",
|
|
38
|
-
"title",
|
|
39
|
-
"description",
|
|
40
|
-
"closeTrigger"
|
|
41
|
-
);
|
|
42
|
-
var parts = anatomy.build();
|
|
5
|
+
const domQuery = require('@zag-js/dom-query');
|
|
6
|
+
const popper = require('@zag-js/popper');
|
|
7
|
+
const popover_anatomy = require('./popover.anatomy.js');
|
|
8
|
+
const popover_dom = require('./popover.dom.js');
|
|
43
9
|
|
|
44
|
-
// src/popover.dom.ts
|
|
45
|
-
var import_dom_query = require("@zag-js/dom-query");
|
|
46
|
-
var import_tabbable = require("@zag-js/tabbable");
|
|
47
|
-
var import_utils = require("@zag-js/utils");
|
|
48
|
-
var dom = (0, import_dom_query.createScope)({
|
|
49
|
-
getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
|
|
50
|
-
getAnchorId: (ctx) => ctx.ids?.anchor ?? `popover:${ctx.id}:anchor`,
|
|
51
|
-
getTriggerId: (ctx) => ctx.ids?.trigger ?? `popover:${ctx.id}:trigger`,
|
|
52
|
-
getContentId: (ctx) => ctx.ids?.content ?? `popover:${ctx.id}:content`,
|
|
53
|
-
getPositionerId: (ctx) => ctx.ids?.positioner ?? `popover:${ctx.id}:popper`,
|
|
54
|
-
getArrowId: (ctx) => ctx.ids?.arrow ?? `popover:${ctx.id}:arrow`,
|
|
55
|
-
getTitleId: (ctx) => ctx.ids?.title ?? `popover:${ctx.id}:title`,
|
|
56
|
-
getDescriptionId: (ctx) => ctx.ids?.description ?? `popover:${ctx.id}:desc`,
|
|
57
|
-
getCloseTriggerId: (ctx) => ctx.ids?.closeTrigger ?? `popover:${ctx.id}:close`,
|
|
58
|
-
getAnchorEl: (ctx) => dom.getById(ctx, dom.getAnchorId(ctx)),
|
|
59
|
-
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
|
60
|
-
getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
|
|
61
|
-
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
|
|
62
|
-
getTitleEl: (ctx) => dom.getById(ctx, dom.getTitleId(ctx)),
|
|
63
|
-
getDescriptionEl: (ctx) => dom.getById(ctx, dom.getDescriptionId(ctx)),
|
|
64
|
-
getFocusableEls: (ctx) => (0, import_tabbable.getFocusables)(dom.getContentEl(ctx)),
|
|
65
|
-
getFirstFocusableEl: (ctx) => dom.getFocusableEls(ctx)[0],
|
|
66
|
-
getDocTabbableEls: (ctx) => (0, import_tabbable.getTabbables)(dom.getDoc(ctx).body),
|
|
67
|
-
getTabbableEls: (ctx) => (0, import_tabbable.getTabbables)(dom.getContentEl(ctx), "if-empty"),
|
|
68
|
-
getFirstTabbableEl: (ctx) => (0, import_tabbable.getFirstTabbable)(dom.getContentEl(ctx), "if-empty"),
|
|
69
|
-
getLastTabbableEl: (ctx) => (0, import_tabbable.getLastTabbable)(dom.getContentEl(ctx), "if-empty"),
|
|
70
|
-
getInitialFocusEl: (ctx) => {
|
|
71
|
-
let el = (0, import_utils.runIfFn)(ctx.initialFocusEl);
|
|
72
|
-
if (!el && ctx.autoFocus)
|
|
73
|
-
el = dom.getFirstFocusableEl(ctx);
|
|
74
|
-
if (!el)
|
|
75
|
-
el = dom.getContentEl(ctx);
|
|
76
|
-
return el;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// src/popover.connect.ts
|
|
81
10
|
function connect(state, send, normalize) {
|
|
82
11
|
const isOpen = state.matches("open");
|
|
83
12
|
const currentPlacement = state.context.currentPlacement;
|
|
84
13
|
const portalled = state.context.currentPortalled;
|
|
85
14
|
const rendered = state.context.renderedElements;
|
|
86
|
-
const popperStyles =
|
|
15
|
+
const popperStyles = popper.getPlacementStyles({
|
|
87
16
|
placement: currentPlacement
|
|
88
17
|
});
|
|
89
18
|
return {
|
|
@@ -114,27 +43,27 @@ function connect(state, send, normalize) {
|
|
|
114
43
|
send({ type: "SET_POSITIONING", options });
|
|
115
44
|
},
|
|
116
45
|
arrowProps: normalize.element({
|
|
117
|
-
id: dom.getArrowId(state.context),
|
|
118
|
-
...parts.arrow.attrs,
|
|
46
|
+
id: popover_dom.dom.getArrowId(state.context),
|
|
47
|
+
...popover_anatomy.parts.arrow.attrs,
|
|
119
48
|
style: popperStyles.arrow
|
|
120
49
|
}),
|
|
121
50
|
arrowTipProps: normalize.element({
|
|
122
|
-
...parts.arrowTip.attrs,
|
|
51
|
+
...popover_anatomy.parts.arrowTip.attrs,
|
|
123
52
|
style: popperStyles.arrowTip
|
|
124
53
|
}),
|
|
125
54
|
anchorProps: normalize.element({
|
|
126
|
-
...parts.anchor.attrs,
|
|
127
|
-
id: dom.getAnchorId(state.context)
|
|
55
|
+
...popover_anatomy.parts.anchor.attrs,
|
|
56
|
+
id: popover_dom.dom.getAnchorId(state.context)
|
|
128
57
|
}),
|
|
129
58
|
triggerProps: normalize.button({
|
|
130
|
-
...parts.trigger.attrs,
|
|
59
|
+
...popover_anatomy.parts.trigger.attrs,
|
|
131
60
|
type: "button",
|
|
132
61
|
"data-placement": currentPlacement,
|
|
133
|
-
id: dom.getTriggerId(state.context),
|
|
62
|
+
id: popover_dom.dom.getTriggerId(state.context),
|
|
134
63
|
"aria-haspopup": "dialog",
|
|
135
64
|
"aria-expanded": isOpen,
|
|
136
|
-
"data-expanded":
|
|
137
|
-
"aria-controls": dom.getContentId(state.context),
|
|
65
|
+
"data-expanded": domQuery.dataAttr(isOpen),
|
|
66
|
+
"aria-controls": popover_dom.dom.getContentId(state.context),
|
|
138
67
|
onClick() {
|
|
139
68
|
send("TOGGLE");
|
|
140
69
|
},
|
|
@@ -143,32 +72,32 @@ function connect(state, send, normalize) {
|
|
|
143
72
|
}
|
|
144
73
|
}),
|
|
145
74
|
positionerProps: normalize.element({
|
|
146
|
-
id: dom.getPositionerId(state.context),
|
|
147
|
-
...parts.positioner.attrs,
|
|
75
|
+
id: popover_dom.dom.getPositionerId(state.context),
|
|
76
|
+
...popover_anatomy.parts.positioner.attrs,
|
|
148
77
|
style: popperStyles.floating
|
|
149
78
|
}),
|
|
150
79
|
contentProps: normalize.element({
|
|
151
|
-
...parts.content.attrs,
|
|
152
|
-
id: dom.getContentId(state.context),
|
|
80
|
+
...popover_anatomy.parts.content.attrs,
|
|
81
|
+
id: popover_dom.dom.getContentId(state.context),
|
|
153
82
|
tabIndex: -1,
|
|
154
83
|
role: "dialog",
|
|
155
84
|
hidden: !isOpen,
|
|
156
|
-
"data-expanded":
|
|
157
|
-
"aria-labelledby": rendered.title ? dom.getTitleId(state.context) : void 0,
|
|
158
|
-
"aria-describedby": rendered.description ? dom.getDescriptionId(state.context) : void 0,
|
|
85
|
+
"data-expanded": domQuery.dataAttr(isOpen),
|
|
86
|
+
"aria-labelledby": rendered.title ? popover_dom.dom.getTitleId(state.context) : void 0,
|
|
87
|
+
"aria-describedby": rendered.description ? popover_dom.dom.getDescriptionId(state.context) : void 0,
|
|
159
88
|
"data-placement": currentPlacement
|
|
160
89
|
}),
|
|
161
90
|
titleProps: normalize.element({
|
|
162
|
-
...parts.title.attrs,
|
|
163
|
-
id: dom.getTitleId(state.context)
|
|
91
|
+
...popover_anatomy.parts.title.attrs,
|
|
92
|
+
id: popover_dom.dom.getTitleId(state.context)
|
|
164
93
|
}),
|
|
165
94
|
descriptionProps: normalize.element({
|
|
166
|
-
...parts.description.attrs,
|
|
167
|
-
id: dom.getDescriptionId(state.context)
|
|
95
|
+
...popover_anatomy.parts.description.attrs,
|
|
96
|
+
id: popover_dom.dom.getDescriptionId(state.context)
|
|
168
97
|
}),
|
|
169
98
|
closeTriggerProps: normalize.button({
|
|
170
|
-
...parts.closeTrigger.attrs,
|
|
171
|
-
id: dom.getCloseTriggerId(state.context),
|
|
99
|
+
...popover_anatomy.parts.closeTrigger.attrs,
|
|
100
|
+
id: popover_dom.dom.getCloseTriggerId(state.context),
|
|
172
101
|
type: "button",
|
|
173
102
|
"aria-label": "close",
|
|
174
103
|
onClick() {
|
|
@@ -177,7 +106,5 @@ function connect(state, send, normalize) {
|
|
|
177
106
|
})
|
|
178
107
|
};
|
|
179
108
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
connect
|
|
183
|
-
});
|
|
109
|
+
|
|
110
|
+
exports.connect = connect;
|
package/dist/popover.connect.mjs
CHANGED
|
@@ -1,8 +1,106 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { dataAttr } from '@zag-js/dom-query';
|
|
2
|
+
import { getPlacementStyles } from '@zag-js/popper';
|
|
3
|
+
import { parts } from './popover.anatomy.mjs';
|
|
4
|
+
import { dom } from './popover.dom.mjs';
|
|
5
|
+
|
|
6
|
+
function connect(state, send, normalize) {
|
|
7
|
+
const isOpen = state.matches("open");
|
|
8
|
+
const currentPlacement = state.context.currentPlacement;
|
|
9
|
+
const portalled = state.context.currentPortalled;
|
|
10
|
+
const rendered = state.context.renderedElements;
|
|
11
|
+
const popperStyles = getPlacementStyles({
|
|
12
|
+
placement: currentPlacement
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
/**
|
|
16
|
+
* Whether the popover is portalled
|
|
17
|
+
*/
|
|
18
|
+
portalled,
|
|
19
|
+
/**
|
|
20
|
+
* Whether the popover is open
|
|
21
|
+
*/
|
|
22
|
+
isOpen,
|
|
23
|
+
/**
|
|
24
|
+
* Function to open the popover
|
|
25
|
+
*/
|
|
26
|
+
open() {
|
|
27
|
+
send("OPEN");
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* Function to close the popover
|
|
31
|
+
*/
|
|
32
|
+
close() {
|
|
33
|
+
send("CLOSE");
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Function to reposition the popover
|
|
37
|
+
*/
|
|
38
|
+
setPositioning(options = {}) {
|
|
39
|
+
send({ type: "SET_POSITIONING", options });
|
|
40
|
+
},
|
|
41
|
+
arrowProps: normalize.element({
|
|
42
|
+
id: dom.getArrowId(state.context),
|
|
43
|
+
...parts.arrow.attrs,
|
|
44
|
+
style: popperStyles.arrow
|
|
45
|
+
}),
|
|
46
|
+
arrowTipProps: normalize.element({
|
|
47
|
+
...parts.arrowTip.attrs,
|
|
48
|
+
style: popperStyles.arrowTip
|
|
49
|
+
}),
|
|
50
|
+
anchorProps: normalize.element({
|
|
51
|
+
...parts.anchor.attrs,
|
|
52
|
+
id: dom.getAnchorId(state.context)
|
|
53
|
+
}),
|
|
54
|
+
triggerProps: normalize.button({
|
|
55
|
+
...parts.trigger.attrs,
|
|
56
|
+
type: "button",
|
|
57
|
+
"data-placement": currentPlacement,
|
|
58
|
+
id: dom.getTriggerId(state.context),
|
|
59
|
+
"aria-haspopup": "dialog",
|
|
60
|
+
"aria-expanded": isOpen,
|
|
61
|
+
"data-expanded": dataAttr(isOpen),
|
|
62
|
+
"aria-controls": dom.getContentId(state.context),
|
|
63
|
+
onClick() {
|
|
64
|
+
send("TOGGLE");
|
|
65
|
+
},
|
|
66
|
+
onBlur(event) {
|
|
67
|
+
send({ type: "TRIGGER_BLUR", target: event.relatedTarget });
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
positionerProps: normalize.element({
|
|
71
|
+
id: dom.getPositionerId(state.context),
|
|
72
|
+
...parts.positioner.attrs,
|
|
73
|
+
style: popperStyles.floating
|
|
74
|
+
}),
|
|
75
|
+
contentProps: normalize.element({
|
|
76
|
+
...parts.content.attrs,
|
|
77
|
+
id: dom.getContentId(state.context),
|
|
78
|
+
tabIndex: -1,
|
|
79
|
+
role: "dialog",
|
|
80
|
+
hidden: !isOpen,
|
|
81
|
+
"data-expanded": dataAttr(isOpen),
|
|
82
|
+
"aria-labelledby": rendered.title ? dom.getTitleId(state.context) : void 0,
|
|
83
|
+
"aria-describedby": rendered.description ? dom.getDescriptionId(state.context) : void 0,
|
|
84
|
+
"data-placement": currentPlacement
|
|
85
|
+
}),
|
|
86
|
+
titleProps: normalize.element({
|
|
87
|
+
...parts.title.attrs,
|
|
88
|
+
id: dom.getTitleId(state.context)
|
|
89
|
+
}),
|
|
90
|
+
descriptionProps: normalize.element({
|
|
91
|
+
...parts.description.attrs,
|
|
92
|
+
id: dom.getDescriptionId(state.context)
|
|
93
|
+
}),
|
|
94
|
+
closeTriggerProps: normalize.button({
|
|
95
|
+
...parts.closeTrigger.attrs,
|
|
96
|
+
id: dom.getCloseTriggerId(state.context),
|
|
97
|
+
type: "button",
|
|
98
|
+
"aria-label": "close",
|
|
99
|
+
onClick() {
|
|
100
|
+
send("REQUEST_CLOSE");
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { connect };
|
package/dist/popover.dom.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { MachineContext } from
|
|
2
|
-
|
|
3
|
-
import '@zag-js/dismissable';
|
|
4
|
-
import '@zag-js/popper';
|
|
5
|
-
import '@zag-js/types';
|
|
6
|
-
|
|
7
|
-
declare const dom: {
|
|
1
|
+
import type { MachineContext as Ctx } from "./popover.types";
|
|
2
|
+
export declare const dom: {
|
|
8
3
|
getRootNode: (ctx: {
|
|
9
4
|
getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
|
|
10
5
|
}) => Document | ShadowRoot;
|
|
@@ -24,28 +19,26 @@ declare const dom: {
|
|
|
24
19
|
getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
|
|
25
20
|
}, id: string) => T_1;
|
|
26
21
|
} & {
|
|
27
|
-
getActiveEl: (ctx:
|
|
28
|
-
getAnchorId: (ctx:
|
|
29
|
-
getTriggerId: (ctx:
|
|
30
|
-
getContentId: (ctx:
|
|
31
|
-
getPositionerId: (ctx:
|
|
32
|
-
getArrowId: (ctx:
|
|
33
|
-
getTitleId: (ctx:
|
|
34
|
-
getDescriptionId: (ctx:
|
|
35
|
-
getCloseTriggerId: (ctx:
|
|
36
|
-
getAnchorEl: (ctx:
|
|
37
|
-
getTriggerEl: (ctx:
|
|
38
|
-
getContentEl: (ctx:
|
|
39
|
-
getPositionerEl: (ctx:
|
|
40
|
-
getTitleEl: (ctx:
|
|
41
|
-
getDescriptionEl: (ctx:
|
|
42
|
-
getFocusableEls: (ctx:
|
|
43
|
-
getFirstFocusableEl: (ctx:
|
|
44
|
-
getDocTabbableEls: (ctx:
|
|
45
|
-
getTabbableEls: (ctx:
|
|
46
|
-
getFirstTabbableEl: (ctx:
|
|
47
|
-
getLastTabbableEl: (ctx:
|
|
48
|
-
getInitialFocusEl: (ctx:
|
|
22
|
+
getActiveEl: (ctx: Ctx) => Element | null;
|
|
23
|
+
getAnchorId: (ctx: Ctx) => string;
|
|
24
|
+
getTriggerId: (ctx: Ctx) => string;
|
|
25
|
+
getContentId: (ctx: Ctx) => string;
|
|
26
|
+
getPositionerId: (ctx: Ctx) => string;
|
|
27
|
+
getArrowId: (ctx: Ctx) => string;
|
|
28
|
+
getTitleId: (ctx: Ctx) => string;
|
|
29
|
+
getDescriptionId: (ctx: Ctx) => string;
|
|
30
|
+
getCloseTriggerId: (ctx: Ctx) => string;
|
|
31
|
+
getAnchorEl: (ctx: Ctx) => HTMLElement | null;
|
|
32
|
+
getTriggerEl: (ctx: Ctx) => HTMLElement | null;
|
|
33
|
+
getContentEl: (ctx: Ctx) => HTMLElement | null;
|
|
34
|
+
getPositionerEl: (ctx: Ctx) => HTMLElement | null;
|
|
35
|
+
getTitleEl: (ctx: Ctx) => HTMLElement | null;
|
|
36
|
+
getDescriptionEl: (ctx: Ctx) => HTMLElement | null;
|
|
37
|
+
getFocusableEls: (ctx: Ctx) => HTMLElement[];
|
|
38
|
+
getFirstFocusableEl: (ctx: Ctx) => HTMLElement;
|
|
39
|
+
getDocTabbableEls: (ctx: Ctx) => HTMLElement[];
|
|
40
|
+
getTabbableEls: (ctx: Ctx) => HTMLElement[];
|
|
41
|
+
getFirstTabbableEl: (ctx: Ctx) => HTMLElement;
|
|
42
|
+
getLastTabbableEl: (ctx: Ctx) => HTMLElement;
|
|
43
|
+
getInitialFocusEl: (ctx: Ctx) => HTMLElement | null;
|
|
49
44
|
};
|
|
50
|
-
|
|
51
|
-
export { dom };
|
package/dist/popover.dom.js
CHANGED
|
@@ -1,32 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var import_tabbable = require("@zag-js/tabbable");
|
|
28
|
-
var import_utils = require("@zag-js/utils");
|
|
29
|
-
var dom = (0, import_dom_query.createScope)({
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const domQuery = require('@zag-js/dom-query');
|
|
6
|
+
const tabbable = require('@zag-js/tabbable');
|
|
7
|
+
const utils = require('@zag-js/utils');
|
|
8
|
+
|
|
9
|
+
const dom = domQuery.createScope({
|
|
30
10
|
getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
|
|
31
11
|
getAnchorId: (ctx) => ctx.ids?.anchor ?? `popover:${ctx.id}:anchor`,
|
|
32
12
|
getTriggerId: (ctx) => ctx.ids?.trigger ?? `popover:${ctx.id}:trigger`,
|
|
@@ -42,14 +22,14 @@ var dom = (0, import_dom_query.createScope)({
|
|
|
42
22
|
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
|
|
43
23
|
getTitleEl: (ctx) => dom.getById(ctx, dom.getTitleId(ctx)),
|
|
44
24
|
getDescriptionEl: (ctx) => dom.getById(ctx, dom.getDescriptionId(ctx)),
|
|
45
|
-
getFocusableEls: (ctx) =>
|
|
25
|
+
getFocusableEls: (ctx) => tabbable.getFocusables(dom.getContentEl(ctx)),
|
|
46
26
|
getFirstFocusableEl: (ctx) => dom.getFocusableEls(ctx)[0],
|
|
47
|
-
getDocTabbableEls: (ctx) =>
|
|
48
|
-
getTabbableEls: (ctx) =>
|
|
49
|
-
getFirstTabbableEl: (ctx) =>
|
|
50
|
-
getLastTabbableEl: (ctx) =>
|
|
27
|
+
getDocTabbableEls: (ctx) => tabbable.getTabbables(dom.getDoc(ctx).body),
|
|
28
|
+
getTabbableEls: (ctx) => tabbable.getTabbables(dom.getContentEl(ctx), "if-empty"),
|
|
29
|
+
getFirstTabbableEl: (ctx) => tabbable.getFirstTabbable(dom.getContentEl(ctx), "if-empty"),
|
|
30
|
+
getLastTabbableEl: (ctx) => tabbable.getLastTabbable(dom.getContentEl(ctx), "if-empty"),
|
|
51
31
|
getInitialFocusEl: (ctx) => {
|
|
52
|
-
let el =
|
|
32
|
+
let el = utils.runIfFn(ctx.initialFocusEl);
|
|
53
33
|
if (!el && ctx.autoFocus)
|
|
54
34
|
el = dom.getFirstFocusableEl(ctx);
|
|
55
35
|
if (!el)
|
|
@@ -57,7 +37,5 @@ var dom = (0, import_dom_query.createScope)({
|
|
|
57
37
|
return el;
|
|
58
38
|
}
|
|
59
39
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
dom
|
|
63
|
-
});
|
|
40
|
+
|
|
41
|
+
exports.dom = dom;
|
package/dist/popover.dom.mjs
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { createScope } from '@zag-js/dom-query';
|
|
2
|
+
import { getFocusables, getTabbables, getFirstTabbable, getLastTabbable } from '@zag-js/tabbable';
|
|
3
|
+
import { runIfFn } from '@zag-js/utils';
|
|
4
|
+
|
|
5
|
+
const 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) => ctx.ids?.positioner ?? `popover:${ctx.id}:popper`,
|
|
11
|
+
getArrowId: (ctx) => ctx.ids?.arrow ?? `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 { dom };
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import '@zag-js/popper';
|
|
5
|
-
import '@zag-js/types';
|
|
6
|
-
|
|
7
|
-
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
8
|
-
|
|
9
|
-
export { machine };
|
|
1
|
+
import { Machine, StateMachine } from '@zag-js/core';
|
|
2
|
+
import type { MachineContext, MachineState, UserDefinedContext } from "./popover.types";
|
|
3
|
+
export declare function machine(userContext: UserDefinedContext): Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|