@antscorp/antsomi-ui 1.3.5-beta.561 → 1.3.5-beta.562

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.
@@ -11,6 +11,7 @@ import { ENV } from '@antscorp/antsomi-ui/es/config';
11
11
  // Utils
12
12
  import { findLastMatchedItemByUrl, findPathOfActiveItem, flattenMenuArray, getMappingAppChildren, recursivePermissionMenu, } from '../utils';
13
13
  import { useCheckUserPermission } from '@antscorp/antsomi-ui/es/queries';
14
+ import { recursiveSortBy } from '@antscorp/antsomi-ui/es/utils';
14
15
  const { DEV, SANDBOX, SANDBOX_CDP } = ENV;
15
16
  export const usePermission = () => {
16
17
  const appConfig = useLeftMenuContext(store => store.appConfig);
@@ -135,7 +136,7 @@ export const usePermission = () => {
135
136
  userPermission,
136
137
  ]);
137
138
  const mappingChildrenMenuWithNoPermission = useMemo(() => getMappingAppChildren({
138
- menuList: (menuList === null || menuList === void 0 ? void 0 : menuList.rows) || [],
139
+ menuList: recursiveSortBy((menuList === null || menuList === void 0 ? void 0 : menuList.rows) || [], 'children', ['level_position']) || [],
139
140
  auth,
140
141
  dashboardList,
141
142
  destinationChannelEntries: destinationChannel === null || destinationChannel === void 0 ? void 0 : destinationChannel.entries,
@@ -137,3 +137,13 @@ export declare function splitTextByNewline(text?: string): string[];
137
137
  * @returns {any | null} The parsed JSON object if successful, or `null` if the parsing fails or the key does not exist.
138
138
  */
139
139
  export declare function parseJSONFromLocalStorage<T = any>(key: string): T | null;
140
+ /**
141
+ * Recursively sorts an array of objects by specified keys and also sorts their nested children arrays.
142
+ *
143
+ * @template T - The type of the objects within the array.
144
+ * @param {T[]} arr - The array of objects to be sorted.
145
+ * @param {keyof T} [childrenKey='children'] - The key used to identify the children array in each object.
146
+ * @param {Array<keyof T>} [sortByKeys=[]] - The keys used to sort the objects.
147
+ * @returns {T[]} - The sorted array with each object’s children arrays also sorted recursively.
148
+ */
149
+ export declare const recursiveSortBy: <T = any>(arr: T[], childrenKey?: keyof T, sortByKeys?: (keyof T)[]) => T[];
@@ -6,6 +6,7 @@ import uniqid from 'uniqid';
6
6
  import { MESSAGES, PORTAL_KEYS } from '@antscorp/antsomi-ui/es/services/constants';
7
7
  // Utils
8
8
  import { handleError } from './handleError';
9
+ import { sortBy } from 'lodash';
9
10
  const PATH = 'src/utils/common.ts';
10
11
  /**
11
12
  * Function to reorder list
@@ -607,3 +608,15 @@ export function parseJSONFromLocalStorage(key) {
607
608
  return null;
608
609
  }
609
610
  }
611
+ /**
612
+ * Recursively sorts an array of objects by specified keys and also sorts their nested children arrays.
613
+ *
614
+ * @template T - The type of the objects within the array.
615
+ * @param {T[]} arr - The array of objects to be sorted.
616
+ * @param {keyof T} [childrenKey='children'] - The key used to identify the children array in each object.
617
+ * @param {Array<keyof T>} [sortByKeys=[]] - The keys used to sort the objects.
618
+ * @returns {T[]} - The sorted array with each object’s children arrays also sorted recursively.
619
+ */
620
+ export const recursiveSortBy = (arr, childrenKey = 'children', sortByKeys = []) => sortBy(arr, [...sortByKeys]).map(item => (Object.assign(Object.assign({}, item), (item[childrenKey] && {
621
+ [childrenKey]: recursiveSortBy(item[childrenKey], childrenKey, sortByKeys),
622
+ }))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.561",
3
+ "version": "1.3.5-beta.562",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",