@cloudscape-design/components 3.0.388 → 3.0.390

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 (184) hide show
  1. package/anchor-navigation/index.d.ts +5 -0
  2. package/anchor-navigation/index.d.ts.map +1 -0
  3. package/anchor-navigation/index.js +14 -0
  4. package/anchor-navigation/index.js.map +1 -0
  5. package/anchor-navigation/interfaces.d.ts +67 -0
  6. package/anchor-navigation/interfaces.d.ts.map +1 -0
  7. package/anchor-navigation/interfaces.js +4 -0
  8. package/anchor-navigation/interfaces.js.map +1 -0
  9. package/anchor-navigation/internal.d.ts +5 -0
  10. package/anchor-navigation/internal.d.ts.map +1 -0
  11. package/anchor-navigation/internal.js +48 -0
  12. package/anchor-navigation/internal.js.map +1 -0
  13. package/anchor-navigation/styles.css.js +13 -0
  14. package/anchor-navigation/styles.scoped.css +243 -0
  15. package/anchor-navigation/styles.selectors.js +14 -0
  16. package/anchor-navigation/test-classes/styles.css.js +11 -0
  17. package/anchor-navigation/test-classes/styles.scoped.css +27 -0
  18. package/anchor-navigation/test-classes/styles.selectors.js +12 -0
  19. package/anchor-navigation/use-scroll-spy.d.ts +18 -0
  20. package/anchor-navigation/use-scroll-spy.d.ts.map +1 -0
  21. package/anchor-navigation/use-scroll-spy.js +74 -0
  22. package/anchor-navigation/use-scroll-spy.js.map +1 -0
  23. package/annotation-context/annotation/styles.css.js +24 -24
  24. package/annotation-context/annotation/styles.scoped.css +30 -30
  25. package/annotation-context/annotation/styles.selectors.js +24 -24
  26. package/app-layout/notifications/styles.css.js +3 -3
  27. package/app-layout/notifications/styles.scoped.css +7 -7
  28. package/app-layout/notifications/styles.selectors.js +3 -3
  29. package/app-layout/visual-refresh/styles.css.js +75 -75
  30. package/app-layout/visual-refresh/styles.scoped.css +295 -295
  31. package/app-layout/visual-refresh/styles.selectors.js +75 -75
  32. package/button/styles.css.js +20 -20
  33. package/button/styles.scoped.css +151 -152
  34. package/button/styles.selectors.js +20 -20
  35. package/button-dropdown/item-element/styles.css.js +15 -15
  36. package/button-dropdown/item-element/styles.scoped.css +18 -19
  37. package/button-dropdown/item-element/styles.selectors.js +15 -15
  38. package/cards/index.js +2 -2
  39. package/cards/index.js.map +1 -1
  40. package/code-editor/styles.css.js +32 -32
  41. package/code-editor/styles.scoped.css +129 -131
  42. package/code-editor/styles.selectors.js +32 -32
  43. package/collection-preferences/content-display/styles.css.js +11 -11
  44. package/collection-preferences/content-display/styles.scoped.css +17 -18
  45. package/collection-preferences/content-display/styles.selectors.js +11 -11
  46. package/collection-preferences/styles.css.js +37 -37
  47. package/collection-preferences/styles.scoped.css +44 -45
  48. package/collection-preferences/styles.selectors.js +37 -37
  49. package/container/index.d.ts.map +1 -1
  50. package/container/index.js +2 -2
  51. package/container/index.js.map +1 -1
  52. package/container/internal.d.ts +5 -1
  53. package/container/internal.d.ts.map +1 -1
  54. package/container/internal.js +7 -4
  55. package/container/internal.js.map +1 -1
  56. package/content-layout/styles.css.js +7 -7
  57. package/content-layout/styles.scoped.css +13 -13
  58. package/content-layout/styles.selectors.js +7 -7
  59. package/expandable-section/expandable-section-container.d.ts +5 -3
  60. package/expandable-section/expandable-section-container.d.ts.map +1 -1
  61. package/expandable-section/expandable-section-container.js +2 -2
  62. package/expandable-section/expandable-section-container.js.map +1 -1
  63. package/expandable-section/index.d.ts.map +1 -1
  64. package/expandable-section/index.js +8 -3
  65. package/expandable-section/index.js.map +1 -1
  66. package/expandable-section/internal.d.ts +3 -3
  67. package/expandable-section/internal.d.ts.map +1 -1
  68. package/expandable-section/internal.js +2 -2
  69. package/expandable-section/internal.js.map +1 -1
  70. package/expandable-section/styles.css.js +29 -29
  71. package/expandable-section/styles.scoped.css +58 -59
  72. package/expandable-section/styles.selectors.js +29 -29
  73. package/flashbar/styles.css.js +47 -47
  74. package/flashbar/styles.scoped.css +171 -172
  75. package/flashbar/styles.selectors.js +47 -47
  76. package/form-field/styles.css.js +19 -19
  77. package/form-field/styles.scoped.css +29 -30
  78. package/form-field/styles.selectors.js +19 -19
  79. package/header/styles.css.js +32 -32
  80. package/header/styles.scoped.css +48 -49
  81. package/header/styles.selectors.js +32 -32
  82. package/index.d.ts +1 -0
  83. package/index.d.ts.map +1 -1
  84. package/index.js +1 -0
  85. package/index.js.map +1 -1
  86. package/internal/analytics/components/analytics-funnel.d.ts +2 -2
  87. package/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
  88. package/internal/analytics/components/analytics-funnel.js +8 -2
  89. package/internal/analytics/components/analytics-funnel.js.map +1 -1
  90. package/internal/analytics/hooks/use-funnel.d.ts.map +1 -1
  91. package/internal/analytics/hooks/use-funnel.js +2 -1
  92. package/internal/analytics/hooks/use-funnel.js.map +1 -1
  93. package/internal/components/abstract-switch/styles.css.js +13 -13
  94. package/internal/components/abstract-switch/styles.scoped.css +19 -21
  95. package/internal/components/abstract-switch/styles.selectors.js +13 -13
  96. package/internal/components/dropdown/dropdown-fit-handler.d.ts +31 -2
  97. package/internal/components/dropdown/dropdown-fit-handler.d.ts.map +1 -1
  98. package/internal/components/dropdown/dropdown-fit-handler.js +49 -7
  99. package/internal/components/dropdown/dropdown-fit-handler.js.map +1 -1
  100. package/internal/components/dropdown/index.d.ts.map +1 -1
  101. package/internal/components/dropdown/index.js +20 -2
  102. package/internal/components/dropdown/index.js.map +1 -1
  103. package/internal/components/dropdown/styles.css.js +21 -21
  104. package/internal/components/dropdown/styles.scoped.css +37 -36
  105. package/internal/components/dropdown/styles.selectors.js +21 -21
  106. package/internal/components/menu-dropdown/styles.css.js +7 -7
  107. package/internal/components/menu-dropdown/styles.scoped.css +13 -14
  108. package/internal/components/menu-dropdown/styles.selectors.js +7 -7
  109. package/internal/components/option/styles.css.js +17 -17
  110. package/internal/components/option/styles.scoped.css +29 -30
  111. package/internal/components/option/styles.selectors.js +17 -17
  112. package/internal/environment.js +1 -1
  113. package/internal/environment.json +1 -1
  114. package/internal/generated/custom-css-properties/index.d.ts.map +1 -1
  115. package/internal/generated/custom-css-properties/index.js +40 -39
  116. package/internal/generated/custom-css-properties/index.js.map +1 -1
  117. package/internal/manifest.json +1 -1
  118. package/internal/utils/scrollable-containers.d.ts +6 -1
  119. package/internal/utils/scrollable-containers.d.ts.map +1 -1
  120. package/internal/utils/scrollable-containers.js +1 -1
  121. package/internal/utils/scrollable-containers.js.map +1 -1
  122. package/modal/internal.d.ts.map +1 -1
  123. package/modal/internal.js +6 -4
  124. package/modal/internal.js.map +1 -1
  125. package/package.json +2 -1
  126. package/progress-bar/styles.css.js +18 -18
  127. package/progress-bar/styles.scoped.css +32 -33
  128. package/progress-bar/styles.selectors.js +18 -18
  129. package/property-filter/styles.css.js +30 -30
  130. package/property-filter/styles.scoped.css +32 -33
  131. package/property-filter/styles.selectors.js +30 -30
  132. package/side-navigation/styles.css.js +28 -28
  133. package/side-navigation/styles.scoped.css +38 -39
  134. package/side-navigation/styles.selectors.js +28 -28
  135. package/split-panel/styles.css.js +56 -56
  136. package/split-panel/styles.scoped.css +77 -78
  137. package/split-panel/styles.selectors.js +56 -56
  138. package/status-indicator/internal.d.ts.map +1 -1
  139. package/status-indicator/internal.js +3 -1
  140. package/status-indicator/internal.js.map +1 -1
  141. package/status-indicator/styles.css.js +22 -22
  142. package/status-indicator/styles.scoped.css +36 -34
  143. package/status-indicator/styles.selectors.js +22 -22
  144. package/table/header-cell/index.d.ts +0 -2
  145. package/table/header-cell/index.d.ts.map +1 -1
  146. package/table/header-cell/index.js +1 -1
  147. package/table/header-cell/index.js.map +1 -1
  148. package/table/index.d.ts.map +1 -1
  149. package/table/index.js +8 -4
  150. package/table/index.js.map +1 -1
  151. package/table/internal.d.ts +1 -0
  152. package/table/internal.d.ts.map +1 -1
  153. package/table/internal.js +8 -2
  154. package/table/internal.js.map +1 -1
  155. package/table/resizer/index.d.ts +3 -5
  156. package/table/resizer/index.d.ts.map +1 -1
  157. package/table/resizer/index.js +44 -66
  158. package/table/resizer/index.js.map +1 -1
  159. package/table/resizer/resizer-lookup.d.ts +8 -0
  160. package/table/resizer/resizer-lookup.d.ts.map +1 -0
  161. package/table/resizer/resizer-lookup.js +39 -0
  162. package/table/resizer/resizer-lookup.js.map +1 -0
  163. package/tabs/styles.css.js +21 -21
  164. package/tabs/styles.scoped.css +39 -40
  165. package/tabs/styles.selectors.js +21 -21
  166. package/test-utils/dom/anchor-navigation/index.d.ts +16 -0
  167. package/test-utils/dom/anchor-navigation/index.js +58 -0
  168. package/test-utils/dom/anchor-navigation/index.js.map +1 -0
  169. package/test-utils/dom/index.d.ts +3 -0
  170. package/test-utils/dom/index.js +10 -2
  171. package/test-utils/dom/index.js.map +1 -1
  172. package/test-utils/selectors/anchor-navigation/index.d.ts +15 -0
  173. package/test-utils/selectors/anchor-navigation/index.js +45 -0
  174. package/test-utils/selectors/anchor-navigation/index.js.map +1 -0
  175. package/test-utils/selectors/index.d.ts +3 -0
  176. package/test-utils/selectors/index.js +10 -2
  177. package/test-utils/selectors/index.js.map +1 -1
  178. package/test-utils/tsconfig.tsbuildinfo +1 -1
  179. package/tiles/styles.css.js +29 -29
  180. package/tiles/styles.scoped.css +70 -71
  181. package/tiles/styles.selectors.js +29 -29
  182. package/wizard/styles.css.js +31 -31
  183. package/wizard/styles.scoped.css +64 -68
  184. package/wizard/styles.selectors.js +31 -31
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { AnchorNavigationProps } from './interfaces';
3
+ export { AnchorNavigationProps };
4
+ export default function AnchorNavigation({ scrollSpyOffset, ...props }: AnchorNavigationProps): JSX.Element;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["anchor-navigation/index.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAKrD,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAE,eAAmB,EAAE,GAAG,KAAK,EAAE,EAAE,qBAAqB,eAGhG"}
@@ -0,0 +1,14 @@
1
+ import { __rest } from "tslib";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import React from 'react';
5
+ import { applyDisplayName } from '../internal/utils/apply-display-name';
6
+ import InternalAnchorNavigation from './internal';
7
+ import useBaseComponent from '../internal/hooks/use-base-component';
8
+ export default function AnchorNavigation(_a) {
9
+ var { scrollSpyOffset = 0 } = _a, props = __rest(_a, ["scrollSpyOffset"]);
10
+ const baseComponentProps = useBaseComponent('AnchorNavigation');
11
+ return React.createElement(InternalAnchorNavigation, Object.assign({ scrollSpyOffset: scrollSpyOffset }, props, baseComponentProps));
12
+ }
13
+ applyDisplayName(AnchorNavigation, 'AnchorNavigation');
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["anchor-navigation/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,wBAAwB,MAAM,YAAY,CAAC;AAClD,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAIpE,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAwD;QAAxD,EAAE,eAAe,GAAG,CAAC,OAAmC,EAA9B,KAAK,cAA/B,mBAAiC,CAAF;IACtE,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;IAChE,OAAO,oBAAC,wBAAwB,kBAAC,eAAe,EAAE,eAAe,IAAM,KAAK,EAAM,kBAAkB,EAAI,CAAC;AAC3G,CAAC;AACD,gBAAgB,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { AnchorNavigationProps } from './interfaces';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport InternalAnchorNavigation from './internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\n\nexport { AnchorNavigationProps };\n\nexport default function AnchorNavigation({ scrollSpyOffset = 0, ...props }: AnchorNavigationProps) {\n const baseComponentProps = useBaseComponent('AnchorNavigation');\n return <InternalAnchorNavigation scrollSpyOffset={scrollSpyOffset} {...props} {...baseComponentProps} />;\n}\napplyDisplayName(AnchorNavigation, 'AnchorNavigation');\n"]}
@@ -0,0 +1,67 @@
1
+ import { BaseComponentProps } from '../internal/base-component';
2
+ import { CancelableEventHandler, NonCancelableEventHandler } from '../internal/events';
3
+ export interface AnchorNavigationProps extends BaseComponentProps {
4
+ /**
5
+ * Adds `aria-labelledby` to the component.
6
+ *
7
+ * Use this property for identifying the header or title that labels the anchor navigation.
8
+ * To use it correctly, define an ID for the element either as label, and set the property to that ID.
9
+ */
10
+ ariaLabelledby?: string;
11
+ /**
12
+ * List of anchors. Each anchor object has the following properties:
13
+ *
14
+ * * `text` (string) - The text for the anchor item.
15
+ * * `href` (string) - The `id` attribute of the target HTML element that the anchor refers to.
16
+ * For example: `"#section1.1"`
17
+ * * `level` (number) - Level of nesting of the anchor.
18
+ * * `info` (string | undefined) - Additional information to display next to the link, for example: "New" or "Updated".
19
+ *
20
+ * Note: The list of anchors should be sorted in the order they appear on the page.
21
+ */
22
+ anchors: AnchorNavigationProps.Anchor[];
23
+ /**
24
+ * Specifies the active anchor href. When set, the component will operate in a
25
+ * controlled manner, and internal scroll-spy will be disabled.
26
+ */
27
+ activeHref?: string;
28
+ /**
29
+ * Specifies the height (in pixels) to be considered as an offset when activating anchors.
30
+ * This is useful when you have a fixed or sticky header that might overlap with the content as you scroll.
31
+ *
32
+ * Defaults to 0.
33
+ */
34
+ scrollSpyOffset?: number;
35
+ /**
36
+ * Fired when an anchor link is clicked without any modifier keys.
37
+ */
38
+ onFollow?: CancelableEventHandler<AnchorNavigationProps.Anchor>;
39
+ /**
40
+ * Fired when an active anchor link changes.
41
+ *
42
+ * Note: This event is triggered both by the component's internal scroll-spy logic,
43
+ * or when the `activeHref` prop is manually updated.
44
+ */
45
+ onActiveHrefChange?: NonCancelableEventHandler<AnchorNavigationProps.Anchor>;
46
+ }
47
+ export declare namespace AnchorNavigationProps {
48
+ interface Anchor {
49
+ /**
50
+ * The text for the anchor item.
51
+ */
52
+ text: string;
53
+ /**
54
+ * The `href` of the anchor. For example: `"#section1.1"`".
55
+ */
56
+ href: string;
57
+ /**
58
+ * Level of nesting of the anchor.
59
+ */
60
+ level: number;
61
+ /**
62
+ * Additional information to display next to the link, for example: "New" or "Updated".
63
+ */
64
+ info?: string;
65
+ }
66
+ }
67
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["anchor-navigation/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEvF,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;;;;;OAUG;IACH,OAAO,EAAE,qBAAqB,CAAC,MAAM,EAAE,CAAC;IAExC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,sBAAsB,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAEhE;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,yBAAyB,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;CAC9E;AAED,yBAAiB,qBAAqB,CAAC;IACrC,UAAiB,MAAM;QACrB;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;QAEb;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;QAEb;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;CACF"}
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
4
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["anchor-navigation/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { CancelableEventHandler, NonCancelableEventHandler } from '../internal/events';\n\nexport interface AnchorNavigationProps extends BaseComponentProps {\n /**\n * Adds `aria-labelledby` to the component.\n *\n * Use this property for identifying the header or title that labels the anchor navigation.\n * To use it correctly, define an ID for the element either as label, and set the property to that ID.\n */\n ariaLabelledby?: string;\n\n /**\n * List of anchors. Each anchor object has the following properties:\n *\n * * `text` (string) - The text for the anchor item.\n * * `href` (string) - The `id` attribute of the target HTML element that the anchor refers to.\n * For example: `\"#section1.1\"`\n * * `level` (number) - Level of nesting of the anchor.\n * * `info` (string | undefined) - Additional information to display next to the link, for example: \"New\" or \"Updated\".\n *\n * Note: The list of anchors should be sorted in the order they appear on the page.\n */\n anchors: AnchorNavigationProps.Anchor[];\n\n /**\n * Specifies the active anchor href. When set, the component will operate in a\n * controlled manner, and internal scroll-spy will be disabled.\n */\n activeHref?: string;\n\n /**\n * Specifies the height (in pixels) to be considered as an offset when activating anchors.\n * This is useful when you have a fixed or sticky header that might overlap with the content as you scroll.\n *\n * Defaults to 0.\n */\n scrollSpyOffset?: number;\n\n /**\n * Fired when an anchor link is clicked without any modifier keys.\n */\n onFollow?: CancelableEventHandler<AnchorNavigationProps.Anchor>;\n\n /**\n * Fired when an active anchor link changes.\n *\n * Note: This event is triggered both by the component's internal scroll-spy logic,\n * or when the `activeHref` prop is manually updated.\n */\n onActiveHrefChange?: NonCancelableEventHandler<AnchorNavigationProps.Anchor>;\n}\n\nexport namespace AnchorNavigationProps {\n export interface Anchor {\n /**\n * The text for the anchor item.\n */\n text: string;\n\n /**\n * The `href` of the anchor. For example: `\"#section1.1\"`\".\n */\n href: string;\n\n /**\n * Level of nesting of the anchor.\n */\n level: number;\n\n /**\n * Additional information to display next to the link, for example: \"New\" or \"Updated\".\n */\n info?: string;\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { AnchorNavigationProps } from './interfaces';
3
+ import { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';
4
+ export default function InternalAnchorNavigation({ anchors, ariaLabelledby, onFollow, onActiveHrefChange, activeHref, __internalRootRef, scrollSpyOffset, ...props }: AnchorNavigationProps & InternalBaseComponentProps): JSX.Element;
5
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["anchor-navigation/internal.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAIrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAG3F,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC/C,OAAO,EACP,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,UAAe,EACf,iBAAwB,EACxB,eAAmB,EACnB,GAAG,KAAK,EACT,EAAE,qBAAqB,GAAG,0BAA0B,eA+CpD"}
@@ -0,0 +1,48 @@
1
+ import { __rest } from "tslib";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import React, { useCallback, useEffect, useMemo } from 'react';
5
+ import clsx from 'clsx';
6
+ import styles from './styles.css.js';
7
+ import testUtilsStyles from './test-classes/styles.css.js';
8
+ import { checkSafeUrl } from '../internal/utils/check-safe-url';
9
+ import useScrollSpy from './use-scroll-spy.js';
10
+ import { fireCancelableEvent, fireNonCancelableEvent, isPlainLeftClick } from '../internal/events/index';
11
+ import { getBaseProps } from '../internal/base-component/index.js';
12
+ export default function InternalAnchorNavigation(_a) {
13
+ var { anchors, ariaLabelledby, onFollow, onActiveHrefChange, activeHref = '', __internalRootRef = null, scrollSpyOffset = 0 } = _a, props = __rest(_a, ["anchors", "ariaLabelledby", "onFollow", "onActiveHrefChange", "activeHref", "__internalRootRef", "scrollSpyOffset"]);
14
+ const baseProps = getBaseProps(props);
15
+ const hrefs = useMemo(() => anchors.map(anchor => anchor.href), [anchors]);
16
+ const onFollowHandler = useCallback((anchor, sourceEvent) => {
17
+ fireCancelableEvent(onFollow, anchor, sourceEvent);
18
+ }, [onFollow]);
19
+ const currentActiveHref = useScrollSpy({
20
+ hrefs,
21
+ scrollSpyOffset,
22
+ activeHref,
23
+ });
24
+ useEffect(() => {
25
+ if (currentActiveHref) {
26
+ const newActiveAnchor = anchors.find(anchor => anchor.href === currentActiveHref);
27
+ fireNonCancelableEvent(onActiveHrefChange, newActiveAnchor);
28
+ }
29
+ }, [onActiveHrefChange, anchors, currentActiveHref]);
30
+ return (React.createElement("nav", Object.assign({}, baseProps, { ref: __internalRootRef, "aria-labelledby": ariaLabelledby, className: clsx(baseProps.className, styles.root, testUtilsStyles.root) }),
31
+ React.createElement("ol", { className: clsx(styles['anchor-list'], testUtilsStyles['anchor-list']) }, anchors.map((anchor, index) => {
32
+ return (React.createElement(Anchor, { onFollow: onFollowHandler, isActive: anchor.href === currentActiveHref, key: index, index: index, anchor: anchor }));
33
+ }))));
34
+ }
35
+ const Anchor = ({ anchor, onFollow, isActive, index }) => {
36
+ checkSafeUrl('SideNavigation', anchor.href);
37
+ const onClick = useCallback((event) => {
38
+ if (isPlainLeftClick(event)) {
39
+ onFollow(anchor, event);
40
+ }
41
+ }, [onFollow, anchor]);
42
+ const activeItemClasses = clsx(styles['anchor-item--active'], testUtilsStyles['anchor-item--active']);
43
+ return (React.createElement("li", { "data-itemid": `anchor-item-${index + 1}`, className: clsx(styles['anchor-item'], isActive && activeItemClasses) },
44
+ React.createElement("a", Object.assign({ onClick: onClick, className: clsx(styles['anchor-link'], testUtilsStyles['anchor-link'], isActive && styles['anchor-link--active']) }, (isActive ? { 'aria-current': true } : {}), { href: anchor.href }),
45
+ React.createElement("span", { className: clsx(styles['anchor-link-text'], testUtilsStyles['anchor-link-text']), style: { paddingLeft: `${anchor.level * 16 + 2}px` } }, anchor.text),
46
+ anchor.info && (React.createElement("span", { className: clsx(styles['anchor-link-info'], testUtilsStyles['anchor-link-info']) }, anchor.info)))));
47
+ };
48
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["anchor-navigation/internal.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;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEzG,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EASI;QATJ,EAC/C,OAAO,EACP,cAAc,EACd,QAAQ,EACR,kBAAkB,EACl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AAM,CAAC,kBAAkB,CAAC,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC,EAChF,KAAK,EAAE,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,IAEnD,MAAM,CAAC,IAAI,CACP;YACN,MAAM,CAAC,IAAI,IAAI,CACd,8BAAM,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC,IAAG,MAAM,CAAC,IAAI,CAAQ,CAC7G,CACC,CACD,CACN,CAAC;AACJ,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';\nimport styles from './styles.css.js';\nimport testUtilsStyles from './test-classes/styles.css.js';\nimport { AnchorNavigationProps } from './interfaces';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport useScrollSpy from './use-scroll-spy.js';\nimport { fireCancelableEvent, fireNonCancelableEvent, isPlainLeftClick } from '../internal/events/index';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\nimport { getBaseProps } from '../internal/base-component/index.js';\n\nexport default function InternalAnchorNavigation({\n anchors,\n ariaLabelledby,\n onFollow,\n onActiveHrefChange,\n activeHref = '',\n __internalRootRef = null,\n scrollSpyOffset = 0,\n ...props\n}: AnchorNavigationProps & InternalBaseComponentProps) {\n const baseProps = getBaseProps(props);\n\n const hrefs = useMemo(() => anchors.map(anchor => anchor.href), [anchors]);\n\n const onFollowHandler = useCallback(\n (anchor: AnchorNavigationProps.Anchor, sourceEvent: React.SyntheticEvent | Event) => {\n fireCancelableEvent(onFollow, anchor, sourceEvent);\n },\n [onFollow]\n );\n\n const currentActiveHref = useScrollSpy({\n hrefs,\n scrollSpyOffset,\n activeHref,\n });\n\n useEffect(() => {\n if (currentActiveHref) {\n const newActiveAnchor = anchors.find(anchor => anchor.href === currentActiveHref);\n fireNonCancelableEvent(onActiveHrefChange, newActiveAnchor);\n }\n }, [onActiveHrefChange, anchors, currentActiveHref]);\n\n return (\n <nav\n {...baseProps}\n ref={__internalRootRef}\n aria-labelledby={ariaLabelledby}\n className={clsx(baseProps.className, styles.root, testUtilsStyles.root)}\n >\n <ol className={clsx(styles['anchor-list'], testUtilsStyles['anchor-list'])}>\n {anchors.map((anchor, index) => {\n return (\n <Anchor\n onFollow={onFollowHandler}\n isActive={anchor.href === currentActiveHref}\n key={index}\n index={index}\n anchor={anchor}\n />\n );\n })}\n </ol>\n </nav>\n );\n}\n\ninterface AnchorProps {\n anchor: AnchorNavigationProps.Anchor;\n onFollow: (anchor: AnchorNavigationProps.Anchor, event: React.SyntheticEvent | Event) => void;\n isActive: boolean;\n index: number;\n}\n\nconst Anchor = ({ anchor, onFollow, isActive, index }: AnchorProps) => {\n checkSafeUrl('SideNavigation', anchor.href);\n\n const onClick = useCallback(\n (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n onFollow(anchor, event);\n }\n },\n [onFollow, anchor]\n );\n\n const activeItemClasses = clsx(styles['anchor-item--active'], testUtilsStyles['anchor-item--active']);\n\n return (\n <li data-itemid={`anchor-item-${index + 1}`} className={clsx(styles['anchor-item'], isActive && activeItemClasses)}>\n <a\n onClick={onClick}\n className={clsx(\n styles['anchor-link'],\n testUtilsStyles['anchor-link'],\n isActive && styles['anchor-link--active']\n )}\n {...(isActive ? { 'aria-current': true } : {})}\n href={anchor.href}\n >\n <span\n className={clsx(styles['anchor-link-text'], testUtilsStyles['anchor-link-text'])}\n style={{ paddingLeft: `${anchor.level * 16 + 2}px` }}\n >\n {anchor.text}\n </span>\n {anchor.info && (\n <span className={clsx(styles['anchor-link-info'], testUtilsStyles['anchor-link-info'])}>{anchor.info}</span>\n )}\n </a>\n </li>\n );\n};\n"]}
@@ -0,0 +1,13 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "root": "awsui_root_swimc_1mwue_93",
5
+ "anchor-list": "awsui_anchor-list_swimc_1mwue_106",
6
+ "anchor-item": "awsui_anchor-item_swimc_1mwue_124",
7
+ "anchor-item--active": "awsui_anchor-item--active_swimc_1mwue_143",
8
+ "anchor-link": "awsui_anchor-link_swimc_1mwue_157",
9
+ "anchor-link--active": "awsui_anchor-link--active_swimc_1mwue_196",
10
+ "anchor-link-text": "awsui_anchor-link-text_swimc_1mwue_203",
11
+ "anchor-link-info": "awsui_anchor-link-info_swimc_1mwue_207"
12
+ };
13
+
@@ -0,0 +1,243 @@
1
+ /*
2
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ /*
6
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
7
+ SPDX-License-Identifier: Apache-2.0
8
+ */
9
+ /*
10
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
11
+ SPDX-License-Identifier: Apache-2.0
12
+ */
13
+ /*
14
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
15
+ SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ /*
18
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
19
+ SPDX-License-Identifier: Apache-2.0
20
+ */
21
+ /*
22
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
23
+ SPDX-License-Identifier: Apache-2.0
24
+ */
25
+ /*
26
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
27
+ SPDX-License-Identifier: Apache-2.0
28
+ */
29
+ /*
30
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
31
+ SPDX-License-Identifier: Apache-2.0
32
+ */
33
+ /*
34
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
35
+ SPDX-License-Identifier: Apache-2.0
36
+ */
37
+ /*
38
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
39
+ SPDX-License-Identifier: Apache-2.0
40
+ */
41
+ /*
42
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
43
+ SPDX-License-Identifier: Apache-2.0
44
+ */
45
+ /*
46
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
47
+ SPDX-License-Identifier: Apache-2.0
48
+ */
49
+ /*
50
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
51
+ SPDX-License-Identifier: Apache-2.0
52
+ */
53
+ /*
54
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
55
+ SPDX-License-Identifier: Apache-2.0
56
+ */
57
+ /*
58
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
59
+ SPDX-License-Identifier: Apache-2.0
60
+ */
61
+ /*
62
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
63
+ SPDX-License-Identifier: Apache-2.0
64
+ */
65
+ /* stylelint-disable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
66
+ /* stylelint-enable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
67
+ /*
68
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
69
+ SPDX-License-Identifier: Apache-2.0
70
+ */
71
+ /*
72
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
73
+ SPDX-License-Identifier: Apache-2.0
74
+ */
75
+ /*
76
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
77
+ SPDX-License-Identifier: Apache-2.0
78
+ */
79
+ /*
80
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
81
+ SPDX-License-Identifier: Apache-2.0
82
+ */
83
+ /* Style used for links in slots/components that are text heavy, to help links stand out among
84
+ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
85
+ /*
86
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
87
+ SPDX-License-Identifier: Apache-2.0
88
+ */
89
+ /*
90
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
91
+ SPDX-License-Identifier: Apache-2.0
92
+ */
93
+ .awsui_root_swimc_1mwue_93:not(#\9) {
94
+ /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
95
+ border-collapse: separate;
96
+ border-spacing: 0;
97
+ caption-side: top;
98
+ cursor: auto;
99
+ direction: ltr;
100
+ empty-cells: show;
101
+ font-family: serif;
102
+ font-size: medium;
103
+ font-style: normal;
104
+ font-variant: normal;
105
+ font-weight: normal;
106
+ font-stretch: normal;
107
+ line-height: normal;
108
+ -webkit-hyphens: none;
109
+ hyphens: none;
110
+ letter-spacing: normal;
111
+ list-style: disc outside none;
112
+ tab-size: 8;
113
+ text-align: left;
114
+ text-align-last: auto;
115
+ text-indent: 0;
116
+ text-shadow: none;
117
+ text-transform: none;
118
+ visibility: visible;
119
+ white-space: normal;
120
+ widows: 2;
121
+ word-spacing: normal;
122
+ box-sizing: border-box;
123
+ font-size: var(--font-size-body-m-x4okxb, 14px);
124
+ line-height: var(--line-height-body-m-30ar75, 20px);
125
+ color: var(--color-text-body-default-2sxhhn, #000716);
126
+ font-weight: 400;
127
+ font-family: var(--font-family-base-dnvic8, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
128
+ -webkit-font-smoothing: auto;
129
+ -moz-osx-font-smoothing: auto;
130
+ }
131
+
132
+ .awsui_anchor-list_swimc_1mwue_106:not(#\9) {
133
+ list-style: none;
134
+ margin: 0;
135
+ padding: 0;
136
+ position: relative;
137
+ text-indent: 0;
138
+ }
139
+ .awsui_anchor-list_swimc_1mwue_106:not(#\9)::before {
140
+ content: "";
141
+ background-color: var(--color-border-divider-default-et9j7s, #e9ebed);
142
+ border-radius: var(--border-radius-tabs-focus-ring-1q0rjo, 20px);
143
+ bottom: -2px;
144
+ pointer-events: none;
145
+ position: absolute;
146
+ top: -2px;
147
+ width: 2px;
148
+ }
149
+
150
+ .awsui_anchor-item_swimc_1mwue_124:not(#\9) {
151
+ transition: var(--motion-duration-slow-z2kaah, 180ms);
152
+ transition-property: all;
153
+ font-size: var(--font-size-body-m-x4okxb, 14px);
154
+ line-height: var(--line-height-body-m-30ar75, 20px);
155
+ color: var(--color-text-body-secondary-so8znq, #414d5c);
156
+ font-weight: 400;
157
+ margin: var(--space-scaled-xxs-7597g1, 4px) 0;
158
+ }
159
+ @media (prefers-reduced-motion: reduce) {
160
+ .awsui_anchor-item_swimc_1mwue_124:not(#\9) {
161
+ animation: none;
162
+ transition: none;
163
+ }
164
+ }
165
+ .awsui-motion-disabled .awsui_anchor-item_swimc_1mwue_124:not(#\9), .awsui-mode-entering .awsui_anchor-item_swimc_1mwue_124:not(#\9) {
166
+ animation: none;
167
+ transition: none;
168
+ }
169
+ .awsui_anchor-item--active_swimc_1mwue_143:not(#\9) {
170
+ position: relative;
171
+ }
172
+ .awsui_anchor-item--active_swimc_1mwue_143:not(#\9)::before {
173
+ content: "";
174
+ background-color: var(--color-text-accent-n2acxv, #0972d3);
175
+ border-radius: var(--border-radius-tabs-focus-ring-1q0rjo, 20px);
176
+ bottom: -2px;
177
+ pointer-events: none;
178
+ position: absolute;
179
+ top: -2px;
180
+ width: 2px;
181
+ }
182
+
183
+ .awsui_anchor-link_swimc_1mwue_157:not(#\9) {
184
+ transition: var(--motion-duration-slow-z2kaah, 180ms);
185
+ transition-property: all;
186
+ font-size: var(--font-size-body-m-x4okxb, 14px);
187
+ line-height: var(--line-height-body-m-30ar75, 20px);
188
+ align-items: baseline;
189
+ color: var(--color-text-body-secondary-so8znq, #414d5c);
190
+ display: flex;
191
+ flex-direction: row;
192
+ font-weight: 400;
193
+ text-decoration: none;
194
+ }
195
+ @media (prefers-reduced-motion: reduce) {
196
+ .awsui_anchor-link_swimc_1mwue_157:not(#\9) {
197
+ animation: none;
198
+ transition: none;
199
+ }
200
+ }
201
+ .awsui-motion-disabled .awsui_anchor-link_swimc_1mwue_157:not(#\9), .awsui-mode-entering .awsui_anchor-link_swimc_1mwue_157:not(#\9) {
202
+ animation: none;
203
+ transition: none;
204
+ }
205
+ body[data-awsui-focus-visible=true] .awsui_anchor-link_swimc_1mwue_157:not(#\9):focus {
206
+ outline: thin dotted;
207
+ outline: var(--border-link-focus-ring-outline-kkfop6, 0);
208
+ outline-offset: 2px;
209
+ outline-color: var(--color-border-item-focused-b2ntyl, #0972d3);
210
+ border-radius: var(--border-radius-control-default-focus-ring-u8zbsz, 4px);
211
+ box-shadow: 0 0 0 var(--border-link-focus-ring-shadow-spread-v8hkrl, 2px) var(--color-border-item-focused-b2ntyl, #0972d3);
212
+ }
213
+ .awsui_anchor-link_swimc_1mwue_157:not(#\9):hover {
214
+ color: var(--color-text-accent-n2acxv, #0972d3);
215
+ }
216
+ .awsui_anchor-link_swimc_1mwue_157:not(#\9):focus {
217
+ outline: none;
218
+ }
219
+ .awsui_anchor-link_swimc_1mwue_157:not(#\9):hover, .awsui_anchor-link_swimc_1mwue_157:not(#\9):focus {
220
+ text-decoration: none;
221
+ }
222
+ .awsui_anchor-link--active_swimc_1mwue_196:not(#\9) {
223
+ font-weight: var(--font-wayfinding-link-active-weight-rbmzei, 700);
224
+ -webkit-font-smoothing: var(--font-smoothing-webkit-m8nc84, antialiased);
225
+ -moz-osx-font-smoothing: var(--font-smoothing-moz-osx-foywby, grayscale);
226
+ color: var(--color-text-accent-n2acxv, #0972d3);
227
+ }
228
+
229
+ .awsui_anchor-link-text_swimc_1mwue_203:not(#\9) {
230
+ display: block;
231
+ }
232
+
233
+ .awsui_anchor-link-info_swimc_1mwue_207:not(#\9) {
234
+ margin-left: var(--space-xs-zb16t3, 8px);
235
+ font-size: var(--font-size-body-s-asqx2i, 12px);
236
+ line-height: var(--line-height-body-s-7zv1j5, 16px);
237
+ letter-spacing: var(--letter-spacing-body-s-z9jkwp, 0.005em);
238
+ -webkit-font-smoothing: var(--font-smoothing-webkit-m8nc84, antialiased);
239
+ -moz-osx-font-smoothing: var(--font-smoothing-moz-osx-foywby, grayscale);
240
+ font-weight: var(--font-button-weight-hv56tz, 700);
241
+ letter-spacing: 0.005em;
242
+ color: var(--color-text-link-default-latg1a, #0972d3);
243
+ }
@@ -0,0 +1,14 @@
1
+
2
+ // es-module interop with Babel and Typescript
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ module.exports.default = {
5
+ "root": "awsui_root_swimc_1mwue_93",
6
+ "anchor-list": "awsui_anchor-list_swimc_1mwue_106",
7
+ "anchor-item": "awsui_anchor-item_swimc_1mwue_124",
8
+ "anchor-item--active": "awsui_anchor-item--active_swimc_1mwue_143",
9
+ "anchor-link": "awsui_anchor-link_swimc_1mwue_157",
10
+ "anchor-link--active": "awsui_anchor-link--active_swimc_1mwue_196",
11
+ "anchor-link-text": "awsui_anchor-link-text_swimc_1mwue_203",
12
+ "anchor-link-info": "awsui_anchor-link-info_swimc_1mwue_207"
13
+ };
14
+
@@ -0,0 +1,11 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "root": "awsui_root_17oho_5eh15_5",
5
+ "anchor-list": "awsui_anchor-list_17oho_5eh15_9",
6
+ "anchor-item--active": "awsui_anchor-item--active_17oho_5eh15_13",
7
+ "anchor-link": "awsui_anchor-link_17oho_5eh15_17",
8
+ "anchor-link-text": "awsui_anchor-link-text_17oho_5eh15_21",
9
+ "anchor-link-info": "awsui_anchor-link-info_17oho_5eh15_25"
10
+ };
11
+
@@ -0,0 +1,27 @@
1
+ /*
2
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ .awsui_root_17oho_5eh15_5:not(#\9) {
6
+ /* used in test-utils */
7
+ }
8
+
9
+ .awsui_anchor-list_17oho_5eh15_9:not(#\9) {
10
+ /* used in test-utils */
11
+ }
12
+
13
+ .awsui_anchor-item--active_17oho_5eh15_13:not(#\9) {
14
+ /* used in test-utils */
15
+ }
16
+
17
+ .awsui_anchor-link_17oho_5eh15_17:not(#\9) {
18
+ /* used in test-utils */
19
+ }
20
+
21
+ .awsui_anchor-link-text_17oho_5eh15_21:not(#\9) {
22
+ /* used in test-utils */
23
+ }
24
+
25
+ .awsui_anchor-link-info_17oho_5eh15_25:not(#\9) {
26
+ /* used in test-utils */
27
+ }
@@ -0,0 +1,12 @@
1
+
2
+ // es-module interop with Babel and Typescript
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ module.exports.default = {
5
+ "root": "awsui_root_17oho_5eh15_5",
6
+ "anchor-list": "awsui_anchor-list_17oho_5eh15_9",
7
+ "anchor-item--active": "awsui_anchor-item--active_17oho_5eh15_13",
8
+ "anchor-link": "awsui_anchor-link_17oho_5eh15_17",
9
+ "anchor-link-text": "awsui_anchor-link-text_17oho_5eh15_21",
10
+ "anchor-link-info": "awsui_anchor-link-info_17oho_5eh15_25"
11
+ };
12
+
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Hook to implement scroll-spy functionality.
3
+ *
4
+ * @param hrefs An array of href strings that correspond to the IDs of the target elements on the page.
5
+ * The hrefs should be sorted in the order they appear on the page for accurate scroll-spy behavior.
6
+ * @param scrollSpyOffset The number of pixels to offset from the top of the document when activating anchors.
7
+ * Useful for accommodating fixed or sticky headers.
8
+ * @param activeHref The currently active href. If provided, the hook will operate in a controlled manner,
9
+ * and the scroll-spy logic will be disabled.
10
+ *
11
+ * @returns {string | undefined} - The href of the currently active element as per scroll position, or undefined if none is active.
12
+ */
13
+ export default function useScrollSpy({ hrefs, scrollSpyOffset, activeHref, }: {
14
+ hrefs: string[];
15
+ scrollSpyOffset: number;
16
+ activeHref?: string;
17
+ }): string | undefined;
18
+ //# sourceMappingURL=use-scroll-spy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-scroll-spy.d.ts","sourceRoot":"lib/default/","sources":["anchor-navigation/use-scroll-spy.tsx"],"names":[],"mappings":"AAMA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,KAAK,EACL,eAAe,EACf,UAAU,GACX,EAAE;IACD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,MAAM,GAAG,SAAS,CAgErB"}
@@ -0,0 +1,74 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { useCallback, useEffect, useState } from 'react';
4
+ const isBrowser = typeof window !== 'undefined';
5
+ /**
6
+ * Hook to implement scroll-spy functionality.
7
+ *
8
+ * @param hrefs An array of href strings that correspond to the IDs of the target elements on the page.
9
+ * The hrefs should be sorted in the order they appear on the page for accurate scroll-spy behavior.
10
+ * @param scrollSpyOffset The number of pixels to offset from the top of the document when activating anchors.
11
+ * Useful for accommodating fixed or sticky headers.
12
+ * @param activeHref The currently active href. If provided, the hook will operate in a controlled manner,
13
+ * and the scroll-spy logic will be disabled.
14
+ *
15
+ * @returns {string | undefined} - The href of the currently active element as per scroll position, or undefined if none is active.
16
+ */
17
+ export default function useScrollSpy({ hrefs, scrollSpyOffset, activeHref, }) {
18
+ const [currentHref, setCurrentHref] = useState(activeHref);
19
+ const [lastAnchorExists, setLastAnchorExists] = useState(false);
20
+ useEffect(() => {
21
+ setCurrentHref(activeHref);
22
+ }, [activeHref]);
23
+ useEffect(() => {
24
+ var _a;
25
+ setLastAnchorExists(isBrowser && !!document.getElementById((_a = hrefs[hrefs.length - 1]) === null || _a === void 0 ? void 0 : _a.slice(1)));
26
+ }, [hrefs]);
27
+ // Get the bounding rectangle of an element by href
28
+ const getRectByHref = useCallback(href => {
29
+ var _a;
30
+ return (_a = document.getElementById(href.slice(1))) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
31
+ }, []);
32
+ // Check if we're scrolled to the bottom of the page
33
+ const isPageBottom = useCallback(() => {
34
+ return lastAnchorExists && Math.ceil(window.scrollY) >= Math.floor(document.body.scrollHeight - window.innerHeight);
35
+ }, [lastAnchorExists]);
36
+ // Find the first href for which the element is within the viewport
37
+ const findHrefInView = useCallback(() => {
38
+ return hrefs.find(href => {
39
+ const rect = getRectByHref(href);
40
+ return rect && rect.bottom <= window.innerHeight && rect.top >= scrollSpyOffset;
41
+ });
42
+ }, [getRectByHref, scrollSpyOffset, hrefs]);
43
+ // Find the last href where its element is above or within the viewport
44
+ const findLastHrefInView = useCallback(() => {
45
+ return [...hrefs].reverse().find(href => {
46
+ const rect = getRectByHref(href);
47
+ return rect && rect.bottom <= window.innerHeight;
48
+ });
49
+ }, [getRectByHref, hrefs]);
50
+ // Scroll event handler
51
+ const handleScroll = useCallback(() => {
52
+ if (activeHref || !isBrowser) {
53
+ return;
54
+ }
55
+ const { scrollY } = window;
56
+ if (document.body.scrollHeight > window.innerHeight && isPageBottom()) {
57
+ setCurrentHref(hrefs[hrefs.length - 1]);
58
+ }
59
+ else {
60
+ setCurrentHref(findHrefInView() || (scrollY > 0 ? findLastHrefInView() : undefined));
61
+ }
62
+ }, [activeHref, isPageBottom, findHrefInView, findLastHrefInView, hrefs]);
63
+ useEffect(() => {
64
+ if (isBrowser) {
65
+ handleScroll();
66
+ window.addEventListener('scroll', handleScroll, { passive: true });
67
+ return () => {
68
+ window.removeEventListener('scroll', handleScroll);
69
+ };
70
+ }
71
+ }, [handleScroll]);
72
+ return currentHref;
73
+ }
74
+ //# sourceMappingURL=use-scroll-spy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-scroll-spy.js","sourceRoot":"lib/default/","sources":["anchor-navigation/use-scroll-spy.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,KAA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Y,EAAE,CAAC;YACf,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YACnE,OAAO,GAAG,EAAE;gBACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACrD,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback, useEffect, useState } from 'react';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Hook to implement scroll-spy functionality.\n *\n * @param hrefs An array of href strings that correspond to the IDs of the target elements on the page.\n * The hrefs should be sorted in the order they appear on the page for accurate scroll-spy behavior.\n * @param scrollSpyOffset The number of pixels to offset from the top of the document when activating anchors.\n * Useful for accommodating fixed or sticky headers.\n * @param activeHref The currently active href. If provided, the hook will operate in a controlled manner,\n * and the scroll-spy logic will be disabled.\n *\n * @returns {string | undefined} - The href of the currently active element as per scroll position, or undefined if none is active.\n */\nexport default function useScrollSpy({\n hrefs,\n scrollSpyOffset,\n activeHref,\n}: {\n hrefs: string[];\n scrollSpyOffset: number;\n activeHref?: string;\n}): string | undefined {\n const [currentHref, setCurrentHref] = useState<string | undefined>(activeHref);\n const [lastAnchorExists, setLastAnchorExists] = useState(false);\n\n useEffect(() => {\n setCurrentHref(activeHref);\n }, [activeHref]);\n\n useEffect(() => {\n setLastAnchorExists(isBrowser && !!document.getElementById(hrefs[hrefs.length - 1]?.slice(1)));\n }, [hrefs]);\n\n // Get the bounding rectangle of an element by href\n const getRectByHref = useCallback(href => {\n return document.getElementById(href.slice(1))?.getBoundingClientRect();\n }, []);\n\n // Check if we're scrolled to the bottom of the page\n const isPageBottom = useCallback(() => {\n return lastAnchorExists && Math.ceil(window.scrollY) >= Math.floor(document.body.scrollHeight - window.innerHeight);\n }, [lastAnchorExists]);\n\n // Find the first href for which the element is within the viewport\n const findHrefInView = useCallback(() => {\n return hrefs.find(href => {\n const rect = getRectByHref(href);\n return rect && rect.bottom <= window.innerHeight && rect.top >= scrollSpyOffset;\n });\n }, [getRectByHref, scrollSpyOffset, hrefs]);\n\n // Find the last href where its element is above or within the viewport\n const findLastHrefInView = useCallback(() => {\n return [...hrefs].reverse().find(href => {\n const rect = getRectByHref(href);\n return rect && rect.bottom <= window.innerHeight;\n });\n }, [getRectByHref, hrefs]);\n\n // Scroll event handler\n const handleScroll = useCallback(() => {\n if (activeHref || !isBrowser) {\n return;\n }\n\n const { scrollY } = window;\n\n if (document.body.scrollHeight > window.innerHeight && isPageBottom()) {\n setCurrentHref(hrefs[hrefs.length - 1]);\n } else {\n setCurrentHref(findHrefInView() || (scrollY > 0 ? findLastHrefInView() : undefined));\n }\n }, [activeHref, isPageBottom, findHrefInView, findLastHrefInView, hrefs]);\n\n useEffect(() => {\n if (isBrowser) {\n handleScroll();\n window.addEventListener('scroll', handleScroll, { passive: true });\n return () => {\n window.removeEventListener('scroll', handleScroll);\n };\n }\n }, [handleScroll]);\n\n return currentHref;\n}\n"]}