@elliemae/ds-left-navigation 2.0.0-alpha.10 → 2.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/LeftNavigationContext.js +0 -4
- package/cjs/common/getItemBackgroundStyle.js +1 -12
- package/cjs/common/getLeftBorderStyle.js +3 -17
- package/cjs/common/getScrollbarStyle.js +1 -24
- package/cjs/common/index.js +0 -2
- package/cjs/configs/useLeftNavConfig.js +14 -21
- package/cjs/configs/useLeftNavItems.js +11 -11
- package/cjs/exported-related/ChevronItem/index.js +7 -3
- package/cjs/exported-related/Icon/index.js +5 -0
- package/cjs/exported-related/ItemRenderer/index.js +11 -10
- package/cjs/exported-related/ItemRenderer/styled.js +27 -27
- package/cjs/exported-related/ItemRenderer/usePropsWithDefaults.js +10 -3
- package/cjs/exported-related/Notifications/index.js +41 -41
- package/cjs/exported-related/OpenWindowItem/index.js +7 -3
- package/cjs/hooks/useExpandableOnClickHandler.js +7 -6
- package/cjs/hooks/useKeyboardNavigation.js +7 -7
- package/cjs/hooks/useOpenableOnClickHandler.js +8 -7
- package/cjs/hooks/useSelectFirstBodyItem.js +14 -4
- package/cjs/index.js +0 -1
- package/cjs/outOfTheBox/ItemControlledDrilldown/index.js +19 -18
- package/cjs/outOfTheBox/ItemControlledDrilldown/styled.js +7 -4
- package/cjs/outOfTheBox/ItemHeader/index.js +24 -15
- package/cjs/outOfTheBox/ItemHeader/styled.js +3 -4
- package/cjs/outOfTheBox/ItemLink/index.js +18 -24
- package/cjs/outOfTheBox/ItemSection/index.js +12 -10
- package/cjs/outOfTheBox/ItemSeparator/index.js +6 -6
- package/cjs/outOfTheBox/ItemSubmenu/index.js +17 -25
- package/cjs/outOfTheBox/ItemSubmenu/styled.js +3 -4
- package/cjs/outOfTheBox/ItemTextLabel/index.js +11 -9
- package/cjs/outOfTheBox/ItemTextLabel/styled.js +7 -4
- package/cjs/outOfTheBox/ItemUncontrolledDrilldown/index.js +15 -15
- package/cjs/outOfTheBox/ItemUncontrolledDrilldown/styled.js +7 -4
- package/cjs/outOfTheBox/ItemWithDate/index.js +9 -8
- package/cjs/outOfTheBox/ItemWithDate/styled.js +7 -4
- package/cjs/outOfTheBox/index.js +6 -6
- package/cjs/parts/LeftNavContent/index.js +5 -2
- package/cjs/parts/LeftNavContent/styled.js +11 -16
- package/cjs/parts/LeftNavContentWithScrollbar/index.js +7 -0
- package/cjs/parts/LeftNavFooterItem/index.js +3 -12
- package/cjs/parts/LeftNavFooterItem/styled.js +8 -9
- package/cjs/parts/LeftNavLoading/index.js +13 -10
- package/cjs/parts/OutOfTheBoxMapItem.js +5 -0
- package/cjs/prop-types.js +2 -1
- package/esm/LeftNavigationContext.js +0 -4
- package/esm/common/getItemBackgroundStyle.js +1 -12
- package/esm/common/getLeftBorderStyle.js +3 -17
- package/esm/common/getScrollbarStyle.js +1 -24
- package/esm/common/index.js +0 -1
- package/esm/configs/useLeftNavConfig.js +14 -21
- package/esm/configs/useLeftNavItems.js +11 -11
- package/esm/exported-related/ChevronItem/index.js +7 -2
- package/esm/exported-related/Icon/index.js +5 -0
- package/esm/exported-related/ItemRenderer/index.js +11 -10
- package/esm/exported-related/ItemRenderer/styled.js +27 -28
- package/esm/exported-related/ItemRenderer/usePropsWithDefaults.js +10 -3
- package/esm/exported-related/Notifications/index.js +41 -37
- package/esm/exported-related/OpenWindowItem/index.js +7 -2
- package/esm/hooks/useExpandableOnClickHandler.js +7 -6
- package/esm/hooks/useKeyboardNavigation.js +7 -7
- package/esm/hooks/useOpenableOnClickHandler.js +8 -7
- package/esm/hooks/useSelectFirstBodyItem.js +14 -4
- package/esm/index.js +0 -1
- package/esm/outOfTheBox/ItemControlledDrilldown/index.js +16 -13
- package/esm/outOfTheBox/ItemControlledDrilldown/styled.js +7 -4
- package/esm/outOfTheBox/ItemHeader/index.js +24 -15
- package/esm/outOfTheBox/ItemHeader/styled.js +3 -3
- package/esm/outOfTheBox/ItemLink/index.js +18 -24
- package/esm/outOfTheBox/ItemSection/index.js +12 -10
- package/esm/outOfTheBox/ItemSeparator/index.js +6 -6
- package/esm/outOfTheBox/ItemSubmenu/index.js +17 -25
- package/esm/outOfTheBox/ItemSubmenu/styled.js +3 -3
- package/esm/outOfTheBox/ItemTextLabel/index.js +11 -9
- package/esm/outOfTheBox/ItemTextLabel/styled.js +7 -4
- package/esm/outOfTheBox/ItemUncontrolledDrilldown/index.js +14 -12
- package/esm/outOfTheBox/ItemUncontrolledDrilldown/styled.js +7 -4
- package/esm/outOfTheBox/ItemWithDate/index.js +9 -8
- package/esm/outOfTheBox/ItemWithDate/styled.js +7 -4
- package/esm/outOfTheBox/index.js +6 -6
- package/esm/parts/LeftNavContent/index.js +5 -2
- package/esm/parts/LeftNavContent/styled.js +11 -16
- package/esm/parts/LeftNavContentWithScrollbar/index.js +7 -0
- package/esm/parts/LeftNavFooterItem/index.js +2 -10
- package/esm/parts/LeftNavFooterItem/styled.js +3 -4
- package/esm/parts/LeftNavLoading/index.js +13 -10
- package/esm/parts/OutOfTheBoxMapItem.js +5 -0
- package/esm/prop-types.js +2 -1
- package/package.json +12 -16
- package/types/LeftNavigation.d.ts +46 -11
- package/types/LeftNavigationContext.d.ts +0 -4
- package/types/common/index.d.ts +0 -1
- package/types/exported-related/ItemRenderer/styled.d.ts +3 -2
- package/types/hooks/useKeyboardNavigation.d.ts +1 -1
- package/types/hooks/useSelectFirstBodyItem.d.ts +1 -1
- package/types/index.d.d.ts +8 -2
- package/types/index.d.ts +1 -2
- package/types/outOfTheBox/ItemControlledDrilldown/styled.d.ts +2 -2
- package/types/outOfTheBox/ItemHeader/styled.d.ts +2 -2
- package/types/outOfTheBox/ItemLink/styled.d.ts +1 -1
- package/types/outOfTheBox/ItemSection/styled.d.ts +3 -3
- package/types/outOfTheBox/ItemSubmenu/styled.d.ts +2 -2
- package/types/outOfTheBox/ItemTextLabel/styled.d.ts +1 -1
- package/types/outOfTheBox/ItemUncontrolledDrilldown/styled.d.ts +2 -2
- package/types/outOfTheBox/ItemWithDate/styled.d.ts +2 -2
- package/types/parts/LeftNavContent/styled.d.ts +7 -11
- package/types/parts/LeftNavContentWithScrollbar/index.d.ts +1 -0
- package/types/parts/LeftNavFooterItem/styled.d.ts +10 -6
- package/types/prop-types.d.ts +87 -18
- package/cjs/common/getFocusedByKeyboardStyle.js +0 -23
- package/cjs/configs/useGlobalKeyListeners.js +0 -31
- package/cjs/package.json +0 -4
- package/esm/common/getFocusedByKeyboardStyle.js +0 -19
- package/esm/configs/useGlobalKeyListeners.js +0 -22
- package/esm/package.json +0 -4
- package/types/common/getFocusedByKeyboardStyle.d.ts +0 -4
- package/types/configs/useGlobalKeyListeners.d.ts +0 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import { useGlobalKeyListeners } from './useGlobalKeyListeners.js';
|
|
3
3
|
import { useLeftNavItems } from './useLeftNavItems.js';
|
|
4
4
|
import { useLeftNavSmoothExpand } from './useLeftNavSmoothExpand.js';
|
|
5
5
|
import { useSelectFirstBodyItem } from '../hooks/useSelectFirstBodyItem.js';
|
|
@@ -18,10 +18,10 @@ const useLeftNavConfig = props => {
|
|
|
18
18
|
// Selection related
|
|
19
19
|
|
|
20
20
|
const [selectedItem, setSelectedItem] = React.useState(null);
|
|
21
|
-
|
|
21
|
+
React.useState(null);
|
|
22
|
+
const [selectedParent, setSelectedParent] = React.useState(null); // Focus related
|
|
22
23
|
|
|
23
|
-
const [focusedItem, setFocusedItem] = React.useState(null);
|
|
24
|
-
const [focusedByKey, setFocusedByKey] = React.useState(true); // Opened uncontrolled drilldowns
|
|
24
|
+
const [focusedItem, setFocusedItem] = React.useState(null); // Opened uncontrolled drilldowns
|
|
25
25
|
|
|
26
26
|
const [openedDrilldowns, setOpenedDrilldowns] = React.useState([]); // -----------------------------------------------------------------------------
|
|
27
27
|
// ************************** ------------ **************************
|
|
@@ -37,24 +37,19 @@ const useLeftNavConfig = props => {
|
|
|
37
37
|
}), [expandedForAnimation, timeoutRef, setExpandedForAnimation]);
|
|
38
38
|
useLeftNavSmoothExpand(props, smoothExpandOpts); // -----------------------------------------------------------------------------
|
|
39
39
|
// ************************** ------------ **************************
|
|
40
|
-
// * KEYBOARD *
|
|
41
|
-
// ************************** ------------ **************************
|
|
42
|
-
|
|
43
|
-
const globalKeyOpts = React.useMemo(() => ({
|
|
44
|
-
setFocusedByKey
|
|
45
|
-
}), [setFocusedByKey]);
|
|
46
|
-
useGlobalKeyListeners(globalKeyOpts); // -----------------------------------------------------------------------------
|
|
47
|
-
// ************************** ------------ **************************
|
|
48
40
|
// * SIDE EFFECTS *
|
|
49
41
|
// ************************** ------------ **************************
|
|
50
42
|
|
|
51
43
|
React.useEffect(() => {
|
|
52
44
|
onSelectedChange(selectedItem);
|
|
53
45
|
}, [selectedItem, onSelectedChange]);
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
if (openedItem !== null) setSelectedParent(openedItem);
|
|
48
|
+
}, [openedItem]);
|
|
54
49
|
React.useEffect(() => {
|
|
55
50
|
onFocusChange(focusedItem);
|
|
56
|
-
}, [focusedItem,
|
|
57
|
-
useSelectFirstBodyItem(items, openedItem, setSelectedItem); // -----------------------------------------------------------------------------
|
|
51
|
+
}, [focusedItem, onFocusChange]);
|
|
52
|
+
useSelectFirstBodyItem(items, openedItem, props.selectedItem !== undefined ? props.selectedItem : selectedItem, setSelectedItem, props.disableDefaultSelection); // -----------------------------------------------------------------------------
|
|
58
53
|
// ************************** ------------ **************************
|
|
59
54
|
// * ITEMS MANAGEMENT *
|
|
60
55
|
// ************************** ------------ **************************
|
|
@@ -64,7 +59,7 @@ const useLeftNavConfig = props => {
|
|
|
64
59
|
bodyHeaderItem: props.BodyHeaderComponent,
|
|
65
60
|
items: props.items,
|
|
66
61
|
openedDrilldowns
|
|
67
|
-
}), [props.items, openedDrilldowns]); // We need to know the current visible items since we have drilldowns
|
|
62
|
+
}), [props.HeaderComponent, props.BodyHeaderComponent, props.items, openedDrilldowns]); // We need to know the current visible items since we have drilldowns
|
|
68
63
|
|
|
69
64
|
const {
|
|
70
65
|
visibleItems,
|
|
@@ -77,19 +72,17 @@ const useLeftNavConfig = props => {
|
|
|
77
72
|
const finalConfig = React.useMemo(() => ({
|
|
78
73
|
leftNavProps: props,
|
|
79
74
|
expandedForAnimation,
|
|
80
|
-
selectedItem,
|
|
75
|
+
selectedItem: props.selectedItem !== undefined ? props.selectedItem : selectedItem,
|
|
81
76
|
setSelectedItem,
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
selectedParent: props.selectedParent !== undefined ? props.selectedParent : selectedParent,
|
|
78
|
+
setSelectedParent,
|
|
84
79
|
focusedItem,
|
|
85
80
|
setFocusedItem,
|
|
86
|
-
focusedByKey,
|
|
87
|
-
setFocusedByKey,
|
|
88
81
|
openedDrilldowns,
|
|
89
82
|
setOpenedDrilldowns,
|
|
90
83
|
visibleItems,
|
|
91
84
|
visibleItemsRefs
|
|
92
|
-
}), [props,
|
|
85
|
+
}), [props, expandedForAnimation, selectedItem, setSelectedItem, setSelectedParent, selectedParent, focusedItem, setFocusedItem, openedDrilldowns, setOpenedDrilldowns, visibleItems, visibleItemsRefs]);
|
|
93
86
|
return finalConfig;
|
|
94
87
|
};
|
|
95
88
|
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
1
5
|
import { useMemo, useRef, createRef } from 'react';
|
|
2
6
|
import { ITEM_TYPES, FOOTER_DS_ID } from '../exported-related/constants.js';
|
|
3
7
|
import '@babel/runtime/helpers/esm/jsx';
|
|
4
8
|
import '@elliemae/ds-grid';
|
|
5
9
|
import 'styled-components';
|
|
10
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
11
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
6
12
|
import '@babel/runtime/helpers/esm/defineProperty';
|
|
7
13
|
import 'react/jsx-runtime';
|
|
8
|
-
import '@elliemae/ds-icons
|
|
9
|
-
import '@elliemae/ds-icons/Notifications';
|
|
10
|
-
import '@elliemae/ds-icons/ExceptionsSmallFill';
|
|
11
|
-
import '@elliemae/ds-icons/AlertsSmallFill';
|
|
12
|
-
import '@elliemae/ds-icons/MessagesSmallFill';
|
|
13
|
-
import '@elliemae/ds-icons/OpenWindow';
|
|
14
|
+
import '@elliemae/ds-icons';
|
|
14
15
|
|
|
15
|
-
/* eslint-disable complexity */
|
|
16
16
|
const notFocuseableItems = [ITEM_TYPES.LEFT_NAV_ITEM_SEPARATOR, ITEM_TYPES.LEFT_NAV_ITEM_SECTION]; // Walks the array of items
|
|
17
17
|
// Drilldowns are tree-like structures
|
|
18
18
|
|
|
19
19
|
const walkItems = (items, openedDrilldowns, callback) => {
|
|
20
20
|
items.forEach(item => {
|
|
21
21
|
if (typeof item.type === 'string') {
|
|
22
|
-
var _item$itemOpts, _item$itemOpts2, _item$itemOpts3;
|
|
22
|
+
var _item$itemOpts$items, _item$itemOpts, _item$itemOpts2, _item$itemOpts$items2, _item$itemOpts3;
|
|
23
23
|
|
|
24
24
|
// Out of the box item
|
|
25
25
|
if (notFocuseableItems.includes(item.type)) return; // not focuseable
|
|
26
26
|
|
|
27
27
|
callback(item.dsId); // If it's an opened uncontrolled drilldown
|
|
28
28
|
|
|
29
|
-
if (item.type === ITEM_TYPES.LEFT_NAV_ITEM_UNCONTROLLED_DRILLDOWN && openedDrilldowns.includes(item.dsId)) walkItems(((_item$itemOpts = item.itemOpts) === null || _item$itemOpts === void 0 ? void 0 : _item$itemOpts.items)
|
|
29
|
+
if (item.type === ITEM_TYPES.LEFT_NAV_ITEM_UNCONTROLLED_DRILLDOWN && openedDrilldowns.includes(item.dsId)) walkItems((_item$itemOpts$items = (_item$itemOpts = item.itemOpts) === null || _item$itemOpts === void 0 ? void 0 : _item$itemOpts.items) !== null && _item$itemOpts$items !== void 0 ? _item$itemOpts$items : [], openedDrilldowns, callback); // If it's an opened controlled drilldown
|
|
30
30
|
|
|
31
|
-
if (item.type === ITEM_TYPES.LEFT_NAV_ITEM_CONTROLLED_DRILLDOWN && (_item$itemOpts2 = item.itemOpts) !== null && _item$itemOpts2 !== void 0 && _item$itemOpts2.isOpened) walkItems(((_item$itemOpts3 = item.itemOpts) === null || _item$itemOpts3 === void 0 ? void 0 : _item$itemOpts3.items)
|
|
31
|
+
if (item.type === ITEM_TYPES.LEFT_NAV_ITEM_CONTROLLED_DRILLDOWN && (_item$itemOpts2 = item.itemOpts) !== null && _item$itemOpts2 !== void 0 && _item$itemOpts2.isOpened) walkItems((_item$itemOpts$items2 = (_item$itemOpts3 = item.itemOpts) === null || _item$itemOpts3 === void 0 ? void 0 : _item$itemOpts3.items) !== null && _item$itemOpts$items2 !== void 0 ? _item$itemOpts$items2 : [], openedDrilldowns, callback);
|
|
32
32
|
} else {
|
|
33
33
|
var _item$itemOpts4;
|
|
34
34
|
|
|
@@ -62,7 +62,7 @@ const useLeftNavItems = props => {
|
|
|
62
62
|
});
|
|
63
63
|
visibleItemsArray.push(FOOTER_DS_ID);
|
|
64
64
|
return visibleItemsArray;
|
|
65
|
-
}, [
|
|
65
|
+
}, [items, openedDrilldowns]);
|
|
66
66
|
visibleItems.forEach(dsId => {
|
|
67
67
|
if (!(dsId in visibleItemsRefs.current)) visibleItemsRefs.current[dsId] = /*#__PURE__*/createRef();
|
|
68
68
|
});
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
import 'react';
|
|
3
|
-
import
|
|
8
|
+
import { ChevronSmallRight } from '@elliemae/ds-icons';
|
|
4
9
|
import { jsx } from 'react/jsx-runtime';
|
|
5
10
|
|
|
6
11
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
7
12
|
|
|
8
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9
|
-
const ChevronItem = props => /*#__PURE__*/jsx(
|
|
14
|
+
const ChevronItem = props => /*#__PURE__*/jsx(ChevronSmallRight, _objectSpread({
|
|
10
15
|
size: "m",
|
|
11
16
|
color: ['brand-primary', 800]
|
|
12
17
|
}, props));
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
import 'react';
|
|
3
8
|
import styled from 'styled-components';
|
|
@@ -20,7 +20,8 @@ const ItemRenderer = props => {
|
|
|
20
20
|
ariaLabel,
|
|
21
21
|
ariaRole,
|
|
22
22
|
ariaLive,
|
|
23
|
-
ariaExpanded
|
|
23
|
+
ariaExpanded,
|
|
24
|
+
ariaDescribedBy
|
|
24
25
|
},
|
|
25
26
|
CollapsedComponent
|
|
26
27
|
},
|
|
@@ -40,10 +41,9 @@ const ItemRenderer = props => {
|
|
|
40
41
|
openedItem
|
|
41
42
|
},
|
|
42
43
|
expandedForAnimation,
|
|
43
|
-
|
|
44
|
+
selectedParent,
|
|
44
45
|
selectedItem,
|
|
45
46
|
setSelectedItem,
|
|
46
|
-
focusedItem,
|
|
47
47
|
setFocusedItem,
|
|
48
48
|
visibleItemsRefs
|
|
49
49
|
} = ctx;
|
|
@@ -63,7 +63,6 @@ const ItemRenderer = props => {
|
|
|
63
63
|
});
|
|
64
64
|
const cols = useMemo(() => expandedForAnimation ? ['auto', '1fr', 'auto'] : ['38px'], [expandedForAnimation]);
|
|
65
65
|
const isSelected = useMemo(() => selectedItem === dsId, [selectedItem, dsId]);
|
|
66
|
-
const isFocused = useMemo(() => focusedItem === dsId, [focusedItem, dsId]);
|
|
67
66
|
|
|
68
67
|
if (!expandedForAnimation && !CollapsedComponent) {
|
|
69
68
|
return null;
|
|
@@ -71,28 +70,30 @@ const ItemRenderer = props => {
|
|
|
71
70
|
|
|
72
71
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
73
72
|
children: [/*#__PURE__*/_jsx(StyledItemWrapper, {
|
|
74
|
-
shadowStyle: shadowStyle,
|
|
73
|
+
shadowStyle: shadowStyle(opened, item.type),
|
|
75
74
|
"data-testid": "leftnav-item-wrapper"
|
|
76
75
|
}, void 0, /*#__PURE__*/jsx(StyledItem, {
|
|
77
76
|
ref: visibleItemsRefs.current[dsId],
|
|
78
77
|
pt: paddingTop,
|
|
79
|
-
pl: indent === undefined ? 'xxxs' :
|
|
78
|
+
pl: indent === undefined ? 'xxxs' : "".concat(indent, "px"),
|
|
80
79
|
minHeight: minHeight,
|
|
81
|
-
shadowStyle: shadowStyle,
|
|
80
|
+
shadowStyle: shadowStyle(opened, item.type),
|
|
82
81
|
alignItems: "flex-start",
|
|
83
82
|
cols: cols,
|
|
84
83
|
onClick: !opened ? handleOnClick : () => null,
|
|
85
84
|
onKeyDown: onKeyDown,
|
|
86
85
|
selectable: selectable,
|
|
87
86
|
selected: isSelected,
|
|
87
|
+
selectedParent: selectedParent === dsId,
|
|
88
88
|
opened: opened,
|
|
89
|
-
focused: isFocused,
|
|
90
|
-
focusedByKey: focusedByKey,
|
|
91
89
|
onFocus: handleFocus,
|
|
92
90
|
"data-testid": "leftnav-item-container",
|
|
93
91
|
tabIndex: focuseable ? 0 : -1,
|
|
92
|
+
"aria-describedby": ariaDescribedBy,
|
|
94
93
|
"aria-expanded": ariaExpanded,
|
|
95
94
|
role: ariaRole,
|
|
95
|
+
"data-selected": isSelected,
|
|
96
|
+
"data-selectedparent": selectedParent === dsId,
|
|
96
97
|
"aria-label": ariaLabel,
|
|
97
98
|
"aria-hidden": !focuseable,
|
|
98
99
|
"aria-live": ariaLive,
|
|
@@ -108,7 +109,7 @@ const ItemRenderer = props => {
|
|
|
108
109
|
marginLeft: opened ? '16px' : '0px',
|
|
109
110
|
marginRight: borderBottomMr,
|
|
110
111
|
height: '1px',
|
|
111
|
-
width:
|
|
112
|
+
width: "calc(100% - ".concat(borderBottomMr, " - ").concat(opened ? '16px' : '0px', ")"),
|
|
112
113
|
backgroundColor: '#E0E3E8'
|
|
113
114
|
}
|
|
114
115
|
})), subitems]
|
|
@@ -2,47 +2,46 @@ import Grid from '@elliemae/ds-grid';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
4
|
/* eslint-disable indent */
|
|
5
|
+
const borderOutside = function (color) {
|
|
6
|
+
let weight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
7
|
+
return "&:before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border: ".concat(weight, "px solid ").concat(color, ";\n pointer-events: none;\n}");
|
|
8
|
+
};
|
|
5
9
|
const StyledItemWrapper = /*#__PURE__*/styled(Grid).withConfig({
|
|
6
10
|
componentId: "sc-11wzgfh-0"
|
|
7
11
|
})(["position:relative;", ""], props => props.shadowStyle(props.theme));
|
|
8
12
|
|
|
9
|
-
const getItemBackground =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const getItemBackground = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
selectable,
|
|
16
|
+
opened,
|
|
17
|
+
selected,
|
|
18
|
+
theme
|
|
19
|
+
} = _ref;
|
|
15
20
|
if (!selectable) return 'white';
|
|
16
21
|
if (selected && !opened) return theme.colors.brand[200];
|
|
17
22
|
return theme.colors.neutral['000'];
|
|
18
23
|
};
|
|
19
24
|
|
|
20
|
-
const getItemHoverBackground =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const getItemHoverBackground = _ref2 => {
|
|
26
|
+
let {
|
|
27
|
+
selectable,
|
|
28
|
+
opened,
|
|
29
|
+
selected,
|
|
30
|
+
theme
|
|
31
|
+
} = _ref2;
|
|
26
32
|
if (!selectable) return 'white';
|
|
27
33
|
if (selected && !opened) return theme.colors.brand[200];
|
|
28
|
-
return theme.colors.
|
|
34
|
+
return theme.colors.brand['200'];
|
|
29
35
|
};
|
|
30
36
|
|
|
31
37
|
const StyledItem = /*#__PURE__*/styled(Grid).withConfig({
|
|
32
38
|
componentId: "sc-11wzgfh-1"
|
|
33
|
-
})(["cursor:", ";min-height:", ";background:", "
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
top: 0;
|
|
41
|
-
left: 0;
|
|
42
|
-
right: 0;
|
|
43
|
-
bottom: 0;
|
|
44
|
-
border: 1px solid ${props.theme.colors.brand[600]};
|
|
45
|
-
pointer-events: none;
|
|
46
|
-
}` : '');
|
|
39
|
+
})(["cursor:", ";min-height:", ";background:", ";", ":hover{background:", ";}:active{background:", ";}", ";outline:none;", ""], props => props.selectable && !props.opened ? 'pointer' : 'auto', props => props.minHeight, getItemBackground, props => props.selected && !props.opened ? borderOutside(props.theme.colors.brand[500], 1) : '', getItemHoverBackground, _ref3 => {
|
|
40
|
+
let {
|
|
41
|
+
selectable,
|
|
42
|
+
theme
|
|
43
|
+
} = _ref3;
|
|
44
|
+
return selectable ? theme.colors.brand[200] : 'white';
|
|
45
|
+
}, props => props.shadowStyle(props.theme), props => props.tabIndex !== -1 ? ":focus {\n ".concat(borderOutside(props.theme.colors.brand[700]), "\n }") : '');
|
|
47
46
|
|
|
48
|
-
export { StyledItem, StyledItemWrapper };
|
|
47
|
+
export { StyledItem, StyledItemWrapper, borderOutside };
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
import { useMemo } from 'react';
|
|
3
8
|
|
|
@@ -14,8 +19,10 @@ const itemDefaultProps = {
|
|
|
14
19
|
ariaLabel: '',
|
|
15
20
|
ariaRole: 'menuitem',
|
|
16
21
|
ariaLive: 'off',
|
|
17
|
-
ariaExpanded: undefined
|
|
18
|
-
|
|
22
|
+
ariaExpanded: undefined,
|
|
23
|
+
ariaDescribedBy: undefined
|
|
24
|
+
};
|
|
25
|
+
const itemWithoutShadows = ['ds-left-nav-item-header', 'ds-left-nav-item-link', 'ds-left-nav-item-submenu']; // Make use Item props with defaults
|
|
19
26
|
|
|
20
27
|
const usePropsWithDefaults = props => {
|
|
21
28
|
const propsWithDefault = useMemo(() => {
|
|
@@ -29,7 +36,7 @@ const usePropsWithDefaults = props => {
|
|
|
29
36
|
minHeight: '48px',
|
|
30
37
|
paddingTop: '12px',
|
|
31
38
|
subitems: [],
|
|
32
|
-
shadowStyle: () =>
|
|
39
|
+
shadowStyle: (opened, type) => theme => "box-shadow: ".concat(opened || !itemWithoutShadows.includes(type) ? 'inset 4px 0 0 0 #52A6EC' : 'inset 4px 0 0 0 white'),
|
|
33
40
|
hasBorderBottom: false,
|
|
34
41
|
borderBottomMr: '0px'
|
|
35
42
|
}, props), {}, {
|
|
@@ -1,47 +1,51 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
2
|
import 'react';
|
|
3
|
-
import
|
|
4
|
-
import ExceptionsSmallFill from '@elliemae/ds-icons/ExceptionsSmallFill';
|
|
5
|
-
import AlertsSmallFill from '@elliemae/ds-icons/AlertsSmallFill';
|
|
6
|
-
import MessagesSmallFill from '@elliemae/ds-icons/MessagesSmallFill';
|
|
3
|
+
import { Notifications as Notifications$1, ExceptionsSmallFill, AlertsSmallFill, MessagesSmallFill } from '@elliemae/ds-icons';
|
|
7
4
|
import styled from 'styled-components';
|
|
8
5
|
import Grid from '@elliemae/ds-grid';
|
|
9
6
|
|
|
10
7
|
const StyledIcon = /*#__PURE__*/styled.div.withConfig({
|
|
11
8
|
componentId: "sc-hasbsd-0"
|
|
12
9
|
})(["display:flex;flex-direction:column;align-items:center;"]);
|
|
13
|
-
const Notifications =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, void 0,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
10
|
+
const Notifications = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
exceptions = false,
|
|
13
|
+
alerts = false,
|
|
14
|
+
messages = false
|
|
15
|
+
} = _ref;
|
|
16
|
+
return /*#__PURE__*/_jsx(StyledIcon, {}, void 0, /*#__PURE__*/_jsx(Notifications$1, {
|
|
17
|
+
size: "m",
|
|
18
|
+
color: ['brand-primary', 800],
|
|
19
|
+
"data-testid": "left-nav-notifications-icon"
|
|
20
|
+
}), (exceptions || alerts || messages) && /*#__PURE__*/_jsx(Grid, {
|
|
21
|
+
cols: ['1fr', '1fr', '1fr'],
|
|
22
|
+
gutter: "xxxs",
|
|
23
|
+
mt: "2px"
|
|
24
|
+
}, void 0, /*#__PURE__*/_jsx(Grid, {
|
|
25
|
+
width: "6px",
|
|
26
|
+
height: "6px",
|
|
27
|
+
"data-testid": "left-nav-exceptions-icon"
|
|
28
|
+
}, void 0, exceptions && /*#__PURE__*/_jsx(ExceptionsSmallFill, {
|
|
29
|
+
width: "6px",
|
|
30
|
+
height: "6px",
|
|
31
|
+
color: ['warning', 900]
|
|
32
|
+
})), /*#__PURE__*/_jsx(Grid, {
|
|
33
|
+
width: "6px",
|
|
34
|
+
height: "6px",
|
|
35
|
+
"data-testid": "left-nav-alerts-icon"
|
|
36
|
+
}, void 0, alerts && /*#__PURE__*/_jsx(AlertsSmallFill, {
|
|
37
|
+
width: "6px",
|
|
38
|
+
height: "6px",
|
|
39
|
+
color: ['danger', 900]
|
|
40
|
+
})), /*#__PURE__*/_jsx(Grid, {
|
|
41
|
+
width: "6px",
|
|
42
|
+
height: "6px",
|
|
43
|
+
"data-testid": "left-nav-messages-icon"
|
|
44
|
+
}, void 0, messages && /*#__PURE__*/_jsx(MessagesSmallFill, {
|
|
45
|
+
width: "6px",
|
|
46
|
+
height: "6px",
|
|
47
|
+
color: ['success', 900]
|
|
48
|
+
}))));
|
|
49
|
+
};
|
|
46
50
|
|
|
47
51
|
export { Notifications, Notifications as default };
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
import 'react';
|
|
3
8
|
import styled from 'styled-components';
|
|
4
|
-
import
|
|
9
|
+
import { OpenWindow as OpenWindow$1 } from '@elliemae/ds-icons';
|
|
5
10
|
import { jsx } from 'react/jsx-runtime';
|
|
6
11
|
|
|
7
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
8
13
|
|
|
9
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
10
|
-
const StyledOpenWindow = /*#__PURE__*/styled(
|
|
15
|
+
const StyledOpenWindow = /*#__PURE__*/styled(OpenWindow$1).withConfig({
|
|
11
16
|
componentId: "sc-g53ios-0"
|
|
12
17
|
})(["cursor:pointer;:focus{outline:1px solid ", ";}"], props => props.theme.colors.brand[800]);
|
|
13
18
|
const OpenWindow = props => /*#__PURE__*/jsx(StyledOpenWindow, _objectSpread({
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { useContext, useCallback } from 'react';
|
|
2
2
|
import { LeftNavContext } from '../LeftNavigationContext.js';
|
|
3
3
|
|
|
4
|
-
const useExpandableOnClickHandler =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const useExpandableOnClickHandler = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
id,
|
|
7
|
+
onExpand,
|
|
8
|
+
onOpen,
|
|
9
|
+
selectable = true
|
|
10
|
+
} = _ref;
|
|
10
11
|
const {
|
|
11
12
|
leftNavProps: {
|
|
12
13
|
expanded
|
|
@@ -19,10 +19,11 @@ const nextIndex = (index, length) => (index + 1) % length;
|
|
|
19
19
|
|
|
20
20
|
const prevIndex = (index, length) => (index - 1 + length) % length;
|
|
21
21
|
|
|
22
|
-
const useKeyboardNavigation =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const useKeyboardNavigation = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
item,
|
|
25
|
+
onClick
|
|
26
|
+
} = _ref;
|
|
26
27
|
const {
|
|
27
28
|
dsId,
|
|
28
29
|
itemOpts: {
|
|
@@ -37,7 +38,6 @@ const useKeyboardNavigation = ({
|
|
|
37
38
|
} = useContext(LeftNavContext);
|
|
38
39
|
const currentIndex = useMemo(() => visibleItems.findIndex(visibleItemDsId => visibleItemDsId === dsId), [dsId, visibleItems]);
|
|
39
40
|
const {
|
|
40
|
-
expandedForAnimation,
|
|
41
41
|
setFocusedItem,
|
|
42
42
|
focusedItem,
|
|
43
43
|
setSelectedItem
|
|
@@ -79,7 +79,7 @@ const useKeyboardNavigation = ({
|
|
|
79
79
|
|
|
80
80
|
if (closable && keyCode === KEY_CODES.LEFT_ARROW) {
|
|
81
81
|
onClick(e);
|
|
82
|
-
|
|
82
|
+
setFocusedItem(dsId);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
if (keyCode === KEY_CODES.DOWN_ARROW) {
|
|
@@ -99,7 +99,7 @@ const useKeyboardNavigation = ({
|
|
|
99
99
|
if (keyCode === KEY_CODES.END) {
|
|
100
100
|
setFocusedItem(visibleItems[visibleItems.length - 1]);
|
|
101
101
|
}
|
|
102
|
-
}, [
|
|
102
|
+
}, [openable, closable, selectable, focusedItem, onClick, focusAndSelect, dsId, setFocusedItem, visibleItems, currentIndex]);
|
|
103
103
|
return onKeyDown;
|
|
104
104
|
};
|
|
105
105
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { useContext, useCallback } from 'react';
|
|
2
2
|
import { LeftNavContext } from '../LeftNavigationContext.js';
|
|
3
3
|
|
|
4
|
-
const useOpenableOnClickHandler =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const useOpenableOnClickHandler = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
id,
|
|
7
|
+
opened,
|
|
8
|
+
onExpand,
|
|
9
|
+
onOpen,
|
|
10
|
+
onClose
|
|
11
|
+
} = _ref;
|
|
11
12
|
const {
|
|
12
13
|
leftNavProps: {
|
|
13
14
|
expanded
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.some.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.some.js';
|
|
1
4
|
import { useEffect } from 'react';
|
|
2
5
|
import { ITEM_TYPES } from '../exported-related/constants.js';
|
|
3
6
|
|
|
@@ -10,13 +13,20 @@ const isSelectableOutOfTheBox = elem => typeof elem.type === 'string' && elem.ty
|
|
|
10
13
|
|
|
11
14
|
const isSelectableCustom = elem => elem.itemOpts.selectable;
|
|
12
15
|
|
|
13
|
-
const
|
|
16
|
+
const isItemInsideTheTree = (item, itemID) => {
|
|
17
|
+
var _item$itemOpts, _item$itemOpts$items;
|
|
18
|
+
|
|
19
|
+
return item.dsId === itemID || (item === null || item === void 0 ? void 0 : (_item$itemOpts = item.itemOpts) === null || _item$itemOpts === void 0 ? void 0 : (_item$itemOpts$items = _item$itemOpts.items) === null || _item$itemOpts$items === void 0 ? void 0 : _item$itemOpts$items.some(it => isItemInsideTheTree(it, itemID)));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const useSelectFirstBodyItem = (items, openedItem, selectedItem, setSelectedItem, disableDefaultSelection) => {
|
|
14
23
|
useEffect(() => {
|
|
15
|
-
if (items && items.length && openedItem) {
|
|
24
|
+
if (!disableDefaultSelection && items && items.length && openedItem) {
|
|
16
25
|
const index = items.findIndex(elem => isSelectableOutOfTheBox(elem) || isSelectableCustom(elem));
|
|
17
|
-
|
|
26
|
+
const isItemInside = items.some(it => isItemInsideTheTree(it, selectedItem));
|
|
27
|
+
if (isItemInside) setSelectedItem(selectedItem);else if (index !== -1) setSelectedItem(items[index].dsId);
|
|
18
28
|
}
|
|
19
|
-
}, [openedItem]);
|
|
29
|
+
}, [openedItem, setSelectedItem, disableDefaultSelection]);
|
|
20
30
|
};
|
|
21
31
|
|
|
22
32
|
export { useSelectFirstBodyItem };
|
package/esm/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import 'overlayscrollbars/css/OverlayScrollbars.css';
|
|
2
1
|
export { LeftNavItemOptionsSchema, LeftNavItemPropsSchema } from './prop-types.js';
|
|
3
2
|
export { LeftNavigation, LeftNavigationWithSchema, LeftNavigation as default } from './LeftNavigation.js';
|
|
4
3
|
export { CHEVRON_BACK_DS_ID, FOOTER_DS_ID, FOOTER_MENU_CLOSE_DS_ID, ITEM_TYPES, LABEL_OVERFLOW } from './exported-related/constants.js';
|