@versaur/react 1.0.14 → 1.0.16

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,159 @@
1
+ import { jsx as l, jsxs as N } from "react/jsx-runtime";
2
+ import { iconStyles as C, buttonIconStyles as j, filterChipStyles as A } from "@versaur/core/primitive";
3
+ import { LoaderIcon as F, XIcon as _ } from "@versaur/icons";
4
+ import B, { forwardRef as T } from "react";
5
+ import { c as w } from "./cx-B9vmfsc1.js";
6
+ function E(n) {
7
+ return n.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
8
+ }
9
+ function I(n) {
10
+ const t = {};
11
+ for (const [o, e] of Object.entries(n)) {
12
+ if (e == null)
13
+ continue;
14
+ const r = E(o);
15
+ typeof e == "boolean" ? e && (t[`data-${r}`] = (!!e).toString()) : (typeof e == "string" || typeof e == "number") && (t[`data-${r}`] = String(e));
16
+ }
17
+ return t;
18
+ }
19
+ const y = B.forwardRef(function({ intent: t = "inherit", size: o = "inherit", as: e, className: r, ...c }, s) {
20
+ const a = I({ intent: t, size: o });
21
+ return /* @__PURE__ */ l(e, { ref: s, className: w(C.icon, r), ...a, ...c });
22
+ });
23
+ y.displayName = "Icon";
24
+ const $ = T(
25
+ ({
26
+ as: n,
27
+ variant: t = "primary",
28
+ size: o = "medium",
29
+ loading: e = !1,
30
+ disabled: r = !1,
31
+ pressed: c = !1,
32
+ type: s = "button",
33
+ onClick: a,
34
+ iconProps: f = {},
35
+ "aria-label": m,
36
+ className: b,
37
+ ...p
38
+ }, v) => {
39
+ const u = I({
40
+ disabled: r || e,
41
+ loading: e,
42
+ size: o,
43
+ variant: t
44
+ }), d = (h) => {
45
+ if (r || e) {
46
+ h.preventDefault();
47
+ return;
48
+ }
49
+ a == null || a(h);
50
+ };
51
+ return /* @__PURE__ */ l(
52
+ "button",
53
+ {
54
+ ref: v,
55
+ type: s,
56
+ className: w(j["button-icon"], b),
57
+ "aria-label": m,
58
+ "aria-pressed": c ? "true" : void 0,
59
+ "aria-busy": e ? "true" : void 0,
60
+ "aria-disabled": r || e ? "true" : void 0,
61
+ ...u,
62
+ ...p,
63
+ onClick: d,
64
+ children: e ? /* @__PURE__ */ l(y, { as: F, "aria-label": "Loading", "data-loading-icon": "loader" }) : /* @__PURE__ */ l(y, { as: n, ...f })
65
+ }
66
+ );
67
+ }
68
+ );
69
+ $.displayName = "ButtonIcon";
70
+ const g = T(
71
+ ({ disabled: n = !1, onClick: t, maxWidth: o, className: e, children: r, style: c, ...s }, a) => {
72
+ const f = I({ disabled: n }), m = (b) => {
73
+ if (n) {
74
+ b.preventDefault();
75
+ return;
76
+ }
77
+ t == null || t(b);
78
+ };
79
+ return /* @__PURE__ */ N(
80
+ "button",
81
+ {
82
+ ref: a,
83
+ type: "button",
84
+ className: w(A.chip, e),
85
+ style: o ? { "--_max-width": o, ...c } : c,
86
+ "aria-disabled": n ? "true" : void 0,
87
+ onClick: m,
88
+ ...f,
89
+ ...s,
90
+ children: [
91
+ /* @__PURE__ */ l("span", { className: A.label, children: r }),
92
+ /* @__PURE__ */ l(y, { as: _ })
93
+ ]
94
+ }
95
+ );
96
+ }
97
+ );
98
+ g.displayName = "FilterChip";
99
+ const x = 100, i = 16;
100
+ function q(n, t) {
101
+ let o = n.parentElement;
102
+ for (; o; ) {
103
+ const e = o.querySelector(`[data-tooltip-trigger="${t}"]`);
104
+ if (e) return e;
105
+ if (o === document.body) break;
106
+ o = o.parentElement;
107
+ }
108
+ return null;
109
+ }
110
+ function G(n, t, o = x, e) {
111
+ const r = window.innerWidth, c = window.innerHeight, s = {
112
+ top: n.top,
113
+ bottom: c - n.bottom,
114
+ left: n.left,
115
+ right: r - n.right
116
+ };
117
+ if (t) {
118
+ const a = n.left + n.width / 2, f = n.top + n.height / 2, m = [
119
+ // Bottom: check if tooltip fits below trigger
120
+ [
121
+ "bottom",
122
+ s.bottom,
123
+ n.bottom + t.height + i <= c && a - t.width / 2 >= i && a + t.width / 2 <= r - i
124
+ ],
125
+ // Top: check if tooltip fits above trigger
126
+ [
127
+ "top",
128
+ s.top,
129
+ n.top - t.height - i >= 0 && a - t.width / 2 >= i && a + t.width / 2 <= r - i
130
+ ],
131
+ // Right: check if tooltip fits to the right of trigger
132
+ [
133
+ "right",
134
+ s.right,
135
+ n.right + t.width + i <= r && f - t.height / 2 >= i && f + t.height / 2 <= c - i
136
+ ],
137
+ // Left: check if tooltip fits to the left of trigger
138
+ [
139
+ "left",
140
+ s.left,
141
+ n.left - t.width - i >= 0 && f - t.height / 2 >= i && f + t.height / 2 <= c - i
142
+ ]
143
+ ], p = (e ? m.filter(([u]) => e.includes(u)) : m).filter(([u, d, h]) => h);
144
+ return p.length > 0 ? p.find(([d]) => d === "bottom") ? "bottom" : p.reduce((d, h) => h[1] > d[1] ? h : d)[0] : (e ? Object.entries(s).filter(
145
+ ([u]) => e.includes(u)
146
+ ) : Object.entries(s)).reduce((u, d) => d[1] > u[1] ? d : u)[0];
147
+ }
148
+ return s.bottom >= o ? "bottom" : Object.entries(s).reduce(
149
+ (a, f) => f[1] > a[1] ? f : a
150
+ )[0];
151
+ }
152
+ export {
153
+ $ as B,
154
+ g as F,
155
+ y as I,
156
+ G as c,
157
+ q as f,
158
+ I as u
159
+ };
@@ -18,7 +18,7 @@ const c = t(
18
18
  c.displayName = "OverlayFooter";
19
19
  export {
20
20
  i as O,
21
- v as a,
22
- d as b,
23
- c
21
+ c as a,
22
+ v as b,
23
+ d as c
24
24
  };
@@ -43,6 +43,7 @@ import { TextAs } from '@versaur/core/primitive';
43
43
  import { TextIntent } from '@versaur/core/primitive';
44
44
  import { TextSize } from '@versaur/core/primitive';
45
45
  import { TextWeight } from '@versaur/core/primitive';
46
+ import { Tooltip as Tooltip_2 } from '@versaur/core/primitive';
46
47
 
47
48
  export declare const Avatar: ForwardRefExoticComponent<AvatarProps & RefAttributes<HTMLSpanElement>> & {
48
49
  Image: ForwardRefExoticComponent<AvatarImageProps & RefAttributes<HTMLImageElement>>;
@@ -310,6 +311,17 @@ export { DotSize }
310
311
 
311
312
  export { DotVariant }
312
313
 
314
+ export declare const FilterChip: ForwardRefExoticComponent<FilterChipProps & RefAttributes<HTMLButtonElement>>;
315
+
316
+ export declare interface FilterChipProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "disabled"> {
317
+ /** Whether the chip is disabled — prevents click and applies visual muted state */
318
+ disabled?: boolean;
319
+ /** Max width for label truncation (CSS length value, e.g. "12rem", "200px") */
320
+ maxWidth?: string;
321
+ /** Chip label content */
322
+ children: ReactNode;
323
+ }
324
+
313
325
  export declare const Heading: ForwardRefExoticComponent<HeadingProps & RefAttributes<HTMLHeadingElement>>;
314
326
 
315
327
  export { HeadingAs }
@@ -533,7 +545,7 @@ declare interface TooltipGetTriggerPropsOptions {
533
545
  [key: string]: any;
534
546
  }
535
547
 
536
- declare type TooltipPlacement = "top" | "bottom" | "left" | "right";
548
+ declare type TooltipPlacement = Tooltip_2.Placement;
537
549
 
538
550
  export declare interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
539
551
  /**
@@ -554,10 +566,11 @@ export declare interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
554
566
  gap?: number;
555
567
  /**
556
568
  * Tooltip interaction type:
557
- * - "hover" (default): Show on hover, hide on hover away (100ms grace period)
569
+ * - "hover" (default): Show on mouse hover, hide on hover away (100ms grace period)
558
570
  * - "persisted": Show on click, persists until user clicks outside or presses Escape
571
+ * - "focus": Show on focus (Tab key), hide on blur
559
572
  */
560
- type?: "hover" | "persisted";
573
+ type?: "hover" | "persisted" | "focus";
561
574
  }
562
575
 
563
576
  /**
package/dist/primitive.js CHANGED
@@ -1,206 +1,18 @@
1
- import { jsxs as x, jsx as c } from "react/jsx-runtime";
2
- import { buttonStyles as k, headingStyles as R, textStyles as w, avatarStyles as S, loaderStyles as K, badgeStyles as z, bannerStyles as A, dotStyles as C, kbdStyles as O } from "@versaur/core/primitive";
3
- import { LoaderIcon as T, UserIcon as U, XIcon as X } from "@versaur/icons";
4
- import { forwardRef as u, useState as q } from "react";
5
- import { u as b, I as B, B as F } from "./helpers-DTL6qrTe.js";
6
- import { c as p } from "./cx-B9vmfsc1.js";
7
- import { H as ot, T as nt } from "./tooltip-BMKVL6jz.js";
8
- const G = u(
9
- ({
10
- variant: a = "primary",
11
- size: r = "medium",
12
- loading: t = !1,
13
- disabled: e = !1,
14
- pressed: o = !1,
15
- leftIcon: s,
16
- rightIcon: n,
17
- children: l,
18
- type: d = "button",
19
- onClick: y,
20
- className: h,
21
- ...m
22
- }, N) => {
23
- const g = !!s, i = !!n, v = !!l;
24
- let f;
25
- g && i && v ? f = "both-text" : g && v ? f = "left-text" : i && v ? f = "right-text" : g && i ? f = "both" : g ? f = "left" : i && (f = "right");
26
- const H = b({
27
- disabled: e || t,
28
- loading: t,
29
- size: r,
30
- variant: a,
31
- ...f && { iconConfig: f }
32
- }), j = (I) => {
33
- if (e || t) {
34
- I.preventDefault();
35
- return;
36
- }
37
- y == null || y(I);
38
- };
39
- return /* @__PURE__ */ x(
40
- "button",
41
- {
42
- ref: N,
43
- type: d,
44
- className: p(k.button, h),
45
- "aria-pressed": o ? "true" : void 0,
46
- "aria-busy": t ? "true" : void 0,
47
- "aria-disabled": e || t ? "true" : void 0,
48
- ...H,
49
- ...m,
50
- onClick: j,
51
- children: [
52
- t ? /* @__PURE__ */ c(B, { as: T, "aria-label": "Loading", "data-loading-icon": "loader" }) : null,
53
- s,
54
- l,
55
- n
56
- ]
57
- }
58
- );
59
- }
60
- );
61
- G.displayName = "Button";
62
- const J = u(
63
- ({ as: a = "h2", size: r, weight: t, intent: e = "default", case: o, transform: s, children: n, className: l, ...d }, y) => {
64
- const h = a, m = b({
65
- as: a,
66
- case: o,
67
- intent: e,
68
- size: r,
69
- transform: s,
70
- weight: t
71
- });
72
- return /* @__PURE__ */ c(h, { ref: y, className: p(R.heading, l), ...m, ...d, children: n });
73
- }
74
- );
75
- J.displayName = "Heading";
76
- const M = u(
77
- ({ as: a = "p", size: r, weight: t, intent: e = "default", case: o, transform: s, children: n, className: l, ...d }, y) => {
78
- const h = a, m = b({
79
- as: a,
80
- case: o,
81
- intent: e,
82
- size: r,
83
- transform: s,
84
- weight: t
85
- });
86
- return /* @__PURE__ */ c(h, { ref: y, className: p(w.text, l), ...m, ...d, children: n });
87
- }
88
- );
89
- M.displayName = "Text";
90
- const L = u(
91
- ({ variant: a = "primary", size: r = "md", shape: t = "circle", children: e, className: o, ...s }, n) => {
92
- const l = b({ shape: t, size: r, variant: a }), d = e || /* @__PURE__ */ c(B, { as: U });
93
- return /* @__PURE__ */ c("span", { ref: n, className: p(S.avatar, o), role: "img", ...l, ...s, children: d });
94
- }
95
- );
96
- L.displayName = "Avatar";
97
- const D = u(({ src: a, alt: r, onError: t, className: e, ...o }, s) => {
98
- const [n, l] = q(!1);
99
- return n ? null : /* @__PURE__ */ c(
100
- "img",
101
- {
102
- ref: s,
103
- className: p(S["avatar-image"], e),
104
- src: a,
105
- alt: r,
106
- onError: (d) => {
107
- l(!0), t == null || t(d);
108
- },
109
- ...o
110
- }
111
- );
112
- });
113
- D.displayName = "Avatar.Image";
114
- const et = Object.assign(L, {
115
- Image: D
116
- }), P = u(
117
- ({ type: a = "spinner", size: r = "sm", children: t, className: e, ...o }, s) => {
118
- const n = b({
119
- size: r,
120
- type: a
121
- });
122
- return /* @__PURE__ */ x("div", { ref: s, className: p(K.loader, e), ...n, ...o, children: [
123
- a === "spinner" && /* @__PURE__ */ c(B, { as: T, "aria-hidden": "true" }),
124
- t
125
- ] });
126
- }
127
- );
128
- P.displayName = "Loader";
129
- const Q = u(
130
- ({
131
- variant: a = "primary",
132
- size: r = "medium",
133
- shape: t = "rounded",
134
- iconLeft: e,
135
- iconRight: o,
136
- maxWidth: s,
137
- children: n,
138
- style: l,
139
- className: d,
140
- ...y
141
- }, h) => {
142
- const m = !!e, N = !!o, g = !!n;
143
- let i;
144
- m && N && g ? i = "both-text" : m && g ? i = "left-text" : N && g ? i = "right-text" : m && N ? i = "both" : m ? i = "left" : N && (i = "right");
145
- const v = b({
146
- shape: t,
147
- size: r,
148
- variant: a,
149
- ...i && { iconConfig: i }
150
- }), f = {
151
- ...l,
152
- ...s && { "--vers-comp-badge-max-width": s }
153
- };
154
- return /* @__PURE__ */ x("div", { ref: h, className: p(z.badge, d), ...v, ...y, style: f, children: [
155
- e,
156
- n,
157
- o
158
- ] });
159
- }
160
- );
161
- Q.displayName = "Badge";
162
- const V = u(
163
- ({ variant: a = "info", icon: r, onDismiss: t, children: e, className: o, ...s }, n) => {
164
- const l = b({
165
- variant: a
166
- });
167
- return /* @__PURE__ */ x("div", { ref: n, className: p(A.banner, o), ...l, ...s, children: [
168
- r && /* @__PURE__ */ c("div", { className: A.icon, children: r }),
169
- /* @__PURE__ */ c("div", { className: A.content, children: e }),
170
- t && /* @__PURE__ */ c(F, { as: X, variant: "ghost", size: "small", onClick: t, "aria-label": "Dismiss banner" })
171
- ] });
172
- }
173
- );
174
- V.displayName = "Banner";
175
- const Y = u(
176
- ({ variant: a = "primary", size: r = "medium", className: t, ...e }, o) => {
177
- const s = b({
178
- size: r,
179
- variant: a
180
- });
181
- return /* @__PURE__ */ c("span", { ref: o, className: p(C.dot, t), ...s, ...e });
182
- }
183
- );
184
- Y.displayName = "Dot";
185
- const Z = u(
186
- ({ variant: a = "filled", size: r = "md", children: t, className: e, ...o }, s) => {
187
- const n = b({ size: r, variant: a });
188
- return /* @__PURE__ */ c("kbd", { ref: s, className: p(O.kbd, e), ...n, ...o, children: t });
189
- }
190
- );
191
- Z.displayName = "Kbd";
1
+ import { A as o, B as t, a as r, b as e, D as n, H as B, c as d, K as i, L as p, T as c, d as x } from "./tooltip-60d7mYVa.js";
2
+ import { B as I, F as T, I as b } from "./helpers-D23F5WBX.js";
192
3
  export {
193
- et as Avatar,
194
- Q as Badge,
195
- V as Banner,
196
- G as Button,
197
- F as ButtonIcon,
198
- Y as Dot,
199
- J as Heading,
200
- ot as Hr,
201
- B as Icon,
202
- Z as Kbd,
203
- P as Loader,
204
- M as Text,
205
- nt as Tooltip
4
+ o as Avatar,
5
+ t as Badge,
6
+ r as Banner,
7
+ e as Button,
8
+ I as ButtonIcon,
9
+ n as Dot,
10
+ T as FilterChip,
11
+ B as Heading,
12
+ d as Hr,
13
+ b as Icon,
14
+ i as Kbd,
15
+ p as Loader,
16
+ c as Text,
17
+ x as Tooltip
206
18
  };