@elliemae/ds-shuttle-v2 3.6.0-next.7
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/DSShuttleV2.js +57 -0
- package/dist/cjs/DSShuttleV2.js.map +7 -0
- package/dist/cjs/config/configureAutoCalculated.js +131 -0
- package/dist/cjs/config/configureAutoCalculated.js.map +7 -0
- package/dist/cjs/config/itemMovementHelpers.js +148 -0
- package/dist/cjs/config/itemMovementHelpers.js.map +7 -0
- package/dist/cjs/config/useFocusTracker/index.js +38 -0
- package/dist/cjs/config/useFocusTracker/index.js.map +7 -0
- package/dist/cjs/config/useFocusTracker/useFocusActionTrackers.js +148 -0
- package/dist/cjs/config/useFocusTracker/useFocusActionTrackers.js.map +7 -0
- package/dist/cjs/config/useFocusTracker/useFocusItemTracker.js +95 -0
- package/dist/cjs/config/useFocusTracker/useFocusItemTracker.js.map +7 -0
- package/dist/cjs/config/useFocusTracker/useFocusRegionTrackers.js +79 -0
- package/dist/cjs/config/useFocusTracker/useFocusRegionTrackers.js.map +7 -0
- package/dist/cjs/config/useFocusTracker/useFocusTracker.js +48 -0
- package/dist/cjs/config/useFocusTracker/useFocusTracker.js.map +7 -0
- package/dist/cjs/config/useShuttleV2.js +43 -0
- package/dist/cjs/config/useShuttleV2.js.map +7 -0
- package/dist/cjs/config/useStore/createAtomInStore.js +40 -0
- package/dist/cjs/config/useStore/createAtomInStore.js.map +7 -0
- package/dist/cjs/config/useStore/index.js +26 -0
- package/dist/cjs/config/useStore/index.js.map +7 -0
- package/dist/cjs/config/useStore/useStore.js +79 -0
- package/dist/cjs/config/useStore/useStore.js.map +7 -0
- package/dist/cjs/constants/index.js +50 -0
- package/dist/cjs/constants/index.js.map +7 -0
- package/dist/cjs/index.js +32 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/parts/Header.js +78 -0
- package/dist/cjs/parts/Header.js.map +7 -0
- package/dist/cjs/parts/Item/Item.js +121 -0
- package/dist/cjs/parts/Item/Item.js.map +7 -0
- package/dist/cjs/parts/Item/ItemActions/ItemActions.js +132 -0
- package/dist/cjs/parts/Item/ItemActions/ItemActions.js.map +7 -0
- package/dist/cjs/parts/Item/ItemActions/index.js +26 -0
- package/dist/cjs/parts/Item/ItemActions/index.js.map +7 -0
- package/dist/cjs/parts/Item/ItemActions/useInnerRefHandlers.js +66 -0
- package/dist/cjs/parts/Item/ItemActions/useInnerRefHandlers.js.map +7 -0
- package/dist/cjs/parts/Item/ItemMiddleSection.js +125 -0
- package/dist/cjs/parts/Item/ItemMiddleSection.js.map +7 -0
- package/dist/cjs/parts/Item/ItemSelection.js +61 -0
- package/dist/cjs/parts/Item/ItemSelection.js.map +7 -0
- package/dist/cjs/parts/Item/useItemArrowNavigation.js +82 -0
- package/dist/cjs/parts/Item/useItemArrowNavigation.js.map +7 -0
- package/dist/cjs/parts/Item/useSelectionLogic.js +70 -0
- package/dist/cjs/parts/Item/useSelectionLogic.js.map +7 -0
- package/dist/cjs/parts/ItemListWrapper.js +114 -0
- package/dist/cjs/parts/ItemListWrapper.js.map +7 -0
- package/dist/cjs/parts/MainContent.js +71 -0
- package/dist/cjs/parts/MainContent.js.map +7 -0
- package/dist/cjs/parts/MultipleSelectionAction.js +120 -0
- package/dist/cjs/parts/MultipleSelectionAction.js.map +7 -0
- package/dist/cjs/parts/PanelWrapper.js +112 -0
- package/dist/cjs/parts/PanelWrapper.js.map +7 -0
- package/dist/cjs/parts/SelectionHeader.js +112 -0
- package/dist/cjs/parts/SelectionHeader.js.map +7 -0
- package/dist/cjs/react-desc-prop-types.js +43 -0
- package/dist/cjs/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/sharedTypes.js +24 -0
- package/dist/cjs/sharedTypes.js.map +7 -0
- package/dist/esm/DSShuttleV2.js +31 -0
- package/dist/esm/DSShuttleV2.js.map +7 -0
- package/dist/esm/config/configureAutoCalculated.js +105 -0
- package/dist/esm/config/configureAutoCalculated.js.map +7 -0
- package/dist/esm/config/itemMovementHelpers.js +122 -0
- package/dist/esm/config/itemMovementHelpers.js.map +7 -0
- package/dist/esm/config/useFocusTracker/index.js +12 -0
- package/dist/esm/config/useFocusTracker/index.js.map +7 -0
- package/dist/esm/config/useFocusTracker/useFocusActionTrackers.js +122 -0
- package/dist/esm/config/useFocusTracker/useFocusActionTrackers.js.map +7 -0
- package/dist/esm/config/useFocusTracker/useFocusItemTracker.js +69 -0
- package/dist/esm/config/useFocusTracker/useFocusItemTracker.js.map +7 -0
- package/dist/esm/config/useFocusTracker/useFocusRegionTrackers.js +53 -0
- package/dist/esm/config/useFocusTracker/useFocusRegionTrackers.js.map +7 -0
- package/dist/esm/config/useFocusTracker/useFocusTracker.js +22 -0
- package/dist/esm/config/useFocusTracker/useFocusTracker.js.map +7 -0
- package/dist/esm/config/useShuttleV2.js +17 -0
- package/dist/esm/config/useShuttleV2.js.map +7 -0
- package/dist/esm/config/useStore/createAtomInStore.js +14 -0
- package/dist/esm/config/useStore/createAtomInStore.js.map +7 -0
- package/dist/esm/config/useStore/index.js +3 -0
- package/dist/esm/config/useStore/index.js.map +7 -0
- package/dist/esm/config/useStore/useStore.js +53 -0
- package/dist/esm/config/useStore/useStore.js.map +7 -0
- package/dist/esm/constants/index.js +24 -0
- package/dist/esm/constants/index.js.map +7 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/parts/Header.js +52 -0
- package/dist/esm/parts/Header.js.map +7 -0
- package/dist/esm/parts/Item/Item.js +95 -0
- package/dist/esm/parts/Item/Item.js.map +7 -0
- package/dist/esm/parts/Item/ItemActions/ItemActions.js +106 -0
- package/dist/esm/parts/Item/ItemActions/ItemActions.js.map +7 -0
- package/dist/esm/parts/Item/ItemActions/index.js +3 -0
- package/dist/esm/parts/Item/ItemActions/index.js.map +7 -0
- package/dist/esm/parts/Item/ItemActions/useInnerRefHandlers.js +40 -0
- package/dist/esm/parts/Item/ItemActions/useInnerRefHandlers.js.map +7 -0
- package/dist/esm/parts/Item/ItemMiddleSection.js +99 -0
- package/dist/esm/parts/Item/ItemMiddleSection.js.map +7 -0
- package/dist/esm/parts/Item/ItemSelection.js +35 -0
- package/dist/esm/parts/Item/ItemSelection.js.map +7 -0
- package/dist/esm/parts/Item/useItemArrowNavigation.js +56 -0
- package/dist/esm/parts/Item/useItemArrowNavigation.js.map +7 -0
- package/dist/esm/parts/Item/useSelectionLogic.js +44 -0
- package/dist/esm/parts/Item/useSelectionLogic.js.map +7 -0
- package/dist/esm/parts/ItemListWrapper.js +88 -0
- package/dist/esm/parts/ItemListWrapper.js.map +7 -0
- package/dist/esm/parts/MainContent.js +45 -0
- package/dist/esm/parts/MainContent.js.map +7 -0
- package/dist/esm/parts/MultipleSelectionAction.js +94 -0
- package/dist/esm/parts/MultipleSelectionAction.js.map +7 -0
- package/dist/esm/parts/PanelWrapper.js +86 -0
- package/dist/esm/parts/PanelWrapper.js.map +7 -0
- package/dist/esm/parts/SelectionHeader.js +86 -0
- package/dist/esm/parts/SelectionHeader.js.map +7 -0
- package/dist/esm/react-desc-prop-types.js +20 -0
- package/dist/esm/react-desc-prop-types.js.map +7 -0
- package/dist/esm/sharedTypes.js +2 -0
- package/dist/esm/sharedTypes.js.map +7 -0
- package/package.json +75 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React2 from "react";
|
|
4
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
5
|
+
import { Search } from "@elliemae/ds-icons";
|
|
6
|
+
import { DSButtonV2, BUTTON_SIZES } from "@elliemae/ds-button";
|
|
7
|
+
import { useStore } from "../config/useStore";
|
|
8
|
+
import { useFocusTracker } from "../config/useFocusTracker";
|
|
9
|
+
const Header = React2.memo(({ isDestinationPanel }) => {
|
|
10
|
+
const HeaderRenderer = useStore((state) => isDestinationPanel ? state.DestinationHeader : state.SourceHeader);
|
|
11
|
+
const onSearchBarOpen = useStore(
|
|
12
|
+
(state) => isDestinationPanel ? state.onDesinationOpenSearchbar : state.onSourceOpenSearchbar
|
|
13
|
+
);
|
|
14
|
+
const isSearchBarOpen = useStore(
|
|
15
|
+
(state) => isDestinationPanel ? state.destinationShowSearchbar : state.sourceShowSearchbar
|
|
16
|
+
);
|
|
17
|
+
const { trackFocusRegionHeader, trackFocusItemReset, trackFocusActionReset } = useFocusTracker();
|
|
18
|
+
const onHeaderFocus = React2.useCallback(() => {
|
|
19
|
+
trackFocusRegionHeader(isDestinationPanel);
|
|
20
|
+
trackFocusItemReset();
|
|
21
|
+
trackFocusActionReset();
|
|
22
|
+
}, [isDestinationPanel, trackFocusActionReset, trackFocusItemReset, trackFocusRegionHeader]);
|
|
23
|
+
const handleFilterClick = React2.useCallback(
|
|
24
|
+
(event) => {
|
|
25
|
+
onSearchBarOpen?.(!isSearchBarOpen, { event });
|
|
26
|
+
},
|
|
27
|
+
[isSearchBarOpen, onSearchBarOpen]
|
|
28
|
+
);
|
|
29
|
+
const cols = React2.useMemo(() => {
|
|
30
|
+
const finalCols = ["1fr"];
|
|
31
|
+
if (onSearchBarOpen)
|
|
32
|
+
finalCols.push("auto");
|
|
33
|
+
return finalCols;
|
|
34
|
+
}, [onSearchBarOpen]);
|
|
35
|
+
return /* @__PURE__ */ jsxs(Grid, {
|
|
36
|
+
onFocus: onHeaderFocus,
|
|
37
|
+
cols,
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx(HeaderRenderer, {}),
|
|
40
|
+
onSearchBarOpen ? /* @__PURE__ */ jsx(DSButtonV2, {
|
|
41
|
+
buttonType: "icon",
|
|
42
|
+
size: BUTTON_SIZES.S,
|
|
43
|
+
onClick: handleFilterClick,
|
|
44
|
+
children: /* @__PURE__ */ jsx(Search, {})
|
|
45
|
+
}) : null
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
export {
|
|
50
|
+
Header
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=Header.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/Header.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { Search } from '@elliemae/ds-icons';\nimport { DSButtonV2, BUTTON_SIZES } from '@elliemae/ds-button';\nimport { useStore } from '../config/useStore';\nimport { useFocusTracker } from '../config/useFocusTracker';\nimport { type DSShuttleV2InternalsT } from '../sharedTypes';\n\nexport const Header = React.memo(({ isDestinationPanel }: DSShuttleV2InternalsT.PanelMetaInfo) => {\n const HeaderRenderer = useStore((state) => (isDestinationPanel ? state.DestinationHeader : state.SourceHeader));\n const onSearchBarOpen = useStore((state) =>\n isDestinationPanel ? state.onDesinationOpenSearchbar : state.onSourceOpenSearchbar,\n );\n const isSearchBarOpen = useStore((state) =>\n isDestinationPanel ? state.destinationShowSearchbar : state.sourceShowSearchbar,\n );\n const { trackFocusRegionHeader, trackFocusItemReset, trackFocusActionReset } = useFocusTracker();\n const onHeaderFocus = React.useCallback(() => {\n trackFocusRegionHeader(isDestinationPanel);\n trackFocusItemReset();\n trackFocusActionReset();\n }, [isDestinationPanel, trackFocusActionReset, trackFocusItemReset, trackFocusRegionHeader]);\n\n const handleFilterClick: React.MouseEventHandler<HTMLButtonElement> = React.useCallback(\n (event) => {\n onSearchBarOpen?.(!isSearchBarOpen, { event });\n },\n [isSearchBarOpen, onSearchBarOpen],\n );\n\n const cols = React.useMemo(() => {\n const finalCols = ['1fr'];\n if (onSearchBarOpen) finalCols.push('auto');\n return finalCols;\n }, [onSearchBarOpen]);\n\n return (\n <Grid onFocus={onHeaderFocus} cols={cols}>\n <HeaderRenderer />\n {onSearchBarOpen ? (\n <DSButtonV2 buttonType=\"icon\" size={BUTTON_SIZES.S} onClick={handleFilterClick}>\n <Search />\n </DSBut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AA,OACV,IACE;AAAA;AAAA,GACN;AAEJ,CAAC;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React2 from "react";
|
|
4
|
+
import { styled } from "@elliemae/ds-system";
|
|
5
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
6
|
+
import { useStore } from "../../config/useStore";
|
|
7
|
+
import { ItemSelection } from "./ItemSelection";
|
|
8
|
+
import { ItemActions } from "./ItemActions";
|
|
9
|
+
import { ItemMiddleSection } from "./ItemMiddleSection";
|
|
10
|
+
import { useSelectionLogic } from "./useSelectionLogic";
|
|
11
|
+
import { useItemArrowNavigation } from "./useItemArrowNavigation";
|
|
12
|
+
import { REGIONS_FOCUSES } from "../../constants";
|
|
13
|
+
const ItemWrapper = styled(Grid, { name: "ds-shuttle-v2", slot: "item-wrapper" })`
|
|
14
|
+
min-height: 36px;
|
|
15
|
+
:hover {
|
|
16
|
+
background-color: brand-200;
|
|
17
|
+
.ds-shuttle-v2-item-action-btn-to-source-icon > svg,
|
|
18
|
+
.ds-shuttle-v2-item-action-btn-to-destination-icon > svg,
|
|
19
|
+
.ds-shuttle-v2-item-action-btn-drilldown-icon > svg {
|
|
20
|
+
fill: brand-700;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
:focus {
|
|
24
|
+
outline: 2px solid brand-700;
|
|
25
|
+
outline-offset: -2px;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
const useInnerRefHandlers = ({ item, isDestinationPanel }) => {
|
|
29
|
+
const { isFirst, isLast } = item;
|
|
30
|
+
const focusRegion = useStore((state) => state.focusRegion);
|
|
31
|
+
const focusItem = useStore((state) => state.focusItem);
|
|
32
|
+
const focusItemAction = useStore((state) => state.focusItemAction);
|
|
33
|
+
const currRegion = isDestinationPanel ? REGIONS_FOCUSES.DESTINATION_PANEL_ITEM : REGIONS_FOCUSES.SOURCE_PANEL_ITEM;
|
|
34
|
+
const currItemId = item.original.id;
|
|
35
|
+
const shouldFocus = React2.useMemo(
|
|
36
|
+
() => focusRegion === currRegion && focusItemAction === "parent" && (focusItem === currItemId || isFirst && focusItem === "first" || isLast && focusItem === "last"),
|
|
37
|
+
[currItemId, currRegion, focusItem, focusItemAction, focusRegion, isFirst, isLast]
|
|
38
|
+
);
|
|
39
|
+
const innerRefHandlerParentItem = React2.useCallback(
|
|
40
|
+
(node) => {
|
|
41
|
+
if (shouldFocus) {
|
|
42
|
+
node?.focus();
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
[shouldFocus]
|
|
46
|
+
);
|
|
47
|
+
return React2.useMemo(() => ({ shouldFocus, innerRefHandlerParentItem }), [shouldFocus, innerRefHandlerParentItem]);
|
|
48
|
+
};
|
|
49
|
+
const cols = ["5px", "1fr", "auto"];
|
|
50
|
+
const Item = React2.memo((itemMeta) => {
|
|
51
|
+
const { item } = itemMeta;
|
|
52
|
+
const { original, isSelected } = item;
|
|
53
|
+
const { id } = original;
|
|
54
|
+
const selectItem = useSelectionLogic(itemMeta);
|
|
55
|
+
const { onItemContainerKeyDown } = useItemArrowNavigation(itemMeta);
|
|
56
|
+
const handleItemKeyDown = React2.useCallback(
|
|
57
|
+
(event) => {
|
|
58
|
+
const { key } = event;
|
|
59
|
+
if (["Spacebar", " ", "Enter"].includes(key)) {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
event.stopPropagation();
|
|
62
|
+
selectItem(event);
|
|
63
|
+
}
|
|
64
|
+
onItemContainerKeyDown(event);
|
|
65
|
+
},
|
|
66
|
+
[onItemContainerKeyDown, selectItem]
|
|
67
|
+
);
|
|
68
|
+
const { shouldFocus, innerRefHandlerParentItem } = useInnerRefHandlers(itemMeta);
|
|
69
|
+
return /* @__PURE__ */ jsxs(ItemWrapper, {
|
|
70
|
+
cols,
|
|
71
|
+
alignItems: "center",
|
|
72
|
+
onClick: selectItem,
|
|
73
|
+
onKeyDown: handleItemKeyDown,
|
|
74
|
+
ref: innerRefHandlerParentItem,
|
|
75
|
+
tabIndex: shouldFocus ? 0 : -1,
|
|
76
|
+
role: "checkbox",
|
|
77
|
+
"aria-checked": isSelected,
|
|
78
|
+
id,
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ jsx(ItemSelection, {
|
|
81
|
+
...itemMeta
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ jsx(ItemMiddleSection, {
|
|
84
|
+
...itemMeta
|
|
85
|
+
}),
|
|
86
|
+
/* @__PURE__ */ jsx(ItemActions, {
|
|
87
|
+
...itemMeta
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
export {
|
|
93
|
+
Item
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=Item.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/Item/Item.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\nimport { type DSShuttleV2T } from '../../react-desc-prop-types';\nimport { useStore } from '../../config/useStore';\nimport { ItemSelection } from './ItemSelection';\nimport { ItemActions } from './ItemActions';\nimport { ItemMiddleSection } from './ItemMiddleSection';\nimport { useSelectionLogic } from './useSelectionLogic';\nimport { useItemArrowNavigation } from './useItemArrowNavigation';\nimport { REGIONS_FOCUSES } from '../../constants';\n\n// we are using the class-name added via slot for the children `:hover` styling of icon colors\nconst ItemWrapper = styled(Grid, { name: 'ds-shuttle-v2', slot: 'item-wrapper' })`\n min-height: 36px;\n :hover {\n background-color: brand-200;\n .ds-shuttle-v2-item-action-btn-to-source-icon > svg,\n .ds-shuttle-v2-item-action-btn-to-destination-icon > svg,\n .ds-shuttle-v2-item-action-btn-drilldown-icon > svg {\n fill: brand-700;\n }\n }\n :focus {\n outline: 2px solid brand-700;\n outline-offset: -2px;\n }\n`;\n\nconst useInnerRefHandlers = ({ item, isDestinationPanel }: DSShuttleV2T.ItemMeta) => {\n const { isFirst, isLast } = item;\n const focusRegion = useStore((state) => state.focusRegion);\n const focusItem = useStore((state) => state.focusItem);\n const focusItemAction = useStore((state) => state.focusItemAction);\n const currRegion = isDestinationPanel ? REGIONS_FOCUSES.DESTINATION_PANEL_ITEM : REGIONS_FOCUSES.SOURCE_PANEL_ITEM;\n const currItemId = item.original.id;\n\n const shouldFocus = React.useMemo(\n () =>\n focusRegion === currRegion &&\n focusItemAction === 'parent' &&\n (focusItem === currItemId || (isFirst && focusItem === 'first') || (isLast && focusItem === 'last')),\n [currItemId, currRegion, focusItem, focusItemAction, focusRegion, isFirst, isLast],\n );\n const innerRefHandlerParentItem = React.useCallback(\n (node: HTMLDivElement) => {\n if (shouldFocus) {\n node?.focus();\n }\n },\n [shouldFocus],\n );\n return React.useMemo(() => ({ shouldFocus, innerRefHandlerParentItem }), [shouldFocus, innerRefHandlerParentItem]);\n};\n\nconst cols = ['5px', '1fr', 'auto'];\nexport const Item = React.memo((itemMeta: DSShuttleV2T.ItemMeta) => {\n const { item } = itemMeta;\n const { original, isSelected } = item;\n const { id } = original;\n\n const selectItem = useSelectionLogic(itemMeta);\n const { onItemContainerKeyDown } = useItemArrowNavigation(itemMeta);\n const handleItemKeyDown: React.KeyboardEventHandler<HTMLDivElement> = React.useCallback(\n (event) => {\n const { key } = event;\n // Spacebar AND ' ' are cross-browser compatibility thing\n if (['Spacebar', ' ', 'Enter'].includes(key)) {\n event.preventDefault();\n event.stopPropagation();\n selectItem(event);\n }\n onItemContainerKeyDown(event);\n },\n [onItemContainerKeyDown, selectItem],\n );\n const { shouldFocus, innerRefHandlerParentItem } = useInnerRefHandlers(itemMeta);\n\n return (\n <ItemWrapper\n cols={cols}\n alignItems=\"center\"\n onClick={selectItem}\n onKeyDown={handleItemKeyDown}\n ref={innerRefHandlerParentItem}\n tabIndex={shouldFocus ? 0 : -1}\n role=\"checkbox\"\n aria-checked={isSelected}\n id={id}\n >\n <ItemSelection {...itemMeta} />\n <ItemMiddleSection {...itemMeta} />\n <ItemActions {...itemMeta} />\n </ItemWrapper>\n );\n});\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,OAAOA,YAAW;AAClB,SAAS,cAAc;AACvB,SAAS,YAAY;AAErB,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AACvC,SAAS,uBAAuB;AAGhC,MAAM,cAAc,OAAO,MAAM,EAAE,MAAM,iBAAiB,MAAM,eAAe,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBhF,MAAM,sBAAsB,CAAC,EAAE,MAAM,mBAAmB,MAA6B;AACnF,QAAM,EAAE,SAAS,OAAO,IAAI;AAC5B,QAAM,cAAc,SAAS,CAAC,UAAU,MAAM,WAAW;AACzD,QAAM,YAAY,SAAS,CAAC,UAAU,MAAM,SAAS;AACrD,QAAM,kBAAkB,SAAS,CAAC,UAAU,MAAM,eAAe;AACjE,QAAM,aAAa,qBAAqB,gBAAgB,yBAAyB,gBAAgB;AACjG,QAAM,aAAa,KAAK,SAAS;AAEjC,QAAM,cAAcA,OAAM;AAAA,IACxB,MACE,gBAAgB,cAChB,oBAAoB,aACnB,cAAc,cAAe,WAAW,cAAc,WAAa,UAAU,cAAc;AAAA,IAC9F,CAAC,YAAY,YAAY,WAAW,iBAAiB,aAAa,SAAS,MAAM;AAAA,EACnF;AACA,QAAM,4BAA4BA,OAAM;AAAA,IACtC,CAAC,SAAyB;AACxB,UAAI,aAAa;AACf,cAAM,MAAM;AAAA,MACd;AAAA,I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time";
|
|
3
|
+
import React2 from "react";
|
|
4
|
+
import { styled } from "@elliemae/ds-system";
|
|
5
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
6
|
+
import { DSButtonV2, BUTTON_SIZES } from "@elliemae/ds-button";
|
|
7
|
+
import { ArrowShortReturn, ArrowShortRight, CloseMedium } from "@elliemae/ds-icons";
|
|
8
|
+
import { DSSeparatorV2 } from "@elliemae/ds-separator";
|
|
9
|
+
import { useActionsClickHandlers } from "../../../config/itemMovementHelpers";
|
|
10
|
+
import { useInnerRefHandlers } from "./useInnerRefHandlers";
|
|
11
|
+
const StyledItemActions = styled(Grid, { name: "ds-shuttle-v2", slot: "item-actions-wrapper" })``;
|
|
12
|
+
const StyledItemActionWrapper = styled(Grid, { name: "ds-shuttle-v2", slot: "item-action-wrapper" })``;
|
|
13
|
+
const StyledItemActionsSeparatorWrapper = styled(Grid, {
|
|
14
|
+
name: "ds-shuttle-v2",
|
|
15
|
+
slot: "item-actions-separator-wrapper"
|
|
16
|
+
})`
|
|
17
|
+
height: 24px;
|
|
18
|
+
`;
|
|
19
|
+
const StyledButton = styled(DSButtonV2, { name: "ds-shuttle-v2", slot: "item-action-btn" })`
|
|
20
|
+
height: 22px !important;
|
|
21
|
+
svg {
|
|
22
|
+
fill: brand-600;
|
|
23
|
+
}
|
|
24
|
+
:disabled svg {
|
|
25
|
+
fill: neutral-200 !important;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
const StyledDrilldownIcon = styled(ArrowShortReturn, {
|
|
29
|
+
name: "ds-shuttle-v2",
|
|
30
|
+
slot: "item-action-btn-drilldown-icon"
|
|
31
|
+
})``;
|
|
32
|
+
const StyledCloseMediumIcon = styled(CloseMedium, {
|
|
33
|
+
name: "ds-shuttle-v2",
|
|
34
|
+
slot: "item-action-btn-to-source-icon"
|
|
35
|
+
})``;
|
|
36
|
+
const StyledArrowShortRightIcon = styled(ArrowShortRight, {
|
|
37
|
+
name: "ds-shuttle-v2",
|
|
38
|
+
slot: "item-action-btn-to-destination-icon"
|
|
39
|
+
})``;
|
|
40
|
+
const actionsCols = ["1px", "20px", "20px"];
|
|
41
|
+
const ItemActions = React2.memo((itemMeta) => {
|
|
42
|
+
const { item, isDestinationPanel } = itemMeta;
|
|
43
|
+
const { original, withActions } = item;
|
|
44
|
+
const { preventDrilldown, preventMove } = original;
|
|
45
|
+
const { shouldFocusDrilldown, shouldFocusMove, innerRefHandlerDrilldown, innerRefHandlerMove } = useInnerRefHandlers(itemMeta);
|
|
46
|
+
const { handleDrilldown, handleSingleMove } = useActionsClickHandlers(itemMeta);
|
|
47
|
+
return /* @__PURE__ */ jsxs(StyledItemActions, {
|
|
48
|
+
cols: actionsCols,
|
|
49
|
+
gutter: "xxs",
|
|
50
|
+
pl: "xs",
|
|
51
|
+
pr: "xxs",
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsx(StyledItemActionsSeparatorWrapper, {
|
|
55
|
+
children: /* @__PURE__ */ jsx(DSSeparatorV2, {
|
|
56
|
+
isVertical: true,
|
|
57
|
+
color: "#E0E3E8"
|
|
58
|
+
})
|
|
59
|
+
}),
|
|
60
|
+
withActions ? /* @__PURE__ */ jsxs(Fragment, {
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ jsx(StyledItemActionWrapper, {
|
|
63
|
+
children: /* @__PURE__ */ jsx(StyledButton, {
|
|
64
|
+
buttonType: "icon",
|
|
65
|
+
onClick: handleDrilldown,
|
|
66
|
+
size: BUTTON_SIZES.S,
|
|
67
|
+
innerRef: innerRefHandlerDrilldown,
|
|
68
|
+
tabIndex: shouldFocusDrilldown && !preventDrilldown ? 0 : -1,
|
|
69
|
+
disabled: preventDrilldown === true,
|
|
70
|
+
children: /* @__PURE__ */ jsx(StyledDrilldownIcon, {
|
|
71
|
+
width: "20px",
|
|
72
|
+
height: "20px"
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ jsx(StyledItemActionWrapper, {
|
|
77
|
+
children: /* @__PURE__ */ jsx(StyledButton, {
|
|
78
|
+
buttonType: "icon",
|
|
79
|
+
onClick: handleSingleMove,
|
|
80
|
+
size: BUTTON_SIZES.S,
|
|
81
|
+
innerRef: innerRefHandlerMove,
|
|
82
|
+
tabIndex: shouldFocusMove && !preventMove ? 0 : -1,
|
|
83
|
+
disabled: preventMove === true,
|
|
84
|
+
children: isDestinationPanel ? /* @__PURE__ */ jsx(StyledCloseMediumIcon, {
|
|
85
|
+
width: "20px",
|
|
86
|
+
height: "20px"
|
|
87
|
+
}) : /* @__PURE__ */ jsx(StyledArrowShortRightIcon, {
|
|
88
|
+
width: "20px",
|
|
89
|
+
height: "20px"
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
}) : /* @__PURE__ */ jsxs(Fragment, {
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ jsx("div", {}),
|
|
97
|
+
/* @__PURE__ */ jsx("div", {})
|
|
98
|
+
]
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
export {
|
|
104
|
+
ItemActions
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=ItemActions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/parts/Item/ItemActions/ItemActions.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSButtonV2, BUTTON_SIZES } from '@elliemae/ds-button';\nimport { ArrowShortReturn, ArrowShortRight, CloseMedium } from '@elliemae/ds-icons';\nimport { DSSeparatorV2 } from '@elliemae/ds-separator';\nimport { type DSShuttleV2T } from '../../../react-desc-prop-types';\nimport { useActionsClickHandlers } from '../../../config/itemMovementHelpers';\nimport { useInnerRefHandlers } from './useInnerRefHandlers';\n\nconst StyledItemActions = styled(Grid, { name: 'ds-shuttle-v2', slot: 'item-actions-wrapper' })``;\nconst StyledItemActionWrapper = styled(Grid, { name: 'ds-shuttle-v2', slot: 'item-action-wrapper' })``;\nconst StyledItemActionsSeparatorWrapper = styled(Grid, {\n name: 'ds-shuttle-v2',\n slot: 'item-actions-separator-wrapper',\n})`\n height: 24px;\n`;\nconst StyledButton = styled(DSButtonV2, { name: 'ds-shuttle-v2', slot: 'item-action-btn' })`\n height: 22px !important;\n svg {\n fill: brand-600;\n }\n :disabled svg {\n fill: neutral-200 !important;\n }\n`;\nconst StyledDrilldownIcon = styled(ArrowShortReturn, {\n name: 'ds-shuttle-v2',\n slot: 'item-action-btn-drilldown-icon',\n})``;\nconst StyledCloseMediumIcon = styled(CloseMedium, {\n name: 'ds-shuttle-v2',\n slot: 'item-action-btn-to-source-icon',\n})``;\nconst StyledArrowShortRightIcon = styled(ArrowShortRight, {\n name: 'ds-shuttle-v2',\n slot: 'item-action-btn-to-destination-icon',\n})``;\n\n// 1px separator, 20px icon button/placeholder, 20px icon button/placeholder\nconst actionsCols = ['1px', '20px', '20px'];\n\nexport const ItemActions = React.memo((itemMeta: DSShuttleV2T.ItemMeta) => {\n const { item, isDestinationPanel } = itemMeta;\n const { original, withActions } = item;\n const { preventDrilldown, preventMove } = original;\n const { shouldFocusDrilldown, shouldFocusMove, innerRefHandlerDrilldown, innerRefHandlerMove } =\n useInnerRefHandlers(itemMeta);\n const { handleDrilldown, handleSingleMove } = useActionsClickHandlers(itemMeta);\n\n return (\n <StyledItemActions cols={actionsCols} gutter=\"xxs\" pl=\"xs\" pr=\"xxs\" alignItems=\"center\">\n <StyledItemActionsSeparatorWrapper>\n <DSSeparatorV2 isVertical color=\"#E0E3E8\" />\n </StyledItemActionsSeparatorWrapper>\n {withActions ? (\n <>\n <StyledItemActionWrapper>\n <StyledButton\n buttonType=\"icon\"\n onClick={handleDrilldown}\n size={BUTTON_SIZES.S}\n innerRef={innerRefHandlerDrilldown}\n tabIndex={shouldFocusDrilldown && !preventDrilldown ? 0 : -1}\n disabled={preventDrilldown === true}\n >\n <StyledDrilldownIcon width=\"20px\" height=\"20px\" />\n </StyledButton>\n </StyledItemActionWrapper>\n <StyledItemActionWrapper>\n <StyledButton\n buttonType=\"icon\"\n onClick={handleSingleMove}\n size={BUTTON_SIZES.S}\n innerRef={innerRefHandlerMove}\n tabIndex={shouldFocusMove && !preventMove ? 0 : -1}\n disabled={preventMove === true}\n >\n {isDestinationPanel ? (\n <StyledCloseMediumIcon width=\"20px\" height=\"20px\" />\n ) : (\n <StyledArrowShortRightIcon width=\"20px\" height=\"20px\" />\n )}\n </StyledButton>\n </StyledItemActionWrapper>\n </>\n ) : (\n // this is a place-holder user for mantainting the grid spacing\n <>\n <div />\n <div />\n </>\n )}\n </StyledItemActions>\n );\n});\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,OAAOA,YAAW;AAClB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY,oBAAoB;AACzC,SAAS,kBAAkB,iBAAiB,mBAAmB;AAC/D,SAAS,qBAAqB;AAE9B,SAAS,+BAA+B;AACxC,SAAS,2BAA2B;AAEpC,MAAM,oBAAoB,OAAO,MAAM,EAAE,MAAM,iBAAiB,MAAM,uBAAuB,CAAC;AAC9F,MAAM,0BAA0B,OAAO,MAAM,EAAE,MAAM,iBAAiB,MAAM,sBAAsB,CAAC;AACnG,MAAM,oCAAoC,OAAO,MAAM;AAAA,EACrD,MAAM;AAAA,EACN,MAAM;AACR,CAAC;AAAA;AAAA;AAGD,MAAM,eAAe,OAAO,YAAY,EAAE,MAAM,iBAAiB,MAAM,kBAAkB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAS1F,MAAM,sBAAsB,OAAO,kBAAkB;AAAA,E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A,cAEzB,+BACC,oBAAC;AAAA,gBAAsB,OAAM;AAAA,gBAAO,QAAO;AAAA,eAAO,IAElD,oBAAC;AAAA,gBAA0B,OAAM;AAAA,gBAAO,QAAO;AAAA,eAAO;AAAA,aAE1D;AAAA,WACF;AAAA;AAAA,OACF,IAGA;AAAA,QACE;AAAA,8BAAC,SAAI;AAAA,UACL,oBAAC,SAAI;AAAA;AAAA,OACP;AAAA;AAAA,GAEJ;AAEJ,CAAC;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/parts/Item/ItemActions/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './ItemActions';\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import { useStore } from "../../../config/useStore";
|
|
4
|
+
import { REGIONS_FOCUSES, ACTIONS_FOCUSES } from "../../../constants";
|
|
5
|
+
const useInnerRefHandlers = ({ item, isDestinationPanel }) => {
|
|
6
|
+
const focusRegion = useStore((state) => state.focusRegion);
|
|
7
|
+
const focusItem = useStore((state) => state.focusItem);
|
|
8
|
+
const focusItemAction = useStore((state) => state.focusItemAction);
|
|
9
|
+
const currRegion = isDestinationPanel ? REGIONS_FOCUSES.DESTINATION_PANEL_ITEM : REGIONS_FOCUSES.SOURCE_PANEL_ITEM;
|
|
10
|
+
const currItemId = item.original.id;
|
|
11
|
+
const { shouldFocusDrilldown, shouldFocusMove } = React2.useMemo(
|
|
12
|
+
() => ({
|
|
13
|
+
shouldFocusDrilldown: focusItem === currItemId && focusRegion === currRegion && focusItemAction === ACTIONS_FOCUSES.DRILLDOWN_BTN,
|
|
14
|
+
shouldFocusMove: focusItem === currItemId && focusRegion === currRegion && focusItemAction === ACTIONS_FOCUSES.MOVE_BTN
|
|
15
|
+
}),
|
|
16
|
+
[currItemId, currRegion, focusItem, focusItemAction, focusRegion]
|
|
17
|
+
);
|
|
18
|
+
const innerRefHandlerDrilldown = React2.useCallback(
|
|
19
|
+
(node) => {
|
|
20
|
+
if (shouldFocusDrilldown)
|
|
21
|
+
node?.focus();
|
|
22
|
+
},
|
|
23
|
+
[shouldFocusDrilldown]
|
|
24
|
+
);
|
|
25
|
+
const innerRefHandlerMove = React2.useCallback(
|
|
26
|
+
(node) => {
|
|
27
|
+
if (shouldFocusMove)
|
|
28
|
+
node?.focus();
|
|
29
|
+
},
|
|
30
|
+
[shouldFocusMove]
|
|
31
|
+
);
|
|
32
|
+
return React2.useMemo(
|
|
33
|
+
() => ({ shouldFocusDrilldown, shouldFocusMove, innerRefHandlerDrilldown, innerRefHandlerMove }),
|
|
34
|
+
[innerRefHandlerDrilldown, innerRefHandlerMove, shouldFocusDrilldown, shouldFocusMove]
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
useInnerRefHandlers
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=useInnerRefHandlers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/parts/Item/ItemActions/useInnerRefHandlers.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { type DSShuttleV2T } from '../../../react-desc-prop-types';\nimport { useStore } from '../../../config/useStore';\nimport { REGIONS_FOCUSES, ACTIONS_FOCUSES } from '../../../constants';\n\nexport const useInnerRefHandlers = ({ item, isDestinationPanel }: DSShuttleV2T.ItemMeta) => {\n const focusRegion = useStore((state) => state.focusRegion);\n const focusItem = useStore((state) => state.focusItem);\n const focusItemAction = useStore((state) => state.focusItemAction);\n const currRegion = isDestinationPanel ? REGIONS_FOCUSES.DESTINATION_PANEL_ITEM : REGIONS_FOCUSES.SOURCE_PANEL_ITEM;\n const currItemId = item.original.id;\n const { shouldFocusDrilldown, shouldFocusMove } = React.useMemo(\n () => ({\n shouldFocusDrilldown:\n focusItem === currItemId && focusRegion === currRegion && focusItemAction === ACTIONS_FOCUSES.DRILLDOWN_BTN,\n shouldFocusMove:\n focusItem === currItemId && focusRegion === currRegion && focusItemAction === ACTIONS_FOCUSES.MOVE_BTN,\n }),\n [currItemId, currRegion, focusItem, focusItemAction, focusRegion],\n );\n const innerRefHandlerDrilldown = React.useCallback(\n (node: HTMLButtonElement) => {\n if (shouldFocusDrilldown) node?.focus();\n },\n [shouldFocusDrilldown],\n );\n const innerRefHandlerMove = React.useCallback(\n (node: HTMLButtonElement) => {\n if (shouldFocusMove) node?.focus();\n },\n [shouldFocusMove],\n );\n return React.useMemo(\n () => ({ shouldFocusDrilldown, shouldFocusMove, innerRefHandlerDrilldown, innerRefHandlerMove }),\n [innerRefHandlerDrilldown, innerRefHandlerMove, shouldFocusDrilldown, shouldFocusMove],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,YAAW;AAElB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB,uBAAuB;AAE1C,MAAM,sBAAsB,CAAC,EAAE,MAAM,mBAAmB,MAA6B;AAC1F,QAAM,cAAc,SAAS,CAAC,UAAU,MAAM,WAAW;AACzD,QAAM,YAAY,SAAS,CAAC,UAAU,MAAM,SAAS;AACrD,QAAM,kBAAkB,SAAS,CAAC,UAAU,MAAM,eAAe;AACjE,QAAM,aAAa,qBAAqB,gBAAgB,yBAAyB,gBAAgB;AACjG,QAAM,aAAa,KAAK,SAAS;AACjC,QAAM,EAAE,sBAAsB,gBAAgB,IAAIA,OAAM;AAAA,IACtD,OAAO;AAAA,MACL,sBACE,cAAc,cAAc,gBAAgB,cAAc,oBAAoB,gBAAgB;AAAA,MAChG,iBACE,cAAc,cAAc,gBAAgB,cAAc,oBAAoB,gBAAgB;AAAA,IAClG;AAAA,IACA,CAAC,YAAY,YAAY,WAAW,iBAAiB,WAAW;AAAA,EAClE;AACA,QAAM,2BAA2BA,OAAM;AAAA,IACrC,CAAC,SAA4B;AAC3B,UAAI;AAAsB,cAAM,MAAM;AAAA,IACxC;AAAA,IACA,CAAC,oBAAoB;AAAA,EACvB;AACA,QAAM,sBAAsBA,OAAM;AAAA,IAChC,CAAC,SAA4B;AAC3B,UAAI;AAAiB,cAAM,MAAM;AAAA,IACnC;AAAA,IACA,CAAC,eAAe;AAAA,EAClB;AACA,SAAOA,OAAM;AAAA,IACX,OAAO,EAAE,sBAAsB,iBAAiB,0BAA0B,oBAAoB;AAAA,IAC9F,CAAC,0BAA0B,qBAAqB,sBAAsB,eAAe;AAAA,EACvF;AACF;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React2 from "react";
|
|
4
|
+
import { styled } from "@elliemae/ds-system";
|
|
5
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
6
|
+
import { DSTypography } from "@elliemae/ds-typography";
|
|
7
|
+
const IconWrapper = styled(Grid, { name: "ds-shuttle-v2", slot: "item-icon-wrapper" })`
|
|
8
|
+
min-height: 1rem;
|
|
9
|
+
`;
|
|
10
|
+
const LabelWrapper = styled(Grid, { name: "ds-shuttle-v2", slot: "item-label-wrapper" })`
|
|
11
|
+
min-height: 1rem;
|
|
12
|
+
`;
|
|
13
|
+
const MidSection = styled(Grid, { name: "ds-shuttle-v2", slot: "item-midsection-wrapper" })`
|
|
14
|
+
min-height: 1rem;
|
|
15
|
+
${(props) => {
|
|
16
|
+
if (props.$softDeleted)
|
|
17
|
+
return `
|
|
18
|
+
color: ${props.theme.colors.neutral[500]};
|
|
19
|
+
svg {
|
|
20
|
+
fill: ${props.theme.colors.neutral[400]};
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
return "";
|
|
24
|
+
}};
|
|
25
|
+
`;
|
|
26
|
+
const customMidSectionCols = ["1fr"];
|
|
27
|
+
const customMidSectionRows = ["1fr"];
|
|
28
|
+
const withSubtitleRows = ["auto", "auto"];
|
|
29
|
+
const TextSection = React2.memo((props) => {
|
|
30
|
+
const { label, subtitle } = props.item.original;
|
|
31
|
+
if (subtitle === void 0)
|
|
32
|
+
return /* @__PURE__ */ jsx(LabelWrapper, {
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
children: /* @__PURE__ */ jsx(DSTypography, {
|
|
35
|
+
variant: "b1",
|
|
36
|
+
children: label
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
return /* @__PURE__ */ jsxs(Grid, {
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
rows: withSubtitleRows,
|
|
42
|
+
gutter: "1px",
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ jsx(DSTypography, {
|
|
45
|
+
variant: "b1",
|
|
46
|
+
children: label
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ jsx(DSTypography, {
|
|
49
|
+
variant: "b4",
|
|
50
|
+
children: subtitle
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
const ItemMiddleSection = React2.memo((itemMeta) => {
|
|
56
|
+
const { item } = itemMeta;
|
|
57
|
+
const { original } = item;
|
|
58
|
+
const { Icon, CustomRenderer, softDeleted } = original;
|
|
59
|
+
const cols = React2.useMemo(() => {
|
|
60
|
+
if (CustomRenderer)
|
|
61
|
+
return [];
|
|
62
|
+
const dynamicCols = [];
|
|
63
|
+
if (Icon)
|
|
64
|
+
dynamicCols.push("auto");
|
|
65
|
+
dynamicCols.push("1fr");
|
|
66
|
+
return dynamicCols;
|
|
67
|
+
}, [CustomRenderer, Icon]);
|
|
68
|
+
if (CustomRenderer)
|
|
69
|
+
return /* @__PURE__ */ jsx(MidSection, {
|
|
70
|
+
cols: customMidSectionCols,
|
|
71
|
+
rows: customMidSectionRows,
|
|
72
|
+
$softDeleted: softDeleted,
|
|
73
|
+
children: /* @__PURE__ */ jsx(CustomRenderer, {
|
|
74
|
+
...itemMeta
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
return /* @__PURE__ */ jsxs(MidSection, {
|
|
78
|
+
cols,
|
|
79
|
+
alignItems: "center",
|
|
80
|
+
ml: "xxs",
|
|
81
|
+
$softDeleted: softDeleted,
|
|
82
|
+
children: [
|
|
83
|
+
Icon ? /* @__PURE__ */ jsx(IconWrapper, {
|
|
84
|
+
alignItems: "center",
|
|
85
|
+
mr: "xxs",
|
|
86
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
87
|
+
...itemMeta
|
|
88
|
+
})
|
|
89
|
+
}) : null,
|
|
90
|
+
/* @__PURE__ */ jsx(TextSection, {
|
|
91
|
+
...itemMeta
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
export {
|
|
97
|
+
ItemMiddleSection
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=ItemMiddleSection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/Item/ItemMiddleSection.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\nimport { DSTypography } from '@elliemae/ds-typography';\nimport { type DSShuttleV2T } from '../../react-desc-prop-types';\n\nconst IconWrapper = styled(Grid, { name: 'ds-shuttle-v2', slot: 'item-icon-wrapper' })`\n min-height: 1rem;\n`;\nconst LabelWrapper = styled(Grid, { name: 'ds-shuttle-v2', slot: 'item-label-wrapper' })`\n min-height: 1rem;\n`;\nconst MidSection = styled(Grid, { name: 'ds-shuttle-v2', slot: 'item-midsection-wrapper' })`\n min-height: 1rem;\n ${(props) => {\n if (props.$softDeleted)\n return `\n color: ${props.theme.colors.neutral[500]};\n svg {\n fill: ${props.theme.colors.neutral[400]};\n }\n `;\n return '';\n }};\n`;\nconst customMidSectionCols = ['1fr'];\nconst customMidSectionRows = ['1fr'];\n\nconst withSubtitleRows = ['auto', 'auto'];\nconst TextSection = React.memo((props: DSShuttleV2T.ItemMeta) => {\n const { label, subtitle } = props.item.original;\n if (subtitle === undefined)\n return (\n <LabelWrapper alignItems=\"center\">\n <DSTypography variant=\"b1\">{label}</DSTypography>\n </LabelWrapper>\n );\n return (\n <Grid alignItems=\"center\" rows={withSubtitleRows} gutter=\"1px\">\n <DSTypography variant=\"b1\">{label}</DSTypography>\n <DSTypography variant=\"b4\">{subtitle}</DSTypography>\n </Grid>\n );\n});\n\nexport const ItemMiddleSection = React.memo((itemMeta: DSShuttleV2T.ItemMeta) => {\n const { item } = itemMeta;\n const { original } = item;\n const { Icon, CustomRenderer, softDeleted } = original;\n const cols = React.useMemo(() => {\n // if CustomRenderer is defined, shortcircuit\n if (CustomRenderer) return [];\n const dynamicCols = [];\n if (Icon) dynamicCols.push('auto');\n dynamicCols.push('1fr');\n return dynamicCols;\n }, [CustomRenderer, Icon]);\n\n if (CustomRenderer)\n return (\n <MidSection cols={customMidSectionCols} rows={customMidSectionRows} $softDeleted={softDeleted}>\n <CustomRenderer {...itemMeta} />\n </MidSection>\n );\n\n return (\n <MidSection cols={cols} alignItems=\"center\" ml=\"xxs\" $softDeleted={softDeleted}>\n {Icon ? (\n <IconWrapper alignItems=\"center\" mr=\"xxs\">\n <Icon {...itemMeta} />\n </IconWrapper>\n ) : null}\n <TextSection {...itemMeta} />\n </MidSection>\n );\n});\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,OAAO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,MAAM;AAE/B,QAAI;AAAgB,aAAO,CAAC;AAC5B,UAAM,cAAc,CAAC;AACrB,QAAI;AAAM,kBAAY,KAAK,MAAM;AACjC,gBAAY,KAAK,KAAK;AACtB,WAAO;AAAA,EACT,GAAG,CAAC,gBAAgB,IAAI,CAAC;AAEzB,MAAI;AACF,WACE,oBAAC;AAAA,MAAW,MAAM;AAAA,MAAsB,MAAM;AAAA,MAAsB,cAAc;AAAA,MAChF,8BAAC;AAAA,QAAgB,GAAG;AAAA,OAAU;AAAA,KAChC;AAGJ,SACE,qBAAC;AAAA,IAAW;AAAA,IAAY,YAAW;AAAA,IAAS,IAAG;AAAA,IAAM,cAAc;AAAA,IAChE;AAAA,aACC,oBAAC;AAAA,QAAY,YAAW;AAAA,QAAS,IAAG;AAAA,QAClC,8BAAC;AAAA,UAAM,GAAG;AAAA,SAAU;AAAA,OACtB,IACE;AAAA,MACJ,oBAAC;AAAA,QAAa,GAAG;AAAA,OAAU;AAAA;AAAA,GAC7B;AAEJ,CAAC;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import React2 from "react";
|
|
4
|
+
import { styled } from "@elliemae/ds-system";
|
|
5
|
+
import { Grid } from "@elliemae/ds-grid";
|
|
6
|
+
const StyledItemSelection = styled(Grid, { name: "ds-shuttle-v2", slot: "item-selection" })`
|
|
7
|
+
width: 5px;
|
|
8
|
+
height: 100%;
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
background-color: ${(props) => {
|
|
11
|
+
if (props.$isSelected)
|
|
12
|
+
return props.theme.colors.brand[500];
|
|
13
|
+
if (props.$selectionPrevented === true)
|
|
14
|
+
return props.theme.colors.neutral["000"];
|
|
15
|
+
return props.theme.colors.neutral[200];
|
|
16
|
+
}};
|
|
17
|
+
border-right: ${(props) => {
|
|
18
|
+
if (props.$selectionPrevented === true)
|
|
19
|
+
return `1px solid ${props.theme.colors.neutral["200"]}`;
|
|
20
|
+
return "";
|
|
21
|
+
}};
|
|
22
|
+
border-bottom: ${(props) => {
|
|
23
|
+
if (props.$selectionPrevented === true)
|
|
24
|
+
return `1px solid ${props.theme.colors.neutral["200"]}`;
|
|
25
|
+
return "";
|
|
26
|
+
}};
|
|
27
|
+
`;
|
|
28
|
+
const ItemSelection = React2.memo(({ item: { isSelected, selectionPrevented } }) => /* @__PURE__ */ jsx(StyledItemSelection, {
|
|
29
|
+
$isSelected: isSelected,
|
|
30
|
+
$selectionPrevented: selectionPrevented
|
|
31
|
+
}));
|
|
32
|
+
export {
|
|
33
|
+
ItemSelection
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=ItemSelection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/Item/ItemSelection.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\nimport { type DSShuttleV2T } from '../../react-desc-prop-types';\n\nconst StyledItemSelection = styled(Grid, { name: 'ds-shuttle-v2', slot: 'item-selection' })<{\n $isSelected: boolean;\n $selectionPrevented?: boolean;\n}>`\n width: 5px;\n height: 100%;\n box-sizing: border-box;\n background-color: ${(props) => {\n if (props.$isSelected) return props.theme.colors.brand[500];\n if (props.$selectionPrevented === true) return props.theme.colors.neutral['000'];\n return props.theme.colors.neutral[200];\n }};\n border-right: ${(props) => {\n if (props.$selectionPrevented === true) return `1px solid ${props.theme.colors.neutral['200']}`;\n return '';\n }};\n border-bottom: ${(props) => {\n if (props.$selectionPrevented === true) return `1px solid ${props.theme.colors.neutral['200']}`;\n return '';\n }};\n`;\n\nexport const ItemSelection = React.memo(({ item: { isSelected, selectionPrevented } }: DSShuttleV2T.ItemMeta) => (\n <StyledItemSelection $isSelected={isSelected} $selectionPrevented={selectionPrevented} />\n));\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,OAAOA,YAAW;AAClB,SAAS,cAAc;AACvB,SAAS,YAAY;AAGrB,MAAM,sBAAsB,OAAO,MAAM,EAAE,MAAM,iBAAiB,MAAM,iBAAiB,CAAC;AAAA;AAAA;AAAA;AAAA,sBAOpE,CAAC,UAAU;AAC7B,MAAI,MAAM;AAAa,WAAO,MAAM,MAAM,OAAO,MAAM;AACvD,MAAI,MAAM,wBAAwB;AAAM,WAAO,MAAM,MAAM,OAAO,QAAQ;AAC1E,SAAO,MAAM,MAAM,OAAO,QAAQ;AACpC;AAAA,kBACgB,CAAC,UAAU;AACzB,MAAI,MAAM,wBAAwB;AAAM,WAAO,aAAa,MAAM,MAAM,OAAO,QAAQ;AACvF,SAAO;AACT;AAAA,mBACiB,CAAC,UAAU;AAC1B,MAAI,MAAM,wBAAwB;AAAM,WAAO,aAAa,MAAM,MAAM,OAAO,QAAQ;AACvF,SAAO;AACT;AAAA;AAGK,MAAM,gBAAgBA,OAAM,KAAK,CAAC,EAAE,MAAM,EAAE,YAAY,mBAAmB,EAAE,MAClF,oBAAC;AAAA,EAAoB,aAAa;AAAA,EAAY,qBAAqB;AAAA,CAAoB,CACxF;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import { useFocusItemTracker, useFocusActionTrackers } from "../../config/useFocusTracker";
|
|
4
|
+
const useItemArrowNavigation = (itemMeta) => {
|
|
5
|
+
const { mutableFocusItem, trackFocusPrevItem, trackFocusNextItem, trackFocusItem } = useFocusItemTracker();
|
|
6
|
+
const { trackFocusNextAction, trackFocusPrevAction, trackFocusActionParent } = useFocusActionTrackers();
|
|
7
|
+
const { item } = itemMeta;
|
|
8
|
+
const { isFirst, isLast } = item;
|
|
9
|
+
const onItemContainerKeyDown = React2.useCallback(
|
|
10
|
+
(e) => {
|
|
11
|
+
const { key } = e;
|
|
12
|
+
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(key))
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(key))
|
|
15
|
+
e.stopPropagation();
|
|
16
|
+
if (key === "ArrowLeft") {
|
|
17
|
+
if (mutableFocusItem.current === "first" && isFirst || mutableFocusItem.current === "last" && isLast) {
|
|
18
|
+
trackFocusItem(item);
|
|
19
|
+
}
|
|
20
|
+
trackFocusPrevAction(itemMeta);
|
|
21
|
+
}
|
|
22
|
+
if (key === "ArrowRight") {
|
|
23
|
+
if (mutableFocusItem.current === "first" && isFirst || mutableFocusItem.current === "last" && isLast) {
|
|
24
|
+
trackFocusItem(item);
|
|
25
|
+
}
|
|
26
|
+
trackFocusNextAction(itemMeta);
|
|
27
|
+
}
|
|
28
|
+
if (key === "ArrowUp") {
|
|
29
|
+
trackFocusPrevItem(itemMeta);
|
|
30
|
+
trackFocusActionParent();
|
|
31
|
+
}
|
|
32
|
+
if (key === "ArrowDown") {
|
|
33
|
+
trackFocusNextItem(itemMeta);
|
|
34
|
+
trackFocusActionParent();
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
[
|
|
38
|
+
mutableFocusItem,
|
|
39
|
+
isFirst,
|
|
40
|
+
isLast,
|
|
41
|
+
trackFocusPrevAction,
|
|
42
|
+
itemMeta,
|
|
43
|
+
trackFocusItem,
|
|
44
|
+
item,
|
|
45
|
+
trackFocusNextAction,
|
|
46
|
+
trackFocusPrevItem,
|
|
47
|
+
trackFocusActionParent,
|
|
48
|
+
trackFocusNextItem
|
|
49
|
+
]
|
|
50
|
+
);
|
|
51
|
+
return React2.useMemo(() => ({ onItemContainerKeyDown }), [onItemContainerKeyDown]);
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
useItemArrowNavigation
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=useItemArrowNavigation.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/Item/useItemArrowNavigation.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React from 'react';\n// import { useStore } from '../../config/useStore';\nimport { useFocusItemTracker, useFocusActionTrackers } from '../../config/useFocusTracker';\nimport { type DSShuttleV2T } from '../../react-desc-prop-types';\n\nexport const useItemArrowNavigation = (itemMeta: DSShuttleV2T.ItemMeta) => {\n const { mutableFocusItem, trackFocusPrevItem, trackFocusNextItem, trackFocusItem } = useFocusItemTracker();\n const { trackFocusNextAction, trackFocusPrevAction, trackFocusActionParent } = useFocusActionTrackers();\n const { item } = itemMeta;\n const { isFirst, isLast } = item;\n\n const onItemContainerKeyDown = React.useCallback<React.KeyboardEventHandler<HTMLDivElement>>(\n (e) => {\n const { key } = e;\n // stopping prepagation it's required to avoid \"ArrowUp/ArrowDown\" to trigger parents logic\n // preventDefault it's just me thinking it's good idea when stopping propagation\n if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) e.preventDefault();\n if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) e.stopPropagation();\n if (key === 'ArrowLeft') {\n if ((mutableFocusItem.current === 'first' && isFirst) || (mutableFocusItem.current === 'last' && isLast)) {\n trackFocusItem(item);\n }\n trackFocusPrevAction(itemMeta);\n }\n if (key === 'ArrowRight') {\n if ((mutableFocusItem.current === 'first' && isFirst) || (mutableFocusItem.current === 'last' && isLast)) {\n trackFocusItem(item);\n }\n trackFocusNextAction(itemMeta);\n }\n if (key === 'ArrowUp') {\n trackFocusPrevItem(itemMeta);\n trackFocusActionParent();\n }\n if (key === 'ArrowDown') {\n trackFocusNextItem(itemMeta);\n trackFocusActionParent();\n }\n },\n [\n mutableFocusItem,\n isFirst,\n isLast,\n trackFocusPrevAction,\n itemMeta,\n trackFocusItem,\n item,\n trackFocusNextAction,\n trackFocusPrevItem,\n trackFocusActionParent,\n trackFocusNextItem,\n ],\n );\n\n return React.useMemo(() => ({ onItemContainerKeyDown }), [onItemContainerKeyDown]);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACCvB,OAAOA,YAAW;AAElB,SAAS,qBAAqB,8BAA8B;AAGrD,MAAM,yBAAyB,CAAC,aAAoC;AACzE,QAAM,EAAE,kBAAkB,oBAAoB,oBAAoB,eAAe,IAAI,oBAAoB;AACzG,QAAM,EAAE,sBAAsB,sBAAsB,uBAAuB,IAAI,uBAAuB;AACtG,QAAM,EAAE,KAAK,IAAI;AACjB,QAAM,EAAE,SAAS,OAAO,IAAI;AAE5B,QAAM,yBAAyBA,OAAM;AAAA,IACnC,CAAC,MAAM;AACL,YAAM,EAAE,IAAI,IAAI;AAGhB,UAAI,CAAC,WAAW,aAAa,aAAa,YAAY,EAAE,SAAS,GAAG;AAAG,UAAE,eAAe;AACxF,UAAI,CAAC,WAAW,aAAa,aAAa,YAAY,EAAE,SAAS,GAAG;AAAG,UAAE,gBAAgB;AACzF,UAAI,QAAQ,aAAa;AACvB,YAAK,iBAAiB,YAAY,WAAW,WAAa,iBAAiB,YAAY,UAAU,QAAS;AACxG,yBAAe,IAAI;AAAA,QACrB;AACA,6BAAqB,QAAQ;AAAA,MAC/B;AACA,UAAI,QAAQ,cAAc;AACxB,YAAK,iBAAiB,YAAY,WAAW,WAAa,iBAAiB,YAAY,UAAU,QAAS;AACxG,yBAAe,IAAI;AAAA,QACrB;AACA,6BAAqB,QAAQ;AAAA,MAC/B;AACA,UAAI,QAAQ,WAAW;AACrB,2BAAmB,QAAQ;AAC3B,+BAAuB;AAAA,MACzB;AACA,UAAI,QAAQ,aAAa;AACvB,2BAAmB,QAAQ;AAC3B,+BA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