@elliemae/ds-app-picker 2.2.0-next.4 → 2.3.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/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/types/DSAppPicker.d.ts +2 -2
package/esm/AppPickerImpl.js
CHANGED
|
@@ -1,174 +1,131 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const AppPickerImpl = _ref => {
|
|
28
|
-
let {
|
|
29
|
-
apps = [],
|
|
30
|
-
customApps = [],
|
|
31
|
-
sectionTitle = 'APPLICATIONS',
|
|
32
|
-
customSectionTitle = 'CUSTOM APPLICATIONS',
|
|
33
|
-
close = () => null,
|
|
34
|
-
wrapperRef,
|
|
35
|
-
onKeyDown,
|
|
36
|
-
triggerRef,
|
|
37
|
-
isOverflow
|
|
38
|
-
} = _ref;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useEffect, useCallback, useRef } from "react";
|
|
3
|
+
import { getDataProps } from "@elliemae/ds-props-helpers";
|
|
4
|
+
import { chunk } from "lodash";
|
|
5
|
+
import { keys } from "./utils";
|
|
6
|
+
import { SimpleTruncatedTooltipText } from "@elliemae/ds-truncated-tooltip-text";
|
|
7
|
+
import {
|
|
8
|
+
StyledWrapper,
|
|
9
|
+
StyledChip,
|
|
10
|
+
StyledChipLabel,
|
|
11
|
+
StyledTitle,
|
|
12
|
+
StyledGrid,
|
|
13
|
+
StyledRow,
|
|
14
|
+
StyledSeparator
|
|
15
|
+
} from "./styles";
|
|
16
|
+
const AppPickerImpl = ({
|
|
17
|
+
apps = [],
|
|
18
|
+
customApps = [],
|
|
19
|
+
sectionTitle = "APPLICATIONS",
|
|
20
|
+
customSectionTitle = "CUSTOM APPLICATIONS",
|
|
21
|
+
close = () => null,
|
|
22
|
+
wrapperRef,
|
|
23
|
+
onKeyDown,
|
|
24
|
+
triggerRef,
|
|
25
|
+
isOverflow
|
|
26
|
+
}) => {
|
|
39
27
|
const allFocusableButtons = useRef([]);
|
|
40
28
|
const selectedButton = useRef(null);
|
|
41
29
|
useEffect(() => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (!e.hasAttribute('disabled')) {
|
|
46
|
-
var _allFocusableButtons$;
|
|
47
|
-
|
|
48
|
-
allFocusableButtons === null || allFocusableButtons === void 0 ? void 0 : (_allFocusableButtons$ = allFocusableButtons.current) === null || _allFocusableButtons$ === void 0 ? void 0 : _allFocusableButtons$.push(e);
|
|
30
|
+
wrapperRef?.current?.querySelectorAll("button").forEach((e, index) => {
|
|
31
|
+
if (!e.hasAttribute("disabled")) {
|
|
32
|
+
allFocusableButtons?.current?.push(e);
|
|
49
33
|
}
|
|
50
|
-
|
|
51
|
-
if (e.getAttribute('aria-selected') === 'true') {
|
|
34
|
+
if (e.getAttribute("aria-selected") === "true") {
|
|
52
35
|
selectedButton.current = index;
|
|
53
36
|
}
|
|
54
37
|
});
|
|
55
|
-
|
|
56
38
|
if (selectedButton.current) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
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();
|
|
39
|
+
wrapperRef?.current?.querySelectorAll("button")[selectedButton.current].focus();
|
|
60
40
|
} else {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
allFocusableButtons === null || allFocusableButtons === void 0 ? void 0 : (_allFocusableButtons$2 = allFocusableButtons.current[0]) === null || _allFocusableButtons$2 === void 0 ? void 0 : _allFocusableButtons$2.focus();
|
|
41
|
+
allFocusableButtons?.current[0]?.focus();
|
|
64
42
|
}
|
|
65
|
-
}, [wrapperRef]);
|
|
66
|
-
|
|
67
|
-
const handleKeyDown = e => {
|
|
68
|
-
var _triggerRef$current;
|
|
69
|
-
|
|
43
|
+
}, [wrapperRef]);
|
|
44
|
+
const handleKeyDown = (e) => {
|
|
70
45
|
switch (e.key) {
|
|
71
46
|
case keys.ESC:
|
|
72
|
-
triggerRef
|
|
47
|
+
triggerRef?.current?.focus();
|
|
73
48
|
close();
|
|
74
49
|
break;
|
|
75
|
-
|
|
76
50
|
case keys.TAB:
|
|
77
51
|
if (e.shiftKey) {
|
|
78
52
|
if (e.target === allFocusableButtons.current[0]) {
|
|
79
|
-
var _allFocusableButtons$3;
|
|
80
|
-
|
|
81
53
|
e.preventDefault();
|
|
82
|
-
allFocusableButtons
|
|
54
|
+
allFocusableButtons?.current[allFocusableButtons.current.length - 1]?.focus();
|
|
83
55
|
}
|
|
84
56
|
} else if (e.target === allFocusableButtons.current[allFocusableButtons.current.length - 1]) {
|
|
85
|
-
var _allFocusableButtons$4;
|
|
86
|
-
|
|
87
57
|
e.preventDefault();
|
|
88
|
-
allFocusableButtons
|
|
58
|
+
allFocusableButtons?.current[0]?.focus();
|
|
89
59
|
}
|
|
90
|
-
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
91
62
|
break;
|
|
92
63
|
}
|
|
93
64
|
};
|
|
94
|
-
|
|
95
65
|
const handleOnClick = useCallback((e, app) => {
|
|
96
|
-
if (app.onClick)
|
|
66
|
+
if (app.onClick)
|
|
67
|
+
app.onClick(e, app);
|
|
97
68
|
}, []);
|
|
98
|
-
const handleOnKeyDownWrapper = useCallback(e => {
|
|
99
|
-
if (onKeyDown)
|
|
100
|
-
|
|
69
|
+
const handleOnKeyDownWrapper = useCallback((e) => {
|
|
70
|
+
if (onKeyDown)
|
|
71
|
+
onKeyDown(e);
|
|
101
72
|
if (!onKeyDown && e.key === keys.ESC) {
|
|
102
73
|
close();
|
|
103
74
|
}
|
|
104
75
|
}, [onKeyDown, close]);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
selected,
|
|
115
|
-
icon: Icon,
|
|
116
|
-
id
|
|
117
|
-
} = app,
|
|
118
|
-
otherProps = _objectWithoutProperties(app, _excluded);
|
|
119
|
-
|
|
120
|
-
return /*#__PURE__*/jsxs(StyledChip, _objectSpread(_objectSpread({
|
|
121
|
-
onClick: e => handleOnClick(e, app),
|
|
76
|
+
const buildRows = (appList, prevIndex = 0) => {
|
|
77
|
+
const rows = chunk(appList, 3);
|
|
78
|
+
const formattedRows = rows.map((row, index) => /* @__PURE__ */ React2.createElement(StyledRow, {
|
|
79
|
+
key: index
|
|
80
|
+
}, row.map((app, key) => {
|
|
81
|
+
const { label, disabled, selected, icon: Icon, id, ...otherProps } = app;
|
|
82
|
+
return /* @__PURE__ */ React2.createElement(StyledChip, {
|
|
83
|
+
key,
|
|
84
|
+
onClick: (e) => handleOnClick(e, app),
|
|
122
85
|
onKeyDown: handleKeyDown,
|
|
123
86
|
"data-testid": "app-picker__chip",
|
|
124
87
|
"aria-disabled": disabled,
|
|
125
|
-
disabled
|
|
126
|
-
selected
|
|
88
|
+
disabled,
|
|
89
|
+
selected,
|
|
127
90
|
"aria-selected": selected,
|
|
128
91
|
"aria-setsize": apps.length + customApps.length,
|
|
129
92
|
"aria-posinset": key + prevIndex,
|
|
130
|
-
id
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}), key);
|
|
93
|
+
id,
|
|
94
|
+
...getDataProps(otherProps)
|
|
95
|
+
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
96
|
+
className: "app-picker__icon",
|
|
97
|
+
size: "m"
|
|
98
|
+
}), /* @__PURE__ */ React2.createElement(StyledChipLabel, null, /* @__PURE__ */ React2.createElement(SimpleTruncatedTooltipText, {
|
|
99
|
+
value: label,
|
|
100
|
+
placement: "bottom"
|
|
101
|
+
})));
|
|
140
102
|
})));
|
|
141
|
-
return
|
|
142
|
-
children: formattedRows
|
|
143
|
-
});
|
|
103
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, formattedRows);
|
|
144
104
|
};
|
|
145
|
-
|
|
146
105
|
const AppsRows = () => buildRows(apps, 1);
|
|
147
|
-
|
|
148
106
|
const CustomRows = () => buildRows(customApps, apps.length);
|
|
149
|
-
|
|
150
|
-
return /*#__PURE__*/jsxs(StyledWrapper, {
|
|
107
|
+
return /* @__PURE__ */ React2.createElement(StyledWrapper, {
|
|
151
108
|
role: "listbox",
|
|
152
109
|
ref: wrapperRef,
|
|
153
110
|
onKeyDown: handleOnKeyDownWrapper,
|
|
154
111
|
"data-testid": "app-picker__wrapper",
|
|
155
|
-
isOverflow
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
112
|
+
isOverflow
|
|
113
|
+
}, /* @__PURE__ */ React2.createElement(StyledTitle, {
|
|
114
|
+
"data-testid": "app-picker__main-title",
|
|
115
|
+
"aria-hidden": true
|
|
116
|
+
}, sectionTitle), /* @__PURE__ */ React2.createElement(StyledGrid, {
|
|
117
|
+
"data-testid": "app-picker__main-grid"
|
|
118
|
+
}, /* @__PURE__ */ React2.createElement(AppsRows, null)), !!customApps.length && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(StyledSeparator, {
|
|
119
|
+
"aria-hidden": true
|
|
120
|
+
}), /* @__PURE__ */ React2.createElement(StyledTitle, {
|
|
121
|
+
"data-testid": "app-picker__custom-title",
|
|
122
|
+
"aria-hidden": true
|
|
123
|
+
}, customSectionTitle), /* @__PURE__ */ React2.createElement(StyledGrid, {
|
|
124
|
+
"data-testid": "app-picker__custom-grid"
|
|
125
|
+
}, /* @__PURE__ */ React2.createElement(CustomRows, null))));
|
|
126
|
+
};
|
|
127
|
+
var AppPickerImpl_default = AppPickerImpl;
|
|
128
|
+
export {
|
|
129
|
+
AppPickerImpl_default as default
|
|
172
130
|
};
|
|
173
|
-
|
|
174
|
-
export { AppPickerImpl as default };
|
|
131
|
+
//# sourceMappingURL=AppPickerImpl.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/AppPickerImpl.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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\nex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,MAC5B,qCAAC,aAAD;AAAA,IAAa,eAAY;AAAA,IAA2B,eAAW;AAAA,KAC5D,qBAEH,qCAAC,YAAD;AAAA,IAAY,eAAY;AAAA,KACtB,qCAAC,YAAD;AAAA;AAQZ,IAAO,wBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/DSAppPicker.js
CHANGED
|
@@ -1,45 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
onKeyDown,
|
|
29
|
-
onClick = () => null,
|
|
30
|
-
onClickOutside = () => null,
|
|
31
|
-
triggerRef
|
|
32
|
-
} = _ref;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useState, useEffect, useRef } from "react";
|
|
3
|
+
import { describe } from "react-desc";
|
|
4
|
+
import { MenuPicker } from "@elliemae/ds-icons";
|
|
5
|
+
import DSButton from "@elliemae/ds-button";
|
|
6
|
+
import DSPopover from "@elliemae/ds-popover";
|
|
7
|
+
import { mergeRefs } from "@elliemae/ds-utilities";
|
|
8
|
+
import AppPickerImpl from "./AppPickerImpl";
|
|
9
|
+
import { propTypes } from "./propTypes";
|
|
10
|
+
const DSAppPicker = ({
|
|
11
|
+
apps = [],
|
|
12
|
+
customApps = [],
|
|
13
|
+
sectionTitle = "APPLICATIONS",
|
|
14
|
+
customSectionTitle = "CUSTOM APPLICATIONS",
|
|
15
|
+
icon: Icon = () => /* @__PURE__ */ React2.createElement(MenuPicker, {
|
|
16
|
+
fill: ["brand-primary", 700],
|
|
17
|
+
size: "m"
|
|
18
|
+
}),
|
|
19
|
+
renderTrigger,
|
|
20
|
+
isOpen,
|
|
21
|
+
onClose = () => null,
|
|
22
|
+
actionRef,
|
|
23
|
+
onKeyDown,
|
|
24
|
+
onClick = () => null,
|
|
25
|
+
onClickOutside = () => null,
|
|
26
|
+
triggerRef
|
|
27
|
+
}) => {
|
|
33
28
|
const [open, setOpen] = useState(false);
|
|
34
29
|
const [isOverflow, setIsOverflow] = useState(false);
|
|
35
30
|
const wrapperRef = useRef(null);
|
|
36
31
|
const defaultTriggerRef = useRef(null);
|
|
37
32
|
useEffect(() => {
|
|
38
33
|
if (actionRef && actionRef.current) {
|
|
39
|
-
actionRef.current.focusToIndex = index => {
|
|
34
|
+
actionRef.current.focusToIndex = (index) => {
|
|
40
35
|
if (wrapperRef.current) {
|
|
41
36
|
const parent = wrapperRef.current;
|
|
42
|
-
const buttons = [...parent.querySelectorAll(
|
|
37
|
+
const buttons = [...parent.querySelectorAll("button")];
|
|
43
38
|
buttons[index].focus();
|
|
44
39
|
}
|
|
45
40
|
};
|
|
@@ -48,79 +43,70 @@ const DSAppPicker = _ref => {
|
|
|
48
43
|
useEffect(() => {
|
|
49
44
|
setTimeout(() => {
|
|
50
45
|
if (wrapperRef.current) {
|
|
51
|
-
const {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} = wrapperRef.current;
|
|
55
|
-
if (scrollHeight > clientHeight) return setIsOverflow(true);
|
|
46
|
+
const { scrollHeight, clientHeight } = wrapperRef.current;
|
|
47
|
+
if (scrollHeight > clientHeight)
|
|
48
|
+
return setIsOverflow(true);
|
|
56
49
|
}
|
|
57
|
-
|
|
58
50
|
return setIsOverflow(false);
|
|
59
51
|
});
|
|
60
52
|
}, [isOpen, open]);
|
|
61
|
-
|
|
62
53
|
const handleOnClose = () => {
|
|
63
|
-
if (typeof isOpen ===
|
|
54
|
+
if (typeof isOpen === "boolean") {
|
|
64
55
|
setOpen(isOpen);
|
|
65
56
|
} else {
|
|
66
57
|
setOpen(false);
|
|
67
58
|
}
|
|
68
|
-
|
|
69
59
|
onClose();
|
|
70
60
|
};
|
|
71
|
-
|
|
72
|
-
const handleOnClickOutside = e => {
|
|
61
|
+
const handleOnClickOutside = (e) => {
|
|
73
62
|
setOpen(false);
|
|
74
63
|
onClose();
|
|
75
64
|
onClickOutside(e);
|
|
76
65
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
customSectionTitle: customSectionTitle,
|
|
66
|
+
const AppPickerContent = () => /* @__PURE__ */ React2.createElement(AppPickerImpl, {
|
|
67
|
+
apps,
|
|
68
|
+
customApps,
|
|
69
|
+
sectionTitle,
|
|
70
|
+
customSectionTitle,
|
|
83
71
|
close: handleOnClose,
|
|
84
|
-
wrapperRef
|
|
85
|
-
onKeyDown
|
|
72
|
+
wrapperRef,
|
|
73
|
+
onKeyDown,
|
|
86
74
|
triggerRef: triggerRef || defaultTriggerRef,
|
|
87
|
-
isOverflow
|
|
75
|
+
isOverflow
|
|
88
76
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
return /*#__PURE__*/_jsx(DSPopover, {
|
|
108
|
-
content: /*#__PURE__*/_jsx(AppPickerContent, {}),
|
|
109
|
-
isOpen: typeof isOpen === 'boolean' ? isOpen : open,
|
|
77
|
+
const RenderTrigger = renderTrigger || (({ ref }) => /* @__PURE__ */ React2.createElement(DSButton, {
|
|
78
|
+
"data-testid": "app-picker__button",
|
|
79
|
+
id: "app-picker__button",
|
|
80
|
+
buttonType: "text",
|
|
81
|
+
icon: /* @__PURE__ */ React2.createElement(Icon, null),
|
|
82
|
+
innerRef: mergeRefs(ref, defaultTriggerRef),
|
|
83
|
+
onClick: (e) => {
|
|
84
|
+
onClick(e);
|
|
85
|
+
setOpen(true);
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
return /* @__PURE__ */ React2.createElement(DSPopover, {
|
|
89
|
+
content: /* @__PURE__ */ React2.createElement(AppPickerContent, null),
|
|
90
|
+
isOpen: typeof isOpen === "boolean" ? isOpen : open,
|
|
110
91
|
onClickOutside: handleOnClickOutside,
|
|
111
92
|
placement: "bottom",
|
|
112
93
|
interactionType: "click",
|
|
113
94
|
renderTrigger: RenderTrigger,
|
|
114
95
|
showArrow: true,
|
|
115
96
|
style: {
|
|
116
|
-
padding:
|
|
117
|
-
maxWidth:
|
|
118
|
-
width:
|
|
97
|
+
padding: "0",
|
|
98
|
+
maxWidth: "1000px",
|
|
99
|
+
width: "fit-content"
|
|
119
100
|
}
|
|
120
101
|
});
|
|
121
102
|
};
|
|
122
|
-
|
|
103
|
+
DSAppPicker.propTypes = propTypes;
|
|
123
104
|
const AppPickerWithSchema = describe(DSAppPicker);
|
|
124
105
|
AppPickerWithSchema.propTypes = propTypes;
|
|
125
|
-
|
|
126
|
-
export {
|
|
106
|
+
var DSAppPicker_default = DSAppPicker;
|
|
107
|
+
export {
|
|
108
|
+
AppPickerWithSchema,
|
|
109
|
+
DSAppPicker,
|
|
110
|
+
DSAppPicker_default as default
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=DSAppPicker.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSAppPicker.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAM,cAA+B,CAAC;AAAA,EACpC,OAAO;AAAA,EACP,aAAa;AAAA,EACb,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,MAAM,OAAO,MAAM,qCAAC,YAAD;AAAA,IAAY,MAAM,CAAC,iBAAiB;AAAA,IAAM,MAAK;AAAA;AAAA,EAClE;AAAA,EACA;AAAA,EACA,UAAU,MAAM;AAAA,EAChB;AAAA,EACA;AAAA,EACA,UAAU,MAAM;AAAA,EAChB,iBAAiB,MAAM;AAAA,EACvB;AAAA,MACI;AACJ,QAAM,CAAC,MAAM,WAAW,SAAS;AACjC,QAAM,CAAC,YAAY,iBAAiB,SAAS;AAC7C,QAAM,aAAa,OAAyB;AAC5C,QAAM,oBAAoB,OAAO;AAEjC,YAAU,MAAM;AACd,QAAI,aAAa,UAAU,SAAS;AAClC,gBAAU,QAAQ,eAAe,CAAC,UAAU;AAC1C,YAAI,WAAW,SAAS;AACtB,gBAAM,SAAS,WAAW;AAC1B,gBAAM,UAAU,CAAC,GAAG,OAAO,iBAAiB;AAC5C,kBAAQ,OAAO;AAAA;AAAA;AAAA;AAAA,KAIpB,CA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
|
1
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export * from "./DSAppPicker";
|
|
3
|
+
import { default as default2 } from "./DSAppPicker";
|
|
4
|
+
export {
|
|
5
|
+
default2 as default
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './DSAppPicker';\n\nexport { default } from './DSAppPicker';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAEA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/propTypes.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { PropTypes } from "react-desc";
|
|
3
|
+
import { MenuPicker } from "@elliemae/ds-icons";
|
|
4
4
|
const propTypes = {
|
|
5
|
-
apps: PropTypes.array.description(
|
|
6
|
-
customApps: PropTypes.array.description(
|
|
7
|
-
sectionTitle: PropTypes.string.description(
|
|
8
|
-
customSectionTitle: PropTypes.string.description(
|
|
9
|
-
icon: PropTypes.func.description(
|
|
10
|
-
renderTrigger: PropTypes.func.description(
|
|
11
|
-
actionRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
onClick: PropTypes.func.description('Custom onClick for Trigger component.'),
|
|
18
|
-
onClickOutside: PropTypes.func.description('Callback event when the user clicks outside the App Picker.')
|
|
5
|
+
apps: PropTypes.array.description("Main items. Format: [{ label:string, icon:component, onClick:func, disabled:bool, selected:bool }]").isRequired,
|
|
6
|
+
customApps: PropTypes.array.description("Custom items. Format: [{ label:string, icon:component, onClick:func, disabled:bool, selected:bool }]"),
|
|
7
|
+
sectionTitle: PropTypes.string.description("main section title").defaultValue("APPLICATIONS"),
|
|
8
|
+
customSectionTitle: PropTypes.string.description("custom section title").defaultValue("CUSTOM APPLICATIONS"),
|
|
9
|
+
icon: PropTypes.func.description("trigger button s icon").defaultValue(MenuPicker),
|
|
10
|
+
renderTrigger: PropTypes.func.description("Custom trigger component."),
|
|
11
|
+
actionRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description("Ref containing a focusToIndex method. This method allows you to focus any App inside the AppPicker."),
|
|
12
|
+
isOpen: PropTypes.bool.description("Wether the AppPicker should be open or not."),
|
|
13
|
+
onClose: PropTypes.func.description("Callback function when the AppPicker closes"),
|
|
14
|
+
onKeyDown: PropTypes.func.description("OnKeyDown handler callback."),
|
|
15
|
+
onClick: PropTypes.func.description("Custom onClick for Trigger component."),
|
|
16
|
+
onClickOutside: PropTypes.func.description("Callback event when the user clicks outside the App Picker.")
|
|
19
17
|
};
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export {
|
|
19
|
+
propTypes
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=propTypes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/propTypes.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from 'react-desc';\nimport { MenuPicker } from '@elliemae/ds-icons';\n\nexport const propTypes = {\n apps: PropTypes.array.description(\n 'Main items. Format: [{ label:string, icon:component, onClick:func, disabled:bool, selected:bool }]',\n ).isRequired,\n customApps: PropTypes.array.description(\n 'Custom items. Format: [{ label:string, icon:component, onClick:func, disabled:bool, selected:bool }]',\n ),\n sectionTitle: PropTypes.string.description('main section title').defaultValue('APPLICATIONS'),\n customSectionTitle: PropTypes.string.description('custom section title').defaultValue('CUSTOM APPLICATIONS'),\n icon: PropTypes.func.description('trigger button s icon').defaultValue(MenuPicker),\n renderTrigger: PropTypes.func.description('Custom trigger component.'),\n actionRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description(\n 'Ref containing a focusToIndex method. This method allows you to focus any App inside the AppPicker.',\n ),\n isOpen: PropTypes.bool.description('Wether the AppPicker should be open or not.'),\n onClose: PropTypes.func.description('Callback function when the AppPicker closes'),\n onKeyDown: PropTypes.func.description('OnKeyDown handler callback.'),\n onClick: PropTypes.func.description('Custom onClick for Trigger component.'),\n onClickOutside: PropTypes.func.description('Callback event when the user clicks outside the App Picker.'),\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAEO,MAAM,YAAY;AAAA,EACvB,MAAM,UAAU,MAAM,YACpB,sGACA;AAAA,EACF,YAAY,UAAU,MAAM,YAC1B;AAAA,EAEF,cAAc,UAAU,OAAO,YAAY,sBAAsB,aAAa;AAAA,EAC9E,oBAAoB,UAAU,OAAO,YAAY,wBAAwB,aAAa;AAAA,EACtF,MAAM,UAAU,KAAK,YAAY,yBAAyB,aAAa;AAAA,EACvE,eAAe,UAAU,KAAK,YAAY;AAAA,EAC1C,WAAW,UAAU,UAAU,CAAC,UAAU,MAAM,UAAU,MAAM,EAAE,SAAS,UAAU,SAAS,YAC5F;AAAA,EAEF,QAAQ,UAAU,KAAK,YAAY;AAAA,EACnC,SAAS,UAAU,KAAK,YAAY;AAAA,EACpC,WAAW,UAAU,KAAK,YAAY;AAAA,EACtC,SAAS,UAAU,KAAK,YAAY;AAAA,EACpC,gBAAgB,UAAU,KAAK,YAAY;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|