@zag-js/popover 0.2.15 → 0.5.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.
@@ -17,7 +17,7 @@ function machine(userContext) {
17
17
  return createMachine(
18
18
  {
19
19
  id: "popover",
20
- initial: ctx.defaultOpen ? "open" : "closed",
20
+ initial: ctx.open ? "open" : "closed",
21
21
  context: {
22
22
  closeOnInteractOutside: true,
23
23
  closeOnEsc: true,
@@ -38,6 +38,9 @@ function machine(userContext) {
38
38
  computed: {
39
39
  currentPortalled: (ctx2) => !!ctx2.modal || !!ctx2.portalled
40
40
  },
41
+ watch: {
42
+ open: ["toggleVisibility"]
43
+ },
41
44
  entry: ["checkRenderedElements"],
42
45
  states: {
43
46
  closed: {
@@ -196,6 +199,9 @@ function machine(userContext) {
196
199
  },
197
200
  invokeOnClose(ctx2) {
198
201
  ctx2.onOpenChange?.(false);
202
+ },
203
+ toggleVisibility(ctx2, _evt, { send }) {
204
+ send({ type: ctx2.open ? "OPEN" : "CLOSE", src: "controlled" });
199
205
  }
200
206
  }
201
207
  }
package/dist/index.js CHANGED
@@ -197,7 +197,7 @@ function machine(userContext) {
197
197
  return (0, import_core.createMachine)(
198
198
  {
199
199
  id: "popover",
200
- initial: ctx.defaultOpen ? "open" : "closed",
200
+ initial: ctx.open ? "open" : "closed",
201
201
  context: {
202
202
  closeOnInteractOutside: true,
203
203
  closeOnEsc: true,
@@ -218,6 +218,9 @@ function machine(userContext) {
218
218
  computed: {
219
219
  currentPortalled: (ctx2) => !!ctx2.modal || !!ctx2.portalled
220
220
  },
221
+ watch: {
222
+ open: ["toggleVisibility"]
223
+ },
221
224
  entry: ["checkRenderedElements"],
222
225
  states: {
223
226
  closed: {
@@ -376,6 +379,9 @@ function machine(userContext) {
376
379
  },
377
380
  invokeOnClose(ctx2) {
378
381
  ctx2.onOpenChange?.(false);
382
+ },
383
+ toggleVisibility(ctx2, _evt, { send }) {
384
+ send({ type: ctx2.open ? "OPEN" : "CLOSE", src: "controlled" });
379
385
  }
380
386
  }
381
387
  }
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-KTOPDXGV.mjs";
7
7
  import {
8
8
  machine
9
- } from "./chunk-NPQGVKMX.mjs";
9
+ } from "./chunk-I6GHRN6K.mjs";
10
10
  import "./chunk-4IGGT6KB.mjs";
11
11
  export {
12
12
  anatomy,
@@ -75,7 +75,7 @@ function machine(userContext) {
75
75
  return (0, import_core.createMachine)(
76
76
  {
77
77
  id: "popover",
78
- initial: ctx.defaultOpen ? "open" : "closed",
78
+ initial: ctx.open ? "open" : "closed",
79
79
  context: {
80
80
  closeOnInteractOutside: true,
81
81
  closeOnEsc: true,
@@ -96,6 +96,9 @@ function machine(userContext) {
96
96
  computed: {
97
97
  currentPortalled: (ctx2) => !!ctx2.modal || !!ctx2.portalled
98
98
  },
99
+ watch: {
100
+ open: ["toggleVisibility"]
101
+ },
99
102
  entry: ["checkRenderedElements"],
100
103
  states: {
101
104
  closed: {
@@ -254,6 +257,9 @@ function machine(userContext) {
254
257
  },
255
258
  invokeOnClose(ctx2) {
256
259
  ctx2.onOpenChange?.(false);
260
+ },
261
+ toggleVisibility(ctx2, _evt, { send }) {
262
+ send({ type: ctx2.open ? "OPEN" : "CLOSE", src: "controlled" });
257
263
  }
258
264
  }
259
265
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  machine
3
- } from "./chunk-NPQGVKMX.mjs";
3
+ } from "./chunk-I6GHRN6K.mjs";
4
4
  import "./chunk-4IGGT6KB.mjs";
5
5
  export {
6
6
  machine
@@ -56,9 +56,9 @@ type PublicContext = DismissableElementHandlers & CommonProperties & {
56
56
  */
57
57
  positioning: PositioningOptions;
58
58
  /**
59
- * Whether to open the popover on page load
59
+ * Whether the popover is open
60
60
  */
61
- defaultOpen?: boolean;
61
+ open?: boolean;
62
62
  };
63
63
  type UserDefinedContext = RequiredBy<PublicContext, "id">;
64
64
  type ComputedContext = Readonly<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/popover",
3
- "version": "0.2.15",
3
+ "version": "0.5.0",
4
4
  "description": "Core logic for the popover widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -29,14 +29,14 @@
29
29
  "focus-trap": "7.4.0",
30
30
  "@zag-js/anatomy": "0.1.4",
31
31
  "@zag-js/aria-hidden": "0.2.2",
32
- "@zag-js/core": "0.2.12",
32
+ "@zag-js/core": "0.5.0",
33
33
  "@zag-js/dom-query": "0.1.4",
34
34
  "@zag-js/utils": "0.3.4",
35
- "@zag-js/dismissable": "0.2.6",
35
+ "@zag-js/dismissable": "0.5.0",
36
+ "@zag-js/tabbable": "0.1.1",
36
37
  "@zag-js/popper": "0.2.7",
37
38
  "@zag-js/remove-scroll": "0.2.4",
38
- "@zag-js/tabbable": "0.1.1",
39
- "@zag-js/types": "0.3.4"
39
+ "@zag-js/types": "0.5.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "clean-package": "2.2.0"