@zag-js/popover 1.34.0 → 1.35.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.
@@ -0,0 +1,142 @@
1
+ import { Machine, EventObject, Service } from '@zag-js/core';
2
+ import { DismissableElementHandlers, PersistentElementOptions } from '@zag-js/dismissable';
3
+ import { PositioningOptions, Placement } from '@zag-js/popper';
4
+ export { Placement, PositioningOptions } from '@zag-js/popper';
5
+ import { PropTypes, RequiredBy, CommonProperties, DirectionProperty } from '@zag-js/types';
6
+
7
+ interface OpenChangeDetails {
8
+ open: boolean;
9
+ }
10
+ type ElementIds = Partial<{
11
+ anchor: string;
12
+ trigger: string;
13
+ content: string;
14
+ title: string;
15
+ description: string;
16
+ closeTrigger: string;
17
+ positioner: string;
18
+ arrow: string;
19
+ }>;
20
+ interface PopoverProps extends CommonProperties, DirectionProperty, DismissableElementHandlers, PersistentElementOptions {
21
+ /**
22
+ * The ids of the elements in the popover. Useful for composition.
23
+ */
24
+ ids?: ElementIds | undefined;
25
+ /**
26
+ * Whether the popover should be modal. When set to `true`:
27
+ * - interaction with outside elements will be disabled
28
+ * - only popover content will be visible to screen readers
29
+ * - scrolling is blocked
30
+ * - focus is trapped within the popover
31
+ *
32
+ * @default false
33
+ */
34
+ modal?: boolean | undefined;
35
+ /**
36
+ * Whether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position
37
+ * of the popover content.
38
+ *
39
+ * @default true
40
+ */
41
+ portalled?: boolean | undefined;
42
+ /**
43
+ * Whether to automatically set focus on the first focusable
44
+ * content within the popover when opened.
45
+ *
46
+ * @default true
47
+ */
48
+ autoFocus?: boolean | undefined;
49
+ /**
50
+ * The element to focus on when the popover is opened.
51
+ */
52
+ initialFocusEl?: (() => HTMLElement | null) | undefined;
53
+ /**
54
+ * Whether to close the popover when the user clicks outside of the popover.
55
+ * @default true
56
+ */
57
+ closeOnInteractOutside?: boolean | undefined;
58
+ /**
59
+ * Whether to close the popover when the escape key is pressed.
60
+ * @default true
61
+ */
62
+ closeOnEscape?: boolean | undefined;
63
+ /**
64
+ * Function invoked when the popover opens or closes
65
+ */
66
+ onOpenChange?: ((details: OpenChangeDetails) => void) | undefined;
67
+ /**
68
+ * The user provided options used to position the popover content
69
+ */
70
+ positioning?: PositioningOptions | undefined;
71
+ /**
72
+ * The controlled open state of the popover
73
+ */
74
+ open?: boolean | undefined;
75
+ /**
76
+ * The initial open state of the popover when rendered.
77
+ * Use when you don't need to control the open state of the popover.
78
+ */
79
+ defaultOpen?: boolean | undefined;
80
+ }
81
+ type PropsWithDefault = "closeOnInteractOutside" | "closeOnEscape" | "modal" | "portalled" | "autoFocus" | "positioning";
82
+ type ComputedContext = Readonly<{
83
+ /**
84
+ * The computed value of `portalled`
85
+ */
86
+ currentPortalled: boolean;
87
+ }>;
88
+ interface PrivateContext {
89
+ /**
90
+ * The elements that are rendered on mount
91
+ */
92
+ renderedElements: {
93
+ title: boolean;
94
+ description: boolean;
95
+ };
96
+ /**
97
+ * The computed placement (maybe different from initial placement)
98
+ */
99
+ currentPlacement?: Placement | undefined;
100
+ }
101
+ interface PopoverSchema {
102
+ props: RequiredBy<PopoverProps, PropsWithDefault>;
103
+ state: "open" | "closed";
104
+ context: PrivateContext;
105
+ computed: ComputedContext;
106
+ event: EventObject;
107
+ action: string;
108
+ effect: string;
109
+ guard: string;
110
+ }
111
+ type PopoverService = Service<PopoverSchema>;
112
+ type PopoverMachine = Machine<PopoverSchema>;
113
+ interface PopoverApi<T extends PropTypes = PropTypes> {
114
+ /**
115
+ * Whether the popover is portalled.
116
+ */
117
+ portalled: boolean;
118
+ /**
119
+ * Whether the popover is open
120
+ */
121
+ open: boolean;
122
+ /**
123
+ * Function to open or close the popover
124
+ */
125
+ setOpen: (open: boolean) => void;
126
+ /**
127
+ * Function to reposition the popover
128
+ */
129
+ reposition: (options?: Partial<PositioningOptions>) => void;
130
+ getArrowProps: () => T["element"];
131
+ getArrowTipProps: () => T["element"];
132
+ getAnchorProps: () => T["element"];
133
+ getTriggerProps: () => T["button"];
134
+ getIndicatorProps: () => T["element"];
135
+ getPositionerProps: () => T["element"];
136
+ getContentProps: () => T["element"];
137
+ getTitleProps: () => T["element"];
138
+ getDescriptionProps: () => T["element"];
139
+ getCloseTriggerProps: () => T["button"];
140
+ }
141
+
142
+ export type { ElementIds, OpenChangeDetails, PopoverApi, PopoverMachine, PopoverProps, PopoverSchema, PopoverService };
@@ -0,0 +1,142 @@
1
+ import { Machine, EventObject, Service } from '@zag-js/core';
2
+ import { DismissableElementHandlers, PersistentElementOptions } from '@zag-js/dismissable';
3
+ import { PositioningOptions, Placement } from '@zag-js/popper';
4
+ export { Placement, PositioningOptions } from '@zag-js/popper';
5
+ import { PropTypes, RequiredBy, CommonProperties, DirectionProperty } from '@zag-js/types';
6
+
7
+ interface OpenChangeDetails {
8
+ open: boolean;
9
+ }
10
+ type ElementIds = Partial<{
11
+ anchor: string;
12
+ trigger: string;
13
+ content: string;
14
+ title: string;
15
+ description: string;
16
+ closeTrigger: string;
17
+ positioner: string;
18
+ arrow: string;
19
+ }>;
20
+ interface PopoverProps extends CommonProperties, DirectionProperty, DismissableElementHandlers, PersistentElementOptions {
21
+ /**
22
+ * The ids of the elements in the popover. Useful for composition.
23
+ */
24
+ ids?: ElementIds | undefined;
25
+ /**
26
+ * Whether the popover should be modal. When set to `true`:
27
+ * - interaction with outside elements will be disabled
28
+ * - only popover content will be visible to screen readers
29
+ * - scrolling is blocked
30
+ * - focus is trapped within the popover
31
+ *
32
+ * @default false
33
+ */
34
+ modal?: boolean | undefined;
35
+ /**
36
+ * Whether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position
37
+ * of the popover content.
38
+ *
39
+ * @default true
40
+ */
41
+ portalled?: boolean | undefined;
42
+ /**
43
+ * Whether to automatically set focus on the first focusable
44
+ * content within the popover when opened.
45
+ *
46
+ * @default true
47
+ */
48
+ autoFocus?: boolean | undefined;
49
+ /**
50
+ * The element to focus on when the popover is opened.
51
+ */
52
+ initialFocusEl?: (() => HTMLElement | null) | undefined;
53
+ /**
54
+ * Whether to close the popover when the user clicks outside of the popover.
55
+ * @default true
56
+ */
57
+ closeOnInteractOutside?: boolean | undefined;
58
+ /**
59
+ * Whether to close the popover when the escape key is pressed.
60
+ * @default true
61
+ */
62
+ closeOnEscape?: boolean | undefined;
63
+ /**
64
+ * Function invoked when the popover opens or closes
65
+ */
66
+ onOpenChange?: ((details: OpenChangeDetails) => void) | undefined;
67
+ /**
68
+ * The user provided options used to position the popover content
69
+ */
70
+ positioning?: PositioningOptions | undefined;
71
+ /**
72
+ * The controlled open state of the popover
73
+ */
74
+ open?: boolean | undefined;
75
+ /**
76
+ * The initial open state of the popover when rendered.
77
+ * Use when you don't need to control the open state of the popover.
78
+ */
79
+ defaultOpen?: boolean | undefined;
80
+ }
81
+ type PropsWithDefault = "closeOnInteractOutside" | "closeOnEscape" | "modal" | "portalled" | "autoFocus" | "positioning";
82
+ type ComputedContext = Readonly<{
83
+ /**
84
+ * The computed value of `portalled`
85
+ */
86
+ currentPortalled: boolean;
87
+ }>;
88
+ interface PrivateContext {
89
+ /**
90
+ * The elements that are rendered on mount
91
+ */
92
+ renderedElements: {
93
+ title: boolean;
94
+ description: boolean;
95
+ };
96
+ /**
97
+ * The computed placement (maybe different from initial placement)
98
+ */
99
+ currentPlacement?: Placement | undefined;
100
+ }
101
+ interface PopoverSchema {
102
+ props: RequiredBy<PopoverProps, PropsWithDefault>;
103
+ state: "open" | "closed";
104
+ context: PrivateContext;
105
+ computed: ComputedContext;
106
+ event: EventObject;
107
+ action: string;
108
+ effect: string;
109
+ guard: string;
110
+ }
111
+ type PopoverService = Service<PopoverSchema>;
112
+ type PopoverMachine = Machine<PopoverSchema>;
113
+ interface PopoverApi<T extends PropTypes = PropTypes> {
114
+ /**
115
+ * Whether the popover is portalled.
116
+ */
117
+ portalled: boolean;
118
+ /**
119
+ * Whether the popover is open
120
+ */
121
+ open: boolean;
122
+ /**
123
+ * Function to open or close the popover
124
+ */
125
+ setOpen: (open: boolean) => void;
126
+ /**
127
+ * Function to reposition the popover
128
+ */
129
+ reposition: (options?: Partial<PositioningOptions>) => void;
130
+ getArrowProps: () => T["element"];
131
+ getArrowTipProps: () => T["element"];
132
+ getAnchorProps: () => T["element"];
133
+ getTriggerProps: () => T["button"];
134
+ getIndicatorProps: () => T["element"];
135
+ getPositionerProps: () => T["element"];
136
+ getContentProps: () => T["element"];
137
+ getTitleProps: () => T["element"];
138
+ getDescriptionProps: () => T["element"];
139
+ getCloseTriggerProps: () => T["button"];
140
+ }
141
+
142
+ export type { ElementIds, OpenChangeDetails, PopoverApi, PopoverMachine, PopoverProps, PopoverSchema, PopoverService };
@@ -0,0 +1,18 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/popover.types.ts
17
+ var popover_types_exports = {};
18
+ module.exports = __toCommonJS(popover_types_exports);
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/popover",
3
- "version": "1.34.0",
3
+ "version": "1.35.0",
4
4
  "description": "Core logic for the popover widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -26,21 +26,21 @@
26
26
  "url": "https://github.com/chakra-ui/zag/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@zag-js/anatomy": "1.34.0",
30
- "@zag-js/aria-hidden": "1.34.0",
31
- "@zag-js/core": "1.34.0",
32
- "@zag-js/dom-query": "1.34.0",
33
- "@zag-js/utils": "1.34.0",
34
- "@zag-js/dismissable": "1.34.0",
35
- "@zag-js/popper": "1.34.0",
36
- "@zag-js/remove-scroll": "1.34.0",
37
- "@zag-js/types": "1.34.0",
38
- "@zag-js/focus-trap": "1.34.0"
29
+ "@zag-js/anatomy": "1.35.0",
30
+ "@zag-js/aria-hidden": "1.35.0",
31
+ "@zag-js/core": "1.35.0",
32
+ "@zag-js/dom-query": "1.35.0",
33
+ "@zag-js/utils": "1.35.0",
34
+ "@zag-js/dismissable": "1.35.0",
35
+ "@zag-js/popper": "1.35.0",
36
+ "@zag-js/remove-scroll": "1.35.0",
37
+ "@zag-js/types": "1.35.0",
38
+ "@zag-js/focus-trap": "1.35.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "clean-package": "2.2.0"
42
42
  },
43
- "clean-package": "../../../clean-package.config.json",
43
+ "clean-package": "./clean-package.config.json",
44
44
  "main": "dist/index.js",
45
45
  "module": "dist/index.mjs",
46
46
  "types": "dist/index.d.ts",
@@ -55,6 +55,16 @@
55
55
  "default": "./dist/index.js"
56
56
  }
57
57
  },
58
+ "./anatomy": {
59
+ "import": {
60
+ "types": "./dist/popover.anatomy.d.mts",
61
+ "default": "./dist/popover.anatomy.mjs"
62
+ },
63
+ "require": {
64
+ "types": "./dist/popover.anatomy.d.ts",
65
+ "default": "./dist/popover.anatomy.js"
66
+ }
67
+ },
58
68
  "./package.json": "./package.json"
59
69
  },
60
70
  "scripts": {