@cloudscape-design/components-themeable 3.0.832 → 3.0.834
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/{file-upload → internal/components}/file-input/styles.scss +7 -13
- package/lib/internal/scss/s3-resource-selector/test-classes/styles.scss +8 -0
- package/lib/internal/scss/table/body-cell/styles.scss +19 -40
- package/lib/internal/template/app-layout/utils/use-drawers.d.ts.map +1 -1
- package/lib/internal/template/app-layout/utils/use-drawers.js +5 -1
- package/lib/internal/template/app-layout/utils/use-drawers.js.map +1 -1
- package/lib/internal/template/file-upload/internal.d.ts.map +1 -1
- package/lib/internal/template/file-upload/internal.js +4 -4
- package/lib/internal/template/file-upload/internal.js.map +1 -1
- package/lib/internal/template/icon/generated/icons.d.ts +26 -0
- package/lib/internal/template/icon/generated/icons.d.ts.map +1 -1
- package/lib/internal/template/icon/generated/icons.js +81 -4
- package/lib/internal/template/icon/generated/icons.js.map +1 -1
- package/lib/internal/template/icon/interfaces.d.ts +1 -1
- package/lib/internal/template/icon/interfaces.d.ts.map +1 -1
- package/lib/internal/template/icon/interfaces.js.map +1 -1
- package/lib/internal/template/internal/components/file-input/index.d.ts +6 -0
- package/lib/internal/template/internal/components/file-input/index.d.ts.map +1 -0
- package/lib/internal/template/{file-upload → internal/components}/file-input/index.js +24 -16
- package/lib/internal/template/internal/components/file-input/index.js.map +1 -0
- package/lib/internal/template/internal/components/file-input/interfaces.d.ts +53 -0
- package/lib/internal/template/internal/components/file-input/interfaces.d.ts.map +1 -0
- package/lib/internal/template/internal/components/file-input/interfaces.js +2 -0
- package/lib/internal/template/internal/components/file-input/interfaces.js.map +1 -0
- package/lib/internal/template/internal/components/file-input/styles.css.js +10 -0
- package/lib/internal/template/{file-upload → internal/components}/file-input/styles.scoped.css +9 -12
- package/lib/internal/template/internal/components/file-input/styles.selectors.js +11 -0
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/internal/environment.json +1 -1
- package/lib/internal/template/s3-resource-selector/s3-modal/index.d.ts.map +1 -1
- package/lib/internal/template/s3-resource-selector/s3-modal/index.js +2 -1
- package/lib/internal/template/s3-resource-selector/s3-modal/index.js.map +1 -1
- package/lib/internal/template/s3-resource-selector/test-classes/styles.css.js +6 -0
- package/lib/internal/template/s3-resource-selector/test-classes/styles.scoped.css +7 -0
- package/lib/internal/template/s3-resource-selector/test-classes/styles.selectors.js +7 -0
- package/lib/internal/template/table/body-cell/disabled-inline-editor.d.ts +1 -1
- package/lib/internal/template/table/body-cell/disabled-inline-editor.d.ts.map +1 -1
- package/lib/internal/template/table/body-cell/disabled-inline-editor.js +4 -4
- package/lib/internal/template/table/body-cell/disabled-inline-editor.js.map +1 -1
- package/lib/internal/template/table/body-cell/index.d.ts +0 -1
- package/lib/internal/template/table/body-cell/index.d.ts.map +1 -1
- package/lib/internal/template/table/body-cell/index.js +4 -4
- package/lib/internal/template/table/body-cell/index.js.map +1 -1
- package/lib/internal/template/table/body-cell/styles.css.js +46 -47
- package/lib/internal/template/table/body-cell/styles.scoped.css +301 -331
- package/lib/internal/template/table/body-cell/styles.selectors.js +46 -47
- package/lib/internal/template/test-utils/dom/file-upload/index.js +16 -16
- package/lib/internal/template/test-utils/dom/file-upload/index.js.map +1 -1
- package/lib/internal/template/test-utils/dom/internal/file-input.d.ts +7 -0
- package/lib/internal/template/test-utils/dom/internal/file-input.js +18 -0
- package/lib/internal/template/test-utils/dom/internal/file-input.js.map +1 -0
- package/lib/internal/template/test-utils/dom/s3-resource-selector/index.js +2 -1
- package/lib/internal/template/test-utils/dom/s3-resource-selector/index.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/file-upload/index.js +16 -16
- package/lib/internal/template/test-utils/selectors/file-upload/index.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/internal/file-input.d.ts +7 -0
- package/lib/internal/template/test-utils/selectors/internal/file-input.js +18 -0
- package/lib/internal/template/test-utils/selectors/internal/file-input.js.map +1 -0
- package/lib/internal/template/test-utils/selectors/s3-resource-selector/index.js +2 -1
- package/lib/internal/template/test-utils/selectors/s3-resource-selector/index.js.map +1 -1
- package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/lib/internal/template/file-upload/file-input/index.d.ts +0 -14
- package/lib/internal/template/file-upload/file-input/index.d.ts.map +0 -1
- package/lib/internal/template/file-upload/file-input/index.js.map +0 -1
- package/lib/internal/template/file-upload/file-input/styles.css.js +0 -9
- package/lib/internal/template/file-upload/file-input/styles.selectors.js +0 -10
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FileInputProps } from './interfaces';
|
|
3
|
+
export { FileInputProps };
|
|
4
|
+
declare const InternalFileInput: React.ForwardRefExoticComponent<FileInputProps & React.RefAttributes<FileInputProps.Ref>>;
|
|
5
|
+
export default InternalFileInput;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/file-input/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAa7E,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,QAAA,MAAM,iBAAiB,2FAqGtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -3,17 +3,19 @@
|
|
|
3
3
|
import { __rest } from "tslib";
|
|
4
4
|
import React, { useEffect, useRef, useState } from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
6
|
+
import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
|
|
7
|
+
import InternalButton from '../../../button/internal';
|
|
8
|
+
import { useFormFieldContext } from '../../../contexts/form-field';
|
|
9
|
+
import ScreenreaderOnly from '../../components/screenreader-only';
|
|
10
|
+
import { fireNonCancelableEvent } from '../../events';
|
|
11
|
+
import checkControlled from '../../hooks/check-controlled';
|
|
12
|
+
import useForwardFocus from '../../hooks/forward-focus';
|
|
13
|
+
import { useUniqueId } from '../../hooks/use-unique-id';
|
|
14
|
+
import { joinStrings } from '../../utils/strings';
|
|
12
15
|
import styles from './styles.css.js';
|
|
13
|
-
|
|
14
|
-
function FileInput(_a, ref) {
|
|
16
|
+
const InternalFileInput = React.forwardRef((_a, ref) => {
|
|
15
17
|
var _b;
|
|
16
|
-
var { accept, ariaRequired, multiple, value, onChange, children } = _a, restProps = __rest(_a, ["accept", "ariaRequired", "multiple", "value", "onChange", "children"]);
|
|
18
|
+
var { accept, ariaRequired, ariaLabel, multiple = false, value, onChange, variant = 'button', children } = _a, restProps = __rest(_a, ["accept", "ariaRequired", "ariaLabel", "multiple", "value", "onChange", "variant", "children"]);
|
|
17
19
|
const uploadInputRef = useRef(null);
|
|
18
20
|
const uploadButtonLabelId = useUniqueId('upload-button-label');
|
|
19
21
|
const formFieldContext = useFormFieldContext(restProps);
|
|
@@ -25,9 +27,11 @@ function FileInput(_a, ref) {
|
|
|
25
27
|
const onUploadInputFocus = () => setIsFocused(true);
|
|
26
28
|
const onUploadInputBlur = () => setIsFocused(false);
|
|
27
29
|
const onUploadInputChange = ({ target }) => {
|
|
28
|
-
onChange
|
|
30
|
+
fireNonCancelableEvent(onChange, { value: target.files ? Array.from(target.files) : [] });
|
|
29
31
|
};
|
|
32
|
+
checkControlled('FileInput', 'value', value, 'onChange', onChange);
|
|
30
33
|
const nativeAttributes = {
|
|
34
|
+
'aria-label': ariaLabel || children,
|
|
31
35
|
'aria-labelledby': joinStrings(formFieldContext.ariaLabelledby, uploadButtonLabelId),
|
|
32
36
|
'aria-describedby': formFieldContext.ariaDescribedby,
|
|
33
37
|
};
|
|
@@ -37,9 +41,12 @@ function FileInput(_a, ref) {
|
|
|
37
41
|
if (ariaRequired) {
|
|
38
42
|
nativeAttributes['aria-required'] = true;
|
|
39
43
|
}
|
|
44
|
+
if (variant === 'icon' && !ariaLabel) {
|
|
45
|
+
warnOnce('FileInput', 'Aria label is required with icon variant.');
|
|
46
|
+
}
|
|
40
47
|
// Synchronizing component's value with the native file input state.
|
|
41
48
|
useEffect(() => {
|
|
42
|
-
|
|
49
|
+
/* istanbul ignore next: The DataTransfer is not available in jsdom. */
|
|
43
50
|
if (window.DataTransfer) {
|
|
44
51
|
const dataTransfer = new DataTransfer();
|
|
45
52
|
for (const file of value) {
|
|
@@ -51,9 +58,10 @@ function FileInput(_a, ref) {
|
|
|
51
58
|
uploadInputRef.current.value = ''; // reset value to allow calling onChange when the same file is uploaded again
|
|
52
59
|
}
|
|
53
60
|
}, [value]);
|
|
54
|
-
return (React.createElement("div", { className: styles
|
|
55
|
-
React.createElement("input", Object.assign({ id: controlId, ref: uploadInputRef, type: "file", hidden: false, multiple: multiple, accept: accept, onChange: onUploadInputChange, onFocus: onUploadInputFocus, onBlur: onUploadInputBlur, className: styles['
|
|
56
|
-
React.createElement(InternalButton, { iconName: "upload", formAction: "none", onClick: onUploadButtonClick, className: clsx(styles['
|
|
57
|
-
React.createElement(ScreenreaderOnly, { id: uploadButtonLabelId }, children)));
|
|
58
|
-
}
|
|
61
|
+
return (React.createElement("div", { className: clsx(styles.root) },
|
|
62
|
+
React.createElement("input", Object.assign({ id: controlId, ref: uploadInputRef, type: "file", hidden: false, multiple: multiple, accept: accept, onChange: onUploadInputChange, onFocus: onUploadInputFocus, onBlur: onUploadInputBlur, className: clsx(styles['file-input'], styles.hidden) }, nativeAttributes)),
|
|
63
|
+
React.createElement(InternalButton, { iconName: "upload", variant: variant === 'icon' ? 'icon' : undefined, formAction: "none", onClick: onUploadButtonClick, className: clsx(styles['file-input-button'], isFocused && styles['force-focus-outline']), __nativeAttributes: { tabIndex: -1, 'aria-hidden': true } }, variant === 'button' && children),
|
|
64
|
+
React.createElement(ScreenreaderOnly, { id: uploadButtonLabelId }, ariaLabel || children)));
|
|
65
|
+
});
|
|
66
|
+
export default InternalFileInput;
|
|
59
67
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/file-input/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAoB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,cAAc,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,gBAAgB,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,MAAM,iBAAiB,GAAG,KAAK,CAAC,UAAU,CACxC,CACE,EAUiB,EACjB,GAA4B,EAC5B,EAAE;;QAZF,EACE,MAAM,EACN,YAAY,EACZ,SAAS,EACT,QAAQ,GAAG,KAAK,EAChB,KAAK,EACL,QAAQ,EACR,OAAO,GAAG,QAAQ,EAClB,QAAQ,OAEO,EADZ,SAAS,cATd,+FAUC,CADa;IAId,MAAM,cAAc,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IACtD,MAAM,mBAAmB,GAAG,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAC/D,MAAM,gBAAgB,GAAG,mBAAm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CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,SAAS,IAAI,MAAM,CAAC,qBAAqB,CAAC,CAAC,EACxF,kBAAkB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,IAExD,OAAO,KAAK,QAAQ,IAAI,QAAQ,CAClB;QAGjB,oBAAC,gBAAgB,IAAC,EAAE,EAAE,mBAAmB,IAAG,SAAS,IAAI,QAAQ,CAAoB,CACjF,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { ChangeEvent, Ref, useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalButton from '../../../button/internal';\nimport { useFormFieldContext } from '../../../contexts/form-field';\nimport ScreenreaderOnly from '../../components/screenreader-only';\nimport { fireNonCancelableEvent } from '../../events';\nimport checkControlled from '../../hooks/check-controlled';\nimport useForwardFocus from '../../hooks/forward-focus';\nimport { useUniqueId } from '../../hooks/use-unique-id';\nimport { joinStrings } from '../../utils/strings';\nimport { FileInputProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\nexport { FileInputProps };\n\nconst InternalFileInput = React.forwardRef(\n (\n {\n accept,\n ariaRequired,\n ariaLabel,\n multiple = false,\n value,\n onChange,\n variant = 'button',\n children,\n ...restProps\n }: FileInputProps,\n ref: Ref<FileInputProps.Ref>\n ) => {\n const uploadInputRef = useRef<HTMLInputElement>(null);\n const uploadButtonLabelId = useUniqueId('upload-button-label');\n const formFieldContext = useFormFieldContext(restProps);\n const selfControlId = useUniqueId('upload-input');\n const controlId = formFieldContext.controlId ?? selfControlId;\n\n useForwardFocus(ref, uploadInputRef);\n\n const [isFocused, setIsFocused] = useState(false);\n const onUploadButtonClick = () => uploadInputRef.current?.click();\n const onUploadInputFocus = () => setIsFocused(true);\n const onUploadInputBlur = () => setIsFocused(false);\n\n const onUploadInputChange = ({ target }: ChangeEvent<HTMLInputElement>) => {\n fireNonCancelableEvent(onChange, { value: target.files ? Array.from(target.files) : [] });\n };\n\n checkControlled('FileInput', 'value', value, 'onChange', onChange);\n\n const nativeAttributes: React.HTMLAttributes<HTMLInputElement> = {\n 'aria-label': ariaLabel || children,\n 'aria-labelledby': joinStrings(formFieldContext.ariaLabelledby, uploadButtonLabelId),\n 'aria-describedby': formFieldContext.ariaDescribedby,\n };\n if (formFieldContext.invalid) {\n nativeAttributes['aria-invalid'] = true;\n }\n if (ariaRequired) {\n nativeAttributes['aria-required'] = true;\n }\n\n if (variant === 'icon' && !ariaLabel) {\n warnOnce('FileInput', 'Aria label is required with icon variant.');\n }\n\n // Synchronizing component's value with the native file input state.\n useEffect(() => {\n /* istanbul ignore next: The DataTransfer is not available in jsdom. */\n if (window.DataTransfer) {\n const dataTransfer = new DataTransfer();\n for (const file of value) {\n dataTransfer.items.add(file);\n }\n uploadInputRef.current!.files = dataTransfer.files;\n }\n if (uploadInputRef.current) {\n uploadInputRef.current.value = ''; // reset value to allow calling onChange when the same file is uploaded again\n }\n }, [value]);\n\n return (\n <div className={clsx(styles.root)}>\n {/* This is the actual interactive and accessible file-upload element. */}\n {/* It is visually hidden to achieve the desired UX design. */}\n <input\n id={controlId}\n ref={uploadInputRef}\n type=\"file\"\n hidden={false}\n multiple={multiple}\n accept={accept}\n onChange={onUploadInputChange}\n onFocus={onUploadInputFocus}\n onBlur={onUploadInputBlur}\n className={clsx(styles['file-input'], styles.hidden)}\n {...nativeAttributes}\n />\n\n {/* The button is decorative. It dispatches clicks to the file input and is ARIA-hidden. */}\n {/* When the input is focused the focus outline is forced on the button. */}\n <InternalButton\n iconName=\"upload\"\n variant={variant === 'icon' ? 'icon' : undefined}\n formAction=\"none\"\n onClick={onUploadButtonClick}\n className={clsx(styles['file-input-button'], isFocused && styles['force-focus-outline'])}\n __nativeAttributes={{ tabIndex: -1, 'aria-hidden': true }}\n >\n {variant === 'button' && children}\n </InternalButton>\n\n {/* The file input needs to be labelled with provided content. Can't use the button because it is ARIA-hidden. */}\n <ScreenreaderOnly id={uploadButtonLabelId}>{ariaLabel || children}</ScreenreaderOnly>\n </div>\n );\n }\n);\n\nexport default InternalFileInput;\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { BaseComponentProps } from '../../base-component';
|
|
2
|
+
import { FormFieldCommonValidationControlProps } from '../../context/form-field-context';
|
|
3
|
+
import { NonCancelableEventHandler } from '../../events';
|
|
4
|
+
export interface FileInputProps extends BaseComponentProps, FormFieldCommonValidationControlProps {
|
|
5
|
+
/**
|
|
6
|
+
* Variant of the file input. Defaults to "button".
|
|
7
|
+
*/
|
|
8
|
+
variant?: 'button' | 'icon';
|
|
9
|
+
/**
|
|
10
|
+
* Adds `aria-label` to the file input element. Use this to provide an accessible name for file inputs
|
|
11
|
+
* that don't have visible text, and to distinguish between multiple file inputs with identical visible text.
|
|
12
|
+
*/
|
|
13
|
+
ariaLabel?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Text displayed in the file input component. Used as the aria label if ariaLabel is not defined.
|
|
16
|
+
* @displayname text
|
|
17
|
+
*/
|
|
18
|
+
children?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Specifies the native file input `accept` attribute to describe the allow-list of file types.
|
|
21
|
+
*/
|
|
22
|
+
accept?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Specifies whether to add aria-required to the file upload control.
|
|
25
|
+
*/
|
|
26
|
+
ariaRequired?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Specifies the native file input `multiple` attribute to allow users entering more than one file.
|
|
29
|
+
*/
|
|
30
|
+
multiple?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Called when the user selects new file(s), or removes a file.
|
|
33
|
+
* The event `detail` contains the current value of the component.
|
|
34
|
+
*/
|
|
35
|
+
onChange: NonCancelableEventHandler<FileInputProps.ChangeDetail>;
|
|
36
|
+
/**
|
|
37
|
+
* Specifies the currently selected file(s).
|
|
38
|
+
* If you want to clear the selection, use empty array.
|
|
39
|
+
*/
|
|
40
|
+
value: ReadonlyArray<File>;
|
|
41
|
+
}
|
|
42
|
+
export declare namespace FileInputProps {
|
|
43
|
+
interface ChangeDetail {
|
|
44
|
+
value: File[];
|
|
45
|
+
}
|
|
46
|
+
interface Ref {
|
|
47
|
+
/**
|
|
48
|
+
* Sets focus on the file upload button.
|
|
49
|
+
*/
|
|
50
|
+
focus(): void;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/file-input/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qCAAqC,EAAE,MAAM,kCAAkC,CAAC;AACzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,WAAW,cAAe,SAAQ,kBAAkB,EAAE,qCAAqC;IAC/F;;OAEG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAE5B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,QAAQ,EAAE,yBAAyB,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IAEjE;;;OAGG;IACH,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,yBAAiB,cAAc,CAAC;IAC9B,UAAiB,YAAY;QAC3B,KAAK,EAAE,IAAI,EAAE,CAAC;KACf;IAED,UAAiB,GAAG;QAClB;;WAEG;QACH,KAAK,IAAI,IAAI,CAAC;KACf;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/internal/components/file-input/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../../base-component';\nimport { FormFieldCommonValidationControlProps } from '../../context/form-field-context';\nimport { NonCancelableEventHandler } from '../../events';\n\nexport interface FileInputProps extends BaseComponentProps, FormFieldCommonValidationControlProps {\n /**\n * Variant of the file input. Defaults to \"button\".\n */\n variant?: 'button' | 'icon';\n\n /**\n * Adds `aria-label` to the file input element. Use this to provide an accessible name for file inputs\n * that don't have visible text, and to distinguish between multiple file inputs with identical visible text.\n */\n ariaLabel?: string;\n\n /**\n * Text displayed in the file input component. Used as the aria label if ariaLabel is not defined.\n * @displayname text\n */\n children?: string;\n\n /**\n * Specifies the native file input `accept` attribute to describe the allow-list of file types.\n */\n accept?: string;\n\n /**\n * Specifies whether to add aria-required to the file upload control.\n */\n ariaRequired?: boolean;\n\n /**\n * Specifies the native file input `multiple` attribute to allow users entering more than one file.\n */\n multiple?: boolean;\n\n /**\n * Called when the user selects new file(s), or removes a file.\n * The event `detail` contains the current value of the component.\n */\n onChange: NonCancelableEventHandler<FileInputProps.ChangeDetail>;\n\n /**\n * Specifies the currently selected file(s).\n * If you want to clear the selection, use empty array.\n */\n value: ReadonlyArray<File>;\n}\n\nexport namespace FileInputProps {\n export interface ChangeDetail {\n value: File[];\n }\n\n export interface Ref {\n /**\n * Sets focus on the file upload button.\n */\n focus(): void;\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
import './styles.scoped.css';
|
|
3
|
+
export default {
|
|
4
|
+
"root": "awsui_root_181f9_tjfs1_181",
|
|
5
|
+
"file-input": "awsui_file-input_181f9_tjfs1_182",
|
|
6
|
+
"hidden": "awsui_hidden_181f9_tjfs1_186",
|
|
7
|
+
"file-input-button": "awsui_file-input-button_181f9_tjfs1_192",
|
|
8
|
+
"force-focus-outline": "awsui_force-focus-outline_181f9_tjfs1_192"
|
|
9
|
+
};
|
|
10
|
+
|
package/lib/internal/template/{file-upload → internal/components}/file-input/styles.scoped.css
RENAMED
|
@@ -178,28 +178,25 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
178
178
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
179
179
|
SPDX-License-Identifier: Apache-2.0
|
|
180
180
|
*/
|
|
181
|
-
.
|
|
182
|
-
.
|
|
181
|
+
.awsui_root_181f9_tjfs1_181:not(#\9),
|
|
182
|
+
.awsui_file-input_181f9_tjfs1_182:not(#\9) {
|
|
183
183
|
/* used in test-utils */
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
.
|
|
187
|
-
position:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
.awsui_upload-input_4xu1k_pzpve_182:not(#\9) {
|
|
191
|
-
position: absolute;
|
|
192
|
-
clip: rect(0, 0, 0, 0);
|
|
186
|
+
.awsui_hidden_181f9_tjfs1_186:not(#\9) {
|
|
187
|
+
position: absolute !important;
|
|
188
|
+
inset-block-start: -9999px !important;
|
|
189
|
+
inset-inline-start: -9999px !important;
|
|
193
190
|
}
|
|
194
191
|
|
|
195
|
-
body[data-awsui-focus-visible=true] .
|
|
192
|
+
body[data-awsui-focus-visible=true] .awsui_file-input-button_181f9_tjfs1_192.awsui_force-focus-outline_181f9_tjfs1_192:not(#\9) {
|
|
196
193
|
position: relative;
|
|
197
194
|
}
|
|
198
|
-
body[data-awsui-focus-visible=true] .
|
|
195
|
+
body[data-awsui-focus-visible=true] .awsui_file-input-button_181f9_tjfs1_192.awsui_force-focus-outline_181f9_tjfs1_192:not(#\9) {
|
|
199
196
|
outline: 2px dotted transparent;
|
|
200
197
|
outline-offset: calc(var(--space-button-focus-outline-gutter-90p0io, 3px) - 1px);
|
|
201
198
|
}
|
|
202
|
-
body[data-awsui-focus-visible=true] .
|
|
199
|
+
body[data-awsui-focus-visible=true] .awsui_file-input-button_181f9_tjfs1_192.awsui_force-focus-outline_181f9_tjfs1_192:not(#\9)::before {
|
|
203
200
|
content: " ";
|
|
204
201
|
display: block;
|
|
205
202
|
position: absolute;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
// es-module interop with Babel and Typescript
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
module.exports.default = {
|
|
5
|
+
"root": "awsui_root_181f9_tjfs1_181",
|
|
6
|
+
"file-input": "awsui_file-input_181f9_tjfs1_182",
|
|
7
|
+
"hidden": "awsui_hidden_181f9_tjfs1_186",
|
|
8
|
+
"file-input-button": "awsui_file-input-button_181f9_tjfs1_192",
|
|
9
|
+
"force-focus-outline": "awsui_force-focus-outline_181f9_tjfs1_192"
|
|
10
|
+
};
|
|
11
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/s3-resource-selector/s3-modal/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAUlD,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/s3-resource-selector/s3-modal/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAUlD,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AASxD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,oBAAoB,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;IACtE,YAAY,EAAE,uBAAuB,CAAC,cAAc,CAAC,CAAC;IACtD,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7C,qBAAqB,EAAE,uBAAuB,CAAC,uBAAuB,CAAC,CAAC;IACxE,YAAY,EAAE,uBAAuB,CAAC,cAAc,CAAC,CAAC;IACtD,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7C,qBAAqB,EAAE,uBAAuB,CAAC,uBAAuB,CAAC,CAAC;IACxE,aAAa,EAAE,uBAAuB,CAAC,eAAe,CAAC,CAAC;IACxD,sBAAsB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9C,sBAAsB,EAAE,uBAAuB,CAAC,wBAAwB,CAAC,CAAC;IAC1E,WAAW,EAAE,uBAAuB,CAAC,WAAW,GAAG,SAAS,CAAC;IAC7D,YAAY,EAAE,uBAAuB,CAAC,cAAc,CAAC,CAAC;IACtD,eAAe,EAAE,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;IAC5D,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,CAAC,QAAQ,EAAE,uBAAuB,CAAC,QAAQ,KAAK,IAAI,CAAC;CAChE;AA2DD,wBAAgB,OAAO,CAAC,EACtB,WAAW,EACX,KAAK,EACL,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,SAAS,GACV,EAAE,YAAY,eAwHd"}
|
|
@@ -12,6 +12,7 @@ import { joinObjectPath } from '../utils';
|
|
|
12
12
|
import { BucketsTable } from './buckets-table';
|
|
13
13
|
import { ObjectsTable } from './objects-table';
|
|
14
14
|
import { VersionsTable } from './versions-table';
|
|
15
|
+
import testUtilStyles from '../test-classes/styles.css.js';
|
|
15
16
|
import styles from './styles.css.js';
|
|
16
17
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
18
|
function assertNever(_value) {
|
|
@@ -63,7 +64,7 @@ export function S3Modal({ i18nStrings, alert, selectableItemsTypes, fetchBuckets
|
|
|
63
64
|
(_a = forwardFocusRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
64
65
|
}, [breadcrumbs]);
|
|
65
66
|
return (React.createElement("div", null,
|
|
66
|
-
React.createElement(InternalModal, { visible: true, size: "max", getModalRoot: getModalRoot, removeModalRoot: removeModalRoot, closeAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.labelModalDismiss, onDismiss: onDismiss, header: i18n('i18nStrings.modalTitle', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.modalTitle), footer: React.createElement(InternalSpaceBetween, { className: styles['modal-actions'], size: "xs", direction: "horizontal" },
|
|
67
|
+
React.createElement(InternalModal, { className: testUtilStyles['modal-root'], visible: true, size: "max", getModalRoot: getModalRoot, removeModalRoot: removeModalRoot, closeAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.labelModalDismiss, onDismiss: onDismiss, header: i18n('i18nStrings.modalTitle', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.modalTitle), footer: React.createElement(InternalSpaceBetween, { className: styles['modal-actions'], size: "xs", direction: "horizontal" },
|
|
67
68
|
React.createElement(InternalButton, { variant: "link", formAction: "none", onClick: onDismiss }, i18n('i18nStrings.modalCancelButton', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.modalCancelButton)),
|
|
68
69
|
React.createElement(InternalButton, { variant: "primary", className: styles['submit-button'], disabled: !selectedItem, formAction: "none", onClick: () => onSubmit(createResourceInfo({ currentView, breadcrumbs, selectedItem })) }, i18n('i18nStrings.modalSubmitButton', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.modalSubmitButton))) },
|
|
69
70
|
React.createElement(InternalSpaceBetween, { size: isVisualRefresh ? 'xxs' : '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E,IAAI,EAAE,CAAC,GACzD,CACH,CAAC,CAAC,CAAC,CACF,WAAW,CAAC,WAAW,CAAC,CACzB,CACoB,CACT,CACZ,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useReducer, useRef } from 'react';\n\nimport { BreadcrumbGroupImplementation } from '../../breadcrumb-group/implementation';\nimport { InternalButton } from '../../button/internal';\nimport { useInternalI18n } from '../../i18n/context';\nimport { ForwardFocusRef } from '../../internal/hooks/forward-focus';\nimport { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update';\nimport { useVisualRefresh } from '../../internal/hooks/use-visual-mode';\nimport InternalModal from '../../modal/internal';\nimport InternalSpaceBetween from '../../space-between/internal';\nimport { S3ResourceSelectorProps } from '../interfaces';\nimport { joinObjectPath } from '../utils';\nimport { BucketsTable } from './buckets-table';\nimport { ObjectsTable } from './objects-table';\nimport { VersionsTable } from './versions-table';\n\nimport styles from './styles.css.js';\n\nexport interface S3ModalProps {\n alert: React.ReactNode;\n selectableItemsTypes: S3ResourceSelectorProps['selectableItemsTypes'];\n fetchBuckets: S3ResourceSelectorProps['fetchBuckets'];\n bucketsVisibleColumns: ReadonlyArray<string>;\n bucketsIsItemDisabled: S3ResourceSelectorProps['bucketsIsItemDisabled'];\n fetchObjects: S3ResourceSelectorProps['fetchObjects'];\n objectsVisibleColumns: ReadonlyArray<string>;\n objectsIsItemDisabled: S3ResourceSelectorProps['objectsIsItemDisabled'];\n fetchVersions: S3ResourceSelectorProps['fetchVersions'];\n versionsVisibleColumns: ReadonlyArray<string>;\n versionsIsItemDisabled: S3ResourceSelectorProps['versionsIsItemDisabled'];\n i18nStrings: S3ResourceSelectorProps.I18nStrings | undefined;\n getModalRoot: S3ResourceSelectorProps['getModalRoot'];\n removeModalRoot: S3ResourceSelectorProps['removeModalRoot'];\n onDismiss: () => void;\n onSubmit: (resource: S3ResourceSelectorProps.Resource) => void;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction assertNever(_value: never) {\n return null;\n}\n\ninterface S3BrowseState {\n selectedItem: string | null;\n currentView: 'buckets' | 'objects' | 'versions';\n breadcrumbs: ReadonlyArray<string>;\n}\n\ntype S3BrowseActions =\n | { type: 'browse-buckets' }\n | { type: 'browse-objects' | 'browse-versions'; breadcrumbs: S3BrowseState['breadcrumbs'] }\n | { type: 'select-item'; item: string };\n\nconst initialBrowseState: S3BrowseState = {\n selectedItem: null,\n currentView: 'buckets',\n breadcrumbs: [],\n};\n\nfunction s3BrowseReducer(state: S3BrowseState, action: S3BrowseActions) {\n switch (action.type) {\n case 'browse-buckets':\n return initialBrowseState;\n case 'browse-objects':\n return {\n selectedItem: null,\n currentView: 'objects' as const,\n breadcrumbs: action.breadcrumbs,\n };\n case 'browse-versions':\n return {\n selectedItem: null,\n currentView: 'versions' as const,\n breadcrumbs: action.breadcrumbs,\n };\n case 'select-item':\n return {\n ...state,\n selectedItem: action.item,\n };\n default:\n assertNever(action);\n }\n return state;\n}\n\nfunction createResourceInfo({ currentView, breadcrumbs, selectedItem }: S3BrowseState) {\n const prefix = 's3://';\n if (currentView === 'versions') {\n return { uri: prefix + joinObjectPath(breadcrumbs), versionId: selectedItem ?? undefined };\n }\n return { uri: prefix + joinObjectPath([...breadcrumbs, selectedItem!]) };\n}\n\nexport function S3Modal({\n i18nStrings,\n alert,\n selectableItemsTypes,\n fetchBuckets,\n bucketsVisibleColumns,\n bucketsIsItemDisabled,\n fetchObjects,\n objectsVisibleColumns,\n objectsIsItemDisabled,\n fetchVersions,\n versionsVisibleColumns,\n versionsIsItemDisabled,\n getModalRoot,\n removeModalRoot,\n onSubmit,\n onDismiss,\n}: S3ModalProps) {\n const [{ currentView, breadcrumbs, selectedItem }, dispatch] = useReducer(s3BrowseReducer, initialBrowseState);\n const forwardFocusRef = useRef<ForwardFocusRef>(null);\n const i18n = useInternalI18n('s3-resource-selector');\n\n const isVisualRefresh = useVisualRefresh();\n\n useEffectOnUpdate(() => {\n forwardFocusRef.current?.focus();\n }, [breadcrumbs]);\n\n return (\n <div>\n <InternalModal\n visible={true}\n size=\"max\"\n getModalRoot={getModalRoot}\n removeModalRoot={removeModalRoot}\n closeAriaLabel={i18nStrings?.labelModalDismiss}\n onDismiss={onDismiss}\n header={i18n('i18nStrings.modalTitle', i18nStrings?.modalTitle)}\n footer={\n <InternalSpaceBetween className={styles['modal-actions']} size=\"xs\" direction=\"horizontal\">\n <InternalButton variant=\"link\" formAction=\"none\" onClick={onDismiss}>\n {i18n('i18nStrings.modalCancelButton', i18nStrings?.modalCancelButton)}\n </InternalButton>\n <InternalButton\n variant=\"primary\"\n className={styles['submit-button']}\n disabled={!selectedItem}\n formAction=\"none\"\n onClick={() => onSubmit(createResourceInfo({ currentView, breadcrumbs, selectedItem }))}\n >\n {i18n('i18nStrings.modalSubmitButton', i18nStrings?.modalSubmitButton)}\n </InternalButton>\n </InternalSpaceBetween>\n }\n >\n <InternalSpaceBetween size={isVisualRefresh ? 'xxs' : 'xs'}>\n <BreadcrumbGroupImplementation\n ariaLabel={i18n('i18nStrings.labelBreadcrumbs', i18nStrings?.labelBreadcrumbs)}\n expandAriaLabel={i18nStrings?.labelExpandBreadcrumbs}\n onFollow={event => {\n event.preventDefault();\n event.detail.item.meta.onClick();\n }}\n items={[\n {\n text: i18n('i18nStrings.modalBreadcrumbRootItem', i18nStrings?.modalBreadcrumbRootItem) ?? '',\n href: '',\n meta: { onClick: () => dispatch({ type: 'browse-buckets' }) },\n },\n ...breadcrumbs.map((segment, index) => ({\n text: segment,\n href: '',\n meta: {\n onClick: () =>\n dispatch({\n type: 'browse-objects',\n breadcrumbs: breadcrumbs.slice(0, index + 1),\n }),\n },\n })),\n ]}\n />\n {alert}\n {currentView === 'buckets' ? (\n <BucketsTable\n forwardFocusRef={forwardFocusRef}\n fetchData={fetchBuckets}\n visibleColumns={bucketsVisibleColumns}\n isItemDisabled={bucketsIsItemDisabled}\n selectableItemsTypes={selectableItemsTypes}\n i18nStrings={i18nStrings}\n isVisualRefresh={isVisualRefresh}\n onDrilldown={path =>\n dispatch({\n type: 'browse-objects',\n breadcrumbs: [path],\n })\n }\n onSelect={item => dispatch({ type: 'select-item', item })}\n />\n ) : currentView === 'objects' ? (\n <ObjectsTable\n forwardFocusRef={forwardFocusRef}\n pathSegments={breadcrumbs}\n fetchData={fetchObjects}\n visibleColumns={objectsVisibleColumns}\n isItemDisabled={objectsIsItemDisabled}\n selectableItemsTypes={selectableItemsTypes}\n i18nStrings={i18nStrings}\n isVisualRefresh={isVisualRefresh}\n onDrilldown={item => {\n dispatch({\n type: item.IsFolder ? 'browse-objects' : 'browse-versions',\n breadcrumbs: [...breadcrumbs, item.Key!],\n });\n }}\n onSelect={item => dispatch({ type: 'select-item', item })}\n />\n ) : currentView === 'versions' ? (\n <VersionsTable\n forwardFocusRef={forwardFocusRef}\n pathSegments={breadcrumbs}\n fetchData={fetchVersions}\n visibleColumns={versionsVisibleColumns}\n isItemDisabled={versionsIsItemDisabled}\n i18nStrings={i18nStrings}\n isVisualRefresh={isVisualRefresh}\n onSelect={item => dispatch({ type: 'select-item', item })}\n />\n ) : (\n assertNever(currentView)\n )}\n </InternalSpaceBetween>\n </InternalModal>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/s3-resource-selector/s3-modal/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EA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E,WAAW,EACzB,SAAS,EAAE,YAAY,EACvB,cAAc,EAAE,qBAAqB,EACrC,cAAc,EAAE,qBAAqB,EACrC,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,IAAI,CAAC,EAAE;wBAClB,QAAQ,CAAC;4BACP,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,iBAAiB;4BAC1D,WAAW,EAAE,CAAC,GAAG,WAAW,EAAE,IAAI,CAAC,GAAI,CAAC;yBACzC,CAAC,CAAC;oBACL,CAAC,EACD,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,GACzD,CACH,CAAC,CAAC,CAAC,WAAW,KAAK,UAAU,CAAC,CAAC,CAAC,CAC/B,oBAAC,aAAa,IACZ,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,WAAW,EACzB,SAAS,EAAE,aAAa,EACxB,cAAc,EAAE,sBAAsB,EACtC,cAAc,EAAE,sBAAsB,EACtC,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,GACzD,CACH,CAAC,CAAC,CAAC,CACF,WAAW,CAAC,WAAW,CAAC,CACzB,CACoB,CACT,CACZ,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useReducer, useRef } from 'react';\n\nimport { BreadcrumbGroupImplementation } from '../../breadcrumb-group/implementation';\nimport { InternalButton } from '../../button/internal';\nimport { useInternalI18n } from '../../i18n/context';\nimport { ForwardFocusRef } from '../../internal/hooks/forward-focus';\nimport { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update';\nimport { useVisualRefresh } from '../../internal/hooks/use-visual-mode';\nimport InternalModal from '../../modal/internal';\nimport InternalSpaceBetween from '../../space-between/internal';\nimport { S3ResourceSelectorProps } from '../interfaces';\nimport { joinObjectPath } from '../utils';\nimport { BucketsTable } from './buckets-table';\nimport { ObjectsTable } from './objects-table';\nimport { VersionsTable } from './versions-table';\n\nimport testUtilStyles from '../test-classes/styles.css.js';\nimport styles from './styles.css.js';\n\nexport interface S3ModalProps {\n alert: React.ReactNode;\n selectableItemsTypes: S3ResourceSelectorProps['selectableItemsTypes'];\n fetchBuckets: S3ResourceSelectorProps['fetchBuckets'];\n bucketsVisibleColumns: ReadonlyArray<string>;\n bucketsIsItemDisabled: S3ResourceSelectorProps['bucketsIsItemDisabled'];\n fetchObjects: S3ResourceSelectorProps['fetchObjects'];\n objectsVisibleColumns: ReadonlyArray<string>;\n objectsIsItemDisabled: S3ResourceSelectorProps['objectsIsItemDisabled'];\n fetchVersions: S3ResourceSelectorProps['fetchVersions'];\n versionsVisibleColumns: ReadonlyArray<string>;\n versionsIsItemDisabled: S3ResourceSelectorProps['versionsIsItemDisabled'];\n i18nStrings: S3ResourceSelectorProps.I18nStrings | undefined;\n getModalRoot: S3ResourceSelectorProps['getModalRoot'];\n removeModalRoot: S3ResourceSelectorProps['removeModalRoot'];\n onDismiss: () => void;\n onSubmit: (resource: S3ResourceSelectorProps.Resource) => void;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction assertNever(_value: never) {\n return null;\n}\n\ninterface S3BrowseState {\n selectedItem: string | null;\n currentView: 'buckets' | 'objects' | 'versions';\n breadcrumbs: ReadonlyArray<string>;\n}\n\ntype S3BrowseActions =\n | { type: 'browse-buckets' }\n | { type: 'browse-objects' | 'browse-versions'; breadcrumbs: S3BrowseState['breadcrumbs'] }\n | { type: 'select-item'; item: string };\n\nconst initialBrowseState: S3BrowseState = {\n selectedItem: null,\n currentView: 'buckets',\n breadcrumbs: [],\n};\n\nfunction s3BrowseReducer(state: S3BrowseState, action: S3BrowseActions) {\n switch (action.type) {\n case 'browse-buckets':\n return initialBrowseState;\n case 'browse-objects':\n return {\n selectedItem: null,\n currentView: 'objects' as const,\n breadcrumbs: action.breadcrumbs,\n };\n case 'browse-versions':\n return {\n selectedItem: null,\n currentView: 'versions' as const,\n breadcrumbs: action.breadcrumbs,\n };\n case 'select-item':\n return {\n ...state,\n selectedItem: action.item,\n };\n default:\n assertNever(action);\n }\n return state;\n}\n\nfunction createResourceInfo({ currentView, breadcrumbs, selectedItem }: S3BrowseState) {\n const prefix = 's3://';\n if (currentView === 'versions') {\n return { uri: prefix + joinObjectPath(breadcrumbs), versionId: selectedItem ?? undefined };\n }\n return { uri: prefix + joinObjectPath([...breadcrumbs, selectedItem!]) };\n}\n\nexport function S3Modal({\n i18nStrings,\n alert,\n selectableItemsTypes,\n fetchBuckets,\n bucketsVisibleColumns,\n bucketsIsItemDisabled,\n fetchObjects,\n objectsVisibleColumns,\n objectsIsItemDisabled,\n fetchVersions,\n versionsVisibleColumns,\n versionsIsItemDisabled,\n getModalRoot,\n removeModalRoot,\n onSubmit,\n onDismiss,\n}: S3ModalProps) {\n const [{ currentView, breadcrumbs, selectedItem }, dispatch] = useReducer(s3BrowseReducer, initialBrowseState);\n const forwardFocusRef = useRef<ForwardFocusRef>(null);\n const i18n = useInternalI18n('s3-resource-selector');\n\n const isVisualRefresh = useVisualRefresh();\n\n useEffectOnUpdate(() => {\n forwardFocusRef.current?.focus();\n }, [breadcrumbs]);\n\n return (\n <div>\n <InternalModal\n className={testUtilStyles['modal-root']}\n visible={true}\n size=\"max\"\n getModalRoot={getModalRoot}\n removeModalRoot={removeModalRoot}\n closeAriaLabel={i18nStrings?.labelModalDismiss}\n onDismiss={onDismiss}\n header={i18n('i18nStrings.modalTitle', i18nStrings?.modalTitle)}\n footer={\n <InternalSpaceBetween className={styles['modal-actions']} size=\"xs\" direction=\"horizontal\">\n <InternalButton variant=\"link\" formAction=\"none\" onClick={onDismiss}>\n {i18n('i18nStrings.modalCancelButton', i18nStrings?.modalCancelButton)}\n </InternalButton>\n <InternalButton\n variant=\"primary\"\n className={styles['submit-button']}\n disabled={!selectedItem}\n formAction=\"none\"\n onClick={() => onSubmit(createResourceInfo({ currentView, breadcrumbs, selectedItem }))}\n >\n {i18n('i18nStrings.modalSubmitButton', i18nStrings?.modalSubmitButton)}\n </InternalButton>\n </InternalSpaceBetween>\n }\n >\n <InternalSpaceBetween size={isVisualRefresh ? 'xxs' : 'xs'}>\n <BreadcrumbGroupImplementation\n ariaLabel={i18n('i18nStrings.labelBreadcrumbs', i18nStrings?.labelBreadcrumbs)}\n expandAriaLabel={i18nStrings?.labelExpandBreadcrumbs}\n onFollow={event => {\n event.preventDefault();\n event.detail.item.meta.onClick();\n }}\n items={[\n {\n text: i18n('i18nStrings.modalBreadcrumbRootItem', i18nStrings?.modalBreadcrumbRootItem) ?? '',\n href: '',\n meta: { onClick: () => dispatch({ type: 'browse-buckets' }) },\n },\n ...breadcrumbs.map((segment, index) => ({\n text: segment,\n href: '',\n meta: {\n onClick: () =>\n dispatch({\n type: 'browse-objects',\n breadcrumbs: breadcrumbs.slice(0, index + 1),\n }),\n },\n })),\n ]}\n />\n {alert}\n {currentView === 'buckets' ? (\n <BucketsTable\n forwardFocusRef={forwardFocusRef}\n fetchData={fetchBuckets}\n visibleColumns={bucketsVisibleColumns}\n isItemDisabled={bucketsIsItemDisabled}\n selectableItemsTypes={selectableItemsTypes}\n i18nStrings={i18nStrings}\n isVisualRefresh={isVisualRefresh}\n onDrilldown={path =>\n dispatch({\n type: 'browse-objects',\n breadcrumbs: [path],\n })\n }\n onSelect={item => dispatch({ type: 'select-item', item })}\n />\n ) : currentView === 'objects' ? (\n <ObjectsTable\n forwardFocusRef={forwardFocusRef}\n pathSegments={breadcrumbs}\n fetchData={fetchObjects}\n visibleColumns={objectsVisibleColumns}\n isItemDisabled={objectsIsItemDisabled}\n selectableItemsTypes={selectableItemsTypes}\n i18nStrings={i18nStrings}\n isVisualRefresh={isVisualRefresh}\n onDrilldown={item => {\n dispatch({\n type: item.IsFolder ? 'browse-objects' : 'browse-versions',\n breadcrumbs: [...breadcrumbs, item.Key!],\n });\n }}\n onSelect={item => dispatch({ type: 'select-item', item })}\n />\n ) : currentView === 'versions' ? (\n <VersionsTable\n forwardFocusRef={forwardFocusRef}\n pathSegments={breadcrumbs}\n fetchData={fetchVersions}\n visibleColumns={versionsVisibleColumns}\n isItemDisabled={versionsIsItemDisabled}\n i18nStrings={i18nStrings}\n isVisualRefresh={isVisualRefresh}\n onSelect={item => dispatch({ type: 'select-item', item })}\n />\n ) : (\n assertNever(currentView)\n )}\n </InternalSpaceBetween>\n </InternalModal>\n </div>\n );\n}\n"]}
|
|
@@ -3,6 +3,6 @@ import { TableBodyCellProps } from './index';
|
|
|
3
3
|
interface DisabledInlineEditorProps<ItemType> extends TableBodyCellProps<ItemType> {
|
|
4
4
|
editDisabledReason: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function DisabledInlineEditor<ItemType>({ className, item, column, ariaLabels, isEditing, onEditStart, onEditEnd, editDisabledReason, isVisualRefresh,
|
|
6
|
+
export declare function DisabledInlineEditor<ItemType>({ className, item, column, ariaLabels, isEditing, onEditStart, onEditEnd, editDisabledReason, isVisualRefresh, resizableColumns, ...rest }: DisabledInlineEditorProps<ItemType>): JSX.Element;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=disabled-inline-editor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disabled-inline-editor.d.ts","sourceRoot":"","sources":["../../../../src/table/body-cell/disabled-inline-editor.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAK7C,UAAU,yBAAyB,CAAC,QAAQ,CAAE,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IAChF,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,EAC7C,SAAS,EACT,IAAI,EACJ,MAAM,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"disabled-inline-editor.d.ts","sourceRoot":"","sources":["../../../../src/table/body-cell/disabled-inline-editor.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAK7C,UAAU,yBAAyB,CAAC,QAAQ,CAAE,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IAChF,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,EAC7C,SAAS,EACT,IAAI,EACJ,MAAM,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,gBAAwB,EACxB,GAAG,IAAI,EACR,EAAE,yBAAyB,CAAC,QAAQ,CAAC,eAmGrC"}
|
|
@@ -17,7 +17,7 @@ import { TableTdElement } from './td-element';
|
|
|
17
17
|
import styles from './styles.css.js';
|
|
18
18
|
export function DisabledInlineEditor(_a) {
|
|
19
19
|
var _b;
|
|
20
|
-
var { className, item, column, ariaLabels, isEditing, onEditStart, onEditEnd, editDisabledReason, isVisualRefresh,
|
|
20
|
+
var { className, item, column, ariaLabels, isEditing, onEditStart, onEditEnd, editDisabledReason, isVisualRefresh, resizableColumns = false } = _a, rest = __rest(_a, ["className", "item", "column", "ariaLabels", "isEditing", "onEditStart", "onEditEnd", "editDisabledReason", "isVisualRefresh", "resizableColumns"]);
|
|
21
21
|
const clickAwayRef = useClickAway(() => {
|
|
22
22
|
if (isEditing) {
|
|
23
23
|
onEditEnd(true);
|
|
@@ -26,7 +26,7 @@ export function DisabledInlineEditor(_a) {
|
|
|
26
26
|
const [hasHover, setHasHover] = useState(false);
|
|
27
27
|
const [hasFocus, setHasFocus] = useState(false);
|
|
28
28
|
// When a cell is both expandable and editable the icon is always shown.
|
|
29
|
-
const showIcon = hasHover || hasFocus || isEditing
|
|
29
|
+
const showIcon = hasHover || hasFocus || isEditing;
|
|
30
30
|
const iconRef = useRef(null);
|
|
31
31
|
const buttonRef = useRef(null);
|
|
32
32
|
const portalRef = useRef(null);
|
|
@@ -43,10 +43,10 @@ export function DisabledInlineEditor(_a) {
|
|
|
43
43
|
const { targetProps, descriptionEl } = useHiddenDescription(editDisabledReason);
|
|
44
44
|
const portalClasses = usePortalModeClasses(portalRef);
|
|
45
45
|
const { tabIndex } = useSingleTabStopNavigation(buttonRef);
|
|
46
|
-
return (React.createElement(TableTdElement, Object.assign({}, rest, { nativeAttributes: { 'data-inline-editing-active': isEditing.toString() }, className: clsx(className, styles['body-cell-editable'],
|
|
46
|
+
return (React.createElement(TableTdElement, Object.assign({}, rest, { nativeAttributes: { 'data-inline-editing-active': isEditing.toString() }, className: clsx(className, styles['body-cell-editable'], resizableColumns && styles['resizable-columns'], isEditing && styles['body-cell-edit-disabled-popover'], isVisualRefresh && styles['is-visual-refresh']), onClick: !isEditing ? onClick : undefined, onMouseEnter: () => setHasHover(true), onMouseLeave: () => setHasHover(false), ref: clickAwayRef }),
|
|
47
47
|
column.cell(item),
|
|
48
48
|
React.createElement("div", { className: styles['body-cell-editor-wrapper'] },
|
|
49
|
-
React.createElement("button", Object.assign({ ref: buttonRef, tabIndex: tabIndex, className: clsx(styles['body-cell-editor'], styles['body-cell-editor-disabled']), "aria-label": (_b = ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.activateEditLabel) === null || _b === void 0 ? void 0 : _b.call(ariaLabels, column, item), "aria-haspopup": "dialog", "aria-disabled": "true",
|
|
49
|
+
React.createElement("button", Object.assign({ ref: buttonRef, tabIndex: tabIndex, className: clsx(styles['body-cell-editor'], styles['body-cell-editor-disabled']), "aria-label": (_b = ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.activateEditLabel) === null || _b === void 0 ? void 0 : _b.call(ariaLabels, column, item), "aria-haspopup": "dialog", "aria-disabled": "true", onFocus: () => setHasFocus(true), onBlur: () => setHasFocus(false), onKeyDown: handleEscape }, targetProps),
|
|
50
50
|
showIcon && React.createElement(Icon, { name: "lock-private", variant: "normal", __internalRootRef: iconRef }),
|
|
51
51
|
descriptionEl)),
|
|
52
52
|
isEditing && (React.createElement("span", { ref: portalRef },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disabled-inline-editor.js","sourceRoot":"","sources":["../../../../src/table/body-cell/disabled-inline-editor.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,IAAI,MAAM,qBAAqB,CAAC;AACvC,OAAO,MAAM,MAAM,kCAAkC,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2DAA2D,CAAC;AACvG,OAAO,oBAAoB,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AACpF,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAC7C,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAuB,MAAM,cAAc,CAAC;AAEnE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAMrC,MAAM,UAAU,oBAAoB,CAAW,
|
|
1
|
+
{"version":3,"file":"disabled-inline-editor.js","sourceRoot":"","sources":["../../../../src/table/body-cell/disabled-inline-editor.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAA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cesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport Icon from '../../icon/internal';\nimport Portal from '../../internal/components/portal';\nimport { useSingleTabStopNavigation } from '../../internal/context/single-tab-stop-navigation-context';\nimport useHiddenDescription from '../../internal/hooks/use-hidden-description';\nimport { usePortalModeClasses } from '../../internal/hooks/use-portal-mode-classes';\nimport InternalLiveRegion from '../../live-region/internal';\nimport Arrow from '../../popover/arrow';\nimport PopoverBody from '../../popover/body';\nimport PopoverContainer from '../../popover/container';\nimport { useClickAway } from './click-away';\nimport { TableBodyCellProps } from './index';\nimport { TableTdElement, TableTdElementProps } from './td-element';\n\nimport styles from './styles.css.js';\n\ninterface DisabledInlineEditorProps<ItemType> extends TableBodyCellProps<ItemType> {\n editDisabledReason: string;\n}\n\nexport function DisabledInlineEditor<ItemType>({\n className,\n item,\n column,\n ariaLabels,\n isEditing,\n onEditStart,\n onEditEnd,\n editDisabledReason,\n isVisualRefresh,\n resizableColumns = false,\n ...rest\n}: DisabledInlineEditorProps<ItemType>) {\n const clickAwayRef = useClickAway(() => {\n if (isEditing) {\n onEditEnd(true);\n }\n });\n\n const [hasHover, setHasHover] = useState(false);\n const [hasFocus, setHasFocus] = useState(false);\n // When a cell is both expandable and editable the icon is always shown.\n const showIcon = hasHover || hasFocus || isEditing;\n\n const iconRef = useRef(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const portalRef = useRef<HTMLSpanElement>(null);\n\n function handleEscape(event: React.KeyboardEvent): void {\n if (event.key === 'Escape') {\n onEditEnd(true);\n }\n }\n\n const onClick = () => {\n onEditStart();\n buttonRef.current?.focus();\n };\n\n const { targetProps, descriptionEl } = useHiddenDescription(editDisabledReason);\n const portalClasses = usePortalModeClasses(portalRef);\n\n const { tabIndex } = useSingleTabStopNavigation(buttonRef);\n\n return (\n <TableTdElement\n {...rest}\n nativeAttributes={\n { 'data-inline-editing-active': isEditing.toString() } as TableTdElementProps['nativeAttributes']\n }\n className={clsx(\n className,\n styles['body-cell-editable'],\n resizableColumns && styles['resizable-columns'],\n isEditing && styles['body-cell-edit-disabled-popover'],\n isVisualRefresh && styles['is-visual-refresh']\n )}\n onClick={!isEditing ? onClick : undefined}\n onMouseEnter={() => setHasHover(true)}\n onMouseLeave={() => setHasHover(false)}\n ref={clickAwayRef}\n >\n {column.cell(item)}\n\n <div className={styles['body-cell-editor-wrapper']}>\n <button\n ref={buttonRef}\n tabIndex={tabIndex}\n className={clsx(styles['body-cell-editor'], styles['body-cell-editor-disabled'])}\n aria-label={ariaLabels?.activateEditLabel?.(column, item)}\n aria-haspopup=\"dialog\"\n aria-disabled=\"true\"\n onFocus={() => setHasFocus(true)}\n onBlur={() => setHasFocus(false)}\n onKeyDown={handleEscape}\n {...targetProps}\n >\n {showIcon && <Icon name=\"lock-private\" variant=\"normal\" __internalRootRef={iconRef} />}\n {descriptionEl}\n </button>\n </div>\n\n {isEditing && (\n <span ref={portalRef}>\n <Portal>\n <span className={portalClasses}>\n <PopoverContainer\n size=\"medium\"\n fixedWidth={false}\n position=\"top\"\n trackRef={iconRef}\n arrow={position => <Arrow position={position} />}\n renderWithPortal={true}\n zIndex={2000}\n >\n <PopoverBody\n dismissButton={false}\n dismissAriaLabel={undefined}\n header={null}\n onDismiss={() => {}}\n overflowVisible=\"both\"\n >\n <InternalLiveRegion tagName=\"span\">{editDisabledReason}</InternalLiveRegion>\n </PopoverBody>\n </PopoverContainer>\n </span>\n </Portal>\n </span>\n )}\n </TableTdElement>\n );\n}\n"]}
|
|
@@ -11,7 +11,6 @@ export interface TableBodyCellProps<ItemType> extends TableTdElementProps {
|
|
|
11
11
|
onEditEnd: (cancelled: boolean) => void;
|
|
12
12
|
submitEdit?: TableProps.SubmitEditFunction<ItemType>;
|
|
13
13
|
ariaLabels: TableProps['ariaLabels'];
|
|
14
|
-
interactiveCell?: boolean;
|
|
15
14
|
}
|
|
16
15
|
export declare function TableBodyCell<ItemType>({ isEditable, ...rest }: TableBodyCellProps<ItemType> & {
|
|
17
16
|
isEditable: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/table/body-cell/index.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAQnE,MAAM,WAAW,kBAAkB,CAAC,QAAQ,CAAE,SAAQ,mBAAmB;IACvE,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC9C,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,UAAU,CAAC,EAAE,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACrD,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/table/body-cell/index.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAQnE,MAAM,WAAW,kBAAkB,CAAC,QAAQ,CAAE,SAAQ,mBAAmB;IACvE,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC9C,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,UAAU,CAAC,EAAE,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACrD,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;CACtC;AA0HD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,EACtC,UAAU,EACV,GAAG,IAAI,EACR,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,eAexD"}
|
|
@@ -17,7 +17,7 @@ const submitHandlerFallback = () => {
|
|
|
17
17
|
};
|
|
18
18
|
function TableCellEditable(_a) {
|
|
19
19
|
var _b, _c, _d;
|
|
20
|
-
var { className, item, column, isEditing, onEditStart, onEditEnd, submitEdit, ariaLabels, isVisualRefresh, resizableColumns = false, successfulEdit = false
|
|
20
|
+
var { className, item, column, isEditing, onEditStart, onEditEnd, submitEdit, ariaLabels, isVisualRefresh, resizableColumns = false, successfulEdit = false } = _a, rest = __rest(_a, ["className", "item", "column", "isEditing", "onEditStart", "onEditEnd", "submitEdit", "ariaLabels", "isVisualRefresh", "resizableColumns", "successfulEdit"]);
|
|
21
21
|
const i18n = useInternalI18n('table');
|
|
22
22
|
const editActivateRef = useRef(null);
|
|
23
23
|
const tdNativeAttributes = {
|
|
@@ -34,7 +34,7 @@ function TableCellEditable(_a) {
|
|
|
34
34
|
const [hasHover, setHasHover] = useState(false);
|
|
35
35
|
const [hasFocus, setHasFocus] = useState(false);
|
|
36
36
|
// When a cell is both expandable and editable the icon is always shown.
|
|
37
|
-
const showIcon = hasHover || hasFocus
|
|
37
|
+
const showIcon = hasHover || hasFocus;
|
|
38
38
|
const prevSuccessfulEdit = usePrevious(successfulEdit);
|
|
39
39
|
const prevHasFocus = usePrevious(hasFocus);
|
|
40
40
|
const [showSuccessIcon, setShowSuccessIcon] = useState(false);
|
|
@@ -49,7 +49,7 @@ function TableCellEditable(_a) {
|
|
|
49
49
|
}
|
|
50
50
|
}, [hasFocus, successfulEdit, prevHasFocus, prevSuccessfulEdit]);
|
|
51
51
|
const { tabIndex: editActivateTabIndex } = useSingleTabStopNavigation(editActivateRef);
|
|
52
|
-
return (React.createElement(TableTdElement, Object.assign({}, rest, { nativeAttributes: tdNativeAttributes, className: clsx(className, styles['body-cell-editable'],
|
|
52
|
+
return (React.createElement(TableTdElement, Object.assign({}, rest, { nativeAttributes: tdNativeAttributes, className: clsx(className, styles['body-cell-editable'], resizableColumns && styles['resizable-columns'], isEditing && styles['body-cell-edit-active'], showSuccessIcon && showIcon && styles['body-cell-has-success'], isVisualRefresh && styles['is-visual-refresh']), onClick: !isEditing ? onEditStart : undefined, onMouseEnter: () => setHasHover(true), onMouseLeave: () => setHasHover(false) }), isEditing ? (React.createElement(InlineEditor, { ariaLabels: ariaLabels, column: column, item: item, onEditEnd: options => {
|
|
53
53
|
setShowSuccessIcon(false);
|
|
54
54
|
isFocusMoveNeededRef.current = options.refocusCell;
|
|
55
55
|
onEditEnd(options.cancelled);
|
|
@@ -64,7 +64,7 @@ function TableCellEditable(_a) {
|
|
|
64
64
|
React.createElement(Icon, { name: "status-positive", variant: "success" })),
|
|
65
65
|
React.createElement(InternalLiveRegion, { tagName: "span", hidden: true }, i18n('ariaLabels.successfulEditLabel', (_c = ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.successfulEditLabel) === null || _c === void 0 ? void 0 : _c.call(ariaLabels, column))))),
|
|
66
66
|
React.createElement("div", { className: styles['body-cell-editor-wrapper'] },
|
|
67
|
-
React.createElement("button", { className: styles['body-cell-editor'], "aria-label": (_d = ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.activateEditLabel) === null || _d === void 0 ? void 0 : _d.call(ariaLabels, column, item), ref: editActivateRef,
|
|
67
|
+
React.createElement("button", { className: styles['body-cell-editor'], "aria-label": (_d = ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.activateEditLabel) === null || _d === void 0 ? void 0 : _d.call(ariaLabels, column, item), ref: editActivateRef, onFocus: () => setHasFocus(true), onBlur: () => setHasFocus(false), tabIndex: editActivateTabIndex }, showIcon && React.createElement(Icon, { name: "edit" })))))));
|
|
68
68
|
}
|
|
69
69
|
export function TableBodyCell(_a) {
|
|
70
70
|
var _b, _c;
|