@spear-ai/spectral 1.4.13 → 1.4.15

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.
@@ -1,480 +0,0 @@
1
- import * as l from "react";
2
- import { useState as te } from "react";
3
- var S = function() {
4
- return S = Object.assign || function(t) {
5
- for (var n, r = 1, a = arguments.length; r < a; r++) {
6
- n = arguments[r];
7
- for (var c in n) Object.prototype.hasOwnProperty.call(n, c) && (t[c] = n[c]);
8
- }
9
- return t;
10
- }, S.apply(this, arguments);
11
- };
12
- function Q(e, t) {
13
- var n = {};
14
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
15
- if (e != null && typeof Object.getOwnPropertySymbols == "function")
16
- for (var a = 0, r = Object.getOwnPropertySymbols(e); a < r.length; a++)
17
- t.indexOf(r[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[a]) && (n[r[a]] = e[r[a]]);
18
- return n;
19
- }
20
- function re(e, t, n) {
21
- if (n || arguments.length === 2) for (var r = 0, a = t.length, c; r < a; r++)
22
- (c || !(r in t)) && (c || (c = Array.prototype.slice.call(t, 0, r)), c[r] = t[r]);
23
- return e.concat(c || Array.prototype.slice.call(t));
24
- }
25
- var x = "right-scroll-bar-position", O = "width-before-scroll-bar", ne = "with-scroll-bars-hidden", ae = "--removed-body-scroll-bar-size";
26
- function W(e, t) {
27
- return typeof e == "function" ? e(t) : e && (e.current = t), e;
28
- }
29
- function oe(e, t) {
30
- var n = te(function() {
31
- return {
32
- // value
33
- value: e,
34
- // last callback
35
- callback: t,
36
- // "memoized" public interface
37
- facade: {
38
- get current() {
39
- return n.value;
40
- },
41
- set current(r) {
42
- var a = n.value;
43
- a !== r && (n.value = r, n.callback(r, a));
44
- }
45
- }
46
- };
47
- })[0];
48
- return n.callback = t, n.facade;
49
- }
50
- var ce = typeof window < "u" ? l.useLayoutEffect : l.useEffect, H = /* @__PURE__ */ new WeakMap();
51
- function ie(e, t) {
52
- var n = oe(null, function(r) {
53
- return e.forEach(function(a) {
54
- return W(a, r);
55
- });
56
- });
57
- return ce(function() {
58
- var r = H.get(n);
59
- if (r) {
60
- var a = new Set(r), c = new Set(e), u = n.current;
61
- a.forEach(function(i) {
62
- c.has(i) || W(i, null);
63
- }), c.forEach(function(i) {
64
- a.has(i) || W(i, u);
65
- });
66
- }
67
- H.set(n, e);
68
- }, [e]), n;
69
- }
70
- function le(e) {
71
- return e;
72
- }
73
- function ue(e, t) {
74
- t === void 0 && (t = le);
75
- var n = [], r = !1, a = {
76
- read: function() {
77
- if (r)
78
- throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");
79
- return n.length ? n[n.length - 1] : e;
80
- },
81
- useMedium: function(c) {
82
- var u = t(c, r);
83
- return n.push(u), function() {
84
- n = n.filter(function(i) {
85
- return i !== u;
86
- });
87
- };
88
- },
89
- assignSyncMedium: function(c) {
90
- for (r = !0; n.length; ) {
91
- var u = n;
92
- n = [], u.forEach(c);
93
- }
94
- n = {
95
- push: function(i) {
96
- return c(i);
97
- },
98
- filter: function() {
99
- return n;
100
- }
101
- };
102
- },
103
- assignMedium: function(c) {
104
- r = !0;
105
- var u = [];
106
- if (n.length) {
107
- var i = n;
108
- n = [], i.forEach(c), u = n;
109
- }
110
- var m = function() {
111
- var v = u;
112
- u = [], v.forEach(c);
113
- }, g = function() {
114
- return Promise.resolve().then(m);
115
- };
116
- g(), n = {
117
- push: function(v) {
118
- u.push(v), g();
119
- },
120
- filter: function(v) {
121
- return u = u.filter(v), n;
122
- }
123
- };
124
- }
125
- };
126
- return a;
127
- }
128
- function fe(e) {
129
- e === void 0 && (e = {});
130
- var t = ue(null);
131
- return t.options = S({ async: !0, ssr: !1 }, e), t;
132
- }
133
- var _ = function(e) {
134
- var t = e.sideCar, n = Q(e, ["sideCar"]);
135
- if (!t)
136
- throw new Error("Sidecar: please provide `sideCar` property to import the right car");
137
- var r = t.read();
138
- if (!r)
139
- throw new Error("Sidecar medium not found");
140
- return l.createElement(r, S({}, n));
141
- };
142
- _.isSideCarExport = !0;
143
- function se(e, t) {
144
- return e.useMedium(t), _;
145
- }
146
- var U = fe(), D = function() {
147
- }, A = l.forwardRef(function(e, t) {
148
- var n = l.useRef(null), r = l.useState({
149
- onScrollCapture: D,
150
- onWheelCapture: D,
151
- onTouchMoveCapture: D
152
- }), a = r[0], c = r[1], u = e.forwardProps, i = e.children, m = e.className, g = e.removeScrollBar, v = e.enabled, C = e.shards, k = e.sideCar, E = e.noRelative, R = e.noIsolation, o = e.inert, f = e.allowPinchZoom, h = e.as, s = h === void 0 ? "div" : h, y = e.gapMode, b = Q(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), d = k, w = ie([n, t]), p = S(S({}, b), a);
153
- return l.createElement(
154
- l.Fragment,
155
- null,
156
- v && l.createElement(d, { sideCar: U, removeScrollBar: g, shards: C, noRelative: E, noIsolation: R, inert: o, setCallbacks: c, allowPinchZoom: !!f, lockRef: n, gapMode: y }),
157
- u ? l.cloneElement(l.Children.only(i), S(S({}, p), { ref: w })) : l.createElement(s, S({}, p, { className: m, ref: w }), i)
158
- );
159
- });
160
- A.defaultProps = {
161
- enabled: !0,
162
- removeScrollBar: !0,
163
- inert: !1
164
- };
165
- A.classNames = {
166
- fullWidth: O,
167
- zeroRight: x
168
- };
169
- var de = function() {
170
- if (typeof __webpack_nonce__ < "u")
171
- return __webpack_nonce__;
172
- };
173
- function ve() {
174
- if (!document)
175
- return null;
176
- var e = document.createElement("style");
177
- e.type = "text/css";
178
- var t = de();
179
- return t && e.setAttribute("nonce", t), e;
180
- }
181
- function he(e, t) {
182
- e.styleSheet ? e.styleSheet.cssText = t : e.appendChild(document.createTextNode(t));
183
- }
184
- function me(e) {
185
- var t = document.head || document.getElementsByTagName("head")[0];
186
- t.appendChild(e);
187
- }
188
- var ge = function() {
189
- var e = 0, t = null;
190
- return {
191
- add: function(n) {
192
- e == 0 && (t = ve()) && (he(t, n), me(t)), e++;
193
- },
194
- remove: function() {
195
- e--, !e && t && (t.parentNode && t.parentNode.removeChild(t), t = null);
196
- }
197
- };
198
- }, ye = function() {
199
- var e = ge();
200
- return function(t, n) {
201
- l.useEffect(function() {
202
- return e.add(t), function() {
203
- e.remove();
204
- };
205
- }, [t && n]);
206
- };
207
- }, K = function() {
208
- var e = ye(), t = function(n) {
209
- var r = n.styles, a = n.dynamic;
210
- return e(r, a), null;
211
- };
212
- return t;
213
- }, Se = {
214
- left: 0,
215
- top: 0,
216
- right: 0,
217
- gap: 0
218
- }, X = function(e) {
219
- return parseInt(e || "", 10) || 0;
220
- }, be = function(e) {
221
- var t = window.getComputedStyle(document.body), n = t[e === "padding" ? "paddingLeft" : "marginLeft"], r = t[e === "padding" ? "paddingTop" : "marginTop"], a = t[e === "padding" ? "paddingRight" : "marginRight"];
222
- return [X(n), X(r), X(a)];
223
- }, we = function(e) {
224
- if (e === void 0 && (e = "margin"), typeof window > "u")
225
- return Se;
226
- var t = be(e), n = document.documentElement.clientWidth, r = window.innerWidth;
227
- return {
228
- left: t[0],
229
- top: t[1],
230
- right: t[2],
231
- gap: Math.max(0, r - n + t[2] - t[0])
232
- };
233
- }, pe = K(), T = "data-scroll-locked", Ce = function(e, t, n, r) {
234
- var a = e.left, c = e.top, u = e.right, i = e.gap;
235
- return n === void 0 && (n = "margin"), `
236
- .`.concat(ne, ` {
237
- overflow: hidden `).concat(r, `;
238
- padding-right: `).concat(i, "px ").concat(r, `;
239
- }
240
- body[`).concat(T, `] {
241
- overflow: hidden `).concat(r, `;
242
- overscroll-behavior: contain;
243
- `).concat([
244
- t && "position: relative ".concat(r, ";"),
245
- n === "margin" && `
246
- padding-left: `.concat(a, `px;
247
- padding-top: `).concat(c, `px;
248
- padding-right: `).concat(u, `px;
249
- margin-left:0;
250
- margin-top:0;
251
- margin-right: `).concat(i, "px ").concat(r, `;
252
- `),
253
- n === "padding" && "padding-right: ".concat(i, "px ").concat(r, ";")
254
- ].filter(Boolean).join(""), `
255
- }
256
-
257
- .`).concat(x, ` {
258
- right: `).concat(i, "px ").concat(r, `;
259
- }
260
-
261
- .`).concat(O, ` {
262
- margin-right: `).concat(i, "px ").concat(r, `;
263
- }
264
-
265
- .`).concat(x, " .").concat(x, ` {
266
- right: 0 `).concat(r, `;
267
- }
268
-
269
- .`).concat(O, " .").concat(O, ` {
270
- margin-right: 0 `).concat(r, `;
271
- }
272
-
273
- body[`).concat(T, `] {
274
- `).concat(ae, ": ").concat(i, `px;
275
- }
276
- `);
277
- }, F = function() {
278
- var e = parseInt(document.body.getAttribute(T) || "0", 10);
279
- return isFinite(e) ? e : 0;
280
- }, Ee = function() {
281
- l.useEffect(function() {
282
- return document.body.setAttribute(T, (F() + 1).toString()), function() {
283
- var e = F() - 1;
284
- e <= 0 ? document.body.removeAttribute(T) : document.body.setAttribute(T, e.toString());
285
- };
286
- }, []);
287
- }, Re = function(e) {
288
- var t = e.noRelative, n = e.noImportant, r = e.gapMode, a = r === void 0 ? "margin" : r;
289
- Ee();
290
- var c = l.useMemo(function() {
291
- return we(a);
292
- }, [a]);
293
- return l.createElement(pe, { styles: Ce(c, !t, a, n ? "" : "!important") });
294
- }, Y = !1;
295
- if (typeof window < "u")
296
- try {
297
- var L = Object.defineProperty({}, "passive", {
298
- get: function() {
299
- return Y = !0, !0;
300
- }
301
- });
302
- window.addEventListener("test", L, L), window.removeEventListener("test", L, L);
303
- } catch {
304
- Y = !1;
305
- }
306
- var P = Y ? { passive: !1 } : !1, ke = function(e) {
307
- return e.tagName === "TEXTAREA";
308
- }, $ = function(e, t) {
309
- if (!(e instanceof Element))
310
- return !1;
311
- var n = window.getComputedStyle(e);
312
- return (
313
- // not-not-scrollable
314
- n[t] !== "hidden" && // contains scroll inside self
315
- !(n.overflowY === n.overflowX && !ke(e) && n[t] === "visible")
316
- );
317
- }, Pe = function(e) {
318
- return $(e, "overflowY");
319
- }, Ne = function(e) {
320
- return $(e, "overflowX");
321
- }, z = function(e, t) {
322
- var n = t.ownerDocument, r = t;
323
- do {
324
- typeof ShadowRoot < "u" && r instanceof ShadowRoot && (r = r.host);
325
- var a = q(e, r);
326
- if (a) {
327
- var c = J(e, r), u = c[1], i = c[2];
328
- if (u > i)
329
- return !0;
330
- }
331
- r = r.parentNode;
332
- } while (r && r !== n.body);
333
- return !1;
334
- }, Te = function(e) {
335
- var t = e.scrollTop, n = e.scrollHeight, r = e.clientHeight;
336
- return [
337
- t,
338
- n,
339
- r
340
- ];
341
- }, Me = function(e) {
342
- var t = e.scrollLeft, n = e.scrollWidth, r = e.clientWidth;
343
- return [
344
- t,
345
- n,
346
- r
347
- ];
348
- }, q = function(e, t) {
349
- return e === "v" ? Pe(t) : Ne(t);
350
- }, J = function(e, t) {
351
- return e === "v" ? Te(t) : Me(t);
352
- }, Le = function(e, t) {
353
- return e === "h" && t === "rtl" ? -1 : 1;
354
- }, Be = function(e, t, n, r, a) {
355
- var c = Le(e, window.getComputedStyle(t).direction), u = c * r, i = n.target, m = t.contains(i), g = !1, v = u > 0, C = 0, k = 0;
356
- do {
357
- if (!i)
358
- break;
359
- var E = J(e, i), R = E[0], o = E[1], f = E[2], h = o - f - c * R;
360
- (R || h) && q(e, i) && (C += h, k += R);
361
- var s = i.parentNode;
362
- i = s && s.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? s.host : s;
363
- } while (
364
- // portaled content
365
- !m && i !== document.body || // self content
366
- m && (t.contains(i) || t === i)
367
- );
368
- return (v && Math.abs(C) < 1 || !v && Math.abs(k) < 1) && (g = !0), g;
369
- }, B = function(e) {
370
- return "changedTouches" in e ? [e.changedTouches[0].clientX, e.changedTouches[0].clientY] : [0, 0];
371
- }, Z = function(e) {
372
- return [e.deltaX, e.deltaY];
373
- }, G = function(e) {
374
- return e && "current" in e ? e.current : e;
375
- }, xe = function(e, t) {
376
- return e[0] === t[0] && e[1] === t[1];
377
- }, Oe = function(e) {
378
- return `
379
- .block-interactivity-`.concat(e, ` {pointer-events: none;}
380
- .allow-interactivity-`).concat(e, ` {pointer-events: all;}
381
- `);
382
- }, Ae = 0, N = [];
383
- function Ie(e) {
384
- var t = l.useRef([]), n = l.useRef([0, 0]), r = l.useRef(), a = l.useState(Ae++)[0], c = l.useState(K)[0], u = l.useRef(e);
385
- l.useEffect(function() {
386
- u.current = e;
387
- }, [e]), l.useEffect(function() {
388
- if (e.inert) {
389
- document.body.classList.add("block-interactivity-".concat(a));
390
- var o = re([e.lockRef.current], (e.shards || []).map(G), !0).filter(Boolean);
391
- return o.forEach(function(f) {
392
- return f.classList.add("allow-interactivity-".concat(a));
393
- }), function() {
394
- document.body.classList.remove("block-interactivity-".concat(a)), o.forEach(function(f) {
395
- return f.classList.remove("allow-interactivity-".concat(a));
396
- });
397
- };
398
- }
399
- }, [e.inert, e.lockRef.current, e.shards]);
400
- var i = l.useCallback(function(o, f) {
401
- if ("touches" in o && o.touches.length === 2 || o.type === "wheel" && o.ctrlKey)
402
- return !u.current.allowPinchZoom;
403
- var h = B(o), s = n.current, y = "deltaX" in o ? o.deltaX : s[0] - h[0], b = "deltaY" in o ? o.deltaY : s[1] - h[1], d, w = o.target, p = Math.abs(y) > Math.abs(b) ? "h" : "v";
404
- if ("touches" in o && p === "h" && w.type === "range")
405
- return !1;
406
- var j = window.getSelection(), I = j && j.anchorNode, ee = I ? I === w || I.contains(w) : !1;
407
- if (ee)
408
- return !1;
409
- var M = z(p, w);
410
- if (!M)
411
- return !0;
412
- if (M ? d = p : (d = p === "v" ? "h" : "v", M = z(p, w)), !M)
413
- return !1;
414
- if (!r.current && "changedTouches" in o && (y || b) && (r.current = d), !d)
415
- return !0;
416
- var V = r.current || d;
417
- return Be(V, f, o, V === "h" ? y : b);
418
- }, []), m = l.useCallback(function(o) {
419
- var f = o;
420
- if (!(!N.length || N[N.length - 1] !== c)) {
421
- var h = "deltaY" in f ? Z(f) : B(f), s = t.current.filter(function(d) {
422
- return d.name === f.type && (d.target === f.target || f.target === d.shadowParent) && xe(d.delta, h);
423
- })[0];
424
- if (s && s.should) {
425
- f.cancelable && f.preventDefault();
426
- return;
427
- }
428
- if (!s) {
429
- var y = (u.current.shards || []).map(G).filter(Boolean).filter(function(d) {
430
- return d.contains(f.target);
431
- }), b = y.length > 0 ? i(f, y[0]) : !u.current.noIsolation;
432
- b && f.cancelable && f.preventDefault();
433
- }
434
- }
435
- }, []), g = l.useCallback(function(o, f, h, s) {
436
- var y = { name: o, delta: f, target: h, should: s, shadowParent: We(h) };
437
- t.current.push(y), setTimeout(function() {
438
- t.current = t.current.filter(function(b) {
439
- return b !== y;
440
- });
441
- }, 1);
442
- }, []), v = l.useCallback(function(o) {
443
- n.current = B(o), r.current = void 0;
444
- }, []), C = l.useCallback(function(o) {
445
- g(o.type, Z(o), o.target, i(o, e.lockRef.current));
446
- }, []), k = l.useCallback(function(o) {
447
- g(o.type, B(o), o.target, i(o, e.lockRef.current));
448
- }, []);
449
- l.useEffect(function() {
450
- return N.push(c), e.setCallbacks({
451
- onScrollCapture: C,
452
- onWheelCapture: C,
453
- onTouchMoveCapture: k
454
- }), document.addEventListener("wheel", m, P), document.addEventListener("touchmove", m, P), document.addEventListener("touchstart", v, P), function() {
455
- N = N.filter(function(o) {
456
- return o !== c;
457
- }), document.removeEventListener("wheel", m, P), document.removeEventListener("touchmove", m, P), document.removeEventListener("touchstart", v, P);
458
- };
459
- }, []);
460
- var E = e.removeScrollBar, R = e.inert;
461
- return l.createElement(
462
- l.Fragment,
463
- null,
464
- R ? l.createElement(c, { styles: Oe(a) }) : null,
465
- E ? l.createElement(Re, { noRelative: e.noRelative, gapMode: e.gapMode }) : null
466
- );
467
- }
468
- function We(e) {
469
- for (var t = null; e !== null; )
470
- e instanceof ShadowRoot && (t = e.host, e = e.host), e = e.parentNode;
471
- return t;
472
- }
473
- const De = se(U, Ie);
474
- var Xe = l.forwardRef(function(e, t) {
475
- return l.createElement(A, S({}, e, { ref: t, sideCar: De }));
476
- });
477
- Xe.classNames = A.classNames;
478
- export {
479
- Xe as R
480
- };
@@ -1,86 +0,0 @@
1
- import { VariantProps } from 'class-variance-authority';
2
- import { ReactElement, ReactNode } from 'react';
3
- export type DialogBaseProps = {
4
- children: ReactNode;
5
- dataTestId?: string;
6
- defaultOpen?: boolean;
7
- isOpen?: boolean;
8
- modal?: boolean;
9
- onOpenChange?: (isOpen: boolean) => void;
10
- };
11
- export type DialogContextValue = {
12
- contentId: string;
13
- dataTestId?: string;
14
- descriptionId: string;
15
- modal: boolean;
16
- isOpen: boolean;
17
- setIsOpen: (isOpen: boolean) => void;
18
- titleId: string;
19
- };
20
- export type TriggerableElement = ReactElement<{
21
- onClick?: (...args: unknown[]) => void;
22
- }>;
23
- export declare function useDialogContext(): DialogContextValue;
24
- export declare function DialogBase({ isOpen: controlledIsOpen, defaultOpen, onOpenChange, children, modal }: DialogBaseProps): import("react/jsx-runtime").JSX.Element;
25
- type DialogTriggerProps = {
26
- asChild?: boolean;
27
- children: ReactNode;
28
- dataTestId?: string;
29
- };
30
- export declare function DialogTriggerBase({ children, asChild, dataTestId }: DialogTriggerProps): import("react/jsx-runtime").JSX.Element;
31
- type DialogCloseProps = {
32
- asChild?: boolean;
33
- children: ReactNode;
34
- dataTestId?: string;
35
- };
36
- export declare function DialogCloseBase({ children, asChild, dataTestId }: DialogCloseProps): import("react/jsx-runtime").JSX.Element;
37
- type DialogPortalProps = {
38
- children: ReactNode;
39
- container?: Element | DocumentFragment;
40
- };
41
- export declare function DialogPortalBase({ children, container }: DialogPortalProps): import('react').ReactPortal | null;
42
- type DialogOverlayProps = {
43
- className?: string;
44
- dataTestId?: string;
45
- };
46
- export declare function DialogOverlayBase({ className, dataTestId }: DialogOverlayProps): import("react/jsx-runtime").JSX.Element | null;
47
- declare const contentVariants: (props?: ({
48
- size?: "sm" | "md" | "lg" | "xl" | "2xl" | null | undefined;
49
- } & import('class-variance-authority/types').ClassProp) | undefined) => string;
50
- export type DialogSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
51
- export type DialogContentProps = {
52
- children: ReactNode;
53
- className?: string;
54
- dataTestId?: string;
55
- onEscapeKeyDown?: (event: KeyboardEvent) => void;
56
- onInteractOutside?: (event: PointerEvent | KeyboardEvent) => void;
57
- onPointerDownOutside?: (event: PointerEvent) => void;
58
- size?: DialogSize;
59
- } & VariantProps<typeof contentVariants>;
60
- export declare function DialogContentBase({ children, className, dataTestId, onEscapeKeyDown, onInteractOutside, onPointerDownOutside, size }: DialogContentProps): import("react/jsx-runtime").JSX.Element | null;
61
- type DialogTitleProps = {
62
- children: ReactNode;
63
- className?: string;
64
- dataTestId?: string;
65
- };
66
- export declare function DialogTitleBase({ children, className, dataTestId }: DialogTitleProps): import("react/jsx-runtime").JSX.Element;
67
- type DialogDescriptionProps = {
68
- children?: ReactNode;
69
- className?: string;
70
- dataTestId?: string;
71
- };
72
- export declare function DialogDescriptionBase({ children, className, dataTestId }: DialogDescriptionProps): import("react/jsx-runtime").JSX.Element;
73
- type DialogHeaderProps = {
74
- children?: ReactNode;
75
- className?: string;
76
- dataTestId?: string;
77
- };
78
- export declare function DialogHeaderBase({ children, className, dataTestId }: DialogHeaderProps): import("react/jsx-runtime").JSX.Element;
79
- type DialogFooterProps = {
80
- children?: ReactNode;
81
- className?: string;
82
- dataTestId?: string;
83
- };
84
- export declare function DialogFooterBase({ children, className, dataTestId }: DialogFooterProps): import("react/jsx-runtime").JSX.Element;
85
- export {};
86
- //# sourceMappingURL=DialogBase.d.ts.map