oolib 2.96.0 → 2.97.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.
@@ -31,6 +31,7 @@ var calcAspectRatio_1 = require("../../../ImageEditor/utils/calcAspectRatio");
31
31
  var themes_1 = require("../../../../../../themes");
32
32
  var icons_1 = require("../../../../../../icons");
33
33
  var Typo_1 = require("../../../../../Typo");
34
+ var useSwipe_1 = require("../../../../../../utils/customHooks/useSwipe");
34
35
  var greyColor80 = themes_1.colors.greyColor80;
35
36
  var CaretLeft = icons_1.icons.CaretLeft, CaretRight = icons_1.icons.CaretRight;
36
37
  var SliderShell = function (_a) {
@@ -41,7 +42,16 @@ var SliderShell = function (_a) {
41
42
  (0, react_1.useEffect)(function () {
42
43
  setImageMinusCaptionHeight(wrapperRef.current.clientWidth / (0, calcAspectRatio_1.calcAspectRatio)(aspectRatio));
43
44
  }, []);
44
- return (react_1.default.createElement(styled_1.StyledFlexWrapper, { ref: wrapperRef },
45
+ var isTouchDevice = (0, react_1.useRef)('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0);
46
+ var handleDragStart = (0, useSwipe_1.useSwipe)({
47
+ isTouchDevice: isTouchDevice,
48
+ onSlide: function (direction) {
49
+ setActiveIdx(function (prevIdx) {
50
+ return direction === 'right' ? (prevIdx < value.length - 1 ? prevIdx + 1 : 0) : (prevIdx > 0 ? prevIdx - 1 : value.length - 1);
51
+ });
52
+ },
53
+ }).handleDragStart;
54
+ return (react_1.default.createElement(styled_1.StyledFlexWrapper, { ref: wrapperRef, onTouchStart: handleDragStart, onMouseDown: handleDragStart },
45
55
  value.map(function (v, idx) { return (react_1.default.createElement(styled_1.StyledFlexItem, { key: (v === null || v === void 0 ? void 0 : v.publicUrl) || idx, marginLeft: idx === 0 && activeIdx * -100 + "%" }, render(v, idx) /* explicitly called, cuz we want an error to throw if render prop aint passed thru */)); }),
46
56
  !isLoading && value.length > 1 && !imageUnderEdit && react_1.default.createElement(react_1.Fragment, null,
47
57
  react_1.default.createElement(styled_1.StyledCaretLeft, { onClick: function () {
@@ -88,7 +88,15 @@ var Modal = function (_a) {
88
88
  ? react_1.default.createElement(Buttons_1.ButtonPrimary, { onClick: onConfirm }, onConfirmText) // In some cases we want to pass button directly to the component as prop
89
89
  : onConfirm,
90
90
  showCloseBtn && react_1.default.createElement(Buttons_1.ButtonGhost, { onClick: onClose }, onCloseText)))))); };
91
- return ((0, react_dom_1.createPortal)(react_1.default.createElement(styled_1.StyledModalLargeBg, null,
91
+ var _o = (0, react_1.useState)(window.visualViewport.height), screenHeight = _o[0], setScreenHeight = _o[1];
92
+ (0, react_1.useEffect)(function () {
93
+ window.addEventListener('resize', setScreenHeight(window.visualViewport.height));
94
+ return function () {
95
+ window.removeEventListener('resize', setScreenHeight(window.visualViewport.height));
96
+ };
97
+ }, []);
98
+ var isKeyboardOpen = window.visualViewport.height < screenHeight;
99
+ return ((0, react_dom_1.createPortal)(react_1.default.createElement(styled_1.StyledModalLargeBg, { style: { height: isKeyboardOpen ? 'auto' : '100svh', overflow: 'hidden' } },
92
100
  react_1.default.createElement(styled_1.StyledModalLargeBgColor, { initial: { opacity: initAnimPos.opacity }, animate: { opacity: animPos.opacity }, transition: {
93
101
  type: "tween",
94
102
  ease: "easeOut",
package/dist/index.d.ts CHANGED
@@ -31,7 +31,7 @@ export { ModalConfirm } from "./components/Modals/ModalConfirm";
31
31
  export { ModalForms } from "./components/Modals/derivedComps/ModalForms";
32
32
  export { Modal } from "./components/Modals/Modal";
33
33
  export { ModalSmall } from "./components/Modals/derivedComps/ModalSmall";
34
- export { EmptyStates } from "./components/EmptyStates2";
34
+ export { EmptyStates } from "./components/EmptyStates";
35
35
  export { HomeCover } from "./components/HomeCover";
36
36
  export { PageScrollIndicator } from "./components/PageScrollIndicator";
37
37
  export { BarChart } from "./components/dataViz/comps/BarChart";
package/dist/index.js CHANGED
@@ -76,8 +76,8 @@ var Modal_1 = require("./components/Modals/Modal");
76
76
  Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return Modal_1.Modal; } });
77
77
  var ModalSmall_1 = require("./components/Modals/derivedComps/ModalSmall");
78
78
  Object.defineProperty(exports, "ModalSmall", { enumerable: true, get: function () { return ModalSmall_1.ModalSmall; } });
79
- var EmptyStates2_1 = require("./components/EmptyStates2");
80
- Object.defineProperty(exports, "EmptyStates", { enumerable: true, get: function () { return EmptyStates2_1.EmptyStates; } });
79
+ var EmptyStates_1 = require("./components/EmptyStates");
80
+ Object.defineProperty(exports, "EmptyStates", { enumerable: true, get: function () { return EmptyStates_1.EmptyStates; } });
81
81
  var HomeCover_1 = require("./components/HomeCover");
82
82
  Object.defineProperty(exports, "HomeCover", { enumerable: true, get: function () { return HomeCover_1.HomeCover; } });
83
83
  var PageScrollIndicator_1 = require("./components/PageScrollIndicator");
@@ -45,6 +45,7 @@ export namespace colors {
45
45
  export { lightPink };
46
46
  export { pinkHighlight };
47
47
  export { blueHighlight };
48
+ export { yellowHighlight };
48
49
  export { annoPink };
49
50
  export { annoBlue };
50
51
  }
@@ -94,6 +95,7 @@ declare const cyan: "#B5F2FA";
94
95
  declare const lightPink: "#FFE5F2";
95
96
  declare const pinkHighlight: "#FF9AF4";
96
97
  declare const blueHighlight: "#52E2EE";
98
+ declare const yellowHighlight: "#FFE600";
97
99
  declare const annoPink: "#FF91F4";
98
100
  declare const annoBlue: "#52E2EE";
99
101
  export {};
@@ -48,6 +48,7 @@ var disabledShadowColor = greyColor70;
48
48
  // Highlight colors used in RTE
49
49
  var pinkHighlight = '#FF9AF4';
50
50
  var blueHighlight = '#52E2EE';
51
+ var yellowHighlight = "#FFE600";
51
52
  // annotation RTE Colors
52
53
  var annoPink = '#FF91F4';
53
54
  var annoBlue = '#52E2EE';
@@ -98,6 +99,7 @@ exports.colors = {
98
99
  lightPink: lightPink,
99
100
  pinkHighlight: pinkHighlight,
100
101
  blueHighlight: blueHighlight,
102
+ yellowHighlight: yellowHighlight,
101
103
  annoPink: annoPink,
102
- annoBlue: annoBlue
104
+ annoBlue: annoBlue,
103
105
  };
@@ -0,0 +1,6 @@
1
+ export function useSwipe({ isTouchDevice, onSlide }: {
2
+ isTouchDevice: any;
3
+ onSlide: any;
4
+ }): {
5
+ handleDragStart: (e: any) => void;
6
+ };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSwipe = void 0;
4
+ var react_1 = require("react");
5
+ // A custom hook for handling swipe gestures.
6
+ var useSwipe = function (_a) {
7
+ var isTouchDevice = _a.isTouchDevice, onSlide = _a.onSlide;
8
+ var isSliding = (0, react_1.useRef)(false); // A reference to track if sliding is happening or not.
9
+ var dragStartX = (0, react_1.useRef)(null); // A reference to track the start position of the drag.
10
+ var dragDistance = (0, react_1.useRef)(0); // A reference to track the distance of the drag.
11
+ //Handles the start of the drag gesture.
12
+ var handleDragStart = function (e) {
13
+ e.preventDefault();
14
+ // Set the initial drag start position
15
+ dragStartX.current = isTouchDevice.current ? e.touches[0].clientX : e.clientX;
16
+ // Reset the drag distance
17
+ dragDistance.current = 0;
18
+ // Set the sliding flag to false
19
+ isSliding.current = false;
20
+ // Add event listeners for touch or mouse move and end events
21
+ if (isTouchDevice.current) {
22
+ document.body.addEventListener('touchmove', handleDragMove, { passive: false });
23
+ document.body.addEventListener('touchend', handleDragEnd);
24
+ }
25
+ else {
26
+ document.body.addEventListener('mousemove', handleDragMove);
27
+ document.body.addEventListener('mouseup', handleDragEnd);
28
+ }
29
+ };
30
+ //Handles the move of the drag gesture.
31
+ var handleDragMove = function (e) {
32
+ // Get the clientX value based on the device type
33
+ var clientX = isTouchDevice.current ? e.touches[0].clientX : e.clientX;
34
+ // Calculate the drag distance
35
+ dragDistance.current = clientX - dragStartX.current;
36
+ // Check if sliding is happening
37
+ if (Math.abs(dragDistance.current) > 20 && !isSliding.current) {
38
+ // Determine the direction of the slide
39
+ var direction = dragDistance.current > 0 ? 'left' : 'right';
40
+ // Call the onSlide function with the direction
41
+ onSlide(direction);
42
+ // Reset the drag start position and distance
43
+ dragStartX.current = clientX;
44
+ dragDistance.current = 0;
45
+ // Set the sliding flag
46
+ isSliding.current = true;
47
+ }
48
+ };
49
+ // Handles the end of the drag gesture.
50
+ var handleDragEnd = function () {
51
+ // Remove event listeners based on device type
52
+ if (isTouchDevice.current) {
53
+ document.body.removeEventListener('touchmove', handleDragMove);
54
+ document.body.removeEventListener('touchend', handleDragEnd);
55
+ }
56
+ else {
57
+ document.body.removeEventListener('mousemove', handleDragMove);
58
+ document.body.removeEventListener('mouseup', handleDragEnd);
59
+ }
60
+ // Reset drag start coordinates, drag distance, and sliding flag
61
+ dragStartX.current = null;
62
+ dragDistance.current = 0;
63
+ isSliding.current = false;
64
+ };
65
+ return {
66
+ handleDragStart: handleDragStart,
67
+ };
68
+ };
69
+ exports.useSwipe = useSwipe;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.96.0",
3
+ "version": "2.97.0",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",