@elliemae/ds-treeview 3.5.0-rc.9 → 3.6.0-next.0
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/dist/cjs/TreeView.js +5 -4
- package/dist/cjs/TreeView.js.map +2 -2
- package/dist/cjs/hoc/WithConditionalDnDContext.js +31 -23
- package/dist/cjs/hoc/WithConditionalDnDContext.js.map +2 -2
- package/dist/cjs/hoc/WithDnDSortableItemContext.js +8 -6
- package/dist/cjs/hoc/WithDnDSortableItemContext.js.map +2 -2
- package/dist/cjs/parts/CheckboxSelectable.js +12 -9
- package/dist/cjs/parts/CheckboxSelectable.js.map +2 -2
- package/dist/cjs/parts/ChildrenCountDisplayer.js +8 -4
- package/dist/cjs/parts/ChildrenCountDisplayer.js.map +2 -2
- package/dist/cjs/parts/DnDHandle.js +3 -2
- package/dist/cjs/parts/DnDHandle.js.map +2 -2
- package/dist/cjs/parts/DropIndicator.js +20 -14
- package/dist/cjs/parts/DropIndicator.js.map +2 -2
- package/dist/cjs/parts/ExpandCaret.js +7 -7
- package/dist/cjs/parts/ExpandCaret.js.map +2 -2
- package/dist/cjs/parts/NestingSpace.js +2 -2
- package/dist/cjs/parts/NestingSpace.js.map +2 -2
- package/dist/cjs/parts/RadioSelectable.js +3 -2
- package/dist/cjs/parts/RadioSelectable.js.map +2 -2
- package/dist/cjs/parts/TreeItem.js +43 -25
- package/dist/cjs/parts/TreeItem.js.map +2 -2
- package/dist/cjs/parts/TreeItemText.js +54 -30
- package/dist/cjs/parts/TreeItemText.js.map +2 -2
- package/dist/cjs/parts/TreeList.js +58 -48
- package/dist/cjs/parts/TreeList.js.map +2 -2
- package/dist/cjs/related-components/TreeViewSearchBar.js +2 -2
- package/dist/cjs/related-components/TreeViewSearchBar.js.map +2 -2
- package/dist/esm/TreeView.js +5 -4
- package/dist/esm/TreeView.js.map +2 -2
- package/dist/esm/hoc/WithConditionalDnDContext.js +31 -23
- package/dist/esm/hoc/WithConditionalDnDContext.js.map +2 -2
- package/dist/esm/hoc/WithDnDSortableItemContext.js +8 -6
- package/dist/esm/hoc/WithDnDSortableItemContext.js.map +2 -2
- package/dist/esm/parts/CheckboxSelectable.js +12 -9
- package/dist/esm/parts/CheckboxSelectable.js.map +2 -2
- package/dist/esm/parts/ChildrenCountDisplayer.js +8 -4
- package/dist/esm/parts/ChildrenCountDisplayer.js.map +2 -2
- package/dist/esm/parts/DnDHandle.js +3 -2
- package/dist/esm/parts/DnDHandle.js.map +2 -2
- package/dist/esm/parts/DropIndicator.js +20 -14
- package/dist/esm/parts/DropIndicator.js.map +2 -2
- package/dist/esm/parts/ExpandCaret.js +7 -7
- package/dist/esm/parts/ExpandCaret.js.map +2 -2
- package/dist/esm/parts/NestingSpace.js +2 -2
- package/dist/esm/parts/NestingSpace.js.map +2 -2
- package/dist/esm/parts/RadioSelectable.js +3 -2
- package/dist/esm/parts/RadioSelectable.js.map +2 -2
- package/dist/esm/parts/TreeItem.js +43 -25
- package/dist/esm/parts/TreeItem.js.map +2 -2
- package/dist/esm/parts/TreeItemText.js +54 -30
- package/dist/esm/parts/TreeItemText.js.map +2 -2
- package/dist/esm/parts/TreeList.js +58 -48
- package/dist/esm/parts/TreeList.js.map +2 -2
- package/dist/esm/related-components/TreeViewSearchBar.js +2 -2
- package/dist/esm/related-components/TreeViewSearchBar.js.map +2 -2
- package/package.json +10 -10
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useMemo } from "react";
|
|
3
4
|
import { useSortable } from "@elliemae/ds-drag-and-drop";
|
|
4
5
|
import { SortableItemContext } from "./SortableItemContext";
|
|
5
6
|
import TreeViewContext from "../TreeViewContext";
|
|
@@ -32,11 +33,12 @@ const withDnDSortableItemContext = (Component) => (props) => {
|
|
|
32
33
|
}),
|
|
33
34
|
[draggableProps]
|
|
34
35
|
);
|
|
35
|
-
return /* @__PURE__ */
|
|
36
|
-
value: ctx
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
return /* @__PURE__ */ jsx(SortableItemContext.Provider, {
|
|
37
|
+
value: ctx,
|
|
38
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
39
|
+
...props
|
|
40
|
+
})
|
|
41
|
+
});
|
|
40
42
|
};
|
|
41
43
|
export {
|
|
42
44
|
withDnDSortableItemContext
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hoc/WithDnDSortableItemContext.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport React, { useContext, useMemo } from 'react';\nimport { useSortable } from '@elliemae/ds-drag-and-drop';\nimport { SortableItemContext, SortableItemContextType } from './SortableItemContext';\nimport TreeViewContext from '../TreeViewContext';\nimport { DnDTreeContext } from './DnDTreeContext';\nimport { DSTreeviewT } from '../react-desc-prop-types';\n\ntype FunctionalHOC = <T = unknown>(Component: React.ComponentType<T>, ...other: unknown[]) => (props: T) => JSX.Element;\n\nexport const withDnDSortableItemContext: FunctionalHOC = (Component) => (props: any) => {\n const { withDragAndDrop } = useContext(TreeViewContext);\n const { dropIndicatorPosition, isDropValid } = useContext(DnDTreeContext);\n\n const id = (props as { item: DSTreeviewT.Item }).item.id.toString();\n\n // onMount generate unique options, so everyting is only ran once\n const draggableOptions = useMemo(\n () => ({\n id,\n }),\n [id],\n );\n\n const useSortableHelpers = useSortable(draggableOptions);\n\n // calculate all the \"useSortable\" values as per required\n const draggableProps = useMemo(() => {\n if (!withDragAndDrop) return false;\n\n const { index, overIndex } = useSortableHelpers;\n\n return {\n ...useSortableHelpers,\n shouldShowDropIndicatorPosition: overIndex === index,\n dropIndicatorPosition,\n isDropValid,\n };\n }, [withDragAndDrop, useSortableHelpers, dropIndicatorPosition, isDropValid]);\n\n // we use a context so we can easly access information wherever without bubbling down\n // this context is all Memoized so as long as component is not re-mounted,\n // the context won't trigger un-required renders per-se...\n const ctx: SortableItemContextType = useMemo(\n () => ({\n draggableProps,\n }),\n [draggableProps],\n );\n // we always add the context, if draggableProps===false we don't have the DnD enabled.\n return (\n <SortableItemContext.Provider value={ctx}>\n <Component {...props} />\n </SortableItemContext.Provider>\n );\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAGA,SAAgB,YAAY,eAAe;AAC3C,SAAS,mBAAmB;AAC5B,SAAS,2BAAoD;AAC7D,OAAO,qBAAqB;AAC5B,SAAS,sBAAsB;AAKxB,MAAM,6BAA4C,CAAC,cAAc,CAAC,UAAe;AACtF,QAAM,EAAE,gBAAgB,IAAI,WAAW,eAAe;AACtD,QAAM,EAAE,uBAAuB,YAAY,IAAI,WAAW,cAAc;AAExE,QAAM,KAAM,MAAqC,KAAK,GAAG,SAAS;AAGlE,QAAM,mBAAmB;AAAA,IACvB,OAAO;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,EAAE;AAAA,EACL;AAEA,QAAM,qBAAqB,YAAY,gBAAgB;AAGvD,QAAM,iBAAiB,QAAQ,MAAM;AACnC,QAAI,CAAC;AAAiB,aAAO;AAE7B,UAAM,EAAE,OAAO,UAAU,IAAI;AAE7B,WAAO;AAAA,MACL,GAAG;AAAA,MACH,iCAAiC,cAAc;AAAA,MAC/C;AAAA,MACA;AAAA,IACF;AAAA,EACF,GAAG,CAAC,iBAAiB,oBAAoB,uBAAuB,WAAW,CAAC;AAK5E,QAAM,MAA+B;AAAA,IACnC,OAAO;AAAA,MACL;AAAA,IACF;AAAA,IACA,CAAC,cAAc;AAAA,EACjB;AAEA,SACE,oBAAC,oBAAoB,UAApB;AAAA,IAA6B,OAAO;AAAA,IACnC,8BAAC;AAAA,MAAW,GAAG;AAAA,KAAO;AAAA,GACxB;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useCallback, useMemo } from "react";
|
|
3
4
|
import { DSCheckbox } from "@elliemae/ds-form";
|
|
4
5
|
import { styled } from "@elliemae/ds-system";
|
|
5
6
|
import TreeViewContext from "../TreeViewContext";
|
|
@@ -55,14 +56,16 @@ function CheckboxSelectable(props) {
|
|
|
55
56
|
return false;
|
|
56
57
|
}, [selectedCheckboxes, id]);
|
|
57
58
|
const isDisabled = useMemo(() => isItemDisabled(item), [item, isItemDisabled]);
|
|
58
|
-
return /* @__PURE__ */
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
return /* @__PURE__ */ jsx(StyledCheckboxWrapper, {
|
|
60
|
+
children: /* @__PURE__ */ jsx(DSCheckbox, {
|
|
61
|
+
checked: isChecked,
|
|
62
|
+
disabled: isDisabled,
|
|
63
|
+
className: "em-ds-tree-item-checkbox",
|
|
64
|
+
"data-testid": "tree-item-checkbox",
|
|
65
|
+
onChange: onCheckboxChange,
|
|
66
|
+
tabIndex: "0"
|
|
67
|
+
})
|
|
68
|
+
});
|
|
66
69
|
}
|
|
67
70
|
var CheckboxSelectable_default = CheckboxSelectable;
|
|
68
71
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/CheckboxSelectable.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useCallback, useMemo } from 'react';\nimport { DSCheckbox } from '@elliemae/ds-form';\nimport { styled } from '@elliemae/ds-system';\nimport TreeViewContext from '../TreeViewContext';\nimport { toggleCheckboxItem } from '../utils/selectable-helper';\nimport { filterObject } from '../utils/object-helpers';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\nconst StyledCheckboxWrapper = styled.span`\n padding-top: 3px;\n`;\ninterface PropsT {\n item: DSTreeviewT.Item;\n itemIndex: number;\n}\nfunction CheckboxSelectable(props: PropsT): JSX.Element | null {\n const { item, itemIndex } = props;\n const { id } = item;\n\n const ctx = useContext(TreeViewContext);\n const {\n props: { onSelectionChange, isItemDisabled },\n virtualListHelpers: { scrollToIndex },\n triggerTreeRerender,\n selectedCheckboxes,\n setSelectedCheckboxes,\n } = ctx;\n\n const onCheckboxChange = useCallback(() => {\n const newSelections = toggleCheckboxItem(item);\n const newSelectionHasmap = filterObject<DSTreeviewT.SelectionState>(\n { ...selectedCheckboxes, ...newSelections },\n (value) => value !== false,\n );\n setSelectedCheckboxes(newSelectionHasmap);\n triggerTreeRerender();\n\n const indexAndScrollTo = {\n scrollToItem: () => {\n if (typeof item.virtualIndex === 'number') scrollToIndex(item.virtualIndex);\n },\n itemIndex,\n };\n if (onSelectionChange) onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);\n }, [\n item,\n triggerTreeRerender,\n onSelectionChange,\n itemIndex,\n scrollToIndex,\n selectedCheckboxes,\n setSelectedCheckboxes,\n ]);\n const isChecked = useMemo(() => {\n if (selectedCheckboxes[id] === 'mixed') {\n return 'mixed' as const;\n }\n if (selectedCheckboxes[id] === true) {\n return true;\n }\n return false;\n }, [selectedCheckboxes, id]);\n\n const isDisabled = useMemo(() => isItemDisabled(item), [item, isItemDisabled]);\n\n return (\n <StyledCheckboxWrapper>\n <DSCheckbox\n checked={isChecked}\n disabled={isDisabled}\n className=\"em-ds-tree-item-checkbox\"\n data-testid=\"tree-item-checkbox\"\n onChange={onCheckboxChange}\n tabIndex=\"0\"\n />\n </StyledCheckboxWrapper>\n );\n}\n\nexport default CheckboxSelectable;\n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AAC,oBAAoB,EAAE,CAAC;AAE3B,QAAM,aAAa,QAAQ,MAAM,eAAe,IAAI,GAAG,CAAC,MAAM,cAAc,CAAC;AAE7E,SACE,oBAAC;AAAA,IACC,8BAAC;AAAA,MACC,SAAS;AAAA,MACT,UAAU;AAAA,MACV,WAAU;AAAA,MACV,eAAY;AAAA,MACZ,UAAU;AAAA,MACV,UAAS;AAAA,KACX;AAAA,GACF;AAEJ;AAEA,IAAO,6BAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { styled } from "@elliemae/ds-system";
|
|
4
4
|
import { DSTreeViewPrefix, treeItemBlockName } from "../config/cssClassesConstants";
|
|
5
5
|
const Separator = styled.span`
|
|
@@ -15,10 +15,14 @@ const ChildrenCountDisplayer = (props) => {
|
|
|
15
15
|
const { isGroup, children } = item;
|
|
16
16
|
if (!isGroup)
|
|
17
17
|
return null;
|
|
18
|
-
return /* @__PURE__ */
|
|
18
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
19
19
|
"data-testid": "tree-item-children-count-displayer",
|
|
20
|
-
className
|
|
21
|
-
|
|
20
|
+
className,
|
|
21
|
+
children: [
|
|
22
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
23
|
+
`${children.length} Items`
|
|
24
|
+
]
|
|
25
|
+
});
|
|
22
26
|
};
|
|
23
27
|
export {
|
|
24
28
|
ChildrenCountDisplayer
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/ChildrenCountDisplayer.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/function-component-definition */\nimport React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { DSTreeViewPrefix, treeItemBlockName } from '../config/cssClassesConstants';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\n\nconst Separator = styled.span`\n width: 1px;\n height: 12px;\n margin: 0 8px;\n border-left: 1px solid ${(props) => props.theme.colors.neutral['600']};\n font-size: 12px;\n`;\n\nconst className = `${DSTreeViewPrefix}-${treeItemBlockName}-children-count-displayer`;\n\ninterface PropsT {\n item: DSTreeviewT.Item;\n}\n\nexport const ChildrenCountDisplayer: React.ComponentType<PropsT> = (props) => {\n const { item } = props;\n const { isGroup, children } = item;\n\n if (!isGroup) return null;\n return (\n <span data-testid=\"tree-item-children-count-displayer\" className={className}>\n <Separator />\n {`${children.length} Items`}\n </span>\n );\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAEA,SAAS,cAAc;AACvB,SAAS,kBAAkB,yBAAyB;AAGpD,MAAM,YAAY,OAAO;AAAA;AAAA;AAAA;AAAA,2BAIE,CAAC,UAAU,MAAM,MAAM,OAAO,QAAQ;AAAA;AAAA;AAIjE,MAAM,YAAY,GAAG,oBAAoB;AAMlC,MAAM,yBAAsD,CAAC,UAAU;AAC5E,QAAM,EAAE,KAAK,IAAI;AACjB,QAAM,EAAE,SAAS,SAAS,IAAI;AAE9B,MAAI,CAAC;AAAS,WAAO;AACrB,SACE,qBAAC;AAAA,IAAK,eAAY;AAAA,IAAqC;AAAA,IACrD;AAAA,0BAAC,aAAU;AAAA,MACV,GAAG,SAAS;AAAA;AAAA,GACf;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import { useContext } from "react";
|
|
3
4
|
import { GripperVertical } from "@elliemae/ds-icons";
|
|
4
5
|
import { SortableItemContext } from "../hoc/SortableItemContext";
|
|
5
6
|
const DnDHandle = ({ id, isDragOverlay }) => {
|
|
6
7
|
const { draggableProps } = useContext(SortableItemContext);
|
|
7
8
|
const isDragging = draggableProps && draggableProps.isDragging;
|
|
8
|
-
return /* @__PURE__ */
|
|
9
|
+
return /* @__PURE__ */ createElement(GripperVertical, {
|
|
9
10
|
role: "button",
|
|
10
11
|
...draggableProps && {
|
|
11
12
|
...draggableProps.listeners,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/DnDHandle.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { GripperVertical } from '@elliemae/ds-icons';\nimport { SortableItemContext } from '../hoc/SortableItemContext';\nimport { DSTreeviewT } from '../react-desc-prop-types';\n\ninterface DnDHandleProps {\n id: DSTreeviewT.StringOrNum;\n isDragOverlay: boolean;\n}\n\nexport const DnDHandle = ({ id, isDragOverlay }: DnDHandleProps) => {\n const { draggableProps } = useContext(SortableItemContext);\n\n const isDragging = draggableProps && draggableProps.isDragging;\n\n return (\n <GripperVertical\n role=\"button\"\n {...(draggableProps && {\n ...draggableProps.listeners,\n ...draggableProps.attributes,\n })}\n data-testid=\"drag-handle\"\n data-isactive={draggableProps && !!draggableProps.active}\n data-isdragoverlay={isDragOverlay}\n id={`${id}-drag-handle`}\n key={`${id}-drag-handle`}\n className={`drag-handle ${isDragging ? '' : 'focuseable'}`}\n color={isDragging ? ['neutral', '080'] : ['brand-primary', '800']}\n size=\"s\"\n tabIndex={0}\n />\n );\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,kBAAkB;AAClC,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AAQ7B,MAAM,YAAY,CAAC,EAAE,IAAI,cAAc,MAAsB;AAClE,QAAM,EAAE,eAAe,IAAI,WAAW,mBAAmB;AAEzD,QAAM,aAAa,kBAAkB,eAAe;AAEpD,SACE,8BAAC;AAAA,IACC,MAAK;AAAA,IACJ,GAAI,kBAAkB;AAAA,MACrB,GAAG,eAAe;AAAA,MAClB,GAAG,eAAe;AAAA,IACpB;AAAA,IACA,eAAY;AAAA,IACZ,iBAAe,kBAAkB,CAAC,CAAC,eAAe;AAAA,IAClD,sBAAoB;AAAA,IACpB,IAAI,GAAG;AAAA,IACP,KAAK,GAAG;AAAA,IACR,WAAW,eAAe,aAAa,KAAK;AAAA,IAC5C,OAAO,aAAa,CAAC,WAAW,KAAK,IAAI,CAAC,iBAAiB,KAAK;AAAA,IAChE,MAAK;AAAA,IACL,UAAU;AAAA,GACZ;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { styled } from "@elliemae/ds-system";
|
|
4
4
|
import { DropIndicatorPosition } from "../hoc/SortableItemContext";
|
|
5
5
|
const getPositionStyles = ({ dropIndicatorPosition }) => `
|
|
@@ -24,27 +24,33 @@ const StyledIndicator = styled.div`
|
|
|
24
24
|
background-color: ${({ isDropValid, theme }) => isDropValid ? theme.colors.brand[600] : theme.colors.danger[900]};
|
|
25
25
|
z-index: 20;
|
|
26
26
|
`;
|
|
27
|
-
const CircleIndicator = (style, isDropValid) => /* @__PURE__ */
|
|
27
|
+
const CircleIndicator = (style, isDropValid) => /* @__PURE__ */ jsx("svg", {
|
|
28
28
|
height: "6",
|
|
29
29
|
width: "6",
|
|
30
|
-
style
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
30
|
+
style,
|
|
31
|
+
children: /* @__PURE__ */ jsx("circle", {
|
|
32
|
+
cx: "3",
|
|
33
|
+
cy: "3",
|
|
34
|
+
r: "3",
|
|
35
|
+
strokeWidth: "0",
|
|
36
|
+
fill: isDropValid ? "#1E79C2" : "#C64252"
|
|
37
|
+
})
|
|
38
|
+
});
|
|
38
39
|
const DropIndicator = ({ dropIndicatorPosition, isLast, isDropValid }) => {
|
|
39
40
|
if (![DropIndicatorPosition.After, DropIndicatorPosition.Before].includes(
|
|
40
41
|
dropIndicatorPosition
|
|
41
42
|
))
|
|
42
43
|
return null;
|
|
43
44
|
const safeDropIndicatorPosition = isLast ? DropIndicatorPosition.Before : dropIndicatorPosition;
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
46
|
+
children: [
|
|
47
|
+
CircleIndicator(getCircleStyles({ dropIndicatorPosition: safeDropIndicatorPosition }), isDropValid),
|
|
48
|
+
/* @__PURE__ */ jsx(StyledIndicator, {
|
|
49
|
+
dropIndicatorPosition: safeDropIndicatorPosition,
|
|
50
|
+
isDropValid
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
});
|
|
48
54
|
};
|
|
49
55
|
var DropIndicator_default = DropIndicator;
|
|
50
56
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/DropIndicator.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { DropIndicatorPosition } from '../hoc/SortableItemContext';\n\ninterface DropIndicatorProps {\n vertical?: boolean;\n dropIndicatorPosition: DropIndicatorPosition | false;\n isLast?: boolean;\n isDropValid?: boolean;\n}\n\nconst getPositionStyles = ({ dropIndicatorPosition }: DropIndicatorProps) => `\n top: ${dropIndicatorPosition === DropIndicatorPosition.Before ? '0' : 'unset'};\n bottom: ${dropIndicatorPosition === DropIndicatorPosition.After ? '0' : 'unset'};\n left: -2px;\n `;\n\nconst getCircleStyles = ({ dropIndicatorPosition }: DropIndicatorProps) => ({\n position: 'absolute',\n zIndex: 20,\n top: dropIndicatorPosition === DropIndicatorPosition.After ? 'unset' : '-2px',\n bottom: dropIndicatorPosition === DropIndicatorPosition.Before ? 'unset' : '-2px',\n left: '0px',\n opacity: 1,\n});\n\nconst StyledIndicator = styled.div<DropIndicatorProps>`\n position: absolute;\n ${getPositionStyles}\n box-sizing: border-box;\n width: ${(props) => (props.vertical ? '2px' : '100%')};\n height: ${(props) => (props.vertical ? '100%' : '2px')};\n background-color: ${({ isDropValid, theme }) => (isDropValid ? theme.colors.brand[600] : theme.colors.danger[900])};\n z-index: 20;\n`;\n\nconst CircleIndicator = (style: Record<string, unknown>, isDropValid: boolean | null | undefined) => (\n <svg height=\"6\" width=\"6\" style={style}>\n <circle cx=\"3\" cy=\"3\" r=\"3\" strokeWidth=\"0\" fill={isDropValid ? '#1E79C2' : '#C64252'} />\n </svg>\n);\n\nconst DropIndicator: React.ComponentType<DropIndicatorProps> = ({ dropIndicatorPosition, isLast, isDropValid }) => {\n if (\n ![DropIndicatorPosition.After, DropIndicatorPosition.Before].includes(\n dropIndicatorPosition as DropIndicatorPosition,\n )\n )\n return null;\n\n const safeDropIndicatorPosition = isLast ? DropIndicatorPosition.Before : dropIndicatorPosition;\n\n return (\n <>\n {CircleIndicator(getCircleStyles({ dropIndicatorPosition: safeDropIndicatorPosition }), isDropValid)}\n <StyledIndicator dropIndicatorPosition={safeDropIndicatorPosition} isDropValid={isDropValid} />\n </>\n );\n};\n\nexport default DropIndicator;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAS,cAAc;AACvB,SAAS,6BAA6B;AAStC,MAAM,oBAAoB,CAAC,EAAE,sBAAsB,MAA0B;AAAA,aAChE,0BAA0B,sBAAsB,S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
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useCallback } from "react";
|
|
3
4
|
import Button from "@elliemae/ds-button";
|
|
4
5
|
import { ArrowheadDown, ArrowheadRight } from "@elliemae/ds-icons";
|
|
5
6
|
import { toggleItemExpand } from "../utils/group-expands-helpers";
|
|
@@ -21,16 +22,15 @@ const ExpandCaret = (props) => {
|
|
|
21
22
|
virtualListHelpers: { scrollToIndex }
|
|
22
23
|
} = ctx;
|
|
23
24
|
if (isGroupOrHasChildrens)
|
|
24
|
-
return /* @__PURE__ */
|
|
25
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
25
26
|
buttonType: "text",
|
|
26
27
|
className: "expandable-arrow",
|
|
27
28
|
"data-testid": "tree-item-expand-toggle",
|
|
28
|
-
|
|
29
|
-
icon: isExpanded ? /* @__PURE__ */ React2.createElement(ArrowheadDown, {
|
|
29
|
+
icon: isExpanded ? /* @__PURE__ */ jsx(ArrowheadDown, {
|
|
30
30
|
size: "s",
|
|
31
31
|
"data-testid": "ic-arrow-head-down",
|
|
32
32
|
color: ["brand-primary", "800"]
|
|
33
|
-
}) : /* @__PURE__ */
|
|
33
|
+
}) : /* @__PURE__ */ jsx(ArrowheadRight, {
|
|
34
34
|
size: "s",
|
|
35
35
|
"data-testid": "ic-arrow-head-right",
|
|
36
36
|
color: ["brand-primary", "800"]
|
|
@@ -58,8 +58,8 @@ const ExpandCaret = (props) => {
|
|
|
58
58
|
},
|
|
59
59
|
size: "s",
|
|
60
60
|
tabIndex: -1
|
|
61
|
-
});
|
|
62
|
-
return /* @__PURE__ */
|
|
61
|
+
}, `${id}-expand-addon`);
|
|
62
|
+
return /* @__PURE__ */ jsx("div", {
|
|
63
63
|
style: { width: "24px" }
|
|
64
64
|
});
|
|
65
65
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/ExpandCaret.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useCallback } from 'react';\nimport Button from '@elliemae/ds-button';\nimport { ArrowheadDown, ArrowheadRight } from '@elliemae/ds-icons';\nimport { toggleItemExpand } from '../utils/group-expands-helpers';\nimport { focusItem } from '../utils/tree-helpers';\nimport TreeViewContext from '../TreeViewContext';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\n\ninterface PropsT {\n item: DSTreeviewT.Item;\n}\n\nexport const ExpandCaret = (props: PropsT): JSX.Element | null => {\n const defaultHandleExpandGroup = useCallback(toggleItemExpand, []);\n const { item } = props;\n const { id, isExpanded, isGroup, children } = item;\n const isGroupOrHasChildrens = isGroup || (Array.isArray(children) && children.length > 0);\n const ctx = useContext(TreeViewContext);\n const {\n props: { onItemFocus },\n handleExpandGroup = defaultHandleExpandGroup,\n triggerTreeRerender,\n updateUserExpandedState,\n setLatestToggledItem,\n setFocusedItem,\n virtualListHelpers: { scrollToIndex },\n } = ctx;\n\n if (isGroupOrHasChildrens)\n return (\n <Button\n buttonType=\"text\"\n className=\"expandable-arrow\"\n data-testid=\"tree-item-expand-toggle\"\n key={`${id}-expand-addon`}\n icon={\n isExpanded ? (\n <ArrowheadDown size=\"s\" data-testid=\"ic-arrow-head-down\" color={['brand-primary', '800']} />\n ) : (\n <ArrowheadRight size=\"s\" data-testid=\"ic-arrow-head-right\" color={['brand-primary', '800']} />\n )\n }\n onMouseDown={(e: React.MouseEvent) => {\n // prevent focusing the caret\n if (e) {\n e.preventDefault();\n }\n }}\n onClick={(e) => {\n e.stopPropagation();\n if (e) handleExpandGroup(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex, e);\n setLatestToggledItem(item);\n const itemVitualIndex = item.virtualIndex;\n if (typeof itemVitualIndex === 'number') {\n onItemFocus({\n itemIndex: itemVitualIndex,\n scrollToItem: (opts = { align: 'start' }) => scrollToIndex(itemVitualIndex, opts),\n item,\n });\n }\n setFocusedItem(item);\n focusItem(item);\n }}\n size=\"s\"\n tabIndex={-1}\n />\n );\n return <div style={{ width: '24px' }} />;\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,mBAAmB;AAC/C,OAAO,YAAY;AACnB,SAAS,eAAe,sBAAsB;AAC9C,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B,OAAO,qBAAqB;AAOrB,MAAM,cAAc,CAAC,UAAsC;AAChE,QAAM,2BAA2B,YAAY,kBAAkB,CAAC,CAAC;AACjE,QAAM,EAAE,KAAK,IAAI;AACjB,QAAM,EAAE,IAAI,YAAY,SAAS,SAAS,IAAI;AAC9C,QAAM,wBAAwB,WAAY,MAAM,QAAQ,QAAQ,KAAK,SAAS,SAAS;AACvF,QAAM,MAAM,WAAW,eAAe;AACtC,QAAM;AAAA,IACJ,OAAO,EAAE,YAAY;AAAA,IACrB,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,oBAAoB,EAAE,cAAc;AAAA,EACtC,IAAI;AAEJ,MAAI;AACF,WACE,oBAAC;AAAA,MACC,YAAW;AAAA,MACX,WAAU;AAAA,MACV,eAAY;AAAA,MAEZ,MACE,aACE,oBAAC;AAAA,QAAc,MAAK;AAAA,QAAI,eAAY;AAAA,QAAqB,OAAO,CAAC,iBAAiB,KAAK;AAAA,OAAG,IAE1F,oBAAC;AAAA,QAAe,MAAK;AAAA,QAAI,eAAY;AAAA,QAAsB,OAAO,CAAC,iBAAiB,KAAK;AAAA,OAAG;AAAA,MAGhG,aAAa,CAAC,MAAwB;AAEpC,YAAI,GAAG;AACL,YAAE,eAAe;AAAA,QACnB;AAAA,MACF;AAAA,MACA,SAAS,CAAC,MAAM;AACd,UAAE,gBAAgB;AAClB,YAAI;AAAG,4BAAkB,MAAM,qBAAqB,yBAAyB,eAAe,CAAC;AAC7F,6BAAqB,IAAI;AACzB,cAAM,kBAAkB,KAAK;AAC7B,YAAI,OAAO,oBAAoB,UAAU;AACvC,sBAAY;AAAA,YACV,WAAW;AAAA,YACX,cAAc,CAAC,OAAO,EAAE,OAAO,QAAQ,MAAM,cAAc,iBAAiB,IAAI;AAAA,YAChF;AAAA,UACF,CAAC;AAAA,QACH;AACA,uBAAe,IAAI;AACnB,kBAAU,IAAI;AAAA,MAChB;AAAA,MACA,MAAK;AAAA,MACL,UAAU;AAAA,OA9BL,GAAG,iBA+BV;AAEJ,SAAO,oBAAC;AAAA,IAAI,OAAO,EAAE,OAAO,OAAO;AAAA,GAAG;AACxC;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
const getItemNestingLeftPadding = (level, opts) => {
|
|
4
4
|
const { spaceForNestingLevel = 1.5 } = opts;
|
|
5
5
|
const groupLeftPadding = spaceForNestingLevel * (level - 1);
|
|
@@ -13,7 +13,7 @@ const NestingSpace = (props) => {
|
|
|
13
13
|
const itemNestingLeftPadding = getItemNestingLeftPadding(treeDepth - 1, {
|
|
14
14
|
spaceForNestingLevel
|
|
15
15
|
});
|
|
16
|
-
return /* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ jsx("div", {
|
|
17
17
|
"data-testid": "tree-item-nested-space",
|
|
18
18
|
style: { width: itemNestingLeftPadding }
|
|
19
19
|
});
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/NestingSpace.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\n\nconst getItemNestingLeftPadding = (level: number, opts: { spaceForNestingLevel: number }) => {\n const { spaceForNestingLevel = 1.5 } = opts;\n const groupLeftPadding = spaceForNestingLevel * (level - 1);\n const finalLeftPadding = groupLeftPadding + spaceForNestingLevel - 0.1;\n // root level left-padding would be negative and would not be applied\n // if \"root-level\" nesting, then defaults to 0 left-padding.\n return finalLeftPadding > 0 ? `${finalLeftPadding}em` : '0';\n};\n\ntype NestingSpacePropsType = {\n item: DSTreeviewT.Item;\n spaceForNestingLevel: number;\n};\n\nexport const NestingSpace = (props: NestingSpacePropsType): JSX.Element | null => {\n const { item, spaceForNestingLevel } = props;\n const { treeDepth } = item;\n if (treeDepth) {\n const itemNestingLeftPadding = getItemNestingLeftPadding(treeDepth - 1, {\n spaceForNestingLevel,\n });\n\n return <div data-testid=\"tree-item-nested-space\" style={{ width: itemNestingLeftPadding }} />;\n }\n return null;\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAGA,MAAM,4BAA4B,CAAC,OAAe,SAA2C;AAC3F,QAAM,EAAE,uBAAuB,IAAI,IAAI;AACvC,QAAM,mBAAmB,wBAAwB,QAAQ;AACzD,QAAM,mBAAmB,mBAAmB,uBAAuB;AAGnE,SAAO,mBAAmB,IAAI,GAAG,uBAAuB;AAC1D;AAOO,MAAM,eAAe,CAAC,UAAqD;AAChF,QAAM,EAAE,MAAM,qBAAqB,IAAI;AACvC,QAAM,EAAE,UAAU,IAAI;AACtB,MAAI,WAAW;AACb,UAAM,yBAAyB,0BAA0B,YAAY,GAAG;AAAA,MACtE;AAAA,IACF,CAAC;AAED,WAAO,oBAAC;AAAA,MAAI,eAAY;AAAA,MAAyB,OAAO,EAAE,OAAO,uBAAuB;AAAA,KAAG;AAAA,EAC7F;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useCallback, useMemo } from "react";
|
|
3
4
|
import { DSRadio } from "@elliemae/ds-form";
|
|
4
5
|
import TreeViewContext from "../TreeViewContext";
|
|
5
6
|
function RadioSelectable(props) {
|
|
@@ -28,7 +29,7 @@ function RadioSelectable(props) {
|
|
|
28
29
|
}, [id, setSelectedCheckboxes, itemIndex, onSelectionChange, item, scrollToIndex]);
|
|
29
30
|
const radioName = useMemo(() => `radios-${uniqueTreeViewUUID}`, [uniqueTreeViewUUID]);
|
|
30
31
|
const isDisabled = useMemo(() => isItemDisabled(item), [item, isItemDisabled]);
|
|
31
|
-
return /* @__PURE__ */
|
|
32
|
+
return /* @__PURE__ */ jsx(DSRadio, {
|
|
32
33
|
checked: selectedCheckboxes[id] === true,
|
|
33
34
|
name: radioName,
|
|
34
35
|
disabled: isDisabled,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/RadioSelectable.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useCallback, useMemo } from 'react';\nimport { DSRadio } from '@elliemae/ds-form';\nimport TreeViewContext from '../TreeViewContext';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\ninterface PropsT {\n item: DSTreeviewT.Item;\n itemIndex: number;\n}\nfunction RadioSelectable(props: PropsT) {\n const { item, itemIndex } = props;\n\n const ctx = useContext(TreeViewContext);\n const {\n props: { onSelectionChange, isItemDisabled },\n virtualListHelpers: { scrollToIndex },\n uniqueTreeViewUUID,\n selectedCheckboxes,\n setSelectedCheckboxes,\n } = ctx;\n\n const { id } = item;\n\n const onRadioChange = useCallback(() => {\n const newSelectionHasmap = { [id]: true };\n setSelectedCheckboxes(newSelectionHasmap);\n const indexAndScrollTo = {\n scrollToItem: () => {\n if (item.virtualIndex) scrollToIndex(item.virtualIndex);\n },\n itemIndex,\n };\n if (onSelectionChange) onSelectionChange(newSelectionHasmap, item, indexAndScrollTo);\n }, [id, setSelectedCheckboxes, itemIndex, onSelectionChange, item, scrollToIndex]);\n\n const radioName = useMemo(() => `radios-${uniqueTreeViewUUID}`, [uniqueTreeViewUUID]);\n\n const isDisabled = useMemo(() => isItemDisabled(item), [item, isItemDisabled]);\n\n return (\n <DSRadio\n checked={selectedCheckboxes[id] === true}\n name={radioName}\n disabled={isDisabled}\n className=\"em-ds-tree-item-radio\"\n data-testid=\"tree-item-radio\"\n onChange={onRadioChange}\n tabIndex={0}\n />\n );\n}\n\nexport default RadioSelectable;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,aAAa,eAAe;AACxD,SAAS,eAAe;AACxB,OAAO,qBAAqB;AAM5B,SAAS,gBAAgB,OAAe;AACtC,QAAM,EAAE,MAAM,UAAU,IAAI;AAE5B,QAAM,MAAM,WAAW,eAAe;AACtC,QAAM;AAAA,IACJ,OAAO,EAAE,mBAAmB,eAAe;AAAA,IAC3C,oBAAoB,EAAE,cAAc;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,EAAE,GAAG,IAAI;AAEf,QAAM,gBAAgB,YAAY,MAAM;AACtC,UAAM,qBAAqB,EAAE,CAAC,KAAK,KAAK;AACxC,0BAAsB,kBAAkB;AACxC,UAAM,mBAAmB;AAAA,MACvB,cAAc,MAAM;AAClB,YAAI,KAAK;AAAc,wBAAc,KAAK,YAAY;AAAA,MACxD;AAAA,MACA;AAAA,IACF;AACA,QAAI;AAAmB,wBAAkB,oBAAoB,MAAM,gBAAgB;AAAA,EACrF,GAAG,CAAC,IAAI,uBAAuB,WAAW,mBAAmB,MAAM,aAAa,CAAC;AAEjF,QAAM,YAAY,QAAQ,MAAM,UAAU,sBAAsB,CAAC,kBAAkB,CAAC;AAEpF,QAAM,aAAa,QAAQ,MAAM,eAAe,IAAI,GAAG,CAAC,MAAM,cAAc,CAAC;AAE7E,SACE,oBAAC;AAAA,IACC,SAAS,mBAAmB,QAAQ;AAAA,IACpC,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAU;AAAA,IACV,eAAY;AAAA,IACZ,UAAU;AAAA,IACV,UAAU;AAAA,GACZ;AAEJ;AAEA,IAAO,0BAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useMemo, useCallback } from "react";
|
|
3
4
|
import { aggregatedClasses } from "@elliemae/ds-classnames";
|
|
4
5
|
import RadioSelectable from "./RadioSelectable";
|
|
5
6
|
import CheckboxSelectable from "./CheckboxSelectable";
|
|
@@ -118,7 +119,7 @@ const TreeItem = (props) => {
|
|
|
118
119
|
);
|
|
119
120
|
const childrenLength = useMemo(() => children?.length ?? 0, [children]);
|
|
120
121
|
const ariaLabel = `${itemLabelText}${showChildrenAmount && childrenLength > 0 ? `, ${childrenLength} Items` : ""}`;
|
|
121
|
-
return /* @__PURE__ */
|
|
122
|
+
return /* @__PURE__ */ jsxs(TreeListItem, {
|
|
122
123
|
tabIndex: 0,
|
|
123
124
|
onMouseLeave: () => {
|
|
124
125
|
if (hoverItem?.id === item.id) {
|
|
@@ -138,29 +139,46 @@ const TreeItem = (props) => {
|
|
|
138
139
|
"aria-label": ariaLabel,
|
|
139
140
|
"data-id": item.id,
|
|
140
141
|
"data-index": item.virtualIndex,
|
|
141
|
-
onKeyDown: onItemKeyDown
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
142
|
+
onKeyDown: onItemKeyDown,
|
|
143
|
+
children: [
|
|
144
|
+
/* @__PURE__ */ jsxs(TreeListItemAddonsWrapper, {
|
|
145
|
+
children: [
|
|
146
|
+
withDragAndDrop ? /* @__PURE__ */ jsx(DnDHandle, {
|
|
147
|
+
id,
|
|
148
|
+
isDragOverlay
|
|
149
|
+
}) : null,
|
|
150
|
+
withRadioChecks && !isDragOverlay ? /* @__PURE__ */ jsx(RadioSelectable, {
|
|
151
|
+
item,
|
|
152
|
+
itemIndex
|
|
153
|
+
}) : null,
|
|
154
|
+
withCheckboxChecks && !isDragOverlay ? /* @__PURE__ */ jsx(CheckboxSelectable, {
|
|
155
|
+
item,
|
|
156
|
+
itemIndex
|
|
157
|
+
}) : null,
|
|
158
|
+
!isDragOverlay && /* @__PURE__ */ jsx(NestingSpace, {
|
|
159
|
+
item,
|
|
160
|
+
spaceForNestingLevel
|
|
161
|
+
}),
|
|
162
|
+
!isDragOverlay && /* @__PURE__ */ jsx(ExpandCaret, {
|
|
163
|
+
item
|
|
164
|
+
}),
|
|
165
|
+
!disableIcons ? /* @__PURE__ */ jsx(Icon, {
|
|
166
|
+
item
|
|
167
|
+
}) : null
|
|
168
|
+
]
|
|
169
|
+
}),
|
|
170
|
+
/* @__PURE__ */ jsx(TreeItemText, {
|
|
171
|
+
item
|
|
172
|
+
}),
|
|
173
|
+
rightAddons && /* @__PURE__ */ jsx(TreeListItemAddonsWrapper, {
|
|
174
|
+
children: typeof rightAddons === "function" ? rightAddons(item) : rightAddons
|
|
175
|
+
}),
|
|
176
|
+
/* @__PURE__ */ jsx(DropIndicator, {
|
|
177
|
+
dropIndicatorPosition,
|
|
178
|
+
isDropValid
|
|
179
|
+
})
|
|
180
|
+
]
|
|
181
|
+
});
|
|
164
182
|
};
|
|
165
183
|
var TreeItem_default = withDnDSortableItemContext(TreeItem);
|
|
166
184
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/TreeItem.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable max-lines */\nimport React, { useContext, useMemo, useCallback } from 'react';\n\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\n\nimport RadioSelectable from './RadioSelectable';\nimport CheckboxSelectable from './CheckboxSelectable';\nimport TreeViewContext from '../TreeViewContext';\nimport { setMultipleRefs } from '../utils/refs-helpers';\nimport { useOnItemKeyDown } from '../utils/keyboard-helpers';\nimport { NestingSpace } from './NestingSpace';\nimport { Icon } from './Icon';\nimport { ExpandCaret } from './ExpandCaret';\nimport { TreeItemText } from './TreeItemText';\nimport { DSTreeViewPrefix, treeItemBlockName } from '../config/cssClassesConstants';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\nimport { DnDHandle } from './DnDHandle';\nimport { withDnDSortableItemContext } from '../hoc/WithDnDSortableItemContext';\nimport { DropIndicatorPosition, SortableItemContext } from '../hoc/SortableItemContext';\nimport DropIndicator from './DropIndicator';\n\nexport const TreeListItem = aggregatedClasses('li', {\n 'data-testid': treeItemBlockName,\n role: 'treeitem',\n // temp fix untill we move to styled components\n})(treeItemBlockName) as unknown as React.ComponentType<React.ComponentProps<'li'>>;\n\nexport const TreeListItemAddonsWrapper = aggregatedClasses('div')(\n treeItemBlockName,\n 'addons',\n // temp fix untill we move to styled components\n) as unknown as React.ComponentType;\n\ninterface PropsT {\n item: DSTreeviewT.Item;\n itemIndex: number;\n isDragOverlay?: boolean;\n virtualItemRef?: React.RefObject<HTMLLIElement>;\n itemWrapperStyle?: { [key: string]: unknown };\n spaceForNestingLevel?: number;\n}\nexport const TreeItem = (props: PropsT): JSX.Element => {\n const {\n item,\n itemIndex,\n itemWrapperStyle = {},\n virtualItemRef,\n spaceForNestingLevel = 1.5,\n isDragOverlay = false,\n } = props;\n const { id, node, children } = item;\n const { nodeItemRef } = node.model;\n\n const { draggableProps } = useContext(SortableItemContext);\n\n const onItemKeyDown = useOnItemKeyDown(item, draggableProps);\n\n const ctx = useContext(TreeViewContext);\n const {\n props: { disableIcons, rightAddons, onItemClick, onItemFocus, rowSize, labelOverflow, nameKey, showChildrenAmount },\n withRadioChecks,\n withCheckboxChecks,\n withDragAndDrop,\n selectedItem,\n selectedCheckboxes,\n hoverItem,\n virtualListHelpers: { scrollToIndex },\n setHoverItem,\n setSelectedItem,\n setFocusedItem,\n } = ctx;\n const itemLabelText = item[nameKey] as DSTreeviewT.Item['name'];\n\n // Sortable Items needs to update\n // - the virtual list ref (for react-virtual requirement)\n // - nodeItemRef which is a prop avaiable in the TreeModel nodes\n // - the drag and drop node reference\n const setItemRefs: React.LegacyRef<HTMLLIElement> | undefined = (ref: HTMLLIElement) => {\n setMultipleRefs(\n virtualItemRef,\n !isDragOverlay && nodeItemRef,\n !isDragOverlay && draggableProps && draggableProps.setNodeRef,\n )(ref);\n };\n\n const dropIndicatorPosition =\n draggableProps && draggableProps.shouldShowDropIndicatorPosition && draggableProps.dropIndicatorPosition;\n\n const isDropIndicatorPositionInside = dropIndicatorPosition === DropIndicatorPosition.Inside;\n\n const isDragging = draggableProps && draggableProps.isDragging;\n\n const isDropValid = draggableProps && draggableProps.isDropValid;\n\n const dropPreviewClassName = useMemo(() => {\n if (isDropIndicatorPositionInside) {\n const className = `${DSTreeViewPrefix}-${treeItemBlockName}${isDropValid ? '--valid' : '--invalid'}-drop-in`;\n return className;\n }\n return '';\n }, [isDropIndicatorPositionInside, isDropValid]);\n\n const dragOverlayClassName = useMemo(() => (isDragOverlay ? 'drag-overlay' : ''), [isDragOverlay]);\n\n const selectedClassName = useMemo(\n () => (selectedItem?.id === item.id && !isDragOverlay ? 'selected' : ''),\n [isDragOverlay, item.id, selectedItem?.id],\n );\n const hoverClassName = useMemo(\n () => (!isDragOverlay && hoverItem?.id === item.id && !isDragging ? 'hover' : ''),\n [isDragOverlay, hoverItem?.id, item.id, isDragging],\n );\n const fixedHeightClassname = useMemo(() => {\n if (labelOverflow === 'truncate') {\n if (rowSize === 'compact') return `${DSTreeViewPrefix}-${treeItemBlockName}--fixed-height-compact`;\n return `${DSTreeViewPrefix}-${treeItemBlockName}--fixed-height`;\n }\n return '';\n }, [labelOverflow, rowSize]);\n\n const isDraggingClassname = useMemo(() => {\n if (isDragging) return `${DSTreeViewPrefix}-${treeItemBlockName}--dragging`;\n return '';\n }, [isDragging]);\n\n const finalClassName = useMemo(\n () =>\n `${dropPreviewClassName} ${fixedHeightClassname} ${selectedClassName} ${hoverClassName} ${dragOverlayClassName} ${isDraggingClassname}`,\n [\n dropPreviewClassName,\n fixedHeightClassname,\n selectedClassName,\n hoverClassName,\n dragOverlayClassName,\n isDraggingClassname,\n ],\n );\n\n const handleItemClick = useCallback(\n (e: React.MouseEvent<HTMLLIElement>) => {\n onItemClick(item, e);\n setFocusedItem(item);\n setSelectedItem(item);\n const itemVirtualIndex = typeof item.virtualIndex === 'number' ? item.virtualIndex : -1;\n onItemFocus({\n itemIndex: itemVirtualIndex,\n scrollToItem: (opts = { align: 'start' }) => scrollToIndex(itemVirtualIndex, opts),\n item,\n });\n },\n [item, scrollToIndex, onItemClick, onItemFocus, setSelectedItem, setFocusedItem],\n );\n\n const childrenLength = useMemo(() => children?.length ?? 0, [children]);\n\n const ariaLabel = `${itemLabelText}${showChildrenAmount && childrenLength > 0 ? `, ${childrenLength} Items` : ''}`;\n\n return (\n <TreeListItem\n tabIndex={0}\n onMouseLeave={() => {\n if (hoverItem?.id === item.id) {\n setHoverItem(null);\n }\n }}\n onMouseEnter={() => {\n setHoverItem(item);\n }}\n onClick={handleItemClick}\n onBlur={() => setFocusedItem(null)}\n ref={setItemRefs}\n style={{ ...itemWrapperStyle }}\n className={finalClassName}\n aria-expanded={!!item.isExpanded}\n aria-selected={!!selectedCheckboxes[item.id]}\n aria-label={ariaLabel}\n data-id={item.id}\n data-index={item.virtualIndex}\n onKeyDown={onItemKeyDown}\n >\n <TreeListItemAddonsWrapper>\n {withDragAndDrop ? <DnDHandle id={id} isDragOverlay={isDragOverlay} /> : null}\n {withRadioChecks && !isDragOverlay ? <RadioSelectable item={item} itemIndex={itemIndex} /> : null}\n {withCheckboxChecks && !isDragOverlay ? <CheckboxSelectable item={item} itemIndex={itemIndex} /> : null}\n {!isDragOverlay && <NestingSpace item={item} spaceForNestingLevel={spaceForNestingLevel} />}\n {!isDragOverlay && <ExpandCaret item={item} />}\n {!disableIcons ? <Icon item={item} /> : null}\n </TreeListItemAddonsWrapper>\n <TreeItemText item={item} />\n {rightAddons && (\n <TreeListItemAddonsWrapper>\n {typeof rightAddons === 'function' ? rightAddons(item) : rightAddons}\n </TreeListItemAddonsWrapper>\n )}\n <DropIndicator dropIndicatorPosition={dropIndicatorPosition} isDropValid={isDropValid} />\n </TreeListItem>\n );\n};\n\nexport default withDnDSortableItemContext(TreeItem);\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAGA,SAAgB,YAAY,SAAS,mBAAmB;AAExD,SAAS,yBAAyB;AAElC,OAAO,qBAAqB;AAC5B,OAAO,wBAAwB;AAC/B,OAAO,qBAAqB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAC7B,SAAS,YAAY;AACrB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,yBAAyB;AAEpD,SAAS,iBAAiB;AAC1B,SAAS,kCAAkC;AAC3C,SAAS,uBAAuB,2BAA2B;AAC3D,OAAO,mBAAmB;AAEnB,MAAM,eAAe,kBAAkB,MAAM;AAAA,EAClD,eAAe;AAAA,EACf,MAAM;AAER,CAAC,EAAE,iBAAi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oBAAC;AAAA,QAAc;AAAA,QAA8C;AAAA,OAA0B;AAAA;AAAA,GACzF;AAEJ;AAEA,IAAO,mBAAQ,2BAA2B,QAAQ;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useContext } from "react";
|
|
3
4
|
import Highlighter from "react-highlight-words";
|
|
4
5
|
import { SimpleTruncatedTooltipText } from "@elliemae/ds-truncated-tooltip-text";
|
|
5
6
|
import { aggregatedClasses } from "@elliemae/ds-classnames";
|
|
@@ -10,10 +11,11 @@ const ItemContent = aggregatedClasses("div")(`${treeItemBlockName}-content`);
|
|
|
10
11
|
const ItemValue = aggregatedClasses("span")(treeItemBlockName, "value");
|
|
11
12
|
const classNameModifierWrapAll = `${DSTreeViewPrefix}-${treeItemBlockName}__value--wrap-all`;
|
|
12
13
|
const classNameModifierTruncate = `${DSTreeViewPrefix}-${treeItemBlockName}__value--truncate`;
|
|
13
|
-
const CustomHighlight = ({ children }) => /* @__PURE__ */
|
|
14
|
+
const CustomHighlight = ({ children }) => /* @__PURE__ */ jsx("mark", {
|
|
14
15
|
className: "tree-text-highlight",
|
|
15
|
-
"data-testid": "tree-text-highlight"
|
|
16
|
-
|
|
16
|
+
"data-testid": "tree-text-highlight",
|
|
17
|
+
children
|
|
18
|
+
});
|
|
17
19
|
const TreeItemText = (props) => {
|
|
18
20
|
const { item } = props;
|
|
19
21
|
const ctx = useContext(TreeViewContext);
|
|
@@ -24,47 +26,69 @@ const TreeItemText = (props) => {
|
|
|
24
26
|
const itemLabelText = item[nameKey];
|
|
25
27
|
if (searchQuery) {
|
|
26
28
|
if (labelOverflow === "truncate") {
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
value: /* @__PURE__ */
|
|
29
|
+
return /* @__PURE__ */ jsx(SimpleTruncatedTooltipText, {
|
|
30
|
+
value: /* @__PURE__ */ jsxs(Fragment, {
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ jsx(Highlighter, {
|
|
33
|
+
autoEscape: true,
|
|
34
|
+
highlightTag: CustomHighlight,
|
|
35
|
+
searchWords: [searchQuery],
|
|
36
|
+
textToHighlight: itemLabelText
|
|
37
|
+
}),
|
|
38
|
+
showChildrenAmount ? /* @__PURE__ */ jsx(ChildrenCountDisplayer, {
|
|
39
|
+
item
|
|
40
|
+
}) : null
|
|
41
|
+
]
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx(Highlighter, {
|
|
29
48
|
autoEscape: true,
|
|
30
49
|
highlightTag: CustomHighlight,
|
|
31
50
|
searchWords: [searchQuery],
|
|
32
51
|
textToHighlight: itemLabelText
|
|
33
|
-
}),
|
|
52
|
+
}),
|
|
53
|
+
showChildrenAmount ? /* @__PURE__ */ jsx(ChildrenCountDisplayer, {
|
|
34
54
|
item
|
|
35
|
-
}) : null
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Highlighter, {
|
|
39
|
-
autoEscape: true,
|
|
40
|
-
highlightTag: CustomHighlight,
|
|
41
|
-
searchWords: [searchQuery],
|
|
42
|
-
textToHighlight: itemLabelText
|
|
43
|
-
}), showChildrenAmount ? /* @__PURE__ */ React2.createElement(ChildrenCountDisplayer, {
|
|
44
|
-
item
|
|
45
|
-
}) : null);
|
|
55
|
+
}) : null
|
|
56
|
+
]
|
|
57
|
+
});
|
|
46
58
|
}
|
|
47
59
|
if (labelOverflow === "truncate") {
|
|
48
|
-
return /* @__PURE__ */
|
|
49
|
-
value: /* @__PURE__ */
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
return /* @__PURE__ */ jsx(SimpleTruncatedTooltipText, {
|
|
61
|
+
value: /* @__PURE__ */ jsxs(Fragment, {
|
|
62
|
+
children: [
|
|
63
|
+
itemLabelText,
|
|
64
|
+
showChildrenAmount ? /* @__PURE__ */ jsx(ChildrenCountDisplayer, {
|
|
65
|
+
item
|
|
66
|
+
}) : null
|
|
67
|
+
]
|
|
68
|
+
})
|
|
52
69
|
});
|
|
53
70
|
}
|
|
54
|
-
return /* @__PURE__ */
|
|
55
|
-
|
|
56
|
-
|
|
71
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
72
|
+
children: [
|
|
73
|
+
itemLabelText,
|
|
74
|
+
showChildrenAmount ? /* @__PURE__ */ jsx(ChildrenCountDisplayer, {
|
|
75
|
+
item
|
|
76
|
+
}) : null
|
|
77
|
+
]
|
|
78
|
+
});
|
|
57
79
|
}, [item, searchQuery, nameKey, showChildrenAmount, labelOverflow]);
|
|
58
80
|
let className = "";
|
|
59
81
|
if (labelOverflow === "wrap-all")
|
|
60
82
|
className += `${classNameModifierWrapAll} `;
|
|
61
83
|
if (labelOverflow === "truncate")
|
|
62
84
|
className += `${classNameModifierTruncate} `;
|
|
63
|
-
return /* @__PURE__ */
|
|
64
|
-
"data-testid": `${treeItemBlockName}-content
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
85
|
+
return /* @__PURE__ */ jsx(ItemContent, {
|
|
86
|
+
"data-testid": `${treeItemBlockName}-content`,
|
|
87
|
+
children: /* @__PURE__ */ jsx(ItemValue, {
|
|
88
|
+
className,
|
|
89
|
+
children: Text
|
|
90
|
+
})
|
|
91
|
+
});
|
|
68
92
|
};
|
|
69
93
|
export {
|
|
70
94
|
TreeItemText
|