@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.
- package/cjs/TreeView.js.map +1 -1
- package/cjs/TreeViewContext.js.map +1 -1
- package/cjs/deprecated/TreeView.js.map +1 -1
- package/cjs/deprecated/__testUtils__/utils.js.map +1 -1
- package/cjs/deprecated/plugins/dnd/TreeDndPlugin.js.map +1 -1
- package/cjs/deprecated/plugins/dnd/renderers/DraggableItem.js.map +1 -1
- package/cjs/deprecated/plugins/dnd/renderers/DroppableList.js.map +1 -1
- package/cjs/deprecated/plugins/dnd/utils.js.map +1 -1
- package/cjs/deprecated/plugins/roving/TreeRovingPlugin.js.map +1 -1
- package/cjs/deprecated/plugins/searchable/SearchableTreePlugin.js.map +1 -1
- package/cjs/deprecated/plugins/selectable/SelectablePluginTree.js.map +1 -1
- package/cjs/deprecated/plugins/selectable/utils.js.map +1 -1
- package/cjs/deprecated/plugins/toolbar/TreeToolbarPlugin.js.map +1 -1
- package/cjs/deprecated/plugins/tree/TreeDataPlugin.js.map +1 -1
- package/cjs/deprecated/plugins/tree/useExpandTreeState.js.map +1 -1
- package/cjs/deprecated/plugins/tree/utils.js.map +1 -1
- package/cjs/deprecated/plugins/tree/walkTreeStrategy.js.map +1 -1
- package/cjs/deprecated/plugins/virtualization/TreeVirtualizationPlugin.js.map +1 -1
- package/cjs/deprecated/renderers.js.map +1 -1
- package/cjs/index-69815fd3.js.map +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/parts/CheckboxSelectable.js.map +1 -1
- package/cjs/parts/ChildrenCountDisplayer.js.map +1 -1
- package/cjs/parts/ExpandCaret.js.map +1 -1
- package/cjs/parts/Icon.js.map +1 -1
- package/cjs/parts/NestingSpace.js.map +1 -1
- package/cjs/parts/RadioSelectable.js.map +1 -1
- package/cjs/parts/TreeItem.js.map +1 -1
- package/cjs/parts/TreeItemText.js.map +1 -1
- package/cjs/parts/TreeList.js.map +1 -1
- package/cjs/plugins/dnd/TreeDndPlugin.js.map +1 -1
- package/cjs/prop-types.js.map +1 -1
- package/cjs/react-desc-prop-types.js.map +1 -1
- package/cjs/related-components/TreeViewSearchBar.js.map +1 -1
- package/cjs/utils/array-helpers.js.map +1 -1
- package/cjs/utils/dnd-helpers.js.map +1 -1
- package/cjs/utils/group-expands-helpers.js.map +1 -1
- package/cjs/utils/keyboard-helpers.js.map +1 -1
- package/cjs/utils/object-helpers.js.map +1 -1
- package/cjs/utils/refs-helpers.js.map +1 -1
- package/cjs/utils/selectable-helper.js.map +1 -1
- package/cjs/utils/string-helpers.js.map +1 -1
- package/cjs/utils/tree-helpers.js.map +1 -1
- package/cjs/utils/useDnDHelpers.js.map +1 -1
- package/cjs/utils/useInstanceRefActions.js.map +1 -1
- package/cjs/utils/useTree.js.map +1 -1
- package/esm/TreeView.js.map +1 -1
- package/esm/TreeViewContext.js.map +1 -1
- package/esm/deprecated/TreeView.js.map +1 -1
- package/esm/deprecated/__testUtils__/utils.js.map +1 -1
- package/esm/deprecated/plugins/dnd/TreeDndPlugin.js.map +1 -1
- package/esm/deprecated/plugins/dnd/renderers/DraggableItem.js.map +1 -1
- package/esm/deprecated/plugins/dnd/renderers/DroppableList.js.map +1 -1
- package/esm/deprecated/plugins/dnd/utils.js.map +1 -1
- package/esm/deprecated/plugins/roving/TreeRovingPlugin.js.map +1 -1
- package/esm/deprecated/plugins/searchable/SearchableTreePlugin.js.map +1 -1
- package/esm/deprecated/plugins/selectable/SelectablePluginTree.js.map +1 -1
- package/esm/deprecated/plugins/selectable/utils.js.map +1 -1
- package/esm/deprecated/plugins/toolbar/TreeToolbarPlugin.js.map +1 -1
- package/esm/deprecated/plugins/tree/TreeDataPlugin.js.map +1 -1
- package/esm/deprecated/plugins/tree/useExpandTreeState.js.map +1 -1
- package/esm/deprecated/plugins/tree/utils.js.map +1 -1
- package/esm/deprecated/plugins/tree/walkTreeStrategy.js.map +1 -1
- package/esm/deprecated/plugins/virtualization/TreeVirtualizationPlugin.js.map +1 -1
- package/esm/deprecated/renderers.js.map +1 -1
- package/esm/index-f9def0ea.js.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/parts/CheckboxSelectable.js.map +1 -1
- package/esm/parts/ChildrenCountDisplayer.js.map +1 -1
- package/esm/parts/ExpandCaret.js.map +1 -1
- package/esm/parts/Icon.js.map +1 -1
- package/esm/parts/NestingSpace.js.map +1 -1
- package/esm/parts/RadioSelectable.js.map +1 -1
- package/esm/parts/TreeItem.js.map +1 -1
- package/esm/parts/TreeItemText.js.map +1 -1
- package/esm/parts/TreeList.js.map +1 -1
- package/esm/plugins/dnd/TreeDndPlugin.js.map +1 -1
- package/esm/prop-types.js.map +1 -1
- package/esm/react-desc-prop-types.js.map +1 -1
- package/esm/related-components/TreeViewSearchBar.js.map +1 -1
- package/esm/utils/array-helpers.js.map +1 -1
- package/esm/utils/dnd-helpers.js.map +1 -1
- package/esm/utils/group-expands-helpers.js.map +1 -1
- package/esm/utils/keyboard-helpers.js.map +1 -1
- package/esm/utils/object-helpers.js.map +1 -1
- package/esm/utils/refs-helpers.js.map +1 -1
- package/esm/utils/selectable-helper.js.map +1 -1
- package/esm/utils/string-helpers.js.map +1 -1
- package/esm/utils/tree-helpers.js.map +1 -1
- package/esm/utils/useDnDHelpers.js.map +1 -1
- package/esm/utils/useInstanceRefActions.js.map +1 -1
- package/esm/utils/useTree.js.map +1 -1
- package/package.json +6 -6
package/cjs/prop-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-types.js","sources":["../../src/prop-types.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport PropTypes from 'prop-types';\n\nexport const InstanceActionsPropTypes = PropTypes.shape({\n toggleExpandAll: PropTypes.func,\n scrollTo: PropTypes.func,\n});\n\nexport const TreeViewInstancePropType = PropTypes.shape({\n current: PropTypes.oneOfType([\n PropTypes.oneOf([null]),\n PropTypes.shape({\n actions: InstanceActionsPropTypes.isRequired,\n }),\n ]),\n});\n\nexport const TreeViewItemPropType = PropTypes.shape({\n children: PropTypes.arrayOf(PropTypes.object),\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n isGroup: PropTypes.oneOfType([\n PropTypes.oneOf([undefined, null]),\n PropTypes.bool,\n ]),\n name: PropTypes.string,\n node: PropTypes.object,\n});\n\nexport const TreeListPropTypes = {\n // required when drag and drop is enabled, tracks the drag and drop results after drop and visual feedback borders\n // passed down to TreeItem\n onMouseDragOverItem: PropTypes.func,\n};\nexport const TreeItemPropTypes = {\n item: TreeViewItemPropType.isRequired,\n index: PropTypes.number,\n itemIndex: PropTypes.number,\n itemWrapperStyle: PropTypes.object,\n virtualItemRef: PropTypes.func,\n spaceForNestingLevel: PropTypes.number,\n onMouseDragOverItem: PropTypes.func,\n};\n\nexport const TreeItemExpandCaretPropTypes = {\n item: TreeViewItemPropType.isRequired,\n};\nexport const TreeItemNestingSpacePropTypes = {\n item: TreeViewItemPropType.isRequired,\n spaceForNestingLevel: PropTypes.number.isRequired,\n};\n\nexport const TreeItemCheckboxPropTypes = {\n item: TreeViewItemPropType.isRequired,\n itemIndex: PropTypes.number.isRequired,\n};\n"],"names":["InstanceActionsPropTypes","PropTypes","shape","toggleExpandAll","func","scrollTo","TreeViewInstancePropType","current","oneOfType","oneOf","actions","isRequired","TreeViewItemPropType","children","arrayOf","object","id","string","number","isGroup","undefined","bool","name","node","TreeListPropTypes","onMouseDragOverItem","TreeItemPropTypes","item","index","itemIndex","itemWrapperStyle","virtualItemRef","spaceForNestingLevel","TreeItemExpandCaretPropTypes","TreeItemNestingSpacePropTypes","TreeItemCheckboxPropTypes"],"mappings":";;;;;;;;;;AAAA;IAGaA,wBAAwB,GAAGC,6BAAS,CAACC,KAAV,CAAgB;
|
|
1
|
+
{"version":3,"file":"prop-types.js","sources":["../../src/prop-types.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport PropTypes from 'prop-types';\n\nexport const InstanceActionsPropTypes = PropTypes.shape({\n toggleExpandAll: PropTypes.func,\n scrollTo: PropTypes.func,\n});\n\nexport const TreeViewInstancePropType = PropTypes.shape({\n current: PropTypes.oneOfType([\n PropTypes.oneOf([null]),\n PropTypes.shape({\n actions: InstanceActionsPropTypes.isRequired,\n }),\n ]),\n});\n\nexport const TreeViewItemPropType = PropTypes.shape({\n children: PropTypes.arrayOf(PropTypes.object),\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n isGroup: PropTypes.oneOfType([\n PropTypes.oneOf([undefined, null]),\n PropTypes.bool,\n ]),\n name: PropTypes.string,\n node: PropTypes.object,\n});\n\nexport const TreeListPropTypes = {\n // required when drag and drop is enabled, tracks the drag and drop results after drop and visual feedback borders\n // passed down to TreeItem\n onMouseDragOverItem: PropTypes.func,\n};\nexport const TreeItemPropTypes = {\n item: TreeViewItemPropType.isRequired,\n index: PropTypes.number,\n itemIndex: PropTypes.number,\n itemWrapperStyle: PropTypes.object,\n virtualItemRef: PropTypes.func,\n spaceForNestingLevel: PropTypes.number,\n onMouseDragOverItem: PropTypes.func,\n};\n\nexport const TreeItemExpandCaretPropTypes = {\n item: TreeViewItemPropType.isRequired,\n};\nexport const TreeItemNestingSpacePropTypes = {\n item: TreeViewItemPropType.isRequired,\n spaceForNestingLevel: PropTypes.number.isRequired,\n};\n\nexport const TreeItemCheckboxPropTypes = {\n item: TreeViewItemPropType.isRequired,\n itemIndex: PropTypes.number.isRequired,\n};\n"],"names":["InstanceActionsPropTypes","PropTypes","shape","toggleExpandAll","func","scrollTo","TreeViewInstancePropType","current","oneOfType","oneOf","actions","isRequired","TreeViewItemPropType","children","arrayOf","object","id","string","number","isGroup","undefined","bool","name","node","TreeListPropTypes","onMouseDragOverItem","TreeItemPropTypes","item","index","itemIndex","itemWrapperStyle","virtualItemRef","spaceForNestingLevel","TreeItemExpandCaretPropTypes","TreeItemNestingSpacePropTypes","TreeItemCheckboxPropTypes"],"mappings":";;;;;;;;;;AAAA;IAGaA,wBAAwB,GAAGC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CAACiB,MAND;EAO/BO,mBAAmB,EAAExB,6BAAS,CAACG;AAPA;IAUpB6B,4BAA4B,GAAG;EAC1CN,IAAI,EAAEf,oBAAoB,CAACD;AADe;IAG/BuB,6BAA6B,GAAG;EAC3CP,IAAI,EAAEf,oBAAoB,CAACD,UADgB;EAE3CqB,oBAAoB,EAAE/B,6BAAS,CAACiB,MAAV,CAAiBP;AAFI;IAKhCwB,yBAAyB,GAAG;EACvCR,IAAI,EAAEf,oBAAoB,CAACD,UADY;EAEvCkB,SAAS,EAAE5B,6BAAS,CAACiB,MAAV,CAAiBP;AAFW;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-desc-prop-types.js","sources":["../../src/react-desc-prop-types.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport { PropTypes } from 'react-desc';\n\nconst InstanceActionsPropTypes = PropTypes.shape({\n toggleExpandAll: PropTypes.func,\n scrollTo: PropTypes.func,\n});\nconst TreeViewItemPropType = PropTypes.shape({\n children: PropTypes.arrayOf(PropTypes.object),\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n isGroup: PropTypes.oneOfType([\n PropTypes.oneOf([undefined, null]),\n PropTypes.bool,\n ]),\n name: PropTypes.string,\n node: PropTypes.object,\n});\n\nconst TreeViewInstancePropType = PropTypes.shape({\n current: PropTypes.oneOfType([\n PropTypes.oneOf([null]),\n PropTypes.shape({\n actions: InstanceActionsPropTypes.isRequired,\n }),\n ]),\n});\n\nexport const TreeViewPropTypes = {\n data: PropTypes.arrayOf(TreeViewItemPropType).description(\n 'data to populate tree view',\n ).isRequired,\n plugins: PropTypes.arrayOf(PropTypes.string)\n .description('list of enabled plugins')\n .defaultValue([]),\n selection: PropTypes.object\n .description('pre selected items')\n .defaultValue({}),\n instanceRef: TreeViewInstancePropType.description('instance ref'),\n disableGroups: PropTypes.bool\n .description('disable grouping funcionality')\n .defaultValue(false),\n disableLeafs: PropTypes.bool\n .description('disable leaf items')\n .defaultValue(false),\n disableIcons: PropTypes.bool.description('disable icons').defaultValue(false),\n fluid: PropTypes.bool\n .description('whether is fluid or not')\n .defaultValue(false),\n isMultiSelect: PropTypes.bool\n .description('whether the tree view is multi select or not')\n .defaultValue(false),\n isSingleSelect: PropTypes.bool\n .description('wheter the tree view is single select or not')\n .defaultValue(false),\n restrictDragAndDrop: PropTypes.bool\n .description('whether to restrict DnD functionality or not')\n .defaultValue(false),\n showChildrenAmount: PropTypes.bool\n .description('whether to show the amount of children or not')\n .defaultValue(false),\n sortable: PropTypes.bool\n .description('whether the sortable functionality is active or not')\n .defaultValue(false),\n labelRenderer: PropTypes.func.description('custom renderer for labels'),\n onItemClick: PropTypes.func.description(\n 'function executed when clicking on an item',\n ),\n onItemFocus: PropTypes.func.description(\n 'function executed when focusing on an item',\n ),\n onVisibleItemsChange: PropTypes.func.description(\n 'function executed when the visible items change',\n ),\n onOrderChange: PropTypes.func.description(\n 'function executed when the items order changes',\n ),\n onSelectionChange: PropTypes.func.description(\n 'function executed when the selection changes',\n ),\n onExpandChange: PropTypes.func.description(\n 'function executed when expanding an item',\n ),\n rowSize: PropTypes.oneOf(['normal', 'compact'])\n .description('size of the row')\n .defaultValue('normal'),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])\n .description('components width')\n .defaultValue('100%'),\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string])\n .description('components height')\n .defaultValue('100%'),\n groupIcon: PropTypes.node.description('icon for groups'),\n itemIcon: PropTypes.node.description('icon for items'),\n searchQuery: PropTypes.string.description('search query value'),\n highlightOnlyQuery: PropTypes.bool\n .description('whether to highlight results or not')\n .defaultValue(false),\n};\n"],"names":["InstanceActionsPropTypes","PropTypes","shape","toggleExpandAll","func","scrollTo","TreeViewItemPropType","children","arrayOf","object","id","oneOfType","string","number","isGroup","oneOf","undefined","bool","name","node","TreeViewInstancePropType","current","actions","isRequired","TreeViewPropTypes","data","description","plugins","defaultValue","selection","instanceRef","disableGroups","disableLeafs","disableIcons","fluid","isMultiSelect","isSingleSelect","restrictDragAndDrop","showChildrenAmount","sortable","labelRenderer","onItemClick","onItemFocus","onVisibleItemsChange","onOrderChange","onSelectionChange","onExpandChange","rowSize","width","height","groupIcon","itemIcon","searchQuery","highlightOnlyQuery"],"mappings":";;;;;;AAAA;AAGA,IAAMA,wBAAwB,GAAGC,mBAAS,CAACC,KAAV,CAAgB;
|
|
1
|
+
{"version":3,"file":"react-desc-prop-types.js","sources":["../../src/react-desc-prop-types.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport { PropTypes } from 'react-desc';\n\nconst InstanceActionsPropTypes = PropTypes.shape({\n toggleExpandAll: PropTypes.func,\n scrollTo: PropTypes.func,\n});\nconst TreeViewItemPropType = PropTypes.shape({\n children: PropTypes.arrayOf(PropTypes.object),\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n isGroup: PropTypes.oneOfType([\n PropTypes.oneOf([undefined, null]),\n PropTypes.bool,\n ]),\n name: PropTypes.string,\n node: PropTypes.object,\n});\n\nconst TreeViewInstancePropType = PropTypes.shape({\n current: PropTypes.oneOfType([\n PropTypes.oneOf([null]),\n PropTypes.shape({\n actions: InstanceActionsPropTypes.isRequired,\n }),\n ]),\n});\n\nexport const TreeViewPropTypes = {\n data: PropTypes.arrayOf(TreeViewItemPropType).description(\n 'data to populate tree view',\n ).isRequired,\n plugins: PropTypes.arrayOf(PropTypes.string)\n .description('list of enabled plugins')\n .defaultValue([]),\n selection: PropTypes.object\n .description('pre selected items')\n .defaultValue({}),\n instanceRef: TreeViewInstancePropType.description('instance ref'),\n disableGroups: PropTypes.bool\n .description('disable grouping funcionality')\n .defaultValue(false),\n disableLeafs: PropTypes.bool\n .description('disable leaf items')\n .defaultValue(false),\n disableIcons: PropTypes.bool.description('disable icons').defaultValue(false),\n fluid: PropTypes.bool\n .description('whether is fluid or not')\n .defaultValue(false),\n isMultiSelect: PropTypes.bool\n .description('whether the tree view is multi select or not')\n .defaultValue(false),\n isSingleSelect: PropTypes.bool\n .description('wheter the tree view is single select or not')\n .defaultValue(false),\n restrictDragAndDrop: PropTypes.bool\n .description('whether to restrict DnD functionality or not')\n .defaultValue(false),\n showChildrenAmount: PropTypes.bool\n .description('whether to show the amount of children or not')\n .defaultValue(false),\n sortable: PropTypes.bool\n .description('whether the sortable functionality is active or not')\n .defaultValue(false),\n labelRenderer: PropTypes.func.description('custom renderer for labels'),\n onItemClick: PropTypes.func.description(\n 'function executed when clicking on an item',\n ),\n onItemFocus: PropTypes.func.description(\n 'function executed when focusing on an item',\n ),\n onVisibleItemsChange: PropTypes.func.description(\n 'function executed when the visible items change',\n ),\n onOrderChange: PropTypes.func.description(\n 'function executed when the items order changes',\n ),\n onSelectionChange: PropTypes.func.description(\n 'function executed when the selection changes',\n ),\n onExpandChange: PropTypes.func.description(\n 'function executed when expanding an item',\n ),\n rowSize: PropTypes.oneOf(['normal', 'compact'])\n .description('size of the row')\n .defaultValue('normal'),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])\n .description('components width')\n .defaultValue('100%'),\n height: PropTypes.oneOfType([PropTypes.number, PropTypes.string])\n .description('components height')\n .defaultValue('100%'),\n groupIcon: PropTypes.node.description('icon for groups'),\n itemIcon: PropTypes.node.description('icon for items'),\n searchQuery: PropTypes.string.description('search query value'),\n highlightOnlyQuery: PropTypes.bool\n .description('whether to highlight results or not')\n .defaultValue(false),\n};\n"],"names":["InstanceActionsPropTypes","PropTypes","shape","toggleExpandAll","func","scrollTo","TreeViewItemPropType","children","arrayOf","object","id","oneOfType","string","number","isGroup","oneOf","undefined","bool","name","node","TreeViewInstancePropType","current","actions","isRequired","TreeViewPropTypes","data","description","plugins","defaultValue","selection","instanceRef","disableGroups","disableLeafs","disableIcons","fluid","isMultiSelect","isSingleSelect","restrictDragAndDrop","showChildrenAmount","sortable","labelRenderer","onItemClick","onItemFocus","onVisibleItemsChange","onOrderChange","onSelectionChange","onExpandChange","rowSize","width","height","groupIcon","itemIcon","searchQuery","highlightOnl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1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeViewSearchBar.js","sources":["../../../src/related-components/TreeViewSearchBar.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { DSNavSearchBox } from '@elliemae/ds-form';\n\nexport function TreeViewSearchBar(props) {\n const { handleChange, onNext, onPrevious, onClear, currentResultIndex, totalResults, value } = props;\n\n return (\n <DSNavSearchBox\n onChange={(v) => {\n handleChange({ target: { value: v } });\n }}\n onNext={onNext}\n onPrevious={onPrevious}\n onClear={onClear}\n currentResultIndex={currentResultIndex}\n totalResults={totalResults}\n value={value}\n />\n );\n}\n\nTreeViewSearchBar.propTypes = {\n value: PropTypes.string.isRequired,\n handleChange: PropTypes.func.isRequired,\n onNext: PropTypes.func.isRequired,\n onPrevious: PropTypes.func.isRequired,\n onClear: PropTypes.func.isRequired,\n currentResultIndex: PropTypes.number.isRequired,\n totalResults: PropTypes.number.isRequired,\n};\n"],"names":["TreeViewSearchBar","props","handleChange","onNext","onPrevious","onClear","currentResultIndex","totalResults","value","React","DSNavSearchBox","v","target","propTypes","PropTypes","string","isRequired","func","number"],"mappings":";;;;;;;;;;;;;AAAA;AAKO,SAASA,iBAAT,CAA2BC,KAA3B,EAAkC;
|
|
1
|
+
{"version":3,"file":"TreeViewSearchBar.js","sources":["../../../src/related-components/TreeViewSearchBar.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { DSNavSearchBox } from '@elliemae/ds-form';\n\nexport function TreeViewSearchBar(props) {\n const { handleChange, onNext, onPrevious, onClear, currentResultIndex, totalResults, value } = props;\n\n return (\n <DSNavSearchBox\n onChange={(v) => {\n handleChange({ target: { value: v } });\n }}\n onNext={onNext}\n onPrevious={onPrevious}\n onClear={onClear}\n currentResultIndex={currentResultIndex}\n totalResults={totalResults}\n value={value}\n />\n );\n}\n\nTreeViewSearchBar.propTypes = {\n value: PropTypes.string.isRequired,\n handleChange: PropTypes.func.isRequired,\n onNext: PropTypes.func.isRequired,\n onPrevious: PropTypes.func.isRequired,\n onClear: PropTypes.func.isRequired,\n currentResultIndex: PropTypes.number.isRequired,\n totalResults: PropTypes.number.isRequired,\n};\n"],"names":["TreeViewSearchBar","props","handleChange","onNext","onPrevious","onClear","currentResultIndex","totalResults","value","React","DSNavSearchBox","v","target","propTypes","PropTypes","string","isRequired","func","number"],"mappings":";;;;;;;;;;;;;AAAA;AAKO,SAASA,iBAAT,CAA2BC,KAA3B,EAAkC;EACvC,IAAQC,YAAR,GAA+FD,KAA/F,CAAQC,YAAR;MAAsBC,MAAtB,GAA+FF,KAA/F,CAAsBE,MAAtB;MAA8BC,UAA9B,GAA+FH,KAA/F,CAA8BG,UAA9B;MAA0CC,OAA1C,GAA+FJ,KAA/F,CAA0CI,OAA1C;MAAmDC,kBAAnD,GAA+FL,KAA/F,CAAmDK,kBAAnD;MAAuEC,YAAvE,GAA+FN,KAA/F,CAAuEM,YAAvE;MAAqFC,KAArF,GAA+FP,KAA/F,CAAqFO,KAArF;EAEA,oBACEC,wCAACC,qBAAD;IACE,QAAQ,EAAE,kBAACC,CAAD,EAAO;MACfT,YAAY,CAAC;QAAEU,MAAM,EAAE;UAAEJ,KAAK,EAAEG;;OAApB,CAAZ;KAFJ;IAIE,MAAM,EAAER,MAJV;IAKE,UAAU,EAAEC,UALd;IAME,OAAO,EAAEC,OANX;IAOE,kBAAkB,EAAEC,kBAPtB;IAQE,YAAY,EAAEC,YARhB;IASE,KAAK,EAAEC;IAVX;AAaD;AAEDR,iBAAiB,CAACa,SAAlB,GAA8B;EAC5BL,KAAK,EAAEM,6BAAS,CAACC,MAAV,CAAiBC,UADI;EAE5Bd,YAAY,EAAEY,6BAAS,CAACG,IAAV,CAAeD,UAFD;EAG5Bb,MAAM,EAAEW,6BAAS,CAACG,IAAV,CAAeD,UAHK;EAI5BZ,UAAU,EAAEU,6BAAS,CAACG,IAAV,CAAeD,UAJC;EAK5BX,OAAO,EAAES,6BAAS,CAACG,IAAV,CAAeD,UALI;EAM5BV,kBAAkB,EAAEQ,6BAAS,CAACI,MAAV,CAAiBF,UANT;EAO5BT,YAAY,EAAEO,6BAAS,CAACI,MAAV,CAAiBF;AAPH,CAA9B;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-helpers.js","sources":["../../../src/utils/array-helpers.tsx"],"sourcesContent":["// https://github.com/sindresorhus/array-move/blob/master/index.js\nexport const arrayMoveMutate = (array, from, to) => {\n const startIndex = from < 0 ? array.length + from : from;\n\n if (startIndex >= 0 && startIndex < array.length) {\n const endIndex = to < 0 ? array.length + to : to;\n\n const [item] = array.splice(from, 1);\n array.splice(endIndex, 0, item);\n }\n};\n\nexport const arrayMove = (array, from, to) => {\n const newArray = [...array];\n arrayMoveMutate(newArray, from, to);\n return newArray;\n};\n"],"names":["arrayMoveMutate","array","from","to","startIndex","length","endIndex","splice","item","arrayMove","newArray"],"mappings":";;;;;;;;;;;;AAAA;IACaA,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD,EAAQC,IAAR,EAAcC,EAAd,EAAqB;
|
|
1
|
+
{"version":3,"file":"array-helpers.js","sources":["../../../src/utils/array-helpers.tsx"],"sourcesContent":["// https://github.com/sindresorhus/array-move/blob/master/index.js\nexport const arrayMoveMutate = (array, from, to) => {\n const startIndex = from < 0 ? array.length + from : from;\n\n if (startIndex >= 0 && startIndex < array.length) {\n const endIndex = to < 0 ? array.length + to : to;\n\n const [item] = array.splice(from, 1);\n array.splice(endIndex, 0, item);\n }\n};\n\nexport const arrayMove = (array, from, to) => {\n const newArray = [...array];\n arrayMoveMutate(newArray, from, to);\n return newArray;\n};\n"],"names":["arrayMoveMutate","array","from","to","startIndex","length","endIndex","splice","item","arrayMove","newArray"],"mappings":";;;;;;;;;;;;AAAA;IACaA,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD,EAAQC,IAAR,EAAcC,EAAd,EAAqB;EAClD,IAAMC,UAAU,GAAGF,IAAI,GAAG,CAAP,GAAWD,KAAK,CAACI,MAAN,GAAeH,IAA1B,GAAiCA,IAApD;;EAEA,IAAIE,UAAU,IAAI,CAAd,IAAmBA,UAAU,GAAGH,KAAK,CAACI,MAA1C,EAAkD;IAChD,IAAMC,QAAQ,GAAGH,EAAE,GAAG,CAAL,GAASF,KAAK,CAACI,MAAN,GAAeF,EAAxB,GAA6BA,EAA9C;;IAEA,oBAAeF,KAAK,CAACM,MAAN,CAAaL,IAAb,EAAmB,CAAnB,CAAf;;QAAOM,IAAP;;IACAP,KAAK,CAACM,MAAN,CAAaD,QAAb,EAAuB,CAAvB,EAA0BE,IAA1B;;AAEH;IAEYC,SAAS,GAAG,SAAZA,SAAY,CAACR,KAAD,EAAQC,IAAR,EAAcC,EAAd,EAAqB;EAC5C,IAAMO,QAAQ,0CAAOT,KAAP,CAAd;;EACAD,eAAe,CAACU,QAAD,EAAWR,IAAX,EAAiBC,EAAjB,CAAf;EACA,OAAOO,QAAP;AACD;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dnd-helpers.js","sources":["../../../src/utils/dnd-helpers.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport { getItemsParentNode, itemsShareSameParent } from './tree-helpers';\n\nexport const keyCodes = {\n lift: [32, 13],\n drop: [32, 13],\n cancel: [27],\n up: [38, 37],\n down: [40, 39],\n};\n\nexport const sameParentAsHoverItemDrop = ({\n isBefore,\n isAfter,\n\n draggedItem,\n overItem,\n movementDirection,\n}) => {\n const hoveredItemNodeNestedIndex = overItem.node.getIndex();\n let newParentNode = getItemsParentNode([overItem], true);\n\n const { treeDepth: draggedItemTreeDepth } = draggedItem;\n const { treeDepth: overItemTreeDepth } = overItem;\n const directionOffset =\n // we don't apply the offset for direction\n // if moving from less nested to more nested\n // or moving bottom to top\n // the offset is required when moving elemnts down in their nest level\n draggedItemTreeDepth <= overItemTreeDepth && movementDirection === 'topToBottom' ? -1 : 0;\n let newNestedIndex;\n\n if (isBefore) newNestedIndex = hoveredItemNodeNestedIndex + directionOffset;\n else if (isAfter) newNestedIndex = hoveredItemNodeNestedIndex + 1 + directionOffset;\n else {\n newNestedIndex = overItem.children.length; // append as last child of the group\n newParentNode = overItem.node;\n }\n if (newNestedIndex < 0) newNestedIndex = 0;\n return {\n newNestedIndex,\n newParentNode,\n };\n};\n\nexport const inferHoverItemKinshipDrop = ({\n isBefore,\n isAfter,\n\n draggedItem,\n overItem,\n movementDirection,\n}) => {\n const hoverItemModel = overItem.node.model;\n const isGroupAndIsExpanded = hoverItemModel.isExpanded && hoverItemModel.children.length > 0;\n\n if (isAfter && isGroupAndIsExpanded) {\n return {\n newNestedIndex: 0, // append after the group, so basically as first child\n newParentNode: overItem.node,\n };\n }\n\n if (isBefore || (isAfter && !isGroupAndIsExpanded)) {\n return sameParentAsHoverItemDrop({\n isBefore,\n isAfter,\n draggedItem,\n overItem,\n movementDirection,\n });\n }\n\n // drop inside\n return {\n newNestedIndex: overItem.children.length, // append as last child of the group\n newParentNode: overItem.node,\n };\n};\n\nexport const isDropValid = ({\n isBefore,\n isAfter,\n\n draggedItem,\n overItem,\n\n restrictDragAndDrop,\n}) => {\n const { id: movedId } = draggedItem;\n const { id: hoverId } = overItem;\n const isInside = !isBefore && !isAfter;\n\n if (movedId === hoverId) return false;\n\n if (isInside && !overItem.isGroup) {\n return false; // we can't drop inside an item that isn't a group\n }\n\n if (restrictDragAndDrop) {\n if (isInside) return false; // in this mode we can't drop inside another element\n const sameParent = itemsShareSameParent([draggedItem, overItem]);\n if (overItem.node.model.isExpanded && isAfter) return false;\n if (!sameParent) return false;\n }\n\n return true;\n};\n\nexport const inferKeyboardKinshipDrop = ({\n items,\n\n newIndex,\n // movementDirection,\n}) => {\n const kinship = {};\n\n // const directionOffset = movementDirection === 'topToBottom' ? 0 : 0;\n const itemBefore = items[newIndex];\n\n const itemBeforeModel = itemBefore.node.model;\n const isGroupAndIsExpanded = itemBeforeModel.isExpanded && itemBeforeModel.children.length > 0;\n\n if (isGroupAndIsExpanded) {\n kinship.newParentNode = itemBefore.node;\n kinship.newNestedIndex = 0;\n } else {\n kinship.newParentNode = getItemsParentNode([itemBefore], true);\n kinship.newNestedIndex = itemBefore.node.getIndex();\n }\n\n return kinship;\n};\n"],"names":["keyCodes","lift","drop","cancel","up","down","sameParentAsHoverItemDrop","isBefore","isAfter","draggedItem","overItem","movementDirection","hoveredItemNodeNestedIndex","node","getIndex","newParentNode","getItemsParentNode","draggedItemTreeDepth","treeDepth","overItemTreeDepth","directionOffset","newNestedIndex","children","length","inferHoverItemKinshipDrop","hoverItemModel","model","isGroupAndIsExpanded","isExpanded","isDropValid","restrictDragAndDrop","movedId","id","hoverId","isInside","isGroup","sameParent","itemsShareSameParent","inferKeyboardKinshipDrop","items","newIndex","kinship","itemBefore","itemBeforeModel"],"mappings":";;;;;;;;;AAAA;IAGaA,QAAQ,GAAG;
|
|
1
|
+
{"version":3,"file":"dnd-helpers.js","sources":["../../../src/utils/dnd-helpers.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport { getItemsParentNode, itemsShareSameParent } from './tree-helpers';\n\nexport const keyCodes = {\n lift: [32, 13],\n drop: [32, 13],\n cancel: [27],\n up: [38, 37],\n down: [40, 39],\n};\n\nexport const sameParentAsHoverItemDrop = ({\n isBefore,\n isAfter,\n\n draggedItem,\n overItem,\n movementDirection,\n}) => {\n const hoveredItemNodeNestedIndex = overItem.node.getIndex();\n let newParentNode = getItemsParentNode([overItem], true);\n\n const { treeDepth: draggedItemTreeDepth } = draggedItem;\n const { treeDepth: overItemTreeDepth } = overItem;\n const directionOffset =\n // we don't apply the offset for direction\n // if moving from less nested to more nested\n // or moving bottom to top\n // the offset is required when moving elemnts down in their nest level\n draggedItemTreeDepth <= overItemTreeDepth && movementDirection === 'topToBottom' ? -1 : 0;\n let newNestedIndex;\n\n if (isBefore) newNestedIndex = hoveredItemNodeNestedIndex + directionOffset;\n else if (isAfter) newNestedIndex = hoveredItemNodeNestedIndex + 1 + directionOffset;\n else {\n newNestedIndex = overItem.children.length; // append as last child of the group\n newParentNode = overItem.node;\n }\n if (newNestedIndex < 0) newNestedIndex = 0;\n return {\n newNestedIndex,\n newParentNode,\n };\n};\n\nexport const inferHoverItemKinshipDrop = ({\n isBefore,\n isAfter,\n\n draggedItem,\n overItem,\n movementDirection,\n}) => {\n const hoverItemModel = overItem.node.model;\n const isGroupAndIsExpanded = hoverItemModel.isExpanded && hoverItemModel.children.length > 0;\n\n if (isAfter && isGroupAndIsExpanded) {\n return {\n newNestedIndex: 0, // append after the group, so basically as first child\n newParentNode: overItem.node,\n };\n }\n\n if (isBefore || (isAfter && !isGroupAndIsExpanded)) {\n return sameParentAsHoverItemDrop({\n isBefore,\n isAfter,\n draggedItem,\n overItem,\n movementDirection,\n });\n }\n\n // drop inside\n return {\n newNestedIndex: overItem.children.length, // append as last child of the group\n newParentNode: overItem.node,\n };\n};\n\nexport const isDropValid = ({\n isBefore,\n isAfter,\n\n draggedItem,\n overItem,\n\n restrictDragAndDrop,\n}) => {\n const { id: movedId } = draggedItem;\n const { id: hoverId } = overItem;\n const isInside = !isBefore && !isAfter;\n\n if (movedId === hoverId) return false;\n\n if (isInside && !overItem.isGroup) {\n return false; // we can't drop inside an item that isn't a group\n }\n\n if (restrictDragAndDrop) {\n if (isInside) return false; // in this mode we can't drop inside another element\n const sameParent = itemsShareSameParent([draggedItem, overItem]);\n if (overItem.node.model.isExpanded && isAfter) return false;\n if (!sameParent) return false;\n }\n\n return true;\n};\n\nexport const inferKeyboardKinshipDrop = ({\n items,\n\n newIndex,\n // movementDirection,\n}) => {\n const kinship = {};\n\n // const directionOffset = movementDirection === 'topToBottom' ? 0 : 0;\n const itemBefore = items[newIndex];\n\n const itemBeforeModel = itemBefore.node.model;\n const isGroupAndIsExpanded = itemBeforeModel.isExpanded && itemBeforeModel.children.length > 0;\n\n if (isGroupAndIsExpanded) {\n kinship.newParentNode = itemBefore.node;\n kinship.newNestedIndex = 0;\n } else {\n kinship.newParentNode = getItemsParentNode([itemBefore], true);\n kinship.newNestedIndex = itemBefore.node.getIndex();\n }\n\n return kinship;\n};\n"],"names":["keyCodes","lift","drop","cancel","up","down","sameParentAsHoverItemDrop","isBefore","isAfter","draggedItem","overItem","movementDirection","hoveredItemNodeNestedIndex","node","getIndex","newParentNode","getItemsParentNode","draggedItemTreeDepth","treeDepth","overItemTreeDepth","directionOffset","newNestedIndex","children","length","inferHoverItemKinshipDrop","hoverItemModel","model","isGroupAndIsExpanded","isExpanded","isDropValid","restrictDragAndDrop","movedId","id","hoverId","isInside","isGroup","sameParent","itemsShareSameParent","inferKeyboardKinshipDrop","items","newIndex","kinship","itemBefore","itemBeforeModel"],"mappings":";;;;;;;;;AAAA;IAGaA,QAAQ,GAAG;EACtBC,IAAI,EAAE,CAAC,EAAD,EAAK,EAAL,CADgB;EAEtBC,IAAI,EAAE,CAAC,EAAD,EAAK,EAAL,CAFgB;EAGtBC,MAAM,EAAE,CAAC,EAAD,CAHc;EAItBC,EAAE,EAAE,CAAC,EAAD,EAAK,EAAL,CAJkB;EAKtBC,IAAI,EAAE,CAAC,EAAD,EAAK,EAAL;AALgB;IAQXC,yBAAyB,GAAG,SAA5BA,yBAA4B,OAOnC;EAAA,IANJC,QAMI,QANJA,QAMI;MALJC,OAKI,QALJA,OAKI;MAHJC,WAGI,QAHJA,WAGI;MAFJC,QAEI,QAFJA,QAEI;MADJC,iBACI,QADJA,iBACI;EACJ,IAAMC,0BAA0B,GAAGF,QAAQ,CAACG,IAAT,CAAcC,QAAd,EAAnC;EACA,IAAIC,aAAa,GAAGC,oCAAkB,CAAC,CAACN,QAAD,CAAD,EAAa,IAAb,CAAtC;EAEA,IAAmBO,oBAAnB,GAA4CR,WAA5C,CAAQS,SAAR;EACA,IAAmBC,iBAAnB,GAAyCT,QAAzC,CAAQQ,SAAR;EACA,IAAME,eAAe;;;;EAKnBH,oBAAoB,IAAIE,iBAAxB,IAA6CR,iBAAiB,KAAK,aAAnE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B;IACxBc,OAAO,CAAC1B,aAAR,GAAwB2B,UAAU,CAAC7B,IAAnC;IACA4B,OAAO,CAACpB,cAAR,GAAyB,CAAzB;GAFF,MAGO;IACLoB,OAAO,CAAC1B,aAAR,GAAwBC,oCAAkB,CAAC,CAAC0B,UAAD,CAAD,EAAe,IAAf,CAA1C;IACAD,OAAO,CAACpB,cAAR,GAAyBqB,UAAU,CAAC7B,IAAX,CAAgBC,QAAhB,EAAzB;;;EAGF,OAAO2B,OAAP;AACD;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-expands-helpers.js","sources":["../../../src/utils/group-expands-helpers.tsx"],"sourcesContent":["/* eslint-disable max-params */\nimport { useCallback, useEffect } from 'react';\n\nexport const toggleItemExpand = (itemToToggle, triggerTreeRerender, scrollTo = () => {}) => {\n const {\n node: {\n model: { isExpanded },\n },\n virtualIndex,\n } = itemToToggle;\n if (itemToToggle.node.model.isGroup) {\n itemToToggle.node.model.isExpanded = !isExpanded;\n triggerTreeRerender();\n setTimeout(() => {\n scrollTo(virtualIndex, { align: 'start' });\n });\n }\n};\n\nexport const expandItemModel = (modelToExpand) => {\n if (modelToExpand.isGroup) modelToExpand.isExpanded = true;\n};\n\nexport const collapseItemModel = (modelToCollapse) => {\n if (modelToCollapse.isGroup) modelToCollapse.isExpanded = false;\n};\n\nexport const expandAll = (treeRoot, triggerTreeRerender) => {\n treeRoot.walk((node) => {\n if (!node.isRoot()) expandItemModel(node.model);\n });\n triggerTreeRerender();\n};\nexport const collapseAll = (treeRoot, triggerTreeRerender) => {\n treeRoot.walk((node) => {\n if (!node.isRoot()) collapseItemModel(node.model);\n });\n triggerTreeRerender();\n};\nexport const getToggleExpandShouldExpand = (treeRoot) => {\n let shouldExpand = false;\n treeRoot.walk((node) => {\n if (!node.isRoot()) {\n if (!node.model.isExpanded && node.model.isGroup) {\n shouldExpand = true;\n // eslint-disable-next-line no-useless-return\n return;\n }\n }\n });\n return shouldExpand;\n};\n\nexport const toggleExpandAllHelper = (isExpand, treeRoot, triggerTreeRerender, setLatestToggledItem) => {\n if (isExpand === true) expandAll(treeRoot, triggerTreeRerender);\n else if (isExpand === false) collapseAll(treeRoot, triggerTreeRerender);\n else {\n const shouldExpand = getToggleExpandShouldExpand(treeRoot);\n if (shouldExpand === true) expandAll(treeRoot, triggerTreeRerender);\n else collapseAll(treeRoot, triggerTreeRerender);\n }\n setLatestToggledItem(null);\n};\n\nexport const useNotifyExpandedChange = (propsWithDefaults, { latestToggledItem, expandedGroups }) => {\n const notifyExpandedChange = useCallback(\n (expandedGroupHashmap) => propsWithDefaults.onExpandChange(expandedGroupHashmap, latestToggledItem),\n [propsWithDefaults, latestToggledItem],\n );\n\n useEffect(() => {\n notifyExpandedChange(expandedGroups);\n }, [expandedGroups]);\n};\n"],"names":["toggleItemExpand","itemToToggle","triggerTreeRerender","scrollTo","isExpanded","node","model","virtualIndex","isGroup","setTimeout","align","expandItemModel","modelToExpand","collapseItemModel","modelToCollapse","expandAll","treeRoot","walk","isRoot","collapseAll","getToggleExpandShouldExpand","shouldExpand","toggleExpandAllHelper","isExpand","setLatestToggledItem","useNotifyExpandedChange","propsWithDefaults","latestToggledItem","expandedGroups","notifyExpandedChange","useCallback","expandedGroupHashmap","onExpandChange","useEffect"],"mappings":";;;;;;AAAA;IAGaA,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,YAAD,EAAeC,mBAAf,EAA4D;
|
|
1
|
+
{"version":3,"file":"group-expands-helpers.js","sources":["../../../src/utils/group-expands-helpers.tsx"],"sourcesContent":["/* eslint-disable max-params */\nimport { useCallback, useEffect } from 'react';\n\nexport const toggleItemExpand = (itemToToggle, triggerTreeRerender, scrollTo = () => {}) => {\n const {\n node: {\n model: { isExpanded },\n },\n virtualIndex,\n } = itemToToggle;\n if (itemToToggle.node.model.isGroup) {\n itemToToggle.node.model.isExpanded = !isExpanded;\n triggerTreeRerender();\n setTimeout(() => {\n scrollTo(virtualIndex, { align: 'start' });\n });\n }\n};\n\nexport const expandItemModel = (modelToExpand) => {\n if (modelToExpand.isGroup) modelToExpand.isExpanded = true;\n};\n\nexport const collapseItemModel = (modelToCollapse) => {\n if (modelToCollapse.isGroup) modelToCollapse.isExpanded = false;\n};\n\nexport const expandAll = (treeRoot, triggerTreeRerender) => {\n treeRoot.walk((node) => {\n if (!node.isRoot()) expandItemModel(node.model);\n });\n triggerTreeRerender();\n};\nexport const collapseAll = (treeRoot, triggerTreeRerender) => {\n treeRoot.walk((node) => {\n if (!node.isRoot()) collapseItemModel(node.model);\n });\n triggerTreeRerender();\n};\nexport const getToggleExpandShouldExpand = (treeRoot) => {\n let shouldExpand = false;\n treeRoot.walk((node) => {\n if (!node.isRoot()) {\n if (!node.model.isExpanded && node.model.isGroup) {\n shouldExpand = true;\n // eslint-disable-next-line no-useless-return\n return;\n }\n }\n });\n return shouldExpand;\n};\n\nexport const toggleExpandAllHelper = (isExpand, treeRoot, triggerTreeRerender, setLatestToggledItem) => {\n if (isExpand === true) expandAll(treeRoot, triggerTreeRerender);\n else if (isExpand === false) collapseAll(treeRoot, triggerTreeRerender);\n else {\n const shouldExpand = getToggleExpandShouldExpand(treeRoot);\n if (shouldExpand === true) expandAll(treeRoot, triggerTreeRerender);\n else collapseAll(treeRoot, triggerTreeRerender);\n }\n setLatestToggledItem(null);\n};\n\nexport const useNotifyExpandedChange = (propsWithDefaults, { latestToggledItem, expandedGroups }) => {\n const notifyExpandedChange = useCallback(\n (expandedGroupHashmap) => propsWithDefaults.onExpandChange(expandedGroupHashmap, latestToggledItem),\n [propsWithDefaults, latestToggledItem],\n );\n\n useEffect(() => {\n notifyExpandedChange(expandedGroups);\n }, [expandedGroups]);\n};\n"],"names":["toggleItemExpand","itemToToggle","triggerTreeRerender","scrollTo","isExpanded","node","model","virtualIndex","isGroup","setTimeout","align","expandItemModel","modelToExpand","collapseItemModel","modelToCollapse","expandAll","treeRoot","walk","isRoot","collapseAll","getToggleExpandShouldExpand","shouldExpand","toggleExpandAllHelper","isExpand","setLatestToggledItem","useNotifyExpandedChange","propsWithDefaults","latestToggledItem","expandedGroups","notifyExpandedChange","useCallback","expandedGroupHashmap","onExpandChange","useEffect"],"mappings":";;;;;;AAAA;IAGaA,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,YAAD,EAAeC,mBAAf,EAA4D;EAAA,IAAxBC,QAAwB,uEAAb,YAAM,EAAO;EAC1F,IAEaC,UAFb,GAKIH,YALJ,CACEI,IADF,CAEIC,KAFJ,CAEaF,UAFb;MAIEG,YAJF,GAKIN,YALJ,CAIEM,YAJF;;EAMA,IAAIN,YAAY,CAACI,IAAb,CAAkBC,KAAlB,CAAwBE,OAA5B,EAAqC;IACnCP,YAAY,CAACI,IAAb,CAAkBC,KAAlB,CAAwBF,UAAxB,GAAqC,CAACA,UAAtC;IACAF,mBAAmB;IACnBO,UAAU,CAAC,YAAM;MACfN,QAAQ,CAACI,YAAD,EAAe;QAAEG,KAAK,EAAE;OAAxB,CAAR;KADQ,CAAV;;AAIH;IAEYC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,aAAD,EAAmB;EAChD,IAAIA,aAAa,CAACJ,OAAlB,EAA2BI,aAAa,CAACR,UAAd,GAA2B,IAA3B;AAC5B;IAEYS,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,eAAD,EAAqB;EACpD,IAAIA,eAAe,CAACN,OAApB,EAA6BM,eAAe,CAACV,UAAhB,GAA6B,KAA7B;AAC9B;IAEYW,SAAS,GAAG,SAAZA,SAAY,CAACC,QAAD,EAAWd,mBAAX,EAAmC;EAC1Dc,QAAQ,CAACC,IAAT,CAAc,UAACZ,IAAD,EAAU;IACtB,IAAI,CAACA,IAAI,CAACa,MAAL,EAAL,EAAoBP,eAAe,CAACN,IAAI,CAACC,KAAN,CAAf;GADtB;EAGAJ,mBAAmB;AACpB;IACYiB,WAAW,GAAG,SAAdA,WAAc,CAACH,QAAD,EAAWd,mBAAX,EAAmC;EAC5Dc,QAAQ,CAACC,IAAT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B,CAAiCD,oBAAjC,EAAuDJ,iBAAvD,CAA1B;GADsC,EAEtC,CAACD,iBAAD,EAAoBC,iBAApB,CAFsC,CAAxC;EAKAM,eAAS,CAAC,YAAM;IACdJ,oBAAoB,CAACD,cAAD,CAApB;GADO,EAEN,CAACA,cAAD,CAFM,CAAT;AAGD;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard-helpers.js","sources":["../../../src/utils/keyboard-helpers.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext, useEffect } from 'react';\nimport TreeViewContext from '../TreeViewContext';\nimport { focusItem } from './tree-helpers';\nimport {\n toggleExpandAllHelper,\n toggleItemExpand,\n} from './group-expands-helpers';\n\n// 9 tab\n// 13 enter\n// 32 space\n// 37 left arrow\n// 38 up arrow\n// 39 right arrow\n// 40 down arrow\n// 35 end\n// 36 home\n\n// 56 number 8\n// 106 (NumPad) *\n\nexport const useOnItemKeyDown = (item) => {\n const ctx = useContext(TreeViewContext);\n const {\n props: { onItemFocus },\n triggerTreeRerender,\n isDragging,\n visibleItems,\n setFocusedItem,\n setSelectedItem,\n setLatestToggledItem,\n virtualListHelpers: { scrollToIndex },\n } = ctx;\n const { isGroup, isExpanded } = item;\n const onItemFocusCurry = useCallback(\n (newFocusItem) =>\n onItemFocus({\n itemIndex: newFocusItem.virtualIndex,\n scrollToItem: (opts = { align: 'start' }) =>\n scrollToIndex(newFocusItem.virtualIndex, opts),\n item: newFocusItem,\n }),\n [onItemFocus],\n );\n\n const onItemKeyDown = useCallback(\n (e) => {\n const { keyCode } = e;\n if (!isDragging) {\n if (keyCode !== 9) e.preventDefault(); // allow tab/shift+tab\n if (keyCode === 13 || keyCode === 32) setSelectedItem(item);\n\n if (keyCode === 37) {\n if (isGroup && isExpanded) {\n toggleItemExpand(item, triggerTreeRerender, scrollToIndex);\n setLatestToggledItem(item);\n }\n }\n if (keyCode === 39) {\n if (isGroup && !isExpanded) {\n toggleItemExpand(item, triggerTreeRerender, scrollToIndex);\n setLatestToggledItem(item);\n }\n }\n\n const { virtualIndex } = item;\n const lastItemIndex = visibleItems.length - 1;\n if (keyCode === 38) {\n const isLoopedFocus = virtualIndex === 0;\n const newFocusIndex = isLoopedFocus\n ? lastItemIndex\n : virtualIndex - 1;\n const newFocusItem = visibleItems[newFocusIndex];\n scrollToIndex(newFocusIndex);\n if (isLoopedFocus) {\n // when looping the list from start to end we need to wait a bit before focusing\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n focusItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n }, 300);\n } else {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }\n }\n if (keyCode === 40) {\n const isLoopedFocus = virtualIndex === lastItemIndex;\n const newFocusIndex = isLoopedFocus ? 0 : virtualIndex + 1;\n const newFocusItem = visibleItems[newFocusIndex];\n scrollToIndex(newFocusIndex);\n if (isLoopedFocus) {\n // when looping the list from start to end we need to wait a bit before focusing\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n } else {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }\n }\n if (keyCode === 35) {\n if (virtualIndex !== lastItemIndex) {\n const newFocusItem = visibleItems[lastItemIndex];\n scrollToIndex(lastItemIndex);\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n }\n }\n if (keyCode === 36) {\n if (virtualIndex !== 0) {\n const newFocusItem = visibleItems[0];\n scrollToIndex(0);\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n }\n }\n }\n },\n [\n item,\n visibleItems,\n isGroup,\n isDragging,\n onItemFocusCurry,\n setFocusedItem,\n setSelectedItem,\n ],\n );\n\n return onItemKeyDown;\n};\n\nexport const useGlobalKeyboardListener = (func) => {\n useEffect(() => {\n document.addEventListener('keydown', func);\n return () => document.removeEventListener('keydown', func);\n }, [func]);\n};\n\nexport const useGlobalToggleAllExpandShortcut = (\n treeRoot,\n triggerTreeRerender,\n setLatestToggledItem,\n) => {\n const memoizedToggleAllKeyboardShortcut = useCallback(\n (e) => {\n const { shiftKey, keyCode } = e;\n if (shiftKey && keyCode === 56) {\n toggleExpandAllHelper(\n 'toggle',\n treeRoot,\n triggerTreeRerender,\n setLatestToggledItem,\n );\n }\n },\n [treeRoot, triggerTreeRerender],\n );\n\n return useGlobalKeyboardListener(memoizedToggleAllKeyboardShortcut);\n};\n"],"names":["useOnItemKeyDown","item","ctx","useContext","TreeViewContext","onItemFocus","props","triggerTreeRerender","isDragging","visibleItems","setFocusedItem","setSelectedItem","setLatestToggledItem","scrollToIndex","virtualListHelpers","isGroup","isExpanded","onItemFocusCurry","useCallback","newFocusItem","itemIndex","virtualIndex","scrollToItem","opts","align","onItemKeyDown","e","keyCode","preventDefault","toggleItemExpand","lastItemIndex","length","isLoopedFocus","newFocusIndex","setTimeout","focusItem","useGlobalKeyboardListener","func","useEffect","document","addEventListener","removeEventListener","useGlobalToggleAllExpandShortcut","treeRoot","memoizedToggleAllKeyboardShortcut","shiftKey","toggleExpandAllHelper"],"mappings":";;;;;;;;;;;AAAA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;IAEaA,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,IAAD,EAAU;AACxC,MAAMC,GAAG,GAAGC,gBAAU,CAACC,0BAAD,CAAtB;AACA,MACWC,WADX,GASIH,GATJ,CACEI,KADF,CACWD,WADX;AAAA,MAEEE,mBAFF,GASIL,GATJ,CAEEK,mBAFF;AAAA,MAGEC,UAHF,GASIN,GATJ,CAGEM,UAHF;AAAA,MAIEC,YAJF,GASIP,GATJ,CAIEO,YAJF;AAAA,MA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QAAQ,CAACC,gBAAT,CAA0B,SAA1B,EAAqCH,IAArC;AACA,WAAO;AAAA,aAAME,QAAQ,CAACE,mBAAT,CAA6B,SAA7B,EAAwCJ,IAAxC,CAAN;AAAA,KAAP;AACD,GAHQ,EAGN,CAACA,IAAD,CAHM,CAAT;AAID;IAEYK,gCAAgC,GAAG,SAAnCA,gCAAmC,CAC9CC,QAD8C,EAE9CpC,mBAF8C,EAG9CK,oBAH8C,EAI3C;AACH,MAAMgC,iCAAiC,GAAG1B,iBAAW,CACnD,UAACQ,CAAD,EAAO;AACL,QAAQmB,QAAR,GAA8BnB,CAA9B,CAAQmB,QAAR;AAAA,QAAkBlB,OAAlB,GAA8BD,CAA9B,CAAkBC,OAAlB;;AACA,QAAIkB,QAAQ,IAAIlB,OAAO,KAAK,EAA5B,EAAgC;AAC9BmB,MAAAA,+CAAqB,CACnB,QADmB,EAEnBH,QAFmB,EAGnBpC,mBAHmB,EAInBK,oBAJmB,CAArB;AAMD;AACF,GAXkD,EAYnD,CAAC+B,QAAD,EAAWpC,mBAAX,CAZmD,CAArD;AAeA,SAAO6B,yBAAyB,CAACQ,iCAAD,CAAhC;AACD;;;;;;"}
|
|
1
|
+
{"version":3,"file":"keyboard-helpers.js","sources":["../../../src/utils/keyboard-helpers.tsx"],"sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext, useEffect } from 'react';\nimport TreeViewContext from '../TreeViewContext';\nimport { focusItem } from './tree-helpers';\nimport {\n toggleExpandAllHelper,\n toggleItemExpand,\n} from './group-expands-helpers';\n\n// 9 tab\n// 13 enter\n// 32 space\n// 37 left arrow\n// 38 up arrow\n// 39 right arrow\n// 40 down arrow\n// 35 end\n// 36 home\n\n// 56 number 8\n// 106 (NumPad) *\n\nexport const useOnItemKeyDown = (item) => {\n const ctx = useContext(TreeViewContext);\n const {\n props: { onItemFocus },\n triggerTreeRerender,\n isDragging,\n visibleItems,\n setFocusedItem,\n setSelectedItem,\n setLatestToggledItem,\n virtualListHelpers: { scrollToIndex },\n } = ctx;\n const { isGroup, isExpanded } = item;\n const onItemFocusCurry = useCallback(\n (newFocusItem) =>\n onItemFocus({\n itemIndex: newFocusItem.virtualIndex,\n scrollToItem: (opts = { align: 'start' }) =>\n scrollToIndex(newFocusItem.virtualIndex, opts),\n item: newFocusItem,\n }),\n [onItemFocus],\n );\n\n const onItemKeyDown = useCallback(\n (e) => {\n const { keyCode } = e;\n if (!isDragging) {\n if (keyCode !== 9) e.preventDefault(); // allow tab/shift+tab\n if (keyCode === 13 || keyCode === 32) setSelectedItem(item);\n\n if (keyCode === 37) {\n if (isGroup && isExpanded) {\n toggleItemExpand(item, triggerTreeRerender, scrollToIndex);\n setLatestToggledItem(item);\n }\n }\n if (keyCode === 39) {\n if (isGroup && !isExpanded) {\n toggleItemExpand(item, triggerTreeRerender, scrollToIndex);\n setLatestToggledItem(item);\n }\n }\n\n const { virtualIndex } = item;\n const lastItemIndex = visibleItems.length - 1;\n if (keyCode === 38) {\n const isLoopedFocus = virtualIndex === 0;\n const newFocusIndex = isLoopedFocus\n ? lastItemIndex\n : virtualIndex - 1;\n const newFocusItem = visibleItems[newFocusIndex];\n scrollToIndex(newFocusIndex);\n if (isLoopedFocus) {\n // when looping the list from start to end we need to wait a bit before focusing\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n focusItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n }, 300);\n } else {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }\n }\n if (keyCode === 40) {\n const isLoopedFocus = virtualIndex === lastItemIndex;\n const newFocusIndex = isLoopedFocus ? 0 : virtualIndex + 1;\n const newFocusItem = visibleItems[newFocusIndex];\n scrollToIndex(newFocusIndex);\n if (isLoopedFocus) {\n // when looping the list from start to end we need to wait a bit before focusing\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n } else {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }\n }\n if (keyCode === 35) {\n if (virtualIndex !== lastItemIndex) {\n const newFocusItem = visibleItems[lastItemIndex];\n scrollToIndex(lastItemIndex);\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n }\n }\n if (keyCode === 36) {\n if (virtualIndex !== 0) {\n const newFocusItem = visibleItems[0];\n scrollToIndex(0);\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n }\n }\n }\n },\n [\n item,\n visibleItems,\n isGroup,\n isDragging,\n onItemFocusCurry,\n setFocusedItem,\n setSelectedItem,\n ],\n );\n\n return onItemKeyDown;\n};\n\nexport const useGlobalKeyboardListener = (func) => {\n useEffect(() => {\n document.addEventListener('keydown', func);\n return () => document.removeEventListener('keydown', func);\n }, [func]);\n};\n\nexport const useGlobalToggleAllExpandShortcut = (\n treeRoot,\n triggerTreeRerender,\n setLatestToggledItem,\n) => {\n const memoizedToggleAllKeyboardShortcut = useCallback(\n (e) => {\n const { shiftKey, keyCode } = e;\n if (shiftKey && keyCode === 56) {\n toggleExpandAllHelper(\n 'toggle',\n treeRoot,\n triggerTreeRerender,\n setLatestToggledItem,\n );\n }\n },\n [treeRoot, triggerTreeRerender],\n );\n\n return useGlobalKeyboardListener(memoizedToggleAllKeyboardShortcut);\n};\n"],"names":["useOnItemKeyDown","item","ctx","useContext","TreeViewContext","onItemFocus","props","triggerTreeRerender","isDragging","visibleItems","setFocusedItem","setSelectedItem","setLatestToggledItem","scrollToIndex","virtualListHelpers","isGroup","isExpanded","onItemFocusCurry","useCallback","newFocusItem","itemIndex","virtualIndex","scrollToItem","opts","align","onItemKeyDown","e","keyCode","preventDefault","toggleItemExpand","lastItemIndex","length","isLoopedFocus","newFocusIndex","setTimeout","focusItem","useGlobalKeyboardListener","func","useEffect","document","addEventListener","removeEventListener","useGlobalToggleAllExpandShortcut","treeRoot","memoizedToggleAllKeyboardShortcut","shiftKey","toggleExpandAllHelper"],"mappings":";;;;;;;;;;;AAAA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;IAEaA,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,IAAD,EAAU;EACxC,IAAMC,GAAG,GAAGC,gBAAU,CAACC,0BAAD,CAAtB;EACA,IACWC,WADX,GASIH,GATJ,CACEI,KADF,CACWD,WADX;MAEEE,mBAFF,GASIL,GATJ,CAEEK,mBAFF;MAGEC,UAHF,GASIN,GATJ,CAGEM,UAHF;MAIEC,YAJF,GASIP,GATJ,CAIEO,YAJF;MAKEC,cALF,GASIR,GATJ,CAKEQ,cALF;MAMEC,eANF,GASIT,GATJ,CAMES,eANF;MAOEC,oBAPF,GASIV,GATJ,CAOEU,oBAPF;MAQwBC,aARxB,GASIX,GATJ,CAQEY,kBARF,CAQwBD,aARxB;EAUA,IAAQE,OAAR,GAAgCd,IAAhC,CAAQc,OAAR;MAAiBC,UAAjB,GAAgCf,IAAhC,CAAiBe,UAAjB;EACA,IAAMC,gBAAgB,GAAGC,iBAAW,CAClC,UAACC,YAAD;IAAA,OACEd,WAAW,CAAC;MACVe,SAAS,EAAED,YAAY,CAACE,YADd;MAEVC,YAAY,EAAE;QAAA,IAACC,IAAD,uEAAQ;UAAEC,KAAK,EAAE;SAAjB;QAAA,OACZX,aAAa,CAACM,YAAY,CAACE,YAAd,EAA4BE,IAA5B,CADD;OAFJ;MAIVtB,IAAI,EAAEkB;KAJG,CADb;GADkC,EAQlC,CAACd,WAAD,CARkC,CAApC;EAWA,IAAMoB,aAAa,GAAGP,iBAAW,CAC/B,UAACQ,CAAD,EAAO;IACL,IAAQC,OAAR,GAAoBD,CAApB,CAAQC,OAAR;;IACA,IAAI,CAACnB,UAAL,EAAiB;MACf,IAAImB,OAAO,KAAK,CAAhB,EAAmBD,C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AEYW,yBAAyB,GAAG,SAA5BA,yBAA4B,CAACC,IAAD,EAAU;EACjDC,eAAS,CAAC,YAAM;IACdC,QAAQ,CAACC,gBAAT,CAA0B,SAA1B,EAAqCH,IAArC;IACA,OAAO;MAAA,OAAME,QAAQ,CAACE,mBAAT,CAA6B,SAA7B,EAAwCJ,IAAxC,CAAN;KAAP;GAFO,EAGN,CAACA,IAAD,CAHM,CAAT;AAID;IAEYK,gCAAgC,GAAG,SAAnCA,gCAAmC,CAC9CC,QAD8C,EAE9CpC,mBAF8C,EAG9CK,oBAH8C,EAI3C;EACH,IAAMgC,iCAAiC,GAAG1B,iBAAW,CACnD,UAACQ,CAAD,EAAO;IACL,IAAQmB,QAAR,GAA8BnB,CAA9B,CAAQmB,QAAR;QAAkBlB,OAAlB,GAA8BD,CAA9B,CAAkBC,OAAlB;;IACA,IAAIkB,QAAQ,IAAIlB,OAAO,KAAK,EAA5B,EAAgC;MAC9BmB,+CAAqB,CACnB,QADmB,EAEnBH,QAFmB,EAGnBpC,mBAHmB,EAInBK,oBAJmB,CAArB;;GAJ+C,EAYnD,CAAC+B,QAAD,EAAWpC,mBAAX,CAZmD,CAArD;EAeA,OAAO6B,yBAAyB,CAACQ,iCAAD,CAAhC;AACD;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-helpers.js","sources":["../../../src/utils/object-helpers.tsx"],"sourcesContent":["/* eslint-disable no-sequences */\n/* eslint-disable no-return-assign */\n/* eslint-disable no-restricted-syntax */\n/* eslint-disable guard-for-in */\n\nexport const unfreeze = (o) => {\n let oo;\n if (o === null) {\n oo = null;\n } else if (o === undefined) {\n oo = undefined;\n } else if (o.constructor.name === 'Date') {\n oo = new Date(o);\n } else if (o instanceof Array) {\n oo = [];\n o.forEach((v) => {\n oo.push(v);\n });\n } else if (o instanceof String) {\n oo = String(o);\n } else if (typeof o === 'object') {\n oo = {};\n for (const property in o) {\n oo[property] = o[property];\n }\n } else {\n oo = o;\n }\n return oo;\n};\n\nexport const filterObject = (obj, predicate) =>\n Object.keys(obj)\n .filter((key) => predicate(obj[key]))\n .reduce((res, key) => ((res[key] = obj[key]), res), {});\n"],"names":["unfreeze","o","oo","undefined","constructor","name","Date","Array","forEach","v","push","String","_typeof","property","filterObject","obj","predicate","Object","keys","filter","key","reduce","res"],"mappings":";;;;;;;;;;AAAA;;AACA;;AACA;;AACA;IAEaA,QAAQ,GAAG,SAAXA,QAAW,CAACC,CAAD,EAAO;
|
|
1
|
+
{"version":3,"file":"object-helpers.js","sources":["../../../src/utils/object-helpers.tsx"],"sourcesContent":["/* eslint-disable no-sequences */\n/* eslint-disable no-return-assign */\n/* eslint-disable no-restricted-syntax */\n/* eslint-disable guard-for-in */\n\nexport const unfreeze = (o) => {\n let oo;\n if (o === null) {\n oo = null;\n } else if (o === undefined) {\n oo = undefined;\n } else if (o.constructor.name === 'Date') {\n oo = new Date(o);\n } else if (o instanceof Array) {\n oo = [];\n o.forEach((v) => {\n oo.push(v);\n });\n } else if (o instanceof String) {\n oo = String(o);\n } else if (typeof o === 'object') {\n oo = {};\n for (const property in o) {\n oo[property] = o[property];\n }\n } else {\n oo = o;\n }\n return oo;\n};\n\nexport const filterObject = (obj, predicate) =>\n Object.keys(obj)\n .filter((key) => predicate(obj[key]))\n .reduce((res, key) => ((res[key] = obj[key]), res), {});\n"],"names":["unfreeze","o","oo","undefined","constructor","name","Date","Array","forEach","v","push","String","_typeof","property","filterObject","obj","predicate","Object","keys","filter","key","reduce","res"],"mappings":";;;;;;;;;;AAAA;;AACA;;AACA;;AACA;IAEaA,QAAQ,GAAG,SAAXA,QAAW,CAACC,CAAD,EAAO;EAC7B,IAAIC,EAAJ;;EACA,IAAID,CAAC,KAAK,IAAV,EAAgB;IACdC,EAAE,GAAG,IAAL;GADF,MAEO,IAAID,CAAC,KAAKE,SAAV,EAAqB;IAC1BD,EAAE,GAAGC,SAAL;GADK,MAEA,IAAIF,CAAC,CAACG,WAAF,CAAcC,IAAd,KAAuB,MAA3B,EAAmC;IACxCH,EAAE,GAAG,IAAII,IAAJ,CAASL,CAAT,CAAL;GADK,MAEA,IAAIA,CAAC,YAAYM,KAAjB,EAAwB;IAC7BL,EAAE,GAAG,EAAL;IACAD,CAAC,CAACO,OAAF,CAAU,UAACC,CAAD,EAAO;MACfP,EAAE,CAACQ,IAAH,CAAQD,CAAR;KADF;GAFK,MAKA,IAAIR,CAAC,YAAYU,MAAjB,EAAyB;IAC9BT,EAAE,GAAGS,MAAM,CAACV,CAAD,CAAX;GADK,MAEA,IAAIW,4BAAOX,CAAP,MAAa,QAAjB,EAA2B;IAChCC,EAAE,GAAG,EAAL;;IACA,KAAK,IAAMW,QAAX,IAAuBZ,CAAvB,EAA0B;MACxBC,EAAE,CAACW,QAAD,CAAF,GAAeZ,CAAC,CAACY,QAAD,CAAhB;;GAHG,MAKA;IACLX,EAAE,GAAGD,CAAL;;;EAEF,OAAOC,EAAP;AACD;IAEYY,YAAY,GAAG,SAAfA,YAAe,CAACC,GAAD,EAAMC,SAAN;EAAA,OAC1BC,MAAM,CAACC,IAAP,CAAYH,GAAZ,EACGI,MADH,CACU,UAACC,GAAD;IAAA,OAASJ,SAAS,CAACD,GAAG,CAACK,GAAD,CAAJ,CAAlB;GADV,EAEGC,MAFH,CAEU,UAACC,GAAD,EAAMF,GAAN;IAAA,OAAgBE,GAAG,CAACF,GAAD,CAAH,GAAWL,GAAG,CAACK,GAAD,CAAf,EAAuBE,GAAtC;GAFV,EAEsD,EAFtD,CAD0B;AAAA;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refs-helpers.js","sources":["../../../src/utils/refs-helpers.tsx"],"sourcesContent":["// allow multiple refs to be set to point to the same DOM element\nexport const setMultipleRefs = (...refs) => {\n const filteredRefs = refs.filter(Boolean);\n if (!filteredRefs.length) return null;\n if (filteredRefs.length === 0) return filteredRefs[0];\n\n return (newRef) => {\n filteredRefs.forEach((refToBeUpdated) => {\n if (typeof refToBeUpdated === 'function') {\n refToBeUpdated(newRef);\n } else if (refToBeUpdated) {\n refToBeUpdated.current = newRef;\n }\n });\n };\n};\n"],"names":["setMultipleRefs","refs","filteredRefs","filter","Boolean","length","newRef","forEach","refToBeUpdated","current"],"mappings":";;;;AAAA;IACaA,eAAe,GAAG,SAAlBA,eAAkB,GAAa;
|
|
1
|
+
{"version":3,"file":"refs-helpers.js","sources":["../../../src/utils/refs-helpers.tsx"],"sourcesContent":["// allow multiple refs to be set to point to the same DOM element\nexport const setMultipleRefs = (...refs) => {\n const filteredRefs = refs.filter(Boolean);\n if (!filteredRefs.length) return null;\n if (filteredRefs.length === 0) return filteredRefs[0];\n\n return (newRef) => {\n filteredRefs.forEach((refToBeUpdated) => {\n if (typeof refToBeUpdated === 'function') {\n refToBeUpdated(newRef);\n } else if (refToBeUpdated) {\n refToBeUpdated.current = newRef;\n }\n });\n };\n};\n"],"names":["setMultipleRefs","refs","filteredRefs","filter","Boolean","length","newRef","forEach","refToBeUpdated","current"],"mappings":";;;;AAAA;IACaA,eAAe,GAAG,SAAlBA,eAAkB,GAAa;EAAA,kCAATC,IAAS;IAATA,IAAS;;;EAC1C,IAAMC,YAAY,GAAGD,IAAI,CAACE,MAAL,CAAYC,OAAZ,CAArB;EACA,IAAI,CAACF,YAAY,CAACG,MAAlB,EAA0B,OAAO,IAAP;EAC1B,IAAIH,YAAY,CAACG,MAAb,KAAwB,CAA5B,EAA+B,OAAOH,YAAY,CAAC,CAAD,CAAnB;EAE/B,OAAO,UAACI,MAAD,EAAY;IACjBJ,YAAY,CAACK,OAAb,CAAqB,UAACC,cAAD,EAAoB;MACvC,IAAI,OAAOA,cAAP,KAA0B,UAA9B,EAA0C;QACxCA,cAAc,CAACF,MAAD,CAAd;OADF,MAEO,IAAIE,cAAJ,EAAoB;QACzBA,cAAc,CAACC,OAAf,GAAyBH,MAAzB;;KAJJ;GADF;AASD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectable-helper.js","sources":["../../../src/utils/selectable-helper.tsx"],"sourcesContent":["/* eslint-disable max-params */\nimport { walkParents, walkAllNodeChildren } from './tree-helpers';\n\nexport const getGroupCheckState = (node) => {\n let childAllChecked = true;\n let anyChildChecked = false;\n walkAllNodeChildren(node, (childNode) => {\n const {\n model: { isChecked },\n } = childNode;\n if (isChecked === 'mixed' || isChecked === true) anyChildChecked = true;\n else childAllChecked = false;\n });\n\n if (childAllChecked) return true;\n if (anyChildChecked) return 'mixed';\n return false;\n};\n\nexport const selectCheckboxItemModelParentsTillRoot = (\n modelToCheck,\n triggerTreeRerender = null,\n) => {\n const newSelections = {};\n const { nodePath } = modelToCheck;\n walkParents(nodePath, (parentNode) => {\n const nextState = getGroupCheckState(parentNode);\n parentNode.model.isChecked = nextState;\n newSelections[parentNode.model.id] = nextState;\n });\n if (triggerTreeRerender) triggerTreeRerender();\n return newSelections;\n};\n\nexport const toggleCheckboxItem = (\n itemToSelect,\n triggerTreeRerender = null,\n) => {\n const {\n node: {\n model: { id, isChecked, children = [] },\n },\n } = itemToSelect;\n\n const newSelections = {};\n // 'mixed' -> true -> false -> true [...->false -> true]\n const nextState = isChecked === 'mixed' ? true : !isChecked;\n itemToSelect.node.model.isChecked = nextState;\n newSelections[id] = nextState;\n\n if (children.length > 0 && (nextState === true || nextState === false)) {\n walkAllNodeChildren(itemToSelect.node, (childNode) => {\n childNode.model.isChecked = nextState;\n newSelections[childNode.model.id] = nextState;\n });\n }\n\n const parentsNewSelections = selectCheckboxItemModelParentsTillRoot(\n itemToSelect,\n );\n\n if (triggerTreeRerender) triggerTreeRerender();\n return { ...parentsNewSelections, ...newSelections };\n};\n"],"names":["getGroupCheckState","node","childAllChecked","anyChildChecked","walkAllNodeChildren","childNode","isChecked","model","selectCheckboxItemModelParentsTillRoot","modelToCheck","triggerTreeRerender","newSelections","nodePath","walkParents","parentNode","nextState","id","toggleCheckboxItem","itemToSelect","children","length","parentsNewSelections"],"mappings":";;;;;;;;;;;;;;;;;IAGaA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,IAAD,EAAU;
|
|
1
|
+
{"version":3,"file":"selectable-helper.js","sources":["../../../src/utils/selectable-helper.tsx"],"sourcesContent":["/* eslint-disable max-params */\nimport { walkParents, walkAllNodeChildren } from './tree-helpers';\n\nexport const getGroupCheckState = (node) => {\n let childAllChecked = true;\n let anyChildChecked = false;\n walkAllNodeChildren(node, (childNode) => {\n const {\n model: { isChecked },\n } = childNode;\n if (isChecked === 'mixed' || isChecked === true) anyChildChecked = true;\n else childAllChecked = false;\n });\n\n if (childAllChecked) return true;\n if (anyChildChecked) return 'mixed';\n return false;\n};\n\nexport const selectCheckboxItemModelParentsTillRoot = (\n modelToCheck,\n triggerTreeRerender = null,\n) => {\n const newSelections = {};\n const { nodePath } = modelToCheck;\n walkParents(nodePath, (parentNode) => {\n const nextState = getGroupCheckState(parentNode);\n parentNode.model.isChecked = nextState;\n newSelections[parentNode.model.id] = nextState;\n });\n if (triggerTreeRerender) triggerTreeRerender();\n return newSelections;\n};\n\nexport const toggleCheckboxItem = (\n itemToSelect,\n triggerTreeRerender = null,\n) => {\n const {\n node: {\n model: { id, isChecked, children = [] },\n },\n } = itemToSelect;\n\n const newSelections = {};\n // 'mixed' -> true -> false -> true [...->false -> true]\n const nextState = isChecked === 'mixed' ? true : !isChecked;\n itemToSelect.node.model.isChecked = nextState;\n newSelections[id] = nextState;\n\n if (children.length > 0 && (nextState === true || nextState === false)) {\n walkAllNodeChildren(itemToSelect.node, (childNode) => {\n childNode.model.isChecked = nextState;\n newSelections[childNode.model.id] = nextState;\n });\n }\n\n const parentsNewSelections = selectCheckboxItemModelParentsTillRoot(\n itemToSelect,\n );\n\n if (triggerTreeRerender) triggerTreeRerender();\n return { ...parentsNewSelections, ...newSelections };\n};\n"],"names":["getGroupCheckState","node","childAllChecked","anyChildChecked","walkAllNodeChildren","childNode","isChecked","model","selectCheckboxItemModelParentsTillRoot","modelToCheck","triggerTreeRerender","newSelections","nodePath","walkParents","parentNode","nextState","id","toggleCheckboxItem","itemToSelect","children","length","parentsNewSelections"],"mappings":";;;;;;;;;;;;;;;;;IAGaA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,IAAD,EAAU;EAC1C,IAAIC,eAAe,GAAG,IAAtB;EACA,IAAIC,eAAe,GAAG,KAAtB;EACAC,qCAAmB,CAACH,IAAD,EAAO,UAACI,SAAD,EAAe;IACvC,IACWC,SADX,GAEID,SAFJ,CACEE,KADF,CACWD,SADX;IAGA,IAAIA,SAAS,KAAK,OAAd,IAAyBA,SAAS,KAAK,IAA3C,EAAiDH,eAAe,GAAG,IAAlB,CAAjD,KACKD,eAAe,GAAG,KAAlB;GALY,CAAnB;EAQA,IAAIA,eAAJ,EAAqB,OAAO,IAAP;EACrB,IAAIC,eAAJ,EAAqB,OAAO,OAAP;EACrB,OAAO,KAAP;AACD;IAEYK,sCAAsC,GAAG,SAAzCA,sCAAyC,CACpDC,YADoD,EAGjD;EAAA,IADHC,mBACG,uEADmB,IACnB;EACH,IAAMC,aAAa,GAAG,EAAtB;EACA,IAAQC,QAAR,GAAqBH,YAArB,CAAQG,QAAR;EACAC,6BAAW,CAACD,QAAD,EAAW,UAACE,UAAD,EAAgB;IACpC,IAAMC,SAAS,GAAGf,kBAAkB,CAACc,UAAD,CAApC;IACAA,UAAU,CAACP,KAAX,CAAiBD,SAAjB,GAA6BS,SAA7B;IACAJ,aAAa,CAACG,UAAU,CAACP,KAAX,CAAiBS,EAAlB,CAAb,GAAqCD,SAArC;GAHS,CAAX;EAKA,IAAIL,mBAAJ,EAAyBA,mBAAmB;EAC5C,OAAOC,aAAP;AACD;IAEYM,kBAAkB,GAAG,SAArBA,kBAAqB,CAChCC,YADgC,EAG7B;EAAA,IADHR,mBACG,uEADmB,IACnB;EACH,4BAIIQ,YAJJ,CACEjB,IADF,CAEIM,KAFJ;MAEaS,EAFb,yBAEaA,EAFb;MAEiBV,SAFjB,yBAEiBA,SAFjB;qDAE4Ba,QAF5B;MAE4BA,QAF5B,uCAEuC,EAFvC;EAMA,IAAMR,aAAa,GAAG,EAAtB,CAPG;;EASH,IAAMI,SAAS,GAAGT,SAAS,KAAK,OAAd,GAAwB,IAAxB,GAA+B,CAACA,SAAlD;EACAY,YAAY,CAACjB,IAAb,CAAkBM,KAAlB,CAAwBD,SAAxB,GAAoCS,SAApC;EACAJ,aAAa,CAACK,EAAD,CAAb,GAAoBD,SAApB;;EAEA,IAAII,QAAQ,CAACC,MAAT,GAAkB,CAAlB,KAAwBL,SAAS,KAAK,IAAd,IAAsBA,SAAS,KAAK,KAA5D,CAAJ,EAAwE;IACtEX,qCAAmB,CAACc,YAAY,CAACjB,IAAd,EAAoB,UAACI,SAAD,EAAe;MACpDA,SAAS,CAACE,KAAV,CAAgBD,SAAhB,GAA4BS,SAA5B;MACAJ,aAAa,CAACN,SAAS,CAACE,KAAV,CAAgBS,EAAjB,CAAb,GAAoCD,SAApC;KAFiB,CAAnB;;;EAMF,IAAMM,oBAAoB,GAAGb,sCAAsC,CACjEU,YADiE,CAAnE;EAIA,IAAIR,mBAAJ,EAAyBA,mBAAmB;EAC5C,uCAAYW,oBAAZ,GAAqCV,aAArC;AACD;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-helpers.js","sources":["../../../src/utils/string-helpers.tsx"],"sourcesContent":["export const standardizeSearchQueryString = (input) =>\n input.trim().toLowerCase();\n"],"names":["standardizeSearchQueryString","input","trim","toLowerCase"],"mappings":";;;;IAAaA,4BAA4B,GAAG,SAA/BA,4BAA+B,CAACC,KAAD;
|
|
1
|
+
{"version":3,"file":"string-helpers.js","sources":["../../../src/utils/string-helpers.tsx"],"sourcesContent":["export const standardizeSearchQueryString = (input) =>\n input.trim().toLowerCase();\n"],"names":["standardizeSearchQueryString","input","trim","toLowerCase"],"mappings":";;;;IAAaA,4BAA4B,GAAG,SAA/BA,4BAA+B,CAACC,KAAD;EAAA,OAC1CA,KAAK,CAACC,IAAN,GAAaC,WAAb,EAD0C;AAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-helpers.js","sources":["../../../src/utils/tree-helpers.tsx"],"sourcesContent":["/* eslint-disable max-params */\n/* eslint-disable complexity */\n/* eslint-disable max-lines */\nimport { createRef } from 'react';\nimport { standardizeSearchQueryString } from './string-helpers';\n\nexport const walkVisibles = (\n node,\n callback,\n skipRoot = true,\n highlightOnlyQuery = false,\n) => {\n const { children, model } = node;\n const {\n name,\n isExpanded,\n childrenMatchesSearchQuery,\n matchesSearchQuery,\n } = model;\n\n const shouldSkipBecauseIsRoot = skipRoot && name === '__root';\n const queryRestrictionsPassed =\n highlightOnlyQuery || childrenMatchesSearchQuery || matchesSearchQuery;\n\n if (!shouldSkipBecauseIsRoot && queryRestrictionsPassed) callback(node);\n\n const shouldWalkChildren =\n children.length && isExpanded && queryRestrictionsPassed;\n if (shouldWalkChildren) {\n children.forEach((childNode) => {\n walkVisibles(childNode, callback, skipRoot, highlightOnlyQuery);\n });\n }\n};\n\nexport const walkParents = (nodePath, callback, skipRoot = true) => {\n const parents = [...nodePath].reverse();\n parents.shift(); // remove current node from the parents array\n if (skipRoot) parents.pop(); // remove the root from the parents if skipping root\n parents.forEach(callback);\n};\n\nexport const walkAllNodeChildren = (node, callback, isFirst = true) => {\n const { children = [] } = node;\n const shouldWalkChildren = children.length;\n\n if (!isFirst) callback(node);\n\n if (shouldWalkChildren) {\n children.forEach((childNode) => {\n walkAllNodeChildren(childNode, callback, false);\n });\n }\n};\n\nexport const getNodeById = (treeRoot, id) => {\n const nodes = treeRoot.all((node) => node.model.id === id);\n return nodes[0];\n};\n\nexport const cloneNode = (tree, node) => tree.parse(node.model);\n\nexport const getItemsParentNode = (items = [], skipSameParentCheck = false) => {\n if (items.length === 0)\n throw new Error(\"Received empty items, can't retrieve parent\");\n\n // in case we already know the items compared shares the same parent\n if (!skipSameParentCheck)\n if (!itemsShareSameParent(items))\n // if we don't know (default, we don't) check if they share the parent\n throw new Error(\n \"Received items don't share the same parent, can't retrieve parent\",\n );\n\n // when moving in first position we receive [undefined,...{items}]\n // when moving in last position we receive [...{items}, undefined]\n const firstExistingItem = items.find((item) => !!item);\n if (!firstExistingItem)\n throw new Error(\"Received no items, can't retrieve parent\");\n\n const firstExistingItemPath = firstExistingItem.node.getPath();\n // path is like [rootParent, ...[parentsNodes], currentNode]\n // length -1 is the current-node\n // length -2 is the parent-node\n // root node is not printed and is always present so minimum path length is 2 (root + currentNode)\n const directParentNode =\n firstExistingItemPath[firstExistingItemPath.length - 2];\n return directParentNode;\n};\n\nexport const itemsShareSameParent = (items = []) => {\n if (items.length === 0)\n throw new Error('Received empty items for comparison');\n if (items.length === 1) return true;\n\n // when moving in first position we receive [undefined,...{items}]\n // when moving in last position we receive [...{items}, undefined]\n const firstExistingItem = items.find((item) => !!item);\n if (!firstExistingItem)\n throw new Error(\"Received no items, can't retrieve parent\");\n\n const firstExistingItemPath = firstExistingItem.node.getPath();\n // path is like [rootParent, ...[parentsNodes], currentNode]\n // length -1 is the current-node\n // length -2 is the parent-node\n // root node is not printed and is always present so minimum path length is 2 (root + currentNode)\n const directParentNode =\n firstExistingItemPath[firstExistingItemPath.length - 2];\n\n return items.every((item) => {\n // undefined nodes count as having the same parent\n if (!item) return true;\n const itemPath = item.node.getPath();\n const itemDirectParent = itemPath[itemPath.length - 2];\n return directParentNode === itemDirectParent;\n });\n};\n\nexport const getNodeMatchesSearchQuery = (node, searchQuery = '') => {\n const standardizedName = standardizeSearchQueryString(node.model.name);\n const standardizedSearchQuery = standardizeSearchQueryString(searchQuery);\n return standardizedName.includes(standardizedSearchQuery);\n};\n\nexport const getChildrenMatchesSearchQuery = (parentNode, searchQuery = '') => {\n let anyChildMatch = false;\n walkAllNodeChildren(parentNode, (node) => {\n if (getNodeMatchesSearchQuery(node, searchQuery)) anyChildMatch = true;\n });\n return anyChildMatch;\n};\n\nexport const enrichNodeModelInPlace = (\n node,\n searchQuery = '',\n selection = null,\n) => {\n const path = node.getPath();\n const depth = path.length - 1;\n node.model.nodePath = path;\n node.model.treeDepth = depth;\n\n if (!node.model.nodeItemRef) {\n node.model.nodeItemRef = createRef();\n }\n\n // if a node has children but was not marked as isGroup, force-mark as group\n // this is useful to avoid having to always check both the flag and the children.length...\n if (\n typeof node.model.isGroup !== 'boolean' &&\n node.model?.children?.length > 0\n ) {\n node.model.isGroup = true;\n }\n\n if (typeof node.model.isExpanded !== 'boolean') {\n node.model.isExpanded = false;\n }\n\n node.model.matchesSearchQuery = true;\n node.model.childrenMatchesSearchQuery = false;\n if (searchQuery) {\n node.model.matchesSearchQuery = getNodeMatchesSearchQuery(\n node,\n searchQuery,\n );\n\n if (node.model.isGroup === true) {\n node.model.childrenMatchesSearchQuery = getChildrenMatchesSearchQuery(\n node,\n searchQuery,\n );\n if (node.model.childrenMatchesSearchQuery) node.model.isExpanded = true;\n }\n }\n if (selection && selection[node.model.id]) {\n node.model.isChecked = selection[node.model.id];\n }\n};\n\nexport const focusItem = (item) => {\n item?.nodeItemRef?.current?.focus();\n};\n"],"names":["walkVisibles","node","callback","skipRoot","highlightOnlyQuery","children","model","name","isExpanded","childrenMatchesSearchQuery","matchesSearchQuery","shouldSkipBecauseIsRoot","queryRestrictionsPassed","shouldWalkChildren","length","forEach","childNode","walkParents","nodePath","parents","_toConsumableArray","reverse","shift","pop","walkAllNodeChildren","isFirst","getNodeById","treeRoot","id","nodes","all","cloneNode","tree","parse","getItemsParentNode","items","skipSameParentCheck","Error","itemsShareSameParent","firstExistingItem","find","item","firstExistingItemPath","getPath","directParentNode","every","itemPath","itemDirectParent","getNodeMatchesSearchQuery","searchQuery","standardizedName","standardizeSearchQueryString","standardizedSearchQuery","includes","getChildrenMatchesSearchQuery","parentNode","anyChildMatch","enrichNodeModelInPlace","selection","path","depth","treeDepth","nodeItemRef","createRef","isGroup","isChecked","focusItem","current","focus"],"mappings":";;;;;;;;;;;;IAMaA,YAAY,GAAG,SAAfA,YAAe,CAC1BC,IAD0B,EAE1BC,QA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file":"tree-helpers.js","sources":["../../../src/utils/tree-helpers.tsx"],"sourcesContent":["/* eslint-disable max-params */\n/* eslint-disable complexity */\n/* eslint-disable max-lines */\nimport { createRef } from 'react';\nimport { standardizeSearchQueryString } from './string-helpers';\n\nexport const walkVisibles = (\n node,\n callback,\n skipRoot = true,\n highlightOnlyQuery = false,\n) => {\n const { children, model } = node;\n const {\n name,\n isExpanded,\n childrenMatchesSearchQuery,\n matchesSearchQuery,\n } = model;\n\n const shouldSkipBecauseIsRoot = skipRoot && name === '__root';\n const queryRestrictionsPassed =\n highlightOnlyQuery || childrenMatchesSearchQuery || matchesSearchQuery;\n\n if (!shouldSkipBecauseIsRoot && queryRestrictionsPassed) callback(node);\n\n const shouldWalkChildren =\n children.length && isExpanded && queryRestrictionsPassed;\n if (shouldWalkChildren) {\n children.forEach((childNode) => {\n walkVisibles(childNode, callback, skipRoot, highlightOnlyQuery);\n });\n }\n};\n\nexport const walkParents = (nodePath, callback, skipRoot = true) => {\n const parents = [...nodePath].reverse();\n parents.shift(); // remove current node from the parents array\n if (skipRoot) parents.pop(); // remove the root from the parents if skipping root\n parents.forEach(callback);\n};\n\nexport const walkAllNodeChildren = (node, callback, isFirst = true) => {\n const { children = [] } = node;\n const shouldWalkChildren = children.length;\n\n if (!isFirst) callback(node);\n\n if (shouldWalkChildren) {\n children.forEach((childNode) => {\n walkAllNodeChildren(childNode, callback, false);\n });\n }\n};\n\nexport const getNodeById = (treeRoot, id) => {\n const nodes = treeRoot.all((node) => node.model.id === id);\n return nodes[0];\n};\n\nexport const cloneNode = (tree, node) => tree.parse(node.model);\n\nexport const getItemsParentNode = (items = [], skipSameParentCheck = false) => {\n if (items.length === 0)\n throw new Error(\"Received empty items, can't retrieve parent\");\n\n // in case we already know the items compared shares the same parent\n if (!skipSameParentCheck)\n if (!itemsShareSameParent(items))\n // if we don't know (default, we don't) check if they share the parent\n throw new Error(\n \"Received items don't share the same parent, can't retrieve parent\",\n );\n\n // when moving in first position we receive [undefined,...{items}]\n // when moving in last position we receive [...{items}, undefined]\n const firstExistingItem = items.find((item) => !!item);\n if (!firstExistingItem)\n throw new Error(\"Received no items, can't retrieve parent\");\n\n const firstExistingItemPath = firstExistingItem.node.getPath();\n // path is like [rootParent, ...[parentsNodes], currentNode]\n // length -1 is the current-node\n // length -2 is the parent-node\n // root node is not printed and is always present so minimum path length is 2 (root + currentNode)\n const directParentNode =\n firstExistingItemPath[firstExistingItemPath.length - 2];\n return directParentNode;\n};\n\nexport const itemsShareSameParent = (items = []) => {\n if (items.length === 0)\n throw new Error('Received empty items for comparison');\n if (items.length === 1) return true;\n\n // when moving in first position we receive [undefined,...{items}]\n // when moving in last position we receive [...{items}, undefined]\n const firstExistingItem = items.find((item) => !!item);\n if (!firstExistingItem)\n throw new Error(\"Received no items, can't retrieve parent\");\n\n const firstExistingItemPath = firstExistingItem.node.getPath();\n // path is like [rootParent, ...[parentsNodes], currentNode]\n // length -1 is the current-node\n // length -2 is the parent-node\n // root node is not printed and is always present so minimum path length is 2 (root + currentNode)\n const directParentNode =\n firstExistingItemPath[firstExistingItemPath.length - 2];\n\n return items.every((item) => {\n // undefined nodes count as having the same parent\n if (!item) return true;\n const itemPath = item.node.getPath();\n const itemDirectParent = itemPath[itemPath.length - 2];\n return directParentNode === itemDirectParent;\n });\n};\n\nexport const getNodeMatchesSearchQuery = (node, searchQuery = '') => {\n const standardizedName = standardizeSearchQueryString(node.model.name);\n const standardizedSearchQuery = standardizeSearchQueryString(searchQuery);\n return standardizedName.includes(standardizedSearchQuery);\n};\n\nexport const getChildrenMatchesSearchQuery = (parentNode, searchQuery = '') => {\n let anyChildMatch = false;\n walkAllNodeChildren(parentNode, (node) => {\n if (getNodeMatchesSearchQuery(node, searchQuery)) anyChildMatch = true;\n });\n return anyChildMatch;\n};\n\nexport const enrichNodeModelInPlace = (\n node,\n searchQuery = '',\n selection = null,\n) => {\n const path = node.getPath();\n const depth = path.length - 1;\n node.model.nodePath = path;\n node.model.treeDepth = depth;\n\n if (!node.model.nodeItemRef) {\n node.model.nodeItemRef = createRef();\n }\n\n // if a node has children but was not marked as isGroup, force-mark as group\n // this is useful to avoid having to always check both the flag and the children.length...\n if (\n typeof node.model.isGroup !== 'boolean' &&\n node.model?.children?.length > 0\n ) {\n node.model.isGroup = true;\n }\n\n if (typeof node.model.isExpanded !== 'boolean') {\n node.model.isExpanded = false;\n }\n\n node.model.matchesSearchQuery = true;\n node.model.childrenMatchesSearchQuery = false;\n if (searchQuery) {\n node.model.matchesSearchQuery = getNodeMatchesSearchQuery(\n node,\n searchQuery,\n );\n\n if (node.model.isGroup === true) {\n node.model.childrenMatchesSearchQuery = getChildrenMatchesSearchQuery(\n node,\n searchQuery,\n );\n if (node.model.childrenMatchesSearchQuery) node.model.isExpanded = true;\n }\n }\n if (selection && selection[node.model.id]) {\n node.model.isChecked = selection[node.model.id];\n }\n};\n\nexport const focusItem = (item) => {\n item?.nodeItemRef?.current?.focus();\n};\n"],"names":["walkVisibles","node","callback","skipRoot","highlightOnlyQuery","children","model","name","isExpanded","childrenMatchesSearchQuery","matchesSearchQuery","shouldSkipBecauseIsRoot","queryRestrictionsPassed","shouldWalkChildren","length","forEach","childNode","walkParents","nodePath","parents","_toConsumableArray","reverse","shift","pop","walkAllNodeChildren","isFirst","getNodeById","treeRoot","id","nodes","all","cloneNode","tree","parse","getItemsParentNode","items","skipSameParentCheck","Error","itemsShareSameParent","firstExistingItem","find","item","firstExistingItemPath","getPath","directParentNode","every","itemPath","itemDirectParent","getNodeMatchesSearchQuery","searchQuery","standardizedName","standardizeSearchQueryString","standardizedSearchQuery","includes","getChildrenMatchesSearchQuery","parentNode","anyChildMatch","enrichNodeModelInPlace","selection","path","depth","treeDepth","nodeItemRef","createRef","isGroup","isChecked","focusItem","current","focus"],"mappings":";;;;;;;;;;;;IAMaA,YAAY,GAAG,SAAfA,YAAe,CAC1BC,IAD0B,EAE1BC,QAF0B,EAKvB;EAAA,IAFHC,QAEG,uEAFQ,IAER;EAAA,IADHC,k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EAGFP,IAAI,CAACK,KAAL,CAAWI,kBAAX,GAAgC,IAAhC;EACAT,IAAI,CAACK,KAAL,CAAWG,0BAAX,GAAwC,KAAxC;;EACA,IAAIwC,WAAJ,EAAiB;IACfhD,IAAI,CAACK,KAAL,CAAWI,kBAAX,GAAgCsC,yBAAyB,CACvD/C,IADuD,EAEvDgD,WAFuD,CAAzD;;IAKA,IAAIhD,IAAI,CAACK,KAAL,CAAW0D,OAAX,KAAuB,IAA3B,EAAiC;MAC/B/D,IAAI,CAACK,KAAL,CAAWG,0BAAX,GAAwC6C,6BAA6B,CACnErD,IADmE,EAEnEgD,WAFmE,CAArE;MAIA,IAAIhD,IAAI,CAACK,KAAL,CAAWG,0BAAf,EAA2CR,IAAI,CAACK,KAAL,CAAWE,UAAX,GAAwB,IAAxB;;;;EAG/C,IAAIkD,SAAS,IAAIA,SAAS,CAACzD,IAAI,CAACK,KAAL,CAAWsB,EAAZ,CAA1B,EAA2C;IACzC3B,IAAI,CAACK,KAAL,CAAW2D,SAAX,GAAuBP,SAAS,CAACzD,IAAI,CAACK,KAAL,CAAWsB,EAAZ,CAAhC;;AAEH;IAEYsC,SAAS,GAAG,SAAZA,SAAY,CAACzB,IAAD,EAAU;EAAA;;EACjCA,IAAI,SAAJ,IAAAA,IAAI,WAAJ,iCAAAA,IAAI,CAAEqB,WAAN,iGAAmBK,OAAnB,gFAA4BC,KAA5B;AACD;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDnDHelpers.js","sources":["../../../src/utils/useDnDHelpers.tsx"],"sourcesContent":["/* eslint-disable max-depth */\n/* eslint-disable no-lonely-if */\n/* eslint-disable max-lines */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { useContext, useCallback } from 'react';\nimport { cloneDeep } from 'lodash';\n\nimport TreeViewContext, { defaultRelativeMouseCoord } from '../TreeViewContext';\nimport { getNodeById, focusItem } from './tree-helpers';\nimport { inferHoverItemKinshipDrop, inferKeyboardKinshipDrop, isDropValid } from './dnd-helpers';\n\nexport const useDnDHelpers = () => {\n const ctx = useContext(TreeViewContext);\n\n const {\n props: { data, onOrderChange, restrictDragAndDrop },\n relativeMouseCord,\n setRelativeMouseCord,\n visibleItems,\n isDragging,\n setIsDragging,\n isKeyboardDragging,\n setIsKeyboardDragging,\n setDraggedItem,\n setFocusedItem,\n triggerTreeRerender,\n tree,\n treeRoot,\n draggedItem,\n } = ctx;\n\n const onSortEnd = useCallback(\n ({ oldIndex, newIndex, isKeySorting }) => {\n let newItems = cloneDeep(data);\n const { isBefore, isAfter, item: overItem, isValid } = relativeMouseCord;\n // if dropping in same position do nothing\n // if the drop is not allowed do nothing\n if (oldIndex === newIndex || !isValid) {\n // onOrderChange(newItems, data);\n setIsDragging(false);\n setDraggedItem(null);\n triggerTreeRerender();\n return;\n }\n\n // if we are moving from topToBottom the offset changes\n const movementDirection = newIndex > oldIndex ? 'topToBottom' : 'bottomToTop';\n\n let newNestedIndex;\n let newParentNode;\n if (isKeySorting) {\n const kinship = inferKeyboardKinshipDrop({\n items: visibleItems,\n\n newIndex,\n movementDirection,\n });\n newNestedIndex = kinship.newNestedIndex;\n newParentNode = kinship.newParentNode;\n } else {\n const kinship = inferHoverItemKinshipDrop({\n isBefore,\n isAfter,\n overItem,\n movementDirection,\n draggedItem,\n });\n newNestedIndex = kinship.newNestedIndex;\n newParentNode = kinship.newParentNode;\n }\n\n const newMovedItemNode = tree.parse(draggedItem.node.model);\n getNodeById(treeRoot, draggedItem.id).drop();\n newParentNode.addChildAtIndex(newMovedItemNode, newNestedIndex);\n\n if (newParentNode.isRoot()) {\n newItems = [...newParentNode.model.children];\n } else {\n newItems = [...treeRoot.model.children];\n }\n\n onOrderChange(newItems, data, draggedItem);\n setIsDragging(false);\n setDraggedItem(null);\n triggerTreeRerender();\n },\n [\n data,\n draggedItem,\n relativeMouseCord,\n visibleItems,\n tree,\n treeRoot,\n onOrderChange,\n triggerTreeRerender,\n setIsDragging,\n setDraggedItem,\n setRelativeMouseCord,\n ],\n );\n\n const onSortStart = useCallback(\n () => {},\n // ({ node, index, collection, isKeySorting }, event) => {\n // console.log('node :>> ', node);\n // console.log('isKeySorting :>> ', isKeySorting);\n // console.log('event :>> ', event);\n // const item = collection?.[index] || visibleItems[index];\n // setIsDragging(true);\n // setDraggedItem(item);\n // },\n [],\n );\n\n const updateBeforeSortStart = useCallback(\n (beforeStartArgs) =>\n new Promise((resolve) => {\n const { index, collection, isKeySorting } = beforeStartArgs;\n const item = collection?.[index] || visibleItems[index];\n const { isExpanded } = item.node.model;\n if (isExpanded) {\n item.node.model.isExpanded = false;\n triggerTreeRerender();\n }\n setRelativeMouseCord(defaultRelativeMouseCoord);\n setIsKeyboardDragging(isKeySorting);\n setIsDragging(true);\n setDraggedItem(item);\n focusItem(null);\n setFocusedItem(null);\n document.activeElement.blur();\n resolve();\n }),\n [visibleItems, isKeyboardDragging, setFocusedItem, setIsKeyboardDragging, setRelativeMouseCord],\n );\n\n // tracks mouse coords relative to an element to check if the drop happens\n // at the top/center/bottom of an element to choose where to move the element\n // requested in the specs\n const onMouseDragOverItem = useCallback(\n ({ event, item, itemIndex, setIsDraggingOverThis, openFolderOnHoverTimeout }) => {\n const { node } = item;\n const { nodeItemRef } = node.model;\n if (isDragging && !isKeyboardDragging) {\n const rect = nodeItemRef.current.getBoundingClientRect();\n const x = event.clientX - rect.left; // x position within the element.\n const y = event.clientY - rect.top; // y position within the element.\n\n // by spec we need to track where the drop will happens\n // if drop happens on top 25% drop before\n // if drop happens on bottom of 25% drop after\n // if drop happens in the middle 50% either invalid or drop into children\n const { height: elementHeight } = rect;\n const dropBeforeMaxY = elementHeight * 0.25;\n const dropAfterMinY = elementHeight - elementHeight * 0.25;\n const isBefore = y < dropBeforeMaxY;\n const isAfter = y > dropAfterMinY;\n const isInside = !isBefore && !isAfter;\n const isValid = isDropValid({\n isBefore,\n isAfter,\n draggedItem,\n overItem: item,\n restrictDragAndDrop,\n });\n setRelativeMouseCord({\n isBefore,\n isAfter,\n isInside,\n isValid,\n item,\n x,\n y,\n relativeElementDOMRect: rect,\n relativeElementIndex: itemIndex,\n });\n setIsDraggingOverThis(true);\n\n if (\n !openFolderOnHoverTimeout?.current && // only set the interval if it wasn't set already once\n draggedItem?.id !== item?.id && // don't open ghost element\n (item.isGroup || item.children.length > 0) && // only open groups\n !restrictDragAndDrop\n ) {\n openFolderOnHoverTimeout.current = setTimeout(() => {\n item.node.model.isExpanded = true;\n openFolderOnHoverTimeout.current = null;\n triggerTreeRerender();\n }, 1000);\n }\n } else {\n setRelativeMouseCord(defaultRelativeMouseCoord);\n }\n },\n [isDragging, setRelativeMouseCord, draggedItem, restrictDragAndDrop, isKeyboardDragging],\n );\n\n return {\n updateBeforeSortStart,\n onSortStart,\n onSortEnd,\n onMouseDragOverItem,\n };\n};\n"],"names":["useDnDHelpers","ctx","useContext","TreeViewContext","props","data","onOrderChange","restrictDragAndDrop","relativeMouseCord","setRelativeMouseCord","visibleItems","isDragging","setIsDragging","isKeyboardDragging","setIsKeyboardDragging","setDraggedItem","setFocusedItem","triggerTreeRerender","tree","treeRoot","draggedItem","onSortEnd","useCallback","oldIndex","newIndex","isKeySorting","newItems","cloneDeep","isBefore","isAfter","overItem","item","isValid","movementDirection","newNestedIndex","newParentNode","kinship","inferKeyboardKinshipDrop","items","inferHoverItemKinshipDrop","newMovedItemNode","parse","node","model","getNodeById","id","drop","addChildAtIndex","isRoot","children","onSortStart","updateBeforeSortStart","beforeStartArgs","Promise","resolve","index","collection","isExpanded","defaultRelativeMouseCoord","focusItem","document","activeElement","blur","onMouseDragOverItem","event","itemIndex","setIsDraggingOverThis","openFolderOnHoverTimeout","nodeItemRef","rect","current","getBoundingClientRect","x","clientX","left","y","clientY","top","elementHeight","height","dropBeforeMaxY","dropAfterMinY","isInside","isDropValid","relativeElementDOMRect","relativeElementIndex","isGroup","length","setTimeout"],"mappings":";;;;;;;;;;;;;;;;IAYaA,aAAa,GAAG,SAAhBA,aAAg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,UAAU,CAAC,YAAM;AAClDzD,UAAAA,IAAI,CAACW,IAAL,CAAUC,KAAV,CAAgBc,UAAhB,GAA6B,IAA7B;AACAU,UAAAA,wBAAwB,CAACG,OAAzB,GAAmC,IAAnC;AACArD,UAAAA,mBAAmB;AACpB,SAJ4C,EAI1C,IAJ0C,CAA7C;AAKD;AACF,KA/CD,MA+CO;AACLR,MAAAA,oBAAoB,CAACiD,yCAAD,CAApB;AACD;AACF,GAtDoC,EAuDrC,CAAC/C,UAAD,EAAaF,oBAAb,EAAmCW,WAAnC,EAAgDb,mBAAhD,EAAqEM,kBAArE,CAvDqC,CAAvC;AA0DA,SAAO;AACLsC,IAAAA,qBAAqB,EAArBA,qBADK;AAELD,IAAAA,WAAW,EAAXA,WAFK;AAGL7B,IAAAA,SAAS,EAATA,SAHK;AAIL0C,IAAAA,mBAAmB,EAAnBA;AAJK,GAAP;AAMD;;;;"}
|
|
1
|
+
{"version":3,"file":"useDnDHelpers.js","sources":["../../../src/utils/useDnDHelpers.tsx"],"sourcesContent":["/* eslint-disable max-depth */\n/* eslint-disable no-lonely-if */\n/* eslint-disable max-lines */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { useContext, useCallback } from 'react';\nimport { cloneDeep } from 'lodash';\n\nimport TreeViewContext, { defaultRelativeMouseCoord } from '../TreeViewContext';\nimport { getNodeById, focusItem } from './tree-helpers';\nimport { inferHoverItemKinshipDrop, inferKeyboardKinshipDrop, isDropValid } from './dnd-helpers';\n\nexport const useDnDHelpers = () => {\n const ctx = useContext(TreeViewContext);\n\n const {\n props: { data, onOrderChange, restrictDragAndDrop },\n relativeMouseCord,\n setRelativeMouseCord,\n visibleItems,\n isDragging,\n setIsDragging,\n isKeyboardDragging,\n setIsKeyboardDragging,\n setDraggedItem,\n setFocusedItem,\n triggerTreeRerender,\n tree,\n treeRoot,\n draggedItem,\n } = ctx;\n\n const onSortEnd = useCallback(\n ({ oldIndex, newIndex, isKeySorting }) => {\n let newItems = cloneDeep(data);\n const { isBefore, isAfter, item: overItem, isValid } = relativeMouseCord;\n // if dropping in same position do nothing\n // if the drop is not allowed do nothing\n if (oldIndex === newIndex || !isValid) {\n // onOrderChange(newItems, data);\n setIsDragging(false);\n setDraggedItem(null);\n triggerTreeRerender();\n return;\n }\n\n // if we are moving from topToBottom the offset changes\n const movementDirection = newIndex > oldIndex ? 'topToBottom' : 'bottomToTop';\n\n let newNestedIndex;\n let newParentNode;\n if (isKeySorting) {\n const kinship = inferKeyboardKinshipDrop({\n items: visibleItems,\n\n newIndex,\n movementDirection,\n });\n newNestedIndex = kinship.newNestedIndex;\n newParentNode = kinship.newParentNode;\n } else {\n const kinship = inferHoverItemKinshipDrop({\n isBefore,\n isAfter,\n overItem,\n movementDirection,\n draggedItem,\n });\n newNestedIndex = kinship.newNestedIndex;\n newParentNode = kinship.newParentNode;\n }\n\n const newMovedItemNode = tree.parse(draggedItem.node.model);\n getNodeById(treeRoot, draggedItem.id).drop();\n newParentNode.addChildAtIndex(newMovedItemNode, newNestedIndex);\n\n if (newParentNode.isRoot()) {\n newItems = [...newParentNode.model.children];\n } else {\n newItems = [...treeRoot.model.children];\n }\n\n onOrderChange(newItems, data, draggedItem);\n setIsDragging(false);\n setDraggedItem(null);\n triggerTreeRerender();\n },\n [\n data,\n draggedItem,\n relativeMouseCord,\n visibleItems,\n tree,\n treeRoot,\n onOrderChange,\n triggerTreeRerender,\n setIsDragging,\n setDraggedItem,\n setRelativeMouseCord,\n ],\n );\n\n const onSortStart = useCallback(\n () => {},\n // ({ node, index, collection, isKeySorting }, event) => {\n // console.log('node :>> ', node);\n // console.log('isKeySorting :>> ', isKeySorting);\n // console.log('event :>> ', event);\n // const item = collection?.[index] || visibleItems[index];\n // setIsDragging(true);\n // setDraggedItem(item);\n // },\n [],\n );\n\n const updateBeforeSortStart = useCallback(\n (beforeStartArgs) =>\n new Promise((resolve) => {\n const { index, collection, isKeySorting } = beforeStartArgs;\n const item = collection?.[index] || visibleItems[index];\n const { isExpanded } = item.node.model;\n if (isExpanded) {\n item.node.model.isExpanded = false;\n triggerTreeRerender();\n }\n setRelativeMouseCord(defaultRelativeMouseCoord);\n setIsKeyboardDragging(isKeySorting);\n setIsDragging(true);\n setDraggedItem(item);\n focusItem(null);\n setFocusedItem(null);\n document.activeElement.blur();\n resolve();\n }),\n [visibleItems, isKeyboardDragging, setFocusedItem, setIsKeyboardDragging, setRelativeMouseCord],\n );\n\n // tracks mouse coords relative to an element to check if the drop happens\n // at the top/center/bottom of an element to choose where to move the element\n // requested in the specs\n const onMouseDragOverItem = useCallback(\n ({ event, item, itemIndex, setIsDraggingOverThis, openFolderOnHoverTimeout }) => {\n const { node } = item;\n const { nodeItemRef } = node.model;\n if (isDragging && !isKeyboardDragging) {\n const rect = nodeItemRef.current.getBoundingClientRect();\n const x = event.clientX - rect.left; // x position within the element.\n const y = event.clientY - rect.top; // y position within the element.\n\n // by spec we need to track where the drop will happens\n // if drop happens on top 25% drop before\n // if drop happens on bottom of 25% drop after\n // if drop happens in the middle 50% either invalid or drop into children\n const { height: elementHeight } = rect;\n const dropBeforeMaxY = elementHeight * 0.25;\n const dropAfterMinY = elementHeight - elementHeight * 0.25;\n const isBefore = y < dropBeforeMaxY;\n const isAfter = y > dropAfterMinY;\n const isInside = !isBefore && !isAfter;\n const isValid = isDropValid({\n isBefore,\n isAfter,\n draggedItem,\n overItem: item,\n restrictDragAndDrop,\n });\n setRelativeMouseCord({\n isBefore,\n isAfter,\n isInside,\n isValid,\n item,\n x,\n y,\n relativeElementDOMRect: rect,\n relativeElementIndex: itemIndex,\n });\n setIsDraggingOverThis(true);\n\n if (\n !openFolderOnHoverTimeout?.current && // only set the interval if it wasn't set already once\n draggedItem?.id !== item?.id && // don't open ghost element\n (item.isGroup || item.children.length > 0) && // only open groups\n !restrictDragAndDrop\n ) {\n openFolderOnHoverTimeout.current = setTimeout(() => {\n item.node.model.isExpanded = true;\n openFolderOnHoverTimeout.current = null;\n triggerTreeRerender();\n }, 1000);\n }\n } else {\n setRelativeMouseCord(defaultRelativeMouseCoord);\n }\n },\n [isDragging, setRelativeMouseCord, draggedItem, restrictDragAndDrop, isKeyboardDragging],\n );\n\n return {\n updateBeforeSortStart,\n onSortStart,\n onSortEnd,\n onMouseDragOverItem,\n };\n};\n"],"names":["useDnDHelpers","ctx","useContext","TreeViewContext","props","data","onOrderChange","restrictDragAndDrop","relativeMouseCord","setRelativeMouseCord","visibleItems","isDragging","setIsDragging","isKeyboardDragging","setIsKeyboardDragging","setDraggedItem","setFocusedItem","triggerTreeRerender","tree","treeRoot","draggedItem","onSortEnd","useCallback","oldIndex","newIndex","isKeySorting","newItems","cloneDeep","isBefore","isAfter","overItem","item","isValid","movementDirection","newNestedIndex","newParentNode","kinship","inferKeyboardKinshipDrop","items","inferHoverItemKinshipDrop","newMovedItemNode","parse","node","model","getNodeById","id","drop","addChildAtIndex","isRoot","children","onSortStart","updateBeforeSortStart","beforeStartArgs","Promise","resolve","index","collection","isExpanded","defaultRelativeMouseCoord","focusItem","document","activeElement","blur","onMouseDragOverItem","event","itemIndex","setIsDraggingOverThis","openFolderOnHoverTimeout","nodeItemRef","rect","current","getBoundingClientRect","x","clientX","left","y","clientY","top","elementHeight","height","dropBeforeMaxY","dropAfterMinY","isInside","isDropValid","relativeElementDOMRect","relativeElementIndex","isGroup","length","setTimeout"],"mappings":";;;;;;;;;;;;;;;;IAYaA,aAAa,GAAG,SAAhBA,aAAgB,GAAM;EACjC,IAAMC,GAAG,GAAGC,gBAAU,CAACC,0BAAD,CAAtB;EAEA,iBAeIF,GAfJ,CACEG,KADF;MACWC,IADX,cACWA,IADX;MACiBC,aADjB,cACiBA,aADjB;MACgCC,mBADhC,cACgCA,mBADhC;MAEEC,iBAFF,GAeIP,GAfJ,CAEEO,iBAFF;MAGEC,oBAHF,GAeIR,GAfJ,CAGEQ,oBAHF;MAIEC,YAJF,GAeIT,GAfJ,CAIES,YAJF;MAKEC,UALF,GAeIV,GAfJ,CAKEU,UALF;MAMEC,aANF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AAW,CAAEyB,EAAb,OAAoBd,IAApB,aAAoBA,IAApB,uBAAoBA,IAAI,CAAEc,EAA1B,CADA;MAECd,IAAI,CAACuD,OAAL,IAAgBvD,IAAI,CAACkB,QAAL,CAAcsC,MAAd,GAAuB,CAFxC;MAGA,CAAChF,mBAJH,EAKE;QACA4D,wBAAwB,CAACG,OAAzB,GAAmCkB,UAAU,CAAC,YAAM;UAClDzD,IAAI,CAACW,IAAL,CAAUC,KAAV,CAAgBc,UAAhB,GAA6B,IAA7B;UACAU,wBAAwB,CAACG,OAAzB,GAAmC,IAAnC;UACArD,mBAAmB;SAHwB,EAI1C,IAJ0C,CAA7C;;KAzCJ,MA+CO;MACLR,oBAAoB,CAACiD,yCAAD,CAApB;;GApDiC,EAuDrC,CAAC/C,UAAD,EAAaF,oBAAb,EAAmCW,WAAnC,EAAgDb,mBAAhD,EAAqEM,kBAArE,CAvDqC,CAAvC;EA0DA,OAAO;IACLsC,qBAAqB,EAArBA,qBADK;IAELD,WAAW,EAAXA,WAFK;IAGL7B,SAAS,EAATA,SAHK;IAIL0C,mBAAmB,EAAnBA;GAJF;AAMD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInstanceRefActions.js","sources":["../../../src/utils/useInstanceRefActions.tsx"],"sourcesContent":["import { useEffect, useMemo, useState, useRef, useCallback } from 'react';\nimport { focusItem } from './tree-helpers';\nimport { toggleExpandAllHelper } from './group-expands-helpers';\n\nexport const useInstanceRefActions = ({ actions }, ctx) => {\n const {\n props: { onItemFocus },\n virtualListHelpers,\n treeRoot,\n visibleItems,\n triggerTreeRerender,\n setSelectedItem,\n setFocusedItem,\n setLatestToggledItem,\n } = ctx;\n const { current: promises } = useRef({});\n const { scrollToIndex } = useMemo(() => virtualListHelpers, [virtualListHelpers]);\n const [expandPromise, setPromise] = useState();\n\n useEffect(() => {\n if (expandPromise && promises.expandResolve) {\n promises.expandResolve(visibleItems);\n promises.expandResolve = null;\n setPromise(null);\n }\n }, [visibleItems, expandPromise, promises]);\n\n actions.toggleExpandAll = useCallback(\n (isExpand) => {\n const p = new Promise((resolve) => {\n promises.expandResolve = resolve;\n toggleExpandAllHelper(isExpand, treeRoot, triggerTreeRerender, setLatestToggledItem);\n });\n setPromise(p);\n return p;\n },\n [promises, treeRoot, triggerTreeRerender, setLatestToggledItem],\n );\n actions.scrollTo = useCallback(\n (indx, opts = { align: 'start' }) => {\n if (scrollToIndex) scrollToIndex(indx, opts);\n },\n [scrollToIndex],\n );\n\n actions.setSelectedItemByVirtualIndex = useCallback(\n (index) => {\n const itemByIndex = visibleItems[index];\n setSelectedItem(itemByIndex);\n },\n [visibleItems, setSelectedItem],\n );\n\n actions.setFocusedItemByVirtualIndex = useCallback(\n (index, opts = { align: 'start', withScroll: false }) => {\n const itemByIndex = visibleItems[index];\n const onItemFocusParams = {\n itemIndex: itemByIndex.virtualIndex,\n scrollToItem: () => scrollToIndex(index, opts),\n item: itemByIndex,\n };\n\n if (opts.withScroll && scrollToIndex) {\n scrollToIndex(index, opts);\n setTimeout(() => {\n setFocusedItem(itemByIndex);\n focusItem(itemByIndex);\n onItemFocus(onItemFocusParams);\n }, 300);\n } else {\n setFocusedItem(itemByIndex);\n focusItem(itemByIndex);\n onItemFocus(onItemFocusParams);\n }\n },\n [visibleItems, scrollToIndex, setFocusedItem, onItemFocus],\n );\n\n return actions;\n};\n"],"names":["useInstanceRefActions","ctx","actions","onItemFocus","props","virtualListHelpers","treeRoot","visibleItems","triggerTreeRerender","setSelectedItem","setFocusedItem","setLatestToggledItem","useRef","promises","current","useMemo","scrollToIndex","useState","expandPromise","setPromise","useEffect","expandResolve","toggleExpandAll","useCallback","isExpand","p","Promise","resolve","toggleExpandAllHelper","scrollTo","indx","opts","align","setSelectedItemByVirtualIndex","index","itemByIndex","setFocusedItemByVirtualIndex","withScroll","onItemFocusParams","itemIndex","virtualIndex","scrollToItem","item","setTimeout","focusItem"],"mappings":";;;;;;;;;;;;;;;IAIaA,qBAAqB,GAAG,SAAxBA,qBAAwB,OAAcC,GAAd,EAAsB;
|
|
1
|
+
{"version":3,"file":"useInstanceRefActions.js","sources":["../../../src/utils/useInstanceRefActions.tsx"],"sourcesContent":["import { useEffect, useMemo, useState, useRef, useCallback } from 'react';\nimport { focusItem } from './tree-helpers';\nimport { toggleExpandAllHelper } from './group-expands-helpers';\n\nexport const useInstanceRefActions = ({ actions }, ctx) => {\n const {\n props: { onItemFocus },\n virtualListHelpers,\n treeRoot,\n visibleItems,\n triggerTreeRerender,\n setSelectedItem,\n setFocusedItem,\n setLatestToggledItem,\n } = ctx;\n const { current: promises } = useRef({});\n const { scrollToIndex } = useMemo(() => virtualListHelpers, [virtualListHelpers]);\n const [expandPromise, setPromise] = useState();\n\n useEffect(() => {\n if (expandPromise && promises.expandResolve) {\n promises.expandResolve(visibleItems);\n promises.expandResolve = null;\n setPromise(null);\n }\n }, [visibleItems, expandPromise, promises]);\n\n actions.toggleExpandAll = useCallback(\n (isExpand) => {\n const p = new Promise((resolve) => {\n promises.expandResolve = resolve;\n toggleExpandAllHelper(isExpand, treeRoot, triggerTreeRerender, setLatestToggledItem);\n });\n setPromise(p);\n return p;\n },\n [promises, treeRoot, triggerTreeRerender, setLatestToggledItem],\n );\n actions.scrollTo = useCallback(\n (indx, opts = { align: 'start' }) => {\n if (scrollToIndex) scrollToIndex(indx, opts);\n },\n [scrollToIndex],\n );\n\n actions.setSelectedItemByVirtualIndex = useCallback(\n (index) => {\n const itemByIndex = visibleItems[index];\n setSelectedItem(itemByIndex);\n },\n [visibleItems, setSelectedItem],\n );\n\n actions.setFocusedItemByVirtualIndex = useCallback(\n (index, opts = { align: 'start', withScroll: false }) => {\n const itemByIndex = visibleItems[index];\n const onItemFocusParams = {\n itemIndex: itemByIndex.virtualIndex,\n scrollToItem: () => scrollToIndex(index, opts),\n item: itemByIndex,\n };\n\n if (opts.withScroll && scrollToIndex) {\n scrollToIndex(index, opts);\n setTimeout(() => {\n setFocusedItem(itemByIndex);\n focusItem(itemByIndex);\n onItemFocus(onItemFocusParams);\n }, 300);\n } else {\n setFocusedItem(itemByIndex);\n focusItem(itemByIndex);\n onItemFocus(onItemFocusParams);\n }\n },\n [visibleItems, scrollToIndex, setFocusedItem, onItemFocus],\n );\n\n return actions;\n};\n"],"names":["useInstanceRefActions","ctx","actions","onItemFocus","props","virtualListHelpers","treeRoot","visibleItems","triggerTreeRerender","setSelectedItem","setFocusedItem","setLatestToggledItem","useRef","promises","current","useMemo","scrollToIndex","useState","expandPromise","setPromise","useEffect","expandResolve","toggleExpandAll","useCallback","isExpand","p","Promise","resolve","toggleExpandAllHelper","scrollTo","indx","opts","align","setSelectedItemByVirtualIndex","index","itemByIndex","setFocusedItemByVirtualIndex","withScroll","onItemFocusParams","itemIndex","virtualIndex","scrollToItem","item","setTimeout","focusItem"],"mappings":";;;;;;;;;;;;;;;IAIaA,qBAAqB,GAAG,SAAxBA,qBAAwB,OAAcC,GAAd,EAAsB;EAAA,IAAnBC,OAAmB,QAAnBA,OAAmB;EACzD,IACWC,WADX,GASIF,GATJ,CACEG,KADF,CACWD,WADX;MAEEE,kBAFF,GASIJ,GATJ,CAEEI,kBAFF;MAGEC,QAHF,GASIL,GATJ,CAGEK,QAHF;MAIEC,YAJF,GASIN,GATJ,CAIEM,YAJF;MAKEC,mBALF,GASIP,GATJ,CAKEO,mBALF;MAMEC,eANF,GASIR,GATJ,CAMEQ,eANF;MAOEC,cAPF,GASIT,GATJ,CAOES,cAPF;MAQEC,oBARF,GASIV,GATJ,CAQEU,oBARF;;EAUA,cAA8BC,YAAM,CAAC,EAAD,CAApC;MAAiBC,QAAjB,WAAQC,OAAR;;EACA,eAA0BC,aAAO,CAAC;IAAA,OAAMV,kBAAN;GAAD,EAA2B,CAACA,kBAAD,CAA3B,CAAjC;MAAQW,aAAR,YAAQA,aAAR;;EACA,gBAAoCC,cAAQ,EAA5C;;MAAOC,aAAP;MAAsBC,UAAtB;;EAEAC,eAAS,CAAC,YAAM;IACd,IAAIF,aAA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AAW,GAAG5B,YAAY,CAAC2B,KAAD,CAAhC;IACA,IAAMI,iBAAiB,GAAG;MACxBC,SAAS,EAAEJ,WAAW,CAACK,YADC;MAExBC,YAAY,EAAE;QAAA,OAAMzB,aAAa,CAACkB,KAAD,EAAQH,IAAR,CAAnB;OAFU;MAGxBW,IAAI,EAAEP;KAHR;;IAMA,IAAIJ,IAAI,CAACM,UAAL,IAAmBrB,aAAvB,EAAsC;MACpCA,aAAa,CAACkB,KAAD,EAAQH,IAAR,CAAb;MACAY,UAAU,CAAC,YAAM;QACfjC,cAAc,CAACyB,WAAD,CAAd;QACAS,2BAAS,CAACT,WAAD,CAAT;QACAhC,WAAW,CAACmC,iBAAD,CAAX;OAHQ,EAIP,GAJO,CAAV;KAFF,MAOO;MACL5B,cAAc,CAACyB,WAAD,CAAd;MACAS,2BAAS,CAACT,WAAD,CAAT;MACAhC,WAAW,CAACmC,iBAAD,CAAX;;GAnB4C,EAsBhD,CAAC/B,YAAD,EAAeS,aAAf,EAA8BN,cAA9B,EAA8CP,WAA9C,CAtBgD,CAAlD;EAyBA,OAAOD,OAAP;AACD;;;;"}
|
package/cjs/utils/useTree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTree.js","sources":["../../../src/utils/useTree.tsx"],"sourcesContent":["import { useState, useCallback, useMemo, useEffect } from 'react';\nimport TreeModel from 'tree-model';\nimport { cloneDeep } from 'lodash';\n\nimport { walkVisibles, enrichNodeModelInPlace } from './tree-helpers';\n\nexport const useTree = (data, props, states) => {\n const { setExpandedGroups } = states;\n const unfrozenData = useMemo(() => cloneDeep(data), [data]);\n // convert data into a TreeModel with extra isExpanded prop\n const tree = useMemo(() => new TreeModel(), []);\n const [treeData, setTreeData] = useState({\n name: '__root',\n isExpanded: true,\n children: unfrozenData,\n });\n\n useEffect(() => {\n setTreeData({\n name: '__root',\n isExpanded: true,\n children: unfrozenData,\n });\n }, [unfrozenData]);\n\n // expose a way to rerender the tree\n // used for expand functionality\n const [rerenderItems, setRerenderItems] = useState({});\n const triggerTreeRerender = useCallback(() => {\n setRerenderItems({});\n }, []);\n\n // when re-rendering we re-parse the list\n const [treeRoot, setTreeRoot] = useState(tree.parse(treeData));\n useEffect(() => {\n setTreeRoot(tree.parse(treeData));\n }, [treeData, rerenderItems]);\n\n const [visibleItems, setVisibleItems] = useState([]);\n\n const {\n searchQuery,\n highlightOnlyQuery,\n onVisibleItemsChange,\n selection,\n } = props;\n\n useEffect(() => {\n const parsedVisibleItems = [];\n const newExpandedHashMap = {};\n treeRoot.walk((node) => {\n enrichNodeModelInPlace(node, searchQuery, selection);\n if (node.model.id && node.model.isGroup && node.model.isExpanded)\n newExpandedHashMap[node.model.id] = true;\n });\n\n walkVisibles(\n treeRoot,\n (node) => {\n parsedVisibleItems.push({ ...node.model, node });\n },\n true,\n highlightOnlyQuery,\n );\n setVisibleItems(parsedVisibleItems);\n onVisibleItemsChange(parsedVisibleItems);\n\n setExpandedGroups(newExpandedHashMap);\n }, [treeRoot, rerenderItems, searchQuery]);\n\n return {\n visibleItems,\n tree,\n treeRoot,\n rerenderItems,\n triggerTreeRerender,\n };\n};\n"],"names":["useTree","data","props","states","setExpandedGroups","unfrozenData","useMemo","cloneDeep","tree","TreeModel","useState","name","isExpanded","children","treeData","setTreeData","useEffect","rerenderItems","setRerenderItems","triggerTreeRerender","useCallback","parse","treeRoot","setTreeRoot","visibleItems","setVisibleItems","searchQuery","highlightOnlyQuery","onVisibleItemsChange","selection","parsedVisibleItems","newExpandedHashMap","walk","node","enrichNodeModelInPlace","model","id","isGroup","walkVisibles","push"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAMaA,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAOC,KAAP,EAAcC,MAAd,EAAyB;
|
|
1
|
+
{"version":3,"file":"useTree.js","sources":["../../../src/utils/useTree.tsx"],"sourcesContent":["import { useState, useCallback, useMemo, useEffect } from 'react';\nimport TreeModel from 'tree-model';\nimport { cloneDeep } from 'lodash';\n\nimport { walkVisibles, enrichNodeModelInPlace } from './tree-helpers';\n\nexport const useTree = (data, props, states) => {\n const { setExpandedGroups } = states;\n const unfrozenData = useMemo(() => cloneDeep(data), [data]);\n // convert data into a TreeModel with extra isExpanded prop\n const tree = useMemo(() => new TreeModel(), []);\n const [treeData, setTreeData] = useState({\n name: '__root',\n isExpanded: true,\n children: unfrozenData,\n });\n\n useEffect(() => {\n setTreeData({\n name: '__root',\n isExpanded: true,\n children: unfrozenData,\n });\n }, [unfrozenData]);\n\n // expose a way to rerender the tree\n // used for expand functionality\n const [rerenderItems, setRerenderItems] = useState({});\n const triggerTreeRerender = useCallback(() => {\n setRerenderItems({});\n }, []);\n\n // when re-rendering we re-parse the list\n const [treeRoot, setTreeRoot] = useState(tree.parse(treeData));\n useEffect(() => {\n setTreeRoot(tree.parse(treeData));\n }, [treeData, rerenderItems]);\n\n const [visibleItems, setVisibleItems] = useState([]);\n\n const {\n searchQuery,\n highlightOnlyQuery,\n onVisibleItemsChange,\n selection,\n } = props;\n\n useEffect(() => {\n const parsedVisibleItems = [];\n const newExpandedHashMap = {};\n treeRoot.walk((node) => {\n enrichNodeModelInPlace(node, searchQuery, selection);\n if (node.model.id && node.model.isGroup && node.model.isExpanded)\n newExpandedHashMap[node.model.id] = true;\n });\n\n walkVisibles(\n treeRoot,\n (node) => {\n parsedVisibleItems.push({ ...node.model, node });\n },\n true,\n highlightOnlyQuery,\n );\n setVisibleItems(parsedVisibleItems);\n onVisibleItemsChange(parsedVisibleItems);\n\n setExpandedGroups(newExpandedHashMap);\n }, [treeRoot, rerenderItems, searchQuery]);\n\n return {\n visibleItems,\n tree,\n treeRoot,\n rerenderItems,\n triggerTreeRerender,\n };\n};\n"],"names":["useTree","data","props","states","setExpandedGroups","unfrozenData","useMemo","cloneDeep","tree","TreeModel","useState","name","isExpanded","children","treeData","setTreeData","useEffect","rerenderItems","setRerenderItems","triggerTreeRerender","useCallback","parse","treeRoot","setTreeRoot","visibleItems","setVisibleItems","searchQuery","highlightOnlyQuery","onVisibleItemsChange","selection","parsedVisibleItems","newExpandedHashMap","walk","node","enrichNodeModelInPlace","model","id","isGroup","walkVisibles","push"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAMaA,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAOC,KAAP,EAAcC,MAAd,EAAyB;EAC9C,IAAQC,iBAAR,GAA8BD,MAA9B,CAAQC,iBAAR;EACA,IAAMC,YAAY,GAAGC,aAAO,CAAC;IAAA,OAAMC,gBAAS,CAACN,IAAD,CAAf;GAAD,EAAwB,CAACA,IAAD,CAAxB,CAA5B,CAF8C;;EAI9C,IAAMO,IAAI,GAAGF,aAAO,CAAC;IAAA,OAAM,IAAIG,6BAAJ,EAAN;GAAD,EAAwB,EAAxB,CAApB;;EACA,gBAAgCC,cAAQ,CAAC;IACvCC,IAAI,EAAE,QADiC;IAEvCC,UAAU,EAAE,IAF2B;IAGvCC,QAAQ,EAAER;GAH4B,CAAxC;;MAAOS,QAAP;MAAiBC,WAAjB;;EAMAC,eAAS,CAAC,YAAM;IACdD,WAAW,CAAC;MACVJ,IAAI,EAAE,QADI;MAEVC,UAAU,EAAE,IAFF;MAGVC,QAAQ,EAAER;KAHD,CAAX;GADO,EAMN,CAACA,YAAD,CANM,CAAT,CAX8C;;;EAqB9C,iBAA0CK,cAAQ,CAAC,EAAD,CAAlD;;MAAOO,aAAP;MAAsBC,gBAAtB;;EACA,IAAMC,mBAAmB,GAAGC,iBAAW,CAAC,YAAM;IAC5CF,gBAAgB,CAAC,EAAD,CAAhB;GADqC,EAEpC,EAFoC,CAAvC,CAtB8C;;EA2B9C,iBAAgCR,cAAQ,CAACF,IAAI,CAACa,KAAL,CAAWP,QAAX,CAAD,CAAxC;;MAAOQ,QAAP;MAAiBC,WAAjB;;EACAP,eAAS,CAAC,YAAM;IACdO,WAAW,CAACf,IAAI,CAACa,KAAL,CAAWP,QAAX,CAAD,CAAX;GADO,EAEN,CAACA,QAAD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
|
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","propTypes","TreeViewPropTypes","defaultProps","TreeViewWithSchema","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,SAASA,QAAT,CAAkBC,KAAlB,EAAyB;
|
|
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","propTypes","TreeViewPropTypes","defaultProps","TreeViewWithSchema","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,SAASA,QAAT,CAAkBC,KAAlB,EAAyB;EAC9B,IAAMC,OAAO,GAAGC,MAAM,CAAC;IAAEC,OAAO,EAAE;GAAZ,CAAtB;EACA,IAAQC,IAAR,GAAgGJ,KAAhG,CAAQI,IAAR;MAAcC,OAAd,GAAgGL,KAAhG,CAAcK,OAAd;MAAuBC,aAAvB,GAAgGN,KAAhG,CAAuBM,aAAvB;MAAsCC,aAAtC,GAAgGP,KAAhG,CAAsCO,aAAtC;MAAqDC,cAArD,GAAgGR,KAAhG,CAAqDQ,cAArD;MAAqEC,WAArE,GAAgGT,KAAhG,CAAqES,WAArE;MAAkFC,SAAlF,GAAgGV,KAAhG,CAAkFU,SAAlF;;EACA,gBAAoCC,QAAQ,CAAC,KAAD,CAA5C;;M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