@cloudscape-design/components 3.0.769 → 3.0.771
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/index.js +3 -3
- package/alert/index.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/global-drawers.d.ts +4 -0
- package/app-layout/visual-refresh-toolbar/drawer/global-drawers.d.ts.map +1 -0
- package/app-layout/visual-refresh-toolbar/drawer/global-drawers.js +10 -0
- package/app-layout/visual-refresh-toolbar/drawer/global-drawers.js.map +1 -0
- package/app-layout/visual-refresh-toolbar/drawer/index.d.ts +2 -8
- package/app-layout/visual-refresh-toolbar/drawer/index.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/index.js +2 -54
- package/app-layout/visual-refresh-toolbar/drawer/index.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/local-drawer.d.ts +9 -0
- package/app-layout/visual-refresh-toolbar/drawer/local-drawer.d.ts.map +1 -0
- package/app-layout/visual-refresh-toolbar/drawer/local-drawer.js +57 -0
- package/app-layout/visual-refresh-toolbar/drawer/local-drawer.js.map +1 -0
- package/app-layout/visual-refresh-toolbar/exports.d.ts +1 -1
- package/app-layout/visual-refresh-toolbar/exports.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/exports.js +1 -1
- package/app-layout/visual-refresh-toolbar/exports.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/internal.d.ts +1 -0
- package/app-layout/visual-refresh-toolbar/internal.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/internal.js +2 -1
- package/app-layout/visual-refresh-toolbar/internal.js.map +1 -1
- package/button/analytics-metadata/interfaces.d.ts +1 -1
- package/button/analytics-metadata/interfaces.d.ts.map +1 -1
- package/button/analytics-metadata/interfaces.js.map +1 -1
- package/button/internal.d.ts +2 -0
- package/button/internal.d.ts.map +1 -1
- package/button/internal.js +5 -5
- package/button/internal.js.map +1 -1
- package/form-field/internal.js +3 -3
- package/form-field/internal.js.map +1 -1
- package/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
- package/internal/analytics/components/analytics-funnel.js +4 -3
- package/internal/analytics/components/analytics-funnel.js.map +1 -1
- package/internal/analytics/hooks/use-funnel.js +3 -3
- package/internal/analytics/hooks/use-funnel.js.map +1 -1
- package/internal/analytics/interfaces.d.ts +1 -0
- package/internal/analytics/interfaces.d.ts.map +1 -1
- package/internal/analytics/interfaces.js.map +1 -1
- package/internal/analytics/selectors.d.ts +2 -1
- package/internal/analytics/selectors.d.ts.map +1 -1
- package/internal/analytics/selectors.js +4 -1
- package/internal/analytics/selectors.js.map +1 -1
- package/internal/components/chart-filter/index.d.ts.map +1 -1
- package/internal/components/chart-filter/index.js +1 -1
- package/internal/components/chart-filter/index.js.map +1 -1
- package/internal/components/dropdown-status/index.d.ts +1 -1
- package/internal/components/dropdown-status/index.d.ts.map +1 -1
- package/internal/components/dropdown-status/index.js.map +1 -1
- package/internal/context/table-component-context.d.ts +16 -0
- package/internal/context/table-component-context.d.ts.map +1 -0
- package/internal/context/table-component-context.js +10 -0
- package/internal/context/table-component-context.js.map +1 -0
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/hooks/use-table-interaction-metrics/index.d.ts +2 -1
- package/internal/hooks/use-table-interaction-metrics/index.d.ts.map +1 -1
- package/internal/hooks/use-table-interaction-metrics/index.js +4 -4
- package/internal/hooks/use-table-interaction-metrics/index.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/link/internal.js +5 -5
- package/link/internal.js.map +1 -1
- package/multiselect/internal.d.ts +8 -1
- package/multiselect/internal.d.ts.map +1 -1
- package/multiselect/internal.js +22 -136
- package/multiselect/internal.js.map +1 -1
- package/multiselect/use-multiselect.d.ts +64 -0
- package/multiselect/use-multiselect.d.ts.map +1 -0
- package/multiselect/use-multiselect.js +163 -0
- package/multiselect/use-multiselect.js.map +1 -0
- package/package.json +1 -1
- package/pagination/internal.d.ts.map +1 -1
- package/pagination/internal.js +7 -1
- package/pagination/internal.js.map +1 -1
- package/property-filter/internal.d.ts.map +1 -1
- package/property-filter/internal.js.map +1 -1
- package/table/internal.d.ts.map +1 -1
- package/table/internal.js +115 -100
- package/table/internal.js.map +1 -1
- package/text-filter/internal.d.ts.map +1 -1
- package/text-filter/internal.js +6 -0
- package/text-filter/internal.js.map +1 -1
- package/wizard/internal.js +2 -2
- package/wizard/internal.js.map +1 -1
package/alert/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import React, { useEffect } from 'react';
|
|
|
5
5
|
import { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
|
|
6
6
|
import { FunnelMetrics } from '../internal/analytics';
|
|
7
7
|
import { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';
|
|
8
|
-
import {
|
|
8
|
+
import { getSubStepAllSelector, getTextFromSelector } from '../internal/analytics/selectors';
|
|
9
9
|
import { getAnalyticsMetadataProps } from '../internal/base-component';
|
|
10
10
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
11
11
|
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
@@ -23,8 +23,8 @@ const Alert = React.forwardRef((_a, ref) => {
|
|
|
23
23
|
useEffect(() => {
|
|
24
24
|
var _a, _b, _c;
|
|
25
25
|
if (funnelInteractionId && visible && type === 'error' && funnelState.current !== 'complete') {
|
|
26
|
-
const stepName =
|
|
27
|
-
const subStepName =
|
|
26
|
+
const stepName = getTextFromSelector(stepNameSelector);
|
|
27
|
+
const subStepName = getTextFromSelector(subStepNameSelector);
|
|
28
28
|
errorCount.current++;
|
|
29
29
|
// We don't want to report an error if it is hidden, e.g. inside an Expandable Section.
|
|
30
30
|
const errorIsVisible = ((_c = (_b = (_a = baseComponentProps.__internalRootRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 0) > 0;
|
package/alert/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/alert/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AACpG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/alert/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AACpG,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAkC,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvG,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAGxE,OAAO,aAAa,MAAM,YAAY,CAAC;AAEvC,OAAO,kBAAkB,MAAM,oCAAoC,CAAC;AAIpE,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAC5B,CAAC,EAAuD,EAAE,GAA8B,EAAE,EAAE;QAA3F,EAAE,IAAI,GAAG,MAAM,EAAE,OAAO,GAAG,IAAI,OAAwB,EAAnB,KAAK,cAAzC,mBAA2C,CAAF;IACxC,MAAM,iBAAiB,GAAG,y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BAAmB;qBACpB,CAAC,CAAC;iBACJ;qBAAM;oBACL,aAAa,CAAC,WAAW,CAAC;wBACxB,gBAAgB;wBAChB,mBAAmB;wBACnB,kBAAkB;qBACnB,CAAC,CAAC;iBACJ;aACF;YAED,OAAO,GAAG,EAAE;gBACV,uDAAuD;gBACvD,UAAU,CAAC,OAAO,EAAE,CAAC;YACvB,CAAC,CAAC;SACH;QAED,uDAAuD;IACzD,CAAC,EAAE,CAAC,mBAAmB,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;IAElE,MAAM,0BAA0B,GAA6C;QAC3E,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,IAAI,kBAAkB,CAAC,MAAM,EAAE;QACtC,UAAU,EAAE;YACV,IAAI;SACL;KACF,CAAC;IAEF,OAAO,CACL,oBAAC,aAAa,kBACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,IACZ,KAAK,EACL,kBAAkB,IACtB,GAAG,EAAE,GAAG,IACJ,6BAA6B,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,CAAC,EAC5E,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACjC,eAAe,KAAK,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect } from 'react';\n\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { FunnelMetrics } from '../internal/analytics';\nimport { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport { getSubStepAllSelector, getTextFromSelector } from '../internal/analytics/selectors';\nimport { BasePropsWithAnalyticsMetadata, getAnalyticsMetadataProps } from '../internal/base-component';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { GeneratedAnalyticsMetadataAlertComponent } from './analytics-metadata/interfaces';\nimport { AlertProps } from './interfaces';\nimport InternalAlert from './internal';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\n\nexport { AlertProps };\n\nconst Alert = React.forwardRef(\n ({ type = 'info', visible = true, ...props }: AlertProps, ref: React.Ref<AlertProps.Ref>) => {\n const analyticsMetadata = getAnalyticsMetadataProps(props as BasePropsWithAnalyticsMetadata);\n const baseComponentProps = useBaseComponent<HTMLDivElement>(\n 'Alert',\n {\n props: { type, visible, dismissible: props.dismissible },\n },\n analyticsMetadata\n );\n\n const { funnelIdentifier, funnelInteractionId, funnelErrorContext, submissionAttempt, funnelState, errorCount } =\n useFunnel();\n const { stepNumber, stepNameSelector, stepIdentifier } = useFunnelStep();\n const { subStepSelector, subStepNameSelector, subStepIdentifier, subStepErrorContext } = useFunnelSubStep();\n\n useEffect(() => {\n if (funnelInteractionId && visible && type === 'error' && funnelState.current !== 'complete') {\n const stepName = getTextFromSelector(stepNameSelector);\n const subStepName = getTextFromSelector(subStepNameSelector);\n\n errorCount.current++;\n\n // We don't want to report an error if it is hidden, e.g. inside an Expandable Section.\n const errorIsVisible = (baseComponentProps.__internalRootRef.current?.getBoundingClientRect()?.width ?? 0) > 0;\n\n if (errorIsVisible) {\n if (subStepSelector) {\n FunnelMetrics.funnelSubStepError({\n funnelInteractionId,\n funnelIdentifier,\n stepIdentifier,\n subStepSelector,\n subStepName,\n subStepNameSelector,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n subStepIdentifier,\n subStepErrorContext,\n });\n } else {\n FunnelMetrics.funnelError({\n funnelIdentifier,\n funnelInteractionId,\n funnelErrorContext,\n });\n }\n }\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n errorCount.current--;\n };\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [funnelInteractionId, visible, submissionAttempt, errorCount]);\n\n const componentAnalyticsMetadata: GeneratedAnalyticsMetadataAlertComponent = {\n name: 'awsui.Alert',\n label: `.${analyticsSelectors.header}`,\n properties: {\n type,\n },\n };\n\n return (\n <InternalAlert\n type={type}\n visible={visible}\n {...props}\n {...baseComponentProps}\n ref={ref}\n {...getAnalyticsMetadataAttribute({ component: componentAnalyticsMetadata })}\n />\n );\n }\n);\n\napplyDisplayName(Alert, 'Alert');\nexport default Alert;\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare function AppLayoutGlobalDrawersImplementation(): JSX.Element;
|
|
3
|
+
export declare const createWidgetizedAppLayoutGlobalDrawers: (Loader?: typeof AppLayoutGlobalDrawersImplementation | undefined) => typeof AppLayoutGlobalDrawersImplementation;
|
|
4
|
+
//# sourceMappingURL=global-drawers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-drawers.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/global-drawers.tsx"],"names":[],"mappings":";AAOA,wBAAgB,oCAAoC,gBAEnD;AAED,eAAO,MAAM,sCAAsC,mHAAkE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { createWidgetizedComponent } from '../../../internal/widgets';
|
|
5
|
+
/* istanbul ignore next: noop stub */
|
|
6
|
+
export function AppLayoutGlobalDrawersImplementation() {
|
|
7
|
+
return React.createElement(React.Fragment, null);
|
|
8
|
+
}
|
|
9
|
+
export const createWidgetizedAppLayoutGlobalDrawers = createWidgetizedComponent(AppLayoutGlobalDrawersImplementation);
|
|
10
|
+
//# sourceMappingURL=global-drawers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-drawers.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/global-drawers.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,qCAAqC;AACrC,MAAM,UAAU,oCAAoC;IAClD,OAAO,yCAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,MAAM,sCAAsC,GAAG,yBAAyB,CAAC,oCAAoC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { createWidgetizedComponent } from '../../../internal/widgets';\n\n/* istanbul ignore next: noop stub */\nexport function AppLayoutGlobalDrawersImplementation() {\n return <></>;\n}\n\nexport const createWidgetizedAppLayoutGlobalDrawers = createWidgetizedComponent(AppLayoutGlobalDrawersImplementation);\n"]}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface AppLayoutDrawerImplementationProps {
|
|
4
|
-
appLayoutInternals: AppLayoutInternals;
|
|
5
|
-
}
|
|
6
|
-
export declare function AppLayoutDrawerImplementation({ appLayoutInternals }: AppLayoutDrawerImplementationProps): JSX.Element;
|
|
7
|
-
export declare const createWidgetizedAppLayoutDrawer: (Loader?: typeof AppLayoutDrawerImplementation | undefined) => typeof AppLayoutDrawerImplementation;
|
|
8
|
-
export {};
|
|
1
|
+
export { createWidgetizedAppLayoutDrawer, AppLayoutDrawerImplementation } from './local-drawer';
|
|
2
|
+
export { createWidgetizedAppLayoutGlobalDrawers, AppLayoutGlobalDrawersImplementation } from './global-drawers';
|
|
9
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,+BAA+B,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,sCAAsC,EAAE,oCAAoC,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,57 +1,5 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { InternalButton } from '../../../button/internal';
|
|
6
|
-
import PanelResizeHandle from '../../../internal/components/panel-resize-handle';
|
|
7
|
-
import { createWidgetizedComponent } from '../../../internal/widgets';
|
|
8
|
-
import { TOOLS_DRAWER_ID } from '../../utils/use-drawers';
|
|
9
|
-
import { useResize } from './use-resize';
|
|
10
|
-
import sharedStyles from '../../resize/styles.css.js';
|
|
11
|
-
import testutilStyles from '../../test-classes/styles.css.js';
|
|
12
|
-
import styles from './styles.css.js';
|
|
13
|
-
export function AppLayoutDrawerImplementation({ appLayoutInternals }) {
|
|
14
|
-
var _a, _b, _c, _d, _e;
|
|
15
|
-
const { activeDrawer, minDrawerSize, activeDrawerSize, maxDrawerSize, ariaLabels, drawers, drawersFocusControl, isMobile, placement, verticalOffsets, onActiveDrawerChange, onActiveDrawerResize, } = appLayoutInternals;
|
|
16
|
-
const drawerRef = useRef(null);
|
|
17
|
-
const activeDrawerId = activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.id;
|
|
18
|
-
const computedAriaLabels = {
|
|
19
|
-
closeButton: activeDrawer ? (_a = activeDrawer.ariaLabels) === null || _a === void 0 ? void 0 : _a.closeButton : ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.toolsClose,
|
|
20
|
-
content: activeDrawer ? (_b = activeDrawer.ariaLabels) === null || _b === void 0 ? void 0 : _b.drawerName : ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.tools,
|
|
21
|
-
};
|
|
22
|
-
const drawersTopOffset = (_c = verticalOffsets.drawers) !== null && _c !== void 0 ? _c : placement.insetBlockStart;
|
|
23
|
-
const isToolsDrawer = (activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.id) === TOOLS_DRAWER_ID;
|
|
24
|
-
const toolsOnlyMode = drawers.length === 1 && drawers[0].id === TOOLS_DRAWER_ID;
|
|
25
|
-
const toolsContent = (_d = drawers === null || drawers === void 0 ? void 0 : drawers.find(drawer => drawer.id === TOOLS_DRAWER_ID)) === null || _d === void 0 ? void 0 : _d.content;
|
|
26
|
-
const resizeProps = useResize({
|
|
27
|
-
currentWidth: activeDrawerSize,
|
|
28
|
-
minWidth: minDrawerSize,
|
|
29
|
-
maxWidth: maxDrawerSize,
|
|
30
|
-
panelRef: drawerRef,
|
|
31
|
-
handleRef: drawersFocusControl.refs.slider,
|
|
32
|
-
onResize: size => onActiveDrawerResize({ id: activeDrawerId, size }),
|
|
33
|
-
});
|
|
34
|
-
return (React.createElement("aside", { id: activeDrawerId, "aria-hidden": !activeDrawer, "aria-label": computedAriaLabels.content, className: clsx(styles.drawer, sharedStyles['with-motion'], {
|
|
35
|
-
[testutilStyles['active-drawer']]: !toolsOnlyMode && activeDrawerId,
|
|
36
|
-
[testutilStyles.tools]: isToolsDrawer,
|
|
37
|
-
}), ref: drawerRef, onBlur: e => {
|
|
38
|
-
if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {
|
|
39
|
-
drawersFocusControl.loseFocus();
|
|
40
|
-
}
|
|
41
|
-
}, style: {
|
|
42
|
-
blockSize: `calc(100vh - ${drawersTopOffset}px - ${placement.insetBlockEnd}px)`,
|
|
43
|
-
insetBlockStart: drawersTopOffset,
|
|
44
|
-
} },
|
|
45
|
-
!isMobile && (activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.resizable) && (React.createElement("div", { className: styles['drawer-slider'] },
|
|
46
|
-
React.createElement(PanelResizeHandle, { ref: drawersFocusControl.refs.slider, position: "side", className: testutilStyles['drawers-slider'], ariaLabel: (_e = activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.ariaLabels) === null || _e === void 0 ? void 0 : _e.resizeHandle, ariaValuenow: resizeProps.relativeSize, onKeyDown: resizeProps.onKeyDown, onPointerDown: resizeProps.onPointerDown }))),
|
|
47
|
-
React.createElement("div", { className: clsx(styles['drawer-content-container'], sharedStyles['with-motion']), style: { width: isMobile ? '100%' : `${activeDrawerSize}px` } },
|
|
48
|
-
React.createElement("div", { className: clsx(styles['drawer-close-button']) },
|
|
49
|
-
React.createElement(InternalButton, { ariaLabel: computedAriaLabels.closeButton, className: clsx({
|
|
50
|
-
[testutilStyles['active-drawer-close-button']]: !isToolsDrawer && activeDrawerId,
|
|
51
|
-
[testutilStyles['tools-close']]: isToolsDrawer,
|
|
52
|
-
}), formAction: "none", iconName: isMobile ? 'close' : 'angle-right', onClick: () => onActiveDrawerChange(null), ref: drawersFocusControl.refs.close, variant: "icon" })),
|
|
53
|
-
React.createElement("div", { className: clsx(styles['drawer-content'], activeDrawerId !== TOOLS_DRAWER_ID && styles['drawer-content-hidden']) }, toolsContent),
|
|
54
|
-
activeDrawerId !== TOOLS_DRAWER_ID && React.createElement("div", { className: styles['drawer-content'] }, activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.content))));
|
|
55
|
-
}
|
|
56
|
-
export const createWidgetizedAppLayoutDrawer = createWidgetizedComponent(AppLayoutDrawerImplementation);
|
|
3
|
+
export { createWidgetizedAppLayoutDrawer, AppLayoutDrawerImplementation } from './local-drawer';
|
|
4
|
+
export { createWidgetizedAppLayoutGlobalDrawers, AppLayoutGlobalDrawersImplementation } from './global-drawers';
|
|
57
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,+BAA+B,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,sCAAsC,EAAE,oCAAoC,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { createWidgetizedAppLayoutDrawer, AppLayoutDrawerImplementation } from './local-drawer';\nexport { createWidgetizedAppLayoutGlobalDrawers, AppLayoutGlobalDrawersImplementation } from './global-drawers';\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AppLayoutInternals } from '../interfaces';
|
|
3
|
+
interface AppLayoutDrawerImplementationProps {
|
|
4
|
+
appLayoutInternals: AppLayoutInternals;
|
|
5
|
+
}
|
|
6
|
+
export declare function AppLayoutDrawerImplementation({ appLayoutInternals }: AppLayoutDrawerImplementationProps): JSX.Element;
|
|
7
|
+
export declare const createWidgetizedAppLayoutDrawer: (Loader?: typeof AppLayoutDrawerImplementation | undefined) => typeof AppLayoutDrawerImplementation;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=local-drawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-drawer.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/local-drawer.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAOnD,UAAU,kCAAkC;IAC1C,kBAAkB,EAAE,kBAAkB,CAAC;CACxC;AAED,wBAAgB,6BAA6B,CAAC,EAAE,kBAAkB,EAAE,EAAE,kCAAkC,eAmGvG;AAED,eAAO,MAAM,+BAA+B,qGAA2D,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React, { useRef } from 'react';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { InternalButton } from '../../../button/internal';
|
|
6
|
+
import PanelResizeHandle from '../../../internal/components/panel-resize-handle';
|
|
7
|
+
import { createWidgetizedComponent } from '../../../internal/widgets';
|
|
8
|
+
import { TOOLS_DRAWER_ID } from '../../utils/use-drawers';
|
|
9
|
+
import { useResize } from './use-resize';
|
|
10
|
+
import sharedStyles from '../../resize/styles.css.js';
|
|
11
|
+
import testutilStyles from '../../test-classes/styles.css.js';
|
|
12
|
+
import styles from './styles.css.js';
|
|
13
|
+
export function AppLayoutDrawerImplementation({ appLayoutInternals }) {
|
|
14
|
+
var _a, _b, _c, _d, _e;
|
|
15
|
+
const { activeDrawer, minDrawerSize, activeDrawerSize, maxDrawerSize, ariaLabels, drawers, drawersFocusControl, isMobile, placement, verticalOffsets, onActiveDrawerChange, onActiveDrawerResize, } = appLayoutInternals;
|
|
16
|
+
const drawerRef = useRef(null);
|
|
17
|
+
const activeDrawerId = activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.id;
|
|
18
|
+
const computedAriaLabels = {
|
|
19
|
+
closeButton: activeDrawer ? (_a = activeDrawer.ariaLabels) === null || _a === void 0 ? void 0 : _a.closeButton : ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.toolsClose,
|
|
20
|
+
content: activeDrawer ? (_b = activeDrawer.ariaLabels) === null || _b === void 0 ? void 0 : _b.drawerName : ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.tools,
|
|
21
|
+
};
|
|
22
|
+
const drawersTopOffset = (_c = verticalOffsets.drawers) !== null && _c !== void 0 ? _c : placement.insetBlockStart;
|
|
23
|
+
const isToolsDrawer = (activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.id) === TOOLS_DRAWER_ID;
|
|
24
|
+
const toolsOnlyMode = drawers.length === 1 && drawers[0].id === TOOLS_DRAWER_ID;
|
|
25
|
+
const toolsContent = (_d = drawers === null || drawers === void 0 ? void 0 : drawers.find(drawer => drawer.id === TOOLS_DRAWER_ID)) === null || _d === void 0 ? void 0 : _d.content;
|
|
26
|
+
const resizeProps = useResize({
|
|
27
|
+
currentWidth: activeDrawerSize,
|
|
28
|
+
minWidth: minDrawerSize,
|
|
29
|
+
maxWidth: maxDrawerSize,
|
|
30
|
+
panelRef: drawerRef,
|
|
31
|
+
handleRef: drawersFocusControl.refs.slider,
|
|
32
|
+
onResize: size => onActiveDrawerResize({ id: activeDrawerId, size }),
|
|
33
|
+
});
|
|
34
|
+
return (React.createElement("aside", { id: activeDrawerId, "aria-hidden": !activeDrawer, "aria-label": computedAriaLabels.content, className: clsx(styles.drawer, sharedStyles['with-motion'], {
|
|
35
|
+
[testutilStyles['active-drawer']]: !toolsOnlyMode && activeDrawerId,
|
|
36
|
+
[testutilStyles.tools]: isToolsDrawer,
|
|
37
|
+
}), ref: drawerRef, onBlur: e => {
|
|
38
|
+
if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {
|
|
39
|
+
drawersFocusControl.loseFocus();
|
|
40
|
+
}
|
|
41
|
+
}, style: {
|
|
42
|
+
blockSize: `calc(100vh - ${drawersTopOffset}px - ${placement.insetBlockEnd}px)`,
|
|
43
|
+
insetBlockStart: drawersTopOffset,
|
|
44
|
+
} },
|
|
45
|
+
!isMobile && (activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.resizable) && (React.createElement("div", { className: styles['drawer-slider'] },
|
|
46
|
+
React.createElement(PanelResizeHandle, { ref: drawersFocusControl.refs.slider, position: "side", className: testutilStyles['drawers-slider'], ariaLabel: (_e = activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.ariaLabels) === null || _e === void 0 ? void 0 : _e.resizeHandle, ariaValuenow: resizeProps.relativeSize, onKeyDown: resizeProps.onKeyDown, onPointerDown: resizeProps.onPointerDown }))),
|
|
47
|
+
React.createElement("div", { className: clsx(styles['drawer-content-container'], sharedStyles['with-motion']), style: { width: isMobile ? '100%' : `${activeDrawerSize}px` } },
|
|
48
|
+
React.createElement("div", { className: clsx(styles['drawer-close-button']) },
|
|
49
|
+
React.createElement(InternalButton, { ariaLabel: computedAriaLabels.closeButton, className: clsx({
|
|
50
|
+
[testutilStyles['active-drawer-close-button']]: !isToolsDrawer && activeDrawerId,
|
|
51
|
+
[testutilStyles['tools-close']]: isToolsDrawer,
|
|
52
|
+
}), formAction: "none", iconName: isMobile ? 'close' : 'angle-right', onClick: () => onActiveDrawerChange(null), ref: drawersFocusControl.refs.close, variant: "icon" })),
|
|
53
|
+
React.createElement("div", { className: clsx(styles['drawer-content'], activeDrawerId !== TOOLS_DRAWER_ID && styles['drawer-content-hidden']) }, toolsContent),
|
|
54
|
+
activeDrawerId !== TOOLS_DRAWER_ID && React.createElement("div", { className: styles['drawer-content'] }, activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.content))));
|
|
55
|
+
}
|
|
56
|
+
export const createWidgetizedAppLayoutDrawer = createWidgetizedComponent(AppLayoutDrawerImplementation);
|
|
57
|
+
//# sourceMappingURL=local-drawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-drawer.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/local-drawer.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,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,iBAAiB,MAAM,kDAAkD,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,SAAS,EAA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AAC,IAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO,CAAO,CAC1G,CACA,CACT,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,yBAAyB,CAAC,6BAA6B,CAAC,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 { InternalButton } from '../../../button/internal';\nimport PanelResizeHandle from '../../../internal/components/panel-resize-handle';\nimport { createWidgetizedComponent } from '../../../internal/widgets';\nimport { TOOLS_DRAWER_ID } from '../../utils/use-drawers';\nimport { AppLayoutInternals } from '../interfaces';\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 AppLayoutDrawerImplementationProps {\n appLayoutInternals: AppLayoutInternals;\n}\n\nexport function AppLayoutDrawerImplementation({ appLayoutInternals }: AppLayoutDrawerImplementationProps) {\n const {\n activeDrawer,\n minDrawerSize,\n activeDrawerSize,\n maxDrawerSize,\n ariaLabels,\n drawers,\n drawersFocusControl,\n isMobile,\n placement,\n verticalOffsets,\n onActiveDrawerChange,\n onActiveDrawerResize,\n } = appLayoutInternals;\n const drawerRef = useRef<HTMLDivElement>(null);\n const activeDrawerId = activeDrawer?.id;\n\n const computedAriaLabels = {\n closeButton: activeDrawer ? activeDrawer.ariaLabels?.closeButton : ariaLabels?.toolsClose,\n content: activeDrawer ? activeDrawer.ariaLabels?.drawerName : ariaLabels?.tools,\n };\n\n const drawersTopOffset = verticalOffsets.drawers ?? placement.insetBlockStart;\n const isToolsDrawer = activeDrawer?.id === TOOLS_DRAWER_ID;\n const toolsOnlyMode = drawers.length === 1 && drawers[0].id === TOOLS_DRAWER_ID;\n const toolsContent = drawers?.find(drawer => drawer.id === TOOLS_DRAWER_ID)?.content;\n const resizeProps = useResize({\n currentWidth: activeDrawerSize,\n minWidth: minDrawerSize,\n maxWidth: maxDrawerSize,\n panelRef: drawerRef,\n handleRef: drawersFocusControl.refs.slider,\n onResize: size => onActiveDrawerResize({ id: activeDrawerId!, size }),\n });\n\n return (\n <aside\n id={activeDrawerId}\n aria-hidden={!activeDrawer}\n aria-label={computedAriaLabels.content}\n className={clsx(styles.drawer, sharedStyles['with-motion'], {\n [testutilStyles['active-drawer']]: !toolsOnlyMode && activeDrawerId,\n [testutilStyles.tools]: isToolsDrawer,\n })}\n ref={drawerRef}\n onBlur={e => {\n if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {\n drawersFocusControl.loseFocus();\n }\n }}\n style={{\n blockSize: `calc(100vh - ${drawersTopOffset}px - ${placement.insetBlockEnd}px)`,\n insetBlockStart: drawersTopOffset,\n }}\n >\n {!isMobile && activeDrawer?.resizable && (\n <div className={styles['drawer-slider']}>\n <PanelResizeHandle\n ref={drawersFocusControl.refs.slider}\n position=\"side\"\n className={testutilStyles['drawers-slider']}\n ariaLabel={activeDrawer?.ariaLabels?.resizeHandle}\n ariaValuenow={resizeProps.relativeSize}\n onKeyDown={resizeProps.onKeyDown}\n onPointerDown={resizeProps.onPointerDown}\n />\n </div>\n )}\n <div\n className={clsx(styles['drawer-content-container'], sharedStyles['with-motion'])}\n style={{ width: isMobile ? '100%' : `${activeDrawerSize}px` }}\n >\n <div className={clsx(styles['drawer-close-button'])}>\n <InternalButton\n ariaLabel={computedAriaLabels.closeButton}\n className={clsx({\n [testutilStyles['active-drawer-close-button']]: !isToolsDrawer && activeDrawerId,\n [testutilStyles['tools-close']]: isToolsDrawer,\n })}\n formAction=\"none\"\n iconName={isMobile ? 'close' : 'angle-right'}\n onClick={() => onActiveDrawerChange(null)}\n ref={drawersFocusControl.refs.close}\n variant=\"icon\"\n />\n </div>\n <div\n className={clsx(\n styles['drawer-content'],\n activeDrawerId !== TOOLS_DRAWER_ID && styles['drawer-content-hidden']\n )}\n >\n {toolsContent}\n </div>\n {activeDrawerId !== TOOLS_DRAWER_ID && <div className={styles['drawer-content']}>{activeDrawer?.content}</div>}\n </div>\n </aside>\n );\n}\n\nexport const createWidgetizedAppLayoutDrawer = createWidgetizedComponent(AppLayoutDrawerImplementation);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AppLayoutDrawerImplementation as AppLayoutDrawer } from './drawer';
|
|
1
|
+
export { AppLayoutDrawerImplementation as AppLayoutDrawer, AppLayoutGlobalDrawersImplementation as AppLayoutGlobalDrawers, } from './drawer';
|
|
2
2
|
export { AppLayoutNavigationImplementation as AppLayoutNavigation } from './navigation';
|
|
3
3
|
export { AppLayoutNotificationsImplementation as AppLayoutNotifications } from './notifications';
|
|
4
4
|
export { AppLayoutSplitPanelDrawerBottomImplementation as AppLayoutSplitPanelDrawerBottom, AppLayoutSplitPanelDrawerSideImplementation as AppLayoutSplitPanelDrawerSide, } from './split-panel';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh-toolbar/exports.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh-toolbar/exports.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,6BAA6B,IAAI,eAAe,EAChD,oCAAoC,IAAI,sBAAsB,GAC/D,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iCAAiC,IAAI,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,oCAAoC,IAAI,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACjG,OAAO,EACL,6CAA6C,IAAI,+BAA+B,EAChF,2CAA2C,IAAI,6BAA6B,GAC7E,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,8BAA8B,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
export { AppLayoutDrawerImplementation as AppLayoutDrawer } from './drawer';
|
|
3
|
+
export { AppLayoutDrawerImplementation as AppLayoutDrawer, AppLayoutGlobalDrawersImplementation as AppLayoutGlobalDrawers, } from './drawer';
|
|
4
4
|
export { AppLayoutNavigationImplementation as AppLayoutNavigation } from './navigation';
|
|
5
5
|
export { AppLayoutNotificationsImplementation as AppLayoutNotifications } from './notifications';
|
|
6
6
|
export { AppLayoutSplitPanelDrawerBottomImplementation as AppLayoutSplitPanelDrawerBottom, AppLayoutSplitPanelDrawerSideImplementation as AppLayoutSplitPanelDrawerSide, } from './split-panel';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh-toolbar/exports.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh-toolbar/exports.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EACL,6BAA6B,IAAI,eAAe,EAChD,oCAAoC,IAAI,sBAAsB,GAC/D,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iCAAiC,IAAI,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,oCAAoC,IAAI,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACjG,OAAO,EACL,6CAA6C,IAAI,+BAA+B,EAChF,2CAA2C,IAAI,6BAA6B,GAC7E,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,8BAA8B,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport {\n AppLayoutDrawerImplementation as AppLayoutDrawer,\n AppLayoutGlobalDrawersImplementation as AppLayoutGlobalDrawers,\n} from './drawer';\nexport { AppLayoutNavigationImplementation as AppLayoutNavigation } from './navigation';\nexport { AppLayoutNotificationsImplementation as AppLayoutNotifications } from './notifications';\nexport {\n AppLayoutSplitPanelDrawerBottomImplementation as AppLayoutSplitPanelDrawerBottom,\n AppLayoutSplitPanelDrawerSideImplementation as AppLayoutSplitPanelDrawerSide,\n} from './split-panel';\nexport { AppLayoutToolbarImplementation as AppLayoutToolbar } from './toolbar';\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const AppLayoutNavigation: typeof import("./navigation").AppLayoutNavigationImplementation;
|
|
2
2
|
export declare const AppLayoutDrawer: typeof import("./drawer").AppLayoutDrawerImplementation;
|
|
3
|
+
export declare const AppLayoutGlobalDrawers: typeof import("./drawer").AppLayoutGlobalDrawersImplementation;
|
|
3
4
|
export declare const AppLayoutNotifications: typeof import("./notifications").AppLayoutNotificationsImplementation;
|
|
4
5
|
export declare const AppLayoutToolbar: typeof import("./toolbar").AppLayoutToolbarImplementation;
|
|
5
6
|
export declare const AppLayoutSplitPanelBottom: typeof import("./split-panel").AppLayoutSplitPanelDrawerBottomImplementation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh-toolbar/internal.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,mBAAmB,iEAAwC,CAAC;AACzE,eAAO,MAAM,eAAe,yDAAoC,CAAC;AACjE,eAAO,MAAM,sBAAsB,uEAA2C,CAAC;AAC/E,eAAO,MAAM,gBAAgB,2DAAqC,CAAC;AACnE,eAAO,MAAM,yBAAyB,8EAAoD,CAAC;AAC3F,eAAO,MAAM,uBAAuB,4EAAkD,CAAC"}
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh-toolbar/internal.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,mBAAmB,iEAAwC,CAAC;AACzE,eAAO,MAAM,eAAe,yDAAoC,CAAC;AACjE,eAAO,MAAM,sBAAsB,gEAA2C,CAAC;AAC/E,eAAO,MAAM,sBAAsB,uEAA2C,CAAC;AAC/E,eAAO,MAAM,gBAAgB,2DAAqC,CAAC;AACnE,eAAO,MAAM,yBAAyB,8EAAoD,CAAC;AAC3F,eAAO,MAAM,uBAAuB,4EAAkD,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { createWidgetizedAppLayoutDrawer } from './drawer';
|
|
3
|
+
import { createWidgetizedAppLayoutDrawer, createWidgetizedAppLayoutGlobalDrawers } from './drawer';
|
|
4
4
|
import { createWidgetizedAppLayoutNavigation } from './navigation';
|
|
5
5
|
import { createWidgetizedAppLayoutNotifications } from './notifications';
|
|
6
6
|
import { createWidgetizedAppLayoutSplitPanelDrawerBottom, createWidgetizedAppLayoutSplitPanelDrawerSide, } from './split-panel';
|
|
7
7
|
import { createWidgetizedAppLayoutToolbar } from './toolbar';
|
|
8
8
|
export const AppLayoutNavigation = createWidgetizedAppLayoutNavigation();
|
|
9
9
|
export const AppLayoutDrawer = createWidgetizedAppLayoutDrawer();
|
|
10
|
+
export const AppLayoutGlobalDrawers = createWidgetizedAppLayoutGlobalDrawers();
|
|
10
11
|
export const AppLayoutNotifications = createWidgetizedAppLayoutNotifications();
|
|
11
12
|
export const AppLayoutToolbar = createWidgetizedAppLayoutToolbar();
|
|
12
13
|
export const AppLayoutSplitPanelBottom = createWidgetizedAppLayoutSplitPanelDrawerBottom();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh-toolbar/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh-toolbar/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,+BAA+B,EAAE,sCAAsC,EAAE,MAAM,UAAU,CAAC;AACnG,OAAO,EAAE,mCAAmC,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,sCAAsC,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,+CAA+C,EAC/C,6CAA6C,GAC9C,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gCAAgC,EAAE,MAAM,WAAW,CAAC;AAE7D,MAAM,CAAC,MAAM,mBAAmB,GAAG,mCAAmC,EAAE,CAAC;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,+BAA+B,EAAE,CAAC;AACjE,MAAM,CAAC,MAAM,sBAAsB,GAAG,sCAAsC,EAAE,CAAC;AAC/E,MAAM,CAAC,MAAM,sBAAsB,GAAG,sCAAsC,EAAE,CAAC;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAAG,gCAAgC,EAAE,CAAC;AACnE,MAAM,CAAC,MAAM,yBAAyB,GAAG,+CAA+C,EAAE,CAAC;AAC3F,MAAM,CAAC,MAAM,uBAAuB,GAAG,6CAA6C,EAAE,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { createWidgetizedAppLayoutDrawer, createWidgetizedAppLayoutGlobalDrawers } from './drawer';\nimport { createWidgetizedAppLayoutNavigation } from './navigation';\nimport { createWidgetizedAppLayoutNotifications } from './notifications';\nimport {\n createWidgetizedAppLayoutSplitPanelDrawerBottom,\n createWidgetizedAppLayoutSplitPanelDrawerSide,\n} from './split-panel';\nimport { createWidgetizedAppLayoutToolbar } from './toolbar';\n\nexport const AppLayoutNavigation = createWidgetizedAppLayoutNavigation();\nexport const AppLayoutDrawer = createWidgetizedAppLayoutDrawer();\nexport const AppLayoutGlobalDrawers = createWidgetizedAppLayoutGlobalDrawers();\nexport const AppLayoutNotifications = createWidgetizedAppLayoutNotifications();\nexport const AppLayoutToolbar = createWidgetizedAppLayoutToolbar();\nexport const AppLayoutSplitPanelBottom = createWidgetizedAppLayoutSplitPanelDrawerBottom();\nexport const AppLayoutSplitPanelSide = createWidgetizedAppLayoutSplitPanelDrawerSide();\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/button/analytics-metadata/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,kEAAkE,CAAC;AAEnG,UAAU,qCAAqC;IAC7C,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/button/analytics-metadata/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,kEAAkE,CAAC;AAEnG,UAAU,qCAAqC;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,GAAG,eAAe,CAAC;KACjC,CAAC;CACH;AAED,UAAU,yCAAyC;IACjD,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,eAAe,CAAC;IAChC,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,MAAM,WAAW,wCAAyC,SAAQ,OAAO,CAAC,qCAAqC,CAAC;IAC9G,SAAS,CAAC,EAAE,yCAAyC,CAAC;CACvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/button/analytics-metadata/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { LabelIdentifier } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\ninterface GeneratedAnalyticsMetadataButtonClick {\n action:
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/button/analytics-metadata/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { LabelIdentifier } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\ninterface GeneratedAnalyticsMetadataButtonClick {\n action: string;\n detail: {\n label: string | LabelIdentifier;\n };\n}\n\ninterface GeneratedAnalyticsMetadataButtonComponent {\n name: 'awsui.Button';\n label: string | LabelIdentifier;\n properties: {\n variant: string;\n disabled: string;\n };\n}\n\nexport interface GeneratedAnalyticsMetadataButtonFragment extends Partial<GeneratedAnalyticsMetadataButtonClick> {\n component?: GeneratedAnalyticsMetadataButtonComponent;\n}\n"]}
|
package/button/internal.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { ButtonProps } from './interfaces';
|
|
|
4
4
|
export type InternalButtonProps = Omit<ButtonProps, 'variant'> & {
|
|
5
5
|
variant?: ButtonProps['variant'] | 'flashbar-icon' | 'breadcrumb-group' | 'menu-trigger' | 'modal-dismiss';
|
|
6
6
|
badge?: boolean;
|
|
7
|
+
analyticsAction?: string;
|
|
7
8
|
__nativeAttributes?: (React.HTMLAttributes<HTMLAnchorElement> & React.HTMLAttributes<HTMLButtonElement>) | Record<`data-${string}`, string>;
|
|
8
9
|
__iconClass?: string;
|
|
9
10
|
__focusable?: boolean;
|
|
@@ -14,6 +15,7 @@ export type InternalButtonProps = Omit<ButtonProps, 'variant'> & {
|
|
|
14
15
|
export declare const InternalButton: React.ForwardRefExoticComponent<Omit<ButtonProps, "variant"> & {
|
|
15
16
|
variant?: ButtonProps['variant'] | 'flashbar-icon' | 'breadcrumb-group' | 'menu-trigger' | 'modal-dismiss';
|
|
16
17
|
badge?: boolean | undefined;
|
|
18
|
+
analyticsAction?: string | undefined;
|
|
17
19
|
__nativeAttributes?: (React.HTMLAttributes<HTMLAnchorElement> & React.HTMLAttributes<HTMLButtonElement>) | Record<`data-${string}`, string> | undefined;
|
|
18
20
|
__iconClass?: string | undefined;
|
|
19
21
|
__focusable?: boolean | undefined;
|
package/button/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/button/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAsB3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAQlF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAM3C,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG;IAC/D,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,eAAe,GAAG,kBAAkB,GAAG,cAAc,GAAG,eAAe,CAAC;IAC3G,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB,CAAC,EACf,CAAC,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,GAAG,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC,GACnF,MAAM,CAAC,QAAQ,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,GAAG,0BAA0B,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,CAAC;AAEtE,eAAO,MAAM,cAAc;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/button/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAsB3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAQlF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAM3C,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG;IAC/D,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,eAAe,GAAG,kBAAkB,GAAG,cAAc,GAAG,eAAe,CAAC;IAC3G,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EACf,CAAC,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,GAAG,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC,GACnF,MAAM,CAAC,QAAQ,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,GAAG,0BAA0B,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,CAAC;AAEtE,eAAO,MAAM,cAAc;cAbf,WAAW,CAAC,SAAS,CAAC,GAAG,eAAe,GAAG,kBAAkB,GAAG,cAAc,GAAG,eAAe;;;;;;;;;6GAyP3G,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
package/button/internal.js
CHANGED
|
@@ -6,7 +6,7 @@ import clsx from 'clsx';
|
|
|
6
6
|
import { getAnalyticsLabelAttribute, getAnalyticsMetadataAttribute, } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
|
|
7
7
|
import { FunnelMetrics } from '../internal/analytics';
|
|
8
8
|
import { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';
|
|
9
|
-
import { DATA_ATTR_FUNNEL_VALUE, getFunnelValueSelector,
|
|
9
|
+
import { DATA_ATTR_FUNNEL_VALUE, getFunnelValueSelector, getSubStepAllSelector, getTextFromSelector, } from '../internal/analytics/selectors';
|
|
10
10
|
import LiveRegion from '../internal/components/live-region';
|
|
11
11
|
import Tooltip from '../internal/components/tooltip/index.js';
|
|
12
12
|
import { useButtonContext } from '../internal/context/button-context';
|
|
@@ -23,7 +23,7 @@ import analyticsSelectors from './analytics-metadata/styles.css.js';
|
|
|
23
23
|
import styles from './styles.css.js';
|
|
24
24
|
import testUtilStyles from './test-classes/styles.css.js';
|
|
25
25
|
export const InternalButton = React.forwardRef((_a, ref) => {
|
|
26
|
-
var { children, iconName, __iconClass, onClick, onFollow, iconAlign = 'left', iconUrl, iconSvg, iconAlt, variant = 'normal', loading = false, loadingText, disabled = false, disabledReason, wrapText = true, href, target, rel, download, formAction = 'submit', ariaLabel, ariaDescribedby, ariaExpanded, ariaControls, fullWidth, badge, __nativeAttributes, __internalRootRef = null, __focusable = false, __injectAnalyticsComponentMetadata = false, __title, __emitPerformanceMarks = true } = _a, props = __rest(_a, ["children", "iconName", "__iconClass", "onClick", "onFollow", "iconAlign", "iconUrl", "iconSvg", "iconAlt", "variant", "loading", "loadingText", "disabled", "disabledReason", "wrapText", "href", "target", "rel", "download", "formAction", "ariaLabel", "ariaDescribedby", "ariaExpanded", "ariaControls", "fullWidth", "badge", "__nativeAttributes", "__internalRootRef", "__focusable", "__injectAnalyticsComponentMetadata", "__title", "__emitPerformanceMarks"]);
|
|
26
|
+
var { children, iconName, __iconClass, onClick, onFollow, iconAlign = 'left', iconUrl, iconSvg, iconAlt, variant = 'normal', loading = false, loadingText, disabled = false, disabledReason, wrapText = true, href, target, rel, download, formAction = 'submit', ariaLabel, ariaDescribedby, ariaExpanded, ariaControls, fullWidth, badge, __nativeAttributes, __internalRootRef = null, __focusable = false, __injectAnalyticsComponentMetadata = false, __title, __emitPerformanceMarks = true, analyticsAction = 'click' } = _a, props = __rest(_a, ["children", "iconName", "__iconClass", "onClick", "onFollow", "iconAlign", "iconUrl", "iconSvg", "iconAlt", "variant", "loading", "loadingText", "disabled", "disabledReason", "wrapText", "href", "target", "rel", "download", "formAction", "ariaLabel", "ariaDescribedby", "ariaExpanded", "ariaControls", "fullWidth", "badge", "__nativeAttributes", "__internalRootRef", "__focusable", "__injectAnalyticsComponentMetadata", "__title", "__emitPerformanceMarks", "analyticsAction"]);
|
|
27
27
|
const [showTooltip, setShowTooltip] = useState(false);
|
|
28
28
|
checkSafeUrl('Button', href);
|
|
29
29
|
const isAnchor = Boolean(href);
|
|
@@ -54,8 +54,8 @@ export const InternalButton = React.forwardRef((_a, ref) => {
|
|
|
54
54
|
if (isAnchor && isPlainLeftClick(event)) {
|
|
55
55
|
fireCancelableEvent(onFollow, { href, target }, event);
|
|
56
56
|
if ((iconName === 'external' || target === '_blank') && funnelInteractionId) {
|
|
57
|
-
const stepName =
|
|
58
|
-
const subStepName =
|
|
57
|
+
const stepName = getTextFromSelector(stepNameSelector);
|
|
58
|
+
const subStepName = getTextFromSelector(subStepNameSelector);
|
|
59
59
|
FunnelMetrics.externalLinkInteracted({
|
|
60
60
|
funnelInteractionId,
|
|
61
61
|
stepNumber,
|
|
@@ -87,7 +87,7 @@ export const InternalButton = React.forwardRef((_a, ref) => {
|
|
|
87
87
|
const analyticsMetadata = disabled
|
|
88
88
|
? {}
|
|
89
89
|
: {
|
|
90
|
-
action:
|
|
90
|
+
action: analyticsAction,
|
|
91
91
|
detail: { label: { root: 'self' } },
|
|
92
92
|
};
|
|
93
93
|
if (__injectAnalyticsComponentMetadata) {
|
package/button/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/button/internal.tsx"],"names":[],"m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AQ,EAAE,QAAQ,IAAI,CAAC,WAAW,IAAI,CAAC,oBAAoB,mBAC5C,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EACjD,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,EACtE,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EACtE,YAAY,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,EAC3E,YAAY,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,IACxE,CAAC,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;YAE5C,aAAa;YACb,oBAAoB,IAAI,CACvB;gBACG,aAAa;gBACb,WAAW,IAAI,CACd,oBAAC,OAAO,IACN,SAAS,EAAE,cAAc,CAAC,yBAAyB,CAAC,EACpD,QAAQ,EAAE,SAAS,EACnB,KAAK,EAAE,cAAe,GACtB,CACH,CACA,CACJ,CACM;QACR,OAAO,IAAI,WAAW,IAAI,oBAAC,UAAU,QAAE,WAAW,CAAc,CAChE,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport {\n getAnalyticsLabelAttribute,\n getAnalyticsMetadataAttribute,\n} from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { FunnelMetrics } from '../internal/analytics';\nimport { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport {\n DATA_ATTR_FUNNEL_VALUE,\n getFunnelValueSelector,\n getNameFromSelector,\n getSubStepAllSelector,\n} from '../internal/analytics/selectors';\nimport LiveRegion from '../internal/components/live-region';\nimport Tooltip from '../internal/components/tooltip/index.js';\nimport { useButtonContext } from '../internal/context/button-context';\nimport { useSingleTabStopNavigation } from '../internal/context/single-tab-stop-navigation-context';\nimport { fireCancelableEvent, isPlainLeftClick } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport useHiddenDescription from '../internal/hooks/use-hidden-description';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { usePerformanceMarks } from '../internal/hooks/use-performance-marks';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { GeneratedAnalyticsMetadataButtonFragment } from './analytics-metadata/interfaces';\nimport { ButtonIconProps, LeftIcon, RightIcon } from './icon-helper';\nimport { ButtonProps } from './interfaces';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\nexport type InternalButtonProps = Omit<ButtonProps, 'variant'> & {\n variant?: ButtonProps['variant'] | 'flashbar-icon' | 'breadcrumb-group' | 'menu-trigger' | 'modal-dismiss';\n badge?: boolean;\n __nativeAttributes?:\n | (React.HTMLAttributes<HTMLAnchorElement> & React.HTMLAttributes<HTMLButtonElement>)\n | Record<`data-${string}`, string>;\n __iconClass?: string;\n __focusable?: boolean;\n __injectAnalyticsComponentMetadata?: boolean;\n __title?: string;\n __emitPerformanceMarks?: boolean;\n} & InternalBaseComponentProps<HTMLAnchorElement | HTMLButtonElement>;\n\nexport const InternalButton = React.forwardRef(\n (\n {\n children,\n iconName,\n __iconClass,\n onClick,\n onFollow,\n iconAlign = 'left',\n iconUrl,\n iconSvg,\n iconAlt,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n disabledReason,\n wrapText = true,\n href,\n target,\n rel,\n download,\n formAction = 'submit',\n ariaLabel,\n ariaDescribedby,\n ariaExpanded,\n ariaControls,\n fullWidth,\n badge,\n __nativeAttributes,\n __internalRootRef = null,\n __focusable = false,\n __injectAnalyticsComponentMetadata = false,\n __title,\n __emitPerformanceMarks = true,\n ...props\n }: InternalButtonProps,\n ref: React.Ref<ButtonProps.Ref>\n ) => {\n const [showTooltip, setShowTooltip] = useState(false);\n\n checkSafeUrl('Button', href);\n const isAnchor = Boolean(href);\n const isNotInteractive = loading || disabled;\n const isDisabledWithReason = (variant === 'normal' || variant === 'primary') && !!disabledReason && disabled;\n const hasAriaDisabled = (loading && !disabled) || (disabled && __focusable) || isDisabledWithReason;\n const shouldHaveContent =\n children && ['icon', 'inline-icon', 'flashbar-icon', 'modal-dismiss'].indexOf(variant) === -1;\n\n const buttonRef = useRef<HTMLElement>(null);\n useForwardFocus(ref, buttonRef);\n\n const buttonContext = useButtonContext();\n\n const uniqueId = useUniqueId('button');\n const { funnelInteractionId } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n const { subStepSelector, subStepNameSelector } = useFunnelSubStep();\n\n const performanceMarkAttributes = usePerformanceMarks(\n 'primaryButton',\n variant === 'primary' && __emitPerformanceMarks,\n buttonRef,\n () => ({\n loading,\n disabled,\n text: buttonRef.current?.innerText,\n }),\n [loading, disabled]\n );\n\n const { targetProps, descriptionEl } = useHiddenDescription(disabledReason);\n\n const handleClick = (event: React.MouseEvent) => {\n if (isNotInteractive) {\n return event.preventDefault();\n }\n\n if (isAnchor && isPlainLeftClick(event)) {\n fireCancelableEvent(onFollow, { href, target }, event);\n\n if ((iconName === 'external' || target === '_blank') && funnelInteractionId) {\n const stepName = getNameFromSelector(stepNameSelector);\n const subStepName = getNameFromSelector(subStepNameSelector);\n\n FunnelMetrics.externalLinkInteracted({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepSelector,\n subStepName,\n subStepNameSelector,\n elementSelector: getFunnelValueSelector(uniqueId),\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n }\n\n const { altKey, button, ctrlKey, metaKey, shiftKey } = event;\n fireCancelableEvent(onClick, { altKey, button, ctrlKey, metaKey, shiftKey }, event);\n buttonContext.onClick({ variant });\n };\n\n const buttonClass = clsx(props.className, styles.button, styles[`variant-${variant}`], {\n [styles.disabled]: isNotInteractive,\n [styles['button-no-wrap']]: !wrapText,\n [styles['button-no-text']]: !shouldHaveContent,\n [styles['full-width']]: shouldHaveContent && fullWidth,\n [styles.link]: isAnchor,\n });\n\n const explicitTabIndex =\n __nativeAttributes && 'tabIndex' in __nativeAttributes ? __nativeAttributes.tabIndex : undefined;\n const { tabIndex } = useSingleTabStopNavigation(buttonRef, {\n tabIndex: isAnchor && isNotInteractive ? -1 : explicitTabIndex,\n });\n\n const analyticsMetadata: GeneratedAnalyticsMetadataButtonFragment = disabled\n ? {}\n : {\n action: 'click',\n detail: { label: { root: 'self' } },\n };\n if (__injectAnalyticsComponentMetadata) {\n analyticsMetadata.component = {\n name: 'awsui.Button',\n label: { root: 'self' },\n properties: { variant, disabled: `${disabled}` },\n };\n }\n\n const buttonProps = {\n ...props,\n ...__nativeAttributes,\n ...performanceMarkAttributes,\n tabIndex,\n // https://github.com/microsoft/TypeScript/issues/36659\n ref: useMergeRefs(buttonRef, __internalRootRef),\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedby,\n 'aria-expanded': ariaExpanded,\n 'aria-controls': ariaControls,\n // add ariaLabel as `title` as visible hint text\n title: __title ?? ariaLabel,\n className: buttonClass,\n onClick: handleClick,\n [DATA_ATTR_FUNNEL_VALUE]: uniqueId,\n ...getAnalyticsMetadataAttribute(analyticsMetadata),\n ...getAnalyticsLabelAttribute(children ? `.${analyticsSelectors.label}` : ''),\n } as const;\n\n const iconProps: ButtonIconProps = {\n loading,\n iconName,\n iconAlign,\n iconUrl,\n iconSvg,\n iconAlt,\n variant,\n badge,\n iconClass: __iconClass,\n iconSize: variant === 'modal-dismiss' ? 'medium' : 'normal',\n };\n const buttonContent = (\n <>\n <LeftIcon {...iconProps} />\n {shouldHaveContent && <span className={clsx(styles.content, analyticsSelectors.label)}>{children}</span>}\n <RightIcon {...iconProps} />\n </>\n );\n\n const { loadingButtonCount } = useFunnel();\n useEffect(() => {\n if (loading) {\n loadingButtonCount.current++;\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n loadingButtonCount.current--;\n };\n }\n }, [loading, loadingButtonCount]);\n\n if (isAnchor) {\n return (\n // https://github.com/yannickcr/eslint-plugin-react/issues/2962\n // eslint-disable-next-line react/jsx-no-target-blank\n <>\n <a\n {...buttonProps}\n href={href}\n target={target}\n // security recommendation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target\n rel={rel ?? (target === '_blank' ? 'noopener noreferrer' : undefined)}\n aria-disabled={isNotInteractive ? true : undefined}\n download={download}\n >\n {buttonContent}\n </a>\n {loading && loadingText && <LiveRegion>{loadingText}</LiveRegion>}\n </>\n );\n }\n\n return (\n <>\n <button\n {...buttonProps}\n type={formAction === 'none' ? 'button' : 'submit'}\n disabled={disabled && !__focusable && !isDisabledWithReason}\n aria-disabled={hasAriaDisabled ? true : undefined}\n onFocus={isDisabledWithReason ? () => setShowTooltip(true) : undefined}\n onBlur={isDisabledWithReason ? () => setShowTooltip(false) : undefined}\n onMouseEnter={isDisabledWithReason ? () => setShowTooltip(true) : undefined}\n onMouseLeave={isDisabledWithReason ? () => setShowTooltip(false) : undefined}\n {...(isDisabledWithReason ? targetProps : {})}\n >\n {buttonContent}\n {isDisabledWithReason && (\n <>\n {descriptionEl}\n {showTooltip && (\n <Tooltip\n className={testUtilStyles['disabled-reason-tooltip']}\n trackRef={buttonRef}\n value={disabledReason!}\n />\n )}\n </>\n )}\n </button>\n {loading && loadingText && <LiveRegion>{loadingText}</LiveRegion>}\n </>\n );\n }\n);\n\nexport default Intern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L;QACE,gDACM,WAAW,IACf,IAAI,EAAE,UAAU,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EACjD,QAAQ,EAAE,QAAQ,IAAI,CAAC,WAAW,IAAI,CAAC,oBAAoB,mBAC5C,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EACjD,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,EACtE,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EACtE,YAAY,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,EAC3E,YAAY,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,IACxE,CAAC,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;YAE5C,aAAa;YACb,oBAAoB,IAAI,CACvB;gBACG,aAAa;gBACb,WAAW,IAAI,CACd,oBAAC,OAAO,IACN,SAAS,EAAE,cAAc,CAAC,yBAAyB,CAAC,EACpD,QAAQ,EAAE,SAAS,EACnB,KAAK,EAAE,cAAe,GACtB,CACH,CACA,CACJ,CACM;QACR,OAAO,IAAI,WAAW,IAAI,oBAAC,UAAU,QAAE,WAAW,CAAc,CAChE,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport {\n getAnalyticsLabelAttribute,\n getAnalyticsMetadataAttribute,\n} from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { FunnelMetrics } from '../internal/analytics';\nimport { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport {\n DATA_ATTR_FUNNEL_VALUE,\n getFunnelValueSelector,\n getSubStepAllSelector,\n getTextFromSelector,\n} from '../internal/analytics/selectors';\nimport LiveRegion from '../internal/components/live-region';\nimport Tooltip from '../internal/components/tooltip/index.js';\nimport { useButtonContext } from '../internal/context/button-context';\nimport { useSingleTabStopNavigation } from '../internal/context/single-tab-stop-navigation-context';\nimport { fireCancelableEvent, isPlainLeftClick } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport useHiddenDescription from '../internal/hooks/use-hidden-description';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { usePerformanceMarks } from '../internal/hooks/use-performance-marks';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { GeneratedAnalyticsMetadataButtonFragment } from './analytics-metadata/interfaces';\nimport { ButtonIconProps, LeftIcon, RightIcon } from './icon-helper';\nimport { ButtonProps } from './interfaces';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\nexport type InternalButtonProps = Omit<ButtonProps, 'variant'> & {\n variant?: ButtonProps['variant'] | 'flashbar-icon' | 'breadcrumb-group' | 'menu-trigger' | 'modal-dismiss';\n badge?: boolean;\n analyticsAction?: string;\n __nativeAttributes?:\n | (React.HTMLAttributes<HTMLAnchorElement> & React.HTMLAttributes<HTMLButtonElement>)\n | Record<`data-${string}`, string>;\n __iconClass?: string;\n __focusable?: boolean;\n __injectAnalyticsComponentMetadata?: boolean;\n __title?: string;\n __emitPerformanceMarks?: boolean;\n} & InternalBaseComponentProps<HTMLAnchorElement | HTMLButtonElement>;\n\nexport const InternalButton = React.forwardRef(\n (\n {\n children,\n iconName,\n __iconClass,\n onClick,\n onFollow,\n iconAlign = 'left',\n iconUrl,\n iconSvg,\n iconAlt,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n disabledReason,\n wrapText = true,\n href,\n target,\n rel,\n download,\n formAction = 'submit',\n ariaLabel,\n ariaDescribedby,\n ariaExpanded,\n ariaControls,\n fullWidth,\n badge,\n __nativeAttributes,\n __internalRootRef = null,\n __focusable = false,\n __injectAnalyticsComponentMetadata = false,\n __title,\n __emitPerformanceMarks = true,\n analyticsAction = 'click',\n ...props\n }: InternalButtonProps,\n ref: React.Ref<ButtonProps.Ref>\n ) => {\n const [showTooltip, setShowTooltip] = useState(false);\n\n checkSafeUrl('Button', href);\n const isAnchor = Boolean(href);\n const isNotInteractive = loading || disabled;\n const isDisabledWithReason = (variant === 'normal' || variant === 'primary') && !!disabledReason && disabled;\n const hasAriaDisabled = (loading && !disabled) || (disabled && __focusable) || isDisabledWithReason;\n const shouldHaveContent =\n children && ['icon', 'inline-icon', 'flashbar-icon', 'modal-dismiss'].indexOf(variant) === -1;\n\n const buttonRef = useRef<HTMLElement>(null);\n useForwardFocus(ref, buttonRef);\n\n const buttonContext = useButtonContext();\n\n const uniqueId = useUniqueId('button');\n const { funnelInteractionId } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n const { subStepSelector, subStepNameSelector } = useFunnelSubStep();\n\n const performanceMarkAttributes = usePerformanceMarks(\n 'primaryButton',\n variant === 'primary' && __emitPerformanceMarks,\n buttonRef,\n () => ({\n loading,\n disabled,\n text: buttonRef.current?.innerText,\n }),\n [loading, disabled]\n );\n\n const { targetProps, descriptionEl } = useHiddenDescription(disabledReason);\n\n const handleClick = (event: React.MouseEvent) => {\n if (isNotInteractive) {\n return event.preventDefault();\n }\n\n if (isAnchor && isPlainLeftClick(event)) {\n fireCancelableEvent(onFollow, { href, target }, event);\n\n if ((iconName === 'external' || target === '_blank') && funnelInteractionId) {\n const stepName = getTextFromSelector(stepNameSelector);\n const subStepName = getTextFromSelector(subStepNameSelector);\n\n FunnelMetrics.externalLinkInteracted({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepSelector,\n subStepName,\n subStepNameSelector,\n elementSelector: getFunnelValueSelector(uniqueId),\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n }\n\n const { altKey, button, ctrlKey, metaKey, shiftKey } = event;\n fireCancelableEvent(onClick, { altKey, button, ctrlKey, metaKey, shiftKey }, event);\n buttonContext.onClick({ variant });\n };\n\n const buttonClass = clsx(props.className, styles.button, styles[`variant-${variant}`], {\n [styles.disabled]: isNotInteractive,\n [styles['button-no-wrap']]: !wrapText,\n [styles['button-no-text']]: !shouldHaveContent,\n [styles['full-width']]: shouldHaveContent && fullWidth,\n [styles.link]: isAnchor,\n });\n\n const explicitTabIndex =\n __nativeAttributes && 'tabIndex' in __nativeAttributes ? __nativeAttributes.tabIndex : undefined;\n const { tabIndex } = useSingleTabStopNavigation(buttonRef, {\n tabIndex: isAnchor && isNotInteractive ? -1 : explicitTabIndex,\n });\n\n const analyticsMetadata: GeneratedAnalyticsMetadataButtonFragment = disabled\n ? {}\n : {\n action: analyticsAction,\n detail: { label: { root: 'self' } },\n };\n if (__injectAnalyticsComponentMetadata) {\n analyticsMetadata.component = {\n name: 'awsui.Button',\n label: { root: 'self' },\n properties: { variant, disabled: `${disabled}` },\n };\n }\n\n const buttonProps = {\n ...props,\n ...__nativeAttributes,\n ...performanceMarkAttributes,\n tabIndex,\n // https://github.com/microsoft/TypeScript/issues/36659\n ref: useMergeRefs(buttonRef, __internalRootRef),\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedby,\n 'aria-expanded': ariaExpanded,\n 'aria-controls': ariaControls,\n // add ariaLabel as `title` as visible hint text\n title: __title ?? ariaLabel,\n className: buttonClass,\n onClick: handleClick,\n [DATA_ATTR_FUNNEL_VALUE]: uniqueId,\n ...getAnalyticsMetadataAttribute(analyticsMetadata),\n ...getAnalyticsLabelAttribute(children ? `.${analyticsSelectors.label}` : ''),\n } as const;\n\n const iconProps: ButtonIconProps = {\n loading,\n iconName,\n iconAlign,\n iconUrl,\n iconSvg,\n iconAlt,\n variant,\n badge,\n iconClass: __iconClass,\n iconSize: variant === 'modal-dismiss' ? 'medium' : 'normal',\n };\n const buttonContent = (\n <>\n <LeftIcon {...iconProps} />\n {shouldHaveContent && <span className={clsx(styles.content, analyticsSelectors.label)}>{children}</span>}\n <RightIcon {...iconProps} />\n </>\n );\n\n const { loadingButtonCount } = useFunnel();\n useEffect(() => {\n if (loading) {\n loadingButtonCount.current++;\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n loadingButtonCount.current--;\n };\n }\n }, [loading, loadingButtonCount]);\n\n if (isAnchor) {\n return (\n // https://github.com/yannickcr/eslint-plugin-react/issues/2962\n // eslint-disable-next-line react/jsx-no-target-blank\n <>\n <a\n {...buttonProps}\n href={href}\n target={target}\n // security recommendation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target\n rel={rel ?? (target === '_blank' ? 'noopener noreferrer' : undefined)}\n aria-disabled={isNotInteractive ? true : undefined}\n download={download}\n >\n {buttonContent}\n </a>\n {loading && loadingText && <LiveRegion>{loadingText}</LiveRegion>}\n </>\n );\n }\n\n return (\n <>\n <button\n {...buttonProps}\n type={formAction === 'none' ? 'button' : 'submit'}\n disabled={disabled && !__focusable && !isDisabledWithReason}\n aria-disabled={hasAriaDisabled ? true : undefined}\n onFocus={isDisabledWithReason ? () => setShowTooltip(true) : undefined}\n onBlur={isDisabledWithReason ? () => setShowTooltip(false) : undefined}\n onMouseEnter={isDisabledWithReason ? () => setShowTooltip(true) : undefined}\n onMouseLeave={isDisabledWithReason ? () => setShowTooltip(false) : undefined}\n {...(isDisabledWithReason ? targetProps : {})}\n >\n {buttonContent}\n {isDisabledWithReason && (\n <>\n {descriptionEl}\n {showTooltip && (\n <Tooltip\n className={testUtilStyles['disabled-reason-tooltip']}\n trackRef={buttonRef}\n value={disabledReason!}\n />\n )}\n </>\n )}\n </button>\n {loading && loadingText && <LiveRegion>{loadingText}</LiveRegion>}\n </>\n );\n }\n);\n\nexport default InternalButton;\n"]}
|
package/form-field/internal.js
CHANGED
|
@@ -10,7 +10,7 @@ import { useInternalI18n } from '../i18n/context';
|
|
|
10
10
|
import InternalIcon from '../icon/internal';
|
|
11
11
|
import { FunnelMetrics } from '../internal/analytics';
|
|
12
12
|
import { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';
|
|
13
|
-
import { DATA_ATTR_FIELD_ERROR, DATA_ATTR_FIELD_LABEL, getFieldSlotSeletor,
|
|
13
|
+
import { DATA_ATTR_FIELD_ERROR, DATA_ATTR_FIELD_LABEL, getFieldSlotSeletor, getSubStepAllSelector, getTextFromSelector, } from '../internal/analytics/selectors';
|
|
14
14
|
import { getBaseProps } from '../internal/base-component';
|
|
15
15
|
import LiveRegion from '../internal/components/live-region';
|
|
16
16
|
import { FormFieldContext, useFormFieldContext } from '../internal/context/form-field-context';
|
|
@@ -79,8 +79,8 @@ export default function InternalFormField(_a) {
|
|
|
79
79
|
useEffect(() => {
|
|
80
80
|
var _a, _b, _c;
|
|
81
81
|
if (funnelInteractionId && errorText && funnelState.current !== 'complete') {
|
|
82
|
-
const stepName =
|
|
83
|
-
const subStepName =
|
|
82
|
+
const stepName = getTextFromSelector(stepNameSelector);
|
|
83
|
+
const subStepName = getTextFromSelector(subStepNameSelector);
|
|
84
84
|
errorCount.current++;
|
|
85
85
|
// We don't want to report an error if it is hidden, e.g. inside an Expandable Section.
|
|
86
86
|
const errorIsVisible = ((_c = (_b = (_a = __internalRootRef === null || __internalRootRef === void 0 ? void 0 : __internalRootRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 0) > 0;
|