@cloudscape-design/components-themeable 3.0.840 → 3.0.841
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/{internal/components/file-dropzone → file-dropzone}/styles.scss +14 -11
- package/lib/internal/scss/{internal/components/file-input → file-input}/styles.scss +2 -2
- package/lib/internal/scss/{internal/components/file-token-group → file-token-group}/constants.scss +1 -1
- package/lib/internal/scss/{internal/components/file-token-group → file-token-group}/styles.scss +3 -3
- package/lib/internal/scss/internal/components/token-list/styles.scss +1 -1
- package/lib/internal/template/button-group/icon-toggle-button-item.d.ts +12 -0
- package/lib/internal/template/button-group/icon-toggle-button-item.d.ts.map +1 -0
- package/lib/internal/template/button-group/icon-toggle-button-item.js +30 -0
- package/lib/internal/template/button-group/icon-toggle-button-item.js.map +1 -0
- package/lib/internal/template/button-group/interfaces.d.ts +42 -6
- package/lib/internal/template/button-group/interfaces.d.ts.map +1 -1
- package/lib/internal/template/button-group/interfaces.js.map +1 -1
- package/lib/internal/template/button-group/item-element.d.ts.map +1 -1
- package/lib/internal/template/button-group/item-element.js +2 -0
- package/lib/internal/template/button-group/item-element.js.map +1 -1
- package/lib/internal/template/button-group/menu-dropdown-item.js +1 -1
- package/lib/internal/template/button-group/menu-dropdown-item.js.map +1 -1
- package/lib/internal/template/{internal/components/file-dropzone → file-dropzone}/index.d.ts +1 -1
- package/lib/internal/template/file-dropzone/index.d.ts.map +1 -0
- package/lib/internal/template/file-dropzone/index.js +14 -0
- package/lib/internal/template/file-dropzone/index.js.map +1 -0
- package/lib/internal/template/{internal/components/file-dropzone → file-dropzone}/interfaces.d.ts +2 -2
- package/lib/internal/template/file-dropzone/interfaces.d.ts.map +1 -0
- package/lib/internal/template/file-dropzone/interfaces.js.map +1 -0
- package/lib/internal/template/file-dropzone/internal.d.ts +5 -0
- package/lib/internal/template/file-dropzone/internal.d.ts.map +1 -0
- package/lib/internal/template/{internal/components/file-dropzone/index.js → file-dropzone/internal.js} +10 -6
- package/lib/internal/template/file-dropzone/internal.js.map +1 -0
- package/lib/internal/template/file-dropzone/styles.css.js +8 -0
- package/lib/internal/template/{internal/components/file-dropzone → file-dropzone}/styles.scoped.css +17 -14
- package/lib/internal/template/{internal/components/file-dropzone → file-dropzone}/styles.selectors.js +3 -3
- package/lib/internal/template/file-dropzone/use-files-dragging.d.ts.map +1 -0
- package/lib/internal/template/file-dropzone/use-files-dragging.js.map +1 -0
- package/lib/internal/template/file-input/index.d.ts +6 -0
- package/lib/internal/template/file-input/index.d.ts.map +1 -0
- package/lib/internal/template/file-input/index.js +20 -0
- package/lib/internal/template/file-input/index.js.map +1 -0
- package/lib/internal/template/{internal/components/file-input → file-input}/interfaces.d.ts +3 -3
- package/lib/internal/template/file-input/interfaces.d.ts.map +1 -0
- package/lib/internal/template/file-input/interfaces.js.map +1 -0
- package/lib/internal/template/file-input/internal.d.ts +6 -0
- package/lib/internal/template/file-input/internal.d.ts.map +1 -0
- package/lib/internal/template/{internal/components/file-input/index.js → file-input/internal.js} +13 -11
- package/lib/internal/template/file-input/internal.js.map +1 -0
- package/lib/internal/template/file-input/styles.css.js +10 -0
- package/lib/internal/template/{internal/components/file-input → file-input}/styles.scoped.css +6 -6
- package/lib/internal/template/file-input/styles.selectors.js +11 -0
- package/lib/internal/template/file-token-group/default-formatters.d.ts.map +1 -0
- package/lib/internal/template/{internal/components/file-token-group → file-token-group}/default-formatters.js +1 -1
- package/lib/internal/template/file-token-group/default-formatters.js.map +1 -0
- package/lib/internal/template/{internal/components/file-token-group → file-token-group}/file-token.d.ts +2 -2
- package/lib/internal/template/file-token-group/file-token.d.ts.map +1 -0
- package/lib/internal/template/{internal/components/file-token-group → file-token-group}/file-token.js +8 -8
- package/lib/internal/template/file-token-group/file-token.js.map +1 -0
- package/lib/internal/template/file-token-group/index.d.ts +6 -0
- package/lib/internal/template/file-token-group/index.d.ts.map +1 -0
- package/lib/internal/template/file-token-group/index.js +23 -0
- package/lib/internal/template/file-token-group/index.js.map +1 -0
- package/lib/internal/template/{internal/components/file-token-group → file-token-group}/interfaces.d.ts +2 -2
- package/lib/internal/template/file-token-group/interfaces.d.ts.map +1 -0
- package/lib/internal/template/file-token-group/interfaces.js.map +1 -0
- package/lib/internal/template/{internal/components/file-token-group/index.d.ts → file-token-group/internal.d.ts} +2 -3
- package/lib/internal/template/file-token-group/internal.d.ts.map +1 -0
- package/lib/internal/template/{internal/components/file-token-group/index.js → file-token-group/internal.js} +7 -7
- package/lib/internal/template/file-token-group/internal.js.map +1 -0
- package/lib/internal/template/file-token-group/styles.css.js +27 -0
- package/lib/internal/template/{internal/components/file-token-group → file-token-group}/styles.scoped.css +29 -29
- package/lib/internal/template/file-token-group/styles.selectors.js +28 -0
- package/lib/internal/template/file-token-group/test-classes/styles.css.js +11 -0
- package/lib/internal/template/file-token-group/test-classes/styles.scoped.css +12 -0
- package/lib/internal/template/file-token-group/test-classes/styles.selectors.js +12 -0
- package/lib/internal/template/file-token-group/thumbnail.d.ts.map +1 -0
- package/lib/internal/template/file-token-group/thumbnail.js.map +1 -0
- package/lib/internal/template/file-upload/internal.d.ts.map +1 -1
- package/lib/internal/template/file-upload/internal.js +6 -5
- package/lib/internal/template/file-upload/internal.js.map +1 -1
- package/lib/internal/template/index.d.ts +3 -0
- package/lib/internal/template/index.d.ts.map +1 -1
- package/lib/internal/template/index.js +3 -0
- package/lib/internal/template/index.js.map +1 -1
- package/lib/internal/template/internal/base-component/styles.scoped.css +62 -43
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/internal/environment.json +1 -1
- package/lib/internal/template/internal/generated/styles/tokens.d.ts +4 -2
- package/lib/internal/template/internal/generated/styles/tokens.js +6 -4
- package/lib/internal/template/internal/generated/theming/index.cjs +136 -74
- package/lib/internal/template/internal/generated/theming/index.js +136 -74
- package/lib/internal/template/package.json +3 -0
- package/lib/internal/template/test-utils/dom/button-group/index.d.ts +5 -0
- package/lib/internal/template/test-utils/dom/button-group/index.js +9 -0
- package/lib/internal/template/test-utils/dom/button-group/index.js.map +1 -1
- package/lib/internal/template/test-utils/dom/{internal/file-dropzone.js → file-dropzone/index.js} +2 -2
- package/lib/internal/template/test-utils/dom/file-dropzone/index.js.map +1 -0
- package/lib/internal/template/test-utils/dom/{internal/file-input.js → file-input/index.js} +2 -2
- package/lib/internal/template/test-utils/dom/file-input/index.js.map +1 -0
- package/lib/internal/template/test-utils/dom/{internal/file-token-group.js → file-token-group/index.js} +14 -14
- package/lib/internal/template/test-utils/dom/file-token-group/index.js.map +1 -0
- package/lib/internal/template/test-utils/dom/file-upload/index.d.ts +1 -1
- package/lib/internal/template/test-utils/dom/file-upload/index.js +13 -13
- package/lib/internal/template/test-utils/dom/file-upload/index.js.map +1 -1
- package/lib/internal/template/test-utils/dom/index.d.ts +9 -0
- package/lib/internal/template/test-utils/dom/index.js +26 -2
- package/lib/internal/template/test-utils/dom/index.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/button-group/index.d.ts +5 -0
- package/lib/internal/template/test-utils/selectors/button-group/index.js +9 -0
- package/lib/internal/template/test-utils/selectors/button-group/index.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/{internal/file-dropzone.js → file-dropzone/index.js} +2 -2
- package/lib/internal/template/test-utils/selectors/file-dropzone/index.js.map +1 -0
- package/lib/internal/template/test-utils/selectors/{internal/file-input.js → file-input/index.js} +2 -2
- package/lib/internal/template/test-utils/selectors/file-input/index.js.map +1 -0
- package/lib/internal/template/test-utils/selectors/{internal/file-token-group.js → file-token-group/index.js} +14 -14
- package/lib/internal/template/test-utils/selectors/file-token-group/index.js.map +1 -0
- package/lib/internal/template/test-utils/selectors/file-upload/index.d.ts +1 -1
- package/lib/internal/template/test-utils/selectors/file-upload/index.js +13 -13
- package/lib/internal/template/test-utils/selectors/file-upload/index.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/index.d.ts +9 -0
- package/lib/internal/template/test-utils/selectors/index.js +26 -2
- package/lib/internal/template/test-utils/selectors/index.js.map +1 -1
- package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
- package/lib/internal/template/toggle-button/internal.d.ts +3 -1
- package/lib/internal/template/toggle-button/internal.d.ts.map +1 -1
- package/lib/internal/template/toggle-button/internal.js.map +1 -1
- package/package.json +1 -1
- package/lib/internal/template/internal/components/file-dropzone/index.d.ts.map +0 -1
- package/lib/internal/template/internal/components/file-dropzone/index.js.map +0 -1
- package/lib/internal/template/internal/components/file-dropzone/interfaces.d.ts.map +0 -1
- package/lib/internal/template/internal/components/file-dropzone/interfaces.js.map +0 -1
- package/lib/internal/template/internal/components/file-dropzone/styles.css.js +0 -8
- package/lib/internal/template/internal/components/file-dropzone/use-files-dragging.d.ts.map +0 -1
- package/lib/internal/template/internal/components/file-dropzone/use-files-dragging.js.map +0 -1
- package/lib/internal/template/internal/components/file-input/index.d.ts +0 -6
- package/lib/internal/template/internal/components/file-input/index.d.ts.map +0 -1
- package/lib/internal/template/internal/components/file-input/index.js.map +0 -1
- package/lib/internal/template/internal/components/file-input/interfaces.d.ts.map +0 -1
- package/lib/internal/template/internal/components/file-input/interfaces.js.map +0 -1
- package/lib/internal/template/internal/components/file-input/styles.css.js +0 -10
- package/lib/internal/template/internal/components/file-input/styles.selectors.js +0 -11
- package/lib/internal/template/internal/components/file-token-group/default-formatters.d.ts.map +0 -1
- package/lib/internal/template/internal/components/file-token-group/default-formatters.js.map +0 -1
- package/lib/internal/template/internal/components/file-token-group/file-token.d.ts.map +0 -1
- package/lib/internal/template/internal/components/file-token-group/file-token.js.map +0 -1
- package/lib/internal/template/internal/components/file-token-group/index.d.ts.map +0 -1
- package/lib/internal/template/internal/components/file-token-group/index.js.map +0 -1
- package/lib/internal/template/internal/components/file-token-group/interfaces.d.ts.map +0 -1
- package/lib/internal/template/internal/components/file-token-group/interfaces.js.map +0 -1
- package/lib/internal/template/internal/components/file-token-group/styles.css.js +0 -27
- package/lib/internal/template/internal/components/file-token-group/styles.selectors.js +0 -28
- package/lib/internal/template/internal/components/file-token-group/test-classes/styles.css.js +0 -11
- package/lib/internal/template/internal/components/file-token-group/test-classes/styles.scoped.css +0 -12
- package/lib/internal/template/internal/components/file-token-group/test-classes/styles.selectors.js +0 -12
- package/lib/internal/template/internal/components/file-token-group/thumbnail.d.ts.map +0 -1
- package/lib/internal/template/internal/components/file-token-group/thumbnail.js.map +0 -1
- package/lib/internal/template/test-utils/dom/internal/file-dropzone.js.map +0 -1
- package/lib/internal/template/test-utils/dom/internal/file-input.js.map +0 -1
- package/lib/internal/template/test-utils/dom/internal/file-token-group.js.map +0 -1
- package/lib/internal/template/test-utils/selectors/internal/file-dropzone.js.map +0 -1
- package/lib/internal/template/test-utils/selectors/internal/file-input.js.map +0 -1
- package/lib/internal/template/test-utils/selectors/internal/file-token-group.js.map +0 -1
- /package/lib/internal/scss/{internal/components/file-token-group → file-token-group}/test-classes/styles.scss +0 -0
- /package/lib/internal/template/{internal/components/file-dropzone → file-dropzone}/interfaces.js +0 -0
- /package/lib/internal/template/{internal/components/file-dropzone → file-dropzone}/use-files-dragging.d.ts +0 -0
- /package/lib/internal/template/{internal/components/file-dropzone → file-dropzone}/use-files-dragging.js +0 -0
- /package/lib/internal/template/{internal/components/file-input → file-input}/interfaces.js +0 -0
- /package/lib/internal/template/{internal/components/file-token-group → file-token-group}/default-formatters.d.ts +0 -0
- /package/lib/internal/template/{internal/components/file-token-group → file-token-group}/interfaces.js +0 -0
- /package/lib/internal/template/{internal/components/file-token-group → file-token-group}/thumbnail.d.ts +0 -0
- /package/lib/internal/template/{internal/components/file-token-group → file-token-group}/thumbnail.js +0 -0
- /package/lib/internal/template/test-utils/dom/{internal/file-dropzone.d.ts → file-dropzone/index.d.ts} +0 -0
- /package/lib/internal/template/test-utils/dom/{internal/file-input.d.ts → file-input/index.d.ts} +0 -0
- /package/lib/internal/template/test-utils/dom/{internal/file-token-group.d.ts → file-token-group/index.d.ts} +0 -0
- /package/lib/internal/template/test-utils/selectors/{internal/file-dropzone.d.ts → file-dropzone/index.d.ts} +0 -0
- /package/lib/internal/template/test-utils/selectors/{internal/file-input.d.ts → file-input/index.d.ts} +0 -0
- /package/lib/internal/template/test-utils/selectors/{internal/file-token-group.d.ts → file-token-group/index.d.ts} +0 -0
|
@@ -3,31 +3,34 @@
|
|
|
3
3
|
SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
@use '
|
|
7
|
-
@use '
|
|
6
|
+
@use '../internal/styles/tokens' as awsui;
|
|
7
|
+
@use '../internal/styles' as styles;
|
|
8
8
|
|
|
9
9
|
.root {
|
|
10
|
-
display: flex;
|
|
11
|
-
flex-direction: column;
|
|
12
|
-
align-items: center;
|
|
13
|
-
justify-content: center;
|
|
14
|
-
gap: awsui.$space-static-xxs;
|
|
15
10
|
padding-block: awsui.$space-static-l;
|
|
16
11
|
padding-inline: awsui.$space-static-l;
|
|
17
12
|
border-start-start-radius: awsui.$border-radius-dropzone;
|
|
18
13
|
border-start-end-radius: awsui.$border-radius-dropzone;
|
|
19
14
|
border-end-start-radius: awsui.$border-radius-dropzone;
|
|
20
15
|
border-end-end-radius: awsui.$border-radius-dropzone;
|
|
21
|
-
color: awsui.$color-dropzone-text-
|
|
22
|
-
background-color: awsui.$color-dropzone-background-
|
|
23
|
-
|
|
16
|
+
color: awsui.$color-dropzone-text-default;
|
|
17
|
+
background-color: awsui.$color-dropzone-background-default;
|
|
18
|
+
border-color: awsui.$color-dropzone-border-default;
|
|
19
|
+
border-block: 1px dashed awsui.$color-dropzone-border-default;
|
|
20
|
+
border-inline: 1px dashed awsui.$color-dropzone-border-default;
|
|
24
21
|
|
|
25
22
|
&.hovered {
|
|
26
23
|
color: awsui.$color-dropzone-text-hover;
|
|
27
24
|
background-color: awsui.$color-dropzone-background-hover;
|
|
25
|
+
border-block: 1px dashed awsui.$color-dropzone-border-hover;
|
|
26
|
+
border-inline: 1px dashed awsui.$color-dropzone-border-hover;
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
.content {
|
|
32
|
-
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
gap: awsui.$space-static-xxs;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
33
36
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
@use '
|
|
6
|
-
@use '
|
|
5
|
+
@use '../internal/styles/tokens' as awsui;
|
|
6
|
+
@use '../internal/styles' as styles;
|
|
7
7
|
@use '@cloudscape-design/component-toolkit/internal/focus-visible' as focus-visible;
|
|
8
8
|
|
|
9
9
|
.root,
|
package/lib/internal/scss/{internal/components/file-token-group → file-token-group}/styles.scss
RENAMED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
@use '
|
|
7
|
-
@use '
|
|
6
|
+
@use '../internal/styles/tokens' as awsui;
|
|
7
|
+
@use '../internal/styles' as styles;
|
|
8
8
|
@use './constants' as constants;
|
|
9
|
-
@use '
|
|
9
|
+
@use '../token-group/mixins.scss' as mixins;
|
|
10
10
|
@use '@cloudscape-design/component-toolkit/internal/focus-visible' as focus-visible;
|
|
11
11
|
|
|
12
12
|
@mixin token-box-validation {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
@use '../../styles/tokens' as awsui;
|
|
7
7
|
@use '../../styles' as styles;
|
|
8
|
-
@use '../../../
|
|
8
|
+
@use '../../../file-token-group/constants' as constants;
|
|
9
9
|
@use '@cloudscape-design/component-toolkit/internal/focus-visible' as focus-visible;
|
|
10
10
|
|
|
11
11
|
.root {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonProps } from '../button/interfaces.js';
|
|
3
|
+
import { CancelableEventHandler } from '../internal/events/index.js';
|
|
4
|
+
import { ButtonGroupProps } from './interfaces.js';
|
|
5
|
+
declare const IconToggleButtonItem: React.ForwardRefExoticComponent<{
|
|
6
|
+
item: ButtonGroupProps.IconToggleButton;
|
|
7
|
+
showTooltip: boolean;
|
|
8
|
+
showFeedback: boolean;
|
|
9
|
+
onItemClick?: CancelableEventHandler<ButtonGroupProps.ItemClickDetails> | undefined;
|
|
10
|
+
} & React.RefAttributes<ButtonProps.Ref>>;
|
|
11
|
+
export default IconToggleButtonItem;
|
|
12
|
+
//# sourceMappingURL=icon-toggle-button-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-toggle-button-item.d.ts","sourceRoot":"","sources":["../../../src/button-group/icon-toggle-button-item.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAuB,MAAM,6BAA6B,CAAC;AAG1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAInD,QAAA,MAAM,oBAAoB;UAQd,iBAAiB,gBAAgB;iBAC1B,OAAO;kBACN,OAAO;;yCAwD1B,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
|
|
6
|
+
import Tooltip from '../internal/components/tooltip/index.js';
|
|
7
|
+
import { fireCancelableEvent } from '../internal/events/index.js';
|
|
8
|
+
import InternalLiveRegion from '../live-region/internal.js';
|
|
9
|
+
import { InternalToggleButton } from '../toggle-button/internal.js';
|
|
10
|
+
import testUtilStyles from './test-classes/styles.css.js';
|
|
11
|
+
const IconToggleButtonItem = forwardRef(({ item, showTooltip, showFeedback, onItemClick, }, ref) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const containerRef = React.useRef(null);
|
|
14
|
+
const hasIcon = item.iconName || item.iconUrl || item.iconSvg;
|
|
15
|
+
const hasPressedIcon = item.pressedIconName || item.pressedIconUrl || item.pressedIconSvg;
|
|
16
|
+
if (!hasIcon) {
|
|
17
|
+
warnOnce('ButtonGroup', `Missing icon for item with id: ${item.id}`);
|
|
18
|
+
}
|
|
19
|
+
if (!hasPressedIcon) {
|
|
20
|
+
warnOnce('ButtonGroup', `Missing pressed icon for item with id: ${item.id}`);
|
|
21
|
+
}
|
|
22
|
+
const feedbackContent = item.pressed ? (_a = item.pressedPopoverFeedback) !== null && _a !== void 0 ? _a : item.popoverFeedback : item.popoverFeedback;
|
|
23
|
+
const canShowTooltip = showTooltip && !item.disabled && !item.loading;
|
|
24
|
+
const canShowFeedback = showTooltip && showFeedback && feedbackContent;
|
|
25
|
+
return (React.createElement("div", { ref: containerRef },
|
|
26
|
+
React.createElement(InternalToggleButton, { variant: "icon", pressed: item.pressed, loading: item.loading, loadingText: item.loadingText, disabled: item.disabled, iconName: hasIcon ? item.iconName : 'close', iconUrl: item.iconUrl, iconSvg: item.iconSvg, pressedIconName: hasIcon ? item.pressedIconName : 'close', pressedIconUrl: item.pressedIconUrl, pressedIconSvg: item.pressedIconUrl, ariaLabel: item.text, onChange: event => fireCancelableEvent(onItemClick, { id: item.id, pressed: event.detail.pressed }), ref: ref, "data-testid": item.id, "data-itemid": item.id, className: clsx(testUtilStyles.item, testUtilStyles['button-group-item']), __title: "" }, item.text),
|
|
27
|
+
(canShowTooltip || canShowFeedback) && (React.createElement(Tooltip, { trackRef: containerRef, trackKey: item.id, value: (showFeedback && React.createElement(InternalLiveRegion, { tagName: "span" }, feedbackContent)) || item.text, className: clsx(testUtilStyles.tooltip, testUtilStyles['button-group-tooltip']) }))));
|
|
28
|
+
});
|
|
29
|
+
export default IconToggleButtonItem;
|
|
30
|
+
//# sourceMappingURL=icon-toggle-button-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-toggle-button-item.js","sourceRoot":"","sources":["../../../src/button-group/icon-toggle-button-item.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAGzE,OAAO,OAAO,MAAM,yCAAyC,CAAC;AAC9D,OAAO,EAA0B,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAC1F,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGpE,OAAO,cAAc,MAAM,8BAA8B,CAAC;AAE1D,MAAM,oBAAoB,GAAG,UAAU,CACrC,CACE,EACE,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,WAAW,GAMZ,EACD,GAA+B,EAC/B,EAAE;;IACF,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAiB,IAAI,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC;IAC9D,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC;IAE1F,IAAI,CAAC,OAAO,EAAE;QACZ,QAAQ,CAAC,aAAa,EAAE,kCAAkC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;KACtE;IACD,IAAI,CAAC,cAAc,EAAE;QACnB,QAAQ,CAAC,aAAa,EAAE,0CAA0C,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC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ACzE,OAAO,EAAC,EAAE,IAET,IAAI,CAAC,IAAI,CACW;QACtB,CAAC,cAAc,IAAI,eAAe,CAAC,IAAI,CACtC,oBAAC,OAAO,IACN,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,IAAI,CAAC,EAAE,EACjB,KAAK,EACH,CAAC,YAAY,IAAI,oBAAC,kBAAkB,IAAC,OAAO,EAAC,MAAM,IAAE,eAAe,CAAsB,CAAC,IAAI,IAAI,CAAC,IAAI,EAE1G,SAAS,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,sBAAsB,CAAC,CAAC,GAC/E,CACH,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { forwardRef } from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { ButtonProps } from '../button/interfaces.js';\nimport Tooltip from '../internal/components/tooltip/index.js';\nimport { CancelableEventHandler, fireCancelableEvent } from '../internal/events/index.js';\nimport InternalLiveRegion from '../live-region/internal.js';\nimport { InternalToggleButton } from '../toggle-button/internal.js';\nimport { ButtonGroupProps } from './interfaces.js';\n\nimport testUtilStyles from './test-classes/styles.css.js';\n\nconst IconToggleButtonItem = forwardRef(\n (\n {\n item,\n showTooltip,\n showFeedback,\n onItemClick,\n }: {\n item: ButtonGroupProps.IconToggleButton;\n showTooltip: boolean;\n showFeedback: boolean;\n onItemClick?: CancelableEventHandler<ButtonGroupProps.ItemClickDetails>;\n },\n ref: React.Ref<ButtonProps.Ref>\n ) => {\n const containerRef = React.useRef<HTMLDivElement>(null);\n const hasIcon = item.iconName || item.iconUrl || item.iconSvg;\n const hasPressedIcon = item.pressedIconName || item.pressedIconUrl || item.pressedIconSvg;\n\n if (!hasIcon) {\n warnOnce('ButtonGroup', `Missing icon for item with id: ${item.id}`);\n }\n if (!hasPressedIcon) {\n warnOnce('ButtonGroup', `Missing pressed icon for item with id: ${item.id}`);\n }\n\n const feedbackContent = item.pressed ? item.pressedPopoverFeedback ?? item.popoverFeedback : item.popoverFeedback;\n const canShowTooltip = showTooltip && !item.disabled && !item.loading;\n const canShowFeedback = showTooltip && showFeedback && feedbackContent;\n return (\n <div ref={containerRef}>\n <InternalToggleButton\n variant=\"icon\"\n pressed={item.pressed}\n loading={item.loading}\n loadingText={item.loadingText}\n disabled={item.disabled}\n iconName={hasIcon ? item.iconName : 'close'}\n iconUrl={item.iconUrl}\n iconSvg={item.iconSvg}\n pressedIconName={hasIcon ? item.pressedIconName : 'close'}\n pressedIconUrl={item.pressedIconUrl}\n pressedIconSvg={item.pressedIconUrl}\n ariaLabel={item.text}\n onChange={event => fireCancelableEvent(onItemClick, { id: item.id, pressed: event.detail.pressed })}\n ref={ref}\n data-testid={item.id}\n data-itemid={item.id}\n className={clsx(testUtilStyles.item, testUtilStyles['button-group-item'])}\n __title=\"\"\n >\n {item.text}\n </InternalToggleButton>\n {(canShowTooltip || canShowFeedback) && (\n <Tooltip\n trackRef={containerRef}\n trackKey={item.id}\n value={\n (showFeedback && <InternalLiveRegion tagName=\"span\">{feedbackContent}</InternalLiveRegion>) || item.text\n }\n className={clsx(testUtilStyles.tooltip, testUtilStyles['button-group-tooltip'])}\n />\n )}\n </div>\n );\n }\n);\n\nexport default IconToggleButtonItem;\n"]}
|
|
@@ -35,15 +35,32 @@ export interface ButtonGroupProps extends BaseComponentProps {
|
|
|
35
35
|
* ### icon-button
|
|
36
36
|
*
|
|
37
37
|
* * `id` (string) - The unique identifier of the button, used as detail in `onItemClick` handler and to focus the button using `ref.focus(id)`.
|
|
38
|
-
* * `text` (string) - The name shown as a tooltip
|
|
39
|
-
* * `disabled` (optional, boolean) - The disabled state indication for
|
|
40
|
-
* * `loading` (optional, boolean) - The loading state indication for
|
|
38
|
+
* * `text` (string) - The name shown as a tooltip for this button.
|
|
39
|
+
* * `disabled` (optional, boolean) - The disabled state indication for this button.
|
|
40
|
+
* * `loading` (optional, boolean) - The loading state indication for this button.
|
|
41
41
|
* * `loadingText` (optional, string) - The loading text announced to screen readers.
|
|
42
42
|
* * `iconName` (optional, string) - Specifies the name of the icon, used with the [icon component](/components/icon/).
|
|
43
43
|
* * `iconAlt` (optional, string) - Specifies alternate text for the icon when using `iconUrl`.
|
|
44
44
|
* * `iconUrl` (optional, string) - Specifies the URL of a custom icon.
|
|
45
45
|
* * `iconSvg` (optional, ReactNode) - Custom SVG icon. Equivalent to the `svg` slot of the [icon component](/components/icon/).
|
|
46
|
-
* * `popoverFeedback` (optional,
|
|
46
|
+
* * `popoverFeedback` (optional, ReactNode) - Text that appears when the user clicks the button. Use to provide feedback to the user.
|
|
47
|
+
*
|
|
48
|
+
* ### icon-toggle-button
|
|
49
|
+
*
|
|
50
|
+
* * `id` (string) - The unique identifier of the button, used as detail in `onItemClick` handler and to focus the button using `ref.focus(id)`.
|
|
51
|
+
* * `pressed` (boolean) - The toggle button pressed state.
|
|
52
|
+
* * `text` (string) - The name shown as a tooltip for this button.
|
|
53
|
+
* * `disabled` (optional, boolean) - The disabled state indication for this button.
|
|
54
|
+
* * `loading` (optional, boolean) - The loading state indication for this button.
|
|
55
|
+
* * `loadingText` (optional, string) - The loading text announced to screen readers.
|
|
56
|
+
* * `iconName` (optional, string) - Specifies the name of the icon, used with the [icon component](/components/icon/).
|
|
57
|
+
* * `iconUrl` (optional, string) - Specifies the URL of a custom icon.
|
|
58
|
+
* * `iconSvg` (optional, ReactNode) - Custom SVG icon. Equivalent to the `svg` slot of the [icon component](/components/icon/).
|
|
59
|
+
* * `pressedIconName` (optional, string) - Specifies the name of the icon in pressed state, used with the [icon component](/components/icon/).
|
|
60
|
+
* * `pressedIconUrl` (optional, string) - Specifies the URL of a custom icon in pressed state.
|
|
61
|
+
* * `pressedIconSvg` (optional, ReactNode) - Custom SVG icon in pressed state. Equivalent to the `svg` slot of the [icon component](/components/icon/).
|
|
62
|
+
* * `popoverFeedback` (optional, ReactNode) - Text that appears when the user clicks the button. Use to provide feedback to the user.
|
|
63
|
+
* * `pressedPopoverFeedback` (optional, ReactNode) - Text that appears when the user clicks the button in pressed state. Defaults to `popoverFeedback`.
|
|
47
64
|
*
|
|
48
65
|
* ### menu-dropdown
|
|
49
66
|
*
|
|
@@ -54,7 +71,7 @@ export interface ButtonGroupProps extends BaseComponentProps {
|
|
|
54
71
|
* * `loadingText` (optional, string) - The loading text announced to screen readers.
|
|
55
72
|
* * `items` (ButtonDropdownProps.ItemOrGroup[]) - The array of dropdown items that belong to this menu.
|
|
56
73
|
*
|
|
57
|
-
* group
|
|
74
|
+
* ### group
|
|
58
75
|
*
|
|
59
76
|
* * `text` (string) - The name of the group rendered as ARIA label for this group.
|
|
60
77
|
* * `items` ((ButtonGroupProps.IconButton | ButtonGroupProps.MenuDropdown)[]) - The array of items that belong to this group.
|
|
@@ -70,7 +87,7 @@ export interface InternalButtonGroupProps extends ButtonGroupProps, InternalBase
|
|
|
70
87
|
export declare namespace ButtonGroupProps {
|
|
71
88
|
type Variant = 'icon';
|
|
72
89
|
type ItemOrGroup = Item | Group;
|
|
73
|
-
type Item = IconButton | MenuDropdown;
|
|
90
|
+
type Item = IconButton | IconToggleButton | MenuDropdown;
|
|
74
91
|
interface IconButton {
|
|
75
92
|
type: 'icon-button';
|
|
76
93
|
id: string;
|
|
@@ -84,6 +101,23 @@ export declare namespace ButtonGroupProps {
|
|
|
84
101
|
iconSvg?: React.ReactNode;
|
|
85
102
|
popoverFeedback?: React.ReactNode;
|
|
86
103
|
}
|
|
104
|
+
interface IconToggleButton {
|
|
105
|
+
type: 'icon-toggle-button';
|
|
106
|
+
id: string;
|
|
107
|
+
text: string;
|
|
108
|
+
pressed: boolean;
|
|
109
|
+
disabled?: boolean;
|
|
110
|
+
loading?: boolean;
|
|
111
|
+
loadingText?: string;
|
|
112
|
+
iconName?: IconProps.Name;
|
|
113
|
+
iconUrl?: string;
|
|
114
|
+
iconSvg?: React.ReactNode;
|
|
115
|
+
pressedIconName?: IconProps.Name;
|
|
116
|
+
pressedIconUrl?: string;
|
|
117
|
+
pressedIconSvg?: React.ReactNode;
|
|
118
|
+
popoverFeedback?: React.ReactNode;
|
|
119
|
+
pressedPopoverFeedback?: React.ReactNode;
|
|
120
|
+
}
|
|
87
121
|
interface MenuDropdown {
|
|
88
122
|
type: 'menu-dropdown';
|
|
89
123
|
id: string;
|
|
@@ -100,6 +134,8 @@ export declare namespace ButtonGroupProps {
|
|
|
100
134
|
}
|
|
101
135
|
interface ItemClickDetails {
|
|
102
136
|
id: string;
|
|
137
|
+
pressed?: boolean;
|
|
138
|
+
checked?: boolean;
|
|
103
139
|
}
|
|
104
140
|
interface Ref {
|
|
105
141
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/button-group/interfaces.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,MAAM,WAAW,gBAAiB,SAAQ,kBAAkB;IAC1D;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC;IAClC;;;;;;;;;;;;OAYG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/button-group/interfaces.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,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ClB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB;IAED,UAAiB,GAAG;QAClB;;WAEG;QACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;KAC7B;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/button-group/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ButtonDropdownProps } from '../button-dropdown/interfaces';\nimport { IconProps } from '../icon/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\n\nexport interface ButtonGroupProps extends BaseComponentProps {\n /**\n * Adds `aria-label` to the button group toolbar element.\n * Use this to provide a unique accessible name for each button group on the page.\n */\n ariaLabel?: string;\n /**\n * Determines the general styling of the button dropdown.\n * * `icon` for icon buttons.\n */\n variant: ButtonGroupProps.Variant;\n /**\n * Use this property to determine dropdown placement strategy for all menu dropdown items.\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 * We recommend you use discretion, and don't enable this property unless necessary\n * because fixed positioning results in a slight, visible lag when scrolling complex pages.\n */\n dropdownExpandToViewport?: boolean;\n /**\n * Array of objects with a number of supported types.\n *\n * ### icon-button\n *\n * * `id` (string) - The unique identifier of the button, used as detail in `onItemClick` handler and to focus the button using `ref.focus(id)`.\n * * `text` (string) - The name shown as a tooltip
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/button-group/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ButtonDropdownProps } from '../button-dropdown/interfaces';\nimport { IconProps } from '../icon/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\n\nexport interface ButtonGroupProps extends BaseComponentProps {\n /**\n * Adds `aria-label` to the button group toolbar element.\n * Use this to provide a unique accessible name for each button group on the page.\n */\n ariaLabel?: string;\n /**\n * Determines the general styling of the button dropdown.\n * * `icon` for icon buttons.\n */\n variant: ButtonGroupProps.Variant;\n /**\n * Use this property to determine dropdown placement strategy for all menu dropdown items.\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 * We recommend you use discretion, and don't enable this property unless necessary\n * because fixed positioning results in a slight, visible lag when scrolling complex pages.\n */\n dropdownExpandToViewport?: boolean;\n /**\n * Array of objects with a number of supported types.\n *\n * ### icon-button\n *\n * * `id` (string) - The unique identifier of the button, used as detail in `onItemClick` handler and to focus the button using `ref.focus(id)`.\n * * `text` (string) - The name shown as a tooltip for this button.\n * * `disabled` (optional, boolean) - The disabled state indication for this button.\n * * `loading` (optional, boolean) - The loading state indication for this button.\n * * `loadingText` (optional, string) - The loading text announced to screen readers.\n * * `iconName` (optional, string) - Specifies the name of the icon, used with the [icon component](/components/icon/).\n * * `iconAlt` (optional, string) - Specifies alternate text for the icon when using `iconUrl`.\n * * `iconUrl` (optional, string) - Specifies the URL of a custom icon.\n * * `iconSvg` (optional, ReactNode) - Custom SVG icon. Equivalent to the `svg` slot of the [icon component](/components/icon/).\n * * `popoverFeedback` (optional, ReactNode) - Text that appears when the user clicks the button. Use to provide feedback to the user.\n *\n * ### icon-toggle-button\n *\n * * `id` (string) - The unique identifier of the button, used as detail in `onItemClick` handler and to focus the button using `ref.focus(id)`.\n * * `pressed` (boolean) - The toggle button pressed state.\n * * `text` (string) - The name shown as a tooltip for this button.\n * * `disabled` (optional, boolean) - The disabled state indication for this button.\n * * `loading` (optional, boolean) - The loading state indication for this button.\n * * `loadingText` (optional, string) - The loading text announced to screen readers.\n * * `iconName` (optional, string) - Specifies the name of the icon, used with the [icon component](/components/icon/).\n * * `iconUrl` (optional, string) - Specifies the URL of a custom icon.\n * * `iconSvg` (optional, ReactNode) - Custom SVG icon. Equivalent to the `svg` slot of the [icon component](/components/icon/).\n * * `pressedIconName` (optional, string) - Specifies the name of the icon in pressed state, used with the [icon component](/components/icon/).\n * * `pressedIconUrl` (optional, string) - Specifies the URL of a custom icon in pressed state.\n * * `pressedIconSvg` (optional, ReactNode) - Custom SVG icon in pressed state. Equivalent to the `svg` slot of the [icon component](/components/icon/).\n * * `popoverFeedback` (optional, ReactNode) - Text that appears when the user clicks the button. Use to provide feedback to the user.\n * * `pressedPopoverFeedback` (optional, ReactNode) - Text that appears when the user clicks the button in pressed state. Defaults to `popoverFeedback`.\n *\n * ### menu-dropdown\n *\n * * `id` (string) - The unique identifier of the button, used as detail in `onItemClick`.\n * * `text` (string) - The name of the menu button shown as a tooltip.\n * * `disabled` (optional, boolean) - The disabled state indication for the menu button.\n * * `loading` (optional, boolean) - The loading state indication for the menu button.\n * * `loadingText` (optional, string) - The loading text announced to screen readers.\n * * `items` (ButtonDropdownProps.ItemOrGroup[]) - The array of dropdown items that belong to this menu.\n *\n * ### group\n *\n * * `text` (string) - The name of the group rendered as ARIA label for this group.\n * * `items` ((ButtonGroupProps.IconButton | ButtonGroupProps.MenuDropdown)[]) - The array of items that belong to this group.\n */\n items: ReadonlyArray<ButtonGroupProps.ItemOrGroup>;\n /**\n * Called when the user clicks on an item, and the item is not disabled. The event detail object contains the id of the clicked item.\n */\n onItemClick?: NonCancelableEventHandler<ButtonGroupProps.ItemClickDetails>;\n}\n\nexport interface InternalButtonGroupProps extends ButtonGroupProps, InternalBaseComponentProps {}\n\nexport namespace ButtonGroupProps {\n export type Variant = 'icon';\n\n export type ItemOrGroup = Item | Group;\n export type Item = IconButton | IconToggleButton | MenuDropdown;\n\n export interface IconButton {\n type: 'icon-button';\n id: string;\n text: string;\n disabled?: boolean;\n loading?: boolean;\n loadingText?: string;\n iconName?: IconProps.Name;\n iconAlt?: string;\n iconUrl?: string;\n iconSvg?: React.ReactNode;\n popoverFeedback?: React.ReactNode;\n }\n\n export interface IconToggleButton {\n type: 'icon-toggle-button';\n id: string;\n text: string;\n pressed: boolean;\n disabled?: boolean;\n loading?: boolean;\n loadingText?: string;\n iconName?: IconProps.Name;\n iconUrl?: string;\n iconSvg?: React.ReactNode;\n pressedIconName?: IconProps.Name;\n pressedIconUrl?: string;\n pressedIconSvg?: React.ReactNode;\n popoverFeedback?: React.ReactNode;\n pressedPopoverFeedback?: React.ReactNode;\n }\n\n export interface MenuDropdown {\n type: 'menu-dropdown';\n id: string;\n text: string;\n disabled?: boolean;\n loading?: boolean;\n loadingText?: string;\n items: ReadonlyArray<ButtonDropdownProps.ItemOrGroup>;\n }\n\n export interface Group {\n type: 'group';\n text: string;\n items: ReadonlyArray<ButtonGroupProps.Item>;\n }\n\n export interface ItemClickDetails {\n id: string;\n pressed?: boolean;\n checked?: boolean;\n }\n\n export interface Ref {\n /**\n * Focuses button group item by id.\n */\n focus(itemId: string): void;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-element.d.ts","sourceRoot":"","sources":["../../../src/button-group/item-element.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6D,MAAM,OAAO,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAuB,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"item-element.d.ts","sourceRoot":"","sources":["../../../src/button-group/item-element.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6D,MAAM,OAAO,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAuB,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAIpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKhD,UAAU,gBAAgB;IACxB,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,OAAO,EAAE,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACpD,UAAU,EAAE,CAAC,OAAO,EAAE,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAC1E,WAAW,CAAC,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC;CACxF;AAED,QAAA,MAAM,WAAW,0FAqHhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -4,6 +4,7 @@ import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react
|
|
|
4
4
|
import { fireCancelableEvent } from '../internal/events';
|
|
5
5
|
import { nodeBelongs } from '../internal/utils/node-belongs';
|
|
6
6
|
import IconButtonItem from './icon-button-item';
|
|
7
|
+
import IconToggleButtonItem from './icon-toggle-button-item.js';
|
|
7
8
|
import MenuDropdownItem from './menu-dropdown-item';
|
|
8
9
|
import styles from './styles.css.js';
|
|
9
10
|
const ItemElement = forwardRef(({ item, dropdownExpandToViewport, tooltip, setTooltip, onItemClick }, ref) => {
|
|
@@ -68,6 +69,7 @@ const ItemElement = forwardRef(({ item, dropdownExpandToViewport, tooltip, setTo
|
|
|
68
69
|
onShowTooltipHard(true);
|
|
69
70
|
}, onBlur: () => onShowTooltipHard(false) },
|
|
70
71
|
item.type === 'icon-button' && (React.createElement(IconButtonItem, { ref: buttonRef, item: item, onItemClick: onClickHandler, showTooltip: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.item) === item.id, showFeedback: !!(tooltip === null || tooltip === void 0 ? void 0 : tooltip.feedback) })),
|
|
72
|
+
item.type === 'icon-toggle-button' && (React.createElement(IconToggleButtonItem, { ref: buttonRef, item: item, onItemClick: onClickHandler, showTooltip: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.item) === item.id, showFeedback: !!(tooltip === null || tooltip === void 0 ? void 0 : tooltip.feedback) })),
|
|
71
73
|
item.type === 'menu-dropdown' && (React.createElement(MenuDropdownItem, { ref: buttonRef, item: item, showTooltip: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.item) === item.id, onItemClick: onClickHandler, expandToViewport: dropdownExpandToViewport }))));
|
|
72
74
|
});
|
|
73
75
|
export default ItemElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-element.js","sourceRoot":"","sources":["../../../src/button-group/item-element.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGlF,OAAO,EAAE,mBAAmB,EAA6B,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,cAAc,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"item-element.js","sourceRoot":"","sources":["../../../src/button-group/item-element.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGlF,OAAO,EAAE,mBAAmB,EAA6B,MAAM,oBAAoB,C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BAAP,OAAO,CAAE,IAAI,MAAK,IAAI,CAAC,EAAE,EACtC,YAAY,EAAE,CAAC,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,CAAA,GACjC,CACH;QACA,IAAI,CAAC,IAAI,KAAK,eAAe,IAAI,CAChC,oBAAC,gBAAgB,IACf,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,IAAI,CAAC,EAAE,EACtC,WAAW,EAAE,cAAc,EAC3B,gBAAgB,EAAE,wBAAwB,GAC1C,CACH,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';\n\nimport { ButtonProps } from '../button/interfaces.js';\nimport { fireCancelableEvent, NonCancelableEventHandler } from '../internal/events';\nimport { nodeBelongs } from '../internal/utils/node-belongs';\nimport IconButtonItem from './icon-button-item';\nimport IconToggleButtonItem from './icon-toggle-button-item.js';\nimport { ButtonGroupProps } from './interfaces';\nimport MenuDropdownItem from './menu-dropdown-item';\n\nimport styles from './styles.css.js';\n\ninterface ItemElementProps {\n item: ButtonGroupProps.Item;\n dropdownExpandToViewport?: boolean;\n tooltip: null | { item: string; feedback: boolean };\n setTooltip: (tooltip: null | { item: string; feedback: boolean }) => void;\n onItemClick?: NonCancelableEventHandler<ButtonGroupProps.ItemClickDetails> | undefined;\n}\n\nconst ItemElement = forwardRef(\n (\n { item, dropdownExpandToViewport, tooltip, setTooltip, onItemClick }: ItemElementProps,\n ref: React.Ref<ButtonProps.Ref>\n ) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n useImperativeHandle(ref, () => ({\n focus: () => {\n buttonRef.current?.focus();\n },\n }));\n\n useEffect(() => {\n if (tooltip?.item !== item.id) {\n return;\n }\n\n const close = () => {\n setTooltip(null);\n };\n\n const handlePointerDownEvent = (event: PointerEvent) => {\n if (event.target && containerRef.current?.contains(event.target as HTMLElement)) {\n return;\n }\n\n close();\n };\n\n const handleKeyDownEvent = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n close();\n }\n };\n\n window.addEventListener('pointerdown', handlePointerDownEvent);\n window.addEventListener('keydown', handleKeyDownEvent);\n\n return () => {\n window.removeEventListener('pointerdown', handlePointerDownEvent);\n window.removeEventListener('keydown', handleKeyDownEvent);\n };\n }, [item.id, tooltip, setTooltip]);\n\n const onShowTooltipSoft = (show: boolean) => {\n if (!tooltip?.feedback) {\n setTooltip(show ? { item: item.id, feedback: false } : null);\n }\n };\n\n const onShowTooltipHard = (show: boolean) => {\n if (!show && item.id !== tooltip?.item) {\n return;\n }\n\n setTooltip(show ? { item: item.id, feedback: false } : null);\n };\n\n const onClickHandler = (event: CustomEvent<ButtonGroupProps.ItemClickDetails>) => {\n const hasPopoverFeedback = 'popoverFeedback' in item && item.popoverFeedback;\n\n if (hasPopoverFeedback) {\n setTooltip({ item: item.id, feedback: true });\n }\n\n fireCancelableEvent(onItemClick, event.detail, event);\n };\n\n return (\n <div\n key={item.id}\n className={styles['item-wrapper']}\n ref={containerRef}\n onPointerEnter={() => onShowTooltipSoft(true)}\n onPointerLeave={() => onShowTooltipSoft(false)}\n onFocus={event => {\n // Showing no tooltip when the focus comes from inside the container.\n // This is needed to prevent the tooltip after a menu closes with item selection or Escape.\n if (event && event.relatedTarget && nodeBelongs(containerRef.current, event.relatedTarget)) {\n return;\n }\n onShowTooltipHard(true);\n }}\n onBlur={() => onShowTooltipHard(false)}\n >\n {item.type === 'icon-button' && (\n <IconButtonItem\n ref={buttonRef}\n item={item}\n onItemClick={onClickHandler}\n showTooltip={tooltip?.item === item.id}\n showFeedback={!!tooltip?.feedback}\n />\n )}\n {item.type === 'icon-toggle-button' && (\n <IconToggleButtonItem\n ref={buttonRef}\n item={item}\n onItemClick={onClickHandler}\n showTooltip={tooltip?.item === item.id}\n showFeedback={!!tooltip?.feedback}\n />\n )}\n {item.type === 'menu-dropdown' && (\n <MenuDropdownItem\n ref={buttonRef}\n item={item}\n showTooltip={tooltip?.item === item.id}\n onItemClick={onClickHandler}\n expandToViewport={dropdownExpandToViewport}\n />\n )}\n </div>\n );\n }\n);\n\nexport default ItemElement;\n"]}
|
|
@@ -10,7 +10,7 @@ import testUtilStyles from './test-classes/styles.css.js';
|
|
|
10
10
|
const MenuDropdownItem = React.forwardRef(({ item, showTooltip, onItemClick, expandToViewport }, ref) => {
|
|
11
11
|
const containerRef = React.useRef(null);
|
|
12
12
|
const onClickHandler = (event) => {
|
|
13
|
-
fireCancelableEvent(onItemClick, { id: event.detail.id }, event);
|
|
13
|
+
fireCancelableEvent(onItemClick, { id: event.detail.id, checked: event.detail.checked }, event);
|
|
14
14
|
};
|
|
15
15
|
return (React.createElement(ButtonDropdown, { ref: ref, variant: "icon", items: item.items, onItemClick: onClickHandler, expandToViewport: expandToViewport, ariaLabel: item.text, className: testUtilStyles['button-group-item'], "data-testid": item.id, customTriggerBuilder: ({ onClick, isOpen, triggerRef, ariaLabel, ariaExpanded, testUtilsClass }) => (React.createElement("div", { ref: containerRef },
|
|
16
16
|
!isOpen && showTooltip && !item.disabled && !item.loading && (React.createElement(Tooltip, { trackRef: containerRef, trackKey: item.id, value: item.text, className: clsx(testUtilStyles.tooltip, testUtilStyles['button-group-tooltip']) })),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-dropdown-item.js","sourceRoot":"","sources":["../../../src/button-group/menu-dropdown-item.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAEhD,OAAO,c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OAAO,EAChB,OAAO,EAAC,EAAE,GACV,CACE,CACP,GACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport InternalButton from '../button/internal';\nimport { ButtonDropdownProps } from '../button-dropdown/interfaces';\nimport ButtonDropdown from '../button-dropdown/internal';\nimport Tooltip from '../internal/components/tooltip';\nimport { CancelableEventHandler, fireCancelableEvent } from '../internal/events';\nimport { ButtonGroupProps } from './interfaces';\n\nimport testUtilStyles from './test-classes/styles.css.js';\n\ninterface MenuDropdownItemProps {\n item: ButtonGroupProps.MenuDropdown;\n showTooltip: boolean;\n onItemClick?: CancelableEventHandler<ButtonGroupProps.ItemClickDetails>;\n expandToViewport?: boolean;\n}\n\nconst MenuDropdownItem = React.forwardRef(\n (\n { item, showTooltip, onItemClick, expandToViewport }: MenuDropdownItemProps,\n ref: React.Ref<ButtonDropdownProps.Ref>\n ) => {\n const containerRef = React.useRef<HTMLDivElement>(null);\n const onClickHandler = (event: CustomEvent<ButtonDropdownProps.ItemClickDetails>) => {\n fireCancelableEvent(onItemClick, { id: event.detail.id, checked: event.detail.checked }, event);\n };\n\n return (\n <ButtonDropdown\n ref={ref}\n variant=\"icon\"\n items={item.items}\n onItemClick={onClickHandler}\n expandToViewport={expandToViewport}\n ariaLabel={item.text}\n className={testUtilStyles['button-group-item']}\n data-testid={item.id}\n customTriggerBuilder={({ onClick, isOpen, triggerRef, ariaLabel, ariaExpanded, testUtilsClass }) => (\n <div ref={containerRef}>\n {!isOpen && showTooltip && !item.disabled && !item.loading && (\n <Tooltip\n trackRef={containerRef}\n trackKey={item.id}\n value={item.text}\n className={clsx(testUtilStyles.tooltip, testUtilStyles['button-group-tooltip'])}\n />\n )}\n <InternalButton\n ref={triggerRef}\n variant=\"icon\"\n ariaLabel={ariaLabel}\n data-itemid={item.id}\n ariaExpanded={ariaExpanded}\n className={clsx(testUtilStyles.item, testUtilsClass)}\n iconName=\"ellipsis\"\n loading={item.loading}\n loadingText={item.loadingText}\n disabled={item.disabled}\n onClick={onClick}\n __title=\"\"\n />\n </div>\n )}\n />\n );\n }\n);\n\nexport default MenuDropdownItem;\n"]}
|
package/lib/internal/template/{internal/components/file-dropzone → file-dropzone}/index.d.ts
RENAMED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import { FileDropzoneProps } from './interfaces';
|
|
3
3
|
import { useFilesDragging } from './use-files-dragging';
|
|
4
4
|
export { FileDropzoneProps, useFilesDragging };
|
|
5
|
-
export default function
|
|
5
|
+
export default function FileDropzone(props: FileDropzoneProps): JSX.Element;
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/file-dropzone/index.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;AAE/C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,iBAAiB,eAG5D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
5
|
+
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
6
|
+
import InternalFileDropzone from './internal';
|
|
7
|
+
import { useFilesDragging } from './use-files-dragging';
|
|
8
|
+
export { useFilesDragging };
|
|
9
|
+
export default function FileDropzone(props) {
|
|
10
|
+
const baseComponentProps = useBaseComponent('FileDropzone');
|
|
11
|
+
return React.createElement(InternalFileDropzone, Object.assign({}, baseComponentProps, props));
|
|
12
|
+
}
|
|
13
|
+
applyDisplayName(FileDropzone, 'FileDropzone');
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/file-dropzone/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,oBAAoB,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAqB,gBAAgB,EAAE,CAAC;AAE/C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAwB;IAC3D,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAC5D,OAAO,oBAAC,oBAAoB,oBAAK,kBAAkB,EAAM,KAAK,EAAI,CAAC;AACrE,CAAC;AAED,gBAAgB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { FileDropzoneProps } from './interfaces';\nimport InternalFileDropzone from './internal';\nimport { useFilesDragging } from './use-files-dragging';\n\nexport { FileDropzoneProps, useFilesDragging };\n\nexport default function FileDropzone(props: FileDropzoneProps) {\n const baseComponentProps = useBaseComponent('FileDropzone');\n return <InternalFileDropzone {...baseComponentProps} {...props} />;\n}\n\napplyDisplayName(FileDropzone, 'FileDropzone');\n"]}
|
package/lib/internal/template/{internal/components/file-dropzone → file-dropzone}/interfaces.d.ts
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { BaseComponentProps } from '
|
|
3
|
-
import { NonCancelableEventHandler } from '
|
|
2
|
+
import { BaseComponentProps } from '../internal/base-component';
|
|
3
|
+
import { NonCancelableEventHandler } from '../internal/events';
|
|
4
4
|
export interface FileDropzoneProps extends BaseComponentProps {
|
|
5
5
|
/**
|
|
6
6
|
* Called when the user selects new file(s), or removes a file.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/file-dropzone/interfaces.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D;;;OAGG;IACH,QAAQ,EAAE,yBAAyB,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACpE;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,yBAAiB,iBAAiB,CAAC;IACjC,UAAiB,YAAY;QAC3B,KAAK,EAAE,IAAI,EAAE,CAAC;KACf;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/file-dropzone/interfaces.tsx"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface FileDropzoneProps extends BaseComponentProps {\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<FileDropzoneProps.ChangeDetail>;\n /**\n * Children of the Dropzone.\n */\n children: React.ReactNode;\n}\n\nexport namespace FileDropzoneProps {\n export interface ChangeDetail {\n value: File[];\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';
|
|
3
|
+
import { FileDropzoneProps } from './interfaces';
|
|
4
|
+
export default function InternalFileDropzone({ onChange, children, __internalRootRef, ...restProps }: FileDropzoneProps & InternalBaseComponentProps): JSX.Element;
|
|
5
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/file-dropzone/internal.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAIjD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,QAAQ,EACR,QAAQ,EACR,iBAAwB,EACxB,GAAG,SAAS,EACb,EAAE,iBAAiB,GAAG,0BAA0B,eA0ChD"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { __rest } from "tslib";
|
|
3
4
|
import React, { useState } from 'react';
|
|
4
5
|
import clsx from 'clsx';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { getBaseProps } from '../internal/base-component';
|
|
7
|
+
import { fireNonCancelableEvent } from '../internal/events';
|
|
7
8
|
import styles from './styles.css.js';
|
|
8
|
-
export
|
|
9
|
-
|
|
9
|
+
export default function InternalFileDropzone(_a) {
|
|
10
|
+
var { onChange, children, __internalRootRef = null } = _a, restProps = __rest(_a, ["onChange", "children", "__internalRootRef"]);
|
|
10
11
|
const [isDropzoneHovered, setDropzoneHovered] = useState(false);
|
|
12
|
+
const baseProps = getBaseProps(restProps);
|
|
11
13
|
const onDragOver = (event) => {
|
|
12
14
|
event.preventDefault();
|
|
13
15
|
if (event.dataTransfer) {
|
|
@@ -27,7 +29,9 @@ export default function InternalFileDropzone({ onChange, children }) {
|
|
|
27
29
|
setDropzoneHovered(false);
|
|
28
30
|
fireNonCancelableEvent(onChange, { value: Array.from(event.dataTransfer.files) });
|
|
29
31
|
};
|
|
30
|
-
return (React.createElement("div", { className: clsx(
|
|
32
|
+
return (React.createElement("div", Object.assign({}, baseProps, { ref: __internalRootRef, className: clsx(baseProps.className, styles.root, {
|
|
33
|
+
[styles.hovered]: isDropzoneHovered,
|
|
34
|
+
}), onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop }),
|
|
31
35
|
React.createElement("div", { className: styles.content }, children)));
|
|
32
36
|
}
|
|
33
|
-
//# sourceMappingURL=
|
|
37
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/file-dropzone/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAI5D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAKI;QALJ,EAC3C,QAAQ,EACR,QAAQ,EACR,iBAAiB,GAAG,IAAI,OAEuB,EAD5C,SAAS,cAJ+B,6CAK5C,CADa;IAEZ,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAE1C,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE;QAC5C,KAAK,CAAC,cAAc,EAAE,CAAC;QAEvB,IAAI,KAAK,CAAC,YAAY,EAAE;YACtB,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACzB,KAAK,CAAC,YAAY,CAAC,UAAU,GAAG,MAAM,CAAC;SACxC;IACH,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,KAAsB,EAAE,EAAE;QAC7C,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,KAAK,CAAC,YAAY,EAAE;YACtB,KAAK,CAAC,YAAY,CAAC,UAAU,GAAG,MAAM,CAAC;SACxC;IACH,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,KAAsB,EAAE,EAAE;QACxC,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAE1B,sBAAsB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC,CAAC;IAEF,OAAO,CACL,6CACM,SAAS,IACb,GAAG,EAAE,iBAAiB,EACtB,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE;YAChD,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,iBAAiB;SACpC,CAAC,EACF,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM;QAEd,6BAAK,SAAS,EAAE,MAAM,CAAC,OAAO,IAAG,QAAQ,CAAO,CAC5C,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useState } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\nimport { FileDropzoneProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\nexport default function InternalFileDropzone({\n onChange,\n children,\n __internalRootRef = null,\n ...restProps\n}: FileDropzoneProps & InternalBaseComponentProps) {\n const [isDropzoneHovered, setDropzoneHovered] = useState(false);\n const baseProps = getBaseProps(restProps);\n\n const onDragOver = (event: React.DragEvent) => {\n event.preventDefault();\n\n if (event.dataTransfer) {\n setDropzoneHovered(true);\n event.dataTransfer.dropEffect = 'copy';\n }\n };\n\n const onDragLeave = (event: React.DragEvent) => {\n event.preventDefault();\n setDropzoneHovered(false);\n if (event.dataTransfer) {\n event.dataTransfer.dropEffect = 'none';\n }\n };\n\n const onDrop = (event: React.DragEvent) => {\n event.preventDefault();\n setDropzoneHovered(false);\n\n fireNonCancelableEvent(onChange, { value: Array.from(event.dataTransfer.files) });\n };\n\n return (\n <div\n {...baseProps}\n ref={__internalRootRef}\n className={clsx(baseProps.className, styles.root, {\n [styles.hovered]: isDropzoneHovered,\n })}\n onDragOver={onDragOver}\n onDragLeave={onDragLeave}\n onDrop={onDrop}\n >\n <div className={styles.content}>{children}</div>\n </div>\n );\n}\n"]}
|
package/lib/internal/template/{internal/components/file-dropzone → file-dropzone}/styles.scoped.css
RENAMED
|
@@ -174,27 +174,30 @@
|
|
|
174
174
|
*/
|
|
175
175
|
/* Style used for links in slots/components that are text heavy, to help links stand out among
|
|
176
176
|
surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
|
|
177
|
-
.
|
|
178
|
-
display: flex;
|
|
179
|
-
flex-direction: column;
|
|
180
|
-
align-items: center;
|
|
181
|
-
justify-content: center;
|
|
182
|
-
gap: var(--space-static-xxs-9qxzo2, 4px);
|
|
177
|
+
.awsui_root_ptw8i_r1fnu_177:not(#\9) {
|
|
183
178
|
padding-block: var(--space-static-l-xtao5d, 20px);
|
|
184
179
|
padding-inline: var(--space-static-l-xtao5d, 20px);
|
|
185
180
|
border-start-start-radius: var(--border-radius-dropzone-849cem, 0px);
|
|
186
181
|
border-start-end-radius: var(--border-radius-dropzone-849cem, 0px);
|
|
187
182
|
border-end-start-radius: var(--border-radius-dropzone-849cem, 0px);
|
|
188
183
|
border-end-end-radius: var(--border-radius-dropzone-849cem, 0px);
|
|
189
|
-
color: var(--color-dropzone-text-
|
|
190
|
-
background-color: var(--color-dropzone-background-
|
|
191
|
-
|
|
184
|
+
color: var(--color-dropzone-text-default-bz3n93, #545b64);
|
|
185
|
+
background-color: var(--color-dropzone-background-default-ocapfj, #ffffff);
|
|
186
|
+
border-color: var(--color-dropzone-border-default-9spjwe, #879596);
|
|
187
|
+
border-block: 1px dashed var(--color-dropzone-border-default-9spjwe, #879596);
|
|
188
|
+
border-inline: 1px dashed var(--color-dropzone-border-default-9spjwe, #879596);
|
|
192
189
|
}
|
|
193
|
-
.
|
|
194
|
-
color: var(--color-dropzone-text-hover-
|
|
195
|
-
background-color: var(--color-dropzone-background-hover-
|
|
190
|
+
.awsui_root_ptw8i_r1fnu_177.awsui_hovered_ptw8i_r1fnu_190:not(#\9) {
|
|
191
|
+
color: var(--color-dropzone-text-hover-r1nuki, #545b64);
|
|
192
|
+
background-color: var(--color-dropzone-background-hover-v8kdg9, #f1faff);
|
|
193
|
+
border-block: 1px dashed var(--color-dropzone-border-hover-1qv9u8, #002b66);
|
|
194
|
+
border-inline: 1px dashed var(--color-dropzone-border-hover-1qv9u8, #002b66);
|
|
196
195
|
}
|
|
197
196
|
|
|
198
|
-
.
|
|
199
|
-
|
|
197
|
+
.awsui_content_ptw8i_r1fnu_197:not(#\9) {
|
|
198
|
+
display: flex;
|
|
199
|
+
flex-direction: column;
|
|
200
|
+
gap: var(--space-static-xxs-9qxzo2, 4px);
|
|
201
|
+
align-items: center;
|
|
202
|
+
justify-content: center;
|
|
200
203
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"root": "
|
|
6
|
-
"hovered": "
|
|
7
|
-
"content": "
|
|
5
|
+
"root": "awsui_root_ptw8i_r1fnu_177",
|
|
6
|
+
"hovered": "awsui_hovered_ptw8i_r1fnu_190",
|
|
7
|
+
"content": "awsui_content_ptw8i_r1fnu_197"
|
|
8
8
|
};
|
|
9
9
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-files-dragging.d.ts","sourceRoot":"","sources":["../../../src/file-dropzone/use-files-dragging.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAgB,gBAAgB;;EAoD/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-files-dragging.js","sourceRoot":"","sources":["../../../src/file-dropzone/use-files-dragging.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE7D,4CAA4C;IAC5C,SAAS,CAAC,GAAG,EAAE;QACb,8CAA8C;QAC9C,IAAI,SAAS,GAAyC,IAAI,CAAC;QAE3D,mFAAmF;QACnF,MAAM,kBAAkB,GAAG,CAAC,KAAgB,EAAE,EAAE;;YAC9C,KAAK,CAAC,cAAc,EAAE,CAAC;YAEvB,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,CAAA,MAAA,KAAK,CAAC,YAAY,0CAAE,KAAK,CAAC,MAAM,KAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;gBACzE,IAAI,CAAA,MA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AE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useEffect, useState } from 'react';\n\n/**\n * A utility to determine whether or not a file is being currently dragged into the window.\n *\n * @returns An object with the following arguments:\n * `areFilesDragging`: True if a file is being dragged over the current window, false otherwise.\n */\nexport function useFilesDragging() {\n const [areFilesDragging, setFilesDragging] = useState(false);\n\n // Registering global drag events listeners.\n useEffect(() => {\n // The timer helps avoiding dropzone blinking.\n let dragTimer: null | ReturnType<typeof setTimeout> = null;\n\n // The file-upload dropzone is shown when the user drags files over to the browser.\n const onDocumentDragOver = (event: DragEvent) => {\n event.preventDefault();\n\n let files = 0;\n for (let item = 0; item < (event.dataTransfer?.types.length || 0); item++) {\n if (event.dataTransfer?.types[item] === 'Files') {\n files++;\n }\n }\n\n if (files > 0) {\n setFilesDragging(true);\n dragTimer && clearTimeout(dragTimer);\n }\n };\n\n // When the files are no longer dragged over the browser the state must be reset.\n const onDocumentDragLeave = (event: DragEvent) => {\n event.preventDefault();\n\n dragTimer = setTimeout(() => setFilesDragging(false), 25);\n };\n\n // If the files were dropped the state must be reset.\n const onDocumentDrop = (event: DragEvent) => {\n event.preventDefault();\n\n dragTimer = setTimeout(() => setFilesDragging(false), 25);\n };\n\n document.addEventListener('dragover', onDocumentDragOver, false);\n document.addEventListener('dragleave', onDocumentDragLeave, false);\n document.addEventListener('drop', onDocumentDrop, false);\n\n return () => {\n dragTimer && clearTimeout(dragTimer);\n document.removeEventListener('dragover', onDocumentDragOver);\n document.removeEventListener('dragleave', onDocumentDragLeave);\n document.removeEventListener('drop', onDocumentDrop);\n };\n }, []);\n\n return { areFilesDragging };\n}\n"]}
|