@elliemae/ds-mini-toolbar 2.3.0-next.3 → 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Components/MiniToolbar.js +81 -0
- package/dist/cjs/Components/MiniToolbar.js.map +7 -0
- package/dist/cjs/Components/ToolbarShortcut.js +72 -0
- package/dist/cjs/Components/ToolbarShortcut.js.map +7 -0
- package/dist/cjs/Components/outOfTheBox/Button.js +41 -0
- package/dist/cjs/Components/outOfTheBox/Button.js.map +7 -0
- package/dist/cjs/Components/outOfTheBox/ComboBox.js +39 -0
- package/dist/cjs/Components/outOfTheBox/ComboBox.js.map +7 -0
- package/dist/cjs/Components/outOfTheBox/IconItem.js +50 -0
- package/dist/cjs/Components/outOfTheBox/IconItem.js.map +7 -0
- package/dist/cjs/Components/outOfTheBox/SearchBox.js +58 -0
- package/dist/cjs/Components/outOfTheBox/SearchBox.js.map +7 -0
- package/dist/cjs/Components/outOfTheBox/Separator.js +39 -0
- package/dist/cjs/Components/outOfTheBox/Separator.js.map +7 -0
- package/dist/cjs/Components/outOfTheBox/index.js +53 -0
- package/dist/cjs/Components/outOfTheBox/index.js.map +7 -0
- package/dist/cjs/hooks/useGenerateItems.js +120 -0
- package/dist/cjs/hooks/useGenerateItems.js.map +7 -0
- package/dist/cjs/index.d.js +27 -0
- package/dist/cjs/index.d.js.map +7 -0
- package/dist/cjs/index.js +38 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/propTypes.js +69 -0
- package/dist/cjs/propTypes.js.map +7 -0
- package/dist/cjs/styles.js +62 -0
- package/dist/cjs/styles.js.map +7 -0
- package/dist/esm/Components/MiniToolbar.js +52 -0
- package/dist/esm/Components/MiniToolbar.js.map +7 -0
- package/dist/esm/Components/ToolbarShortcut.js +43 -0
- package/dist/esm/Components/ToolbarShortcut.js.map +7 -0
- package/dist/esm/Components/outOfTheBox/Button.js +12 -0
- package/dist/esm/Components/outOfTheBox/Button.js.map +7 -0
- package/dist/esm/Components/outOfTheBox/ComboBox.js +10 -0
- package/dist/esm/Components/outOfTheBox/ComboBox.js.map +7 -0
- package/dist/esm/Components/outOfTheBox/IconItem.js +21 -0
- package/dist/esm/Components/outOfTheBox/IconItem.js.map +7 -0
- package/dist/esm/Components/outOfTheBox/SearchBox.js +29 -0
- package/dist/esm/Components/outOfTheBox/SearchBox.js.map +7 -0
- package/dist/esm/Components/outOfTheBox/Separator.js +10 -0
- package/dist/esm/Components/outOfTheBox/Separator.js.map +7 -0
- package/dist/esm/Components/outOfTheBox/index.js +24 -0
- package/dist/esm/Components/outOfTheBox/index.js.map +7 -0
- package/dist/esm/hooks/useGenerateItems.js +102 -0
- package/dist/esm/hooks/useGenerateItems.js.map +7 -0
- package/dist/esm/index.d.js +2 -0
- package/dist/esm/index.d.js.map +7 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/propTypes.js +40 -0
- package/dist/esm/propTypes.js.map +7 -0
- package/dist/esm/styles.js +33 -0
- package/dist/esm/styles.js.map +7 -0
- package/{types → dist/types}/Components/MiniToolbar.d.ts +0 -0
- package/{types → dist/types}/Components/ToolbarShortcut.d.ts +0 -0
- package/{types → dist/types}/Components/outOfTheBox/Button.d.ts +0 -0
- package/{types → dist/types}/Components/outOfTheBox/ComboBox.d.ts +0 -0
- package/{types → dist/types}/Components/outOfTheBox/IconItem.d.ts +0 -0
- package/{types → dist/types}/Components/outOfTheBox/SearchBox.d.ts +0 -0
- package/{types → dist/types}/Components/outOfTheBox/Separator.d.ts +0 -0
- package/{types → dist/types}/Components/outOfTheBox/index.d.ts +0 -0
- package/{types → dist/types}/hooks/useGenerateItems.d.ts +0 -0
- package/{types → dist/types}/index.d.d.ts +0 -0
- package/{types → dist/types}/index.d.ts +0 -0
- package/{types → dist/types}/propTypes.d.ts +0 -0
- package/{types → dist/types}/styles.d.ts +0 -0
- package/{types → dist/types}/tests/DSMiniToolbar.events.test.d.ts +0 -0
- package/{types → dist/types}/tests/DSMiniToolbar.keyboard.test.d.ts +0 -0
- package/{types → dist/types}/tests/DSMiniToolbar.test.d.ts +0 -0
- package/{types → dist/types}/tests/utils.test.d.ts +0 -0
- package/package.json +50 -42
- package/cjs/Components/MiniToolbar.js +0 -70
- package/cjs/Components/ToolbarShortcut.js +0 -72
- package/cjs/Components/outOfTheBox/Button.js +0 -29
- package/cjs/Components/outOfTheBox/ComboBox.js +0 -25
- package/cjs/Components/outOfTheBox/IconItem.js +0 -36
- package/cjs/Components/outOfTheBox/SearchBox.js +0 -55
- package/cjs/Components/outOfTheBox/Separator.js +0 -19
- package/cjs/Components/outOfTheBox/index.js +0 -26
- package/cjs/hooks/useGenerateItems.js +0 -134
- package/cjs/index.d.js +0 -2
- package/cjs/index.js +0 -12
- package/cjs/propTypes.js +0 -35
- package/cjs/styles.js +0 -29
- package/esm/Components/MiniToolbar.js +0 -60
- package/esm/Components/ToolbarShortcut.js +0 -63
- package/esm/Components/outOfTheBox/Button.js +0 -20
- package/esm/Components/outOfTheBox/ComboBox.js +0 -17
- package/esm/Components/outOfTheBox/IconItem.js +0 -28
- package/esm/Components/outOfTheBox/SearchBox.js +0 -45
- package/esm/Components/outOfTheBox/Separator.js +0 -11
- package/esm/Components/outOfTheBox/index.js +0 -13
- package/esm/hooks/useGenerateItems.js +0 -125
- package/esm/index.d.js +0 -1
- package/esm/index.js +0 -2
- package/esm/propTypes.js +0 -30
- package/esm/styles.js +0 -17
|
@@ -1,125 +0,0 @@
|
|
|
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
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/esm/index.js
DELETED
package/esm/propTypes.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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 };
|