@pega/cosmos-react-core 10.0.0-build.9.7 → 10.0.0-build.9.8
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/AIRewrite/AIRewrite.styles.d.ts +32 -12
- package/lib/components/AIRewrite/AIRewrite.styles.d.ts.map +1 -1
- package/lib/components/AIRewrite/AIRewrite.styles.js +5 -2
- package/lib/components/AIRewrite/AIRewrite.styles.js.map +1 -1
- package/lib/components/AppShell/AppHeader.d.ts.map +1 -1
- package/lib/components/AppShell/AppHeader.js +3 -2
- package/lib/components/AppShell/AppHeader.js.map +1 -1
- package/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +17 -7
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.types.d.ts +23 -2
- package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.types.js.map +1 -1
- package/lib/components/AppShell/AppShellList.styles.d.ts +1 -1
- package/lib/components/AppShell/AppShellList.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellList.styles.js +63 -23
- package/lib/components/AppShell/AppShellList.styles.js.map +1 -1
- package/lib/components/AppShell/Notifications.d.ts +28 -0
- package/lib/components/AppShell/Notifications.d.ts.map +1 -0
- package/lib/components/AppShell/Notifications.js +145 -0
- package/lib/components/AppShell/Notifications.js.map +1 -0
- package/lib/components/AppShell/TouchAppShell.d.ts +1 -1
- package/lib/components/AppShell/TouchAppShell.d.ts.map +1 -1
- package/lib/components/AppShell/TouchAppShell.js +4 -3
- package/lib/components/AppShell/TouchAppShell.js.map +1 -1
- package/lib/components/AppShell/TouchAppShell.styles.d.ts +4 -2
- package/lib/components/AppShell/TouchAppShell.styles.d.ts.map +1 -1
- package/lib/components/AppShell/index.d.ts +1 -1
- package/lib/components/AppShell/index.d.ts.map +1 -1
- package/lib/components/AppShell/index.js.map +1 -1
- package/lib/components/Dialog/Dialog.types.d.ts +42 -12
- package/lib/components/Dialog/Dialog.types.d.ts.map +1 -1
- package/lib/components/Dialog/Dialog.types.js.map +1 -1
- package/lib/components/Dialog/FormDialog.d.ts.map +1 -1
- package/lib/components/Dialog/FormDialog.js +29 -33
- package/lib/components/Dialog/FormDialog.js.map +1 -1
- package/lib/components/Dialog/FormDialogWrapper.d.ts +5 -0
- package/lib/components/Dialog/FormDialogWrapper.d.ts.map +1 -0
- package/lib/components/Dialog/FormDialogWrapper.js +13 -0
- package/lib/components/Dialog/FormDialogWrapper.js.map +1 -0
- package/lib/components/Dialog/TouchDialog.d.ts.map +1 -1
- package/lib/components/Dialog/TouchDialog.js +6 -6
- package/lib/components/Dialog/TouchDialog.js.map +1 -1
- package/lib/components/Dialog/TouchDialog.styles.d.ts +2 -2
- package/lib/components/Dialog/TouchDialog.styles.d.ts.map +1 -1
- package/lib/components/Dialog/TouchDialog.styles.js +31 -30
- package/lib/components/Dialog/TouchDialog.styles.js.map +1 -1
- package/lib/components/Dialog/TouchDialog.types.d.ts +9 -4
- package/lib/components/Dialog/TouchDialog.types.d.ts.map +1 -1
- package/lib/components/Dialog/TouchDialog.types.js.map +1 -1
- package/lib/components/Dialog/TouchFormDialog.d.ts +5 -0
- package/lib/components/Dialog/TouchFormDialog.d.ts.map +1 -0
- package/lib/components/Dialog/TouchFormDialog.js +53 -0
- package/lib/components/Dialog/TouchFormDialog.js.map +1 -0
- package/lib/components/Dialog/TouchFormDialog.styles.d.ts +7 -0
- package/lib/components/Dialog/TouchFormDialog.styles.d.ts.map +1 -0
- package/lib/components/Dialog/TouchFormDialog.styles.js +39 -0
- package/lib/components/Dialog/TouchFormDialog.styles.js.map +1 -0
- package/lib/components/Dialog/index.d.ts +2 -1
- package/lib/components/Dialog/index.d.ts.map +1 -1
- package/lib/components/Dialog/index.js +2 -1
- package/lib/components/Dialog/index.js.map +1 -1
- package/lib/components/InlineEdit/InlineEdit.styles.d.ts +32 -12
- package/lib/components/InlineEdit/InlineEdit.styles.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.styles.d.ts +32 -12
- package/lib/components/ListToolbar/ListToolbar.styles.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.styles.js +9 -6
- package/lib/components/ListToolbar/ListToolbar.styles.js.map +1 -1
- package/lib/components/Modal/DockedModals.js +1 -1
- package/lib/components/Modal/DockedModals.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/package.json +1 -1
|
@@ -10,9 +10,11 @@ export declare const StyledMainTouchAppShell: import("styled-components/dist/typ
|
|
|
10
10
|
export declare const StyledSplitViewPanel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
11
11
|
active?: boolean;
|
|
12
12
|
}>> & string;
|
|
13
|
-
export declare const StyledPortalTouchDialog: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").
|
|
13
|
+
export declare const StyledPortalTouchDialog: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<(Omit<Omit<Pick<import("../Dialog/TouchDialog.types").TouchDialogPropsBase, "size" | "progress" | "open" | "footer" | "ref" | "className" | "aria-label" | "children" | "heading" | "testId" | "onBeforeOpen" | "onAfterOpen" | "onAfterClose" | "outerClickAction"> & Required<Pick<import("../Dialog/TouchDialog.types").TouchDialogPropsBase, "onBeforeClose">> & Partial<Pick<import("../Dialog/TouchDialog.types").TouchDialogPropsBase, "onDismiss">>, "ref"> & import("react").RefAttributes<HTMLDivElement> & import("../..").ForwardProps, "ref"> & {
|
|
14
14
|
ref?: ((instance: HTMLDivElement | 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<HTMLDivElement> | null | undefined;
|
|
15
|
-
},
|
|
15
|
+
}) | (Omit<Omit<Pick<import("../Dialog/TouchDialog.types").TouchDialogPropsBase, "size" | "progress" | "open" | "footer" | "ref" | "className" | "aria-label" | "children" | "heading" | "testId" | "onBeforeOpen" | "onAfterOpen" | "onAfterClose" | "outerClickAction"> & Required<Pick<import("../Dialog/TouchDialog.types").TouchDialogPropsBase, "onDismiss">> & Partial<Pick<import("../Dialog/TouchDialog.types").TouchDialogPropsBase, "onBeforeClose">>, "ref"> & import("react").RefAttributes<HTMLDivElement> & import("../..").ForwardProps, "ref"> & {
|
|
16
|
+
ref?: ((instance: HTMLDivElement | 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<HTMLDivElement> | null | undefined;
|
|
17
|
+
}), import("styled-components/dist/types").BaseObject>> & string & Omit<import("../..").ForwardRefForwardPropsComponent<import("../Dialog").TouchDialogProps>, keyof import("react").Component<any, {}, any>>;
|
|
16
18
|
export declare const StyledMobileMoreMenu: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, never>, "ref"> & {
|
|
17
19
|
ref?: ((instance: HTMLElement | 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<HTMLElement> | null | undefined;
|
|
18
20
|
}, never>> & string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TouchAppShell.styles.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/TouchAppShell.styles.ts"],"names":[],"mappings":"AAAA,OAAe,EAA0B,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA8BtF,eAAO,MAAM,wBAAwB;0BACb,OAAO;kBACf,OAAO;YACb,YAAY;EAarB,CAAC;AAEF,eAAO,MAAM,uBAAuB;aAAyB,OAAO;YAOnE,CAAC;AAIF,eAAO,MAAM,oBAAoB;aAAyB,OAAO;YAY/D,CAAC;AAIH,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"TouchAppShell.styles.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/TouchAppShell.styles.ts"],"names":[],"mappings":"AAAA,OAAe,EAA0B,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA8BtF,eAAO,MAAM,wBAAwB;0BACb,OAAO;kBACf,OAAO;YACb,YAAY;EAarB,CAAC;AAEF,eAAO,MAAM,uBAAuB;aAAyB,OAAO;YAOnE,CAAC;AAIF,eAAO,MAAM,oBAAoB;aAAyB,OAAO;YAY/D,CAAC;AAIH,eAAO,MAAM,uBAAuB;;;;6MAWnC,CAAC;AAIF,eAAO,MAAM,oBAAoB;;mBAShC,CAAC;AAIF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAAwC,OAAO;gJAqFzE,CAAC;AAIH,eAAO,MAAM,0BAA0B;;2JAgDrC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { default } from './AppShell';
|
|
2
2
|
export { default as AppShellList } from './AppShellList';
|
|
3
3
|
export type { AppShellListProps } from './AppShellList';
|
|
4
|
-
export type { AppHeaderProps, AppShellProps, ContextSwitcherProps, DrawerItemProps, DrawerListProps, NavOrientation, ShareAppConfig, PortalSwitcherConfig, DocumentTab, DocumentTabsProps, DocumentTabGroup } from './AppShell.types';
|
|
4
|
+
export type { AppHeaderProps, AppShellProps, ContextSwitcherProps, DrawerItemProps, DrawerListProps, NavOrientation, ShareAppConfig, PortalSwitcherConfig, DocumentTab, DocumentTabsProps, DocumentTabGroup, NotificationsProps } from './AppShell.types';
|
|
5
5
|
export { default as AppShellContext, AppShellDrawerContext } from './AppShellContext';
|
|
6
6
|
export { default as ContextSwitcher } from './ContextSwitcher';
|
|
7
7
|
export { default as ThemeSwitcher } from './ThemeSwitcher';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EACV,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EACV,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/AppShell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/AppShell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAgBzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { default } from './AppShell';\nexport { default as AppShellList } from './AppShellList';\nexport type { AppShellListProps } from './AppShellList';\nexport type {\n AppHeaderProps,\n AppShellProps,\n ContextSwitcherProps,\n DrawerItemProps,\n DrawerListProps,\n NavOrientation,\n ShareAppConfig,\n PortalSwitcherConfig,\n DocumentTab,\n DocumentTabsProps,\n DocumentTabGroup,\n NotificationsProps\n} from './AppShell.types';\nexport { default as AppShellContext, AppShellDrawerContext } from './AppShellContext';\nexport { default as ContextSwitcher } from './ContextSwitcher';\nexport { default as ThemeSwitcher } from './ThemeSwitcher';\n"]}
|
|
@@ -37,11 +37,14 @@ export interface BaseDialogProps {
|
|
|
37
37
|
ref?: PopoverProps['ref'];
|
|
38
38
|
}
|
|
39
39
|
export type DialogProps = WithAttributes<'div', BaseDialogProps>;
|
|
40
|
-
/**
|
|
41
|
-
|
|
40
|
+
/**
|
|
41
|
+
* A simple callback or an object to customize a subset button properties.
|
|
42
|
+
* The callback should return true or Promise resolving to true value to indicate whether the dialog should close.
|
|
43
|
+
*/
|
|
44
|
+
export type FormAction = (() => void | boolean | Promise<void | boolean>) | {
|
|
42
45
|
text?: string;
|
|
43
46
|
disabled?: boolean;
|
|
44
|
-
handler: () => void
|
|
47
|
+
handler: () => void | boolean | Promise<void | boolean>;
|
|
45
48
|
};
|
|
46
49
|
type HeadingOrARIALabel = {
|
|
47
50
|
/** A string to indicate context for the dialog. The dialog will be labelled by this value. */
|
|
@@ -58,26 +61,53 @@ type HeadingOrARIALabel = {
|
|
|
58
61
|
export type FormDialogProps = WithAttributes<'div', BaseDialogProps & {
|
|
59
62
|
/** Called when the user presses escape or clicks away. */
|
|
60
63
|
onDismiss?: () => void;
|
|
61
|
-
/**
|
|
62
|
-
* Renders a standard design system cancel button.
|
|
63
|
-
* If onDismiss is not provided, onCancel will be invoked when the user presses the Escape key or clicks outside of the dialog.
|
|
64
|
-
* Invocation of this indicates the user wishes to cancel any changes and close the dialog.
|
|
65
|
-
*/
|
|
66
|
-
onCancel: FormAction;
|
|
67
64
|
/**
|
|
68
65
|
* Renders a standard design system submit button.
|
|
69
66
|
* Invocation of this indicates the user wishes to submit any changes and close the dialog. Please consider progress states after submit.
|
|
67
|
+
* Returning or resolving the returned promise to true starts closing animation on touch devices followed by calling onAfterClose to indicate safe unmount.
|
|
70
68
|
*/
|
|
71
69
|
onSubmit: FormAction;
|
|
72
70
|
} & (({
|
|
73
71
|
/** Renders in a visually compact manner with icon action buttons. */
|
|
74
|
-
compact
|
|
72
|
+
compact?: boolean;
|
|
75
73
|
} & ExcludeStrict<HeadingOrARIALabel, {
|
|
76
74
|
heading: string;
|
|
77
75
|
}>) | ({
|
|
78
76
|
/** Renders in a visually compact manner with icon action buttons. */
|
|
79
|
-
compact?: false
|
|
80
|
-
} & HeadingOrARIALabel
|
|
77
|
+
compact?: false;
|
|
78
|
+
} & ExcludeStrict<HeadingOrARIALabel, {
|
|
79
|
+
'aria-label': string;
|
|
80
|
+
}>)) & ({
|
|
81
|
+
/**
|
|
82
|
+
* Called after the dialog has completely closed and safe to unmount.
|
|
83
|
+
* It will be invoked when onCancel or onSubmit has returned true or resolved to a true value.
|
|
84
|
+
*/
|
|
85
|
+
onAfterClose?: () => void;
|
|
86
|
+
/**
|
|
87
|
+
* Renders a standard design system cancel button.
|
|
88
|
+
* If onDismiss is not provided, onCancel will be invoked when the user presses the Escape key or clicks outside of the dialog.
|
|
89
|
+
* Invocation of this indicates the user wishes to cancel any changes and close the dialog.
|
|
90
|
+
* Returning or resolving the returned promise to true starts closing animation on touch devices followed by calling onAfterClose to indicate safe unmount.
|
|
91
|
+
*
|
|
92
|
+
* @default () => true
|
|
93
|
+
*/
|
|
94
|
+
onCancel: FormAction | undefined;
|
|
95
|
+
} | {
|
|
96
|
+
/**
|
|
97
|
+
* Called after the dialog has completely closed and safe to unmount.
|
|
98
|
+
* It will be invoked when onCancel or onSubmit has returned true or resolved to a true value.
|
|
99
|
+
*/
|
|
100
|
+
onAfterClose: () => void;
|
|
101
|
+
/**
|
|
102
|
+
* Renders a standard design system cancel button.
|
|
103
|
+
* If onDismiss is not provided, onCancel will be invoked when the user presses the Escape key or clicks outside of the dialog.
|
|
104
|
+
* Invocation of this indicates the user wishes to cancel any changes and close the dialog.
|
|
105
|
+
* Returning or resolving the returned promise to true starts closing animation on touch devices followed by calling onAfterClose to indicate safe unmount.
|
|
106
|
+
*
|
|
107
|
+
* @default () => true
|
|
108
|
+
*/
|
|
109
|
+
onCancel?: FormAction;
|
|
110
|
+
})>;
|
|
81
111
|
export type InfoDialogProps = WithAttributes<'div', OmitStrict<BaseDialogProps, 'arrow'> & {
|
|
82
112
|
/** A string or summary item like props to indicate context for the dialog. The dialog will be labelled by either the heading element or primary property. */
|
|
83
113
|
heading?: string | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.types.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAE9B;;;OAGG;IACH,MAAM,EAAE,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE5C,6IAA6I;IAC7I,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IAEnC,yIAAyI;IACzI,QAAQ,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IAE9C,iGAAiG;IACjG,MAAM,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;IAEhC,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IAEpC;;;OAGG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,8CAA8C;IAC9C,GAAG,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC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AAY,EAAE,MAAM,IAAI,CAAC;IAEzB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB,CACJ,CACJ,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,CAC1C,KAAK,EACL,UAAU,CAAC,eAAe,EAAE,OAAO,CAAC,GAAG;IACrC,6JAA6J;IAC7J,OAAO,CAAC,EACJ,MAAM,GACN;QACE,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,SAAS,CAAC;KACpB,CAAC;IAEN,2IAA2I;IAC3I,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB,CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.types.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactNode } from 'react';\n\nimport type { ExcludeStrict, OmitStrict, WithAttributes } from '../../types';\nimport type { PopoverProps } from '../Popover';\nimport type { ProgressProps } from '../Progress';\nimport type { AdditionalInfoProps } from '../AdditionalInfo';\n\nexport interface BaseDialogProps {\n /**\n * Certain uses of dialogs require a linear edge with an input like control.\n * There an arrow is not desired.\n * @default true\n */\n arrow?: PopoverProps['arrow'];\n\n /**\n * An element the dialog is contextually and visually associated with. Normally a triggering button.\n * Components rendering Dialog should mount and unmount instances based on this value.\n */\n target: NonNullable<PopoverProps['target']>;\n\n /** Content for the dialog. Avoid form control buttons within as those should be rendered by way of onCancel and onSubmit with FormDialog. */\n children: PopoverProps['children'];\n\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 /** Optionally render the dialog element at the end of the body or within a specified element. */\n portal?: PopoverProps['portal'];\n\n /** Positioning strategy for solving rendering scenarios. */\n strategy?: PopoverProps['strategy'];\n\n /**\n * Intended positioning placement for the dialog element.\n * Placement may auto adjust based on screen position and other layout variables.\n */\n placement?: PopoverProps['placement'];\n /**\n * Optionally determines whether to trap the focus inside the dialog, preventing it from being moved outside until the dialog is closed.\n * @default false\n */\n focusTrap?: boolean;\n\n /** Reference to the dialog's root element. */\n ref?: PopoverProps['ref'];\n}\n\nexport type DialogProps = WithAttributes<'div', BaseDialogProps>;\n\n
|
|
1
|
+
{"version":3,"file":"Dialog.types.js","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactNode } from 'react';\n\nimport type { ExcludeStrict, OmitStrict, WithAttributes } from '../../types';\nimport type { PopoverProps } from '../Popover';\nimport type { ProgressProps } from '../Progress';\nimport type { AdditionalInfoProps } from '../AdditionalInfo';\n\nexport interface BaseDialogProps {\n /**\n * Certain uses of dialogs require a linear edge with an input like control.\n * There an arrow is not desired.\n * @default true\n */\n arrow?: PopoverProps['arrow'];\n\n /**\n * An element the dialog is contextually and visually associated with. Normally a triggering button.\n * Components rendering Dialog should mount and unmount instances based on this value.\n */\n target: NonNullable<PopoverProps['target']>;\n\n /** Content for the dialog. Avoid form control buttons within as those should be rendered by way of onCancel and onSubmit with FormDialog. */\n children: PopoverProps['children'];\n\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 /** Optionally render the dialog element at the end of the body or within a specified element. */\n portal?: PopoverProps['portal'];\n\n /** Positioning strategy for solving rendering scenarios. */\n strategy?: PopoverProps['strategy'];\n\n /**\n * Intended positioning placement for the dialog element.\n * Placement may auto adjust based on screen position and other layout variables.\n */\n placement?: PopoverProps['placement'];\n /**\n * Optionally determines whether to trap the focus inside the dialog, preventing it from being moved outside until the dialog is closed.\n * @default false\n */\n focusTrap?: boolean;\n\n /** Reference to the dialog's root element. */\n ref?: PopoverProps['ref'];\n}\n\nexport type DialogProps = WithAttributes<'div', BaseDialogProps>;\n\n/**\n * A simple callback or an object to customize a subset button properties.\n * The callback should return true or Promise resolving to true value to indicate whether the dialog should close.\n */\nexport type FormAction =\n | (() => void | boolean | Promise<void | boolean>)\n | {\n text?: string;\n disabled?: boolean;\n handler: () => void | boolean | Promise<void | boolean>;\n };\n\ntype HeadingOrARIALabel =\n | {\n /** A string to indicate context for the dialog. The dialog will be labelled by this value. */\n heading: string;\n /** Show additional info in form dialog header. */\n additionalInfo?: AdditionalInfoProps;\n\n 'aria-label'?: never;\n }\n | {\n /** Provide a contextually sufficient aria label if a visible heading is not provided. */\n 'aria-label': string;\n\n heading?: never;\n additionalInfo?: never;\n };\n\nexport type FormDialogProps = WithAttributes<\n 'div',\n BaseDialogProps & {\n /** Called when the user presses escape or clicks away. */\n onDismiss?: () => void;\n\n /**\n * Renders a standard design system submit button.\n * Invocation of this indicates the user wishes to submit any changes and close the dialog. Please consider progress states after submit.\n * Returning or resolving the returned promise to true starts closing animation on touch devices followed by calling onAfterClose to indicate safe unmount.\n */\n onSubmit: FormAction;\n } & (\n | ({\n /** Renders in a visually compact manner with icon action buttons. */\n compact?: boolean;\n } & ExcludeStrict<HeadingOrARIALabel, { heading: string }>) // An aria-label is required for accessibility and supports both modes.\n | ({\n /** Renders in a visually compact manner with icon action buttons. */\n compact?: false;\n } & ExcludeStrict<HeadingOrARIALabel, { 'aria-label': string }>) // Heading is not supported in compact mode.\n ) &\n (\n | {\n /**\n * Called after the dialog has completely closed and safe to unmount.\n * It will be invoked when onCancel or onSubmit has returned true or resolved to a true value.\n */\n onAfterClose?: () => void;\n\n /**\n * Renders a standard design system cancel button.\n * If onDismiss is not provided, onCancel will be invoked when the user presses the Escape key or clicks outside of the dialog.\n * Invocation of this indicates the user wishes to cancel any changes and close the dialog.\n * Returning or resolving the returned promise to true starts closing animation on touch devices followed by calling onAfterClose to indicate safe unmount.\n *\n * @default () => true\n */\n // Required key accepting undefined: forwarding an optional prop is allowed, omitting it requires onAfterClose.\n onCancel: FormAction | undefined;\n }\n | {\n /**\n * Called after the dialog has completely closed and safe to unmount.\n * It will be invoked when onCancel or onSubmit has returned true or resolved to a true value.\n */\n onAfterClose: () => void;\n\n /**\n * Renders a standard design system cancel button.\n * If onDismiss is not provided, onCancel will be invoked when the user presses the Escape key or clicks outside of the dialog.\n * Invocation of this indicates the user wishes to cancel any changes and close the dialog.\n * Returning or resolving the returned promise to true starts closing animation on touch devices followed by calling onAfterClose to indicate safe unmount.\n *\n * @default () => true\n */\n onCancel?: FormAction;\n }\n )\n>;\n\nexport type InfoDialogProps = WithAttributes<\n 'div',\n OmitStrict<BaseDialogProps, 'arrow'> & {\n /** A string or summary item like props to indicate context for the dialog. The dialog will be labelled by either the heading element or primary property. */\n heading?:\n | string\n | {\n primary: string;\n secondary?: string;\n visual?: ReactNode;\n };\n\n /** Renders a standard design system dismiss button to close the dialog when the user clicks this button, presses escape or clicks away. */\n onDismiss: () => void;\n }\n>;\n\n/**\n * Components which render Dialog internally may need to offer some control to consuming components.\n * Use this interface to offer an imperative handle for shared control.\n */\nexport interface DialogHandleValue {\n open: () => void;\n close: () => void;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/FormDialog.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FormDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/FormDialog.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AA4B7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAWtD,eAAO,MAAM,gBAAgB;;uNAAmB,CAAC;AAEjD,QAAA,MAAM,UAAU,6HAwOf,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useEffect, useLayoutEffect, useRef } from 'react';
|
|
2
|
+
import { forwardRef, useCallback, useEffect, useLayoutEffect, useRef } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import { useConsolidatedRef, useContentTabIndex, useEscape, useI18n, useOuterEvent, useUID } from '../../hooks';
|
|
4
|
+
import { useConsolidatedRef, useContentTabIndex, useEscape, useEvent, useI18n, useOuterEvent, useUID } from '../../hooks';
|
|
5
5
|
import { getActiveElement, focusNonInteractiveElement, getFocusables } from '../../utils';
|
|
6
6
|
import Button, { StyledButton } from '../Button';
|
|
7
7
|
import Text from '../Text';
|
|
@@ -19,7 +19,7 @@ const StyledCompactActions = styled.div `
|
|
|
19
19
|
}
|
|
20
20
|
`;
|
|
21
21
|
export const StyledFormDialog = styled(Dialog) ``;
|
|
22
|
-
const FormDialog = forwardRef(function FormDialog({ arrow = true, compact, target, heading, 'aria-label': ariaLabel, children, progress, onDismiss, onCancel, onSubmit, additionalInfo, ...restProps }, ref) {
|
|
22
|
+
const FormDialog = forwardRef(function FormDialog({ arrow = true, compact, target, heading, 'aria-label': ariaLabel, children, progress, onDismiss, onCancel = () => true, onSubmit, onAfterClose, additionalInfo, ...restProps }, ref) {
|
|
23
23
|
const t = useI18n();
|
|
24
24
|
const headingId = useUID();
|
|
25
25
|
const headingRef = useRef(null);
|
|
@@ -47,22 +47,24 @@ const FormDialog = forwardRef(function FormDialog({ arrow = true, compact, targe
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
const onCancelHandler = typeof onCancel === 'function' ? onCancel : onCancel.handler;
|
|
50
|
-
|
|
50
|
+
const closeDialog = useCallback(async () => {
|
|
51
51
|
if (onDismiss) {
|
|
52
52
|
onDismiss();
|
|
53
|
+
onAfterClose?.();
|
|
53
54
|
}
|
|
54
55
|
else {
|
|
55
|
-
onCancelHandler();
|
|
56
|
+
const result = await onCancelHandler();
|
|
57
|
+
if (result !== false) {
|
|
58
|
+
onAfterClose?.();
|
|
59
|
+
}
|
|
56
60
|
}
|
|
61
|
+
}, [onDismiss, onCancelHandler, onAfterClose]);
|
|
62
|
+
useEscape(e => {
|
|
63
|
+
closeDialog();
|
|
57
64
|
e.stopPropagation();
|
|
58
|
-
}, dialogRef, [
|
|
65
|
+
}, dialogRef, [closeDialog]);
|
|
59
66
|
useOuterEvent('mousedown', [resolvedTarget, dialogRef], () => {
|
|
60
|
-
|
|
61
|
-
onDismiss();
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
onCancelHandler();
|
|
65
|
-
}
|
|
67
|
+
closeDialog();
|
|
66
68
|
});
|
|
67
69
|
// Using layout effect to capture the focused element prior to dialog elements taking focus.
|
|
68
70
|
useLayoutEffect(() => {
|
|
@@ -78,33 +80,27 @@ const FormDialog = forwardRef(function FormDialog({ arrow = true, compact, targe
|
|
|
78
80
|
setFocus();
|
|
79
81
|
}
|
|
80
82
|
}, [progress]);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
onCancelHandler();
|
|
89
|
-
}
|
|
90
|
-
// The 0 timeout ensures that the dialog will not re-open immediately after the close event is triggered.
|
|
91
|
-
}, 0);
|
|
92
|
-
};
|
|
93
|
-
resolvedTarget?.addEventListener('click', closeDialog);
|
|
94
|
-
return () => {
|
|
95
|
-
resolvedTarget?.removeEventListener('click', closeDialog);
|
|
96
|
-
};
|
|
97
|
-
}, [resolvedTarget, onDismiss, onCancelHandler]);
|
|
83
|
+
// The 0 timeout ensures that the dialog will not re-open immediately after the close event is triggered.
|
|
84
|
+
useEvent('click', () => setTimeout(closeDialog, 0), {
|
|
85
|
+
target: resolvedTarget,
|
|
86
|
+
dependencies: [resolvedTarget, closeDialog]
|
|
87
|
+
});
|
|
98
88
|
const cancelButton = (() => {
|
|
99
89
|
const label = typeof onCancel !== 'function' && onCancel.text ? onCancel.text : t('cancel');
|
|
100
|
-
return (_jsx(Button, { icon: compact, label: compact ? label : undefined, disabled: typeof onCancel !== 'function' ? onCancel.disabled : undefined, onClick: () => {
|
|
101
|
-
onCancelHandler();
|
|
90
|
+
return (_jsx(Button, { icon: compact, label: compact ? label : undefined, disabled: typeof onCancel !== 'function' ? onCancel.disabled : undefined, onClick: async () => {
|
|
91
|
+
const result = await onCancelHandler();
|
|
92
|
+
if (result !== false) {
|
|
93
|
+
onAfterClose?.();
|
|
94
|
+
}
|
|
102
95
|
}, children: compact ? _jsx(Icon, { name: 'times' }) : label }));
|
|
103
96
|
})();
|
|
104
97
|
const submitButton = (() => {
|
|
105
98
|
const label = typeof onSubmit !== 'function' && onSubmit.text ? onSubmit.text : t('submit');
|
|
106
|
-
return (_jsx(Button, { icon: compact, label: compact ? label : undefined, variant: 'primary', disabled: typeof onSubmit !== 'function' ? onSubmit.disabled : undefined, onClick: () => {
|
|
107
|
-
(typeof onSubmit !== 'function' ? onSubmit.handler : onSubmit)();
|
|
99
|
+
return (_jsx(Button, { icon: compact, label: compact ? label : undefined, variant: 'primary', disabled: typeof onSubmit !== 'function' ? onSubmit.disabled : undefined, onClick: async () => {
|
|
100
|
+
const result = await (typeof onSubmit !== 'function' ? onSubmit.handler : onSubmit)();
|
|
101
|
+
if (result !== false) {
|
|
102
|
+
onAfterClose?.();
|
|
103
|
+
}
|
|
108
104
|
}, children: compact ? _jsx(Icon, { name: 'check' }) : label }));
|
|
109
105
|
})();
|
|
110
106
|
const layout = (() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/FormDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,MAAM,MAAM,mBAAmB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YACxB,CAAC,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE;YAC7B,CAAC,CAAC,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC,EACrC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,SAAS,YAEb,MAAM,GACU,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, useEffect, useLayoutEffect, useRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\nimport styled from 'styled-components';\n\nimport {\n useConsolidatedRef,\n useContentTabIndex,\n useEscape,\n useI18n,\n useOuterEvent,\n useUID\n} from '../../hooks';\nimport { getActiveElement, focusNonInteractiveElement, getFocusables } from '../../utils';\nimport Button, { StyledButton } from '../Button';\nimport Text from '../Text';\nimport Progress from '../Progress';\nimport AdditionalInfo from '../AdditionalInfo';\nimport type { RefElement } from '../../types';\nimport Flex from '../Flex';\nimport getResolvedTarget from '../Popover/getResolvedTarget';\nimport Icon from '../Icon';\n\nimport {\n StyledChildrenWrap,\n StyledDialogContent,\n StyledDialogFooter,\n StyledDialogHeader\n} from './Dialog.styles';\nimport type { FormDialogProps } from './Dialog.types';\nimport Dialog from './Dialog';\n\nconst StyledCompactDialogContent = styled.div``;\n\nconst StyledCompactActions = styled.div`\n ${StyledButton} {\n margin-inline-start: unset;\n }\n`;\n\nexport const StyledFormDialog = styled(Dialog)``;\n\nconst FormDialog = forwardRef<RefElement<FormDialogProps>, PropsWithoutRef<FormDialogProps>>(\n function FormDialog(\n {\n arrow = true,\n compact,\n target,\n heading,\n 'aria-label': ariaLabel,\n children,\n progress,\n onDismiss,\n onCancel,\n onSubmit,\n additionalInfo,\n ...restProps\n },\n ref\n ) {\n const t = useI18n();\n const headingId = useUID();\n const headingRef = useRef<HTMLHeadingElement>(null);\n const dialogRef = useConsolidatedRef(ref);\n const dialogContentRef = useRef<HTMLDivElement>(null);\n const contentTabIndex = useContentTabIndex(dialogRef, dialogContentRef, [], [progress]);\n const resolvedTarget = getResolvedTarget(target);\n\n const setFocus = () => {\n if (progress || !dialogRef.current) return;\n if (headingRef.current) {\n focusNonInteractiveElement(headingRef.current, heading ?? ariaLabel);\n } else if (compact) {\n const focusables = getFocusables(dialogContentRef);\n if (focusables[0]) {\n focusables[0].focus();\n } else {\n focusNonInteractiveElement(dialogRef.current, heading ?? ariaLabel);\n }\n } else {\n focusNonInteractiveElement(dialogRef.current, heading ?? ariaLabel);\n }\n };\n\n const onCancelHandler = typeof onCancel === 'function' ? onCancel : onCancel.handler;\n\n useEscape(\n e => {\n if (onDismiss) {\n onDismiss();\n } else {\n onCancelHandler();\n }\n e.stopPropagation();\n },\n dialogRef,\n [onDismiss, onCancelHandler]\n );\n\n useOuterEvent('mousedown', [resolvedTarget, dialogRef], () => {\n if (onDismiss) {\n onDismiss();\n } else {\n onCancelHandler();\n }\n });\n\n // Using layout effect to capture the focused element prior to dialog elements taking focus.\n useLayoutEffect(() => {\n const initiatorElement = getActiveElement();\n\n return () => {\n if (initiatorElement instanceof HTMLElement && initiatorElement.isConnected) {\n initiatorElement.focus();\n }\n };\n }, []);\n\n useEffect(() => {\n if (!progress) {\n setFocus();\n }\n }, [progress]);\n\n useEffect(() => {\n const closeDialog = () => {\n setTimeout(() => {\n if (onDismiss) {\n onDismiss();\n } else {\n onCancelHandler();\n }\n // The 0 timeout ensures that the dialog will not re-open immediately after the close event is triggered.\n }, 0);\n };\n\n resolvedTarget?.addEventListener('click', closeDialog);\n\n return () => {\n resolvedTarget?.removeEventListener('click', closeDialog);\n };\n }, [resolvedTarget, onDismiss, onCancelHandler]);\n\n const cancelButton = (() => {\n const label = typeof onCancel !== 'function' && onCancel.text ? onCancel.text : t('cancel');\n\n return (\n <Button\n icon={compact}\n label={compact ? label : undefined}\n disabled={typeof onCancel !== 'function' ? onCancel.disabled : undefined}\n onClick={() => {\n onCancelHandler();\n }}\n >\n {compact ? <Icon name='times' /> : label}\n </Button>\n );\n })();\n\n const submitButton = (() => {\n const label = typeof onSubmit !== 'function' && onSubmit.text ? onSubmit.text : t('submit');\n\n return (\n <Button\n icon={compact}\n label={compact ? label : undefined}\n variant='primary'\n disabled={typeof onSubmit !== 'function' ? onSubmit.disabled : undefined}\n onClick={() => {\n (typeof onSubmit !== 'function' ? onSubmit.handler : onSubmit)();\n }}\n >\n {compact ? <Icon name='check' /> : label}\n </Button>\n );\n })();\n\n const layout = (() => {\n if (compact) {\n return (\n <Flex\n container={{ alignItems: 'start', pad: 0.75, colGap: 1 }}\n as={StyledCompactDialogContent}\n ref={dialogContentRef}\n >\n {progress && (\n <Progress\n visible={!!progress}\n focusOnVisible\n placement='local'\n message={typeof progress === 'string' ? progress : undefined}\n />\n )}\n {children && (\n <Flex item={{ grow: 1 }} as={StyledChildrenWrap} inert={progress ? '' : undefined}>\n {children}\n </Flex>\n )}\n <Flex\n container={{ alignItems: 'start', colGap: 0.5 }}\n item={{ shrink: 0 }}\n as={StyledCompactActions}\n >\n {cancelButton}\n {submitButton}\n </Flex>\n </Flex>\n );\n }\n\n return (\n <>\n {heading !== undefined && (\n <Flex\n container={{\n alignItems: 'center',\n gap: additionalInfo?.heading ? 1 : undefined,\n pad: [2, 2, 1]\n }}\n item={{ shrink: 0 }}\n as={StyledDialogHeader}\n >\n <Text ref={headingRef} id={headingId} variant='h2'>\n {heading}\n </Text>\n {additionalInfo?.heading && (\n <AdditionalInfo heading={additionalInfo.heading}>\n {additionalInfo.children}\n </AdditionalInfo>\n )}\n </Flex>\n )}\n <Flex\n item={{ grow: 1 }}\n as={StyledDialogContent}\n ref={dialogContentRef}\n tabIndex={contentTabIndex}\n >\n {children && (\n <StyledChildrenWrap inert={progress ? '' : undefined}>{children}</StyledChildrenWrap>\n )}\n <Progress\n visible={!!progress}\n focusOnVisible\n placement='local'\n message={typeof progress === 'string' ? progress : undefined}\n />\n </Flex>\n <Flex\n container={{ alignItems: 'center', justify: 'between', pad: 2 }}\n item={{ shrink: 0 }}\n as={StyledDialogFooter}\n >\n {cancelButton}\n {submitButton}\n </Flex>\n </>\n );\n })();\n\n return (\n <StyledFormDialog\n {...restProps}\n {...(heading === undefined\n ? { 'aria-label': ariaLabel }\n : { 'aria-labelledby': headingId })}\n arrow={arrow}\n target={target}\n progress={progress}\n ref={dialogRef}\n >\n {layout}\n </StyledFormDialog>\n );\n }\n);\n\nexport default FormDialog;\n"]}
|
|
1
|
+
{"version":3,"file":"FormDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/FormDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpF,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,OAAO,EACP,aAAa,EACb,MAAM,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAE/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAEhD,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAA;I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,kBAAkB,IAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,YAAG,QAAQ,GAAsB,CACtF,EACD,KAAC,QAAQ,IACP,OAAO,EAAE,CAAC,CAAC,QAAQ,EACnB,cAAc,QACd,SAAS,EAAC,OAAO,EACjB,OAAO,EAAE,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,GAC5D,IACG,EACP,MAAC,IAAI,IACH,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,EAAE,EAC/D,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,EACnB,EAAE,EAAE,kBAAkB,aAErB,YAAY,EACZ,YAAY,IACR,IACN,CACJ,CAAC;IACJ,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,CACL,KAAC,gBAAgB,OACX,SAAS,KACT,CAAC,OAAO,KAAK,SAAS;YACxB,CAAC,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE;YAC7B,CAAC,CAAC,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC,EACrC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,SAAS,YAEb,MAAM,GACU,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, useCallback, useEffect, useLayoutEffect, useRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\nimport styled from 'styled-components';\n\nimport {\n useConsolidatedRef,\n useContentTabIndex,\n useEscape,\n useEvent,\n useI18n,\n useOuterEvent,\n useUID\n} from '../../hooks';\nimport { getActiveElement, focusNonInteractiveElement, getFocusables } from '../../utils';\nimport Button, { StyledButton } from '../Button';\nimport Text from '../Text';\nimport Progress from '../Progress';\nimport AdditionalInfo from '../AdditionalInfo';\nimport type { RefElement } from '../../types';\nimport Flex from '../Flex';\nimport getResolvedTarget from '../Popover/getResolvedTarget';\nimport Icon from '../Icon';\n\nimport {\n StyledChildrenWrap,\n StyledDialogContent,\n StyledDialogFooter,\n StyledDialogHeader\n} from './Dialog.styles';\nimport type { FormDialogProps } from './Dialog.types';\nimport Dialog from './Dialog';\n\nconst StyledCompactDialogContent = styled.div``;\n\nconst StyledCompactActions = styled.div`\n ${StyledButton} {\n margin-inline-start: unset;\n }\n`;\n\nexport const StyledFormDialog = styled(Dialog)``;\n\nconst FormDialog = forwardRef<RefElement<FormDialogProps>, PropsWithoutRef<FormDialogProps>>(\n function FormDialog(\n {\n arrow = true,\n compact,\n target,\n heading,\n 'aria-label': ariaLabel,\n children,\n progress,\n onDismiss,\n onCancel = () => true,\n onSubmit,\n onAfterClose,\n additionalInfo,\n ...restProps\n },\n ref\n ) {\n const t = useI18n();\n const headingId = useUID();\n const headingRef = useRef<HTMLHeadingElement>(null);\n const dialogRef = useConsolidatedRef(ref);\n const dialogContentRef = useRef<HTMLDivElement>(null);\n const contentTabIndex = useContentTabIndex(dialogRef, dialogContentRef, [], [progress]);\n const resolvedTarget = getResolvedTarget(target);\n\n const setFocus = () => {\n if (progress || !dialogRef.current) return;\n if (headingRef.current) {\n focusNonInteractiveElement(headingRef.current, heading ?? ariaLabel);\n } else if (compact) {\n const focusables = getFocusables(dialogContentRef);\n if (focusables[0]) {\n focusables[0].focus();\n } else {\n focusNonInteractiveElement(dialogRef.current, heading ?? ariaLabel);\n }\n } else {\n focusNonInteractiveElement(dialogRef.current, heading ?? ariaLabel);\n }\n };\n\n const onCancelHandler = typeof onCancel === 'function' ? onCancel : onCancel.handler;\n\n const closeDialog = useCallback(async () => {\n if (onDismiss) {\n onDismiss();\n onAfterClose?.();\n } else {\n const result = await onCancelHandler();\n if (result !== false) {\n onAfterClose?.();\n }\n }\n }, [onDismiss, onCancelHandler, onAfterClose]);\n\n useEscape(\n e => {\n closeDialog();\n e.stopPropagation();\n },\n dialogRef,\n [closeDialog]\n );\n\n useOuterEvent('mousedown', [resolvedTarget, dialogRef], () => {\n closeDialog();\n });\n\n // Using layout effect to capture the focused element prior to dialog elements taking focus.\n useLayoutEffect(() => {\n const initiatorElement = getActiveElement();\n\n return () => {\n if (initiatorElement instanceof HTMLElement && initiatorElement.isConnected) {\n initiatorElement.focus();\n }\n };\n }, []);\n\n useEffect(() => {\n if (!progress) {\n setFocus();\n }\n }, [progress]);\n\n // The 0 timeout ensures that the dialog will not re-open immediately after the close event is triggered.\n useEvent('click', () => setTimeout(closeDialog, 0), {\n target: resolvedTarget,\n dependencies: [resolvedTarget, closeDialog]\n });\n\n const cancelButton = (() => {\n const label = typeof onCancel !== 'function' && onCancel.text ? onCancel.text : t('cancel');\n\n return (\n <Button\n icon={compact}\n label={compact ? label : undefined}\n disabled={typeof onCancel !== 'function' ? onCancel.disabled : undefined}\n onClick={async () => {\n const result = await onCancelHandler();\n if (result !== false) {\n onAfterClose?.();\n }\n }}\n >\n {compact ? <Icon name='times' /> : label}\n </Button>\n );\n })();\n\n const submitButton = (() => {\n const label = typeof onSubmit !== 'function' && onSubmit.text ? onSubmit.text : t('submit');\n\n return (\n <Button\n icon={compact}\n label={compact ? label : undefined}\n variant='primary'\n disabled={typeof onSubmit !== 'function' ? onSubmit.disabled : undefined}\n onClick={async () => {\n const result = await (typeof onSubmit !== 'function' ? onSubmit.handler : onSubmit)();\n if (result !== false) {\n onAfterClose?.();\n }\n }}\n >\n {compact ? <Icon name='check' /> : label}\n </Button>\n );\n })();\n\n const layout = (() => {\n if (compact) {\n return (\n <Flex\n container={{ alignItems: 'start', pad: 0.75, colGap: 1 }}\n as={StyledCompactDialogContent}\n ref={dialogContentRef}\n >\n {progress && (\n <Progress\n visible={!!progress}\n focusOnVisible\n placement='local'\n message={typeof progress === 'string' ? progress : undefined}\n />\n )}\n {children && (\n <Flex item={{ grow: 1 }} as={StyledChildrenWrap} inert={progress ? '' : undefined}>\n {children}\n </Flex>\n )}\n <Flex\n container={{ alignItems: 'start', colGap: 0.5 }}\n item={{ shrink: 0 }}\n as={StyledCompactActions}\n >\n {cancelButton}\n {submitButton}\n </Flex>\n </Flex>\n );\n }\n\n return (\n <>\n {heading !== undefined && (\n <Flex\n container={{\n alignItems: 'center',\n gap: additionalInfo?.heading ? 1 : undefined,\n pad: [2, 2, 1]\n }}\n item={{ shrink: 0 }}\n as={StyledDialogHeader}\n >\n <Text ref={headingRef} id={headingId} variant='h2'>\n {heading}\n </Text>\n {additionalInfo?.heading && (\n <AdditionalInfo heading={additionalInfo.heading}>\n {additionalInfo.children}\n </AdditionalInfo>\n )}\n </Flex>\n )}\n <Flex\n item={{ grow: 1 }}\n as={StyledDialogContent}\n ref={dialogContentRef}\n tabIndex={contentTabIndex}\n >\n {children && (\n <StyledChildrenWrap inert={progress ? '' : undefined}>{children}</StyledChildrenWrap>\n )}\n <Progress\n visible={!!progress}\n focusOnVisible\n placement='local'\n message={typeof progress === 'string' ? progress : undefined}\n />\n </Flex>\n <Flex\n container={{ alignItems: 'center', justify: 'between', pad: 2 }}\n item={{ shrink: 0 }}\n as={StyledDialogFooter}\n >\n {cancelButton}\n {submitButton}\n </Flex>\n </>\n );\n })();\n\n return (\n <StyledFormDialog\n {...restProps}\n {...(heading === undefined\n ? { 'aria-label': ariaLabel }\n : { 'aria-labelledby': headingId })}\n arrow={arrow}\n target={target}\n progress={progress}\n ref={dialogRef}\n >\n {layout}\n </StyledFormDialog>\n );\n }\n);\n\nexport default FormDialog;\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PropsWithoutRef } from 'react';
|
|
2
|
+
import type { FormDialogProps } from './Dialog.types';
|
|
3
|
+
declare const FormDialogWrapper: import("react").ForwardRefExoticComponent<PropsWithoutRef<FormDialogProps> & import("react").RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export default FormDialogWrapper;
|
|
5
|
+
//# sourceMappingURL=FormDialogWrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormDialogWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/FormDialogWrapper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAK7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD,QAAA,MAAM,iBAAiB,6HAQtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { isTouchDevice } from '../../utils';
|
|
4
|
+
import FormDialog from './FormDialog';
|
|
5
|
+
import TouchFormDialog from './TouchFormDialog';
|
|
6
|
+
const FormDialogWrapper = forwardRef(function FormDialogWrapper(props, ref) {
|
|
7
|
+
if (isTouchDevice) {
|
|
8
|
+
return _jsx(TouchFormDialog, { ...props, ref: ref });
|
|
9
|
+
}
|
|
10
|
+
return _jsx(FormDialog, { ...props, ref: ref });
|
|
11
|
+
});
|
|
12
|
+
export default FormDialogWrapper;
|
|
13
|
+
//# sourceMappingURL=FormDialogWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormDialogWrapper.js","sourceRoot":"","sources":["../../../src/components/Dialog/FormDialogWrapper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAInC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,iBAAiB,GAAG,UAAU,CAClC,SAAS,iBAAiB,CAAC,KAAK,EAAE,GAAG;IACnC,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,KAAC,eAAe,OAAK,KAAK,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;IAClD,CAAC;IAED,OAAO,KAAC,UAAU,OAAK,KAAK,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;AAC7C,CAAC,CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\n\nimport type { RefElement } from '../../types';\nimport { isTouchDevice } from '../../utils';\n\nimport type { FormDialogProps } from './Dialog.types';\nimport FormDialog from './FormDialog';\nimport TouchFormDialog from './TouchFormDialog';\n\nconst FormDialogWrapper = forwardRef<RefElement<FormDialogProps>, PropsWithoutRef<FormDialogProps>>(\n function FormDialogWrapper(props, ref) {\n if (isTouchDevice) {\n return <TouchFormDialog {...props} ref={ref} />;\n }\n\n return <FormDialog {...props} ref={ref} />;\n }\n);\n\nexport default FormDialogWrapper;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TouchDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAkBnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAY5D,QAAA,MAAM,WAAW,EAAE,+BAA+B,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"TouchDialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAkBnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAY5D,QAAA,MAAM,WAAW,EAAE,+BAA+B,CAAC,gBAAgB,CAgPlE,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import { useConsolidatedRef, useConfiguration, useFocusTrap, useI18n, useTestIds, useEscape, useUID, useEvent } from '../../hooks';
|
|
@@ -12,7 +12,7 @@ import { focusNonInteractiveElement, getActiveElement, isInstance } from '../../
|
|
|
12
12
|
import Progress from '../Progress';
|
|
13
13
|
import { StyledTouchDialogContent, StyledTouchDialogHeader, StyledTouchDialog, StyledTouchDialogBackdrop, StyledExpandCollapse } from './TouchDialog.styles';
|
|
14
14
|
import { getTouchDialogTestIds } from './TouchDialog.test-ids';
|
|
15
|
-
import { StyledChildrenWrap } from './Dialog.styles';
|
|
15
|
+
import { StyledChildrenWrap, StyledDialogFooter } from './Dialog.styles';
|
|
16
16
|
registerIcon(caretUp, timesIcon);
|
|
17
17
|
const drawerSizeMapping = {
|
|
18
18
|
auto: 'auto',
|
|
@@ -20,7 +20,7 @@ const drawerSizeMapping = {
|
|
|
20
20
|
half: '50dvh',
|
|
21
21
|
full: '90dvh'
|
|
22
22
|
};
|
|
23
|
-
const TouchDialog = forwardRef(function TouchDialog({ open, onDismiss: onDismissProp, children, size = 'half', onBeforeOpen, onAfterOpen: onAfterOpenProp, onBeforeClose, onAfterClose, heading, 'aria-label': ariaLabel, progress: progressProp, outerClickAction = 'close', testId, ...restProps }, ref) {
|
|
23
|
+
const TouchDialog = forwardRef(function TouchDialog({ open, onDismiss: onDismissProp, children, footer, size = 'half', onBeforeOpen, onAfterOpen: onAfterOpenProp, onBeforeClose, onAfterClose, heading, 'aria-label': ariaLabel, progress: progressProp, outerClickAction = 'close', testId, ...restProps }, ref) {
|
|
24
24
|
const dialogRef = useConsolidatedRef(ref);
|
|
25
25
|
const backdropRef = useRef(null);
|
|
26
26
|
const t = useI18n();
|
|
@@ -78,12 +78,12 @@ const TouchDialog = forwardRef(function TouchDialog({ open, onDismiss: onDismiss
|
|
|
78
78
|
}
|
|
79
79
|
}, [progressProp, setFocus]);
|
|
80
80
|
useEscape(e => {
|
|
81
|
-
onDismiss
|
|
81
|
+
onDismiss();
|
|
82
82
|
e.stopPropagation();
|
|
83
83
|
}, dialogRef, [onDismiss]);
|
|
84
84
|
const progress = (_jsx(Progress, { visible: !!progressProp, focusOnVisible: true, placement: 'local', message: typeof progressProp === 'string' ? progressProp : undefined }));
|
|
85
85
|
const isCompact = isFullCompact && drawerSize === 'compact';
|
|
86
|
-
const hasContent = children !== undefined || progressProp !== undefined;
|
|
86
|
+
const hasContent = children !== undefined || footer !== undefined || progressProp !== undefined;
|
|
87
87
|
const dismissButton = (_jsx(Button, { "data-testid": testIds.dismiss, variant: 'simple', icon: true, label: t('dismiss'), onClick: onDismiss, children: _jsx(Icon, { name: 'times' }) }));
|
|
88
88
|
useEvent('click', e => {
|
|
89
89
|
if (open && e.target === backdropRef.current) {
|
|
@@ -105,7 +105,7 @@ const TouchDialog = forwardRef(function TouchDialog({ open, onDismiss: onDismiss
|
|
|
105
105
|
returnRef.current.focus();
|
|
106
106
|
}
|
|
107
107
|
onAfterClose?.();
|
|
108
|
-
}, children: _jsxs(StyledTouchDialog, { "data-testid": testIds.root, "aria-labelledby": heading ? headingId : undefined, "aria-label": ariaLabel, ...restProps, ref: dialogRef, open: drawerOpen, placement: 'bottom', position: 'fixed', size: drawerSizeMapping[drawerSize], shadow: true, onAfterOpen: onAfterOpen, onBeforeClose: onBeforeClose, role: 'dialog', "aria-modal": shouldTrapFocus ? 'true' : undefined, "aria-busy": !!progressProp, children: [_jsxs(Flex, { container: { direction: 'row', justify: 'between', alignItems: 'center' }, as: StyledTouchDialogHeader, children: [typeof heading === 'string' ? (_jsx(Text, { variant: 'h2', ref: headingRef, id: headingId, children: heading })) : (heading && (_jsx(Flex, { item: { grow: 1 }, ref: headingWrapperRef, id: headingId, children: heading }))), dismissButton] }), hasContent && (_jsxs(Flex, { as: StyledTouchDialogContent, container: { gap: 1, direction: 'column' }, hidden: isCompact && !progressProp, children: [children && (_jsx(StyledChildrenWrap, { inert: progressProp || isCompact ? '' : undefined, hidden: isCompact, children: children })), progress] })), (!isAutoSize || isFullCompact) && (_jsx(StyledExpandCollapse, { onToggle: () => {
|
|
108
|
+
}, children: _jsxs(StyledTouchDialog, { "data-testid": testIds.root, "aria-labelledby": heading ? headingId : undefined, "aria-label": ariaLabel, ...restProps, ref: dialogRef, open: drawerOpen, placement: 'bottom', position: 'fixed', size: drawerSizeMapping[drawerSize], shadow: true, onAfterOpen: onAfterOpen, onBeforeClose: onBeforeClose, role: 'dialog', "aria-modal": shouldTrapFocus ? 'true' : undefined, "aria-busy": !!progressProp, children: [_jsxs(Flex, { container: { direction: 'row', justify: 'between', alignItems: 'center' }, as: StyledTouchDialogHeader, children: [typeof heading === 'string' ? (_jsx(Text, { variant: 'h2', ref: headingRef, id: headingId, children: heading })) : (heading && (_jsx(Flex, { item: { grow: 1 }, ref: headingWrapperRef, id: headingId, children: heading }))), dismissButton] }), hasContent && (_jsxs(_Fragment, { children: [_jsxs(Flex, { as: StyledTouchDialogContent, container: { gap: 1, direction: 'column' }, hidden: isCompact && !progressProp, children: [children && (_jsx(StyledChildrenWrap, { inert: progressProp || isCompact ? '' : undefined, hidden: isCompact, children: children })), progress] }), footer && (_jsx(Flex, { container: { alignItems: 'center', justify: 'between', pad: [0, 1, 1] }, item: { shrink: 0 }, as: StyledDialogFooter, hidden: isCompact, inert: isCompact ? '' : undefined, children: footer }))] })), (!isAutoSize || isFullCompact) && (_jsx(StyledExpandCollapse, { onToggle: () => {
|
|
109
109
|
setDrawerSize(prev => {
|
|
110
110
|
if (isFullCompact)
|
|
111
111
|
return prev === 'compact' ? 'full' : 'compact';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TouchDialog.js","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EA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CAAC,CAAC,CAAC,SAAS,CAAC;4BAClE,IAAI,IAAI,KAAK,MAAM;gCAAE,OAAO,MAAM,CAAC;4BACnC,OAAO,MAAM,CAAC;wBAChB,CAAC,CAAC,CAAC;oBACL,CAAC,EACD,QAAQ,EAAE,UAAU,KAAK,MAAM,EAC/B,OAAO,QACP,QAAQ,SACR,CACH,IACiB,GACM,CAC7B,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 useEvent\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 { focusNonInteractiveElement, getActiveElement, isInstance } from '../../utils';\nimport Progress from '../Progress';\n\nimport {\n StyledTouchDialogContent,\n StyledTouchDialogHeader,\n StyledTouchDialog,\n StyledTouchDialogBackdrop,\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 compact: 'var(--touch-dialog-compact-height)',\n half: '50dvh',\n full: '90dvh'\n} as const;\n\nconst 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 'aria-label': ariaLabel,\n progress: progressProp,\n outerClickAction = 'close',\n testId,\n ...restProps\n }: PropsWithoutRef<TouchDialogProps>,\n ref: TouchDialogProps['ref']\n ) {\n const dialogRef = useConsolidatedRef(ref);\n const backdropRef = useRef<HTMLDivElement>(null);\n const t = useI18n();\n const { portalTarget } = useConfiguration();\n const headingRef = useRef<HTMLHeadingElement>(null);\n const headingWrapperRef = useRef<HTMLDivElement>(null);\n const isFullCompact = size === 'full-compact';\n const [drawerSize, setDrawerSize] = useState<'auto' | 'compact' | 'half' | 'full'>(\n isFullCompact ? 'full' : size\n );\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(isFullCompact ? 'full' : size);\n }, [size]);\n\n const isAutoSize = size === 'auto' || isFullCompact;\n\n const resetSize = useCallback(() => {\n setDrawerSize(isFullCompact ? 'compact' : size);\n }, [size]);\n\n const shouldTrapFocus = open && drawerOpen && !(isFullCompact && drawerSize === 'compact');\n\n useFocusTrap(shouldTrapFocus ? dialogRef : null, false, [shouldTrapFocus]);\n\n const setFocus = useCallback(() => {\n if (progressProp || !drawerOpen || dialogRef.current?.contains(getActiveElement())) return;\n if (headingWrapperRef.current) {\n focusNonInteractiveElement(\n headingWrapperRef.current.querySelector('h2') ?? headingWrapperRef.current,\n ariaLabel\n );\n } else if (headingRef.current) {\n focusNonInteractiveElement(headingRef.current, ariaLabel);\n } else if (dialogRef.current) {\n focusNonInteractiveElement(dialogRef.current, ariaLabel);\n }\n }, [progressProp, drawerOpen, heading, ariaLabel]);\n\n const onDismiss = useCallback(() => {\n setDrawerOpen(false);\n onDismissProp?.();\n }, [onDismissProp]);\n\n const onOuterClick = useCallback(() => {\n if (outerClickAction === 'reset-size') {\n resetSize();\n } else {\n onDismiss();\n }\n }, [onDismiss, outerClickAction, resetSize]);\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 const isCompact = isFullCompact && drawerSize === 'compact';\n const hasContent = children !== undefined || progressProp !== undefined;\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 useEvent(\n 'click',\n e => {\n if (open && e.target === backdropRef.current) {\n onOuterClick();\n }\n },\n { target: backdropRef, dependencies: [onOuterClick, open] }\n );\n\n const content = (\n <StyledTouchDialogBackdrop\n ref={backdropRef}\n open={open}\n $compact={isCompact}\n onBeforeTransitionIn={() => {\n setDrawerOpen(true);\n if (isFullCompact) setDrawerSize('full');\n returnRef.current = getActiveElement();\n onBeforeOpen?.();\n }}\n onBeforeTransitionOut={() => {\n setDrawerOpen(false);\n }}\n onAfterTransitionOut={() => {\n resetSize();\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 aria-labelledby={heading ? headingId : undefined}\n aria-label={ariaLabel}\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 role='dialog'\n aria-modal={shouldTrapFocus ? 'true' : undefined}\n aria-busy={!!progressProp}\n >\n <Flex\n container={{ direction: 'row', justify: 'between', alignItems: 'center' }}\n as={StyledTouchDialogHeader}\n >\n {typeof heading === 'string' ? (\n <Text variant='h2' ref={headingRef} id={headingId}>\n {heading}\n </Text>\n ) : (\n heading && (\n <Flex item={{ grow: 1 }} ref={headingWrapperRef} id={headingId}>\n {heading}\n </Flex>\n )\n )}\n {dismissButton}\n </Flex>\n {hasContent && (\n <Flex\n as={StyledTouchDialogContent}\n container={{ gap: 1, direction: 'column' }}\n hidden={isCompact && !progressProp}\n >\n {children && (\n <StyledChildrenWrap\n inert={progressProp || isCompact ? '' : undefined}\n hidden={isCompact}\n >\n {children}\n </StyledChildrenWrap>\n )}\n {progress}\n </Flex>\n )}\n {(!isAutoSize || isFullCompact) && (\n <StyledExpandCollapse\n onToggle={() => {\n setDrawerSize(prev => {\n if (isFullCompact) return prev === 'compact' ? 'full' : 'compact';\n if (prev === 'full') return 'half';\n return 'full';\n });\n }}\n expanded={drawerSize === 'full'}\n compact\n iconOnly\n />\n )}\n </StyledTouchDialog>\n </StyledTouchDialogBackdrop>\n );\n\n return portalTarget ? createPortal(content, portalTarget) : content;\n }\n);\n\nexport default TouchDialog;\n"]}
|
|
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,EACN,QAAQ,EACT,MAAM,aAAa,CAAC;AAErB,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MA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ACb,aAAa,CAAC,IAAI,CAAC,EAAE;4BACnB,IAAI,aAAa;gCAAE,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;4BAClE,IAAI,IAAI,KAAK,MAAM;gCAAE,OAAO,MAAM,CAAC;4BACnC,OAAO,MAAM,CAAC;wBAChB,CAAC,CAAC,CAAC;oBACL,CAAC,EACD,QAAQ,EAAE,UAAU,KAAK,MAAM,EAC/B,OAAO,QACP,QAAQ,SACR,CACH,IACiB,GACM,CAC7B,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 useEvent\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 { focusNonInteractiveElement, getActiveElement, isInstance } from '../../utils';\nimport Progress from '../Progress';\n\nimport {\n StyledTouchDialogContent,\n StyledTouchDialogHeader,\n StyledTouchDialog,\n StyledTouchDialogBackdrop,\n StyledExpandCollapse\n} from './TouchDialog.styles';\nimport { getTouchDialogTestIds } from './TouchDialog.test-ids';\nimport type { TouchDialogProps } from './TouchDialog.types';\nimport { StyledChildrenWrap, StyledDialogFooter } from './Dialog.styles';\n\nregisterIcon(caretUp, timesIcon);\n\nconst drawerSizeMapping = {\n auto: 'auto',\n compact: 'var(--touch-dialog-compact-height)',\n half: '50dvh',\n full: '90dvh'\n} as const;\n\nconst TouchDialog: ForwardRefForwardPropsComponent<TouchDialogProps> = forwardRef(\n function TouchDialog(\n {\n open,\n onDismiss: onDismissProp,\n children,\n footer,\n size = 'half',\n onBeforeOpen,\n onAfterOpen: onAfterOpenProp,\n onBeforeClose,\n onAfterClose,\n heading,\n 'aria-label': ariaLabel,\n progress: progressProp,\n outerClickAction = 'close',\n testId,\n ...restProps\n }: PropsWithoutRef<TouchDialogProps>,\n ref: TouchDialogProps['ref']\n ) {\n const dialogRef = useConsolidatedRef(ref);\n const backdropRef = useRef<HTMLDivElement>(null);\n const t = useI18n();\n const { portalTarget } = useConfiguration();\n const headingRef = useRef<HTMLHeadingElement>(null);\n const headingWrapperRef = useRef<HTMLDivElement>(null);\n const isFullCompact = size === 'full-compact';\n const [drawerSize, setDrawerSize] = useState<'auto' | 'compact' | 'half' | 'full'>(\n isFullCompact ? 'full' : size\n );\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(isFullCompact ? 'full' : size);\n }, [size]);\n\n const isAutoSize = size === 'auto' || isFullCompact;\n\n const resetSize = useCallback(() => {\n setDrawerSize(isFullCompact ? 'compact' : size);\n }, [size]);\n\n const shouldTrapFocus = open && drawerOpen && !(isFullCompact && drawerSize === 'compact');\n\n useFocusTrap(shouldTrapFocus ? dialogRef : null, false, [shouldTrapFocus]);\n\n const setFocus = useCallback(() => {\n if (progressProp || !drawerOpen || dialogRef.current?.contains(getActiveElement())) return;\n if (headingWrapperRef.current) {\n focusNonInteractiveElement(\n headingWrapperRef.current.querySelector('h2') ?? headingWrapperRef.current,\n ariaLabel\n );\n } else if (headingRef.current) {\n focusNonInteractiveElement(headingRef.current, ariaLabel);\n } else if (dialogRef.current) {\n focusNonInteractiveElement(dialogRef.current, ariaLabel);\n }\n }, [progressProp, drawerOpen, heading, ariaLabel]);\n\n const onDismiss = useCallback(() => {\n setDrawerOpen(false);\n onDismissProp?.();\n }, [onDismissProp]);\n\n const onOuterClick = useCallback(() => {\n if (outerClickAction === 'reset-size') {\n resetSize();\n } else {\n onDismiss();\n }\n }, [onDismiss, outerClickAction, resetSize]);\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 const isCompact = isFullCompact && drawerSize === 'compact';\n const hasContent = children !== undefined || footer !== undefined || progressProp !== undefined;\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 useEvent(\n 'click',\n e => {\n if (open && e.target === backdropRef.current) {\n onOuterClick();\n }\n },\n { target: backdropRef, dependencies: [onOuterClick, open] }\n );\n\n const content = (\n <StyledTouchDialogBackdrop\n ref={backdropRef}\n open={open}\n $compact={isCompact}\n onBeforeTransitionIn={() => {\n setDrawerOpen(true);\n if (isFullCompact) setDrawerSize('full');\n returnRef.current = getActiveElement();\n onBeforeOpen?.();\n }}\n onBeforeTransitionOut={() => {\n setDrawerOpen(false);\n }}\n onAfterTransitionOut={() => {\n resetSize();\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 aria-labelledby={heading ? headingId : undefined}\n aria-label={ariaLabel}\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 role='dialog'\n aria-modal={shouldTrapFocus ? 'true' : undefined}\n aria-busy={!!progressProp}\n >\n <Flex\n container={{ direction: 'row', justify: 'between', alignItems: 'center' }}\n as={StyledTouchDialogHeader}\n >\n {typeof heading === 'string' ? (\n <Text variant='h2' ref={headingRef} id={headingId}>\n {heading}\n </Text>\n ) : (\n heading && (\n <Flex item={{ grow: 1 }} ref={headingWrapperRef} id={headingId}>\n {heading}\n </Flex>\n )\n )}\n {dismissButton}\n </Flex>\n {hasContent && (\n <>\n <Flex\n as={StyledTouchDialogContent}\n container={{ gap: 1, direction: 'column' }}\n hidden={isCompact && !progressProp}\n >\n {children && (\n <StyledChildrenWrap\n inert={progressProp || isCompact ? '' : undefined}\n hidden={isCompact}\n >\n {children}\n </StyledChildrenWrap>\n )}\n {progress}\n </Flex>\n {footer && (\n <Flex\n container={{ alignItems: 'center', justify: 'between', pad: [0, 1, 1] }}\n item={{ shrink: 0 }}\n as={StyledDialogFooter}\n hidden={isCompact}\n inert={isCompact ? '' : undefined}\n >\n {footer}\n </Flex>\n )}\n </>\n )}\n {(!isAutoSize || isFullCompact) && (\n <StyledExpandCollapse\n onToggle={() => {\n setDrawerSize(prev => {\n if (isFullCompact) return prev === 'compact' ? 'full' : 'compact';\n if (prev === 'full') return 'half';\n return 'full';\n });\n }}\n expanded={drawerSize === 'full'}\n compact\n iconOnly\n />\n )}\n </StyledTouchDialog>\n </StyledTouchDialogBackdrop>\n );\n\n return portalTarget ? createPortal(content, portalTarget) : content;\n }\n);\n\nexport default TouchDialog;\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
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
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
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 StyledTouchDialogHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
5
|
+
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;
|
|
4
6
|
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
7
|
export declare const StyledTouchDialogBackdrop: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<Omit<import("../Backdrop").BackdropProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
6
8
|
ref?: ((instance: HTMLDivElement | 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<HTMLDivElement> | null | undefined;
|
|
@@ -9,6 +11,4 @@ export declare const StyledTouchDialogBackdrop: import("styled-components/dist/t
|
|
|
9
11
|
}>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<import("../Backdrop").BackdropProps, "ref"> & import("react").RefAttributes<HTMLDivElement>> & {
|
|
10
12
|
getTestIds: (testIdProp?: import("../..").TestIdProp["testId"]) => import("../..").TestIdsRecord<readonly []>;
|
|
11
13
|
}, keyof import("react").Component<any, {}, any>>;
|
|
12
|
-
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;
|
|
13
|
-
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;
|
|
14
14
|
//# sourceMappingURL=TouchDialog.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TouchDialog.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.styles.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,oBAAoB;;2OAQhC,CAAC;AAIF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"TouchDialog.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/TouchDialog.styles.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,oBAAoB;;2OAQhC,CAAC;AAIF,eAAO,MAAM,uBAAuB,6NASnC,CAAC;AAIF,eAAO,MAAM,wBAAwB,6NAepC,CAAC;AAIF,eAAO,MAAM,iBAAiB,mVA+B7B,CAAC;AAIF,eAAO,MAAM,yBAAyB;;;eAAiC,OAAO;;;iDAM7E,CAAC"}
|