@rpg-engine/long-bow 0.5.71 → 0.5.73

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.
@@ -10,6 +10,7 @@ import Draggable from 'react-draggable';
10
10
  import ReactDOM from 'react-dom';
11
11
  import { camelCase } from 'lodash-es';
12
12
  import { observer } from 'mobx-react-lite';
13
+ import { Capacitor } from '@capacitor/core';
13
14
  import { AiFillCaretRight } from 'react-icons/ai';
14
15
  import 'rpgui/rpgui.css';
15
16
  import 'rpgui/rpgui.min.js';
@@ -16010,8 +16011,15 @@ var CloseButton$3 = /*#__PURE__*/styled.div.withConfig({
16010
16011
  componentId: "sc-jl6f8-4"
16011
16012
  })(["position:absolute;top:3px;right:0px;color:white;z-index:22;font-size:1.5rem;@media (max-width:950px){font-size:1.7rem;padding:12px;}"]);
16012
16013
 
16014
+ var getTransformedBasePath = function getTransformedBasePath(basePath) {
16015
+ if (Capacitor.isNativePlatform()) {
16016
+ return Capacitor.convertFileSrc(basePath);
16017
+ }
16018
+ return basePath;
16019
+ };
16013
16020
  var SimpleImageCarousel = function SimpleImageCarousel(_ref) {
16014
- var images = _ref.images,
16021
+ var basePath = _ref.basePath,
16022
+ imagesSrc = _ref.imagesSrc,
16015
16023
  styles = _ref.styles,
16016
16024
  _ref$autoCycle = _ref.autoCycle,
16017
16025
  autoCycle = _ref$autoCycle === void 0 ? false : _ref$autoCycle,
@@ -16022,40 +16030,42 @@ var SimpleImageCarousel = function SimpleImageCarousel(_ref) {
16022
16030
  var _useState = useState(0),
16023
16031
  currentImage = _useState[0],
16024
16032
  setCurrentImage = _useState[1];
16025
- var autoCycleId = useRef(null);
16026
- var handleLeftClick = function handleLeftClick() {
16027
- setCurrentImage(function (prevImage) {
16028
- return (prevImage - 1 + (images == null ? void 0 : images.length)) % (images == null ? void 0 : images.length);
16029
- });
16030
- if (stopAutoCyclingOnInteraction && autoCycleId.current) {
16031
- clearInterval(autoCycleId.current);
16032
- autoCycleId.current = null;
16033
- }
16034
- };
16035
- var handleRightClick = function handleRightClick() {
16036
- setCurrentImage(function (prevImage) {
16037
- return (prevImage + 1) % (images == null ? void 0 : images.length);
16038
- });
16039
- if (stopAutoCyclingOnInteraction && autoCycleId.current) {
16040
- clearInterval(autoCycleId.current);
16041
- autoCycleId.current = null;
16042
- }
16043
- };
16033
+ var isInteracted = useRef(false);
16044
16034
  useEffect(function () {
16045
- if (autoCycle) {
16046
- autoCycleId.current = setInterval(function () {
16047
- setCurrentImage(function (prevImage) {
16048
- return (prevImage + 1) % (images == null ? void 0 : images.length);
16049
- });
16035
+ var timer = null;
16036
+ if (autoCycle && !isInteracted.current) {
16037
+ timer = setInterval(function () {
16038
+ if (stopAutoCyclingOnInteraction && isInteracted.current) {
16039
+ clearInterval(timer);
16040
+ return;
16041
+ }
16042
+ handleRightClick(true);
16050
16043
  }, autoCycleDelay);
16051
16044
  }
16052
16045
  return function () {
16053
- if (autoCycleId.current) {
16054
- clearInterval(autoCycleId.current);
16046
+ if (timer) {
16047
+ clearInterval(timer);
16055
16048
  }
16056
16049
  };
16057
- }, [autoCycle, autoCycleDelay, images == null ? void 0 : images.length]);
16058
- var hasMoreThanOneImage = (images == null ? void 0 : images.length) > 1;
16050
+ }, [autoCycle, autoCycleDelay]);
16051
+ var handleLeftClick = function handleLeftClick() {
16052
+ isInteracted.current = true;
16053
+ setCurrentImage(function (oldImage) {
16054
+ return oldImage === 0 ? imagesSrc.length - 1 : oldImage - 1;
16055
+ });
16056
+ };
16057
+ var handleRightClick = function handleRightClick(isAutomatedClick) {
16058
+ if (isAutomatedClick === void 0) {
16059
+ isAutomatedClick = false;
16060
+ }
16061
+ if (!isAutomatedClick) {
16062
+ isInteracted.current = true;
16063
+ }
16064
+ setCurrentImage(function (oldImage) {
16065
+ return oldImage === imagesSrc.length - 1 ? 0 : oldImage + 1;
16066
+ });
16067
+ };
16068
+ var hasMoreThanOneImage = imagesSrc.length > 1;
16059
16069
  return React.createElement(ImageContainer, {
16060
16070
  style: styles
16061
16071
  }, hasMoreThanOneImage && React.createElement(CustomLeftArrow, {
@@ -16066,14 +16076,14 @@ var SimpleImageCarousel = function SimpleImageCarousel(_ref) {
16066
16076
  onPointerDown: handleRightClick
16067
16077
  }), React.createElement(Carousel, null, React.createElement(FadeInCarouselImg, {
16068
16078
  key: currentImage,
16069
- src: images == null ? void 0 : images[currentImage],
16070
- alt: "Image " + currentImage
16079
+ src: getTransformedBasePath(basePath) + "/" + imagesSrc[currentImage],
16080
+ alt: imagesSrc[currentImage]
16071
16081
  })));
16072
16082
  };
16073
16083
  var ImageContainer = /*#__PURE__*/styled.div.withConfig({
16074
16084
  displayName: "SimpleImageCarousel__ImageContainer",
16075
16085
  componentId: "sc-gdvbly-0"
16076
- })(["flex:1;display:flex;justify-content:center;align-items:center;height:100%;margin-right:0.5rem;max-width:400px;position:relative;width:400px;"]);
16086
+ })(["flex:1;display:flex;justify-content:center;align-items:center;height:100%;margin-right:0.5rem;max-width:400px;position:relative;"]);
16077
16087
  var CustomLeftArrow = /*#__PURE__*/styled(SelectArrow).withConfig({
16078
16088
  displayName: "SimpleImageCarousel__CustomLeftArrow",
16079
16089
  componentId: "sc-gdvbly-1"