{"version":3,"file":"SideNavSortableList.cjs","names":["_react","require","_SortableList","_jsxRuntime","SideNavSortableList","items","onChange","parentId","processSideNavItems","depth","processedItems","useMemo","sortableItems","map","item","sortableItem","renderItem","useCallback","jsx","SortableList","Item","id","isDisabled","isSelected","isSortable","label","children","navItem","MemoizedSideNavSortableList","exports","memo","displayName"],"sources":["../../../../src/ui-shell/SideNav/SideNavSortableList.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { UniqueIdentifier } from \"@dnd-kit/core\";\nimport { memo, useCallback, useMemo } from \"react\";\n\nimport type { SideNavItem } from \"./types.js\";\n\nimport { BaseItem, SortableList } from \"./SortableList/SortableList.js\";\n\nexport type SideNavSortableListProps = {\n  /**\n   * The depth level for nested items\n   */\n  depth?: number;\n  /**\n   * The nav items to render as sortable list\n   */\n  items: SideNavItem[];\n  /**\n   * Callback when items are reordered\n   */\n  onChange: (\n    parentId: string,\n    activeId: UniqueIdentifier,\n    activeIndex: number,\n    overIndex: number,\n  ) => void;\n  /**\n   * The parent ID for the sortable list\n   */\n  parentId: string;\n  /**\n   * Function to process nav items into sortable items\n   */\n  processSideNavItems: (\n    items: SideNavItem[],\n    depth?: number,\n    isWithinSortableList?: boolean,\n  ) => (SideNavItem & { sortableItem: BaseItem })[];\n};\n\nconst SideNavSortableList = ({\n  items,\n  onChange,\n  parentId,\n  processSideNavItems,\n  depth = 1,\n}: SideNavSortableListProps) => {\n  const processedItems = useMemo(\n    () => processSideNavItems(items, depth, true),\n    [processSideNavItems, items, depth],\n  );\n\n  const sortableItems = useMemo(\n    () => processedItems.map((item) => item.sortableItem),\n    [processedItems],\n  );\n\n  const renderItem = useCallback(\n    (sortableItem: BaseItem) => (\n      <SortableList.Item\n        id={sortableItem.id}\n        isDisabled={sortableItem.isDisabled}\n        isSelected={sortableItem.isSelected}\n        isSortable={sortableItem.isSortable}\n        label={sortableItem.label}\n      >\n        {sortableItem.navItem}\n      </SortableList.Item>\n    ),\n    [],\n  );\n\n  return (\n    <SortableList\n      items={sortableItems}\n      onChange={onChange}\n      parentId={parentId}\n      renderItem={renderItem}\n    />\n  );\n};\n\nconst MemoizedSideNavSortableList = memo(SideNavSortableList);\nMemoizedSideNavSortableList.displayName = \"SideNavSortableList\";\n\nexport { MemoizedSideNavSortableList as SideNavSortableList };\n"],"mappings":";;;;;;AAaA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,aAAA,GAAAD,OAAA;AAAwE,IAAAE,WAAA,GAAAF,OAAA;AAjBxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyCA,MAAMG,mBAAmB,GAAGA,CAAC;EAC3BC,KAAK;EACLC,QAAQ;EACRC,QAAQ;EACRC,mBAAmB;EACnBC,KAAK,GAAG;AACgB,CAAC,KAAK;EAC9B,MAAMC,cAAc,GAAG,IAAAC,cAAO,EAC5B,MAAMH,mBAAmB,CAACH,KAAK,EAAEI,KAAK,EAAE,IAAI,CAAC,EAC7C,CAACD,mBAAmB,EAAEH,KAAK,EAAEI,KAAK,CACpC,CAAC;EAED,MAAMG,aAAa,GAAG,IAAAD,cAAO,EAC3B,MAAMD,cAAc,CAACG,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,YAAY,CAAC,EACrD,CAACL,cAAc,CACjB,CAAC;EAED,MAAMM,UAAU,GAAG,IAAAC,kBAAW,EAC3BF,YAAsB,IACrB,IAAAZ,WAAA,CAAAe,GAAA,EAAChB,aAAA,CAAAiB,YAAY,CAACC,IAAI;IAChBC,EAAE,EAAEN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