@elliemae/ds-app-picker 2.3.0-alpha.8 → 2.3.0-next.10
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/AppPickerImpl.js +182 -0
- package/cjs/DSAppPicker.js +138 -0
- package/cjs/index.js +11 -0
- package/cjs/propTypes.js +25 -0
- package/cjs/styles.js +164 -0
- package/cjs/types/AppPickerTypes.js +2 -0
- package/cjs/utils.js +18 -0
- package/esm/AppPickerImpl.js +174 -0
- package/esm/DSAppPicker.js +126 -0
- package/esm/index.js +1 -0
- package/esm/propTypes.js +21 -0
- package/esm/styles.js +150 -0
- package/esm/types/AppPickerTypes.js +1 -0
- package/esm/utils.js +14 -0
- package/package.json +34 -38
- package/types/AppPickerImpl.d.ts +3 -0
- package/types/DSAppPicker.d.ts +11 -0
- package/types/index.d.ts +2 -0
- package/types/propTypes.d.ts +61 -0
- package/types/styles.d.ts +7 -0
- package/types/tests/AppPicker.test.d.ts +1 -0
- package/types/types/AppPickerTypes.d.ts +41 -0
- package/types/utils.d.ts +12 -0
- package/dist/cjs/AppPickerImpl.js +0 -152
- package/dist/cjs/AppPickerImpl.js.map +0 -7
- package/dist/cjs/DSAppPicker.js +0 -141
- package/dist/cjs/DSAppPicker.js.map +0 -7
- package/dist/cjs/index.js +0 -36
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/propTypes.js +0 -50
- package/dist/cjs/propTypes.js.map +0 -7
- package/dist/cjs/styles.js +0 -190
- package/dist/cjs/styles.js.map +0 -7
- package/dist/cjs/types/AppPickerTypes.js +0 -27
- package/dist/cjs/types/AppPickerTypes.js.map +0 -7
- package/dist/cjs/utils.js +0 -46
- package/dist/cjs/utils.js.map +0 -7
- package/dist/esm/AppPickerImpl.js +0 -131
- package/dist/esm/AppPickerImpl.js.map +0 -7
- package/dist/esm/DSAppPicker.js +0 -112
- package/dist/esm/DSAppPicker.js.map +0 -7
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/propTypes.js +0 -21
- package/dist/esm/propTypes.js.map +0 -7
- package/dist/esm/styles.js +0 -161
- package/dist/esm/styles.js.map +0 -7
- package/dist/esm/types/AppPickerTypes.js +0 -2
- package/dist/esm/types/AppPickerTypes.js.map +0 -7
- package/dist/esm/utils.js +0 -17
- package/dist/esm/utils.js.map +0 -7
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
5
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
11
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
12
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
13
|
+
var react = require('react');
|
|
14
|
+
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
15
|
+
var lodash = require('lodash');
|
|
16
|
+
var utils = require('./utils.js');
|
|
17
|
+
var dsTruncatedTooltipText = require('@elliemae/ds-truncated-tooltip-text');
|
|
18
|
+
var styles = require('./styles.js');
|
|
19
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
20
|
+
|
|
21
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
|
+
|
|
23
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
24
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
25
|
+
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
26
|
+
|
|
27
|
+
var _StyledSeparator;
|
|
28
|
+
|
|
29
|
+
const _excluded = ["label", "disabled", "selected", "icon", "id"];
|
|
30
|
+
|
|
31
|
+
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; }
|
|
32
|
+
|
|
33
|
+
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__default["default"](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; }
|
|
34
|
+
|
|
35
|
+
const AppPickerImpl = _ref => {
|
|
36
|
+
let {
|
|
37
|
+
apps = [],
|
|
38
|
+
customApps = [],
|
|
39
|
+
sectionTitle = 'APPLICATIONS',
|
|
40
|
+
customSectionTitle = 'CUSTOM APPLICATIONS',
|
|
41
|
+
close = () => null,
|
|
42
|
+
wrapperRef,
|
|
43
|
+
onKeyDown,
|
|
44
|
+
triggerRef,
|
|
45
|
+
isOverflow
|
|
46
|
+
} = _ref;
|
|
47
|
+
const allFocusableButtons = react.useRef([]);
|
|
48
|
+
const selectedButton = react.useRef(null);
|
|
49
|
+
react.useEffect(() => {
|
|
50
|
+
var _wrapperRef$current;
|
|
51
|
+
|
|
52
|
+
wrapperRef === null || wrapperRef === void 0 ? void 0 : (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.querySelectorAll('button').forEach((e, index) => {
|
|
53
|
+
if (!e.hasAttribute('disabled')) {
|
|
54
|
+
var _allFocusableButtons$;
|
|
55
|
+
|
|
56
|
+
allFocusableButtons === null || allFocusableButtons === void 0 ? void 0 : (_allFocusableButtons$ = allFocusableButtons.current) === null || _allFocusableButtons$ === void 0 ? void 0 : _allFocusableButtons$.push(e);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (e.getAttribute('aria-selected') === 'true') {
|
|
60
|
+
selectedButton.current = index;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (selectedButton.current) {
|
|
65
|
+
var _wrapperRef$current2;
|
|
66
|
+
|
|
67
|
+
wrapperRef === null || wrapperRef === void 0 ? void 0 : (_wrapperRef$current2 = wrapperRef.current) === null || _wrapperRef$current2 === void 0 ? void 0 : _wrapperRef$current2.querySelectorAll('button')[selectedButton.current].focus();
|
|
68
|
+
} else {
|
|
69
|
+
var _allFocusableButtons$2;
|
|
70
|
+
|
|
71
|
+
allFocusableButtons === null || allFocusableButtons === void 0 ? void 0 : (_allFocusableButtons$2 = allFocusableButtons.current[0]) === null || _allFocusableButtons$2 === void 0 ? void 0 : _allFocusableButtons$2.focus();
|
|
72
|
+
}
|
|
73
|
+
}, [wrapperRef]); // eslint-disable-next-line max-statements
|
|
74
|
+
|
|
75
|
+
const handleKeyDown = e => {
|
|
76
|
+
var _triggerRef$current;
|
|
77
|
+
|
|
78
|
+
switch (e.key) {
|
|
79
|
+
case utils.keys.ESC:
|
|
80
|
+
triggerRef === null || triggerRef === void 0 ? void 0 : (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.focus();
|
|
81
|
+
close();
|
|
82
|
+
break;
|
|
83
|
+
|
|
84
|
+
case utils.keys.TAB:
|
|
85
|
+
if (e.shiftKey) {
|
|
86
|
+
if (e.target === allFocusableButtons.current[0]) {
|
|
87
|
+
var _allFocusableButtons$3;
|
|
88
|
+
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
allFocusableButtons === null || allFocusableButtons === void 0 ? void 0 : (_allFocusableButtons$3 = allFocusableButtons.current[allFocusableButtons.current.length - 1]) === null || _allFocusableButtons$3 === void 0 ? void 0 : _allFocusableButtons$3.focus();
|
|
91
|
+
}
|
|
92
|
+
} else if (e.target === allFocusableButtons.current[allFocusableButtons.current.length - 1]) {
|
|
93
|
+
var _allFocusableButtons$4;
|
|
94
|
+
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
allFocusableButtons === null || allFocusableButtons === void 0 ? void 0 : (_allFocusableButtons$4 = allFocusableButtons.current[0]) === null || _allFocusableButtons$4 === void 0 ? void 0 : _allFocusableButtons$4.focus();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const handleOnClick = react.useCallback((e, app) => {
|
|
104
|
+
if (app.onClick) app.onClick(e, app);
|
|
105
|
+
}, []);
|
|
106
|
+
const handleOnKeyDownWrapper = react.useCallback(e => {
|
|
107
|
+
if (onKeyDown) onKeyDown(e);
|
|
108
|
+
|
|
109
|
+
if (!onKeyDown && e.key === utils.keys.ESC) {
|
|
110
|
+
close();
|
|
111
|
+
}
|
|
112
|
+
}, [onKeyDown, close]);
|
|
113
|
+
|
|
114
|
+
const buildRows = function (appList) {
|
|
115
|
+
let prevIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
116
|
+
const rows = lodash.chunk(appList, 3); // divides array in subarrays of 3 items
|
|
117
|
+
|
|
118
|
+
const formattedRows = rows.map((row, index) => /*#__PURE__*/_jsx__default["default"](styles.StyledRow, {}, index, row.map((app, key) => {
|
|
119
|
+
const {
|
|
120
|
+
label,
|
|
121
|
+
disabled,
|
|
122
|
+
selected,
|
|
123
|
+
icon: Icon,
|
|
124
|
+
id
|
|
125
|
+
} = app,
|
|
126
|
+
otherProps = _objectWithoutProperties__default["default"](app, _excluded);
|
|
127
|
+
|
|
128
|
+
return /*#__PURE__*/jsxRuntime.jsxs(styles.StyledChip, _objectSpread(_objectSpread({
|
|
129
|
+
onClick: e => handleOnClick(e, app),
|
|
130
|
+
onKeyDown: handleKeyDown,
|
|
131
|
+
"data-testid": "app-picker__chip",
|
|
132
|
+
"aria-disabled": disabled,
|
|
133
|
+
disabled: disabled,
|
|
134
|
+
selected: selected,
|
|
135
|
+
"aria-selected": selected,
|
|
136
|
+
"aria-setsize": apps.length + customApps.length,
|
|
137
|
+
"aria-posinset": key + prevIndex,
|
|
138
|
+
id: id
|
|
139
|
+
}, dsPropsHelpers.getDataProps(otherProps)), {}, {
|
|
140
|
+
children: [/*#__PURE__*/_jsx__default["default"](Icon, {
|
|
141
|
+
className: "app-picker__icon",
|
|
142
|
+
size: "m"
|
|
143
|
+
}), /*#__PURE__*/_jsx__default["default"](styles.StyledChipLabel, {}, void 0, /*#__PURE__*/_jsx__default["default"](dsTruncatedTooltipText.SimpleTruncatedTooltipText, {
|
|
144
|
+
value: label,
|
|
145
|
+
placement: "bottom"
|
|
146
|
+
}))]
|
|
147
|
+
}), key);
|
|
148
|
+
})));
|
|
149
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
150
|
+
children: formattedRows
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const AppsRows = () => buildRows(apps, 1);
|
|
155
|
+
|
|
156
|
+
const CustomRows = () => buildRows(customApps, apps.length);
|
|
157
|
+
|
|
158
|
+
return /*#__PURE__*/jsxRuntime.jsxs(styles.StyledWrapper, {
|
|
159
|
+
role: "listbox",
|
|
160
|
+
ref: wrapperRef,
|
|
161
|
+
onKeyDown: handleOnKeyDownWrapper,
|
|
162
|
+
"data-testid": "app-picker__wrapper",
|
|
163
|
+
isOverflow: isOverflow,
|
|
164
|
+
children: [/*#__PURE__*/_jsx__default["default"](styles.StyledTitle, {
|
|
165
|
+
"data-testid": "app-picker__main-title",
|
|
166
|
+
"aria-hidden": true
|
|
167
|
+
}, void 0, sectionTitle), /*#__PURE__*/_jsx__default["default"](styles.StyledGrid, {
|
|
168
|
+
"data-testid": "app-picker__main-grid"
|
|
169
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](AppsRows, {})), !!customApps.length && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
170
|
+
children: [_StyledSeparator || (_StyledSeparator = /*#__PURE__*/_jsx__default["default"](styles.StyledSeparator, {
|
|
171
|
+
"aria-hidden": true
|
|
172
|
+
})), /*#__PURE__*/_jsx__default["default"](styles.StyledTitle, {
|
|
173
|
+
"data-testid": "app-picker__custom-title",
|
|
174
|
+
"aria-hidden": true
|
|
175
|
+
}, void 0, customSectionTitle), /*#__PURE__*/_jsx__default["default"](styles.StyledGrid, {
|
|
176
|
+
"data-testid": "app-picker__custom-grid"
|
|
177
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](CustomRows, {}))]
|
|
178
|
+
})]
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
module.exports = AppPickerImpl;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
+
var react = require('react');
|
|
8
|
+
var reactDesc = require('react-desc');
|
|
9
|
+
var dsIcons = require('@elliemae/ds-icons');
|
|
10
|
+
var DSButton = require('@elliemae/ds-button');
|
|
11
|
+
var DSPopover = require('@elliemae/ds-popover');
|
|
12
|
+
var dsUtilities = require('@elliemae/ds-utilities');
|
|
13
|
+
var AppPickerImpl = require('./AppPickerImpl.js');
|
|
14
|
+
var propTypes = require('./propTypes.js');
|
|
15
|
+
|
|
16
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
|
+
|
|
18
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
19
|
+
var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
|
|
20
|
+
var DSPopover__default = /*#__PURE__*/_interopDefaultLegacy(DSPopover);
|
|
21
|
+
|
|
22
|
+
const DSAppPicker = _ref => {
|
|
23
|
+
var _Icon;
|
|
24
|
+
|
|
25
|
+
let {
|
|
26
|
+
apps = [],
|
|
27
|
+
customApps = [],
|
|
28
|
+
sectionTitle = 'APPLICATIONS',
|
|
29
|
+
customSectionTitle = 'CUSTOM APPLICATIONS',
|
|
30
|
+
icon: Icon = () => /*#__PURE__*/_jsx__default["default"](dsIcons.MenuPicker, {
|
|
31
|
+
fill: ['brand-primary', 700],
|
|
32
|
+
size: "m"
|
|
33
|
+
}),
|
|
34
|
+
renderTrigger,
|
|
35
|
+
isOpen,
|
|
36
|
+
onClose = () => null,
|
|
37
|
+
actionRef,
|
|
38
|
+
onKeyDown,
|
|
39
|
+
onClick = () => null,
|
|
40
|
+
onClickOutside = () => null,
|
|
41
|
+
triggerRef
|
|
42
|
+
} = _ref;
|
|
43
|
+
const [open, setOpen] = react.useState(false);
|
|
44
|
+
const [isOverflow, setIsOverflow] = react.useState(false);
|
|
45
|
+
const wrapperRef = react.useRef(null);
|
|
46
|
+
const defaultTriggerRef = react.useRef(null);
|
|
47
|
+
react.useEffect(() => {
|
|
48
|
+
if (actionRef && actionRef.current) {
|
|
49
|
+
actionRef.current.focusToIndex = index => {
|
|
50
|
+
if (wrapperRef.current) {
|
|
51
|
+
const parent = wrapperRef.current;
|
|
52
|
+
const buttons = [...parent.querySelectorAll('button')];
|
|
53
|
+
buttons[index].focus();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}, [actionRef, apps, customApps]);
|
|
58
|
+
react.useEffect(() => {
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
if (wrapperRef.current) {
|
|
61
|
+
const {
|
|
62
|
+
scrollHeight,
|
|
63
|
+
clientHeight
|
|
64
|
+
} = wrapperRef.current;
|
|
65
|
+
if (scrollHeight > clientHeight) return setIsOverflow(true);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return setIsOverflow(false);
|
|
69
|
+
});
|
|
70
|
+
}, [isOpen, open]);
|
|
71
|
+
|
|
72
|
+
const handleOnClose = () => {
|
|
73
|
+
if (typeof isOpen === 'boolean') {
|
|
74
|
+
setOpen(isOpen);
|
|
75
|
+
} else {
|
|
76
|
+
setOpen(false);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
onClose();
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const handleOnClickOutside = e => {
|
|
83
|
+
setOpen(false);
|
|
84
|
+
onClose();
|
|
85
|
+
onClickOutside(e);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const AppPickerContent = () => /*#__PURE__*/_jsx__default["default"](AppPickerImpl, {
|
|
89
|
+
apps: apps,
|
|
90
|
+
customApps: customApps,
|
|
91
|
+
sectionTitle: sectionTitle,
|
|
92
|
+
customSectionTitle: customSectionTitle,
|
|
93
|
+
close: handleOnClose,
|
|
94
|
+
wrapperRef: wrapperRef,
|
|
95
|
+
onKeyDown: onKeyDown,
|
|
96
|
+
triggerRef: triggerRef || defaultTriggerRef,
|
|
97
|
+
isOverflow: isOverflow
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const RenderTrigger = renderTrigger || (_ref2 => {
|
|
101
|
+
let {
|
|
102
|
+
ref
|
|
103
|
+
} = _ref2;
|
|
104
|
+
return /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
|
|
105
|
+
"data-testid": "app-picker__button",
|
|
106
|
+
id: "app-picker__button",
|
|
107
|
+
buttonType: "text",
|
|
108
|
+
icon: _Icon || (_Icon = /*#__PURE__*/_jsx__default["default"](Icon, {})),
|
|
109
|
+
innerRef: dsUtilities.mergeRefs(ref, defaultTriggerRef),
|
|
110
|
+
onClick: e => {
|
|
111
|
+
onClick(e);
|
|
112
|
+
setOpen(true);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return /*#__PURE__*/_jsx__default["default"](DSPopover__default["default"], {
|
|
118
|
+
content: /*#__PURE__*/_jsx__default["default"](AppPickerContent, {}),
|
|
119
|
+
isOpen: typeof isOpen === 'boolean' ? isOpen : open,
|
|
120
|
+
onClickOutside: handleOnClickOutside,
|
|
121
|
+
placement: "bottom",
|
|
122
|
+
interactionType: "click",
|
|
123
|
+
renderTrigger: RenderTrigger,
|
|
124
|
+
showArrow: true,
|
|
125
|
+
style: {
|
|
126
|
+
padding: '0',
|
|
127
|
+
maxWidth: '1000px',
|
|
128
|
+
width: 'fit-content'
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const AppPickerWithSchema = reactDesc.describe(DSAppPicker);
|
|
134
|
+
AppPickerWithSchema.propTypes = propTypes.propTypes;
|
|
135
|
+
|
|
136
|
+
exports.AppPickerWithSchema = AppPickerWithSchema;
|
|
137
|
+
exports.DSAppPicker = DSAppPicker;
|
|
138
|
+
exports["default"] = DSAppPicker;
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var DSAppPicker = require('./DSAppPicker.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.AppPickerWithSchema = DSAppPicker.AppPickerWithSchema;
|
|
10
|
+
exports.DSAppPicker = DSAppPicker.DSAppPicker;
|
|
11
|
+
exports["default"] = DSAppPicker.DSAppPicker;
|
package/cjs/propTypes.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var reactDesc = require('react-desc');
|
|
6
|
+
var dsIcons = require('@elliemae/ds-icons');
|
|
7
|
+
|
|
8
|
+
const propTypes = {
|
|
9
|
+
apps: reactDesc.PropTypes.array.description('Main items. Format: [{ label:string, icon:component, onClick:func, disabled:bool, selected:bool }]').isRequired,
|
|
10
|
+
customApps: reactDesc.PropTypes.array.description('Custom items. Format: [{ label:string, icon:component, onClick:func, disabled:bool, selected:bool }]'),
|
|
11
|
+
sectionTitle: reactDesc.PropTypes.string.description('main section title').defaultValue('APPLICATIONS'),
|
|
12
|
+
customSectionTitle: reactDesc.PropTypes.string.description('custom section title').defaultValue('CUSTOM APPLICATIONS'),
|
|
13
|
+
icon: reactDesc.PropTypes.func.description('trigger button s icon').defaultValue(dsIcons.MenuPicker),
|
|
14
|
+
renderTrigger: reactDesc.PropTypes.func.description('Custom trigger component.'),
|
|
15
|
+
actionRef: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.func, reactDesc.PropTypes.shape({
|
|
16
|
+
current: reactDesc.PropTypes.any
|
|
17
|
+
})]).description('Ref containing a focusToIndex method. This method allows you to focus any App inside the AppPicker.'),
|
|
18
|
+
isOpen: reactDesc.PropTypes.bool.description('Wether the AppPicker should be open or not.'),
|
|
19
|
+
onClose: reactDesc.PropTypes.func.description('Callback function when the AppPicker closes'),
|
|
20
|
+
onKeyDown: reactDesc.PropTypes.func.description('OnKeyDown handler callback.'),
|
|
21
|
+
onClick: reactDesc.PropTypes.func.description('Custom onClick for Trigger component.'),
|
|
22
|
+
onClickOutside: reactDesc.PropTypes.func.description('Callback event when the user clicks outside the App Picker.')
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.propTypes = propTypes;
|
package/cjs/styles.js
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
|
|
6
|
+
var dsSystem = require('@elliemae/ds-system');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
|
|
11
|
+
|
|
12
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
13
|
+
const StyledTitle = dsSystem.styled('h3', {
|
|
14
|
+
name: 'DS-AppPicker',
|
|
15
|
+
slot: 'title'
|
|
16
|
+
})(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n color: ", ";\n font-size: ", ";\n font-weight: ", ";\n margin: 12px 0 0 0;\n line-height: 1.38;\n text-transform: uppercase;\n"])), _ref => {
|
|
17
|
+
let {
|
|
18
|
+
theme
|
|
19
|
+
} = _ref;
|
|
20
|
+
return theme.colors.neutral[700];
|
|
21
|
+
}, _ref2 => {
|
|
22
|
+
let {
|
|
23
|
+
theme
|
|
24
|
+
} = _ref2;
|
|
25
|
+
return theme.fontSizes.value[400];
|
|
26
|
+
}, _ref3 => {
|
|
27
|
+
let {
|
|
28
|
+
theme
|
|
29
|
+
} = _ref3;
|
|
30
|
+
return theme.fontWeights.semibold;
|
|
31
|
+
});
|
|
32
|
+
const StyledWrapper = dsSystem.styled('ul', {
|
|
33
|
+
name: 'DS-AppPicker',
|
|
34
|
+
slot: 'root'
|
|
35
|
+
})(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral__default["default"](["\n align-items: center;\n min-width: 308px;\n min-height: 110px;\n max-height: 449px;\n width: 308px;\n overflow-y: auto;\n overflow-x: hidden;\n margin: 0;\n padding: ", ";\n &:focus {\n outline: none;\n }\n"])), _ref4 => {
|
|
36
|
+
let {
|
|
37
|
+
isOverflow
|
|
38
|
+
} = _ref4;
|
|
39
|
+
return isOverflow ? '0 0 0 16px' : '0 16px';
|
|
40
|
+
});
|
|
41
|
+
const StyledGrid = dsSystem.styled('div', {
|
|
42
|
+
name: 'DS-AppPicker',
|
|
43
|
+
slot: 'grid'
|
|
44
|
+
})(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral__default["default"](["\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n width: 100%;\n margin: 8px 0;\n"])));
|
|
45
|
+
const StyledRow = dsSystem.styled('div', {
|
|
46
|
+
name: 'DS-AppPicker',
|
|
47
|
+
slot: 'row'
|
|
48
|
+
})(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral__default["default"](["\n display: flex;\n width: 100%;\n"])));
|
|
49
|
+
const StyledChipLabel = dsSystem.styled('p', {
|
|
50
|
+
name: 'DS-AppPicker',
|
|
51
|
+
slot: 'chipLabel'
|
|
52
|
+
})(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral__default["default"](["\n font-size: ", ";\n font-weight: ", ";\n word-wrap: break-word;\n margin: 0 6px;\n line-height: 1.45;\n width: 100%;\n z-index: 120;\n\n & span {\n padding-top: 6px;\n }\n"])), _ref5 => {
|
|
53
|
+
let {
|
|
54
|
+
theme
|
|
55
|
+
} = _ref5;
|
|
56
|
+
return theme.fontSizes.label[200];
|
|
57
|
+
}, _ref6 => {
|
|
58
|
+
let {
|
|
59
|
+
theme
|
|
60
|
+
} = _ref6;
|
|
61
|
+
return theme.fontWeights.semibold;
|
|
62
|
+
});
|
|
63
|
+
const styledChipSelectedCss = dsSystem.css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral__default["default"](["\n color: ", ";\n background-color: ", ";\n\n .app-picker__icon {\n fill: ", ";\n }\n\n &:before {\n border: 1px solid ", ";\n }\n\n &:focus {\n &:before {\n border: 2px solid ", ";\n }\n }\n"])), _ref7 => {
|
|
64
|
+
let {
|
|
65
|
+
theme
|
|
66
|
+
} = _ref7;
|
|
67
|
+
return theme.colors.brand[800];
|
|
68
|
+
}, _ref8 => {
|
|
69
|
+
let {
|
|
70
|
+
theme
|
|
71
|
+
} = _ref8;
|
|
72
|
+
return theme.colors.brand[200];
|
|
73
|
+
}, _ref9 => {
|
|
74
|
+
let {
|
|
75
|
+
theme
|
|
76
|
+
} = _ref9;
|
|
77
|
+
return theme.colors.brand[800];
|
|
78
|
+
}, _ref10 => {
|
|
79
|
+
let {
|
|
80
|
+
theme
|
|
81
|
+
} = _ref10;
|
|
82
|
+
return theme.colors.brand[600];
|
|
83
|
+
}, _ref11 => {
|
|
84
|
+
let {
|
|
85
|
+
theme
|
|
86
|
+
} = _ref11;
|
|
87
|
+
return theme.colors.brand[800];
|
|
88
|
+
});
|
|
89
|
+
const StyledChip = dsSystem.styled('button', {
|
|
90
|
+
name: 'DS-AppPicker',
|
|
91
|
+
slot: 'chip'
|
|
92
|
+
})(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral__default["default"](["\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n border: none;\n height: 68px;\n width: 92px;\n background-color: #fff;\n color: ", ";\n cursor: pointer;\n outline: none;\n\n &:before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n border-radius: 2px;\n border: 2px solid transparent;\n }\n\n & .app-picker__icon {\n fill: ", ";\n height: 28px;\n width: 28px;\n }\n\n & .app-picker__icon svg {\n height: 28px;\n width: 28px;\n }\n\n &:hover {\n color: ", ";\n background-color: ", ";\n .app-picker__icon {\n fill: ", ";\n }\n }\n\n &:focus {\n &:before {\n border-color: ", ";\n }\n }\n\n &:disabled {\n color: ", ";\n cursor: not-allowed;\n\n .app-picker__icon {\n fill: ", ";\n }\n\n &:focus,\n &:hover {\n background-color: #fff;\n cursor: not-allowed;\n &:before {\n border-color: transparent;\n }\n\n ", " {\n color: ", ";\n }\n }\n\n &:hover .app-picker__icon {\n fill: ", ";\n }\n }\n\n ", "\n"])), _ref12 => {
|
|
93
|
+
let {
|
|
94
|
+
theme
|
|
95
|
+
} = _ref12;
|
|
96
|
+
return theme.colors.brand[600];
|
|
97
|
+
}, _ref13 => {
|
|
98
|
+
let {
|
|
99
|
+
theme
|
|
100
|
+
} = _ref13;
|
|
101
|
+
return theme.colors.brand[600];
|
|
102
|
+
}, _ref14 => {
|
|
103
|
+
let {
|
|
104
|
+
theme
|
|
105
|
+
} = _ref14;
|
|
106
|
+
return theme.colors.brand[800];
|
|
107
|
+
}, _ref15 => {
|
|
108
|
+
let {
|
|
109
|
+
theme
|
|
110
|
+
} = _ref15;
|
|
111
|
+
return theme.colors.brand[200];
|
|
112
|
+
}, _ref16 => {
|
|
113
|
+
let {
|
|
114
|
+
theme
|
|
115
|
+
} = _ref16;
|
|
116
|
+
return theme.colors.brand[800];
|
|
117
|
+
}, _ref17 => {
|
|
118
|
+
let {
|
|
119
|
+
theme
|
|
120
|
+
} = _ref17;
|
|
121
|
+
return theme.colors.brand[800];
|
|
122
|
+
}, _ref18 => {
|
|
123
|
+
let {
|
|
124
|
+
theme
|
|
125
|
+
} = _ref18;
|
|
126
|
+
return theme.colors.neutral[500];
|
|
127
|
+
}, _ref19 => {
|
|
128
|
+
let {
|
|
129
|
+
theme
|
|
130
|
+
} = _ref19;
|
|
131
|
+
return theme.colors.neutral[500];
|
|
132
|
+
}, StyledChipLabel, _ref20 => {
|
|
133
|
+
let {
|
|
134
|
+
theme
|
|
135
|
+
} = _ref20;
|
|
136
|
+
return theme.colors.neutral[500];
|
|
137
|
+
}, _ref21 => {
|
|
138
|
+
let {
|
|
139
|
+
theme
|
|
140
|
+
} = _ref21;
|
|
141
|
+
return theme.colors.neutral[500];
|
|
142
|
+
}, _ref22 => {
|
|
143
|
+
let {
|
|
144
|
+
selected
|
|
145
|
+
} = _ref22;
|
|
146
|
+
return !selected ? '' : styledChipSelectedCss;
|
|
147
|
+
});
|
|
148
|
+
const StyledSeparator = dsSystem.styled('hr', {
|
|
149
|
+
name: 'DS-AppPicker',
|
|
150
|
+
slot: 'separator'
|
|
151
|
+
})(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral__default["default"](["\n border-top: 1px solid ", ";\n border-bottom: none;\n width: 99%;\n margin: 0;\n"])), _ref23 => {
|
|
152
|
+
let {
|
|
153
|
+
theme
|
|
154
|
+
} = _ref23;
|
|
155
|
+
return theme.colors.neutral[100];
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
exports.StyledChip = StyledChip;
|
|
159
|
+
exports.StyledChipLabel = StyledChipLabel;
|
|
160
|
+
exports.StyledGrid = StyledGrid;
|
|
161
|
+
exports.StyledRow = StyledRow;
|
|
162
|
+
exports.StyledSeparator = StyledSeparator;
|
|
163
|
+
exports.StyledTitle = StyledTitle;
|
|
164
|
+
exports.StyledWrapper = StyledWrapper;
|
package/cjs/utils.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const keys = {
|
|
6
|
+
LEFT: 'ArrowLeft',
|
|
7
|
+
UP: 'ArrowUp',
|
|
8
|
+
RIGHT: 'ArrowRight',
|
|
9
|
+
DOWN: 'ArrowDown',
|
|
10
|
+
ENTER: 'Enter',
|
|
11
|
+
SPACE: '',
|
|
12
|
+
TAB: 'Tab',
|
|
13
|
+
ESC: 'Escape',
|
|
14
|
+
HOME: 'Home',
|
|
15
|
+
END: 'End'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.keys = keys;
|