@elliemae/ds-mini-toolbar 2.3.0-alpha.9 → 2.3.0-next.3
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/Components/MiniToolbar.js +70 -0
- package/cjs/Components/ToolbarShortcut.js +72 -0
- package/cjs/Components/outOfTheBox/Button.js +29 -0
- package/cjs/Components/outOfTheBox/ComboBox.js +25 -0
- package/cjs/Components/outOfTheBox/IconItem.js +36 -0
- package/cjs/Components/outOfTheBox/SearchBox.js +55 -0
- package/cjs/Components/outOfTheBox/Separator.js +19 -0
- package/cjs/Components/outOfTheBox/index.js +26 -0
- package/cjs/hooks/useGenerateItems.js +134 -0
- package/cjs/index.d.js +2 -0
- package/cjs/index.js +12 -0
- package/cjs/propTypes.js +35 -0
- package/cjs/styles.js +29 -0
- package/esm/Components/MiniToolbar.js +60 -0
- package/esm/Components/ToolbarShortcut.js +63 -0
- package/esm/Components/outOfTheBox/Button.js +20 -0
- package/esm/Components/outOfTheBox/ComboBox.js +17 -0
- package/esm/Components/outOfTheBox/IconItem.js +28 -0
- package/esm/Components/outOfTheBox/SearchBox.js +45 -0
- package/esm/Components/outOfTheBox/Separator.js +11 -0
- package/esm/Components/outOfTheBox/index.js +13 -0
- package/esm/hooks/useGenerateItems.js +125 -0
- package/esm/index.d.js +1 -0
- package/esm/index.js +2 -0
- package/esm/propTypes.js +30 -0
- package/esm/styles.js +17 -0
- package/package.json +43 -45
- package/{dist/types → types}/Components/MiniToolbar.d.ts +0 -0
- package/{dist/types → types}/Components/ToolbarShortcut.d.ts +0 -0
- package/{dist/types → types}/Components/outOfTheBox/Button.d.ts +0 -0
- package/{dist/types → types}/Components/outOfTheBox/ComboBox.d.ts +0 -0
- package/{dist/types → types}/Components/outOfTheBox/IconItem.d.ts +0 -0
- package/{dist/types → types}/Components/outOfTheBox/SearchBox.d.ts +0 -0
- package/{dist/types → types}/Components/outOfTheBox/Separator.d.ts +0 -0
- package/{dist/types → types}/Components/outOfTheBox/index.d.ts +0 -0
- package/{dist/types → types}/hooks/useGenerateItems.d.ts +0 -0
- package/{dist/types → types}/index.d.d.ts +0 -0
- package/{dist/types → types}/index.d.ts +0 -0
- package/{dist/types → types}/propTypes.d.ts +0 -0
- package/{dist/types → types}/styles.d.ts +0 -0
- package/{dist/types → types}/tests/DSMiniToolbar.events.test.d.ts +0 -0
- package/{dist/types → types}/tests/DSMiniToolbar.keyboard.test.d.ts +0 -0
- package/{dist/types → types}/tests/DSMiniToolbar.test.d.ts +0 -0
- package/{dist/types → types}/tests/utils.test.d.ts +0 -0
- package/dist/cjs/Components/MiniToolbar.js +0 -81
- package/dist/cjs/Components/MiniToolbar.js.map +0 -7
- package/dist/cjs/Components/ToolbarShortcut.js +0 -72
- package/dist/cjs/Components/ToolbarShortcut.js.map +0 -7
- package/dist/cjs/Components/outOfTheBox/Button.js +0 -41
- package/dist/cjs/Components/outOfTheBox/Button.js.map +0 -7
- package/dist/cjs/Components/outOfTheBox/ComboBox.js +0 -39
- package/dist/cjs/Components/outOfTheBox/ComboBox.js.map +0 -7
- package/dist/cjs/Components/outOfTheBox/IconItem.js +0 -50
- package/dist/cjs/Components/outOfTheBox/IconItem.js.map +0 -7
- package/dist/cjs/Components/outOfTheBox/SearchBox.js +0 -58
- package/dist/cjs/Components/outOfTheBox/SearchBox.js.map +0 -7
- package/dist/cjs/Components/outOfTheBox/Separator.js +0 -39
- package/dist/cjs/Components/outOfTheBox/Separator.js.map +0 -7
- package/dist/cjs/Components/outOfTheBox/index.js +0 -53
- package/dist/cjs/Components/outOfTheBox/index.js.map +0 -7
- package/dist/cjs/hooks/useGenerateItems.js +0 -120
- package/dist/cjs/hooks/useGenerateItems.js.map +0 -7
- package/dist/cjs/index.d.js +0 -27
- package/dist/cjs/index.d.js.map +0 -7
- package/dist/cjs/index.js +0 -38
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/propTypes.js +0 -69
- package/dist/cjs/propTypes.js.map +0 -7
- package/dist/cjs/styles.js +0 -62
- package/dist/cjs/styles.js.map +0 -7
- package/dist/esm/Components/MiniToolbar.js +0 -52
- package/dist/esm/Components/MiniToolbar.js.map +0 -7
- package/dist/esm/Components/ToolbarShortcut.js +0 -43
- package/dist/esm/Components/ToolbarShortcut.js.map +0 -7
- package/dist/esm/Components/outOfTheBox/Button.js +0 -12
- package/dist/esm/Components/outOfTheBox/Button.js.map +0 -7
- package/dist/esm/Components/outOfTheBox/ComboBox.js +0 -10
- package/dist/esm/Components/outOfTheBox/ComboBox.js.map +0 -7
- package/dist/esm/Components/outOfTheBox/IconItem.js +0 -21
- package/dist/esm/Components/outOfTheBox/IconItem.js.map +0 -7
- package/dist/esm/Components/outOfTheBox/SearchBox.js +0 -29
- package/dist/esm/Components/outOfTheBox/SearchBox.js.map +0 -7
- package/dist/esm/Components/outOfTheBox/Separator.js +0 -10
- package/dist/esm/Components/outOfTheBox/Separator.js.map +0 -7
- package/dist/esm/Components/outOfTheBox/index.js +0 -24
- package/dist/esm/Components/outOfTheBox/index.js.map +0 -7
- package/dist/esm/hooks/useGenerateItems.js +0 -102
- package/dist/esm/hooks/useGenerateItems.js.map +0 -7
- package/dist/esm/index.d.js +0 -2
- package/dist/esm/index.d.js.map +0 -7
- package/dist/esm/index.js +0 -9
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/propTypes.js +0 -40
- package/dist/esm/propTypes.js.map +0 -7
- package/dist/esm/styles.js +0 -33
- package/dist/esm/styles.js.map +0 -7
|
@@ -0,0 +1,63 @@
|
|
|
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';
|
|
6
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
7
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
+
import { useRef, useEffect } from 'react';
|
|
9
|
+
import { Item } from '../styles.js';
|
|
10
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
const ToolbarShortcut = props => {
|
|
17
|
+
const {
|
|
18
|
+
Component,
|
|
19
|
+
shortcutProps,
|
|
20
|
+
sharedProps,
|
|
21
|
+
ContextualRegion,
|
|
22
|
+
contextualRegionProps
|
|
23
|
+
} = props;
|
|
24
|
+
const leftRef = useRef(null);
|
|
25
|
+
const rightRef = useRef(null);
|
|
26
|
+
const timerLeft = useRef(null);
|
|
27
|
+
const timerRight = useRef(null);
|
|
28
|
+
const {
|
|
29
|
+
position = 'left',
|
|
30
|
+
isOpen = false
|
|
31
|
+
} = contextualRegionProps || {};
|
|
32
|
+
const {
|
|
33
|
+
style
|
|
34
|
+
} = shortcutProps || {};
|
|
35
|
+
|
|
36
|
+
const mergedProps = _objectSpread(_objectSpread({}, sharedProps), shortcutProps);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (isOpen && leftRef.current) {
|
|
40
|
+
timerLeft.current = setTimeout(() => leftRef.current.focus(), 200);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (isOpen && rightRef.current) {
|
|
44
|
+
timerRight.current = setTimeout(() => rightRef.current.focus(), 200);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return () => {
|
|
48
|
+
clearTimeout(timerLeft.current);
|
|
49
|
+
clearTimeout(timerRight.current);
|
|
50
|
+
};
|
|
51
|
+
}, [isOpen, leftRef, rightRef]);
|
|
52
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
53
|
+
children: [isOpen && position === 'left' && /*#__PURE__*/_jsx(Item, {}, void 0, /*#__PURE__*/jsx(ContextualRegion, _objectSpread({
|
|
54
|
+
innerRef: leftRef
|
|
55
|
+
}, contextualRegionProps))), Component && /*#__PURE__*/_jsx(Item, {
|
|
56
|
+
style: style
|
|
57
|
+
}, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, mergedProps))), isOpen && position === 'right' && /*#__PURE__*/_jsx(Item, {}, void 0, /*#__PURE__*/jsx(ContextualRegion, _objectSpread({
|
|
58
|
+
innerRef: rightRef
|
|
59
|
+
}, contextualRegionProps)))]
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export { ToolbarShortcut };
|
|
@@ -0,0 +1,20 @@
|
|
|
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';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import 'react';
|
|
8
|
+
import DSButton from '@elliemae/ds-button';
|
|
9
|
+
import { jsx } from 'react/jsx-runtime';
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
|
|
13
|
+
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; }
|
|
14
|
+
|
|
15
|
+
const MiniToolbarButton = props => /*#__PURE__*/jsx(DSButton, _objectSpread(_objectSpread({}, props), {}, {
|
|
16
|
+
"aria-label": props.ariaLabel,
|
|
17
|
+
"data-testid": "ds-mini-toolbar__shortcut"
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
export { MiniToolbarButton };
|
|
@@ -0,0 +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';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import 'react';
|
|
8
|
+
import { DSComboBox2 } from '@elliemae/ds-form';
|
|
9
|
+
import { jsx } from 'react/jsx-runtime';
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
|
|
13
|
+
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; }
|
|
14
|
+
|
|
15
|
+
const MiniToolbarComboBox = props => /*#__PURE__*/jsx(DSComboBox2, _objectSpread({}, props));
|
|
16
|
+
|
|
17
|
+
export { MiniToolbarComboBox };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { StyledButton } from '../../styles.js';
|
|
4
|
+
|
|
5
|
+
const MiniToolbarIcon = props => {
|
|
6
|
+
const {
|
|
7
|
+
Icon,
|
|
8
|
+
size,
|
|
9
|
+
color,
|
|
10
|
+
onClick,
|
|
11
|
+
ariaLabel,
|
|
12
|
+
style,
|
|
13
|
+
buttonType = 'secondary'
|
|
14
|
+
} = props;
|
|
15
|
+
return /*#__PURE__*/_jsx(StyledButton, {
|
|
16
|
+
"aria-label": ariaLabel,
|
|
17
|
+
buttonType: buttonType,
|
|
18
|
+
onClick: onClick,
|
|
19
|
+
style: style,
|
|
20
|
+
leftIcon: /*#__PURE__*/_jsx(Icon, {
|
|
21
|
+
size: size,
|
|
22
|
+
color: color
|
|
23
|
+
}),
|
|
24
|
+
"data-testid": "ds-mini-toolbar__shortcut"
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { MiniToolbarIcon };
|
|
@@ -0,0 +1,45 @@
|
|
|
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';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
+
import 'react';
|
|
9
|
+
import { Search } from '@elliemae/ds-icons';
|
|
10
|
+
import { DSSearchBox } from '@elliemae/ds-form';
|
|
11
|
+
import { StyledButton } from '../../styles.js';
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
const MiniToolbarSearchButton = props => {
|
|
19
|
+
const {
|
|
20
|
+
size,
|
|
21
|
+
color,
|
|
22
|
+
onClick,
|
|
23
|
+
ariaLabel,
|
|
24
|
+
style,
|
|
25
|
+
buttonType = 'secondary'
|
|
26
|
+
} = props;
|
|
27
|
+
return /*#__PURE__*/_jsx(StyledButton, {
|
|
28
|
+
"aria-label": ariaLabel,
|
|
29
|
+
buttonType: buttonType,
|
|
30
|
+
onClick: onClick,
|
|
31
|
+
style: style,
|
|
32
|
+
leftIcon: /*#__PURE__*/_jsx(Search, {
|
|
33
|
+
size: size,
|
|
34
|
+
color: color
|
|
35
|
+
}),
|
|
36
|
+
"data-testid": "ds-mini-toolbar__shortcut"
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const MiniToolbarSearchBox = props => /*#__PURE__*/jsx(DSSearchBox, _objectSpread({
|
|
41
|
+
clearable: true,
|
|
42
|
+
showIcon: false
|
|
43
|
+
}, props));
|
|
44
|
+
|
|
45
|
+
export { MiniToolbarSearchBox, MiniToolbarSearchButton };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { Separator } from '../../styles.js';
|
|
4
|
+
|
|
5
|
+
var _Separator;
|
|
6
|
+
|
|
7
|
+
const MiniToolbarSeparator = () => _Separator || (_Separator = /*#__PURE__*/_jsx(Separator, {
|
|
8
|
+
"data-testid": "ds-mini-toolbar__separator"
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
export { MiniToolbarSeparator };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { MiniToolbarButton } from './Button.js';
|
|
2
|
+
export { MiniToolbarIcon } from './IconItem.js';
|
|
3
|
+
export { MiniToolbarSearchBox } from './SearchBox.js';
|
|
4
|
+
export { MiniToolbarSeparator } from './Separator.js';
|
|
5
|
+
export { MiniToolbarComboBox } from './ComboBox.js';
|
|
6
|
+
|
|
7
|
+
const ICON_ITEM = 'ds-icon-item';
|
|
8
|
+
const SEPARATOR = 'ds-separator';
|
|
9
|
+
const BUTTON = 'ds-button';
|
|
10
|
+
const SEARCH_BOX = 'ds-search-box';
|
|
11
|
+
const COMBO_BOX = 'ds-combo-box';
|
|
12
|
+
|
|
13
|
+
export { BUTTON, COMBO_BOX, ICON_ITEM, SEARCH_BOX, SEPARATOR };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
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';
|
|
10
|
+
import { useMemo } from 'react';
|
|
11
|
+
import { uid } from 'uid';
|
|
12
|
+
import { Search } from '@elliemae/ds-icons';
|
|
13
|
+
import { SEARCH_BOX, SEPARATOR, BUTTON, ICON_ITEM, COMBO_BOX } from '../Components/outOfTheBox/index.js';
|
|
14
|
+
import { ToolbarShortcut } from '../Components/ToolbarShortcut.js';
|
|
15
|
+
import { MiniToolbarSearchButton, MiniToolbarSearchBox } from '../Components/outOfTheBox/SearchBox.js';
|
|
16
|
+
import { MiniToolbarSeparator } from '../Components/outOfTheBox/Separator.js';
|
|
17
|
+
import { MiniToolbarButton } from '../Components/outOfTheBox/Button.js';
|
|
18
|
+
import { MiniToolbarIcon } from '../Components/outOfTheBox/IconItem.js';
|
|
19
|
+
import { MiniToolbarComboBox } from '../Components/outOfTheBox/ComboBox.js';
|
|
20
|
+
|
|
21
|
+
var _MiniToolbarSeparator;
|
|
22
|
+
|
|
23
|
+
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; }
|
|
24
|
+
|
|
25
|
+
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; }
|
|
26
|
+
|
|
27
|
+
const useGenerateItems = items => {
|
|
28
|
+
const instanceUID = useMemo(() => uid(6), []);
|
|
29
|
+
const shortcutItems = useMemo(() => items.filter(item => item.hasShortcut || item.component === SEARCH_BOX || item.contextualRegion).map((item, index) => {
|
|
30
|
+
const {
|
|
31
|
+
component,
|
|
32
|
+
shortcutComponent,
|
|
33
|
+
shortcutProps,
|
|
34
|
+
sharedProps,
|
|
35
|
+
contextualRegion,
|
|
36
|
+
contextualRegionProps
|
|
37
|
+
} = item;
|
|
38
|
+
let Component;
|
|
39
|
+
let ContextualRegion;
|
|
40
|
+
if (component === SEPARATOR) return _MiniToolbarSeparator || (_MiniToolbarSeparator = /*#__PURE__*/_jsx(MiniToolbarSeparator, {}));
|
|
41
|
+
if (component === BUTTON) Component = MiniToolbarButton;else if (component === ICON_ITEM) Component = MiniToolbarIcon;else if (component === COMBO_BOX) Component = MiniToolbarComboBox;else if (component === SEARCH_BOX) {
|
|
42
|
+
if (item.hasShortcut) {
|
|
43
|
+
Component = MiniToolbarSearchButton;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ContextualRegion = MiniToolbarSearchBox;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!ContextualRegion) {
|
|
50
|
+
ContextualRegion = contextualRegion;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!Component) {
|
|
54
|
+
Component = shortcutComponent;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return /*#__PURE__*/_jsx(ToolbarShortcut, {
|
|
58
|
+
Component: Component,
|
|
59
|
+
shortcutProps: shortcutProps,
|
|
60
|
+
sharedProps: sharedProps,
|
|
61
|
+
ContextualRegion: ContextualRegion,
|
|
62
|
+
contextualRegionProps: contextualRegionProps
|
|
63
|
+
}, "".concat(instanceUID, "-shortcut-").concat(index));
|
|
64
|
+
}), [instanceUID, items]);
|
|
65
|
+
const dropdownMenuItems = useMemo(() => items.map((item, index) => {
|
|
66
|
+
const {
|
|
67
|
+
component,
|
|
68
|
+
sharedProps,
|
|
69
|
+
dropdownComponentProps
|
|
70
|
+
} = item;
|
|
71
|
+
const dropdownItem = {};
|
|
72
|
+
|
|
73
|
+
const {
|
|
74
|
+
Icon,
|
|
75
|
+
color,
|
|
76
|
+
label,
|
|
77
|
+
onClick
|
|
78
|
+
} = _objectSpread(_objectSpread({}, sharedProps), dropdownComponentProps);
|
|
79
|
+
|
|
80
|
+
if (component === SEPARATOR) dropdownItem.type = 'separator';else {
|
|
81
|
+
dropdownItem.id = "".concat(instanceUID, "-dropdown-").concat(index);
|
|
82
|
+
|
|
83
|
+
dropdownItem.onClick = () => onClick(item);
|
|
84
|
+
|
|
85
|
+
dropdownItem.label = label;
|
|
86
|
+
|
|
87
|
+
dropdownItem.onKeyDown = e => {
|
|
88
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
89
|
+
onClick(item);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (component === ICON_ITEM) {
|
|
95
|
+
dropdownItem.leftAddon = /*#__PURE__*/_jsx(Icon, {
|
|
96
|
+
color: color
|
|
97
|
+
});
|
|
98
|
+
} else if (component === SEARCH_BOX) {
|
|
99
|
+
dropdownItem.leftAddon = /*#__PURE__*/_jsx(Search, {
|
|
100
|
+
color: color
|
|
101
|
+
});
|
|
102
|
+
} else if (component === COMBO_BOX) {
|
|
103
|
+
dropdownItem.type = 'subMenu';
|
|
104
|
+
dropdownItem.label = label;
|
|
105
|
+
dropdownItem.subItems = sharedProps.options.map((option, index) => {
|
|
106
|
+
option.id = "".concat(instanceUID, "-option-").concat(index);
|
|
107
|
+
|
|
108
|
+
option.onClick = () => dropdownComponentProps.onSelectMenuItem(option);
|
|
109
|
+
|
|
110
|
+
option.onKeyDown = e => {
|
|
111
|
+
if (e.key === ' ' || e.key === 'Enter') {
|
|
112
|
+
dropdownComponentProps.onSelectMenuItem(option);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return option;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return dropdownItem;
|
|
121
|
+
}), [instanceUID, items]);
|
|
122
|
+
return [shortcutItems, dropdownMenuItems];
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export { useGenerateItems };
|
package/esm/index.d.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/esm/index.js
ADDED
package/esm/propTypes.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PropTypes, describe } from 'react-desc';
|
|
2
|
+
|
|
3
|
+
const outOfTheBoxType = PropTypes.oneOf(['ds-button', 'ds-icon-item', 'ds-separator', 'ds-search-box', 'ds-combo-box']).description('out-of-the-box toolbar components');
|
|
4
|
+
const toolbarItemProps = {
|
|
5
|
+
component: PropTypes.oneOfType([outOfTheBoxType, PropTypes.element]).description('Main component').isRequired,
|
|
6
|
+
hasShortcut: PropTypes.bool.description('Whether to include the component as a shortcut in the toolbar or not').defaultValue(false),
|
|
7
|
+
shortcutComponent: PropTypes.element.description('Component to render as a shortcut in the toolbar'),
|
|
8
|
+
shortcutProps: PropTypes.object.description('Shortcut component props'),
|
|
9
|
+
dropdownComponentProps: PropTypes.object.description('Dropdown component props'),
|
|
10
|
+
sharedProps: PropTypes.object.description('Props shared by shortcut component and dropdown component'),
|
|
11
|
+
contextualRegion: PropTypes.element.description('Component that can be rendered as an adjacent region to the shortcut component'),
|
|
12
|
+
contextualRegionProps: PropTypes.object.description('Contextual region component props')
|
|
13
|
+
};
|
|
14
|
+
const itemPropTypes = PropTypes.shape(toolbarItemProps).description('Items props');
|
|
15
|
+
const overflowButtonPropTypes = {
|
|
16
|
+
ariaLabel: PropTypes.string,
|
|
17
|
+
buttonType: PropTypes.oneOf(['secondary', 'text']),
|
|
18
|
+
style: PropTypes.object
|
|
19
|
+
};
|
|
20
|
+
const miniToolbarProps = {
|
|
21
|
+
items: PropTypes.arrayOf(itemPropTypes).description('Array of items').isRequired,
|
|
22
|
+
overflowButtonProps: PropTypes.shape(overflowButtonPropTypes).description('Overflow button props')
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const ToolbarItem = () => null;
|
|
26
|
+
|
|
27
|
+
const ToolbarItemWithSchema = describe(ToolbarItem);
|
|
28
|
+
ToolbarItemWithSchema.propTypes = toolbarItemProps;
|
|
29
|
+
|
|
30
|
+
export { ToolbarItemWithSchema, miniToolbarProps };
|
package/esm/styles.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import DSButton from '@elliemae/ds-button';
|
|
3
|
+
|
|
4
|
+
const Container = /*#__PURE__*/styled.ul.withConfig({
|
|
5
|
+
componentId: "sc-18ftw1x-0"
|
|
6
|
+
})(["display:flex;align-items:center;justify-content:center;width:fit-content;padding:0 6px;"]);
|
|
7
|
+
const Separator = /*#__PURE__*/styled.span.withConfig({
|
|
8
|
+
componentId: "sc-18ftw1x-1"
|
|
9
|
+
})(["height:24px;width:1px;margin:6px;border-left:1px solid #bbb;"]);
|
|
10
|
+
const Item = /*#__PURE__*/styled.li.withConfig({
|
|
11
|
+
componentId: "sc-18ftw1x-2"
|
|
12
|
+
})(["display:flex;margin:6px;cursor:pointer;"]);
|
|
13
|
+
const StyledButton = /*#__PURE__*/styled(DSButton).withConfig({
|
|
14
|
+
componentId: "sc-18ftw1x-3"
|
|
15
|
+
})(["&:not(:focus){border-color:transparent;}"]);
|
|
16
|
+
|
|
17
|
+
export { Container, Item, Separator, StyledButton };
|
package/package.json
CHANGED
|
@@ -1,62 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-mini-toolbar",
|
|
3
|
-
"version": "2.3.0-
|
|
3
|
+
"version": "2.3.0-next.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - MiniToolbar",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"module": "./dist/esm/index.js",
|
|
10
|
-
"main": "./dist/cjs/index.js",
|
|
11
|
-
"types": "./dist/types/index.d.ts",
|
|
6
|
+
"module": "./esm/index.js",
|
|
7
|
+
"main": "./cjs/index.js",
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
12
9
|
"exports": {
|
|
13
10
|
".": {
|
|
14
|
-
"import": "./
|
|
15
|
-
"require": "./
|
|
11
|
+
"import": "./esm/index.js",
|
|
12
|
+
"require": "./cjs/index.js"
|
|
16
13
|
},
|
|
17
14
|
"./styles": {
|
|
18
|
-
"import": "./
|
|
19
|
-
"require": "./
|
|
15
|
+
"import": "./esm/styles.js",
|
|
16
|
+
"require": "./cjs/styles.js"
|
|
20
17
|
},
|
|
21
18
|
"./propTypes": {
|
|
22
|
-
"import": "./
|
|
23
|
-
"require": "./
|
|
19
|
+
"import": "./esm/propTypes.js",
|
|
20
|
+
"require": "./cjs/propTypes.js"
|
|
24
21
|
},
|
|
25
22
|
"./hooks/useGenerateItems": {
|
|
26
|
-
"import": "./
|
|
27
|
-
"require": "./
|
|
23
|
+
"import": "./esm/hooks/useGenerateItems.js",
|
|
24
|
+
"require": "./cjs/hooks/useGenerateItems.js"
|
|
28
25
|
},
|
|
29
26
|
"./Components/ToolbarShortcut": {
|
|
30
|
-
"import": "./
|
|
31
|
-
"require": "./
|
|
27
|
+
"import": "./esm/Components/ToolbarShortcut.js",
|
|
28
|
+
"require": "./cjs/Components/ToolbarShortcut.js"
|
|
32
29
|
},
|
|
33
30
|
"./Components/outOfTheBox/Separator": {
|
|
34
|
-
"import": "./
|
|
35
|
-
"require": "./
|
|
31
|
+
"import": "./esm/Components/outOfTheBox/Separator.js",
|
|
32
|
+
"require": "./cjs/Components/outOfTheBox/Separator.js"
|
|
36
33
|
},
|
|
37
34
|
"./Components/outOfTheBox/SearchBox": {
|
|
38
|
-
"import": "./
|
|
39
|
-
"require": "./
|
|
35
|
+
"import": "./esm/Components/outOfTheBox/SearchBox.js",
|
|
36
|
+
"require": "./cjs/Components/outOfTheBox/SearchBox.js"
|
|
40
37
|
},
|
|
41
38
|
"./Components/outOfTheBox": {
|
|
42
|
-
"import": "./
|
|
43
|
-
"require": "./
|
|
39
|
+
"import": "./esm/Components/outOfTheBox/index.js",
|
|
40
|
+
"require": "./cjs/Components/outOfTheBox/index.js"
|
|
44
41
|
},
|
|
45
42
|
"./Components/outOfTheBox/IconItem": {
|
|
46
|
-
"import": "./
|
|
47
|
-
"require": "./
|
|
43
|
+
"import": "./esm/Components/outOfTheBox/IconItem.js",
|
|
44
|
+
"require": "./cjs/Components/outOfTheBox/IconItem.js"
|
|
48
45
|
},
|
|
49
46
|
"./Components/outOfTheBox/ComboBox": {
|
|
50
|
-
"import": "./
|
|
51
|
-
"require": "./
|
|
47
|
+
"import": "./esm/Components/outOfTheBox/ComboBox.js",
|
|
48
|
+
"require": "./cjs/Components/outOfTheBox/ComboBox.js"
|
|
52
49
|
},
|
|
53
50
|
"./Components/outOfTheBox/Button": {
|
|
54
|
-
"import": "./
|
|
55
|
-
"require": "./
|
|
51
|
+
"import": "./esm/Components/outOfTheBox/Button.js",
|
|
52
|
+
"require": "./cjs/Components/outOfTheBox/Button.js"
|
|
56
53
|
},
|
|
57
54
|
"./Components/MiniToolbar": {
|
|
58
|
-
"import": "./
|
|
59
|
-
"require": "./
|
|
55
|
+
"import": "./esm/Components/MiniToolbar.js",
|
|
56
|
+
"require": "./cjs/Components/MiniToolbar.js"
|
|
60
57
|
}
|
|
61
58
|
},
|
|
62
59
|
"repository": {
|
|
@@ -64,16 +61,22 @@
|
|
|
64
61
|
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
65
62
|
},
|
|
66
63
|
"engines": {
|
|
67
|
-
"
|
|
68
|
-
"node": ">=
|
|
64
|
+
"npm": ">=7",
|
|
65
|
+
"node": ">=14"
|
|
69
66
|
},
|
|
70
67
|
"author": "ICE MT",
|
|
68
|
+
"scripts": {
|
|
69
|
+
"dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
|
|
70
|
+
"prebuild": "exit 0",
|
|
71
|
+
"predev": "exit 0",
|
|
72
|
+
"build": "node ../../scripts/build/build.js"
|
|
73
|
+
},
|
|
71
74
|
"dependencies": {
|
|
72
|
-
"@elliemae/ds-button": "2.3.0-
|
|
73
|
-
"@elliemae/ds-dropdownmenu": "2.3.0-
|
|
74
|
-
"@elliemae/ds-form": "2.3.0-
|
|
75
|
-
"@elliemae/ds-icons": "2.3.0-
|
|
76
|
-
"@elliemae/ds-system": "2.3.0-
|
|
75
|
+
"@elliemae/ds-button": "2.3.0-next.3",
|
|
76
|
+
"@elliemae/ds-dropdownmenu": "2.3.0-next.3",
|
|
77
|
+
"@elliemae/ds-form": "2.3.0-next.3",
|
|
78
|
+
"@elliemae/ds-icons": "2.3.0-next.3",
|
|
79
|
+
"@elliemae/ds-system": "2.3.0-next.1",
|
|
77
80
|
"react-desc": "~4.1.3",
|
|
78
81
|
"uid": "~2.0.0"
|
|
79
82
|
},
|
|
@@ -90,12 +93,7 @@
|
|
|
90
93
|
},
|
|
91
94
|
"publishConfig": {
|
|
92
95
|
"access": "public",
|
|
93
|
-
"
|
|
94
|
-
|
|
95
|
-
"scripts": {
|
|
96
|
-
"dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
|
|
97
|
-
"prebuild": "exit 0",
|
|
98
|
-
"predev": "exit 0",
|
|
99
|
-
"build": "node ../../scripts/build/build.js"
|
|
96
|
+
"directory": "dist",
|
|
97
|
+
"generateSubmodules": true
|
|
100
98
|
}
|
|
101
99
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var MiniToolbar_exports = {};
|
|
29
|
-
__export(MiniToolbar_exports, {
|
|
30
|
-
MiniToolbar: () => MiniToolbar,
|
|
31
|
-
MiniToolbarWithSchema: () => MiniToolbarWithSchema
|
|
32
|
-
});
|
|
33
|
-
var React = __toESM(require("react"));
|
|
34
|
-
var import_react = __toESM(require("react"));
|
|
35
|
-
var import_react_desc = require("react-desc");
|
|
36
|
-
var import_ds_dropdownmenu = require("@elliemae/ds-dropdownmenu");
|
|
37
|
-
var import_ds_icons = require("@elliemae/ds-icons");
|
|
38
|
-
var import_styles = require("../styles");
|
|
39
|
-
var import_propTypes = require("../propTypes");
|
|
40
|
-
var import_useGenerateItems = require("../hooks/useGenerateItems");
|
|
41
|
-
const Elipsis = /* @__PURE__ */ import_react.default.createElement(import_ds_icons.MoreOptionsVert, {
|
|
42
|
-
color: ["brand-primary", "600"],
|
|
43
|
-
size: "m"
|
|
44
|
-
});
|
|
45
|
-
const MiniToolbar = ({ items, overflowButtonProps }) => {
|
|
46
|
-
const [shortcutItems, dropdownMenuItems] = (0, import_useGenerateItems.useGenerateItems)(items);
|
|
47
|
-
const [isDropdownMenuOpen, setIsDropdownMenuOpen] = (0, import_react.useState)(false);
|
|
48
|
-
const closeDropdownMenu = (0, import_react.useCallback)(() => setIsDropdownMenuOpen(false), []);
|
|
49
|
-
const openDropdownMenu = (0, import_react.useCallback)(() => setIsDropdownMenuOpen(true), []);
|
|
50
|
-
const openDropdownMenuKeyPress = (0, import_react.useCallback)((e) => {
|
|
51
|
-
if (e.key === " ") {
|
|
52
|
-
setIsDropdownMenuOpen(true);
|
|
53
|
-
}
|
|
54
|
-
}, []);
|
|
55
|
-
const { ariaLabel, style, buttonType = "secondary" } = overflowButtonProps || {};
|
|
56
|
-
return /* @__PURE__ */ import_react.default.createElement(import_styles.Container, {
|
|
57
|
-
role: "toolbar",
|
|
58
|
-
"data-testid": "ds-mini-toolbar"
|
|
59
|
-
}, shortcutItems, /* @__PURE__ */ import_react.default.createElement(import_ds_dropdownmenu.DSDropdownMenu, {
|
|
60
|
-
"data-testid": "ds-mini-toolbar__dropdown-menu",
|
|
61
|
-
isOpen: isDropdownMenuOpen,
|
|
62
|
-
onSelectMenuItem: closeDropdownMenu,
|
|
63
|
-
onClickOutsideMenu: closeDropdownMenu,
|
|
64
|
-
options: dropdownMenuItems,
|
|
65
|
-
triggerComponent: /* @__PURE__ */ import_react.default.createElement(import_styles.StyledButton, {
|
|
66
|
-
"aria-label": ariaLabel,
|
|
67
|
-
"data-testid": "ds-mini-toolbar__elipsis",
|
|
68
|
-
size: "m",
|
|
69
|
-
style,
|
|
70
|
-
buttonType,
|
|
71
|
-
onClick: openDropdownMenu,
|
|
72
|
-
onKeyPress: openDropdownMenuKeyPress,
|
|
73
|
-
leftIcon: Elipsis
|
|
74
|
-
})
|
|
75
|
-
}));
|
|
76
|
-
};
|
|
77
|
-
MiniToolbar.propTypes = import_propTypes.miniToolbarProps;
|
|
78
|
-
const MiniToolbarWithSchema = (0, import_react_desc.describe)(MiniToolbar);
|
|
79
|
-
MiniToolbarWithSchema.propTypes = import_propTypes.miniToolbarProps;
|
|
80
|
-
module.exports = __toCommonJS(MiniToolbar_exports);
|
|
81
|
-
//# sourceMappingURL=MiniToolbar.js.map
|