@react-hive/honey-layout 1.0.0 → 1.1.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/helpers.d.ts CHANGED
@@ -1,27 +1,34 @@
1
1
  import { HTMLAttributes } from 'react';
2
- import { HoneyBreakpointName, HoneyCSSArrayValue, HoneyCSSDimensionShortHandValue, HoneyCSSDimensionUnit, HoneyCSSMultiValue, HoneyCSSMediaRule, HoneySpacings, HoneyThemedProps, HoneyColorKey, HoneyFontName, HoneyCSSColor, HoneyDimensionName, Nullable, HoneyCSSProperties, HoneyBreakpoints, HoneyScreenState } from './types';
2
+ import { FlattenSimpleInterpolation } from 'styled-components';
3
+ import { HoneyBreakpointName, HoneyCSSArrayValue, HoneyCSSDimensionShortHandValue, HoneyCSSDimensionUnit, HoneyCSSMultiValue, HoneyCSSMediaRule, HoneySpacings, HoneyThemedProps, HoneyColorKey, HoneyFontName, HoneyCSSColor, HoneyDimensionName, Nullable, HoneyCSSProperties, HoneyBreakpoints, HoneyScreenState, HoneyCSSDimensionValue } from './types';
3
4
  /**
4
5
  * Conditional type to determine the return type of the `resolveSpacing` function.
5
6
  *
6
- * @template MultiValue - Type of the spacing value, can be a single value or an array of values.
7
+ * @template MultiValue - Type of the spacing value can be a single value or an array of values.
7
8
  * @template Unit - CSS length unit, which can be null or a specific unit type.
8
- * @template T - Type of the numeric value.
9
9
  */
10
- type ResolveSpacingResult<MultiValue extends HoneyCSSMultiValue<T>, Unit extends Nullable<HoneyCSSDimensionUnit>, T extends number> = Unit extends null ? MultiValue extends HoneyCSSArrayValue<T> ? HoneyCSSArrayValue<T> : T : MultiValue extends HoneyCSSArrayValue<T> ? HoneyCSSDimensionShortHandValue<MultiValue, NonNullable<Unit>> : `${T}${Unit}`;
10
+ export type ResolveSpacingResult<MultiValue extends HoneyCSSMultiValue<number>, Unit extends Nullable<HoneyCSSDimensionUnit>> = Unit extends null ? MultiValue extends HoneyCSSArrayValue<number> ? HoneyCSSArrayValue<number> : number : MultiValue extends HoneyCSSArrayValue<number> ? HoneyCSSDimensionShortHandValue<MultiValue, NonNullable<Unit>> : `${number}${Unit}`;
11
11
  /**
12
- * Resolves the spacing value based on the provided `value`, `unit`, and `type`.
13
- *
14
- * @template MultiValue - Type of the spacing value, can be a single value or an array of values.
15
- * @template Unit - CSS length unit, which can be null or a specific unit type.
16
- * @template T - Type of the numeric value.
17
- *
18
- * @param value - The spacing factor to be applied, which can be a single number or an array of 2, 3, or 4 numbers.
19
- * @param unit - The CSS unit to be used for the calculated value, e.g., 'px', 'em'. Set `null` to apply no unit. Default: 'px'.
20
- * @param type - The type of spacing to be used from the theme, e.g., 'base', 'small', 'large'. Default: 'base'.
21
- *
22
- * @returns The resolved spacing value, either as a single number or a string of space-separated numbers, optionally with the specified unit.
12
+ * Resolves a spacing value or multiple spacing values based on the provided input, CSS unit, and spacing type.
13
+ * This function calculates the appropriate spacing values from a theme and formats them with the specified CSS unit.
14
+ *
15
+ * @template MultiValue - Represents the spacing value(s), which could be a single number or an array of numbers (e.g., [1, 2, 3, 4]).
16
+ * @template Unit - The CSS unit used for the resolved spacing value, e.g., 'px', 'em'. Defaults to 'px'.
17
+ *
18
+ * @param {MultiValue} value - The spacing factor(s) to be applied. It can be:
19
+ * - A single number representing a multiplier for the base spacing value.
20
+ * - An array of numbers representing multiple multipliers for base spacing values (e.g., for margins or padding).
21
+ * @param {Unit} [unit='px'] - The CSS unit to use for the calculated value. If `null` or `undefined`, no unit is applied.
22
+ * Defaults to 'px'.
23
+ * @param {keyof HoneySpacings} [type='base'] - The type of spacing to use from the theme. Determines which base spacing
24
+ * value to use for calculations (e.g., 'base', 'small', 'large'). Defaults to 'base'.
25
+ *
26
+ * @returns {(props: HoneyThemedProps) => ResolveSpacingResult<MultiValue, Unit>} - A function that takes `HoneyThemedProps`
27
+ * (containing the theme object) and returns the resolved spacing value(s). The result is either:
28
+ * - A single calculated value (e.g., '16px') if the input is a single number.
29
+ * - A string of space-separated values (e.g., '8px 16px 24px 32px') if the input is an array of numbers.
23
30
  */
24
- export declare const resolveSpacing: <MultiValue extends HoneyCSSMultiValue<T>, Unit extends Nullable<HoneyCSSDimensionUnit> = "px", T extends number = number>(value: MultiValue, unit?: Unit, type?: keyof HoneySpacings) => ({ theme }: HoneyThemedProps) => ResolveSpacingResult<MultiValue, Unit, T>;
31
+ export declare const resolveSpacing: <MultiValue extends HoneyCSSMultiValue<number>, Unit extends Nullable<HoneyCSSDimensionUnit> = "px">(value: MultiValue, unit?: Unit, type?: keyof HoneySpacings) => ((props: HoneyThemedProps) => ResolveSpacingResult<MultiValue, Unit>);
25
32
  /**
26
33
  * Resolves a color value based on the provided color key and optional alpha value.
27
34
  *
@@ -41,15 +48,15 @@ export declare const resolveColor: (colorKey: HoneyColorKey, alpha?: number) =>
41
48
  *
42
49
  * @returns A function that takes the theme and returns the CSS for the specified font.
43
50
  */
44
- export declare const resolveFont: (fontName: HoneyFontName) => ({ theme }: HoneyThemedProps) => import('styled-components').FlattenSimpleInterpolation;
51
+ export declare const resolveFont: (fontName: HoneyFontName) => ({ theme }: HoneyThemedProps) => FlattenSimpleInterpolation;
45
52
  /**
46
53
  * Resolves a specific dimension value from the theme configuration.
47
54
  *
48
- * @param dimensionName - The name of the dimension to resolve.
55
+ * @param {HoneyDimensionName} dimensionName - The name of the dimension to resolve.
49
56
  *
50
57
  * @returns A function that takes the theme and returns the resolved dimension value from the theme.
51
58
  */
52
- export declare const resolveDimension: (dimensionName: HoneyDimensionName) => ({ theme }: HoneyThemedProps) => `${number}px` | `${number}cm` | `${number}mm` | `${number}in` | `${number}pt` | `${number}pc` | `${number}em` | `${number}rem` | `${number}%` | `${number}vh` | `${number}vw` | `${number}vmin` | `${number}vmax`;
59
+ export declare const resolveDimension: (dimensionName: HoneyDimensionName) => ({ theme }: HoneyThemedProps) => HoneyCSSDimensionValue;
53
60
  /**
54
61
  * Generates CSS styles based on the provided breakpoint and props.
55
62
  * Filters the props to include only those with breakpoints matching the specified breakpoint.
@@ -96,4 +103,3 @@ export declare const generateMediaStyles: <Props extends HoneyCSSProperties>(bre
96
103
  * - `isXl`: Whether the screen width is less than the 'xl' breakpoint.
97
104
  */
98
105
  export declare const resolveScreenState: (breakpoints: Partial<HoneyBreakpoints> | undefined) => HoneyScreenState;
99
- export {};