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