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/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: same 28px chip as the composer's sibling permission / plan
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; transition: background .14s ease; }
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); transition: transform .12s ease; }
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 (translucent fill + blur + prominent
68
- elevation stroke) so every DSH dropdown reads the same. */
69
- .mdsl-menu { position: fixed; z-index: 40; display: flex; flex-direction: column; width: 384px; max-width: calc(100vw - 24px); max-height: min(480px, 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; }
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
- /* Header: one search field + one jump rail. Everything else belongs to the
75
- scrolling body, so the fixed chrome stays ~74px instead of a wrapped tag
76
- wall that ate a third of the card. */
77
- .mdsl-header { flex: none; display: flex; flex-direction: column; gap: 6px; padding: 4px 4px 6px; }
78
- .mdsl-search-wrap { position: relative; display: flex; align-items: center; }
79
- .mdsl-search-icon { position: absolute; left: 9px; display: flex; color: var(--dsw-alias-label-tertiary); pointer-events: none; }
80
- .mdsl-search { width: 100%; height: 32px; padding: 0 30px 0 29px; border: 0.5px solid var(--dsw-alias-border-l4); border-radius: var(--dsw-radius-md, 12px); background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); font-family: inherit; font-size: 13px; line-height: 20px; outline: none; transition: border-color .14s ease; }
81
- .mdsl-search::placeholder { color: var(--dsw-alias-label-tertiary); }
82
- .mdsl-search:focus { border-color: var(--dsw-alias-state-business-primary); }
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
- /* Group headings stick while their rows scroll, painted with the shipped
104
- menu-group fill so rows never bleed through. Normal case (text-transform:
105
- uppercase mangles mixed CJK/Latin provider names). */
106
- .mdsl-group { display: flex; flex-direction: column; gap: 1px; }
107
- .mdsl-group + .mdsl-group { margin-top: 3px; }
108
- .mdsl-group-title { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 5px; padding: 4px 7px 3px; background-color: var(--dsw-alias-bg-overlay); background-image: linear-gradient(var(--dsw-alias-menu-group-header-fill, transparent), var(--dsw-alias-menu-group-header-fill, transparent)); color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 16px; font-weight: 500; cursor: pointer; user-select: none; transition: color .12s ease; }
109
- .mdsl-group-title:hover { color: var(--dsw-alias-label-secondary); }
110
- .mdsl-group-title:focus-visible { outline: none; color: var(--dsw-alias-label-primary); }
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
- .mdsl-row { display: flex; align-items: flex-start; gap: 7px; padding: 6px 8px; border-radius: var(--dsw-radius-md, 12px); cursor: pointer; transition: background .12s ease; }
118
- .mdsl-row:hover { background: var(--dsw-alias-interactive-bg-hover); }
119
- .mdsl-row-current, .mdsl-row-current:hover { background: var(--dsw-alias-interactive-bg-active); }
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-star { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin: 0 0 0 -2px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--dsw-alias-label-tertiary); cursor: pointer; transition: color .12s ease, background .12s ease; }
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
- .mdsl-empty { padding: 18px 10px; text-align: center; color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 18px; }
137
- .mdsl-empty-sub { margin-top: 2px; color: var(--dsw-alias-label-caption); font-size: 11px; line-height: 16px; }
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; }
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
- /* Pinned footer: repeats the current selection while the body is scrolled
141
- into some other provider, plus the only keyboard shortcut worth naming. */
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) => import_react.default.createElement(
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
- import_react.default.createElement("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" })
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 chevron = () => import_react.default.createElement(
150
+ var check = () => h(
166
151
  "svg",
167
- { width: 10, height: 10, viewBox: "0 0 10 10", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" },
168
- import_react.default.createElement("path", { d: "M3.5 2.5L6.5 5l-3 2.5", stroke: "currentColor", strokeWidth: 1.3, strokeLinecap: "round", strokeLinejoin: "round" })
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 = () => import_react.default.createElement(
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
- import_react.default.createElement("path", { d: "M3 4.75L6 7.75l3-3", stroke: "currentColor", strokeWidth: 1.3, strokeLinecap: "round", strokeLinejoin: "round" })
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 = () => import_react.default.createElement(
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
- import_react.default.createElement("path", { d: "M3 3l6 6M9 3L3 9", stroke: "currentColor", strokeWidth: 1.4, strokeLinecap: "round" })
163
+ h("path", { d: "M3 3l6 6M9 3L3 9", stroke: "currentColor", strokeWidth: 1.4, strokeLinecap: "round" })
184
164
  );
185
- var searchIcon = () => import_react.default.createElement(
165
+ var searchIcon = () => h(
186
166
  "span",
187
167
  { className: "mdsl-search-icon" },
188
- import_react.default.createElement(
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
- import_react.default.createElement("circle", { cx: 7, cy: 7, r: 5, stroke: "currentColor", strokeWidth: 1.4 }),
192
- import_react.default.createElement("line", { x1: 10.8, y1: 10.8, x2: 14, y2: 14, stroke: "currentColor", strokeWidth: 1.4, strokeLinecap: "round" })
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) => ({ ...d, status: "loading", error: null }));
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 || placement === null) return;
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(384, window.innerWidth - margin * 2);
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(160, Math.min(480, side === "top" ? spaceAbove : spaceBelow));
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
- side,
256
- maxHeight,
257
- width,
258
- left,
259
- bottom: window.innerHeight - rect.top + gap,
260
- top: rect.bottom + gap
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 = () => placeMenu();
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
- setUserToggled(/* @__PURE__ */ new Map());
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 = (g, m, ev) => {
317
- if (ev && ev.stopPropagation) ev.stopPropagation();
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 isGroupCollapsed = (gid) => {
326
- if (query.trim() !== "") return false;
327
- if (userToggled.has(gid)) return userToggled.get(gid);
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 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
- });
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 : "\u9009\u62E9\u6A21\u578B");
367
- const triggerLabel = current ? providerName + "/" + modelName : "\u9009\u62E9\u6A21\u578B";
368
- const effEffort = current ? current.reasoningEffort !== void 0 ? current.reasoningEffort : curModel && curModel.reasoning ? curModel.reasoning.defaultEffort : void 0 : void 0;
369
- const effMatch = effEffort && curModel && curModel.reasoning ? curModel.reasoning.efforts.find((e) => e.id === effEffort) : void 0;
370
- const effLabel = effMatch ? effMatch.name : effEffort ? effEffort : curModel && curModel.reasoning ? "\u9ED8\u8BA4" : void 0;
371
- const allChoices = [];
372
- if (data.groups) {
373
- for (const g of data.groups) {
374
- for (const m of g.models) {
375
- allChoices.push({ g, m, selected: current !== null && current.provider === g.id && current.model === m.id });
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 filtered = q === "" ? allChoices : allChoices.filter((c) => (c.m.name + " " + (c.m.description || "") + " " + c.g.name).toLowerCase().includes(q));
381
- const favs = filtered.filter((c) => favorites.has(`${c.g.id}/${c.m.id}`));
382
- const nonFavs = filtered.filter((c) => !favorites.has(`${c.g.id}/${c.m.id}`));
383
- const favsCollapsed = isGroupCollapsed(FAVS_KEY);
384
- const tagList = [];
385
- if (favorites.size > 0) {
386
- const isCurrent = current !== null && favorites.has(current.provider + "/" + current.model);
387
- tagList.push({ id: FAVS_KEY, name: "\u6536\u85CF", isCurrent });
388
- }
389
- if (data.groups) {
390
- for (const g of data.groups) {
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 groupTitle = (gid, name2, count, isCollapsed, interactive, icon) => import_react.default.createElement(
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
- className: "mdsl-group-title",
401
- role: "button",
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 = (c) => {
419
- const hasEfforts = c.m.reasoning && c.m.reasoning.efforts && c.m.reasoning.efforts.length;
420
- const effEff = current !== null && current.provider === c.g.id && current.model === c.m.id ? effEffort : hasEfforts ? c.m.reasoning.defaultEffort : void 0;
421
- const isFav = favorites.has(`${c.g.id}/${c.m.id}`);
422
- const chips = [];
423
- if (hasEfforts) {
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
- key: `${c.g.id}/${c.m.id}`,
440
- className: "mdsl-row" + (c.selected ? " mdsl-row-current" : ""),
384
+ className: "mdsl-row",
441
385
  role: "button",
442
386
  tabIndex: 0,
443
- "aria-pressed": c.selected,
444
- onClick: selectRow,
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
- selectRow();
393
+ choose(g, m);
449
394
  }
450
395
  }
451
396
  },
452
- import_react.default.createElement("button", { type: "button", className: "mdsl-star" + (isFav ? " mdsl-star-on" : ""), "aria-label": isFav ? "\u53D6\u6D88\u6536\u85CF" : "\u6536\u85CF", "aria-pressed": isFav, onClick: (ev) => toggleFav(c.g.id, c.m.id, ev) }, star(isFav)),
453
- import_react.default.createElement(
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-row-main" },
456
- import_react.default.createElement(
457
- "div",
458
- { className: "mdsl-row-head" },
459
- import_react.default.createElement("span", { className: "mdsl-row-name" }, c.m.name),
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
- c.m.description ? import_react.default.createElement("div", { className: "mdsl-row-desc" }, c.m.description) : null,
463
- chips.length ? import_react.default.createElement("div", { className: "mdsl-row-chips" }, chips) : null
464
- )
465
- );
466
- };
467
- const renderGroup = (g) => {
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(
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
- className: "mdsl-group" + (isCollapsed ? " mdsl-group-collapsed" : ""),
475
- key: g.id,
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 noMatch = data.status === "ready" && q !== "" && filtered.length === 0;
483
- const currentEffortText = effLabel && effLabel !== "\u9ED8\u8BA4" ? effLabel : "";
484
- return import_react.default.createElement(
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
- import_react.default.createElement(
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: triggerLabel + (effLabel ? " \xB7 " + effLabel : ""),
486
+ title: triggerTitle,
499
487
  "aria-haspopup": "dialog",
500
488
  "aria-expanded": open
501
489
  },
502
- import_react.default.createElement("span", { className: "mdsl-label" }, triggerLabel),
503
- effLabel ? import_react.default.createElement("span", { className: "mdsl-effort" }, effLabel) : null,
504
- import_react.default.createElement("span", { className: "mdsl-chevron" + (open ? " mdsl-chevron-open" : "") }, chevronDown())
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 ? import_react.default.createElement("div", { className: "mdsl-backdrop", onClick: closeMenu }) : null,
507
- open && placement !== null ? import_react.default.createElement(
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: (ev) => {
522
- if (ev.key === "Escape") {
523
- ev.preventDefault();
524
- ev.stopPropagation();
525
- closeMenu();
526
- }
527
- }
509
+ onKeyDown: onMenuKeyDown
528
510
  },
529
- import_react.default.createElement(
511
+ h(
530
512
  "div",
531
- { className: "mdsl-header" },
532
- import_react.default.createElement(
533
- "div",
534
- { className: "mdsl-search-wrap" },
535
- searchIcon(),
536
- import_react.default.createElement("input", {
537
- ref: searchRef,
538
- className: "mdsl-search",
539
- "aria-label": "\u641C\u7D22\u6A21\u578B",
540
- placeholder: "\u641C\u7D22\u6A21\u578B\u3001\u63CF\u8FF0\u6216\u63D0\u4F9B\u5546\u2026",
541
- value: query,
542
- onChange: (ev) => setQuery(ev.target.value)
543
- }),
544
- query !== "" ? import_react.default.createElement("button", { type: "button", className: "mdsl-search-clear", "aria-label": "\u6E05\u9664\u641C\u7D22", onClick: () => setQuery("") }, closeIcon()) : null
545
- ),
546
- q === "" && tagList.length > 0 ? import_react.default.createElement(
547
- "div",
548
- { className: "mdsl-tags", ref: tagRailRef },
549
- tagList.map((tag) => import_react.default.createElement(
550
- "button",
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" ? import_react.default.createElement("div", { className: "mdsl-error" }, data.error || "\u52A0\u8F7D\u5931\u8D25") : null,
565
- data.failures && data.failures.length ? import_react.default.createElement("div", { className: "mdsl-error" }, data.failures.map((f) => f.name + ": " + f.message).join("\uFF1B")) : null,
566
- import_react.default.createElement(
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" ? import_react.default.createElement("div", { className: "mdsl-empty" }, "\u52A0\u8F7D\u4E2D\u2026") : null,
570
- data.status === "ready" && allChoices.length === 0 ? import_react.default.createElement("div", { className: "mdsl-empty" }, "\u6682\u65E0\u53EF\u7528\u6A21\u578B") : null,
571
- noMatch ? import_react.default.createElement(
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-empty" },
574
- "\u6CA1\u6709\u5339\u914D\u7684\u6A21\u578B",
575
- import_react.default.createElement("div", { className: "mdsl-empty-sub" }, "\u6362\u4E2A\u5173\u952E\u8BCD\u8BD5\u8BD5")
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
- favs.length ? import_react.default.createElement(
549
+ filteredGroups.map((g) => h(
578
550
  "div",
579
- {
580
- className: "mdsl-group" + (favsCollapsed ? " mdsl-group-collapsed" : ""),
581
- key: FAVS_KEY,
582
- "data-group-id": FAVS_KEY,
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
  );