@cloudscape-design/components 3.0.347 → 3.0.348

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 (62) hide show
  1. package/button-dropdown/interfaces.d.ts +2 -15
  2. package/button-dropdown/interfaces.d.ts.map +1 -1
  3. package/button-dropdown/interfaces.js.map +1 -1
  4. package/i18n/index.d.ts +1 -1
  5. package/i18n/index.d.ts.map +1 -1
  6. package/i18n/index.js +1 -1
  7. package/i18n/index.js.map +1 -1
  8. package/i18n/provider.d.ts.map +1 -1
  9. package/i18n/provider.js +4 -2
  10. package/i18n/provider.js.map +1 -1
  11. package/i18n/testing.d.ts.map +1 -1
  12. package/i18n/testing.js +2 -0
  13. package/i18n/testing.js.map +1 -1
  14. package/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
  15. package/internal/analytics/components/analytics-funnel.js +50 -1
  16. package/internal/analytics/components/analytics-funnel.js.map +1 -1
  17. package/internal/analytics/context/analytics-context.d.ts +13 -0
  18. package/internal/analytics/context/analytics-context.d.ts.map +1 -1
  19. package/internal/analytics/context/analytics-context.js +4 -0
  20. package/internal/analytics/context/analytics-context.js.map +1 -1
  21. package/internal/analytics/hooks/use-funnel.d.ts +4 -0
  22. package/internal/analytics/hooks/use-funnel.d.ts.map +1 -1
  23. package/internal/analytics/hooks/use-funnel.js +73 -20
  24. package/internal/analytics/hooks/use-funnel.js.map +1 -1
  25. package/internal/components/dropdown/interfaces.d.ts +8 -5
  26. package/internal/components/dropdown/interfaces.d.ts.map +1 -1
  27. package/internal/components/dropdown/interfaces.js.map +1 -1
  28. package/internal/environment.js +1 -1
  29. package/internal/environment.json +1 -1
  30. package/internal/manifest.json +1 -1
  31. package/package.json +1 -1
  32. package/table/body-cell/td-element.d.ts +3 -1
  33. package/table/body-cell/td-element.d.ts.map +1 -1
  34. package/table/body-cell/td-element.js +5 -7
  35. package/table/body-cell/td-element.js.map +1 -1
  36. package/table/header-cell/index.d.ts +2 -0
  37. package/table/header-cell/index.d.ts.map +1 -1
  38. package/table/header-cell/index.js +4 -3
  39. package/table/header-cell/index.js.map +1 -1
  40. package/table/header-cell/utils.d.ts +0 -1
  41. package/table/header-cell/utils.d.ts.map +1 -1
  42. package/table/header-cell/utils.js +0 -6
  43. package/table/header-cell/utils.js.map +1 -1
  44. package/table/internal.d.ts.map +1 -1
  45. package/table/internal.js +9 -8
  46. package/table/internal.js.map +1 -1
  47. package/table/sticky-header.d.ts +2 -0
  48. package/table/sticky-header.d.ts.map +1 -1
  49. package/table/sticky-header.js +3 -2
  50. package/table/sticky-header.js.map +1 -1
  51. package/table/table-role/index.d.ts +2 -0
  52. package/table/table-role/index.d.ts.map +1 -0
  53. package/table/table-role/index.js +4 -0
  54. package/table/table-role/index.js.map +1 -0
  55. package/table/table-role/table-role-helper.d.ts +22 -0
  56. package/table/table-role/table-role-helper.d.ts.map +1 -0
  57. package/table/table-role/table-role-helper.js +47 -0
  58. package/table/table-role/table-role-helper.js.map +1 -0
  59. package/table/thead.d.ts +2 -0
  60. package/table/thead.d.ts.map +1 -1
  61. package/table/thead.js +4 -3
  62. package/table/thead.js.map +1 -1
@@ -1,8 +1,9 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+ import { __awaiter } from "tslib";
3
4
  import { useContext } from 'react';
4
5
  import { FunnelContext, FunnelStepContext, FunnelSubStepContext } from '../context/analytics-context';
5
- import { DATA_ATTR_FUNNEL_INTERACTION_ID, DATA_ATTR_FUNNEL_SUBSTEP, getSubStepAllSelector } from '../selectors';
6
+ import { DATA_ATTR_FUNNEL_INTERACTION_ID, DATA_ATTR_FUNNEL_SUBSTEP, getNameFromSelector, getSubStepAllSelector, } from '../selectors';
6
7
  import { FunnelMetrics } from '../';
7
8
  /**
8
9
  * Custom React Hook to manage and interact with FunnelSubStep.
@@ -16,39 +17,91 @@ import { FunnelMetrics } from '../';
16
17
  */
17
18
  export const useFunnelSubStep = () => {
18
19
  const context = useContext(FunnelSubStepContext);
19
- const { funnelInteractionId, funnelState } = useFunnel();
20
+ const { funnelInteractionId, funnelState, latestFocusCleanupFunction } = useFunnel();
20
21
  const { stepNumber, stepNameSelector } = useFunnelStep();
21
- const { subStepId, subStepSelector, subStepNameSelector, subStepRef, isNestedSubStep } = context;
22
+ const { subStepId, subStepSelector, subStepNameSelector, subStepRef, isNestedSubStep, mousePressed, isFocusedSubStep, focusCleanupFunction, } = context;
22
23
  if (isNestedSubStep) {
23
24
  return context;
24
25
  }
25
- const onFocus = (event) => {
26
- if (funnelInteractionId &&
27
- subStepRef.current &&
28
- (!event.relatedTarget || !subStepRef.current.contains(event.relatedTarget))) {
26
+ const onFocus = (event) => __awaiter(void 0, void 0, void 0, function* () {
27
+ var _a;
28
+ const element = event.target;
29
+ // Ignore spurious focus events, such as when the browser window is focused again.
30
+ yield new Promise(r => setTimeout(r, 1));
31
+ if (document.activeElement !== element) {
32
+ return;
33
+ }
34
+ if (isFocusedSubStep.current) {
35
+ return;
36
+ }
37
+ isFocusedSubStep.current = true;
38
+ if (funnelInteractionId && subStepId) {
39
+ /*
40
+ If the previously focused substep has provided a cleanup function, we
41
+ call it here on behalf of the previously focused substep.
42
+ */
43
+ (_a = latestFocusCleanupFunction.current) === null || _a === void 0 ? void 0 : _a.call(latestFocusCleanupFunction);
29
44
  FunnelMetrics.funnelSubStepStart({
30
45
  funnelInteractionId,
31
46
  subStepSelector,
32
47
  subStepNameSelector,
48
+ subStepName: getNameFromSelector(subStepNameSelector),
33
49
  stepNumber,
34
50
  stepNameSelector,
35
51
  subStepAllSelector: getSubStepAllSelector(),
36
52
  });
53
+ /*
54
+ This cleanup function will be called when the user leaves this substep.
55
+ The function might be called either:
56
+
57
+ - by the next focused substep as `latestFocusCleanupFunction`
58
+ (through a separate instance of the function we're currently in), or
59
+
60
+ - by the same substep as `focusCleanupFunction`
61
+ (through the `onMouseUp` handler or the `onBlur` handler).
62
+ */
63
+ let cleanupFunctionHasBeenRun = false;
64
+ focusCleanupFunction.current = () => {
65
+ if (cleanupFunctionHasBeenRun) {
66
+ return;
67
+ }
68
+ cleanupFunctionHasBeenRun = true;
69
+ if (funnelState.current !== 'cancelled') {
70
+ FunnelMetrics.funnelSubStepComplete({
71
+ funnelInteractionId,
72
+ subStepSelector,
73
+ subStepNameSelector,
74
+ subStepName: getNameFromSelector(subStepNameSelector),
75
+ stepNumber,
76
+ stepNameSelector,
77
+ subStepAllSelector: getSubStepAllSelector(),
78
+ });
79
+ }
80
+ };
81
+ latestFocusCleanupFunction.current = focusCleanupFunction.current;
37
82
  }
38
- };
83
+ });
39
84
  const onBlur = (event) => {
40
- if (funnelInteractionId &&
41
- subStepRef.current &&
42
- !subStepRef.current.contains(event.relatedTarget) &&
43
- funnelState.current !== 'cancelled') {
44
- FunnelMetrics.funnelSubStepComplete({
45
- funnelInteractionId,
46
- subStepSelector,
47
- subStepNameSelector,
48
- stepNumber,
49
- stepNameSelector,
50
- subStepAllSelector: getSubStepAllSelector(),
51
- });
85
+ var _a;
86
+ if (mousePressed.current) {
87
+ /*
88
+ Ignore blur events that are caused by mouse interaction, because these events don't
89
+ always reflect user intention. For example, clicking the label of an interactive form
90
+ element will briefly blur it.
91
+ The mouse-caused events are handled in the global `onMouseUp` handler of the substep
92
+ context instead.
93
+ */
94
+ return;
95
+ }
96
+ if (!subStepRef.current || !subStepRef.current.contains(event.relatedTarget) || !event.relatedTarget) {
97
+ isFocusedSubStep.current = false;
98
+ if (funnelInteractionId && subStepId && funnelState.current !== 'cancelled') {
99
+ /*
100
+ Run this substep's own focus cleanup function if another substep
101
+ hasn't already done it for us.
102
+ */
103
+ (_a = focusCleanupFunction.current) === null || _a === void 0 ? void 0 : _a.call(focusCleanupFunction);
104
+ }
52
105
  }
53
106
  };
54
107
  const funnelSubStepProps = funnelInteractionId
@@ -1 +1 @@
1
- {"version":3,"file":"use-funnel.js","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names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AO,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC;YACjD,WAAW,CAAC,OAAO,KAAK,WAAW,EACnC;YACA,aAAa,CAAC,qBAAqB,CAAC;gBAClC,mBAAmB;gBACnB,eAAe;gBACf,mBAAmB;gBACnB,UAAU;gBACV,gBAAgB;gBAChB,kBAAkB,EAAE,qBAAqB,EAAE;aAC5C,CAAC,CAAC;SACJ;IACH,CAAC,CAAC;IAEF,MAAM,kBAAkB,GAAwB,mBAAmB;QACjE,CAAC,CAAC;YACE,CAAC,wBAAwB,CAAC,EAAE,SAAS;YACrC,OAAO;YACP,MAAM;SACP;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,uBAAS,kBAAkB,IAAK,OAAO,EAAG;AAC5C,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC1C,MAAM,WAAW,GAA0D,OAAO,CAAC,mBAAmB;QACpG,CAAC,CAAC;YACE,CAAC,+BAA+B,CAAC,EAAE,OAAO,CAAC,mBAAmB;SAC/D;QACH,CAAC,CAAC,EAAE,CAAC;IAEP,uBAAS,WAAW,IAAK,OAAO,EAAG;AACrC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useContext } from 'react';\nimport { FunnelContext, FunnelStepContext, FunnelSubStepContext } from '../context/analytics-context';\nimport { DATA_ATTR_FUNNEL_INTERACTION_ID, DATA_ATTR_FUNNEL_SUBSTEP, getSubStepAllSelector } from '../selectors';\nimport { FunnelMetrics } from '../';\n\n/**\n * Custom React Hook to manage and interact with FunnelSubStep.\n * This hook will provide necessary properties and methods required\n * to track and manage interactions with a FunnelSubStep component.\n *\n * The `onFocus` method is used to track the beginning of interaction with the FunnelSubStep.\n * The `onBlur` method is used to track the completion of interaction with the FunnelSubStep.\n * The subStepId is a unique identifier for the funnel sub-step.\n * The subStepRef is a reference to the DOM element of the funnel sub-step.\n */\nexport const useFunnelSubStep = () => {\n const context = useContext(FunnelSubStepContext);\n const { funnelInteractionId, funnelState } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n\n const { subStepId, subStepSelector, subStepNameSelector, subStepRef, isNestedSubStep } = context;\n\n if (isNestedSubStep) {\n return context;\n }\n\n const onFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n if (\n funnelInteractionId &&\n subStepRef.current &&\n (!event.relatedTarget || !subStepRef.current.contains(event.relatedTarget as Node))\n ) {\n FunnelMetrics.funnelSubStepStart({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n\n const onBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (\n funnelInteractionId &&\n subStepRef.current &&\n !subStepRef.current.contains(event.relatedTarget) &&\n funnelState.current !== 'cancelled'\n ) {\n FunnelMetrics.funnelSubStepComplete({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n\n const funnelSubStepProps: Record<string, any> = funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_SUBSTEP]: subStepId,\n onFocus,\n onBlur,\n }\n : {};\n\n return { funnelSubStepProps, ...context };\n};\n\n/**\n * Custom React Hook to manage and interact with FunnelStep.\n * This hook will provide necessary properties required to track\n * and manage interactions with a FunnelStep component.\n *\n * The 'data-analytics-funnel-step' property of funnelStepProps is used to track the index of the current step in the funnel.\n * The context contains additional properties of the FunnelStep.\n */\nexport const useFunnelStep = () => {\n const context = useContext(FunnelStepContext);\n return context;\n};\n\n/**\n * Custom React Hook to manage and interact with Funnel.\n * This hook will provide necessary properties required to track\n * and manage interactions with a Funnel component.\n *\n * The 'data-analytics-funnel-interaction-id' property of funnelProps is used to track the unique identifier of the current interaction with the funnel.\n */\nexport const useFunnel = () => {\n const context = useContext(FunnelContext);\n const funnelProps: Record<string, string | number | boolean | undefined> = context.funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_INTERACTION_ID]: context.funnelInteractionId,\n }\n : {};\n\n return { funnelProps, ...context };\n};\n"]}
1
+ {"version":3,"file":"use-funnel.js","sourceRoot":"lib/default/","sources":["internal/analytics/hooks/use-funnel.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACjD,MAAM,EAAE,mBAAmB,EAAE,WAAW,EAAE,0BAA0B,EAAE,GAAG,SAAS,EAAE,CAAC;IACrF,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,aAAa,EAAE,CAAC;IAEzD,MAAM,EACJ,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,GACrB,GAAG,OAAO,CAAC;IAEZ,IAAI,eAAe,EAAE;QACnB,OAAO,OAAO,CAAC;KAChB;IAED,MAAM,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X-License-Identifier: Apache-2.0\n\nimport { useContext } from 'react';\nimport { FunnelContext, FunnelStepContext, FunnelSubStepContext } from '../context/analytics-context';\nimport {\n DATA_ATTR_FUNNEL_INTERACTION_ID,\n DATA_ATTR_FUNNEL_SUBSTEP,\n getNameFromSelector,\n getSubStepAllSelector,\n} from '../selectors';\nimport { FunnelMetrics } from '../';\n\n/**\n * Custom React Hook to manage and interact with FunnelSubStep.\n * This hook will provide necessary properties and methods required\n * to track and manage interactions with a FunnelSubStep component.\n *\n * The `onFocus` method is used to track the beginning of interaction with the FunnelSubStep.\n * The `onBlur` method is used to track the completion of interaction with the FunnelSubStep.\n * The subStepId is a unique identifier for the funnel sub-step.\n * The subStepRef is a reference to the DOM element of the funnel sub-step.\n */\nexport const useFunnelSubStep = () => {\n const context = useContext(FunnelSubStepContext);\n const { funnelInteractionId, funnelState, latestFocusCleanupFunction } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n\n const {\n subStepId,\n subStepSelector,\n subStepNameSelector,\n subStepRef,\n isNestedSubStep,\n mousePressed,\n isFocusedSubStep,\n focusCleanupFunction,\n } = context;\n\n if (isNestedSubStep) {\n return context;\n }\n\n const onFocus = async (event: React.FocusEvent<HTMLDivElement>) => {\n const element = event.target;\n // Ignore spurious focus events, such as when the browser window is focused again.\n await new Promise(r => setTimeout(r, 1));\n if (document.activeElement !== element) {\n return;\n }\n\n if (isFocusedSubStep.current) {\n return;\n }\n isFocusedSubStep.current = true;\n\n if (funnelInteractionId && subStepId) {\n /*\n If the previously focused substep has provided a cleanup function, we\n call it here on behalf of the previously focused substep.\n */\n latestFocusCleanupFunction.current?.();\n\n FunnelMetrics.funnelSubStepStart({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n subStepName: getNameFromSelector(subStepNameSelector),\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n\n /*\n This cleanup function will be called when the user leaves this substep.\n The function might be called either:\n\n - by the next focused substep as `latestFocusCleanupFunction`\n (through a separate instance of the function we're currently in), or\n\n - by the same substep as `focusCleanupFunction`\n (through the `onMouseUp` handler or the `onBlur` handler).\n */\n let cleanupFunctionHasBeenRun = false;\n focusCleanupFunction.current = () => {\n if (cleanupFunctionHasBeenRun) {\n return;\n }\n cleanupFunctionHasBeenRun = true;\n\n if (funnelState.current !== 'cancelled') {\n FunnelMetrics.funnelSubStepComplete({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n subStepName: getNameFromSelector(subStepNameSelector),\n stepNumber,\n stepNameSelector,\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n };\n latestFocusCleanupFunction.current = focusCleanupFunction.current;\n }\n };\n\n const onBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (mousePressed.current) {\n /*\n Ignore blur events that are caused by mouse interaction, because these events don't\n always reflect user intention. For example, clicking the label of an interactive form\n element will briefly blur it.\n The mouse-caused events are handled in the global `onMouseUp` handler of the substep\n context instead.\n */\n return;\n }\n\n if (!subStepRef.current || !subStepRef.current.contains(event.relatedTarget) || !event.relatedTarget) {\n isFocusedSubStep.current = false;\n\n if (funnelInteractionId && subStepId && funnelState.current !== 'cancelled') {\n /*\n Run this substep's own focus cleanup function if another substep\n hasn't already done it for us.\n */\n focusCleanupFunction.current?.();\n }\n }\n };\n\n const funnelSubStepProps: Record<string, any> = funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_SUBSTEP]: subStepId,\n onFocus,\n onBlur,\n }\n : {};\n\n return { funnelSubStepProps, ...context };\n};\n\n/**\n * Custom React Hook to manage and interact with FunnelStep.\n * This hook will provide necessary properties required to track\n * and manage interactions with a FunnelStep component.\n *\n * The 'data-analytics-funnel-step' property of funnelStepProps is used to track the index of the current step in the funnel.\n * The context contains additional properties of the FunnelStep.\n */\nexport const useFunnelStep = () => {\n const context = useContext(FunnelStepContext);\n return context;\n};\n\n/**\n * Custom React Hook to manage and interact with Funnel.\n * This hook will provide necessary properties required to track\n * and manage interactions with a Funnel component.\n *\n * The 'data-analytics-funnel-interaction-id' property of funnelProps is used to track the unique identifier of the current interaction with the funnel.\n */\nexport const useFunnel = () => {\n const context = useContext(FunnelContext);\n const funnelProps: Record<string, string | number | boolean | undefined> = context.funnelInteractionId\n ? {\n [DATA_ATTR_FUNNEL_INTERACTION_ID]: context.funnelInteractionId,\n }\n : {};\n\n return { funnelProps, ...context };\n};\n"]}
@@ -138,12 +138,15 @@ export interface DropdownProps extends ExpandToViewport {
138
138
  }
139
139
  export interface ExpandToViewport {
140
140
  /**
141
- * Enabling this property will allow the dropdown to extend beyond its parent by using fixed positioning and
141
+ * By default, the dropdown height is constrained to fit inside the height of its next scrollable container element.
142
+ * Enabling this property will allow the dropdown to extend beyond that container by using fixed positioning and
142
143
  * [React Portals](https://reactjs.org/docs/portals.html).
143
- * If you want the dropdown to ignore the `overflow` CSS property of its parents,
144
- * such as in a split view layout, enable this property.
145
- * However, use discretion. If you don't need to, we recommend you don't enable this property because fixed positioning results
146
- * in a slight, visible lag when scrolling complex pages.
144
+ *
145
+ * Set this property if the dropdown would otherwise be constrained by a scrollable container,
146
+ * for example inside table and split view layouts.
147
+ *
148
+ * However, use discretion. We recommend you don't enable this property unless necessary
149
+ * because fixed positioning results in a slight, visible lag when scrolling complex pages.
147
150
  */
148
151
  expandToViewport?: boolean;
149
152
  }
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["internal/components/dropdown/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAC9D,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,qBAAsB,SAAQ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C,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["internal/components/dropdown/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { NonCancelableEventHandler } from '../../events';\nimport React from 'react';\n\nexport type OptionsFilteringType = 'none' | 'auto' | 'manual';\nexport interface OptionsLoadItemsDetail {\n filteringText: string;\n firstPage: boolean;\n samePage: boolean;\n}\n\nexport interface BaseDropdownHostProps extends ExpandToViewport {\n /**\n * If you have more than 500 options, enable this flag to apply a performance optimization\n * that makes the filtering experience smoother. We don't recommend enabling the feature if you\n * have less than 500 options, because the improvements to performance are offset by a\n * visible scrolling lag.\n *\n * When you set this flag to `true`, it removes options that are not currently in view from the DOM.\n * If your test accesses such options, you need to first scroll the options container\n * to the correct offset, before performing any operations on them. Use the element returned\n * by the `findOptionsContainer` test utility for this.\n */\n virtualScroll?: boolean;\n\n /**\n * Use this event to implement the asynchronous behavior for the component.\n *\n * The event is called in the following situations:\n * * The user scrolls to the end of the list of options, if `statusType` is set to `pending`.\n * * The user clicks on the recovery button in the error state.\n * * The user types inside the input field.\n * * The user focuses the input field.\n *\n * The detail object contains the following properties:\n * * `filteringText` - The value that you need to use to fetch options.\n * * `firstPage` - Indicates that you should fetch the first page of options that match the `filteringText`.\n * * `samePage` - Indicates that you should fetch the same page that you have previously fetched (for example, when the user clicks on the recovery button).\n **/\n onLoadItems?: NonCancelableEventHandler<OptionsLoadItemsDetail>;\n}\n\nexport interface DropdownProps extends ExpandToViewport {\n /**\n * Trigger element.\n */\n trigger: React.ReactNode;\n /**\n * \"Sticky\" header of the dropdown content\n */\n header?: React.ReactNode;\n /**\n * Footer slot fixed at the bottom of the dropdown\n */\n footer?: React.ReactNode;\n /**\n * Dropdown content elements.\n */\n children?: React.ReactNode;\n /**\n * Updating content key triggers dropdown position re-evaluation.\n */\n contentKey?: string;\n /**\n * Open state of the dropdown.\n */\n open?: boolean;\n /**\n * Called when a user clicks outside of the dropdown content, when it is open.\n */\n onDropdownClose?: NonCancelableEventHandler<null>;\n /**\n * Called when a mouse button is pressed inside the dropdown content.\n */\n onMouseDown?: React.MouseEventHandler;\n /**\n * Dropdown id\n */\n dropdownId?: string;\n /**\n * Stretches dropdown to occupy entire width.\n */\n stretchWidth?: boolean;\n /**\n * Stretches dropdown to occupy entire height.\n */\n stretchHeight?: boolean;\n\n /**\n * Stretches the trigger to the height of the dropdown container.\n */\n stretchTriggerHeight?: boolean;\n\n /**\n * Whether the dropdown content should be at least as wide as the trigger.\n *\n * @defaultValue true\n */\n stretchToTriggerWidth?: boolean;\n\n /**\n * Determines that the dropdown should preferably be aligned to the center of the trigger\n * instead of dropping left or right.\n */\n preferCenter?: boolean;\n\n /**\n * Indicates if this dropdown lies within a parent dropdown and positions itself relative to it (as a fly out).\n */\n interior?: boolean;\n /**\n * Sets the min width of the dropdown (in px)\n */\n minWidth?: number;\n /**\n * Whether the dropdown will have a scrollbar or not\n */\n scrollable?: boolean;\n\n /**\n * Whether the dropdown will have a focus loop including trigger, header, content and footer.\n */\n loopFocus?: boolean;\n\n /**\n * Called when focus enters the trigger or dropdown content.\n */\n onFocus?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n\n /**\n * Called when focus leaves the trigger or dropdown content.\n */\n onBlur?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n\n /**\n * ID for the dropdown content wrapper\n */\n dropdownContentId?: string;\n /**\n * HTML role for the dropdown content wrapper\n */\n dropdownContentRole?: string;\n /**\n * Labelledby for the dropdown (required when role=\"dialog\")\n */\n ariaLabelledby?: string;\n /**\n * Describedby for the dropdown (recommended when role=\"dialog\")\n */\n ariaDescribedby?: string;\n}\n\nexport interface ExpandToViewport {\n /**\n * Enabling this property will allow the dropdown to extend beyond its parent by using fixed positioning and\n * [React Portals](https://reactjs.org/docs/portals.html).\n * If you want the dropdown to ignore the `overflow` CSS property of its parents,\n * such as in a split view layout, enable this property.\n * However, use discretion. If you don't need to, we recommend you don't enable this property because fixed positioning results\n * in a slight, visible lag when scrolling complex pages.\n */\n expandToViewport?: boolean;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["internal/components/dropdown/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { NonCancelableEventHandler } from '../../events';\nimport React from 'react';\n\nexport type OptionsFilteringType = 'none' | 'auto' | 'manual';\nexport interface OptionsLoadItemsDetail {\n filteringText: string;\n firstPage: boolean;\n samePage: boolean;\n}\n\nexport interface BaseDropdownHostProps extends ExpandToViewport {\n /**\n * If you have more than 500 options, enable this flag to apply a performance optimization\n * that makes the filtering experience smoother. We don't recommend enabling the feature if you\n * have less than 500 options, because the improvements to performance are offset by a\n * visible scrolling lag.\n *\n * When you set this flag to `true`, it removes options that are not currently in view from the DOM.\n * If your test accesses such options, you need to first scroll the options container\n * to the correct offset, before performing any operations on them. Use the element returned\n * by the `findOptionsContainer` test utility for this.\n */\n virtualScroll?: boolean;\n\n /**\n * Use this event to implement the asynchronous behavior for the component.\n *\n * The event is called in the following situations:\n * * The user scrolls to the end of the list of options, if `statusType` is set to `pending`.\n * * The user clicks on the recovery button in the error state.\n * * The user types inside the input field.\n * * The user focuses the input field.\n *\n * The detail object contains the following properties:\n * * `filteringText` - The value that you need to use to fetch options.\n * * `firstPage` - Indicates that you should fetch the first page of options that match the `filteringText`.\n * * `samePage` - Indicates that you should fetch the same page that you have previously fetched (for example, when the user clicks on the recovery button).\n **/\n onLoadItems?: NonCancelableEventHandler<OptionsLoadItemsDetail>;\n}\n\nexport interface DropdownProps extends ExpandToViewport {\n /**\n * Trigger element.\n */\n trigger: React.ReactNode;\n /**\n * \"Sticky\" header of the dropdown content\n */\n header?: React.ReactNode;\n /**\n * Footer slot fixed at the bottom of the dropdown\n */\n footer?: React.ReactNode;\n /**\n * Dropdown content elements.\n */\n children?: React.ReactNode;\n /**\n * Updating content key triggers dropdown position re-evaluation.\n */\n contentKey?: string;\n /**\n * Open state of the dropdown.\n */\n open?: boolean;\n /**\n * Called when a user clicks outside of the dropdown content, when it is open.\n */\n onDropdownClose?: NonCancelableEventHandler<null>;\n /**\n * Called when a mouse button is pressed inside the dropdown content.\n */\n onMouseDown?: React.MouseEventHandler;\n /**\n * Dropdown id\n */\n dropdownId?: string;\n /**\n * Stretches dropdown to occupy entire width.\n */\n stretchWidth?: boolean;\n /**\n * Stretches dropdown to occupy entire height.\n */\n stretchHeight?: boolean;\n\n /**\n * Stretches the trigger to the height of the dropdown container.\n */\n stretchTriggerHeight?: boolean;\n\n /**\n * Whether the dropdown content should be at least as wide as the trigger.\n *\n * @defaultValue true\n */\n stretchToTriggerWidth?: boolean;\n\n /**\n * Determines that the dropdown should preferably be aligned to the center of the trigger\n * instead of dropping left or right.\n */\n preferCenter?: boolean;\n\n /**\n * Indicates if this dropdown lies within a parent dropdown and positions itself relative to it (as a fly out).\n */\n interior?: boolean;\n /**\n * Sets the min width of the dropdown (in px)\n */\n minWidth?: number;\n /**\n * Whether the dropdown will have a scrollbar or not\n */\n scrollable?: boolean;\n\n /**\n * Whether the dropdown will have a focus loop including trigger, header, content and footer.\n */\n loopFocus?: boolean;\n\n /**\n * Called when focus enters the trigger or dropdown content.\n */\n onFocus?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n\n /**\n * Called when focus leaves the trigger or dropdown content.\n */\n onBlur?: NonCancelableEventHandler<Pick<React.FocusEvent, 'target' | 'relatedTarget'>>;\n\n /**\n * ID for the dropdown content wrapper\n */\n dropdownContentId?: string;\n /**\n * HTML role for the dropdown content wrapper\n */\n dropdownContentRole?: string;\n /**\n * Labelledby for the dropdown (required when role=\"dialog\")\n */\n ariaLabelledby?: string;\n /**\n * Describedby for the dropdown (recommended when role=\"dialog\")\n */\n ariaDescribedby?: string;\n}\n\nexport interface ExpandToViewport {\n /**\n * By default, the dropdown height is constrained to fit inside the height of its next scrollable container element.\n * Enabling this property will allow the dropdown to extend beyond that container by using fixed positioning and\n * [React Portals](https://reactjs.org/docs/portals.html).\n *\n * Set this property if the dropdown would otherwise be constrained by a scrollable container,\n * for example inside table and split view layouts.\n *\n * However, use discretion. We recommend you don't enable this property unless necessary\n * because fixed positioning results in a slight, visible lag when scrolling complex pages.\n */\n expandToViewport?: boolean;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
 
2
2
  export var PACKAGE_SOURCE = 'components';
3
- export var PACKAGE_VERSION = '3.0.0 (33458e3)';
3
+ export var PACKAGE_VERSION = '3.0.0 (c203e09)';
4
4
  export var THEME = 'open-source-visual-refresh';
5
5
  export var ALWAYS_VISUAL_REFRESH = true;
6
6
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (33458e35)",
3
+ "PACKAGE_VERSION": "3.0.0 (c203e090)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "33458e356a8b7806fe991883672edba54bfbd2e2"
2
+ "commit": "c203e0901b9f62a4eaed2fdd7bc38f422545e6dc"
3
3
  }
package/package.json CHANGED
@@ -109,7 +109,7 @@
109
109
  "./internal/base-component/index.js",
110
110
  "./internal/base-component/styles.css.js"
111
111
  ],
112
- "version": "3.0.347",
112
+ "version": "3.0.348",
113
113
  "repository": {
114
114
  "type": "git",
115
115
  "url": "https://github.com/cloudscape-design/components.git"
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { StickyColumnsModel } from '../sticky-columns/use-sticky-columns.js';
2
+ import { StickyColumnsModel } from '../sticky-columns';
3
+ import { TableRole } from '../table-role/table-role-helper.js';
3
4
  export interface TableTdElementProps {
4
5
  className?: string;
5
6
  style?: React.CSSProperties;
@@ -22,6 +23,7 @@ export interface TableTdElementProps {
22
23
  columnId: PropertyKey;
23
24
  stickyState: StickyColumnsModel;
24
25
  isVisualRefresh?: boolean;
26
+ tableRole: TableRole;
25
27
  }
26
28
  export declare const TableTdElement: React.ForwardRefExoticComponent<TableTdElementProps & React.RefAttributes<HTMLTableCellElement>>;
27
29
  //# sourceMappingURL=td-element.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"td-element.d.ts","sourceRoot":"lib/default/","sources":["table/body-cell/td-element.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,kBAAkB,EAAuB,MAAM,yCAAyC,CAAC;AAElG,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,IAAI,CACrB,KAAK,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,GAAG,KAAK,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,EAC3F,OAAO,GAAG,WAAW,GAAG,SAAS,CAClC,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,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B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,WAAW,CAAC;IACtB,WAAW,EAAE,kBAAkB,CAAC;IAChC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,cAAc,kGAyE1B,CAAC"}
@@ -4,13 +4,11 @@ import clsx from 'clsx';
4
4
  import React from 'react';
5
5
  import styles from './styles.css.js';
6
6
  import { getStickyClassNames } from '../utils';
7
- import { useStickyCellStyles } from '../sticky-columns/use-sticky-columns.js';
8
- export const TableTdElement = React.forwardRef(({ className, style, children, wrapLines, isRowHeader, isFirstRow, isLastRow, isSelected, isNextSelected, isPrevSelected, nativeAttributes, onClick, onMouseEnter, onMouseLeave, isEvenRow, stripedRows, isVisualRefresh, hasSelection, hasFooter, columnId, stickyState, }, ref) => {
9
- let Element = 'td';
10
- if (isRowHeader) {
11
- Element = 'th';
12
- nativeAttributes = Object.assign(Object.assign({}, nativeAttributes), { scope: 'row' });
13
- }
7
+ import { useStickyCellStyles } from '../sticky-columns';
8
+ import { getTableCellRoleProps } from '../table-role/table-role-helper.js';
9
+ export const TableTdElement = React.forwardRef(({ className, style, children, wrapLines, isRowHeader, isFirstRow, isLastRow, isSelected, isNextSelected, isPrevSelected, nativeAttributes, onClick, onMouseEnter, onMouseLeave, isEvenRow, stripedRows, isVisualRefresh, hasSelection, hasFooter, columnId, stickyState, tableRole, }, ref) => {
10
+ const Element = isRowHeader ? 'th' : 'td';
11
+ nativeAttributes = Object.assign(Object.assign({}, nativeAttributes), getTableCellRoleProps({ tableRole, isRowHeader }));
14
12
  const stickyStyles = useStickyCellStyles({
15
13
  stickyColumns: stickyState,
16
14
  columnId,
@@ -1 +1 @@
1
- {"version":3,"file":"td-element.js","sourceRoot":"lib/default/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UAAU,IAAI,MAAM,CAAC,oBAAoB,CAAC,EAC1C,cAAc,IAAI,MAAM,CAAC,yBAAyB,CAAC,EACnD,cAAc,IAAI,MAAM,CAAC,yBAAyB,CAAC,EACnD,CAAC,SAAS,IAAI,WAAW,IAAI,MAAM,CAAC,kBAAkB,CAAC,EACvD,WAAW,IAAI,MAAM,CAAC,kBAAkB,CAAC,EACzC,eAAe,IAAI,MAAM,CAAC,mBAAmB,CAAC,EAC9C,YAAY,IAAI,MAAM,CAAC,eAAe,CAAC,EACvC,SAAS,IAAI,MAAM,CAAC,YAAY,CAAC,EACjC,YAAY,CAAC,SAAS,CACvB,EACD,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,IAAI,CAAC,EAAE;YACV,IAAI,IAAI,EAAE;gBACR,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACvB,IAAI,GAAG,EAAE;oBACN,GAAoD,CAAC,OAAO,GAAG,IAAI,CAAC;iBACtE;aACF;QACH,CAAC,IACG,gBAAgB,GAEnB,QAAQ,CACD,CACX,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React from 'react';\nimport styles from './styles.css.js';\nimport { getStickyClassNames } from '../utils';\nimport { StickyColumnsModel, useStickyCellStyles } from '../sticky-columns/use-sticky-columns.js';\n\nexport interface TableTdElementProps {\n className?: string;\n style?: React.CSSProperties;\n wrapLines: boolean | undefined;\n isRowHeader?: boolean;\n isFirstRow: boolean;\n isLastRow: boolean;\n isSelected: boolean;\n isNextSelected: boolean;\n isPrevSelected: boolean;\n nativeAttributes?: Omit<\n React.TdHTMLAttributes<HTMLTableCellElement> | React.ThHTMLAttributes<HTMLTableCellElement>,\n 'style' | 'className' | 'onClick'\n >;\n onClick?: () => void;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n children?: React.ReactNode;\n isEvenRow?: boolean;\n stripedRows?: boolean;\n hasSelection?: boolean;\n hasFooter?: boolean;\n columnId: PropertyKey;\n stickyState: StickyColumnsModel;\n isVisualRefresh?: boolean;\n}\n\nexport const TableTdElement = React.forwardRef<HTMLTableCellElement, TableTdElementProps>(\n (\n {\n className,\n style,\n children,\n wrapLines,\n isRowHeader,\n isFirstRow,\n isLastRow,\n isSelected,\n isNextSelected,\n isPrevSelected,\n nativeAttributes,\n onClick,\n onMouseEnter,\n onMouseLeave,\n isEvenRow,\n stripedRows,\n isVisualRefresh,\n hasSelection,\n hasFooter,\n columnId,\n stickyState,\n },\n ref\n ) => {\n let Element: 'th' | 'td' = 'td';\n if (isRowHeader) {\n Element = 'th';\n nativeAttributes = {\n ...nativeAttributes,\n scope: 'row',\n };\n }\n\n const stickyStyles = useStickyCellStyles({\n stickyColumns: stickyState,\n columnId,\n getClassName: props => getStickyClassNames(styles, props),\n });\n return (\n <Element\n style={{ ...style, ...stickyStyles.style }}\n className={clsx(\n className,\n styles['body-cell'],\n wrapLines && styles['body-cell-wrap'],\n isFirstRow && styles['body-cell-first-row'],\n isLastRow && styles['body-cell-last-row'],\n isSelected && styles['body-cell-selected'],\n isNextSelected && styles['body-cell-next-selected'],\n isPrevSelected && styles['body-cell-prev-selected'],\n !isEvenRow && stripedRows && styles['body-cell-shaded'],\n stripedRows && styles['has-striped-rows'],\n isVisualRefresh && styles['is-visual-refresh'],\n hasSelection && styles['has-selection'],\n hasFooter && styles['has-footer'],\n stickyStyles.className\n )}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n ref={node => {\n if (node) {\n stickyStyles.ref(node);\n if (ref) {\n (ref as React.MutableRefObject<HTMLTableCellElement>).current = node;\n }\n }\n }}\n {...nativeAttributes}\n >\n {children}\n </Element>\n );\n }\n);\n"]}
1
+ {"version":3,"file":"td-element.js","sourceRoot":"lib/default/","sources":["table/body-cell/td-element.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M,CAAC,qBAAqB,CAAC,EAC3C,SAAS,IAAI,MAAM,CAAC,oBAAoB,CAAC,EACzC,UAAU,IAAI,MAAM,CAAC,oBAAoB,CAAC,EAC1C,cAAc,IAAI,MAAM,CAAC,yBAAyB,CAAC,EACnD,cAAc,IAAI,MAAM,CAAC,yBAAyB,CAAC,EACnD,CAAC,SAAS,IAAI,WAAW,IAAI,MAAM,CAAC,kBAAkB,CAAC,EACvD,WAAW,IAAI,MAAM,CAAC,kBAAkB,CAAC,EACzC,eAAe,IAAI,MAAM,CAAC,mBAAmB,CAAC,EAC9C,YAAY,IAAI,MAAM,CAAC,eAAe,CAAC,EACvC,SAAS,IAAI,MAAM,CAAC,YAAY,CAAC,EACjC,YAAY,CAAC,SAAS,CACvB,EACD,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAC1B,GAAG,EAAE,IAAI,CAAC,EAAE;YACV,IAAI,IAAI,EAAE;gBACR,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACvB,IAAI,GAAG,EAAE;oBACN,GAAoD,CAAC,OAAO,GAAG,IAAI,CAAC;iBACtE;aACF;QACH,CAAC,IACG,gBAAgB,GAEnB,QAAQ,CACD,CACX,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React from 'react';\nimport styles from './styles.css.js';\nimport { getStickyClassNames } from '../utils';\nimport { StickyColumnsModel, useStickyCellStyles } from '../sticky-columns';\nimport { TableRole, getTableCellRoleProps } from '../table-role/table-role-helper.js';\n\nexport interface TableTdElementProps {\n className?: string;\n style?: React.CSSProperties;\n wrapLines: boolean | undefined;\n isRowHeader?: boolean;\n isFirstRow: boolean;\n isLastRow: boolean;\n isSelected: boolean;\n isNextSelected: boolean;\n isPrevSelected: boolean;\n nativeAttributes?: Omit<\n React.TdHTMLAttributes<HTMLTableCellElement> | React.ThHTMLAttributes<HTMLTableCellElement>,\n 'style' | 'className' | 'onClick'\n >;\n onClick?: () => void;\n onMouseEnter?: () => void;\n onMouseLeave?: () => void;\n children?: React.ReactNode;\n isEvenRow?: boolean;\n stripedRows?: boolean;\n hasSelection?: boolean;\n hasFooter?: boolean;\n columnId: PropertyKey;\n stickyState: StickyColumnsModel;\n isVisualRefresh?: boolean;\n tableRole: TableRole;\n}\n\nexport const TableTdElement = React.forwardRef<HTMLTableCellElement, TableTdElementProps>(\n (\n {\n className,\n style,\n children,\n wrapLines,\n isRowHeader,\n isFirstRow,\n isLastRow,\n isSelected,\n isNextSelected,\n isPrevSelected,\n nativeAttributes,\n onClick,\n onMouseEnter,\n onMouseLeave,\n isEvenRow,\n stripedRows,\n isVisualRefresh,\n hasSelection,\n hasFooter,\n columnId,\n stickyState,\n tableRole,\n },\n ref\n ) => {\n const Element = isRowHeader ? 'th' : 'td';\n\n nativeAttributes = { ...nativeAttributes, ...getTableCellRoleProps({ tableRole, isRowHeader }) };\n\n const stickyStyles = useStickyCellStyles({\n stickyColumns: stickyState,\n columnId,\n getClassName: props => getStickyClassNames(styles, props),\n });\n return (\n <Element\n style={{ ...style, ...stickyStyles.style }}\n className={clsx(\n className,\n styles['body-cell'],\n wrapLines && styles['body-cell-wrap'],\n isFirstRow && styles['body-cell-first-row'],\n isLastRow && styles['body-cell-last-row'],\n isSelected && styles['body-cell-selected'],\n isNextSelected && styles['body-cell-next-selected'],\n isPrevSelected && styles['body-cell-prev-selected'],\n !isEvenRow && stripedRows && styles['body-cell-shaded'],\n stripedRows && styles['has-striped-rows'],\n isVisualRefresh && styles['is-visual-refresh'],\n hasSelection && styles['has-selection'],\n hasFooter && styles['has-footer'],\n stickyStyles.className\n )}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n ref={node => {\n if (node) {\n stickyStyles.ref(node);\n if (ref) {\n (ref as React.MutableRefObject<HTMLTableCellElement>).current = node;\n }\n }\n }}\n {...nativeAttributes}\n >\n {children}\n </Element>\n );\n }\n);\n"]}
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { TableProps } from '../interfaces';
3
3
  import { InteractiveComponent } from '../thead';
4
4
  import { StickyColumnsModel } from '../sticky-columns';
5
+ import { TableRole } from '../table-role';
5
6
  interface TableHeaderCellProps<ItemType> {
6
7
  className?: string;
7
8
  style?: React.CSSProperties;
@@ -25,6 +26,7 @@ interface TableHeaderCellProps<ItemType> {
25
26
  cellRef: React.RefCallback<HTMLElement>;
26
27
  focusedComponent?: InteractiveComponent | null;
27
28
  onFocusedComponentChange?: (element: InteractiveComponent | null) => void;
29
+ tableRole: TableRole;
28
30
  }
29
31
  export declare function TableHeaderCell<ItemType>({ className, style, tabIndex, column, activeSortingColumn, sortingDescending, sortingDisabled, wrapLines, focusedComponent, onFocusedComponentChange, hidden, onClick, colIndex, updateColumn, resizableColumns, onResizeFinish, isEditable, columnId, stickyState, cellRef, }: TableHeaderCellProps<ItemType>): JSX.Element;
30
32
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["table/header-cell/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGhD,OAAO,EAAE,kBAAkB,EAAuB,MAAM,mBAAmB,CAAC;AAG5E,UAAU,oBAAoB,CAAC,QAAQ;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC9C,mBAAmB,CAAC,EAAE,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACzD,iBAAi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;IAC/C,wBAAwB,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1E,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,EACxC,SAAS,EACT,KAAK,EACL,QAAQ,EACR,MAAM,EACN,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,wBAAwB,EACxB,MAAM,EACN,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,QAAQ,EACR,WAAW,EACX,OAAO,GACR,EAAE,oBAAoB,CAAC,QAAQ,CAAC,eA6GhC"}
@@ -4,7 +4,7 @@ import clsx from 'clsx';
4
4
  import React from 'react';
5
5
  import InternalIcon from '../../icon/internal';
6
6
  import { KeyCode } from '../../internal/keycode';
7
- import { getAriaSort, getSortingIconName, getSortingStatus, isSorted } from './utils';
7
+ import { getSortingIconName, getSortingStatus, isSorted } from './utils';
8
8
  import styles from './styles.css.js';
9
9
  import { Resizer } from '../resizer';
10
10
  import { useUniqueId } from '../../internal/hooks/use-unique-id';
@@ -12,6 +12,7 @@ import { getStickyClassNames } from '../utils';
12
12
  import { useInternalI18n } from '../../i18n/context';
13
13
  import { useStickyCellStyles } from '../sticky-columns';
14
14
  import { useMergeRefs } from '../../internal/hooks/use-merge-refs';
15
+ import { getTableColHeaderRoleProps } from '../table-role';
15
16
  export function TableHeaderCell({ className, style, tabIndex, column, activeSortingColumn, sortingDescending, sortingDisabled, wrapLines, focusedComponent, onFocusedComponentChange, hidden, onClick, colIndex, updateColumn, resizableColumns, onResizeFinish, isEditable, columnId, stickyState, cellRef, }) {
16
17
  var _a;
17
18
  const i18n = useInternalI18n('table');
@@ -39,7 +40,7 @@ export function TableHeaderCell({ className, style, tabIndex, column, activeSort
39
40
  getClassName: props => getStickyClassNames(styles, props),
40
41
  });
41
42
  const mergedRef = useMergeRefs(stickyStyles.ref, cellRef);
42
- return (React.createElement("th", { className: clsx(className, {
43
+ return (React.createElement("th", Object.assign({ className: clsx(className, {
43
44
  [styles['header-cell-resizable']]: !!resizableColumns,
44
45
  [styles['header-cell-sortable']]: sortingStatus,
45
46
  [styles['header-cell-sorted']]: sortingStatus === 'ascending' || sortingStatus === 'descending',
@@ -47,7 +48,7 @@ export function TableHeaderCell({ className, style, tabIndex, column, activeSort
47
48
  [styles['header-cell-ascending']]: sortingStatus === 'ascending',
48
49
  [styles['header-cell-descending']]: sortingStatus === 'descending',
49
50
  [styles['header-cell-hidden']]: hidden,
50
- }, stickyStyles.className), "aria-sort": sortingStatus && getAriaSort(sortingStatus), style: Object.assign(Object.assign({}, style), stickyStyles.style), scope: "col", ref: mergedRef },
51
+ }, stickyStyles.className), style: Object.assign(Object.assign({}, style), stickyStyles.style), ref: mergedRef }, getTableColHeaderRoleProps({ sortingStatus })),
51
52
  React.createElement("div", Object.assign({ className: clsx(styles['header-cell-content'], {
52
53
  [styles['header-cell-fake-focus']]: (focusedComponent === null || focusedComponent === void 0 ? void 0 : focusedComponent.type) === 'column' && focusedComponent.col === colIndex,
53
54
  }), "aria-label": column.ariaLabel
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["table/header-cell/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtF,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,oC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ACR,CAAC,CAAC,CAAC,IAAI,CACJ;YACL,aAAa,IAAI,CAChB,8BAAM,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC;gBACrC,oBAAC,YAAY,IAAC,IAAI,EAAE,kBAAkB,CAAC,aAAa,CAAC,GAAI,CACpD,CACR,CACG;QACL,gBAAgB,IAAI,CACnB;YACE,oBAAC,OAAO,IACN,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,CAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI,MAAK,SAAS,IAAI,gBAAgB,CAAC,GAAG,KAAK,QAAQ,EACxF,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,EACxD,QAAQ,EAAE,cAAc,EACxB,cAAc,EAAE,QAAQ,EACxB,OAAO,EAAE,GAAG,EAAE,CAAC,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAG,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,EAC7E,MAAM,EAAE,GAAG,EAAE,CAAC,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAG,IAAI,CAAC,EAC9C,QAAQ,EAAE,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,GAC3F,CACD,CACJ,CACE,CACN,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React from 'react';\nimport InternalIcon from '../../icon/internal';\nimport { KeyCode } from '../../internal/keycode';\nimport { TableProps } from '../interfaces';\nimport { getAriaSort, getSortingIconName, getSortingStatus, isSorted } from './utils';\nimport styles from './styles.css.js';\nimport { Resizer } from '../resizer';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\nimport { InteractiveComponent } from '../thead';\nimport { getStickyClassNames } from '../utils';\nimport { useInternalI18n } from '../../i18n/context';\nimport { StickyColumnsModel, useStickyCellStyles } from '../sticky-columns';\nimport { useMergeRefs } from '../../internal/hooks/use-merge-refs';\n\ninterface TableHeaderCellProps<ItemType> {\n className?: string;\n style?: React.CSSProperties;\n tabIndex: number;\n column: TableProps.ColumnDefinition<ItemType>;\n activeSortingColumn?: TableProps.SortingColumn<ItemType>;\n sortingDescending?: boolean;\n sortingDisabled?: boolean;\n wrapLines?: boolean;\n hidden?: boolean;\n onClick(detail: TableProps.SortingState<any>): void;\n onResizeFinish: () => void;\n colIndex: number;\n updateColumn: (columnId: PropertyKey, newWidth: number) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n resizableColumns?: boolean;\n isEditable?: boolean;\n columnId: PropertyKey;\n stickyState: StickyColumnsModel;\n cellRef: React.RefCallback<HTMLElement>;\n focusedComponent?: InteractiveComponent | null;\n onFocusedComponentChange?: (element: InteractiveComponent | null) => void;\n}\n\nexport function TableHeaderCell<ItemType>({\n className,\n style,\n tabIndex,\n column,\n activeSortingColumn,\n sortingDescending,\n sortingDisabled,\n wrapLines,\n focusedComponent,\n onFocusedComponentChange,\n hidden,\n onClick,\n colIndex,\n updateColumn,\n resizableColumns,\n onResizeFinish,\n isEditable,\n columnId,\n stickyState,\n cellRef,\n}: TableHeaderCellProps<ItemType>) {\n const i18n = useInternalI18n('table');\n const sortable = !!column.sortingComparator || !!column.sortingField;\n const sorted = !!activeSortingColumn && isSorted(column, activeSortingColumn);\n const sortingStatus = getSortingStatus(sortable, sorted, !!sortingDescending, !!sortingDisabled);\n const handleClick = () =>\n onClick({\n sortingColumn: column,\n isDescending: sorted ? !sortingDescending : false,\n });\n\n // Elements with role=\"button\" do not have the default behavior of <button>, where pressing\n // Enter or Space will trigger a click event. Therefore we need to add this ourselves.\n // The native <button> element cannot be used due to a misaligned implementation in Firefox:\n // https://bugzilla.mozilla.org/show_bug.cgi?id=843003\n const handleKeyPress = ({ nativeEvent: e }: React.KeyboardEvent) => {\n if (e.keyCode === KeyCode.enter || e.keyCode === KeyCode.space) {\n e.preventDefault();\n handleClick();\n }\n };\n\n const headerId = useUniqueId('table-header-');\n\n const stickyStyles = useStickyCellStyles({\n stickyColumns: stickyState,\n columnId,\n getClassName: props => getStickyClassNames(styles, props),\n });\n\n const mergedRef = useMergeRefs(stickyStyles.ref, cellRef);\n\n return (\n <th\n className={clsx(\n className,\n {\n [styles['header-cell-resizable']]: !!resizableColumns,\n [styles['header-cell-sortable']]: sortingStatus,\n [styles['header-cell-sorted']]: sortingStatus === 'ascending' || sortingStatus === 'descending',\n [styles['header-cell-disabled']]: sortingDisabled,\n [styles['header-cell-ascending']]: sortingStatus === 'ascending',\n [styles['header-cell-descending']]: sortingStatus === 'descending',\n [styles['header-cell-hidden']]: hidden,\n },\n stickyStyles.className\n )}\n aria-sort={sortingStatus && getAriaSort(sortingStatus)}\n style={{ ...style, ...stickyStyles.style }}\n scope=\"col\"\n ref={mergedRef}\n >\n <div\n className={clsx(styles['header-cell-content'], {\n [styles['header-cell-fake-focus']]: focusedComponent?.type === 'column' && focusedComponent.col === colIndex,\n })}\n aria-label={\n column.ariaLabel\n ? column.ariaLabel({\n sorted: sorted,\n descending: sorted && !!sortingDescending,\n disabled: !!sortingDisabled,\n })\n : undefined\n }\n {...(sortingStatus && !sortingDisabled\n ? {\n onKeyPress: handleKeyPress,\n tabIndex: tabIndex,\n role: 'button',\n onClick: handleClick,\n onFocus: () => onFocusedComponentChange?.({ type: 'column', col: colIndex }),\n onBlur: () => onFocusedComponentChange?.(null),\n }\n : {})}\n >\n <div className={clsx(styles['header-cell-text'], wrapLines && styles['header-cell-text-wrap'])} id={headerId}>\n {column.header}\n {isEditable ? (\n <span\n className={styles['edit-icon']}\n role=\"img\"\n aria-label={i18n('columnDefinitions.editConfig.editIconAriaLabel', column.editConfig?.editIconAriaLabel)}\n >\n <InternalIcon name=\"edit\" />\n </span>\n ) : null}\n </div>\n {sortingStatus && (\n <span className={styles['sorting-icon']}>\n <InternalIcon name={getSortingIconName(sortingStatus)} />\n </span>\n )}\n </div>\n {resizableColumns && (\n <>\n <Resizer\n tabIndex={tabIndex}\n showFocusRing={focusedComponent?.type === 'resizer' && focusedComponent.col === colIndex}\n onDragMove={newWidth => updateColumn(columnId, newWidth)}\n onFinish={onResizeFinish}\n ariaLabelledby={headerId}\n onFocus={() => onFocusedComponentChange?.({ type: 'resizer', col: colIndex })}\n onBlur={() => onFocusedComponentChange?.(null)}\n minWidth={typeof column.minWidth === 'string' ? parseInt(column.minWidth) : column.minWidth}\n />\n </>\n )}\n </th>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["table/header-cell/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAsB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAa,0BAA0B,EAAE,MAAM,eAAe,CAAC;AA4BtE,MAAM,UAAU,eAAe,CAAW,EACxC,SAAS,EACT,KAA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gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI,MAAK,SAAS,IAAI,gBAAgB,CAAC,GAAG,KAAK,QAAQ,EACxF,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,EACxD,QAAQ,EAAE,cAAc,EACxB,cAAc,EAAE,QAAQ,EACxB,OAAO,EAAE,GAAG,EAAE,CAAC,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAG,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,EAC7E,MAAM,EAAE,GAAG,EAAE,CAAC,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAG,IAAI,CAAC,EAC9C,QAAQ,EAAE,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,GAC3F,CACD,CACJ,CACE,CACN,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React from 'react';\nimport InternalIcon from '../../icon/internal';\nimport { KeyCode } from '../../internal/keycode';\nimport { TableProps } from '../interfaces';\nimport { getSortingIconName, getSortingStatus, isSorted } from './utils';\nimport styles from './styles.css.js';\nimport { Resizer } from '../resizer';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\nimport { InteractiveComponent } from '../thead';\nimport { getStickyClassNames } from '../utils';\nimport { useInternalI18n } from '../../i18n/context';\nimport { StickyColumnsModel, useStickyCellStyles } from '../sticky-columns';\nimport { useMergeRefs } from '../../internal/hooks/use-merge-refs';\nimport { TableRole, getTableColHeaderRoleProps } from '../table-role';\n\ninterface TableHeaderCellProps<ItemType> {\n className?: string;\n style?: React.CSSProperties;\n tabIndex: number;\n column: TableProps.ColumnDefinition<ItemType>;\n activeSortingColumn?: TableProps.SortingColumn<ItemType>;\n sortingDescending?: boolean;\n sortingDisabled?: boolean;\n wrapLines?: boolean;\n hidden?: boolean;\n onClick(detail: TableProps.SortingState<any>): void;\n onResizeFinish: () => void;\n colIndex: number;\n updateColumn: (columnId: PropertyKey, newWidth: number) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n resizableColumns?: boolean;\n isEditable?: boolean;\n columnId: PropertyKey;\n stickyState: StickyColumnsModel;\n cellRef: React.RefCallback<HTMLElement>;\n focusedComponent?: InteractiveComponent | null;\n onFocusedComponentChange?: (element: InteractiveComponent | null) => void;\n tableRole: TableRole;\n}\n\nexport function TableHeaderCell<ItemType>({\n className,\n style,\n tabIndex,\n column,\n activeSortingColumn,\n sortingDescending,\n sortingDisabled,\n wrapLines,\n focusedComponent,\n onFocusedComponentChange,\n hidden,\n onClick,\n colIndex,\n updateColumn,\n resizableColumns,\n onResizeFinish,\n isEditable,\n columnId,\n stickyState,\n cellRef,\n}: TableHeaderCellProps<ItemType>) {\n const i18n = useInternalI18n('table');\n const sortable = !!column.sortingComparator || !!column.sortingField;\n const sorted = !!activeSortingColumn && isSorted(column, activeSortingColumn);\n const sortingStatus = getSortingStatus(sortable, sorted, !!sortingDescending, !!sortingDisabled);\n const handleClick = () =>\n onClick({\n sortingColumn: column,\n isDescending: sorted ? !sortingDescending : false,\n });\n\n // Elements with role=\"button\" do not have the default behavior of <button>, where pressing\n // Enter or Space will trigger a click event. Therefore we need to add this ourselves.\n // The native <button> element cannot be used due to a misaligned implementation in Firefox:\n // https://bugzilla.mozilla.org/show_bug.cgi?id=843003\n const handleKeyPress = ({ nativeEvent: e }: React.KeyboardEvent) => {\n if (e.keyCode === KeyCode.enter || e.keyCode === KeyCode.space) {\n e.preventDefault();\n handleClick();\n }\n };\n\n const headerId = useUniqueId('table-header-');\n\n const stickyStyles = useStickyCellStyles({\n stickyColumns: stickyState,\n columnId,\n getClassName: props => getStickyClassNames(styles, props),\n });\n\n const mergedRef = useMergeRefs(stickyStyles.ref, cellRef);\n\n return (\n <th\n className={clsx(\n className,\n {\n [styles['header-cell-resizable']]: !!resizableColumns,\n [styles['header-cell-sortable']]: sortingStatus,\n [styles['header-cell-sorted']]: sortingStatus === 'ascending' || sortingStatus === 'descending',\n [styles['header-cell-disabled']]: sortingDisabled,\n [styles['header-cell-ascending']]: sortingStatus === 'ascending',\n [styles['header-cell-descending']]: sortingStatus === 'descending',\n [styles['header-cell-hidden']]: hidden,\n },\n stickyStyles.className\n )}\n style={{ ...style, ...stickyStyles.style }}\n ref={mergedRef}\n {...getTableColHeaderRoleProps({ sortingStatus })}\n >\n <div\n className={clsx(styles['header-cell-content'], {\n [styles['header-cell-fake-focus']]: focusedComponent?.type === 'column' && focusedComponent.col === colIndex,\n })}\n aria-label={\n column.ariaLabel\n ? column.ariaLabel({\n sorted: sorted,\n descending: sorted && !!sortingDescending,\n disabled: !!sortingDisabled,\n })\n : undefined\n }\n {...(sortingStatus && !sortingDisabled\n ? {\n onKeyPress: handleKeyPress,\n tabIndex: tabIndex,\n role: 'button',\n onClick: handleClick,\n onFocus: () => onFocusedComponentChange?.({ type: 'column', col: colIndex }),\n onBlur: () => onFocusedComponentChange?.(null),\n }\n : {})}\n >\n <div className={clsx(styles['header-cell-text'], wrapLines && styles['header-cell-text-wrap'])} id={headerId}>\n {column.header}\n {isEditable ? (\n <span\n className={styles['edit-icon']}\n role=\"img\"\n aria-label={i18n('columnDefinitions.editConfig.editIconAriaLabel', column.editConfig?.editIconAriaLabel)}\n >\n <InternalIcon name=\"edit\" />\n </span>\n ) : null}\n </div>\n {sortingStatus && (\n <span className={styles['sorting-icon']}>\n <InternalIcon name={getSortingIconName(sortingStatus)} />\n </span>\n )}\n </div>\n {resizableColumns && (\n <>\n <Resizer\n tabIndex={tabIndex}\n showFocusRing={focusedComponent?.type === 'resizer' && focusedComponent.col === colIndex}\n onDragMove={newWidth => updateColumn(columnId, newWidth)}\n onFinish={onResizeFinish}\n ariaLabelledby={headerId}\n onFocus={() => onFocusedComponentChange?.({ type: 'resizer', col: colIndex })}\n onBlur={() => onFocusedComponentChange?.(null)}\n minWidth={typeof column.minWidth === 'string' ? parseInt(column.minWidth) : column.minWidth}\n />\n </>\n )}\n </th>\n );\n}\n"]}
@@ -2,7 +2,6 @@ import { TableProps } from '../interfaces';
2
2
  type SortingStatus = 'sortable' | 'ascending' | 'descending';
3
3
  export declare const getSortingStatus: (sortable: boolean, sorted: boolean, descending: boolean, disabled: boolean) => SortingStatus | undefined;
4
4
  export declare const getSortingIconName: (sortingState: SortingStatus) => "caret-down-filled" | "caret-down" | "caret-up-filled";
5
- export declare const getAriaSort: (sortingState: SortingStatus) => "none" | "ascending" | "descending";
6
5
  export declare const isSorted: <T>(column: TableProps.ColumnDefinition<T>, sortingColumn: TableProps.SortingColumn<T>) => boolean;
7
6
  export {};
8
7
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"lib/default/","sources":["table/header-cell/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,KAAK,aAAa,GAAG,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC;AAY7D,eAAO,MAAM,gBAAgB,aACjB,OAAO,UACT,OAAO,cACH,OAAO,YACT,OAAO,KAChB,aAAa,GAAG,SAWlB,CAAC;AAEF,eAAO,MAAM,kBAAkB,iBAAkB,aAAa,2DAA8B,CAAC;AAC7F,eAAO,MAAM,WAAW,iBAAkB,aAAa,wCAAkC,CAAC;AAC1F,eAAO,MAAM,QAAQ,oGAGqF,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"lib/default/","sources":["table/header-cell/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,KAAK,aAAa,GAAG,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC;AAO7D,eAAO,MAAM,gBAAgB,aACjB,OAAO,UACT,OAAO,cACH,OAAO,YACT,OAAO,KAChB,aAAa,GAAG,SAWlB,CAAC;AAEF,eAAO,MAAM,kBAAkB,iBAAkB,aAAa,2DAA8B,CAAC;AAC7F,eAAO,MAAM,QAAQ,oGAGqF,CAAC"}
@@ -3,11 +3,6 @@ const stateToIcon = {
3
3
  ascending: 'caret-up-filled',
4
4
  descending: 'caret-down-filled',
5
5
  };
6
- const stateToAriaSort = {
7
- sortable: 'none',
8
- ascending: 'ascending',
9
- descending: 'descending',
10
- };
11
6
  export const getSortingStatus = (sortable, sorted, descending, disabled) => {
12
7
  if (sorted) {
13
8
  if (descending) {
@@ -21,7 +16,6 @@ export const getSortingStatus = (sortable, sorted, descending, disabled) => {
21
16
  return undefined;
22
17
  };
23
18
  export const getSortingIconName = (sortingState) => stateToIcon[sortingState];
24
- export const getAriaSort = (sortingState) => stateToAriaSort[sortingState];
25
19
  export const isSorted = (column, sortingColumn) => column === sortingColumn ||
26
20
  (column.sortingField !== undefined && column.sortingField === sortingColumn.sortingField) ||
27
21
  (column.sortingComparator !== undefined && column.sortingComparator === sortingColumn.sortingComparator);
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"lib/default/","sources":["table/header-cell/utils.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,GAAG;IAClB,QAAQ,EAAE,YAAY;IACtB,SAAS,EAAE,iBAAiB;IAC5B,UAAU,EAAE,mBAAmB;CACvB,CAAC;AACX,MAAM,eAAe,GAAG;IACtB,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,WAAW;IACtB,UAAU,EAAE,YAAY;CAChB,CAAC;AAEX,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,QAAiB,EACjB,MAAe,EACf,UAAmB,EACnB,QAAiB,EACU,EAAE;IAC7B,IAAI,MAAM,EAAE;QACV,IAAI,UAAU,EAAE;YACd,OAAO,YAAY,CAAC;SACrB;QACD,OAAO,WAAW,CAAC;KACpB;IACD,IAAI,QAAQ,IAAI,CAAC,QAAQ,EAAE;QACzB,OAAO,UAAU,CAAC;KACnB;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,YAA2B,EAAE,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;AAC7F,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,YAA2B,EAAE,EAAE,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;AAC1F,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAI,MAAsC,EAAE,aAA0C,EAAE,EAAE,CAChH,MAAM,KAAK,aAAa;IACxB,CAAC,MAAM,CAAC,YAAY,KAAK,SAAS,IAAI,MAAM,CAAC,YAAY,KAAK,aAAa,CAAC,YAAY,CAAC;IACzF,CAAC,MAAM,CAAC,iBAAiB,KAAK,SAAS,IAAI,MAAM,CAAC,iBAAiB,KAAK,aAAa,CAAC,iBAAiB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { TableProps } from '../interfaces';\n\ntype SortingStatus = 'sortable' | 'ascending' | 'descending';\nconst stateToIcon = {\n sortable: 'caret-down',\n ascending: 'caret-up-filled',\n descending: 'caret-down-filled',\n} as const;\nconst stateToAriaSort = {\n sortable: 'none',\n ascending: 'ascending',\n descending: 'descending',\n} as const;\n\nexport const getSortingStatus = (\n sortable: boolean,\n sorted: boolean,\n descending: boolean,\n disabled: boolean\n): SortingStatus | undefined => {\n if (sorted) {\n if (descending) {\n return 'descending';\n }\n return 'ascending';\n }\n if (sortable && !disabled) {\n return 'sortable';\n }\n return undefined;\n};\n\nexport const getSortingIconName = (sortingState: SortingStatus) => stateToIcon[sortingState];\nexport const getAriaSort = (sortingState: SortingStatus) => stateToAriaSort[sortingState];\nexport const isSorted = <T>(column: TableProps.ColumnDefinition<T>, sortingColumn: TableProps.SortingColumn<T>) =>\n column === sortingColumn ||\n (column.sortingField !== undefined && column.sortingField === sortingColumn.sortingField) ||\n (column.sortingComparator !== undefined && column.sortingComparator === sortingColumn.sortingComparator);\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"lib/default/","sources":["table/header-cell/utils.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,GAAG;IAClB,QAAQ,EAAE,YAAY;IACtB,SAAS,EAAE,iBAAiB;IAC5B,UAAU,EAAE,mBAAmB;CACvB,CAAC;AAEX,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,QAAiB,EACjB,MAAe,EACf,UAAmB,EACnB,QAAiB,EACU,EAAE;IAC7B,IAAI,MAAM,EAAE;QACV,IAAI,UAAU,EAAE;YACd,OAAO,YAAY,CAAC;SACrB;QACD,OAAO,WAAW,CAAC;KACpB;IACD,IAAI,QAAQ,IAAI,CAAC,QAAQ,EAAE;QACzB,OAAO,UAAU,CAAC;KACnB;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,YAA2B,EAAE,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;AAC7F,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAI,MAAsC,EAAE,aAA0C,EAAE,EAAE,CAChH,MAAM,KAAK,aAAa;IACxB,CAAC,MAAM,CAAC,YAAY,KAAK,SAAS,IAAI,MAAM,CAAC,YAAY,KAAK,aAAa,CAAC,YAAY,CAAC;IACzF,CAAC,MAAM,CAAC,iBAAiB,KAAK,SAAS,IAAI,MAAM,CAAC,iBAAiB,KAAK,aAAa,CAAC,iBAAiB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { TableProps } from '../interfaces';\n\ntype SortingStatus = 'sortable' | 'ascending' | 'descending';\nconst stateToIcon = {\n sortable: 'caret-down',\n ascending: 'caret-up-filled',\n descending: 'caret-down-filled',\n} as const;\n\nexport const getSortingStatus = (\n sortable: boolean,\n sorted: boolean,\n descending: boolean,\n disabled: boolean\n): SortingStatus | undefined => {\n if (sorted) {\n if (descending) {\n return 'descending';\n }\n return 'ascending';\n }\n if (sortable && !disabled) {\n return 'sortable';\n }\n return undefined;\n};\n\nexport const getSortingIconName = (sortingState: SortingStatus) => stateToIcon[sortingState];\nexport const isSorted = <T>(column: TableProps.ColumnDefinition<T>, sortingColumn: TableProps.SortingColumn<T>) =>\n column === sortingColumn ||\n (column.sortingField !== undefined && column.sortingField === sortingColumn.sortingField) ||\n (column.sortingComparator !== undefined && column.sortingComparator === sortingColumn.sortingComparator);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["table/internal.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAc,MAAM,cAAc,CAAC;AAyC/D,QAAA,MAAM,aAAa,qBAgbK,CAAC;AAEzB,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["table/internal.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAc,MAAM,cAAc,CAAC;AA0C/D,QAAA,MAAM,aAAa,qBAmbK,CAAC;AAEzB,eAAe,aAAa,CAAC"}
package/table/internal.js CHANGED
@@ -34,6 +34,7 @@ import { StickyScrollbar } from './sticky-scrollbar';
34
34
  import { checkColumnWidths } from './column-widths-utils';
35
35
  import { useMobile } from '../internal/hooks/use-mobile';
36
36
  import { useContainerQuery } from '@cloudscape-design/component-toolkit';
37
+ import { getTableRoleProps, getTableRowRoleProps } from './table-role';
37
38
  const SELECTION_COLUMN_WIDTH = 54;
38
39
  const selectionColumnId = Symbol('selection-column-id');
39
40
  const InternalTable = React.forwardRef((_a, ref) => {
@@ -112,6 +113,8 @@ const InternalTable = React.forwardRef((_a, ref) => {
112
113
  stickyColumnsFirst: ((_b = stickyColumns === null || stickyColumns === void 0 ? void 0 : stickyColumns.first) !== null && _b !== void 0 ? _b : 0) + ((stickyColumns === null || stickyColumns === void 0 ? void 0 : stickyColumns.first) && hasSelection ? 1 : 0),
113
114
  stickyColumnsLast: (stickyColumns === null || stickyColumns === void 0 ? void 0 : stickyColumns.last) || 0,
114
115
  });
116
+ const hasEditableCells = !!columnDefinitions.find(col => col.editConfig);
117
+ const tableRole = hasEditableCells ? 'grid' : 'table';
115
118
  const theadProps = {
116
119
  containerWidth,
117
120
  selectionType,
@@ -136,6 +139,7 @@ const InternalTable = React.forwardRef((_a, ref) => {
136
139
  stripedRows,
137
140
  stickyState,
138
141
  selectionColumnId,
142
+ tableRole,
139
143
  };
140
144
  const wrapperRef = useMergeRefs(wrapperMeasureRef, wrapperRefObject, stickyState.refs.wrapper);
141
145
  const tableRef = useMergeRefs(tableMeasureRef, tableRefObject, stickyState.refs.table);
@@ -170,7 +174,7 @@ const InternalTable = React.forwardRef((_a, ref) => {
170
174
  hasHeader && (React.createElement("div", { ref: overlapElement, className: clsx(hasDynamicHeight && [styles['dark-header'], 'awsui-context-content-header']) },
171
175
  React.createElement("div", { ref: toolsHeaderWrapper, className: clsx(styles['header-controls'], styles[`variant-${computedVariant}`]) },
172
176
  React.createElement(ToolsHeader, { header: header, filter: filter, pagination: pagination, preferences: preferences })))),
173
- stickyHeader && (React.createElement(StickyHeader, { ref: stickyHeaderRef, variant: computedVariant, theadProps: theadProps, wrapperRef: wrapperRefObject, theadRef: theadRef, secondaryWrapperRef: secondaryWrapperRef, tableRef: tableRefObject, onScroll: handleScroll, tableHasHeader: hasHeader, contentDensity: contentDensity }))), disableHeaderPaddings: true, disableContentPaddings: true, variant: toContainerVariant(computedVariant), __disableFooterPaddings: true, __disableFooterDivider: true, __disableStickyMobile: false, footer: hasFooter ? (React.createElement("div", { className: clsx(styles['footer-wrapper'], styles[`variant-${computedVariant}`]) },
177
+ stickyHeader && (React.createElement(StickyHeader, { ref: stickyHeaderRef, variant: computedVariant, theadProps: theadProps, wrapperRef: wrapperRefObject, theadRef: theadRef, secondaryWrapperRef: secondaryWrapperRef, tableRef: tableRefObject, onScroll: handleScroll, tableHasHeader: hasHeader, contentDensity: contentDensity, tableRole: tableRole }))), disableHeaderPaddings: true, disableContentPaddings: true, variant: toContainerVariant(computedVariant), __disableFooterPaddings: true, __disableFooterDivider: true, __disableStickyMobile: false, footer: hasFooter ? (React.createElement("div", { className: clsx(styles['footer-wrapper'], styles[`variant-${computedVariant}`]) },
174
178
  React.createElement("div", { className: clsx(styles.footer, hasFooterPagination && styles['footer-with-pagination']) },
175
179
  footer && React.createElement("span", null, footer),
176
180
  hasFooterPagination && React.createElement("div", { className: styles['footer-pagination'] }, pagination)))) : null, __stickyHeader: stickyHeader, __mobileStickyOffset: toolsHeaderHeight, __stickyOffset: stickyHeaderVerticalOffset }, focusMarkers.root),
@@ -180,10 +184,7 @@ const InternalTable = React.forwardRef((_a, ref) => {
180
184
  }), onScroll: handleScroll }, wrapperProps),
181
185
  !!renderAriaLive && !!firstIndex && (React.createElement(LiveRegion, null,
182
186
  React.createElement("span", null, renderAriaLive({ totalItemsCount, firstIndex, lastIndex: firstIndex + items.length - 1 })))),
183
- React.createElement("table", { ref: tableRef, className: clsx(styles.table, resizableColumns && styles['table-layout-fixed'], contentDensity === 'compact' && getVisualContextClassname('compact-table')),
184
- // Browsers have weird mechanism to guess whether it's a data table or a layout table.
185
- // If we state explicitly, they get it always correctly even with low number of rows.
186
- role: "table", "aria-label": ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.tableLabel, "aria-rowcount": totalItemsCount ? totalItemsCount + 1 : -1 },
187
+ React.createElement("table", Object.assign({ ref: tableRef, className: clsx(styles.table, resizableColumns && styles['table-layout-fixed'], contentDensity === 'compact' && getVisualContextClassname('compact-table')) }, getTableRoleProps({ tableRole, totalItemsCount, ariaLabel: ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.tableLabel })),
187
188
  React.createElement(Thead, Object.assign({ ref: theadRef, hidden: stickyHeader, onFocusedComponentChange: component => { var _a; return (_a = stickyHeaderRef.current) === null || _a === void 0 ? void 0 : _a.setFocus(component); } }, theadProps)),
188
189
  React.createElement("tbody", null, loading || items.length === 0 ? (React.createElement("tr", null,
189
190
  React.createElement("td", { colSpan: selectionType ? visibleColumnDefinitions.length + 1 : visibleColumnDefinitions.length, className: clsx(styles['cell-merged'], hasFooter && styles['has-footer']) },
@@ -205,8 +206,8 @@ const InternalTable = React.forwardRef((_a, ref) => {
205
206
  if (!currentTarget.contains(getMouseDownTarget())) {
206
207
  (_a = stickyHeaderRef.current) === null || _a === void 0 ? void 0 : _a.scrollToRow(currentTarget);
207
208
  }
208
- } }, focusMarkers.item, { onClick: onRowClickHandler && onRowClickHandler.bind(null, rowIndex, item), onContextMenu: onRowContextMenuHandler && onRowContextMenuHandler.bind(null, rowIndex, item), "aria-rowindex": firstIndex ? firstIndex + rowIndex + 1 : undefined }),
209
- selectionType !== undefined && (React.createElement(TableTdElement, { className: clsx(styles['selection-control']), isVisualRefresh: isVisualRefresh, isFirstRow: firstVisible, isLastRow: lastVisible, isSelected: isSelected, isNextSelected: isNextSelected, isPrevSelected: isPrevSelected, wrapLines: false, isEvenRow: isEven, stripedRows: stripedRows, hasSelection: hasSelection, hasFooter: hasFooter, stickyState: stickyState, columnId: selectionColumnId },
209
+ } }, focusMarkers.item, { onClick: onRowClickHandler && onRowClickHandler.bind(null, rowIndex, item), onContextMenu: onRowContextMenuHandler && onRowContextMenuHandler.bind(null, rowIndex, item) }, getTableRowRoleProps({ tableRole, firstIndex, rowIndex })),
210
+ selectionType !== undefined && (React.createElement(TableTdElement, { className: clsx(styles['selection-control']), isVisualRefresh: isVisualRefresh, isFirstRow: firstVisible, isLastRow: lastVisible, isSelected: isSelected, isNextSelected: isNextSelected, isPrevSelected: isPrevSelected, wrapLines: false, isEvenRow: isEven, stripedRows: stripedRows, hasSelection: hasSelection, hasFooter: hasFooter, stickyState: stickyState, columnId: selectionColumnId, tableRole: tableRole },
210
211
  React.createElement(SelectionControl, Object.assign({ onFocusDown: moveFocusDown, onFocusUp: moveFocusUp, onShiftToggle: updateShiftToggle }, getItemSelectionProps(item))))),
211
212
  visibleColumnDefinitions.map((column, colIndex) => {
212
213
  var _a;
@@ -232,7 +233,7 @@ const InternalTable = React.forwardRef((_a, ref) => {
232
233
  setLastSuccessfulEditCell([rowIndex, colIndex]);
233
234
  }
234
235
  }
235
- }, submitEdit: wrapWithInlineLoadingState(submitEdit), hasFooter: hasFooter, stripedRows: stripedRows, isEvenRow: isEven, columnId: (_a = column.id) !== null && _a !== void 0 ? _a : colIndex, stickyState: stickyState, isVisualRefresh: isVisualRefresh }));
236
+ }, submitEdit: wrapWithInlineLoadingState(submitEdit), hasFooter: hasFooter, stripedRows: stripedRows, isEvenRow: isEven, columnId: (_a = column.id) !== null && _a !== void 0 ? _a : colIndex, stickyState: stickyState, isVisualRefresh: isVisualRefresh, tableRole: tableRole }));
236
237
  })));
237
238
  })))),
238
239
  resizableColumns && React.createElement(ResizeTracker, null)),