@streamscloud/kit 0.48.0 → 0.49.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.
|
@@ -42,14 +42,24 @@ $effect(() => {
|
|
|
42
42
|
const t = triggerEl;
|
|
43
43
|
const c = contentEl;
|
|
44
44
|
const update = async () => {
|
|
45
|
-
const middleware = [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
const middleware = [
|
|
46
|
+
offsetMiddleware(offset),
|
|
47
|
+
flip({ padding: boundaryMargin }),
|
|
48
|
+
shift({ padding: boundaryMargin }),
|
|
49
|
+
size({
|
|
50
|
+
padding: boundaryMargin,
|
|
51
|
+
apply({ rects, elements, availableWidth, availableHeight }) {
|
|
52
|
+
elements.floating.style.setProperty('--_--popover--available-width', `${availableWidth}px`);
|
|
53
|
+
elements.floating.style.setProperty('--_--popover--available-height', `${availableHeight}px`);
|
|
54
|
+
if (matchWidth) {
|
|
55
|
+
// Clamped here too, not just in CSS: the max-width rule is gated on `panel`, so panel={false} has no other bound.
|
|
56
|
+
const width = Math.min(rects.reference.width, availableWidth);
|
|
57
|
+
elements.floating.style.width = `${width}px`;
|
|
58
|
+
elements.floating.style.minWidth = `${width}px`;
|
|
59
|
+
}
|
|
50
60
|
}
|
|
51
|
-
})
|
|
52
|
-
|
|
61
|
+
})
|
|
62
|
+
];
|
|
53
63
|
const result = await computePosition(t, c, {
|
|
54
64
|
placement: position,
|
|
55
65
|
strategy: fixedPosition ? 'fixed' : 'absolute',
|
|
@@ -187,13 +197,15 @@ const handleBackdropClick = (e) => {
|
|
|
187
197
|
<div
|
|
188
198
|
bind:this={contentEl}
|
|
189
199
|
class="popover__content"
|
|
190
|
-
class:popover__content--
|
|
200
|
+
class:popover__content--bounded={panel}
|
|
191
201
|
data-placement={resolvedPlacement}
|
|
192
202
|
role="dialog"
|
|
193
203
|
tabindex="-1"
|
|
194
204
|
onclick={handleContentClick}
|
|
195
205
|
onkeydown={() => undefined}>
|
|
196
|
-
{
|
|
206
|
+
<div class="popover__panel" class:popover__panel--styled={panel}>
|
|
207
|
+
{@render children()}
|
|
208
|
+
</div>
|
|
197
209
|
</div>
|
|
198
210
|
{/if}
|
|
199
211
|
</div>
|
|
@@ -224,6 +236,23 @@ let dd: PopoverInstance | undefined = $state.raw(undefined);
|
|
|
224
236
|
<button onclick={() => dd?.open()}>Open externally</button>
|
|
225
237
|
```
|
|
226
238
|
|
|
239
|
+
With `panel` on, content sizes to `max-content` and, above the `min-width` floor, never exceeds the room Floating UI measures around the trigger: the `size()` middleware feeds the space left after
|
|
240
|
+
`flip` / `shift` into the max-width / max-height defaults. So the panel always has a definite width — which is what makes a consumer's own
|
|
241
|
+
`text-overflow: ellipsis` (on a `min-inline-size: 0` flex child) resolve inside the panel — and a long list scrolls instead of running off-screen. Set
|
|
242
|
+
`--sc-kit--popover--content--max-width` for a tighter cap than the available space.
|
|
243
|
+
|
|
244
|
+
Because the panel fits itself to the available height, it is a scroll container by default. With `panel={false}` none of the three bounds apply — no width
|
|
245
|
+
cap, no height fit, no clipping — since that consumer owns the box entirely. Floating content nested inside it — a submenu, a `Tooltip` on
|
|
246
|
+
an item — is not clipped **once the panel has appeared**: those bubbles resolve their position against the popover's own positioned box, which sits outside
|
|
247
|
+
the scrolling area, so `fixedPosition` on a nested Popover stays optional. During the appear animation the panel does carry a transform and therefore does
|
|
248
|
+
clip, so a bubble opening within that window (a `Tooltip` with a near-zero `delay`) is cut off for its duration.
|
|
249
|
+
|
|
250
|
+
Two consequences of the panel being a scroll container. `--sc-kit--popover--content--overflow: visible` removes the clipping but not the height fit — the
|
|
251
|
+
panel is still shrunk and its content would paint outside the chrome, so pair it with `--sc-kit--popover--content--max-height: none` to opt out of both. And
|
|
252
|
+
the clip is tight to the panel's box, whose inline padding is `0` by default: content that paints a focus ring outside its own border box (kit's pattern is
|
|
253
|
+
`outline: 2px` + `outline-offset: 2px`, so 4px) needs inline padding of its own — either via `--sc-kit--popover--content--padding` or a wrapper. `PopoverItem`
|
|
254
|
+
already carries the margin that keeps it clear.
|
|
255
|
+
|
|
227
256
|
### CSS Custom Properties
|
|
228
257
|
| Property | Description | Default |
|
|
229
258
|
|---|---|---|
|
|
@@ -232,7 +261,10 @@ let dd: PopoverInstance | undefined = $state.raw(undefined);
|
|
|
232
261
|
| `--sc-kit--popover--content--border-color` | Content border color | `var(--sc-kit--color--border)` |
|
|
233
262
|
| `--sc-kit--popover--content--border-radius` | Content corner radius | `var(--sc-kit--radius--md)` |
|
|
234
263
|
| `--sc-kit--popover--content--box-shadow` | Content shadow | `var(--sc-kit--shadow--lg)` |
|
|
235
|
-
| `--sc-kit--popover--content--
|
|
264
|
+
| `--sc-kit--popover--content--max-height` | Content max height. Applies only with `panel` on — a `panel={false}` consumer owns its own bounds | available height around the trigger |
|
|
265
|
+
| `--sc-kit--popover--content--max-width` | Content max width — the upper bound content shrinks against. Applies only with `panel` on | available width around the trigger |
|
|
266
|
+
| `--sc-kit--popover--content--min-width` | Content min width. Wins over max-width when the two conflict; ignored under `matchWidth` | `12.5rem` |
|
|
267
|
+
| `--sc-kit--popover--content--overflow` | Panel overflow, both axes. Applies only with `panel` on. `visible` opts out of clipping | `hidden auto` |
|
|
236
268
|
| `--sc-kit--popover--content--padding` | Content padding | `var(--sc-kit--space--1) 0` |
|
|
237
269
|
| `--sc-kit--popover--content--z-index` | Content z-index | `var(--sc-kit--z-index--popover)` |
|
|
238
270
|
|
|
@@ -298,7 +330,10 @@ Props for keeping the popover open during interaction:
|
|
|
298
330
|
--_dd--content-border-color: var(--sc-kit--popover--content--border-color, var(--sc-kit--color--border));
|
|
299
331
|
--_dd--content-border-radius: var(--sc-kit--popover--content--border-radius, var(--sc-kit--radius--md));
|
|
300
332
|
--_dd--content-shadow: var(--sc-kit--popover--content--box-shadow, var(--sc-kit--shadow--lg));
|
|
301
|
-
--_dd--content-
|
|
333
|
+
--_dd--content-max-height: var(--sc-kit--popover--content--max-height, var(--_--popover--available-height, 100vh));
|
|
334
|
+
--_dd--content-max-width: var(--sc-kit--popover--content--max-width, var(--_--popover--available-width, 100vw));
|
|
335
|
+
--_dd--content-min-width: var(--sc-kit--popover--content--min-width, 12.5rem);
|
|
336
|
+
--_dd--content-overflow: var(--sc-kit--popover--content--overflow, hidden auto);
|
|
302
337
|
--_dd--content-padding: var(--sc-kit--popover--content--padding, var(--sc-kit--space--1) 0);
|
|
303
338
|
--_dd--content-z-index: var(--sc-kit--popover--content--z-index, var(--sc-kit--z-index--popover));
|
|
304
339
|
--_dd--anim-shift-x: 0;
|
|
@@ -311,15 +346,9 @@ Props for keeping the popover open during interaction:
|
|
|
311
346
|
z-index: var(--_dd--content-z-index);
|
|
312
347
|
width: max-content;
|
|
313
348
|
min-width: var(--_dd--content-min-width);
|
|
314
|
-
transform-origin: var(--_dd--anim-origin-x) var(--_dd--anim-origin-y);
|
|
315
|
-
animation: popover-appear var(--sc-kit--duration--fast) var(--sc-kit--ease--out) both;
|
|
316
349
|
}
|
|
317
|
-
.popover__content--
|
|
318
|
-
|
|
319
|
-
border: 1px solid var(--_dd--content-border-color);
|
|
320
|
-
border-radius: var(--_dd--content-border-radius);
|
|
321
|
-
box-shadow: var(--_dd--content-shadow);
|
|
322
|
-
padding: var(--_dd--content-padding);
|
|
350
|
+
.popover__content--bounded {
|
|
351
|
+
max-width: var(--_dd--content-max-width);
|
|
323
352
|
}
|
|
324
353
|
.popover__content:focus-visible {
|
|
325
354
|
outline: none;
|
|
@@ -364,6 +393,39 @@ Props for keeping the popover open during interaction:
|
|
|
364
393
|
.popover__content[data-placement=right-end] {
|
|
365
394
|
--_dd--anim-origin-y: bottom;
|
|
366
395
|
}
|
|
396
|
+
.popover__panel {
|
|
397
|
+
transform-origin: var(--_dd--anim-origin-x) var(--_dd--anim-origin-y);
|
|
398
|
+
animation: popover-appear var(--sc-kit--duration--fast) var(--sc-kit--ease--out);
|
|
399
|
+
}
|
|
400
|
+
.popover__panel--styled {
|
|
401
|
+
background: var(--_dd--content-background);
|
|
402
|
+
border: 1px solid var(--_dd--content-border-color);
|
|
403
|
+
border-radius: var(--_dd--content-border-radius);
|
|
404
|
+
box-shadow: var(--_dd--content-shadow);
|
|
405
|
+
padding: var(--_dd--content-padding);
|
|
406
|
+
max-height: var(--_dd--content-max-height);
|
|
407
|
+
overflow: var(--_dd--content-overflow);
|
|
408
|
+
--_cross-browser-scrollbar--thumb-color: var(--scrollbar--thumb-color, light-dark(#d1d5db, #4b5563));
|
|
409
|
+
--_cross-browser-scrollbar--track-color: var(--scrollbar--track-color, transparent);
|
|
410
|
+
}
|
|
411
|
+
.popover__panel--styled::-webkit-scrollbar {
|
|
412
|
+
width: 6px;
|
|
413
|
+
height: 6px;
|
|
414
|
+
}
|
|
415
|
+
.popover__panel--styled::-webkit-scrollbar-track {
|
|
416
|
+
background: var(--_cross-browser-scrollbar--track-color);
|
|
417
|
+
border-radius: 100vw;
|
|
418
|
+
}
|
|
419
|
+
.popover__panel--styled::-webkit-scrollbar-thumb {
|
|
420
|
+
background: var(--_cross-browser-scrollbar--thumb-color);
|
|
421
|
+
border-radius: 100vw;
|
|
422
|
+
}
|
|
423
|
+
@supports (scrollbar-color: transparent transparent) {
|
|
424
|
+
.popover__panel--styled {
|
|
425
|
+
scrollbar-color: var(--_cross-browser-scrollbar--thumb-color) var(--_cross-browser-scrollbar--track-color);
|
|
426
|
+
scrollbar-width: thin;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
367
429
|
|
|
368
430
|
@keyframes popover-appear {
|
|
369
431
|
from {
|
|
@@ -12,7 +12,7 @@ type Props = {
|
|
|
12
12
|
boundaryMargin?: number;
|
|
13
13
|
/** Render a semi-transparent backdrop behind the content. */
|
|
14
14
|
backdrop?: boolean;
|
|
15
|
-
/** Make the content match the trigger element width. */
|
|
15
|
+
/** Make the content match the trigger element width, overriding `--sc-kit--popover--content--min-width` (never growing past the available space). */
|
|
16
16
|
matchWidth?: boolean;
|
|
17
17
|
/** Apply built-in panel styling (background, shadow, border-radius). @default true */
|
|
18
18
|
panel?: boolean;
|
|
@@ -61,6 +61,23 @@ type Props = {
|
|
|
61
61
|
* <button onclick={() => dd?.open()}>Open externally</button>
|
|
62
62
|
* ```
|
|
63
63
|
*
|
|
64
|
+
* With `panel` on, content sizes to `max-content` and, above the `min-width` floor, never exceeds the room Floating UI measures around the trigger: the `size()` middleware feeds the space left after
|
|
65
|
+
* `flip` / `shift` into the max-width / max-height defaults. So the panel always has a definite width — which is what makes a consumer's own
|
|
66
|
+
* `text-overflow: ellipsis` (on a `min-inline-size: 0` flex child) resolve inside the panel — and a long list scrolls instead of running off-screen. Set
|
|
67
|
+
* `--sc-kit--popover--content--max-width` for a tighter cap than the available space.
|
|
68
|
+
*
|
|
69
|
+
* Because the panel fits itself to the available height, it is a scroll container by default. With `panel={false}` none of the three bounds apply — no width
|
|
70
|
+
* cap, no height fit, no clipping — since that consumer owns the box entirely. Floating content nested inside it — a submenu, a `Tooltip` on
|
|
71
|
+
* an item — is not clipped **once the panel has appeared**: those bubbles resolve their position against the popover's own positioned box, which sits outside
|
|
72
|
+
* the scrolling area, so `fixedPosition` on a nested Popover stays optional. During the appear animation the panel does carry a transform and therefore does
|
|
73
|
+
* clip, so a bubble opening within that window (a `Tooltip` with a near-zero `delay`) is cut off for its duration.
|
|
74
|
+
*
|
|
75
|
+
* Two consequences of the panel being a scroll container. `--sc-kit--popover--content--overflow: visible` removes the clipping but not the height fit — the
|
|
76
|
+
* panel is still shrunk and its content would paint outside the chrome, so pair it with `--sc-kit--popover--content--max-height: none` to opt out of both. And
|
|
77
|
+
* the clip is tight to the panel's box, whose inline padding is `0` by default: content that paints a focus ring outside its own border box (kit's pattern is
|
|
78
|
+
* `outline: 2px` + `outline-offset: 2px`, so 4px) needs inline padding of its own — either via `--sc-kit--popover--content--padding` or a wrapper. `PopoverItem`
|
|
79
|
+
* already carries the margin that keeps it clear.
|
|
80
|
+
*
|
|
64
81
|
* ### CSS Custom Properties
|
|
65
82
|
* | Property | Description | Default |
|
|
66
83
|
* |---|---|---|
|
|
@@ -69,7 +86,10 @@ type Props = {
|
|
|
69
86
|
* | `--sc-kit--popover--content--border-color` | Content border color | `var(--sc-kit--color--border)` |
|
|
70
87
|
* | `--sc-kit--popover--content--border-radius` | Content corner radius | `var(--sc-kit--radius--md)` |
|
|
71
88
|
* | `--sc-kit--popover--content--box-shadow` | Content shadow | `var(--sc-kit--shadow--lg)` |
|
|
72
|
-
* | `--sc-kit--popover--content--
|
|
89
|
+
* | `--sc-kit--popover--content--max-height` | Content max height. Applies only with `panel` on — a `panel={false}` consumer owns its own bounds | available height around the trigger |
|
|
90
|
+
* | `--sc-kit--popover--content--max-width` | Content max width — the upper bound content shrinks against. Applies only with `panel` on | available width around the trigger |
|
|
91
|
+
* | `--sc-kit--popover--content--min-width` | Content min width. Wins over max-width when the two conflict; ignored under `matchWidth` | `12.5rem` |
|
|
92
|
+
* | `--sc-kit--popover--content--overflow` | Panel overflow, both axes. Applies only with `panel` on. `visible` opts out of clipping | `hidden auto` |
|
|
73
93
|
* | `--sc-kit--popover--content--padding` | Content padding | `var(--sc-kit--space--1) 0` |
|
|
74
94
|
* | `--sc-kit--popover--content--z-index` | Content z-index | `var(--sc-kit--z-index--popover)` |
|
|
75
95
|
*
|