@wildwinter/expr-editor 0.15.0 → 0.15.2

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.cjs CHANGED
@@ -385,8 +385,14 @@ function openPopover(anchor, render, opts = {}) {
385
385
  container.append(pop);
386
386
  const a = anchor.getBoundingClientRect();
387
387
  const ph = pop.getBoundingClientRect();
388
- let top = a.bottom + 4;
389
- if (top + ph.height > window.innerHeight - 8 && a.top - ph.height - 4 > 8) top = a.top - ph.height - 4;
388
+ const GAP = 4;
389
+ const EDGE = 8;
390
+ const below = window.innerHeight - EDGE - (a.bottom + GAP);
391
+ const above = a.top - GAP - EDGE;
392
+ const flip = ph.height > below && above > below;
393
+ const room = flip ? above : below;
394
+ const top = flip ? a.top - Math.min(ph.height, above) - GAP : a.bottom + GAP;
395
+ if (ph.height > room) pop.style.maxHeight = `${Math.max(96, Math.round(room))}px`;
390
396
  let left = a.left;
391
397
  if (left + ph.width > window.innerWidth - 8) left = Math.max(8, window.innerWidth - 8 - ph.width);
392
398
  if (container === document.body) {
@@ -1387,6 +1393,7 @@ function valueWizard(opts) {
1387
1393
  const isStage = opts.expectedType === "quality";
1388
1394
  const flagsReady = opts.expectedType === "flags" && opts.expectedRef !== void 0;
1389
1395
  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";
1396
+ let flagSign = "+";
1390
1397
  const draw = () => {
1391
1398
  body.replaceChildren();
1392
1399
  const other = () => button("exed-vwiz-other", "\u21A9 a different kind", () => {
@@ -1423,12 +1430,23 @@ function valueWizard(opts) {
1423
1430
  case "flags": {
1424
1431
  const flags = opts.expectedFlags ?? [];
1425
1432
  if (!flags.length) body.append(el("div", "exed-hint", ["This property declares no flag values yet."]));
1426
- for (const sign of ["+", "-"]) {
1427
- if (!flags.length) break;
1428
- body.append(el("div", "exed-vwiz-note", [sign === "+" ? "Set a flag:" : "Clear a flag:"]));
1429
- const row = el("div", "exed-field-row");
1430
- for (const f of flags) row.append(optBtn(`${sign} ${f}`, () => opts.onCommit(flagChangeSrc(opts.expectedRef, sign, f))));
1431
- body.append(row);
1433
+ else {
1434
+ const signRow = el("div", "exed-field-row");
1435
+ signRow.append(
1436
+ button(`exed-opt${flagSign === "+" ? " sel" : ""}`, "\uFF0B set", () => {
1437
+ flagSign = "+";
1438
+ draw();
1439
+ }),
1440
+ button(`exed-opt${flagSign === "-" ? " sel" : ""}`, "\uFF0D clear", () => {
1441
+ flagSign = "-";
1442
+ draw();
1443
+ })
1444
+ );
1445
+ body.append(signRow);
1446
+ body.append(el("div", "exed-vwiz-note", [flagSign === "+" ? "Set a flag:" : "Clear a flag:"]));
1447
+ const list = el("div", "exed-picker-list");
1448
+ for (const f of flags) list.append(optBtn(`${flagSign} ${f}`, () => opts.onCommit(flagChangeSrc(opts.expectedRef, flagSign, f))));
1449
+ body.append(list);
1432
1450
  }
1433
1451
  body.append(button("exed-vwiz-other", "\u21A9 a different kind (replaces every flag)", () => {
1434
1452
  kind = "menu";