@mekari/pixel3-tooltip 0.0.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.
package/dist/index.js ADDED
@@ -0,0 +1,373 @@
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.tsx
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ MpTooltip: () => MpTooltip,
25
+ PixelTooltipDirective: () => PixelTooltipDirective
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/tooltip.tsx
30
+ var import_vue3 = require("vue");
31
+ var import_vue4 = require("vue");
32
+
33
+ // src/modules/tooltip.hooks.ts
34
+ var import_vue = require("@floating-ui/vue");
35
+ var import_pixel3_utils = require("@mekari/pixel3-utils");
36
+ var import_vue2 = require("vue");
37
+ var import_recipes = require("@mekari/pixel3-styled-system/recipes");
38
+ function useTooltip(props, emit, slots) {
39
+ if (slots.default().length > 1) {
40
+ console.error("[Pixel]: The MpTooltip component only expects one child.");
41
+ }
42
+ const getId = (0, import_vue2.computed)(() => props.id || `tooltip-${(0, import_pixel3_utils.useId)(4)}`);
43
+ const isOpen = (0, import_vue2.ref)(false);
44
+ const triggerNode2 = (0, import_vue2.ref)(null);
45
+ const contentNode = (0, import_vue2.ref)(null);
46
+ const placement = (0, import_vue2.ref)(props.placement);
47
+ const middleware = (0, import_vue2.ref)([(0, import_vue.offset)(4), (0, import_vue.flip)(), (0, import_vue.shift)()]);
48
+ const {
49
+ floatingStyles
50
+ } = (0, import_vue.useFloating)(triggerNode2, contentNode, {
51
+ placement,
52
+ middleware,
53
+ whileElementsMounted: import_vue.autoUpdate
54
+ });
55
+ function onOpenTooltip() {
56
+ setTimeout(() => {
57
+ isOpen.value = true;
58
+ emit("open");
59
+ }, props.showDelay);
60
+ }
61
+ __name(onOpenTooltip, "onOpenTooltip");
62
+ function onCloseTooltip() {
63
+ setTimeout(() => {
64
+ isOpen.value = false;
65
+ emit("close");
66
+ }, props.hideDelay);
67
+ }
68
+ __name(onCloseTooltip, "onCloseTooltip");
69
+ const triggerAttrs = (0, import_vue2.computed)(() => {
70
+ return {
71
+ ref: triggerNode2,
72
+ "data-pixel-component": "MpTooltip",
73
+ id: getId.value,
74
+ onMouseover: () => {
75
+ if (props.isManual)
76
+ return;
77
+ onOpenTooltip();
78
+ },
79
+ onMouseleave: () => {
80
+ if (props.isManual)
81
+ return;
82
+ onCloseTooltip();
83
+ },
84
+ onFocus: () => {
85
+ if (props.isManual)
86
+ return;
87
+ onOpenTooltip();
88
+ },
89
+ onBlur: () => {
90
+ if (props.isManual)
91
+ return;
92
+ onCloseTooltip();
93
+ }
94
+ };
95
+ });
96
+ const contentAttrs = (0, import_vue2.computed)(() => {
97
+ return {
98
+ ref: contentNode,
99
+ class: (0, import_recipes.tooltipRecipe)(),
100
+ style: {
101
+ display: isOpen.value ? "unset" : "none",
102
+ ...floatingStyles.value
103
+ }
104
+ };
105
+ });
106
+ (0, import_vue2.watch)(() => props.isOpen, (newValue) => {
107
+ if (props.isManual) {
108
+ isOpen.value = newValue;
109
+ }
110
+ });
111
+ return {
112
+ triggerNode: triggerNode2,
113
+ contentNode,
114
+ triggerAttrs,
115
+ contentAttrs,
116
+ isOpen,
117
+ onOpenTooltip,
118
+ onCloseTooltip
119
+ };
120
+ }
121
+ __name(useTooltip, "useTooltip");
122
+ function useSingletonTooltip(props) {
123
+ const {
124
+ triggerNode: triggerNode2,
125
+ isOpen,
126
+ placement
127
+ } = (0, import_vue2.toRefs)(props);
128
+ const contentNode = (0, import_vue2.ref)(null);
129
+ const middleware = (0, import_vue2.ref)([(0, import_vue.offset)(4), (0, import_vue.flip)(), (0, import_vue.shift)()]);
130
+ const {
131
+ floatingStyles
132
+ } = (0, import_vue.useFloating)(triggerNode2, contentNode, {
133
+ placement,
134
+ middleware,
135
+ whileElementsMounted: import_vue.autoUpdate
136
+ });
137
+ const contentAttrs = (0, import_vue2.computed)(() => {
138
+ return {
139
+ ref: contentNode,
140
+ class: (0, import_recipes.tooltipRecipe)(),
141
+ style: {
142
+ display: (isOpen == null ? void 0 : isOpen.value) ? "unset" : "none",
143
+ ...floatingStyles.value
144
+ }
145
+ };
146
+ });
147
+ return {
148
+ triggerNode: triggerNode2,
149
+ contentNode,
150
+ contentAttrs
151
+ };
152
+ }
153
+ __name(useSingletonTooltip, "useSingletonTooltip");
154
+
155
+ // src/modules/tooltip.props.ts
156
+ var tooltipProps = {
157
+ label: {
158
+ type: String
159
+ },
160
+ placement: {
161
+ type: String,
162
+ default: "top"
163
+ },
164
+ id: {
165
+ type: String
166
+ },
167
+ defaultIsOpen: {
168
+ type: Boolean
169
+ },
170
+ isManual: {
171
+ type: Boolean
172
+ },
173
+ isOpen: {
174
+ type: Boolean
175
+ },
176
+ showDelay: {
177
+ type: Number,
178
+ default: 0
179
+ },
180
+ hideDelay: {
181
+ type: Number,
182
+ default: 0
183
+ },
184
+ usePortal: {
185
+ type: Boolean
186
+ },
187
+ isKeepAlive: {
188
+ type: Boolean,
189
+ default: true
190
+ }
191
+ };
192
+ var singletonTooltipProps = {
193
+ triggerNode: {
194
+ type: [Object],
195
+ default: null
196
+ },
197
+ label: {
198
+ type: String
199
+ },
200
+ placement: {
201
+ type: String,
202
+ default: "right"
203
+ },
204
+ isOpen: {
205
+ type: Boolean
206
+ }
207
+ };
208
+
209
+ // src/tooltip.tsx
210
+ var MpTooltip = (0, import_vue4.defineComponent)({
211
+ name: "MpTooltip",
212
+ inheritAttrs: false,
213
+ props: tooltipProps,
214
+ emits: ["open", "close"],
215
+ setup(props, {
216
+ slots,
217
+ emit
218
+ }) {
219
+ const {
220
+ triggerAttrs,
221
+ contentAttrs,
222
+ isOpen
223
+ } = useTooltip(props, emit, slots);
224
+ return () => {
225
+ const triggerNode2 = (0, import_vue4.cloneVNode)(slots.default()[0], triggerAttrs.value);
226
+ const contentNode = (0, import_vue3.createVNode)("div", contentAttrs.value, [(0, import_vue3.createTextVNode)(" "), slots.label ? slots.label() : props.label, (0, import_vue3.createTextVNode)(" ")]);
227
+ const renderContentNode = props.usePortal ? (0, import_vue3.createVNode)(import_vue4.Teleport, {
228
+ "to": "body"
229
+ }, {
230
+ default: () => [(0, import_vue3.createTextVNode)(" "), contentNode, (0, import_vue3.createTextVNode)(" ")]
231
+ }) : contentNode;
232
+ return (0, import_vue3.createVNode)(import_vue3.Fragment, null, [triggerNode2, props.isKeepAlive ? renderContentNode : isOpen.value ? renderContentNode : null]);
233
+ };
234
+ }
235
+ });
236
+
237
+ // src/v-tooltip.ts
238
+ var import_vue7 = require("vue");
239
+
240
+ // src/singleton-tooltip.tsx
241
+ var import_vue5 = require("vue");
242
+ var import_vue6 = require("vue");
243
+ var MpSingletonTooltip = (0, import_vue6.defineComponent)({
244
+ name: "MpSingletonTooltip",
245
+ inheritAttrs: false,
246
+ props: singletonTooltipProps,
247
+ setup(props, {
248
+ slots
249
+ }) {
250
+ const {
251
+ contentAttrs
252
+ } = useSingletonTooltip(props);
253
+ return () => {
254
+ return props.label ? (0, import_vue5.createVNode)("div", contentAttrs.value, [(0, import_vue5.createTextVNode)(" "), slots.default ? slots.default() : props.label, (0, import_vue5.createTextVNode)(" ")]) : null;
255
+ };
256
+ }
257
+ });
258
+
259
+ // src/v-tooltip.ts
260
+ var directiveApp;
261
+ var triggerNode = (0, import_vue7.ref)(null);
262
+ var timeoutOpen = (0, import_vue7.ref)();
263
+ var timeoutClose = (0, import_vue7.ref)();
264
+ var tooltipState = (0, import_vue7.ref)({
265
+ isOpen: false,
266
+ label: "",
267
+ placement: "top"
268
+ });
269
+ function initTooltipDirectiveApp() {
270
+ if (directiveApp)
271
+ return;
272
+ directiveApp = (0, import_vue7.createApp)({
273
+ devtools: {
274
+ hide: true
275
+ },
276
+ name: "PixelTooltipDirectiveApp",
277
+ render() {
278
+ return (0, import_vue7.h)(MpSingletonTooltip, {
279
+ isOpen: tooltipState.value.isOpen,
280
+ triggerNode,
281
+ label: tooltipState.value.label,
282
+ placement: tooltipState.value.placement
283
+ });
284
+ }
285
+ });
286
+ const mountTarget = document.createElement("div");
287
+ mountTarget.id = "PixelTooltipDirectiveApp";
288
+ document.body.appendChild(mountTarget);
289
+ directiveApp.mount(mountTarget);
290
+ }
291
+ __name(initTooltipDirectiveApp, "initTooltipDirectiveApp");
292
+ var PixelTooltipDirective = {
293
+ mounted: (el, binding) => {
294
+ if (window) {
295
+ initTooltipDirectiveApp();
296
+ }
297
+ const value = binding.value;
298
+ const props = {
299
+ label: typeof binding.value === "string" ? binding.value : value.label,
300
+ placement: value.placement,
301
+ showDelay: value.showDelay,
302
+ hideDelay: value.hideDelay
303
+ };
304
+ el.$pixelTooltip = {
305
+ show: async () => {
306
+ clearTimeout(timeoutOpen.value);
307
+ timeoutOpen.value = setTimeout(async () => {
308
+ triggerNode.value = el;
309
+ tooltipState.value.label = props.label;
310
+ tooltipState.value.placement = props.placement || "top";
311
+ tooltipState.value.isOpen = true;
312
+ }, value.showDelay || 0);
313
+ },
314
+ hide: () => {
315
+ clearTimeout(timeoutClose.value);
316
+ timeoutClose.value = setTimeout(async () => {
317
+ tooltipState.value.isOpen = false;
318
+ tooltipState.value.label = "";
319
+ }, value.hideDelay || 0);
320
+ }
321
+ };
322
+ el.addEventListener("mouseover", el.$pixelTooltip.show);
323
+ el.addEventListener("focus", el.$pixelTooltip.show);
324
+ el.addEventListener("mouseleave", el.$pixelTooltip.hide);
325
+ el.addEventListener("blur", el.$pixelTooltip.hide);
326
+ },
327
+ updated: (el, binding) => {
328
+ if (window) {
329
+ initTooltipDirectiveApp();
330
+ }
331
+ const value = binding.value;
332
+ const props = {
333
+ label: typeof binding.value === "string" ? binding.value : value.label,
334
+ placement: value.placement,
335
+ showDelay: value.showDelay,
336
+ hideDelay: value.hideDelay
337
+ };
338
+ el.$pixelTooltip = {
339
+ show: async () => {
340
+ clearTimeout(timeoutOpen.value);
341
+ timeoutOpen.value = setTimeout(async () => {
342
+ triggerNode.value = el;
343
+ tooltipState.value.label = props.label;
344
+ tooltipState.value.placement = props.placement || "top";
345
+ tooltipState.value.isOpen = true;
346
+ }, value.showDelay || 0);
347
+ },
348
+ hide: () => {
349
+ clearTimeout(timeoutClose.value);
350
+ timeoutClose.value = setTimeout(async () => {
351
+ tooltipState.value.isOpen = false;
352
+ tooltipState.value.label = "";
353
+ }, value.hideDelay || 0);
354
+ }
355
+ };
356
+ el.addEventListener("mouseover", el.$pixelTooltip.show);
357
+ el.addEventListener("focus", el.$pixelTooltip.show);
358
+ el.addEventListener("mouseleave", el.$pixelTooltip.hide);
359
+ el.addEventListener("blur", el.$pixelTooltip.hide);
360
+ },
361
+ beforeUnmount(el) {
362
+ el.removeEventListener("mouseover", el.$pixelTooltip.show);
363
+ el.removeEventListener("focus", el.$pixelTooltip.show);
364
+ el.removeEventListener("mouseleave", el.$pixelTooltip.hide);
365
+ el.removeEventListener("blur", el.$pixelTooltip.hide);
366
+ delete el["$pixelTooltip"];
367
+ }
368
+ };
369
+ // Annotate the CommonJS export names for ESM import in node:
370
+ 0 && (module.exports = {
371
+ MpTooltip,
372
+ PixelTooltipDirective
373
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import {
2
+ MpTooltip
3
+ } from "./chunk-4C7JA7QR.mjs";
4
+ import {
5
+ PixelTooltipDirective
6
+ } from "./chunk-73AMP22F.mjs";
7
+ import "./chunk-JHWDKDBR.mjs";
8
+ import "./chunk-OBETIXOG.mjs";
9
+ import "./chunk-22GSYROL.mjs";
10
+ import "./chunk-QZ7VFGWC.mjs";
11
+ export {
12
+ MpTooltip,
13
+ PixelTooltipDirective
14
+ };
@@ -0,0 +1 @@
1
+ {"inputs":{"src/modules/tooltip.hooks.ts":{"bytes":3101,"imports":[{"path":"@floating-ui/vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/modules/tooltip.props.ts":{"bytes":1707,"imports":[],"format":"esm"},"src/tooltip.tsx":{"bytes":1278,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"src/modules/tooltip.hooks.ts","kind":"import-statement","original":"./modules/tooltip.hooks"},{"path":"src/modules/tooltip.props.ts","kind":"import-statement","original":"./modules/tooltip.props"}],"format":"esm"},"src/singleton-tooltip.tsx":{"bytes":781,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"src/modules/tooltip.props.ts","kind":"import-statement","original":"./modules/tooltip.props"},{"path":"src/modules/tooltip.hooks.ts","kind":"import-statement","original":"./modules/tooltip.hooks"}],"format":"esm"},"src/v-tooltip.ts":{"bytes":4420,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"src/singleton-tooltip.tsx","kind":"import-statement","original":"./singleton-tooltip"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.tsx":{"bytes":176,"imports":[{"path":"src/tooltip.tsx","kind":"import-statement","original":"./tooltip"},{"path":"src/v-tooltip.ts","kind":"import-statement","original":"./v-tooltip"}],"format":"esm"}},"outputs":{"dist/index.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@floating-ui/vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-utils","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/index.tsx","inputs":{"src/index.tsx":{"bytesInOutput":177},"src/tooltip.tsx":{"bytesInOutput":1141},"src/modules/tooltip.hooks.ts":{"bytesInOutput":3417},"src/modules/tooltip.props.ts":{"bytesInOutput":679},"src/v-tooltip.ts":{"bytesInOutput":3695},"src/singleton-tooltip.tsx":{"bytesInOutput":566}},"bytes":10888},"dist/singleton-tooltip.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@floating-ui/vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-utils","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/singleton-tooltip.tsx","inputs":{"src/singleton-tooltip.tsx":{"bytesInOutput":749},"src/modules/tooltip.props.ts":{"bytesInOutput":219},"src/modules/tooltip.hooks.ts":{"bytesInOutput":1096}},"bytes":3191},"dist/tooltip.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@floating-ui/vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-utils","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/tooltip.tsx","inputs":{"src/tooltip.tsx":{"bytesInOutput":1274},"src/modules/tooltip.hooks.ts":{"bytesInOutput":2484},"src/modules/tooltip.props.ts":{"bytesInOutput":460}},"bytes":5316},"dist/v-tooltip.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@floating-ui/vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-utils","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/v-tooltip.ts","inputs":{"src/v-tooltip.ts":{"bytesInOutput":3860},"src/singleton-tooltip.tsx":{"bytesInOutput":566},"src/modules/tooltip.props.ts":{"bytesInOutput":219},"src/modules/tooltip.hooks.ts":{"bytesInOutput":1125}},"bytes":6942},"dist/modules/tooltip.hooks.js":{"imports":[{"path":"@floating-ui/vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-utils","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/modules/tooltip.hooks.ts","inputs":{"src/modules/tooltip.hooks.ts":{"bytesInOutput":3576}},"bytes":4625},"dist/modules/tooltip.props.js":{"imports":[],"exports":[],"entryPoint":"src/modules/tooltip.props.ts","inputs":{"src/modules/tooltip.props.ts":{"bytesInOutput":966}},"bytes":1945}}}
@@ -0,0 +1 @@
1
+ {"inputs":{"src/modules/tooltip.hooks.ts":{"bytes":3101,"imports":[{"path":"@floating-ui/vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/modules/tooltip.props.ts":{"bytes":1707,"imports":[],"format":"esm"},"src/tooltip.tsx":{"bytes":1278,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"src/modules/tooltip.hooks.ts","kind":"import-statement","original":"./modules/tooltip.hooks"},{"path":"src/modules/tooltip.props.ts","kind":"import-statement","original":"./modules/tooltip.props"}],"format":"esm"},"src/singleton-tooltip.tsx":{"bytes":781,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"src/modules/tooltip.props.ts","kind":"import-statement","original":"./modules/tooltip.props"},{"path":"src/modules/tooltip.hooks.ts","kind":"import-statement","original":"./modules/tooltip.hooks"}],"format":"esm"},"src/v-tooltip.ts":{"bytes":4420,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"src/singleton-tooltip.tsx","kind":"import-statement","original":"./singleton-tooltip"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.tsx":{"bytes":176,"imports":[{"path":"src/tooltip.tsx","kind":"import-statement","original":"./tooltip"},{"path":"src/v-tooltip.ts","kind":"import-statement","original":"./v-tooltip"}],"format":"esm"}},"outputs":{"dist/index.mjs":{"imports":[{"path":"dist/chunk-4C7JA7QR.mjs","kind":"import-statement"},{"path":"dist/chunk-73AMP22F.mjs","kind":"import-statement"},{"path":"dist/chunk-JHWDKDBR.mjs","kind":"import-statement"},{"path":"dist/chunk-OBETIXOG.mjs","kind":"import-statement"},{"path":"dist/chunk-22GSYROL.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["MpTooltip","PixelTooltipDirective"],"entryPoint":"src/index.tsx","inputs":{"src/index.tsx":{"bytesInOutput":0}},"bytes":289},"dist/singleton-tooltip.mjs":{"imports":[{"path":"dist/chunk-JHWDKDBR.mjs","kind":"import-statement"},{"path":"dist/chunk-OBETIXOG.mjs","kind":"import-statement"},{"path":"dist/chunk-22GSYROL.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["MpSingletonTooltip"],"entryPoint":"src/singleton-tooltip.tsx","inputs":{},"bytes":187},"dist/tooltip.mjs":{"imports":[{"path":"dist/chunk-4C7JA7QR.mjs","kind":"import-statement"},{"path":"dist/chunk-OBETIXOG.mjs","kind":"import-statement"},{"path":"dist/chunk-22GSYROL.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["MpTooltip"],"entryPoint":"src/tooltip.tsx","inputs":{},"bytes":169},"dist/chunk-4C7JA7QR.mjs":{"imports":[{"path":"dist/chunk-OBETIXOG.mjs","kind":"import-statement"},{"path":"dist/chunk-22GSYROL.mjs","kind":"import-statement"},{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true}],"exports":["MpTooltip"],"inputs":{"src/tooltip.tsx":{"bytesInOutput":1074}},"bytes":1227},"dist/v-tooltip.mjs":{"imports":[{"path":"dist/chunk-73AMP22F.mjs","kind":"import-statement"},{"path":"dist/chunk-JHWDKDBR.mjs","kind":"import-statement"},{"path":"dist/chunk-OBETIXOG.mjs","kind":"import-statement"},{"path":"dist/chunk-22GSYROL.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["PixelTooltipDirective"],"entryPoint":"src/v-tooltip.ts","inputs":{},"bytes":224},"dist/chunk-73AMP22F.mjs":{"imports":[{"path":"dist/chunk-JHWDKDBR.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"},{"path":"vue","kind":"import-statement","external":true}],"exports":["PixelTooltipDirective"],"inputs":{"src/v-tooltip.ts":{"bytesInOutput":3600}},"bytes":3768},"dist/chunk-JHWDKDBR.mjs":{"imports":[{"path":"dist/chunk-OBETIXOG.mjs","kind":"import-statement"},{"path":"dist/chunk-22GSYROL.mjs","kind":"import-statement"},{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true}],"exports":["MpSingletonTooltip"],"inputs":{"src/singleton-tooltip.tsx":{"bytesInOutput":560}},"bytes":750},"dist/modules/tooltip.hooks.mjs":{"imports":[{"path":"dist/chunk-OBETIXOG.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["useSingletonTooltip","useTooltip"],"entryPoint":"src/modules/tooltip.hooks.ts","inputs":{},"bytes":157},"dist/chunk-OBETIXOG.mjs":{"imports":[{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"},{"path":"@floating-ui/vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"import-statement","external":true}],"exports":["useSingletonTooltip","useTooltip"],"inputs":{"src/modules/tooltip.hooks.ts":{"bytesInOutput":2975}},"bytes":3106},"dist/modules/tooltip.props.mjs":{"imports":[{"path":"dist/chunk-22GSYROL.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["singletonTooltipProps","tooltipEmits","tooltipProps"],"entryPoint":"src/modules/tooltip.props.ts","inputs":{},"bytes":197},"dist/chunk-22GSYROL.mjs":{"imports":[],"exports":["singletonTooltipProps","tooltipEmits","tooltipProps"],"inputs":{"src/modules/tooltip.props.ts":{"bytesInOutput":717}},"bytes":818},"dist/chunk-QZ7VFGWC.mjs":{"imports":[],"exports":["__name"],"inputs":{},"bytes":151}}}
@@ -0,0 +1,51 @@
1
+ import { TooltipProps, TooltipEmits, SingletonTooltipProps, MaybeElement } from './tooltip.props.mjs';
2
+ import * as _floating_ui_vue from '@floating-ui/vue';
3
+ import * as vue from 'vue';
4
+ import { Slots } from 'vue';
5
+
6
+ declare function useTooltip(props: TooltipProps, emit: TooltipEmits, slots: Slots): {
7
+ triggerNode: vue.Ref<null>;
8
+ contentNode: vue.Ref<null>;
9
+ triggerAttrs: vue.ComputedRef<{
10
+ ref: vue.Ref<null>;
11
+ 'data-pixel-component': string;
12
+ id: string;
13
+ onMouseover: () => void;
14
+ onMouseleave: () => void;
15
+ onFocus: () => void;
16
+ onBlur: () => void;
17
+ }>;
18
+ contentAttrs: vue.ComputedRef<{
19
+ ref: vue.Ref<null>;
20
+ class: string;
21
+ style: {
22
+ position: _floating_ui_vue.Strategy;
23
+ top: string;
24
+ left: string;
25
+ transform?: string | undefined;
26
+ willChange?: string | undefined;
27
+ display: string;
28
+ };
29
+ }>;
30
+ isOpen: vue.Ref<boolean>;
31
+ onOpenTooltip: () => void;
32
+ onCloseTooltip: () => void;
33
+ };
34
+ declare function useSingletonTooltip(props: SingletonTooltipProps): {
35
+ triggerNode: Readonly<vue.Ref<MaybeElement>>;
36
+ contentNode: vue.Ref<null>;
37
+ contentAttrs: vue.ComputedRef<{
38
+ ref: vue.Ref<null>;
39
+ class: string;
40
+ style: {
41
+ position: _floating_ui_vue.Strategy;
42
+ top: string;
43
+ left: string;
44
+ transform?: string | undefined;
45
+ willChange?: string | undefined;
46
+ display: string;
47
+ };
48
+ }>;
49
+ };
50
+
51
+ export { useSingletonTooltip, useTooltip };
@@ -0,0 +1,51 @@
1
+ import { TooltipProps, TooltipEmits, SingletonTooltipProps, MaybeElement } from './tooltip.props.js';
2
+ import * as _floating_ui_vue from '@floating-ui/vue';
3
+ import * as vue from 'vue';
4
+ import { Slots } from 'vue';
5
+
6
+ declare function useTooltip(props: TooltipProps, emit: TooltipEmits, slots: Slots): {
7
+ triggerNode: vue.Ref<null>;
8
+ contentNode: vue.Ref<null>;
9
+ triggerAttrs: vue.ComputedRef<{
10
+ ref: vue.Ref<null>;
11
+ 'data-pixel-component': string;
12
+ id: string;
13
+ onMouseover: () => void;
14
+ onMouseleave: () => void;
15
+ onFocus: () => void;
16
+ onBlur: () => void;
17
+ }>;
18
+ contentAttrs: vue.ComputedRef<{
19
+ ref: vue.Ref<null>;
20
+ class: string;
21
+ style: {
22
+ position: _floating_ui_vue.Strategy;
23
+ top: string;
24
+ left: string;
25
+ transform?: string | undefined;
26
+ willChange?: string | undefined;
27
+ display: string;
28
+ };
29
+ }>;
30
+ isOpen: vue.Ref<boolean>;
31
+ onOpenTooltip: () => void;
32
+ onCloseTooltip: () => void;
33
+ };
34
+ declare function useSingletonTooltip(props: SingletonTooltipProps): {
35
+ triggerNode: Readonly<vue.Ref<MaybeElement>>;
36
+ contentNode: vue.Ref<null>;
37
+ contentAttrs: vue.ComputedRef<{
38
+ ref: vue.Ref<null>;
39
+ class: string;
40
+ style: {
41
+ position: _floating_ui_vue.Strategy;
42
+ top: string;
43
+ left: string;
44
+ transform?: string | undefined;
45
+ willChange?: string | undefined;
46
+ display: string;
47
+ };
48
+ }>;
49
+ };
50
+
51
+ export { useSingletonTooltip, useTooltip };
@@ -0,0 +1,152 @@
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/modules/tooltip.hooks.ts
22
+ var tooltip_hooks_exports = {};
23
+ __export(tooltip_hooks_exports, {
24
+ useSingletonTooltip: () => useSingletonTooltip,
25
+ useTooltip: () => useTooltip
26
+ });
27
+ module.exports = __toCommonJS(tooltip_hooks_exports);
28
+ var import_vue = require("@floating-ui/vue");
29
+ var import_pixel3_utils = require("@mekari/pixel3-utils");
30
+ var import_vue2 = require("vue");
31
+ var import_recipes = require("@mekari/pixel3-styled-system/recipes");
32
+ function useTooltip(props, emit, slots) {
33
+ if (slots.default().length > 1) {
34
+ console.error("[Pixel]: The MpTooltip component only expects one child.");
35
+ }
36
+ const getId = (0, import_vue2.computed)(() => props.id || `tooltip-${(0, import_pixel3_utils.useId)(4)}`);
37
+ const isOpen = (0, import_vue2.ref)(false);
38
+ const triggerNode = (0, import_vue2.ref)(null);
39
+ const contentNode = (0, import_vue2.ref)(null);
40
+ const placement = (0, import_vue2.ref)(props.placement);
41
+ const middleware = (0, import_vue2.ref)([(0, import_vue.offset)(4), (0, import_vue.flip)(), (0, import_vue.shift)()]);
42
+ const {
43
+ floatingStyles
44
+ } = (0, import_vue.useFloating)(triggerNode, contentNode, {
45
+ placement,
46
+ middleware,
47
+ whileElementsMounted: import_vue.autoUpdate
48
+ });
49
+ function onOpenTooltip() {
50
+ setTimeout(() => {
51
+ isOpen.value = true;
52
+ emit("open");
53
+ }, props.showDelay);
54
+ }
55
+ __name(onOpenTooltip, "onOpenTooltip");
56
+ function onCloseTooltip() {
57
+ setTimeout(() => {
58
+ isOpen.value = false;
59
+ emit("close");
60
+ }, props.hideDelay);
61
+ }
62
+ __name(onCloseTooltip, "onCloseTooltip");
63
+ const triggerAttrs = (0, import_vue2.computed)(() => {
64
+ return {
65
+ ref: triggerNode,
66
+ "data-pixel-component": "MpTooltip",
67
+ id: getId.value,
68
+ onMouseover: () => {
69
+ if (props.isManual)
70
+ return;
71
+ onOpenTooltip();
72
+ },
73
+ onMouseleave: () => {
74
+ if (props.isManual)
75
+ return;
76
+ onCloseTooltip();
77
+ },
78
+ onFocus: () => {
79
+ if (props.isManual)
80
+ return;
81
+ onOpenTooltip();
82
+ },
83
+ onBlur: () => {
84
+ if (props.isManual)
85
+ return;
86
+ onCloseTooltip();
87
+ }
88
+ };
89
+ });
90
+ const contentAttrs = (0, import_vue2.computed)(() => {
91
+ return {
92
+ ref: contentNode,
93
+ class: (0, import_recipes.tooltipRecipe)(),
94
+ style: {
95
+ display: isOpen.value ? "unset" : "none",
96
+ ...floatingStyles.value
97
+ }
98
+ };
99
+ });
100
+ (0, import_vue2.watch)(() => props.isOpen, (newValue) => {
101
+ if (props.isManual) {
102
+ isOpen.value = newValue;
103
+ }
104
+ });
105
+ return {
106
+ triggerNode,
107
+ contentNode,
108
+ triggerAttrs,
109
+ contentAttrs,
110
+ isOpen,
111
+ onOpenTooltip,
112
+ onCloseTooltip
113
+ };
114
+ }
115
+ __name(useTooltip, "useTooltip");
116
+ function useSingletonTooltip(props) {
117
+ const {
118
+ triggerNode,
119
+ isOpen,
120
+ placement
121
+ } = (0, import_vue2.toRefs)(props);
122
+ const contentNode = (0, import_vue2.ref)(null);
123
+ const middleware = (0, import_vue2.ref)([(0, import_vue.offset)(4), (0, import_vue.flip)(), (0, import_vue.shift)()]);
124
+ const {
125
+ floatingStyles
126
+ } = (0, import_vue.useFloating)(triggerNode, contentNode, {
127
+ placement,
128
+ middleware,
129
+ whileElementsMounted: import_vue.autoUpdate
130
+ });
131
+ const contentAttrs = (0, import_vue2.computed)(() => {
132
+ return {
133
+ ref: contentNode,
134
+ class: (0, import_recipes.tooltipRecipe)(),
135
+ style: {
136
+ display: (isOpen == null ? void 0 : isOpen.value) ? "unset" : "none",
137
+ ...floatingStyles.value
138
+ }
139
+ };
140
+ });
141
+ return {
142
+ triggerNode,
143
+ contentNode,
144
+ contentAttrs
145
+ };
146
+ }
147
+ __name(useSingletonTooltip, "useSingletonTooltip");
148
+ // Annotate the CommonJS export names for ESM import in node:
149
+ 0 && (module.exports = {
150
+ useSingletonTooltip,
151
+ useTooltip
152
+ });