@jayyuen66/dsh-zvec-grep 0.1.15 → 0.1.16

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/client.js +187 -162
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The deviations below are deliberate: version headings carry no release date (publish times are recorded by the registry — `npm view <package> time`), and a release may add sections beyond the standard six, such as `Not changed, deliberately` and `Earlier`.
4
4
 
5
+ ## 0.1.16
6
+
7
+ 设置卡的下拉候选与说明浮层不再漂到浏览器最左边;shared 抬到 `^0.2.8`(含运行时几何自检)。zg 检索工具与路由行为不变。
8
+
9
+ ### Fixed
10
+
11
+ - **下拉候选与说明浮层被钉在视口左边缘**:`.dsu-menu` 与 `.dsu-tip` 的 `position-area: block-end span-inline-start` 选中的是「行内起始列 + 中间列」,而 `position: fixed` 下该区域的起始边是**视口左边缘**、不是触发器左边缘,再叠一条 `justify-self: start`,浮层就落在 `x=0`。改为 `block-end span-inline-end`——真实 Chromium(patchright headless,156.0.8078.4)实测:1440px 视口、触发器左边缘 860px,改前浮层左边缘 0,改后 860;触发器贴到右侧时 `flip-inline` 会改成右边缘对齐,贴到视口底部时 `flip-block` 翻到上方。
12
+ - **锚定没兑现时改回 JS 矩形定位**:`select.ts` 与 `field.ts` 的 `place()` 此前只要 `CSS.supports("position-area: block-end")` 为真就直接 `return`,方向性错误没有任何兜底。现在锚定后先量一次浮层矩形,用 shared 0.2.8 的 `anchorPlacementOff` 判它是否真贴在触发器上(行内起始边或结束边任一在 2px 容差内贴住,且块向落在触发器下方或上方),不通过才把 `position-area` 显式置 `none` 再写 `left` / `top`。顺序是承重的:实测同时留着 `position-area` 只写坐标时块向仍由锚定决定(浮层 `y` 落在 314 而不是 160),必须先关。回退是单向的——同一个浮层一旦走过 JS 路径,后续 `resize` 不再尝试锚定,避免两个定位源来回抢。
13
+ - **回归测试**:`test/card-ui.test.ts` 新增 `anchorPlacementOff` 的四种对齐形态(左边缘对齐、`flip-inline` 右对齐、`flip-block` 翻上方、两轴都不沾)与容差边界,以及三条锚定用例(浮层真贴住时不写 JS 坐标、被钉到视口左侧时改写坐标并关掉 `position-area`、回退过的浮层不再重试锚定)。
14
+
15
+ ### Changed
16
+
17
+ - **运行时依赖 shared 抬到 `^0.2.8`**:`pnpm-workspace.yaml` 的 catalog 由根 `sync` 投影,`pnpm-lock.yaml` 随 `sync:lock` 重解;`client.js` 按新 shared 重建,内联的 `CARD_UI_CSS` 逐字节等于已装 shared 导出的那一份。0.2.8 新增的 `anchorPlacementOff` / `ANCHOR_PLACEMENT_TOLERANCE` 只被卡片内部使用,本包对外工具与 Remote 方法名单不变。
18
+
5
19
  ## 0.1.15
6
20
 
7
21
  宿主开发基线抬到 `0.2.2-rc.2`,支持窗口收到 `^0.2.2-rc.1`。zg 检索工具与路由行为不变。
package/client.js CHANGED
@@ -88,7 +88,7 @@ const REMOTE_EMBEDDING_CATALOG = Object.freeze([
88
88
  dimension: 1024
89
89
  }
90
90
  ].map((entry) => Object.freeze(entry)));
91
- // node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui-D2cuQvLS.js
91
+ // node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui-yf56_khz.js
92
92
  const c = `
93
93
  .dsu-form{display:flex;flex-direction:column}
94
94
  .dsu-section{margin-top:24px;padding-top:24px;border-top:.5px solid var(--dsw-alias-border-l1)}
@@ -109,11 +109,11 @@ const c = `
109
109
  .dsu-helpBtn{appearance:none;border:0;background:transparent;padding:0;width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;color:var(--dsw-alias-label-tertiary);cursor:help;border-radius:50%;flex:none}
110
110
  .dsu-help:hover .dsu-helpBtn,.dsu-helpBtn:focus-visible{color:var(--dsw-alias-label-primary)}
111
111
  .dsu-helpBtn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
112
- .dsu-tip{position:fixed;z-index:60;box-sizing:border-box;max-width:min(340px,calc(100vw - 16px));max-height:calc(100vh - 16px);overflow:auto;overflow-wrap:anywhere;padding:10px 12px;border-radius:10px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);box-shadow:0 12px 32px rgb(0 0 0 / 45%);font-size:12px;line-height:1.6;font-weight:400;color:var(--dsw-alias-label-secondary)}
112
+ .dsu-tip{width:max-content;position:fixed;position-area:block-end span-inline-end;justify-self:start;margin-top:8px;z-index:60;box-sizing:border-box;max-width:min(340px,calc(100vw - 16px));max-height:calc(100vh - 16px);overflow:auto;overflow-wrap:anywhere;padding:10px 12px;border-radius:10px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);box-shadow:0 12px 32px rgb(0 0 0 / 45%);font-size:12px;line-height:1.6;font-weight:400;color:var(--dsw-alias-label-secondary)}
113
113
  .dsu-input{width:100%;height:34px;padding:0 12px;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px}
114
114
  .dsu-input:focus-visible{outline:none;border-color:var(--dsw-alias-state-business-primary)}
115
115
  .dsu-input[aria-invalid="true"]{border-color:var(--dsw-alias-state-error-primary)}
116
- .dsu-input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}
116
+ .dsu-input:disabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}
117
117
  .dsu-input::placeholder{color:var(--dsw-alias-label-tertiary)}
118
118
  .dsu-textarea{height:auto;min-height:96px;padding:8px 12px;line-height:1.6;resize:vertical}
119
119
  .dsu-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
@@ -134,7 +134,7 @@ const c = `
134
134
  .dsu-selectValue{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
135
135
  .dsu-chevron{flex:none;color:var(--dsw-alias-label-tertiary);transition:transform .16s}
136
136
  .dsu-select[aria-expanded="true"] .dsu-chevron{transform:rotate(180deg)}
137
- .dsu-menu{position:fixed;position-area:block-end span-inline-start;justify-self:start;margin-top:6px;z-index:70;padding:4px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);border-radius:12px;box-shadow:0 12px 32px rgb(0 0 0 / 50%);max-height:280px;overflow:auto}
137
+ .dsu-menu{position:fixed;position-area:block-end span-inline-end;justify-self:start;margin-top:6px;z-index:70;padding:4px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);border-radius:12px;box-shadow:0 12px 32px rgb(0 0 0 / 50%);max-height:280px;overflow:auto}
138
138
  .dsu-option{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:1.4;width:100%;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 10px;border-radius:8px;cursor:pointer;text-align:left}
139
139
  .dsu-option:hover,.dsu-option[data-active="true"]{background:var(--dsw-alias-bg-layer-3)}
140
140
  .dsu-option:disabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}
@@ -177,64 +177,80 @@ function u(t) {
177
177
  function d(t) {
178
178
  return (0, react.createElement)(`section`, { className: `dsu-section` }, (0, react.createElement)(`h2`, { className: `dsu-sectionTitle` }, t.title), t.hint === void 0 ? null : (0, react.createElement)(`p`, { className: `dsu-sectionHint` }, t.hint), t.children);
179
179
  }
180
- function m(a) {
181
- let c = (0, react.useId)(), [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(!1), p = (0, react.useRef)(!1), m = (0, react.useRef)(!1), h = (0, react.useRef)(!1), g = (0, react.useRef)(null), _ = (0, react.useRef)(null), v = (0, react.useRef)(null), y = (0, react.useCallback)(() => {
182
- v.current !== null && (clearTimeout(v.current), v.current = null);
183
- }, []), b = (0, react.useCallback)(() => {
184
- let e = g.current, t = _.current;
180
+ function m() {
181
+ return `happyDOM` in globalThis ? !1 : typeof CSS < `u` && typeof CSS.supports == `function` && CSS.supports(`position-area: block-end`);
182
+ }
183
+ function h(e, t) {
184
+ let n = Math.abs(t.left - e.left) <= 2, r = Math.abs(t.right - e.right) <= 2;
185
+ if (!n && !r) return !0;
186
+ let i = t.top >= e.bottom - 2, a = t.bottom <= e.top + 2;
187
+ return !i && !a;
188
+ }
189
+ function g(a) {
190
+ let c = (0, react.useId)(), l = `--dsu-tip-${c.replaceAll(/[^a-zA-Z0-9]/gu, ``)}`, [u, d] = (0, react.useState)(!1), f = (0, react.useRef)(!1), p = (0, react.useRef)(!1), g = (0, react.useRef)(!1), _ = (0, react.useRef)(null), v = (0, react.useRef)(null), y = (0, react.useRef)(null), b = (0, react.useRef)(null), x = (0, react.useCallback)(() => {
191
+ b.current !== null && (clearTimeout(b.current), b.current = null);
192
+ }, []), S = (0, react.useCallback)(() => {
193
+ let e = v.current, t = y.current;
185
194
  /* v8 ignore next 3 -- place 只在 open 的 layout effect 与挂载期监听器里调用;refs 为空只可能是卸载竞态 */
186
195
  if (e === null || t === null) return;
187
- let n = e.getBoundingClientRect(), r = t.offsetWidth, i = t.offsetHeight, { left: a } = n, o = n.bottom + 8;
188
- o + i > window.innerHeight - 8 && (o = n.top - i - 8), a + r > window.innerWidth - 8 && (a = window.innerWidth - r - 8);
189
- let s = Math.max(8, window.innerWidth - r - 8), c = Math.max(8, window.innerHeight - i - 8);
190
- t.style.left = `${Math.min(Math.max(8, a), s)}px`, t.style.top = `${Math.min(Math.max(8, o), c)}px`;
191
- }, []), x = (0, react.useCallback)(() => {
192
- y(), h.current = !1, f(!1), u(!1);
193
- }, [y]), S = (0, react.useCallback)(() => {
194
- y(), u(!0);
195
- }, [y]), C = (0, react.useCallback)(() => {
196
- y(), p.current || m.current || h.current || (v.current = setTimeout(() => {
196
+ let n = m() && t.style.positionArea !== `none`, r = e.getBoundingClientRect();
197
+ if (n && !h(r, t.getBoundingClientRect())) return;
198
+ n && (t.style.positionArea = `none`), t.style.marginTop = `0px`;
199
+ let i = t.offsetWidth, a = t.offsetHeight, { left: o } = r, s = r.bottom + 8;
200
+ s + a > window.innerHeight - 8 && (s = r.top - a - 8), o + i > window.innerWidth - 8 && (o = window.innerWidth - i - 8);
201
+ let c = Math.max(8, window.innerWidth - i - 8), l = Math.max(8, window.innerHeight - a - 8);
202
+ t.style.left = `${Math.min(Math.max(8, o), c)}px`, t.style.top = `${Math.min(Math.max(8, s), l)}px`;
203
+ }, []), C = (0, react.useCallback)(() => {
204
+ x(), g.current = !1, d(!1);
205
+ }, [x]), w = (0, react.useCallback)(() => {
206
+ x(), d(!0);
207
+ }, [x]), T = (0, react.useCallback)(() => {
208
+ x(), f.current || p.current || g.current || (b.current = setTimeout(() => {
197
209
  /* v8 ignore next 3 -- 任何重新进入/钉住都会 cancelHide;这次复查只防未来的异步路径 */
198
- v.current = null, p.current || m.current || h.current || u(!1);
210
+ b.current = null, f.current || p.current || g.current || d(!1);
199
211
  }, 120));
200
- }, [y]), w = (0, react.useCallback)((e) => {
201
- h.current = e, f(e);
212
+ }, [x]), E = (0, react.useCallback)((e) => {
213
+ g.current = e;
202
214
  }, []);
203
215
  (0, react.useLayoutEffect)(() => {
204
- if (!l) return () => {};
205
- b();
216
+ if (!u) return () => {};
217
+ S();
206
218
  let e = (e) => {
207
219
  let { target: t } = e;
208
- t instanceof Node && _.current?.contains(t) === !0 || (h.current ? b() : x());
220
+ t instanceof Node && y.current?.contains(t) === !0 || (g.current ? S() : C());
209
221
  }, t = () => {
210
- b();
222
+ S();
223
+ }, n = (e) => {
224
+ let t = e.target;
225
+ _.current?.contains(t) !== !0 && C();
211
226
  };
212
- return window.addEventListener(`scroll`, e, !0), window.addEventListener(`resize`, t), () => {
213
- window.removeEventListener(`scroll`, e, !0), window.removeEventListener(`resize`, t);
227
+ return document.addEventListener(`pointerdown`, n, !0), window.addEventListener(`scroll`, e, !0), window.addEventListener(`resize`, t), () => {
228
+ document.removeEventListener(`pointerdown`, n, !0), window.removeEventListener(`scroll`, e, !0), window.removeEventListener(`resize`, t);
214
229
  };
215
230
  }, [
216
- l,
231
+ u,
217
232
  a.detail,
218
- b,
219
- x
233
+ S,
234
+ C
220
235
  ]), (0, react.useEffect)(() => {
221
- if (!l) return () => {};
236
+ if (!u) return () => {};
222
237
  let e = (e) => {
223
- e.key === `Escape` && x();
238
+ e.key === `Escape` && C();
224
239
  };
225
240
  return document.addEventListener(`keydown`, e), () => {
226
241
  document.removeEventListener(`keydown`, e);
227
242
  };
228
- }, [l, x]), (0, react.useEffect)(() => y, [y]);
229
- let T = (0, react.createElement)(`button`, {
230
- ref: g,
243
+ }, [u, C]), (0, react.useEffect)(() => x, [x]);
244
+ let D = (0, react.createElement)(`button`, {
245
+ ref: v,
231
246
  type: `button`,
232
247
  className: `dsu-helpBtn`,
248
+ style: { anchorName: l },
233
249
  "aria-label": `${a.label} 说明`,
234
- "aria-describedby": c,
235
- "aria-pressed": d,
250
+ "aria-expanded": u,
251
+ "aria-controls": c,
236
252
  onClick: () => {
237
- h.current ? x() : (w(!0), S());
253
+ g.current ? C() : (E(!0), w());
238
254
  }
239
255
  }, (0, react.createElement)(`svg`, {
240
256
  width: 12,
@@ -258,44 +274,49 @@ function m(a) {
258
274
  cy: 4.3,
259
275
  r: .8,
260
276
  fill: `currentColor`
261
- }))), E = (0, react.createElement)(`div`, {
262
- ref: _,
277
+ }))), O = (0, react.createElement)(`div`, {
278
+ ref: y,
263
279
  id: c,
264
280
  role: `tooltip`,
265
281
  className: `dsu-tip`,
266
- hidden: !l
267
- }, a.detail), D = a.showLabel === !1 ? null : (0, react.createElement)(`span`, { className: `dsu-label${a.compact === !0 ? ` dsu-labelMono` : ``}` }, a.label);
282
+ style: {
283
+ positionAnchor: l,
284
+ positionTryFallbacks: `flip-block, flip-inline`
285
+ },
286
+ hidden: !u
287
+ }, a.detail), k = a.showLabel === !1 ? null : (0, react.createElement)(`span`, { className: `dsu-label${a.compact === !0 ? ` dsu-labelMono` : ``}` }, a.label);
268
288
  return (0, react.createElement)(`span`, {
289
+ ref: _,
269
290
  className: `dsu-help`,
270
291
  onMouseEnter: () => {
271
- p.current = !0, S();
292
+ f.current = !0, w();
272
293
  },
273
294
  onMouseLeave: () => {
274
- p.current = !1, C();
295
+ f.current = !1, T();
275
296
  },
276
297
  onFocus: () => {
277
- m.current = !0, S();
298
+ p.current = !0, w();
278
299
  },
279
300
  onBlur: (e) => {
280
301
  let t = e.relatedTarget;
281
- t instanceof Node && e.currentTarget.contains(t) || (m.current = !1, C());
302
+ t instanceof Node && e.currentTarget.contains(t) || (p.current = !1, T());
282
303
  }
283
- }, D, T, E);
304
+ }, k, D, O);
284
305
  }
285
- function h(t) {
306
+ function _(t) {
286
307
  let n = `dsu-label${t.compact === !0 ? ` dsu-labelMono` : ``}`, r = t.controlId === void 0 ? (0, react.createElement)(`span`, { className: n }, t.label) : (0, react.createElement)(`label`, {
287
308
  className: n,
288
309
  htmlFor: t.controlId
289
310
  }, t.label);
290
- return (0, react.createElement)(`div`, { className: `dsu-labelRow` }, r, t.detail === void 0 ? null : (0, react.createElement)(m, {
311
+ return (0, react.createElement)(`div`, { className: `dsu-labelRow` }, r, t.detail === void 0 ? null : (0, react.createElement)(g, {
291
312
  label: t.label,
292
313
  detail: t.detail,
293
314
  showLabel: !1
294
315
  }));
295
316
  }
296
- function g(t) {
317
+ function v(t) {
297
318
  let n = t.controlId === void 0 ? void 0 : `${t.controlId}-hint`;
298
- return (0, react.createElement)(`div`, { className: `dsu-field${t.wide === !0 ? ` dsu-fieldWide` : ``}` }, (0, react.createElement)(`div`, { className: `dsu-fieldMeta` }, (0, react.createElement)(h, {
319
+ return (0, react.createElement)(`div`, { className: `dsu-field${t.wide === !0 ? ` dsu-fieldWide` : ``}` }, (0, react.createElement)(`div`, { className: `dsu-fieldMeta` }, (0, react.createElement)(_, {
299
320
  label: t.label,
300
321
  detail: t.detail,
301
322
  compact: t.compact,
@@ -305,9 +326,9 @@ function g(t) {
305
326
  id: n
306
327
  }, t.hint)), (0, react.createElement)(`div`, { className: `dsu-control` }, t.children));
307
328
  }
308
- function _(t) {
329
+ function y(t) {
309
330
  let n = (0, react.useId)(), i = t.hint === void 0 ? void 0 : `${n}-hint`;
310
- return (0, react.createElement)(g, {
331
+ return (0, react.createElement)(v, {
311
332
  ...t,
312
333
  controlId: n
313
334
  }, (0, react.createElement)(`button`, {
@@ -324,55 +345,57 @@ function _(t) {
324
345
  }
325
346
  }, (0, react.createElement)(`span`, { className: `dsu-knob` })));
326
347
  }
327
- function v(t) {
328
- let i = typeof t.value == `number` && Number.isFinite(t.value) ? String(t.value) : ``, [a, c] = (0, react.useState)(i), [l, u] = (0, react.useState)(!1), d = (0, react.useRef)(void 0), f = (0, react.useId)(), p = (0, react.useId)(), m = [t.hint === void 0 ? void 0 : `${f}-hint`, l ? p : void 0].filter((e) => e !== void 0), h = m.length === 0 ? void 0 : m.join(` `);
348
+ function b(t) {
349
+ let i = typeof t.value == `number` && Number.isFinite(t.value) ? String(t.value) : ``, [a, c] = (0, react.useState)(i), [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(!1), p = (0, react.useRef)(void 0), m = (0, react.useId)(), h = (0, react.useId)(), g = t.hint === void 0 ? void 0 : `${m}-hint`, _ = l && d, y = [g, _ ? h : void 0].filter((e) => e !== void 0), b = y.length === 0 ? void 0 : y.join(` `);
329
350
  (0, react.useEffect)(() => {
330
- t.value !== d.current && (d.current = t.value, c(i), u(!1));
351
+ t.value !== p.current && (p.current = t.value, c(i), u(!1), f(!1));
331
352
  }, [t.value, i]);
332
- let _ = (e) => {
353
+ let x = (e) => {
333
354
  let n = t.min ?? -1 / 0, r = t.max ?? 1 / 0;
334
355
  if (!Number.isFinite(e) || e < n || e > r) return !1;
335
356
  let { step: i } = t;
336
357
  if (i === void 0 || i <= 0) return !0;
337
358
  let a = (e - (t.min ?? 0)) / i;
338
359
  return Math.abs(a - Math.round(a)) < 1e-9;
339
- }, v = (e) => {
340
- if (c(e), e === ``) {
341
- u(!1), d.current = void 0, t.onChange(void 0);
360
+ }, S = (e) => {
361
+ if (f(!1), c(e), e === ``) {
362
+ u(!1), p.current = void 0, t.onChange(void 0);
342
363
  return;
343
364
  }
344
365
  let n = Number(e);
345
- _(n) ? (u(!1), d.current = n, t.onChange(n)) : u(!0);
346
- }, y = () => {
366
+ x(n) ? (u(!1), p.current = n, t.onChange(n)) : u(!0);
367
+ }, C = () => {
347
368
  a === `` || l || c(String(Number(a)));
369
+ }, w = () => {
370
+ f(l), C();
348
371
  };
349
- return (0, react.createElement)(g, {
372
+ return (0, react.createElement)(v, {
350
373
  ...t,
351
- controlId: f
374
+ controlId: m
352
375
  }, (0, react.createElement)(`div`, { className: `dsu-numberWrap` }, (0, react.createElement)(`div`, { className: `dsu-number` }, (0, react.createElement)(`input`, {
353
376
  className: `dsu-input`,
354
377
  type: `number`,
355
378
  inputMode: `numeric`,
356
- id: f,
379
+ id: m,
357
380
  value: a,
358
381
  min: t.min,
359
382
  max: t.max,
360
383
  step: t.step,
361
384
  placeholder: t.placeholder,
362
- "aria-invalid": l || void 0,
363
- "aria-describedby": h,
385
+ "aria-invalid": _ || void 0,
386
+ "aria-describedby": b,
364
387
  "data-field": t.field,
365
388
  disabled: t.disabled === !0,
366
389
  onChange: (e) => {
367
- v(e.target.value);
390
+ S(e.target.value);
368
391
  },
369
- onBlur: y
370
- }), t.unit === void 0 ? null : (0, react.createElement)(`span`, { className: `dsu-unit` }, t.unit)), l ? (0, react.createElement)(`p`, {
392
+ onBlur: w
393
+ }), t.unit === void 0 ? null : (0, react.createElement)(`span`, { className: `dsu-unit` }, t.unit)), _ ? (0, react.createElement)(`p`, {
371
394
  className: `dsu-error`,
372
- id: p
395
+ id: h
373
396
  }, t.invalidHint) : null));
374
397
  }
375
- function y(t) {
398
+ function x(t) {
376
399
  let [i, a] = (0, react.useState)(t.value), [o, c] = (0, react.useState)(!1), l = (0, react.useId)(), u = t.hint === void 0 ? void 0 : `${l}-hint`;
377
400
  (0, react.useEffect)(() => {
378
401
  o || a(t.value);
@@ -395,71 +418,70 @@ function y(t) {
395
418
  a(e.target.value), t.onChange(e.target.value);
396
419
  }
397
420
  };
398
- return (0, react.createElement)(g, {
421
+ return (0, react.createElement)(v, {
399
422
  ...t,
400
423
  controlId: l
401
424
  }, t.multiline === !0 ? (0, react.createElement)(`textarea`, d) : (0, react.createElement)(`input`, d));
402
425
  }
403
- function x() {
404
- return `happyDOM` in globalThis ? !1 : typeof CSS < `u` && typeof CSS.supports == `function` && CSS.supports(`position-area: block-end`);
405
- }
406
- function S(c) {
407
- let [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(0), p = (0, react.useRef)(null), m = (0, react.useRef)(null), h = (0, react.useId)(), _ = (0, react.useId)(), v = `--dsu-${_.replaceAll(/[^a-zA-Z0-9]/gu, ``)}`, y = c.hint === void 0 ? void 0 : `${_}-hint`, { disabled: b, value: S, options: C, onChange: w } = c, T = (0, react.useMemo)(() => C.map((e, t) => ({
426
+ function C(c) {
427
+ let [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(0), p = (0, react.useRef)(null), g = (0, react.useRef)(null), _ = (0, react.useId)(), y = (0, react.useId)(), b = `--dsu-${y.replaceAll(/[^a-zA-Z0-9]/gu, ``)}`, x = c.hint === void 0 ? void 0 : `${y}-hint`, { disabled: S, value: C, options: w, onChange: T } = c, E = (0, react.useMemo)(() => w.map((e, t) => ({
408
428
  option: e,
409
429
  index: t
410
- })).filter((e) => e.option.disabled !== !0), [C]), E = C.find((e) => e.value === S)?.label ?? S, D = C[d], O = D !== void 0 && D.disabled !== !0, k = (0, react.useCallback)(() => {
411
- let e = p.current, t = m.current;
430
+ })).filter((e) => e.option.disabled !== !0), [w]), D = w.find((e) => e.value === C)?.label ?? C, O = w[d], k = O !== void 0 && O.disabled !== !0, A = (0, react.useCallback)(() => {
431
+ let e = p.current, t = g.current;
412
432
  /* v8 ignore next 3 -- place 只在 open 的 layout effect 里调用;refs 为空只可能是卸载竞态 */
413
433
  if (e === null || t === null) return;
414
434
  let n = e.getBoundingClientRect(), r = Math.min(n.width, window.innerWidth - 16);
415
- if (t.style.width = `${r}px`, x()) return;
416
- t.style.marginTop = `0px`;
417
- let { left: i } = n;
418
- i + r > window.innerWidth - 8 && (i = window.innerWidth - r - 8);
419
- let a = t.offsetHeight, o = n.bottom + 6;
420
- o + a > window.innerHeight - 8 && (o = n.top - a - 6);
421
- let s = Math.max(8, window.innerWidth - r - 8), c = Math.max(8, window.innerHeight - a - 8);
422
- t.style.left = `${Math.min(Math.max(8, i), s)}px`, t.style.top = `${Math.min(Math.max(8, o), c)}px`;
423
- }, []), A = (0, react.useCallback)(() => {
424
- u(!1);
435
+ t.style.width = `${r}px`;
436
+ let i = m() && t.style.positionArea !== `none`;
437
+ if (i && !h(n, t.getBoundingClientRect())) return;
438
+ i && (t.style.positionArea = `none`), t.style.marginTop = `0px`;
439
+ let { left: a } = n;
440
+ a + r > window.innerWidth - 8 && (a = window.innerWidth - r - 8);
441
+ let o = t.offsetHeight, s = n.bottom + 6;
442
+ s + o > window.innerHeight - 8 && (s = n.top - o - 6);
443
+ let c = Math.max(8, window.innerWidth - r - 8), l = Math.max(8, window.innerHeight - o - 8);
444
+ t.style.left = `${Math.min(Math.max(8, a), c)}px`, t.style.top = `${Math.min(Math.max(8, s), l)}px`;
425
445
  }, []), j = (0, react.useCallback)(() => {
426
- if (b === !0) return;
427
- let e = T.find((e) => e.option.value === S) ?? T.at(0);
446
+ u(!1);
447
+ }, []), M = (0, react.useCallback)(() => {
448
+ if (S === !0) return;
449
+ let e = E.find((e) => e.option.value === C) ?? E.at(0);
428
450
  e !== void 0 && (f(e.index), u(!0));
429
451
  }, [
430
- b,
431
452
  S,
432
- T
433
- ]), M = (0, react.useCallback)((e) => {
453
+ C,
454
+ E
455
+ ]), N = (0, react.useCallback)((e) => {
434
456
  /* v8 ignore next 3 -- 浮层只能经由 openMenu 打开;组件禁用时打不开 */
435
- if (b === !0) return;
436
- let t = C[e];
457
+ if (S === !0) return;
458
+ let t = w[e];
437
459
  /* v8 ignore next 3 -- disabled 选项在浏览器里不派发 click;越界下标由调用方保证 */
438
- t !== void 0 && t.disabled !== !0 && (w(t.value), A(), p.current?.focus());
460
+ t !== void 0 && t.disabled !== !0 && (T(t.value), j(), p.current?.focus());
439
461
  }, [
440
- b,
441
- C,
462
+ S,
442
463
  w,
443
- A
444
- ]), N = (0, react.useCallback)((e) => {
445
- let t = T.findIndex((e) => e.index === d);
464
+ T,
465
+ j
466
+ ]), P = (0, react.useCallback)((e) => {
467
+ let t = E.findIndex((e) => e.index === d);
446
468
  /* v8 ignore next 5 -- open 时归一 effect 已保证 enabled 非空且 active 落在可用项上 */
447
- if (t === -1 || T.length === 0) return;
448
- let n = (t + e + T.length) % T.length, r = T[n];
469
+ if (t === -1 || E.length === 0) return;
470
+ let n = (t + e + E.length) % E.length, r = E[n];
449
471
  /* v8 ignore next 3 -- next 由取模保证在界内 */
450
472
  r !== void 0 && f(r.index);
451
- }, [d, T]);
473
+ }, [d, E]);
452
474
  (0, react.useLayoutEffect)(() => {
453
475
  if (!l) return () => {};
454
- k();
476
+ A();
455
477
  let e = (e) => {
456
478
  let t = e.target;
457
- m.current?.contains(t) !== !0 && p.current?.contains(t) !== !0 && A();
479
+ g.current?.contains(t) !== !0 && p.current?.contains(t) !== !0 && j();
458
480
  }, t = (e) => {
459
481
  let { target: t } = e;
460
- t instanceof Node && m.current?.contains(t) === !0 || A();
482
+ t instanceof Node && g.current?.contains(t) === !0 || j();
461
483
  }, n = () => {
462
- k();
484
+ A();
463
485
  };
464
486
  return document.addEventListener(`pointerdown`, e, !0), window.addEventListener(`scroll`, t, !0), window.addEventListener(`resize`, n), () => {
465
487
  document.removeEventListener(`pointerdown`, e, !0), window.removeEventListener(`scroll`, t, !0), window.removeEventListener(`resize`, n);
@@ -467,29 +489,29 @@ function S(c) {
467
489
  }, [
468
490
  l,
469
491
  c.options,
470
- k,
471
- A
492
+ A,
493
+ j
472
494
  ]), (0, react.useEffect)(() => {
473
495
  if (!l) return;
474
- if (b === !0 || T.length === 0) {
475
- A();
496
+ if (S === !0 || E.length === 0) {
497
+ j();
476
498
  return;
477
499
  }
478
- if (T.some((e) => e.index === d)) return;
479
- let e = T.find((e) => e.option.value === S) ?? T.at(0);
500
+ if (E.some((e) => e.index === d)) return;
501
+ let e = E.find((e) => e.option.value === C) ?? E.at(0);
480
502
  /* v8 ignore next 3 -- enabled 非空在上一分支已保证 */
481
503
  e !== void 0 && f(e.index);
482
504
  }, [
483
505
  l,
484
- b,
485
506
  S,
486
507
  C,
508
+ w,
487
509
  d,
488
- A,
489
- T
510
+ j,
511
+ E
490
512
  ]), (0, react.useLayoutEffect)(() => {
491
513
  if (!l) return;
492
- let e = m.current;
514
+ let e = g.current;
493
515
  /* v8 ignore next 2 -- 同上,menu 在 open 的 commit 之后必然已挂上 */
494
516
  if (e === null) return;
495
517
  let t = e.querySelector(`[data-active="true"]`);
@@ -498,38 +520,38 @@ function S(c) {
498
520
  }, [
499
521
  l,
500
522
  d,
501
- C
523
+ w
502
524
  ]);
503
- let P = (e) => {
525
+ let F = (e) => {
504
526
  if (e.key === `ArrowDown` || e.key === `ArrowUp`) {
505
527
  if (e.preventDefault(), !l) {
506
- j();
528
+ M();
507
529
  return;
508
530
  }
509
- N(e.key === `ArrowDown` ? 1 : -1);
531
+ P(e.key === `ArrowDown` ? 1 : -1);
510
532
  } else if (e.key === `Home` || e.key === `End`) {
511
- if (e.preventDefault(), l || j(), T.length === 0) return;
512
- let t = e.key === `Home` ? T.at(0) : T.at(-1);
533
+ if (e.preventDefault(), l || M(), E.length === 0) return;
534
+ let t = e.key === `Home` ? E.at(0) : E.at(-1);
513
535
  /* v8 ignore next 3 -- enabled 为空已在上一条返回 */
514
536
  if (t === void 0) return;
515
537
  f(t.index);
516
538
  } else if (e.key === `Enter` || e.key === ` `) {
517
539
  if (e.preventDefault(), !l) {
518
- j();
540
+ M();
519
541
  return;
520
542
  }
521
- M(d);
522
- } else (e.key === `Tab` || e.key === `Escape`) && A();
523
- }, F = [], I;
524
- for (let [t, n] of C.entries()) n.group !== I && (n.group !== void 0 && F.push((0, react.createElement)(`div`, {
543
+ N(d);
544
+ } else (e.key === `Tab` || e.key === `Escape`) && j();
545
+ }, I = [], L;
546
+ for (let [t, n] of w.entries()) n.group !== L && (n.group !== void 0 && I.push((0, react.createElement)(`div`, {
525
547
  key: `group-${t}-${n.group}`,
526
548
  className: `dsu-optionGroup`,
527
549
  role: `presentation`
528
- }, n.group)), I = n.group), F.push((0, react.createElement)(`button`, {
550
+ }, n.group)), L = n.group), I.push((0, react.createElement)(`button`, {
529
551
  key: `option-${n.value}`,
530
552
  type: `button`,
531
553
  role: `option`,
532
- id: `${h}-${t}`,
554
+ id: `${_}-${t}`,
533
555
  className: `dsu-option`,
534
556
  tabIndex: -1,
535
557
  "aria-selected": n.value === c.value,
@@ -539,7 +561,7 @@ function S(c) {
539
561
  e.preventDefault();
540
562
  },
541
563
  onClick: () => {
542
- M(t);
564
+ N(t);
543
565
  },
544
566
  onMouseEnter: () => {
545
567
  /* v8 ignore next -- happy-dom 对 disabled 元素不派发 mouse 事件;浏览器实现各有差异,保留禁用检查 */
@@ -559,34 +581,34 @@ function S(c) {
559
581
  strokeLinecap: `round`,
560
582
  strokeLinejoin: `round`
561
583
  }))));
562
- return (0, react.createElement)(g, {
584
+ return (0, react.createElement)(v, {
563
585
  ...c,
564
- controlId: _
586
+ controlId: y
565
587
  }, (0, react.createElement)(`div`, {
566
588
  className: `dsu-selectWrap`,
567
589
  onBlur: (e) => {
568
590
  let t = e.relatedTarget;
569
- t instanceof Node && e.currentTarget.contains(t) || A();
591
+ t instanceof Node && e.currentTarget.contains(t) || j();
570
592
  }
571
593
  }, (0, react.createElement)(`button`, {
572
594
  ref: p,
573
595
  type: `button`,
574
- id: _,
575
- style: { anchorName: v },
596
+ id: y,
597
+ style: { anchorName: b },
576
598
  className: `dsu-select dsu-input`,
577
599
  role: `combobox`,
578
600
  "aria-haspopup": `listbox`,
579
601
  "aria-expanded": l,
580
- "aria-controls": `${h}-list`,
581
- "aria-activedescendant": l && O ? `${h}-${d}` : void 0,
582
- "aria-describedby": y,
602
+ "aria-controls": `${_}-list`,
603
+ "aria-activedescendant": l && k ? `${_}-${d}` : void 0,
604
+ "aria-describedby": x,
583
605
  "data-field": c.field,
584
- disabled: b === !0 || C.length === 0,
606
+ disabled: S === !0 || w.length === 0,
585
607
  onClick: () => {
586
- l ? A() : j();
608
+ l ? j() : M();
587
609
  },
588
- onKeyDown: P
589
- }, (0, react.createElement)(`span`, { className: `dsu-selectValue` }, E), (0, react.createElement)(`svg`, {
610
+ onKeyDown: F
611
+ }, (0, react.createElement)(`span`, { className: `dsu-selectValue` }, D), (0, react.createElement)(`svg`, {
590
612
  className: `dsu-chevron`,
591
613
  width: 14,
592
614
  height: 14,
@@ -600,19 +622,19 @@ function S(c) {
600
622
  strokeLinecap: `round`,
601
623
  strokeLinejoin: `round`
602
624
  }))), (0, react.createElement)(`div`, {
603
- ref: m,
604
- id: `${h}-list`,
625
+ ref: g,
626
+ id: `${_}-list`,
605
627
  role: `listbox`,
606
628
  className: `dsu-menu`,
607
629
  style: {
608
- positionAnchor: v,
630
+ positionAnchor: b,
609
631
  positionTryFallbacks: `flip-block, flip-inline`
610
632
  },
611
633
  "aria-label": c.label,
612
634
  hidden: !l
613
- }, ...F)));
635
+ }, ...I)));
614
636
  }
615
- function C(t) {
637
+ function w(t) {
616
638
  let n = !t.writable || t.busy || !t.dirty, r;
617
639
  return r = t.error === null ? t.writable ? t.dirty ? t.dirtyLabel : t.cleanLabel : t.readOnlyLabel : t.error, (0, react.createElement)(`div`, {
618
640
  className: `dsu-savebar`,
@@ -629,7 +651,10 @@ function C(t) {
629
651
  "data-field": `discard`,
630
652
  disabled: n,
631
653
  onClick: t.onDiscard
632
- }, t.revertLabel), (0, react.createElement)(`span`, { className: t.error === null ? `dsu-status` : `dsu-status dsu-statusError` }, r));
654
+ }, t.revertLabel), (0, react.createElement)(`span`, {
655
+ role: `status`,
656
+ className: t.error === null ? `dsu-status` : `dsu-status dsu-statusError`
657
+ }, r));
633
658
  }
634
659
  // node_modules/@jayyuen66/dsh-plugin-shared/dist/card-diff.js
635
660
  function e$1(t, n, r) {
@@ -1200,7 +1225,7 @@ function numberDisplay(display, schema) {
1200
1225
  /** 检索模型小节:embedding 下拉(按本地后端分组)+ 每组结果数。 */
1201
1226
  function buildModelSection(deps) {
1202
1227
  const { editable, fields, setField, t } = deps;
1203
- const embedding = (0, react.createElement)(S, {
1228
+ const embedding = (0, react.createElement)(C, {
1204
1229
  label: t("embeddingLabel"),
1205
1230
  ...l(t("embeddingHint")),
1206
1231
  field: "defaultEmbedding",
@@ -1211,7 +1236,7 @@ function buildModelSection(deps) {
1211
1236
  setField("defaultEmbedding", next);
1212
1237
  }
1213
1238
  });
1214
- const limit = (0, react.createElement)(v, {
1239
+ const limit = (0, react.createElement)(b, {
1215
1240
  label: t("limitLabel"),
1216
1241
  hint: t("limitInvalid", {
1217
1242
  min: 1,
@@ -1255,7 +1280,7 @@ function buildRebuildField(deps) {
1255
1280
  disabled: rebuild.phase === "running",
1256
1281
  onClick: deps.onRebuild
1257
1282
  }, rebuild.phase === "running" ? t("rebuildRunning") : t("rebuildButton"));
1258
- return (0, react.createElement)(g, {
1283
+ return (0, react.createElement)(v, {
1259
1284
  label: t("rebuildLabel"),
1260
1285
  ...l(rebuildHintText(t, fields.embedding, roots.length > 0)),
1261
1286
  wide: true
@@ -1288,7 +1313,7 @@ function buildRebuildStatusRow(deps) {
1288
1313
  /** 网络与索引小节:传输三档、镜像地址、search-first 开关、配额与时效、工作区重建与守护进程状态。 */
1289
1314
  function buildIndexSection(deps) {
1290
1315
  const { editable, fields, setField, t } = deps;
1291
- const transport = (0, react.createElement)(S, {
1316
+ const transport = (0, react.createElement)(C, {
1292
1317
  label: t("transportLabel"),
1293
1318
  ...l(t("transportHint")),
1294
1319
  field: "transport",
@@ -1299,7 +1324,7 @@ function buildIndexSection(deps) {
1299
1324
  setField("transport", next);
1300
1325
  }
1301
1326
  });
1302
- const endpoint = (0, react.createElement)(y, {
1327
+ const endpoint = (0, react.createElement)(x, {
1303
1328
  label: t("endpointLabel"),
1304
1329
  ...l(t("endpointHint")),
1305
1330
  field: "hfEndpoint",
@@ -1311,7 +1336,7 @@ function buildIndexSection(deps) {
1311
1336
  setField("hfEndpoint", next.trim() === "" ? void 0 : next.trim());
1312
1337
  }
1313
1338
  });
1314
- const enforce = (0, react.createElement)(_, {
1339
+ const enforce = (0, react.createElement)(y, {
1315
1340
  label: t("enforceLabel"),
1316
1341
  ...l(t("enforceHint")),
1317
1342
  field: "enforceSearchFirst",
@@ -1321,7 +1346,7 @@ function buildIndexSection(deps) {
1321
1346
  setField("enforceSearchFirst", next);
1322
1347
  }
1323
1348
  });
1324
- const budget = (0, react.createElement)(v, {
1349
+ const budget = (0, react.createElement)(b, {
1325
1350
  label: t("budgetLabel"),
1326
1351
  ...l(t("budgetHint", { default: 3 })),
1327
1352
  field: "grepBudgetPerSearch",
@@ -1336,7 +1361,7 @@ function buildIndexSection(deps) {
1336
1361
  setField("grepBudgetPerSearch", next);
1337
1362
  }
1338
1363
  });
1339
- const window = (0, react.createElement)(v, {
1364
+ const window = (0, react.createElement)(b, {
1340
1365
  label: t("windowLabel"),
1341
1366
  ...l(t("windowHint", { default: 10 })),
1342
1367
  field: "unlockWindowMin",
@@ -1356,7 +1381,7 @@ function buildIndexSection(deps) {
1356
1381
  /** 卡片主体:检索模型 / 网络与索引两节 + 保存条。 */
1357
1382
  function buildCardBody(deps) {
1358
1383
  const { t } = deps;
1359
- const saveBar = (0, react.createElement)(C, {
1384
+ const saveBar = (0, react.createElement)(w, {
1360
1385
  dirty: deps.dirty,
1361
1386
  busy: deps.busy,
1362
1387
  writable: deps.writable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayyuen66/dsh-zvec-grep",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "dsh 工作区语义检索插件(zg):zg_search / zg_index / zg_status + 本地 embedding 设置卡片 + systemPrompt 路由规则 + guard 安全兜底。",
5
5
  "keywords": [
6
6
  "cordis",
@@ -51,7 +51,7 @@
51
51
  "registry": "https://registry.npmjs.org"
52
52
  },
53
53
  "dependencies": {
54
- "@jayyuen66/dsh-plugin-shared": "^0.2.5",
54
+ "@jayyuen66/dsh-plugin-shared": "^0.2.8",
55
55
  "zod": "4.6.7"
56
56
  },
57
57
  "devDependencies": {