@cloudscape-design/components 3.0.600 → 3.0.602

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 (108) hide show
  1. package/app-layout/classic.d.ts +5 -1
  2. package/app-layout/classic.d.ts.map +1 -1
  3. package/app-layout/classic.js +1 -1
  4. package/app-layout/classic.js.map +1 -1
  5. package/app-layout/implementation.d.ts +5 -1
  6. package/app-layout/implementation.d.ts.map +1 -1
  7. package/app-layout/implementation.js.map +1 -1
  8. package/app-layout/interfaces.d.ts +2 -0
  9. package/app-layout/interfaces.d.ts.map +1 -1
  10. package/app-layout/interfaces.js.map +1 -1
  11. package/app-layout/internal.d.ts +5 -1
  12. package/app-layout/internal.d.ts.map +1 -1
  13. package/app-layout/visual-refresh/context.d.ts +3 -3
  14. package/app-layout/visual-refresh/context.d.ts.map +1 -1
  15. package/app-layout/visual-refresh/context.js +1 -1
  16. package/app-layout/visual-refresh/context.js.map +1 -1
  17. package/app-layout/visual-refresh/index.d.ts +5 -1
  18. package/app-layout/visual-refresh/index.d.ts.map +1 -1
  19. package/app-layout/visual-refresh/index.js.map +1 -1
  20. package/app-layout/widget.d.ts +2 -2
  21. package/app-layout/widget.d.ts.map +1 -1
  22. package/app-layout/widget.js.map +1 -1
  23. package/button-dropdown/internal.d.ts.map +1 -1
  24. package/button-dropdown/internal.js +2 -1
  25. package/button-dropdown/internal.js.map +1 -1
  26. package/calendar/grid/index.d.ts +1 -1
  27. package/calendar/grid/index.d.ts.map +1 -1
  28. package/calendar/grid/index.js.map +1 -1
  29. package/calendar/grid/use-calendar-grid-keyboard-navigation.d.ts +1 -1
  30. package/calendar/grid/use-calendar-grid-keyboard-navigation.d.ts.map +1 -1
  31. package/calendar/grid/use-calendar-grid-keyboard-navigation.js +16 -28
  32. package/calendar/grid/use-calendar-grid-keyboard-navigation.js.map +1 -1
  33. package/date-range-picker/calendar/grids/grid.d.ts +1 -1
  34. package/date-range-picker/calendar/grids/grid.d.ts.map +1 -1
  35. package/date-range-picker/calendar/grids/grid.js +4 -4
  36. package/date-range-picker/calendar/grids/grid.js.map +1 -1
  37. package/date-range-picker/calendar/grids/index.d.ts.map +1 -1
  38. package/date-range-picker/calendar/grids/index.js +14 -28
  39. package/date-range-picker/calendar/grids/index.js.map +1 -1
  40. package/date-range-picker/calendar/grids/styles.css.js +27 -25
  41. package/date-range-picker/calendar/grids/styles.scoped.css +54 -54
  42. package/date-range-picker/calendar/grids/styles.selectors.js +27 -25
  43. package/internal/direction.d.ts +9 -0
  44. package/internal/direction.d.ts.map +1 -0
  45. package/internal/direction.js +15 -0
  46. package/internal/direction.js.map +1 -0
  47. package/internal/environment.js +1 -1
  48. package/internal/environment.json +1 -1
  49. package/internal/manifest.json +1 -1
  50. package/internal/utils/handle-key.d.ts +13 -0
  51. package/internal/utils/handle-key.d.ts.map +1 -0
  52. package/internal/utils/handle-key.js +37 -0
  53. package/internal/utils/handle-key.js.map +1 -0
  54. package/package.json +1 -1
  55. package/segmented-control/internal-segmented-control.d.ts.map +1 -1
  56. package/segmented-control/internal-segmented-control.js +5 -6
  57. package/segmented-control/internal-segmented-control.js.map +1 -1
  58. package/table/body-cell/index.d.ts.map +1 -1
  59. package/table/body-cell/index.js +6 -3
  60. package/table/body-cell/index.js.map +1 -1
  61. package/table/body-cell/styles.css.js +43 -42
  62. package/table/body-cell/styles.scoped.css +203 -200
  63. package/table/body-cell/styles.selectors.js +43 -42
  64. package/table/body-cell/td-element.d.ts +6 -2
  65. package/table/body-cell/td-element.d.ts.map +1 -1
  66. package/table/body-cell/td-element.js +6 -6
  67. package/table/body-cell/td-element.js.map +1 -1
  68. package/table/expandable-rows/expand-toggle-button.d.ts +6 -2
  69. package/table/expandable-rows/expand-toggle-button.d.ts.map +1 -1
  70. package/table/expandable-rows/expand-toggle-button.js +1 -6
  71. package/table/expandable-rows/expand-toggle-button.js.map +1 -1
  72. package/table/expandable-rows/expandable-rows-utils.d.ts +3 -2
  73. package/table/expandable-rows/expandable-rows-utils.d.ts.map +1 -1
  74. package/table/expandable-rows/expandable-rows-utils.js.map +1 -1
  75. package/table/index.d.ts.map +1 -1
  76. package/table/index.js +3 -0
  77. package/table/index.js.map +1 -1
  78. package/table/internal.d.ts.map +1 -1
  79. package/table/internal.js +5 -7
  80. package/table/internal.js.map +1 -1
  81. package/table/selection/selection-control.d.ts +1 -3
  82. package/table/selection/selection-control.d.ts.map +1 -1
  83. package/table/selection/selection-control.js +5 -3
  84. package/table/selection/selection-control.js.map +1 -1
  85. package/table/table-role/grid-navigation.d.ts.map +1 -1
  86. package/table/table-role/grid-navigation.js +10 -9
  87. package/table/table-role/grid-navigation.js.map +1 -1
  88. package/table/table-role/table-role-helper.d.ts +3 -5
  89. package/table/table-role/table-role-helper.d.ts.map +1 -1
  90. package/table/table-role/table-role-helper.js +8 -4
  91. package/table/table-role/table-role-helper.js.map +1 -1
  92. package/table/table-role/utils.d.ts +1 -0
  93. package/table/table-role/utils.d.ts.map +1 -1
  94. package/table/table-role/utils.js +4 -1
  95. package/table/table-role/utils.js.map +1 -1
  96. package/table/thead.d.ts.map +1 -1
  97. package/table/thead.js +1 -1
  98. package/table/thead.js.map +1 -1
  99. package/tabs/scroll-utils.d.ts +4 -4
  100. package/tabs/scroll-utils.d.ts.map +1 -1
  101. package/tabs/scroll-utils.js +14 -14
  102. package/tabs/scroll-utils.js.map +1 -1
  103. package/tabs/tab-header-bar.d.ts.map +1 -1
  104. package/tabs/tab-header-bar.js +25 -50
  105. package/tabs/tab-header-bar.js.map +1 -1
  106. package/top-navigation/parts/overflow-menu/menu-item.d.ts.map +1 -1
  107. package/top-navigation/parts/overflow-menu/menu-item.js +2 -1
  108. package/top-navigation/parts/overflow-menu/menu-item.js.map +1 -1
@@ -0,0 +1,15 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export function isRtl(element) {
4
+ return getComputedStyle(element).direction === 'rtl';
5
+ }
6
+ /**
7
+ * The scrollLeft value will be a negative number if the direction is RTL and
8
+ * needs to be converted to a positive value for direction independent scroll
9
+ * computations. Additionally, the scrollLeft value can be a decimal value on
10
+ * systems using display scaling requiring the floor and ceiling calls.
11
+ */
12
+ export function getScrollInlineStart(element) {
13
+ return isRtl(element) ? Math.floor(element.scrollLeft) * -1 : Math.ceil(element.scrollLeft);
14
+ }
15
+ //# sourceMappingURL=direction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direction.js","sourceRoot":"","sources":["../../../src/internal/direction.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,MAAM,UAAU,KAAK,CAAC,OAAiC;IACrD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC,SAAS,KAAK,KAAK,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAoB;IACvD,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAC9F,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function isRtl(element: HTMLElement | SVGElement) {\n return getComputedStyle(element).direction === 'rtl';\n}\n\n/**\n * The scrollLeft value will be a negative number if the direction is RTL and\n * needs to be converted to a positive value for direction independent scroll\n * computations. Additionally, the scrollLeft value can be a decimal value on\n * systems using display scaling requiring the floor and ceiling calls.\n */\nexport function getScrollInlineStart(element: HTMLElement) {\n return isRtl(element) ? Math.floor(element.scrollLeft) * -1 : Math.ceil(element.scrollLeft);\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (0a7c2fe5)";
2
+ export var PACKAGE_VERSION = "3.0.0 (a3c06e8f)";
3
3
  export var THEME = "open-source-visual-refresh";
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (0a7c2fe5)",
3
+ "PACKAGE_VERSION": "3.0.0 (a3c06e8f)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "0a7c2fe557b000404d52e565ffcbf94f18e53349"
2
+ "commit": "a3c06e8fffbbd0e6625d8e923d44996278f5c70e"
3
3
  }
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ export default function handleKey(event: React.KeyboardEvent<HTMLElement>, { onActivate, onBlockEnd, onBlockStart, onEnd, onHome, onInlineEnd, onInlineStart, onPageDown, onPageUp, }: {
3
+ onActivate?: (event: React.KeyboardEvent) => void;
4
+ onBlockEnd?: (event: React.KeyboardEvent) => void;
5
+ onBlockStart?: (event: React.KeyboardEvent) => void;
6
+ onEnd?: (event: React.KeyboardEvent) => void;
7
+ onHome?: (event: React.KeyboardEvent) => void;
8
+ onInlineEnd?: (event: React.KeyboardEvent) => void;
9
+ onInlineStart?: (event: React.KeyboardEvent) => void;
10
+ onPageDown?: (event: React.KeyboardEvent) => void;
11
+ onPageUp?: (event: React.KeyboardEvent) => void;
12
+ }): void;
13
+ //# sourceMappingURL=handle-key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-key.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/handle-key.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,EACvC,EACE,UAAU,EACV,UAAU,EACV,YAAY,EACZ,KAAK,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,UAAU,EACV,QAAQ,GACT,EAAE;IACD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IAClD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IAClD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IACpD,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IAC7C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IAC9C,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IACnD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IACrD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;CACjD,QAgCF"}
@@ -0,0 +1,37 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { KeyCode } from '../keycode';
4
+ import { isRtl } from '../direction';
5
+ export default function handleKey(event, { onActivate, onBlockEnd, onBlockStart, onEnd, onHome, onInlineEnd, onInlineStart, onPageDown, onPageUp, }) {
6
+ switch (event.keyCode) {
7
+ case KeyCode.down:
8
+ onBlockEnd === null || onBlockEnd === void 0 ? void 0 : onBlockEnd(event);
9
+ break;
10
+ case KeyCode.end:
11
+ onEnd === null || onEnd === void 0 ? void 0 : onEnd(event);
12
+ break;
13
+ case KeyCode.enter:
14
+ case KeyCode.space:
15
+ onActivate === null || onActivate === void 0 ? void 0 : onActivate(event);
16
+ break;
17
+ case KeyCode.home:
18
+ onHome === null || onHome === void 0 ? void 0 : onHome(event);
19
+ break;
20
+ case KeyCode.left:
21
+ isRtl(event.currentTarget) ? onInlineEnd === null || onInlineEnd === void 0 ? void 0 : onInlineEnd(event) : onInlineStart === null || onInlineStart === void 0 ? void 0 : onInlineStart(event);
22
+ break;
23
+ case KeyCode.pageDown:
24
+ onPageDown === null || onPageDown === void 0 ? void 0 : onPageDown(event);
25
+ break;
26
+ case KeyCode.pageUp:
27
+ onPageUp === null || onPageUp === void 0 ? void 0 : onPageUp(event);
28
+ break;
29
+ case KeyCode.right:
30
+ isRtl(event.currentTarget) ? onInlineStart === null || onInlineStart === void 0 ? void 0 : onInlineStart(event) : onInlineEnd === null || onInlineEnd === void 0 ? void 0 : onInlineEnd(event);
31
+ break;
32
+ case KeyCode.up:
33
+ onBlockStart === null || onBlockStart === void 0 ? void 0 : onBlockStart(event);
34
+ break;
35
+ }
36
+ }
37
+ //# sourceMappingURL=handle-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-key.js","sourceRoot":"","sources":["../../../../src/internal/utils/handle-key.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,KAAuC,EACvC,EACE,UAAU,EACV,UAAU,EACV,YAAY,EACZ,KAAK,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,UAAU,EACV,QAAQ,GAWT;IAED,QAAQ,KAAK,CAAC,OAAO,EAAE;QACrB,KAAK,OAAO,CAAC,IAAI;YACf,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,KAAK,CAAC,CAAC;YACpB,MAAM;QACR,KAAK,OAAO,CAAC,GAAG;YACd,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,KAAK,CAAC,CAAC;YACf,MAAM;QACR,KAAK,OAAO,CAAC,KAAK,CAAC;QACnB,KAAK,OAAO,CAAC,KAAK;YAChB,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,KAAK,CAAC,CAAC;YACpB,MAAM;QACR,KAAK,OAAO,CAAC,IAAI;YACf,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,KAAK,CAAC,CAAC;YAChB,MAAM;QACR,KAAK,OAAO,CAAC,IAAI;YACf,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,KAAK,CAAC,CAAC;YAC3E,MAAM;QACR,KAAK,OAAO,CAAC,QAAQ;YACnB,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,KAAK,CAAC,CAAC;YACpB,MAAM;QACR,KAAK,OAAO,CAAC,MAAM;YACjB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,KAAK,CAAC,CAAC;YAClB,MAAM;QACR,KAAK,OAAO,CAAC,KAAK;YAChB,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,KAAK,CAAC,CAAC;YAC3E,MAAM;QACR,KAAK,OAAO,CAAC,EAAE;YACb,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,KAAK,CAAC,CAAC;YACtB,MAAM;KACT;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\nimport { KeyCode } from '../keycode';\nimport { isRtl } from '../direction';\n\nexport default function handleKey(\n event: React.KeyboardEvent<HTMLElement>,\n {\n onActivate,\n onBlockEnd,\n onBlockStart,\n onEnd,\n onHome,\n onInlineEnd,\n onInlineStart,\n onPageDown,\n onPageUp,\n }: {\n onActivate?: (event: React.KeyboardEvent) => void;\n onBlockEnd?: (event: React.KeyboardEvent) => void;\n onBlockStart?: (event: React.KeyboardEvent) => void;\n onEnd?: (event: React.KeyboardEvent) => void;\n onHome?: (event: React.KeyboardEvent) => void;\n onInlineEnd?: (event: React.KeyboardEvent) => void;\n onInlineStart?: (event: React.KeyboardEvent) => void;\n onPageDown?: (event: React.KeyboardEvent) => void;\n onPageUp?: (event: React.KeyboardEvent) => void;\n }\n) {\n switch (event.keyCode) {\n case KeyCode.down:\n onBlockEnd?.(event);\n break;\n case KeyCode.end:\n onEnd?.(event);\n break;\n case KeyCode.enter:\n case KeyCode.space:\n onActivate?.(event);\n break;\n case KeyCode.home:\n onHome?.(event);\n break;\n case KeyCode.left:\n isRtl(event.currentTarget) ? onInlineEnd?.(event) : onInlineStart?.(event);\n break;\n case KeyCode.pageDown:\n onPageDown?.(event);\n break;\n case KeyCode.pageUp:\n onPageUp?.(event);\n break;\n case KeyCode.right:\n isRtl(event.currentTarget) ? onInlineStart?.(event) : onInlineEnd?.(event);\n break;\n case KeyCode.up:\n onBlockStart?.(event);\n break;\n }\n}\n"]}
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.600",
119
+ "version": "3.0.602",
120
120
  "repository": {
121
121
  "type": "git",
122
122
  "url": "https://github.com/cloudscape-design/components.git"
@@ -1 +1 @@
1
- {"version":3,"file":"internal-segmented-control.d.ts","sourceRoot":"","sources":["../../../src/segmented-control/internal-segmented-control.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAIrD,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC/C,UAAU,EACV,OAAO,EACP,KAAK,EACL,cAAc,EACd,QAAQ,GACT,EAAE,qBAAqB,eAmEvB"}
1
+ {"version":3,"file":"internal-segmented-control.d.ts","sourceRoot":"","sources":["../../../src/segmented-control/internal-segmented-control.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAIrD,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC/C,UAAU,EACV,OAAO,EACP,KAAK,EACL,cAAc,EACd,QAAQ,GACT,EAAE,qBAAqB,eAqEvB"}
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import React, { useRef } from 'react';
4
4
  import clsx from 'clsx';
5
+ import handleKey from '../internal/utils/handle-key';
5
6
  import { KeyCode } from '../internal/keycode';
6
7
  import { fireNonCancelableEvent } from '../internal/events';
7
8
  import { Segment } from './segment';
@@ -19,12 +20,10 @@ export default function InternalSegmentedControl({ selectedId, options, label, a
19
20
  return;
20
21
  }
21
22
  let nextIndex = activeIndex;
22
- if (event.keyCode === KeyCode.right) {
23
- nextIndex = activeIndex + 1 === enabledSegments.length ? 0 : activeIndex + 1;
24
- }
25
- else if (event.keyCode === KeyCode.left) {
26
- nextIndex = activeIndex === 0 ? enabledSegments.length - 1 : activeIndex - 1;
27
- }
23
+ handleKey(event, {
24
+ onInlineStart: () => (nextIndex = activeIndex === 0 ? enabledSegments.length - 1 : activeIndex - 1),
25
+ onInlineEnd: () => (nextIndex = activeIndex + 1 === enabledSegments.length ? 0 : activeIndex + 1),
26
+ });
28
27
  const nextSegmentId = enabledSegments[nextIndex].id;
29
28
  (_a = segmentByIdRef.current[nextSegmentId]) === null || _a === void 0 ? void 0 : _a.focus();
30
29
  };
@@ -1 +1 @@
1
- {"version":3,"file":"internal-segmented-control.js","sourceRoot":"","sources":["../../../src/segmented-control/internal-segmented-control.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI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IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,IAAI,CAAC,EAAE;oBACV,IAAI,IAAI,EAAE;wBACR,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;qBAC1C;yBAAM;wBACL,OAAO,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;qBAC1C;gBACH,CAAC,EACD,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,UAAU,KAAK,MAAM,CAAC,EAAE,EAAE;wBAC5B,sBAAsB,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;qBAC7D;gBACH,CAAC,EACD,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,mBAAmB,CAAC,GAC7D,CACH,CAAC;QACJ,CAAC,CAAC,CACA,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\nimport { KeyCode } from '../internal/keycode';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { SegmentedControlProps } from './interfaces';\nimport { Segment } from './segment';\nimport styles from './styles.css.js';\n\nexport default function InternalSegmentedControl({\n selectedId,\n options,\n label,\n ariaLabelledby,\n onChange,\n}: SegmentedControlProps) {\n const segmentByIdRef = useRef<{ [id: string]: HTMLButtonElement }>({});\n const selectedOptions = (options || []).filter(option => {\n return option.id === selectedId;\n });\n const currentSelectedOption = selectedOptions.length ? selectedOptions[0] : null;\n const enabledSegments = (options || []).filter(option => !option.disabled);\n\n const moveHighlight = (event: React.KeyboardEvent<HTMLButtonElement>, activeIndex: number) => {\n if (event.keyCode !== KeyCode.right && event.keyCode !== KeyCode.left) {\n return;\n }\n let nextIndex = activeIndex;\n if (event.keyCode === KeyCode.right) {\n nextIndex = activeIndex + 1 === enabledSegments.length ? 0 : activeIndex + 1;\n } else if (event.keyCode === KeyCode.left) {\n nextIndex = activeIndex === 0 ? enabledSegments.length - 1 : activeIndex - 1;\n }\n const nextSegmentId = enabledSegments[nextIndex].id;\n segmentByIdRef.current[nextSegmentId]?.focus();\n };\n\n return (\n <div\n className={clsx(styles['segment-part'], styles[`segment-count-${options?.length}`])}\n aria-label={label}\n aria-labelledby={ariaLabelledby}\n role=\"toolbar\"\n >\n {options &&\n options.map((option: SegmentedControlProps.Option, index) => {\n const isActive = selectedId === option.id;\n const enabledSegmentIndex = enabledSegments.indexOf(option);\n let tabIndex = isActive ? 0 : -1;\n if (currentSelectedOption === null && enabledSegmentIndex === 0) {\n tabIndex = 0;\n }\n return (\n <Segment\n key={index}\n id={option.id}\n disabled={!!option.disabled}\n iconName={option.iconName}\n iconAlt={option.iconAlt}\n iconUrl={option.iconUrl}\n iconSvg={option.iconSvg}\n text={option.text}\n isActive={isActive}\n tabIndex={tabIndex}\n ref={node => {\n if (node) {\n segmentByIdRef.current[option.id] = node;\n } else {\n delete segmentByIdRef.current[option.id];\n }\n }}\n onClick={() => {\n if (selectedId !== option.id) {\n fireNonCancelableEvent(onChange, { selectedId: option.id });\n }\n }}\n onKeyDown={event => moveHighlight(event, enabledSegmentIndex)}\n />\n );\n })}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"internal-segmented-control.js","sourceRoot":"","sources":["../../../src/segmented-control/internal-segmented-control.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAA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I,IAAI,EAAE;wBACR,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;qBAC1C;yBAAM;wBACL,OAAO,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;qBAC1C;gBACH,CAAC,EACD,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,UAAU,KAAK,MAAM,CAAC,EAAE,EAAE;wBAC5B,sBAAsB,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;qBAC7D;gBACH,CAAC,EACD,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,mBAAmB,CAAC,GAC7D,CACH,CAAC;QACJ,CAAC,CAAC,CACA,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\nimport handleKey from '../internal/utils/handle-key';\nimport { KeyCode } from '../internal/keycode';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { SegmentedControlProps } from './interfaces';\nimport { Segment } from './segment';\nimport styles from './styles.css.js';\n\nexport default function InternalSegmentedControl({\n selectedId,\n options,\n label,\n ariaLabelledby,\n onChange,\n}: SegmentedControlProps) {\n const segmentByIdRef = useRef<{ [id: string]: HTMLButtonElement }>({});\n const selectedOptions = (options || []).filter(option => {\n return option.id === selectedId;\n });\n const currentSelectedOption = selectedOptions.length ? selectedOptions[0] : null;\n const enabledSegments = (options || []).filter(option => !option.disabled);\n\n const moveHighlight = (event: React.KeyboardEvent<HTMLButtonElement>, activeIndex: number) => {\n if (event.keyCode !== KeyCode.right && event.keyCode !== KeyCode.left) {\n return;\n }\n\n let nextIndex = activeIndex;\n\n handleKey(event, {\n onInlineStart: () => (nextIndex = activeIndex === 0 ? enabledSegments.length - 1 : activeIndex - 1),\n onInlineEnd: () => (nextIndex = activeIndex + 1 === enabledSegments.length ? 0 : activeIndex + 1),\n });\n\n const nextSegmentId = enabledSegments[nextIndex].id;\n segmentByIdRef.current[nextSegmentId]?.focus();\n };\n\n return (\n <div\n className={clsx(styles['segment-part'], styles[`segment-count-${options?.length}`])}\n aria-label={label}\n aria-labelledby={ariaLabelledby}\n role=\"toolbar\"\n >\n {options &&\n options.map((option: SegmentedControlProps.Option, index) => {\n const isActive = selectedId === option.id;\n const enabledSegmentIndex = enabledSegments.indexOf(option);\n let tabIndex = isActive ? 0 : -1;\n if (currentSelectedOption === null && enabledSegmentIndex === 0) {\n tabIndex = 0;\n }\n return (\n <Segment\n key={index}\n id={option.id}\n disabled={!!option.disabled}\n iconName={option.iconName}\n iconAlt={option.iconAlt}\n iconUrl={option.iconUrl}\n iconSvg={option.iconSvg}\n text={option.text}\n isActive={isActive}\n tabIndex={tabIndex}\n ref={node => {\n if (node) {\n segmentByIdRef.current[option.id] = node;\n } else {\n delete segmentByIdRef.current[option.id];\n }\n }}\n onClick={() => {\n if (selectedId !== option.id) {\n fireNonCancelableEvent(onChange, { selectedId: option.id });\n }\n }}\n onKeyDown={event => moveHighlight(event, enabledSegmentIndex)}\n />\n );\n })}\n </div>\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;IACx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
49
49
  }
50
50
  }, [hasFocus, successfulEdit, prevHasFocus, prevSuccessfulEdit]);
51
51
  const { tabIndex: editActivateTabIndex } = useSingleTabStopNavigation(editActivateRef);
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
+ 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 => {
53
53
  setShowSuccessIcon(false);
54
54
  isFocusMoveNeededRef.current = options.refocusCell;
55
55
  onEditEnd(options.cancelled);
@@ -69,11 +69,14 @@ function TableCellEditable(_a) {
69
69
  export function TableBodyCell(_a) {
70
70
  var _b, _c;
71
71
  var { isEditable } = _a, rest = __rest(_a, ["isEditable"]);
72
+ const isExpandableColumnCell = rest.level !== undefined;
72
73
  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);
73
- if (editDisabledReason && !rest.expandableProps) {
74
+ // Inline editing is deactivated for expandable column because editable cells are interactive
75
+ // and cannot include interactive content such as expand toggles.
76
+ if (editDisabledReason && !isExpandableColumnCell) {
74
77
  return React.createElement(DisabledInlineEditor, Object.assign({ editDisabledReason: editDisabledReason }, rest));
75
78
  }
76
- if ((isEditable || rest.isEditing) && !rest.expandableProps) {
79
+ if ((isEditable || rest.isEditing) && !isExpandableColumnCell) {
77
80
  return React.createElement(TableCellEditable, Object.assign({}, rest));
78
81
  }
79
82
  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;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,E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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
+ {"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,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,eAAe,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IACxD,MAAM,kBAAkB,GAAG;QACzB,4BAA4B,EAAE,SAAS,CAAC,QAA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,OAAO,oBAAC,oBAAoB,kBAAC,kBAAkB,EAAE,kBAAkB,IAAM,IAAI,EAAI,CAAC;KACnF;IACD,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,sBAAsB,EAAE;QAC7D,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 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 isExpandableColumnCell = rest.level !== undefined;\n const editDisabledReason = rest.column.editConfig?.disabledReason?.(rest.item);\n\n // Inline editing is deactivated for expandable column because editable cells are interactive\n // and cannot include interactive content such as expand toggles.\n if (editDisabledReason && !isExpandableColumnCell) {\n return <DisabledInlineEditor editDisabledReason={editDisabledReason} {...rest} />;\n }\n if ((isEditable || rest.isEditing) && !isExpandableColumnCell) {\n return <TableCellEditable {...rest} />;\n }\n\n const { column, item } = rest;\n return <TableTdElement {...rest}>{column.cell(item)}</TableTdElement>;\n}\n"]}
@@ -1,47 +1,48 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "expandable-toggle-wrapper": "awsui_expandable-toggle-wrapper_c6tup_v6hb3_99",
5
- "body-cell": "awsui_body-cell_c6tup_v6hb3_107",
6
- "body-cell-expandable-level-1": "awsui_body-cell-expandable-level-1_c6tup_v6hb3_121",
7
- "body-cell-expandable-level-2": "awsui_body-cell-expandable-level-2_c6tup_v6hb3_124",
8
- "body-cell-expandable-level-3": "awsui_body-cell-expandable-level-3_c6tup_v6hb3_127",
9
- "body-cell-expandable-level-4": "awsui_body-cell-expandable-level-4_c6tup_v6hb3_130",
10
- "body-cell-expandable-level-5": "awsui_body-cell-expandable-level-5_c6tup_v6hb3_133",
11
- "body-cell-expandable-level-6": "awsui_body-cell-expandable-level-6_c6tup_v6hb3_136",
12
- "body-cell-expandable-level-7": "awsui_body-cell-expandable-level-7_c6tup_v6hb3_139",
13
- "body-cell-expandable-level-8": "awsui_body-cell-expandable-level-8_c6tup_v6hb3_142",
14
- "body-cell-expandable-level-9": "awsui_body-cell-expandable-level-9_c6tup_v6hb3_145",
15
- "body-cell-expandable-level-next": "awsui_body-cell-expandable-level-next_c6tup_v6hb3_148",
16
- "sticky-cell": "awsui_sticky-cell_c6tup_v6hb3_172",
17
- "body-cell-wrap": "awsui_body-cell-wrap_c6tup_v6hb3_175",
18
- "is-visual-refresh": "awsui_is-visual-refresh_c6tup_v6hb3_187",
19
- "has-striped-rows": "awsui_has-striped-rows_c6tup_v6hb3_199",
20
- "body-cell-edit-active": "awsui_body-cell-edit-active_c6tup_v6hb3_232",
21
- "body-cell-interactive": "awsui_body-cell-interactive_c6tup_v6hb3_232",
22
- "body-cell-editable": "awsui_body-cell-editable_c6tup_v6hb3_232",
23
- "has-striped-rows-sticky-cell-pad-left": "awsui_has-striped-rows-sticky-cell-pad-left_c6tup_v6hb3_298",
24
- "has-selection": "awsui_has-selection_c6tup_v6hb3_331",
25
- "body-cell-first-row": "awsui_body-cell-first-row_c6tup_v6hb3_367",
26
- "body-cell-last-row": "awsui_body-cell-last-row_c6tup_v6hb3_370",
27
- "body-cell-selected": "awsui_body-cell-selected_c6tup_v6hb3_370",
28
- "has-footer": "awsui_has-footer_c6tup_v6hb3_370",
29
- "body-cell-shaded": "awsui_body-cell-shaded_c6tup_v6hb3_380",
30
- "sticky-cell-pad-left": "awsui_sticky-cell-pad-left_c6tup_v6hb3_414",
31
- "sticky-cell-last-right": "awsui_sticky-cell-last-right_c6tup_v6hb3_461",
32
- "sticky-cell-last-left": "awsui_sticky-cell-last-left_c6tup_v6hb3_465",
33
- "body-cell-next-selected": "awsui_body-cell-next-selected_c6tup_v6hb3_488",
34
- "body-cell-prev-selected": "awsui_body-cell-prev-selected_c6tup_v6hb3_492",
35
- "body-cell-editor-wrapper": "awsui_body-cell-editor-wrapper_c6tup_v6hb3_516",
36
- "body-cell-success": "awsui_body-cell-success_c6tup_v6hb3_523",
37
- "body-cell-editor": "awsui_body-cell-editor_c6tup_v6hb3_516",
38
- "body-cell-editor-disabled": "awsui_body-cell-editor-disabled_c6tup_v6hb3_550",
39
- "body-cell-editor-form": "awsui_body-cell-editor-form_c6tup_v6hb3_559",
40
- "body-cell-editor-row": "awsui_body-cell-editor-row_c6tup_v6hb3_569",
41
- "body-cell-editor-controls": "awsui_body-cell-editor-controls_c6tup_v6hb3_579",
42
- "body-cell-expandable": "awsui_body-cell-expandable_c6tup_v6hb3_121",
43
- "expandable-cell-content": "awsui_expandable-cell-content_c6tup_v6hb3_603",
44
- "body-cell-edit-disabled-popover": "awsui_body-cell-edit-disabled-popover_c6tup_v6hb3_651",
45
- "body-cell-has-success": "awsui_body-cell-has-success_c6tup_v6hb3_655"
4
+ "expandable-toggle-wrapper": "awsui_expandable-toggle-wrapper_c6tup_1ls9v_99",
5
+ "body-cell": "awsui_body-cell_c6tup_1ls9v_107",
6
+ "body-cell-content": "awsui_body-cell-content_c6tup_1ls9v_121",
7
+ "body-cell-wrap": "awsui_body-cell-wrap_c6tup_1ls9v_124",
8
+ "is-visual-refresh": "awsui_is-visual-refresh_c6tup_1ls9v_136",
9
+ "has-striped-rows": "awsui_has-striped-rows_c6tup_1ls9v_148",
10
+ "body-cell-expandable-level-1": "awsui_body-cell-expandable-level-1_c6tup_1ls9v_151",
11
+ "body-cell-expandable-level-2": "awsui_body-cell-expandable-level-2_c6tup_1ls9v_154",
12
+ "body-cell-expandable-level-3": "awsui_body-cell-expandable-level-3_c6tup_1ls9v_157",
13
+ "body-cell-expandable-level-4": "awsui_body-cell-expandable-level-4_c6tup_1ls9v_160",
14
+ "body-cell-expandable-level-5": "awsui_body-cell-expandable-level-5_c6tup_1ls9v_163",
15
+ "body-cell-expandable-level-6": "awsui_body-cell-expandable-level-6_c6tup_1ls9v_166",
16
+ "body-cell-expandable-level-7": "awsui_body-cell-expandable-level-7_c6tup_1ls9v_169",
17
+ "body-cell-expandable-level-8": "awsui_body-cell-expandable-level-8_c6tup_1ls9v_172",
18
+ "body-cell-expandable-level-9": "awsui_body-cell-expandable-level-9_c6tup_1ls9v_175",
19
+ "body-cell-expandable-level-next": "awsui_body-cell-expandable-level-next_c6tup_1ls9v_178",
20
+ "body-cell-edit-active": "awsui_body-cell-edit-active_c6tup_1ls9v_181",
21
+ "body-cell-interactive": "awsui_body-cell-interactive_c6tup_1ls9v_181",
22
+ "body-cell-editable": "awsui_body-cell-editable_c6tup_1ls9v_181",
23
+ "has-striped-rows-sticky-cell-pad-left": "awsui_has-striped-rows-sticky-cell-pad-left_c6tup_1ls9v_247",
24
+ "has-selection": "awsui_has-selection_c6tup_1ls9v_280",
25
+ "body-cell-first-row": "awsui_body-cell-first-row_c6tup_1ls9v_316",
26
+ "body-cell-last-row": "awsui_body-cell-last-row_c6tup_1ls9v_319",
27
+ "body-cell-selected": "awsui_body-cell-selected_c6tup_1ls9v_319",
28
+ "has-footer": "awsui_has-footer_c6tup_1ls9v_319",
29
+ "body-cell-shaded": "awsui_body-cell-shaded_c6tup_1ls9v_329",
30
+ "sticky-cell": "awsui_sticky-cell_c6tup_1ls9v_355",
31
+ "sticky-cell-pad-left": "awsui_sticky-cell-pad-left_c6tup_1ls9v_363",
32
+ "sticky-cell-last-right": "awsui_sticky-cell-last-right_c6tup_1ls9v_410",
33
+ "sticky-cell-last-left": "awsui_sticky-cell-last-left_c6tup_1ls9v_414",
34
+ "body-cell-next-selected": "awsui_body-cell-next-selected_c6tup_1ls9v_437",
35
+ "body-cell-prev-selected": "awsui_body-cell-prev-selected_c6tup_1ls9v_441",
36
+ "body-cell-editor-wrapper": "awsui_body-cell-editor-wrapper_c6tup_1ls9v_465",
37
+ "body-cell-success": "awsui_body-cell-success_c6tup_1ls9v_472",
38
+ "body-cell-editor": "awsui_body-cell-editor_c6tup_1ls9v_465",
39
+ "body-cell-editor-disabled": "awsui_body-cell-editor-disabled_c6tup_1ls9v_499",
40
+ "body-cell-editor-form": "awsui_body-cell-editor-form_c6tup_1ls9v_508",
41
+ "body-cell-editor-row": "awsui_body-cell-editor-row_c6tup_1ls9v_518",
42
+ "body-cell-editor-controls": "awsui_body-cell-editor-controls_c6tup_1ls9v_528",
43
+ "body-cell-expandable": "awsui_body-cell-expandable_c6tup_1ls9v_151",
44
+ "expandable-cell-content": "awsui_expandable-cell-content_c6tup_1ls9v_552",
45
+ "body-cell-edit-disabled-popover": "awsui_body-cell-edit-disabled-popover_c6tup_1ls9v_600",
46
+ "body-cell-has-success": "awsui_body-cell-has-success_c6tup_1ls9v_604"
46
47
  };
47
48