@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.cjs +26 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -0
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
387
|
-
|
|
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
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
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";
|