beez-ui 0.8.2 → 0.9.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +11 -9
  3. package/dist/components/filter-presets-bar.d.ts +71 -0
  4. package/dist/components/filter-presets-bar.js +508 -0
  5. package/dist/components/reaction-button.d.ts +7 -2
  6. package/dist/components/reaction-button.js +59 -48
  7. package/dist/hooks.d.ts +10 -0
  8. package/dist/hooks.js +10 -0
  9. package/dist/index.d.ts +1 -23
  10. package/dist/index.js +1 -23
  11. package/dist/styles.css +1 -1
  12. package/package.json +11 -126
  13. package/dist/components/bouncing-dots-loader.d.ts +0 -19
  14. package/dist/components/bouncing-dots-loader.js +0 -47
  15. package/dist/components/confirm-delete-button.d.ts +0 -29
  16. package/dist/components/confirm-delete-button.js +0 -254
  17. package/dist/components/empty-state.d.ts +0 -24
  18. package/dist/components/empty-state.js +0 -37
  19. package/dist/components/error-state.d.ts +0 -20
  20. package/dist/components/error-state.js +0 -145
  21. package/dist/components/external-browser-handoff.d.ts +0 -27
  22. package/dist/components/external-browser-handoff.js +0 -306
  23. package/dist/components/info-popover.d.ts +0 -23
  24. package/dist/components/info-popover.js +0 -158
  25. package/dist/components/month-calendar-header.d.ts +0 -65
  26. package/dist/components/month-calendar-header.js +0 -337
  27. package/dist/components/month-grid.d.ts +0 -59
  28. package/dist/components/month-grid.js +0 -301
  29. package/dist/components/notification-bell.d.ts +0 -50
  30. package/dist/components/notification-bell.js +0 -338
  31. package/dist/components/notification-panel.d.ts +0 -56
  32. package/dist/components/notification-panel.js +0 -281
  33. package/dist/components/open-in-browser-cta.d.ts +0 -22
  34. package/dist/components/open-in-browser-cta.js +0 -61
  35. package/dist/components/pwa-update-control.d.ts +0 -18
  36. package/dist/components/pwa-update-control.js +0 -119
  37. package/dist/emoji-picker.d.ts +0 -27
  38. package/dist/emoji-picker.js +0 -283
  39. package/dist/hooks/use-minute-clock.d.ts +0 -23
  40. package/dist/hooks/use-minute-clock.js +0 -147
  41. package/dist/hooks/use-month-transition-direction.d.ts +0 -21
  42. package/dist/hooks/use-month-transition-direction.js +0 -110
  43. package/dist/lib/browser-navigation.d.ts +0 -21
  44. package/dist/lib/browser-navigation.js +0 -42
  45. package/dist/lib/in-app-browser.d.ts +0 -35
  46. package/dist/lib/in-app-browser.js +0 -80
  47. package/dist/lib/month-grid.d.ts +0 -42
  48. package/dist/lib/month-grid.js +0 -74
@@ -1,145 +0,0 @@
1
- "use client";
2
- import { c as _c } from "react/compiler-runtime";
3
- import { cn } from "../lib/utils.js";
4
- import { Button } from "./button.js";
5
- import { Link } from "./link.js";
6
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
- /** Copy and actions settle in one after another; reduced motion drops it through the shared fallback. */
8
- const ENTER_CLASS_NAME = "animate-in fade-in slide-in-from-bottom-1.5 fill-mode-both duration-300";
9
- /**
10
- * Renders a full-height section with the error copy, a retry button and an optional way home.
11
- * The home link uses the router adapter configured in `BeezUIProvider`.
12
- * @param props - Copy, retry callback and optional home destination.
13
- * @returns The error view.
14
- */
15
- export function ErrorState(t0) {
16
- const $ = _c(26);
17
- const { eyebrow, title, description, retryLabel, onRetry, homeHref, homeLabel, className } = t0;
18
- let t1;
19
- if ($[0] !== className) {
20
- t1 = cn("relative isolate grid h-full min-h-svh w-full content-center justify-items-start gap-5 overflow-hidden bg-background p-[clamp(2rem,5vw,5rem)] text-foreground", className);
21
- $[0] = className;
22
- $[1] = t1;
23
- } else {
24
- t1 = $[1];
25
- }
26
- let t2;
27
- if ($[2] !== eyebrow) {
28
- t2 = eyebrow ? /* @__PURE__ */ _jsx("p", {
29
- className: cn("m-0 font-mono text-[0.8rem] tracking-[0.2em] text-foreground/60 uppercase", ENTER_CLASS_NAME),
30
- children: eyebrow
31
- }) : null;
32
- $[2] = eyebrow;
33
- $[3] = t2;
34
- } else {
35
- t2 = $[3];
36
- }
37
- let t3;
38
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
39
- t3 = cn("m-0 max-w-[14ch] font-display text-[clamp(2.8rem,8vw,5.5rem)] leading-[0.96] font-semibold text-balance sm:max-w-[12ch]", ENTER_CLASS_NAME, "delay-40");
40
- $[4] = t3;
41
- } else {
42
- t3 = $[4];
43
- }
44
- let t4;
45
- if ($[5] !== title) {
46
- t4 = /* @__PURE__ */ _jsx("h1", {
47
- className: t3,
48
- children: title
49
- });
50
- $[5] = title;
51
- $[6] = t4;
52
- } else {
53
- t4 = $[6];
54
- }
55
- let t5;
56
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
57
- t5 = cn("m-0 max-w-[40rem] text-[clamp(1rem,2vw,1.15rem)] leading-[1.75] text-pretty text-muted-foreground", ENTER_CLASS_NAME, "delay-80");
58
- $[7] = t5;
59
- } else {
60
- t5 = $[7];
61
- }
62
- let t6;
63
- if ($[8] !== description) {
64
- t6 = /* @__PURE__ */ _jsx("p", {
65
- className: t5,
66
- children: description
67
- });
68
- $[8] = description;
69
- $[9] = t6;
70
- } else {
71
- t6 = $[9];
72
- }
73
- let t7;
74
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
75
- t7 = cn("flex w-full flex-wrap gap-3.5 pt-2 sm:w-auto", ENTER_CLASS_NAME, "delay-120");
76
- $[10] = t7;
77
- } else {
78
- t7 = $[10];
79
- }
80
- let t8;
81
- if ($[11] !== onRetry || $[12] !== retryLabel) {
82
- t8 = /* @__PURE__ */ _jsx(Button, {
83
- size: "lg",
84
- type: "button",
85
- onClick: onRetry,
86
- children: retryLabel
87
- });
88
- $[11] = onRetry;
89
- $[12] = retryLabel;
90
- $[13] = t8;
91
- } else {
92
- t8 = $[13];
93
- }
94
- let t9;
95
- if ($[14] !== homeHref || $[15] !== homeLabel) {
96
- t9 = homeHref && homeLabel ? /* @__PURE__ */ _jsx(Button, {
97
- asChild: true,
98
- size: "lg",
99
- variant: "outline",
100
- children: /* @__PURE__ */ _jsx(Link, {
101
- href: homeHref,
102
- children: homeLabel
103
- })
104
- }) : null;
105
- $[14] = homeHref;
106
- $[15] = homeLabel;
107
- $[16] = t9;
108
- } else {
109
- t9 = $[16];
110
- }
111
- let t10;
112
- if ($[17] !== t8 || $[18] !== t9) {
113
- t10 = /* @__PURE__ */ _jsxs("div", {
114
- className: t7,
115
- children: [t8, t9]
116
- });
117
- $[17] = t8;
118
- $[18] = t9;
119
- $[19] = t10;
120
- } else {
121
- t10 = $[19];
122
- }
123
- let t11;
124
- if ($[20] !== t1 || $[21] !== t10 || $[22] !== t2 || $[23] !== t4 || $[24] !== t6) {
125
- t11 = /* @__PURE__ */ _jsxs("section", {
126
- "data-slot": "error-state",
127
- className: t1,
128
- children: [
129
- t2,
130
- t4,
131
- t6,
132
- t10
133
- ]
134
- });
135
- $[20] = t1;
136
- $[21] = t10;
137
- $[22] = t2;
138
- $[23] = t4;
139
- $[24] = t6;
140
- $[25] = t11;
141
- } else {
142
- t11 = $[25];
143
- }
144
- return t11;
145
- }
@@ -1,27 +0,0 @@
1
- export interface ExternalBrowserHandoffCopy {
2
- eyebrow?: string;
3
- title: string;
4
- description: string;
5
- countdownDescription: string;
6
- primaryAction: string;
7
- fallbackLink: string;
8
- }
9
- export interface ExternalBrowserHandoffProps {
10
- /** Deep link that opens the page in the default browser (see `buildExternalBrowserUrl`). */
11
- externalBrowserUrl: string;
12
- /** In-app destination used when the deep link does not open another app. */
13
- fallbackUrl: string;
14
- countdownSeconds?: number;
15
- copy?: Partial<ExternalBrowserHandoffCopy>;
16
- /** Navigates to the fallback. Defaults to a full browser navigation. */
17
- onFallback?: (fallbackUrl: string) => void;
18
- className?: string;
19
- }
20
- /**
21
- * Counts down and then follows `fallbackUrl`, unless the page was hidden because the external
22
- * browser opened. Repeated taps on the primary action restart one fallback window instead of
23
- * stacking redirects.
24
- * @param props - Deep link, fallback, countdown and copy.
25
- * @returns The handoff section.
26
- */
27
- export declare function ExternalBrowserHandoff({ externalBrowserUrl, fallbackUrl, countdownSeconds, copy, onFallback, className, }: ExternalBrowserHandoffProps): import("react").JSX.Element;
@@ -1,306 +0,0 @@
1
- "use client";
2
- import { c as _c } from "react/compiler-runtime";
3
- /**
4
- * Full-page handoff for in-app browsers: a primary action opens the page in the default browser
5
- * through a deep link, and a countdown falls back to an in-app URL when the deep link does not take.
6
- */
7
- import { useEffect, useRef, useState } from "react";
8
- import { cn } from "../lib/utils.js";
9
- import { navigateToUrl } from "../lib/browser-navigation.js";
10
- import { AnimatedCount } from "./animated-count.js";
11
- import { Button } from "./button.js";
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- const DEFAULT_COUNTDOWN_SECONDS = 5;
14
- const COUNTDOWN_INTERVAL_MS = 1e3;
15
- /** After tapping the deep link, the page must still be visible this long to count as a failure. */
16
- const DEEP_LINK_FALLBACK_DELAY_MS = 2e3;
17
- const VISIBLE_DOCUMENT_STATE = "visible";
18
- /** Staggered entrance; `backwards` releases the properties so press and disabled styles keep working. */
19
- const ENTER_CLASS_NAME = "animate-in fade-in slide-in-from-bottom-1.5 fill-mode-backwards duration-300";
20
- const EXTERNAL_BROWSER_HANDOFF_DEFAULT_COPY = {
21
- title: "Abrí este sitio en tu navegador",
22
- description: "Para continuar, abrí este sitio en tu navegador habitual.",
23
- countdownDescription: "Cuando el contador llegue a 0, vas a continuar acá mismo.",
24
- primaryAction: "Continuar en tu navegador",
25
- fallbackLink: "O continuá acá"
26
- };
27
- /**
28
- * Counts down and then follows `fallbackUrl`, unless the page was hidden because the external
29
- * browser opened. Repeated taps on the primary action restart one fallback window instead of
30
- * stacking redirects.
31
- * @param props - Deep link, fallback, countdown and copy.
32
- * @returns The handoff section.
33
- */
34
- export function ExternalBrowserHandoff(t0) {
35
- const $ = _c(48);
36
- const { externalBrowserUrl, fallbackUrl, countdownSeconds: t1, copy, onFallback: t2, className } = t0;
37
- const countdownSeconds = t1 === undefined ? DEFAULT_COUNTDOWN_SECONDS : t1;
38
- const onFallback = t2 === undefined ? navigateToUrl : t2;
39
- let t3;
40
- if ($[0] !== copy) {
41
- t3 = {
42
- ...EXTERNAL_BROWSER_HANDOFF_DEFAULT_COPY,
43
- ...copy
44
- };
45
- $[0] = copy;
46
- $[1] = t3;
47
- } else {
48
- t3 = $[1];
49
- }
50
- const resolvedCopy = t3;
51
- const automaticFallbackTimeoutIdRef = useRef(null);
52
- const primaryActionFallbackTimeoutIdRef = useRef(null);
53
- const onFallbackRef = useRef(onFallback);
54
- const [remainingSeconds, setRemainingSeconds] = useState(countdownSeconds);
55
- let t4;
56
- let t5;
57
- if ($[2] !== onFallback) {
58
- t4 = () => {
59
- onFallbackRef.current = onFallback;
60
- };
61
- t5 = [onFallback];
62
- $[2] = onFallback;
63
- $[3] = t4;
64
- $[4] = t5;
65
- } else {
66
- t4 = $[3];
67
- t5 = $[4];
68
- }
69
- useEffect(t4, t5);
70
- let t6;
71
- let t7;
72
- if ($[5] !== countdownSeconds || $[6] !== fallbackUrl) {
73
- t6 = () => {
74
- const followFallbackIfVisible = () => {
75
- if (document.visibilityState === VISIBLE_DOCUMENT_STATE) {
76
- onFallbackRef.current(fallbackUrl);
77
- }
78
- };
79
- const countdownIntervalId = window.setInterval(() => {
80
- setRemainingSeconds(_temp);
81
- }, COUNTDOWN_INTERVAL_MS);
82
- automaticFallbackTimeoutIdRef.current = window.setTimeout(() => {
83
- setRemainingSeconds(0);
84
- followFallbackIfVisible();
85
- }, countdownSeconds * COUNTDOWN_INTERVAL_MS);
86
- return () => {
87
- window.clearInterval(countdownIntervalId);
88
- window.clearTimeout(automaticFallbackTimeoutIdRef.current ?? undefined);
89
- automaticFallbackTimeoutIdRef.current = null;
90
- window.clearTimeout(primaryActionFallbackTimeoutIdRef.current ?? undefined);
91
- primaryActionFallbackTimeoutIdRef.current = null;
92
- };
93
- };
94
- t7 = [countdownSeconds, fallbackUrl];
95
- $[5] = countdownSeconds;
96
- $[6] = fallbackUrl;
97
- $[7] = t6;
98
- $[8] = t7;
99
- } else {
100
- t6 = $[7];
101
- t7 = $[8];
102
- }
103
- useEffect(t6, t7);
104
- let t8;
105
- if ($[9] !== fallbackUrl) {
106
- t8 = () => {
107
- window.clearTimeout(automaticFallbackTimeoutIdRef.current ?? undefined);
108
- automaticFallbackTimeoutIdRef.current = null;
109
- window.clearTimeout(primaryActionFallbackTimeoutIdRef.current ?? undefined);
110
- primaryActionFallbackTimeoutIdRef.current = window.setTimeout(() => {
111
- primaryActionFallbackTimeoutIdRef.current = null;
112
- if (document.visibilityState === VISIBLE_DOCUMENT_STATE) {
113
- onFallbackRef.current(fallbackUrl);
114
- }
115
- }, DEEP_LINK_FALLBACK_DELAY_MS);
116
- };
117
- $[9] = fallbackUrl;
118
- $[10] = t8;
119
- } else {
120
- t8 = $[10];
121
- }
122
- const handlePrimaryAction = t8;
123
- let t9;
124
- if ($[11] !== className) {
125
- t9 = cn("grid w-full place-items-center px-5 py-6", className);
126
- $[11] = className;
127
- $[12] = t9;
128
- } else {
129
- t9 = $[12];
130
- }
131
- let t10;
132
- if ($[13] !== resolvedCopy.eyebrow) {
133
- t10 = resolvedCopy.eyebrow ? /* @__PURE__ */ _jsx("p", {
134
- className: cn("m-0 text-[0.78rem] font-bold tracking-[0.05em] text-muted-foreground uppercase", ENTER_CLASS_NAME),
135
- children: resolvedCopy.eyebrow
136
- }) : null;
137
- $[13] = resolvedCopy.eyebrow;
138
- $[14] = t10;
139
- } else {
140
- t10 = $[14];
141
- }
142
- let t11;
143
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
144
- t11 = cn("m-0 text-[clamp(1.75rem,5vw,2.5rem)] leading-[1.15] font-bold text-balance text-foreground", ENTER_CLASS_NAME, "delay-35");
145
- $[15] = t11;
146
- } else {
147
- t11 = $[15];
148
- }
149
- let t12;
150
- if ($[16] !== resolvedCopy.title) {
151
- t12 = /* @__PURE__ */ _jsx("h1", {
152
- className: t11,
153
- children: resolvedCopy.title
154
- });
155
- $[16] = resolvedCopy.title;
156
- $[17] = t12;
157
- } else {
158
- t12 = $[17];
159
- }
160
- let t13;
161
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
162
- t13 = cn("mx-auto my-0 max-w-md text-base leading-relaxed text-pretty text-muted-foreground", ENTER_CLASS_NAME, "delay-70");
163
- $[18] = t13;
164
- } else {
165
- t13 = $[18];
166
- }
167
- let t14;
168
- if ($[19] !== resolvedCopy.description) {
169
- t14 = /* @__PURE__ */ _jsx("p", {
170
- className: t13,
171
- children: resolvedCopy.description
172
- });
173
- $[19] = resolvedCopy.description;
174
- $[20] = t14;
175
- } else {
176
- t14 = $[20];
177
- }
178
- let t15;
179
- if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
180
- t15 = cn("mt-3 mb-2 grid max-w-md justify-items-center gap-2.5", ENTER_CLASS_NAME, "delay-105");
181
- $[21] = t15;
182
- } else {
183
- t15 = $[21];
184
- }
185
- let t16;
186
- if ($[22] !== remainingSeconds) {
187
- t16 = /* @__PURE__ */ _jsx("span", {
188
- className: "inline-flex size-18 items-center justify-center rounded-full bg-foreground text-4xl leading-none font-bold text-background tabular-nums shadow-[0_0_0_0.375rem_color-mix(in_srgb,var(--foreground)_8%,transparent)]",
189
- children: /* @__PURE__ */ _jsx(AnimatedCount, { value: remainingSeconds })
190
- });
191
- $[22] = remainingSeconds;
192
- $[23] = t16;
193
- } else {
194
- t16 = $[23];
195
- }
196
- let t17;
197
- if ($[24] !== resolvedCopy.countdownDescription) {
198
- t17 = /* @__PURE__ */ _jsx("p", {
199
- className: "mx-auto my-0 text-[0.95rem] leading-normal text-pretty text-foreground",
200
- children: resolvedCopy.countdownDescription
201
- });
202
- $[24] = resolvedCopy.countdownDescription;
203
- $[25] = t17;
204
- } else {
205
- t17 = $[25];
206
- }
207
- let t18;
208
- if ($[26] !== t16 || $[27] !== t17) {
209
- t18 = /* @__PURE__ */ _jsxs("div", {
210
- role: "timer",
211
- className: t15,
212
- children: [t16, t17]
213
- });
214
- $[26] = t16;
215
- $[27] = t17;
216
- $[28] = t18;
217
- } else {
218
- t18 = $[28];
219
- }
220
- let t19;
221
- if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
222
- t19 = cn("mt-2 w-full", ENTER_CLASS_NAME, "delay-140");
223
- $[29] = t19;
224
- } else {
225
- t19 = $[29];
226
- }
227
- let t20;
228
- if ($[30] !== externalBrowserUrl || $[31] !== handlePrimaryAction || $[32] !== resolvedCopy.primaryAction) {
229
- t20 = /* @__PURE__ */ _jsx(Button, {
230
- asChild: true,
231
- size: "lg",
232
- className: t19,
233
- children: /* @__PURE__ */ _jsx("a", {
234
- href: externalBrowserUrl,
235
- onClick: handlePrimaryAction,
236
- children: resolvedCopy.primaryAction
237
- })
238
- });
239
- $[30] = externalBrowserUrl;
240
- $[31] = handlePrimaryAction;
241
- $[32] = resolvedCopy.primaryAction;
242
- $[33] = t20;
243
- } else {
244
- t20 = $[33];
245
- }
246
- let t21;
247
- if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
248
- t21 = cn("inline-flex min-h-11 items-center rounded-[calc(var(--radius)-2px)] px-3 py-2 text-[0.9rem] text-muted-foreground underline decoration-current/40 underline-offset-[0.2rem] transition-[color,text-decoration-color] hover:text-foreground hover:decoration-current focus-visible:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", ENTER_CLASS_NAME, "delay-175");
249
- $[34] = t21;
250
- } else {
251
- t21 = $[34];
252
- }
253
- let t22;
254
- if ($[35] !== fallbackUrl || $[36] !== resolvedCopy.fallbackLink) {
255
- t22 = /* @__PURE__ */ _jsx("a", {
256
- className: t21,
257
- href: fallbackUrl,
258
- children: resolvedCopy.fallbackLink
259
- });
260
- $[35] = fallbackUrl;
261
- $[36] = resolvedCopy.fallbackLink;
262
- $[37] = t22;
263
- } else {
264
- t22 = $[37];
265
- }
266
- let t23;
267
- if ($[38] !== t10 || $[39] !== t12 || $[40] !== t14 || $[41] !== t18 || $[42] !== t20 || $[43] !== t22) {
268
- t23 = /* @__PURE__ */ _jsxs("div", {
269
- className: "grid w-full max-w-lg justify-items-center gap-3.5 text-center",
270
- children: [
271
- t10,
272
- t12,
273
- t14,
274
- t18,
275
- t20,
276
- t22
277
- ]
278
- });
279
- $[38] = t10;
280
- $[39] = t12;
281
- $[40] = t14;
282
- $[41] = t18;
283
- $[42] = t20;
284
- $[43] = t22;
285
- $[44] = t23;
286
- } else {
287
- t23 = $[44];
288
- }
289
- let t24;
290
- if ($[45] !== t23 || $[46] !== t9) {
291
- t24 = /* @__PURE__ */ _jsx("section", {
292
- "data-slot": "external-browser-handoff",
293
- className: t9,
294
- children: t23
295
- });
296
- $[45] = t23;
297
- $[46] = t9;
298
- $[47] = t24;
299
- } else {
300
- t24 = $[47];
301
- }
302
- return t24;
303
- }
304
- function _temp(currentRemainingSeconds) {
305
- return Math.max(currentRemainingSeconds - 1, 0);
306
- }
@@ -1,23 +0,0 @@
1
- /** Icon button that toggles a short explanatory message, for inline help next to labels. */
2
- import { type ReactNode } from "react";
3
- export interface InfoPopoverLabels {
4
- /** Accessible name of the close button inside the message. */
5
- close?: string;
6
- /** Accessible name of the icon-only trigger. */
7
- trigger?: string;
8
- }
9
- export interface InfoPopoverProps {
10
- /** Explanation shown inside the popover. */
11
- message: ReactNode;
12
- labels?: InfoPopoverLabels;
13
- side?: "top" | "right" | "bottom" | "left";
14
- className?: string;
15
- contentClassName?: string;
16
- }
17
- /**
18
- * Renders an info icon that opens the message on click or tap, unlike a hover tooltip, so it
19
- * works on touch devices. Escape, an outside click or the close button dismiss it.
20
- * @param props - Message, optional labels, side and class names.
21
- * @returns The trigger with its popover.
22
- */
23
- export declare function InfoPopover({ message, labels, side, className, contentClassName }: InfoPopoverProps): import("react").JSX.Element;
@@ -1,158 +0,0 @@
1
- "use client";
2
- import { c as _c } from "react/compiler-runtime";
3
- /** Icon button that toggles a short explanatory message, for inline help next to labels. */
4
- import { useState } from "react";
5
- import { Info, X } from "lucide-react";
6
- import { cn } from "../lib/utils.js";
7
- import { Button } from "./button.js";
8
- import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
9
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
- const INFO_POPOVER_DEFAULT_LABELS = {
11
- close: "Cerrar ayuda",
12
- trigger: "Más información"
13
- };
14
- /**
15
- * Renders an info icon that opens the message on click or tap, unlike a hover tooltip, so it
16
- * works on touch devices. Escape, an outside click or the close button dismiss it.
17
- * @param props - Message, optional labels, side and class names.
18
- * @returns The trigger with its popover.
19
- */
20
- export function InfoPopover(t0) {
21
- const $ = _c(25);
22
- const { message, labels, side: t1, className, contentClassName } = t0;
23
- const side = t1 === undefined ? "top" : t1;
24
- let t2;
25
- if ($[0] !== labels) {
26
- t2 = {
27
- ...INFO_POPOVER_DEFAULT_LABELS,
28
- ...labels
29
- };
30
- $[0] = labels;
31
- $[1] = t2;
32
- } else {
33
- t2 = $[1];
34
- }
35
- const resolvedLabels = t2;
36
- const [isOpen, setIsOpen] = useState(false);
37
- const t3 = resolvedLabels.trigger;
38
- let t4;
39
- if ($[2] !== className) {
40
- t4 = cn("text-muted-foreground hover:text-foreground aria-expanded:text-foreground", className);
41
- $[2] = className;
42
- $[3] = t4;
43
- } else {
44
- t4 = $[3];
45
- }
46
- let t5;
47
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
48
- t5 = /* @__PURE__ */ _jsx(Info, {
49
- "aria-hidden": "true",
50
- className: "size-[0.95rem]"
51
- });
52
- $[4] = t5;
53
- } else {
54
- t5 = $[4];
55
- }
56
- let t6;
57
- if ($[5] !== resolvedLabels.trigger || $[6] !== t4) {
58
- t6 = /* @__PURE__ */ _jsx(PopoverTrigger, {
59
- asChild: true,
60
- children: /* @__PURE__ */ _jsx(Button, {
61
- "data-slot": "info-popover-trigger",
62
- "aria-label": t3,
63
- className: t4,
64
- size: "icon-xs",
65
- type: "button",
66
- variant: "ghost",
67
- children: t5
68
- })
69
- });
70
- $[5] = resolvedLabels.trigger;
71
- $[6] = t4;
72
- $[7] = t6;
73
- } else {
74
- t6 = $[7];
75
- }
76
- let t7;
77
- if ($[8] !== contentClassName) {
78
- t7 = cn("relative w-[min(20rem,calc(100vw-2rem))] py-3.5 pr-10 pl-3.5", contentClassName);
79
- $[8] = contentClassName;
80
- $[9] = t7;
81
- } else {
82
- t7 = $[9];
83
- }
84
- let t8;
85
- let t9;
86
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
87
- t8 = () => setIsOpen(false);
88
- t9 = /* @__PURE__ */ _jsx(X, {
89
- "aria-hidden": "true",
90
- className: "size-[0.95rem]"
91
- });
92
- $[10] = t8;
93
- $[11] = t9;
94
- } else {
95
- t8 = $[10];
96
- t9 = $[11];
97
- }
98
- let t10;
99
- if ($[12] !== resolvedLabels.close) {
100
- t10 = /* @__PURE__ */ _jsx(Button, {
101
- "aria-label": resolvedLabels.close,
102
- className: "absolute top-2 right-2",
103
- size: "icon-xs",
104
- type: "button",
105
- variant: "ghost",
106
- onClick: t8,
107
- children: t9
108
- });
109
- $[12] = resolvedLabels.close;
110
- $[13] = t10;
111
- } else {
112
- t10 = $[13];
113
- }
114
- let t11;
115
- if ($[14] !== message) {
116
- t11 = /* @__PURE__ */ _jsx("div", {
117
- className: "m-0 text-sm leading-normal text-foreground",
118
- children: message
119
- });
120
- $[14] = message;
121
- $[15] = t11;
122
- } else {
123
- t11 = $[15];
124
- }
125
- let t12;
126
- if ($[16] !== side || $[17] !== t10 || $[18] !== t11 || $[19] !== t7) {
127
- t12 = /* @__PURE__ */ _jsxs(PopoverContent, {
128
- "data-slot": "info-popover-content",
129
- side,
130
- sideOffset: 10,
131
- collisionPadding: 16,
132
- className: t7,
133
- children: [t10, t11]
134
- });
135
- $[16] = side;
136
- $[17] = t10;
137
- $[18] = t11;
138
- $[19] = t7;
139
- $[20] = t12;
140
- } else {
141
- t12 = $[20];
142
- }
143
- let t13;
144
- if ($[21] !== isOpen || $[22] !== t12 || $[23] !== t6) {
145
- t13 = /* @__PURE__ */ _jsxs(Popover, {
146
- open: isOpen,
147
- onOpenChange: setIsOpen,
148
- children: [t6, t12]
149
- });
150
- $[21] = isOpen;
151
- $[22] = t12;
152
- $[23] = t6;
153
- $[24] = t13;
154
- } else {
155
- t13 = $[24];
156
- }
157
- return t13;
158
- }