@zag-js/tooltip 1.34.1 → 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,119 @@
1
+ import { Machine, EventObject, Service } from '@zag-js/core';
2
+ import { PositioningOptions, Placement } from '@zag-js/popper';
3
+ export { Placement, PositioningOptions } from '@zag-js/popper';
4
+ import { PropTypes, RequiredBy, DirectionProperty, CommonProperties } from '@zag-js/types';
5
+
6
+ interface OpenChangeDetails {
7
+ open: boolean;
8
+ }
9
+ type ElementIds = Partial<{
10
+ trigger: string;
11
+ content: string;
12
+ arrow: string;
13
+ positioner: string;
14
+ }>;
15
+ interface TooltipProps extends DirectionProperty, CommonProperties {
16
+ /**
17
+ * The ids of the elements in the tooltip. Useful for composition.
18
+ */
19
+ ids?: ElementIds | undefined;
20
+ /**
21
+ * The open delay of the tooltip.
22
+ * @default 400
23
+ */
24
+ openDelay?: number | undefined;
25
+ /**
26
+ * The close delay of the tooltip.
27
+ * @default 150
28
+ */
29
+ closeDelay?: number | undefined;
30
+ /**
31
+ * Whether to close the tooltip on pointerdown.
32
+ * @default true
33
+ */
34
+ closeOnPointerDown?: boolean | undefined;
35
+ /**
36
+ * Whether to close the tooltip when the Escape key is pressed.
37
+ * @default true
38
+ */
39
+ closeOnEscape?: boolean | undefined;
40
+ /**
41
+ * Whether the tooltip should close on scroll
42
+ * @default true
43
+ */
44
+ closeOnScroll?: boolean | undefined;
45
+ /**
46
+ * Whether the tooltip should close on click
47
+ * @default true
48
+ */
49
+ closeOnClick?: boolean | undefined;
50
+ /**
51
+ * Whether the tooltip's content is interactive.
52
+ * In this mode, the tooltip will remain open when user hovers over the content.
53
+ * @see https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus
54
+ *
55
+ * @default false
56
+ */
57
+ interactive?: boolean | undefined;
58
+ /**
59
+ * Function called when the tooltip is opened.
60
+ */
61
+ onOpenChange?: ((details: OpenChangeDetails) => void) | undefined;
62
+ /**
63
+ * Custom label for the tooltip.
64
+ */
65
+ "aria-label"?: string | undefined;
66
+ /**
67
+ * The user provided options used to position the popover content
68
+ */
69
+ positioning?: PositioningOptions | undefined;
70
+ /**
71
+ * Whether the tooltip is disabled
72
+ */
73
+ disabled?: boolean | undefined;
74
+ /**
75
+ * The controlled open state of the tooltip
76
+ */
77
+ open?: boolean | undefined;
78
+ /**
79
+ * The initial open state of the tooltip when rendered.
80
+ * Use when you don't need to control the open state of the tooltip.
81
+ */
82
+ defaultOpen?: boolean | undefined;
83
+ }
84
+ type PropsWithDefault = "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "id" | "positioning";
85
+ interface TooltipSchema {
86
+ state: "open" | "closed" | "opening" | "closing";
87
+ props: RequiredBy<TooltipProps, PropsWithDefault>;
88
+ context: {
89
+ currentPlacement: Placement | undefined;
90
+ hasPointerMoveOpened: boolean;
91
+ };
92
+ event: EventObject;
93
+ action: string;
94
+ effect: string;
95
+ guard: string;
96
+ }
97
+ type TooltipService = Service<TooltipSchema>;
98
+ type TooltipMachine = Machine<TooltipSchema>;
99
+ interface TooltipApi<T extends PropTypes = PropTypes> {
100
+ /**
101
+ * Whether the tooltip is open.
102
+ */
103
+ open: boolean;
104
+ /**
105
+ * Function to open the tooltip.
106
+ */
107
+ setOpen: (open: boolean) => void;
108
+ /**
109
+ * Function to reposition the popover
110
+ */
111
+ reposition: (options?: Partial<PositioningOptions>) => void;
112
+ getTriggerProps: () => T["button"];
113
+ getArrowProps: () => T["element"];
114
+ getArrowTipProps: () => T["element"];
115
+ getPositionerProps: () => T["element"];
116
+ getContentProps: () => T["element"];
117
+ }
118
+
119
+ export type { ElementIds, OpenChangeDetails, TooltipApi, TooltipMachine, TooltipProps, TooltipSchema, TooltipService };
@@ -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/tooltip.types.ts
17
+ var tooltip_types_exports = {};
18
+ module.exports = __toCommonJS(tooltip_types_exports);
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/tooltip",
3
- "version": "1.34.1",
3
+ "version": "1.35.0",
4
4
  "description": "Core logic for the tooltip widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -26,18 +26,18 @@
26
26
  "url": "https://github.com/chakra-ui/zag/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@zag-js/anatomy": "1.34.1",
30
- "@zag-js/core": "1.34.1",
31
- "@zag-js/popper": "1.34.1",
32
- "@zag-js/focus-visible": "1.34.1",
33
- "@zag-js/dom-query": "1.34.1",
34
- "@zag-js/utils": "1.34.1",
35
- "@zag-js/types": "1.34.1"
29
+ "@zag-js/anatomy": "1.35.0",
30
+ "@zag-js/core": "1.35.0",
31
+ "@zag-js/popper": "1.35.0",
32
+ "@zag-js/focus-visible": "1.35.0",
33
+ "@zag-js/dom-query": "1.35.0",
34
+ "@zag-js/utils": "1.35.0",
35
+ "@zag-js/types": "1.35.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "clean-package": "2.2.0"
39
39
  },
40
- "clean-package": "../../../clean-package.config.json",
40
+ "clean-package": "./clean-package.config.json",
41
41
  "main": "dist/index.js",
42
42
  "module": "dist/index.mjs",
43
43
  "types": "dist/index.d.ts",
@@ -52,6 +52,16 @@
52
52
  "default": "./dist/index.js"
53
53
  }
54
54
  },
55
+ "./anatomy": {
56
+ "import": {
57
+ "types": "./dist/tooltip.anatomy.d.mts",
58
+ "default": "./dist/tooltip.anatomy.mjs"
59
+ },
60
+ "require": {
61
+ "types": "./dist/tooltip.anatomy.d.ts",
62
+ "default": "./dist/tooltip.anatomy.js"
63
+ }
64
+ },
55
65
  "./package.json": "./package.json"
56
66
  },
57
67
  "scripts": {