dsh-model-select-plus 0.1.7 → 0.2.1
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 +11 -8
- package/lib/client.cjs +307 -322
- package/package.json +2 -2
- package/src/client.js +412 -354
package/lib/client.cjs
CHANGED
|
@@ -46,103 +46,91 @@ var module = { exports: {} };
|
|
|
46
46
|
var API = "/plugins/dsh-model-select-plus/api";
|
|
47
47
|
var STYLE_TAG = "dsh-model-select-plus/style";
|
|
48
48
|
var FAVS_KEY = "__favorites__";
|
|
49
|
+
var h = import_react.default.createElement;
|
|
49
50
|
var CSS = `
|
|
50
51
|
.mdsl-root, .mdsl-root *, .mdsl-root *::before, .mdsl-root *::after { box-sizing: border-box; }
|
|
51
52
|
.mdsl-root { position: relative; display: inline-flex; align-items: center; min-width: 0; max-width: 100%; }
|
|
52
53
|
.mdsl-backdrop { position: fixed; inset: 0; z-index: 35; }
|
|
53
54
|
|
|
54
|
-
/* Trigger:
|
|
55
|
+
/* Trigger: the composer's 28px chip, same as the sibling permission / plan
|
|
55
56
|
controls, so the row does not jump when this plugin replaces the seat. */
|
|
56
|
-
.mdsl-trigger { display: flex; align-items: center; gap: 4px; min-width: 0; max-width:
|
|
57
|
+
.mdsl-trigger { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 260px; max-width: min(260px, 45cqw); height: 28px; padding: 0 4px 0 8px; border: 0; border-radius: var(--dsw-radius-sm, 8px); background: transparent; color: var(--dsw-alias-label-secondary); font-family: inherit; font-size: 13px; line-height: 20px; font-weight: 400; cursor: pointer; outline: none; }
|
|
57
58
|
.mdsl-trigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
|
|
58
59
|
.mdsl-trigger:focus-visible { box-shadow: 0 0 0 2px var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); }
|
|
59
60
|
.mdsl-trigger:disabled { color: var(--dsw-alias-label-dimmed); cursor: default; }
|
|
60
|
-
.mdsl-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
61
|
-
/* The
|
|
62
|
-
|
|
61
|
+
.mdsl-label { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
62
|
+
/* The provider is context, the model is the subject: on overflow the level
|
|
63
|
+
collapses first, then the provider, and the model name stays whole. */
|
|
64
|
+
.mdsl-trigger-provider { flex-shrink: 100; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-tertiary); }
|
|
63
65
|
.mdsl-effort { flex-shrink: 1000; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-caption); }
|
|
64
|
-
.mdsl-chevron { flex: none; display: inline-flex; color: var(--dsw-alias-label-caption);
|
|
66
|
+
.mdsl-chevron { flex: none; display: inline-flex; color: var(--dsw-alias-label-caption); }
|
|
65
67
|
.mdsl-chevron-open { transform: rotate(180deg); }
|
|
66
68
|
|
|
67
|
-
/* Card: the shipped menu material
|
|
68
|
-
|
|
69
|
-
.mdsl-menu { position: fixed; z-index: 40; display: flex; flex-direction: column; width:
|
|
69
|
+
/* Card: the shipped menu material. 420px is the native menu ceiling; the
|
|
70
|
+
extra width is what keeps names whole once every row carries its levels. */
|
|
71
|
+
.mdsl-menu { position: fixed; z-index: 40; display: flex; flex-direction: column; width: 420px; max-width: calc(100vw - 24px); max-height: min(440px, calc(100vh - 120px)); padding: 4px; background: var(--dsw-menu-surface-fill, var(--dsw-alias-bg-overlay)); -webkit-backdrop-filter: var(--dsw-menu-backdrop-filter, blur(20px) saturate(140%)); backdrop-filter: var(--dsw-menu-backdrop-filter, blur(20px) saturate(140%)); border: 0; border-radius: var(--dsw-radius-lg, 16px); --dsw-elevation-stroke-color: var(--dsw-alias-border-l1); box-shadow: var(--dsw-elevation-prominent, 0 10px 36px rgba(0,0,0,.14)); color: var(--dsw-alias-label-primary); font-family: inherit; font-size: 13px; --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2); --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2); overflow: hidden; animation: mdsl-in .16s cubic-bezier(.22, 1, .36, 1); transform-origin: bottom right; }
|
|
70
72
|
body[data-ds-dark-theme] .mdsl-menu { --dsw-elevation-stroke-color: var(--dsw-alias-border-l3); }
|
|
71
73
|
@keyframes mdsl-in { from { opacity: 0; transform: translateY(4px) scale(.99); } to { opacity: 1; transform: none; } }
|
|
72
74
|
@media (prefers-reduced-motion: reduce) { .mdsl-menu { animation: none; } }
|
|
73
75
|
|
|
74
|
-
/*
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
.mdsl-
|
|
78
|
-
.mdsl-search-
|
|
79
|
-
.mdsl-search-icon {
|
|
80
|
-
.mdsl-search { width: 100%; height:
|
|
81
|
-
.mdsl-search::placeholder { color: var(--dsw-alias-label-
|
|
82
|
-
.mdsl-search
|
|
83
|
-
.mdsl-search-clear { position: absolute; right: 5px; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; }
|
|
76
|
+
/* One search line with a 0.5px rule. No jump rail: 18 models are cheap to
|
|
77
|
+
scroll, and the second navigation layer only repeated the headings. */
|
|
78
|
+
.mdsl-search-wrap { position: relative; flex: none; display: flex; align-items: center; height: 34px; border-bottom: 0.5px solid var(--dsw-alias-border-l1); }
|
|
79
|
+
.mdsl-search-wrap:focus-within { border-bottom-color: var(--dsw-alias-state-business-primary); }
|
|
80
|
+
.mdsl-search-icon { position: absolute; left: 8px; display: flex; color: var(--dsw-alias-label-tertiary); pointer-events: none; }
|
|
81
|
+
.mdsl-search-wrap:focus-within .mdsl-search-icon { color: var(--dsw-alias-label-primary); }
|
|
82
|
+
.mdsl-search { width: 100%; height: 100%; padding: 0 28px 0 30px; border: 0; border-radius: 0; background: transparent; color: var(--dsw-alias-label-primary); font-family: inherit; font-size: 13px; line-height: 20px; outline: none; }
|
|
83
|
+
.mdsl-search::placeholder { color: var(--dsw-alias-label-caption); }
|
|
84
|
+
.mdsl-search-clear { position: absolute; right: 4px; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; }
|
|
84
85
|
.mdsl-search-clear:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
|
|
85
86
|
.mdsl-search-clear:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-alias-state-business-primary); }
|
|
86
87
|
|
|
87
|
-
/* Provider jump rail: single row, horizontal scroll. Counts live on the
|
|
88
|
-
sticky group headings only \u2014 the old rail repeated them in parentheses. */
|
|
89
|
-
.mdsl-tags { display: flex; align-items: center; gap: 6px; overflow-x: auto; overflow-y: hidden; padding: 1px 0; scrollbar-width: none; -ms-overflow-style: none; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent); }
|
|
90
|
-
.mdsl-tags::-webkit-scrollbar { display: none; }
|
|
91
|
-
.mdsl-tag { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border: 1px solid var(--dsw-alias-border-l1); border-radius: 999px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-secondary); font-family: inherit; font-size: 11px; line-height: 16px; cursor: pointer; user-select: none; transition: border-color .12s ease, color .12s ease, background .12s ease; }
|
|
92
|
-
.mdsl-tag:hover { border-color: var(--dsw-alias-border-l2); background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
|
|
93
|
-
.mdsl-tag:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-alias-state-business-primary); }
|
|
94
|
-
.mdsl-tag-current { border-color: var(--dsw-alias-brand-primary); background: var(--dsw-alias-interactive-bg-active); color: var(--dsw-alias-label-primary); font-weight: 500; }
|
|
95
|
-
.mdsl-tag-icon { display: inline-flex; margin-left: -2px; color: var(--dsw-alias-brand-primary); }
|
|
96
|
-
.mdsl-tag-name { white-space: nowrap; }
|
|
97
|
-
|
|
98
88
|
.mdsl-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 2px 2px; scrollbar-width: thin; scrollbar-color: var(--dsh-scrollbar-thumb, var(--dsw-alias-scrollbar-bg-l2)) transparent; }
|
|
99
89
|
.mdsl-body::-webkit-scrollbar { width: 8px; }
|
|
100
90
|
.mdsl-body::-webkit-scrollbar-thumb { background: var(--dsh-scrollbar-thumb, var(--dsw-alias-scrollbar-bg-l2)); border: 2px solid transparent; border-radius: 999px; background-clip: content-box; }
|
|
101
91
|
.mdsl-body::-webkit-scrollbar-thumb:hover { background: var(--dsh-scrollbar-thumb-hover, var(--dsw-alias-scrollbar-hover-l2)); border: 2px solid transparent; background-clip: content-box; }
|
|
102
92
|
|
|
103
|
-
/*
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
.mdsl-group {
|
|
107
|
-
.mdsl-group + .mdsl-group { margin-top:
|
|
108
|
-
.mdsl-group-title { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap:
|
|
109
|
-
.mdsl-group-title
|
|
110
|
-
.mdsl-group-
|
|
111
|
-
.mdsl-group-chevron { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 10px; height: 10px; color: currentColor; transform: rotate(90deg); transition: transform .14s ease; }
|
|
112
|
-
.mdsl-group-collapsed .mdsl-group-chevron { transform: none; }
|
|
113
|
-
.mdsl-group-icon { flex: none; display: inline-flex; color: var(--dsw-alias-brand-primary); }
|
|
93
|
+
/* Sections: 10px of air between groups; a 22px heading that paints its
|
|
94
|
+
header fill only while stuck to the top, so static groups stay flat
|
|
95
|
+
instead of drawing a grey band each. */
|
|
96
|
+
.mdsl-group { position: relative; }
|
|
97
|
+
.mdsl-group + .mdsl-group { margin-top: 10px; }
|
|
98
|
+
.mdsl-group-title { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 4px; padding: 4px 8px 2px; background: transparent; color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 16px; font-weight: 500; }
|
|
99
|
+
.mdsl-group-title[data-stuck] { background: var(--dsw-alias-menu-group-header-fill, var(--dsw-alias-bg-overlay)); box-shadow: 0 0.5px 0 var(--dsw-alias-border-l1); }
|
|
100
|
+
.mdsl-group-icon { display: inline-flex; color: var(--dsw-alias-brand-primary); }
|
|
114
101
|
.mdsl-group-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
115
|
-
.mdsl-group-count { flex: none; margin-left: auto; color: var(--dsw-alias-label-caption); font-variant-numeric: tabular-nums; }
|
|
116
102
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
.mdsl-
|
|
103
|
+
/* Row: 34px, the native menu row height. Selection is a 6% fill plus the
|
|
104
|
+
trailing check; the 10% block read as a disabled row. */
|
|
105
|
+
.mdsl-item { border-radius: var(--dsw-radius-md, 12px); }
|
|
106
|
+
.mdsl-item:hover, .mdsl-item-current { background: var(--dsw-alias-interactive-bg-hover); }
|
|
107
|
+
.mdsl-row { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 8px; border-radius: var(--dsw-radius-md, 12px); cursor: pointer; }
|
|
120
108
|
.mdsl-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--dsw-alias-state-business-primary); }
|
|
121
|
-
.mdsl-
|
|
109
|
+
.mdsl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-primary); font-size: 13px; line-height: 20px; }
|
|
110
|
+
.mdsl-item-current .mdsl-name { font-weight: 500; }
|
|
111
|
+
.mdsl-prov { flex: none; color: var(--dsw-alias-label-caption); font-size: 11px; line-height: 16px; }
|
|
112
|
+
.mdsl-check { flex: none; display: inline-flex; color: var(--dsw-alias-label-primary); }
|
|
113
|
+
.mdsl-star { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--dsw-alias-label-tertiary); opacity: 0; cursor: pointer; }
|
|
114
|
+
.mdsl-item:hover .mdsl-star, .mdsl-star-on, .mdsl-star:focus-visible { opacity: 1; }
|
|
122
115
|
.mdsl-star:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
|
|
123
116
|
.mdsl-star:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-alias-state-business-primary); }
|
|
124
117
|
.mdsl-star-on { color: var(--dsw-alias-brand-primary); }
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
.mdsl-
|
|
130
|
-
.mdsl-
|
|
131
|
-
.mdsl-chip {
|
|
132
|
-
.mdsl-chip:hover { border-color: var(--dsw-alias-border-l2); color: var(--dsw-alias-label-primary); }
|
|
118
|
+
|
|
119
|
+
/* Effort lives on the row: one click commits model + level. The provider
|
|
120
|
+
default is the weight-only chip; the current row's pinned level gets a
|
|
121
|
+
fill as well. Only the description still expands under the current row. */
|
|
122
|
+
.mdsl-chips { display: flex; align-items: center; gap: 2px; flex: none; }
|
|
123
|
+
.mdsl-chip { height: 20px; padding: 0 5px; border: 0; border-radius: 4px; background: transparent; color: var(--dsw-alias-label-tertiary); font-family: inherit; font-size: 11px; line-height: 20px; cursor: pointer; }
|
|
124
|
+
.mdsl-chip:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
|
|
133
125
|
.mdsl-chip:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-alias-state-business-primary); }
|
|
134
|
-
.mdsl-chip-
|
|
126
|
+
.mdsl-chip-eff { color: var(--dsw-alias-label-secondary); font-weight: 500; }
|
|
127
|
+
.mdsl-chip-on { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); font-weight: 500; }
|
|
135
128
|
|
|
136
|
-
.mdsl-
|
|
137
|
-
.mdsl-
|
|
138
|
-
.mdsl-error { margin: 4px 2px; padding: 6px 8px; border-radius: var(--dsw-radius-sm, 8px); background: var(--dsw-alias-interactive-bg-hover-danger); color: var(--dsw-alias-state-error-primary); font-size: 11px; line-height: 16px; }
|
|
129
|
+
.mdsl-sub { padding: 2px 8px 8px; }
|
|
130
|
+
.mdsl-desc { color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 16px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
|
139
131
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.mdsl-footer { flex: none; display: flex; align-items: center; gap: 6px; margin-top: 2px; padding: 5px 6px 3px; border-top: 0.5px solid var(--dsw-alias-border-l2); color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 16px; }
|
|
143
|
-
.mdsl-footer-dot { flex: none; width: 5px; height: 5px; border-radius: 50%; background: var(--dsw-alias-brand-primary); }
|
|
144
|
-
.mdsl-footer-current { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-secondary); }
|
|
145
|
-
.mdsl-footer-hint { flex: none; color: var(--dsw-alias-label-caption); font-variant-numeric: tabular-nums; }
|
|
132
|
+
.mdsl-empty { padding: 16px 8px; text-align: center; color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 18px; }
|
|
133
|
+
.mdsl-error { margin: 4px 2px; padding: 6px 8px; border-radius: 8px; background: var(--dsw-alias-interactive-bg-hover-danger); color: var(--dsw-alias-state-error-primary); font-size: 11px; line-height: 16px; }
|
|
146
134
|
`;
|
|
147
135
|
function injectStyle() {
|
|
148
136
|
if (typeof document === "undefined") return () => {
|
|
@@ -157,57 +145,50 @@ var module = { exports: {} };
|
|
|
157
145
|
tag.remove();
|
|
158
146
|
};
|
|
159
147
|
}
|
|
160
|
-
var star = (filled) =>
|
|
148
|
+
var star = (filled) => h(
|
|
161
149
|
"svg",
|
|
162
150
|
{ width: 14, height: 14, viewBox: "0 0 24 24", fill: filled ? "currentColor" : "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" },
|
|
163
|
-
|
|
151
|
+
h("path", { d: "M12 2.6l2.86 5.8 6.4.94-4.63 4.5 1.1 6.37L12 17.02 6.27 20.2l1.1-6.37-4.63-4.5 6.4-.94L12 2.6z", stroke: "currentColor", strokeWidth: 1.5, strokeLinejoin: "round" })
|
|
164
152
|
);
|
|
165
|
-
var
|
|
153
|
+
var check = () => h(
|
|
166
154
|
"svg",
|
|
167
|
-
{ width:
|
|
168
|
-
|
|
155
|
+
{ width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" },
|
|
156
|
+
h("path", { d: "M2.8 7.4l2.6 2.6 5.8-6.4", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" })
|
|
169
157
|
);
|
|
170
|
-
var chevronDown = () =>
|
|
158
|
+
var chevronDown = () => h(
|
|
171
159
|
"svg",
|
|
172
160
|
{ width: 12, height: 12, viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" },
|
|
173
|
-
|
|
161
|
+
h("path", { d: "M3 4.75L6 7.75l3-3", stroke: "currentColor", strokeWidth: 1.3, strokeLinecap: "round", strokeLinejoin: "round" })
|
|
174
162
|
);
|
|
175
|
-
var
|
|
176
|
-
"svg",
|
|
177
|
-
{ width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" },
|
|
178
|
-
import_react.default.createElement("path", { d: "M2.8 7.4l2.6 2.6 5.8-6.4", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" })
|
|
179
|
-
);
|
|
180
|
-
var closeIcon = () => import_react.default.createElement(
|
|
163
|
+
var closeIcon = () => h(
|
|
181
164
|
"svg",
|
|
182
165
|
{ width: 12, height: 12, viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" },
|
|
183
|
-
|
|
166
|
+
h("path", { d: "M3 3l6 6M9 3L3 9", stroke: "currentColor", strokeWidth: 1.4, strokeLinecap: "round" })
|
|
184
167
|
);
|
|
185
|
-
var searchIcon = () =>
|
|
168
|
+
var searchIcon = () => h(
|
|
186
169
|
"span",
|
|
187
170
|
{ className: "mdsl-search-icon" },
|
|
188
|
-
|
|
171
|
+
h(
|
|
189
172
|
"svg",
|
|
190
173
|
{ width: 14, height: 14, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" },
|
|
191
|
-
|
|
192
|
-
|
|
174
|
+
h("circle", { cx: 7, cy: 7, r: 5, stroke: "currentColor", strokeWidth: 1.4 }),
|
|
175
|
+
h("line", { x1: 10.8, y1: 10.8, x2: 14, y2: 14, stroke: "currentColor", strokeWidth: 1.4, strokeLinecap: "round" })
|
|
193
176
|
)
|
|
194
177
|
);
|
|
195
178
|
function ModelSelectLite(props) {
|
|
196
179
|
const sessionId = props.sessionId;
|
|
197
180
|
const locked = props.locked === true;
|
|
198
|
-
const bodyRef = import_react.default.useRef(null);
|
|
199
181
|
const triggerRef = import_react.default.useRef(null);
|
|
182
|
+
const bodyRef = import_react.default.useRef(null);
|
|
200
183
|
const searchRef = import_react.default.useRef(null);
|
|
201
|
-
const tagRailRef = import_react.default.useRef(null);
|
|
202
184
|
const [placement, setPlacement] = import_react.default.useState(null);
|
|
203
185
|
const [open, setOpen] = import_react.default.useState(false);
|
|
204
186
|
const [data, setData] = import_react.default.useState({ status: "idle", groups: [], failures: [], current: null, error: null });
|
|
205
187
|
const [query, setQuery] = import_react.default.useState("");
|
|
206
188
|
const [busy, setBusy] = import_react.default.useState(false);
|
|
207
189
|
const [, bump] = import_react.default.useState(0);
|
|
208
|
-
const [userToggled, setUserToggled] = import_react.default.useState(() => /* @__PURE__ */ new Map());
|
|
209
190
|
const load = () => {
|
|
210
|
-
setData((d) =>
|
|
191
|
+
setData((d) => d.groups.length > 0 ? { ...d, error: null } : { ...d, status: "loading", error: null });
|
|
211
192
|
const url = `${API}/catalog?sessionId=${encodeURIComponent(sessionId)}`;
|
|
212
193
|
fetch(url).then((res) => res.json()).then((res) => {
|
|
213
194
|
if (res === null || res && res.error !== void 0) {
|
|
@@ -220,44 +201,42 @@ var module = { exports: {} };
|
|
|
220
201
|
});
|
|
221
202
|
};
|
|
222
203
|
import_react.default.useEffect(() => {
|
|
223
|
-
if (sessionId !== void 0)
|
|
224
|
-
setUserToggled(/* @__PURE__ */ new Map());
|
|
225
|
-
load();
|
|
226
|
-
}
|
|
204
|
+
if (sessionId !== void 0) load();
|
|
227
205
|
}, [sessionId]);
|
|
206
|
+
const focusedForOpen = import_react.default.useRef(false);
|
|
228
207
|
import_react.default.useEffect(() => {
|
|
229
|
-
if (!open
|
|
208
|
+
if (!open) {
|
|
209
|
+
focusedForOpen.current = false;
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (placement === null || focusedForOpen.current) return;
|
|
213
|
+
focusedForOpen.current = true;
|
|
230
214
|
const el = searchRef.current;
|
|
231
215
|
if (el) el.focus({ preventScroll: true });
|
|
232
216
|
}, [open, placement]);
|
|
233
|
-
import_react.default.useEffect(() => {
|
|
234
|
-
if (!open) return;
|
|
235
|
-
const rail = tagRailRef.current;
|
|
236
|
-
if (!rail) return;
|
|
237
|
-
const current2 = rail.querySelector('[data-current="true"]');
|
|
238
|
-
if (!current2) return;
|
|
239
|
-
const left = current2.offsetLeft - (rail.clientWidth - current2.offsetWidth) / 2;
|
|
240
|
-
rail.scrollTo({ left: Math.max(0, left), behavior: "smooth" });
|
|
241
|
-
}, [open, data.current, data.status]);
|
|
242
217
|
const placeMenu = () => {
|
|
243
218
|
const trigger = triggerRef.current;
|
|
244
219
|
if (!trigger) return;
|
|
245
220
|
const rect = trigger.getBoundingClientRect();
|
|
246
221
|
const margin = 12;
|
|
247
222
|
const gap = 6;
|
|
248
|
-
const width = Math.min(
|
|
223
|
+
const width = Math.min(420, window.innerWidth - margin * 2);
|
|
249
224
|
const spaceAbove = rect.top - gap - margin;
|
|
250
225
|
const spaceBelow = window.innerHeight - rect.bottom - gap - margin;
|
|
251
226
|
const side = spaceAbove >= spaceBelow ? "top" : "bottom";
|
|
252
|
-
const maxHeight = Math.max(
|
|
227
|
+
const maxHeight = Math.max(180, Math.min(440, side === "top" ? spaceAbove : spaceBelow));
|
|
253
228
|
const left = Math.min(Math.max(margin, rect.right - width), window.innerWidth - width - margin);
|
|
254
|
-
setPlacement({
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
229
|
+
setPlacement((prev) => {
|
|
230
|
+
const next = {
|
|
231
|
+
side,
|
|
232
|
+
maxHeight,
|
|
233
|
+
width,
|
|
234
|
+
left,
|
|
235
|
+
bottom: window.innerHeight - rect.top + gap,
|
|
236
|
+
top: rect.bottom + gap
|
|
237
|
+
};
|
|
238
|
+
if (prev !== null && prev.side === next.side && prev.maxHeight === next.maxHeight && prev.width === next.width && prev.left === next.left && prev.bottom === next.bottom && prev.top === next.top) return prev;
|
|
239
|
+
return next;
|
|
261
240
|
});
|
|
262
241
|
};
|
|
263
242
|
import_react.default.useLayoutEffect(() => {
|
|
@@ -265,7 +244,11 @@ var module = { exports: {} };
|
|
|
265
244
|
}, [open]);
|
|
266
245
|
import_react.default.useEffect(() => {
|
|
267
246
|
if (!open) return;
|
|
268
|
-
const reposition = () =>
|
|
247
|
+
const reposition = (ev) => {
|
|
248
|
+
const body = bodyRef.current;
|
|
249
|
+
if (ev && ev.target instanceof Node && body !== null && body.contains(ev.target)) return;
|
|
250
|
+
placeMenu();
|
|
251
|
+
};
|
|
269
252
|
window.addEventListener("resize", reposition);
|
|
270
253
|
window.addEventListener("scroll", reposition, true);
|
|
271
254
|
return () => {
|
|
@@ -273,6 +256,53 @@ var module = { exports: {} };
|
|
|
273
256
|
window.removeEventListener("scroll", reposition, true);
|
|
274
257
|
};
|
|
275
258
|
}, [open]);
|
|
259
|
+
import_react.default.useEffect(() => {
|
|
260
|
+
if (!open) return;
|
|
261
|
+
const body = bodyRef.current;
|
|
262
|
+
if (!body) return;
|
|
263
|
+
let raf = 0;
|
|
264
|
+
const sync = () => {
|
|
265
|
+
raf = 0;
|
|
266
|
+
const top = body.getBoundingClientRect().top;
|
|
267
|
+
const heads = body.querySelectorAll(".mdsl-group-title");
|
|
268
|
+
for (const head of heads) {
|
|
269
|
+
if (head.getBoundingClientRect().top <= top + 1) head.setAttribute("data-stuck", "");
|
|
270
|
+
else head.removeAttribute("data-stuck");
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
const schedule = () => {
|
|
274
|
+
if (!raf) raf = requestAnimationFrame(sync);
|
|
275
|
+
};
|
|
276
|
+
body.addEventListener("scroll", schedule, { passive: true });
|
|
277
|
+
window.addEventListener("resize", schedule);
|
|
278
|
+
schedule();
|
|
279
|
+
return () => {
|
|
280
|
+
body.removeEventListener("scroll", schedule);
|
|
281
|
+
window.removeEventListener("resize", schedule);
|
|
282
|
+
if (raf) cancelAnimationFrame(raf);
|
|
283
|
+
};
|
|
284
|
+
}, [open, placement, data.status, data.current, query]);
|
|
285
|
+
const locatedForOpen = import_react.default.useRef(false);
|
|
286
|
+
import_react.default.useLayoutEffect(() => {
|
|
287
|
+
if (!open) {
|
|
288
|
+
locatedForOpen.current = false;
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (locatedForOpen.current || placement === null) return;
|
|
292
|
+
if (data.status !== "ready" || query !== "") return;
|
|
293
|
+
const body = bodyRef.current;
|
|
294
|
+
if (!body) return;
|
|
295
|
+
const item = body.querySelector('[data-current="true"]');
|
|
296
|
+
if (item === null) {
|
|
297
|
+
locatedForOpen.current = true;
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const bodyRect = body.getBoundingClientRect();
|
|
301
|
+
const itemRect = item.getBoundingClientRect();
|
|
302
|
+
const delta = itemRect.top - bodyRect.top - (body.clientHeight - itemRect.height) / 2;
|
|
303
|
+
body.scrollTop = Math.max(0, body.scrollTop + delta);
|
|
304
|
+
locatedForOpen.current = true;
|
|
305
|
+
}, [open, placement, data.status, query]);
|
|
276
306
|
const focusTrigger = () => {
|
|
277
307
|
const el = triggerRef.current;
|
|
278
308
|
if (el) el.focus({ preventScroll: true });
|
|
@@ -287,7 +317,7 @@ var module = { exports: {} };
|
|
|
287
317
|
setPlacement(null);
|
|
288
318
|
focusTrigger();
|
|
289
319
|
};
|
|
290
|
-
const selectSelection = (sel) => {
|
|
320
|
+
const selectSelection = (sel, keepOpen) => {
|
|
291
321
|
if (busy) return;
|
|
292
322
|
setBusy(true);
|
|
293
323
|
fetch(`${API}/select`, {
|
|
@@ -302,8 +332,8 @@ var module = { exports: {} };
|
|
|
302
332
|
}).then((res) => res.json()).then((res) => {
|
|
303
333
|
setBusy(false);
|
|
304
334
|
if (res && res.ok === true) {
|
|
305
|
-
setData((d) => ({ ...d, current: res.selected, error: null }));
|
|
306
|
-
|
|
335
|
+
setData((d) => ({ ...d, current: res.selected || null, error: null }));
|
|
336
|
+
if (keepOpen) return;
|
|
307
337
|
closeMenu();
|
|
308
338
|
} else {
|
|
309
339
|
setData((d) => ({ ...d, error: res && res.message || "\u9009\u62E9\u5931\u8D25" }));
|
|
@@ -313,178 +343,162 @@ var module = { exports: {} };
|
|
|
313
343
|
setData((d) => ({ ...d, error: String(err && err.message || err) }));
|
|
314
344
|
});
|
|
315
345
|
};
|
|
316
|
-
const toggleFav = (
|
|
317
|
-
|
|
318
|
-
const key = `${g}/${m}`;
|
|
346
|
+
const toggleFav = (gid, mid) => {
|
|
347
|
+
const key = `${gid}/${mid}`;
|
|
319
348
|
const next = new Set(favorites);
|
|
320
349
|
if (next.has(key)) next.delete(key);
|
|
321
350
|
else next.add(key);
|
|
322
351
|
favorites = next;
|
|
323
352
|
bump((x) => x + 1);
|
|
324
353
|
};
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const cur = data.current;
|
|
329
|
-
const isCurrentGroup = gid === FAVS_KEY ? cur !== null && favorites.has(cur.provider + "/" + cur.model) : cur !== null && cur.provider === gid;
|
|
330
|
-
return !isCurrentGroup;
|
|
331
|
-
};
|
|
332
|
-
const toggleCollapse = (gid) => {
|
|
333
|
-
const nextState = !isGroupCollapsed(gid);
|
|
334
|
-
setUserToggled((prev) => {
|
|
335
|
-
const next = new Map(prev);
|
|
336
|
-
next.set(gid, nextState);
|
|
337
|
-
return next;
|
|
338
|
-
});
|
|
354
|
+
const choose = (g, m) => {
|
|
355
|
+
const effort = m.reasoning ? m.reasoning.defaultEffort : void 0;
|
|
356
|
+
selectSelection({ provider: g.id, model: m.id, ...effort === void 0 ? {} : { reasoningEffort: effort } }, false);
|
|
339
357
|
};
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const next = /* @__PURE__ */ new Map();
|
|
344
|
-
if (data.groups) {
|
|
345
|
-
for (const g of data.groups) next.set(g.id, true);
|
|
346
|
-
}
|
|
347
|
-
next.set(FAVS_KEY, true);
|
|
348
|
-
next.set(gid, false);
|
|
349
|
-
return next;
|
|
350
|
-
});
|
|
351
|
-
setTimeout(() => {
|
|
352
|
-
if (!bodyRef.current) return;
|
|
353
|
-
const el = bodyRef.current.querySelector('[data-group-id="' + gid + '"]');
|
|
354
|
-
if (el) {
|
|
355
|
-
const bodyRect = bodyRef.current.getBoundingClientRect();
|
|
356
|
-
const elRect = el.getBoundingClientRect();
|
|
357
|
-
const targetScrollTop = bodyRef.current.scrollTop + (elRect.top - bodyRect.top);
|
|
358
|
-
bodyRef.current.scrollTo({ top: Math.max(0, targetScrollTop - 2), behavior: "smooth" });
|
|
359
|
-
}
|
|
360
|
-
}, 40);
|
|
358
|
+
const chooseEffort = (g, m, effort) => {
|
|
359
|
+
const sameModel = current !== null && current !== void 0 && current.provider === g.id && current.model === m.id;
|
|
360
|
+
selectSelection({ provider: g.id, model: m.id, ...effort === void 0 ? {} : { reasoningEffort: effort } }, sameModel);
|
|
361
361
|
};
|
|
362
362
|
const current = data.current;
|
|
363
363
|
const curGroup = current ? data.groups.find((g) => g.id === current.provider) : void 0;
|
|
364
364
|
const curModel = curGroup ? curGroup.models.find((mm) => mm.id === current.model) : void 0;
|
|
365
365
|
const providerName = curGroup ? curGroup.name : current ? current.provider : "";
|
|
366
|
-
const modelName = curModel && curModel.name || (current ? current.model : "
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}
|
|
366
|
+
const modelName = curModel && curModel.name || (current ? current.model : "");
|
|
367
|
+
const pinnedEffort = current ? current.reasoningEffort : void 0;
|
|
368
|
+
let effortLabel;
|
|
369
|
+
if (curModel && curModel.reasoning) {
|
|
370
|
+
const shown = pinnedEffort !== void 0 ? pinnedEffort : curModel.reasoning.defaultEffort;
|
|
371
|
+
if (shown !== void 0) {
|
|
372
|
+
const hit = (curModel.reasoning.efforts || []).find((e) => e.id === shown);
|
|
373
|
+
effortLabel = hit ? hit.name : shown;
|
|
374
|
+
} else {
|
|
375
|
+
effortLabel = "\u9ED8\u8BA4";
|
|
377
376
|
}
|
|
378
377
|
}
|
|
379
378
|
const q = query.trim().toLowerCase();
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
const
|
|
383
|
-
const
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
if (g.models && g.models.length > 0) {
|
|
392
|
-
const isCurrent = current !== null && current.provider === g.id;
|
|
393
|
-
tagList.push({ id: g.id, name: g.name, isCurrent });
|
|
394
|
-
}
|
|
379
|
+
const matches = (g, m) => q === "" || (m.name + " " + (m.description || "") + " " + g.name).toLowerCase().includes(q);
|
|
380
|
+
let total = 0;
|
|
381
|
+
const favEntries = [];
|
|
382
|
+
const filteredGroups = [];
|
|
383
|
+
for (const g of data.groups || []) {
|
|
384
|
+
const models = [];
|
|
385
|
+
for (const m of g.models || []) {
|
|
386
|
+
total += 1;
|
|
387
|
+
if (!matches(g, m)) continue;
|
|
388
|
+
if (favorites.has(`${g.id}/${m.id}`)) favEntries.push({ g, m });
|
|
389
|
+
else models.push(m);
|
|
395
390
|
}
|
|
391
|
+
if (models.length > 0) filteredGroups.push({ id: g.id, name: g.name, models });
|
|
396
392
|
}
|
|
397
|
-
const
|
|
393
|
+
const noMatch = data.status === "ready" && q !== "" && filteredGroups.length === 0 && favEntries.length === 0;
|
|
394
|
+
const isCurrentModel = (g, m) => current !== null && current !== void 0 && current.provider === g.id && current.model === m.id;
|
|
395
|
+
const heading = (label, icon) => h(
|
|
398
396
|
"div",
|
|
399
|
-
{
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
tabIndex: 0,
|
|
403
|
-
"aria-expanded": isCollapsed ? false : true,
|
|
404
|
-
title: (isCollapsed ? "\u5C55\u5F00\uFF1A" : "\u6298\u53E0\uFF1A") + name2,
|
|
405
|
-
onClick: interactive ? () => toggleCollapse(gid) : void 0,
|
|
406
|
-
onKeyDown: interactive ? (ev) => {
|
|
407
|
-
if (ev.key === "Enter" || ev.key === " ") {
|
|
408
|
-
ev.preventDefault();
|
|
409
|
-
toggleCollapse(gid);
|
|
410
|
-
}
|
|
411
|
-
} : void 0
|
|
412
|
-
},
|
|
413
|
-
import_react.default.createElement("span", { className: "mdsl-group-chevron" }, chevron()),
|
|
414
|
-
icon ? import_react.default.createElement("span", { className: "mdsl-group-icon" }, icon) : null,
|
|
415
|
-
import_react.default.createElement("span", { className: "mdsl-group-name" }, name2),
|
|
416
|
-
import_react.default.createElement("span", { className: "mdsl-group-count" }, count)
|
|
397
|
+
{ className: "mdsl-group-title" },
|
|
398
|
+
icon ? h("span", { className: "mdsl-group-icon" }, icon) : null,
|
|
399
|
+
h("span", { className: "mdsl-group-name" }, label)
|
|
417
400
|
);
|
|
418
|
-
const renderRow = (
|
|
419
|
-
const
|
|
420
|
-
const
|
|
421
|
-
const
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
for (const e of c.m.reasoning.efforts) {
|
|
429
|
-
chips.push(import_react.default.createElement("button", { key: e.id, type: "button", className: "mdsl-chip" + (effEff === e.id ? " mdsl-chip-on" : ""), "aria-pressed": effEff === e.id, title: e.description || e.name, onClick: (ev) => {
|
|
430
|
-
ev.stopPropagation();
|
|
431
|
-
selectSelection({ provider: c.g.id, model: c.m.id, reasoningEffort: e.id });
|
|
432
|
-
} }, e.name));
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
const selectRow = () => selectSelection({ provider: c.g.id, model: c.m.id, ...hasEfforts && c.m.reasoning.defaultEffort !== void 0 ? { reasoningEffort: c.m.reasoning.defaultEffort } : {} });
|
|
436
|
-
return import_react.default.createElement(
|
|
401
|
+
const renderRow = (g, m, showProvider) => {
|
|
402
|
+
const selected = isCurrentModel(g, m);
|
|
403
|
+
const fav = favorites.has(`${g.id}/${m.id}`);
|
|
404
|
+
const hasEfforts = !!(m.reasoning && m.reasoning.efforts && m.reasoning.efforts.length);
|
|
405
|
+
const desc = typeof m.description === "string" && m.description !== "" ? m.description : void 0;
|
|
406
|
+
const rowEffort = selected ? pinnedEffort : m.reasoning ? m.reasoning.defaultEffort : void 0;
|
|
407
|
+
const stop = (ev) => {
|
|
408
|
+
if (ev.key === "Enter" || ev.key === " ") ev.stopPropagation();
|
|
409
|
+
};
|
|
410
|
+
const row = h(
|
|
437
411
|
"div",
|
|
438
412
|
{
|
|
439
|
-
|
|
440
|
-
className: "mdsl-row" + (c.selected ? " mdsl-row-current" : ""),
|
|
413
|
+
className: "mdsl-row",
|
|
441
414
|
role: "button",
|
|
442
415
|
tabIndex: 0,
|
|
443
|
-
"aria-pressed":
|
|
444
|
-
|
|
416
|
+
"aria-pressed": selected,
|
|
417
|
+
title: desc,
|
|
418
|
+
onClick: () => choose(g, m),
|
|
445
419
|
onKeyDown: (ev) => {
|
|
446
420
|
if (ev.key === "Enter" || ev.key === " ") {
|
|
447
421
|
ev.preventDefault();
|
|
448
|
-
|
|
422
|
+
choose(g, m);
|
|
449
423
|
}
|
|
450
424
|
}
|
|
451
425
|
},
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
426
|
+
h("span", { className: "mdsl-name" }, m.name),
|
|
427
|
+
showProvider ? h("span", { className: "mdsl-prov" }, g.name) : null,
|
|
428
|
+
hasEfforts ? h(
|
|
429
|
+
"span",
|
|
430
|
+
{ className: "mdsl-chips", role: "group", "aria-label": "\u63A8\u7406\u7B49\u7EA7" },
|
|
431
|
+
m.reasoning.efforts.map((e) => h(
|
|
432
|
+
"button",
|
|
433
|
+
{
|
|
434
|
+
key: e.id,
|
|
435
|
+
type: "button",
|
|
436
|
+
title: e.description || e.name,
|
|
437
|
+
"aria-pressed": rowEffort === e.id,
|
|
438
|
+
className: "mdsl-chip" + (rowEffort === e.id ? selected ? " mdsl-chip-on" : " mdsl-chip-eff" : ""),
|
|
439
|
+
onClick: (ev) => {
|
|
440
|
+
ev.stopPropagation();
|
|
441
|
+
chooseEffort(g, m, e.id);
|
|
442
|
+
},
|
|
443
|
+
// A real button fires click on Enter/Space; keep the row's own
|
|
444
|
+
// keyboard handler out of the way so the level wins.
|
|
445
|
+
onKeyDown: stop
|
|
446
|
+
},
|
|
447
|
+
e.name
|
|
448
|
+
))
|
|
449
|
+
) : null,
|
|
450
|
+
h(
|
|
451
|
+
"button",
|
|
452
|
+
{
|
|
453
|
+
type: "button",
|
|
454
|
+
className: "mdsl-star" + (fav ? " mdsl-star-on" : ""),
|
|
455
|
+
"aria-label": fav ? "\u53D6\u6D88\u6536\u85CF" : "\u6536\u85CF",
|
|
456
|
+
"aria-pressed": fav,
|
|
457
|
+
onClick: (ev) => {
|
|
458
|
+
ev.stopPropagation();
|
|
459
|
+
toggleFav(g.id, m.id);
|
|
460
|
+
},
|
|
461
|
+
onKeyDown: stop
|
|
462
|
+
},
|
|
463
|
+
star(fav)
|
|
464
|
+
),
|
|
465
|
+
selected ? h("span", { className: "mdsl-check" }, check()) : null
|
|
465
466
|
);
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
const items = nonFavs.filter((c) => c.g.id === g.id);
|
|
469
|
-
if (items.length === 0) return null;
|
|
470
|
-
const isCollapsed = isGroupCollapsed(g.id);
|
|
471
|
-
return import_react.default.createElement(
|
|
467
|
+
const sub = selected && desc !== void 0 ? h("div", { className: "mdsl-sub" }, h("div", { className: "mdsl-desc" }, desc)) : null;
|
|
468
|
+
return h(
|
|
472
469
|
"div",
|
|
473
470
|
{
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
"data-
|
|
471
|
+
key: `${g.id}/${m.id}`,
|
|
472
|
+
className: "mdsl-item" + (selected ? " mdsl-item-current" : ""),
|
|
473
|
+
"data-current": selected ? "true" : void 0
|
|
477
474
|
},
|
|
478
|
-
|
|
479
|
-
|
|
475
|
+
row,
|
|
476
|
+
sub
|
|
480
477
|
);
|
|
481
478
|
};
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
|
|
479
|
+
const onMenuKeyDown = (ev) => {
|
|
480
|
+
if (ev.key === "Escape") {
|
|
481
|
+
ev.preventDefault();
|
|
482
|
+
ev.stopPropagation();
|
|
483
|
+
closeMenu();
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
if (ev.key !== "ArrowDown" && ev.key !== "ArrowUp") return;
|
|
487
|
+
const body = bodyRef.current;
|
|
488
|
+
if (!body) return;
|
|
489
|
+
const rows = Array.from(body.querySelectorAll(".mdsl-row"));
|
|
490
|
+
if (rows.length === 0) return;
|
|
491
|
+
ev.preventDefault();
|
|
492
|
+
const at = rows.indexOf(document.activeElement);
|
|
493
|
+
const step = ev.key === "ArrowDown" ? 1 : -1;
|
|
494
|
+
const next = at === -1 ? step > 0 ? 0 : rows.length - 1 : (at + step + rows.length) % rows.length;
|
|
495
|
+
rows[next].focus();
|
|
496
|
+
};
|
|
497
|
+
const triggerTitle = current ? (providerName ? providerName + " / " + modelName : modelName) + (effortLabel ? " / " + effortLabel : "") : "\u9009\u62E9\u6A21\u578B";
|
|
498
|
+
return h(
|
|
485
499
|
"div",
|
|
486
500
|
{ className: "mdsl-root" },
|
|
487
|
-
|
|
501
|
+
h(
|
|
488
502
|
"button",
|
|
489
503
|
{
|
|
490
504
|
ref: triggerRef,
|
|
@@ -495,16 +509,17 @@ var module = { exports: {} };
|
|
|
495
509
|
else openMenu();
|
|
496
510
|
},
|
|
497
511
|
disabled: locked,
|
|
498
|
-
title:
|
|
512
|
+
title: triggerTitle,
|
|
499
513
|
"aria-haspopup": "dialog",
|
|
500
514
|
"aria-expanded": open
|
|
501
515
|
},
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
516
|
+
current && providerName ? h("span", { className: "mdsl-trigger-provider" }, providerName + "/") : null,
|
|
517
|
+
h("span", { className: "mdsl-label" }, current ? modelName : "\u9009\u62E9\u6A21\u578B"),
|
|
518
|
+
effortLabel ? h("span", { className: "mdsl-effort" }, effortLabel) : null,
|
|
519
|
+
h("span", { className: "mdsl-chevron" + (open ? " mdsl-chevron-open" : "") }, chevronDown())
|
|
505
520
|
),
|
|
506
|
-
open ?
|
|
507
|
-
open && placement !== null ?
|
|
521
|
+
open ? h("div", { className: "mdsl-backdrop", onClick: closeMenu }) : null,
|
|
522
|
+
open && placement !== null ? h(
|
|
508
523
|
"div",
|
|
509
524
|
{
|
|
510
525
|
className: "mdsl-menu",
|
|
@@ -518,82 +533,52 @@ var module = { exports: {} };
|
|
|
518
533
|
},
|
|
519
534
|
role: "dialog",
|
|
520
535
|
"aria-label": "\u9009\u62E9\u6A21\u578B",
|
|
521
|
-
onKeyDown:
|
|
522
|
-
if (ev.key === "Escape") {
|
|
523
|
-
ev.preventDefault();
|
|
524
|
-
ev.stopPropagation();
|
|
525
|
-
closeMenu();
|
|
526
|
-
}
|
|
527
|
-
}
|
|
536
|
+
onKeyDown: onMenuKeyDown
|
|
528
537
|
},
|
|
529
|
-
|
|
538
|
+
h(
|
|
530
539
|
"div",
|
|
531
|
-
{ className: "mdsl-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
key: tag.id,
|
|
553
|
-
type: "button",
|
|
554
|
-
className: "mdsl-tag" + (tag.isCurrent ? " mdsl-tag-current" : ""),
|
|
555
|
-
"data-current": tag.isCurrent ? "true" : void 0,
|
|
556
|
-
title: "\u8DF3\u8F6C\u81F3 " + tag.name,
|
|
557
|
-
onClick: () => scrollToGroup(tag.id)
|
|
558
|
-
},
|
|
559
|
-
tag.id === FAVS_KEY ? import_react.default.createElement("span", { className: "mdsl-tag-icon" }, star(tag.isCurrent)) : null,
|
|
560
|
-
import_react.default.createElement("span", { className: "mdsl-tag-name" }, tag.name)
|
|
561
|
-
))
|
|
562
|
-
) : null
|
|
540
|
+
{ className: "mdsl-search-wrap" },
|
|
541
|
+
searchIcon(),
|
|
542
|
+
h("input", {
|
|
543
|
+
ref: searchRef,
|
|
544
|
+
className: "mdsl-search",
|
|
545
|
+
type: "text",
|
|
546
|
+
"aria-label": "\u641C\u7D22\u6A21\u578B",
|
|
547
|
+
placeholder: "\u641C\u7D22\u6A21\u578B",
|
|
548
|
+
value: query,
|
|
549
|
+
onChange: (ev) => setQuery(ev.target.value)
|
|
550
|
+
}),
|
|
551
|
+
query !== "" ? h("button", {
|
|
552
|
+
type: "button",
|
|
553
|
+
className: "mdsl-search-clear",
|
|
554
|
+
"aria-label": "\u6E05\u9664\u641C\u7D22",
|
|
555
|
+
onClick: () => {
|
|
556
|
+
setQuery("");
|
|
557
|
+
const el = searchRef.current;
|
|
558
|
+
if (el) el.focus({ preventScroll: true });
|
|
559
|
+
}
|
|
560
|
+
}, closeIcon()) : null
|
|
563
561
|
),
|
|
564
|
-
data.status === "error" ?
|
|
565
|
-
data.failures && data.failures.length ?
|
|
566
|
-
|
|
562
|
+
data.status === "error" ? h("div", { className: "mdsl-error" }, data.error || "\u52A0\u8F7D\u5931\u8D25") : null,
|
|
563
|
+
data.failures && data.failures.length ? h("div", { className: "mdsl-error" }, data.failures.map((f) => f.name + ": " + f.message).join("\uFF1B")) : null,
|
|
564
|
+
h(
|
|
567
565
|
"div",
|
|
568
566
|
{ className: "mdsl-body", ref: bodyRef, role: "group", "aria-label": "\u6A21\u578B\u5217\u8868" },
|
|
569
|
-
data.status === "loading" ?
|
|
570
|
-
data.status === "ready" &&
|
|
571
|
-
noMatch ?
|
|
567
|
+
data.status === "loading" ? h("div", { className: "mdsl-empty" }, "\u52A0\u8F7D\u4E2D\u2026") : null,
|
|
568
|
+
data.status === "ready" && total === 0 ? h("div", { className: "mdsl-empty" }, "\u6682\u65E0\u53EF\u7528\u6A21\u578B") : null,
|
|
569
|
+
noMatch ? h("div", { className: "mdsl-empty" }, "\u6CA1\u6709\u5339\u914D\u7684\u6A21\u578B") : null,
|
|
570
|
+
favEntries.length > 0 ? h(
|
|
572
571
|
"div",
|
|
573
|
-
{ className: "mdsl-
|
|
574
|
-
"\
|
|
575
|
-
|
|
572
|
+
{ className: "mdsl-group", key: FAVS_KEY },
|
|
573
|
+
heading("\u6536\u85CF", star(true)),
|
|
574
|
+
favEntries.map(({ g, m }) => renderRow(g, m, true))
|
|
576
575
|
) : null,
|
|
577
|
-
|
|
576
|
+
filteredGroups.map((g) => h(
|
|
578
577
|
"div",
|
|
579
|
-
{
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
role: "group",
|
|
584
|
-
"aria-label": "\u6536\u85CF"
|
|
585
|
-
},
|
|
586
|
-
groupTitle(FAVS_KEY, "\u6536\u85CF", favs.length, favsCollapsed, q === "", star(true)),
|
|
587
|
-
favsCollapsed ? null : favs.map(renderRow)
|
|
588
|
-
) : null,
|
|
589
|
-
(data.groups || []).map(renderGroup)
|
|
590
|
-
),
|
|
591
|
-
import_react.default.createElement(
|
|
592
|
-
"div",
|
|
593
|
-
{ className: "mdsl-footer" },
|
|
594
|
-
import_react.default.createElement("span", { className: "mdsl-footer-dot" }),
|
|
595
|
-
import_react.default.createElement("span", { className: "mdsl-footer-current" }, current ? modelName + (currentEffortText ? " \xB7 " + currentEffortText : "") : "\u672A\u9009\u62E9\u6A21\u578B"),
|
|
596
|
-
import_react.default.createElement("span", { className: "mdsl-footer-hint" }, "Esc")
|
|
578
|
+
{ className: "mdsl-group", key: g.id },
|
|
579
|
+
heading(g.name),
|
|
580
|
+
g.models.map((m) => renderRow(g, m, false))
|
|
581
|
+
))
|
|
597
582
|
)
|
|
598
583
|
) : null
|
|
599
584
|
);
|