@cloudscape-design/components-themeable 3.0.1394 → 3.0.1396
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/button/styles.scss +9 -0
- package/lib/internal/scss/code-editor/ace-editor.scss +2 -2
- package/lib/internal/scss/container/styles.scss +1 -1
- package/lib/internal/scss/copy-to-clipboard/motion.scss +31 -0
- package/lib/internal/scss/copy-to-clipboard/styles.scss +41 -0
- package/lib/internal/scss/icon/hover-motion.scss +17 -12
- package/lib/internal/scss/internal/components/button-trigger/styles.scss +9 -0
- package/lib/internal/scss/internal/components/control-group/styles.scss +29 -0
- package/lib/internal/scss/internal/components/control-group/test-classes/styles.scss +4 -0
- package/lib/internal/scss/internal/components/expand-toggle-button/styles.scss +1 -1
- package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
- package/lib/internal/scss/internal/styles/forms/mixins.scss +2 -2
- package/lib/internal/scss/internal/styles/utils/mixins.scss +6 -0
- package/lib/internal/scss/table/cell-base/_cell-box.scss +4 -3
- package/lib/internal/scss/table/styles.scss +3 -0
- package/lib/internal/scss/toggle/motion.scss +46 -20
- package/lib/internal/scss/toggle/styles.scss +4 -3
- package/lib/internal/template/action-card/internal.d.ts.map +1 -1
- package/lib/internal/template/action-card/internal.js +1 -4
- package/lib/internal/template/action-card/internal.js.map +1 -1
- package/lib/internal/template/button/styles.css.js +24 -24
- package/lib/internal/template/button/styles.scoped.css +99 -78
- package/lib/internal/template/button/styles.selectors.js +24 -24
- package/lib/internal/template/code-editor/styles.css.js +33 -33
- package/lib/internal/template/code-editor/styles.scoped.css +188 -188
- package/lib/internal/template/code-editor/styles.selectors.js +33 -33
- package/lib/internal/template/container/styles.css.js +34 -34
- package/lib/internal/template/container/styles.scoped.css +59 -59
- package/lib/internal/template/container/styles.selectors.js +34 -34
- package/lib/internal/template/copy-to-clipboard/internal.d.ts.map +1 -1
- package/lib/internal/template/copy-to-clipboard/internal.js +50 -16
- package/lib/internal/template/copy-to-clipboard/internal.js.map +1 -1
- package/lib/internal/template/copy-to-clipboard/styles.css.js +10 -5
- package/lib/internal/template/copy-to-clipboard/styles.scoped.css +38 -6
- package/lib/internal/template/copy-to-clipboard/styles.selectors.js +10 -5
- package/lib/internal/template/input/styles.css.js +37 -37
- package/lib/internal/template/input/styles.scoped.css +67 -67
- package/lib/internal/template/input/styles.selectors.js +37 -37
- package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
- package/lib/internal/template/internal/base-theme/styles.scoped.css +10 -0
- package/lib/internal/template/internal/components/autosuggest-input/styles.css.js +27 -27
- package/lib/internal/template/internal/components/autosuggest-input/styles.scoped.css +35 -35
- package/lib/internal/template/internal/components/autosuggest-input/styles.selectors.js +27 -27
- package/lib/internal/template/internal/components/button-trigger/styles.css.js +23 -23
- package/lib/internal/template/internal/components/button-trigger/styles.scoped.css +50 -44
- package/lib/internal/template/internal/components/button-trigger/styles.selectors.js +23 -23
- package/lib/internal/template/internal/components/control-group/index.d.ts.map +1 -1
- package/lib/internal/template/internal/components/control-group/index.js +41 -14
- package/lib/internal/template/internal/components/control-group/index.js.map +1 -1
- package/lib/internal/template/internal/components/control-group/interfaces.d.ts +8 -1
- package/lib/internal/template/internal/components/control-group/interfaces.d.ts.map +1 -1
- package/lib/internal/template/internal/components/control-group/interfaces.js.map +1 -1
- package/lib/internal/template/internal/components/control-group/styles.css.js +20 -16
- package/lib/internal/template/internal/components/control-group/styles.scoped.css +52 -16
- package/lib/internal/template/internal/components/control-group/styles.selectors.js +20 -16
- package/lib/internal/template/internal/components/control-group/test-classes/styles.css.js +4 -3
- package/lib/internal/template/internal/components/control-group/test-classes/styles.scoped.css +7 -3
- package/lib/internal/template/internal/components/control-group/test-classes/styles.selectors.js +4 -3
- package/lib/internal/template/internal/components/expand-toggle-button/styles.css.js +4 -4
- package/lib/internal/template/internal/components/expand-toggle-button/styles.scoped.css +18 -18
- package/lib/internal/template/internal/components/expand-toggle-button/styles.selectors.js +4 -4
- package/lib/internal/template/internal/environment.js +2 -2
- package/lib/internal/template/internal/environment.json +2 -2
- package/lib/internal/template/internal/generated/styles/tokens.d.ts +4 -0
- package/lib/internal/template/internal/generated/styles/tokens.js +4 -0
- package/lib/internal/template/internal/generated/theming/index.cjs +44 -0
- package/lib/internal/template/internal/generated/theming/index.js +44 -0
- package/lib/internal/template/internal/hooks/use-fits-inline.d.ts +16 -0
- package/lib/internal/template/internal/hooks/use-fits-inline.d.ts.map +1 -0
- package/lib/internal/template/internal/hooks/use-fits-inline.js +31 -0
- package/lib/internal/template/internal/hooks/use-fits-inline.js.map +1 -0
- package/lib/internal/template/prompt-input/styles.css.js +26 -26
- package/lib/internal/template/prompt-input/styles.scoped.css +55 -55
- package/lib/internal/template/prompt-input/styles.selectors.js +26 -26
- package/lib/internal/template/property-filter/filtering-token/index.js +3 -2
- package/lib/internal/template/property-filter/filtering-token/index.js.map +1 -1
- package/lib/internal/template/table/body-cell/styles.css.js +47 -47
- package/lib/internal/template/table/body-cell/styles.scoped.css +568 -568
- package/lib/internal/template/table/body-cell/styles.selectors.js +47 -47
- package/lib/internal/template/table/header-cell/styles.css.js +39 -39
- package/lib/internal/template/table/header-cell/styles.scoped.css +82 -82
- package/lib/internal/template/table/header-cell/styles.selectors.js +39 -39
- package/lib/internal/template/table/styles.css.js +37 -37
- package/lib/internal/template/table/styles.scoped.css +46 -45
- package/lib/internal/template/table/styles.selectors.js +37 -37
- package/lib/internal/template/test-utils/dom/internal/control-group.d.ts +4 -0
- package/lib/internal/template/test-utils/dom/internal/control-group.js +6 -0
- package/lib/internal/template/test-utils/dom/internal/control-group.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/internal/control-group.d.ts +4 -0
- package/lib/internal/template/test-utils/selectors/internal/control-group.js +6 -0
- package/lib/internal/template/test-utils/selectors/internal/control-group.js.map +1 -1
- package/lib/internal/template/textarea/styles.css.js +9 -9
- package/lib/internal/template/textarea/styles.scoped.css +19 -19
- package/lib/internal/template/textarea/styles.selectors.js +9 -9
- package/lib/internal/template/toggle/styles.css.js +10 -10
- package/lib/internal/template/toggle/styles.scoped.css +30 -17
- package/lib/internal/template/toggle/styles.selectors.js +10 -10
- package/lib/internal/template/token/index.d.ts +1 -1
- package/lib/internal/template/token/index.d.ts.map +1 -1
- package/lib/internal/template/token/index.js +6 -3
- package/lib/internal/template/token/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -156,6 +156,15 @@ $tokens: style-api.resolve($props, carrier);
|
|
|
156
156
|
);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
&.variant-inline-link {
|
|
160
|
+
@include style-api.focus-highlight(
|
|
161
|
+
$gutter-block: awsui.$space-button-inline-link-focus-outline-gutter,
|
|
162
|
+
$radius: $radius,
|
|
163
|
+
$width: $width,
|
|
164
|
+
$color: $color
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
159
168
|
&.variant-control-group-action {
|
|
160
169
|
@include styles.form-focus-element(
|
|
161
170
|
$border-color: $color,
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
.code-editor :global .ace_editor {
|
|
21
21
|
font-family: awsui.$font-family-monospace;
|
|
22
|
-
font-size:
|
|
23
|
-
line-height:
|
|
22
|
+
font-size: awsui.$font-size-body-m;
|
|
23
|
+
line-height: awsui.$line-height-body-m;
|
|
24
24
|
|
|
25
25
|
$gutter-padding-left: 24px;
|
|
26
26
|
$gutter-padding-right: 16px;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
@use '../internal/styles/tokens' as awsui;
|
|
5
|
+
@use '../internal/styles/utils/theming' as theming;
|
|
6
|
+
|
|
7
|
+
@mixin copy-to-clipboard-expressive-with-motion {
|
|
8
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
9
|
+
@include theming.expressive-motion-only(':not(.awsui-motion-disabled):not(.awsui-mode-entering)') {
|
|
10
|
+
@content;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@mixin exiting-with-motion {
|
|
16
|
+
@include copy-to-clipboard-expressive-with-motion {
|
|
17
|
+
transition-property: opacity, transform;
|
|
18
|
+
transition-duration: awsui.$motion-duration-refresh-only-fast;
|
|
19
|
+
transition-timing-function: awsui.$motion-easing-refresh-only-b;
|
|
20
|
+
transition-delay: 0s;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@mixin entering-with-motion {
|
|
25
|
+
@include copy-to-clipboard-expressive-with-motion {
|
|
26
|
+
transition-property: opacity, transform;
|
|
27
|
+
transition-duration: awsui.$motion-duration-refresh-only-medium;
|
|
28
|
+
transition-timing-function: awsui.$motion-easing-refresh-only-a;
|
|
29
|
+
transition-delay: awsui.$motion-duration-refresh-only-fast;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -4,11 +4,52 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
@use '../internal/styles/tokens' as awsui;
|
|
7
|
+
@use './motion';
|
|
7
8
|
|
|
8
9
|
.root {
|
|
9
10
|
display: contents;
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
.icon-swap {
|
|
14
|
+
position: absolute;
|
|
15
|
+
inset: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.icon-swap-copy,
|
|
19
|
+
.icon-swap-result {
|
|
20
|
+
position: absolute;
|
|
21
|
+
inset-block-start: 0;
|
|
22
|
+
inset-inline-start: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.icon-swap-copy {
|
|
26
|
+
opacity: 1;
|
|
27
|
+
transform: scale(1);
|
|
28
|
+
@include motion.entering-with-motion;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.icon-swap-result {
|
|
32
|
+
opacity: 0;
|
|
33
|
+
transform: scale(0);
|
|
34
|
+
@include motion.exiting-with-motion;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.icon-swap-copied > .icon-swap-copy {
|
|
38
|
+
opacity: 0;
|
|
39
|
+
transform: scale(0);
|
|
40
|
+
@include motion.exiting-with-motion;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.icon-swap-copied > .icon-swap-result {
|
|
44
|
+
opacity: 1;
|
|
45
|
+
transform: scale(1);
|
|
46
|
+
@include motion.entering-with-motion;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.popover-message {
|
|
50
|
+
display: inline;
|
|
51
|
+
}
|
|
52
|
+
|
|
12
53
|
.inline-container {
|
|
13
54
|
word-break: break-all;
|
|
14
55
|
|
|
@@ -31,6 +31,14 @@ $_opted-in: 'svg[#{$_animated-attribute}]';
|
|
|
31
31
|
// Opt-in attribute for which element triggers hover motion.
|
|
32
32
|
$_trigger-attribute: 'data-awsui-motion-trigger';
|
|
33
33
|
$_hover-trigger: '[#{$_trigger-attribute}~="hover"]#{$_enabled-only}';
|
|
34
|
+
// A focus owner that plays the motion of icons inside it.
|
|
35
|
+
$_focus-trigger: '[#{$_trigger-attribute}~="focus"]#{$_enabled-only}';
|
|
36
|
+
// A trigger whose focus owner is nested and does not contain the icon (e.g. action card).
|
|
37
|
+
// Matches `:focus-within` during keyboard interaction (the `useFocusVisible` body attribute that
|
|
38
|
+
// focus rings use) instead of `:has(:focus-visible)`: a non-subject `:has()` is costly on every
|
|
39
|
+
// style recalc and DOM insert. `:where(body... *)` keeps it independent of where the theme class is.
|
|
40
|
+
$_delegated-focus-trigger: '[#{$_trigger-attribute}~="delegated-focus"]#{$_enabled-only}';
|
|
41
|
+
$_keyboard-focus-within: ':focus-within:where(body[data-awsui-focus-visible="true"] *)';
|
|
34
42
|
|
|
35
43
|
// Opt-in attribute for where the motion should be applied within a trigger region.
|
|
36
44
|
$_target-attribute: 'data-awsui-motion-target';
|
|
@@ -1569,10 +1577,13 @@ $icon-hover-motion: (
|
|
|
1569
1577
|
}
|
|
1570
1578
|
}
|
|
1571
1579
|
|
|
1572
|
-
// Also fires on :focus-visible,
|
|
1580
|
+
// Also fires on :focus-visible of the trigger, of a focus owner around the icon, or of a
|
|
1581
|
+
// focus owner nested inside a delegated-focus trigger.
|
|
1573
1582
|
@mixin _on-hover-trigger($suffix) {
|
|
1574
1583
|
#{'#{$_hover-trigger}:hover #{$suffix}'},
|
|
1575
|
-
#{'#{$_hover-trigger}:
|
|
1584
|
+
#{'#{$_hover-trigger}:focus-visible #{$suffix}'},
|
|
1585
|
+
#{'#{$_focus-trigger}:focus-visible #{$suffix}'},
|
|
1586
|
+
#{'#{$_delegated-focus-trigger}#{$_keyboard-focus-within} #{$suffix}'} {
|
|
1576
1587
|
@content;
|
|
1577
1588
|
}
|
|
1578
1589
|
}
|
|
@@ -1609,9 +1620,10 @@ $icon-hover-motion: (
|
|
|
1609
1620
|
}
|
|
1610
1621
|
|
|
1611
1622
|
// Icons with BOTH a whole-icon spec and a part spec are excluded — the cancel would out-specify the whole-icon rule and reset it to none.
|
|
1623
|
+
// No `:has()` check for the parts is needed: an opted-in svg that is a direct child of `.icon.name-*`
|
|
1624
|
+
// is always the generated icon of that name (overrides are wrapped in a `.custom-icon` span).
|
|
1612
1625
|
@mixin _cancel-floor-under-hover-parts {
|
|
1613
1626
|
$names: ();
|
|
1614
|
-
$parts: ();
|
|
1615
1627
|
|
|
1616
1628
|
@each $name, $specs in $icon-hover-motion {
|
|
1617
1629
|
$whole-icon: false;
|
|
@@ -1623,17 +1635,11 @@ $icon-hover-motion: (
|
|
|
1623
1635
|
|
|
1624
1636
|
@if not $whole-icon {
|
|
1625
1637
|
$names: list.append($names, '.name-#{$name}', comma);
|
|
1626
|
-
@each $spec in _specs($specs) {
|
|
1627
|
-
$part: '.#{map.get($spec, part)}';
|
|
1628
|
-
@if not list.index($parts, $part) {
|
|
1629
|
-
$parts: list.append($parts, $part, comma);
|
|
1630
|
-
}
|
|
1631
|
-
}
|
|
1632
1638
|
}
|
|
1633
1639
|
}
|
|
1634
1640
|
|
|
1635
1641
|
@if list.length($names) > 0 {
|
|
1636
|
-
@include _on-hover-trigger('.icon#{$_animating-icon}:is(#{$names}) > :global(#{$_opted-in}
|
|
1642
|
+
@include _on-hover-trigger('.icon#{$_animating-icon}:is(#{$names}) > :global(#{$_opted-in})') {
|
|
1637
1643
|
@include with-motion {
|
|
1638
1644
|
transform: none;
|
|
1639
1645
|
}
|
|
@@ -2202,8 +2208,7 @@ $_spec-keys: (part, animation, to, base, origin, duration, easing, delay, iterat
|
|
|
2202
2208
|
// Safari mishandles negative dash offsets. This check validates no negative offsets exist.
|
|
2203
2209
|
// Instead of negative offsets, shift the offset up by one period to keep it positive.
|
|
2204
2210
|
@each $state in (base, to) {
|
|
2205
|
-
$
|
|
2206
|
-
$offset: map.get($values, stroke-dashoffset);
|
|
2211
|
+
$offset: map.get($spec, $state, stroke-dashoffset);
|
|
2207
2212
|
@if meta.type-of($offset) == 'number' and $offset < 0 {
|
|
2208
2213
|
@error 'The $icon-hover-motion spec for `#{$name}` sets a negative `stroke-dashoffset`, ' +
|
|
2209
2214
|
'which Safari mishandles. Add one full dash period (the sum of the `stroke-dasharray` ' +
|
|
@@ -146,6 +146,15 @@ $icon-offset: awsui.$space-xxxs;
|
|
|
146
146
|
&.warning:focus {
|
|
147
147
|
@include styles.form-warning-control();
|
|
148
148
|
}
|
|
149
|
+
|
|
150
|
+
@include focus-visible.when-visible {
|
|
151
|
+
&.invalid {
|
|
152
|
+
border-color: awsui.$color-text-status-error;
|
|
153
|
+
}
|
|
154
|
+
&.warning {
|
|
155
|
+
border-color: awsui.$color-text-status-warning;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
149
158
|
}
|
|
150
159
|
|
|
151
160
|
&.custom-option {
|
|
@@ -13,9 +13,17 @@ $margin-overlap: calc(-1 * #{awsui.$border-width-field});
|
|
|
13
13
|
@include styles.styles-reset;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
// Spans the whole row (controls + action) and hosts the measurement scaffolding (sensor + ghost).
|
|
17
|
+
// It must have `position: static` so the sensor resolves against the nearest positioned ancestor
|
|
18
|
+
// outside the component instead of this wrapper.
|
|
19
|
+
.group-layout-wrapper {
|
|
20
|
+
position: static;
|
|
21
|
+
}
|
|
22
|
+
|
|
16
23
|
.action-slot {
|
|
17
24
|
display: flex;
|
|
18
25
|
margin-inline-start: $margin-overlap;
|
|
26
|
+
flex-shrink: 0;
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
.group-layout {
|
|
@@ -42,10 +50,13 @@ $margin-overlap: calc(-1 * #{awsui.$border-width-field});
|
|
|
42
50
|
&-horizontal {
|
|
43
51
|
flex-direction: row;
|
|
44
52
|
flex-wrap: nowrap;
|
|
53
|
+
min-inline-size: 0;
|
|
54
|
+
flex-shrink: 1;
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
&-vertical {
|
|
48
58
|
flex-direction: column;
|
|
59
|
+
flex-grow: 1;
|
|
49
60
|
}
|
|
50
61
|
}
|
|
51
62
|
|
|
@@ -77,6 +88,17 @@ $margin-overlap: calc(-1 * #{awsui.$border-width-field});
|
|
|
77
88
|
}
|
|
78
89
|
}
|
|
79
90
|
|
|
91
|
+
// Width sensor
|
|
92
|
+
.sensor {
|
|
93
|
+
@include styles.measurement-ghost;
|
|
94
|
+
inset-inline-end: 0;
|
|
95
|
+
min-inline-size: 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.ghost-anchor {
|
|
99
|
+
@include styles.measurement-ghost-anchor;
|
|
100
|
+
}
|
|
101
|
+
|
|
80
102
|
.inline-label {
|
|
81
103
|
@include forms.inline-label;
|
|
82
104
|
// A grouped Multiselect always renders inline tokens, whose row sits higher
|
|
@@ -98,3 +120,10 @@ $margin-overlap: calc(-1 * #{awsui.$border-width-field});
|
|
|
98
120
|
.inline-label-trigger-wrapper {
|
|
99
121
|
@include forms.inline-label-trigger-wrapper;
|
|
100
122
|
}
|
|
123
|
+
|
|
124
|
+
// Hidden single-row copy of the layout, laid out at its natural width so its
|
|
125
|
+
// `max-content` size is the true required width including the action button.
|
|
126
|
+
.ghost {
|
|
127
|
+
@include styles.measurement-ghost;
|
|
128
|
+
inline-size: max-content;
|
|
129
|
+
}
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
// so we disable this one
|
|
45
45
|
&:not(.disable-focus-highlight) {
|
|
46
46
|
@include focus-visible.when-visible {
|
|
47
|
-
@include styles.focus-highlight(awsui.$space-
|
|
47
|
+
@include styles.focus-highlight(awsui.$space-expand-toggle-focus-outline-gutter);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -124,8 +124,8 @@
|
|
|
124
124
|
// See focus-highlight above.
|
|
125
125
|
outline: 2px dotted transparent;
|
|
126
126
|
|
|
127
|
-
border-block:
|
|
128
|
-
border-inline:
|
|
127
|
+
border-block-color: $border-color;
|
|
128
|
+
border-inline-color: $border-color;
|
|
129
129
|
|
|
130
130
|
box-shadow: $box-shadow;
|
|
131
131
|
}
|
|
@@ -20,6 +20,12 @@
|
|
|
20
20
|
pointer-events: none;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
// A zero-height relative anchor for the absolutely-positioned measurement ghost.
|
|
24
|
+
@mixin measurement-ghost-anchor {
|
|
25
|
+
position: relative;
|
|
26
|
+
block-size: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
@mixin text-wrapping {
|
|
24
30
|
// When using with Flexbox, a flex item has min-width set to "auto" by default, which
|
|
25
31
|
// prevents the text wrapping. We need to override the min-width by setting it to "0"
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
@use '../../internal/styles/tokens' as awsui;
|
|
5
5
|
|
|
6
|
-
$cell-vertical-padding: awsui.$space-
|
|
7
|
-
//
|
|
6
|
+
$cell-vertical-padding: awsui.$space-table-cell-vertical;
|
|
7
|
+
// Calculate padding to prevent a shift in content after selection due to the difference
|
|
8
|
+
// between selected border widths and normal row divider widths (visual refresh).
|
|
8
9
|
$cell-vertical-padding-w-border: calc(
|
|
9
10
|
#{$cell-vertical-padding} + (#{awsui.$border-item-width} - #{awsui.$border-divider-list-width})
|
|
10
11
|
);
|
|
11
|
-
$cell-horizontal-padding: awsui.$space-scaled-
|
|
12
|
+
$cell-horizontal-padding: calc(#{awsui.$space-s} + #{awsui.$space-scaled-xs});
|
|
12
13
|
$cell-edge-horizontal-padding: calc(#{awsui.$space-l} - #{awsui.$border-item-width});
|
|
13
14
|
$border-placeholder: awsui.$border-item-width solid transparent;
|
|
14
15
|
// Divider inset from the cell's top/bottom edges. Shared with the existing Table's resizer so the two match.
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
@use '@cloudscape-design/component-toolkit/internal/focus-visible' as focus-visible;
|
|
9
9
|
@use '../container/shared' as container;
|
|
10
10
|
@use '../internal/generated/custom-css-properties/index.scss' as custom-props;
|
|
11
|
+
@use '../internal/styles/typography/constants.scss' as constants;
|
|
11
12
|
|
|
12
13
|
.root {
|
|
13
14
|
@include styles.default-text-style;
|
|
@@ -61,6 +62,8 @@
|
|
|
61
62
|
border-spacing: 0;
|
|
62
63
|
position: relative;
|
|
63
64
|
box-sizing: border-box;
|
|
65
|
+
// Needed to apply compact table context font-size
|
|
66
|
+
font-size: awsui.$font-size-body-m;
|
|
64
67
|
&-layout-fixed {
|
|
65
68
|
table-layout: fixed;
|
|
66
69
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
@use 'sass:math';
|
|
5
|
+
@use '../internal/styles' as styles;
|
|
4
6
|
@use '../internal/styles/tokens' as awsui;
|
|
5
7
|
@use '../internal/styles/utils/theming' as theming;
|
|
6
8
|
|
|
@@ -25,51 +27,75 @@ $tail-stretch: 4px;
|
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
// Include inside the handle rule. `$handle-size` is the handle's resting inline size
|
|
29
|
-
|
|
30
|
+
// Include inside the handle rule. `$handle-size` is the handle's resting inline size,
|
|
31
|
+
// `$travel` the distance it moves to the checked position.
|
|
32
|
+
//
|
|
33
|
+
// Travel (`translate`) and tail (`scale`) are transforms so they keep running while a change
|
|
34
|
+
// handler blocks the main thread; layout properties froze mid-stretch and snapped. They use
|
|
35
|
+
// separate properties because one `transform` animation would override the travel transition.
|
|
36
|
+
@mixin handle($handle-size, $travel) {
|
|
30
37
|
@include toggle-expressive-with-motion {
|
|
31
38
|
transition:
|
|
32
|
-
|
|
39
|
+
translate $travel-duration $settle-easing,
|
|
33
40
|
background-color $travel-duration $settle-easing;
|
|
34
41
|
}
|
|
35
42
|
|
|
36
|
-
|
|
43
|
+
&.toggle-handle-checked {
|
|
44
|
+
@include toggle-expressive-with-motion {
|
|
45
|
+
transform: none;
|
|
46
|
+
translate: $travel 0;
|
|
47
|
+
}
|
|
48
|
+
@include styles.with-direction('rtl') {
|
|
49
|
+
@include toggle-expressive-with-motion {
|
|
50
|
+
translate: -$travel 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// The tail only plays once the state has changed since mount. It stretches away from the leading
|
|
56
|
+
// edge: inline-end going on, inline-start going off. `transform-origin` is physical, so RTL swaps.
|
|
37
57
|
&[data-awsui-motion-ready] {
|
|
38
58
|
@include toggle-expressive-with-motion {
|
|
39
59
|
animation: awsui-toggle-tail-off $tail-duration $settle-easing;
|
|
60
|
+
transform-origin: 0 50%;
|
|
61
|
+
}
|
|
62
|
+
@include styles.with-direction('rtl') {
|
|
63
|
+
@include toggle-expressive-with-motion {
|
|
64
|
+
transform-origin: 100% 50%;
|
|
65
|
+
}
|
|
40
66
|
}
|
|
41
67
|
&.toggle-handle-checked {
|
|
42
68
|
@include toggle-expressive-with-motion {
|
|
43
69
|
animation-name: awsui-toggle-tail-on;
|
|
70
|
+
transform-origin: 100% 50%;
|
|
71
|
+
}
|
|
72
|
+
@include styles.with-direction('rtl') {
|
|
73
|
+
@include toggle-expressive-with-motion {
|
|
74
|
+
transform-origin: 0 50%;
|
|
75
|
+
}
|
|
44
76
|
}
|
|
45
77
|
}
|
|
46
78
|
}
|
|
47
79
|
|
|
80
|
+
// Identical keyframes under two names: the animation only restarts when `animation-name` changes.
|
|
48
81
|
@if theming.has-expressive-motion() {
|
|
82
|
+
$tail-scale: math.div($handle-size + $tail-stretch, $handle-size);
|
|
49
83
|
@keyframes awsui-toggle-tail-on {
|
|
50
|
-
0
|
|
51
|
-
|
|
52
|
-
|
|
84
|
+
0%,
|
|
85
|
+
100% {
|
|
86
|
+
scale: 1;
|
|
53
87
|
}
|
|
54
88
|
35% {
|
|
55
|
-
|
|
56
|
-
margin-inline-start: -$tail-stretch;
|
|
57
|
-
}
|
|
58
|
-
100% {
|
|
59
|
-
inline-size: $handle-size;
|
|
60
|
-
margin-inline-start: 0;
|
|
89
|
+
scale: $tail-scale 1;
|
|
61
90
|
}
|
|
62
91
|
}
|
|
63
|
-
// Going off, the trailing edge is the end edge, so the width alone grows.
|
|
64
92
|
@keyframes awsui-toggle-tail-off {
|
|
65
|
-
0
|
|
66
|
-
|
|
93
|
+
0%,
|
|
94
|
+
100% {
|
|
95
|
+
scale: 1;
|
|
67
96
|
}
|
|
68
97
|
35% {
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
100% {
|
|
72
|
-
inline-size: $handle-size;
|
|
98
|
+
scale: $tail-scale 1;
|
|
73
99
|
}
|
|
74
100
|
}
|
|
75
101
|
}
|
|
@@ -14,6 +14,7 @@ $toggle-width: 2.4 * styles.$base-size;
|
|
|
14
14
|
$toggle-height: 1.6 * styles.$base-size;
|
|
15
15
|
$handle-size: 1.2 * styles.$base-size;
|
|
16
16
|
$handle-offset: 0.2 * styles.$base-size;
|
|
17
|
+
$handle-travel: 0.8 * styles.$base-size;
|
|
17
18
|
$shadow-color: awsui.$color-shadow-toggle-handle;
|
|
18
19
|
|
|
19
20
|
$control-props: style-api.combine((color, background-color), style-api.$focus-ring);
|
|
@@ -90,10 +91,10 @@ $description-tokens: style-api.resolve((color), public);
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
&-checked {
|
|
93
|
-
transform: translateX(
|
|
94
|
+
transform: translateX($handle-travel);
|
|
94
95
|
|
|
95
96
|
@include styles.with-direction('rtl') {
|
|
96
|
-
transform: translateX(-
|
|
97
|
+
transform: translateX(-$handle-travel);
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
|
|
@@ -109,5 +110,5 @@ $description-tokens: style-api.resolve((color), public);
|
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
@include motion.handle($handle-size);
|
|
113
|
+
@include motion.handle($handle-size, $handle-travel);
|
|
113
114
|
}
|
|
@@ -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;AAGlF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/C,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG,0BAA0B,CAAC;AAEnF,QAAA,MAAM,kBAAkB,
|
|
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,0HAoOvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -49,9 +49,6 @@ const InternalActionCard = React.forwardRef(({ header, description, children, on
|
|
|
49
49
|
onClick: handleButtonClick,
|
|
50
50
|
'aria-describedby': ariaDescribedby,
|
|
51
51
|
'aria-disabled': disabled || undefined,
|
|
52
|
-
// The hover region is the whole card (see the root element); focusing
|
|
53
|
-
// the inner control also plays the motion.
|
|
54
|
-
'data-awsui-motion-trigger': 'focus',
|
|
55
52
|
};
|
|
56
53
|
// <a>-tag specific props
|
|
57
54
|
const anchorProps = {
|
|
@@ -91,7 +88,7 @@ const InternalActionCard = React.forwardRef(({ header, description, children, on
|
|
|
91
88
|
headerSection,
|
|
92
89
|
iconWrapper)) : (headerSection),
|
|
93
90
|
children && (React.createElement("div", { className: clsx(styles.body, testStyles.body, disableContentPaddings && styles['no-padding']), id: bodyId }, children))));
|
|
94
|
-
return (React.createElement("div", { ...baseProps, ref: mergedRootRef, role: "group", "aria-labelledby": header ? headerId : standaloneButtonId, className: clsx(styles.root, styles[`variant-${variant}`], disabled && styles.disabled, disabled && testStyles.disabled, !!icon && styles['has-icon'], !!icon && styles['icon-align-end'], !!icon && styles[`icon-vertical-align-${iconVerticalAlignment}`], baseProps.className), "aria-disabled": disabled || undefined, "data-awsui-motion-trigger": "hover" },
|
|
91
|
+
return (React.createElement("div", { ...baseProps, ref: mergedRootRef, role: "group", "aria-labelledby": header ? headerId : standaloneButtonId, className: clsx(styles.root, styles[`variant-${variant}`], disabled && styles.disabled, disabled && testStyles.disabled, !!icon && styles['has-icon'], !!icon && styles['icon-align-end'], !!icon && styles[`icon-vertical-align-${iconVerticalAlignment}`], baseProps.className), "aria-disabled": disabled || undefined, "data-awsui-motion-trigger": "hover delegated-focus" },
|
|
95
92
|
standaloneButton,
|
|
96
93
|
contentElement,
|
|
97
94
|
!iconInHeaderRow && iconWrapper));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/action-card/internal.tsx"],"names":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AC,CAAC,IAAI,IAAI,MAAM,CAAC,uBAAuB,qBAAqB,EAAE,CAAC,EAChE,SAAS,CAAC,SAAS,CACpB,mBACc,QAAQ,IAAI,SAAS,+BACV,OAAO;QAEhC,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\" data-awsui-motion-target=\"\">\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 // The hover region is the whole card (see the root element); focusing\n // the inner control also plays the motion.\n 'data-awsui-motion-trigger': 'focus',\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 data-awsui-motion-trigger=\"hover\"\n >\n {standaloneButton}\n {contentElement}\n {!iconInHeaderRow && iconWrapper}\n </div>\n );\n }\n);\n\nexport default InternalActionCard;\n"]}
|
|
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,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAG5E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,UAAU,MAAM,8BAA8B,CAAC;AAItD,MAAM,kBAAkB,GAAG,KAAK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,UAAU,CAAC,IAAI,EAAE,sBAAsB,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,EAC7F,EAAE,EAAE,MAAM,IAET,QAAQ,CACL,CACP,CACG,CACP,CAAC;IAEF,OAAO,CACL,gCACM,SAAS,EACb,GAAG,EAAE,aAAa,EAClB,IAAI,EAAC,OAAO,qBACK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,EACvD,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,IAAI,EACX,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,+BAGV,uBAAuB;QAEhD,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\" data-awsui-motion-target=\"\">\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 // Keyboard focus on the nested header or overlay button, which does not contain the icon,\n // also plays the motion.\n data-awsui-motion-trigger=\"hover delegated-focus\"\n >\n {standaloneButton}\n {contentElement}\n {!iconInHeaderRow && iconWrapper}\n </div>\n );\n }\n);\n\nexport default InternalActionCard;\n"]}
|