@clyrex-digital/clyrex-controls-dev 0.8.1-dev.20261016052853 → 0.8.1-dev.20261016054542
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Slider-BH5S4XRN.mjs → Slider-HVBGZ6AD.mjs} +249 -49
- package/dist/{Slider-XDYPGJYI.mjs → Slider-TMKPDMQ4.mjs} +249 -49
- package/dist/index.js +249 -49
- package/dist/index.mjs +1 -1
- package/dist/server.js +249 -49
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -4829,8 +4829,15 @@ var init_Slider = __esm({
|
|
|
4829
4829
|
);
|
|
4830
4830
|
const [isPlaying, setIsPlaying] = (0, import_react42.useState)(autoplay);
|
|
4831
4831
|
const trackRef = (0, import_react42.useRef)(null);
|
|
4832
|
-
console.log("trackRef:", trackRef);
|
|
4833
4832
|
const [videoProgress, setVideoProgress] = (0, import_react42.useState)(null);
|
|
4833
|
+
const activeVideosRef = (0, import_react42.useRef)([]);
|
|
4834
|
+
const completedVideosRef = (0, import_react42.useRef)(/* @__PURE__ */ new Set());
|
|
4835
|
+
const nextSlideRef = (0, import_react42.useRef)(() => {
|
|
4836
|
+
});
|
|
4837
|
+
const isPlayingRef = (0, import_react42.useRef)(isPlaying);
|
|
4838
|
+
(0, import_react42.useEffect)(() => {
|
|
4839
|
+
isPlayingRef.current = isPlaying;
|
|
4840
|
+
}, [isPlaying]);
|
|
4834
4841
|
(0, import_react42.useEffect)(() => {
|
|
4835
4842
|
if (typeof initialSlidesToShow === "number") {
|
|
4836
4843
|
setSlidesToShowState(initialSlidesToShow);
|
|
@@ -4849,51 +4856,6 @@ var init_Slider = __esm({
|
|
|
4849
4856
|
window.addEventListener("resize", handleResize);
|
|
4850
4857
|
return () => window.removeEventListener("resize", handleResize);
|
|
4851
4858
|
}, [initialSlidesToShow]);
|
|
4852
|
-
(0, import_react42.useEffect)(() => {
|
|
4853
|
-
if (!autoplay) return;
|
|
4854
|
-
const activeSlideElement = trackRef.current?.children[currentSlide];
|
|
4855
|
-
const videoElement = activeSlideElement?.querySelector("video");
|
|
4856
|
-
if (videoElement) {
|
|
4857
|
-
videoElement.loop = false;
|
|
4858
|
-
setVideoProgress(0);
|
|
4859
|
-
if (videoElement.ended) {
|
|
4860
|
-
videoElement.currentTime = 0;
|
|
4861
|
-
}
|
|
4862
|
-
videoElement.play().catch(() => {
|
|
4863
|
-
});
|
|
4864
|
-
const handleTimeUpdate = () => {
|
|
4865
|
-
if (videoElement.duration && !isNaN(videoElement.duration) && videoElement.duration > 0) {
|
|
4866
|
-
const pct = videoElement.currentTime / videoElement.duration * 100;
|
|
4867
|
-
setVideoProgress(pct);
|
|
4868
|
-
}
|
|
4869
|
-
};
|
|
4870
|
-
const handleVideoEnded = () => {
|
|
4871
|
-
setVideoProgress(100);
|
|
4872
|
-
nextSlide();
|
|
4873
|
-
};
|
|
4874
|
-
const handleVideoError = () => {
|
|
4875
|
-
nextSlide();
|
|
4876
|
-
};
|
|
4877
|
-
videoElement.addEventListener("timeupdate", handleTimeUpdate);
|
|
4878
|
-
videoElement.addEventListener("loadedmetadata", handleTimeUpdate);
|
|
4879
|
-
videoElement.addEventListener("ended", handleVideoEnded, { once: true });
|
|
4880
|
-
videoElement.addEventListener("error", handleVideoError, { once: true });
|
|
4881
|
-
return () => {
|
|
4882
|
-
videoElement.removeEventListener("timeupdate", handleTimeUpdate);
|
|
4883
|
-
videoElement.removeEventListener("loadedmetadata", handleTimeUpdate);
|
|
4884
|
-
videoElement.removeEventListener("ended", handleVideoEnded);
|
|
4885
|
-
videoElement.removeEventListener("error", handleVideoError);
|
|
4886
|
-
videoElement.pause();
|
|
4887
|
-
setVideoProgress(null);
|
|
4888
|
-
};
|
|
4889
|
-
}
|
|
4890
|
-
const timer = setInterval(() => {
|
|
4891
|
-
if (isPlaying) {
|
|
4892
|
-
nextSlide();
|
|
4893
|
-
}
|
|
4894
|
-
}, autoplay_speed);
|
|
4895
|
-
return () => clearInterval(timer);
|
|
4896
|
-
}, [autoplay, autoplay_speed, currentSlide, isPlaying]);
|
|
4897
4859
|
const totalSlides = import_react42.Children.count(children);
|
|
4898
4860
|
const numColumns = columns ?? slidesToShowState;
|
|
4899
4861
|
const slideWidthPercentage = (() => {
|
|
@@ -4909,17 +4871,18 @@ var init_Slider = __esm({
|
|
|
4909
4871
|
const effectiveSlidesToShow = 100 / slideWidthPercentage;
|
|
4910
4872
|
const maxSlide = Math.max(0, Math.ceil(totalSlides - effectiveSlidesToShow));
|
|
4911
4873
|
const step = scrollByColumns ? Math.max(1, Math.floor(effectiveSlidesToShow)) : 1;
|
|
4912
|
-
const
|
|
4874
|
+
const rawPositions = Array.from(
|
|
4913
4875
|
{ length: Math.ceil(maxSlide / step) + 1 },
|
|
4914
4876
|
(_, index) => Math.min(index * step, maxSlide)
|
|
4915
4877
|
);
|
|
4878
|
+
const slidePositions = Array.from(new Set(rawPositions));
|
|
4916
4879
|
const currentStepIndex = slidePositions.reduce(
|
|
4917
4880
|
(closestIndex, position, index) => Math.abs(position - currentSlide) < Math.abs(slidePositions[closestIndex] - currentSlide) ? index : closestIndex,
|
|
4918
4881
|
0
|
|
4919
4882
|
);
|
|
4920
4883
|
const nextSlide = () => {
|
|
4921
4884
|
if (currentStepIndex >= slidePositions.length - 1) {
|
|
4922
|
-
if (infinite_scroll) {
|
|
4885
|
+
if (infinite_scroll || autoplay) {
|
|
4923
4886
|
setTransition(true);
|
|
4924
4887
|
setCurrentSlide(0);
|
|
4925
4888
|
}
|
|
@@ -4928,6 +4891,7 @@ var init_Slider = __esm({
|
|
|
4928
4891
|
setCurrentSlide(slidePositions[currentStepIndex + 1]);
|
|
4929
4892
|
}
|
|
4930
4893
|
};
|
|
4894
|
+
nextSlideRef.current = nextSlide;
|
|
4931
4895
|
const prevSlide = () => {
|
|
4932
4896
|
if (currentStepIndex <= 0) {
|
|
4933
4897
|
if (infinite_scroll) {
|
|
@@ -4949,6 +4913,242 @@ var init_Slider = __esm({
|
|
|
4949
4913
|
setIsPlaying(true);
|
|
4950
4914
|
}
|
|
4951
4915
|
};
|
|
4916
|
+
const getVisibleSlideElements = () => {
|
|
4917
|
+
if (!trackRef.current) return [];
|
|
4918
|
+
const childEls = Array.from(trackRef.current.children);
|
|
4919
|
+
if (childEls.length === 0) return [];
|
|
4920
|
+
const container = trackRef.current.parentElement;
|
|
4921
|
+
if (container) {
|
|
4922
|
+
const containerRect = container.getBoundingClientRect();
|
|
4923
|
+
if (containerRect.width > 0) {
|
|
4924
|
+
const visibleByRect = childEls.filter((child) => {
|
|
4925
|
+
const rect = child.getBoundingClientRect();
|
|
4926
|
+
const visibleLeft = Math.max(containerRect.left, rect.left);
|
|
4927
|
+
const visibleRight = Math.min(containerRect.right, rect.right);
|
|
4928
|
+
const visibleWidth = visibleRight - visibleLeft;
|
|
4929
|
+
return visibleWidth > 20 || visibleWidth / (rect.width || 1) > 0.15;
|
|
4930
|
+
});
|
|
4931
|
+
if (visibleByRect.length > 0) {
|
|
4932
|
+
return visibleByRect;
|
|
4933
|
+
}
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
const cols = columns ?? slidesToShowState ?? 1;
|
|
4937
|
+
const numCols = Math.max(1, Math.round(effectiveSlidesToShow || cols || 1));
|
|
4938
|
+
const startIndex = Math.max(0, Math.min(currentSlide, childEls.length - 1));
|
|
4939
|
+
return childEls.slice(startIndex, Math.min(childEls.length, startIndex + numCols));
|
|
4940
|
+
};
|
|
4941
|
+
const getVisibleVideos = () => {
|
|
4942
|
+
const slideEls = getVisibleSlideElements();
|
|
4943
|
+
const vids = [];
|
|
4944
|
+
for (const el of slideEls) {
|
|
4945
|
+
const found = el.querySelectorAll("video");
|
|
4946
|
+
found.forEach((v) => {
|
|
4947
|
+
if (!vids.includes(v)) {
|
|
4948
|
+
vids.push(v);
|
|
4949
|
+
}
|
|
4950
|
+
});
|
|
4951
|
+
}
|
|
4952
|
+
return vids;
|
|
4953
|
+
};
|
|
4954
|
+
const pauseInactiveVideos = (activeVids) => {
|
|
4955
|
+
if (!trackRef.current) return;
|
|
4956
|
+
const allVideos = Array.from(trackRef.current.querySelectorAll("video"));
|
|
4957
|
+
for (const vid of allVideos) {
|
|
4958
|
+
if (!activeVids.includes(vid)) {
|
|
4959
|
+
vid.pause();
|
|
4960
|
+
try {
|
|
4961
|
+
if (!vid.ended && vid.currentTime > 0) {
|
|
4962
|
+
vid.currentTime = 0;
|
|
4963
|
+
}
|
|
4964
|
+
} catch {
|
|
4965
|
+
}
|
|
4966
|
+
}
|
|
4967
|
+
}
|
|
4968
|
+
for (const vid of Array.from(completedVideosRef.current)) {
|
|
4969
|
+
if (!activeVids.includes(vid)) {
|
|
4970
|
+
completedVideosRef.current.delete(vid);
|
|
4971
|
+
}
|
|
4972
|
+
}
|
|
4973
|
+
};
|
|
4974
|
+
(0, import_react42.useEffect)(() => {
|
|
4975
|
+
const vids = activeVideosRef.current;
|
|
4976
|
+
if (!vids || vids.length === 0) return;
|
|
4977
|
+
for (const video of vids) {
|
|
4978
|
+
if (isPlaying) {
|
|
4979
|
+
video.play().catch(() => {
|
|
4980
|
+
});
|
|
4981
|
+
} else {
|
|
4982
|
+
video.pause();
|
|
4983
|
+
}
|
|
4984
|
+
}
|
|
4985
|
+
}, [isPlaying]);
|
|
4986
|
+
(0, import_react42.useEffect)(() => {
|
|
4987
|
+
if (!autoplay) return;
|
|
4988
|
+
let isEffectActive = true;
|
|
4989
|
+
let cleanupVideo = null;
|
|
4990
|
+
let timer = null;
|
|
4991
|
+
let observer = null;
|
|
4992
|
+
const setupVisibleVideos = (videosToPlay) => {
|
|
4993
|
+
if (!isEffectActive) return;
|
|
4994
|
+
if (timer) {
|
|
4995
|
+
clearInterval(timer);
|
|
4996
|
+
timer = null;
|
|
4997
|
+
}
|
|
4998
|
+
const allVisVideos = getVisibleVideos();
|
|
4999
|
+
pauseInactiveVideos(allVisVideos);
|
|
5000
|
+
activeVideosRef.current = videosToPlay;
|
|
5001
|
+
const pendingVideos = videosToPlay.filter((v) => !completedVideosRef.current.has(v));
|
|
5002
|
+
if (pendingVideos.length === 0) {
|
|
5003
|
+
setVideoProgress(100);
|
|
5004
|
+
nextSlideRef.current();
|
|
5005
|
+
return;
|
|
5006
|
+
}
|
|
5007
|
+
const startedVideos = /* @__PURE__ */ new Set();
|
|
5008
|
+
let hasTriggeredNext = false;
|
|
5009
|
+
const checkAllPendingEnded = () => {
|
|
5010
|
+
if (!isEffectActive || hasTriggeredNext) return;
|
|
5011
|
+
for (const vid of pendingVideos) {
|
|
5012
|
+
if (!completedVideosRef.current.has(vid)) {
|
|
5013
|
+
const hasStarted = startedVideos.has(vid);
|
|
5014
|
+
const isAtEnd = vid.ended || vid.duration > 0 && vid.currentTime >= vid.duration - 0.25;
|
|
5015
|
+
if (hasStarted && isAtEnd) {
|
|
5016
|
+
completedVideosRef.current.add(vid);
|
|
5017
|
+
}
|
|
5018
|
+
}
|
|
5019
|
+
}
|
|
5020
|
+
const allFinished = pendingVideos.every((v) => completedVideosRef.current.has(v));
|
|
5021
|
+
if (allFinished) {
|
|
5022
|
+
hasTriggeredNext = true;
|
|
5023
|
+
setVideoProgress(100);
|
|
5024
|
+
nextSlideRef.current();
|
|
5025
|
+
}
|
|
5026
|
+
};
|
|
5027
|
+
const handleTimeUpdate = () => {
|
|
5028
|
+
if (!isEffectActive || hasTriggeredNext) return;
|
|
5029
|
+
let maxDuration = 0;
|
|
5030
|
+
let activeProgress = 0;
|
|
5031
|
+
for (const v of pendingVideos) {
|
|
5032
|
+
if (v.currentTime > 0.05 || !v.paused) {
|
|
5033
|
+
startedVideos.add(v);
|
|
5034
|
+
}
|
|
5035
|
+
if (v.duration && !isNaN(v.duration) && v.duration > maxDuration) {
|
|
5036
|
+
maxDuration = v.duration;
|
|
5037
|
+
activeProgress = v.currentTime / v.duration * 100;
|
|
5038
|
+
}
|
|
5039
|
+
}
|
|
5040
|
+
if (maxDuration > 0) {
|
|
5041
|
+
setVideoProgress(Math.min(100, Math.max(0, activeProgress)));
|
|
5042
|
+
}
|
|
5043
|
+
checkAllPendingEnded();
|
|
5044
|
+
};
|
|
5045
|
+
const handleVideoEnded = (e) => {
|
|
5046
|
+
const vid = e.target;
|
|
5047
|
+
if (vid) {
|
|
5048
|
+
startedVideos.add(vid);
|
|
5049
|
+
completedVideosRef.current.add(vid);
|
|
5050
|
+
}
|
|
5051
|
+
checkAllPendingEnded();
|
|
5052
|
+
};
|
|
5053
|
+
const handlePlaying = (e) => {
|
|
5054
|
+
const vid = e.target;
|
|
5055
|
+
if (vid) {
|
|
5056
|
+
startedVideos.add(vid);
|
|
5057
|
+
}
|
|
5058
|
+
};
|
|
5059
|
+
const handleVideoError = (e) => {
|
|
5060
|
+
const vid = e.target;
|
|
5061
|
+
if (vid) {
|
|
5062
|
+
completedVideosRef.current.add(vid);
|
|
5063
|
+
}
|
|
5064
|
+
checkAllPendingEnded();
|
|
5065
|
+
};
|
|
5066
|
+
for (const vid of pendingVideos) {
|
|
5067
|
+
vid.muted = true;
|
|
5068
|
+
vid.defaultMuted = true;
|
|
5069
|
+
vid.playsInline = true;
|
|
5070
|
+
vid.loop = false;
|
|
5071
|
+
vid.removeAttribute("loop");
|
|
5072
|
+
if (vid.ended || vid.duration && vid.currentTime >= vid.duration - 0.25) {
|
|
5073
|
+
vid.currentTime = 0;
|
|
5074
|
+
}
|
|
5075
|
+
vid.addEventListener("timeupdate", handleTimeUpdate);
|
|
5076
|
+
vid.addEventListener("loadedmetadata", handleTimeUpdate);
|
|
5077
|
+
vid.addEventListener("ended", handleVideoEnded);
|
|
5078
|
+
vid.addEventListener("playing", handlePlaying);
|
|
5079
|
+
vid.addEventListener("error", handleVideoError);
|
|
5080
|
+
if (isPlayingRef.current) {
|
|
5081
|
+
vid.play().catch(() => {
|
|
5082
|
+
});
|
|
5083
|
+
} else {
|
|
5084
|
+
vid.pause();
|
|
5085
|
+
}
|
|
5086
|
+
}
|
|
5087
|
+
cleanupVideo = () => {
|
|
5088
|
+
for (const vid of pendingVideos) {
|
|
5089
|
+
vid.removeEventListener("timeupdate", handleTimeUpdate);
|
|
5090
|
+
vid.removeEventListener("loadedmetadata", handleTimeUpdate);
|
|
5091
|
+
vid.removeEventListener("ended", handleVideoEnded);
|
|
5092
|
+
vid.removeEventListener("playing", handlePlaying);
|
|
5093
|
+
vid.removeEventListener("error", handleVideoError);
|
|
5094
|
+
vid.pause();
|
|
5095
|
+
}
|
|
5096
|
+
activeVideosRef.current = [];
|
|
5097
|
+
setVideoProgress(null);
|
|
5098
|
+
};
|
|
5099
|
+
};
|
|
5100
|
+
const initialVideos = getVisibleVideos();
|
|
5101
|
+
const initialPending = initialVideos.filter((v) => !completedVideosRef.current.has(v));
|
|
5102
|
+
if (initialPending.length > 0) {
|
|
5103
|
+
setupVisibleVideos(initialPending);
|
|
5104
|
+
} else {
|
|
5105
|
+
pauseInactiveVideos([]);
|
|
5106
|
+
activeVideosRef.current = [];
|
|
5107
|
+
setVideoProgress(null);
|
|
5108
|
+
if (trackRef.current && typeof MutationObserver !== "undefined") {
|
|
5109
|
+
observer = new MutationObserver(() => {
|
|
5110
|
+
const asyncVideos = getVisibleVideos();
|
|
5111
|
+
const asyncPending = asyncVideos.filter((v) => !completedVideosRef.current.has(v));
|
|
5112
|
+
if (asyncPending.length > 0) {
|
|
5113
|
+
const hasNew = asyncPending.some((v) => !activeVideosRef.current.includes(v));
|
|
5114
|
+
if (hasNew) {
|
|
5115
|
+
if (observer) {
|
|
5116
|
+
observer.disconnect();
|
|
5117
|
+
observer = null;
|
|
5118
|
+
}
|
|
5119
|
+
setupVisibleVideos(asyncPending);
|
|
5120
|
+
}
|
|
5121
|
+
}
|
|
5122
|
+
});
|
|
5123
|
+
observer.observe(trackRef.current, { childList: true, subtree: true });
|
|
5124
|
+
}
|
|
5125
|
+
timer = setInterval(() => {
|
|
5126
|
+
const currentVids = getVisibleVideos();
|
|
5127
|
+
const currentPending = currentVids.filter((v) => !completedVideosRef.current.has(v));
|
|
5128
|
+
if (currentPending.length > 0) {
|
|
5129
|
+
clearInterval(timer);
|
|
5130
|
+
timer = null;
|
|
5131
|
+
setupVisibleVideos(currentPending);
|
|
5132
|
+
return;
|
|
5133
|
+
}
|
|
5134
|
+
if (isPlayingRef.current) {
|
|
5135
|
+
nextSlideRef.current();
|
|
5136
|
+
}
|
|
5137
|
+
}, autoplay_speed);
|
|
5138
|
+
}
|
|
5139
|
+
return () => {
|
|
5140
|
+
isEffectActive = false;
|
|
5141
|
+
if (cleanupVideo) {
|
|
5142
|
+
cleanupVideo();
|
|
5143
|
+
}
|
|
5144
|
+
if (timer) {
|
|
5145
|
+
clearInterval(timer);
|
|
5146
|
+
}
|
|
5147
|
+
if (observer) {
|
|
5148
|
+
observer.disconnect();
|
|
5149
|
+
}
|
|
5150
|
+
};
|
|
5151
|
+
}, [autoplay, autoplay_speed, currentSlide, slidesToShowState, columns]);
|
|
4952
5152
|
const handleMouseEnter = () => {
|
|
4953
5153
|
if (autoplay) {
|
|
4954
5154
|
setIsPlaying(false);
|
|
@@ -5144,7 +5344,7 @@ var init_Slider = __esm({
|
|
|
5144
5344
|
}
|
|
5145
5345
|
};
|
|
5146
5346
|
const renderProgressBar = () => {
|
|
5147
|
-
if (style === "modern" && isActive) {
|
|
5347
|
+
if ((style === "modern" || style === "cumulative") && isActive) {
|
|
5148
5348
|
const displayProgress = customProgress ?? progress;
|
|
5149
5349
|
return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
5150
5350
|
"div",
|
package/dist/server.mjs
CHANGED
|
@@ -2507,7 +2507,7 @@ var Pagination = dynamic15(() => import("./Pagination-RMAXCIL7.mjs"), { ssr: tru
|
|
|
2507
2507
|
var DataBindingControls = dynamic15(() => import("./DataBindingControls-Z2AHWFYX.mjs"), {
|
|
2508
2508
|
ssr: true
|
|
2509
2509
|
});
|
|
2510
|
-
var Slider = dynamic15(() => import("./Slider-
|
|
2510
|
+
var Slider = dynamic15(() => import("./Slider-HVBGZ6AD.mjs"), {
|
|
2511
2511
|
ssr: false
|
|
2512
2512
|
});
|
|
2513
2513
|
function toCamelCase(str) {
|