@react-hive/honey-layout 12.1.0 → 14.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.
- package/dist/components/HoneyBox/HoneyBox.d.ts +1 -1
- package/dist/components/HoneyFlex/HoneyFlex.d.ts +1 -1
- package/dist/components/HoneyGrid/HoneyGridStyled.d.ts +1 -1
- package/dist/components/HoneyGridColumn/HoneyGridColumn.types.d.ts +1 -1
- package/dist/components/HoneyGridColumn/HoneyGridColumnStyled.d.ts +12 -3
- package/dist/components/HoneyList/HoneyListStyled.d.ts +1 -1
- package/dist/components/HoneyPopup/HoneyPopupStyled.d.ts +1 -1
- package/dist/helpers/helpers.d.ts +2 -16
- package/dist/index.cjs +16 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +14214 -14431
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +22 -22
- package/dist/index.mjs.map +1 -1
- package/dist/types/data.types.d.ts +1 -33
- package/dist/types/utility.types.d.ts +0 -67
- package/dist/utils/index.d.ts +0 -1
- package/package.json +12 -12
- package/dist/utils/data-utils.d.ts +0 -91
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { RefObject } from 'react';
|
|
5
5
|
import type { HoneyStyledFunction } from '@react-hive/honey-style';
|
|
6
|
-
import type {
|
|
6
|
+
import type { Nullable } from './utility.types';
|
|
7
7
|
import type { HoneyKeyboardEventCode } from './dom.types';
|
|
8
8
|
export type HoneyEffectResultFn<Props extends object> = HoneyStyledFunction<Props>;
|
|
9
9
|
export type HoneyEffect<Config = unknown, Props extends object = object> = (config: Config) => HoneyEffectResultFn<Props>;
|
|
@@ -86,35 +86,3 @@ export interface HoneyActiveOverlay {
|
|
|
86
86
|
*/
|
|
87
87
|
notifyListeners: (targetEventType: HoneyOverlayEventType, keyCode: HoneyKeyboardEventCode, e: KeyboardEvent) => void;
|
|
88
88
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Represents an item that has been flattened from a hierarchical data structure, with additional
|
|
91
|
-
* properties to support tracking its position and relationships within the hierarchy.
|
|
92
|
-
*
|
|
93
|
-
* This type is particularly useful for scenarios where nested data structures, such as trees or
|
|
94
|
-
* lists with sub-items, need to be transformed into a flat structure while preserving the depth
|
|
95
|
-
* and parent-child relationships.
|
|
96
|
-
*
|
|
97
|
-
* @template OriginItem - The type of the original item from the hierarchical structure.
|
|
98
|
-
* @template NestedListKey - The key within `OriginItem` that contains nested items or lists.
|
|
99
|
-
*/
|
|
100
|
-
export type HoneyFlattenedItem<OriginItem extends object, NestedListKey extends string> = Omit<OriginItem, NestedListKey> & {
|
|
101
|
-
/**
|
|
102
|
-
* The optional id of the parent item in the flattened structure. This establishes the parent-child
|
|
103
|
-
* relationship and allows the reconstruction of the original hierarchy if needed.
|
|
104
|
-
*/
|
|
105
|
-
parentId: OriginItem[KeysWithNonArrayValues<OriginItem>] | undefined;
|
|
106
|
-
/**
|
|
107
|
-
* The depth level of the item in the flattened structure. This indicates how deep the item is nested
|
|
108
|
-
* within the hierarchy, starting from 0 for top-level items.
|
|
109
|
-
*
|
|
110
|
-
* @default 0
|
|
111
|
-
*/
|
|
112
|
-
depthLevel: number;
|
|
113
|
-
/**
|
|
114
|
-
* The total number of nested items that are contained within the current item. This helps to keep
|
|
115
|
-
* track of the overall size of the nested structure for each item.
|
|
116
|
-
*
|
|
117
|
-
* @default 0
|
|
118
|
-
*/
|
|
119
|
-
totalNestedItems: number;
|
|
120
|
-
};
|
|
@@ -5,70 +5,3 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export type TimeoutId = ReturnType<typeof setTimeout>;
|
|
7
7
|
export type Nullable<T> = T | null;
|
|
8
|
-
/**
|
|
9
|
-
* Extracts the keys from a given type `T` whose values match the specified `Condition`.
|
|
10
|
-
*
|
|
11
|
-
* @template T - The object type from which to extract keys.
|
|
12
|
-
* @template Condition - The condition that the type of the values must satisfy to be included.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* type Example = { a: string; b: number; c: boolean };
|
|
17
|
-
* type StringKeys = ExtractKeys<Example, string>; // "a"
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
type ExtractKeys<T, Condition> = {
|
|
21
|
-
[K in keyof T]: T[K] extends Condition ? K : never;
|
|
22
|
-
}[keyof T];
|
|
23
|
-
/**
|
|
24
|
-
* Excludes the keys from a given type `T` whose values match the specified `Condition`.
|
|
25
|
-
*
|
|
26
|
-
* @template T - The object type from which to exclude keys.
|
|
27
|
-
* @template Condition - The condition that the type of the values must satisfy to be excluded.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* type Example = { a: string; b: number; c: boolean };
|
|
32
|
-
* type NonNumberKeys = ExcludeKeys<Example, number>; // "a" | "c"
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
type ExcludeKeys<T, Condition> = {
|
|
36
|
-
[K in keyof T]: T[K] extends Condition ? never : K;
|
|
37
|
-
}[keyof T];
|
|
38
|
-
/**
|
|
39
|
-
* Extracts the keys from a given type `T` where the values are `string`, `null`, or `undefined`.
|
|
40
|
-
*
|
|
41
|
-
* @template T - The object type from which to extract string-related keys.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```ts
|
|
45
|
-
* type Example = { a: string; b: number; c: string | null };
|
|
46
|
-
* type StringKeys = KeysWithStringValues<Example>; // "a" | "c"
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export type KeysWithStringValues<T> = Extract<ExtractKeys<T, string | null | undefined>, string>;
|
|
50
|
-
/**
|
|
51
|
-
* Extracts the keys from a given type `T` where the values are arrays (`unknown[]`), `null`, or `undefined`.
|
|
52
|
-
*
|
|
53
|
-
* @template T - The object type from which to extract array-related keys.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```ts
|
|
57
|
-
* type Example = { a: string[]; b: number; c: number[] | null };
|
|
58
|
-
* type ArrayKeys = KeysWithArrayValues<Example>; // "a" | "c"
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
export type KeysWithArrayValues<T> = Extract<ExtractKeys<T, unknown[] | null | undefined>, string>;
|
|
62
|
-
/**
|
|
63
|
-
* Extracts the keys from a given type `T` where the values are **not** arrays (`unknown[]`), `null`, or `undefined`.
|
|
64
|
-
*
|
|
65
|
-
* @template T - The object type from which to extract non-array keys.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```ts
|
|
69
|
-
* type Example = { a: string; b: number; c: string[]; d: null };
|
|
70
|
-
* type NonArrayKeys = KeysWithNonArrayValues<Example>; // "a" | "b"
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
export type KeysWithNonArrayValues<T> = Extract<ExcludeKeys<T, unknown[] | null | undefined>, string>;
|
|
74
|
-
export {};
|
package/dist/utils/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-hive/honey-layout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"!dist/**/jest*"
|
|
42
42
|
],
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@react-hive/honey-style": "^
|
|
44
|
+
"@react-hive/honey-style": "^3.0.0",
|
|
45
45
|
"react": "^19.0.0",
|
|
46
46
|
"react-dom": "^19.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@floating-ui/dom": "1.7.
|
|
50
|
-
"@floating-ui/react": "0.27.
|
|
51
|
-
"@react-hive/honey-utils": "3.
|
|
49
|
+
"@floating-ui/dom": "1.7.5",
|
|
50
|
+
"@floating-ui/react": "0.27.17",
|
|
51
|
+
"@react-hive/honey-utils": "3.23.0",
|
|
52
52
|
"csstype": "3.2.3",
|
|
53
53
|
"highlight.js": "11.11.1",
|
|
54
54
|
"lodash.merge": "4.6.2",
|
|
@@ -65,28 +65,28 @@
|
|
|
65
65
|
"@types/lodash.merge": "4.6.9",
|
|
66
66
|
"@types/lodash.throttle": "4.1.9",
|
|
67
67
|
"@types/mdx": "2.0.13",
|
|
68
|
-
"@types/node": "22.19.
|
|
69
|
-
"@types/react": "^19.2.
|
|
68
|
+
"@types/node": "22.19.11",
|
|
69
|
+
"@types/react": "^19.2.13",
|
|
70
70
|
"@types/react-dom": "^19.2.3",
|
|
71
71
|
"copy-webpack-plugin": "13.0.1",
|
|
72
72
|
"css-loader": "7.1.2",
|
|
73
73
|
"eslint": "9.39.2",
|
|
74
74
|
"eslint-plugin-react": "7.37.5",
|
|
75
|
-
"html-webpack-plugin": "5.6.
|
|
75
|
+
"html-webpack-plugin": "5.6.6",
|
|
76
76
|
"husky": "9.1.7",
|
|
77
77
|
"jest": "29.7.0",
|
|
78
78
|
"jest-environment-jsdom": "29.7.0",
|
|
79
|
-
"prettier": "3.
|
|
79
|
+
"prettier": "3.8.1",
|
|
80
80
|
"style-loader": "4.0.0",
|
|
81
81
|
"ts-jest": "29.4.6",
|
|
82
82
|
"ts-loader": "9.5.4",
|
|
83
83
|
"ts-node": "10.9.2",
|
|
84
84
|
"tsx": "4.21.0",
|
|
85
85
|
"typescript": "5.9.3",
|
|
86
|
-
"typescript-eslint": "8.
|
|
87
|
-
"webpack": "5.
|
|
86
|
+
"typescript-eslint": "8.55.0",
|
|
87
|
+
"webpack": "5.105.1",
|
|
88
88
|
"webpack-cli": "6.0.1",
|
|
89
|
-
"webpack-dev-server": "5.2.
|
|
89
|
+
"webpack-dev-server": "5.2.3"
|
|
90
90
|
},
|
|
91
91
|
"jest": {
|
|
92
92
|
"preset": "ts-jest",
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import type { HoneyFlattenedItem, KeysWithArrayValues, KeysWithNonArrayValues, KeysWithStringValues } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Recursively converts a nested list structure into a flat list. It excludes the nested list key from the result
|
|
4
|
-
* while adding hierarchical metadata, such as `depthLevel`, `parentId`, and `totalNestedItems` to each flattened item.
|
|
5
|
-
*
|
|
6
|
-
* This function is useful for flattening deeply nested tree-like structures (e.g., categories, folders)
|
|
7
|
-
* while preserving their relationships and depth levels in the hierarchy.
|
|
8
|
-
*
|
|
9
|
-
* @template OriginItem - The type of the items in the nested list.
|
|
10
|
-
*
|
|
11
|
-
* @param items - The array of items to be flattened. If undefined, it returns an empty array.
|
|
12
|
-
* @param itemIdKey - The key in each item that uniquely identifies it (e.g., 'id').
|
|
13
|
-
* @param nestedItemsKey - The key in each item that contains the nested items or list (e.g., 'children').
|
|
14
|
-
* @param flattenedItemsResult - An array that accumulates the flattened items. Defaults to an empty array.
|
|
15
|
-
* @param parentId - Optional. The ID of the parent item in the flattened structure. Defaults to undefined for top-level items.
|
|
16
|
-
* @param depthLevel - Optional. The current depth level of the item in the nested structure. Defaults to 0 for top-level items.
|
|
17
|
-
*
|
|
18
|
-
* @returns A flat array of items, where the nested list key is removed, and each item includes:
|
|
19
|
-
* - `parentId`: ID of its parent item in the flattened structure (undefined for top-level items).
|
|
20
|
-
* - `depthLevel`: The depth level of the item in the hierarchy, with 0 being the top-level.
|
|
21
|
-
* - `totalNestedItems`: The total number of direct child items within the current item (defaults to 0 for leaf nodes).
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* const nestedData = [
|
|
26
|
-
* { id: 1, name: 'Item 1', children: [{ id: 2, name: 'Item 1.1' }] },
|
|
27
|
-
* { id: 3, name: 'Item 2', children: [] },
|
|
28
|
-
* ];
|
|
29
|
-
*
|
|
30
|
-
* const flatList = flattenNestedList(nestedData, 'id', 'children');
|
|
31
|
-
*
|
|
32
|
-
* // Output:
|
|
33
|
-
* // [
|
|
34
|
-
* // { id: 1, name: 'Item 1', parentId: undefined, depthLevel: 0, totalNestedItems: 1 },
|
|
35
|
-
* // { id: 2, name: 'Item 1.1', parentId: 1, depthLevel: 1, totalNestedItems: 0 },
|
|
36
|
-
* // { id: 3, name: 'Item 2', parentId: undefined, depthLevel: 0, totalNestedItems: 0 }
|
|
37
|
-
* // ]
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare const flattenNestedList: <OriginItem extends object>(items: OriginItem[] | undefined, itemIdKey: KeysWithNonArrayValues<OriginItem>, nestedItemsKey: KeysWithArrayValues<OriginItem>, flattenedItemsResult?: HoneyFlattenedItem<OriginItem, typeof nestedItemsKey>[], parentId?: OriginItem[KeysWithNonArrayValues<OriginItem>] | undefined, depthLevel?: number) => HoneyFlattenedItem<OriginItem, typeof nestedItemsKey>[];
|
|
41
|
-
/**
|
|
42
|
-
* Filters a list of flattened items based on a specified parent ID and an optional predicate function.
|
|
43
|
-
*
|
|
44
|
-
* This utility is useful for extracting items that share the same parent in a flattened hierarchical
|
|
45
|
-
* structure, such as categories or tree-like data. Optionally, it allows further filtering through a
|
|
46
|
-
* custom predicate function.
|
|
47
|
-
*
|
|
48
|
-
* @template OriginItem - The type of the items in the flattened list.
|
|
49
|
-
* @template NestedListKey - The key within `OriginItem` that contains nested items or lists.
|
|
50
|
-
*
|
|
51
|
-
* @param flattenedItems - The array of flattened items to filter, which contains items with hierarchical metadata.
|
|
52
|
-
* @param parentId - The parent ID to filter the items by. Only items with this parent ID will be included in the result.
|
|
53
|
-
* @param predicate - Optional. A custom function to apply additional filtering logic on items that match the parent ID.
|
|
54
|
-
*
|
|
55
|
-
* @returns An array of flattened items that match the specified `parentId`, and if provided, the `predicate` function.
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```ts
|
|
59
|
-
* const filteredItems = filterFlattenedItems(flatList, 1, item => item.depthLevel > 1);
|
|
60
|
-
*
|
|
61
|
-
* // This would return items with `parentId` equal to 1, and where `depthLevel` is greater than 1.
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
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>[];
|
|
65
|
-
/**
|
|
66
|
-
* Searches through a list of flattened items to find matches based on a search query.
|
|
67
|
-
* This function considers both the items themselves and their parents in the hierarchy, ensuring that
|
|
68
|
-
* any matching items and their respective parents are included in the result.
|
|
69
|
-
*
|
|
70
|
-
* The search is case-insensitive and can handle partial matches, making it useful for dynamic filtering
|
|
71
|
-
* of hierarchical data such as categories or trees.
|
|
72
|
-
*
|
|
73
|
-
* @template OriginItem - The type of the original item.
|
|
74
|
-
* @template NestedListKey - The key within `OriginItem` that contains nested items or lists.
|
|
75
|
-
*
|
|
76
|
-
* @param flattenedItems - The array of flattened items to search through, which may include hierarchical metadata.
|
|
77
|
-
* @param itemIdKey - The key used to uniquely identify each item (e.g., 'id').
|
|
78
|
-
* @param valueKey - The key in each item that contains the value to be searched (e.g., 'name').
|
|
79
|
-
* @param searchQuery - The query string used to filter items. Supports partial matches.
|
|
80
|
-
*
|
|
81
|
-
* @returns An array of matched flattened items, including their parent items if applicable.
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```ts
|
|
85
|
-
* const searchResults = searchFlattenedItems(flatList, 'id', 'name', 'search term');
|
|
86
|
-
*
|
|
87
|
-
* // This will return items where the 'name' field matches the search term,
|
|
88
|
-
* // including any relevant parent items in the hierarchy.
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
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>[];
|