@opencode/ui 2.0.7 → 2.0.8

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.
@@ -31,6 +31,8 @@ export declare const toaster: {
31
31
  }) => JSX.Element, options?: {
32
32
  duration?: number;
33
33
  persistent?: boolean;
34
+ /** Reactive value the toast's height depends on; sonner re-measures when it changes. */
35
+ resize?: () => unknown;
34
36
  }): number;
35
37
  dismiss(toastId?: number): string | number | undefined;
36
38
  };
package/dist/i18n/en.d.ts CHANGED
@@ -133,6 +133,8 @@ declare const source: {
133
133
  "ui.promptInput.dropFiles.pdf": string;
134
134
  "ui.promptInput.dropFiles.imagePdf": string;
135
135
  "ui.promptInput.removeAttachment": string;
136
+ "ui.promptInput.cancelUpload": string;
137
+ "ui.promptInput.uploading": string;
136
138
  "ui.promptInput.label": string;
137
139
  "ui.promptInput.placeholder.shell": string;
138
140
  "ui.promptInput.placeholder.normal": string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencode/ui",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -79,6 +79,15 @@
79
79
  grid-column: 2;
80
80
  }
81
81
 
82
+ /* Custom toasts render no close button, so their content takes the whole width. */
83
+ &:not(:has(> [data-close-button])) > [data-content] {
84
+ grid-column: 1 / -1;
85
+ }
86
+
87
+ [data-description]:empty {
88
+ display: none;
89
+ }
90
+
82
91
  > [data-close-button] {
83
92
  grid-column: 2;
84
93
  grid-row: 1;
@@ -140,13 +140,30 @@ export const Toast = Object.assign(ToastRoot, {
140
140
  let toastV2Id = 0
141
141
 
142
142
  export const toaster = {
143
- show(render: (props: { toastId: number }) => JSX.Element, options?: { duration?: number; persistent?: boolean }) {
143
+ show(
144
+ render: (props: { toastId: number }) => JSX.Element,
145
+ options?: {
146
+ duration?: number
147
+ persistent?: boolean
148
+ /** Reactive value the toast's height depends on; sonner re-measures when it changes. */
149
+ resize?: () => unknown
150
+ },
151
+ ) {
144
152
  const toastId = --toastV2Id
145
153
  toast.custom((id) => render({ toastId: Number(id) }), {
146
154
  id: toastId,
147
155
  className: "toast-v2",
148
156
  duration: options?.persistent ? Number.POSITIVE_INFINITY : options?.duration,
149
157
  unstyled: true,
158
+ // Sonner only re-measures on title/description changes, so a function-valued description is
159
+ // the hook for a custom toast whose height depends on reactive state. It renders nothing;
160
+ // toast.css collapses the empty description element.
161
+ description: options?.resize
162
+ ? (): JSX.Element => {
163
+ options.resize?.()
164
+ return undefined
165
+ }
166
+ : undefined,
150
167
  })
151
168
  return toastId
152
169
  },
package/src/i18n/en.ts CHANGED
@@ -147,6 +147,8 @@ const source = {
147
147
  "ui.promptInput.dropFiles.pdf": "Drop PDFs or files to add",
148
148
  "ui.promptInput.dropFiles.imagePdf": "Drop images, PDFs, or files to add",
149
149
  "ui.promptInput.removeAttachment": "Remove attachment",
150
+ "ui.promptInput.cancelUpload": "Cancel upload",
151
+ "ui.promptInput.uploading": "{{percent}}%",
150
152
  "ui.promptInput.label": "Prompt",
151
153
  "ui.promptInput.placeholder.shell": "Enter shell command…",
152
154
  "ui.promptInput.placeholder.normal": "Ask anything, {{slash}} for commands, {{at}} for context…",