@opencode/ui 2.0.8 → 2.0.9
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,4 +1,4 @@
|
|
|
1
|
-
import { createEffect, mergeProps, onCleanup, onMount, Show, splitProps, type ComponentProps } from "solid-js"
|
|
1
|
+
import { createEffect, mergeProps, on, onCleanup, onMount, Show, splitProps, type ComponentProps } from "solid-js"
|
|
2
2
|
import { Portal } from "solid-js/web"
|
|
3
3
|
import { createResizeObserver } from "@solid-primitives/resize-observer"
|
|
4
4
|
import { createStore } from "solid-js/store"
|
|
@@ -236,18 +236,22 @@ export function ScrollView(props: ScrollViewProps) {
|
|
|
236
236
|
local.viewportRef(viewportRef)
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
+
// The observer reports every target once when it starts observing (including a thumb mount that
|
|
240
|
+
// appears later), after layout. Measuring here as well would force a synchronous layout per
|
|
241
|
+
// ScrollView while the page is still rendering.
|
|
239
242
|
createResizeObserver(
|
|
240
243
|
() => [viewportRef, viewportRef.firstElementChild, thumbMount()].filter(Boolean) as HTMLElement[],
|
|
241
244
|
updateThumb,
|
|
242
245
|
)
|
|
243
|
-
|
|
244
|
-
updateThumb()
|
|
245
246
|
})
|
|
246
247
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
248
|
+
// Inputs that change the thumb without resizing anything: re-measure on change, but leave the
|
|
249
|
+
// first measurement to the observer.
|
|
250
|
+
createEffect(
|
|
251
|
+
on([() => local.verticalScrollAdjustment, vertical, horizontal, thumbMount], () => updateThumb(), {
|
|
252
|
+
defer: true,
|
|
253
|
+
}),
|
|
254
|
+
)
|
|
251
255
|
|
|
252
256
|
createEffect(() => {
|
|
253
257
|
if (!horizontal() || !viewportRef) return
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// A toast shows a few lines; the rest of a long description would only be retained (in the dedupe
|
|
2
|
+
// key, the active-toast registry and the toaster's store) for as long as the toast lives. Server
|
|
3
|
+
// errors have carried a whole data URL here.
|
|
4
|
+
export const toastDescriptionLimit = 2000
|
|
5
|
+
|
|
6
|
+
export function boundToastDescription<T extends { description?: string }>(options: T): T {
|
|
7
|
+
if (!options.description || options.description.length <= toastDescriptionLimit) return options
|
|
8
|
+
return { ...options, description: `${options.description.slice(0, toastDescriptionLimit)}…` }
|
|
9
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Toaster, toast, type ToasterProps } from "solid-sonner"
|
|
2
|
+
import { boundToastDescription } from "./description"
|
|
2
3
|
import { isRTL } from "@kobalte/core/i18n"
|
|
3
4
|
import type { ComponentProps, JSX } from "solid-js"
|
|
4
5
|
import { createContext, onCleanup, onMount, splitProps, useContext } from "solid-js"
|
|
@@ -205,7 +206,7 @@ const activeToastByKey = new Map<string, ActiveToast>()
|
|
|
205
206
|
const activeToastById = new Map<number, ActiveToast>()
|
|
206
207
|
|
|
207
208
|
export function showToast(options: ToastOptions | string) {
|
|
208
|
-
const opts
|
|
209
|
+
const opts = boundToastDescription(typeof options === "string" ? { description: options } : options)
|
|
209
210
|
const key = JSON.stringify({
|
|
210
211
|
title: opts.title,
|
|
211
212
|
description: opts.description,
|