@elliemae/ds-app-picker 2.2.0-alpha.1 → 2.2.0-alpha.5
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 +113 -143
- package/cjs/AppPickerImpl.js.map +7 -0
- package/cjs/DSAppPicker.js +104 -101
- package/cjs/DSAppPicker.js.map +7 -0
- package/cjs/index.js +36 -11
- package/cjs/index.js.map +7 -0
- package/cjs/propTypes.js +48 -23
- package/cjs/propTypes.js.map +7 -0
- package/cjs/styles.js +184 -158
- package/cjs/styles.js.map +7 -0
- package/cjs/types/AppPickerTypes.js +27 -2
- package/cjs/types/AppPickerTypes.js.map +7 -0
- package/cjs/utils.js +44 -16
- package/cjs/utils.js.map +7 -0
- package/esm/AppPickerImpl.js +85 -128
- package/esm/AppPickerImpl.js.map +7 -0
- package/esm/DSAppPicker.js +67 -81
- package/esm/DSAppPicker.js.map +7 -0
- package/esm/index.js +7 -1
- package/esm/index.js.map +7 -0
- package/esm/propTypes.js +19 -19
- package/esm/propTypes.js.map +7 -0
- package/esm/styles.js +159 -148
- package/esm/styles.js.map +7 -0
- package/esm/types/AppPickerTypes.js +2 -1
- package/esm/types/AppPickerTypes.js.map +7 -0
- package/esm/utils.js +15 -12
- package/esm/utils.js.map +7 -0
- package/package.json +6 -6
package/cjs/AppPickerImpl.js
CHANGED
|
@@ -1,182 +1,152 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
allFocusableButtons === null || allFocusableButtons === void 0 ? void 0 : (_allFocusableButtons$ = allFocusableButtons.current) === null || _allFocusableButtons$ === void 0 ? void 0 : _allFocusableButtons$.push(e);
|
|
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 AppPickerImpl_exports = {};
|
|
29
|
+
__export(AppPickerImpl_exports, {
|
|
30
|
+
default: () => AppPickerImpl_default
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react = __toESM(require("react"));
|
|
34
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
35
|
+
var import_lodash = require("lodash");
|
|
36
|
+
var import_utils = require("./utils");
|
|
37
|
+
var import_ds_truncated_tooltip_text = require("@elliemae/ds-truncated-tooltip-text");
|
|
38
|
+
var import_styles = require("./styles");
|
|
39
|
+
const AppPickerImpl = ({
|
|
40
|
+
apps = [],
|
|
41
|
+
customApps = [],
|
|
42
|
+
sectionTitle = "APPLICATIONS",
|
|
43
|
+
customSectionTitle = "CUSTOM APPLICATIONS",
|
|
44
|
+
close = () => null,
|
|
45
|
+
wrapperRef,
|
|
46
|
+
onKeyDown,
|
|
47
|
+
triggerRef,
|
|
48
|
+
isOverflow
|
|
49
|
+
}) => {
|
|
50
|
+
const allFocusableButtons = (0, import_react.useRef)([]);
|
|
51
|
+
const selectedButton = (0, import_react.useRef)(null);
|
|
52
|
+
(0, import_react.useEffect)(() => {
|
|
53
|
+
wrapperRef?.current?.querySelectorAll("button").forEach((e, index) => {
|
|
54
|
+
if (!e.hasAttribute("disabled")) {
|
|
55
|
+
allFocusableButtons?.current?.push(e);
|
|
57
56
|
}
|
|
58
|
-
|
|
59
|
-
if (e.getAttribute('aria-selected') === 'true') {
|
|
57
|
+
if (e.getAttribute("aria-selected") === "true") {
|
|
60
58
|
selectedButton.current = index;
|
|
61
59
|
}
|
|
62
60
|
});
|
|
63
|
-
|
|
64
61
|
if (selectedButton.current) {
|
|
65
|
-
|
|
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();
|
|
62
|
+
wrapperRef?.current?.querySelectorAll("button")[selectedButton.current].focus();
|
|
68
63
|
} else {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
allFocusableButtons === null || allFocusableButtons === void 0 ? void 0 : (_allFocusableButtons$2 = allFocusableButtons.current[0]) === null || _allFocusableButtons$2 === void 0 ? void 0 : _allFocusableButtons$2.focus();
|
|
64
|
+
allFocusableButtons?.current[0]?.focus();
|
|
72
65
|
}
|
|
73
|
-
}, [wrapperRef]);
|
|
74
|
-
|
|
75
|
-
const handleKeyDown = e => {
|
|
76
|
-
var _triggerRef$current;
|
|
77
|
-
|
|
66
|
+
}, [wrapperRef]);
|
|
67
|
+
const handleKeyDown = (e) => {
|
|
78
68
|
switch (e.key) {
|
|
79
|
-
case
|
|
80
|
-
triggerRef
|
|
69
|
+
case import_utils.keys.ESC:
|
|
70
|
+
triggerRef?.current?.focus();
|
|
81
71
|
close();
|
|
82
72
|
break;
|
|
83
|
-
|
|
84
|
-
case utils.keys.TAB:
|
|
73
|
+
case import_utils.keys.TAB:
|
|
85
74
|
if (e.shiftKey) {
|
|
86
75
|
if (e.target === allFocusableButtons.current[0]) {
|
|
87
|
-
var _allFocusableButtons$3;
|
|
88
|
-
|
|
89
76
|
e.preventDefault();
|
|
90
|
-
allFocusableButtons
|
|
77
|
+
allFocusableButtons?.current[allFocusableButtons.current.length - 1]?.focus();
|
|
91
78
|
}
|
|
92
79
|
} else if (e.target === allFocusableButtons.current[allFocusableButtons.current.length - 1]) {
|
|
93
|
-
var _allFocusableButtons$4;
|
|
94
|
-
|
|
95
80
|
e.preventDefault();
|
|
96
|
-
allFocusableButtons
|
|
81
|
+
allFocusableButtons?.current[0]?.focus();
|
|
97
82
|
}
|
|
98
|
-
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
99
85
|
break;
|
|
100
86
|
}
|
|
101
87
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
88
|
+
const handleOnClick = (0, import_react.useCallback)((e, app) => {
|
|
89
|
+
if (app.onClick)
|
|
90
|
+
app.onClick(e, app);
|
|
105
91
|
}, []);
|
|
106
|
-
const handleOnKeyDownWrapper =
|
|
107
|
-
if (onKeyDown)
|
|
108
|
-
|
|
109
|
-
if (!onKeyDown && e.key ===
|
|
92
|
+
const handleOnKeyDownWrapper = (0, import_react.useCallback)((e) => {
|
|
93
|
+
if (onKeyDown)
|
|
94
|
+
onKeyDown(e);
|
|
95
|
+
if (!onKeyDown && e.key === import_utils.keys.ESC) {
|
|
110
96
|
close();
|
|
111
97
|
}
|
|
112
98
|
}, [onKeyDown, close]);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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),
|
|
99
|
+
const buildRows = (appList, prevIndex = 0) => {
|
|
100
|
+
const rows = (0, import_lodash.chunk)(appList, 3);
|
|
101
|
+
const formattedRows = rows.map((row, index) => /* @__PURE__ */ import_react.default.createElement(import_styles.StyledRow, {
|
|
102
|
+
key: index
|
|
103
|
+
}, row.map((app, key) => {
|
|
104
|
+
const { label, disabled, selected, icon: Icon, id, ...otherProps } = app;
|
|
105
|
+
return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledChip, {
|
|
106
|
+
key,
|
|
107
|
+
onClick: (e) => handleOnClick(e, app),
|
|
130
108
|
onKeyDown: handleKeyDown,
|
|
131
109
|
"data-testid": "app-picker__chip",
|
|
132
110
|
"aria-disabled": disabled,
|
|
133
|
-
disabled
|
|
134
|
-
selected
|
|
111
|
+
disabled,
|
|
112
|
+
selected,
|
|
135
113
|
"aria-selected": selected,
|
|
136
114
|
"aria-setsize": apps.length + customApps.length,
|
|
137
115
|
"aria-posinset": key + prevIndex,
|
|
138
|
-
id
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}), key);
|
|
116
|
+
id,
|
|
117
|
+
...(0, import_ds_props_helpers.getDataProps)(otherProps)
|
|
118
|
+
}, /* @__PURE__ */ import_react.default.createElement(Icon, {
|
|
119
|
+
className: "app-picker__icon",
|
|
120
|
+
size: "m"
|
|
121
|
+
}), /* @__PURE__ */ import_react.default.createElement(import_styles.StyledChipLabel, null, /* @__PURE__ */ import_react.default.createElement(import_ds_truncated_tooltip_text.SimpleTruncatedTooltipText, {
|
|
122
|
+
value: label,
|
|
123
|
+
placement: "bottom"
|
|
124
|
+
})));
|
|
148
125
|
})));
|
|
149
|
-
return
|
|
150
|
-
children: formattedRows
|
|
151
|
-
});
|
|
126
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, formattedRows);
|
|
152
127
|
};
|
|
153
|
-
|
|
154
128
|
const AppsRows = () => buildRows(apps, 1);
|
|
155
|
-
|
|
156
129
|
const CustomRows = () => buildRows(customApps, apps.length);
|
|
157
|
-
|
|
158
|
-
return /*#__PURE__*/jsxRuntime.jsxs(styles.StyledWrapper, {
|
|
130
|
+
return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledWrapper, {
|
|
159
131
|
role: "listbox",
|
|
160
132
|
ref: wrapperRef,
|
|
161
133
|
onKeyDown: handleOnKeyDownWrapper,
|
|
162
134
|
"data-testid": "app-picker__wrapper",
|
|
163
|
-
isOverflow
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}, void 0, /*#__PURE__*/_jsx__default["default"](CustomRows, {}))]
|
|
178
|
-
})]
|
|
179
|
-
});
|
|
135
|
+
isOverflow
|
|
136
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledTitle, {
|
|
137
|
+
"data-testid": "app-picker__main-title",
|
|
138
|
+
"aria-hidden": true
|
|
139
|
+
}, sectionTitle), /* @__PURE__ */ import_react.default.createElement(import_styles.StyledGrid, {
|
|
140
|
+
"data-testid": "app-picker__main-grid"
|
|
141
|
+
}, /* @__PURE__ */ import_react.default.createElement(AppsRows, null)), !!customApps.length && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledSeparator, {
|
|
142
|
+
"aria-hidden": true
|
|
143
|
+
}), /* @__PURE__ */ import_react.default.createElement(import_styles.StyledTitle, {
|
|
144
|
+
"data-testid": "app-picker__custom-title",
|
|
145
|
+
"aria-hidden": true
|
|
146
|
+
}, customSectionTitle), /* @__PURE__ */ import_react.default.createElement(import_styles.StyledGrid, {
|
|
147
|
+
"data-testid": "app-picker__custom-grid"
|
|
148
|
+
}, /* @__PURE__ */ import_react.default.createElement(CustomRows, null))));
|
|
180
149
|
};
|
|
181
|
-
|
|
182
|
-
module.exports =
|
|
150
|
+
var AppPickerImpl_default = AppPickerImpl;
|
|
151
|
+
module.exports = __toCommonJS(AppPickerImpl_exports);
|
|
152
|
+
//# sourceMappingURL=AppPickerImpl.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/AppPickerImpl.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react/prop-types */\n/* eslint-disable react/no-array-index-key */\n/* eslint-disable max-lines */\nimport React, { useEffect, useCallback, useRef } from 'react';\nimport { getDataProps } from '@elliemae/ds-props-helpers';\nimport { chunk } from 'lodash';\nimport { keys } from './utils';\nimport { AppItemType, DSAppPickerImplType } from './types/AppPickerTypes';\nimport { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\nimport {\n StyledWrapper,\n StyledChip,\n StyledChipLabel,\n StyledTitle,\n StyledGrid,\n StyledRow,\n StyledSeparator,\n} from './styles';\n\nconst AppPickerImpl: DSAppPickerImplType = ({\n apps = [],\n customApps = [],\n sectionTitle = 'APPLICATIONS',\n customSectionTitle = 'CUSTOM APPLICATIONS',\n close = () => null,\n wrapperRef,\n onKeyDown,\n triggerRef,\n isOverflow,\n}) => {\n const allFocusableButtons = useRef<HTMLButtonElement[]>([]);\n const selectedButton = useRef<number | null>(null);\n\n useEffect(() => {\n wrapperRef?.current?.querySelectorAll('button').forEach((e, index) => {\n if (!e.hasAttribute('disabled')) {\n allFocusableButtons?.current?.push(e);\n }\n if (e.getAttribute('aria-selected') === 'true') {\n selectedButton.current = index;\n }\n });\n\n if (selectedButton.current) {\n wrapperRef?.current?.querySelectorAll('button')[selectedButton.current].focus();\n } else {\n allFocusableButtons?.current[0]?.focus();\n }\n }, [wrapperRef]);\n\n // eslint-disable-next-line max-statements\n const handleKeyDown = (e: React.KeyboardEvent) => {\n switch (e.key) {\n case keys.ESC:\n triggerRef?.current?.focus();\n close();\n break;\n case keys.TAB:\n if (e.shiftKey) {\n if (e.target === allFocusableButtons.current[0]) {\n e.preventDefault();\n allFocusableButtons?.current[allFocusableButtons.current.length - 1]?.focus();\n }\n } else if (e.target === allFocusableButtons.current[allFocusableButtons.current.length - 1]) {\n e.preventDefault();\n allFocusableButtons?.current[0]?.focus();\n }\n break;\n default:\n break;\n }\n };\n\n const handleOnClick = useCallback((e, app) => {\n if (app.onClick) app.onClick(e, app);\n }, []);\n\n const handleOnKeyDownWrapper = useCallback(\n (e) => {\n if (onKeyDown) onKeyDown(e);\n if (!onKeyDown && e.key === keys.ESC) {\n close();\n }\n },\n [onKeyDown, close],\n );\n\n const buildRows = (appList: AppItemType[], prevIndex = 0): JSX.Element => {\n const rows = chunk(appList, 3); // divides array in subarrays of 3 items\n const formattedRows = rows.map((row, index) => (\n <StyledRow key={index}>\n {row.map((app, key) => {\n const { label, disabled, selected, icon: Icon, id, ...otherProps } = app;\n return (\n <StyledChip\n key={key}\n onClick={(e) => handleOnClick(e, app)}\n onKeyDown={handleKeyDown}\n data-testid=\"app-picker__chip\"\n aria-disabled={disabled}\n disabled={disabled}\n selected={selected}\n aria-selected={selected}\n aria-setsize={apps.length + customApps.length}\n aria-posinset={key + prevIndex}\n id={id}\n {...getDataProps(otherProps)}\n >\n <Icon className=\"app-picker__icon\" size=\"m\" />\n <StyledChipLabel>\n <SimpleTruncatedTooltipText value={label} placement=\"bottom\" />\n </StyledChipLabel>\n </StyledChip>\n );\n })}\n </StyledRow>\n ));\n return <>{formattedRows}</>;\n };\n\n const AppsRows = () => buildRows(apps, 1);\n const CustomRows = () => buildRows(customApps, apps.length);\n\n return (\n <StyledWrapper\n role=\"listbox\"\n ref={wrapperRef}\n onKeyDown={handleOnKeyDownWrapper}\n data-testid=\"app-picker__wrapper\"\n isOverflow={isOverflow}\n >\n <StyledTitle data-testid=\"app-picker__main-title\" aria-hidden>\n {sectionTitle}\n </StyledTitle>\n <StyledGrid data-testid=\"app-picker__main-grid\">\n <AppsRows />\n </StyledGrid>\n {!!customApps.length && (\n <>\n <StyledSeparator aria-hidden />\n <StyledTitle data-testid=\"app-picker__custom-title\" aria-hidden>\n {customSectionTitle}\n </StyledTitle>\n <StyledGrid data-testid=\"app-picker__custom-grid\">\n <CustomRows />\n </StyledGrid>\n </>\n )}\n </StyledWrapper>\n );\n};\n\nexport default AppPickerImpl;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,mBAAsD;AACtD,8BAA6B;AAC7B,oBAAsB;AACtB,mBAAqB;AAErB,uCAA2C;AAC3C,oBAQO;AAEP,MAAM,gBAAqC,CAAC;AAAA,EAC1C,OAAO;AAAA,EACP,aAAa;AAAA,EACb,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,QAAQ,MAAM;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACI;AACJ,QAAM,sBAAsB,yBAA4B;AACxD,QAAM,iBAAiB,yBAAsB;AAE7C,8BAAU,MAAM;AACd,gBAAY,SAAS,iBAAiB,UAAU,QAAQ,CAAC,GAAG,UAAU;AACpE,UAAI,CAAC,EAAE,aAAa,aAAa;AAC/B,6BAAqB,SAAS,KAAK;AAAA;AAErC,UAAI,EAAE,aAAa,qBAAqB,QAAQ;AAC9C,uBAAe,UAAU;AAAA;AAAA;AAI7B,QAAI,eAAe,SAAS;AAC1B,kBAAY,SAAS,iBAAiB,UAAU,eAAe,SAAS;AAAA,WACnE;AACL,2BAAqB,QAAQ,IAAI;AAAA;AAAA,KAElC,CAAC;AAGJ,QAAM,gBAAgB,CAAC,MAA2B;AAChD,YAAQ,EAAE;AAAA,WACH,kBAAK;AACR,oBAAY,SAAS;AACrB;AACA;AAAA,WACG,kBAAK;AACR,YAAI,EAAE,UAAU;AACd,cAAI,EAAE,WAAW,oBAAoB,QAAQ,IAAI;AAC/C,cAAE;AACF,iCAAqB,QAAQ,oBAAoB,QAAQ,SAAS,IAAI;AAAA;AAAA,mBAE/D,EAAE,WAAW,oBAAoB,QAAQ,oBAAoB,QAAQ,SAAS,IAAI;AAC3F,YAAE;AACF,+BAAqB,QAAQ,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a,eAAY;AAAA,IAAyB,eAAW;AAAA,KAC1D,eAEH,mDAAC,0BAAD;AAAA,IAAY,eAAY;AAAA,KACtB,mDAAC,UAAD,QAED,CAAC,CAAC,WAAW,UACZ,wFACE,mDAAC,+BAAD;AAAA,IAAiB,eAAW;AAAA,MAC5B,mDAAC,2BAAD;AAAA,IAAa,eAAY;AAAA,IAA2B,eAAW;AAAA,KAC5D,qBAEH,mDAAC,0BAAD;AAAA,IAAY,eAAY;AAAA,KACtB,mDAAC,YAAD;AAAA;AAQZ,IAAO,wBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/cjs/DSAppPicker.js
CHANGED
|
@@ -1,138 +1,141 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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 DSAppPicker_exports = {};
|
|
29
|
+
__export(DSAppPicker_exports, {
|
|
30
|
+
AppPickerWithSchema: () => AppPickerWithSchema,
|
|
31
|
+
DSAppPicker: () => DSAppPicker,
|
|
32
|
+
default: () => DSAppPicker_default
|
|
33
|
+
});
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_react_desc = require("react-desc");
|
|
37
|
+
var import_ds_icons = require("@elliemae/ds-icons");
|
|
38
|
+
var import_ds_button = __toESM(require("@elliemae/ds-button"));
|
|
39
|
+
var import_ds_popover = __toESM(require("@elliemae/ds-popover"));
|
|
40
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
41
|
+
var import_AppPickerImpl = __toESM(require("./AppPickerImpl"));
|
|
42
|
+
var import_propTypes = require("./propTypes");
|
|
43
|
+
const DSAppPicker = ({
|
|
44
|
+
apps = [],
|
|
45
|
+
customApps = [],
|
|
46
|
+
sectionTitle = "APPLICATIONS",
|
|
47
|
+
customSectionTitle = "CUSTOM APPLICATIONS",
|
|
48
|
+
icon: Icon = () => /* @__PURE__ */ import_react.default.createElement(import_ds_icons.MenuPicker, {
|
|
49
|
+
fill: ["brand-primary", 700],
|
|
50
|
+
size: "m"
|
|
51
|
+
}),
|
|
52
|
+
renderTrigger,
|
|
53
|
+
isOpen,
|
|
54
|
+
onClose = () => null,
|
|
55
|
+
actionRef,
|
|
56
|
+
onKeyDown,
|
|
57
|
+
onClick = () => null,
|
|
58
|
+
onClickOutside = () => null,
|
|
59
|
+
triggerRef
|
|
60
|
+
}) => {
|
|
61
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
62
|
+
const [isOverflow, setIsOverflow] = (0, import_react.useState)(false);
|
|
63
|
+
const wrapperRef = (0, import_react.useRef)(null);
|
|
64
|
+
const defaultTriggerRef = (0, import_react.useRef)(null);
|
|
65
|
+
(0, import_react.useEffect)(() => {
|
|
48
66
|
if (actionRef && actionRef.current) {
|
|
49
|
-
actionRef.current.focusToIndex = index => {
|
|
67
|
+
actionRef.current.focusToIndex = (index) => {
|
|
50
68
|
if (wrapperRef.current) {
|
|
51
69
|
const parent = wrapperRef.current;
|
|
52
|
-
const buttons = [...parent.querySelectorAll(
|
|
70
|
+
const buttons = [...parent.querySelectorAll("button")];
|
|
53
71
|
buttons[index].focus();
|
|
54
72
|
}
|
|
55
73
|
};
|
|
56
74
|
}
|
|
57
75
|
}, [actionRef, apps, customApps]);
|
|
58
|
-
|
|
76
|
+
(0, import_react.useEffect)(() => {
|
|
59
77
|
setTimeout(() => {
|
|
60
78
|
if (wrapperRef.current) {
|
|
61
|
-
const {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
} = wrapperRef.current;
|
|
65
|
-
if (scrollHeight > clientHeight) return setIsOverflow(true);
|
|
79
|
+
const { scrollHeight, clientHeight } = wrapperRef.current;
|
|
80
|
+
if (scrollHeight > clientHeight)
|
|
81
|
+
return setIsOverflow(true);
|
|
66
82
|
}
|
|
67
|
-
|
|
68
83
|
return setIsOverflow(false);
|
|
69
84
|
});
|
|
70
85
|
}, [isOpen, open]);
|
|
71
|
-
|
|
72
86
|
const handleOnClose = () => {
|
|
73
|
-
if (typeof isOpen ===
|
|
87
|
+
if (typeof isOpen === "boolean") {
|
|
74
88
|
setOpen(isOpen);
|
|
75
89
|
} else {
|
|
76
90
|
setOpen(false);
|
|
77
91
|
}
|
|
78
|
-
|
|
79
92
|
onClose();
|
|
80
93
|
};
|
|
81
|
-
|
|
82
|
-
const handleOnClickOutside = e => {
|
|
94
|
+
const handleOnClickOutside = (e) => {
|
|
83
95
|
setOpen(false);
|
|
84
96
|
onClose();
|
|
85
97
|
onClickOutside(e);
|
|
86
98
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
customSectionTitle: customSectionTitle,
|
|
99
|
+
const AppPickerContent = () => /* @__PURE__ */ import_react.default.createElement(import_AppPickerImpl.default, {
|
|
100
|
+
apps,
|
|
101
|
+
customApps,
|
|
102
|
+
sectionTitle,
|
|
103
|
+
customSectionTitle,
|
|
93
104
|
close: handleOnClose,
|
|
94
|
-
wrapperRef
|
|
95
|
-
onKeyDown
|
|
105
|
+
wrapperRef,
|
|
106
|
+
onKeyDown,
|
|
96
107
|
triggerRef: triggerRef || defaultTriggerRef,
|
|
97
|
-
isOverflow
|
|
108
|
+
isOverflow
|
|
98
109
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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,
|
|
110
|
+
const RenderTrigger = renderTrigger || (({ ref }) => /* @__PURE__ */ import_react.default.createElement(import_ds_button.default, {
|
|
111
|
+
"data-testid": "app-picker__button",
|
|
112
|
+
id: "app-picker__button",
|
|
113
|
+
buttonType: "text",
|
|
114
|
+
icon: /* @__PURE__ */ import_react.default.createElement(Icon, null),
|
|
115
|
+
innerRef: (0, import_ds_utilities.mergeRefs)(ref, defaultTriggerRef),
|
|
116
|
+
onClick: (e) => {
|
|
117
|
+
onClick(e);
|
|
118
|
+
setOpen(true);
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
121
|
+
return /* @__PURE__ */ import_react.default.createElement(import_ds_popover.default, {
|
|
122
|
+
content: /* @__PURE__ */ import_react.default.createElement(AppPickerContent, null),
|
|
123
|
+
isOpen: typeof isOpen === "boolean" ? isOpen : open,
|
|
120
124
|
onClickOutside: handleOnClickOutside,
|
|
121
125
|
placement: "bottom",
|
|
122
126
|
interactionType: "click",
|
|
123
127
|
renderTrigger: RenderTrigger,
|
|
124
128
|
showArrow: true,
|
|
125
129
|
style: {
|
|
126
|
-
padding:
|
|
127
|
-
maxWidth:
|
|
128
|
-
width:
|
|
130
|
+
padding: "0",
|
|
131
|
+
maxWidth: "1000px",
|
|
132
|
+
width: "fit-content"
|
|
129
133
|
}
|
|
130
134
|
});
|
|
131
135
|
};
|
|
132
|
-
|
|
133
|
-
const AppPickerWithSchema =
|
|
134
|
-
AppPickerWithSchema.propTypes =
|
|
135
|
-
|
|
136
|
-
exports
|
|
137
|
-
|
|
138
|
-
exports["default"] = DSAppPicker;
|
|
136
|
+
DSAppPicker.propTypes = import_propTypes.propTypes;
|
|
137
|
+
const AppPickerWithSchema = (0, import_react_desc.describe)(DSAppPicker);
|
|
138
|
+
AppPickerWithSchema.propTypes = import_propTypes.propTypes;
|
|
139
|
+
var DSAppPicker_default = DSAppPicker;
|
|
140
|
+
module.exports = __toCommonJS(DSAppPicker_exports);
|
|
141
|
+
//# sourceMappingURL=DSAppPicker.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/DSAppPicker.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useState, useEffect, useRef } from 'react';\nimport { describe } from 'react-desc';\nimport { MenuPicker } from '@elliemae/ds-icons';\nimport DSButton from '@elliemae/ds-button';\nimport DSPopover from '@elliemae/ds-popover';\nimport { mergeRefs } from '@elliemae/ds-utilities';\nimport AppPickerImpl from './AppPickerImpl';\nimport { propTypes } from './propTypes';\nimport type { DSAppPickerType } from './types/AppPickerTypes';\n\nconst DSAppPicker: DSAppPickerType = ({\n apps = [],\n customApps = [],\n sectionTitle = 'APPLICATIONS',\n customSectionTitle = 'CUSTOM APPLICATIONS',\n icon: Icon = () => <MenuPicker fill={['brand-primary', 700]} size=\"m\" />,\n renderTrigger,\n isOpen,\n onClose = () => null,\n actionRef,\n onKeyDown,\n onClick = () => null,\n onClickOutside = () => null,\n triggerRef,\n}) => {\n const [open, setOpen] = useState(false);\n const [isOverflow, setIsOverflow] = useState(false);\n const wrapperRef = useRef<HTMLUListElement>(null);\n const defaultTriggerRef = useRef(null);\n\n useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusToIndex = (index) => {\n if (wrapperRef.current) {\n const parent = wrapperRef.current;\n const buttons = [...parent.querySelectorAll('button')];\n buttons[index].focus();\n }\n };\n }\n }, [actionRef, apps, customApps]);\n\n useEffect(() => {\n setTimeout(() => {\n if (wrapperRef.current) {\n const { scrollHeight, clientHeight } = wrapperRef.current;\n if (scrollHeight > clientHeight) return setIsOverflow(true);\n }\n return setIsOverflow(false);\n });\n }, [isOpen, open]);\n\n const handleOnClose = () => {\n if (typeof isOpen === 'boolean') {\n setOpen(isOpen);\n } else {\n setOpen(false);\n }\n onClose();\n };\n\n const handleOnClickOutside = (e: MouseEvent) => {\n setOpen(false);\n onClose();\n onClickOutside(e);\n };\n\n const AppPickerContent = () => (\n <AppPickerImpl\n apps={apps}\n customApps={customApps}\n sectionTitle={sectionTitle}\n customSectionTitle={customSectionTitle}\n close={handleOnClose}\n wrapperRef={wrapperRef}\n onKeyDown={onKeyDown}\n triggerRef={triggerRef || defaultTriggerRef}\n isOverflow={isOverflow}\n />\n );\n\n const RenderTrigger =\n renderTrigger ||\n (({ ref }) => (\n <DSButton\n data-testid=\"app-picker__button\"\n id=\"app-picker__button\"\n buttonType=\"text\"\n icon={<Icon />}\n innerRef={mergeRefs(ref, defaultTriggerRef)}\n onClick={(e) => {\n onClick(e);\n setOpen(true);\n }}\n />\n ));\n\n return (\n <DSPopover\n content={<AppPickerContent />}\n isOpen={typeof isOpen === 'boolean' ? isOpen : open}\n onClickOutside={handleOnClickOutside}\n placement=\"bottom\"\n interactionType=\"click\"\n renderTrigger={RenderTrigger}\n showArrow\n style={{\n padding: '0',\n maxWidth: '1000px',\n width: 'fit-content',\n }}\n />\n );\n};\n\nDSAppPicker.propTypes = propTypes;\n\nconst AppPickerWithSchema = describe(DSAppPicker);\nAppPickerWithSchema.propTypes = propTypes;\n\nexport { DSAppPicker, AppPickerWithSchema };\nexport default DSAppPicker;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAmD;AACnD,wBAAyB;AACzB,sBAA2B;AAC3B,uBAAqB;A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