@react-hive/honey-style 1.10.0 → 2.0.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.
@@ -1,2 +1,3 @@
1
1
  export * from './types';
2
+ export * from './utility.types';
2
3
  export * from './css.types';
@@ -99,7 +99,7 @@ export interface HoneyFont {
99
99
  *
100
100
  * @example
101
101
  * ```ts
102
- * declare module '@react-hive/honey-layout' {
102
+ * declare module '@react-hive/honey-style' {
103
103
  * export interface HoneyFonts {
104
104
  * body: HoneyFont;
105
105
  * caption: HoneyFont;
@@ -163,7 +163,7 @@ interface BaseHoneyColors {
163
163
  *
164
164
  * @example
165
165
  * ```ts
166
- * declare module '@react-hive/honey-layout' {
166
+ * declare module '@react-hive/honey-style' {
167
167
  * export interface HoneyColors {
168
168
  * neutral: Record<'charcoalDark' | 'charcoalGray' | 'crimsonRed', HoneyCSSColor>;
169
169
  * }
@@ -0,0 +1 @@
1
+ export type Nullable<T> = T | null;
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { HoneyColor, HoneyColorKey, HoneyCSSClassName, HoneyCSSColor, HoneyCSSDimensionValue, HoneyDimensionName, HoneyFontName, HoneyHEXColor, HoneyStyledComponent, HoneyStyledContext } from './types';
1
+ import type { Nullable, HoneyColor, HoneyColorKey, HoneyCSSClassName, HoneyCSSColor, HoneyCSSDimensionUnit, HoneyCSSDimensionValue, HoneyCSSShorthandDimensionOutput, HoneyCSSShorthandTuple, HoneyCSSSpacingValue, HoneyDimensionName, HoneyFontName, HoneyHEXColor, HoneySpacings, HoneyStyledComponent, HoneyStyledContext } from './types';
2
2
  export declare function assert(condition: any, message: string): asserts condition;
3
3
  export declare const generateId: (prefix: string) => string;
4
4
  export declare const toKebabCase: (str: string) => string;
@@ -34,7 +34,6 @@ export declare const boolFilter: <T>(array: (T | false | null | undefined)[]) =>
34
34
  export declare const combineClassNames: (classNames: HoneyCSSClassName[]) => string;
35
35
  export declare const resolveClassName: (css: string) => string;
36
36
  export declare const isStyledComponent: (component: any) => component is HoneyStyledComponent;
37
- export declare const processCss: (rawCss: string, selector?: string) => string;
38
37
  /**
39
38
  * Filters out non-standard HTML attributes from a props object intended for a native HTML element.
40
39
  *
@@ -72,6 +71,46 @@ export declare const pxToRem: (px: number, base?: number) => string;
72
71
  * @returns True if the string value is a theme color value, false otherwise.
73
72
  */
74
73
  export declare const checkIsThemeColorValue: (propertyValue: string) => propertyValue is HoneyColorKey;
74
+ /**
75
+ * Determines the resolved type for spacing values when processed by `resolveSpacing`.
76
+ *
77
+ * The return type adapts based on the shape of the `Value` and presence of a CSS `Unit`:
78
+ *
79
+ * - If `Value` is a `string` (e.g., raw `'10px'` or `'auto'`), it is returned as-is.
80
+ * - If `Unit` is `null`, the original value is returned (either number or shorthand array).
81
+ * - If `Unit` is provided and `Value` is a shorthand array (e.g., `[1, 2, 3, 4]`),
82
+ * it is resolved to a space-separated dimension string (e.g., `'8px 16px 24px 32px'`).
83
+ * - If `Unit` is provided and `Value` is a number, it is resolved to a single dimension string (e.g., `'16px'`).
84
+ *
85
+ * This type helps enforce correct resolution behavior depending on user input and configuration.
86
+ *
87
+ * @template Value - The input spacing value (number, shorthand array, or raw string).
88
+ * @template Unit - A CSS length unit (e.g., 'px', 'em'), or `null` to skip unit formatting.
89
+ */
90
+ export type HoneyResolveSpacingResult<Value extends HoneyCSSSpacingValue, Unit extends Nullable<HoneyCSSDimensionUnit>> = Value extends HoneyCSSDimensionValue ? Value : Unit extends null ? Value : Value extends HoneyCSSShorthandTuple<number | HoneyCSSDimensionValue> ? HoneyCSSShorthandDimensionOutput<Value, NonNullable<Unit>> : HoneyCSSDimensionValue<NonNullable<Unit>>;
91
+ /**
92
+ * Resolves a spacing value or shorthand spacing array using the theme and optional unit.
93
+ *
94
+ * This function takes spacing multipliers and converts them into pixel or unit-based values
95
+ * using a theme spacing scale (e.g., `theme.spacings.base`). Useful for applying consistent
96
+ * layout spacing with theming and token support.
97
+ *
98
+ * @template Value - The spacing value(s) to resolve. Can be:
99
+ * - A number (e.g., `1`) representing a multiplier.
100
+ * - An array of numbers (e.g., `[1, 2, 3, 4]`) for shorthand spacing.
101
+ * - A dimension string (e.g., `'10px'`) will be returned as `never`.
102
+ * @template Unit - Optional CSS unit (`'px'`, `'em'`, etc.), or `null` to skip units.
103
+ *
104
+ * @param value - Spacing multiplier(s) to apply.
105
+ * @param [unit='px'] - The CSS unit to append. If `null`, values remain numeric.
106
+ * @param [type='base'] - The spacing type to use from the theme (e.g., `'base'`, `'small'`).
107
+ *
108
+ * @returns A function that takes a theme context and returns:
109
+ * - A single resolved value (e.g., `'16px'`) if `value` is a number.
110
+ * - A space-separated string (e.g., `'8px 12px'`) if `value` is an array.
111
+ * - `never` if the input is a raw string (unsupported).
112
+ */
113
+ export declare const resolveSpacing: <Value extends HoneyCSSSpacingValue, Unit extends Nullable<HoneyCSSDimensionUnit> = "px">(value: Value, unit?: Unit, type?: keyof HoneySpacings) => ((context: HoneyStyledContext<object>) => HoneyResolveSpacingResult<Value, Unit>);
75
114
  /**
76
115
  * Resolves the font styles based on the provided font name from the theme.
77
116
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-hive/honey-style",
3
- "version": "1.10.0",
3
+ "version": "2.0.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "react",