@pega/cosmos-react-core 9.17.1 → 9.18.0
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/AppHeader.d.ts.map +1 -1
- package/lib/components/AppShell/AppHeader.js +44 -7
- package/lib/components/AppShell/AppHeader.js.map +1 -1
- package/lib/components/AppShell/AppHeader.styles.d.ts +6 -2
- package/lib/components/AppShell/AppHeader.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppHeader.styles.js +36 -18
- package/lib/components/AppShell/AppHeader.styles.js.map +1 -1
- package/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +28 -9
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShellContext.d.ts +1 -0
- package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellContext.js +1 -0
- package/lib/components/AppShell/AppShellContext.js.map +1 -1
- package/lib/components/Currency/CurrencyInput.d.ts.map +1 -1
- package/lib/components/Currency/CurrencyInput.js +19 -12
- package/lib/components/Currency/CurrencyInput.js.map +1 -1
- package/lib/components/Currency/utils.d.ts +8 -0
- package/lib/components/Currency/utils.d.ts.map +1 -1
- package/lib/components/Currency/utils.js +34 -4
- package/lib/components/Currency/utils.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/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/HorizontalFormProgress.js +1 -1
- package/lib/components/MultiStepForm/HorizontalFormProgress.js.map +1 -1
- package/lib/components/Number/utils.js +1 -1
- package/lib/components/Number/utils.js.map +1 -1
- package/lib/components/ResponsiveActions/ResponsiveActions.d.ts.map +1 -1
- package/lib/components/ResponsiveActions/ResponsiveActions.js +1 -0
- package/lib/components/ResponsiveActions/ResponsiveActions.js.map +1 -1
- package/lib/components/TextArea/TextArea.d.ts.map +1 -1
- package/lib/components/TextArea/TextArea.js +7 -21
- package/lib/components/TextArea/TextArea.js.map +1 -1
- package/lib/components/TextArea/TextArea.styles.d.ts +0 -1
- package/lib/components/TextArea/TextArea.styles.d.ts.map +1 -1
- package/lib/components/TextArea/TextArea.styles.js +1 -2
- package/lib/components/TextArea/TextArea.styles.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +1 -0
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/i18n/default.d.ts +1 -0
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +1 -0
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +1 -0
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/theme/themes/aurigaDarkTheme.json +45 -58
- package/lib/theme/themes/aurigaTheme.json +40 -53
- package/lib/theme/themes/virgoTheme.json +3 -3
- 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,85 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { useConsolidatedRef, useConfiguration, useFocusTrap, useI18n, useTestIds, useEscape, useUID } from '../../hooks';
|
|
5
|
+
import Button from '../Button';
|
|
6
|
+
import Icon, { registerIcon } from '../Icon';
|
|
7
|
+
import Text from '../Text';
|
|
8
|
+
import * as caretUp from '../Icon/icons/caret-up.icon';
|
|
9
|
+
import * as timesIcon from '../Icon/icons/times.icon';
|
|
10
|
+
import Flex from '../Flex';
|
|
11
|
+
import Backdrop from '../Backdrop';
|
|
12
|
+
import { focusNonInteractiveElement, getActiveElement, isInstance } from '../../utils';
|
|
13
|
+
import Progress from '../Progress';
|
|
14
|
+
import { StyledTouchDialogContent, StyledTouchDialogHeader, StyledTouchDialog, StyledExpandCollapse } from './TouchDialog.styles';
|
|
15
|
+
import { getTouchDialogTestIds } from './TouchDialog.test-ids';
|
|
16
|
+
import { StyledChildrenWrap } from './Dialog.styles';
|
|
17
|
+
registerIcon(caretUp, timesIcon);
|
|
18
|
+
const drawerSizeMapping = {
|
|
19
|
+
auto: 'auto',
|
|
20
|
+
half: '50dvh',
|
|
21
|
+
full: '90dvh'
|
|
22
|
+
};
|
|
23
|
+
export const TouchDialog = forwardRef(function TouchDialog({ open, onDismiss: onDismissProp, children, size = 'half', onBeforeOpen, onAfterOpen: onAfterOpenProp, onBeforeClose, onAfterClose, heading, progress: progressProp, testId, ...restProps }, ref) {
|
|
24
|
+
const dialogRef = useConsolidatedRef(ref);
|
|
25
|
+
const t = useI18n();
|
|
26
|
+
const { portalTarget } = useConfiguration();
|
|
27
|
+
const headingRef = useRef(null);
|
|
28
|
+
const [drawerSize, setDrawerSize] = useState(size);
|
|
29
|
+
const headingId = useUID();
|
|
30
|
+
const testIds = useTestIds(testId, getTouchDialogTestIds);
|
|
31
|
+
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
32
|
+
const returnRef = useRef(null);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
setDrawerSize(size);
|
|
35
|
+
}, [size]);
|
|
36
|
+
const isAutoSize = size === 'auto';
|
|
37
|
+
useFocusTrap(open && drawerOpen ? dialogRef : null, true, [open, drawerOpen]);
|
|
38
|
+
const setFocus = useCallback(() => {
|
|
39
|
+
if (progressProp || !drawerOpen || dialogRef.current?.contains(getActiveElement()))
|
|
40
|
+
return;
|
|
41
|
+
if (headingRef.current) {
|
|
42
|
+
focusNonInteractiveElement(headingRef.current, heading);
|
|
43
|
+
}
|
|
44
|
+
else if (dialogRef.current) {
|
|
45
|
+
focusNonInteractiveElement(dialogRef.current, heading);
|
|
46
|
+
}
|
|
47
|
+
}, [progressProp, drawerOpen, heading]);
|
|
48
|
+
const onDismiss = useCallback(() => {
|
|
49
|
+
setDrawerOpen(false);
|
|
50
|
+
onDismissProp?.();
|
|
51
|
+
}, [onDismissProp]);
|
|
52
|
+
const onAfterOpen = useCallback(() => {
|
|
53
|
+
onAfterOpenProp?.();
|
|
54
|
+
setFocus();
|
|
55
|
+
}, [onAfterOpenProp, setFocus]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!progressProp) {
|
|
58
|
+
// Delay focus to the next tick to allow progress to unmount so setFocus do not bail out
|
|
59
|
+
setTimeout(setFocus, 0);
|
|
60
|
+
}
|
|
61
|
+
}, [progressProp, setFocus]);
|
|
62
|
+
useEscape(e => {
|
|
63
|
+
onDismiss?.();
|
|
64
|
+
e.stopPropagation();
|
|
65
|
+
}, dialogRef, [onDismiss]);
|
|
66
|
+
const progress = (_jsx(Progress, { visible: !!progressProp, focusOnVisible: true, placement: 'local', message: typeof progressProp === 'string' ? progressProp : undefined }));
|
|
67
|
+
const dismissButton = (_jsx(Button, { "data-testid": testIds.dismiss, variant: 'simple', icon: true, label: t('dismiss'), onClick: onDismiss, children: _jsx(Icon, { name: 'times' }) }));
|
|
68
|
+
const content = (_jsx(Backdrop, { open: open, onBeforeTransitionIn: () => {
|
|
69
|
+
setDrawerOpen(true);
|
|
70
|
+
returnRef.current = getActiveElement();
|
|
71
|
+
onBeforeOpen?.();
|
|
72
|
+
}, onBeforeTransitionOut: () => {
|
|
73
|
+
setDrawerOpen(false);
|
|
74
|
+
setDrawerSize(size);
|
|
75
|
+
}, onAfterTransitionOut: () => {
|
|
76
|
+
if (isInstance(returnRef.current, HTMLElement) &&
|
|
77
|
+
dialogRef.current?.contains(getActiveElement())) {
|
|
78
|
+
returnRef.current.focus();
|
|
79
|
+
}
|
|
80
|
+
onAfterClose?.();
|
|
81
|
+
}, children: _jsxs(StyledTouchDialog, { "data-testid": testIds.root, ...restProps, ref: dialogRef, open: drawerOpen, placement: 'bottom', position: 'fixed', size: drawerSizeMapping[drawerSize], shadow: true, onAfterOpen: onAfterOpen, onBeforeClose: onBeforeClose, onOuterClick: onDismiss, role: 'dialog', "aria-modal": 'true', "aria-labelledby": heading ? headingId : undefined, "aria-busy": !!progressProp, children: [_jsxs(Flex, { container: { direction: 'row', justify: 'between', alignItems: 'center' }, as: StyledTouchDialogHeader, children: [heading && (_jsx(Text, { variant: 'h2', ref: headingRef, id: headingId, children: heading })), dismissButton] }), _jsxs(Flex, { as: StyledTouchDialogContent, container: { gap: 1, direction: 'column' }, children: [children && (_jsx(StyledChildrenWrap, { inert: progressProp ? '' : undefined, children: children })), progress] }), !isAutoSize && (_jsx(StyledExpandCollapse, { onToggle: () => setDrawerSize(prev => (prev === 'half' ? 'full' : 'half')), expanded: drawerSize === 'full', compact: true, iconOnly: true }))] }) }));
|
|
82
|
+
return portalTarget ? createPortal(content, portalTarget) : content;
|
|
83
|
+
});
|
|
84
|
+
export default TouchDialog;
|
|
85
|
+
//# sourceMappingURL=TouchDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TouchDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,UAAU,EACV,SAAS,EACT,MAAM,EACP,MAAM,aAAa,CAAC;AAErB,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,KAAK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ACA,QAAQ,IACJ,EACN,CAAC,UAAU,IAAI,CACd,KAAC,oBAAoB,IACnB,QAAQ,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAC1E,QAAQ,EAAE,UAAU,KAAK,MAAM,EAC/B,OAAO,QACP,QAAQ,SACR,CACH,IACiB,GACX,CACZ,CAAC;IAEF,OAAO,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACtE,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport type { PropsWithoutRef } from 'react';\n\nimport {\n useConsolidatedRef,\n useConfiguration,\n useFocusTrap,\n useI18n,\n useTestIds,\n useEscape,\n useUID\n} from '../../hooks';\nimport type { ForwardRefForwardPropsComponent } from '../../types';\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport Text from '../Text';\nimport * as caretUp from '../Icon/icons/caret-up.icon';\nimport * as timesIcon from '../Icon/icons/times.icon';\nimport Flex from '../Flex';\nimport Backdrop from '../Backdrop';\nimport { focusNonInteractiveElement, getActiveElement, isInstance } from '../../utils';\nimport Progress from '../Progress';\n\nimport {\n StyledTouchDialogContent,\n StyledTouchDialogHeader,\n StyledTouchDialog,\n StyledExpandCollapse\n} from './TouchDialog.styles';\nimport { getTouchDialogTestIds } from './TouchDialog.test-ids';\nimport type { TouchDialogProps } from './TouchDialog.types';\nimport { StyledChildrenWrap } from './Dialog.styles';\n\nregisterIcon(caretUp, timesIcon);\n\nconst drawerSizeMapping = {\n auto: 'auto',\n half: '50dvh',\n full: '90dvh'\n} as const;\n\nexport const TouchDialog: ForwardRefForwardPropsComponent<TouchDialogProps> = forwardRef(\n function TouchDialog(\n {\n open,\n onDismiss: onDismissProp,\n children,\n size = 'half',\n onBeforeOpen,\n onAfterOpen: onAfterOpenProp,\n onBeforeClose,\n onAfterClose,\n heading,\n progress: progressProp,\n testId,\n ...restProps\n }: PropsWithoutRef<TouchDialogProps>,\n ref: TouchDialogProps['ref']\n ) {\n const dialogRef = useConsolidatedRef(ref);\n const t = useI18n();\n const { portalTarget } = useConfiguration();\n const headingRef = useRef<HTMLHeadingElement>(null);\n const [drawerSize, setDrawerSize] = useState(size);\n const headingId = useUID();\n const testIds = useTestIds(testId, getTouchDialogTestIds);\n const [drawerOpen, setDrawerOpen] = useState(false);\n const returnRef = useRef<Element | null>(null);\n\n useEffect(() => {\n setDrawerSize(size);\n }, [size]);\n\n const isAutoSize = size === 'auto';\n\n useFocusTrap(open && drawerOpen ? dialogRef : null, true, [open, drawerOpen]);\n\n const setFocus = useCallback(() => {\n if (progressProp || !drawerOpen || dialogRef.current?.contains(getActiveElement())) return;\n if (headingRef.current) {\n focusNonInteractiveElement(headingRef.current, heading);\n } else if (dialogRef.current) {\n focusNonInteractiveElement(dialogRef.current, heading);\n }\n }, [progressProp, drawerOpen, heading]);\n\n const onDismiss = useCallback(() => {\n setDrawerOpen(false);\n onDismissProp?.();\n }, [onDismissProp]);\n\n const onAfterOpen = useCallback(() => {\n onAfterOpenProp?.();\n setFocus();\n }, [onAfterOpenProp, setFocus]);\n\n useEffect(() => {\n if (!progressProp) {\n // Delay focus to the next tick to allow progress to unmount so setFocus do not bail out\n setTimeout(setFocus, 0);\n }\n }, [progressProp, setFocus]);\n\n useEscape(\n e => {\n onDismiss?.();\n e.stopPropagation();\n },\n dialogRef,\n [onDismiss]\n );\n\n const progress = (\n <Progress\n visible={!!progressProp}\n focusOnVisible\n placement='local'\n message={typeof progressProp === 'string' ? progressProp : undefined}\n />\n );\n\n const dismissButton = (\n <Button\n data-testid={testIds.dismiss}\n variant='simple'\n icon\n label={t('dismiss')}\n onClick={onDismiss}\n >\n <Icon name='times' />\n </Button>\n );\n\n const content = (\n <Backdrop\n open={open}\n onBeforeTransitionIn={() => {\n setDrawerOpen(true);\n returnRef.current = getActiveElement();\n onBeforeOpen?.();\n }}\n onBeforeTransitionOut={() => {\n setDrawerOpen(false);\n setDrawerSize(size);\n }}\n onAfterTransitionOut={() => {\n if (\n isInstance(returnRef.current, HTMLElement) &&\n dialogRef.current?.contains(getActiveElement())\n ) {\n returnRef.current.focus();\n }\n onAfterClose?.();\n }}\n >\n <StyledTouchDialog\n data-testid={testIds.root}\n {...restProps}\n ref={dialogRef}\n open={drawerOpen}\n placement='bottom'\n position='fixed'\n size={drawerSizeMapping[drawerSize]}\n shadow\n onAfterOpen={onAfterOpen}\n onBeforeClose={onBeforeClose}\n onOuterClick={onDismiss}\n role='dialog'\n aria-modal='true'\n aria-labelledby={heading ? headingId : undefined}\n aria-busy={!!progressProp}\n >\n <Flex\n container={{ direction: 'row', justify: 'between', alignItems: 'center' }}\n as={StyledTouchDialogHeader}\n >\n {heading && (\n <Text variant='h2' ref={headingRef} id={headingId}>\n {heading}\n </Text>\n )}\n {dismissButton}\n </Flex>\n <Flex as={StyledTouchDialogContent} container={{ gap: 1, direction: 'column' }}>\n {children && (\n <StyledChildrenWrap inert={progressProp ? '' : undefined}>\n {children}\n </StyledChildrenWrap>\n )}\n {progress}\n </Flex>\n {!isAutoSize && (\n <StyledExpandCollapse\n onToggle={() => setDrawerSize(prev => (prev === 'half' ? 'full' : 'half'))}\n expanded={drawerSize === 'full'}\n compact\n iconOnly\n />\n )}\n </StyledTouchDialog>\n </Backdrop>\n );\n\n return portalTarget ? createPortal(content, portalTarget) : content;\n }\n);\n\nexport default TouchDialog;\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const StyledExpandCollapse: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("../ExpandCollapse").ExpandCollapseButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>, "ref"> & {
|
|
2
|
+
ref?: ((instance: 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<HTMLButtonElement> | null | undefined;
|
|
3
|
+
}, never>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<import("../ExpandCollapse").ExpandCollapseButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>, keyof import("react").Component<any, {}, any>>;
|
|
4
|
+
export declare const StyledTouchDialog: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("../Drawer").DrawerProps & import("../..").ForwardProps, never>> & string & Omit<import("react").FunctionComponent<import("../Drawer").DrawerProps & import("../..").ForwardProps>, keyof import("react").Component<any, {}, any>>;
|
|
5
|
+
export declare const StyledTouchDialogHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
6
|
+
export declare const StyledTouchDialogContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
7
|
+
//# sourceMappingURL=TouchDialog.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TouchDialog.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.styles.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,oBAAoB;;2OAQhC,CAAC;AAIF,eAAO,MAAM,iBAAiB,mVAqB7B,CAAC;AAIF,eAAO,MAAM,uBAAuB,6NAQnC,CAAC;AAIF,eAAO,MAAM,wBAAwB,6NAepC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { defaultThemeProp } from '../../theme';
|
|
3
|
+
import { StyledButton } from '../Button';
|
|
4
|
+
import Drawer from '../Drawer';
|
|
5
|
+
import { ExpandCollapseButton } from '../ExpandCollapse';
|
|
6
|
+
import { StyledIcon } from '../Icon';
|
|
7
|
+
import { StyledChildrenWrap } from './Dialog.styles';
|
|
8
|
+
export const StyledExpandCollapse = styled(ExpandCollapseButton) `
|
|
9
|
+
position: absolute;
|
|
10
|
+
inset-block-start: 0;
|
|
11
|
+
width: 100%;
|
|
12
|
+
|
|
13
|
+
&[aria-expanded='false'] ${StyledIcon} {
|
|
14
|
+
transform: rotate(-90deg);
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
StyledExpandCollapse.defaultProps = defaultThemeProp;
|
|
18
|
+
export const StyledTouchDialog = styled(Drawer)(({ theme: { base, components } }) => css `
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
background: ${components.popover.background};
|
|
22
|
+
inset-block-end: calc(${base.spacing} * 0.5);
|
|
23
|
+
inset-inline: calc(${base.spacing} * 0.5);
|
|
24
|
+
max-height: 90dvh;
|
|
25
|
+
border-radius: ${components.card['border-radius']};
|
|
26
|
+
width: auto;
|
|
27
|
+
transition-property: transform, box-shadow, opacity, height;
|
|
28
|
+
|
|
29
|
+
@media (height < 31.25rem) {
|
|
30
|
+
overflow-y: auto;
|
|
31
|
+
display: block;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&:has(${StyledExpandCollapse}) {
|
|
35
|
+
padding-block-start: ${base['hit-area'].compact};
|
|
36
|
+
}
|
|
37
|
+
`);
|
|
38
|
+
StyledTouchDialog.defaultProps = defaultThemeProp;
|
|
39
|
+
export const StyledTouchDialogHeader = styled.div(({ theme: { base } }) => css `
|
|
40
|
+
padding-inline: ${base.spacing};
|
|
41
|
+
|
|
42
|
+
${StyledButton} {
|
|
43
|
+
margin-inline-start: auto;
|
|
44
|
+
}
|
|
45
|
+
`);
|
|
46
|
+
StyledTouchDialogHeader.defaultProps = defaultThemeProp;
|
|
47
|
+
export const StyledTouchDialogContent = styled.div(({ theme: { base } }) => css `
|
|
48
|
+
min-height: 0;
|
|
49
|
+
overflow: auto;
|
|
50
|
+
height: 100%;
|
|
51
|
+
position: relative;
|
|
52
|
+
padding-block-start: calc(${base.spacing} * 0.5);
|
|
53
|
+
|
|
54
|
+
${StyledChildrenWrap} {
|
|
55
|
+
height: 100%;
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
padding-inline: ${base.spacing};
|
|
59
|
+
}
|
|
60
|
+
`);
|
|
61
|
+
StyledTouchDialogContent.defaultProps = defaultThemeProp;
|
|
62
|
+
//# sourceMappingURL=TouchDialog.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TouchDialog.styles.js","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAA;;;;;6BAKnC,UAAU;;;CAGtC,CAAC;AAEF,oBAAoB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAErD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,CAC7C,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;;;kBAGxB,UAAU,CAAC,OAAO,CAAC,UAAU;4BACnB,IAAI,CAAC,OAAO;yBACf,IAAI,CAAC,OAAO;;qBAEhB,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC;;;;;;;;;YASzC,oBAAoB;6BACH,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO;;GAElD,CACF,CAAC;AAEF,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAC/C,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;sBACR,IAAI,CAAC,OAAO;;MAE5B,YAAY;;;GAGf,CACF,CAAC;AAEF,uBAAuB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAExD,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,GAAG,CAChD,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;;;;;gCAKE,IAAI,CAAC,OAAO;;MAEtC,kBAAkB;;;;wBAIA,IAAI,CAAC,OAAO;;GAEjC,CACF,CAAC;AAEF,wBAAwB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { StyledButton } from '../Button';\nimport Drawer from '../Drawer';\nimport { ExpandCollapseButton } from '../ExpandCollapse';\nimport { StyledIcon } from '../Icon';\n\nimport { StyledChildrenWrap } from './Dialog.styles';\n\nexport const StyledExpandCollapse = styled(ExpandCollapseButton)`\n position: absolute;\n inset-block-start: 0;\n width: 100%;\n\n &[aria-expanded='false'] ${StyledIcon} {\n transform: rotate(-90deg);\n }\n`;\n\nStyledExpandCollapse.defaultProps = defaultThemeProp;\n\nexport const StyledTouchDialog = styled(Drawer)(\n ({ theme: { base, components } }) => css`\n display: flex;\n flex-direction: column;\n background: ${components.popover.background};\n inset-block-end: calc(${base.spacing} * 0.5);\n inset-inline: calc(${base.spacing} * 0.5);\n max-height: 90dvh;\n border-radius: ${components.card['border-radius']};\n width: auto;\n transition-property: transform, box-shadow, opacity, height;\n\n @media (height < 31.25rem) {\n overflow-y: auto;\n display: block;\n }\n\n &:has(${StyledExpandCollapse}) {\n padding-block-start: ${base['hit-area'].compact};\n }\n `\n);\n\nStyledTouchDialog.defaultProps = defaultThemeProp;\n\nexport const StyledTouchDialogHeader = styled.div(\n ({ theme: { base } }) => css`\n padding-inline: ${base.spacing};\n\n ${StyledButton} {\n margin-inline-start: auto;\n }\n `\n);\n\nStyledTouchDialogHeader.defaultProps = defaultThemeProp;\n\nexport const StyledTouchDialogContent = styled.div(\n ({ theme: { base } }) => css`\n min-height: 0;\n overflow: auto;\n height: 100%;\n position: relative;\n padding-block-start: calc(${base.spacing} * 0.5);\n\n ${StyledChildrenWrap} {\n height: 100%;\n display: flex;\n flex-direction: column;\n padding-inline: ${base.spacing};\n }\n `\n);\n\nStyledTouchDialogContent.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TouchDialog.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,4GAAsD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TouchDialog.test-ids.js","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC,cAAc,EAAE,CAAC,SAAS,CAAU,CAAC,CAAC","sourcesContent":["import { createTestIds } from '../../utils';\n\nexport const getTouchDialogTestIds = createTestIds('touch-dialog', ['dismiss'] as const);\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Ref } from 'react';
|
|
2
|
+
import type { BaseProps, TestIdProp } from '../../types';
|
|
3
|
+
import type { DrawerProps } from '../Drawer';
|
|
4
|
+
import type { ProgressProps } from '../Progress';
|
|
5
|
+
export interface TouchDialogProps extends BaseProps, TestIdProp {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the TouchDialog should be open or closed.
|
|
8
|
+
* The component should not be unmounted before onAfterClose is called,
|
|
9
|
+
* otherwise the closing animation will be interrupted.
|
|
10
|
+
*/
|
|
11
|
+
open: DrawerProps['open'];
|
|
12
|
+
/**
|
|
13
|
+
* Callback fired when the TouchDialog is dismissed with user intent.
|
|
14
|
+
* The parent component should toggle the `open` prop.
|
|
15
|
+
*/
|
|
16
|
+
onDismiss: () => void;
|
|
17
|
+
/** Heading text displayed at the top of the drawer. */
|
|
18
|
+
heading?: string;
|
|
19
|
+
/** Content of the TouchDialog. */
|
|
20
|
+
children?: DrawerProps['children'];
|
|
21
|
+
/** If there is a progress state either on opening, or after submit, you must indicate as such. A custom message is supported as well. */
|
|
22
|
+
progress?: boolean | ProgressProps['message'];
|
|
23
|
+
/**
|
|
24
|
+
* The initial height of the TouchDialog panel.
|
|
25
|
+
* - `'auto'` — height is driven by content (capped at 90% of the viewport).
|
|
26
|
+
* - `'half'` — half the viewport height.
|
|
27
|
+
* - `'full'` — opens to the maximum height (90% of the viewport).
|
|
28
|
+
* @default 'half'
|
|
29
|
+
*/
|
|
30
|
+
size?: 'auto' | 'half' | 'full';
|
|
31
|
+
/** Callback fired before the TouchDialog starts opening. */
|
|
32
|
+
onBeforeOpen?: DrawerProps['onBeforeOpen'];
|
|
33
|
+
/** Callback fired after the TouchDialog finishes opening. */
|
|
34
|
+
onAfterOpen?: DrawerProps['onAfterOpen'];
|
|
35
|
+
/** Callback fired before the TouchDialog starts closing. */
|
|
36
|
+
onBeforeClose?: DrawerProps['onBeforeClose'];
|
|
37
|
+
/** Callback fired after the TouchDialog finishes closing. */
|
|
38
|
+
onAfterClose?: DrawerProps['onAfterClose'];
|
|
39
|
+
/** Ref for the dialog panel element. */
|
|
40
|
+
ref?: Ref<HTMLDivElement>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=TouchDialog.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TouchDialog.types.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,gBAAiB,SAAQ,SAAS,EAAE,UAAU;IAC7D;;;;OAIG;IACH,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B;;;OAGG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IACnC,yIAAyI;IACzI,QAAQ,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IAC9C;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAChC,4DAA4D;IAC5D,YAAY,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;IAC3C,6DAA6D;IAC7D,WAAW,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;IACzC,4DAA4D;IAC5D,aAAa,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IAC7C,6DAA6D;IAC7D,YAAY,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;IAC3C,wCAAwC;IACxC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TouchDialog.types.js","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Ref } from 'react';\n\nimport type { BaseProps, TestIdProp } from '../../types';\nimport type { DrawerProps } from '../Drawer';\nimport type { ProgressProps } from '../Progress';\n\nexport interface TouchDialogProps extends BaseProps, TestIdProp {\n /**\n * Whether the TouchDialog should be open or closed.\n * The component should not be unmounted before onAfterClose is called,\n * otherwise the closing animation will be interrupted.\n */\n open: DrawerProps['open'];\n /**\n * Callback fired when the TouchDialog is dismissed with user intent.\n * The parent component should toggle the `open` prop.\n */\n onDismiss: () => void;\n /** Heading text displayed at the top of the drawer. */\n heading?: string;\n /** Content of the TouchDialog. */\n children?: DrawerProps['children'];\n /** If there is a progress state either on opening, or after submit, you must indicate as such. A custom message is supported as well. */\n progress?: boolean | ProgressProps['message'];\n /**\n * The initial height of the TouchDialog panel.\n * - `'auto'` — height is driven by content (capped at 90% of the viewport).\n * - `'half'` — half the viewport height.\n * - `'full'` — opens to the maximum height (90% of the viewport).\n * @default 'half'\n */\n size?: 'auto' | 'half' | 'full';\n /** Callback fired before the TouchDialog starts opening. */\n onBeforeOpen?: DrawerProps['onBeforeOpen'];\n /** Callback fired after the TouchDialog finishes opening. */\n onAfterOpen?: DrawerProps['onAfterOpen'];\n /** Callback fired before the TouchDialog starts closing. */\n onBeforeClose?: DrawerProps['onBeforeClose'];\n /** Callback fired after the TouchDialog finishes closing. */\n onAfterClose?: DrawerProps['onAfterClose'];\n /** Ref for the dialog panel element. */\n ref?: Ref<HTMLDivElement>;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InfoDialogProps } from './Dialog.types';
|
|
2
|
+
declare const TouchInfoDialog: import("react").ForwardRefExoticComponent<Omit<Pick<InfoDialogProps, "hidden" | "color" | "content" | "style" | "progress" | "translate" | "slot" | "title" | "ref" | "suppressHydrationWarning" | "className" | "id" | "lang" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "accessKey" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "nonce" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "inert" | "heading" | "placement" | "strategy" | "portal" | "onDismiss" | "focusTrap">, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
3
|
+
export default TouchInfoDialog;
|
|
4
|
+
//# sourceMappingURL=TouchInfoDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TouchInfoDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/TouchInfoDialog.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,QAAA,MAAM,eAAe,80JAuBnB,CAAC;AAEH,eAAe,eAAe,CAAC"}
|
|
@@ -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,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,UAAU,MAAM,
|
|
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,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,OAAO,MAAM,YAAY,CAAC;AAiBjC,MAAM,WAAW,GAAG,UAAU,CAC5B,SAAS,WAAW,CAClB,EAAE,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,EAChF,GAAG;IAEH,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,UAAU,CAAoB,IAAI,CAAC,CAAC;IAEhE,OAAO,CACL,iBAAS,SAAS,EAAE,GAAG,EAAE,GAAG,YACzB,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CACb,KAAC,OAAO,KAAG,CACZ,CAAC,CAAC,CAAC,CACF,8BACE,KAAC,MAAM,IACL,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,CAAC,CAAgC,EAAE,EAAE;wBAC5C,IAAI,YAAY,IAAI,CAAC,MAAM;4BAAE,YAAY,EAAE,CAAC;wBAC5C,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;oBAC7B,CAAC,YAEA,CAAC,CAAC,iBAAiB,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,GAClC,EAER,MAAM,IAAI,CACT,KAAC,UAAU,IACT,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,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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GACD,CACH,GACW,CACf,CAAC,CAAC,CAAC,CACF,KAAC,uBAAuB,IACtB,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,EAC9C,kBAAkB,QAClB,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,MAAM,EACtB,MAAM,EAAE,SAAS,EAAE,OAAO,EAC1B,GAAG,EAAE,UAAU,qBACE,SAAS,YAEzB,IAAI,IAAI,CACP,8BACE,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,YAC9B,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,EAAC,EAAE,EAAE,SAAS,YAC7B,OAAO,GACH,GACF,EACP,KAAC,IAAI,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
|