@duskmoon-dev/core 1.17.1 → 1.18.0

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.
@@ -2,395 +2,199 @@
2
2
  export const css = `/**
3
3
  * Tooltip Component Styles
4
4
  * DuskMoonUI - Material Design 3 inspired tooltip system
5
+ *
6
+ * Breaking: uses native Popover API (popover="hint") + CSS Anchor Positioning.
7
+ * Markup:
8
+ * <button interestfor="id" style="anchor-name: --id" class="tooltip-delay">…</button>
9
+ * <div id="id" popover="hint" class="tooltip tooltip-top" style="position-anchor: --id">…</div>
5
10
  */
6
11
 
7
12
  @layer components {
8
- /* Base Tooltip */
9
- .tooltip {
10
- position: relative;
11
- display: inline-block;
12
- }
13
+ /* ========================================
14
+ * Base surface (the popover element itself)
15
+ * ======================================== */
16
+
17
+ .tooltip[popover] {
18
+ --tooltip-bg: var(--color-on-surface);
19
+ --tooltip-fg: var(--color-surface);
13
20
 
14
- /* Tooltip Content */
15
- .tooltip-content {
16
21
  position: absolute;
22
+ inset: auto;
17
23
  z-index: 1000;
24
+ margin: 0.5rem;
18
25
  padding: 0.375rem 0.75rem;
19
26
  font-size: 0.75rem;
20
27
  font-weight: 500;
21
28
  line-height: 1rem;
22
29
  white-space: nowrap;
23
- background-color: var(--color-on-surface);
24
- color: var(--color-surface);
30
+ background-color: var(--tooltip-bg);
31
+ color: var(--tooltip-fg);
32
+ border: none;
25
33
  border-radius: var(--radius-xs);
26
34
  box-shadow: var(--shadow-md);
27
- opacity: 0;
28
- visibility: hidden;
29
- transition: opacity 150ms ease-out, visibility 150ms ease-out;
30
35
  pointer-events: none;
36
+ opacity: 0;
37
+ transform: scale(0.95);
38
+ position-area: top;
39
+ position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
40
+ transition:
41
+ opacity 150ms ease-out,
42
+ transform 150ms ease-out,
43
+ overlay 150ms ease-out allow-discrete,
44
+ display 150ms ease-out allow-discrete;
31
45
  }
32
46
 
33
- /* Tooltip Arrow */
34
- .tooltip-content::before {
35
- content: '';
36
- position: absolute;
37
- width: 0;
38
- height: 0;
39
- border: 0.375rem solid transparent;
47
+ .tooltip[popover]:popover-open {
48
+ opacity: 1;
49
+ transform: scale(1);
40
50
  }
41
51
 
42
- /* Show Tooltip */
43
- .tooltip:hover .tooltip-content,
44
- .tooltip:focus-within .tooltip-content,
45
- .tooltip-open .tooltip-content {
46
- opacity: 1;
47
- visibility: visible;
52
+ @starting-style {
53
+ .tooltip[popover]:popover-open {
54
+ opacity: 0;
55
+ transform: scale(0.95);
56
+ }
48
57
  }
49
58
 
50
- /* Position: Top (default) - applied to all tooltips as base */
51
- .tooltip .tooltip-content {
52
- bottom: 100%;
53
- top: auto;
54
- left: 50%;
55
- right: auto;
56
- transform: translateX(-50%);
57
- margin-bottom: 0.5rem;
58
- margin-top: 0;
59
- margin-left: 0;
60
- margin-right: 0;
59
+ /* ========================================
60
+ * Preferred position-area
61
+ * ======================================== */
62
+
63
+ .tooltip-top[popover] {
64
+ position-area: top;
61
65
  }
62
66
 
63
- .tooltip .tooltip-content::before {
64
- top: 100%;
65
- bottom: auto;
66
- left: 50%;
67
- right: auto;
68
- transform: translateX(-50%);
69
- border-top-color: var(--color-on-surface);
70
- border-bottom-color: transparent;
71
- border-left-color: transparent;
72
- border-right-color: transparent;
67
+ .tooltip-bottom[popover] {
68
+ position-area: bottom;
69
+ }
70
+
71
+ .tooltip-left[popover] {
72
+ position-area: left;
73
73
  }
74
74
 
75
- /* Position: Bottom */
76
- .tooltip.tooltip-bottom .tooltip-content {
75
+ .tooltip-right[popover] {
76
+ position-area: right;
77
+ }
78
+
79
+ /* ========================================
80
+ * Arrow (preferred position only; may be wrong after flip)
81
+ * ======================================== */
82
+
83
+ .tooltip[popover]::before {
84
+ content: '';
85
+ position: absolute;
86
+ width: 0;
87
+ height: 0;
88
+ border: 0.375rem solid transparent;
89
+ }
90
+
91
+ .tooltip-top[popover]::before,
92
+ .tooltip[popover]:not(.tooltip-bottom):not(.tooltip-left):not(.tooltip-right)::before {
77
93
  top: 100%;
78
- bottom: auto;
79
94
  left: 50%;
80
- right: auto;
81
95
  transform: translateX(-50%);
82
- margin-top: 0.5rem;
83
- margin-bottom: 0;
84
- margin-left: 0;
85
- margin-right: 0;
96
+ border-top-color: var(--tooltip-bg);
86
97
  }
87
98
 
88
- .tooltip.tooltip-bottom .tooltip-content::before {
99
+ .tooltip-bottom[popover]::before {
89
100
  bottom: 100%;
90
101
  top: auto;
91
102
  left: 50%;
92
- right: auto;
93
103
  transform: translateX(-50%);
94
- border-bottom-color: var(--color-on-surface);
104
+ border-bottom-color: var(--tooltip-bg);
95
105
  border-top-color: transparent;
96
- border-left-color: transparent;
97
- border-right-color: transparent;
98
106
  }
99
107
 
100
- /* Position: Left */
101
- .tooltip.tooltip-left .tooltip-content {
102
- right: 100%;
103
- left: auto;
104
- top: 50%;
105
- bottom: auto;
106
- transform: translateY(-50%);
107
- margin-right: 0.5rem;
108
- margin-left: 0;
109
- margin-top: 0;
110
- margin-bottom: 0;
111
- }
112
-
113
- .tooltip.tooltip-left .tooltip-content::before {
108
+ .tooltip-left[popover]::before {
114
109
  left: 100%;
115
- right: auto;
116
110
  top: 50%;
117
111
  bottom: auto;
118
112
  transform: translateY(-50%);
119
- border-left-color: var(--color-on-surface);
120
- border-right-color: transparent;
113
+ border-left-color: var(--tooltip-bg);
121
114
  border-top-color: transparent;
122
- border-bottom-color: transparent;
123
115
  }
124
116
 
125
- /* Position: Right */
126
- .tooltip.tooltip-right .tooltip-content {
127
- left: 100%;
128
- right: auto;
129
- top: 50%;
130
- bottom: auto;
131
- transform: translateY(-50%);
132
- margin-left: 0.5rem;
133
- margin-right: 0;
134
- margin-top: 0;
135
- margin-bottom: 0;
136
- }
137
-
138
- .tooltip.tooltip-right .tooltip-content::before {
117
+ .tooltip-right[popover]::before {
139
118
  right: 100%;
140
119
  left: auto;
141
120
  top: 50%;
142
121
  bottom: auto;
143
122
  transform: translateY(-50%);
144
- border-right-color: var(--color-on-surface);
145
- border-left-color: transparent;
123
+ border-right-color: var(--tooltip-bg);
146
124
  border-top-color: transparent;
147
- border-bottom-color: transparent;
148
- }
149
-
150
- /* Light Tooltip */
151
- .tooltip.tooltip-light .tooltip-content {
152
- background-color: var(--color-surface);
153
- color: var(--color-on-surface);
154
- border: 1px solid var(--color-outline);
155
- box-shadow: var(--shadow-md);
156
- }
157
-
158
- .tooltip.tooltip-light .tooltip-content::before {
159
- border-top-color: var(--color-surface);
160
- }
161
-
162
- .tooltip.tooltip-light.tooltip-bottom .tooltip-content::before {
163
- border-bottom-color: var(--color-surface);
164
- }
165
-
166
- .tooltip.tooltip-light.tooltip-left .tooltip-content::before {
167
- border-left-color: var(--color-surface);
168
- }
169
-
170
- .tooltip.tooltip-light.tooltip-right .tooltip-content::before {
171
- border-right-color: var(--color-surface);
172
- }
173
-
174
- /* Color Variants */
175
- .tooltip.tooltip-primary .tooltip-content {
176
- background-color: var(--color-primary);
177
- color: var(--color-primary-content);
178
- }
179
-
180
- .tooltip.tooltip-primary .tooltip-content::before {
181
- border-top-color: var(--color-primary);
182
- }
183
-
184
- .tooltip.tooltip-primary.tooltip-bottom .tooltip-content::before {
185
- border-bottom-color: var(--color-primary);
186
- }
187
-
188
- .tooltip.tooltip-primary.tooltip-left .tooltip-content::before {
189
- border-left-color: var(--color-primary);
190
- }
191
-
192
- .tooltip.tooltip-primary.tooltip-right .tooltip-content::before {
193
- border-right-color: var(--color-primary);
194
125
  }
195
126
 
196
- .tooltip.tooltip-secondary .tooltip-content {
197
- background-color: var(--color-secondary);
198
- color: var(--color-secondary-content);
199
- }
200
-
201
- .tooltip.tooltip-secondary .tooltip-content::before {
202
- border-top-color: var(--color-secondary);
203
- }
204
-
205
- .tooltip.tooltip-secondary.tooltip-bottom .tooltip-content::before {
206
- border-bottom-color: var(--color-secondary);
207
- }
208
-
209
- .tooltip.tooltip-secondary.tooltip-left .tooltip-content::before {
210
- border-left-color: var(--color-secondary);
211
- }
212
-
213
- .tooltip.tooltip-secondary.tooltip-right .tooltip-content::before {
214
- border-right-color: var(--color-secondary);
215
- }
216
-
217
- .tooltip.tooltip-error .tooltip-content {
218
- background-color: var(--color-error);
219
- color: var(--color-error-content);
220
- }
221
-
222
- .tooltip.tooltip-error .tooltip-content::before {
223
- border-top-color: var(--color-error);
224
- }
225
-
226
- .tooltip.tooltip-error.tooltip-bottom .tooltip-content::before {
227
- border-bottom-color: var(--color-error);
228
- }
229
-
230
- .tooltip.tooltip-error.tooltip-left .tooltip-content::before {
231
- border-left-color: var(--color-error);
232
- }
233
-
234
- .tooltip.tooltip-error.tooltip-right .tooltip-content::before {
235
- border-right-color: var(--color-error);
236
- }
237
-
238
- .tooltip.tooltip-tertiary .tooltip-content {
239
- background-color: var(--color-tertiary);
240
- color: var(--color-tertiary-content);
241
- }
242
-
243
- .tooltip.tooltip-tertiary .tooltip-content::before {
244
- border-top-color: var(--color-tertiary);
245
- }
246
-
247
- .tooltip.tooltip-tertiary.tooltip-bottom .tooltip-content::before {
248
- border-bottom-color: var(--color-tertiary);
249
- }
250
-
251
- .tooltip.tooltip-tertiary.tooltip-left .tooltip-content::before {
252
- border-left-color: var(--color-tertiary);
253
- }
254
-
255
- .tooltip.tooltip-tertiary.tooltip-right .tooltip-content::before {
256
- border-right-color: var(--color-tertiary);
257
- }
258
-
259
- .tooltip.tooltip-info .tooltip-content {
260
- background-color: var(--color-info);
261
- color: var(--color-info-content);
262
- }
263
-
264
- .tooltip.tooltip-info .tooltip-content::before {
265
- border-top-color: var(--color-info);
266
- }
267
-
268
- .tooltip.tooltip-info.tooltip-bottom .tooltip-content::before {
269
- border-bottom-color: var(--color-info);
270
- }
127
+ /* ========================================
128
+ * Color variants
129
+ * ======================================== */
271
130
 
272
- .tooltip.tooltip-info.tooltip-left .tooltip-content::before {
273
- border-left-color: var(--color-info);
274
- }
275
-
276
- .tooltip.tooltip-info.tooltip-right .tooltip-content::before {
277
- border-right-color: var(--color-info);
278
- }
279
-
280
- .tooltip.tooltip-success .tooltip-content {
281
- background-color: var(--color-success);
282
- color: var(--color-success-content);
283
- }
284
-
285
- .tooltip.tooltip-success .tooltip-content::before {
286
- border-top-color: var(--color-success);
287
- }
288
-
289
- .tooltip.tooltip-success.tooltip-bottom .tooltip-content::before {
290
- border-bottom-color: var(--color-success);
291
- }
292
-
293
- .tooltip.tooltip-success.tooltip-left .tooltip-content::before {
294
- border-left-color: var(--color-success);
295
- }
296
-
297
- .tooltip.tooltip-success.tooltip-right .tooltip-content::before {
298
- border-right-color: var(--color-success);
299
- }
300
-
301
- .tooltip.tooltip-warning .tooltip-content {
302
- background-color: var(--color-warning);
303
- color: var(--color-warning-content);
304
- }
305
-
306
- .tooltip.tooltip-warning .tooltip-content::before {
307
- border-top-color: var(--color-warning);
308
- }
309
-
310
- .tooltip.tooltip-warning.tooltip-bottom .tooltip-content::before {
311
- border-bottom-color: var(--color-warning);
312
- }
313
-
314
- .tooltip.tooltip-warning.tooltip-left .tooltip-content::before {
315
- border-left-color: var(--color-warning);
316
- }
317
-
318
- .tooltip.tooltip-warning.tooltip-right .tooltip-content::before {
319
- border-right-color: var(--color-warning);
320
- }
321
-
322
- .tooltip.tooltip-accent .tooltip-content {
323
- background-color: var(--color-accent);
324
- color: var(--color-accent-content);
325
- }
326
-
327
- .tooltip.tooltip-accent .tooltip-content::before {
328
- border-top-color: var(--color-accent);
329
- }
330
-
331
- .tooltip.tooltip-accent.tooltip-bottom .tooltip-content::before {
332
- border-bottom-color: var(--color-accent);
333
- }
334
-
335
- .tooltip.tooltip-accent.tooltip-left .tooltip-content::before {
336
- border-left-color: var(--color-accent);
131
+ .tooltip-light[popover] {
132
+ --tooltip-bg: var(--color-surface);
133
+ --tooltip-fg: var(--color-on-surface);
134
+ border: 1px solid var(--color-outline);
337
135
  }
338
136
 
339
- .tooltip.tooltip-accent.tooltip-right .tooltip-content::before {
340
- border-right-color: var(--color-accent);
137
+ .tooltip-primary[popover] {
138
+ --tooltip-bg: var(--color-primary);
139
+ --tooltip-fg: var(--color-primary-content);
341
140
  }
342
141
 
343
- .tooltip.tooltip-neutral .tooltip-content {
344
- background-color: var(--color-neutral);
345
- color: var(--color-neutral-content);
142
+ .tooltip-secondary[popover] {
143
+ --tooltip-bg: var(--color-secondary);
144
+ --tooltip-fg: var(--color-secondary-content);
346
145
  }
347
146
 
348
- .tooltip.tooltip-neutral .tooltip-content::before {
349
- border-top-color: var(--color-neutral);
147
+ .tooltip-tertiary[popover] {
148
+ --tooltip-bg: var(--color-tertiary);
149
+ --tooltip-fg: var(--color-tertiary-content);
350
150
  }
351
151
 
352
- .tooltip.tooltip-neutral.tooltip-bottom .tooltip-content::before {
353
- border-bottom-color: var(--color-neutral);
152
+ .tooltip-info[popover] {
153
+ --tooltip-bg: var(--color-info);
154
+ --tooltip-fg: var(--color-info-content);
354
155
  }
355
156
 
356
- .tooltip.tooltip-neutral.tooltip-left .tooltip-content::before {
357
- border-left-color: var(--color-neutral);
157
+ .tooltip-success[popover] {
158
+ --tooltip-bg: var(--color-success);
159
+ --tooltip-fg: var(--color-success-content);
358
160
  }
359
161
 
360
- .tooltip.tooltip-neutral.tooltip-right .tooltip-content::before {
361
- border-right-color: var(--color-neutral);
162
+ .tooltip-warning[popover] {
163
+ --tooltip-bg: var(--color-warning);
164
+ --tooltip-fg: var(--color-warning-content);
362
165
  }
363
166
 
364
- .tooltip.tooltip-base .tooltip-content {
365
- background-color: var(--color-base-100);
366
- color: var(--color-base-content);
167
+ .tooltip-error[popover] {
168
+ --tooltip-bg: var(--color-error);
169
+ --tooltip-fg: var(--color-error-content);
367
170
  }
368
171
 
369
- .tooltip.tooltip-base .tooltip-content::before {
370
- border-top-color: var(--color-base-100);
172
+ .tooltip-accent[popover] {
173
+ --tooltip-bg: var(--color-accent);
174
+ --tooltip-fg: var(--color-accent-content);
371
175
  }
372
176
 
373
- .tooltip.tooltip-base.tooltip-bottom .tooltip-content::before {
374
- border-bottom-color: var(--color-base-100);
177
+ .tooltip-neutral[popover] {
178
+ --tooltip-bg: var(--color-neutral);
179
+ --tooltip-fg: var(--color-neutral-content);
375
180
  }
376
181
 
377
- .tooltip.tooltip-base.tooltip-left .tooltip-content::before {
378
- border-left-color: var(--color-base-100);
182
+ .tooltip-base[popover] {
183
+ --tooltip-bg: var(--color-base-100);
184
+ --tooltip-fg: var(--color-base-content);
379
185
  }
380
186
 
381
- .tooltip.tooltip-base.tooltip-right .tooltip-content::before {
382
- border-right-color: var(--color-base-100);
383
- }
187
+ /* ========================================
188
+ * Content variants
189
+ * ======================================== */
384
190
 
385
- /* Multi-line Tooltip */
386
- .tooltip-multiline .tooltip-content {
191
+ .tooltip-multiline[popover] {
387
192
  white-space: normal;
388
193
  max-width: 16rem;
389
194
  text-align: center;
390
195
  }
391
196
 
392
- /* Rich Tooltip */
393
- .tooltip-rich .tooltip-content {
197
+ .tooltip-rich[popover] {
394
198
  padding: 0.75rem 1rem;
395
199
  max-width: 20rem;
396
200
  white-space: normal;
@@ -409,23 +213,28 @@ export const css = `/**
409
213
  opacity: 0.9;
410
214
  }
411
215
 
412
- /* Delay Variants */
413
- .tooltip-delay .tooltip-content {
414
- transition-delay: 300ms;
216
+ /* ========================================
217
+ * Invoker utilities (apply on the trigger)
218
+ * ======================================== */
219
+
220
+ .tooltip-delay {
221
+ interest-delay: 300ms;
415
222
  }
416
223
 
417
- .tooltip-delay-long .tooltip-content {
418
- transition-delay: 500ms;
224
+ .tooltip-delay-long {
225
+ interest-delay: 500ms;
419
226
  }
420
227
 
421
- /* Interactive Tooltip */
422
- .tooltip-interactive .tooltip-content {
228
+ .tooltip-interactive[popover] {
423
229
  pointer-events: auto;
424
230
  }
425
231
 
426
- /* Reduce Motion */
232
+ /* ========================================
233
+ * Reduce Motion
234
+ * ======================================== */
235
+
427
236
  @media (prefers-reduced-motion: reduce) {
428
- .tooltip-content {
237
+ .tooltip[popover] {
429
238
  transition: none;
430
239
  }
431
240
  }