@cloudscape-design/components-themeable 3.0.1315 → 3.0.1316

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.
Files changed (83) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
  3. package/lib/internal/scss/link/styles.scss +16 -0
  4. package/lib/internal/scss/side-navigation/styles.scss +221 -48
  5. package/lib/internal/scss/side-navigation/test-classes/styles.scss +4 -0
  6. package/lib/internal/scss/top-navigation/test-classes/styles.scss +8 -0
  7. package/lib/internal/template/file-token-group/file-token.d.ts.map +1 -1
  8. package/lib/internal/template/file-token-group/file-token.js +33 -27
  9. package/lib/internal/template/file-token-group/file-token.js.map +1 -1
  10. package/lib/internal/template/internal/base-component/styles.scoped.css +13 -1
  11. package/lib/internal/template/internal/breakpoints.d.ts +1 -1
  12. package/lib/internal/template/internal/breakpoints.d.ts.map +1 -1
  13. package/lib/internal/template/internal/breakpoints.js +25 -3
  14. package/lib/internal/template/internal/breakpoints.js.map +1 -1
  15. package/lib/internal/template/internal/environment.js +2 -2
  16. package/lib/internal/template/internal/environment.json +2 -2
  17. package/lib/internal/template/internal/generated/styles/tokens.d.ts +5 -0
  18. package/lib/internal/template/internal/generated/styles/tokens.js +5 -0
  19. package/lib/internal/template/internal/generated/theming/index.cjs +99 -0
  20. package/lib/internal/template/internal/generated/theming/index.cjs.d.ts +36 -0
  21. package/lib/internal/template/internal/generated/theming/index.d.ts +36 -0
  22. package/lib/internal/template/internal/generated/theming/index.js +99 -0
  23. package/lib/internal/template/internal/hooks/container-queries/use-container-breakpoints.d.ts.map +1 -1
  24. package/lib/internal/template/internal/hooks/container-queries/use-container-breakpoints.js +2 -1
  25. package/lib/internal/template/internal/hooks/container-queries/use-container-breakpoints.js.map +1 -1
  26. package/lib/internal/template/link/internal.js +1 -1
  27. package/lib/internal/template/link/internal.js.map +1 -1
  28. package/lib/internal/template/link/styles.css.js +21 -21
  29. package/lib/internal/template/link/styles.scoped.css +118 -72
  30. package/lib/internal/template/link/styles.selectors.js +21 -21
  31. package/lib/internal/template/prompt-input/index.d.ts.map +1 -1
  32. package/lib/internal/template/prompt-input/index.js +3 -1
  33. package/lib/internal/template/prompt-input/index.js.map +1 -1
  34. package/lib/internal/template/side-navigation/implementation.d.ts +1 -1
  35. package/lib/internal/template/side-navigation/implementation.d.ts.map +1 -1
  36. package/lib/internal/template/side-navigation/implementation.js +4 -4
  37. package/lib/internal/template/side-navigation/implementation.js.map +1 -1
  38. package/lib/internal/template/side-navigation/index.d.ts +1 -1
  39. package/lib/internal/template/side-navigation/index.d.ts.map +1 -1
  40. package/lib/internal/template/side-navigation/index.js +5 -3
  41. package/lib/internal/template/side-navigation/index.js.map +1 -1
  42. package/lib/internal/template/side-navigation/interfaces.d.ts +20 -1
  43. package/lib/internal/template/side-navigation/interfaces.d.ts.map +1 -1
  44. package/lib/internal/template/side-navigation/interfaces.js.map +1 -1
  45. package/lib/internal/template/side-navigation/parts.d.ts +3 -2
  46. package/lib/internal/template/side-navigation/parts.d.ts.map +1 -1
  47. package/lib/internal/template/side-navigation/parts.js +147 -37
  48. package/lib/internal/template/side-navigation/parts.js.map +1 -1
  49. package/lib/internal/template/side-navigation/styles.css.js +46 -30
  50. package/lib/internal/template/side-navigation/styles.scoped.css +223 -74
  51. package/lib/internal/template/side-navigation/styles.selectors.js +46 -30
  52. package/lib/internal/template/side-navigation/test-classes/styles.css.js +2 -1
  53. package/lib/internal/template/side-navigation/test-classes/styles.scoped.css +5 -1
  54. package/lib/internal/template/side-navigation/test-classes/styles.selectors.js +2 -1
  55. package/lib/internal/template/test-utils/dom/top-navigation/index.d.ts +2 -1
  56. package/lib/internal/template/test-utils/dom/top-navigation/index.js +4 -0
  57. package/lib/internal/template/test-utils/dom/top-navigation/index.js.map +1 -1
  58. package/lib/internal/template/test-utils/selectors/top-navigation/index.d.ts +1 -0
  59. package/lib/internal/template/test-utils/selectors/top-navigation/index.js +4 -0
  60. package/lib/internal/template/test-utils/selectors/top-navigation/index.js.map +1 -1
  61. package/lib/internal/template/token/internal.d.ts +18 -2
  62. package/lib/internal/template/token/internal.d.ts.map +1 -1
  63. package/lib/internal/template/token/internal.js +20 -9
  64. package/lib/internal/template/token/internal.js.map +1 -1
  65. package/lib/internal/template/top-navigation/index.d.ts +1 -1
  66. package/lib/internal/template/top-navigation/index.d.ts.map +1 -1
  67. package/lib/internal/template/top-navigation/index.js +2 -2
  68. package/lib/internal/template/top-navigation/index.js.map +1 -1
  69. package/lib/internal/template/top-navigation/interfaces.d.ts +14 -1
  70. package/lib/internal/template/top-navigation/interfaces.d.ts.map +1 -1
  71. package/lib/internal/template/top-navigation/interfaces.js.map +1 -1
  72. package/lib/internal/template/top-navigation/internal.d.ts +2 -2
  73. package/lib/internal/template/top-navigation/internal.d.ts.map +1 -1
  74. package/lib/internal/template/top-navigation/internal.js +42 -21
  75. package/lib/internal/template/top-navigation/internal.js.map +1 -1
  76. package/lib/internal/template/top-navigation/test-classes/styles.css.js +6 -0
  77. package/lib/internal/template/top-navigation/test-classes/styles.scoped.css +7 -0
  78. package/lib/internal/template/top-navigation/test-classes/styles.selectors.js +7 -0
  79. package/lib/internal/template/top-navigation/use-top-navigation.d.ts +5 -0
  80. package/lib/internal/template/top-navigation/use-top-navigation.d.ts.map +1 -1
  81. package/lib/internal/template/top-navigation/use-top-navigation.js +12 -5
  82. package/lib/internal/template/top-navigation/use-top-navigation.js.map +1 -1
  83. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../../src/side-navigation/implementation.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;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IAEF,MAAM,eAAe,GAAG,WAAW,CACjC,CACE,IAI2C,EAC3C,WAAyC,EACzC,EAAE;QACF,mBAAmB,CAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IACnD,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,OAAO,CACL,gCACM,SAAS,EACb,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC,EACtF,GAAG,EAAE,iBAAiB;QAErB,MAAM,IAAI,CACT,oBAAC,MAAM,IAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,GAAI,CACjH;QACA,YAAY,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,IAAG,YAAY,CAAO;QAC7E,KAAK,IAAI,CACR,6BAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC;YACtC,oBAAC,mBAAmB,IAClB,OAAO,EAAC,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,eAAe,EAC3B,UAAU,EAAE,eAAe,EAC3B,UAAU,EAAE,UAAU,GACtB,CACE,CACP,CACG,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,yBAAyB,CAAC,4BAA4B,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo } from 'react';\nimport clsx from 'clsx';\n\nimport { useAppLayoutToolbarDesignEnabled } from '../app-layout/utils/feature-flags';\nimport { getBaseProps } from '../internal/base-component';\nimport { fireCancelableEvent, fireNonCancelableEvent } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { isDevelopment } from '../internal/is-development';\nimport { createWidgetizedComponent } from '../internal/widgets';\nimport { SideNavigationProps } from './interfaces';\nimport { Header, NavigationItemsList } from './parts';\nimport { checkDuplicateHrefs, generateExpandableItemsMapping } from './util';\n\nimport styles from './styles.css.js';\n\ntype SideNavigationInternalProps = SideNavigationProps & InternalBaseComponentProps;\n\nexport function SideNavigationImplementation({\n header,\n itemsControl,\n activeHref,\n items = [],\n onFollow,\n onChange,\n __internalRootRef,\n ...props\n}: SideNavigationInternalProps) {\n const baseProps = getBaseProps(props);\n const isToolbar = useAppLayoutToolbarDesignEnabled();\n const parentMap = useMemo(() => generateExpandableItemsMapping(items), [items]);\n\n if (isDevelopment) {\n // This code should be wiped in production anyway.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => checkDuplicateHrefs(items), [items]);\n }\n\n const onChangeHandler = useCallback(\n (item: SideNavigationProps.Section | SideNavigationProps.ExpandableLinkGroup, expanded: boolean) => {\n // generateExpandableItemsMapping walks through the entire tree, so we're certain about getting a value.\n fireNonCancelableEvent(onChange, { item, expanded: expanded, expandableParents: parentMap.get(item)! });\n },\n [onChange, parentMap]\n );\n\n const onFollowHandler = useCallback(\n (\n item:\n | SideNavigationProps.Link\n | SideNavigationProps.Header\n | SideNavigationProps.LinkGroup\n | SideNavigationProps.ExpandableLinkGroup,\n sourceEvent: React.SyntheticEvent | Event\n ) => {\n fireCancelableEvent(onFollow, item, sourceEvent);\n },\n [onFollow]\n );\n\n return (\n <div\n {...baseProps}\n className={clsx(styles.root, baseProps.className, isToolbar && styles['with-toolbar'])}\n ref={__internalRootRef}\n >\n {header && (\n <Header definition={header} activeHref={activeHref} fireChange={onChangeHandler} fireFollow={onFollowHandler} />\n )}\n {itemsControl && <div className={styles['items-control']}>{itemsControl}</div>}\n {items && (\n <div className={styles['list-container']}>\n <NavigationItemsList\n variant=\"root\"\n items={items}\n fireFollow={onFollowHandler}\n fireChange={onChangeHandler}\n activeHref={activeHref}\n />\n </div>\n )}\n </div>\n );\n}\n\nexport const createWidgetizedSideNavigation = createWidgetizedComponent(SideNavigationImplementation);\n"]}
1
+ {"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../../src/side-navigation/implementation.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,8BAA8B,EAAE,MAAM,QAAQ,CAAC;AAE7E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,MAAM,UAAU,4BAA4B,CAAC,EAC3C,MAAM,EACN,YAAY,EACZ,UAAU,EACV,KAAK,GAAG,EAAE,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,GAAG,KAAK,EACjB,iBAAiB,EACjB,GAAG,KAAK,EACoB;IAC5B,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,gCAAgC,EAAE,CAAC;IACrD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,8BAA8B,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEhF,IAAI,aAAa,EAAE,CAAC;QAClB,kDAAkD;QAClD,sDAAsD;QACtD,SAAS,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC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AAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,yBAAyB,CAAC,4BAA4B,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo } from 'react';\nimport clsx from 'clsx';\n\nimport { useAppLayoutToolbarDesignEnabled } from '../app-layout/utils/feature-flags';\nimport { getBaseProps } from '../internal/base-component';\nimport { fireCancelableEvent, fireNonCancelableEvent } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { isDevelopment } from '../internal/is-development';\nimport { createWidgetizedComponent } from '../internal/widgets';\nimport { SideNavigationProps } from './interfaces';\nimport { Header, NavigationItemsList } from './parts';\nimport { checkDuplicateHrefs, generateExpandableItemsMapping } from './util';\n\nimport styles from './styles.css.js';\n\ntype SideNavigationInternalProps = SideNavigationProps & InternalBaseComponentProps;\n\nexport function SideNavigationImplementation({\n header,\n itemsControl,\n activeHref,\n items = [],\n onFollow,\n onChange,\n collapsed = false,\n __internalRootRef,\n ...props\n}: SideNavigationInternalProps) {\n const baseProps = getBaseProps(props);\n const isToolbar = useAppLayoutToolbarDesignEnabled();\n const parentMap = useMemo(() => generateExpandableItemsMapping(items), [items]);\n\n if (isDevelopment) {\n // This code should be wiped in production anyway.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => checkDuplicateHrefs(items), [items]);\n }\n\n const onChangeHandler = useCallback(\n (item: SideNavigationProps.Section | SideNavigationProps.ExpandableLinkGroup, expanded: boolean) => {\n // generateExpandableItemsMapping walks through the entire tree, so we're certain about getting a value.\n fireNonCancelableEvent(onChange, { item, expanded: expanded, expandableParents: parentMap.get(item)! });\n },\n [onChange, parentMap]\n );\n\n const onFollowHandler = useCallback(\n (\n item:\n | SideNavigationProps.Link\n | SideNavigationProps.Header\n | SideNavigationProps.LinkGroup\n | SideNavigationProps.ExpandableLinkGroup,\n sourceEvent: React.SyntheticEvent | Event\n ) => {\n fireCancelableEvent(onFollow, item, sourceEvent);\n },\n [onFollow]\n );\n\n return (\n <div\n {...baseProps}\n className={clsx(styles.root, baseProps.className, isToolbar && styles['with-toolbar'])}\n ref={__internalRootRef}\n >\n {header && (\n <Header\n definition={header}\n activeHref={activeHref}\n fireChange={onChangeHandler}\n fireFollow={onFollowHandler}\n collapsed={collapsed}\n />\n )}\n {!collapsed && itemsControl && <div className={styles['items-control']}>{itemsControl}</div>}\n {items && (\n <div className={styles['list-container']}>\n <NavigationItemsList\n variant=\"root\"\n items={items}\n fireFollow={onFollowHandler}\n fireChange={onChangeHandler}\n activeHref={activeHref}\n collapsed={collapsed}\n />\n </div>\n )}\n </div>\n );\n}\n\nexport const createWidgetizedSideNavigation = createWidgetizedComponent(SideNavigationImplementation);\n"]}
@@ -1,4 +1,4 @@
1
1
  import { SideNavigationProps } from './interfaces';
2
2
  export { SideNavigationProps };
3
- export default function SideNavigation({ items, ...props }: SideNavigationProps): JSX.Element;
3
+ export default function SideNavigation({ items, collapsed, ...props }: SideNavigationProps): JSX.Element;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/side-navigation/index.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAKnD,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,KAAU,EAAE,GAAG,KAAK,EAAE,EAAE,mBAAmB,eAkBnF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/side-navigation/index.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAKnD,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,KAAU,EAAE,SAAiB,EAAE,GAAG,KAAK,EAAE,EAAE,mBAAmB,eAqBtG"}
@@ -7,8 +7,10 @@ import useBaseComponent from '../internal/hooks/use-base-component';
7
7
  import { applyDisplayName } from '../internal/utils/apply-display-name';
8
8
  import { InternalSideNavigation } from './internal';
9
9
  import analyticsSelectors from './analytics-metadata/styles.css.js';
10
- export default function SideNavigation({ items = [], ...props }) {
11
- const internalProps = useBaseComponent('SideNavigation');
10
+ export default function SideNavigation({ items = [], collapsed = false, ...props }) {
11
+ const internalProps = useBaseComponent('SideNavigation', {
12
+ props: { collapsed },
13
+ });
12
14
  const componentAnalyticMetadata = {
13
15
  name: 'awsui.SideNavigation',
14
16
  label: `.${analyticsSelectors['header-link-text']}`,
@@ -16,7 +18,7 @@ export default function SideNavigation({ items = [], ...props }) {
16
18
  activeHref: props.activeHref || '',
17
19
  },
18
20
  };
19
- return (React.createElement(InternalSideNavigation, { ...props, ...internalProps, items: items, ...getAnalyticsMetadataAttribute({ component: componentAnalyticMetadata }) }));
21
+ return (React.createElement(InternalSideNavigation, { ...props, ...internalProps, items: items, collapsed: collapsed, ...getAnalyticsMetadataAttribute({ component: componentAnalyticMetadata }) }));
20
22
  }
21
23
  applyDisplayName(SideNavigation, 'SideNavigation');
22
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/side-navigation/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,YAAY,CAAC;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAGxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,kBAAkB,MAAM,oCAAoC,CAAC;AAIpE,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,KAAK,EAAuB;IAClF,MAAM,aAAa,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAEzD,MAAM,yBAAyB,GAAsD;QACnF,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,IAAI,kBAAkB,CAAC,kBAAkB,CAAC,EAAE;QACnD,UAAU,EAAE;YACV,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,EAAE;SACnC;KACF,CAAC;IACF,OAAO,CACL,oBAAC,sBAAsB,OACjB,KAAK,KACL,aAAa,EACjB,KAAK,EAAE,KAAK,KACR,6BAA6B,CAAC,EAAE,SAAS,EAAE,yBAAyB,EAAE,CAAC,GAC3E,CACH,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n'use client';\nimport React from 'react';\n\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { GeneratedAnalyticsMetadataSideNavigationComponent } from './analytics-metadata/interfaces';\nimport { SideNavigationProps } from './interfaces';\nimport { InternalSideNavigation } from './internal';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\n\nexport { SideNavigationProps };\n\nexport default function SideNavigation({ items = [], ...props }: SideNavigationProps) {\n const internalProps = useBaseComponent('SideNavigation');\n\n const componentAnalyticMetadata: GeneratedAnalyticsMetadataSideNavigationComponent = {\n name: 'awsui.SideNavigation',\n label: `.${analyticsSelectors['header-link-text']}`,\n properties: {\n activeHref: props.activeHref || '',\n },\n };\n return (\n <InternalSideNavigation\n {...props}\n {...internalProps}\n items={items}\n {...getAnalyticsMetadataAttribute({ component: componentAnalyticMetadata })}\n />\n );\n}\n\napplyDisplayName(SideNavigation, 'SideNavigation');\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/side-navigation/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,YAAY,CAAC;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAGxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,kBAAkB,MAAM,oCAAoC,CAAC;AAIpE,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,SAAS,GAAG,KAAK,EAAE,GAAG,KAAK,EAAuB;IACrG,MAAM,aAAa,GAAG,gBAAgB,CAAC,gBAAgB,EAAE;QACvD,KAAK,EAAE,EAAE,SAAS,EAAE;KACrB,CAAC,CAAC;IAEH,MAAM,yBAAyB,GAAsD;QACnF,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,IAAI,kBAAkB,CAAC,kBAAkB,CAAC,EAAE;QACnD,UAAU,EAAE;YACV,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,EAAE;SACnC;KACF,CAAC;IACF,OAAO,CACL,oBAAC,sBAAsB,OACjB,KAAK,KACL,aAAa,EACjB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,KAChB,6BAA6B,CAAC,EAAE,SAAS,EAAE,yBAAyB,EAAE,CAAC,GAC3E,CACH,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n'use client';\nimport React from 'react';\n\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { GeneratedAnalyticsMetadataSideNavigationComponent } from './analytics-metadata/interfaces';\nimport { SideNavigationProps } from './interfaces';\nimport { InternalSideNavigation } from './internal';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\n\nexport { SideNavigationProps };\n\nexport default function SideNavigation({ items = [], collapsed = false, ...props }: SideNavigationProps) {\n const internalProps = useBaseComponent('SideNavigation', {\n props: { collapsed },\n });\n\n const componentAnalyticMetadata: GeneratedAnalyticsMetadataSideNavigationComponent = {\n name: 'awsui.SideNavigation',\n label: `.${analyticsSelectors['header-link-text']}`,\n properties: {\n activeHref: props.activeHref || '',\n },\n };\n return (\n <InternalSideNavigation\n {...props}\n {...internalProps}\n items={items}\n collapsed={collapsed}\n {...getAnalyticsMetadataAttribute({ component: componentAnalyticMetadata })}\n />\n );\n}\n\napplyDisplayName(SideNavigation, 'SideNavigation');\n"]}
@@ -45,6 +45,7 @@ export interface SideNavigationProps extends BaseComponentProps {
45
45
  * - `externalIconAriaLabel` (string) - Adds an aria-label to the external icon.
46
46
  * - `info` (ReactNode) - Enables you to display content next to the link. Although it is technically possible to insert any content,
47
47
  * our UX guidelines allow only to add a Badge and/or a "New" label.
48
+ * - `icon` (ReactNode) - Optional content rendered before the link text. Accepts any React node (for example, an `<Icon />` component or a custom `<svg>`).
48
49
  *
49
50
  * #### Divider
50
51
  * Object that represents a horizontal divider between navigation content.
@@ -76,6 +77,7 @@ export interface SideNavigationProps extends BaseComponentProps {
76
77
  * - `items` (array) - Specifies the content of the section. You can use any valid item from this list.
77
78
  * Although there is no technical limitation to the nesting level,
78
79
  * our UX recommendation is to use only one level.
80
+ * - `icon` (ReactNode) - Optional content rendered before the link group text. Accepts any React node.
79
81
  *
80
82
  * #### ExpandableLinkGroup
81
83
  *
@@ -88,6 +90,7 @@ export interface SideNavigationProps extends BaseComponentProps {
88
90
  * - `items` (array) - Specifies the content of the section. You can use any valid item from this list.
89
91
  * Although there is no technical limitation to the nesting level,
90
92
  * our UX recommendation is to use only one level.
93
+ * - `icon` (ReactNode) - Optional content rendered before the expandable link group text. Accepts any React node.
91
94
  */
92
95
  items?: ReadonlyArray<SideNavigationProps.Item>;
93
96
  /**
@@ -115,11 +118,24 @@ export interface SideNavigationProps extends BaseComponentProps {
115
118
  * upon changing the `activeHref` property, this event isn't raised.
116
119
  */
117
120
  onChange?: NonCancelableEventHandler<SideNavigationProps.ChangeDetail>;
121
+ /**
122
+ * If true, the navigation is rendered in a compact, icon-only state:
123
+ * - Item text labels and the header title are hidden.
124
+ * - Section, `Section group`, `Link group`, and `Expandable link group`
125
+ * children are not rendered.
126
+ * - `Items control` is not rendered.
127
+ * - Items without an `icon` are not rendered. Provide an icon for any
128
+ * item that should remain visible while collapsed.
129
+ *
130
+ * @defaultValue false
131
+ */
132
+ collapsed?: boolean;
118
133
  }
119
134
  export declare namespace SideNavigationProps {
120
135
  interface Logo {
121
- src: string;
136
+ src?: string;
122
137
  alt?: string;
138
+ svg?: React.ReactNode;
123
139
  }
124
140
  interface Header {
125
141
  text?: string;
@@ -136,6 +152,7 @@ export declare namespace SideNavigationProps {
136
152
  external?: boolean;
137
153
  externalIconAriaLabel?: string;
138
154
  info?: React.ReactNode;
155
+ icon?: React.ReactNode;
139
156
  }
140
157
  interface Section {
141
158
  type: 'section';
@@ -154,6 +171,7 @@ export declare namespace SideNavigationProps {
154
171
  href: string;
155
172
  info?: React.ReactNode;
156
173
  items: ReadonlyArray<Item>;
174
+ icon?: React.ReactNode;
157
175
  }
158
176
  interface ExpandableLinkGroup {
159
177
  type: 'expandable-link-group';
@@ -161,6 +179,7 @@ export declare namespace SideNavigationProps {
161
179
  href: string;
162
180
  items: ReadonlyArray<Item>;
163
181
  defaultExpanded?: boolean;
182
+ icon?: React.ReactNode;
164
183
  }
165
184
  type Item = Divider | Link | Section | LinkGroup | ExpandableLinkGroup | SectionGroup;
166
185
  interface ChangeDetail {
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/side-navigation/interfaces.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE7G,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC;IAEpC;;QAEI;IACJ,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE/B;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAEhD;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,sBAAsB,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAEpE;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,EAAE,yBAAyB,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;CACxE;AAED,yBAAiB,mBAAmB,CAAC;IACnC,UAAiB,IAAI;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,CAAC,EAAE,MAAM,CAAC;KACd;IACD,UAAiB,MAAM;QACrB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,IAAI,CAAC;KACb;IAED,UAAiB,OAAO;QACtB,IAAI,EAAE,SAAS,CAAC;KACjB;IAED,UAAiB,IAAI;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,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,CAAC,IAAI,CAAC,CAAC;QAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;KACxB;IAED,KAAY,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,GAAG,mBAAmB,GAAG,YAAY,CAAC;IAE7F,UAAiB,YAAY;QAC3B,IAAI,EAAE,OAAO,GAAG,mBAAmB,CAAC;QACpC,QAAQ,EAAE,OAAO,CAAC;QAClB,iBAAiB,EAAE,aAAa,CAAC,OAAO,GAAG,mBAAmB,CAAC,CAAC;KACjE;IAED,UAAiB,YAAa,SAAQ,oBAAoB;QACxD,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,uBAAuB,GAAG,gBAAgB,CAAC;QAC1E,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;KACxB;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/side-navigation/interfaces.tsx"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { BaseNavigationDetail, CancelableEventHandler, NonCancelableEventHandler } from '../internal/events';\n\nexport interface SideNavigationProps extends BaseComponentProps {\n /**\n * Controls the header that appears at the top of the navigation component.\n *\n * It contains the following:\n * - `text` (string) - Specifies the header text.\n * - `href` (string) - Specifies the `href` that the header links to.\n * - `logo` (object) - Specifies a logo image.\n */\n header?: SideNavigationProps.Header;\n\n /**\n * A slot located below the header and above the items.\n **/\n itemsControl?: React.ReactNode;\n\n /**\n * Specifies the `href` of the currently active link.\n * All items within the navigation with a matching `href` are highlighted.\n *\n * `Sections` and `Expandable Page Groups` that contain a highlighted item\n * are automatically expanded, unless their definitions have the `defaultExpanded`\n * property explicitly set to `false`.\n */\n activeHref?: string;\n\n /**\n * Specifies the items to be displayed in the navigation.\n * Allowed objects are: `Link`, `Divider`, `Section`, `LinkGroup` and `ExpandableLinkGroup`.\n *\n * You can inject extra properties (for example, an ID)\n * in order to identify the item when it's used in an event `detail`\n * (for more information, see the events section below).\n *\n * #### Link\n * Object that represents an anchor in the navigation.\n * Links are rendered as `<a>` tags.\n * - `type` - `'link'`.\n * - `text` (string) - Specifies the link text.\n * - `href` (string) - Specifies the `href` of the link.\n * - `external` (boolean) - Determines whether to display an external link icon next to the link.\n * If set to `true`, an external link icon appears next to the link.\n * The anchor also has the attributes `target=\"_blank\"` and `rel=\"noopener\"`.\n * Additionally, the `activeHref` property won't be modified when a user chooses the link.\n * - `externalIconAriaLabel` (string) - Adds an aria-label to the external icon.\n * - `info` (ReactNode) - Enables you to display content next to the link. Although it is technically possible to insert any content,\n * our UX guidelines allow only to add a Badge and/or a \"New\" label.\n *\n * #### Divider\n * Object that represents a horizontal divider between navigation content.\n * It contains `type`: `'divider'` only.\n *\n * #### Section\n * Object that represents a section within the navigation.\n * - `type`: `'section'`.\n * - `text` (string) - Specifies the text to display as a title of the section.\n * - `defaultExpanded` (boolean) - Determines whether the section should be expanded by default. Default value is `true`.\n * - `items` (array) - Specifies the content of the section. You can use any valid item from this list.\n * Although there is no technical limitation to the nesting level,\n * our UX recommendation is to use only one level.\n *\n * #### Section Group\n * Aggregates a set of items that are conceptually related to each other, and can be displayed under a single heading to provide further organization.\n * You can nest sections, links, link groups and expandable link groups within a section group depending on your information architecture needs.\n * - `type`: `'section-group'`.\n * - `title` (string) - Specifies the text to display as a title of the section group.\n * - `items` (array) - Specifies the content of the section header group. You can use `Section`, `Link`, `LinkGroup`, `ExpandableLinkGroup`.\n *\n * #### LinkGroup\n * Object that represents a group of links.\n * - `type`: `'link-group'`.\n * - `text` (string) - Specifies the text of the group link.\n * - `href` (string) - Specifies the `href` of the group link.\n * - `info` (ReactNode) - Enables you to display content next to the link. Although it is technically possible to insert any content,\n * our UX guidelines allow only to add a Badge and/or a \"New\" label.\n * - `items` (array) - Specifies the content of the section. You can use any valid item from this list.\n * Although there is no technical limitation to the nesting level,\n * our UX recommendation is to use only one level.\n *\n * #### ExpandableLinkGroup\n *\n * Object that represents an expandable group of links.\n * - `type`: `'expandable-link-group'`.\n * - `text` (string) - Specifies the text of the group link.\n * - `href` (string) - Specifies the `href` of the group link.\n * - `defaultExpanded` (boolean) - Specifies whether the group should be expanded by default.\n * If not explicitly set, the group is collapsed by default, unless one of the nested links is active.\n * - `items` (array) - Specifies the content of the section. You can use any valid item from this list.\n * Although there is no technical limitation to the nesting level,\n * our UX recommendation is to use only one level.\n */\n items?: ReadonlyArray<SideNavigationProps.Item>;\n\n /**\n * Fired when an anchor is clicked without any modifier (that is, CTRL, ALT, SHIFT).\n * The event `detail` contains a definition of the clicked item.\n * Use this event to prevent default browser navigation (by calling `preventDefault` method)\n * and branch your own routing.\n *\n * If the event is prevented the `activeHref` property won't be automatically set\n * to the href of the clicked item so you'll have to do it yourself.\n */\n onFollow?: CancelableEventHandler<SideNavigationProps.FollowDetail>;\n\n /**\n * Fired when the expansion state of `Section` or `ExpandablePageGroup` items changes\n * as a result of a user interaction. The event `detail` contains an object with information about the changed item.\n *\n * - `item` (object) - Specifies the item that was changed.\n * - `expanded` (boolean) - Specifies whether the item is expanded or not.\n * - `expandableParents` (array) - A list of parent items that have a type of `Section`\n * or `ExpandablePageGroup`. Use this `expandableParents` array to set their expanded\n * state to `true` if you want your data model to keep track of the current state\n * of the navigation items.\n *\n * Note: If the expansion is a result of the activation of a nested link\n * upon changing the `activeHref` property, this event isn't raised.\n */\n onChange?: NonCancelableEventHandler<SideNavigationProps.ChangeDetail>;\n}\n\nexport namespace SideNavigationProps {\n export interface Logo {\n src: string;\n alt?: string;\n }\n export interface Header {\n text?: string;\n href: string;\n logo?: Logo;\n }\n\n export interface Divider {\n type: 'divider';\n }\n\n export interface Link {\n type: 'link';\n text: string;\n href: string;\n external?: boolean;\n externalIconAriaLabel?: string;\n info?: React.ReactNode;\n }\n\n export interface Section {\n type: 'section';\n text: string;\n items: ReadonlyArray<Item>;\n defaultExpanded?: boolean;\n }\n\n export interface SectionGroup {\n type: 'section-group';\n title: string;\n items: ReadonlyArray<Section | Link | LinkGroup | ExpandableLinkGroup>;\n }\n export interface LinkGroup {\n type: 'link-group';\n text: string;\n href: string;\n info?: React.ReactNode;\n items: ReadonlyArray<Item>;\n }\n\n export interface ExpandableLinkGroup {\n type: 'expandable-link-group';\n text: string;\n href: string;\n items: ReadonlyArray<Item>;\n defaultExpanded?: boolean;\n }\n\n export type Item = Divider | Link | Section | LinkGroup | ExpandableLinkGroup | SectionGroup;\n\n export interface ChangeDetail {\n item: Section | ExpandableLinkGroup;\n expanded: boolean;\n expandableParents: ReadonlyArray<Section | ExpandableLinkGroup>;\n }\n\n export interface FollowDetail extends BaseNavigationDetail {\n text?: string;\n href: string;\n type?: 'link' | 'link-group' | 'expandable-link-group' | 'section-header';\n info?: React.ReactNode;\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/side-navigation/interfaces.tsx"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { BaseNavigationDetail, CancelableEventHandler, NonCancelableEventHandler } from '../internal/events';\n\nexport interface SideNavigationProps extends BaseComponentProps {\n /**\n * Controls the header that appears at the top of the navigation component.\n *\n * It contains the following:\n * - `text` (string) - Specifies the header text.\n * - `href` (string) - Specifies the `href` that the header links to.\n * - `logo` (object) - Specifies a logo image.\n */\n header?: SideNavigationProps.Header;\n\n /**\n * A slot located below the header and above the items.\n **/\n itemsControl?: React.ReactNode;\n\n /**\n * Specifies the `href` of the currently active link.\n * All items within the navigation with a matching `href` are highlighted.\n *\n * `Sections` and `Expandable Page Groups` that contain a highlighted item\n * are automatically expanded, unless their definitions have the `defaultExpanded`\n * property explicitly set to `false`.\n */\n activeHref?: string;\n\n /**\n * Specifies the items to be displayed in the navigation.\n * Allowed objects are: `Link`, `Divider`, `Section`, `LinkGroup` and `ExpandableLinkGroup`.\n *\n * You can inject extra properties (for example, an ID)\n * in order to identify the item when it's used in an event `detail`\n * (for more information, see the events section below).\n *\n * #### Link\n * Object that represents an anchor in the navigation.\n * Links are rendered as `<a>` tags.\n * - `type` - `'link'`.\n * - `text` (string) - Specifies the link text.\n * - `href` (string) - Specifies the `href` of the link.\n * - `external` (boolean) - Determines whether to display an external link icon next to the link.\n * If set to `true`, an external link icon appears next to the link.\n * The anchor also has the attributes `target=\"_blank\"` and `rel=\"noopener\"`.\n * Additionally, the `activeHref` property won't be modified when a user chooses the link.\n * - `externalIconAriaLabel` (string) - Adds an aria-label to the external icon.\n * - `info` (ReactNode) - Enables you to display content next to the link. Although it is technically possible to insert any content,\n * our UX guidelines allow only to add a Badge and/or a \"New\" label.\n * - `icon` (ReactNode) - Optional content rendered before the link text. Accepts any React node (for example, an `<Icon />` component or a custom `<svg>`).\n *\n * #### Divider\n * Object that represents a horizontal divider between navigation content.\n * It contains `type`: `'divider'` only.\n *\n * #### Section\n * Object that represents a section within the navigation.\n * - `type`: `'section'`.\n * - `text` (string) - Specifies the text to display as a title of the section.\n * - `defaultExpanded` (boolean) - Determines whether the section should be expanded by default. Default value is `true`.\n * - `items` (array) - Specifies the content of the section. You can use any valid item from this list.\n * Although there is no technical limitation to the nesting level,\n * our UX recommendation is to use only one level.\n *\n * #### Section Group\n * Aggregates a set of items that are conceptually related to each other, and can be displayed under a single heading to provide further organization.\n * You can nest sections, links, link groups and expandable link groups within a section group depending on your information architecture needs.\n * - `type`: `'section-group'`.\n * - `title` (string) - Specifies the text to display as a title of the section group.\n * - `items` (array) - Specifies the content of the section header group. You can use `Section`, `Link`, `LinkGroup`, `ExpandableLinkGroup`.\n *\n * #### LinkGroup\n * Object that represents a group of links.\n * - `type`: `'link-group'`.\n * - `text` (string) - Specifies the text of the group link.\n * - `href` (string) - Specifies the `href` of the group link.\n * - `info` (ReactNode) - Enables you to display content next to the link. Although it is technically possible to insert any content,\n * our UX guidelines allow only to add a Badge and/or a \"New\" label.\n * - `items` (array) - Specifies the content of the section. You can use any valid item from this list.\n * Although there is no technical limitation to the nesting level,\n * our UX recommendation is to use only one level.\n * - `icon` (ReactNode) - Optional content rendered before the link group text. Accepts any React node.\n *\n * #### ExpandableLinkGroup\n *\n * Object that represents an expandable group of links.\n * - `type`: `'expandable-link-group'`.\n * - `text` (string) - Specifies the text of the group link.\n * - `href` (string) - Specifies the `href` of the group link.\n * - `defaultExpanded` (boolean) - Specifies whether the group should be expanded by default.\n * If not explicitly set, the group is collapsed by default, unless one of the nested links is active.\n * - `items` (array) - Specifies the content of the section. You can use any valid item from this list.\n * Although there is no technical limitation to the nesting level,\n * our UX recommendation is to use only one level.\n * - `icon` (ReactNode) - Optional content rendered before the expandable link group text. Accepts any React node.\n */\n items?: ReadonlyArray<SideNavigationProps.Item>;\n\n /**\n * Fired when an anchor is clicked without any modifier (that is, CTRL, ALT, SHIFT).\n * The event `detail` contains a definition of the clicked item.\n * Use this event to prevent default browser navigation (by calling `preventDefault` method)\n * and branch your own routing.\n *\n * If the event is prevented the `activeHref` property won't be automatically set\n * to the href of the clicked item so you'll have to do it yourself.\n */\n onFollow?: CancelableEventHandler<SideNavigationProps.FollowDetail>;\n\n /**\n * Fired when the expansion state of `Section` or `ExpandablePageGroup` items changes\n * as a result of a user interaction. The event `detail` contains an object with information about the changed item.\n *\n * - `item` (object) - Specifies the item that was changed.\n * - `expanded` (boolean) - Specifies whether the item is expanded or not.\n * - `expandableParents` (array) - A list of parent items that have a type of `Section`\n * or `ExpandablePageGroup`. Use this `expandableParents` array to set their expanded\n * state to `true` if you want your data model to keep track of the current state\n * of the navigation items.\n *\n * Note: If the expansion is a result of the activation of a nested link\n * upon changing the `activeHref` property, this event isn't raised.\n */\n onChange?: NonCancelableEventHandler<SideNavigationProps.ChangeDetail>;\n\n /**\n * If true, the navigation is rendered in a compact, icon-only state:\n * - Item text labels and the header title are hidden.\n * - Section, `Section group`, `Link group`, and `Expandable link group`\n * children are not rendered.\n * - `Items control` is not rendered.\n * - Items without an `icon` are not rendered. Provide an icon for any\n * item that should remain visible while collapsed.\n *\n * @defaultValue false\n */\n collapsed?: boolean;\n}\n\nexport namespace SideNavigationProps {\n export interface Logo {\n src?: string;\n alt?: string;\n svg?: React.ReactNode;\n }\n export interface Header {\n text?: string;\n href: string;\n logo?: Logo;\n }\n\n export interface Divider {\n type: 'divider';\n }\n\n export interface Link {\n type: 'link';\n text: string;\n href: string;\n external?: boolean;\n externalIconAriaLabel?: string;\n info?: React.ReactNode;\n icon?: React.ReactNode;\n }\n\n export interface Section {\n type: 'section';\n text: string;\n items: ReadonlyArray<Item>;\n defaultExpanded?: boolean;\n }\n\n export interface SectionGroup {\n type: 'section-group';\n title: string;\n items: ReadonlyArray<Section | Link | LinkGroup | ExpandableLinkGroup>;\n }\n export interface LinkGroup {\n type: 'link-group';\n text: string;\n href: string;\n info?: React.ReactNode;\n items: ReadonlyArray<Item>;\n icon?: React.ReactNode;\n }\n\n export interface ExpandableLinkGroup {\n type: 'expandable-link-group';\n text: string;\n href: string;\n items: ReadonlyArray<Item>;\n defaultExpanded?: boolean;\n icon?: React.ReactNode;\n }\n\n export type Item = Divider | Link | Section | LinkGroup | ExpandableLinkGroup | SectionGroup;\n\n export interface ChangeDetail {\n item: Section | ExpandableLinkGroup;\n expanded: boolean;\n expandableParents: ReadonlyArray<Section | ExpandableLinkGroup>;\n }\n\n export interface FollowDetail extends BaseNavigationDetail {\n text?: string;\n href: string;\n type?: 'link' | 'link-group' | 'expandable-link-group' | 'section-header';\n info?: React.ReactNode;\n }\n}\n"]}
@@ -5,15 +5,16 @@ interface BaseItemComponentProps {
5
5
  fireChange: (item: SideNavigationProps.Section | SideNavigationProps.ExpandableLinkGroup, expanded: boolean) => void;
6
6
  fireFollow: (item: SideNavigationProps.Link | SideNavigationProps.Header | SideNavigationProps.LinkGroup | SideNavigationProps.ExpandableLinkGroup, event: React.SyntheticEvent | Event) => void;
7
7
  position?: string;
8
+ collapsed?: boolean;
8
9
  }
9
10
  interface HeaderProps extends BaseItemComponentProps {
10
11
  definition: SideNavigationProps.Header;
11
12
  }
12
- export declare function Header({ definition, activeHref, fireFollow }: HeaderProps): JSX.Element;
13
+ export declare function Header({ definition, activeHref, fireFollow, collapsed }: HeaderProps): JSX.Element;
13
14
  interface NavigationItemsListProps extends BaseItemComponentProps {
14
15
  items: ReadonlyArray<SideNavigationProps.Item>;
15
16
  variant: 'section' | 'section-group' | 'link-group' | 'expandable-link-group' | 'root';
16
17
  }
17
- export declare function NavigationItemsList({ items, variant, activeHref, fireChange, fireFollow, position, }: NavigationItemsListProps): JSX.Element;
18
+ export declare function NavigationItemsList({ items, variant, activeHref, fireChange, fireFollow, position, collapsed, }: NavigationItemsListProps): JSX.Element;
18
19
  export {};
19
20
  //# sourceMappingURL=parts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../../../src/side-navigation/parts.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA+D,MAAM,OAAO,CAAC;AAcpF,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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AC,MAAM,CAAC;CACxC;AAED,wBAAgB,MAAM,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,WAAW,eA4DpF;AAED,UAAU,wBAAyB,SAAQ,sBAAsB;IAC/D,KAAK,EAAE,aAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO,EAAE,SAAS,GAAG,eAAe,GAAG,YAAY,GAAG,uBAAuB,GAAG,MAAM,CAAC;CACxF;AAQD,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,OAAO,EACP,UAAU,EACV,UAAU,EACV,UAAU,EACV,QAAa,EACb,SAAS,GACV,EAAE,wBAAwB,eA0Q1B"}
@@ -1,6 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
3
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
4
  import clsx from 'clsx';
5
5
  import { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
6
6
  import InternalBox from '../box/internal';
@@ -10,11 +10,12 @@ import InternalIcon from '../icon/internal';
10
10
  import { isPlainLeftClick } from '../internal/events';
11
11
  import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
12
12
  import { checkSafeUrl } from '../internal/utils/check-safe-url';
13
+ import Tooltip from '../tooltip/internal';
13
14
  import { hasActiveLink } from './util';
14
15
  import analyticsSelectors from './analytics-metadata/styles.css.js';
15
16
  import styles from './styles.css.js';
16
17
  import testUtilStyles from './test-classes/styles.css.js';
17
- export function Header({ definition, activeHref, fireFollow }) {
18
+ export function Header({ definition, activeHref, fireFollow, collapsed }) {
18
19
  checkSafeUrl('SideNavigation', definition.href);
19
20
  const onClick = useCallback((event) => {
20
21
  if (isPlainLeftClick(event)) {
@@ -31,15 +32,18 @@ export function Header({ definition, activeHref, fireFollow }) {
31
32
  },
32
33
  };
33
34
  return (React.createElement(React.Fragment, null,
34
- React.createElement("h2", { className: styles.header },
35
- React.createElement("a", { href: definition.href, className: clsx(styles['header-link'], { [styles['header-link--has-logo']]: !!definition.logo }), "aria-current": definition.href === activeHref ? 'page' : undefined, onClick: onClick, ...getAnalyticsMetadataAttribute(clickActionAnalyticsMetadata) },
36
- definition.logo && (React.createElement("img", { className: clsx(styles['header-logo'], {
37
- [styles['header-logo--stretched']]: !definition.text,
38
- }), ...definition.logo })),
39
- React.createElement("span", { className: clsx(styles['header-link-text'], analyticsSelectors['header-link-text']) }, definition.text))),
35
+ React.createElement("h2", { className: clsx(styles.header, collapsed && styles['header--collapsed']) },
36
+ React.createElement("a", { href: definition.href, className: clsx(styles['header-link'], { [styles['header-link--has-logo']]: !!definition.logo }), "aria-current": definition.href === activeHref ? 'page' : undefined, "aria-label": collapsed ? definition.text : undefined, onClick: onClick, ...getAnalyticsMetadataAttribute(clickActionAnalyticsMetadata) },
37
+ definition.logo &&
38
+ (definition.logo.svg ? (React.createElement("span", { className: clsx(styles['header-logo'], {
39
+ [styles['header-logo--stretched']]: !definition.text || collapsed,
40
+ }) }, definition.logo.svg)) : (React.createElement("img", { className: clsx(styles['header-logo'], {
41
+ [styles['header-logo--stretched']]: !definition.text || collapsed,
42
+ }), src: definition.logo.src, alt: definition.logo.alt }))),
43
+ !collapsed && (React.createElement("span", { className: clsx(styles['header-link-text'], analyticsSelectors['header-link-text']) }, definition.text)))),
40
44
  React.createElement(Divider, { isPresentational: true, variant: "header" })));
41
45
  }
42
- export function NavigationItemsList({ items, variant, activeHref, fireChange, fireFollow, position = '', }) {
46
+ export function NavigationItemsList({ items, variant, activeHref, fireChange, fireFollow, position = '', collapsed, }) {
43
47
  const lists = [];
44
48
  let currentListIndex = 0;
45
49
  lists[currentListIndex] = {
@@ -50,12 +54,54 @@ export function NavigationItemsList({ items, variant, activeHref, fireChange, fi
50
54
  var _a, _b, _c, _d, _e;
51
55
  const itemid = index + 1;
52
56
  const itemPosition = `${position ? `${position},` : ''}${itemid}`;
57
+ // Renders icon-bearing children of a container item as a collapsed group.
58
+ // The inner <ul> carries the group label so list semantics are preserved
59
+ // for screen readers even when the visual header is hidden.
60
+ function pushCollapsedGroup(children, label) {
61
+ var _a;
62
+ const iconChildren = children.filter(child => child.icon);
63
+ if (iconChildren.length === 0) {
64
+ return;
65
+ }
66
+ const groupElements = iconChildren.map((child, childIndex) => {
67
+ const childPosition = `${position ? `${position},` : ''}${itemid},${childIndex + 1}`;
68
+ return (React.createElement("li", { key: childPosition, className: clsx(styles['list-item'], styles['list-item--collapsed']) },
69
+ React.createElement(Link, { definition: child, activeHref: activeHref, fireFollow: fireFollow, fireChange: fireChange, position: childPosition, collapsed: collapsed })));
70
+ });
71
+ const prevItem = index > 0 ? items[index - 1] : null;
72
+ const nextItem = index < items.length - 1 ? items[index + 1] : null;
73
+ (_a = lists[currentListIndex].items) === null || _a === void 0 ? void 0 : _a.push({
74
+ element: (React.createElement("li", { key: `group-${itemid}`, className: clsx(styles['list-item--group'], (prevItem === null || prevItem === void 0 ? void 0 : prevItem.type) === 'divider' && styles['list-item--group-no-padding-start'], (nextItem === null || nextItem === void 0 ? void 0 : nextItem.type) === 'divider' && styles['list-item--group-no-padding-end']) },
75
+ React.createElement("ul", { className: styles['list--collapsed-group'], "aria-label": label }, groupElements))),
76
+ });
77
+ }
78
+ // In collapsed mode, flatten container items to show only icon-bearing children.
79
+ if (collapsed && (item.type === 'expandable-link-group' || item.type === 'link-group') && !item.icon) {
80
+ const group = item;
81
+ pushCollapsedGroup(group.items, group.text);
82
+ return;
83
+ }
84
+ if (collapsed && (item.type === 'section' || item.type === 'section-group')) {
85
+ const sectionLabel = item.type === 'section'
86
+ ? item.text
87
+ : item.title;
88
+ // Section-groups may contain nested sections — flatten one level.
89
+ const childItems = item.type === 'section'
90
+ ? item.items
91
+ : item.items.flatMap(child => child.type === 'section' ? child.items : [child]);
92
+ pushCollapsedGroup(childItems, sectionLabel);
93
+ return;
94
+ }
95
+ if (collapsed && item.type !== 'divider' && !item.icon) {
96
+ return;
97
+ }
53
98
  switch (item.type) {
54
99
  case 'divider': {
55
100
  const dividerIndex = lists.length;
56
101
  lists[dividerIndex] = {
102
+ listVariant: variant,
57
103
  element: (React.createElement("div", { "data-itemid": `item-${itemid}` },
58
- React.createElement(Divider, { variant: "default" }))),
104
+ React.createElement(Divider, { variant: "default", collapsed: collapsed }))),
59
105
  };
60
106
  currentListIndex = lists.length;
61
107
  lists[currentListIndex] = {
@@ -66,61 +112,103 @@ export function NavigationItemsList({ items, variant, activeHref, fireChange, fi
66
112
  }
67
113
  case 'link': {
68
114
  (_a = lists[currentListIndex].items) === null || _a === void 0 ? void 0 : _a.push({
69
- element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: styles['list-item'] },
70
- React.createElement(Link, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow, position: itemPosition }))),
115
+ element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: clsx(styles['list-item'], collapsed && styles['list-item--collapsed'], item.info && styles['list-item--info']) },
116
+ React.createElement(Link, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow, position: itemPosition, collapsed: collapsed }))),
71
117
  });
72
118
  return;
73
119
  }
74
120
  case 'section': {
75
121
  (_b = lists[currentListIndex].items) === null || _b === void 0 ? void 0 : _b.push({
76
- element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: styles['list-item'] },
77
- React.createElement(Section, { definition: item, activeHref: activeHref, variant: variant, fireChange: fireChange, fireFollow: fireFollow, position: itemPosition }))),
122
+ element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: clsx(styles['list-item'], collapsed && styles['list-item--collapsed']) },
123
+ React.createElement(Section, { definition: item, activeHref: activeHref, variant: variant, fireChange: fireChange, fireFollow: fireFollow, position: itemPosition, collapsed: collapsed }))),
78
124
  });
79
125
  return;
80
126
  }
81
127
  case 'section-group': {
82
128
  (_c = lists[currentListIndex].items) === null || _c === void 0 ? void 0 : _c.push({
83
- element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: styles['list-item'] },
84
- React.createElement(SectionGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow, position: itemPosition }))),
129
+ element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: clsx(styles['list-item'], collapsed && styles['list-item--collapsed']) },
130
+ React.createElement(SectionGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow, position: itemPosition, collapsed: collapsed }))),
85
131
  });
86
132
  return;
87
133
  }
88
134
  case 'link-group': {
89
135
  (_d = lists[currentListIndex].items) === null || _d === void 0 ? void 0 : _d.push({
90
- element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: styles['list-item'] },
91
- React.createElement(LinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow, position: itemPosition }))),
136
+ element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: clsx(styles['list-item'], collapsed && styles['list-item--collapsed'], item.info && styles['list-item--info']) },
137
+ React.createElement(LinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow, position: itemPosition, collapsed: collapsed }))),
92
138
  });
93
139
  return;
94
140
  }
95
141
  case 'expandable-link-group': {
96
142
  (_e = lists[currentListIndex].items) === null || _e === void 0 ? void 0 : _e.push({
97
- element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: styles['list-item'] },
98
- React.createElement(ExpandableLinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow, variant: variant, position: itemPosition }))),
143
+ element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: clsx(styles['list-item'], collapsed && styles['list-item--collapsed']) },
144
+ React.createElement(ExpandableLinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow, variant: variant, position: itemPosition, collapsed: collapsed }))),
99
145
  });
100
146
  return;
101
147
  }
102
148
  }
103
149
  });
104
- return (React.createElement(React.Fragment, null, lists.map((list, index) => {
150
+ // In collapsed mode, skip empty item segments and deduplicate consecutive dividers.
151
+ const filteredLists = collapsed
152
+ ? lists.filter((list, index) => {
153
+ if (list.items) {
154
+ return list.items.length > 0;
155
+ }
156
+ // Divider — skip if preceded by another divider or empty segment, or followed by nothing.
157
+ const prevVisible = lists
158
+ .slice(0, index)
159
+ .reverse()
160
+ .find(l => !l.items || l.items.length > 0);
161
+ const nextVisible = lists.slice(index + 1).find(l => !l.items || l.items.length > 0);
162
+ return ((!prevVisible || (prevVisible.items !== undefined && prevVisible.items.length > 0)) &&
163
+ nextVisible !== undefined &&
164
+ (nextVisible.items === undefined || nextVisible.items.length > 0));
165
+ })
166
+ : lists;
167
+ return (React.createElement(React.Fragment, null, filteredLists.map((list, index) => {
105
168
  if (!list.items || list.items.length === 0) {
106
169
  return (React.createElement("div", { key: `hr-${index}`, className: clsx(styles.list, styles[`list-variant-${variant}`], {
107
170
  [styles['list-variant-root--first']]: list.listVariant === 'root' && index === 0,
171
+ [styles['list-variant-root--collapsed']]: list.listVariant === 'root' && collapsed,
108
172
  }) }, list.element));
109
173
  }
110
174
  else {
111
175
  return (React.createElement("ul", { key: `list-${index}`, className: clsx(styles.list, styles[`list-variant-${list.listVariant}`], {
112
176
  [styles['list-variant-root--first']]: list.listVariant === 'root' && index === 0,
177
+ [styles['list-variant-root--collapsed']]: list.listVariant === 'root' && collapsed,
113
178
  }) }, list.items.map(item => item.element)));
114
179
  }
115
180
  })));
116
181
  }
117
- function Divider({ variant = 'default', isPresentational = false }) {
118
- return (React.createElement("hr", { className: clsx(styles.divider, styles[`divider-${variant}`]), role: isPresentational ? 'presentation' : undefined }));
182
+ function Divider({ variant = 'default', isPresentational = false, collapsed }) {
183
+ return (React.createElement("hr", { className: clsx(styles.divider, styles[`divider-${variant}`], collapsed && styles['divider--collapsed']), role: isPresentational ? 'presentation' : undefined }));
184
+ }
185
+ const ItemIcon = React.forwardRef(function ItemIcon({ icon, collapsed, className, ...rest }, ref) {
186
+ if (!icon) {
187
+ return null;
188
+ }
189
+ return (React.createElement("span", { ref: ref, className: clsx(styles['item-icon'], testUtilStyles['item-icon'], collapsed && styles['item-icon--collapsed'], className), ...rest }, icon));
190
+ });
191
+ // Manages a tooltip that shows the item's text label on focus or hover.
192
+ // Used in the collapsed state, where the visible labels are hidden, to give
193
+ // pointer and keyboard users a way to identify each item without relying on
194
+ // their browser's native title popup.
195
+ function useCollapsedTooltip(label) {
196
+ const [show, setShow] = useState(false);
197
+ const triggerRef = useRef(null);
198
+ const triggerProps = {
199
+ onFocus: () => setShow(true),
200
+ onBlur: () => setShow(false),
201
+ onMouseEnter: () => setShow(true),
202
+ onMouseLeave: () => setShow(false),
203
+ };
204
+ const tooltip = show ? (React.createElement(Tooltip, { getTrack: () => triggerRef.current, content: label, position: "right", onEscape: () => setShow(false) })) : null;
205
+ return { triggerRef, triggerProps, tooltip };
119
206
  }
120
- function Link({ definition, activeHref, fireFollow, position }) {
207
+ function Link({ definition, activeHref, fireFollow, position, collapsed }) {
121
208
  checkSafeUrl('SideNavigation', definition.href);
122
209
  const isActive = definition.href === activeHref;
123
210
  const i18n = useInternalI18n('link');
211
+ const collapsedTooltip = useCollapsedTooltip(definition.text);
124
212
  const onClick = useCallback((event) => {
125
213
  if (isPlainLeftClick(event)) {
126
214
  fireFollow(definition, event);
@@ -137,13 +225,19 @@ function Link({ definition, activeHref, fireFollow, position }) {
137
225
  };
138
226
  const renderedExternalIconAriaLabel = i18n('externalIconAriaLabel', definition.externalIconAriaLabel);
139
227
  return (React.createElement(React.Fragment, null,
140
- React.createElement("a", { href: definition.href, className: clsx(styles.link, { [styles['link-active']]: isActive }), target: definition.external ? '_blank' : undefined, rel: definition.external ? 'noopener noreferrer' : undefined, "aria-current": definition.href === activeHref ? 'page' : undefined, onClick: onClick, ...getAnalyticsMetadataAttribute(clickActionAnalyticsMetadata) },
141
- React.createElement("span", { className: analyticsSelectors['link-text'] }, definition.text),
142
- definition.external && (React.createElement("span", { "aria-label": renderedExternalIconAriaLabel, role: renderedExternalIconAriaLabel ? 'img' : undefined },
143
- React.createElement(InternalIcon, { name: "external", className: styles['external-icon'] })))),
144
- definition.info && React.createElement("span", { className: clsx(styles.info, testUtilStyles.info) }, definition.info)));
228
+ React.createElement("a", { ref: collapsed ? collapsedTooltip.triggerRef : undefined, href: definition.href, className: clsx(styles.link, {
229
+ [styles['link-active']]: isActive,
230
+ [styles['link--collapsed']]: collapsed,
231
+ }), target: definition.external ? '_blank' : undefined, rel: definition.external ? 'noopener noreferrer' : undefined, "aria-current": definition.href === activeHref ? 'page' : undefined, "aria-label": collapsed ? definition.text : undefined, onClick: onClick, ...(collapsed ? collapsedTooltip.triggerProps : {}), ...getAnalyticsMetadataAttribute(clickActionAnalyticsMetadata) },
232
+ React.createElement(ItemIcon, { icon: definition.icon, collapsed: collapsed, "aria-hidden": collapsed ? true : undefined }),
233
+ !collapsed && (React.createElement("span", { className: styles['link-text-wrapper'] },
234
+ React.createElement("span", { className: analyticsSelectors['link-text'] }, definition.text),
235
+ definition.external && (React.createElement("span", { "aria-label": renderedExternalIconAriaLabel, role: renderedExternalIconAriaLabel ? 'img' : undefined },
236
+ React.createElement(InternalIcon, { name: "external", className: styles['external-icon'] }))))),
237
+ collapsed && collapsedTooltip.tooltip),
238
+ !collapsed && definition.info && (React.createElement("span", { className: clsx(styles.info, testUtilStyles.info) }, definition.info))));
145
239
  }
146
- function Section({ definition, activeHref, fireFollow, fireChange, variant, position }) {
240
+ function Section({ definition, activeHref, fireFollow, fireChange, variant, position, collapsed }) {
147
241
  var _a;
148
242
  const [expanded, setExpanded] = useState((_a = definition.defaultExpanded) !== null && _a !== void 0 ? _a : true);
149
243
  const isVisualRefresh = useVisualRefresh();
@@ -155,21 +249,34 @@ function Section({ definition, activeHref, fireFollow, fireChange, variant, posi
155
249
  var _a;
156
250
  setExpanded((_a = definition.defaultExpanded) !== null && _a !== void 0 ? _a : true);
157
251
  }, [definition]);
158
- return (React.createElement(InternalExpandableSection, { variant: "footer", expanded: expanded, onChange: onExpandedChange, className: clsx(styles.section, variant === 'section-group' && styles['section--no-ident'], isVisualRefresh && styles.refresh), headerText: definition.text },
252
+ if (collapsed) {
253
+ return null;
254
+ }
255
+ const isInSectionGroup = variant === 'section-group';
256
+ return (React.createElement(InternalExpandableSection, { variant: "footer", expanded: expanded, onChange: onExpandedChange, className: clsx(styles.section, isInSectionGroup && styles['section--no-ident'], isVisualRefresh && styles.refresh), headerText: definition.text },
159
257
  React.createElement(NavigationItemsList, { variant: "section", items: definition.items, fireFollow: fireFollow, fireChange: fireChange, activeHref: activeHref, position: position })));
160
258
  }
161
- function SectionGroup({ definition, activeHref, fireFollow, fireChange, position }) {
259
+ function SectionGroup({ definition, activeHref, fireFollow, fireChange, position, collapsed }) {
260
+ if (collapsed) {
261
+ return null;
262
+ }
162
263
  return (React.createElement("div", { className: styles['section-group'] },
163
264
  React.createElement(InternalBox, { className: styles['section-group-title'], variant: "h3" }, definition.title),
164
265
  React.createElement(NavigationItemsList, { variant: "section-group", items: definition.items, fireFollow: fireFollow, fireChange: fireChange, activeHref: activeHref, position: position })));
165
266
  }
166
- function LinkGroup({ definition, activeHref, fireFollow, fireChange, position }) {
267
+ function LinkGroup({ definition, activeHref, fireFollow, fireChange, position, collapsed }) {
167
268
  checkSafeUrl('SideNavigation', definition.href);
168
269
  return (React.createElement(React.Fragment, null,
169
- React.createElement(Link, { definition: { type: 'link', href: definition.href, text: definition.text, info: definition.info }, fireFollow: (_, event) => fireFollow(definition, event), fireChange: fireChange, activeHref: activeHref, position: position }),
170
- React.createElement(NavigationItemsList, { variant: "link-group", items: definition.items, fireFollow: fireFollow, fireChange: fireChange, activeHref: activeHref, position: position })));
270
+ React.createElement(Link, { definition: {
271
+ type: 'link',
272
+ href: definition.href,
273
+ text: definition.text,
274
+ info: definition.info,
275
+ icon: definition.icon,
276
+ }, fireFollow: (_, event) => fireFollow(definition, event), fireChange: fireChange, activeHref: activeHref, position: position, collapsed: collapsed }),
277
+ !collapsed && (React.createElement(NavigationItemsList, { variant: "link-group", items: definition.items, fireFollow: fireFollow, fireChange: fireChange, activeHref: activeHref, position: position }))));
171
278
  }
172
- function ExpandableLinkGroup({ definition, fireFollow, fireChange, activeHref, variant, position, }) {
279
+ function ExpandableLinkGroup({ definition, fireFollow, fireChange, activeHref, variant, position, collapsed, }) {
173
280
  // Check whether the definition contains an active link and memoize it to avoid
174
281
  // rechecking every time.
175
282
  const containsActiveLink = useMemo(() => {
@@ -203,7 +310,10 @@ function ExpandableLinkGroup({ definition, fireFollow, fireChange, activeHref, v
203
310
  fireChange(definition, true);
204
311
  }
205
312
  };
206
- return (React.createElement(InternalExpandableSection, { className: clsx(styles['expandable-link-group'], variant === 'section-group' && styles['expandable-link-group--no-ident']), variant: "navigation", expanded: userExpanded !== null && userExpanded !== void 0 ? userExpanded : expanded, onChange: onExpandedChange, headerText: React.createElement(Link, { definition: { type: 'link', href: definition.href, text: definition.text }, fireFollow: onHeaderFollow, fireChange: fireChange, activeHref: activeHref, position: position }) },
313
+ if (collapsed) {
314
+ return (React.createElement(Link, { definition: { type: 'link', href: definition.href, text: definition.text, icon: definition.icon }, fireFollow: onHeaderFollow, fireChange: fireChange, activeHref: activeHref, position: position, collapsed: collapsed }));
315
+ }
316
+ return (React.createElement(InternalExpandableSection, { className: clsx(styles['expandable-link-group'], variant === 'section-group' && styles['expandable-link-group--no-ident'], definition.href === activeHref && styles['expandable-link-group--active']), variant: "navigation", expanded: userExpanded !== null && userExpanded !== void 0 ? userExpanded : expanded, onChange: onExpandedChange, headerText: React.createElement(Link, { definition: { type: 'link', href: definition.href, text: definition.text, icon: definition.icon }, fireFollow: onHeaderFollow, fireChange: fireChange, activeHref: activeHref, position: position }) },
207
317
  React.createElement(NavigationItemsList, { variant: "expandable-link-group", items: definition.items, fireFollow: fireFollow, fireChange: fireChange, activeHref: activeHref, position: position })));
208
318
  }
209
319
  //# sourceMappingURL=parts.js.map