@smwb/ui-react 2.0.1 → 2.1.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/README.md +5 -5
- package/dist/assets/styles/less/components/carousel/carousel.entry.css +1 -1
- package/dist/components/dataDisplay/carousel/carousel.d.ts +10 -0
- package/dist/components/dataDisplay/carousel/carousel.js +249 -131
- package/dist/components/dataDisplay/carousel/carousel.js.map +1 -1
- package/dist/components/dataDisplay/carousel/utils.d.ts +5 -0
- package/dist/components/dataDisplay/carousel/utils.js +32 -18
- package/dist/components/dataDisplay/carousel/utils.js.map +1 -1
- package/dist/components/inputs/selectField/selectField.js +85 -84
- package/dist/components/inputs/selectField/selectField.js.map +1 -1
- package/dist/components/layout/screenDivider/screenDivider.js +47 -56
- package/dist/components/layout/screenDivider/screenDivider.js.map +1 -1
- package/dist/headless/components/dataDisplay/carousel/carousel.js +249 -131
- package/dist/headless/components/dataDisplay/carousel/carousel.js.map +1 -1
- package/dist/headless/components/dataDisplay/carousel/utils.js +32 -18
- package/dist/headless/components/dataDisplay/carousel/utils.js.map +1 -1
- package/dist/headless/components/inputs/selectField/selectField.js +102 -101
- package/dist/headless/components/inputs/selectField/selectField.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/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/package.json +2 -2
|
@@ -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,M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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,kBA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,gCAAgC,QAAQxC,CAAW,IAAID,CAAS;AAAA,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,178 +1,296 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { useForkRef as
|
|
5
|
-
import { dragPrevent as
|
|
6
|
-
import { useSafeLayoutEffect as
|
|
7
|
-
import { useEventCallback as
|
|
8
|
-
import { Icon as
|
|
9
|
-
|
|
1
|
+
import { jsx as a, Fragment as ie, jsxs as j } from "react/jsx-runtime";
|
|
2
|
+
import O, { forwardRef as Oe, useState as x, useRef as T, useId as ze, useEffect as ue } from "react";
|
|
3
|
+
import m from "clsx";
|
|
4
|
+
import { useForkRef as Be } from "../../../hooks/useForkRef.js";
|
|
5
|
+
import { dragPrevent as de, getStartSlide as He, getSlidesToShow as Ke, isMouseEvent as fe, coordX as z, coordY as me, getSlideStyle as Ge, isTouchEvent as qe, getSlideWidth as Je, clamp as Qe, toCssLength as B, toCssNumber as Ue, getSlideIndexForMultipleParts as he } from "./utils.js";
|
|
6
|
+
import { useSafeLayoutEffect as _e } from "../../../hooks/useSafeLayoutEffect.js";
|
|
7
|
+
import { useEventCallback as H } from "../../../hooks/useEventCallback.js";
|
|
8
|
+
import { Icon as E } from "../../base/icon/icon.js";
|
|
9
|
+
import { Modal as Ze } from "../../feedBack/modal/modal.js";
|
|
10
|
+
const et = {
|
|
10
11
|
isPressed: !1,
|
|
11
12
|
startX: 0,
|
|
12
|
-
startY: 0
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
startY: 0,
|
|
14
|
+
lastX: 0,
|
|
15
|
+
lastT: 0,
|
|
16
|
+
axis: null,
|
|
17
|
+
dragged: !1
|
|
18
|
+
}, we = 8, tt = 0.4, mt = Oe(function({
|
|
19
|
+
slidesToShow: ve = 3,
|
|
20
|
+
startSlide: ge = 0,
|
|
21
|
+
children: w,
|
|
22
|
+
className: be,
|
|
23
|
+
showNavigation: xe = !0,
|
|
24
|
+
showArrows: pe,
|
|
25
|
+
arrowsSize: v = 30,
|
|
26
|
+
navigationClassName: Se,
|
|
27
|
+
onSlideChange: g,
|
|
28
|
+
navigationDotRenderer: K,
|
|
29
|
+
"aria-label": Ie = "Carousel",
|
|
30
|
+
autoplay: G = !1,
|
|
31
|
+
autoplayInterval: q = 4e3,
|
|
32
|
+
pauseOnHover: M = !0,
|
|
33
|
+
cellHeight: ye,
|
|
34
|
+
aspectRatio: Ne,
|
|
35
|
+
gap: Te,
|
|
36
|
+
maxWidth: Ee,
|
|
37
|
+
enableFullscreen: k = !1
|
|
38
|
+
}, Me) {
|
|
39
|
+
const s = O.Children.count(w), n = Ke(ve, s), L = He(ge, s), J = pe && s > 1, X = Math.max(0, s - n), [l, Q] = x(L), [Y, $] = x({
|
|
30
40
|
animation: void 0
|
|
31
|
-
}),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
...
|
|
41
|
+
}), [ke, U] = x(0), [Le, Z] = x(!1), [h, A] = x(null), P = T(null), Xe = T(null), Ae = Be(Me, Xe), f = T(null), [ee, te] = x(!1), i = T({ ...et });
|
|
42
|
+
_e(() => {
|
|
43
|
+
$((e) => ({
|
|
44
|
+
...e,
|
|
35
45
|
animation: !1
|
|
36
46
|
}));
|
|
37
|
-
}, [
|
|
38
|
-
|
|
39
|
-
...
|
|
47
|
+
}, [n]), _e(() => {
|
|
48
|
+
Q(L), g == null || g(L), Y.animation !== void 0 && $((e) => ({
|
|
49
|
+
...e,
|
|
40
50
|
animation: !0
|
|
41
51
|
}));
|
|
42
|
-
}, [
|
|
43
|
-
const
|
|
44
|
-
Object.assign(
|
|
45
|
-
},
|
|
46
|
-
|
|
52
|
+
}, [L]);
|
|
53
|
+
const F = (e) => {
|
|
54
|
+
Object.assign(i.current, e);
|
|
55
|
+
}, V = () => typeof performance != "undefined" ? performance.now() : Date.now(), se = (e) => {
|
|
56
|
+
const t = Qe(e, 0, X);
|
|
57
|
+
Q(t), $((r) => ({ ...r, animation: !0 })), g == null || g(t);
|
|
58
|
+
}, p = (e) => {
|
|
59
|
+
A((t) => t === null ? t : (t + e + s) % s);
|
|
60
|
+
}, S = T(null), Pe = (e) => {
|
|
61
|
+
f.current && (f.current.removeEventListener(e ? "mousemove" : "touchmove", ne), f.current.removeEventListener(e ? "mouseup" : "touchend", b), e && f.current.removeEventListener("mouseleave", b));
|
|
62
|
+
}, re = H((e) => {
|
|
63
|
+
if (!f.current)
|
|
47
64
|
return;
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
65
|
+
const t = fe(e);
|
|
66
|
+
if (t && e.button !== 0)
|
|
50
67
|
return;
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
68
|
+
e.stopPropagation();
|
|
69
|
+
const r = z(e), o = me(e);
|
|
70
|
+
F({
|
|
54
71
|
isPressed: !0,
|
|
55
|
-
startX:
|
|
56
|
-
startY:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
startX: r,
|
|
73
|
+
startY: o,
|
|
74
|
+
lastX: r,
|
|
75
|
+
lastT: V(),
|
|
76
|
+
axis: null,
|
|
77
|
+
dragged: !1
|
|
78
|
+
}), f.current.addEventListener(t ? "mousemove" : "touchmove", ne, { passive: !1 }), f.current.addEventListener(t ? "mouseup" : "touchend", b), t && f.current.addEventListener("mouseleave", b);
|
|
79
|
+
}), ne = H((e) => {
|
|
80
|
+
if (!P.current || !i.current.isPressed)
|
|
60
81
|
return;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
const o = V(t), m = Z(t), d = o - l, M = m - u, w = Math.abs(d), N = Math.abs(M);
|
|
67
|
-
if (w < N)
|
|
68
|
-
return;
|
|
69
|
-
const S = g.current.offsetWidth / s, ht = s === 1 ? 1.95 : 1.4;
|
|
70
|
-
if (w % S > S / ht) {
|
|
71
|
-
const _t = d < 0 ? 1 : -1, wt = r - s, E = c + _t;
|
|
72
|
-
if (E < 0 || E > wt)
|
|
82
|
+
if (qe(e) && e.touches.length > 1)
|
|
83
|
+
return b(e);
|
|
84
|
+
const t = z(e), r = me(e), o = t - i.current.startX, c = r - i.current.startY;
|
|
85
|
+
if (i.current.axis === null) {
|
|
86
|
+
if (Math.abs(o) < we && Math.abs(c) < we)
|
|
73
87
|
return;
|
|
74
|
-
|
|
88
|
+
const u = Math.abs(o) >= Math.abs(c) ? "x" : "y";
|
|
89
|
+
if (F({ axis: u, dragged: !0 }), u === "y")
|
|
90
|
+
return b(e);
|
|
91
|
+
s > 1 && Z(!0);
|
|
75
92
|
}
|
|
76
|
-
|
|
77
|
-
|
|
93
|
+
if (i.current.axis === "x") {
|
|
94
|
+
if (e.preventDefault(), e.stopPropagation(), s > 1) {
|
|
95
|
+
const u = l <= 0, d = l >= X, _ = u && o > 0 || d && o < 0 ? o * 0.35 : o;
|
|
96
|
+
U(_);
|
|
97
|
+
}
|
|
98
|
+
i.current.lastX = t, i.current.lastT = V();
|
|
99
|
+
}
|
|
100
|
+
}), b = H((e) => {
|
|
101
|
+
if (!i.current.isPressed)
|
|
78
102
|
return;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
103
|
+
const t = fe(e);
|
|
104
|
+
Pe(t);
|
|
105
|
+
const { axis: r, dragged: o, startX: c, lastX: u, lastT: d } = i.current;
|
|
106
|
+
if (F({ isPressed: !1 }), Z(!1), r === "x" && o && s > 1 && P.current) {
|
|
107
|
+
const _ = z(e), D = _ - c, y = P.current.offsetWidth / n, R = d ? (_ - u) / Math.max(1, V() - d) : 0;
|
|
108
|
+
let N = y > 0 ? Math.round(-D / y) : 0;
|
|
109
|
+
N === 0 && Math.abs(R) > tt && (N = R < 0 ? 1 : -1), se(l + N);
|
|
110
|
+
}
|
|
111
|
+
U(0);
|
|
112
|
+
}), Ce = (e) => () => {
|
|
113
|
+
i.current.dragged || k && A(e);
|
|
114
|
+
}, C = (e) => () => se(e), W = (e) => {
|
|
115
|
+
const t = n === 1, r = t ? s : Math.ceil(s / n), o = l + n, c = s - n <= l, d = (he(o, n, s, c) + e + r) % r;
|
|
116
|
+
return t ? d : d * n;
|
|
117
|
+
}, De = () => {
|
|
118
|
+
if (!xe)
|
|
119
|
+
return /* @__PURE__ */ a(ie, {});
|
|
120
|
+
const e = s - n <= l, t = n === 1, r = t ? s : Math.ceil(s / n), o = [];
|
|
121
|
+
for (let c = 0; c < r; c++) {
|
|
122
|
+
let u = c, d = l;
|
|
123
|
+
if (!t) {
|
|
124
|
+
const R = c === r - 1, N = l + n;
|
|
125
|
+
u = R ? s - n : c * n, d = he(N, n, s, e);
|
|
96
126
|
}
|
|
97
|
-
const
|
|
98
|
-
let
|
|
99
|
-
|
|
127
|
+
const _ = d === c, D = C(u);
|
|
128
|
+
let y = /* @__PURE__ */ a("div", { className: m("smwb-carousel__navigation__dot", _ && "current"), onClick: D }, c);
|
|
129
|
+
K && (y = K(c, _, D)), o.push(y);
|
|
100
130
|
}
|
|
101
|
-
return /* @__PURE__ */
|
|
102
|
-
},
|
|
103
|
-
const
|
|
104
|
-
return
|
|
105
|
-
},
|
|
106
|
-
transform: `translateX(-${
|
|
107
|
-
transition:
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
Array.isArray(
|
|
111
|
-
}, [
|
|
112
|
-
if (!
|
|
131
|
+
return /* @__PURE__ */ a("div", { className: m("smwb-carousel__navigation", Se), children: o });
|
|
132
|
+
}, Re = () => {
|
|
133
|
+
const e = l > X ? X : l;
|
|
134
|
+
return Je(n) * e;
|
|
135
|
+
}, Ye = ze(), $e = Ge(n), Fe = {
|
|
136
|
+
transform: `translateX(calc(-${Re()}% + ${ke}px))`,
|
|
137
|
+
transition: Le || Y.animation === void 0 ? "none" : Y.animation ? "transform 500ms cubic-bezier(.1, 0, .25, 1)" : "none"
|
|
138
|
+
}, I = {}, oe = B(ye), ce = Ue(Ne), ae = B(Te), le = B(Ee);
|
|
139
|
+
if (oe && (I["--smwb-carousel-cell-height"] = oe), ce && (I["--smwb-carousel-aspect-ratio"] = ce), ae && (I["--smwb-carousel-gap"] = ae), le && (I["--smwb-carousel-max-width"] = le), O.useEffect(() => {
|
|
140
|
+
Array.isArray(w) || console.error("SMWB Material: The `children` prop was passed invalidly. It should contain an array of elements.");
|
|
141
|
+
}, [w]), ue(() => {
|
|
142
|
+
if (!G || s <= 1 || M && ee || h !== null)
|
|
143
|
+
return;
|
|
144
|
+
const e = window.setInterval(() => {
|
|
145
|
+
C(W(1))();
|
|
146
|
+
}, q);
|
|
147
|
+
return () => window.clearInterval(e);
|
|
148
|
+
}, [
|
|
149
|
+
G,
|
|
150
|
+
q,
|
|
151
|
+
M,
|
|
152
|
+
ee,
|
|
153
|
+
s,
|
|
154
|
+
l,
|
|
155
|
+
n,
|
|
156
|
+
h
|
|
157
|
+
]), ue(() => {
|
|
158
|
+
if (h === null || s <= 1)
|
|
113
159
|
return;
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
return () =>
|
|
118
|
-
}, [
|
|
160
|
+
const e = (t) => {
|
|
161
|
+
t.key === "ArrowLeft" ? p(-1) : t.key === "ArrowRight" && p(1);
|
|
162
|
+
};
|
|
163
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
164
|
+
}, [h, s]), !Array.isArray(w))
|
|
165
|
+
return /* @__PURE__ */ a(ie, {});
|
|
166
|
+
const Ve = w, We = (e) => {
|
|
167
|
+
var t, r;
|
|
168
|
+
S.current = (r = (t = e.touches[0]) == null ? void 0 : t.clientX) != null ? r : null;
|
|
169
|
+
}, je = (e) => {
|
|
170
|
+
var r, o;
|
|
171
|
+
if (S.current === null || s <= 1)
|
|
172
|
+
return;
|
|
173
|
+
const t = ((o = (r = e.changedTouches[0]) == null ? void 0 : r.clientX) != null ? o : S.current) - S.current;
|
|
174
|
+
S.current = null, Math.abs(t) > 40 && p(t < 0 ? 1 : -1);
|
|
175
|
+
};
|
|
176
|
+
return /* @__PURE__ */ j(
|
|
119
177
|
"div",
|
|
120
178
|
{
|
|
121
|
-
className:
|
|
179
|
+
className: m("smwb-carousel", be),
|
|
122
180
|
"data-testid": "carousel",
|
|
123
|
-
ref:
|
|
181
|
+
ref: Ae,
|
|
124
182
|
role: "region",
|
|
125
183
|
"aria-roledescription": "carousel",
|
|
126
|
-
"aria-label":
|
|
127
|
-
|
|
128
|
-
|
|
184
|
+
"aria-label": Ie,
|
|
185
|
+
style: I,
|
|
186
|
+
onMouseEnter: M ? () => te(!0) : void 0,
|
|
187
|
+
onMouseLeave: M ? () => te(!1) : void 0,
|
|
129
188
|
children: [
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
|
|
132
|
-
|
|
189
|
+
/* @__PURE__ */ j("div", { className: m("smwb-carousel__inner"), ref: P, children: [
|
|
190
|
+
J && /* @__PURE__ */ a(
|
|
191
|
+
E,
|
|
133
192
|
{
|
|
134
193
|
name: "chevron_left",
|
|
135
|
-
size:
|
|
136
|
-
className:
|
|
194
|
+
size: v,
|
|
195
|
+
className: m("smwb-carousel__arrow", "smwb-carousel__arrow_prev"),
|
|
137
196
|
style: {
|
|
138
|
-
top: `calc(50% - ${
|
|
139
|
-
left: -
|
|
197
|
+
top: `calc(50% - ${v / 2}px)`,
|
|
198
|
+
left: -v / 2
|
|
140
199
|
},
|
|
141
|
-
onClick: () =>
|
|
200
|
+
onClick: () => C(W(-1))()
|
|
142
201
|
}
|
|
143
202
|
),
|
|
144
|
-
/* @__PURE__ */
|
|
203
|
+
/* @__PURE__ */ a(
|
|
145
204
|
"div",
|
|
146
205
|
{
|
|
147
|
-
ref:
|
|
206
|
+
ref: f,
|
|
148
207
|
className: "smwb-carousel__track",
|
|
149
|
-
onMouseDown:
|
|
150
|
-
onTouchStart:
|
|
151
|
-
onDragStart:
|
|
152
|
-
onDragEnd:
|
|
153
|
-
children: /* @__PURE__ */
|
|
208
|
+
onMouseDown: re,
|
|
209
|
+
onTouchStart: re,
|
|
210
|
+
onDragStart: de,
|
|
211
|
+
onDragEnd: de,
|
|
212
|
+
children: /* @__PURE__ */ a("div", { className: "smwb-carousel__layer", style: Fe, children: O.Children.map(w, (e, t) => /* @__PURE__ */ a("div", { id: `${Ye}${t}`, className: "smwb-carousel__slide", style: $e, children: /* @__PURE__ */ a(
|
|
213
|
+
"div",
|
|
214
|
+
{
|
|
215
|
+
className: m(
|
|
216
|
+
"smwb-carousel__slide-inner",
|
|
217
|
+
k && "smwb-carousel__slide-inner_clickable"
|
|
218
|
+
),
|
|
219
|
+
onClick: k ? Ce(t) : void 0,
|
|
220
|
+
children: e
|
|
221
|
+
}
|
|
222
|
+
) }, t)) })
|
|
154
223
|
}
|
|
155
224
|
),
|
|
156
|
-
|
|
157
|
-
|
|
225
|
+
J && /* @__PURE__ */ a(
|
|
226
|
+
E,
|
|
158
227
|
{
|
|
159
228
|
name: "chevron_right",
|
|
160
|
-
size:
|
|
161
|
-
className:
|
|
229
|
+
size: v,
|
|
230
|
+
className: m("smwb-carousel__arrow", "smwb-carousel__arrow_next"),
|
|
162
231
|
style: {
|
|
163
|
-
top: `calc(50% - ${
|
|
164
|
-
right: -
|
|
232
|
+
top: `calc(50% - ${v / 2}px)`,
|
|
233
|
+
right: -v / 2
|
|
165
234
|
},
|
|
166
|
-
onClick: () =>
|
|
235
|
+
onClick: () => C(W(1))()
|
|
167
236
|
}
|
|
168
237
|
)
|
|
169
238
|
] }),
|
|
170
|
-
|
|
239
|
+
De(),
|
|
240
|
+
k && /* @__PURE__ */ a(
|
|
241
|
+
Ze,
|
|
242
|
+
{
|
|
243
|
+
open: h !== null,
|
|
244
|
+
size: "fullscreen",
|
|
245
|
+
backdrop: "darkBlured",
|
|
246
|
+
className: "smwb-carousel__fullscreen",
|
|
247
|
+
onClose: () => A(null),
|
|
248
|
+
"aria-label": "Image viewer",
|
|
249
|
+
children: h !== null && /* @__PURE__ */ j("div", { className: "smwb-carousel__fullscreen-content", children: [
|
|
250
|
+
s > 1 && /* @__PURE__ */ a(
|
|
251
|
+
E,
|
|
252
|
+
{
|
|
253
|
+
name: "chevron_left",
|
|
254
|
+
size: 40,
|
|
255
|
+
className: m("smwb-carousel__fullscreen-arrow", "smwb-carousel__fullscreen-arrow_prev"),
|
|
256
|
+
onClick: () => p(-1)
|
|
257
|
+
}
|
|
258
|
+
),
|
|
259
|
+
/* @__PURE__ */ a(
|
|
260
|
+
"div",
|
|
261
|
+
{
|
|
262
|
+
className: "smwb-carousel__fullscreen-stage",
|
|
263
|
+
onTouchStart: We,
|
|
264
|
+
onTouchEnd: je,
|
|
265
|
+
children: Ve[h]
|
|
266
|
+
}
|
|
267
|
+
),
|
|
268
|
+
s > 1 && /* @__PURE__ */ a(
|
|
269
|
+
E,
|
|
270
|
+
{
|
|
271
|
+
name: "chevron_right",
|
|
272
|
+
size: 40,
|
|
273
|
+
className: m("smwb-carousel__fullscreen-arrow", "smwb-carousel__fullscreen-arrow_next"),
|
|
274
|
+
onClick: () => p(1)
|
|
275
|
+
}
|
|
276
|
+
),
|
|
277
|
+
/* @__PURE__ */ a(
|
|
278
|
+
E,
|
|
279
|
+
{
|
|
280
|
+
name: "close",
|
|
281
|
+
size: 32,
|
|
282
|
+
className: "smwb-carousel__fullscreen-close",
|
|
283
|
+
onClick: () => A(null)
|
|
284
|
+
}
|
|
285
|
+
)
|
|
286
|
+
] })
|
|
287
|
+
}
|
|
288
|
+
)
|
|
171
289
|
]
|
|
172
290
|
}
|
|
173
|
-
)
|
|
291
|
+
);
|
|
174
292
|
});
|
|
175
293
|
export {
|
|
176
|
-
|
|
294
|
+
mt as Carousel
|
|
177
295
|
};
|
|
178
296
|
//# sourceMappingURL=carousel.js.map
|