@cloudscape-design/components 3.0.588 → 3.0.590

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/box/interfaces.d.ts +7 -3
  2. package/box/interfaces.d.ts.map +1 -1
  3. package/box/interfaces.js.map +1 -1
  4. package/box/internal.js +1 -1
  5. package/box/internal.js.map +1 -1
  6. package/box/styles.css.js +191 -190
  7. package/box/styles.scoped.css +242 -235
  8. package/box/styles.selectors.js +191 -190
  9. package/internal/base-component/styles.scoped.css +5 -0
  10. package/internal/environment.js +1 -1
  11. package/internal/environment.json +1 -1
  12. package/internal/generated/styles/tokens.d.ts +1 -0
  13. package/internal/generated/styles/tokens.js +1 -0
  14. package/internal/generated/theming/index.cjs +38 -0
  15. package/internal/generated/theming/index.js +38 -0
  16. package/internal/manifest.json +1 -1
  17. package/package.json +1 -1
  18. package/table/body-cell/disabled-inline-editor.d.ts.map +1 -1
  19. package/table/body-cell/disabled-inline-editor.js +1 -0
  20. package/table/body-cell/disabled-inline-editor.js.map +1 -1
  21. package/table/body-cell/index.d.ts.map +1 -1
  22. package/table/body-cell/index.js +4 -3
  23. package/table/body-cell/index.js.map +1 -1
  24. package/table/body-cell/styles.css.js +42 -29
  25. package/table/body-cell/styles.scoped.css +312 -87
  26. package/table/body-cell/styles.selectors.js +42 -29
  27. package/table/body-cell/td-element.d.ts +2 -0
  28. package/table/body-cell/td-element.d.ts.map +1 -1
  29. package/table/body-cell/td-element.js +11 -4
  30. package/table/body-cell/td-element.js.map +1 -1
  31. package/table/expandable-rows/expand-toggle-button.d.ts +4 -0
  32. package/table/expandable-rows/expand-toggle-button.d.ts.map +1 -0
  33. package/table/expandable-rows/expand-toggle-button.js +19 -0
  34. package/table/expandable-rows/expand-toggle-button.js.map +1 -0
  35. package/table/expandable-rows/expandable-rows-utils.d.ts +24 -0
  36. package/table/expandable-rows/expandable-rows-utils.d.ts.map +1 -0
  37. package/table/expandable-rows/expandable-rows-utils.js +58 -0
  38. package/table/expandable-rows/expandable-rows-utils.js.map +1 -0
  39. package/table/expandable-rows/styles.css.js +8 -0
  40. package/table/expandable-rows/styles.scoped.css +197 -0
  41. package/table/expandable-rows/styles.selectors.js +9 -0
  42. package/table/header-cell/index.d.ts +2 -1
  43. package/table/header-cell/index.d.ts.map +1 -1
  44. package/table/header-cell/index.js +3 -2
  45. package/table/header-cell/index.js.map +1 -1
  46. package/table/header-cell/styles.css.js +25 -24
  47. package/table/header-cell/styles.scoped.css +65 -46
  48. package/table/header-cell/styles.selectors.js +25 -24
  49. package/table/interfaces.d.ts +31 -3
  50. package/table/interfaces.d.ts.map +1 -1
  51. package/table/interfaces.js.map +1 -1
  52. package/table/internal.d.ts.map +1 -1
  53. package/table/internal.js +41 -15
  54. package/table/internal.js.map +1 -1
  55. package/table/table-role/grid-navigation.js +4 -1
  56. package/table/table-role/grid-navigation.js.map +1 -1
  57. package/table/table-role/interfaces.d.ts +1 -1
  58. package/table/table-role/interfaces.d.ts.map +1 -1
  59. package/table/table-role/interfaces.js.map +1 -1
  60. package/table/table-role/table-role-helper.d.ts +5 -0
  61. package/table/table-role/table-role-helper.d.ts.map +1 -1
  62. package/table/table-role/table-role-helper.js +11 -6
  63. package/table/table-role/table-role-helper.js.map +1 -1
  64. package/table/thead.d.ts +1 -0
  65. package/table/thead.d.ts.map +1 -1
  66. package/table/thead.js +5 -2
  67. package/table/thead.js.map +1 -1
  68. package/table/use-table-focus-navigation.d.ts +2 -3
  69. package/table/use-table-focus-navigation.d.ts.map +1 -1
  70. package/table/use-table-focus-navigation.js +3 -3
  71. package/table/use-table-focus-navigation.js.map +1 -1
  72. package/test-utils/dom/table/index.d.ts +12 -0
  73. package/test-utils/dom/table/index.js +28 -1
  74. package/test-utils/dom/table/index.js.map +1 -1
  75. package/test-utils/selectors/table/index.d.ts +6 -0
  76. package/test-utils/selectors/table/index.js +14 -0
  77. package/test-utils/selectors/table/index.js.map +1 -1
  78. package/test-utils/tsconfig.tsbuildinfo +1 -1
@@ -79,6 +79,8 @@ export var preset = {
79
79
  "colorOrange500": "#ec7211",
80
80
  "colorOrange600": "#eb5f07",
81
81
  "colorOrange700": "#dd6b10",
82
+ "colorPurple400": "#bf80ff",
83
+ "colorPurple600": "#7300e5",
82
84
  "colorRed100": "#fff7f7",
83
85
  "colorRed500": "#eb6f6f",
84
86
  "colorRed600": "#d91515",
@@ -1455,6 +1457,10 @@ export var preset = {
1455
1457
  "light": "{colorGrey600}",
1456
1458
  "dark": "{colorGrey350}"
1457
1459
  },
1460
+ "colorTextLabelGenAi": {
1461
+ "light": "{colorPurple600}",
1462
+ "dark": "{colorPurple400}"
1463
+ },
1458
1464
  "colorTextHeadingDefault": {
1459
1465
  "light": "{colorGrey900}",
1460
1466
  "dark": "{colorGrey300}"
@@ -3501,6 +3507,10 @@ export var preset = {
3501
3507
  "light": "{colorGrey350}",
3502
3508
  "dark": "{colorGrey350}"
3503
3509
  },
3510
+ "colorTextLabelGenAi": {
3511
+ "light": "{colorPurple400}",
3512
+ "dark": "{colorPurple400}"
3513
+ },
3504
3514
  "colorTextHeadingDefault": {
3505
3515
  "light": "{colorGrey300}",
3506
3516
  "dark": "{colorGrey300}"
@@ -4519,6 +4529,10 @@ export var preset = {
4519
4529
  "light": "{colorGrey350}",
4520
4530
  "dark": "{colorGrey350}"
4521
4531
  },
4532
+ "colorTextLabelGenAi": {
4533
+ "light": "{colorPurple400}",
4534
+ "dark": "{colorPurple400}"
4535
+ },
4522
4536
  "colorTextHeadingDefault": {
4523
4537
  "light": "{colorGrey300}",
4524
4538
  "dark": "{colorGrey300}"
@@ -5469,6 +5483,10 @@ export var preset = {
5469
5483
  "light": "{colorGrey600}",
5470
5484
  "dark": "{colorGrey350}"
5471
5485
  },
5486
+ "colorTextLabelGenAi": {
5487
+ "light": "{colorPurple600}",
5488
+ "dark": "{colorPurple400}"
5489
+ },
5472
5490
  "colorTextHeadingDefault": {
5473
5491
  "light": "{colorGrey900}",
5474
5492
  "dark": "{colorGrey300}"
@@ -6419,6 +6437,10 @@ export var preset = {
6419
6437
  "light": "{colorGrey600}",
6420
6438
  "dark": "{colorGrey350}"
6421
6439
  },
6440
+ "colorTextLabelGenAi": {
6441
+ "light": "{colorPurple600}",
6442
+ "dark": "{colorPurple400}"
6443
+ },
6422
6444
  "colorTextHeadingDefault": {
6423
6445
  "light": "{colorGrey900}",
6424
6446
  "dark": "{colorGrey300}"
@@ -7369,6 +7391,10 @@ export var preset = {
7369
7391
  "light": "{colorGrey600}",
7370
7392
  "dark": "{colorGrey350}"
7371
7393
  },
7394
+ "colorTextLabelGenAi": {
7395
+ "light": "{colorPurple600}",
7396
+ "dark": "{colorPurple400}"
7397
+ },
7372
7398
  "colorTextHeadingDefault": {
7373
7399
  "light": "{colorGrey900}",
7374
7400
  "dark": "{colorGrey300}"
@@ -8321,6 +8347,10 @@ export var preset = {
8321
8347
  "light": "{colorGrey350}",
8322
8348
  "dark": "{colorGrey350}"
8323
8349
  },
8350
+ "colorTextLabelGenAi": {
8351
+ "light": "{colorPurple400}",
8352
+ "dark": "{colorPurple400}"
8353
+ },
8324
8354
  "colorTextHeadingDefault": {
8325
8355
  "light": "{colorGrey300}",
8326
8356
  "dark": "{colorGrey300}"
@@ -8862,6 +8892,7 @@ export var preset = {
8862
8892
  "colorTextFormLabel": "color",
8863
8893
  "colorTextFormSecondary": "color",
8864
8894
  "colorTextGroupLabel": "color",
8895
+ "colorTextLabelGenAi": "color",
8865
8896
  "colorTextHeadingDefault": "color",
8866
8897
  "colorTextHeadingSecondary": "color",
8867
8898
  "colorTextHomeHeaderDefault": "color",
@@ -9530,6 +9561,7 @@ export var preset = {
9530
9561
  "colorTextFormDefault",
9531
9562
  "colorTextFormSecondary",
9532
9563
  "colorTextGroupLabel",
9564
+ "colorTextLabelGenAi",
9533
9565
  "colorTextHeadingDefault",
9534
9566
  "colorTextHeadingSecondary",
9535
9567
  "colorTextHomeHeaderDefault",
@@ -9675,6 +9707,8 @@ export var preset = {
9675
9707
  "colorOrange500": "color-orange-500",
9676
9708
  "colorOrange600": "color-orange-600",
9677
9709
  "colorOrange700": "color-orange-700",
9710
+ "colorPurple400": "color-purple-400",
9711
+ "colorPurple600": "color-purple-600",
9678
9712
  "colorRed100": "color-red-100",
9679
9713
  "colorRed500": "color-red-500",
9680
9714
  "colorRed600": "color-red-600",
@@ -10028,6 +10062,7 @@ export var preset = {
10028
10062
  "colorTextFormLabel": "color-text-form-label",
10029
10063
  "colorTextFormSecondary": "color-text-form-secondary",
10030
10064
  "colorTextGroupLabel": "color-text-group-label",
10065
+ "colorTextLabelGenAi": "color-text-label-gen-ai",
10031
10066
  "colorTextHeadingDefault": "color-text-heading-default",
10032
10067
  "colorTextHeadingSecondary": "color-text-heading-secondary",
10033
10068
  "colorTextHomeHeaderDefault": "color-text-home-header-default",
@@ -10362,6 +10397,8 @@ export var preset = {
10362
10397
  "colorOrange500": "--color-orange-500-dpl1nc",
10363
10398
  "colorOrange600": "--color-orange-600-5vsg33",
10364
10399
  "colorOrange700": "--color-orange-700-3igdeo",
10400
+ "colorPurple400": "--color-purple-400-wvnlma",
10401
+ "colorPurple600": "--color-purple-600-468euy",
10365
10402
  "colorRed100": "--color-red-100-wywj7v",
10366
10403
  "colorRed500": "--color-red-500-9zl15j",
10367
10404
  "colorRed600": "--color-red-600-gv9so7",
@@ -10715,6 +10752,7 @@ export var preset = {
10715
10752
  "colorTextFormLabel": "--color-text-form-label-ktbzsd",
10716
10753
  "colorTextFormSecondary": "--color-text-form-secondary-dxc248",
10717
10754
  "colorTextGroupLabel": "--color-text-group-label-jpw8sm",
10755
+ "colorTextLabelGenAi": "--color-text-label-gen-ai-76ots7",
10718
10756
  "colorTextHeadingDefault": "--color-text-heading-default-lstrpn",
10719
10757
  "colorTextHeadingSecondary": "--color-text-heading-secondary-37b2tq",
10720
10758
  "colorTextHomeHeaderDefault": "--color-text-home-header-default-efg900",
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "d4d0eb7ce0096e4946546e94a72511fa7abbe571"
2
+ "commit": "04e74f65b28e68e095bb2e7e48e599a2f39f3e86"
3
3
  }
package/package.json CHANGED
@@ -116,7 +116,7 @@
116
116
  "./internal/base-component/index.js",
117
117
  "./internal/base-component/styles.css.js"
118
118
  ],
119
- "version": "3.0.588",
119
+ "version": "3.0.590",
120
120
  "repository": {
121
121
  "type": "git",
122
122
  "url": "https://github.com/cloudscape-design/components.git"
@@ -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,eAmGrC"}
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,CAAC;AAChD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,oBAAoB,MAAM,oDAAoD,CAAC;AACtF,OAAO,IAAI,MAAM,qBAAqB,CAAC;AACvC,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,MAAM,MAAM,kCAAkC,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AACpF,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAuB,MAAM,cAAc,CAAC;AAEnE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,0BAA0B,EAAE,MAAM,2DAA2D,CAAC;AAMvG,MAAM,UAAU,oBAAoB,CAAW,EAYT;;QAZS,EAC7C,SAAS,EACT,IAAI,EACJ,MAAM,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAe,GAAG,IAAI,OAEc,EADjC,IAAI,cAXsC,kJAY9C,CADQ;IAEP,MAAM,YAAY,GAAG,YAAY,CAAC,G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AAE,KAAK,EACjB,QAAQ,EAAC,KAAK,EACd,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,oBAAC,KAAK,IAAC,QAAQ,EAAE,QAAQ,GAAI,EAChD,gBAAgB,EAAE,IAAI,EACtB,MAAM,EAAE,IAAI;wBAEZ,oBAAC,WAAW,IACV,aAAa,EAAE,KAAK,EACpB,gBAAgB,EAAE,SAAS,EAC3B,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC,EACnB,eAAe,EAAC,MAAM;4BAEtB,2CAAgB,QAAQ,IAAE,kBAAkB,CAAQ,CACxC,CACG,CACd,CACA,CACJ,CACR,CACc,CAClB,CAAC;AACJ,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,OAAO,oBAAoB,MAAM,oDAAoD,CAAC;AACtF,OAAO,IAAI,MAAM,qBAAqB,CAAC;AACvC,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,MAAM,MAAM,kCAAkC,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AACpF,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAuB,MAAM,cAAc,CAAC;AAEnE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,0BAA0B,EAAE,MAAM,2DAA2D,CAAC;AAMvG,MAAM,UAAU,oBAAoB,CAAW,EAYT;;QAZS,EAC7C,SAAS,EACT,IAAI,EACJ,MAAM,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAe,GAAG,IAAI,OAEc,EADjC,IAAI,cAXsC,kJAY9C,CADQ;IAEP,MAAM,YAAY,GAAG,YAAY,CAAC,GAAG,EAAE;QACrC,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,I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d,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,oBAAC,KAAK,IAAC,QAAQ,EAAE,QAAQ,GAAI,EAChD,gBAAgB,EAAE,IAAI,EACtB,MAAM,EAAE,IAAI;wBAEZ,oBAAC,WAAW,IACV,aAAa,EAAE,KAAK,EACpB,gBAAgB,EAAE,SAAS,EAC3B,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC,EACnB,eAAe,EAAC,MAAM;4BAEtB,2CAAgB,QAAQ,IAAE,kBAAkB,CAAQ,CACxC,CACG,CACd,CACA,CACJ,CACR,CACc,CAClB,CAAC;AACJ,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 // 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,CAAE,SAAQ,mBAAmB;IACvE,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC9C,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,UAAU,CAAC,EAAE,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACrD,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IACrC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AA0HD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,EACtC,UAAU,EACV,GAAG,IAAI,EACR,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,eAYxD"}
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,CAAE,SAAQ,mBAAmB;IACvE,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC9C,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,UAAU,CAAC,EAAE,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACrD,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IACrC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AA4HD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,EACtC,UAAU,EACV,GAAG,IAAI,EACR,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG;IAAE,UAAU,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,iBAAi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right 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,0BAA0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,GAAG,EAAE,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,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
- "body-cell": "awsui_body-cell_c6tup_6muoq_99",
5
- "sticky-cell": "awsui_sticky-cell_c6tup_6muoq_133",
6
- "body-cell-wrap": "awsui_body-cell-wrap_c6tup_6muoq_136",
7
- "is-visual-refresh": "awsui_is-visual-refresh_c6tup_6muoq_148",
8
- "has-striped-rows": "awsui_has-striped-rows_c6tup_6muoq_160",
9
- "body-cell-edit-active": "awsui_body-cell-edit-active_c6tup_6muoq_163",
10
- "body-cell-editable": "awsui_body-cell-editable_c6tup_6muoq_163",
11
- "has-striped-rows-sticky-cell-pad-left": "awsui_has-striped-rows-sticky-cell-pad-left_c6tup_6muoq_169",
12
- "has-selection": "awsui_has-selection_c6tup_6muoq_172",
13
- "body-cell-first-row": "awsui_body-cell-first-row_c6tup_6muoq_178",
14
- "body-cell-last-row": "awsui_body-cell-last-row_c6tup_6muoq_181",
15
- "body-cell-selected": "awsui_body-cell-selected_c6tup_6muoq_181",
16
- "has-footer": "awsui_has-footer_c6tup_6muoq_181",
17
- "body-cell-shaded": "awsui_body-cell-shaded_c6tup_6muoq_191",
18
- "sticky-cell-pad-left": "awsui_sticky-cell-pad-left_c6tup_6muoq_225",
19
- "sticky-cell-last-right": "awsui_sticky-cell-last-right_c6tup_6muoq_242",
20
- "sticky-cell-last-left": "awsui_sticky-cell-last-left_c6tup_6muoq_246",
21
- "body-cell-next-selected": "awsui_body-cell-next-selected_c6tup_6muoq_269",
22
- "body-cell-prev-selected": "awsui_body-cell-prev-selected_c6tup_6muoq_273",
23
- "body-cell-editor-wrapper": "awsui_body-cell-editor-wrapper_c6tup_6muoq_297",
24
- "body-cell-success": "awsui_body-cell-success_c6tup_6muoq_304",
25
- "body-cell-editor": "awsui_body-cell-editor_c6tup_6muoq_297",
26
- "body-cell-editor-disabled": "awsui_body-cell-editor-disabled_c6tup_6muoq_331",
27
- "body-cell-editor-form": "awsui_body-cell-editor-form_c6tup_6muoq_340",
28
- "body-cell-editor-row": "awsui_body-cell-editor-row_c6tup_6muoq_350",
29
- "body-cell-editor-controls": "awsui_body-cell-editor-controls_c6tup_6muoq_360",
30
- "body-cell-interactive": "awsui_body-cell-interactive_c6tup_6muoq_381",
31
- "body-cell-edit-disabled-popover": "awsui_body-cell-edit-disabled-popover_c6tup_6muoq_423",
32
- "body-cell-has-success": "awsui_body-cell-has-success_c6tup_6muoq_427"
4
+ "expandable-toggle-wrapper": "awsui_expandable-toggle-wrapper_c6tup_19jo8_99",
5
+ "body-cell": "awsui_body-cell_c6tup_19jo8_107",
6
+ "body-cell-expandable-level-1": "awsui_body-cell-expandable-level-1_c6tup_19jo8_121",
7
+ "body-cell-expandable-level-2": "awsui_body-cell-expandable-level-2_c6tup_19jo8_124",
8
+ "body-cell-expandable-level-3": "awsui_body-cell-expandable-level-3_c6tup_19jo8_127",
9
+ "body-cell-expandable-level-4": "awsui_body-cell-expandable-level-4_c6tup_19jo8_130",
10
+ "body-cell-expandable-level-5": "awsui_body-cell-expandable-level-5_c6tup_19jo8_133",
11
+ "body-cell-expandable-level-6": "awsui_body-cell-expandable-level-6_c6tup_19jo8_136",
12
+ "body-cell-expandable-level-7": "awsui_body-cell-expandable-level-7_c6tup_19jo8_139",
13
+ "body-cell-expandable-level-8": "awsui_body-cell-expandable-level-8_c6tup_19jo8_142",
14
+ "body-cell-expandable-level-9": "awsui_body-cell-expandable-level-9_c6tup_19jo8_145",
15
+ "body-cell-expandable-level-next": "awsui_body-cell-expandable-level-next_c6tup_19jo8_148",
16
+ "sticky-cell": "awsui_sticky-cell_c6tup_19jo8_172",
17
+ "body-cell-wrap": "awsui_body-cell-wrap_c6tup_19jo8_175",
18
+ "is-visual-refresh": "awsui_is-visual-refresh_c6tup_19jo8_187",
19
+ "has-striped-rows": "awsui_has-striped-rows_c6tup_19jo8_199",
20
+ "body-cell-edit-active": "awsui_body-cell-edit-active_c6tup_19jo8_232",
21
+ "body-cell-interactive": "awsui_body-cell-interactive_c6tup_19jo8_232",
22
+ "body-cell-editable": "awsui_body-cell-editable_c6tup_19jo8_232",
23
+ "has-striped-rows-sticky-cell-pad-left": "awsui_has-striped-rows-sticky-cell-pad-left_c6tup_19jo8_298",
24
+ "has-selection": "awsui_has-selection_c6tup_19jo8_331",
25
+ "body-cell-first-row": "awsui_body-cell-first-row_c6tup_19jo8_367",
26
+ "body-cell-last-row": "awsui_body-cell-last-row_c6tup_19jo8_370",
27
+ "body-cell-selected": "awsui_body-cell-selected_c6tup_19jo8_370",
28
+ "has-footer": "awsui_has-footer_c6tup_19jo8_370",
29
+ "body-cell-shaded": "awsui_body-cell-shaded_c6tup_19jo8_380",
30
+ "sticky-cell-pad-left": "awsui_sticky-cell-pad-left_c6tup_19jo8_414",
31
+ "sticky-cell-last-right": "awsui_sticky-cell-last-right_c6tup_19jo8_461",
32
+ "sticky-cell-last-left": "awsui_sticky-cell-last-left_c6tup_19jo8_465",
33
+ "body-cell-next-selected": "awsui_body-cell-next-selected_c6tup_19jo8_488",
34
+ "body-cell-prev-selected": "awsui_body-cell-prev-selected_c6tup_19jo8_492",
35
+ "body-cell-editor-wrapper": "awsui_body-cell-editor-wrapper_c6tup_19jo8_516",
36
+ "body-cell-success": "awsui_body-cell-success_c6tup_19jo8_523",
37
+ "body-cell-editor": "awsui_body-cell-editor_c6tup_19jo8_516",
38
+ "body-cell-editor-disabled": "awsui_body-cell-editor-disabled_c6tup_19jo8_550",
39
+ "body-cell-editor-form": "awsui_body-cell-editor-form_c6tup_19jo8_559",
40
+ "body-cell-editor-row": "awsui_body-cell-editor-row_c6tup_19jo8_569",
41
+ "body-cell-editor-controls": "awsui_body-cell-editor-controls_c6tup_19jo8_579",
42
+ "body-cell-expandable": "awsui_body-cell-expandable_c6tup_19jo8_121",
43
+ "expandable-cell-content": "awsui_expandable-cell-content_c6tup_19jo8_603",
44
+ "body-cell-edit-disabled-popover": "awsui_body-cell-edit-disabled-popover_c6tup_19jo8_648",
45
+ "body-cell-has-success": "awsui_body-cell-has-success_c6tup_19jo8_652"
33
46
  };
34
47