@elliemae/ds-treeview 2.2.1 → 2.3.0-alpha.4
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 +47 -31
- package/cjs/TreeView.js.map +7 -0
- package/cjs/TreeViewContext.js +55 -43
- package/cjs/TreeViewContext.js.map +7 -0
- package/cjs/config/cssClassesConstants.js +41 -13
- package/cjs/config/cssClassesConstants.js.map +7 -0
- package/cjs/config/useTreeview.js +102 -88
- package/cjs/config/useTreeview.js.map +7 -0
- package/cjs/hoc/DnDTreeContext.js +45 -0
- package/cjs/hoc/DnDTreeContext.js.map +7 -0
- package/cjs/hoc/SortableItemContext.js +46 -0
- package/cjs/hoc/SortableItemContext.js.map +7 -0
- package/cjs/hoc/WithConditionalDnDContext.js +128 -0
- package/cjs/hoc/WithConditionalDnDContext.js.map +7 -0
- package/cjs/hoc/WithDnDSortableItemContext.js +69 -0
- package/cjs/hoc/WithDnDSortableItemContext.js.map +7 -0
- package/cjs/index.js +37 -27
- package/cjs/index.js.map +7 -0
- package/cjs/parts/CheckboxSelectable.js +70 -59
- package/cjs/parts/CheckboxSelectable.js.map +7 -0
- package/cjs/parts/ChildrenCountDisplayer.js +45 -28
- package/cjs/parts/ChildrenCountDisplayer.js.map +7 -0
- package/cjs/parts/DnDHandle.js +57 -0
- package/cjs/parts/DnDHandle.js.map +7 -0
- package/cjs/parts/DropIndicator.js +80 -0
- package/cjs/parts/DropIndicator.js.map +7 -0
- package/cjs/parts/ExpandCaret.js +85 -83
- package/cjs/parts/ExpandCaret.js.map +7 -0
- package/cjs/parts/Icon.js +46 -31
- package/cjs/parts/Icon.js.map +7 -0
- package/cjs/parts/NestingSpace.js +43 -35
- package/cjs/parts/NestingSpace.js.map +7 -0
- package/cjs/parts/RadioSelectable.js +52 -37
- package/cjs/parts/RadioSelectable.js.map +7 -0
- package/cjs/parts/TreeItem.js +121 -165
- package/cjs/parts/TreeItem.js.map +7 -0
- package/cjs/parts/TreeItemText.js +88 -95
- package/cjs/parts/TreeItemText.js.map +7 -0
- package/cjs/parts/TreeList.js +114 -132
- package/cjs/parts/TreeList.js.map +7 -0
- package/cjs/plugins/dnd/TreeDndPlugin.js +34 -43
- package/cjs/plugins/dnd/TreeDndPlugin.js.map +7 -0
- package/cjs/plugins/dnd/index.js +28 -10
- package/cjs/plugins/dnd/index.js.map +7 -0
- package/cjs/plugins/index.js +34 -22
- package/cjs/plugins/index.js.map +7 -0
- package/cjs/plugins/roving/TreeRovingPlugin.js +35 -7
- package/cjs/plugins/roving/TreeRovingPlugin.js.map +7 -0
- package/cjs/plugins/roving/index.js +28 -9
- package/cjs/plugins/roving/index.js.map +7 -0
- package/cjs/plugins/searchable/SearchableTreePlugin.js +35 -7
- package/cjs/plugins/searchable/SearchableTreePlugin.js.map +7 -0
- package/cjs/plugins/searchable/index.js +28 -9
- package/cjs/plugins/searchable/index.js.map +7 -0
- package/cjs/plugins/selectable/SelectablePluginTree.js +35 -7
- package/cjs/plugins/selectable/SelectablePluginTree.js.map +7 -0
- package/cjs/plugins/selectable/index.js +28 -9
- package/cjs/plugins/selectable/index.js.map +7 -0
- package/cjs/plugins/toolbar/TreeToolbarPlugin.js +35 -7
- package/cjs/plugins/toolbar/TreeToolbarPlugin.js.map +7 -0
- package/cjs/plugins/toolbar/index.js +28 -9
- package/cjs/plugins/toolbar/index.js.map +7 -0
- package/cjs/plugins/tree/TreeDataPlugin.js +35 -7
- package/cjs/plugins/tree/TreeDataPlugin.js.map +7 -0
- package/cjs/plugins/tree/index.js +28 -9
- package/cjs/plugins/tree/index.js.map +7 -0
- package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +35 -7
- package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js.map +7 -0
- package/cjs/plugins/virtualization/index.js +28 -9
- package/cjs/plugins/virtualization/index.js.map +7 -0
- package/cjs/react-desc-prop-types.js +83 -53
- package/cjs/react-desc-prop-types.js.map +7 -0
- package/cjs/related-components/TreeViewSearchBar.js +42 -40
- package/cjs/related-components/TreeViewSearchBar.js.map +7 -0
- package/cjs/sharedTypes.js +27 -2
- package/cjs/sharedTypes.js.map +7 -0
- package/cjs/utils/array-helpers.js +35 -11
- package/cjs/utils/array-helpers.js.map +7 -0
- package/cjs/utils/group-expands-helpers.js +86 -59
- package/cjs/utils/group-expands-helpers.js.map +7 -0
- package/cjs/utils/keyboard-helpers.js +86 -90
- package/cjs/utils/keyboard-helpers.js.map +7 -0
- package/cjs/utils/object-helpers.js +43 -36
- package/cjs/utils/object-helpers.js.map +7 -0
- package/cjs/utils/refs-helpers.js +43 -22
- package/cjs/utils/refs-helpers.js.map +7 -0
- package/cjs/utils/selectable-helper.js +61 -53
- package/cjs/utils/selectable-helper.js.map +7 -0
- package/cjs/utils/string-helpers.js +35 -7
- package/cjs/utils/string-helpers.js.map +7 -0
- package/cjs/utils/tree-helpers.js +125 -135
- package/cjs/utils/tree-helpers.js.map +7 -0
- package/cjs/utils/useInstanceRefActions.js +54 -43
- package/cjs/utils/useInstanceRefActions.js.map +7 -0
- package/cjs/utils/useTree.js +78 -78
- package/cjs/utils/useTree.js.map +7 -0
- package/esm/TreeView.js +16 -20
- package/esm/TreeView.js.map +7 -0
- package/esm/TreeViewContext.js +26 -37
- package/esm/TreeViewContext.js.map +7 -0
- package/esm/config/cssClassesConstants.js +12 -6
- package/esm/config/cssClassesConstants.js.map +7 -0
- package/esm/config/useTreeview.js +59 -66
- package/esm/config/useTreeview.js.map +7 -0
- package/esm/hoc/DnDTreeContext.js +16 -0
- package/esm/hoc/DnDTreeContext.js.map +7 -0
- package/esm/hoc/SortableItemContext.js +17 -0
- package/esm/hoc/SortableItemContext.js.map +7 -0
- package/esm/hoc/WithConditionalDnDContext.js +99 -0
- package/esm/hoc/WithConditionalDnDContext.js.map +7 -0
- package/esm/hoc/WithDnDSortableItemContext.js +40 -0
- package/esm/hoc/WithDnDSortableItemContext.js.map +7 -0
- package/esm/index.js +8 -9
- package/esm/index.js.map +7 -0
- package/esm/parts/CheckboxSelectable.js +36 -46
- package/esm/parts/CheckboxSelectable.js.map +7 -0
- package/esm/parts/ChildrenCountDisplayer.js +16 -20
- package/esm/parts/ChildrenCountDisplayer.js.map +7 -0
- package/esm/parts/DnDHandle.js +28 -0
- package/esm/parts/DnDHandle.js.map +7 -0
- package/esm/parts/DropIndicator.js +51 -0
- package/esm/parts/DropIndicator.js.map +7 -0
- package/esm/parts/ExpandCaret.js +54 -72
- package/esm/parts/ExpandCaret.js.map +7 -0
- package/esm/parts/Icon.js +16 -22
- package/esm/parts/Icon.js.map +7 -0
- package/esm/parts/NestingSpace.js +14 -27
- package/esm/parts/NestingSpace.js.map +7 -0
- package/esm/parts/RadioSelectable.js +20 -28
- package/esm/parts/RadioSelectable.js.map +7 -0
- package/esm/parts/TreeItem.js +89 -150
- package/esm/parts/TreeItem.js.map +7 -0
- package/esm/parts/TreeItemText.js +58 -85
- package/esm/parts/TreeItemText.js.map +7 -0
- package/esm/parts/TreeList.js +86 -120
- package/esm/parts/TreeList.js.map +7 -0
- package/esm/plugins/dnd/TreeDndPlugin.js +5 -34
- package/esm/plugins/dnd/TreeDndPlugin.js.map +7 -0
- package/esm/plugins/dnd/index.js +3 -1
- package/esm/plugins/dnd/index.js.map +7 -0
- package/esm/plugins/index.js +9 -7
- package/esm/plugins/index.js.map +7 -0
- package/esm/plugins/roving/TreeRovingPlugin.js +6 -3
- package/esm/plugins/roving/TreeRovingPlugin.js.map +7 -0
- package/esm/plugins/roving/index.js +3 -1
- package/esm/plugins/roving/index.js.map +7 -0
- package/esm/plugins/searchable/SearchableTreePlugin.js +6 -3
- package/esm/plugins/searchable/SearchableTreePlugin.js.map +7 -0
- package/esm/plugins/searchable/index.js +3 -1
- package/esm/plugins/searchable/index.js.map +7 -0
- package/esm/plugins/selectable/SelectablePluginTree.js +6 -3
- package/esm/plugins/selectable/SelectablePluginTree.js.map +7 -0
- package/esm/plugins/selectable/index.js +3 -1
- package/esm/plugins/selectable/index.js.map +7 -0
- package/esm/plugins/toolbar/TreeToolbarPlugin.js +6 -3
- package/esm/plugins/toolbar/TreeToolbarPlugin.js.map +7 -0
- package/esm/plugins/toolbar/index.js +3 -1
- package/esm/plugins/toolbar/index.js.map +7 -0
- package/esm/plugins/tree/TreeDataPlugin.js +6 -3
- package/esm/plugins/tree/TreeDataPlugin.js.map +7 -0
- package/esm/plugins/tree/index.js +3 -1
- package/esm/plugins/tree/index.js.map +7 -0
- package/esm/plugins/virtualization/TreeVirtualizationPlugin.js +6 -3
- package/esm/plugins/virtualization/TreeVirtualizationPlugin.js.map +7 -0
- package/esm/plugins/virtualization/index.js +3 -1
- package/esm/plugins/virtualization/index.js.map +7 -0
- package/esm/react-desc-prop-types.js +48 -43
- package/esm/react-desc-prop-types.js.map +7 -0
- package/esm/related-components/TreeViewSearchBar.js +13 -32
- package/esm/related-components/TreeViewSearchBar.js.map +7 -0
- package/esm/sharedTypes.js +2 -1
- package/esm/sharedTypes.js.map +7 -0
- package/esm/utils/array-helpers.js +6 -6
- package/esm/utils/array-helpers.js.map +7 -0
- package/esm/utils/group-expands-helpers.js +56 -46
- package/esm/utils/group-expands-helpers.js.map +7 -0
- package/esm/utils/keyboard-helpers.js +47 -74
- package/esm/utils/keyboard-helpers.js.map +7 -0
- package/esm/utils/object-helpers.js +14 -31
- package/esm/utils/object-helpers.js.map +7 -0
- package/esm/utils/refs-helpers.js +15 -19
- package/esm/utils/refs-helpers.js.map +7 -0
- package/esm/utils/selectable-helper.js +32 -43
- package/esm/utils/selectable-helper.js.map +7 -0
- package/esm/utils/string-helpers.js +6 -3
- package/esm/utils/string-helpers.js.map +7 -0
- package/esm/utils/tree-helpers.js +94 -119
- package/esm/utils/tree-helpers.js.map +7 -0
- package/esm/utils/useInstanceRefActions.js +21 -35
- package/esm/utils/useInstanceRefActions.js.map +7 -0
- package/esm/utils/useTree.js +37 -57
- package/esm/utils/useTree.js.map +7 -0
- package/package.json +34 -18
- package/types/hoc/DnDTreeContext.d.ts +14 -0
- package/types/hoc/SortableItemContext.d.ts +19 -0
- package/types/hoc/WithConditionalDnDContext.d.ts +4 -0
- package/types/hoc/WithDnDSortableItemContext.d.ts +4 -0
- package/types/parts/DnDHandle.d.ts +6 -0
- package/types/parts/DropIndicator.d.ts +10 -0
- package/types/parts/TreeItem.d.ts +4 -11
- package/types/parts/TreeList.d.ts +0 -4
- package/types/plugins/dnd/TreeDndPlugin.d.ts +0 -2
- package/types/react-desc-prop-types.d.ts +17 -3
- package/types/sharedTypes.d.ts +1 -8
- package/types/utils/keyboard-helpers.d.ts +2 -1
- package/types/utils/refs-helpers.d.ts +1 -1
- package/types/utils/tree-helpers.d.ts +4 -1
- package/types/utils/useTree.d.ts +1 -0
- package/cjs/utils/dnd-helpers.js +0 -140
- package/cjs/utils/useDnDHelpers.js +0 -220
- package/esm/utils/dnd-helpers.js +0 -132
- package/esm/utils/useDnDHelpers.js +0 -216
- package/types/utils/dnd-helpers.d.ts +0 -39
- package/types/utils/useDnDHelpers.d.ts +0 -26
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/keyboard-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\n/* 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 { toggleExpandAllHelper, toggleItemExpand } from './group-expands-helpers';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\nimport type { DSTreeviewInternalsT } from '../sharedTypes';\nimport { SortableItemContextType } from '../hoc/SortableItemContext';\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: DSTreeviewT.Item, draggableProps: SortableItemContextType['draggableProps']) => {\n const ctx = useContext(TreeViewContext);\n const {\n props: { onItemFocus },\n triggerTreeRerender,\n visibleItems,\n setFocusedItem,\n setSelectedItem,\n setLatestToggledItem,\n updateUserExpandedState,\n virtualListHelpers: { scrollToIndex },\n } = ctx;\n const { isGroup, isExpanded } = item;\n const onItemFocusCurry = useCallback(\n (newFocusItem: DSTreeviewT.Item) =>\n onItemFocus({\n itemIndex: newFocusItem.virtualIndex as number,\n scrollToItem: (opts = { align: 'start' }) => scrollToIndex(newFocusItem.virtualIndex as number, opts),\n item: newFocusItem,\n }),\n [onItemFocus, scrollToIndex],\n );\n\n const onItemKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLLIElement>) => {\n const { keyCode } = e;\n if (!(draggableProps && draggableProps.active)) {\n if (keyCode !== 9) e.preventDefault(); // allow tab/shift+tab\n if ((keyCode === 13 || keyCode === 32) && (e.target as HTMLElement).tagName === 'LI') {\n setSelectedItem(item);\n }\n\n if (keyCode === 37) {\n if (isGroup && isExpanded) {\n toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);\n setLatestToggledItem(item);\n }\n }\n if (keyCode === 39) {\n if (isGroup && !isExpanded) {\n toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);\n setLatestToggledItem(item);\n }\n }\n\n const { virtualIndex } = item;\n if (typeof virtualIndex === 'number') {\n const lastItemIndex = visibleItems.length - 1;\n if (keyCode === 38) {\n const isLoopedFocus = virtualIndex === 0;\n const newFocusIndex = isLoopedFocus ? lastItemIndex : 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 [\n draggableProps,\n setSelectedItem,\n item,\n isGroup,\n isExpanded,\n triggerTreeRerender,\n updateUserExpandedState,\n scrollToIndex,\n setLatestToggledItem,\n visibleItems,\n setFocusedItem,\n onItemFocusCurry,\n ],\n );\n\n return onItemKeyDown;\n};\n\nexport const useGlobalKeyboardListener = (func: (e: KeyboardEvent) => void) => {\n useEffect(() => {\n document.addEventListener('keydown', func);\n return () => document.removeEventListener('keydown', func);\n }, [func]);\n};\n\nexport const useGlobalToggleAllExpandShortcut = (\n treeRoot: DSTreeviewT.Item['node'],\n triggerTreeRerender: () => void,\n setLatestToggledItem: DSTreeviewInternalsT.CTX['setLatestToggledItem'],\n updateUserExpandedState: DSTreeviewInternalsT.CTX['updateUserExpandedState'],\n) => {\n const memoizedToggleAllKeyboardShortcut = useCallback(\n (e: KeyboardEvent) => {\n const { shiftKey, keyCode } = e;\n if (shiftKey && keyCode === 56) {\n toggleExpandAllHelper('toggle', treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);\n }\n },\n [setLatestToggledItem, treeRoot, triggerTreeRerender, updateUserExpandedState],\n );\n\n return useGlobalKeyboardListener(memoizedToggleAllKeyboardShortcut);\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACIA;AACA;AACA;AACA;AAkBO,MAAM,mBAAmB,CAAC,MAAwB,mBAA8D;AACrH,QAAM,MAAM,WAAW;AACvB,QAAM;AAAA,IACJ,OAAO,EAAE;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,oBAAoB,EAAE;AAAA,MACpB;AACJ,QAAM,EAAE,SAAS,eAAe;AAChC,QAAM,mBAAmB,YACvB,CAAC,iBACC,YAAY;AAAA,IACV,WAAW,aAAa;AAAA,IACxB,cAAc,CAAC,OAAO,EAAE,OAAO,cAAc,cAAc,aAAa,cAAwB;AAAA,IAChG,MAAM;AAAA,MAEV,CAAC,aAAa;AAGhB,QAAM,gBAAgB,YACpB,CAAC,MAA0C;AACzC,UAAM,EAAE,YAAY;AACpB,QAAI,CAAE,mBAAkB,eAAe,SAAS;AAC9C,UAAI,YAAY;AAAG,UAAE;AACrB,UAAK,aAAY,MAAM,YAAY,OAAQ,EAAE,OAAuB,YAAY,MAAM;AACpF,wBAAgB;AAAA;AAGlB,UAAI,YAAY,IAAI;AAClB,YAAI,WAAW,YAAY;AACzB,2BAAiB,MAAM,qBAAqB,yBAAyB;AACrE,+BAAqB;AAAA;AAAA;AAGzB,UAAI,YAAY,IAAI;AAClB,YAAI,WAAW,CAAC,YAAY;AAC1B,2BAAiB,MAAM,qBAAqB,yBAAyB;AACrE,+BAAqB;AAAA;AAAA;AAIzB,YAAM,EAAE,iBAAiB;AACzB,UAAI,OAAO,iBAAiB,UAAU;AACpC,cAAM,gBAAgB,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C;AAAA;AAGC,MAAM,mCAAmC,CAC9C,UACA,qBACA,sBACA,4BACG;AACH,QAAM,oCAAoC,YACxC,CAAC,MAAqB;AACpB,UAAM,EAAE,UAAU,YAAY;AAC9B,QAAI,YAAY,YAAY,IAAI;AAC9B,4BAAsB,UAAU,UAAU,qBAAqB,sBAAsB;AAAA;AAAA,KAGzF,CAAC,sBAAsB,UAAU,qBAAqB;AAGxD,SAAO,0BAA0B;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,64 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
6
|
-
|
|
7
|
-
/* eslint-disable no-sequences */
|
|
8
|
-
|
|
9
|
-
/* eslint-disable no-return-assign */
|
|
10
|
-
|
|
11
|
-
/* eslint-disable no-restricted-syntax */
|
|
12
|
-
|
|
13
|
-
/* eslint-disable guard-for-in */
|
|
1
|
+
import * as React from "react";
|
|
14
2
|
function isObjectADate(o) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return (o === null || o === void 0 ? void 0 : (_o$constructor = o.constructor) === null || _o$constructor === void 0 ? void 0 : _o$constructor.name) === 'Date';
|
|
3
|
+
return o?.constructor?.name === "Date";
|
|
18
4
|
}
|
|
19
|
-
|
|
20
5
|
function isObjectAnArray(o) {
|
|
21
6
|
return Array.isArray(o);
|
|
22
7
|
}
|
|
23
|
-
|
|
24
8
|
function isObjectAString(o) {
|
|
25
|
-
return typeof o ===
|
|
9
|
+
return typeof o === "object";
|
|
26
10
|
}
|
|
27
|
-
|
|
28
|
-
const unfreeze = o => {
|
|
11
|
+
const unfreeze = (o) => {
|
|
29
12
|
let oo;
|
|
30
|
-
|
|
31
13
|
if (o === null) {
|
|
32
14
|
oo = null;
|
|
33
|
-
} else if (o ===
|
|
34
|
-
oo =
|
|
15
|
+
} else if (o === void 0) {
|
|
16
|
+
oo = void 0;
|
|
35
17
|
} else if (isObjectADate(o)) {
|
|
36
18
|
oo = new Date(o);
|
|
37
19
|
} else if (isObjectAnArray(o)) {
|
|
38
20
|
oo = [];
|
|
39
|
-
o.forEach(v => {
|
|
21
|
+
o.forEach((v) => {
|
|
40
22
|
oo.push(v);
|
|
41
23
|
});
|
|
42
24
|
} else if (isObjectAString(o)) {
|
|
43
25
|
oo = String(o);
|
|
44
26
|
} else if (isObjectAString(o)) {
|
|
45
27
|
oo = {};
|
|
46
|
-
|
|
47
28
|
for (const property in o) {
|
|
48
29
|
oo[property] = o[property];
|
|
49
30
|
}
|
|
50
31
|
} else {
|
|
51
32
|
oo = o;
|
|
52
33
|
}
|
|
53
|
-
|
|
54
34
|
return oo;
|
|
55
35
|
};
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
36
|
function filterObject(obj, predicate) {
|
|
58
37
|
return Object.keys(obj).reduce((res, key) => {
|
|
59
|
-
if (predicate(obj[key]))
|
|
38
|
+
if (predicate(obj[key]))
|
|
39
|
+
res[key] = obj[key];
|
|
60
40
|
return res;
|
|
61
41
|
}, {});
|
|
62
42
|
}
|
|
63
|
-
|
|
64
|
-
|
|
43
|
+
export {
|
|
44
|
+
filterObject,
|
|
45
|
+
unfreeze
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=object-helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/object-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-sequences */\n/* eslint-disable no-return-assign */\n/* eslint-disable no-restricted-syntax */\n/* eslint-disable guard-for-in */\n\nfunction isObjectADate(o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>): o is Date {\n return o?.constructor?.name === 'Date';\n}\nfunction isObjectAnArray(\n o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>,\n): o is unknown[] {\n return Array.isArray(o);\n}\nfunction isObjectAString(\n o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>,\n): o is Record<string, unknown> {\n return typeof o === 'object';\n}\n\nexport const unfreeze = (o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>) => {\n let oo: string | number | unknown[] | Date | null | undefined | Record<string, unknown>;\n if (o === null) {\n oo = null;\n } else if (o === undefined) {\n oo = undefined;\n } else if (isObjectADate(o)) {\n oo = new Date(o);\n } else if (isObjectAnArray(o)) {\n oo = [];\n o.forEach((v) => {\n (oo as unknown[]).push(v);\n });\n } else if (isObjectAString(o)) {\n oo = String(o);\n } else if (isObjectAString(o)) {\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\ntype GenericItemT<T = unknown> = { [key: string]: T };\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function filterObject<T = unknown>(obj: GenericItemT<T>, predicate: (val: T) => boolean) {\n return Object.keys(obj).reduce<GenericItemT<T>>((res, key) => {\n if (predicate(obj[key])) res[key] = obj[key];\n return res;\n }, {} as GenericItemT<T>);\n}\n"],
|
|
5
|
+
"mappings": "AAAA;ACKA,uBAAuB,GAA+F;AACpH,SAAO,GAAG,aAAa,SAAS;AAAA;AAElC,yBACE,GACgB;AAChB,SAAO,MAAM,QAAQ;AAAA;AAEvB,yBACE,GAC8B;AAC9B,SAAO,OAAO,MAAM;AAAA;AAGf,MAAM,WAAW,CAAC,MAAuF;AAC9G,MAAI;AACJ,MAAI,MAAM,MAAM;AACd,SAAK;AAAA,aACI,MAAM,QAAW;AAC1B,SAAK;AAAA,aACI,cAAc,IAAI;AAC3B,SAAK,IAAI,KAAK;AAAA,aACL,gBAAgB,IAAI;AAC7B,SAAK;AACL,MAAE,QAAQ,CAAC,MAAM;AACf,MAAC,GAAiB,KAAK;AAAA;AAAA,aAEhB,gBAAgB,IAAI;AAC7B,SAAK,OAAO;AAAA,aACH,gBAAgB,IAAI;AAC7B,SAAK;AACL,eAAW,YAAY,GAAG;AACxB,SAAG,YAAY,EAAE;AAAA;AAAA,SAEd;AACL,SAAK;AAAA;AAEP,SAAO;AAAA;AAKF,sBAAmC,KAAsB,WAAgC;AAC9F,SAAO,OAAO,KAAK,KAAK,OAAwB,CAAC,KAAK,QAAQ;AAC5D,QAAI,UAAU,IAAI;AAAO,UAAI,OAAO,IAAI;AACxC,WAAO;AAAA,KACN;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
|
|
7
|
-
// allow multiple refs to be set to point to the same DOM element
|
|
8
|
-
const setMultipleRefs = function () {
|
|
9
|
-
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
10
|
-
refs[_key] = arguments[_key];
|
|
11
|
-
}
|
|
12
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const setMultipleRefs = (...refs) => {
|
|
13
3
|
const filteredRefs = refs.filter(Boolean);
|
|
14
|
-
if (!filteredRefs.length)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
if (!filteredRefs.length)
|
|
5
|
+
return () => {
|
|
6
|
+
};
|
|
7
|
+
if (filteredRefs.length === 0)
|
|
8
|
+
return () => {
|
|
9
|
+
};
|
|
10
|
+
return (newRef) => {
|
|
11
|
+
filteredRefs.forEach((refToBeUpdated) => {
|
|
12
|
+
if (typeof refToBeUpdated === "function") {
|
|
19
13
|
refToBeUpdated(newRef);
|
|
20
14
|
} else if (refToBeUpdated) {
|
|
21
15
|
refToBeUpdated.current = newRef;
|
|
@@ -23,5 +17,7 @@ const setMultipleRefs = function () {
|
|
|
23
17
|
});
|
|
24
18
|
};
|
|
25
19
|
};
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
export {
|
|
21
|
+
setMultipleRefs
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=refs-helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/refs-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "// allow multiple refs to be set to point to the same DOM element\ntype GenericMergeableRef = null | undefined | React.MutableRefObject<unknown> | ((ref: HTMLElement) => void) | false;\nexport const setMultipleRefs = (...refs: GenericMergeableRef[]): ((ref: HTMLElement) => void) => {\n const filteredRefs = refs.filter(Boolean);\n if (!filteredRefs.length) return () => {};\n if (filteredRefs.length === 0) return () => {};\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"],
|
|
5
|
+
"mappings": "AAAA;ACEO,MAAM,kBAAkB,IAAI,SAA8D;AAC/F,QAAM,eAAe,KAAK,OAAO;AACjC,MAAI,CAAC,aAAa;AAAQ,WAAO,MAAM;AAAA;AACvC,MAAI,aAAa,WAAW;AAAG,WAAO,MAAM;AAAA;AAE5C,SAAO,CAAC,WAAW;AACjB,iBAAa,QAAQ,CAAC,mBAAmB;AACvC,UAAI,OAAO,mBAAmB,YAAY;AACxC,uBAAe;AAAA,iBACN,gBAAgB;AACzB,uBAAe,UAAU;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,70 +1,59 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import { walkAllNodeChildren, walkParents } from './tree-helpers.js';
|
|
8
|
-
|
|
9
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
-
|
|
11
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
-
const getGroupCheckState = node => {
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { walkParents, walkAllNodeChildren } from "./tree-helpers";
|
|
3
|
+
const getGroupCheckState = (node) => {
|
|
13
4
|
let childAllChecked = true;
|
|
14
5
|
let anyChildChecked = false;
|
|
15
|
-
walkAllNodeChildren(node, childNode => {
|
|
6
|
+
walkAllNodeChildren(node, (childNode) => {
|
|
16
7
|
const {
|
|
17
|
-
model: {
|
|
18
|
-
isChecked
|
|
19
|
-
}
|
|
8
|
+
model: { isChecked }
|
|
20
9
|
} = childNode;
|
|
21
|
-
if (isChecked ===
|
|
10
|
+
if (isChecked === "mixed" || isChecked === true)
|
|
11
|
+
anyChildChecked = true;
|
|
12
|
+
else
|
|
13
|
+
childAllChecked = false;
|
|
22
14
|
});
|
|
23
|
-
if (childAllChecked)
|
|
24
|
-
|
|
15
|
+
if (childAllChecked)
|
|
16
|
+
return true;
|
|
17
|
+
if (anyChildChecked)
|
|
18
|
+
return "mixed";
|
|
25
19
|
return false;
|
|
26
20
|
};
|
|
27
|
-
const selectCheckboxItemModelParentsTillRoot =
|
|
28
|
-
let triggerTreeRerender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
21
|
+
const selectCheckboxItemModelParentsTillRoot = (modelToCheck, triggerTreeRerender = null) => {
|
|
29
22
|
const newSelections = {};
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
} = modelToCheck;
|
|
33
|
-
walkParents(nodePath, parentNode => {
|
|
23
|
+
const { nodePath } = modelToCheck;
|
|
24
|
+
walkParents(nodePath, (parentNode) => {
|
|
34
25
|
const nextState = getGroupCheckState(parentNode);
|
|
35
26
|
parentNode.model.isChecked = nextState;
|
|
36
27
|
newSelections[parentNode.model.id] = nextState;
|
|
37
28
|
});
|
|
38
|
-
if (triggerTreeRerender)
|
|
29
|
+
if (triggerTreeRerender)
|
|
30
|
+
triggerTreeRerender();
|
|
39
31
|
return newSelections;
|
|
40
32
|
};
|
|
41
|
-
const toggleCheckboxItem =
|
|
42
|
-
let triggerTreeRerender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
33
|
+
const toggleCheckboxItem = (itemToSelect, triggerTreeRerender = null) => {
|
|
43
34
|
const {
|
|
44
35
|
node: {
|
|
45
|
-
model: {
|
|
46
|
-
id,
|
|
47
|
-
isChecked,
|
|
48
|
-
children = []
|
|
49
|
-
}
|
|
36
|
+
model: { id, isChecked, children = [] }
|
|
50
37
|
}
|
|
51
38
|
} = itemToSelect;
|
|
52
|
-
const newSelections = {};
|
|
53
|
-
|
|
54
|
-
const nextState = isChecked === 'mixed' ? true : !isChecked;
|
|
39
|
+
const newSelections = {};
|
|
40
|
+
const nextState = isChecked === "mixed" ? true : !isChecked;
|
|
55
41
|
itemToSelect.node.model.isChecked = nextState;
|
|
56
42
|
newSelections[id] = nextState;
|
|
57
|
-
|
|
58
43
|
if (children.length > 0 && (nextState === true || nextState === false)) {
|
|
59
|
-
walkAllNodeChildren(itemToSelect.node, childNode => {
|
|
44
|
+
walkAllNodeChildren(itemToSelect.node, (childNode) => {
|
|
60
45
|
childNode.model.isChecked = nextState;
|
|
61
46
|
newSelections[childNode.model.id] = nextState;
|
|
62
47
|
});
|
|
63
48
|
}
|
|
64
|
-
|
|
65
49
|
const parentsNewSelections = selectCheckboxItemModelParentsTillRoot(itemToSelect);
|
|
66
|
-
if (triggerTreeRerender)
|
|
67
|
-
|
|
50
|
+
if (triggerTreeRerender)
|
|
51
|
+
triggerTreeRerender();
|
|
52
|
+
return { ...parentsNewSelections, ...newSelections };
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
getGroupCheckState,
|
|
56
|
+
selectCheckboxItemModelParentsTillRoot,
|
|
57
|
+
toggleCheckboxItem
|
|
68
58
|
};
|
|
69
|
-
|
|
70
|
-
export { getGroupCheckState, selectCheckboxItemModelParentsTillRoot, toggleCheckboxItem };
|
|
59
|
+
//# sourceMappingURL=selectable-helper.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/selectable-helper.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nimport { walkParents, walkAllNodeChildren } from './tree-helpers';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\n\nexport const getGroupCheckState = (node: DSTreeviewT.Item['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: DSTreeviewT.Item,\n triggerTreeRerender: (() => void) | null = null,\n) => {\n const newSelections: DSTreeviewT.SelectionItems = {};\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 = (itemToSelect: DSTreeviewT.Item, triggerTreeRerender: (() => void) | null = null) => {\n const {\n node: {\n model: { id, isChecked, children = [] },\n },\n } = itemToSelect;\n\n const newSelections: DSTreeviewT.SelectionItems = {};\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(itemToSelect);\n\n if (triggerTreeRerender) triggerTreeRerender();\n return { ...parentsNewSelections, ...newSelections };\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AAGO,MAAM,qBAAqB,CAAC,SAAmC;AACpE,MAAI,kBAAkB;AACtB,MAAI,kBAAkB;AACtB,sBAAoB,MAAM,CAAC,cAAc;AACvC,UAAM;AAAA,MACJ,OAAO,EAAE;AAAA,QACP;AACJ,QAAI,cAAc,WAAW,cAAc;AAAM,wBAAkB;AAAA;AAC9D,wBAAkB;AAAA;AAGzB,MAAI;AAAiB,WAAO;AAC5B,MAAI;AAAiB,WAAO;AAC5B,SAAO;AAAA;AAGF,MAAM,yCAAyC,CACpD,cACA,sBAA2C,SACxC;AACH,QAAM,gBAA4C;AAClD,QAAM,EAAE,aAAa;AACrB,cAAY,UAAU,CAAC,eAAe;AACpC,UAAM,YAAY,mBAAmB;AACrC,eAAW,MAAM,YAAY;AAC7B,kBAAc,WAAW,MAAM,MAAM;AAAA;AAEvC,MAAI;AAAqB;AACzB,SAAO;AAAA;AAGF,MAAM,qBAAqB,CAAC,cAAgC,sBAA2C,SAAS;AACrH,QAAM;AAAA,IACJ,MAAM;AAAA,MACJ,OAAO,EAAE,IAAI,WAAW,WAAW;AAAA;AAAA,MAEnC;AAEJ,QAAM,gBAA4C;AAElD,QAAM,YAAY,cAAc,UAAU,OAAO,CAAC;AAClD,eAAa,KAAK,MAAM,YAAY;AACpC,gBAAc,MAAM;AAEpB,MAAI,SAAS,SAAS,KAAM,eAAc,QAAQ,cAAc,QAAQ;AACtE,wBAAoB,aAAa,MAAM,CAAC,cAAc;AACpD,gBAAU,MAAM,YAAY;AAC5B,oBAAc,UAAU,MAAM,MAAM;AAAA;AAAA;AAIxC,QAAM,uBAAuB,uCAAuC;AAEpE,MAAI;AAAqB;AACzB,SAAO,KAAK,yBAAyB;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const standardizeSearchQueryString = (input) => input.trim().toLowerCase();
|
|
3
|
+
export {
|
|
4
|
+
standardizeSearchQueryString
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=string-helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/string-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const standardizeSearchQueryString = (input: string) => input.trim().toLowerCase();\n"],
|
|
5
|
+
"mappings": "AAAA;ACAO,MAAM,+BAA+B,CAAC,UAAkB,MAAM,OAAO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,180 +1,155 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import 'core-js/modules/esnext.iterator.every.js';
|
|
9
|
-
import { createRef } from 'react';
|
|
10
|
-
import { standardizeSearchQueryString } from './string-helpers.js';
|
|
11
|
-
|
|
12
|
-
const walkVisibles = function (node, callback) {
|
|
13
|
-
let skipRoot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
14
|
-
let highlightOnlyQuery = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
15
|
-
const {
|
|
16
|
-
children,
|
|
17
|
-
model
|
|
18
|
-
} = node;
|
|
19
|
-
const {
|
|
20
|
-
name,
|
|
21
|
-
isExpanded,
|
|
22
|
-
childrenMatchesSearchQuery,
|
|
23
|
-
matchesSearchQuery
|
|
24
|
-
} = model;
|
|
25
|
-
const shouldSkipBecauseIsRoot = skipRoot && name === '__root';
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { createRef } from "react";
|
|
3
|
+
import { standardizeSearchQueryString } from "./string-helpers";
|
|
4
|
+
const walkVisibles = (node, callback, skipRoot = true, highlightOnlyQuery = false) => {
|
|
5
|
+
const { children, model } = node;
|
|
6
|
+
const { name, isExpanded, childrenMatchesSearchQuery, matchesSearchQuery } = model;
|
|
7
|
+
const shouldSkipBecauseIsRoot = skipRoot && name === "__root";
|
|
26
8
|
const queryRestrictionsPassed = !!(highlightOnlyQuery || childrenMatchesSearchQuery || matchesSearchQuery);
|
|
27
|
-
if (!shouldSkipBecauseIsRoot && queryRestrictionsPassed)
|
|
9
|
+
if (!shouldSkipBecauseIsRoot && queryRestrictionsPassed)
|
|
10
|
+
callback(node);
|
|
28
11
|
const shouldWalkChildren = !!(children.length > 0 && isExpanded && queryRestrictionsPassed);
|
|
29
|
-
|
|
30
12
|
if (shouldWalkChildren) {
|
|
31
|
-
children.forEach(childNode => {
|
|
13
|
+
children.forEach((childNode) => {
|
|
32
14
|
walkVisibles(childNode, callback, skipRoot, highlightOnlyQuery);
|
|
33
15
|
});
|
|
34
16
|
}
|
|
35
17
|
};
|
|
36
|
-
const walkParents =
|
|
37
|
-
let skipRoot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
18
|
+
const walkParents = (nodePath, callback, skipRoot = true) => {
|
|
38
19
|
const parents = [...nodePath].reverse();
|
|
39
|
-
parents.shift();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
20
|
+
parents.shift();
|
|
21
|
+
if (skipRoot)
|
|
22
|
+
parents.pop();
|
|
43
23
|
parents.forEach(callback);
|
|
44
24
|
};
|
|
45
|
-
const walkAllNodeChildren =
|
|
46
|
-
|
|
47
|
-
const {
|
|
48
|
-
children = []
|
|
49
|
-
} = node;
|
|
25
|
+
const walkAllNodeChildren = (node, callback, isFirst = true) => {
|
|
26
|
+
const { children = [] } = node;
|
|
50
27
|
const shouldWalkChildren = children.length;
|
|
51
|
-
if (!isFirst)
|
|
52
|
-
|
|
28
|
+
if (!isFirst)
|
|
29
|
+
callback(node);
|
|
53
30
|
if (shouldWalkChildren) {
|
|
54
|
-
children.forEach(childNode => {
|
|
31
|
+
children.forEach((childNode) => {
|
|
55
32
|
walkAllNodeChildren(childNode, callback, false);
|
|
56
33
|
});
|
|
57
34
|
}
|
|
58
35
|
};
|
|
59
36
|
const getNodeById = (treeRoot, id) => {
|
|
60
|
-
const nodes = treeRoot.all(node => node.model.id === id);
|
|
37
|
+
const nodes = treeRoot.all((node) => node.model.id === id);
|
|
61
38
|
return nodes[0];
|
|
62
39
|
};
|
|
63
40
|
const cloneNode = (tree, node) => tree.parse(node.model);
|
|
64
|
-
const itemsShareSameParent =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (items.length === 1)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const firstExistingItemPath = firstExistingItem.node.getPath();
|
|
73
|
-
// length -1 is the current-node
|
|
74
|
-
// length -2 is the parent-node
|
|
75
|
-
// root node is not printed and is always present so minimum path length is 2 (root + currentNode)
|
|
76
|
-
|
|
41
|
+
const itemsShareSameParent = (items = []) => {
|
|
42
|
+
if (items.length === 0)
|
|
43
|
+
throw new Error("Received empty items for comparison");
|
|
44
|
+
if (items.length === 1)
|
|
45
|
+
return true;
|
|
46
|
+
const firstExistingItem = items.find((item) => !!item);
|
|
47
|
+
if (!firstExistingItem)
|
|
48
|
+
throw new Error("Received no items, can't retrieve parent");
|
|
49
|
+
const firstExistingItemPath = firstExistingItem.node.getPath();
|
|
77
50
|
const directParentNode = firstExistingItemPath[firstExistingItemPath.length - 2];
|
|
78
|
-
return items.every(item => {
|
|
79
|
-
|
|
80
|
-
|
|
51
|
+
return items.every((item) => {
|
|
52
|
+
if (!item)
|
|
53
|
+
return true;
|
|
81
54
|
const itemPath = item.node.getPath();
|
|
82
55
|
const itemDirectParent = itemPath[itemPath.length - 2];
|
|
83
56
|
return directParentNode === itemDirectParent;
|
|
84
57
|
});
|
|
85
58
|
};
|
|
86
|
-
const getItemsParentNode =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const firstExistingItemPath = firstExistingItem.node.getPath(); // path is like [rootParent, ...[parentsNodes], currentNode]
|
|
98
|
-
// length -1 is the current-node
|
|
99
|
-
// length -2 is the parent-node
|
|
100
|
-
// root node is not printed and is always present so minimum path length is 2 (root + currentNode)
|
|
101
|
-
|
|
59
|
+
const getItemsParentNode = (items = [], skipSameParentCheck = false) => {
|
|
60
|
+
if (items.length === 0)
|
|
61
|
+
throw new Error("Received empty items, can't retrieve parent");
|
|
62
|
+
if (!skipSameParentCheck) {
|
|
63
|
+
if (!itemsShareSameParent(items))
|
|
64
|
+
throw new Error("Received items don't share the same parent, can't retrieve parent");
|
|
65
|
+
}
|
|
66
|
+
const firstExistingItem = items.find((item) => !!item);
|
|
67
|
+
if (!firstExistingItem)
|
|
68
|
+
throw new Error("Received no items, can't retrieve parent");
|
|
69
|
+
const firstExistingItemPath = firstExistingItem.node.getPath();
|
|
102
70
|
const directParentNode = firstExistingItemPath[firstExistingItemPath.length - 2];
|
|
103
71
|
return directParentNode;
|
|
104
72
|
};
|
|
105
|
-
const getNodeMatchesSearchQuery =
|
|
106
|
-
let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
73
|
+
const getNodeMatchesSearchQuery = (node, searchQuery = "") => {
|
|
107
74
|
const standardizedName = standardizeSearchQueryString(node.model.name);
|
|
108
75
|
const standardizedSearchQuery = standardizeSearchQueryString(searchQuery);
|
|
109
76
|
return standardizedName.includes(standardizedSearchQuery);
|
|
110
77
|
};
|
|
111
|
-
const getChildrenMatchesSearchQuery =
|
|
112
|
-
let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
78
|
+
const getChildrenMatchesSearchQuery = (parentNode, searchQuery = "") => {
|
|
113
79
|
let anyChildMatch = false;
|
|
114
|
-
walkAllNodeChildren(parentNode, node => {
|
|
115
|
-
if (getNodeMatchesSearchQuery(node, searchQuery))
|
|
80
|
+
walkAllNodeChildren(parentNode, (node) => {
|
|
81
|
+
if (getNodeMatchesSearchQuery(node, searchQuery))
|
|
82
|
+
anyChildMatch = true;
|
|
116
83
|
});
|
|
117
84
|
return anyChildMatch;
|
|
118
85
|
};
|
|
119
|
-
|
|
120
|
-
* Mutate in place a node from tree-model normalizing object properties like "isGroup" even if user didn't specify it explicitly,
|
|
121
|
-
* after execution the node will have "nodePath" "treeDepth" "nodeItemRef" "isGroup" "isExpanded"
|
|
122
|
-
* (optionally, based on the provided arguments) "matchesSearchQuery" "childrenMatchesSearchQuery" "isChecked"
|
|
123
|
-
*
|
|
124
|
-
* @param {Object} node - node (based on 'tree-model' lib) that you wish to mutate with extra props
|
|
125
|
-
* @param {string} [searchQuery=''] - optional string used to parse "matchesSearchQuery"/"childrenMatchesSearchQuery" properties
|
|
126
|
-
* @param {Object} [selection=null] - optional selection hashmap used to parse "isChecked" properties
|
|
127
|
-
* @param {Object} [expanded=null] - optional expanded hashmap used to parse "isExpanded" properties
|
|
128
|
-
*/
|
|
129
|
-
|
|
130
|
-
const enrichNodeModelInPlace = function (node) {
|
|
131
|
-
var _node$model, _node$model$children;
|
|
132
|
-
|
|
133
|
-
let searchQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
134
|
-
let selection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
135
|
-
let expanded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
86
|
+
const enrichNodeModelInPlace = (node, searchQuery = "", selection = null, expanded = null) => {
|
|
136
87
|
const path = node.getPath();
|
|
137
88
|
const depth = path.length - 1;
|
|
138
89
|
node.model.nodePath = path;
|
|
139
90
|
node.model.treeDepth = depth;
|
|
140
|
-
|
|
141
91
|
if (!node.model.nodeItemRef) {
|
|
142
|
-
node.model.nodeItemRef =
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (typeof node.model.isGroup !== 'boolean' && ((_node$model = node.model) === null || _node$model === void 0 ? void 0 : (_node$model$children = _node$model.children) === null || _node$model$children === void 0 ? void 0 : _node$model$children.length) > 0) {
|
|
92
|
+
node.model.nodeItemRef = createRef();
|
|
93
|
+
}
|
|
94
|
+
if (typeof node.model.isGroup !== "boolean" && (node.model?.children?.length ?? 0) > 0) {
|
|
148
95
|
node.model.isGroup = true;
|
|
149
96
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
97
|
+
if (node.model.isGroup && node.model.id !== "__ds_tree_root") {
|
|
98
|
+
if (expanded)
|
|
99
|
+
node.model.isExpanded = !!expanded[node.model.id];
|
|
100
|
+
else if (typeof node.model.isExpanded !== "boolean") {
|
|
153
101
|
node.model.isExpanded = false;
|
|
154
102
|
}
|
|
155
103
|
}
|
|
156
|
-
|
|
157
104
|
node.model.matchesSearchQuery = true;
|
|
158
105
|
node.model.childrenMatchesSearchQuery = false;
|
|
159
106
|
const partiallyEnrichedNode = node;
|
|
160
|
-
|
|
161
107
|
if (searchQuery) {
|
|
162
108
|
partiallyEnrichedNode.model.matchesSearchQuery = getNodeMatchesSearchQuery(partiallyEnrichedNode, searchQuery);
|
|
163
|
-
|
|
164
109
|
if (partiallyEnrichedNode.model.isGroup === true) {
|
|
165
110
|
partiallyEnrichedNode.model.childrenMatchesSearchQuery = getChildrenMatchesSearchQuery(partiallyEnrichedNode, searchQuery);
|
|
166
|
-
if (partiallyEnrichedNode.model.childrenMatchesSearchQuery)
|
|
111
|
+
if (partiallyEnrichedNode.model.childrenMatchesSearchQuery)
|
|
112
|
+
partiallyEnrichedNode.model.isExpanded = true;
|
|
167
113
|
}
|
|
168
114
|
}
|
|
169
|
-
|
|
170
115
|
if (selection && selection[partiallyEnrichedNode.model.id]) {
|
|
171
116
|
partiallyEnrichedNode.model.isChecked = selection[partiallyEnrichedNode.model.id];
|
|
172
117
|
}
|
|
173
118
|
};
|
|
174
|
-
const focusItem = item => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
119
|
+
const focusItem = (item) => {
|
|
120
|
+
item?.nodeItemRef?.current?.focus();
|
|
121
|
+
};
|
|
122
|
+
const flattenTreeForDnD = (data, shouldDescend = () => true) => {
|
|
123
|
+
const flattenedTree = [];
|
|
124
|
+
let index = 0;
|
|
125
|
+
const doit = (node, depth = 0, parentId = null) => {
|
|
126
|
+
flattenedTree.push({
|
|
127
|
+
uid: node.id.toString(),
|
|
128
|
+
depth,
|
|
129
|
+
realIndex: index,
|
|
130
|
+
childrenCount: node.children?.length ?? 0,
|
|
131
|
+
parentId: parentId !== null ? parentId.toString() : null,
|
|
132
|
+
original: node
|
|
133
|
+
});
|
|
134
|
+
index += 1;
|
|
135
|
+
if (shouldDescend(node))
|
|
136
|
+
node.children?.forEach((child) => doit(child, depth + 1, node.id.toString()));
|
|
137
|
+
};
|
|
138
|
+
data.forEach((datum) => doit(datum));
|
|
139
|
+
return flattenedTree;
|
|
140
|
+
};
|
|
141
|
+
export {
|
|
142
|
+
cloneNode,
|
|
143
|
+
enrichNodeModelInPlace,
|
|
144
|
+
flattenTreeForDnD,
|
|
145
|
+
focusItem,
|
|
146
|
+
getChildrenMatchesSearchQuery,
|
|
147
|
+
getItemsParentNode,
|
|
148
|
+
getNodeById,
|
|
149
|
+
getNodeMatchesSearchQuery,
|
|
150
|
+
itemsShareSameParent,
|
|
151
|
+
walkAllNodeChildren,
|
|
152
|
+
walkParents,
|
|
153
|
+
walkVisibles
|
|
178
154
|
};
|
|
179
|
-
|
|
180
|
-
export { cloneNode, enrichNodeModelInPlace, focusItem, getChildrenMatchesSearchQuery, getItemsParentNode, getNodeById, getNodeMatchesSearchQuery, itemsShareSameParent, walkAllNodeChildren, walkParents, walkVisibles };
|
|
155
|
+
//# sourceMappingURL=tree-helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/tree-helpers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable max-params */\n/* eslint-disable complexity */\n/* eslint-disable max-lines */\nimport { createRef } from 'react';\nimport type TreeModel from 'tree-model';\nimport { standardizeSearchQueryString } from './string-helpers';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\n\nexport const walkVisibles = (\n node: DSTreeviewT.Item['node'],\n callback: (node: DSTreeviewT.Item['node']) => void,\n skipRoot = true,\n highlightOnlyQuery = false,\n) => {\n const { children, model } = node;\n const { name, isExpanded, childrenMatchesSearchQuery, matchesSearchQuery } = model;\n\n const shouldSkipBecauseIsRoot = skipRoot && name === '__root';\n const queryRestrictionsPassed = !!(highlightOnlyQuery || childrenMatchesSearchQuery || matchesSearchQuery);\n\n if (!shouldSkipBecauseIsRoot && queryRestrictionsPassed) callback(node);\n\n const shouldWalkChildren = !!(children.length > 0 && isExpanded && queryRestrictionsPassed);\n if (shouldWalkChildren) {\n children.forEach((childNode) => {\n walkVisibles(childNode, callback, skipRoot, highlightOnlyQuery);\n });\n }\n};\n\nexport const walkParents = (\n nodePath: DSTreeviewT.Item['nodePath'],\n callback: (currParent: DSTreeviewT.Item['node']) => void,\n skipRoot = true,\n) => {\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\ntype RecursiveCallbackT = (childNode: DSTreeviewT.Item['node'], cb?: RecursiveCallbackT, isFirst?: boolean) => void;\nexport const walkAllNodeChildren = (node: DSTreeviewT.Item['node'], callback: RecursiveCallbackT, 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: DSTreeviewT.Item['node'], id: DSTreeviewT.StringOrNum) => {\n const nodes = treeRoot.all((node) => (node as unknown as DSTreeviewT.Item).model.id === id);\n return nodes[0];\n};\n\nexport const cloneNode = (tree: TreeModel, node: DSTreeviewT.Item) => tree.parse(node.model);\n\nexport const itemsShareSameParent = (items: DSTreeviewT.Item[] = []) => {\n if (items.length === 0) 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) 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 = 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 getItemsParentNode = (items: DSTreeviewT.Item[] = [], skipSameParentCheck = false) => {\n if (items.length === 0) 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(\"Received items don't share the same parent, can't retrieve parent\");\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) 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 = firstExistingItemPath[firstExistingItemPath.length - 2];\n return directParentNode as unknown as DSTreeviewT.Item['node'];\n};\n\nexport const getNodeMatchesSearchQuery = (node: DSTreeviewT.Item['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: DSTreeviewT.Item['node'], searchQuery = '') => {\n let anyChildMatch = false;\n walkAllNodeChildren(parentNode, (node) => {\n if (getNodeMatchesSearchQuery(node, searchQuery)) anyChildMatch = true;\n });\n return anyChildMatch;\n};\n\n/**\n * Mutate in place a node from tree-model normalizing object properties like \"isGroup\" even if user didn't specify it explicitly,\n * after execution the node will have \"nodePath\" \"treeDepth\" \"nodeItemRef\" \"isGroup\" \"isExpanded\"\n * (optionally, based on the provided arguments) \"matchesSearchQuery\" \"childrenMatchesSearchQuery\" \"isChecked\"\n *\n * @param {Object} node - node (based on 'tree-model' lib) that you wish to mutate with extra props\n * @param {string} [searchQuery=''] - optional string used to parse \"matchesSearchQuery\"/\"childrenMatchesSearchQuery\" properties\n * @param {Object} [selection=null] - optional selection hashmap used to parse \"isChecked\" properties\n * @param {Object} [expanded=null] - optional expanded hashmap used to parse \"isExpanded\" properties\n */\nexport const enrichNodeModelInPlace = (\n node: TreeModel.Node<DSTreeviewT.SimpleItem>,\n searchQuery = '',\n selection: DSTreeviewT.SelectionItems | null = null,\n expanded: DSTreeviewT.ExpandedItems | null = 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 (typeof node.model.isGroup !== 'boolean' && (node.model?.children?.length ?? 0) > 0) {\n node.model.isGroup = true;\n }\n\n if (node.model.isGroup && node.model.id !== '__ds_tree_root') {\n if (expanded) node.model.isExpanded = !!expanded[node.model.id];\n else if (typeof node.model.isExpanded !== 'boolean') {\n node.model.isExpanded = false;\n }\n }\n\n node.model.matchesSearchQuery = true;\n node.model.childrenMatchesSearchQuery = false;\n const partiallyEnrichedNode = node as unknown as TreeModel.Node<DSTreeviewT.Item>;\n if (searchQuery) {\n partiallyEnrichedNode.model.matchesSearchQuery = getNodeMatchesSearchQuery(partiallyEnrichedNode, searchQuery);\n\n if (partiallyEnrichedNode.model.isGroup === true) {\n partiallyEnrichedNode.model.childrenMatchesSearchQuery = getChildrenMatchesSearchQuery(\n partiallyEnrichedNode,\n searchQuery,\n );\n if (partiallyEnrichedNode.model.childrenMatchesSearchQuery) partiallyEnrichedNode.model.isExpanded = true;\n }\n }\n if (selection && selection[partiallyEnrichedNode.model.id]) {\n partiallyEnrichedNode.model.isChecked = selection[partiallyEnrichedNode.model.id];\n }\n};\n\nexport const focusItem = (item: DSTreeviewT.Item | null) => {\n item?.nodeItemRef?.current?.focus();\n};\n\nexport const flattenTreeForDnD = (\n data: DSTreeviewT.SimpleItem[],\n shouldDescend: (datum: DSTreeviewT.SimpleItem) => boolean = () => true,\n) => {\n const flattenedTree: DSTreeviewT.DndItem[] = [];\n let index = 0;\n const doit = (node: DSTreeviewT.SimpleItem, depth = 0, parentId: DSTreeviewT.StringOrNum | null = null) => {\n flattenedTree.push({\n uid: node.id.toString(),\n depth,\n realIndex: index,\n childrenCount: node.children?.length ?? 0,\n parentId: parentId !== null ? parentId.toString() : null,\n original: node,\n });\n index += 1;\n if (shouldDescend(node)) node.children?.forEach((child) => doit(child, depth + 1, node.id.toString()));\n };\n\n data.forEach((datum) => doit(datum));\n return flattenedTree;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACIA;AAEA;AAGO,MAAM,eAAe,CAC1B,MACA,UACA,WAAW,MACX,qBAAqB,UAClB;AACH,QAAM,EAAE,UAAU,UAAU;AAC5B,QAAM,EAAE,MAAM,YAAY,4BAA4B,uBAAuB;AAE7E,QAAM,0BAA0B,YAAY,SAAS;AACrD,QAAM,0BAA0B,CAAC,CAAE,uBAAsB,8BAA8B;AAEvF,MAAI,CAAC,2BAA2B;AAAyB,aAAS;AAElE,QAAM,qBAAqB,CAAC,CAAE,UAAS,SAAS,KAAK,cAAc;AACnE,MAAI,oBAAoB;AACtB,aAAS,QAAQ,CAAC,cAAc;AAC9B,mBAAa,WAAW,UAAU,UAAU;AAAA;AAAA;AAAA;AAK3C,MAAM,cAAc,CACzB,UACA,UACA,WAAW,SACR;AACH,QAAM,UAAU,CAAC,GAAG,UAAU;AAC9B,UAAQ;AACR,MAAI;AAAU,YAAQ;AACtB,UAAQ,QAAQ;AAAA;AAIX,MAAM,sBAAsB,CAAC,MAAgC,UAA8B,UAAU,SAAS;AACnH,QAAM,EAAE,WAAW,OAAO;AAC1B,QAAM,qBAAqB,SAAS;AAEpC,MAAI,CAAC;AAAS,aAAS;AAEvB,MAAI,oBAAoB;A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