@elliemae/ds-global-header 2.0.0-rc.9 → 2.0.2
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/{index.d.js → GlobalHeaderTypes.js} +0 -0
- package/cjs/components/Breadcrumb/GlobalHeaderBreadcrumb.js +28 -18
- package/cjs/components/Breadcrumb/PureBreadcrumb.js +31 -8
- package/cjs/components/Breadcrumb/styles.js +9 -14
- package/cjs/components/Toolbar/ToolbarItems.js +49 -26
- package/cjs/components/Toolbar/styles.js +1 -6
- package/cjs/config/useGetPropsWithDefaults.js +2 -2
- package/cjs/config/useGlobalHeader.js +10 -4
- package/cjs/config/useValidateProps.js +5 -20
- package/cjs/config/validateHelpers.js +2 -2
- package/cjs/defaultProps.js +4 -2
- package/cjs/outOfTheBox/AppPicker/AppPicker.js +59 -27
- package/cjs/outOfTheBox/PopupMenu/PopupMenu.js +64 -49
- package/cjs/outOfTheBox/PopupMenu/PopupMenuContent.js +36 -16
- package/cjs/outOfTheBox/PopupMenu/styles.js +1 -1
- package/cjs/outOfTheBox/SearchToggle/SearchToggle.js +113 -0
- package/cjs/outOfTheBox/SearchToggle/styles.js +15 -0
- package/cjs/outOfTheBox/index.js +2 -0
- package/cjs/propTypes.js +1 -1
- package/esm/{index.d.js → GlobalHeaderTypes.js} +0 -0
- package/esm/components/Breadcrumb/GlobalHeaderBreadcrumb.js +26 -18
- package/esm/components/Breadcrumb/PureBreadcrumb.js +29 -8
- package/esm/components/Breadcrumb/styles.js +9 -14
- package/esm/components/Toolbar/ToolbarItems.js +48 -26
- package/esm/components/Toolbar/styles.js +1 -6
- package/esm/config/useGetPropsWithDefaults.js +2 -2
- package/esm/config/useGlobalHeader.js +10 -4
- package/esm/config/useValidateProps.js +5 -20
- package/esm/config/validateHelpers.js +2 -2
- package/esm/defaultProps.js +4 -2
- package/esm/outOfTheBox/AppPicker/AppPicker.js +57 -27
- package/esm/outOfTheBox/PopupMenu/PopupMenu.js +63 -49
- package/esm/outOfTheBox/PopupMenu/PopupMenuContent.js +37 -18
- package/esm/outOfTheBox/PopupMenu/styles.js +1 -1
- package/esm/outOfTheBox/SearchToggle/SearchToggle.js +103 -0
- package/esm/outOfTheBox/SearchToggle/styles.js +7 -0
- package/esm/outOfTheBox/index.js +1 -0
- package/esm/propTypes.js +1 -1
- package/package.json +19 -5
- package/types/GlobalHeader.d.ts +1 -1
- package/types/GlobalHeaderContainer.d.ts +1 -1
- package/types/GlobalHeaderContext.d.ts +1 -1
- package/types/{index.d.d.ts → GlobalHeaderTypes.d.ts} +28 -17
- package/types/components/Breadcrumb/PureBreadcrumb.d.ts +2 -2
- package/types/components/Breadcrumb/styles.d.ts +1 -1
- package/types/config/useGetPropsWithDefaults.d.ts +1 -1
- package/types/config/useGlobalHeader.d.ts +1 -1
- package/types/config/useValidateProps.d.ts +1 -1
- package/types/config/validateHelpers.d.ts +4 -4
- package/types/defaultProps.d.ts +1 -1
- package/types/outOfTheBox/AppPicker/AppPicker.d.ts +8 -3
- package/types/outOfTheBox/PopupMenu/PopupMenu.d.ts +2 -2
- package/types/outOfTheBox/PopupMenu/PopupMenuContent.d.ts +2 -2
- package/types/outOfTheBox/SearchToggle/SearchToggle.d.ts +2 -0
- package/types/outOfTheBox/SearchToggle/styles.d.ts +1 -0
- package/types/outOfTheBox/index.d.ts +1 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
3
4
|
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
4
5
|
import 'core-js/modules/esnext.iterator.map.js';
|
|
5
6
|
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
@@ -7,16 +8,20 @@ import 'core-js/modules/esnext.iterator.constructor.js';
|
|
|
7
8
|
import 'core-js/modules/esnext.iterator.filter.js';
|
|
8
9
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
10
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
10
|
-
import { useContext, useMemo
|
|
11
|
+
import { useContext, useMemo } from 'react';
|
|
11
12
|
import { AppPicker } from '../../outOfTheBox/AppPicker/AppPicker.js';
|
|
12
13
|
import { PopupMenu } from '../../outOfTheBox/PopupMenu/PopupMenu.js';
|
|
14
|
+
import { SearchToggle } from '../../outOfTheBox/SearchToggle/SearchToggle.js';
|
|
13
15
|
import { Button } from './styles.js';
|
|
14
16
|
import { GlobalHeaderContext } from '../../GlobalHeaderContext.js';
|
|
17
|
+
import { getDataProps } from '@elliemae/ds-props-helpers';
|
|
15
18
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
const _excluded = ["Icon", "type", "onClick", "componentProps", "label", "onKeyPress", "id", "CustomComponent"];
|
|
18
21
|
|
|
19
|
-
function
|
|
22
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
+
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
25
|
const ToolbarItems = () => {
|
|
21
26
|
const {
|
|
22
27
|
props: {
|
|
@@ -24,7 +29,7 @@ const ToolbarItems = () => {
|
|
|
24
29
|
},
|
|
25
30
|
instanceUID
|
|
26
31
|
} = useContext(GlobalHeaderContext);
|
|
27
|
-
const itemsList = useMemo(() => toolbar.map(item => {
|
|
32
|
+
const itemsList = useMemo(() => toolbar === null || toolbar === void 0 ? void 0 : toolbar.map(item => {
|
|
28
33
|
var _Icon;
|
|
29
34
|
|
|
30
35
|
const {
|
|
@@ -32,39 +37,56 @@ const ToolbarItems = () => {
|
|
|
32
37
|
type,
|
|
33
38
|
onClick,
|
|
34
39
|
componentProps,
|
|
35
|
-
label
|
|
36
|
-
|
|
40
|
+
label,
|
|
41
|
+
onKeyPress,
|
|
42
|
+
id,
|
|
43
|
+
CustomComponent
|
|
44
|
+
} = item,
|
|
45
|
+
otherProps = _objectWithoutProperties(item, _excluded);
|
|
37
46
|
|
|
38
47
|
switch (type) {
|
|
39
48
|
case 'ds-popup-menu':
|
|
40
|
-
|
|
41
|
-
options,
|
|
42
|
-
closeOnClick
|
|
43
|
-
} = componentProps;
|
|
44
|
-
return /*#__PURE__*/_jsx(PopupMenu, {
|
|
45
|
-
onClick: onClick,
|
|
49
|
+
return /*#__PURE__*/jsx(PopupMenu, _objectSpread(_objectSpread({
|
|
46
50
|
title: label,
|
|
47
51
|
Icon: Icon,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
onClick: onClick,
|
|
53
|
+
onKeyPress: onKeyPress,
|
|
54
|
+
id: id
|
|
55
|
+
}, otherProps), {}, {
|
|
56
|
+
componentProps: componentProps
|
|
57
|
+
}), "".concat(instanceUID, "-ds-popup-menu-").concat(label));
|
|
51
58
|
|
|
52
59
|
case 'ds-app-picker':
|
|
53
|
-
return /*#__PURE__*/
|
|
54
|
-
onClick: onClick,
|
|
60
|
+
return /*#__PURE__*/jsx(AppPicker, _objectSpread({
|
|
55
61
|
label: label,
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
id: id,
|
|
63
|
+
componentProps: componentProps
|
|
64
|
+
}, otherProps), "".concat(instanceUID, "-ds-app-picker-").concat(label));
|
|
65
|
+
|
|
66
|
+
case 'ds-search-toggle':
|
|
67
|
+
return /*#__PURE__*/jsx(SearchToggle, _objectSpread({
|
|
68
|
+
id: id,
|
|
69
|
+
componentProps: componentProps
|
|
70
|
+
}, otherProps), "".concat(instanceUID, "-ds-search-toggle-").concat(id));
|
|
71
|
+
|
|
72
|
+
case 'custom':
|
|
73
|
+
if (CustomComponent) return /*#__PURE__*/_jsx(CustomComponent, {
|
|
74
|
+
item: item
|
|
75
|
+
});
|
|
76
|
+
return null;
|
|
58
77
|
|
|
59
78
|
default:
|
|
60
|
-
return /*#__PURE__*/
|
|
79
|
+
return /*#__PURE__*/jsx(Button, _objectSpread(_objectSpread({
|
|
61
80
|
onClick: onClick,
|
|
62
81
|
title: label,
|
|
63
|
-
"data-testid": "gh-toolbar-item"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
"data-testid": "gh-toolbar-item",
|
|
83
|
+
id: id
|
|
84
|
+
}, getDataProps(otherProps)), {}, {
|
|
85
|
+
children: _Icon || (_Icon = /*#__PURE__*/_jsx(Icon, {
|
|
86
|
+
fill: "#FFF",
|
|
87
|
+
size: "m"
|
|
88
|
+
}))
|
|
89
|
+
}), "".concat(instanceUID, "-ds-toolbar-button-").concat(label));
|
|
68
90
|
}
|
|
69
91
|
}), [toolbar, instanceUID]);
|
|
70
92
|
return /*#__PURE__*/jsx(Fragment, {
|
|
@@ -2,7 +2,7 @@ import styled from 'styled-components';
|
|
|
2
2
|
|
|
3
3
|
const Button = /*#__PURE__*/styled.button.withConfig({
|
|
4
4
|
componentId: "sc-1gqj0i3-0"
|
|
5
|
-
})(["height:40px;width:40px;border:none;background-color:transparent;cursor:pointer;position:relative;outline:none;&:hover:not(:focus){background-color:", ";outline:none;}&:focus{:
|
|
5
|
+
})(["height:40px;width:40px;border:none;background-color:transparent;cursor:pointer;position:relative;outline:none;&:hover:not(:focus){background-color:", ";outline:none;}&:focus{:before{content:'';position:absolute;z-index:2;top:2px;left:2px;width:calc(100% - 4px);height:calc(100% - 4px);border:2px solid ", ";border-radius:4px;}}"], _ref => {
|
|
6
6
|
let {
|
|
7
7
|
theme
|
|
8
8
|
} = _ref;
|
|
@@ -11,11 +11,6 @@ const Button = /*#__PURE__*/styled.button.withConfig({
|
|
|
11
11
|
let {
|
|
12
12
|
theme
|
|
13
13
|
} = _ref2;
|
|
14
|
-
return theme.colors.brand[700];
|
|
15
|
-
}, _ref3 => {
|
|
16
|
-
let {
|
|
17
|
-
theme
|
|
18
|
-
} = _ref3;
|
|
19
14
|
return theme.colors.neutral['000'];
|
|
20
15
|
});
|
|
21
16
|
|
|
@@ -7,9 +7,9 @@ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
import { defaultProps } from '../defaultProps.js';
|
|
9
9
|
|
|
10
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
11
|
|
|
12
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
13
|
const useGetPropsWithDefaults = props => {
|
|
14
14
|
const {
|
|
15
15
|
toolbar,
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
-
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.map.js';
|
|
4
2
|
import React, { useState, useMemo } from 'react';
|
|
5
3
|
import { uid } from 'uid';
|
|
6
4
|
import { useGetPropsWithDefaults } from './useGetPropsWithDefaults.js';
|
|
@@ -8,8 +6,16 @@ import { useGetPropsWithDefaults } from './useGetPropsWithDefaults.js';
|
|
|
8
6
|
const useGlobalHeader = props => {
|
|
9
7
|
const [showIconOnly, setShowIconOnly] = useState(false);
|
|
10
8
|
const instanceUID = useMemo(() => uid(5), []);
|
|
11
|
-
const globalHeaderToolbarGrid = useMemo(() =>
|
|
12
|
-
|
|
9
|
+
const globalHeaderToolbarGrid = useMemo(() => {
|
|
10
|
+
var _props$toolbar$length, _props$toolbar;
|
|
11
|
+
|
|
12
|
+
return new Array((_props$toolbar$length = props === null || props === void 0 ? void 0 : (_props$toolbar = props.toolbar) === null || _props$toolbar === void 0 ? void 0 : _props$toolbar.length) !== null && _props$toolbar$length !== void 0 ? _props$toolbar$length : 0).fill('auto');
|
|
13
|
+
}, [props.toolbar]);
|
|
14
|
+
const globalHeaderBreadcrumbGrid = useMemo(() => {
|
|
15
|
+
var _props$breadcrumb$len, _props$breadcrumb;
|
|
16
|
+
|
|
17
|
+
return ['auto', ...new Array((_props$breadcrumb$len = props === null || props === void 0 ? void 0 : (_props$breadcrumb = props.breadcrumb) === null || _props$breadcrumb === void 0 ? void 0 : _props$breadcrumb.length) !== null && _props$breadcrumb$len !== void 0 ? _props$breadcrumb$len : 0).fill('auto'), '1fr'];
|
|
18
|
+
}, [props.breadcrumb]);
|
|
13
19
|
const propsWithDefaults = useGetPropsWithDefaults(props);
|
|
14
20
|
const ctx = React.useMemo(() => ({
|
|
15
21
|
props: propsWithDefaults,
|
|
@@ -31,21 +31,6 @@ const validateAppPickerItem = componentProps => {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
const validateGenericToolbarItem = item => {
|
|
35
|
-
if (item.label && typeof item.label !== 'string') {
|
|
36
|
-
throwToolbarItemGenericError('label', item.label);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (item.onClick && typeof item.onClick !== 'function') {
|
|
40
|
-
throwToolbarItemGenericError('onClick', item.onClick);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (item.Icon && typeof item.Icon !== 'function') {
|
|
44
|
-
if (item.type === 'ds-app-picker') return;
|
|
45
|
-
throwToolbarItemGenericError('Icon', item.Icon);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
34
|
const useValidateProps = props => {
|
|
50
35
|
const {
|
|
51
36
|
breadcrumb,
|
|
@@ -62,7 +47,7 @@ const useValidateProps = props => {
|
|
|
62
47
|
throwLogoError('LogoWithBrand', LogoWithBrand);
|
|
63
48
|
}
|
|
64
49
|
|
|
65
|
-
breadcrumb.forEach(breadcrumbItem => {
|
|
50
|
+
breadcrumb === null || breadcrumb === void 0 ? void 0 : breadcrumb.forEach(breadcrumbItem => {
|
|
66
51
|
if (breadcrumbItem.label && typeof breadcrumbItem.label !== 'string') {
|
|
67
52
|
throwBreadcrumbItemError('label', breadcrumbItem.label);
|
|
68
53
|
}
|
|
@@ -79,9 +64,7 @@ const useValidateProps = props => {
|
|
|
79
64
|
throwBreadcrumbItemError('isSelected', breadcrumbItem.isSelected);
|
|
80
65
|
}
|
|
81
66
|
});
|
|
82
|
-
toolbar.forEach(toolbarItem => {
|
|
83
|
-
validateGenericToolbarItem(toolbarItem);
|
|
84
|
-
|
|
67
|
+
toolbar === null || toolbar === void 0 ? void 0 : toolbar.forEach(toolbarItem => {
|
|
85
68
|
if (toolbarItem.type) {
|
|
86
69
|
if (!isValidToolbarType(toolbarItem.type)) {
|
|
87
70
|
throwToolbarItemGenericError('type', toolbarItem.type);
|
|
@@ -93,7 +76,9 @@ const useValidateProps = props => {
|
|
|
93
76
|
|
|
94
77
|
if (toolbarItem.type === 'ds-popup-menu') {
|
|
95
78
|
validatePopupItem(toolbarItem.componentProps);
|
|
96
|
-
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (toolbarItem.type === 'ds-app-picker') {
|
|
97
82
|
validateAppPickerItem(toolbarItem.componentProps);
|
|
98
83
|
}
|
|
99
84
|
}
|
|
@@ -6,7 +6,7 @@ const breadcrumbProps = {
|
|
|
6
6
|
};
|
|
7
7
|
const toolbarProps = {
|
|
8
8
|
label: 'string',
|
|
9
|
-
type: '"ds-app-picker" or "ds-popup-menu"',
|
|
9
|
+
type: '"ds-app-picker" or "ds-popup-menu" or "ds-search-toggle"',
|
|
10
10
|
componentProps: 'object',
|
|
11
11
|
Icon: 'react component',
|
|
12
12
|
onClick: 'function',
|
|
@@ -24,7 +24,7 @@ const getVariableType = arg => {
|
|
|
24
24
|
if (arg === undefined) return 'undefined';
|
|
25
25
|
return typeof arg;
|
|
26
26
|
};
|
|
27
|
-
const isValidToolbarType = string => string === 'ds-app-picker' || string === 'ds-popup-menu';
|
|
27
|
+
const isValidToolbarType = string => string === 'ds-app-picker' || string === 'ds-popup-menu' || string === 'ds-search-toggle' || string === 'custom';
|
|
28
28
|
const throwBreadcrumbItemError = (validPropKey, invalidProp) => {
|
|
29
29
|
throw new Error("You are trying to pass a not valid \"".concat(validPropKey, "\" property for a breadcrumb item, please provide a valid type.\n\n Received: ").concat(invalidProp, " (").concat(typeof invalidProp, ")\n Expected: (").concat(breadcrumbProps[validPropKey], ")\n "));
|
|
30
30
|
};
|
package/esm/defaultProps.js
CHANGED
|
@@ -1,77 +1,107 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
1
2
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
2
4
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
3
10
|
import { useState, useRef, useCallback, useMemo } from 'react';
|
|
4
11
|
import { DSAppPicker } from '@elliemae/ds-app-picker';
|
|
12
|
+
import { mergeRefs } from '@elliemae/ds-utilities';
|
|
5
13
|
import { MenuPicker } from '@elliemae/ds-icons';
|
|
6
14
|
import { Button } from '../../components/Toolbar/styles.js';
|
|
15
|
+
import { getDataProps } from '@elliemae/ds-props-helpers';
|
|
7
16
|
import { jsx } from 'react/jsx-runtime';
|
|
8
17
|
|
|
9
18
|
var _MenuPicker;
|
|
10
|
-
const AppPicker = _ref => {
|
|
11
|
-
var _DSAppPicker;
|
|
12
19
|
|
|
20
|
+
const _excluded = ["label", "id", "componentProps"];
|
|
21
|
+
|
|
22
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
+
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
+
const AppPicker = _ref => {
|
|
13
26
|
let {
|
|
14
27
|
label,
|
|
28
|
+
id,
|
|
29
|
+
componentProps
|
|
30
|
+
} = _ref,
|
|
31
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
|
|
33
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
34
|
+
const buttonRef = useRef(null);
|
|
35
|
+
const {
|
|
15
36
|
apps,
|
|
37
|
+
icon,
|
|
16
38
|
customApps,
|
|
17
39
|
sectionTitle,
|
|
18
40
|
customSectionTitle,
|
|
19
|
-
onClick = () => null,
|
|
20
41
|
actionRef,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
42
|
+
isOpen: userIsOpen,
|
|
43
|
+
onKeyDown: userOnKeyDown,
|
|
44
|
+
onClickOutside: userOnClickOutside,
|
|
45
|
+
renderTrigger: userRenderTrigger,
|
|
46
|
+
onClose,
|
|
47
|
+
triggerRef,
|
|
48
|
+
triggerOnClick
|
|
49
|
+
} = componentProps;
|
|
25
50
|
const handleTriggerKeyDown = useCallback(e => {
|
|
26
51
|
if (e.code === 'Enter' || e.code === 'Space') {
|
|
27
52
|
setIsOpen(true);
|
|
28
53
|
}
|
|
29
54
|
}, []);
|
|
30
55
|
const handleAppPickerOnKeyDown = useCallback(e => {
|
|
31
|
-
customHandleOnKeyDown(e);
|
|
32
|
-
|
|
33
56
|
if (e.code === 'Escape') {
|
|
57
|
+
var _buttonRef$current;
|
|
58
|
+
|
|
34
59
|
setIsOpen(false);
|
|
60
|
+
buttonRef === null || buttonRef === void 0 ? void 0 : (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
|
|
35
61
|
}
|
|
36
|
-
}, [
|
|
62
|
+
}, []);
|
|
37
63
|
const handleOnClickOutside = useCallback(() => {
|
|
38
64
|
setIsOpen(false);
|
|
39
65
|
}, []);
|
|
40
|
-
const handleOnClick = useCallback(
|
|
66
|
+
const handleOnClick = useCallback(() => {
|
|
41
67
|
setIsOpen(true);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const trigger = useMemo(() => _ref2 => {
|
|
68
|
+
}, []);
|
|
69
|
+
const renderTrigger = useMemo(() => _ref2 => {
|
|
45
70
|
let {
|
|
46
71
|
ref
|
|
47
72
|
} = _ref2;
|
|
48
73
|
return /*#__PURE__*/jsx("div", {
|
|
49
74
|
ref: ref,
|
|
50
|
-
children: /*#__PURE__*/jsx(Button, {
|
|
51
|
-
onClick: handleOnClick,
|
|
75
|
+
children: /*#__PURE__*/jsx(Button, _objectSpread(_objectSpread({
|
|
76
|
+
onClick: triggerOnClick !== null && triggerOnClick !== void 0 ? triggerOnClick : handleOnClick,
|
|
52
77
|
onKeyDown: handleTriggerKeyDown,
|
|
53
|
-
ref: buttonRef,
|
|
78
|
+
ref: mergeRefs(buttonRef, triggerRef),
|
|
54
79
|
title: label,
|
|
55
80
|
"data-testid": "gh-toolbar-item",
|
|
81
|
+
id: id
|
|
82
|
+
}, getDataProps(otherProps)), {}, {
|
|
56
83
|
children: _MenuPicker || (_MenuPicker = /*#__PURE__*/_jsx(MenuPicker, {
|
|
57
84
|
fill: "#FFF",
|
|
58
|
-
|
|
85
|
+
width: 20.73,
|
|
86
|
+
height: 20.73
|
|
59
87
|
}))
|
|
60
|
-
})
|
|
88
|
+
}))
|
|
61
89
|
});
|
|
62
|
-
}, [handleOnClick, handleTriggerKeyDown, label]);
|
|
63
|
-
return
|
|
64
|
-
isOpen: isOpen,
|
|
90
|
+
}, [triggerOnClick, handleOnClick, handleTriggerKeyDown, triggerRef, label, id, otherProps]);
|
|
91
|
+
return /*#__PURE__*/_jsx(DSAppPicker, {
|
|
65
92
|
apps: apps,
|
|
66
93
|
customApps: customApps,
|
|
67
94
|
sectionTitle: sectionTitle,
|
|
68
95
|
customSectionTitle: customSectionTitle,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
triggerRef: buttonRef,
|
|
96
|
+
icon: icon,
|
|
97
|
+
onKeyDown: userOnKeyDown !== null && userOnKeyDown !== void 0 ? userOnKeyDown : handleAppPickerOnKeyDown,
|
|
72
98
|
actionRef: actionRef,
|
|
73
|
-
|
|
74
|
-
|
|
99
|
+
onClickOutside: userOnClickOutside !== null && userOnClickOutside !== void 0 ? userOnClickOutside : handleOnClickOutside,
|
|
100
|
+
renderTrigger: userRenderTrigger !== null && userRenderTrigger !== void 0 ? userRenderTrigger : renderTrigger,
|
|
101
|
+
isOpen: userIsOpen !== null && userIsOpen !== void 0 ? userIsOpen : isOpen,
|
|
102
|
+
onClose: onClose,
|
|
103
|
+
triggerRef: triggerRef
|
|
104
|
+
});
|
|
75
105
|
};
|
|
76
106
|
|
|
77
107
|
export { AppPicker };
|
|
@@ -1,77 +1,91 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
1
2
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
2
4
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
10
|
+
import { useState, useCallback, useMemo } from 'react';
|
|
11
|
+
import { DSPopperJS } from '@elliemae/ds-popperjs';
|
|
5
12
|
import { PopupMenuContent } from './PopupMenuContent.js';
|
|
6
13
|
import { Button } from '../../components/Toolbar/styles.js';
|
|
14
|
+
import { getDataProps } from '@elliemae/ds-props-helpers';
|
|
7
15
|
import { jsx } from 'react/jsx-runtime';
|
|
8
16
|
|
|
17
|
+
const _excluded = ["Icon", "title", "onClick", "id", "componentProps"];
|
|
18
|
+
|
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
+
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
22
|
const PopupMenu = _ref => {
|
|
10
23
|
var _PopupMenuContent;
|
|
11
24
|
|
|
12
25
|
let {
|
|
13
26
|
Icon,
|
|
14
|
-
options,
|
|
15
|
-
closeOnClick,
|
|
16
27
|
title,
|
|
17
|
-
onClick
|
|
18
|
-
|
|
28
|
+
onClick,
|
|
29
|
+
id,
|
|
30
|
+
componentProps
|
|
31
|
+
} = _ref,
|
|
32
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
33
|
+
|
|
19
34
|
const [isOpen, setIsOpen] = useState(false);
|
|
20
|
-
const buttonRef =
|
|
35
|
+
const [buttonRef, setButtonRef] = useState(null);
|
|
36
|
+
const {
|
|
37
|
+
onClickOutside = () => null,
|
|
38
|
+
onKeyPress,
|
|
39
|
+
popupOnKeyPress,
|
|
40
|
+
isOpen: userIsOpen,
|
|
41
|
+
options,
|
|
42
|
+
closeOnClick
|
|
43
|
+
} = componentProps;
|
|
21
44
|
const handleKeyPress = useCallback(e => {
|
|
22
45
|
if (e.code === 'Enter' || e.code === 'Space') {
|
|
23
46
|
setIsOpen(true);
|
|
24
47
|
}
|
|
25
|
-
|
|
48
|
+
|
|
49
|
+
if (onKeyPress) onKeyPress(e);
|
|
50
|
+
}, [onKeyPress]);
|
|
26
51
|
const handleOnClose = useCallback(() => {
|
|
27
|
-
|
|
52
|
+
if (userIsOpen === undefined) {
|
|
53
|
+
setIsOpen(false);
|
|
54
|
+
}
|
|
28
55
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}, []);
|
|
56
|
+
buttonRef === null || buttonRef === void 0 ? void 0 : buttonRef.focus();
|
|
57
|
+
}, [buttonRef, userIsOpen]);
|
|
32
58
|
const handleTriggerOnClick = useCallback(e => {
|
|
33
|
-
setIsOpen(true);
|
|
59
|
+
if (userIsOpen === undefined) setIsOpen(true);
|
|
34
60
|
onClick(e);
|
|
35
|
-
}, [onClick]);
|
|
61
|
+
}, [onClick, userIsOpen]);
|
|
36
62
|
const handleItemClick = useCallback(() => {
|
|
37
|
-
if (closeOnClick) handleOnClose();
|
|
38
|
-
}, [closeOnClick, handleOnClose]);
|
|
39
|
-
const handleClickOutside = useCallback(() => setIsOpen(false), []);
|
|
63
|
+
if (closeOnClick && userIsOpen === undefined) handleOnClose();
|
|
64
|
+
}, [closeOnClick, handleOnClose, userIsOpen]);
|
|
40
65
|
const content = useMemo(() => _PopupMenuContent || (_PopupMenuContent = /*#__PURE__*/_jsx(PopupMenuContent, {
|
|
41
66
|
options: options,
|
|
42
67
|
onItemClick: handleItemClick,
|
|
43
|
-
onClose: handleOnClose
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
content: content,
|
|
65
|
-
onClickOutside: handleClickOutside,
|
|
66
|
-
placement: "bottom",
|
|
67
|
-
interactionType: "click",
|
|
68
|
-
showArrow: true,
|
|
69
|
-
style: {
|
|
70
|
-
padding: '0',
|
|
71
|
-
width: 'fit-content'
|
|
72
|
-
},
|
|
73
|
-
renderTrigger: trigger
|
|
74
|
-
}), [content, handleClickOutside, isOpen, trigger]);
|
|
68
|
+
onClose: handleOnClose,
|
|
69
|
+
popupOnKeyPress: popupOnKeyPress
|
|
70
|
+
})), [options, handleItemClick, handleOnClose, popupOnKeyPress]);
|
|
71
|
+
return /*#__PURE__*/_jsx("div", {}, void 0, /*#__PURE__*/jsx(Button, _objectSpread(_objectSpread({
|
|
72
|
+
onClick: handleTriggerOnClick,
|
|
73
|
+
onKeyPress: handleKeyPress,
|
|
74
|
+
title: title,
|
|
75
|
+
ref: setButtonRef,
|
|
76
|
+
"data-testid": "gh-toolbar-item",
|
|
77
|
+
id: id
|
|
78
|
+
}, getDataProps(otherProps)), {}, {
|
|
79
|
+
children: Icon && /*#__PURE__*/_jsx(Icon, {
|
|
80
|
+
fill: "#FFF",
|
|
81
|
+
size: "m"
|
|
82
|
+
})
|
|
83
|
+
})), /*#__PURE__*/_jsx(DSPopperJS, {
|
|
84
|
+
referenceElement: buttonRef,
|
|
85
|
+
showPopover: userIsOpen !== null && userIsOpen !== void 0 ? userIsOpen : isOpen,
|
|
86
|
+
closeContextMenu: handleOnClose,
|
|
87
|
+
onClickOutside: onClickOutside
|
|
88
|
+
}, void 0, content));
|
|
75
89
|
};
|
|
76
90
|
|
|
77
91
|
export { PopupMenu };
|
|
@@ -1,63 +1,82 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
3
|
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
3
4
|
import 'core-js/modules/esnext.iterator.map.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
10
|
import React, { useContext, useRef, useEffect, useMemo } from 'react';
|
|
5
|
-
import {
|
|
11
|
+
import { getDataProps, getAriaProps } from '@elliemae/ds-props-helpers';
|
|
12
|
+
import { ItemWrapper, Separator, List, Label } from './styles.js';
|
|
6
13
|
import { GlobalHeaderContext } from '../../GlobalHeaderContext.js';
|
|
7
|
-
import { jsx } from 'react/jsx-runtime';
|
|
14
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
15
|
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
19
|
const PopupMenuContent = /*#__PURE__*/React.memo(_ref => {
|
|
10
20
|
let {
|
|
11
21
|
options,
|
|
12
22
|
onItemClick,
|
|
13
|
-
onClose
|
|
23
|
+
onClose,
|
|
24
|
+
popupOnKeyPress
|
|
14
25
|
} = _ref;
|
|
15
26
|
const {
|
|
16
27
|
instanceUID
|
|
17
28
|
} = useContext(GlobalHeaderContext);
|
|
18
|
-
const menuRef = useRef();
|
|
29
|
+
const menuRef = useRef(null);
|
|
19
30
|
useEffect(() => {
|
|
20
31
|
var _menuRef$current, _menuRef$current$firs;
|
|
21
32
|
|
|
22
33
|
(_menuRef$current = menuRef.current) === null || _menuRef$current === void 0 ? void 0 : (_menuRef$current$firs = _menuRef$current.firstChild) === null || _menuRef$current$firs === void 0 ? void 0 : _menuRef$current$firs.focus();
|
|
23
34
|
}, []);
|
|
24
35
|
const content = useMemo(() => options.map(option => {
|
|
25
|
-
var _Content;
|
|
26
|
-
|
|
27
36
|
const {
|
|
28
37
|
type,
|
|
29
|
-
|
|
30
|
-
label,
|
|
38
|
+
Icon,
|
|
39
|
+
label = '',
|
|
31
40
|
onClick,
|
|
32
|
-
Content
|
|
41
|
+
Content,
|
|
42
|
+
id
|
|
33
43
|
} = option;
|
|
34
44
|
|
|
45
|
+
const ariaAndDataProps = _objectSpread(_objectSpread({}, getAriaProps(option)), getDataProps(option));
|
|
46
|
+
|
|
35
47
|
const handleClick = e => {
|
|
36
48
|
onItemClick(e);
|
|
37
|
-
onClick(e);
|
|
49
|
+
if (onClick) onClick(e);
|
|
38
50
|
};
|
|
39
51
|
|
|
40
52
|
const handleKeyDown = e => {
|
|
41
53
|
if (e.code === 'Escape') onClose();
|
|
54
|
+
if (popupOnKeyPress) popupOnKeyPress(e);
|
|
42
55
|
};
|
|
43
56
|
|
|
44
57
|
switch (type) {
|
|
45
58
|
case 'separator':
|
|
46
|
-
return /*#__PURE__*/
|
|
59
|
+
return /*#__PURE__*/jsx(Separator, _objectSpread({}, ariaAndDataProps), "".concat(instanceUID, "-separator-").concat(label));
|
|
47
60
|
|
|
48
61
|
case 'custom':
|
|
49
|
-
return /*#__PURE__*/
|
|
62
|
+
return /*#__PURE__*/jsx(ItemWrapper, _objectSpread(_objectSpread({
|
|
50
63
|
onClick: handleClick,
|
|
51
|
-
onKeyDown: handleKeyDown
|
|
52
|
-
|
|
64
|
+
onKeyDown: handleKeyDown,
|
|
65
|
+
id: id
|
|
66
|
+
}, ariaAndDataProps), {}, {
|
|
67
|
+
children: Content && /*#__PURE__*/_jsx(Content, {})
|
|
68
|
+
}), "".concat(instanceUID, "-popup-").concat(label));
|
|
53
69
|
|
|
54
70
|
default:
|
|
55
|
-
return /*#__PURE__*/
|
|
71
|
+
return /*#__PURE__*/jsxs(ItemWrapper, _objectSpread(_objectSpread({
|
|
56
72
|
onClick: handleClick,
|
|
57
|
-
onKeyDown: handleKeyDown
|
|
58
|
-
|
|
73
|
+
onKeyDown: handleKeyDown,
|
|
74
|
+
id: id
|
|
75
|
+
}, ariaAndDataProps), {}, {
|
|
76
|
+
children: [Icon && /*#__PURE__*/_jsx(Icon, {}), Label && /*#__PURE__*/_jsx(Label, {}, void 0, label)]
|
|
77
|
+
}), "".concat(instanceUID, "-popup-").concat(label));
|
|
59
78
|
}
|
|
60
|
-
}), [
|
|
79
|
+
}), [options, onItemClick, onClose, popupOnKeyPress, instanceUID]);
|
|
61
80
|
return /*#__PURE__*/jsx(List, {
|
|
62
81
|
ref: menuRef,
|
|
63
82
|
children: content
|