motile-ui 1.0.4 → 1.1.1
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/components/Sheet/Sheet.js +33 -28
- package/dist/components/Sheet/useSheetNavigation.d.ts +1 -0
- package/dist/components/Sheet/useSheetNavigation.js +4 -0
- package/dist/components/Tooltip/Tooltip.js +170 -159
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.js +8 -0
- package/dist/index.d.ts +0 -5
- package/dist/index.js +34 -40
- package/package.json +6 -14
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as u, jsxs as $ } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback as
|
|
3
|
-
import { createPortal as
|
|
2
|
+
import { useCallback as b, useState as S, useEffect as v, useId as A, useRef as x, useMemo as F, createContext as N, useContext as T } from "react";
|
|
3
|
+
import { createPortal as w } from "react-dom";
|
|
4
4
|
import { Slot as g } from "../../utils/Slot.js";
|
|
5
|
-
import { useScrollLock as
|
|
5
|
+
import { useScrollLock as K } from "../../hooks/useScrollLock.js";
|
|
6
6
|
import { useClickOutside as H } from "../../hooks/useClickOutside.js";
|
|
7
7
|
import { useEscapeKey as V } from "../../hooks/useEscapeKey.js";
|
|
8
8
|
import { useHistoryClose as q } from "../../hooks/useHistoryClose.js";
|
|
9
9
|
import './Sheet.css';/* empty css */
|
|
10
|
-
const I =
|
|
11
|
-
function
|
|
12
|
-
const e =
|
|
10
|
+
const I = N(null);
|
|
11
|
+
function k() {
|
|
12
|
+
const e = T(I);
|
|
13
13
|
if (!e)
|
|
14
14
|
throw new Error("Sheet components must be used within Sheet.Root");
|
|
15
15
|
return e;
|
|
@@ -19,7 +19,7 @@ function z({
|
|
|
19
19
|
defaultValue: n = !1,
|
|
20
20
|
onChange: o
|
|
21
21
|
}) {
|
|
22
|
-
const t = e !== void 0, [i, a] = S(n), s = t ? e : i, l =
|
|
22
|
+
const t = e !== void 0, [i, a] = S(n), s = t ? e : i, l = b(
|
|
23
23
|
(r) => {
|
|
24
24
|
const f = typeof r == "function" ? r(s) : r;
|
|
25
25
|
t || a(f), o == null || o(f);
|
|
@@ -38,14 +38,14 @@ function B({
|
|
|
38
38
|
defaultOpen: s = !1,
|
|
39
39
|
onOpenChange: l
|
|
40
40
|
}) {
|
|
41
|
-
const r =
|
|
41
|
+
const r = A().replace(/:/g, ""), f = x(null), h = x(null), [d, c] = z({
|
|
42
42
|
value: a,
|
|
43
43
|
defaultValue: s,
|
|
44
44
|
onChange: l
|
|
45
45
|
}), { isClosingFromHistory: p, navigateAndClose: y } = q({
|
|
46
46
|
isOpen: d,
|
|
47
47
|
onClose: () => c(!1)
|
|
48
|
-
}), m =
|
|
48
|
+
}), m = F(
|
|
49
49
|
() => ({
|
|
50
50
|
open: d,
|
|
51
51
|
setOpen: c,
|
|
@@ -79,7 +79,7 @@ function B({
|
|
|
79
79
|
return /* @__PURE__ */ u(I.Provider, { value: m, children: e });
|
|
80
80
|
}
|
|
81
81
|
function P({ children: e, asChild: n = !1 }) {
|
|
82
|
-
const { open: o, setOpen: t, triggerId: i, contentId: a } =
|
|
82
|
+
const { open: o, setOpen: t, triggerId: i, contentId: a } = k(), s = b(() => {
|
|
83
83
|
t((l) => !l);
|
|
84
84
|
}, [t]);
|
|
85
85
|
return n ? /* @__PURE__ */ u(
|
|
@@ -104,17 +104,17 @@ function P({ children: e, asChild: n = !1 }) {
|
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
function j({ children: e, container: n }) {
|
|
107
|
-
const { open: o } =
|
|
108
|
-
return
|
|
107
|
+
const { open: o } = k(), [t, i] = S(!1);
|
|
108
|
+
return v(() => {
|
|
109
109
|
i(!0);
|
|
110
|
-
}, []), !t || !o ? null :
|
|
110
|
+
}, []), !t || !o ? null : w(e, n || document.body);
|
|
111
111
|
}
|
|
112
112
|
function E({ className: e = "", style: n }) {
|
|
113
|
-
const { open: o, setOpen: t, position: i, closeOnBackdrop: a, zIndex: s, overlayRef: l } =
|
|
113
|
+
const { open: o, setOpen: t, position: i, closeOnBackdrop: a, zIndex: s, overlayRef: l } = k(), [r, f] = S(!1), [h, d] = S(!1), c = typeof a == "boolean" ? { clickOutside: a } : {
|
|
114
114
|
escapeKey: a.escapeKey ?? !1,
|
|
115
115
|
clickOutside: a.clickOutside ?? !1
|
|
116
116
|
};
|
|
117
|
-
|
|
117
|
+
v(() => {
|
|
118
118
|
if (o)
|
|
119
119
|
f(!0);
|
|
120
120
|
else if (r) {
|
|
@@ -124,17 +124,17 @@ function E({ className: e = "", style: n }) {
|
|
|
124
124
|
}, 300);
|
|
125
125
|
return () => clearTimeout(m);
|
|
126
126
|
}
|
|
127
|
-
}, [o, r]),
|
|
127
|
+
}, [o, r]), v(() => {
|
|
128
128
|
if (!r || !o) return;
|
|
129
129
|
const m = requestAnimationFrame(() => {
|
|
130
|
-
const
|
|
130
|
+
const _ = requestAnimationFrame(() => {
|
|
131
131
|
d(!0);
|
|
132
132
|
});
|
|
133
|
-
return () => cancelAnimationFrame(
|
|
133
|
+
return () => cancelAnimationFrame(_);
|
|
134
134
|
});
|
|
135
135
|
return () => cancelAnimationFrame(m);
|
|
136
136
|
}, [r, o]);
|
|
137
|
-
const p =
|
|
137
|
+
const p = b(
|
|
138
138
|
(m) => {
|
|
139
139
|
c.clickOutside && m.target === l.current && t(!1);
|
|
140
140
|
},
|
|
@@ -168,21 +168,21 @@ function L({ children: e, className: n = "", style: o }) {
|
|
|
168
168
|
contentId: f,
|
|
169
169
|
sheetRef: h,
|
|
170
170
|
isClosingFromHistory: d
|
|
171
|
-
} =
|
|
171
|
+
} = k(), [c, p] = S(!1), [y, m] = S(!1), _ = typeof s == "boolean" ? { escapeKey: s, clickOutside: s } : {
|
|
172
172
|
escapeKey: s.escapeKey ?? !1,
|
|
173
173
|
clickOutside: s.clickOutside ?? !1
|
|
174
174
|
};
|
|
175
|
-
if (
|
|
175
|
+
if (K({
|
|
176
176
|
enabled: t,
|
|
177
177
|
allowedSelectors: [".motile-sheet__body"]
|
|
178
178
|
}), H({
|
|
179
179
|
refs: [h],
|
|
180
180
|
handler: () => i(!1),
|
|
181
|
-
enabled: t &&
|
|
181
|
+
enabled: t && _.clickOutside
|
|
182
182
|
}), V({
|
|
183
183
|
handler: () => i(!1),
|
|
184
|
-
enabled: t &&
|
|
185
|
-
}),
|
|
184
|
+
enabled: t && _.escapeKey
|
|
185
|
+
}), v(() => {
|
|
186
186
|
if (t)
|
|
187
187
|
p(!0);
|
|
188
188
|
else if (c) {
|
|
@@ -192,7 +192,7 @@ function L({ children: e, className: n = "", style: o }) {
|
|
|
192
192
|
}, d ? 0 : 300);
|
|
193
193
|
return () => clearTimeout(C);
|
|
194
194
|
}
|
|
195
|
-
}, [t, c, d]),
|
|
195
|
+
}, [t, c, d]), v(() => {
|
|
196
196
|
if (!c || !t || d) return;
|
|
197
197
|
const O = requestAnimationFrame(() => {
|
|
198
198
|
const C = requestAnimationFrame(() => {
|
|
@@ -231,7 +231,7 @@ function W({ children: e, className: n = "" }) {
|
|
|
231
231
|
return /* @__PURE__ */ u("div", { className: `motile-sheet__body ${n}`, children: e });
|
|
232
232
|
}
|
|
233
233
|
function G({ children: e, asChild: n = !1 }) {
|
|
234
|
-
const { setOpen: o } =
|
|
234
|
+
const { setOpen: o } = k(), t = b(() => {
|
|
235
235
|
o(!1);
|
|
236
236
|
}, [o]);
|
|
237
237
|
return n ? /* @__PURE__ */ u(
|
|
@@ -269,7 +269,11 @@ function G({ children: e, asChild: n = !1 }) {
|
|
|
269
269
|
}
|
|
270
270
|
);
|
|
271
271
|
}
|
|
272
|
-
|
|
272
|
+
function ne() {
|
|
273
|
+
const { navigateAndClose: e } = k();
|
|
274
|
+
return e;
|
|
275
|
+
}
|
|
276
|
+
const se = {
|
|
273
277
|
Root: B,
|
|
274
278
|
Trigger: P,
|
|
275
279
|
Portal: j,
|
|
@@ -281,5 +285,6 @@ const ne = {
|
|
|
281
285
|
Close: G
|
|
282
286
|
};
|
|
283
287
|
export {
|
|
284
|
-
|
|
288
|
+
se as Sheet,
|
|
289
|
+
ne as useSheetNavigation
|
|
285
290
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useSheetNavigation } from './Sheet';
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { jsxs as tt, jsx as
|
|
2
|
-
import et, { useState as
|
|
3
|
-
import { createPortal as
|
|
1
|
+
import { jsxs as tt, jsx as V } from "react/jsx-runtime";
|
|
2
|
+
import et, { useState as A, useEffect as B, useCallback as C, useId as ot, useRef as y, useLayoutEffect as nt, createContext as rt, useContext as st } from "react";
|
|
3
|
+
import { createPortal as it } from "react-dom";
|
|
4
4
|
import { Slot as at } from "../../utils/Slot.js";
|
|
5
5
|
import { FloatingArrow as lt } from "../../utils/FloatingArrow.js";
|
|
6
6
|
import './Tooltip.css';/* empty css */
|
|
7
7
|
const Z = rt(null);
|
|
8
8
|
function J() {
|
|
9
|
-
const t =
|
|
9
|
+
const t = st(Z);
|
|
10
10
|
if (!t)
|
|
11
11
|
throw new Error("Tooltip components must be used within Tooltip.Root");
|
|
12
12
|
return t;
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
function X(t, e, r,
|
|
14
|
+
const i = 8;
|
|
15
|
+
function X(t, e, r, s, a, m, p) {
|
|
16
16
|
switch (t) {
|
|
17
17
|
case "top":
|
|
18
|
-
return e.top - a.top -
|
|
18
|
+
return e.top - a.top - s >= i;
|
|
19
19
|
case "bottom":
|
|
20
|
-
return e.bottom + a.bottom +
|
|
20
|
+
return e.bottom + a.bottom + s <= p - i;
|
|
21
21
|
case "left":
|
|
22
|
-
return e.left - a.left - r >=
|
|
22
|
+
return e.left - a.left - r >= i;
|
|
23
23
|
case "right":
|
|
24
|
-
return e.right + a.right + r <=
|
|
24
|
+
return e.right + a.right + r <= m - i;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function ct(t) {
|
|
@@ -32,32 +32,32 @@ function ct(t) {
|
|
|
32
32
|
right: "left"
|
|
33
33
|
}[t]];
|
|
34
34
|
}
|
|
35
|
-
function ut(t, e, r,
|
|
35
|
+
function ut(t, e, r, s) {
|
|
36
36
|
if (!(r < 768))
|
|
37
37
|
return ct(t);
|
|
38
|
-
const
|
|
39
|
-
return t === "left" || t === "right" ? [
|
|
38
|
+
const p = e.top + e.height / 2 < s / 2;
|
|
39
|
+
return t === "left" || t === "right" ? [p ? "bottom" : "top", p ? "top" : "bottom", t === "left" ? "right" : "left"] : t === "top" || t === "bottom" ? [t === "top" ? "bottom" : "top"] : [];
|
|
40
40
|
}
|
|
41
|
-
function pt(t, e, r,
|
|
41
|
+
function pt(t, e, r, s) {
|
|
42
42
|
const a = {
|
|
43
|
-
top: t.top - e.top -
|
|
44
|
-
bottom:
|
|
45
|
-
left: t.left - e.left -
|
|
46
|
-
right: r - t.right - e.right -
|
|
43
|
+
top: t.top - e.top - i,
|
|
44
|
+
bottom: s - t.bottom - e.bottom - i,
|
|
45
|
+
left: t.left - e.left - i,
|
|
46
|
+
right: r - t.right - e.right - i
|
|
47
47
|
};
|
|
48
|
-
let
|
|
48
|
+
let m = "bottom", p = a.bottom;
|
|
49
49
|
for (const [n, l] of Object.entries(a))
|
|
50
|
-
l >
|
|
51
|
-
return
|
|
50
|
+
l > p && (p = l, m = n);
|
|
51
|
+
return m;
|
|
52
52
|
}
|
|
53
53
|
function ft({
|
|
54
54
|
children: t,
|
|
55
55
|
position: e = "top",
|
|
56
56
|
align: r = "center",
|
|
57
|
-
variant:
|
|
57
|
+
variant: s = "filled",
|
|
58
58
|
color: a,
|
|
59
|
-
showArrow:
|
|
60
|
-
keepOpen:
|
|
59
|
+
showArrow: m = !1,
|
|
60
|
+
keepOpen: p = !1,
|
|
61
61
|
offset: n
|
|
62
62
|
}) {
|
|
63
63
|
const l = n === void 0 ? { top: 7, bottom: 6, left: 6, right: 6 } : typeof n == "number" ? { top: n, bottom: n, left: n, right: n } : {
|
|
@@ -65,52 +65,52 @@ function ft({
|
|
|
65
65
|
bottom: n.bottom ?? 6,
|
|
66
66
|
left: n.left ?? 6,
|
|
67
67
|
right: n.right ?? 6
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
() =>
|
|
68
|
+
}, k = ot().replace(/:/g, ""), w = y(null), x = y(null), b = y(), [c, h] = A(!1), [F, z] = A(e), [W, K] = A({}), N = y(null), j = C((R, E = 0) => {
|
|
69
|
+
b.current && (clearTimeout(b.current), b.current = void 0), !R && E > 0 ? b.current = window.setTimeout(
|
|
70
|
+
() => h(!1),
|
|
71
71
|
E
|
|
72
|
-
) :
|
|
72
|
+
) : h(R);
|
|
73
73
|
}, []);
|
|
74
74
|
nt(() => {
|
|
75
|
-
if (!
|
|
76
|
-
const
|
|
75
|
+
if (!c || !w.current || !x.current) return;
|
|
76
|
+
const R = () => {
|
|
77
77
|
if (!w.current || !x.current) return;
|
|
78
|
-
const o = w.current.getBoundingClientRect(),
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
(isNaN(
|
|
85
|
-
const U =
|
|
86
|
-
|
|
87
|
-
let
|
|
88
|
-
if (o.width === 0 && o.height === 0 || X(e, o,
|
|
89
|
-
|
|
78
|
+
const o = w.current.getBoundingClientRect(), P = x.current;
|
|
79
|
+
P.classList.add("measuring"), P.offsetHeight;
|
|
80
|
+
const _ = P.getBoundingClientRect(), q = _.width, H = _.height;
|
|
81
|
+
let u = q, d = H;
|
|
82
|
+
P.classList.remove("measuring");
|
|
83
|
+
const T = window.innerWidth, O = window.innerHeight;
|
|
84
|
+
(isNaN(u) || u <= 0) && (u = 100), (isNaN(d) || d <= 0) && (d = 50);
|
|
85
|
+
const U = T - i * 2, $ = O - i * 2;
|
|
86
|
+
u > U && (u = U), d > $ && (d = $);
|
|
87
|
+
let M = e;
|
|
88
|
+
if (o.width === 0 && o.height === 0 || X(e, o, u, d, l, T, O))
|
|
89
|
+
M = e;
|
|
90
90
|
else {
|
|
91
|
-
const
|
|
91
|
+
const I = ut(e, o, T, O);
|
|
92
92
|
let D = !1;
|
|
93
|
-
for (const G of
|
|
94
|
-
if (X(G, o,
|
|
95
|
-
|
|
93
|
+
for (const G of I)
|
|
94
|
+
if (X(G, o, u, d, l, T, O)) {
|
|
95
|
+
M = G, D = !0;
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
|
-
D || (
|
|
98
|
+
D || (M = pt(o, l, T, O));
|
|
99
99
|
}
|
|
100
|
-
let
|
|
101
|
-
if (
|
|
100
|
+
let f = 0, g = 0;
|
|
101
|
+
if (M === "top" || M === "bottom") {
|
|
102
102
|
switch (r) {
|
|
103
103
|
case "start":
|
|
104
|
-
|
|
104
|
+
f = o.left;
|
|
105
105
|
break;
|
|
106
106
|
case "center":
|
|
107
|
-
|
|
107
|
+
f = o.left + o.width / 2 - u / 2;
|
|
108
108
|
break;
|
|
109
109
|
case "end":
|
|
110
|
-
|
|
110
|
+
f = o.right - u;
|
|
111
111
|
break;
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
f = Math.max(i, Math.min(f, T - i - u)), g = M === "top" ? o.top - l.top - d : o.bottom + l.bottom, g = Math.max(i, Math.min(g, O - i - d));
|
|
114
114
|
} else {
|
|
115
115
|
switch (r) {
|
|
116
116
|
case "start":
|
|
@@ -123,188 +123,199 @@ function ft({
|
|
|
123
123
|
g = o.bottom - d;
|
|
124
124
|
break;
|
|
125
125
|
}
|
|
126
|
-
g = Math.max(
|
|
126
|
+
g = Math.max(i, Math.min(g, O - i - d)), M === "left" ? (f = o.left - l.left - u, f < i && (u = o.left - l.left - i, f = i)) : (f = o.right + l.right, f + u > T - i && (u = T - i - f));
|
|
127
127
|
}
|
|
128
|
-
let
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
128
|
+
let v = 0;
|
|
129
|
+
const S = 12, L = 16;
|
|
130
|
+
if (M === "left" || M === "right") {
|
|
131
131
|
switch (r) {
|
|
132
132
|
case "start":
|
|
133
|
-
|
|
133
|
+
v = o.top - g + S;
|
|
134
134
|
break;
|
|
135
135
|
case "center":
|
|
136
|
-
|
|
136
|
+
v = o.top + o.height / 2 - g;
|
|
137
137
|
break;
|
|
138
138
|
case "end":
|
|
139
|
-
|
|
139
|
+
v = o.bottom - g - S;
|
|
140
140
|
break;
|
|
141
141
|
}
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
Math.min(
|
|
142
|
+
const I = Math.max(L, d - L);
|
|
143
|
+
v = Math.max(
|
|
144
|
+
L,
|
|
145
|
+
Math.min(v, I)
|
|
146
146
|
);
|
|
147
147
|
} else {
|
|
148
148
|
switch (r) {
|
|
149
149
|
case "start":
|
|
150
|
-
|
|
150
|
+
v = o.left - f + S;
|
|
151
151
|
break;
|
|
152
152
|
case "center":
|
|
153
|
-
|
|
153
|
+
v = o.left + o.width / 2 - f;
|
|
154
154
|
break;
|
|
155
155
|
case "end":
|
|
156
|
-
|
|
156
|
+
v = o.right - f - S;
|
|
157
157
|
break;
|
|
158
158
|
}
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
Math.min(
|
|
159
|
+
const I = Math.max(L, u - L);
|
|
160
|
+
v = Math.max(
|
|
161
|
+
L,
|
|
162
|
+
Math.min(v, I)
|
|
163
163
|
);
|
|
164
164
|
}
|
|
165
|
-
isNaN(
|
|
166
|
-
left: Math.round(
|
|
165
|
+
isNaN(v) && (v = L), z(M), K({
|
|
166
|
+
left: Math.round(f),
|
|
167
167
|
top: Math.round(g),
|
|
168
|
-
...
|
|
169
|
-
...d !==
|
|
170
|
-
"--arrow-offset": `${Math.round(
|
|
168
|
+
...u !== q && { maxWidth: u },
|
|
169
|
+
...d !== H && { maxHeight: $ },
|
|
170
|
+
"--arrow-offset": `${Math.round(v)}px`,
|
|
171
171
|
...a && { "--motile-tooltip-color": a }
|
|
172
172
|
});
|
|
173
173
|
}, E = () => {
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
N.current === null && (N.current = requestAnimationFrame(() => {
|
|
175
|
+
R(), N.current = null;
|
|
176
176
|
}));
|
|
177
177
|
};
|
|
178
|
-
|
|
178
|
+
R(), window.addEventListener("scroll", E, {
|
|
179
179
|
passive: !0,
|
|
180
180
|
capture: !0
|
|
181
181
|
}), window.addEventListener("resize", E, { passive: !0 });
|
|
182
|
-
const
|
|
183
|
-
return w.current &&
|
|
184
|
-
|
|
182
|
+
const Y = new ResizeObserver(E);
|
|
183
|
+
return w.current && Y.observe(w.current), () => {
|
|
184
|
+
N.current !== null && (cancelAnimationFrame(N.current), N.current = null), window.removeEventListener("scroll", E, { capture: !0 }), window.removeEventListener("resize", E), Y.disconnect();
|
|
185
185
|
};
|
|
186
|
-
}, [
|
|
187
|
-
if (!
|
|
188
|
-
const
|
|
189
|
-
|
|
186
|
+
}, [c, e, r, a, n]), B(() => {
|
|
187
|
+
if (!c) return;
|
|
188
|
+
const R = () => {
|
|
189
|
+
j(!1, 0);
|
|
190
190
|
};
|
|
191
|
-
return window.addEventListener("scroll",
|
|
192
|
-
window.removeEventListener("scroll",
|
|
191
|
+
return window.addEventListener("scroll", R, { capture: !0 }), () => {
|
|
192
|
+
window.removeEventListener("scroll", R, { capture: !0 });
|
|
193
193
|
};
|
|
194
|
-
}, [
|
|
195
|
-
|
|
194
|
+
}, [c, j]), B(() => () => {
|
|
195
|
+
b.current && clearTimeout(b.current);
|
|
196
196
|
}, []);
|
|
197
197
|
const Q = {
|
|
198
|
-
open:
|
|
199
|
-
setOpen:
|
|
198
|
+
open: c,
|
|
199
|
+
setOpen: j,
|
|
200
200
|
position: e,
|
|
201
201
|
align: r,
|
|
202
|
-
variant:
|
|
203
|
-
showArrow:
|
|
202
|
+
variant: s,
|
|
203
|
+
showArrow: m,
|
|
204
204
|
color: a,
|
|
205
|
-
keepOpen:
|
|
206
|
-
tooltipId: `${
|
|
205
|
+
keepOpen: p,
|
|
206
|
+
tooltipId: `${k}-tooltip`,
|
|
207
207
|
triggerRef: w,
|
|
208
208
|
contentRef: x,
|
|
209
|
-
style:
|
|
210
|
-
placement:
|
|
209
|
+
style: W,
|
|
210
|
+
placement: F
|
|
211
211
|
};
|
|
212
|
-
return /* @__PURE__ */
|
|
212
|
+
return /* @__PURE__ */ V(Z.Provider, { value: Q, children: t });
|
|
213
213
|
}
|
|
214
214
|
function mt({ children: t, asChild: e = !1 }) {
|
|
215
|
-
const { open: r, setOpen:
|
|
216
|
-
|
|
217
|
-
}, [
|
|
218
|
-
|
|
219
|
-
}, [
|
|
220
|
-
|
|
221
|
-
}, [
|
|
222
|
-
|
|
223
|
-
}, [
|
|
224
|
-
|
|
225
|
-
}, [
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
215
|
+
const { open: r, setOpen: s, tooltipId: a, triggerRef: m, keepOpen: p } = J(), n = C(() => {
|
|
216
|
+
s(!0, 0);
|
|
217
|
+
}, [s]), l = C(() => {
|
|
218
|
+
p ? s(!1, 100) : s(!1, 0);
|
|
219
|
+
}, [s, p]), k = C(() => {
|
|
220
|
+
s(!0, 0);
|
|
221
|
+
}, [s]), w = C(() => {
|
|
222
|
+
s(!1, 0);
|
|
223
|
+
}, [s]), x = C(() => {
|
|
224
|
+
s(!r, 0);
|
|
225
|
+
}, [s, r]);
|
|
226
|
+
if (e)
|
|
227
|
+
return /* @__PURE__ */ V(
|
|
228
|
+
at,
|
|
229
|
+
{
|
|
230
|
+
ref: (c) => {
|
|
231
|
+
m.current = c;
|
|
232
|
+
},
|
|
233
|
+
className: "motile-tooltip-trigger",
|
|
234
|
+
"aria-describedby": r ? a : void 0,
|
|
235
|
+
tabIndex: 0,
|
|
236
|
+
onMouseEnter: n,
|
|
237
|
+
onMouseLeave: l,
|
|
238
|
+
onFocus: k,
|
|
239
|
+
onBlur: w,
|
|
240
|
+
onClick: x,
|
|
241
|
+
children: t
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
const b = (c, h) => (F) => {
|
|
245
|
+
c == null || c(F), h(F);
|
|
246
|
+
};
|
|
247
|
+
return et.cloneElement(t, {
|
|
248
|
+
ref: (c) => {
|
|
249
|
+
m.current = c;
|
|
250
|
+
const h = t.props.ref || t.ref;
|
|
251
|
+
h && (typeof h == "function" ? h(c) : typeof h == "object" && h !== null && (h.current = c));
|
|
247
252
|
},
|
|
248
253
|
className: `motile-tooltip-trigger ${t.props.className || ""}`.trim(),
|
|
249
254
|
"aria-describedby": r ? a : void 0,
|
|
250
255
|
tabIndex: t.props.tabIndex ?? 0,
|
|
251
|
-
onMouseEnter:
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
+
onMouseEnter: b(
|
|
257
|
+
t.props.onMouseEnter,
|
|
258
|
+
n
|
|
259
|
+
),
|
|
260
|
+
onMouseLeave: b(
|
|
261
|
+
t.props.onMouseLeave,
|
|
262
|
+
l
|
|
263
|
+
),
|
|
264
|
+
onFocus: b(t.props.onFocus, k),
|
|
265
|
+
onBlur: b(t.props.onBlur, w),
|
|
266
|
+
onClick: b(t.props.onClick, x)
|
|
256
267
|
});
|
|
257
268
|
}
|
|
258
269
|
function bt({ children: t }) {
|
|
259
270
|
const {
|
|
260
271
|
open: e,
|
|
261
272
|
setOpen: r,
|
|
262
|
-
tooltipId:
|
|
273
|
+
tooltipId: s,
|
|
263
274
|
contentRef: a,
|
|
264
|
-
variant:
|
|
265
|
-
showArrow:
|
|
275
|
+
variant: m,
|
|
276
|
+
showArrow: p,
|
|
266
277
|
keepOpen: n,
|
|
267
278
|
align: l,
|
|
268
|
-
style:
|
|
279
|
+
style: k,
|
|
269
280
|
placement: w
|
|
270
|
-
} = J(), [x,
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}, []),
|
|
281
|
+
} = J(), [x, b] = A(!1), [c, h] = A(!1);
|
|
282
|
+
B(() => {
|
|
283
|
+
b(!0);
|
|
284
|
+
}, []), B(() => {
|
|
274
285
|
e ? requestAnimationFrame(() => {
|
|
275
|
-
|
|
276
|
-
}) :
|
|
286
|
+
h(!0);
|
|
287
|
+
}) : h(!1);
|
|
277
288
|
}, [e]);
|
|
278
|
-
const
|
|
289
|
+
const F = C(() => {
|
|
279
290
|
n && r(!0, 0);
|
|
280
|
-
}, [n, r]), z =
|
|
291
|
+
}, [n, r]), z = C(() => {
|
|
281
292
|
n && r(!1, 0);
|
|
282
|
-
}, [n, r]),
|
|
283
|
-
return !x || !e ? null :
|
|
293
|
+
}, [n, r]), W = k["--motile-tooltip-color"] || (m === "filled" ? "var(--motile-ui-tooltip, rgba(0, 0, 0, 0.9))" : "var(--motile-ui-tooltip, #3b82f6)");
|
|
294
|
+
return !x || !e ? null : it(
|
|
284
295
|
/* @__PURE__ */ tt(
|
|
285
296
|
"div",
|
|
286
297
|
{
|
|
287
298
|
ref: a,
|
|
288
|
-
id:
|
|
299
|
+
id: s,
|
|
289
300
|
role: "tooltip",
|
|
290
|
-
className: `motile-tooltip-bubble motile-tooltip-bubble--${
|
|
291
|
-
"data-open":
|
|
301
|
+
className: `motile-tooltip-bubble motile-tooltip-bubble--${m}`,
|
|
302
|
+
"data-open": c || void 0,
|
|
292
303
|
"data-placement": w,
|
|
293
304
|
"data-align": l,
|
|
294
|
-
"data-show-arrow":
|
|
305
|
+
"data-show-arrow": p || void 0,
|
|
295
306
|
"data-keep-open": n || void 0,
|
|
296
|
-
style:
|
|
307
|
+
style: k,
|
|
297
308
|
"aria-hidden": !e,
|
|
298
|
-
onMouseEnter:
|
|
309
|
+
onMouseEnter: F,
|
|
299
310
|
onMouseLeave: z,
|
|
300
311
|
children: [
|
|
301
312
|
t,
|
|
302
|
-
|
|
313
|
+
p && /* @__PURE__ */ V(
|
|
303
314
|
lt,
|
|
304
315
|
{
|
|
305
316
|
className: "motile-tooltip-arrow",
|
|
306
|
-
variant:
|
|
307
|
-
color:
|
|
317
|
+
variant: m,
|
|
318
|
+
color: W
|
|
308
319
|
}
|
|
309
320
|
)
|
|
310
321
|
]
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useScrollLock } from './useScrollLock';
|
|
2
|
+
export { useClickOutside } from './useClickOutside';
|
|
3
|
+
export type { UseClickOutsideOptions } from './useClickOutside';
|
|
4
|
+
export { useEscapeKey } from './useEscapeKey';
|
|
5
|
+
export type { UseEscapeKeyOptions } from './useEscapeKey';
|
package/dist/index.d.ts
CHANGED
|
@@ -30,8 +30,3 @@ export { Dock } from './components/Dock';
|
|
|
30
30
|
export type { DockRootProps, DockItemProps, DockSeparatorProps, DockPosition, } from './components/Dock';
|
|
31
31
|
export { SpeedDial } from './components/SpeedDial';
|
|
32
32
|
export type { SpeedDialDirection, SpeedDialRootProps, SpeedDialTriggerProps, SpeedDialActionsProps, SpeedDialActionProps, } from './components/SpeedDial';
|
|
33
|
-
export { useScrollLock } from './hooks/useScrollLock';
|
|
34
|
-
export { useClickOutside } from './hooks/useClickOutside';
|
|
35
|
-
export type { UseClickOutsideOptions } from './hooks/useClickOutside';
|
|
36
|
-
export { useEscapeKey } from './hooks/useEscapeKey';
|
|
37
|
-
export type { UseEscapeKeyOptions } from './hooks/useEscapeKey';
|
package/dist/index.js
CHANGED
|
@@ -1,42 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { useToast as j } from "./components/Toast/useToast.js";
|
|
19
|
-
import { Dock as z } from "./components/Dock/Dock.js";
|
|
20
|
-
import { SpeedDial as G } from "./components/SpeedDial/SpeedDial.js";
|
|
1
|
+
import { Button as e } from "./components/Button/Button.js";
|
|
2
|
+
import { Input as p } from "./components/Input/Input.js";
|
|
3
|
+
import { Textarea as f } from "./components/Textarea/Textarea.js";
|
|
4
|
+
import { Checkbox as a } from "./components/Checkbox/Checkbox.js";
|
|
5
|
+
import { Switch as d } from "./components/Switch/Switch.js";
|
|
6
|
+
import { Accordion as l } from "./components/Accordion/Accordion.js";
|
|
7
|
+
import { Skeleton as S } from "./components/Skeleton/Skeleton.js";
|
|
8
|
+
import { Badge as h } from "./components/Badge/Badge.js";
|
|
9
|
+
import { Tooltip as s } from "./components/Tooltip/Tooltip.js";
|
|
10
|
+
import { Popover as D } from "./components/Popover/Popover.js";
|
|
11
|
+
import { Drawer as w } from "./components/Drawer/Drawer.js";
|
|
12
|
+
import { Sheet as P } from "./components/Sheet/Sheet.js";
|
|
13
|
+
import { Modal as g } from "./components/Modal/Modal.js";
|
|
14
|
+
import { ToastProvider as C } from "./components/Toast/Toast.js";
|
|
15
|
+
import { useToast as M } from "./components/Toast/useToast.js";
|
|
16
|
+
import { Dock as q } from "./components/Dock/Dock.js";
|
|
17
|
+
import { SpeedDial as z } from "./components/SpeedDial/SpeedDial.js";
|
|
21
18
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
f as useEscapeKey,
|
|
40
|
-
e as useScrollLock,
|
|
41
|
-
j as useToast
|
|
19
|
+
l as Accordion,
|
|
20
|
+
h as Badge,
|
|
21
|
+
e as Button,
|
|
22
|
+
a as Checkbox,
|
|
23
|
+
q as Dock,
|
|
24
|
+
w as Drawer,
|
|
25
|
+
p as Input,
|
|
26
|
+
g as Modal,
|
|
27
|
+
D as Popover,
|
|
28
|
+
P as Sheet,
|
|
29
|
+
S as Skeleton,
|
|
30
|
+
z as SpeedDial,
|
|
31
|
+
d as Switch,
|
|
32
|
+
f as Textarea,
|
|
33
|
+
C as ToastProvider,
|
|
34
|
+
s as Tooltip,
|
|
35
|
+
M as useToast
|
|
42
36
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motile-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A modern React component library for webview applications",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"import": "./dist/components/Popover/Popover.js"
|
|
49
49
|
},
|
|
50
50
|
"./Sheet": {
|
|
51
|
-
"types": "./dist/components/Sheet/
|
|
52
|
-
"import": "./dist/components/Sheet/
|
|
51
|
+
"types": "./dist/components/Sheet/useSheetNavigation.d.ts",
|
|
52
|
+
"import": "./dist/components/Sheet/useSheetNavigation.js"
|
|
53
53
|
},
|
|
54
54
|
"./Skeleton": {
|
|
55
55
|
"types": "./dist/components/Skeleton/Skeleton.d.ts",
|
|
@@ -83,17 +83,9 @@
|
|
|
83
83
|
"types": "./dist/components/Toast/useToast.d.ts",
|
|
84
84
|
"import": "./dist/components/Toast/useToast.js"
|
|
85
85
|
},
|
|
86
|
-
"./
|
|
87
|
-
"types": "./dist/hooks/
|
|
88
|
-
"import": "./dist/hooks/
|
|
89
|
-
},
|
|
90
|
-
"./useClickOutside": {
|
|
91
|
-
"types": "./dist/hooks/useClickOutside.d.ts",
|
|
92
|
-
"import": "./dist/hooks/useClickOutside.js"
|
|
93
|
-
},
|
|
94
|
-
"./useEscapeKey": {
|
|
95
|
-
"types": "./dist/hooks/useEscapeKey.d.ts",
|
|
96
|
-
"import": "./dist/hooks/useEscapeKey.js"
|
|
86
|
+
"./hooks": {
|
|
87
|
+
"types": "./dist/hooks/index.d.ts",
|
|
88
|
+
"import": "./dist/hooks/index.js"
|
|
97
89
|
}
|
|
98
90
|
},
|
|
99
91
|
"files": [
|