@zag-js/popover 1.43.1 → 1.43.3

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.
@@ -35,11 +35,15 @@ __export(popover_connect_exports, {
35
35
  module.exports = __toCommonJS(popover_connect_exports);
36
36
  var import_dom_query = require("@zag-js/dom-query");
37
37
  var import_popper = require("@zag-js/popper");
38
+ var import_utils = require("@zag-js/utils");
38
39
  var import_popover = require("./popover.anatomy.js");
39
40
  var dom = __toESM(require("./popover.dom.js"));
41
+ var defaultTranslations = {
42
+ closeTriggerLabel: "close"
43
+ };
40
44
  function connect(service, normalize) {
41
45
  const { state, context, send, computed, prop, scope } = service;
42
- const translations = prop("translations");
46
+ const translations = (0, import_utils.mergeWithDefault)(defaultTranslations, prop("translations"));
43
47
  const open = state.matches("open");
44
48
  const currentPlacement = context.get("currentPlacement");
45
49
  const currentPlacementSide = currentPlacement ? (0, import_popper.getPlacementSide)(currentPlacement) : void 0;
@@ -1,11 +1,15 @@
1
1
  // src/popover.connect.ts
2
2
  import { ariaAttr, dataAttr, isLeftClick, isSafari } from "@zag-js/dom-query";
3
3
  import { getPlacementSide, getPlacementStyles } from "@zag-js/popper";
4
+ import { mergeWithDefault } from "@zag-js/utils";
4
5
  import { parts } from "./popover.anatomy.mjs";
5
6
  import * as dom from "./popover.dom.mjs";
7
+ var defaultTranslations = {
8
+ closeTriggerLabel: "close"
9
+ };
6
10
  function connect(service, normalize) {
7
11
  const { state, context, send, computed, prop, scope } = service;
8
- const translations = prop("translations");
12
+ const translations = mergeWithDefault(defaultTranslations, prop("translations"));
9
13
  const open = state.matches("open");
10
14
  const currentPlacement = context.get("currentPlacement");
11
15
  const currentPlacementSide = currentPlacement ? getPlacementSide(currentPlacement) : void 0;
@@ -51,10 +51,6 @@ var machine = (0, import_core.createMachine)({
51
51
  portalled: true,
52
52
  restoreFocus: true,
53
53
  ...props,
54
- translations: {
55
- closeTriggerLabel: "close",
56
- ...props.translations
57
- },
58
54
  positioning: {
59
55
  placement: "bottom",
60
56
  ...props.positioning
@@ -17,10 +17,6 @@ var machine = createMachine({
17
17
  portalled: true,
18
18
  restoreFocus: true,
19
19
  ...props,
20
- translations: {
21
- closeTriggerLabel: "close",
22
- ...props.translations
23
- },
24
20
  positioning: {
25
21
  placement: "bottom",
26
22
  ...props.positioning
@@ -20,16 +20,16 @@ interface TriggerValueChangeDetails {
20
20
  interface IntlTranslations {
21
21
  closeTriggerLabel?: string | undefined;
22
22
  }
23
- type ElementIds = Partial<{
24
- anchor: string;
25
- trigger: string | ((value?: string) => string);
26
- content: string;
27
- title: string;
28
- description: string;
29
- closeTrigger: string;
30
- positioner: string;
31
- arrow: string;
32
- }>;
23
+ interface ElementIds {
24
+ anchor?: string | undefined;
25
+ trigger?: (string | ((value?: string) => string)) | undefined;
26
+ content?: string | undefined;
27
+ title?: string | undefined;
28
+ description?: string | undefined;
29
+ closeTrigger?: string | undefined;
30
+ positioner?: string | undefined;
31
+ arrow?: string | undefined;
32
+ }
33
33
  interface PopoverProps extends CommonProperties, DirectionProperty, DismissableElementHandlers, PersistentElementOptions {
34
34
  /**
35
35
  * Specifies the localized strings that identifies the accessibility elements and their states
@@ -118,7 +118,7 @@ interface PopoverProps extends CommonProperties, DirectionProperty, DismissableE
118
118
  */
119
119
  onTriggerValueChange?: ((details: TriggerValueChangeDetails) => void) | undefined;
120
120
  }
121
- type PropsWithDefault = "closeOnInteractOutside" | "closeOnEscape" | "modal" | "portalled" | "autoFocus" | "restoreFocus" | "positioning" | "translations";
121
+ type PropsWithDefault = "closeOnInteractOutside" | "closeOnEscape" | "modal" | "portalled" | "autoFocus" | "restoreFocus" | "positioning";
122
122
  type ComputedContext = Readonly<{
123
123
  /**
124
124
  * The computed value of `portalled`
@@ -158,7 +158,7 @@ interface TriggerProps {
158
158
  /**
159
159
  * The value that identifies this specific trigger
160
160
  */
161
- value?: string;
161
+ value?: string | undefined;
162
162
  }
163
163
  interface PopoverApi<T extends PropTypes = PropTypes> {
164
164
  /**
@@ -20,16 +20,16 @@ interface TriggerValueChangeDetails {
20
20
  interface IntlTranslations {
21
21
  closeTriggerLabel?: string | undefined;
22
22
  }
23
- type ElementIds = Partial<{
24
- anchor: string;
25
- trigger: string | ((value?: string) => string);
26
- content: string;
27
- title: string;
28
- description: string;
29
- closeTrigger: string;
30
- positioner: string;
31
- arrow: string;
32
- }>;
23
+ interface ElementIds {
24
+ anchor?: string | undefined;
25
+ trigger?: (string | ((value?: string) => string)) | undefined;
26
+ content?: string | undefined;
27
+ title?: string | undefined;
28
+ description?: string | undefined;
29
+ closeTrigger?: string | undefined;
30
+ positioner?: string | undefined;
31
+ arrow?: string | undefined;
32
+ }
33
33
  interface PopoverProps extends CommonProperties, DirectionProperty, DismissableElementHandlers, PersistentElementOptions {
34
34
  /**
35
35
  * Specifies the localized strings that identifies the accessibility elements and their states
@@ -118,7 +118,7 @@ interface PopoverProps extends CommonProperties, DirectionProperty, DismissableE
118
118
  */
119
119
  onTriggerValueChange?: ((details: TriggerValueChangeDetails) => void) | undefined;
120
120
  }
121
- type PropsWithDefault = "closeOnInteractOutside" | "closeOnEscape" | "modal" | "portalled" | "autoFocus" | "restoreFocus" | "positioning" | "translations";
121
+ type PropsWithDefault = "closeOnInteractOutside" | "closeOnEscape" | "modal" | "portalled" | "autoFocus" | "restoreFocus" | "positioning";
122
122
  type ComputedContext = Readonly<{
123
123
  /**
124
124
  * The computed value of `portalled`
@@ -158,7 +158,7 @@ interface TriggerProps {
158
158
  /**
159
159
  * The value that identifies this specific trigger
160
160
  */
161
- value?: string;
161
+ value?: string | undefined;
162
162
  }
163
163
  interface PopoverApi<T extends PropTypes = PropTypes> {
164
164
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/popover",
3
- "version": "1.43.1",
3
+ "version": "1.43.3",
4
4
  "description": "Core logic for the popover widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -29,16 +29,16 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@zag-js/anatomy": "1.43.1",
33
- "@zag-js/aria-hidden": "1.43.1",
34
- "@zag-js/core": "1.43.1",
35
- "@zag-js/dom-query": "1.43.1",
36
- "@zag-js/utils": "1.43.1",
37
- "@zag-js/dismissable": "1.43.1",
38
- "@zag-js/popper": "1.43.1",
39
- "@zag-js/remove-scroll": "1.43.1",
40
- "@zag-js/types": "1.43.1",
41
- "@zag-js/focus-trap": "1.43.1"
32
+ "@zag-js/anatomy": "1.43.3",
33
+ "@zag-js/aria-hidden": "1.43.3",
34
+ "@zag-js/core": "1.43.3",
35
+ "@zag-js/dom-query": "1.43.3",
36
+ "@zag-js/utils": "1.43.3",
37
+ "@zag-js/dismissable": "1.43.3",
38
+ "@zag-js/popper": "1.43.3",
39
+ "@zag-js/remove-scroll": "1.43.3",
40
+ "@zag-js/types": "1.43.3",
41
+ "@zag-js/focus-trap": "1.43.3"
42
42
  },
43
43
  "devDependencies": {
44
44
  "clean-package": "2.2.0"