@cloudscape-design/components-themeable 3.0.1325 → 3.0.1327

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 (153) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/action-card/styles.scss +4 -2
  3. package/lib/internal/scss/badge/styles.scss +4 -4
  4. package/lib/internal/scss/box/styles.scss +1 -0
  5. package/lib/internal/scss/box/visual-accent.scss +117 -0
  6. package/lib/internal/scss/button-dropdown/styles.scss +6 -0
  7. package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
  8. package/lib/internal/scss/link/constants.scss +2 -2
  9. package/lib/internal/scss/side-navigation/styles.scss +6 -0
  10. package/lib/internal/template/action-card/interfaces.d.ts +40 -1
  11. package/lib/internal/template/action-card/interfaces.d.ts.map +1 -1
  12. package/lib/internal/template/action-card/interfaces.js.map +1 -1
  13. package/lib/internal/template/action-card/internal.d.ts.map +1 -1
  14. package/lib/internal/template/action-card/internal.js +32 -9
  15. package/lib/internal/template/action-card/internal.js.map +1 -1
  16. package/lib/internal/template/action-card/styles.css.js +17 -17
  17. package/lib/internal/template/action-card/styles.scoped.css +96 -92
  18. package/lib/internal/template/action-card/styles.selectors.js +17 -17
  19. package/lib/internal/template/badge/styles.css.js +10 -10
  20. package/lib/internal/template/badge/styles.scoped.css +14 -14
  21. package/lib/internal/template/badge/styles.selectors.js +10 -10
  22. package/lib/internal/template/box/interfaces.d.ts +59 -0
  23. package/lib/internal/template/box/interfaces.d.ts.map +1 -1
  24. package/lib/internal/template/box/interfaces.js.map +1 -1
  25. package/lib/internal/template/box/internal.d.ts +1 -1
  26. package/lib/internal/template/box/internal.d.ts.map +1 -1
  27. package/lib/internal/template/box/internal.js +4 -2
  28. package/lib/internal/template/box/internal.js.map +1 -1
  29. package/lib/internal/template/box/styles.css.js +224 -193
  30. package/lib/internal/template/box/styles.scoped.css +424 -238
  31. package/lib/internal/template/box/styles.selectors.js +224 -193
  32. package/lib/internal/template/button-dropdown/category-elements/category-element.d.ts +1 -1
  33. package/lib/internal/template/button-dropdown/category-elements/category-element.d.ts.map +1 -1
  34. package/lib/internal/template/button-dropdown/category-elements/category-element.js +3 -3
  35. package/lib/internal/template/button-dropdown/category-elements/category-element.js.map +1 -1
  36. package/lib/internal/template/button-dropdown/category-elements/expandable-category-element.d.ts +1 -1
  37. package/lib/internal/template/button-dropdown/category-elements/expandable-category-element.d.ts.map +1 -1
  38. package/lib/internal/template/button-dropdown/category-elements/expandable-category-element.js +22 -12
  39. package/lib/internal/template/button-dropdown/category-elements/expandable-category-element.js.map +1 -1
  40. package/lib/internal/template/button-dropdown/category-elements/mobile-expandable-category-element.d.ts +1 -1
  41. package/lib/internal/template/button-dropdown/category-elements/mobile-expandable-category-element.d.ts.map +1 -1
  42. package/lib/internal/template/button-dropdown/category-elements/mobile-expandable-category-element.js +12 -10
  43. package/lib/internal/template/button-dropdown/category-elements/mobile-expandable-category-element.js.map +1 -1
  44. package/lib/internal/template/button-dropdown/filter.d.ts +8 -0
  45. package/lib/internal/template/button-dropdown/filter.d.ts.map +1 -0
  46. package/lib/internal/template/button-dropdown/filter.js +18 -0
  47. package/lib/internal/template/button-dropdown/filter.js.map +1 -0
  48. package/lib/internal/template/button-dropdown/index.d.ts.map +1 -1
  49. package/lib/internal/template/button-dropdown/index.js +3 -3
  50. package/lib/internal/template/button-dropdown/index.js.map +1 -1
  51. package/lib/internal/template/button-dropdown/interfaces.d.ts +41 -0
  52. package/lib/internal/template/button-dropdown/interfaces.d.ts.map +1 -1
  53. package/lib/internal/template/button-dropdown/interfaces.js.map +1 -1
  54. package/lib/internal/template/button-dropdown/internal-interfaces.d.ts +12 -0
  55. package/lib/internal/template/button-dropdown/internal-interfaces.d.ts.map +1 -1
  56. package/lib/internal/template/button-dropdown/internal-interfaces.js.map +1 -1
  57. package/lib/internal/template/button-dropdown/internal.d.ts.map +1 -1
  58. package/lib/internal/template/button-dropdown/internal.js +46 -7
  59. package/lib/internal/template/button-dropdown/internal.js.map +1 -1
  60. package/lib/internal/template/button-dropdown/item-element/index.d.ts +1 -1
  61. package/lib/internal/template/button-dropdown/item-element/index.d.ts.map +1 -1
  62. package/lib/internal/template/button-dropdown/item-element/index.js +35 -16
  63. package/lib/internal/template/button-dropdown/item-element/index.js.map +1 -1
  64. package/lib/internal/template/button-dropdown/items-list.d.ts +1 -1
  65. package/lib/internal/template/button-dropdown/items-list.d.ts.map +1 -1
  66. package/lib/internal/template/button-dropdown/items-list.js +4 -4
  67. package/lib/internal/template/button-dropdown/items-list.js.map +1 -1
  68. package/lib/internal/template/button-dropdown/styles.css.js +23 -22
  69. package/lib/internal/template/button-dropdown/styles.scoped.css +38 -32
  70. package/lib/internal/template/button-dropdown/styles.selectors.js +23 -22
  71. package/lib/internal/template/button-dropdown/tooltip.d.ts +2 -1
  72. package/lib/internal/template/button-dropdown/tooltip.d.ts.map +1 -1
  73. package/lib/internal/template/button-dropdown/tooltip.js +22 -14
  74. package/lib/internal/template/button-dropdown/tooltip.js.map +1 -1
  75. package/lib/internal/template/button-dropdown/utils/filter-items.d.ts +4 -0
  76. package/lib/internal/template/button-dropdown/utils/filter-items.d.ts.map +1 -0
  77. package/lib/internal/template/button-dropdown/utils/filter-items.js +55 -0
  78. package/lib/internal/template/button-dropdown/utils/filter-items.js.map +1 -0
  79. package/lib/internal/template/button-dropdown/utils/use-button-dropdown.d.ts +7 -1
  80. package/lib/internal/template/button-dropdown/utils/use-button-dropdown.d.ts.map +1 -1
  81. package/lib/internal/template/button-dropdown/utils/use-button-dropdown.js +77 -13
  82. package/lib/internal/template/button-dropdown/utils/use-button-dropdown.js.map +1 -1
  83. package/lib/internal/template/code-editor/interfaces.js.map +1 -1
  84. package/lib/internal/template/error-boundary/internal.d.ts.map +1 -1
  85. package/lib/internal/template/error-boundary/internal.js +1 -0
  86. package/lib/internal/template/error-boundary/internal.js.map +1 -1
  87. package/lib/internal/template/help-panel/styles.css.js +6 -6
  88. package/lib/internal/template/help-panel/styles.scoped.css +69 -69
  89. package/lib/internal/template/help-panel/styles.selectors.js +6 -6
  90. package/lib/internal/template/icon/generated/icons.d.ts +1 -0
  91. package/lib/internal/template/icon/generated/icons.d.ts.map +1 -1
  92. package/lib/internal/template/icon/generated/icons.js +2 -0
  93. package/lib/internal/template/icon/generated/icons.js.map +1 -1
  94. package/lib/internal/template/icon-provider/interfaces.d.ts +1 -1
  95. package/lib/internal/template/icon-provider/interfaces.d.ts.map +1 -1
  96. package/lib/internal/template/icon-provider/interfaces.js.map +1 -1
  97. package/lib/internal/template/internal/base-component/index.js +3 -3
  98. package/lib/internal/template/internal/base-component/index.js.map +1 -1
  99. package/lib/internal/template/internal/base-component/styles.scoped.css +33 -1
  100. package/lib/internal/template/internal/components/token-list/styles.css.js +10 -10
  101. package/lib/internal/template/internal/components/token-list/styles.scoped.css +24 -24
  102. package/lib/internal/template/internal/components/token-list/styles.selectors.js +10 -10
  103. package/lib/internal/template/internal/environment.js +2 -2
  104. package/lib/internal/template/internal/environment.json +2 -2
  105. package/lib/internal/template/internal/generated/styles/tokens.d.ts +140 -0
  106. package/lib/internal/template/internal/generated/styles/tokens.js +140 -0
  107. package/lib/internal/template/internal/generated/theming/index.cjs +2080 -20
  108. package/lib/internal/template/internal/generated/theming/index.cjs.d.ts +45 -0
  109. package/lib/internal/template/internal/generated/theming/index.d.ts +45 -0
  110. package/lib/internal/template/internal/generated/theming/index.js +2080 -20
  111. package/lib/internal/template/internal/utils/external-props.js +7 -5
  112. package/lib/internal/template/internal/utils/external-props.js.map +1 -1
  113. package/lib/internal/template/item-card/internal.js +1 -1
  114. package/lib/internal/template/item-card/internal.js.map +1 -1
  115. package/lib/internal/template/link/styles.css.js +21 -21
  116. package/lib/internal/template/link/styles.scoped.css +86 -86
  117. package/lib/internal/template/link/styles.selectors.js +21 -21
  118. package/lib/internal/template/multiselect/embedded.d.ts +2 -2
  119. package/lib/internal/template/multiselect/internal.d.ts +1 -1
  120. package/lib/internal/template/pagination/internal.d.ts.map +1 -1
  121. package/lib/internal/template/pagination/internal.js +2 -2
  122. package/lib/internal/template/pagination/internal.js.map +1 -1
  123. package/lib/internal/template/select/parts/filter.d.ts +1 -1
  124. package/lib/internal/template/select/utils/connect-options.d.ts.map +1 -1
  125. package/lib/internal/template/select/utils/connect-options.js +11 -7
  126. package/lib/internal/template/select/utils/connect-options.js.map +1 -1
  127. package/lib/internal/template/select/utils/use-select.d.ts.map +1 -1
  128. package/lib/internal/template/select/utils/use-select.js +5 -4
  129. package/lib/internal/template/select/utils/use-select.js.map +1 -1
  130. package/lib/internal/template/side-navigation/parts.js +4 -3
  131. package/lib/internal/template/side-navigation/parts.js.map +1 -1
  132. package/lib/internal/template/side-navigation/styles.css.js +47 -46
  133. package/lib/internal/template/side-navigation/styles.scoped.css +76 -70
  134. package/lib/internal/template/side-navigation/styles.selectors.js +47 -46
  135. package/lib/internal/template/table/index.d.ts.map +1 -1
  136. package/lib/internal/template/table/index.js +5 -3
  137. package/lib/internal/template/table/index.js.map +1 -1
  138. package/lib/internal/template/test-utils/dom/action-card/index.d.ts +4 -2
  139. package/lib/internal/template/test-utils/dom/action-card/index.js +5 -3
  140. package/lib/internal/template/test-utils/dom/action-card/index.js.map +1 -1
  141. package/lib/internal/template/test-utils/dom/button-dropdown/index.d.ts +16 -0
  142. package/lib/internal/template/test-utils/dom/button-dropdown/index.js +24 -0
  143. package/lib/internal/template/test-utils/dom/button-dropdown/index.js.map +1 -1
  144. package/lib/internal/template/test-utils/dom/pagination/index.d.ts +9 -6
  145. package/lib/internal/template/test-utils/dom/pagination/index.js +15 -5
  146. package/lib/internal/template/test-utils/dom/pagination/index.js.map +1 -1
  147. package/lib/internal/template/test-utils/selectors/button-dropdown/index.d.ts +16 -0
  148. package/lib/internal/template/test-utils/selectors/button-dropdown/index.js +24 -0
  149. package/lib/internal/template/test-utils/selectors/button-dropdown/index.js.map +1 -1
  150. package/lib/internal/template/test-utils/selectors/pagination/index.d.ts +8 -6
  151. package/lib/internal/template/test-utils/selectors/pagination/index.js +9 -5
  152. package/lib/internal/template/test-utils/selectors/pagination/index.js.map +1 -1
  153. package/package.json +1 -1
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "45502c04e248f53271215aeb14362cf0f2551cc1"
2
+ "commit": "3f01803dd43a9bc50956b6ebcd760b686c18aa38"
3
3
  }
@@ -163,11 +163,13 @@
163
163
  @include mixins.apply-state-styles('disabled');
164
164
  }
165
165
 
166
- &:not(.disabled):has(button:hover) {
166
+ &:not(.disabled):has(.header-button:hover),
167
+ &:not(.disabled):has(.overlay-button:hover) {
167
168
  @include mixins.apply-state-styles('hover');
168
169
  }
169
170
 
170
- &:not(.disabled):has(button:active) {
171
+ &:not(.disabled):has(.header-button:active),
172
+ &:not(.disabled):has(.overlay-button:active) {
171
173
  @include mixins.apply-state-styles('active');
172
174
  }
173
175
 
@@ -24,25 +24,25 @@
24
24
  color: awsui.$color-text-notification-default;
25
25
 
26
26
  &.badge-color-grey {
27
- background-color: awsui.$color-background-notification-grey;
27
+ background-color: awsui.$color-background-badge-grey;
28
28
  border-color: awsui.$color-border-badge-grey;
29
29
  color: awsui.$color-text-badge-grey;
30
30
  }
31
31
 
32
32
  &.badge-color-green {
33
- background-color: awsui.$color-background-notification-green;
33
+ background-color: awsui.$color-background-badge-green;
34
34
  border-color: awsui.$color-border-badge-green;
35
35
  color: awsui.$color-text-badge-green;
36
36
  }
37
37
 
38
38
  &.badge-color-blue {
39
- background-color: awsui.$color-background-notification-blue;
39
+ background-color: awsui.$color-background-badge-blue;
40
40
  border-color: awsui.$color-border-badge-blue;
41
41
  color: awsui.$color-text-badge-blue;
42
42
  }
43
43
 
44
44
  &.badge-color-red {
45
- background-color: awsui.$color-background-notification-red;
45
+ background-color: awsui.$color-background-badge-red;
46
46
  border-color: awsui.$color-border-badge-red;
47
47
  color: awsui.$color-text-badge-red;
48
48
  }
@@ -6,6 +6,7 @@
6
6
  @use '../internal/styles' as styles;
7
7
  @use './text';
8
8
  @use './layout';
9
+ @use './visual-accent';
9
10
 
10
11
  .root {
11
12
  @include styles.default-text-style;
@@ -0,0 +1,117 @@
1
+ /*
2
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ @use 'sass:map';
7
+ @use 'sass:meta';
8
+ @use '../internal/styles/tokens' as awsui;
9
+
10
+ // T-shirt size keywords mirror the Box spacing scale (see spacing.scss).
11
+ // `full` renders fully rounded corners (a circle when combined with `aspectRatio: 'equal'`).
12
+ $accent-radii: (
13
+ 'xxxs': awsui.$space-xxxs,
14
+ 'xxs': awsui.$space-xxs,
15
+ 'xs': awsui.$space-xs,
16
+ 's': awsui.$space-s,
17
+ 'm': awsui.$space-m,
18
+ 'l': awsui.$space-l,
19
+ 'xl': awsui.$space-xl,
20
+ 'xxl': awsui.$space-xxl,
21
+ 'xxxl': awsui.$space-xxxl,
22
+ 'full': 50%,
23
+ );
24
+
25
+ @mixin accent-radius($value) {
26
+ border-start-start-radius: $value;
27
+ border-start-end-radius: $value;
28
+ border-end-start-radius: $value;
29
+ border-end-end-radius: $value;
30
+ }
31
+
32
+ // ─── Base visual accent container ─────────────────────────────────────────────
33
+ // Applied whenever the `visualAccent` prop is set. Provides the container layout. Corners are
34
+ // square by default; the `.visual-accent-radius-*` classes below apply corner rounding for the
35
+ // curated `borderRadius` keywords.
36
+ .visual-accent {
37
+ display: inline-flex;
38
+ align-items: center;
39
+ justify-content: center;
40
+ padding-block: awsui.$space-xxs;
41
+ padding-inline: awsui.$space-xs;
42
+ box-sizing: border-box;
43
+ }
44
+
45
+ // ─── Accent border radius (t-shirt size keywords) ─────────────────────────────
46
+ // Mirror the Box spacing scale so `borderRadius` keywords align with `padding` / `margin`.
47
+ @each $name, $value in $accent-radii {
48
+ .visual-accent-radius-#{$name} {
49
+ @include accent-radius($value);
50
+ }
51
+ }
52
+
53
+ // ─── Accent aspect ratio ──────────────────────────────────────────────────────
54
+ // `auto` — default; the container's width follows its content.
55
+ // `equal` — equal width and height, suitable for icon wrapping. Combine with
56
+ // `borderRadius: 'full'` to render a circle.
57
+
58
+ .visual-accent-aspect-auto {
59
+ // Reset any square constraints so content can size the container naturally.
60
+ aspect-ratio: auto;
61
+ inline-size: auto;
62
+ }
63
+
64
+ .visual-accent-aspect-equal {
65
+ // Equal padding on all sides.
66
+ padding-block: awsui.$space-xs;
67
+ padding-inline: awsui.$space-xs;
68
+ // Force the element to be a square regardless of content dimensions.
69
+ // The width is constrained to match the height (content + padding).
70
+ aspect-ratio: 1 / 1;
71
+ // Prevent content from stretching the box wider than tall.
72
+ overflow: hidden;
73
+ // Let the box shrink-wrap to its height, width follows via aspect-ratio.
74
+ inline-size: fit-content;
75
+ }
76
+
77
+ // ─── Accent colors ──────────────────────────────────────────────────────────────
78
+ // Light/dark values are resolved by the design tokens, so no explicit dark-mode
79
+ // overrides are needed here.
80
+ //
81
+ // The selectors chain the `.visual-accent` base class with the `.visual-accent-{color}`
82
+ // modifier (both are always applied together whenever `visualAccent` is set) to reach a
83
+ // specificity of (0,3,0). This intentionally beats the `color` prop's `.box.color-*`
84
+ // selector (0,2,0) so the accent's coordinated foreground color always wins, regardless of
85
+ // stylesheet source order. Winning here preserves the guaranteed background/foreground color
86
+ // contrast of the accent pair. Descendants (nested Box, Icon) inherit this color.
87
+ //
88
+ // Token variables are looked up dynamically from the tokens module, so adding a color only
89
+ // requires extending `$accent-colors`.
90
+ $accent-colors: (
91
+ 'red',
92
+ 'yellow',
93
+ 'indigo',
94
+ 'green',
95
+ 'orange',
96
+ 'purple',
97
+ 'mint',
98
+ 'lime',
99
+ 'grey',
100
+ 'teal',
101
+ 'cyan',
102
+ 'blue',
103
+ 'violet',
104
+ 'fuchsia',
105
+ 'magenta',
106
+ 'pink',
107
+ 'rose',
108
+ 'amber'
109
+ );
110
+ $tokens: meta.module-variables('awsui');
111
+
112
+ @each $accent in $accent-colors {
113
+ .box.visual-accent.visual-accent-#{$accent} {
114
+ background-color: map.get($tokens, 'color-background-accent-#{$accent}');
115
+ color: map.get($tokens, 'color-text-accent-#{$accent}');
116
+ }
117
+ }
@@ -145,6 +145,12 @@ $dropdown-trigger-icon-offset: 2px;
145
145
  flex: 0 0 auto;
146
146
  }
147
147
 
148
+ .filter {
149
+ position: relative;
150
+ z-index: 4;
151
+ flex-shrink: 0;
152
+ }
153
+
148
154
  .test-utils-button-trigger {
149
155
  /* used in test-utils */
150
156
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Build environment
3
- $awsui-commit-hash: "45502c04";
3
+ $awsui-commit-hash: "3f01803d";
4
4
  // Manually managed CSS-variables
5
5
  $maxContentWidth: --awsui-max-content-width-6b9ypa;
6
6
  $minContentWidth: --awsui-min-content-width-6b9ypa;
@@ -63,10 +63,10 @@ $link-variants: (
63
63
  'text-color-default': awsui.$color-text-link-secondary-default,
64
64
  'text-color-hover': awsui.$color-text-link-secondary-hover,
65
65
  'text-color-active': awsui.$color-text-link-secondary-hover,
66
- 'font-weight': inherit,
66
+ 'font-weight': awsui.$font-weight-link-secondary,
67
67
  'decoration-line': none,
68
68
  'decoration-color': transparent,
69
- 'decoration-color-hover': currentColor,
69
+ 'decoration-color-hover': awsui.$color-text-link-decoration-hover,
70
70
  'letter-spacing': normal,
71
71
  ),
72
72
  'primary': (
@@ -250,6 +250,12 @@ $expandable-icon-negative-margin: awsui.$space-l;
250
250
  }
251
251
  }
252
252
 
253
+ .section-header {
254
+ display: contents;
255
+ font-size: awsui.$font-side-navigation-section-header-size;
256
+ font-weight: awsui.$font-side-navigation-section-header-weight;
257
+ }
258
+
253
259
  // ==========================================================================
254
260
  // Section groups
255
261
  // ==========================================================================
@@ -1,6 +1,6 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { BaseComponentProps } from '../types/base-component';
3
- import { CancelableEventHandler } from '../types/events';
3
+ import { BaseNavigationDetail, CancelableEventHandler } from '../types/events';
4
4
  import { NativeAttributes } from '../types/native-attributes';
5
5
  export interface ActionCardProps extends BaseComponentProps {
6
6
  /**
@@ -19,6 +19,33 @@ export interface ActionCardProps extends BaseComponentProps {
19
19
  * Called when the user clicks on the action card.
20
20
  */
21
21
  onClick?: CancelableEventHandler<ActionCardProps.ClickDetail>;
22
+ /**
23
+ * Turns the action card into a link, pointing to the given URL. The card is rendered using an `a` element instead of a `button`.
24
+ * For example, use this property if selecting the card should navigate the user to another page.
25
+ */
26
+ href?: string;
27
+ /**
28
+ * Specifies where to open the linked URL (for example, to open in a new browser window or tab use `_blank`).
29
+ * This property only applies when an `href` is provided.
30
+ */
31
+ target?: string;
32
+ /**
33
+ * Adds a `rel` attribute to the link. By default, the component sets the `rel` attribute to "noopener noreferrer" when `target` is `"_blank"`.
34
+ * If the `rel` property is provided, it overrides the default behavior.
35
+ * This property only applies when an `href` is provided.
36
+ */
37
+ rel?: string;
38
+ /**
39
+ * Specifies whether the linked URL, when selected, will prompt the user to download instead of navigate.
40
+ * You can specify a string value that will be suggested as the name of the downloaded file.
41
+ * This property only applies when an `href` is provided.
42
+ */
43
+ download?: boolean | string;
44
+ /**
45
+ * Called when the user clicks on the action card with the left mouse button without pressing
46
+ * modifier keys (that is, CTRL, ALT, SHIFT, META), and the action card has an `href` set.
47
+ */
48
+ onFollow?: CancelableEventHandler<ActionCardProps.FollowDetail>;
22
49
  /**
23
50
  * Adds an aria-label to the action card.
24
51
  */
@@ -65,10 +92,22 @@ export interface ActionCardProps extends BaseComponentProps {
65
92
  * @awsuiSystem core
66
93
  */
67
94
  nativeButtonAttributes?: NativeAttributes<React.ButtonHTMLAttributes<HTMLButtonElement>>;
95
+ /**
96
+ * Attributes to add to the native `a` element (when `href` is provided).
97
+ * Some attributes will be automatically combined with internal attribute values:
98
+ * - `className` will be appended.
99
+ * - Event handlers will be chained, unless the default is prevented.
100
+ *
101
+ * We do not support using this attribute to apply custom styling.
102
+ *
103
+ * @awsuiSystem core
104
+ */
105
+ nativeAnchorAttributes?: NativeAttributes<React.AnchorHTMLAttributes<HTMLAnchorElement>>;
68
106
  }
69
107
  export declare namespace ActionCardProps {
70
108
  interface ClickDetail {
71
109
  }
110
+ type FollowDetail = BaseNavigationDetail;
72
111
  type IconVerticalAlignment = 'top' | 'center';
73
112
  type Variant = 'default' | 'embedded';
74
113
  interface Ref {
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/action-card/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,MAAM,WAAW,eAAgB,SAAQ,kBAAkB;IACzD;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,sBAAsB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IAE9D;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEvB;;OAEG;IACH,qBAAqB,CAAC,EAAE,eAAe,CAAC,qBAAqB,CAAC;IAE9D;;;;;OAKG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC;IAElC;;;;;;;;;OASG;IACH,sBAAsB,CA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E,MAAM,CAAC;IAEnB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEvB;;OAEG;IACH,qBAAqB,CAAC,EAAE,eAAe,CAAC,qBAAqB,CAAC;IAE9D;;;;;OAKG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC;IAElC;;;;;;;;;OASG;IACH,sBAAsB,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAEzF;;;;;;;;;OASG;IACH,sBAAsB,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC,CAAC;CAC1F;AAED,yBAAiB,eAAe,CAAC;IAE/B,UAAiB,WAAW;KAAG;IAE/B,KAAY,YAAY,GAAG,oBAAoB,CAAC;IAEhD,KAAY,qBAAqB,GAAG,KAAK,GAAG,QAAQ,CAAC;IACrD,KAAY,OAAO,GAAG,SAAS,GAAG,UAAU,CAAC;IAE7C,UAAiB,GAAG;QAClB;;WAEG;QACH,KAAK,IAAI,IAAI,CAAC;KACf;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/action-card/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { ReactNode } from 'react';\n\nimport { BaseComponentProps } from '../types/base-component';\nimport { CancelableEventHandler } from '../types/events';\nimport { NativeAttributes } from '../types/native-attributes';\n\nexport interface ActionCardProps extends BaseComponentProps {\n /**\n * The header content displayed at the top of the action card.\n */\n header?: ReactNode;\n\n /**\n * The description content displayed below the header.\n */\n description?: ReactNode;\n\n /**\n * The main content of the action card.\n */\n children?: ReactNode;\n\n /**\n * Called when the user clicks on the action card.\n */\n onClick?: CancelableEventHandler<ActionCardProps.ClickDetail>;\n\n /**\n * Adds an aria-label to the action card.\n */\n ariaLabel?: string;\n\n /**\n * Adds an aria-describedby reference for the action card.\n */\n ariaDescribedby?: string;\n\n /**\n * Determines whether the action card is disabled.\n */\n disabled?: boolean;\n\n /**\n * Removes the default padding from the header area.\n */\n disableHeaderPaddings?: boolean;\n\n /**\n * Removes the default padding from the content area.\n */\n disableContentPaddings?: boolean;\n\n /**\n * Displays an icon next to the content. You can use the `iconVerticalAlignment` property to control vertical alignment.\n */\n icon?: React.ReactNode;\n\n /**\n * Specifies the vertical alignment of the icon.\n */\n iconVerticalAlignment?: ActionCardProps.IconVerticalAlignment;\n\n /**\n * Specifies the visual variant of the card, which controls the border radius and padding.\n *\n * - `default` - Uses container-level border radius and padding (larger).\n * - `embedded` - Uses compact border radius and padding (smaller).\n */\n variant?: ActionCardProps.Variant;\n\n /**\n * Attributes to add to the native button element.\n * Some attributes will be automatically combined with internal attribute values:\n * - `className` will be appended.\n * - Event handlers will be chained, unless the default is prevented.\n *\n * We do not support using this attribute to apply custom styling.\n *\n * @awsuiSystem core\n */\n nativeButtonAttributes?: NativeAttributes<React.ButtonHTMLAttributes<HTMLButtonElement>>;\n}\n\nexport namespace ActionCardProps {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n export interface ClickDetail {}\n\n export type IconVerticalAlignment = 'top' | 'center';\n export type Variant = 'default' | 'embedded';\n\n export interface Ref {\n /**\n * Sets focus on the action card.\n */\n focus(): void;\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/action-card/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { ReactNode } from 'react';\n\nimport { BaseComponentProps } from '../types/base-component';\nimport { BaseNavigationDetail, CancelableEventHandler } from '../types/events';\nimport { NativeAttributes } from '../types/native-attributes';\n\nexport interface ActionCardProps extends BaseComponentProps {\n /**\n * The header content displayed at the top of the action card.\n */\n header?: ReactNode;\n\n /**\n * The description content displayed below the header.\n */\n description?: ReactNode;\n\n /**\n * The main content of the action card.\n */\n children?: ReactNode;\n\n /**\n * Called when the user clicks on the action card.\n */\n onClick?: CancelableEventHandler<ActionCardProps.ClickDetail>;\n\n /**\n * Turns the action card into a link, pointing to the given URL. The card is rendered using an `a` element instead of a `button`.\n * For example, use this property if selecting the card should navigate the user to another page.\n */\n href?: string;\n\n /**\n * Specifies where to open the linked URL (for example, to open in a new browser window or tab use `_blank`).\n * This property only applies when an `href` is provided.\n */\n target?: string;\n\n /**\n * Adds a `rel` attribute to the link. By default, the component sets the `rel` attribute to \"noopener noreferrer\" when `target` is `\"_blank\"`.\n * If the `rel` property is provided, it overrides the default behavior.\n * This property only applies when an `href` is provided.\n */\n rel?: string;\n\n /**\n * Specifies whether the linked URL, when selected, will prompt the user to download instead of navigate.\n * You can specify a string value that will be suggested as the name of the downloaded file.\n * This property only applies when an `href` is provided.\n */\n download?: boolean | string;\n\n /**\n * Called when the user clicks on the action card with the left mouse button without pressing\n * modifier keys (that is, CTRL, ALT, SHIFT, META), and the action card has an `href` set.\n */\n onFollow?: CancelableEventHandler<ActionCardProps.FollowDetail>;\n\n /**\n * Adds an aria-label to the action card.\n */\n ariaLabel?: string;\n\n /**\n * Adds an aria-describedby reference for the action card.\n */\n ariaDescribedby?: string;\n\n /**\n * Determines whether the action card is disabled.\n */\n disabled?: boolean;\n\n /**\n * Removes the default padding from the header area.\n */\n disableHeaderPaddings?: boolean;\n\n /**\n * Removes the default padding from the content area.\n */\n disableContentPaddings?: boolean;\n\n /**\n * Displays an icon next to the content. You can use the `iconVerticalAlignment` property to control vertical alignment.\n */\n icon?: React.ReactNode;\n\n /**\n * Specifies the vertical alignment of the icon.\n */\n iconVerticalAlignment?: ActionCardProps.IconVerticalAlignment;\n\n /**\n * Specifies the visual variant of the card, which controls the border radius and padding.\n *\n * - `default` - Uses container-level border radius and padding (larger).\n * - `embedded` - Uses compact border radius and padding (smaller).\n */\n variant?: ActionCardProps.Variant;\n\n /**\n * Attributes to add to the native button element.\n * Some attributes will be automatically combined with internal attribute values:\n * - `className` will be appended.\n * - Event handlers will be chained, unless the default is prevented.\n *\n * We do not support using this attribute to apply custom styling.\n *\n * @awsuiSystem core\n */\n nativeButtonAttributes?: NativeAttributes<React.ButtonHTMLAttributes<HTMLButtonElement>>;\n\n /**\n * Attributes to add to the native `a` element (when `href` is provided).\n * Some attributes will be automatically combined with internal attribute values:\n * - `className` will be appended.\n * - Event handlers will be chained, unless the default is prevented.\n *\n * We do not support using this attribute to apply custom styling.\n *\n * @awsuiSystem core\n */\n nativeAnchorAttributes?: NativeAttributes<React.AnchorHTMLAttributes<HTMLAnchorElement>>;\n}\n\nexport namespace ActionCardProps {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n export interface ClickDetail {}\n\n export type FollowDetail = BaseNavigationDetail;\n\n export type IconVerticalAlignment = 'top' | 'center';\n export type Variant = 'default' | 'embedded';\n\n export interface Ref {\n /**\n * Sets focus on the action card.\n */\n focus(): void;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/action-card/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAStC,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/C,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG,0BAA0B,CAAC;AAEnF,QAAA,MAAM,kBAAkB,0HA8LvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/action-card/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAStC,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/C,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG,0BAA0B,CAAC;AAEnF,QAAA,MAAM,kBAAkB,0HAiOvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -5,20 +5,23 @@ import clsx from 'clsx';
5
5
  import { useMergeRefs, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';
6
6
  import { getBaseProps } from '../internal/base-component';
7
7
  import InternalStructuredItem from '../internal/components/structured-item';
8
- import { fireCancelableEvent } from '../internal/events';
8
+ import { fireCancelableEvent, isPlainLeftClick } from '../internal/events';
9
9
  import useForwardFocus from '../internal/hooks/forward-focus';
10
+ import { checkSafeUrl } from '../internal/utils/check-safe-url';
10
11
  import WithNativeAttributes from '../internal/utils/with-native-attributes';
11
12
  import styles from './styles.css.js';
12
13
  import testStyles from './test-classes/styles.css.js';
13
- const InternalActionCard = React.forwardRef(({ header, description, children, onClick, ariaLabel, ariaDescribedby, disabled, disableHeaderPaddings, disableContentPaddings, icon, iconVerticalAlignment, variant, nativeButtonAttributes, __internalRootRef, ...rest }, ref) => {
14
+ const InternalActionCard = React.forwardRef(({ header, description, children, onClick, onFollow, href, target, rel, download, ariaLabel, ariaDescribedby, disabled, disableHeaderPaddings, disableContentPaddings, icon, iconVerticalAlignment, variant, nativeButtonAttributes, nativeAnchorAttributes, __internalRootRef, ...rest }, ref) => {
14
15
  const baseProps = getBaseProps(rest);
15
- const buttonRef = useRef(null);
16
+ const containerRef = useRef(null);
16
17
  const rootRef = useRef(null);
17
18
  const headerId = useUniqueId('action-card-header-');
18
19
  const standaloneButtonId = useUniqueId('action-card-button-');
19
20
  const descriptionId = useUniqueId('action-card-description-');
20
21
  const bodyId = useUniqueId('action-card-body-');
21
- useForwardFocus(ref, buttonRef);
22
+ useForwardFocus(ref, containerRef);
23
+ checkSafeUrl('ActionCard', href);
24
+ const isAnchor = Boolean(href);
22
25
  if (!header && !ariaLabel) {
23
26
  warnOnce('ActionCard', 'An accessible name is required. Provide either a `header` or an `ariaLabel` prop so the action card has a meaningful label for screen reader users.');
24
27
  }
@@ -26,6 +29,9 @@ const InternalActionCard = React.forwardRef(({ header, description, children, on
26
29
  if (disabled) {
27
30
  return event.preventDefault();
28
31
  }
32
+ if (isAnchor && isPlainLeftClick(event)) {
33
+ fireCancelableEvent(onFollow, { href, target }, event);
34
+ }
29
35
  fireCancelableEvent(onClick, {}, event);
30
36
  };
31
37
  const headerRowEmpty = !header && !description;
@@ -37,16 +43,26 @@ const InternalActionCard = React.forwardRef(({ header, description, children, on
37
43
  if (!ariaDescribedby && description && (ariaLabel || header)) {
38
44
  ariaDescribedby = descriptionId;
39
45
  }
40
- const buttonProps = {
41
- type: 'button',
46
+ // Shared props between <a>-tag and <button>-tag
47
+ const interactiveProps = {
42
48
  className: clsx(styles['header-button'], testStyles.button, disabled && styles.disabled, variant && styles[`variant-${variant}`]),
43
49
  onClick: handleButtonClick,
44
50
  'aria-describedby': ariaDescribedby,
45
51
  'aria-disabled': disabled || undefined,
46
52
  };
53
+ // <a>-tag specific props
54
+ const anchorProps = {
55
+ href: disabled ? undefined : href,
56
+ role: disabled ? 'link' : undefined,
57
+ tabIndex: disabled ? 0 : undefined,
58
+ target,
59
+ // security recommendation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target
60
+ rel: rel !== null && rel !== void 0 ? rel : (target === '_blank' ? 'noopener noreferrer' : undefined),
61
+ download,
62
+ };
63
+ const renderInteractiveElement = (props, children) => isAnchor ? (React.createElement(WithNativeAttributes, { ...props, ...anchorProps, tag: "a", componentName: "ActionCard", nativeAttributes: nativeAnchorAttributes, ref: containerRef }, children)) : (React.createElement(WithNativeAttributes, { ...props, type: "button", tag: "button", componentName: "ActionCard", nativeAttributes: nativeButtonAttributes, ref: containerRef }, children));
47
64
  const headerSection = !headerRowEmpty ? (React.createElement("div", { className: clsx(styles.header, disableHeaderPaddings && styles['no-padding']) },
48
- React.createElement(InternalStructuredItem, { content: header && (React.createElement("div", { className: clsx(styles['header-inner'], testStyles.header, disabled && styles.disabled) },
49
- React.createElement(WithNativeAttributes, { ...buttonProps, tag: "button", componentName: "ActionCard", nativeAttributes: nativeButtonAttributes, ref: buttonRef, id: headerId }, header))), secondaryContent: description && (React.createElement("div", { id: descriptionId, className: clsx(styles.description, testStyles.description, disabled && styles.disabled, header && styles['has-header']) }, description)), disablePaddings: disableHeaderPaddings }))) : null;
65
+ React.createElement(InternalStructuredItem, { content: header && (React.createElement("div", { className: clsx(styles['header-inner'], testStyles.header, disabled && styles.disabled) }, renderInteractiveElement({ ...interactiveProps, id: headerId }, header))), secondaryContent: description && (React.createElement("div", { id: descriptionId, className: clsx(styles.description, testStyles.description, disabled && styles.disabled, header && styles['has-header']) }, description)), disablePaddings: disableHeaderPaddings }))) : null;
50
66
  // When there's no header, a standalone overlay button is rendered.
51
67
  // If ariaLabel is provided, it's used directly. Otherwise, derive the button's
52
68
  // accessible name from the first available content: description or children.
@@ -59,7 +75,14 @@ const InternalActionCard = React.forwardRef(({ header, description, children, on
59
75
  standaloneButtonLabelledBy = bodyId;
60
76
  }
61
77
  }
62
- const standaloneButton = !header ? (React.createElement(WithNativeAttributes, { ...buttonProps, tag: "button", componentName: "ActionCard", nativeAttributes: nativeButtonAttributes, ref: buttonRef, id: standaloneButtonId, className: clsx(styles['overlay-button'], testStyles.button, disabled && styles.disabled, variant && styles[`variant-${variant}`]), "aria-label": ariaLabel || undefined, "aria-labelledby": standaloneButtonLabelledBy })) : null;
78
+ const standaloneOverlayProps = {
79
+ ...interactiveProps,
80
+ id: standaloneButtonId,
81
+ className: clsx(styles['overlay-button'], testStyles.button, disabled && styles.disabled, variant && styles[`variant-${variant}`]),
82
+ 'aria-label': ariaLabel || undefined,
83
+ 'aria-labelledby': standaloneButtonLabelledBy,
84
+ };
85
+ const standaloneButton = !header ? renderInteractiveElement(standaloneOverlayProps) : null;
63
86
  const contentElement = (React.createElement("div", { className: styles['inner-card'] },
64
87
  iconInHeaderRow ? (React.createElement("div", { className: styles['header-row'] },
65
88
  headerSection,
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/action-card/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEpG,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,sBAAsB,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAE9D,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAG5E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,UAAU,MAAM,8BAA8B,CAAC;AAItD,MAAM,kBAAkB,GAAG,KAAK,CAAC,UAAU,CACzC,CACE,EACE,MAAM,EACN,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,eAAe,EACf,QAAQ,EACR,qBAAqB,EACrB,sBAAsB,EACtB,IAAI,EACJ,qBAAqB,EACrB,OAAO,EACP,sBAAsB,EACtB,iBAAiB,EACjB,GAAG,IAAI,EACiB,EAC1B,GAAmC,EACnC,EAAE;IACF,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,MAAM,CAAiB,IAAI,CAA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,MAAM,CAAC,WAAW,OAAO,EAAE,CAAC,EAC5B,QAAQ,IAAI,MAAM,CAAC,QAAQ,EAC3B,QAAQ,IAAI,UAAU,CAAC,QAAQ,EAC/B,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,EAC5B,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,gBAAgB,CAAC,EAClC,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,uBAAuB,qBAAqB,EAAE,CAAC,EAChE,SAAS,CAAC,SAAS,CACpB,mBACc,QAAQ,IAAI,SAAS;QAEnC,gBAAgB;QAChB,cAAc;QACd,CAAC,eAAe,IAAI,WAAW,CAC5B,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getBaseProps } from '../internal/base-component';\nimport InternalStructuredItem from '../internal/components/structured-item';\nimport { fireCancelableEvent } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport WithNativeAttributes from '../internal/utils/with-native-attributes';\nimport { ActionCardProps } from './interfaces';\n\nimport styles from './styles.css.js';\nimport testStyles from './test-classes/styles.css.js';\n\nexport type InternalActionCardProps = ActionCardProps & InternalBaseComponentProps;\n\nconst InternalActionCard = React.forwardRef(\n (\n {\n header,\n description,\n children,\n onClick,\n ariaLabel,\n ariaDescribedby,\n disabled,\n disableHeaderPaddings,\n disableContentPaddings,\n icon,\n iconVerticalAlignment,\n variant,\n nativeButtonAttributes,\n __internalRootRef,\n ...rest\n }: InternalActionCardProps,\n ref: React.Ref<ActionCardProps.Ref>\n ) => {\n const baseProps = getBaseProps(rest);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const rootRef = useRef<HTMLDivElement>(null);\n const headerId = useUniqueId('action-card-header-');\n const standaloneButtonId = useUniqueId('action-card-button-');\n const descriptionId = useUniqueId('action-card-description-');\n const bodyId = useUniqueId('action-card-body-');\n\n useForwardFocus(ref, buttonRef);\n\n if (!header && !ariaLabel) {\n warnOnce(\n 'ActionCard',\n 'An accessible name is required. Provide either a `header` or an `ariaLabel` prop so the action card has a meaningful label for screen reader users.'\n );\n }\n\n const handleButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n return event.preventDefault();\n }\n fireCancelableEvent(onClick, {}, event);\n };\n\n const headerRowEmpty = !header && !description;\n\n const iconWrapper = icon && (\n <div className={clsx(styles.icon, testStyles.icon)} aria-hidden=\"true\">\n {icon}\n </div>\n );\n const iconInHeaderRow = icon && iconVerticalAlignment === 'top' && !!header;\n\n const mergedRootRef = useMergeRefs(rootRef, __internalRootRef);\n\n // Link the description element as the button's accessible description\n // when the button already has a name (via header text or ariaLabel).\n if (!ariaDescribedby && description && (ariaLabel || header)) {\n ariaDescribedby = descriptionId;\n }\n\n const buttonProps = {\n type: 'button' as const,\n className: clsx(\n styles['header-button'],\n testStyles.button,\n disabled && styles.disabled,\n variant && styles[`variant-${variant}`]\n ),\n onClick: handleButtonClick,\n 'aria-describedby': ariaDescribedby,\n 'aria-disabled': disabled || undefined,\n };\n\n const headerSection = !headerRowEmpty ? (\n <div className={clsx(styles.header, disableHeaderPaddings && styles['no-padding'])}>\n <InternalStructuredItem\n content={\n header && (\n <div className={clsx(styles['header-inner'], testStyles.header, disabled && styles.disabled)}>\n <WithNativeAttributes<HTMLButtonElement, React.ButtonHTMLAttributes<HTMLButtonElement>>\n {...buttonProps}\n tag=\"button\"\n componentName=\"ActionCard\"\n nativeAttributes={nativeButtonAttributes}\n ref={buttonRef}\n id={headerId}\n >\n {header}\n </WithNativeAttributes>\n </div>\n )\n }\n secondaryContent={\n description && (\n <div\n id={descriptionId}\n className={clsx(\n styles.description,\n testStyles.description,\n disabled && styles.disabled,\n header && styles['has-header']\n )}\n >\n {description}\n </div>\n )\n }\n disablePaddings={disableHeaderPaddings}\n />\n </div>\n ) : null;\n\n // When there's no header, a standalone overlay button is rendered.\n // If ariaLabel is provided, it's used directly. Otherwise, derive the button's\n // accessible name from the first available content: description or children.\n let standaloneButtonLabelledBy: string | undefined;\n if (!ariaLabel) {\n if (description) {\n standaloneButtonLabelledBy = descriptionId;\n } else if (children) {\n standaloneButtonLabelledBy = bodyId;\n }\n }\n\n const standaloneButton = !header ? (\n <WithNativeAttributes<HTMLButtonElement, React.ButtonHTMLAttributes<HTMLButtonElement>>\n {...buttonProps}\n tag=\"button\"\n componentName=\"ActionCard\"\n nativeAttributes={nativeButtonAttributes}\n ref={buttonRef}\n id={standaloneButtonId}\n className={clsx(\n styles['overlay-button'],\n testStyles.button,\n disabled && styles.disabled,\n variant && styles[`variant-${variant}`]\n )}\n aria-label={ariaLabel || undefined}\n aria-labelledby={standaloneButtonLabelledBy}\n />\n ) : null;\n\n const contentElement = (\n <div className={styles['inner-card']}>\n {iconInHeaderRow ? (\n <div className={styles['header-row']}>\n {headerSection}\n {iconWrapper}\n </div>\n ) : (\n headerSection\n )}\n {children && (\n <div\n className={clsx(styles.body, testStyles.body, disableContentPaddings && styles['no-padding'])}\n id={bodyId}\n >\n {children}\n </div>\n )}\n </div>\n );\n\n return (\n <div\n {...baseProps}\n ref={mergedRootRef}\n role=\"group\"\n aria-labelledby={header ? headerId : standaloneButtonId}\n className={clsx(\n styles.root,\n styles[`variant-${variant}`],\n disabled && styles.disabled,\n disabled && testStyles.disabled,\n !!icon && styles['has-icon'],\n !!icon && styles['icon-align-end'],\n !!icon && styles[`icon-vertical-align-${iconVerticalAlignment}`],\n baseProps.className\n )}\n aria-disabled={disabled || undefined}\n >\n {standaloneButton}\n {contentElement}\n {!iconInHeaderRow && iconWrapper}\n </div>\n );\n }\n);\n\nexport default InternalActionCard;\n"]}
1
+ {"version":3,"file":"intern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CAAC,uBAAuB,qBAAqB,EAAE,CAAC,EAChE,SAAS,CAAC,SAAS,CACpB,mBACc,QAAQ,IAAI,SAAS;QAEnC,gBAAgB;QAChB,cAAc;QACd,CAAC,eAAe,IAAI,WAAW,CAC5B,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getBaseProps } from '../internal/base-component';\nimport InternalStructuredItem from '../internal/components/structured-item';\nimport { fireCancelableEvent, isPlainLeftClick } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport WithNativeAttributes from '../internal/utils/with-native-attributes';\nimport { ActionCardProps } from './interfaces';\n\nimport styles from './styles.css.js';\nimport testStyles from './test-classes/styles.css.js';\n\nexport type InternalActionCardProps = ActionCardProps & InternalBaseComponentProps;\n\nconst InternalActionCard = React.forwardRef(\n (\n {\n header,\n description,\n children,\n onClick,\n onFollow,\n href,\n target,\n rel,\n download,\n ariaLabel,\n ariaDescribedby,\n disabled,\n disableHeaderPaddings,\n disableContentPaddings,\n icon,\n iconVerticalAlignment,\n variant,\n nativeButtonAttributes,\n nativeAnchorAttributes,\n __internalRootRef,\n ...rest\n }: InternalActionCardProps,\n ref: React.Ref<ActionCardProps.Ref>\n ) => {\n const baseProps = getBaseProps(rest);\n const containerRef = useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n const rootRef = useRef<HTMLDivElement>(null);\n const headerId = useUniqueId('action-card-header-');\n const standaloneButtonId = useUniqueId('action-card-button-');\n const descriptionId = useUniqueId('action-card-description-');\n const bodyId = useUniqueId('action-card-body-');\n\n useForwardFocus(ref, containerRef);\n\n checkSafeUrl('ActionCard', href);\n const isAnchor = Boolean(href);\n\n if (!header && !ariaLabel) {\n warnOnce(\n 'ActionCard',\n 'An accessible name is required. Provide either a `header` or an `ariaLabel` prop so the action card has a meaningful label for screen reader users.'\n );\n }\n\n const handleButtonClick = (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n if (disabled) {\n return event.preventDefault();\n }\n if (isAnchor && isPlainLeftClick(event)) {\n fireCancelableEvent(onFollow, { href, target }, event);\n }\n fireCancelableEvent(onClick, {}, event);\n };\n\n const headerRowEmpty = !header && !description;\n\n const iconWrapper = icon && (\n <div className={clsx(styles.icon, testStyles.icon)} aria-hidden=\"true\">\n {icon}\n </div>\n );\n const iconInHeaderRow = icon && iconVerticalAlignment === 'top' && !!header;\n\n const mergedRootRef = useMergeRefs(rootRef, __internalRootRef);\n\n // Link the description element as the button's accessible description\n // when the button already has a name (via header text or ariaLabel).\n if (!ariaDescribedby && description && (ariaLabel || header)) {\n ariaDescribedby = descriptionId;\n }\n\n // Shared props between <a>-tag and <button>-tag\n const interactiveProps = {\n className: clsx(\n styles['header-button'],\n testStyles.button,\n disabled && styles.disabled,\n variant && styles[`variant-${variant}`]\n ),\n onClick: handleButtonClick,\n 'aria-describedby': ariaDescribedby,\n 'aria-disabled': disabled || undefined,\n };\n\n // <a>-tag specific props\n const anchorProps = {\n href: disabled ? undefined : href,\n role: disabled ? 'link' : undefined,\n tabIndex: disabled ? 0 : undefined,\n target,\n // security recommendation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target\n rel: rel ?? (target === '_blank' ? 'noopener noreferrer' : undefined),\n download,\n };\n\n const renderInteractiveElement = (props: Record<string, unknown>, children?: React.ReactNode) =>\n isAnchor ? (\n <WithNativeAttributes<HTMLAnchorElement, React.AnchorHTMLAttributes<HTMLAnchorElement>>\n {...props}\n {...anchorProps}\n tag=\"a\"\n componentName=\"ActionCard\"\n nativeAttributes={nativeAnchorAttributes}\n ref={containerRef as React.Ref<HTMLAnchorElement>}\n >\n {children}\n </WithNativeAttributes>\n ) : (\n <WithNativeAttributes<HTMLButtonElement, React.ButtonHTMLAttributes<HTMLButtonElement>>\n {...props}\n type=\"button\"\n tag=\"button\"\n componentName=\"ActionCard\"\n nativeAttributes={nativeButtonAttributes}\n ref={containerRef as React.Ref<HTMLButtonElement>}\n >\n {children}\n </WithNativeAttributes>\n );\n\n const headerSection = !headerRowEmpty ? (\n <div className={clsx(styles.header, disableHeaderPaddings && styles['no-padding'])}>\n <InternalStructuredItem\n content={\n header && (\n <div className={clsx(styles['header-inner'], testStyles.header, disabled && styles.disabled)}>\n {renderInteractiveElement({ ...interactiveProps, id: headerId }, header)}\n </div>\n )\n }\n secondaryContent={\n description && (\n <div\n id={descriptionId}\n className={clsx(\n styles.description,\n testStyles.description,\n disabled && styles.disabled,\n header && styles['has-header']\n )}\n >\n {description}\n </div>\n )\n }\n disablePaddings={disableHeaderPaddings}\n />\n </div>\n ) : null;\n\n // When there's no header, a standalone overlay button is rendered.\n // If ariaLabel is provided, it's used directly. Otherwise, derive the button's\n // accessible name from the first available content: description or children.\n let standaloneButtonLabelledBy: string | undefined;\n if (!ariaLabel) {\n if (description) {\n standaloneButtonLabelledBy = descriptionId;\n } else if (children) {\n standaloneButtonLabelledBy = bodyId;\n }\n }\n\n const standaloneOverlayProps = {\n ...interactiveProps,\n id: standaloneButtonId,\n className: clsx(\n styles['overlay-button'],\n testStyles.button,\n disabled && styles.disabled,\n variant && styles[`variant-${variant}`]\n ),\n 'aria-label': ariaLabel || undefined,\n 'aria-labelledby': standaloneButtonLabelledBy,\n };\n\n const standaloneButton = !header ? renderInteractiveElement(standaloneOverlayProps) : null;\n\n const contentElement = (\n <div className={styles['inner-card']}>\n {iconInHeaderRow ? (\n <div className={styles['header-row']}>\n {headerSection}\n {iconWrapper}\n </div>\n ) : (\n headerSection\n )}\n {children && (\n <div\n className={clsx(styles.body, testStyles.body, disableContentPaddings && styles['no-padding'])}\n id={bodyId}\n >\n {children}\n </div>\n )}\n </div>\n );\n\n return (\n <div\n {...baseProps}\n ref={mergedRootRef}\n role=\"group\"\n aria-labelledby={header ? headerId : standaloneButtonId}\n className={clsx(\n styles.root,\n styles[`variant-${variant}`],\n disabled && styles.disabled,\n disabled && testStyles.disabled,\n !!icon && styles['has-icon'],\n !!icon && styles['icon-align-end'],\n !!icon && styles[`icon-vertical-align-${iconVerticalAlignment}`],\n baseProps.className\n )}\n aria-disabled={disabled || undefined}\n >\n {standaloneButton}\n {contentElement}\n {!iconInHeaderRow && iconWrapper}\n </div>\n );\n }\n);\n\nexport default InternalActionCard;\n"]}
@@ -1,22 +1,22 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "root": "awsui_root_16248_1xlcm_161",
5
- "icon": "awsui_icon_16248_1xlcm_193",
6
- "header-inner": "awsui_header-inner_16248_1xlcm_209",
7
- "disabled": "awsui_disabled_16248_1xlcm_218",
8
- "header": "awsui_header_16248_1xlcm_209",
9
- "body": "awsui_body_16248_1xlcm_224",
10
- "header-row": "awsui_header-row_16248_1xlcm_228",
11
- "description": "awsui_description_16248_1xlcm_241",
12
- "has-header": "awsui_has-header_16248_1xlcm_247",
13
- "header-button": "awsui_header-button_16248_1xlcm_261",
14
- "overlay-button": "awsui_overlay-button_16248_1xlcm_262",
15
- "variant-embedded": "awsui_variant-embedded_16248_1xlcm_281",
16
- "variant-default": "awsui_variant-default_16248_1xlcm_293",
17
- "inner-card": "awsui_inner-card_16248_1xlcm_394",
18
- "no-padding": "awsui_no-padding_16248_1xlcm_401",
19
- "icon-vertical-align-center": "awsui_icon-vertical-align-center_16248_1xlcm_412",
20
- "icon-align-end": "awsui_icon-align-end_16248_1xlcm_546"
4
+ "root": "awsui_root_16248_11dsh_161",
5
+ "icon": "awsui_icon_16248_11dsh_193",
6
+ "header-inner": "awsui_header-inner_16248_11dsh_209",
7
+ "disabled": "awsui_disabled_16248_11dsh_218",
8
+ "header": "awsui_header_16248_11dsh_209",
9
+ "body": "awsui_body_16248_11dsh_224",
10
+ "header-row": "awsui_header-row_16248_11dsh_228",
11
+ "description": "awsui_description_16248_11dsh_241",
12
+ "has-header": "awsui_has-header_16248_11dsh_247",
13
+ "header-button": "awsui_header-button_16248_11dsh_261",
14
+ "overlay-button": "awsui_overlay-button_16248_11dsh_262",
15
+ "variant-embedded": "awsui_variant-embedded_16248_11dsh_281",
16
+ "variant-default": "awsui_variant-default_16248_11dsh_293",
17
+ "inner-card": "awsui_inner-card_16248_11dsh_394",
18
+ "no-padding": "awsui_no-padding_16248_11dsh_401",
19
+ "icon-vertical-align-center": "awsui_icon-vertical-align-center_16248_11dsh_412",
20
+ "icon-align-end": "awsui_icon-align-end_16248_11dsh_548"
21
21
  };
22
22