@react-hive/honey-layout 17.1.0 → 17.3.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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @deprecated Please, use import from `@react-hive/honey-style`
3
3
  */
4
- declare const resolveSpacing: <Value extends import("@react-hive/honey-style").HoneyCssSpacingValue, Unit extends import("@react-hive/honey-style").Nullable<import("@react-hive/honey-style").HoneyCssDimensionUnit> = "px">(value: Value, unit?: Unit, type?: keyof import("@react-hive/honey-style").HoneySpacings) => ((context: import("@react-hive/honey-style").HoneyStyledContext<object>) => import("@react-hive/honey-style").HoneyResolveSpacingResult<Value, Unit>);
4
+ declare const resolveSpacing: <Value extends import("@react-hive/honey-style").HoneyCssSpacingValue, Unit extends import("@react-hive/honey-style").Nullable<import("@react-hive/honey-css").HoneyCssDimensionUnit> = "px">(value: Value, unit?: Unit, type?: keyof import("@react-hive/honey-style").HoneySpacings) => ((context: import("@react-hive/honey-style").HoneyStyledContext<object>) => import("@react-hive/honey-style").HoneyResolveSpacingResult<Value, Unit>);
5
5
  export { resolveSpacing };
6
6
  export * from './constants';
7
7
  export * from './types';
@@ -4606,7 +4606,7 @@ __webpack_require__.r(__webpack_exports__);
4606
4606
  */
4607
4607
  const useHoneyLayerRegistryContext = () => {
4608
4608
  const context = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_HoneyLayerRegistryContext__WEBPACK_IMPORTED_MODULE_2__.HoneyLayerRegistryContext);
4609
- (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.assert)(context, 'The `useHoneyLayerRegistryContext()` hook can only be used inside <HoneyLayerRegistry/> component!');
4609
+ (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.assert)(context, '[@react-hive/honey-layout]: The `useHoneyLayerRegistryContext()` hook can only be used inside <HoneyLayerRegistry/> component.');
4610
4610
  return context;
4611
4611
  };
4612
4612
 
@@ -5108,7 +5108,7 @@ __webpack_require__.r(__webpack_exports__);
5108
5108
 
5109
5109
  const useHoneyPopupContext = () => {
5110
5110
  const context = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_components__WEBPACK_IMPORTED_MODULE_2__.HoneyPopupContext);
5111
- (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.assert)(context, 'The `useHoneyPopupContext()` hook can only be used inside <HoneyPopup/> component!');
5111
+ (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.assert)(context, '[@react-hive/honey-layout]: The `useHoneyPopupContext()` hook can only be used inside <HoneyPopup/> component.');
5112
5112
  return context;
5113
5113
  };
5114
5114
 
@@ -5460,10 +5460,12 @@ __webpack_require__.r(__webpack_exports__);
5460
5460
  "use strict";
5461
5461
  __webpack_require__.r(__webpack_exports__);
5462
5462
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5463
+ /* harmony export */ HONEY_LAYOUT_CSS_PROPERTY_PREFIX: () => (/* binding */ HONEY_LAYOUT_CSS_PROPERTY_PREFIX),
5463
5464
  /* harmony export */ __DEV__: () => (/* binding */ __DEV__)
5464
5465
  /* harmony export */ });
5465
5466
  const ENV = "development" || 0;
5466
5467
  const __DEV__ = ENV !== 'production';
5468
+ const HONEY_LAYOUT_CSS_PROPERTY_PREFIX = '$';
5467
5469
  if (__DEV__ && typeof window !== 'undefined' && !process.env.VITEST_WORKER_ID) {
5468
5470
  console.info('[@react-hive/honey-layout]: You are running in development mode. ' +
5469
5471
  'This build is not optimized for production and may include extra checks or logs.');
@@ -5567,37 +5569,21 @@ __webpack_require__.r(__webpack_exports__);
5567
5569
  /* harmony import */ var _react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @react-hive/honey-style */ "@react-hive/honey-style");
5568
5570
  /* harmony import */ var _react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__);
5569
5571
  /* harmony import */ var _react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @react-hive/honey-utils */ "./node_modules/.pnpm/@react-hive+honey-utils@4.0.0/node_modules/@react-hive/honey-utils/dist/index.mjs");
5572
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../constants */ "./src/constants.ts");
5573
+
5570
5574
 
5571
5575
 
5572
5576
  /**
5573
- * Type guard function that checks whether a given CSS property name
5574
- * is classified as a spacing-related property.
5575
- *
5576
- * Spacing properties include margin, padding, positional offsets,
5577
- * and layout gaps (e.g., `gap`, `top`, `marginLeft`, etc.).
5578
- *
5579
- * @param propertyName - The name of the CSS property to check.
5580
- *
5581
- * @returns `true` if the property is a spacing property, otherwise `false`.
5582
- */
5583
- const isSpacingCssProperty = (propertyName) => _react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__.CSS_SPACING_PROPERTIES.includes(propertyName);
5584
- /**
5585
- * Type guard function to check if a property name is a color property.
5586
- *
5587
- * @param propertyName - The name of the CSS property.
5577
+ * Determines whether a property name uses the configured CSS property prefix.
5588
5578
  *
5589
- * @returns True if the property name is a color property, false otherwise.
5590
- */
5591
- const isColorCssProperty = (propertyName) => _react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__.CSS_COLOR_PROPERTIES.includes(propertyName);
5592
- /**
5593
- * Determines if a given HTML property is a CSS property that is prefixed with a '$'.
5594
- * This convention is typically used for applying dynamic or responsive styles.
5579
+ * This helper is prefix-agnostic by design. The actual prefix is defined by
5580
+ * `HONEY_LAYOUT_CSS_PROPERTY_PREFIX`, which currently uses `$` for honey-layout CSS props.
5595
5581
  *
5596
- * @param propertyName - The HTML property or key to check.
5582
+ * @param propertyName - The property name to check.
5597
5583
  *
5598
- * @returns Returns true if the property is a valid prefixed CSS property, otherwise false.
5584
+ * @returns Returns true if the property name starts with the configured CSS property prefix.
5599
5585
  */
5600
- const is$PrefixedCssProperty = (propertyName) => propertyName[0] === '$';
5586
+ const isPrefixedCssProperty = (propertyName) => propertyName[0] === _constants__WEBPACK_IMPORTED_MODULE_2__.HONEY_LAYOUT_CSS_PROPERTY_PREFIX;
5601
5587
  /**
5602
5588
  * Retrieves the CSS property value for a specific breakpoint, potentially resolving it to include units.
5603
5589
  *
@@ -5626,12 +5612,12 @@ const getCssPropertyValue = (propertyName, propertyValue, breakpoint) => {
5626
5612
  if (resolvedValue === undefined) {
5627
5613
  return undefined;
5628
5614
  }
5629
- if (isSpacingCssProperty(propertyName)) {
5615
+ if ((0,_react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__.isCssSpacingProperty)(propertyName)) {
5630
5616
  if (typeof resolvedValue === 'number' || Array.isArray(resolvedValue)) {
5631
5617
  return (0,_react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__.resolveSpacing)(resolvedValue, 'px');
5632
5618
  }
5633
5619
  }
5634
- else if (isColorCssProperty(propertyName)) {
5620
+ else if ((0,_react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__.isCssColorProperty)(propertyName)) {
5635
5621
  if (typeof resolvedValue === 'string' && (0,_react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__.isThemeColorValue)(resolvedValue)) {
5636
5622
  return (0,_react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__.resolveColor)(resolvedValue);
5637
5623
  }
@@ -5649,7 +5635,7 @@ const getCssPropertyValue = (propertyName, propertyValue, breakpoint) => {
5649
5635
  * @returns An array of tuples where each tuple contains a Honey-prefixed CSS property and its value.
5650
5636
  */
5651
5637
  const matchCssProperties = (props, breakpoint) => Object.entries(props).filter(([propertyName, propertyValue]) => {
5652
- const isMatchingXsBreakpoint = breakpoint === 'xs' && is$PrefixedCssProperty(propertyName);
5638
+ const isMatchingXsBreakpoint = breakpoint === 'xs' && isPrefixedCssProperty(propertyName);
5653
5639
  return (isMatchingXsBreakpoint ||
5654
5640
  (propertyValue && typeof propertyValue === 'object' && breakpoint in propertyValue));
5655
5641
  });
@@ -5667,7 +5653,7 @@ const matchCssProperties = (props, breakpoint) => Object.entries(props).filter((
5667
5653
  */
5668
5654
  const createStyles = (breakpoint) => ({ theme, ...props }) => (0,_react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__.css) `
5669
5655
  ${matchCssProperties(props, breakpoint).map(([prefixedPropertyName, propertyValue]) => {
5670
- const propertyName = prefixedPropertyName.slice(1);
5656
+ const propertyName = prefixedPropertyName.slice(_constants__WEBPACK_IMPORTED_MODULE_2__.HONEY_LAYOUT_CSS_PROPERTY_PREFIX.length);
5671
5657
  return (0,_react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__.css) `
5672
5658
  ${(0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.camelToDashCase)(propertyName)}: ${getCssPropertyValue(propertyName, propertyValue, breakpoint)};
5673
5659
  `;
@@ -5683,7 +5669,7 @@ const createStyles = (breakpoint) => ({ theme, ...props }) => (0,_react_hive_hon
5683
5669
  *
5684
5670
  * @returns Returns true if at least one property in `props` has styles for the specified breakpoint; otherwise, false.
5685
5671
  */
5686
- const hasBreakpointStyles = (breakpoint, props) => Object.entries(props).some(([propertyName, propertyValue]) => is$PrefixedCssProperty(propertyName) &&
5672
+ const hasBreakpointStyles = (breakpoint, props) => Object.entries(props).some(([propertyName, propertyValue]) => isPrefixedCssProperty(propertyName) &&
5687
5673
  typeof propertyValue === 'object' &&
5688
5674
  breakpoint in propertyValue);
5689
5675
  /**
@@ -5700,7 +5686,9 @@ const hasBreakpointStyles = (breakpoint, props) => Object.entries(props).some(([
5700
5686
  */
5701
5687
  const applyBreakpointStyles = (breakpoint) => ({ theme, ...props }) => {
5702
5688
  const breakpointConfig = theme.breakpoints[breakpoint];
5703
- if (!breakpointConfig || !hasBreakpointStyles(breakpoint, props)) {
5689
+ (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.assert)(breakpointConfig, `[@react-hive/honey-layout]: Missing breakpoint configuration for "${breakpoint}". ` +
5690
+ `Expected theme.breakpoints.${breakpoint} to be defined.`);
5691
+ if (!hasBreakpointStyles(breakpoint, props)) {
5704
5692
  return null;
5705
5693
  }
5706
5694
  return (0,_react_hive_honey_style__WEBPACK_IMPORTED_MODULE_0__.css) `
@@ -5874,7 +5862,7 @@ __webpack_require__.r(__webpack_exports__);
5874
5862
  */
5875
5863
  const useHoneyLayout = () => {
5876
5864
  const context = (0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(_contexts__WEBPACK_IMPORTED_MODULE_2__.HoneyLayoutContext);
5877
- (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.assert)(context, 'The `useHoneyLayout()` hook must be used inside <HoneyLayoutProvider/> component!');
5865
+ (0,_react_hive_honey_utils__WEBPACK_IMPORTED_MODULE_1__.assert)(context, '[@react-hive/honey-layout]: The `useHoneyLayout()` hook must be used inside <HoneyLayoutProvider/> component.');
5878
5866
  return context;
5879
5867
  };
5880
5868
 
@@ -14692,6 +14680,7 @@ var __webpack_exports__ = {};
14692
14680
  \**********************/
14693
14681
  __webpack_require__.r(__webpack_exports__);
14694
14682
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
14683
+ /* harmony export */ HONEY_LAYOUT_CSS_PROPERTY_PREFIX: () => (/* reexport safe */ _constants__WEBPACK_IMPORTED_MODULE_1__.HONEY_LAYOUT_CSS_PROPERTY_PREFIX),
14695
14684
  /* harmony export */ HoneyBox: () => (/* reexport safe */ _components__WEBPACK_IMPORTED_MODULE_3__.HoneyBox),
14696
14685
  /* harmony export */ HoneyContextMenu: () => (/* reexport safe */ _components__WEBPACK_IMPORTED_MODULE_3__.HoneyContextMenu),
14697
14686
  /* harmony export */ HoneyFlex: () => (/* reexport safe */ _components__WEBPACK_IMPORTED_MODULE_3__.HoneyFlex),