@pega/cosmos-react-core 10.0.0-build.4.5 → 10.0.0-build.4.7
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/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +17 -3
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/Dialog/InfoDialogWrapper.d.ts +4 -0
- package/lib/components/Dialog/InfoDialogWrapper.d.ts.map +1 -0
- package/lib/components/Dialog/InfoDialogWrapper.js +13 -0
- package/lib/components/Dialog/InfoDialogWrapper.js.map +1 -0
- package/lib/components/Dialog/TouchDialog.d.ts +5 -0
- package/lib/components/Dialog/TouchDialog.d.ts.map +1 -0
- package/lib/components/Dialog/TouchDialog.js +85 -0
- package/lib/components/Dialog/TouchDialog.js.map +1 -0
- package/lib/components/Dialog/TouchDialog.styles.d.ts +7 -0
- package/lib/components/Dialog/TouchDialog.styles.d.ts.map +1 -0
- package/lib/components/Dialog/TouchDialog.styles.js +62 -0
- package/lib/components/Dialog/TouchDialog.styles.js.map +1 -0
- package/lib/components/Dialog/TouchDialog.test-ids.d.ts +2 -0
- package/lib/components/Dialog/TouchDialog.test-ids.d.ts.map +1 -0
- package/lib/components/Dialog/TouchDialog.test-ids.js +3 -0
- package/lib/components/Dialog/TouchDialog.test-ids.js.map +1 -0
- package/lib/components/Dialog/TouchDialog.types.d.ts +42 -0
- package/lib/components/Dialog/TouchDialog.types.d.ts.map +1 -0
- package/lib/components/Dialog/TouchDialog.types.js +2 -0
- package/lib/components/Dialog/TouchDialog.types.js.map +1 -0
- package/lib/components/Dialog/TouchInfoDialog.d.ts +4 -0
- package/lib/components/Dialog/TouchInfoDialog.d.ts.map +1 -0
- package/lib/components/Dialog/TouchInfoDialog.js +14 -0
- package/lib/components/Dialog/TouchInfoDialog.js.map +1 -0
- package/lib/components/Dialog/index.d.ts +4 -1
- package/lib/components/Dialog/index.d.ts.map +1 -1
- package/lib/components/Dialog/index.js +3 -1
- package/lib/components/Dialog/index.js.map +1 -1
- package/lib/components/File/CompactList.js +1 -1
- package/lib/components/File/CompactList.js.map +1 -1
- package/lib/components/File/mimeTypes.json +1 -0
- package/lib/components/ListToolbar/PresetMenuPopover.d.ts.map +1 -1
- package/lib/components/ListToolbar/PresetMenuPopover.js +16 -5
- package/lib/components/ListToolbar/PresetMenuPopover.js.map +1 -1
- package/lib/components/MenuButton/MenuButton.d.ts.map +1 -1
- package/lib/components/MenuButton/MenuButton.js +33 -7
- package/lib/components/MenuButton/MenuButton.js.map +1 -1
- package/lib/components/MultiStepForm/FormProgress.styles.d.ts +25 -1
- package/lib/components/MultiStepForm/FormProgress.styles.d.ts.map +1 -1
- package/lib/components/MultiStepForm/FormProgress.styles.js +168 -5
- package/lib/components/MultiStepForm/FormProgress.styles.js.map +1 -1
- package/lib/components/MultiStepForm/HorizontalFormProgress.d.ts +2 -2
- package/lib/components/MultiStepForm/HorizontalFormProgress.d.ts.map +1 -1
- package/lib/components/MultiStepForm/HorizontalFormProgress.js +48 -22
- package/lib/components/MultiStepForm/HorizontalFormProgress.js.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.d.ts.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.js +2 -2
- package/lib/components/MultiStepForm/MultiStepForm.js.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.types.d.ts +5 -0
- package/lib/components/MultiStepForm/MultiStepForm.types.d.ts.map +1 -1
- package/lib/components/MultiStepForm/MultiStepForm.types.js.map +1 -1
- package/lib/components/MultiStepForm/VerticalFormProgress.d.ts +2 -2
- package/lib/components/MultiStepForm/VerticalFormProgress.d.ts.map +1 -1
- package/lib/components/MultiStepForm/VerticalFormProgress.js +45 -20
- package/lib/components/MultiStepForm/VerticalFormProgress.js.map +1 -1
- package/lib/components/MultiStepForm/useFormProgressOverflow.d.ts +1 -1
- package/lib/components/MultiStepForm/useFormProgressOverflow.d.ts.map +1 -1
- package/lib/components/MultiStepForm/useFormProgressOverflow.js +17 -9
- package/lib/components/MultiStepForm/useFormProgressOverflow.js.map +1 -1
- package/lib/theme/theme.d.ts +12 -0
- package/lib/theme/theme.d.ts.map +1 -1
- package/lib/theme/themeDefinition.json +6 -0
- package/lib/theme/themeOverrides.schema.json +9 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +1 -0
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/isTouchDevice.d.ts +3 -0
- package/lib/utils/isTouchDevice.d.ts.map +1 -0
- package/lib/utils/isTouchDevice.js +4 -0
- package/lib/utils/isTouchDevice.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState } from 'react';
|
|
3
|
+
import { TouchDialog } from './TouchDialog';
|
|
4
|
+
const TouchInfoDialog = forwardRef(function TouchInfoDialog({ heading: headingProp, children, onDismiss, ...restProps }, ref) {
|
|
5
|
+
const headingText = typeof headingProp === 'string' ? headingProp : headingProp?.primary;
|
|
6
|
+
const [open, setOpen] = useState(true);
|
|
7
|
+
return (_jsx(TouchDialog, { ...restProps, open: open, onDismiss: () => {
|
|
8
|
+
setOpen(false);
|
|
9
|
+
}, ref: ref, heading: headingText, onAfterClose: () => {
|
|
10
|
+
onDismiss();
|
|
11
|
+
}, children: children }));
|
|
12
|
+
});
|
|
13
|
+
export default TouchInfoDialog;
|
|
14
|
+
//# sourceMappingURL=TouchInfoDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TouchInfoDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/TouchInfoDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAwB,MAAM,OAAO,CAAC;AAInE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,MAAM,eAAe,GAAG,UAAU,CAGhC,SAAS,eAAe,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EAAE,GAAG;IACzF,MAAM,WAAW,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC;IACzF,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEvC,OAAO,CACL,KAAC,WAAW,OACN,SAAS,EACb,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,GAAG,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,EACD,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,WAAW,EACpB,YAAY,EAAE,GAAG,EAAE;YACjB,SAAS,EAAE,CAAC;QACd,CAAC,YAEA,QAAQ,GACG,CACf,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, useState, type PropsWithoutRef } from 'react';\n\nimport type { RefElement, OmitStrict } from '../../types';\n\nimport { TouchDialog } from './TouchDialog';\nimport type { InfoDialogProps } from './Dialog.types';\n\nconst TouchInfoDialog = forwardRef<\n RefElement<InfoDialogProps>,\n PropsWithoutRef<OmitStrict<InfoDialogProps, 'target'>>\n>(function TouchInfoDialog({ heading: headingProp, children, onDismiss, ...restProps }, ref) {\n const headingText = typeof headingProp === 'string' ? headingProp : headingProp?.primary;\n const [open, setOpen] = useState(true);\n\n return (\n <TouchDialog\n {...restProps}\n open={open}\n onDismiss={() => {\n setOpen(false);\n }}\n ref={ref}\n heading={headingText}\n onAfterClose={() => {\n onDismiss();\n }}\n >\n {children}\n </TouchDialog>\n );\n});\n\nexport default TouchInfoDialog;\n"]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { default as FormDialog } from './FormDialog';
|
|
2
|
-
export { default as InfoDialog } from './
|
|
2
|
+
export { default as InfoDialog } from './InfoDialogWrapper';
|
|
3
|
+
export { default as TouchDialog } from './TouchDialog';
|
|
4
|
+
export type { TouchDialogProps } from './TouchDialog.types';
|
|
5
|
+
export { getTouchDialogTestIds } from './TouchDialog.test-ids';
|
|
3
6
|
export type { FormDialogProps, InfoDialogProps, DialogHandleValue } from './Dialog.types';
|
|
4
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { default as FormDialog } from './FormDialog';
|
|
2
|
-
export { default as InfoDialog } from './
|
|
2
|
+
export { default as InfoDialog } from './InfoDialogWrapper';
|
|
3
|
+
export { default as TouchDialog } from './TouchDialog';
|
|
4
|
+
export { getTouchDialogTestIds } from './TouchDialog.test-ids';
|
|
3
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Dialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Dialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { default as FormDialog } from './FormDialog';\nexport { default as InfoDialog } from './InfoDialogWrapper';\nexport { default as TouchDialog } from './TouchDialog';\nexport type { TouchDialogProps } from './TouchDialog.types';\nexport { getTouchDialogTestIds } from './TouchDialog.test-ids';\nexport type { FormDialogProps, InfoDialogProps, DialogHandleValue } from './Dialog.types';\n"]}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import Button from '../Button';
|
|
4
4
|
import { useElement, useI18n } from '../../hooks';
|
|
5
|
-
import InfoDialog from '../Dialog
|
|
5
|
+
import { InfoDialog } from '../Dialog';
|
|
6
6
|
import NoValue from '../NoValue';
|
|
7
7
|
const CompactList = forwardRef(function CompactList({ count, onDialogOpen, onDialogClose, progress, heading, content, ...restProps }, ref) {
|
|
8
8
|
const t = useI18n();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompactList.js","sourceRoot":"","sources":["../../../src/components/File/CompactList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAInC,OAAO,MAAM,MAAM,WAAW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B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,GAAG,EAAE;wBACd,IAAI,aAAa;4BAAE,aAAa,EAAE,CAAC;wBACnC,SAAS,CAAC,IAAI,CAAC,CAAC;oBAClB,CAAC,YAEA,OAAO,GACG,CACd,IACA,CACJ,GACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef, MouseEvent } from 'react';\n\nimport type { NoChildrenProp, RefElement, WithAttributes } from '../../types';\nimport Button from '../Button';\nimport { useElement, useI18n } from '../../hooks';\nimport { InfoDialog } from '../Dialog';\nimport type { InfoDialogProps } from '../Dialog';\nimport NoValue from '../NoValue';\n\nexport type CompactListProps = WithAttributes<\n 'div',\n NoChildrenProp &\n Pick<InfoDialogProps, 'progress'> & {\n /** number representing the total count of items */\n count: number;\n heading: InfoDialogProps['heading'];\n /** Callback that triggers when the dialog is open */\n onDialogOpen?: () => void;\n /** Callback that triggers when the dialog is closed */\n onDialogClose?: () => void;\n content?: InfoDialogProps['children'];\n }\n>;\n\nconst CompactList = forwardRef<RefElement<CompactListProps>, PropsWithoutRef<CompactListProps>>(\n function CompactList(\n { count, onDialogOpen, onDialogClose, progress, heading, content, ...restProps },\n ref\n ) {\n const t = useI18n();\n const [target, setTarget] = useElement<HTMLButtonElement>(null);\n\n return (\n <div {...restProps} ref={ref}>\n {count === 0 ? (\n <NoValue />\n ) : (\n <>\n <Button\n variant='link'\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n if (onDialogOpen && !target) onDialogOpen();\n setTarget(e.currentTarget);\n }}\n >\n {t('number_of_items', [count], { count })}\n </Button>\n\n {target && (\n <InfoDialog\n heading={heading}\n progress={progress}\n target={target}\n onDismiss={() => {\n if (onDialogClose) onDialogClose();\n setTarget(null);\n }}\n >\n {content}\n </InfoDialog>\n )}\n </>\n )}\n </div>\n );\n }\n);\n\nexport default CompactList;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresetMenuPopover.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/PresetMenuPopover.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAc,SAAS,EAAW,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PresetMenuPopover.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/PresetMenuPopover.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAc,SAAS,EAAW,MAAM,OAAO,CAAC;AAa/E,OAAO,KAAK,EAAE,SAAS,EAA6B,MAAM,oBAAoB,CAAC;AAO/E,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACxC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAcD,QAAA,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,sBAAsB,CA2FhE,CAAC;AACF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect } from 'react';
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import Popover from '../Popover';
|
|
5
|
-
import {
|
|
5
|
+
import { TouchDialog } from '../Dialog/TouchDialog';
|
|
6
|
+
import { useConsolidatedRef, useDirection, useOuterEvent, useEscape, useI18n, useUID } from '../../hooks';
|
|
6
7
|
import Menu from '../Menu';
|
|
7
8
|
import { defaultThemeProp } from '../../theme';
|
|
8
9
|
import Flex from '../Flex';
|
|
9
|
-
import { getFocusables } from '../../utils';
|
|
10
|
+
import { getFocusables, isTouchDevice } from '../../utils';
|
|
10
11
|
import Text from '../Text';
|
|
11
12
|
const StyledPresetMenuPopover = styled(Popover)(({ theme: { base: { 'content-width': contentWidth } } }) => {
|
|
12
13
|
return css `
|
|
@@ -15,7 +16,10 @@ const StyledPresetMenuPopover = styled(Popover)(({ theme: { base: { 'content-wid
|
|
|
15
16
|
});
|
|
16
17
|
StyledPresetMenuPopover.defaultProps = defaultThemeProp;
|
|
17
18
|
const PresetMenuPopover = ({ heading, buttonRef, menu, isOpen, onClose }) => {
|
|
19
|
+
const t = useI18n();
|
|
18
20
|
const popoverRef = useConsolidatedRef();
|
|
21
|
+
const dialogRef = useRef(null);
|
|
22
|
+
const menuRef = useConsolidatedRef();
|
|
19
23
|
const { rtl } = useDirection();
|
|
20
24
|
const headingId = useUID();
|
|
21
25
|
useEscape(e => {
|
|
@@ -25,7 +29,7 @@ const PresetMenuPopover = ({ heading, buttonRef, menu, isOpen, onClose }) => {
|
|
|
25
29
|
}
|
|
26
30
|
}, buttonRef);
|
|
27
31
|
useOuterEvent(['mousedown', 'focusin'], [popoverRef], () => {
|
|
28
|
-
if (isOpen) {
|
|
32
|
+
if (isOpen && !isTouchDevice) {
|
|
29
33
|
onClose();
|
|
30
34
|
}
|
|
31
35
|
});
|
|
@@ -33,7 +37,14 @@ const PresetMenuPopover = ({ heading, buttonRef, menu, isOpen, onClose }) => {
|
|
|
33
37
|
if (isOpen)
|
|
34
38
|
getFocusables(popoverRef)[0]?.focus();
|
|
35
39
|
}, [isOpen]);
|
|
36
|
-
return (_jsx(
|
|
40
|
+
return isTouchDevice ? (_jsx(TouchDialog, { open: isOpen, onDismiss: onClose, ref: dialogRef, heading: heading, "aria-label": heading ? undefined : t('menu_option_list'), onAfterOpen: () => menuRef.current?.focus(),
|
|
41
|
+
// Focus back to the button explicitly as touch dialog could have been opened from another touch dialog.
|
|
42
|
+
onAfterClose: () => buttonRef.current?.focus(), children: menu && (_jsx(Menu, { ...menu, ref: menuRef, items: menu.items, onItemClick: (itemId, e) => {
|
|
43
|
+
if (menu?.mode !== 'multi-select') {
|
|
44
|
+
onClose();
|
|
45
|
+
}
|
|
46
|
+
menu?.onItemClick?.(itemId, e);
|
|
47
|
+
} })) })) : (_jsx(StyledPresetMenuPopover, { placement: rtl ? 'bottom-end' : 'bottom-start', hideOnTargetHidden: true, show: !!menu && isOpen, target: buttonRef?.current, ref: popoverRef, "aria-labelledby": headingId, children: menu && (_jsxs(_Fragment, { children: [_jsx(Flex, { container: { pad: [1, 2] }, children: _jsx(Text, { variant: 'h3', id: headingId, children: heading }) }), _jsx(Menu, { ...menu, items: menu.items, onItemClick: (itemId, e) => {
|
|
37
48
|
if (menu?.mode !== 'multi-select' &&
|
|
38
49
|
e
|
|
39
50
|
.detail > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresetMenuPopover.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/PresetMenuPopover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PresetMenuPopover.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/PresetMenuPopover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,SAAS,EACT,OAAO,EACP,MAAM,EACP,MAAM,aAAa,CAAC;AAErB,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;A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OACC,IAAI,EACR,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBACzB,IACE,IAAI,EAAE,IAAI,KAAK,cAAc;4BAC5B,CAAgF;iCAC9E,MAAM,GAAG,CAAC,EACb,CAAC;4BACD,OAAO,EAAE,CAAC;wBACZ,CAAC;wBACD,IAAI,EAAE,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;oBACjC,CAAC,EACD,cAAc,EAAE,SAAS,EAAE,OAAO,IAAI,SAAS,GAC/C,IACD,CACJ,GACuB,CAC3B,CAAC;AACJ,CAAC,CAAC;AACF,eAAe,iBAAiB,CAAC","sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { FunctionComponent, MouseEvent, RefObject, UIEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Popover from '../Popover';\nimport { TouchDialog } from '../Dialog/TouchDialog';\nimport {\n useConsolidatedRef,\n useDirection,\n useOuterEvent,\n useEscape,\n useI18n,\n useUID\n} from '../../hooks';\nimport type { MenuProps, AcceptedMouseEventElement } from '../Menu/Menu.types';\nimport Menu from '../Menu';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport { getFocusables, isTouchDevice } from '../../utils';\nimport Text from '../Text';\n\nexport interface PresetMenuPopoverProps {\n heading?: string;\n buttonRef: RefObject<HTMLButtonElement>;\n menu?: MenuProps;\n isOpen: boolean;\n onClose: () => void;\n}\n\nconst StyledPresetMenuPopover = styled(Popover)(({\n theme: {\n base: { 'content-width': contentWidth }\n }\n}) => {\n return css`\n min-width: ${contentWidth.xs};\n `;\n});\n\nStyledPresetMenuPopover.defaultProps = defaultThemeProp;\n\nconst PresetMenuPopover: FunctionComponent<PresetMenuPopoverProps> = ({\n heading,\n buttonRef,\n menu,\n isOpen,\n onClose\n}: PresetMenuPopoverProps) => {\n const t = useI18n();\n const popoverRef = useConsolidatedRef<HTMLDivElement>();\n const dialogRef = useRef<HTMLDivElement>(null);\n const menuRef = useConsolidatedRef<HTMLDivElement>();\n const { rtl } = useDirection();\n const headingId = useUID();\n\n useEscape(e => {\n if (isOpen) {\n onClose();\n e.stopPropagation();\n }\n }, buttonRef);\n\n useOuterEvent(['mousedown', 'focusin'], [popoverRef], () => {\n if (isOpen && !isTouchDevice) {\n onClose();\n }\n });\n\n useEffect(() => {\n if (isOpen) getFocusables(popoverRef)[0]?.focus();\n }, [isOpen]);\n\n return isTouchDevice ? (\n <TouchDialog\n open={isOpen}\n onDismiss={onClose}\n ref={dialogRef}\n heading={heading}\n aria-label={heading ? undefined : t('menu_option_list')}\n onAfterOpen={() => menuRef.current?.focus()}\n // Focus back to the button explicitly as touch dialog could have been opened from another touch dialog.\n onAfterClose={() => buttonRef.current?.focus()}\n >\n {menu && (\n <Menu\n {...menu}\n ref={menuRef}\n items={menu.items}\n onItemClick={(itemId, e) => {\n if (menu?.mode !== 'multi-select') {\n onClose();\n }\n menu?.onItemClick?.(itemId, e);\n }}\n />\n )}\n </TouchDialog>\n ) : (\n <StyledPresetMenuPopover\n placement={rtl ? 'bottom-end' : 'bottom-start'}\n hideOnTargetHidden\n show={!!menu && isOpen}\n target={buttonRef?.current}\n ref={popoverRef}\n aria-labelledby={headingId}\n >\n {menu && (\n <>\n <Flex container={{ pad: [1, 2] }}>\n <Text variant='h3' id={headingId}>\n {heading}\n </Text>\n </Flex>\n <Menu\n {...menu}\n items={menu.items}\n onItemClick={(itemId, e) => {\n if (\n menu?.mode !== 'multi-select' &&\n (e as MouseEvent<AcceptedMouseEventElement> & UIEvent<AcceptedMouseEventElement>)\n .detail > 0\n ) {\n onClose();\n }\n menu?.onItemClick?.(itemId, e);\n }}\n focusControlEl={buttonRef?.current ?? undefined}\n />\n </>\n )}\n </StyledPresetMenuPopover>\n );\n};\nexport default PresetMenuPopover;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuButton.d.ts","sourceRoot":"","sources":["../../../src/components/MenuButton/MenuButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EAIjB,oBAAoB,EAErB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,SAAS,EACT,+BAA+B,EAC/B,cAAc,EACd,UAAU,EACV,UAAU,EACX,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"MenuButton.d.ts","sourceRoot":"","sources":["../../../src/components/MenuButton/MenuButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EAIjB,oBAAoB,EAErB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,SAAS,EACT,+BAA+B,EAC/B,cAAc,EACd,UAAU,EACV,UAAU,EACX,MAAM,aAAa,CAAC;AAarB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAKpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAclD,MAAM,WAAW,eAAgB,SAAQ,SAAS,EAAE,cAAc,EAAE,UAAU;IAC5E,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACjC,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/B,qEAAqE;IACrE,KAAK,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/B,4CAA4C;IAC5C,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,0BAA0B;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC,CAAC;IACnE,qCAAqC;IACrC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,GAAG,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IACzB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,gBAAgB,yOAiB5B,CAAC;;;;AAwSF,wBAA6D"}
|
|
@@ -3,6 +3,7 @@ import { forwardRef, useState, useCallback } from 'react';
|
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import { defaultThemeProp } from '../../theme';
|
|
5
5
|
import { useConsolidatedRef, useUID, useFocusWithin, useDirection, useTestIds, useEscape, useElement } from '../../hooks';
|
|
6
|
+
import { TouchDialog } from '../Dialog/TouchDialog';
|
|
6
7
|
import Button, { StyledButton } from '../Button';
|
|
7
8
|
import Popover, { StyledPopover } from '../Popover';
|
|
8
9
|
import Menu from '../Menu';
|
|
@@ -10,7 +11,8 @@ import Icon, { registerIcon, StyledIcon } from '../Icon';
|
|
|
10
11
|
import * as arrowMicroDownIcon from '../Icon/icons/arrow-micro-down.icon';
|
|
11
12
|
import Flex from '../Flex';
|
|
12
13
|
import { Count } from '../Badges';
|
|
13
|
-
import { getActiveElement, getFocusables, isInstance, withTestIds } from '../../utils';
|
|
14
|
+
import { getActiveElement, getFocusables, isInstance, isTouchDevice, withTestIds } from '../../utils';
|
|
15
|
+
import { StyledMenu, StyledMenuListWrapper } from '../Menu/Menu.styles';
|
|
14
16
|
import { getMenuButtonTestIds } from './MenuButton.test-ids';
|
|
15
17
|
registerIcon(arrowMicroDownIcon);
|
|
16
18
|
export const StyledMenuButton = styled.button(({ theme: { base: { spacing } } }) => {
|
|
@@ -54,6 +56,16 @@ StyledMenuButtonChildren.defaultProps = defaultThemeProp;
|
|
|
54
56
|
const StyledMenuButtonPopover = styled(Popover) `
|
|
55
57
|
min-width: 20ch;
|
|
56
58
|
`;
|
|
59
|
+
const StyledMenuTouchDialog = styled(TouchDialog) `
|
|
60
|
+
${StyledMenu} {
|
|
61
|
+
height: 100%;
|
|
62
|
+
|
|
63
|
+
${StyledMenuListWrapper} {
|
|
64
|
+
flex-grow: 1;
|
|
65
|
+
overflow: auto;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
57
69
|
const MenuButton = forwardRef(function MenuButton(props, ref) {
|
|
58
70
|
const uid = useUID();
|
|
59
71
|
const { testId, id = uid, text, menu, popover, onClick, icon, count, iconOnly = false, showArrow, onKeyDown: onKeyDownProp, ...restProps } = props;
|
|
@@ -63,10 +75,11 @@ const MenuButton = forwardRef(function MenuButton(props, ref) {
|
|
|
63
75
|
// Force re-render when popoverRef is set, so useFocusWithin has a non-null ref to read
|
|
64
76
|
const [, forceRerender] = useElement(null);
|
|
65
77
|
const popoverRef = useConsolidatedRef(popover?.ref, forceRerender);
|
|
78
|
+
const dialogRef = useConsolidatedRef(popover?.ref);
|
|
66
79
|
const filterInputRef = useConsolidatedRef(menu?.filterInputProps?.ref);
|
|
67
80
|
const menuRef = useConsolidatedRef(menu?.ref);
|
|
68
81
|
// FIXME: Type assertion required for issue in useFocusWithin generic
|
|
69
|
-
useFocusWithin([popoverRef, buttonRef], useCallback((isFocused) => {
|
|
82
|
+
useFocusWithin([popoverRef, dialogRef, buttonRef], useCallback((isFocused) => {
|
|
70
83
|
if (!isFocused)
|
|
71
84
|
setIsOpen(false);
|
|
72
85
|
}, []));
|
|
@@ -107,9 +120,11 @@ const MenuButton = forwardRef(function MenuButton(props, ref) {
|
|
|
107
120
|
return;
|
|
108
121
|
}
|
|
109
122
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
123
|
+
// Do not close the drawer when the user is tabbing backwards.
|
|
124
|
+
if (!isTouchDevice)
|
|
125
|
+
setIsOpen(false);
|
|
126
|
+
}, [menu, isTouchDevice, onKeyDownProp]);
|
|
127
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { "data-testid": testIds.root, as: StyledMenuButton, "aria-label": text, ...restProps, id: id, ref: buttonRef, "aria-expanded": isOpen, "aria-haspopup": isTouchDevice ? 'dialog' : 'menu', "aria-controls": isOpen ? `${id}-${isTouchDevice ? 'dialog' : 'popover'}` : undefined, label: iconOnly && !isOpen ? text : undefined, onClick: (e) => {
|
|
113
128
|
// e.detail is 0 when triggered by keyboard.
|
|
114
129
|
const mouseClick = e.detail > 0;
|
|
115
130
|
if (isOpen) {
|
|
@@ -127,7 +142,18 @@ const MenuButton = forwardRef(function MenuButton(props, ref) {
|
|
|
127
142
|
if (!isOpen || mouseClick) {
|
|
128
143
|
onClick?.(e);
|
|
129
144
|
}
|
|
130
|
-
}, onKeyDown: onKeyDown, icon: iconOnly, children: _jsxs(Flex, { as: StyledMenuButtonChildren, container: { alignItems: 'center', gap: 1 }, padIcon: iconOnly && showArrow, children: [icon && _jsx(Icon, { name: icon }), !iconOnly && (_jsxs(_Fragment, { children: [_jsx(StyledMenuButtonText, { children: text }), typeof count === 'number' && _jsx(Count, { children: count })] })), ((!iconOnly && showArrow === undefined) || showArrow) && (_jsx(Icon, { name: 'arrow-micro-down' }))] }) }), _jsx(
|
|
145
|
+
}, onKeyDown: onKeyDown, icon: iconOnly, children: _jsxs(Flex, { as: StyledMenuButtonChildren, container: { alignItems: 'center', gap: 1 }, padIcon: iconOnly && showArrow, children: [icon && _jsx(Icon, { name: icon }), !iconOnly && (_jsxs(_Fragment, { children: [_jsx(StyledMenuButtonText, { children: text }), typeof count === 'number' && _jsx(Count, { children: count })] })), ((!iconOnly && showArrow === undefined) || showArrow) && (_jsx(Icon, { name: 'arrow-micro-down' }))] }) }), isTouchDevice ? (_jsx(StyledMenuTouchDialog, { ref: dialogRef, open: !!menu && isOpen, onDismiss: () => {
|
|
146
|
+
setIsOpen(false);
|
|
147
|
+
}, id: `${id}-dialog`, heading: text, onAfterClose: () => {
|
|
148
|
+
if (dialogRef.current?.contains(getActiveElement())) {
|
|
149
|
+
buttonRef.current?.focus();
|
|
150
|
+
}
|
|
151
|
+
}, children: menu && (_jsx(Menu, { testId: testIds.root, ...menu, ref: menuRef, loading: menu.loading, scrollAt: Infinity, items: menu.items, onItemClick: (itemId, e) => {
|
|
152
|
+
if (menu.mode !== 'multi-select') {
|
|
153
|
+
setIsOpen(false);
|
|
154
|
+
}
|
|
155
|
+
menu.onItemClick?.(itemId, e);
|
|
156
|
+
}, focusControlEl: undefined })) })) : (_jsx(StyledMenuButtonPopover, { placement: rtl ? 'bottom-end' : 'bottom-start', hideOnTargetHidden: true, ...popover, id: `${id}-popover`, show: !!menu && isOpen, target: buttonRef.current, ref: popoverRef, onKeyDown: (e) => {
|
|
131
157
|
if (e.key !== 'Tab' || !buttonRef.current)
|
|
132
158
|
return;
|
|
133
159
|
const footerEl = menuRef.current?.querySelector('footer');
|
|
@@ -160,7 +186,7 @@ const MenuButton = forwardRef(function MenuButton(props, ref) {
|
|
|
160
186
|
buttonRef.current?.focus();
|
|
161
187
|
}
|
|
162
188
|
menu.onItemClick?.(itemId, e);
|
|
163
|
-
}, focusControlEl: menu.focusControlEl || buttonRef.current || undefined })) })] }));
|
|
189
|
+
}, focusControlEl: menu.focusControlEl || buttonRef.current || undefined })) }))] }));
|
|
164
190
|
});
|
|
165
191
|
export default withTestIds(MenuButton, getMenuButtonTestIds);
|
|
166
192
|
//# sourceMappingURL=MenuButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuButton.js","sourceRoot":"","sources":["../../../src/components/MenuButton/MenuButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAS1D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAShD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,O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,EAAE,CAAC,EAAE,EAAE;wBACzB,iGAAiG;wBACjG,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;4BACjC,SAAS,CAAC,KAAK,CAAC,CAAC;4BACjB,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;wBAC7B,CAAC;wBACD,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;oBAChC,CAAC,EACD,cAAc,EAAE,IAAI,CAAC,cAAc,IAAI,SAAS,CAAC,OAAO,IAAI,SAAS,GACrE,CACH,GACuB,IACzB,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { forwardRef, useState, useCallback } from 'react';\nimport type {\n MouseEventHandler,\n MouseEvent,\n UIEvent,\n PropsWithoutRef,\n KeyboardEventHandler,\n KeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type {\n BaseProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp,\n OmitStrict,\n TestIdProp\n} from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport {\n useConsolidatedRef,\n useUID,\n useFocusWithin,\n useDirection,\n useTestIds,\n useEscape,\n useElement\n} from '../../hooks';\nimport Button, { StyledButton } from '../Button';\nimport type { ButtonProps } from '../Button';\nimport Popover, { StyledPopover } from '../Popover';\nimport type { PopoverProps } from '../Popover';\nimport Menu from '../Menu';\nimport type { MenuProps } from '../Menu/Menu.types';\nimport Icon, { registerIcon, StyledIcon } from '../Icon';\nimport * as arrowMicroDownIcon from '../Icon/icons/arrow-micro-down.icon';\nimport Flex from '../Flex';\nimport { Count } from '../Badges';\nimport type { CountProps } from '../Badges/Count';\nimport { getActiveElement, getFocusables, isInstance, withTestIds } from '../../utils';\n\nimport { getMenuButtonTestIds } from './MenuButton.test-ids';\n\nregisterIcon(arrowMicroDownIcon);\n\nexport interface MenuButtonProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** The text for the MenuButton also used to set the aria-label. */\n text: string;\n /**\n * Determines the Button variant for the MenuButton.\n * @default 'secondary'\n */\n variant?: ButtonProps['variant'];\n /** The name of the icon for the MenuButton. */\n icon?: string;\n /** Only display the icon. The text prop will be forwarded to a tooltip. */\n iconOnly?: ButtonProps['icon'];\n /** The total count representing the list data which was selected. */\n count?: CountProps['children'];\n /** The click handler for the MenuButton. */\n onClick?: MouseEventHandler;\n /** Menu related props. */\n menu?: MenuProps;\n /** Popover related props. */\n popover?: OmitStrict<PopoverProps, 'show' | 'target' | 'children'>;\n /** DOM id for the button element. */\n id?: string;\n /** Ref for the button element. */\n ref?: ButtonProps['ref'];\n /** The keydown handler for the MenuButton. */\n onKeyDown?: KeyboardEventHandler;\n /** Whether to display an arrow when only the icon is displayed. */\n showArrow?: boolean;\n}\n\nexport const StyledMenuButton = styled.button(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n gap: ${spacing};\n flex-shrink: 0;\n white-space: nowrap;\n max-width: 100%;\n\n & + ${StyledPopover} + ${StyledButton} {\n margin-inline-start: ${spacing};\n }\n `;\n }\n);\n\nStyledMenuButton.defaultProps = defaultThemeProp;\n\nconst StyledMenuButtonText = styled.span`\n text-overflow: ellipsis;\n overflow: hidden;\n`;\n\nconst StyledMenuButtonChildren = styled.span<{ padIcon?: boolean }>(({ theme, padIcon }) => {\n const {\n base: {\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n },\n components: {\n icon: {\n size: { s: iconSize }\n }\n }\n } = theme;\n\n return css`\n max-width: 100%;\n\n ${padIcon &&\n css`\n padding-inline-start: calc((${hitAreaMouse} - ${iconSize}) / 2);\n\n @media (pointer: coarse) {\n padding-inline-start: calc(${hitAreaFinger} - ${iconSize} * 2);\n }\n `}\n\n ${StyledIcon}:last-child:not(:first-child) {\n /* Offsets the flex gap to make the down arrow appear to trail the text. */\n margin-inline-start: -${theme.base.spacing};\n }\n `;\n});\n\nStyledMenuButtonChildren.defaultProps = defaultThemeProp;\n\nconst StyledMenuButtonPopover = styled(Popover)`\n min-width: 20ch;\n`;\n\nconst MenuButton: ForwardRefForwardPropsComponent<MenuButtonProps> = forwardRef(function MenuButton(\n props: PropsWithoutRef<MenuButtonProps>,\n ref: MenuButtonProps['ref']\n) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n text,\n menu,\n popover,\n onClick,\n icon,\n count,\n iconOnly = false,\n showArrow,\n onKeyDown: onKeyDownProp,\n ...restProps\n } = props;\n const testIds = useTestIds(testId, getMenuButtonTestIds);\n const [isOpen, setIsOpen] = useState(false);\n\n const buttonRef = useConsolidatedRef(ref);\n // Force re-render when popoverRef is set, so useFocusWithin has a non-null ref to read\n const [, forceRerender] = useElement(null);\n const popoverRef = useConsolidatedRef<HTMLDivElement>(popover?.ref, forceRerender);\n const filterInputRef = useConsolidatedRef<HTMLInputElement>(menu?.filterInputProps?.ref);\n const menuRef = useConsolidatedRef<HTMLDivElement>(menu?.ref);\n\n // FIXME: Type assertion required for issue in useFocusWithin generic\n useFocusWithin<HTMLElement>(\n [popoverRef, buttonRef],\n useCallback((isFocused: boolean) => {\n if (!isFocused) setIsOpen(false);\n }, [])\n );\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n }\n }, buttonRef);\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n buttonRef.current?.focus();\n }\n }, menu?.focusControlEl);\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n buttonRef.current?.focus();\n }\n }, filterInputRef);\n\n const { rtl } = useDirection();\n\n const onKeyDown = useCallback(\n (e: KeyboardEvent) => {\n onKeyDownProp?.(e);\n if (e.key !== 'Tab' || !menu) return;\n\n const footerEl = menuRef.current?.querySelector('footer');\n if (!footerEl) return;\n\n const tabbingForward = !e.shiftKey;\n\n if (tabbingForward) {\n const footerFocusables = getFocusables(footerEl);\n\n if (footerFocusables.length > 0) {\n e.preventDefault();\n footerFocusables[0].focus();\n return;\n }\n }\n\n setIsOpen(false);\n },\n [menu]\n );\n\n return (\n <>\n <Button\n data-testid={testIds.root}\n as={StyledMenuButton}\n aria-label={text}\n {...restProps}\n id={id}\n ref={buttonRef}\n aria-expanded={isOpen}\n aria-haspopup='menu'\n aria-controls={isOpen ? `${id}-popover` : undefined}\n label={iconOnly && !isOpen ? text : undefined}\n onClick={(e: MouseEvent<HTMLButtonElement> & UIEvent<HTMLButtonElement>) => {\n // e.detail is 0 when triggered by keyboard.\n const mouseClick = e.detail > 0;\n\n if (isOpen) {\n if (mouseClick) {\n // Close the menu if it is open and it is a *mouse* click on the button.\n setIsOpen(false);\n }\n } else {\n // Open the menu if it's closed, for mouse or keyboard click.\n setIsOpen(true);\n }\n\n // If the menu is closed or the user mouse clicks.\n // This avoids Enter key firing onClick when selecting a menu item.\n if (!isOpen || mouseClick) {\n onClick?.(e);\n }\n }}\n onKeyDown={onKeyDown}\n icon={iconOnly}\n >\n <Flex\n as={StyledMenuButtonChildren}\n container={{ alignItems: 'center', gap: 1 }}\n padIcon={iconOnly && showArrow}\n >\n {icon && <Icon name={icon} />}\n {!iconOnly && (\n <>\n <StyledMenuButtonText>{text}</StyledMenuButtonText>\n {typeof count === 'number' && <Count>{count}</Count>}\n </>\n )}\n {((!iconOnly && showArrow === undefined) || showArrow) && (\n <Icon name='arrow-micro-down' />\n )}\n </Flex>\n </Button>\n\n <StyledMenuButtonPopover\n placement={rtl ? 'bottom-end' : 'bottom-start'}\n hideOnTargetHidden\n {...popover}\n id={`${id}-popover`}\n show={!!menu && isOpen}\n target={buttonRef.current}\n ref={popoverRef}\n onKeyDown={(e: KeyboardEvent) => {\n if (e.key !== 'Tab' || !buttonRef.current) return;\n\n const footerEl = menuRef.current?.querySelector('footer');\n if (!footerEl || !footerEl?.contains(getActiveElement())) return;\n\n const footerFocusables = getFocusables(footerEl);\n\n if (isInstance(e.target, HTMLElement)) {\n const currentIndex = footerFocusables.indexOf(e.target);\n const tabbingForward = !e.shiftKey;\n const isLastFocusable = currentIndex === footerFocusables.length - 1;\n\n if (tabbingForward && isLastFocusable) {\n e.preventDefault();\n const rootNode = buttonRef.current.getRootNode();\n if (!isInstance(rootNode, Document, ShadowRoot)) return;\n\n const allFocusables = getFocusables(rootNode);\n const nextIndex = allFocusables.indexOf(buttonRef.current) + 1;\n\n allFocusables[nextIndex]?.focus();\n setIsOpen(false);\n } else if (!tabbingForward && currentIndex === 0) {\n e.preventDefault();\n buttonRef.current?.focus();\n }\n }\n }}\n >\n {menu && (\n <Menu\n testId={testIds.root}\n {...menu}\n ref={menuRef}\n loading={menu.loading}\n items={menu.items}\n onItemClick={(itemId, e) => {\n // When clicking an item (by mouse or keyboard) and the menu is not multi-select, close the menu.\n if (menu.mode !== 'multi-select') {\n setIsOpen(false);\n buttonRef.current?.focus();\n }\n menu.onItemClick?.(itemId, e);\n }}\n focusControlEl={menu.focusControlEl || buttonRef.current || undefined}\n />\n )}\n </StyledMenuButtonPopover>\n </>\n );\n});\n\nexport default withTestIds(MenuButton, getMenuButtonTestIds);\n"]}
|
|
1
|
+
{"version":3,"file":"MenuButton.js","sourceRoot":"","sources":["../../../src/components/MenuButton/MenuButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAS1D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAShD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,cAAc,EACd,YAAY,EACZ,UAAU,EACV,SAAS,EACT,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,OAAO,EAAE,EA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BACjG,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;4BACjC,SAAS,CAAC,KAAK,CAAC,CAAC;4BACjB,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;wBAC7B,CAAC;wBACD,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;oBAChC,CAAC,EACD,cAAc,EAAE,IAAI,CAAC,cAAc,IAAI,SAAS,CAAC,OAAO,IAAI,SAAS,GACrE,CACH,GACuB,CAC3B,IACA,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { forwardRef, useState, useCallback } from 'react';\nimport type {\n MouseEventHandler,\n MouseEvent,\n UIEvent,\n PropsWithoutRef,\n KeyboardEventHandler,\n KeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type {\n BaseProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp,\n OmitStrict,\n TestIdProp\n} from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport {\n useConsolidatedRef,\n useUID,\n useFocusWithin,\n useDirection,\n useTestIds,\n useEscape,\n useElement\n} from '../../hooks';\nimport { TouchDialog } from '../Dialog/TouchDialog';\nimport Button, { StyledButton } from '../Button';\nimport type { ButtonProps } from '../Button';\nimport Popover, { StyledPopover } from '../Popover';\nimport type { PopoverProps } from '../Popover';\nimport Menu from '../Menu';\nimport type { MenuProps } from '../Menu/Menu.types';\nimport Icon, { registerIcon, StyledIcon } from '../Icon';\nimport * as arrowMicroDownIcon from '../Icon/icons/arrow-micro-down.icon';\nimport Flex from '../Flex';\nimport { Count } from '../Badges';\nimport type { CountProps } from '../Badges/Count';\nimport {\n getActiveElement,\n getFocusables,\n isInstance,\n isTouchDevice,\n withTestIds\n} from '../../utils';\nimport { StyledMenu, StyledMenuListWrapper } from '../Menu/Menu.styles';\n\nimport { getMenuButtonTestIds } from './MenuButton.test-ids';\n\nregisterIcon(arrowMicroDownIcon);\n\nexport interface MenuButtonProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** The text for the MenuButton also used to set the aria-label. */\n text: string;\n /**\n * Determines the Button variant for the MenuButton.\n * @default 'secondary'\n */\n variant?: ButtonProps['variant'];\n /** The name of the icon for the MenuButton. */\n icon?: string;\n /** Only display the icon. The text prop will be forwarded to a tooltip. */\n iconOnly?: ButtonProps['icon'];\n /** The total count representing the list data which was selected. */\n count?: CountProps['children'];\n /** The click handler for the MenuButton. */\n onClick?: MouseEventHandler;\n /** Menu related props. */\n menu?: MenuProps;\n /** Popover related props. */\n popover?: OmitStrict<PopoverProps, 'show' | 'target' | 'children'>;\n /** DOM id for the button element. */\n id?: string;\n /** Ref for the button element. */\n ref?: ButtonProps['ref'];\n /** The keydown handler for the MenuButton. */\n onKeyDown?: KeyboardEventHandler;\n /** Whether to display an arrow when only the icon is displayed. */\n showArrow?: boolean;\n}\n\nexport const StyledMenuButton = styled.button(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n gap: ${spacing};\n flex-shrink: 0;\n white-space: nowrap;\n max-width: 100%;\n\n & + ${StyledPopover} + ${StyledButton} {\n margin-inline-start: ${spacing};\n }\n `;\n }\n);\n\nStyledMenuButton.defaultProps = defaultThemeProp;\n\nconst StyledMenuButtonText = styled.span`\n text-overflow: ellipsis;\n overflow: hidden;\n`;\n\nconst StyledMenuButtonChildren = styled.span<{ padIcon?: boolean }>(({ theme, padIcon }) => {\n const {\n base: {\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n },\n components: {\n icon: {\n size: { s: iconSize }\n }\n }\n } = theme;\n\n return css`\n max-width: 100%;\n\n ${padIcon &&\n css`\n padding-inline-start: calc((${hitAreaMouse} - ${iconSize}) / 2);\n\n @media (pointer: coarse) {\n padding-inline-start: calc(${hitAreaFinger} - ${iconSize} * 2);\n }\n `}\n\n ${StyledIcon}:last-child:not(:first-child) {\n /* Offsets the flex gap to make the down arrow appear to trail the text. */\n margin-inline-start: -${theme.base.spacing};\n }\n `;\n});\n\nStyledMenuButtonChildren.defaultProps = defaultThemeProp;\n\nconst StyledMenuButtonPopover = styled(Popover)`\n min-width: 20ch;\n`;\n\nconst StyledMenuTouchDialog = styled(TouchDialog)`\n ${StyledMenu} {\n height: 100%;\n\n ${StyledMenuListWrapper} {\n flex-grow: 1;\n overflow: auto;\n }\n }\n`;\n\nconst MenuButton: ForwardRefForwardPropsComponent<MenuButtonProps> = forwardRef(function MenuButton(\n props: PropsWithoutRef<MenuButtonProps>,\n ref: MenuButtonProps['ref']\n) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n text,\n menu,\n popover,\n onClick,\n icon,\n count,\n iconOnly = false,\n showArrow,\n onKeyDown: onKeyDownProp,\n ...restProps\n } = props;\n const testIds = useTestIds(testId, getMenuButtonTestIds);\n const [isOpen, setIsOpen] = useState(false);\n\n const buttonRef = useConsolidatedRef(ref);\n // Force re-render when popoverRef is set, so useFocusWithin has a non-null ref to read\n const [, forceRerender] = useElement(null);\n const popoverRef = useConsolidatedRef<HTMLDivElement>(popover?.ref, forceRerender);\n const dialogRef = useConsolidatedRef<HTMLDivElement>(popover?.ref);\n const filterInputRef = useConsolidatedRef<HTMLInputElement>(menu?.filterInputProps?.ref);\n const menuRef = useConsolidatedRef<HTMLDivElement>(menu?.ref);\n\n // FIXME: Type assertion required for issue in useFocusWithin generic\n useFocusWithin<HTMLElement>(\n [popoverRef, dialogRef, buttonRef],\n useCallback((isFocused: boolean) => {\n if (!isFocused) setIsOpen(false);\n }, [])\n );\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n }\n }, buttonRef);\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n buttonRef.current?.focus();\n }\n }, menu?.focusControlEl);\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n buttonRef.current?.focus();\n }\n }, filterInputRef);\n\n const { rtl } = useDirection();\n\n const onKeyDown = useCallback(\n (e: KeyboardEvent) => {\n onKeyDownProp?.(e);\n if (e.key !== 'Tab' || !menu) return;\n\n const footerEl = menuRef.current?.querySelector('footer');\n if (!footerEl) return;\n\n const tabbingForward = !e.shiftKey;\n\n if (tabbingForward) {\n const footerFocusables = getFocusables(footerEl);\n\n if (footerFocusables.length > 0) {\n e.preventDefault();\n footerFocusables[0].focus();\n return;\n }\n }\n\n // Do not close the drawer when the user is tabbing backwards.\n if (!isTouchDevice) setIsOpen(false);\n },\n [menu, isTouchDevice, onKeyDownProp]\n );\n\n return (\n <>\n <Button\n data-testid={testIds.root}\n as={StyledMenuButton}\n aria-label={text}\n {...restProps}\n id={id}\n ref={buttonRef}\n aria-expanded={isOpen}\n aria-haspopup={isTouchDevice ? 'dialog' : 'menu'}\n aria-controls={isOpen ? `${id}-${isTouchDevice ? 'dialog' : 'popover'}` : undefined}\n label={iconOnly && !isOpen ? text : undefined}\n onClick={(e: MouseEvent<HTMLButtonElement> & UIEvent<HTMLButtonElement>) => {\n // e.detail is 0 when triggered by keyboard.\n const mouseClick = e.detail > 0;\n\n if (isOpen) {\n if (mouseClick) {\n // Close the menu if it is open and it is a *mouse* click on the button.\n setIsOpen(false);\n }\n } else {\n // Open the menu if it's closed, for mouse or keyboard click.\n setIsOpen(true);\n }\n\n // If the menu is closed or the user mouse clicks.\n // This avoids Enter key firing onClick when selecting a menu item.\n if (!isOpen || mouseClick) {\n onClick?.(e);\n }\n }}\n onKeyDown={onKeyDown}\n icon={iconOnly}\n >\n <Flex\n as={StyledMenuButtonChildren}\n container={{ alignItems: 'center', gap: 1 }}\n padIcon={iconOnly && showArrow}\n >\n {icon && <Icon name={icon} />}\n {!iconOnly && (\n <>\n <StyledMenuButtonText>{text}</StyledMenuButtonText>\n {typeof count === 'number' && <Count>{count}</Count>}\n </>\n )}\n {((!iconOnly && showArrow === undefined) || showArrow) && (\n <Icon name='arrow-micro-down' />\n )}\n </Flex>\n </Button>\n\n {isTouchDevice ? (\n <StyledMenuTouchDialog\n ref={dialogRef}\n open={!!menu && isOpen}\n onDismiss={() => {\n setIsOpen(false);\n }}\n id={`${id}-dialog`}\n heading={text}\n onAfterClose={() => {\n if (dialogRef.current?.contains(getActiveElement())) {\n buttonRef.current?.focus();\n }\n }}\n >\n {menu && (\n <Menu\n testId={testIds.root}\n {...menu}\n ref={menuRef}\n loading={menu.loading}\n scrollAt={Infinity}\n items={menu.items}\n onItemClick={(itemId, e) => {\n if (menu.mode !== 'multi-select') {\n setIsOpen(false);\n }\n menu.onItemClick?.(itemId, e);\n }}\n focusControlEl={undefined}\n />\n )}\n </StyledMenuTouchDialog>\n ) : (\n <StyledMenuButtonPopover\n placement={rtl ? 'bottom-end' : 'bottom-start'}\n hideOnTargetHidden\n {...popover}\n id={`${id}-popover`}\n show={!!menu && isOpen}\n target={buttonRef.current}\n ref={popoverRef}\n onKeyDown={(e: KeyboardEvent) => {\n if (e.key !== 'Tab' || !buttonRef.current) return;\n\n const footerEl = menuRef.current?.querySelector('footer');\n if (!footerEl || !footerEl?.contains(getActiveElement())) return;\n\n const footerFocusables = getFocusables(footerEl);\n\n if (isInstance(e.target, HTMLElement)) {\n const currentIndex = footerFocusables.indexOf(e.target);\n const tabbingForward = !e.shiftKey;\n const isLastFocusable = currentIndex === footerFocusables.length - 1;\n\n if (tabbingForward && isLastFocusable) {\n e.preventDefault();\n const rootNode = buttonRef.current.getRootNode();\n if (!isInstance(rootNode, Document, ShadowRoot)) return;\n\n const allFocusables = getFocusables(rootNode);\n const nextIndex = allFocusables.indexOf(buttonRef.current) + 1;\n\n allFocusables[nextIndex]?.focus();\n setIsOpen(false);\n } else if (!tabbingForward && currentIndex === 0) {\n e.preventDefault();\n buttonRef.current?.focus();\n }\n }\n }}\n >\n {menu && (\n <Menu\n testId={testIds.root}\n {...menu}\n ref={menuRef}\n loading={menu.loading}\n items={menu.items}\n onItemClick={(itemId, e) => {\n // When clicking an item (by mouse or keyboard) and the menu is not multi-select, close the menu.\n if (menu.mode !== 'multi-select') {\n setIsOpen(false);\n buttonRef.current?.focus();\n }\n menu.onItemClick?.(itemId, e);\n }}\n focusControlEl={menu.focusControlEl || buttonRef.current || undefined}\n />\n )}\n </StyledMenuButtonPopover>\n )}\n </>\n );\n});\n\nexport default withTestIds(MenuButton, getMenuButtonTestIds);\n"]}
|
|
@@ -3,11 +3,17 @@ import type { Step } from './MultiStepForm.types';
|
|
|
3
3
|
export declare const stepItemMinWidth = 15;
|
|
4
4
|
/** Min width of step marker without labels in ch units */
|
|
5
5
|
export declare const stepMarkerMinWidth = 3;
|
|
6
|
+
/** Min width of each bar segment in bars mode in ch units */
|
|
7
|
+
export declare const stepBarMinWidth = 3;
|
|
8
|
+
/** Min height of each vertical bar segment in bars mode */
|
|
9
|
+
export declare const stepVerticalBarMinHeight = "2.5rem";
|
|
6
10
|
export declare const CurrentStepPopover: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("../Popover").PopoverProps<string> & import("../..").ForwardProps, never>> & string & Omit<(<Modifiers extends string = string>(props: import("../Popover").PopoverProps<Modifiers> & import("../..").ForwardProps) => import("react").ReactElement | null), keyof import("react").Component<any, {}, any>>;
|
|
7
11
|
export declare const StyledBar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
8
12
|
shifted?: boolean;
|
|
9
13
|
}>> & string;
|
|
10
|
-
export declare const StyledFill: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").
|
|
14
|
+
export declare const StyledFill: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
15
|
+
fillScale: number;
|
|
16
|
+
}>> & string;
|
|
11
17
|
export declare const StyledFormProgress: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<(Omit<Omit<Pick<import("../Flex/Flex").BaseFlexProps & import("../..").BaseProps & import("../..").AsProp & {
|
|
12
18
|
children?: import("react").ReactNode;
|
|
13
19
|
ref?: import("react").Ref<Element>;
|
|
@@ -211,4 +217,22 @@ export declare const StyledBulletWrapper: import("styled-components/dist/types")
|
|
|
211
217
|
}>> & string;
|
|
212
218
|
export declare const StyledStepText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
213
219
|
export declare const StyledHorizontalStepText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
220
|
+
export declare const StyleHorizontalBarList: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>, {
|
|
221
|
+
showStepNames?: boolean;
|
|
222
|
+
}>> & string;
|
|
223
|
+
export declare const StyledHorizontalBarSegment: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<Omit<import("../Button/BareButton").BareButtonProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement> & import("../..").ForwardProps, "ref"> & {
|
|
224
|
+
ref?: ((instance: HTMLAnchorElement | HTMLButtonElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLAnchorElement | HTMLButtonElement> | null | undefined;
|
|
225
|
+
}, {
|
|
226
|
+
current: boolean;
|
|
227
|
+
completed?: boolean;
|
|
228
|
+
clickable?: boolean;
|
|
229
|
+
}>> & string & Omit<import("../..").ForwardRefForwardPropsComponent<import("../Button/BareButton").BareButtonProps>, keyof import("react").Component<any, {}, any>>;
|
|
230
|
+
export declare const StyledVerticalBarWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
231
|
+
export declare const StyledVerticalBarSegment: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<Omit<import("../Button/BareButton").BareButtonProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement | HTMLButtonElement> & import("../..").ForwardProps, "ref"> & {
|
|
232
|
+
ref?: ((instance: HTMLAnchorElement | HTMLButtonElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLAnchorElement | HTMLButtonElement> | null | undefined;
|
|
233
|
+
}, {
|
|
234
|
+
current: boolean;
|
|
235
|
+
completed?: boolean;
|
|
236
|
+
clickable?: boolean;
|
|
237
|
+
}>> & string & Omit<import("../..").ForwardRefForwardPropsComponent<import("../Button/BareButton").BareButtonProps>, keyof import("react").Component<any, {}, any>>;
|
|
214
238
|
//# sourceMappingURL=FormProgress.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormProgress.styles.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/FormProgress.styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormProgress.styles.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/FormProgress.styles.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAElD,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,0DAA0D;AAC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