@react-hive/honey-layout 1.1.0 → 2.2.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,6 +1,6 @@
1
1
  import { PropsWithChildren } from 'react';
2
- import { DefaultTheme, FlattenSimpleInterpolation } from 'styled-components';
3
- import { HoneyColorKey, HoneyCSSColor, HoneyCSSDimensionUnit, HoneyCSSDimensionValue, HoneyCSSMultiValue, HoneyDimensionName, HoneyFontName, HoneyScreenState, HoneySpacings, HoneyThemedProps, Nullable } from '../types';
2
+ import { DefaultTheme, Interpolation } from 'styled-components';
3
+ import { HoneyColorKey, HoneyCSSColor, HoneyCSSDimensionUnit, HoneyCSSDimensionValue, HoneyCSSMultiValue, HoneyDimensionName, HoneyFontName, HoneyScreenState, HoneySpacings, Nullable } from '../types';
4
4
  import { ResolveSpacingResult } from '../helpers';
5
5
  import { UseHoneyMediaQueryOptions } from '../hooks';
6
6
  type HoneyLayoutContextValue = {
@@ -39,9 +39,9 @@ type HoneyLayoutContextValue = {
39
39
  *
40
40
  * @param {HoneyFontName} fontName - The name of the font to resolve from the theme.
41
41
  *
42
- * @returns {FlattenSimpleInterpolation} - The interpolated CSS styles for the specified font.
42
+ * @returns {Interpolation<object>} - The CSS style rules for the specified font.
43
43
  */
44
- resolveFont: (fontName: HoneyFontName) => FlattenSimpleInterpolation;
44
+ resolveFont: (fontName: HoneyFontName) => Interpolation<object>;
45
45
  /**
46
46
  * Function to resolve dimension values based on the theme.
47
47
  *
@@ -54,7 +54,9 @@ type HoneyLayoutContextValue = {
54
54
  type HoneyLayoutProviderContentProps = {
55
55
  mediaQueryOptions?: UseHoneyMediaQueryOptions;
56
56
  };
57
- type HoneyLayoutProviderProps = HoneyThemedProps<HoneyLayoutProviderContentProps>;
57
+ type HoneyLayoutProviderProps = HoneyLayoutProviderContentProps & {
58
+ theme: DefaultTheme;
59
+ };
58
60
  export declare const HoneyLayoutProvider: ({ theme, ...props }: PropsWithChildren<HoneyLayoutProviderProps>) => import("react/jsx-runtime").JSX.Element;
59
61
  /**
60
62
  * Custom hook to access the Honey layout context.
@@ -1,6 +1,8 @@
1
1
  import { PropsWithChildren } from 'react';
2
- import { HoneyThemedProps } from '../types';
3
- type HoneyLayoutThemeOverrideProps = HoneyThemedProps;
2
+ import { DefaultTheme } from 'styled-components';
3
+ type HoneyLayoutThemeOverrideProps = {
4
+ theme: DefaultTheme;
5
+ };
4
6
  /**
5
7
  * Provides a theme override context to its children.
6
8
  * Merges the provided theme with the existing theme from the `ThemeContext`.
@@ -0,0 +1,47 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * Type definition for status content options in a component.
4
+ *
5
+ * This type is used to provide properties for handling different states of a component,
6
+ * such as loading, error, and no content states, along with the content to display in each state.
7
+ *
8
+ * @template T - An optional generic type parameter to extend the type with additional properties.
9
+ */
10
+ export type HoneyStatusContentOptions<T = unknown> = {
11
+ /**
12
+ * A flag indicating whether the component is in a loading state.
13
+ *
14
+ * @default false
15
+ */
16
+ isLoading?: boolean;
17
+ /**
18
+ * A flag indicating whether the component has encountered an error.
19
+ *
20
+ * @default false
21
+ */
22
+ isError?: boolean;
23
+ /**
24
+ * A flag indicating whether the component has no content to display.
25
+ *
26
+ * @default false
27
+ */
28
+ isNoContent?: boolean;
29
+ /**
30
+ * The content to display when the component is in a loading state.
31
+ *
32
+ * @default null
33
+ */
34
+ loadingContent?: ReactNode;
35
+ /**
36
+ * The content to display when the component has encountered an error.
37
+ *
38
+ * @default null
39
+ */
40
+ errorContent?: ReactNode;
41
+ /**
42
+ * The content to display when the component has no content to display.
43
+ *
44
+ * @default null
45
+ */
46
+ noContent?: ReactNode;
47
+ } & T;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * The types for handling CSS properties and values, focusing on dimensions, colors, media queries, and other essential CSS concepts.
3
+ */
4
+ import * as CSS from 'csstype';
5
+ export type HoneyCSSResolutionUnit = 'dpi' | 'dpcm' | 'dppx' | 'x';
6
+ export type HoneyCSSResolutionValue = `${number}${HoneyCSSResolutionUnit}`;
7
+ export type HoneyCSSMediaOrientation = 'landscape' | 'portrait';
8
+ type HoneyCSSAbsoluteDimensionUnit = 'px' | 'cm' | 'mm' | 'in' | 'pt' | 'pc';
9
+ type HoneyCSSRelativeDimensionUnit = 'em' | 'rem' | '%' | 'vh' | 'vw' | 'vmin' | 'vmax';
10
+ /**
11
+ * Represents a CSS dimension unit, which can be either an absolute or relative.
12
+ */
13
+ export type HoneyCSSDimensionUnit = HoneyCSSAbsoluteDimensionUnit | HoneyCSSRelativeDimensionUnit;
14
+ /**
15
+ * Represents an array of CSS values, either 2, 3, or 4 values.
16
+ *
17
+ * @template T - Type of the value.
18
+ */
19
+ export type HoneyCSSArrayValue<T> = [T, T] | [T, T, T] | [T, T, T, T];
20
+ /**
21
+ * Represents a CSS value that can be either a single value or an array of values.
22
+ *
23
+ * @template T - Type of the value.
24
+ */
25
+ export type HoneyCSSMultiValue<T> = T | HoneyCSSArrayValue<T>;
26
+ /**
27
+ * Type representing CSS properties related to spacing and positioning.
28
+ */
29
+ export type HoneyCSSDimensionProperty = keyof Pick<CSS.Properties, 'width' | 'height' | 'margin' | 'marginTop' | 'marginRight' | 'marginBottom' | 'marginLeft' | 'padding' | 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft' | 'top' | 'right' | 'bottom' | 'left' | 'gap' | 'rowGap' | 'columnGap'>;
30
+ /**
31
+ * Represents a subset of CSS properties that define color-related styles.
32
+ */
33
+ export type HoneyCSSColorProperty = keyof Pick<CSS.Properties, 'color' | 'backgroundColor' | 'borderColor' | 'borderTopColor' | 'borderRightColor' | 'borderBottomColor' | 'borderLeftColor' | 'outlineColor' | 'textDecorationColor' | 'fill' | 'stroke'>;
34
+ /**
35
+ * Represents a specific CSS dimension value with a unit.
36
+ */
37
+ export type HoneyCSSDimensionValue<Unit extends HoneyCSSDimensionUnit = HoneyCSSDimensionUnit> = `${number}${Unit}`;
38
+ /**
39
+ * Type representing numeric values for CSS dimension properties.
40
+ *
41
+ * If `CSSProperty` extends `HoneyCSSDimensionProperty`, this type will be a single value or an array of numbers,
42
+ * allowing for spacing properties that can have single or multiple numeric values (e.g., margin, padding).
43
+ * Otherwise, it results in `never`, indicating that non-distance properties are not included.
44
+ *
45
+ * @template CSSProperty - The key of a CSS property to check.
46
+ */
47
+ export type HoneyCSSDimensionNumericValue<CSSProperty extends keyof CSS.Properties> = CSSProperty extends HoneyCSSDimensionProperty ? HoneyCSSMultiValue<number> : never;
48
+ /**
49
+ * Represents a shorthand CSS dimension value for 2, 3, or 4 values with the same unit.
50
+ *
51
+ * @template Value - Type of the value.
52
+ * @template Unit - CSS length unit.
53
+ */
54
+ export type HoneyCSSDimensionShortHandValue<Value, Unit extends HoneyCSSDimensionUnit> = Value extends [unknown, unknown] ? `${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>}` : Value extends [unknown, unknown, unknown] ? `${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>}` : Value extends [unknown, unknown, unknown, unknown] ? `${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>}` : never;
55
+ /**
56
+ * Options for CSS @media at-rule.
57
+ */
58
+ export type HoneyCSSMediaRule = {
59
+ operator?: 'not' | 'only';
60
+ mediaType?: 'all' | 'print' | 'screen' | 'speech';
61
+ width?: HoneyCSSDimensionValue;
62
+ minWidth?: HoneyCSSDimensionValue;
63
+ maxWidth?: HoneyCSSDimensionValue;
64
+ height?: HoneyCSSDimensionValue;
65
+ minHeight?: HoneyCSSDimensionValue;
66
+ maxHeight?: HoneyCSSDimensionValue;
67
+ orientation?: HoneyCSSMediaOrientation;
68
+ resolution?: HoneyCSSResolutionValue;
69
+ minResolution?: HoneyCSSResolutionValue;
70
+ maxResolution?: HoneyCSSResolutionValue;
71
+ update?: 'none' | 'slow' | 'fast';
72
+ };
73
+ export {};
@@ -0,0 +1,33 @@
1
+ import { KeysWithNonArrayValues } from './utility.types';
2
+ /**
3
+ * Represents an item that has been flattened from a hierarchical data structure, with additional
4
+ * properties to support tracking its position and relationships within the hierarchy.
5
+ *
6
+ * This type is particularly useful for scenarios where nested data structures, such as trees or
7
+ * lists with sub-items, need to be transformed into a flat structure while preserving the depth
8
+ * and parent-child relationships.
9
+ *
10
+ * @template OriginItem - The type of the original item from the hierarchical structure.
11
+ * @template NestedListKey - The key within `OriginItem` that contains nested items or lists.
12
+ */
13
+ export type HoneyFlattenedItem<OriginItem extends object, NestedListKey extends string> = Omit<OriginItem, NestedListKey> & {
14
+ /**
15
+ * The optional id of the parent item in the flattened structure. This establishes the parent-child
16
+ * relationship and allows the reconstruction of the original hierarchy if needed.
17
+ */
18
+ parentId: OriginItem[KeysWithNonArrayValues<OriginItem>] | undefined;
19
+ /**
20
+ * The depth level of the item in the flattened structure. This indicates how deep the item is nested
21
+ * within the hierarchy, starting from 0 for top-level items.
22
+ *
23
+ * @default 0
24
+ */
25
+ depthLevel: number;
26
+ /**
27
+ * The total number of nested items that are contained within the current item. This helps to keep
28
+ * track of the overall size of the nested structure for each item.
29
+ *
30
+ * @default 0
31
+ */
32
+ totalNestedItems: number;
33
+ };
@@ -0,0 +1,6 @@
1
+ export * from './utility.types';
2
+ export * from './data.types';
3
+ export * from './state.types';
4
+ export * from './css.types';
5
+ export * from './component.types';
6
+ export * from './types';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Types related to managing application state, React context, or any other state management tools.
3
+ */
4
+ /**
5
+ * Represents the state of the screen layout.
6
+ */
7
+ export type HoneyScreenState = {
8
+ /** Indicates if the screen size is extra-small (xs). */
9
+ isXs: boolean;
10
+ /** Indicates if the screen size is small (sm). */
11
+ isSm: boolean;
12
+ /** Indicates if the screen size is medium (md). */
13
+ isMd: boolean;
14
+ /** Indicates if the screen size is large (lg). */
15
+ isLg: boolean;
16
+ /** Indicates if the screen size is extra-large (xl). */
17
+ isXl: boolean;
18
+ /** Indicates if the screen orientation is portrait. */
19
+ isPortrait: boolean;
20
+ /** Indicates if the screen orientation is landscape. */
21
+ isLandscape: boolean;
22
+ };
@@ -1,78 +1,12 @@
1
- import { ComponentType, ReactNode } from 'react';
2
- import { DefaultTheme, Interpolation } from 'styled-components';
1
+ import { ElementType } from 'react';
2
+ import { ExecutionContext, Interpolation } from 'styled-components';
3
3
  import { DataType } from 'csstype';
4
+ import { HoneyCSSColorProperty, HoneyCSSDimensionNumericValue, HoneyCSSDimensionValue } from './css.types';
4
5
  import * as CSS from 'csstype';
5
6
  export type TimeoutId = ReturnType<typeof setTimeout>;
6
7
  export type Nullable<T> = T | null;
7
- type ExtractKeys<T, Condition> = {
8
- [K in keyof T]: T[K] extends Condition ? K : never;
9
- }[keyof T];
10
- type ExcludeKeys<T, Condition> = {
11
- [K in keyof T]: T[K] extends Condition ? never : K;
12
- }[keyof T];
13
- export type KeysWithStringValues<T> = Extract<ExtractKeys<T, string | null | undefined>, string>;
14
- export type KeysWithArrayValues<T> = Extract<ExtractKeys<T, unknown[] | null | undefined>, string>;
15
- export type KeysWithNonArrayValues<T> = Extract<ExcludeKeys<T, unknown[] | null | undefined>, string>;
16
8
  export type HoneyHEXColor = `#${string}`;
17
- type HoneyCSSAbsoluteDimensionUnit = 'px' | 'cm' | 'mm' | 'in' | 'pt' | 'pc';
18
- type HoneyCSSRelativeDimensionUnit = 'em' | 'rem' | '%' | 'vh' | 'vw' | 'vmin' | 'vmax';
19
- /**
20
- * Type representing CSS properties related to spacing and positioning.
21
- */
22
- export type HoneyCSSDimensionProperty = keyof Pick<CSS.Properties, 'width' | 'height' | 'margin' | 'marginTop' | 'marginRight' | 'marginBottom' | 'marginLeft' | 'padding' | 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft' | 'top' | 'right' | 'bottom' | 'left' | 'gap' | 'rowGap' | 'columnGap'>;
23
- /**
24
- * Represents a subset of CSS properties that define color-related styles.
25
- */
26
- export type HoneyCSSColorProperty = keyof Pick<CSS.Properties, 'color' | 'backgroundColor' | 'borderColor' | 'borderTopColor' | 'borderRightColor' | 'borderBottomColor' | 'borderLeftColor' | 'outlineColor' | 'textDecorationColor' | 'fill' | 'stroke'>;
27
- /**
28
- * Represents a CSS dimension unit, which can be either an absolute or relative.
29
- */
30
- export type HoneyCSSDimensionUnit = HoneyCSSAbsoluteDimensionUnit | HoneyCSSRelativeDimensionUnit;
31
- export type HoneyCSSResolutionUnit = 'dpi' | 'dpcm' | 'dppx' | 'x';
32
- export type HoneyCSSResolutionValue = `${number}${HoneyCSSResolutionUnit}`;
33
- export type HoneyCSSMediaOrientation = 'landscape' | 'portrait';
34
9
  export type HoneyCSSColor = DataType.NamedColor | HoneyHEXColor;
35
- /**
36
- * Represents a specific CSS dimension value with a unit.
37
- */
38
- export type HoneyCSSDimensionValue<Unit extends HoneyCSSDimensionUnit = HoneyCSSDimensionUnit> = `${number}${Unit}`;
39
- /**
40
- * Represents a shorthand CSS dimension value for 2, 3, or 4 values with the same unit.
41
- *
42
- * @template Value - Type of the value.
43
- * @template Unit - CSS length unit.
44
- */
45
- export type HoneyCSSDimensionShortHandValue<Value, Unit extends HoneyCSSDimensionUnit> = Value extends [unknown, unknown] ? `${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>}` : Value extends [unknown, unknown, unknown] ? `${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>}` : Value extends [unknown, unknown, unknown, unknown] ? `${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>} ${HoneyCSSDimensionValue<Unit>}` : never;
46
- /**
47
- * Represents an array of CSS values, either 2, 3, or 4 values.
48
- *
49
- * @template T - Type of the value.
50
- */
51
- export type HoneyCSSArrayValue<T> = [T, T] | [T, T, T] | [T, T, T, T];
52
- /**
53
- * Represents a CSS value that can be either a single value or an array of values.
54
- *
55
- * @template T - Type of the value.
56
- */
57
- export type HoneyCSSMultiValue<T> = T | HoneyCSSArrayValue<T>;
58
- /**
59
- * Options for CSS @media at-rule.
60
- */
61
- export type HoneyCSSMediaRule = {
62
- operator?: 'not' | 'only';
63
- mediaType?: 'all' | 'print' | 'screen' | 'speech';
64
- width?: HoneyCSSDimensionValue;
65
- minWidth?: HoneyCSSDimensionValue;
66
- maxWidth?: HoneyCSSDimensionValue;
67
- height?: HoneyCSSDimensionValue;
68
- minHeight?: HoneyCSSDimensionValue;
69
- maxHeight?: HoneyCSSDimensionValue;
70
- orientation?: HoneyCSSMediaOrientation;
71
- resolution?: HoneyCSSResolutionValue;
72
- minResolution?: HoneyCSSResolutionValue;
73
- maxResolution?: HoneyCSSResolutionValue;
74
- update?: 'none' | 'slow' | 'fast';
75
- };
76
10
  /**
77
11
  * Represents the breakpoints configuration in pixes for a responsive layout.
78
12
  *
@@ -132,25 +66,12 @@ declare module 'styled-components' {
132
66
  interface DefaultTheme extends HoneyTheme {
133
67
  }
134
68
  }
135
- export type HoneyThemedProps<T = unknown> = {
136
- theme: DefaultTheme;
137
- } & T;
138
69
  /**
139
70
  * A type representing a function that returns a value for a specific CSS property based on the provided theme.
140
71
  *
141
72
  * @template CSSProperty - The CSS property this function will generate a value for.
142
73
  */
143
- type HoneyCSSPropertyValueFn<CSSProperty extends keyof CSS.Properties> = (props: HoneyThemedProps) => CSS.Properties[CSSProperty];
144
- /**
145
- * Type representing numeric values for CSS dimension properties.
146
- *
147
- * If `CSSProperty` extends `HoneyCSSDimensionProperty`, this type will be a single value or an array of numbers,
148
- * allowing for spacing properties that can have single or multiple numeric values (e.g., margin, padding).
149
- * Otherwise, it results in `never`, indicating that non-distance properties are not included.
150
- *
151
- * @template CSSProperty - The key of a CSS property to check.
152
- */
153
- type HoneyCSSDimensionNumericValue<CSSProperty extends keyof CSS.Properties> = CSSProperty extends HoneyCSSDimensionProperty ? HoneyCSSMultiValue<number> : never;
74
+ type HoneyCSSPropertyValueFn<CSSProperty extends keyof CSS.Properties> = (context: ExecutionContext) => CSS.Properties[CSSProperty];
154
75
  /**
155
76
  * Type representing possible values for CSS color properties.
156
77
  *
@@ -184,29 +105,24 @@ type HoneyResponsiveCSSPropertyValue<CSSProperty extends keyof CSS.Properties> =
184
105
  */
185
106
  export type HoneyCSSPropertyValue<CSSProperty extends keyof CSS.Properties> = HoneyCSSColorValue<CSSProperty> | HoneyCSSPropertyValueFn<CSSProperty> | HoneyResponsiveCSSPropertyValue<CSSProperty>;
186
107
  /**
187
- * Defines a type representing a set of CSS properties where each property key is prefixed with a dollar sign ($).
108
+ * A utility type to add a `$` prefix to a given CSS property name.
109
+ *
110
+ * @template CSSProperty - The string type representing a CSS property name.
188
111
  */
189
- export type HoneyCSSProperties = Partial<{
190
- [CSSProperty in keyof CSS.Properties as `$${CSSProperty}`]: HoneyCSSPropertyValue<CSSProperty>;
191
- }>;
112
+ export type HoneyPrefixedCSSProperty<CSSProperty extends keyof CSS.Properties = keyof CSS.Properties> = `$${CSSProperty}`;
192
113
  /**
193
- * Represents the state of the screen layout.
114
+ * Represents an object where each key is a prefixed CSS property (with a `$` prefix),
115
+ *
116
+ * Example:
117
+ * ```
118
+ * const styles: HoneyPrefixedCSSProperties = {
119
+ * $color: 'red',
120
+ * $fontSize: '12px'
121
+ * };
122
+ * ```
194
123
  */
195
- export type HoneyScreenState = {
196
- /** Indicates if the screen size is extra-small (xs). */
197
- isXs: boolean;
198
- /** Indicates if the screen size is small (sm). */
199
- isSm: boolean;
200
- /** Indicates if the screen size is medium (md). */
201
- isMd: boolean;
202
- /** Indicates if the screen size is large (lg). */
203
- isLg: boolean;
204
- /** Indicates if the screen size is extra-large (xl). */
205
- isXl: boolean;
206
- /** Indicates if the screen orientation is portrait. */
207
- isPortrait: boolean;
208
- /** Indicates if the screen orientation is landscape. */
209
- isLandscape: boolean;
124
+ export type HoneyPrefixedCSSProperties = {
125
+ [CSSProperty in keyof CSS.Properties as HoneyPrefixedCSSProperty<CSSProperty>]?: HoneyCSSPropertyValue<CSSProperty>;
210
126
  };
211
127
  /**
212
128
  * Defines different spacing sizes available in the theme.
@@ -223,7 +139,7 @@ export type HoneySpacings = {
223
139
  /**
224
140
  * Defines the color palette used in the theme.
225
141
  */
226
- export interface BaseHoneyColors {
142
+ interface BaseHoneyColors {
227
143
  /**
228
144
  * Used for elements that require high visibility and emphasis, such as primary buttons, call-to-action elements,
229
145
  * and important elements like headers or titles.
@@ -273,7 +189,7 @@ export interface BaseHoneyColors {
273
189
  * @example
274
190
  * ```typescript
275
191
  * declare module '@react-hive/honey-layout' {
276
- * interface HoneyColors {
192
+ * export interface HoneyColors {
277
193
  * neutral: Record<'charcoalDark' | 'charcoalGray' | 'crimsonRed', HoneyCSSColor>;
278
194
  * }
279
195
  * }
@@ -318,7 +234,7 @@ export type HoneyFont = {
318
234
  * @example
319
235
  * ```typescript
320
236
  * declare module '@react-hive/honey-layout' {
321
- * interface HoneyFonts {
237
+ * export interface HoneyFonts {
322
238
  * body: HoneyFont;
323
239
  * caption: HoneyFont;
324
240
  * }
@@ -337,79 +253,8 @@ export interface HoneyDimensions {
337
253
  }
338
254
  export type HoneyDimensionName = keyof HoneyDimensions;
339
255
  export type ComponentWithAs<T, P = object> = {
340
- as?: string | ComponentType<P>;
256
+ as?: ElementType<P>;
341
257
  } & T;
342
- export type HoneyModifierResultFn = () => Interpolation<HoneyThemedProps>;
258
+ export type HoneyModifierResultFn = () => Interpolation<object>;
343
259
  export type HoneyModifier<Config = unknown> = (config?: Config) => HoneyModifierResultFn;
344
- /**
345
- * Type definition for status content options in a component.
346
- *
347
- * This type is used to provide properties for handling different states of a component,
348
- * such as loading, error, and no content states, along with the content to display in each state.
349
- *
350
- * @template T - An optional generic type parameter to extend the type with additional properties.
351
- */
352
- export type HoneyStatusContentOptions<T = unknown> = {
353
- /**
354
- * A flag indicating whether the component is in a loading state.
355
- *
356
- * @default false
357
- */
358
- isLoading?: boolean;
359
- /**
360
- * A flag indicating whether the component has encountered an error.
361
- *
362
- * @default false
363
- */
364
- isError?: boolean;
365
- /**
366
- * A flag indicating whether the component has no content to display.
367
- *
368
- * @default false
369
- */
370
- isNoContent?: boolean;
371
- /**
372
- * The content to display when the component is in a loading state.
373
- *
374
- * @default null
375
- */
376
- loadingContent?: ReactNode;
377
- /**
378
- * The content to display when the component has encountered an error.
379
- *
380
- * @default null
381
- */
382
- errorContent?: ReactNode;
383
- /**
384
- * The content to display when the component has no content to display.
385
- *
386
- * @default null
387
- */
388
- noContent?: ReactNode;
389
- } & T;
390
- /**
391
- * Represents an item that has been flattened with additional properties for hierarchical data structures.
392
- *
393
- * @template OriginItem - The type of the original item.
394
- * @template NestedListKey - The key within `Item` that contains nested items or lists.
395
- */
396
- export type HoneyFlattenedItem<OriginItem extends object, NestedListKey extends string> = Omit<OriginItem, NestedListKey> & {
397
- /**
398
- * Optional id of the parent item in the flattened structure.
399
- * Used to establish parent-child relationships in hierarchical data.
400
- */
401
- parentId: OriginItem[KeysWithNonArrayValues<OriginItem>] | undefined;
402
- /**
403
- * The depth level of the item in the flattened structure.
404
- * Indicates how deep the item is nested within the hierarchy.
405
- */
406
- depthLevel: number;
407
- /**
408
- * The total number of nested items within the current item.
409
- * Helps to keep track of the size of the nested structure.
410
- *
411
- * @default 0
412
- */
413
- totalNestedItems: number;
414
- };
415
260
  export {};
@@ -0,0 +1,72 @@
1
+ /**
2
+ * This file stores generic or helper types that provide utility across multiple files.
3
+ * These types are often unrelated to specific components or business logic.
4
+ * They aim to assist in working with types more effectively and flexibly.
5
+ */
6
+ /**
7
+ * Extracts the keys from a given type `T` whose values match the specified `Condition`.
8
+ *
9
+ * @template T - The object type from which to extract keys.
10
+ * @template Condition - The condition that the type of the values must satisfy to be included.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * type Example = { a: string; b: number; c: boolean };
15
+ * type StringKeys = ExtractKeys<Example, string>; // "a"
16
+ * ```
17
+ */
18
+ type ExtractKeys<T, Condition> = {
19
+ [K in keyof T]: T[K] extends Condition ? K : never;
20
+ }[keyof T];
21
+ /**
22
+ * Excludes the keys from a given type `T` whose values match the specified `Condition`.
23
+ *
24
+ * @template T - The object type from which to exclude keys.
25
+ * @template Condition - The condition that the type of the values must satisfy to be excluded.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * type Example = { a: string; b: number; c: boolean };
30
+ * type NonNumberKeys = ExcludeKeys<Example, number>; // "a" | "c"
31
+ * ```
32
+ */
33
+ type ExcludeKeys<T, Condition> = {
34
+ [K in keyof T]: T[K] extends Condition ? never : K;
35
+ }[keyof T];
36
+ /**
37
+ * Extracts the keys from a given type `T` where the values are `string`, `null`, or `undefined`.
38
+ *
39
+ * @template T - The object type from which to extract string-related keys.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * type Example = { a: string; b: number; c: string | null };
44
+ * type StringKeys = KeysWithStringValues<Example>; // "a" | "c"
45
+ * ```
46
+ */
47
+ export type KeysWithStringValues<T> = Extract<ExtractKeys<T, string | null | undefined>, string>;
48
+ /**
49
+ * Extracts the keys from a given type `T` where the values are arrays (`unknown[]`), `null`, or `undefined`.
50
+ *
51
+ * @template T - The object type from which to extract array-related keys.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * type Example = { a: string[]; b: number; c: number[] | null };
56
+ * type ArrayKeys = KeysWithArrayValues<Example>; // "a" | "c"
57
+ * ```
58
+ */
59
+ export type KeysWithArrayValues<T> = Extract<ExtractKeys<T, unknown[] | null | undefined>, string>;
60
+ /**
61
+ * Extracts the keys from a given type `T` where the values are **not** arrays (`unknown[]`), `null`, or `undefined`.
62
+ *
63
+ * @template T - The object type from which to extract non-array keys.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * type Example = { a: string; b: number; c: string[]; d: null };
68
+ * type NonArrayKeys = KeysWithNonArrayValues<Example>; // "a" | "b"
69
+ * ```
70
+ */
71
+ export type KeysWithNonArrayValues<T> = Extract<ExcludeKeys<T, unknown[] | null | undefined>, string>;
72
+ export {};