@react-hive/honey-layout 17.6.0 → 17.8.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.
@@ -4118,7 +4118,11 @@ __webpack_require__.r(__webpack_exports__);
4118
4118
  * - `centerX`, `centerY` → axis-aware centering helpers
4119
4119
  *
4120
4120
  * Semantic helpers exist purely for convenience and readability.
4121
- * Any explicitly provided style props **always take precedence**.
4121
+ *
4122
+ * Precedence rules:
4123
+ * - `inline` takes precedence over `$display`
4124
+ * - `$flexDirection` takes precedence over `row`
4125
+ * - `$alignItems` and `$justifyContent` take precedence over centering helpers
4122
4126
  *
4123
4127
  * ---
4124
4128
  *
@@ -4139,7 +4143,7 @@ __webpack_require__.r(__webpack_exports__);
4139
4143
  *
4140
4144
  * @example Horizontal layout
4141
4145
  * ```tsx
4142
- * <HoneyFlex $gap={2} row/>
4146
+ * <HoneyFlex $gap={2} row />
4143
4147
  * ```
4144
4148
  *
4145
4149
  * @example Column layout
@@ -4157,9 +4161,10 @@ __webpack_require__.r(__webpack_exports__);
4157
4161
  const HoneyFlex = (0,_react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__.styled)((0,_HoneyBox__WEBPACK_IMPORTED_MODULE_3__.HoneyBox), ({ inline = false, row = false, center = false, centerX = false, centerY = false, $display, $flexDirection, $alignItems, $justifyContent, ...props }) => {
4158
4162
  const display = inline ? 'inline-flex' : ($display ?? 'flex');
4159
4163
  const flexDirection = $flexDirection ?? (row ? 'row' : 'column');
4160
- const isRow = flexDirection === 'row';
4161
- const shouldCenterAlignItems = center || (isRow ? centerY : centerX);
4162
- const shouldCenterJustifyContent = center || (isRow ? centerX : centerY);
4164
+ const isRowDirection = flexDirection === 'row' || flexDirection === 'row-reverse';
4165
+ const isColumnDirection = flexDirection === 'column' || flexDirection === 'column-reverse';
4166
+ const shouldCenterAlignItems = center || (isRowDirection ? centerY : isColumnDirection ? centerX : false);
4167
+ const shouldCenterJustifyContent = center || (isRowDirection ? centerX : isColumnDirection ? centerY : false);
4163
4168
  const alignItems = $alignItems ?? (shouldCenterAlignItems ? 'center' : undefined);
4164
4169
  const justifyContent = $justifyContent ?? (shouldCenterJustifyContent ? 'center' : undefined);
4165
4170
  if (_constants__WEBPACK_IMPORTED_MODULE_1__.__DEV__) {
@@ -4169,9 +4174,9 @@ const HoneyFlex = (0,_react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__.styled
4169
4174
  (0,_utils__WEBPACK_IMPORTED_MODULE_2__.warnOnce)(`HoneyFlex:${hasAlignConflict}:${hasJustifyConflict}`, [
4170
4175
  '[@react-hive/honey-layout]: HoneyFlex.',
4171
4176
  'Semantic centering props conflict with explicit flex alignment styles:',
4172
- hasAlignConflict && ` - align-items is controlled by both semantics and $alignItems`,
4177
+ hasAlignConflict && ' - align-items is controlled by both semantics and $alignItems',
4173
4178
  hasJustifyConflict &&
4174
- ` - justify-content is controlled by both semantics and $justifyContent`,
4179
+ ' - justify-content is controlled by both semantics and $justifyContent',
4175
4180
  'Explicit styles always win. Remove one side to silence this warning.',
4176
4181
  ]
4177
4182
  .filter(Boolean)
@@ -5979,32 +5984,35 @@ __webpack_require__.r(__webpack_exports__);
5979
5984
  * It can also subscribe to overlay-level events, such as `keyup`, for the matched overlay.
5980
5985
  *
5981
5986
  * @param targetOverlayId - The ID of the active overlay to find.
5982
- * @param options - Optional overlay event handlers.
5987
+ * @param options - Optional configuration for resolving the overlay and attaching event handlers.
5983
5988
  *
5984
- * @returns The matching active overlay instance, or `undefined` when the overlay is not registered.
5989
+ * @returns The matching active overlay instance, or `null` when the hook is disabled
5990
+ * or the overlay is not currently registered.
5985
5991
  *
5986
5992
  * @remarks
5987
5993
  * - The hook only works with overlays that are currently active.
5988
- * - If the overlay is inactive, unregistered, or already removed from the stack, `undefined` is returned.
5989
- * - The `onKeyUp` listener is attached only to the matched overlay.
5990
- * - Event listeners are automatically cleaned up when the overlay, handler, or component lifecycle changes.
5994
+ * - If `enabled` is `false`, the hook returns `null` and does not attach listeners.
5995
+ * - If the overlay is inactive, unregistered, or already removed from the stack, `null` is returned.
5996
+ * - The `onKeyUp` listener is attached only to the matched overlay while the hook is enabled.
5997
+ * - Event listeners are automatically cleaned up when the overlay, handler, enabled state,
5998
+ * or component lifecycle changes.
5991
5999
  *
5992
6000
  * @example
5993
6001
  * ```tsx
5994
6002
  * const overlay = useHoneyOverlay('my-overlay-id', {
6003
+ * enabled: isOpen,
5995
6004
  * onKeyUp: (keyCode, overlay, e) => {
5996
6005
  * if (keyCode === 'Escape') {
5997
- * //
6006
+ * // Handle Escape key.
5998
6007
  * }
5999
6008
  * },
6000
6009
  * });
6001
6010
  * ```
6002
6011
  */
6003
- const useHoneyOverlay = (targetOverlayId, { onKeyUp } = {}) => {
6012
+ const useHoneyOverlay = (targetOverlayId, { enabled = true, onKeyUp } = {}) => {
6004
6013
  const { overlays } = (0,_hooks__WEBPACK_IMPORTED_MODULE_1__.useHoneyLayout)();
6005
- const overlay = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => overlays.find(overlay => overlay.id === targetOverlayId), [overlays, targetOverlayId]);
6014
+ const overlay = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => (enabled ? (overlays.find(overlay => overlay.id === targetOverlayId) ?? null) : null), [enabled, overlays, targetOverlayId]);
6006
6015
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
6007
- // If no overlay is found or no `onKeyUp` handler is provided, skip setting up the listener
6008
6016
  if (!overlay || !onKeyUp) {
6009
6017
  return;
6010
6018
  }