@zag-js/popover 1.47.0 → 1.49.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/dist/index.d.mts +7 -10
- package/dist/index.d.ts +7 -10
- package/dist/index.js +12 -38
- package/dist/index.mjs +2 -7
- package/dist/popover.anatomy.d.mts +2 -6
- package/dist/popover.anatomy.d.ts +2 -6
- package/dist/popover.anatomy.js +8 -44
- package/dist/popover.anatomy.mjs +4 -18
- package/dist/popover.connect.d.mts +3 -9
- package/dist/popover.connect.d.ts +3 -9
- package/dist/popover.connect.js +164 -187
- package/dist/popover.connect.mjs +157 -149
- package/dist/popover.dom.d.mts +19 -22
- package/dist/popover.dom.d.ts +19 -22
- package/dist/popover.dom.js +47 -89
- package/dist/popover.dom.mjs +25 -46
- package/dist/popover.machine.d.mts +2 -9
- package/dist/popover.machine.d.ts +2 -9
- package/dist/popover.machine.js +308 -339
- package/dist/popover.machine.mjs +299 -299
- package/dist/popover.props.d.mts +3 -10
- package/dist/popover.props.d.ts +3 -10
- package/dist/popover.props.js +36 -60
- package/dist/popover.props.mjs +30 -33
- package/dist/popover.types.d.mts +185 -188
- package/dist/popover.types.d.ts +185 -188
- package/dist/popover.types.js +4 -18
- package/dist/popover.types.mjs +1 -0
- package/package.json +13 -13
package/dist/popover.connect.mjs
CHANGED
|
@@ -1,155 +1,163 @@
|
|
|
1
|
-
// src/popover.connect.ts
|
|
2
1
|
import { ariaAttr, dataAttr, isLeftClick, isSafari } from "@zag-js/dom-query";
|
|
3
2
|
import { getPlacementSide, getPlacementStyles } from "@zag-js/popper";
|
|
4
3
|
import { mergeWithDefault } from "@zag-js/utils";
|
|
5
4
|
import { parts } from "./popover.anatomy.mjs";
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
5
|
+
import { getAnchorId, getArrowId, getCloseTriggerId, getContentId, getDescriptionId, getPositionerId, getTitleId, getTriggerId } from "./popover.dom.mjs";
|
|
6
|
+
// src/popover.connect.ts
|
|
7
|
+
const defaultTranslations = { closeTriggerLabel: "close" };
|
|
10
8
|
function connect(service, normalize) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
9
|
+
const { state, context, send, computed, prop, scope } = service;
|
|
10
|
+
const translations = mergeWithDefault(defaultTranslations, prop("translations"));
|
|
11
|
+
const open = state.matches("open");
|
|
12
|
+
const currentPlacement = context.get("currentPlacement");
|
|
13
|
+
const currentPlacementSide = currentPlacement ? getPlacementSide(currentPlacement) : void 0;
|
|
14
|
+
const portalled = computed("currentPortalled");
|
|
15
|
+
const rendered = context.get("renderedElements");
|
|
16
|
+
const triggerValue = context.get("triggerValue");
|
|
17
|
+
const popperStyles = getPlacementStyles({
|
|
18
|
+
...prop("positioning"),
|
|
19
|
+
placement: currentPlacement
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
portalled,
|
|
23
|
+
open,
|
|
24
|
+
setOpen(nextOpen) {
|
|
25
|
+
send({
|
|
26
|
+
type: nextOpen ? "OPEN" : "CLOSE",
|
|
27
|
+
replaces: "open"
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
triggerValue,
|
|
31
|
+
setTriggerValue(value) {
|
|
32
|
+
send({
|
|
33
|
+
type: "TRIGGER_VALUE.SET",
|
|
34
|
+
value
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
reposition(options = {}) {
|
|
38
|
+
send({
|
|
39
|
+
type: "POSITIONING.SET",
|
|
40
|
+
options
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
getArrowProps() {
|
|
44
|
+
return normalize.element({
|
|
45
|
+
id: getArrowId(scope),
|
|
46
|
+
...parts.arrow.attrs,
|
|
47
|
+
dir: prop("dir"),
|
|
48
|
+
style: popperStyles.arrow
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
getArrowTipProps() {
|
|
52
|
+
return normalize.element({
|
|
53
|
+
...parts.arrowTip.attrs,
|
|
54
|
+
dir: prop("dir"),
|
|
55
|
+
style: popperStyles.arrowTip
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
getAnchorProps() {
|
|
59
|
+
return normalize.element({
|
|
60
|
+
...parts.anchor.attrs,
|
|
61
|
+
dir: prop("dir"),
|
|
62
|
+
id: getAnchorId(scope)
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
getTriggerProps(props = {}) {
|
|
66
|
+
const { value } = props;
|
|
67
|
+
const current = value == null ? false : triggerValue === value;
|
|
68
|
+
return normalize.button({
|
|
69
|
+
...parts.trigger.attrs,
|
|
70
|
+
dir: prop("dir"),
|
|
71
|
+
type: "button",
|
|
72
|
+
"data-placement": currentPlacement,
|
|
73
|
+
"data-side": currentPlacementSide,
|
|
74
|
+
id: getTriggerId(scope, value),
|
|
75
|
+
"data-ownedby": scope.id,
|
|
76
|
+
"data-value": value,
|
|
77
|
+
"data-current": dataAttr(current),
|
|
78
|
+
"aria-haspopup": "dialog",
|
|
79
|
+
"aria-expanded": value == null ? open : open && current,
|
|
80
|
+
"data-state": open ? "open" : "closed",
|
|
81
|
+
"aria-controls": getContentId(scope),
|
|
82
|
+
onPointerDown(event) {
|
|
83
|
+
if (!isLeftClick(event)) return;
|
|
84
|
+
if (isSafari()) event.currentTarget.focus();
|
|
85
|
+
},
|
|
86
|
+
onClick(event) {
|
|
87
|
+
if (event.defaultPrevented) return;
|
|
88
|
+
send({
|
|
89
|
+
type: open && value != null && !current ? "TRIGGER_VALUE.SET" : "TOGGLE",
|
|
90
|
+
value
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
onBlur(event) {
|
|
94
|
+
send({
|
|
95
|
+
type: "TRIGGER_BLUR",
|
|
96
|
+
target: event.relatedTarget
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
getIndicatorProps() {
|
|
102
|
+
return normalize.element({
|
|
103
|
+
...parts.indicator.attrs,
|
|
104
|
+
dir: prop("dir"),
|
|
105
|
+
"data-state": open ? "open" : "closed"
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
getPositionerProps() {
|
|
109
|
+
return normalize.element({
|
|
110
|
+
id: getPositionerId(scope),
|
|
111
|
+
...parts.positioner.attrs,
|
|
112
|
+
dir: prop("dir"),
|
|
113
|
+
style: popperStyles.floating
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
getContentProps() {
|
|
117
|
+
return normalize.element({
|
|
118
|
+
...parts.content.attrs,
|
|
119
|
+
dir: prop("dir"),
|
|
120
|
+
id: getContentId(scope),
|
|
121
|
+
tabIndex: -1,
|
|
122
|
+
role: "dialog",
|
|
123
|
+
"aria-modal": ariaAttr(prop("modal")),
|
|
124
|
+
hidden: !open,
|
|
125
|
+
"data-state": open ? "open" : "closed",
|
|
126
|
+
"data-expanded": dataAttr(open),
|
|
127
|
+
"aria-labelledby": rendered.title ? getTitleId(scope) : void 0,
|
|
128
|
+
"aria-describedby": rendered.description ? getDescriptionId(scope) : void 0,
|
|
129
|
+
"data-placement": currentPlacement,
|
|
130
|
+
"data-side": currentPlacementSide
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
getTitleProps() {
|
|
134
|
+
return normalize.element({
|
|
135
|
+
...parts.title.attrs,
|
|
136
|
+
id: getTitleId(scope),
|
|
137
|
+
dir: prop("dir")
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
getDescriptionProps() {
|
|
141
|
+
return normalize.element({
|
|
142
|
+
...parts.description.attrs,
|
|
143
|
+
id: getDescriptionId(scope),
|
|
144
|
+
dir: prop("dir")
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
getCloseTriggerProps() {
|
|
148
|
+
return normalize.button({
|
|
149
|
+
...parts.closeTrigger.attrs,
|
|
150
|
+
dir: prop("dir"),
|
|
151
|
+
id: getCloseTriggerId(scope),
|
|
152
|
+
type: "button",
|
|
153
|
+
"aria-label": translations.closeTriggerLabel,
|
|
154
|
+
onClick(event) {
|
|
155
|
+
if (event.defaultPrevented) return;
|
|
156
|
+
event.stopPropagation();
|
|
157
|
+
send({ type: "CLOSE" });
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
};
|
|
152
162
|
}
|
|
153
|
-
export {
|
|
154
|
-
connect
|
|
155
|
-
};
|
|
163
|
+
export { connect };
|
package/dist/popover.dom.d.mts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import { Scope } from
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const
|
|
9
|
-
declare const
|
|
10
|
-
declare const
|
|
11
|
-
declare const
|
|
12
|
-
declare const
|
|
13
|
-
declare const
|
|
14
|
-
declare const
|
|
15
|
-
declare const
|
|
16
|
-
declare const
|
|
17
|
-
declare const
|
|
18
|
-
declare const
|
|
19
|
-
declare const
|
|
20
|
-
declare const getFirstFocusableEl: (scope: Scope) => HTMLElement;
|
|
21
|
-
|
|
22
|
-
export { getActiveTriggerEl, getAnchorEl, getAnchorId, getArrowId, getCloseTriggerId, getContentEl, getContentId, getDescriptionEl, getDescriptionId, getFirstFocusableEl, getFocusableEls, getPositionerEl, getPositionerId, getTitleEl, getTitleId, getTriggerEl, getTriggerEls, getTriggerId };
|
|
1
|
+
import { Scope } from "@zag-js/core";
|
|
2
|
+
export declare const getAnchorId: (scope: Scope) => any;
|
|
3
|
+
export declare const getTriggerId: (scope: Scope, value?: string) => any;
|
|
4
|
+
export declare const getContentId: (scope: Scope) => any;
|
|
5
|
+
export declare const getPositionerId: (scope: Scope) => any;
|
|
6
|
+
export declare const getArrowId: (scope: Scope) => any;
|
|
7
|
+
export declare const getTitleId: (scope: Scope) => any;
|
|
8
|
+
export declare const getDescriptionId: (scope: Scope) => any;
|
|
9
|
+
export declare const getCloseTriggerId: (scope: Scope) => any;
|
|
10
|
+
export declare const getAnchorEl: (scope: Scope) => HTMLElement | null;
|
|
11
|
+
export declare const getTriggerEl: (scope: Scope) => HTMLElement | null;
|
|
12
|
+
export declare const getTriggerEls: (scope: Scope) => HTMLElement[];
|
|
13
|
+
export declare const getActiveTriggerEl: (scope: Scope, value: string | null) => HTMLElement | null;
|
|
14
|
+
export declare const getContentEl: (scope: Scope) => HTMLElement | null;
|
|
15
|
+
export declare const getPositionerEl: (scope: Scope) => HTMLElement | null;
|
|
16
|
+
export declare const getTitleEl: (scope: Scope) => HTMLElement | null;
|
|
17
|
+
export declare const getDescriptionEl: (scope: Scope) => HTMLElement | null;
|
|
18
|
+
export declare const getFocusableEls: (scope: Scope) => HTMLElement[];
|
|
19
|
+
export declare const getFirstFocusableEl: (scope: Scope) => HTMLElement;
|
package/dist/popover.dom.d.ts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import { Scope } from
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const
|
|
9
|
-
declare const
|
|
10
|
-
declare const
|
|
11
|
-
declare const
|
|
12
|
-
declare const
|
|
13
|
-
declare const
|
|
14
|
-
declare const
|
|
15
|
-
declare const
|
|
16
|
-
declare const
|
|
17
|
-
declare const
|
|
18
|
-
declare const
|
|
19
|
-
declare const
|
|
20
|
-
declare const getFirstFocusableEl: (scope: Scope) => HTMLElement;
|
|
21
|
-
|
|
22
|
-
export { getActiveTriggerEl, getAnchorEl, getAnchorId, getArrowId, getCloseTriggerId, getContentEl, getContentId, getDescriptionEl, getDescriptionId, getFirstFocusableEl, getFocusableEls, getPositionerEl, getPositionerId, getTitleEl, getTitleId, getTriggerEl, getTriggerEls, getTriggerId };
|
|
1
|
+
import { Scope } from "@zag-js/core";
|
|
2
|
+
export declare const getAnchorId: (scope: Scope) => any;
|
|
3
|
+
export declare const getTriggerId: (scope: Scope, value?: string) => any;
|
|
4
|
+
export declare const getContentId: (scope: Scope) => any;
|
|
5
|
+
export declare const getPositionerId: (scope: Scope) => any;
|
|
6
|
+
export declare const getArrowId: (scope: Scope) => any;
|
|
7
|
+
export declare const getTitleId: (scope: Scope) => any;
|
|
8
|
+
export declare const getDescriptionId: (scope: Scope) => any;
|
|
9
|
+
export declare const getCloseTriggerId: (scope: Scope) => any;
|
|
10
|
+
export declare const getAnchorEl: (scope: Scope) => HTMLElement | null;
|
|
11
|
+
export declare const getTriggerEl: (scope: Scope) => HTMLElement | null;
|
|
12
|
+
export declare const getTriggerEls: (scope: Scope) => HTMLElement[];
|
|
13
|
+
export declare const getActiveTriggerEl: (scope: Scope, value: string | null) => HTMLElement | null;
|
|
14
|
+
export declare const getContentEl: (scope: Scope) => HTMLElement | null;
|
|
15
|
+
export declare const getPositionerEl: (scope: Scope) => HTMLElement | null;
|
|
16
|
+
export declare const getTitleEl: (scope: Scope) => HTMLElement | null;
|
|
17
|
+
export declare const getDescriptionEl: (scope: Scope) => HTMLElement | null;
|
|
18
|
+
export declare const getFocusableEls: (scope: Scope) => HTMLElement[];
|
|
19
|
+
export declare const getFirstFocusableEl: (scope: Scope) => HTMLElement;
|
package/dist/popover.dom.js
CHANGED
|
@@ -1,92 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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);
|
|
19
|
-
|
|
20
|
-
// src/popover.dom.ts
|
|
21
|
-
var popover_dom_exports = {};
|
|
22
|
-
__export(popover_dom_exports, {
|
|
23
|
-
getActiveTriggerEl: () => getActiveTriggerEl,
|
|
24
|
-
getAnchorEl: () => getAnchorEl,
|
|
25
|
-
getAnchorId: () => getAnchorId,
|
|
26
|
-
getArrowId: () => getArrowId,
|
|
27
|
-
getCloseTriggerId: () => getCloseTriggerId,
|
|
28
|
-
getContentEl: () => getContentEl,
|
|
29
|
-
getContentId: () => getContentId,
|
|
30
|
-
getDescriptionEl: () => getDescriptionEl,
|
|
31
|
-
getDescriptionId: () => getDescriptionId,
|
|
32
|
-
getFirstFocusableEl: () => getFirstFocusableEl,
|
|
33
|
-
getFocusableEls: () => getFocusableEls,
|
|
34
|
-
getPositionerEl: () => getPositionerEl,
|
|
35
|
-
getPositionerId: () => getPositionerId,
|
|
36
|
-
getTitleEl: () => getTitleEl,
|
|
37
|
-
getTitleId: () => getTitleId,
|
|
38
|
-
getTriggerEl: () => getTriggerEl,
|
|
39
|
-
getTriggerEls: () => getTriggerEls,
|
|
40
|
-
getTriggerId: () => getTriggerId
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
41
4
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
5
|
+
let _zag_js_dom_query = require("@zag-js/dom-query");
|
|
6
|
+
let _zag_js_utils = require("@zag-js/utils");
|
|
7
|
+
// src/popover.dom.ts
|
|
8
|
+
const getAnchorId = (scope) => scope.ids?.anchor ?? `popover:${scope.id}:anchor`;
|
|
9
|
+
const getTriggerId = (scope, value) => {
|
|
10
|
+
const customId = scope.ids?.trigger;
|
|
11
|
+
if (customId != null) return (0, _zag_js_utils.isFunction)(customId) ? customId(value) : customId;
|
|
12
|
+
return value ? `popover:${scope.id}:trigger:${value}` : `popover:${scope.id}:trigger`;
|
|
50
13
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
return scope.getById(getTriggerId(scope, value));
|
|
14
|
+
const getContentId = (scope) => scope.ids?.content ?? `popover:${scope.id}:content`;
|
|
15
|
+
const getPositionerId = (scope) => scope.ids?.positioner ?? `popover:${scope.id}:popper`;
|
|
16
|
+
const getArrowId = (scope) => scope.ids?.arrow ?? `popover:${scope.id}:arrow`;
|
|
17
|
+
const getTitleId = (scope) => scope.ids?.title ?? `popover:${scope.id}:title`;
|
|
18
|
+
const getDescriptionId = (scope) => scope.ids?.description ?? `popover:${scope.id}:desc`;
|
|
19
|
+
const getCloseTriggerId = (scope) => scope.ids?.closeTrigger ?? `popover:${scope.id}:close`;
|
|
20
|
+
const getAnchorEl = (scope) => scope.getById(getAnchorId(scope));
|
|
21
|
+
const getTriggerEl = (scope) => scope.getById(getTriggerId(scope));
|
|
22
|
+
const getTriggerEls = (scope) => (0, _zag_js_dom_query.queryAll)(scope.getRootNode(), `[data-scope="popover"][data-part="trigger"]${(0, _zag_js_dom_query.getByOwnerId)(scope.id)}`);
|
|
23
|
+
const getActiveTriggerEl = (scope, value) => {
|
|
24
|
+
if (value == null) return getTriggerEl(scope) ?? getTriggerEls(scope)[0];
|
|
25
|
+
return scope.getById(getTriggerId(scope, value));
|
|
65
26
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
getTriggerEls,
|
|
91
|
-
getTriggerId
|
|
92
|
-
});
|
|
27
|
+
const getContentEl = (scope) => scope.getById(getContentId(scope));
|
|
28
|
+
const getPositionerEl = (scope) => scope.getById(getPositionerId(scope));
|
|
29
|
+
const getTitleEl = (scope) => scope.getById(getTitleId(scope));
|
|
30
|
+
const getDescriptionEl = (scope) => scope.getById(getDescriptionId(scope));
|
|
31
|
+
const getFocusableEls = (scope) => (0, _zag_js_dom_query.getFocusables)(getContentEl(scope));
|
|
32
|
+
const getFirstFocusableEl = (scope) => getFocusableEls(scope)[0];
|
|
33
|
+
exports.getActiveTriggerEl = getActiveTriggerEl;
|
|
34
|
+
exports.getAnchorEl = getAnchorEl;
|
|
35
|
+
exports.getAnchorId = getAnchorId;
|
|
36
|
+
exports.getArrowId = getArrowId;
|
|
37
|
+
exports.getCloseTriggerId = getCloseTriggerId;
|
|
38
|
+
exports.getContentEl = getContentEl;
|
|
39
|
+
exports.getContentId = getContentId;
|
|
40
|
+
exports.getDescriptionEl = getDescriptionEl;
|
|
41
|
+
exports.getDescriptionId = getDescriptionId;
|
|
42
|
+
exports.getFirstFocusableEl = getFirstFocusableEl;
|
|
43
|
+
exports.getFocusableEls = getFocusableEls;
|
|
44
|
+
exports.getPositionerEl = getPositionerEl;
|
|
45
|
+
exports.getPositionerId = getPositionerId;
|
|
46
|
+
exports.getTitleEl = getTitleEl;
|
|
47
|
+
exports.getTitleId = getTitleId;
|
|
48
|
+
exports.getTriggerEl = getTriggerEl;
|
|
49
|
+
exports.getTriggerEls = getTriggerEls;
|
|
50
|
+
exports.getTriggerId = getTriggerId;
|
package/dist/popover.dom.mjs
CHANGED
|
@@ -1,50 +1,29 @@
|
|
|
1
|
-
// src/popover.dom.ts
|
|
2
1
|
import { getByOwnerId, getFocusables, queryAll } from "@zag-js/dom-query";
|
|
3
2
|
import { isFunction } from "@zag-js/utils";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
var getContentId = (scope) => scope.ids?.content ?? `popover:${scope.id}:content`;
|
|
11
|
-
var getPositionerId = (scope) => scope.ids?.positioner ?? `popover:${scope.id}:popper`;
|
|
12
|
-
var getArrowId = (scope) => scope.ids?.arrow ?? `popover:${scope.id}:arrow`;
|
|
13
|
-
var getTitleId = (scope) => scope.ids?.title ?? `popover:${scope.id}:title`;
|
|
14
|
-
var getDescriptionId = (scope) => scope.ids?.description ?? `popover:${scope.id}:desc`;
|
|
15
|
-
var getCloseTriggerId = (scope) => scope.ids?.closeTrigger ?? `popover:${scope.id}:close`;
|
|
16
|
-
var getAnchorEl = (scope) => scope.getById(getAnchorId(scope));
|
|
17
|
-
var getTriggerEl = (scope) => scope.getById(getTriggerId(scope));
|
|
18
|
-
var getTriggerEls = (scope) => queryAll(scope.getRootNode(), `[data-scope="popover"][data-part="trigger"]${getByOwnerId(scope.id)}`);
|
|
19
|
-
var getActiveTriggerEl = (scope, value) => {
|
|
20
|
-
if (value == null) {
|
|
21
|
-
return getTriggerEl(scope) ?? getTriggerEls(scope)[0];
|
|
22
|
-
}
|
|
23
|
-
return scope.getById(getTriggerId(scope, value));
|
|
3
|
+
// src/popover.dom.ts
|
|
4
|
+
const getAnchorId = (scope) => scope.ids?.anchor ?? `popover:${scope.id}:anchor`;
|
|
5
|
+
const getTriggerId = (scope, value) => {
|
|
6
|
+
const customId = scope.ids?.trigger;
|
|
7
|
+
if (customId != null) return isFunction(customId) ? customId(value) : customId;
|
|
8
|
+
return value ? `popover:${scope.id}:trigger:${value}` : `popover:${scope.id}:trigger`;
|
|
24
9
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
getContentEl,
|
|
38
|
-
getContentId,
|
|
39
|
-
getDescriptionEl,
|
|
40
|
-
getDescriptionId,
|
|
41
|
-
getFirstFocusableEl,
|
|
42
|
-
getFocusableEls,
|
|
43
|
-
getPositionerEl,
|
|
44
|
-
getPositionerId,
|
|
45
|
-
getTitleEl,
|
|
46
|
-
getTitleId,
|
|
47
|
-
getTriggerEl,
|
|
48
|
-
getTriggerEls,
|
|
49
|
-
getTriggerId
|
|
10
|
+
const getContentId = (scope) => scope.ids?.content ?? `popover:${scope.id}:content`;
|
|
11
|
+
const getPositionerId = (scope) => scope.ids?.positioner ?? `popover:${scope.id}:popper`;
|
|
12
|
+
const getArrowId = (scope) => scope.ids?.arrow ?? `popover:${scope.id}:arrow`;
|
|
13
|
+
const getTitleId = (scope) => scope.ids?.title ?? `popover:${scope.id}:title`;
|
|
14
|
+
const getDescriptionId = (scope) => scope.ids?.description ?? `popover:${scope.id}:desc`;
|
|
15
|
+
const getCloseTriggerId = (scope) => scope.ids?.closeTrigger ?? `popover:${scope.id}:close`;
|
|
16
|
+
const getAnchorEl = (scope) => scope.getById(getAnchorId(scope));
|
|
17
|
+
const getTriggerEl = (scope) => scope.getById(getTriggerId(scope));
|
|
18
|
+
const getTriggerEls = (scope) => queryAll(scope.getRootNode(), `[data-scope="popover"][data-part="trigger"]${getByOwnerId(scope.id)}`);
|
|
19
|
+
const getActiveTriggerEl = (scope, value) => {
|
|
20
|
+
if (value == null) return getTriggerEl(scope) ?? getTriggerEls(scope)[0];
|
|
21
|
+
return scope.getById(getTriggerId(scope, value));
|
|
50
22
|
};
|
|
23
|
+
const getContentEl = (scope) => scope.getById(getContentId(scope));
|
|
24
|
+
const getPositionerEl = (scope) => scope.getById(getPositionerId(scope));
|
|
25
|
+
const getTitleEl = (scope) => scope.getById(getTitleId(scope));
|
|
26
|
+
const getDescriptionEl = (scope) => scope.getById(getDescriptionId(scope));
|
|
27
|
+
const getFocusableEls = (scope) => getFocusables(getContentEl(scope));
|
|
28
|
+
const getFirstFocusableEl = (scope) => getFocusableEls(scope)[0];
|
|
29
|
+
export { getActiveTriggerEl, getAnchorEl, getAnchorId, getArrowId, getCloseTriggerId, getContentEl, getContentId, getDescriptionEl, getDescriptionId, getFirstFocusableEl, getFocusableEls, getPositionerEl, getPositionerId, getTitleEl, getTitleId, getTriggerEl, getTriggerEls, getTriggerId };
|
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import '@zag-js/dismissable';
|
|
4
|
-
import '@zag-js/popper';
|
|
5
|
-
import '@zag-js/types';
|
|
6
|
-
|
|
7
|
-
declare const machine: _zag_js_core.Machine<PopoverSchema>;
|
|
8
|
-
|
|
9
|
-
export { machine };
|
|
1
|
+
import { PopoverSchema } from "./popover.types.mjs";
|
|
2
|
+
export declare const machine: import("@zag-js/core").Machine<PopoverSchema>;
|