@opencode/ui 0.0.0-dev-21018 → 0.0.0-dev-21020

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.
@@ -20,6 +20,7 @@ export declare function useDialogLayer(): {
20
20
  } | undefined;
21
21
  export declare function DialogProvider(props: ParentProps): JSX.Element;
22
22
  export declare function useDialog(): {
23
+ /** The top dialog that is open. One that has started closing no longer counts, though it waits to be disposed. */
23
24
  readonly active: Active | undefined;
24
25
  /**
25
26
  * id lets the caller close this dialog later rather than whichever is on top. Opening is deferred; once
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencode/ui",
3
- "version": "0.0.0-dev-21018",
3
+ "version": "0.0.0-dev-21020",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -47,6 +47,9 @@ function init() {
47
47
  const closing = new Map<string, ReturnType<typeof setTimeout> | undefined>()
48
48
  // The same ids, reactive, so the top dialog that stays open owns the focus trap during an exit animation.
49
49
  const [exiting, setExiting] = createSignal<ReadonlySet<string>>(new Set())
50
+ // The top dialog that stays open. A dialog without an exit animation leaves the DOM as soon as it starts closing, so
51
+ // it stops being the active dialog then, not when it is disposed.
52
+ const top = () => stack().findLast((item) => !exiting().has(item.id))
50
53
  const lock = { value: false }
51
54
  const state = { disposed: false }
52
55
 
@@ -161,7 +164,7 @@ function init() {
161
164
 
162
165
  return (
163
166
  <Kobalte
164
- modal={stack().findLast((item) => !exiting().has(item.id))?.id === id}
167
+ modal={top()?.id === id}
165
168
  open={!closing()}
166
169
  onOpenChange={(open: boolean) => {
167
170
  if (!open) dismiss(id)
@@ -231,6 +234,7 @@ function init() {
231
234
 
232
235
  return {
233
236
  stack,
237
+ top,
234
238
  close,
235
239
  show,
236
240
  push,
@@ -302,8 +306,9 @@ export function useDialog() {
302
306
  }
303
307
 
304
308
  return {
309
+ /** The top dialog that is open. One that has started closing no longer counts, though it waits to be disposed. */
305
310
  get active() {
306
- return ctx.stack().at(-1)
311
+ return ctx.top()
307
312
  },
308
313
  /**
309
314
  * id lets the caller close this dialog later rather than whichever is on top. Opening is deferred; once