@opencode/ui 0.0.0-dev-347 → 0.0.0-dev-358

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencode/ui",
3
- "version": "0.0.0-dev-347",
3
+ "version": "0.0.0-dev-358",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -288,7 +288,7 @@
288
288
  "dependencies": {
289
289
  "@kitlangton/solid-motion": "0.2.2",
290
290
  "@kobalte/core": "0.13.13",
291
- "@opencode/util": "0.0.0-dev-347",
291
+ "@opencode/util": "0.0.0-dev-358",
292
292
  "@pierre/diffs": "1.6.1",
293
293
  "@pierre/highlights": "0.2.0",
294
294
  "@solid-primitives/event-listener": "2.4.6",
@@ -182,8 +182,9 @@
182
182
  }
183
183
 
184
184
  /* A modal Kobalte dialog turns the body's pointer events off and only restores them when its content unmounts, which
185
- the closing flight above holds back; the page takes clicks again as soon as the close starts. */
186
- body:has([data-component="image-preview"] [data-slot="image-preview-content"][data-closed]) {
185
+ the closing flight above holds back; the page takes clicks again as soon as the close starts. The preview marks the
186
+ body itself: a body:has() rule made Chromium restyle the body on every DOM insertion anywhere in the page. */
187
+ body[data-image-preview-closing] {
187
188
  pointer-events: auto !important;
188
189
  }
189
190
 
@@ -405,12 +405,16 @@ export function ImagePreview(props: ImagePreviewProps) {
405
405
  settle()
406
406
  showOrigin()
407
407
  giveBack()
408
+ document.body.removeAttribute("data-image-preview-closing")
408
409
  })
409
410
 
410
411
  createEffect(
411
412
  on(
412
413
  () => dialog.isOpen(),
413
414
  (open) => {
415
+ // See image-preview.css: the body takes clicks again while the closing flight holds the dialog mounted.
416
+ document.body.toggleAttribute("data-image-preview-closing", !open)
417
+
414
418
  if (!open) dismiss()
415
419
  },
416
420
  { defer: true },
@@ -2,7 +2,7 @@ import { Toaster, toast, type ToasterProps } from "solid-sonner"
2
2
  import { boundToastDescription } from "./description"
3
3
  import { isRTL } from "@kobalte/core/i18n"
4
4
  import type { ComponentProps, JSX } from "solid-js"
5
- import { createContext, onCleanup, onMount, splitProps, useContext } from "solid-js"
5
+ import { createContext, onCleanup, splitProps, useContext } from "solid-js"
6
6
  import { Portal } from "solid-js/web"
7
7
  import { useI18n } from "../../context/i18n"
8
8
  import "../../actions/button/button.css"
@@ -14,46 +14,26 @@ export interface ToastRegionProps extends ToasterProps {}
14
14
  function ToastRegion(props: ToastRegionProps) {
15
15
  const i18n = useI18n()
16
16
  const [local, rest] = splitProps(props, ["class", "className", "style", "toastOptions", "swipeDirections"])
17
- onMount(() => {
17
+
18
+ // The Portal's container holds the toast region whenever it exists. Watching the container, not the whole body,
19
+ // keeps every DOM change elsewhere in the page (each streamed delta, each mounted row) from scanning the document.
20
+ const observe = (container: HTMLDivElement) => {
18
21
  const sync = () => {
19
- document.querySelectorAll<HTMLElement>(".toast-v2-region .toast-v2").forEach((element) => {
22
+ container.querySelectorAll<HTMLElement>(".toast-v2-region .toast-v2").forEach((element) => {
20
23
  const hidden = element.dataset.visible === "false"
21
24
  element.inert = hidden
22
25
  element.tabIndex = hidden ? -1 : 0
23
26
  })
24
27
  }
25
28
 
26
- let connected = false
27
-
28
- const connect = () => {
29
- const regions = document.querySelectorAll(".toast-v2-region")
30
-
31
- if (!regions.length) return
32
- observer.disconnect()
33
- regions.forEach((region) => {
34
- observer.observe(region, {
35
- subtree: true,
36
- childList: true,
37
- attributes: true,
38
- attributeFilter: ["data-visible"],
39
- })
40
- })
41
- connected = true
42
- sync()
43
- }
44
-
45
- const observer = new MutationObserver(() => {
46
- if (!connected) connect()
47
- else sync()
48
- })
49
-
50
- observer.observe(document.body, { subtree: true, childList: true })
51
- queueMicrotask(connect)
29
+ const observer = new MutationObserver(sync)
30
+ observer.observe(container, { subtree: true, childList: true, attributes: true, attributeFilter: ["data-visible"] })
31
+ sync()
52
32
  onCleanup(() => observer.disconnect())
53
- })
33
+ }
54
34
 
55
35
  return (
56
- <Portal>
36
+ <Portal ref={observe}>
57
37
  <Toaster
58
38
  position={isRTL(i18n.locale()) ? "bottom-left" : "bottom-right"}
59
39
  offset={isRTL(i18n.locale()) ? { left: 32, bottom: 48 } : { right: 32, bottom: 48 }}
@@ -16,34 +16,6 @@
16
16
  background: var(--v2-background-bg-layer-01);
17
17
  border-radius: 6px;
18
18
  box-shadow: var(--v2-elevation-floating);
19
- transform-origin: top center;
20
- animation: select-v2-content-in 120ms ease-out;
21
- }
22
-
23
- [data-component="menu-v2-content"][data-slot="select-v2-content"][data-closed] {
24
- animation: select-v2-content-out 80ms ease-in forwards;
25
- }
26
-
27
- @keyframes select-v2-content-in {
28
- from {
29
- opacity: 0;
30
- transform: translateY(-2px);
31
- }
32
- to {
33
- opacity: 1;
34
- transform: translateY(0);
35
- }
36
- }
37
-
38
- @keyframes select-v2-content-out {
39
- from {
40
- opacity: 1;
41
- transform: translateY(0);
42
- }
43
- to {
44
- opacity: 0;
45
- transform: translateY(-2px);
46
- }
47
19
  }
48
20
 
49
21
  /* Shared trigger structure for the inline control. */
@@ -276,14 +276,3 @@
276
276
  font-variant-numeric: normal;
277
277
  }
278
278
  }
279
-
280
- @keyframes menu-v2-in {
281
- from {
282
- opacity: 0;
283
- transform: scale(0.96);
284
- }
285
- to {
286
- opacity: 1;
287
- transform: scale(1);
288
- }
289
- }