@cloudscape-design/components 3.0.1113 → 3.0.1115
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/alert/internal.d.ts.map +1 -1
- package/alert/internal.js +15 -4
- package/alert/internal.js.map +1 -1
- package/app-layout/runtime-drawer/index.d.ts +5 -3
- package/app-layout/runtime-drawer/index.d.ts.map +1 -1
- package/app-layout/runtime-drawer/index.js +16 -11
- package/app-layout/runtime-drawer/index.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.d.ts +6 -2
- package/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.js +2 -3
- package/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/styles.css.js +26 -25
- package/app-layout/visual-refresh-toolbar/drawer/styles.scoped.css +75 -69
- package/app-layout/visual-refresh-toolbar/drawer/styles.selectors.js +26 -25
- package/app-layout/visual-refresh-toolbar/state/use-ai-drawer.d.ts +6 -1
- package/app-layout/visual-refresh-toolbar/state/use-ai-drawer.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/state/use-ai-drawer.js +5 -3
- package/app-layout/visual-refresh-toolbar/state/use-ai-drawer.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/state/use-app-layout.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/state/use-app-layout.js +1 -0
- package/app-layout/visual-refresh-toolbar/state/use-app-layout.js.map +1 -1
- package/cards/analytics-metadata/interfaces.d.ts +1 -0
- package/cards/analytics-metadata/interfaces.d.ts.map +1 -1
- package/cards/analytics-metadata/interfaces.js.map +1 -1
- package/cards/index.d.ts.map +1 -1
- package/cards/index.js +3 -0
- package/cards/index.js.map +1 -1
- package/icon/generated/icons.js +1 -1
- package/icon/generated/icons.js.map +1 -1
- package/internal/base-component/styles.scoped.css +1 -1
- package/internal/environment.js +2 -2
- package/internal/environment.json +2 -2
- package/internal/manifest.json +1 -1
- package/internal/plugins/widget/interfaces.d.ts +3 -0
- package/internal/plugins/widget/interfaces.d.ts.map +1 -1
- package/internal/plugins/widget/interfaces.js.map +1 -1
- package/package.json +1 -1
- package/select/parts/styles.css.js +20 -19
- package/select/parts/styles.scoped.css +23 -20
- package/select/parts/styles.selectors.js +20 -19
- package/select/parts/trigger.d.ts.map +1 -1
- package/select/parts/trigger.js +1 -1
- package/select/parts/trigger.js.map +1 -1
- package/table/table-role/table-role-helper.d.ts.map +1 -1
- package/table/table-role/table-role-helper.js +3 -1
- package/table/table-role/table-role-helper.js.map +1 -1
- package/test-utils/dom/token-group/index.js +4 -6
- package/test-utils/dom/token-group/index.js.map +1 -1
- package/test-utils/dom/token-group/token.js +2 -5
- package/test-utils/dom/token-group/token.js.map +1 -1
- package/test-utils/selectors/token-group/index.js +4 -6
- package/test-utils/selectors/token-group/index.js.map +1 -1
- package/test-utils/selectors/token-group/token.js +2 -5
- package/test-utils/selectors/token-group/token.js.map +1 -1
- package/token/dismiss-button.d.ts.map +1 -1
- package/token/dismiss-button.js +2 -1
- package/token/dismiss-button.js.map +1 -1
- package/token/internal.d.ts.map +1 -1
- package/token/internal.js +2 -1
- package/token/internal.js.map +1 -1
package/alert/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/alert/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/alert/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAe3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAQlF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAsB1C,QAAA,MAAM,aAAa;;;;YANP,UAAU,CAAC,OAAO,CAAC;wCAwL9B,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
package/alert/internal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import React, { useRef } from 'react';
|
|
4
|
+
import React, { useImperativeHandle, useRef } from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';
|
|
7
7
|
import { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
|
|
@@ -13,7 +13,6 @@ import { getBaseProps } from '../internal/base-component';
|
|
|
13
13
|
import VisualContext from '../internal/components/visual-context';
|
|
14
14
|
import { LinkDefaultVariantContext } from '../internal/context/link-default-variant-context';
|
|
15
15
|
import { fireNonCancelableEvent } from '../internal/events';
|
|
16
|
-
import useForwardFocus from '../internal/hooks/forward-focus';
|
|
17
16
|
import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
18
17
|
import { awsuiPluginsInternal } from '../internal/plugins/api';
|
|
19
18
|
import { createUseDiscoveredAction, createUseDiscoveredContent } from '../internal/plugins/helpers';
|
|
@@ -36,7 +35,19 @@ const InternalAlert = React.forwardRef((_a, ref) => {
|
|
|
36
35
|
const baseProps = getBaseProps(rest);
|
|
37
36
|
const i18n = useInternalI18n('alert');
|
|
38
37
|
const focusRef = useRef(null);
|
|
39
|
-
|
|
38
|
+
useImperativeHandle(ref, () => ({
|
|
39
|
+
focus: () => {
|
|
40
|
+
if (focusRef.current) {
|
|
41
|
+
focusRef.current.tabIndex = -1;
|
|
42
|
+
focusRef.current.focus();
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
}));
|
|
46
|
+
const handleBlur = () => {
|
|
47
|
+
if (focusRef.current) {
|
|
48
|
+
focusRef.current.removeAttribute('tabindex');
|
|
49
|
+
}
|
|
50
|
+
};
|
|
40
51
|
const { discoveredActions, headerRef: headerRefAction, contentRef: contentRefAction } = useDiscoveredAction(type);
|
|
41
52
|
const { initialHidden, headerReplacementType, contentReplacementType, headerRef: headerRefContent, contentRef: contentRefContent, replacementHeaderRef, replacementContentRef, } = useDiscoveredContent({ type, header, children });
|
|
42
53
|
const [containerWidth, containerMeasureRef] = useContainerWidth();
|
|
@@ -60,7 +71,7 @@ const InternalAlert = React.forwardRef((_a, ref) => {
|
|
|
60
71
|
React.createElement(VisualContext, { contextName: "alert" },
|
|
61
72
|
React.createElement("div", { className: clsx(styles.alert, styles[`type-${type}`], styles[`icon-size-${size}`], hasAction && styles['with-action'], dismissible && styles['with-dismiss']), style: getAlertStyles(style) },
|
|
62
73
|
React.createElement("div", { className: styles['alert-wrapper'] },
|
|
63
|
-
React.createElement("div", { className: styles['alert-focus-wrapper'],
|
|
74
|
+
React.createElement("div", { className: styles['alert-focus-wrapper'], ref: focusRef, role: "group", onBlur: handleBlur },
|
|
64
75
|
React.createElement("div", { className: clsx(styles.icon, styles.text), style: getIconStyles(style) },
|
|
65
76
|
React.createElement(InternalIcon, { name: typeToIcon[type], size: size, ariaLabel: statusIconAriaLabel })),
|
|
66
77
|
React.createElement("div", { className: clsx(styles.message, styles.text), id: messageSlotId },
|
package/alert/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/alert/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,eAAe,EA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AAM,CAAC,MAAM,CACvD,EACD,GAAG,EAAE,qBAAqB,GACrB,CACH,CACF;wBACN,oBAAC,cAAc,IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EACxB,eAAe,EAAE;gCACf,UAAU,EAAE,MAAM,CAAC,aAAa,CAAC;gCACjC,YAAY,EAAE,MAAM,CAAC,eAAe,CAAC;6BACtC,EACD,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,iBAAiB,EACpC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,aAAa,CAAC,EAC1D,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,MAAM,CAAC,gBAAgB,CAAC,GACtC,CACE;oBACL,WAAW,IAAI,CACd,2CACE,SAAS,EAAE,MAAM,CAAC,OAAO,IACrB,6BAA6B,CAAC;wBAChC,MAAM,EAAE,SAAS;qBACiC,CAAC;wBAErD,oBAAC,cAAc,IACb,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,EACnC,OAAO,EAAC,MAAM,EACd,QAAQ,EAAC,OAAO,EAChB,UAAU,EAAC,MAAM,EACjB,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAChD,KAAK,EAAE,sBAAsB,CAAC,KAAK,CAAC,GACpC,CACE,CACP,CACG,CACQ,CACmB,CACjC,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { InternalButton } from '../button/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { IconProps } from '../icon/interfaces';\nimport InternalIcon from '../icon/internal';\nimport { DATA_ATTR_ANALYTICS_ALERT } from '../internal/analytics/selectors';\nimport { getBaseProps } from '../internal/base-component';\nimport VisualContext from '../internal/components/visual-context';\nimport { LinkDefaultVariantContext } from '../internal/context/link-default-variant-context';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { awsuiPluginsInternal } from '../internal/plugins/api';\nimport { createUseDiscoveredAction, createUseDiscoveredContent } from '../internal/plugins/helpers';\nimport { SomeRequired } from '../internal/types';\nimport useContainerWidth from '../internal/utils/use-container-width';\nimport { ActionsWrapper } from './actions-wrapper';\nimport { GeneratedAnalyticsMetadataAlertDismiss } from './analytics-metadata/interfaces';\nimport { AlertProps } from './interfaces';\nimport { getAlertStyles, getDismissButtonStyles, getIconStyles } from './style';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\n\nconst typeToIcon: Record<AlertProps.Type, IconProps['name']> = {\n error: 'status-negative',\n warning: 'status-warning',\n success: 'status-positive',\n info: 'status-info',\n};\n\ntype InternalAlertProps = SomeRequired<AlertProps, 'type'> &\n InternalBaseComponentProps & {\n messageSlotId?: string;\n style?: AlertProps['style'];\n };\n\nconst useDiscoveredAction = createUseDiscoveredAction(awsuiPluginsInternal.alert.onActionRegistered);\nconst useDiscoveredContent = createUseDiscoveredContent('alert', awsuiPluginsInternal.alertContent);\n\nconst InternalAlert = React.forwardRef(\n (\n {\n type,\n i18nStrings,\n visible = true,\n dismissible,\n children,\n header,\n buttonText,\n action,\n onDismiss,\n onButtonClick,\n __internalRootRef,\n statusIconAriaLabel: deprecatedStatusIconAriaLabel,\n dismissAriaLabel: deprecatedDismissAriaLabel,\n messageSlotId,\n style,\n ...rest\n }: InternalAlertProps,\n ref: React.Ref<AlertProps.Ref>\n ) => {\n const baseProps = getBaseProps(rest);\n const i18n = useInternalI18n('alert');\n\n const focusRef = useRef<HTMLDivElement>(null);\n useForwardFocus(ref, focusRef);\n\n const { discoveredActions, headerRef: headerRefAction, contentRef: contentRefAction } = useDiscoveredAction(type);\n const {\n initialHidden,\n headerReplacementType,\n contentReplacementType,\n headerRef: headerRefContent,\n contentRef: contentRefContent,\n replacementHeaderRef,\n replacementContentRef,\n } = useDiscoveredContent({ type, header, children });\n\n const [containerWidth, containerMeasureRef] = useContainerWidth();\n const containerRef = useMergeRefs(containerMeasureRef, __internalRootRef);\n const headerRef = useMergeRefs(headerRefAction, headerRefContent);\n const contentRef = useMergeRefs(contentRefAction, contentRefContent);\n\n const isRefresh = useVisualRefresh();\n const size = isRefresh\n ? 'normal'\n : headerReplacementType !== 'remove' && header && contentReplacementType !== 'remove' && children\n ? 'big'\n : 'normal';\n\n const hasAction = Boolean(action || buttonText || discoveredActions.length);\n\n const analyticsAttributes = {\n [DATA_ATTR_ANALYTICS_ALERT]: type,\n };\n\n const statusIconAriaLabel = i18n(\n `i18nStrings.${type}IconAriaLabel`,\n i18nStrings?.[`${type}IconAriaLabel`] ?? deprecatedStatusIconAriaLabel\n );\n\n const dismissAriaLabel = i18n(\n 'i18nStrings.dismissAriaLabel',\n i18nStrings?.dismissAriaLabel ?? i18n('dismissAriaLabel', deprecatedDismissAriaLabel)\n );\n\n return (\n <div\n {...baseProps}\n {...analyticsAttributes}\n aria-hidden={!visible}\n className={clsx(\n styles.root,\n { [styles.hidden]: !visible, [styles['initial-hidden']]: initialHidden },\n baseProps.className\n )}\n ref={containerRef}\n >\n <LinkDefaultVariantContext.Provider value={{ defaultVariant: 'primary' }}>\n <VisualContext contextName=\"alert\">\n <div\n className={clsx(\n styles.alert,\n styles[`type-${type}`],\n styles[`icon-size-${size}`],\n hasAction && styles['with-action'],\n dismissible && styles['with-dismiss']\n )}\n style={getAlertStyles(style)}\n >\n <div className={styles['alert-wrapper']}>\n <div className={styles['alert-focus-wrapper']} tabIndex={-1} ref={focusRef} role=\"group\">\n <div className={clsx(styles.icon, styles.text)} style={getIconStyles(style)}>\n <InternalIcon name={typeToIcon[type]} size={size} ariaLabel={statusIconAriaLabel} />\n </div>\n <div className={clsx(styles.message, styles.text)} id={messageSlotId}>\n <div\n className={clsx(\n header && styles.header,\n headerReplacementType !== 'original' ? styles.hidden : analyticsSelectors.header\n )}\n ref={headerRef}\n >\n {header}\n </div>\n <div\n className={clsx(\n styles['header-replacement'],\n headerReplacementType !== 'replaced' ? styles.hidden : analyticsSelectors.header\n )}\n ref={replacementHeaderRef}\n ></div>\n <div\n className={clsx(styles.content, contentReplacementType !== 'original' && styles.hidden)}\n ref={contentRef}\n >\n {children}\n </div>\n <div\n className={clsx(\n styles['content-replacement'],\n contentReplacementType !== 'replaced' && styles.hidden\n )}\n ref={replacementContentRef}\n ></div>\n </div>\n </div>\n <ActionsWrapper\n className={styles.action}\n testUtilClasses={{\n actionSlot: styles['action-slot'],\n actionButton: styles['action-button'],\n }}\n action={action}\n discoveredActions={discoveredActions}\n buttonText={buttonText}\n onButtonClick={() => fireNonCancelableEvent(onButtonClick)}\n containerWidth={containerWidth}\n wrappedClass={styles['action-wrapped']}\n />\n </div>\n {dismissible && (\n <div\n className={styles.dismiss}\n {...getAnalyticsMetadataAttribute({\n action: 'dismiss',\n } as Partial<GeneratedAnalyticsMetadataAlertDismiss>)}\n >\n <InternalButton\n className={styles['dismiss-button']}\n variant=\"icon\"\n iconName=\"close\"\n formAction=\"none\"\n ariaLabel={dismissAriaLabel}\n onClick={() => fireNonCancelableEvent(onDismiss)}\n style={getDismissButtonStyles(style)}\n />\n </div>\n )}\n </div>\n </VisualContext>\n </LinkDefaultVariantContext.Provider>\n </div>\n );\n }\n);\n\nexport default InternalAlert;\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/alert/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,mBAAmB,EAA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AAO,EAAC,MAAM,EACd,QAAQ,EAAC,OAAO,EAChB,UAAU,EAAC,MAAM,EACjB,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAChD,KAAK,EAAE,sBAAsB,CAAC,KAAK,CAAC,GACpC,CACE,CACP,CACG,CACQ,CACmB,CACjC,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { InternalButton } from '../button/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { IconProps } from '../icon/interfaces';\nimport InternalIcon from '../icon/internal';\nimport { DATA_ATTR_ANALYTICS_ALERT } from '../internal/analytics/selectors';\nimport { getBaseProps } from '../internal/base-component';\nimport VisualContext from '../internal/components/visual-context';\nimport { LinkDefaultVariantContext } from '../internal/context/link-default-variant-context';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { awsuiPluginsInternal } from '../internal/plugins/api';\nimport { createUseDiscoveredAction, createUseDiscoveredContent } from '../internal/plugins/helpers';\nimport { SomeRequired } from '../internal/types';\nimport useContainerWidth from '../internal/utils/use-container-width';\nimport { ActionsWrapper } from './actions-wrapper';\nimport { GeneratedAnalyticsMetadataAlertDismiss } from './analytics-metadata/interfaces';\nimport { AlertProps } from './interfaces';\nimport { getAlertStyles, getDismissButtonStyles, getIconStyles } from './style';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\n\nconst typeToIcon: Record<AlertProps.Type, IconProps['name']> = {\n error: 'status-negative',\n warning: 'status-warning',\n success: 'status-positive',\n info: 'status-info',\n};\n\ntype InternalAlertProps = SomeRequired<AlertProps, 'type'> &\n InternalBaseComponentProps & {\n messageSlotId?: string;\n style?: AlertProps['style'];\n };\n\nconst useDiscoveredAction = createUseDiscoveredAction(awsuiPluginsInternal.alert.onActionRegistered);\nconst useDiscoveredContent = createUseDiscoveredContent('alert', awsuiPluginsInternal.alertContent);\n\nconst InternalAlert = React.forwardRef(\n (\n {\n type,\n i18nStrings,\n visible = true,\n dismissible,\n children,\n header,\n buttonText,\n action,\n onDismiss,\n onButtonClick,\n __internalRootRef,\n statusIconAriaLabel: deprecatedStatusIconAriaLabel,\n dismissAriaLabel: deprecatedDismissAriaLabel,\n messageSlotId,\n style,\n ...rest\n }: InternalAlertProps,\n ref: React.Ref<AlertProps.Ref>\n ) => {\n const baseProps = getBaseProps(rest);\n const i18n = useInternalI18n('alert');\n\n const focusRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => ({\n focus: () => {\n if (focusRef.current) {\n focusRef.current.tabIndex = -1;\n focusRef.current.focus();\n }\n },\n }));\n const handleBlur = () => {\n if (focusRef.current) {\n focusRef.current.removeAttribute('tabindex');\n }\n };\n\n const { discoveredActions, headerRef: headerRefAction, contentRef: contentRefAction } = useDiscoveredAction(type);\n const {\n initialHidden,\n headerReplacementType,\n contentReplacementType,\n headerRef: headerRefContent,\n contentRef: contentRefContent,\n replacementHeaderRef,\n replacementContentRef,\n } = useDiscoveredContent({ type, header, children });\n\n const [containerWidth, containerMeasureRef] = useContainerWidth();\n const containerRef = useMergeRefs(containerMeasureRef, __internalRootRef);\n const headerRef = useMergeRefs(headerRefAction, headerRefContent);\n const contentRef = useMergeRefs(contentRefAction, contentRefContent);\n\n const isRefresh = useVisualRefresh();\n const size = isRefresh\n ? 'normal'\n : headerReplacementType !== 'remove' && header && contentReplacementType !== 'remove' && children\n ? 'big'\n : 'normal';\n\n const hasAction = Boolean(action || buttonText || discoveredActions.length);\n\n const analyticsAttributes = {\n [DATA_ATTR_ANALYTICS_ALERT]: type,\n };\n\n const statusIconAriaLabel = i18n(\n `i18nStrings.${type}IconAriaLabel`,\n i18nStrings?.[`${type}IconAriaLabel`] ?? deprecatedStatusIconAriaLabel\n );\n\n const dismissAriaLabel = i18n(\n 'i18nStrings.dismissAriaLabel',\n i18nStrings?.dismissAriaLabel ?? i18n('dismissAriaLabel', deprecatedDismissAriaLabel)\n );\n\n return (\n <div\n {...baseProps}\n {...analyticsAttributes}\n aria-hidden={!visible}\n className={clsx(\n styles.root,\n { [styles.hidden]: !visible, [styles['initial-hidden']]: initialHidden },\n baseProps.className\n )}\n ref={containerRef}\n >\n <LinkDefaultVariantContext.Provider value={{ defaultVariant: 'primary' }}>\n <VisualContext contextName=\"alert\">\n <div\n className={clsx(\n styles.alert,\n styles[`type-${type}`],\n styles[`icon-size-${size}`],\n hasAction && styles['with-action'],\n dismissible && styles['with-dismiss']\n )}\n style={getAlertStyles(style)}\n >\n <div className={styles['alert-wrapper']}>\n <div className={styles['alert-focus-wrapper']} ref={focusRef} role=\"group\" onBlur={handleBlur}>\n <div className={clsx(styles.icon, styles.text)} style={getIconStyles(style)}>\n <InternalIcon name={typeToIcon[type]} size={size} ariaLabel={statusIconAriaLabel} />\n </div>\n <div className={clsx(styles.message, styles.text)} id={messageSlotId}>\n <div\n className={clsx(\n header && styles.header,\n headerReplacementType !== 'original' ? styles.hidden : analyticsSelectors.header\n )}\n ref={headerRef}\n >\n {header}\n </div>\n <div\n className={clsx(\n styles['header-replacement'],\n headerReplacementType !== 'replaced' ? styles.hidden : analyticsSelectors.header\n )}\n ref={replacementHeaderRef}\n ></div>\n <div\n className={clsx(styles.content, contentReplacementType !== 'original' && styles.hidden)}\n ref={contentRef}\n >\n {children}\n </div>\n <div\n className={clsx(\n styles['content-replacement'],\n contentReplacementType !== 'replaced' && styles.hidden\n )}\n ref={replacementContentRef}\n ></div>\n </div>\n </div>\n <ActionsWrapper\n className={styles.action}\n testUtilClasses={{\n actionSlot: styles['action-slot'],\n actionButton: styles['action-button'],\n }}\n action={action}\n discoveredActions={discoveredActions}\n buttonText={buttonText}\n onButtonClick={() => fireNonCancelableEvent(onButtonClick)}\n containerWidth={containerWidth}\n wrappedClass={styles['action-wrapped']}\n />\n </div>\n {dismissible && (\n <div\n className={styles.dismiss}\n {...getAnalyticsMetadataAttribute({\n action: 'dismiss',\n } as Partial<GeneratedAnalyticsMetadataAlertDismiss>)}\n >\n <InternalButton\n className={styles['dismiss-button']}\n variant=\"icon\"\n iconName=\"close\"\n formAction=\"none\"\n ariaLabel={dismissAriaLabel}\n onClick={() => fireNonCancelableEvent(onDismiss)}\n style={getDismissButtonStyles(style)}\n />\n </div>\n )}\n </div>\n </VisualContext>\n </LinkDefaultVariantContext.Provider>\n </div>\n );\n }\n);\n\nexport default InternalAlert;\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { ButtonGroupProps } from '../../button-group/interfaces';
|
|
2
3
|
import { NonCancelableEventHandler } from '../../internal/events';
|
|
3
4
|
import { DrawerConfig as RuntimeDrawerConfig, DrawerStateChangeParams } from '../../internal/plugins/controllers/drawers';
|
|
@@ -17,8 +18,9 @@ export declare const mapRuntimeConfigToDrawer: (runtimeConfig: RuntimeDrawerConf
|
|
|
17
18
|
headerActions?: ReadonlyArray<ButtonGroupProps.Item>;
|
|
18
19
|
};
|
|
19
20
|
export declare const mapRuntimeConfigToAiDrawer: (runtimeConfig: RuntimeAiDrawerConfig) => AppLayoutProps.Drawer & {
|
|
20
|
-
orderPriority?: number;
|
|
21
|
-
onToggle?: NonCancelableEventHandler<DrawerStateChangeParams
|
|
22
|
-
headerActions?:
|
|
21
|
+
orderPriority?: number | undefined;
|
|
22
|
+
onToggle?: NonCancelableEventHandler<DrawerStateChangeParams> | undefined;
|
|
23
|
+
headerActions?: readonly ButtonGroupProps.Item[] | undefined;
|
|
24
|
+
exitExpandedModeTrigger?: React.ReactNode;
|
|
23
25
|
};
|
|
24
26
|
export declare function convertRuntimeDrawers(localDrawers: Array<RuntimeDrawerConfig>, globalDrawers: Array<RuntimeDrawerConfig>): DrawersLayout;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/app-layout/runtime-drawer/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/app-layout/runtime-drawer/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAI7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAA0B,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EACL,YAAY,IAAI,mBAAmB,EACnC,uBAAuB,EACxB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAK/C,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,MAAM;IAC1D,QAAQ,CAAC,EAAE,yBAAyB,CAAC,uBAAuB,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC7B,WAAW,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAClC,UAAU,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;CAClC;AAkFD,eAAO,MAAM,wBAAwB,kBACpB,mBAAmB,KACjC,eAAe,MAAM,GAAG;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,0BAA0B,uBAAuB,CAAC,CAAC;IAC9D,aAAa,CAAC,EAAE,cAAc,iBAAiB,IAAI,CAAC,CAAC;CA2BtD,CAAC;AAEF,eAAO,MAAM,0BAA0B,kBACtB,qBAAqB;;;;8BAKV,MAAM,SAAS;CAoC1C,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,KAAK,CAAC,mBAAmB,CAAC,EACxC,aAAa,EAAE,KAAK,CAAC,mBAAmB,CAAC,GACxC,aAAa,CAQf"}
|
|
@@ -59,29 +59,34 @@ function checkForUnsupportedProps(headerActions) {
|
|
|
59
59
|
}
|
|
60
60
|
return headerActions;
|
|
61
61
|
}
|
|
62
|
+
const convertRuntimeTriggerToReactNode = (runtimeTrigger) => {
|
|
63
|
+
if (!runtimeTrigger) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
// eslint-disable-next-line react/no-danger
|
|
67
|
+
return React.createElement("span", { style: { lineHeight: 0 }, dangerouslySetInnerHTML: { __html: runtimeTrigger } });
|
|
68
|
+
};
|
|
62
69
|
export const mapRuntimeConfigToDrawer = (runtimeConfig) => {
|
|
63
70
|
var _a;
|
|
64
71
|
const { mountContent, unmountContent, trigger } = runtimeConfig, runtimeDrawer = __rest(runtimeConfig, ["mountContent", "unmountContent", "trigger"]);
|
|
65
72
|
return Object.assign(Object.assign({}, runtimeDrawer), { ariaLabels: Object.assign({ drawerName: (_a = runtimeDrawer.ariaLabels.content) !== null && _a !== void 0 ? _a : '' }, runtimeDrawer.ariaLabels), trigger: trigger
|
|
66
73
|
? Object.assign({}, (trigger.iconSvg && {
|
|
67
|
-
iconSvg: (
|
|
68
|
-
// eslint-disable-next-line react/no-danger
|
|
69
|
-
React.createElement("span", { dangerouslySetInnerHTML: { __html: trigger.iconSvg } })),
|
|
74
|
+
iconSvg: convertRuntimeTriggerToReactNode(trigger.iconSvg),
|
|
70
75
|
})) : undefined, content: (React.createElement(RuntimeDrawerWrapper, { key: runtimeDrawer.id, mountContent: mountContent, unmountContent: unmountContent, id: runtimeDrawer.id })), onResize: event => {
|
|
71
76
|
fireNonCancelableEvent(runtimeDrawer.onResize, { size: event.detail.size, id: runtimeDrawer.id });
|
|
72
77
|
}, headerActions: runtimeDrawer.headerActions ? checkForUnsupportedProps(runtimeDrawer.headerActions) : undefined });
|
|
73
78
|
};
|
|
74
79
|
export const mapRuntimeConfigToAiDrawer = (runtimeConfig) => {
|
|
75
80
|
var _a;
|
|
76
|
-
const { mountContent, unmountContent, trigger } = runtimeConfig, runtimeDrawer = __rest(runtimeConfig, ["mountContent", "unmountContent", "trigger"]);
|
|
77
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, runtimeDrawer), { ariaLabels: Object.assign({ drawerName: (_a = runtimeDrawer.ariaLabels.content) !== null && _a !== void 0 ? _a : '' }, runtimeDrawer.ariaLabels), trigger
|
|
81
|
+
const { mountContent, unmountContent, trigger, exitExpandedModeTrigger } = runtimeConfig, runtimeDrawer = __rest(runtimeConfig, ["mountContent", "unmountContent", "trigger", "exitExpandedModeTrigger"]);
|
|
82
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, runtimeDrawer), { ariaLabels: Object.assign({ drawerName: (_a = runtimeDrawer.ariaLabels.content) !== null && _a !== void 0 ? _a : '' }, runtimeDrawer.ariaLabels) }), (trigger && {
|
|
83
|
+
trigger: {
|
|
84
|
+
customIcon: convertRuntimeTriggerToReactNode(trigger === null || trigger === void 0 ? void 0 : trigger.customIcon),
|
|
85
|
+
iconSvg: convertRuntimeTriggerToReactNode(trigger === null || trigger === void 0 ? void 0 : trigger.iconSvg),
|
|
86
|
+
},
|
|
87
|
+
})), { exitExpandedModeTrigger: exitExpandedModeTrigger
|
|
78
88
|
? {
|
|
79
|
-
customIcon: (
|
|
80
|
-
// eslint-disable-next-line react/no-danger
|
|
81
|
-
React.createElement("span", { style: { lineHeight: 0 }, dangerouslySetInnerHTML: { __html: trigger.customIcon } })) : undefined,
|
|
82
|
-
iconSvg: trigger.iconSvg ? (
|
|
83
|
-
// eslint-disable-next-line react/no-danger
|
|
84
|
-
React.createElement("span", { dangerouslySetInnerHTML: { __html: trigger.iconSvg } })) : undefined,
|
|
89
|
+
customIcon: convertRuntimeTriggerToReactNode(exitExpandedModeTrigger === null || exitExpandedModeTrigger === void 0 ? void 0 : exitExpandedModeTrigger.customIcon),
|
|
85
90
|
}
|
|
86
91
|
: undefined, content: (React.createElement(RuntimeDrawerWrapper, { key: runtimeDrawer.id, mountContent: mountContent, unmountContent: unmountContent, id: runtimeDrawer.id })) }), (runtimeDrawer.mountHeader && {
|
|
87
92
|
header: (React.createElement(RuntimeDrawerHeader, { mountHeader: runtimeDrawer.mountHeader, unmountHeader: runtimeDrawer.unmountHeader })),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/app-layout/runtime-drawer/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAGzE,OAAO,EAAE,sBAAsB,EAA6B,MAAM,uBAAuB,CAAC;AAK1F,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAGtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAoBrC,SAAS,oBAAoB,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,EAA8B;IAC5F,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACzC,MAAM,wBAAwB,GAAG,MAAM,CAA4B,IAAI,CAAC,CAAC;IACzE,MAAM,gBAAgB,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,CAAC,CAAC,EAAE,IAAI,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAExD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,SAAS,GAAG,GAAG,CAA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AW,IAAI;QAC/B,MAAM,EAAE,CACN,oBAAC,mBAAmB,IAAC,WAAW,EAAE,aAAa,CAAC,WAAW,EAAE,aAAa,EAAE,aAAa,CAAC,aAAa,GAAI,CAC5G;KACF,CAAC,KACF,QAAQ,EAAE,KAAK,CAAC,EAAE;YAChB,sBAAsB,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC;QACpG,CAAC,EACD,aAAa,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,wBAAwB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,IAC9G;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,qBAAqB,CACnC,YAAwC,EACxC,aAAyC;IAEzC,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IACzC,OAAO;QACL,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACnE,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAC,OAAA,CAAC,MAAA,IAAI,CAAC,aAAa,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAA,EAAA,CAAC;QACjE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAC,OAAA,CAAC,MAAA,IAAI,CAAC,aAAa,mCAAI,CAAC,CAAC,IAAI,CAAC,CAAA,EAAA,CAAC;KAClE,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useRef } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { ButtonGroupProps } from '../../button-group/interfaces';\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from '../../internal/events';\nimport {\n DrawerConfig as RuntimeDrawerConfig,\n DrawerStateChangeParams,\n} from '../../internal/plugins/controllers/drawers';\nimport { sortByPriority } from '../../internal/plugins/helpers/utils';\nimport { DrawerPayload as RuntimeAiDrawerConfig } from '../../internal/plugins/widget/interfaces';\nimport { AppLayoutProps } from '../interfaces';\nimport { ActiveDrawersContext } from '../utils/visibility-context';\n\nimport styles from './styles.css.js';\n\nexport interface RuntimeDrawer extends AppLayoutProps.Drawer {\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n}\n\nexport interface DrawersLayout {\n global: Array<RuntimeDrawer>;\n localBefore: Array<RuntimeDrawer>;\n localAfter: Array<RuntimeDrawer>;\n}\n\ntype VisibilityCallback = (isVisible: boolean) => void;\n\ninterface RuntimeContentWrapperProps {\n id?: string;\n mountContent: RuntimeDrawerConfig['mountContent'];\n unmountContent: RuntimeDrawerConfig['unmountContent'];\n}\n\nfunction RuntimeDrawerWrapper({ mountContent, unmountContent, id }: RuntimeContentWrapperProps) {\n const ref = useRef<HTMLDivElement>(null);\n const visibilityChangeCallback = useRef<VisibilityCallback | null>(null);\n const activeDrawersIds = useContext(ActiveDrawersContext);\n const isVisible = !!id && activeDrawersIds.includes(id);\n\n useEffect(() => {\n const container = ref.current!;\n mountContent(container, {\n onVisibilityChange: cb => {\n visibilityChangeCallback.current = cb;\n },\n });\n return () => {\n unmountContent(container);\n visibilityChangeCallback.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n visibilityChangeCallback.current?.(isVisible);\n }, [isVisible]);\n\n return <div ref={ref} className={styles['runtime-content-wrapper']} data-awsui-runtime-drawer-root-id={id}></div>;\n}\n\ninterface RuntimeContentHeaderProps {\n mountHeader: (container: HTMLElement) => void;\n unmountHeader?: (container: HTMLElement) => void;\n}\n\nfunction RuntimeDrawerHeader({ mountHeader, unmountHeader }: RuntimeContentHeaderProps) {\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const container = ref.current!;\n mountHeader?.(container);\n return () => {\n unmountHeader?.(container);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return <div className={styles['runtime-header-wrapper']} ref={ref} />;\n}\n\nfunction checkForUnsupportedProps(headerActions: ReadonlyArray<ButtonGroupProps.Item>) {\n const unsupportedProps = new Set([\n 'iconSvg',\n 'popoverFeedback',\n 'pressedIconSvg',\n 'popoverFeedback',\n 'pressedPopoverFeedback',\n ]);\n for (const item of headerActions) {\n const unsupported = Object.keys(item).filter(key => unsupportedProps.has(key));\n if (unsupported.length > 0) {\n warnOnce('AppLayout', `The headerActions properties are not supported for runtime api: ${unsupported.join(' ')}`);\n }\n }\n return headerActions;\n}\n\nexport const mapRuntimeConfigToDrawer = (\n runtimeConfig: RuntimeDrawerConfig\n): AppLayoutProps.Drawer & {\n orderPriority?: number;\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n headerActions?: ReadonlyArray<ButtonGroupProps.Item>;\n} => {\n const { mountContent, unmountContent, trigger, ...runtimeDrawer } = runtimeConfig;\n\n return {\n ...runtimeDrawer,\n ariaLabels: { drawerName: runtimeDrawer.ariaLabels.content ?? '', ...runtimeDrawer.ariaLabels },\n trigger: trigger\n ? {\n ...(trigger.iconSvg && {\n iconSvg: (\n // eslint-disable-next-line react/no-danger\n <span dangerouslySetInnerHTML={{ __html: trigger.iconSvg }} />\n ),\n }),\n }\n : undefined,\n content: (\n <RuntimeDrawerWrapper\n key={runtimeDrawer.id}\n mountContent={mountContent}\n unmountContent={unmountContent}\n id={runtimeDrawer.id}\n />\n ),\n onResize: event => {\n fireNonCancelableEvent(runtimeDrawer.onResize, { size: event.detail.size, id: runtimeDrawer.id });\n },\n headerActions: runtimeDrawer.headerActions ? checkForUnsupportedProps(runtimeDrawer.headerActions) : undefined,\n };\n};\n\nexport const mapRuntimeConfigToAiDrawer = (\n runtimeConfig: RuntimeAiDrawerConfig\n): AppLayoutProps.Drawer & {\n orderPriority?: number;\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n headerActions?: ReadonlyArray<ButtonGroupProps.Item>;\n} => {\n const { mountContent, unmountContent, trigger, ...runtimeDrawer } = runtimeConfig;\n\n return {\n ...runtimeDrawer,\n ariaLabels: { drawerName: runtimeDrawer.ariaLabels.content ?? '', ...runtimeDrawer.ariaLabels },\n trigger: trigger\n ? {\n customIcon: trigger?.customIcon ? (\n // eslint-disable-next-line react/no-danger\n <span style={{ lineHeight: 0 }} dangerouslySetInnerHTML={{ __html: trigger.customIcon }} />\n ) : undefined,\n iconSvg: trigger.iconSvg ? (\n // eslint-disable-next-line react/no-danger\n <span dangerouslySetInnerHTML={{ __html: trigger.iconSvg }} />\n ) : undefined,\n }\n : undefined,\n content: (\n <RuntimeDrawerWrapper\n key={runtimeDrawer.id}\n mountContent={mountContent}\n unmountContent={unmountContent}\n id={runtimeDrawer.id}\n />\n ),\n ...(runtimeDrawer.mountHeader && {\n header: (\n <RuntimeDrawerHeader mountHeader={runtimeDrawer.mountHeader} unmountHeader={runtimeDrawer.unmountHeader} />\n ),\n }),\n onResize: event => {\n fireNonCancelableEvent(runtimeDrawer.onResize, { size: event.detail.size, id: runtimeDrawer.id });\n },\n headerActions: runtimeDrawer.headerActions ? checkForUnsupportedProps(runtimeDrawer.headerActions) : undefined,\n };\n};\n\nexport function convertRuntimeDrawers(\n localDrawers: Array<RuntimeDrawerConfig>,\n globalDrawers: Array<RuntimeDrawerConfig>\n): DrawersLayout {\n const converted = localDrawers.map(mapRuntimeConfigToDrawer);\n const sorted = sortByPriority(converted);\n return {\n global: sortByPriority(globalDrawers.map(mapRuntimeConfigToDrawer)),\n localBefore: sorted.filter(item => (item.orderPriority ?? 0) > 0),\n localAfter: sorted.filter(item => (item.orderPriority ?? 0) <= 0),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../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AE,CAAC,CAAC;QACpG,CAAC,EACD,aAAa,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,wBAAwB,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,IAC9G;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,qBAAqB,CACnC,YAAwC,EACxC,aAAyC;IAEzC,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IACzC,OAAO;QACL,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACnE,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAC,OAAA,CAAC,MAAA,IAAI,CAAC,aAAa,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAA,EAAA,CAAC;QACjE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAC,OAAA,CAAC,MAAA,IAAI,CAAC,aAAa,mCAAI,CAAC,CAAC,IAAI,CAAC,CAAA,EAAA,CAAC;KAClE,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useRef } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { ButtonGroupProps } from '../../button-group/interfaces';\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from '../../internal/events';\nimport {\n DrawerConfig as RuntimeDrawerConfig,\n DrawerStateChangeParams,\n} from '../../internal/plugins/controllers/drawers';\nimport { sortByPriority } from '../../internal/plugins/helpers/utils';\nimport { DrawerPayload as RuntimeAiDrawerConfig } from '../../internal/plugins/widget/interfaces';\nimport { AppLayoutProps } from '../interfaces';\nimport { ActiveDrawersContext } from '../utils/visibility-context';\n\nimport styles from './styles.css.js';\n\nexport interface RuntimeDrawer extends AppLayoutProps.Drawer {\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n}\n\nexport interface DrawersLayout {\n global: Array<RuntimeDrawer>;\n localBefore: Array<RuntimeDrawer>;\n localAfter: Array<RuntimeDrawer>;\n}\n\ntype VisibilityCallback = (isVisible: boolean) => void;\n\ninterface RuntimeContentWrapperProps {\n id?: string;\n mountContent: RuntimeDrawerConfig['mountContent'];\n unmountContent: RuntimeDrawerConfig['unmountContent'];\n}\n\nfunction RuntimeDrawerWrapper({ mountContent, unmountContent, id }: RuntimeContentWrapperProps) {\n const ref = useRef<HTMLDivElement>(null);\n const visibilityChangeCallback = useRef<VisibilityCallback | null>(null);\n const activeDrawersIds = useContext(ActiveDrawersContext);\n const isVisible = !!id && activeDrawersIds.includes(id);\n\n useEffect(() => {\n const container = ref.current!;\n mountContent(container, {\n onVisibilityChange: cb => {\n visibilityChangeCallback.current = cb;\n },\n });\n return () => {\n unmountContent(container);\n visibilityChangeCallback.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n visibilityChangeCallback.current?.(isVisible);\n }, [isVisible]);\n\n return <div ref={ref} className={styles['runtime-content-wrapper']} data-awsui-runtime-drawer-root-id={id}></div>;\n}\n\ninterface RuntimeContentHeaderProps {\n mountHeader: (container: HTMLElement) => void;\n unmountHeader?: (container: HTMLElement) => void;\n}\n\nfunction RuntimeDrawerHeader({ mountHeader, unmountHeader }: RuntimeContentHeaderProps) {\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const container = ref.current!;\n mountHeader?.(container);\n return () => {\n unmountHeader?.(container);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return <div className={styles['runtime-header-wrapper']} ref={ref} />;\n}\n\nfunction checkForUnsupportedProps(headerActions: ReadonlyArray<ButtonGroupProps.Item>) {\n const unsupportedProps = new Set([\n 'iconSvg',\n 'popoverFeedback',\n 'pressedIconSvg',\n 'popoverFeedback',\n 'pressedPopoverFeedback',\n ]);\n for (const item of headerActions) {\n const unsupported = Object.keys(item).filter(key => unsupportedProps.has(key));\n if (unsupported.length > 0) {\n warnOnce('AppLayout', `The headerActions properties are not supported for runtime api: ${unsupported.join(' ')}`);\n }\n }\n return headerActions;\n}\n\nconst convertRuntimeTriggerToReactNode = (runtimeTrigger?: string) => {\n if (!runtimeTrigger) {\n return undefined;\n }\n // eslint-disable-next-line react/no-danger\n return <span style={{ lineHeight: 0 }} dangerouslySetInnerHTML={{ __html: runtimeTrigger }} />;\n};\n\nexport const mapRuntimeConfigToDrawer = (\n runtimeConfig: RuntimeDrawerConfig\n): AppLayoutProps.Drawer & {\n orderPriority?: number;\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n headerActions?: ReadonlyArray<ButtonGroupProps.Item>;\n} => {\n const { mountContent, unmountContent, trigger, ...runtimeDrawer } = runtimeConfig;\n\n return {\n ...runtimeDrawer,\n ariaLabels: { drawerName: runtimeDrawer.ariaLabels.content ?? '', ...runtimeDrawer.ariaLabels },\n trigger: trigger\n ? {\n ...(trigger.iconSvg && {\n iconSvg: convertRuntimeTriggerToReactNode(trigger.iconSvg),\n }),\n }\n : undefined,\n content: (\n <RuntimeDrawerWrapper\n key={runtimeDrawer.id}\n mountContent={mountContent}\n unmountContent={unmountContent}\n id={runtimeDrawer.id}\n />\n ),\n onResize: event => {\n fireNonCancelableEvent(runtimeDrawer.onResize, { size: event.detail.size, id: runtimeDrawer.id });\n },\n headerActions: runtimeDrawer.headerActions ? checkForUnsupportedProps(runtimeDrawer.headerActions) : undefined,\n };\n};\n\nexport const mapRuntimeConfigToAiDrawer = (\n runtimeConfig: RuntimeAiDrawerConfig\n): AppLayoutProps.Drawer & {\n orderPriority?: number;\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n headerActions?: ReadonlyArray<ButtonGroupProps.Item>;\n exitExpandedModeTrigger?: React.ReactNode;\n} => {\n const { mountContent, unmountContent, trigger, exitExpandedModeTrigger, ...runtimeDrawer } = runtimeConfig;\n\n return {\n ...runtimeDrawer,\n ariaLabels: { drawerName: runtimeDrawer.ariaLabels.content ?? '', ...runtimeDrawer.ariaLabels },\n ...(trigger && {\n trigger: {\n customIcon: convertRuntimeTriggerToReactNode(trigger?.customIcon),\n iconSvg: convertRuntimeTriggerToReactNode(trigger?.iconSvg),\n },\n }),\n exitExpandedModeTrigger: exitExpandedModeTrigger\n ? {\n customIcon: convertRuntimeTriggerToReactNode(exitExpandedModeTrigger?.customIcon),\n }\n : undefined,\n content: (\n <RuntimeDrawerWrapper\n key={runtimeDrawer.id}\n mountContent={mountContent}\n unmountContent={unmountContent}\n id={runtimeDrawer.id}\n />\n ),\n ...(runtimeDrawer.mountHeader && {\n header: (\n <RuntimeDrawerHeader mountHeader={runtimeDrawer.mountHeader} unmountHeader={runtimeDrawer.unmountHeader} />\n ),\n }),\n onResize: event => {\n fireNonCancelableEvent(runtimeDrawer.onResize, { size: event.detail.size, id: runtimeDrawer.id });\n },\n headerActions: runtimeDrawer.headerActions ? checkForUnsupportedProps(runtimeDrawer.headerActions) : undefined,\n };\n};\n\nexport function convertRuntimeDrawers(\n localDrawers: Array<RuntimeDrawerConfig>,\n globalDrawers: Array<RuntimeDrawerConfig>\n): DrawersLayout {\n const converted = localDrawers.map(mapRuntimeConfigToDrawer);\n const sorted = sortByPriority(converted);\n return {\n global: sortByPriority(globalDrawers.map(mapRuntimeConfigToDrawer)),\n localBefore: sorted.filter(item => (item.orderPriority ?? 0) > 0),\n localAfter: sorted.filter(item => (item.orderPriority ?? 0) <= 0),\n };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { AppLayoutProps } from '../../interfaces';
|
|
3
3
|
import { FocusControlState } from '../../utils/use-focus-control';
|
|
4
4
|
import { AppLayoutInternals, InternalDrawer } from '../interfaces';
|
|
@@ -23,7 +23,11 @@ interface AIDrawerProps {
|
|
|
23
23
|
interface AppLayoutGlobalAiDrawerImplementationProps {
|
|
24
24
|
appLayoutInternals: AppLayoutInternals;
|
|
25
25
|
show: boolean;
|
|
26
|
-
activeAiDrawer: InternalDrawer
|
|
26
|
+
activeAiDrawer: (InternalDrawer & {
|
|
27
|
+
exitExpandedModeTrigger?: {
|
|
28
|
+
customIcon?: React.ReactNode;
|
|
29
|
+
};
|
|
30
|
+
}) | null;
|
|
27
31
|
aiDrawerProps: AIDrawerProps;
|
|
28
32
|
}
|
|
29
33
|
export declare function AppLayoutGlobalAiDrawerImplementation({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-ai-drawer.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"global-ai-drawer.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAUtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAOxD,UAAU,aAAa;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,GAAG,CAAC;IAChB,oBAAoB,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACpD,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACpD,sBAAsB,EAAE,SAAS,GAAG,CAAC,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC,CAAC;IACpG,oBAAoB,EAAE,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACrE,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACrD;AAED,UAAU,0CAA0C;IAClD,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,cAAc,EACV,CAAC,cAAc,GAAG;QAChB,uBAAuB,CAAC,EAAE;YACxB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;SAC9B,CAAC;KACH,CAAC,GACF,IAAI,CAAC;IACT,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,wBAAgB,qCAAqC,CAAC,EACpD,kBAAkB,EAClB,IAAI,EACJ,cAAc,EACd,aAAa,GACd,EAAE,0CAA0C,eAwM5C"}
|
|
@@ -75,7 +75,7 @@ export function AppLayoutGlobalAiDrawerImplementation({ appLayoutInternals, show
|
|
|
75
75
|
}
|
|
76
76
|
return (React.createElement(Transition, { nodeRef: drawerRef, in: show, appear: show, mountOnEnter: true, timeout: 250 }, drawerTransitionState => {
|
|
77
77
|
return (React.createElement(Transition, { nodeRef: drawerRef, in: isExpanded, timeout: 250 }, expandedTransitionState => {
|
|
78
|
-
var _a, _b, _c, _d, _e;
|
|
78
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
79
79
|
return (React.createElement("aside", { id: activeAiDrawer === null || activeAiDrawer === void 0 ? void 0 : activeAiDrawer.id, "aria-hidden": !activeAiDrawer, "aria-label": computedAriaLabels.content, className: clsx(styles.drawer, styles['ai-drawer'], !animationDisabled && isExpanded && styles['with-expanded-motion'], {
|
|
80
80
|
[sharedStyles['with-motion-horizontal']]: !animationDisabled,
|
|
81
81
|
[testutilStyles['active-drawer']]: show,
|
|
@@ -111,8 +111,7 @@ export function AppLayoutGlobalAiDrawerImplementation({ appLayoutInternals, show
|
|
|
111
111
|
}
|
|
112
112
|
}, ariaLabel: "Left panel actions", items: drawerActions }))),
|
|
113
113
|
!isMobile && isExpanded && ((_d = activeAiDrawer === null || activeAiDrawer === void 0 ? void 0 : activeAiDrawer.ariaLabels) === null || _d === void 0 ? void 0 : _d.exitExpandedModeButton) && (React.createElement("div", { className: styles['drawer-back-to-console-slot'] },
|
|
114
|
-
React.createElement("div", { className: styles['drawer-back-to-console-button-wrapper'] },
|
|
115
|
-
React.createElement("button", { className: clsx(testutilStyles['active-ai-drawer-leave-expanded-mode-custom-button'], styles['drawer-back-to-console-button']), formAction: "none", onClick: () => setExpandedDrawerId(null) }, (_e = activeAiDrawer === null || activeAiDrawer === void 0 ? void 0 : activeAiDrawer.ariaLabels) === null || _e === void 0 ? void 0 : _e.exitExpandedModeButton))))),
|
|
114
|
+
React.createElement("div", { className: styles['drawer-back-to-console-button-wrapper'] }, ((_e = activeAiDrawer === null || activeAiDrawer === void 0 ? void 0 : activeAiDrawer.exitExpandedModeTrigger) === null || _e === void 0 ? void 0 : _e.customIcon) ? (React.createElement("button", { className: clsx(testutilStyles['active-ai-drawer-leave-expanded-mode-custom-button'], styles['drawer-back-to-console-custom-button']), formAction: "none", onClick: () => setExpandedDrawerId(null), "aria-label": (_f = activeAiDrawer === null || activeAiDrawer === void 0 ? void 0 : activeAiDrawer.ariaLabels) === null || _f === void 0 ? void 0 : _f.exitExpandedModeButton }, (_g = activeAiDrawer === null || activeAiDrawer === void 0 ? void 0 : activeAiDrawer.exitExpandedModeTrigger) === null || _g === void 0 ? void 0 : _g.customIcon)) : (React.createElement("button", { className: clsx(testutilStyles['active-ai-drawer-leave-expanded-mode-custom-button'], styles['drawer-back-to-console-button']), formAction: "none", onClick: () => setExpandedDrawerId(null), "aria-label": (_h = activeAiDrawer === null || activeAiDrawer === void 0 ? void 0 : activeAiDrawer.ariaLabels) === null || _h === void 0 ? void 0 : _h.exitExpandedModeButton }, (_j = activeAiDrawer === null || activeAiDrawer === void 0 ? void 0 : activeAiDrawer.ariaLabels) === null || _j === void 0 ? void 0 : _j.exitExpandedModeButton)))))),
|
|
116
115
|
React.createElement("div", { className: styles['drawer-content-content'] }, activeAiDrawer === null || activeAiDrawer === void 0 ? void 0 : activeAiDrawer.content)))));
|
|
117
116
|
}));
|
|
118
117
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-ai-drawer.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,WAAW,MAAM,gCAAgC,CAAC;AACzD,OAAO,iBAAiB,MAAM,kDAAkD,CAAC;AACjF,OAAO,cAAc,MAAM,mDAAmD,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAKxE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,YAAY,MAAM,4BAA4B,CAAC;AACtD,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAwBrC,MAAM,UAAU,qCAAqC,CAAC,EACpD,kBAAkB,EAClB,IAAI,EACJ,cAAc,EACd,aAAa,GAC8B;;IAC3C,MAAM,EACJ,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,UAAU,EACV,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AC,EACpE,MAAM,CAAC,+BAA+B,CAAC,CACxC,EACD,UAAU,EAAC,MAAM,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAEvC,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,UAAU,0CAAE,sBAAsB,CAC5C,CACL,CACF,CACP,CACM;wBACT,6BAAK,SAAS,EAAE,MAAM,CAAC,wBAAwB,CAAC,IAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,OAAO,CAAO,CAC7E,CACF,CACA,CACT,CAAC;QACJ,CAAC,CACU,CACd,CAAC;IACJ,CAAC,CACU,CACd,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport { Transition } from 'react-transition-group';\nimport clsx from 'clsx';\n\nimport { InternalItemOrGroup } from '../../../button-group/interfaces';\nimport ButtonGroup from '../../../button-group/internal';\nimport PanelResizeHandle from '../../../internal/components/panel-resize-handle';\nimport customCssProps from '../../../internal/generated/custom-css-properties';\nimport { usePrevious } from '../../../internal/hooks/use-previous';\nimport { getLimitedValue } from '../../../split-panel/utils/size-utils';\nimport { AppLayoutProps } from '../../interfaces';\nimport { FocusControlState } from '../../utils/use-focus-control';\nimport { AppLayoutInternals, InternalDrawer } from '../interfaces';\nimport { OnChangeParams } from '../state/use-ai-drawer';\nimport { useResize } from './use-resize';\n\nimport sharedStyles from '../../resize/styles.css.js';\nimport testutilStyles from '../../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\ninterface AIDrawerProps {\n activeAiDrawerSize: number;\n minAiDrawerSize: number;\n aiDrawer: AppLayoutProps.Drawer | undefined;\n maxAiDrawerSize: number;\n ariaLabels: any;\n aiDrawerFocusControl: FocusControlState | undefined;\n isMobile: boolean;\n drawersOpenQueue: ReadonlyArray<string> | undefined;\n onActiveAiDrawerChange: undefined | ((newDrawerId: string | null, params?: OnChangeParams) => void);\n onActiveDrawerResize: (detail: { id: string; size: number }) => void;\n expandedDrawerId?: string | null;\n setExpandedDrawerId: (value: string | null) => void;\n}\n\ninterface AppLayoutGlobalAiDrawerImplementationProps {\n appLayoutInternals: AppLayoutInternals;\n show: boolean;\n activeAiDrawer: InternalDrawer | null;\n aiDrawerProps: AIDrawerProps;\n}\n\nexport function AppLayoutGlobalAiDrawerImplementation({\n appLayoutInternals,\n show,\n activeAiDrawer,\n aiDrawerProps,\n}: AppLayoutGlobalAiDrawerImplementationProps) {\n const {\n activeAiDrawerSize,\n minAiDrawerSize,\n maxAiDrawerSize,\n ariaLabels,\n aiDrawerFocusControl,\n isMobile,\n drawersOpenQueue,\n onActiveAiDrawerChange,\n onActiveDrawerResize,\n expandedDrawerId,\n setExpandedDrawerId,\n } = aiDrawerProps;\n const { verticalOffsets, placement } = appLayoutInternals;\n const drawerRef = useRef<HTMLDivElement>(null);\n const activeDrawerId = activeAiDrawer?.id;\n\n const computedAriaLabels = {\n closeButton: activeAiDrawer ? activeAiDrawer.ariaLabels?.closeButton : ariaLabels?.toolsClose,\n content: activeAiDrawer ? activeAiDrawer.ariaLabels?.drawerName : ariaLabels?.tools,\n };\n\n const resizeProps = useResize({\n currentWidth: activeAiDrawerSize,\n minWidth: minAiDrawerSize,\n maxWidth: maxAiDrawerSize,\n panelRef: drawerRef,\n handleRef: aiDrawerFocusControl!.refs.slider,\n onResize: size => {\n onActiveDrawerResize({ id: activeDrawerId!, size });\n },\n position: 'side-start',\n });\n const size = getLimitedValue(minAiDrawerSize, activeAiDrawerSize, maxAiDrawerSize);\n const isExpanded = activeAiDrawer?.isExpandable && expandedDrawerId === activeDrawerId;\n const wasExpanded = usePrevious(isExpanded);\n const animationDisabled =\n (activeAiDrawer?.defaultActive && !drawersOpenQueue?.includes(activeAiDrawer.id)) || (wasExpanded && !isExpanded);\n const drawerHeight = `calc(100vh - ${verticalOffsets.toolbar + placement.insetBlockEnd}px)`;\n // disable resizing when the drawer is at its minimum width in a \"squeezed\" state\n // (window is between mobile and desktop sizes). At this point, the drawer can't be\n // resized in either direction, so we disable the resize handler\n const isResizingDisabled = maxAiDrawerSize < activeAiDrawerSize;\n let drawerActions: ReadonlyArray<InternalItemOrGroup> = [\n {\n type: 'icon-button',\n id: 'close',\n iconName: isMobile ? 'close' : 'angle-left',\n text: computedAriaLabels.closeButton,\n analyticsAction: 'close',\n },\n ];\n if (!isMobile && activeAiDrawer?.isExpandable) {\n drawerActions = [\n {\n type: 'icon-button',\n id: 'expand',\n iconName: isExpanded ? 'shrink' : 'expand',\n text: activeAiDrawer?.ariaLabels?.expandedModeButton ?? '',\n analyticsAction: isExpanded ? 'expand' : 'collapse',\n },\n ...drawerActions,\n ];\n }\n if (activeAiDrawer?.headerActions) {\n drawerActions = [\n {\n type: 'group',\n text: 'Actions',\n items: activeAiDrawer.headerActions!,\n },\n ...drawerActions,\n ];\n }\n\n return (\n <Transition nodeRef={drawerRef} in={show} appear={show} mountOnEnter={true} timeout={250}>\n {drawerTransitionState => {\n return (\n <Transition nodeRef={drawerRef} in={isExpanded} timeout={250}>\n {expandedTransitionState => {\n return (\n <aside\n id={activeAiDrawer?.id}\n aria-hidden={!activeAiDrawer}\n aria-label={computedAriaLabels.content}\n className={clsx(\n styles.drawer,\n styles['ai-drawer'],\n !animationDisabled && isExpanded && styles['with-expanded-motion'],\n {\n [sharedStyles['with-motion-horizontal']]: !animationDisabled,\n [testutilStyles['active-drawer']]: show,\n [styles['drawer-hidden']]: !show && drawerTransitionState === 'exited',\n [testutilStyles['drawer-closed']]: !activeAiDrawer,\n [styles['drawer-expanded']]: isExpanded,\n }\n )}\n ref={drawerRef}\n onBlur={e => {\n if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {\n aiDrawerFocusControl?.loseFocus();\n }\n }}\n style={{\n blockSize: drawerHeight,\n insetBlockStart: `${placement.insetBlockStart}px`,\n ...(!isMobile && {\n [customCssProps.drawerMinSize]: `${size}px`,\n [customCssProps.drawerSize]: `${['entering', 'entered'].includes(drawerTransitionState) ? size : 0}px`,\n }),\n }}\n data-testid={activeDrawerId && `awsui-app-layout-drawer-${activeDrawerId}`}\n >\n {!isMobile && activeAiDrawer?.resizable && (!isExpanded || expandedTransitionState !== 'entered') && (\n <div className={styles['drawer-slider']}>\n <PanelResizeHandle\n ref={aiDrawerFocusControl?.refs.slider}\n position=\"side-start\"\n className={clsx(testutilStyles['drawers-slider'], styles['ai-drawer-slider-handle'])}\n ariaLabel={activeAiDrawer?.ariaLabels?.resizeHandle}\n tooltipText={activeAiDrawer?.ariaLabels?.resizeHandleTooltipText}\n ariaValuenow={resizeProps.relativeSize}\n onKeyDown={resizeProps.onKeyDown}\n onPointerDown={resizeProps.onPointerDown}\n onDirectionClick={resizeProps.onDirectionClick}\n disabled={isResizingDisabled}\n />\n </div>\n )}\n <div className={clsx(styles['drawer-content-container'], sharedStyles['with-motion-horizontal'])}>\n <div className={styles['drawer-content']}>\n <header className={styles['drawer-content-header']}>\n <div className={styles['drawer-content-header-content']}>\n {activeAiDrawer?.header ?? <div />}\n <div className={styles['drawer-actions']}>\n <ButtonGroup\n dropdownExpandToViewport={false}\n variant=\"icon\"\n onItemClick={event => {\n switch (event.detail.id) {\n case 'close':\n onActiveAiDrawerChange?.(null, { initiatedByUserAction: true });\n break;\n case 'expand':\n setExpandedDrawerId(isExpanded ? null : activeDrawerId!);\n break;\n default:\n activeAiDrawer?.onHeaderActionClick?.(event);\n }\n }}\n ariaLabel=\"Left panel actions\"\n items={drawerActions}\n />\n </div>\n </div>\n {!isMobile && isExpanded && activeAiDrawer?.ariaLabels?.exitExpandedModeButton && (\n <div className={styles['drawer-back-to-console-slot']}>\n <div className={styles['drawer-back-to-console-button-wrapper']}>\n <button\n className={clsx(\n testutilStyles['active-ai-drawer-leave-expanded-mode-custom-button'],\n styles['drawer-back-to-console-button']\n )}\n formAction=\"none\"\n onClick={() => setExpandedDrawerId(null)}\n >\n {activeAiDrawer?.ariaLabels?.exitExpandedModeButton}\n </button>\n </div>\n </div>\n )}\n </header>\n <div className={styles['drawer-content-content']}>{activeAiDrawer?.content}</div>\n </div>\n </div>\n </aside>\n );\n }}\n </Transition>\n );\n }}\n </Transition>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"global-ai-drawer.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,WAAW,MAAM,gCAAgC,CAAC;AACzD,OAAO,iBAAiB,MAAM,kDAAkD,CAAC;AACjF,OAAO,cAAc,MAAM,mDAAmD,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAKxE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,YAAY,MAAM,4BAA4B,CAAC;AACtD,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AA8BrC,MAAM,UAAU,qCAAqC,CAAC,EACpD,kBAAkB,EAClB,IAAI,EACJ,cAAc,EACd,aAAa,GAC8B;;IAC3C,MAAM,EACJ,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,QAAQ,EACR,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,GACpB,GAAG,aAAa,CAAC;IAClB,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,kBAAkB,CAAC;IAC1D,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC/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c,aAAd,cAAc,uBAAd,cAAc,CAAE,UAAU,0CAAE,sBAAsB,IAE7D,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,uBAAuB,0CAAE,UAAU,CAC7C,CACV,CAAC,CAAC,CAAC,CACF,gCACE,SAAS,EAAE,IAAI,CACb,cAAc,CAAC,oDAAoD,CAAC,EACpE,MAAM,CAAC,+BAA+B,CAAC,CACxC,EACD,UAAU,EAAC,MAAM,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,gBAC5B,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,UAAU,0CAAE,sBAAsB,IAE7D,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,UAAU,0CAAE,sBAAsB,CAC5C,CACV,CACG,CACF,CACP,CACM;wBACT,6BAAK,SAAS,EAAE,MAAM,CAAC,wBAAwB,CAAC,IAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,OAAO,CAAO,CAC7E,CACF,CACA,CACT,CAAC;QACJ,CAAC,CACU,CACd,CAAC;IACJ,CAAC,CACU,CACd,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport { Transition } from 'react-transition-group';\nimport clsx from 'clsx';\n\nimport { InternalItemOrGroup } from '../../../button-group/interfaces';\nimport ButtonGroup from '../../../button-group/internal';\nimport PanelResizeHandle from '../../../internal/components/panel-resize-handle';\nimport customCssProps from '../../../internal/generated/custom-css-properties';\nimport { usePrevious } from '../../../internal/hooks/use-previous';\nimport { getLimitedValue } from '../../../split-panel/utils/size-utils';\nimport { AppLayoutProps } from '../../interfaces';\nimport { FocusControlState } from '../../utils/use-focus-control';\nimport { AppLayoutInternals, InternalDrawer } from '../interfaces';\nimport { OnChangeParams } from '../state/use-ai-drawer';\nimport { useResize } from './use-resize';\n\nimport sharedStyles from '../../resize/styles.css.js';\nimport testutilStyles from '../../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\ninterface AIDrawerProps {\n activeAiDrawerSize: number;\n minAiDrawerSize: number;\n aiDrawer: AppLayoutProps.Drawer | undefined;\n maxAiDrawerSize: number;\n ariaLabels: any;\n aiDrawerFocusControl: FocusControlState | undefined;\n isMobile: boolean;\n drawersOpenQueue: ReadonlyArray<string> | undefined;\n onActiveAiDrawerChange: undefined | ((newDrawerId: string | null, params?: OnChangeParams) => void);\n onActiveDrawerResize: (detail: { id: string; size: number }) => void;\n expandedDrawerId?: string | null;\n setExpandedDrawerId: (value: string | null) => void;\n}\n\ninterface AppLayoutGlobalAiDrawerImplementationProps {\n appLayoutInternals: AppLayoutInternals;\n show: boolean;\n activeAiDrawer:\n | (InternalDrawer & {\n exitExpandedModeTrigger?: {\n customIcon?: React.ReactNode;\n };\n })\n | null;\n aiDrawerProps: AIDrawerProps;\n}\n\nexport function AppLayoutGlobalAiDrawerImplementation({\n appLayoutInternals,\n show,\n activeAiDrawer,\n aiDrawerProps,\n}: AppLayoutGlobalAiDrawerImplementationProps) {\n const {\n activeAiDrawerSize,\n minAiDrawerSize,\n maxAiDrawerSize,\n ariaLabels,\n aiDrawerFocusControl,\n isMobile,\n drawersOpenQueue,\n onActiveAiDrawerChange,\n onActiveDrawerResize,\n expandedDrawerId,\n setExpandedDrawerId,\n } = aiDrawerProps;\n const { verticalOffsets, placement } = appLayoutInternals;\n const drawerRef = useRef<HTMLDivElement>(null);\n const activeDrawerId = activeAiDrawer?.id;\n\n const computedAriaLabels = {\n closeButton: activeAiDrawer ? activeAiDrawer.ariaLabels?.closeButton : ariaLabels?.toolsClose,\n content: activeAiDrawer ? activeAiDrawer.ariaLabels?.drawerName : ariaLabels?.tools,\n };\n\n const resizeProps = useResize({\n currentWidth: activeAiDrawerSize,\n minWidth: minAiDrawerSize,\n maxWidth: maxAiDrawerSize,\n panelRef: drawerRef,\n handleRef: aiDrawerFocusControl!.refs.slider,\n onResize: size => {\n onActiveDrawerResize({ id: activeDrawerId!, size });\n },\n position: 'side-start',\n });\n const size = getLimitedValue(minAiDrawerSize, activeAiDrawerSize, maxAiDrawerSize);\n const isExpanded = activeAiDrawer?.isExpandable && expandedDrawerId === activeDrawerId;\n const wasExpanded = usePrevious(isExpanded);\n const animationDisabled =\n (activeAiDrawer?.defaultActive && !drawersOpenQueue?.includes(activeAiDrawer.id)) || (wasExpanded && !isExpanded);\n const drawerHeight = `calc(100vh - ${verticalOffsets.toolbar + placement.insetBlockEnd}px)`;\n // disable resizing when the drawer is at its minimum width in a \"squeezed\" state\n // (window is between mobile and desktop sizes). At this point, the drawer can't be\n // resized in either direction, so we disable the resize handler\n const isResizingDisabled = maxAiDrawerSize < activeAiDrawerSize;\n let drawerActions: ReadonlyArray<InternalItemOrGroup> = [\n {\n type: 'icon-button',\n id: 'close',\n iconName: isMobile ? 'close' : 'angle-left',\n text: computedAriaLabels.closeButton,\n analyticsAction: 'close',\n },\n ];\n if (!isMobile && activeAiDrawer?.isExpandable) {\n drawerActions = [\n {\n type: 'icon-button',\n id: 'expand',\n iconName: isExpanded ? 'shrink' : 'expand',\n text: activeAiDrawer?.ariaLabels?.expandedModeButton ?? '',\n analyticsAction: isExpanded ? 'expand' : 'collapse',\n },\n ...drawerActions,\n ];\n }\n if (activeAiDrawer?.headerActions) {\n drawerActions = [\n {\n type: 'group',\n text: 'Actions',\n items: activeAiDrawer.headerActions!,\n },\n ...drawerActions,\n ];\n }\n\n return (\n <Transition nodeRef={drawerRef} in={show} appear={show} mountOnEnter={true} timeout={250}>\n {drawerTransitionState => {\n return (\n <Transition nodeRef={drawerRef} in={isExpanded} timeout={250}>\n {expandedTransitionState => {\n return (\n <aside\n id={activeAiDrawer?.id}\n aria-hidden={!activeAiDrawer}\n aria-label={computedAriaLabels.content}\n className={clsx(\n styles.drawer,\n styles['ai-drawer'],\n !animationDisabled && isExpanded && styles['with-expanded-motion'],\n {\n [sharedStyles['with-motion-horizontal']]: !animationDisabled,\n [testutilStyles['active-drawer']]: show,\n [styles['drawer-hidden']]: !show && drawerTransitionState === 'exited',\n [testutilStyles['drawer-closed']]: !activeAiDrawer,\n [styles['drawer-expanded']]: isExpanded,\n }\n )}\n ref={drawerRef}\n onBlur={e => {\n if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {\n aiDrawerFocusControl?.loseFocus();\n }\n }}\n style={{\n blockSize: drawerHeight,\n insetBlockStart: `${placement.insetBlockStart}px`,\n ...(!isMobile && {\n [customCssProps.drawerMinSize]: `${size}px`,\n [customCssProps.drawerSize]: `${['entering', 'entered'].includes(drawerTransitionState) ? size : 0}px`,\n }),\n }}\n data-testid={activeDrawerId && `awsui-app-layout-drawer-${activeDrawerId}`}\n >\n {!isMobile && activeAiDrawer?.resizable && (!isExpanded || expandedTransitionState !== 'entered') && (\n <div className={styles['drawer-slider']}>\n <PanelResizeHandle\n ref={aiDrawerFocusControl?.refs.slider}\n position=\"side-start\"\n className={clsx(testutilStyles['drawers-slider'], styles['ai-drawer-slider-handle'])}\n ariaLabel={activeAiDrawer?.ariaLabels?.resizeHandle}\n tooltipText={activeAiDrawer?.ariaLabels?.resizeHandleTooltipText}\n ariaValuenow={resizeProps.relativeSize}\n onKeyDown={resizeProps.onKeyDown}\n onPointerDown={resizeProps.onPointerDown}\n onDirectionClick={resizeProps.onDirectionClick}\n disabled={isResizingDisabled}\n />\n </div>\n )}\n <div className={clsx(styles['drawer-content-container'], sharedStyles['with-motion-horizontal'])}>\n <div className={styles['drawer-content']}>\n <header className={styles['drawer-content-header']}>\n <div className={styles['drawer-content-header-content']}>\n {activeAiDrawer?.header ?? <div />}\n <div className={styles['drawer-actions']}>\n <ButtonGroup\n dropdownExpandToViewport={false}\n variant=\"icon\"\n onItemClick={event => {\n switch (event.detail.id) {\n case 'close':\n onActiveAiDrawerChange?.(null, { initiatedByUserAction: true });\n break;\n case 'expand':\n setExpandedDrawerId(isExpanded ? null : activeDrawerId!);\n break;\n default:\n activeAiDrawer?.onHeaderActionClick?.(event);\n }\n }}\n ariaLabel=\"Left panel actions\"\n items={drawerActions}\n />\n </div>\n </div>\n {!isMobile && isExpanded && activeAiDrawer?.ariaLabels?.exitExpandedModeButton && (\n <div className={styles['drawer-back-to-console-slot']}>\n <div className={styles['drawer-back-to-console-button-wrapper']}>\n {activeAiDrawer?.exitExpandedModeTrigger?.customIcon ? (\n <button\n className={clsx(\n testutilStyles['active-ai-drawer-leave-expanded-mode-custom-button'],\n styles['drawer-back-to-console-custom-button']\n )}\n formAction=\"none\"\n onClick={() => setExpandedDrawerId(null)}\n aria-label={activeAiDrawer?.ariaLabels?.exitExpandedModeButton}\n >\n {activeAiDrawer?.exitExpandedModeTrigger?.customIcon}\n </button>\n ) : (\n <button\n className={clsx(\n testutilStyles['active-ai-drawer-leave-expanded-mode-custom-button'],\n styles['drawer-back-to-console-button']\n )}\n formAction=\"none\"\n onClick={() => setExpandedDrawerId(null)}\n aria-label={activeAiDrawer?.ariaLabels?.exitExpandedModeButton}\n >\n {activeAiDrawer?.ariaLabels?.exitExpandedModeButton}\n </button>\n )}\n </div>\n </div>\n )}\n </header>\n <div className={styles['drawer-content-content']}>{activeAiDrawer?.content}</div>\n </div>\n </div>\n </aside>\n );\n }}\n </Transition>\n );\n }}\n </Transition>\n );\n}\n"]}
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"drawer": "
|
|
5
|
-
"with-expanded-motion": "awsui_with-expanded-
|
|
6
|
-
"legacy": "
|
|
7
|
-
"ai-drawer": "awsui_ai-
|
|
8
|
-
"last-opened": "awsui_last-
|
|
9
|
-
"drawer-global": "awsui_drawer-
|
|
10
|
-
"drawer-expanded": "awsui_drawer-
|
|
11
|
-
"drawer-hidden": "awsui_drawer-
|
|
12
|
-
"has-next-siblings": "awsui_has-next-
|
|
13
|
-
"global-drawer-wrapper": "awsui_global-drawer-
|
|
14
|
-
"drawer-content-container": "awsui_drawer-content-
|
|
15
|
-
"drawer-gap": "awsui_drawer-
|
|
16
|
-
"drawer-close-button": "awsui_drawer-close-
|
|
17
|
-
"drawer-expanded-mode-button": "awsui_drawer-expanded-mode-
|
|
18
|
-
"drawer-content": "awsui_drawer-
|
|
19
|
-
"drawer-content-hidden": "awsui_drawer-content-
|
|
20
|
-
"drawer-slider": "awsui_drawer-
|
|
21
|
-
"drawer-actions": "awsui_drawer-
|
|
22
|
-
"ai-drawer-slider-handle": "awsui_ai-drawer-slider-
|
|
23
|
-
"drawer-content-header": "awsui_drawer-content-
|
|
24
|
-
"drawer-content-header-content": "awsui_drawer-content-header-
|
|
25
|
-
"drawer-back-to-console-slot": "awsui_drawer-back-to-console-
|
|
26
|
-
"drawer-back-to-console-button-wrapper": "awsui_drawer-back-to-console-button-
|
|
27
|
-
"drawer-back-to-console-button": "awsui_drawer-back-to-console-
|
|
28
|
-
"drawer-
|
|
4
|
+
"drawer": "awsui_drawer_12i0j_1z01s_193",
|
|
5
|
+
"with-expanded-motion": "awsui_with-expanded-motion_12i0j_1z01s_207",
|
|
6
|
+
"legacy": "awsui_legacy_12i0j_1z01s_221",
|
|
7
|
+
"ai-drawer": "awsui_ai-drawer_12i0j_1z01s_221",
|
|
8
|
+
"last-opened": "awsui_last-opened_12i0j_1z01s_229",
|
|
9
|
+
"drawer-global": "awsui_drawer-global_12i0j_1z01s_233",
|
|
10
|
+
"drawer-expanded": "awsui_drawer-expanded_12i0j_1z01s_242",
|
|
11
|
+
"drawer-hidden": "awsui_drawer-hidden_12i0j_1z01s_246",
|
|
12
|
+
"has-next-siblings": "awsui_has-next-siblings_12i0j_1z01s_256",
|
|
13
|
+
"global-drawer-wrapper": "awsui_global-drawer-wrapper_12i0j_1z01s_256",
|
|
14
|
+
"drawer-content-container": "awsui_drawer-content-container_12i0j_1z01s_270",
|
|
15
|
+
"drawer-gap": "awsui_drawer-gap_12i0j_1z01s_273",
|
|
16
|
+
"drawer-close-button": "awsui_drawer-close-button_12i0j_1z01s_291",
|
|
17
|
+
"drawer-expanded-mode-button": "awsui_drawer-expanded-mode-button_12i0j_1z01s_297",
|
|
18
|
+
"drawer-content": "awsui_drawer-content_12i0j_1z01s_270",
|
|
19
|
+
"drawer-content-hidden": "awsui_drawer-content-hidden_12i0j_1z01s_309",
|
|
20
|
+
"drawer-slider": "awsui_drawer-slider_12i0j_1z01s_312",
|
|
21
|
+
"drawer-actions": "awsui_drawer-actions_12i0j_1z01s_362",
|
|
22
|
+
"ai-drawer-slider-handle": "awsui_ai-drawer-slider-handle_12i0j_1z01s_418",
|
|
23
|
+
"drawer-content-header": "awsui_drawer-content-header_12i0j_1z01s_437",
|
|
24
|
+
"drawer-content-header-content": "awsui_drawer-content-header-content_12i0j_1z01s_450",
|
|
25
|
+
"drawer-back-to-console-slot": "awsui_drawer-back-to-console-slot_12i0j_1z01s_467",
|
|
26
|
+
"drawer-back-to-console-button-wrapper": "awsui_drawer-back-to-console-button-wrapper_12i0j_1z01s_506",
|
|
27
|
+
"drawer-back-to-console-button": "awsui_drawer-back-to-console-button_12i0j_1z01s_506",
|
|
28
|
+
"drawer-back-to-console-custom-button": "awsui_drawer-back-to-console-custom-button_12i0j_1z01s_579",
|
|
29
|
+
"drawer-content-content": "awsui_drawer-content-content_12i0j_1z01s_585"
|
|
29
30
|
};
|
|
30
31
|
|