@react-hive/honey-layout 9.14.0 → 9.15.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.
@@ -13697,6 +13697,10 @@ __webpack_require__.r(__webpack_exports__);
13697
13697
  /* harmony export */ useHoneyMediaQuery: () => (/* reexport safe */ _use_honey_media_query__WEBPACK_IMPORTED_MODULE_1__.useHoneyMediaQuery),
13698
13698
  /* harmony export */ useHoneyOnChange: () => (/* reexport safe */ _use_honey_on_change__WEBPACK_IMPORTED_MODULE_0__.useHoneyOnChange),
13699
13699
  /* harmony export */ useHoneyOverlay: () => (/* reexport safe */ _use_honey_overlay__WEBPACK_IMPORTED_MODULE_6__.useHoneyOverlay),
13700
+ /* harmony export */ useHoneyResize: () => (/* reexport safe */ _use_honey_resize__WEBPACK_IMPORTED_MODULE_7__.useHoneyResize),
13701
+ /* harmony export */ useHoneySyntheticScroll: () => (/* reexport safe */ _use_honey_synthetic_scroll__WEBPACK_IMPORTED_MODULE_8__.useHoneySyntheticScroll),
13702
+ /* harmony export */ useHoneySyntheticScrollX: () => (/* reexport safe */ _use_honey_synthetic_scroll_x__WEBPACK_IMPORTED_MODULE_9__.useHoneySyntheticScrollX),
13703
+ /* harmony export */ useHoneySyntheticScrollY: () => (/* reexport safe */ _use_honey_synthetic_scroll_y__WEBPACK_IMPORTED_MODULE_10__.useHoneySyntheticScrollY),
13700
13704
  /* harmony export */ useRegisterHoneyOverlay: () => (/* reexport safe */ _use_register_honey_overlay__WEBPACK_IMPORTED_MODULE_5__.useRegisterHoneyOverlay)
13701
13705
  /* harmony export */ });
13702
13706
  /* harmony import */ var _use_honey_on_change__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./use-honey-on-change */ "./src/hooks/use-honey-on-change.ts");
@@ -13706,6 +13710,14 @@ __webpack_require__.r(__webpack_exports__);
13706
13710
  /* harmony import */ var _use_honey_layout__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./use-honey-layout */ "./src/hooks/use-honey-layout.ts");
13707
13711
  /* harmony import */ var _use_register_honey_overlay__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./use-register-honey-overlay */ "./src/hooks/use-register-honey-overlay.ts");
13708
13712
  /* harmony import */ var _use_honey_overlay__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./use-honey-overlay */ "./src/hooks/use-honey-overlay.ts");
13713
+ /* harmony import */ var _use_honey_resize__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./use-honey-resize */ "./src/hooks/use-honey-resize.ts");
13714
+ /* harmony import */ var _use_honey_synthetic_scroll__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./use-honey-synthetic-scroll */ "./src/hooks/use-honey-synthetic-scroll.ts");
13715
+ /* harmony import */ var _use_honey_synthetic_scroll_x__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./use-honey-synthetic-scroll-x */ "./src/hooks/use-honey-synthetic-scroll-x.ts");
13716
+ /* harmony import */ var _use_honey_synthetic_scroll_y__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./use-honey-synthetic-scroll-y */ "./src/hooks/use-honey-synthetic-scroll-y.ts");
13717
+
13718
+
13719
+
13720
+
13709
13721
 
13710
13722
 
13711
13723
 
@@ -14046,7 +14058,7 @@ __webpack_require__.r(__webpack_exports__);
14046
14058
  * @returns void
14047
14059
  *
14048
14060
  * @example
14049
- * ```tsx
14061
+ * ```ts
14050
14062
  * useHoneyOnChange(someValue, (newValue) => {
14051
14063
  * console.log('Value changed to:', newValue);
14052
14064
  *
@@ -14126,6 +14138,216 @@ const useHoneyOverlay = (targetOverlayId, { onKeyUp } = {}) => {
14126
14138
  };
14127
14139
 
14128
14140
 
14141
+ /***/ },
14142
+
14143
+ /***/ "./src/hooks/use-honey-resize.ts"
14144
+ /*!***************************************!*\
14145
+ !*** ./src/hooks/use-honey-resize.ts ***!
14146
+ \***************************************/
14147
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
14148
+
14149
+ "use strict";
14150
+ __webpack_require__.r(__webpack_exports__);
14151
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
14152
+ /* harmony export */ useHoneyResize: () => (/* binding */ useHoneyResize)
14153
+ /* harmony export */ });
14154
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
14155
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
14156
+ /* harmony import */ var _react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @react-hive/honey-utils */ "./node_modules/@react-hive/honey-utils/dist/index.mjs");
14157
+ /* harmony import */ var lodash_throttle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash.throttle */ "./node_modules/lodash.throttle/index.js");
14158
+ /* harmony import */ var lodash_throttle__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash_throttle__WEBPACK_IMPORTED_MODULE_2__);
14159
+
14160
+
14161
+
14162
+ /**
14163
+ * A hook that subscribes to the window `resize` event and invokes a handler function in response.
14164
+ *
14165
+ * The handler can be optionally throttled to limit execution frequency, which is useful
14166
+ * for expensive layout calculations or DOM measurements.
14167
+ *
14168
+ * @example
14169
+ * ```ts
14170
+ * useHoneyResize(() => {
14171
+ * console.log('Window resized');
14172
+ * }, { throttleTime: 200 });
14173
+ * ```
14174
+ *
14175
+ * @param handler - Callback invoked when the window is resized.
14176
+ * @param options - Configuration options controlling invocation timing and performance.
14177
+ */
14178
+ const useHoneyResize = (handler, { invokeOnMount = false, throttleTime = 0, enabled = true } = {}) => {
14179
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
14180
+ if (!enabled) {
14181
+ return;
14182
+ }
14183
+ const handleResize = throttleTime
14184
+ ? lodash_throttle__WEBPACK_IMPORTED_MODULE_2___default()(handler, throttleTime)
14185
+ : handler;
14186
+ window.addEventListener('resize', handleResize);
14187
+ if (invokeOnMount) {
14188
+ handler();
14189
+ }
14190
+ return () => {
14191
+ if ('cancel' in handleResize && (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.isFunction)(handleResize.cancel)) {
14192
+ handleResize.cancel();
14193
+ }
14194
+ window.removeEventListener('resize', handleResize);
14195
+ };
14196
+ }, [enabled, invokeOnMount, handler]);
14197
+ };
14198
+
14199
+
14200
+ /***/ },
14201
+
14202
+ /***/ "./src/hooks/use-honey-synthetic-scroll-x.ts"
14203
+ /*!***************************************************!*\
14204
+ !*** ./src/hooks/use-honey-synthetic-scroll-x.ts ***!
14205
+ \***************************************************/
14206
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
14207
+
14208
+ "use strict";
14209
+ __webpack_require__.r(__webpack_exports__);
14210
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
14211
+ /* harmony export */ useHoneySyntheticScrollX: () => (/* binding */ useHoneySyntheticScrollX)
14212
+ /* harmony export */ });
14213
+ /* harmony import */ var _use_honey_synthetic_scroll__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./use-honey-synthetic-scroll */ "./src/hooks/use-honey-synthetic-scroll.ts");
14214
+
14215
+ const useHoneySyntheticScrollX = (options) => (0,_use_honey_synthetic_scroll__WEBPACK_IMPORTED_MODULE_0__.useHoneySyntheticScroll)({
14216
+ ...options,
14217
+ axis: 'x',
14218
+ });
14219
+
14220
+
14221
+ /***/ },
14222
+
14223
+ /***/ "./src/hooks/use-honey-synthetic-scroll-y.ts"
14224
+ /*!***************************************************!*\
14225
+ !*** ./src/hooks/use-honey-synthetic-scroll-y.ts ***!
14226
+ \***************************************************/
14227
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
14228
+
14229
+ "use strict";
14230
+ __webpack_require__.r(__webpack_exports__);
14231
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
14232
+ /* harmony export */ useHoneySyntheticScrollY: () => (/* binding */ useHoneySyntheticScrollY)
14233
+ /* harmony export */ });
14234
+ /* harmony import */ var _use_honey_synthetic_scroll__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./use-honey-synthetic-scroll */ "./src/hooks/use-honey-synthetic-scroll.ts");
14235
+
14236
+ const useHoneySyntheticScrollY = (options) => (0,_use_honey_synthetic_scroll__WEBPACK_IMPORTED_MODULE_0__.useHoneySyntheticScroll)({
14237
+ ...options,
14238
+ axis: 'y',
14239
+ });
14240
+
14241
+
14242
+ /***/ },
14243
+
14244
+ /***/ "./src/hooks/use-honey-synthetic-scroll.ts"
14245
+ /*!*************************************************!*\
14246
+ !*** ./src/hooks/use-honey-synthetic-scroll.ts ***!
14247
+ \*************************************************/
14248
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
14249
+
14250
+ "use strict";
14251
+ __webpack_require__.r(__webpack_exports__);
14252
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
14253
+ /* harmony export */ useHoneySyntheticScroll: () => (/* binding */ useHoneySyntheticScroll)
14254
+ /* harmony export */ });
14255
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
14256
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
14257
+ /* harmony import */ var _react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @react-hive/honey-utils */ "./node_modules/@react-hive/honey-utils/dist/index.mjs");
14258
+ /* harmony import */ var _use_honey_drag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./use-honey-drag */ "./src/hooks/use-honey-drag.ts");
14259
+ /* harmony import */ var _use_honey_resize__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./use-honey-resize */ "./src/hooks/use-honey-resize.ts");
14260
+
14261
+
14262
+
14263
+
14264
+ /**
14265
+ * Enables synthetic scrolling for a container using pointer-based drag gestures.
14266
+ *
14267
+ * Instead of relying on native scrollbars, this hook translates the container
14268
+ * using CSS transforms in response to drag input.
14269
+ *
14270
+ * ### Key characteristics
14271
+ * - Dragging is only applied when content overflows the container on a given axis.
14272
+ * - Movement is clamped within calculated bounds, with optional overscroll allowance.
14273
+ * - Scroll position is stored purely in `transform: translate(...)`.
14274
+ * - Active transforms can be automatically cleared on window resize.
14275
+ *
14276
+ * ### Internals
14277
+ * - Uses {@link useHoneyDrag} to track mouse / touch movement.
14278
+ * - Uses {@link useHoneyResize} to optionally reset scroll state on resize.
14279
+ *
14280
+ * @template Element - The HTML element type of the scrollable container.
14281
+ *
14282
+ * @param options - Configuration controlling axes, boundaries, and lifecycle behavior.
14283
+ *
14284
+ * @returns A ref that must be attached to the scrollable container element.
14285
+ */
14286
+ const useHoneySyntheticScroll = ({ axis = 'both', availableWindowPct = 0, onStartDrag, onEndDrag, resetOnResize = true, } = {}) => {
14287
+ const scrollableContainerRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
14288
+ /**
14289
+ * Handles drag movement and applies clamped translation along the enabled axis or axes.
14290
+ *
14291
+ * For each axis:
14292
+ * - Skip processing if there is no overflow.
14293
+ * - Compute the candidate translate value from the drag delta.
14294
+ * - Clamp movement within calculated min / max bounds.
14295
+ */
14296
+ const onMoveDrag = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(scrollableContainer => async ({ deltaX, deltaY }) => {
14297
+ const { translateX, translateY } = (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.parse2DMatrix)(scrollableContainer);
14298
+ let nextX = translateX;
14299
+ let nextY = translateY;
14300
+ let handled = false;
14301
+ if (axis === 'x' || axis === 'both') {
14302
+ const overflowX = scrollableContainer.scrollWidth - scrollableContainer.clientWidth;
14303
+ if (overflowX > 0) {
14304
+ const thresholdX = scrollableContainer.clientWidth * (availableWindowPct / 100);
14305
+ const candidateX = translateX + deltaX;
14306
+ const minX = -(overflowX + thresholdX);
14307
+ const maxX = thresholdX;
14308
+ if ((deltaX < 0 && candidateX >= minX) || (deltaX > 0 && candidateX <= maxX)) {
14309
+ nextX = candidateX;
14310
+ handled = true;
14311
+ }
14312
+ }
14313
+ }
14314
+ if (axis === 'y' || axis === 'both') {
14315
+ const overflowY = scrollableContainer.scrollHeight - scrollableContainer.clientHeight;
14316
+ if (overflowY > 0) {
14317
+ const thresholdY = scrollableContainer.clientHeight * (availableWindowPct / 100);
14318
+ const candidateY = translateY + deltaY;
14319
+ const minY = -(overflowY + thresholdY);
14320
+ const maxY = thresholdY;
14321
+ if ((deltaY < 0 && candidateY >= minY) || (deltaY > 0 && candidateY <= maxY)) {
14322
+ nextY = candidateY;
14323
+ handled = true;
14324
+ }
14325
+ }
14326
+ }
14327
+ // Apply transform only when at least one axis was updated
14328
+ if (handled) {
14329
+ scrollableContainer.style.transform = `translate(${nextX}px, ${nextY}px)`;
14330
+ }
14331
+ return handled;
14332
+ }, [availableWindowPct]);
14333
+ (0,_use_honey_drag__WEBPACK_IMPORTED_MODULE_2__.useHoneyDrag)(scrollableContainerRef, {
14334
+ onStartDrag,
14335
+ onMoveDrag,
14336
+ onEndDrag,
14337
+ });
14338
+ const resizeHandler = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(() => {
14339
+ const scrollableContainer = scrollableContainerRef.current;
14340
+ if (scrollableContainer) {
14341
+ scrollableContainer.style.removeProperty('transform');
14342
+ }
14343
+ }, []);
14344
+ (0,_use_honey_resize__WEBPACK_IMPORTED_MODULE_3__.useHoneyResize)(resizeHandler, {
14345
+ enabled: resetOnResize,
14346
+ });
14347
+ return scrollableContainerRef;
14348
+ };
14349
+
14350
+
14129
14351
  /***/ },
14130
14352
 
14131
14353
  /***/ "./src/hooks/use-register-honey-overlay.ts"
@@ -14889,6 +15111,10 @@ __webpack_require__.r(__webpack_exports__);
14889
15111
  /* harmony export */ useHoneyOverlay: () => (/* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_5__.useHoneyOverlay),
14890
15112
  /* harmony export */ useHoneyPopup: () => (/* reexport safe */ _components__WEBPACK_IMPORTED_MODULE_3__.useHoneyPopup),
14891
15113
  /* harmony export */ useHoneyPopupContext: () => (/* reexport safe */ _components__WEBPACK_IMPORTED_MODULE_3__.useHoneyPopupContext),
15114
+ /* harmony export */ useHoneyResize: () => (/* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_5__.useHoneyResize),
15115
+ /* harmony export */ useHoneySyntheticScroll: () => (/* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_5__.useHoneySyntheticScroll),
15116
+ /* harmony export */ useHoneySyntheticScrollX: () => (/* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_5__.useHoneySyntheticScrollX),
15117
+ /* harmony export */ useHoneySyntheticScrollY: () => (/* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_5__.useHoneySyntheticScrollY),
14892
15118
  /* harmony export */ useRegisterHoneyOverlay: () => (/* reexport safe */ _hooks__WEBPACK_IMPORTED_MODULE_5__.useRegisterHoneyOverlay)
14893
15119
  /* harmony export */ });
14894
15120
  /* harmony import */ var _react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @react-hive/honey-style */ "@react-hive/honey-style");