@elliemae/ds-app-picker 3.21.2-rc.2 → 3.21.2-rc.3
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 +14 -28
- package/dist/cjs/AppPickerImpl.js.map +2 -2
- package/dist/cjs/DSAppPicker.js +21 -18
- package/dist/cjs/DSAppPicker.js.map +2 -2
- package/dist/cjs/hooks/useKeepTrackButtons.js +18 -17
- package/dist/cjs/hooks/useKeepTrackButtons.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js +4 -1
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/utils.js +1 -1
- package/dist/cjs/utils.js.map +2 -2
- package/dist/esm/AppPickerImpl.js +15 -29
- package/dist/esm/AppPickerImpl.js.map +2 -2
- package/dist/esm/DSAppPicker.js +22 -19
- package/dist/esm/DSAppPicker.js.map +2 -2
- package/dist/esm/hooks/useKeepTrackButtons.js +19 -18
- package/dist/esm/hooks/useKeepTrackButtons.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js +4 -1
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/utils.js +1 -1
- package/dist/esm/utils.js.map +2 -2
- package/dist/types/hooks/useKeepTrackButtons.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/package.json +9 -9
|
@@ -39,6 +39,7 @@ var import_utils = require("./utils.js");
|
|
|
39
39
|
var import_styles = require("./styles.js");
|
|
40
40
|
var import_useKeepTrackButtons = require("./hooks/useKeepTrackButtons.js");
|
|
41
41
|
var import_DSAppPickerDefinitions = require("./DSAppPickerDefinitions.js");
|
|
42
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
42
43
|
const AppPickerImpl = ({
|
|
43
44
|
apps,
|
|
44
45
|
customApps,
|
|
@@ -59,30 +60,8 @@ const AppPickerImpl = ({
|
|
|
59
60
|
actionRef,
|
|
60
61
|
triggerIsInternal
|
|
61
62
|
});
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
switch (e.key) {
|
|
65
|
-
case import_utils.keys.ESC:
|
|
66
|
-
triggerRef?.current?.focus();
|
|
67
|
-
close();
|
|
68
|
-
break;
|
|
69
|
-
case import_utils.keys.TAB:
|
|
70
|
-
if (e.shiftKey) {
|
|
71
|
-
if (e.target === allFocusableButtons.current[0]) {
|
|
72
|
-
e.preventDefault();
|
|
73
|
-
allFocusableButtons?.current[allFocusableButtons.current.length - 1]?.focus();
|
|
74
|
-
}
|
|
75
|
-
} else if (e.target === allFocusableButtons.current[allFocusableButtons.current.length - 1]) {
|
|
76
|
-
e.preventDefault();
|
|
77
|
-
allFocusableButtons?.current[0]?.focus();
|
|
78
|
-
}
|
|
79
|
-
break;
|
|
80
|
-
default:
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
[allFocusableButtons, close, triggerRef]
|
|
85
|
-
);
|
|
63
|
+
const firstElementRef = (0, import_react.useRef)(null);
|
|
64
|
+
const lastElementRef = (0, import_react.useRef)(null);
|
|
86
65
|
const handleOnClick = (0, import_react.useCallback)(
|
|
87
66
|
(app) => (e) => {
|
|
88
67
|
if (app.onClick)
|
|
@@ -95,11 +74,19 @@ const AppPickerImpl = ({
|
|
|
95
74
|
if (onKeyDown)
|
|
96
75
|
onKeyDown(e);
|
|
97
76
|
if (!onKeyDown && e.key === import_utils.keys.ESC) {
|
|
77
|
+
triggerRef?.current?.focus();
|
|
98
78
|
close();
|
|
99
79
|
}
|
|
100
80
|
},
|
|
101
|
-
[onKeyDown, close]
|
|
81
|
+
[onKeyDown, triggerRef, close]
|
|
102
82
|
);
|
|
83
|
+
firstElementRef.current = allFocusableButtons[0];
|
|
84
|
+
lastElementRef.current = allFocusableButtons[allFocusableButtons.length - 1];
|
|
85
|
+
const handleOnKeyDown = (0, import_ds_utilities.useFocusTrap)({
|
|
86
|
+
firstElementRef,
|
|
87
|
+
lastElementRef,
|
|
88
|
+
onKeyDown: handleOnKeyDownWrapper
|
|
89
|
+
});
|
|
103
90
|
const totalAppsLength = (0, import_react.useMemo)(() => apps.length + customApps.length, [apps.length, customApps.length]);
|
|
104
91
|
const buildRows = (0, import_react.useCallback)(
|
|
105
92
|
(appList, prevIndex, title) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: appList.map((app, index) => {
|
|
@@ -109,7 +96,6 @@ const AppPickerImpl = ({
|
|
|
109
96
|
import_ds_chip.DSChip,
|
|
110
97
|
{
|
|
111
98
|
onClick: handleOnClick(app),
|
|
112
|
-
onKeyDown: handleKeyDown,
|
|
113
99
|
"data-testid": import_DSAppPickerDefinitions.DSAppPickerDataTestIds.CHIP,
|
|
114
100
|
"aria-disabled": disabled,
|
|
115
101
|
disabled,
|
|
@@ -124,7 +110,7 @@ const AppPickerImpl = ({
|
|
|
124
110
|
index
|
|
125
111
|
) });
|
|
126
112
|
}) }),
|
|
127
|
-
[
|
|
113
|
+
[handleOnClick, totalAppsLength]
|
|
128
114
|
);
|
|
129
115
|
const AppsRows = (0, import_react.useMemo)(() => buildRows(apps, 1, sectionTitle), [apps, buildRows, sectionTitle]);
|
|
130
116
|
const CustomRows = (0, import_react.useMemo)(
|
|
@@ -156,7 +142,7 @@ const AppPickerImpl = ({
|
|
|
156
142
|
forwardedAs: "ul",
|
|
157
143
|
role: "listbox",
|
|
158
144
|
ref: convertedTypeReference,
|
|
159
|
-
onKeyDown:
|
|
145
|
+
onKeyDown: handleOnKeyDown,
|
|
160
146
|
"data-testid": import_DSAppPickerDefinitions.DSAppPickerDataTestIds.WRAPPER,
|
|
161
147
|
isOverflow,
|
|
162
148
|
cols: layout.cols,
|
|
@@ -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 max-lines */\n/* eslint-disable react/no-array-index-key */\nimport React, { useCallback, useMemo } from 'react';\nimport { DSChip } from '@elliemae/ds-chip';\nimport { keys } from './utils.js';\nimport { StyledWrapper, StyledSeparator, StyledListItemFullRow, StyledListItem, StyledTitle } from './styles.js';\nimport { useKeepTrackButtons } from './hooks/useKeepTrackButtons.js';\nimport type { DSAppPickerT } from './react-desc-prop-types.js';\nimport { DSAppPickerDataTestIds } from './DSAppPickerDefinitions.js';\n\ninterface AppPickerImplProps\n extends Omit<\n DSAppPickerT.InternalProps,\n 'onClose' | 'icon' | 'onClick' | 'onClickOutside' | 'renderTrigger' | 'isOpen'\n > {\n close: () => void;\n wrapperRef: React.RefObject<HTMLDivElement>;\n isOverflow: boolean;\n wasOpenedByKeyboardRef: React.MutableRefObject<boolean>;\n triggerIsInternal: boolean;\n}\n\nconst AppPickerImpl: React.ComponentType<AppPickerImplProps> = ({\n apps,\n customApps,\n sectionTitle,\n customSectionTitle,\n close,\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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable react/no-array-index-key */\nimport React, { useCallback, useRef, useMemo } from 'react';\nimport { DSChip } from '@elliemae/ds-chip';\nimport { keys } from './utils.js';\nimport { StyledWrapper, StyledSeparator, StyledListItemFullRow, StyledListItem, StyledTitle } from './styles.js';\nimport { useKeepTrackButtons } from './hooks/useKeepTrackButtons.js';\nimport type { DSAppPickerT } from './react-desc-prop-types.js';\nimport { DSAppPickerDataTestIds } from './DSAppPickerDefinitions.js';\nimport { useFocusTrap } from '@elliemae/ds-utilities';\n\ninterface AppPickerImplProps\n extends Omit<\n DSAppPickerT.InternalProps,\n 'onClose' | 'icon' | 'onClick' | 'onClickOutside' | 'renderTrigger' | 'isOpen'\n > {\n close: () => void;\n wrapperRef: React.RefObject<HTMLDivElement>;\n isOverflow: boolean;\n wasOpenedByKeyboardRef: React.MutableRefObject<boolean>;\n triggerIsInternal: boolean;\n}\n\nconst AppPickerImpl: React.ComponentType<AppPickerImplProps> = ({\n apps,\n customApps,\n sectionTitle,\n customSectionTitle,\n close,\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 const firstElementRef = useRef<HTMLElement | null>(null);\n const lastElementRef = useRef<HTMLElement | null>(null);\n\n const handleOnClick = useCallback(\n (app: DSAppPickerT.AppItem) => (e: React.MouseEvent) => {\n if (app.onClick) app.onClick(e, app);\n },\n [],\n );\n\n const handleOnKeyDownWrapper: React.KeyboardEventHandler = useCallback(\n (e) => {\n if (onKeyDown) onKeyDown(e);\n if (!onKeyDown && e.key === keys.ESC) {\n triggerRef?.current?.focus();\n close();\n }\n },\n [onKeyDown, triggerRef, close],\n );\n firstElementRef.current = allFocusableButtons[0];\n lastElementRef.current = allFocusableButtons[allFocusableButtons.length - 1];\n\n const handleOnKeyDown = useFocusTrap({\n firstElementRef,\n lastElementRef,\n onKeyDown: handleOnKeyDownWrapper,\n });\n\n const totalAppsLength = useMemo(() => apps.length + customApps.length, [apps.length, customApps.length]);\n\n const buildRows = useCallback(\n (appList: DSAppPickerT.AppItem[], 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 data-testid={DSAppPickerDataTestIds.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 [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={handleOnKeyDown}\n data-testid={DSAppPickerDataTestIds.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={DSAppPickerDataTestIds.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={DSAppPickerDataTestIds.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;AD6EjB;AA3EN,mBAAoD;AACpD,qBAAuB;AACvB,mBAAqB;AACrB,oBAAmG;AACnG,iCAAoC;AAEpC,oCAAuC;AACvC,0BAA6B;AAc7B,MAAM,gBAAyD,CAAC;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,oBAAoB,QAAI,gDAAoB;AAAA,IAClD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,sBAAkB,qBAA2B,IAAI;AACvD,QAAM,qBAAiB,qBAA2B,IAAI;AAEtD,QAAM,oBAAgB;AAAA,IACpB,CAAC,QAA8B,CAAC,MAAwB;AACtD,UAAI,IAAI;AAAS,YAAI,QAAQ,GAAG,GAAG;AAAA,IACrC;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,6BAAqD;AAAA,IACzD,CAAC,MAAM;AACL,UAAI;AAAW,kBAAU,CAAC;AAC1B,UAAI,CAAC,aAAa,EAAE,QAAQ,kBAAK,KAAK;AACpC,oBAAY,SAAS,MAAM;AAC3B,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,CAAC,WAAW,YAAY,KAAK;AAAA,EAC/B;AACA,kBAAgB,UAAU,oBAAoB,CAAC;AAC/C,iBAAe,UA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ACzB,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,eAAa,qDAAuB;AAAA,MACpC;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,eAAa,qDAAuB,YAAY,MAAK,gBAC/D,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,eAAa,qDAAuB,cAAc,MAAK,gBACjE,8BACH,GACF;AAAA,UACC;AAAA,WACH;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,wBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/DSAppPicker.js
CHANGED
|
@@ -129,24 +129,27 @@ const DSAppPicker = (props) => {
|
|
|
129
129
|
triggerRef
|
|
130
130
|
]
|
|
131
131
|
);
|
|
132
|
-
const RenderTrigger =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
132
|
+
const RenderTrigger = (0, import_react.useMemo)(
|
|
133
|
+
() => renderTrigger || (({ ref }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
134
|
+
import_ds_button_v2.DSButtonV2,
|
|
135
|
+
{
|
|
136
|
+
"data-testid": import_DSAppPickerDefinitions.DSAppPickerDataTestIds.TRIGGER,
|
|
137
|
+
id: "app-picker__button",
|
|
138
|
+
buttonType: "icon",
|
|
139
|
+
"aria-haspopup": "true",
|
|
140
|
+
"aria-expanded": isOpen ?? open,
|
|
141
|
+
"aria-label": "Application picker",
|
|
142
|
+
innerRef: (0, import_ds_utilities.mergeRefs)(ref, triggerRef || defaultTriggerRef),
|
|
143
|
+
onClick: (e) => {
|
|
144
|
+
wasOpenedByKeyboardRef.current = e.detail === 0;
|
|
145
|
+
onClick?.(e);
|
|
146
|
+
setOpen(true);
|
|
147
|
+
},
|
|
148
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {})
|
|
149
|
+
}
|
|
150
|
+
)),
|
|
151
|
+
[Icon, isOpen, onClick, open, renderTrigger, triggerRef]
|
|
152
|
+
);
|
|
150
153
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
151
154
|
import_ds_popover.default,
|
|
152
155
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSAppPicker.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useState, useEffect, useRef, useCallback } from 'react';\nimport { DSButtonV2 } from '@elliemae/ds-button-v2';\nimport { mergeRefs } from '@elliemae/ds-utilities';\nimport { describe, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport DSPopover from '@elliemae/ds-popover';\nimport AppPickerImpl from './AppPickerImpl.js';\nimport type { DSAppPickerT } from './react-desc-prop-types.js';\nimport { DSAppPickerPropTypes, defaultProps } from './react-desc-prop-types.js';\nimport { DSAppPickerDataTestIds, DSAppPickerName } from './DSAppPickerDefinitions.js';\n\nconst DSAppPicker: React.ComponentType<DSAppPickerT.Props> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSAppPickerT.InternalProps>(props, defaultProps);\n\n const {\n apps,\n customApps,\n sectionTitle,\n customSectionTitle,\n icon: Icon,\n renderTrigger,\n isOpen,\n onClose,\n actionRef,\n onKeyDown,\n onClick,\n onClickOutside,\n triggerRef,\n } = propsWithDefault;\n\n const [open, setOpen] = useState(false);\n const [isOverflow, setIsOverflow] = useState(false);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const defaultTriggerRef = useRef(null);\n const wasOpenedByKeyboardRef = useRef(false);\n\n useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusToIndex = (index: number) => {\n if (wrapperRef.current) {\n const parent = wrapperRef.current;\n const buttons = [...parent.querySelectorAll('button')];\n buttons[index].focus();\n }\n };\n actionRef.current.focusWrapper = () => {\n wrapperRef.current?.focus();\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 = useCallback(() => {\n setOpen(false);\n onClose?.();\n }, [onClose]);\n\n const handleOnClickOutside = (e: React.MouseEvent) => {\n setOpen(false);\n onClose?.();\n onClickOutside?.(e);\n };\n\n const AppPickerContent = useCallback(\n () => (\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 actionRef={actionRef}\n triggerIsInternal={!renderTrigger}\n wasOpenedByKeyboardRef={wasOpenedByKeyboardRef}\n isOverflow={isOverflow}\n />\n ),\n [\n actionRef,\n apps,\n customApps,\n customSectionTitle,\n handleOnClose,\n isOverflow,\n onKeyDown,\n renderTrigger,\n sectionTitle,\n triggerRef,\n ],\n );\n\n const RenderTrigger
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADyEjB;AAzEN,
|
|
4
|
+
"sourcesContent": ["import React, { useState, useEffect, useMemo, useRef, useCallback } from 'react';\nimport { DSButtonV2 } from '@elliemae/ds-button-v2';\nimport { mergeRefs } from '@elliemae/ds-utilities';\nimport { describe, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport DSPopover from '@elliemae/ds-popover';\nimport AppPickerImpl from './AppPickerImpl.js';\nimport type { DSAppPickerT } from './react-desc-prop-types.js';\nimport { DSAppPickerPropTypes, defaultProps } from './react-desc-prop-types.js';\nimport { DSAppPickerDataTestIds, DSAppPickerName } from './DSAppPickerDefinitions.js';\n\nconst DSAppPicker: React.ComponentType<DSAppPickerT.Props> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSAppPickerT.InternalProps>(props, defaultProps);\n\n const {\n apps,\n customApps,\n sectionTitle,\n customSectionTitle,\n icon: Icon,\n renderTrigger,\n isOpen,\n onClose,\n actionRef,\n onKeyDown,\n onClick,\n onClickOutside,\n triggerRef,\n } = propsWithDefault;\n\n const [open, setOpen] = useState(false);\n const [isOverflow, setIsOverflow] = useState(false);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const defaultTriggerRef = useRef(null);\n const wasOpenedByKeyboardRef = useRef(false);\n\n useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusToIndex = (index: number) => {\n if (wrapperRef.current) {\n const parent = wrapperRef.current;\n const buttons = [...parent.querySelectorAll('button')];\n buttons[index].focus();\n }\n };\n actionRef.current.focusWrapper = () => {\n wrapperRef.current?.focus();\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 = useCallback(() => {\n setOpen(false);\n onClose?.();\n }, [onClose]);\n\n const handleOnClickOutside = (e: React.MouseEvent) => {\n setOpen(false);\n onClose?.();\n onClickOutside?.(e);\n };\n\n const AppPickerContent = useCallback(\n () => (\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 actionRef={actionRef}\n triggerIsInternal={!renderTrigger}\n wasOpenedByKeyboardRef={wasOpenedByKeyboardRef}\n isOverflow={isOverflow}\n />\n ),\n [\n actionRef,\n apps,\n customApps,\n customSectionTitle,\n handleOnClose,\n isOverflow,\n onKeyDown,\n renderTrigger,\n sectionTitle,\n triggerRef,\n ],\n );\n\n const RenderTrigger = useMemo(\n () =>\n renderTrigger ||\n (({ ref }: { ref: React.RefObject<HTMLButtonElement> }) => (\n <DSButtonV2\n data-testid={DSAppPickerDataTestIds.TRIGGER}\n id=\"app-picker__button\"\n buttonType=\"icon\"\n aria-haspopup=\"true\"\n aria-expanded={isOpen ?? open}\n aria-label=\"Application picker\"\n innerRef={mergeRefs(ref, triggerRef || defaultTriggerRef)}\n onClick={(e: React.MouseEvent | React.KeyboardEvent) => {\n wasOpenedByKeyboardRef.current = e.detail === 0;\n onClick?.(e);\n setOpen(true);\n }}\n >\n <Icon />\n </DSButtonV2>\n )),\n [Icon, isOpen, onClick, open, renderTrigger, triggerRef],\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.displayName = DSAppPickerName;\nconst AppPickerWithSchema = describe(DSAppPicker);\nAppPickerWithSchema.propTypes = DSAppPickerPropTypes;\n\nexport { DSAppPicker, AppPickerWithSchema };\nexport default DSAppPicker;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADyEjB;AAzEN,mBAAyE;AACzE,0BAA2B;AAC3B,0BAA0B;AAC1B,8BAAuD;AACvD,wBAAsB;AACtB,2BAA0B;AAE1B,mCAAmD;AACnD,oCAAwD;AAExD,MAAM,cAAuD,CAAC,UAAU;AACtE,QAAM,uBAAmB,sDAAyD,OAAO,yCAAY;AAErG,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,KAAK;AACtC,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,KAAK;AAClD,QAAM,iBAAa,qBAAuB,IAAI;AAC9C,QAAM,wBAAoB,qBAAO,IAAI;AACrC,QAAM,6BAAyB,qBAAO,KAAK;AAE3C,8BAAU,MAAM;AACd,QAAI,aAAa,UAAU,SAAS;AAClC,gBAAU,QAAQ,eAAe,CAAC,UAAkB;AAClD,YAAI,WAAW,SAAS;AACtB,gBAAM,SAAS,WAAW;AAC1B,gBAAM,UAAU,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BAAe,UAAU;AAAA,QACzB,cAAW;AAAA,QACX,cAAU,+BAAU,KAAK,cAAc,iBAAiB;AAAA,QACxD,SAAS,CAAC,MAA8C;AACtD,iCAAuB,UAAU,EAAE,WAAW;AAC9C,oBAAU,CAAC;AACX,kBAAQ,IAAI;AAAA,QACd;AAAA,QAEA,sDAAC,QAAK;AAAA;AAAA,IACR;AAAA,IAEJ,CAAC,MAAM,QAAQ,SAAS,MAAM,eAAe,UAAU;AAAA,EACzD;AAEA,SACE;AAAA,IAAC,kBAAAC;AAAA,IAAA;AAAA,MACC,SAAS,4CAAC,oBAAiB;AAAA,MAC3B,QAAQ,OAAO,WAAW,YAAY,SAAS;AAAA,MAC/C,gBAAgB;AAAA,MAChB,WAAU;AAAA,MACV,iBAAgB;AAAA,MAChB,eAAe;AAAA,MACf,WAAS;AAAA,MACT,OAAO;AAAA,QACL,SAAS;AAAA,QACT,UAAU;AAAA,QACV,OAAO;AAAA,MACT;AAAA;AAAA,EACF;AAEJ;AAEA,YAAY,cAAc;AAC1B,MAAM,0BAAsB,kCAAS,WAAW;AAChD,oBAAoB,YAAY;AAGhC,IAAO,sBAAQ;",
|
|
6
6
|
"names": ["AppPickerImpl", "DSPopover"]
|
|
7
7
|
}
|
|
@@ -40,30 +40,31 @@ const useKeepTrackButtons = ({
|
|
|
40
40
|
actionRef,
|
|
41
41
|
triggerIsInternal
|
|
42
42
|
}) => {
|
|
43
|
-
const allFocusableButtons = (0, import_react.
|
|
43
|
+
const [allFocusableButtons, setAllFocusableButtons] = (0, import_react.useState)([]);
|
|
44
44
|
const selectedButton = (0, import_react.useRef)(null);
|
|
45
45
|
(0, import_react.useEffect)(() => {
|
|
46
46
|
if (actionRef && actionRef.current) {
|
|
47
|
-
actionRef.current.focusSelectedOrFirstAvailable = () => setTimeout(() =>
|
|
47
|
+
actionRef.current.focusSelectedOrFirstAvailable = () => setTimeout(() => {
|
|
48
|
+
(0, import_utils.focusSelectedOrFirstAvailable)(wrapperRef, allFocusableButtons, selectedButton);
|
|
49
|
+
});
|
|
48
50
|
}
|
|
49
|
-
}, [actionRef, wrapperRef]);
|
|
51
|
+
}, [actionRef, allFocusableButtons, wrapperRef]);
|
|
50
52
|
(0, import_react.useEffect)(() => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
selectedButton.current = index;
|
|
58
|
-
}
|
|
59
|
-
if (wasOpenedByKeyboardRef.current || !triggerIsInternal) {
|
|
60
|
-
(0, import_utils.focusSelectedOrFirstAvailable)(wrapperRef, allFocusableButtons, selectedButton);
|
|
61
|
-
} else {
|
|
62
|
-
wrapperRef.current?.focus();
|
|
63
|
-
}
|
|
64
|
-
});
|
|
53
|
+
wrapperRef?.current?.querySelectorAll("button").forEach((e, index) => {
|
|
54
|
+
if (!e.hasAttribute("disabled"))
|
|
55
|
+
setAllFocusableButtons((prev) => [...prev, e]);
|
|
56
|
+
if (e.getAttribute("aria-selected") === "true") {
|
|
57
|
+
selectedButton.current = index;
|
|
58
|
+
}
|
|
65
59
|
});
|
|
66
60
|
}, [wasOpenedByKeyboardRef, wrapperRef, triggerIsInternal]);
|
|
61
|
+
(0, import_react.useEffect)(() => {
|
|
62
|
+
if (wasOpenedByKeyboardRef?.current || !triggerIsInternal) {
|
|
63
|
+
(0, import_utils.focusSelectedOrFirstAvailable)(wrapperRef, allFocusableButtons, selectedButton);
|
|
64
|
+
} else {
|
|
65
|
+
wrapperRef.current?.focus();
|
|
66
|
+
}
|
|
67
|
+
}, [wasOpenedByKeyboardRef, wrapperRef, triggerIsInternal, allFocusableButtons]);
|
|
67
68
|
return { allFocusableButtons, selectedButton };
|
|
68
69
|
};
|
|
69
70
|
//# sourceMappingURL=useKeepTrackButtons.js.map
|
|
@@ -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 type { DSAppPickerT } from '../react-desc-prop-types.js';\nimport { focusSelectedOrFirstAvailable } from '../utils.js';\n\ninterface UseKeepTrackButtonsT {\n wrapperRef: React.RefObject<HTMLDivElement>;\n wasOpenedByKeyboardRef: React.MutableRefObject<boolean>;\n actionRef?: DSAppPickerT.ActionRef;\n triggerIsInternal?: boolean;\n}\n\nexport const useKeepTrackButtons = ({\n wrapperRef,\n wasOpenedByKeyboardRef,\n actionRef,\n triggerIsInternal,\n}: UseKeepTrackButtonsT) => {\n const allFocusableButtons =
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,
|
|
4
|
+
"sourcesContent": ["import type React from 'react';\nimport { useEffect, useRef, useState } from 'react';\nimport type { DSAppPickerT } from '../react-desc-prop-types.js';\nimport { focusSelectedOrFirstAvailable } from '../utils.js';\n\ninterface UseKeepTrackButtonsT {\n wrapperRef: React.RefObject<HTMLDivElement>;\n wasOpenedByKeyboardRef: React.MutableRefObject<boolean>;\n actionRef?: DSAppPickerT.ActionRef;\n triggerIsInternal?: boolean;\n}\n\nexport const useKeepTrackButtons = ({\n wrapperRef,\n wasOpenedByKeyboardRef,\n actionRef,\n triggerIsInternal,\n}: UseKeepTrackButtonsT) => {\n const [allFocusableButtons, setAllFocusableButtons] = useState<HTMLButtonElement[]>([]);\n const selectedButton = useRef<number | null>(null);\n\n useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusSelectedOrFirstAvailable = () =>\n setTimeout(() => {\n focusSelectedOrFirstAvailable(wrapperRef, allFocusableButtons, selectedButton);\n });\n }\n }, [actionRef, allFocusableButtons, wrapperRef]);\n\n useEffect(() => {\n wrapperRef?.current?.querySelectorAll('button').forEach((e, index) => {\n if (!e.hasAttribute('disabled')) setAllFocusableButtons((prev) => [...prev, e]);\n if (e.getAttribute('aria-selected') === 'true') {\n selectedButton.current = index;\n }\n });\n }, [wasOpenedByKeyboardRef, wrapperRef, triggerIsInternal]);\n\n useEffect(() => {\n if (wasOpenedByKeyboardRef?.current || !triggerIsInternal) {\n focusSelectedOrFirstAvailable(wrapperRef, allFocusableButtons, selectedButton);\n } else {\n wrapperRef.current?.focus();\n }\n }, [wasOpenedByKeyboardRef, wrapperRef, triggerIsInternal, allFocusableButtons]);\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,mBAA4C;AAE5C,mBAA8C;AASvC,MAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA4B;AAC1B,QAAM,CAAC,qBAAqB,sBAAsB,QAAI,uBAA8B,CAAC,CAAC;AACtF,QAAM,qBAAiB,qBAAsB,IAAI;AAEjD,8BAAU,MAAM;AACd,QAAI,aAAa,UAAU,SAAS;AAClC,gBAAU,QAAQ,gCAAgC,MAChD,WAAW,MAAM;AACf,wDAA8B,YAAY,qBAAqB,cAAc;AAAA,MAC/E,CAAC;AAAA,IACL;AAAA,EACF,GAAG,CAAC,WAAW,qBAAqB,UAAU,CAAC;AAE/C,8BAAU,MAAM;AACd,gBAAY,SAAS,iBAAiB,QAAQ,EAAE,QAAQ,CAAC,GAAG,UAAU;AACpE,UAAI,CAAC,EAAE,aAAa,UAAU;AAAG,+BAAuB,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC;AAC9E,UAAI,EAAE,aAAa,eAAe,MAAM,QAAQ;AAC9C,uBAAe,UAAU;AAAA,MAC3B;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,wBAAwB,YAAY,iBAAiB,CAAC;AAE1D,8BAAU,MAAM;AACd,QAAI,wBAAwB,WAAW,CAAC,mBAAmB;AACzD,sDAA8B,YAAY,qBAAqB,cAAc;AAAA,IAC/E,OAAO;AACL,iBAAW,SAAS,MAAM;AAAA,IAC5B;AAAA,EACF,GAAG,CAAC,wBAAwB,YAAY,mBAAmB,mBAAmB,CAAC;AAE/E,SAAO,EAAE,qBAAqB,eAAe;AAC/C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -61,6 +61,9 @@ const DSAppPickerPropTypes = {
|
|
|
61
61
|
onClose: import_ds_props_helpers.PropTypes.func.description("Callback function when the AppPicker closes"),
|
|
62
62
|
onKeyDown: import_ds_props_helpers.PropTypes.func.description("OnKeyDown handler callback."),
|
|
63
63
|
onClick: import_ds_props_helpers.PropTypes.func.description("Custom onClick for Trigger component."),
|
|
64
|
-
onClickOutside: import_ds_props_helpers.PropTypes.func.description("Callback event when the user clicks outside the App Picker.")
|
|
64
|
+
onClickOutside: import_ds_props_helpers.PropTypes.func.description("Callback event when the user clicks outside the App Picker."),
|
|
65
|
+
triggerRef: import_ds_props_helpers.PropTypes.oneOfType([import_ds_props_helpers.PropTypes.func, import_ds_props_helpers.PropTypes.shape({ current: import_ds_props_helpers.PropTypes.any })]).description(
|
|
66
|
+
"Ref to the trigger button."
|
|
67
|
+
)
|
|
65
68
|
};
|
|
66
69
|
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react-desc-prop-types.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport type { WeakValidationMap } from 'react';\nimport { MenuPicker } from '@elliemae/ds-icons';\nimport type { SvgIconT } from '@elliemae/ds-icons';\nimport type { GlobalAttributesT, XstyledProps } from '@elliemae/ds-props-helpers';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\n\nexport declare namespace DSAppPickerT {\n export interface AppItem {\n label: string;\n icon: React.ComponentType<{ className: string; size: string }>;\n onClick?: (e: React.MouseEvent, item: AppItem) => void | null;\n disabled?: boolean;\n id?: string;\n selected?: boolean;\n }\n\n export type ActionRef = React.MutableRefObject<{\n focusToIndex?: (index: number) => void;\n focusSelectedOrFirstAvailable?: () => void;\n focusWrapper: () => void;\n }>;\n\n export interface DefaultProps {\n apps: AppItem[];\n customApps: AppItem[];\n sectionTitle: string;\n customSectionTitle: string;\n icon: React.ComponentType<SvgIconT.Props>;\n }\n\n export interface OptionalProps {\n onClose?: () => void;\n onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;\n onClickOutside?: (e: React.MouseEvent) => void;\n onKeyDown?: (e: React.KeyboardEvent) => void;\n actionRef?: ActionRef;\n renderTrigger?: React.ComponentType<Record<string, unknown>>;\n isOpen?: boolean;\n triggerRef?: React.RefObject<HTMLButtonElement>;\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps {}\n\n export interface InternalProps\n extends DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps {}\n}\n\nexport const defaultProps: DSAppPickerT.DefaultProps = {\n apps: [],\n customApps: [],\n sectionTitle: 'APPLICATIONS',\n customSectionTitle: 'CUSTOM APPLICATIONS',\n icon: () => <MenuPicker color={['brand-primary', '700']} size=\"m\" />,\n};\n\n// =============================================================================\n// PropTypes\n// =============================================================================\n\nexport const DSAppPickerPropTypes = {\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} as WeakValidationMap<unknown>;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD4DT;AA1Dd,sBAA2B;AAG3B,8BAA0B;AAkDnB,MAAM,eAA0C;AAAA,EACrD,MAAM,CAAC;AAAA,EACP,YAAY,CAAC;AAAA,EACb,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,MAAM,MAAM,4CAAC,8BAAW,OAAO,CAAC,iBAAiB,KAAK,GAAG,MAAK,KAAI;AACpE;AAMO,MAAM,uBAAuB;AAAA,EAClC,MAAM,kCAAU,MAAM;AAAA,IACpB;AAAA,EACF,EAAE;AAAA,EACF,YAAY,kCAAU,MAAM;AAAA,IAC1B;AAAA,EACF;AAAA,EACA,cAAc,kCAAU,OAAO,YAAY,oBAAoB,EAAE,aAAa,cAAc;AAAA,EAC5F,oBAAoB,kCAAU,OAAO,YAAY,sBAAsB,EAAE,aAAa,qBAAqB;AAAA,EAC3G,MAAM,kCAAU,KAAK,YAAY,uBAAuB,EAAE,aAAa,0BAAU;AAAA,EACjF,eAAe,kCAAU,KAAK,YAAY,2BAA2B;AAAA,EACrE,WAAW,kCAAU,UAAU,CAAC,kCAAU,MAAM,kCAAU,MAAM,EAAE,SAAS,kCAAU,IAAI,CAAC,CAAC,CAAC,EAAE;AAAA,IAC5F;AAAA,EACF;AAAA,EACA,QAAQ,kCAAU,KAAK,YAAY,6CAA6C;AAAA,EAChF,SAAS,kCAAU,KAAK,YAAY,6CAA6C;AAAA,EACjF,WAAW,kCAAU,KAAK,YAAY,6BAA6B;AAAA,EACnE,SAAS,kCAAU,KAAK,YAAY,uCAAuC;AAAA,EAC3E,gBAAgB,kCAAU,KAAK,YAAY,6DAA6D;
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport type { WeakValidationMap } from 'react';\nimport { MenuPicker } from '@elliemae/ds-icons';\nimport type { SvgIconT } from '@elliemae/ds-icons';\nimport type { GlobalAttributesT, XstyledProps } from '@elliemae/ds-props-helpers';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\n\nexport declare namespace DSAppPickerT {\n export interface AppItem {\n label: string;\n icon: React.ComponentType<{ className: string; size: string }>;\n onClick?: (e: React.MouseEvent, item: AppItem) => void | null;\n disabled?: boolean;\n id?: string;\n selected?: boolean;\n }\n\n export type ActionRef = React.MutableRefObject<{\n focusToIndex?: (index: number) => void;\n focusSelectedOrFirstAvailable?: () => void;\n focusWrapper: () => void;\n }>;\n\n export interface DefaultProps {\n apps: AppItem[];\n customApps: AppItem[];\n sectionTitle: string;\n customSectionTitle: string;\n icon: React.ComponentType<SvgIconT.Props>;\n }\n\n export interface OptionalProps {\n onClose?: () => void;\n onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;\n onClickOutside?: (e: React.MouseEvent) => void;\n onKeyDown?: (e: React.KeyboardEvent) => void;\n actionRef?: ActionRef;\n renderTrigger?: React.ComponentType<Record<string, unknown>>;\n isOpen?: boolean;\n triggerRef?: React.RefObject<HTMLButtonElement>;\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps {}\n\n export interface InternalProps\n extends DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps {}\n}\n\nexport const defaultProps: DSAppPickerT.DefaultProps = {\n apps: [],\n customApps: [],\n sectionTitle: 'APPLICATIONS',\n customSectionTitle: 'CUSTOM APPLICATIONS',\n icon: () => <MenuPicker color={['brand-primary', '700']} size=\"m\" />,\n};\n\n// =============================================================================\n// PropTypes\n// =============================================================================\n\nexport const DSAppPickerPropTypes = {\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 triggerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description(\n 'Ref to the trigger button.',\n ),\n} as WeakValidationMap<unknown>;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD4DT;AA1Dd,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Ref, selec
|
|
|
49
49
|
if (selectedButtonRef.current !== null) {
|
|
50
50
|
wrapperRef?.current?.querySelectorAll("button")[selectedButtonRef.current].focus();
|
|
51
51
|
} else {
|
|
52
|
-
allFocusableButtonsRef?.
|
|
52
|
+
allFocusableButtonsRef?.[0]?.focus();
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
//# sourceMappingURL=utils.js.map
|
package/dist/cjs/utils.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import type React from 'react';\n\nexport const keys = {\n LEFT: 'ArrowLeft',\n UP: 'ArrowUp',\n RIGHT: 'ArrowRight',\n DOWN: 'ArrowDown',\n ENTER: 'Enter',\n SPACE: '',\n TAB: 'Tab',\n ESC: 'Escape',\n HOME: 'Home',\n END: 'End',\n};\n\nexport const focusSelectedOrFirstAvailable = (\n wrapperRef: React.RefObject<HTMLDivElement>,\n allFocusableButtonsRef:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEhB,MAAM,OAAO;AAAA,EAClB,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AACP;AAEO,MAAM,gCAAgC,CAC3C,YACA,wBACA,sBACG;AACH,MAAI,kBAAkB,YAAY,MAAM;AACtC,gBAAY,SAAS,iBAAiB,QAAQ,EAAE,kBAAkB,OAAO,EAAE,MAAM;AAAA,EACnF,OAAO;AACL,
|
|
4
|
+
"sourcesContent": ["import type React from 'react';\n\nexport const keys = {\n LEFT: 'ArrowLeft',\n UP: 'ArrowUp',\n RIGHT: 'ArrowRight',\n DOWN: 'ArrowDown',\n ENTER: 'Enter',\n SPACE: '',\n TAB: 'Tab',\n ESC: 'Escape',\n HOME: 'Home',\n END: 'End',\n};\n\nexport const focusSelectedOrFirstAvailable = (\n wrapperRef: React.RefObject<HTMLDivElement>,\n allFocusableButtonsRef: HTMLButtonElement[],\n selectedButtonRef: React.MutableRefObject<number | null>,\n) => {\n if (selectedButtonRef.current !== null) {\n wrapperRef?.current?.querySelectorAll('button')[selectedButtonRef.current].focus();\n } else {\n allFocusableButtonsRef?.[0]?.focus();\n }\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEhB,MAAM,OAAO;AAAA,EAClB,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AACP;AAEO,MAAM,gCAAgC,CAC3C,YACA,wBACA,sBACG;AACH,MAAI,kBAAkB,YAAY,MAAM;AACtC,gBAAY,SAAS,iBAAiB,QAAQ,EAAE,kBAAkB,OAAO,EAAE,MAAM;AAAA,EACnF,OAAO;AACL,6BAAyB,CAAC,GAAG,MAAM;AAAA,EACrC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useCallback, useMemo } from "react";
|
|
3
|
+
import { useCallback, useRef, useMemo } from "react";
|
|
4
4
|
import { DSChip } from "@elliemae/ds-chip";
|
|
5
5
|
import { keys } from "./utils.js";
|
|
6
6
|
import { StyledWrapper, StyledSeparator, StyledListItemFullRow, StyledListItem, StyledTitle } from "./styles.js";
|
|
7
7
|
import { useKeepTrackButtons } from "./hooks/useKeepTrackButtons.js";
|
|
8
8
|
import { DSAppPickerDataTestIds } from "./DSAppPickerDefinitions.js";
|
|
9
|
+
import { useFocusTrap } from "@elliemae/ds-utilities";
|
|
9
10
|
const AppPickerImpl = ({
|
|
10
11
|
apps,
|
|
11
12
|
customApps,
|
|
@@ -26,30 +27,8 @@ const AppPickerImpl = ({
|
|
|
26
27
|
actionRef,
|
|
27
28
|
triggerIsInternal
|
|
28
29
|
});
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
switch (e.key) {
|
|
32
|
-
case keys.ESC:
|
|
33
|
-
triggerRef?.current?.focus();
|
|
34
|
-
close();
|
|
35
|
-
break;
|
|
36
|
-
case keys.TAB:
|
|
37
|
-
if (e.shiftKey) {
|
|
38
|
-
if (e.target === allFocusableButtons.current[0]) {
|
|
39
|
-
e.preventDefault();
|
|
40
|
-
allFocusableButtons?.current[allFocusableButtons.current.length - 1]?.focus();
|
|
41
|
-
}
|
|
42
|
-
} else if (e.target === allFocusableButtons.current[allFocusableButtons.current.length - 1]) {
|
|
43
|
-
e.preventDefault();
|
|
44
|
-
allFocusableButtons?.current[0]?.focus();
|
|
45
|
-
}
|
|
46
|
-
break;
|
|
47
|
-
default:
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
[allFocusableButtons, close, triggerRef]
|
|
52
|
-
);
|
|
30
|
+
const firstElementRef = useRef(null);
|
|
31
|
+
const lastElementRef = useRef(null);
|
|
53
32
|
const handleOnClick = useCallback(
|
|
54
33
|
(app) => (e) => {
|
|
55
34
|
if (app.onClick)
|
|
@@ -62,11 +41,19 @@ const AppPickerImpl = ({
|
|
|
62
41
|
if (onKeyDown)
|
|
63
42
|
onKeyDown(e);
|
|
64
43
|
if (!onKeyDown && e.key === keys.ESC) {
|
|
44
|
+
triggerRef?.current?.focus();
|
|
65
45
|
close();
|
|
66
46
|
}
|
|
67
47
|
},
|
|
68
|
-
[onKeyDown, close]
|
|
48
|
+
[onKeyDown, triggerRef, close]
|
|
69
49
|
);
|
|
50
|
+
firstElementRef.current = allFocusableButtons[0];
|
|
51
|
+
lastElementRef.current = allFocusableButtons[allFocusableButtons.length - 1];
|
|
52
|
+
const handleOnKeyDown = useFocusTrap({
|
|
53
|
+
firstElementRef,
|
|
54
|
+
lastElementRef,
|
|
55
|
+
onKeyDown: handleOnKeyDownWrapper
|
|
56
|
+
});
|
|
70
57
|
const totalAppsLength = useMemo(() => apps.length + customApps.length, [apps.length, customApps.length]);
|
|
71
58
|
const buildRows = useCallback(
|
|
72
59
|
(appList, prevIndex, title) => /* @__PURE__ */ jsx(Fragment, { children: appList.map((app, index) => {
|
|
@@ -76,7 +63,6 @@ const AppPickerImpl = ({
|
|
|
76
63
|
DSChip,
|
|
77
64
|
{
|
|
78
65
|
onClick: handleOnClick(app),
|
|
79
|
-
onKeyDown: handleKeyDown,
|
|
80
66
|
"data-testid": DSAppPickerDataTestIds.CHIP,
|
|
81
67
|
"aria-disabled": disabled,
|
|
82
68
|
disabled,
|
|
@@ -91,7 +77,7 @@ const AppPickerImpl = ({
|
|
|
91
77
|
index
|
|
92
78
|
) });
|
|
93
79
|
}) }),
|
|
94
|
-
[
|
|
80
|
+
[handleOnClick, totalAppsLength]
|
|
95
81
|
);
|
|
96
82
|
const AppsRows = useMemo(() => buildRows(apps, 1, sectionTitle), [apps, buildRows, sectionTitle]);
|
|
97
83
|
const CustomRows = useMemo(
|
|
@@ -123,7 +109,7 @@ const AppPickerImpl = ({
|
|
|
123
109
|
forwardedAs: "ul",
|
|
124
110
|
role: "listbox",
|
|
125
111
|
ref: convertedTypeReference,
|
|
126
|
-
onKeyDown:
|
|
112
|
+
onKeyDown: handleOnKeyDown,
|
|
127
113
|
"data-testid": DSAppPickerDataTestIds.WRAPPER,
|
|
128
114
|
isOverflow,
|
|
129
115
|
cols: layout.cols,
|
|
@@ -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 max-lines */\n/* eslint-disable react/no-array-index-key */\nimport React, { useCallback, useMemo } from 'react';\nimport { DSChip } from '@elliemae/ds-chip';\nimport { keys } from './utils.js';\nimport { StyledWrapper, StyledSeparator, StyledListItemFullRow, StyledListItem, StyledTitle } from './styles.js';\nimport { useKeepTrackButtons } from './hooks/useKeepTrackButtons.js';\nimport type { DSAppPickerT } from './react-desc-prop-types.js';\nimport { DSAppPickerDataTestIds } from './DSAppPickerDefinitions.js';\n\ninterface AppPickerImplProps\n extends Omit<\n DSAppPickerT.InternalProps,\n 'onClose' | 'icon' | 'onClick' | 'onClickOutside' | 'renderTrigger' | 'isOpen'\n > {\n close: () => void;\n wrapperRef: React.RefObject<HTMLDivElement>;\n isOverflow: boolean;\n wasOpenedByKeyboardRef: React.MutableRefObject<boolean>;\n triggerIsInternal: boolean;\n}\n\nconst AppPickerImpl: React.ComponentType<AppPickerImplProps> = ({\n apps,\n customApps,\n sectionTitle,\n customSectionTitle,\n close,\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
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable react/no-array-index-key */\nimport React, { useCallback, useRef, useMemo } from 'react';\nimport { DSChip } from '@elliemae/ds-chip';\nimport { keys } from './utils.js';\nimport { StyledWrapper, StyledSeparator, StyledListItemFullRow, StyledListItem, StyledTitle } from './styles.js';\nimport { useKeepTrackButtons } from './hooks/useKeepTrackButtons.js';\nimport type { DSAppPickerT } from './react-desc-prop-types.js';\nimport { DSAppPickerDataTestIds } from './DSAppPickerDefinitions.js';\nimport { useFocusTrap } from '@elliemae/ds-utilities';\n\ninterface AppPickerImplProps\n extends Omit<\n DSAppPickerT.InternalProps,\n 'onClose' | 'icon' | 'onClick' | 'onClickOutside' | 'renderTrigger' | 'isOpen'\n > {\n close: () => void;\n wrapperRef: React.RefObject<HTMLDivElement>;\n isOverflow: boolean;\n wasOpenedByKeyboardRef: React.MutableRefObject<boolean>;\n triggerIsInternal: boolean;\n}\n\nconst AppPickerImpl: React.ComponentType<AppPickerImplProps> = ({\n apps,\n customApps,\n sectionTitle,\n customSectionTitle,\n close,\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 const firstElementRef = useRef<HTMLElement | null>(null);\n const lastElementRef = useRef<HTMLElement | null>(null);\n\n const handleOnClick = useCallback(\n (app: DSAppPickerT.AppItem) => (e: React.MouseEvent) => {\n if (app.onClick) app.onClick(e, app);\n },\n [],\n );\n\n const handleOnKeyDownWrapper: React.KeyboardEventHandler = useCallback(\n (e) => {\n if (onKeyDown) onKeyDown(e);\n if (!onKeyDown && e.key === keys.ESC) {\n triggerRef?.current?.focus();\n close();\n }\n },\n [onKeyDown, triggerRef, close],\n );\n firstElementRef.current = allFocusableButtons[0];\n lastElementRef.current = allFocusableButtons[allFocusableButtons.length - 1];\n\n const handleOnKeyDown = useFocusTrap({\n firstElementRef,\n lastElementRef,\n onKeyDown: handleOnKeyDownWrapper,\n });\n\n const totalAppsLength = useMemo(() => apps.length + customApps.length, [apps.length, customApps.length]);\n\n const buildRows = useCallback(\n (appList: DSAppPickerT.AppItem[], 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 data-testid={DSAppPickerDataTestIds.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 [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={handleOnKeyDown}\n data-testid={DSAppPickerDataTestIds.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={DSAppPickerDataTestIds.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={DSAppPickerDataTestIds.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;AC6EjB,mBAK2B,KA6EzB,YAlFF;AA3EN,SAAgB,aAAa,QAAQ,eAAe;AACpD,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,eAAe,iBAAiB,uBAAuB,gBAAgB,mBAAmB;AACnG,SAAS,2BAA2B;AAEpC,SAAS,8BAA8B;AACvC,SAAS,oBAAoB;AAc7B,MAAM,gBAAyD,CAAC;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,oBAAoB,IAAI,oBAAoB;AAAA,IAClD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,kBAAkB,OAA2B,IAAI;AACvD,QAAM,iBAAiB,OAA2B,IAAI;AAEtD,QAAM,gBAAgB;AAAA,IACpB,CAAC,QAA8B,CAAC,MAAwB;AACtD,UAAI,IAAI;AAAS,YAAI,QAAQ,GAAG,GAAG;AAAA,IACrC;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,yBAAqD;AAAA,IACzD,CAAC,MAAM;AACL,UAAI;AAAW,kBAAU,CAAC;AAC1B,UAAI,CAAC,aAAa,EAAE,QAAQ,KAAK,KAAK;AACpC,oBAAY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|
1
1
|
import * as React from "react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useEffect, useRef, useCallback } from "react";
|
|
3
|
+
import { useState, useEffect, useMemo, useRef, useCallback } from "react";
|
|
4
4
|
import { DSButtonV2 } from "@elliemae/ds-button-v2";
|
|
5
5
|
import { mergeRefs } from "@elliemae/ds-utilities";
|
|
6
6
|
import { describe, useMemoMergePropsWithDefault } from "@elliemae/ds-props-helpers";
|
|
@@ -94,24 +94,27 @@ const DSAppPicker = (props) => {
|
|
|
94
94
|
triggerRef
|
|
95
95
|
]
|
|
96
96
|
);
|
|
97
|
-
const RenderTrigger =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
97
|
+
const RenderTrigger = useMemo(
|
|
98
|
+
() => renderTrigger || (({ ref }) => /* @__PURE__ */ jsx(
|
|
99
|
+
DSButtonV2,
|
|
100
|
+
{
|
|
101
|
+
"data-testid": DSAppPickerDataTestIds.TRIGGER,
|
|
102
|
+
id: "app-picker__button",
|
|
103
|
+
buttonType: "icon",
|
|
104
|
+
"aria-haspopup": "true",
|
|
105
|
+
"aria-expanded": isOpen ?? open,
|
|
106
|
+
"aria-label": "Application picker",
|
|
107
|
+
innerRef: mergeRefs(ref, triggerRef || defaultTriggerRef),
|
|
108
|
+
onClick: (e) => {
|
|
109
|
+
wasOpenedByKeyboardRef.current = e.detail === 0;
|
|
110
|
+
onClick?.(e);
|
|
111
|
+
setOpen(true);
|
|
112
|
+
},
|
|
113
|
+
children: /* @__PURE__ */ jsx(Icon, {})
|
|
114
|
+
}
|
|
115
|
+
)),
|
|
116
|
+
[Icon, isOpen, onClick, open, renderTrigger, triggerRef]
|
|
117
|
+
);
|
|
115
118
|
return /* @__PURE__ */ jsx(
|
|
116
119
|
DSPopover,
|
|
117
120
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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, useCallback } from 'react';\nimport { DSButtonV2 } from '@elliemae/ds-button-v2';\nimport { mergeRefs } from '@elliemae/ds-utilities';\nimport { describe, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport DSPopover from '@elliemae/ds-popover';\nimport AppPickerImpl from './AppPickerImpl.js';\nimport type { DSAppPickerT } from './react-desc-prop-types.js';\nimport { DSAppPickerPropTypes, defaultProps } from './react-desc-prop-types.js';\nimport { DSAppPickerDataTestIds, DSAppPickerName } from './DSAppPickerDefinitions.js';\n\nconst DSAppPicker: React.ComponentType<DSAppPickerT.Props> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSAppPickerT.InternalProps>(props, defaultProps);\n\n const {\n apps,\n customApps,\n sectionTitle,\n customSectionTitle,\n icon: Icon,\n renderTrigger,\n isOpen,\n onClose,\n actionRef,\n onKeyDown,\n onClick,\n onClickOutside,\n triggerRef,\n } = propsWithDefault;\n\n const [open, setOpen] = useState(false);\n const [isOverflow, setIsOverflow] = useState(false);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const defaultTriggerRef = useRef(null);\n const wasOpenedByKeyboardRef = useRef(false);\n\n useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusToIndex = (index: number) => {\n if (wrapperRef.current) {\n const parent = wrapperRef.current;\n const buttons = [...parent.querySelectorAll('button')];\n buttons[index].focus();\n }\n };\n actionRef.current.focusWrapper = () => {\n wrapperRef.current?.focus();\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 = useCallback(() => {\n setOpen(false);\n onClose?.();\n }, [onClose]);\n\n const handleOnClickOutside = (e: React.MouseEvent) => {\n setOpen(false);\n onClose?.();\n onClickOutside?.(e);\n };\n\n const AppPickerContent = useCallback(\n () => (\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 actionRef={actionRef}\n triggerIsInternal={!renderTrigger}\n wasOpenedByKeyboardRef={wasOpenedByKeyboardRef}\n isOverflow={isOverflow}\n />\n ),\n [\n actionRef,\n apps,\n customApps,\n customSectionTitle,\n handleOnClose,\n isOverflow,\n onKeyDown,\n renderTrigger,\n sectionTitle,\n triggerRef,\n ],\n );\n\n const RenderTrigger
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACyEjB;AAzEN,SAAgB,UAAU,WAAW,QAAQ,mBAAmB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useEffect, useMemo, useRef, useCallback } from 'react';\nimport { DSButtonV2 } from '@elliemae/ds-button-v2';\nimport { mergeRefs } from '@elliemae/ds-utilities';\nimport { describe, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport DSPopover from '@elliemae/ds-popover';\nimport AppPickerImpl from './AppPickerImpl.js';\nimport type { DSAppPickerT } from './react-desc-prop-types.js';\nimport { DSAppPickerPropTypes, defaultProps } from './react-desc-prop-types.js';\nimport { DSAppPickerDataTestIds, DSAppPickerName } from './DSAppPickerDefinitions.js';\n\nconst DSAppPicker: React.ComponentType<DSAppPickerT.Props> = (props) => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSAppPickerT.InternalProps>(props, defaultProps);\n\n const {\n apps,\n customApps,\n sectionTitle,\n customSectionTitle,\n icon: Icon,\n renderTrigger,\n isOpen,\n onClose,\n actionRef,\n onKeyDown,\n onClick,\n onClickOutside,\n triggerRef,\n } = propsWithDefault;\n\n const [open, setOpen] = useState(false);\n const [isOverflow, setIsOverflow] = useState(false);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const defaultTriggerRef = useRef(null);\n const wasOpenedByKeyboardRef = useRef(false);\n\n useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusToIndex = (index: number) => {\n if (wrapperRef.current) {\n const parent = wrapperRef.current;\n const buttons = [...parent.querySelectorAll('button')];\n buttons[index].focus();\n }\n };\n actionRef.current.focusWrapper = () => {\n wrapperRef.current?.focus();\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 = useCallback(() => {\n setOpen(false);\n onClose?.();\n }, [onClose]);\n\n const handleOnClickOutside = (e: React.MouseEvent) => {\n setOpen(false);\n onClose?.();\n onClickOutside?.(e);\n };\n\n const AppPickerContent = useCallback(\n () => (\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 actionRef={actionRef}\n triggerIsInternal={!renderTrigger}\n wasOpenedByKeyboardRef={wasOpenedByKeyboardRef}\n isOverflow={isOverflow}\n />\n ),\n [\n actionRef,\n apps,\n customApps,\n customSectionTitle,\n handleOnClose,\n isOverflow,\n onKeyDown,\n renderTrigger,\n sectionTitle,\n triggerRef,\n ],\n );\n\n const RenderTrigger = useMemo(\n () =>\n renderTrigger ||\n (({ ref }: { ref: React.RefObject<HTMLButtonElement> }) => (\n <DSButtonV2\n data-testid={DSAppPickerDataTestIds.TRIGGER}\n id=\"app-picker__button\"\n buttonType=\"icon\"\n aria-haspopup=\"true\"\n aria-expanded={isOpen ?? open}\n aria-label=\"Application picker\"\n innerRef={mergeRefs(ref, triggerRef || defaultTriggerRef)}\n onClick={(e: React.MouseEvent | React.KeyboardEvent) => {\n wasOpenedByKeyboardRef.current = e.detail === 0;\n onClick?.(e);\n setOpen(true);\n }}\n >\n <Icon />\n </DSButtonV2>\n )),\n [Icon, isOpen, onClick, open, renderTrigger, triggerRef],\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.displayName = DSAppPickerName;\nconst AppPickerWithSchema = describe(DSAppPicker);\nAppPickerWithSchema.propTypes = DSAppPickerPropTypes;\n\nexport { DSAppPicker, AppPickerWithSchema };\nexport default DSAppPicker;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACyEjB;AAzEN,SAAgB,UAAU,WAAW,SAAS,QAAQ,mBAAmB;AACzE,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,UAAU,oCAAoC;AACvD,OAAO,eAAe;AACtB,OAAO,mBAAmB;AAE1B,SAAS,sBAAsB,oBAAoB;AACnD,SAAS,wBAAwB,uBAAuB;AAExD,MAAM,cAAuD,CAAC,UAAU;AACtE,QAAM,mBAAmB,6BAAyD,OAAO,YAAY;AAErG,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,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;AAAA,IACF;AAAA,IAEF;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,gBAAgB;AAAA,IACpB,MACE,kBACC,CAAC,EAAE,IAAI,MACN;AAAA,MAAC;AAAA;AAAA,QACC,eAAa,uBAAuB;AAAA,QACpC,IAAG;AAAA,QACH,YAAW;AAAA,QACX,iBAAc;AAAA,QACd,iBAAe,UAAU;AAAA,QACzB,cAAW;AAAA,QACX,UAAU,UAAU,KAAK,cAAc,iBAAiB;AAAA,QACxD,SAAS,CAAC,MAA8C;AACtD,iCAAuB,UAAU,EAAE,WAAW;AAC9C,oBAAU,CAAC;AACX,kBAAQ,IAAI;AAAA,QACd;AAAA,QAEA,8BAAC,QAAK;AAAA;AAAA,IACR;AAAA,IAEJ,CAAC,MAAM,QAAQ,SAAS,MAAM,eAAe,UAAU;AAAA,EACzD;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS,oBAAC,oBAAiB;AAAA,MAC3B,QAAQ,OAAO,WAAW,YAAY,SAAS;AAAA,MAC/C,gBAAgB;AAAA,MAChB,WAAU;AAAA,MACV,iBAAgB;AAAA,MAChB,eAAe;AAAA,MACf,WAAS;AAAA,MACT,OAAO;AAAA,QACL,SAAS;AAAA,QACT,UAAU;AAAA,QACV,OAAO;AAAA,MACT;AAAA;AAAA,EACF;AAEJ;AAEA,YAAY,cAAc;AAC1B,MAAM,sBAAsB,SAAS,WAAW;AAChD,oBAAoB,YAAY;AAGhC,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { focusSelectedOrFirstAvailable } from "../utils.js";
|
|
4
4
|
const useKeepTrackButtons = ({
|
|
5
5
|
wrapperRef,
|
|
@@ -7,30 +7,31 @@ const useKeepTrackButtons = ({
|
|
|
7
7
|
actionRef,
|
|
8
8
|
triggerIsInternal
|
|
9
9
|
}) => {
|
|
10
|
-
const allFocusableButtons =
|
|
10
|
+
const [allFocusableButtons, setAllFocusableButtons] = useState([]);
|
|
11
11
|
const selectedButton = useRef(null);
|
|
12
12
|
useEffect(() => {
|
|
13
13
|
if (actionRef && actionRef.current) {
|
|
14
|
-
actionRef.current.focusSelectedOrFirstAvailable = () => setTimeout(() =>
|
|
14
|
+
actionRef.current.focusSelectedOrFirstAvailable = () => setTimeout(() => {
|
|
15
|
+
focusSelectedOrFirstAvailable(wrapperRef, allFocusableButtons, selectedButton);
|
|
16
|
+
});
|
|
15
17
|
}
|
|
16
|
-
}, [actionRef, wrapperRef]);
|
|
18
|
+
}, [actionRef, allFocusableButtons, wrapperRef]);
|
|
17
19
|
useEffect(() => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
selectedButton.current = index;
|
|
25
|
-
}
|
|
26
|
-
if (wasOpenedByKeyboardRef.current || !triggerIsInternal) {
|
|
27
|
-
focusSelectedOrFirstAvailable(wrapperRef, allFocusableButtons, selectedButton);
|
|
28
|
-
} else {
|
|
29
|
-
wrapperRef.current?.focus();
|
|
30
|
-
}
|
|
31
|
-
});
|
|
20
|
+
wrapperRef?.current?.querySelectorAll("button").forEach((e, index) => {
|
|
21
|
+
if (!e.hasAttribute("disabled"))
|
|
22
|
+
setAllFocusableButtons((prev) => [...prev, e]);
|
|
23
|
+
if (e.getAttribute("aria-selected") === "true") {
|
|
24
|
+
selectedButton.current = index;
|
|
25
|
+
}
|
|
32
26
|
});
|
|
33
27
|
}, [wasOpenedByKeyboardRef, wrapperRef, triggerIsInternal]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (wasOpenedByKeyboardRef?.current || !triggerIsInternal) {
|
|
30
|
+
focusSelectedOrFirstAvailable(wrapperRef, allFocusableButtons, selectedButton);
|
|
31
|
+
} else {
|
|
32
|
+
wrapperRef.current?.focus();
|
|
33
|
+
}
|
|
34
|
+
}, [wasOpenedByKeyboardRef, wrapperRef, triggerIsInternal, allFocusableButtons]);
|
|
34
35
|
return { allFocusableButtons, selectedButton };
|
|
35
36
|
};
|
|
36
37
|
export {
|
|
@@ -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 type { DSAppPickerT } from '../react-desc-prop-types.js';\nimport { focusSelectedOrFirstAvailable } from '../utils.js';\n\ninterface UseKeepTrackButtonsT {\n wrapperRef: React.RefObject<HTMLDivElement>;\n wasOpenedByKeyboardRef: React.MutableRefObject<boolean>;\n actionRef?: DSAppPickerT.ActionRef;\n triggerIsInternal?: boolean;\n}\n\nexport const useKeepTrackButtons = ({\n wrapperRef,\n wasOpenedByKeyboardRef,\n actionRef,\n triggerIsInternal,\n}: UseKeepTrackButtonsT) => {\n const allFocusableButtons =
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,WAAW,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type React from 'react';\nimport { useEffect, useRef, useState } from 'react';\nimport type { DSAppPickerT } from '../react-desc-prop-types.js';\nimport { focusSelectedOrFirstAvailable } from '../utils.js';\n\ninterface UseKeepTrackButtonsT {\n wrapperRef: React.RefObject<HTMLDivElement>;\n wasOpenedByKeyboardRef: React.MutableRefObject<boolean>;\n actionRef?: DSAppPickerT.ActionRef;\n triggerIsInternal?: boolean;\n}\n\nexport const useKeepTrackButtons = ({\n wrapperRef,\n wasOpenedByKeyboardRef,\n actionRef,\n triggerIsInternal,\n}: UseKeepTrackButtonsT) => {\n const [allFocusableButtons, setAllFocusableButtons] = useState<HTMLButtonElement[]>([]);\n const selectedButton = useRef<number | null>(null);\n\n useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.focusSelectedOrFirstAvailable = () =>\n setTimeout(() => {\n focusSelectedOrFirstAvailable(wrapperRef, allFocusableButtons, selectedButton);\n });\n }\n }, [actionRef, allFocusableButtons, wrapperRef]);\n\n useEffect(() => {\n wrapperRef?.current?.querySelectorAll('button').forEach((e, index) => {\n if (!e.hasAttribute('disabled')) setAllFocusableButtons((prev) => [...prev, e]);\n if (e.getAttribute('aria-selected') === 'true') {\n selectedButton.current = index;\n }\n });\n }, [wasOpenedByKeyboardRef, wrapperRef, triggerIsInternal]);\n\n useEffect(() => {\n if (wasOpenedByKeyboardRef?.current || !triggerIsInternal) {\n focusSelectedOrFirstAvailable(wrapperRef, allFocusableButtons, selectedButton);\n } else {\n wrapperRef.current?.focus();\n }\n }, [wasOpenedByKeyboardRef, wrapperRef, triggerIsInternal, allFocusableButtons]);\n\n return { allFocusableButtons, selectedButton };\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,WAAW,QAAQ,gBAAgB;AAE5C,SAAS,qCAAqC;AASvC,MAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA4B;AAC1B,QAAM,CAAC,qBAAqB,sBAAsB,IAAI,SAA8B,CAAC,CAAC;AACtF,QAAM,iBAAiB,OAAsB,IAAI;AAEjD,YAAU,MAAM;AACd,QAAI,aAAa,UAAU,SAAS;AAClC,gBAAU,QAAQ,gCAAgC,MAChD,WAAW,MAAM;AACf,sCAA8B,YAAY,qBAAqB,cAAc;AAAA,MAC/E,CAAC;AAAA,IACL;AAAA,EACF,GAAG,CAAC,WAAW,qBAAqB,UAAU,CAAC;AAE/C,YAAU,MAAM;AACd,gBAAY,SAAS,iBAAiB,QAAQ,EAAE,QAAQ,CAAC,GAAG,UAAU;AACpE,UAAI,CAAC,EAAE,aAAa,UAAU;AAAG,+BAAuB,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC;AAC9E,UAAI,EAAE,aAAa,eAAe,MAAM,QAAQ;AAC9C,uBAAe,UAAU;AAAA,MAC3B;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,wBAAwB,YAAY,iBAAiB,CAAC;AAE1D,YAAU,MAAM;AACd,QAAI,wBAAwB,WAAW,CAAC,mBAAmB;AACzD,oCAA8B,YAAY,qBAAqB,cAAc;AAAA,IAC/E,OAAO;AACL,iBAAW,SAAS,MAAM;AAAA,IAC5B;AAAA,EACF,GAAG,CAAC,wBAAwB,YAAY,mBAAmB,mBAAmB,CAAC;AAE/E,SAAO,EAAE,qBAAqB,eAAe;AAC/C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,7 +27,10 @@ const DSAppPickerPropTypes = {
|
|
|
27
27
|
onClose: PropTypes.func.description("Callback function when the AppPicker closes"),
|
|
28
28
|
onKeyDown: PropTypes.func.description("OnKeyDown handler callback."),
|
|
29
29
|
onClick: PropTypes.func.description("Custom onClick for Trigger component."),
|
|
30
|
-
onClickOutside: PropTypes.func.description("Callback event when the user clicks outside the App Picker.")
|
|
30
|
+
onClickOutside: PropTypes.func.description("Callback event when the user clicks outside the App Picker."),
|
|
31
|
+
triggerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description(
|
|
32
|
+
"Ref to the trigger button."
|
|
33
|
+
)
|
|
31
34
|
};
|
|
32
35
|
export {
|
|
33
36
|
DSAppPickerPropTypes,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport type { WeakValidationMap } from 'react';\nimport { MenuPicker } from '@elliemae/ds-icons';\nimport type { SvgIconT } from '@elliemae/ds-icons';\nimport type { GlobalAttributesT, XstyledProps } from '@elliemae/ds-props-helpers';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\n\nexport declare namespace DSAppPickerT {\n export interface AppItem {\n label: string;\n icon: React.ComponentType<{ className: string; size: string }>;\n onClick?: (e: React.MouseEvent, item: AppItem) => void | null;\n disabled?: boolean;\n id?: string;\n selected?: boolean;\n }\n\n export type ActionRef = React.MutableRefObject<{\n focusToIndex?: (index: number) => void;\n focusSelectedOrFirstAvailable?: () => void;\n focusWrapper: () => void;\n }>;\n\n export interface DefaultProps {\n apps: AppItem[];\n customApps: AppItem[];\n sectionTitle: string;\n customSectionTitle: string;\n icon: React.ComponentType<SvgIconT.Props>;\n }\n\n export interface OptionalProps {\n onClose?: () => void;\n onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;\n onClickOutside?: (e: React.MouseEvent) => void;\n onKeyDown?: (e: React.KeyboardEvent) => void;\n actionRef?: ActionRef;\n renderTrigger?: React.ComponentType<Record<string, unknown>>;\n isOpen?: boolean;\n triggerRef?: React.RefObject<HTMLButtonElement>;\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps {}\n\n export interface InternalProps\n extends DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps {}\n}\n\nexport const defaultProps: DSAppPickerT.DefaultProps = {\n apps: [],\n customApps: [],\n sectionTitle: 'APPLICATIONS',\n customSectionTitle: 'CUSTOM APPLICATIONS',\n icon: () => <MenuPicker color={['brand-primary', '700']} size=\"m\" />,\n};\n\n// =============================================================================\n// PropTypes\n// =============================================================================\n\nexport const DSAppPickerPropTypes = {\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} as WeakValidationMap<unknown>;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;AC4DT;AA1Dd,SAAS,kBAAkB;AAG3B,SAAS,iBAAiB;AAkDnB,MAAM,eAA0C;AAAA,EACrD,MAAM,CAAC;AAAA,EACP,YAAY,CAAC;AAAA,EACb,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,MAAM,MAAM,oBAAC,cAAW,OAAO,CAAC,iBAAiB,KAAK,GAAG,MAAK,KAAI;AACpE;AAMO,MAAM,uBAAuB;AAAA,EAClC,MAAM,UAAU,MAAM;AAAA,IACpB;AAAA,EACF,EAAE;AAAA,EACF,YAAY,UAAU,MAAM;AAAA,IAC1B;AAAA,EACF;AAAA,EACA,cAAc,UAAU,OAAO,YAAY,oBAAoB,EAAE,aAAa,cAAc;AAAA,EAC5F,oBAAoB,UAAU,OAAO,YAAY,sBAAsB,EAAE,aAAa,qBAAqB;AAAA,EAC3G,MAAM,UAAU,KAAK,YAAY,uBAAuB,EAAE,aAAa,UAAU;AAAA,EACjF,eAAe,UAAU,KAAK,YAAY,2BAA2B;AAAA,EACrE,WAAW,UAAU,UAAU,CAAC,UAAU,MAAM,UAAU,MAAM,EAAE,SAAS,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE;AAAA,IAC5F;AAAA,EACF;AAAA,EACA,QAAQ,UAAU,KAAK,YAAY,6CAA6C;AAAA,EAChF,SAAS,UAAU,KAAK,YAAY,6CAA6C;AAAA,EACjF,WAAW,UAAU,KAAK,YAAY,6BAA6B;AAAA,EACnE,SAAS,UAAU,KAAK,YAAY,uCAAuC;AAAA,EAC3E,gBAAgB,UAAU,KAAK,YAAY,6DAA6D;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport type { WeakValidationMap } from 'react';\nimport { MenuPicker } from '@elliemae/ds-icons';\nimport type { SvgIconT } from '@elliemae/ds-icons';\nimport type { GlobalAttributesT, XstyledProps } from '@elliemae/ds-props-helpers';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\n\nexport declare namespace DSAppPickerT {\n export interface AppItem {\n label: string;\n icon: React.ComponentType<{ className: string; size: string }>;\n onClick?: (e: React.MouseEvent, item: AppItem) => void | null;\n disabled?: boolean;\n id?: string;\n selected?: boolean;\n }\n\n export type ActionRef = React.MutableRefObject<{\n focusToIndex?: (index: number) => void;\n focusSelectedOrFirstAvailable?: () => void;\n focusWrapper: () => void;\n }>;\n\n export interface DefaultProps {\n apps: AppItem[];\n customApps: AppItem[];\n sectionTitle: string;\n customSectionTitle: string;\n icon: React.ComponentType<SvgIconT.Props>;\n }\n\n export interface OptionalProps {\n onClose?: () => void;\n onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;\n onClickOutside?: (e: React.MouseEvent) => void;\n onKeyDown?: (e: React.KeyboardEvent) => void;\n actionRef?: ActionRef;\n renderTrigger?: React.ComponentType<Record<string, unknown>>;\n isOpen?: boolean;\n triggerRef?: React.RefObject<HTMLButtonElement>;\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps {}\n\n export interface InternalProps\n extends DefaultProps,\n OptionalProps,\n Omit<GlobalAttributesT<HTMLDivElement>, keyof DefaultProps | keyof OptionalProps | keyof XstyledProps>,\n XstyledProps {}\n}\n\nexport const defaultProps: DSAppPickerT.DefaultProps = {\n apps: [],\n customApps: [],\n sectionTitle: 'APPLICATIONS',\n customSectionTitle: 'CUSTOM APPLICATIONS',\n icon: () => <MenuPicker color={['brand-primary', '700']} size=\"m\" />,\n};\n\n// =============================================================================\n// PropTypes\n// =============================================================================\n\nexport const DSAppPickerPropTypes = {\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 triggerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.any })]).description(\n 'Ref to the trigger button.',\n ),\n} as WeakValidationM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7 +15,7 @@ const focusSelectedOrFirstAvailable = (wrapperRef, allFocusableButtonsRef, selec
|
|
|
15
15
|
if (selectedButtonRef.current !== null) {
|
|
16
16
|
wrapperRef?.current?.querySelectorAll("button")[selectedButtonRef.current].focus();
|
|
17
17
|
} else {
|
|
18
|
-
allFocusableButtonsRef?.
|
|
18
|
+
allFocusableButtonsRef?.[0]?.focus();
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
export {
|
package/dist/esm/utils.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/utils.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type React from 'react';\n\nexport const keys = {\n LEFT: 'ArrowLeft',\n UP: 'ArrowUp',\n RIGHT: 'ArrowRight',\n DOWN: 'ArrowDown',\n ENTER: 'Enter',\n SPACE: '',\n TAB: 'Tab',\n ESC: 'Escape',\n HOME: 'Home',\n END: 'End',\n};\n\nexport const focusSelectedOrFirstAvailable = (\n wrapperRef: React.RefObject<HTMLDivElement>,\n allFocusableButtonsRef:
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACEhB,MAAM,OAAO;AAAA,EAClB,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AACP;AAEO,MAAM,gCAAgC,CAC3C,YACA,wBACA,sBACG;AACH,MAAI,kBAAkB,YAAY,MAAM;AACtC,gBAAY,SAAS,iBAAiB,QAAQ,EAAE,kBAAkB,OAAO,EAAE,MAAM;AAAA,EACnF,OAAO;AACL,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type React from 'react';\n\nexport const keys = {\n LEFT: 'ArrowLeft',\n UP: 'ArrowUp',\n RIGHT: 'ArrowRight',\n DOWN: 'ArrowDown',\n ENTER: 'Enter',\n SPACE: '',\n TAB: 'Tab',\n ESC: 'Escape',\n HOME: 'Home',\n END: 'End',\n};\n\nexport const focusSelectedOrFirstAvailable = (\n wrapperRef: React.RefObject<HTMLDivElement>,\n allFocusableButtonsRef: HTMLButtonElement[],\n selectedButtonRef: React.MutableRefObject<number | null>,\n) => {\n if (selectedButtonRef.current !== null) {\n wrapperRef?.current?.querySelectorAll('button')[selectedButtonRef.current].focus();\n } else {\n allFocusableButtonsRef?.[0]?.focus();\n }\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEhB,MAAM,OAAO;AAAA,EAClB,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AACP;AAEO,MAAM,gCAAgC,CAC3C,YACA,wBACA,sBACG;AACH,MAAI,kBAAkB,YAAY,MAAM;AACtC,gBAAY,SAAS,iBAAiB,QAAQ,EAAE,kBAAkB,OAAO,EAAE,MAAM;AAAA,EACnF,OAAO;AACL,6BAAyB,CAAC,GAAG,MAAM;AAAA,EACrC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,7 +7,7 @@ interface UseKeepTrackButtonsT {
|
|
|
7
7
|
triggerIsInternal?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export declare const useKeepTrackButtons: ({ wrapperRef, wasOpenedByKeyboardRef, actionRef, triggerIsInternal, }: UseKeepTrackButtonsT) => {
|
|
10
|
-
allFocusableButtons:
|
|
10
|
+
allFocusableButtons: HTMLButtonElement[];
|
|
11
11
|
selectedButton: React.MutableRefObject<number | null>;
|
|
12
12
|
};
|
|
13
13
|
export {};
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ export declare const keys: {
|
|
|
11
11
|
HOME: string;
|
|
12
12
|
END: string;
|
|
13
13
|
};
|
|
14
|
-
export declare const focusSelectedOrFirstAvailable: (wrapperRef: React.RefObject<HTMLDivElement>, allFocusableButtonsRef:
|
|
14
|
+
export declare const focusSelectedOrFirstAvailable: (wrapperRef: React.RefObject<HTMLDivElement>, allFocusableButtonsRef: HTMLButtonElement[], selectedButtonRef: React.MutableRefObject<number | null>) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-app-picker",
|
|
3
|
-
"version": "3.21.2-rc.
|
|
3
|
+
"version": "3.21.2-rc.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - App Picker",
|
|
6
6
|
"files": [
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"indent": 4
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@elliemae/ds-
|
|
63
|
-
"@elliemae/ds-
|
|
64
|
-
"@elliemae/ds-
|
|
65
|
-
"@elliemae/ds-
|
|
66
|
-
"@elliemae/ds-
|
|
67
|
-
"@elliemae/ds-popover": "3.21.2-rc.
|
|
68
|
-
"@elliemae/ds-
|
|
69
|
-
"@elliemae/ds-utilities": "3.21.2-rc.
|
|
62
|
+
"@elliemae/ds-button-v2": "3.21.2-rc.3",
|
|
63
|
+
"@elliemae/ds-chip": "3.21.2-rc.3",
|
|
64
|
+
"@elliemae/ds-icons": "3.21.2-rc.3",
|
|
65
|
+
"@elliemae/ds-grid": "3.21.2-rc.3",
|
|
66
|
+
"@elliemae/ds-system": "3.21.2-rc.3",
|
|
67
|
+
"@elliemae/ds-popover": "3.21.2-rc.3",
|
|
68
|
+
"@elliemae/ds-props-helpers": "3.21.2-rc.3",
|
|
69
|
+
"@elliemae/ds-utilities": "3.21.2-rc.3"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@testing-library/jest-dom": "~5.16.5",
|