@n-uf/placement 26.12.3 → 26.12.5
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/CHANGELOG.md +35 -0
- package/dist/stack.d.ts +34 -15
- package/dist/stack.js +44 -25
- package/dist/stack.js.map +1 -1
- package/dist/tiling.js +1 -1
- package/dist/tiling.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,41 @@ Versions are calendar versions, `YY.M.R` (year, month of the release, counter wi
|
|
|
5
5
|
|
|
6
6
|
Unreleased entries live in `changes/` until a release joins them.
|
|
7
7
|
|
|
8
|
+
## 26.12.5
|
|
9
|
+
|
|
10
|
+
- **Fixed:** growing back brings an item out of the » into a form too wide across. Giving way keeps an item's last
|
|
11
|
+
drawn form when it is wider than the stack's cross size (its `cross.min` over it) and its next form is the », but
|
|
12
|
+
growing back refused that form, so the item stayed in the » with room to spare. Growing back now refuses only a form
|
|
13
|
+
the way down would step out of across, so it is the exact reverse of giving way here too.
|
|
14
|
+
|
|
15
|
+
## 26.12.4
|
|
16
|
+
|
|
17
|
+
- **Changed (breaking):** a form pinned by adding 1000 to its rank moves that pin to `level` (`StackForm.level`, a
|
|
18
|
+
whole number 0 or more). Such a form still orders the same on a bar, but in a column drawn as a rail it now counts as
|
|
19
|
+
a rank of 1000 or more, so panel tiles go into the » after it steps, not before. The give-way order reads the level
|
|
20
|
+
first, then the rank, everywhere: giving way, a batch into the » (which never takes a step into a higher level while
|
|
21
|
+
a lower one is open), growing back and the squeeze, so a priority can no longer carry a step past a pin.
|
|
22
|
+
`controlLadder`'s `keep` now sets `level` on the partial folds, `fold`, `menu` and the column's menu, and its ranks
|
|
23
|
+
are the same at every `keep`. `RANK_LEVEL` is removed. A rank may be any finite number, negative included, and ranks
|
|
24
|
+
are relative. See docs/decisions/0021-a-pin-is-a-forms-level.md.
|
|
25
|
+
- **Changed (breaking, behavior):** a bar with a growing title and a pinned group now shrinks the title before the
|
|
26
|
+
pinned group hides a control. While a title holds its natural length, steps are taken only at the lowest open level,
|
|
27
|
+
the title's shrink counted at its own level, so a title given a level shrinks after every step of a lower level,
|
|
28
|
+
whatever its kind; the pinned group's tier steps (level 0) still shorten its controls before the title shrinks.
|
|
29
|
+
Before, the pinned group's partial folds, being `row` steps, were taken while the title kept its natural length.
|
|
30
|
+
- **Added:** `formLevel` and `formRank`, the one reading of a form's level (a whole number, 0 or more; anything else
|
|
31
|
+
0) and rank (any finite number; anything else 0).
|
|
32
|
+
- **Added:** `StackStep.held`, set on a stack with a growing fixed item (a title): whether it still held its natural
|
|
33
|
+
length when the step was taken. A history without it (from an older version) is read by each step's kind: a step to
|
|
34
|
+
a form of the same kind was taken while the title held.
|
|
35
|
+
- **Fixed:** growing back beside a title is the exact reverse of giving way. A step taken after the title shrank came
|
|
36
|
+
back only with the title at its natural length, so growth could stall, and a step into the » that opened only after
|
|
37
|
+
the title shrank could leave items in the » with room to spare. Each step now comes back under the hold it was taken
|
|
38
|
+
with, and a fit whose history has a step taken after the title's shrink starts with the title shrunk, as a fresh fit
|
|
39
|
+
has it.
|
|
40
|
+
- **Fixed:** a batch into the » of a lower level than a title's now comes before the title shrinks, like every other
|
|
41
|
+
step of a lower level.
|
|
42
|
+
|
|
8
43
|
## 26.12.3
|
|
9
44
|
|
|
10
45
|
- **Changed (breaking, behavior):** `decideSplit` and `layoutSplit`: a fixed length that is not kept is now held
|
package/dist/stack.d.ts
CHANGED
|
@@ -118,12 +118,21 @@ interface StackForm {
|
|
|
118
118
|
/** Icons only. Default: true for the kind `icons`. A window model's compact (icons-only) edge takes it. */
|
|
119
119
|
readonly compact?: boolean;
|
|
120
120
|
/**
|
|
121
|
-
* Give-way order (default 0)
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
121
|
+
* Give-way order within the form's `level` (default 0): any finite number, negative included; anything else reads 0
|
|
122
|
+
* (`formRank`). When the stack is too long, the step taken is the one into the next form of the lowest level, then of
|
|
123
|
+
* the lowest rank, across all items (the form the item would take, not the one it leaves); ties go unkept before kept,
|
|
124
|
+
* then the item used longest ago, then the later in the stack. Adding one number to every rank of a stack changes
|
|
125
|
+
* nothing.
|
|
125
126
|
*/
|
|
126
127
|
readonly rank?: number;
|
|
128
|
+
/**
|
|
129
|
+
* The form's level (default 0): a whole number, 0 or more; anything else reads 0 (`formLevel`). A level comes before
|
|
130
|
+
* the rank in the order: every step into a form of a lower level is taken before any step into a form of a higher
|
|
131
|
+
* level, whatever their ranks. It is a pin: `controlLadder` sets it from `keep` on a pinned group's partial folds, fold
|
|
132
|
+
* and menu, so every group of a lower level gives way entirely before the pinned one folds a control. Room coming back
|
|
133
|
+
* reads the same order backwards.
|
|
134
|
+
*/
|
|
135
|
+
readonly level?: number;
|
|
127
136
|
/**
|
|
128
137
|
* A form whose length depends on the cross size it gets (meant for a column of words). With it, `main` and `cross` are
|
|
129
138
|
* computed and the given ones ignored: the rows are laid once the stack's cross size is known (beside the lead, a
|
|
@@ -189,6 +198,10 @@ declare const itemSteps: (item: {
|
|
|
189
198
|
readonly fixed?: boolean;
|
|
190
199
|
readonly stepping?: boolean;
|
|
191
200
|
}) => boolean;
|
|
201
|
+
/** A form's rank as the solver reads it: `rank` when it is a finite number, else 0. */
|
|
202
|
+
declare const formRank: (f: StackForm) => number;
|
|
203
|
+
/** A form's level as the solver reads it: `level` when it is a whole number, 0 or more, else 0. */
|
|
204
|
+
declare const formLevel: (f: StackForm) => number;
|
|
192
205
|
/** Whether a form has no room of its own, the » entry standing for it (`menu`, default: the kind `menu`). */
|
|
193
206
|
declare const formMenu: (f: StackForm) => boolean;
|
|
194
207
|
/** Whether a form is drawn at its own size across under `ownCross` (`ownCross`, default: the group kinds). */
|
|
@@ -446,6 +459,13 @@ interface StackStep {
|
|
|
446
459
|
readonly from: number;
|
|
447
460
|
readonly to: number;
|
|
448
461
|
readonly batch?: number;
|
|
462
|
+
/**
|
|
463
|
+
* Set on a stack with a growing fixed item (a title): `true` when the step was taken while it held its natural length,
|
|
464
|
+
* `false` when it came after its shrink. Growing back undoes a step under the same hold, and a fit whose history still
|
|
465
|
+
* holds a step taken after the shrink starts with the title shrunk. Without it (a history from an older version) the
|
|
466
|
+
* step's level and kind stand in.
|
|
467
|
+
*/
|
|
468
|
+
readonly held?: boolean;
|
|
449
469
|
}
|
|
450
470
|
/** What `fitStack` takes besides the input. */
|
|
451
471
|
interface FitOptions {
|
|
@@ -488,7 +508,7 @@ interface FitOptions {
|
|
|
488
508
|
* step that can't be undone stops all growth. So growing back is exactly the reverse of giving way: at every length the
|
|
489
509
|
* way back holds what the way down held. A `previous` without a history (built by hand, or by an older version) grows
|
|
490
510
|
* the old way: a fresh fit that is a pure gain over the kept one, else the item that gave way most recently by its
|
|
491
|
-
* rank, `kept` and age first, one at a time, menu items out only when that keeps the order. A `previous` with no `need`
|
|
511
|
+
* level, rank, `kept` and age first, one at a time, menu items out only when that keeps the order. A `previous` with no `need`
|
|
492
512
|
* (one an app built by hand) is no help and the fresh fit is returned.
|
|
493
513
|
*/
|
|
494
514
|
declare function fitStack(input: StackInput, options?: FitOptions): StackFit;
|
|
@@ -525,6 +545,9 @@ declare function fitStack(input: StackInput, options?: FitOptions): StackFit;
|
|
|
525
545
|
* Ranks are spaced by step type in fixed bands whatever a group's tier count: tier steps in [100, 400), partial folds
|
|
526
546
|
* 400 + k / n, fold 500, menu 600. So the same-tier steps of several groups interleave, and a partial fold never comes
|
|
527
547
|
* before another group's tier step, even when the groups have different tier counts.
|
|
548
|
+
*
|
|
549
|
+
* A pin (`keep`) is a level, not a rank: the pinned group's partial folds, fold and menu carry `level: keep`, so they come
|
|
550
|
+
* after every step of a lower level, and their ranks stay the same.
|
|
528
551
|
*/
|
|
529
552
|
|
|
530
553
|
/** One control of a group: an id and its length along the stack per tier. */
|
|
@@ -562,8 +585,11 @@ interface ControlLadderSpec {
|
|
|
562
585
|
readonly cross?: number;
|
|
563
586
|
};
|
|
564
587
|
/**
|
|
565
|
-
* A pinned primary's level (default 0
|
|
566
|
-
*
|
|
588
|
+
* A pinned primary's level (default 0; a whole number, 0 or more, anything else reads 0, as `StackForm.level`): its
|
|
589
|
+
* partial folds, fold and menu (and the column's menu) carry it as their `level`, so every group of a lower level gives
|
|
590
|
+
* way entirely before it folds a control, and a growing title of a lower level shrinks first, whatever the ranks and
|
|
591
|
+
* priorities. Tier steps and the first row stay at level 0 (they shorten its controls before a title shrinks), and the
|
|
592
|
+
* ranks are the same at every level.
|
|
567
593
|
*/
|
|
568
594
|
readonly keep?: number;
|
|
569
595
|
}
|
|
@@ -572,13 +598,6 @@ interface ControlLadder {
|
|
|
572
598
|
readonly row: readonly StackForm[];
|
|
573
599
|
readonly column?: readonly StackForm[];
|
|
574
600
|
}
|
|
575
|
-
/**
|
|
576
|
-
* One level of give-way ranks: a pin (`ControlLadderSpec.keep`) raises a group's later forms by this much per level, so a
|
|
577
|
-
* form's rank is its level times `RANK_LEVEL` plus its rank within the level (`rank % RANK_LEVEL`, under `RANK_LEVEL`).
|
|
578
|
-
* A consumer that ranks a step of its own after "every shorter drawn form" of a stack reads the forms' ranks within their
|
|
579
|
-
* level, so a pin moves its own item and nothing else.
|
|
580
|
-
*/
|
|
581
|
-
declare const RANK_LEVEL = 1000;
|
|
582
601
|
/** `spec`'s forms: the row ladder, and the column ladder when `spec.column` is given. Pure. */
|
|
583
602
|
declare function controlLadder(spec: ControlLadderSpec): ControlLadder;
|
|
584
603
|
|
|
@@ -733,4 +752,4 @@ interface FloatFitOptions {
|
|
|
733
752
|
}
|
|
734
753
|
declare function fitFloat(want: Rect, stage: Rect, avoid?: readonly Rect[], options?: FloatFitOptions): FloatFit;
|
|
735
754
|
|
|
736
|
-
export { type ControlLadder, type ControlLadderSpec, type CrossLimits, DEFAULT_MENU, DEFAULT_RAIL, type EdgeBand, type EdgeCut, type FitOptions, type FloatFit, type FloatFitOptions, type GroupFormKind, type LadderControl, type MainSize, type PanelFormKind, type PlacedStackItem,
|
|
755
|
+
export { type ControlLadder, type ControlLadderSpec, type CrossLimits, DEFAULT_MENU, DEFAULT_RAIL, type EdgeBand, type EdgeCut, type FitOptions, type FloatFit, type FloatFitOptions, type GroupFormKind, type LadderControl, type MainSize, type PanelFormKind, type PlacedStackItem, type StackAxis, type StackDivider, type StackFit, type StackForm, type StackFormKind, type StackGap, type StackGapOptions, type StackGapRefusal, type StackInput, type StackItem, type StackLengths, type StackMenu, type StackNote, type StackNoteCode, type StackStep, type WrapSpec, controlLadder, cutEdges, dividers, fitFloat, fitStack, formBody, formCompact, formCrossMin, formFitsCross, formFolded, formLevel, formMain, formMenu, formOwnCross, formRank, formSetsCross, formStepGroup, itemSteps, resetBetween, resetLengths, resizeBetween, stackGaps, withItem, wrapCross, wrapLines, wrapRows };
|
package/dist/stack.js
CHANGED
|
@@ -51,6 +51,8 @@ function cutEdges(stage, bands) {
|
|
|
51
51
|
|
|
52
52
|
// src/stack/model.ts
|
|
53
53
|
var itemSteps = (item) => item.fixed !== true || item.stepping === true;
|
|
54
|
+
var formRank = (f) => typeof f.rank === "number" && Number.isFinite(f.rank) ? f.rank : 0;
|
|
55
|
+
var formLevel = (f) => typeof f.level === "number" && Number.isInteger(f.level) && f.level > 0 ? f.level : 0;
|
|
54
56
|
var formMenu = (f) => f.menu ?? f.kind === "menu";
|
|
55
57
|
var formOwnCross = (f) => f.ownCross ?? GROUP_KINDS.has(f.kind);
|
|
56
58
|
var formStepGroup = (f) => f.stepGroup ?? f.kind;
|
|
@@ -166,9 +168,10 @@ var finite2 = (x, fallback = 0) => Number.isFinite(x) ? x : fallback;
|
|
|
166
168
|
var mainOf = formMain;
|
|
167
169
|
var crossMin = formCrossMin;
|
|
168
170
|
var crossNatural = (f) => f.wrap ? wrapCross(f.wrap).natural : finite2(f.cross.natural);
|
|
169
|
-
var
|
|
170
|
-
function givesWayBefore(items, a,
|
|
171
|
-
|
|
171
|
+
var formOrder = (fa, fb) => formLevel(fa) - formLevel(fb) || formRank(fa) - formRank(fb);
|
|
172
|
+
function givesWayBefore(items, a, fa, b, fb) {
|
|
173
|
+
const order = formOrder(fa, fb);
|
|
174
|
+
if (order !== 0) return order;
|
|
172
175
|
const ka = items[a].kept ? 1 : 0;
|
|
173
176
|
const kb = items[b].kept ? 1 : 0;
|
|
174
177
|
if (ka !== kb) return ka - kb;
|
|
@@ -181,7 +184,7 @@ function victim(items, to) {
|
|
|
181
184
|
let best = -1;
|
|
182
185
|
for (let i = 0; i < items.length; i++) {
|
|
183
186
|
if (to[i] < 0 || !itemSteps(items[i])) continue;
|
|
184
|
-
if (best < 0 || givesWayBefore(items, i,
|
|
187
|
+
if (best < 0 || givesWayBefore(items, i, items[i].forms[to[i]], best, items[best].forms[to[best]]) < 0) best = i;
|
|
185
188
|
}
|
|
186
189
|
return best;
|
|
187
190
|
}
|
|
@@ -247,7 +250,7 @@ function solve(input, previous, seed, grow = false) {
|
|
|
247
250
|
const menuOrder = [];
|
|
248
251
|
const step = (i, j, batch) => {
|
|
249
252
|
if (!firstStep.includes(i)) firstStep.push(i);
|
|
250
|
-
hist.push({ id: items[i].id, from: at[i], to: j, ...batch !== void 0 ? { batch } : {} });
|
|
253
|
+
hist.push({ id: items[i].id, from: at[i], to: j, ...batch !== void 0 ? { batch } : {}, ...idx.some(holds) ? { held: hold } : {} });
|
|
251
254
|
withHistory.add(items[i].id);
|
|
252
255
|
at[i] = j;
|
|
253
256
|
if (isMenu(form(i)) && !menuOrder.includes(i)) menuOrder.push(i);
|
|
@@ -269,6 +272,7 @@ function solve(input, previous, seed, grow = false) {
|
|
|
269
272
|
};
|
|
270
273
|
const holds = (i) => !itemSteps(items[i]) && form(i).main.grows === true;
|
|
271
274
|
let hold = idx.some(holds);
|
|
275
|
+
const holdLevel = () => idx.reduce((m, i) => holds(i) ? Math.min(m, formLevel(form(i))) : m, Infinity);
|
|
272
276
|
const minSumWith = (held) => {
|
|
273
277
|
const c = items.some((it) => it.forms.some((f) => f.wrap)) ? crossOf() : 0;
|
|
274
278
|
return idx.reduce((s, i) => s + mainOf(form(i), held && holds(i) ? "natural" : "min", c), 0) + (inMenu() ? menuMain(input) : 0) + gapsOf() + sp.start + sp.end;
|
|
@@ -318,9 +322,10 @@ function solve(input, previous, seed, grow = false) {
|
|
|
318
322
|
if (f.wrap) return !formFitsCross(f, cross2);
|
|
319
323
|
return crossMin(f) > cross2 + EPS;
|
|
320
324
|
};
|
|
325
|
+
const stepsAcross = (i, cross2) => itemSteps(items[i]) && tooWide(i, cross2) && canStep(i) && !isMenu(items[i].forms[nextOffered(i)]);
|
|
321
326
|
if (seed) seed.need = minSumWith(false);
|
|
322
327
|
if (grow) {
|
|
323
|
-
const comesBefore = (a, b) => givesWayBefore(items, b,
|
|
328
|
+
const comesBefore = (a, b) => givesWayBefore(items, b, items[b].forms[at[b]], a, items[a].forms[at[a]]) < 0;
|
|
324
329
|
const index = new Map(items.map((it, i) => [it.id, i]));
|
|
325
330
|
let stuck = false;
|
|
326
331
|
const undoes = (n, c0) => {
|
|
@@ -328,9 +333,10 @@ function solve(input, previous, seed, grow = false) {
|
|
|
328
333
|
const changed = [...new Set(group.map((s) => index.get(s.id)))];
|
|
329
334
|
const was = changed.map((i) => at[i]);
|
|
330
335
|
const forms = (s) => items[index.get(s.id)].forms;
|
|
331
|
-
|
|
336
|
+
const held = (s) => s.held ?? formStepGroup(forms(s)[s.from]) === formStepGroup(forms(s)[s.to]);
|
|
337
|
+
hold = group.every(held) && idx.some(holds);
|
|
332
338
|
for (const s of [...group].reverse()) at[index.get(s.id)] = s.from;
|
|
333
|
-
if (minSum() <= length + EPS && crossOf() === c0 && changed.every((j) => !
|
|
339
|
+
if (minSum() <= length + EPS && crossOf() === c0 && changed.every((j) => !stepsAcross(j, c0))) return true;
|
|
334
340
|
changed.forEach((i, k) => at[i] = was[k]);
|
|
335
341
|
return false;
|
|
336
342
|
};
|
|
@@ -354,7 +360,7 @@ function solve(input, previous, seed, grow = false) {
|
|
|
354
360
|
for (; ; ) {
|
|
355
361
|
if (stuck) break;
|
|
356
362
|
const c0 = crossOf();
|
|
357
|
-
const fitsWith = (changed) => minSum() <= length + EPS && crossOf() === c0 && changed.every((j) => !
|
|
363
|
+
const fitsWith = (changed) => minSum() <= length + EPS && crossOf() === c0 && changed.every((j) => !stepsAcross(j, c0));
|
|
358
364
|
const queue = idx.filter((i) => itemSteps(items[i]) && at[i] > start[i] && !withHistory.has(items[i].id)).sort((a, b) => comesBefore(a, b) ? -1 : 1);
|
|
359
365
|
const next = queue[0];
|
|
360
366
|
if (next === void 0) break;
|
|
@@ -374,7 +380,7 @@ function solve(input, previous, seed, grow = false) {
|
|
|
374
380
|
for (const [q, i] of queue.entries()) {
|
|
375
381
|
if (!isMenu(form(i))) continue;
|
|
376
382
|
const ahead = queue.slice(0, q);
|
|
377
|
-
if (!ahead.every((j) => isMenu(form(j)) || at[i] - 1 - start[i] >= at[j] - start[j] &&
|
|
383
|
+
if (!ahead.every((j) => isMenu(form(j)) || at[i] - 1 - start[i] >= at[j] - start[j] && formOrder(form(i), form(j)) >= 0)) break;
|
|
378
384
|
inside2.push(i);
|
|
379
385
|
}
|
|
380
386
|
let out = false;
|
|
@@ -388,7 +394,7 @@ function solve(input, previous, seed, grow = false) {
|
|
|
388
394
|
if (!out) break;
|
|
389
395
|
}
|
|
390
396
|
}
|
|
391
|
-
hold = idx.some(holds);
|
|
397
|
+
hold = idx.some(holds) && !hist.some((s) => s.held === false);
|
|
392
398
|
let cross = crossOf();
|
|
393
399
|
let overflow = 0;
|
|
394
400
|
const guard = 2 * items.reduce((s, it) => s + it.forms.length, 0) + 2;
|
|
@@ -396,7 +402,7 @@ function solve(input, previous, seed, grow = false) {
|
|
|
396
402
|
cross = crossOf();
|
|
397
403
|
let stepped = false;
|
|
398
404
|
for (const i of idx) {
|
|
399
|
-
if (
|
|
405
|
+
if (stepsAcross(i, cross)) {
|
|
400
406
|
step(i, nextOffered(i));
|
|
401
407
|
stepped = true;
|
|
402
408
|
}
|
|
@@ -406,13 +412,24 @@ function solve(input, previous, seed, grow = false) {
|
|
|
406
412
|
if (over <= EPS) break;
|
|
407
413
|
const to = idx.map((i) => itemSteps(items[i]) ? stepTo(i) : -1);
|
|
408
414
|
if (hold) {
|
|
415
|
+
const low = idx.reduce((m, i) => to[i] >= 0 ? Math.min(m, formLevel(items[i].forms[to[i]])) : m, holdLevel());
|
|
409
416
|
const variant = victim(
|
|
410
417
|
items,
|
|
411
|
-
idx.map((i) => to[i] >= 0 && sameKind(i, to[i]) ? to[i] : -1)
|
|
418
|
+
idx.map((i) => to[i] >= 0 && sameKind(i, to[i]) && formLevel(items[i].forms[to[i]]) <= low ? to[i] : -1)
|
|
412
419
|
);
|
|
413
|
-
if (variant >= 0)
|
|
414
|
-
|
|
415
|
-
|
|
420
|
+
if (variant >= 0) {
|
|
421
|
+
step(variant, to[variant]);
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
const top = holdLevel();
|
|
425
|
+
const below = idx.map((i) => {
|
|
426
|
+
const j = to[i] < 0 && !inMenu() && itemSteps(items[i]) ? menuFormAfter(i) : -1;
|
|
427
|
+
return j >= 0 && formLevel(items[i].forms[j]) < top ? j : -1;
|
|
428
|
+
});
|
|
429
|
+
if (low >= top && menuBatch(below) === null) {
|
|
430
|
+
hold = false;
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
416
433
|
}
|
|
417
434
|
const pool = idx.map((i) => to[i] < 0 && !inMenu() && itemSteps(items[i]) ? menuFormAfter(i) : -1);
|
|
418
435
|
const v = victim(
|
|
@@ -420,7 +437,8 @@ function solve(input, previous, seed, grow = false) {
|
|
|
420
437
|
idx.map((i) => to[i] >= 0 ? to[i] : pool[i])
|
|
421
438
|
);
|
|
422
439
|
if (v >= 0 && to[v] < 0) {
|
|
423
|
-
const
|
|
440
|
+
const open = idx.reduce((m, i) => to[i] >= 0 && itemSteps(items[i]) ? Math.min(m, formLevel(items[i].forms[to[i]])) : m, Infinity);
|
|
441
|
+
const batch = menuBatch(pool.map((j, i) => j >= 0 && formLevel(items[i].forms[j]) <= open ? j : -1));
|
|
424
442
|
if (batch) {
|
|
425
443
|
const id = batches++;
|
|
426
444
|
for (const [i, j] of batch) step(i, j, id);
|
|
@@ -496,7 +514,7 @@ function solve(input, previous, seed, grow = false) {
|
|
|
496
514
|
short -= take;
|
|
497
515
|
};
|
|
498
516
|
const oneByOne = (group) => {
|
|
499
|
-
const order = [...group].sort((a, b) => givesWayBefore(items, a,
|
|
517
|
+
const order = [...group].sort((a, b) => givesWayBefore(items, a, form(a), b, form(b)));
|
|
500
518
|
for (const i of order) {
|
|
501
519
|
if (short <= 0) return;
|
|
502
520
|
const take = Math.min(short, size.get(i));
|
|
@@ -560,16 +578,16 @@ var sizesOf = (fit) => sizes.get(fit);
|
|
|
560
578
|
// src/stack/ladder.ts
|
|
561
579
|
var nonNeg2 = (x) => typeof x === "number" && Number.isFinite(x) ? Math.max(0, x) : 0;
|
|
562
580
|
var RANK_TIER = 100;
|
|
563
|
-
var RANK_LEVEL = 1e3;
|
|
564
581
|
function controlLadder(spec) {
|
|
565
|
-
const
|
|
582
|
+
const level = formLevel({ kind: "row", main: { min: 0, natural: 0 }, cross: { natural: 0 }, ...spec.keep !== void 0 ? { level: spec.keep } : {} });
|
|
583
|
+
const pin = level > 0 ? { level } : {};
|
|
566
584
|
const cross = nonNeg2(spec.cross);
|
|
567
585
|
const grip = nonNeg2(spec.grip);
|
|
568
586
|
const gap = nonNeg2(spec.gap);
|
|
569
587
|
const more = nonNeg2(spec.more);
|
|
570
588
|
const column = spec.column ? [
|
|
571
589
|
{ kind: "icons", main: { min: nonNeg2(spec.column.icons), natural: nonNeg2(spec.column.icons) }, cross: { natural: nonNeg2(spec.column.cross ?? spec.cross) }, ...grip > 0 ? { grip } : {} },
|
|
572
|
-
{ kind: "menu", main: { min: 0, natural: 0 }, cross: { natural: 0 }, ...
|
|
590
|
+
{ kind: "menu", main: { min: 0, natural: 0 }, cross: { natural: 0 }, ...pin }
|
|
573
591
|
] : void 0;
|
|
574
592
|
const controls = spec.controls;
|
|
575
593
|
const n = controls.length;
|
|
@@ -595,10 +613,10 @@ function controlLadder(spec) {
|
|
|
595
613
|
for (let k = 1; k < n; k++) {
|
|
596
614
|
const hidden = new Set(order.slice(0, k));
|
|
597
615
|
const shown = all.filter((i) => !hidden.has(i));
|
|
598
|
-
row.push(form(rowLength(shown, more), { kind: "row", rank: 4 * RANK_TIER + k / n
|
|
616
|
+
row.push(form(rowLength(shown, more), { kind: "row", rank: 4 * RANK_TIER + k / n, ...pin, hides: ids(hidden), tiers: tiersOf(shown) }));
|
|
599
617
|
}
|
|
600
|
-
row.push(form(grip + more, { kind: "fold", rank: 5 * RANK_TIER
|
|
601
|
-
row.push({ kind: "menu", main: { min: 0, natural: 0 }, cross: { natural: 0 }, rank: 6 * RANK_TIER
|
|
618
|
+
row.push(form(grip + more, { kind: "fold", rank: 5 * RANK_TIER, ...pin, hides: ids(new Set(all)) }));
|
|
619
|
+
row.push({ kind: "menu", main: { min: 0, natural: 0 }, cross: { natural: 0 }, rank: 6 * RANK_TIER, ...pin });
|
|
602
620
|
return { row, ...column ? { column } : {} };
|
|
603
621
|
}
|
|
604
622
|
|
|
@@ -882,7 +900,6 @@ function fitFloat(want, stage, avoid = [], options = {}) {
|
|
|
882
900
|
export {
|
|
883
901
|
DEFAULT_MENU,
|
|
884
902
|
DEFAULT_RAIL,
|
|
885
|
-
RANK_LEVEL,
|
|
886
903
|
controlLadder,
|
|
887
904
|
cutEdges,
|
|
888
905
|
dividers,
|
|
@@ -893,9 +910,11 @@ export {
|
|
|
893
910
|
formCrossMin,
|
|
894
911
|
formFitsCross,
|
|
895
912
|
formFolded,
|
|
913
|
+
formLevel,
|
|
896
914
|
formMain,
|
|
897
915
|
formMenu,
|
|
898
916
|
formOwnCross,
|
|
917
|
+
formRank,
|
|
899
918
|
formSetsCross,
|
|
900
919
|
formStepGroup,
|
|
901
920
|
itemSteps,
|