@cloudscape-design/components-themeable 3.0.1253 → 3.0.1255
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/feature-notifications-drawer-content.d.ts +3 -2
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/feature-notifications-drawer-content.d.ts.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/feature-notifications-drawer-content.js +3 -3
- package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/feature-notifications-drawer-content.js.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/state/use-feature-notifications.d.ts.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/state/use-feature-notifications.js +6 -6
- package/lib/internal/template/app-layout/visual-refresh-toolbar/state/use-feature-notifications.js.map +1 -1
- package/lib/internal/template/i18n/providers/remote-provider.d.ts.map +1 -1
- package/lib/internal/template/i18n/providers/remote-provider.js +10 -1
- package/lib/internal/template/i18n/providers/remote-provider.js.map +1 -1
- package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
- package/lib/internal/template/internal/environment.js +2 -2
- package/lib/internal/template/internal/environment.json +2 -2
- package/lib/internal/template/internal/plugins/widget/interfaces.d.ts +8 -0
- package/lib/internal/template/internal/plugins/widget/interfaces.d.ts.map +1 -1
- package/lib/internal/template/internal/plugins/widget/interfaces.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { Feature, MountContentPart } from '../../../internal/plugins/widget/interfaces';
|
|
1
|
+
import { Feature, FeatureNotificationsPayload, MountContentPart } from '../../../internal/plugins/widget/interfaces';
|
|
2
2
|
interface RuntimeContentPartProps<T> {
|
|
3
3
|
mountContent?: MountContentPart<T>;
|
|
4
4
|
content: T;
|
|
5
5
|
}
|
|
6
6
|
export declare function RuntimeContentPart<T>({ content, mountContent }: RuntimeContentPartProps<T>): JSX.Element;
|
|
7
|
-
export default function RuntimeFeaturesNotificationDrawer<T>({ features, mountItem, featuresPageLink, }: {
|
|
7
|
+
export default function RuntimeFeaturesNotificationDrawer<T>({ features, mountItem, featuresPageLink, i18nStrings, }: {
|
|
8
8
|
features: Array<Feature<T>>;
|
|
9
9
|
mountItem?: MountContentPart<T>;
|
|
10
10
|
featuresPageLink?: string;
|
|
11
|
+
i18nStrings?: FeatureNotificationsPayload<unknown>['i18nStrings'];
|
|
11
12
|
}): JSX.Element;
|
|
12
13
|
export {};
|
|
13
14
|
//# sourceMappingURL=feature-notifications-drawer-content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-notifications-drawer-content.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/feature-notifications-drawer-content.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"feature-notifications-drawer-content.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/feature-notifications-drawer-content.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAQrH,UAAU,uBAAuB,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC;CACZ;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,uBAAuB,CAAC,CAAC,CAAC,eAkB1F;AAED,MAAM,CAAC,OAAO,UAAU,iCAAiC,CAAC,CAAC,EAAE,EAC3D,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,WAAW,GACZ,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,SAAS,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,2BAA2B,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC;CACnE,eA6CA"}
|
|
@@ -24,9 +24,9 @@ export function RuntimeContentPart({ content, mountContent }) {
|
|
|
24
24
|
}, []);
|
|
25
25
|
return mountContent ? React.createElement("div", { ref: ref }) : React.createElement(React.Fragment, null, content);
|
|
26
26
|
}
|
|
27
|
-
export default function RuntimeFeaturesNotificationDrawer({ features, mountItem, featuresPageLink, }) {
|
|
27
|
+
export default function RuntimeFeaturesNotificationDrawer({ features, mountItem, featuresPageLink, i18nStrings, }) {
|
|
28
28
|
const i18n = useInternalI18n('features-notification-drawer');
|
|
29
|
-
return (React.createElement(InternalDrawer, { header: i18n('i18nStrings.title',
|
|
29
|
+
return (React.createElement(InternalDrawer, { header: i18n('i18nStrings.title', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.titleText), disableContentPaddings: true },
|
|
30
30
|
React.createElement("div", { className: styles['runtime-feature-notifications-drawer-content'] },
|
|
31
31
|
React.createElement(Box, { padding: { top: 'm', left: 'xl', right: 'xl', bottom: 'm' } },
|
|
32
32
|
React.createElement(List, { items: features, renderItem: item => ({
|
|
@@ -42,6 +42,6 @@ export default function RuntimeFeaturesNotificationDrawer({ features, mountItem,
|
|
|
42
42
|
}) }),
|
|
43
43
|
!!featuresPageLink && (React.createElement("footer", { className: styles['runtime-feature-notifications-footer'] },
|
|
44
44
|
React.createElement(Box, { padding: { top: 's' } },
|
|
45
|
-
React.createElement(Link, { href: featuresPageLink }, i18n('i18nStrings.viewAll',
|
|
45
|
+
React.createElement(Link, { href: featuresPageLink }, i18n('i18nStrings.viewAll', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.viewAllText)))))))));
|
|
46
46
|
}
|
|
47
47
|
//# sourceMappingURL=feature-notifications-drawer-content.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-notifications-drawer-content.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/feature-notifications-drawer-content.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,GAAG,MAAM,uBAAuB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,YAAY,MAAM,iCAAiC,CAAC;AAE3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAOrC,MAAM,UAAU,kBAAkB,CAAI,EAAE,OAAO,EAAE,YAAY,EAA8B;IACzF,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEzC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,CAAC,YAAY,IAAI,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QAED,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC;QAC9B,MAAM,UAAU,GAAG,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAEpD,OAAO,GAAG,EAAE;YACV,UAAU,aAAV,UAAU,uBAAV,UAAU,EAAI,CAAC;QACjB,CAAC,CAAC;QACF,uDAAuD;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,YAAY,CAAC,CAAC,CAAC,6BAAK,GAAG,EAAE,GAAG,GAAI,CAAC,CAAC,CAAC,0CAAG,OAAO,CAAI,CAAC;AAC3D,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,iCAAiC,CAAI,EAC3D,QAAQ,EACR,SAAS,EACT,gBAAgB,
|
|
1
|
+
{"version":3,"file":"feature-notifications-drawer-content.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/drawer/feature-notifications-drawer-content.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,GAAG,MAAM,uBAAuB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,YAAY,MAAM,iCAAiC,CAAC;AAE3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAOrC,MAAM,UAAU,kBAAkB,CAAI,EAAE,OAAO,EAAE,YAAY,EAA8B;IACzF,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEzC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,CAAC,YAAY,IAAI,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QAED,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC;QAC9B,MAAM,UAAU,GAAG,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAEpD,OAAO,GAAG,EAAE;YACV,UAAU,aAAV,UAAU,uBAAV,UAAU,EAAI,CAAC;QACjB,CAAC,CAAC;QACF,uDAAuD;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,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AAO,EAAE,IAAI,CAAC,eAAe,GAAI,CAC1E,CACP;4BACD,oBAAC,GAAG;gCACF,oBAAC,kBAAkB,IAAC,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,GAAI,CAClE,CACO,CAChB;qBACF,CAAC,GACF;gBAED,CAAC,CAAC,gBAAgB,IAAI,CACrB,gCAAQ,SAAS,EAAE,MAAM,CAAC,sCAAsC,CAAC;oBAC/D,oBAAC,GAAG,IAAC,OAAO,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE;wBACxB,oBAAC,IAAI,IAAC,IAAI,EAAE,gBAAgB,IAAG,IAAI,CAAC,qBAAqB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAAC,CAAQ,CACxF,CACC,CACV,CACG,CACF,CACS,CAClB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\n\nimport Box from '../../../box/internal';\nimport { InternalDrawer } from '../../../drawer/internal';\nimport { useInternalI18n } from '../../../i18n/context';\nimport { Feature, FeatureNotificationsPayload, MountContentPart } from '../../../internal/plugins/widget/interfaces';\nimport { formatDate } from '../../../internal/utils/date-time';\nimport Link from '../../../link/internal';\nimport List from '../../../list/internal';\nimport SpaceBetween from '../../../space-between/internal';\n\nimport styles from './styles.css.js';\n\ninterface RuntimeContentPartProps<T> {\n mountContent?: MountContentPart<T>;\n content: T;\n}\n\nexport function RuntimeContentPart<T>({ content, mountContent }: RuntimeContentPartProps<T>) {\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!(mountContent && ref.current)) {\n return;\n }\n\n const container = ref.current;\n const destructor = mountContent(container, content);\n\n return () => {\n destructor?.();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return mountContent ? <div ref={ref} /> : <>{content}</>;\n}\n\nexport default function RuntimeFeaturesNotificationDrawer<T>({\n features,\n mountItem,\n featuresPageLink,\n i18nStrings,\n}: {\n features: Array<Feature<T>>;\n mountItem?: MountContentPart<T>;\n featuresPageLink?: string;\n i18nStrings?: FeatureNotificationsPayload<unknown>['i18nStrings'];\n}) {\n const i18n = useInternalI18n('features-notification-drawer');\n\n return (\n <InternalDrawer header={i18n('i18nStrings.title', i18nStrings?.titleText)} disableContentPaddings={true}>\n <div className={styles['runtime-feature-notifications-drawer-content']}>\n <Box padding={{ top: 'm', left: 'xl', right: 'xl', bottom: 'm' }}>\n <List\n items={features}\n renderItem={item => ({\n id: item.id,\n content: (\n <Box variant=\"h3\">\n <RuntimeContentPart mountContent={mountItem} content={item.header} />\n </Box>\n ),\n secondaryContent: (\n <SpaceBetween size=\"xs\" direction=\"vertical\">\n <Box fontSize=\"body-s\" color=\"text-body-secondary\">\n {formatDate(item.releaseDate)}\n </Box>\n {!!item.contentCategory && (\n <Box>\n <RuntimeContentPart mountContent={mountItem} content={item.contentCategory} />\n </Box>\n )}\n <Box>\n <RuntimeContentPart mountContent={mountItem} content={item.content} />\n </Box>\n </SpaceBetween>\n ),\n })}\n />\n\n {!!featuresPageLink && (\n <footer className={styles['runtime-feature-notifications-footer']}>\n <Box padding={{ top: 's' }}>\n <Link href={featuresPageLink}>{i18n('i18nStrings.viewAll', i18nStrings?.viewAllText)}</Link>\n </Box>\n </footer>\n )}\n </Box>\n </div>\n </InternalDrawer>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-feature-notifications.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/state/use-feature-notifications.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,SAAS,EAA6B,MAAM,OAAO,CAAC;AAOpE,OAAO,EAIL,aAAa,EACd,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOlD,UAAU,8BAA8B;IACtC,UAAU,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;CACpC;AACD,MAAM,WAAW,yBAAyB;IACxC,yBAAyB,EAAE,yBAAyB,CAAC;IACrD,MAAM,CAAC,EAAE,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC;CACvC;AACD,MAAM,MAAM,yBAAyB,GAAG,CAAC,KAAK,EAAE,8BAA8B,KAAK,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;AA+BtG,wBAAgB,uBAAuB;;;
|
|
1
|
+
{"version":3,"file":"use-feature-notifications.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/state/use-feature-notifications.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,SAAS,EAA6B,MAAM,OAAO,CAAC;AAOpE,OAAO,EAIL,aAAa,EACd,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOlD,UAAU,8BAA8B;IACtC,UAAU,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;CACpC;AACD,MAAM,WAAW,yBAAyB;IACxC,yBAAyB,EAAE,yBAAyB,CAAC;IACrD,MAAM,CAAC,EAAE,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC;CACvC;AACD,MAAM,MAAM,yBAAyB,GAAG,CAAC,KAAK,EAAE,8BAA8B,KAAK,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;AA+BtG,wBAAgB,uBAAuB;;;gDAuDc,aAAa;EA0IjE"}
|
package/lib/internal/template/app-layout/visual-refresh-toolbar/state/use-feature-notifications.js
CHANGED
|
@@ -51,10 +51,10 @@ export function useFeatureNotifications() {
|
|
|
51
51
|
.sort((a, b) => b.releaseDate.getTime() - a.releaseDate.getTime());
|
|
52
52
|
};
|
|
53
53
|
const mapPayloadToDrawer = (payload) => {
|
|
54
|
-
var _a;
|
|
54
|
+
var _a, _b, _c, _d, _e;
|
|
55
55
|
return {
|
|
56
56
|
id: payload.id,
|
|
57
|
-
content: (React.createElement(RuntimeFeaturesNotificationDrawer, { features: payload.features, featuresPageLink: payload.featuresPageLink, mountItem: payload.mountItem })),
|
|
57
|
+
content: (React.createElement(RuntimeFeaturesNotificationDrawer, { features: payload.features, featuresPageLink: payload.featuresPageLink, mountItem: payload.mountItem, i18nStrings: payload.i18nStrings })),
|
|
58
58
|
trigger: {
|
|
59
59
|
iconSvg: (React.createElement("svg", { viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg", focusable: "false", "aria-hidden": "true" },
|
|
60
60
|
React.createElement("path", { d: "M7 4L14.3244 1.25334C14.6513 1.13076 15 1.3724 15 1.7215V13.2785C15 13.6276 14.6513 13.8692 14.3244 13.7467L7 11" }),
|
|
@@ -62,10 +62,10 @@ export function useFeatureNotifications() {
|
|
|
62
62
|
React.createElement("path", { d: "M9.93649 12.1466C9.66614 13.4393 8.51989 14.4102 7.14687 14.4102C5.57286 14.4102 4.29688 13.1342 4.29688 11.5602C4.29688 11.3685 4.31579 11.1813 4.35187 11.0002" }))),
|
|
63
63
|
},
|
|
64
64
|
ariaLabels: {
|
|
65
|
-
closeButton: i18n('ariaLabels.closeButton',
|
|
66
|
-
drawerName: (
|
|
67
|
-
triggerButton: i18n('ariaLabels.triggerButton',
|
|
68
|
-
resizeHandle: i18n('ariaLabels.resizeHandle',
|
|
65
|
+
closeButton: i18n('ariaLabels.closeButton', (_a = payload.i18nStrings) === null || _a === void 0 ? void 0 : _a.closeButtonAriaLabel),
|
|
66
|
+
drawerName: (_c = i18n('ariaLabels.content', (_b = payload.i18nStrings) === null || _b === void 0 ? void 0 : _b.contentAriaLabel)) !== null && _c !== void 0 ? _c : '',
|
|
67
|
+
triggerButton: i18n('ariaLabels.triggerButton', (_d = payload.i18nStrings) === null || _d === void 0 ? void 0 : _d.triggerButtonAriaLabel),
|
|
68
|
+
resizeHandle: i18n('ariaLabels.resizeHandle', (_e = payload.i18nStrings) === null || _e === void 0 ? void 0 : _e.resizeHandleAriaLabel),
|
|
69
69
|
},
|
|
70
70
|
resizable: true,
|
|
71
71
|
defaultSize: 320,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-feature-notifications.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/state/use-feature-notifications.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAa,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,aAAqC,MAAM,6CAA6C,CAAC;AAChG,OAAO,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAO1G,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,iCAAiC,EAAE,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAEvH,MAAM,0BAA0B,GAAG;IACjC,SAAS,EAAE,6BAA6B;CACzC,CAAC;AAcF,MAAM,oCAAoC,GAAG,GAAG,CAAC;AACjD,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAEvC,SAAS,oBAAoB,CAAC,WAAiB,EAAE,iBAAyB,CAAC;IACzE,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAC;IACtD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,sBAAsB,CAAC,QAA+B;IAC7D,MAAM,UAAU,GAAG,oBAAoB,CAAC,IAAI,IAAI,EAAE,EAAE,oCAAoC,CAAC,CAAC;IAE1F,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC/C,MAAM,WAAW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,uBAAuB,EAAE,CAAC;QACtE,CAAC,MAAA,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAE,6BAA6B,mCAAI,2BAA2B,CAAC,CACtF,iBAAiB,EACjB,cAAc,CACf,CAAC,IAAI,CAAC,GAAG,EAAE;YACV,eAAe,CAAC,cAAc,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,gCAAgC,GAAG,GAAG,EAAE;QAC5C,IAAI,CAAC,wBAAwB,IAAI,oBAAoB,EAAE,CAAC;YACtD,OAAO;QACT,CAAC;QAED,2BAA2B,EAAE,CAAC;IAChC,CAAC,CAAC;IAEF,MAAM,yBAAyB,GAA8B;QAC3D,yBAAyB;QACzB,MAAM,EAAE,wBAAwB,IAAI,kBAAkB,CAAC,wBAAwB,CAAC;KACjF,CAAC;IAEF,OAAO;QACL,yBAAyB;QACzB,gCAAgC;QAChC,kCAAkC;KACnC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { RefObject, useMemo, useRef, useState } from 'react';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../../../i18n/context';\nimport FeaturePrompt, { FeaturePromptProps } from '../../../internal/do-not-use/feature-prompt';\nimport { persistFeatureNotifications, retrieveFeatureNotifications } from '../../../internal/persistence';\nimport {\n Feature,\n FeatureNotificationsPayload,\n PersistedFeaturesDict,\n WidgetMessage,\n} from '../../../internal/plugins/widget/interfaces';\nimport { useMountRefPromise } from '../../../internal/utils/promises';\nimport { AppLayoutProps } from '../../interfaces';\nimport RuntimeFeaturesNotificationDrawer, { RuntimeContentPart } from '../drawer/feature-notifications-drawer-content';\n\nconst DEFAULT_PERSISTENCE_CONFIG = {\n uniqueKey: 'awsui-feature-notifications',\n};\n\ninterface RenderLatestFeaturePromptProps {\n triggerRef: RefObject<HTMLElement>;\n}\nexport interface FeatureNotificationsProps {\n renderLatestFeaturePrompt: RenderLatestFeaturePrompt;\n drawer?: AppLayoutProps.Drawer | null;\n}\nexport type RenderLatestFeaturePrompt = (props: RenderLatestFeaturePromptProps) => JSX.Element | null;\ninterface FeatureNotifications extends FeatureNotificationsPayload<unknown> {\n badge?: boolean;\n}\n\nconst FEATURE_NOTIFICATIONS_RETENTION_DAYS = 180;\nconst DEFAULT_FEATURE_FILTER_DAYS = 90;\n\nfunction subtractDaysFromDate(currentDate: Date, daysToSubtract: number = 0): Date {\n const pastDate = new Date(currentDate);\n pastDate.setDate(pastDate.getDate() - daysToSubtract);\n return pastDate;\n}\n\nfunction filterOutdatedFeatures(features: PersistedFeaturesDict): PersistedFeaturesDict {\n const cutoffDate = subtractDaysFromDate(new Date(), FEATURE_NOTIFICATIONS_RETENTION_DAYS);\n\n return Object.keys(features).reduce((acc, key) => {\n const featureDate = new Date(features[key]);\n\n if (featureDate && featureDate >= cutoffDate) {\n return {\n ...acc,\n [key]: features[key],\n };\n }\n\n return acc;\n }, {});\n}\n\nexport function useFeatureNotifications() {\n const i18n = useInternalI18n('features-notification-drawer');\n const [featurePromptDismissed, setFeaturePromptDismissed] = useState(false);\n const [featureNotificationsData, setFeatureNotificationsData] = useState<FeatureNotifications | null>(null);\n const [seenFeatures, setSeenFeatures] = useState<PersistedFeaturesDict>({});\n const featurePromptRef = useRef<FeaturePromptProps.Ref>(null);\n const { ref: featurePromptMountRef, promise: featurePromptMountPromise } = useMountRefPromise();\n const featurePromptMergedRef = useMergeRefs(featurePromptRef, featurePromptMountRef);\n const allNotificationsSeen = useMemo(() => {\n return featureNotificationsData?.features.every(feature => !!seenFeatures[feature.id]);\n }, [featureNotificationsData, seenFeatures]);\n\n const defaultFeaturesFilter = (feature: Feature<unknown>) => {\n return feature.releaseDate >= subtractDaysFromDate(new Date(), DEFAULT_FEATURE_FILTER_DAYS);\n };\n\n const getFeaturesToDisplay = (payload: FeatureNotificationsPayload<unknown>): Array<Feature<unknown>> => {\n return payload.features\n .slice()\n .filter(payload.filterFeatures ? payload.filterFeatures : defaultFeaturesFilter)\n .sort((a, b) => b.releaseDate.getTime() - a.releaseDate.getTime());\n };\n\n const mapPayloadToDrawer = (payload: FeatureNotifications): AppLayoutProps.Drawer => {\n return {\n id: payload.id,\n content: (\n <RuntimeFeaturesNotificationDrawer\n features={payload.features}\n featuresPageLink={payload.featuresPageLink}\n mountItem={payload.mountItem}\n />\n ),\n trigger: {\n iconSvg: (\n <svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\" focusable=\"false\" aria-hidden=\"true\">\n <path d=\"M7 4L14.3244 1.25334C14.6513 1.13076 15 1.3724 15 1.7215V13.2785C15 13.6276 14.6513 13.8692 14.3244 13.7467L7 11\" />\n <path d=\"M1 6C1 4.89543 1.89543 4 3 4H7V11H3C1.89543 11 1 10.1046 1 9V6Z\" />\n <path d=\"M9.93649 12.1466C9.66614 13.4393 8.51989 14.4102 7.14687 14.4102C5.57286 14.4102 4.29688 13.1342 4.29688 11.5602C4.29688 11.3685 4.31579 11.1813 4.35187 11.0002\" />\n </svg>\n ),\n },\n ariaLabels: {\n closeButton: i18n('ariaLabels.closeButton', undefined),\n drawerName: i18n('ariaLabels.content', undefined) ?? '',\n triggerButton: i18n('ariaLabels.triggerButton', undefined),\n resizeHandle: i18n('ariaLabels.resizeHandle', undefined),\n },\n resizable: true,\n defaultSize: 320,\n badge: payload.badge,\n };\n };\n\n function featureNotificationsMessageHandler(event: WidgetMessage) {\n if (event.type === 'registerFeatureNotifications') {\n const { payload } = event;\n const features = getFeaturesToDisplay(payload);\n if (features.length === 0) {\n return;\n }\n\n setFeatureNotificationsData({ ...payload, features });\n\n const persistenceConfig = payload.persistenceConfig ?? DEFAULT_PERSISTENCE_CONFIG;\n // Retrieve previously seen feature notifications from persistence to determine\n // which features the user has already viewed\n (payload?.__retrieveFeatureNotifications || retrieveFeatureNotifications)(persistenceConfig).then(\n seenFeatureNotifications => {\n setSeenFeatures(seenFeatureNotifications);\n const hasUnseenFeatures = features.some(feature => !seenFeatureNotifications[feature.id]);\n if (hasUnseenFeatures) {\n const latestFeature = features.find(feature => !seenFeatureNotifications[feature.id]) ?? null;\n if (\n !payload.suppressFeaturePrompt &&\n !featurePromptDismissed &&\n !seenFeatureNotifications[getFeaturePromptPersistenceId(latestFeature)]\n ) {\n featurePromptMountPromise.then(() => {\n featurePromptRef.current?.show();\n });\n }\n setFeatureNotificationsData(data => (data ? { ...data, badge: true } : data));\n }\n }\n );\n return;\n }\n\n if (event.type === 'showFeaturePromptIfPossible' && !allNotificationsSeen) {\n featurePromptRef.current?.show();\n return;\n }\n\n if (event.type === 'clearFeatureNotifications') {\n setFeatureNotificationsData(null);\n return;\n }\n }\n\n function getLatestUnseenFeature() {\n return featureNotificationsData?.features.find(feature => !seenFeatures[feature.id]) ?? null;\n }\n\n function renderLatestFeaturePrompt({ triggerRef }: RenderLatestFeaturePromptProps) {\n const latestFeature = getLatestUnseenFeature();\n if (!triggerRef.current || !latestFeature) {\n return null;\n }\n return (\n <FeaturePrompt\n ref={featurePromptMergedRef}\n onShow={() => {\n triggerRef.current!.dataset!.awsuiSuppressTooltip = 'true';\n }}\n onDismiss={event => {\n if (event.detail?.method !== 'blur') {\n triggerRef?.current!.focus();\n }\n setFeaturePromptDismissed(true);\n Promise.resolve().then(() => {\n if (triggerRef.current?.dataset) {\n triggerRef.current!.dataset!.awsuiSuppressTooltip = 'false';\n }\n });\n persistFeaturePromptDismiss(latestFeature);\n }}\n header={\n <RuntimeContentPart mountContent={featureNotificationsData?.mountItem} content={latestFeature.header} />\n }\n content={\n <RuntimeContentPart mountContent={featureNotificationsData?.mountItem} content={latestFeature.content} />\n }\n trackKey={latestFeature.id}\n position=\"left\"\n getTrack={() => triggerRef.current}\n />\n );\n }\n\n const setFeaturesToSeenAndPersist = () => {\n const persistenceConfig = featureNotificationsData?.persistenceConfig ?? DEFAULT_PERSISTENCE_CONFIG;\n const featuresMap = featureNotificationsData?.features.reduce((acc, feature) => {\n return {\n ...acc,\n [feature.id]: feature.releaseDate,\n };\n }, {});\n const filteredSeenFeaturesMap = filterOutdatedFeatures(seenFeatures);\n const allFeaturesMap = { ...featuresMap, ...filteredSeenFeaturesMap };\n (featureNotificationsData?.__persistFeatureNotifications ?? persistFeatureNotifications)(\n persistenceConfig,\n allFeaturesMap\n ).then(() => {\n setSeenFeatures(allFeaturesMap);\n setFeatureNotificationsData(data => (data ? { ...data, badge: false } : data));\n });\n };\n\n const getFeaturePromptPersistenceId = (feature?: Feature<unknown> | null) => `${feature?.id}_feature-prompt`;\n\n const persistFeaturePromptDismiss = (feature: Feature<unknown>) => {\n const persistenceConfig = featureNotificationsData?.persistenceConfig ?? DEFAULT_PERSISTENCE_CONFIG;\n const featuresMap = { [getFeaturePromptPersistenceId(feature)]: feature.releaseDate?.toString() };\n const filteredSeenFeaturesMap = filterOutdatedFeatures(seenFeatures);\n const allFeaturesMap = { ...featuresMap, ...filteredSeenFeaturesMap };\n (featureNotificationsData?.__persistFeatureNotifications ?? persistFeatureNotifications)(\n persistenceConfig,\n allFeaturesMap\n ).then(() => {\n setSeenFeatures(allFeaturesMap);\n });\n };\n\n const onOpenFeatureNotificationsDrawer = () => {\n if (!featureNotificationsData || allNotificationsSeen) {\n return;\n }\n\n setFeaturesToSeenAndPersist();\n };\n\n const featureNotificationsProps: FeatureNotificationsProps = {\n renderLatestFeaturePrompt,\n drawer: featureNotificationsData && mapPayloadToDrawer(featureNotificationsData),\n };\n\n return {\n featureNotificationsProps,\n onOpenFeatureNotificationsDrawer,\n featureNotificationsMessageHandler,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-feature-notifications.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/state/use-feature-notifications.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAa,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,C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AA2B,CAAC,CACtF,iBAAiB,EACjB,cAAc,CACf,CAAC,IAAI,CAAC,GAAG,EAAE;YACV,eAAe,CAAC,cAAc,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,gCAAgC,GAAG,GAAG,EAAE;QAC5C,IAAI,CAAC,wBAAwB,IAAI,oBAAoB,EAAE,CAAC;YACtD,OAAO;QACT,CAAC;QAED,2BAA2B,EAAE,CAAC;IAChC,CAAC,CAAC;IAEF,MAAM,yBAAyB,GAA8B;QAC3D,yBAAyB;QACzB,MAAM,EAAE,wBAAwB,IAAI,kBAAkB,CAAC,wBAAwB,CAAC;KACjF,CAAC;IAEF,OAAO;QACL,yBAAyB;QACzB,gCAAgC;QAChC,kCAAkC;KACnC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { RefObject, useMemo, useRef, useState } from 'react';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../../../i18n/context';\nimport FeaturePrompt, { FeaturePromptProps } from '../../../internal/do-not-use/feature-prompt';\nimport { persistFeatureNotifications, retrieveFeatureNotifications } from '../../../internal/persistence';\nimport {\n Feature,\n FeatureNotificationsPayload,\n PersistedFeaturesDict,\n WidgetMessage,\n} from '../../../internal/plugins/widget/interfaces';\nimport { useMountRefPromise } from '../../../internal/utils/promises';\nimport { AppLayoutProps } from '../../interfaces';\nimport RuntimeFeaturesNotificationDrawer, { RuntimeContentPart } from '../drawer/feature-notifications-drawer-content';\n\nconst DEFAULT_PERSISTENCE_CONFIG = {\n uniqueKey: 'awsui-feature-notifications',\n};\n\ninterface RenderLatestFeaturePromptProps {\n triggerRef: RefObject<HTMLElement>;\n}\nexport interface FeatureNotificationsProps {\n renderLatestFeaturePrompt: RenderLatestFeaturePrompt;\n drawer?: AppLayoutProps.Drawer | null;\n}\nexport type RenderLatestFeaturePrompt = (props: RenderLatestFeaturePromptProps) => JSX.Element | null;\ninterface FeatureNotifications extends FeatureNotificationsPayload<unknown> {\n badge?: boolean;\n}\n\nconst FEATURE_NOTIFICATIONS_RETENTION_DAYS = 180;\nconst DEFAULT_FEATURE_FILTER_DAYS = 90;\n\nfunction subtractDaysFromDate(currentDate: Date, daysToSubtract: number = 0): Date {\n const pastDate = new Date(currentDate);\n pastDate.setDate(pastDate.getDate() - daysToSubtract);\n return pastDate;\n}\n\nfunction filterOutdatedFeatures(features: PersistedFeaturesDict): PersistedFeaturesDict {\n const cutoffDate = subtractDaysFromDate(new Date(), FEATURE_NOTIFICATIONS_RETENTION_DAYS);\n\n return Object.keys(features).reduce((acc, key) => {\n const featureDate = new Date(features[key]);\n\n if (featureDate && featureDate >= cutoffDate) {\n return {\n ...acc,\n [key]: features[key],\n };\n }\n\n return acc;\n }, {});\n}\n\nexport function useFeatureNotifications() {\n const i18n = useInternalI18n('features-notification-drawer');\n const [featurePromptDismissed, setFeaturePromptDismissed] = useState(false);\n const [featureNotificationsData, setFeatureNotificationsData] = useState<FeatureNotifications | null>(null);\n const [seenFeatures, setSeenFeatures] = useState<PersistedFeaturesDict>({});\n const featurePromptRef = useRef<FeaturePromptProps.Ref>(null);\n const { ref: featurePromptMountRef, promise: featurePromptMountPromise } = useMountRefPromise();\n const featurePromptMergedRef = useMergeRefs(featurePromptRef, featurePromptMountRef);\n const allNotificationsSeen = useMemo(() => {\n return featureNotificationsData?.features.every(feature => !!seenFeatures[feature.id]);\n }, [featureNotificationsData, seenFeatures]);\n\n const defaultFeaturesFilter = (feature: Feature<unknown>) => {\n return feature.releaseDate >= subtractDaysFromDate(new Date(), DEFAULT_FEATURE_FILTER_DAYS);\n };\n\n const getFeaturesToDisplay = (payload: FeatureNotificationsPayload<unknown>): Array<Feature<unknown>> => {\n return payload.features\n .slice()\n .filter(payload.filterFeatures ? payload.filterFeatures : defaultFeaturesFilter)\n .sort((a, b) => b.releaseDate.getTime() - a.releaseDate.getTime());\n };\n\n const mapPayloadToDrawer = (payload: FeatureNotifications): AppLayoutProps.Drawer => {\n return {\n id: payload.id,\n content: (\n <RuntimeFeaturesNotificationDrawer\n features={payload.features}\n featuresPageLink={payload.featuresPageLink}\n mountItem={payload.mountItem}\n i18nStrings={payload.i18nStrings}\n />\n ),\n trigger: {\n iconSvg: (\n <svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\" focusable=\"false\" aria-hidden=\"true\">\n <path d=\"M7 4L14.3244 1.25334C14.6513 1.13076 15 1.3724 15 1.7215V13.2785C15 13.6276 14.6513 13.8692 14.3244 13.7467L7 11\" />\n <path d=\"M1 6C1 4.89543 1.89543 4 3 4H7V11H3C1.89543 11 1 10.1046 1 9V6Z\" />\n <path d=\"M9.93649 12.1466C9.66614 13.4393 8.51989 14.4102 7.14687 14.4102C5.57286 14.4102 4.29688 13.1342 4.29688 11.5602C4.29688 11.3685 4.31579 11.1813 4.35187 11.0002\" />\n </svg>\n ),\n },\n ariaLabels: {\n closeButton: i18n('ariaLabels.closeButton', payload.i18nStrings?.closeButtonAriaLabel),\n drawerName: i18n('ariaLabels.content', payload.i18nStrings?.contentAriaLabel) ?? '',\n triggerButton: i18n('ariaLabels.triggerButton', payload.i18nStrings?.triggerButtonAriaLabel),\n resizeHandle: i18n('ariaLabels.resizeHandle', payload.i18nStrings?.resizeHandleAriaLabel),\n },\n resizable: true,\n defaultSize: 320,\n badge: payload.badge,\n };\n };\n\n function featureNotificationsMessageHandler(event: WidgetMessage) {\n if (event.type === 'registerFeatureNotifications') {\n const { payload } = event;\n const features = getFeaturesToDisplay(payload);\n if (features.length === 0) {\n return;\n }\n\n setFeatureNotificationsData({ ...payload, features });\n\n const persistenceConfig = payload.persistenceConfig ?? DEFAULT_PERSISTENCE_CONFIG;\n // Retrieve previously seen feature notifications from persistence to determine\n // which features the user has already viewed\n (payload?.__retrieveFeatureNotifications || retrieveFeatureNotifications)(persistenceConfig).then(\n seenFeatureNotifications => {\n setSeenFeatures(seenFeatureNotifications);\n const hasUnseenFeatures = features.some(feature => !seenFeatureNotifications[feature.id]);\n if (hasUnseenFeatures) {\n const latestFeature = features.find(feature => !seenFeatureNotifications[feature.id]) ?? null;\n if (\n !payload.suppressFeaturePrompt &&\n !featurePromptDismissed &&\n !seenFeatureNotifications[getFeaturePromptPersistenceId(latestFeature)]\n ) {\n featurePromptMountPromise.then(() => {\n featurePromptRef.current?.show();\n });\n }\n setFeatureNotificationsData(data => (data ? { ...data, badge: true } : data));\n }\n }\n );\n return;\n }\n\n if (event.type === 'showFeaturePromptIfPossible' && !allNotificationsSeen) {\n featurePromptRef.current?.show();\n return;\n }\n\n if (event.type === 'clearFeatureNotifications') {\n setFeatureNotificationsData(null);\n return;\n }\n }\n\n function getLatestUnseenFeature() {\n return featureNotificationsData?.features.find(feature => !seenFeatures[feature.id]) ?? null;\n }\n\n function renderLatestFeaturePrompt({ triggerRef }: RenderLatestFeaturePromptProps) {\n const latestFeature = getLatestUnseenFeature();\n if (!triggerRef.current || !latestFeature) {\n return null;\n }\n return (\n <FeaturePrompt\n ref={featurePromptMergedRef}\n onShow={() => {\n triggerRef.current!.dataset!.awsuiSuppressTooltip = 'true';\n }}\n onDismiss={event => {\n if (event.detail?.method !== 'blur') {\n triggerRef?.current!.focus();\n }\n setFeaturePromptDismissed(true);\n Promise.resolve().then(() => {\n if (triggerRef.current?.dataset) {\n triggerRef.current!.dataset!.awsuiSuppressTooltip = 'false';\n }\n });\n persistFeaturePromptDismiss(latestFeature);\n }}\n header={\n <RuntimeContentPart mountContent={featureNotificationsData?.mountItem} content={latestFeature.header} />\n }\n content={\n <RuntimeContentPart mountContent={featureNotificationsData?.mountItem} content={latestFeature.content} />\n }\n trackKey={latestFeature.id}\n position=\"left\"\n getTrack={() => triggerRef.current}\n />\n );\n }\n\n const setFeaturesToSeenAndPersist = () => {\n const persistenceConfig = featureNotificationsData?.persistenceConfig ?? DEFAULT_PERSISTENCE_CONFIG;\n const featuresMap = featureNotificationsData?.features.reduce((acc, feature) => {\n return {\n ...acc,\n [feature.id]: feature.releaseDate,\n };\n }, {});\n const filteredSeenFeaturesMap = filterOutdatedFeatures(seenFeatures);\n const allFeaturesMap = { ...featuresMap, ...filteredSeenFeaturesMap };\n (featureNotificationsData?.__persistFeatureNotifications ?? persistFeatureNotifications)(\n persistenceConfig,\n allFeaturesMap\n ).then(() => {\n setSeenFeatures(allFeaturesMap);\n setFeatureNotificationsData(data => (data ? { ...data, badge: false } : data));\n });\n };\n\n const getFeaturePromptPersistenceId = (feature?: Feature<unknown> | null) => `${feature?.id}_feature-prompt`;\n\n const persistFeaturePromptDismiss = (feature: Feature<unknown>) => {\n const persistenceConfig = featureNotificationsData?.persistenceConfig ?? DEFAULT_PERSISTENCE_CONFIG;\n const featuresMap = { [getFeaturePromptPersistenceId(feature)]: feature.releaseDate?.toString() };\n const filteredSeenFeaturesMap = filterOutdatedFeatures(seenFeatures);\n const allFeaturesMap = { ...featuresMap, ...filteredSeenFeaturesMap };\n (featureNotificationsData?.__persistFeatureNotifications ?? persistFeatureNotifications)(\n persistenceConfig,\n allFeaturesMap\n ).then(() => {\n setSeenFeatures(allFeaturesMap);\n });\n };\n\n const onOpenFeatureNotificationsDrawer = () => {\n if (!featureNotificationsData || allNotificationsSeen) {\n return;\n }\n\n setFeaturesToSeenAndPersist();\n };\n\n const featureNotificationsProps: FeatureNotificationsProps = {\n renderLatestFeaturePrompt,\n drawer: featureNotificationsData && mapPayloadToDrawer(featureNotificationsData),\n };\n\n return {\n featureNotificationsProps,\n onOpenFeatureNotificationsDrawer,\n featureNotificationsMessageHandler,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-provider.d.ts","sourceRoot":"","sources":["../../../../src/i18n/providers/remote-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0C,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"remote-provider.d.ts","sourceRoot":"","sources":["../../../../src/i18n/providers/remote-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAO/D,OAAO,EAAE,cAAc,EAAuB,MAAM,YAAY,CAAC;AAGjE,UAAU,sBAAsB;IAC9B,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;IAEpF,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,uBAAuB,eAuC9F"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import React, { useContext, useEffect, useState } from 'react';
|
|
4
|
+
import { getGlobalFlag } from '@cloudscape-design/component-toolkit/internal';
|
|
4
5
|
// NOTE: Ensure that direct or transitive dependencies never pull in
|
|
5
6
|
// intl-messageformat or any `@formatjs` dependencies! Otherwise, it
|
|
6
7
|
// would harm any bundle size improvements this component brings.
|
|
@@ -21,13 +22,18 @@ export default function RemoteI18nProvider({ loadFormatter, children }) {
|
|
|
21
22
|
const [locale] = useState(() => determineAppLocale());
|
|
22
23
|
const [staticLoadFormatter] = useState(() => loadFormatter);
|
|
23
24
|
useEffect(() => {
|
|
25
|
+
let mounted = true;
|
|
24
26
|
// Translations are already provided from a local provider, so skip.
|
|
25
27
|
if (hasWrapperContext) {
|
|
26
28
|
return;
|
|
27
29
|
}
|
|
30
|
+
// Skip trying to load remote provider if the app layout widget is not available
|
|
31
|
+
if (!getGlobalFlag('appLayoutWidget')) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
28
34
|
staticLoadFormatter({ locale })
|
|
29
35
|
.then(formatter => {
|
|
30
|
-
if (formatter) {
|
|
36
|
+
if (formatter && mounted) {
|
|
31
37
|
setFormatFunction(() => formatter.format.bind(formatter));
|
|
32
38
|
}
|
|
33
39
|
// If formatter isn't available, do nothing.
|
|
@@ -35,6 +41,9 @@ export default function RemoteI18nProvider({ loadFormatter, children }) {
|
|
|
35
41
|
.catch(() => {
|
|
36
42
|
// Do nothing. Failure in fetching the formatter should not be fatal.
|
|
37
43
|
});
|
|
44
|
+
return () => {
|
|
45
|
+
mounted = false;
|
|
46
|
+
};
|
|
38
47
|
}, [hasWrapperContext, locale, staticLoadFormatter]);
|
|
39
48
|
const value = wrapperContext || (formatFunction && { locale, format: formatFunction });
|
|
40
49
|
return React.createElement(InternalI18nContext.Provider, { value: value }, children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-provider.js","sourceRoot":"","sources":["../../../../src/i18n/providers/remote-provider.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE/D,oEAAoE;AACpE,oEAAoE;AACpE,iEAAiE;AACjE,OAAO,EAAkB,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAiBtD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,aAAa,EAAE,QAAQ,EAA2B;IAC7F,MAAM,cAAc,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC;IACvD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,EAA8B,CAAC;IAEnF,qEAAqE;IACrE,8EAA8E;IAC9E,4CAA4C;IAC5C,MAAM,iBAAiB,GAAG,CAAC,CAAC,cAAc,CAAC;IAC3C,MAAM,CAAC,MA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,QAAQ,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC;IAE5D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,oEAAoE;QACpE,IAAI,iBAAiB,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QACD,gFAAgF;QAChF,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACtC,OAAO;QACT,CAAC;QAED,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;aAC5B,IAAI,CAAC,SAAS,CAAC,EAAE;YAChB,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;gBACzB,iBAAiB,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;YAC5D,CAAC;YACD,4CAA4C;QAC9C,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE;YACV,qEAAqE;QACvE,CAAC,CAAC,CAAC;QACL,OAAO,GAAG,EAAE;YACV,OAAO,GAAG,KAAK,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,iBAAiB,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAErD,MAAM,KAAK,GAAG,cAAc,IAAI,CAAC,cAAc,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IACvF,OAAO,oBAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,QAAQ,CAAgC,CAAC;AAC/F,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useEffect, useState } from 'react';\n\nimport { getGlobalFlag } from '@cloudscape-design/component-toolkit/internal';\n\n// NOTE: Ensure that direct or transitive dependencies never pull in\n// intl-messageformat or any `@formatjs` dependencies! Otherwise, it\n// would harm any bundle size improvements this component brings.\nimport { FormatFunction, InternalI18nContext } from '../context';\nimport { determineAppLocale } from '../utils/locales';\n\ninterface I18nFormatterInterface {\n format: FormatFunction;\n}\n\nexport interface RemoteI18nProviderProps {\n /**\n * A format function, loaded dynamically from the result of this callback. If\n * the callback returns null, it means that the provider isn't available for\n * whatever reason, and nothing happens.\n */\n loadFormatter: (args: { locale: string }) => Promise<I18nFormatterInterface | null>;\n\n children: React.ReactNode;\n}\n\n/**\n * A lightweight implementation of the I18nProvider context wrapper that expects both the\n * messages and the formatting logic to be provided from a remote source. Explicitly does\n * nothing if it's wrapped by a LocalI18nProvider.\n */\nexport default function RemoteI18nProvider({ loadFormatter, children }: RemoteI18nProviderProps) {\n const wrapperContext = useContext(InternalI18nContext);\n const [formatFunction, setFormatFunction] = useState<FormatFunction | undefined>();\n\n // Ensure that every dependency of the effect below can never change.\n // The locale comes from the document, and the formatter only depends on that,\n // so it should never need to update either.\n const hasWrapperContext = !!wrapperContext;\n const [locale] = useState(() => determineAppLocale());\n const [staticLoadFormatter] = useState(() => loadFormatter);\n\n useEffect(() => {\n let mounted = true;\n // Translations are already provided from a local provider, so skip.\n if (hasWrapperContext) {\n return;\n }\n // Skip trying to load remote provider if the app layout widget is not available\n if (!getGlobalFlag('appLayoutWidget')) {\n return;\n }\n\n staticLoadFormatter({ locale })\n .then(formatter => {\n if (formatter && mounted) {\n setFormatFunction(() => formatter.format.bind(formatter));\n }\n // If formatter isn't available, do nothing.\n })\n .catch(() => {\n // Do nothing. Failure in fetching the formatter should not be fatal.\n });\n return () => {\n mounted = false;\n };\n }, [hasWrapperContext, locale, staticLoadFormatter]);\n\n const value = wrapperContext || (formatFunction && { locale, format: formatFunction });\n return <InternalI18nContext.Provider value={value}>{children}</InternalI18nContext.Provider>;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export var PACKAGE_SOURCE = "components";
|
|
2
|
-
export var PACKAGE_VERSION = "3.0.0 (
|
|
3
|
-
export var GIT_SHA = "
|
|
2
|
+
export var PACKAGE_VERSION = "3.0.0 (bd81b05d)";
|
|
3
|
+
export var GIT_SHA = "bd81b05d";
|
|
4
4
|
export var THEME = "open-source-visual-refresh";
|
|
5
5
|
export var SYSTEM = "core";
|
|
6
6
|
export var ALWAYS_VISUAL_REFRESH = true;
|
|
@@ -162,6 +162,14 @@ export interface FeatureNotificationsPayload<T> {
|
|
|
162
162
|
* Should return a dictionary mapping feature IDs to their release date strings.
|
|
163
163
|
*/
|
|
164
164
|
__retrieveFeatureNotifications?: RetrieveFeatureNotifications;
|
|
165
|
+
i18nStrings?: {
|
|
166
|
+
titleText?: string;
|
|
167
|
+
viewAllText?: string;
|
|
168
|
+
closeButtonAriaLabel?: string;
|
|
169
|
+
contentAriaLabel?: string;
|
|
170
|
+
triggerButtonAriaLabel?: string;
|
|
171
|
+
resizeHandleAriaLabel?: string;
|
|
172
|
+
};
|
|
165
173
|
}
|
|
166
174
|
export type FeatureNotificationsPayloadPublic<T> = Omit<FeatureNotificationsPayload<T>, '__persistFeatureNotifications' | '__retrieveFeatureNotifications'>;
|
|
167
175
|
export type RegisterDrawerMessage = Message<'registerLeftDrawer' | 'registerBottomDrawer', DrawerPayload>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/widget/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,UAAU,OAAO,CAAC,IAAI,EAAE,OAAO;IAC7B,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,KAAK,sBAAsB,GAAG,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAC;AAE/E,UAAU,mBAAmB;IAC3B,kBAAkB,EAAE,sBAAsB,CAAC;CAC5C;AAED,UA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a,GAAG,eAAe,CAAC,CAAC,CACpG,CAAC;AACF,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,YAAY,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AACtE,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,aAAa,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AACxE,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AACxF,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAC1E,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AACD,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,6BAA6B,CAAC;CACrC;AACD,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,2BAA2B,CAAC;CACnC;AAED,MAAM,MAAM,sBAAsB,CAAC,CAAC,GAAG,OAAO,IAC1C,yBAAyB,GACzB,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,GACnB,mBAAmB,GACnB,uBAAuB,GACvB,mCAAmC,CAAC,CAAC,CAAC,GACtC,2BAA2B,GAC3B,yBAAyB,CAAC;AAE9B,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,qBAAqB,GAAG,mCAAmC,CAAC,CAAC,CAAC,CAAC;AAE/F,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/widget/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ButtonGroupProps, ItemRuntime } from '../../../button-group/interfaces';\nimport { NonCancelableEventHandler } from '../../events';\n\ninterface Message<Type, Payload> {\n type: Type;\n payload: Payload;\n}\n\ntype DrawerVisibilityChange = (callback: (isVisible: boolean) => void) => void;\n\ninterface MountContentContext {\n onVisibilityChange: DrawerVisibilityChange;\n}\n\ninterface DrawerStateChangeParams {\n isOpen: boolean;\n initiatedByUserAction?: boolean;\n}\n\nexport interface DrawerPayload {\n id: string;\n ariaLabels: {\n content?: string;\n closeButton?: string;\n triggerButton?: string;\n resizeHandle?: string;\n resizeHandleTooltipText?: string;\n expandedModeButton?: string;\n exitExpandedModeButton?: string;\n };\n isExpandable?: boolean;\n resizable?: boolean;\n defaultSize?: number;\n onResize?: NonCancelableEventHandler<{ size: number; id: string }>;\n defaultActive?: boolean;\n trigger?: {\n iconSvg?: string;\n customIcon?: string;\n };\n exitExpandedModeTrigger?: {\n customIcon?: string;\n };\n mountContent: (container: HTMLElement, mountContext: MountContentContext) => void;\n unmountContent: (container: HTMLElement) => void;\n preserveInactiveContent?: boolean;\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n mountHeader?: (container: HTMLElement) => void;\n unmountHeader?: (container: HTMLElement) => void;\n headerActions?: ReadonlyArray<ItemRuntime>;\n onHeaderActionClick?: NonCancelableEventHandler<ButtonGroupProps.ItemClickDetails>;\n onToggleFocusMode?: NonCancelableEventHandler<{ isExpanded: boolean }>;\n position?: 'side' | 'bottom';\n}\n\ntype Destructor = () => void;\nexport type MountContentPart<T> = (container: HTMLElement, data: T) => Destructor | void;\n\n/**\n * Describes a single feature entry in the notification drawer.\n *\n * The generic type `T` determines how feature text content is provided:\n * - When `T` is `string`, the values are rendered as plain text.\n * - When `T` is `ReactNode`, you must also provide `mountItem` on the parent\n * `FeatureNotificationsPayload` so the framework can mount the React content\n * into the DOM container.\n */\nexport interface Feature<T> {\n /** Unique identifier used for persistence tracking (seen/unseen state) and list keying. */\n id: string;\n /** Primary title displayed as the feature heading in both the notification drawer and the feature prompt popover. */\n header: T;\n /** Descriptive body rendered below the header in the notification drawer and the feature prompt popover. */\n content: T;\n /** Optional category label rendered between the release date and the content in the notification drawer. */\n contentCategory?: T;\n /** Publication date of the feature. Used for default filtering (last 90 days), descending sort order, and display formatting. */\n releaseDate: Date;\n}\n\nexport interface FeatureNotificationsPersistenceConfig {\n uniqueKey: string;\n}\n\ntype FeatureId = string;\ntype FeatureReleaseDateString = string;\nexport type PersistedFeaturesDict = Record<FeatureId, FeatureReleaseDateString>;\nexport type PersistFeatureNotifications = (\n persistenceConfig: FeatureNotificationsPersistenceConfig,\n value: PersistedFeaturesDict\n) => Promise<void>;\nexport type RetrieveFeatureNotifications = (\n persistenceConfig: FeatureNotificationsPersistenceConfig\n) => Promise<PersistedFeaturesDict>;\n\nexport interface FeatureNotificationsPayload<T> {\n /**\n * Unique identifier for the feature notifications.\n */\n id: string;\n /**\n * When set to `true`, prevents the feature prompt from automatically appearing\n * when unseen features are detected during registration. The prompt can still\n * be shown programmatically via the `showFeaturePromptIfPossible` message.\n *\n * @default false\n */\n suppressFeaturePrompt?: boolean;\n /**\n * List of features to display in the notification drawer. Each feature is filtered\n * by `filterFeatures` (or a default 90-day recency filter), sorted by `releaseDate`\n * in descending order, and tracked for seen/unseen state via persistence. The latest\n * unseen feature is used to populate the feature prompt, and opening the drawer marks\n * all features as seen.\n */\n features: Array<Feature<T>>;\n /**\n * Mounting function used to render each feature's `header`, `content`, and\n * `contentCategory` values into the DOM. Required when `T` is `ReactNode`\n * (or any non-string type) so the framework can mount the content into the\n * provided container element. When `T` is `string`, this can be omitted and\n * values are rendered as plain text.\n *\n * The function receives the target `container` element and the `data` value\n * (one of the feature's text fields), and should return an optional destructor\n * that will be called on unmount to clean up resources (e.g. `root.unmount()`).\n *\n * @example\n * ```ts\n * import { createRoot } from 'react-dom/client';\n *\n * mountItem: (container, data) => {\n * const root = createRoot(container);\n * root.render(data);\n * return () => root.unmount();\n * }\n * ```\n */\n mountItem?: MountContentPart<T>;\n /**\n * Optional URL rendered as a \"View all feature releases\" link at the bottom of the notification\n * drawer, allowing users to navigate to a dedicated page with the full list of\n * features.\n */\n featuresPageLink?: string;\n /**\n * Optional predicate to control which features are displayed. Applied to each\n * feature before sorting. When omitted, a default filter is used that only\n * keeps features with a `releaseDate` within the last 90 days.\n */\n filterFeatures?: (item: Feature<T>) => boolean;\n /**\n * Configuration for persisting seen/unseen state of features. The `uniqueKey`\n * is used as the storage key when saving and retrieving which features the user\n * has already viewed. When omitted, a default key (`'awsui-feature-notifications'`)\n * is used.\n */\n persistenceConfig?: FeatureNotificationsPersistenceConfig;\n /**\n * @internal\n * Optional override for saving the seen/unseen state of features. When provided,\n * this function is called instead of the built-in persistence mechanism when the\n * user opens the notification drawer and all features are marked as seen.\n * Receives the `persistenceConfig` and a dictionary mapping feature IDs to their\n * release date strings.\n */\n __persistFeatureNotifications?: PersistFeatureNotifications;\n /**\n * @internal\n * Optional override for retrieving the previously persisted seen/unseen state of\n * features. When provided, this function is called instead of the built-in retrieval\n * mechanism during registration to determine which features the user has already viewed.\n * Should return a dictionary mapping feature IDs to their release date strings.\n */\n __retrieveFeatureNotifications?: RetrieveFeatureNotifications;\n}\n\nexport type FeatureNotificationsPayloadPublic<T> = Omit<\n FeatureNotificationsPayload<T>,\n '__persistFeatureNotifications' | '__retrieveFeatureNotifications'\n>;\n\nexport type RegisterDrawerMessage = Message<'registerLeftDrawer' | 'registerBottomDrawer', DrawerPayload>;\nexport type RegisterFeatureNotificationsMessage<T> = Message<\n 'registerFeatureNotifications',\n FeatureNotificationsPayload<T>\n>;\nexport type UpdateDrawerConfigMessage = Message<\n 'updateDrawerConfig',\n Pick<DrawerPayload, 'id'> &\n Partial<Omit<DrawerPayload, 'mountContent' | 'unmountContent' | 'mountHeader' | 'unmountHeader'>>\n>;\nexport type OpenDrawerMessage = Message<'openDrawer', { id: string }>;\nexport type CloseDrawerMessage = Message<'closeDrawer', { id: string }>;\nexport type ResizeDrawerMessage = Message<'resizeDrawer', { id: string; size: number }>;\nexport type ExpandDrawerMessage = Message<'expandDrawer', { id: string }>;\nexport interface ExitExpandedModeMessage {\n type: 'exitExpandedMode';\n}\nexport interface ShowFeaturePromptIfPossible {\n type: 'showFeaturePromptIfPossible';\n}\nexport interface ClearFeatureNotifications {\n type: 'clearFeatureNotifications';\n}\n\nexport type AppLayoutUpdateMessage<T = unknown> =\n | UpdateDrawerConfigMessage\n | OpenDrawerMessage\n | CloseDrawerMessage\n | ResizeDrawerMessage\n | ExpandDrawerMessage\n | ExitExpandedModeMessage\n | RegisterFeatureNotificationsMessage<T>\n | ShowFeaturePromptIfPossible\n | ClearFeatureNotifications;\n\nexport type InitialMessage<T> = RegisterDrawerMessage | RegisterFeatureNotificationsMessage<T>;\n\nexport type WidgetMessage<T = unknown> = InitialMessage<T> | AppLayoutUpdateMessage<T>;\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/widget/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ButtonGroupProps, ItemRuntime } from '../../../button-group/interfaces';\nimport { NonCancelableEventHandler } from '../../events';\n\ninterface Message<Type, Payload> {\n type: Type;\n payload: Payload;\n}\n\ntype DrawerVisibilityChange = (callback: (isVisible: boolean) => void) => void;\n\ninterface MountContentContext {\n onVisibilityChange: DrawerVisibilityChange;\n}\n\ninterface DrawerStateChangeParams {\n isOpen: boolean;\n initiatedByUserAction?: boolean;\n}\n\nexport interface DrawerPayload {\n id: string;\n ariaLabels: {\n content?: string;\n closeButton?: string;\n triggerButton?: string;\n resizeHandle?: string;\n resizeHandleTooltipText?: string;\n expandedModeButton?: string;\n exitExpandedModeButton?: string;\n };\n isExpandable?: boolean;\n resizable?: boolean;\n defaultSize?: number;\n onResize?: NonCancelableEventHandler<{ size: number; id: string }>;\n defaultActive?: boolean;\n trigger?: {\n iconSvg?: string;\n customIcon?: string;\n };\n exitExpandedModeTrigger?: {\n customIcon?: string;\n };\n mountContent: (container: HTMLElement, mountContext: MountContentContext) => void;\n unmountContent: (container: HTMLElement) => void;\n preserveInactiveContent?: boolean;\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n mountHeader?: (container: HTMLElement) => void;\n unmountHeader?: (container: HTMLElement) => void;\n headerActions?: ReadonlyArray<ItemRuntime>;\n onHeaderActionClick?: NonCancelableEventHandler<ButtonGroupProps.ItemClickDetails>;\n onToggleFocusMode?: NonCancelableEventHandler<{ isExpanded: boolean }>;\n position?: 'side' | 'bottom';\n}\n\ntype Destructor = () => void;\nexport type MountContentPart<T> = (container: HTMLElement, data: T) => Destructor | void;\n\n/**\n * Describes a single feature entry in the notification drawer.\n *\n * The generic type `T` determines how feature text content is provided:\n * - When `T` is `string`, the values are rendered as plain text.\n * - When `T` is `ReactNode`, you must also provide `mountItem` on the parent\n * `FeatureNotificationsPayload` so the framework can mount the React content\n * into the DOM container.\n */\nexport interface Feature<T> {\n /** Unique identifier used for persistence tracking (seen/unseen state) and list keying. */\n id: string;\n /** Primary title displayed as the feature heading in both the notification drawer and the feature prompt popover. */\n header: T;\n /** Descriptive body rendered below the header in the notification drawer and the feature prompt popover. */\n content: T;\n /** Optional category label rendered between the release date and the content in the notification drawer. */\n contentCategory?: T;\n /** Publication date of the feature. Used for default filtering (last 90 days), descending sort order, and display formatting. */\n releaseDate: Date;\n}\n\nexport interface FeatureNotificationsPersistenceConfig {\n uniqueKey: string;\n}\n\ntype FeatureId = string;\ntype FeatureReleaseDateString = string;\nexport type PersistedFeaturesDict = Record<FeatureId, FeatureReleaseDateString>;\nexport type PersistFeatureNotifications = (\n persistenceConfig: FeatureNotificationsPersistenceConfig,\n value: PersistedFeaturesDict\n) => Promise<void>;\nexport type RetrieveFeatureNotifications = (\n persistenceConfig: FeatureNotificationsPersistenceConfig\n) => Promise<PersistedFeaturesDict>;\n\nexport interface FeatureNotificationsPayload<T> {\n /**\n * Unique identifier for the feature notifications.\n */\n id: string;\n /**\n * When set to `true`, prevents the feature prompt from automatically appearing\n * when unseen features are detected during registration. The prompt can still\n * be shown programmatically via the `showFeaturePromptIfPossible` message.\n *\n * @default false\n */\n suppressFeaturePrompt?: boolean;\n /**\n * List of features to display in the notification drawer. Each feature is filtered\n * by `filterFeatures` (or a default 90-day recency filter), sorted by `releaseDate`\n * in descending order, and tracked for seen/unseen state via persistence. The latest\n * unseen feature is used to populate the feature prompt, and opening the drawer marks\n * all features as seen.\n */\n features: Array<Feature<T>>;\n /**\n * Mounting function used to render each feature's `header`, `content`, and\n * `contentCategory` values into the DOM. Required when `T` is `ReactNode`\n * (or any non-string type) so the framework can mount the content into the\n * provided container element. When `T` is `string`, this can be omitted and\n * values are rendered as plain text.\n *\n * The function receives the target `container` element and the `data` value\n * (one of the feature's text fields), and should return an optional destructor\n * that will be called on unmount to clean up resources (e.g. `root.unmount()`).\n *\n * @example\n * ```ts\n * import { createRoot } from 'react-dom/client';\n *\n * mountItem: (container, data) => {\n * const root = createRoot(container);\n * root.render(data);\n * return () => root.unmount();\n * }\n * ```\n */\n mountItem?: MountContentPart<T>;\n /**\n * Optional URL rendered as a \"View all feature releases\" link at the bottom of the notification\n * drawer, allowing users to navigate to a dedicated page with the full list of\n * features.\n */\n featuresPageLink?: string;\n /**\n * Optional predicate to control which features are displayed. Applied to each\n * feature before sorting. When omitted, a default filter is used that only\n * keeps features with a `releaseDate` within the last 90 days.\n */\n filterFeatures?: (item: Feature<T>) => boolean;\n /**\n * Configuration for persisting seen/unseen state of features. The `uniqueKey`\n * is used as the storage key when saving and retrieving which features the user\n * has already viewed. When omitted, a default key (`'awsui-feature-notifications'`)\n * is used.\n */\n persistenceConfig?: FeatureNotificationsPersistenceConfig;\n /**\n * @internal\n * Optional override for saving the seen/unseen state of features. When provided,\n * this function is called instead of the built-in persistence mechanism when the\n * user opens the notification drawer and all features are marked as seen.\n * Receives the `persistenceConfig` and a dictionary mapping feature IDs to their\n * release date strings.\n */\n __persistFeatureNotifications?: PersistFeatureNotifications;\n /**\n * @internal\n * Optional override for retrieving the previously persisted seen/unseen state of\n * features. When provided, this function is called instead of the built-in retrieval\n * mechanism during registration to determine which features the user has already viewed.\n * Should return a dictionary mapping feature IDs to their release date strings.\n */\n __retrieveFeatureNotifications?: RetrieveFeatureNotifications;\n\n i18nStrings?: {\n titleText?: string;\n viewAllText?: string;\n closeButtonAriaLabel?: string;\n contentAriaLabel?: string;\n triggerButtonAriaLabel?: string;\n resizeHandleAriaLabel?: string;\n };\n}\n\nexport type FeatureNotificationsPayloadPublic<T> = Omit<\n FeatureNotificationsPayload<T>,\n '__persistFeatureNotifications' | '__retrieveFeatureNotifications'\n>;\n\nexport type RegisterDrawerMessage = Message<'registerLeftDrawer' | 'registerBottomDrawer', DrawerPayload>;\nexport type RegisterFeatureNotificationsMessage<T> = Message<\n 'registerFeatureNotifications',\n FeatureNotificationsPayload<T>\n>;\nexport type UpdateDrawerConfigMessage = Message<\n 'updateDrawerConfig',\n Pick<DrawerPayload, 'id'> &\n Partial<Omit<DrawerPayload, 'mountContent' | 'unmountContent' | 'mountHeader' | 'unmountHeader'>>\n>;\nexport type OpenDrawerMessage = Message<'openDrawer', { id: string }>;\nexport type CloseDrawerMessage = Message<'closeDrawer', { id: string }>;\nexport type ResizeDrawerMessage = Message<'resizeDrawer', { id: string; size: number }>;\nexport type ExpandDrawerMessage = Message<'expandDrawer', { id: string }>;\nexport interface ExitExpandedModeMessage {\n type: 'exitExpandedMode';\n}\nexport interface ShowFeaturePromptIfPossible {\n type: 'showFeaturePromptIfPossible';\n}\nexport interface ClearFeatureNotifications {\n type: 'clearFeatureNotifications';\n}\n\nexport type AppLayoutUpdateMessage<T = unknown> =\n | UpdateDrawerConfigMessage\n | OpenDrawerMessage\n | CloseDrawerMessage\n | ResizeDrawerMessage\n | ExpandDrawerMessage\n | ExitExpandedModeMessage\n | RegisterFeatureNotificationsMessage<T>\n | ShowFeaturePromptIfPossible\n | ClearFeatureNotifications;\n\nexport type InitialMessage<T> = RegisterDrawerMessage | RegisterFeatureNotificationsMessage<T>;\n\nexport type WidgetMessage<T = unknown> = InitialMessage<T> | AppLayoutUpdateMessage<T>;\n"]}
|