@gjermundgaraba-designs/pixel-paper 0.20.0 → 0.20.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/src/commandPalette/commandPalette.d.ts +4 -3
- package/dist/src/commandPalette/commandPalette.d.ts.map +1 -1
- package/dist/src/commandPalette/commandPalette.js +34 -35
- package/dist/src/commandPalette/match.d.ts +5 -2
- package/dist/src/commandPalette/match.d.ts.map +1 -1
- package/dist/src/commandPalette/match.js +14 -3
- package/dist/src/reel/layout.d.ts +2 -1
- package/dist/src/reel/layout.d.ts.map +1 -1
- package/dist/src/reel/layout.js +22 -4
- package/package.json +1 -1
- package/src/commandPalette/commandPalette.ts +11 -15
- package/src/commandPalette/match.ts +22 -5
- package/src/reel/layout.ts +27 -4
|
@@ -425,9 +425,10 @@ export type ViewInputs = Readonly<{
|
|
|
425
425
|
}>;
|
|
426
426
|
/** The row the cursor is on as the view shows it with `commands`: the row the reader moved it
|
|
427
427
|
* to while that row is listed, else the page's `start` or `current` while the query finds it,
|
|
428
|
-
* else the first row the query finds; none when nothing is listed. Compare it before and after
|
|
429
|
-
* when the cursor fell to another row (its row left) and
|
|
430
|
-
* `ScrollToCursor`; a cursor whose row is still listed keeps
|
|
428
|
+
* else the first row the query finds; none when nothing is listed. Compare it before and after
|
|
429
|
+
* the caller's commands change to know when the cursor fell to another row (its row left) and
|
|
430
|
+
* should be scrolled into view with `ScrollToCursor`; a cursor whose row is still listed keeps
|
|
431
|
+
* it, and the list its scroll. */
|
|
431
432
|
export declare const maybeCursorId: (model: Model, commands: ReadonlyArray<Command>) => Option.Option<string>;
|
|
432
433
|
/**
|
|
433
434
|
* Type to find a command or a title; one inverted cursor row, moved by ↑ and ↓ only
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandPalette.d.ts","sourceRoot":"","sources":["../../../src/commandPalette/commandPalette.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,MAAM,EAAkB,MA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;;;;;;;;;IA9bf;oFACgF;cACtE,aAAa,CAAC,OAAO,CAAC;IAChC;wBACoB;YACZ,MAAM;IACd,mFAAmF;WAC5E,MAAM;IACb;;kCAE8B;mBACf,MAAM,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC;IACjD;0CACsC;uBACnB,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS;GA6b5C,CAAC"}
|
|
@@ -211,7 +211,7 @@ const maybeCurrentCursor = (model) => __foldkitBrandViewResult((Option.match(mod
|
|
|
211
211
|
onSome: (page) => __foldkitBrandViewResult((page.maybeCursor), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#onSome~5"),
|
|
212
212
|
})), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#maybeCurrentCursor");
|
|
213
213
|
const ARROW_STEP = { ArrowUp: -1, ArrowDown: 1 };
|
|
214
|
-
const
|
|
214
|
+
const isListed = (rows, rowId) => __foldkitBrandViewResult((Array.some(rows, (row) => __foldkitBrandViewResult((row.id === rowId), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~8"))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#isListed");
|
|
215
215
|
// NOTE: where the cursor is among the rows a key carries (see `Model`). With no arrows waiting
|
|
216
216
|
// it is the Model's cursor while that row is listed, else the shown one, so each key acts from
|
|
217
217
|
// where the last left it, also when several come before the next render; with arrows waiting,
|
|
@@ -219,11 +219,11 @@ const isListedIn = (rows, rowId) => __foldkitBrandViewResult((Array.some(rows, (
|
|
|
219
219
|
// key waits for the next render.
|
|
220
220
|
const cursorAsShown = (model, shown) => {
|
|
221
221
|
const { rows, maybeShownCursor, shownQuery, shownShift } = shown;
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
return __foldkitBrandViewResult((Option.some(Option.orElse(Option.filter(maybeCurrentCursor(model), (rowId) => __foldkitBrandViewResult((
|
|
222
|
+
const isTheList = shownQuery === query(model);
|
|
223
|
+
if (isTheList && model.cursorShift === 0) {
|
|
224
|
+
return __foldkitBrandViewResult((Option.some(Option.orElse(Option.filter(maybeCurrentCursor(model), (rowId) => __foldkitBrandViewResult((isListed(rows, rowId)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~9")), () => __foldkitBrandViewResult((maybeShownCursor), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~10")))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#cursorAsShown");
|
|
225
225
|
}
|
|
226
|
-
else if (
|
|
226
|
+
else if (isTheList && shownShift === model.cursorShift) {
|
|
227
227
|
return __foldkitBrandViewResult((Option.some(maybeShownCursor)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#cursorAsShown");
|
|
228
228
|
}
|
|
229
229
|
else {
|
|
@@ -347,12 +347,11 @@ const earlyKeySubscriptions = Subscription.make()((entry) => (__foldkitBrandView
|
|
|
347
347
|
* other record on the page uses: `subscriptions("palette")` is keyed `paletteEarlyKeys`. */
|
|
348
348
|
export const subscriptions = (keyPrefix) => __foldkitBrandViewResult((prefixKeys(keyPrefix, earlyKeySubscriptions)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#subscriptions");
|
|
349
349
|
const pageOf = (commands, state) => __foldkitBrandViewResult((pipe(Array.findFirst(commands, (command) => __foldkitBrandViewResult((command.id === state.commandId), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~23")), Option.flatMap((command) => __foldkitBrandViewResult((Option.fromNullishOr(command.page)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~24")), Option.map((page) => (__foldkitBrandViewResult(({ commandId: state.commandId, page, state }), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~25"))))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#pageOf");
|
|
350
|
-
const
|
|
351
|
-
const
|
|
352
|
-
const firstId = (rows) => __foldkitBrandViewResult((Option.map(Array.head(rows), (row) => __foldkitBrandViewResult((row.id), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~28"))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#firstId");
|
|
350
|
+
const firstListed = (rows, candidates) => __foldkitBrandViewResult((Array.findFirst(Array.getSomes(candidates), (cursorId) => __foldkitBrandViewResult((isListed(rows, cursorId)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~26"))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#firstListed");
|
|
351
|
+
const firstId = (rows) => __foldkitBrandViewResult((Option.map(Array.head(rows), (row) => __foldkitBrandViewResult((row.id), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~27"))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#firstId");
|
|
353
352
|
const shifted = (shown, shift) => (__foldkitBrandViewResult(({
|
|
354
353
|
...shown,
|
|
355
|
-
maybeCursorId: Option.map(rowAfter(shown.rows, shown.maybeCursorId, shift), (row) => __foldkitBrandViewResult((row.id), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
354
|
+
maybeCursorId: Option.map(rowAfter(shown.rows, shown.maybeCursorId, shift), (row) => __foldkitBrandViewResult((row.id), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~28")),
|
|
356
355
|
}), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#shifted"));
|
|
357
356
|
// NOTE: arrows waiting for the view count from the cursor's row. When that row has left the
|
|
358
357
|
// list (the application changed it in between), they are dropped rather than counted from
|
|
@@ -371,7 +370,7 @@ const shownOf = (model, commands) => {
|
|
|
371
370
|
// `start`, else its `current`, else the first row, these three only among the rows the query
|
|
372
371
|
// finds; none when nothing is listed.
|
|
373
372
|
const unshiftedOf = (model, commands) => {
|
|
374
|
-
const maybePage = Option.flatMap(model.maybePage, (state) => __foldkitBrandViewResult((pageOf(commands, state)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
373
|
+
const maybePage = Option.flatMap(model.maybePage, (state) => __foldkitBrandViewResult((pageOf(commands, state)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~29"));
|
|
375
374
|
return __foldkitBrandViewResult((Option.match(maybePage, {
|
|
376
375
|
onNone: () => {
|
|
377
376
|
const rows = findCommands(commands, model.query);
|
|
@@ -379,32 +378,32 @@ const unshiftedOf = (model, commands) => {
|
|
|
379
378
|
maybePage,
|
|
380
379
|
rows,
|
|
381
380
|
contextIds: HashSet.empty(),
|
|
382
|
-
maybeCursorId: pipe(Option.filter(model.maybeCursor, (rowId) => __foldkitBrandViewResult((isListed(rows, rowId)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
381
|
+
maybeCursorId: pipe(Option.filter(model.maybeCursor, (rowId) => __foldkitBrandViewResult((isListed(rows, rowId)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~30")), Option.orElse(() => __foldkitBrandViewResult((firstId(rows)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~31"))),
|
|
383
382
|
}), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#onNone~14");
|
|
384
383
|
},
|
|
385
384
|
onSome: ({ page, state }) => {
|
|
386
|
-
const { rows, found } = pageChoices(page, state.query);
|
|
387
|
-
const idsOf = (choices) => __foldkitBrandViewResult((HashSet.fromIterable(Array.map(choices, ({ id }) => __foldkitBrandViewResult((id), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~33")))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#idsOf");
|
|
385
|
+
const { rows, found, contextIds } = pageChoices(page, state.query);
|
|
388
386
|
return __foldkitBrandViewResult(({
|
|
389
387
|
maybePage,
|
|
390
388
|
rows,
|
|
391
|
-
contextIds
|
|
392
|
-
maybeCursorId: pipe(Option.filter(state.maybeCursor, (rowId) => __foldkitBrandViewResult((isListed(rows, rowId)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
389
|
+
contextIds,
|
|
390
|
+
maybeCursorId: pipe(Option.filter(state.maybeCursor, (rowId) => __foldkitBrandViewResult((isListed(rows, rowId)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~32")), Option.orElse(() => __foldkitBrandViewResult((firstListed(found, [
|
|
393
391
|
Option.fromNullishOr(page.start),
|
|
394
392
|
Option.fromNullishOr(page.current),
|
|
395
|
-
])), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
393
|
+
])), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~33")), Option.orElse(() => __foldkitBrandViewResult((firstId(found)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~34"))),
|
|
396
394
|
}), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#onSome~13");
|
|
397
395
|
},
|
|
398
396
|
})), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#unshiftedOf");
|
|
399
397
|
};
|
|
400
398
|
/** The row the cursor is on as the view shows it with `commands`: the row the reader moved it
|
|
401
399
|
* to while that row is listed, else the page's `start` or `current` while the query finds it,
|
|
402
|
-
* else the first row the query finds; none when nothing is listed. Compare it before and after
|
|
403
|
-
* when the cursor fell to another row (its row left) and
|
|
404
|
-
* `ScrollToCursor`; a cursor whose row is still listed keeps
|
|
400
|
+
* else the first row the query finds; none when nothing is listed. Compare it before and after
|
|
401
|
+
* the caller's commands change to know when the cursor fell to another row (its row left) and
|
|
402
|
+
* should be scrolled into view with `ScrollToCursor`; a cursor whose row is still listed keeps
|
|
403
|
+
* it, and the list its scroll. */
|
|
405
404
|
export const maybeCursorId = (model, commands) => __foldkitBrandViewResult((shownOf(model, commands).maybeCursorId), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#maybeCursorId");
|
|
406
405
|
const isCommand = (row) => __foldkitBrandViewResult(("group" in row), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#isCommand");
|
|
407
|
-
const isCurrentRow = (shown, row) => __foldkitBrandViewResult((Option.exists(shown.maybePage, ({ page }) => __foldkitBrandViewResult((page.current === row.id), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
406
|
+
const isCurrentRow = (shown, row) => __foldkitBrandViewResult((Option.exists(shown.maybePage, ({ page }) => __foldkitBrandViewResult((page.current === row.id), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~35"))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#isCurrentRow");
|
|
408
407
|
const isContextRow = (shown, row) => __foldkitBrandViewResult((HashSet.has(shown.contextIds, row.id)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#isContextRow");
|
|
409
408
|
const levelOf = (row) => __foldkitBrandViewResult(("level" in row ? Option.fromNullishOr(row.level) : Option.none()), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#levelOf");
|
|
410
409
|
// What a row is as this render shows it, which Enter acts on as a click would.
|
|
@@ -417,14 +416,14 @@ const shownRowFor = (shown, row) => (__foldkitBrandViewResult(({
|
|
|
417
416
|
// shows them (also for a page whose command left).
|
|
418
417
|
const shownQueryOf = (model, shown) => __foldkitBrandViewResult((Option.match(shown.maybePage, { onNone: () => __foldkitBrandViewResult((model.query), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#onNone~15"), onSome: ({ state }) => __foldkitBrandViewResult((state.query), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#onSome~14") })), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#shownQueryOf");
|
|
419
418
|
// The command whose page the view shows.
|
|
420
|
-
const shownPageIdOf = (shown) => __foldkitBrandViewResult((Option.map(shown.maybePage, ({ commandId }) => __foldkitBrandViewResult((commandId), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
419
|
+
const shownPageIdOf = (shown) => __foldkitBrandViewResult((Option.map(shown.maybePage, ({ commandId }) => __foldkitBrandViewResult((commandId), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~36"))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#shownPageIdOf");
|
|
421
420
|
// NOTE: the field's keys that act on the rows are taken here, where the rows are known, as a
|
|
422
421
|
// Mount on the document cannot know them: ↑, ↓ and Enter carry what this render shows (see
|
|
423
422
|
// `Model`), and each is taken from the field (its default prevented). A modified key and every
|
|
424
423
|
// key while a pick is out are left to the field.
|
|
425
424
|
const fieldKeyDown = (model, shown) => __foldkitBrandViewResult(((key, modifiers) => {
|
|
426
425
|
const list = {
|
|
427
|
-
rows: Array.map(shown.rows, (row) => __foldkitBrandViewResult((shownRowFor(shown, row)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
426
|
+
rows: Array.map(shown.rows, (row) => __foldkitBrandViewResult((shownRowFor(shown, row)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~38")),
|
|
428
427
|
maybeShownCursor: shown.maybeCursorId,
|
|
429
428
|
maybeShownPage: shownPageIdOf(shown),
|
|
430
429
|
shownQuery: shownQueryOf(model, shown),
|
|
@@ -432,7 +431,7 @@ const fieldKeyDown = (model, shown) => __foldkitBrandViewResult(((key, modifiers
|
|
|
432
431
|
};
|
|
433
432
|
return __foldkitBrandViewResult((isPicking(model) || !isPlain(modifiers)
|
|
434
433
|
? Option.none()
|
|
435
|
-
: Match.value(key).pipe(Match.withReturnType(), Match.whenOr("ArrowDown", "ArrowUp", (arrow) => __foldkitBrandViewResult((Option.some(Message.PressedArrowKey({ key: arrow, ...list }))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
434
|
+
: Match.value(key).pipe(Match.withReturnType(), Match.whenOr("ArrowDown", "ArrowUp", (arrow) => __foldkitBrandViewResult((Option.some(Message.PressedArrowKey({ key: arrow, ...list }))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~39")), Match.when("Enter", () => __foldkitBrandViewResult((Option.some(Message.PressedEnter(list))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~40")), Match.orElse(() => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~41")))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~37");
|
|
436
435
|
}), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#fieldKeyDown");
|
|
437
436
|
const optionId = (paletteId, index) => __foldkitBrandViewResult((`${paletteId}-option-${index}`), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#optionId");
|
|
438
437
|
const NOTHING_FOUND = "nothing matches · try fewer letters";
|
|
@@ -483,31 +482,31 @@ const rowView = (model, shown, row, index, h) => {
|
|
|
483
482
|
], rowPartsView(model, shown, row, h))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#rowView");
|
|
484
483
|
};
|
|
485
484
|
const groupedRows = (model, shown, h) => {
|
|
486
|
-
const indexed = Array.map(shown.rows, (row, index) => (__foldkitBrandViewResult(({ row, index }), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
485
|
+
const indexed = Array.map(shown.rows, (row, index) => (__foldkitBrandViewResult(({ row, index }), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~42")));
|
|
487
486
|
return __foldkitBrandViewResult((Option.match(shown.maybePage, {
|
|
488
|
-
onSome: () => __foldkitBrandViewResult((Array.map(indexed, ({ row, index }) => __foldkitBrandViewResult((rowView(model, shown, row, index, h)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
487
|
+
onSome: () => __foldkitBrandViewResult((Array.map(indexed, ({ row, index }) => __foldkitBrandViewResult((rowView(model, shown, row, index, h)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~43"))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#onSome~16"),
|
|
489
488
|
onNone: () => {
|
|
490
|
-
const groups = Array.dedupe(Array.map(shown.rows, (row) => (__foldkitBrandViewResult((isCommand(row) ? row.group : ""), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
489
|
+
const groups = Array.dedupe(Array.map(shown.rows, (row) => (__foldkitBrandViewResult((isCommand(row) ? row.group : ""), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~44"))));
|
|
491
490
|
return __foldkitBrandViewResult((Array.map(groups, (group, groupIndex) => {
|
|
492
491
|
const headingId = `${id(model)}-group-${groupIndex}`;
|
|
493
492
|
return __foldkitBrandViewResult((h.keyed("div")(`group-${group}`, [h.Role("group"), h.AriaLabelledBy(headingId)], [
|
|
494
493
|
h.div([h.Id(headingId), h.Role("presentation"), h.Class("palette-group")], [group]),
|
|
495
|
-
...Array.map(Array.filter(indexed, ({ row }) => __foldkitBrandViewResult((isCommand(row) && row.group === group), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
496
|
-
])), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
494
|
+
...Array.map(Array.filter(indexed, ({ row }) => __foldkitBrandViewResult((isCommand(row) && row.group === group), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~46")), ({ row, index }) => __foldkitBrandViewResult((rowView(model, shown, row, index, h)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~47")),
|
|
495
|
+
])), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~45");
|
|
497
496
|
})), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#onNone~17");
|
|
498
497
|
},
|
|
499
498
|
})), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#groupedRows");
|
|
500
499
|
};
|
|
501
500
|
const comboboxAttributes = (model, shown, noun, h) => {
|
|
502
501
|
const paletteId = id(model);
|
|
503
|
-
const maybeCursorIndex = Option.flatMap(shown.maybeCursorId, (cursorId) => __foldkitBrandViewResult((Array.findFirstIndex(shown.rows, (row) => __foldkitBrandViewResult((row.id === cursorId), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
502
|
+
const maybeCursorIndex = Option.flatMap(shown.maybeCursorId, (cursorId) => __foldkitBrandViewResult((Array.findFirstIndex(shown.rows, (row) => __foldkitBrandViewResult((row.id === cursorId), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~49"))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~48"));
|
|
504
503
|
return __foldkitBrandViewResult(([
|
|
505
504
|
h.OnKeyDownPreventDefault(fieldKeyDown(model, shown)),
|
|
506
505
|
h.Role("combobox"),
|
|
507
506
|
h.AriaExpanded(true),
|
|
508
507
|
h.AriaControls(listIdOf(paletteId)),
|
|
509
508
|
h.AriaAutocomplete("list"),
|
|
510
|
-
...Option.toArray(Option.map(maybeCursorIndex, (index) => __foldkitBrandViewResult((h.AriaActiveDescendant(optionId(paletteId, index))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
509
|
+
...Option.toArray(Option.map(maybeCursorIndex, (index) => __foldkitBrandViewResult((h.AriaActiveDescendant(optionId(paletteId, index))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~50"))),
|
|
511
510
|
h.AriaLabel(Option.match(shown.maybePage, {
|
|
512
511
|
onNone: () => __foldkitBrandViewResult((`Command or ${noun}`), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#onNone~18"),
|
|
513
512
|
onSome: ({ page }) => __foldkitBrandViewResult((page.title), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#onSome~17"),
|
|
@@ -541,9 +540,9 @@ const headView = (model, shown, scope, field, h) => __foldkitBrandViewResult((h.
|
|
|
541
540
|
isQuiet: true,
|
|
542
541
|
isDisabled: isPicking(model),
|
|
543
542
|
onClick: Message.ClickedBack(),
|
|
544
|
-
}, h)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
543
|
+
}, h)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~51"))),
|
|
545
544
|
h.span([h.Class("palette-scope")], [scope]),
|
|
546
|
-
...Option.toArray(Option.map(shown.maybePage, ({ page }) => __foldkitBrandViewResult((h.span([h.Class("palette-title")], [page.title])), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
545
|
+
...Option.toArray(Option.map(shown.maybePage, ({ page }) => __foldkitBrandViewResult((h.span([h.Class("palette-title")], [page.title])), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~52"))),
|
|
547
546
|
field,
|
|
548
547
|
])), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#headView");
|
|
549
548
|
const listView = (model, shown, h) => __foldkitBrandViewResult((h.div([
|
|
@@ -569,10 +568,10 @@ const countView = (model, shown, h) => {
|
|
|
569
568
|
: [countWords(shown.rows.length - HashSet.size(shown.contextIds))])), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#countView");
|
|
570
569
|
};
|
|
571
570
|
const cardView = (model, viewInputs, render, h) => {
|
|
572
|
-
const { commands, scope = "commands", noun = "title", toDetailView = () => __foldkitBrandViewResult(([]), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
571
|
+
const { commands, scope = "commands", noun = "title", toDetailView = () => __foldkitBrandViewResult(([]), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~53") } = viewInputs;
|
|
573
572
|
const shown = shownOf(model, commands);
|
|
574
573
|
return __foldkitBrandViewResult((h.div([
|
|
575
|
-
...Option.toArray(Option.map(shownPageIdOf(shown), (commandId) => __foldkitBrandViewResult((h.DataAttribute(PAGE_ATTRIBUTE, commandId)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
574
|
+
...Option.toArray(Option.map(shownPageIdOf(shown), (commandId) => __foldkitBrandViewResult((h.DataAttribute(PAGE_ATTRIBUTE, commandId)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~54"))),
|
|
576
575
|
h.OnMount(BindPaletteKeys()),
|
|
577
576
|
h.Class("card palette"),
|
|
578
577
|
], [
|
|
@@ -614,4 +613,4 @@ export const view = defineView((model, viewInputs, h) => __foldkitBrandViewResul
|
|
|
614
613
|
toView: (render) => __foldkitBrandViewResult((cardView(model, viewInputs, render, h)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#toView~2"),
|
|
615
614
|
},
|
|
616
615
|
toParentMessage: (message) => __foldkitBrandViewResult((Message.GotDialogMessage({ message })), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#toParentMessage~2"),
|
|
617
|
-
})), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~
|
|
616
|
+
})), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/commandPalette.js#anonymous~55"));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HashSet } from "effect";
|
|
1
2
|
import type { GlyphName } from "../glyph/glyphs.ts";
|
|
2
3
|
/** One row of the palette: a command, or a choice on a page. */
|
|
3
4
|
export type Choice = Readonly<{
|
|
@@ -45,11 +46,13 @@ export declare const matches: (query: string, label: string) => boolean;
|
|
|
45
46
|
export declare const findCommands: (commands: ReadonlyArray<Command>, query: string) => ReadonlyArray<Command>;
|
|
46
47
|
/** The choices a page's query finds. */
|
|
47
48
|
export declare const findChoices: (page: Page, query: string) => ReadonlyArray<Choice>;
|
|
48
|
-
/** What a page shows for its query: the choices it finds
|
|
49
|
-
*
|
|
49
|
+
/** What a page shows for its query: the choices it finds; the rows, which are those choices
|
|
50
|
+
* each with the choices it sits under in the page's tree, in the page's order; and the rows
|
|
51
|
+
* kept only for the choices under them. */
|
|
50
52
|
export type PageChoices = Readonly<{
|
|
51
53
|
rows: ReadonlyArray<Choice>;
|
|
52
54
|
found: ReadonlyArray<Choice>;
|
|
55
|
+
contextIds: HashSet.HashSet<string>;
|
|
53
56
|
}>;
|
|
54
57
|
export declare const pageChoices: (page: Page, query: string) => PageChoices;
|
|
55
58
|
//# sourceMappingURL=match.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../../src/commandPalette/match.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../../src/commandPalette/match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAA+B,MAAM,QAAQ,CAAC;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD,gEAAgE;AAChE,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;uBACmB;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;2CACuC;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;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|
@@ -21,12 +21,18 @@ export const findCommands = (commands, query) => {
|
|
|
21
21
|
const groupIndex = (command) => __foldkitBrandViewResult((Option.getOrElse(Array.findFirstIndex(groups, (group) => __foldkitBrandViewResult((group === command.group), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/match.js#anonymous~7")), () => __foldkitBrandViewResult((groups.length), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/match.js#anonymous~8"))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/match.js#groupIndex");
|
|
22
22
|
return __foldkitBrandViewResult((Array.sort(ordered, Order.mapInput(Order.Number, groupIndex))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/match.js#findCommands");
|
|
23
23
|
};
|
|
24
|
+
const isBlank = (query) => __foldkitBrandViewResult((String.isEmpty(String.trim(query))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/match.js#isBlank");
|
|
24
25
|
/** The choices a page's query finds. */
|
|
25
|
-
export const findChoices = (page, query) => __foldkitBrandViewResult((
|
|
26
|
+
export const findChoices = (page, query) => __foldkitBrandViewResult((isBlank(query)
|
|
26
27
|
? page.choices
|
|
27
28
|
: Array.filter(page.choices, (choice) => __foldkitBrandViewResult((matches(query, choice.label)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/match.js#anonymous~9"))), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/match.js#findChoices");
|
|
28
29
|
const WALK_START = { chain: [], keptIds: HashSet.empty() };
|
|
29
|
-
|
|
30
|
+
const unfiltered = (page) => (__foldkitBrandViewResult(({
|
|
31
|
+
rows: page.choices,
|
|
32
|
+
found: page.choices,
|
|
33
|
+
contextIds: HashSet.empty(),
|
|
34
|
+
}), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/match.js#unfiltered"));
|
|
35
|
+
const treeChoices = (page, query) => {
|
|
30
36
|
const found = findChoices(page, query);
|
|
31
37
|
const foundIds = HashSet.fromIterable(Array.map(found, ({ id }) => __foldkitBrandViewResult((id), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/match.js#anonymous~10")));
|
|
32
38
|
const { keptIds } = Array.reduce(page.choices, WALK_START, ({ chain, keptIds }, choice) => {
|
|
@@ -38,5 +44,10 @@ export const pageChoices = (page, query) => {
|
|
|
38
44
|
: keptIds,
|
|
39
45
|
}), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/match.js#anonymous~11");
|
|
40
46
|
});
|
|
41
|
-
return __foldkitBrandViewResult(({
|
|
47
|
+
return __foldkitBrandViewResult(({
|
|
48
|
+
rows: Array.filter(page.choices, ({ id }) => __foldkitBrandViewResult((HashSet.has(keptIds, id)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/match.js#anonymous~13")),
|
|
49
|
+
found,
|
|
50
|
+
contextIds: HashSet.difference(keptIds, foundIds),
|
|
51
|
+
}), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/match.js#treeChoices");
|
|
42
52
|
};
|
|
53
|
+
export const pageChoices = (page, query) => __foldkitBrandViewResult((isBlank(query) ? unfiltered(page) : treeChoices(page, query)), "@gjermundgaraba-designs/pixel-paper/src/commandPalette/match.js#pageChoices");
|
|
@@ -173,7 +173,8 @@ export declare const targetAtPoint: (subject: Subject, columns: ReadonlyArray<Co
|
|
|
173
173
|
/** What moving `splitter` by `share` asks of the layout, from the sizes the layout holds (not
|
|
174
174
|
* the sizes printed, which the stylesheet may hold at a minimum): a width splitter adds
|
|
175
175
|
* `share` to its column's width; a pane splitter moves `share` of its column's height from
|
|
176
|
-
* the pane below it to the pane above
|
|
176
|
+
* the pane below it to the pane above, leaving each a weight above nothing however small the
|
|
177
|
+
* column. None when what it sizes is gone. */
|
|
177
178
|
export declare const resizeOf: (layout: Layout, splitter: Splitter, share: number) => Option.Option<Resize>;
|
|
178
179
|
/** Whether what `splitter` sizes is still in `layout`. */
|
|
179
180
|
export declare const isSplitterPresent: (layout: Layout, splitter: Splitter) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot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) => __foldkitBrandViewResult((Arr
|
|
|
69
69
|
export const columnOf = (layout, columnId) => __foldkitBrandViewResult((Array.findFirst(layout, (column) => __foldkitBrandViewResult((column.id === columnId), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#anonymous~7"))), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#columnOf");
|
|
70
70
|
/** The id of the column after the one at `columnIndex`: none after the last. */
|
|
71
71
|
const nextColumnId = (layout, columnIndex) => __foldkitBrandViewResult((Option.map(Array.get(layout, columnIndex + 1), (column) => __foldkitBrandViewResult((column.id), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#anonymous~8"))), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#nextColumnId");
|
|
72
|
+
// a running mean, which never passes the largest weight, where the weights' sum may overflow
|
|
72
73
|
const meanWeight = (panes) => __foldkitBrandViewResult((Array.match(panes, {
|
|
73
74
|
onEmpty: () => __foldkitBrandViewResult((1), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#onEmpty"),
|
|
74
|
-
onNonEmpty: (some) => __foldkitBrandViewResult((
|
|
75
|
+
onNonEmpty: (some) => __foldkitBrandViewResult((Array.reduce(some, 0, (mean, pane, index) => __foldkitBrandViewResult((mean + (pane.weight - mean) / (index + 1)), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#anonymous~9"))), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#onNonEmpty"),
|
|
75
76
|
})), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#meanWeight");
|
|
76
77
|
const othersIn = (column, paneId) => __foldkitBrandViewResult((Array.filter(column.panes, (pane) => __foldkitBrandViewResult((pane.id !== paneId), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#anonymous~10"))), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#othersIn");
|
|
77
78
|
const insertAt = (items, index, item) => {
|
|
@@ -343,10 +344,20 @@ const WIDTH_FLOOR = 0.1;
|
|
|
343
344
|
const SHARE_FLOOR = 0.05;
|
|
344
345
|
const PRECISION = 10_000;
|
|
345
346
|
const rounded = (value) => __foldkitBrandViewResult((Math.round(value * PRECISION) / PRECISION), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#rounded");
|
|
347
|
+
/** `weight`, at least `floor`, to four decimals, or, where a step of four decimals is more than
|
|
348
|
+
* `floor` (a column whose weights total under a five-hundredth, or two panes that small), to
|
|
349
|
+
* the first power of ten no more than it, so that it never rounds to nothing. A weight too
|
|
350
|
+
* large or a floor too small to scale by that power is left as it is. */
|
|
351
|
+
const roundedOver = (weight, floor) => {
|
|
352
|
+
const precision = Math.max(PRECISION, 10 ** Math.ceil(-Math.log10(floor)));
|
|
353
|
+
const scaled = weight * precision;
|
|
354
|
+
return __foldkitBrandViewResult((globalThis.Number.isFinite(scaled) ? Math.round(scaled) / precision : weight), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#roundedOver");
|
|
355
|
+
};
|
|
346
356
|
/** What moving `splitter` by `share` asks of the layout, from the sizes the layout holds (not
|
|
347
357
|
* the sizes printed, which the stylesheet may hold at a minimum): a width splitter adds
|
|
348
358
|
* `share` to its column's width; a pane splitter moves `share` of its column's height from
|
|
349
|
-
* the pane below it to the pane above
|
|
359
|
+
* the pane below it to the pane above, leaving each a weight above nothing however small the
|
|
360
|
+
* column. None when what it sizes is gone. */
|
|
350
361
|
export const resizeOf = (layout, splitter, share) => __foldkitBrandViewResult((Splitter.match(splitter, {
|
|
351
362
|
Width: ({ columnId }) => __foldkitBrandViewResult((Option.map(columnOf(layout, columnId), (column) => __foldkitBrandViewResult((OutMessage.ResizedColumn({
|
|
352
363
|
columnId,
|
|
@@ -355,14 +366,21 @@ export const resizeOf = (layout, splitter, share) => __foldkitBrandViewResult((S
|
|
|
355
366
|
Split: ({ abovePaneId }) => __foldkitBrandViewResult((Option.flatMap(placeOf(layout, abovePaneId), ({ column, row, pane: above }) => __foldkitBrandViewResult((Option.map(Array.get(column.panes, row + 1), (below) => {
|
|
356
367
|
const total = Number.sumAll(Array.map(column.panes, ({ weight }) => __foldkitBrandViewResult((weight), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#anonymous~51")));
|
|
357
368
|
const pair = above.weight + below.weight;
|
|
358
|
-
|
|
369
|
+
// a column so small that a twentieth of it is no number keeps the least there is
|
|
370
|
+
const floor = Math.max(Math.min(total * SHARE_FLOOR, pair / 2), globalThis.Number.MIN_VALUE);
|
|
359
371
|
const nextAbove = Number.clamp(above.weight + share * total, {
|
|
360
372
|
minimum: floor,
|
|
361
373
|
maximum: pair - floor,
|
|
362
374
|
});
|
|
363
375
|
return __foldkitBrandViewResult((OutMessage.ResizedPanes({
|
|
364
376
|
columnId: column.id,
|
|
365
|
-
weights:
|
|
377
|
+
weights: globalThis.Number.isFinite(total)
|
|
378
|
+
? {
|
|
379
|
+
[above.id]: roundedOver(nextAbove, floor),
|
|
380
|
+
[below.id]: roundedOver(pair - nextAbove, floor),
|
|
381
|
+
}
|
|
382
|
+
: // weights that total past the largest number have no share to move: they stay
|
|
383
|
+
{ [above.id]: above.weight, [below.id]: below.weight },
|
|
366
384
|
})), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#anonymous~50");
|
|
367
385
|
})), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#anonymous~49"))), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#Split"),
|
|
368
386
|
})), "@gjermundgaraba-designs/pixel-paper/src/reel/layout.js#resizeOf");
|
package/package.json
CHANGED
|
@@ -329,7 +329,7 @@ type ShownList = Readonly<{
|
|
|
329
329
|
shownShift: number;
|
|
330
330
|
}>;
|
|
331
331
|
|
|
332
|
-
const
|
|
332
|
+
const isListed = (rows: ReadonlyArray<Readonly<{ id: string }>>, rowId: string): boolean =>
|
|
333
333
|
Array.some(rows, (row) => row.id === rowId);
|
|
334
334
|
|
|
335
335
|
// NOTE: where the cursor is among the rows a key carries (see `Model`). With no arrows waiting
|
|
@@ -339,16 +339,16 @@ const isListedIn = (rows: ReadonlyArray<ShownRow>, rowId: string): boolean =>
|
|
|
339
339
|
// key waits for the next render.
|
|
340
340
|
const cursorAsShown = (model: Model, shown: ShownList): Option.Option<Option.Option<string>> => {
|
|
341
341
|
const { rows, maybeShownCursor, shownQuery, shownShift } = shown;
|
|
342
|
-
const
|
|
342
|
+
const isTheList = shownQuery === query(model);
|
|
343
343
|
|
|
344
|
-
if (
|
|
344
|
+
if (isTheList && model.cursorShift === 0) {
|
|
345
345
|
return Option.some(
|
|
346
346
|
Option.orElse(
|
|
347
|
-
Option.filter(maybeCurrentCursor(model), (rowId) =>
|
|
347
|
+
Option.filter(maybeCurrentCursor(model), (rowId) => isListed(rows, rowId)),
|
|
348
348
|
() => maybeShownCursor,
|
|
349
349
|
),
|
|
350
350
|
);
|
|
351
|
-
} else if (
|
|
351
|
+
} else if (isTheList && shownShift === model.cursorShift) {
|
|
352
352
|
return Option.some(maybeShownCursor);
|
|
353
353
|
} else {
|
|
354
354
|
return Option.none();
|
|
@@ -583,9 +583,6 @@ const pageOf = (commands: ReadonlyArray<Command>, state: OpenPage): Option.Optio
|
|
|
583
583
|
Option.map((page) => ({ commandId: state.commandId, page, state })),
|
|
584
584
|
);
|
|
585
585
|
|
|
586
|
-
const isListed = (rows: ReadonlyArray<Choice | Command>, rowId: string): boolean =>
|
|
587
|
-
Array.some(rows, (row) => row.id === rowId);
|
|
588
|
-
|
|
589
586
|
const firstListed = (
|
|
590
587
|
rows: ReadonlyArray<Choice>,
|
|
591
588
|
candidates: ReadonlyArray<Option.Option<string>>,
|
|
@@ -633,13 +630,11 @@ const unshiftedOf = (model: Model, commands: ReadonlyArray<Command>): Shown => {
|
|
|
633
630
|
};
|
|
634
631
|
},
|
|
635
632
|
onSome: ({ page, state }) => {
|
|
636
|
-
const { rows, found } = pageChoices(page, state.query);
|
|
637
|
-
const idsOf = (choices: ReadonlyArray<Choice>) =>
|
|
638
|
-
HashSet.fromIterable(Array.map(choices, ({ id }) => id));
|
|
633
|
+
const { rows, found, contextIds } = pageChoices(page, state.query);
|
|
639
634
|
return {
|
|
640
635
|
maybePage,
|
|
641
636
|
rows,
|
|
642
|
-
contextIds
|
|
637
|
+
contextIds,
|
|
643
638
|
maybeCursorId: pipe(
|
|
644
639
|
Option.filter(state.maybeCursor, (rowId) => isListed(rows, rowId)),
|
|
645
640
|
Option.orElse(() =>
|
|
@@ -657,9 +652,10 @@ const unshiftedOf = (model: Model, commands: ReadonlyArray<Command>): Shown => {
|
|
|
657
652
|
|
|
658
653
|
/** The row the cursor is on as the view shows it with `commands`: the row the reader moved it
|
|
659
654
|
* to while that row is listed, else the page's `start` or `current` while the query finds it,
|
|
660
|
-
* else the first row the query finds; none when nothing is listed. Compare it before and after
|
|
661
|
-
* when the cursor fell to another row (its row left) and
|
|
662
|
-
* `ScrollToCursor`; a cursor whose row is still listed keeps
|
|
655
|
+
* else the first row the query finds; none when nothing is listed. Compare it before and after
|
|
656
|
+
* the caller's commands change to know when the cursor fell to another row (its row left) and
|
|
657
|
+
* should be scrolled into view with `ScrollToCursor`; a cursor whose row is still listed keeps
|
|
658
|
+
* it, and the list its scroll. */
|
|
663
659
|
export const maybeCursorId = (
|
|
664
660
|
model: Model,
|
|
665
661
|
commands: ReadonlyArray<Command>,
|
|
@@ -78,9 +78,11 @@ export const findCommands = (
|
|
|
78
78
|
return Array.sort(ordered, Order.mapInput(Order.Number, groupIndex));
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
+
const isBlank = (query: string): boolean => String.isEmpty(String.trim(query));
|
|
82
|
+
|
|
81
83
|
/** The choices a page's query finds. */
|
|
82
84
|
export const findChoices = (page: Page, query: string): ReadonlyArray<Choice> =>
|
|
83
|
-
|
|
85
|
+
isBlank(query)
|
|
84
86
|
? page.choices
|
|
85
87
|
: Array.filter(page.choices, (choice) => matches(query, choice.label));
|
|
86
88
|
|
|
@@ -88,14 +90,22 @@ type Walk = Readonly<{ chain: ReadonlyArray<Choice>; keptIds: HashSet.HashSet<st
|
|
|
88
90
|
|
|
89
91
|
const WALK_START: Walk = { chain: [], keptIds: HashSet.empty() };
|
|
90
92
|
|
|
91
|
-
/** What a page shows for its query: the choices it finds
|
|
92
|
-
*
|
|
93
|
+
/** What a page shows for its query: the choices it finds; the rows, which are those choices
|
|
94
|
+
* each with the choices it sits under in the page's tree, in the page's order; and the rows
|
|
95
|
+
* kept only for the choices under them. */
|
|
93
96
|
export type PageChoices = Readonly<{
|
|
94
97
|
rows: ReadonlyArray<Choice>;
|
|
95
98
|
found: ReadonlyArray<Choice>;
|
|
99
|
+
contextIds: HashSet.HashSet<string>;
|
|
96
100
|
}>;
|
|
97
101
|
|
|
98
|
-
|
|
102
|
+
const unfiltered = (page: Page): PageChoices => ({
|
|
103
|
+
rows: page.choices,
|
|
104
|
+
found: page.choices,
|
|
105
|
+
contextIds: HashSet.empty(),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const treeChoices = (page: Page, query: string): PageChoices => {
|
|
99
109
|
const found = findChoices(page, query);
|
|
100
110
|
const foundIds = HashSet.fromIterable(Array.map(found, ({ id }) => id));
|
|
101
111
|
const { keptIds } = Array.reduce(page.choices, WALK_START, ({ chain, keptIds }, choice): Walk => {
|
|
@@ -107,5 +117,12 @@ export const pageChoices = (page: Page, query: string): PageChoices => {
|
|
|
107
117
|
: keptIds,
|
|
108
118
|
};
|
|
109
119
|
});
|
|
110
|
-
return {
|
|
120
|
+
return {
|
|
121
|
+
rows: Array.filter(page.choices, ({ id }) => HashSet.has(keptIds, id)),
|
|
122
|
+
found,
|
|
123
|
+
contextIds: HashSet.difference(keptIds, foundIds),
|
|
124
|
+
};
|
|
111
125
|
};
|
|
126
|
+
|
|
127
|
+
export const pageChoices = (page: Page, query: string): PageChoices =>
|
|
128
|
+
isBlank(query) ? unfiltered(page) : treeChoices(page, query);
|
package/src/reel/layout.ts
CHANGED
|
@@ -111,10 +111,12 @@ export const columnOf = (layout: Layout, columnId: string): Option.Option<Column
|
|
|
111
111
|
const nextColumnId = (layout: Layout, columnIndex: number): Option.Option<string> =>
|
|
112
112
|
Option.map(Array.get(layout, columnIndex + 1), (column) => column.id);
|
|
113
113
|
|
|
114
|
+
// a running mean, which never passes the largest weight, where the weights' sum may overflow
|
|
114
115
|
const meanWeight = (panes: ReadonlyArray<Pane>): number =>
|
|
115
116
|
Array.match(panes, {
|
|
116
117
|
onEmpty: () => 1,
|
|
117
|
-
onNonEmpty: (some) =>
|
|
118
|
+
onNonEmpty: (some) =>
|
|
119
|
+
Array.reduce(some, 0, (mean, pane, index) => mean + (pane.weight - mean) / (index + 1)),
|
|
118
120
|
});
|
|
119
121
|
|
|
120
122
|
const othersIn = (column: Column, paneId: string): ReadonlyArray<Pane> =>
|
|
@@ -562,10 +564,21 @@ const PRECISION = 10_000;
|
|
|
562
564
|
|
|
563
565
|
const rounded = (value: number): number => Math.round(value * PRECISION) / PRECISION;
|
|
564
566
|
|
|
567
|
+
/** `weight`, at least `floor`, to four decimals, or, where a step of four decimals is more than
|
|
568
|
+
* `floor` (a column whose weights total under a five-hundredth, or two panes that small), to
|
|
569
|
+
* the first power of ten no more than it, so that it never rounds to nothing. A weight too
|
|
570
|
+
* large or a floor too small to scale by that power is left as it is. */
|
|
571
|
+
const roundedOver = (weight: number, floor: number): number => {
|
|
572
|
+
const precision = Math.max(PRECISION, 10 ** Math.ceil(-Math.log10(floor)));
|
|
573
|
+
const scaled = weight * precision;
|
|
574
|
+
return globalThis.Number.isFinite(scaled) ? Math.round(scaled) / precision : weight;
|
|
575
|
+
};
|
|
576
|
+
|
|
565
577
|
/** What moving `splitter` by `share` asks of the layout, from the sizes the layout holds (not
|
|
566
578
|
* the sizes printed, which the stylesheet may hold at a minimum): a width splitter adds
|
|
567
579
|
* `share` to its column's width; a pane splitter moves `share` of its column's height from
|
|
568
|
-
* the pane below it to the pane above
|
|
580
|
+
* the pane below it to the pane above, leaving each a weight above nothing however small the
|
|
581
|
+
* column. None when what it sizes is gone. */
|
|
569
582
|
export const resizeOf = (
|
|
570
583
|
layout: Layout,
|
|
571
584
|
splitter: Splitter,
|
|
@@ -584,14 +597,24 @@ export const resizeOf = (
|
|
|
584
597
|
Option.map(Array.get(column.panes, row + 1), (below) => {
|
|
585
598
|
const total = Number.sumAll(Array.map(column.panes, ({ weight }) => weight));
|
|
586
599
|
const pair = above.weight + below.weight;
|
|
587
|
-
|
|
600
|
+
// a column so small that a twentieth of it is no number keeps the least there is
|
|
601
|
+
const floor = Math.max(
|
|
602
|
+
Math.min(total * SHARE_FLOOR, pair / 2),
|
|
603
|
+
globalThis.Number.MIN_VALUE,
|
|
604
|
+
);
|
|
588
605
|
const nextAbove = Number.clamp(above.weight + share * total, {
|
|
589
606
|
minimum: floor,
|
|
590
607
|
maximum: pair - floor,
|
|
591
608
|
});
|
|
592
609
|
return OutMessage.ResizedPanes({
|
|
593
610
|
columnId: column.id,
|
|
594
|
-
weights:
|
|
611
|
+
weights: globalThis.Number.isFinite(total)
|
|
612
|
+
? {
|
|
613
|
+
[above.id]: roundedOver(nextAbove, floor),
|
|
614
|
+
[below.id]: roundedOver(pair - nextAbove, floor),
|
|
615
|
+
}
|
|
616
|
+
: // weights that total past the largest number have no share to move: they stay
|
|
617
|
+
{ [above.id]: above.weight, [below.id]: below.weight },
|
|
595
618
|
});
|
|
596
619
|
}),
|
|
597
620
|
),
|