@gardenfi/garden-book 0.3.0-beta.3 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/garden-book",
3
- "version": "0.3.0-beta.3",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": [
@@ -1,330 +0,0 @@
1
- import * as s from "react";
2
- import { composeEventHandlers as g } from "../../primitive/dist/index.js";
3
- import { useComposedRefs as H } from "../../react-compose-refs/dist/index.js";
4
- import { createContextScope as Y } from "../../react-context/dist/index.js";
5
- import { DismissableLayer as q } from "../../react-dismissable-layer/dist/index.js";
6
- import { useId as X } from "../../react-id/dist/index.js";
7
- import { Root as K, Anchor as W, createPopperScope as N, Content as z, Arrow as J } from "../../react-popper/dist/index.js";
8
- import { Presence as Q } from "../../react-presence/dist/index.js";
9
- import { Primitive as Z } from "../../react-primitive/dist/index.js";
10
- import { createSlottable as $ } from "../node_modules/@radix-ui/react-slot/dist/index.js";
11
- import { useControllableState as ee } from "../../react-use-controllable-state/dist/index.js";
12
- import { Root as te } from "../../react-visually-hidden/dist/index.js";
13
- import { jsx as h, jsxs as oe } from "react/jsx-runtime";
14
- var [_] = Y("Tooltip", [
15
- N
16
- ]), D = N(), S = "TooltipProvider", re = 700, L = "tooltip.open", [ne, k] = _(S), G = (t) => {
17
- const {
18
- __scopeTooltip: o,
19
- delayDuration: e = re,
20
- skipDelayDuration: r = 300,
21
- disableHoverableContent: n = !1,
22
- children: l
23
- } = t, a = s.useRef(!0), f = s.useRef(!1), i = s.useRef(0);
24
- return s.useEffect(() => {
25
- const p = i.current;
26
- return () => window.clearTimeout(p);
27
- }, []), /* @__PURE__ */ h(
28
- ne,
29
- {
30
- scope: o,
31
- isOpenDelayedRef: a,
32
- delayDuration: e,
33
- onOpen: s.useCallback(() => {
34
- window.clearTimeout(i.current), a.current = !1;
35
- }, []),
36
- onClose: s.useCallback(() => {
37
- window.clearTimeout(i.current), i.current = window.setTimeout(
38
- () => a.current = !0,
39
- r
40
- );
41
- }, [r]),
42
- isPointerInTransitRef: f,
43
- onPointerInTransitChange: s.useCallback((p) => {
44
- f.current = p;
45
- }, []),
46
- disableHoverableContent: n,
47
- children: l
48
- }
49
- );
50
- };
51
- G.displayName = S;
52
- var P = "Tooltip", [se, O] = _(P), j = (t) => {
53
- const {
54
- __scopeTooltip: o,
55
- children: e,
56
- open: r,
57
- defaultOpen: n,
58
- onOpenChange: l,
59
- disableHoverableContent: a,
60
- delayDuration: f
61
- } = t, i = k(P, t.__scopeTooltip), p = D(o), [c, d] = s.useState(null), v = X(), u = s.useRef(0), m = a ?? i.disableHoverableContent, y = f ?? i.delayDuration, T = s.useRef(!1), [x, C] = ee({
62
- prop: r,
63
- defaultProp: n ?? !1,
64
- onChange: (M) => {
65
- M ? (i.onOpen(), document.dispatchEvent(new CustomEvent(L))) : i.onClose(), l == null || l(M);
66
- },
67
- caller: P
68
- }), w = s.useMemo(() => x ? T.current ? "delayed-open" : "instant-open" : "closed", [x]), E = s.useCallback(() => {
69
- window.clearTimeout(u.current), u.current = 0, T.current = !1, C(!0);
70
- }, [C]), R = s.useCallback(() => {
71
- window.clearTimeout(u.current), u.current = 0, C(!1);
72
- }, [C]), I = s.useCallback(() => {
73
- window.clearTimeout(u.current), u.current = window.setTimeout(() => {
74
- T.current = !0, C(!0), u.current = 0;
75
- }, y);
76
- }, [y, C]);
77
- return s.useEffect(() => () => {
78
- u.current && (window.clearTimeout(u.current), u.current = 0);
79
- }, []), /* @__PURE__ */ h(K, { ...p, children: /* @__PURE__ */ h(
80
- se,
81
- {
82
- scope: o,
83
- contentId: v,
84
- open: x,
85
- stateAttribute: w,
86
- trigger: c,
87
- onTriggerChange: d,
88
- onTriggerEnter: s.useCallback(() => {
89
- i.isOpenDelayedRef.current ? I() : E();
90
- }, [i.isOpenDelayedRef, I, E]),
91
- onTriggerLeave: s.useCallback(() => {
92
- m ? R() : (window.clearTimeout(u.current), u.current = 0);
93
- }, [R, m]),
94
- onOpen: E,
95
- onClose: R,
96
- disableHoverableContent: m,
97
- children: e
98
- }
99
- ) });
100
- };
101
- j.displayName = P;
102
- var A = "TooltipTrigger", F = s.forwardRef(
103
- (t, o) => {
104
- const { __scopeTooltip: e, ...r } = t, n = O(A, e), l = k(A, e), a = D(e), f = s.useRef(null), i = H(o, f, n.onTriggerChange), p = s.useRef(!1), c = s.useRef(!1), d = s.useCallback(() => p.current = !1, []);
105
- return s.useEffect(() => () => document.removeEventListener("pointerup", d), [d]), /* @__PURE__ */ h(W, { asChild: !0, ...a, children: /* @__PURE__ */ h(
106
- Z.button,
107
- {
108
- "aria-describedby": n.open ? n.contentId : void 0,
109
- "data-state": n.stateAttribute,
110
- ...r,
111
- ref: i,
112
- onPointerMove: g(t.onPointerMove, (v) => {
113
- v.pointerType !== "touch" && !c.current && !l.isPointerInTransitRef.current && (n.onTriggerEnter(), c.current = !0);
114
- }),
115
- onPointerLeave: g(t.onPointerLeave, () => {
116
- n.onTriggerLeave(), c.current = !1;
117
- }),
118
- onPointerDown: g(t.onPointerDown, () => {
119
- n.open && n.onClose(), p.current = !0, document.addEventListener("pointerup", d, { once: !0 });
120
- }),
121
- onFocus: g(t.onFocus, () => {
122
- p.current || n.onOpen();
123
- }),
124
- onBlur: g(t.onBlur, n.onClose),
125
- onClick: g(t.onClick, n.onClose)
126
- }
127
- ) });
128
- }
129
- );
130
- F.displayName = A;
131
- var ie = "TooltipPortal", [Ae, ae] = _(ie, {
132
- forceMount: void 0
133
- }), b = "TooltipContent", B = s.forwardRef(
134
- (t, o) => {
135
- const e = ae(b, t.__scopeTooltip), { forceMount: r = e.forceMount, side: n = "top", ...l } = t, a = O(b, t.__scopeTooltip);
136
- return /* @__PURE__ */ h(Q, { present: r || a.open, children: a.disableHoverableContent ? /* @__PURE__ */ h(U, { side: n, ...l, ref: o }) : /* @__PURE__ */ h(le, { side: n, ...l, ref: o }) });
137
- }
138
- ), le = s.forwardRef((t, o) => {
139
- const e = O(b, t.__scopeTooltip), r = k(b, t.__scopeTooltip), n = s.useRef(null), l = H(o, n), [a, f] = s.useState(null), { trigger: i, onClose: p } = e, c = n.current, { onPointerInTransitChange: d } = r, v = s.useCallback(() => {
140
- f(null), d(!1);
141
- }, [d]), u = s.useCallback(
142
- (m, y) => {
143
- const T = m.currentTarget, x = { x: m.clientX, y: m.clientY }, C = fe(x, T.getBoundingClientRect()), w = ve(x, C), E = he(y.getBoundingClientRect()), R = Te([...w, ...E]);
144
- f(R), d(!0);
145
- },
146
- [d]
147
- );
148
- return s.useEffect(() => () => v(), [v]), s.useEffect(() => {
149
- if (i && c) {
150
- const m = (T) => u(T, c), y = (T) => u(T, i);
151
- return i.addEventListener("pointerleave", m), c.addEventListener("pointerleave", y), () => {
152
- i.removeEventListener("pointerleave", m), c.removeEventListener("pointerleave", y);
153
- };
154
- }
155
- }, [i, c, u, v]), s.useEffect(() => {
156
- if (a) {
157
- const m = (y) => {
158
- const T = y.target, x = { x: y.clientX, y: y.clientY }, C = (i == null ? void 0 : i.contains(T)) || (c == null ? void 0 : c.contains(T)), w = !me(x, a);
159
- C ? v() : w && (v(), p());
160
- };
161
- return document.addEventListener("pointermove", m), () => document.removeEventListener("pointermove", m);
162
- }
163
- }, [i, c, a, p, v]), /* @__PURE__ */ h(U, { ...t, ref: l });
164
- }), [ce, ue] = _(P, { isInside: !1 }), pe = $("TooltipContent"), U = s.forwardRef(
165
- (t, o) => {
166
- const {
167
- __scopeTooltip: e,
168
- children: r,
169
- "aria-label": n,
170
- onEscapeKeyDown: l,
171
- onPointerDownOutside: a,
172
- ...f
173
- } = t, i = O(b, e), p = D(e), { onClose: c } = i;
174
- return s.useEffect(() => (document.addEventListener(L, c), () => document.removeEventListener(L, c)), [c]), s.useEffect(() => {
175
- if (i.trigger) {
176
- const d = (v) => {
177
- const u = v.target;
178
- u != null && u.contains(i.trigger) && c();
179
- };
180
- return window.addEventListener("scroll", d, { capture: !0 }), () => window.removeEventListener("scroll", d, { capture: !0 });
181
- }
182
- }, [i.trigger, c]), /* @__PURE__ */ h(
183
- q,
184
- {
185
- asChild: !0,
186
- disableOutsidePointerEvents: !1,
187
- onEscapeKeyDown: l,
188
- onPointerDownOutside: a,
189
- onFocusOutside: (d) => d.preventDefault(),
190
- onDismiss: c,
191
- children: /* @__PURE__ */ oe(
192
- z,
193
- {
194
- "data-state": i.stateAttribute,
195
- ...p,
196
- ...f,
197
- ref: o,
198
- style: {
199
- ...f.style,
200
- "--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
201
- "--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
202
- "--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
203
- "--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
204
- "--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
205
- },
206
- children: [
207
- /* @__PURE__ */ h(pe, { children: r }),
208
- /* @__PURE__ */ h(ce, { scope: e, isInside: !0, children: /* @__PURE__ */ h(te, { id: i.contentId, role: "tooltip", children: n || r }) })
209
- ]
210
- }
211
- )
212
- }
213
- );
214
- }
215
- );
216
- B.displayName = b;
217
- var V = "TooltipArrow", de = s.forwardRef(
218
- (t, o) => {
219
- const { __scopeTooltip: e, ...r } = t, n = D(e);
220
- return ue(
221
- V,
222
- e
223
- ).isInside ? null : /* @__PURE__ */ h(J, { ...n, ...r, ref: o });
224
- }
225
- );
226
- de.displayName = V;
227
- function fe(t, o) {
228
- const e = Math.abs(o.top - t.y), r = Math.abs(o.bottom - t.y), n = Math.abs(o.right - t.x), l = Math.abs(o.left - t.x);
229
- switch (Math.min(e, r, n, l)) {
230
- case l:
231
- return "left";
232
- case n:
233
- return "right";
234
- case e:
235
- return "top";
236
- case r:
237
- return "bottom";
238
- default:
239
- throw new Error("unreachable");
240
- }
241
- }
242
- function ve(t, o, e = 5) {
243
- const r = [];
244
- switch (o) {
245
- case "top":
246
- r.push(
247
- { x: t.x - e, y: t.y + e },
248
- { x: t.x + e, y: t.y + e }
249
- );
250
- break;
251
- case "bottom":
252
- r.push(
253
- { x: t.x - e, y: t.y - e },
254
- { x: t.x + e, y: t.y - e }
255
- );
256
- break;
257
- case "left":
258
- r.push(
259
- { x: t.x + e, y: t.y - e },
260
- { x: t.x + e, y: t.y + e }
261
- );
262
- break;
263
- case "right":
264
- r.push(
265
- { x: t.x - e, y: t.y - e },
266
- { x: t.x - e, y: t.y + e }
267
- );
268
- break;
269
- }
270
- return r;
271
- }
272
- function he(t) {
273
- const { top: o, right: e, bottom: r, left: n } = t;
274
- return [
275
- { x: n, y: o },
276
- { x: e, y: o },
277
- { x: e, y: r },
278
- { x: n, y: r }
279
- ];
280
- }
281
- function me(t, o) {
282
- const { x: e, y: r } = t;
283
- let n = !1;
284
- for (let l = 0, a = o.length - 1; l < o.length; a = l++) {
285
- const f = o[l], i = o[a], p = f.x, c = f.y, d = i.x, v = i.y;
286
- c > r != v > r && e < (d - p) * (r - c) / (v - c) + p && (n = !n);
287
- }
288
- return n;
289
- }
290
- function Te(t) {
291
- const o = t.slice();
292
- return o.sort((e, r) => e.x < r.x ? -1 : e.x > r.x ? 1 : e.y < r.y ? -1 : e.y > r.y ? 1 : 0), ye(o);
293
- }
294
- function ye(t) {
295
- if (t.length <= 1) return t.slice();
296
- const o = [];
297
- for (let r = 0; r < t.length; r++) {
298
- const n = t[r];
299
- for (; o.length >= 2; ) {
300
- const l = o[o.length - 1], a = o[o.length - 2];
301
- if ((l.x - a.x) * (n.y - a.y) >= (l.y - a.y) * (n.x - a.x)) o.pop();
302
- else break;
303
- }
304
- o.push(n);
305
- }
306
- o.pop();
307
- const e = [];
308
- for (let r = t.length - 1; r >= 0; r--) {
309
- const n = t[r];
310
- for (; e.length >= 2; ) {
311
- const l = e[e.length - 1], a = e[e.length - 2];
312
- if ((l.x - a.x) * (n.y - a.y) >= (l.y - a.y) * (n.x - a.x)) e.pop();
313
- else break;
314
- }
315
- e.push(n);
316
- }
317
- return e.pop(), o.length === 1 && e.length === 1 && o[0].x === e[0].x && o[0].y === e[0].y ? o : o.concat(e);
318
- }
319
- var ke = G, Ie = j, Me = F, He = B;
320
- export {
321
- He as Content,
322
- ke as Provider,
323
- Ie as Root,
324
- j as Tooltip,
325
- de as TooltipArrow,
326
- B as TooltipContent,
327
- G as TooltipProvider,
328
- F as TooltipTrigger,
329
- Me as Trigger
330
- };
@@ -1,11 +0,0 @@
1
- import "react";
2
- import { jsx as e, Fragment as o } from "react/jsx-runtime";
3
- var l = Symbol("radix.slottable");
4
- // @__NO_SIDE_EFFECTS__
5
- function n(r) {
6
- const t = ({ children: a }) => /* @__PURE__ */ e(o, { children: a });
7
- return t.displayName = `${r}.Slottable`, t.__radixId = l, t;
8
- }
9
- export {
10
- n as createSlottable
11
- };