@cloudscape-design/components-themeable 3.0.604 → 3.0.606
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/table/body-cell/styles.scss +53 -16
- package/lib/internal/scss/table/expandable-rows/motion.scss +13 -0
- package/lib/internal/scss/table/expandable-rows/styles.scss +47 -0
- package/lib/internal/scss/table/header-cell/styles.scss +15 -6
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/internal/environment.json +1 -1
- package/lib/internal/template/table/body-cell/disabled-inline-editor.d.ts.map +1 -1
- package/lib/internal/template/table/body-cell/disabled-inline-editor.js +1 -0
- package/lib/internal/template/table/body-cell/disabled-inline-editor.js.map +1 -1
- package/lib/internal/template/table/body-cell/index.d.ts.map +1 -1
- package/lib/internal/template/table/body-cell/index.js +4 -3
- package/lib/internal/template/table/body-cell/index.js.map +1 -1
- package/lib/internal/template/table/body-cell/styles.css.js +42 -29
- package/lib/internal/template/table/body-cell/styles.scoped.css +312 -87
- package/lib/internal/template/table/body-cell/styles.selectors.js +42 -29
- package/lib/internal/template/table/body-cell/td-element.d.ts +2 -0
- package/lib/internal/template/table/body-cell/td-element.d.ts.map +1 -1
- package/lib/internal/template/table/body-cell/td-element.js +11 -4
- package/lib/internal/template/table/body-cell/td-element.js.map +1 -1
- package/lib/internal/template/table/expandable-rows/expand-toggle-button.d.ts +4 -0
- package/lib/internal/template/table/expandable-rows/expand-toggle-button.d.ts.map +1 -0
- package/lib/internal/template/table/expandable-rows/expand-toggle-button.js +19 -0
- package/lib/internal/template/table/expandable-rows/expand-toggle-button.js.map +1 -0
- package/lib/internal/template/table/expandable-rows/expandable-rows-utils.d.ts +24 -0
- package/lib/internal/template/table/expandable-rows/expandable-rows-utils.d.ts.map +1 -0
- package/lib/internal/template/table/expandable-rows/expandable-rows-utils.js +58 -0
- package/lib/internal/template/table/expandable-rows/expandable-rows-utils.js.map +1 -0
- package/lib/internal/template/table/expandable-rows/styles.css.js +8 -0
- package/lib/internal/template/table/expandable-rows/styles.scoped.css +197 -0
- package/lib/internal/template/table/expandable-rows/styles.selectors.js +9 -0
- package/lib/internal/template/table/header-cell/index.d.ts +2 -1
- package/lib/internal/template/table/header-cell/index.d.ts.map +1 -1
- package/lib/internal/template/table/header-cell/index.js +3 -2
- package/lib/internal/template/table/header-cell/index.js.map +1 -1
- package/lib/internal/template/table/header-cell/styles.css.js +25 -24
- package/lib/internal/template/table/header-cell/styles.scoped.css +65 -46
- package/lib/internal/template/table/header-cell/styles.selectors.js +25 -24
- package/lib/internal/template/table/interfaces.d.ts +31 -3
- package/lib/internal/template/table/interfaces.d.ts.map +1 -1
- package/lib/internal/template/table/interfaces.js.map +1 -1
- package/lib/internal/template/table/internal.d.ts.map +1 -1
- package/lib/internal/template/table/internal.js +41 -15
- package/lib/internal/template/table/internal.js.map +1 -1
- package/lib/internal/template/table/table-role/grid-navigation.js +4 -1
- package/lib/internal/template/table/table-role/grid-navigation.js.map +1 -1
- package/lib/internal/template/table/table-role/interfaces.d.ts +1 -1
- package/lib/internal/template/table/table-role/interfaces.d.ts.map +1 -1
- package/lib/internal/template/table/table-role/interfaces.js.map +1 -1
- package/lib/internal/template/table/table-role/table-role-helper.d.ts +5 -0
- package/lib/internal/template/table/table-role/table-role-helper.d.ts.map +1 -1
- package/lib/internal/template/table/table-role/table-role-helper.js +11 -6
- package/lib/internal/template/table/table-role/table-role-helper.js.map +1 -1
- package/lib/internal/template/table/thead.d.ts +1 -0
- package/lib/internal/template/table/thead.d.ts.map +1 -1
- package/lib/internal/template/table/thead.js +5 -2
- package/lib/internal/template/table/thead.js.map +1 -1
- package/lib/internal/template/table/use-table-focus-navigation.d.ts +2 -3
- package/lib/internal/template/table/use-table-focus-navigation.d.ts.map +1 -1
- package/lib/internal/template/table/use-table-focus-navigation.js +3 -3
- package/lib/internal/template/table/use-table-focus-navigation.js.map +1 -1
- package/lib/internal/template/test-utils/dom/table/index.d.ts +12 -0
- package/lib/internal/template/test-utils/dom/table/index.js +28 -1
- package/lib/internal/template/test-utils/dom/table/index.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/table/index.d.ts +6 -0
- package/lib/internal/template/test-utils/selectors/table/index.js +14 -0
- package/lib/internal/template/test-utils/selectors/table/index.js.map +1 -1
- package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -26,11 +26,33 @@ $edit-button-padding-right: calc(
|
|
|
26
26
|
); // Cell vertical padding + xxs space that would normally come from the button.
|
|
27
27
|
$success-icon-padding-right: calc(#{$edit-button-padding-right} + #{$icon-width-with-spacing});
|
|
28
28
|
|
|
29
|
+
.expandable-toggle-wrapper {
|
|
30
|
+
position: absolute;
|
|
31
|
+
inset-block: 0;
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
margin-inline-start: calc(-1 * (#{awsui.$space-m} + #{awsui.$space-xs}));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@mixin cell-offset($padding) {
|
|
38
|
+
padding-inline-start: $padding;
|
|
39
|
+
|
|
40
|
+
@for $i from 1 through 9 {
|
|
41
|
+
&.body-cell-expandable-level-#{$i} {
|
|
42
|
+
padding-inline-start: calc($padding + $i * (#{awsui.$space-m} + #{awsui.$space-xs}));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
&.body-cell-expandable-level-next {
|
|
46
|
+
padding-inline-start: calc($padding + 9 * (#{awsui.$space-m} + #{awsui.$space-xs}));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
29
50
|
.body-cell {
|
|
30
51
|
box-sizing: border-box;
|
|
31
52
|
padding-block-start: $cell-vertical-padding;
|
|
32
53
|
padding-block-end: $cell-vertical-padding-w-border;
|
|
33
|
-
|
|
54
|
+
@include cell-offset($cell-horizontal-padding);
|
|
55
|
+
padding-inline-end: $cell-horizontal-padding;
|
|
34
56
|
border-block-start: awsui.$border-divider-list-width solid transparent;
|
|
35
57
|
word-wrap: break-word;
|
|
36
58
|
border-block-end: awsui.$border-divider-list-width solid awsui.$color-border-divider-secondary;
|
|
@@ -65,9 +87,9 @@ $success-icon-padding-right: calc(#{$edit-button-padding-right} + #{$icon-width-
|
|
|
65
87
|
}
|
|
66
88
|
&.is-visual-refresh:first-child {
|
|
67
89
|
&:not(.has-striped-rows) {
|
|
68
|
-
|
|
69
|
-
&:not(.body-cell-edit-active).body-cell-editable:hover {
|
|
70
|
-
|
|
90
|
+
@include cell-offset(awsui.$space-xxxs);
|
|
91
|
+
&:not(.body-cell-edit-active).body-cell-interactive.body-cell-editable:hover {
|
|
92
|
+
@include cell-offset(calc(#{awsui.$space-xxxs} + #{awsui.$border-divider-list-width}));
|
|
71
93
|
}
|
|
72
94
|
}
|
|
73
95
|
|
|
@@ -77,9 +99,9 @@ $success-icon-padding-right: calc(#{$edit-button-padding-right} + #{$icon-width-
|
|
|
77
99
|
to the table edge.
|
|
78
100
|
*/
|
|
79
101
|
&:first-child.has-striped-rows {
|
|
80
|
-
|
|
102
|
+
@include cell-offset(awsui.$space-xxs);
|
|
81
103
|
&-sticky-cell-pad-left {
|
|
82
|
-
|
|
104
|
+
@include cell-offset(awsui.$space-table-horizontal);
|
|
83
105
|
}
|
|
84
106
|
}
|
|
85
107
|
|
|
@@ -93,7 +115,7 @@ $success-icon-padding-right: calc(#{$edit-button-padding-right} + #{$icon-width-
|
|
|
93
115
|
}
|
|
94
116
|
}
|
|
95
117
|
&:first-child:not(.is-visual-refresh) {
|
|
96
|
-
|
|
118
|
+
@include cell-offset($cell-edge-horizontal-padding);
|
|
97
119
|
}
|
|
98
120
|
&-first-row {
|
|
99
121
|
border-block-start: $border-placeholder;
|
|
@@ -148,7 +170,7 @@ $success-icon-padding-right: calc(#{$edit-button-padding-right} + #{$icon-width-
|
|
|
148
170
|
background: awsui.$color-background-container-content;
|
|
149
171
|
z-index: 798; // Our sticky elements should have z-index in the range of 800-850, this value needs to be lower
|
|
150
172
|
&-pad-left:not(.has-selection):not(.is-visual-refresh.body-cell:first-child.has-striped-rows) {
|
|
151
|
-
|
|
173
|
+
@include cell-offset(awsui.$space-table-horizontal);
|
|
152
174
|
}
|
|
153
175
|
&.body-cell-shaded {
|
|
154
176
|
background: awsui.$color-background-cell-shaded;
|
|
@@ -295,6 +317,14 @@ $success-icon-padding-right: calc(#{$edit-button-padding-right} + #{$icon-width-
|
|
|
295
317
|
}
|
|
296
318
|
}
|
|
297
319
|
|
|
320
|
+
&.body-cell-expandable {
|
|
321
|
+
position: relative;
|
|
322
|
+
|
|
323
|
+
&.sticky-cell {
|
|
324
|
+
position: sticky;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
298
328
|
&.body-cell-editable {
|
|
299
329
|
position: relative;
|
|
300
330
|
|
|
@@ -310,25 +340,29 @@ $success-icon-padding-right: calc(#{$edit-button-padding-right} + #{$icon-width-
|
|
|
310
340
|
}
|
|
311
341
|
|
|
312
342
|
&:not(.body-cell-edit-active) {
|
|
313
|
-
|
|
343
|
+
&.body-cell-interactive {
|
|
344
|
+
cursor: pointer;
|
|
345
|
+
}
|
|
314
346
|
|
|
315
347
|
@mixin focused-editor-styles {
|
|
316
348
|
padding-inline-end: calc(#{$cell-horizontal-padding} + #{awsui.$space-l});
|
|
317
|
-
& > .body-cell-editor-wrapper
|
|
349
|
+
& > .body-cell-editor-wrapper,
|
|
350
|
+
& > .expandable-cell-content > .body-cell-editor-wrapper {
|
|
318
351
|
opacity: 1;
|
|
319
352
|
}
|
|
320
353
|
& > .body-cell-success {
|
|
321
354
|
opacity: 1;
|
|
322
355
|
}
|
|
323
356
|
}
|
|
324
|
-
& > .body-cell-editor-wrapper
|
|
357
|
+
& > .body-cell-editor-wrapper,
|
|
358
|
+
& > .expandable-cell-content > .body-cell-editor-wrapper {
|
|
325
359
|
opacity: 0;
|
|
326
360
|
}
|
|
327
361
|
|
|
328
362
|
// Showing focus outline for the cell.
|
|
329
363
|
// We don't use our focus-visible polyfill here because it doesn't work properly with screen readers.
|
|
330
364
|
// These edit buttons are special because they are visually hidden (opacity: 0), but exposed to assistive technology.
|
|
331
|
-
// It's therefore important to display the focus outline, even when a keyboard
|
|
365
|
+
// It's therefore important to display the focus outline, even when a keyboard use wasn't detected.
|
|
332
366
|
// For example, when an edit button is selected from the VoiceOver rotor menu.
|
|
333
367
|
&.body-cell-interactive:focus-within {
|
|
334
368
|
@include styles.focus-highlight(
|
|
@@ -339,7 +373,8 @@ $success-icon-padding-right: calc(#{$edit-button-padding-right} + #{$icon-width-
|
|
|
339
373
|
);
|
|
340
374
|
}
|
|
341
375
|
// When a cell is not interactive the focus outline must be present for the editor button.
|
|
342
|
-
&:not(.body-cell-interactive) > .body-cell-editor-wrapper > .body-cell-editor
|
|
376
|
+
&:not(.body-cell-interactive) > .body-cell-editor-wrapper > .body-cell-editor,
|
|
377
|
+
&:not(.body-cell-interactive) > .expandable-cell-content > .body-cell-editor-wrapper > .body-cell-editor {
|
|
343
378
|
@include focus-visible.when-visible {
|
|
344
379
|
@include styles.focus-highlight(awsui.$space-button-inline-icon-focus-outline-gutter);
|
|
345
380
|
}
|
|
@@ -370,7 +405,8 @@ $success-icon-padding-right: calc(#{$edit-button-padding-right} + #{$icon-width-
|
|
|
370
405
|
inset-inline: 0;
|
|
371
406
|
}
|
|
372
407
|
|
|
373
|
-
& > .body-cell-editor-wrapper
|
|
408
|
+
& > .body-cell-editor-wrapper,
|
|
409
|
+
& > .expandable-cell-content > .body-cell-editor-wrapper {
|
|
374
410
|
padding-inline-end: calc(#{$edit-button-padding-right} - (2 * #{awsui.$border-divider-list-width}));
|
|
375
411
|
}
|
|
376
412
|
& > .body-cell-success {
|
|
@@ -394,7 +430,7 @@ $success-icon-padding-right: calc(#{$edit-button-padding-right} + #{$icon-width-
|
|
|
394
430
|
}
|
|
395
431
|
}
|
|
396
432
|
}
|
|
397
|
-
&-editable.is-visual-refresh:not(.body-cell-edit-active):hover {
|
|
433
|
+
&-editable.is-visual-refresh:not(.body-cell-edit-active).body-cell-interactive:hover {
|
|
398
434
|
&:first-child {
|
|
399
435
|
border-start-start-radius: awsui.$border-radius-item;
|
|
400
436
|
border-end-start-radius: awsui.$border-radius-item;
|
|
@@ -404,7 +440,8 @@ $success-icon-padding-right: calc(#{$edit-button-padding-right} + #{$icon-width-
|
|
|
404
440
|
border-end-end-radius: awsui.$border-radius-item;
|
|
405
441
|
}
|
|
406
442
|
&.body-cell-first-row > .body-cell-success,
|
|
407
|
-
&.body-cell-first-row > .body-cell-editor-wrapper
|
|
443
|
+
&.body-cell-first-row > .body-cell-editor-wrapper,
|
|
444
|
+
&.body-cell-first-row > .expandable-cell-content > .body-cell-editor-wrapper {
|
|
408
445
|
padding-block-start: awsui.$border-divider-list-width;
|
|
409
446
|
}
|
|
410
447
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@use '../../internal/styles' as styles;
|
|
7
|
+
@use '../../internal/styles/tokens' as tokens;
|
|
8
|
+
|
|
9
|
+
.expand-toggle-icon {
|
|
10
|
+
@include styles.with-motion {
|
|
11
|
+
transition: transform tokens.$motion-duration-rotate-90 tokens.$motion-easing-rotate-90;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@use '../../internal/styles/index' as styles;
|
|
7
|
+
@use '../../internal/styles/tokens' as awsui;
|
|
8
|
+
@use '../../internal/hooks/focus-visible' as focus-visible;
|
|
9
|
+
@use '../../internal/styles/tokens' as tokens;
|
|
10
|
+
|
|
11
|
+
@use './motion';
|
|
12
|
+
|
|
13
|
+
.expand-toggle-icon {
|
|
14
|
+
transform: rotate(-90deg);
|
|
15
|
+
|
|
16
|
+
&-expanded {
|
|
17
|
+
transform: rotate(0deg);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.expand-toggle {
|
|
22
|
+
@include styles.styles-reset;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
inline-size: awsui.$space-m;
|
|
25
|
+
block-size: awsui.$space-m;
|
|
26
|
+
border-block: 0;
|
|
27
|
+
border-inline: 0;
|
|
28
|
+
margin-block: 0;
|
|
29
|
+
margin-inline: 0;
|
|
30
|
+
padding-block: 0;
|
|
31
|
+
padding-inline: 0;
|
|
32
|
+
background: none;
|
|
33
|
+
outline: 0;
|
|
34
|
+
|
|
35
|
+
@include focus-visible.when-visible {
|
|
36
|
+
@include styles.focus-highlight(awsui.$space-button-inline-icon-focus-outline-gutter);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
color: awsui.$color-text-interactive-default;
|
|
40
|
+
|
|
41
|
+
&:hover {
|
|
42
|
+
color: awsui.$color-text-interactive-hover;
|
|
43
|
+
}
|
|
44
|
+
&:active {
|
|
45
|
+
color: awsui.$color-text-interactive-active;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -7,6 +7,14 @@
|
|
|
7
7
|
@use '../../internal/styles/tokens' as awsui;
|
|
8
8
|
@use '../../internal/styles' as styles;
|
|
9
9
|
|
|
10
|
+
@mixin cell-offset($padding) {
|
|
11
|
+
padding-inline-start: $padding;
|
|
12
|
+
|
|
13
|
+
&.header-cell-content-expandable {
|
|
14
|
+
padding-inline-start: calc(#{$padding} + #{awsui.$space-m} + #{awsui.$space-xs});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
.header-cell {
|
|
11
19
|
position: relative;
|
|
12
20
|
text-align: start;
|
|
@@ -94,7 +102,8 @@
|
|
|
94
102
|
.header-cell-content {
|
|
95
103
|
position: relative;
|
|
96
104
|
padding-block: awsui.$space-scaled-xxs;
|
|
97
|
-
|
|
105
|
+
@include cell-offset(awsui.$space-s);
|
|
106
|
+
padding-inline-end: awsui.$space-s;
|
|
98
107
|
|
|
99
108
|
.header-cell-sortable > & {
|
|
100
109
|
padding-inline-end: calc(#{awsui.$space-xl} + #{awsui.$space-xxs});
|
|
@@ -158,15 +167,15 @@ settings icon in the pagination slot.
|
|
|
158
167
|
*/
|
|
159
168
|
.header-cell:not(.is-visual-refresh) {
|
|
160
169
|
&:first-child {
|
|
161
|
-
|
|
170
|
+
@include cell-offset(awsui.$space-xs);
|
|
162
171
|
}
|
|
163
172
|
}
|
|
164
173
|
|
|
165
174
|
.header-cell.is-visual-refresh {
|
|
166
175
|
&:first-child:not(.has-striped-rows) {
|
|
167
|
-
|
|
176
|
+
@include cell-offset(awsui.$space-xxxs);
|
|
168
177
|
&.sticky-cell-pad-left {
|
|
169
|
-
|
|
178
|
+
@include cell-offset(awsui.$space-table-horizontal);
|
|
170
179
|
}
|
|
171
180
|
}
|
|
172
181
|
|
|
@@ -176,11 +185,11 @@ settings icon in the pagination slot.
|
|
|
176
185
|
to the table edge.
|
|
177
186
|
*/
|
|
178
187
|
&:first-child.has-striped-rows {
|
|
179
|
-
|
|
188
|
+
@include cell-offset(awsui.$space-xxs);
|
|
180
189
|
}
|
|
181
190
|
|
|
182
191
|
&:first-child > .header-cell-content {
|
|
183
|
-
|
|
192
|
+
@include cell-offset(0px);
|
|
184
193
|
}
|
|
185
194
|
|
|
186
195
|
&:last-child.header-cell-sortable {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disabled-inline-editor.d.ts","sourceRoot":"","sources":["../../../../src/table/body-cell/disabled-inline-editor.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAI7C,UAAU,yBAAyB,CAAC,QAAQ,CAAE,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IAChF,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,EAC7C,SAAS,EACT,IAAI,EACJ,MAAM,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAsB,EACtB,GAAG,IAAI,EACR,EAAE,yBAAyB,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"disabled-inline-editor.d.ts","sourceRoot":"","sources":["../../../../src/table/body-cell/disabled-inline-editor.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAI7C,UAAU,yBAAyB,CAAC,QAAQ,CAAE,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IAChF,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,EAC7C,SAAS,EACT,IAAI,EACJ,MAAM,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAsB,EACtB,GAAG,IAAI,EACR,EAAE,yBAAyB,CAAC,QAAQ,CAAC,eAoGrC"}
|
|
@@ -24,6 +24,7 @@ export function DisabledInlineEditor(_a) {
|
|
|
24
24
|
});
|
|
25
25
|
const [hasHover, setHasHover] = useState(false);
|
|
26
26
|
const [hasFocus, setHasFocus] = useState(false);
|
|
27
|
+
// When a cell is both expandable and editable the icon is always shown.
|
|
27
28
|
const showIcon = hasHover || hasFocus || isEditing || !interactiveCell;
|
|
28
29
|
const iconRef = useRef(null);
|
|
29
30
|
const buttonRef = useRef(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disabled-inline-editor.js","sourceRoot":"","sources":["../../../../src/table/body-cell/disabled-inline-editor.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CA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,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport useHiddenDescription from '../../button-dropdown/utils/use-hidden-description';\nimport Icon from '../../icon/internal';\nimport PopoverContainer from '../../popover/container';\nimport PopoverBody from '../../popover/body';\nimport Portal from '../../internal/components/portal';\nimport { usePortalModeClasses } from '../../internal/hooks/use-portal-mode-classes';\nimport Arrow from '../../popover/arrow';\nimport { useClickAway } from './click-away';\nimport { TableTdElement, TableTdElementProps } from './td-element';\nimport { TableBodyCellProps } from './index';\nimport styles from './styles.css.js';\nimport { useSingleTabStopNavigation } from '../../internal/context/single-tab-stop-navigation-context';\n\ninterface DisabledInlineEditorProps<ItemType> extends TableBodyCellProps<ItemType> {\n editDisabledReason: string;\n}\n\nexport function DisabledInlineEditor<ItemType>({\n className,\n item,\n column,\n ariaLabels,\n isEditing,\n onEditStart,\n onEditEnd,\n editDisabledReason,\n isVisualRefresh,\n interactiveCell = true,\n ...rest\n}: DisabledInlineEditorProps<ItemType>) {\n const clickAwayRef = useClickAway(() => {\n if (isEditing) {\n onEditEnd(true);\n }\n });\n\n const [hasHover, setHasHover] = useState(false);\n const [hasFocus, setHasFocus] = useState(false);\n const showIcon = hasHover || hasFocus || isEditing || !interactiveCell;\n\n const iconRef = useRef(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const portalRef = useRef<HTMLSpanElement>(null);\n\n function handleEscape(event: React.KeyboardEvent): void {\n if (event.key === 'Escape') {\n onEditEnd(true);\n }\n }\n\n const onClick = () => {\n onEditStart();\n buttonRef.current?.focus();\n };\n\n const { targetProps, descriptionEl } = useHiddenDescription(editDisabledReason);\n const portalClasses = usePortalModeClasses(portalRef);\n\n const { tabIndex } = useSingleTabStopNavigation(buttonRef);\n\n return (\n <TableTdElement\n {...rest}\n nativeAttributes={\n { 'data-inline-editing-active': isEditing.toString() } as TableTdElementProps['nativeAttributes']\n }\n className={clsx(\n className,\n styles['body-cell-editable'],\n interactiveCell && styles['body-cell-interactive'],\n isEditing && styles['body-cell-edit-disabled-popover'],\n isVisualRefresh && styles['is-visual-refresh']\n )}\n onClick={interactiveCell && !isEditing ? onClick : undefined}\n onMouseEnter={() => setHasHover(true)}\n onMouseLeave={() => setHasHover(false)}\n ref={clickAwayRef}\n >\n {column.cell(item)}\n\n <div className={styles['body-cell-editor-wrapper']}>\n <button\n ref={buttonRef}\n tabIndex={tabIndex}\n className={clsx(styles['body-cell-editor'], styles['body-cell-editor-disabled'])}\n aria-label={ariaLabels?.activateEditLabel?.(column, item)}\n aria-haspopup=\"dialog\"\n aria-disabled=\"true\"\n onClick={!interactiveCell && !isEditing ? onClick : undefined}\n onFocus={() => setHasFocus(true)}\n onBlur={() => setHasFocus(false)}\n onKeyDown={handleEscape}\n {...targetProps}\n >\n {showIcon && <Icon name=\"lock-private\" variant=\"normal\" __internalRootRef={iconRef} />}\n {descriptionEl}\n </button>\n </div>\n\n {isEditing && (\n <span ref={portalRef}>\n <Portal>\n <span className={portalClasses}>\n <PopoverContainer\n size=\"medium\"\n fixedWidth={false}\n position=\"top\"\n trackRef={iconRef}\n arrow={position => <Arrow position={position} />}\n renderWithPortal={true}\n zIndex={2000}\n >\n <PopoverBody\n dismissButton={false}\n dismissAriaLabel={undefined}\n header={null}\n onDismiss={() => {}}\n overflowVisible=\"both\"\n >\n <span aria-live=\"polite\">{editDisabledReason}</span>\n </PopoverBody>\n </PopoverContainer>\n </span>\n </Portal>\n </span>\n )}\n </TableTdElement>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"disabled-inline-editor.js","sourceRoot":"","sources":["../../../../src/table/body-cell/disabled-inline-editor.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,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, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport useHiddenDescription from '../../button-dropdown/utils/use-hidden-description';\nimport Icon from '../../icon/internal';\nimport PopoverContainer from '../../popover/container';\nimport PopoverBody from '../../popover/body';\nimport Portal from '../../internal/components/portal';\nimport { usePortalModeClasses } from '../../internal/hooks/use-portal-mode-classes';\nimport Arrow from '../../popover/arrow';\nimport { useClickAway } from './click-away';\nimport { TableTdElement, TableTdElementProps } from './td-element';\nimport { TableBodyCellProps } from './index';\nimport styles from './styles.css.js';\nimport { useSingleTabStopNavigation } from '../../internal/context/single-tab-stop-navigation-context';\n\ninterface DisabledInlineEditorProps<ItemType> extends TableBodyCellProps<ItemType> {\n editDisabledReason: string;\n}\n\nexport function DisabledInlineEditor<ItemType>({\n className,\n item,\n column,\n ariaLabels,\n isEditing,\n onEditStart,\n onEditEnd,\n editDisabledReason,\n isVisualRefresh,\n interactiveCell = true,\n ...rest\n}: DisabledInlineEditorProps<ItemType>) {\n const clickAwayRef = useClickAway(() => {\n if (isEditing) {\n onEditEnd(true);\n }\n });\n\n const [hasHover, setHasHover] = useState(false);\n const [hasFocus, setHasFocus] = useState(false);\n // When a cell is both expandable and editable the icon is always shown.\n const showIcon = hasHover || hasFocus || isEditing || !interactiveCell;\n\n const iconRef = useRef(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const portalRef = useRef<HTMLSpanElement>(null);\n\n function handleEscape(event: React.KeyboardEvent): void {\n if (event.key === 'Escape') {\n onEditEnd(true);\n }\n }\n\n const onClick = () => {\n onEditStart();\n buttonRef.current?.focus();\n };\n\n const { targetProps, descriptionEl } = useHiddenDescription(editDisabledReason);\n const portalClasses = usePortalModeClasses(portalRef);\n\n const { tabIndex } = useSingleTabStopNavigation(buttonRef);\n\n return (\n <TableTdElement\n {...rest}\n nativeAttributes={\n { 'data-inline-editing-active': isEditing.toString() } as TableTdElementProps['nativeAttributes']\n }\n className={clsx(\n className,\n styles['body-cell-editable'],\n interactiveCell && styles['body-cell-interactive'],\n isEditing && styles['body-cell-edit-disabled-popover'],\n isVisualRefresh && styles['is-visual-refresh']\n )}\n onClick={interactiveCell && !isEditing ? onClick : undefined}\n onMouseEnter={() => setHasHover(true)}\n onMouseLeave={() => setHasHover(false)}\n ref={clickAwayRef}\n >\n {column.cell(item)}\n\n <div className={styles['body-cell-editor-wrapper']}>\n <button\n ref={buttonRef}\n tabIndex={tabIndex}\n className={clsx(styles['body-cell-editor'], styles['body-cell-editor-disabled'])}\n aria-label={ariaLabels?.activateEditLabel?.(column, item)}\n aria-haspopup=\"dialog\"\n aria-disabled=\"true\"\n onClick={!interactiveCell && !isEditing ? onClick : undefined}\n onFocus={() => setHasFocus(true)}\n onBlur={() => setHasFocus(false)}\n onKeyDown={handleEscape}\n {...targetProps}\n >\n {showIcon && <Icon name=\"lock-private\" variant=\"normal\" __internalRootRef={iconRef} />}\n {descriptionEl}\n </button>\n </div>\n\n {isEditing && (\n <span ref={portalRef}>\n <Portal>\n <span className={portalClasses}>\n <PopoverContainer\n size=\"medium\"\n fixedWidth={false}\n position=\"top\"\n trackRef={iconRef}\n arrow={position => <Arrow position={position} />}\n renderWithPortal={true}\n zIndex={2000}\n >\n <PopoverBody\n dismissButton={false}\n dismissAriaLabel={undefined}\n header={null}\n onDismiss={() => {}}\n overflowVisible=\"both\"\n >\n <span aria-live=\"polite\">{editDisabledReason}</span>\n </PopoverBody>\n </PopoverContainer>\n </span>\n </Portal>\n </span>\n )}\n </TableTdElement>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/table/body-cell/index.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAYnE,MAAM,WAAW,kBAAkB,CAAC,QAAQ,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AU,EAAE,OAAO,CAAA;CAAE,eAYxD"}
|
|
@@ -33,6 +33,7 @@ function TableCellEditable(_a) {
|
|
|
33
33
|
// To improve the initial page render performance we only show the edit icon when necessary.
|
|
34
34
|
const [hasHover, setHasHover] = useState(false);
|
|
35
35
|
const [hasFocus, setHasFocus] = useState(false);
|
|
36
|
+
// When a cell is both expandable and editable the icon is always shown.
|
|
36
37
|
const showIcon = hasHover || hasFocus || !interactiveCell;
|
|
37
38
|
const prevSuccessfulEdit = usePrevious(successfulEdit);
|
|
38
39
|
const prevHasFocus = usePrevious(hasFocus);
|
|
@@ -48,7 +49,7 @@ function TableCellEditable(_a) {
|
|
|
48
49
|
}
|
|
49
50
|
}, [hasFocus, successfulEdit, prevHasFocus, prevSuccessfulEdit]);
|
|
50
51
|
const { tabIndex: editActivateTabIndex } = useSingleTabStopNavigation(editActivateRef);
|
|
51
|
-
return (React.createElement(TableTdElement, Object.assign({}, rest, { nativeAttributes: tdNativeAttributes, className: clsx(className, styles['body-cell-editable'], interactiveCell && styles['body-cell-interactive'], isEditing && styles['body-cell-edit-active'], showSuccessIcon && showIcon && styles['body-cell-has-success'], isVisualRefresh && styles['is-visual-refresh']), onClick: interactiveCell && !isEditing ? onEditStart : undefined, onMouseEnter: () => setHasHover(true), onMouseLeave: () => setHasHover(false) }), isEditing ? (React.createElement(InlineEditor, { ariaLabels: ariaLabels, column: column, item: item, onEditEnd: options => {
|
|
52
|
+
return (React.createElement(TableTdElement, Object.assign({}, rest, { expandableProps: !isEditing ? rest.expandableProps : undefined, nativeAttributes: tdNativeAttributes, className: clsx(className, styles['body-cell-editable'], interactiveCell && styles['body-cell-interactive'], isEditing && styles['body-cell-edit-active'], showSuccessIcon && showIcon && styles['body-cell-has-success'], isVisualRefresh && styles['is-visual-refresh']), onClick: interactiveCell && !isEditing ? onEditStart : undefined, onMouseEnter: () => setHasHover(true), onMouseLeave: () => setHasHover(false) }), isEditing ? (React.createElement(InlineEditor, { ariaLabels: ariaLabels, column: column, item: item, onEditEnd: options => {
|
|
52
53
|
setShowSuccessIcon(false);
|
|
53
54
|
isFocusMoveNeededRef.current = options.refocusCell;
|
|
54
55
|
onEditEnd(options.cancelled);
|
|
@@ -69,10 +70,10 @@ export function TableBodyCell(_a) {
|
|
|
69
70
|
var _b, _c;
|
|
70
71
|
var { isEditable } = _a, rest = __rest(_a, ["isEditable"]);
|
|
71
72
|
const editDisabledReason = (_c = (_b = rest.column.editConfig) === null || _b === void 0 ? void 0 : _b.disabledReason) === null || _c === void 0 ? void 0 : _c.call(_b, rest.item);
|
|
72
|
-
if (editDisabledReason) {
|
|
73
|
+
if (editDisabledReason && !rest.expandableProps) {
|
|
73
74
|
return React.createElement(DisabledInlineEditor, Object.assign({ editDisabledReason: editDisabledReason }, rest));
|
|
74
75
|
}
|
|
75
|
-
if (isEditable || rest.isEditing) {
|
|
76
|
+
if ((isEditable || rest.isEditing) && !rest.expandableProps) {
|
|
76
77
|
return React.createElement(TableCellEditable, Object.assign({}, rest));
|
|
77
78
|
}
|
|
78
79
|
const { column, item } = rest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/table/body-cell/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,qBAAqB,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAuB,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,UAAU,MAAM,gDAAgD,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;A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AAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAChC,MAAM,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EAChC,QAAQ,EAAE,oBAAoB,IAE7B,QAAQ,IAAI,oBAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,CAC1B,CACL,CACL,CACJ,CACc,CAClB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAW,EAGiB;;QAHjB,EACtC,UAAU,OAE6C,EADpD,IAAI,cAF+B,cAGvC,CADQ;IAEP,MAAM,kBAAkB,GAAG,MAAA,MAAA,IAAI,CAAC,MAAM,CAAC,UAAU,0CAAE,cAAc,mDAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IAE/E,IAAI,kBAAkB,EAAE;QACtB,OAAO,oBAAC,oBAAoB,kBAAC,kBAAkB,EAAE,kBAAkB,IAAM,IAAI,EAAI,CAAC;KACnF;IAED,IAAI,UAAU,IAAI,IAAI,CAAC,SAAS,EAAE;QAChC,OAAO,oBAAC,iBAAiB,oBAAK,IAAI,EAAI,CAAC;KACxC;IACD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAC9B,OAAO,oBAAC,cAAc,oBAAK,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAkB,CAAC;AACxE,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport React, { useEffect, useRef, useState } from 'react';\nimport Icon from '../../icon/internal';\nimport { TableProps } from '../interfaces';\nimport { TableTdElement, TableTdElementProps } from './td-element';\nimport { InlineEditor } from './inline-editor';\nimport LiveRegion from '../../internal/components/live-region/index.js';\nimport { useInternalI18n } from '../../i18n/context';\nimport { usePrevious } from '../../internal/hooks/use-previous';\nimport { useSingleTabStopNavigation } from '../../internal/context/single-tab-stop-navigation-context.js';\nimport { DisabledInlineEditor } from './disabled-inline-editor';\n\nconst submitHandlerFallback = () => {\n throw new Error('The function `handleSubmit` is required for editable columns');\n};\n\nexport interface TableBodyCellProps<ItemType> extends TableTdElementProps {\n column: TableProps.ColumnDefinition<ItemType>;\n item: ItemType;\n isEditing: boolean;\n successfulEdit?: boolean;\n onEditStart: () => void;\n onEditEnd: (cancelled: boolean) => void;\n submitEdit?: TableProps.SubmitEditFunction<ItemType>;\n ariaLabels: TableProps['ariaLabels'];\n interactiveCell?: boolean;\n}\n\nfunction TableCellEditable<ItemType>({\n className,\n item,\n column,\n isEditing,\n onEditStart,\n onEditEnd,\n submitEdit,\n ariaLabels,\n isVisualRefresh,\n successfulEdit = false,\n interactiveCell = true,\n ...rest\n}: TableBodyCellProps<ItemType>) {\n const i18n = useInternalI18n('table');\n const editActivateRef = useRef<HTMLButtonElement>(null);\n const tdNativeAttributes = {\n 'data-inline-editing-active': isEditing.toString(),\n };\n const isFocusMoveNeededRef = useRef(false);\n\n useEffect(() => {\n if (!isEditing && editActivateRef.current && isFocusMoveNeededRef.current) {\n isFocusMoveNeededRef.current = false;\n editActivateRef.current.focus();\n }\n }, [isEditing]);\n // To improve the initial page render performance we only show the edit icon when necessary.\n const [hasHover, setHasHover] = useState(false);\n const [hasFocus, setHasFocus] = useState(false);\n const showIcon = hasHover || hasFocus || !interactiveCell;\n\n const prevSuccessfulEdit = usePrevious(successfulEdit);\n const prevHasFocus = usePrevious(hasFocus);\n const [showSuccessIcon, setShowSuccessIcon] = useState(false);\n\n useEffect(() => {\n // Hide the success icon after a successful edit, when cell loses focus.\n if (successfulEdit && prevSuccessfulEdit && !hasFocus && prevHasFocus) {\n setShowSuccessIcon(false);\n }\n // Show success icon right after a successful edit, when `successfulEdit` switches to true.\n if (successfulEdit && !prevSuccessfulEdit) {\n setShowSuccessIcon(true);\n }\n }, [hasFocus, successfulEdit, prevHasFocus, prevSuccessfulEdit]);\n\n const { tabIndex: editActivateTabIndex } = useSingleTabStopNavigation(editActivateRef);\n\n return (\n <TableTdElement\n {...rest}\n nativeAttributes={tdNativeAttributes as TableTdElementProps['nativeAttributes']}\n className={clsx(\n className,\n styles['body-cell-editable'],\n interactiveCell && styles['body-cell-interactive'],\n isEditing && styles['body-cell-edit-active'],\n showSuccessIcon && showIcon && styles['body-cell-has-success'],\n isVisualRefresh && styles['is-visual-refresh']\n )}\n onClick={interactiveCell && !isEditing ? onEditStart : undefined}\n onMouseEnter={() => setHasHover(true)}\n onMouseLeave={() => setHasHover(false)}\n >\n {isEditing ? (\n <InlineEditor\n ariaLabels={ariaLabels}\n column={column}\n item={item}\n onEditEnd={options => {\n setShowSuccessIcon(false);\n isFocusMoveNeededRef.current = options.refocusCell;\n onEditEnd(options.cancelled);\n }}\n submitEdit={submitEdit ?? submitHandlerFallback}\n />\n ) : (\n <>\n {column.cell(item)}\n\n {showSuccessIcon && showIcon && (\n <>\n <span\n className={styles['body-cell-success']}\n aria-label={ariaLabels?.successfulEditLabel?.(column)}\n role=\"img\"\n onMouseDown={e => {\n // Prevent the editor's Button blur event to be fired when clicking the success icon.\n // This prevents unfocusing the button and triggers the `TableTdElement` onClick event which initiates the edit mode.\n e.preventDefault();\n }}\n >\n <Icon name=\"status-positive\" variant=\"success\" />\n </span>\n <LiveRegion>\n {i18n('ariaLabels.successfulEditLabel', ariaLabels?.successfulEditLabel?.(column))}\n </LiveRegion>\n </>\n )}\n\n <div className={styles['body-cell-editor-wrapper']}>\n <button\n className={styles['body-cell-editor']}\n aria-label={ariaLabels?.activateEditLabel?.(column, item)}\n ref={editActivateRef}\n onClick={!interactiveCell && !isEditing ? onEditStart : undefined}\n onFocus={() => setHasFocus(true)}\n onBlur={() => setHasFocus(false)}\n tabIndex={editActivateTabIndex}\n >\n {showIcon && <Icon name=\"edit\" />}\n </button>\n </div>\n </>\n )}\n </TableTdElement>\n );\n}\n\nexport function TableBodyCell<ItemType>({\n isEditable,\n ...rest\n}: TableBodyCellProps<ItemType> & { isEditable: boolean }) {\n const editDisabledReason = rest.column.editConfig?.disabledReason?.(rest.item);\n\n if (editDisabledReason) {\n return <DisabledInlineEditor editDisabledReason={editDisabledReason} {...rest} />;\n }\n\n if (isEditable || rest.isEditing) {\n return <TableCellEditable {...rest} />;\n }\n const { column, item } = rest;\n return <TableTdElement {...rest}>{column.cell(item)}</TableTdElement>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/table/body-cell/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,qBAAqB,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAuB,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,UAAU,MAAM,gDAAgD,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8DAA8D,CAAC;AAC1G,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACjC,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;AAClF,CAAC,CAAC;AAcF,SAAS,iBAAiB,CAAW,EAaN;;QAbM,EACnC,SAAS,EACT,IAAI,EACJ,MAAM,EACN,SAAS,EACT,WAAW,EACX,SAAS,EACT,UAAU,EACV,UAAU,EACV,eAAe,EACf,cAAc,GAAG,KAAK,EACtB,eAAe,GAAG,IAAI,OAEO,EAD1B,IAAI,cAZ4B,4JAapC,CADQ;IAEP,MAAM,IAAI,GAAG,e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MAAA,MAAA,IAAI,CAAC,MAAM,CAAC,UAAU,0CAAE,cAAc,mDAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IAE/E,IAAI,kBAAkB,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;QAC/C,OAAO,oBAAC,oBAAoB,kBAAC,kBAAkB,EAAE,kBAAkB,IAAM,IAAI,EAAI,CAAC;KACnF;IACD,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;QAC3D,OAAO,oBAAC,iBAAiB,oBAAK,IAAI,EAAI,CAAC;KACxC;IAED,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAC9B,OAAO,oBAAC,cAAc,oBAAK,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAkB,CAAC;AACxE,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport React, { useEffect, useRef, useState } from 'react';\nimport Icon from '../../icon/internal';\nimport { TableProps } from '../interfaces';\nimport { TableTdElement, TableTdElementProps } from './td-element';\nimport { InlineEditor } from './inline-editor';\nimport LiveRegion from '../../internal/components/live-region/index.js';\nimport { useInternalI18n } from '../../i18n/context';\nimport { usePrevious } from '../../internal/hooks/use-previous';\nimport { useSingleTabStopNavigation } from '../../internal/context/single-tab-stop-navigation-context.js';\nimport { DisabledInlineEditor } from './disabled-inline-editor';\n\nconst submitHandlerFallback = () => {\n throw new Error('The function `handleSubmit` is required for editable columns');\n};\n\nexport interface TableBodyCellProps<ItemType> extends TableTdElementProps {\n column: TableProps.ColumnDefinition<ItemType>;\n item: ItemType;\n isEditing: boolean;\n successfulEdit?: boolean;\n onEditStart: () => void;\n onEditEnd: (cancelled: boolean) => void;\n submitEdit?: TableProps.SubmitEditFunction<ItemType>;\n ariaLabels: TableProps['ariaLabels'];\n interactiveCell?: boolean;\n}\n\nfunction TableCellEditable<ItemType>({\n className,\n item,\n column,\n isEditing,\n onEditStart,\n onEditEnd,\n submitEdit,\n ariaLabels,\n isVisualRefresh,\n successfulEdit = false,\n interactiveCell = true,\n ...rest\n}: TableBodyCellProps<ItemType>) {\n const i18n = useInternalI18n('table');\n const editActivateRef = useRef<HTMLButtonElement>(null);\n const tdNativeAttributes = {\n 'data-inline-editing-active': isEditing.toString(),\n };\n const isFocusMoveNeededRef = useRef(false);\n\n useEffect(() => {\n if (!isEditing && editActivateRef.current && isFocusMoveNeededRef.current) {\n isFocusMoveNeededRef.current = false;\n editActivateRef.current.focus();\n }\n }, [isEditing]);\n // To improve the initial page render performance we only show the edit icon when necessary.\n const [hasHover, setHasHover] = useState(false);\n const [hasFocus, setHasFocus] = useState(false);\n // When a cell is both expandable and editable the icon is always shown.\n const showIcon = hasHover || hasFocus || !interactiveCell;\n\n const prevSuccessfulEdit = usePrevious(successfulEdit);\n const prevHasFocus = usePrevious(hasFocus);\n const [showSuccessIcon, setShowSuccessIcon] = useState(false);\n\n useEffect(() => {\n // Hide the success icon after a successful edit, when cell loses focus.\n if (successfulEdit && prevSuccessfulEdit && !hasFocus && prevHasFocus) {\n setShowSuccessIcon(false);\n }\n // Show success icon right after a successful edit, when `successfulEdit` switches to true.\n if (successfulEdit && !prevSuccessfulEdit) {\n setShowSuccessIcon(true);\n }\n }, [hasFocus, successfulEdit, prevHasFocus, prevSuccessfulEdit]);\n\n const { tabIndex: editActivateTabIndex } = useSingleTabStopNavigation(editActivateRef);\n\n return (\n <TableTdElement\n {...rest}\n expandableProps={!isEditing ? rest.expandableProps : undefined}\n nativeAttributes={tdNativeAttributes as TableTdElementProps['nativeAttributes']}\n className={clsx(\n className,\n styles['body-cell-editable'],\n interactiveCell && styles['body-cell-interactive'],\n isEditing && styles['body-cell-edit-active'],\n showSuccessIcon && showIcon && styles['body-cell-has-success'],\n isVisualRefresh && styles['is-visual-refresh']\n )}\n onClick={interactiveCell && !isEditing ? onEditStart : undefined}\n onMouseEnter={() => setHasHover(true)}\n onMouseLeave={() => setHasHover(false)}\n >\n {isEditing ? (\n <InlineEditor\n ariaLabels={ariaLabels}\n column={column}\n item={item}\n onEditEnd={options => {\n setShowSuccessIcon(false);\n isFocusMoveNeededRef.current = options.refocusCell;\n onEditEnd(options.cancelled);\n }}\n submitEdit={submitEdit ?? submitHandlerFallback}\n />\n ) : (\n <>\n {column.cell(item)}\n\n {showSuccessIcon && showIcon && (\n <>\n <span\n className={styles['body-cell-success']}\n aria-label={ariaLabels?.successfulEditLabel?.(column)}\n role=\"img\"\n onMouseDown={e => {\n // Prevent the editor's Button blur event to be fired when clicking the success icon.\n // This prevents unfocusing the button and triggers the `TableTdElement` onClick event which initiates the edit mode.\n e.preventDefault();\n }}\n >\n <Icon name=\"status-positive\" variant=\"success\" />\n </span>\n <LiveRegion>\n {i18n('ariaLabels.successfulEditLabel', ariaLabels?.successfulEditLabel?.(column))}\n </LiveRegion>\n </>\n )}\n\n <div className={styles['body-cell-editor-wrapper']}>\n <button\n className={styles['body-cell-editor']}\n aria-label={ariaLabels?.activateEditLabel?.(column, item)}\n ref={editActivateRef}\n onClick={!interactiveCell && !isEditing ? onEditStart : undefined}\n onFocus={() => setHasFocus(true)}\n onBlur={() => setHasFocus(false)}\n tabIndex={editActivateTabIndex}\n >\n {showIcon && <Icon name=\"edit\" />}\n </button>\n </div>\n </>\n )}\n </TableTdElement>\n );\n}\n\nexport function TableBodyCell<ItemType>({\n isEditable,\n ...rest\n}: TableBodyCellProps<ItemType> & { isEditable: boolean }) {\n const editDisabledReason = rest.column.editConfig?.disabledReason?.(rest.item);\n\n if (editDisabledReason && !rest.expandableProps) {\n return <DisabledInlineEditor editDisabledReason={editDisabledReason} {...rest} />;\n }\n if ((isEditable || rest.isEditing) && !rest.expandableProps) {\n return <TableCellEditable {...rest} />;\n }\n\n const { column, item } = rest;\n return <TableTdElement {...rest}>{column.cell(item)}</TableTdElement>;\n}\n"]}
|
|
@@ -1,34 +1,47 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"body-cell-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"body-cell-
|
|
10
|
-
"body-cell-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"body-cell-
|
|
14
|
-
"body-cell-
|
|
15
|
-
"body-cell-
|
|
16
|
-
"
|
|
17
|
-
"body-cell-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"body-cell-
|
|
22
|
-
"body-cell-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"body-cell-
|
|
26
|
-
"body-cell-
|
|
27
|
-
"body-cell-
|
|
28
|
-
"
|
|
29
|
-
"body-cell-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
4
|
+
"expandable-toggle-wrapper": "awsui_expandable-toggle-wrapper_c6tup_16kbu_99",
|
|
5
|
+
"body-cell": "awsui_body-cell_c6tup_16kbu_107",
|
|
6
|
+
"body-cell-expandable-level-1": "awsui_body-cell-expandable-level-1_c6tup_16kbu_121",
|
|
7
|
+
"body-cell-expandable-level-2": "awsui_body-cell-expandable-level-2_c6tup_16kbu_124",
|
|
8
|
+
"body-cell-expandable-level-3": "awsui_body-cell-expandable-level-3_c6tup_16kbu_127",
|
|
9
|
+
"body-cell-expandable-level-4": "awsui_body-cell-expandable-level-4_c6tup_16kbu_130",
|
|
10
|
+
"body-cell-expandable-level-5": "awsui_body-cell-expandable-level-5_c6tup_16kbu_133",
|
|
11
|
+
"body-cell-expandable-level-6": "awsui_body-cell-expandable-level-6_c6tup_16kbu_136",
|
|
12
|
+
"body-cell-expandable-level-7": "awsui_body-cell-expandable-level-7_c6tup_16kbu_139",
|
|
13
|
+
"body-cell-expandable-level-8": "awsui_body-cell-expandable-level-8_c6tup_16kbu_142",
|
|
14
|
+
"body-cell-expandable-level-9": "awsui_body-cell-expandable-level-9_c6tup_16kbu_145",
|
|
15
|
+
"body-cell-expandable-level-next": "awsui_body-cell-expandable-level-next_c6tup_16kbu_148",
|
|
16
|
+
"sticky-cell": "awsui_sticky-cell_c6tup_16kbu_172",
|
|
17
|
+
"body-cell-wrap": "awsui_body-cell-wrap_c6tup_16kbu_175",
|
|
18
|
+
"is-visual-refresh": "awsui_is-visual-refresh_c6tup_16kbu_187",
|
|
19
|
+
"has-striped-rows": "awsui_has-striped-rows_c6tup_16kbu_199",
|
|
20
|
+
"body-cell-edit-active": "awsui_body-cell-edit-active_c6tup_16kbu_232",
|
|
21
|
+
"body-cell-interactive": "awsui_body-cell-interactive_c6tup_16kbu_232",
|
|
22
|
+
"body-cell-editable": "awsui_body-cell-editable_c6tup_16kbu_232",
|
|
23
|
+
"has-striped-rows-sticky-cell-pad-left": "awsui_has-striped-rows-sticky-cell-pad-left_c6tup_16kbu_298",
|
|
24
|
+
"has-selection": "awsui_has-selection_c6tup_16kbu_331",
|
|
25
|
+
"body-cell-first-row": "awsui_body-cell-first-row_c6tup_16kbu_367",
|
|
26
|
+
"body-cell-last-row": "awsui_body-cell-last-row_c6tup_16kbu_370",
|
|
27
|
+
"body-cell-selected": "awsui_body-cell-selected_c6tup_16kbu_370",
|
|
28
|
+
"has-footer": "awsui_has-footer_c6tup_16kbu_370",
|
|
29
|
+
"body-cell-shaded": "awsui_body-cell-shaded_c6tup_16kbu_380",
|
|
30
|
+
"sticky-cell-pad-left": "awsui_sticky-cell-pad-left_c6tup_16kbu_414",
|
|
31
|
+
"sticky-cell-last-right": "awsui_sticky-cell-last-right_c6tup_16kbu_461",
|
|
32
|
+
"sticky-cell-last-left": "awsui_sticky-cell-last-left_c6tup_16kbu_465",
|
|
33
|
+
"body-cell-next-selected": "awsui_body-cell-next-selected_c6tup_16kbu_488",
|
|
34
|
+
"body-cell-prev-selected": "awsui_body-cell-prev-selected_c6tup_16kbu_492",
|
|
35
|
+
"body-cell-editor-wrapper": "awsui_body-cell-editor-wrapper_c6tup_16kbu_516",
|
|
36
|
+
"body-cell-success": "awsui_body-cell-success_c6tup_16kbu_523",
|
|
37
|
+
"body-cell-editor": "awsui_body-cell-editor_c6tup_16kbu_516",
|
|
38
|
+
"body-cell-editor-disabled": "awsui_body-cell-editor-disabled_c6tup_16kbu_550",
|
|
39
|
+
"body-cell-editor-form": "awsui_body-cell-editor-form_c6tup_16kbu_559",
|
|
40
|
+
"body-cell-editor-row": "awsui_body-cell-editor-row_c6tup_16kbu_569",
|
|
41
|
+
"body-cell-editor-controls": "awsui_body-cell-editor-controls_c6tup_16kbu_579",
|
|
42
|
+
"body-cell-expandable": "awsui_body-cell-expandable_c6tup_16kbu_121",
|
|
43
|
+
"expandable-cell-content": "awsui_expandable-cell-content_c6tup_16kbu_603",
|
|
44
|
+
"body-cell-edit-disabled-popover": "awsui_body-cell-edit-disabled-popover_c6tup_16kbu_648",
|
|
45
|
+
"body-cell-has-success": "awsui_body-cell-has-success_c6tup_16kbu_652"
|
|
33
46
|
};
|
|
34
47
|
|