@caseparts-org/caseblocks 0.0.89 → 0.0.91

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.
Files changed (47) hide show
  1. package/dist/Cart.module-9txlotpz.js +18 -0
  2. package/dist/assets/Cart.css +1 -1
  3. package/dist/assets/Icon.css +1 -1
  4. package/dist/assets/Popover.css +1 -0
  5. package/dist/assets/SlideInPanel.css +1 -0
  6. package/dist/assets/Tooltip.css +1 -1
  7. package/dist/assets/buttonClassName.css +1 -1
  8. package/dist/atoms/Button/buttonClassName.js +25 -25
  9. package/dist/atoms/Icon/Icon.d.ts +3 -1
  10. package/dist/atoms/Icon/Icon.js +48 -32
  11. package/dist/atoms/Input/Input.js +4 -4
  12. package/dist/atoms/Popover/Popover.d.ts +14 -0
  13. package/dist/atoms/Popover/Popover.js +110 -0
  14. package/dist/atoms/Popover/Popover.stories.d.ts +66 -0
  15. package/dist/atoms/Popover/Popover.stories.js +207 -0
  16. package/dist/atoms/SlideInPanel/SlideInPanel.d.ts +18 -0
  17. package/dist/atoms/SlideInPanel/SlideInPanel.js +99 -0
  18. package/dist/atoms/SlideInPanel/SlideInPanel.stories.d.ts +10 -0
  19. package/dist/atoms/SlideInPanel/SlideInPanel.stories.js +117 -0
  20. package/dist/atoms/Tooltip/Tooltip.d.ts +16 -0
  21. package/dist/atoms/Tooltip/Tooltip.js +126 -0
  22. package/dist/{molecules → atoms}/Tooltip/Tooltip.stories.d.ts +8 -26
  23. package/dist/atoms/Tooltip/Tooltip.stories.js +209 -0
  24. package/dist/index-B4KbmMH3.js +383 -0
  25. package/dist/main-client.d.ts +3 -1
  26. package/dist/main-client.js +40 -38
  27. package/dist/molecules/AddToCart/AddToCart.js +18 -18
  28. package/dist/molecules/CardLink/CardLink.js +5 -5
  29. package/dist/molecules/Cart/Cart.d.ts +10 -6
  30. package/dist/molecules/Cart/Cart.js +42 -93
  31. package/dist/molecules/Cart/Cart.stories.js +61 -28
  32. package/dist/molecules/Cart/CartSlideInPanel.d.ts +15 -0
  33. package/dist/molecules/Cart/CartSlideInPanel.js +97 -0
  34. package/dist/molecules/CategoryNav/CategoryNav.js +2 -2
  35. package/dist/molecules/StatefulButton/StatefulButton.stories.js +4 -4
  36. package/dist/molecules/ToggleView/ToggleView.js +6 -6
  37. package/dist/organisms/Carousel/Carousel.js +44 -44
  38. package/dist/organisms/Footer/Footer.js +1 -1
  39. package/dist/organisms/MainNav/MainNav.d.ts +13 -11
  40. package/dist/organisms/MainNav/MainNav.js +86 -82
  41. package/dist/organisms/MainNav/MainNav.stories.d.ts +1 -2
  42. package/dist/organisms/MainNav/MainNav.stories.js +85 -58
  43. package/package.json +28 -7
  44. package/dist/molecules/Cart/Cart.stories.d.ts +0 -15
  45. package/dist/molecules/Tooltip/Tooltip.d.ts +0 -12
  46. package/dist/molecules/Tooltip/Tooltip.js +0 -2321
  47. package/dist/molecules/Tooltip/Tooltip.stories.js +0 -202
@@ -0,0 +1,207 @@
1
+ import { jsxs as t, jsx as e, Fragment as n } from "react/jsx-runtime";
2
+ import a from "react";
3
+ import { Popover as i } from "./Popover.js";
4
+ import { Button as o } from "../Button/Button.js";
5
+ const k = {
6
+ title: "Case Parts/Atoms/Popover",
7
+ component: i,
8
+ parameters: {
9
+ layout: "centered",
10
+ controls: { sort: "requiredFirst" },
11
+ docs: {
12
+ description: {
13
+ component: "Interactive popover opened by clicking its trigger. Closes on outside click or Escape. Position accepts side plus optional alignment."
14
+ }
15
+ }
16
+ },
17
+ tags: ["autodocs"],
18
+ args: {
19
+ position: "top center",
20
+ closeOnOutsideClick: !0,
21
+ disabled: !1
22
+ },
23
+ argTypes: {
24
+ position: {
25
+ control: "select",
26
+ options: [
27
+ "top",
28
+ "top left",
29
+ "top center",
30
+ "top right",
31
+ "right",
32
+ "right top",
33
+ "right center",
34
+ "right bottom",
35
+ "bottom",
36
+ "bottom left",
37
+ "bottom center",
38
+ "bottom right",
39
+ "left",
40
+ "left top",
41
+ "left center",
42
+ "left bottom"
43
+ ],
44
+ description: "Side plus optional alignment; single side centers automatically."
45
+ },
46
+ closeOnOutsideClick: {
47
+ control: "boolean",
48
+ description: "Close when clicking outside the popover."
49
+ },
50
+ disabled: {
51
+ control: "boolean",
52
+ description: "Disable opening."
53
+ },
54
+ popoverClassName: { table: { disable: !0 } },
55
+ contentClassName: { table: { disable: !0 } },
56
+ trigger: { table: { disable: !0 }, description: "Trigger element (click opens)." },
57
+ children: { description: "Popover content (interactive)." }
58
+ }
59
+ }, r = () => /* @__PURE__ */ e("style", { children: ".storyRoboto{font-family:'Roboto',sans-serif;}" }), R = {
60
+ render: (c) => /* @__PURE__ */ t(n, { children: [
61
+ /* @__PURE__ */ e(r, {}),
62
+ /* @__PURE__ */ e(
63
+ i,
64
+ {
65
+ ...c,
66
+ contentClassName: "storyRoboto",
67
+ trigger: /* @__PURE__ */ e(o, { size: "md", variant: "primary", children: "Open form" }),
68
+ children: /* @__PURE__ */ e(() => {
69
+ const [s, m] = a.useState(""), [p, h] = a.useState(""), [g, u] = a.useState(!1);
70
+ return /* @__PURE__ */ t(
71
+ "form",
72
+ {
73
+ onSubmit: (l) => {
74
+ l.preventDefault(), u(!0);
75
+ },
76
+ style: { display: "flex", flexDirection: "column", gap: 8, minWidth: 220 },
77
+ children: [
78
+ /* @__PURE__ */ t("label", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
79
+ /* @__PURE__ */ e("span", { children: "Name" }),
80
+ /* @__PURE__ */ e(
81
+ "input",
82
+ {
83
+ value: s,
84
+ onChange: (l) => m(l.target.value),
85
+ placeholder: "Jane Doe",
86
+ style: { padding: 4 }
87
+ }
88
+ )
89
+ ] }),
90
+ /* @__PURE__ */ t("label", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
91
+ /* @__PURE__ */ e("span", { children: "Email" }),
92
+ /* @__PURE__ */ e(
93
+ "input",
94
+ {
95
+ type: "email",
96
+ value: p,
97
+ onChange: (l) => h(l.target.value),
98
+ placeholder: "jane@example.com",
99
+ style: { padding: 4 }
100
+ }
101
+ )
102
+ ] }),
103
+ /* @__PURE__ */ e("button", { type: "submit", style: { padding: "4px 8px" }, children: "Submit" }),
104
+ g && /* @__PURE__ */ t("div", { style: { fontSize: 12, color: "var(--color-neutrals-neutral-6)" }, children: [
105
+ "Submitted: ",
106
+ s || "(no name)",
107
+ ", ",
108
+ p || "(no email)"
109
+ ] })
110
+ ]
111
+ }
112
+ );
113
+ }, {})
114
+ }
115
+ )
116
+ ] })
117
+ }, N = {
118
+ render: () => /* @__PURE__ */ t(n, { children: [
119
+ /* @__PURE__ */ e(r, {}),
120
+ /* @__PURE__ */ e(
121
+ i,
122
+ {
123
+ position: "bottom center",
124
+ contentClassName: "storyRoboto",
125
+ trigger: /* @__PURE__ */ e(o, { size: "md", variant: "secondary", children: "Bottom" }),
126
+ children: "Positioned below the trigger."
127
+ }
128
+ )
129
+ ] })
130
+ }, S = {
131
+ render: () => /* @__PURE__ */ t(n, { children: [
132
+ /* @__PURE__ */ e(r, {}),
133
+ /* @__PURE__ */ e(
134
+ i,
135
+ {
136
+ position: "right center",
137
+ contentClassName: "storyRoboto",
138
+ trigger: /* @__PURE__ */ e(o, { size: "md", variant: "cta-primary", children: "Right" }),
139
+ children: "Popover to the right."
140
+ }
141
+ )
142
+ ] })
143
+ }, P = {
144
+ render: () => /* @__PURE__ */ t(n, { children: [
145
+ /* @__PURE__ */ e(r, {}),
146
+ /* @__PURE__ */ e(
147
+ i,
148
+ {
149
+ position: "left center",
150
+ contentClassName: "storyRoboto",
151
+ trigger: /* @__PURE__ */ e(o, { size: "md", variant: "tertiary", children: "Left" }),
152
+ children: "Popover to the left."
153
+ }
154
+ )
155
+ ] })
156
+ }, O = {
157
+ render: () => /* @__PURE__ */ e(y, {})
158
+ }, y = () => {
159
+ const [c, d] = a.useState(0);
160
+ return /* @__PURE__ */ t(n, { children: [
161
+ /* @__PURE__ */ e(r, {}),
162
+ /* @__PURE__ */ e(
163
+ i,
164
+ {
165
+ position: "bottom left",
166
+ contentClassName: "storyRoboto",
167
+ trigger: /* @__PURE__ */ e(o, { size: "md", variant: "primary", children: "More interactivity" }),
168
+ children: /* @__PURE__ */ t("div", { style: { display: "flex", flexDirection: "column", gap: 10, minWidth: 240 }, children: [
169
+ /* @__PURE__ */ e("div", { style: { fontWeight: 500 }, children: "Counter demo" }),
170
+ /* @__PURE__ */ t("div", { style: { display: "flex", gap: 8, alignItems: "center" }, children: [
171
+ /* @__PURE__ */ e(o, { size: "sm", variant: "secondary", onClick: () => d((s) => s + 1), children: "Increment" }),
172
+ /* @__PURE__ */ e("span", { style: { minWidth: 32, textAlign: "center" }, children: c }),
173
+ /* @__PURE__ */ e(o, { size: "sm", variant: "tertiary", onClick: () => d(0), children: "Reset" })
174
+ ] }),
175
+ /* @__PURE__ */ e("hr", { style: { border: 0, height: 1, background: "#ddd" } }),
176
+ /* @__PURE__ */ t("label", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
177
+ /* @__PURE__ */ e("span", { children: "Notes" }),
178
+ /* @__PURE__ */ e("textarea", { rows: 3, placeholder: "Type notes...", style: { padding: 4 } })
179
+ ] })
180
+ ] })
181
+ }
182
+ )
183
+ ] });
184
+ }, z = {
185
+ render: () => /* @__PURE__ */ t(n, { children: [
186
+ /* @__PURE__ */ e(r, {}),
187
+ /* @__PURE__ */ e(
188
+ i,
189
+ {
190
+ position: "top center",
191
+ closeOnOutsideClick: !1,
192
+ contentClassName: "storyRoboto",
193
+ trigger: /* @__PURE__ */ e(o, { size: "md", variant: "destructive", children: "Manual close" }),
194
+ children: "Outside clicks will NOT close me. Press Escape."
195
+ }
196
+ )
197
+ ] })
198
+ };
199
+ export {
200
+ R as BasicClick,
201
+ N as BottomClick,
202
+ O as InteractiveContent,
203
+ z as OutsideClickDisabled,
204
+ P as PositionLeft,
205
+ S as PositionRight,
206
+ k as default
207
+ };
@@ -0,0 +1,18 @@
1
+ import { HideAtProps } from '../HideAt';
2
+ import * as React from "react";
3
+ export type SlideInSide = "left" | "right" | "bottom";
4
+ export interface SlideInPanelProps extends HideAtProps {
5
+ side: SlideInSide;
6
+ open: boolean;
7
+ onClose: () => void;
8
+ children: React.ReactNode;
9
+ width?: number | string;
10
+ height?: number | string;
11
+ className?: string;
12
+ overlayClassName?: string;
13
+ panelClassName?: string;
14
+ closeOnOverlayClick?: boolean;
15
+ disableEsc?: boolean;
16
+ ariaLabel?: string;
17
+ }
18
+ export declare const SlideInPanel: React.FC<SlideInPanelProps>;
@@ -0,0 +1,99 @@
1
+ import { jsxs as k, jsx as u } from "react/jsx-runtime";
2
+ import * as r from "react";
3
+ import { r as A } from "../../index-B4KbmMH3.js";
4
+ import { c } from "../../clsx-OuTLNxxd.js";
5
+ import { getHideAtStyles as N } from "../HideAt.js";
6
+ import '../../assets/SlideInPanel.css';const q = "_root_12lt6_1", P = "_overlay_12lt6_8", R = "_panel_12lt6_16", j = "_active_12lt6_52", o = {
7
+ root: q,
8
+ overlay: P,
9
+ panel: R,
10
+ "panel-left": "_panel-left_12lt6_29",
11
+ "panel-right": "_panel-right_12lt6_36",
12
+ "panel-bottom": "_panel-bottom_12lt6_43",
13
+ active: j,
14
+ "from-left": "_from-left_12lt6_52",
15
+ "from-right": "_from-right_12lt6_53",
16
+ "from-bottom": "_from-bottom_12lt6_54"
17
+ }, D = ({
18
+ side: a,
19
+ open: t,
20
+ onClose: l,
21
+ children: d,
22
+ width: v = 375,
23
+ height: p = "50%",
24
+ className: y,
25
+ overlayClassName: b,
26
+ panelClassName: h,
27
+ closeOnOverlayClick: x = !0,
28
+ disableEsc: m = !1,
29
+ hideAt: E,
30
+ ariaLabel: g = "Panel"
31
+ }) => {
32
+ const [n, _] = r.useState(t), [s, i] = r.useState(!1);
33
+ r.useEffect(() => {
34
+ t ? (n || _(!0), i(!1), requestAnimationFrame(() => {
35
+ requestAnimationFrame(() => i(!0));
36
+ })) : i(!1);
37
+ }, [t, n]), r.useEffect(() => {
38
+ if (!t || m) return;
39
+ const e = (S) => {
40
+ S.key === "Escape" && l();
41
+ };
42
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
43
+ }, [t, m, l]);
44
+ const f = r.useRef(null);
45
+ if (r.useEffect(() => {
46
+ if (t && s && f.current) {
47
+ const e = f.current.querySelector(
48
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
49
+ );
50
+ e == null || e.focus();
51
+ }
52
+ }, [t, s]), !n || typeof document > "u") return null;
53
+ const w = a === "bottom" ? { height: p } : { width: v };
54
+ return A.createPortal(
55
+ /* @__PURE__ */ k(
56
+ "div",
57
+ {
58
+ className: c(
59
+ o.root,
60
+ o[`from-${a}`],
61
+ s && o.active,
62
+ N(E),
63
+ y
64
+ ),
65
+ "aria-hidden": !t,
66
+ children: [
67
+ /* @__PURE__ */ u(
68
+ "div",
69
+ {
70
+ className: c(o.overlay, b),
71
+ onClick: () => {
72
+ t && x && l();
73
+ }
74
+ }
75
+ ),
76
+ /* @__PURE__ */ u(
77
+ "div",
78
+ {
79
+ ref: f,
80
+ role: "dialog",
81
+ "aria-modal": "true",
82
+ "aria-label": g,
83
+ className: c(o.panel, o[`panel-${a}`], h),
84
+ style: w,
85
+ onTransitionEnd: (e) => {
86
+ e.propertyName === "transform" && !t && _(!1);
87
+ },
88
+ children: d
89
+ }
90
+ )
91
+ ]
92
+ }
93
+ ),
94
+ document.body
95
+ );
96
+ };
97
+ export {
98
+ D as SlideInPanel
99
+ };
@@ -0,0 +1,10 @@
1
+ import { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { SlideInPanel } from './SlideInPanel';
3
+ declare const meta: Meta<typeof SlideInPanel>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof SlideInPanel>;
6
+ export declare const RightPanel: Story;
7
+ export declare const LeftPanel: Story;
8
+ export declare const BottomPanel: Story;
9
+ export declare const CustomSize: Story;
10
+ export declare const OverlayClickDisabled: Story;
@@ -0,0 +1,117 @@
1
+ import { jsx as t, jsxs as i, Fragment as h } from "react/jsx-runtime";
2
+ import * as a from "react";
3
+ import { SlideInPanel as c } from "./SlideInPanel.js";
4
+ import { Button as l } from "../Button/Button.js";
5
+ const y = {
6
+ title: "Case Parts/Atoms/SlideInPanel",
7
+ component: c,
8
+ parameters: {
9
+ layout: "centered",
10
+ controls: { sort: "requiredFirst" }
11
+ },
12
+ tags: ["autodocs"],
13
+ args: {
14
+ side: "right",
15
+ open: !1,
16
+ width: 360,
17
+ height: "50%",
18
+ closeOnOverlayClick: !0,
19
+ disableEsc: !1,
20
+ ariaLabel: "Panel"
21
+ },
22
+ argTypes: {
23
+ side: {
24
+ control: "select",
25
+ options: ["left", "right", "bottom"],
26
+ description: "Edge the panel slides in from."
27
+ },
28
+ open: {
29
+ control: "boolean",
30
+ description: "Panel visibility (storybook control)."
31
+ },
32
+ width: {
33
+ control: "text",
34
+ description: "Panel width (left/right). Number or CSS width."
35
+ },
36
+ height: {
37
+ control: "text",
38
+ description: "Panel height (bottom). Number or CSS height."
39
+ },
40
+ closeOnOverlayClick: {
41
+ control: "boolean",
42
+ description: "Close when clicking the dark overlay."
43
+ },
44
+ disableEsc: {
45
+ control: "boolean",
46
+ description: "Disable Escape key closing."
47
+ },
48
+ ariaLabel: {
49
+ control: "text",
50
+ description: "Accessible label for dialog."
51
+ },
52
+ hideAt: { table: { disable: !0 } },
53
+ // internal responsive prop
54
+ onClose: { table: { disable: !0 } },
55
+ // implemented internally
56
+ children: { description: "Panel content." }
57
+ }
58
+ }, m = () => /* @__PURE__ */ t("style", { children: ".storyRoboto{font-family:'Roboto',sans-serif;}" });
59
+ function o(e) {
60
+ const [r, n] = a.useState(e.open);
61
+ a.useEffect(() => n(e.open), [e.open]);
62
+ const s = () => n(!1);
63
+ return /* @__PURE__ */ i(h, { children: [
64
+ /* @__PURE__ */ t(m, {}),
65
+ /* @__PURE__ */ t(l, { size: "md", variant: "primary", onClick: () => n((d) => !d), children: r ? "Hide Panel" : "Show Panel" }),
66
+ /* @__PURE__ */ t(
67
+ c,
68
+ {
69
+ ...e,
70
+ open: r,
71
+ onClose: s,
72
+ panelClassName: "storyRoboto",
73
+ children: /* @__PURE__ */ i("div", { style: { padding: 16 }, children: [
74
+ /* @__PURE__ */ t("h3", { style: { margin: "0 0 12px" }, children: "SlideInPanel" }),
75
+ /* @__PURE__ */ i("p", { style: { margin: 0, fontSize: 14 }, children: [
76
+ "This panel slides from the ",
77
+ /* @__PURE__ */ t("strong", { children: e.side }),
78
+ ". Resize it with width/height args. Press Escape or click overlay (if enabled) to close."
79
+ ] }),
80
+ /* @__PURE__ */ i("div", { style: { marginTop: 16, display: "flex", gap: 8 }, children: [
81
+ /* @__PURE__ */ t(l, { size: "sm", variant: "secondary", onClick: s, children: "Close" }),
82
+ /* @__PURE__ */ t(l, { size: "sm", variant: "tertiary", onClick: () => alert("Action"), children: "Action" })
83
+ ] })
84
+ ] })
85
+ }
86
+ )
87
+ ] });
88
+ }
89
+ const C = {
90
+ name: "Right",
91
+ render: (e) => /* @__PURE__ */ t(o, { ...e }),
92
+ args: { side: "right", width: 360 }
93
+ }, u = {
94
+ name: "Left",
95
+ render: (e) => /* @__PURE__ */ t(o, { ...e }),
96
+ args: { side: "left", width: 320 }
97
+ }, P = {
98
+ name: "Bottom",
99
+ render: (e) => /* @__PURE__ */ t(o, { ...e }),
100
+ args: { side: "bottom", height: "40%" }
101
+ }, k = {
102
+ name: "Custom Size",
103
+ render: (e) => /* @__PURE__ */ t(o, { ...e }),
104
+ args: { side: "right", width: "480px" }
105
+ }, v = {
106
+ name: "Overlay Click Disabled",
107
+ render: (e) => /* @__PURE__ */ t(o, { ...e }),
108
+ args: { side: "right", closeOnOverlayClick: !1 }
109
+ };
110
+ export {
111
+ P as BottomPanel,
112
+ k as CustomSize,
113
+ u as LeftPanel,
114
+ v as OverlayClickDisabled,
115
+ C as RightPanel,
116
+ y as default
117
+ };
@@ -0,0 +1,16 @@
1
+ import * as React from "react";
2
+ type PositionKeyword = "top" | "right" | "bottom" | "left";
3
+ type Position = "top left" | "top center" | "top right" | "right top" | "right center" | "right bottom" | "bottom left" | "bottom center" | "bottom right" | "left top" | "left center" | "left bottom" | PositionKeyword;
4
+ export type TooltipProps = {
5
+ children: React.ReactNode;
6
+ trigger: React.ReactElement;
7
+ tooltipClassName?: string;
8
+ contentClassName?: string;
9
+ position?: Position;
10
+ openDelay?: number;
11
+ closeDelay?: number;
12
+ disabled?: boolean;
13
+ leaveGraceMs?: number;
14
+ };
15
+ export declare const Tooltip: React.FC<TooltipProps>;
16
+ export {};
@@ -0,0 +1,126 @@
1
+ import { jsxs as H, Fragment as N, jsx as F } from "react/jsx-runtime";
2
+ import * as r from "react";
3
+ import { c as M } from "../../clsx-OuTLNxxd.js";
4
+ import { r as O } from "../../index-B4KbmMH3.js";
5
+ import '../../assets/Tooltip.css';const W = "_tooltip_17o7a_1", A = "_content_17o7a_11", S = {
6
+ tooltip: W,
7
+ content: A
8
+ };
9
+ function D(l) {
10
+ return l ? l.includes(" ") ? l : `${l} center` : "top center";
11
+ }
12
+ function I(l) {
13
+ const m = D(l).toLowerCase(), [i, t] = m.split(" ");
14
+ return { side: ["top", "right", "bottom", "left"].includes(i) ? i : "top", align: t === "left" || t === "top" ? "start" : t === "right" || t === "bottom" ? "end" : "center" };
15
+ }
16
+ function $(l, m, i, t, a = 8) {
17
+ const e = l.getBoundingClientRect(), u = m.getBoundingClientRect();
18
+ let f = 0, s = 0;
19
+ i === "top" ? f = e.top - u.height - a : i === "bottom" ? f = e.bottom + a : i === "left" ? s = e.left - u.width - a : i === "right" && (s = e.right + a), i === "top" || i === "bottom" ? t === "start" ? s = e.left : t === "end" ? s = e.right - u.width : s = e.left + e.width / 2 - u.width / 2 : t === "start" ? f = e.top : t === "end" ? f = e.bottom - u.height : f = e.top + e.height / 2 - u.height / 2;
20
+ const h = window.innerWidth, w = window.innerHeight;
21
+ return f = Math.max(4, Math.min(w - u.height - 4, f)), s = Math.max(4, Math.min(h - u.width - 4, s)), { top: f, left: s };
22
+ }
23
+ const K = ({
24
+ tooltipClassName: l,
25
+ contentClassName: m,
26
+ children: i,
27
+ trigger: t,
28
+ position: a,
29
+ disabled: e,
30
+ openDelay: u = 150,
31
+ closeDelay: f = 100,
32
+ leaveGraceMs: s = 0
33
+ }) => {
34
+ const { side: h, align: w } = I(a), [c, E] = r.useState(!1), [d, g] = r.useState(null), _ = r.useRef(null), z = r.useRef(null), T = r.useRef(null), R = r.useRef(null), y = r.useRef(null), L = r.useRef(!1), p = (n) => {
35
+ n.current && (window.clearTimeout(n.current), n.current = null);
36
+ }, C = () => {
37
+ p(T), p(R), p(y);
38
+ };
39
+ r.useEffect(() => () => C(), []);
40
+ const B = () => {
41
+ e || c || (p(T), T.current = window.setTimeout(() => E(!0), u));
42
+ }, x = () => {
43
+ c && (p(R), R.current = window.setTimeout(() => {
44
+ L.current || E(!1);
45
+ }, f));
46
+ }, k = () => {
47
+ if (c) {
48
+ if (p(y), s <= 0) {
49
+ x();
50
+ return;
51
+ }
52
+ y.current = window.setTimeout(() => {
53
+ L.current || x();
54
+ }, s);
55
+ }
56
+ }, P = (n, o) => (b) => {
57
+ n == null || n(b), o == null || o(b);
58
+ }, j = r.cloneElement(t, {
59
+ ref: (n) => {
60
+ const { ref: o } = t;
61
+ typeof o == "function" ? o(n) : o && (o.current = n), _.current = n;
62
+ },
63
+ onPointerEnter: P(t.props.onPointerEnter, B),
64
+ onPointerLeave: P(t.props.onPointerLeave, k),
65
+ onFocus: P(t.props.onFocus, B),
66
+ onBlur: P(t.props.onBlur, x),
67
+ "aria-describedby": c ? "tooltip-popup" : void 0,
68
+ style: { ...t.props.style || {}, outline: "none" }
69
+ });
70
+ return r.useEffect(() => {
71
+ e && c && (C(), E(!1));
72
+ }, [e]), r.useEffect(() => {
73
+ if (!c) return;
74
+ const n = (o) => {
75
+ o.key === "Escape" && E(!1);
76
+ };
77
+ return window.addEventListener("keydown", n), () => window.removeEventListener("keydown", n);
78
+ }, [c]), r.useLayoutEffect(() => {
79
+ if (!c) {
80
+ g(null);
81
+ return;
82
+ }
83
+ const n = _.current, o = z.current;
84
+ if (!n || !o) return;
85
+ const b = 8, v = () => {
86
+ g($(n, o, h, w, b));
87
+ };
88
+ return v(), window.addEventListener("resize", v), window.addEventListener("scroll", v, !0), () => {
89
+ window.removeEventListener("resize", v), window.removeEventListener("scroll", v, !0);
90
+ };
91
+ }, [c, h, w, i]), /* @__PURE__ */ H(N, { children: [
92
+ j,
93
+ c && typeof document < "u" && O.createPortal(
94
+ /* @__PURE__ */ F(
95
+ "div",
96
+ {
97
+ id: "tooltip-popup",
98
+ ref: z,
99
+ role: "tooltip",
100
+ "aria-hidden": !c,
101
+ "data-side": h,
102
+ "data-align": w,
103
+ className: M(S.tooltip, l),
104
+ style: {
105
+ position: "absolute",
106
+ top: (d == null ? void 0 : d.top) ?? 0,
107
+ left: (d == null ? void 0 : d.left) ?? 0,
108
+ visibility: d ? "visible" : "hidden",
109
+ zIndex: 10
110
+ },
111
+ onPointerEnter: () => {
112
+ L.current = !0, p(R), p(y);
113
+ },
114
+ onPointerLeave: () => {
115
+ L.current = !1, k();
116
+ },
117
+ children: /* @__PURE__ */ F("div", { className: M(S.content, m), children: i })
118
+ }
119
+ ),
120
+ document.body
121
+ )
122
+ ] });
123
+ };
124
+ export {
125
+ K as Tooltip
126
+ };
@@ -2,7 +2,7 @@ import { StoryObj } from '@storybook/react-vite';
2
2
  import { Tooltip } from './Tooltip';
3
3
  declare const meta: {
4
4
  title: string;
5
- component: typeof Tooltip;
5
+ component: import('react').FC<import('./Tooltip').TooltipProps>;
6
6
  parameters: {
7
7
  layout: string;
8
8
  controls: {
@@ -16,42 +16,24 @@ declare const meta: {
16
16
  };
17
17
  tags: string[];
18
18
  args: {
19
- on: "mouseenter focus";
20
- placement: "top";
21
- mouseEnterDelay: number;
22
- mouseLeaveDelay: number;
23
- arrow: true;
19
+ position: "top center";
20
+ openDelay: number;
21
+ closeDelay: number;
24
22
  };
25
23
  argTypes: {
26
- on: {
24
+ position: {
27
25
  control: "select";
28
26
  options: string[];
29
27
  description: string;
30
28
  };
31
- placement: {
32
- control: "select";
33
- options: string[];
34
- description: string;
35
- };
36
- mouseEnterDelay: {
29
+ openDelay: {
37
30
  control: "number";
38
31
  description: string;
39
32
  };
40
- mouseLeaveDelay: {
33
+ closeDelay: {
41
34
  control: "number";
42
35
  description: string;
43
36
  };
44
- delay: {
45
- control: false;
46
- table: {
47
- category: string;
48
- };
49
- description: string;
50
- };
51
- arrow: {
52
- control: "boolean";
53
- description: string;
54
- };
55
37
  contentClassName: {
56
38
  table: {
57
39
  disable: true;
@@ -76,7 +58,7 @@ declare const meta: {
76
58
  export default meta;
77
59
  type Story = StoryObj<typeof Tooltip>;
78
60
  export declare const OnHover: Story;
79
- export declare const OnClick: Story;
61
+ export declare const BottomHover: Story;
80
62
  export declare const PositionRight: Story;
81
63
  export declare const PositionLeft: Story;
82
64
  export declare const AbsolutelyPositioned: Story;