@elliemae/ds-app-picker 3.12.0-rc.2 → 3.12.0-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 +43 -60
- package/dist/cjs/AppPickerImpl.js.map +1 -1
- package/dist/cjs/DSAppPicker.js +52 -46
- package/dist/cjs/DSAppPicker.js.map +1 -1
- package/dist/cjs/styles.js +3 -3
- package/dist/cjs/styles.js.map +2 -2
- package/dist/esm/AppPickerImpl.js +43 -60
- package/dist/esm/AppPickerImpl.js.map +1 -1
- package/dist/esm/DSAppPicker.js +52 -46
- package/dist/esm/DSAppPicker.js.map +1 -1
- package/dist/esm/styles.js +3 -3
- package/dist/esm/styles.js.map +2 -2
- package/package.json +8 -8
|
@@ -92,30 +92,27 @@ const AppPickerImpl = ({
|
|
|
92
92
|
);
|
|
93
93
|
const totalAppsLength = (0, import_react.useMemo)(() => apps.length + customApps.length, [apps.length, customApps.length]);
|
|
94
94
|
const buildRows = (0, import_react.useCallback)(
|
|
95
|
-
(appList, prevIndex, title) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
117
|
-
})
|
|
118
|
-
}),
|
|
95
|
+
(appList, prevIndex, title) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: appList.map((app, index) => {
|
|
96
|
+
const { label, disabled, selected, icon: Icon, id } = app;
|
|
97
|
+
const IconComp = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { className: "app-picker__icon", size: "m" });
|
|
98
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledListItem, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
99
|
+
import_ds_chip.DSChip,
|
|
100
|
+
{
|
|
101
|
+
onClick: handleOnClick(app),
|
|
102
|
+
onKeyDown: handleKeyDown,
|
|
103
|
+
"data-testid": "app-picker__chip",
|
|
104
|
+
"aria-disabled": disabled,
|
|
105
|
+
disabled,
|
|
106
|
+
selected,
|
|
107
|
+
"aria-selected": selected,
|
|
108
|
+
id,
|
|
109
|
+
"aria-label": `${label}. ${title} (${index + prevIndex} of ${totalAppsLength})`,
|
|
110
|
+
icon: IconComp,
|
|
111
|
+
label
|
|
112
|
+
},
|
|
113
|
+
index
|
|
114
|
+
) });
|
|
115
|
+
}) }),
|
|
119
116
|
[handleKeyDown, handleOnClick, totalAppsLength]
|
|
120
117
|
);
|
|
121
118
|
const AppsRows = (0, import_react.useMemo)(() => buildRows(apps, 1, sectionTitle), [apps, buildRows, sectionTitle]);
|
|
@@ -142,43 +139,29 @@ const AppPickerImpl = ({
|
|
|
142
139
|
};
|
|
143
140
|
}, [apps.length, customApps.length]);
|
|
144
141
|
const convertedTypeReference = wrapperRef;
|
|
145
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledTitle, {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
AppsRows,
|
|
164
|
-
customApps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
165
|
-
children: [
|
|
166
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledListItemFullRow, {
|
|
167
|
-
"aria-hidden": true,
|
|
168
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledSeparator, {})
|
|
169
|
-
}),
|
|
170
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledListItemFullRow, {
|
|
171
|
-
"aria-hidden": true,
|
|
172
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledTitle, {
|
|
173
|
-
"data-testid": "app-picker__custom-title",
|
|
174
|
-
children: customSectionTitle
|
|
175
|
-
})
|
|
176
|
-
}),
|
|
142
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
143
|
+
import_styles.StyledWrapper,
|
|
144
|
+
{
|
|
145
|
+
forwardedAs: "ul",
|
|
146
|
+
ref: convertedTypeReference,
|
|
147
|
+
onKeyDown: handleOnKeyDownWrapper,
|
|
148
|
+
"data-testid": "app-picker__wrapper",
|
|
149
|
+
isOverflow,
|
|
150
|
+
cols: layout.cols,
|
|
151
|
+
rows: layout.rows,
|
|
152
|
+
tabIndex: -1,
|
|
153
|
+
"aria-label": `Application picker, ${sectionTitle} (${apps.length} apps)${customApps.length > 0 ? `, ${customSectionTitle} (${customApps.length} apps)` : ""}`,
|
|
154
|
+
children: [
|
|
155
|
+
/* @__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 }) }),
|
|
156
|
+
AppsRows,
|
|
157
|
+
customApps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
158
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledListItemFullRow, { "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.StyledSeparator, {}) }),
|
|
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__custom-title", children: customSectionTitle }) }),
|
|
177
160
|
CustomRows
|
|
178
|
-
]
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
161
|
+
] })
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
);
|
|
182
165
|
};
|
|
183
166
|
var AppPickerImpl_default = AppPickerImpl;
|
|
184
167
|
//# sourceMappingURL=AppPickerImpl.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/AppPickerImpl.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
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';\nimport type { AppItemType, DSAppPickerImplType } from './types/AppPickerTypes';\nimport { StyledWrapper, StyledSeparator, StyledListItemFullRow, StyledListItem, StyledTitle } from './styles';\nimport { useKeepTrackButtons } from './hooks/useKeepTrackButtons';\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, wasOpenedByKeyboardRef, actionRef, triggerIsInternal);\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>\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 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 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>\n <StyledTitle data-testid=\"app-picker__main-title\">{sectionTitle}</StyledTitle>\n </StyledListItemFullRow>\n {AppsRows}\n {customApps.length > 0 && (\n <>\n <StyledListItemFullRow aria-hidden>\n <StyledSeparator />\n </StyledListItemFullRow>\n <StyledListItemFullRow aria-hidden>\n <StyledTitle data-testid=\"app-picker__custom-title\">{customSectionTitle}</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;ADyEjB;AAtEN,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;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,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,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,MAChC,sDAAC,6BAAY,eAAY,0BAA0B,wBAAa,GAClE;AAAA,QACC;AAAA,QACA,WAAW,SAAS,KACnB,4EACE;AAAA,sDAAC,uCAAsB,eAAW,MAChC,sDAAC,iCAAgB,GACnB;AAAA,UACA,4CAAC,uCAAsB,eAAW,MAChC,sDAAC,6BAAY,eAAY,4BAA4B,8BAAmB,GAC1E;AAAA,UACC;AAAA,WACH;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,wBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/DSAppPicker.js
CHANGED
|
@@ -43,10 +43,7 @@ const DSAppPicker = ({
|
|
|
43
43
|
customApps = [],
|
|
44
44
|
sectionTitle = "APPLICATIONS",
|
|
45
45
|
customSectionTitle = "CUSTOM APPLICATIONS",
|
|
46
|
-
icon: Icon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_icons.MenuPicker, {
|
|
47
|
-
color: ["brand-primary", "700"],
|
|
48
|
-
size: "m"
|
|
49
|
-
}),
|
|
46
|
+
icon: Icon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_icons.MenuPicker, { color: ["brand-primary", "700"], size: "m" }),
|
|
50
47
|
renderTrigger,
|
|
51
48
|
isOpen,
|
|
52
49
|
onClose = () => null,
|
|
@@ -95,20 +92,23 @@ const DSAppPicker = ({
|
|
|
95
92
|
onClickOutside(e);
|
|
96
93
|
};
|
|
97
94
|
const AppPickerContent = (0, import_react.useCallback)(
|
|
98
|
-
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
95
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
96
|
+
import_AppPickerImpl.default,
|
|
97
|
+
{
|
|
98
|
+
apps,
|
|
99
|
+
customApps,
|
|
100
|
+
sectionTitle,
|
|
101
|
+
customSectionTitle,
|
|
102
|
+
close: handleOnClose,
|
|
103
|
+
wrapperRef,
|
|
104
|
+
onKeyDown,
|
|
105
|
+
triggerRef: triggerRef || defaultTriggerRef,
|
|
106
|
+
actionRef,
|
|
107
|
+
triggerIsInternal: !renderTrigger,
|
|
108
|
+
wasOpenedByKeyboardRef,
|
|
109
|
+
isOverflow
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
112
|
[
|
|
113
113
|
actionRef,
|
|
114
114
|
apps,
|
|
@@ -122,35 +122,41 @@ const DSAppPicker = ({
|
|
|
122
122
|
triggerRef
|
|
123
123
|
]
|
|
124
124
|
);
|
|
125
|
-
const RenderTrigger = renderTrigger || (({ ref }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
onClick(e)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppPickerContent, {}),
|
|
142
|
-
isOpen: typeof isOpen === "boolean" ? isOpen : open,
|
|
143
|
-
onClickOutside: handleOnClickOutside,
|
|
144
|
-
placement: "bottom",
|
|
145
|
-
interactionType: "click",
|
|
146
|
-
renderTrigger: RenderTrigger,
|
|
147
|
-
showArrow: true,
|
|
148
|
-
style: {
|
|
149
|
-
padding: "0",
|
|
150
|
-
maxWidth: "1000px",
|
|
151
|
-
width: "fit-content"
|
|
125
|
+
const RenderTrigger = renderTrigger || (({ ref }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
126
|
+
import_ds_button.DSButtonV2,
|
|
127
|
+
{
|
|
128
|
+
"data-testid": "app-picker__button",
|
|
129
|
+
id: "app-picker__button",
|
|
130
|
+
buttonType: "icon",
|
|
131
|
+
"aria-haspopup": "true",
|
|
132
|
+
"aria-expanded": isOpen ?? open,
|
|
133
|
+
"aria-label": "Application picker",
|
|
134
|
+
innerRef: (0, import_ds_utilities.mergeRefs)(ref, defaultTriggerRef),
|
|
135
|
+
onClick: (e) => {
|
|
136
|
+
wasOpenedByKeyboardRef.current = e.detail === 0;
|
|
137
|
+
onClick(e);
|
|
138
|
+
setOpen(true);
|
|
139
|
+
},
|
|
140
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {})
|
|
152
141
|
}
|
|
153
|
-
|
|
142
|
+
));
|
|
143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
|
+
import_ds_popover.default,
|
|
145
|
+
{
|
|
146
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppPickerContent, {}),
|
|
147
|
+
isOpen: typeof isOpen === "boolean" ? isOpen : open,
|
|
148
|
+
onClickOutside: handleOnClickOutside,
|
|
149
|
+
placement: "bottom",
|
|
150
|
+
interactionType: "click",
|
|
151
|
+
renderTrigger: RenderTrigger,
|
|
152
|
+
showArrow: true,
|
|
153
|
+
style: {
|
|
154
|
+
padding: "0",
|
|
155
|
+
maxWidth: "1000px",
|
|
156
|
+
width: "fit-content"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
);
|
|
154
160
|
};
|
|
155
161
|
DSAppPicker.displayName = "DSAppPicker";
|
|
156
162
|
const AppPickerWithSchema = (0, import_ds_utilities.describe)(DSAppPicker);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSAppPicker.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable react/no-unused-prop-types */\nimport React, { useState, useEffect, useRef, useCallback } from 'react';\nimport { MenuPicker } from '@elliemae/ds-icons';\nimport { DSButtonV2 } from '@elliemae/ds-button';\nimport { describe, mergeRefs } from '@elliemae/ds-utilities';\nimport DSPopover from '@elliemae/ds-popover';\nimport AppPickerImpl from './AppPickerImpl';\nimport { propTypes } from './propTypes';\nimport type { DSAppPickerType } from './types/AppPickerTypes';\n\nconst DSAppPicker: DSAppPickerType = ({\n apps = [],\n customApps = [],\n sectionTitle = 'APPLICATIONS',\n customSectionTitle = 'CUSTOM APPLICATIONS',\n icon: Icon = () => <MenuPicker color={['brand-primary', '700']} size=\"m\" />,\n renderTrigger,\n isOpen,\n onClose = () => null,\n actionRef,\n onKeyDown,\n onClick = () => null,\n onClickOutside = () => null,\n triggerRef,\n}) => {\n const [open, setOpen] = useState(false);\n const [isOverflow, setIsOverflow] = useState(false);\n const wrapperRef = useRef<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 =\n renderTrigger ||\n (({ ref }: { ref: React.RefObject<HTMLButtonElement> }) => (\n <DSButtonV2\n data-testid=\"app-picker__button\"\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, defaultTriggerRef)}\n onClick={(e: React.MouseEvent) => {\n wasOpenedByKeyboardRef.current = e.detail === 0;\n onClick(e);\n setOpen(true);\n }}\n >\n <Icon />\n </DSButtonV2>\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 = 'DSAppPicker';\nconst AppPickerWithSchema = describe(DSAppPicker);\nAppPickerWithSchema.propTypes = propTypes;\n\nexport { DSAppPicker, AppPickerWithSchema };\nexport default DSAppPicker;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADeF;AAdrB,mBAAgE;AAChE,sBAA2B;AAC3B,uBAA2B;AAC3B,0BAAoC;AACpC,wBAAsB;AACtB,2BAA0B;AAC1B,uBAA0B;AAG1B,MAAM,cAA+B,CAAC;AAAA,EACpC,OAAO,CAAC;AAAA,EACR,aAAa,CAAC;AAAA,EACd,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,MAAM,OAAO,MAAM,4CAAC
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADeF;AAdrB,mBAAgE;AAChE,sBAA2B;AAC3B,uBAA2B;AAC3B,0BAAoC;AACpC,wBAAsB;AACtB,2BAA0B;AAC1B,uBAA0B;AAG1B,MAAM,cAA+B,CAAC;AAAA,EACpC,OAAO,CAAC;AAAA,EACR,aAAa,CAAC;AAAA,EACd,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,MAAM,OAAO,MAAM,4CAAC,8BAAW,OAAO,CAAC,iBAAiB,KAAK,GAAG,MAAK,KAAI;AAAA,EACzE;AAAA,EACA;AAAA,EACA,UAAU,MAAM;AAAA,EAChB;AAAA,EACA;AAAA,EACA,UAAU,MAAM;AAAA,EAChB,iBAAiB,MAAM;AAAA,EACvB;AACF,MAAM;AACJ,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,KAAK;AACtC,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,KAAK;AAClD,QAAM,iBAAa,qBAAu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;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,gBACJ,kBACC,CAAC,EAAE,IAAI,MACN;AAAA,IAAC;AAAA;AAAA,MACC,eAAY;AAAA,MACZ,IAAG;AAAA,MACH,YAAW;AAAA,MACX,iBAAc;AAAA,MACd,iBAAe,UAAU;AAAA,MACzB,cAAW;AAAA,MACX,cAAU,+BAAU,KAAK,iBAAiB;AAAA,MAC1C,SAAS,CAAC,MAAwB;AAChC,+BAAuB,UAAU,EAAE,WAAW;AAC9C,gBAAQ,CAAC;AACT,gBAAQ,IAAI;AAAA,MACd;AAAA,MAEA,sDAAC,QAAK;AAAA;AAAA,EACR;AAGJ,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,8BAAS,WAAW;AAChD,oBAAoB,YAAY;AAGhC,IAAO,sBAAQ;",
|
|
6
6
|
"names": ["AppPickerImpl", "DSPopover"]
|
|
7
7
|
}
|
package/dist/cjs/styles.js
CHANGED
|
@@ -34,7 +34,7 @@ module.exports = __toCommonJS(styles_exports);
|
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
35
|
var import_ds_system = require("@elliemae/ds-system");
|
|
36
36
|
var import_ds_grid = require("@elliemae/ds-grid");
|
|
37
|
-
const StyledWrapper = (0, import_ds_system.styled)(import_ds_grid.Grid, { name: "
|
|
37
|
+
const StyledWrapper = (0, import_ds_system.styled)(import_ds_grid.Grid, { name: "DSAppPicker", slot: "root" })`
|
|
38
38
|
align-items: center;
|
|
39
39
|
min-width: 308px;
|
|
40
40
|
min-height: 110px;
|
|
@@ -55,7 +55,7 @@ const StyledListItemFullRow = import_ds_system.styled.li`
|
|
|
55
55
|
list-style: none;
|
|
56
56
|
grid-column: 1/4;
|
|
57
57
|
`;
|
|
58
|
-
const StyledTitle = (0, import_ds_system.styled)("h3", { name: "
|
|
58
|
+
const StyledTitle = (0, import_ds_system.styled)("h3", { name: "DSAppPicker", slot: "title" })`
|
|
59
59
|
color: ${({ theme }) => theme.colors.neutral[700]};
|
|
60
60
|
font-size: ${({ theme }) => theme.fontSizes.value[400]};
|
|
61
61
|
font-weight: ${({ theme }) => theme.fontWeights.semibold};
|
|
@@ -63,7 +63,7 @@ const StyledTitle = (0, import_ds_system.styled)("h3", { name: "DS-AppPicker", s
|
|
|
63
63
|
line-height: 1.385;
|
|
64
64
|
text-transform: uppercase;
|
|
65
65
|
`;
|
|
66
|
-
const StyledSeparator = (0, import_ds_system.styled)("hr", { name: "
|
|
66
|
+
const StyledSeparator = (0, import_ds_system.styled)("hr", { name: "DSAppPicker", slot: "separator" })`
|
|
67
67
|
border-top: 1px solid ${({ theme }) => theme.colors.neutral[100]};
|
|
68
68
|
border-bottom: none;
|
|
69
69
|
width: 99%;
|
package/dist/cjs/styles.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/styles.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable max-lines */\nimport { styled } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\n\nexport const StyledWrapper = styled(Grid, { name: '
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,uBAAuB;AACvB,qBAAqB;AAEd,MAAM,oBAAgB,yBAAO,qBAAM,EAAE,MAAM,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable max-lines */\nimport { styled } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\n\nexport const StyledWrapper = styled(Grid, { name: 'DSAppPicker', slot: 'root' })<{ isOverflow: boolean }>`\n align-items: center;\n min-width: 308px;\n min-height: 110px;\n max-height: 449px;\n width: 308px;\n overflow-y: auto;\n overflow-x: hidden;\n margin: 0;\n padding: ${({ isOverflow }) => (isOverflow ? '0 0 8px 16px' : '0 16px 8px 16px')};\n &:focus {\n outline: none;\n }\n`;\n\nexport const StyledListItem = styled.li`\n list-style: none;\n`;\n\nexport const StyledListItemFullRow = styled.li`\n list-style: none;\n grid-column: 1/4;\n`;\n\nexport const StyledTitle = styled('h3', { name: 'DSAppPicker', slot: 'title' })`\n color: ${({ theme }) => theme.colors.neutral[700]};\n font-size: ${({ theme }) => theme.fontSizes.value[400]};\n font-weight: ${({ theme }) => theme.fontWeights.semibold};\n margin: 12px 0 8px 0;\n line-height: 1.385;\n text-transform: uppercase;\n`;\n\nexport const StyledSeparator = styled('hr', { name: 'DSAppPicker', slot: 'separator' })`\n border-top: 1px solid ${({ theme }) => theme.colors.neutral[100]};\n border-bottom: none;\n width: 99%;\n margin: 8px 0 0 0;\n`;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,uBAAuB;AACvB,qBAAqB;AAEd,MAAM,oBAAgB,yBAAO,qBAAM,EAAE,MAAM,eAAe,MAAM,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aASlE,CAAC,EAAE,WAAW,MAAO,aAAa,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAMzD,MAAM,iBAAiB,wBAAO;AAAA;AAAA;AAI9B,MAAM,wBAAwB,wBAAO;AAAA;AAAA;AAAA;AAKrC,MAAM,kBAAc,yBAAO,MAAM,EAAE,MAAM,eAAe,MAAM,QAAQ,CAAC;AAAA,WACnE,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,QAAQ;AAAA,eAChC,CAAC,EAAE,MAAM,MAAM,MAAM,UAAU,MAAM;AAAA,iBACnC,CAAC,EAAE,MAAM,MAAM,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAM3C,MAAM,sBAAkB,yBAAO,MAAM,EAAE,MAAM,eAAe,MAAM,YAAY,CAAC;AAAA,0BAC5D,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,QAAQ;AAAA;AAAA;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -63,30 +63,27 @@ const AppPickerImpl = ({
|
|
|
63
63
|
);
|
|
64
64
|
const totalAppsLength = useMemo(() => apps.length + customApps.length, [apps.length, customApps.length]);
|
|
65
65
|
const buildRows = useCallback(
|
|
66
|
-
(appList, prevIndex, title) => /* @__PURE__ */ jsx(Fragment, {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
88
|
-
})
|
|
89
|
-
}),
|
|
66
|
+
(appList, prevIndex, title) => /* @__PURE__ */ jsx(Fragment, { children: appList.map((app, index) => {
|
|
67
|
+
const { label, disabled, selected, icon: Icon, id } = app;
|
|
68
|
+
const IconComp = () => /* @__PURE__ */ jsx(Icon, { className: "app-picker__icon", size: "m" });
|
|
69
|
+
return /* @__PURE__ */ jsx(StyledListItem, { children: /* @__PURE__ */ jsx(
|
|
70
|
+
DSChip,
|
|
71
|
+
{
|
|
72
|
+
onClick: handleOnClick(app),
|
|
73
|
+
onKeyDown: handleKeyDown,
|
|
74
|
+
"data-testid": "app-picker__chip",
|
|
75
|
+
"aria-disabled": disabled,
|
|
76
|
+
disabled,
|
|
77
|
+
selected,
|
|
78
|
+
"aria-selected": selected,
|
|
79
|
+
id,
|
|
80
|
+
"aria-label": `${label}. ${title} (${index + prevIndex} of ${totalAppsLength})`,
|
|
81
|
+
icon: IconComp,
|
|
82
|
+
label
|
|
83
|
+
},
|
|
84
|
+
index
|
|
85
|
+
) });
|
|
86
|
+
}) }),
|
|
90
87
|
[handleKeyDown, handleOnClick, totalAppsLength]
|
|
91
88
|
);
|
|
92
89
|
const AppsRows = useMemo(() => buildRows(apps, 1, sectionTitle), [apps, buildRows, sectionTitle]);
|
|
@@ -113,43 +110,29 @@ const AppPickerImpl = ({
|
|
|
113
110
|
};
|
|
114
111
|
}, [apps.length, customApps.length]);
|
|
115
112
|
const convertedTypeReference = wrapperRef;
|
|
116
|
-
return /* @__PURE__ */ jsxs(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
children: /* @__PURE__ */ jsx(StyledTitle, {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
AppsRows,
|
|
135
|
-
customApps.length > 0 && /* @__PURE__ */ jsxs(Fragment, {
|
|
136
|
-
children: [
|
|
137
|
-
/* @__PURE__ */ jsx(StyledListItemFullRow, {
|
|
138
|
-
"aria-hidden": true,
|
|
139
|
-
children: /* @__PURE__ */ jsx(StyledSeparator, {})
|
|
140
|
-
}),
|
|
141
|
-
/* @__PURE__ */ jsx(StyledListItemFullRow, {
|
|
142
|
-
"aria-hidden": true,
|
|
143
|
-
children: /* @__PURE__ */ jsx(StyledTitle, {
|
|
144
|
-
"data-testid": "app-picker__custom-title",
|
|
145
|
-
children: customSectionTitle
|
|
146
|
-
})
|
|
147
|
-
}),
|
|
113
|
+
return /* @__PURE__ */ jsxs(
|
|
114
|
+
StyledWrapper,
|
|
115
|
+
{
|
|
116
|
+
forwardedAs: "ul",
|
|
117
|
+
ref: convertedTypeReference,
|
|
118
|
+
onKeyDown: handleOnKeyDownWrapper,
|
|
119
|
+
"data-testid": "app-picker__wrapper",
|
|
120
|
+
isOverflow,
|
|
121
|
+
cols: layout.cols,
|
|
122
|
+
rows: layout.rows,
|
|
123
|
+
tabIndex: -1,
|
|
124
|
+
"aria-label": `Application picker, ${sectionTitle} (${apps.length} apps)${customApps.length > 0 ? `, ${customSectionTitle} (${customApps.length} apps)` : ""}`,
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ jsx(StyledListItemFullRow, { "aria-hidden": true, children: /* @__PURE__ */ jsx(StyledTitle, { "data-testid": "app-picker__main-title", children: sectionTitle }) }),
|
|
127
|
+
AppsRows,
|
|
128
|
+
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 }) }),
|
|
148
131
|
CustomRows
|
|
149
|
-
]
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
132
|
+
] })
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
);
|
|
153
136
|
};
|
|
154
137
|
var AppPickerImpl_default = AppPickerImpl;
|
|
155
138
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/AppPickerImpl.tsx"],
|
|
4
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';\nimport type { AppItemType, DSAppPickerImplType } from './types/AppPickerTypes';\nimport { StyledWrapper, StyledSeparator, StyledListItemFullRow, StyledListItem, StyledTitle } from './styles';\nimport { useKeepTrackButtons } from './hooks/useKeepTrackButtons';\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, wasOpenedByKeyboardRef, actionRef, triggerIsInternal);\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>\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 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 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>\n <StyledTitle data-testid=\"app-picker__main-title\">{sectionTitle}</StyledTitle>\n </StyledListItemFullRow>\n {AppsRows}\n {customApps.length > 0 && (\n <>\n <StyledListItemFullRow aria-hidden>\n <StyledSeparator />\n </StyledListItemFullRow>\n <StyledListItemFullRow aria-hidden>\n <StyledTitle data-testid=\"app-picker__custom-title\">{customSectionTitle}</StyledTitle>\n </StyledListItemFullRow>\n {CustomRows}\n </>\n )}\n </StyledWrapper>\n );\n};\n\nexport default AppPickerImpl;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACyEjB,mBAK2B,KA0EzB,YA/EF;AAtEN,SAAgB,aAAa,eAAe;AAC5C,SAAS,cAAc;AACvB,SAAS,YAAY;AAErB,SAAS,eAAe,iBAAiB,uBAAuB,gBAAgB,mBAAmB;AACnG,SAAS,2BAA2B;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;AACJ,QAAM,EAAE,oBAAoB,IAAI,oBAAoB,YAAY,wBAAwB,WAAW,iBAAiB;AAGpH,QAAM,gBAAgB;AAAA,IACpB,CAAC,MAA2B;AAC1B,cAAQ,EAAE,KAAK;AAAA,QACb,KAAK,KAAK;AACR,sBAAY,SAAS,MAAM;AAC3B,gBAAM;AACN;AAAA,QACF,KAAK,KAAK;AACR,cAAI,EAAE,UAAU;AACd,gBAAI,EAAE,WAAW,oBAAoB,QAAQ,IAAI;AAC/C,gBAAE,eAAe;AACjB,mCAAqB,QAAQ,oBAAoB,QAAQ,SAAS,IAAI,MAAM;AAAA,YAC9E;AAAA,UACF,WAAW,EAAE,WAAW,oBAAoB,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D,WAAW,SAAS,IAAI,KAAK,uBAAuB,WAAW,iBAAiB;AAAA,MAGlF;AAAA,4BAAC,yBAAsB,eAAW,MAChC,8BAAC,eAAY,eAAY,0BAA0B,wBAAa,GAClE;AAAA,QACC;AAAA,QACA,WAAW,SAAS,KACnB,iCACE;AAAA,8BAAC,yBAAsB,eAAW,MAChC,8BAAC,mBAAgB,GACnB;AAAA,UACA,oBAAC,yBAAsB,eAAW,MAChC,8BAAC,eAAY,eAAY,4BAA4B,8BAAmB,GAC1E;AAAA,UACC;AAAA,WACH;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,wBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/DSAppPicker.js
CHANGED
|
@@ -12,10 +12,7 @@ const DSAppPicker = ({
|
|
|
12
12
|
customApps = [],
|
|
13
13
|
sectionTitle = "APPLICATIONS",
|
|
14
14
|
customSectionTitle = "CUSTOM APPLICATIONS",
|
|
15
|
-
icon: Icon = () => /* @__PURE__ */ jsx(MenuPicker, {
|
|
16
|
-
color: ["brand-primary", "700"],
|
|
17
|
-
size: "m"
|
|
18
|
-
}),
|
|
15
|
+
icon: Icon = () => /* @__PURE__ */ jsx(MenuPicker, { color: ["brand-primary", "700"], size: "m" }),
|
|
19
16
|
renderTrigger,
|
|
20
17
|
isOpen,
|
|
21
18
|
onClose = () => null,
|
|
@@ -64,20 +61,23 @@ const DSAppPicker = ({
|
|
|
64
61
|
onClickOutside(e);
|
|
65
62
|
};
|
|
66
63
|
const AppPickerContent = useCallback(
|
|
67
|
-
() => /* @__PURE__ */ jsx(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
64
|
+
() => /* @__PURE__ */ jsx(
|
|
65
|
+
AppPickerImpl,
|
|
66
|
+
{
|
|
67
|
+
apps,
|
|
68
|
+
customApps,
|
|
69
|
+
sectionTitle,
|
|
70
|
+
customSectionTitle,
|
|
71
|
+
close: handleOnClose,
|
|
72
|
+
wrapperRef,
|
|
73
|
+
onKeyDown,
|
|
74
|
+
triggerRef: triggerRef || defaultTriggerRef,
|
|
75
|
+
actionRef,
|
|
76
|
+
triggerIsInternal: !renderTrigger,
|
|
77
|
+
wasOpenedByKeyboardRef,
|
|
78
|
+
isOverflow
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
81
|
[
|
|
82
82
|
actionRef,
|
|
83
83
|
apps,
|
|
@@ -91,35 +91,41 @@ const DSAppPicker = ({
|
|
|
91
91
|
triggerRef
|
|
92
92
|
]
|
|
93
93
|
);
|
|
94
|
-
const RenderTrigger = renderTrigger || (({ ref }) => /* @__PURE__ */ jsx(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
onClick(e)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
content: /* @__PURE__ */ jsx(AppPickerContent, {}),
|
|
111
|
-
isOpen: typeof isOpen === "boolean" ? isOpen : open,
|
|
112
|
-
onClickOutside: handleOnClickOutside,
|
|
113
|
-
placement: "bottom",
|
|
114
|
-
interactionType: "click",
|
|
115
|
-
renderTrigger: RenderTrigger,
|
|
116
|
-
showArrow: true,
|
|
117
|
-
style: {
|
|
118
|
-
padding: "0",
|
|
119
|
-
maxWidth: "1000px",
|
|
120
|
-
width: "fit-content"
|
|
94
|
+
const RenderTrigger = renderTrigger || (({ ref }) => /* @__PURE__ */ jsx(
|
|
95
|
+
DSButtonV2,
|
|
96
|
+
{
|
|
97
|
+
"data-testid": "app-picker__button",
|
|
98
|
+
id: "app-picker__button",
|
|
99
|
+
buttonType: "icon",
|
|
100
|
+
"aria-haspopup": "true",
|
|
101
|
+
"aria-expanded": isOpen ?? open,
|
|
102
|
+
"aria-label": "Application picker",
|
|
103
|
+
innerRef: mergeRefs(ref, defaultTriggerRef),
|
|
104
|
+
onClick: (e) => {
|
|
105
|
+
wasOpenedByKeyboardRef.current = e.detail === 0;
|
|
106
|
+
onClick(e);
|
|
107
|
+
setOpen(true);
|
|
108
|
+
},
|
|
109
|
+
children: /* @__PURE__ */ jsx(Icon, {})
|
|
121
110
|
}
|
|
122
|
-
|
|
111
|
+
));
|
|
112
|
+
return /* @__PURE__ */ jsx(
|
|
113
|
+
DSPopover,
|
|
114
|
+
{
|
|
115
|
+
content: /* @__PURE__ */ jsx(AppPickerContent, {}),
|
|
116
|
+
isOpen: typeof isOpen === "boolean" ? isOpen : open,
|
|
117
|
+
onClickOutside: handleOnClickOutside,
|
|
118
|
+
placement: "bottom",
|
|
119
|
+
interactionType: "click",
|
|
120
|
+
renderTrigger: RenderTrigger,
|
|
121
|
+
showArrow: true,
|
|
122
|
+
style: {
|
|
123
|
+
padding: "0",
|
|
124
|
+
maxWidth: "1000px",
|
|
125
|
+
width: "fit-content"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
);
|
|
123
129
|
};
|
|
124
130
|
DSAppPicker.displayName = "DSAppPicker";
|
|
125
131
|
const AppPickerWithSchema = describe(DSAppPicker);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSAppPicker.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/no-unused-prop-types */\nimport React, { useState, useEffect, useRef, useCallback } from 'react';\nimport { MenuPicker } from '@elliemae/ds-icons';\nimport { DSButtonV2 } from '@elliemae/ds-button';\nimport { describe, mergeRefs } from '@elliemae/ds-utilities';\nimport DSPopover from '@elliemae/ds-popover';\nimport AppPickerImpl from './AppPickerImpl';\nimport { propTypes } from './propTypes';\nimport type { DSAppPickerType } from './types/AppPickerTypes';\n\nconst DSAppPicker: DSAppPickerType = ({\n apps = [],\n customApps = [],\n sectionTitle = 'APPLICATIONS',\n customSectionTitle = 'CUSTOM APPLICATIONS',\n icon: Icon = () => <MenuPicker color={['brand-primary', '700']} size=\"m\" />,\n renderTrigger,\n isOpen,\n onClose = () => null,\n actionRef,\n onKeyDown,\n onClick = () => null,\n onClickOutside = () => null,\n triggerRef,\n}) => {\n const [open, setOpen] = useState(false);\n const [isOverflow, setIsOverflow] = useState(false);\n const wrapperRef = useRef<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 =\n renderTrigger ||\n (({ ref }: { ref: React.RefObject<HTMLButtonElement> }) => (\n <DSButtonV2\n data-testid=\"app-picker__button\"\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, defaultTriggerRef)}\n onClick={(e: React.MouseEvent) => {\n wasOpenedByKeyboardRef.current = e.detail === 0;\n onClick(e);\n setOpen(true);\n }}\n >\n <Icon />\n </DSButtonV2>\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 = 'DSAppPicker';\nconst AppPickerWithSchema = describe(DSAppPicker);\nAppPickerWithSchema.propTypes = propTypes;\n\nexport { DSAppPicker, AppPickerWithSchema };\nexport default DSAppPicker;\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACeF;AAdrB,SAAgB,UAAU,WAAW,QAAQ,mBAAmB;AAChE,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,UAAU,iBAAiB;AACpC,OAAO,eAAe;AACtB,OAAO,mBAAmB;AAC1B,SAAS,iBAAiB;AAG1B,MAAM,cAA+B,CAAC;AAAA,EACpC,OAAO,CAAC;AAAA,EACR,aAAa,CAAC;AAAA,EACd,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,MAAM,OAAO,MAAM,oBAAC
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACeF;AAdrB,SAAgB,UAAU,WAAW,QAAQ,mBAAmB;AAChE,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,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EACF;AAEJ;AAEA,YAAY,cAAc;AAC1B,MAAM,sBAAsB,SAAS,WAAW;AAChD,oBAAoB,YAAY;AAGhC,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/styles.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { styled } from "@elliemae/ds-system";
|
|
3
3
|
import { Grid } from "@elliemae/ds-grid";
|
|
4
|
-
const StyledWrapper = styled(Grid, { name: "
|
|
4
|
+
const StyledWrapper = styled(Grid, { name: "DSAppPicker", slot: "root" })`
|
|
5
5
|
align-items: center;
|
|
6
6
|
min-width: 308px;
|
|
7
7
|
min-height: 110px;
|
|
@@ -22,7 +22,7 @@ const StyledListItemFullRow = styled.li`
|
|
|
22
22
|
list-style: none;
|
|
23
23
|
grid-column: 1/4;
|
|
24
24
|
`;
|
|
25
|
-
const StyledTitle = styled("h3", { name: "
|
|
25
|
+
const StyledTitle = styled("h3", { name: "DSAppPicker", slot: "title" })`
|
|
26
26
|
color: ${({ theme }) => theme.colors.neutral[700]};
|
|
27
27
|
font-size: ${({ theme }) => theme.fontSizes.value[400]};
|
|
28
28
|
font-weight: ${({ theme }) => theme.fontWeights.semibold};
|
|
@@ -30,7 +30,7 @@ const StyledTitle = styled("h3", { name: "DS-AppPicker", slot: "title" })`
|
|
|
30
30
|
line-height: 1.385;
|
|
31
31
|
text-transform: uppercase;
|
|
32
32
|
`;
|
|
33
|
-
const StyledSeparator = styled("hr", { name: "
|
|
33
|
+
const StyledSeparator = styled("hr", { name: "DSAppPicker", slot: "separator" })`
|
|
34
34
|
border-top: 1px solid ${({ theme }) => theme.colors.neutral[100]};
|
|
35
35
|
border-bottom: none;
|
|
36
36
|
width: 99%;
|
package/dist/esm/styles.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/styles.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable max-lines */\nimport { styled } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\n\nexport const StyledWrapper = styled(Grid, { name: '
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,cAAc;AACvB,SAAS,YAAY;AAEd,MAAM,gBAAgB,OAAO,MAAM,EAAE,MAAM,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable max-lines */\nimport { styled } from '@elliemae/ds-system';\nimport { Grid } from '@elliemae/ds-grid';\n\nexport const StyledWrapper = styled(Grid, { name: 'DSAppPicker', slot: 'root' })<{ isOverflow: boolean }>`\n align-items: center;\n min-width: 308px;\n min-height: 110px;\n max-height: 449px;\n width: 308px;\n overflow-y: auto;\n overflow-x: hidden;\n margin: 0;\n padding: ${({ isOverflow }) => (isOverflow ? '0 0 8px 16px' : '0 16px 8px 16px')};\n &:focus {\n outline: none;\n }\n`;\n\nexport const StyledListItem = styled.li`\n list-style: none;\n`;\n\nexport const StyledListItemFullRow = styled.li`\n list-style: none;\n grid-column: 1/4;\n`;\n\nexport const StyledTitle = styled('h3', { name: 'DSAppPicker', slot: 'title' })`\n color: ${({ theme }) => theme.colors.neutral[700]};\n font-size: ${({ theme }) => theme.fontSizes.value[400]};\n font-weight: ${({ theme }) => theme.fontWeights.semibold};\n margin: 12px 0 8px 0;\n line-height: 1.385;\n text-transform: uppercase;\n`;\n\nexport const StyledSeparator = styled('hr', { name: 'DSAppPicker', slot: 'separator' })`\n border-top: 1px solid ${({ theme }) => theme.colors.neutral[100]};\n border-bottom: none;\n width: 99%;\n margin: 8px 0 0 0;\n`;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,cAAc;AACvB,SAAS,YAAY;AAEd,MAAM,gBAAgB,OAAO,MAAM,EAAE,MAAM,eAAe,MAAM,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aASlE,CAAC,EAAE,WAAW,MAAO,aAAa,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAMzD,MAAM,iBAAiB,OAAO;AAAA;AAAA;AAI9B,MAAM,wBAAwB,OAAO;AAAA;AAAA;AAAA;AAKrC,MAAM,cAAc,OAAO,MAAM,EAAE,MAAM,eAAe,MAAM,QAAQ,CAAC;AAAA,WACnE,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,QAAQ;AAAA,eAChC,CAAC,EAAE,MAAM,MAAM,MAAM,UAAU,MAAM;AAAA,iBACnC,CAAC,EAAE,MAAM,MAAM,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAM3C,MAAM,kBAAkB,OAAO,MAAM,EAAE,MAAM,eAAe,MAAM,YAAY,CAAC;AAAA,0BAC5D,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,QAAQ;AAAA;AAAA;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-app-picker",
|
|
3
|
-
"version": "3.12.0-rc.
|
|
3
|
+
"version": "3.12.0-rc.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - App Picker",
|
|
6
6
|
"files": [
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
"indent": 4
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@elliemae/ds-button": "3.12.0-rc.
|
|
63
|
-
"@elliemae/ds-chip": "3.12.0-rc.
|
|
64
|
-
"@elliemae/ds-grid": "3.12.0-rc.
|
|
65
|
-
"@elliemae/ds-icons": "3.12.0-rc.
|
|
66
|
-
"@elliemae/ds-popover": "3.12.0-rc.
|
|
67
|
-
"@elliemae/ds-system": "3.12.0-rc.
|
|
68
|
-
"@elliemae/ds-utilities": "3.12.0-rc.
|
|
62
|
+
"@elliemae/ds-button": "3.12.0-rc.3",
|
|
63
|
+
"@elliemae/ds-chip": "3.12.0-rc.3",
|
|
64
|
+
"@elliemae/ds-grid": "3.12.0-rc.3",
|
|
65
|
+
"@elliemae/ds-icons": "3.12.0-rc.3",
|
|
66
|
+
"@elliemae/ds-popover": "3.12.0-rc.3",
|
|
67
|
+
"@elliemae/ds-system": "3.12.0-rc.3",
|
|
68
|
+
"@elliemae/ds-utilities": "3.12.0-rc.3"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@testing-library/jest-dom": "~5.16.4",
|