@versaur/react 1.0.12 → 1.0.14
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/blocks.d.ts +1 -117
- package/dist/blocks.js +495 -714
- package/dist/drawer-DRv9k7lp.js +120 -0
- package/dist/forms.d.ts +125 -0
- package/dist/forms.js +618 -321
- package/dist/helpers-DTL6qrTe.js +129 -0
- package/dist/{overlay-parts-Zq9CuT31.js → overlay-parts-CFeD8VN0.js} +3 -3
- package/dist/primitive.d.ts +6 -6
- package/dist/primitive.js +8 -9
- package/dist/tooltip-BMKVL6jz.js +170 -0
- package/dist/utils.d.ts +87 -0
- package/dist/utils.js +62 -5
- package/package.json +2 -2
- package/dist/tooltip-Zuq8gd0f.js +0 -210
- package/dist/use-data-attrs-iPFyfiKN.js +0 -16
package/dist/tooltip-Zuq8gd0f.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
-
import { iconStyles as _, hrStyles as j, buttonIconStyles as H, tooltipStyles as x } from "@versaur/core/primitive";
|
|
3
|
-
import M, { forwardRef as b, useEffect as k, useRef as D } from "react";
|
|
4
|
-
import { u as T } from "./use-data-attrs-iPFyfiKN.js";
|
|
5
|
-
import { c as f } from "./cx-B9vmfsc1.js";
|
|
6
|
-
import { LoaderIcon as F } from "@versaur/icons";
|
|
7
|
-
const y = M.forwardRef(function({ intent: a = "inherit", size: n = "inherit", as: i, className: o, ...t }, e) {
|
|
8
|
-
const r = T({ intent: a, size: n });
|
|
9
|
-
return /* @__PURE__ */ u(i, { ref: e, className: f(_.icon, o), ...r, ...t });
|
|
10
|
-
});
|
|
11
|
-
y.displayName = "Icon";
|
|
12
|
-
const O = b(
|
|
13
|
-
({ orientation: s, variant: a, size: n, spacing: i, className: o, ...t }, e) => {
|
|
14
|
-
const r = T({
|
|
15
|
-
orientation: s,
|
|
16
|
-
size: n,
|
|
17
|
-
spacing: i,
|
|
18
|
-
variant: a
|
|
19
|
-
});
|
|
20
|
-
return /* @__PURE__ */ u(
|
|
21
|
-
"hr",
|
|
22
|
-
{
|
|
23
|
-
ref: e,
|
|
24
|
-
className: f(j.hr, o),
|
|
25
|
-
role: "separator",
|
|
26
|
-
"aria-orientation": s === "vertical" ? "vertical" : void 0,
|
|
27
|
-
...r,
|
|
28
|
-
...t
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
O.displayName = "Hr";
|
|
34
|
-
const U = b(
|
|
35
|
-
({
|
|
36
|
-
as: s,
|
|
37
|
-
variant: a = "primary",
|
|
38
|
-
size: n = "medium",
|
|
39
|
-
loading: i = !1,
|
|
40
|
-
disabled: o = !1,
|
|
41
|
-
pressed: t = !1,
|
|
42
|
-
type: e = "button",
|
|
43
|
-
onClick: r,
|
|
44
|
-
iconProps: p = {},
|
|
45
|
-
"aria-label": c,
|
|
46
|
-
className: m,
|
|
47
|
-
...v
|
|
48
|
-
}, h) => {
|
|
49
|
-
const E = T({
|
|
50
|
-
disabled: o || i,
|
|
51
|
-
loading: i,
|
|
52
|
-
size: n,
|
|
53
|
-
variant: a
|
|
54
|
-
}), L = (d) => {
|
|
55
|
-
if (o || i) {
|
|
56
|
-
d.preventDefault();
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
r == null || r(d);
|
|
60
|
-
};
|
|
61
|
-
return /* @__PURE__ */ u(
|
|
62
|
-
"button",
|
|
63
|
-
{
|
|
64
|
-
ref: h,
|
|
65
|
-
type: e,
|
|
66
|
-
className: f(H["button-icon"], m),
|
|
67
|
-
"aria-label": c,
|
|
68
|
-
"aria-pressed": t ? "true" : void 0,
|
|
69
|
-
"aria-busy": i ? "true" : void 0,
|
|
70
|
-
"aria-disabled": o || i ? "true" : void 0,
|
|
71
|
-
...E,
|
|
72
|
-
...v,
|
|
73
|
-
onClick: L,
|
|
74
|
-
children: i ? /* @__PURE__ */ u(y, { as: F, "aria-label": "Loading", "data-loading-icon": "loader" }) : /* @__PURE__ */ u(y, { as: s, ...p })
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
U.displayName = "ButtonIcon";
|
|
80
|
-
function C({ id: s, tooltipRef: a, placement: n, gap: i, triggerType: o }) {
|
|
81
|
-
k(() => {
|
|
82
|
-
const t = a.current;
|
|
83
|
-
if (!t || !s)
|
|
84
|
-
return;
|
|
85
|
-
let e = null;
|
|
86
|
-
if (t.parentElement && (e = t.parentElement.querySelector(`[data-tooltip-trigger="${s}"]`)), !e) {
|
|
87
|
-
let l = t.parentElement;
|
|
88
|
-
for (; l && !e && (e = l.querySelector(`[data-tooltip-trigger="${s}"]`), !(e || l.classList.contains("sbdocs-story") || l.classList.contains("docblock-storylet"))); )
|
|
89
|
-
l = l.parentElement;
|
|
90
|
-
}
|
|
91
|
-
if (e || (e = document.querySelector(`[data-tooltip-trigger="${s}"]`)), !e)
|
|
92
|
-
return;
|
|
93
|
-
let r = null;
|
|
94
|
-
const p = () => {
|
|
95
|
-
const l = e.getBoundingClientRect(), B = window.innerWidth, $ = window.innerHeight, q = 100, A = {
|
|
96
|
-
top: l.top,
|
|
97
|
-
bottom: $ - l.bottom,
|
|
98
|
-
left: l.left,
|
|
99
|
-
right: B - l.right
|
|
100
|
-
};
|
|
101
|
-
return A.bottom >= q ? "bottom" : Object.entries(A).reduce((I, N) => N[1] > I[1] ? N : I)[0];
|
|
102
|
-
}, c = () => {
|
|
103
|
-
r && (clearTimeout(r), r = null);
|
|
104
|
-
const l = n || p();
|
|
105
|
-
t.dataset.placement = l, t.matches(":popover-open") || t.showPopover();
|
|
106
|
-
}, m = () => {
|
|
107
|
-
r && clearTimeout(r), r = setTimeout(() => {
|
|
108
|
-
t.matches(":popover-open") && t.hidePopover(), r = null;
|
|
109
|
-
}, 100);
|
|
110
|
-
}, v = () => {
|
|
111
|
-
(o === "hover" || o === "all") && c();
|
|
112
|
-
}, h = () => {
|
|
113
|
-
(o === "hover" || o === "all") && m();
|
|
114
|
-
}, E = () => {
|
|
115
|
-
(o === "focus" || o === "all") && c();
|
|
116
|
-
}, L = () => {
|
|
117
|
-
o === "hover" && t.hidePopover();
|
|
118
|
-
}, d = () => {
|
|
119
|
-
o === "focus" && (t.matches(":popover-open") ? t.hidePopover() : c());
|
|
120
|
-
}, S = () => {
|
|
121
|
-
r && (clearTimeout(r), r = null);
|
|
122
|
-
}, w = () => {
|
|
123
|
-
(o === "hover" || o === "all") && m();
|
|
124
|
-
};
|
|
125
|
-
return e.addEventListener("mouseenter", v), e.addEventListener("mouseleave", h), e.addEventListener("focus", E), e.addEventListener("blur", L), e.addEventListener("click", d), t.addEventListener("mouseenter", S), t.addEventListener("mouseleave", w), () => {
|
|
126
|
-
r && clearTimeout(r), e.removeEventListener("mouseenter", v), e.removeEventListener("mouseleave", h), e.removeEventListener("focus", E), e.removeEventListener("blur", L), e.removeEventListener("click", d), t.removeEventListener("mouseenter", S), t.removeEventListener("mouseleave", w);
|
|
127
|
-
};
|
|
128
|
-
}, [s, i, o]);
|
|
129
|
-
}
|
|
130
|
-
function G(...s) {
|
|
131
|
-
return (a) => {
|
|
132
|
-
s.forEach((n) => {
|
|
133
|
-
if (typeof n == "function")
|
|
134
|
-
n(a);
|
|
135
|
-
else if (n && "current" in n)
|
|
136
|
-
try {
|
|
137
|
-
n.current = a;
|
|
138
|
-
} catch {
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
const W = 8, g = b(
|
|
144
|
-
({ id: s, children: a, placement: n, gap: i = W, triggerType: o = "all", style: t, className: e, ...r }, p) => {
|
|
145
|
-
const c = D(null), m = T({
|
|
146
|
-
placement: n
|
|
147
|
-
});
|
|
148
|
-
return C({
|
|
149
|
-
gap: i,
|
|
150
|
-
id: s,
|
|
151
|
-
placement: n,
|
|
152
|
-
tooltipRef: c,
|
|
153
|
-
triggerType: o
|
|
154
|
-
}), /* @__PURE__ */ u(
|
|
155
|
-
"div",
|
|
156
|
-
{
|
|
157
|
-
ref: G(c, p),
|
|
158
|
-
id: s,
|
|
159
|
-
className: f(x.tooltip, e),
|
|
160
|
-
...m,
|
|
161
|
-
style: {
|
|
162
|
-
"--_gap": `${i}px`,
|
|
163
|
-
positionAnchor: `--tooltip-${s}`,
|
|
164
|
-
...t
|
|
165
|
-
},
|
|
166
|
-
...r,
|
|
167
|
-
popover: "auto",
|
|
168
|
-
children: a
|
|
169
|
-
}
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
);
|
|
173
|
-
g.displayName = "Tooltip";
|
|
174
|
-
const R = b(
|
|
175
|
-
({ children: s, maxWidth: a, maxLines: n = 2, style: i, className: o, ...t }, e) => {
|
|
176
|
-
const r = {
|
|
177
|
-
"--_lines": n,
|
|
178
|
-
"--_max-width": a,
|
|
179
|
-
...i
|
|
180
|
-
};
|
|
181
|
-
return /* @__PURE__ */ u("div", { ref: e, className: f(x["tooltip-text"], o), style: r, ...t, children: s });
|
|
182
|
-
}
|
|
183
|
-
);
|
|
184
|
-
R.displayName = "Tooltip.Text";
|
|
185
|
-
function z(s) {
|
|
186
|
-
const { id: a, triggerType: n = "all", ...i } = s, o = {
|
|
187
|
-
"data-tooltip-trigger": a,
|
|
188
|
-
style: { anchorName: `--tooltip-${a}` },
|
|
189
|
-
...Object.fromEntries(Object.entries(i).map(([t, e]) => [t, String(e)]))
|
|
190
|
-
};
|
|
191
|
-
return n !== "focus" && (o.popoverTarget = a), o;
|
|
192
|
-
}
|
|
193
|
-
function J(s) {
|
|
194
|
-
const { id: a } = s, n = document.getElementById(a);
|
|
195
|
-
n && n.matches(":popover-open") && requestAnimationFrame(() => {
|
|
196
|
-
const i = document.querySelector(`[data-tooltip-trigger="${a}"]`);
|
|
197
|
-
i && document.activeElement === i && i.blur(), n.matches(":popover-open") && n.hidePopover();
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
const P = g;
|
|
201
|
-
P.Text = R;
|
|
202
|
-
P.getTooltipTriggerProps = z;
|
|
203
|
-
P.close = J;
|
|
204
|
-
export {
|
|
205
|
-
U as B,
|
|
206
|
-
O as H,
|
|
207
|
-
y as I,
|
|
208
|
-
P as T,
|
|
209
|
-
G as c
|
|
210
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
function r(e) {
|
|
2
|
-
return e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
3
|
-
}
|
|
4
|
-
function i(e) {
|
|
5
|
-
const o = {};
|
|
6
|
-
for (const [a, t] of Object.entries(e)) {
|
|
7
|
-
if (t == null)
|
|
8
|
-
continue;
|
|
9
|
-
const n = r(a);
|
|
10
|
-
typeof t == "boolean" ? t && (o[`data-${n}`] = (!!t).toString()) : (typeof t == "string" || typeof t == "number") && (o[`data-${n}`] = String(t));
|
|
11
|
-
}
|
|
12
|
-
return o;
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
i as u
|
|
16
|
-
};
|