@cloudscape-design/components-themeable 3.0.787 → 3.0.788
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/styles/forms/mixins.scss +7 -0
- package/lib/internal/scss/prompt-input/styles.scss +127 -34
- package/lib/internal/scss/prompt-input/test-classes/styles.scss +8 -0
- package/lib/internal/template/internal/components/tooltip/index.d.ts +2 -1
- package/lib/internal/template/internal/components/tooltip/index.d.ts.map +1 -1
- package/lib/internal/template/internal/components/tooltip/index.js +2 -2
- package/lib/internal/template/internal/components/tooltip/index.js.map +1 -1
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/internal/environment.json +1 -1
- package/lib/internal/template/popover/container.d.ts +2 -1
- package/lib/internal/template/popover/container.d.ts.map +1 -1
- package/lib/internal/template/popover/container.js +5 -4
- package/lib/internal/template/popover/container.js.map +1 -1
- package/lib/internal/template/popover/interfaces.d.ts +4 -0
- package/lib/internal/template/popover/interfaces.d.ts.map +1 -1
- package/lib/internal/template/popover/interfaces.js.map +1 -1
- package/lib/internal/template/popover/use-popover-position.d.ts +3 -1
- package/lib/internal/template/popover/use-popover-position.d.ts.map +1 -1
- package/lib/internal/template/popover/use-popover-position.js +21 -5
- package/lib/internal/template/popover/use-popover-position.js.map +1 -1
- package/lib/internal/template/popover/utils/positions.d.ts +2 -1
- package/lib/internal/template/popover/utils/positions.d.ts.map +1 -1
- package/lib/internal/template/popover/utils/positions.js +6 -0
- package/lib/internal/template/popover/utils/positions.js.map +1 -1
- package/lib/internal/template/prompt-input/interfaces.d.ts +16 -0
- package/lib/internal/template/prompt-input/interfaces.d.ts.map +1 -1
- package/lib/internal/template/prompt-input/interfaces.js.map +1 -1
- package/lib/internal/template/prompt-input/internal.d.ts.map +1 -1
- package/lib/internal/template/prompt-input/internal.js +28 -11
- package/lib/internal/template/prompt-input/internal.js.map +1 -1
- package/lib/internal/template/prompt-input/styles.css.js +14 -8
- package/lib/internal/template/prompt-input/styles.scoped.css +264 -68
- package/lib/internal/template/prompt-input/styles.selectors.js +14 -8
- package/lib/internal/template/prompt-input/test-classes/styles.css.js +5 -3
- package/lib/internal/template/prompt-input/test-classes/styles.scoped.css +11 -3
- package/lib/internal/template/prompt-input/test-classes/styles.selectors.js +5 -3
- package/lib/internal/template/select/parts/item.d.ts.map +1 -1
- package/lib/internal/template/select/parts/item.js +1 -1
- package/lib/internal/template/select/parts/item.js.map +1 -1
- package/lib/internal/template/select/parts/multiselect-item.d.ts.map +1 -1
- package/lib/internal/template/select/parts/multiselect-item.js +1 -1
- package/lib/internal/template/select/parts/multiselect-item.js.map +1 -1
- package/lib/internal/template/test-utils/dom/prompt-input/index.d.ts +2 -0
- package/lib/internal/template/test-utils/dom/prompt-input/index.js +6 -0
- package/lib/internal/template/test-utils/dom/prompt-input/index.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/prompt-input/index.d.ts +2 -0
- package/lib/internal/template/test-utils/selectors/prompt-input/index.js +6 -0
- package/lib/internal/template/test-utils/selectors/prompt-input/index.js.map +1 -1
- package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -255,3 +255,10 @@
|
|
|
255
255
|
block-size: $height;
|
|
256
256
|
inline-size: $width;
|
|
257
257
|
}
|
|
258
|
+
|
|
259
|
+
@mixin control-border-radius-full {
|
|
260
|
+
border-start-start-radius: constants.$control-border-radius;
|
|
261
|
+
border-start-end-radius: constants.$control-border-radius;
|
|
262
|
+
border-end-start-radius: constants.$control-border-radius;
|
|
263
|
+
border-end-end-radius: constants.$control-border-radius;
|
|
264
|
+
}
|
|
@@ -6,40 +6,81 @@
|
|
|
6
6
|
|
|
7
7
|
@use '../internal/styles' as styles;
|
|
8
8
|
@use '../internal/styles/tokens' as awsui;
|
|
9
|
+
@use '../internal/styles/foundation/' as foundation;
|
|
10
|
+
@use '../internal/styles/forms/constants' as constants;
|
|
9
11
|
@use '@cloudscape-design/component-toolkit/internal/focus-visible' as focus-visible;
|
|
10
12
|
|
|
11
13
|
$send-icon-right-spacing: awsui.$space-static-xxs;
|
|
14
|
+
$invalid-border-offset: constants.$invalid-control-left-padding;
|
|
12
15
|
|
|
13
16
|
.root {
|
|
14
|
-
|
|
17
|
+
@include styles.styles-reset;
|
|
18
|
+
@include styles.control-border-radius-full();
|
|
19
|
+
cursor: text;
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
background-color: awsui.$color-background-input-default;
|
|
22
|
+
|
|
23
|
+
border-block: styles.$control-border-width solid awsui.$color-border-input-default;
|
|
24
|
+
border-inline: styles.$control-border-width solid awsui.$color-border-input-default;
|
|
25
|
+
|
|
26
|
+
&.textarea-readonly {
|
|
27
|
+
@include styles.form-readonly-element;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.disabled {
|
|
31
|
+
@include styles.form-disabled-element;
|
|
32
|
+
cursor: default;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.textarea-invalid {
|
|
36
|
+
@include styles.form-invalid-control();
|
|
37
|
+
& {
|
|
38
|
+
padding-inline-start: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&:focus-within,
|
|
42
|
+
&:focus {
|
|
43
|
+
@include styles.form-invalid-control();
|
|
44
|
+
& {
|
|
45
|
+
padding-inline-start: 0;
|
|
46
|
+
box-shadow: foundation.$box-shadow-focused-light-invalid;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&.textarea-warning {
|
|
52
|
+
@include styles.form-warning-control();
|
|
53
|
+
& {
|
|
54
|
+
padding-inline-start: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:focus-within,
|
|
58
|
+
&:focus {
|
|
59
|
+
@include styles.form-warning-control();
|
|
60
|
+
& {
|
|
61
|
+
padding-inline-start: 0;
|
|
62
|
+
box-shadow: foundation.$box-shadow-focused-light-invalid;
|
|
30
63
|
}
|
|
31
64
|
}
|
|
32
65
|
}
|
|
66
|
+
|
|
67
|
+
&:focus-within,
|
|
68
|
+
&:focus {
|
|
69
|
+
@include styles.form-focus-element;
|
|
70
|
+
}
|
|
33
71
|
}
|
|
34
72
|
|
|
35
73
|
.textarea {
|
|
36
74
|
@include styles.styles-reset;
|
|
75
|
+
@include styles.control-border-radius-full();
|
|
76
|
+
@include styles.font-body-m;
|
|
37
77
|
// Restore browsers' default resize values
|
|
38
78
|
resize: none;
|
|
39
79
|
// Restore default text cursor
|
|
40
80
|
cursor: text;
|
|
41
81
|
// Allow multi-line placeholders
|
|
42
82
|
white-space: pre-wrap;
|
|
83
|
+
background-color: inherit;
|
|
43
84
|
|
|
44
85
|
padding-block: styles.$control-padding-vertical;
|
|
45
86
|
padding-inline: styles.$control-padding-horizontal;
|
|
@@ -49,19 +90,8 @@ $send-icon-right-spacing: awsui.$space-static-xxs;
|
|
|
49
90
|
inline-size: 100%;
|
|
50
91
|
display: block;
|
|
51
92
|
box-sizing: border-box;
|
|
52
|
-
background-color: awsui.$color-background-input-default;
|
|
53
|
-
border-start-start-radius: styles.$control-border-radius;
|
|
54
|
-
border-start-end-radius: styles.$control-border-radius;
|
|
55
|
-
border-end-start-radius: styles.$control-border-radius;
|
|
56
|
-
border-end-end-radius: styles.$control-border-radius;
|
|
57
|
-
border-block: styles.$control-border-width solid awsui.$color-border-input-default;
|
|
58
|
-
border-inline: styles.$control-border-width solid awsui.$color-border-input-default;
|
|
59
93
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
&.textarea-readonly {
|
|
63
|
-
@include styles.form-readonly-element;
|
|
64
|
-
}
|
|
94
|
+
border: 0;
|
|
65
95
|
|
|
66
96
|
&::placeholder {
|
|
67
97
|
@include styles.form-placeholder;
|
|
@@ -73,7 +103,7 @@ $send-icon-right-spacing: awsui.$space-static-xxs;
|
|
|
73
103
|
}
|
|
74
104
|
|
|
75
105
|
&:focus {
|
|
76
|
-
|
|
106
|
+
outline: none;
|
|
77
107
|
}
|
|
78
108
|
|
|
79
109
|
&:invalid {
|
|
@@ -81,8 +111,14 @@ $send-icon-right-spacing: awsui.$space-static-xxs;
|
|
|
81
111
|
box-shadow: none;
|
|
82
112
|
}
|
|
83
113
|
|
|
114
|
+
&.invalid,
|
|
115
|
+
&.warning {
|
|
116
|
+
padding-inline-start: $invalid-border-offset;
|
|
117
|
+
}
|
|
118
|
+
|
|
84
119
|
&:disabled {
|
|
85
120
|
@include styles.form-disabled-element;
|
|
121
|
+
border: 0;
|
|
86
122
|
cursor: default;
|
|
87
123
|
|
|
88
124
|
&::placeholder {
|
|
@@ -95,14 +131,71 @@ $send-icon-right-spacing: awsui.$space-static-xxs;
|
|
|
95
131
|
}
|
|
96
132
|
}
|
|
97
133
|
|
|
98
|
-
|
|
99
|
-
|
|
134
|
+
&-wrapper {
|
|
135
|
+
display: flex;
|
|
100
136
|
}
|
|
137
|
+
}
|
|
101
138
|
|
|
102
|
-
|
|
103
|
-
|
|
139
|
+
.button {
|
|
140
|
+
align-self: flex-end;
|
|
141
|
+
padding-inline: calc(styles.$control-padding-horizontal / 2);
|
|
142
|
+
padding-block-end: awsui.$space-scaled-xxxs;
|
|
143
|
+
|
|
144
|
+
> .action-button {
|
|
145
|
+
padding: 0;
|
|
146
|
+
|
|
147
|
+
// offset the focus ring by 1px per side so it doesn't blend into the textarea border
|
|
148
|
+
@include focus-visible.when-visible {
|
|
149
|
+
@include styles.focus-highlight(
|
|
150
|
+
(
|
|
151
|
+
'vertical': calc((-1 * #{awsui.$space-xxxs}) - 1px),
|
|
152
|
+
'horizontal': calc((#{awsui.$space-xxxs}) - 1px),
|
|
153
|
+
)
|
|
154
|
+
);
|
|
155
|
+
}
|
|
104
156
|
}
|
|
105
|
-
|
|
106
|
-
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.secondary-content {
|
|
160
|
+
@include styles.styles-reset;
|
|
161
|
+
@include styles.control-border-radius-full();
|
|
162
|
+
|
|
163
|
+
&.with-paddings {
|
|
164
|
+
padding-block-start: styles.$control-padding-vertical;
|
|
165
|
+
padding-block-end: awsui.$space-scaled-s;
|
|
166
|
+
padding-inline-start: styles.$control-padding-horizontal;
|
|
167
|
+
padding-inline-end: calc(styles.$control-padding-horizontal / 2);
|
|
168
|
+
|
|
169
|
+
&.invalid,
|
|
170
|
+
&.warning {
|
|
171
|
+
padding-inline-start: $invalid-border-offset;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.secondary-actions {
|
|
177
|
+
@include styles.styles-reset;
|
|
178
|
+
@include styles.control-border-radius-full();
|
|
179
|
+
display: flex;
|
|
180
|
+
justify-content: space-between;
|
|
181
|
+
align-items: flex-end;
|
|
182
|
+
|
|
183
|
+
&.with-paddings {
|
|
184
|
+
padding-inline-start: styles.$control-padding-horizontal;
|
|
185
|
+
padding-block-start: awsui.$space-scaled-s;
|
|
186
|
+
padding-block-end: styles.$control-padding-vertical;
|
|
187
|
+
|
|
188
|
+
&.invalid,
|
|
189
|
+
&.warning {
|
|
190
|
+
padding-inline-start: $invalid-border-offset;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
> .button {
|
|
194
|
+
padding-block-end: 0;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
> .button {
|
|
199
|
+
padding-block-end: awsui.$space-scaled-xxs;
|
|
107
200
|
}
|
|
108
201
|
}
|
|
@@ -8,6 +8,7 @@ export interface TooltipProps {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
contentAttributes?: React.HTMLAttributes<HTMLDivElement>;
|
|
10
10
|
size?: PopoverProps['size'];
|
|
11
|
+
hideOnOverscroll?: boolean;
|
|
11
12
|
}
|
|
12
|
-
export default function Tooltip({ value, trackRef, trackKey, className, contentAttributes, position, size, }: TooltipProps): JSX.Element;
|
|
13
|
+
export default function Tooltip({ value, trackRef, trackKey, className, contentAttributes, position, size, hideOnOverscroll, }: TooltipProps): JSX.Element;
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/tooltip/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAM3D,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC;IACpD,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/tooltip/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAM3D,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC;IACpD,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,iBAAsB,EACtB,QAAgB,EAChB,IAAc,EACd,gBAAgB,GACjB,EAAE,YAAY,eA6Bd"}
|
|
@@ -8,13 +8,13 @@ import PopoverContainer from '../../../popover/container';
|
|
|
8
8
|
import Portal from '../portal';
|
|
9
9
|
import { Transition } from '../transition';
|
|
10
10
|
import styles from './styles.css.js';
|
|
11
|
-
export default function Tooltip({ value, trackRef, trackKey, className, contentAttributes = {}, position = 'top', size = 'small', }) {
|
|
11
|
+
export default function Tooltip({ value, trackRef, trackKey, className, contentAttributes = {}, position = 'top', size = 'small', hideOnOverscroll, }) {
|
|
12
12
|
if (!trackKey && (typeof value === 'string' || typeof value === 'number')) {
|
|
13
13
|
trackKey = value;
|
|
14
14
|
}
|
|
15
15
|
return (React.createElement(Portal, null,
|
|
16
16
|
React.createElement("div", Object.assign({ className: clsx(styles.root, className) }, contentAttributes, { "data-testid": trackKey }),
|
|
17
|
-
React.createElement(Transition, { in: true }, () => (React.createElement(PopoverContainer, { trackRef: trackRef, trackKey: trackKey, size: size, fixedWidth: false, position: position, zIndex: 7000, arrow: position => React.createElement(PopoverArrow, { position: position }) },
|
|
17
|
+
React.createElement(Transition, { in: true }, () => (React.createElement(PopoverContainer, { trackRef: trackRef, trackKey: trackKey, size: size, fixedWidth: false, position: position, zIndex: 7000, arrow: position => React.createElement(PopoverArrow, { position: position }), hideOnOverscroll: hideOnOverscroll },
|
|
18
18
|
React.createElement(PopoverBody, { dismissButton: false, dismissAriaLabel: undefined, onDismiss: undefined, header: undefined }, value)))))));
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/tooltip/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAE1D,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,MAAM,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/tooltip/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAE1D,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAarC,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,iBAAiB,GAAG,EAAE,EACtB,QAAQ,GAAG,KAAK,EAChB,IAAI,GAAG,OAAO,EACd,gBAAgB,GACH;IACb,IAAI,CAAC,QAAQ,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,EAAE;QACzE,QAAQ,GAAG,KAAK,CAAC;KAClB;IAED,OAAO,CACL,oBAAC,MAAM;QACL,2CAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAM,iBAAiB,mBAAe,QAAQ;YACxF,oBAAC,UAAU,IAAC,EAAE,EAAE,IAAI,IACjB,GAAG,EAAE,CAAC,CACL,oBAAC,gBAAgB,IACf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,KAAK,EACjB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,oBAAC,YAAY,IAAC,QAAQ,EAAE,QAAQ,GAAI,EACvD,gBAAgB,EAAE,gBAAgB;gBAElC,oBAAC,WAAW,IAAC,aAAa,EAAE,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,IACpG,KAAK,CACM,CACG,CACpB,CACU,CACT,CACC,CACV,CAAC;AACJ,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 PopoverArrow from '../../../popover/arrow';\nimport PopoverBody from '../../../popover/body';\nimport PopoverContainer from '../../../popover/container';\nimport { PopoverProps } from '../../../popover/interfaces';\nimport Portal from '../portal';\nimport { Transition } from '../transition';\n\nimport styles from './styles.css.js';\n\nexport interface TooltipProps {\n value: React.ReactNode;\n trackRef: React.RefObject<HTMLElement | SVGElement>;\n trackKey?: string | number;\n position?: 'top' | 'right' | 'bottom' | 'left';\n className?: string;\n contentAttributes?: React.HTMLAttributes<HTMLDivElement>;\n size?: PopoverProps['size'];\n hideOnOverscroll?: boolean;\n}\n\nexport default function Tooltip({\n value,\n trackRef,\n trackKey,\n className,\n contentAttributes = {},\n position = 'top',\n size = 'small',\n hideOnOverscroll,\n}: TooltipProps) {\n if (!trackKey && (typeof value === 'string' || typeof value === 'number')) {\n trackKey = value;\n }\n\n return (\n <Portal>\n <div className={clsx(styles.root, className)} {...contentAttributes} data-testid={trackKey}>\n <Transition in={true}>\n {() => (\n <PopoverContainer\n trackRef={trackRef}\n trackKey={trackKey}\n size={size}\n fixedWidth={false}\n position={position}\n zIndex={7000}\n arrow={position => <PopoverArrow position={position} />}\n hideOnOverscroll={hideOnOverscroll}\n >\n <PopoverBody dismissButton={false} dismissAriaLabel={undefined} onDismiss={undefined} header={undefined}>\n {value}\n </PopoverBody>\n </PopoverContainer>\n )}\n </Transition>\n </div>\n </Portal>\n );\n}\n"]}
|
|
@@ -24,6 +24,7 @@ export interface PopoverContainerProps {
|
|
|
24
24
|
keepPosition?: boolean;
|
|
25
25
|
allowScrollToFit?: boolean;
|
|
26
26
|
allowVerticalOverflow?: boolean;
|
|
27
|
+
hideOnOverscroll?: boolean;
|
|
27
28
|
}
|
|
28
|
-
export default function PopoverContainer({ position, trackRef, trackKey, arrow, children, zIndex, renderWithPortal, size, fixedWidth, variant, keepPosition, allowScrollToFit, allowVerticalOverflow, }: PopoverContainerProps): JSX.Element;
|
|
29
|
+
export default function PopoverContainer({ position, trackRef, trackKey, arrow, children, zIndex, renderWithPortal, size, fixedWidth, variant, keepPosition, allowScrollToFit, allowVerticalOverflow, hideOnOverscroll, }: PopoverContainerProps): JSX.Element | null;
|
|
29
30
|
//# sourceMappingURL=container.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/popover/container.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkC,MAAM,OAAO,CAAC;AAOvD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAK9D,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,QAA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AQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,IAAI,EAAE,YAAY,CAAC,IAAI,GAAG,SAAS,CAAC;IACpC,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,YAAY,CAAC;IAEvB,YAAY,CAAC,EAAE,OAAO,CAAC;IAGvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,MAAM,EACN,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,GACjB,EAAE,qBAAqB,sBAkGvB"}
|
|
@@ -7,14 +7,14 @@ import { useResizeObserver } from '@cloudscape-design/component-toolkit/internal
|
|
|
7
7
|
import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
8
8
|
import usePopoverPosition from './use-popover-position.js';
|
|
9
9
|
import styles from './styles.css.js';
|
|
10
|
-
export default function PopoverContainer({ position, trackRef, trackKey, arrow, children, zIndex, renderWithPortal, size, fixedWidth, variant, keepPosition, allowScrollToFit, allowVerticalOverflow, }) {
|
|
10
|
+
export default function PopoverContainer({ position, trackRef, trackKey, arrow, children, zIndex, renderWithPortal, size, fixedWidth, variant, keepPosition, allowScrollToFit, allowVerticalOverflow, hideOnOverscroll, }) {
|
|
11
11
|
const bodyRef = useRef(null);
|
|
12
12
|
const contentRef = useRef(null);
|
|
13
13
|
const popoverRef = useRef(null);
|
|
14
14
|
const arrowRef = useRef(null);
|
|
15
15
|
const isRefresh = useVisualRefresh();
|
|
16
16
|
// Updates the position handler.
|
|
17
|
-
const { updatePositionHandler, popoverStyle, internalPosition, positionHandlerRef } = usePopoverPosition({
|
|
17
|
+
const { updatePositionHandler, popoverStyle, internalPosition, positionHandlerRef, isOverscrolling } = usePopoverPosition({
|
|
18
18
|
popoverRef,
|
|
19
19
|
bodyRef,
|
|
20
20
|
arrowRef,
|
|
@@ -25,6 +25,7 @@ export default function PopoverContainer({ position, trackRef, trackKey, arrow,
|
|
|
25
25
|
preferredPosition: position,
|
|
26
26
|
renderWithPortal,
|
|
27
27
|
keepPosition,
|
|
28
|
+
hideOnOverscroll,
|
|
28
29
|
});
|
|
29
30
|
// Recalculate position when properties change.
|
|
30
31
|
useLayoutEffect(() => {
|
|
@@ -65,8 +66,8 @@ export default function PopoverContainer({ position, trackRef, trackKey, arrow,
|
|
|
65
66
|
window.removeEventListener('resize', updatePositionOnResize);
|
|
66
67
|
window.removeEventListener('scroll', refreshPosition, true);
|
|
67
68
|
};
|
|
68
|
-
}, [keepPosition, positionHandlerRef, trackRef, updatePositionHandler]);
|
|
69
|
-
return (React.createElement("div", { ref: popoverRef, style: Object.assign(Object.assign({}, popoverStyle), { zIndex }), className: clsx(styles.container, isRefresh && styles.refresh) },
|
|
69
|
+
}, [hideOnOverscroll, keepPosition, positionHandlerRef, trackRef, updatePositionHandler]);
|
|
70
|
+
return isOverscrolling ? null : (React.createElement("div", { ref: popoverRef, style: Object.assign(Object.assign({}, popoverStyle), { zIndex }), className: clsx(styles.container, isRefresh && styles.refresh) },
|
|
70
71
|
React.createElement("div", { ref: arrowRef, className: clsx(styles[`container-arrow`], styles[`container-arrow-position-${internalPosition}`]), "aria-hidden": true }, arrow(internalPosition)),
|
|
71
72
|
React.createElement("div", { ref: bodyRef, className: clsx(styles['container-body'], styles[`container-body-size-${size}`], {
|
|
72
73
|
[styles['fixed-width']]: fixedWidth,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/popover/container.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,O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UAAU,IAAG,QAAQ,CAAO,CAClC,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useLayoutEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\nimport { useResizeObserver } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { InternalPosition, PopoverProps } from './interfaces';\nimport usePopoverPosition from './use-popover-position.js';\n\nimport styles from './styles.css.js';\n\nexport interface PopoverContainerProps {\n /** References the element the container is positioned against. */\n trackRef: React.RefObject<HTMLElement | SVGElement>;\n /**\n Used to update the container position in case track or track position changes:\n \n const trackRef = useRef<Element>(null)\n return (<>\n <Track style={getPosition(selectedItemId)} ref={trackRef} />\n <PopoverContainer trackRef={trackRef} trackKey={selectedItemId} .../>\n </>)\n */\n trackKey?: string | number;\n position: PopoverProps.Position;\n zIndex?: React.CSSProperties['zIndex'];\n arrow: (position: InternalPosition | null) => React.ReactNode;\n children: React.ReactNode;\n renderWithPortal?: boolean;\n size: PopoverProps.Size | 'content';\n fixedWidth: boolean;\n variant?: 'annotation';\n // When keepPosition is true, the popover will not recalculate its position when it resizes nor when it receives clicks.\n keepPosition?: boolean;\n // When allowScrollToFit is true, we will scroll to the the popover if it overflows the viewport even when choosing the best possible position for it.\n // Do not use this if the popover is open on hover, in order to avoid unexpected movement.\n allowScrollToFit?: boolean;\n allowVerticalOverflow?: boolean;\n // Whether the popover should be hidden when the trigger is scrolled away.\n hideOnOverscroll?: boolean;\n}\n\nexport default function PopoverContainer({\n position,\n trackRef,\n trackKey,\n arrow,\n children,\n zIndex,\n renderWithPortal,\n size,\n fixedWidth,\n variant,\n keepPosition,\n allowScrollToFit,\n allowVerticalOverflow,\n hideOnOverscroll,\n}: PopoverContainerProps) {\n const bodyRef = useRef<HTMLDivElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const popoverRef = useRef<HTMLDivElement | null>(null);\n const arrowRef = useRef<HTMLDivElement | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n // Updates the position handler.\n const { updatePositionHandler, popoverStyle, internalPosition, positionHandlerRef, isOverscrolling } =\n usePopoverPosition({\n popoverRef,\n bodyRef,\n arrowRef,\n trackRef,\n contentRef,\n allowScrollToFit,\n allowVerticalOverflow,\n preferredPosition: position,\n renderWithPortal,\n keepPosition,\n hideOnOverscroll,\n });\n\n // Recalculate position when properties change.\n useLayoutEffect(() => {\n updatePositionHandler();\n }, [updatePositionHandler, trackKey]);\n\n // Recalculate position when content size changes.\n useResizeObserver(contentRef, () => {\n updatePositionHandler(true);\n });\n\n // Recalculate position on DOM events.\n useLayoutEffect(() => {\n /*\n This is a heuristic. Some layout changes are caused by user clicks (e.g. toggling the tools panel, submitting a form),\n and by tracking the click event we can adapt the popover's position to the new layout.\n\n TODO: extend this to Enter and Spacebar?\n */\n\n const onClick = (event: UIEvent | KeyboardEvent) => {\n if (\n // Do not update position if keepPosition is true.\n keepPosition ||\n // If the click was on the trigger, this will make the popover appear or disappear,\n // so no need to update its position either in this case.\n nodeContains(trackRef.current, event.target)\n ) {\n return;\n }\n\n requestAnimationFrame(() => {\n updatePositionHandler();\n });\n };\n\n const updatePositionOnResize = () => requestAnimationFrame(() => updatePositionHandler());\n const refreshPosition = () => requestAnimationFrame(() => positionHandlerRef.current());\n\n window.addEventListener('click', onClick);\n window.addEventListener('resize', updatePositionOnResize);\n window.addEventListener('scroll', refreshPosition, true);\n\n return () => {\n window.removeEventListener('click', onClick);\n window.removeEventListener('resize', updatePositionOnResize);\n window.removeEventListener('scroll', refreshPosition, true);\n };\n }, [hideOnOverscroll, keepPosition, positionHandlerRef, trackRef, updatePositionHandler]);\n\n return isOverscrolling ? null : (\n <div\n ref={popoverRef}\n style={{ ...popoverStyle, zIndex }}\n className={clsx(styles.container, isRefresh && styles.refresh)}\n >\n <div\n ref={arrowRef}\n className={clsx(styles[`container-arrow`], styles[`container-arrow-position-${internalPosition}`])}\n aria-hidden={true}\n >\n {arrow(internalPosition)}\n </div>\n\n <div\n ref={bodyRef}\n className={clsx(styles['container-body'], styles[`container-body-size-${size}`], {\n [styles['fixed-width']]: fixedWidth,\n [styles[`container-body-variant-${variant}`]]: variant,\n })}\n >\n <div ref={contentRef}>{children}</div>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -78,6 +78,10 @@ export interface Dimensions {
|
|
|
78
78
|
blockSize: number;
|
|
79
79
|
}
|
|
80
80
|
export type BoundingBox = Dimensions & Offset;
|
|
81
|
+
export type Rect = BoundingBox & {
|
|
82
|
+
insetBlockEnd: number;
|
|
83
|
+
insetInlineEnd: number;
|
|
84
|
+
};
|
|
81
85
|
export declare namespace PopoverProps {
|
|
82
86
|
type Position = 'top' | 'right' | 'bottom' | 'left';
|
|
83
87
|
type Size = 'small' | 'medium' | 'large';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/popover/interfaces.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,WAAW,YAAa,SAAQ,kBAAkB;IACtD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC;IAEjC;;OAEG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC;IAEzB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,WAAW,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC;IAEvC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B;;OAEG;IACH,MAAM,CAAC,EAAE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Y,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC;IAE5C,UAAiB,GAAG;QAClB;;WAEG;QACH,KAAK,IAAI,IAAI,CAAC;KACf;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/popover/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 '../internal/base-component';\n\nexport interface PopoverProps extends BaseComponentProps {\n /**\n * Determines where the popover is displayed when opened, relative to the trigger.\n * If the popover doesn't have enough space to open in this direction, it\n * automatically chooses a better direction based on available space.\n */\n position?: PopoverProps.Position;\n\n /**\n * Determines the maximum width for the popover.\n */\n size?: PopoverProps.Size;\n\n /**\n * Expands the popover body to its maximum width regardless of content.\n * For example, use it when you need to place a column layout in the popover content.\n */\n fixedWidth?: boolean;\n\n /**\n * Specifies the type of content inside the trigger region. The following types are available:\n * - `text` - Use for inline text triggers.\n * - `custom` - Use for the [button](/components/button/) component.\n */\n triggerType?: PopoverProps.TriggerType;\n\n /**\n * Adds `aria-label` to the text trigger button. Use this to provide an accessible name for triggers\n * that don't have visible text, and to distinguish between multiple triggers with identical visible text.\n */\n triggerAriaLabel?: string;\n\n /**\n * Specifies if the text trigger content should wrap. If you set it to false, it prevents the text from\n * wrapping and truncates it with an ellipsis.\n */\n wrapTriggerText?: boolean;\n\n /**\n * Element that triggers the popover when selected by the user.\n * @displayname trigger\n */\n children?: React.ReactNode;\n\n /**\n * Specifies optional header text for the popover.\n */\n header?: string;\n\n /**\n * Content of the popover.\n */\n content?: React.ReactNode;\n\n /**\n * Determines whether the dismiss button is shown in the popover body.\n */\n dismissButton?: boolean;\n\n /**\n * Adds an `aria-label` to the dismiss button for accessibility.\n * @i18n\n */\n dismissAriaLabel?: string;\n\n /**\n * By default, the popover is constrained to fit inside its parent\n * [stacking context](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context).\n * Enabling this property will allow the popover to be rendered in the root stack context using\n * [React Portals](https://reactjs.org/docs/portals.html).\n * Enable this setting if you need the popover to ignore its parent stacking context, such as in side navigation.\n *\n * Note: Using popover rendered with portal within a Modal is not supported.\n */\n renderWithPortal?: boolean;\n}\n\n/**\n * The position the popover is actually in, given space constraints.\n */\nexport type InternalPosition =\n | 'right-top'\n | 'right-bottom'\n | 'left-top'\n | 'left-bottom'\n | 'top-center'\n | 'top-right'\n | 'top-left'\n | 'bottom-center'\n | 'bottom-right'\n | 'bottom-left';\n\nexport interface Offset {\n insetInlineStart: number;\n insetBlockStart: number;\n}\n\nexport interface Dimensions {\n inlineSize: number;\n blockSize: number;\n}\n\nexport type BoundingBox = Dimensions & Offset;\n\nexport namespace PopoverProps {\n export type Position = 'top' | 'right' | 'bottom' | 'left';\n export type Size = 'small' | 'medium' | 'large';\n export type TriggerType = 'text' | 'custom';\n\n export interface Ref {\n /**\n * Sets focus on the popover's trigger.\n */\n focus(): void;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/popover/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 '../internal/base-component';\n\nexport interface PopoverProps extends BaseComponentProps {\n /**\n * Determines where the popover is displayed when opened, relative to the trigger.\n * If the popover doesn't have enough space to open in this direction, it\n * automatically chooses a better direction based on available space.\n */\n position?: PopoverProps.Position;\n\n /**\n * Determines the maximum width for the popover.\n */\n size?: PopoverProps.Size;\n\n /**\n * Expands the popover body to its maximum width regardless of content.\n * For example, use it when you need to place a column layout in the popover content.\n */\n fixedWidth?: boolean;\n\n /**\n * Specifies the type of content inside the trigger region. The following types are available:\n * - `text` - Use for inline text triggers.\n * - `custom` - Use for the [button](/components/button/) component.\n */\n triggerType?: PopoverProps.TriggerType;\n\n /**\n * Adds `aria-label` to the text trigger button. Use this to provide an accessible name for triggers\n * that don't have visible text, and to distinguish between multiple triggers with identical visible text.\n */\n triggerAriaLabel?: string;\n\n /**\n * Specifies if the text trigger content should wrap. If you set it to false, it prevents the text from\n * wrapping and truncates it with an ellipsis.\n */\n wrapTriggerText?: boolean;\n\n /**\n * Element that triggers the popover when selected by the user.\n * @displayname trigger\n */\n children?: React.ReactNode;\n\n /**\n * Specifies optional header text for the popover.\n */\n header?: string;\n\n /**\n * Content of the popover.\n */\n content?: React.ReactNode;\n\n /**\n * Determines whether the dismiss button is shown in the popover body.\n */\n dismissButton?: boolean;\n\n /**\n * Adds an `aria-label` to the dismiss button for accessibility.\n * @i18n\n */\n dismissAriaLabel?: string;\n\n /**\n * By default, the popover is constrained to fit inside its parent\n * [stacking context](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context).\n * Enabling this property will allow the popover to be rendered in the root stack context using\n * [React Portals](https://reactjs.org/docs/portals.html).\n * Enable this setting if you need the popover to ignore its parent stacking context, such as in side navigation.\n *\n * Note: Using popover rendered with portal within a Modal is not supported.\n */\n renderWithPortal?: boolean;\n}\n\n/**\n * The position the popover is actually in, given space constraints.\n */\nexport type InternalPosition =\n | 'right-top'\n | 'right-bottom'\n | 'left-top'\n | 'left-bottom'\n | 'top-center'\n | 'top-right'\n | 'top-left'\n | 'bottom-center'\n | 'bottom-right'\n | 'bottom-left';\n\nexport interface Offset {\n insetInlineStart: number;\n insetBlockStart: number;\n}\n\nexport interface Dimensions {\n inlineSize: number;\n blockSize: number;\n}\n\nexport type BoundingBox = Dimensions & Offset;\n\nexport type Rect = BoundingBox & {\n insetBlockEnd: number;\n insetInlineEnd: number;\n};\n\nexport namespace PopoverProps {\n export type Position = 'top' | 'right' | 'bottom' | 'left';\n export type Size = 'small' | 'medium' | 'large';\n export type TriggerType = 'text' | 'custom';\n\n export interface Ref {\n /**\n * Sets focus on the popover's trigger.\n */\n focus(): void;\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { InternalPosition, Offset, PopoverProps } from './interfaces';
|
|
3
|
-
export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trackRef, contentRef, allowScrollToFit, allowVerticalOverflow, preferredPosition, renderWithPortal, keepPosition, }: {
|
|
3
|
+
export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trackRef, contentRef, allowScrollToFit, allowVerticalOverflow, preferredPosition, renderWithPortal, keepPosition, hideOnOverscroll, }: {
|
|
4
4
|
popoverRef: React.RefObject<HTMLDivElement | null>;
|
|
5
5
|
bodyRef: React.RefObject<HTMLDivElement | null>;
|
|
6
6
|
arrowRef: React.RefObject<HTMLDivElement | null>;
|
|
@@ -11,10 +11,12 @@ export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trac
|
|
|
11
11
|
preferredPosition: PopoverProps.Position;
|
|
12
12
|
renderWithPortal?: boolean;
|
|
13
13
|
keepPosition?: boolean;
|
|
14
|
+
hideOnOverscroll?: boolean;
|
|
14
15
|
}): {
|
|
15
16
|
updatePositionHandler: (onContentResize?: any) => void;
|
|
16
17
|
popoverStyle: Partial<Offset>;
|
|
17
18
|
internalPosition: InternalPosition | null;
|
|
18
19
|
positionHandlerRef: React.MutableRefObject<() => void>;
|
|
20
|
+
isOverscrolling: boolean;
|
|
19
21
|
};
|
|
20
22
|
//# sourceMappingURL=use-popover-position.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-popover-position.d.ts","sourceRoot":"","sources":["../../../src/popover/use-popover-position.ts"],"names":[],"mappings":"AAGA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAW7D,OAAO,EAAe,gBAAgB,EAAE,MAAM,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"use-popover-position.d.ts","sourceRoot":"","sources":["../../../src/popover/use-popover-position.ts"],"names":[],"mappings":"AAGA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAW7D,OAAO,EAAe,gBAAgB,EAAE,MAAM,EAAE,YAAY,EAAQ,MAAM,cAAc,CAAC;AAGzF,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,UAAU,EACV,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GACjB,EAAE;IACD,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACnD,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAChD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACjD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,UAAU,GAAG,IAAI,CAAC,CAAC;IAC3D,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACnD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iBAAiB,EAAE,YAAY,CAAC,QAAQ,CAAC;IACzC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;;;;qDAOyC,IAAI;;EA0J7C"}
|
|
@@ -5,13 +5,15 @@ import { nodeContains } from '@cloudscape-design/component-toolkit/dom';
|
|
|
5
5
|
import { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';
|
|
6
6
|
import { getContainingBlock } from '../internal/utils/dom';
|
|
7
7
|
import { calculateScroll, getFirstScrollableParent, scrollRectangleIntoView, } from '../internal/utils/scrollable-containers';
|
|
8
|
-
import { calculatePosition, getDimensions, getOffsetDimensions } from './utils/positions';
|
|
9
|
-
export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trackRef, contentRef, allowScrollToFit, allowVerticalOverflow, preferredPosition, renderWithPortal, keepPosition, }) {
|
|
8
|
+
import { calculatePosition, getDimensions, getOffsetDimensions, isCenterOutside } from './utils/positions';
|
|
9
|
+
export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trackRef, contentRef, allowScrollToFit, allowVerticalOverflow, preferredPosition, renderWithPortal, keepPosition, hideOnOverscroll, }) {
|
|
10
10
|
const previousInternalPositionRef = useRef(null);
|
|
11
11
|
const [popoverStyle, setPopoverStyle] = useState({});
|
|
12
12
|
const [internalPosition, setInternalPosition] = useState(null);
|
|
13
|
+
const [isOverscrolling, setIsOverscrolling] = useState(false);
|
|
13
14
|
// Store the handler in a ref so that it can still be replaced from outside of the listener closure.
|
|
14
15
|
const positionHandlerRef = useRef(() => { });
|
|
16
|
+
const scrollableContainerRectRef = useRef(null);
|
|
15
17
|
const updatePositionHandler = useCallback((onContentResize = false) => {
|
|
16
18
|
var _a;
|
|
17
19
|
if (!trackRef.current || !popoverRef.current || !bodyRef.current || !contentRef.current || !arrowRef.current) {
|
|
@@ -98,12 +100,25 @@ export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trac
|
|
|
98
100
|
const scrollableParent = getFirstScrollableParent(popover);
|
|
99
101
|
scrollRectangleIntoView(rect, scrollableParent);
|
|
100
102
|
}
|
|
103
|
+
if (hideOnOverscroll && trackRef.current instanceof HTMLElement) {
|
|
104
|
+
const scrollableContainer = getFirstScrollableParent(trackRef.current);
|
|
105
|
+
if (scrollableContainer) {
|
|
106
|
+
scrollableContainerRectRef.current = getLogicalBoundingClientRect(scrollableContainer);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
101
109
|
positionHandlerRef.current = () => {
|
|
102
|
-
const
|
|
110
|
+
const trackRect = getLogicalBoundingClientRect(track);
|
|
111
|
+
const newTrackOffset = toRelativePosition(trackRect, containingBlock ? getLogicalBoundingClientRect(containingBlock) : viewportRect);
|
|
103
112
|
setPopoverStyle({
|
|
104
113
|
insetBlockStart: newTrackOffset.insetBlockStart + trackRelativeOffset.insetBlockStart,
|
|
105
114
|
insetInlineStart: newTrackOffset.insetInlineStart + trackRelativeOffset.insetInlineStart,
|
|
106
115
|
});
|
|
116
|
+
if (hideOnOverscroll && scrollableContainerRectRef.current) {
|
|
117
|
+
// Assuming the arrow tip is at the vertical center of the popover trigger.
|
|
118
|
+
// This is good enough for disabled reason tooltip in select and multiselect.
|
|
119
|
+
// Can be further refined to take the exact arrow position into account if hideOnOverscroll is to be used in other cases.
|
|
120
|
+
setIsOverscrolling(isCenterOutside(trackRect, scrollableContainerRectRef.current));
|
|
121
|
+
}
|
|
107
122
|
};
|
|
108
123
|
}, [
|
|
109
124
|
trackRef,
|
|
@@ -112,12 +127,13 @@ export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trac
|
|
|
112
127
|
contentRef,
|
|
113
128
|
arrowRef,
|
|
114
129
|
keepPosition,
|
|
115
|
-
allowScrollToFit,
|
|
116
130
|
preferredPosition,
|
|
117
131
|
renderWithPortal,
|
|
118
132
|
allowVerticalOverflow,
|
|
133
|
+
allowScrollToFit,
|
|
134
|
+
hideOnOverscroll,
|
|
119
135
|
]);
|
|
120
|
-
return { updatePositionHandler, popoverStyle, internalPosition, positionHandlerRef };
|
|
136
|
+
return { updatePositionHandler, popoverStyle, internalPosition, positionHandlerRef, isOverscrolling };
|
|
121
137
|
}
|
|
122
138
|
function getBorderWidth(element) {
|
|
123
139
|
return parseInt(getComputedStyle(element).borderWidth) || 0;
|