@cystackapp/ui 1.4.0
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/assets/background-pattern-circles-md.svg.js +5 -0
- package/dist/components/badge/Badge.d.ts +29 -0
- package/dist/components/badge/Badge.js +67 -0
- package/dist/components/badge/BadgeTestStory.d.ts +5 -0
- package/dist/components/badge/badge-utils.d.ts +27 -0
- package/dist/components/badge/badge-utils.js +74 -0
- package/dist/components/badge/variants/BadgeMore.d.ts +6 -0
- package/dist/components/badge/variants/BadgeMore.js +10 -0
- package/dist/components/badge/variants/BadgeMoreTestStory.d.ts +5 -0
- package/dist/components/badge/variants/BadgeTag.d.ts +10 -0
- package/dist/components/badge/variants/BadgeTag.js +50 -0
- package/dist/components/combobox/Combobox.d.ts +96 -0
- package/dist/components/combobox/Combobox.js +206 -0
- package/dist/components/combobox/use-validated-combobox.d.ts +17 -0
- package/dist/components/combobox/use-validated-combobox.js +23 -0
- package/dist/components/error-state/ErrorState.d.ts +9 -0
- package/dist/components/error-state/ErrorState.js +33 -0
- package/dist/components/page-title/PageTitle.d.ts +7 -0
- package/dist/components/page-title/PageTitle.js +6 -0
- package/dist/components/popover/Popover.d.ts +8 -0
- package/dist/components/popover/Popover.js +42 -0
- package/dist/components/popover/use-popover-coord.d.ts +24 -0
- package/dist/components/popover/use-popover-coord.js +130 -0
- package/dist/components/switch/Switch.d.ts +7 -0
- package/dist/components/switch/Switch.js +39 -0
- package/dist/components/tooltip/Tooltip.d.ts +11 -0
- package/dist/components/tooltip/Tooltip.js +58 -0
- package/dist/components/tooltip/tooltip-utils.d.ts +4 -0
- package/dist/components/tooltip/tooltip-utils.js +120 -0
- package/dist/hooks/element-shift/use-animation-frame.d.ts +4 -0
- package/dist/hooks/element-shift/use-animation-frame.js +14 -0
- package/dist/hooks/element-shift/use-element-shift.d.ts +17 -0
- package/dist/hooks/element-shift/use-element-shift.js +22 -0
- package/dist/hooks/element-shift/use-mutation-observer.d.ts +4 -0
- package/dist/hooks/element-shift/use-mutation-observer.js +15 -0
- package/dist/hooks/element-shift/use-resize-observer.d.ts +5 -0
- package/dist/hooks/element-shift/use-resize-observer.js +13 -0
- package/dist/hooks/element-shift/use-scroll-listener.d.ts +5 -0
- package/dist/hooks/element-shift/use-scroll-listener.js +26 -0
- package/dist/hooks/element-shift/use-transition-end-listener.d.ts +5 -0
- package/dist/hooks/element-shift/use-transition-end-listener.js +28 -0
- package/dist/hooks/element-shift/use-window-resize-listener.d.ts +4 -0
- package/dist/hooks/element-shift/use-window-resize-listener.js +10 -0
- package/dist/i18n/resources.d.ts +2 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +42 -0
- package/dist/node_modules/clsx/dist/clsx.js +16 -0
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +2924 -0
- package/dist/utils/cn.d.ts +2 -0
- package/dist/utils/cn.js +8 -0
- package/package.json +66 -0
- package/theme.css +358 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsxs as r, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { AlertCircle as c } from "@untitled-ui/icons-react";
|
|
4
|
+
import { cn as i } from "../../utils/cn.js";
|
|
5
|
+
import m from "../../assets/background-pattern-circles-md.svg.js";
|
|
6
|
+
const p = ({
|
|
7
|
+
title: s,
|
|
8
|
+
supportingText: l,
|
|
9
|
+
buttons: t,
|
|
10
|
+
className: a
|
|
11
|
+
}) => /* @__PURE__ */ r(
|
|
12
|
+
"div",
|
|
13
|
+
{
|
|
14
|
+
className: i(
|
|
15
|
+
"relative flex flex-1 flex-col items-center justify-center gap-8 overflow-hidden pb-6 pt-12",
|
|
16
|
+
a
|
|
17
|
+
),
|
|
18
|
+
children: [
|
|
19
|
+
/* @__PURE__ */ e(m, { className: "absolute -top-[10.55rem] h-120 w-120" }),
|
|
20
|
+
/* @__PURE__ */ r("div", { className: "z-10 flex flex-col items-center gap-5", children: [
|
|
21
|
+
/* @__PURE__ */ e("div", { className: "flex size-12 items-center justify-center rounded-lg border border-gray-v2-200 bg-white shadow-xs", children: /* @__PURE__ */ e(c, { className: "size-6 shrink-0 text-gray-v2-500" }) }),
|
|
22
|
+
/* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-2 px-3 text-center", children: [
|
|
23
|
+
/* @__PURE__ */ e("span", { className: "text-lg font-semibold text-gray-v2-700", children: s }),
|
|
24
|
+
l ? /* @__PURE__ */ e("span", { className: "text-sm text-gray-v2", children: l }) : null
|
|
25
|
+
] })
|
|
26
|
+
] }),
|
|
27
|
+
t ? /* @__PURE__ */ e("div", { className: "flex gap-3", children: t }) : null
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
export {
|
|
32
|
+
p as ErrorState
|
|
33
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
content: ReactNode;
|
|
4
|
+
contentClassName?: string;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const Popover: ({ content, contentClassName, children }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsxs as p, jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as s, useState as f } from "react";
|
|
3
|
+
import { cn as c } from "../../utils/cn.js";
|
|
4
|
+
import { usePopoverCoord as d } from "./use-popover-coord.js";
|
|
5
|
+
const M = ({ content: r, contentClassName: l, children: n }) => {
|
|
6
|
+
const e = s(null), o = s(null), [a, t] = f(!1), { style: i } = d(e, o, {
|
|
7
|
+
position: "bottomLeft",
|
|
8
|
+
syncWidth: !1
|
|
9
|
+
});
|
|
10
|
+
return /* @__PURE__ */ p(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
ref: e,
|
|
14
|
+
className: "relative",
|
|
15
|
+
onMouseOver: () => {
|
|
16
|
+
t(!0);
|
|
17
|
+
},
|
|
18
|
+
onMouseOut: () => {
|
|
19
|
+
t(!1);
|
|
20
|
+
},
|
|
21
|
+
children: [
|
|
22
|
+
n,
|
|
23
|
+
/* @__PURE__ */ u(
|
|
24
|
+
"div",
|
|
25
|
+
{
|
|
26
|
+
ref: o,
|
|
27
|
+
className: c(
|
|
28
|
+
"z-10 p-2 flex flex-wrap items-start justify-start gap-1 border border-gray-v2-200 bg-white rounded-lg shadow-lg transition-all",
|
|
29
|
+
a ? "" : "scale-90 opacity-0 invisible",
|
|
30
|
+
l
|
|
31
|
+
),
|
|
32
|
+
style: i,
|
|
33
|
+
children: r
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
M as Popover
|
|
42
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CSSProperties, RefObject } from 'react';
|
|
2
|
+
export declare const DEFAULT_OFFSET = 4;
|
|
3
|
+
export type PopoverPosition = "topLeft" | "top" | "topRight" | "bottomLeft" | "bottom" | "bottomRight" | "leftTop" | "left" | "leftBottom" | "rightTop" | "right" | "rightBottom";
|
|
4
|
+
/**
|
|
5
|
+
* A hook that takes a HTMLElement ref, and return style (position) to stick a popover into it.
|
|
6
|
+
*
|
|
7
|
+
* Exported for consumers that build custom popover-like UI (e.g. dropdowns, comboboxes)
|
|
8
|
+
* without using the {@link Popover} wrapper component directly.
|
|
9
|
+
*
|
|
10
|
+
* @param triggerRef - ref object of trigger button element.
|
|
11
|
+
* @param popoverRef - ref object of the popover element. Used for auto-flip on viewport overflow.
|
|
12
|
+
* @param options.position - decide transform origin and where to place the popover.
|
|
13
|
+
* @param options.syncWidth - default true. When set true, popover width will be sync with trigger button width.
|
|
14
|
+
* @param options.offset - gap between trigger and popover. Default: 4.
|
|
15
|
+
* @returns `style` — CSSProperties for the popover container; `resolvedPosition` — the actual placement after auto-flip.
|
|
16
|
+
*/
|
|
17
|
+
export declare function usePopoverCoord(triggerRef: RefObject<HTMLElement>, popoverRef: RefObject<HTMLElement>, options?: {
|
|
18
|
+
position?: PopoverPosition;
|
|
19
|
+
syncWidth?: boolean;
|
|
20
|
+
offset?: number;
|
|
21
|
+
}): {
|
|
22
|
+
style: CSSProperties;
|
|
23
|
+
resolvedPosition: PopoverPosition;
|
|
24
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { useState as s, useMemo as a, useCallback as V } from "react";
|
|
2
|
+
import { useElementShift as $ } from "../../hooks/element-shift/use-element-shift.js";
|
|
3
|
+
const M = 4, y = {
|
|
4
|
+
// Top/bottom family — flip vertical axis; flip horizontal axis separately
|
|
5
|
+
topLeft: {
|
|
6
|
+
overflowV: "bottomLeft",
|
|
7
|
+
overflowH: "topRight",
|
|
8
|
+
overflowBoth: "bottomRight"
|
|
9
|
+
},
|
|
10
|
+
top: { overflowV: "bottom", overflowH: "top", overflowBoth: "bottom" },
|
|
11
|
+
topRight: {
|
|
12
|
+
overflowV: "bottomRight",
|
|
13
|
+
overflowH: "topLeft",
|
|
14
|
+
overflowBoth: "bottomLeft"
|
|
15
|
+
},
|
|
16
|
+
bottomLeft: {
|
|
17
|
+
overflowV: "topLeft",
|
|
18
|
+
overflowH: "bottomRight",
|
|
19
|
+
overflowBoth: "topRight"
|
|
20
|
+
},
|
|
21
|
+
bottom: { overflowV: "top", overflowH: "bottom", overflowBoth: "top" },
|
|
22
|
+
bottomRight: {
|
|
23
|
+
overflowV: "topRight",
|
|
24
|
+
overflowH: "bottomLeft",
|
|
25
|
+
overflowBoth: "topLeft"
|
|
26
|
+
},
|
|
27
|
+
// Right/left family — flip vertical alignment; flip side separately
|
|
28
|
+
rightTop: {
|
|
29
|
+
overflowV: "rightBottom",
|
|
30
|
+
overflowH: "leftTop",
|
|
31
|
+
overflowBoth: "leftBottom"
|
|
32
|
+
},
|
|
33
|
+
right: { overflowV: "right", overflowH: "left", overflowBoth: "left" },
|
|
34
|
+
rightBottom: {
|
|
35
|
+
overflowV: "rightTop",
|
|
36
|
+
overflowH: "leftBottom",
|
|
37
|
+
overflowBoth: "leftTop"
|
|
38
|
+
},
|
|
39
|
+
leftTop: {
|
|
40
|
+
overflowV: "leftBottom",
|
|
41
|
+
overflowH: "rightTop",
|
|
42
|
+
overflowBoth: "rightBottom"
|
|
43
|
+
},
|
|
44
|
+
left: { overflowV: "left", overflowH: "right", overflowBoth: "right" },
|
|
45
|
+
leftBottom: {
|
|
46
|
+
overflowV: "leftTop",
|
|
47
|
+
overflowH: "rightBottom",
|
|
48
|
+
overflowBoth: "rightTop"
|
|
49
|
+
}
|
|
50
|
+
}, C = {
|
|
51
|
+
topLeft: "bottom left",
|
|
52
|
+
top: "bottom",
|
|
53
|
+
topRight: "bottom right",
|
|
54
|
+
bottomLeft: "top left",
|
|
55
|
+
bottom: "top",
|
|
56
|
+
bottomRight: "top right",
|
|
57
|
+
leftTop: "top right",
|
|
58
|
+
left: "right",
|
|
59
|
+
leftBottom: "bottom right",
|
|
60
|
+
rightTop: "top left",
|
|
61
|
+
right: "left",
|
|
62
|
+
rightBottom: "bottom left"
|
|
63
|
+
};
|
|
64
|
+
function O(n, w, m = {}) {
|
|
65
|
+
const l = m.position ?? "bottomLeft", b = m.syncWidth ?? !0, r = m.offset ?? M, [t, B] = s(), [o, c] = s(l), [i, x] = s(), d = a(() => t === void 0 ? {} : o === "topLeft" ? {
|
|
66
|
+
bottom: `calc(100vh - ${t.top - r}px)`,
|
|
67
|
+
left: t.left
|
|
68
|
+
} : o === "top" ? {
|
|
69
|
+
bottom: `calc(100vh - ${t.top - r}px)`,
|
|
70
|
+
left: t.left + t.width / 2 - ((i == null ? void 0 : i.width) ?? 0) / 2
|
|
71
|
+
} : o === "topRight" ? {
|
|
72
|
+
bottom: `calc(100vh - ${t.top - r}px)`,
|
|
73
|
+
right: `calc(100vw - ${t.right}px)`
|
|
74
|
+
} : o === "bottomLeft" ? { top: t.bottom + r, left: t.left } : o === "bottom" ? {
|
|
75
|
+
top: t.bottom + r,
|
|
76
|
+
left: t.left + t.width / 2 - ((i == null ? void 0 : i.width) ?? 0) / 2
|
|
77
|
+
} : o === "bottomRight" ? {
|
|
78
|
+
top: t.bottom + r,
|
|
79
|
+
right: `calc(100vw - ${t.right}px)`
|
|
80
|
+
} : o === "leftTop" ? {
|
|
81
|
+
top: t.top,
|
|
82
|
+
right: `calc(100vw - ${t.left - r}px)`
|
|
83
|
+
} : o === "left" ? {
|
|
84
|
+
top: t.top + t.height / 2 - ((i == null ? void 0 : i.height) ?? 0) / 2,
|
|
85
|
+
right: `calc(100vw - ${t.left - r}px)`
|
|
86
|
+
} : o === "leftBottom" ? {
|
|
87
|
+
bottom: `calc(100vh - ${t.bottom}px)`,
|
|
88
|
+
right: `calc(100vw - ${t.left - r}px)`
|
|
89
|
+
} : o === "rightTop" ? { top: t.top, left: t.right + r } : o === "right" ? {
|
|
90
|
+
top: t.top + t.height / 2 - ((i == null ? void 0 : i.height) ?? 0) / 2,
|
|
91
|
+
left: t.right + r
|
|
92
|
+
} : o === "rightBottom" ? {
|
|
93
|
+
bottom: `calc(100vh - ${t.bottom}px)`,
|
|
94
|
+
left: t.right + r
|
|
95
|
+
} : {}, [t, o, r, i]), H = a(() => t === void 0 ? { position: "fixed", visibility: "hidden" } : {
|
|
96
|
+
position: "fixed",
|
|
97
|
+
...d,
|
|
98
|
+
width: b ? t.width : void 0,
|
|
99
|
+
transformOrigin: C[o]
|
|
100
|
+
}, [t, o, d, b]), L = V(() => {
|
|
101
|
+
if (!n.current) return;
|
|
102
|
+
const g = n.current.getBoundingClientRect();
|
|
103
|
+
if (B((f) => {
|
|
104
|
+
const e = {
|
|
105
|
+
top: Math.round(g.top),
|
|
106
|
+
bottom: Math.round(g.bottom),
|
|
107
|
+
left: Math.round(g.left),
|
|
108
|
+
right: Math.round(g.right),
|
|
109
|
+
width: Math.round(g.width),
|
|
110
|
+
height: Math.round(g.height)
|
|
111
|
+
};
|
|
112
|
+
return f === void 0 ? e : f.top === e.top && f.bottom === e.bottom && f.left === e.left && f.right === e.right && f.width === e.width && f.height === e.height ? f : e;
|
|
113
|
+
}), w.current && n.current) {
|
|
114
|
+
const f = n.current.getBoundingClientRect(), e = w.current.getBoundingClientRect();
|
|
115
|
+
x({ width: e.width, height: e.height });
|
|
116
|
+
const h = {
|
|
117
|
+
top: f.top - e.height < 0,
|
|
118
|
+
bottom: f.bottom + e.height > window.innerHeight,
|
|
119
|
+
left: f.right - e.width < 0,
|
|
120
|
+
right: f.left + e.width > window.innerWidth
|
|
121
|
+
}, p = y[l], R = l.startsWith("top"), T = l.startsWith("left") || l.endsWith("Right"), u = R ? h.top && !h.bottom : h.bottom && !h.top, v = T ? h.left && !h.right : h.right && !h.left;
|
|
122
|
+
c(u && v ? p.overflowBoth : u ? p.overflowV : v ? p.overflowH : l);
|
|
123
|
+
}
|
|
124
|
+
}, [w, l, n]);
|
|
125
|
+
return $(n, L), { style: H, resolvedPosition: o };
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
M as DEFAULT_OFFSET,
|
|
129
|
+
O as usePopoverCoord
|
|
130
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes } from 'react';
|
|
2
|
+
interface Props extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type" | "role" | "aria-checked" | "onClick" | "onChange"> {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
onChange?: (checked: boolean) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const Switch: ({ checked, onChange, className, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u } from "react";
|
|
3
|
+
import { cn as a } from "../../utils/cn.js";
|
|
4
|
+
const b = ({ checked: e, onChange: n, className: i, ...r }) => {
|
|
5
|
+
const [l, c] = u(
|
|
6
|
+
e ?? !1
|
|
7
|
+
), t = e ?? l;
|
|
8
|
+
return /* @__PURE__ */ o(
|
|
9
|
+
"button",
|
|
10
|
+
{
|
|
11
|
+
type: "button",
|
|
12
|
+
role: "switch",
|
|
13
|
+
"aria-checked": t,
|
|
14
|
+
onClick: () => {
|
|
15
|
+
const s = !t;
|
|
16
|
+
n && n(s), c(s);
|
|
17
|
+
},
|
|
18
|
+
...r,
|
|
19
|
+
className: a(
|
|
20
|
+
"relative w-9 h-5 shrink-0 p-0.5 rounded-full transition-colors duration-300 ease-in-out",
|
|
21
|
+
"outline-2 outline-offset-2 outline-transparent focus-visible:outline-brand-v2-600",
|
|
22
|
+
t ? "bg-brand-v2-600" : "bg-gray-v2-200",
|
|
23
|
+
i
|
|
24
|
+
),
|
|
25
|
+
children: /* @__PURE__ */ o(
|
|
26
|
+
"span",
|
|
27
|
+
{
|
|
28
|
+
className: a(
|
|
29
|
+
"absolute inset-0.5 size-4 rounded-full transition-all bg-white shadow-[var(--shadow-sm-01),var(--shadow-sm-02)]",
|
|
30
|
+
t ? "translate-x-full" : ""
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
b as Switch
|
|
39
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PopoverPosition } from '../popover/use-popover-coord';
|
|
3
|
+
interface Props {
|
|
4
|
+
content: ReactNode;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
position?: PopoverPosition;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const Tooltip: ({ content, children, position, disabled, className, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as t, Fragment as g, jsxs as m } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as p, useState as x } from "react";
|
|
3
|
+
import { createPortal as v } from "react-dom";
|
|
4
|
+
import { cn as h } from "../../utils/cn.js";
|
|
5
|
+
import { usePopoverCoord as w } from "../popover/use-popover-coord.js";
|
|
6
|
+
import { getArrowStyle as M, getBridgeStyle as S } from "./tooltip-utils.js";
|
|
7
|
+
const E = ({
|
|
8
|
+
content: r,
|
|
9
|
+
children: s,
|
|
10
|
+
position: d = "top",
|
|
11
|
+
disabled: u = !1,
|
|
12
|
+
className: f
|
|
13
|
+
}) => {
|
|
14
|
+
const l = p(null), n = p(null), [c, i] = x(!1), { style: y, resolvedPosition: a } = w(
|
|
15
|
+
l,
|
|
16
|
+
n,
|
|
17
|
+
{ position: d, syncWidth: !1 }
|
|
18
|
+
), e = () => i(!0), o = () => i(!1);
|
|
19
|
+
return u || r == null ? /* @__PURE__ */ t(g, { children: s }) : /* @__PURE__ */ m(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
ref: l,
|
|
23
|
+
className: "relative w-fit min-w-0",
|
|
24
|
+
onMouseEnter: e,
|
|
25
|
+
onMouseLeave: o,
|
|
26
|
+
onFocus: e,
|
|
27
|
+
onBlur: o,
|
|
28
|
+
children: [
|
|
29
|
+
s,
|
|
30
|
+
v(
|
|
31
|
+
/* @__PURE__ */ m(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
ref: n,
|
|
35
|
+
role: "tooltip",
|
|
36
|
+
className: h(
|
|
37
|
+
"z-50 w-max max-w-xs px-3 py-2 rounded-lg bg-gray-v2-900 text-white text-xs font-medium leading-4.5 shadow-lg transition-all",
|
|
38
|
+
c ? "" : "scale-90 opacity-0 invisible",
|
|
39
|
+
f
|
|
40
|
+
),
|
|
41
|
+
style: y,
|
|
42
|
+
onMouseEnter: e,
|
|
43
|
+
onMouseLeave: o,
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ t("span", { "aria-hidden": "true", style: S(a), children: /* @__PURE__ */ t("span", { style: M(a) }) }),
|
|
46
|
+
r
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
document.body
|
|
51
|
+
)
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
E as Tooltip
|
|
58
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { DEFAULT_OFFSET as e } from "../popover/use-popover-coord.js";
|
|
2
|
+
const i = "var(--color-gray-v2-900)", t = 5, r = 10, l = {
|
|
3
|
+
width: 0,
|
|
4
|
+
height: 0,
|
|
5
|
+
borderLeft: `${t}px solid transparent`,
|
|
6
|
+
borderRight: `${t}px solid transparent`,
|
|
7
|
+
borderTop: `${t}px solid ${i}`
|
|
8
|
+
}, s = {
|
|
9
|
+
width: 0,
|
|
10
|
+
height: 0,
|
|
11
|
+
borderLeft: `${t}px solid transparent`,
|
|
12
|
+
borderRight: `${t}px solid transparent`,
|
|
13
|
+
borderBottom: `${t}px solid ${i}`
|
|
14
|
+
}, n = {
|
|
15
|
+
width: 0,
|
|
16
|
+
height: 0,
|
|
17
|
+
borderTop: `${t}px solid transparent`,
|
|
18
|
+
borderBottom: `${t}px solid transparent`,
|
|
19
|
+
borderLeft: `${t}px solid ${i}`
|
|
20
|
+
}, p = {
|
|
21
|
+
width: 0,
|
|
22
|
+
height: 0,
|
|
23
|
+
borderTop: `${t}px solid transparent`,
|
|
24
|
+
borderBottom: `${t}px solid transparent`,
|
|
25
|
+
borderRight: `${t}px solid ${i}`
|
|
26
|
+
};
|
|
27
|
+
function h(o) {
|
|
28
|
+
return o.startsWith("top") ? {
|
|
29
|
+
position: "absolute",
|
|
30
|
+
top: "100%",
|
|
31
|
+
left: 0,
|
|
32
|
+
width: "100%",
|
|
33
|
+
height: e
|
|
34
|
+
} : o.startsWith("bottom") ? {
|
|
35
|
+
position: "absolute",
|
|
36
|
+
bottom: "100%",
|
|
37
|
+
left: 0,
|
|
38
|
+
width: "100%",
|
|
39
|
+
height: e
|
|
40
|
+
} : o.startsWith("left") ? {
|
|
41
|
+
position: "absolute",
|
|
42
|
+
left: "100%",
|
|
43
|
+
top: 0,
|
|
44
|
+
width: e,
|
|
45
|
+
height: "100%"
|
|
46
|
+
} : {
|
|
47
|
+
position: "absolute",
|
|
48
|
+
right: "100%",
|
|
49
|
+
top: 0,
|
|
50
|
+
width: e,
|
|
51
|
+
height: "100%"
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function b(o) {
|
|
55
|
+
return o === "topLeft" ? {
|
|
56
|
+
...l,
|
|
57
|
+
position: "absolute",
|
|
58
|
+
top: 0,
|
|
59
|
+
left: r
|
|
60
|
+
} : o === "top" ? {
|
|
61
|
+
...l,
|
|
62
|
+
position: "absolute",
|
|
63
|
+
top: 0,
|
|
64
|
+
left: `calc(50% - ${t}px)`
|
|
65
|
+
} : o === "topRight" ? {
|
|
66
|
+
...l,
|
|
67
|
+
position: "absolute",
|
|
68
|
+
top: 0,
|
|
69
|
+
right: r
|
|
70
|
+
} : o === "bottomLeft" ? {
|
|
71
|
+
...s,
|
|
72
|
+
position: "absolute",
|
|
73
|
+
bottom: 0,
|
|
74
|
+
left: r
|
|
75
|
+
} : o === "bottom" ? {
|
|
76
|
+
...s,
|
|
77
|
+
position: "absolute",
|
|
78
|
+
bottom: 0,
|
|
79
|
+
left: `calc(50% - ${t}px)`
|
|
80
|
+
} : o === "bottomRight" ? {
|
|
81
|
+
...s,
|
|
82
|
+
position: "absolute",
|
|
83
|
+
bottom: 0,
|
|
84
|
+
right: r
|
|
85
|
+
} : o === "leftTop" ? {
|
|
86
|
+
...n,
|
|
87
|
+
position: "absolute",
|
|
88
|
+
left: 0,
|
|
89
|
+
top: r
|
|
90
|
+
} : o === "left" ? {
|
|
91
|
+
...n,
|
|
92
|
+
position: "absolute",
|
|
93
|
+
left: 0,
|
|
94
|
+
top: `calc(50% - ${t}px)`
|
|
95
|
+
} : o === "leftBottom" ? {
|
|
96
|
+
...n,
|
|
97
|
+
position: "absolute",
|
|
98
|
+
left: 0,
|
|
99
|
+
bottom: r
|
|
100
|
+
} : o === "rightTop" ? {
|
|
101
|
+
...p,
|
|
102
|
+
position: "absolute",
|
|
103
|
+
right: 0,
|
|
104
|
+
top: r
|
|
105
|
+
} : o === "right" ? {
|
|
106
|
+
...p,
|
|
107
|
+
position: "absolute",
|
|
108
|
+
right: 0,
|
|
109
|
+
top: `calc(50% - ${t}px)`
|
|
110
|
+
} : {
|
|
111
|
+
...p,
|
|
112
|
+
position: "absolute",
|
|
113
|
+
right: 0,
|
|
114
|
+
bottom: r
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export {
|
|
118
|
+
b as getArrowStyle,
|
|
119
|
+
h as getBridgeStyle
|
|
120
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useLayoutEffect as i } from "react";
|
|
2
|
+
function o(t, r = !1) {
|
|
3
|
+
i(() => {
|
|
4
|
+
if (!r) return;
|
|
5
|
+
let e;
|
|
6
|
+
const n = () => {
|
|
7
|
+
t(), e = requestAnimationFrame(n);
|
|
8
|
+
};
|
|
9
|
+
return e = requestAnimationFrame(n), () => cancelAnimationFrame(e);
|
|
10
|
+
}, [t, r]);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
o as useAnimationFrame
|
|
14
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Triggers `update` every time the element is shifted on screen.
|
|
4
|
+
*
|
|
5
|
+
* Composed from individual hooks — use them directly when you only need
|
|
6
|
+
* a subset of the shift detection behaviors.
|
|
7
|
+
*
|
|
8
|
+
* @param animationFrame - poll on every animation frame. Very costly; off by default.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useElementShift(elementRef: RefObject<Element | null>, update: () => void, { ancestorScroll, ancestorResize, elementResize, layoutShift, transitionEnd, animationFrame, }?: {
|
|
11
|
+
ancestorScroll?: boolean | undefined;
|
|
12
|
+
ancestorResize?: boolean | undefined;
|
|
13
|
+
elementResize?: boolean | undefined;
|
|
14
|
+
layoutShift?: boolean | undefined;
|
|
15
|
+
transitionEnd?: boolean | undefined;
|
|
16
|
+
animationFrame?: boolean | undefined;
|
|
17
|
+
}): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useLayoutEffect as f } from "react";
|
|
2
|
+
import { useResizeObserver as u } from "./use-resize-observer.js";
|
|
3
|
+
import { useScrollListener as L } from "./use-scroll-listener.js";
|
|
4
|
+
import { useWindowResizeListener as c } from "./use-window-resize-listener.js";
|
|
5
|
+
import { useMutationObserver as E } from "./use-mutation-observer.js";
|
|
6
|
+
import { useTransitionEndListener as b } from "./use-transition-end-listener.js";
|
|
7
|
+
import { useAnimationFrame as l } from "./use-animation-frame.js";
|
|
8
|
+
function x(o, r, {
|
|
9
|
+
ancestorScroll: i = !0,
|
|
10
|
+
ancestorResize: e = !0,
|
|
11
|
+
elementResize: s = !0,
|
|
12
|
+
layoutShift: t = !0,
|
|
13
|
+
transitionEnd: m = !0,
|
|
14
|
+
animationFrame: n = !1
|
|
15
|
+
} = {}) {
|
|
16
|
+
L(o, r, i), c(r, e), E(r, t), b(o, r, m), l(r, n), u(o, r, s), f(() => {
|
|
17
|
+
r();
|
|
18
|
+
}, [r]);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
x as useElementShift
|
|
22
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useLayoutEffect as u } from "react";
|
|
2
|
+
function s(t, e = !0) {
|
|
3
|
+
u(() => {
|
|
4
|
+
if (!e) return;
|
|
5
|
+
const r = new MutationObserver(t);
|
|
6
|
+
return r.observe(document.body, {
|
|
7
|
+
attributes: !0,
|
|
8
|
+
childList: !0,
|
|
9
|
+
subtree: !0
|
|
10
|
+
}), () => r.disconnect();
|
|
11
|
+
}, [t, e]);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
s as useMutationObserver
|
|
15
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useLayoutEffect as s } from "react";
|
|
2
|
+
function c(e, r, t = !0) {
|
|
3
|
+
s(() => {
|
|
4
|
+
if (!t) return;
|
|
5
|
+
const n = e.current;
|
|
6
|
+
if (!n) return;
|
|
7
|
+
const o = new ResizeObserver(r);
|
|
8
|
+
return o.observe(n), () => o.disconnect();
|
|
9
|
+
}, [e, r, t]);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
c as useResizeObserver
|
|
13
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useLayoutEffect as u } from "react";
|
|
2
|
+
function l(o) {
|
|
3
|
+
const t = [];
|
|
4
|
+
let e = o.parentElement;
|
|
5
|
+
for (; e && e !== document.body; ) {
|
|
6
|
+
const r = getComputedStyle(e), n = r.overflow + r.overflowX + r.overflowY;
|
|
7
|
+
/(auto|scroll|overlay)/.test(n) && t.push(e), e = e.parentElement;
|
|
8
|
+
}
|
|
9
|
+
return t.push(window), t;
|
|
10
|
+
}
|
|
11
|
+
function f(o, t, e = !0) {
|
|
12
|
+
u(() => {
|
|
13
|
+
if (!e) return;
|
|
14
|
+
const r = o.current;
|
|
15
|
+
if (!r) return;
|
|
16
|
+
const n = l(r);
|
|
17
|
+
return n.forEach(
|
|
18
|
+
(s) => s.addEventListener("scroll", t, { passive: !0 })
|
|
19
|
+
), () => n.forEach(
|
|
20
|
+
(s) => s.removeEventListener("scroll", t)
|
|
21
|
+
);
|
|
22
|
+
}, [o, t, e]);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
f as useScrollListener
|
|
26
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Listens for `transitionend` events on all CSS-transformed ancestors of the element.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useTransitionEndListener(ref: RefObject<Element | null>, onTransitionEnd: () => void, isEnabled?: boolean): void;
|