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