@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.
package/dist/utils.d.ts CHANGED
@@ -77,45 +77,92 @@ export declare const getTransformationValues: (element: HTMLElement) => {
77
77
  translateY: number;
78
78
  };
79
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.
80
+ * Recursively converts a nested list structure into a flat list. It excludes the nested list key from the result
81
+ * while adding hierarchical metadata, such as `depthLevel`, `parentId`, and `totalNestedItems` to each flattened item.
82
+ *
83
+ * This function is useful for flattening deeply nested tree-like structures (e.g., categories, folders)
84
+ * while preserving their relationships and depth levels in the hierarchy.
85
+ *
86
+ * @template OriginItem - The type of the items in the nested list.
87
+ *
88
+ * @param items - The array of items to be flattened. If undefined, it returns an empty array.
89
+ * @param itemIdKey - The key in each item that uniquely identifies it (e.g., 'id').
90
+ * @param nestedItemsKey - The key in each item that contains the nested items or list (e.g., 'children').
91
+ * @param flattenedItemsResult - An array that accumulates the flattened items. Defaults to an empty array.
92
+ * @param parentId - Optional. The ID of the parent item in the flattened structure. Defaults to undefined for top-level items.
93
+ * @param depthLevel - Optional. The current depth level of the item in the nested structure. Defaults to 0 for top-level items.
94
+ *
95
+ * @returns A flat array of items, where the nested list key is removed, and each item includes:
96
+ * - `parentId`: ID of its parent item in the flattened structure (undefined for top-level items).
97
+ * - `depthLevel`: The depth level of the item in the hierarchy, with 0 being the top-level.
98
+ * - `totalNestedItems`: The total number of direct child items within the current item (defaults to 0 for leaf nodes).
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * const nestedData = [
103
+ * { id: 1, name: 'Item 1', children: [{ id: 2, name: 'Item 1.1' }] },
104
+ * { id: 3, name: 'Item 2', children: [] },
105
+ * ];
106
+ *
107
+ * const flatList = flattenNestedList(nestedData, 'id', 'children');
108
+ *
109
+ * // Output:
110
+ * // [
111
+ * // { id: 1, name: 'Item 1', parentId: undefined, depthLevel: 0, totalNestedItems: 1 },
112
+ * // { id: 2, name: 'Item 1.1', parentId: 1, depthLevel: 1, totalNestedItems: 0 },
113
+ * // { id: 3, name: 'Item 2', parentId: undefined, depthLevel: 0, totalNestedItems: 0 }
114
+ * // ]
115
+ * ```
116
+ */
117
+ 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>[];
118
+ /**
119
+ * Filters a list of flattened items based on a specified parent ID and an optional predicate function.
81
120
  *
82
- * @template OriginItem - The type of the items in the list.
121
+ * This utility is useful for extracting items that share the same parent in a flattened hierarchical
122
+ * structure, such as categories or tree-like data. Optionally, it allows further filtering through a
123
+ * custom predicate function.
83
124
  *
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.
125
+ * @template OriginItem - The type of the items in the flattened list.
126
+ * @template NestedListKey - The key within `OriginItem` that contains nested items or lists.
90
127
  *
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, typeof nestedItemsKey>[], parentId?: OriginItem[KeysWithNonArrayValues<OriginItem>] | undefined, depthLevel?: number) => HoneyFlattenedItem<OriginItem, typeof nestedItemsKey>[];
94
- /**
95
- * Filters flattened items based on the specified parent ID and an optional predicate.
128
+ * @param flattenedItems - The array of flattened items to filter, which contains items with hierarchical metadata.
129
+ * @param parentId - The parent ID to filter the items by. Only items with this parent ID will be included in the result.
130
+ * @param predicate - Optional. A custom function to apply additional filtering logic on items that match the parent ID.
96
131
  *
97
- * @template OriginItem - The type of the items in the list.
98
- * @template NestedListKey - The key within `Item` that contains nested items or lists.
132
+ * @returns An array of flattened items that match the specified `parentId`, and if provided, the `predicate` function.
99
133
  *
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.
134
+ * @example
135
+ * ```ts
136
+ * const filteredItems = filterFlattenedItems(flatList, 1, item => item.depthLevel > 1);
103
137
  *
104
- * @returns An array of flattened items that match the specified parent ID and predicate.
138
+ * // This would return items with `parentId` equal to 1, and where `depthLevel` is greater than 1.
139
+ * ```
105
140
  */
106
141
  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
142
  /**
108
143
  * 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.
144
+ * This function considers both the items themselves and their parents in the hierarchy, ensuring that
145
+ * any matching items and their respective parents are included in the result.
146
+ *
147
+ * The search is case-insensitive and can handle partial matches, making it useful for dynamic filtering
148
+ * of hierarchical data such as categories or trees.
110
149
  *
111
150
  * @template OriginItem - The type of the original item.
112
- * @template NestedListKey - The key within the item that contains nested items or lists.
151
+ * @template NestedListKey - The key within `OriginItem` that contains nested items or lists.
152
+ *
153
+ * @param flattenedItems - The array of flattened items to search through, which may include hierarchical metadata.
154
+ * @param itemIdKey - The key used to uniquely identify each item (e.g., 'id').
155
+ * @param valueKey - The key in each item that contains the value to be searched (e.g., 'name').
156
+ * @param searchQuery - The query string used to filter items. Supports partial matches.
157
+ *
158
+ * @returns An array of matched flattened items, including their parent items if applicable.
113
159
  *
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.
160
+ * @example
161
+ * ```ts
162
+ * const searchResults = searchFlattenedItems(flatList, 'id', 'name', 'search term');
118
163
  *
119
- * @returns An array of matched flattened items, including their parents if applicable.
164
+ * // This will return items where the 'name' field matches the search term,
165
+ * // including any relevant parent items in the hierarchy.
166
+ * ```
120
167
  */
121
168
  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 CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@react-hive/honey-layout",
3
- "version": "1.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "react",
7
7
  "layout",
8
- "theme"
8
+ "theme",
9
+ "responsive"
9
10
  ],
10
11
  "homepage": "https://react-honey-layout.netlify.app",
11
12
  "bugs": {
@@ -31,10 +32,10 @@
31
32
  ],
32
33
  "peerDependencies": {
33
34
  "@mdx-js/react": "3.0.1",
34
- "react": "18.2.0",
35
- "react-dom": "18.2.0",
36
- "react-router-dom": "6.26.1",
37
- "styled-components": "5.3.11",
35
+ "react": ">=18.0.0",
36
+ "react-dom": ">=18.0.0",
37
+ "react-router-dom": "6.26.2",
38
+ "styled-components": "6.1.13",
38
39
  "highlight.js": "11.10.0"
39
40
  },
40
41
  "dependencies": {
@@ -44,12 +45,11 @@
44
45
  },
45
46
  "devDependencies": {
46
47
  "@testing-library/react": "16.0.1",
47
- "@types/jest": "29.5.12",
48
+ "@types/jest": "29.5.13",
48
49
  "@typescript-eslint/eslint-plugin": "7.18.0",
49
50
  "@typescript-eslint/parser": "7.18.0",
50
- "@types/react": "18.2.79",
51
- "@types/react-dom": "18.2.25",
52
- "@types/styled-components": "5.1.34",
51
+ "@types/react": ">=18.0.0",
52
+ "@types/react-dom": ">=18.0.0",
53
53
  "@types/mdx": "2.0.13",
54
54
  "@types/lodash.merge": "4.6.9",
55
55
  "@types/lodash.debounce": "4.0.9",
@@ -65,9 +65,9 @@
65
65
  "jest-environment-jsdom": "29.7.0",
66
66
  "prettier": "3.3.3",
67
67
  "ts-jest": "29.2.5",
68
- "typescript": "5.5.4",
69
- "vite": "5.4.3",
70
- "vite-plugin-dts": "4.1.0",
68
+ "typescript": "5.6.2",
69
+ "vite": "5.4.7",
70
+ "vite-plugin-dts": "4.2.2",
71
71
  "vite-plugin-checker": "0.8.0"
72
72
  },
73
73
  "jest": {