@elliemae/ds-treeview 1.61.10 → 1.61.13

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 (93) hide show
  1. package/cjs/TreeView.js.map +1 -1
  2. package/cjs/TreeViewContext.js.map +1 -1
  3. package/cjs/deprecated/TreeView.js.map +1 -1
  4. package/cjs/deprecated/__testUtils__/utils.js.map +1 -1
  5. package/cjs/deprecated/plugins/dnd/TreeDndPlugin.js.map +1 -1
  6. package/cjs/deprecated/plugins/dnd/renderers/DraggableItem.js.map +1 -1
  7. package/cjs/deprecated/plugins/dnd/renderers/DroppableList.js.map +1 -1
  8. package/cjs/deprecated/plugins/dnd/utils.js.map +1 -1
  9. package/cjs/deprecated/plugins/roving/TreeRovingPlugin.js.map +1 -1
  10. package/cjs/deprecated/plugins/searchable/SearchableTreePlugin.js.map +1 -1
  11. package/cjs/deprecated/plugins/selectable/SelectablePluginTree.js.map +1 -1
  12. package/cjs/deprecated/plugins/selectable/utils.js.map +1 -1
  13. package/cjs/deprecated/plugins/toolbar/TreeToolbarPlugin.js.map +1 -1
  14. package/cjs/deprecated/plugins/tree/TreeDataPlugin.js.map +1 -1
  15. package/cjs/deprecated/plugins/tree/useExpandTreeState.js.map +1 -1
  16. package/cjs/deprecated/plugins/tree/utils.js.map +1 -1
  17. package/cjs/deprecated/plugins/tree/walkTreeStrategy.js.map +1 -1
  18. package/cjs/deprecated/plugins/virtualization/TreeVirtualizationPlugin.js.map +1 -1
  19. package/cjs/deprecated/renderers.js.map +1 -1
  20. package/cjs/index-69815fd3.js.map +1 -1
  21. package/cjs/index.js.map +1 -1
  22. package/cjs/parts/CheckboxSelectable.js.map +1 -1
  23. package/cjs/parts/ChildrenCountDisplayer.js.map +1 -1
  24. package/cjs/parts/ExpandCaret.js.map +1 -1
  25. package/cjs/parts/Icon.js.map +1 -1
  26. package/cjs/parts/NestingSpace.js.map +1 -1
  27. package/cjs/parts/RadioSelectable.js.map +1 -1
  28. package/cjs/parts/TreeItem.js.map +1 -1
  29. package/cjs/parts/TreeItemText.js.map +1 -1
  30. package/cjs/parts/TreeList.js.map +1 -1
  31. package/cjs/plugins/dnd/TreeDndPlugin.js.map +1 -1
  32. package/cjs/prop-types.js.map +1 -1
  33. package/cjs/react-desc-prop-types.js.map +1 -1
  34. package/cjs/related-components/TreeViewSearchBar.js.map +1 -1
  35. package/cjs/utils/array-helpers.js.map +1 -1
  36. package/cjs/utils/dnd-helpers.js.map +1 -1
  37. package/cjs/utils/group-expands-helpers.js.map +1 -1
  38. package/cjs/utils/keyboard-helpers.js.map +1 -1
  39. package/cjs/utils/object-helpers.js.map +1 -1
  40. package/cjs/utils/refs-helpers.js.map +1 -1
  41. package/cjs/utils/selectable-helper.js.map +1 -1
  42. package/cjs/utils/string-helpers.js.map +1 -1
  43. package/cjs/utils/tree-helpers.js.map +1 -1
  44. package/cjs/utils/useDnDHelpers.js.map +1 -1
  45. package/cjs/utils/useInstanceRefActions.js.map +1 -1
  46. package/cjs/utils/useTree.js.map +1 -1
  47. package/esm/TreeView.js.map +1 -1
  48. package/esm/TreeViewContext.js.map +1 -1
  49. package/esm/deprecated/TreeView.js.map +1 -1
  50. package/esm/deprecated/__testUtils__/utils.js.map +1 -1
  51. package/esm/deprecated/plugins/dnd/TreeDndPlugin.js.map +1 -1
  52. package/esm/deprecated/plugins/dnd/renderers/DraggableItem.js.map +1 -1
  53. package/esm/deprecated/plugins/dnd/renderers/DroppableList.js.map +1 -1
  54. package/esm/deprecated/plugins/dnd/utils.js.map +1 -1
  55. package/esm/deprecated/plugins/roving/TreeRovingPlugin.js.map +1 -1
  56. package/esm/deprecated/plugins/searchable/SearchableTreePlugin.js.map +1 -1
  57. package/esm/deprecated/plugins/selectable/SelectablePluginTree.js.map +1 -1
  58. package/esm/deprecated/plugins/selectable/utils.js.map +1 -1
  59. package/esm/deprecated/plugins/toolbar/TreeToolbarPlugin.js.map +1 -1
  60. package/esm/deprecated/plugins/tree/TreeDataPlugin.js.map +1 -1
  61. package/esm/deprecated/plugins/tree/useExpandTreeState.js.map +1 -1
  62. package/esm/deprecated/plugins/tree/utils.js.map +1 -1
  63. package/esm/deprecated/plugins/tree/walkTreeStrategy.js.map +1 -1
  64. package/esm/deprecated/plugins/virtualization/TreeVirtualizationPlugin.js.map +1 -1
  65. package/esm/deprecated/renderers.js.map +1 -1
  66. package/esm/index-f9def0ea.js.map +1 -1
  67. package/esm/index.js.map +1 -1
  68. package/esm/parts/CheckboxSelectable.js.map +1 -1
  69. package/esm/parts/ChildrenCountDisplayer.js.map +1 -1
  70. package/esm/parts/ExpandCaret.js.map +1 -1
  71. package/esm/parts/Icon.js.map +1 -1
  72. package/esm/parts/NestingSpace.js.map +1 -1
  73. package/esm/parts/RadioSelectable.js.map +1 -1
  74. package/esm/parts/TreeItem.js.map +1 -1
  75. package/esm/parts/TreeItemText.js.map +1 -1
  76. package/esm/parts/TreeList.js.map +1 -1
  77. package/esm/plugins/dnd/TreeDndPlugin.js.map +1 -1
  78. package/esm/prop-types.js.map +1 -1
  79. package/esm/react-desc-prop-types.js.map +1 -1
  80. package/esm/related-components/TreeViewSearchBar.js.map +1 -1
  81. package/esm/utils/array-helpers.js.map +1 -1
  82. package/esm/utils/dnd-helpers.js.map +1 -1
  83. package/esm/utils/group-expands-helpers.js.map +1 -1
  84. package/esm/utils/keyboard-helpers.js.map +1 -1
  85. package/esm/utils/object-helpers.js.map +1 -1
  86. package/esm/utils/refs-helpers.js.map +1 -1
  87. package/esm/utils/selectable-helper.js.map +1 -1
  88. package/esm/utils/string-helpers.js.map +1 -1
  89. package/esm/utils/tree-helpers.js.map +1 -1
  90. package/esm/utils/useDnDHelpers.js.map +1 -1
  91. package/esm/utils/useInstanceRefActions.js.map +1 -1
  92. package/esm/utils/useTree.js.map +1 -1
  93. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"TreeView.js","sources":["../../src/TreeView.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable max-statements */\nimport React, { useState, useRef, useEffect } from 'react';\nimport { useVirtual } from 'react-virtual';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { describe } from 'react-desc';\nimport { TreeViewPropTypes } from './react-desc-prop-types';\nimport TreeViewContext, { defaultProps, defaultRelativeMouseCoord } from './TreeViewContext';\nimport { TreeDnD, TreeDndPlugin } from './plugins/dnd';\nimport { useTree } from './utils/useTree';\nimport { TreeList } from './parts/TreeList';\nimport { useNotifyExpandedChange } from './utils/group-expands-helpers';\nimport { useInstanceRefActions } from './utils/useInstanceRefActions';\nimport { useGlobalToggleAllExpandShortcut } from './utils/keyboard-helpers';\nexport function TreeView(props) {\n const treeRef = useRef({ actions: {} });\n const { data, plugins, onOrderChange, isMultiSelect, isSingleSelect, instanceRef, selection } = props;\n const [isDragging, setIsDragging] = useState(false);\n const [isKeyboardDragging, setIsKeyboardDragging] = useState(false);\n const [draggedItem, setDraggedItem] = useState(null);\n const [hoverItem, setHoverItem] = useState(null);\n const [relativeMouseCord, setRelativeMouseCord] = useState(defaultRelativeMouseCoord);\n const [uniqueTreeViewUUID] = useState(uuidv4());\n const [latestToggledItem, setLatestToggledItem] = useState(null);\n const [selectedItem, setSelectedItem] = useState(null);\n const [focusedItem, setFocusedItem] = useState(null);\n const [selectedCheckboxes, setSelectedCheckboxes] = useState({\n ...selection,\n });\n const [expandedGroups, setExpandedGroups] = useState({});\n\n const { visibleItems, tree, treeRoot, triggerTreeRerender } = useTree(data, props, {\n setExpandedGroups,\n });\n\n const virtualListRef = useRef();\n // estimateSize should not be really required given what was stated on\n // https://github.com/tannerlinsley/react-virtual/issues/23\n\n const virtualListHelpers = useVirtual({\n size: visibleItems.length,\n parentRef: virtualListRef,\n overscan: 15,\n });\n\n const withDragAndDrop = plugins?.includes(TreeDndPlugin) && onOrderChange;\n const withRadioChecks = isSingleSelect && !isMultiSelect;\n const withCheckboxChecks = !isSingleSelect && isMultiSelect;\n\n const ctx = {\n props,\n setRelativeMouseCord,\n relativeMouseCord,\n virtualListHelpers,\n virtualListRef,\n tree,\n treeRoot,\n visibleItems,\n triggerTreeRerender,\n isDragging,\n setIsDragging,\n isKeyboardDragging,\n setIsKeyboardDragging,\n draggedItem,\n setDraggedItem,\n withRadioChecks,\n withCheckboxChecks,\n withDragAndDrop,\n uniqueTreeViewUUID,\n selectedCheckboxes,\n setSelectedCheckboxes,\n selectedItem,\n setSelectedItem,\n expandedGroups,\n setExpandedGroups,\n latestToggledItem,\n setLatestToggledItem,\n focusedItem,\n setFocusedItem,\n hoverItem,\n setHoverItem,\n };\n // this hooks can't use the context because the context provider doesn't wrap this\n // as such we manually pass the second parameter as fit\n if (instanceRef) instanceRef.current = treeRef.current;\n useInstanceRefActions(treeRef.current, ctx);\n useGlobalToggleAllExpandShortcut(treeRoot, triggerTreeRerender, setLatestToggledItem);\n useNotifyExpandedChange(props, ctx);\n\n useEffect(() => {\n setTimeout(() => {\n ctx.props.onInstanceRefInitialized(treeRef);\n }, 100);\n }, []);\n\n return (\n <TreeViewContext.Provider value={ctx}>\n {plugins?.includes(TreeDndPlugin) ? <TreeDnD /> : <TreeList />}\n </TreeViewContext.Provider>\n );\n}\n\nTreeView.propTypes = TreeViewPropTypes;\nTreeView.defaultProps = defaultProps;\n\nconst TreeViewWithSchema = describe(TreeView);\nTreeViewWithSchema.propTypes = TreeViewPropTypes;\n\nexport { TreeViewWithSchema };\n"],"names":["TreeView","props","treeRef","useRef","actions","data","plugins","onOrderChange","isMultiSelect","isSingleSelect","instanceRef","selection","useState","isDragging","setIsDragging","isKeyboardDragging","setIsKeyboardDragging","draggedItem","setDraggedItem","hoverItem","setHoverItem","defaultRelativeMouseCoord","relativeMouseCord","setRelativeMouseCord","uuidv4","uniqueTreeViewUUID","latestToggledItem","setLatestToggledItem","selectedItem","setSelectedItem","focusedItem","setFocusedItem","selectedCheckboxes","setSelectedCheckboxes","expandedGroups","setExpandedGroups","useTree","visibleItems","tree","treeRoot","triggerTreeRerender","virtualListRef","virtualListHelpers","useVirtual","size","length","parentRef","overscan","withDragAndDrop","includes","TreeDndPlugin","withRadioChecks","withCheckboxChecks","ctx","current","useInstanceRefActions","useGlobalToggleAllExpandShortcut","useNotifyExpandedChange","useEffect","setTimeout","onInstanceRefInitialized","React","TreeViewContext","TreeDnD","TreeList","propTypes","TreeViewPropTypes","defaultProps","TreeViewWithSchema","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,SAASA,QAAT,CAAkBC,KAAlB,EAAyB;AAC9B,MAAMC,OAAO,GAAGC,YAAM,CAAC;AAAEC,IAAAA,OAAO,EAAE;AAAX,GAAD,CAAtB;AACA,MAAQC,IAAR,GAAgGJ,KAAhG,CAAQI,IAAR;AAAA,MAAcC,OAAd,GAAgGL,KAAhG,CAAcK,OAAd;AAAA,MAAuBC,aAAvB,GAAgGN,KAAhG,CAAuBM,aAAvB;AAAA,MAAsCC,aAAtC,GAAgGP,KAAhG,CAAsCO,aAAtC;AAAA,MAAqDC,cAArD,GAAgGR,KAAhG,CAAqDQ,cAArD;AAAA,MAAqEC,WAArE,GAAgGT,KAAhG,CAAqES,WAArE;AAAA,MAAkFC,SAAlF,GAAgGV,KAAhG,CAAkFU,SAAlF;;AACA,kBAAoCC,cAAQ,CAAC,KAAD,CAA5C;AAAA;AAAA,MAAOC,UAAP;AAAA,MAAmBC,aAAnB;;AACA,mBAAoDF,cAAQ,CAAC,KAAD,CAA5D;AAAA;AAAA,MAAOG,kBAAP;AAAA,MAA2BC,qBAA3B;;AACA,mBAAsCJ,cAAQ,CAAC,IAAD,CAA9C;AAAA;AAAA,MAAOK,WAAP;AAAA,MAAoBC,cAApB;;AACA,mBAAkCN,cAAQ,CAAC,IAAD,CAA1C;AAAA;AAAA,MAAOO,SAAP;AAAA,MAAkBC,YAAlB;;AACA,mBAAkDR,cAAQ,CAACS,yCAAD,CAA1D;AAAA;AAAA,MAAOC,iBAAP;AAAA,MAA0BC,oB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,WAAJ,EAAiBA,WAAW,CAAC4C,OAAZ,GAAsBpD,OAAO,CAACoD,OAA9B;AACjBC,EAAAA,iDAAqB,CAACrD,OAAO,CAACoD,OAAT,EAAkBD,GAAlB,CAArB;AACAG,EAAAA,sDAAgC,CAACjB,QAAD,EAAWC,mBAAX,EAAgCb,oBAAhC,CAAhC;AACA8B,EAAAA,iDAAuB,CAACxD,KAAD,EAAQoD,GAAR,CAAvB;AAEAK,EAAAA,eAAS,CAAC,YAAM;AACdC,IAAAA,UAAU,CAAC,YAAM;AACfN,MAAAA,GAAG,CAACpD,KAAJ,CAAU2D,wBAAV,CAAmC1D,OAAnC;AACD,KAFS,EAEP,GAFO,CAAV;AAGD,GAJQ,EAIN,EAJM,CAAT;AAMA,sBACE2D,wCAACC,0BAAD,CAAiB,QAAjB;AAA0B,IAAA,KAAK,EAAET;AAAjC,KACG/C,OAAO,SAAP,IAAAA,OAAO,WAAP,IAAAA,OAAO,CAAE2C,QAAT,CAAkBC,uCAAlB,iBAAmCW,wCAACE,iCAAD,OAAnC,gBAAiDF,wCAACG,uBAAD,OADpD,CADF;AAKD;AAEDhE,QAAQ,CAACiE,SAAT,GAAqBC,oCAArB;AACAlE,QAAQ,CAACmE,YAAT,GAAwBA,4BAAxB;IAEMC,kBAAkB,GAAGC,kBAAQ,CAACrE,QAAD;AACnCoE,kBAAkB,CAACH,SAAnB,GAA+BC,oCAA/B;;;;;"}
1
+ {"version":3,"file":"TreeView.js","sources":["../../src/TreeView.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable max-statements */\nimport React, { useState, useRef, useEffect } from 'react';\nimport { useVirtual } from 'react-virtual';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { describe } from 'react-desc';\nimport { TreeViewPropTypes } from './react-desc-prop-types';\nimport TreeViewContext, { defaultProps, defaultRelativeMouseCoord } from './TreeViewContext';\nimport { TreeDnD, TreeDndPlugin } from './plugins/dnd';\nimport { useTree } from './utils/useTree';\nimport { TreeList } from './parts/TreeList';\nimport { useNotifyExpandedChange } from './utils/group-expands-helpers';\nimport { useInstanceRefActions } from './utils/useInstanceRefActions';\nimport { useGlobalToggleAllExpandShortcut } from './utils/keyboard-helpers';\nexport function TreeView(props) {\n const treeRef = useRef({ actions: {} });\n const { data, plugins, onOrderChange, isMultiSelect, isSingleSelect, instanceRef, selection } = props;\n const [isDragging, setIsDragging] = useState(false);\n const [isKeyboardDragging, setIsKeyboardDragging] = useState(false);\n const [draggedItem, setDraggedItem] = useState(null);\n const [hoverItem, setHoverItem] = useState(null);\n const [relativeMouseCord, setRelativeMouseCord] = useState(defaultRelativeMouseCoord);\n const [uniqueTreeViewUUID] = useState(uuidv4());\n const [latestToggledItem, setLatestToggledItem] = useState(null);\n const [selectedItem, setSelectedItem] = useState(null);\n const [focusedItem, setFocusedItem] = useState(null);\n const [selectedCheckboxes, setSelectedCheckboxes] = useState({\n ...selection,\n });\n const [expandedGroups, setExpandedGroups] = useState({});\n\n const { visibleItems, tree, treeRoot, triggerTreeRerender } = useTree(data, props, {\n setExpandedGroups,\n });\n\n const virtualListRef = useRef();\n // estimateSize should not be really required given what was stated on\n // https://github.com/tannerlinsley/react-virtual/issues/23\n\n const virtualListHelpers = useVirtual({\n size: visibleItems.length,\n parentRef: virtualListRef,\n overscan: 15,\n });\n\n const withDragAndDrop = plugins?.includes(TreeDndPlugin) && onOrderChange;\n const withRadioChecks = isSingleSelect && !isMultiSelect;\n const withCheckboxChecks = !isSingleSelect && isMultiSelect;\n\n const ctx = {\n props,\n setRelativeMouseCord,\n relativeMouseCord,\n virtualListHelpers,\n virtualListRef,\n tree,\n treeRoot,\n visibleItems,\n triggerTreeRerender,\n isDragging,\n setIsDragging,\n isKeyboardDragging,\n setIsKeyboardDragging,\n draggedItem,\n setDraggedItem,\n withRadioChecks,\n withCheckboxChecks,\n withDragAndDrop,\n uniqueTreeViewUUID,\n selectedCheckboxes,\n setSelectedCheckboxes,\n selectedItem,\n setSelectedItem,\n expandedGroups,\n setExpandedGroups,\n latestToggledItem,\n setLatestToggledItem,\n focusedItem,\n setFocusedItem,\n hoverItem,\n setHoverItem,\n };\n // this hooks can't use the context because the context provider doesn't wrap this\n // as such we manually pass the second parameter as fit\n if (instanceRef) instanceRef.current = treeRef.current;\n useInstanceRefActions(treeRef.current, ctx);\n useGlobalToggleAllExpandShortcut(treeRoot, triggerTreeRerender, setLatestToggledItem);\n useNotifyExpandedChange(props, ctx);\n\n useEffect(() => {\n setTimeout(() => {\n ctx.props.onInstanceRefInitialized(treeRef);\n }, 100);\n }, []);\n\n return (\n <TreeViewContext.Provider value={ctx}>\n {plugins?.includes(TreeDndPlugin) ? <TreeDnD /> : <TreeList />}\n </TreeViewContext.Provider>\n );\n}\n\nTreeView.propTypes = TreeViewPropTypes;\nTreeView.defaultProps = defaultProps;\n\nconst TreeViewWithSchema = describe(TreeView);\nTreeViewWithSchema.propTypes = TreeViewPropTypes;\n\nexport { TreeViewWithSchema };\n"],"names":["TreeView","props","treeRef","useRef","actions","data","plugins","onOrderChange","isMultiSelect","isSingleSelect","instanceRef","selection","useState","isDragging","setIsDragging","isKeyboardDragging","setIsKeyboardDragging","draggedItem","setDraggedItem","hoverItem","setHoverItem","defaultRelativeMouseCoord","relativeMouseCord","setRelativeMouseCord","uuidv4","uniqueTreeViewUUID","latestToggledItem","setLatestToggledItem","selectedItem","setSelectedItem","focusedItem","setFocusedItem","selectedCheckboxes","setSelectedCheckboxes","expandedGroups","setExpandedGroups","useTree","visibleItems","tree","treeRoot","triggerTreeRerender","virtualListRef","virtualListHelpers","useVirtual","size","length","parentRef","overscan","withDragAndDrop","includes","TreeDndPlugin","withRadioChecks","withCheckboxChecks","ctx","current","useInstanceRefActions","useGlobalToggleAllExpandShortcut","useNotifyExpandedChange","useEffect","setTimeout","onInstanceRefInitialized","React","TreeViewContext","TreeDnD","TreeList","propTypes","TreeViewPropTypes","defaultProps","TreeViewWithSchema","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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/B;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeViewContext.js","sources":["../../src/TreeViewContext.tsx"],"sourcesContent":["/* eslint-disable no-unused-vars */\nimport { createContext, createRef } from 'react';\n// import Folder from '@elliemae/ds-icons/Folder';\n// import FilePdf from '@elliemae/ds-icons/FilePdf';\n\nexport const defaultProps = {\n plugins: [],\n selection: {}, // { [id]:[state] } -> e.g. {1:true, 2:'mixed'}\n instanceRef: createRef(),\n disableGroups: false,\n disableLeafs: false,\n disableIcons: false,\n fluid: false,\n isMultiSelect: false,\n isSingleSelect: false,\n restrictDragAndDrop: false,\n showChildrenAmount: false,\n sortable: false,\n isLoading: false,\n highlightOnlyQuery: false,\n onInstanceRefInitialized: (istanceRef) => {},\n onItemClick: (item, e) => {},\n onItemFocus: (params) => {}, // { itemIndex: number, scrollToItem: func }\n onVisibleItemsChange: (newVisibleItems) => {},\n onOrderChange: (newData, oldData, draggedItem) => {},\n onSelectionChange: (selectionHasmap, item, indexAndScrollTo) => {}, // indexAndScrollTo = { scrollToItem: ()=>{}, itemIndex :number }\n onExpandChange: (expandedHashmap, itemToggled) => {}, // expandedHashmap -> {[id]:true, ...[id]:true} itemToggled -> item that caused the change for being toggled\n rowSize: 'normal', // ['normal', 'compact']\n labelOverflow: 'wrap', // ['wrap', 'wrap-all', 'truncate']\n noItemsPlaceholder: 'No items found',\n nameKey: 'name', // use to retrieve the label text inside ever data item\n width: '100%',\n height: '100%',\n groupIcon: null, // <Folder />,\n itemIcon: null, // <FilePdf />,\n searchQuery: '',\n};\n\nexport const defaultRelativeMouseCoord = {\n isBefore: false,\n isAfter: false,\n isValid: true,\n item: null,\n x: null,\n y: null,\n relativeElementDOMRect: null,\n relativeElementIndex: null,\n};\n\n/** Context for cross component communication */\nconst TreeViewContext = createContext({\n props: defaultProps,\n visibleItems: [],\n withRadioChecks: false,\n withCheckboxChecks: false,\n withDragAndDrop: false,\n relativeMouseCord: defaultRelativeMouseCoord,\n setRelativeMouseCord: () => {},\n labelRenderer: (value) => value,\n triggerTreeRerender: () => {},\n tree: {},\n virtualListHelpers: {},\n virtualListRef: {},\n treeRoot: {},\n isDragging: false,\n setIsDragging: () => {},\n isKeyboardDragging: false,\n setIsKeyboardDragging: () => {},\n draggedItem: null, // item\n setDraggedItem: () => {},\n uniqueTreeViewUUID: '',\n selectedItem: null, // item\n setSelectedItem: () => {},\n focusedItem: null, // item\n setFocusedItem: () => {},\n selectedCheckboxes: {}, // { [id]:[state] } -> e.g. {1:true, 2:'mixed'}\n setSelectedCheckboxes: () => {},\n expandedGroups: {}, // { [id]:true } -> e.g. {1:true, 2:true} // false are not listed\n setExpandedGroups: () => {},\n latestToggledItem: null, // item -> if toggle all -> should be undefined\n setLatestToggledItem: () => {},\n hoverItem: null, // item\n setHoverItem: () => {},\n});\n\nexport default TreeViewContext;\n"],"names":["defaultProps","plugins","selection","instanceRef","createRef","disableGroups","disableLeafs","disableIcons","fluid","isMultiSelect","isSingleSelect","restrictDragAndDrop","showChildrenAmount","sortable","isLoading","highlightOnlyQuery","onInstanceRefInitialized","istanceRef","onItemClick","item","e","onItemFocus","params","onVisibleItemsChange","newVisibleItems","onOrderChange","newData","oldData","draggedItem","onSelectionChange","selectionHasmap","indexAndScrollTo","onExpandChange","expandedHashmap","itemToggled","rowSize","labelOverflow","noItemsPlaceholder","nameKey","width","height","groupIcon","itemIcon","searchQuery","defaultRelativeMouseCoord","isBefore","isAfter","isValid","x","y","relativeElementDOMRect","relativeElementIndex","TreeViewContext","createContext","props","visibleItems","withRadioChecks","withCheckboxChecks","withDragAndDrop","relativeMouseCord","setRelativeMouseCord","labelRenderer","value","triggerTreeRerender","tree","virtualListHelpers","virtualListRef","treeRoot","isDragging","setIsDragging","isKeyboardDragging","setIsKeyboardDragging","setDraggedItem","uniqueTreeViewUUID","selectedItem","setSelectedItem","focusedItem","setFocusedItem","selectedCheckboxes","setSelectedCheckboxes","expandedGroups","setExpandedGroups","latestToggledItem","setLatestToggledItem","hoverItem","setHoverIt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IAlBuB;AAkBjB;AACnB4C,EAAAA,cAAc,EAAE,0BAAM,EAnBc;AAoBpCC,EAAAA,kBAAkB,EAAE,EApBgB;AAqBpCC,EAAAA,YAAY,EAAE,IArBsB;AAqBhB;AACpBC,EAAAA,eAAe,EAAE,2BAAM,EAtBa;AAuBpCC,EAAAA,WAAW,EAAE,IAvBuB;AAuBjB;AACnBC,EAAAA,cAAc,EAAE,0BAAM,EAxBc;AAyBpCC,EAAAA,kBAAkB,EAAE,EAzBgB;AAyBZ;AACxBC,EAAAA,qBAAqB,EAAE,iCAAM,EA1BO;AA2BpCC,EAAAA,cAAc,EAAE,EA3BoB;AA2BhB;AACpBC,EAAAA,iBAAiB,EAAE,6BAAM,EA5BW;AA6BpCC,EAAAA,iBAAiB,EAAE,IA7BiB;AA6BX;AACzBC,EAAAA,oBAAoB,EAAE,gCAAM,EA9BQ;AA+BpCC,EAAAA,SAAS,EAAE,IA/ByB;AA+BnB;AACjBC,EAAAA,YAAY,EAAE,wBAAM;AAhCgB,CAAD;;;;;;"}
1
+ {"version":3,"file":"TreeViewContext.js","sources":["../../src/TreeViewContext.tsx"],"sourcesContent":["/* eslint-disable no-unused-vars */\nimport { createContext, createRef } from 'react';\n// import Folder from '@elliemae/ds-icons/Folder';\n// import FilePdf from '@elliemae/ds-icons/FilePdf';\n\nexport const defaultProps = {\n plugins: [],\n selection: {}, // { [id]:[state] } -> e.g. {1:true, 2:'mixed'}\n instanceRef: createRef(),\n disableGroups: false,\n disableLeafs: false,\n disableIcons: false,\n fluid: false,\n isMultiSelect: false,\n isSingleSelect: false,\n restrictDragAndDrop: false,\n showChildrenAmount: false,\n sortable: false,\n isLoading: false,\n highlightOnlyQuery: false,\n onInstanceRefInitialized: (istanceRef) => {},\n onItemClick: (item, e) => {},\n onItemFocus: (params) => {}, // { itemIndex: number, scrollToItem: func }\n onVisibleItemsChange: (newVisibleItems) => {},\n onOrderChange: (newData, oldData, draggedItem) => {},\n onSelectionChange: (selectionHasmap, item, indexAndScrollTo) => {}, // indexAndScrollTo = { scrollToItem: ()=>{}, itemIndex :number }\n onExpandChange: (expandedHashmap, itemToggled) => {}, // expandedHashmap -> {[id]:true, ...[id]:true} itemToggled -> item that caused the change for being toggled\n rowSize: 'normal', // ['normal', 'compact']\n labelOverflow: 'wrap', // ['wrap', 'wrap-all', 'truncate']\n noItemsPlaceholder: 'No items found',\n nameKey: 'name', // use to retrieve the label text inside ever data item\n width: '100%',\n height: '100%',\n groupIcon: null, // <Folder />,\n itemIcon: null, // <FilePdf />,\n searchQuery: '',\n};\n\nexport const defaultRelativeMouseCoord = {\n isBefore: false,\n isAfter: false,\n isValid: true,\n item: null,\n x: null,\n y: null,\n relativeElementDOMRect: null,\n relativeElementIndex: null,\n};\n\n/** Context for cross component communication */\nconst TreeViewContext = createContext({\n props: defaultProps,\n visibleItems: [],\n withRadioChecks: false,\n withCheckboxChecks: false,\n withDragAndDrop: false,\n relativeMouseCord: defaultRelativeMouseCoord,\n setRelativeMouseCord: () => {},\n labelRenderer: (value) => value,\n triggerTreeRerender: () => {},\n tree: {},\n virtualListHelpers: {},\n virtualListRef: {},\n treeRoot: {},\n isDragging: false,\n setIsDragging: () => {},\n isKeyboardDragging: false,\n setIsKeyboardDragging: () => {},\n draggedItem: null, // item\n setDraggedItem: () => {},\n uniqueTreeViewUUID: '',\n selectedItem: null, // item\n setSelectedItem: () => {},\n focusedItem: null, // item\n setFocusedItem: () => {},\n selectedCheckboxes: {}, // { [id]:[state] } -> e.g. {1:true, 2:'mixed'}\n setSelectedCheckboxes: () => {},\n expandedGroups: {}, // { [id]:true } -> e.g. {1:true, 2:true} // false are not listed\n setExpandedGroups: () => {},\n latestToggledItem: null, // item -> if toggle all -> should be undefined\n setLatestToggledItem: () => {},\n hoverItem: null, // item\n setHoverItem: () => {},\n});\n\nexport default TreeViewContext;\n"],"names":["defaultProps","plugins","selection","instanceRef","createRef","disableGroups","disableLeafs","disableIcons","fluid","isMultiSelect","isSingleSelect","restrictDragAndDrop","showChildrenAmount","sortable","isLoading","highlightOnlyQuery","onInstanceRefInitialized","istanceRef","onItemClick","item","e","onItemFocus","params","onVisibleItemsChange","newVisibleItems","onOrderChange","newData","oldData","draggedItem","onSelectionChange","selectionHasmap","indexAndScrollTo","onExpandChange","expandedHashmap","itemToggled","rowSize","labelOverflow","noItemsPlaceholder","nameKey","width","height","groupIcon","itemIcon","searchQuery","defaultRelativeMouseCoord","isBefore","isAfter","isValid","x","y","relativeElementDOMRect","relativeElementIndex","TreeViewContext","createContext","props","visibleItems","withRadioChecks","withCheckboxChecks","withDragAndDrop","relativeMouseCord","setRelativeMouseCord","labelRenderer","value","triggerTreeRerender","tree","virtualListHelpers","virtualListRef","treeRoot","isDragging","setIsDragging","isKeyboardDragging","setIsKeyboardDragging","setDraggedItem","uniqueTreeViewUUID","selectedItem","setSelectedItem","focusedItem","setFocusedItem","selectedCheckboxes","setSelectedCheckboxes","expandedGroups","setExpandedGroups","latestToggledItem","setLatestToggledItem","hoverItem","setHoverItem"],"mappings":";;;;;;AAAA;AAGA;;IAEaA,YAAY,GAAG;EAC1BC,OAAO,EAAE,EADiB;EAE1BC,SAAS,EAAE,EAFe;;EAG1BC,WAAW,eAAEC,eAAS,EAHI;EAI1BC,aAAa,EAAE,KAJW;EAK1BC,YAAY,EAAE,KALY;EAM1BC,YAAY,EAAE,KANY;EAO1BC,KAAK,EAAE,KAPmB;EAQ1BC,aAAa,EAAE,KARW;EAS1BC,cAAc,EAAE,KATU;EAU1BC,mBAAmB,EAAE,KAVK;EAW1BC,kBAAkB,EAAE,KAXM;EAY1BC,QAAQ,EAAE,KAZgB;EAa1BC,SAAS,EAAE,KAbe;EAc1BC,kBAAkB,EAAE,KAdM;EAe1BC,wBAAwB,EAAE,kCAACC,UAAD,EAAgB,EAfhB;EAgB1BC,WAAW,EAAE,qBAACC,IAAD,EAAOC,CAAP,EAAa,EAhBA;EAiB1BC,WAAW,EAAE,qBAACC,MAAD,EAAY,EAjBC;;EAkB1BC,oBAAo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QAAQ,EAAE,EAb0B;EAcpCC,UAAU,EAAE,KAdwB;EAepCC,aAAa,EAAE,yBAAM,EAfe;EAgBpCC,kBAAkB,EAAE,KAhBgB;EAiBpCC,qBAAqB,EAAE,iCAAM,EAjBO;EAkBpC3C,WAAW,EAAE,IAlBuB;;EAmBpC4C,cAAc,EAAE,0BAAM,EAnBc;EAoBpCC,kBAAkB,EAAE,EApBgB;EAqBpCC,YAAY,EAAE,IArBsB;;EAsBpCC,eAAe,EAAE,2BAAM,EAtBa;EAuBpCC,WAAW,EAAE,IAvBuB;;EAwBpCC,cAAc,EAAE,0BAAM,EAxBc;EAyBpCC,kBAAkB,EAAE,EAzBgB;;EA0BpCC,qBAAqB,EAAE,iCAAM,EA1BO;EA2BpCC,cAAc,EAAE,EA3BoB;;EA4BpCC,iBAAiB,EAAE,6BAAM,EA5BW;EA6BpCC,iBAAiB,EAAE,IA7BiB;;EA8BpCC,oBAAoB,EAAE,gCAAM,EA9BQ;EA+BpCC,SAAS,EAAE,IA/ByB;;EAgCpCC,YAAY,EAAE,wBAAM;AAhCgB,CAAD;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeView.js","sources":["../../../src/deprecated/TreeView.tsx"],"sourcesContent":["import React from 'react';\nimport useDataList from '@elliemae/ds-shared/useDataList';\nimport { TreeRenderers } from './renderers';\nimport { TreePluginList } from './plugins/tree';\nimport { TreeVirtualizationPlugin } from './plugins/virtualization/TreeVirtualizationPlugin';\nimport { TreeRovingPlugin } from './plugins/roving';\n\nconst wrapComponentIfExists = (Wrapper, children) =>\n Wrapper ? <Wrapper>{children}</Wrapper> : children;\n\nexport function TreeView({\n data,\n plugins = [],\n children,\n roving = true,\n rowSize = 'normal',\n ...props\n}) {\n const instance = useDataList({\n data,\n plugins: [\n TreePluginList,\n TreeVirtualizationPlugin,\n roving && TreeRovingPlugin,\n ...plugins,\n ],\n customDecorators: { shouldWalkChildren: [] }, // adds a new decorator to the useDataList specific for trees\n renderers: TreeRenderers,\n ...props,\n rowSize,\n });\n\n const { list: ListComponent, listWrapper: Wrapper } = instance.renderers;\n const { getListProps } = instance;\n\n return wrapComponentIfExists(\n Wrapper,\n <ListComponent\n records={instance.records}\n {...getListProps()}\n className={`em-ds-tv-row-size-${rowSize}`}\n />,\n );\n}\n"],"names":["wrapComponentIfExists","Wrapper","children","React","TreeView","data","plugins","roving","rowSize","props","instance","useDataList","TreePluginList","TreeVirtualizationPlugin","TreeRovingPlugin","customDecorators","shouldWalkChildren","renderers","TreeRenderers","ListComponent","list","listWrapper","getListProps","records"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,OAAD,EAAUC,QAAV;AAAA,SAC5BD,OAAO,gBAAGE,wCAAC,OAAD,QAAUD,QAAV,CAAH,GAAmCA,QADd;AAAA,CAA9B;;AAGO,SAASE,QAAT,OAOJ;AAAA,MANDC,IAMC,QANDA,IAMC;AAAA,0BALDC,OAKC;AAAA,MALDA,OAKC,6BALS,EAKT;AAAA,WAJDJ,QAIC;AAAA,6BAHDK,MAGC;AAAA,MAHDA,MAGC,4BAHQ,IAGR;AAAA,0BAFDC,OAEC;AAAA,MAFDA,OAEC,6BAFS,QAET;AAAA,MADEC,KACF;;AACD,MAAMC,QAAQ,GAAGC,+BAAW;AAC1BN,IAAAA,IAAI,EAAJA,IAD0B;AAE1BC,IAAAA,OAAO,GACLM,qDADK,EAELC,mFAFK,EAGLN,MAAM,IAAIO,2DAHL,gDAIFR,OAJE,EAFmB;AAQ1BS,IAAAA,gBAAgB,EAAE;AAAEC,MAAAA,kBAAkB,EAAE;AAAtB,KARQ;AAQoB;AAC9CC,IAAAA,SAAS,EAAEC;AATe,KAUvBT,KAVuB;AAW1BD,IAAAA,OAAO,EAAPA;AAX0B,KAA5B;AAcA,4BAAsDE,QAAQ,CAACO,SAA/D;AAAA,MAAcE,aAAd,uBAAQC,IAAR;AAAA,MAA0CnB,OAA1C,uBAA6BoB,WAA7B;AACA,MAAQC,YAAR,GAAyBZ,QAAzB,CAAQY,YAAR;AAEA,SAAOtB,qBAAqB,CAC1BC,OAD0B,eAE1BE,wCAAC,aAAD;AACE,IAAA,OAAO,EAAEO,QAAQ,CAACa;AADpB,KAEMD,YAAY,EAFlB;AAGE,IAAA,SAAS,8BAAuBd,OAAvB;AAHX,KAF0B,CAA5B;AAQD;;;;"}
1
+ {"version":3,"file":"TreeView.js","sources":["../../../src/deprecated/TreeView.tsx"],"sourcesContent":["import React from 'react';\nimport useDataList from '@elliemae/ds-shared/useDataList';\nimport { TreeRenderers } from './renderers';\nimport { TreePluginList } from './plugins/tree';\nimport { TreeVirtualizationPlugin } from './plugins/virtualization/TreeVirtualizationPlugin';\nimport { TreeRovingPlugin } from './plugins/roving';\n\nconst wrapComponentIfExists = (Wrapper, children) =>\n Wrapper ? <Wrapper>{children}</Wrapper> : children;\n\nexport function TreeView({\n data,\n plugins = [],\n children,\n roving = true,\n rowSize = 'normal',\n ...props\n}) {\n const instance = useDataList({\n data,\n plugins: [\n TreePluginList,\n TreeVirtualizationPlugin,\n roving && TreeRovingPlugin,\n ...plugins,\n ],\n customDecorators: { shouldWalkChildren: [] }, // adds a new decorator to the useDataList specific for trees\n renderers: TreeRenderers,\n ...props,\n rowSize,\n });\n\n const { list: ListComponent, listWrapper: Wrapper } = instance.renderers;\n const { getListProps } = instance;\n\n return wrapComponentIfExists(\n Wrapper,\n <ListComponent\n records={instance.records}\n {...getListProps()}\n className={`em-ds-tv-row-size-${rowSize}`}\n />,\n );\n}\n"],"names":["wrapComponentIfExists","Wrapper","children","React","TreeView","data","plugins","roving","rowSize","props","instance","useDataList","TreePluginList","TreeVirtualizationPlugin","TreeRovingPlugin","customDecorators","shouldWalkChildren","renderers","TreeRenderers","ListComponent","list","listWrapper","getListProps","records"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,OAAD,EAAUC,QAAV;EAAA,OAC5BD,OAAO,gBAAGE,wCAAC,OAAD,QAAUD,QAAV,CAAH,GAAmCA,QADd;AAAA,CAA9B;;AAGO,SAASE,QAAT,OAOJ;MANDC,IAMC,QANDA,IAMC;0BALDC,OAKC;MALDA,OAKC,6BALS,EAKT;WAJDJ,QAIC;6BAHDK,MAGC;MAHDA,MAGC,4BAHQ,IAGR;0BAFDC,OAEC;MAFDA,OAEC,6BAFS,QAET;MADEC,KACF;;EACD,IAAMC,QAAQ,GAAGC,+BAAW;IAC1BN,IAAI,EAAJA,IAD0B;IAE1BC,OAAO,GACLM,qDADK,EAELC,mFAFK,EAGLN,MAAM,IAAIO,2DAHL,gDAIFR,OAJE,EAFmB;IAQ1BS,gBAAgB,EAAE;MAAEC,kBAAkB,EAAE;KARd;;IAS1BC,SAAS,EAAEC;KACRT,KAVuB;IAW1BD,OAAO,EAAPA;KAXF;EAcA,0BAAsDE,QAAQ,CAACO,SAA/D;MAAcE,aAAd,uBAAQC,IAAR;MAA0CnB,OAA1C,uBAA6BoB,WAA7B;EACA,IAAQC,YAAR,GAAyBZ,QAAzB,CAAQY,YAAR;EAEA,OAAOtB,qBAAqB,CAC1BC,OAD0B,eAE1BE,wCAAC,aAAD;IACE,OAAO,EAAEO,QAAQ,CAACa;KACdD,YAAY,EAFlB;IAGE,SAAS,8BAAuBd,OAAvB;KALe,CAA5B;AAQD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/deprecated/__testUtils__/utils.tsx"],"sourcesContent":["import React from 'react';\nimport { render } from '@testing-library/react';\nimport { treeItemBlockName } from '../renderers';\nimport { TreeView } from '../TreeView';\n\nexport const treeItemsToMap = (items) => {\n const itemsMap = new Map();\n items.forEach((item) =>\n itemsMap.set(\n item.textContent.replace(/\\(.*?\\)/, '').replace(' ', ''),\n item,\n ),\n );\n return itemsMap;\n};\n\n/**\n * Returns items and itemMap with itemText as keys\n *\n * @param root0\n * @param root0.data\n * @param root0.plugins\n * @param key\n */\nexport function getTreeItemsFromRender(\n { data, plugins, ...props },\n key = treeItemBlockName,\n) {\n const { getAllByTestId, ...testingLibraryApi } = render(\n <TreeView\n {...props}\n data={data}\n height={1000}\n plugins={plugins}\n width={300}\n />,\n );\n\n const items = getAllByTestId(key);\n const itemsMap = treeItemsToMap(items);\n\n return {\n items,\n itemsMap,\n getAllByTestId,\n ...testingLibraryApi,\n };\n}\n"],"names":["treeItemsToMap","items","itemsMap","Map","forEach","item","set","textContent","replace","getTreeItemsFromRender","key","treeItemBlockName","data","plugins","props","render","React","TreeView","getAllByTestId","testingLibraryApi"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKaA,cAAc,GAAG,SAAjBA,cAAiB,CAACC,KAAD,EAAW;AACvC,MAAMC,QAAQ,GAAG,IAAIC,GAAJ,EAAjB;AACAF,EAAAA,KAAK,CAACG,OAAN,CAAc,UAACC,IAAD;AAAA,WACZH,QAAQ,CAACI,GAAT,CACED,IAAI,CAACE,WAAL,CAAiBC,OAAjB,CAAyB,SAAzB,EAAoC,EAApC,EAAwCA,OAAxC,CAAgD,GAAhD,EAAqD,EAArD,CADF,EAEEH,IAFF,CADY;AAAA,GAAd;AAMA,SAAOH,QAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASO,sBAAT,OAGL;AAAA,MADAC,GACA,uEADMC,sCACN;;AAAA,MAFEC,IAEF,QAFEA,IAEF;AAAA,MAFQC,OAER,QAFQA,OAER;AAAA,MAFoBC,KAEpB;;AACA,gBAAiDC,YAAM,eACrDC,wCAACC,4BAAD,mCACMH,KADN;AAEE,IAAA,IAAI,EAAEF,IAFR;AAGE,IAAA,MAAM,EAAE,IAHV;AAIE,IAAA,OAAO,EAAEC,OAJX;AAKE,IAAA,KAAK,EAAE;AALT,KADqD,CAAvD;AAAA,MAAQK,cAAR,WAAQA,cAAR;AAAA,MAA2BC,iBAA3B;;AAUA,MAAMlB,KAAK,GAAGiB,cAAc,CAACR,GAAD,CAA5B;AACA,MAAMR,QAAQ,GAAGF,cAAc,CAACC,KAAD,CAA/B;AAEA;AACEA,IAAAA,KAAK,EAALA,KADF;AAEEC,IAAAA,QAAQ,EAARA,QAFF;AAGEgB,IAAAA,cAAc,EAAdA;AAHF,KAIKC,iBAJL;AAMD;;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/deprecated/__testUtils__/utils.tsx"],"sourcesContent":["import React from 'react';\nimport { render } from '@testing-library/react';\nimport { treeItemBlockName } from '../renderers';\nimport { TreeView } from '../TreeView';\n\nexport const treeItemsToMap = (items) => {\n const itemsMap = new Map();\n items.forEach((item) =>\n itemsMap.set(\n item.textContent.replace(/\\(.*?\\)/, '').replace(' ', ''),\n item,\n ),\n );\n return itemsMap;\n};\n\n/**\n * Returns items and itemMap with itemText as keys\n *\n * @param root0\n * @param root0.data\n * @param root0.plugins\n * @param key\n */\nexport function getTreeItemsFromRender(\n { data, plugins, ...props },\n key = treeItemBlockName,\n) {\n const { getAllByTestId, ...testingLibraryApi } = render(\n <TreeView\n {...props}\n data={data}\n height={1000}\n plugins={plugins}\n width={300}\n />,\n );\n\n const items = getAllByTestId(key);\n const itemsMap = treeItemsToMap(items);\n\n return {\n items,\n itemsMap,\n getAllByTestId,\n ...testingLibraryApi,\n };\n}\n"],"names":["treeItemsToMap","items","itemsMap","Map","forEach","item","set","textContent","replace","getTreeItemsFromRender","key","treeItemBlockName","data","plugins","props","render","React","TreeView","getAllByTestId","testingLibraryApi"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKaA,cAAc,GAAG,SAAjBA,cAAiB,CAACC,KAAD,EAAW;EACvC,IAAMC,QAAQ,GAAG,IAAIC,GAAJ,EAAjB;EACAF,KAAK,CAACG,OAAN,CAAc,UAACC,IAAD;IAAA,OACZH,QAAQ,CAACI,GAAT,CACED,IAAI,CAACE,WAAL,CAAiBC,OAAjB,CAAyB,SAAzB,EAAoC,EAApC,EAAwCA,OAAxC,CAAgD,GAAhD,EAAqD,EAArD,CADF,EAEEH,IAFF,CADY;GAAd;EAMA,OAAOH,QAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASO,sBAAT,OAGL;EAAA,IADAC,GACA,uEADMC,sCACN;;EAAA,IAFEC,IAEF,QAFEA,IAEF;MAFQC,OAER,QAFQA,OAER;MAFoBC,KAEpB;;EACA,cAAiDC,YAAM,eACrDC,wCAACC,4BAAD,mCACMH,KADN;IAEE,IAAI,EAAEF,IAFR;IAGE,MAAM,EAAE,IAHV;IAIE,OAAO,EAAEC,OAJX;IAKE,KAAK,EAAE;KAN4C,CAAvD;MAAQK,cAAR,WAAQA,cAAR;MAA2BC,iBAA3B;;EAUA,IAAMlB,KAAK,GAAGiB,cAAc,CAACR,GAAD,CAA5B;EACA,IAAMR,QAAQ,GAAGF,cAAc,CAACC,KAAD,CAA/B;EAEA;IACEA,KAAK,EAALA,KADF;IAEEC,QAAQ,EAARA,QAFF;IAGEgB,cAAc,EAAdA;KACGC,iBAJL;AAMD;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeDndPlugin.js","sources":["../../../../../src/deprecated/plugins/dnd/TreeDndPlugin.tsx"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { isEqual } from '@elliemae/ds-utilities';\nimport createInstancePlugin from '@elliemae/ds-shared/createDataInstance/createInstancePlugin';\nimport DraggableItem from './renderers/DraggableItem';\nimport DroppableList from './renderers/DroppableList';\nimport {\n changePositionBetweenDifferentArrays,\n changePositionSameArray,\n getTreePosition,\n} from './utils';\n\nexport const TreeDndPlugin = createInstancePlugin('tree-dnd', {\n state(instance) {\n const {\n originalData,\n props: { childrenKey = 'children', onOrderChange = () => null },\n } = instance;\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [draggedRecord, setDraggedRecord] = useState(null);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const changeRecordsPosition = useCallback(\n ({ sourceRecord, targetRecord, combineWith, down }) => {\n let nextTreeData;\n\n const sourceTreePosition = getTreePosition(sourceRecord.path);\n let targetTreePosition = {};\n\n if (combineWith) {\n targetTreePosition = { parentPath: combineWith.path };\n } else if (targetRecord) {\n targetTreePosition = getTreePosition(targetRecord.path);\n } else {\n // there is no reordering\n // Reason: outside tree / outside drop target\n return originalData;\n }\n // if we are not combining elements we change the same array\n // if we combine elements, we change a different array (the children of the target)\n const changingSameArray =\n !combineWith &&\n isEqual(sourceTreePosition.parentPath, targetTreePosition.parentPath);\n\n if (changingSameArray) {\n nextTreeData = changePositionSameArray({\n sourceRecord,\n targetRecord,\n sourceTreePosition,\n targetTreePosition,\n data: originalData,\n });\n } else {\n nextTreeData = changePositionBetweenDifferentArrays({\n sourceRecord,\n targetRecord: combineWith || targetRecord,\n combineWith,\n sourceTreePosition,\n targetTreePosition,\n data: originalData,\n down,\n });\n }\n\n onOrderChange(nextTreeData, sourceRecord);\n // console.log('nextTreeData :>> ', nextTreeData);\n // console.log(\n // `${sourceRecord?.data?.name} --> ${\n // combineWith?.data?.name || targetRecord?.data?.name\n // }`,\n // );\n return nextTreeData;\n },\n [originalData, childrenKey],\n );\n\n return {\n state: { draggedRecord },\n actions: { setDraggedRecord, changeRecordsPosition },\n };\n },\n renderers(renderers, instance) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const item = useMemo(() => DraggableItem(renderers, instance), []);\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const list = useMemo(() => DroppableList(renderers, instance), []);\n return { ...renderers, item, list };\n },\n});\n"],"names":["TreeDndPlugin","createInstancePlugin","state","instance","originalData","props","childrenKey","onOrderChange","useState","draggedRecord","setDraggedRecord","changeRecordsPosition","useCallback","sourceRecord","targetRecord","combineWith","down","nextTreeData","sourceTreePosition","getTreePosition","path","targetTreePosition","parentPath","changingSameArray","isEqual","changePositionSameArray","data","changePositionBetweenDif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AAa,CAACL,UAAD,EAAY1B,QAAZ,CAAnB;AAAA,KAAD,EAA2C,EAA3C,CAApB;AACA,2CAAY0B,UAAZ;AAAuBC,MAAAA,IAAI,EAAJA,IAAvB;AAA6BG,MAAAA,IAAI,EAAJA;AAA7B;AACD;AA5E2D,CAAb;;;;"}
1
+ {"version":3,"file":"TreeDndPlugin.js","sources":["../../../../../src/deprecated/plugins/dnd/TreeDndPlugin.tsx"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\nimport { isEqual } from '@elliemae/ds-utilities';\nimport createInstancePlugin from '@elliemae/ds-shared/createDataInstance/createInstancePlugin';\nimport DraggableItem from './renderers/DraggableItem';\nimport DroppableList from './renderers/DroppableList';\nimport {\n changePositionBetweenDifferentArrays,\n changePositionSameArray,\n getTreePosition,\n} from './utils';\n\nexport const TreeDndPlugin = createInstancePlugin('tree-dnd', {\n state(instance) {\n const {\n originalData,\n props: { childrenKey = 'children', onOrderChange = () => null },\n } = instance;\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [draggedRecord, setDraggedRecord] = useState(null);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const changeRecordsPosition = useCallback(\n ({ sourceRecord, targetRecord, combineWith, down }) => {\n let nextTreeData;\n\n const sourceTreePosition = getTreePosition(sourceRecord.path);\n let targetTreePosition = {};\n\n if (combineWith) {\n targetTreePosition = { parentPath: combineWith.path };\n } else if (targetRecord) {\n targetTreePosition = getTreePosition(targetRecord.path);\n } else {\n // there is no reordering\n // Reason: outside tree / outside drop target\n return originalData;\n }\n // if we are not combining elements we change the same array\n // if we combine elements, we change a different array (the children of the target)\n const changingSameArray =\n !combineWith &&\n isEqual(sourceTreePosition.parentPath, targetTreePosition.parentPath);\n\n if (changingSameArray) {\n nextTreeData = changePositionSameArray({\n sourceRecord,\n targetRecord,\n sourceTreePosition,\n targetTreePosition,\n data: originalData,\n });\n } else {\n nextTreeData = changePositionBetweenDifferentArrays({\n sourceRecord,\n targetRecord: combineWith || targetRecord,\n combineWith,\n sourceTreePosition,\n targetTreePosition,\n data: originalData,\n down,\n });\n }\n\n onOrderChange(nextTreeData, sourceRecord);\n // console.log('nextTreeData :>> ', nextTreeData);\n // console.log(\n // `${sourceRecord?.data?.name} --> ${\n // combineWith?.data?.name || targetRecord?.data?.name\n // }`,\n // );\n return nextTreeData;\n },\n [originalData, childrenKey],\n );\n\n return {\n state: { draggedRecord },\n actions: { setDraggedRecord, changeRecordsPosition },\n };\n },\n renderers(renderers, instance) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const item = useMemo(() => DraggableItem(renderers, instance), []);\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const list = useMemo(() => DroppableList(renderers, instance), []);\n return { ...renderers, item, list };\n },\n});\n"],"names":["TreeDndPlugin","createInstancePlugin","state","instance","originalData","props","childrenKey","onOrderChange","useState","draggedRecord","setDraggedRecord","changeRecordsPosition","useCallback","sourceRecord","targetRecord","combineWith","down","nextTreeData","sourceTreePosition","getTreePosition","path","targetTreePosition","parentPath","changingSameArray","isEqual","changePositionSameArray","data","changePositionBetweenDifferentArrays","actions","renderers","item","useMemo","DraggableItem","list","DroppableList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAWaA,aAAa,GAAGC,wCAAoB,CAAC,UAAD,EAAa;EAC5DC,KAD4D,iBACtDC,QADsD,EAC5C;IACd,IACEC,YADF,GAGID,QAHJ,CACEC,YADF;0BAGID,QAHJ,CAEEE,KAFF;gDAEWC,WAFX;QAEWA,WAFX,sCAEyB,UAFzB;gDAEqCC,aAFrC;QAEqCA,aAFrC,sCAEqD;MAAA,OAAM,IAAN;KAFrD,yBADc;;IAOd,gBAA0CC,cAAQ,CAAC,IAAD,CAAlD;;QAAOC,aAAP;QAAsBC,gBAAtB,iBAPc;;;IAUd,IAAMC,qBAAqB,GAAGC,iBAAW,CACvC,gBAAuD;MAAA,IAApDC,YAAoD,QAApDA,YAAoD;UAAtCC,YAAsC,QAAtCA,YAAsC;UAA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O,EAAE;QAAElB,gBAAgB,EAAhBA,gBAAF;QAAoBC,qBAAqB,EAArBA;;KAF/B;GAjE0D;EAsE5DkB,SAtE4D,qBAsElDA,UAtEkD,EAsEvC1B,QAtEuC,EAsE7B;;IAE7B,IAAM2B,IAAI,GAAGC,aAAO,CAAC;MAAA,OAAMC,8CAAa,CAACH,UAAD,CAAnB;KAAD,EAA2C,EAA3C,CAApB,CAF6B;;IAI7B,IAAMI,IAAI,GAAGF,aAAO,CAAC;MAAA,OAAMG,8CAAa,CAACL,UAAD,EAAY1B,QAAZ,CAAnB;KAAD,EAA2C,EAA3C,CAApB;IACA,uCAAY0B,UAAZ;MAAuBC,IAAI,EAAJA,IAAvB;MAA6BG,IAAI,EAAJA;;;AA3E6B,CAAb;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"DraggableItem.js","sources":["../../../../../../src/deprecated/plugins/dnd/renderers/DraggableItem.tsx"],"sourcesContent":["/* eslint-disable react/prop-types */\nimport React from 'react';\nimport { Draggable } from 'react-beautiful-dnd';\nimport { GripperVertical } from '@elliemae/ds-icons';\nimport { getDraggableProps } from '../utils';\n\n// eslint-disable-next-line react/display-name\nconst DraggableItem =\n (\n renderers,\n // , instance\n ) =>\n (props) => {\n const { record, index, isItemFocused } = props;\n const ItemComponent = renderers.item;\n const isDragDisabled = record?.parentNode?.data?.disableDragChildren || record?.data?.disableDrag || false;\n // const { draggedRecord } = instance.getInstance().state;\n\n // const isDragging = record.id === draggedRecord?.id;\n return (\n <Draggable\n isDragDisabled={isDragDisabled}\n key={`${record.id}-draggable`}\n draggableId={String(record.id)}\n index={index}\n >\n {(provided, snapshot) => {\n const { key, ...draggableProps } = getDraggableProps(props, provided, snapshot);\n\n return (\n <ItemComponent\n key={key}\n {...draggableProps}\n // isDragging={isDragging}\n leftAddons={[\n <GripperVertical\n data-testid=\"drag-handle\"\n key={`${record.id}-drag-handle`}\n {...provided.dragHandleProps}\n className=\"drag-handle\"\n tabIndex={isItemFocused ? 0 : -1}\n />,\n ...(props.leftAddons || []),\n ]}\n >\n {props.children}\n </ItemComponent>\n );\n }}\n </Draggable>\n );\n };\n\nexport default DraggableItem;\n"],"names":["DraggableItem","renderers","props","record","index","isItemFocused","ItemComponent","item","isDragDisabled","parentNode","data","disableDragChildren","disableDrag","React","Draggable","id","String","provided","snapshot","getDraggableProps","key","draggableProps","GripperVertical","dragHandleProps","leftAddons","children"],"mappings":";;;;;;;;;;;;;;;;;;;;;IAOMA,aAAa,GACjB,SADIA,aACJ,CACEC,SADF;AAAA;AAAA,SAIA,UAACC,KAAD,EAAW;AAAA;;AACT,QAAQC,MAAR,GAAyCD,KAAzC,CAAQC,MAAR;AAAA,QAAgBC,KAAhB,GAAyCF,KAAzC,CAAgBE,KAAhB;AAAA,QAAuBC,aAAvB,GAAyCH,KAAzC,CAAuBG,aAAvB;AACA,QAAMC,aAAa,GAAGL,SAAS,CAACM,IAAhC;AACA,QAAMC,cAAc,GAAG,CAAAL,MAAM,SAAN,IAAAA,MAAM,WAAN,kCAAAA,MAAM,CAAEM,UAAR,mGAAoBC,IAApB,gFAA0BC,mBAA1B,MAAiDR,MAAjD,aAAiDA,MAAjD,uCAAiDA,MAAM,CAAEO,IAAzD,iDAAiD,aAAcE,WAA/D,KAA8E,KAArG,CAHS;AAMT;;AACA,wBACEC,wCAACC,2BAAD;AACE,MAAA,cAAc,EAAEN,cADlB;AAEE,MAAA,GAAG,YAAKL,MAAM,CAACY,EAAZ,eAFL;AAGE,MAAA,WAAW,EAAEC,MAAM,CAACb,MAAM,CAACY,EAAR,CAHrB;AAIE,MAAA,KAAK,EAAEX;AAJT,OAMG,UAACa,QAAD,EAAWC,QAAX,EAAwB;AACvB,+BAAmCC,8CAAiB,CAACjB,KAAD,EAAQe,QAAR,EAAkBC,QAAlB,CAApD;AAAA,UAAQE,GAAR,sBAAQA,GAAR;AAAA,UAAgBC,cAAhB;;AAEA,0BACER,wCAAC,aAAD;AACE,QAAA,GAAG,EAAEO;AADP,SAEMC,cAFN;AAGE;AACA,QAAA,UAAU,gBACRR,wCAACS,uBAAD;AACE,yBAAY,aADd;AAEE,UAAA,GAAG,YAAKnB,MAAM,CAACY,EAAZ;AAFL,WAGME,QAAQ,CAACM,eAHf;AAIE,UAAA,SAAS,EAAC,aAJZ;AAKE,UAAA,QAAQ,EAAElB,aAAa,GAAG,CAAH,GAAO,CAAC;AALjC,WADQ,gDAQJH,KAAK,CAACsB,UAAN,IAAoB,EARhB;AAJZ,UAeGtB,KAAK,CAACuB,QAfT,CADF;AAmBD,KA5BH,CADF;AAgCD,GA3CD;AAAA;;;;"}
1
+ {"version":3,"file":"DraggableItem.js","sources":["../../../../../../src/deprecated/plugins/dnd/renderers/DraggableItem.tsx"],"sourcesContent":["/* eslint-disable react/prop-types */\nimport React from 'react';\nimport { Draggable } from 'react-beautiful-dnd';\nimport { GripperVertical } from '@elliemae/ds-icons';\nimport { getDraggableProps } from '../utils';\n\n// eslint-disable-next-line react/display-name\nconst DraggableItem =\n (\n renderers,\n // , instance\n ) =>\n (props) => {\n const { record, index, isItemFocused } = props;\n const ItemComponent = renderers.item;\n const isDragDisabled = record?.parentNode?.data?.disableDragChildren || record?.data?.disableDrag || false;\n // const { draggedRecord } = instance.getInstance().state;\n\n // const isDragging = record.id === draggedRecord?.id;\n return (\n <Draggable\n isDragDisabled={isDragDisabled}\n key={`${record.id}-draggable`}\n draggableId={String(record.id)}\n index={index}\n >\n {(provided, snapshot) => {\n const { key, ...draggableProps } = getDraggableProps(props, provided, snapshot);\n\n return (\n <ItemComponent\n key={key}\n {...draggableProps}\n // isDragging={isDragging}\n leftAddons={[\n <GripperVertical\n data-testid=\"drag-handle\"\n key={`${record.id}-drag-handle`}\n {...provided.dragHandleProps}\n className=\"drag-handle\"\n tabIndex={isItemFocused ? 0 : -1}\n />,\n ...(props.leftAddons || []),\n ]}\n >\n {props.children}\n </ItemComponent>\n );\n }}\n </Draggable>\n );\n };\n\nexport default DraggableItem;\n"],"names":["DraggableItem","renderers","props","record","index","isItemFocused","ItemComponent","item","isDragDisabled","parentNode","data","disableDragChildren","disableDrag","React","Draggable","id","String","provided","snapshot","getDraggableProps","key","draggableProps","GripperVertical","dragHandleProps","leftAddons","children"],"mappings":";;;;;;;;;;;;;;;;;;;;;IAOMA,aAAa,GACjB,SADIA,aACJ,CACEC,SADF;AAAA;EAAA,OAIA,UAACC,KAAD,EAAW;IAAA;;IACT,IAAQC,MAAR,GAAyCD,KAAzC,CAAQC,MAAR;QAAgBC,KAAhB,GAAyCF,KAAzC,CAAgBE,KAAhB;QAAuBC,aAAvB,GAAyCH,KAAzC,CAAuBG,aAAvB;IACA,IAAMC,aAAa,GAAGL,SAAS,CAACM,IAAhC;IACA,IAAMC,cAAc,GAAG,CAAAL,MAAM,SAAN,IAAAA,MAAM,WAAN,kCAAAA,MAAM,CAAEM,UAAR,mGAAoBC,IAApB,gFAA0BC,mBAA1B,MAAiDR,MAAjD,aAAiDA,MAAjD,uCAAiDA,MAAM,CAAEO,IAAzD,iDAAiD,aAAcE,WAA/D,KAA8E,KAArG,CAHS;;;IAOT,oBACEC,wCAACC,2BAAD;MACE,cAAc,EAAEN,cADlB;MAEE,GAAG,YAAKL,MAAM,CAACY,EAAZ,eAFL;MAGE,WAAW,EAAEC,MAAM,CAACb,MAAM,CAACY,EAAR,CAHrB;MAIE,KAAK,EAAEX;OAEN,UAACa,QAAD,EAAWC,QAAX,EAAwB;MACvB,yBAAmCC,8CAAiB,CAACjB,KAAD,EAAQe,QAAR,EAAkBC,QAAlB,CAApD;UAAQE,GAAR,sBAAQA,GAAR;UAAgBC,cAAhB;;MAEA,oBACER,wCAAC,aAAD;QACE,GAAG,EAAEO;SACDC,cAFN;;QAIE,UAAU,gBACRR,wCAACS,uBAAD;UACE,eAAY,aADd;UAEE,GAAG,YAAKnB,MAAM,CAACY,EAAZ;WACCE,QAAQ,CAACM,eAHf;UAIE,SAAS,EAAC,aAJZ;UAKE,QAAQ,EAAElB,aAAa,GAAG,CAAH,GAAO,CAAC;WANzB,gDAQJH,KAAK,CAACsB,UAAN,IAAoB,EARhB;UAWTtB,KAAK,CAACuB,QAfT,CADF;KATJ,CADF;GAXF;AAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"DroppableList.js","sources":["../../../../../../src/deprecated/plugins/dnd/renderers/DroppableList.tsx"],"sourcesContent":["/* eslint-disable react/prop-types */\n/* eslint max-lines: [\"error\", 300] */\n/* eslint-disable react-hooks/rules-of-hooks */\nimport React, {\n useCallback,\n useContext,\n useRef,\n useState,\n // useMemo,\n} from 'react';\nimport { DragDropContext, Droppable } from 'react-beautiful-dnd';\nimport { cx } from '@elliemae/ds-utilities';\nimport { GripperVertical } from '@elliemae/ds-icons';\nimport { mergeRefs } from '@elliemae/ds-utilities';\nimport FocusGroupContext from '@elliemae/ds-shared/FocusGroup/FocusGroupContext';\nimport { findItemById, findItemOnDocument } from '../../tree/utils';\nimport { getDraggableProps } from '../utils';\n\nconst DroppableList =\n (renderers, instance) =>\n ({ records, ...rest }) => {\n const {\n props: { expandTimerDelay = 1000, restrictDragAndDrop },\n actions: { setDraggedRecord, changeRecordsPosition, toggleExpand },\n state: { draggedRecord },\n itemRenderer,\n } = instance.getInstance();\n\n const focusContext = useContext(FocusGroupContext);\n const [focusedItemWasDragged, setFocusedItemWasDragged] = useState(false);\n const preDragFocusedNode = useRef();\n const expandTimerRef = useRef();\n const draggedRecordShouldExpand = useRef(false);\n const currTargetRef = useRef({});\n\n const onDragUpdate = useCallback(\n (data) => {\n const { destination, combine } = data;\n clearTimeout(expandTimerRef.current);\n\n if (combine) {\n const { draggableId } = combine;\n const targetRecord = findItemById(records, draggableId);\n\n if (targetRecord && targetRecord.isGroup && !targetRecord.expanded) {\n expandTimerRef.current = setTimeout(() => toggleExpand(targetRecord), expandTimerDelay);\n }\n }\n currTargetRef.current = destination || currTargetRef.current;\n },\n [records],\n );\n\n const onDragStart = useCallback(\n ({ source }) => {\n preDragFocusedNode.current = document.activeElement;\n // when we move the currently focused item, preDragFocusedNode is the body of the doc\n setFocusedItemWasDragged(preDragFocusedNode.current.tagName === 'BODY');\n\n const draggingRecord = records[source.index];\n\n if (draggingRecord.expanded) {\n draggedRecordShouldExpand.current = true;\n toggleExpand(draggingRecord);\n }\n\n setDraggedRecord(draggingRecord);\n },\n [records],\n );\n\n const onDragEnd = useCallback(\n // eslint-disable-next-line complexity\n // eslint-disable-next-line max-statements\n ({ destination, source, combine }) => {\n clearTimeout(expandTimerRef.current);\n const sourceIndex = source.index;\n const destinationIndex = destination && destination.index;\n\n if (sourceIndex === destinationIndex) return;\n\n const sourceRecord = records[sourceIndex];\n const targetRecord = destination && records[destinationIndex];\n const combineWith = combine && findItemById(records, combine.draggableId);\n\n const down = sourceIndex < destinationIndex;\n\n if (restrictDragAndDrop && sourceRecord?.parentNode?.id !== targetRecord?.parentNode?.id) return;\n\n // TODO check if we can change the records Immutable, this makes the DOM inconsistent on first renderers\n changeRecordsPosition({\n sourceRecord,\n targetRecord,\n combineWith,\n down,\n });\n\n if (draggedRecordShouldExpand.current) {\n draggedRecordShouldExpand.current = false;\n toggleExpand(sourceRecord);\n }\n\n if (focusContext) {\n // TODO if we fix the mutable/immutable records handling this work-around should not be required anymore\n setTimeout(() => {\n const postDragFocusedNode = focusedItemWasDragged\n ? findItemOnDocument(sourceRecord.id)\n : findItemOnDocument(preDragFocusedNode.current.dataset.id);\n\n focusContext.focusItemByNode(postDragFocusedNode);\n }, 0);\n }\n\n currTargetRef.current = null;\n setDraggedRecord(null);\n },\n [records, focusedItemWasDragged],\n );\n\n const { item: ItemComponent, list: ListComponent } = renderers;\n const renderClone = useCallback(\n (provided, snapshot, rubric) => {\n const targetRecord = (currTargetRef.current && records[currTargetRef.current.index]) || {};\n const record = records[rubric.source.index];\n return (\n <ItemComponent\n {...provided.draggableProps}\n key={rubric.source.index}\n record={record}\n {...getDraggableProps(\n {\n className: 'item-cloned',\n },\n provided,\n snapshot,\n )}\n >\n <GripperVertical {...provided.dragHandleProps} className=\"drag-handle\" />\n {itemRenderer({\n record,\n nestingLevel: targetRecord.nestingLevel,\n })}\n </ItemComponent>\n );\n },\n [currTargetRef, records, itemRenderer],\n );\n\n return (\n <DragDropContext onDragEnd={onDragEnd} onDragStart={onDragStart} onDragUpdate={onDragUpdate}>\n <Droppable droppableId=\"droppableId\" isCombineEnabled mode=\"virtual\" renderClone={renderClone}>\n {(droppableProvided, snapshot) => {\n // Add an extra item to our list to make space for a dragging item\n // work in a virtual list\n const itemCount = snapshot.isUsingPlaceholder ? records.length + 1 : records.length;\n\n return (\n <ListComponent\n {...rest}\n className={cx(rest.className, draggedRecord && 'dragging')}\n innerRef={mergeRefs(droppableProvided.innerRef, rest.innerRef, rest.ref)}\n itemCount={itemCount}\n records={records}\n />\n );\n }}\n </Droppable>\n </DragDropContext>\n );\n };\n\nexport default DroppableList;\n"],"names":["DroppableList","renderers","instance","records","rest","getInstance","props","expandTimerDelay","restrictDragAndDrop","actions","setDraggedRecord","changeRecordsPosition","toggleExpand","draggedRecord","state","itemRenderer","focusContext","useContext","FocusGroupContext","useState","focusedItemWasDragged","setFocusedItemWasDragged","preDragFocusedNode","useRef","expandTimerRef","draggedRecordShouldExpand","currTargetRef","onDragUpdate","useCallback","data","destination","combine","clearTimeout","current","draggableId","targetRecord","findItemById","isGroup","expanded","setTimeout","onDragStart","source","document","activeElement","tagName","draggingRecord","index","onDragEnd","sourceIndex","destinationIndex","sourceRecord","combineWith","down","parentNode","id","postDragFocusedNode","findItemOnDocument","dataset","focusItemByNode","ItemComponent","item","ListComponent","list","renderClone","provided","snapshot","rubric","record","React","draggableProps","getDraggableProps","className","GripperVertical","dragHandleProps","nestingLevel","DragDropContext","Droppable","droppableProvided","itemCount","isUsingPlaceholder","length","cx","mergeRefs","innerRef","ref"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;IAkBMA,aAAa,GACjB,SADIA,aACJ,CAACC,SAAD,EAAYC,QAAZ;AAAA,SACA,gBAA0B;AAAA,QAAvBC,OAAuB,QAAv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S,GAAGb,QAAQ,CAACc,kBAAT,GAA8B5E,OAAO,CAAC6E,MAAR,GAAiB,CAA/C,GAAmD7E,OAAO,CAAC6E,MAA7E;AAEA,0BACEZ,wCAAC,aAAD,mCACMhE,IADN;AAEE,QAAA,SAAS,EAAE6E,cAAE,CAAC7E,IAAI,CAACmE,SAAN,EAAiB1D,aAAa,IAAI,UAAlC,CAFf;AAGE,QAAA,QAAQ,EAAEqE,qBAAS,CAACL,iBAAiB,CAACM,QAAnB,EAA6B/E,IAAI,CAAC+E,QAAlC,EAA4C/E,IAAI,CAACgF,GAAjD,CAHrB;AAIE,QAAA,SAAS,EAAEN,SAJb;AAKE,QAAA,OAAO,EAAE3E;AALX,SADF;AASD,KAfH,CADF,CADF;AAqBD,GAtJD;AAAA;;;;"}
1
+ {"version":3,"file":"DroppableList.js","sources":["../../../../../../src/deprecated/plugins/dnd/renderers/DroppableList.tsx"],"sourcesContent":["/* eslint-disable react/prop-types */\n/* eslint max-lines: [\"error\", 300] */\n/* eslint-disable react-hooks/rules-of-hooks */\nimport React, {\n useCallback,\n useContext,\n useRef,\n useState,\n // useMemo,\n} from 'react';\nimport { DragDropContext, Droppable } from 'react-beautiful-dnd';\nimport { cx } from '@elliemae/ds-utilities';\nimport { GripperVertical } from '@elliemae/ds-icons';\nimport { mergeRefs } from '@elliemae/ds-utilities';\nimport FocusGroupContext from '@elliemae/ds-shared/FocusGroup/FocusGroupContext';\nimport { findItemById, findItemOnDocument } from '../../tree/utils';\nimport { getDraggableProps } from '../utils';\n\nconst DroppableList =\n (renderers, instance) =>\n ({ records, ...rest }) => {\n const {\n props: { expandTimerDelay = 1000, restrictDragAndDrop },\n actions: { setDraggedRecord, changeRecordsPosition, toggleExpand },\n state: { draggedRecord },\n itemRenderer,\n } = instance.getInstance();\n\n const focusContext = useContext(FocusGroupContext);\n const [focusedItemWasDragged, setFocusedItemWasDragged] = useState(false);\n const preDragFocusedNode = useRef();\n const expandTimerRef = useRef();\n const draggedRecordShouldExpand = useRef(false);\n const currTargetRef = useRef({});\n\n const onDragUpdate = useCallback(\n (data) => {\n const { destination, combine } = data;\n clearTimeout(expandTimerRef.current);\n\n if (combine) {\n const { draggableId } = combine;\n const targetRecord = findItemById(records, draggableId);\n\n if (targetRecord && targetRecord.isGroup && !targetRecord.expanded) {\n expandTimerRef.current = setTimeout(() => toggleExpand(targetRecord), expandTimerDelay);\n }\n }\n currTargetRef.current = destination || currTargetRef.current;\n },\n [records],\n );\n\n const onDragStart = useCallback(\n ({ source }) => {\n preDragFocusedNode.current = document.activeElement;\n // when we move the currently focused item, preDragFocusedNode is the body of the doc\n setFocusedItemWasDragged(preDragFocusedNode.current.tagName === 'BODY');\n\n const draggingRecord = records[source.index];\n\n if (draggingRecord.expanded) {\n draggedRecordShouldExpand.current = true;\n toggleExpand(draggingRecord);\n }\n\n setDraggedRecord(draggingRecord);\n },\n [records],\n );\n\n const onDragEnd = useCallback(\n // eslint-disable-next-line complexity\n // eslint-disable-next-line max-statements\n ({ destination, source, combine }) => {\n clearTimeout(expandTimerRef.current);\n const sourceIndex = source.index;\n const destinationIndex = destination && destination.index;\n\n if (sourceIndex === destinationIndex) return;\n\n const sourceRecord = records[sourceIndex];\n const targetRecord = destination && records[destinationIndex];\n const combineWith = combine && findItemById(records, combine.draggableId);\n\n const down = sourceIndex < destinationIndex;\n\n if (restrictDragAndDrop && sourceRecord?.parentNode?.id !== targetRecord?.parentNode?.id) return;\n\n // TODO check if we can change the records Immutable, this makes the DOM inconsistent on first renderers\n changeRecordsPosition({\n sourceRecord,\n targetRecord,\n combineWith,\n down,\n });\n\n if (draggedRecordShouldExpand.current) {\n draggedRecordShouldExpand.current = false;\n toggleExpand(sourceRecord);\n }\n\n if (focusContext) {\n // TODO if we fix the mutable/immutable records handling this work-around should not be required anymore\n setTimeout(() => {\n const postDragFocusedNode = focusedItemWasDragged\n ? findItemOnDocument(sourceRecord.id)\n : findItemOnDocument(preDragFocusedNode.current.dataset.id);\n\n focusContext.focusItemByNode(postDragFocusedNode);\n }, 0);\n }\n\n currTargetRef.current = null;\n setDraggedRecord(null);\n },\n [records, focusedItemWasDragged],\n );\n\n const { item: ItemComponent, list: ListComponent } = renderers;\n const renderClone = useCallback(\n (provided, snapshot, rubric) => {\n const targetRecord = (currTargetRef.current && records[currTargetRef.current.index]) || {};\n const record = records[rubric.source.index];\n return (\n <ItemComponent\n {...provided.draggableProps}\n key={rubric.source.index}\n record={record}\n {...getDraggableProps(\n {\n className: 'item-cloned',\n },\n provided,\n snapshot,\n )}\n >\n <GripperVertical {...provided.dragHandleProps} className=\"drag-handle\" />\n {itemRenderer({\n record,\n nestingLevel: targetRecord.nestingLevel,\n })}\n </ItemComponent>\n );\n },\n [currTargetRef, records, itemRenderer],\n );\n\n return (\n <DragDropContext onDragEnd={onDragEnd} onDragStart={onDragStart} onDragUpdate={onDragUpdate}>\n <Droppable droppableId=\"droppableId\" isCombineEnabled mode=\"virtual\" renderClone={renderClone}>\n {(droppableProvided, snapshot) => {\n // Add an extra item to our list to make space for a dragging item\n // work in a virtual list\n const itemCount = snapshot.isUsingPlaceholder ? records.length + 1 : records.length;\n\n return (\n <ListComponent\n {...rest}\n className={cx(rest.className, draggedRecord && 'dragging')}\n innerRef={mergeRefs(droppableProvided.innerRef, rest.innerRef, rest.ref)}\n itemCount={itemCount}\n records={records}\n />\n );\n }}\n </Droppable>\n </DragDropContext>\n );\n };\n\nexport default DroppableList;\n"],"names":["DroppableList","renderers","instance","records","rest","getInstance","props","expandTimerDelay","restrictDragAndDrop","actions","setDraggedRecord","changeRecordsPosition","toggleExpand","draggedRecord","state","itemRenderer","focusContext","useContext","FocusGroupContext","useState","focusedItemWasDragged","setFocusedItemWasDragged","preDragFocusedNode","useRef","expandTimerRef","draggedRecordShouldExpand","currTargetRef","onDragUpdate","useCallback","data","destination","combine","clearTimeout","current","draggableId","targetRecord","findItemById","isGroup","expanded","setTimeout","onDragStart","source","document","activeElement","tagName","draggingRecord","index","onDragEnd","sourceIndex","destinationIndex","sourceRecord","combineWith","down","parentNode","id","postDragFocusedNode","findItemOnDocument","dataset","focusItemByNode","ItemComponent","item","ListComponent","list","renderClone","provided","snapshot","rubric","record","React","draggableProps","getDraggableProps","className","GripperVertical","dragHandleProps","nestingLevel","DragDropContext","Droppable","droppableProvided","itemCount","isUsingPlaceholder","length","cx","mergeRefs","innerRef","ref"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;IAkBMA,aAAa,GACjB,SADIA,aACJ,CAACC,SAAD,EAAYC,QAAZ;EAAA,OACA,gBAA0B;IAAA,IAAvBC,OAAuB,QAAvBA,OAAuB;QAAXC,IAAW;;IACxB,4BAKIF,QAAQ,CAACG,WAAT,EALJ;uDACEC,KADF;wDACWC,gBADX;QACWA,gBADX,uCAC8B,IAD9B;QACoCC,mBADpC,0BACoCA,mBADpC;uDAEEC,OAFF;QAEaC,gBAFb,0BAEaA,gBAFb;QAE+BC,qBAF/B,0BAE+BA,qBAF/B;QAEsDC,YAFtD,0BAEsDA,YAFtD;QAGWC,aAHX,yBAGEC,KAHF,CAGWD,aAHX;QAIEE,YAJF,yBAIEA,YAJF;;IAOA,IAAMC,YAAY,GAAGC,gBAAU,CAACC,qCAAD,CAA/B;;IACA,gBAA0DC,cAAQ,CAAC,KAAD,CAAlE;;QAAOC,qBAAP;QAA8BC,wBAA9B;;IACA,IAAMC,kBAAkB,GAAGC,YAAM,EAAjC;IACA,IAAMC,cAAc,GAAGD,YAAM,EAA7B;IACA,IAAME,yBAAyB,GAAGF,YAAM,CAAC,KAAD,CAAxC;IACA,IAAMG,aAAa,GAAGH,YAAM,CAAC,EAAD,CAA5B;IAEA,IAAMI,YAAY,GAAGC,iBAAW,CAC9B,UAACC,IAAD,EAAU;MACR,IAAQC,WAAR,GAAiCD,IAAjC,CAAQC,WAAR;UAAqBC,OAArB,GAAiCF,IAAjC,CAAqBE,OAArB;MACAC,YAAY,CAACR,cAAc,CAACS,OAAhB,CAAZ;;MAEA,IAAIF,OAAJ,EAAa;QACX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CAA/C,GAAmD7E,OAAO,CAAC6E,MAA7E;MAEA,oBACEZ,wCAAC,aAAD,mCACMhE,IADN;QAEE,SAAS,EAAE6E,cAAE,CAAC7E,IAAI,CAACmE,SAAN,EAAiB1D,aAAa,IAAI,UAAlC,CAFf;QAGE,QAAQ,EAAEqE,qBAAS,CAACL,iBAAiB,CAACM,QAAnB,EAA6B/E,IAAI,CAAC+E,QAAlC,EAA4C/E,IAAI,CAACgF,GAAjD,CAHrB;QAIE,SAAS,EAAEN,SAJb;QAKE,OAAO,EAAE3E;SANb;KANJ,CADF,CADF;GAjIF;AAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../src/deprecated/plugins/dnd/utils.tsx"],"sourcesContent":["/* eslint-disable complexity */\n/* eslint-disable no-continue */\n/* eslint-disable max-statements */\n/* eslint-disable indent */\n/* eslint-disable no-nested-ternary */\n/* eslint-disable max-lines */\nimport {\n arrayMove,\n cx,\n get,\n set,\n cloneDeep,\n} from '@elliemae/ds-utilities';\nimport { mergeRefs } from '@elliemae/ds-utilities';\n\nexport function getStyle(provided, style) {\n if (!style) {\n return provided.draggableProps.style;\n }\n return {\n ...provided.draggableProps.style,\n ...style,\n };\n}\n\nexport function getDraggableProps(props, provided, snapshot) {\n const isGroupedOver = Boolean(snapshot.combineTargetFor);\n return {\n ...props,\n ...provided.draggableProps,\n className: cx(props.className, isGroupedOver && 'can-group-over'),\n // provided,\n innerRef: mergeRefs(provided.innerRef, props.innerRef, props.ref),\n 'data-index': props.index,\n style: getStyle(provided, { ...props.style, display: 'flex' }),\n };\n}\n\nexport const setTreeArrayInPath = (treeData, path, data) => {\n const nextTreeData = [...treeData];\n if (path.length) {\n set(nextTreeData, path, data);\n return nextTreeData;\n }\n return data;\n};\n\n// check if at the earliest possible different nest level the source is before the target or not\nexport const isSourceBeforeTarget = (sourcePath, targetPath) => {\n let sourceIsBeforeTarget = false;\n if (sourcePath.length <= targetPath.length) {\n // we increase by 2 beacuse every other position is 'children'\n for (let i = 0; i < sourcePath.length; i += 2) {\n const source = sourcePath[i];\n const target = targetPath[i];\n // since we skip by 2 source/target can be out of bounds\n // if source/target are the same we are at same nest level\n if (\n !Number.isInteger(source) || // check to see if it's a number because 0 == false in javascript\n !Number.isInteger(target) ||\n source === target\n )\n continue;\n // the nest level differs, as such we check if source if before or after\n sourceIsBeforeTarget = source < target;\n break;\n }\n }\n\n return sourceIsBeforeTarget;\n};\n\nexport const updateTargetPath = (sourcePath, targetPath, incr = -1) => {\n const nextTargetPath = [...targetPath];\n\n const posToUpdate = sourcePath.length ? sourcePath.length - 1 : 0;\n nextTargetPath.splice(posToUpdate, 1, targetPath[posToUpdate] + incr);\n\n return nextTargetPath;\n};\n\nexport const getParentPath = (path) => path.slice(0, -1);\nexport const getParentChildrenByPath = (treeData, path) =>\n path && path.length ? get(treeData, path) : treeData;\n\nexport const getTreePosition = (recordPath) => ({\n parentPath: getParentPath(recordPath),\n index: recordPath.slice(-1)[0],\n});\n\nexport const changePositionBetweenDifferentArrays = ({\n sourceTreePosition, // already extracted sourceRecord.path\n targetTreePosition, // already extracted targetRecord.path\n // combineWith the element we want to append to the children of (this is null when the drag doesn't result in adding children)\n combineWith,\n sourceRecord, // what we are dragging\n targetRecord, // what we are dropping on top of\n down, // ???\n data, // tree before dragEnd changes\n childrenKey = 'children', // constant -> 'children'\n}) => {\n let nextTreeData = cloneDeep(data);\n\n if (!sourceRecord || !sourceRecord.data)\n throw new Error('error while dragging, no dragged item received');\n\n const sourceTreeChildren = getParentChildrenByPath(\n nextTreeData,\n sourceTreePosition.parentPath,\n );\n\n // When moving an item we remove the item from it's former parent children array\n sourceTreeChildren.splice(sourceTreePosition.index, 1);\n nextTreeData = setTreeArrayInPath(\n nextTreeData,\n sourceTreePosition.parentPath,\n sourceTreeChildren,\n );\n\n // if source is at previous position than the target children\n // then the index should decrease\n const shouldUpdateTarget = isSourceBeforeTarget(\n sourceRecord.path,\n targetRecord.path,\n );\n const nextTargetPosition = shouldUpdateTarget\n ? combineWith\n ? {\n parentPath: updateTargetPath(sourceRecord.path, combineWith.path),\n }\n : getTreePosition(updateTargetPath(sourceRecord.path, targetRecord.path))\n : targetTreePosition;\n\n // add to target\n const { parentPath } = nextTargetPosition;\n const targetTreeChildren =\n getParentChildrenByPath(nextTreeData, parentPath) ||\n combineWith?.data ||\n targetRecord?.data;\n if (combineWith && targetTreeChildren) {\n const targetChildrensArray = targetTreeChildren[childrenKey];\n targetChildrensArray.push(sourceRecord.data);\n } else if (targetTreeChildren) {\n targetTreeChildren.splice(\n targetTreePosition.index + (down ? 1 : 0),\n 0,\n sourceRecord.data,\n );\n }\n\n nextTreeData = setTreeArrayInPath(\n nextTreeData,\n parentPath,\n targetTreeChildren,\n );\n\n return nextTreeData;\n};\n\nexport const combineWithTarget = () => {};\n\nexport const changePositionSameArray = ({\n targetTreePosition,\n sourceRecord,\n targetRecord,\n data,\n}) => {\n let nextTreeData = cloneDeep(data);\n\n const targetTreeChildren = getParentChildrenByPath(\n nextTreeData,\n targetTreePosition.parentPath,\n );\n const nextChildren = arrayMove(\n targetTreeChildren,\n sourceRecord.index,\n targetRecord.index,\n );\n\n // mutates the tree. That's the reason of the clone above\n nextTreeData = setTreeArrayInPath(\n nextTreeData,\n targetTreePosition.parentPath,\n nextChildren,\n );\n\n return nextTreeData;\n};\n"],"names":["getStyle","provided","style","draggableProps","getDraggableProps","props","snapshot","isGroupedOver","Boolean","combineTargetFor","className","cx","innerRef","mergeRefs","ref","index","display","setTreeArrayInPath","treeData","path","data","nextTreeData","length","set","isSourceBeforeTarget","sourcePath","targetPath","sourceIsBeforeTarget","i","source","target","Number","isInteger","updateTargetPath","incr","nextTargetPath","posToUpdate","splice","getParentPath","slice","getParentChildrenByPath","get","getTreePosition","recordPath","parentPath","changePositionBetweenDifferentArrays","sourceTreePosition","targetTreePosition","combineWith","sourceRecord","targetRecord","down","childrenKey","cloneDeep","Error","sourceTreeChildren","shouldUpdateTarget","nextTargetPosition","targetTreeChildren","targetChildrensArray","push","combineWithTarget","changePositionSameArray","nextChildren","arrayMove"],"mappings":";;;;;;;;;;;;;;;;AAeO,SAASA,QAAT,CAAkBC,QAAlB,EAA4BC,KAA5B,EAAmC;AACxC,MAAI,CAACA,KAAL,EAAY;AACV,WAAOD,QAAQ,CAACE,cAAT,CAAwBD,KAA/B;AACD;;AACD,yCACKD,QAAQ,CAACE,cAAT,CAAwBD,KAD7B,GAEKA,KAFL;AAID;AAEM,SAASE,iBAAT,CAA2BC,KAA3B,EAAkCJ,QAAlC,EAA4CK,QAA5C,EAAsD;AAC3D,MAAMC,aAAa,GAAGC,OAAO,CAACF,QAAQ,CAACG,gBAAV,CAA7B;AACA,uDACKJ,KADL,GAEKJ,QAAQ,CAACE,cAFd;AAGEO,IAAAA,SAAS,EAAEC,cAAE,CAACN,KAAK,CAACK,SAAP,EAAkBH,aAAa,IAAI,gBAAnC,CAHf;AAIE;AACAK,IAAAA,QAAQ,EAAEC,qBAAS,CAACZ,QAAQ,CAACW,QAAV,EAAoBP,KAAK,CAACO,QAA1B,EAAoCP,KAAK,CAACS,GAA1C,CALrB;AAME,kBAAcT,KAAK,CAACU,KANtB;AAOEb,IAAAA,KAAK,EAAEF,QAAQ,CAACC,QAAD,kCAAgBI,KAAK,CAACH,KAAtB;AAA6Bc,MAAAA,OAAO,EAAE;AAAtC;AAPjB;AASD;IAEYC,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,QAAD,EAAWC,IAAX,EAAiBC,IAAjB,EAA0B;AAC1D,MAAMC,YAAY,0CAAOH,QAAP,CAAlB;;AACA,MAAIC,IAAI,CAACG,MAAT,EAAiB;AACfC,IAAAA,eAAG,CAACF,YAAD,EAAeF,IAAf,EAAqBC,IAArB,CAAH;AACA,WAAOC,YAAP;AACD;;AACD,SAAOD,IAAP;AACD;;IAGYI,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACC,UAAD,EAAaC,UAAb,EAA4B;AAC9D,MAAIC,oBAAoB,GAAG,KAA3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,UAF6B,CAAlD;AAIA,MAAMmB,YAAY,GAAGC,qBAAS,CAC5BN,kBAD4B,EAE5BT,YAAY,CAAClC,KAFe,EAG5BmC,YAAY,CAACnC,KAHe,CAA9B,CAPI;;AAcJM,EAAAA,YAAY,GAAGJ,kBAAkB,CAC/BI,YAD+B,EAE/B0B,kBAAkB,CAACH,UAFY,EAG/BmB,YAH+B,CAAjC;AAMA,SAAO1C,YAAP;AACD;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../src/deprecated/plugins/dnd/utils.tsx"],"sourcesContent":["/* eslint-disable complexity */\n/* eslint-disable no-continue */\n/* eslint-disable max-statements */\n/* eslint-disable indent */\n/* eslint-disable no-nested-ternary */\n/* eslint-disable max-lines */\nimport {\n arrayMove,\n cx,\n get,\n set,\n cloneDeep,\n} from '@elliemae/ds-utilities';\nimport { mergeRefs } from '@elliemae/ds-utilities';\n\nexport function getStyle(provided, style) {\n if (!style) {\n return provided.draggableProps.style;\n }\n return {\n ...provided.draggableProps.style,\n ...style,\n };\n}\n\nexport function getDraggableProps(props, provided, snapshot) {\n const isGroupedOver = Boolean(snapshot.combineTargetFor);\n return {\n ...props,\n ...provided.draggableProps,\n className: cx(props.className, isGroupedOver && 'can-group-over'),\n // provided,\n innerRef: mergeRefs(provided.innerRef, props.innerRef, props.ref),\n 'data-index': props.index,\n style: getStyle(provided, { ...props.style, display: 'flex' }),\n };\n}\n\nexport const setTreeArrayInPath = (treeData, path, data) => {\n const nextTreeData = [...treeData];\n if (path.length) {\n set(nextTreeData, path, data);\n return nextTreeData;\n }\n return data;\n};\n\n// check if at the earliest possible different nest level the source is before the target or not\nexport const isSourceBeforeTarget = (sourcePath, targetPath) => {\n let sourceIsBeforeTarget = false;\n if (sourcePath.length <= targetPath.length) {\n // we increase by 2 beacuse every other position is 'children'\n for (let i = 0; i < sourcePath.length; i += 2) {\n const source = sourcePath[i];\n const target = targetPath[i];\n // since we skip by 2 source/target can be out of bounds\n // if source/target are the same we are at same nest level\n if (\n !Number.isInteger(source) || // check to see if it's a number because 0 == false in javascript\n !Number.isInteger(target) ||\n source === target\n )\n continue;\n // the nest level differs, as such we check if source if before or after\n sourceIsBeforeTarget = source < target;\n break;\n }\n }\n\n return sourceIsBeforeTarget;\n};\n\nexport const updateTargetPath = (sourcePath, targetPath, incr = -1) => {\n const nextTargetPath = [...targetPath];\n\n const posToUpdate = sourcePath.length ? sourcePath.length - 1 : 0;\n nextTargetPath.splice(posToUpdate, 1, targetPath[posToUpdate] + incr);\n\n return nextTargetPath;\n};\n\nexport const getParentPath = (path) => path.slice(0, -1);\nexport const getParentChildrenByPath = (treeData, path) =>\n path && path.length ? get(treeData, path) : treeData;\n\nexport const getTreePosition = (recordPath) => ({\n parentPath: getParentPath(recordPath),\n index: recordPath.slice(-1)[0],\n});\n\nexport const changePositionBetweenDifferentArrays = ({\n sourceTreePosition, // already extracted sourceRecord.path\n targetTreePosition, // already extracted targetRecord.path\n // combineWith the element we want to append to the children of (this is null when the drag doesn't result in adding children)\n combineWith,\n sourceRecord, // what we are dragging\n targetRecord, // what we are dropping on top of\n down, // ???\n data, // tree before dragEnd changes\n childrenKey = 'children', // constant -> 'children'\n}) => {\n let nextTreeData = cloneDeep(data);\n\n if (!sourceRecord || !sourceRecord.data)\n throw new Error('error while dragging, no dragged item received');\n\n const sourceTreeChildren = getParentChildrenByPath(\n nextTreeData,\n sourceTreePosition.parentPath,\n );\n\n // When moving an item we remove the item from it's former parent children array\n sourceTreeChildren.splice(sourceTreePosition.index, 1);\n nextTreeData = setTreeArrayInPath(\n nextTreeData,\n sourceTreePosition.parentPath,\n sourceTreeChildren,\n );\n\n // if source is at previous position than the target children\n // then the index should decrease\n const shouldUpdateTarget = isSourceBeforeTarget(\n sourceRecord.path,\n targetRecord.path,\n );\n const nextTargetPosition = shouldUpdateTarget\n ? combineWith\n ? {\n parentPath: updateTargetPath(sourceRecord.path, combineWith.path),\n }\n : getTreePosition(updateTargetPath(sourceRecord.path, targetRecord.path))\n : targetTreePosition;\n\n // add to target\n const { parentPath } = nextTargetPosition;\n const targetTreeChildren =\n getParentChildrenByPath(nextTreeData, parentPath) ||\n combineWith?.data ||\n targetRecord?.data;\n if (combineWith && targetTreeChildren) {\n const targetChildrensArray = targetTreeChildren[childrenKey];\n targetChildrensArray.push(sourceRecord.data);\n } else if (targetTreeChildren) {\n targetTreeChildren.splice(\n targetTreePosition.index + (down ? 1 : 0),\n 0,\n sourceRecord.data,\n );\n }\n\n nextTreeData = setTreeArrayInPath(\n nextTreeData,\n parentPath,\n targetTreeChildren,\n );\n\n return nextTreeData;\n};\n\nexport const combineWithTarget = () => {};\n\nexport const changePositionSameArray = ({\n targetTreePosition,\n sourceRecord,\n targetRecord,\n data,\n}) => {\n let nextTreeData = cloneDeep(data);\n\n const targetTreeChildren = getParentChildrenByPath(\n nextTreeData,\n targetTreePosition.parentPath,\n );\n const nextChildren = arrayMove(\n targetTreeChildren,\n sourceRecord.index,\n targetRecord.index,\n );\n\n // mutates the tree. That's the reason of the clone above\n nextTreeData = setTreeArrayInPath(\n nextTreeData,\n targetTreePosition.parentPath,\n nextChildren,\n );\n\n return nextTreeData;\n};\n"],"names":["getStyle","provided","style","draggableProps","getDraggableProps","props","snapshot","isGroupedOver","Boolean","combineTargetFor","className","cx","innerRef","mergeRefs","ref","index","display","setTreeArrayInPath","treeData","path","data","nextTreeData","length","set","isSourceBeforeTarget","sourcePath","targetPath","sourceIsBeforeTarget","i","source","target","Number","isInteger","updateTargetPath","incr","nextTargetPath","posToUpdate","splice","getParentPath","slice","getParentChildrenByPath","get","getTreePosition","recordPath","parentPath","changePositionBetweenDifferentArrays","sourceTreePosition","targetTreePosition","combineWith","sourceRecord","targetRecord","down","childrenKey","cloneDeep","Error","sourceTreeChildren","shouldUpdateTarget","nextTargetPosition","targetTreeChildren","targetChildrensArray","push","combineWithTarget","changePositionSameArray","nextChildren","arrayMove"],"mappings":";;;;;;;;;;;;;;;;AAeO,SAASA,QAAT,CAAkB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../../../src/deprecated/plugins/roving/TreeRovingPlugin.tsx"],"sourcesContent":["/* eslint-disable react/prop-types */\n/* eslint-disable react-hooks/rules-of-hooks */\nimport React, { useMemo, useRef, useState } from 'react';\nimport FocusGroupProvider from '@elliemae/ds-shared/FocusGroup/FocusGroupManager';\nimport useFocusGroupItem from '@elliemae/ds-shared/FocusGroup/useFocusGroupItem';\nimport { mergeRefs } from '@elliemae/ds-utilities';\nimport createInstancePlugin from '@elliemae/ds-shared/createDataInstance/createInstancePlugin';\n\n// eslint-disable-next-line react/display-name\nconst TreeListRovingHoc = (instance) => (props) => {\n const { hotKeys } = instance.getInstance();\n return (\n <FocusGroupProvider hotKeys={hotKeys}>{props.children}</FocusGroupProvider>\n );\n};\n\n// eslint-disable-next-line react/display-name\nconst TreeItemRovingHoc = (Component) => ({\n innerRef,\n onFocus,\n onBlur,\n ...props\n}) => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const ref = useRef(null);\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useFocusGroupItem(ref, {\n onFocus,\n onBlur,\n });\n return <Component {...props} innerRef={mergeRefs(ref, innerRef)} />;\n};\n\nexport const TreeRovingPlugin = createInstancePlugin('tree-data', {\n getItemProps(props, instance) {\n const [isItemFocused, setIsItemFocused] = useState(false);\n return {\n ...props,\n onBlur: () => setIsItemFocused(false),\n // eslint-disable-next-line no-unused-vars\n onFocus: (e) => {\n setIsItemFocused(true);\n if (instance?.props?.onItemFocus) {\n instance.props.onItemFocus({\n scrollToItem: (...args) =>\n props?.listRef?.current?.scrollToItem(args),\n itemIndex: props?.index,\n });\n }\n },\n isItemFocused,\n 'data-index': props.index,\n };\n },\n renderers(renderers, instance) {\n const ListWrapper = useMemo(() => TreeListRovingHoc(instance), []);\n const Item = useMemo(() => TreeItemRovingHoc(renderers.item, instance), []);\n\n return {\n ...renderers,\n listWrapper: ListWrapper,\n item: Item,\n };\n },\n});\n\nTreeRovingPlugin.order = 0;\n"],"names":["TreeListRovingHoc","instance","props","getInstance","hotKeys","React","FocusGroupProvider","children","TreeItemRovingHoc","Component","innerRef","onFocus","onBlur","ref","useRef","useFocusGroupItem","mergeRefs","TreeRovingPlugin","createInstancePlugin","getItemProps","useState","isItemFocused","setIsItemFocused","e","onItemFocus","scrollToItem","args","listRef","current","itemIndex","index","renderers","ListWrapper","useMemo","Item","item","listWrapper","order"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,QAAD;AAAA,SAAc,UAACC,KAAD,EAAW;AACjD,gCAAoBD,QAAQ,CAACE,WAAT,EAApB;AAAA,QAAQC,OAAR,yBAAQA,OAAR;;AACA,wBACEC,wCAACC,sCAAD;AAAoB,MAAA,OAAO,EAAEF;AAA7B,OAAuCF,KAAK,CAACK,QAA7C,CADF;AAGD,GALyB;AAAA,CAA1B;;;AAQA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,SAAD;AAAA,SAAe,gBAKnC;AAAA,QAJJC,QAII,QAJJA,QAII;AAAA,QAHJC,OAGI,QAHJA,OAGI;AAAA,QAFJC,MAEI,QAFJA,MAEI;AAAA,QADDV,KACC;;AACJ;AACA,QAAMW,GAAG,GAAGC,YAAM,CAAC,IAAD,CAAlB,CAFI;;AAIJC,IAAAA,qCAAiB,CAACF,GAAD,EAAM;AACrBF,MAAAA,OAAO,EAAPA,OADqB;AAErBC,MAAAA,MAAM,EAANA;AAFqB,KAAN,CAAjB;AAIA,wBAAOP,wCAAC,SAAD,mCAAeH,KAAf;AAAsB,MAAA,QAAQ,EAAEc,qBAAS,CAACH,GAAD,EAAMH,QAAN;AAAzC,OAAP;AACD,GAdyB;AAAA,CAA1B;;IAgBaO,gBAAgB,GAAGC,wCAAoB,CAAC,WAAD,EAAc;AAChEC,EAAAA,YADgE,wBACnDjB,KADmD,EAC5CD,QAD4C,EAClC;AAC5B,oBAA0CmB,cAAQ,CAAC,KAAD,CAAlD;AAAA;AAAA,Q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AAjB,GAAyB,CAAzB;;;;"}
1
+ {"version":3,"file":"TreeRovingPlugin.js","sources":["../../../../../src/deprecated/plugins/roving/TreeRovingPlugin.tsx"],"sourcesContent":["/* eslint-disable react/prop-types */\n/* eslint-disable react-hooks/rules-of-hooks */\nimport React, { useMemo, useRef, useState } from 'react';\nimport FocusGroupProvider from '@elliemae/ds-shared/FocusGroup/FocusGroupManager';\nimport useFocusGroupItem from '@elliemae/ds-shared/FocusGroup/useFocusGroupItem';\nimport { mergeRefs } from '@elliemae/ds-utilities';\nimport createInstancePlugin from '@elliemae/ds-shared/createDataInstance/createInstancePlugin';\n\n// eslint-disable-next-line react/display-name\nconst TreeListRovingHoc = (instance) => (props) => {\n const { hotKeys } = instance.getInstance();\n return (\n <FocusGroupProvider hotKeys={hotKeys}>{props.children}</FocusGroupProvider>\n );\n};\n\n// eslint-disable-next-line react/display-name\nconst TreeItemRovingHoc = (Component) => ({\n innerRef,\n onFocus,\n onBlur,\n ...props\n}) => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const ref = useRef(null);\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useFocusGroupItem(ref, {\n onFocus,\n onBlur,\n });\n return <Component {...props} innerRef={mergeRefs(ref, innerRef)} />;\n};\n\nexport const TreeRovingPlugin = createInstancePlugin('tree-data', {\n getItemProps(props, instance) {\n const [isItemFocused, setIsItemFocused] = useState(false);\n return {\n ...props,\n onBlur: () => setIsItemFocused(false),\n // eslint-disable-next-line no-unused-vars\n onFocus: (e) => {\n setIsItemFocused(true);\n if (instance?.props?.onItemFocus) {\n instance.props.onItemFocus({\n scrollToItem: (...args) =>\n props?.listRef?.current?.scrollToItem(args),\n itemIndex: props?.index,\n });\n }\n },\n isItemFocused,\n 'data-index': props.index,\n };\n },\n renderers(renderers, instance) {\n const ListWrapper = useMemo(() => TreeListRovingHoc(instance), []);\n const Item = useMemo(() => TreeItemRovingHoc(renderers.item, instance), []);\n\n return {\n ...renderers,\n listWrapper: ListWrapper,\n item: Item,\n };\n },\n});\n\nTreeRovingPlugin.order = 0;\n"],"names":["TreeListRovingHoc","instance","props","getInstance","hotKeys","React","FocusGroupProvider","children","TreeItemRovingHoc","Component","innerRef","onFocus","onBlur","ref","useRef","useFocusGroupItem","mergeRefs","TreeRovingPlugin","createInstancePlugin","getItemProps","useState","isItemFocused","setIsItemFocused","e","onItemFocus","scrollToItem","args","listRef","current","itemIndex","index","renderers","ListWrapper","useMemo","Item","item","listWrapper","order"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,QAAD;EAAA,OAAc,UAACC,KAAD,EAAW;IACjD,4BAAoBD,QAAQ,CAACE,WAAT,EAApB;QAAQC,OAAR,yBAAQA,OAAR;;IACA,oBACEC,wCAACC,sCAAD;MAAoB,OAAO,EAAEF;OAAUF,KAAK,CAACK,QAA7C,CADF;GAFwB;AAAA,CAA1B;;;AAQA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,SAAD;EAAA,OAAe,gBAKnC;IAAA,IAJJC,QAII,QAJJA,QAII;QAHJC,OAGI,QAHJA,OAGI;QAFJC,MAEI,QAFJA,MAEI;QADDV,KACC;;;IAEJ,IAAMW,GAAG,GAAGC,YAAM,CAAC,IAAD,CAAlB,CAFI;;IAIJC,qCAAiB,CAACF,GAAD,EAAM;MACrBF,OAAO,EAAPA,OADqB;MAErBC,MAAM,EAANA;KAFe,CAAjB;IAIA,oBAAOP,wCAAC,SAAD,mCAAeH,KAAf;MAAsB,QAAQ,EAAEc,qBAAS,CAACH,GAAD,EAAMH,QAAN;OAAhD;GAbwB;AAAA,CAA1B;;IAgBaO,gBAAgB,GAAGC,wCAAoB,CAAC,WAAD,EAAc;EAChEC,YADgE,wBACnDjB,KADmD,EAC5CD,QAD4C,EAClC;IAC5B,gBAA0CmB,cAAQ,CAAC,KAAD,CAAlD;;QAAOC,aAAP;QAAsBC,gBAAtB;;IACA,uCACKpB,KADL;MAEEU,MAAM,EAAE;QAAA,OAAMU,gBAAgB,CAAC,KAAD,CAAtB;OAFV;;MAIEX,OAAO,EAAE,iBAACY,CAAD,EAAO;QAAA;;QACdD,gBAAgB,CAAC,IAAD,CAAhB;;QACA,IAAIrB,QAAJ,aAAIA,QAAJ,kCAAIA,QAAQ,CAAEC,KAAd,4CAAI,gBAAiBsB,WAArB,EAAkC;UAChCvB,QAAQ,CAACC,KAAT,CAAesB,WAAf,CAA2B;YACzBC,YAAY,EAAE;cAAA;;cAAA,kCAAIC,IAAJ;gBAAIA,IAAJ;;;cAAA,OACZxB,KADY,aACZA,KADY,yCACZA,KAAK,CAAEyB,OADK,4EACZ,eAAgBC,OADJ,0DACZ,sBAAyBH,YAAzB,CAAsCC,IAAtC,CADY;aADW;YAGzBG,SAAS,EAAE3B,KAAF,aAAEA,KAAF,uBAAEA,KAAK,CAAE4B;WAHpB;;OAPN;MAcET,aAAa,EAAbA,aAdF;MAeE,cAAcnB,KAAK,CAAC4B;;GAlBwC;EAqBhEC,SArBgE,qBAqBtDA,UArBsD,EAqB3C9B,QArB2C,EAqBjC;IAC7B,IAAM+B,WAAW,GAAGC,aAAO,CAAC;MAAA,OAAMjC,iBAAiB,CAACC,QAAD,CAAvB;KAAD,EAAoC,EAApC,CAA3B;IACA,IAAMiC,IAAI,GAAGD,aAAO,CAAC;MAAA,OAAMzB,iBAAiB,CAACuB,UAAS,CAACI,IAAX,CAAvB;KAAD,EAAoD,EAApD,CAApB;IAEA,uCACKJ,UADL;MAEEK,WAAW,EAAEJ,WAFf;MAGEG,IAAI,EAAED;;;AA5BsD,CAAd;AAiCpDjB,gBAAgB,CAACoB,KAAjB,GAAyB,CAAzB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SearchableTreePlugin.js","sources":["../../../../../src/deprecated/plugins/searchable/SearchableTreePlugin.tsx"],"sourcesContent":["import createInstancePlugin from '@elliemae/ds-shared/createDataInstance/createInstancePlugin';\nimport Highlighter from 'react-highlight-words';\nimport React from 'react';\nimport { usePrevious } from '@elliemae/ds-utilities';\n\nconst markParentsAsChildMatch = (record) => {\n let currRecord = record;\n\n while (currRecord.parentNode) {\n currRecord.parentNode.childMatch = true;\n currRecord = currRecord.parentNode;\n }\n};\n\nfunction transformRecords(records, instance) {\n // gets the ul with overflow: auto\n const list = instance.getListRef()?.current?.parentElement;\n const {\n props: { searchQuery },\n } = instance.getInstance();\n if (!searchQuery) return records;\n // Scroll the list to the top once the search is triggered\n list?.scrollTo(0, 0);\n return records.filter((record) => record.selfMatch || record.childMatch);\n}\ntransformRecords.order = 0;\n\nfunction transformRecord(record, instance) {\n const {\n props: { searchQuery },\n getItemLabel,\n } = instance.getInstance();\n if (\n searchQuery &&\n getItemLabel(record).toLowerCase().indexOf(searchQuery.toLowerCase()) !== -1\n ) {\n markParentsAsChildMatch(record);\n // eslint-disable-next-line no-param-reassign\n record.selfMatch = true;\n }\n return record;\n}\ntransformRecord.order = 0;\n\nconst itemRenderer = (value, itemProps, instance) => {\n const {\n props: { searchQuery, showHighlight = true },\n } = instance.getInstance();\n if (!showHighlight || !searchQuery) return value;\n return (\n <Highlighter\n autoEscape\n highlightClassName=\"tree-text-highlight\"\n searchWords={[searchQuery]}\n textToHighlight={value}\n />\n );\n};\nitemRenderer.order = 0;\n\nexport const SearchableTreePlugin = createInstancePlugin('searchable-tree', {\n instance: (instance) => {\n const {\n props: { searchQuery },\n } = instance;\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const prevSearchQuery = usePrevious(searchQuery);\n return {\n prevSearchQuery,\n };\n },\n shouldWalkChildren: (record, instance) => {\n const {\n props: { searchQuery },\n } = instance.getInstance();\n return !!searchQuery;\n },\n record: transformRecord,\n records: transformRecords,\n itemRenderer,\n});\n"],"names":["markParentsAsChildMatch","record","currRecord","parentNode","childMatch","transformRecords","records","instance","list","getListRef","current","parentElement","getInstance","searchQuery","props","scrollTo","filter","selfMatch","order","transformRecord","getItemLabel","toLowerCase","indexOf","itemRenderer","value","itemProps","showHighlight","React","Highlighter","SearchableTreePlugin","createInstancePlugin","prevSearchQuery","usePrevious","shouldWalkChildren"],"mappings":";;;;;;;;;;;;;;;AAKA,IAAMA,uBAAuB,GAAG,SAA1BA,uBAA0B,CAACC,MAAD,EAAY;AAC1C,MAAIC,UAAU,GAAGD,MAAjB;;AAEA,SAAOC,UAAU,CAACC,UAAlB,EAA8B;AAC5BD,IAAAA,UAAU,CAACC,UAAX,CAAsBC,UAAtB,GAAmC,IAAnC;AACAF,IAAAA,UAAU,GAAGA,UAAU,CAACC,UAAxB;AACD;AACF,CAPD;;AASA,SAASE,gBAAT,CAA0BC,OAA1B,EAAmCC,QAAnC,EAA6C;AAAA;;AAC3C;AACA,MAAMC,IAAI,2BAAGD,QAAQ,CAACE,UAAT,EAAH,kFAAG,qBAAuBC,OAA1B,0DAAG,sBAAgCC,aAA7C;;AACA,8BAEIJ,QAAQ,CAACK,WAAT,EAFJ;AAAA,MACWC,WADX,yBACEC,KADF,CACWD,WADX;;AAGA,MAAI,CAACA,WAAL,EAAkB,OAAOP,OAAP,CANyB;;AAQ3CE,EAAAA,IAAI,SAAJ,IAAAA,IAAI,WAAJ,YAAAA,IAAI,CAAEO,QAAN,CAAe,CAAf,EAAkB,CAAlB;AACA,SAAOT,OAAO,CAACU,MAAR,CAAe,UAACf,MAAD;AAAA,WAAYA,MAAM,CAACgB,SAAP,IAAoBhB,MAAM,CAACG,UAAvC;AAAA,GAAf,CAAP;AACD;;AACDC,gBAAgB,CAACa,KAAjB,GAAyB,CAAzB;;AAEA,SAASC,eAAT,CAAyBlB,MAAzB,EAAiCM,QAAjC,EAA2C;AACzC,+BAGIA,QAAQ,CAACK,WAAT,EAHJ;AAAA,MACWC,WADX,0BACEC,KADF,CACWD,WADX;AAAA,MAEEO,YAFF,0BAEEA,YAFF;;AAIA,MACEP,WAAW,IACXO,YAAY,CAACnB,MAAD,CAAZ,CAAqBoB,WAArB,GAAmCC,OAAnC,CAA2CT,WAAW,CAACQ,W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B1Eb,EAAAA,OAAO,EAAED,gBAlBiE;AAmB1EkB,EAAAA,YAAY,EAAZA;AAnB0E,CAApB;;;;"}
1
+ {"version":3,"file":"SearchableTreePlugin.js","sources":["../../../../../src/deprecated/plugins/searchable/SearchableTreePlugin.tsx"],"sourcesContent":["import createInstancePlugin from '@elliemae/ds-shared/createDataInstance/createInstancePlugin';\nimport Highlighter from 'react-highlight-words';\nimport React from 'react';\nimport { usePrevious } from '@elliemae/ds-utilities';\n\nconst markParentsAsChildMatch = (record) => {\n let currRecord = record;\n\n while (currRecord.parentNode) {\n currRecord.parentNode.childMatch = true;\n currRecord = currRecord.parentNode;\n }\n};\n\nfunction transformRecords(records, instance) {\n // gets the ul with overflow: auto\n const list = instance.getListRef()?.current?.parentElement;\n const {\n props: { searchQuery },\n } = instance.getInstance();\n if (!searchQuery) return records;\n // Scroll the list to the top once the search is triggered\n list?.scrollTo(0, 0);\n return records.filter((record) => record.selfMatch || record.childMatch);\n}\ntransformRecords.order = 0;\n\nfunction transformRecord(record, instance) {\n const {\n props: { searchQuery },\n getItemLabel,\n } = instance.getInstance();\n if (\n searchQuery &&\n getItemLabel(record).toLowerCase().indexOf(searchQuery.toLowerCase()) !== -1\n ) {\n markParentsAsChildMatch(record);\n // eslint-disable-next-line no-param-reassign\n record.selfMatch = true;\n }\n return record;\n}\ntransformRecord.order = 0;\n\nconst itemRenderer = (value, itemProps, instance) => {\n const {\n props: { searchQuery, showHighlight = true },\n } = instance.getInstance();\n if (!showHighlight || !searchQuery) return value;\n return (\n <Highlighter\n autoEscape\n highlightClassName=\"tree-text-highlight\"\n searchWords={[searchQuery]}\n textToHighlight={value}\n />\n );\n};\nitemRenderer.order = 0;\n\nexport const SearchableTreePlugin = createInstancePlugin('searchable-tree', {\n instance: (instance) => {\n const {\n props: { searchQuery },\n } = instance;\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const prevSearchQuery = usePrevious(searchQuery);\n return {\n prevSearchQuery,\n };\n },\n shouldWalkChildren: (record, instance) => {\n const {\n props: { searchQuery },\n } = instance.getInstance();\n return !!searchQuery;\n },\n record: transformRecord,\n records: transformRecords,\n itemRenderer,\n});\n"],"names":["markParentsAsChildMatch","record","currRecord","parentNode","childMatch","transformRecords","records","instance","list","getListRef","current","parentElement","getInstance","searchQuery","props","scrollTo","filter","selfMatch","order","transformRecord","getItemLabel","toLowerCase","indexOf","itemRenderer","value","itemProps","showHighlight","React","Highlighter","SearchableTreePlugin","createInstancePlugin","prevSearchQuery","usePrevious","shouldWalkChildren"],"mappings":";;;;;;;;;;;;;;;AAKA,IAAMA,uBAAuB,GAAG,SAA1BA,uBAA0B,CAACC,MAAD,EAAY;EAC1C,IAAIC,UAAU,GAAGD,MAAjB;;EAEA,OAAOC,UAAU,CAACC,UAAlB,EAA8B;IAC5BD,UAAU,CAACC,UAAX,CAAsBC,UAAtB,GAAmC,IAAnC;IACAF,UAAU,GAAGA,UAAU,CAACC,UAAxB;;AAEH,CAPD;;AASA,SAASE,gBAAT,CAA0BC,OAA1B,EAAmCC,QAAnC,EAA6C;EAAA;;;EAE3C,IAAMC,IAAI,2BAAGD,QAAQ,CAACE,UAAT,EAAH,kFAAG,qBAAuBC,OAA1B,0DAAG,sBAAgCC,aAA7C;;EACA,4BAEIJ,QAAQ,CAACK,WAAT,EAFJ;MACWC,WADX,yBACEC,KADF,CACWD,WADX;;EAGA,IAAI,CAACA,WAAL,EAAkB,OAAOP,OAAP,CANyB;;EAQ3CE,IAAI,SAAJ,IAAAA,IAAI,WAAJ,YAAAA,IAAI,CAAEO,QAAN,CAAe,CAAf,EAAkB,CAAlB;EACA,OAAOT,OAAO,CAACU,MAAR,CAAe,UAACf,MAAD;IAAA,OAAYA,MAAM,CAACgB,SAAP,IAAoBhB,MAAM,CAACG,UAAvC;GAAf,CAAP;AACD;;AACDC,gBAAgB,CAACa,KAAjB,GAAyB,CAAzB;;AAEA,SAASC,eAAT,CAAyBlB,MAAzB,EAAiCM,QAAjC,EAA2C;EACzC,6BAGIA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GA,OAAO,CAAC,CAACA,WAAT;GAfwE;EAiB1EZ,MAAM,EAAEkB,eAjBkE;EAkB1Eb,OAAO,EAAED,gBAlBiE;EAmB1EkB,YAAY,EAAZA;AAnB0E,CAApB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectablePluginTree.js","sources":["../../../../../src/deprecated/plugins/selectable/SelectablePluginTree.tsx"],"sourcesContent":["/* eslint no-param-reassign: [2, { \"props\": false }] */\n/* eslint max-lines: [\"error\", 300] */\nimport React, { useCallback, useMemo } from 'react';\nimport { DSCheckbox, DSRadio } from '@elliemae/ds-form';\nimport { cx, isFunction, useDerivedStateFromProps } from '@elliemae/ds-utilities';\nimport createInstancePlugin from '@elliemae/ds-shared/createDataInstance/createInstancePlugin';\nimport { walkTreeStrategy } from '../tree/walkTreeStrategy';\nimport { getParentChildren, getParentId } from '../tree/utils';\nimport { checkParentState } from './utils';\n\nconst updateParentState = ({ node, checked, selectionState, isCurrentParentChildren = true }) => {\n const { parentNode } = node;\n\n if (parentNode) {\n let nextSelectedChildrenAmount;\n // increase or decrease the amount\n if (checked === true && isCurrentParentChildren) nextSelectedChildrenAmount = parentNode.selectedChildren.length;\n if (checked === true && !isCurrentParentChildren)\n nextSelectedChildrenAmount = parentNode.selectedChildren.length + 1;\n if (checked === false) nextSelectedChildrenAmount = parentNode.selectedChildren.length - 1;\n\n const parentChildren = getParentChildren(node);\n const parentChildrenLength = parentChildren && parentChildren.length;\n\n // check parent state\n const parentState = checkParentState(nextSelectedChildrenAmount, parentChildrenLength, checked);\n\n selectionState[parentNode.id || 'all'] = parentState;\n\n updateParentState({\n node: parentNode,\n checked: parentState,\n selectionState,\n isCurrentParentChildren: false,\n });\n }\n};\n\nconst useSelectableTreeState = (instance) => {\n const {\n originalData,\n idKey = 'id',\n props: {\n onSelect = () => null,\n selection: selectionProp = {},\n onSelectionChange = () => null,\n isMultiSelect = false,\n isSingleSelect = false,\n },\n } = instance;\n const [selection, setSelection] = useDerivedStateFromProps(selectionProp);\n\n const isAllSelected = useMemo(() => {\n if (!isMultiSelect) return false;\n const amountSelected = originalData.reduce(\n (result, item) => (selection[item[idKey]] === true ? result + 1 : result),\n 0,\n );\n\n if (amountSelected === originalData.length) {\n return true;\n }\n if (amountSelected === 0) {\n return false;\n }\n return 'mixed';\n }, [selection]);\n\n const select = useCallback((record, additionalActions = {}) => {\n if (isFunction(onSelect)) {\n onSelect(record.data, {\n scrollToItem: (...args) => {\n if (additionalActions.scrollToItem) additionalActions.scrollToItem(args);\n },\n itemIndex: additionalActions?.itemIndex,\n });\n }\n setSelection((prevSelection) => {\n const nextSelectionState = isMultiSelect ? { ...prevSelection } : {};\n const nextState = isMultiSelect ? !prevSelection[record.id] : {};\n\n nextSelectionState[record.id] = nextState;\n\n if (isMultiSelect || isSingleSelect) {\n // if node group then select all its leafs\n if (record.isGroup && isMultiSelect) {\n if (record.parentNode && nextState) record.parentNode.selectedChildren.push(record.id);\n if (!nextState) record.selectedChildren = [];\n // get all children\n walkTreeStrategy({\n data: record.data.children,\n parentNode: record,\n cb: (node) => {\n const parentId = getParentId(node);\n // if direct child and truthy next state\n if (nextState && parentId === record.id) {\n record.selectedChildren.push(node.id);\n }\n nextSelectionState[node.id] = nextState;\n },\n });\n }\n // mutates the cloned selection state\n updateParentState({\n node: record,\n checked: nextState,\n selectionState: nextSelectionState,\n });\n }\n\n onSelectionChange(nextSelectionState, record.data, {\n scrollToItem: (...args) => {\n if (additionalActions.scrollToItem) additionalActions.scrollToItem(args);\n },\n itemIndex: additionalActions?.itemIndex,\n });\n return nextSelectionState;\n });\n }, []);\n\n return {\n state: { selection, isAllSelected },\n actions: { select },\n };\n};\n\nconst updateParentInternalState = (record, checked) => {\n const { parentNode } = record;\n if (!parentNode) return;\n\n // if next state is checked\n if (checked === true) {\n parentNode.selectedChildren.push(record.id);\n } else {\n parentNode.selectedChildren = parentNode.selectedChildren.filter((id) => id !== record.id);\n }\n};\n\nconst SelectionFormatter = (value, { record }, instance) => {\n const {\n actions: { select },\n props: { isMultiSelect },\n } = instance.getInstance();\n const handleSelect = () => select(record);\n\n return (\n <>\n {isMultiSelect && (\n <DSCheckbox\n checked={record.checked}\n className=\"tree-item-checkbox\"\n data-testid=\"tree-item-checkbox\"\n onChange={handleSelect}\n tabIndex={-1}\n />\n )}\n {value}\n </>\n );\n};\nSelectionFormatter.order = 300;\n\nexport const SelectablePluginTree = createInstancePlugin('selectable', {\n state: useSelectableTreeState,\n // itemRenderer: SelectionFormatter,\n record: (record, instance) => {\n const {\n state: { selection },\n props: { isMultiSelect, isSingleSelect },\n } = instance.getInstance();\n\n record.checked = selection[record.id];\n\n if (isMultiSelect || isSingleSelect) {\n // if it's the root of the tree declare the selectedChildren array\n if (!record.parentNode.id && record.parentNode.selectedChildren === undefined) {\n record.parentNode.selectedChildren = [];\n }\n if (record.isGroup && record.selectedChildren === undefined) {\n record.selectedChildren = [];\n }\n updateParentInternalState(record, record.checked);\n }\n\n return record;\n },\n getItemProps(props, instance, { record }) {\n const {\n actions: { select },\n props: { isMultiSelect, isSingleSelect, disableLeafs, disableGroups },\n } = instance.getInstance();\n const handleSelect = () =>\n select(record, {\n scrollToItem: (...args) => props?.listRef?.current?.scrollToItem(args),\n itemIndex: props?.index,\n });\n const checkboxAddon = isMultiSelect && (\n <DSCheckbox\n checked={record.checked}\n disabled={record.isGroup ? disableGroups : disableLeafs}\n className=\"tree-item-checkbox\"\n data-testid=\"tree-item-checkbox\"\n onChange={handleSelect}\n tabIndex={-1}\n />\n );\n\n const radioAddon = isSingleSelect && !isMultiSelect && (\n <DSRadio\n checked={!!record.checked}\n disabled={record.isGroup ? disableGroups : disableLeafs}\n className=\"tree-item-radio\"\n data-testid=\"tree-item-radio\"\n onChange={handleSelect}\n tabIndex={-1}\n />\n );\n\n if (isMultiSelect || isSingleSelect) {\n return {\n ...props,\n leftAddons: [checkboxAddon, radioAddon, ...(props.leftAddons || [])],\n 'aria-selected': !!record.checked,\n };\n }\n\n return {\n ...props,\n onClick: handleSelect,\n className: cx(props.className, record.checked && 'selected'),\n 'aria-selected': !!record.checked,\n };\n },\n\n hotKeys(grid) {\n return {\n key: 'space',\n handler: ({ index }) => {\n const {\n records,\n actions: { select },\n } = grid.getInstance();\n select(records[index]);\n },\n };\n },\n});\n"],"names":["updateParentState","node","checked","selectionState","isCurrentParentChildren","parentNode","nextSelectedChildrenAmount","selectedChildren","length","parentChildren","getParentChildren","parentChildrenLength","parentState","checkParentState","id","useSelectableTreeState","instance","originalData","idKey","props","onSelect","selection","selectionProp","onSelectionChange","isMultiSelect","isSingleSelect","useDerivedStateFromProps","setSelection","isAllSelected","useMemo","amountSelected","reduce","result","item","select","useCallback","record","additionalActions","isFunction","data","scrollToItem","args","itemIndex","prevSelection","nextSelectionState","nextState","isGroup","push","walkTreeStrategy","children","cb","parentId","getParentId","state","actions","updateParentInternalState","filter","SelectablePluginTree","createInstancePlugin","getInstance","undefined","getItemProps","disableLeafs","disableGroups","handleSelect","listRef","current","index","checkboxAddon","React","DSCheckbox","radioAddon","DSRadio","leftAddons","onClick","className","cx","hotKeys","grid","key","handler","records"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,OAAuE;AAAA,MAApEC,IAAoE,QAApEA,IAAoE;AAAA,MAA9DC,OAA8D,QAA9DA,OAA8D;AAAA,MAArDC,cAAqD,QAArDA,cAAqD;AAAA,mCAArCC,uBAAqC;AAAA,MAArCA,uBAAqC,sCAAX,IAAW;AAC/F,MAAQC,UAAR,GAAuBJ,IAAvB,CAAQI,UAAR;;AAEA,MAAIA,UAAJ,EAAgB;AACd,QAAIC,0BAAJ,CADc;;AAGd,QAAIJ,OAAO,KAAK,IAAZ,IAAoBE,uBAAxB,EAAiDE,0BAA0B,GAAGD,UAAU,CAACE,gBAAX,CAA4BC,MAAzD;AACjD,QAAIN,OAAO,KAAK,IAAZ,IAAoB,CAACE,uBAAzB,EACEE,0BAA0B,GAAGD,UAAU,CA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AAMD,GAtEoE;AAwErE2E,EAAAA,OAxEqE,mBAwE7DC,IAxE6D,EAwEvD;AACZ,WAAO;AACLC,MAAAA,GAAG,EAAE,OADA;AAELC,MAAAA,OAAO,EAAE,wBAAe;AAAA,YAAZb,KAAY,SAAZA,KAAY;;AACtB,gCAGIW,IAAI,CAACnB,WAAL,EAHJ;AAAA,YACEsB,OADF,qBACEA,OADF;AAAA,YAEa/C,MAFb,qBAEEoB,OAFF,CAEapB,MAFb;;AAIAA,QAAAA,MAAM,CAAC+C,OAAO,CAACd,KAAD,CAAR,CAAN;AACD;AARI,KAAP;AAUD;AAnFoE,CAAf;;;;"}
1
+ {"version":3,"file":"SelectablePluginTree.js","sources":["../../../../../src/deprecated/plugins/selectable/SelectablePluginTree.tsx"],"sourcesContent":["/* eslint no-param-reassign: [2, { \"props\": false }] */\n/* eslint max-lines: [\"error\", 300] */\nimport React, { useCallback, useMemo } from 'react';\nimport { DSCheckbox, DSRadio } from '@elliemae/ds-form';\nimport { cx, isFunction, useDerivedStateFromProps } from '@elliemae/ds-utilities';\nimport createInstancePlugin from '@elliemae/ds-shared/createDataInstance/createInstancePlugin';\nimport { walkTreeStrategy } from '../tree/walkTreeStrategy';\nimport { getParentChildren, getParentId } from '../tree/utils';\nimport { checkParentState } from './utils';\n\nconst updateParentState = ({ node, checked, selectionState, isCurrentParentChildren = true }) => {\n const { parentNode } = node;\n\n if (parentNode) {\n let nextSelectedChildrenAmount;\n // increase or decrease the amount\n if (checked === true && isCurrentParentChildren) nextSelectedChildrenAmount = parentNode.selectedChildren.length;\n if (checked === true && !isCurrentParentChildren)\n nextSelectedChildrenAmount = parentNode.selectedChildren.length + 1;\n if (checked === false) nextSelectedChildrenAmount = parentNode.selectedChildren.length - 1;\n\n const parentChildren = getParentChildren(node);\n const parentChildrenLength = parentChildren && parentChildren.length;\n\n // check parent state\n const parentState = checkParentState(nextSelectedChildrenAmount, parentChildrenLength, checked);\n\n selectionState[parentNode.id || 'all'] = parentState;\n\n updateParentState({\n node: parentNode,\n checked: parentState,\n selectionState,\n isCurrentParentChildren: false,\n });\n }\n};\n\nconst useSelectableTreeState = (instance) => {\n const {\n originalData,\n idKey = 'id',\n props: {\n onSelect = () => null,\n selection: selectionProp = {},\n onSelectionChange = () => null,\n isMultiSelect = false,\n isSingleSelect = false,\n },\n } = instance;\n const [selection, setSelection] = useDerivedStateFromProps(selectionProp);\n\n const isAllSelected = useMemo(() => {\n if (!isMultiSelect) return false;\n const amountSelected = originalData.reduce(\n (result, item) => (selection[item[idKey]] === true ? result + 1 : result),\n 0,\n );\n\n if (amountSelected === originalData.length) {\n return true;\n }\n if (amountSelected === 0) {\n return false;\n }\n return 'mixed';\n }, [selection]);\n\n const select = useCallback((record, additionalActions = {}) => {\n if (isFunction(onSelect)) {\n onSelect(record.data, {\n scrollToItem: (...args) => {\n if (additionalActions.scrollToItem) additionalActions.scrollToItem(args);\n },\n itemIndex: additionalActions?.itemIndex,\n });\n }\n setSelection((prevSelection) => {\n const nextSelectionState = isMultiSelect ? { ...prevSelection } : {};\n const nextState = isMultiSelect ? !prevSelection[record.id] : {};\n\n nextSelectionState[record.id] = nextState;\n\n if (isMultiSelect || isSingleSelect) {\n // if node group then select all its leafs\n if (record.isGroup && isMultiSelect) {\n if (record.parentNode && nextState) record.parentNode.selectedChildren.push(record.id);\n if (!nextState) record.selectedChildren = [];\n // get all children\n walkTreeStrategy({\n data: record.data.children,\n parentNode: record,\n cb: (node) => {\n const parentId = getParentId(node);\n // if direct child and truthy next state\n if (nextState && parentId === record.id) {\n record.selectedChildren.push(node.id);\n }\n nextSelectionState[node.id] = nextState;\n },\n });\n }\n // mutates the cloned selection state\n updateParentState({\n node: record,\n checked: nextState,\n selectionState: nextSelectionState,\n });\n }\n\n onSelectionChange(nextSelectionState, record.data, {\n scrollToItem: (...args) => {\n if (additionalActions.scrollToItem) additionalActions.scrollToItem(args);\n },\n itemIndex: additionalActions?.itemIndex,\n });\n return nextSelectionState;\n });\n }, []);\n\n return {\n state: { selection, isAllSelected },\n actions: { select },\n };\n};\n\nconst updateParentInternalState = (record, checked) => {\n const { parentNode } = record;\n if (!parentNode) return;\n\n // if next state is checked\n if (checked === true) {\n parentNode.selectedChildren.push(record.id);\n } else {\n parentNode.selectedChildren = parentNode.selectedChildren.filter((id) => id !== record.id);\n }\n};\n\nconst SelectionFormatter = (value, { record }, instance) => {\n const {\n actions: { select },\n props: { isMultiSelect },\n } = instance.getInstance();\n const handleSelect = () => select(record);\n\n return (\n <>\n {isMultiSelect && (\n <DSCheckbox\n checked={record.checked}\n className=\"tree-item-checkbox\"\n data-testid=\"tree-item-checkbox\"\n onChange={handleSelect}\n tabIndex={-1}\n />\n )}\n {value}\n </>\n );\n};\nSelectionFormatter.order = 300;\n\nexport const SelectablePluginTree = createInstancePlugin('selectable', {\n state: useSelectableTreeState,\n // itemRenderer: SelectionFormatter,\n record: (record, instance) => {\n const {\n state: { selection },\n props: { isMultiSelect, isSingleSelect },\n } = instance.getInstance();\n\n record.checked = selection[record.id];\n\n if (isMultiSelect || isSingleSelect) {\n // if it's the root of the tree declare the selectedChildren array\n if (!record.parentNode.id && record.parentNode.selectedChildren === undefined) {\n record.parentNode.selectedChildren = [];\n }\n if (record.isGroup && record.selectedChildren === undefined) {\n record.selectedChildren = [];\n }\n updateParentInternalState(record, record.checked);\n }\n\n return record;\n },\n getItemProps(props, instance, { record }) {\n const {\n actions: { select },\n props: { isMultiSelect, isSingleSelect, disableLeafs, disableGroups },\n } = instance.getInstance();\n const handleSelect = () =>\n select(record, {\n scrollToItem: (...args) => props?.listRef?.current?.scrollToItem(args),\n itemIndex: props?.index,\n });\n const checkboxAddon = isMultiSelect && (\n <DSCheckbox\n checked={record.checked}\n disabled={record.isGroup ? disableGroups : disableLeafs}\n className=\"tree-item-checkbox\"\n data-testid=\"tree-item-checkbox\"\n onChange={handleSelect}\n tabIndex={-1}\n />\n );\n\n const radioAddon = isSingleSelect && !isMultiSelect && (\n <DSRadio\n checked={!!record.checked}\n disabled={record.isGroup ? disableGroups : disableLeafs}\n className=\"tree-item-radio\"\n data-testid=\"tree-item-radio\"\n onChange={handleSelect}\n tabIndex={-1}\n />\n );\n\n if (isMultiSelect || isSingleSelect) {\n return {\n ...props,\n leftAddons: [checkboxAddon, radioAddon, ...(props.leftAddons || [])],\n 'aria-selected': !!record.checked,\n };\n }\n\n return {\n ...props,\n onClick: handleSelect,\n className: cx(props.className, record.checked && 'selected'),\n 'aria-selected': !!record.checked,\n };\n },\n\n hotKeys(grid) {\n return {\n key: 'space',\n handler: ({ index }) => {\n const {\n records,\n actions: { select },\n } = grid.getInstance();\n select(records[index]);\n },\n };\n },\n});\n"],"names":["updateParentState","node","checked","selectionState","isCurrentParentChildren","parentNode","nextSelectedChildrenAmount","selectedChildren","length","parentChildren","getParentChildren","parentChildrenLength","parentState","checkParentState","id","useSelectableTreeState","instance","originalData","idKey","props","onSelect","selection","selectionProp","onSelectionChange","isMultiSelect","isSingleSelect","useDerivedStateFromProps","setSelection","isAllSelected","useMemo","amountSelected","reduce","result","item","select","useCallback","record","additionalActions","isFunction","data","scrollToItem","args","itemIndex","prevSelection","nextSelectionState","nextState","isGroup","push","walkTreeStrategy","children","cb","parentId","getParentId","state","actions","updateParentInternalState","filter","SelectablePluginTree","createInstancePlugin","getInstance","undefined","getItemProps","disableLeafs","disableGroups","handleSelect","listRef","current","index","checkboxAddon","React","DSCheckbox","radioAddon","DSRadio","leftAddons","onClick","className","cx","hotKeys","grid","key","handler","records"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,OAAuE;EAAA,IAApEC,IAAoE,QAApEA,IAAoE;MAA9DC,OAA8D,QAA9DA,OAA8D;MAArDC,cAAqD,QAArDA,cAAqD;mCAArCC,uBAAqC;MAArCA,uBAAqC,sCAAX,IAAW;EAC/F,IAAQC,UAAR,GAAuBJ,IAAvB,CAAQI,UAAR;;EAEA,IAAIA,UAAJ,EAAgB;IACd,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,GAAG9C,cAAc,IAAI,CAACD,aAAnB,iBACjB6C,wCAACG,cAAD;MACE,OAAO,EAAE,CAAC,CAACpC,MAAM,CAAClC,OADpB;MAEE,QAAQ,EAAEkC,MAAM,CAACU,OAAP,GAAiBiB,aAAjB,GAAiCD,YAF7C;MAGE,SAAS,EAAC,iBAHZ;MAIE,eAAY,iBAJd;MAKE,QAAQ,EAAEE,YALZ;MAME,QAAQ,EAAE,CAAC;MAPf;;IAWA,IAAIxC,aAAa,IAAIC,cAArB,EAAqC;MACnC,uCACKN,KADL;QAEEsD,UAAU,GAAGL,aAAH,EAAkBG,UAAlB,gDAAkCpD,KAAK,CAACsD,UAAN,IAAoB,EAAtD,EAFZ;QAGE,iBAAiB,CAAC,CAACrC,MAAM,CAAClC;;;;IAI9B,uCACKiB,KADL;MAEEuD,OAAO,EAAEV,YAFX;MAGEW,SAAS,EAAEC,cAAE,CAACzD,KAAK,CAACwD,SAAP,EAAkBvC,MAAM,CAAClC,OAAP,IAAkB,UAApC,CAHf;MAIE,iBAAiB,CAAC,CAACkC,MAAM,CAAClC;;GApEuC;EAwErE2E,OAxEqE,mBAwE7DC,IAxE6D,EAwEvD;IACZ,OAAO;MACLC,GAAG,EAAE,OADA;MAELC,OAAO,EAAE,wBAAe;QAAA,IAAZb,KAAY,SAAZA,KAAY;;QACtB,wBAGIW,IAAI,CAACnB,WAAL,EAHJ;YACEsB,OADF,qBACEA,OADF;YAEa/C,MAFb,qBAEEoB,OAFF,CAEapB,MAFb;;QAIAA,MAAM,CAAC+C,OAAO,CAACd,KAAD,CAAR,CAAN;;KAPJ;;AAzEmE,CAAf;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../src/deprecated/plugins/selectable/utils.tsx"],"sourcesContent":["export const checkParentState = (\n nextSelectedChildrenAmount,\n parentChildrenLength,\n checked,\n) => {\n let parentState = false;\n if (nextSelectedChildrenAmount === parentChildrenLength) {\n parentState = true;\n } else if (\n nextSelectedChildrenAmount > 0 &&\n nextSelectedChildrenAmount < parentChildrenLength\n ) {\n parentState = 'mixed';\n } else if (parentChildrenLength && checked === 'mixed') {\n parentState = 'mixed';\n }\n\n return parentState;\n};\n"],"names":["checkParentState","nextSelectedChildrenAmount","parentChildrenLength","checked","parentState"],"mappings":";;;;IAAaA,gBAAgB,GAAG,SAAnBA,gBAAmB,CAC9BC,0BAD8B,EAE9BC,oBAF8B,EAG9BC,OAH8B,EAI3B;AACH,MAAIC,WAAW,GAAG,KAAlB;;AACA,MAAIH,0BAA0B,KAAKC,oBAAnC,EAAyD;AACvDE,IAAAA,WAAW,GAAG,IAAd;AACD,GAFD,MAEO,IACLH,0BAA0B,GAAG,CAA7B,IACAA,0BAA0B,GAAGC,oBAFxB,EAGL;AACAE,IAAAA,WAAW,GAAG,OAAd;AACD,GALM,MAKA,IAAIF,oBAAoB,IAAIC,OAAO,KAAK,OAAxC,EAAiD;AACtDC,IAAAA,WAAW,GAAG,OAAd;AACD;;AAED,SAAOA,WAAP;AACD;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../src/deprecated/plugins/selectable/utils.tsx"],"sourcesContent":["export const checkParentState = (\n nextSelectedChildrenAmount,\n parentChildrenLength,\n checked,\n) => {\n let parentState = false;\n if (nextSelectedChildrenAmount === parentChildrenLength) {\n parentState = true;\n } else if (\n nextSelectedChildrenAmount > 0 &&\n nextSelectedChildrenAmount < parentChildrenLength\n ) {\n parentState = 'mixed';\n } else if (parentChildrenLength && checked === 'mixed') {\n parentState = 'mixed';\n }\n\n return parentState;\n};\n"],"names":["checkParentState","nextSelectedChildrenAmount","parentChildrenLength","checked","parentState"],"mappings":";;;;IAAaA,gBAAgB,GAAG,SAAnBA,gBAAmB,CAC9BC,0BAD8B,EAE9BC,oBAF8B,EAG9BC,OAH8B,EAI3B;EACH,IAAIC,WAAW,GAAG,KAAlB;;EACA,IAAIH,0BAA0B,KAAKC,oBAAnC,EAAyD;IACvDE,WAAW,GAAG,IAAd;GADF,MAEO,IACLH,0BAA0B,GAAG,CAA7B,IACAA,0BAA0B,GAAGC,oBAFxB,EAGL;IACAE,WAAW,GAAG,OAAd;GAJK,MAKA,IAAIF,oBAAoB,IAAIC,OAAO,KAAK,OAAxC,EAAiD;IACtDC,WAAW,GAAG,OAAd;;;EAGF,OAAOA,WAAP;AACD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeToolbarPlugin.js","sources":["../../../../../src/deprecated/plugins/toolbar/TreeToolbarPlugin.tsx"],"sourcesContent":["/* eslint-disable react-hooks/rules-of-hooks */\n/* eslint-disable react/prop-types */\nimport React, { useContext, useMemo, useRef } from 'react';\nimport { MoreOptionsVert } from '@elliemae/ds-icons';\nimport DSButton from '@elliemae/ds-button';\nimport { runAll } from '@elliemae/ds-utilities';\nimport createInstancePlugin from '@elliemae/ds-shared/createDataInstance/createInstancePlugin';\nimport ToolbarProvider, { ToolbarContext } from '@elliemae/ds-shared/toolbar/ToolbarProvider';\nimport FocusGroupContext from '@elliemae/ds-shared/FocusGroup/FocusGroupContext';\n\nconst ToolbarDisclosure = (props) => {\n const {\n onMouseEnter,\n onMouseLeave,\n extraParams,\n renderToolbar,\n isItemFocused,\n icon = <MoreOptionsVert color={['brand-primary', 800]} />,\n rowSize,\n ...rest\n } = props;\n\n const toolbarContext = useContext(ToolbarContext);\n const ref = useRef(null);\n const show = () => {\n if (ref.current) {\n const toolbar = renderToolbar({\n onCloseToolbar: toolbarContext.hide,\n ...extraParams,\n size: rowSize,\n });\n toolbarContext.show({\n reference: ref.current,\n renderer: toolbar,\n });\n }\n };\n\n const hide = (e) => {\n toolbarContext.hide(e);\n };\n\n return (\n <DSButton\n {...rest}\n buttonType=\"text\"\n className=\"toolbar-trigger\"\n icon={icon}\n innerRef={ref}\n onClick={show}\n onMouseEnter={runAll(show, onMouseEnter)}\n onMouseLeave={runAll(hide, onMouseLeave)}\n tabIndex={isItemFocused ? 0 : -1}\n />\n );\n};\n\nconst TriggerFormatter = (value, extraParams, instance) => {\n const {\n props: { onShowToolbar, onCloseToolbar, renderToolbar, rowSize },\n } = instance.getInstance();\n\n return (\n <>\n {value}\n <ToolbarDisclosure\n isItemFocused={extraParams.isItemFocused}\n onClose={onCloseToolbar}\n onShow={onShowToolbar}\n renderToolbar={renderToolbar}\n rowSize={rowSize}\n />\n </>\n );\n};\n\nexport const TreeToolbarPlugin = createInstancePlugin('tree-toolbar', {\n itemRenderer: TriggerFormatter,\n renderers(renderers) {\n const List = useMemo(() => {\n const Component = renderers.list;\n // eslint-disable-next-line react/display-name\n return (props) => {\n const focusContext = useContext(FocusGroupContext);\n return (\n <ToolbarProvider\n onHide={(state, e) => {\n if (e && e.type === 'keydown' && focusContext) focusContext.focus();\n }}\n >\n <Component {...props} />\n </ToolbarProvider>\n );\n };\n }, []);\n return {\n ...renderers,\n list: List,\n };\n },\n});\n"],"names":["ToolbarDisclosure","props","onMouseEnter","onMouseLeave","extraParams","renderToolbar","isItemFocused","icon","React","MoreOptionsVert","rowSize","rest","toolbarContext","useContext","ToolbarContext","ref","useRef","show","current","toolbar","onCloseToolbar","hide","size","reference","renderer","e","DSButton","runAll","TriggerFormatter","value","instance","getInstance","onShowToolbar","TreeToolbarPlugin","createInstancePlugin","itemRenderer","renderers","List","useMemo","Component","list","focusContext","FocusGroupContext","ToolbarProvider","state","type","focus"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,EAAW;AACnC,MACEC,YADF,GASID,KATJ,CACEC,YADF;AAAA,MAEEC,YAFF,GASIF,KATJ,CAEEE,YAFF;AAAA,MAGEC,WAHF,GASIH,KATJ,CAGEG,WAHF;AAAA,MAIEC,aAJF,GASIJ,KATJ,CAIEI,aAJF;AAAA,MAKEC,aALF,GASIL,KATJ,CAKEK,aALF;AAAA,oBASIL,KATJ,CAMEM,IANF;AAAA,MAMEA,IANF,yCAMSC,wCAACC,uBAAD;AAAiB,IAAA,KAAK,EA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ACC,WAAT,EAFJ;AAAA,qDACE9B,KADF;AAAA,MACW+B,aADX,0BACWA,aADX;AAAA,MAC0BZ,cAD1B,0BAC0BA,cAD1B;AAAA,MAC0Cf,aAD1C,0BAC0CA,aAD1C;AAAA,MACyDK,OADzD,0BACyDA,OADzD;;AAIA,sBACEF,kFACGqB,KADH,eAEErB,wCAAC,iBAAD;AACE,IAAA,aAAa,EAAEJ,WAAW,CAACE,aAD7B;AAEE,IAAA,OAAO,EAAEc,cAFX;AAGE,IAAA,MAAM,EAAEY,aAHV;AAIE,IAAA,aAAa,EAAE3B,aAJjB;AAKE,IAAA,OAAO,EAAEK;AALX,IAFF,CADF;AAYD,CAjBD;;IAmBauB,iBAAiB,GAAGC,wCAAoB,CAAC,cAAD,EAAiB;AACpEC,EAAAA,YAAY,EAAEP,gBADsD;AAEpEQ,EAAAA,SAFoE,qBAE1DA,UAF0D,EAE/C;AACnB,QAAMC,IAAI,GAAGC,aAAO,CAAC,YAAM;AACzB,UAAMC,SAAS,GAAGH,UAAS,CAACI,IAA5B,CADyB;;AAGzB,aAAO,UAACvC,KAAD,EAAW;AAChB,YAAMwC,YAAY,GAAG5B,gBAAU,CAAC6B,qCAAD,CAA/B;AACA,4BACElC,wCAACmC,mCAAD;AACE,UAAA,MAAM,EAAE,gBAACC,KAAD,EAAQnB,CAAR,EAAc;AACpB,gBAAIA,CAAC,IAAIA,CAAC,CAACoB,IAAF,KAAW,SAAhB,IAA6BJ,YAAjC,EAA+CA,YAAY,CAACK,KAAb;AAChD;AAHH,wBAKEtC,wCAAC,SAAD,EAAeP,KAAf,CALF,CADF;AASD,OAXD;AAYD,KAfmB,EAejB,EAfiB,CAApB;AAgBA,2CACKmC,UADL;AAEEI,MAAAA,IAAI,EAAEH;AAFR;AAID;AAvBmE,CAAjB;;;;"}
1
+ {"version":3,"file":"TreeToolbarPlugin.js","sources":["../../../../../src/deprecated/plugins/toolbar/TreeToolbarPlugin.tsx"],"sourcesContent":["/* eslint-disable react-hooks/rules-of-hooks */\n/* eslint-disable react/prop-types */\nimport React, { useContext, useMemo, useRef } from 'react';\nimport { MoreOptionsVert } from '@elliemae/ds-icons';\nimport DSButton from '@elliemae/ds-button';\nimport { runAll } from '@elliemae/ds-utilities';\nimport createInstancePlugin from '@elliemae/ds-shared/createDataInstance/createInstancePlugin';\nimport ToolbarProvider, { ToolbarContext } from '@elliemae/ds-shared/toolbar/ToolbarProvider';\nimport FocusGroupContext from '@elliemae/ds-shared/FocusGroup/FocusGroupContext';\n\nconst ToolbarDisclosure = (props) => {\n const {\n onMouseEnter,\n onMouseLeave,\n extraParams,\n renderToolbar,\n isItemFocused,\n icon = <MoreOptionsVert color={['brand-primary', 800]} />,\n rowSize,\n ...rest\n } = props;\n\n const toolbarContext = useContext(ToolbarContext);\n const ref = useRef(null);\n const show = () => {\n if (ref.current) {\n const toolbar = renderToolbar({\n onCloseToolbar: toolbarContext.hide,\n ...extraParams,\n size: rowSize,\n });\n toolbarContext.show({\n reference: ref.current,\n renderer: toolbar,\n });\n }\n };\n\n const hide = (e) => {\n toolbarContext.hide(e);\n };\n\n return (\n <DSButton\n {...rest}\n buttonType=\"text\"\n className=\"toolbar-trigger\"\n icon={icon}\n innerRef={ref}\n onClick={show}\n onMouseEnter={runAll(show, onMouseEnter)}\n onMouseLeave={runAll(hide, onMouseLeave)}\n tabIndex={isItemFocused ? 0 : -1}\n />\n );\n};\n\nconst TriggerFormatter = (value, extraParams, instance) => {\n const {\n props: { onShowToolbar, onCloseToolbar, renderToolbar, rowSize },\n } = instance.getInstance();\n\n return (\n <>\n {value}\n <ToolbarDisclosure\n isItemFocused={extraParams.isItemFocused}\n onClose={onCloseToolbar}\n onShow={onShowToolbar}\n renderToolbar={renderToolbar}\n rowSize={rowSize}\n />\n </>\n );\n};\n\nexport const TreeToolbarPlugin = createInstancePlugin('tree-toolbar', {\n itemRenderer: TriggerFormatter,\n renderers(renderers) {\n const List = useMemo(() => {\n const Component = renderers.list;\n // eslint-disable-next-line react/display-name\n return (props) => {\n const focusContext = useContext(FocusGroupContext);\n return (\n <ToolbarProvider\n onHide={(state, e) => {\n if (e && e.type === 'keydown' && focusContext) focusContext.focus();\n }}\n >\n <Component {...props} />\n </ToolbarProvider>\n );\n };\n }, []);\n return {\n ...renderers,\n list: List,\n };\n },\n});\n"],"names":["ToolbarDisclosure","props","onMouseEnter","onMouseLeave","extraParams","renderToolbar","isItemFocused","icon","React","MoreOptionsVert","rowSize","rest","toolbarContext","useContext","ToolbarContext","ref","useRef","show","current","toolbar","onCloseToolbar","hide","size","reference","renderer","e","DSButton","runAll","TriggerFormatter","value","instance","getInstance","onShowToolbar","TreeToolbarPlugin","createInstancePlugin","itemRenderer","renderers","List","useMemo","Component","list","focusContext","FocusGroupContext","ToolbarProvider","state","type","focus"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,EAAW;EACnC,IACEC,YADF,GASID,KATJ,CACEC,YADF;MAEEC,YAFF,GASIF,KATJ,CAEEE,YAFF;MAGEC,WAHF,GASIH,KATJ,CAGEG,WAHF;MAIEC,aAJF,GASIJ,KATJ,CAIEI,aAJF;MAKEC,aALF,GASIL,KATJ,CAKEK,aALF;oBASIL,KATJ,CAMEM,IANF;MAMEA,IANF,yCAMSC,wCAACC,uBAAD;IAAiB,KAAK,EAAE,CAAC,eAAD,EAAkB,GAAlB;IANjC;MAOEC,OAPF,GASIT,KATJ,CAOES,OAPF;MAQKC,IARL,gDASIV,KATJ;;EAWA,IAAMW,cAAc,GAAGC,gBAAU,CAACC,8BAAD,CAAjC;EACA,IAAMC,GAAG,GAAGC,YAAM,CAAC,IAAD,CAAlB;;EACA,IAAMC,IAAI,GAAG,SAAPA,IAAO,GAAM;IACjB,IAAIF,GAAG,CAACG,OAAR,EAAiB;MACf,IAAMC,OAAO,GAAGd,aAAa;QAC3Be,cAAc,EAAER,cAAc,CAACS;SAC5BjB,WAFwB;QAG3Bk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