@smwb/ui-react 2.0.0 → 2.0.2
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/README.md +7 -6
- package/dist/components/layout/screenDivider/screenDivider.js +47 -56
- package/dist/components/layout/screenDivider/screenDivider.js.map +1 -1
- package/dist/components/navigation/menu/menuComponent.js +13 -9
- package/dist/components/navigation/menu/menuComponent.js.map +1 -1
- package/dist/headless/components/layout/screenDivider/screenDivider.js +47 -56
- package/dist/headless/components/layout/screenDivider/screenDivider.js.map +1 -1
- package/dist/headless/components/navigation/menu/menuComponent.js +13 -9
- package/dist/headless/components/navigation/menu/menuComponent.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,15 +9,16 @@ runtime light/dark theming and LESS-based customization. Part of the `@smwb` des
|
|
|
9
9
|
|
|
10
10
|
| Package | What it is |
|
|
11
11
|
| --- | --- |
|
|
12
|
-
| **`@smwb/ui-react`** | This package — React components. |
|
|
13
|
-
| `@smwb/ui-solid` | SolidJS port, same design system and class names. |
|
|
14
|
-
| `@smwb/ui-styles` | Framework-agnostic **LESS source** + design tokens (`smwb-*`). |
|
|
15
|
-
| `@smwb/ui-css` | **Prebuilt aggregate stylesheet** (`import "@smwb/ui-css"`). |
|
|
16
|
-
| `@smwb/ui-mcp-react` | MCP server exposing this catalog to AI tools. |
|
|
12
|
+
| [**`@smwb/ui-react`**](https://www.npmjs.com/package/@smwb/ui-react) | This package — React components. |
|
|
13
|
+
| [`@smwb/ui-solid`](https://www.npmjs.com/package/@smwb/ui-solid) | SolidJS port, same design system and class names. |
|
|
14
|
+
| [`@smwb/ui-styles`](https://www.npmjs.com/package/@smwb/ui-styles) | Framework-agnostic **LESS source** + design tokens (`smwb-*`). |
|
|
15
|
+
| [`@smwb/ui-css`](https://www.npmjs.com/package/@smwb/ui-css) | **Prebuilt aggregate stylesheet** (`import "@smwb/ui-css"`). |
|
|
16
|
+
| [`@smwb/ui-mcp-react`](https://www.npmjs.com/package/@smwb/ui-mcp-react) | MCP server exposing this catalog to AI tools. |
|
|
17
17
|
|
|
18
18
|
## Component catalog
|
|
19
19
|
|
|
20
|
-
- **Storybook (production):** https://summerweb.ru/ui
|
|
20
|
+
- **Storybook (production):** https://summerweb.ru/ui-react/
|
|
21
|
+
- **Storybook (dev):** https://summerweb.ru/ui-dev-react/
|
|
21
22
|
- **Local:** `npm run storybook` → http://localhost:6006
|
|
22
23
|
|
|
23
24
|
## Installation
|
|
@@ -1,89 +1,80 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as B, jsx as w } from "react/jsx-runtime";
|
|
2
2
|
import '../../../assets/styles/less/components/screenDivider/screenDivider.entry.css';/* empty css */
|
|
3
|
-
import { forwardRef as
|
|
3
|
+
import { forwardRef as C, useRef as O, useState as y, useEffect as b, Children as P, useMemo as U, useCallback as W } from "react";
|
|
4
4
|
import D from "clsx";
|
|
5
|
-
import { throttle as
|
|
6
|
-
import { useForkRef as
|
|
7
|
-
const
|
|
5
|
+
import { throttle as X } from "../../../utils/throttle.js";
|
|
6
|
+
import { useForkRef as Y } from "../../../hooks/useForkRef.js";
|
|
7
|
+
const x = (c, d) => !c && d ? 100 - d : c || 50, Z = C(function({
|
|
8
8
|
className: d,
|
|
9
9
|
orientation: e = "horizontal",
|
|
10
|
-
sizeFirst:
|
|
10
|
+
sizeFirst: f,
|
|
11
11
|
sizeSecond: v,
|
|
12
|
-
children:
|
|
13
|
-
onSizeChange:
|
|
12
|
+
children: L,
|
|
13
|
+
onSizeChange: i,
|
|
14
14
|
keyboardStep: g = 5,
|
|
15
|
-
resizerAriaLabel:
|
|
16
|
-
},
|
|
17
|
-
const p =
|
|
15
|
+
resizerAriaLabel: $ = "Resize panels"
|
|
16
|
+
}, k) {
|
|
17
|
+
const p = O(null), A = Y(k, p), [t, n] = y(x(f, v)), [E, R] = y(null), [m, _] = y(!1);
|
|
18
18
|
b(() => {
|
|
19
|
-
|
|
20
|
-
}, [
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
19
|
+
n(x(f, v));
|
|
20
|
+
}, [f, v]);
|
|
21
|
+
const h = P.toArray(L);
|
|
22
|
+
if (h.length > 2)
|
|
23
23
|
throw new Error("Allowed not more than 2 children");
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
() =>
|
|
28
|
-
if (!
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
s < 0 && (s = 0);
|
|
34
|
-
const t = s / n.clientHeight * 100;
|
|
35
|
-
_(t, n.clientWidth) > 5 && t < 101 && l(t - 7);
|
|
36
|
-
} else {
|
|
37
|
-
let s = r.clientX - n.offsetLeft;
|
|
38
|
-
s < 0 && (s = 0);
|
|
39
|
-
const t = s / n.clientWidth * 100;
|
|
40
|
-
_(t, n.clientWidth) > 5 && t < 101 && l(t);
|
|
41
|
-
}
|
|
24
|
+
const M = () => {
|
|
25
|
+
R(p.current), _(!0);
|
|
26
|
+
}, o = U(
|
|
27
|
+
() => X((r) => {
|
|
28
|
+
if (!m) return;
|
|
29
|
+
const a = p.current;
|
|
30
|
+
if (!a || a !== E) return;
|
|
31
|
+
const s = a.getBoundingClientRect(), l = e === "vertical" ? s.height : s.width, j = e === "vertical" ? r.clientY - s.top : r.clientX - s.left, H = Math.max(5, Math.min(l - 5, j));
|
|
32
|
+
n(H / l * 100);
|
|
42
33
|
}, 1e3 / 60),
|
|
43
|
-
[
|
|
44
|
-
), u =
|
|
45
|
-
|
|
46
|
-
}, [
|
|
34
|
+
[m, E, e]
|
|
35
|
+
), u = W(() => {
|
|
36
|
+
R(null), _(!1), document.body.removeEventListener("pointerup", u), document.body.removeEventListener("pointermove", o);
|
|
37
|
+
}, [o]);
|
|
47
38
|
b(() => {
|
|
48
|
-
|
|
49
|
-
}, [
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
r.key ===
|
|
53
|
-
},
|
|
54
|
-
return b(() => (
|
|
55
|
-
document.body.removeEventListener("pointerup", u), document.body.removeEventListener("pointermove",
|
|
56
|
-
}), [
|
|
39
|
+
i == null || i(t);
|
|
40
|
+
}, [t, i]);
|
|
41
|
+
const K = (r) => {
|
|
42
|
+
const a = e === "vertical" ? "ArrowUp" : "ArrowLeft", s = e === "vertical" ? "ArrowDown" : "ArrowRight";
|
|
43
|
+
r.key === a ? (r.preventDefault(), n((l) => Math.max(0, l - g))) : r.key === s ? (r.preventDefault(), n((l) => Math.min(100, l + g))) : r.key === "Home" ? (r.preventDefault(), n(0)) : r.key === "End" && (r.preventDefault(), n(100));
|
|
44
|
+
}, N = e === "vertical" ? { height: `${100 - t}%` } : { width: `${100 - t}%` }, I = e === "vertical" ? { height: `${t}%` } : { width: `${t}%` };
|
|
45
|
+
return b(() => (m ? (document.body.addEventListener("pointerup", u), document.body.addEventListener("pointermove", o), document.body.style.cursor = e === "horizontal" ? "e-resize" : "n-resize") : document.body.style.cursor = "default", () => {
|
|
46
|
+
document.body.removeEventListener("pointerup", u), document.body.removeEventListener("pointermove", o);
|
|
47
|
+
}), [o, u, m, e]), /* @__PURE__ */ B(
|
|
57
48
|
"div",
|
|
58
49
|
{
|
|
59
50
|
className: D("smwb-screen-divider__wrapper", `smwb-${e}`, d),
|
|
60
|
-
ref:
|
|
51
|
+
ref: A,
|
|
61
52
|
"data-testid": "screen-divider",
|
|
62
53
|
children: [
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ w("div", { className: D("smwb-screen-divider__first", `smwb-${e}`), style: I, children: h[0] || "" }),
|
|
55
|
+
/* @__PURE__ */ w(
|
|
65
56
|
"span",
|
|
66
57
|
{
|
|
67
58
|
className: "smwb-screen-divider__resizer",
|
|
68
|
-
onPointerDown:
|
|
59
|
+
onPointerDown: M,
|
|
69
60
|
draggable: !1,
|
|
70
61
|
role: "separator",
|
|
71
62
|
"aria-orientation": e === "vertical" ? "horizontal" : "vertical",
|
|
72
|
-
"aria-valuenow": Math.round(
|
|
63
|
+
"aria-valuenow": Math.round(t),
|
|
73
64
|
"aria-valuemin": 0,
|
|
74
65
|
"aria-valuemax": 100,
|
|
75
|
-
"aria-label":
|
|
66
|
+
"aria-label": $,
|
|
76
67
|
tabIndex: 0,
|
|
77
|
-
onKeyDown:
|
|
68
|
+
onKeyDown: K
|
|
78
69
|
}
|
|
79
70
|
),
|
|
80
|
-
/* @__PURE__ */
|
|
71
|
+
/* @__PURE__ */ w("div", { className: D("smwb-screen-divider__second", `smwb-${e}`), style: N, children: h[1] || "" })
|
|
81
72
|
]
|
|
82
73
|
}
|
|
83
74
|
);
|
|
84
75
|
});
|
|
85
76
|
export {
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
Z as ScreenDivider,
|
|
78
|
+
Z as default
|
|
88
79
|
};
|
|
89
80
|
//# sourceMappingURL=screenDivider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenDivider.js","sources":["../../../../src/components/layout/screenDivider/screenDivider.tsx"],"sourcesContent":["import React, {\n Children,\n forwardRef,\n KeyboardEvent,\n PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport cn from \"clsx\";\nimport { throttle } from \"../../../utils/throttle\";\nimport { useForkRef } from \"../../../hooks/useForkRef\";\n\nexport interface ScreenDividerProps {\n sizeFirst?: number;\n sizeSecond?: number;\n className?: string;\n orientation?: \"horizontal\" | \"vertical\";\n /** Called with the first pane size (percent) whenever it changes. */\n onSizeChange?: (sizeFirst: number) => void;\n /** Step (in percent) applied on arrow-key resize. */\n keyboardStep?: number;\n /** Accessible label for the resizer handle. */\n resizerAriaLabel?: string;\n}\n\nconst toPixels = (percent: number, parentSize: number) => {\n return parentSize * (percent / 100);\n};\n\nconst getInitialDivider = (sizeFirst?: number | null, sizeSecond?: number | null) => {\n if (!sizeFirst && sizeSecond) {\n return 100 - sizeSecond;\n }\n if (sizeFirst) {\n return sizeFirst;\n }\n return 50;\n};\n\nexport const ScreenDivider = forwardRef<HTMLDivElement, PropsWithChildren<ScreenDividerProps>>(function ScreenDivider(\n {\n className,\n orientation = \"horizontal\",\n sizeFirst,\n sizeSecond,\n children,\n onSizeChange,\n keyboardStep = 5,\n resizerAriaLabel = \"Resize panels\",\n },\n ref\n) {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const forkedWrapperRef = useForkRef<HTMLDivElement>(ref, wrapperRef);\n const [divider, setDivider] = useState<number>(getInitialDivider(sizeFirst, sizeSecond));\n const [currentElement, setCurrentElement] = useState<HTMLDivElement | null>(null);\n const [isDragging, setIsDragging] = useState(false);\n\n useEffect(() => {\n setDivider(getInitialDivider(sizeFirst, sizeSecond));\n }, [sizeFirst, sizeSecond]);\n\n const child = Children.toArray(children);\n if (child.length > 2) {\n throw new Error(\"Allowed not more than 2 children\");\n }\n\n const handleDragStart = () => {\n setCurrentElement(wrapperRef.current);\n setIsDragging(true);\n };\n\n const dragOverHandler = useMemo(\n () =>\n throttle((e: PointerEvent) => {\n if (!isDragging) return;\n\n const wrapper = wrapperRef.current;\n if (!wrapper || wrapper !== currentElement) return;\n if (orientation === \"vertical\") {\n let relativeMouseY = e.clientY - wrapper.offsetTop;\n if (relativeMouseY < 0) {\n relativeMouseY = 0;\n }\n const newDivider = (relativeMouseY / wrapper.clientHeight) * 100;\n if (toPixels(newDivider, wrapper.clientWidth) > 5 && newDivider < 101) {\n setDivider(newDivider - 7);\n }\n } else {\n let relativeMouseX = e.clientX - wrapper.offsetLeft;\n if (relativeMouseX < 0) {\n relativeMouseX = 0;\n }\n const newDivider = (relativeMouseX / wrapper.clientWidth) * 100;\n if (toPixels(newDivider, wrapper.clientWidth) > 5 && newDivider < 101) {\n setDivider(newDivider);\n }\n }\n }, 1000 / 60),\n [isDragging, currentElement, orientation]\n );\n\n const handleDragEnd = useCallback(() => {\n setCurrentElement(null);\n setIsDragging(false);\n document.body.removeEventListener(\"pointerup\", handleDragEnd);\n document.body.removeEventListener(\"pointermove\", dragOverHandler);\n }, [dragOverHandler]);\n\n useEffect(() => {\n onSizeChange?.(divider);\n }, [divider, onSizeChange]);\n\n const onResizerKeyDown = (event: KeyboardEvent<HTMLSpanElement>) => {\n const decreaseKey = orientation === \"vertical\" ? \"ArrowUp\" : \"ArrowLeft\";\n const increaseKey = orientation === \"vertical\" ? \"ArrowDown\" : \"ArrowRight\";\n\n if (event.key === decreaseKey) {\n event.preventDefault();\n setDivider((prev) => Math.max(0, prev - keyboardStep));\n } else if (event.key === increaseKey) {\n event.preventDefault();\n setDivider((prev) => Math.min(100, prev + keyboardStep));\n } else if (event.key === \"Home\") {\n event.preventDefault();\n setDivider(0);\n } else if (event.key === \"End\") {\n event.preventDefault();\n setDivider(100);\n }\n };\n\n const secondChildStyle =\n orientation === \"vertical\" ? { height: `${100 - divider}%` } : { width: `${100 - divider}%` };\n\n const firstChildStyle = orientation === \"vertical\" ? { height: `${divider}%` } : { width: `${divider}%` };\n\n useEffect(() => {\n if (isDragging) {\n document.body.addEventListener(\"pointerup\", handleDragEnd);\n document.body.addEventListener(\"pointermove\", dragOverHandler);\n document.body.style.cursor = orientation === \"horizontal\" ? \"e-resize\" : \"n-resize\";\n } else {\n document.body.style.cursor = \"default\";\n }\n\n return () => {\n document.body.removeEventListener(\"pointerup\", handleDragEnd);\n document.body.removeEventListener(\"pointermove\", dragOverHandler);\n };\n }, [dragOverHandler, handleDragEnd, isDragging, orientation]);\n\n return (\n <div\n className={cn(\"smwb-screen-divider__wrapper\", `smwb-${orientation}`, className)}\n ref={forkedWrapperRef}\n data-testid=\"screen-divider\"\n >\n <div className={cn(\"smwb-screen-divider__first\", `smwb-${orientation}`)} style={firstChildStyle}>\n {child[0] || \"\"}\n </div>\n <span\n className=\"smwb-screen-divider__resizer\"\n onPointerDown={handleDragStart}\n draggable={false}\n role=\"separator\"\n aria-orientation={orientation === \"vertical\" ? \"horizontal\" : \"vertical\"}\n aria-valuenow={Math.round(divider)}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-label={resizerAriaLabel}\n tabIndex={0}\n onKeyDown={onResizerKeyDown}\n />\n <div className={cn(\"smwb-screen-divider__second\", `smwb-${orientation}`)} style={secondChildStyle}>\n {child[1] || \"\"}\n </div>\n </div>\n );\n});\n\nexport default ScreenDivider;\n"],"names":["toPixels","percent","parentSize","getInitialDivider","sizeFirst","sizeSecond","ScreenDivider","forwardRef","className","orientation","children","onSizeChange","keyboardStep","resizerAriaLabel","ref","wrapperRef","useRef","forkedWrapperRef","useForkRef","divider","setDivider","useState","currentElement","setCurrentElement","isDragging","setIsDragging","useEffect","child","Children","handleDragStart","dragOverHandler","useMemo","throttle","e","wrapper","relativeMouseY","newDivider","relativeMouseX","handleDragEnd","useCallback","onResizerKeyDown","event","decreaseKey","increaseKey","prev","secondChildStyle","firstChildStyle","jsxs","cn","jsx"],"mappings":";;;;;;AA6BA,MAAMA,IAAW,CAACC,GAAiBC,MAC1BA,KAAcD,IAAU,MAG3BE,IAAoB,CAACC,GAA2BC,MAChD,CAACD,KAAaC,IACT,MAAMA,IAEXD,KAGG,IAGIE,IAAgBC,EAAkE,SAC7F;AAAA,EACE,WAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,WAAAL;AAAA,EACA,YAAAC;AAAA,EACA,UAAAK;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,kBAAAC,IAAmB;AACrB,GACAC,GACA;AACA,QAAMC,IAAaC,EAAuB,IAAI,GACxCC,IAAmBC,EAA2BJ,GAAKC,CAAU,GAC7D,CAACI,GAASC,CAAU,IAAIC,EAAiBlB,EAAkBC,GAAWC,CAAU,CAAC,GACjF,CAACiB,GAAgBC,CAAiB,IAAIF,EAAgC,IAAI,GAC1E,CAACG,GAAYC,CAAa,IAAIJ,EAAS,EAAK;AAElD,EAAAK,EAAU,MAAM;AACd,IAAAN,EAAWjB,EAAkBC,GAAWC,CAAU,C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,WAAWD,EAAG,8BAA8B,QAAQvC,CAAW,EAAE,GAAG,OAAOqC,GAC7E,UAAAnB,EAAM,CAAC,KAAK,IACf;AAAA,QACA,gBAAAsB;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,eAAepB;AAAA,YACf,WAAW;AAAA,YACX,MAAK;AAAA,YACL,oBAAkBpB,MAAgB,aAAa,eAAe;AAAA,YAC9D,iBAAe,KAAK,MAAMU,CAAO;AAAA,YACjC,iBAAe;AAAA,YACf,iBAAe;AAAA,YACf,cAAYN;AAAA,YACZ,UAAU;AAAA,YACV,WAAW2B;AAAA,UAAA;AAAA,QAAA;AAAA,QAEb,gBAAAS,EAAC,OAAA,EAAI,WAAWD,EAAG,+BAA+B,QAAQvC,CAAW,EAAE,GAAG,OAAOoC,GAC9E,UAAAlB,EAAM,CAAC,KAAK,GAAA,CACf;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;"}
|
|
1
|
+
{"version":3,"file":"screenDivider.js","sources":["../../../../src/components/layout/screenDivider/screenDivider.tsx"],"sourcesContent":["import React, {\n Children,\n forwardRef,\n KeyboardEvent,\n PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport cn from \"clsx\";\nimport { throttle } from \"../../../utils/throttle\";\nimport { useForkRef } from \"../../../hooks/useForkRef\";\n\nexport interface ScreenDividerProps {\n sizeFirst?: number;\n sizeSecond?: number;\n className?: string;\n orientation?: \"horizontal\" | \"vertical\";\n /** Called with the first pane size (percent) whenever it changes. */\n onSizeChange?: (sizeFirst: number) => void;\n /** Step (in percent) applied on arrow-key resize. */\n keyboardStep?: number;\n /** Accessible label for the resizer handle. */\n resizerAriaLabel?: string;\n}\n\nconst getInitialDivider = (sizeFirst?: number | null, sizeSecond?: number | null) => {\n if (!sizeFirst && sizeSecond) {\n return 100 - sizeSecond;\n }\n if (sizeFirst) {\n return sizeFirst;\n }\n return 50;\n};\n\nexport const ScreenDivider = forwardRef<HTMLDivElement, PropsWithChildren<ScreenDividerProps>>(function ScreenDivider(\n {\n className,\n orientation = \"horizontal\",\n sizeFirst,\n sizeSecond,\n children,\n onSizeChange,\n keyboardStep = 5,\n resizerAriaLabel = \"Resize panels\",\n },\n ref\n) {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const forkedWrapperRef = useForkRef<HTMLDivElement>(ref, wrapperRef);\n const [divider, setDivider] = useState<number>(getInitialDivider(sizeFirst, sizeSecond));\n const [currentElement, setCurrentElement] = useState<HTMLDivElement | null>(null);\n const [isDragging, setIsDragging] = useState(false);\n\n useEffect(() => {\n setDivider(getInitialDivider(sizeFirst, sizeSecond));\n }, [sizeFirst, sizeSecond]);\n\n const child = Children.toArray(children);\n if (child.length > 2) {\n throw new Error(\"Allowed not more than 2 children\");\n }\n\n const handleDragStart = () => {\n setCurrentElement(wrapperRef.current);\n setIsDragging(true);\n };\n\n const dragOverHandler = useMemo(\n () =>\n throttle((e: PointerEvent) => {\n if (!isDragging) return;\n const wrapper = wrapperRef.current;\n if (!wrapper || wrapper !== currentElement) return;\n // Viewport-relative rect — using offsetLeft/offsetTop here is wrong\n // because they are relative to the nearest positioned ancestor, not\n // the viewport that clientX/clientY live in (this is what made the\n // divider drift away from the cursor when the wrapper was nested).\n const rect = wrapper.getBoundingClientRect();\n const total = orientation === \"vertical\" ? rect.height : rect.width;\n const cursor = orientation === \"vertical\" ? e.clientY - rect.top : e.clientX - rect.left;\n // 5px margin on each side so neither pane fully collapses.\n const clamped = Math.max(5, Math.min(total - 5, cursor));\n setDivider((clamped / total) * 100);\n }, 1000 / 60),\n [isDragging, currentElement, orientation]\n );\n\n const handleDragEnd = useCallback(() => {\n setCurrentElement(null);\n setIsDragging(false);\n document.body.removeEventListener(\"pointerup\", handleDragEnd);\n document.body.removeEventListener(\"pointermove\", dragOverHandler);\n }, [dragOverHandler]);\n\n useEffect(() => {\n onSizeChange?.(divider);\n }, [divider, onSizeChange]);\n\n const onResizerKeyDown = (event: KeyboardEvent<HTMLSpanElement>) => {\n const decreaseKey = orientation === \"vertical\" ? \"ArrowUp\" : \"ArrowLeft\";\n const increaseKey = orientation === \"vertical\" ? \"ArrowDown\" : \"ArrowRight\";\n\n if (event.key === decreaseKey) {\n event.preventDefault();\n setDivider((prev) => Math.max(0, prev - keyboardStep));\n } else if (event.key === increaseKey) {\n event.preventDefault();\n setDivider((prev) => Math.min(100, prev + keyboardStep));\n } else if (event.key === \"Home\") {\n event.preventDefault();\n setDivider(0);\n } else if (event.key === \"End\") {\n event.preventDefault();\n setDivider(100);\n }\n };\n\n const secondChildStyle =\n orientation === \"vertical\" ? { height: `${100 - divider}%` } : { width: `${100 - divider}%` };\n\n const firstChildStyle = orientation === \"vertical\" ? { height: `${divider}%` } : { width: `${divider}%` };\n\n useEffect(() => {\n if (isDragging) {\n document.body.addEventListener(\"pointerup\", handleDragEnd);\n document.body.addEventListener(\"pointermove\", dragOverHandler);\n document.body.style.cursor = orientation === \"horizontal\" ? \"e-resize\" : \"n-resize\";\n } else {\n document.body.style.cursor = \"default\";\n }\n\n return () => {\n document.body.removeEventListener(\"pointerup\", handleDragEnd);\n document.body.removeEventListener(\"pointermove\", dragOverHandler);\n };\n }, [dragOverHandler, handleDragEnd, isDragging, orientation]);\n\n return (\n <div\n className={cn(\"smwb-screen-divider__wrapper\", `smwb-${orientation}`, className)}\n ref={forkedWrapperRef}\n data-testid=\"screen-divider\"\n >\n <div className={cn(\"smwb-screen-divider__first\", `smwb-${orientation}`)} style={firstChildStyle}>\n {child[0] || \"\"}\n </div>\n <span\n className=\"smwb-screen-divider__resizer\"\n onPointerDown={handleDragStart}\n draggable={false}\n role=\"separator\"\n aria-orientation={orientation === \"vertical\" ? \"horizontal\" : \"vertical\"}\n aria-valuenow={Math.round(divider)}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-label={resizerAriaLabel}\n tabIndex={0}\n onKeyDown={onResizerKeyDown}\n />\n <div className={cn(\"smwb-screen-divider__second\", `smwb-${orientation}`)} style={secondChildStyle}>\n {child[1] || \"\"}\n </div>\n </div>\n );\n});\n\nexport default ScreenDivider;\n"],"names":["getInitialDivider","sizeFirst","sizeSecond","ScreenDivider","forwardRef","className","orientation","children","onSizeChange","keyboardStep","resizerAriaLabel","ref","wrapperRef","useRef","forkedWrapperRef","useForkRef","divider","setDivider","useState","currentElement","setCurrentElement","isDragging","setIsDragging","useEffect","child","Children","handleDragStart","dragOverHandler","useMemo","throttle","e","wrapper","rect","total","cursor","clamped","handleDragEnd","useCallback","onResizerKeyDown","event","decreaseKey","increaseKey","prev","secondChildStyle","firstChildStyle","jsxs","cn","jsx"],"mappings":";;;;;;AA6BA,MAAMA,IAAoB,CAACC,GAA2BC,MAChD,CAACD,KAAaC,IACT,MAAMA,IAEXD,KAGG,IAGIE,IAAgBC,EAAkE,SAC7F;AAAA,EACE,WAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,WAAAL;AAAA,EACA,YAAAC;AAAA,EACA,UAAAK;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,kBAAAC,IAAmB;AACrB,GACAC,GACA;AACA,QAAMC,IAAaC,EAAuB,IAAI,GACxCC,IAAmBC,EAA2BJ,GAAKC,CAAU,GAC7D,CAACI,GAASC,CAAU,IAAIC,EAAiBlB,EAAkBC,GAAWC,CAAU,CAAC,GACjF,CAACiB,GAAgBC,CAAiB,IAAIF,EAAgC,IAAI,GAC1E,CAACG,GAAYC,CAAa,IAAIJ,EAAS,EAAK;AAElD,EAAAK,EAAU,MAAM;AACd,IAAAN,EAAWjB,EAAkBC,GAAWC,CAAU,CAAC;AAAA,EACrD,GAAG,CAACD,GAAWC,CAAU,CAAC;AAE1B,QAAMsB,IAAQC,EAAS,QAAQlB,CAAQ;AACvC,MAAIiB,EAAM,SAAS;AACjB,UAAM,IAAI,MAAM,kCAAkC;AAGpD,QAAME,IAAkB,MAAM;AAC5B,IAAAN,EAAkBR,EAAW,OAAO,GACpCU,EAAc,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C,OAAA,EAAI,WAAWD,EAAG,+BAA+B,QAAQxC,CAAW,EAAE,GAAG,OAAOqC,GAC9E,UAAAnB,EAAM,CAAC,KAAK,GAAA,CACf;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useMenuContext as
|
|
4
|
-
import { MenuList as
|
|
5
|
-
import { MenuFloating as
|
|
6
|
-
const
|
|
7
|
-
const { variant:
|
|
8
|
-
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import m from "react";
|
|
3
|
+
import { useMenuContext as i } from "./menuContext.js";
|
|
4
|
+
import { MenuList as a } from "./menuList.js";
|
|
5
|
+
import { MenuFloating as p } from "./menuFloating.js";
|
|
6
|
+
const g = m.forwardRef(function(o, n) {
|
|
7
|
+
const { variant: e } = i();
|
|
8
|
+
if (e === "static") {
|
|
9
|
+
const { anchorElement: u, isOpen: c, onClose: f, placement: l, middleware: M, ...r } = o;
|
|
10
|
+
return /* @__PURE__ */ t(a, { ref: n, ...r });
|
|
11
|
+
}
|
|
12
|
+
return /* @__PURE__ */ t(p, { ref: n, ...o });
|
|
9
13
|
});
|
|
10
14
|
export {
|
|
11
|
-
|
|
15
|
+
g as MenuComponent
|
|
12
16
|
};
|
|
13
17
|
//# sourceMappingURL=menuComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menuComponent.js","sources":["../../../../src/components/navigation/menu/menuComponent.tsx"],"sourcesContent":["import React from \"react\";\nimport { useMenuContext } from \"./menuContext\";\nimport { MenuList } from \"./menuList\";\nimport { MenuFloating, MenuFloatingProps } from \"./menuFloating\";\n\nexport const MenuComponent = React.forwardRef<HTMLDivElement, MenuFloatingProps>(function MenuComponent(props, ref) {\n const { variant } = useMenuContext();\n
|
|
1
|
+
{"version":3,"file":"menuComponent.js","sources":["../../../../src/components/navigation/menu/menuComponent.tsx"],"sourcesContent":["import React from \"react\";\nimport { useMenuContext } from \"./menuContext\";\nimport { MenuList } from \"./menuList\";\nimport { MenuFloating, MenuFloatingProps } from \"./menuFloating\";\n\nexport const MenuComponent = React.forwardRef<HTMLDivElement, MenuFloatingProps>(function MenuComponent(props, ref) {\n const { variant } = useMenuContext();\n if (variant === \"static\") {\n // Static menus render MenuList directly; strip the floating-only props so\n // they don't leak onto the underlying <div> (e.g. isOpen → DOM attribute).\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { anchorElement, isOpen, onClose, placement, middleware, ...domProps } = props;\n return <MenuList ref={ref} {...domProps} />;\n }\n return <MenuFloating ref={ref} {...props} />;\n});\n"],"names":["MenuComponent","React","props","ref","variant","useMenuContext","anchorElement","isOpen","onClose","placement","middleware","domProps","jsx","MenuList","MenuFloating"],"mappings":";;;;;AAKO,MAAMA,IAAgBC,EAAM,WAA8C,SAAuBC,GAAOC,GAAK;AAClH,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAA;AACpB,MAAID,MAAY,UAAU;AAIxB,UAAM,EAAE,eAAAE,GAAe,QAAAC,GAAQ,SAAAC,GAAS,WAAAC,GAAW,YAAAC,GAAY,GAAGC,MAAaT;AAC/E,WAAO,gBAAAU,EAACC,GAAA,EAAS,KAAAV,GAAW,GAAGQ,EAAA,CAAU;AAAA,EAC3C;AACA,SAAO,gBAAAC,EAACE,GAAA,EAAa,KAAAX,GAAW,GAAGD,EAAA,CAAO;AAC5C,CAAC;"}
|
|
@@ -1,88 +1,79 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsxs as B, jsx as w } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as C, useRef as O, useState as y, useEffect as b, Children as P, useMemo as U, useCallback as W } from "react";
|
|
3
3
|
import D from "clsx";
|
|
4
|
-
import { throttle as
|
|
5
|
-
import { useForkRef as
|
|
6
|
-
const
|
|
4
|
+
import { throttle as X } from "../../../utils/throttle.js";
|
|
5
|
+
import { useForkRef as Y } from "../../../hooks/useForkRef.js";
|
|
6
|
+
const x = (c, d) => !c && d ? 100 - d : c || 50, V = C(function({
|
|
7
7
|
className: d,
|
|
8
8
|
orientation: e = "horizontal",
|
|
9
|
-
sizeFirst:
|
|
9
|
+
sizeFirst: f,
|
|
10
10
|
sizeSecond: v,
|
|
11
|
-
children:
|
|
12
|
-
onSizeChange:
|
|
11
|
+
children: L,
|
|
12
|
+
onSizeChange: i,
|
|
13
13
|
keyboardStep: g = 5,
|
|
14
|
-
resizerAriaLabel:
|
|
15
|
-
},
|
|
16
|
-
const p =
|
|
14
|
+
resizerAriaLabel: $ = "Resize panels"
|
|
15
|
+
}, k) {
|
|
16
|
+
const p = O(null), A = Y(k, p), [t, n] = y(x(f, v)), [E, R] = y(null), [m, _] = y(!1);
|
|
17
17
|
b(() => {
|
|
18
|
-
|
|
19
|
-
}, [
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
18
|
+
n(x(f, v));
|
|
19
|
+
}, [f, v]);
|
|
20
|
+
const h = P.toArray(L);
|
|
21
|
+
if (h.length > 2)
|
|
22
22
|
throw new Error("Allowed not more than 2 children");
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
() =>
|
|
27
|
-
if (!
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
s < 0 && (s = 0);
|
|
33
|
-
const t = s / n.clientHeight * 100;
|
|
34
|
-
_(t, n.clientWidth) > 5 && t < 101 && l(t - 7);
|
|
35
|
-
} else {
|
|
36
|
-
let s = r.clientX - n.offsetLeft;
|
|
37
|
-
s < 0 && (s = 0);
|
|
38
|
-
const t = s / n.clientWidth * 100;
|
|
39
|
-
_(t, n.clientWidth) > 5 && t < 101 && l(t);
|
|
40
|
-
}
|
|
23
|
+
const M = () => {
|
|
24
|
+
R(p.current), _(!0);
|
|
25
|
+
}, o = U(
|
|
26
|
+
() => X((r) => {
|
|
27
|
+
if (!m) return;
|
|
28
|
+
const a = p.current;
|
|
29
|
+
if (!a || a !== E) return;
|
|
30
|
+
const s = a.getBoundingClientRect(), l = e === "vertical" ? s.height : s.width, j = e === "vertical" ? r.clientY - s.top : r.clientX - s.left, H = Math.max(5, Math.min(l - 5, j));
|
|
31
|
+
n(H / l * 100);
|
|
41
32
|
}, 1e3 / 60),
|
|
42
|
-
[
|
|
43
|
-
), u =
|
|
44
|
-
|
|
45
|
-
}, [
|
|
33
|
+
[m, E, e]
|
|
34
|
+
), u = W(() => {
|
|
35
|
+
R(null), _(!1), document.body.removeEventListener("pointerup", u), document.body.removeEventListener("pointermove", o);
|
|
36
|
+
}, [o]);
|
|
46
37
|
b(() => {
|
|
47
|
-
|
|
48
|
-
}, [
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
r.key ===
|
|
52
|
-
},
|
|
53
|
-
return b(() => (
|
|
54
|
-
document.body.removeEventListener("pointerup", u), document.body.removeEventListener("pointermove",
|
|
55
|
-
}), [
|
|
38
|
+
i == null || i(t);
|
|
39
|
+
}, [t, i]);
|
|
40
|
+
const K = (r) => {
|
|
41
|
+
const a = e === "vertical" ? "ArrowUp" : "ArrowLeft", s = e === "vertical" ? "ArrowDown" : "ArrowRight";
|
|
42
|
+
r.key === a ? (r.preventDefault(), n((l) => Math.max(0, l - g))) : r.key === s ? (r.preventDefault(), n((l) => Math.min(100, l + g))) : r.key === "Home" ? (r.preventDefault(), n(0)) : r.key === "End" && (r.preventDefault(), n(100));
|
|
43
|
+
}, N = e === "vertical" ? { height: `${100 - t}%` } : { width: `${100 - t}%` }, I = e === "vertical" ? { height: `${t}%` } : { width: `${t}%` };
|
|
44
|
+
return b(() => (m ? (document.body.addEventListener("pointerup", u), document.body.addEventListener("pointermove", o), document.body.style.cursor = e === "horizontal" ? "e-resize" : "n-resize") : document.body.style.cursor = "default", () => {
|
|
45
|
+
document.body.removeEventListener("pointerup", u), document.body.removeEventListener("pointermove", o);
|
|
46
|
+
}), [o, u, m, e]), /* @__PURE__ */ B(
|
|
56
47
|
"div",
|
|
57
48
|
{
|
|
58
49
|
className: D("smwb-screen-divider__wrapper", `smwb-${e}`, d),
|
|
59
|
-
ref:
|
|
50
|
+
ref: A,
|
|
60
51
|
"data-testid": "screen-divider",
|
|
61
52
|
children: [
|
|
62
|
-
/* @__PURE__ */
|
|
63
|
-
/* @__PURE__ */
|
|
53
|
+
/* @__PURE__ */ w("div", { className: D("smwb-screen-divider__first", `smwb-${e}`), style: I, children: h[0] || "" }),
|
|
54
|
+
/* @__PURE__ */ w(
|
|
64
55
|
"span",
|
|
65
56
|
{
|
|
66
57
|
className: "smwb-screen-divider__resizer",
|
|
67
|
-
onPointerDown:
|
|
58
|
+
onPointerDown: M,
|
|
68
59
|
draggable: !1,
|
|
69
60
|
role: "separator",
|
|
70
61
|
"aria-orientation": e === "vertical" ? "horizontal" : "vertical",
|
|
71
|
-
"aria-valuenow": Math.round(
|
|
62
|
+
"aria-valuenow": Math.round(t),
|
|
72
63
|
"aria-valuemin": 0,
|
|
73
64
|
"aria-valuemax": 100,
|
|
74
|
-
"aria-label":
|
|
65
|
+
"aria-label": $,
|
|
75
66
|
tabIndex: 0,
|
|
76
|
-
onKeyDown:
|
|
67
|
+
onKeyDown: K
|
|
77
68
|
}
|
|
78
69
|
),
|
|
79
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ w("div", { className: D("smwb-screen-divider__second", `smwb-${e}`), style: N, children: h[1] || "" })
|
|
80
71
|
]
|
|
81
72
|
}
|
|
82
73
|
);
|
|
83
74
|
});
|
|
84
75
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
V as ScreenDivider,
|
|
77
|
+
V as default
|
|
87
78
|
};
|
|
88
79
|
//# sourceMappingURL=screenDivider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenDivider.js","sources":["../../../../../src/components/layout/screenDivider/screenDivider.tsx"],"sourcesContent":["import React, {\n Children,\n forwardRef,\n KeyboardEvent,\n PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport cn from \"clsx\";\nimport { throttle } from \"../../../utils/throttle\";\nimport { useForkRef } from \"../../../hooks/useForkRef\";\n\nexport interface ScreenDividerProps {\n sizeFirst?: number;\n sizeSecond?: number;\n className?: string;\n orientation?: \"horizontal\" | \"vertical\";\n /** Called with the first pane size (percent) whenever it changes. */\n onSizeChange?: (sizeFirst: number) => void;\n /** Step (in percent) applied on arrow-key resize. */\n keyboardStep?: number;\n /** Accessible label for the resizer handle. */\n resizerAriaLabel?: string;\n}\n\nconst toPixels = (percent: number, parentSize: number) => {\n return parentSize * (percent / 100);\n};\n\nconst getInitialDivider = (sizeFirst?: number | null, sizeSecond?: number | null) => {\n if (!sizeFirst && sizeSecond) {\n return 100 - sizeSecond;\n }\n if (sizeFirst) {\n return sizeFirst;\n }\n return 50;\n};\n\nexport const ScreenDivider = forwardRef<HTMLDivElement, PropsWithChildren<ScreenDividerProps>>(function ScreenDivider(\n {\n className,\n orientation = \"horizontal\",\n sizeFirst,\n sizeSecond,\n children,\n onSizeChange,\n keyboardStep = 5,\n resizerAriaLabel = \"Resize panels\",\n },\n ref\n) {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const forkedWrapperRef = useForkRef<HTMLDivElement>(ref, wrapperRef);\n const [divider, setDivider] = useState<number>(getInitialDivider(sizeFirst, sizeSecond));\n const [currentElement, setCurrentElement] = useState<HTMLDivElement | null>(null);\n const [isDragging, setIsDragging] = useState(false);\n\n useEffect(() => {\n setDivider(getInitialDivider(sizeFirst, sizeSecond));\n }, [sizeFirst, sizeSecond]);\n\n const child = Children.toArray(children);\n if (child.length > 2) {\n throw new Error(\"Allowed not more than 2 children\");\n }\n\n const handleDragStart = () => {\n setCurrentElement(wrapperRef.current);\n setIsDragging(true);\n };\n\n const dragOverHandler = useMemo(\n () =>\n throttle((e: PointerEvent) => {\n if (!isDragging) return;\n\n const wrapper = wrapperRef.current;\n if (!wrapper || wrapper !== currentElement) return;\n if (orientation === \"vertical\") {\n let relativeMouseY = e.clientY - wrapper.offsetTop;\n if (relativeMouseY < 0) {\n relativeMouseY = 0;\n }\n const newDivider = (relativeMouseY / wrapper.clientHeight) * 100;\n if (toPixels(newDivider, wrapper.clientWidth) > 5 && newDivider < 101) {\n setDivider(newDivider - 7);\n }\n } else {\n let relativeMouseX = e.clientX - wrapper.offsetLeft;\n if (relativeMouseX < 0) {\n relativeMouseX = 0;\n }\n const newDivider = (relativeMouseX / wrapper.clientWidth) * 100;\n if (toPixels(newDivider, wrapper.clientWidth) > 5 && newDivider < 101) {\n setDivider(newDivider);\n }\n }\n }, 1000 / 60),\n [isDragging, currentElement, orientation]\n );\n\n const handleDragEnd = useCallback(() => {\n setCurrentElement(null);\n setIsDragging(false);\n document.body.removeEventListener(\"pointerup\", handleDragEnd);\n document.body.removeEventListener(\"pointermove\", dragOverHandler);\n }, [dragOverHandler]);\n\n useEffect(() => {\n onSizeChange?.(divider);\n }, [divider, onSizeChange]);\n\n const onResizerKeyDown = (event: KeyboardEvent<HTMLSpanElement>) => {\n const decreaseKey = orientation === \"vertical\" ? \"ArrowUp\" : \"ArrowLeft\";\n const increaseKey = orientation === \"vertical\" ? \"ArrowDown\" : \"ArrowRight\";\n\n if (event.key === decreaseKey) {\n event.preventDefault();\n setDivider((prev) => Math.max(0, prev - keyboardStep));\n } else if (event.key === increaseKey) {\n event.preventDefault();\n setDivider((prev) => Math.min(100, prev + keyboardStep));\n } else if (event.key === \"Home\") {\n event.preventDefault();\n setDivider(0);\n } else if (event.key === \"End\") {\n event.preventDefault();\n setDivider(100);\n }\n };\n\n const secondChildStyle =\n orientation === \"vertical\" ? { height: `${100 - divider}%` } : { width: `${100 - divider}%` };\n\n const firstChildStyle = orientation === \"vertical\" ? { height: `${divider}%` } : { width: `${divider}%` };\n\n useEffect(() => {\n if (isDragging) {\n document.body.addEventListener(\"pointerup\", handleDragEnd);\n document.body.addEventListener(\"pointermove\", dragOverHandler);\n document.body.style.cursor = orientation === \"horizontal\" ? \"e-resize\" : \"n-resize\";\n } else {\n document.body.style.cursor = \"default\";\n }\n\n return () => {\n document.body.removeEventListener(\"pointerup\", handleDragEnd);\n document.body.removeEventListener(\"pointermove\", dragOverHandler);\n };\n }, [dragOverHandler, handleDragEnd, isDragging, orientation]);\n\n return (\n <div\n className={cn(\"smwb-screen-divider__wrapper\", `smwb-${orientation}`, className)}\n ref={forkedWrapperRef}\n data-testid=\"screen-divider\"\n >\n <div className={cn(\"smwb-screen-divider__first\", `smwb-${orientation}`)} style={firstChildStyle}>\n {child[0] || \"\"}\n </div>\n <span\n className=\"smwb-screen-divider__resizer\"\n onPointerDown={handleDragStart}\n draggable={false}\n role=\"separator\"\n aria-orientation={orientation === \"vertical\" ? \"horizontal\" : \"vertical\"}\n aria-valuenow={Math.round(divider)}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-label={resizerAriaLabel}\n tabIndex={0}\n onKeyDown={onResizerKeyDown}\n />\n <div className={cn(\"smwb-screen-divider__second\", `smwb-${orientation}`)} style={secondChildStyle}>\n {child[1] || \"\"}\n </div>\n </div>\n );\n});\n\nexport default ScreenDivider;\n"],"names":["toPixels","percent","parentSize","getInitialDivider","sizeFirst","sizeSecond","ScreenDivider","forwardRef","className","orientation","children","onSizeChange","keyboardStep","resizerAriaLabel","ref","wrapperRef","useRef","forkedWrapperRef","useForkRef","divider","setDivider","useState","currentElement","setCurrentElement","isDragging","setIsDragging","useEffect","child","Children","handleDragStart","dragOverHandler","useMemo","throttle","e","wrapper","relativeMouseY","newDivider","relativeMouseX","handleDragEnd","useCallback","onResizerKeyDown","event","decreaseKey","increaseKey","prev","secondChildStyle","firstChildStyle","jsxs","cn","jsx"],"mappings":";;;;;AA4BA,MAAMA,IAAW,CAACC,GAAiBC,MAC1BA,KAAcD,IAAU,MAG3BE,IAAoB,CAACC,GAA2BC,MAChD,CAACD,KAAaC,IACT,MAAMA,IAEXD,KAGG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EAAU,OACJF,KACF,SAAS,KAAK,iBAAiB,aAAac,CAAa,GACzD,SAAS,KAAK,iBAAiB,eAAeR,CAAe,GAC7D,SAAS,KAAK,MAAM,SAASrB,MAAgB,eAAe,aAAa,cAEzE,SAAS,KAAK,MAAM,SAAS,WAGxB,MAAM;AACX,aAAS,KAAK,oBAAoB,aAAa6B,CAAa,GAC5D,SAAS,KAAK,oBAAoB,eAAeR,CAAe;AAAA,EAClE,IACC,CAACA,GAAiBQ,GAAed,GAAYf,CAAW,CAAC,GAG1D,gBAAAsC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,EAAG,gCAAgC,QAAQvC,CAAW,IAAID,CAAS;AAAA,MAC9E,KAAKS;AAAA,MACL,eAAY;AAAA,MAEZ,UAAA;AAAA,QAAA,gBAAAgC,EAAC,OAAA,EAAI,WAAWD,EAAG,8BAA8B,QAAQvC,CAAW,EAAE,GAAG,OAAOqC,GAC7E,UAAAnB,EAAM,CAAC,KAAK,IACf;AAAA,QACA,gBAAAsB;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,eAAepB;AAAA,YACf,WAAW;AAAA,YACX,MAAK;AAAA,YACL,oBAAkBpB,MAAgB,aAAa,eAAe;AAAA,YAC9D,iBAAe,KAAK,MAAMU,CAAO;AAAA,YACjC,iBAAe;AAAA,YACf,iBAAe;AAAA,YACf,cAAYN;AAAA,YACZ,UAAU;AAAA,YACV,WAAW2B;AAAA,UAAA;AAAA,QAAA;AAAA,QAEb,gBAAAS,EAAC,OAAA,EAAI,WAAWD,EAAG,+BAA+B,QAAQvC,CAAW,EAAE,GAAG,OAAOoC,GAC9E,UAAAlB,EAAM,CAAC,KAAK,GAAA,CACf;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;"}
|
|
1
|
+
{"version":3,"file":"screenDivider.js","sources":["../../../../../src/components/layout/screenDivider/screenDivider.tsx"],"sourcesContent":["import React, {\n Children,\n forwardRef,\n KeyboardEvent,\n PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport cn from \"clsx\";\nimport { throttle } from \"../../../utils/throttle\";\nimport { useForkRef } from \"../../../hooks/useForkRef\";\n\nexport interface ScreenDividerProps {\n sizeFirst?: number;\n sizeSecond?: number;\n className?: string;\n orientation?: \"horizontal\" | \"vertical\";\n /** Called with the first pane size (percent) whenever it changes. */\n onSizeChange?: (sizeFirst: number) => void;\n /** Step (in percent) applied on arrow-key resize. */\n keyboardStep?: number;\n /** Accessible label for the resizer handle. */\n resizerAriaLabel?: string;\n}\n\nconst getInitialDivider = (sizeFirst?: number | null, sizeSecond?: number | null) => {\n if (!sizeFirst && sizeSecond) {\n return 100 - sizeSecond;\n }\n if (sizeFirst) {\n return sizeFirst;\n }\n return 50;\n};\n\nexport const ScreenDivider = forwardRef<HTMLDivElement, PropsWithChildren<ScreenDividerProps>>(function ScreenDivider(\n {\n className,\n orientation = \"horizontal\",\n sizeFirst,\n sizeSecond,\n children,\n onSizeChange,\n keyboardStep = 5,\n resizerAriaLabel = \"Resize panels\",\n },\n ref\n) {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const forkedWrapperRef = useForkRef<HTMLDivElement>(ref, wrapperRef);\n const [divider, setDivider] = useState<number>(getInitialDivider(sizeFirst, sizeSecond));\n const [currentElement, setCurrentElement] = useState<HTMLDivElement | null>(null);\n const [isDragging, setIsDragging] = useState(false);\n\n useEffect(() => {\n setDivider(getInitialDivider(sizeFirst, sizeSecond));\n }, [sizeFirst, sizeSecond]);\n\n const child = Children.toArray(children);\n if (child.length > 2) {\n throw new Error(\"Allowed not more than 2 children\");\n }\n\n const handleDragStart = () => {\n setCurrentElement(wrapperRef.current);\n setIsDragging(true);\n };\n\n const dragOverHandler = useMemo(\n () =>\n throttle((e: PointerEvent) => {\n if (!isDragging) return;\n const wrapper = wrapperRef.current;\n if (!wrapper || wrapper !== currentElement) return;\n // Viewport-relative rect — using offsetLeft/offsetTop here is wrong\n // because they are relative to the nearest positioned ancestor, not\n // the viewport that clientX/clientY live in (this is what made the\n // divider drift away from the cursor when the wrapper was nested).\n const rect = wrapper.getBoundingClientRect();\n const total = orientation === \"vertical\" ? rect.height : rect.width;\n const cursor = orientation === \"vertical\" ? e.clientY - rect.top : e.clientX - rect.left;\n // 5px margin on each side so neither pane fully collapses.\n const clamped = Math.max(5, Math.min(total - 5, cursor));\n setDivider((clamped / total) * 100);\n }, 1000 / 60),\n [isDragging, currentElement, orientation]\n );\n\n const handleDragEnd = useCallback(() => {\n setCurrentElement(null);\n setIsDragging(false);\n document.body.removeEventListener(\"pointerup\", handleDragEnd);\n document.body.removeEventListener(\"pointermove\", dragOverHandler);\n }, [dragOverHandler]);\n\n useEffect(() => {\n onSizeChange?.(divider);\n }, [divider, onSizeChange]);\n\n const onResizerKeyDown = (event: KeyboardEvent<HTMLSpanElement>) => {\n const decreaseKey = orientation === \"vertical\" ? \"ArrowUp\" : \"ArrowLeft\";\n const increaseKey = orientation === \"vertical\" ? \"ArrowDown\" : \"ArrowRight\";\n\n if (event.key === decreaseKey) {\n event.preventDefault();\n setDivider((prev) => Math.max(0, prev - keyboardStep));\n } else if (event.key === increaseKey) {\n event.preventDefault();\n setDivider((prev) => Math.min(100, prev + keyboardStep));\n } else if (event.key === \"Home\") {\n event.preventDefault();\n setDivider(0);\n } else if (event.key === \"End\") {\n event.preventDefault();\n setDivider(100);\n }\n };\n\n const secondChildStyle =\n orientation === \"vertical\" ? { height: `${100 - divider}%` } : { width: `${100 - divider}%` };\n\n const firstChildStyle = orientation === \"vertical\" ? { height: `${divider}%` } : { width: `${divider}%` };\n\n useEffect(() => {\n if (isDragging) {\n document.body.addEventListener(\"pointerup\", handleDragEnd);\n document.body.addEventListener(\"pointermove\", dragOverHandler);\n document.body.style.cursor = orientation === \"horizontal\" ? \"e-resize\" : \"n-resize\";\n } else {\n document.body.style.cursor = \"default\";\n }\n\n return () => {\n document.body.removeEventListener(\"pointerup\", handleDragEnd);\n document.body.removeEventListener(\"pointermove\", dragOverHandler);\n };\n }, [dragOverHandler, handleDragEnd, isDragging, orientation]);\n\n return (\n <div\n className={cn(\"smwb-screen-divider__wrapper\", `smwb-${orientation}`, className)}\n ref={forkedWrapperRef}\n data-testid=\"screen-divider\"\n >\n <div className={cn(\"smwb-screen-divider__first\", `smwb-${orientation}`)} style={firstChildStyle}>\n {child[0] || \"\"}\n </div>\n <span\n className=\"smwb-screen-divider__resizer\"\n onPointerDown={handleDragStart}\n draggable={false}\n role=\"separator\"\n aria-orientation={orientation === \"vertical\" ? \"horizontal\" : \"vertical\"}\n aria-valuenow={Math.round(divider)}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-label={resizerAriaLabel}\n tabIndex={0}\n onKeyDown={onResizerKeyDown}\n />\n <div className={cn(\"smwb-screen-divider__second\", `smwb-${orientation}`)} style={secondChildStyle}>\n {child[1] || \"\"}\n </div>\n </div>\n );\n});\n\nexport default ScreenDivider;\n"],"names":["getInitialDivider","sizeFirst","sizeSecond","ScreenDivider","forwardRef","className","orientation","children","onSizeChange","keyboardStep","resizerAriaLabel","ref","wrapperRef","useRef","forkedWrapperRef","useForkRef","divider","setDivider","useState","currentElement","setCurrentElement","isDragging","setIsDragging","useEffect","child","Children","handleDragStart","dragOverHandler","useMemo","throttle","e","wrapper","rect","total","cursor","clamped","handleDragEnd","useCallback","onResizerKeyDown","event","decreaseKey","increaseKey","prev","secondChildStyle","firstChildStyle","jsxs","cn","jsx"],"mappings":";;;;;AA4BA,MAAMA,IAAoB,CAACC,GAA2BC,MAChD,CAACD,KAAaC,IACT,MAAMA,IAEXD,KAGG,IAGIE,IAAgBC,EAAkE,SAC7F;AAAA,EACE,WAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,WAAAL;AAAA,EACA,YAAAC;AAAA,EACA,UAAAK;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,kBAAAC,IAAmB;AACrB,GACAC,GACA;AACA,QAAMC,I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MAC9E,KAAKS;AAAA,MACL,eAAY;AAAA,MAEZ,UAAA;AAAA,QAAA,gBAAAiC,EAAC,OAAA,EAAI,WAAWD,EAAG,8BAA8B,QAAQxC,CAAW,EAAE,GAAG,OAAOsC,GAC7E,UAAApB,EAAM,CAAC,KAAK,IACf;AAAA,QACA,gBAAAuB;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,eAAerB;AAAA,YACf,WAAW;AAAA,YACX,MAAK;AAAA,YACL,oBAAkBpB,MAAgB,aAAa,eAAe;AAAA,YAC9D,iBAAe,KAAK,MAAMU,CAAO;AAAA,YACjC,iBAAe;AAAA,YACf,iBAAe;AAAA,YACf,cAAYN;AAAA,YACZ,UAAU;AAAA,YACV,WAAW4B;AAAA,UAAA;AAAA,QAAA;AAAA,QAEb,gBAAAS,EAAC,OAAA,EAAI,WAAWD,EAAG,+BAA+B,QAAQxC,CAAW,EAAE,GAAG,OAAOqC,GAC9E,UAAAnB,EAAM,CAAC,KAAK,GAAA,CACf;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useMenuContext as
|
|
4
|
-
import { MenuList as
|
|
5
|
-
import { MenuFloating as
|
|
6
|
-
const
|
|
7
|
-
const { variant:
|
|
8
|
-
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import m from "react";
|
|
3
|
+
import { useMenuContext as i } from "./menuContext.js";
|
|
4
|
+
import { MenuList as a } from "./menuList.js";
|
|
5
|
+
import { MenuFloating as p } from "./menuFloating.js";
|
|
6
|
+
const g = m.forwardRef(function(o, n) {
|
|
7
|
+
const { variant: e } = i();
|
|
8
|
+
if (e === "static") {
|
|
9
|
+
const { anchorElement: u, isOpen: c, onClose: f, placement: l, middleware: M, ...r } = o;
|
|
10
|
+
return /* @__PURE__ */ t(a, { ref: n, ...r });
|
|
11
|
+
}
|
|
12
|
+
return /* @__PURE__ */ t(p, { ref: n, ...o });
|
|
9
13
|
});
|
|
10
14
|
export {
|
|
11
|
-
|
|
15
|
+
g as MenuComponent
|
|
12
16
|
};
|
|
13
17
|
//# sourceMappingURL=menuComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menuComponent.js","sources":["../../../../../src/components/navigation/menu/menuComponent.tsx"],"sourcesContent":["import React from \"react\";\nimport { useMenuContext } from \"./menuContext\";\nimport { MenuList } from \"./menuList\";\nimport { MenuFloating, MenuFloatingProps } from \"./menuFloating\";\n\nexport const MenuComponent = React.forwardRef<HTMLDivElement, MenuFloatingProps>(function MenuComponent(props, ref) {\n const { variant } = useMenuContext();\n
|
|
1
|
+
{"version":3,"file":"menuComponent.js","sources":["../../../../../src/components/navigation/menu/menuComponent.tsx"],"sourcesContent":["import React from \"react\";\nimport { useMenuContext } from \"./menuContext\";\nimport { MenuList } from \"./menuList\";\nimport { MenuFloating, MenuFloatingProps } from \"./menuFloating\";\n\nexport const MenuComponent = React.forwardRef<HTMLDivElement, MenuFloatingProps>(function MenuComponent(props, ref) {\n const { variant } = useMenuContext();\n if (variant === \"static\") {\n // Static menus render MenuList directly; strip the floating-only props so\n // they don't leak onto the underlying <div> (e.g. isOpen → DOM attribute).\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { anchorElement, isOpen, onClose, placement, middleware, ...domProps } = props;\n return <MenuList ref={ref} {...domProps} />;\n }\n return <MenuFloating ref={ref} {...props} />;\n});\n"],"names":["MenuComponent","React","props","ref","variant","useMenuContext","anchorElement","isOpen","onClose","placement","middleware","domProps","jsx","MenuList","MenuFloating"],"mappings":";;;;;AAKO,MAAMA,IAAgBC,EAAM,WAA8C,SAAuBC,GAAOC,GAAK;AAClH,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAA;AACpB,MAAID,MAAY,UAAU;AAIxB,UAAM,EAAE,eAAAE,GAAe,QAAAC,GAAQ,SAAAC,GAAS,WAAAC,GAAW,YAAAC,GAAY,GAAGC,MAAaT;AAC/E,WAAO,gBAAAU,EAACC,GAAA,EAAS,KAAAV,GAAW,GAAGQ,EAAA,CAAU;AAAA,EAC3C;AACA,SAAO,gBAAAC,EAACE,GAAA,EAAa,KAAAX,GAAW,GAAGD,EAAA,CAAO;AAC5C,CAAC;"}
|