@react-spectrum/tooltip 3.0.0-alpha.0 → 3.0.0-nightly-4980928d3-240906

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.
@@ -0,0 +1,321 @@
1
+ .KF3Kcq_i18nFontFamily {
2
+ font-synthesis: weight;
3
+ font-family: adobe-clean, Source Sans Pro, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Ubuntu, Trebuchet MS, Lucida Grande, sans-serif;
4
+ }
5
+
6
+ .KF3Kcq_i18nFontFamily:lang(ar) {
7
+ font-family: myriad-arabic, adobe-clean, Source Sans Pro, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Ubuntu, Trebuchet MS, Lucida Grande, sans-serif;
8
+ }
9
+
10
+ .KF3Kcq_i18nFontFamily:lang(he) {
11
+ font-family: myriad-hebrew, adobe-clean, Source Sans Pro, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Ubuntu, Trebuchet MS, Lucida Grande, sans-serif;
12
+ }
13
+
14
+ .KF3Kcq_i18nFontFamily:lang(zh) {
15
+ font-family: adobe-clean-han-traditional, source-han-traditional, MingLiu, Heiti TC Light, sans-serif;
16
+ }
17
+
18
+ .KF3Kcq_i18nFontFamily:lang(zh-Hans) {
19
+ font-family: adobe-clean-han-simplified-c, source-han-simplified-c, SimSun, Heiti SC Light, sans-serif;
20
+ }
21
+
22
+ .KF3Kcq_i18nFontFamily:lang(zh-Hant) {
23
+ font-family: adobe-clean-han-traditional, source-han-traditional, MingLiu, Microsoft JhengHei UI, Microsoft JhengHei, Heiti TC Light, sans-serif;
24
+ }
25
+
26
+ .KF3Kcq_i18nFontFamily:lang(zh-SG), .KF3Kcq_i18nFontFamily:lang(zh-CN) {
27
+ font-family: adobe-clean-han-simplified-c, source-han-simplified-c, SimSun, Heiti SC Light, sans-serif;
28
+ }
29
+
30
+ .KF3Kcq_i18nFontFamily:lang(ko) {
31
+ font-family: adobe-clean-han-korean, source-han-korean, Malgun Gothic, Apple Gothic, sans-serif;
32
+ }
33
+
34
+ .KF3Kcq_i18nFontFamily:lang(ja) {
35
+ font-family: adobe-clean-han-japanese, Hiragino Kaku Gothic ProN, ヒラギノ角ゴ ProN W3, Osaka, YuGothic, Yu Gothic, メイリオ, Meiryo, MS Pゴシック, MS PGothic, sans-serif;
36
+ }
37
+
38
+ .KF3Kcq_spectrum-FocusRing-ring {
39
+ --spectrum-focus-ring-border-radius: var(--spectrum-textfield-border-radius, var(--spectrum-alias-border-radius-regular));
40
+ --spectrum-focus-ring-gap: var(--spectrum-alias-input-focusring-gap);
41
+ --spectrum-focus-ring-size: var(--spectrum-alias-input-focusring-size);
42
+ --spectrum-focus-ring-border-size: 0px;
43
+ --spectrum-focus-ring-color: var(--spectrum-high-contrast-focus-ring-color, var(--spectrum-alias-focus-ring-color, var(--spectrum-alias-focus-color)));
44
+ }
45
+
46
+ .KF3Kcq_spectrum-FocusRing-ring:after {
47
+ border-radius: calc(var(--spectrum-focus-ring-border-radius) + var(--spectrum-focus-ring-gap));
48
+ content: "";
49
+ margin: calc(-1 * var(--spectrum-focus-ring-border-size));
50
+ pointer-events: none;
51
+ transition: box-shadow var(--spectrum-global-animation-duration-100, .13s) ease-out, margin var(--spectrum-global-animation-duration-100, .13s) ease-out;
52
+ display: block;
53
+ position: absolute;
54
+ inset: 0;
55
+ }
56
+
57
+ .KF3Kcq_spectrum-FocusRing.KF3Kcq_focus-ring:after {
58
+ margin: calc(var(--spectrum-focus-ring-gap) * -1 - var(--spectrum-focus-ring-border-size));
59
+ box-shadow: 0 0 0 var(--spectrum-focus-ring-size) var(--spectrum-focus-ring-color);
60
+ }
61
+
62
+ .KF3Kcq_spectrum-FocusRing--quiet:after {
63
+ border-radius: 0;
64
+ }
65
+
66
+ .KF3Kcq_spectrum-FocusRing--quiet.KF3Kcq_focus-ring:after {
67
+ margin: 0 0 calc(var(--spectrum-focus-ring-gap) * -1 - var(--spectrum-focus-ring-border-size)) 0;
68
+ box-shadow: 0 var(--spectrum-focus-ring-size) 0 var(--spectrum-focus-ring-color);
69
+ }
70
+
71
+ @media (forced-colors: active) {
72
+ .KF3Kcq_spectrum-FocusRing, .KF3Kcq_spectrum-FocusRing-ring, .KF3Kcq_spectrum-FocusRing--quiet {
73
+ --spectrum-high-contrast-focus-ring-color: Highlight;
74
+ }
75
+
76
+ :is(.KF3Kcq_spectrum-FocusRing, .KF3Kcq_spectrum-FocusRing-ring, .KF3Kcq_spectrum-FocusRing--quiet):after {
77
+ forced-color-adjust: none;
78
+ }
79
+ }
80
+
81
+ .KF3Kcq_spectrum-overlay {
82
+ visibility: hidden;
83
+ opacity: 0;
84
+ transition: transform var(--spectrum-global-animation-duration-100, .13s) ease-in-out, opacity var(--spectrum-global-animation-duration-100, .13s) ease-in-out, visibility 0s linear var(--spectrum-global-animation-duration-100, .13s);
85
+ pointer-events: none;
86
+ }
87
+
88
+ .KF3Kcq_spectrum-overlay--open {
89
+ visibility: visible;
90
+ opacity: .9999;
91
+ pointer-events: auto;
92
+ transition-delay: 0s;
93
+ }
94
+
95
+ .KF3Kcq_spectrum-overlay--bottom--open {
96
+ transform: translateY(var(--spectrum-overlay-positive-transform-distance));
97
+ }
98
+
99
+ .KF3Kcq_spectrum-overlay--top--open {
100
+ transform: translateY(var(--spectrum-overlay-negative-transform-distance));
101
+ }
102
+
103
+ .KF3Kcq_spectrum-overlay--right--open {
104
+ transform: translateX(var(--spectrum-overlay-positive-transform-distance));
105
+ }
106
+
107
+ .KF3Kcq_spectrum-overlay--left--open {
108
+ transform: translateX(var(--spectrum-overlay-negative-transform-distance));
109
+ }
110
+
111
+ .KF3Kcq_spectrum-Tooltip {
112
+ box-sizing: border-box;
113
+ vertical-align: top;
114
+ padding: var(--spectrum-tooltip-padding-top, var(--spectrum-global-dimension-size-50)) var(--spectrum-tooltip-padding-x, var(--spectrum-global-dimension-size-125));
115
+ border-radius: var(--spectrum-alias-border-radius-regular, var(--spectrum-global-dimension-size-50));
116
+ min-block-size: var(--spectrum-tooltip-min-height, var(--spectrum-global-dimension-size-300));
117
+ font-size: var(--spectrum-tooltip-text-size, var(--spectrum-global-dimension-font-size-75));
118
+ font-weight: var(--spectrum-tooltip-text-font-weight, var(--spectrum-global-font-weight-regular));
119
+ line-height: var(--spectrum-tooltip-text-line-height, var(--spectrum-global-dimension-font-size-200));
120
+ word-break: break-word;
121
+ -webkit-font-smoothing: antialiased;
122
+ cursor: default;
123
+ -webkit-user-select: none;
124
+ user-select: none;
125
+ flex-direction: row;
126
+ align-items: center;
127
+ inline-size: auto;
128
+ display: inline-flex;
129
+ position: relative;
130
+ }
131
+
132
+ .KF3Kcq_spectrum-Tooltip p {
133
+ margin: 0;
134
+ }
135
+
136
+ .KF3Kcq_spectrum-Tooltip-tip {
137
+ border-width: var(--spectrum-tooltip-tip-height, var(--spectrum-global-dimension-size-50));
138
+ border-style: solid;
139
+ border-bottom-color: #0000;
140
+ border-left-color: #0000;
141
+ border-right-color: #0000;
142
+ width: 0;
143
+ height: 0;
144
+ position: absolute;
145
+ }
146
+
147
+ :is(.KF3Kcq_spectrum-Tooltip--right, .KF3Kcq_spectrum-Tooltip--left) .KF3Kcq_spectrum-Tooltip-tip {
148
+ margin-top: calc(var(--spectrum-tooltip-tip-height, var(--spectrum-global-dimension-size-50)) * -1);
149
+ top: 50%;
150
+ }
151
+
152
+ .KF3Kcq_spectrum-Tooltip--right {
153
+ margin-left: var(--spectrum-global-dimension-size-40);
154
+ }
155
+
156
+ .KF3Kcq_spectrum-Tooltip--right .KF3Kcq_spectrum-Tooltip-tip {
157
+ right: 100%;
158
+ transform: rotate(90deg);
159
+ }
160
+
161
+ .KF3Kcq_spectrum-Tooltip--left {
162
+ margin-right: var(--spectrum-global-dimension-size-40);
163
+ }
164
+
165
+ .KF3Kcq_spectrum-Tooltip--left .KF3Kcq_spectrum-Tooltip-tip {
166
+ left: 100%;
167
+ transform: rotate(-90deg);
168
+ }
169
+
170
+ .KF3Kcq_spectrum-Tooltip--top {
171
+ margin-bottom: var(--spectrum-global-dimension-size-40);
172
+ }
173
+
174
+ .KF3Kcq_spectrum-Tooltip--top .KF3Kcq_spectrum-Tooltip-tip {
175
+ top: 100%;
176
+ }
177
+
178
+ .KF3Kcq_spectrum-Tooltip--bottom {
179
+ margin-top: var(--spectrum-global-dimension-size-40);
180
+ }
181
+
182
+ .KF3Kcq_spectrum-Tooltip--bottom .KF3Kcq_spectrum-Tooltip-tip {
183
+ bottom: 100%;
184
+ transform: rotate(-180deg);
185
+ }
186
+
187
+ :is(.KF3Kcq_spectrum-Tooltip--bottom, .KF3Kcq_spectrum-Tooltip--top) .KF3Kcq_spectrum-Tooltip-tip {
188
+ margin-left: calc(var(--spectrum-tooltip-tip-height, var(--spectrum-global-dimension-size-50)) * -1);
189
+ left: 50%;
190
+ }
191
+
192
+ .KF3Kcq_spectrum-Tooltip-typeIcon {
193
+ inline-size: var(--spectrum-tooltip-icon-size, var(--spectrum-global-dimension-size-175));
194
+ block-size: var(--spectrum-tooltip-icon-size, var(--spectrum-global-dimension-size-175));
195
+ margin-inline-start: calc(var(--spectrum-tooltip-icon-margin-x, var(--spectrum-global-dimension-size-100)) - var(--spectrum-tooltip-padding-x, var(--spectrum-global-dimension-size-125)));
196
+ margin-inline-end: var(--spectrum-tooltip-icon-margin-x, var(--spectrum-global-dimension-size-100));
197
+ align-self: flex-start;
198
+ margin-top: 1px;
199
+ }
200
+
201
+ .KF3Kcq_spectrum-Tooltip-label {
202
+ max-inline-size: var(--spectrum-tooltip-content-max-width);
203
+ line-height: var(--spectrum-tooltip-text-line-height, var(--spectrum-global-dimension-font-size-200));
204
+ }
205
+
206
+ .KF3Kcq_u-tooltip-showOnHover {
207
+ display: inline-block;
208
+ position: relative;
209
+ }
210
+
211
+ .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip {
212
+ white-space: nowrap;
213
+ transition: transform var(--spectrum-global-animation-duration-100, .13s) ease-in-out;
214
+ position: absolute;
215
+ top: -100%;
216
+ visibility: visible !important;
217
+ }
218
+
219
+ .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip-label {
220
+ max-inline-size: none;
221
+ }
222
+
223
+ .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip--right, .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip--right .KF3Kcq_spectrum-Tooltip-tip, .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip--left, .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip--left .KF3Kcq_spectrum-Tooltip-tip {
224
+ top: 50%;
225
+ }
226
+
227
+ .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip--right {
228
+ left: 100%;
229
+ transform: translate(0, -50%);
230
+ }
231
+
232
+ .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip--left {
233
+ transform: translate(-100%, -50%);
234
+ }
235
+
236
+ .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip--bottom, .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip--bottom .KF3Kcq_spectrum-Tooltip-tip, .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip--top, .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip--top .KF3Kcq_spectrum-Tooltip-tip {
237
+ left: 50%;
238
+ }
239
+
240
+ .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip--bottom {
241
+ transform: translate(-50%, calc(var(--spectrum-tooltip-tip-margin, var(--spectrum-global-dimension-size-50)) * -1));
242
+ top: 100%;
243
+ }
244
+
245
+ .KF3Kcq_u-tooltip-showOnHover .KF3Kcq_spectrum-Tooltip--top {
246
+ transform: translate(-50%, var(--spectrum-tooltip-tip-margin, var(--spectrum-global-dimension-size-50)));
247
+ }
248
+
249
+ .KF3Kcq_u-tooltip-showOnHover.KF3Kcq_is-hovered .KF3Kcq_spectrum-Tooltip, .KF3Kcq_u-tooltip-showOnHover:focus .KF3Kcq_spectrum-Tooltip, .KF3Kcq_u-tooltip-showOnHover.KF3Kcq_is-focused .KF3Kcq_spectrum-Tooltip, .KF3Kcq_u-tooltip-showOnHover :focus .KF3Kcq_spectrum-Tooltip {
250
+ opacity: 1;
251
+ }
252
+
253
+ .KF3Kcq_u-tooltip-showOnHover.KF3Kcq_is-hovered .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--bottom, .KF3Kcq_u-tooltip-showOnHover:focus .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--bottom, .KF3Kcq_u-tooltip-showOnHover.KF3Kcq_is-focused .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--bottom, .KF3Kcq_u-tooltip-showOnHover :focus .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--bottom {
254
+ transform: translate(-50%);
255
+ }
256
+
257
+ .KF3Kcq_u-tooltip-showOnHover.KF3Kcq_is-hovered .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--top, .KF3Kcq_u-tooltip-showOnHover:focus .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--top, .KF3Kcq_u-tooltip-showOnHover.KF3Kcq_is-focused .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--top, .KF3Kcq_u-tooltip-showOnHover :focus .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--top {
258
+ transform: translate(-50%, calc(var(--spectrum-tooltip-tip-margin, var(--spectrum-global-dimension-size-50)) * -1));
259
+ }
260
+
261
+ .KF3Kcq_u-tooltip-showOnHover.KF3Kcq_is-hovered .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--left, .KF3Kcq_u-tooltip-showOnHover:focus .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--left, .KF3Kcq_u-tooltip-showOnHover.KF3Kcq_is-focused .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--left, .KF3Kcq_u-tooltip-showOnHover :focus .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--left {
262
+ transform: translate(calc(-100% - var(--spectrum-tooltip-tip-margin, var(--spectrum-global-dimension-size-50))), -50%);
263
+ }
264
+
265
+ .KF3Kcq_u-tooltip-showOnHover.KF3Kcq_is-hovered .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--right, .KF3Kcq_u-tooltip-showOnHover:focus .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--right, .KF3Kcq_u-tooltip-showOnHover.KF3Kcq_is-focused .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--right, .KF3Kcq_u-tooltip-showOnHover :focus .KF3Kcq_spectrum-Tooltip.KF3Kcq_spectrum-Tooltip--right {
266
+ transform: translate(var(--spectrum-tooltip-tip-margin, var(--spectrum-global-dimension-size-50)), -50%);
267
+ }
268
+
269
+ .KF3Kcq_spectrum-Tooltip {
270
+ --spectrum-tooltip-background-color: var(--spectrum-alias-neutral-background-color);
271
+ --spectrum-tooltip-negative-background-color: var(--spectrum-negative-background-color-default);
272
+ --spectrum-tooltip-positive-background-color: var(--spectrum-positive-background-color-default);
273
+ --spectrum-tooltip-info-background-color: var(--spectrum-informative-background-color-default);
274
+ background-color: var(--spectrum-tooltip-background-color, var(--spectrum-global-color-static-gray-700));
275
+ color: var(--spectrum-tooltip-text-color, var(--spectrum-global-color-static-white));
276
+ -webkit-filter: var(--spectrum-tooltip-dropshadow);
277
+ will-change: filter;
278
+ }
279
+
280
+ .KF3Kcq_spectrum-Tooltip-tip {
281
+ border-top-color: var(--spectrum-tooltip-background-color, var(--spectrum-global-color-static-gray-700));
282
+ }
283
+
284
+ .KF3Kcq_spectrum-Tooltip--negative, .KF3Kcq_spectrum-Tooltip--error {
285
+ background-color: var(--spectrum-tooltip-negative-background-color, var(--spectrum-global-color-static-red-700));
286
+ }
287
+
288
+ :is(.KF3Kcq_spectrum-Tooltip--negative, .KF3Kcq_spectrum-Tooltip--error) .KF3Kcq_spectrum-Tooltip-tip {
289
+ border-top-color: var(--spectrum-tooltip-negative-background-color, var(--spectrum-global-color-static-red-700));
290
+ }
291
+
292
+ .KF3Kcq_spectrum-Tooltip--info, .KF3Kcq_spectrum-Tooltip--help {
293
+ background-color: var(--spectrum-tooltip-info-background-color, var(--spectrum-global-color-static-blue-700));
294
+ }
295
+
296
+ :is(.KF3Kcq_spectrum-Tooltip--info, .KF3Kcq_spectrum-Tooltip--help) .KF3Kcq_spectrum-Tooltip-tip {
297
+ border-top-color: var(--spectrum-tooltip-info-background-color, var(--spectrum-global-color-static-blue-700));
298
+ }
299
+
300
+ .KF3Kcq_spectrum-Tooltip--positive, .KF3Kcq_spectrum-Tooltip--success {
301
+ background-color: var(--spectrum-tooltip-positive-background-color, var(--spectrum-global-color-static-green-700));
302
+ }
303
+
304
+ :is(.KF3Kcq_spectrum-Tooltip--positive, .KF3Kcq_spectrum-Tooltip--success) .KF3Kcq_spectrum-Tooltip-tip {
305
+ border-top-color: var(--spectrum-tooltip-positive-background-color, var(--spectrum-global-color-static-green-700));
306
+ }
307
+
308
+ @media (forced-colors: active) {
309
+ .KF3Kcq_spectrum-Tooltip {
310
+ border: 1px solid #0000;
311
+ }
312
+
313
+ .KF3Kcq_spectrum-Tooltip-tip {
314
+ forced-color-adjust: none;
315
+ --spectrum-tooltip-background-color: CanvasText;
316
+ --spectrum-tooltip-negative-background-color: Highlight;
317
+ --spectrum-tooltip-info-background-color: Highlight;
318
+ --spectrum-tooltip-positive-background-color: Highlight;
319
+ }
320
+ }
321
+ /*# sourceMappingURL=vars.80858477.css.map */
@@ -0,0 +1 @@
1
+ {"mappings":"AA4DA;;;;;AAIE;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAQA;;;;AAIA;;;;AAKF;;;;;;;;AAOE;;;;;;;;;;;AAqBE;;;;;AAQF;;;;AAKE;;;;;AAOJ;EACE;;;;EAIE;;;;;AAkBJ;;;;;;;AAYA;;;;;;;AAWA;;;;AAIA;;;;AAUA;;;;AAIA;;;;AAIA;;;;;;;;;;;;;;;;;;;;;AA+BE;;;;AASF;;;;;;;;;;;AAeE;;;;;AAMF;;;;AAEE;;;;;AAUF;;;;AAEE;;;;;AAUF;;;;AAEE;;;;AASF;;;;AAEE;;;;;AAYA;;;;;AAMF;;;;;;;;;AAWA;;;;;AAOA;;;;;AAIE;;;;;;;;AASA;;;;AAKA;;;;AAQA;;;;;AAKA;;;;AAIA;;;;AAQA;;;;;AAKA;;;;AAIA;;;;AAOA;;;;AAOA;;;;AAOA;;;;AAOA;;;;AAoBF;;;;;;;;;;;AAgBA;;;;AAIA;;;;AAIE;;;;AAKF;;;;AAIE;;;;AAKF;;;;AAIE;;;;AAKF;EACE;;;;EAGA","sources":["packages/@adobe/spectrum-css-temp/components/tooltip/vars.css"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"vars.80858477.css.map"}
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-spectrum/tooltip",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.0-nightly-4980928d3-240906",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -31,30 +36,29 @@
31
36
  "url": "https://github.com/adobe/react-spectrum"
32
37
  },
33
38
  "dependencies": {
34
- "@babel/runtime": "^7.6.2",
35
- "@react-aria/focus": "^3.2.0",
36
- "@react-aria/interactions": "^3.2.0",
37
- "@react-aria/overlays": "^3.2.0",
38
- "@react-aria/tooltip": "3.0.0-alpha.0",
39
- "@react-aria/utils": "^3.2.0",
40
- "@react-spectrum/overlays": "^3.2.0",
41
- "@react-spectrum/utils": "^3.2.0",
42
- "@react-stately/tooltip": "3.0.0-alpha.0",
43
- "@react-stately/utils": "^3.1.0",
44
- "@react-types/overlays": "^3.2.0",
45
- "@react-types/shared": "^3.2.0",
46
- "@react-types/tooltip": "3.0.0-alpha.0",
47
- "@spectrum-icons/ui": "^3.1.0"
39
+ "@react-aria/focus": "^3.0.0-nightly-4980928d3-240906",
40
+ "@react-aria/overlays": "^3.0.0-nightly-4980928d3-240906",
41
+ "@react-aria/tooltip": "^3.0.0-nightly-4980928d3-240906",
42
+ "@react-aria/utils": "^3.0.0-nightly-4980928d3-240906",
43
+ "@react-spectrum/overlays": "^3.0.0-nightly-4980928d3-240906",
44
+ "@react-spectrum/utils": "^3.0.0-nightly-4980928d3-240906",
45
+ "@react-stately/tooltip": "^3.0.0-nightly-4980928d3-240906",
46
+ "@react-types/overlays": "^3.0.0-nightly-4980928d3-240906",
47
+ "@react-types/shared": "^3.0.0-nightly-4980928d3-240906",
48
+ "@react-types/tooltip": "^3.0.0-nightly-4980928d3-240906",
49
+ "@spectrum-icons/ui": "^3.0.0-nightly-4980928d3-240906",
50
+ "@swc/helpers": "^0.5.0"
48
51
  },
49
52
  "devDependencies": {
50
- "@adobe/spectrum-css-temp": "^3.0.0-alpha.1"
53
+ "@adobe/spectrum-css-temp": "3.0.0-alpha.1"
51
54
  },
52
55
  "peerDependencies": {
53
- "@react-spectrum/provider": "^3.0.0-rc.1",
54
- "react": "^16.8.0"
56
+ "@react-spectrum/provider": "^3.0.0-nightly-4980928d3-240906",
57
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
58
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
55
59
  },
56
60
  "publishConfig": {
57
61
  "access": "public"
58
62
  },
59
- "gitHead": "661f0f2e3b8648a75aae83043267954700059fe0"
60
- }
63
+ "stableVersion": "3.6.9"
64
+ }
package/src/Tooltip.tsx CHANGED
@@ -11,39 +11,40 @@
11
11
  */
12
12
 
13
13
  import AlertSmall from '@spectrum-icons/ui/AlertSmall';
14
- import {classNames, useStyleProps} from '@react-spectrum/utils';
14
+ import {classNames, createDOMRef, useStyleProps} from '@react-spectrum/utils';
15
+ import {DOMRef} from '@react-types/shared';
15
16
  import InfoSmall from '@spectrum-icons/ui/InfoSmall';
16
17
  import {mergeProps} from '@react-aria/utils';
17
- import React, {RefObject, useRef} from 'react';
18
+ import React, {useContext, useImperativeHandle, useRef} from 'react';
18
19
  import {SpectrumTooltipProps} from '@react-types/tooltip';
19
20
  import styles from '@adobe/spectrum-css-temp/components/tooltip/vars.css';
20
21
  import SuccessSmall from '@spectrum-icons/ui/SuccessSmall';
22
+ import {TooltipContext} from './context';
21
23
  import {useTooltip} from '@react-aria/tooltip';
22
- import {useTooltipProvider} from './TooltipTrigger';
23
24
 
24
25
  let iconMap = {
25
- neutral: '',
26
26
  info: InfoSmall,
27
27
  positive: SuccessSmall,
28
28
  negative: AlertSmall
29
29
  };
30
30
 
31
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
- function Tooltip(props: SpectrumTooltipProps, ref: RefObject<HTMLDivElement>) {
33
- let defaultRef = useRef();
34
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
- ref = ref || defaultRef; // need to figure out how to merge?
36
- let {ref: overlayRef, ...tooltipProviderProps} = useTooltipProvider();
31
+ function Tooltip(props: SpectrumTooltipProps, ref: DOMRef) {
32
+ let {ref: overlayRef, arrowProps, state, arrowRef, ...tooltipProviderProps} = useContext(TooltipContext);
33
+ let defaultRef = useRef(undefined);
34
+ overlayRef = overlayRef || defaultRef;
37
35
  props = mergeProps(props, tooltipProviderProps);
38
36
  let {
39
37
  variant = 'neutral',
40
- placement = 'right',
38
+ placement = 'top',
41
39
  isOpen,
42
40
  showIcon,
43
41
  ...otherProps
44
42
  } = props;
45
43
  let {styleProps} = useStyleProps(otherProps);
46
- let {tooltipProps} = useTooltip(props);
44
+ let {tooltipProps} = useTooltip(props, state);
45
+
46
+ // Sync ref with overlayRef from context.
47
+ useImperativeHandle(ref, () => createDOMRef(overlayRef));
47
48
 
48
49
  let Icon = iconMap[variant];
49
50
 
@@ -57,7 +58,8 @@ function Tooltip(props: SpectrumTooltipProps, ref: RefObject<HTMLDivElement>) {
57
58
  `spectrum-Tooltip--${variant}`,
58
59
  `spectrum-Tooltip--${placement}`,
59
60
  {
60
- 'is-open': isOpen
61
+ 'is-open': isOpen,
62
+ [`is-open--${placement}`]: isOpen
61
63
  },
62
64
  styleProps.className
63
65
  )}
@@ -68,12 +70,11 @@ function Tooltip(props: SpectrumTooltipProps, ref: RefObject<HTMLDivElement>) {
68
70
  {props.children}
69
71
  </span>
70
72
  )}
71
- <span className={classNames(styles, 'spectrum-Tooltip-tip')} />
73
+ <span {...arrowProps} ref={arrowRef} className={classNames(styles, 'spectrum-Tooltip-tip')} />
72
74
  </div>
73
75
  );
74
76
  }
75
77
 
76
-
77
78
  /**
78
79
  * Display container for Tooltip content. Has a directional arrow dependent on its placement.
79
80
  */
@@ -10,53 +10,68 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {DOMRef, StyleProps} from '@react-types/shared';
14
13
  import {FocusableProvider} from '@react-aria/focus';
15
14
  import {Overlay} from '@react-spectrum/overlays';
16
- import {PlacementAxis} from '@react-types/overlays';
17
- import React, {RefObject, useContext, useRef} from 'react';
18
- import {TooltipTriggerProps} from '@react-types/tooltip';
19
- import {useDOMRef} from '@react-spectrum/utils';
15
+ import React, {JSX, ReactElement, useRef, useState} from 'react';
16
+ import {SpectrumTooltipTriggerProps} from '@react-types/tooltip';
17
+ import {TooltipContext} from './context';
18
+ import {useLayoutEffect} from '@react-aria/utils';
20
19
  import {useOverlayPosition} from '@react-aria/overlays';
21
20
  import {useTooltipTrigger} from '@react-aria/tooltip';
22
21
  import {useTooltipTriggerState} from '@react-stately/tooltip';
23
22
 
24
- interface TooltipContextProps extends StyleProps {
25
- ref?: RefObject<HTMLDivElement>,
26
- placement?: PlacementAxis,
27
- isOpen?: boolean
28
- }
29
-
30
- const TooltipContext = React.createContext<TooltipContextProps>({});
31
-
32
- export function useTooltipProvider(): TooltipContextProps {
33
- return useContext(TooltipContext) || {};
34
- }
23
+ const DEFAULT_OFFSET = -1; // Offset needed to reach 4px/5px (med/large) distance between tooltip and trigger button
24
+ const DEFAULT_CROSS_OFFSET = 0;
35
25
 
36
- function TooltipTrigger(props: TooltipTriggerProps, ref: DOMRef<HTMLElement>) {
26
+ function TooltipTrigger(props: SpectrumTooltipTriggerProps) {
37
27
  let {
38
28
  children,
39
- isDisabled
29
+ crossOffset = DEFAULT_CROSS_OFFSET,
30
+ isDisabled,
31
+ offset = DEFAULT_OFFSET,
32
+ trigger: triggerAction
40
33
  } = props;
41
34
 
42
- let [trigger, tooltip] = React.Children.toArray(children);
43
-
35
+ let [trigger, tooltip] = React.Children.toArray(children) as [ReactElement, ReactElement];
44
36
  let state = useTooltipTriggerState(props);
45
37
 
46
- let domRef = useDOMRef(ref);
47
- let triggerRef = useRef<HTMLElement>();
48
- let tooltipTriggerRef = domRef || triggerRef;
49
- let overlayRef = useRef<HTMLDivElement>();
38
+ let tooltipTriggerRef = useRef<HTMLElement>(undefined);
39
+ let overlayRef = useRef<HTMLDivElement>(undefined);
50
40
 
51
41
  let {triggerProps, tooltipProps} = useTooltipTrigger({
52
- isDisabled
42
+ isDisabled,
43
+ trigger: triggerAction
53
44
  }, state, tooltipTriggerRef);
54
45
 
55
- let {overlayProps, placement} = useOverlayPosition({
56
- placement: props.placement || 'right',
46
+ let [borderRadius, setBorderRadius] = useState(0);
47
+ useLayoutEffect(() => {
48
+ if (overlayRef.current && state.isOpen) {
49
+ let spectrumBorderRadius = window.getComputedStyle(overlayRef.current).borderRadius;
50
+ if (spectrumBorderRadius !== '') {
51
+ setBorderRadius(parseInt(spectrumBorderRadius, 10));
52
+ }
53
+ }
54
+ }, [state.isOpen, overlayRef]);
55
+ let arrowRef = useRef(null);
56
+ let [arrowWidth, setArrowWidth] = useState(0);
57
+ useLayoutEffect(() => {
58
+ if (arrowRef.current && state.isOpen) {
59
+ setArrowWidth(arrowRef.current.getBoundingClientRect().width);
60
+ }
61
+ }, [state.isOpen, arrowRef]);
62
+
63
+ let {overlayProps, arrowProps, placement} = useOverlayPosition({
64
+ placement: props.placement || 'top',
57
65
  targetRef: tooltipTriggerRef,
58
66
  overlayRef,
59
- isOpen: state.isOpen
67
+ offset,
68
+ crossOffset,
69
+ isOpen: state.isOpen,
70
+ shouldFlip: props.shouldFlip,
71
+ containerPadding: props.containerPadding,
72
+ arrowSize: arrowWidth,
73
+ arrowBoundaryOffset: borderRadius,
74
+ onClose: () => state.close(true)
60
75
  });
61
76
 
62
77
  return (
@@ -66,12 +81,15 @@ function TooltipTrigger(props: TooltipTriggerProps, ref: DOMRef<HTMLElement>) {
66
81
  {trigger}
67
82
  <TooltipContext.Provider
68
83
  value={{
84
+ state,
69
85
  placement,
70
86
  ref: overlayRef,
71
87
  UNSAFE_style: overlayProps.style,
88
+ arrowProps,
89
+ arrowRef: arrowRef,
72
90
  ...tooltipProps
73
91
  }}>
74
- <Overlay isOpen={state.isOpen}>
92
+ <Overlay isOpen={state.isOpen} nodeRef={overlayRef}>
75
93
  {tooltip}
76
94
  </Overlay>
77
95
  </TooltipContext.Provider>
@@ -79,8 +97,32 @@ function TooltipTrigger(props: TooltipTriggerProps, ref: DOMRef<HTMLElement>) {
79
97
  );
80
98
  }
81
99
 
100
+ // Support TooltipTrigger inside components using CollectionBuilder.
101
+ TooltipTrigger.getCollectionNode = function* (props: SpectrumTooltipTriggerProps) {
102
+ // Replaced the use of React.Children.toArray because it mutates the key prop.
103
+ let childArray: ReactElement[] = [];
104
+ React.Children.forEach(props.children, child => {
105
+ if (React.isValidElement(child)) {
106
+ childArray.push(child);
107
+ }
108
+ });
109
+ let [trigger, tooltip] = childArray;
110
+ yield {
111
+ element: trigger,
112
+ wrapper: (element) => (
113
+ <TooltipTrigger key={element.key} {...props}>
114
+ {element}
115
+ {tooltip}
116
+ </TooltipTrigger>
117
+ )
118
+ };
119
+ };
120
+
82
121
  /**
83
- * Display container for Tooltip content. Has a directional arrow dependent on its placement.
122
+ * TooltipTrigger wraps around a trigger element and a Tooltip. It handles opening and closing
123
+ * the Tooltip when the user hovers over or focuses the trigger, and positioning the Tooltip
124
+ * relative to the trigger.
84
125
  */
85
- let _TooltipTrigger = React.forwardRef(TooltipTrigger);
126
+ // We don't want getCollectionNode to show up in the type definition
127
+ let _TooltipTrigger = TooltipTrigger as (props: SpectrumTooltipTriggerProps) => JSX.Element;
86
128
  export {_TooltipTrigger as TooltipTrigger};
package/src/context.ts ADDED
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import {PlacementAxis} from '@react-types/overlays';
14
+ import React, {HTMLAttributes} from 'react';
15
+ import {RefObject, StyleProps} from '@react-types/shared';
16
+ import {TooltipTriggerState} from '@react-stately/tooltip';
17
+
18
+ interface TooltipContextProps extends StyleProps {
19
+ state?: TooltipTriggerState,
20
+ ref?: RefObject<HTMLDivElement | null>,
21
+ placement?: PlacementAxis,
22
+ arrowProps?: HTMLAttributes<HTMLElement>,
23
+ arrowRef?: RefObject<HTMLElement | null>
24
+ }
25
+
26
+ export const TooltipContext = React.createContext<TooltipContextProps>({});
package/src/index.ts CHANGED
@@ -12,5 +12,6 @@
12
12
 
13
13
  /// <reference types="css-module-types" />
14
14
 
15
- export * from './Tooltip';
16
- export * from './TooltipTrigger';
15
+ export {Tooltip} from './Tooltip';
16
+ export {TooltipTrigger} from './TooltipTrigger';
17
+ export type {SpectrumTooltipProps, SpectrumTooltipTriggerProps} from '@react-types/tooltip';