@bysages/solid 0.4.3 → 0.5.0
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 +2 -2
- package/dist/ai-NX47X8sz.mjs +365 -0
- package/dist/ai-prompt-input-CEnnpkgi.mjs +486 -0
- package/dist/{ai-response-CJ-uEAgj.mjs → ai-response-BM_DVIDY.mjs} +25 -27
- package/dist/{chevron-BHQrYKPM.mjs → chevron-DGKPHc2O.mjs} +2 -3
- package/dist/components/accordion/index.d.mts +1 -2
- package/dist/components/accordion/index.mjs +9 -16
- package/dist/components/affix/index.d.mts +1 -3
- package/dist/components/affix/index.mjs +19 -18
- package/dist/components/ai/index.d.mts +95 -2
- package/dist/components/ai/index.mjs +7 -69
- package/dist/components/ai-action/index.d.mts +0 -2
- package/dist/components/ai-action/index.mjs +4 -5
- package/dist/components/ai-attachments/index.d.mts +0 -2
- package/dist/components/ai-attachments/index.mjs +39 -52
- package/dist/components/ai-message/index.d.mts +2 -15
- package/dist/components/ai-message/index.mjs +18 -15
- package/dist/components/ai-prompt-input/index.d.mts +19 -15
- package/dist/components/ai-prompt-input/index.mjs +1 -168
- package/dist/components/ai-reasoning/index.d.mts +0 -2
- package/dist/components/ai-reasoning/index.mjs +8 -13
- package/dist/components/ai-response/index.d.mts +1 -3
- package/dist/components/ai-response/index.mjs +1 -2
- package/dist/components/ai-source/index.d.mts +0 -2
- package/dist/components/ai-source/index.mjs +25 -26
- package/dist/components/ai-suggestion/index.d.mts +0 -2
- package/dist/components/ai-suggestion/index.mjs +3 -4
- package/dist/components/ai-tool/index.d.mts +2 -25
- package/dist/components/ai-tool/index.mjs +75 -40
- package/dist/components/alert/index.d.mts +1 -2
- package/dist/components/alert/index.mjs +38 -33
- package/dist/components/angle-slider/index.d.mts +1 -2
- package/dist/components/angle-slider/index.mjs +6 -9
- package/dist/components/aspect-ratio/index.d.mts +1 -3
- package/dist/components/aspect-ratio/index.mjs +18 -17
- package/dist/components/autocomplete/index.d.mts +1 -2
- package/dist/components/autocomplete/index.mjs +6 -8
- package/dist/components/avatar/index.d.mts +17 -6
- package/dist/components/avatar/index.mjs +66 -10
- package/dist/components/avatar-group/index.d.mts +1 -3
- package/dist/components/avatar-group/index.mjs +15 -14
- package/dist/components/back-top/index.d.mts +1 -3
- package/dist/components/back-top/index.mjs +29 -34
- package/dist/components/badge/index.d.mts +1 -3
- package/dist/components/badge/index.mjs +18 -17
- package/dist/components/banner/index.d.mts +18 -3
- package/dist/components/banner/index.mjs +108 -31
- package/dist/components/bento/index.d.mts +1 -3
- package/dist/components/bento/index.mjs +30 -31
- package/dist/components/block-ui/index.d.mts +1 -3
- package/dist/components/block-ui/index.mjs +30 -33
- package/dist/components/breadcrumb/index.d.mts +15 -3
- package/dist/components/breadcrumb/index.mjs +56 -12
- package/dist/components/browser/index.d.mts +1 -3
- package/dist/components/browser/index.mjs +50 -51
- package/dist/components/button/index.d.mts +1 -3
- package/dist/components/button/index.mjs +31 -30
- package/dist/components/button-group/index.d.mts +1 -3
- package/dist/components/button-group/index.mjs +21 -20
- package/dist/components/calendar/index.d.mts +0 -2
- package/dist/components/calendar/index.mjs +73 -116
- package/dist/components/card/index.d.mts +1 -3
- package/dist/components/card/index.mjs +3 -4
- package/dist/components/carousel/index.d.mts +1 -2
- package/dist/components/carousel/index.mjs +6 -7
- package/dist/components/cascade-select/index.d.mts +1 -3
- package/dist/components/cascade-select/index.mjs +127 -167
- package/dist/components/checkbox/index.d.mts +1 -2
- package/dist/components/checkbox/index.mjs +7 -10
- package/dist/components/checkbox-group/index.d.mts +1 -2
- package/dist/components/checkbox-group/index.mjs +9 -12
- package/dist/components/chip/index.d.mts +1 -3
- package/dist/components/chip/index.mjs +22 -25
- package/dist/components/client-only/index.d.mts +0 -2
- package/dist/components/client-only/index.mjs +2 -3
- package/dist/components/clipboard/index.d.mts +1 -2
- package/dist/components/clipboard/index.mjs +10 -17
- package/dist/components/collapsible/index.d.mts +1 -2
- package/dist/components/collapsible/index.mjs +7 -14
- package/dist/components/collection/index.mjs +1 -2
- package/dist/components/color-picker/index.d.mts +5 -2
- package/dist/components/color-picker/index.mjs +69 -39
- package/dist/components/combobox/index.d.mts +1 -2
- package/dist/components/combobox/index.mjs +9 -14
- package/dist/components/command/index.d.mts +1 -2
- package/dist/components/command/index.mjs +63 -80
- package/dist/components/comment/index.d.mts +1 -3
- package/dist/components/comment/index.mjs +64 -80
- package/dist/components/config-provider/index.d.mts +1 -3
- package/dist/components/config-provider/index.mjs +10 -13
- package/dist/components/container/index.d.mts +1 -3
- package/dist/components/container/index.mjs +18 -17
- package/dist/components/data-view/index.d.mts +1 -3
- package/dist/components/data-view/index.mjs +81 -90
- package/dist/components/date-input/index.d.mts +1 -2
- package/dist/components/date-input/index.mjs +6 -9
- package/dist/components/date-picker/index.d.mts +1 -2
- package/dist/components/date-picker/index.mjs +11 -16
- package/dist/components/deferred-content/index.d.mts +1 -3
- package/dist/components/deferred-content/index.mjs +24 -25
- package/dist/components/descriptions/index.d.mts +1 -2
- package/dist/components/descriptions/index.mjs +40 -39
- package/dist/components/dialog/index.d.mts +11 -2
- package/dist/components/dialog/index.mjs +78 -40
- package/dist/components/dock/index.d.mts +1 -3
- package/dist/components/dock/index.mjs +29 -30
- package/dist/components/download-trigger/index.d.mts +0 -2
- package/dist/components/download-trigger/index.mjs +2 -3
- package/dist/components/drawer/index.d.mts +1 -2
- package/dist/components/drawer/index.mjs +9 -18
- package/dist/components/dynamic-input/index.d.mts +1 -3
- package/dist/components/dynamic-input/index.mjs +73 -77
- package/dist/components/editable/index.d.mts +1 -2
- package/dist/components/editable/index.mjs +7 -10
- package/dist/components/ellipsis/index.d.mts +1 -3
- package/dist/components/ellipsis/index.mjs +21 -20
- package/dist/components/empty/index.d.mts +1 -3
- package/dist/components/empty/index.mjs +3 -4
- package/dist/components/field/index.d.mts +1 -2
- package/dist/components/field/index.mjs +4 -5
- package/dist/components/fieldset/index.d.mts +1 -2
- package/dist/components/fieldset/index.mjs +6 -9
- package/dist/components/file-upload/index.d.mts +1 -2
- package/dist/components/file-upload/index.mjs +6 -7
- package/dist/components/float-button/index.d.mts +25 -3
- package/dist/components/float-button/index.mjs +108 -39
- package/dist/components/floating-panel/index.d.mts +1 -2
- package/dist/components/floating-panel/index.mjs +10 -21
- package/dist/components/focus-trap/index.d.mts +0 -2
- package/dist/components/focus-trap/index.mjs +2 -3
- package/dist/components/form/index.d.mts +0 -2
- package/dist/components/form/index.mjs +42 -58
- package/dist/components/format/index.d.mts +1 -3
- package/dist/components/format/index.mjs +1 -2
- package/dist/components/frame/index.d.mts +1 -2
- package/dist/components/frame/index.mjs +3 -4
- package/dist/components/grid/index.d.mts +1 -3
- package/dist/components/grid/index.mjs +23 -22
- package/dist/components/highlight/index.d.mts +1 -3
- package/dist/components/highlight/index.mjs +2 -3
- package/dist/components/hover-card/index.d.mts +1 -2
- package/dist/components/hover-card/index.mjs +12 -27
- package/dist/components/icon/index.d.mts +1 -3
- package/dist/components/icon/index.mjs +35 -36
- package/dist/components/image/index.d.mts +1 -3
- package/dist/components/image/index.mjs +48 -52
- package/dist/components/image-cropper/index.d.mts +1 -2
- package/dist/components/image-cropper/index.mjs +5 -6
- package/dist/components/image-viewer/index.d.mts +1 -1
- package/dist/components/image-viewer/index.mjs +1 -2
- package/dist/components/input/index.d.mts +1 -3
- package/dist/components/input/index.mjs +1 -2
- package/dist/components/input-group/index.d.mts +1 -2
- package/dist/components/input-group/index.mjs +19 -16
- package/dist/components/json-tree-view/index.d.mts +1 -2
- package/dist/components/json-tree-view/index.mjs +5 -6
- package/dist/components/kbd/index.d.mts +1 -3
- package/dist/components/kbd/index.mjs +12 -11
- package/dist/components/layout/index.d.mts +1 -2
- package/dist/components/layout/index.mjs +92 -84
- package/dist/components/link/index.d.mts +1 -3
- package/dist/components/link/index.mjs +15 -15
- package/dist/components/list/index.d.mts +1 -2
- package/dist/components/list/index.mjs +57 -61
- package/dist/components/listbox/index.d.mts +1 -2
- package/dist/components/listbox/index.mjs +8 -11
- package/dist/components/marquee/index.d.mts +1 -2
- package/dist/components/marquee/index.mjs +7 -8
- package/dist/components/masonry/index.d.mts +1 -3
- package/dist/components/masonry/index.mjs +19 -18
- package/dist/components/media-player/index.d.mts +1 -1
- package/dist/components/media-player/index.mjs +1 -2
- package/dist/components/mentions/index.d.mts +2 -2
- package/dist/components/mentions/index.mjs +1 -3
- package/dist/components/menu/index.d.mts +1 -2
- package/dist/components/menu/index.mjs +8 -17
- package/dist/components/menubar/index.d.mts +1 -2
- package/dist/components/menubar/index.mjs +66 -72
- package/dist/components/meter/index.d.mts +1 -2
- package/dist/components/meter/index.mjs +42 -43
- package/dist/components/navigation-menu/index.d.mts +1 -2
- package/dist/components/navigation-menu/index.mjs +7 -12
- package/dist/components/number-input/index.d.mts +1 -2
- package/dist/components/number-input/index.mjs +7 -10
- package/dist/components/order-list/index.d.mts +1 -3
- package/dist/components/order-list/index.mjs +86 -101
- package/dist/components/page-header/index.d.mts +1 -3
- package/dist/components/page-header/index.mjs +3 -4
- package/dist/components/pagination/index.d.mts +1 -2
- package/dist/components/pagination/index.mjs +31 -42
- package/dist/components/password-input/index.d.mts +1 -2
- package/dist/components/password-input/index.mjs +6 -7
- package/dist/components/pin-input/index.d.mts +1 -2
- package/dist/components/pin-input/index.mjs +6 -9
- package/dist/components/popconfirm/index.d.mts +2 -3
- package/dist/components/popconfirm/index.mjs +15 -23
- package/dist/components/popover/index.d.mts +2 -26
- package/dist/components/popover/index.mjs +10 -21
- package/dist/components/presence/index.d.mts +0 -2
- package/dist/components/presence/index.mjs +2 -3
- package/dist/components/progress/index.d.mts +1 -2
- package/dist/components/progress/index.mjs +14 -26
- package/dist/components/progress-group/index.d.mts +1 -3
- package/dist/components/progress-group/index.mjs +60 -68
- package/dist/components/qr-code/index.d.mts +1 -2
- package/dist/components/qr-code/index.mjs +5 -8
- package/dist/components/radio-group/index.d.mts +1 -2
- package/dist/components/radio-group/index.mjs +6 -9
- package/dist/components/rating-group/index.d.mts +1 -2
- package/dist/components/rating-group/index.mjs +7 -10
- package/dist/components/result/index.d.mts +1 -2
- package/dist/components/result/index.mjs +28 -29
- package/dist/components/scroll-area/index.d.mts +8 -3
- package/dist/components/scroll-area/index.mjs +19 -11
- package/dist/components/segment-group/index.d.mts +1 -2
- package/dist/components/segment-group/index.mjs +5 -8
- package/dist/components/select/index.d.mts +1 -1
- package/dist/components/select/index.mjs +1 -2
- package/dist/components/separator/index.d.mts +1 -3
- package/dist/components/separator/index.mjs +21 -20
- package/dist/components/signature-pad/index.d.mts +1 -2
- package/dist/components/signature-pad/index.mjs +7 -10
- package/dist/components/skeleton/index.d.mts +1 -3
- package/dist/components/skeleton/index.mjs +12 -11
- package/dist/components/slider/index.d.mts +1 -2
- package/dist/components/slider/index.mjs +6 -9
- package/dist/components/spinner/index.d.mts +1 -3
- package/dist/components/spinner/index.mjs +20 -19
- package/dist/components/split-button/index.d.mts +1 -2
- package/dist/components/split-button/index.mjs +92 -94
- package/dist/components/splitter/index.d.mts +1 -2
- package/dist/components/splitter/index.mjs +5 -8
- package/dist/components/spotlight/index.d.mts +1 -3
- package/dist/components/spotlight/index.mjs +22 -23
- package/dist/components/stack/index.d.mts +1 -3
- package/dist/components/stack/index.mjs +24 -23
- package/dist/components/stat/index.d.mts +1 -2
- package/dist/components/stat/index.mjs +15 -14
- package/dist/components/steps/index.d.mts +0 -2
- package/dist/components/steps/index.mjs +10 -17
- package/dist/components/swap/index.d.mts +1 -2
- package/dist/components/swap/index.mjs +5 -6
- package/dist/components/switch/index.d.mts +1 -2
- package/dist/components/switch/index.mjs +6 -9
- package/dist/components/table/index.d.mts +0 -2
- package/dist/components/table/index.mjs +233 -320
- package/dist/components/tabs/index.d.mts +8 -12
- package/dist/components/tabs/index.mjs +83 -34
- package/dist/components/tag/index.d.mts +1 -2
- package/dist/components/tag/index.mjs +46 -70
- package/dist/components/tags-input/index.d.mts +1 -2
- package/dist/components/tags-input/index.mjs +7 -10
- package/dist/components/terminal/index.d.mts +3 -3
- package/dist/components/terminal/index.mjs +61 -56
- package/dist/components/textarea/index.d.mts +1 -3
- package/dist/components/textarea/index.mjs +10 -11
- package/dist/components/timeline/index.d.mts +1 -2
- package/dist/components/timeline/index.mjs +15 -14
- package/dist/components/timer/index.d.mts +1 -2
- package/dist/components/timer/index.mjs +5 -6
- package/dist/components/toast/index.d.mts +0 -2
- package/dist/components/toast/index.mjs +5 -6
- package/dist/components/toc/index.d.mts +1 -1
- package/dist/components/toc/index.mjs +1 -2
- package/dist/components/toggle/index.d.mts +1 -2
- package/dist/components/toggle/index.mjs +5 -6
- package/dist/components/toggle-group/index.d.mts +1 -2
- package/dist/components/toggle-group/index.mjs +11 -16
- package/dist/components/toolbar/index.d.mts +1 -3
- package/dist/components/toolbar/index.mjs +27 -31
- package/dist/components/tooltip/index.d.mts +1 -2
- package/dist/components/tooltip/index.mjs +7 -16
- package/dist/components/tour/index.d.mts +0 -2
- package/dist/components/tour/index.mjs +11 -16
- package/dist/components/transfer/index.d.mts +1 -2
- package/dist/components/transfer/index.mjs +115 -126
- package/dist/components/tree-select/index.d.mts +2 -3
- package/dist/components/tree-select/index.mjs +24 -33
- package/dist/components/tree-view/index.d.mts +10 -4
- package/dist/components/tree-view/index.mjs +32 -23
- package/dist/components/typography/index.d.mts +2 -3
- package/dist/components/typography/index.mjs +4 -4
- package/dist/components/user/index.d.mts +1 -3
- package/dist/components/user/index.mjs +40 -57
- package/dist/components/virtual-list/index.d.mts +1 -3
- package/dist/components/virtual-list/index.mjs +39 -45
- package/dist/components/watermark/index.d.mts +1 -3
- package/dist/components/watermark/index.mjs +15 -22
- package/dist/{element-dGIhOTJ6.mjs → element-liigPBUh.mjs} +1 -2
- package/dist/{family-Cmd8HEyK.mjs → family-B5HtE0on.mjs} +1 -2
- package/dist/generative/index.d.mts +0 -2
- package/dist/generative/index.mjs +240 -248
- package/dist/{icon-DTqmJCd5.mjs → icon-DQqYA2fO.mjs} +11 -17
- package/dist/{id-2ygNzPHF.mjs → id-DGvz-2rQ.mjs} +1 -2
- package/dist/{image-viewer-19s75Hz_.mjs → image-viewer-TEia4PaY.mjs} +73 -101
- package/dist/{index-BU5U5w04.d.mts → index-B4WyTngM.d.mts} +0 -4
- package/dist/index-BRvSfkKs.d.mts +25 -0
- package/dist/{index-DhripUtf.d.mts → index-CTsFsYdA.d.mts} +0 -4
- package/dist/index-CutrHCzU.d.mts +153 -0
- package/dist/{index-wW28BYf1.d.mts → index-CwmZdzxT.d.mts} +0 -8
- package/dist/index-DK7YgaAU.d.mts +37 -0
- package/dist/index-Dms00480.d.mts +115 -0
- package/dist/{index-ID48LCMU.d.mts → index-Dv6mwzIr.d.mts} +3 -7
- package/dist/index.d.mts +17 -17
- package/dist/index.mjs +12 -12
- package/dist/{input-BL3N3L8g.mjs → input-2xfPP-7Z.mjs} +11 -13
- package/dist/{media-player-yF7KVUxM.mjs → media-player-LHnTiSiN.mjs} +248 -259
- package/dist/mentions-CvY9IGzc.mjs +438 -0
- package/dist/{select-DI7pFspF.mjs → select-NaNlrYUT.mjs} +72 -96
- package/dist/{toc-DRHr8_eD.mjs → toc-RnPG3w7q.mjs} +5 -7
- package/dist/{use-component-messages-C4SCVYjD.mjs → use-component-messages-DS9ppb4C.mjs} +1 -2
- package/package.json +13 -13
- package/dist/index-DEArHiFI.d.mts +0 -104
- package/dist/index-DVc1L_zt.d.mts +0 -10435
- package/dist/mentions-DKUG7eHt.mjs +0 -279
package/README.md
CHANGED
|
@@ -37,10 +37,10 @@ Theme the document, then use the components — the component import
|
|
|
37
37
|
carries the whole token layer in with it:
|
|
38
38
|
|
|
39
39
|
```tsx
|
|
40
|
-
// index.tsx
|
|
41
|
-
import { render } from "solid-js/web";
|
|
42
40
|
import { applyTheme } from "@bysages/solid";
|
|
43
41
|
import { Dialog } from "@bysages/solid";
|
|
42
|
+
// index.tsx
|
|
43
|
+
import { render } from "solid-js/web";
|
|
44
44
|
|
|
45
45
|
applyTheme({ mode: "system", accent: "ink" });
|
|
46
46
|
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { n as withSelfRoot } from "./family-B5HtE0on.mjs";
|
|
2
|
+
import { r as iconNode } from "./icon-DQqYA2fO.mjs";
|
|
3
|
+
import { Action } from "./components/ai-action/index.mjs";
|
|
4
|
+
import { AiMessage as Message } from "./components/ai-message/index.mjs";
|
|
5
|
+
import { n as useComponentMessages } from "./use-component-messages-DS9ppb4C.mjs";
|
|
6
|
+
import { t as PromptInput } from "./ai-prompt-input-CEnnpkgi.mjs";
|
|
7
|
+
import { AiReasoning as Reasoning } from "./components/ai-reasoning/index.mjs";
|
|
8
|
+
import { t as Response } from "./ai-response-BM_DVIDY.mjs";
|
|
9
|
+
import { AiSource as Source, AiSources as Sources } from "./components/ai-source/index.mjs";
|
|
10
|
+
import { AiSuggestion as Suggestion } from "./components/ai-suggestion/index.mjs";
|
|
11
|
+
import { AiTool as Tool } from "./components/ai-tool/index.mjs";
|
|
12
|
+
import { createConversationFollower } from "@bysages/core";
|
|
13
|
+
import { createComponent, effect, insert, mergeProps, setAttribute, spread, template, use } from "solid-js/web";
|
|
14
|
+
import { injectComponentStyle } from "@bysages/core/styling";
|
|
15
|
+
import { For, createEffect, createSignal, on, onCleanup, onMount, splitProps } from "solid-js";
|
|
16
|
+
// src/components/ai/parts.tsx
|
|
17
|
+
var _tmpl$$1 = /*#__PURE__*/ template(`<a data-scope=ai data-part=file-link target=_blank rel=noreferrer><span>`);
|
|
18
|
+
var _tmpl$2$1 = /*#__PURE__*/ template(`<figure data-scope=ai data-part=media>`);
|
|
19
|
+
var _tmpl$3 = /*#__PURE__*/ template(`<img>`);
|
|
20
|
+
var _tmpl$4 = /*#__PURE__*/ template(`<audio controls>`);
|
|
21
|
+
var _tmpl$5 = /*#__PURE__*/ template(`<video controls>`);
|
|
22
|
+
var _tmpl$6 = /*#__PURE__*/ template(`<li data-scope=ai data-part=document-source><span></span><span>`);
|
|
23
|
+
var _tmpl$7 = /*#__PURE__*/ template(`<hr data-scope=ai data-part=step-start>`);
|
|
24
|
+
const mediaKind = (mediaType) => {
|
|
25
|
+
const family = mediaType.split("/")[0];
|
|
26
|
+
if (family === "image") return "image";
|
|
27
|
+
if (family === "audio") return "audio";
|
|
28
|
+
if (family === "video") return "video";
|
|
29
|
+
return "file";
|
|
30
|
+
};
|
|
31
|
+
function toolPartDisplay(part) {
|
|
32
|
+
const name = part.type === "dynamic-tool" ? part.toolName : part.type.slice(5);
|
|
33
|
+
const approval = (() => {
|
|
34
|
+
if (part.state === "approval-requested") return "required";
|
|
35
|
+
if (part.state === "approval-responded") return part.approval.approved ? "approved" : "denied";
|
|
36
|
+
if (part.state === "output-denied") return "denied";
|
|
37
|
+
})();
|
|
38
|
+
return {
|
|
39
|
+
name,
|
|
40
|
+
status: (() => {
|
|
41
|
+
if (part.state === "input-streaming") return "pending";
|
|
42
|
+
if (part.state === "input-available") return "running";
|
|
43
|
+
if (part.state === "approval-requested") return "running";
|
|
44
|
+
if (part.state === "approval-responded") return "running";
|
|
45
|
+
if (part.state === "output-available") return "completed";
|
|
46
|
+
if (part.state === "output-error") return "error";
|
|
47
|
+
return "denied";
|
|
48
|
+
})(),
|
|
49
|
+
approval,
|
|
50
|
+
input: part.input,
|
|
51
|
+
output: part.state === "output-error" ? part.errorText : part.output
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const fileLabel = (part) => "filename" in part && part.filename ? part.filename : part.mediaType;
|
|
55
|
+
const fileLink = (part) => (() => {
|
|
56
|
+
var _el$ = _tmpl$$1(), _el$2 = _el$.firstChild;
|
|
57
|
+
insert(_el$, () => iconNode("file"), _el$2);
|
|
58
|
+
insert(_el$2, () => fileLabel(part));
|
|
59
|
+
effect(() => setAttribute(_el$, "href", part.url));
|
|
60
|
+
return _el$;
|
|
61
|
+
})();
|
|
62
|
+
const slotContent = (content) => content ?? null;
|
|
63
|
+
const isTextPart = (part) => part.type === "text";
|
|
64
|
+
const isCustomPart = (part) => part.type === "custom";
|
|
65
|
+
const isReasoningPart = (part) => part.type === "reasoning";
|
|
66
|
+
const isReasoningFilePart = (part) => part.type === "reasoning-file";
|
|
67
|
+
const isFilePart = (part) => part.type === "file";
|
|
68
|
+
const isSourceUrlPart = (part) => part.type === "source-url";
|
|
69
|
+
const isSourceDocumentPart = (part) => part.type === "source-document";
|
|
70
|
+
const isToolPart = (part) => part.type === "dynamic-tool" || part.type.startsWith("tool-");
|
|
71
|
+
const isDataPart = (part) => part.type.startsWith("data-");
|
|
72
|
+
const isStepStartPart = (part) => part.type === "step-start";
|
|
73
|
+
const AiMedia = withSelfRoot(function AiMedia(props) {
|
|
74
|
+
injectComponentStyle("ai");
|
|
75
|
+
const shown = props.part ?? (props.mediaType && props.url ? {
|
|
76
|
+
type: "file",
|
|
77
|
+
mediaType: props.mediaType,
|
|
78
|
+
url: props.url,
|
|
79
|
+
...props.filename ? { filename: props.filename } : {}
|
|
80
|
+
} : null);
|
|
81
|
+
if (!shown) return null;
|
|
82
|
+
const kind = mediaKind(shown.mediaType);
|
|
83
|
+
const label = fileLabel(shown);
|
|
84
|
+
return (() => {
|
|
85
|
+
var _el$3 = _tmpl$2$1();
|
|
86
|
+
setAttribute(_el$3, "data-kind", kind);
|
|
87
|
+
insert(_el$3, () => kind === "image" ? (() => {
|
|
88
|
+
var _el$4 = _tmpl$3();
|
|
89
|
+
effect((_p$) => {
|
|
90
|
+
var _v$ = shown.url, _v$2 = props.alt ?? (label === shown.mediaType ? "" : label);
|
|
91
|
+
_v$ !== _p$.e && setAttribute(_el$4, "src", _p$.e = _v$);
|
|
92
|
+
_v$2 !== _p$.t && setAttribute(_el$4, "alt", _p$.t = _v$2);
|
|
93
|
+
return _p$;
|
|
94
|
+
}, {
|
|
95
|
+
e: void 0,
|
|
96
|
+
t: void 0
|
|
97
|
+
});
|
|
98
|
+
return _el$4;
|
|
99
|
+
})() : kind === "audio" ? (() => {
|
|
100
|
+
var _el$5 = _tmpl$4();
|
|
101
|
+
effect(() => setAttribute(_el$5, "src", shown.url));
|
|
102
|
+
return _el$5;
|
|
103
|
+
})() : kind === "video" ? (() => {
|
|
104
|
+
var _el$6 = _tmpl$5();
|
|
105
|
+
effect(() => setAttribute(_el$6, "src", shown.url));
|
|
106
|
+
return _el$6;
|
|
107
|
+
})() : fileLink(shown));
|
|
108
|
+
return _el$3;
|
|
109
|
+
})();
|
|
110
|
+
});
|
|
111
|
+
const source = (part) => "url" in part ? createComponent(Sources, { get children() {
|
|
112
|
+
return createComponent(Source, {
|
|
113
|
+
get href() {
|
|
114
|
+
return part.url;
|
|
115
|
+
},
|
|
116
|
+
get children() {
|
|
117
|
+
return part.title ?? part.url;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
} }) : createComponent(Sources, { get children() {
|
|
121
|
+
var _el$7 = _tmpl$6(), _el$8 = _el$7.firstChild, _el$9 = _el$8.nextSibling;
|
|
122
|
+
insert(_el$8, () => part.title);
|
|
123
|
+
insert(_el$9, () => part.mediaType);
|
|
124
|
+
return _el$7;
|
|
125
|
+
} });
|
|
126
|
+
function AiPartsRenderer(props) {
|
|
127
|
+
injectComponentStyle("ai");
|
|
128
|
+
const renderPart = (part, index) => {
|
|
129
|
+
if (isTextPart(part)) {
|
|
130
|
+
const custom = slotContent(props.slots?.text?.({
|
|
131
|
+
part,
|
|
132
|
+
index
|
|
133
|
+
}));
|
|
134
|
+
if (custom) return custom;
|
|
135
|
+
return part.text ? createComponent(Response, {
|
|
136
|
+
get content() {
|
|
137
|
+
return part.text;
|
|
138
|
+
},
|
|
139
|
+
get highlighter() {
|
|
140
|
+
return props.highlighter;
|
|
141
|
+
}
|
|
142
|
+
}) : null;
|
|
143
|
+
}
|
|
144
|
+
if (isReasoningPart(part)) {
|
|
145
|
+
const custom = slotContent(props.slots?.reasoning?.({
|
|
146
|
+
part,
|
|
147
|
+
index
|
|
148
|
+
}));
|
|
149
|
+
if (custom) return custom;
|
|
150
|
+
return createComponent(Reasoning, {
|
|
151
|
+
get defaultOpen() {
|
|
152
|
+
return part.state === "streaming";
|
|
153
|
+
},
|
|
154
|
+
get children() {
|
|
155
|
+
return part.text;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (isReasoningFilePart(part)) return slotContent(props.slots?.reasoningFile?.({
|
|
160
|
+
part,
|
|
161
|
+
index
|
|
162
|
+
})) ?? createComponent(AiMedia, { part });
|
|
163
|
+
if (isFilePart(part)) return slotContent(props.slots?.file?.({
|
|
164
|
+
part,
|
|
165
|
+
index
|
|
166
|
+
})) ?? createComponent(AiMedia, { part });
|
|
167
|
+
if (isSourceUrlPart(part)) return slotContent(props.slots?.sourceUrl?.({
|
|
168
|
+
part,
|
|
169
|
+
index
|
|
170
|
+
})) ?? source(part);
|
|
171
|
+
if (isSourceDocumentPart(part)) return slotContent(props.slots?.sourceDocument?.({
|
|
172
|
+
part,
|
|
173
|
+
index
|
|
174
|
+
})) ?? source(part);
|
|
175
|
+
if (isToolPart(part)) {
|
|
176
|
+
const custom = slotContent(props.slots?.tool?.({
|
|
177
|
+
part,
|
|
178
|
+
index
|
|
179
|
+
}));
|
|
180
|
+
if (custom) return custom;
|
|
181
|
+
const display = toolPartDisplay(part);
|
|
182
|
+
return createComponent(Tool, {
|
|
183
|
+
get name() {
|
|
184
|
+
return display.name;
|
|
185
|
+
},
|
|
186
|
+
get status() {
|
|
187
|
+
return display.status;
|
|
188
|
+
},
|
|
189
|
+
get approval() {
|
|
190
|
+
return display.approval;
|
|
191
|
+
},
|
|
192
|
+
get inputValue() {
|
|
193
|
+
return display.input;
|
|
194
|
+
},
|
|
195
|
+
get outputValue() {
|
|
196
|
+
return display.output;
|
|
197
|
+
},
|
|
198
|
+
get defaultOpen() {
|
|
199
|
+
return display.status === "error" || display.approval === "required";
|
|
200
|
+
},
|
|
201
|
+
onApprove: () => props.onApprove?.({
|
|
202
|
+
part,
|
|
203
|
+
index
|
|
204
|
+
}),
|
|
205
|
+
onDeny: () => props.onDeny?.({
|
|
206
|
+
part,
|
|
207
|
+
index
|
|
208
|
+
})
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if (isStepStartPart(part)) return slotContent(props.slots?.stepStart?.({
|
|
212
|
+
part,
|
|
213
|
+
index
|
|
214
|
+
})) ?? _tmpl$7();
|
|
215
|
+
if (isDataPart(part)) return slotContent(props.slots?.data?.({
|
|
216
|
+
part,
|
|
217
|
+
index
|
|
218
|
+
}));
|
|
219
|
+
if (isCustomPart(part)) return slotContent(props.slots?.custom?.({
|
|
220
|
+
part,
|
|
221
|
+
index
|
|
222
|
+
}));
|
|
223
|
+
return slotContent(props.slots?.fallback?.({
|
|
224
|
+
part,
|
|
225
|
+
index
|
|
226
|
+
}));
|
|
227
|
+
};
|
|
228
|
+
const overriddenMessage = slotContent(props.slots?.default?.({ message: props.message }));
|
|
229
|
+
if (overriddenMessage) return overriddenMessage;
|
|
230
|
+
return createComponent(For, {
|
|
231
|
+
get each() {
|
|
232
|
+
return props.message.parts;
|
|
233
|
+
},
|
|
234
|
+
children: (part, index) => renderPart(part, index())
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
const AiParts = withSelfRoot(AiPartsRenderer);
|
|
238
|
+
// src/components/ai/index.tsx
|
|
239
|
+
var _tmpl$ = /*#__PURE__*/ template(`<div>`);
|
|
240
|
+
var _tmpl$2 = /*#__PURE__*/ template(`<button>`);
|
|
241
|
+
function part(name, extra = {}) {
|
|
242
|
+
function Component(props) {
|
|
243
|
+
const messages = useComponentMessages();
|
|
244
|
+
const partExtra = typeof extra === "function" ? extra(messages()) : extra;
|
|
245
|
+
return (() => {
|
|
246
|
+
var _el$ = _tmpl$();
|
|
247
|
+
spread(_el$, mergeProps(partExtra, props, {
|
|
248
|
+
"data-scope": "ai",
|
|
249
|
+
get ["data-part"]() {
|
|
250
|
+
return name.toLowerCase();
|
|
251
|
+
}
|
|
252
|
+
}), false, false);
|
|
253
|
+
return _el$;
|
|
254
|
+
})();
|
|
255
|
+
}
|
|
256
|
+
return Component;
|
|
257
|
+
}
|
|
258
|
+
/** The log itself: the column every stroke lands in, a landmark to
|
|
259
|
+
* screen readers. While the reply streams, the log follows its growth —
|
|
260
|
+
* but only while the reader rests at the bottom edge. */
|
|
261
|
+
const AiConversation = function AiConversation(props) {
|
|
262
|
+
const [own, rest] = splitProps(props, ["autoScroll"]);
|
|
263
|
+
const messages = useComponentMessages();
|
|
264
|
+
let node;
|
|
265
|
+
let stopFollowing;
|
|
266
|
+
createEffect(on(() => own.autoScroll !== false, (enabled) => {
|
|
267
|
+
stopFollowing?.();
|
|
268
|
+
stopFollowing = void 0;
|
|
269
|
+
if (node && enabled) stopFollowing = createConversationFollower(node);
|
|
270
|
+
}));
|
|
271
|
+
onCleanup(() => stopFollowing?.());
|
|
272
|
+
return (() => {
|
|
273
|
+
var _el$2 = _tmpl$();
|
|
274
|
+
use((element) => {
|
|
275
|
+
node = element;
|
|
276
|
+
}, _el$2);
|
|
277
|
+
spread(_el$2, mergeProps(rest, {
|
|
278
|
+
"role": "log",
|
|
279
|
+
get ["aria-label"]() {
|
|
280
|
+
return props["aria-label"] ?? messages().ai.conversation;
|
|
281
|
+
},
|
|
282
|
+
"data-scope": "ai",
|
|
283
|
+
"data-part": "conversation"
|
|
284
|
+
}), false, false);
|
|
285
|
+
return _el$2;
|
|
286
|
+
})();
|
|
287
|
+
};
|
|
288
|
+
const AiJumpToLatest = function AiJumpToLatest(props) {
|
|
289
|
+
const [own, rest] = splitProps(props, ["threshold", "onJump"]);
|
|
290
|
+
const messages = useComponentMessages();
|
|
291
|
+
const [visible, setVisible] = createSignal(false);
|
|
292
|
+
let button;
|
|
293
|
+
let log;
|
|
294
|
+
const measure = () => {
|
|
295
|
+
if (!log) return;
|
|
296
|
+
setVisible(log.scrollHeight - log.scrollTop - log.clientHeight > (own.threshold ?? 96));
|
|
297
|
+
};
|
|
298
|
+
onMount(() => {
|
|
299
|
+
log = button?.closest("[data-scope=\"ai\"][data-part=\"conversation\"]") ?? null;
|
|
300
|
+
log?.addEventListener("scroll", measure, { passive: true });
|
|
301
|
+
measure();
|
|
302
|
+
onCleanup(() => log?.removeEventListener("scroll", measure));
|
|
303
|
+
});
|
|
304
|
+
createEffect(on(() => own.threshold, measure));
|
|
305
|
+
const jump = () => {
|
|
306
|
+
if (log) log.scrollTop = log.scrollHeight;
|
|
307
|
+
own.onJump?.();
|
|
308
|
+
};
|
|
309
|
+
return (() => {
|
|
310
|
+
var _el$3 = _tmpl$2();
|
|
311
|
+
use((element) => {
|
|
312
|
+
button = element;
|
|
313
|
+
}, _el$3);
|
|
314
|
+
spread(_el$3, mergeProps(rest, {
|
|
315
|
+
"type": "button",
|
|
316
|
+
"data-scope": "ai",
|
|
317
|
+
"data-part": "jump-to-latest",
|
|
318
|
+
get ["data-visible"]() {
|
|
319
|
+
return visible() ? "" : void 0;
|
|
320
|
+
},
|
|
321
|
+
get tabIndex() {
|
|
322
|
+
return visible() ? 0 : -1;
|
|
323
|
+
},
|
|
324
|
+
get ["aria-label"]() {
|
|
325
|
+
return rest["aria-label"] ?? messages().ai.jumpToLatest;
|
|
326
|
+
},
|
|
327
|
+
"onClick": jump
|
|
328
|
+
}), false, true);
|
|
329
|
+
insert(_el$3, () => rest.children ?? messages().ai.jumpToLatest);
|
|
330
|
+
return _el$3;
|
|
331
|
+
})();
|
|
332
|
+
};
|
|
333
|
+
/** The bubble's inner measure — content that belongs to neither side
|
|
334
|
+
* specifically. */
|
|
335
|
+
const AiContent = withSelfRoot(part("Content"));
|
|
336
|
+
/** The quiet row under a message — copy, retry, feedback. */
|
|
337
|
+
const AiActions = withSelfRoot(part("Actions"));
|
|
338
|
+
/** The while-it-works whisper for the in-flight turns. */
|
|
339
|
+
const AiLoader = withSelfRoot(part("Loader", (messages) => ({
|
|
340
|
+
role: "status",
|
|
341
|
+
"aria-label": messages.ai.loading
|
|
342
|
+
})));
|
|
343
|
+
/** The whole family under one handle — `Ai.Conversation`,
|
|
344
|
+
* `Ai.MessageContent`, and the rest. */
|
|
345
|
+
const Ai = Object.assign(AiConversation, {
|
|
346
|
+
Root: AiConversation,
|
|
347
|
+
Conversation: AiConversation,
|
|
348
|
+
MessageContent: AiContent,
|
|
349
|
+
Actions: AiActions,
|
|
350
|
+
Loader: AiLoader,
|
|
351
|
+
Media: AiMedia,
|
|
352
|
+
Parts: AiParts,
|
|
353
|
+
JumpToLatest: AiJumpToLatest,
|
|
354
|
+
Message,
|
|
355
|
+
Response,
|
|
356
|
+
Reasoning,
|
|
357
|
+
Tool,
|
|
358
|
+
Sources,
|
|
359
|
+
Source,
|
|
360
|
+
Action,
|
|
361
|
+
Suggestion,
|
|
362
|
+
PromptInput
|
|
363
|
+
});
|
|
364
|
+
injectComponentStyle("ai");
|
|
365
|
+
export { AiJumpToLatest as a, AiParts as c, AiConversation as i, toolPartDisplay as l, AiActions as n, AiLoader as o, AiContent as r, AiMedia as s, Ai as t };
|