@cloudscape-design/components 3.0.654 → 3.0.655

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.
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (6ea83631)";
2
+ export var PACKAGE_VERSION = "3.0.0 (5a4e58cf)";
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 (6ea83631)",
3
+ "PACKAGE_VERSION": "3.0.0 (5a4e58cf)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "6ea836312d04cdd2eacb7b5efb4b396d48b843fe"
2
+ "commit": "5a4e58cf2c1014a115842ae98839053dc9769286"
3
3
  }
package/package.json CHANGED
@@ -117,7 +117,7 @@
117
117
  "./internal/base-component/index.js",
118
118
  "./internal/base-component/styles.css.js"
119
119
  ],
120
- "version": "3.0.654",
120
+ "version": "3.0.655",
121
121
  "repository": {
122
122
  "type": "git",
123
123
  "url": "https://github.com/cloudscape-design/components.git"
@@ -73,7 +73,7 @@ export function InlineEditor({ ariaLabels, item, column, onEditEnd, submitEdit,
73
73
  React.createElement("form", { onSubmit: onSubmitClick, className: styles['body-cell-editor-form'] },
74
74
  React.createElement(FormField, { stretch: true, label: ariaLabel, constraintText: constraintText, __hideLabel: true, __disableGutters: true, i18nStrings: { errorIconAriaLabel }, errorText: validation(item, currentEditValue) },
75
75
  React.createElement("div", { className: styles['body-cell-editor-row'] },
76
- editingCell(item, cellContext),
76
+ React.createElement("div", { className: styles['body-cell-editor-row-editor'] }, editingCell(item, cellContext)),
77
77
  React.createElement("span", { className: styles['body-cell-editor-controls'] },
78
78
  React.createElement(SpaceBetween, { direction: "horizontal", size: "xxs" },
79
79
  !currentEditLoading ? (React.createElement(Button, { ariaLabel: (_b = ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.cancelEditLabel) === null || _b === void 0 ? void 0 : _b.call(ariaLabels, column), formAction: "none", iconName: "close", variant: "inline-icon", onClick: () => onCancel() })) : null,
@@ -1 +1 @@
1
- {"version":3,"file":"inline-editor.js","sourceRoot":"","sources":["../../../../src/table/body-cell/inline-editor.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,SAAS,MAAM,2BAA2B,CAAC;AAClD,OAAO,YAAY,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,SAA2B,MAAM,sCAAsC,CAAC;AAC/E,OAAO,UAAU,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,+BAA+B;AAC/B,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC;AAgB7B,MAAM,UAAU,YAAY,CAAW,EACrC,UAAU,EACV,IAAI,EACJ,MAAM,EACN,SAAS,EACT,UAAU,EACV,UAAU,GACkB;;IAC5B,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpE,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,EAAiB,CAAC;IAC1E,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IAEtC,MAAM,YAAY,GAAG,MAAM,CAAe,IAAI,CAAC,CAAC;IAEhD,MAAM,WAAW,GAAG;QAClB,YAAY,E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,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,eAAe,2DAAG,MAAM,CAAC,EAChD,UAAU,EAAC,MAAM,EACjB,QAAQ,EAAC,OAAO,EAChB,OAAO,EAAC,aAAa,EACrB,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,GACzB,CACH,CAAC,CAAC,CAAC,IAAI;gCACR,oBAAC,MAAM,IACL,SAAS,EAAE,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,eAAe,2DAAG,MAAM,CAAC,EAChD,UAAU,EAAC,QAAQ,EACnB,QAAQ,EAAC,OAAO,EAChB,OAAO,EAAC,aAAa,EACrB,OAAO,EAAE,kBAAkB,GAC3B,CACW;4BACf,oBAAC,UAAU,QACR,kBAAkB;gCACjB,CAAC,CAAC,IAAI,CAAC,+BAA+B,EAAE,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,kBAAkB,2DAAG,MAAM,CAAC,CAAC;gCACjF,CAAC,CAAC,EAAE,CACK,CACR,CACH,CACI,CACP,CACH,CACI,CACb,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport Button from '../../button/internal';\nimport FormField from '../../form-field/internal';\nimport SpaceBetween from '../../space-between/internal';\nimport { useClickAway } from './click-away';\nimport { TableProps } from '../interfaces';\nimport styles from './styles.css.js';\nimport { Optional } from '../../internal/types';\nimport FocusLock, { FocusLockRef } from '../../internal/components/focus-lock';\nimport LiveRegion from '../../internal/components/live-region';\nimport { useInternalI18n } from '../../i18n/context';\n\n// A function that does nothing\nconst noop = () => undefined;\n\ninterface OnEditEndOptions {\n cancelled: boolean;\n refocusCell: boolean;\n}\n\ninterface InlineEditorProps<ItemType> {\n ariaLabels: TableProps['ariaLabels'];\n column: TableProps.ColumnDefinition<ItemType>;\n item: ItemType;\n onEditEnd: (options: OnEditEndOptions) => void;\n submitEdit: TableProps.SubmitEditFunction<ItemType>;\n __onRender?: () => void;\n}\n\nexport function InlineEditor<ItemType>({\n ariaLabels,\n item,\n column,\n onEditEnd,\n submitEdit,\n __onRender,\n}: InlineEditorProps<ItemType>) {\n const [currentEditLoading, setCurrentEditLoading] = useState(false);\n const [currentEditValue, setCurrentEditValue] = useState<Optional<any>>();\n const i18n = useInternalI18n('table');\n\n const focusLockRef = useRef<FocusLockRef>(null);\n\n const cellContext = {\n currentValue: currentEditValue,\n setValue: setCurrentEditValue,\n };\n\n function finishEdit({ cancelled = false, refocusCell = true }: Partial<OnEditEndOptions> = {}) {\n if (!cancelled) {\n setCurrentEditValue(undefined);\n }\n onEditEnd({ cancelled, refocusCell: refocusCell });\n }\n\n async function onSubmitClick(evt: React.FormEvent) {\n evt.preventDefault();\n if (currentEditValue === undefined) {\n finishEdit();\n return;\n }\n\n setCurrentEditLoading(true);\n try {\n await submitEdit(item, column, currentEditValue);\n setCurrentEditLoading(false);\n finishEdit();\n } catch (e) {\n setCurrentEditLoading(false);\n focusLockRef.current?.focusFirst();\n }\n }\n\n function onCancel({ reFocusEditedCell = true } = {}) {\n if (currentEditLoading) {\n return;\n }\n finishEdit({ cancelled: true, refocusCell: reFocusEditedCell });\n }\n\n function handleEscape(event: React.KeyboardEvent): void {\n if (event.key === 'Escape') {\n onCancel();\n }\n }\n\n const clickAwayRef = useClickAway(() => onCancel({ reFocusEditedCell: false }));\n\n useEffect(() => {\n if (__onRender) {\n const timer = setTimeout(__onRender, 1);\n return () => clearTimeout(timer);\n }\n }, [__onRender]);\n\n // asserting non-undefined editConfig here because this component is unreachable otherwise\n const {\n ariaLabel = undefined,\n validation = noop,\n errorIconAriaLabel,\n constraintText,\n editingCell,\n } = column.editConfig!;\n\n return (\n <FocusLock restoreFocus={true} ref={focusLockRef}>\n <div\n role=\"dialog\"\n ref={clickAwayRef}\n aria-label={ariaLabels?.activateEditLabel?.(column, item)}\n onKeyDown={handleEscape}\n >\n <form onSubmit={onSubmitClick} className={styles['body-cell-editor-form']}>\n <FormField\n stretch={true}\n label={ariaLabel}\n constraintText={constraintText}\n __hideLabel={true}\n __disableGutters={true}\n i18nStrings={{ errorIconAriaLabel }}\n errorText={validation(item, currentEditValue)}\n >\n <div className={styles['body-cell-editor-row']}>\n {editingCell(item, cellContext)}\n <span className={styles['body-cell-editor-controls']}>\n <SpaceBetween direction=\"horizontal\" size=\"xxs\">\n {!currentEditLoading ? (\n <Button\n ariaLabel={ariaLabels?.cancelEditLabel?.(column)}\n formAction=\"none\"\n iconName=\"close\"\n variant=\"inline-icon\"\n onClick={() => onCancel()}\n />\n ) : null}\n <Button\n ariaLabel={ariaLabels?.submitEditLabel?.(column)}\n formAction=\"submit\"\n iconName=\"check\"\n variant=\"inline-icon\"\n loading={currentEditLoading}\n />\n </SpaceBetween>\n <LiveRegion>\n {currentEditLoading\n ? i18n('ariaLabels.submittingEditText', ariaLabels?.submittingEditText?.(column))\n : ''}\n </LiveRegion>\n </span>\n </div>\n </FormField>\n </form>\n </div>\n </FocusLock>\n );\n}\n"]}
1
+ {"version":3,"file":"inline-editor.js","sourceRoot":"","sources":["../../../../src/table/body-cell/inline-editor.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,SAAS,MAAM,2BAA2B,CAAC;AAClD,OAAO,YAAY,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,SAA2B,MAAM,sCAAsC,CAAC;AAC/E,OAAO,UAAU,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,+BAA+B;AAC/B,MAAM,IA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All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport Button from '../../button/internal';\nimport FormField from '../../form-field/internal';\nimport SpaceBetween from '../../space-between/internal';\nimport { useClickAway } from './click-away';\nimport { TableProps } from '../interfaces';\nimport styles from './styles.css.js';\nimport { Optional } from '../../internal/types';\nimport FocusLock, { FocusLockRef } from '../../internal/components/focus-lock';\nimport LiveRegion from '../../internal/components/live-region';\nimport { useInternalI18n } from '../../i18n/context';\n\n// A function that does nothing\nconst noop = () => undefined;\n\ninterface OnEditEndOptions {\n cancelled: boolean;\n refocusCell: boolean;\n}\n\ninterface InlineEditorProps<ItemType> {\n ariaLabels: TableProps['ariaLabels'];\n column: TableProps.ColumnDefinition<ItemType>;\n item: ItemType;\n onEditEnd: (options: OnEditEndOptions) => void;\n submitEdit: TableProps.SubmitEditFunction<ItemType>;\n __onRender?: () => void;\n}\n\nexport function InlineEditor<ItemType>({\n ariaLabels,\n item,\n column,\n onEditEnd,\n submitEdit,\n __onRender,\n}: InlineEditorProps<ItemType>) {\n const [currentEditLoading, setCurrentEditLoading] = useState(false);\n const [currentEditValue, setCurrentEditValue] = useState<Optional<any>>();\n const i18n = useInternalI18n('table');\n\n const focusLockRef = useRef<FocusLockRef>(null);\n\n const cellContext = {\n currentValue: currentEditValue,\n setValue: setCurrentEditValue,\n };\n\n function finishEdit({ cancelled = false, refocusCell = true }: Partial<OnEditEndOptions> = {}) {\n if (!cancelled) {\n setCurrentEditValue(undefined);\n }\n onEditEnd({ cancelled, refocusCell: refocusCell });\n }\n\n async function onSubmitClick(evt: React.FormEvent) {\n evt.preventDefault();\n if (currentEditValue === undefined) {\n finishEdit();\n return;\n }\n\n setCurrentEditLoading(true);\n try {\n await submitEdit(item, column, currentEditValue);\n setCurrentEditLoading(false);\n finishEdit();\n } catch (e) {\n setCurrentEditLoading(false);\n focusLockRef.current?.focusFirst();\n }\n }\n\n function onCancel({ reFocusEditedCell = true } = {}) {\n if (currentEditLoading) {\n return;\n }\n finishEdit({ cancelled: true, refocusCell: reFocusEditedCell });\n }\n\n function handleEscape(event: React.KeyboardEvent): void {\n if (event.key === 'Escape') {\n onCancel();\n }\n }\n\n const clickAwayRef = useClickAway(() => onCancel({ reFocusEditedCell: false }));\n\n useEffect(() => {\n if (__onRender) {\n const timer = setTimeout(__onRender, 1);\n return () => clearTimeout(timer);\n }\n }, [__onRender]);\n\n // asserting non-undefined editConfig here because this component is unreachable otherwise\n const {\n ariaLabel = undefined,\n validation = noop,\n errorIconAriaLabel,\n constraintText,\n editingCell,\n } = column.editConfig!;\n\n return (\n <FocusLock restoreFocus={true} ref={focusLockRef}>\n <div\n role=\"dialog\"\n ref={clickAwayRef}\n aria-label={ariaLabels?.activateEditLabel?.(column, item)}\n onKeyDown={handleEscape}\n >\n <form onSubmit={onSubmitClick} className={styles['body-cell-editor-form']}>\n <FormField\n stretch={true}\n label={ariaLabel}\n constraintText={constraintText}\n __hideLabel={true}\n __disableGutters={true}\n i18nStrings={{ errorIconAriaLabel }}\n errorText={validation(item, currentEditValue)}\n >\n <div className={styles['body-cell-editor-row']}>\n <div className={styles['body-cell-editor-row-editor']}>{editingCell(item, cellContext)}</div>\n <span className={styles['body-cell-editor-controls']}>\n <SpaceBetween direction=\"horizontal\" size=\"xxs\">\n {!currentEditLoading ? (\n <Button\n ariaLabel={ariaLabels?.cancelEditLabel?.(column)}\n formAction=\"none\"\n iconName=\"close\"\n variant=\"inline-icon\"\n onClick={() => onCancel()}\n />\n ) : null}\n <Button\n ariaLabel={ariaLabels?.submitEditLabel?.(column)}\n formAction=\"submit\"\n iconName=\"check\"\n variant=\"inline-icon\"\n loading={currentEditLoading}\n />\n </SpaceBetween>\n <LiveRegion>\n {currentEditLoading\n ? i18n('ariaLabels.submittingEditText', ariaLabels?.submittingEditText?.(column))\n : ''}\n </LiveRegion>\n </span>\n </div>\n </FormField>\n </form>\n </div>\n </FocusLock>\n );\n}\n"]}
@@ -1,50 +1,51 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "expandable-toggle-wrapper": "awsui_expandable-toggle-wrapper_c6tup_dtubq_97",
5
- "body-cell": "awsui_body-cell_c6tup_dtubq_105",
6
- "body-cell-content": "awsui_body-cell-content_c6tup_dtubq_113",
7
- "expandable-level-0": "awsui_expandable-level-0_c6tup_dtubq_116",
8
- "expandable-level-1": "awsui_expandable-level-1_c6tup_dtubq_119",
9
- "expandable-level-2": "awsui_expandable-level-2_c6tup_dtubq_122",
10
- "expandable-level-3": "awsui_expandable-level-3_c6tup_dtubq_125",
11
- "expandable-level-4": "awsui_expandable-level-4_c6tup_dtubq_128",
12
- "expandable-level-5": "awsui_expandable-level-5_c6tup_dtubq_131",
13
- "expandable-level-6": "awsui_expandable-level-6_c6tup_dtubq_134",
14
- "expandable-level-7": "awsui_expandable-level-7_c6tup_dtubq_137",
15
- "expandable-level-8": "awsui_expandable-level-8_c6tup_dtubq_140",
16
- "expandable-level-9": "awsui_expandable-level-9_c6tup_dtubq_143",
17
- "expandable-level-next": "awsui_expandable-level-next_c6tup_dtubq_146",
18
- "body-cell-wrap": "awsui_body-cell-wrap_c6tup_dtubq_163",
19
- "is-visual-refresh": "awsui_is-visual-refresh_c6tup_dtubq_177",
20
- "has-striped-rows": "awsui_has-striped-rows_c6tup_dtubq_189",
21
- "body-cell-edit-active": "awsui_body-cell-edit-active_c6tup_dtubq_225",
22
- "body-cell-interactive": "awsui_body-cell-interactive_c6tup_dtubq_225",
23
- "body-cell-editable": "awsui_body-cell-editable_c6tup_dtubq_225",
24
- "has-striped-rows-sticky-cell-pad-inline-start": "awsui_has-striped-rows-sticky-cell-pad-inline-start_c6tup_dtubq_297",
25
- "has-selection": "awsui_has-selection_c6tup_dtubq_333",
26
- "body-cell-first-row": "awsui_body-cell-first-row_c6tup_dtubq_376",
27
- "body-cell-last-row": "awsui_body-cell-last-row_c6tup_dtubq_379",
28
- "body-cell-selected": "awsui_body-cell-selected_c6tup_dtubq_379",
29
- "has-footer": "awsui_has-footer_c6tup_dtubq_379",
30
- "body-cell-shaded": "awsui_body-cell-shaded_c6tup_dtubq_389",
31
- "sticky-cell": "awsui_sticky-cell_c6tup_dtubq_417",
32
- "sticky-cell-pad-left": "awsui_sticky-cell-pad-left_c6tup_dtubq_425",
33
- "sticky-cell-last-inline-end": "awsui_sticky-cell-last-inline-end_c6tup_dtubq_475",
34
- "sticky-cell-last-inline-start": "awsui_sticky-cell-last-inline-start_c6tup_dtubq_484",
35
- "body-cell-next-selected": "awsui_body-cell-next-selected_c6tup_dtubq_517",
36
- "body-cell-prev-selected": "awsui_body-cell-prev-selected_c6tup_dtubq_523",
37
- "body-cell-editor-wrapper": "awsui_body-cell-editor-wrapper_c6tup_dtubq_549",
38
- "body-cell-success": "awsui_body-cell-success_c6tup_dtubq_556",
39
- "body-cell-editor": "awsui_body-cell-editor_c6tup_dtubq_549",
40
- "body-cell-editor-disabled": "awsui_body-cell-editor-disabled_c6tup_dtubq_583",
41
- "body-cell-editor-form": "awsui_body-cell-editor-form_c6tup_dtubq_592",
42
- "body-cell-editor-row": "awsui_body-cell-editor-row_c6tup_dtubq_602",
43
- "body-cell-editor-controls": "awsui_body-cell-editor-controls_c6tup_dtubq_612",
44
- "body-cell-expandable": "awsui_body-cell-expandable_c6tup_dtubq_615",
45
- "resizable-columns": "awsui_resizable-columns_c6tup_dtubq_636",
46
- "expandable-cell-content": "awsui_expandable-cell-content_c6tup_dtubq_639",
47
- "body-cell-has-success": "awsui_body-cell-has-success_c6tup_dtubq_708",
48
- "body-cell-edit-disabled-popover": "awsui_body-cell-edit-disabled-popover_c6tup_dtubq_708"
4
+ "expandable-toggle-wrapper": "awsui_expandable-toggle-wrapper_c6tup_14u7g_97",
5
+ "body-cell": "awsui_body-cell_c6tup_14u7g_105",
6
+ "body-cell-content": "awsui_body-cell-content_c6tup_14u7g_113",
7
+ "expandable-level-0": "awsui_expandable-level-0_c6tup_14u7g_116",
8
+ "expandable-level-1": "awsui_expandable-level-1_c6tup_14u7g_119",
9
+ "expandable-level-2": "awsui_expandable-level-2_c6tup_14u7g_122",
10
+ "expandable-level-3": "awsui_expandable-level-3_c6tup_14u7g_125",
11
+ "expandable-level-4": "awsui_expandable-level-4_c6tup_14u7g_128",
12
+ "expandable-level-5": "awsui_expandable-level-5_c6tup_14u7g_131",
13
+ "expandable-level-6": "awsui_expandable-level-6_c6tup_14u7g_134",
14
+ "expandable-level-7": "awsui_expandable-level-7_c6tup_14u7g_137",
15
+ "expandable-level-8": "awsui_expandable-level-8_c6tup_14u7g_140",
16
+ "expandable-level-9": "awsui_expandable-level-9_c6tup_14u7g_143",
17
+ "expandable-level-next": "awsui_expandable-level-next_c6tup_14u7g_146",
18
+ "body-cell-wrap": "awsui_body-cell-wrap_c6tup_14u7g_163",
19
+ "is-visual-refresh": "awsui_is-visual-refresh_c6tup_14u7g_177",
20
+ "has-striped-rows": "awsui_has-striped-rows_c6tup_14u7g_189",
21
+ "body-cell-edit-active": "awsui_body-cell-edit-active_c6tup_14u7g_225",
22
+ "body-cell-interactive": "awsui_body-cell-interactive_c6tup_14u7g_225",
23
+ "body-cell-editable": "awsui_body-cell-editable_c6tup_14u7g_225",
24
+ "has-striped-rows-sticky-cell-pad-inline-start": "awsui_has-striped-rows-sticky-cell-pad-inline-start_c6tup_14u7g_297",
25
+ "has-selection": "awsui_has-selection_c6tup_14u7g_333",
26
+ "body-cell-first-row": "awsui_body-cell-first-row_c6tup_14u7g_376",
27
+ "body-cell-last-row": "awsui_body-cell-last-row_c6tup_14u7g_379",
28
+ "body-cell-selected": "awsui_body-cell-selected_c6tup_14u7g_379",
29
+ "has-footer": "awsui_has-footer_c6tup_14u7g_379",
30
+ "body-cell-shaded": "awsui_body-cell-shaded_c6tup_14u7g_389",
31
+ "sticky-cell": "awsui_sticky-cell_c6tup_14u7g_417",
32
+ "sticky-cell-pad-left": "awsui_sticky-cell-pad-left_c6tup_14u7g_425",
33
+ "sticky-cell-last-inline-end": "awsui_sticky-cell-last-inline-end_c6tup_14u7g_475",
34
+ "sticky-cell-last-inline-start": "awsui_sticky-cell-last-inline-start_c6tup_14u7g_484",
35
+ "body-cell-next-selected": "awsui_body-cell-next-selected_c6tup_14u7g_517",
36
+ "body-cell-prev-selected": "awsui_body-cell-prev-selected_c6tup_14u7g_523",
37
+ "body-cell-editor-wrapper": "awsui_body-cell-editor-wrapper_c6tup_14u7g_549",
38
+ "body-cell-success": "awsui_body-cell-success_c6tup_14u7g_556",
39
+ "body-cell-editor": "awsui_body-cell-editor_c6tup_14u7g_549",
40
+ "body-cell-editor-disabled": "awsui_body-cell-editor-disabled_c6tup_14u7g_583",
41
+ "body-cell-editor-form": "awsui_body-cell-editor-form_c6tup_14u7g_592",
42
+ "body-cell-editor-row": "awsui_body-cell-editor-row_c6tup_14u7g_602",
43
+ "body-cell-editor-controls": "awsui_body-cell-editor-controls_c6tup_14u7g_612",
44
+ "body-cell-editor-row-editor": "awsui_body-cell-editor-row-editor_c6tup_14u7g_615",
45
+ "body-cell-expandable": "awsui_body-cell-expandable_c6tup_14u7g_618",
46
+ "resizable-columns": "awsui_resizable-columns_c6tup_14u7g_639",
47
+ "expandable-cell-content": "awsui_expandable-cell-content_c6tup_14u7g_642",
48
+ "body-cell-has-success": "awsui_body-cell-has-success_c6tup_14u7g_711",
49
+ "body-cell-edit-disabled-popover": "awsui_body-cell-edit-disabled-popover_c6tup_14u7g_711"
49
50
  };
50
51