@cloudscape-design/components-themeable 3.0.164 → 3.0.166

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.
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "1dd8e744b1023d79340bcd41bdc2c46df9e8783f"
2
+ "commit": "7f4d906d5da45024d8614a4c6f6260a54626c264"
3
3
  }
@@ -13,6 +13,7 @@ export interface AppLayoutProps extends BaseComponentProps {
13
13
  disableContentPaddings?: boolean;
14
14
  /**
15
15
  * Activates a backwards-compatibility mode for applications with non-fixed headers and footers.
16
+ * @deprecated This layout is being phased out and may miss some features
16
17
  */
17
18
  disableBodyScroll?: boolean;
18
19
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/app-layout/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,cAAe,SAAQ,kBAAkB;IACxD;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC;IAEzC;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IA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,sBAAsB;QACrC,IAAI,EAAE,MAAM,CAAC;KACd;IAED,UAAiB,qBAAqB;QACpC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;KAC7B;IAGD,KAAY,kBAAkB,GAAG,MAAM,GAAG,QAAQ,CAAC;CACpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/app-layout/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface AppLayoutProps extends BaseComponentProps {\n /**\n * Determines the default behavior of the component based on some predefined page layouts.\n * Individual properties will always take precedence over the default coming from the content type.\n */\n contentType?: AppLayoutProps.ContentType;\n\n /**\n * If `true`, disables outer paddings for the content slot.\n */\n disableContentPaddings?: boolean;\n\n /**\n * Activates a backwards-compatibility mode for applications with non-fixed headers and footers.\n */\n disableBodyScroll?: boolean;\n\n /**\n * State of the navigation drawer.\n */\n navigationOpen?: boolean;\n\n /**\n * Navigation drawer width in pixels.\n */\n navigationWidth?: number;\n\n /**\n * If `true`, the navigation drawer is not displayed at all.\n */\n navigationHide?: boolean;\n\n /**\n * State of the tools drawer.\n */\n toolsOpen?: boolean;\n\n /**\n * If `true`, the tools drawer is not displayed at all.\n */\n toolsHide?: boolean;\n\n /**\n * Tools drawer width in pixels.\n */\n toolsWidth?: number;\n\n /**\n * Maximum main content panel width in pixels.\n *\n * If set to `Number.MAX_VALUE`, the main content panel will occupy the full available width.\n */\n maxContentWidth?: number;\n\n /**\n * Minimum main content panel width in pixels.\n */\n minContentWidth?: number;\n\n /**\n * If true, the notification slot is rendered above the scrollable\n * content area so it is always visible.\n *\n * Note that sticky notifications are not supported in Internet Explorer.\n */\n stickyNotifications?: boolean;\n\n /**\n * CSS selector for the application header.\n */\n headerSelector?: string;\n\n /**\n * CSS selector for the application footer.\n */\n footerSelector?: string;\n\n /**\n * Aria labels for the drawer operating buttons. Use this property to ensure accessibility.\n *\n * * `navigation` (string) - Label for the landmark that wraps the navigation drawer.\n * * `navigationClose` (string) - Label for the button that closes the navigation drawer.\n * * `navigationToggle` (string) - Label for the button that opens the navigation drawer.\n * * `notification` (string) - Label for the region that contains notification messages.\n * * `tools` (string) - Label for the landmark that wraps the tools drawer.\n * * `toolsClose` (string) - Label for the button that closes the tools drawer.\n * * `toolsToggle` (string) - Label for the button that opens the tools drawer.\n *\n * Example:\n * ```\n * {\n * navigation: \"Navigation drawer\",\n * navigationClose: \"Close navigation drawer\",\n * navigationToggle: \"Open navigation drawer\",\n * notifications: \"Notifications\",\n * tools: \"Help panel\",\n * toolsClose: \"Close help panel\",\n * toolsToggle: \"Open help panel\"\n * }\n * ```\n */\n ariaLabels?: AppLayoutProps.Labels;\n\n /**\n * Navigation drawer.\n */\n navigation?: React.ReactNode;\n\n /**\n * Top area of the page content.\n * **Deprecated**, replaced by the `header` slot of the [content layout](/components/content-layout/) component.\n * @visualrefresh\n */\n contentHeader?: React.ReactNode;\n\n /**\n * Disables overlap between `contentHeader` and `content` slots.\n * **Deprecated**, replaced by the `disableOverlap` property of the [content layout](/components/content-layout/) component.\n * @visualrefresh\n */\n disableContentHeaderOverlap?: boolean;\n\n /**\n * Main content.\n */\n content?: React.ReactNode;\n\n /**\n * Tools drawer.\n */\n tools?: React.ReactNode;\n\n /**\n * Displayed on top of the main content in the scrollable area.\n *\n * Conceived to contain notifications (flash messages).\n */\n notifications?: React.ReactNode;\n\n /**\n * Use this slot to add the [breadcrumb group component](/components/breadcrumb-group/) to the app layout.\n */\n breadcrumbs?: React.ReactNode;\n\n /**\n * Fired when the navigation drawer is toggled.\n */\n onNavigationChange?: NonCancelableEventHandler<AppLayoutProps.ChangeDetail>;\n\n /**\n * Fired when the tools drawer is toggled.\n */\n onToolsChange?: NonCancelableEventHandler<AppLayoutProps.ChangeDetail>;\n /**\n * Use this slot to add the [split panel component](/components/split-panel/) to the app layout.\n */\n splitPanel?: React.ReactNode;\n\n /**\n * The size of the split panel in pixels.\n */\n splitPanelSize?: number;\n\n /**\n * State of the split panel.\n */\n splitPanelOpen?: boolean;\n /**\n * Controls the split panel preferences.\n *\n * By default, the preference is `{ position: 'bottom' }`\n */\n splitPanelPreferences?: AppLayoutProps.SplitPanelPreferences;\n /**\n * Fired when the split panel is resized.\n */\n onSplitPanelResize?: NonCancelableEventHandler<AppLayoutProps.SplitPanelResizeDetail>;\n /**\n * Fired when the split panel is toggled.\n */\n onSplitPanelToggle?: NonCancelableEventHandler<AppLayoutProps.ChangeDetail>;\n /**\n * Fired when the split panel preferences change.\n */\n onSplitPanelPreferencesChange?: NonCancelableEventHandler<AppLayoutProps.SplitPanelPreferences>;\n}\n\nexport namespace AppLayoutProps {\n export type ContentType = 'default' | 'form' | 'table' | 'cards' | 'wizard';\n\n export interface Ref {\n /**\n * Manually closes the navigation drawer if it is necessary for the current\n * viewport size.\n */\n closeNavigationIfNecessary(): void;\n\n /**\n * Opens the tools panel if it is not already open. Note that it is preferable\n * to control the state by listening to `toolsChange` and providing `toolsOpen`.\n */\n openTools(): void;\n\n /**\n * Focuses the tools panel if it is open. Use this to focus the tools panel\n * after changing the content, for example when clicking on an 'info' link while\n * the panel is already open.\n */\n focusToolsClose(): void;\n }\n\n export interface Labels {\n notifications?: string;\n\n navigation?: string;\n navigationToggle?: string;\n navigationClose?: string;\n\n tools?: string;\n toolsToggle?: string;\n toolsClose?: string;\n }\n\n export interface ChangeDetail {\n open: boolean;\n }\n\n export interface SplitPanelResizeDetail {\n size: number;\n }\n\n export interface SplitPanelPreferences {\n position: 'side' | 'bottom';\n }\n // Duplicated the positions because using this definition in SplitPanelPreferences would display\n // 'AppLayoutProps.SplitPanelPosition' on the API docs instead of the string values.\n export type SplitPanelPosition = 'side' | 'bottom';\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/app-layout/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface AppLayoutProps extends BaseComponentProps {\n /**\n * Determines the default behavior of the component based on some predefined page layouts.\n * Individual properties will always take precedence over the default coming from the content type.\n */\n contentType?: AppLayoutProps.ContentType;\n\n /**\n * If `true`, disables outer paddings for the content slot.\n */\n disableContentPaddings?: boolean;\n\n /**\n * Activates a backwards-compatibility mode for applications with non-fixed headers and footers.\n * @deprecated This layout is being phased out and may miss some features\n */\n disableBodyScroll?: boolean;\n\n /**\n * State of the navigation drawer.\n */\n navigationOpen?: boolean;\n\n /**\n * Navigation drawer width in pixels.\n */\n navigationWidth?: number;\n\n /**\n * If `true`, the navigation drawer is not displayed at all.\n */\n navigationHide?: boolean;\n\n /**\n * State of the tools drawer.\n */\n toolsOpen?: boolean;\n\n /**\n * If `true`, the tools drawer is not displayed at all.\n */\n toolsHide?: boolean;\n\n /**\n * Tools drawer width in pixels.\n */\n toolsWidth?: number;\n\n /**\n * Maximum main content panel width in pixels.\n *\n * If set to `Number.MAX_VALUE`, the main content panel will occupy the full available width.\n */\n maxContentWidth?: number;\n\n /**\n * Minimum main content panel width in pixels.\n */\n minContentWidth?: number;\n\n /**\n * If true, the notification slot is rendered above the scrollable\n * content area so it is always visible.\n *\n * Note that sticky notifications are not supported in Internet Explorer.\n */\n stickyNotifications?: boolean;\n\n /**\n * CSS selector for the application header.\n */\n headerSelector?: string;\n\n /**\n * CSS selector for the application footer.\n */\n footerSelector?: string;\n\n /**\n * Aria labels for the drawer operating buttons. Use this property to ensure accessibility.\n *\n * * `navigation` (string) - Label for the landmark that wraps the navigation drawer.\n * * `navigationClose` (string) - Label for the button that closes the navigation drawer.\n * * `navigationToggle` (string) - Label for the button that opens the navigation drawer.\n * * `notification` (string) - Label for the region that contains notification messages.\n * * `tools` (string) - Label for the landmark that wraps the tools drawer.\n * * `toolsClose` (string) - Label for the button that closes the tools drawer.\n * * `toolsToggle` (string) - Label for the button that opens the tools drawer.\n *\n * Example:\n * ```\n * {\n * navigation: \"Navigation drawer\",\n * navigationClose: \"Close navigation drawer\",\n * navigationToggle: \"Open navigation drawer\",\n * notifications: \"Notifications\",\n * tools: \"Help panel\",\n * toolsClose: \"Close help panel\",\n * toolsToggle: \"Open help panel\"\n * }\n * ```\n */\n ariaLabels?: AppLayoutProps.Labels;\n\n /**\n * Navigation drawer.\n */\n navigation?: React.ReactNode;\n\n /**\n * Top area of the page content.\n * **Deprecated**, replaced by the `header` slot of the [content layout](/components/content-layout/) component.\n * @visualrefresh\n */\n contentHeader?: React.ReactNode;\n\n /**\n * Disables overlap between `contentHeader` and `content` slots.\n * **Deprecated**, replaced by the `disableOverlap` property of the [content layout](/components/content-layout/) component.\n * @visualrefresh\n */\n disableContentHeaderOverlap?: boolean;\n\n /**\n * Main content.\n */\n content?: React.ReactNode;\n\n /**\n * Tools drawer.\n */\n tools?: React.ReactNode;\n\n /**\n * Displayed on top of the main content in the scrollable area.\n *\n * Conceived to contain notifications (flash messages).\n */\n notifications?: React.ReactNode;\n\n /**\n * Use this slot to add the [breadcrumb group component](/components/breadcrumb-group/) to the app layout.\n */\n breadcrumbs?: React.ReactNode;\n\n /**\n * Fired when the navigation drawer is toggled.\n */\n onNavigationChange?: NonCancelableEventHandler<AppLayoutProps.ChangeDetail>;\n\n /**\n * Fired when the tools drawer is toggled.\n */\n onToolsChange?: NonCancelableEventHandler<AppLayoutProps.ChangeDetail>;\n /**\n * Use this slot to add the [split panel component](/components/split-panel/) to the app layout.\n */\n splitPanel?: React.ReactNode;\n\n /**\n * The size of the split panel in pixels.\n */\n splitPanelSize?: number;\n\n /**\n * State of the split panel.\n */\n splitPanelOpen?: boolean;\n /**\n * Controls the split panel preferences.\n *\n * By default, the preference is `{ position: 'bottom' }`\n */\n splitPanelPreferences?: AppLayoutProps.SplitPanelPreferences;\n /**\n * Fired when the split panel is resized.\n */\n onSplitPanelResize?: NonCancelableEventHandler<AppLayoutProps.SplitPanelResizeDetail>;\n /**\n * Fired when the split panel is toggled.\n */\n onSplitPanelToggle?: NonCancelableEventHandler<AppLayoutProps.ChangeDetail>;\n /**\n * Fired when the split panel preferences change.\n */\n onSplitPanelPreferencesChange?: NonCancelableEventHandler<AppLayoutProps.SplitPanelPreferences>;\n}\n\nexport namespace AppLayoutProps {\n export type ContentType = 'default' | 'form' | 'table' | 'cards' | 'wizard';\n\n export interface Ref {\n /**\n * Manually closes the navigation drawer if it is necessary for the current\n * viewport size.\n */\n closeNavigationIfNecessary(): void;\n\n /**\n * Opens the tools panel if it is not already open. Note that it is preferable\n * to control the state by listening to `toolsChange` and providing `toolsOpen`.\n */\n openTools(): void;\n\n /**\n * Focuses the tools panel if it is open. Use this to focus the tools panel\n * after changing the content, for example when clicking on an 'info' link while\n * the panel is already open.\n */\n focusToolsClose(): void;\n }\n\n export interface Labels {\n notifications?: string;\n\n navigation?: string;\n navigationToggle?: string;\n navigationClose?: string;\n\n tools?: string;\n toolsToggle?: string;\n toolsClose?: string;\n }\n\n export interface ChangeDetail {\n open: boolean;\n }\n\n export interface SplitPanelResizeDetail {\n size: number;\n }\n\n export interface SplitPanelPreferences {\n position: 'side' | 'bottom';\n }\n // Duplicated the positions because using this definition in SplitPanelPreferences would display\n // 'AppLayoutProps.SplitPanelPosition' on the API docs instead of the string values.\n export type SplitPanelPosition = 'side' | 'bottom';\n}\n"]}
@@ -1,5 +1,5 @@
1
1
 
2
- export var PACKAGE_VERSION = '3.0.0 (1dd8e74)';
2
+ export var PACKAGE_VERSION = '3.0.0 (7f4d906)';
3
3
  export var THEME = 'open-source-visual-refresh';
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-telemetry/index.ts"],"names":[],"mappings":"AAKA,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,QAWjD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-telemetry/index.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,QAcjD"}
@@ -1,9 +1,13 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { useEffect } from 'react';
4
+ import { THEME } from '../../environment';
4
5
  import { Metrics } from '../../metrics';
6
+ import { useVisualRefresh } from '../use-visual-mode';
5
7
  export function useTelemetry(componentName) {
8
+ var isVisualRefresh = useVisualRefresh();
6
9
  useEffect(function () {
10
+ Metrics.initMetrics(isVisualRefresh ? 'vr' : THEME);
7
11
  if (typeof window !== 'undefined') {
8
12
  Metrics.sendMetricOnce('awsui-viewport-width', window.innerWidth || 0);
9
13
  Metrics.sendMetricOnce('awsui-viewport-height', window.innerHeight || 0);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-telemetry/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,UAAU,YAAY,CAAC,aAAqB;IAChD,SAAS,CAAC;QACR,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,OAAO,CAAC,cAAc,CAAC,sBAAsB,EAAE,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;YACvE,OAAO,CAAC,cAAc,CAAC,uBAAuB,EAAE,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC;SAC1E;QACD,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC7B,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;QACtD,4GAA4G;QAC5G,uDAAuD;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useEffect } from 'react';\nimport { Metrics } from '../../metrics';\n\nexport function useTelemetry(componentName: string) {\n useEffect(() => {\n if (typeof window !== 'undefined') {\n Metrics.sendMetricOnce('awsui-viewport-width', window.innerWidth || 0);\n Metrics.sendMetricOnce('awsui-viewport-height', window.innerHeight || 0);\n }\n Metrics.logComponentLoaded();\n Metrics.logComponentUsed(componentName.toLowerCase());\n // Components do not change the name dynamically. Explicit empty array to prevent accidential double metrics\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-telemetry/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,UAAU,YAAY,CAAC,aAAqB;IAChD,IAAM,eAAe,GAAG,gBAAgB,EAAE,CAAC;IAE3C,SAAS,CAAC;QACR,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACpD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,OAAO,CAAC,cAAc,CAAC,sBAAsB,EAAE,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;YACvE,OAAO,CAAC,cAAc,CAAC,uBAAuB,EAAE,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC;SAC1E;QACD,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC7B,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;QACtD,4GAA4G;QAC5G,uDAAuD;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useEffect } from 'react';\nimport { THEME } from '../../environment';\nimport { Metrics } from '../../metrics';\nimport { useVisualRefresh } from '../use-visual-mode';\n\nexport function useTelemetry(componentName: string) {\n const isVisualRefresh = useVisualRefresh();\n\n useEffect(() => {\n Metrics.initMetrics(isVisualRefresh ? 'vr' : THEME);\n if (typeof window !== 'undefined') {\n Metrics.sendMetricOnce('awsui-viewport-width', window.innerWidth || 0);\n Metrics.sendMetricOnce('awsui-viewport-height', window.innerHeight || 0);\n }\n Metrics.logComponentLoaded();\n Metrics.logComponentUsed(componentName.toLowerCase());\n // Components do not change the name dynamically. Explicit empty array to prevent accidential double metrics\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n}\n"]}
@@ -10,7 +10,7 @@ export interface MetricsV2EventItem {
10
10
  eventValue?: string | Record<string, string | number | boolean>;
11
11
  }
12
12
  export declare const Metrics: {
13
- initMetrics(fwk: string): void;
13
+ initMetrics(theme: string): void;
14
14
  /**
15
15
  * Calls Console Platform's client logging JS API with provided metric name, value, and detail.
16
16
  * Does nothing if Console Platform client logging JS is not present in page.
@@ -20,7 +20,7 @@ export declare const Metrics: {
20
20
  * Calls Console Platform's client v2 logging JS API with provided metric name and detail.
21
21
  * Does nothing if Console Platform client logging JS is not present in page.
22
22
  */
23
- sendPanoramaMetric(metricName: string, metric: MetricsV2EventItem): void;
23
+ sendPanoramaMetric(metric: MetricsV2EventItem): void;
24
24
  sendMetricObject(metric: MetricsLogItem, value: number): void;
25
25
  sendMetricObjectOnce(metric: MetricsLogItem, value: number): void;
26
26
  sendMetricOnce(metricName: string, value: number, detail?: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../src/internal/metrics.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IACjE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CACjE;AA2FD,eAAO,MAAM,OAAO;qBACD,MAAM;IAIvB;;;OAGG;2BACoB,MAAM,SAAS,MAAM,WAAW,MAAM,GAAG,IAAI;IAepE;;;OAGG;mCAC4B,MAAM,UAAU,kBAAkB,GAAG,IAAI;6BAwB/C,cAAc,SAAS,MAAM,GAAG,IAAI;iCAIhC,cAAc,SAAS,MAAM,GAAG,IAAI;+BAYtC,MAAM,SAAS,MAAM,WAAW,MAAM,GAAG,IAAI;;oCA4BxC,MAAM;CAUvC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;iDA/KsB,MAAM;wCAIf,MAAM,WAAW,MAAM;CAmLjE,CAAC"}
1
+ {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../src/internal/metrics.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IACjE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CACjE;AA8FD,eAAO,MAAM,OAAO;uBACC,MAAM;IAIzB;;;OAGG;2BACoB,MAAM,SAAS,MAAM,WAAW,MAAM,GAAG,IAAI;IAqBpE;;;OAGG;+BACwB,kBAAkB,GAAG,IAAI;6BAoB3B,cAAc,SAAS,MAAM,GAAG,IAAI;iCAIhC,cAAc,SAAS,MAAM,GAAG,IAAI;+BAYtC,MAAM,SAAS,MAAM,WAAW,MAAM,GAAG,IAAI;;oCA4BxC,MAAM;CAUvC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;iDA3KsB,MAAM;wCAIf,MAAM,WAAW,MAAM;CA+KjE,CAAC"}
@@ -1,8 +1,15 @@
1
1
  import { __assign } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { THEME, PACKAGE_VERSION } from './environment';
4
+ import { PACKAGE_VERSION } from './environment';
5
5
  var oneTimeMetrics = {};
6
+ // In case we need to override the theme for VR
7
+ var theme = '';
8
+ function setTheme(newTheme) {
9
+ theme = newTheme;
10
+ }
11
+ // react is the only framework we're using
12
+ var framework = 'react';
6
13
  var buildMetricHash = function (_a) {
7
14
  var source = _a.source, action = _a.action;
8
15
  return ["src".concat(source), "action".concat(action)].join('_');
@@ -23,7 +30,7 @@ var buildMetricDetail = function (_a) {
23
30
  var detailObject = {
24
31
  o: metricOrigin,
25
32
  s: source,
26
- t: THEME,
33
+ t: theme,
27
34
  a: action,
28
35
  f: framework,
29
36
  v: formatMajorVersionForMetricDetail(version)
@@ -32,7 +39,7 @@ var buildMetricDetail = function (_a) {
32
39
  };
33
40
  var buildMetricName = function (_a) {
34
41
  var source = _a.source, version = _a.version;
35
- return ['awsui', source, "".concat(formatVersionForMetricName(THEME, version))].join('_');
42
+ return ['awsui', source, "".concat(formatVersionForMetricName(theme, version))].join('_');
36
43
  };
37
44
  var findPanorama = function (currentWindow) {
38
45
  try {
@@ -66,20 +73,20 @@ var findAWSC = function (currentWindow) {
66
73
  return undefined;
67
74
  }
68
75
  };
69
- // react is the default framework we're logging, for angular we need to set it explicitly
70
- var framework = 'react';
71
- function setFramework(fwk) {
72
- framework = fwk;
73
- }
74
76
  export var Metrics = {
75
- initMetrics: function (fwk) {
76
- setFramework(fwk);
77
+ initMetrics: function (theme) {
78
+ setTheme(theme);
77
79
  },
78
80
  /**
79
81
  * Calls Console Platform's client logging JS API with provided metric name, value, and detail.
80
82
  * Does nothing if Console Platform client logging JS is not present in page.
81
83
  */
82
84
  sendMetric: function (metricName, value, detail) {
85
+ if (!theme) {
86
+ // Metrics need to be initialized first (initMetrics)
87
+ console.error('Metrics need to be initalized first.');
88
+ return;
89
+ }
83
90
  if (!metricName || !/^[a-zA-Z0-9_-]{1,32}$/.test(metricName)) {
84
91
  console.error("Invalid metric name: ".concat(metricName));
85
92
  return;
@@ -97,16 +104,12 @@ export var Metrics = {
97
104
  * Calls Console Platform's client v2 logging JS API with provided metric name and detail.
98
105
  * Does nothing if Console Platform client logging JS is not present in page.
99
106
  */
100
- sendPanoramaMetric: function (metricName, metric) {
101
- if (!metricName || !/^[a-zA-Z0-9_-]{1,32}$/.test(metricName)) {
102
- console.error("Invalid metric name: ".concat(metricName));
103
- return;
104
- }
107
+ sendPanoramaMetric: function (metric) {
105
108
  if (typeof metric.eventDetail === 'object') {
106
109
  metric.eventDetail = JSON.stringify(metric.eventDetail);
107
110
  }
108
111
  if (metric.eventDetail && metric.eventDetail.length > 200) {
109
- console.error("Detail for metric ".concat(metricName, " is too long: ").concat(metric.eventDetail));
112
+ console.error("Detail for metric is too long: ".concat(metric.eventDetail));
110
113
  return;
111
114
  }
112
115
  if (typeof metric.eventValue === 'object') {
@@ -114,7 +117,7 @@ export var Metrics = {
114
117
  }
115
118
  var panorama = findPanorama(window);
116
119
  if (typeof panorama === 'function') {
117
- panorama(metricName, __assign(__assign({}, metric), { timestamp: Date.now() }));
120
+ panorama('trackCustomEvent', __assign(__assign({}, metric), { timestamp: Date.now() }));
118
121
  }
119
122
  },
120
123
  sendMetricObject: function (metric, value) {
@@ -1 +1 @@
1
- {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/internal/metrics.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA0BvD,IAAM,cAAc,GAA4B,EAAE,CAAC;AAEnD,IAAM,eAAe,GAAG,UAAC,EAAkC;QAAhC,MAAM,YAAA,EAAE,MAAM,YAAA;IACvC,OAAO,CAAC,aAAM,MAAM,CAAE,EAAE,gBAAS,MAAM,CAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,IAAM,eAAe,GAAG,UAAC,aAAqB;IAC5C,IAAM,iBAAiB,GAAG,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC7D,OAAO,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACvD,CAAC,CAAC;AAEF,IAAM,iCAAiC,GAAG,UAAC,OAAe;IACxD,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF,IAAM,0BAA0B,GAAG,UAAC,KAAa,EAAE,OAAe;IAChE,OAAO,UAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAG,eAAe,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAE,CAAC;AAC1E,CAAC,CAAC;AAEF,IAAM,iBAAiB,GAA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,CAAC,UAAU,CAAC,EAAE;YAC/B,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACrC,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;SACnC;IACH,CAAC;IAED;;;OAGG;IACH,cAAc,YAAC,UAAkB,EAAE,KAAa,EAAE,MAAe;QAC/D,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE;YAC/B,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;YAC3C,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;SACnC;IACH,CAAC;IAED;;;;OAIG;IACH,kBAAkB;QAChB,IAAI,CAAC,oBAAoB,CACvB;YACE,MAAM,EAAE,YAAY;YACpB,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE,eAAe;SACzB,EACD,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,gBAAgB,YAAC,aAAqB;QACpC,IAAI,CAAC,oBAAoB,CACvB;YACE,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,eAAe;SACzB,EACD,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,IAAM,iBAAiB,GAAG;IAC/B,wBAAwB,EAAE;QACxB,KAAK,IAAM,IAAI,IAAI,cAAc,EAAE;YACjC,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;SAC7B;IACH,CAAC;IACD,iCAAiC,mCAAA;IACjC,0BAA0B,4BAAA;CAC3B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { THEME, PACKAGE_VERSION } from './environment';\n\nexport interface MetricsLogItem {\n source: string;\n action: string;\n version: string;\n}\n\nexport interface MetricsV2EventItem {\n eventType?: string;\n eventContext?: string;\n eventDetail?: string | Record<string, string | number | boolean>;\n eventValue?: string | Record<string, string | number | boolean>;\n}\n\ninterface AWSC {\n Clog: any;\n}\n\ninterface MetricsWindow extends Window {\n AWSC?: AWSC;\n panorama?: any;\n}\n\ndeclare const AWSUI_METRIC_ORIGIN: string | undefined;\n\nconst oneTimeMetrics: Record<string, boolean> = {};\n\nconst buildMetricHash = ({ source, action }: MetricsLogItem): string => {\n return [`src${source}`, `action${action}`].join('_');\n};\n\nconst getMajorVersion = (versionString: string): string => {\n const majorVersionMatch = versionString.match(/^(\\d+\\.\\d+)/);\n return majorVersionMatch ? majorVersionMatch[1] : '';\n};\n\nconst formatMajorVersionForMetricDetail = (version: string) => {\n return version.replace(/\\s/g, '');\n};\n\nconst formatVersionForMetricName = (theme: string, version: string) => {\n return `${theme.charAt(0)}${getMajorVersion(version).replace('.', '')}`;\n};\n\nconst buildMetricDetail = ({ source, action, version }: MetricsLogItem): string => {\n const metricOrigin = typeof AWSUI_METRIC_ORIGIN !== 'undefined' ? AWSUI_METRIC_ORIGIN : 'main';\n const detailObject = {\n o: metricOrigin,\n s: source,\n t: THEME,\n a: action,\n f: framework,\n v: formatMajorVersionForMetricDetail(version),\n };\n return JSON.stringify(detailObject);\n};\n\nconst buildMetricName = ({ source, version }: MetricsLogItem): string => {\n return ['awsui', source, `${formatVersionForMetricName(THEME, version)}`].join('_');\n};\n\nconst findPanorama = (currentWindow?: MetricsWindow): any | undefined => {\n try {\n if (typeof currentWindow?.panorama === 'function') {\n return currentWindow?.panorama;\n }\n\n if (!currentWindow || currentWindow.parent === currentWindow) {\n // When the window has no more parents, it references itself\n return undefined;\n }\n\n return findPanorama(currentWindow.parent);\n } catch (ex) {\n // Most likely a cross-origin access error\n return undefined;\n }\n};\n\nconst findAWSC = (currentWindow?: MetricsWindow): AWSC | undefined => {\n try {\n if (typeof currentWindow?.AWSC === 'object') {\n return currentWindow?.AWSC;\n }\n\n if (!currentWindow || currentWindow.parent === currentWindow) {\n // When the window has no more parents, it references itself\n return undefined;\n }\n\n return findAWSC(currentWindow.parent);\n } catch (ex) {\n // Most likely a cross-origin access error\n return undefined;\n }\n};\n\n// react is the default framework we're logging, for angular we need to set it explicitly\nlet framework = 'react';\nfunction setFramework(fwk: string) {\n framework = fwk;\n}\n\nexport const Metrics = {\n initMetrics(fwk: string) {\n setFramework(fwk);\n },\n\n /**\n * Calls Console Platform's client logging JS API with provided metric name, value, and detail.\n * Does nothing if Console Platform client logging JS is not present in page.\n */\n sendMetric(metricName: string, value: number, detail?: string): void {\n if (!metricName || !/^[a-zA-Z0-9_-]{1,32}$/.test(metricName)) {\n console.error(`Invalid metric name: ${metricName}`);\n return;\n }\n if (detail && detail.length > 200) {\n console.error(`Detail for metric ${metricName} is too long: ${detail}`);\n return;\n }\n const AWSC = findAWSC(window);\n if (typeof AWSC === 'object' && typeof AWSC.Clog === 'object' && typeof AWSC.Clog.log === 'function') {\n AWSC.Clog.log(metricName, value, detail);\n }\n },\n\n /**\n * Calls Console Platform's client v2 logging JS API with provided metric name and detail.\n * Does nothing if Console Platform client logging JS is not present in page.\n */\n sendPanoramaMetric(metricName: string, metric: MetricsV2EventItem): void {\n if (!metricName || !/^[a-zA-Z0-9_-]{1,32}$/.test(metricName)) {\n console.error(`Invalid metric name: ${metricName}`);\n return;\n }\n if (typeof metric.eventDetail === 'object') {\n metric.eventDetail = JSON.stringify(metric.eventDetail);\n }\n if (metric.eventDetail && metric.eventDetail.length > 200) {\n console.error(`Detail for metric ${metricName} is too long: ${metric.eventDetail}`);\n return;\n }\n if (typeof metric.eventValue === 'object') {\n metric.eventValue = JSON.stringify(metric.eventValue);\n }\n const panorama = findPanorama(window);\n if (typeof panorama === 'function') {\n panorama(metricName, {\n ...metric,\n timestamp: Date.now(),\n });\n }\n },\n\n sendMetricObject(metric: MetricsLogItem, value: number): void {\n this.sendMetric(buildMetricName(metric), value, buildMetricDetail(metric));\n },\n\n sendMetricObjectOnce(metric: MetricsLogItem, value: number): void {\n const metricHash = buildMetricHash(metric);\n if (!oneTimeMetrics[metricHash]) {\n this.sendMetricObject(metric, value);\n oneTimeMetrics[metricHash] = true;\n }\n },\n\n /*\n * Calls Console Platform's client logging only the first time the provided metricName is used.\n * Subsequent calls with the same metricName are ignored.\n */\n sendMetricOnce(metricName: string, value: number, detail?: string): void {\n if (!oneTimeMetrics[metricName]) {\n this.sendMetric(metricName, value, detail);\n oneTimeMetrics[metricName] = true;\n }\n },\n\n /*\n * Reports a metric value 1 to Console Platform's client logging service to indicate that the\n * component was loaded. The component load event will only be reported as used to client logging\n * service once per page view.\n */\n logComponentLoaded() {\n this.sendMetricObjectOnce(\n {\n source: 'components',\n action: 'loaded',\n version: PACKAGE_VERSION,\n },\n 1\n );\n },\n\n /*\n * Reports a metric value 1 to Console Platform's client logging service to indicate that the\n * component was used in the page. A component will only be reported as used to client logging\n * service once per page view.\n */\n logComponentUsed(componentName: string) {\n this.sendMetricObjectOnce(\n {\n source: componentName,\n action: 'used',\n version: PACKAGE_VERSION,\n },\n 1\n );\n },\n};\n\nexport const MetricsTestHelper = {\n resetOneTimeMetricsCache: () => {\n for (const prop in oneTimeMetrics) {\n delete oneTimeMetrics[prop];\n }\n },\n formatMajorVersionForMetricDetail,\n formatVersionForMetricName,\n};\n"]}
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/internal/metrics.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA0BhD,IAAM,cAAc,GAA4B,EAAE,CAAC;AAEnD,+CAA+C;AAC/C,IAAI,KAAK,GAAG,EAAE,CAAC;AACf,SAAS,QAAQ,CAAC,QAAgB;IAChC,KAAK,GAAG,QAAQ,CAAC;AACnB,CAAC;AAED,0CAA0C;AAC1C,IAAM,SAAS,GAAG,OAAO,CAAC;AAE1B,IAAM,eAAe,GAAG,UAAC,EAAkC;QAAhC,MAAM,YAAA,EAAE,MAAM,YAAA;IACvC,OAAO,CAAC,aAAM,MAAM,CAAE,EAAE,gBAAS,MAAM,C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,IAAM,iBAAiB,GAAG;IAC/B,wBAAwB,EAAE;QACxB,KAAK,IAAM,IAAI,IAAI,cAAc,EAAE;YACjC,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;SAC7B;IACH,CAAC;IACD,iCAAiC,mCAAA;IACjC,0BAA0B,4BAAA;CAC3B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PACKAGE_VERSION } from './environment';\n\nexport interface MetricsLogItem {\n source: string;\n action: string;\n version: string;\n}\n\nexport interface MetricsV2EventItem {\n eventType?: string;\n eventContext?: string;\n eventDetail?: string | Record<string, string | number | boolean>;\n eventValue?: string | Record<string, string | number | boolean>;\n}\n\ninterface AWSC {\n Clog: any;\n}\n\ninterface MetricsWindow extends Window {\n AWSC?: AWSC;\n panorama?: any;\n}\n\ndeclare const AWSUI_METRIC_ORIGIN: string | undefined;\n\nconst oneTimeMetrics: Record<string, boolean> = {};\n\n// In case we need to override the theme for VR\nlet theme = '';\nfunction setTheme(newTheme: string) {\n theme = newTheme;\n}\n\n// react is the only framework we're using\nconst framework = 'react';\n\nconst buildMetricHash = ({ source, action }: MetricsLogItem): string => {\n return [`src${source}`, `action${action}`].join('_');\n};\n\nconst getMajorVersion = (versionString: string): string => {\n const majorVersionMatch = versionString.match(/^(\\d+\\.\\d+)/);\n return majorVersionMatch ? majorVersionMatch[1] : '';\n};\n\nconst formatMajorVersionForMetricDetail = (version: string) => {\n return version.replace(/\\s/g, '');\n};\n\nconst formatVersionForMetricName = (theme: string, version: string) => {\n return `${theme.charAt(0)}${getMajorVersion(version).replace('.', '')}`;\n};\n\nconst buildMetricDetail = ({ source, action, version }: MetricsLogItem): string => {\n const metricOrigin = typeof AWSUI_METRIC_ORIGIN !== 'undefined' ? AWSUI_METRIC_ORIGIN : 'main';\n const detailObject = {\n o: metricOrigin,\n s: source,\n t: theme,\n a: action,\n f: framework,\n v: formatMajorVersionForMetricDetail(version),\n };\n return JSON.stringify(detailObject);\n};\n\nconst buildMetricName = ({ source, version }: MetricsLogItem): string => {\n return ['awsui', source, `${formatVersionForMetricName(theme, version)}`].join('_');\n};\n\nconst findPanorama = (currentWindow?: MetricsWindow): any | undefined => {\n try {\n if (typeof currentWindow?.panorama === 'function') {\n return currentWindow?.panorama;\n }\n\n if (!currentWindow || currentWindow.parent === currentWindow) {\n // When the window has no more parents, it references itself\n return undefined;\n }\n\n return findPanorama(currentWindow.parent);\n } catch (ex) {\n // Most likely a cross-origin access error\n return undefined;\n }\n};\n\nconst findAWSC = (currentWindow?: MetricsWindow): AWSC | undefined => {\n try {\n if (typeof currentWindow?.AWSC === 'object') {\n return currentWindow?.AWSC;\n }\n\n if (!currentWindow || currentWindow.parent === currentWindow) {\n // When the window has no more parents, it references itself\n return undefined;\n }\n\n return findAWSC(currentWindow.parent);\n } catch (ex) {\n // Most likely a cross-origin access error\n return undefined;\n }\n};\n\nexport const Metrics = {\n initMetrics(theme: string) {\n setTheme(theme);\n },\n\n /**\n * Calls Console Platform's client logging JS API with provided metric name, value, and detail.\n * Does nothing if Console Platform client logging JS is not present in page.\n */\n sendMetric(metricName: string, value: number, detail?: string): void {\n if (!theme) {\n // Metrics need to be initialized first (initMetrics)\n console.error('Metrics need to be initalized first.');\n return;\n }\n\n if (!metricName || !/^[a-zA-Z0-9_-]{1,32}$/.test(metricName)) {\n console.error(`Invalid metric name: ${metricName}`);\n return;\n }\n if (detail && detail.length > 200) {\n console.error(`Detail for metric ${metricName} is too long: ${detail}`);\n return;\n }\n const AWSC = findAWSC(window);\n if (typeof AWSC === 'object' && typeof AWSC.Clog === 'object' && typeof AWSC.Clog.log === 'function') {\n AWSC.Clog.log(metricName, value, detail);\n }\n },\n\n /**\n * Calls Console Platform's client v2 logging JS API with provided metric name and detail.\n * Does nothing if Console Platform client logging JS is not present in page.\n */\n sendPanoramaMetric(metric: MetricsV2EventItem): void {\n if (typeof metric.eventDetail === 'object') {\n metric.eventDetail = JSON.stringify(metric.eventDetail);\n }\n if (metric.eventDetail && metric.eventDetail.length > 200) {\n console.error(`Detail for metric is too long: ${metric.eventDetail}`);\n return;\n }\n if (typeof metric.eventValue === 'object') {\n metric.eventValue = JSON.stringify(metric.eventValue);\n }\n const panorama = findPanorama(window);\n if (typeof panorama === 'function') {\n panorama('trackCustomEvent', {\n ...metric,\n timestamp: Date.now(),\n });\n }\n },\n\n sendMetricObject(metric: MetricsLogItem, value: number): void {\n this.sendMetric(buildMetricName(metric), value, buildMetricDetail(metric));\n },\n\n sendMetricObjectOnce(metric: MetricsLogItem, value: number): void {\n const metricHash = buildMetricHash(metric);\n if (!oneTimeMetrics[metricHash]) {\n this.sendMetricObject(metric, value);\n oneTimeMetrics[metricHash] = true;\n }\n },\n\n /*\n * Calls Console Platform's client logging only the first time the provided metricName is used.\n * Subsequent calls with the same metricName are ignored.\n */\n sendMetricOnce(metricName: string, value: number, detail?: string): void {\n if (!oneTimeMetrics[metricName]) {\n this.sendMetric(metricName, value, detail);\n oneTimeMetrics[metricName] = true;\n }\n },\n\n /*\n * Reports a metric value 1 to Console Platform's client logging service to indicate that the\n * component was loaded. The component load event will only be reported as used to client logging\n * service once per page view.\n */\n logComponentLoaded() {\n this.sendMetricObjectOnce(\n {\n source: 'components',\n action: 'loaded',\n version: PACKAGE_VERSION,\n },\n 1\n );\n },\n\n /*\n * Reports a metric value 1 to Console Platform's client logging service to indicate that the\n * component was used in the page. A component will only be reported as used to client logging\n * service once per page view.\n */\n logComponentUsed(componentName: string) {\n this.sendMetricObjectOnce(\n {\n source: componentName,\n action: 'used',\n version: PACKAGE_VERSION,\n },\n 1\n );\n },\n};\n\nexport const MetricsTestHelper = {\n resetOneTimeMetricsCache: () => {\n for (const prop in oneTimeMetrics) {\n delete oneTimeMetrics[prop];\n }\n },\n formatMajorVersionForMetricDetail,\n formatVersionForMetricName,\n};\n"]}
@@ -4,7 +4,7 @@
4
4
  * License: ISC
5
5
  * Private: false
6
6
  * Description: Array manipulation, ordering, searching, summarizing, etc.
7
- * Repository: git+https://github.com/d3/d3-array.git
7
+ * Repository: https://github.com/d3/d3-array.git
8
8
  * Homepage: https://d3js.org/d3-array/
9
9
  * Author: Mike Bostock (http://bost.ocks.org/mike)
10
10
  * License Copyright:
@@ -32,7 +32,7 @@
32
32
  * License: ISC
33
33
  * Private: false
34
34
  * Description: Map and Set with automatic key interning
35
- * Repository: git+https://github.com/mbostock/internmap.git
35
+ * Repository: https://github.com/mbostock/internmap.git
36
36
  * Homepage: https://github.com/mbostock/internmap/
37
37
  * Author: Mike Bostock (https://bost.ocks.org/mike)
38
38
  * License Copyright:
@@ -60,7 +60,7 @@
60
60
  * License: ISC
61
61
  * Private: false
62
62
  * Description: Encodings that map abstract data to visual representation.
63
- * Repository: git+https://github.com/d3/d3-scale.git
63
+ * Repository: https://github.com/d3/d3-scale.git
64
64
  * Homepage: https://d3js.org/d3-scale/
65
65
  * Author: Mike Bostock (https://bost.ocks.org/mike)
66
66
  * License Copyright:
@@ -88,7 +88,7 @@
88
88
  * License: ISC
89
89
  * Private: false
90
90
  * Description: Color spaces! RGB, HSL, Cubehelix, Lab and HCL (Lch).
91
- * Repository: git+https://github.com/d3/d3-color.git
91
+ * Repository: https://github.com/d3/d3-color.git
92
92
  * Homepage: https://d3js.org/d3-color/
93
93
  * Author: Mike Bostock (http://bost.ocks.org/mike)
94
94
  * License Copyright:
@@ -116,7 +116,7 @@
116
116
  * License: ISC
117
117
  * Private: false
118
118
  * Description: Interpolate numbers, colors, strings, arrays, objects, whatever!
119
- * Repository: git+https://github.com/d3/d3-interpolate.git
119
+ * Repository: https://github.com/d3/d3-interpolate.git
120
120
  * Homepage: https://d3js.org/d3-interpolate/
121
121
  * Author: Mike Bostock (http://bost.ocks.org/mike)
122
122
  * License Copyright:
@@ -144,7 +144,7 @@
144
144
  * License: ISC
145
145
  * Private: false
146
146
  * Description: Format numbers for human consumption.
147
- * Repository: git+https://github.com/d3/d3-format.git
147
+ * Repository: https://github.com/d3/d3-format.git
148
148
  * Homepage: https://d3js.org/d3-format/
149
149
  * Author: Mike Bostock (http://bost.ocks.org/mike)
150
150
  * License Copyright:
@@ -172,7 +172,7 @@
172
172
  * License: ISC
173
173
  * Private: false
174
174
  * Description: A calculator for humanity’s peculiar conventions of time.
175
- * Repository: git+https://github.com/d3/d3-time.git
175
+ * Repository: https://github.com/d3/d3-time.git
176
176
  * Homepage: https://d3js.org/d3-time/
177
177
  * Author: Mike Bostock (http://bost.ocks.org/mike)
178
178
  * License Copyright:
@@ -200,7 +200,7 @@
200
200
  * License: ISC
201
201
  * Private: false
202
202
  * Description: A JavaScript time formatter and parser inspired by strftime and strptime.
203
- * Repository: git+https://github.com/d3/d3-time-format.git
203
+ * Repository: https://github.com/d3/d3-time-format.git
204
204
  * Homepage: https://d3js.org/d3-time-format/
205
205
  * Author: Mike Bostock (http://bost.ocks.org/mike)
206
206
  * License Copyright:
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/side-navigation/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAMzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAOnD,UAAU,sBAAsB;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,OAAO,GAAG,mBAAmB,CAAC,mBAAmB,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACrH,UAAU,EAAE,CACV,IAAI,EACA,mBAAmB,CAAC,IAAI,GACxB,mBAAmB,CAAC,MAAM,GAC1B,mBAAmB,CAAC,SAAS,GAC7B,mBAAmB,CAAC,mBAAmB,EAC3C,KAAK,EAAE,KAAK,CAAC,cAAc,GAAG,KAAK,KAChC,IAAI,CAAC;CACX;AAED,MAAM,WAAW,WAAY,SAAQ,sBAAsB;IACzD,UAAU,EAAE,mBAAmB,CAAC,MAAM,CAAC;CACxC;AAED,wB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EAAE,SAAS,GAAG,YAAY,GAAG,uBAAuB,GAAG,MAAM,CAAC;CACtE;AAED,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,aAAa,eA6B7F"}
@@ -32,11 +32,11 @@ export function Header(_a) {
32
32
  export function ItemList(_a) {
33
33
  var variant = _a.variant, items = _a.items, activeHref = _a.activeHref, fireChange = _a.fireChange, fireFollow = _a.fireFollow;
34
34
  return (React.createElement("ul", { className: clsx(styles.list, styles["list-variant-".concat(variant)]) }, items.map(function (item, i) { return (React.createElement("li", { key: i, className: styles['list-item'] },
35
- item.type === 'divider' && React.createElement(Divider, { variant: "default" }),
36
35
  item.type === 'link' && (React.createElement(Link, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow })),
37
36
  item.type === 'section' && (React.createElement(Section, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow })),
38
37
  item.type === 'link-group' && (React.createElement(LinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow })),
39
- item.type === 'expandable-link-group' && (React.createElement(ExpandableLinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow })))); })));
38
+ item.type === 'expandable-link-group' && (React.createElement(ExpandableLinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow })),
39
+ ((i === 0 && item.type === 'divider') || (items[i + 1] && items[i + 1].type === 'divider')) && (React.createElement(Divider, { variant: "default" })))); })));
40
40
  }
41
41
  function Divider(_a) {
42
42
  var _b = _a.variant, variant = _b === void 0 ? 'default' : _b;
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/side-navigation/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAA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AAU,EAAE,UAAU,CAAC,CACzB,CAAC;IAEF,IAAM,cAAc,GAA4B,UAAC,CAAC,EAAE,KAAK;QACvD,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC9B,eAAe,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,QAAQ,EAAE;YACb,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;SAC9B;IACH,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,yBAAyB,IACxB,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,EAC1C,OAAO,EAAC,YAAY,EACpB,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ,EAClC,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EACR,oBAAC,IAAI,IACH,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,EAC1E,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ,EAClC,UAAU,EAAE,cAAc,EAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACtB;QAGJ,oBAAC,QAAQ,IACP,OAAO,EAAC,uBAAuB,EAC/B,KAAK,EAAE,UAAU,CAAC,KAAK,EACvB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACtB,CACwB,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useState, useEffect, useMemo } from 'react';\nimport clsx from 'clsx';\nimport { ExpandableSectionProps } from '../expandable-section/interfaces';\nimport InternalExpandableSection from '../expandable-section/internal';\nimport InternalIcon from '../icon/internal';\n\nimport { SideNavigationProps } from './interfaces';\nimport styles from './styles.css.js';\nimport { NonCancelableCustomEvent, isPlainLeftClick } from '../internal/events';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport { hasActiveLink } from './util';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\n\ninterface BaseItemComponentProps {\n activeHref?: string;\n fireChange: (item: SideNavigationProps.Section | SideNavigationProps.ExpandableLinkGroup, expanded: boolean) => void;\n fireFollow: (\n item:\n | SideNavigationProps.Link\n | SideNavigationProps.Header\n | SideNavigationProps.LinkGroup\n | SideNavigationProps.ExpandableLinkGroup,\n event: React.SyntheticEvent | Event\n ) => void;\n}\n\nexport interface HeaderProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Header;\n}\n\nexport function Header({ definition, activeHref, fireFollow }: HeaderProps) {\n checkSafeUrl('SideNavigation', definition.href);\n const focusVisible = useFocusVisible();\n\n const onClick = useCallback(\n (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n fireFollow(definition, event);\n }\n },\n [fireFollow, definition]\n );\n\n return (\n <>\n <div className={styles.header}>\n <a\n {...focusVisible}\n href={definition.href}\n className={clsx(styles['header-link'], { [styles['header-link--has-logo']]: !!definition.logo })}\n aria-current={definition.href === activeHref ? 'page' : undefined}\n onClick={onClick}\n >\n {definition.logo && (\n <img\n className={clsx(styles['header-logo'], {\n [styles['header-logo--stretched']]: !definition.text,\n })}\n {...definition.logo}\n />\n )}\n <span className={styles['header-link-text']}>{definition.text}</span>\n </a>\n </div>\n <Divider variant=\"header\" />\n </>\n );\n}\n\nexport interface ItemListProps extends BaseItemComponentProps {\n items: ReadonlyArray<SideNavigationProps.Item>;\n variant: 'section' | 'link-group' | 'expandable-link-group' | 'root';\n}\n\nexport function ItemList({ variant, items, activeHref, fireChange, fireFollow }: ItemListProps) {\n return (\n <ul className={clsx(styles.list, styles[`list-variant-${variant}`])}>\n {items.map((item, i) => (\n <li key={i} className={styles['list-item']}>\n {item.type === 'divider' && <Divider variant=\"default\" />}\n {item.type === 'link' && (\n <Link definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n )}\n {item.type === 'section' && (\n <Section definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n )}\n {item.type === 'link-group' && (\n <LinkGroup definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n )}\n {item.type === 'expandable-link-group' && (\n <ExpandableLinkGroup\n definition={item}\n activeHref={activeHref}\n fireChange={fireChange}\n fireFollow={fireFollow}\n />\n )}\n </li>\n ))}\n </ul>\n );\n}\n\ninterface DividerProps {\n variant: 'default' | 'header';\n}\n\nfunction Divider({ variant = 'default' }: DividerProps) {\n return <hr className={clsx(styles.divider, styles[`divider-${variant}`])} />;\n}\n\ninterface LinkProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Link;\n expanded?: boolean;\n}\n\nfunction Link({ definition, expanded, activeHref, fireFollow }: LinkProps) {\n checkSafeUrl('SideNavigation', definition.href);\n const isActive = definition.href === activeHref;\n const focusVisible = useFocusVisible();\n\n const onClick = useCallback(\n (event: React.MouseEvent) => {\n // Prevent the click event from toggling outer expandable sections.\n event.stopPropagation();\n\n if (isPlainLeftClick(event)) {\n fireFollow(definition, event);\n }\n },\n [fireFollow, definition]\n );\n\n return (\n <>\n {/* https://github.com/yannickcr/eslint-plugin-react/issues/2962 */}\n {/* eslint-disable-next-line react/jsx-no-target-blank */}\n <a\n {...focusVisible}\n href={definition.href}\n className={clsx(styles.link, { [styles['link-active']]: isActive })}\n target={definition.external ? '_blank' : undefined}\n rel={definition.external ? 'noopener noreferrer' : undefined}\n aria-expanded={expanded}\n aria-current={definition.href === activeHref ? 'page' : undefined}\n onClick={onClick}\n >\n {definition.text}\n {definition.external && (\n <span\n aria-label={definition.externalIconAriaLabel}\n role={definition.externalIconAriaLabel ? 'img' : undefined}\n >\n <InternalIcon name=\"external\" className={styles['external-icon']} />\n </span>\n )}\n </a>\n {definition.info && <span className={styles.info}>{definition.info}</span>}\n </>\n );\n}\n\ninterface SectionProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Section;\n}\n\nfunction Section({ definition, activeHref, fireFollow, fireChange }: SectionProps) {\n const [expanded, setExpanded] = useState<boolean>(definition.defaultExpanded ?? true);\n\n const onExpandedChange = useCallback(\n (e: NonCancelableCustomEvent<ExpandableSectionProps.ChangeDetail>) => {\n fireChange(definition, e.detail.expanded);\n setExpanded(e.detail.expanded);\n },\n [definition, fireChange]\n );\n\n useEffect(() => {\n setExpanded(definition.defaultExpanded ?? true);\n }, [definition]);\n\n return (\n <InternalExpandableSection\n variant=\"footer\"\n expanded={expanded}\n onChange={onExpandedChange}\n className={styles.section}\n headerText={definition.text}\n >\n <ItemList\n variant=\"section\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </InternalExpandableSection>\n );\n}\n\ninterface LinkGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.LinkGroup;\n}\n\nfunction LinkGroup({ definition, activeHref, fireFollow, fireChange }: LinkGroupProps) {\n checkSafeUrl('SideNavigation', definition.href);\n\n return (\n <>\n <Link\n definition={{ type: 'link', href: definition.href, text: definition.text }}\n fireFollow={(_, event) => fireFollow(definition, event)}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n <ItemList\n variant=\"link-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </>\n );\n}\n\ninterface ExpandableLinkGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.ExpandableLinkGroup;\n}\n\nfunction ExpandableLinkGroup({ definition, fireFollow, fireChange, activeHref }: ExpandableLinkGroupProps) {\n // Check whether the definition contains an active link and memoize it to avoid\n // rechecking every time.\n const containsActiveLink = useMemo(() => {\n return activeHref ? hasActiveLink(definition.items, activeHref) : false;\n }, [activeHref, definition.items]);\n\n const [expanded, setExpanded] = useState<boolean>(() => {\n return definition.defaultExpanded ?? (definition.href === activeHref || containsActiveLink);\n });\n\n const [userExpanded, setUserExpanded] = useState<boolean | undefined>();\n\n // Reset user expansion status when the items property is updated.\n useEffect(() => setUserExpanded(undefined), [definition]);\n\n // By default, the expandable section is open when there's an active link inside.\n useEffect(() => {\n setExpanded(definition.href === activeHref || containsActiveLink);\n }, [definition.href, containsActiveLink, activeHref]);\n\n // If the definition object itself is updated, reset the expansion state to default.\n useEffect(() => {\n if (definition.defaultExpanded !== undefined) {\n setExpanded(definition.defaultExpanded);\n }\n }, [definition]);\n\n const onExpandedChange = useCallback(\n (e: NonCancelableCustomEvent<ExpandableSectionProps.ChangeDetail>) => {\n fireChange(definition, e.detail.expanded);\n setUserExpanded(e.detail.expanded);\n },\n [definition, fireChange]\n );\n\n const onHeaderFollow: LinkProps['fireFollow'] = (_, event) => {\n fireFollow(definition, event);\n setUserExpanded(true);\n if (!expanded) {\n fireChange(definition, true);\n }\n };\n\n return (\n <InternalExpandableSection\n className={styles['expandable-link-group']}\n variant=\"navigation\"\n expanded={userExpanded ?? expanded}\n onChange={onExpandedChange}\n headerText={\n <Link\n definition={{ type: 'link', href: definition.href, text: definition.text }}\n expanded={userExpanded ?? expanded}\n fireFollow={onHeaderFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n }\n >\n <ItemList\n variant=\"expandable-link-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </InternalExpandableSection>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/side-navigation/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,yBAAyB,MAAM,gCAAgC,CAAC;AACvE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAG5C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAA4B,gBAAgB,EAAE,MAA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ACzB,CAAC;IAEF,IAAM,cAAc,GAA4B,UAAC,CAAC,EAAE,KAAK;QACvD,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC9B,eAAe,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,QAAQ,EAAE;YACb,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;SAC9B;IACH,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,yBAAyB,IACxB,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,EAC1C,OAAO,EAAC,YAAY,EACpB,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ,EAClC,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EACR,oBAAC,IAAI,IACH,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,EAC1E,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ,EAClC,UAAU,EAAE,cAAc,EAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACtB;QAGJ,oBAAC,QAAQ,IACP,OAAO,EAAC,uBAAuB,EAC/B,KAAK,EAAE,UAAU,CAAC,KAAK,EACvB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACtB,CACwB,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useState, useEffect, useMemo } from 'react';\nimport clsx from 'clsx';\nimport { ExpandableSectionProps } from '../expandable-section/interfaces';\nimport InternalExpandableSection from '../expandable-section/internal';\nimport InternalIcon from '../icon/internal';\n\nimport { SideNavigationProps } from './interfaces';\nimport styles from './styles.css.js';\nimport { NonCancelableCustomEvent, isPlainLeftClick } from '../internal/events';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport { hasActiveLink } from './util';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\n\ninterface BaseItemComponentProps {\n activeHref?: string;\n fireChange: (item: SideNavigationProps.Section | SideNavigationProps.ExpandableLinkGroup, expanded: boolean) => void;\n fireFollow: (\n item:\n | SideNavigationProps.Link\n | SideNavigationProps.Header\n | SideNavigationProps.LinkGroup\n | SideNavigationProps.ExpandableLinkGroup,\n event: React.SyntheticEvent | Event\n ) => void;\n}\n\nexport interface HeaderProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Header;\n}\n\nexport function Header({ definition, activeHref, fireFollow }: HeaderProps) {\n checkSafeUrl('SideNavigation', definition.href);\n const focusVisible = useFocusVisible();\n\n const onClick = useCallback(\n (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n fireFollow(definition, event);\n }\n },\n [fireFollow, definition]\n );\n\n return (\n <>\n <div className={styles.header}>\n <a\n {...focusVisible}\n href={definition.href}\n className={clsx(styles['header-link'], { [styles['header-link--has-logo']]: !!definition.logo })}\n aria-current={definition.href === activeHref ? 'page' : undefined}\n onClick={onClick}\n >\n {definition.logo && (\n <img\n className={clsx(styles['header-logo'], {\n [styles['header-logo--stretched']]: !definition.text,\n })}\n {...definition.logo}\n />\n )}\n <span className={styles['header-link-text']}>{definition.text}</span>\n </a>\n </div>\n <Divider variant=\"header\" />\n </>\n );\n}\n\nexport interface ItemListProps extends BaseItemComponentProps {\n items: ReadonlyArray<SideNavigationProps.Item>;\n variant: 'section' | 'link-group' | 'expandable-link-group' | 'root';\n}\n\nexport function ItemList({ variant, items, activeHref, fireChange, fireFollow }: ItemListProps) {\n return (\n <ul className={clsx(styles.list, styles[`list-variant-${variant}`])}>\n {items.map((item, i) => (\n <li key={i} className={styles['list-item']}>\n {item.type === 'link' && (\n <Link definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n )}\n {item.type === 'section' && (\n <Section definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n )}\n {item.type === 'link-group' && (\n <LinkGroup definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n )}\n {item.type === 'expandable-link-group' && (\n <ExpandableLinkGroup\n definition={item}\n activeHref={activeHref}\n fireChange={fireChange}\n fireFollow={fireFollow}\n />\n )}\n {((i === 0 && item.type === 'divider') || (items[i + 1] && items[i + 1].type === 'divider')) && (\n <Divider variant=\"default\" />\n )}\n </li>\n ))}\n </ul>\n );\n}\n\ninterface DividerProps {\n variant: 'default' | 'header';\n}\n\nfunction Divider({ variant = 'default' }: DividerProps) {\n return <hr className={clsx(styles.divider, styles[`divider-${variant}`])} />;\n}\n\ninterface LinkProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Link;\n expanded?: boolean;\n}\n\nfunction Link({ definition, expanded, activeHref, fireFollow }: LinkProps) {\n checkSafeUrl('SideNavigation', definition.href);\n const isActive = definition.href === activeHref;\n const focusVisible = useFocusVisible();\n\n const onClick = useCallback(\n (event: React.MouseEvent) => {\n // Prevent the click event from toggling outer expandable sections.\n event.stopPropagation();\n\n if (isPlainLeftClick(event)) {\n fireFollow(definition, event);\n }\n },\n [fireFollow, definition]\n );\n\n return (\n <>\n {/* https://github.com/yannickcr/eslint-plugin-react/issues/2962 */}\n {/* eslint-disable-next-line react/jsx-no-target-blank */}\n <a\n {...focusVisible}\n href={definition.href}\n className={clsx(styles.link, { [styles['link-active']]: isActive })}\n target={definition.external ? '_blank' : undefined}\n rel={definition.external ? 'noopener noreferrer' : undefined}\n aria-expanded={expanded}\n aria-current={definition.href === activeHref ? 'page' : undefined}\n onClick={onClick}\n >\n {definition.text}\n {definition.external && (\n <span\n aria-label={definition.externalIconAriaLabel}\n role={definition.externalIconAriaLabel ? 'img' : undefined}\n >\n <InternalIcon name=\"external\" className={styles['external-icon']} />\n </span>\n )}\n </a>\n {definition.info && <span className={styles.info}>{definition.info}</span>}\n </>\n );\n}\n\ninterface SectionProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Section;\n}\n\nfunction Section({ definition, activeHref, fireFollow, fireChange }: SectionProps) {\n const [expanded, setExpanded] = useState<boolean>(definition.defaultExpanded ?? true);\n\n const onExpandedChange = useCallback(\n (e: NonCancelableCustomEvent<ExpandableSectionProps.ChangeDetail>) => {\n fireChange(definition, e.detail.expanded);\n setExpanded(e.detail.expanded);\n },\n [definition, fireChange]\n );\n\n useEffect(() => {\n setExpanded(definition.defaultExpanded ?? true);\n }, [definition]);\n\n return (\n <InternalExpandableSection\n variant=\"footer\"\n expanded={expanded}\n onChange={onExpandedChange}\n className={styles.section}\n headerText={definition.text}\n >\n <ItemList\n variant=\"section\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </InternalExpandableSection>\n );\n}\n\ninterface LinkGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.LinkGroup;\n}\n\nfunction LinkGroup({ definition, activeHref, fireFollow, fireChange }: LinkGroupProps) {\n checkSafeUrl('SideNavigation', definition.href);\n\n return (\n <>\n <Link\n definition={{ type: 'link', href: definition.href, text: definition.text }}\n fireFollow={(_, event) => fireFollow(definition, event)}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n <ItemList\n variant=\"link-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </>\n );\n}\n\ninterface ExpandableLinkGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.ExpandableLinkGroup;\n}\n\nfunction ExpandableLinkGroup({ definition, fireFollow, fireChange, activeHref }: ExpandableLinkGroupProps) {\n // Check whether the definition contains an active link and memoize it to avoid\n // rechecking every time.\n const containsActiveLink = useMemo(() => {\n return activeHref ? hasActiveLink(definition.items, activeHref) : false;\n }, [activeHref, definition.items]);\n\n const [expanded, setExpanded] = useState<boolean>(() => {\n return definition.defaultExpanded ?? (definition.href === activeHref || containsActiveLink);\n });\n\n const [userExpanded, setUserExpanded] = useState<boolean | undefined>();\n\n // Reset user expansion status when the items property is updated.\n useEffect(() => setUserExpanded(undefined), [definition]);\n\n // By default, the expandable section is open when there's an active link inside.\n useEffect(() => {\n setExpanded(definition.href === activeHref || containsActiveLink);\n }, [definition.href, containsActiveLink, activeHref]);\n\n // If the definition object itself is updated, reset the expansion state to default.\n useEffect(() => {\n if (definition.defaultExpanded !== undefined) {\n setExpanded(definition.defaultExpanded);\n }\n }, [definition]);\n\n const onExpandedChange = useCallback(\n (e: NonCancelableCustomEvent<ExpandableSectionProps.ChangeDetail>) => {\n fireChange(definition, e.detail.expanded);\n setUserExpanded(e.detail.expanded);\n },\n [definition, fireChange]\n );\n\n const onHeaderFollow: LinkProps['fireFollow'] = (_, event) => {\n fireFollow(definition, event);\n setUserExpanded(true);\n if (!expanded) {\n fireChange(definition, true);\n }\n };\n\n return (\n <InternalExpandableSection\n className={styles['expandable-link-group']}\n variant=\"navigation\"\n expanded={userExpanded ?? expanded}\n onChange={onExpandedChange}\n headerText={\n <Link\n definition={{ type: 'link', href: definition.href, text: definition.text }}\n expanded={userExpanded ?? expanded}\n fireFollow={onHeaderFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n }\n >\n <ItemList\n variant=\"expandable-link-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </InternalExpandableSection>\n );\n}\n"]}