@wildwinter/expr-editor 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -383,8 +383,14 @@ function openPopover(anchor, render, opts = {}) {
383
383
  container.append(pop);
384
384
  const a = anchor.getBoundingClientRect();
385
385
  const ph = pop.getBoundingClientRect();
386
- let top = a.bottom + 4;
387
- if (top + ph.height > window.innerHeight - 8 && a.top - ph.height - 4 > 8) top = a.top - ph.height - 4;
386
+ const GAP = 4;
387
+ const EDGE = 8;
388
+ const below = window.innerHeight - EDGE - (a.bottom + GAP);
389
+ const above = a.top - GAP - EDGE;
390
+ const flip = ph.height > below && above > below;
391
+ const room = flip ? above : below;
392
+ const top = flip ? a.top - Math.min(ph.height, above) - GAP : a.bottom + GAP;
393
+ if (ph.height > room) pop.style.maxHeight = `${Math.max(96, Math.round(room))}px`;
388
394
  let left = a.left;
389
395
  if (left + ph.width > window.innerWidth - 8) left = Math.max(8, window.innerWidth - 8 - ph.width);
390
396
  if (container === document.body) {
@@ -1385,6 +1391,7 @@ function valueWizard(opts) {
1385
1391
  const isStage = opts.expectedType === "quality";
1386
1392
  const flagsReady = opts.expectedType === "flags" && opts.expectedRef !== void 0;
1387
1393
  let kind = opts.expectedType === "number" ? "number" : opts.expectedType === "string" ? "text" : opts.expectedType === "boolean" ? "bool" : (opts.expectedType === "enum" || opts.expectedType === "quality") && choices?.length ? "enum" : flagsReady ? "flags" : "menu";
1394
+ let flagSign = "+";
1388
1395
  const draw = () => {
1389
1396
  body.replaceChildren();
1390
1397
  const other = () => button("exed-vwiz-other", "\u21A9 a different kind", () => {
@@ -1421,12 +1428,23 @@ function valueWizard(opts) {
1421
1428
  case "flags": {
1422
1429
  const flags = opts.expectedFlags ?? [];
1423
1430
  if (!flags.length) body.append(el("div", "exed-hint", ["This property declares no flag values yet."]));
1424
- for (const sign of ["+", "-"]) {
1425
- if (!flags.length) break;
1426
- body.append(el("div", "exed-vwiz-note", [sign === "+" ? "Set a flag:" : "Clear a flag:"]));
1427
- const row = el("div", "exed-field-row");
1428
- for (const f of flags) row.append(optBtn(`${sign} ${f}`, () => opts.onCommit(flagChangeSrc(opts.expectedRef, sign, f))));
1429
- body.append(row);
1431
+ else {
1432
+ const signRow = el("div", "exed-field-row");
1433
+ signRow.append(
1434
+ button(`exed-opt${flagSign === "+" ? " sel" : ""}`, "\uFF0B set", () => {
1435
+ flagSign = "+";
1436
+ draw();
1437
+ }),
1438
+ button(`exed-opt${flagSign === "-" ? " sel" : ""}`, "\uFF0D clear", () => {
1439
+ flagSign = "-";
1440
+ draw();
1441
+ })
1442
+ );
1443
+ body.append(signRow);
1444
+ body.append(el("div", "exed-vwiz-note", [flagSign === "+" ? "Set a flag:" : "Clear a flag:"]));
1445
+ const list = el("div", "exed-picker-list");
1446
+ for (const f of flags) list.append(optBtn(`${flagSign} ${f}`, () => opts.onCommit(flagChangeSrc(opts.expectedRef, flagSign, f))));
1447
+ body.append(list);
1430
1448
  }
1431
1449
  body.append(button("exed-vwiz-other", "\u21A9 a different kind (replaces every flag)", () => {
1432
1450
  kind = "menu";