@frontify/fondue 13.7.2 → 13.7.3

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/dist/components/Flyout/helpers/getVerticalPositioning.es.js.map +1 -1
  2. package/dist/components/InputLabel/InputLabel.es.js.map +1 -1
  3. package/dist/components/Tree/Tree.es.js.map +1 -1
  4. package/dist/components/Tree/TreeContext.es.js.map +1 -1
  5. package/dist/components/Tree/TreeItem/DragHandle.es.js.map +1 -1
  6. package/dist/components/Tree/TreeItem/ExpandButton.es.js.map +1 -1
  7. package/dist/components/Tree/TreeItem/TreeItem.es.js.map +1 -1
  8. package/dist/components/Tree/TreeItem/TreeItemMultiselect.es.js.map +1 -1
  9. package/dist/components/Tree/TreeItem/TreeItemOverlay.es.js.map +1 -1
  10. package/dist/components/Tree/TreeItem/useMultiselectTreeItem.es.js.map +1 -1
  11. package/dist/components/Tree/TreeItem/useTreeItem.es.js.map +1 -1
  12. package/dist/components/Tree/helpers/constants.es.js.map +1 -1
  13. package/dist/components/Tree/helpers/getMovementAnnouncements.es.js.map +1 -1
  14. package/dist/components/Tree/helpers/multiselect.es.js.map +1 -1
  15. package/dist/components/Tree/helpers/multiselectTreeItemstyling.es.js.map +1 -1
  16. package/dist/components/Tree/helpers/nodes.es.js.map +1 -1
  17. package/dist/components/Tree/helpers/projection.es.js.map +1 -1
  18. package/dist/components/Tree/helpers/reducer.es.js.map +1 -1
  19. package/dist/components/Tree/helpers/sensorsActivationConstraint.es.js.map +1 -1
  20. package/dist/components/Tree/helpers/treeHandleKeyDown.es.js.map +1 -1
  21. package/dist/components/Tree/types.es.js.map +1 -1
  22. package/dist/components/Tree/utils/keyboardCoordinates.es.js.map +1 -1
  23. package/dist/components/Tree/utils/removeFragmentsAndEnrichChildren.es.js.map +1 -1
  24. package/dist/components/Tree/utils/useDeepCompareEffect.es.js.map +1 -1
  25. package/dist/index.cjs.js.map +1 -1
  26. package/dist/index.d.ts +261 -3
  27. package/dist/index.umd.js.map +1 -1
  28. package/dist/packages/components/style.css +1 -1
  29. package/dist/packages/rte/style.css +1 -1
  30. package/dist/tools/codemod/index.js +87 -1
  31. package/dist/tools/internal/index.js +30 -36
  32. package/package.json +6 -7
  33. package/dist/tools/sdk-cli/adapters/claude-skill/skill/SKILL.md +0 -207
  34. package/dist/tools/sdk-cli/adapters/claude-skill/skill/reference.md +0 -235
  35. package/dist/tools/sdk-cli/index.js +0 -224
@@ -1 +1 @@
1
- {"version":3,"file":"getMovementAnnouncements.es.js","sources":["../../../../src/components/Tree/helpers/getMovementAnnouncements.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { arrayMove } from '@dnd-kit/sortable';\nimport { type Dispatch, type SetStateAction, isValidElement } from 'react';\n\nimport { type TreeActive, type TreeAnnouncements, type TreeOver, type TreeState } from '../types';\n\ntype AnnouncementItem = {\n level: number;\n id: string;\n parentId?: string;\n};\n\ntype AnnouncementArgs = {\n eventName: string;\n activeId: string;\n activeTitle: string;\n overId?: string;\n overTitle?: string;\n treeState: TreeState;\n currentPosition: Nullable<{ overId: string; parentId: Nullable<string> }>;\n setCurrentPosition: Dispatch<\n SetStateAction<\n Nullable<{\n overId: string;\n parentId: Nullable<string>;\n }>\n >\n >;\n};\n\nexport const getAnnouncements = (\n treeState: TreeState,\n currentPosition: AnnouncementArgs['currentPosition'],\n setCurrentPosition: AnnouncementArgs['setCurrentPosition'],\n): TreeAnnouncements => {\n const getActiveTitle = (active: TreeActive) => {\n let title: string = active.id;\n\n const activeNode = treeState.nodes.find((node) => node.props.id === active.id);\n\n if (activeNode && isValidElement(activeNode.props.contentComponent)) {\n title = activeNode.props.contentComponent.props.title;\n } else if (activeNode?.props?.label) {\n title = activeNode.props.label;\n }\n\n return title;\n };\n\n const getOverTitle = (over: TreeOver | null) => {\n let title = over?.id;\n\n const overNode = treeState.nodes.find((node) => node.props.id === over?.id);\n\n if (overNode && isValidElement(overNode.props.contentComponent)) {\n title = overNode.props.contentComponent.props.title;\n } else if (overNode?.props?.label) {\n title = overNode.props.label;\n }\n\n return title;\n };\n\n return {\n onDragStart({ active }) {\n return `Picked up ${getActiveTitle(active) || active.id}.`;\n },\n onDragMove({ active, over }) {\n return getMovementAnnouncement({\n eventName: 'onDragMove',\n activeId: active.id,\n activeTitle: getActiveTitle(active),\n overId: over?.id,\n overTitle: getOverTitle(over),\n treeState,\n setCurrentPosition,\n currentPosition,\n });\n },\n onDragOver({ active, over }) {\n return getMovementAnnouncement({\n eventName: 'onDragOver',\n activeId: active.id,\n activeTitle: getActiveTitle(active),\n overId: over?.id,\n overTitle: getOverTitle(over),\n treeState,\n setCurrentPosition,\n currentPosition,\n });\n },\n onDragEnd({ active, over }) {\n return getMovementAnnouncement({\n eventName: 'onDragEnd',\n activeId: active.id,\n activeTitle: getActiveTitle(active),\n overId: over?.id,\n overTitle: getOverTitle(over),\n treeState,\n setCurrentPosition,\n currentPosition,\n });\n },\n onDragCancel({ active }) {\n const title = getActiveTitle(active);\n\n return `Moving was cancelled. ${title} was dropped in its original position.`;\n },\n };\n};\n\nconst getMovementAnnouncement = ({\n eventName,\n activeId,\n activeTitle,\n overId,\n overTitle,\n treeState,\n currentPosition,\n setCurrentPosition,\n}: AnnouncementArgs) => {\n const projected = treeState.projection;\n\n if (overId && projected) {\n if (eventName !== 'onDragEnd') {\n if (\n currentPosition &&\n projected.parentId === currentPosition.parentId &&\n overId === currentPosition.overId\n ) {\n return;\n } else {\n setCurrentPosition({\n parentId: projected.parentId,\n overId,\n });\n }\n }\n\n const announcementNodes: AnnouncementItem[] = treeState.nodes.map(({ props }) => ({\n id: props.id,\n level: props.level ?? 0,\n parentId: props.parentId,\n }));\n\n const overIndex = announcementNodes.findIndex(({ id }) => id === overId);\n const activeIndex = announcementNodes.findIndex(({ id }) => id === activeId);\n const sortedItems = arrayMove(announcementNodes, activeIndex, overIndex);\n\n const previousItem = sortedItems[overIndex - 1];\n\n let announcement;\n const movedVerb = eventName === 'onDragEnd' ? 'dropped' : 'moved';\n const nestedVerb = eventName === 'onDragEnd' ? 'dropped' : 'nested';\n\n if (!previousItem) {\n const nextItem = sortedItems[overIndex + 1];\n announcement = `${activeTitle} was ${movedVerb} before ${overTitle || nextItem.id}.`;\n } else {\n if (projected.depth > previousItem.level) {\n announcement = `${activeTitle} was ${nestedVerb} under ${overTitle || previousItem.id}.`;\n } else {\n let previousSibling: AnnouncementItem | undefined = previousItem;\n while (previousSibling && projected.depth < previousSibling.level) {\n const parentId: string | undefined = previousSibling.parentId;\n previousSibling = sortedItems.find(({ id }) => id === parentId);\n }\n\n if (previousSibling) {\n announcement = `${activeTitle} was ${movedVerb} after ${overTitle || previousSibling.id}.`;\n }\n }\n }\n\n return announcement;\n }\n\n return;\n};\n"],"names":["getAnnouncements","treeState","currentPosition","setCurrentPosition","getActiveTitle","active","title","activeNode","node","isValidElement","_a","getOverTitle","over","overNode","getMovementAnnouncement","eventName","activeId","activeTitle","overId","overTitle","projected","announcementNodes","props","overIndex","id","activeIndex","sortedItems","arrayMove","previousItem","announcement","movedVerb","nestedVerb","previousSibling","parentId","nextItem"],"mappings":";;AA+BO,MAAMA,IAAmB,CAC5BC,GACAC,GACAC,MACoB;AACpB,QAAMC,IAAiB,CAACC,MAAuB;;AAC3C,QAAIC,IAAgBD,EAAO;AAE3B,UAAME,IAAaN,EAAU,MAAM,KAAK,CAACO,MAASA,EAAK,MAAM,OAAOH,EAAO,EAAE;AAE7E,WAAIE,KAAcE,EAAeF,EAAW,MAAM,gBAAgB,IAC9DD,IAAQC,EAAW,MAAM,iBAAiB,MAAM,SACzCG,IAAAH,KAAA,gBAAAA,EAAY,UAAZ,QAAAG,EAAmB,UAC1BJ,IAAQC,EAAW,MAAM,QAGtBD;AAAA,EACX,GAEMK,IAAe,CAACC,MAA0B;;AAC5C,QAAIN,IAAQM,KAAA,gBAAAA,EAAM;AAElB,UAAMC,IAAWZ,EAAU,MAAM,KAAK,CAACO,MAASA,EAAK,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QAAQY,EAAgB,SAAO;AAC/D,gBAAMC,IAA+BD,EAAgB;AACrD,UAAAA,IAAkBN,EAAY,KAAK,CAAC,EAAE,IAAAF,EAAA,MAASA,MAAOS,CAAQ;AAAA,QAClE;AAEA,QAAID,MACAH,IAAe,GAAGZ,CAAW,QAAQa,CAAS,UAAUX,KAAaa,EAAgB,EAAE;AAAA,MAE/F;AAAA,SAhBe;AACf,YAAME,IAAWR,EAAYH,IAAY,CAAC;AAC1C,MAAAM,IAAe,GAAGZ,CAAW,QAAQa,CAAS,WAAWX,KAAae,EAAS,EAAE;AAAA,IACrF;AAgBA,WAAOL;AAAA,EACX;AAGJ;"}
1
+ {"version":3,"file":"getMovementAnnouncements.es.js","sources":["../../../../src/components/Tree/helpers/getMovementAnnouncements.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { arrayMove } from '@dnd-kit/sortable';\nimport { type Dispatch, type SetStateAction, isValidElement } from 'react';\n\nimport { type TreeActive, type TreeAnnouncements, type TreeOver, type TreeState } from '../types';\n\ntype AnnouncementItem = {\n level: number;\n id: string;\n parentId?: string;\n};\n\ntype AnnouncementArgs = {\n eventName: string;\n activeId: string;\n activeTitle: string;\n overId?: string;\n overTitle?: string;\n treeState: TreeState;\n currentPosition: Nullable<{ overId: string; parentId: Nullable<string> }>;\n setCurrentPosition: Dispatch<\n SetStateAction<\n Nullable<{\n overId: string;\n parentId: Nullable<string>;\n }>\n >\n >;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getAnnouncements = (\n treeState: TreeState,\n currentPosition: AnnouncementArgs['currentPosition'],\n setCurrentPosition: AnnouncementArgs['setCurrentPosition'],\n): TreeAnnouncements => {\n const getActiveTitle = (active: TreeActive) => {\n let title: string = active.id;\n\n const activeNode = treeState.nodes.find((node) => node.props.id === active.id);\n\n if (activeNode && isValidElement(activeNode.props.contentComponent)) {\n title = activeNode.props.contentComponent.props.title;\n } else if (activeNode?.props?.label) {\n title = activeNode.props.label;\n }\n\n return title;\n };\n\n const getOverTitle = (over: TreeOver | null) => {\n let title = over?.id;\n\n const overNode = treeState.nodes.find((node) => node.props.id === over?.id);\n\n if (overNode && isValidElement(overNode.props.contentComponent)) {\n title = overNode.props.contentComponent.props.title;\n } else if (overNode?.props?.label) {\n title = overNode.props.label;\n }\n\n return title;\n };\n\n return {\n onDragStart({ active }) {\n return `Picked up ${getActiveTitle(active) || active.id}.`;\n },\n onDragMove({ active, over }) {\n return getMovementAnnouncement({\n eventName: 'onDragMove',\n activeId: active.id,\n activeTitle: getActiveTitle(active),\n overId: over?.id,\n overTitle: getOverTitle(over),\n treeState,\n setCurrentPosition,\n currentPosition,\n });\n },\n onDragOver({ active, over }) {\n return getMovementAnnouncement({\n eventName: 'onDragOver',\n activeId: active.id,\n activeTitle: getActiveTitle(active),\n overId: over?.id,\n overTitle: getOverTitle(over),\n treeState,\n setCurrentPosition,\n currentPosition,\n });\n },\n onDragEnd({ active, over }) {\n return getMovementAnnouncement({\n eventName: 'onDragEnd',\n activeId: active.id,\n activeTitle: getActiveTitle(active),\n overId: over?.id,\n overTitle: getOverTitle(over),\n treeState,\n setCurrentPosition,\n currentPosition,\n });\n },\n onDragCancel({ active }) {\n const title = getActiveTitle(active);\n\n return `Moving was cancelled. ${title} was dropped in its original position.`;\n },\n };\n};\n\nconst getMovementAnnouncement = ({\n eventName,\n activeId,\n activeTitle,\n overId,\n overTitle,\n treeState,\n currentPosition,\n setCurrentPosition,\n}: AnnouncementArgs) => {\n const projected = treeState.projection;\n\n if (overId && projected) {\n if (eventName !== 'onDragEnd') {\n if (\n currentPosition &&\n projected.parentId === currentPosition.parentId &&\n overId === currentPosition.overId\n ) {\n return;\n } else {\n setCurrentPosition({\n parentId: projected.parentId,\n overId,\n });\n }\n }\n\n const announcementNodes: AnnouncementItem[] = treeState.nodes.map(({ props }) => ({\n id: props.id,\n level: props.level ?? 0,\n parentId: props.parentId,\n }));\n\n const overIndex = announcementNodes.findIndex(({ id }) => id === overId);\n const activeIndex = announcementNodes.findIndex(({ id }) => id === activeId);\n const sortedItems = arrayMove(announcementNodes, activeIndex, overIndex);\n\n const previousItem = sortedItems[overIndex - 1];\n\n let announcement;\n const movedVerb = eventName === 'onDragEnd' ? 'dropped' : 'moved';\n const nestedVerb = eventName === 'onDragEnd' ? 'dropped' : 'nested';\n\n if (!previousItem) {\n const nextItem = sortedItems[overIndex + 1];\n announcement = `${activeTitle} was ${movedVerb} before ${overTitle || nextItem.id}.`;\n } else {\n if (projected.depth > previousItem.level) {\n announcement = `${activeTitle} was ${nestedVerb} under ${overTitle || previousItem.id}.`;\n } else {\n let previousSibling: AnnouncementItem | undefined = previousItem;\n while (previousSibling && projected.depth < previousSibling.level) {\n const parentId: string | undefined = previousSibling.parentId;\n previousSibling = sortedItems.find(({ id }) => id === parentId);\n }\n\n if (previousSibling) {\n announcement = `${activeTitle} was ${movedVerb} after ${overTitle || previousSibling.id}.`;\n }\n }\n }\n\n return announcement;\n }\n\n return;\n};\n"],"names":["getAnnouncements","treeState","currentPosition","setCurrentPosition","getActiveTitle","active","title","activeNode","node","isValidElement","_a","getOverTitle","over","overNode","getMovementAnnouncement","eventName","activeId","activeTitle","overId","overTitle","projected","announcementNodes","props","overIndex","id","activeIndex","sortedItems","arrayMove","previousItem","announcement","movedVerb","nestedVerb","previousSibling","parentId","nextItem"],"mappings":";;AAkCO,MAAMA,IAAmB,CAC5BC,GACAC,GACAC,MACoB;AACpB,QAAMC,IAAiB,CAACC,MAAuB;;AAC3C,QAAIC,IAAgBD,EAAO;AAE3B,UAAME,IAAaN,EAAU,MAAM,KAAK,CAACO,MAASA,EAAK,MAAM,OAAOH,EAAO,EAAE;AAE7E,WAAIE,KAAcE,EAAeF,EAAW,MAAM,gBAAgB,IAC9DD,IAAQC,EAAW,MAAM,iBAAiB,MAAM,SACzCG,IAAAH,KAAA,gBAAA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ahB,MAAc,cAAc,YAAY;AAE3D,QAAKa;AAID,UAAIR,EAAU,QAAQQ,EAAa;AAC/B,QAAAC,IAAe,GAAGZ,CAAW,QAAQc,CAAU,UAAUZ,KAAaS,EAAa,EAAE;AAAA,WAClF;AACH,YAAII,IAAgDJ;AACpD,eAAOI,KAAmBZ,EAAU,QAAQY,EAAgB,SAAO;AAC/D,gBAAMC,IAA+BD,EAAgB;AACrD,UAAAA,IAAkBN,EAAY,KAAK,CAAC,EAAE,IAAAF,EAAA,MAASA,MAAOS,CAAQ;AAAA,QAClE;AAEA,QAAID,MACAH,IAAe,GAAGZ,CAAW,QAAQa,CAAS,UAAUX,KAAaa,EAAgB,EAAE;AAAA,MAE/F;AAAA,SAhBe;AACf,YAAME,IAAWR,EAAYH,IAAY,CAAC;AAC1C,MAAAM,IAAe,GAAGZ,CAAW,QAAQa,CAAS,WAAWX,KAAae,EAAS,EAAE;AAAA,IACrF;AAgBA,WAAOL;AAAA,EACX;AAGJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"multiselect.es.js","sources":["../../../../src/components/Tree/helpers/multiselect.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { CheckboxState } from '@components/Checkbox/Checkbox';\n\nimport { type TreeItemMultiselectProps } from '../types';\n\nimport { ROOT_ID } from './constants';\n\nexport type TreeItemMultiselectWithNodes = TreeItemMultiselectProps & {\n id: string;\n parentId: string;\n extendedId?: string;\n nodes?: TreeItemMultiselectWithNodes[];\n numChildNodes?: number;\n onSelect?: (id: string) => void;\n};\n\nexport const getMultiselectCheckBoxState = (isSelected: boolean, isPartialSelected: boolean) => {\n let theCheckboxState = CheckboxState.Unchecked;\n if (isSelected) {\n theCheckboxState = CheckboxState.Checked;\n } else if (isPartialSelected) {\n theCheckboxState = CheckboxState.Mixed;\n }\n\n return theCheckboxState;\n};\n\nexport const getSelectedChildrenItems = (\n tree: TreeItemMultiselectWithNodes[],\n selectedIds: string[],\n onlyPartial = false,\n) => {\n return tree\n .filter(\n (item) =>\n (onlyPartial ? false : selectedIds.includes(getExtendedId(item))) ||\n selectedIds.includes(convertToPartialSelectedId([getExtendedId(item)])[0]),\n )\n .map((item) => item.id);\n};\n\nexport const getSelectedTreeItem = (\n tree: TreeItemMultiselectWithNodes[],\n id: string,\n): TreeItemMultiselectWithNodes | null => {\n for (const item of tree) {\n if (item.id === id) {\n return item;\n }\n if (item.nodes && item.nodes?.length > 0) {\n const deepItem = getSelectedTreeItem(item.nodes, id);\n if (deepItem) {\n return deepItem;\n }\n }\n }\n\n return null;\n};\n\nexport const getParentSelectedTreeItem = (\n tree: TreeItemMultiselectWithNodes[],\n id: string,\n parent: TreeItemMultiselectWithNodes | null,\n): TreeItemMultiselectWithNodes | null => {\n for (const item of tree) {\n if (parent !== null && item.id === id) {\n return parent;\n }\n if (item.nodes && item.nodes?.length > 0) {\n const deepItem = getParentSelectedTreeItem(item.nodes, id, item);\n if (deepItem) {\n return deepItem;\n }\n }\n }\n return null;\n};\n\nexport const addSelectedItemsFromSelection = (\n treeItems: TreeItemMultiselectWithNodes[],\n id: string,\n newSelectedItems: string[],\n) => {\n const parentItemChecked = getParentSelectedTreeItem(treeItems, id, null);\n newSelectedItems = parentItemChecked?.id\n ? fixParentSelectionState(parentItemChecked, newSelectedItems)\n : newSelectedItems;\n\n const itemChecked = getSelectedTreeItem(treeItems, id);\n if (!itemChecked) {\n return newSelectedItems;\n }\n\n const itemCheckedExtendedId = getExtendedId(itemChecked);\n const childrenSelectedItems = getSelectedChildrenItems(itemChecked?.nodes ?? [], newSelectedItems);\n const childrenCount = itemChecked?.nodes?.length ?? 0;\n\n // Select/unselect children\n if (childrenCount) {\n const childrenIds = itemChecked?.nodes?.map((item) => getExtendedId(item)) ?? [];\n\n newSelectedItems = newSelectedItems.includes(itemCheckedExtendedId)\n ? addSelectedIds(newSelectedItems, childrenIds, false)\n : removeSelectedIds(newSelectedItems, childrenIds, false);\n\n if (childrenSelectedItems.length === 0) {\n newSelectedItems = removeSelectedIds(newSelectedItems, [itemCheckedExtendedId], true);\n }\n }\n\n // tree down\n for (const child of itemChecked?.nodes ?? []) {\n newSelectedItems = addSelectedItemsFromSelection(treeItems, child.id, newSelectedItems);\n }\n\n // tree up\n let parent = parentItemChecked;\n const treeBranch: TreeItemMultiselectWithNodes[] = [];\n while (parent !== null) {\n treeBranch.push(parent);\n parent = getParentSelectedTreeItem(treeItems, parent.id, null);\n }\n for (const item of treeBranch) {\n newSelectedItems = fixParentSelectionState(item, newSelectedItems);\n }\n\n return newSelectedItems;\n};\n\nexport const fixParentSelectionState = (parent: TreeItemMultiselectWithNodes, newSelectedItems: string[]) => {\n const parentExtendedId = getExtendedId(parent);\n const isParentSelected = newSelectedItems.includes(parentExtendedId);\n const siblingsSelectedItems = getSelectedChildrenItems(parent?.nodes ?? [], newSelectedItems);\n const siblingsPartiallySelectedItems = getSelectedChildrenItems(parent?.nodes ?? [], newSelectedItems, true);\n const siblingsCount = parent?.nodes?.length ?? 0;\n\n // Select/unselect parent\n if (siblingsSelectedItems.length === 0) {\n newSelectedItems = isParentSelected\n ? removeSelectedIds(newSelectedItems, [parentExtendedId], false)\n : newSelectedItems;\n newSelectedItems = removeSelectedIds(newSelectedItems, [parentExtendedId], true);\n } else if (siblingsSelectedItems.length === siblingsCount && siblingsPartiallySelectedItems.length === 0) {\n newSelectedItems = !isParentSelected\n ? addSelectedIds(newSelectedItems, [parentExtendedId], false)\n : newSelectedItems;\n\n newSelectedItems = removeSelectedIds(newSelectedItems, [parentExtendedId], true);\n } else if (parent?.id) {\n // flag parent as partial checked and unselect it\n newSelectedItems = addSelectedIds(newSelectedItems, [parentExtendedId], true);\n newSelectedItems = removeSelectedIds(newSelectedItems, [parentExtendedId], false);\n }\n\n return newSelectedItems;\n};\n\nexport const cleanOrphanSelectedIds = (selectIds: string[]) => {\n const orphans: string[] = [];\n let newSelectedIds: string[] = selectIds;\n\n const cleanSelectedIds = selectIds.map((extendedId) => extendedId.split('/').pop());\n\n for (const extendedId of selectIds) {\n const parentId = extendedId.split('/').shift();\n if (parentId === ROOT_ID || parentId === convertToPartialSelectedId([ROOT_ID])[0]) {\n continue;\n }\n if (\n !cleanSelectedIds.includes(parentId) &&\n !cleanSelectedIds.includes(removePartialFlagSelectedId([parentId ?? ''])[0] ?? '')\n ) {\n orphans.push(extendedId);\n }\n }\n\n if (orphans.length > 0) {\n newSelectedIds = removeSelectedIds(selectIds, orphans, false);\n newSelectedIds = cleanOrphanSelectedIds(newSelectedIds);\n }\n\n return newSelectedIds;\n};\n\nexport const convertToPartialSelectedId = (ids: string[]) => ids.map((id) => `*${id}`);\nexport const removePartialFlagSelectedId = (ids: string[]) => ids.map((id) => id.replace(/^\\*/, ''));\nexport const getExtendedId = (item: TreeItemMultiselectWithNodes) => item.extendedId ?? `${item.parentId}/${item.id}`;\n\nexport const removeSelectedIds = (ids: string[], idsToRemove: string[], partial: boolean): string[] => {\n idsToRemove = partial ? convertToPartialSelectedId(idsToRemove) : idsToRemove;\n return [...new Set(idsToRemove.length > 0 ? ids.filter((itemId: string) => !idsToRemove.includes(itemId)) : ids)];\n};\nexport const addSelectedIds = (ids: string[], idsToAdd: string[], partial: boolean) => {\n idsToAdd = (partial ? convertToPartialSelectedId(idsToAdd) : idsToAdd).filter((id) => id !== '');\n return [...new Set(idsToAdd.length > 0 ? [...ids, ...idsToAdd] : ids)];\n};\n\nexport const getNewSelectedItems = (\n id: string,\n selectedIds: string[],\n treeItems: TreeItemMultiselectWithNodes[],\n ignoreRemoveSelected = false,\n) => {\n let newSelectedItems = [];\n\n const itemToChecked = getSelectedTreeItem(treeItems, id);\n if (!itemToChecked) {\n return selectedIds;\n }\n\n const extendedId = getExtendedId(itemToChecked);\n\n if (selectedIds.includes(extendedId) && !ignoreRemoveSelected) {\n newSelectedItems = removeSelectedIds(selectedIds, [extendedId], false);\n } else {\n newSelectedItems = addSelectedIds(selectedIds, [extendedId], false);\n newSelectedItems = removeSelectedIds(newSelectedItems, [extendedId], true);\n }\n\n newSelectedItems = addSelectedItemsFromSelection(treeItems, id, newSelectedItems);\n return cleanOrphanSelectedIds(newSelectedItems);\n};\n"],"names":["getMultiselectCheckBoxState","isSelected","isPartialSelected","theCheckboxState","CheckboxState","getSelectedChildrenItems","tree","selectedIds","onlyPartial","item","getExtendedId","convertToPartialSelectedId","getSelectedTreeItem","id","_a","deepItem","getParentSelectedTreeItem","parent","addSelectedItemsFromSelection","treeItems","newSelectedItems","parentItemChecked","fixParentSelectionState","itemChecked","itemCheckedExtendedId","childrenSelectedItems","childrenIds","_b","addSelectedIds","removeSelectedIds","child","treeBranch","parentExtendedId","isParentSelected","siblingsSelectedItems","siblingsPartiallySelectedItems","siblingsCount","cleanOrphanSelectedIds","selectIds","orphans","newSelectedIds","cleanSelectedIds","extendedId","parentId","ROOT_ID","removePartialFlagSelectedId","ids","idsToRemove","partial","itemId","idsToAdd","getNewSelectedItems","ignoreRemoveSelected","itemToChecked"],"mappings":";;AAiBO,MAAMA,IAA8B,CAACC,GAAqBC,MAA+B;AAC5F,MAAIC,IAAmBC,EAAc;AACrC,SAAIH,IACAE,IAAmBC,EAAc,UAC1BF,MACPC,IAAmBC,EAAc,QAG9BD;AACX,GAEaE,IAA2B,CACpCC,GACAC,GACAC,IAAc,OAEPF,EACF;AAAA,EACG,CAACG,OACID,IAAc,KAAQD,EAAY,SAASG,EAAcD,CAAI,CAAC,MAC/DF,EAAY,SAASI,EAA2B,CAACD,EAAcD,CAAI,CAAC,CAAC,EAAE,CAAC,CAAC;AAAA,EAEhF,IAAI,CAACA,MAASA,EAAK,EAAE,GAGjBG,IAAsB,CAC/BN,GACAO,MACsC;;AACtC,aAAWJ,KAAQH,GAAM;AACrB,QAAIG,EAAK,OAAOI;AACZ,aAAOJ;AAEX,QAAIA,EAAK,WAASK,IAAAL,EAAK,UAAL,gBAAAK,EAAY,UAAS,GAAG;AACtC,YAAMC,IAAWH,EAAoBH,EAAK,OAAOI,CAAE;AACnD,UAAIE;AACA,eAAOA;AAA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GX,QAAMmC,IAAahC,EAAc2C,CAAa;AAE9C,SAAI9C,EAAY,SAASmC,CAAU,KAAK,CAACU,IACrChC,IAAmBS,EAAkBtB,GAAa,CAACmC,CAAU,GAAG,EAAK,KAErEtB,IAAmBQ,EAAerB,GAAa,CAACmC,CAAU,GAAG,EAAK,GAClEtB,IAAmBS,EAAkBT,GAAkB,CAACsB,CAAU,GAAG,EAAI,IAG7EtB,IAAmBF,EAA8BC,GAAWN,GAAIO,CAAgB,GACzEiB,EAAuBjB,CAAgB;AAClD;"}
1
+ {"version":3,"file":"multiselect.es.js","sources":["../../../../src/components/Tree/helpers/multiselect.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { CheckboxState } from '@components/Checkbox/Checkbox';\n\nimport { type TreeItemMultiselectProps } from '../types';\n\nimport { ROOT_ID } from './constants';\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeItemMultiselectWithNodes = TreeItemMultiselectProps & {\n id: string;\n parentId: string;\n extendedId?: string;\n nodes?: TreeItemMultiselectWithNodes[];\n numChildNodes?: number;\n onSelect?: (id: string) => void;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getMultiselectCheckBoxState = (isSelected: boolean, isPartialSelected: boolean) => {\n let theCheckboxState = CheckboxState.Unchecked;\n if (isSelected) {\n theCheckboxState = CheckboxState.Checked;\n } else if (isPartialSelected) {\n theCheckboxState = CheckboxState.Mixed;\n }\n\n return theCheckboxState;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getSelectedChildrenItems = (\n tree: TreeItemMultiselectWithNodes[],\n selectedIds: string[],\n onlyPartial = false,\n) => {\n return tree\n .filter(\n (item) =>\n (onlyPartial ? false : selectedIds.includes(getExtendedId(item))) ||\n selectedIds.includes(convertToPartialSelectedId([getExtendedId(item)])[0]),\n )\n .map((item) => item.id);\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getSelectedTreeItem = (\n tree: TreeItemMultiselectWithNodes[],\n id: string,\n): TreeItemMultiselectWithNodes | null => {\n for (const item of tree) {\n if (item.id === id) {\n return item;\n }\n if (item.nodes && item.nodes?.length > 0) {\n const deepItem = getSelectedTreeItem(item.nodes, id);\n if (deepItem) {\n return deepItem;\n }\n }\n }\n\n return null;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getParentSelectedTreeItem = (\n tree: TreeItemMultiselectWithNodes[],\n id: string,\n parent: TreeItemMultiselectWithNodes | null,\n): TreeItemMultiselectWithNodes | null => {\n for (const item of tree) {\n if (parent !== null && item.id === id) {\n return parent;\n }\n if (item.nodes && item.nodes?.length > 0) {\n const deepItem = getParentSelectedTreeItem(item.nodes, id, item);\n if (deepItem) {\n return deepItem;\n }\n }\n }\n return null;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const addSelectedItemsFromSelection = (\n treeItems: TreeItemMultiselectWithNodes[],\n id: string,\n newSelectedItems: string[],\n) => {\n const parentItemChecked = getParentSelectedTreeItem(treeItems, id, null);\n newSelectedItems = parentItemChecked?.id\n ? fixParentSelectionState(parentItemChecked, newSelectedItems)\n : newSelectedItems;\n\n const itemChecked = getSelectedTreeItem(treeItems, id);\n if (!itemChecked) {\n return newSelectedItems;\n }\n\n const itemCheckedExtendedId = getExtendedId(itemChecked);\n const childrenSelectedItems = getSelectedChildrenItems(itemChecked?.nodes ?? [], newSelectedItems);\n const childrenCount = itemChecked?.nodes?.length ?? 0;\n\n // Select/unselect children\n if (childrenCount) {\n const childrenIds = itemChecked?.nodes?.map((item) => getExtendedId(item)) ?? [];\n\n newSelectedItems = newSelectedItems.includes(itemCheckedExtendedId)\n ? addSelectedIds(newSelectedItems, childrenIds, false)\n : removeSelectedIds(newSelectedItems, childrenIds, false);\n\n if (childrenSelectedItems.length === 0) {\n newSelectedItems = removeSelectedIds(newSelectedItems, [itemCheckedExtendedId], true);\n }\n }\n\n // tree down\n for (const child of itemChecked?.nodes ?? []) {\n newSelectedItems = addSelectedItemsFromSelection(treeItems, child.id, newSelectedItems);\n }\n\n // tree up\n let parent = parentItemChecked;\n const treeBranch: TreeItemMultiselectWithNodes[] = [];\n while (parent !== null) {\n treeBranch.push(parent);\n parent = getParentSelectedTreeItem(treeItems, parent.id, null);\n }\n for (const item of treeBranch) {\n newSelectedItems = fixParentSelectionState(item, newSelectedItems);\n }\n\n return newSelectedItems;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const fixParentSelectionState = (parent: TreeItemMultiselectWithNodes, newSelectedItems: string[]) => {\n const parentExtendedId = getExtendedId(parent);\n const isParentSelected = newSelectedItems.includes(parentExtendedId);\n const siblingsSelectedItems = getSelectedChildrenItems(parent?.nodes ?? [], newSelectedItems);\n const siblingsPartiallySelectedItems = getSelectedChildrenItems(parent?.nodes ?? [], newSelectedItems, true);\n const siblingsCount = parent?.nodes?.length ?? 0;\n\n // Select/unselect parent\n if (siblingsSelectedItems.length === 0) {\n newSelectedItems = isParentSelected\n ? removeSelectedIds(newSelectedItems, [parentExtendedId], false)\n : newSelectedItems;\n newSelectedItems = removeSelectedIds(newSelectedItems, [parentExtendedId], true);\n } else if (siblingsSelectedItems.length === siblingsCount && siblingsPartiallySelectedItems.length === 0) {\n newSelectedItems = !isParentSelected\n ? addSelectedIds(newSelectedItems, [parentExtendedId], false)\n : newSelectedItems;\n\n newSelectedItems = removeSelectedIds(newSelectedItems, [parentExtendedId], true);\n } else if (parent?.id) {\n // flag parent as partial checked and unselect it\n newSelectedItems = addSelectedIds(newSelectedItems, [parentExtendedId], true);\n newSelectedItems = removeSelectedIds(newSelectedItems, [parentExtendedId], false);\n }\n\n return newSelectedItems;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const cleanOrphanSelectedIds = (selectIds: string[]) => {\n const orphans: string[] = [];\n let newSelectedIds: string[] = selectIds;\n\n const cleanSelectedIds = selectIds.map((extendedId) => extendedId.split('/').pop());\n\n for (const extendedId of selectIds) {\n const parentId = extendedId.split('/').shift();\n if (parentId === ROOT_ID || parentId === convertToPartialSelectedId([ROOT_ID])[0]) {\n continue;\n }\n if (\n !cleanSelectedIds.includes(parentId) &&\n !cleanSelectedIds.includes(removePartialFlagSelectedId([parentId ?? ''])[0] ?? '')\n ) {\n orphans.push(extendedId);\n }\n }\n\n if (orphans.length > 0) {\n newSelectedIds = removeSelectedIds(selectIds, orphans, false);\n newSelectedIds = cleanOrphanSelectedIds(newSelectedIds);\n }\n\n return newSelectedIds;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const convertToPartialSelectedId = (ids: string[]) => ids.map((id) => `*${id}`);\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const removePartialFlagSelectedId = (ids: string[]) => ids.map((id) => id.replace(/^\\*/, ''));\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getExtendedId = (item: TreeItemMultiselectWithNodes) => item.extendedId ?? `${item.parentId}/${item.id}`;\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const removeSelectedIds = (ids: string[], idsToRemove: string[], partial: boolean): string[] => {\n idsToRemove = partial ? convertToPartialSelectedId(idsToRemove) : idsToRemove;\n return [...new Set(idsToRemove.length > 0 ? ids.filter((itemId: string) => !idsToRemove.includes(itemId)) : ids)];\n};\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const addSelectedIds = (ids: string[], idsToAdd: string[], partial: boolean) => {\n idsToAdd = (partial ? convertToPartialSelectedId(idsToAdd) : idsToAdd).filter((id) => id !== '');\n return [...new Set(idsToAdd.length > 0 ? [...ids, ...idsToAdd] : ids)];\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getNewSelectedItems = (\n id: string,\n selectedIds: string[],\n treeItems: TreeItemMultiselectWithNodes[],\n ignoreRemoveSelected = false,\n) => {\n let newSelectedItems = [];\n\n const itemToChecked = getSelectedTreeItem(treeItems, id);\n if (!itemToChecked) {\n return selectedIds;\n }\n\n const extendedId = getExtendedId(itemToChecked);\n\n if (selectedIds.includes(extendedId) && !ignoreRemoveSelected) {\n newSelectedItems = removeSelectedIds(selectedIds, [extendedId], false);\n } else {\n newSelectedItems = addSelectedIds(selectedIds, [extendedId], false);\n newSelectedItems = removeSelectedIds(newSelectedItems, [extendedId], true);\n }\n\n newSelectedItems = addSelectedItemsFromSelection(treeItems, id, newSelectedItems);\n return cleanOrphanSelectedIds(newSelectedItems);\n};\n"],"names":["getMultiselectCheckBoxState","isSelected","isPartialSelected","theCheckboxState","CheckboxState","getSelectedChildrenItems","tree","selectedIds","onlyPartial","item","getExtendedId","convertToPartialSelectedId","getSelectedTreeItem","id","_a","deepItem","getParentSelectedTreeItem","parent","addSelectedItemsFromSelection","treeItems","newSelectedItems","parentItemChecked","fixParentSelectionState","itemChecked","itemCheckedExtendedId","childrenSelectedItems","childrenIds","_b","addSelectedIds","removeSelectedIds","child","treeBranch","parentExtendedId","isParentSelected","siblingsSelectedItems","siblingsPartiallySelectedItems","siblingsCount","cleanOrphanSelectedIds","selectIds","orphans","newSelectedIds","cleanSelectedIds","extendedId","parentId","ROOT_ID","removePartialFlagSelectedId","ids","idsToRemove","partial","itemId","idsToAdd","getNewSelectedItems","ignoreRemoveSelected","itemToChecked"],"mappings":";;AAuBO,MAAMA,IAA8B,CAACC,GAAqBC,MAA+B;AAC5F,MAAIC,IAAmBC,EAAc;AACrC,SAAIH,IACAE,IAAmBC,EAAc,UAC1BF,MACPC,IAAmBC,EAAc,QAG9BD;AACX,GAKaE,IAA2B,CACpCC,GACAC,GACAC,IAAc,OAEPF,EACF;AAAA,EACG,CAACG,OACID,IAAc,KAAQD,EAAY,SAASG,EAAcD,CAAI,CAAC,MAC/DF,EAAY,SAASI,EAA2B,CAACD,EAAcD,CAAI,CAAC,CAAC,EAAE,CAAC,CAAC;AAAA,EAEhF,IAAI,CAACA,MAASA,EAAK,EAAE,GAMjBG,IAAsB,CAC/BN,GACAO,MACsC;;AACtC,aAAWJ,KAAQH,GAAM;AACrB,QAAIG,EAAK,OAAOI;AACZ,aAAOJ;AAEX,QAAIA,EAAK,WAASK,IAAAL,EAAK,UAAL,gBAAAK,EAAY,UAAS,GAAG;AACtC,YAAMC,IAAWH,EAAoBH,EAAK,OAAOI,CAAE;AACnD,UAAIE;AACA,eAAOA;AAAA,IAEf;AAAA,EACJ;AAEA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2C,CAAa;AAE9C,SAAI9C,EAAY,SAASmC,CAAU,KAAK,CAACU,IACrChC,IAAmBS,EAAkBtB,GAAa,CAACmC,CAAU,GAAG,EAAK,KAErEtB,IAAmBQ,EAAerB,GAAa,CAACmC,CAAU,GAAG,EAAK,GAClEtB,IAAmBS,EAAkBT,GAAkB,CAACsB,CAAU,GAAG,EAAI,IAG7EtB,IAAmBF,EAA8BC,GAAWN,GAAIO,CAAgB,GACzEiB,EAAuBjB,CAAgB;AAClD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"multiselectTreeItemstyling.es.js","sources":["../../../../src/components/Tree/helpers/multiselectTreeItemstyling.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { FOCUS_VISIBLE_STYLE } from '@utilities/focusStyle';\nimport { merge } from '@utilities/merge';\n\nimport {\n TreeItemBorderClassMap,\n TreeItemBorderRadiusClassMap,\n TreeItemBorderStyleClassMap,\n TreeItemColorsClassMap,\n TreeItemShadowClassMap,\n TreeItemSpacingClassMap,\n type TreeItemStyling,\n} from '../types';\n\nexport const getMultiselectLiClassName = (itemStyleProps: TreeItemStyling, isDisabled: boolean) => {\n const styling = TreeItemColorsClassMap[itemStyleProps.activeColorStyle ?? 'neutral'];\n return merge([\n FOCUS_VISIBLE_STYLE,\n 'tw-box-content tw-relative tw-cursor-default tw-transition-colors tw-outline-none tw-ring-inset tw-group tw-no-underline tw-leading-5',\n TreeItemSpacingClassMap[itemStyleProps.spacingY ?? 'none'],\n isDisabled ? 'tw-text-text-disabled' : styling.textColor,\n ]);\n};\n\nexport const getMultiselectBackgroundClassName = (\n itemStyleProps: TreeItemStyling,\n isSelected: boolean,\n isDisabled: boolean,\n) => {\n const styling = TreeItemColorsClassMap[itemStyleProps.activeColorStyle ?? 'neutral'];\n return merge([\n 'tw-block tw-absolute tw-inset-0 tw-transition-colors -tw-z-10',\n itemStyleProps.borderWidth !== 'none'\n ? TreeItemBorderRadiusClassMap[itemStyleProps.borderRadius ?? 'small']\n : '',\n (!isSelected || itemStyleProps.activeColorStyle !== 'neutral') && styling.pressedBackgroundColor,\n isDisabled ? TreeItemColorsClassMap.none.backgroundColor : styling.backgroundColor,\n ]);\n};\n\nexport const getMultiselectContainerClassName = (itemStyleProps: TreeItemStyling) => {\n const containerBorder =\n itemStyleProps.borderWidth !== 'none'\n ? merge([\n TreeItemBorderClassMap[itemStyleProps.borderWidth ?? 'none'],\n TreeItemBorderRadiusClassMap[itemStyleProps.borderRadius ?? 'small'],\n TreeItemBorderStyleClassMap[itemStyleProps.borderStyle ?? 'none'],\n ])\n : '';\n\n return merge([\n 'tw-relative tw-z-0 tw-transition-colors tw-flex tw-items-center tw-content-center tw-leading-5 tw-width-fit tw-justify-start tw-pl-2',\n TreeItemShadowClassMap[itemStyleProps.shadow ?? 'none'],\n containerBorder,\n TreeItemBorderRadiusClassMap[itemStyleProps.borderRadius ?? 'small'],\n itemStyleProps.contentHight === 'single-line' ? 'tw-h-10' : 'tw-h-fit',\n ]);\n};\n"],"names":["getMultiselectLiClassName","itemStyleProps","isDisabled","styling","TreeItemColorsClassMap","merge","FOCUS_VISIBLE_STYLE","TreeItemSpacingClassMap","getMultiselectBackgroundClassName","isSelected","TreeItemBorderRadiusClassMap","getMultiselectContainerClassName","containerBorder","TreeItemBorderClassMap","TreeItemBorderStyleClassMap","TreeItemShadowClassMap"],"mappings":";;;AAeO,MAAMA,IAA4B,CAACC,GAAiCC,MAAwB;AAC/F,QAAMC,IAAUC,EAAuBH,EAAe,oBAAoB,SAAS;AACnF,SAAOI,EAAM;AAAA,IACTC;AAAA,IACA;AAAA,IACAC,EAAwBN,EAAe,YAAY,MAAM;AAAA,IACzDC,IAAa,0BAA0BC,EAAQ;AAAA,EAAA,CAClD;AACL,GAEaK,IAAoC,CAC7CP,GACAQ,GACAP,MACC;AACD,QAAMC,IAAUC,EAAuBH,EAAe,oBAAoB,SAAS;AACnF,SAAOI,EAAM;AAAA,IACT;AAAA,IACAJ,EAAe,gBAAgB,SACzBS,EAA6BT,EAAe,gBAAgB,OAAO,IACnE;AAAA,KACL,CAACQ,KAAcR,EAAe,qBAAqB,cAAcE,EAAQ;AAAA,IAC1ED,IAAaE,EAAuB,KAAK,kBAAkBD,EAAQ;AAAA,EAAA,CACtE;AACL,GAEaQ,IAAmC,CAACV,MAAoC;AACjF,QAAMW,IACFX,EAAe,gBAAgB,SACzBI,EAAM;AAAA,IACFQ,EAAuBZ,EAAe,eAAe,MAAM;AAAA,IAC3DS,EAA6BT,EAAe,gBAAgB,OAAO;AAAA,IACnEa,EAA4Bb,EAAe,eAAe,MAAM;AAAA,EAAA,CACnE,IACD;AAEV,SAAOI,EAAM;AAAA,IACT;AAAA,IACAU,EAAuBd,EAAe,UAAU,MAAM;AAAA,IACtDW;AAAA,IACAF,EAA6BT,EAAe,gBAAgB,OAAO;AAAA,IACnEA,EAAe,iBAAiB,gBAAgB,YAAY;AAAA,EAAA,CAC/D;AACL;"}
1
+ {"version":3,"file":"multiselectTreeItemstyling.es.js","sources":["../../../../src/components/Tree/helpers/multiselectTreeItemstyling.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { FOCUS_VISIBLE_STYLE } from '@utilities/focusStyle';\nimport { merge } from '@utilities/merge';\n\nimport {\n TreeItemBorderClassMap,\n TreeItemBorderRadiusClassMap,\n TreeItemBorderStyleClassMap,\n TreeItemColorsClassMap,\n TreeItemShadowClassMap,\n TreeItemSpacingClassMap,\n type TreeItemStyling,\n} from '../types';\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getMultiselectLiClassName = (itemStyleProps: TreeItemStyling, isDisabled: boolean) => {\n const styling = TreeItemColorsClassMap[itemStyleProps.activeColorStyle ?? 'neutral'];\n return merge([\n FOCUS_VISIBLE_STYLE,\n 'tw-box-content tw-relative tw-cursor-default tw-transition-colors tw-outline-none tw-ring-inset tw-group tw-no-underline tw-leading-5',\n TreeItemSpacingClassMap[itemStyleProps.spacingY ?? 'none'],\n isDisabled ? 'tw-text-text-disabled' : styling.textColor,\n ]);\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getMultiselectBackgroundClassName = (\n itemStyleProps: TreeItemStyling,\n isSelected: boolean,\n isDisabled: boolean,\n) => {\n const styling = TreeItemColorsClassMap[itemStyleProps.activeColorStyle ?? 'neutral'];\n return merge([\n 'tw-block tw-absolute tw-inset-0 tw-transition-colors -tw-z-10',\n itemStyleProps.borderWidth !== 'none'\n ? TreeItemBorderRadiusClassMap[itemStyleProps.borderRadius ?? 'small']\n : '',\n (!isSelected || itemStyleProps.activeColorStyle !== 'neutral') && styling.pressedBackgroundColor,\n isDisabled ? TreeItemColorsClassMap.none.backgroundColor : styling.backgroundColor,\n ]);\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getMultiselectContainerClassName = (itemStyleProps: TreeItemStyling) => {\n const containerBorder =\n itemStyleProps.borderWidth !== 'none'\n ? merge([\n TreeItemBorderClassMap[itemStyleProps.borderWidth ?? 'none'],\n TreeItemBorderRadiusClassMap[itemStyleProps.borderRadius ?? 'small'],\n TreeItemBorderStyleClassMap[itemStyleProps.borderStyle ?? 'none'],\n ])\n : '';\n\n return merge([\n 'tw-relative tw-z-0 tw-transition-colors tw-flex tw-items-center tw-content-center tw-leading-5 tw-width-fit tw-justify-start tw-pl-2',\n TreeItemShadowClassMap[itemStyleProps.shadow ?? 'none'],\n containerBorder,\n TreeItemBorderRadiusClassMap[itemStyleProps.borderRadius ?? 'small'],\n itemStyleProps.contentHight === 'single-line' ? 'tw-h-10' : 'tw-h-fit',\n ]);\n};\n"],"names":["getMultiselectLiClassName","itemStyleProps","isDisabled","styling","TreeItemColorsClassMap","merge","FOCUS_VISIBLE_STYLE","TreeItemSpacingClassMap","getMultiselectBackgroundClassName","isSelected","TreeItemBorderRadiusClassMap","getMultiselectContainerClassName","containerBorder","TreeItemBorderClassMap","TreeItemBorderStyleClassMap","TreeItemShadowClassMap"],"mappings":";;;AAkBO,MAAMA,IAA4B,CAACC,GAAiCC,MAAwB;AAC/F,QAAMC,IAAUC,EAAuBH,EAAe,oBAAoB,SAAS;AACnF,SAAOI,EAAM;AAAA,IACTC;AAAA,IACA;AAAA,IACAC,EAAwBN,EAAe,YAAY,MAAM;AAAA,IACzDC,IAAa,0BAA0BC,EAAQ;AAAA,EAAA,CAClD;AACL,GAKaK,IAAoC,CAC7CP,GACAQ,GACAP,MACC;AACD,QAAMC,IAAUC,EAAuBH,EAAe,oBAAoB,SAAS;AACnF,SAAOI,EAAM;AAAA,IACT;AAAA,IACAJ,EAAe,gBAAgB,SACzBS,EAA6BT,EAAe,gBAAgB,OAAO,IACnE;AAAA,KACL,CAACQ,KAAcR,EAAe,qBAAqB,cAAcE,EAAQ;AAAA,IAC1ED,IAAaE,EAAuB,KAAK,kBAAkBD,EAAQ;AAAA,EAAA,CACtE;AACL,GAKaQ,IAAmC,CAACV,MAAoC;AACjF,QAAMW,IACFX,EAAe,gBAAgB,SACzBI,EAAM;AAAA,IACFQ,EAAuBZ,EAAe,eAAe,MAAM;AAAA,IAC3DS,EAA6BT,EAAe,gBAAgB,OAAO;AAAA,IACnEa,EAA4Bb,EAAe,eAAe,MAAM;AAAA,EAAA,CACnE,IACD;AAEV,SAAOI,EAAM;AAAA,IACT;AAAA,IACAU,EAAuBd,EAAe,UAAU,MAAM;AAAA,IACtDW;AAAA,IACAF,EAA6BT,EAAe,gBAAgB,OAAO;AAAA,IACnEA,EAAe,iBAAiB,gBAAgB,YAAY;AAAA,EAAA,CAC/D;AACL;"}
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.es.js","sources":["../../../../src/components/Tree/helpers/nodes.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type ReactElement } from 'react';\n\nimport { type TreeNodeWithoutElements, type TreeState } from '../types';\n\nimport { ROOT_ID } from './constants';\n\nexport const removeReactNodesFromFlatArray = (tree: ReactElement[], nodeIds: string[]): ReactElement[] => {\n // Create a set of the node IDs to remove for faster lookup\n const nodesToRemove = new Set(nodeIds);\n\n // Filter the tree array to remove the nodes with IDs in the set\n return tree.filter((node) => !nodesToRemove.has(node.props.id));\n};\n\nexport const getReactNodeIdsInFlatArray = (tree: ReactElement[], startingNodeId: string): string[] => {\n const nodeIds: string[] = [];\n\n // Create a map from node IDs to their corresponding nodes\n const nodeMap = new Map<string, ReactElement>(tree.map((node) => [node.props.id, node]));\n\n // Find the node with the given id\n const startingNode = nodeMap.get(startingNodeId);\n\n // Recursively find all child nodes\n function findChildNodes(nodeId: number) {\n const children = tree.filter((child) => child.props.parentId === nodeId);\n for (const child of children) {\n nodeIds.push(child.props.id);\n findChildNodes(child.props.id);\n }\n }\n\n if (startingNode) {\n findChildNodes(startingNode.props.id);\n }\n\n return nodeIds;\n};\n\nexport const getReactNodesInFlatArray = (tree: ReactElement[], startingNodeId: string): ReactElement[] => {\n const nodes: ReactElement[] = [];\n\n // Create a map from node IDs to their corresponding nodes\n const nodeMap = new Map<string, ReactElement>(tree.map((node) => [node.props.id, node]));\n\n // Find the node with the given id\n const startingNode = nodeMap.get(startingNodeId);\n\n // Recursively find all child nodes\n function findChildNodes(nodeId: number) {\n const children = tree.filter((child) => child.props.parentId === nodeId);\n for (const child of children) {\n nodes.push(child);\n findChildNodes(child.props.id);\n }\n }\n\n if (startingNode) {\n findChildNodes(startingNode.props.id);\n }\n\n return nodes;\n};\n\nexport const getNodesToRender = (rootNodes: TreeState['rootNodes'], expandedIds: TreeState['expandedIds']) => {\n const nodesToRender: { id: string; node: ReactElement }[] = [];\n for (const node of rootNodes) {\n const parentId = node.props.parentId;\n if (\n typeof parentId === 'string' &&\n (parentId === ROOT_ID || (expandedIds.has(parentId) && nodesToRender.find((n) => n.id === parentId)))\n ) {\n nodesToRender.push({ id: node.props.id, node });\n }\n }\n\n return nodesToRender.map((n) => n.node);\n};\n\nexport const extractNodeFromElement = (node: ReactElement): TreeNodeWithoutElements => ({\n id: node.props.id,\n level: node.props.level,\n parentId: node.props.parentId,\n extendedId: `${node.props.parentId}/${node.props.id}`,\n nodes: [],\n});\n\nexport const getTreeNodesWithoutElements = (\n nodes: ReactElement[] = [],\n parentId = '__ROOT__',\n): TreeNodeWithoutElements[] => {\n const parsedNodes = nodes\n .filter((n) => n.props.parentId === parentId)\n .map((node, index) => ({\n ...extractNodeFromElement(node),\n nodes: getTreeNodesWithoutElements(nodes.slice(index + 1), node.props.id),\n }));\n\n return parsedNodes;\n};\n"],"names":["removeReactNodesFromFlatArray","tree","nodeIds","nodesToRemove","node","getReactNodeIdsInFlatArray","startingNodeId","startingNode","findChildNodes","nodeId","children","child","getReactNodesInFlatArray","nodes","getNodesToRender","rootNodes","expandedIds","nodesToRender","parentId","ROOT_ID","n","extractNodeFromElement","getTreeNodesWithoutElements","index"],"mappings":";AAQO,MAAMA,IAAgC,CAACC,GAAsBC,MAAsC;AAEtG,QAAMC,IAAgB,IAAI,IAAID,CAAO;AAGrC,SAAOD,EAAK,OAAO,CAACG,MAAS,CAACD,EAAc,IAAIC,EAAK,MAAM,EAAE,CAAC;AAClE,GAEaC,IAA6B,CAACJ,GAAsBK,MAAqC;AAClG,QAAMJ,IAAoB,CAAA,GAMpBK,IAHU,IAAI,IAA0BN,EAAK,IAAI,CAACG,MAAS,CAACA,EAAK,MAAM,IAAIA,CAAI,CAAC,CAAC,EAG1D,IAAIE,CAAc;AAG/C,WAASE,EAAeC,GAAgB;AACpC,UAAMC,IAAWT,EAAK,OAAO,CAACU,MAAUA,EAAM,MAAM,aAAaF,CAAM;AACvE,eAAWE,KAASD;AAChB,MAAAR,EAAQ,KAAKS,EAAM,MAAM,EA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,CAAQ,EAC3C,IAAI,CAACd,GAAMmB,OAAW;AAAA,EACnB,GAAGF,EAAuBjB,CAAI;AAAA,EAC9B,OAAOkB,EAA4BT,EAAM,MAAMU,IAAQ,CAAC,GAAGnB,EAAK,MAAM,EAAE;AAAA,EAC1E;"}
1
+ {"version":3,"file":"nodes.es.js","sources":["../../../../src/components/Tree/helpers/nodes.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type ReactElement } from 'react';\n\nimport { type TreeNodeWithoutElements, type TreeState } from '../types';\n\nimport { ROOT_ID } from './constants';\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const removeReactNodesFromFlatArray = (tree: ReactElement[], nodeIds: string[]): ReactElement[] => {\n // Create a set of the node IDs to remove for faster lookup\n const nodesToRemove = new Set(nodeIds);\n\n // Filter the tree array to remove the nodes with IDs in the set\n return tree.filter((node) => !nodesToRemove.has(node.props.id));\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getReactNodeIdsInFlatArray = (tree: ReactElement[], startingNodeId: string): string[] => {\n const nodeIds: string[] = [];\n\n // Create a map from node IDs to their corresponding nodes\n const nodeMap = new Map<string, ReactElement>(tree.map((node) => [node.props.id, node]));\n\n // Find the node with the given id\n const startingNode = nodeMap.get(startingNodeId);\n\n // Recursively find all child nodes\n function findChildNodes(nodeId: number) {\n const children = tree.filter((child) => child.props.parentId === nodeId);\n for (const child of children) {\n nodeIds.push(child.props.id);\n findChildNodes(child.props.id);\n }\n }\n\n if (startingNode) {\n findChildNodes(startingNode.props.id);\n }\n\n return nodeIds;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getReactNodesInFlatArray = (tree: ReactElement[], startingNodeId: string): ReactElement[] => {\n const nodes: ReactElement[] = [];\n\n // Create a map from node IDs to their corresponding nodes\n const nodeMap = new Map<string, ReactElement>(tree.map((node) => [node.props.id, node]));\n\n // Find the node with the given id\n const startingNode = nodeMap.get(startingNodeId);\n\n // Recursively find all child nodes\n function findChildNodes(nodeId: number) {\n const children = tree.filter((child) => child.props.parentId === nodeId);\n for (const child of children) {\n nodes.push(child);\n findChildNodes(child.props.id);\n }\n }\n\n if (startingNode) {\n findChildNodes(startingNode.props.id);\n }\n\n return nodes;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getNodesToRender = (rootNodes: TreeState['rootNodes'], expandedIds: TreeState['expandedIds']) => {\n const nodesToRender: { id: string; node: ReactElement }[] = [];\n for (const node of rootNodes) {\n const parentId = node.props.parentId;\n if (\n typeof parentId === 'string' &&\n (parentId === ROOT_ID || (expandedIds.has(parentId) && nodesToRender.find((n) => n.id === parentId)))\n ) {\n nodesToRender.push({ id: node.props.id, node });\n }\n }\n\n return nodesToRender.map((n) => n.node);\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const extractNodeFromElement = (node: ReactElement): TreeNodeWithoutElements => ({\n id: node.props.id,\n level: node.props.level,\n parentId: node.props.parentId,\n extendedId: `${node.props.parentId}/${node.props.id}`,\n nodes: [],\n});\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getTreeNodesWithoutElements = (\n nodes: ReactElement[] = [],\n parentId = '__ROOT__',\n): TreeNodeWithoutElements[] => {\n const parsedNodes = nodes\n .filter((n) => n.props.parentId === parentId)\n .map((node, index) => ({\n ...extractNodeFromElement(node),\n nodes: getTreeNodesWithoutElements(nodes.slice(index + 1), node.props.id),\n }));\n\n return parsedNodes;\n};\n"],"names":["removeReactNodesFromFlatArray","tree","nodeIds","nodesToRemove","node","getReactNodeIdsInFlatArray","startingNodeId","startingNode","findChildNodes","nodeId","children","child","getReactNodesInFlatArray","nodes","getNodesToRender","rootNodes","expandedIds","nodesToRender","parentId","ROOT_ID","n","extractNodeFromElement","getTreeNodesWithoutElements","index"],"mappings":";AAWO,MAAMA,IAAgC,CAACC,GAAsBC,MAAsC;AAEtG,QAAMC,IAAgB,IAAI,IAAID,CAAO;AAGrC,SAAOD,EAAK,OAAO,CAACG,MAAS,CAACD,EAAc,IAAIC,EAAK,MAAM,EAAE,CAAC;AAClE,GAKaC,IAA6B,CAACJ,GAAsBK,MAAqC;AAClG,QAAMJ,IAAoB,CAAA,GAMpBK,IAHU,IAAI,IAA0BN,EAAK,IAAI,CAACG,MAAS,CAACA,EAAK,MAAM,IAAIA,CAAI,CAAC,CAAC,EAG1D,IAAIE,CAAc;AAG/C,WAASE,EAAeC,GAAgB;AACpC,UAAMC,IAAWT,EAAK,OAAO,CAACU,MAAUA,EAAM,MAAM,aAAaF,CAAM;AACvE,eAAWE,KAASD;AAChB,MAAAR,EAAQ,KAAKS,EAAM,MAAM,EAAE,GAC3BH,EAAeG,EAAM,MAAM,EAAE;AAAA,EAErC;AAEA,SAAIJ,KACAC,EAAeD,EAAa,MAAM,EAAE,GAGjCL;AACX,GAKaU,IAA2B,CAACX,GAAsBK,MAA2C;AACtG,QAAMO,IAAwB,CAAA,GAMxBN,IAHU,IAAI,IAA0BN,EAAK,IAAI,CAACG,MAAS,CAACA,EAAK,MAAM,IAAIA,CAAI,CAAC,CAAC,EAG1D,IAAIE,CAAc;AAG/C,WAASE,EAAeC,GAAgB;AACpC,UAAMC,IAAWT,EAAK,OAAO,CAACU,MAAUA,EAAM,MAAM,aAAaF,CAAM;AACvE,eAAWE,KAASD;AAChB,MAAAG,EAAM,KAAKF,CAAK,GAChBH,EAAeG,EAAM,MAAM,EAAE;AAAA,EAErC;AAEA,SAAIJ,KACAC,EAAeD,EAAa,MAAM,EAAE,GAGjCM;AACX,GAKaC,IAAmB,CAACC,GAAmCC,MAA0C;AAC1G,QAAMC,IAAsD,CAAA;AAC5D,aAAWb,KAAQW,GAAW;AAC1B,UAAMG,IAAWd,EAAK,MAAM;AAC5B,IACI,OAAOc,KAAa,aACnBA,MAAaC,KAAYH,EAAY,IAAIE,CAAQ,KAAKD,EAAc,KAAK,CAACG,MAAMA,EAAE,OAAOF,CAAQ,MAElGD,EAAc,KAAK,EAAE,IAAIb,EAAK,MAAM,IAAI,MAAAA,GAAM;AAAA,EAEtD;AAEA,SAAOa,EAAc,IAAI,CAACG,MAAMA,EAAE,IAAI;AAC1C,GAKaC,IAAyB,CAACjB,OAAiD;AAAA,EACpF,IAAIA,EAAK,MAAM;AAAA,EACf,OAAOA,EAAK,MAAM;AAAA,EAClB,UAAUA,EAAK,MAAM;AAAA,EACrB,YAAY,GAAGA,EAAK,MAAM,QAAQ,IAAIA,EAAK,MAAM,EAAE;AAAA,EACnD,OAAO,CAAA;AACX,IAKakB,IAA8B,CACvCT,IAAwB,IACxBK,IAAW,eAESL,EACf,OAAO,CAACO,MAAMA,EAAE,MAAM,aAAaF,CAAQ,EAC3C,IAAI,CAACd,GAAMmB,OAAW;AAAA,EACnB,GAAGF,EAAuBjB,CAAI;AAAA,EAC9B,OAAOkB,EAA4BT,EAAM,MAAMU,IAAQ,CAAC,GAAGnB,EAAK,MAAM,EAAE;AAAA,EAC1E;"}
@@ -1 +1 @@
1
- {"version":3,"file":"projection.es.js","sources":["../../../../src/components/Tree/helpers/projection.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { arrayMove } from '@dnd-kit/sortable';\nimport { type ReactElement } from 'react';\n\nimport { INDENTATION_WIDTH, ROOT_ID } from '../helpers';\nimport { type InternalTreeItemProps } from '../TreeItem';\n\nexport type ProjectionArgs = {\n nodes: ReactElement<InternalTreeItemProps>[];\n activeId: string;\n overId: string;\n dragOffset: number;\n};\n\nexport type Projection = {\n depth: number;\n maxDepth: number;\n minDepth: number;\n position: number;\n type?: string;\n accepts?: string;\n parentId: Nullable<string>;\n isWithinParent: boolean | undefined;\n previousNode: Nullable<{ id: string; depth: number; accepts?: string }>;\n};\n\nconst getNodeDepth = (node: ReactElement) => {\n return node ? node.props.level : 0;\n};\n\nconst getDragDepth = (offset: number) => {\n return Math.round(offset / INDENTATION_WIDTH);\n};\n\nconst getNodeDepthConstraint = (node: ReactElement) => {\n return (node?.props.levelConstraint ?? null) !== null ? node.props.levelConstraint : false;\n};\n\nconst calculateMaxDepth = (previousNode: ReactElement, nextNode: ReactElement) => {\n const previousNodeDepth = getNodeDepth(previousNode);\n\n if (previousNode?.props.accepts) {\n const nextNodeDepth = getNodeDepth(nextNode);\n return previousNodeDepth >= nextNodeDepth ? previousNodeDepth + 1 : nextNodeDepth;\n } else {\n return previousNodeDepth;\n }\n};\n\nconst calculateMinDepth = (previousNode: ReactElement, nextNode: ReactElement) => {\n const nextNodeDepth = getNodeDepth(nextNode);\n\n if (previousNode?.props.accepts) {\n return nextNodeDepth;\n } else {\n return Math.min(getNodeDepth(previousNode), nextNodeDepth);\n }\n};\n\nexport const getProjection = ({ nodes, activeId, overId, dragOffset }: ProjectionArgs): Projection => {\n const overNodeIndex = nodes.findIndex(({ props }) => props.id === overId);\n const activeNodeIndex = nodes.findIndex(({ props }) => props.id === activeId);\n\n const activeNode = nodes[activeNodeIndex];\n const newNodes = arrayMove(nodes, activeNodeIndex, overNodeIndex);\n\n const previousNode = newNodes[overNodeIndex - 1];\n const nextNode = newNodes[overNodeIndex + 1];\n\n const activeNodeDepthConstraint = getNodeDepthConstraint(activeNode);\n const dragDepth = getDragDepth(dragOffset);\n const projectedDepth = (activeNode?.props?.level ?? 0) + dragDepth;\n\n const maxDepth =\n activeNodeDepthConstraint !== false ? activeNodeDepthConstraint : calculateMaxDepth(previousNode, nextNode);\n const minDepth =\n activeNodeDepthConstraint !== false ? activeNodeDepthConstraint : calculateMinDepth(previousNode, nextNode);\n\n let depth = projectedDepth || getNodeDepth(nextNode);\n if (projectedDepth >= maxDepth) {\n depth = maxDepth;\n } else if (projectedDepth < minDepth) {\n depth = minDepth;\n }\n\n const getParentId = () => {\n if (depth === 0 || !previousNode) {\n return ROOT_ID;\n }\n\n if (previousNode.props.parentId && depth === previousNode.props.level) {\n return previousNode.props.parentId ?? null;\n }\n\n if (previousNode.props.level !== undefined && depth > previousNode.props.level) {\n return previousNode.props.accepts\n ? previousNode.props.id\n : (previousNode.props.parentId ?? previousNode.props.id);\n }\n\n const newParent = newNodes\n .slice(0, overNodeIndex)\n .reverse()\n .find((item) => item.props.level === depth)?.props.parentId;\n\n return newParent ?? null;\n };\n\n const getParent = (parentId: Nullable<string>) => {\n if (!parentId) {\n return null;\n }\n return nodes.find(({ props }) => props.id === parentId)?.props;\n };\n\n const parentId = getParentId();\n const parent = getParent(parentId);\n\n // whether we are moving down there is a +1 offset, unless we are in the same parent\n const correctionDueDragDirection =\n activeNodeIndex < overNodeIndex && activeNode.props.parentId !== parentId ? 1 : 0;\n\n const nodesInParent = newNodes.filter(({ props }) => props.parentId === parentId);\n\n /**\n * To get the position the item is dropped within its parent (first match wins):\n * - Get the index of the active item among the parent nodes\n * - Use the 'over' item to get the position\n * - If the over element is the parent matched set it to the top\n * - If the item is going out:\n * - try to figure the position by the parent from the next element\n * - Or go to the first (going down) or last position (going up)\n * - if we move the item in or same depth and up it goes to the last position\n */\n let dropIndexInParent = nodesInParent.findIndex(({ props }) => props.id === activeId);\n\n if (dropIndexInParent < 0) {\n const overNextIndex = nodesInParent.findIndex(({ props }) => props.id === overId);\n if (overNextIndex >= 0) {\n dropIndexInParent = overNextIndex;\n } else if (parentId === overId) {\n dropIndexInParent = -1;\n } else if (dragDepth < 0) {\n const nextNodeNodesInParent = nextNode.props.parentId\n ? newNodes.filter(({ props }) => props.parentId === nextNode.props.parentId)\n : [];\n const nextNodePosition = nextNodeNodesInParent.findIndex(({ props }) => props.id === nextNode.props.id);\n if (nextNodePosition >= 0) {\n dropIndexInParent = nextNodePosition + (activeNodeIndex < overNodeIndex ? -1 : 0);\n } else {\n dropIndexInParent = activeNodeIndex < overNodeIndex ? nodesInParent.length : -1;\n }\n } else if (activeNodeIndex >= overNodeIndex) {\n dropIndexInParent = nodesInParent.length;\n }\n }\n\n dropIndexInParent = dropIndexInParent + correctionDueDragDirection;\n const parentDepth = parent?.level ?? 0;\n\n return {\n depth,\n maxDepth,\n minDepth,\n parentId: parentId ?? null,\n type: parent?.type,\n accepts: parent?.accepts,\n position: dropIndexInParent >= 0 ? dropIndexInParent : 0,\n isWithinParent: parentDepth ? depth > parentDepth : false,\n previousNode: previousNode\n ? {\n id: previousNode.props.id,\n depth: getNodeDepth(previousNode),\n accepts: previousNode.props.accepts,\n }\n : null,\n };\n};\n"],"names":["getNodeDepth","node","getDragDepth","offset","INDENTATION_WIDTH","getNodeDepthConstraint","calculateMaxDepth","previousNode","nextNode","previousNodeDepth","nextNodeDepth","calculateMinDepth","getProjection","nodes","activeId","overId","dragOffset","overNodeIndex","props","activeNodeIndex","activeNode","newNodes","arrayMove","activeNodeDepthConstraint","dragDepth","projectedDepth","_a","maxDepth","minDepth","depth","getParentId","ROOT_ID","item","getParent","parentId","parent","correctionDueDragDirection","nodesInParent","dropIndexInParent","overNextIndex","nextNodePosition","parentDepth"],"mappings":";;AA2BA,MAAMA,IAAe,CAACC,MACXA,IAAOA,EAAK,MAAM,QAAQ,GAG/BC,IAAe,CAACC,MACX,KAAK,MAAMA,IAASC,CAAiB,GAG1CC,IAAyB,CAACJ,QACpBA,KAAA,gBAAAA,EAAM,MAAM,oBAAmB,UAAU,OAAOA,EAAK,MAAM,kBAAkB,IAGnFK,IAAoB,CAACC,GAA4BC,MAA2B;AAC9E,QAAMC,IAA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oBnB,IAAkBF,IAAgBoB,EAAc,SAAS;AAAA,IAErF,MAAA,CAAWlB,KAAmBF,MAC1BqB,IAAoBD,EAAc;AAAA,EAE1C;AAEA,EAAAC,IAAoBA,IAAoBF;AACxC,QAAMK,KAAcN,KAAA,gBAAAA,EAAQ,UAAS;AAErC,SAAO;AAAA,IACH,OAAAN;AAAA,IACA,UAAAF;AAAA,IACA,UAAAC;AAAA,IACA,UAAUM,KAAY;AAAA,IACtB,MAAMC,KAAA,gBAAAA,EAAQ;AAAA,IACd,SAASA,KAAA,gBAAAA,EAAQ;AAAA,IACjB,UAAUG,KAAqB,IAAIA,IAAoB;AAAA,IACvD,gBAAgBG,IAAcZ,IAAQY,IAAc;AAAA,IACpD,cAAclC,IACR;AAAA,MACI,IAAIA,EAAa,MAAM;AAAA,MACvB,OAAOP,EAAaO,CAAY;AAAA,MAChC,SAASA,EAAa,MAAM;AAAA,IAAA,IAEhC;AAAA,EAAA;AAEd;"}
1
+ {"version":3,"file":"projection.es.js","sources":["../../../../src/components/Tree/helpers/projection.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { arrayMove } from '@dnd-kit/sortable';\nimport { type ReactElement } from 'react';\n\nimport { INDENTATION_WIDTH, ROOT_ID } from '../helpers';\nimport { type InternalTreeItemProps } from '../TreeItem';\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type ProjectionArgs = {\n nodes: ReactElement<InternalTreeItemProps>[];\n activeId: string;\n overId: string;\n dragOffset: number;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type Projection = {\n depth: number;\n maxDepth: number;\n minDepth: number;\n position: number;\n type?: string;\n accepts?: string;\n parentId: Nullable<string>;\n isWithinParent: boolean | undefined;\n previousNode: Nullable<{ id: string; depth: number; accepts?: string }>;\n};\n\nconst getNodeDepth = (node: ReactElement) => {\n return node ? node.props.level : 0;\n};\n\nconst getDragDepth = (offset: number) => {\n return Math.round(offset / INDENTATION_WIDTH);\n};\n\nconst getNodeDepthConstraint = (node: ReactElement) => {\n return (node?.props.levelConstraint ?? null) !== null ? node.props.levelConstraint : false;\n};\n\nconst calculateMaxDepth = (previousNode: ReactElement, nextNode: ReactElement) => {\n const previousNodeDepth = getNodeDepth(previousNode);\n\n if (previousNode?.props.accepts) {\n const nextNodeDepth = getNodeDepth(nextNode);\n return previousNodeDepth >= nextNodeDepth ? previousNodeDepth + 1 : nextNodeDepth;\n } else {\n return previousNodeDepth;\n }\n};\n\nconst calculateMinDepth = (previousNode: ReactElement, nextNode: ReactElement) => {\n const nextNodeDepth = getNodeDepth(nextNode);\n\n if (previousNode?.props.accepts) {\n return nextNodeDepth;\n } else {\n return Math.min(getNodeDepth(previousNode), nextNodeDepth);\n }\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getProjection = ({ nodes, activeId, overId, dragOffset }: ProjectionArgs): Projection => {\n const overNodeIndex = nodes.findIndex(({ props }) => props.id === overId);\n const activeNodeIndex = nodes.findIndex(({ props }) => props.id === activeId);\n\n const activeNode = nodes[activeNodeIndex];\n const newNodes = arrayMove(nodes, activeNodeIndex, overNodeIndex);\n\n const previousNode = newNodes[overNodeIndex - 1];\n const nextNode = newNodes[overNodeIndex + 1];\n\n const activeNodeDepthConstraint = getNodeDepthConstraint(activeNode);\n const dragDepth = getDragDepth(dragOffset);\n const projectedDepth = (activeNode?.props?.level ?? 0) + dragDepth;\n\n const maxDepth =\n activeNodeDepthConstraint !== false ? activeNodeDepthConstraint : calculateMaxDepth(previousNode, nextNode);\n const minDepth =\n activeNodeDepthConstraint !== false ? activeNodeDepthConstraint : calculateMinDepth(previousNode, nextNode);\n\n let depth = projectedDepth || getNodeDepth(nextNode);\n if (projectedDepth >= maxDepth) {\n depth = maxDepth;\n } else if (projectedDepth < minDepth) {\n depth = minDepth;\n }\n\n const getParentId = () => {\n if (depth === 0 || !previousNode) {\n return ROOT_ID;\n }\n\n if (previousNode.props.parentId && depth === previousNode.props.level) {\n return previousNode.props.parentId ?? null;\n }\n\n if (previousNode.props.level !== undefined && depth > previousNode.props.level) {\n return previousNode.props.accepts\n ? previousNode.props.id\n : (previousNode.props.parentId ?? previousNode.props.id);\n }\n\n const newParent = newNodes\n .slice(0, overNodeIndex)\n .reverse()\n .find((item) => item.props.level === depth)?.props.parentId;\n\n return newParent ?? null;\n };\n\n const getParent = (parentId: Nullable<string>) => {\n if (!parentId) {\n return null;\n }\n return nodes.find(({ props }) => props.id === parentId)?.props;\n };\n\n const parentId = getParentId();\n const parent = getParent(parentId);\n\n // whether we are moving down there is a +1 offset, unless we are in the same parent\n const correctionDueDragDirection =\n activeNodeIndex < overNodeIndex && activeNode.props.parentId !== parentId ? 1 : 0;\n\n const nodesInParent = newNodes.filter(({ props }) => props.parentId === parentId);\n\n /**\n * To get the position the item is dropped within its parent (first match wins):\n * - Get the index of the active item among the parent nodes\n * - Use the 'over' item to get the position\n * - If the over element is the parent matched set it to the top\n * - If the item is going out:\n * - try to figure the position by the parent from the next element\n * - Or go to the first (going down) or last position (going up)\n * - if we move the item in or same depth and up it goes to the last position\n */\n let dropIndexInParent = nodesInParent.findIndex(({ props }) => props.id === activeId);\n\n if (dropIndexInParent < 0) {\n const overNextIndex = nodesInParent.findIndex(({ props }) => props.id === overId);\n if (overNextIndex >= 0) {\n dropIndexInParent = overNextIndex;\n } else if (parentId === overId) {\n dropIndexInParent = -1;\n } else if (dragDepth < 0) {\n const nextNodeNodesInParent = nextNode.props.parentId\n ? newNodes.filter(({ props }) => props.parentId === nextNode.props.parentId)\n : [];\n const nextNodePosition = nextNodeNodesInParent.findIndex(({ props }) => props.id === nextNode.props.id);\n if (nextNodePosition >= 0) {\n dropIndexInParent = nextNodePosition + (activeNodeIndex < overNodeIndex ? -1 : 0);\n } else {\n dropIndexInParent = activeNodeIndex < overNodeIndex ? nodesInParent.length : -1;\n }\n } else if (activeNodeIndex >= overNodeIndex) {\n dropIndexInParent = nodesInParent.length;\n }\n }\n\n dropIndexInParent = dropIndexInParent + correctionDueDragDirection;\n const parentDepth = parent?.level ?? 0;\n\n return {\n depth,\n maxDepth,\n minDepth,\n parentId: parentId ?? null,\n type: parent?.type,\n accepts: parent?.accepts,\n position: dropIndexInParent >= 0 ? dropIndexInParent : 0,\n isWithinParent: parentDepth ? depth > parentDepth : false,\n previousNode: previousNode\n ? {\n id: previousNode.props.id,\n depth: getNodeDepth(previousNode),\n accepts: previousNode.props.accepts,\n }\n : null,\n };\n};\n"],"names":["getNodeDepth","node","getDragDepth","offset","INDENTATION_WIDTH","getNodeDepthConstraint","calculateMaxDepth","previousNode","nextNode","previousNodeDepth","nextNodeDepth","calculateMinDepth","getProjection","nodes","activeId","overId","dragOffset","overNodeIndex","props","activeNodeIndex","activeNode","newNodes","arrayMove","activeNodeDepthConstraint","dragDepth","projectedDepth","_a","maxDepth","minDepth","depth","getParentId","ROOT_ID","item","getParent","parentId","parent","correctionDueDragDirection","nodesInParent","dropIndexInParent","overNextIndex","nextNodePosition","parentDepth"],"mappings":";;AAiCA,MAAMA,IAAe,CAACC,MACXA,IAAOA,EAAK,MAAM,QAAQ,GAG/BC,IAAe,CAACC,MACX,KAAK,MAAMA,IAASC,CAAiB,GAG1CC,IAAyB,CAACJ,QACpBA,KAAA,gBAAAA,EAAM,MAAM,oBAAmB,UAAU,OAAOA,EAAK,MAAM,kBAAkB,IAGnFK,IAAoB,CAACC,GAA4BC,MAA2B;AAC9E,QAAMC,IAAoBT,EAAaO,CAAY;AAEnD,MAAIA,KAAA,QAAAA,EAAc,MAAM,SAAS;AAC7B,UAAMG,IAAgBV,EAAaQ,CAAQ;AAC3C,WAAOC,KAAqBC,I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BA,IAAoBF;AACxC,QAAMK,KAAcN,KAAA,gBAAAA,EAAQ,UAAS;AAErC,SAAO;AAAA,IACH,OAAAN;AAAA,IACA,UAAAF;AAAA,IACA,UAAAC;AAAA,IACA,UAAUM,KAAY;AAAA,IACtB,MAAMC,KAAA,gBAAAA,EAAQ;AAAA,IACd,SAASA,KAAA,gBAAAA,EAAQ;AAAA,IACjB,UAAUG,KAAqB,IAAIA,IAAoB;AAAA,IACvD,gBAAgBG,IAAcZ,IAAQY,IAAc;AAAA,IACpD,cAAclC,IACR;AAAA,MACI,IAAIA,EAAa,MAAM;AAAA,MACvB,OAAOP,EAAaO,CAAY;AAAA,MAChC,SAASA,EAAa,MAAM;AAAA,IAAA,IAEhC;AAAA,EAAA;AAEd;"}
@@ -1 +1 @@
1
- {"version":3,"file":"reducer.es.js","sources":["../../../../src/components/Tree/helpers/reducer.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { isEqualWith } from 'lodash-es';\nimport { type ReactElement } from 'react';\n\nimport { type InternalTreeItemProps } from '../TreeItem';\n\nimport { getReactNodeIdsInFlatArray, getReactNodesInFlatArray, removeReactNodesFromFlatArray } from './nodes';\n\nexport const shouldUpdateTreeState = (event: globalThis.KeyboardEvent, multiselect: boolean) => {\n return multiselect && (event.key === 'Meta' || event.ctrlKey);\n};\n\nexport const findIndexById = (nodes: ReactElement<InternalTreeItemProps>[], id: string) => {\n return nodes.findIndex((node) => node.props.id === id);\n};\n\nexport const getNodeChildrenIds = (nodes: ReactElement<InternalTreeItemProps>[], id: string) => {\n return nodes.filter((node) => node.props.parentId === id).map((node) => node.props.id);\n};\n\nexport const updateNodeWithNewChildren = (\n nodes: ReactElement<InternalTreeItemProps>[],\n parentId: string,\n children: ReactElement[],\n) => {\n const nodeIds = getReactNodeIdsInFlatArray(nodes, parentId);\n const cleanNodes = nodeIds.length > 0 ? removeReactNodesFromFlatArray(nodes, nodeIds) : nodes;\n const parentIndex = findIndexById(cleanNodes, parentId);\n if (parentIndex === -1) {\n return nodes;\n }\n\n return [...cleanNodes.slice(0, parentIndex + 1), ...children, ...cleanNodes.slice(parentIndex + 1)];\n};\n\nexport const getCurrentChildrenForNewNodesIfExpanded = (\n currentNodes: ReactElement[],\n expandedIds: Set<string>,\n newNodes: ReactElement[],\n) => {\n const updatedTreeNode: ReactElement[] = [];\n for (const node of newNodes) {\n updatedTreeNode.push(node);\n\n if (!expandedIds.has(node.props.id)) {\n continue;\n }\n\n for (const child of getReactNodesInFlatArray(currentNodes, node.props.id)) {\n updatedTreeNode.push(child);\n }\n }\n\n return updatedTreeNode;\n};\n\nexport const currentNodesChanged = (\n currentChildrenIds: string[],\n currentNodes: ReactElement<InternalTreeItemProps>[],\n newNodes: ReactElement<InternalTreeItemProps>[],\n) => {\n for (const nodeId of currentChildrenIds) {\n const newNode = newNodes.find((n) => n.props.id === nodeId);\n const newContentComponent = newNode?.props?.contentComponent as Partial<ReactElement>;\n\n const currentNode = currentNodes.find((n) => n.props.id === nodeId);\n const currentContentComponent = currentNode?.props?.contentComponent as Partial<ReactElement>;\n\n if (\n (!currentContentComponent || !newContentComponent) &&\n !isEqualWith(currentNode?.props, newNode?.props, isEqualCustomizer)\n ) {\n return true;\n }\n\n if (!isEqualWith(currentContentComponent?.props, newContentComponent?.props, isEqualCustomizer)) {\n return true;\n }\n }\n return false;\n};\n\nconst isEqualCustomizer = (nodeProp: unknown, othernodeProp: unknown): boolean | undefined => {\n if (typeof nodeProp === 'function' || typeof othernodeProp === 'function') {\n return true;\n }\n};\n"],"names":["shouldUpdateTreeState","event","multiselect","findIndexById","nodes","id","node","getNodeChildrenIds","updateNodeWithNewChildren","parentId","children","nodeIds","getReactNodeIdsInFlatArray","cleanNodes","removeReactNodesFromFlatArray","parentIndex","getCurrentChildrenForNewNodesIfExpanded","currentNodes","expandedIds","newNodes","updatedTreeNode","child","getReactNodesInFlatArray","currentNodesChanged","currentChildrenIds","nodeId","newNode","n","newContentComponent","_a","currentNode","currentContent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AF,KAAA,gBAAAA,EAAa,UAAb,gBAAAE,EAAoB;AASpD,SANK,CAACD,KAA2B,CAACH,MAC9B,CAACK,EAAYH,KAAA,gBAAAA,EAAa,OAAOJ,KAAA,gBAAAA,EAAS,OAAOQ,CAAiB,KAKlE,CAACD,EAAYF,KAAA,gBAAAA,EAAyB,OAAOH,KAAA,gBAAAA,EAAqB,OAAOM,CAAiB;AAC1F,aAAO;AAAA,EAEf;AACA,SAAO;AACX,GAEMA,IAAoB,CAACC,GAAmBC,MAAgD;AAC1F,MAAI,OAAOD,KAAa,cAAc,OAAOC,KAAkB;AAC3D,WAAO;AAEf;"}
1
+ {"version":3,"file":"reducer.es.js","sources":["../../../../src/components/Tree/helpers/reducer.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { isEqualWith } from 'lodash-es';\nimport { type ReactElement } from 'react';\n\nimport { type InternalTreeItemProps } from '../TreeItem';\n\nimport { getReactNodeIdsInFlatArray, getReactNodesInFlatArray, removeReactNodesFromFlatArray } from './nodes';\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const shouldUpdateTreeState = (event: globalThis.KeyboardEvent, multiselect: boolean) => {\n return multiselect && (event.key === 'Meta' || event.ctrlKey);\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const findIndexById = (nodes: ReactElement<InternalTreeItemProps>[], id: string) => {\n return nodes.findIndex((node) => node.props.id === id);\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getNodeChildrenIds = (nodes: ReactElement<InternalTreeItemProps>[], id: string) => {\n return nodes.filter((node) => node.props.parentId === id).map((node) => node.props.id);\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const updateNodeWithNewChildren = (\n nodes: ReactElement<InternalTreeItemProps>[],\n parentId: string,\n children: ReactElement[],\n) => {\n const nodeIds = getReactNodeIdsInFlatArray(nodes, parentId);\n const cleanNodes = nodeIds.length > 0 ? removeReactNodesFromFlatArray(nodes, nodeIds) : nodes;\n const parentIndex = findIndexById(cleanNodes, parentId);\n if (parentIndex === -1) {\n return nodes;\n }\n\n return [...cleanNodes.slice(0, parentIndex + 1), ...children, ...cleanNodes.slice(parentIndex + 1)];\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const getCurrentChildrenForNewNodesIfExpanded = (\n currentNodes: ReactElement[],\n expandedIds: Set<string>,\n newNodes: ReactElement[],\n) => {\n const updatedTreeNode: ReactElement[] = [];\n for (const node of newNodes) {\n updatedTreeNode.push(node);\n\n if (!expandedIds.has(node.props.id)) {\n continue;\n }\n\n for (const child of getReactNodesInFlatArray(currentNodes, node.props.id)) {\n updatedTreeNode.push(child);\n }\n }\n\n return updatedTreeNode;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const currentNodesChanged = (\n currentChildrenIds: string[],\n currentNodes: ReactElement<InternalTreeItemProps>[],\n newNodes: ReactElement<InternalTreeItemProps>[],\n) => {\n for (const nodeId of currentChildrenIds) {\n const newNode = newNodes.find((n) => n.props.id === nodeId);\n const newContentComponent = newNode?.props?.contentComponent as Partial<ReactElement>;\n\n const currentNode = currentNodes.find((n) => n.props.id === nodeId);\n const currentContentComponent = currentNode?.props?.contentComponent as Partial<ReactElement>;\n\n if (\n (!currentContentComponent || !newContentComponent) &&\n !isEqualWith(currentNode?.props, newNode?.props, isEqualCustomizer)\n ) {\n return true;\n }\n\n if (!isEqualWith(currentContentComponent?.props, newContentComponent?.props, isEqualCustomizer)) {\n return true;\n }\n }\n return false;\n};\n\nconst isEqualCustomizer = (nodeProp: unknown, othernodeProp: unknown): boolean | undefined => {\n if (typeof nodeProp === 'function' || typeof othernodeProp === 'function') {\n return true;\n }\n};\n"],"names":["shouldUpdateTreeState","event","multiselect","findIndexById","nodes","id","node","getNodeChildrenIds","updateNodeWithNewChildren","parentId","children","nodeIds","getReactNodeIdsInFlatArray","cleanNodes","removeReactNodesFromFlatArray","parentIndex","getCurrentChildrenForNewNodesIfExpanded","currentNodes","expandedIds","newNodes","updatedTreeNode","child","getReactNodesInFlatArray","currentNodesChanged","currentChildrenIds","nodeId","newNode","n","newContentComponent","_a","currentNode","currentContentComponent","_b","isEqualWith","isEqualCustomizer","nodeProp","othernodeProp"],"mappings":";;AAYO,MAAMA,IAAwB,CAACC,GAAiCC,MAC5DA,MAAgBD,EAAM,QAAQ,UAAUA,EAAM,UAM5CE,IAAgB,CAACC,GAA8CC,MACjED,EAAM,UAAU,CAACE,MAASA,EAAK,MAAM,OAAOD,CAAE,GAM5CE,IAAqB,CAACH,GAA8CC,MACtED,EAAM,OAAO,CAACE,MAASA,EAAK,MAAM,aAAaD,CAAE,EAAE,IAAI,CAACC,MAASA,EAAK,MAAM,EAAE,GAM5EE,IAA4B,CACrCJ,GACAK,GACAC,MACC;AACD,QAAMC,IAAUC,EAA2BR,GAAOK,CAAQ,GACpDI,IAAaF,EAAQ,SAAS,IAAIG,EAA8BV,GAAOO,CAAO,IAAIP,GAClFW,IAAcZ,EAAcU,GAAYJ,CAAQ;AACtD,SAAIM,MAAgB,KACTX,IAGJ,CAAC,GAAGS,EAAW,MAAM,GAAGE,IAAc,CAAC,GAAG,GAAGL,GAAU,GAAGG,EAAW,MAAME,IAAc,CAAC,CAAC;AACtG,GAKaC,IAA0C,CACnDC,GACAC,GACAC,MACC;AACD,QAAMC,IAAkC,CAAA;AACxC,aAAWd,KAAQa;AAGf,QAFAC,EAAgB,KAAKd,CAAI,GAErB,EAACY,EAAY,IAAIZ,EAAK,MAAM,EAAE;AAIlC,iBAAWe,KAASC,EAAyBL,GAAcX,EAAK,MAAM,EAAE;AACpE,QAAAc,EAAgB,KAAKC,CAAK;AAIlC,SAAOD;AACX,GAKaG,IAAsB,CAC/BC,GACAP,GACAE,MACC;;AACD,aAAWM,KAAUD,GAAoB;AACrC,UAAME,IAAUP,EAAS,KAAK,CAACQ,MAAMA,EAAE,MAAM,OAAOF,CAAM,GACpDG,KAAsBC,IAAAH,KAAA,gBAAAA,EAAS,UAAT,gBAAAG,EAAgB,kBAEtCC,IAAcb,EAAa,KAAK,CAACU,MAAMA,EAAE,MAAM,OAAOF,CAAM,GAC5DM,KAA0BC,IAAAF,KAAA,gBAAAA,EAAa,UAAb,gBAAAE,EAAoB;AASpD,SANK,CAACD,KAA2B,CAACH,MAC9B,CAACK,EAAYH,KAAA,gBAAAA,EAAa,OAAOJ,KAAA,gBAAAA,EAAS,OAAOQ,CAAiB,KAKlE,CAACD,EAAYF,KAAA,gBAAAA,EAAyB,OAAOH,KAAA,gBAAAA,EAAqB,OAAOM,CAAiB;AAC1F,aAAO;AAAA,EAEf;AACA,SAAO;AACX,GAEMA,IAAoB,CAACC,GAAmBC,MAAgD;AAC1F,MAAI,OAAOD,KAAa,cAAc,OAAOC,KAAkB;AAC3D,WAAO;AAEf;"}
@@ -1 +1 @@
1
- {"version":3,"file":"sensorsActivationConstraint.es.js","sources":["../../../../src/components/Tree/helpers/sensorsActivationConstraint.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type TreeProps } from '../types';\n\ntype SensorsActivationConstraintProps = {\n dragHandlerPosition: TreeProps['dragHandlerPosition'];\n enableDragDelay: TreeProps['enableDragDelay'];\n};\n\ntype SensorsActivationConstraint = {\n delay: number;\n tolerance: number;\n};\n\nexport const sensorsActivationConstraint = ({\n dragHandlerPosition,\n enableDragDelay,\n}: SensorsActivationConstraintProps): SensorsActivationConstraint => {\n const delay = enableDragDelay ? 150 : 0;\n return dragHandlerPosition === 'none' ? { delay, tolerance: 5 } : { delay: 0, tolerance: 5 };\n};\n"],"names":["sensorsActivationConstraint","dragHandlerPosition","enableDragDelay"],"mappings":"AAcO,MAAMA,IAA8B,CAAC;AAAA,EACxC,qBAAAC;AAAA,EACA,iBAAAC;AACJ,MAEWD,MAAwB,SAAS,EAAE,OAD5BC,IAAkB,MAAM,GACW,WAAW,EAAA,IAAM,EAAE,OAAO,GAAG,WAAW,EAAA;"}
1
+ {"version":3,"file":"sensorsActivationConstraint.es.js","sources":["../../../../src/components/Tree/helpers/sensorsActivationConstraint.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type TreeProps } from '../types';\n\ntype SensorsActivationConstraintProps = {\n dragHandlerPosition: TreeProps['dragHandlerPosition'];\n enableDragDelay: TreeProps['enableDragDelay'];\n};\n\ntype SensorsActivationConstraint = {\n delay: number;\n tolerance: number;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const sensorsActivationConstraint = ({\n dragHandlerPosition,\n enableDragDelay,\n}: SensorsActivationConstraintProps): SensorsActivationConstraint => {\n const delay = enableDragDelay ? 150 : 0;\n return dragHandlerPosition === 'none' ? { delay, tolerance: 5 } : { delay: 0, tolerance: 5 };\n};\n"],"names":["sensorsActivationConstraint","dragHandlerPosition","enableDragDelay"],"mappings":"AAiBO,MAAMA,IAA8B,CAAC;AAAA,EACxC,qBAAAC;AAAA,EACA,iBAAAC;AACJ,MAEWD,MAAwB,SAAS,EAAE,OAD5BC,IAAkB,MAAM,GACW,WAAW,EAAA,IAAM,EAAE,OAAO,GAAG,WAAW,EAAA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"treeHandleKeyDown.es.js","sources":["../../../../src/components/Tree/helpers/treeHandleKeyDown.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { KeyboardCode } from '@dnd-kit/core';\nimport { type KeyboardEvent } from 'react';\n\nimport { type TreeState } from '../types';\n\nimport { ROOT_ID } from './constants';\n\nexport const handleKeyDownEvent = (\n event: KeyboardEvent<HTMLUListElement>,\n expandedIds: TreeState['expandedIds'],\n nodes: TreeState['nodes'],\n handleSelect: (id: string) => void,\n handleShrink: (id: string) => void,\n handleExpand: (id: string) => void,\n) => {\n const activeElement = document.activeElement;\n\n if (\n !activeElement?.parentElement ||\n activeElement.getAttribute('role') !== 'treeitem' ||\n !(activeElement instanceof HTMLLIElement)\n ) {\n return;\n }\n\n const items = Array.from(activeElement.parentElement.children).filter(\n (child) => child.nodeName === 'LI',\n ) as HTMLLIElement[];\n\n const currentIndex = items.indexOf(activeElement);\n\n const node = nodes[currentIndex];\n\n const id: string = node.props.id;\n const isExpanded = expandedIds.has(id);\n const parentId: string | undefined = node.props.parentId;\n const hasChildren = activeElement.getAttribute('data-has-children') === 'true';\n\n const { code } = event;\n\n const toggleSelect = () => {\n event.preventDefault();\n\n handleSelect(id);\n };\n\n const expandItem = () => {\n event.preventDefault();\n\n handleExpand(id);\n };\n\n const shrinkItem = () => {\n event.preventDefault();\n\n handleShrink(id);\n };\n\n const focusPrevious = () => {\n const previousIndex = (currentIndex + items.length - 1) % items.length;\n items[previousIndex].focus();\n };\n\n const focusNext = () => {\n const nextIndex = (currentIndex + 1) % items.length;\n items[nextIndex].focus();\n };\n\n switch (code) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Enter:\n toggleSelect();\n\n break;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Space:\n if (hasChildren) {\n expandItem();\n } else {\n toggleSelect();\n }\n\n break;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Right:\n if (!hasChildren) {\n break;\n }\n\n if (isExpanded) {\n focusNext();\n } else {\n expandItem();\n }\n\n break;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Left:\n if (hasChildren && isExpanded) {\n shrinkItem();\n } else if (parentId && parentId !== ROOT_ID) {\n const parentIndex = nodes.findIndex((node) => node.props.id === parentId);\n\n items[parentIndex].focus();\n }\n break;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Up:\n event.preventDefault();\n focusPrevious();\n\n break;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Down:\n event.preventDefault();\n focusNext();\n\n break;\n\n default:\n break;\n }\n};\n"],"names":["handleKeyDownEvent","event","expandedIds","nodes","handleSelect","handleShrink","handleExpand","activeElement","items","child","currentIndex","node","id","isExpanded","parentId","hasChildren","code","toggleSelect","expandItem","shrinkItem","focusPrevious","previousIndex","focusNext","nextIndex","KeyboardCode","ROOT_ID","parentIndex"],"mappings":";;AASO,MAAMA,IAAqB,CAC9BC,GACAC,GACAC,GACAC,GACAC,GACAC,MACC;AACD,QAAMC,IAAgB,SAAS;AAE/B,MACI,EAACA,KAAA,QAAAA,EAAe,kBAChBA,EAAc,aAAa,MAAM,MAAM,cACvC,EAAEA,aAAyB;AAE3B;AAGJ,QAAMC,IAAQ,MAAM,KAAKD,EAAc,cAAc,QAAQ,EAAE;AAAA,IAC3D,CAACE,MAAUA,EAAM,aAAa;AAAA,EAAA,GAG5BC,IAAeF,EAAM,QAAQD,CAAa,GAE1CI,IAAOR,EAAMO,CAAY,GAEzBE,IAAaD,EAAK,MAAM,IACxBE,IAAaX,EAAY,IAAIU,CAAE,GAC/BE,IAA+BH,EAAK,MAAM,UAC1CI,IAAcR,EAAc,aAAa,mBAAmB,MAAM,QAElE,EAAE,MAAAS,MAASf,GAEXgB,IAAe,MAAM;AACvB,IAAAhB,EAAM,eAAA,GAENG,EAAaQ,CAAE;AAAA,EACnB,GAEMM,IAAa,MAAM;AACrB,IAAAjB,EAAM,eAAA,GAENK,EAAaM,CAAE;AAAA,EACnB,GAEMO,IAAa,MAAM;AACrB,IAAAlB,EAAM,eAAA,GAENI,EAAaO,CAAE;AAAA,EACnB,GAEMQ,IAAgB,MAAM;AACxB,UAAMC,KAAiBX,IAAeF,EAAM,SAAS,KAAKA,EAAM;AAChE,IAAAA,EAAMa,CAAa,EAAE,MAAA;AAAA,EACzB,GAEMC,IAAY,MAAM;AACpB,UAAMC,KAAab,IAAe,KAAKF,EAAM;AAC7C,IAAAA,EAAMe,CAAS,EAAE,MAAA;AAAA,EACrB;AAEA,UAAQP,GAAA;AAAA,IAEJ,KAAKQ,EAAa;AACd,MAAAP,EAAA;AAEA;AAAA,IAGJ,KAAKO,EAAa;AACd,MAAIT,IACAG,EAAA,IAEAD,EAAA;AAGJ;AAAA,IAGJ,KAAKO,EAAa;AACd,UAAI,CAACT;AACD;AAGJ,MAAIF,IACAS,EAAA,IAEAJ,EAAA;AAGJ;AAAA,IAGJ,KAAKM,EAAa;AACd,UAAIT,KAAeF;AACf,QAAAM,EAAA;AAAA,eACOL,KAAYA,MAAaW,GAAS;AACzC,cAAMC,IAAcvB,EAAM,UAAU,CAACQ,MAASA,EAAK,MAAM,OAAOG,CAAQ;AAExE,QAAAN,EAAMkB,CAAW,EAAE,MAAA;AAAA,MACvB;AACA;AAAA,IAGJ,KAAKF,EAAa;AACd,MAAAvB,EAAM,eAAA,GACNmB,EAAA;AAEA;AAAA,IAGJ,KAAKI,EAAa;AACd,MAAAvB,EAAM,eAAA,GACNqB,EAAA;AAEA;AAAA,EAGA;AAEZ;"}
1
+ {"version":3,"file":"treeHandleKeyDown.es.js","sources":["../../../../src/components/Tree/helpers/treeHandleKeyDown.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { KeyboardCode } from '@dnd-kit/core';\nimport { type KeyboardEvent } from 'react';\n\nimport { type TreeState } from '../types';\n\nimport { ROOT_ID } from './constants';\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const handleKeyDownEvent = (\n event: KeyboardEvent<HTMLUListElement>,\n expandedIds: TreeState['expandedIds'],\n nodes: TreeState['nodes'],\n handleSelect: (id: string) => void,\n handleShrink: (id: string) => void,\n handleExpand: (id: string) => void,\n) => {\n const activeElement = document.activeElement;\n\n if (\n !activeElement?.parentElement ||\n activeElement.getAttribute('role') !== 'treeitem' ||\n !(activeElement instanceof HTMLLIElement)\n ) {\n return;\n }\n\n const items = Array.from(activeElement.parentElement.children).filter(\n (child) => child.nodeName === 'LI',\n ) as HTMLLIElement[];\n\n const currentIndex = items.indexOf(activeElement);\n\n const node = nodes[currentIndex];\n\n const id: string = node.props.id;\n const isExpanded = expandedIds.has(id);\n const parentId: string | undefined = node.props.parentId;\n const hasChildren = activeElement.getAttribute('data-has-children') === 'true';\n\n const { code } = event;\n\n const toggleSelect = () => {\n event.preventDefault();\n\n handleSelect(id);\n };\n\n const expandItem = () => {\n event.preventDefault();\n\n handleExpand(id);\n };\n\n const shrinkItem = () => {\n event.preventDefault();\n\n handleShrink(id);\n };\n\n const focusPrevious = () => {\n const previousIndex = (currentIndex + items.length - 1) % items.length;\n items[previousIndex].focus();\n };\n\n const focusNext = () => {\n const nextIndex = (currentIndex + 1) % items.length;\n items[nextIndex].focus();\n };\n\n switch (code) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Enter:\n toggleSelect();\n\n break;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Space:\n if (hasChildren) {\n expandItem();\n } else {\n toggleSelect();\n }\n\n break;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Right:\n if (!hasChildren) {\n break;\n }\n\n if (isExpanded) {\n focusNext();\n } else {\n expandItem();\n }\n\n break;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Left:\n if (hasChildren && isExpanded) {\n shrinkItem();\n } else if (parentId && parentId !== ROOT_ID) {\n const parentIndex = nodes.findIndex((node) => node.props.id === parentId);\n\n items[parentIndex].focus();\n }\n break;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Up:\n event.preventDefault();\n focusPrevious();\n\n break;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Down:\n event.preventDefault();\n focusNext();\n\n break;\n\n default:\n break;\n }\n};\n"],"names":["handleKeyDownEvent","event","expandedIds","nodes","handleSelect","handleShrink","handleExpand","activeElement","items","child","currentIndex","node","id","isExpanded","parentId","hasChildren","code","toggleSelect","expandItem","shrinkItem","focusPrevious","previousIndex","focusNext","nextIndex","KeyboardCode","ROOT_ID","parentIndex"],"mappings":";;AAYO,MAAMA,IAAqB,CAC9BC,GACAC,GACAC,GACAC,GACAC,GACAC,MACC;AACD,QAAMC,IAAgB,SAAS;AAE/B,MACI,EAACA,KAAA,QAAAA,EAAe,kBAChBA,EAAc,aAAa,MAAM,MAAM,cACvC,EAAEA,aAAyB;AAE3B;AAGJ,QAAMC,IAAQ,MAAM,KAAKD,EAAc,cAAc,QAAQ,EAAE;AAAA,IAC3D,CAACE,MAAUA,EAAM,aAAa;AAAA,EAAA,GAG5BC,IAAeF,EAAM,QAAQD,CAAa,GAE1CI,IAAOR,EAAMO,CAAY,GAEzBE,IAAaD,EAAK,MAAM,IACxBE,IAAaX,EAAY,IAAIU,CAAE,GAC/BE,IAA+BH,EAAK,MAAM,UAC1CI,IAAcR,EAAc,aAAa,mBAAmB,MAAM,QAElE,EAAE,MAAAS,MAASf,GAEXgB,IAAe,MAAM;AACvB,IAAAhB,EAAM,eAAA,GAENG,EAAaQ,CAAE;AAAA,EACnB,GAEMM,IAAa,MAAM;AACrB,IAAAjB,EAAM,eAAA,GAENK,EAAaM,CAAE;AAAA,EACnB,GAEMO,IAAa,MAAM;AACrB,IAAAlB,EAAM,eAAA,GAENI,EAAaO,CAAE;AAAA,EACnB,GAEMQ,IAAgB,MAAM;AACxB,UAAMC,KAAiBX,IAAeF,EAAM,SAAS,KAAKA,EAAM;AAChE,IAAAA,EAAMa,CAAa,EAAE,MAAA;AAAA,EACzB,GAEMC,IAAY,MAAM;AACpB,UAAMC,KAAab,IAAe,KAAKF,EAAM;AAC7C,IAAAA,EAAMe,CAAS,EAAE,MAAA;AAAA,EACrB;AAEA,UAAQP,GAAA;AAAA,IAEJ,KAAKQ,EAAa;AACd,MAAAP,EAAA;AAEA;AAAA,IAGJ,KAAKO,EAAa;AACd,MAAIT,IACAG,EAAA,IAEAD,EAAA;AAGJ;AAAA,IAGJ,KAAKO,EAAa;AACd,UAAI,CAACT;AACD;AAGJ,MAAIF,IACAS,EAAA,IAEAJ,EAAA;AAGJ;AAAA,IAGJ,KAAKM,EAAa;AACd,UAAIT,KAAeF;AACf,QAAAM,EAAA;AAAA,eACOL,KAAYA,MAAaW,GAAS;AACzC,cAAMC,IAAcvB,EAAM,UAAU,CAACQ,MAASA,EAAK,MAAM,OAAOG,CAAQ;AAExE,QAAAN,EAAMkB,CAAW,EAAE,MAAA;AAAA,MACvB;AACA;AAAA,IAGJ,KAAKF,EAAa;AACd,MAAAvB,EAAM,eAAA,GACNmB,EAAA;AAEA;AAAA,IAGJ,KAAKI,EAAa;AACd,MAAAvB,EAAM,eAAA,GACNqB,EAAA;AAEA;AAAA,EAGA;AAEZ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.es.js","sources":["../../../src/components/Tree/types.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type Active, type Collision, type Over, type Translate } from '@dnd-kit/core';\nimport { type useSortable } from '@dnd-kit/sortable';\nimport { type MutableRefObject, type ReactElement, type ReactNode } from 'react';\n\nimport { type Projection } from './helpers';\nimport { type InternalTreeItemProps } from './TreeItem';\nimport { type Overlay } from './TreeItem/TreeItemOverlay';\n\nexport type SensorContext = MutableRefObject<{\n nodes: ReactElement[];\n offset: number;\n}>;\n\nexport type TreeNodeWithoutElements = {\n id: string;\n level: number;\n parentId: string;\n extendedId: string;\n nodes: TreeNodeWithoutElements[];\n};\n\nexport type OnSelectCallback = (id: string, ignoreRemoveSelected?: boolean, nodes?: TreeNodeWithoutElements[]) => void;\nexport type OnSelectInternalCallback = (id: string, ignoreRemoveSelected?: boolean) => void;\nexport type OnExpandCallback = (id: string) => void;\n\nexport type OnShrinkCallback = (id: string) => void;\nexport type OnTreeDropCallback = (args: {\n id: string;\n parentId: Nullable<string>;\n sort: number;\n contentComponent: Nullable<ReactNode>;\n parentType?: string;\n}) => void;\n\nexport type DragHandlerPosition = 'left' | 'right' | 'none';\nexport type TreeItemPropsSizing = 'none' | 'x-small' | 'small' | 'medium' | 'large' | 'x-large';\ntype TreeItemContentFit = 'content-fit' | 'single-line';\ntype TreeItemBorderStyle = 'solid' | 'dashed' | 'dotted' | 'none';\nexport type TreeItemColors = 'neutral' | 'soft' | 'none';\ntype TreeItemColorStyles = {\n textColor: string;\n selectedTextColor: string;\n backgroundColor: string;\n selectedBackgroundColor: string;\n pressedBackgroundColor: string;\n dragHanlderTextColor: string;\n selectedDragHanlderTextColor: string;\n};\n\nexport const TreeItemSpacingClassMap: Record<TreeItemPropsSizing, string> = {\n none: 'tw-my-0',\n 'x-small': 'tw-my-0.5',\n small: 'tw-my-1',\n medium: 'tw-my-1.5',\n large: 'tw-my-2',\n 'x-large': 'tw-my-2.5',\n};\n\nexport const TreeItemShadowClassMap: Record<TreeItemPropsSizing, string> = {\n none: 'tw-shadow-none',\n 'x-small': 'tw-shadow-sm',\n small: 'tw-shadow',\n medium: 'tw-shadow-md',\n large: 'tw-shadow-lg',\n 'x-large': 'tw-shadow-xl',\n};\n\nexport const TreeItemBorderRadiusClassMap: Record<TreeItemPropsSizing, string> = {\n none: 'tw-rounded-none',\n 'x-small': 'tw-rounded-sm',\n small: 'tw-rounded',\n medium: 'tw-rounded-md',\n large: 'tw-rounded-lg',\n 'x-large': 'tw-rounded-xl',\n};\n\nexport const TreeItemBorderClassMap: Record<Exclude<TreeItemPropsSizing, 'x-large'>, string> = {\n none: 'tw-border-0',\n 'x-small': 'tw-border',\n small: 'tw-border-2',\n medium: 'tw-border-4',\n large: 'tw-border-8',\n};\n\nexport const TreeItemBorderStyleClassMap: Record<TreeItemBorderStyle, string> = {\n none: 'tw-border-none',\n solid: 'tw-border-solid',\n dotted: 'tw-border-dotted',\n dashed: 'tw-border-dashed',\n};\n\nexport const TreeItemColorsClassMap: Record<TreeItemColors, TreeItemColorStyles> = {\n none: {\n textColor: '',\n selectedTextColor: '',\n backgroundColor: '',\n selectedBackgroundColor: '',\n pressedBackgroundColor: '',\n dragHanlderTextColor: '',\n selectedDragHanlderTextColor: '',\n },\n soft: {\n textColor: 'tw-text-primary',\n selectedTextColor: 'tw-font-medium tw-text-primary',\n backgroundColor: 'group-hover:tw-bg-surface-hover',\n selectedBackgroundColor: 'tw-bg-surface-active group-hover:tw-bg-surface-hover',\n pressedBackgroundColor: 'group-active:tw-bg-surface-active',\n dragHanlderTextColor: 'tw-text-primary',\n selectedDragHanlderTextColor: 'tw-text-primary',\n },\n neutral: {\n textColor: 'tw-text-primary',\n selectedTextColor: 'tw-font-medium tw-text-primary',\n backgroundColor: 'group-hover:tw-bg-container-secondary-hover',\n selectedBackgroundColor: 'tw-bg-container-secondary-active group-hover:tw-bg-container-secondary-hover',\n pressedBackgroundColor: 'group-active:tw-bg-container-secondary-active',\n dragHanlderTextColor: 'tw-text-primary',\n selectedDragHanlderTextColor: 'tw-text-primary',\n },\n};\n\nexport type TreeItemStyling = {\n spacingY?: TreeItemPropsSizing;\n contentHight?: TreeItemContentFit;\n shadow?: TreeItemPropsSizing;\n borderRadius?: TreeItemPropsSizing;\n borderWidth?: Exclude<TreeItemPropsSizing, 'x-large'>;\n borderStyle?: TreeItemBorderStyle;\n activeColorStyle?: TreeItemColors;\n};\n\nexport type TreeProps = {\n id: string;\n draggable?: boolean;\n children: ReactNode;\n multiselect?: boolean;\n selectedIds?: string[];\n expandedIds?: string[];\n dragHandlerPosition?: DragHandlerPosition;\n enableDragDelay?: boolean;\n showDragHandlerOnHoverOnly?: boolean;\n showContentWhileDragging?: boolean;\n itemStyle?: TreeItemStyling;\n 'data-test-id'?: string;\n onSelect?: OnSelectCallback;\n onExpand?: OnExpandCallback;\n onShrink?: OnShrinkCallback;\n onDrop?: OnTreeDropCallback;\n};\n\ntype TreeItemBaseProps = {\n id: string;\n 'data-test-id'?: string;\n onDrop?: OnTreeDropCallback;\n /**\n * The type of item being dragged.\n */\n type?: string;\n /**\n * The kinds of dragItems this dropTarget accepts\n * @example 'itemA, itemA-within, itemA-deeper'\n * if suffix '-within' is appended, then it will allow dropping item inside it\n * if suffix '-deeper' is appended, then it will allow expand because it will allow dropping in levels deeper\n */\n accepts?: string;\n children?: ReactNode;\n draggable?: boolean;\n /** Removes the expand caret, recovering the space ignoring if there are children */\n expandable?: boolean;\n showDragHandlerOnHoverOnly?: boolean;\n /**\n * dragHandlerPosition = 'none' makes the whole item draggble rather than only the dragHandler\n */\n dragHandlerPosition?: DragHandlerPosition;\n showContentWhileDragging?: boolean;\n itemStyle?: TreeItemStyling;\n showCaret?: boolean;\n ignoreItemDoubleClick?: boolean;\n expandOnSelect?: boolean;\n levelConstraint?: Nullable<number>;\n};\n\nexport type TreeItemWithLabelProps = {\n label?: string;\n contentComponent?: never;\n} & TreeItemBaseProps;\n\nexport type TreeItemWithContentComponentProps = {\n label?: never;\n contentComponent?: ReactNode;\n} & TreeItemBaseProps;\n\nexport type SortableProps = Partial<ReturnType<typeof useSortable>>;\n\nexport type TreeItemProps = SortableProps & (TreeItemWithLabelProps | TreeItemWithContentComponentProps);\n\nexport type TreeItemMultiselectProps = Omit<\n TreeItemProps,\n | 'type'\n | 'onDrop'\n | 'accepts'\n | 'registerOverlay'\n | 'draggable'\n | 'showContentWhileDragging'\n | 'ignoreItemDoubleClick'\n | 'showDragHandlerOnHoverOnly'\n | 'dragHandlerPosition'\n> & {\n isDisabled?: boolean;\n checkBoxPosition?: DragHandlerPosition;\n onBeforeUnregisterChildren?: (id: string, nodes: TreeNodeWithoutElements[]) => void;\n};\n\nexport type SortableTreeItemProps = TreeItemProps;\n\nexport type TreeItemState = {\n parentId?: string;\n childrenIds?: string[];\n level: number;\n domElement?: HTMLElement;\n};\n\nexport type TreeState = {\n selectedIds: Set<string>;\n expandedIds: Set<string>;\n selectionMode: 'single' | 'multiselect';\n overlay?: Overlay;\n nodes: ReactElement<InternalTreeItemProps>[];\n rootNodes: ReactElement<InternalTreeItemProps>[];\n projection: Nullable<Projection>;\n};\n\nexport type TreeStateAction =\n | { type: 'REPLACE_STATE'; payload: TreeState }\n | { type: 'REGISTER_OVERLAY_ITEM'; payload: Overlay }\n | { type: 'SET_SELECT'; payload: string }\n | { type: 'EXPAND_NODE'; payload: string }\n | { type: 'SHRINK_NODE'; payload: string }\n | { type: 'SET_HIDDEN'; payload: { ids: string[]; isHidden: boolean } }\n | { type: 'SET_SELECTION_MODE'; payload: { selectionMode: TreeState['selectionMode'] } }\n | { type: 'SET_PROJECTION'; payload: Nullable<Projection> }\n | { type: 'REGISTER_NODE_CHILDREN'; payload: { id: string; children: ReactElement<InternalTreeItemProps>[] } }\n | { type: 'UNREGISTER_NODE_CHILDREN'; payload: string }\n | { type: 'REPLACE_EXPANDED'; payload: string[] }\n | { type: 'REPLACE_SELECTED'; payload: string[] }\n | { type: 'REGISTER_ROOT_NODES'; payload: ReactElement<InternalTreeItemProps>[] }\n | { type: 'REGISTER_NODES'; payload: ReactElement<InternalTreeItemProps>[] };\n\nexport type RegisterNodeChildrenPayload = Extract<TreeStateAction, { type: 'REGISTER_NODE_CHILDREN' }>['payload'];\n\nexport type CollisionPosition = Nullable<'before' | 'within' | 'after'>;\n\n// dnd-kit type overrides\nexport type TreeActive = Omit<Active, 'id'> & {\n id: string;\n};\n\nexport type TreeOver = Omit<Over, 'id'> & {\n id: string;\n};\n\ntype TreeCollision = Omit<Collision, 'id'> & {\n id: string;\n};\n\ntype TreeDragEvent = {\n activatorEvent: Event;\n active: TreeActive;\n collisions: TreeCollision[] | null;\n delta: Translate;\n over: TreeOver | null;\n};\n\nexport type TreeDragStartEvent = Pick<TreeDragEvent, 'active'>;\nexport type TreeDragMoveEvent = TreeDragEvent;\nexport type TreeDragOverEvent = TreeDragMoveEvent;\nexport type TreeDragEndEvent = TreeDragEvent;\nexport type TreeDragCancelEvent = TreeDragEndEvent;\n\nexport type TreeAnnouncements = {\n onDragStart({ active }: Pick<TreeDragEvent, 'active'>): string | undefined;\n onDragMove?({ active, over }: TreeDragEvent): string | undefined;\n onDragOver({ active, over }: TreeDragEvent): string | undefined;\n onDragEnd({ active, over }: TreeDragEvent): string | undefined;\n onDragCancel({ active, over }: TreeDragEvent): string | undefined;\n};\n"],"names":["TreeItemSpacingClassMap","TreeItemShadowClassMap","TreeItemBorderRadiusClassMap","TreeItemBorderClassMap","TreeItemBorderStyleClassMap","TreeItemColorsClassMap"],"mappings":"AAmDO,MAAMA,IAA+D;AAAA,EACxE,MAAM;AAAA,EACN,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,WAAW;AACf,GAEaC,IAA8D;AAAA,EACvE,MAAM;AAAA,EACN,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,WAAW;AACf,GAEaC,IAAoE;AAAA,EAC7E,MAAM;AAAA,EACN,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,WAAW;AACf,GAEaC,IAAkF;AAAA,EAC3F,MAAM;AAAA,EACN,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAEaC,IAAmE;AAAA,EAC5E,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AACZ,GAEaC,IAAsE;AAAA,EAC/E,MAAM;AAAA,IACF,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,iBAAiB;AAAA,IACjB,yBAAyB;AAAA,IACzB,wBAAwB;AAAA,IACxB,sBAAsB;AAAA,IACtB,8BAA8B;AAAA,EAAA;AAAA,EAElC,MAAM;AAAA,IACF,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,iBAAiB;AAAA,IACjB,yBAAyB;AAAA,IACzB,wBAAwB;AAAA,IACxB,sBAAsB;AAAA,IACtB,8BAA8B;AAAA,EAAA;AAAA,EAElC,SAAS;AAAA,IACL,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,iBAAiB;AAAA,IACjB,yBAAyB;AAAA,IACzB,wBAAwB;AAAA,IACxB,sBAAsB;AAAA,IACtB,8BAA8B;AAAA,EAAA;AAEtC;"}
1
+ {"version":3,"file":"types.es.js","sources":["../../../src/components/Tree/types.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type Active, type Collision, type Over, type Translate } from '@dnd-kit/core';\nimport { type useSortable } from '@dnd-kit/sortable';\nimport { type MutableRefObject, type ReactElement, type ReactNode } from 'react';\n\nimport { type Projection } from './helpers';\nimport { type InternalTreeItemProps } from './TreeItem';\nimport { type Overlay } from './TreeItem/TreeItemOverlay';\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type SensorContext = MutableRefObject<{\n nodes: ReactElement[];\n offset: number;\n}>;\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeNodeWithoutElements = {\n id: string;\n level: number;\n parentId: string;\n extendedId: string;\n nodes: TreeNodeWithoutElements[];\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type OnSelectCallback = (id: string, ignoreRemoveSelected?: boolean, nodes?: TreeNodeWithoutElements[]) => void;\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type OnSelectInternalCallback = (id: string, ignoreRemoveSelected?: boolean) => void;\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type OnExpandCallback = (id: string) => void;\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type OnShrinkCallback = (id: string) => void;\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type OnTreeDropCallback = (args: {\n id: string;\n parentId: Nullable<string>;\n sort: number;\n contentComponent: Nullable<ReactNode>;\n parentType?: string;\n}) => void;\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type DragHandlerPosition = 'left' | 'right' | 'none';\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeItemPropsSizing = 'none' | 'x-small' | 'small' | 'medium' | 'large' | 'x-large';\ntype TreeItemContentFit = 'content-fit' | 'single-line';\ntype TreeItemBorderStyle = 'solid' | 'dashed' | 'dotted' | 'none';\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeItemColors = 'neutral' | 'soft' | 'none';\ntype TreeItemColorStyles = {\n textColor: string;\n selectedTextColor: string;\n backgroundColor: string;\n selectedBackgroundColor: string;\n pressedBackgroundColor: string;\n dragHanlderTextColor: string;\n selectedDragHanlderTextColor: string;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const TreeItemSpacingClassMap: Record<TreeItemPropsSizing, string> = {\n none: 'tw-my-0',\n 'x-small': 'tw-my-0.5',\n small: 'tw-my-1',\n medium: 'tw-my-1.5',\n large: 'tw-my-2',\n 'x-large': 'tw-my-2.5',\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const TreeItemShadowClassMap: Record<TreeItemPropsSizing, string> = {\n none: 'tw-shadow-none',\n 'x-small': 'tw-shadow-sm',\n small: 'tw-shadow',\n medium: 'tw-shadow-md',\n large: 'tw-shadow-lg',\n 'x-large': 'tw-shadow-xl',\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const TreeItemBorderRadiusClassMap: Record<TreeItemPropsSizing, string> = {\n none: 'tw-rounded-none',\n 'x-small': 'tw-rounded-sm',\n small: 'tw-rounded',\n medium: 'tw-rounded-md',\n large: 'tw-rounded-lg',\n 'x-large': 'tw-rounded-xl',\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const TreeItemBorderClassMap: Record<Exclude<TreeItemPropsSizing, 'x-large'>, string> = {\n none: 'tw-border-0',\n 'x-small': 'tw-border',\n small: 'tw-border-2',\n medium: 'tw-border-4',\n large: 'tw-border-8',\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const TreeItemBorderStyleClassMap: Record<TreeItemBorderStyle, string> = {\n none: 'tw-border-none',\n solid: 'tw-border-solid',\n dotted: 'tw-border-dotted',\n dashed: 'tw-border-dashed',\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const TreeItemColorsClassMap: Record<TreeItemColors, TreeItemColorStyles> = {\n none: {\n textColor: '',\n selectedTextColor: '',\n backgroundColor: '',\n selectedBackgroundColor: '',\n pressedBackgroundColor: '',\n dragHanlderTextColor: '',\n selectedDragHanlderTextColor: '',\n },\n soft: {\n textColor: 'tw-text-primary',\n selectedTextColor: 'tw-font-medium tw-text-primary',\n backgroundColor: 'group-hover:tw-bg-surface-hover',\n selectedBackgroundColor: 'tw-bg-surface-active group-hover:tw-bg-surface-hover',\n pressedBackgroundColor: 'group-active:tw-bg-surface-active',\n dragHanlderTextColor: 'tw-text-primary',\n selectedDragHanlderTextColor: 'tw-text-primary',\n },\n neutral: {\n textColor: 'tw-text-primary',\n selectedTextColor: 'tw-font-medium tw-text-primary',\n backgroundColor: 'group-hover:tw-bg-container-secondary-hover',\n selectedBackgroundColor: 'tw-bg-container-secondary-active group-hover:tw-bg-container-secondary-hover',\n pressedBackgroundColor: 'group-active:tw-bg-container-secondary-active',\n dragHanlderTextColor: 'tw-text-primary',\n selectedDragHanlderTextColor: 'tw-text-primary',\n },\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeItemStyling = {\n spacingY?: TreeItemPropsSizing;\n contentHight?: TreeItemContentFit;\n shadow?: TreeItemPropsSizing;\n borderRadius?: TreeItemPropsSizing;\n borderWidth?: Exclude<TreeItemPropsSizing, 'x-large'>;\n borderStyle?: TreeItemBorderStyle;\n activeColorStyle?: TreeItemColors;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeProps = {\n id: string;\n draggable?: boolean;\n children: ReactNode;\n multiselect?: boolean;\n selectedIds?: string[];\n expandedIds?: string[];\n dragHandlerPosition?: DragHandlerPosition;\n enableDragDelay?: boolean;\n showDragHandlerOnHoverOnly?: boolean;\n showContentWhileDragging?: boolean;\n itemStyle?: TreeItemStyling;\n 'data-test-id'?: string;\n onSelect?: OnSelectCallback;\n onExpand?: OnExpandCallback;\n onShrink?: OnShrinkCallback;\n onDrop?: OnTreeDropCallback;\n};\n\ntype TreeItemBaseProps = {\n id: string;\n 'data-test-id'?: string;\n onDrop?: OnTreeDropCallback;\n /**\n * The type of item being dragged.\n */\n type?: string;\n /**\n * The kinds of dragItems this dropTarget accepts\n * @example 'itemA, itemA-within, itemA-deeper'\n * if suffix '-within' is appended, then it will allow dropping item inside it\n * if suffix '-deeper' is appended, then it will allow expand because it will allow dropping in levels deeper\n */\n accepts?: string;\n children?: ReactNode;\n draggable?: boolean;\n /** Removes the expand caret, recovering the space ignoring if there are children */\n expandable?: boolean;\n showDragHandlerOnHoverOnly?: boolean;\n /**\n * dragHandlerPosition = 'none' makes the whole item draggble rather than only the dragHandler\n */\n dragHandlerPosition?: DragHandlerPosition;\n showContentWhileDragging?: boolean;\n itemStyle?: TreeItemStyling;\n showCaret?: boolean;\n ignoreItemDoubleClick?: boolean;\n expandOnSelect?: boolean;\n levelConstraint?: Nullable<number>;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeItemWithLabelProps = {\n label?: string;\n contentComponent?: never;\n} & TreeItemBaseProps;\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeItemWithContentComponentProps = {\n label?: never;\n contentComponent?: ReactNode;\n} & TreeItemBaseProps;\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type SortableProps = Partial<ReturnType<typeof useSortable>>;\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeItemProps = SortableProps & (TreeItemWithLabelProps | TreeItemWithContentComponentProps);\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeItemMultiselectProps = Omit<\n TreeItemProps,\n | 'type'\n | 'onDrop'\n | 'accepts'\n | 'registerOverlay'\n | 'draggable'\n | 'showContentWhileDragging'\n | 'ignoreItemDoubleClick'\n | 'showDragHandlerOnHoverOnly'\n | 'dragHandlerPosition'\n> & {\n isDisabled?: boolean;\n checkBoxPosition?: DragHandlerPosition;\n onBeforeUnregisterChildren?: (id: string, nodes: TreeNodeWithoutElements[]) => void;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type SortableTreeItemProps = TreeItemProps;\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeItemState = {\n parentId?: string;\n childrenIds?: string[];\n level: number;\n domElement?: HTMLElement;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeState = {\n selectedIds: Set<string>;\n expandedIds: Set<string>;\n selectionMode: 'single' | 'multiselect';\n overlay?: Overlay;\n nodes: ReactElement<InternalTreeItemProps>[];\n rootNodes: ReactElement<InternalTreeItemProps>[];\n projection: Nullable<Projection>;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeStateAction =\n | { type: 'REPLACE_STATE'; payload: TreeState }\n | { type: 'REGISTER_OVERLAY_ITEM'; payload: Overlay }\n | { type: 'SET_SELECT'; payload: string }\n | { type: 'EXPAND_NODE'; payload: string }\n | { type: 'SHRINK_NODE'; payload: string }\n | { type: 'SET_HIDDEN'; payload: { ids: string[]; isHidden: boolean } }\n | { type: 'SET_SELECTION_MODE'; payload: { selectionMode: TreeState['selectionMode'] } }\n | { type: 'SET_PROJECTION'; payload: Nullable<Projection> }\n | { type: 'REGISTER_NODE_CHILDREN'; payload: { id: string; children: ReactElement<InternalTreeItemProps>[] } }\n | { type: 'UNREGISTER_NODE_CHILDREN'; payload: string }\n | { type: 'REPLACE_EXPANDED'; payload: string[] }\n | { type: 'REPLACE_SELECTED'; payload: string[] }\n | { type: 'REGISTER_ROOT_NODES'; payload: ReactElement<InternalTreeItemProps>[] }\n | { type: 'REGISTER_NODES'; payload: ReactElement<InternalTreeItemProps>[] };\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type RegisterNodeChildrenPayload = Extract<TreeStateAction, { type: 'REGISTER_NODE_CHILDREN' }>['payload'];\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type CollisionPosition = Nullable<'before' | 'within' | 'after'>;\n\n// dnd-kit type overrides\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeActive = Omit<Active, 'id'> & {\n id: string;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeOver = Omit<Over, 'id'> & {\n id: string;\n};\n\ntype TreeCollision = Omit<Collision, 'id'> & {\n id: string;\n};\n\ntype TreeDragEvent = {\n activatorEvent: Event;\n active: TreeActive;\n collisions: TreeCollision[] | null;\n delta: Translate;\n over: TreeOver | null;\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeDragStartEvent = Pick<TreeDragEvent, 'active'>;\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeDragMoveEvent = TreeDragEvent;\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeDragOverEvent = TreeDragMoveEvent;\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeDragEndEvent = TreeDragEvent;\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeDragCancelEvent = TreeDragEndEvent;\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport type TreeAnnouncements = {\n onDragStart({ active }: Pick<TreeDragEvent, 'active'>): string | undefined;\n onDragMove?({ active, over }: TreeDragEvent): string | undefined;\n onDragOver({ active, over }: TreeDragEvent): string | undefined;\n onDragEnd({ active, over }: TreeDragEvent): string | undefined;\n onDragCancel({ active, over }: TreeDragEvent): string | undefined;\n};\n"],"names":["TreeItemSpacingClassMap","TreeItemShadowClassMap","TreeItemBorderRadiusClassMap","TreeItemBorderClassMap","TreeItemBorderStyleClassMap","TreeItemColorsClassMap"],"mappings":"AAoFO,MAAMA,IAA+D;AAAA,EACxE,MAAM;AAAA,EACN,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,WAAW;AACf,GAKaC,IAA8D;AAAA,EACvE,MAAM;AAAA,EACN,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,WAAW;AACf,GAKaC,IAAoE;AAAA,EAC7E,MAAM;AAAA,EACN,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,WAAW;AACf,GAKaC,IAAkF;AAAA,EAC3F,MAAM;AAAA,EACN,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAKaC,IAAmE;AAAA,EAC5E,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AACZ,GAKaC,IAAsE;AAAA,EAC/E,MAAM;AAAA,IACF,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,iBAAiB;AAAA,IACjB,yBAAyB;AAAA,IACzB,wBAAwB;AAAA,IACxB,sBAAsB;AAAA,IACtB,8BAA8B;AAAA,EAAA;AAAA,EAElC,MAAM;AAAA,IACF,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,iBAAiB;AAAA,IACjB,yBAAyB;AAAA,IACzB,wBAAwB;AAAA,IACxB,sBAAsB;AAAA,IACtB,8BAA8B;AAAA,EAAA;AAAA,EAElC,SAAS;AAAA,IACL,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,iBAAiB;AAAA,IACjB,yBAAyB;AAAA,IACzB,wBAAwB;AAAA,IACxB,sBAAsB;AAAA,IACtB,8BAA8B;AAAA,EAAA;AAEtC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"keyboardCoordinates.es.js","sources":["../../../../src/components/Tree/utils/keyboardCoordinates.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n type DroppableContainer,\n KeyboardCode,\n type KeyboardCoordinateGetter,\n closestCorners,\n getFirstCollision,\n} from '@dnd-kit/core';\n\nimport { INDENTATION_WIDTH, getProjection } from '../helpers';\nimport { type SensorContext } from '../types';\n\nconst directions: string[] = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];\n\nconst horizontal: string[] = [KeyboardCode.Left, KeyboardCode.Right];\n\nexport const sortableTreeKeyboardCoordinates: (context: SensorContext) => KeyboardCoordinateGetter =\n (context) =>\n (event, { currentCoordinates, context: { active, over, collisionRect, droppableRects, droppableContainers } }) => {\n if (directions.includes(event.code)) {\n if (!active || !collisionRect) {\n return;\n }\n\n event.preventDefault();\n\n const {\n current: { nodes, offset },\n } = context;\n\n if (horizontal.includes(event.code) && over?.id) {\n const { depth, maxDepth, minDepth } = getProjection({\n nodes,\n activeId: active.id as string,\n overId: over.id as string,\n dragOffset: offset,\n });\n\n switch (event.code) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Left:\n if (depth > minDepth) {\n return {\n ...currentCoordinates,\n x: currentCoordinates.x - INDENTATION_WIDTH,\n };\n }\n break;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Right:\n if (depth < maxDepth) {\n return {\n ...currentCoordinates,\n x: currentCoordinates.x + INDENTATION_WIDTH,\n };\n }\n break;\n }\n\n return undefined;\n }\n\n const containers: DroppableContainer[] = [];\n\n for (const [containerId, container] of droppableContainers) {\n if (container?.disabled || containerId === over?.id) {\n continue;\n }\n\n const rect = droppableRects.get(containerId);\n\n if (!rect) {\n continue;\n }\n\n switch (event.code) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Down:\n if (collisionRect.top < rect.top) {\n containers.push(container);\n }\n break;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Up:\n if (collisionRect.top > rect.top) {\n containers.push(container);\n }\n break;\n }\n }\n\n const collisions = closestCorners({\n active,\n collisionRect,\n pointerCoordinates: null,\n droppableRects,\n droppableContainers: containers,\n });\n\n let closestId = getFirstCollision(collisions, 'id');\n\n if (closestId === over?.id && collisions.length > 1) {\n closestId = collisions[1].id;\n }\n\n if (closestId && over?.id) {\n const activeRect = droppableRects.get(active.id);\n const newRect = droppableRects.get(closestId);\n const newDroppable = droppableContainers.get(closestId);\n\n if (activeRect && newRect && newDroppable) {\n const newIndex = nodes.findIndex(({ props }) => props.id === closestId);\n const newNode = nodes[newIndex];\n const activeIndex = nodes.findIndex(({ props }) => props.id === active.id);\n const activeNode = nodes[activeIndex];\n\n const dragOffset = (newNode.props.level - activeNode.props.level) * INDENTATION_WIDTH;\n\n if (newNode && activeNode) {\n const { depth } = getProjection({\n nodes,\n activeId: active.id as string,\n overId: closestId as string,\n dragOffset,\n });\n\n const isBelow = newIndex > activeIndex;\n const modifier = isBelow ? 1 : -1;\n const offset = (collisionRect.height - activeRect.height) / 2;\n\n const newCoordinates = {\n x: newRect.left + depth * INDENTATION_WIDTH,\n y: newRect.top + modifier * offset,\n };\n\n return newCoordinates;\n }\n }\n }\n }\n\n return undefined;\n };\n"],"names":["directions","KeyboardCode","horizontal","sortableTreeKeyboardCoordinates","context","event","currentCoordinates","active","over","collisionRect","droppableRects","droppableContainers","nodes","offset","depth","maxDepth","minDepth","getProjection","INDENTATION_WIDTH","containers","containerId","container","rect","collisions","closestCorners","closestId","getFirstCollision","activeRect","newRect","newDroppable","newIndex","props","newNode","activeIndex","activeNode","dragOffset","modifier"],"mappings":";;;AAaA,MAAMA,IAAuB,CAACC,EAAa,MAAMA,EAAa,OAAOA,EAAa,IAAIA,EAAa,IAAI,GAEjGC,IAAuB,CAACD,EAAa,MAAMA,EAAa,KAAK,GAEtDE,IACT,CAACC,MACD,CAACC,GAAO,EAAE,oBAAAC,GAAoB,SAAS,EAAE,QAAAC,GAAQ,MAAAC,GAAM,eAAAC,GAAe,gBAAAC,GAAgB,qBAAAC,EAAA,QAA4B;AAC9G,MAAIX,EAAW,SAASK,EAAM,IAAI,GAAG;AACjC,QAAI,CAACE,KAAU,CAACE;AACZ;AAGJ,IAAAJ,EAAM,eAAA;AAEN,UAAM;AAAA,MACF,SAAS,EAAE,OAAAO,GAAO,QAAAC,EAAA;AAAA,IAAO,IACzBT;AAEJ,QAAIF,EAAW,SAASG,EAAM,IAAI,MAAKG,KAAA,QAAAA,EAAM,KAAI;AAC7C,YAAM,EAAE,OAAAM,GAAO,UAAAC,GAAU,UAAAC,EAAA,IAAaC,EAAc;AAAA,QAChD,OAAAL;AAAA,QACA,UAAUL,EAAO;AAAA,QACjB,QAAQC,EAAK;AAAA,QACb,YAAYK;AAAA,MAAA,CACf;AAED,cAAQR,EAAM,MAAA;AAAA,QAEV,KAAKJ,EAAa;AACd,cAAIa,IAAQE;AACR,mBAAO;AAAA,cACH,GAAGV;AAAA,cACH,GAAGA,EAAmB,IAAIY;AAAA,YAAA;AA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,OAAAmB,QAAYA,EAAM,OAAOxB,EAAO,EAAE,GACnE2B,IAAatB,EAAMqB,CAAW,GAE9BE,KAAcH,EAAQ,MAAM,QAAQE,EAAW,MAAM,SAAShB;AAEpE,YAAIc,KAAWE,GAAY;AACvB,gBAAM,EAAE,OAAApB,EAAA,IAAUG,EAAc;AAAA,YAC5B,OAAAL;AAAA,YACA,UAAUL,EAAO;AAAA,YACjB,QAAQkB;AAAA,YACR,YAAAU;AAAA,UAAA,CACH,GAGKC,IADUN,IAAWG,IACA,IAAI,IACzBpB,KAAUJ,EAAc,SAASkB,EAAW,UAAU;AAO5D,iBALuB;AAAA,YACnB,GAAGC,EAAQ,OAAOd,IAAQI;AAAA,YAC1B,GAAGU,EAAQ,MAAMQ,IAAWvB;AAAAA,UAAA;AAAA,QAIpC;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AAGJ;"}
1
+ {"version":3,"file":"keyboardCoordinates.es.js","sources":["../../../../src/components/Tree/utils/keyboardCoordinates.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n type DroppableContainer,\n KeyboardCode,\n type KeyboardCoordinateGetter,\n closestCorners,\n getFirstCollision,\n} from '@dnd-kit/core';\n\nimport { INDENTATION_WIDTH, getProjection } from '../helpers';\nimport { type SensorContext } from '../types';\n\nconst directions: string[] = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];\n\nconst horizontal: string[] = [KeyboardCode.Left, KeyboardCode.Right];\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const sortableTreeKeyboardCoordinates: (context: SensorContext) => KeyboardCoordinateGetter =\n (context) =>\n (event, { currentCoordinates, context: { active, over, collisionRect, droppableRects, droppableContainers } }) => {\n if (directions.includes(event.code)) {\n if (!active || !collisionRect) {\n return;\n }\n\n event.preventDefault();\n\n const {\n current: { nodes, offset },\n } = context;\n\n if (horizontal.includes(event.code) && over?.id) {\n const { depth, maxDepth, minDepth } = getProjection({\n nodes,\n activeId: active.id as string,\n overId: over.id as string,\n dragOffset: offset,\n });\n\n switch (event.code) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Left:\n if (depth > minDepth) {\n return {\n ...currentCoordinates,\n x: currentCoordinates.x - INDENTATION_WIDTH,\n };\n }\n break;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Right:\n if (depth < maxDepth) {\n return {\n ...currentCoordinates,\n x: currentCoordinates.x + INDENTATION_WIDTH,\n };\n }\n break;\n }\n\n return undefined;\n }\n\n const containers: DroppableContainer[] = [];\n\n for (const [containerId, container] of droppableContainers) {\n if (container?.disabled || containerId === over?.id) {\n continue;\n }\n\n const rect = droppableRects.get(containerId);\n\n if (!rect) {\n continue;\n }\n\n switch (event.code) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Down:\n if (collisionRect.top < rect.top) {\n containers.push(container);\n }\n break;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case KeyboardCode.Up:\n if (collisionRect.top > rect.top) {\n containers.push(container);\n }\n break;\n }\n }\n\n const collisions = closestCorners({\n active,\n collisionRect,\n pointerCoordinates: null,\n droppableRects,\n droppableContainers: containers,\n });\n\n let closestId = getFirstCollision(collisions, 'id');\n\n if (closestId === over?.id && collisions.length > 1) {\n closestId = collisions[1].id;\n }\n\n if (closestId && over?.id) {\n const activeRect = droppableRects.get(active.id);\n const newRect = droppableRects.get(closestId);\n const newDroppable = droppableContainers.get(closestId);\n\n if (activeRect && newRect && newDroppable) {\n const newIndex = nodes.findIndex(({ props }) => props.id === closestId);\n const newNode = nodes[newIndex];\n const activeIndex = nodes.findIndex(({ props }) => props.id === active.id);\n const activeNode = nodes[activeIndex];\n\n const dragOffset = (newNode.props.level - activeNode.props.level) * INDENTATION_WIDTH;\n\n if (newNode && activeNode) {\n const { depth } = getProjection({\n nodes,\n activeId: active.id as string,\n overId: closestId as string,\n dragOffset,\n });\n\n const isBelow = newIndex > activeIndex;\n const modifier = isBelow ? 1 : -1;\n const offset = (collisionRect.height - activeRect.height) / 2;\n\n const newCoordinates = {\n x: newRect.left + depth * INDENTATION_WIDTH,\n y: newRect.top + modifier * offset,\n };\n\n return newCoordinates;\n }\n }\n }\n }\n\n return undefined;\n };\n"],"names":["directions","KeyboardCode","horizontal","sortableTreeKeyboardCoordinates","context","event","currentCoordinates","active","over","collisionRect","droppableRects","droppableContainers","nodes","offset","depth","maxDepth","minDepth","getProjection","INDENTATION_WIDTH","containers","containerId","container","rect","collisions","closestCorners","closestId","getFirstCollision","activeRect","newRect","newDroppable","newIndex","props","newNode","activeIndex","activeNode","dragOffset","modifier"],"mappings":";;;AAaA,MAAMA,IAAuB,CAACC,EAAa,MAAMA,EAAa,OAAOA,EAAa,IAAIA,EAAa,IAAI,GAEjGC,IAAuB,CAACD,EAAa,MAAMA,EAAa,KAAK,GAKtDE,IACT,CAACC,MACD,CAACC,GAAO,EAAE,oBAAAC,GAAoB,SAAS,EAAE,QAAAC,GAAQ,MAAAC,GAAM,eAAAC,GAAe,gBAAAC,GAAgB,qBAAAC,EAAA,QAA4B;AAC9G,MAAIX,EAAW,SAASK,EAAM,IAAI,GAAG;AACjC,QAAI,CAACE,KAAU,CAACE;AACZ;AAGJ,IAAAJ,EAAM,eAAA;AAEN,UAAM;AAAA,MACF,SAAS,EAAE,OAAAO,GAAO,QAAAC,EAAA;AAAA,IAAO,IACzBT;AAEJ,QAAIF,EAAW,SAASG,EAAM,IAAI,MAAKG,KAAA,QAAAA,EAAM,KAAI;AAC7C,YAAM,EAAE,OAAAM,GAAO,UAAAC,GAAU,UAAAC,EAAA,IAAaC,EAAc;AAAA,QAChD,OAAAL;AAAA,QACA,UAAUL,EAAO;AAAA,QACjB,QAAQC,EAAK;AAAA,QACb,YAAYK;AAAA,MAAA,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c;AACvC,cAAMC,IAAWlB,EAAM,UAAU,CAAC,EAAE,OAAAmB,QAAYA,EAAM,OAAON,CAAS,GAChEO,IAAUpB,EAAMkB,CAAQ,GACxBG,IAAcrB,EAAM,UAAU,CAAC,EAAE,OAAAmB,QAAYA,EAAM,OAAOxB,EAAO,EAAE,GACnE2B,IAAatB,EAAMqB,CAAW,GAE9BE,KAAcH,EAAQ,MAAM,QAAQE,EAAW,MAAM,SAAShB;AAEpE,YAAIc,KAAWE,GAAY;AACvB,gBAAM,EAAE,OAAApB,EAAA,IAAUG,EAAc;AAAA,YAC5B,OAAAL;AAAA,YACA,UAAUL,EAAO;AAAA,YACjB,QAAQkB;AAAA,YACR,YAAAU;AAAA,UAAA,CACH,GAGKC,IADUN,IAAWG,IACA,IAAI,IACzBpB,KAAUJ,EAAc,SAASkB,EAAW,UAAU;AAO5D,iBALuB;AAAA,YACnB,GAAGC,EAAQ,OAAOd,IAAQI;AAAA,YAC1B,GAAGU,EAAQ,MAAMQ,IAAWvB;AAAAA,UAAA;AAAA,QAIpC;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AAGJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"removeFragmentsAndEnrichChildren.es.js","sources":["../../../../src/components/Tree/utils/removeFragmentsAndEnrichChildren.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Children, type ReactElement, type ReactNode, cloneElement, isValidElement } from 'react';\nimport { isFragment } from 'react-is';\n\ntype EnrichedProps = {\n parentId: string;\n level: number;\n};\n\n/**\n * Recursively removes React Fragments and enriches the remaining child elements passed in with additional properties.\n *\n * @param children The child elements to remove React Fragments from and enrich.\n * @param enrichedProps Additional properties to add to each child element.\n * @returns An array of ReactElements with enriched props.\n *\n * @example\n *\n * const children = (\n * <>\n * <Child1 />\n * <Child2 />\n * <Child3 />\n * </>\n * );\n *\n * const enrichedProps = {\n * parentId: '12345',\n * level: 2,\n * };\n *\n * const flattenedAndEnriched = flattenAndEnrichChildren(children, enrichedProps);\n *\n * @returns {ReactElement[]} Array with the three child elements from the example, each with the `parentId` and `level` props added.\n */\nexport const removeFragmentsAndEnrichChildren = (children?: ReactNode, enrichedProps?: EnrichedProps) => {\n const result: ReactElement[] = [];\n\n Children.forEach(children, (child) => {\n if (isFragment(child)) {\n result.push(...removeFragmentsAndEnrichChildren(child.props.children, enrichedProps));\n } else {\n if (isValidElement(child)) {\n result.push(cloneElement(child, { ...(child.props ?? {}), ...enrichedProps }));\n }\n }\n });\n\n return result.filter(Boolean);\n};\n\nexport const recursivelyRemoveFragmentsAndEnrichChildren = (\n children?: ReactNode,\n enrichedProps?: EnrichedProps,\n): ReactElement[] => {\n if (!children) {\n return [];\n }\n\n const enriched = removeFragmentsAndEnrichChildren(children, enrichedProps);\n\n return enriched.map((child: ReactElement) => {\n const newEnriched = {\n ...child,\n props: {\n ...child.props,\n children: recursivelyRemoveFragmentsAndEnrichChildren(child.props.children, {\n parentId: child.props.id,\n level: child.props.level + 1,\n }),\n },\n };\n\n return newEnriched;\n });\n};\n"],"names":["removeFragmentsAndEnrichChildren","children","enrichedProps","result","Children","child","isFragment","isValidElement","cloneElement","recursivelyRemoveFragmentsAndEnrichChildren"],"mappings":";;AAoCO,MAAMA,IAAmC,CAACC,GAAsBC,MAAkC;AACrG,QAAMC,IAAyB,CAAA;AAE/B,SAAAC,EAAS,QAAQH,GAAU,CAACI,MAAU;AAClC,IAAIC,EAAWD,CAAK,IAChBF,EAAO,KAAK,GAAGH,EAAiCK,EAAM,MAAM,UAAUH,CAAa,CAAC,IAEhFK,EAAeF,CAAK,KACpBF,EAAO,KAAKK,EAAaH,GAAO,EAAE,GAAIA,EAAM,SAAS,CAAA,GAAK,GAAGH,EAAA,CAAe,CAAC;AAAA,EAGzF,CAAC,GAEMC,EAAO,OAAO,OAAO;AAChC,GAEaM,IAA8C,CACvDR,GACAC,MAEKD,IAIYD,EAAiCC,GAAUC,CAAa,EAEzD,IAAI,CAACG,OACG;AAAA,EAChB,GAAGA;AAAA,EACH,OAAO;AAAA,IACH,GAAGA,EAAM;AAAA,IACT,UAAUI,EAA4CJ,EAAM,MAAM,UAAU;AAAA,MACxE,UAAUA,EAAM,MAAM;AAAA,MACtB,OAAOA,EAAM,MAAM,QAAQ;AAAA,IAAA,CAC9B;AAAA,EAAA;AACL,EAIP,IAlBU,CAAA;"}
1
+ {"version":3,"file":"removeFragmentsAndEnrichChildren.es.js","sources":["../../../../src/components/Tree/utils/removeFragmentsAndEnrichChildren.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Children, type ReactElement, type ReactNode, cloneElement, isValidElement } from 'react';\nimport { isFragment } from 'react-is';\n\ntype EnrichedProps = {\n parentId: string;\n level: number;\n};\n\n/**\n * Recursively removes React Fragments and enriches the remaining child elements passed in with additional properties.\n *\n * @param children The child elements to remove React Fragments from and enrich.\n * @param enrichedProps Additional properties to add to each child element.\n * @returns An array of ReactElements with enriched props.\n *\n * @example\n *\n * const children = (\n * <>\n * <Child1 />\n * <Child2 />\n * <Child3 />\n * </>\n * );\n *\n * const enrichedProps = {\n * parentId: '12345',\n * level: 2,\n * };\n *\n * const flattenedAndEnriched = flattenAndEnrichChildren(children, enrichedProps);\n *\n * @returns {ReactElement[]} Array with the three child elements from the example, each with the `parentId` and `level` props added.\n *\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const removeFragmentsAndEnrichChildren = (children?: ReactNode, enrichedProps?: EnrichedProps) => {\n const result: ReactElement[] = [];\n\n Children.forEach(children, (child) => {\n if (isFragment(child)) {\n result.push(...removeFragmentsAndEnrichChildren(child.props.children, enrichedProps));\n } else {\n if (isValidElement(child)) {\n result.push(cloneElement(child, { ...(child.props ?? {}), ...enrichedProps }));\n }\n }\n });\n\n return result.filter(Boolean);\n};\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const recursivelyRemoveFragmentsAndEnrichChildren = (\n children?: ReactNode,\n enrichedProps?: EnrichedProps,\n): ReactElement[] => {\n if (!children) {\n return [];\n }\n\n const enriched = removeFragmentsAndEnrichChildren(children, enrichedProps);\n\n return enriched.map((child: ReactElement) => {\n const newEnriched = {\n ...child,\n props: {\n ...child.props,\n children: recursivelyRemoveFragmentsAndEnrichChildren(child.props.children, {\n parentId: child.props.id,\n level: child.props.level + 1,\n }),\n },\n };\n\n return newEnriched;\n });\n};\n"],"names":["removeFragmentsAndEnrichChildren","children","enrichedProps","result","Children","child","isFragment","isValidElement","cloneElement","recursivelyRemoveFragmentsAndEnrichChildren"],"mappings":";;AAsCO,MAAMA,IAAmC,CAACC,GAAsBC,MAAkC;AACrG,QAAMC,IAAyB,CAAA;AAE/B,SAAAC,EAAS,QAAQH,GAAU,CAACI,MAAU;AAClC,IAAIC,EAAWD,CAAK,IAChBF,EAAO,KAAK,GAAGH,EAAiCK,EAAM,MAAM,UAAUH,CAAa,CAAC,IAEhFK,EAAeF,CAAK,KACpBF,EAAO,KAAKK,EAAaH,GAAO,EAAE,GAAIA,EAAM,SAAS,CAAA,GAAK,GAAGH,EAAA,CAAe,CAAC;AAAA,EAGzF,CAAC,GAEMC,EAAO,OAAO,OAAO;AAChC,GAKaM,IAA8C,CACvDR,GACAC,MAEKD,IAIYD,EAAiCC,GAAUC,CAAa,EAEzD,IAAI,CAACG,OACG;AAAA,EAChB,GAAGA;AAAA,EACH,OAAO;AAAA,IACH,GAAGA,EAAM;AAAA,IACT,UAAUI,EAA4CJ,EAAM,MAAM,UAAU;AAAA,MACxE,UAAUA,EAAM,MAAM;AAAA,MACtB,OAAOA,EAAM,MAAM,QAAQ;AAAA,IAAA,CAC9B;AAAA,EAAA;AACL,EAIP,IAlBU,CAAA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDeepCompareEffect.es.js","sources":["../../../../src/components/Tree/utils/useDeepCompareEffect.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type DependencyList, type EffectCallback, useEffect, useRef } from 'react';\nimport isEqual from 'react-fast-compare';\n\nconst isPrimitive = (val: unknown): boolean => val !== Object(val);\n\nexport const useDeepCompareEffect = (effect: EffectCallback, deps: unknown[]): void => {\n if (process.env.NODE_ENV !== 'production') {\n if (!deps || deps.length === 0) {\n console.warn('`useDeepCompareEffect` should not be used with no dependencies. Use `useEffect` instead.');\n }\n\n if (deps.every(isPrimitive)) {\n console.warn(\n '`useDeepCompareEffect` should not be used with dependencies that are all primitive values. Use `useEffect` instead.',\n );\n }\n }\n\n const ref = useRef<DependencyList | undefined>(undefined);\n\n if (!isEqual(deps, ref.current)) {\n ref.current = deps;\n }\n\n // Intended eslint disable, it doesn't pick ref.current as dependencies array\n // eslint-disable-next-line @eslint-react/exhaustive-deps\n useEffect(effect, ref.current);\n};\n"],"names":["isPrimitive","val","useDeepCompareEffect","effect","deps","ref","useRef","isEqual","useEffect"],"mappings":";;AAKA,MAAMA,IAAc,CAACC,MAA0BA,MAAQ,OAAOA,CAAG,GAEpDC,IAAuB,CAACC,GAAwBC,MAA0B;AACnF,EAAI,QAAQ,IAAI,aAAa,kBACrB,CAACA,KAAQA,EAAK,WAAW,MACzB,QAAQ,KAAK,0FAA0F,GAGvGA,EAAK,MAAMJ,CAAW,KACtB,QAAQ;AAAA,IACJ;AAAA,EAAA;AAKZ,QAAMK,IAAMC,EAAmC,MAAS;AAExD,EAAKC,EAAQH,GAAMC,EAAI,OAAO,MAC1BA,EAAI,UAAUD,IAKlBI,EAAUL,GAAQE,EAAI,OAAO;AACjC;"}
1
+ {"version":3,"file":"useDeepCompareEffect.es.js","sources":["../../../../src/components/Tree/utils/useDeepCompareEffect.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type DependencyList, type EffectCallback, useEffect, useRef } from 'react';\nimport isEqual from 'react-fast-compare';\n\nconst isPrimitive = (val: unknown): boolean => val !== Object(val);\n\n/**\n * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.\n */\nexport const useDeepCompareEffect = (effect: EffectCallback, deps: unknown[]): void => {\n if (process.env.NODE_ENV !== 'production') {\n if (!deps || deps.length === 0) {\n console.warn('`useDeepCompareEffect` should not be used with no dependencies. Use `useEffect` instead.');\n }\n\n if (deps.every(isPrimitive)) {\n console.warn(\n '`useDeepCompareEffect` should not be used with dependencies that are all primitive values. Use `useEffect` instead.',\n );\n }\n }\n\n const ref = useRef<DependencyList | undefined>(undefined);\n\n if (!isEqual(deps, ref.current)) {\n ref.current = deps;\n }\n\n // Intended eslint disable, it doesn't pick ref.current as dependencies array\n // eslint-disable-next-line @eslint-react/exhaustive-deps\n useEffect(effect, ref.current);\n};\n"],"names":["isPrimitive","val","useDeepCompareEffect","effect","deps","ref","useRef","isEqual","useEffect"],"mappings":";;AAKA,MAAMA,IAAc,CAACC,MAA0BA,MAAQ,OAAOA,CAAG,GAKpDC,IAAuB,CAACC,GAAwBC,MAA0B;AACnF,EAAI,QAAQ,IAAI,aAAa,kBACrB,CAACA,KAAQA,EAAK,WAAW,MACzB,QAAQ,KAAK,0FAA0F,GAGvGA,EAAK,MAAMJ,CAAW,KACtB,QAAQ;AAAA,IACJ;AAAA,EAAA;AAKZ,QAAMK,IAAMC,EAAmC,MAAS;AAExD,EAAKC,EAAQH,GAAMC,EAAI,OAAO,MAC1BA,EAAI,UAAUD,IAKlBI,EAAUL,GAAQE,EAAI,OAAO;AACjC;"}