wimui 0.51.1 → 0.52.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/dist/components/_internal/FeedbackCloseButton.cjs +1 -1
- package/dist/components/_internal/FeedbackCloseButton.js +14 -13
- package/dist/components/_internal/FieldLabelContent.cjs +1 -1
- package/dist/components/_internal/FieldLabelContent.js +18 -17
- package/dist/components/ai/AIResponseFeedback/AIResponseFeedback.cjs +1 -1
- package/dist/components/ai/AIResponseFeedback/AIResponseFeedback.js +46 -45
- package/dist/components/ai/AgentStatus/AgentStatus.cjs +1 -1
- package/dist/components/ai/AgentStatus/AgentStatus.js +24 -23
- package/dist/components/ai/ArtifactsOverlay/ArtifactsOverlay.cjs +1 -1
- package/dist/components/ai/ArtifactsOverlay/ArtifactsOverlay.js +47 -45
- package/dist/components/ai/ChatUI/ChatUI.cjs +1 -1
- package/dist/components/ai/ChatUI/ChatUI.js +82 -81
- package/dist/components/ai/CodeBlock/CodeBlock.cjs +3 -3
- package/dist/components/ai/CodeBlock/CodeBlock.js +53 -52
- package/dist/components/ai/CodeDiffViewer/CodeDiffViewer.cjs +2 -2
- package/dist/components/ai/CodeDiffViewer/CodeDiffViewer.js +105 -104
- package/dist/components/ai/MarkdownRenderer/MarkdownRenderer.cjs +1 -1
- package/dist/components/ai/MarkdownRenderer/MarkdownRenderer.js +60 -59
- package/dist/components/ai/ModelSelector/ModelSelector.cjs +1 -1
- package/dist/components/ai/ModelSelector/ModelSelector.js +122 -120
- package/dist/components/ai/ModelSelector/model-selector.module.cjs +1 -1
- package/dist/components/ai/ModelSelector/model-selector.module.js +1 -1
- package/dist/components/ai/PromptInput/PromptInput.cjs +1 -1
- package/dist/components/ai/PromptInput/PromptInput.js +76 -75
- package/dist/components/ai/SourceCitation/SourceCitation.cjs +1 -1
- package/dist/components/ai/SourceCitation/SourceCitation.js +39 -38
- package/dist/components/ai/Terminal/Terminal.cjs +2 -2
- package/dist/components/ai/Terminal/Terminal.js +65 -64
- package/dist/components/ai/ThreadList/ThreadList.cjs +1 -1
- package/dist/components/ai/ThreadList/ThreadList.js +64 -62
- package/dist/components/data-display/Accordion/accordion.module.cjs +1 -1
- package/dist/components/data-display/Accordion/accordion.module.js +1 -1
- package/dist/components/data-display/Barcode/Barcode.cjs +1 -1
- package/dist/components/data-display/Barcode/Barcode.js +76 -75
- package/dist/components/data-display/Calendar/Calendar.cjs +1 -1
- package/dist/components/data-display/Calendar/Calendar.js +75 -74
- package/dist/components/data-display/CalendarHeatmap/CalendarHeatmap.cjs +1 -1
- package/dist/components/data-display/CalendarHeatmap/CalendarHeatmap.js +54 -52
- package/dist/components/data-display/Carousel/Carousel.cjs +1 -1
- package/dist/components/data-display/Carousel/Carousel.js +24 -23
- package/dist/components/data-display/Chip/Chip.cjs +1 -1
- package/dist/components/data-display/Chip/Chip.js +36 -35
- package/dist/components/data-display/Comment/Comment.cjs +1 -1
- package/dist/components/data-display/Comment/Comment.js +58 -57
- package/dist/components/data-display/Countdown/Countdown.cjs +1 -1
- package/dist/components/data-display/Countdown/Countdown.js +56 -55
- package/dist/components/data-display/DataGrid/DataGrid.cjs +1 -1
- package/dist/components/data-display/DataGrid/DataGrid.js +128 -127
- package/dist/components/data-display/JsonViewer/JsonViewer.cjs +1 -1
- package/dist/components/data-display/JsonViewer/JsonViewer.js +153 -152
- package/dist/components/data-display/Kanban/Kanban.cjs +1 -1
- package/dist/components/data-display/Kanban/Kanban.js +95 -94
- package/dist/components/data-display/NodeGraph/NodeGraph.cjs +1 -1
- package/dist/components/data-display/NodeGraph/NodeGraph.js +67 -66
- package/dist/components/data-display/PivotTable/PivotTable.cjs +1 -1
- package/dist/components/data-display/PivotTable/PivotTable.js +153 -152
- package/dist/components/data-display/Presence/Presence.cjs +1 -1
- package/dist/components/data-display/Presence/Presence.js +28 -27
- package/dist/components/data-display/PullToRefresh/PullToRefresh.cjs +1 -1
- package/dist/components/data-display/PullToRefresh/PullToRefresh.js +73 -72
- package/dist/components/data-display/Reaction/Reaction.cjs +1 -1
- package/dist/components/data-display/Reaction/Reaction.js +31 -30
- package/dist/components/data-display/ScheduleView/ScheduleView.cjs +1 -1
- package/dist/components/data-display/ScheduleView/ScheduleView.js +52 -50
- package/dist/components/data-display/SortableList/SortableList.cjs +1 -1
- package/dist/components/data-display/SortableList/SortableList.js +44 -43
- package/dist/components/data-display/Tag/Tag.cjs +1 -1
- package/dist/components/data-display/Tag/Tag.js +29 -28
- package/dist/components/data-display/TreeDiagram/TreeDiagram.cjs +1 -1
- package/dist/components/data-display/TreeDiagram/TreeDiagram.js +85 -84
- package/dist/components/data-display/TreeView/TreeView.cjs +1 -1
- package/dist/components/data-display/TreeView/TreeView.js +123 -122
- package/dist/components/feedback/Autosave/Autosave.cjs +1 -1
- package/dist/components/feedback/Autosave/Autosave.js +32 -31
- package/dist/components/feedback/ErrorBoundary/ErrorBoundary.cjs +1 -1
- package/dist/components/feedback/ErrorBoundary/ErrorBoundary.js +35 -34
- package/dist/components/feedback/ScrollProgress/ScrollProgress.cjs +1 -1
- package/dist/components/feedback/ScrollProgress/ScrollProgress.js +21 -20
- package/dist/components/feedback/Tour/Tour.cjs +1 -1
- package/dist/components/feedback/Tour/Tour.js +127 -101
- package/dist/components/form/Button/Button.cjs +1 -1
- package/dist/components/form/Button/Button.js +55 -54
- package/dist/components/form/ColorInput/ColorInput.cjs +1 -1
- package/dist/components/form/ColorInput/ColorInput.js +30 -29
- package/dist/components/form/ColorPicker/color-picker.module.cjs +1 -1
- package/dist/components/form/ColorPicker/color-picker.module.js +1 -1
- package/dist/components/form/CopyButton/CopyButton.cjs +1 -1
- package/dist/components/form/CopyButton/CopyButton.js +27 -26
- package/dist/components/form/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/form/DatePicker/DatePicker.js +47 -46
- package/dist/components/form/DateRangePicker/DateRangePicker.cjs +1 -1
- package/dist/components/form/DateRangePicker/DateRangePicker.js +36 -35
- package/dist/components/form/Dropzone/Dropzone.cjs +1 -1
- package/dist/components/form/Dropzone/Dropzone.js +56 -55
- package/dist/components/form/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/form/FileUpload/FileUpload.js +47 -46
- package/dist/components/form/FloatButton/FloatButton.cjs +1 -1
- package/dist/components/form/FloatButton/FloatButton.d.ts +4 -1
- package/dist/components/form/FloatButton/FloatButton.js +6 -6
- package/dist/components/form/ImageCropper/ImageCropper.cjs +1 -1
- package/dist/components/form/ImageCropper/ImageCropper.js +101 -99
- package/dist/components/form/InlineEdit/InlineEdit.cjs +1 -1
- package/dist/components/form/InlineEdit/InlineEdit.js +66 -65
- package/dist/components/form/Input/Input.cjs +1 -1
- package/dist/components/form/Input/Input.js +45 -44
- package/dist/components/form/InputBase/InputBase.cjs +1 -1
- package/dist/components/form/InputBase/InputBase.js +51 -50
- package/dist/components/form/InputBase/input-base.module.cjs +1 -1
- package/dist/components/form/InputBase/input-base.module.js +1 -1
- package/dist/components/form/MultiSelect/multiselect.module.cjs +1 -1
- package/dist/components/form/MultiSelect/multiselect.module.js +1 -1
- package/dist/components/form/OtpInput/otp-input.module.cjs +1 -1
- package/dist/components/form/OtpInput/otp-input.module.js +1 -1
- package/dist/components/form/PasswordStrength/PasswordStrength.cjs +1 -1
- package/dist/components/form/PasswordStrength/PasswordStrength.js +27 -26
- package/dist/components/form/PhoneInput/PhoneInput.cjs +1 -1
- package/dist/components/form/PhoneInput/PhoneInput.js +10 -10
- package/dist/components/form/QueryBuilder/QueryBuilder.cjs +1 -1
- package/dist/components/form/QueryBuilder/QueryBuilder.js +90 -89
- package/dist/components/form/RangeSlider/RangeSlider.cjs +1 -1
- package/dist/components/form/RangeSlider/RangeSlider.js +121 -119
- package/dist/components/form/RangeSlider/range-slider.module.cjs +1 -1
- package/dist/components/form/RangeSlider/range-slider.module.js +1 -1
- package/dist/components/form/RichTextEditor/RichTextEditor.cjs +1 -1
- package/dist/components/form/RichTextEditor/RichTextEditor.js +223 -222
- package/dist/components/form/SegmentedControl/SegmentedControl.cjs +1 -1
- package/dist/components/form/SegmentedControl/SegmentedControl.js +7 -7
- package/dist/components/form/Select/Select.cjs +1 -1
- package/dist/components/form/Select/Select.js +112 -111
- package/dist/components/form/SignaturePad/SignaturePad.cjs +1 -1
- package/dist/components/form/SignaturePad/SignaturePad.js +86 -79
- package/dist/components/form/SmartSearchInput/SmartSearchInput.cjs +1 -1
- package/dist/components/form/SmartSearchInput/SmartSearchInput.js +63 -62
- package/dist/components/form/TagInput/TagInput.cjs +1 -1
- package/dist/components/form/TagInput/TagInput.js +68 -67
- package/dist/components/form/ThemeToggle/ThemeToggle.cjs +1 -1
- package/dist/components/form/ThemeToggle/ThemeToggle.js +69 -67
- package/dist/components/form/ThemeToggle/theme-toggle.module.cjs +1 -1
- package/dist/components/form/ThemeToggle/theme-toggle.module.js +1 -1
- package/dist/components/form/ToggleGroup/ToggleGroup.cjs +1 -1
- package/dist/components/form/ToggleGroup/ToggleGroup.js +6 -6
- package/dist/components/form/Transfer/Transfer.cjs +1 -1
- package/dist/components/form/Transfer/Transfer.d.ts +1 -1
- package/dist/components/form/Transfer/Transfer.js +155 -154
- package/dist/components/form/Transfer/transfer.module.cjs +1 -1
- package/dist/components/form/Transfer/transfer.module.js +6 -6
- package/dist/components/form/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/form/TreeSelect/TreeSelect.js +6 -6
- package/dist/components/layout/Dashboard/Dashboard.cjs +1 -1
- package/dist/components/layout/Dashboard/Dashboard.js +90 -89
- package/dist/components/layout/Navbar/Navbar.cjs +1 -1
- package/dist/components/layout/Navbar/Navbar.d.ts +1 -1
- package/dist/components/layout/Navbar/Navbar.js +1 -1
- package/dist/components/layout/Sidebar/Sidebar.d.ts +1 -1
- package/dist/components/layout/Splitter/Splitter.cjs +1 -1
- package/dist/components/layout/Splitter/Splitter.js +40 -39
- package/dist/components/layout/Toolbar/Toolbar.cjs +1 -1
- package/dist/components/layout/Toolbar/Toolbar.js +66 -39
- package/dist/components/media/Audio/Audio.cjs +1 -1
- package/dist/components/media/Audio/Audio.js +91 -90
- package/dist/components/media/Audio/components/AudioCustomControls.cjs +1 -1
- package/dist/components/media/Audio/components/AudioCustomControls.js +116 -114
- package/dist/components/media/Gallery/Gallery.cjs +1 -1
- package/dist/components/media/Gallery/Gallery.js +132 -131
- package/dist/components/media/ImageCompare/ImageCompare.cjs +1 -1
- package/dist/components/media/ImageCompare/ImageCompare.js +75 -73
- package/dist/components/media/Lightbox/Lightbox.cjs +1 -1
- package/dist/components/media/Lightbox/Lightbox.js +128 -127
- package/dist/components/media/Video/Video.cjs +1 -1
- package/dist/components/media/Video/Video.js +73 -71
- package/dist/components/media/Video/components/VideoAdvancedMenu.cjs +1 -1
- package/dist/components/media/Video/components/VideoAdvancedMenu.js +140 -138
- package/dist/components/media/Video/components/VideoControls.cjs +1 -1
- package/dist/components/media/Video/components/VideoControls.js +103 -102
- package/dist/components/navigation/BackTop/BackTop.cjs +1 -1
- package/dist/components/navigation/BackTop/BackTop.js +37 -36
- package/dist/components/navigation/Breadcrumb/Breadcrumb.cjs +1 -1
- package/dist/components/navigation/Breadcrumb/Breadcrumb.js +41 -40
- package/dist/components/navigation/CommandPalette/CommandPalette.cjs +1 -1
- package/dist/components/navigation/CommandPalette/CommandPalette.js +100 -99
- package/dist/components/navigation/HamburgerMenu/HamburgerMenu.cjs +1 -1
- package/dist/components/navigation/HamburgerMenu/HamburgerMenu.d.ts +6 -0
- package/dist/components/navigation/HamburgerMenu/HamburgerMenu.js +32 -22
- package/dist/components/navigation/Pagination/Pagination.cjs +1 -1
- package/dist/components/navigation/Pagination/Pagination.js +39 -38
- package/dist/components/navigation/SpeedDial/SpeedDial.cjs +1 -1
- package/dist/components/navigation/SpeedDial/SpeedDial.js +44 -43
- package/dist/components/navigation/Tabs/tabs.module.cjs +1 -1
- package/dist/components/navigation/Tabs/tabs.module.js +1 -1
- package/dist/components/overlay/ContextMenu/ContextMenu.cjs +1 -1
- package/dist/components/overlay/ContextMenu/ContextMenu.js +4 -4
- package/dist/components/overlay/Popover/Popover.cjs +1 -1
- package/dist/components/overlay/Popover/Popover.js +63 -62
- package/dist/components/typography/Spoiler/Spoiler.cjs +1 -1
- package/dist/components/typography/Spoiler/Spoiler.js +38 -37
- package/dist/i18n/generated/common.cjs +2 -0
- package/dist/i18n/generated/common.d.ts +3 -0
- package/dist/i18n/generated/common.js +570 -0
- package/dist/i18n/generated/components.cjs +2 -0
- package/dist/i18n/generated/components.d.ts +3 -0
- package/dist/i18n/generated/components.js +399 -0
- package/dist/i18n/generated/data-display.cjs +2 -0
- package/dist/i18n/generated/data-display.d.ts +3 -0
- package/dist/i18n/generated/data-display.js +12 -0
- package/dist/i18n/generated/form.cjs +2 -0
- package/dist/i18n/generated/form.d.ts +3 -0
- package/dist/i18n/generated/form.js +321 -0
- package/dist/i18n/generated/keys.d.ts +5 -1
- package/dist/i18n/generated/locales.cjs +2 -0
- package/dist/i18n/generated/locales.d.ts +1 -0
- package/dist/i18n/generated/locales.js +9 -0
- package/dist/i18n/instance.cjs +1 -1
- package/dist/i18n/instance.d.ts +18 -3
- package/dist/i18n/instance.js +24 -26
- package/dist/i18n/useWimTranslation.cjs +1 -1
- package/dist/i18n/useWimTranslation.d.ts +7 -8
- package/dist/i18n/useWimTranslation.js +6 -5
- package/dist/llms-full.txt +10 -6
- package/dist/llms.txt +1 -1
- package/dist/locales/en/common.json +53 -4
- package/dist/locales/en/components.json +3 -1
- package/dist/locales/ja/common.json +53 -4
- package/dist/locales/ja/components.json +3 -1
- package/dist/locales/pt/common.json +53 -4
- package/dist/locales/pt/components.json +3 -1
- package/dist/styles.css +2 -2
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +5 -5
- package/package.json +10 -10
- package/dist/i18n/generated/resources.cjs +0 -2
- package/dist/i18n/generated/resources.d.ts +0 -4
- package/dist/i18n/generated/resources.js +0 -1103
|
@@ -7,19 +7,20 @@ import i from "../../../icon/columns.js";
|
|
|
7
7
|
import a from "../../../icon/copy.js";
|
|
8
8
|
import o from "../../../icon/spinner.js";
|
|
9
9
|
import { Icon as s } from "../../media/Icon/Icon.js";
|
|
10
|
-
import c from "
|
|
11
|
-
import l
|
|
12
|
-
import h from "
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
10
|
+
import { formNs as c } from "../../../i18n/generated/form.js";
|
|
11
|
+
import l from "./code-diff-viewer.module.js";
|
|
12
|
+
import u, { useCallback as d, useEffect as f, useImperativeHandle as p, useMemo as m, useRef as h } from "react";
|
|
13
|
+
import g from "classnames";
|
|
14
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
15
|
+
import { diffLines as y } from "diff";
|
|
15
16
|
//#region src/components/ai/CodeDiffViewer/CodeDiffViewer.tsx
|
|
16
|
-
function
|
|
17
|
+
function b(e) {
|
|
17
18
|
let t = e.endsWith("\n") ? e.slice(0, -1) : e;
|
|
18
19
|
return t === "" ? [] : t.split("\n");
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
+
function x(e) {
|
|
21
22
|
let t = [], n = 1, r = 1;
|
|
22
|
-
for (let i of e) for (let e of
|
|
23
|
+
for (let i of e) for (let e of b(i.value)) i.removed ? t.push({
|
|
23
24
|
type: "removed",
|
|
24
25
|
content: e,
|
|
25
26
|
oldNum: n++
|
|
@@ -35,12 +36,12 @@ function b(e) {
|
|
|
35
36
|
});
|
|
36
37
|
return t;
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function S(e) {
|
|
39
40
|
let t = [], n = [], r = 1, i = 1, a = 0;
|
|
40
41
|
for (; a < e.length;) {
|
|
41
42
|
let o = e[a];
|
|
42
43
|
if (!o.added && !o.removed) {
|
|
43
|
-
for (let e of
|
|
44
|
+
for (let e of b(o.value)) t.push({
|
|
44
45
|
type: "unchanged",
|
|
45
46
|
content: e,
|
|
46
47
|
num: r++
|
|
@@ -51,7 +52,7 @@ function x(e) {
|
|
|
51
52
|
});
|
|
52
53
|
a++;
|
|
53
54
|
} else if (o.removed) {
|
|
54
|
-
let s =
|
|
55
|
+
let s = b(o.value), c = e[a + 1], l = c?.added ? b(c.value) : [];
|
|
55
56
|
c?.added && a++;
|
|
56
57
|
let u = Math.max(s.length, l.length);
|
|
57
58
|
for (let e = 0; e < u; e++) t.push(e < s.length ? {
|
|
@@ -71,7 +72,7 @@ function x(e) {
|
|
|
71
72
|
});
|
|
72
73
|
a++;
|
|
73
74
|
} else {
|
|
74
|
-
for (let e of
|
|
75
|
+
for (let e of b(o.value)) t.push({
|
|
75
76
|
type: "empty",
|
|
76
77
|
content: ""
|
|
77
78
|
}), n.push({
|
|
@@ -87,170 +88,170 @@ function x(e) {
|
|
|
87
88
|
right: n
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
|
-
function
|
|
91
|
-
return /* @__PURE__ */
|
|
92
|
-
className:
|
|
91
|
+
function C({ num: e }) {
|
|
92
|
+
return /* @__PURE__ */ _("span", {
|
|
93
|
+
className: l.lineNum,
|
|
93
94
|
"aria-hidden": "true",
|
|
94
95
|
children: e ?? ""
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
|
-
function
|
|
98
|
+
function w({ line: e }) {
|
|
98
99
|
let t = e.type === "added" ? "+" : e.type === "removed" ? "−" : " ";
|
|
99
|
-
return /* @__PURE__ */
|
|
100
|
-
className:
|
|
100
|
+
return /* @__PURE__ */ v("div", {
|
|
101
|
+
className: g(l.row, l[e.type]),
|
|
101
102
|
children: [
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
/* @__PURE__ */
|
|
105
|
-
className:
|
|
103
|
+
/* @__PURE__ */ _(C, { num: e.oldNum }),
|
|
104
|
+
/* @__PURE__ */ _(C, { num: e.newNum }),
|
|
105
|
+
/* @__PURE__ */ _("span", {
|
|
106
|
+
className: l.prefix,
|
|
106
107
|
"aria-hidden": "true",
|
|
107
108
|
children: t
|
|
108
109
|
}),
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
className:
|
|
110
|
+
/* @__PURE__ */ _("span", {
|
|
111
|
+
className: l.lineContent,
|
|
111
112
|
children: e.content
|
|
112
113
|
})
|
|
113
114
|
]
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
|
-
function
|
|
117
|
-
return /* @__PURE__ */
|
|
118
|
-
className:
|
|
117
|
+
function T({ line: e }) {
|
|
118
|
+
return /* @__PURE__ */ v("div", {
|
|
119
|
+
className: g(l.splitCell, l[e.type]),
|
|
119
120
|
children: [
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
e.type !== "empty" && /* @__PURE__ */
|
|
122
|
-
className:
|
|
121
|
+
/* @__PURE__ */ _(C, { num: e.num }),
|
|
122
|
+
e.type !== "empty" && /* @__PURE__ */ _("span", {
|
|
123
|
+
className: l.prefix,
|
|
123
124
|
"aria-hidden": "true",
|
|
124
125
|
children: e.type === "added" ? "+" : e.type === "removed" ? "−" : " "
|
|
125
126
|
}),
|
|
126
|
-
/* @__PURE__ */
|
|
127
|
-
className:
|
|
127
|
+
/* @__PURE__ */ _("span", {
|
|
128
|
+
className: l.lineContent,
|
|
128
129
|
children: e.content
|
|
129
130
|
})
|
|
130
131
|
]
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
|
-
var
|
|
134
|
-
let { t:
|
|
135
|
-
|
|
136
|
-
let e =
|
|
134
|
+
var E = u.forwardRef(({ before: b, after: C, language: E, filename: D, view: O = "split", onApply: k, onReject: A, className: j, isApplying: M = !1, isApplied: N = !1, ...P }, F) => {
|
|
135
|
+
let { t: I } = e(c), [L, R] = u.useState(!1), [z, B] = u.useState(O), [V, H] = u.useState(null), U = V ?? z, W = h(null);
|
|
136
|
+
p(F, () => W.current, []), f(() => {
|
|
137
|
+
let e = W.current;
|
|
137
138
|
if (!e) return;
|
|
138
139
|
let t = new ResizeObserver(([e]) => {
|
|
139
140
|
let t = e.contentRect.width < 640;
|
|
140
|
-
|
|
141
|
+
B((e) => {
|
|
141
142
|
let n = t ? "unified" : "split";
|
|
142
|
-
return e !== n &&
|
|
143
|
+
return e !== n && H(null), n;
|
|
143
144
|
});
|
|
144
145
|
});
|
|
145
146
|
return t.observe(e), () => t.disconnect();
|
|
146
147
|
}, []);
|
|
147
|
-
let
|
|
148
|
+
let G = m(() => y(b ?? "", C ?? ""), [b, C]), K = m(() => x(G), [G]), q = m(() => S(G), [G]), J = D ?? E, Y = d(async () => {
|
|
148
149
|
try {
|
|
149
|
-
await navigator.clipboard.writeText(
|
|
150
|
+
await navigator.clipboard.writeText(C), R(!0), setTimeout(() => R(!1), 2e3);
|
|
150
151
|
} catch {}
|
|
151
|
-
}, [
|
|
152
|
-
return /* @__PURE__ */
|
|
153
|
-
ref:
|
|
154
|
-
className:
|
|
155
|
-
...
|
|
156
|
-
children: [/* @__PURE__ */
|
|
157
|
-
className:
|
|
158
|
-
children: [/* @__PURE__ */
|
|
159
|
-
className:
|
|
160
|
-
children: [
|
|
161
|
-
className:
|
|
162
|
-
children:
|
|
163
|
-
}), /* @__PURE__ */
|
|
164
|
-
className:
|
|
165
|
-
children: [/* @__PURE__ */
|
|
152
|
+
}, [C]);
|
|
153
|
+
return /* @__PURE__ */ v("div", {
|
|
154
|
+
ref: W,
|
|
155
|
+
className: g("wim-code-diff-viewer", l.root, j),
|
|
156
|
+
...P,
|
|
157
|
+
children: [/* @__PURE__ */ v("div", {
|
|
158
|
+
className: l.header,
|
|
159
|
+
children: [/* @__PURE__ */ v("div", {
|
|
160
|
+
className: l.headerLeft,
|
|
161
|
+
children: [J && /* @__PURE__ */ _("span", {
|
|
162
|
+
className: l.filename,
|
|
163
|
+
children: J
|
|
164
|
+
}), /* @__PURE__ */ v("div", {
|
|
165
|
+
className: l.viewToggle,
|
|
166
|
+
children: [/* @__PURE__ */ _("button", {
|
|
166
167
|
type: "button",
|
|
167
|
-
className:
|
|
168
|
-
onClick: () =>
|
|
169
|
-
"aria-label":
|
|
170
|
-
"aria-pressed":
|
|
171
|
-
children: /* @__PURE__ */
|
|
168
|
+
className: g(l.viewBtn, U === "split" && l.active),
|
|
169
|
+
onClick: () => H("split"),
|
|
170
|
+
"aria-label": I("code_diff_viewer.split_view"),
|
|
171
|
+
"aria-pressed": U === "split",
|
|
172
|
+
children: /* @__PURE__ */ _(s, {
|
|
172
173
|
component: i,
|
|
173
174
|
size: "sm",
|
|
174
175
|
"aria-hidden": "true"
|
|
175
176
|
})
|
|
176
|
-
}), /* @__PURE__ */
|
|
177
|
+
}), /* @__PURE__ */ _("button", {
|
|
177
178
|
type: "button",
|
|
178
|
-
className:
|
|
179
|
-
onClick: () =>
|
|
180
|
-
"aria-label":
|
|
181
|
-
"aria-pressed":
|
|
182
|
-
children: /* @__PURE__ */
|
|
179
|
+
className: g(l.viewBtn, U === "unified" && l.active),
|
|
180
|
+
onClick: () => H("unified"),
|
|
181
|
+
"aria-label": I("code_diff_viewer.unified_view"),
|
|
182
|
+
"aria-pressed": U === "unified",
|
|
183
|
+
children: /* @__PURE__ */ _(s, {
|
|
183
184
|
component: t,
|
|
184
185
|
size: "sm",
|
|
185
186
|
"aria-hidden": "true"
|
|
186
187
|
})
|
|
187
188
|
})]
|
|
188
189
|
})]
|
|
189
|
-
}), /* @__PURE__ */
|
|
190
|
-
className:
|
|
190
|
+
}), /* @__PURE__ */ v("div", {
|
|
191
|
+
className: l.headerActions,
|
|
191
192
|
children: [
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
+
/* @__PURE__ */ _("button", {
|
|
193
194
|
type: "button",
|
|
194
|
-
className:
|
|
195
|
-
onClick:
|
|
196
|
-
"aria-label":
|
|
197
|
-
children: /* @__PURE__ */
|
|
198
|
-
component:
|
|
195
|
+
className: g(l.iconButton, L && l.copied),
|
|
196
|
+
onClick: Y,
|
|
197
|
+
"aria-label": I(L ? "code_diff_viewer.copied_label" : "code_diff_viewer.copy_label"),
|
|
198
|
+
children: /* @__PURE__ */ _(s, {
|
|
199
|
+
component: L ? n : a,
|
|
199
200
|
size: "sm"
|
|
200
201
|
})
|
|
201
202
|
}),
|
|
202
|
-
|
|
203
|
+
A && /* @__PURE__ */ v("button", {
|
|
203
204
|
type: "button",
|
|
204
|
-
className:
|
|
205
|
-
onClick:
|
|
206
|
-
children: [/* @__PURE__ */
|
|
205
|
+
className: g(l.actionButton, l.rejectButton),
|
|
206
|
+
onClick: A,
|
|
207
|
+
children: [/* @__PURE__ */ _(s, {
|
|
207
208
|
component: r,
|
|
208
209
|
size: "sm",
|
|
209
210
|
"aria-hidden": "true"
|
|
210
|
-
}),
|
|
211
|
+
}), I("code_diff_viewer.reject")]
|
|
211
212
|
}),
|
|
212
|
-
(
|
|
213
|
+
(k || N) && /* @__PURE__ */ v("button", {
|
|
213
214
|
type: "button",
|
|
214
|
-
className:
|
|
215
|
-
onClick:
|
|
216
|
-
disabled:
|
|
217
|
-
children: [/* @__PURE__ */
|
|
218
|
-
component:
|
|
215
|
+
className: g(l.actionButton, l.applyButton, M && l.applying, N && l.applied),
|
|
216
|
+
onClick: k,
|
|
217
|
+
disabled: M || N,
|
|
218
|
+
children: [/* @__PURE__ */ _(s, {
|
|
219
|
+
component: M ? o : n,
|
|
219
220
|
size: "sm",
|
|
220
|
-
className:
|
|
221
|
+
className: g(M && l.spin),
|
|
221
222
|
"aria-hidden": "true"
|
|
222
|
-
}),
|
|
223
|
+
}), I(N ? "code_diff_viewer.applied" : "code_diff_viewer.apply")]
|
|
223
224
|
})
|
|
224
225
|
]
|
|
225
226
|
})]
|
|
226
|
-
}), /* @__PURE__ */
|
|
227
|
-
className:
|
|
227
|
+
}), /* @__PURE__ */ _("div", {
|
|
228
|
+
className: l.body,
|
|
228
229
|
tabIndex: 0,
|
|
229
|
-
children:
|
|
230
|
-
className:
|
|
231
|
-
children:
|
|
232
|
-
}) : /* @__PURE__ */
|
|
233
|
-
className:
|
|
230
|
+
children: U === "unified" ? /* @__PURE__ */ _("div", {
|
|
231
|
+
className: l.unified,
|
|
232
|
+
children: K.map((e, t) => /* @__PURE__ */ _(w, { line: e }, t))
|
|
233
|
+
}) : /* @__PURE__ */ v("div", {
|
|
234
|
+
className: l.split,
|
|
234
235
|
children: [
|
|
235
|
-
/* @__PURE__ */
|
|
236
|
-
className:
|
|
236
|
+
/* @__PURE__ */ _("div", {
|
|
237
|
+
className: l.splitPane,
|
|
237
238
|
tabIndex: 0,
|
|
238
|
-
children:
|
|
239
|
+
children: q.left.map((e, t) => /* @__PURE__ */ _(T, { line: e }, t))
|
|
239
240
|
}),
|
|
240
|
-
/* @__PURE__ */
|
|
241
|
-
className:
|
|
241
|
+
/* @__PURE__ */ _("div", {
|
|
242
|
+
className: l.splitDivider,
|
|
242
243
|
"aria-hidden": "true"
|
|
243
244
|
}),
|
|
244
|
-
/* @__PURE__ */
|
|
245
|
-
className:
|
|
245
|
+
/* @__PURE__ */ _("div", {
|
|
246
|
+
className: l.splitPane,
|
|
246
247
|
tabIndex: 0,
|
|
247
|
-
children:
|
|
248
|
+
children: q.right.map((e, t) => /* @__PURE__ */ _(T, { line: e }, t))
|
|
248
249
|
})
|
|
249
250
|
]
|
|
250
251
|
})
|
|
251
252
|
})]
|
|
252
253
|
});
|
|
253
254
|
});
|
|
254
|
-
|
|
255
|
+
E.displayName = "CodeDiffViewer";
|
|
255
256
|
//#endregion
|
|
256
|
-
export {
|
|
257
|
+
export { E as CodeDiffViewer };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../typography/Text/Text.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/form.cjs"),r=require("../../typography/Text/Text.cjs"),i=require("../../navigation/Link/Link.cjs"),a=require("../../typography/Title/Title.cjs"),o=require("../../typography/Blockquote/Blockquote.cjs"),s=require("../CodeBlock/CodeBlock.cjs"),c=require("./markdown-renderer.module.cjs");let l=require("react");l=e.__toESM(l,1);let u=require("classnames");u=e.__toESM(u,1);let d=require("react/jsx-runtime"),f=require("react-markdown");f=e.__toESM(f,1);let p=require("remark-gfm");p=e.__toESM(p,1);var m=[`xs`,`sm`,`md`,`lg`,`xl`,`2xl`,`3xl`,`4xl`];function h(e,t){let n=m.indexOf(t);return m[Math.max(0,n-(e-1))]}var g=({content:e,baseLevel:l=`2xl`,className:m})=>{let{t:g}=t.useWimTranslation(n.formNs);return(0,d.jsx)(`div`,{className:(0,u.default)(`wim-markdown-renderer`,c.default.root,m),children:(0,d.jsx)(f.default,{remarkPlugins:[p.default],components:{h1:({children:e})=>(0,d.jsx)(a.Title,{tag:`h1`,size:h(1,l),className:c.default.heading,children:e}),h2:({children:e})=>(0,d.jsx)(a.Title,{tag:`h2`,size:h(2,l),className:c.default.heading,children:e}),h3:({children:e})=>(0,d.jsx)(a.Title,{tag:`h3`,size:h(3,l),className:c.default.heading,children:e}),h4:({children:e})=>(0,d.jsx)(a.Title,{tag:`h4`,size:h(4,l),className:c.default.heading,children:e}),p:({children:e})=>(0,d.jsx)(r.Text,{className:c.default.paragraph,children:e}),a:({href:e,children:t})=>(0,d.jsx)(i.Link,{href:e,children:t}),blockquote:({children:e})=>(0,d.jsx)(o.Blockquote,{children:e}),ul:({children:e})=>(0,d.jsx)(`ul`,{className:c.default.list,children:e}),ol:({children:e})=>(0,d.jsx)(`ol`,{className:c.default.list,children:e}),li:({children:e})=>(0,d.jsx)(`li`,{className:c.default.listItem,children:e}),code({className:e,children:t,...n}){let r=/language-(\w+)/.exec(e||``);return r?(0,d.jsx)(s.CodeBlock,{code:String(t).replace(/\n$/,``),language:r[1],className:c.default.codeBlock}):(0,d.jsx)(`code`,{className:c.default.inlineCode,...n,children:t})},table:({children:e})=>(0,d.jsx)(`div`,{className:c.default.tableWrapper,children:(0,d.jsx)(`table`,{className:c.default.table,children:e})}),th:({children:e})=>(0,d.jsx)(`th`,{className:c.default.th,children:e}),td:({children:e})=>(0,d.jsx)(`td`,{className:c.default.td,children:e}),input:({type:e,checked:t,disabled:n})=>e===`checkbox`?(0,d.jsx)(`input`,{type:`checkbox`,checked:t,disabled:n,readOnly:!0,"aria-label":g(t?`markdown.task_done`:`markdown.task_todo`)}):null},children:e})})};g.displayName=`MarkdownRenderer`,exports.MarkdownRenderer=g;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useWimTranslation as e } from "../../../i18n/useWimTranslation.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import o from "
|
|
3
|
+
import { formNs as t } from "../../../i18n/generated/form.js";
|
|
4
|
+
import { Text as n } from "../../typography/Text/Text.js";
|
|
5
|
+
import { Link as r } from "../../navigation/Link/Link.js";
|
|
6
|
+
import { Title as i } from "../../typography/Title/Title.js";
|
|
7
|
+
import { Blockquote as a } from "../../typography/Blockquote/Blockquote.js";
|
|
8
|
+
import { CodeBlock as o } from "../CodeBlock/CodeBlock.js";
|
|
9
|
+
import s from "./markdown-renderer.module.js";
|
|
9
10
|
import "react";
|
|
10
|
-
import
|
|
11
|
-
import { jsx as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
11
|
+
import c from "classnames";
|
|
12
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
13
|
+
import u from "react-markdown";
|
|
14
|
+
import d from "remark-gfm";
|
|
14
15
|
//#region src/components/ai/MarkdownRenderer/MarkdownRenderer.tsx
|
|
15
|
-
var
|
|
16
|
+
var f = [
|
|
16
17
|
"xs",
|
|
17
18
|
"sm",
|
|
18
19
|
"md",
|
|
@@ -22,101 +23,101 @@ var d = [
|
|
|
22
23
|
"3xl",
|
|
23
24
|
"4xl"
|
|
24
25
|
];
|
|
25
|
-
function
|
|
26
|
-
let n =
|
|
27
|
-
return
|
|
26
|
+
function p(e, t) {
|
|
27
|
+
let n = f.indexOf(t);
|
|
28
|
+
return f[Math.max(0, n - (e - 1))];
|
|
28
29
|
}
|
|
29
|
-
var
|
|
30
|
-
let { t:
|
|
31
|
-
return /* @__PURE__ */
|
|
32
|
-
className:
|
|
33
|
-
children: /* @__PURE__ */
|
|
34
|
-
remarkPlugins: [
|
|
30
|
+
var m = ({ content: f, baseLevel: m = "2xl", className: h }) => {
|
|
31
|
+
let { t: g } = e(t);
|
|
32
|
+
return /* @__PURE__ */ l("div", {
|
|
33
|
+
className: c("wim-markdown-renderer", s.root, h),
|
|
34
|
+
children: /* @__PURE__ */ l(u, {
|
|
35
|
+
remarkPlugins: [d],
|
|
35
36
|
components: {
|
|
36
|
-
h1: ({ children: e }) => /* @__PURE__ */
|
|
37
|
+
h1: ({ children: e }) => /* @__PURE__ */ l(i, {
|
|
37
38
|
tag: "h1",
|
|
38
|
-
size:
|
|
39
|
-
className:
|
|
39
|
+
size: p(1, m),
|
|
40
|
+
className: s.heading,
|
|
40
41
|
children: e
|
|
41
42
|
}),
|
|
42
|
-
h2: ({ children: e }) => /* @__PURE__ */
|
|
43
|
+
h2: ({ children: e }) => /* @__PURE__ */ l(i, {
|
|
43
44
|
tag: "h2",
|
|
44
|
-
size:
|
|
45
|
-
className:
|
|
45
|
+
size: p(2, m),
|
|
46
|
+
className: s.heading,
|
|
46
47
|
children: e
|
|
47
48
|
}),
|
|
48
|
-
h3: ({ children: e }) => /* @__PURE__ */
|
|
49
|
+
h3: ({ children: e }) => /* @__PURE__ */ l(i, {
|
|
49
50
|
tag: "h3",
|
|
50
|
-
size:
|
|
51
|
-
className:
|
|
51
|
+
size: p(3, m),
|
|
52
|
+
className: s.heading,
|
|
52
53
|
children: e
|
|
53
54
|
}),
|
|
54
|
-
h4: ({ children: e }) => /* @__PURE__ */
|
|
55
|
+
h4: ({ children: e }) => /* @__PURE__ */ l(i, {
|
|
55
56
|
tag: "h4",
|
|
56
|
-
size:
|
|
57
|
-
className:
|
|
57
|
+
size: p(4, m),
|
|
58
|
+
className: s.heading,
|
|
58
59
|
children: e
|
|
59
60
|
}),
|
|
60
|
-
p: ({ children: e }) => /* @__PURE__ */
|
|
61
|
-
className:
|
|
61
|
+
p: ({ children: e }) => /* @__PURE__ */ l(n, {
|
|
62
|
+
className: s.paragraph,
|
|
62
63
|
children: e
|
|
63
64
|
}),
|
|
64
|
-
a: ({ href: e, children: t }) => /* @__PURE__ */
|
|
65
|
+
a: ({ href: e, children: t }) => /* @__PURE__ */ l(r, {
|
|
65
66
|
href: e,
|
|
66
67
|
children: t
|
|
67
68
|
}),
|
|
68
|
-
blockquote: ({ children: e }) => /* @__PURE__ */
|
|
69
|
-
ul: ({ children: e }) => /* @__PURE__ */
|
|
70
|
-
className:
|
|
69
|
+
blockquote: ({ children: e }) => /* @__PURE__ */ l(a, { children: e }),
|
|
70
|
+
ul: ({ children: e }) => /* @__PURE__ */ l("ul", {
|
|
71
|
+
className: s.list,
|
|
71
72
|
children: e
|
|
72
73
|
}),
|
|
73
|
-
ol: ({ children: e }) => /* @__PURE__ */
|
|
74
|
-
className:
|
|
74
|
+
ol: ({ children: e }) => /* @__PURE__ */ l("ol", {
|
|
75
|
+
className: s.list,
|
|
75
76
|
children: e
|
|
76
77
|
}),
|
|
77
|
-
li: ({ children: e }) => /* @__PURE__ */
|
|
78
|
-
className:
|
|
78
|
+
li: ({ children: e }) => /* @__PURE__ */ l("li", {
|
|
79
|
+
className: s.listItem,
|
|
79
80
|
children: e
|
|
80
81
|
}),
|
|
81
82
|
code({ className: e, children: t, ...n }) {
|
|
82
83
|
let r = /language-(\w+)/.exec(e || "");
|
|
83
|
-
return r ? /* @__PURE__ */
|
|
84
|
+
return r ? /* @__PURE__ */ l(o, {
|
|
84
85
|
code: String(t).replace(/\n$/, ""),
|
|
85
86
|
language: r[1],
|
|
86
|
-
className:
|
|
87
|
-
}) : /* @__PURE__ */
|
|
88
|
-
className:
|
|
87
|
+
className: s.codeBlock
|
|
88
|
+
}) : /* @__PURE__ */ l("code", {
|
|
89
|
+
className: s.inlineCode,
|
|
89
90
|
...n,
|
|
90
91
|
children: t
|
|
91
92
|
});
|
|
92
93
|
},
|
|
93
|
-
table: ({ children: e }) => /* @__PURE__ */
|
|
94
|
-
className:
|
|
95
|
-
children: /* @__PURE__ */
|
|
96
|
-
className:
|
|
94
|
+
table: ({ children: e }) => /* @__PURE__ */ l("div", {
|
|
95
|
+
className: s.tableWrapper,
|
|
96
|
+
children: /* @__PURE__ */ l("table", {
|
|
97
|
+
className: s.table,
|
|
97
98
|
children: e
|
|
98
99
|
})
|
|
99
100
|
}),
|
|
100
|
-
th: ({ children: e }) => /* @__PURE__ */
|
|
101
|
-
className:
|
|
101
|
+
th: ({ children: e }) => /* @__PURE__ */ l("th", {
|
|
102
|
+
className: s.th,
|
|
102
103
|
children: e
|
|
103
104
|
}),
|
|
104
|
-
td: ({ children: e }) => /* @__PURE__ */
|
|
105
|
-
className:
|
|
105
|
+
td: ({ children: e }) => /* @__PURE__ */ l("td", {
|
|
106
|
+
className: s.td,
|
|
106
107
|
children: e
|
|
107
108
|
}),
|
|
108
|
-
input: ({ type: e, checked: t, disabled: n }) => e === "checkbox" ? /* @__PURE__ */
|
|
109
|
+
input: ({ type: e, checked: t, disabled: n }) => e === "checkbox" ? /* @__PURE__ */ l("input", {
|
|
109
110
|
type: "checkbox",
|
|
110
111
|
checked: t,
|
|
111
112
|
disabled: n,
|
|
112
113
|
readOnly: !0,
|
|
113
|
-
"aria-label":
|
|
114
|
+
"aria-label": g(t ? "markdown.task_done" : "markdown.task_todo")
|
|
114
115
|
}) : null
|
|
115
116
|
},
|
|
116
|
-
children:
|
|
117
|
+
children: f
|
|
117
118
|
})
|
|
118
119
|
});
|
|
119
120
|
};
|
|
120
|
-
|
|
121
|
+
m.displayName = "MarkdownRenderer";
|
|
121
122
|
//#endregion
|
|
122
|
-
export {
|
|
123
|
+
export { m as MarkdownRenderer };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../layout/Transition/Transition.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../i18n/generated/common.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../../icon/check.cjs"),a=require("../../../icon/chevron-down.cjs"),o=require("../../media/Icon/Icon.cjs"),s=require("./model-selector.module.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=e=>e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}K`:String(e),f=(e,t=`$`)=>`${t}${e}`,p=c.default.forwardRef(({models:e,value:p,defaultValue:m,onChange:h,size:g=`md`,disabled:_=!1,fullWidth:v=!1,showPricing:y=!0,showContext:b=!0,labels:x,className:S,...C},w)=>{let{t:T}=t.useWimTranslation(n.commonNs),{placeholder:E=T(`modelSelector.placeholder`),contextLabel:D=T(`modelSelector.context`),inputLabel:O=T(`modelSelector.input`),outputLabel:k=T(`modelSelector.output`),perTokensLabel:A=`/1M`,triggerAriaLabel:j=T(`modelSelector.placeholder`)}=x??{},M=p!==void 0,[N,P]=(0,c.useState)(m),F=M?p:N,I=e.find(e=>e.id===F),[L,R]=(0,c.useState)(!1),[z,B]=(0,c.useState)(-1),V=(0,c.useRef)(null),H=(0,c.useRef)(null),U=(0,c.useId)(),W=`${U}-listbox`,G=(0,c.useCallback)(e=>{V.current=e,typeof w==`function`?w(e):w&&(w.current=e)},[w]);(0,c.useEffect)(()=>{if(!L)return;let e=e=>{V.current&&!V.current.contains(e.target)&&R(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[L]);let K=e=>{e.disabled||(M||P(e.id),h?.(e.id,e),R(!1))},q=(t,n)=>{let r=t;for(let t=0;t<e.length;t++){if(!e[r]?.disabled)return r;r=(r+n+e.length)%e.length}return-1},J=t=>{let n=e.findIndex(e=>e.id===F);B(t??(n>=0?n:q(0,1))),R(!0)},Y=t=>{B(n=>{let r=n;for(let n=0;n<e.length&&(r=(r+t+e.length)%e.length,e[r]?.disabled);n++);return r})},X=t=>{if(!_)switch(t.key){case`ArrowDown`:case`ArrowUp`:t.preventDefault(),L?Y(t.key===`ArrowDown`?1:-1):J();break;case`Home`:case`End`:t.preventDefault(),t.key===`Home`?L?B(q(0,1)):J(q(0,1)):L?B(q(e.length-1,-1)):J(q(e.length-1,-1));break;case`Enter`:case` `:if(t.preventDefault(),!L)J();else{let t=e[z];t&&K(t)}break;case`Escape`:L&&(t.preventDefault(),R(!1));break;case`Tab`:R(!1)}};(0,c.useEffect)(()=>{L&&z>=0&&(H.current?.querySelectorAll(`[role="option"]`)?.[z])?.scrollIntoView({block:`nearest`})},[z,L]);let Z=e=>{let t=[];if(b&&e.contextLength&&t.push((0,u.jsxs)(`span`,{className:s.default.meta,children:[D,` `,d(e.contextLength)]},`ctx`)),y&&e.pricing){let{input:n,output:r,currency:i}=e.pricing;n!==void 0&&t.push((0,u.jsxs)(`span`,{className:s.default.meta,children:[O,` `,f(n,i),A]},`in`)),r!==void 0&&t.push((0,u.jsxs)(`span`,{className:s.default.meta,children:[k,` `,f(r,i),A]},`out`))}if(t.length===0)return null;let n=t.flatMap((e,t)=>t===0?[e]:[` `,e]);return(0,u.jsx)(`span`,{className:s.default.metaRow,children:n})};return(0,u.jsxs)(`div`,{ref:G,className:(0,l.default)(`wim-model-selector`,s.default.root,s.default[g],v&&s.default.fullWidth,_&&s.default.disabled,S),...C,children:[(0,u.jsxs)(`button`,{type:`button`,role:`combobox`,className:s.default.trigger,"aria-haspopup":`listbox`,"aria-expanded":L,"aria-controls":L?W:void 0,"aria-activedescendant":L&&z>=0?`${U}-opt-${z}`:void 0,"aria-label":j,disabled:_,onClick:()=>{_||(L?R(!1):J())},onKeyDown:X,onKeyUp:e=>{e.key===` `&&e.preventDefault()},children:[(0,u.jsx)(`span`,{className:s.default.triggerLabel,children:I?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`span`,{className:s.default.triggerName,children:I.name}),` `,I.badge&&(0,u.jsx)(`span`,{className:s.default.badge,children:I.badge})]}):(0,u.jsx)(`span`,{className:s.default.placeholder,children:E})}),(0,u.jsx)(o.Icon,{component:a.default,size:`sm`,className:(0,l.default)(s.default.chevron,L&&s.default.chevronOpen)})]}),(0,u.jsx)(r.Transition,{show:L,preset:`scale`,unmount:!0,className:s.default.dropdownWrapper,children:(0,u.jsx)(`ul`,{ref:H,id:W,role:`listbox`,"aria-label":j,tabIndex:-1,className:s.default.dropdown,onMouseDown:e=>e.preventDefault(),children:e.map((e,t)=>{let n=e.id===F;return(0,u.jsxs)(`li`,{id:`${U}-opt-${t}`,role:`option`,"aria-selected":n,"aria-disabled":e.disabled||void 0,className:(0,l.default)(s.default.option,t===z&&s.default.active,e.disabled&&s.default.optionDisabled),onMouseEnter:()=>B(t),onClick:()=>K(e),children:[(0,u.jsx)(`span`,{className:s.default.check,"aria-hidden":`true`,children:n&&(0,u.jsx)(o.Icon,{component:i.default,size:`sm`})}),(0,u.jsxs)(`span`,{className:s.default.optionBody,children:[(0,u.jsxs)(`span`,{className:s.default.optionHeader,children:[(0,u.jsx)(`span`,{className:s.default.optionName,children:e.name}),` `,e.badge&&(0,u.jsx)(`span`,{className:s.default.badge,children:e.badge})]}),` `,e.description&&(0,u.jsx)(`span`,{className:s.default.description,children:e.description}),` `,Z(e)]})]},e.id)})})})]})});p.displayName=`ModelSelector`,exports.ModelSelector=p;
|