@seclai/react 0.0.7 → 0.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.
- package/README.md +39 -1
- package/dist/index.cjs +429 -86
- package/dist/index.d.cts +85 -10
- package/dist/index.d.ts +85 -10
- package/dist/index.js +422 -83
- package/dist/styles.css +276 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The handlers' wire format, declared here rather than imported from
|
|
@@ -237,6 +238,89 @@ declare function fetchAttachmentReferences(endpoints: AgentEndpoints, { signal }
|
|
|
237
238
|
*/
|
|
238
239
|
declare function uploadFile(endpoints: AgentEndpoints, file: File, { signal }?: EndpointRequestOptions): Promise<UploadResult>;
|
|
239
240
|
|
|
241
|
+
/** A CSS aspect ratio: a number such as `16 / 9`, or a string such as `"16 / 9"`. */
|
|
242
|
+
type MediaAspectRatio = number | string;
|
|
243
|
+
interface MediaPreviewProps {
|
|
244
|
+
attachment: AgentAttachment;
|
|
245
|
+
/**
|
|
246
|
+
* The image frame's aspect ratio. Without it the frame takes the image's own
|
|
247
|
+
* ratio once it loads, and `--seclai-media-aspect-ratio` (square by default)
|
|
248
|
+
* until then.
|
|
249
|
+
*/
|
|
250
|
+
aspectRatio?: MediaAspectRatio;
|
|
251
|
+
/** A badge on the image, matching the agent's numbered list ("1.", "2."). */
|
|
252
|
+
number?: number;
|
|
253
|
+
/** App-specific buttons, shown after the download link. A function gets the attachment. */
|
|
254
|
+
actions?: ReactNode | ((attachment: AgentAttachment) => ReactNode);
|
|
255
|
+
/** Makes the image a button, for opening a full-size viewer. */
|
|
256
|
+
onOpen?(): void;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Shows a file from a run. An image gets a card with a fixed-ratio frame and a
|
|
260
|
+
* download link. Anything else is a download link for now: audio, video and PDF
|
|
261
|
+
* previews are coming in a later version.
|
|
262
|
+
*/
|
|
263
|
+
declare function MediaPreview({ attachment, aspectRatio, number, actions, onOpen }: MediaPreviewProps): react.JSX.Element;
|
|
264
|
+
|
|
265
|
+
interface MediaGalleryProps {
|
|
266
|
+
/** A run's attachments. Images become numbered cards; other files follow as download links. */
|
|
267
|
+
attachments: AgentAttachment[];
|
|
268
|
+
/** Every card's aspect ratio. Without it each card takes its image's own ratio. */
|
|
269
|
+
aspectRatio?: MediaAspectRatio;
|
|
270
|
+
/**
|
|
271
|
+
* Skeleton cards to show after the images, for images still being generated.
|
|
272
|
+
* They're numbered on from the last image.
|
|
273
|
+
*/
|
|
274
|
+
pending?: number;
|
|
275
|
+
/** App-specific buttons for each card. Gets the attachment and its 1-based number. */
|
|
276
|
+
actions?(attachment: AgentAttachment, number: number): ReactNode;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Lays out a run's images as numbered cards that open a full-size viewer, with
|
|
280
|
+
* "Download all" when there's more than one. Files that aren't images are shown
|
|
281
|
+
* after them with `MediaPreview`.
|
|
282
|
+
*/
|
|
283
|
+
declare function MediaGallery({ attachments, aspectRatio, pending, actions, }: MediaGalleryProps): react.JSX.Element;
|
|
284
|
+
|
|
285
|
+
interface MediaSkeletonProps {
|
|
286
|
+
/** The frame's aspect ratio. Defaults to `--seclai-media-aspect-ratio`, square unless you set it. */
|
|
287
|
+
aspectRatio?: MediaAspectRatio;
|
|
288
|
+
/** A badge, for the number the image will have once it arrives. */
|
|
289
|
+
number?: number;
|
|
290
|
+
/** What a screen reader hears. Defaults to "Image <number> is being generated". */
|
|
291
|
+
label?: string;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* A placeholder card for an image that hasn't arrived yet, the same shape as a
|
|
295
|
+
* `MediaPreview` card, so the layout doesn't jump when it does. It pulses unless
|
|
296
|
+
* the user prefers reduced motion.
|
|
297
|
+
*/
|
|
298
|
+
declare function MediaSkeleton({ aspectRatio, number, label }: MediaSkeletonProps): react.JSX.Element;
|
|
299
|
+
|
|
300
|
+
interface MediaViewerProps {
|
|
301
|
+
/** The images to page through, in order. Image `i` is numbered `i + 1`. */
|
|
302
|
+
attachments: AgentAttachment[];
|
|
303
|
+
/** The image showing, or `null` when the viewer is closed. */
|
|
304
|
+
index: number | null;
|
|
305
|
+
/** Called with the new index when the user goes to the previous or next image. */
|
|
306
|
+
onIndexChange(index: number): void;
|
|
307
|
+
/** Called when the user closes the viewer: Escape, the close button or a click on the backdrop. */
|
|
308
|
+
onClose(): void;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* A full-size image viewer in a modal `<dialog>`, with previous and next (also on
|
|
312
|
+
* the arrow keys) and a download button. It's controlled: pass the `index` to
|
|
313
|
+
* show, and `null` to close it. Focus moves into the viewer when it opens and
|
|
314
|
+
* back to where it was when it closes.
|
|
315
|
+
*/
|
|
316
|
+
declare function MediaViewer({ attachments, index, onIndexChange, onClose }: MediaViewerProps): react.JSX.Element;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* The filename to save an attachment as: its own name, or else `image-<number>`
|
|
320
|
+
* (or its id) with an extension from its mime type.
|
|
321
|
+
*/
|
|
322
|
+
declare function attachmentFileName(attachment: AgentAttachment, number?: number): string;
|
|
323
|
+
|
|
240
324
|
interface MarkdownContentProps {
|
|
241
325
|
content: string;
|
|
242
326
|
}
|
|
@@ -246,13 +330,4 @@ interface MarkdownContentProps {
|
|
|
246
330
|
*/
|
|
247
331
|
declare function MarkdownContent({ content }: MarkdownContentProps): react.JSX.Element;
|
|
248
332
|
|
|
249
|
-
|
|
250
|
-
attachment: AgentAttachment;
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Shows a file from a run. For now images show inline and everything else is a
|
|
254
|
-
* download link. Audio, video and PDF previews are coming in a later version.
|
|
255
|
-
*/
|
|
256
|
-
declare function MediaPreview({ attachment }: MediaPreviewProps): react.JSX.Element;
|
|
257
|
-
|
|
258
|
-
export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatAttachButton, type AgentChatFile, type AgentChatMessage, type AgentChatProps, type AgentEndpointOptions, type AgentEndpoints, type AgentRunEvent, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, MediaPreview, type MediaPreviewProps, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadResult, type UseAgentRunOptions, type UseAgentRunResult, createEndpoints, fetchAttachmentReferences, uploadFile, useAgentRun };
|
|
333
|
+
export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatAttachButton, type AgentChatFile, type AgentChatMessage, type AgentChatProps, type AgentEndpointOptions, type AgentEndpoints, type AgentRunEvent, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, type MediaAspectRatio, MediaGallery, type MediaGalleryProps, MediaPreview, type MediaPreviewProps, MediaSkeleton, type MediaSkeletonProps, MediaViewer, type MediaViewerProps, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadResult, type UseAgentRunOptions, type UseAgentRunResult, attachmentFileName, createEndpoints, fetchAttachmentReferences, uploadFile, useAgentRun };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The handlers' wire format, declared here rather than imported from
|
|
@@ -237,6 +238,89 @@ declare function fetchAttachmentReferences(endpoints: AgentEndpoints, { signal }
|
|
|
237
238
|
*/
|
|
238
239
|
declare function uploadFile(endpoints: AgentEndpoints, file: File, { signal }?: EndpointRequestOptions): Promise<UploadResult>;
|
|
239
240
|
|
|
241
|
+
/** A CSS aspect ratio: a number such as `16 / 9`, or a string such as `"16 / 9"`. */
|
|
242
|
+
type MediaAspectRatio = number | string;
|
|
243
|
+
interface MediaPreviewProps {
|
|
244
|
+
attachment: AgentAttachment;
|
|
245
|
+
/**
|
|
246
|
+
* The image frame's aspect ratio. Without it the frame takes the image's own
|
|
247
|
+
* ratio once it loads, and `--seclai-media-aspect-ratio` (square by default)
|
|
248
|
+
* until then.
|
|
249
|
+
*/
|
|
250
|
+
aspectRatio?: MediaAspectRatio;
|
|
251
|
+
/** A badge on the image, matching the agent's numbered list ("1.", "2."). */
|
|
252
|
+
number?: number;
|
|
253
|
+
/** App-specific buttons, shown after the download link. A function gets the attachment. */
|
|
254
|
+
actions?: ReactNode | ((attachment: AgentAttachment) => ReactNode);
|
|
255
|
+
/** Makes the image a button, for opening a full-size viewer. */
|
|
256
|
+
onOpen?(): void;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Shows a file from a run. An image gets a card with a fixed-ratio frame and a
|
|
260
|
+
* download link. Anything else is a download link for now: audio, video and PDF
|
|
261
|
+
* previews are coming in a later version.
|
|
262
|
+
*/
|
|
263
|
+
declare function MediaPreview({ attachment, aspectRatio, number, actions, onOpen }: MediaPreviewProps): react.JSX.Element;
|
|
264
|
+
|
|
265
|
+
interface MediaGalleryProps {
|
|
266
|
+
/** A run's attachments. Images become numbered cards; other files follow as download links. */
|
|
267
|
+
attachments: AgentAttachment[];
|
|
268
|
+
/** Every card's aspect ratio. Without it each card takes its image's own ratio. */
|
|
269
|
+
aspectRatio?: MediaAspectRatio;
|
|
270
|
+
/**
|
|
271
|
+
* Skeleton cards to show after the images, for images still being generated.
|
|
272
|
+
* They're numbered on from the last image.
|
|
273
|
+
*/
|
|
274
|
+
pending?: number;
|
|
275
|
+
/** App-specific buttons for each card. Gets the attachment and its 1-based number. */
|
|
276
|
+
actions?(attachment: AgentAttachment, number: number): ReactNode;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Lays out a run's images as numbered cards that open a full-size viewer, with
|
|
280
|
+
* "Download all" when there's more than one. Files that aren't images are shown
|
|
281
|
+
* after them with `MediaPreview`.
|
|
282
|
+
*/
|
|
283
|
+
declare function MediaGallery({ attachments, aspectRatio, pending, actions, }: MediaGalleryProps): react.JSX.Element;
|
|
284
|
+
|
|
285
|
+
interface MediaSkeletonProps {
|
|
286
|
+
/** The frame's aspect ratio. Defaults to `--seclai-media-aspect-ratio`, square unless you set it. */
|
|
287
|
+
aspectRatio?: MediaAspectRatio;
|
|
288
|
+
/** A badge, for the number the image will have once it arrives. */
|
|
289
|
+
number?: number;
|
|
290
|
+
/** What a screen reader hears. Defaults to "Image <number> is being generated". */
|
|
291
|
+
label?: string;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* A placeholder card for an image that hasn't arrived yet, the same shape as a
|
|
295
|
+
* `MediaPreview` card, so the layout doesn't jump when it does. It pulses unless
|
|
296
|
+
* the user prefers reduced motion.
|
|
297
|
+
*/
|
|
298
|
+
declare function MediaSkeleton({ aspectRatio, number, label }: MediaSkeletonProps): react.JSX.Element;
|
|
299
|
+
|
|
300
|
+
interface MediaViewerProps {
|
|
301
|
+
/** The images to page through, in order. Image `i` is numbered `i + 1`. */
|
|
302
|
+
attachments: AgentAttachment[];
|
|
303
|
+
/** The image showing, or `null` when the viewer is closed. */
|
|
304
|
+
index: number | null;
|
|
305
|
+
/** Called with the new index when the user goes to the previous or next image. */
|
|
306
|
+
onIndexChange(index: number): void;
|
|
307
|
+
/** Called when the user closes the viewer: Escape, the close button or a click on the backdrop. */
|
|
308
|
+
onClose(): void;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* A full-size image viewer in a modal `<dialog>`, with previous and next (also on
|
|
312
|
+
* the arrow keys) and a download button. It's controlled: pass the `index` to
|
|
313
|
+
* show, and `null` to close it. Focus moves into the viewer when it opens and
|
|
314
|
+
* back to where it was when it closes.
|
|
315
|
+
*/
|
|
316
|
+
declare function MediaViewer({ attachments, index, onIndexChange, onClose }: MediaViewerProps): react.JSX.Element;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* The filename to save an attachment as: its own name, or else `image-<number>`
|
|
320
|
+
* (or its id) with an extension from its mime type.
|
|
321
|
+
*/
|
|
322
|
+
declare function attachmentFileName(attachment: AgentAttachment, number?: number): string;
|
|
323
|
+
|
|
240
324
|
interface MarkdownContentProps {
|
|
241
325
|
content: string;
|
|
242
326
|
}
|
|
@@ -246,13 +330,4 @@ interface MarkdownContentProps {
|
|
|
246
330
|
*/
|
|
247
331
|
declare function MarkdownContent({ content }: MarkdownContentProps): react.JSX.Element;
|
|
248
332
|
|
|
249
|
-
|
|
250
|
-
attachment: AgentAttachment;
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Shows a file from a run. For now images show inline and everything else is a
|
|
254
|
-
* download link. Audio, video and PDF previews are coming in a later version.
|
|
255
|
-
*/
|
|
256
|
-
declare function MediaPreview({ attachment }: MediaPreviewProps): react.JSX.Element;
|
|
257
|
-
|
|
258
|
-
export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatAttachButton, type AgentChatFile, type AgentChatMessage, type AgentChatProps, type AgentEndpointOptions, type AgentEndpoints, type AgentRunEvent, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, MediaPreview, type MediaPreviewProps, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadResult, type UseAgentRunOptions, type UseAgentRunResult, createEndpoints, fetchAttachmentReferences, uploadFile, useAgentRun };
|
|
333
|
+
export { type AcceptedAttachmentSlot, type AgentAttachment, AgentChat, type AgentChatAttachButton, type AgentChatFile, type AgentChatMessage, type AgentChatProps, type AgentEndpointOptions, type AgentEndpoints, type AgentRunEvent, AgentRunForm, type AgentRunFormProps, type AgentRunState, type AgentRunStatus, type AgentRunStep, type AgentUiMode, type AttachmentReferences, DEFAULT_BASE_PATH, type EndpointRequestOptions, MarkdownContent, type MarkdownContentProps, type MediaAspectRatio, MediaGallery, type MediaGalleryProps, MediaPreview, type MediaPreviewProps, MediaSkeleton, type MediaSkeletonProps, MediaViewer, type MediaViewerProps, SeclaiAgent, type SeclaiAgentProps, type StartRunOptions, type UploadResult, type UseAgentRunOptions, type UseAgentRunResult, attachmentFileName, createEndpoints, fetchAttachmentReferences, uploadFile, useAgentRun };
|