@elliemae/ds-app-picker 3.16.0-next.20 → 3.16.0-next.22
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/AppPickerImpl.js +12 -5
- package/dist/cjs/AppPickerImpl.js.map +2 -2
- package/dist/cjs/hooks/useKeepTrackButtons.js +7 -2
- package/dist/cjs/hooks/useKeepTrackButtons.js.map +2 -2
- package/dist/esm/AppPickerImpl.js +12 -5
- package/dist/esm/AppPickerImpl.js.map +2 -2
- package/dist/esm/hooks/useKeepTrackButtons.js +7 -2
- package/dist/esm/hooks/useKeepTrackButtons.js.map +2 -2
- package/dist/types/hooks/useKeepTrackButtons.d.ts +8 -1
- package/dist/types/tests/a11y/axe.test.d.ts +1 -0
- package/package.json +11 -9
|
@@ -52,7 +52,12 @@ const AppPickerImpl = ({
|
|
|
52
52
|
wasOpenedByKeyboardRef,
|
|
53
53
|
triggerIsInternal
|
|
54
54
|
}) => {
|
|
55
|
-
const { allFocusableButtons } = (0, import_useKeepTrackButtons.useKeepTrackButtons)(
|
|
55
|
+
const { allFocusableButtons } = (0, import_useKeepTrackButtons.useKeepTrackButtons)({
|
|
56
|
+
wrapperRef,
|
|
57
|
+
wasOpenedByKeyboardRef,
|
|
58
|
+
actionRef,
|
|
59
|
+
triggerIsInternal
|
|
60
|
+
});
|
|
56
61
|
const handleKeyDown = (0, import_react.useCallback)(
|
|
57
62
|
(e) => {
|
|
58
63
|
switch (e.key) {
|
|
@@ -99,7 +104,7 @@ const AppPickerImpl = ({
|
|
|
99
104
|
(appList, prevIndex, title) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: appList.map((app, index) => {
|
|
100
105
|
const { label, disabled, selected, icon: Icon, id } = app;
|
|
101
106
|
const IconComp = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { className: "app-picker__icon", size: "m" });
|
|
102
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledListItem, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledListItem, { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
103
108
|
import_ds_chip.DSChip,
|
|
104
109
|
{
|
|
105
110
|
onClick: handleOnClick(app),
|
|
@@ -109,6 +114,7 @@ const AppPickerImpl = ({
|
|
|
109
114
|
disabled,
|
|
110
115
|
selected,
|
|
111
116
|
"aria-selected": selected,
|
|
117
|
+
role: "option",
|
|
112
118
|
id,
|
|
113
119
|
"aria-label": `${label}. ${title} (${index + prevIndex} of ${totalAppsLength})`,
|
|
114
120
|
icon: IconComp,
|
|
@@ -147,6 +153,7 @@ const AppPickerImpl = ({
|
|
|
147
153
|
import_styles.StyledWrapper,
|
|
148
154
|
{
|
|
149
155
|
forwardedAs: "ul",
|
|
156
|
+
role: "listbox",
|
|
150
157
|
ref: convertedTypeReference,
|
|
151
158
|
onKeyDown: handleOnKeyDownWrapper,
|
|
152
159
|
"data-testid": "app-picker__wrapper",
|
|
@@ -156,11 +163,11 @@ const AppPickerImpl = ({
|
|
|
156
163
|
tabIndex: -1,
|
|
157
164
|
"aria-label": `Application picker, ${sectionTitle} (${apps.length} apps)${customApps.length > 0 ? `, ${customSectionTitle} (${customApps.length} apps)` : ""}`,
|
|
158
165
|
children: [
|
|
159
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledListItemFullRow, { "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledTitle, { "data-testid": "app-picker__main-title", children: sectionTitle }) }),
|
|
166
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledListItemFullRow, { "aria-hidden": true, role: "group", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledTitle, { "data-testid": "app-picker__main-title", role: "presentation", children: sectionTitle }) }),
|
|
160
167
|
AppsRows,
|
|
161
168
|
customApps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
162
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledListItemFullRow, { "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledSeparator, {}) }),
|
|
163
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledListItemFullRow, { "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledTitle, { "data-testid": "app-picker__custom-title", children: customSectionTitle }) }),
|
|
169
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledListItemFullRow, { "aria-hidden": true, role: "group", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledSeparator, { role: "presentation" }) }),
|
|
170
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledListItemFullRow, { "aria-hidden": true, role: "group", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledTitle, { "data-testid": "app-picker__custom-title", role: "presentation", children: customSectionTitle }) }),
|
|
164
171
|
CustomRows
|
|
165
172
|
] })
|
|
166
173
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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, { useCallback, useMemo } from 'react';\nimport { DSChip } from '@elliemae/ds-chip';\nimport { keys } from './utils.js';\nimport type { AppItemType, DSAppPickerImplType } from './types/AppPickerTypes.js';\nimport { StyledWrapper, StyledSeparator, StyledListItemFullRow, StyledListItem, StyledTitle } from './styles.js';\nimport { useKeepTrackButtons } from './hooks/useKeepTrackButtons.js';\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 actionRef,\n wasOpenedByKeyboardRef,\n triggerIsInternal,\n}) => {\n const { allFocusableButtons } = useKeepTrackButtons(wrapperRef
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react/prop-types */\n/* eslint-disable react/no-array-index-key */\n/* eslint-disable max-lines */\nimport React, { useCallback, useMemo } from 'react';\nimport { DSChip } from '@elliemae/ds-chip';\nimport { keys } from './utils.js';\nimport type { AppItemType, DSAppPickerImplType } from './types/AppPickerTypes.js';\nimport { StyledWrapper, StyledSeparator, StyledListItemFullRow, StyledListItem, StyledTitle } from './styles.js';\nimport { useKeepTrackButtons } from './hooks/useKeepTrackButtons.js';\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 actionRef,\n wasOpenedByKeyboardRef,\n triggerIsInternal,\n}) => {\n const { allFocusableButtons } = useKeepTrackButtons({\n wrapperRef,\n wasOpenedByKeyboardRef,\n actionRef,\n triggerIsInternal,\n });\n\n // eslint-disable-next-line max-statements\n const handleKeyDown = useCallback(\n (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 [allFocusableButtons, close, triggerRef],\n );\n\n const handleOnClick = useCallback(\n (app: AppItemType) => (e: React.MouseEvent) => {\n if (app.onClick) app.onClick(e, app);\n },\n [],\n );\n\n const handleOnKeyDownWrapper = useCallback(\n (e: React.KeyboardEvent) => {\n if (onKeyDown) onKeyDown(e);\n if (!onKeyDown && e.key === keys.ESC) {\n close();\n }\n },\n [onKeyDown, close],\n );\n\n const totalAppsLength = useMemo(() => apps.length + customApps.length, [apps.length, customApps.length]);\n\n const buildRows = useCallback(\n (appList: AppItemType[], prevIndex: number, title: string): JSX.Element => (\n <>\n {appList.map((app, index) => {\n const { label, disabled, selected, icon: Icon, id } = app;\n\n // eslint-disable-next-line react/no-unstable-nested-components\n const IconComp = () => <Icon className=\"app-picker__icon\" size=\"m\" />;\n\n return (\n <StyledListItem role=\"presentation\">\n <DSChip\n key={index}\n onClick={handleOnClick(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 role=\"option\"\n id={id}\n aria-label={`${label}. ${title} (${index + prevIndex} of ${totalAppsLength})`}\n icon={IconComp}\n label={label}\n />\n </StyledListItem>\n );\n })}\n </>\n ),\n [handleKeyDown, handleOnClick, totalAppsLength],\n );\n\n const AppsRows = useMemo(() => buildRows(apps, 1, sectionTitle), [apps, buildRows, sectionTitle]);\n const CustomRows = useMemo(\n () => buildRows(customApps, apps.length, customSectionTitle),\n [apps.length, buildRows, customApps, customSectionTitle],\n );\n\n const layout = useMemo(() => {\n const cols = ['repeat(3, 92px)'];\n let appsRows = 0;\n let customRows = 0;\n const rows = [];\n if (apps.length > 0) {\n appsRows = apps.length / 3;\n rows.push('68px', `repeat(${appsRows}, 68px})`);\n }\n if (customApps.length > 0) {\n customRows = customApps.length / 3;\n rows.push('9px', '68px', `repeat(${customRows}, 68px})`);\n }\n return {\n rows,\n cols,\n };\n }, [apps.length, customApps.length]);\n\n // Needed just for typescript reasons\n const convertedTypeReference = wrapperRef as unknown as React.RefObject<HTMLDivElement> &\n React.RefObject<HTMLUListElement>;\n\n return (\n <StyledWrapper\n forwardedAs=\"ul\"\n role=\"listbox\"\n ref={convertedTypeReference}\n onKeyDown={handleOnKeyDownWrapper}\n data-testid=\"app-picker__wrapper\"\n isOverflow={isOverflow}\n cols={layout.cols}\n rows={layout.rows}\n tabIndex={-1}\n aria-label={`Application picker, ${sectionTitle} (${apps.length} apps)${\n customApps.length > 0 ? `, ${customSectionTitle} (${customApps.length} apps)` : ''\n }`}\n >\n <StyledListItemFullRow aria-hidden role=\"group\">\n <StyledTitle data-testid=\"app-picker__main-title\" role=\"presentation\">\n {sectionTitle}\n </StyledTitle>\n </StyledListItemFullRow>\n {AppsRows}\n {customApps.length > 0 && (\n <>\n <StyledListItemFullRow aria-hidden role=\"group\">\n <StyledSeparator role=\"presentation\" />\n </StyledListItemFullRow>\n <StyledListItemFullRow aria-hidden role=\"group\">\n <StyledTitle data-testid=\"app-picker__custom-title\" role=\"presentation\">\n {customSectionTitle}\n </StyledTitle>\n </StyledListItemFullRow>\n {CustomRows}\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;AAAA;ACAA,YAAuB;AD8EjB;AA3EN,mBAA4C;AAC5C,qBAAuB;AACvB,mBAAqB;AAErB,oBAAmG;AACnG,iCAAoC;AAEpC,MAAM,gBAAqC,CAAC;AAAA,EAC1C,OAAO,CAAC;AAAA,EACR,aAAa,CAAC;AAAA,EACd,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,QAAQ,MAAM;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AAC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C;AAAA;AAAA,MACC,aAAY;AAAA,MACZ,MAAK;AAAA,MACL,KAAK;AAAA,MACL,WAAW;AAAA,MACX,eAAY;AAAA,MACZ;AAAA,MACA,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,UAAU;AAAA,MACV,cAAY,uBAAuB,iBAAiB,KAAK,eACvD,WAAW,SAAS,IAAI,KAAK,uBAAuB,WAAW,iBAAiB;AAAA,MAGlF;AAAA,oDAAC,uCAAsB,eAAW,MAAC,MAAK,SACtC,sDAAC,6BAAY,eAAY,0BAAyB,MAAK,gBACpD,wBACH,GACF;AAAA,QACC;AAAA,QACA,WAAW,SAAS,KACnB,4EACE;AAAA,sDAAC,uCAAsB,eAAW,MAAC,MAAK,SACtC,sDAAC,iCAAgB,MAAK,gBAAe,GACvC;AAAA,UACA,4CAAC,uCAAsB,eAAW,MAAC,MAAK,SACtC,sDAAC,6BAAY,eAAY,4BAA2B,MAAK,gBACtD,8BACH,GACF;AAAA,UACC;AAAA,WACH;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,wBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,7 +34,12 @@ module.exports = __toCommonJS(useKeepTrackButtons_exports);
|
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
35
|
var import_react = require("react");
|
|
36
36
|
var import_utils = require("../utils.js");
|
|
37
|
-
const useKeepTrackButtons = (
|
|
37
|
+
const useKeepTrackButtons = ({
|
|
38
|
+
wrapperRef,
|
|
39
|
+
wasOpenedByKeyboardRef,
|
|
40
|
+
actionRef,
|
|
41
|
+
triggerIsInternal
|
|
42
|
+
}) => {
|
|
38
43
|
const allFocusableButtons = (0, import_react.useRef)([]);
|
|
39
44
|
const selectedButton = (0, import_react.useRef)(null);
|
|
40
45
|
(0, import_react.useEffect)(() => {
|
|
@@ -48,7 +53,7 @@ const useKeepTrackButtons = (wrapperRef, wasOpenedByKeyboardRef, actionRef, trig
|
|
|
48
53
|
if (!e.hasAttribute("disabled")) {
|
|
49
54
|
allFocusableButtons?.current?.push(e);
|
|
50
55
|
}
|
|
51
|
-
if (e.getAttribute("aria-
|
|
56
|
+
if (e.getAttribute("aria-current") === "true") {
|
|
52
57
|
selectedButton.current = index;
|
|
53
58
|
}
|
|
54
59
|
if (wasOpenedByKeyboardRef.current || !triggerIsInternal) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useKeepTrackButtons.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import type React from 'react';\nimport { useEffect, useRef } from 'react';\nimport { focusSelectedOrFirstAvailable } from '../utils.js';\nimport type { ActionRef } from '../types/AppPickerTypes.js';\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAkC;AAClC,mBAA8C;
|
|
4
|
+
"sourcesContent": ["import type React from 'react';\nimport { useEffect, useRef } from 'react';\nimport { focusSelectedOrFirstAvailable } from '../utils.js';\nimport type { ActionRef } from '../types/AppPickerTypes.js';\n\ninterface UseKeepTrackButtonsT {\n wrapperRef: React.RefObject<HTMLDivElement>;\n wasOpenedByKeyboardRef: React.MutableRefObject<boolean>;\n actionRef?: ActionRef;\n triggerIsInternal?: boolean;\n}\n\nexport const useKeepTrackButtons = ({\n wrapperRef,\n wasOpenedByKeyboardRef,\n actionRef,\n triggerIsInternal,\n}: UseKeepTrackButtonsT) => {\n const allFocusableButtons = useRef<HTMLButtonElement[]>([]);\n const selectedButton = useRef<number | null>(null);\n\n useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusSelectedOrFirstAvailable = () =>\n setTimeout(() => focusSelectedOrFirstAvailable(wrapperRef, allFocusableButtons, selectedButton));\n }\n }, [actionRef, wrapperRef]);\n\n useEffect(() => {\n setTimeout(() => {\n wrapperRef?.current?.querySelectorAll('button').forEach((e, index) => {\n if (!e.hasAttribute('disabled')) {\n allFocusableButtons?.current?.push(e);\n }\n if (e.getAttribute('aria-current') === 'true') {\n selectedButton.current = index;\n }\n if (wasOpenedByKeyboardRef.current || !triggerIsInternal) {\n focusSelectedOrFirstAvailable(wrapperRef, allFocusableButtons, selectedButton);\n } else {\n wrapperRef.current?.focus();\n }\n });\n });\n }, [wasOpenedByKeyboardRef, wrapperRef, triggerIsInternal]);\n\n return { allFocusableButtons, selectedButton };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAkC;AAClC,mBAA8C;AAUvC,MAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA4B;AAC1B,QAAM,0BAAsB,qBAA4B,CAAC,CAAC;AAC1D,QAAM,qBAAiB,qBAAsB,IAAI;AAEjD,8BAAU,MAAM;AACd,QAAI,aAAa,UAAU,SAAS;AAClC,gBAAU,QAAQ,gCAAgC,MAChD,WAAW,UAAM,4CAA8B,YAAY,qBAAqB,cAAc,CAAC;AAAA,IACnG;AAAA,EACF,GAAG,CAAC,WAAW,UAAU,CAAC;AAE1B,8BAAU,MAAM;AACd,eAAW,MAAM;AACf,kBAAY,SAAS,iBAAiB,QAAQ,EAAE,QAAQ,CAAC,GAAG,UAAU;AACpE,YAAI,CAAC,EAAE,aAAa,UAAU,GAAG;AAC/B,+BAAqB,SAAS,KAAK,CAAC;AAAA,QACtC;AACA,YAAI,EAAE,aAAa,cAAc,MAAM,QAAQ;AAC7C,yBAAe,UAAU;AAAA,QAC3B;AACA,YAAI,uBAAuB,WAAW,CAAC,mBAAmB;AACxD,0DAA8B,YAAY,qBAAqB,cAAc;AAAA,QAC/E,OAAO;AACL,qBAAW,SAAS,MAAM;AAAA,QAC5B;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH,GAAG,CAAC,wBAAwB,YAAY,iBAAiB,CAAC;AAE1D,SAAO,EAAE,qBAAqB,eAAe;AAC/C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -19,7 +19,12 @@ const AppPickerImpl = ({
|
|
|
19
19
|
wasOpenedByKeyboardRef,
|
|
20
20
|
triggerIsInternal
|
|
21
21
|
}) => {
|
|
22
|
-
const { allFocusableButtons } = useKeepTrackButtons(
|
|
22
|
+
const { allFocusableButtons } = useKeepTrackButtons({
|
|
23
|
+
wrapperRef,
|
|
24
|
+
wasOpenedByKeyboardRef,
|
|
25
|
+
actionRef,
|
|
26
|
+
triggerIsInternal
|
|
27
|
+
});
|
|
23
28
|
const handleKeyDown = useCallback(
|
|
24
29
|
(e) => {
|
|
25
30
|
switch (e.key) {
|
|
@@ -66,7 +71,7 @@ const AppPickerImpl = ({
|
|
|
66
71
|
(appList, prevIndex, title) => /* @__PURE__ */ jsx(Fragment, { children: appList.map((app, index) => {
|
|
67
72
|
const { label, disabled, selected, icon: Icon, id } = app;
|
|
68
73
|
const IconComp = () => /* @__PURE__ */ jsx(Icon, { className: "app-picker__icon", size: "m" });
|
|
69
|
-
return /* @__PURE__ */ jsx(StyledListItem, { children: /* @__PURE__ */ jsx(
|
|
74
|
+
return /* @__PURE__ */ jsx(StyledListItem, { role: "presentation", children: /* @__PURE__ */ jsx(
|
|
70
75
|
DSChip,
|
|
71
76
|
{
|
|
72
77
|
onClick: handleOnClick(app),
|
|
@@ -76,6 +81,7 @@ const AppPickerImpl = ({
|
|
|
76
81
|
disabled,
|
|
77
82
|
selected,
|
|
78
83
|
"aria-selected": selected,
|
|
84
|
+
role: "option",
|
|
79
85
|
id,
|
|
80
86
|
"aria-label": `${label}. ${title} (${index + prevIndex} of ${totalAppsLength})`,
|
|
81
87
|
icon: IconComp,
|
|
@@ -114,6 +120,7 @@ const AppPickerImpl = ({
|
|
|
114
120
|
StyledWrapper,
|
|
115
121
|
{
|
|
116
122
|
forwardedAs: "ul",
|
|
123
|
+
role: "listbox",
|
|
117
124
|
ref: convertedTypeReference,
|
|
118
125
|
onKeyDown: handleOnKeyDownWrapper,
|
|
119
126
|
"data-testid": "app-picker__wrapper",
|
|
@@ -123,11 +130,11 @@ const AppPickerImpl = ({
|
|
|
123
130
|
tabIndex: -1,
|
|
124
131
|
"aria-label": `Application picker, ${sectionTitle} (${apps.length} apps)${customApps.length > 0 ? `, ${customSectionTitle} (${customApps.length} apps)` : ""}`,
|
|
125
132
|
children: [
|
|
126
|
-
/* @__PURE__ */ jsx(StyledListItemFullRow, { "aria-hidden": true, children: /* @__PURE__ */ jsx(StyledTitle, { "data-testid": "app-picker__main-title", children: sectionTitle }) }),
|
|
133
|
+
/* @__PURE__ */ jsx(StyledListItemFullRow, { "aria-hidden": true, role: "group", children: /* @__PURE__ */ jsx(StyledTitle, { "data-testid": "app-picker__main-title", role: "presentation", children: sectionTitle }) }),
|
|
127
134
|
AppsRows,
|
|
128
135
|
customApps.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
129
|
-
/* @__PURE__ */ jsx(StyledListItemFullRow, { "aria-hidden": true, children: /* @__PURE__ */ jsx(StyledSeparator, {}) }),
|
|
130
|
-
/* @__PURE__ */ jsx(StyledListItemFullRow, { "aria-hidden": true, children: /* @__PURE__ */ jsx(StyledTitle, { "data-testid": "app-picker__custom-title", children: customSectionTitle }) }),
|
|
136
|
+
/* @__PURE__ */ jsx(StyledListItemFullRow, { "aria-hidden": true, role: "group", children: /* @__PURE__ */ jsx(StyledSeparator, { role: "presentation" }) }),
|
|
137
|
+
/* @__PURE__ */ jsx(StyledListItemFullRow, { "aria-hidden": true, role: "group", children: /* @__PURE__ */ jsx(StyledTitle, { "data-testid": "app-picker__custom-title", role: "presentation", children: customSectionTitle }) }),
|
|
131
138
|
CustomRows
|
|
132
139
|
] })
|
|
133
140
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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, { useCallback, useMemo } from 'react';\nimport { DSChip } from '@elliemae/ds-chip';\nimport { keys } from './utils.js';\nimport type { AppItemType, DSAppPickerImplType } from './types/AppPickerTypes.js';\nimport { StyledWrapper, StyledSeparator, StyledListItemFullRow, StyledListItem, StyledTitle } from './styles.js';\nimport { useKeepTrackButtons } from './hooks/useKeepTrackButtons.js';\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 actionRef,\n wasOpenedByKeyboardRef,\n triggerIsInternal,\n}) => {\n const { allFocusableButtons } = useKeepTrackButtons(wrapperRef
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
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, { useCallback, useMemo } from 'react';\nimport { DSChip } from '@elliemae/ds-chip';\nimport { keys } from './utils.js';\nimport type { AppItemType, DSAppPickerImplType } from './types/AppPickerTypes.js';\nimport { StyledWrapper, StyledSeparator, StyledListItemFullRow, StyledListItem, StyledTitle } from './styles.js';\nimport { useKeepTrackButtons } from './hooks/useKeepTrackButtons.js';\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 actionRef,\n wasOpenedByKeyboardRef,\n triggerIsInternal,\n}) => {\n const { allFocusableButtons } = useKeepTrackButtons({\n wrapperRef,\n wasOpenedByKeyboardRef,\n actionRef,\n triggerIsInternal,\n });\n\n // eslint-disable-next-line max-statements\n const handleKeyDown = useCallback(\n (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 [allFocusableButtons, close, triggerRef],\n );\n\n const handleOnClick = useCallback(\n (app: AppItemType) => (e: React.MouseEvent) => {\n if (app.onClick) app.onClick(e, app);\n },\n [],\n );\n\n const handleOnKeyDownWrapper = useCallback(\n (e: React.KeyboardEvent) => {\n if (onKeyDown) onKeyDown(e);\n if (!onKeyDown && e.key === keys.ESC) {\n close();\n }\n },\n [onKeyDown, close],\n );\n\n const totalAppsLength = useMemo(() => apps.length + customApps.length, [apps.length, customApps.length]);\n\n const buildRows = useCallback(\n (appList: AppItemType[], prevIndex: number, title: string): JSX.Element => (\n <>\n {appList.map((app, index) => {\n const { label, disabled, selected, icon: Icon, id } = app;\n\n // eslint-disable-next-line react/no-unstable-nested-components\n const IconComp = () => <Icon className=\"app-picker__icon\" size=\"m\" />;\n\n return (\n <StyledListItem role=\"presentation\">\n <DSChip\n key={index}\n onClick={handleOnClick(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 role=\"option\"\n id={id}\n aria-label={`${label}. ${title} (${index + prevIndex} of ${totalAppsLength})`}\n icon={IconComp}\n label={label}\n />\n </StyledListItem>\n );\n })}\n </>\n ),\n [handleKeyDown, handleOnClick, totalAppsLength],\n );\n\n const AppsRows = useMemo(() => buildRows(apps, 1, sectionTitle), [apps, buildRows, sectionTitle]);\n const CustomRows = useMemo(\n () => buildRows(customApps, apps.length, customSectionTitle),\n [apps.length, buildRows, customApps, customSectionTitle],\n );\n\n const layout = useMemo(() => {\n const cols = ['repeat(3, 92px)'];\n let appsRows = 0;\n let customRows = 0;\n const rows = [];\n if (apps.length > 0) {\n appsRows = apps.length / 3;\n rows.push('68px', `repeat(${appsRows}, 68px})`);\n }\n if (customApps.length > 0) {\n customRows = customApps.length / 3;\n rows.push('9px', '68px', `repeat(${customRows}, 68px})`);\n }\n return {\n rows,\n cols,\n };\n }, [apps.length, customApps.length]);\n\n // Needed just for typescript reasons\n const convertedTypeReference = wrapperRef as unknown as React.RefObject<HTMLDivElement> &\n React.RefObject<HTMLUListElement>;\n\n return (\n <StyledWrapper\n forwardedAs=\"ul\"\n role=\"listbox\"\n ref={convertedTypeReference}\n onKeyDown={handleOnKeyDownWrapper}\n data-testid=\"app-picker__wrapper\"\n isOverflow={isOverflow}\n cols={layout.cols}\n rows={layout.rows}\n tabIndex={-1}\n aria-label={`Application picker, ${sectionTitle} (${apps.length} apps)${\n customApps.length > 0 ? `, ${customSectionTitle} (${customApps.length} apps)` : ''\n }`}\n >\n <StyledListItemFullRow aria-hidden role=\"group\">\n <StyledTitle data-testid=\"app-picker__main-title\" role=\"presentation\">\n {sectionTitle}\n </StyledTitle>\n </StyledListItemFullRow>\n {AppsRows}\n {customApps.length > 0 && (\n <>\n <StyledListItemFullRow aria-hidden role=\"group\">\n <StyledSeparator role=\"presentation\" />\n </StyledListItemFullRow>\n <StyledListItemFullRow aria-hidden role=\"group\">\n <StyledTitle data-testid=\"app-picker__custom-title\" role=\"presentation\">\n {customSectionTitle}\n </StyledTitle>\n </StyledListItemFullRow>\n {CustomRows}\n </>\n )}\n </StyledWrapper>\n );\n};\n\nexport default AppPickerImpl;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC8EjB,mBA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M,OAAO,CAAC;AACd,QAAI,KAAK,SAAS,GAAG;AACnB,iBAAW,KAAK,SAAS;AACzB,WAAK,KAAK,QAAQ,UAAU,kBAAkB;AAAA,IAChD;AACA,QAAI,WAAW,SAAS,GAAG;AACzB,mBAAa,WAAW,SAAS;AACjC,WAAK,KAAK,OAAO,QAAQ,UAAU,oBAAoB;AAAA,IACzD;AACA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF,GAAG,CAAC,KAAK,QAAQ,WAAW,MAAM,CAAC;AAGnC,QAAM,yBAAyB;AAG/B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAY;AAAA,MACZ,MAAK;AAAA,MACL,KAAK;AAAA,MACL,WAAW;AAAA,MACX,eAAY;AAAA,MACZ;AAAA,MACA,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,UAAU;AAAA,MACV,cAAY,uBAAuB,iBAAiB,KAAK,eACvD,WAAW,SAAS,IAAI,KAAK,uBAAuB,WAAW,iBAAiB;AAAA,MAGlF;AAAA,4BAAC,yBAAsB,eAAW,MAAC,MAAK,SACtC,8BAAC,eAAY,eAAY,0BAAyB,MAAK,gBACpD,wBACH,GACF;AAAA,QACC;AAAA,QACA,WAAW,SAAS,KACnB,iCACE;AAAA,8BAAC,yBAAsB,eAAW,MAAC,MAAK,SACtC,8BAAC,mBAAgB,MAAK,gBAAe,GACvC;AAAA,UACA,oBAAC,yBAAsB,eAAW,MAAC,MAAK,SACtC,8BAAC,eAAY,eAAY,4BAA2B,MAAK,gBACtD,8BACH,GACF;AAAA,UACC;AAAA,WACH;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,wBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useEffect, useRef } from "react";
|
|
3
3
|
import { focusSelectedOrFirstAvailable } from "../utils.js";
|
|
4
|
-
const useKeepTrackButtons = (
|
|
4
|
+
const useKeepTrackButtons = ({
|
|
5
|
+
wrapperRef,
|
|
6
|
+
wasOpenedByKeyboardRef,
|
|
7
|
+
actionRef,
|
|
8
|
+
triggerIsInternal
|
|
9
|
+
}) => {
|
|
5
10
|
const allFocusableButtons = useRef([]);
|
|
6
11
|
const selectedButton = useRef(null);
|
|
7
12
|
useEffect(() => {
|
|
@@ -15,7 +20,7 @@ const useKeepTrackButtons = (wrapperRef, wasOpenedByKeyboardRef, actionRef, trig
|
|
|
15
20
|
if (!e.hasAttribute("disabled")) {
|
|
16
21
|
allFocusableButtons?.current?.push(e);
|
|
17
22
|
}
|
|
18
|
-
if (e.getAttribute("aria-
|
|
23
|
+
if (e.getAttribute("aria-current") === "true") {
|
|
19
24
|
selectedButton.current = index;
|
|
20
25
|
}
|
|
21
26
|
if (wasOpenedByKeyboardRef.current || !triggerIsInternal) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useKeepTrackButtons.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type React from 'react';\nimport { useEffect, useRef } from 'react';\nimport { focusSelectedOrFirstAvailable } from '../utils.js';\nimport type { ActionRef } from '../types/AppPickerTypes.js';\n\
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,WAAW,cAAc;AAClC,SAAS,qCAAqC;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type React from 'react';\nimport { useEffect, useRef } from 'react';\nimport { focusSelectedOrFirstAvailable } from '../utils.js';\nimport type { ActionRef } from '../types/AppPickerTypes.js';\n\ninterface UseKeepTrackButtonsT {\n wrapperRef: React.RefObject<HTMLDivElement>;\n wasOpenedByKeyboardRef: React.MutableRefObject<boolean>;\n actionRef?: ActionRef;\n triggerIsInternal?: boolean;\n}\n\nexport const useKeepTrackButtons = ({\n wrapperRef,\n wasOpenedByKeyboardRef,\n actionRef,\n triggerIsInternal,\n}: UseKeepTrackButtonsT) => {\n const allFocusableButtons = useRef<HTMLButtonElement[]>([]);\n const selectedButton = useRef<number | null>(null);\n\n useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusSelectedOrFirstAvailable = () =>\n setTimeout(() => focusSelectedOrFirstAvailable(wrapperRef, allFocusableButtons, selectedButton));\n }\n }, [actionRef, wrapperRef]);\n\n useEffect(() => {\n setTimeout(() => {\n wrapperRef?.current?.querySelectorAll('button').forEach((e, index) => {\n if (!e.hasAttribute('disabled')) {\n allFocusableButtons?.current?.push(e);\n }\n if (e.getAttribute('aria-current') === 'true') {\n selectedButton.current = index;\n }\n if (wasOpenedByKeyboardRef.current || !triggerIsInternal) {\n focusSelectedOrFirstAvailable(wrapperRef, allFocusableButtons, selectedButton);\n } else {\n wrapperRef.current?.focus();\n }\n });\n });\n }, [wasOpenedByKeyboardRef, wrapperRef, triggerIsInternal]);\n\n return { allFocusableButtons, selectedButton };\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,WAAW,cAAc;AAClC,SAAS,qCAAqC;AAUvC,MAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA4B;AAC1B,QAAM,sBAAsB,OAA4B,CAAC,CAAC;AAC1D,QAAM,iBAAiB,OAAsB,IAAI;AAEjD,YAAU,MAAM;AACd,QAAI,aAAa,UAAU,SAAS;AAClC,gBAAU,QAAQ,gCAAgC,MAChD,WAAW,MAAM,8BAA8B,YAAY,qBAAqB,cAAc,CAAC;AAAA,IACnG;AAAA,EACF,GAAG,CAAC,WAAW,UAAU,CAAC;AAE1B,YAAU,MAAM;AACd,eAAW,MAAM;AACf,kBAAY,SAAS,iBAAiB,QAAQ,EAAE,QAAQ,CAAC,GAAG,UAAU;AACpE,YAAI,CAAC,EAAE,aAAa,UAAU,GAAG;AAC/B,+BAAqB,SAAS,KAAK,CAAC;AAAA,QACtC;AACA,YAAI,EAAE,aAAa,cAAc,MAAM,QAAQ;AAC7C,yBAAe,UAAU;AAAA,QAC3B;AACA,YAAI,uBAAuB,WAAW,CAAC,mBAAmB;AACxD,wCAA8B,YAAY,qBAAqB,cAAc;AAAA,QAC/E,OAAO;AACL,qBAAW,SAAS,MAAM;AAAA,QAC5B;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH,GAAG,CAAC,wBAAwB,YAAY,iBAAiB,CAAC;AAE1D,SAAO,EAAE,qBAAqB,eAAe;AAC/C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import type { ActionRef } from '../types/AppPickerTypes.js';
|
|
3
|
-
|
|
3
|
+
interface UseKeepTrackButtonsT {
|
|
4
|
+
wrapperRef: React.RefObject<HTMLDivElement>;
|
|
5
|
+
wasOpenedByKeyboardRef: React.MutableRefObject<boolean>;
|
|
6
|
+
actionRef?: ActionRef;
|
|
7
|
+
triggerIsInternal?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const useKeepTrackButtons: ({ wrapperRef, wasOpenedByKeyboardRef, actionRef, triggerIsInternal, }: UseKeepTrackButtonsT) => {
|
|
4
10
|
allFocusableButtons: React.MutableRefObject<HTMLButtonElement[]>;
|
|
5
11
|
selectedButton: React.MutableRefObject<number | null>;
|
|
6
12
|
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-app-picker",
|
|
3
|
-
"version": "3.16.0-next.
|
|
3
|
+
"version": "3.16.0-next.22",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - App Picker",
|
|
6
6
|
"files": [
|
|
@@ -59,18 +59,20 @@
|
|
|
59
59
|
"indent": 4
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@elliemae/ds-button": "3.16.0-next.
|
|
63
|
-
"@elliemae/ds-
|
|
64
|
-
"@elliemae/ds-
|
|
65
|
-
"@elliemae/ds-
|
|
66
|
-
"@elliemae/ds-
|
|
67
|
-
"@elliemae/ds-props-helpers": "3.16.0-next.
|
|
68
|
-
"@elliemae/ds-system": "3.16.0-next.
|
|
69
|
-
"@elliemae/ds-utilities": "3.16.0-next.
|
|
62
|
+
"@elliemae/ds-button": "3.16.0-next.22",
|
|
63
|
+
"@elliemae/ds-grid": "3.16.0-next.22",
|
|
64
|
+
"@elliemae/ds-chip": "3.16.0-next.22",
|
|
65
|
+
"@elliemae/ds-popover": "3.16.0-next.22",
|
|
66
|
+
"@elliemae/ds-icons": "3.16.0-next.22",
|
|
67
|
+
"@elliemae/ds-props-helpers": "3.16.0-next.22",
|
|
68
|
+
"@elliemae/ds-system": "3.16.0-next.22",
|
|
69
|
+
"@elliemae/ds-utilities": "3.16.0-next.22"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@testing-library/jest-dom": "~5.16.5",
|
|
73
73
|
"@testing-library/react": "~12.1.3",
|
|
74
|
+
"@testing-library/user-event": "~13.5.0",
|
|
75
|
+
"jest-axe": "^7.0.1",
|
|
74
76
|
"styled-components": "~5.3.9"
|
|
75
77
|
},
|
|
76
78
|
"peerDependencies": {
|