@react-hive/honey-layout 1.0.0-beta

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.
Files changed (35) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/dist/components/HoneyBox.d.ts +6 -0
  4. package/dist/components/HoneyGrid/HoneyGrid.d.ts +22 -0
  5. package/dist/components/HoneyGrid/HoneyGrid.styled.d.ts +859 -0
  6. package/dist/components/HoneyGrid/hooks/index.d.ts +1 -0
  7. package/dist/components/HoneyGrid/hooks/useCurrentHoneyGrid.d.ts +5 -0
  8. package/dist/components/HoneyGrid/index.d.ts +2 -0
  9. package/dist/components/HoneyGridColumn/HoneyGridColumn.d.ts +3 -0
  10. package/dist/components/HoneyGridColumn/HoneyGridColumn.styled.d.ts +866 -0
  11. package/dist/components/HoneyGridColumn/HoneyGridColumn.types.d.ts +2 -0
  12. package/dist/components/HoneyGridColumn/index.d.ts +3 -0
  13. package/dist/components/HoneyLazyContent.d.ts +30 -0
  14. package/dist/components/HoneyList/HoneyList.d.ts +12 -0
  15. package/dist/components/HoneyList/HoneyList.helpers.d.ts +2 -0
  16. package/dist/components/HoneyList/HoneyList.types.d.ts +3 -0
  17. package/dist/components/HoneyList/index.d.ts +3 -0
  18. package/dist/components/HoneyLoopingList/HoneyLoopingList.d.ts +12 -0
  19. package/dist/components/HoneyLoopingList/index.d.ts +1 -0
  20. package/dist/components/HoneyStatusContent.d.ts +6 -0
  21. package/dist/components/index.d.ts +7 -0
  22. package/dist/constants.d.ts +5 -0
  23. package/dist/helpers.d.ts +905 -0
  24. package/dist/hooks/index.d.ts +4 -0
  25. package/dist/hooks/use-honey-drag.d.ts +71 -0
  26. package/dist/hooks/use-honey-infinite-scroll.d.ts +7 -0
  27. package/dist/hooks/use-honey-media-query.d.ts +18 -0
  28. package/dist/hooks/use-honey-synthetic-scrollable-container.d.ts +23 -0
  29. package/dist/index.d.ts +6 -0
  30. package/dist/index.js +1826 -0
  31. package/dist/providers/HoneyThemeProvider.d.ts +14 -0
  32. package/dist/providers/index.d.ts +1 -0
  33. package/dist/types.d.ts +419 -0
  34. package/dist/utils.d.ts +121 -0
  35. package/package.json +84 -0
@@ -0,0 +1,14 @@
1
+ import { PropsWithChildren, JSX } from 'react';
2
+ import { DefaultTheme } from 'styled-components';
3
+ type HoneyThemeProviderProps = {
4
+ theme: DefaultTheme;
5
+ };
6
+ /**
7
+ * Component for providing a merged theme to its children.
8
+ * Merges the provided theme with the current theme from the context.
9
+ *
10
+ * @param {PropsWithChildren<HoneyThemeProviderProps>} props - Props containing the theme object.
11
+ * @returns {JSX.Element} - The wrapped children with the merged theme.
12
+ */
13
+ export declare const HoneyThemeProvider: ({ children, theme, }: PropsWithChildren<HoneyThemeProviderProps>) => JSX.Element;
14
+ export {};
@@ -0,0 +1 @@
1
+ export * from './HoneyThemeProvider';
@@ -0,0 +1,419 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ import { Interpolation } from 'styled-components';
3
+ import { DataType } from 'csstype';
4
+ import * as CSS from 'csstype';
5
+ export type TimeoutId = ReturnType<typeof setTimeout>;
6
+ 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
+ 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
+ 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
+ /**
77
+ * Represents the breakpoints configuration for a responsive layout.
78
+ *
79
+ * Notes:
80
+ * - `xs`: Extra small devices
81
+ * - `sm`: Small devices
82
+ * - `md`: Medium devices
83
+ * - `lg`: Large devices
84
+ * - `xl`: Extra large devices
85
+ */
86
+ export type HoneyBreakpoints = {
87
+ xs: number;
88
+ sm: number;
89
+ md: number;
90
+ lg: number;
91
+ xl: number;
92
+ };
93
+ export type HoneyBreakpointName = keyof HoneyBreakpoints;
94
+ /**
95
+ * A type representing a function that returns a value for a specific CSS property based on the provided theme.
96
+ *
97
+ * @template CSSProperty - The CSS property this function will generate a value for.
98
+ */
99
+ type HoneyCSSPropertyValueFn<CSSProperty extends keyof CSS.Properties> = (props: {
100
+ theme: HoneyTheme;
101
+ }) => CSS.Properties[CSSProperty];
102
+ /**
103
+ * Type representing numeric values for CSS dimension properties.
104
+ *
105
+ * If `CSSProperty` extends `HoneyCSSDimensionProperty`, this type will be a single value or an array of numbers,
106
+ * allowing for spacing properties that can have single or multiple numeric values (e.g., margin, padding).
107
+ * Otherwise, it results in `never`, indicating that non-distance properties are not included.
108
+ *
109
+ * @template CSSProperty - The key of a CSS property to check.
110
+ */
111
+ type HoneyCSSDimensionNumericValue<CSSProperty extends keyof CSS.Properties> = CSSProperty extends HoneyCSSDimensionProperty ? HoneyCSSMultiValue<number> : never;
112
+ /**
113
+ * Type representing possible values for CSS color properties.
114
+ *
115
+ * This type can be either a color from the theme or a valid CSS color value.
116
+ *
117
+ * @template CSSProperty - The key of a CSS property to check.
118
+ */
119
+ type HoneyCSSColorValue<CSSProperty extends keyof CSS.Properties> = CSSProperty extends HoneyCSSColorProperty ? HoneyCSSColor | HoneyColorKey : CSS.Properties[CSSProperty] | HoneyCSSDimensionNumericValue<CSSProperty>;
120
+ /**
121
+ * Represents a responsive CSS property value for a specific CSS property.
122
+ *
123
+ * This type maps each breakpoint name to a corresponding CSS property value.
124
+ * The values can include:
125
+ * - A standard CSS property value.
126
+ * - A numeric value for dimension properties.
127
+ * - A function returning a value based on the CSS property.
128
+ *
129
+ * @template CSSProperty - The key of a CSS property for which values are defined.
130
+ */
131
+ type HoneyResponsiveCSSPropertyValue<CSSProperty extends keyof CSS.Properties> = Partial<Record<HoneyBreakpointName, HoneyCSSColorValue<CSSProperty> | HoneyCSSPropertyValueFn<CSSProperty>>>;
132
+ /**
133
+ * Represents a CSS property value that can be either a single value or a responsive value.
134
+ *
135
+ * This type can be one of the following:
136
+ * - A standard CSS property value.
137
+ * - A numeric value for dimension properties.
138
+ * - A function that generates the value based on the CSS property.
139
+ * - A responsive value where each breakpoint maps to a specific CSS property value.
140
+ *
141
+ * @template CSSProperty - The key of a CSS property to check.
142
+ */
143
+ export type HoneyCSSPropertyValue<CSSProperty extends keyof CSS.Properties> = HoneyCSSColorValue<CSSProperty> | HoneyCSSPropertyValueFn<CSSProperty> | HoneyResponsiveCSSPropertyValue<CSSProperty>;
144
+ /**
145
+ * Defines a type representing a set of CSS properties where each property key is prefixed with a dollar sign ($).
146
+ */
147
+ export type HoneyCSSProperties = Partial<{
148
+ [CSSProperty in keyof CSS.Properties as `$${CSSProperty}`]: HoneyCSSPropertyValue<CSSProperty>;
149
+ }>;
150
+ /**
151
+ * Represents the state of the screen layout.
152
+ */
153
+ export type HoneyScreenState = {
154
+ /** Indicates if the screen size is extra-small (xs). */
155
+ isXs: boolean;
156
+ /** Indicates if the screen size is small (sm). */
157
+ isSm: boolean;
158
+ /** Indicates if the screen size is medium (md). */
159
+ isMd: boolean;
160
+ /** Indicates if the screen size is large (lg). */
161
+ isLg: boolean;
162
+ /** Indicates if the screen size is extra-large (xl). */
163
+ isXl: boolean;
164
+ /** Indicates if the screen orientation is portrait. */
165
+ isPortrait: boolean;
166
+ /** Indicates if the screen orientation is landscape. */
167
+ isLandscape: boolean;
168
+ };
169
+ export type HoneyContainer = {
170
+ /**
171
+ * Max container width in any CSS distance value.
172
+ */
173
+ maxWidth: HoneyCSSDimensionValue;
174
+ };
175
+ /**
176
+ * Defines different spacing sizes available in the theme.
177
+ */
178
+ export type HoneySpacings = {
179
+ /**
180
+ * The base spacing value in pixels.
181
+ */
182
+ base: number;
183
+ small?: number;
184
+ medium?: number;
185
+ large?: number;
186
+ };
187
+ /**
188
+ * Defines the color palette used in the theme.
189
+ */
190
+ export interface BaseHoneyColors {
191
+ /**
192
+ * Used for elements that require high visibility and emphasis, such as primary buttons, call-to-action elements,
193
+ * and important elements like headers or titles.
194
+ */
195
+ primary: Record<string, HoneyCSSColor>;
196
+ /**
197
+ * Used to complement the primary color and add visual interest.
198
+ * Often used for secondary buttons, borders, and decorative elements to provide contrast and balance within the design.
199
+ * Helps create a cohesive visual hierarchy by providing variation in color tones.
200
+ */
201
+ secondary: Record<string, HoneyCSSColor>;
202
+ /**
203
+ * Used to draw attention to specific elements or interactions.
204
+ * Often applied to interactive elements like links, icons, or tooltips to indicate their interactive nature.
205
+ * Can be used sparingly to highlight important information or to create visual focal points.
206
+ */
207
+ accent: Record<string, HoneyCSSColor>;
208
+ /**
209
+ * Used for backgrounds, text, and other elements where a subtle, non-distracting color is desired.
210
+ * Provides a versatile palette for elements like backgrounds, borders, text, and icons, allowing other colors to stand
211
+ * out more prominently. Helps maintain balance and readability without overwhelming the user with too much color.
212
+ */
213
+ neutral: Record<string, HoneyCSSColor>;
214
+ /**
215
+ * Used to indicate successful or positive actions or states.
216
+ * Often applied to elements like success messages, notifications, or icons to convey successful completion of tasks or operations.
217
+ * Provides visual feedback to users to indicate that their actions were successful.
218
+ */
219
+ success: Record<string, HoneyCSSColor>;
220
+ /**
221
+ * Used to indicate cautionary or potentially risky situations.
222
+ * Applied to elements like warning messages, alerts, or icons to notify users about potential issues or actions that require attention.
223
+ * Helps users recognize and address potential problems or risks before they escalate.
224
+ */
225
+ warning: Record<string, HoneyCSSColor>;
226
+ /**
227
+ * Used to indicate errors, critical issues, or potentially destructive actions.
228
+ * Applied to elements like error messages, validation indicators, form fields, or delete buttons to alert users about incorrect input,
229
+ * system errors, or actions that may have irreversible consequences. Provides visual feedback to prompt users to
230
+ * take corrective actions or seek assistance when encountering errors or potentially risky actions.
231
+ */
232
+ error: Record<string, HoneyCSSColor>;
233
+ }
234
+ /**
235
+ * Example of augmenting the colors interface.
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * declare module '@react-hive/honey-layout' {
240
+ * interface HoneyColors {
241
+ * neutral: Record<'charcoalDark' | 'charcoalGray' | 'crimsonRed', HoneyColor>;
242
+ * }
243
+ * }
244
+ * ```
245
+ */
246
+ export interface HoneyColors extends BaseHoneyColors {
247
+ }
248
+ /**
249
+ * Generates a union of all possible color keys by combining each property of `HoneyColors` with its corresponding keys.
250
+ *
251
+ * This type iterates over each key in the `HoneyColors` interface and creates a string template,
252
+ * which combines the color type with each of its keys. The result is a union of all possible color keys.
253
+ *
254
+ * @example
255
+ *
256
+ * Given the `HoneyColors` interface:
257
+ * ```typescript
258
+ * interface HoneyColors {
259
+ * primary: Record<'blue' | 'green', HoneyColor>;
260
+ * neutral: Record<'charcoalDark' | 'charcoalGray' | 'crimsonRed', HoneyColor>;
261
+ * }
262
+ * ```
263
+ *
264
+ * The resulting `HoneyColorKey` type will be:
265
+ * ```typescript
266
+ * type HoneyColorKey = 'neutral.charcoalDark' | 'neutral.charcoalGray' | 'neutral.crimsonRed' | 'primary.blue' | 'primary.green';
267
+ * ```
268
+ */
269
+ export type HoneyColorKey = {
270
+ [ColorType in keyof HoneyColors]: `${ColorType}.${keyof HoneyColors[ColorType] & string}`;
271
+ }[keyof HoneyColors];
272
+ export type HoneyFont = {
273
+ size: number;
274
+ family?: string;
275
+ weight?: number;
276
+ lineHeight?: number;
277
+ letterSpacing?: number;
278
+ };
279
+ /**
280
+ * Example of augmenting the fonts interface.
281
+ *
282
+ * @example
283
+ * ```typescript
284
+ * declare module '@react-hive/honey-layout' {
285
+ * interface HoneyFonts {
286
+ * body: HoneyFont;
287
+ * caption: HoneyFont;
288
+ * }
289
+ * }
290
+ * ```
291
+ */
292
+ export interface HoneyFonts {
293
+ [key: string]: HoneyFont;
294
+ }
295
+ export type HoneyFontName = keyof HoneyFonts;
296
+ /**
297
+ * Represents a map of dimension names to CSS distance values.
298
+ */
299
+ export interface HoneyDimensions {
300
+ [key: string]: HoneyCSSDimensionValue;
301
+ }
302
+ export type HoneyDimensionName = keyof HoneyDimensions;
303
+ /**
304
+ * Represents the theme configuration.
305
+ */
306
+ export interface BaseHoneyTheme {
307
+ /**
308
+ * Breakpoints for responsive design, where keys are breakpoint names and values are breakpoint values.
309
+ */
310
+ breakpoints: Partial<HoneyBreakpoints>;
311
+ /**
312
+ * Configuration for the container.
313
+ */
314
+ container: Partial<HoneyContainer>;
315
+ /**
316
+ * Spacing values used throughout the theme.
317
+ */
318
+ spacings: HoneySpacings;
319
+ /**
320
+ * Font settings used throughout the theme.
321
+ */
322
+ fonts: HoneyFonts;
323
+ /**
324
+ * Color palette used throughout the theme.
325
+ */
326
+ colors: HoneyColors;
327
+ /**
328
+ * Dimension values used throughout the theme.
329
+ */
330
+ dimensions: HoneyDimensions;
331
+ }
332
+ export interface HoneyTheme extends BaseHoneyTheme {
333
+ }
334
+ declare module 'styled-components' {
335
+ interface DefaultTheme extends HoneyTheme {
336
+ }
337
+ }
338
+ export type HoneyThemedProps<T = unknown> = {
339
+ theme: HoneyTheme;
340
+ } & T;
341
+ export type ComponentWithAs<T, P = object> = {
342
+ as?: string | ComponentType<P>;
343
+ } & T;
344
+ export type HoneyModifierResultFn = () => Interpolation<{
345
+ theme: HoneyTheme;
346
+ }>;
347
+ export type HoneyModifier<Config = unknown> = (config?: Config) => HoneyModifierResultFn;
348
+ /**
349
+ * Type definition for status content options in a component.
350
+ *
351
+ * This type is used to provide properties for handling different states of a component,
352
+ * such as loading, error, and no content states, along with the content to display in each state.
353
+ *
354
+ * @template T - An optional generic type parameter to extend the type with additional properties.
355
+ */
356
+ export type HoneyStatusContentOptions<T = unknown> = {
357
+ /**
358
+ * A flag indicating whether the component is in a loading state.
359
+ *
360
+ * @default false
361
+ */
362
+ isLoading?: boolean;
363
+ /**
364
+ * A flag indicating whether the component has encountered an error.
365
+ *
366
+ * @default false
367
+ */
368
+ isError?: boolean;
369
+ /**
370
+ * A flag indicating whether the component has no content to display.
371
+ *
372
+ * @default false
373
+ */
374
+ isNoContent?: boolean;
375
+ /**
376
+ * The content to display when the component is in a loading state.
377
+ *
378
+ * @default null
379
+ */
380
+ loadingContent?: ReactNode;
381
+ /**
382
+ * The content to display when the component has encountered an error.
383
+ *
384
+ * @default null
385
+ */
386
+ errorContent?: ReactNode;
387
+ /**
388
+ * The content to display when the component has no content to display.
389
+ *
390
+ * @default null
391
+ */
392
+ noContent?: ReactNode;
393
+ } & T;
394
+ /**
395
+ * Represents an item that has been flattened with additional properties for hierarchical data structures.
396
+ *
397
+ * @template OriginItem - The type of the original item.
398
+ * @template NestedListKey - The key within `Item` that contains nested items or lists.
399
+ */
400
+ export type HoneyFlattenedItem<OriginItem extends object, NestedListKey extends string> = Omit<OriginItem, NestedListKey> & {
401
+ /**
402
+ * Optional id of the parent item in the flattened structure.
403
+ * Used to establish parent-child relationships in hierarchical data.
404
+ */
405
+ parentId: OriginItem[KeysWithNonArrayValues<OriginItem>] | undefined;
406
+ /**
407
+ * The depth level of the item in the flattened structure.
408
+ * Indicates how deep the item is nested within the hierarchy.
409
+ */
410
+ depthLevel: number;
411
+ /**
412
+ * The total number of nested items within the current item.
413
+ * Helps to keep track of the size of the nested structure.
414
+ *
415
+ * @default 0
416
+ */
417
+ totalNestedItems: number;
418
+ };
419
+ export {};
@@ -0,0 +1,121 @@
1
+ import { HoneyCSSMediaRule, HoneyFlattenedItem, HoneyHEXColor, KeysWithArrayValues, KeysWithNonArrayValues, KeysWithStringValues } from './types';
2
+ export declare const camelToDashCase: (inputString: string) => string;
3
+ /**
4
+ * Splits a string into an array of filtered from redundant spaces words.
5
+ *
6
+ * @param {string} inputString - The input string to be split.
7
+ *
8
+ * @returns {string[]} An array of words from the input string.
9
+ */
10
+ export declare const splitStringIntoWords: (inputString: string) => string[];
11
+ /**
12
+ * Converts a pixel value to rem.
13
+ *
14
+ * @param px - The pixel value to be converted to rem.
15
+ * @param base - The base value for conversion. Default is 16, which is the typical root font size.
16
+ *
17
+ * @returns The value in rem as a string.
18
+ */
19
+ export declare const pxToRem: (px: number, base?: number) => string;
20
+ /**
21
+ * Calculates the Euclidean distance between two points in 2D space.
22
+ *
23
+ * @param {number} startX - The X coordinate of the starting point.
24
+ * @param {number} startY - The Y coordinate of the starting point.
25
+ * @param {number} endX - The X coordinate of the ending point.
26
+ * @param {number} endY - The Y coordinate of the ending point.
27
+ *
28
+ * @returns {number} - The Euclidean distance between the two points.
29
+ */
30
+ export declare const calculateEuclideanDistance: (startX: number, startY: number, endX: number, endY: number) => number;
31
+ /**
32
+ * Calculates the moving speed.
33
+ *
34
+ * @param {number} delta - The change in position (distance).
35
+ * @param {number} elapsedTime - The time taken to move the distance.
36
+ *
37
+ * @returns {number} - The calculated speed, which is the absolute value of delta divided by elapsed time.
38
+ */
39
+ export declare const calculateMovingSpeed: (delta: number, elapsedTime: number) => number;
40
+ /**
41
+ * Calculates the specified percentage of a given value.
42
+ *
43
+ * @param {number} value - The value to calculate the percentage of.
44
+ * @param {number} percentage - The percentage to calculate.
45
+ *
46
+ * @returns {number} - The calculated percentage of the value.
47
+ */
48
+ export declare const calculatePercentage: (value: number, percentage: number) => number;
49
+ /**
50
+ * Converts a 3-character or 6-character HEX color code to an 8-character HEX with alpha (RRGGBBAA) format.
51
+ *
52
+ * @param hex - The 3-character or 6-character HEX color code (e.g., "#RGB" or "#RRGGBB" or "RGB" or "RRGGBB").
53
+ * @param alpha - The alpha transparency value between 0 (fully transparent) and 1 (fully opaque).
54
+ *
55
+ * @throws {Error} If alpha value is not between 0 and 1, or if the hex code is invalid.
56
+ *
57
+ * @returns {HoneyHEXColor} - The 8-character HEX with alpha (RRGGBBAA) format color code, or null if input is invalid.
58
+ */
59
+ export declare const convertHexToHexWithAlpha: (hex: string, alpha: number) => HoneyHEXColor;
60
+ /**
61
+ * Builds a media query string based on the provided options.
62
+ *
63
+ * @param {HoneyCSSMediaRule[]} rules - Conditions for the media query.
64
+ *
65
+ * @returns {string} The generated media query string.
66
+ */
67
+ export declare const media: (rules: HoneyCSSMediaRule[]) => string;
68
+ /**
69
+ * Get various transformation values from the transformation matrix of an element.
70
+ *
71
+ * @param {HTMLElement} element - The element with a transformation applied.
72
+ *
73
+ * @returns An object containing transformation values.
74
+ */
75
+ export declare const getTransformationValues: (element: HTMLElement) => {
76
+ translateX: number;
77
+ translateY: number;
78
+ };
79
+ /**
80
+ * Converts a nested list structure into a flat list, excluding the nested list key from the result and adding depth level, parent ID, and total nested items properties.
81
+ *
82
+ * @template OriginItem - The type of the items in the list.
83
+ *
84
+ * @param items - The array of items to be flattened. Can be undefined.
85
+ * @param itemIdKey - The key in each item that uniquely identifies it.
86
+ * @param nestedItemsKey - The key in each item that contains the nested list.
87
+ * @param result - The array that accumulates the flattened items. Defaults to an empty array.
88
+ * @param parentId - Optional. The ID of the parent item in the flattened structure. Defaults to undefined for parent item.
89
+ * @param depthLevel - Optional. The current depth level of the item in the nested structure. Defaults to 0.
90
+ *
91
+ * @returns A flat array of items, excluding the nested list key and including `depthLevel`, `parentId`, and `totalNestedItems` properties.
92
+ */
93
+ export declare const flattenNestedList: <OriginItem extends object>(items: OriginItem[] | undefined, itemIdKey: KeysWithNonArrayValues<OriginItem>, nestedItemsKey: KeysWithArrayValues<OriginItem>, result?: HoneyFlattenedItem<OriginItem, KeysWithArrayValues<OriginItem>>[], parentId?: OriginItem[KeysWithNonArrayValues<OriginItem>] | undefined, depthLevel?: number) => HoneyFlattenedItem<OriginItem, KeysWithArrayValues<OriginItem>>[];
94
+ /**
95
+ * Filters flattened items based on the specified parent ID and an optional predicate.
96
+ *
97
+ * @template OriginItem - The type of the items in the list.
98
+ * @template NestedListKey - The key within `Item` that contains nested items or lists.
99
+ *
100
+ * @param flattenedItems - The array of flattened items to filter.
101
+ * @param parentId - The parent ID to filter the items by.
102
+ * @param predicate - Optional. A function to further filter the flattened items that match the parent ID.
103
+ *
104
+ * @returns An array of flattened items that match the specified parent ID and predicate.
105
+ */
106
+ export declare const filterFlattenedItems: <OriginItem extends object, NestedListKey extends string>(flattenedItems: HoneyFlattenedItem<OriginItem, NestedListKey>[], parentId: OriginItem[KeysWithNonArrayValues<OriginItem>], predicate?: (flattenedItem: HoneyFlattenedItem<OriginItem, NestedListKey>) => boolean) => HoneyFlattenedItem<OriginItem, NestedListKey>[];
107
+ /**
108
+ * Searches through a list of flattened items to find matches based on a search query.
109
+ * The search considers both parent and nested items and ensures that matching items and their parents are included in the result.
110
+ *
111
+ * @template OriginItem - The type of the original item.
112
+ * @template NestedListKey - The key within the item that contains nested items or lists.
113
+ *
114
+ * @param flattenedItems - The array of flattened items to search through.
115
+ * @param itemIdKey - The key used to identify each item uniquely.
116
+ * @param valueKey - The key in each item that contains the searchable value.
117
+ * @param searchQuery - The search query string used to match items.
118
+ *
119
+ * @returns An array of matched flattened items, including their parents if applicable.
120
+ */
121
+ export declare const searchFlattenedItems: <OriginItem extends object, NestedListKey extends string>(flattenedItems: HoneyFlattenedItem<OriginItem, NestedListKey>[], itemIdKey: KeysWithNonArrayValues<OriginItem>, valueKey: KeysWithStringValues<OriginItem>, searchQuery: string) => HoneyFlattenedItem<OriginItem, NestedListKey>[];
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@react-hive/honey-layout",
3
+ "version": "1.0.0-beta",
4
+ "description": "",
5
+ "keywords": [
6
+ "react",
7
+ "layout",
8
+ "theme"
9
+ ],
10
+ "homepage": "https://react-honey-layout.netlify.app",
11
+ "bugs": {
12
+ "url": "https://github.com/React-Hive/honey-layout/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+ssh://git@github.com/React-Hive/honey-layout.git"
17
+ },
18
+ "author": "Mykhailo Aliinyk <m.aliynik@gmail.com>",
19
+ "license": "MIT",
20
+ "scripts": {
21
+ "start": "vite serve --config vite-docs.config.ts",
22
+ "test": "jest --collect-coverage",
23
+ "build:lib": "vite build --config vite-lib.config.ts",
24
+ "build:docs": "vite build --config vite-docs.config.ts"
25
+ },
26
+ "type": "module",
27
+ "main": "dist/index.js",
28
+ "types": "dist/index.d.ts",
29
+ "files": [
30
+ "dist"
31
+ ],
32
+ "peerDependencies": {
33
+ "@mdx-js/react": "3.0.1",
34
+ "react": "18.2.0",
35
+ "react-dom": "18.2.0",
36
+ "react-router-dom": "6.24.1",
37
+ "styled-components": "5.3.9",
38
+ "highlight.js": "11.10.0"
39
+ },
40
+ "dependencies": {
41
+ "lodash.merge": "4.6.2",
42
+ "lodash.debounce": "4.0.8",
43
+ "csstype": "3.1.3"
44
+ },
45
+ "devDependencies": {
46
+ "@testing-library/react": "16.0.0",
47
+ "@types/jest": "29.5.12",
48
+ "@typescript-eslint/eslint-plugin": "7.16.0",
49
+ "@typescript-eslint/parser": "7.16.0",
50
+ "@types/react": "18.2.78",
51
+ "@types/react-dom": "18.2.25",
52
+ "@types/styled-components": "5.1.34",
53
+ "@types/mdx": "2.0.13",
54
+ "@types/lodash.merge": "4.6.9",
55
+ "@types/lodash.debounce": "4.0.9",
56
+ "@vitejs/plugin-react": "4.3.1",
57
+ "@mdx-js/rollup": "3.0.1",
58
+ "eslint": "8.57.0",
59
+ "eslint-config-airbnb": "19.0.4",
60
+ "eslint-config-airbnb-typescript": "18.0.0",
61
+ "eslint-config-prettier": "9.1.0",
62
+ "eslint-plugin-import": "2.29.1",
63
+ "eslint-plugin-prettier": "5.2.1",
64
+ "jest": "29.7.0",
65
+ "jest-environment-jsdom": "29.7.0",
66
+ "prettier": "3.3.3",
67
+ "ts-jest": "29.2.4",
68
+ "typescript": "5.4.5",
69
+ "vite": "5.4.0",
70
+ "vite-plugin-dts": "4.0.2",
71
+ "vite-plugin-checker": "0.7.2"
72
+ },
73
+ "jest": {
74
+ "preset": "ts-jest",
75
+ "testEnvironment": "jsdom",
76
+ "testMatch": [
77
+ "**/src/**/__tests__/**/*.tsx"
78
+ ]
79
+ },
80
+ "browserslist": [
81
+ "defaults",
82
+ "not IE 11"
83
+ ]
84
+ }